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AAM,QAAa,MAAM,EAAM,aAC1B,EAOD,EAAS,WAAa,EAAK,QAN3B,EAAW,CACP,WAAY,EAAK,QAErB,WAAW,IAAI,EAAO,GAK9B,CACA,QAAQ,eAAe,EAAU,cACjC,MAAM,EAAO,EAAM,YACnB,EAAK,OAAO,OAAO,QAAU,GAAU,eAAe,QAChD,IAAK,eAAgB,MAAM,EAAM,cAAc,SAC/C,IAAK,SAAU,EAAS,MAAS,MACvC,OAAO,EAAM,GAAO,EACxB,CA7CA,GAAG,KAAK,QAAQ,qBAChB,GAAG,QAAQ,QAAQ,mBACnB,IAAI,kBAAkB,IAClB,IAAK,MAAM,KAAS,EAChB,IAAK,MAAM,KAAQ,EAAM,WAAY,CACjC,MAAM,EAAQ,SAAS,mBAAmB,EAAM,WAAW,aAAc,CACrE,WAAW,GACA,CAAC,OAAQ,KAAK,SAAS,EAAK,WAC7B,WAAW,cACX,WAAW,gBAGzB,IAAI,EACJ,KAAQ,EAAU,EAAM,YACM,MAAtB,EAAQ,UACR,oBAAoB,GAGpB,kBAAkB,EAG9B,CACJ,IACD,QAAQ,SAAS,KAAM,CAAE,WAAW,EAAM,SAAS","file":"/npm/router-dom@3.0.3/dist/router.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/router-dom@3.0.3/dist/router.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { pathToRegexp, match } from \"path-to-regexp\";\nimport { render, html, hydro, $, $$, setReuseElements } from \"hydro-js\";\nlet router;\nconst storageKey = \"router-scroll\";\nconst outletSelector = \"[data-outlet]\";\nconst reactivityRegex = /\\{\\{([^]*?)\\}\\}/;\nconst fetchCache = new WeakMap();\nlet base = $(\"base\")?.getAttribute(\"href\") || \"\";\nif (base.endsWith(\"/\")) {\n    base = [...base].slice(0, -1).join(\"\");\n}\naddEventListener(\"popstate\", async (e) => {\n    router?.doRouting(location.pathname + location.search, e);\n});\n// Reload -> store scrollPosition\naddEventListener(\"beforeunload\", () => sessionStorage.setItem(`${storageKey}-${location.pathname + location.search}`, `${scrollX} ${scrollY}`));\nexport default class Router {\n    options;\n    routes;\n    oldRoute;\n    constructor(routes, options = {}) {\n        // Handle nested routes\n        const length = routes.length - 1;\n        for (let i = length; i >= 0; i--) {\n            const route = routes[i];\n            if (route.children) {\n                route.children.forEach((child, idx) => {\n                    routes.splice(i + idx, 0, {\n                        ...child,\n                        path: `${route.path}/${child.path}`,\n                        isChildOf: route,\n                    });\n                });\n                Reflect.deleteProperty(route, \"children\");\n            }\n        }\n        const newRoutes = routes.map((route) => {\n            return {\n                restoreScroll: true,\n                ...route,\n                path: pathToRegexp(base + route.path),\n                originalPath: base + route.path,\n            };\n        });\n        this.routes = newRoutes;\n        this.options = options;\n        router = this;\n        // Prefetch resources\n        this.routes.forEach((route) => {\n            // @ts-expect-error\n            if (route.templateUrl && !navigator.connection?.saveData) {\n                const controller = new AbortController();\n                const cache = { promise: null, controller };\n                fetchCache.set(route, cache);\n                setTimeout(() => {\n                    requestIdleCallback(() => {\n                        cache.promise = fetch(route.templateUrl, {\n                            signal: controller.signal,\n                        });\n                        cache.promise\n                            .then((res) => res.text())\n                            .then((_html) => {\n                            cache.html = _html;\n                        })\n                            .catch(async (err) => {\n                            await this.options.errorHandler?.(err);\n                        });\n                    });\n                });\n            }\n        });\n        this.doRouting();\n    }\n    getMatchingRoute(path) {\n        if (path.startsWith(\".\")) {\n            path = path.replace(\".\", \"\");\n        }\n        return this.routes.find((route) => route.path.exec(path));\n    }\n    async doRouting(to = location.pathname + location.search, e) {\n        dispatchEvent(new Event(\"beforeRouting\"));\n        const from = this.oldRoute ?? to;\n        const route = this.getMatchingRoute(to);\n        if (route) {\n            // Store position\n            let currStorageKey;\n            if (this.oldRoute) {\n                currStorageKey = `${storageKey}-${from}`;\n                sessionStorage.setItem(currStorageKey, `${scrollX} ${scrollY}`);\n            }\n            try {\n                const { params } = match(route.originalPath, {\n                    decode: decodeURIComponent,\n                })(to);\n                const allParams = {\n                    ...Router.getParams(),\n                    ...Object.fromEntries(Object.entries(params)\n                        .map((pair) => Number.isNaN(Number(pair[0])) && pair)\n                        .filter(Boolean)),\n                };\n                const props = {\n                    from: from.replace(base, \"\"),\n                    to: to.replace(base, \"\"),\n                    ...(Object.keys(allParams).length ? { params: allParams } : {}),\n                    ...(history.state && Object.keys(history.state).length\n                        ? { state: history.state }\n                        : {}),\n                };\n                // Trigger leave\n                if (this.oldRoute) {\n                    const oldRoute = this.routes.find((route) => route.path.exec(this.oldRoute));\n                    if (oldRoute) {\n                        await oldRoute[\"leave\" /* cycles.leave */]?.(props);\n                        this.oldRoute = route.originalPath;\n                    }\n                }\n                // Trigger beforeEnter\n                await route[\"beforeEnter\" /* cycles.beforeEnter */]?.(props);\n                // Handle template / element\n                if (!!route.isChildOf) {\n                    setReuseElements(false);\n                    const parent = route.isChildOf;\n                    if (parent.templateUrl) {\n                        await handleTemplate(parent, $(outletSelector));\n                    }\n                    else if (parent.element) {\n                        const copy = $(outletSelector).cloneNode();\n                        copy.append(html `${parent.element}`);\n                        render(copy, outletSelector, false);\n                    }\n                    setReuseElements(true);\n                }\n                const where = route.isChildOf\n                    ? $(outletSelector).querySelector(outletSelector)\n                    : $(outletSelector);\n                if (route?.templateUrl) {\n                    await handleTemplate(route, where);\n                }\n                else if (route?.element) {\n                    const copy = where.cloneNode();\n                    copy.append(html `${route.element}`);\n                    render(copy, where, false);\n                }\n                else {\n                    // Clear outlet\n                    $(outletSelector).textContent = null;\n                }\n                currStorageKey = `${storageKey}-${to}`;\n                // Trigger afterEnter\n                await route[\"afterEnter\" /* cycles.afterEnter */]?.(props);\n            }\n            catch (err) {\n                if (this.options.errorHandler) {\n                    await this.options.errorHandler(err, e);\n                }\n                else {\n                    console.error(err, e);\n                }\n            }\n            finally {\n                // Reload -> restore scroll position\n                if (route.restoreScroll && sessionStorage.getItem(currStorageKey)) {\n                    const [left, top] = sessionStorage\n                        .getItem(currStorageKey)\n                        .split(\" \")\n                        .map(Number);\n                    sessionStorage.removeItem(currStorageKey);\n                    scrollTo({\n                        top,\n                        left,\n                        behavior: this.options.scrollBehavior || \"auto\",\n                    });\n                }\n                else {\n                    // Reset Scroll, just like Browser\n                    if (!window.isHMR) {\n                        scrollTo({\n                            top: 0,\n                            left: 0,\n                            behavior: this.options.scrollBehavior || \"auto\",\n                        });\n                    }\n                }\n                dispatchEvent(new Event(\"afterRouting\"));\n            }\n        }\n    }\n    go(path, state, params = \"\") {\n        this.oldRoute = location.pathname + location.search;\n        const newPath = base + path + params;\n        // Only navigate when the path differs\n        if (newPath !== this.oldRoute) {\n            history.pushState({ ...state }, \"\", newPath);\n            this.doRouting(newPath);\n        }\n    }\n    removeRoute(path) {\n        const idx = this.routes.findIndex((route) => String(route.path) === String(pathToRegexp(path)));\n        if (idx > -1) {\n            this.routes.splice(idx, 1);\n        }\n    }\n    addRoute(route) {\n        this.routes.push({\n            ...route,\n            path: pathToRegexp(base + route.path),\n            originalPath: base + route.path,\n        });\n    }\n    modifyRoute(path, newRoute) {\n        const idx = this.routes.findIndex((route) => String(route.path) === String(pathToRegexp(path)));\n        if (idx > -1) {\n            this.routes[idx] = {\n                ...newRoute,\n                path: pathToRegexp(base + newRoute.path),\n                originalPath: base + path,\n            };\n        }\n    }\n    changeOptions(options) {\n        this.options = options;\n    }\n    static getParams(search = location.search) {\n        return Object.fromEntries(new URLSearchParams(search));\n    }\n}\nfunction registerAnchorEvent(anchor) {\n    if (anchor.getAttribute(\"href\")?.startsWith(\"http\"))\n        return;\n    anchor.addEventListener(\"click\", (e) => {\n        e.preventDefault();\n        const hasData = anchor.getAttribute(\"data\");\n        const hydroProp = replaceBars(hasData);\n        const href = anchor.getAttribute(\"href\") || \"\";\n        router.go(href, hasData ? hydro[hydroProp] : void 0);\n    });\n}\nfunction registerFormEvent(form) {\n    form.addEventListener(\"submit\", (e) => {\n        if (!router.options.formHandler)\n            return;\n        e.preventDefault();\n        const action = form.getAttribute(\"action\");\n        const method = form.getAttribute(\"method\");\n        fetch(action, {\n            method,\n            ...(![\"HEAD\", \"GET\"].includes(method.toUpperCase())\n                ? { body: new FormData(form) }\n                : {}),\n            ...router.options.fetchOptions,\n        })\n            .then((res) => router.options.formHandler(res, e))\n            .catch(async (err) => {\n            if (router.options.errorHandler) {\n                await router.options.errorHandler(err, e);\n            }\n            else {\n                console.error(err, e);\n            }\n        });\n    });\n}\nfunction replaceBars(hydroTerm) {\n    if (hydroTerm === null || !hydroTerm.includes(\"{{\"))\n        return hydroTerm;\n    const [_, hydroPath] = hydroTerm.match(reactivityRegex) || [];\n    return hydroPath;\n}\n// Add EventListener for every added anchor and form Element\n$$(\"a\").forEach(registerAnchorEvent);\n$$(\"form\").forEach(registerFormEvent);\nnew MutationObserver((entries) => {\n    for (const entry of entries) {\n        for (const node of entry.addedNodes) {\n            const nodes = document.createNodeIterator(node, NodeFilter.SHOW_ELEMENT, {\n                acceptNode(elem) {\n                    return [\"form\", \"a\"].includes(elem.localName)\n                        ? NodeFilter.FILTER_ACCEPT\n                        : NodeFilter.FILTER_REJECT;\n                },\n            });\n            let formOrA;\n            while ((formOrA = nodes.nextNode())) {\n                if (formOrA.localName === \"a\") {\n                    registerAnchorEvent(formOrA);\n                }\n                else {\n                    registerFormEvent(formOrA);\n                }\n            }\n        }\n    }\n}).observe(document.body, { childList: true, subtree: true });\nasync function handleTemplate(route, where) {\n    let cacheObj = fetchCache.get(route);\n    if (!fetchCache.has(route) || cacheObj?.promise === null) {\n        cacheObj?.controller?.abort();\n        const data = await fetch(route.templateUrl);\n        if (!cacheObj) {\n            cacheObj = {\n                html: await data.text(),\n            };\n            fetchCache.set(route, cacheObj);\n        }\n        else {\n            cacheObj.html = await data.text();\n        }\n    }\n    Reflect.deleteProperty(cacheObj, \"controller\");\n    const copy = where.cloneNode();\n    copy.append(window.isHMR || !cacheObj?.hasOwnProperty(\"html\")\n        ? html `${await (await fetch(route.templateUrl)).text()}`\n        : html `${(await cacheObj.html) || \"\"}`);\n    render(copy, where, false);\n}\n"]}