import {k as S, ah as L, o as m} from "./index.RAAV9mvH.js";
import "./index.tZu5qiVQ.js";
const p = document.getElementById("auth-action")
  , T = JSON.parse(p?.dataset.authmode || "false");
T ? S.init() : p?.remove();
const v = new Set
  , i = new WeakSet;
let c, w, h = !1;
function A(e) {
    h || (h = !0,
    c ??= e?.prefetchAll ?? !1,
    w ??= e?.defaultStrategy ?? "hover",
    k(),
    H(), 
    M())
}
function k() {
    for (const e of ["touchstart", "mousedown"])
        document.body.addEventListener(e, t=>{
            s(t.target, "tap") && f(t.target.href, {
                with: "fetch",
                ignoreSlowConnection: !0
            })
        }
        , {
            passive: !0
        })
}
function H() {
    let e;
    document.body.addEventListener("focusin", o=>{
        s(o.target, "hover") && t(o)
    }
    , {
        passive: !0
    }),
    document.body.addEventListener("focusout", n, {
        passive: !0
    }),
    b(()=>{
        for (const o of document.getElementsByTagName("a"))
            i.has(o) || s(o, "hover") && (i.add(o),
            o.addEventListener("mouseenter", t, {
                passive: !0
            }),
            o.addEventListener("mouseleave", n, {
                passive: !0
            }))
    }
    );
    function t(o) {
        const r = o.target.href;
        e && clearTimeout(e),
        e = setTimeout(()=>{
            f(r, {
                with: "fetch"
            })
        }
        , 80)
    }
    function n() {
        e && (clearTimeout(e),
        e = 0)
    }
}
function M() {
    let e;
    b(()=>{
        for (const t of document.getElementsByTagName("a"))
            i.has(t) || s(t, "viewport") && (i.add(t),
            e ??= R(),
            e.observe(t))
    }
    )
}
function R() {
    const e = new WeakMap;
    return new IntersectionObserver((t,n)=>{
        for (const o of t) {
            const r = o.target
              , a = e.get(r);
            o.isIntersecting ? (a && clearTimeout(a),
            e.set(r, setTimeout(()=>{
                n.unobserve(r),
                e.delete(r),
                f(r.href, {
                    with: "link"
                })
            }
            , 300))) : a && (clearTimeout(a),
            e.delete(r))
        }
    }
    )
}
function f(e, t) {
    const n = t?.ignoreSlowConnection ?? !1;
    if (!V(e, n))
        return;
    if (v.add(e),
    (t?.with ?? "link") === "link") {
        const r = document.createElement("link");
        r.rel = "prefetch",
        r.setAttribute("href", e),
        document.head.append(r)
    } else
        fetch(e).catch(r=>{
            console.log(`[astro] Failed to prefetch ${e}`),
            console.error(r)
        }
        )
}
function V(e, t) {
    if (!navigator.onLine || !t && y())
        return !1;
    try {
        const n = new URL(e,location.href);
        return location.origin === n.origin && (location.pathname !== n.pathname || location.search !== n.search) && !v.has(e)
    } catch {}
    return !1
}
function s(e, t) {
    if (e?.tagName !== "A")
        return !1;
    const n = e.dataset.astroPrefetch;
    return n === "false" ? !1 : t === "tap" && (n != null || c) && y() ? !0 : n == null && c || n === "" ? t === w : n === t
}
function y() {
    if ("connection"in navigator) {
        const e = navigator.connection;
        return e.saveData || /(2|3)g/.test(e.effectiveType)
    }
    return !1
}
function b(e) {
    e();
    let t = !1;
    document.addEventListener("astro:page-load", ()=>{
        if (!t) {
            t = !0;
            return
        }
        e()
    }
    )
}
function D() {
    const e = document.querySelector('[name="astro-view-transitions-fallback"]');
    return e ? e.getAttribute("content") : "animate"
}
function g(e) {
    return e.dataset.astroReload !== void 0
}
(L || D() !== "none") && (document.addEventListener("click", e=>{
    let t = e.target;
    if (t instanceof Element && (t = t.closest("a, area")),
    !(t instanceof HTMLAnchorElement) && !(t instanceof SVGAElement) && !(t instanceof HTMLAreaElement))
        return;
    const n = t instanceof HTMLElement ? t.target : t.target.baseVal
      , o = t instanceof HTMLElement ? t.href : t.href.baseVal
      , r = new URL(o,location.href).origin;
    g(t) || t.hasAttribute("download") || !t.href || n && n !== "_self" || r !== location.origin || e.button !== 0 || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey || e.defaultPrevented || (e.preventDefault(),
    m(o, {
        history: t.dataset.astroHistory === "replace" ? "replace" : "auto",
        sourceElement: t
    }))
}
),
document.addEventListener("submit", e=>{
    let t = e.target;
    if (t.tagName !== "FORM" || g(t))
        return;
    const n = t
      , o = e.submitter
      , r = new FormData(n,o);
    let a = o?.getAttribute("formaction") ?? n.action ?? location.pathname;
    const l = o?.getAttribute("formmethod") ?? n.method;
    if (l === "dialog")
        return;
    const u = {
        sourceElement: o ?? n
    };
    if (l === "get") {
        const E = new URLSearchParams(r)
          , d = new URL(a);
        d.search = E.toString(),
        a = d.toString()
    } else
        u.formData = r;
    e.preventDefault(),
    m(a, u)
}
),
A({
    prefetchAll: !0
}));
