@krate/runtime 0.5.0-rc.3 → 0.5.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,8 @@ export interface CacheScope {
28
28
  revalidate: number;
29
29
  /** True when a read opted out of caching (no-store, revalidate 0, unstable_noStore). */
30
30
  noStore: boolean;
31
+ /** True when an error boundary caught a render error (the response is a 500 and uncacheable). */
32
+ errorCaught?: boolean;
31
33
  }
32
34
  /** Minimal AsyncLocalStorage shape (the Node class satisfies it). */
33
35
  export interface AsyncStore<T> {
@@ -118,6 +120,8 @@ export declare function routeDataTag(route: string): string;
118
120
  export declare function recordCacheRead(tags: readonly string[] | undefined, revalidate: number | false | undefined): void;
119
121
  /** Marks the current render as uncacheable. Outside a render it has no effect. */
120
122
  export declare function markNoStore(): void;
123
+ /** Marks the current render as having shown an error boundary's UI. */
124
+ export declare function markErrorCaught(): void;
121
125
  /**
122
126
  * Reads a JSON value from the data cache; undefined on a miss. With a shared
123
127
  * cache the instances' common store answers; when it cannot, this process's own
@@ -178,6 +178,14 @@ export function markNoStore() {
178
178
  if (scope)
179
179
  scope.noStore = true;
180
180
  }
181
+ /** Marks the current render as having shown an error boundary's UI. */
182
+ export function markErrorCaught() {
183
+ const scope = currentRenderScope();
184
+ if (scope) {
185
+ scope.errorCaught = true;
186
+ scope.noStore = true;
187
+ }
188
+ }
181
189
  // Data cache access. In QuickJS the Go host owns the cache (shared by every
182
190
  // VM worker and invalidated with the rest of the host's caches); values cross
183
191
  // the bridge as JSON.
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},U=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of q(t))!B.call(e,r)&&r!==n&&w(e,r,{get:()=>t[r],enumerable:!(o=L(t,r))||o.enumerable});return e};var G=e=>U(w({},"__esModule",{value:!0}),e);var ne={};H(ne,{forbidden:()=>b,krateResetNavigation:()=>K,notFound:()=>y,permanentRedirect:()=>te,redirect:()=>I,unauthorized:()=>C,useParams:()=>z,usePathname:()=>W,useRouter:()=>Q,useSearchParams:()=>j,useSelectedLayoutSegment:()=>ee,useSelectedLayoutSegments:()=>Z});var v=window.createSignal;var c=window.krateDerived;var X=Symbol.for("krate.request.store");function i(){let e=globalThis[X];return e&&typeof e.getStore=="function"?e.getStore():void 0}function y(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function T(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function b(){return T(403)}function C(){return T(401)}function k(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},o=[];for(let r of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!s){o.push(r);continue}let u=n[s[3]];u!==void 0&&u!==""&&o.push(...u.split("/").filter(Boolean))}return{path:"/"+o.join("/"),route:t,params:n}}function m(e){try{return decodeURIComponent(e)}catch{return e}}function _(){return k().path}function A(){let e=i(),t=new URLSearchParams;for(let[n,o]of Object.entries(e&&e.searchParams||{}))t.append(n,String(o));return t}function E(){let{route:e,params:t}=k(),n={};for(let o of e.split("/").filter(Boolean)){let r=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!r)continue;let s=t[r[3]];s===void 0||s===""||(n[r[3]]=r[2]?s.split("/").filter(Boolean).map(m):m(s))}return n}function d(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function N(){return{push:d("push"),replace:d("replace"),back:d("back"),forward:d("forward"),refresh:d("refresh"),prefetch:()=>{}}}function S(e,t){return k().path.split("/").filter(Boolean).map(m).slice(typeof t=="number"?t:0)}function P(e,t){let n=S(e,t);return n.length>0?n[0]:null}var O=window.getNavigationState,F=window.subscribeNavigation,a=window.krateRouter;function M(){let e=globalThis.__KRATE_ROUTE__;if(typeof e=="string")return e;if(typeof document>"u")return"";let t=document.getElementById("__krate_page");if(!t)return"";try{let n=JSON.parse(t.textContent||"{}");return typeof n.r=="string"?n.r:""}catch{return""}}function V(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}function D(){if(typeof location>"u")return{pathname:"/",search:"",route:""};let{pathname:e,search:t}=O();return{pathname:V(e),search:t,route:M()}}var g=null;function f(){if(g)return g;let[e,t]=v(D());if(g=e,typeof window<"u"){let n=()=>{let o=D(),r=e();(o.pathname!==r.pathname||o.search!==r.search||o.route!==r.route)&&t(o)};F(n),window.addEventListener("krate:navigate-end",n)}return e}function K(){g=null}function p(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function W(){if(i())return _();let e=f(),t=c(()=>e().pathname);return p(t,()=>t())}function j(){if(i())return A();let e=f(),t=c(()=>new URLSearchParams(e().search));return p(t,()=>e().search)}function l(e){try{return decodeURIComponent(e)}catch{return e}}function $(e,t){let n={};if(!e)return n;let o=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean);for(let s=0;s<o.length;s++){let u=o[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(u);if(!h)continue;let x=h[3];if(h[2]){let R=r.slice(s).map(l);return R.length>0&&(n[x]=R),n}s<r.length&&(n[x]=l(r[s]))}return n}function z(){if(i())return E();let e=f(),t=c(()=>{let n=e();return $(n.route,n.pathname)});return p(t,()=>JSON.stringify(t()))}var Y={push:(e,t)=>{a.push(e,t)},replace:(e,t)=>{a.replace(e,t)},back:()=>a.back(),forward:()=>a.forward(),refresh:()=>{a.refresh()},prefetch:e=>{a.prefetch(e)}};function Q(){return i()?N():Y}function Z(e,t){if(i())return S(e,t);let n=f(),o=typeof t=="number"?t:0,r=c(()=>n().pathname.split("/").filter(Boolean).map(l).slice(o));return p(r,()=>r().join("/"))}function ee(e,t){if(i())return P(e,t);let n=f(),o=typeof t=="number"?t:0,r=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(l);return s.length>o?s[o]:null});return p(r,()=>String(r()))}function I(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function te(e){return I(e)}return G(ne);})();
1
+ var __krate_exports=(()=>{var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},U=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of q(t))!B.call(e,r)&&r!==n&&w(e,r,{get:()=>t[r],enumerable:!(o=L(t,r))||o.enumerable});return e};var G=e=>U(w({},"__esModule",{value:!0}),e);var ne={};H(ne,{forbidden:()=>b,krateResetNavigation:()=>K,notFound:()=>y,permanentRedirect:()=>te,redirect:()=>I,unauthorized:()=>C,useParams:()=>z,usePathname:()=>W,useRouter:()=>Q,useSearchParams:()=>j,useSelectedLayoutSegment:()=>ee,useSelectedLayoutSegments:()=>Z});var v=window.createSignal;var c=window.krateDerived;var X=Symbol.for("krate.request.store");function i(){let e=globalThis[X];return e&&typeof e.getStore=="function"?e.getStore():void 0}function y(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function T(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function b(){return T(403)}function C(){return T(401)}function k(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},o=[];for(let r of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!s){o.push(r);continue}let u=n[s[3]];u!==void 0&&u!==""&&o.push(...u.split("/").filter(Boolean))}return{path:"/"+o.join("/"),route:t,params:n}}function m(e){try{return decodeURIComponent(e)}catch{return e}}function _(){return k().path}function A(){let e=i(),t=new URLSearchParams;for(let[n,o]of Object.entries(e&&e.searchParams||{}))t.append(n,String(o));return t}function E(){let{route:e,params:t}=k(),n={};for(let o of e.split("/").filter(Boolean)){let r=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!r)continue;let s=t[r[3]];s===void 0||s===""||(n[r[3]]=r[2]?s.split("/").filter(Boolean).map(m):m(s))}return n}function d(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function N(){return{push:d("push"),replace:d("replace"),back:d("back"),forward:d("forward"),refresh:d("refresh"),prefetch:()=>{}}}function S(e,t){return k().path.split("/").filter(Boolean).map(m).slice(typeof t=="number"?t:0)}function P(e,t){let n=S(e,t);return n.length>0?n[0]:null}var O=window.getNavigationState,F=window.subscribeNavigation,a=window.krateRouter;function M(){let e=globalThis.__KRATE_ROUTE__;if(typeof e=="string")return e;if(typeof document>"u")return"";let t=document.getElementById("__krate_page");if(!t)return"";try{let n=JSON.parse(t.textContent||"{}");return typeof n.r=="string"?n.r:""}catch{return""}}function V(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}function D(){if(typeof location>"u")return{pathname:"/",search:"",route:""};let{pathname:e,search:t}=O();return{pathname:V(e),search:t,route:M()}}var p=null;function f(){if(p)return p;let[e,t]=v(D());if(p=e,typeof window<"u"){let n=()=>{let o=D(),r=e();(o.pathname!==r.pathname||o.search!==r.search||o.route!==r.route)&&t(o)};F(n),window.addEventListener("krate:navigate-end",n)}return e}function K(){p=null}function g(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function W(){if(i())return _();let e=f(),t=c(()=>e().pathname);return g(t,()=>t())}function j(){if(i())return A();let e=f(),t=c(()=>new URLSearchParams(e().search));return g(t,()=>e().search)}function l(e){try{return decodeURIComponent(e)}catch{return e}}function $(e,t){let n={};if(!e)return n;let o=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean);for(let s=0;s<o.length;s++){let u=o[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(u);if(!h)continue;let x=h[3];if(h[2]){let R=r.slice(s).map(l);return R.length>0&&(n[x]=R),n}s<r.length&&(n[x]=l(r[s]))}return n}function z(){if(i())return E();let e=f(),t=c(()=>{let n=e();return $(n.route,n.pathname)});return g(t,()=>JSON.stringify(t()))}var Y={push:(e,t)=>{a.push(e,t)},replace:(e,t)=>{a.replace(e,t)},back:()=>a.back(),forward:()=>a.forward(),refresh:()=>{a.refresh()},prefetch:e=>{a.prefetch(e)}};function Q(){return i()?N():Y}function Z(e,t){if(i())return S(e,t);let n=f(),o=typeof t=="number"?t:0,r=c(()=>n().pathname.split("/").filter(Boolean).map(l).slice(o));return g(r,()=>r().join("/"))}function ee(e,t){if(i())return P(e,t);let n=f(),o=typeof t=="number"?t:0,r=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(l);return s.length>o?s[o]:null});return g(r,()=>String(r()))}function I(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function te(e){return I(e)}return G(ne);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var ft=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var ve=(t,e)=>{for(var n in e)ft(t,n,{get:e[n],enumerable:!0})},ke=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ge(e))!ye.call(t,o)&&o!==n&&ft(t,o,{get:()=>e[o],enumerable:!(r=me(e,o))||r.enumerable});return t};var be=t=>ke(ft({},"__esModule",{value:!0}),t);var sn={};ve(sn,{compareRouteSpecificity:()=>qt,destroyRouter:()=>on,getHistoryState:()=>xe,getNavigationState:()=>Ft,initRouter:()=>he,invalidatePrefetchCache:()=>Et,krateRouter:()=>en,matchRoutePattern:()=>Zt,navigate:()=>nn,pageAssetURLs:()=>Ot,reinitRouter:()=>rn,subscribeNavigation:()=>Wt});var we="__krate_cfg__";function Q(){let t=globalThis;if(t.__KRATE_CFG__)return t.__KRATE_CFG__;let e=t.document,n=e&&typeof e.getElementById=="function"?e.getElementById(we):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return t.__KRATE_CFG__=r,r}catch{}return{}}function U(){let t=Q(),e=t&&t.basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function C(t){let e=U();return e&&t.charCodeAt(0)===47&&t.charCodeAt(1)!==47?e+t:t}var kt=/\/chunks\/runtime\.[^/]+\.js$/;function bt(){return Q()}function O(t){let e=U();if(e&&(t===e||t.startsWith(e+"/"))){let n=t.slice(e.length);return n===""?"/":n}return t}function pt(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function F(t){if(bt().dev)try{console.warn("[krate router] "+t)}catch{}}function Kt(t,e){if(/^(https?:)?\/\//.test(t)||t.startsWith("/"))return new URL(t,e).href;let n=e;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(t,n).href}function Ot(t,e,n){let r=new DOMParser().parseFromString(t,"text/html"),o=[],i=new Set,s=a=>{if(!a)return;let c;try{c=Kt(a,e)}catch{return}i.has(c)||n.has(c)||kt.test(c)||(i.add(c),o.push(c))};return r.querySelectorAll("script[src]").forEach(a=>s(a.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(a=>s(a.getAttribute("href"))),o}var R=!1,_=0,k,Pt=0,m="",A="",j="idle",$=new Set,S=new Map,T=new Map,Ee=30,Se=3e4,L=new Map,Ae=50,dt=new Set,Le=128,q=new Map,W=new Map,H=null,J=[],_e="_krate/i",Te=150,Re=200;function mt(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function I(){return Pt++,Date.now().toString(36)+"-"+Pt.toString(36)}function it(t){try{let e=new URL(t,location.href);return e.hash="",e.href}catch{return t}}function x(t){let e=new URL(t,location.href);return pt(e.pathname)+e.search}function V(t,e=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(t,e);return}e?location.replace(t):location.assign(t)}function z(t,e){return{__krate:t,state:e===void 0?null:e}}function tt(t){if(t&&typeof t=="object"&&typeof t.__krate=="string")return t.__krate}function xe(){if(typeof history>"u")return null;let t=history.state;return tt(t)!==void 0?t.state:t}function Bt(){let t=new URL(location.href);return{url:t.href,pathname:O(t.pathname),search:t.search,hash:t.hash,status:j}}function Ft(){return typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:Bt()}function st(){if($.size===0)return;let t=Bt();for(let e of Array.from($))try{e(t)}catch(n){console.error(n)}}function D(t){j!==t&&(j=t,st())}function Wt(t){return $.add(t),()=>{$.delete(t)}}function b(t,e,n=!1){try{let r=new CustomEvent(t,{detail:e,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function wt(t){try{let e=globalThis.__krate_onNavigation;typeof e=="function"&&e(t)}catch{}}function Y(t){if(t){if(L.delete(t),L.size>=Ae){let e=L.keys().next().value;e!==void 0&&L.delete(e)}L.set(t,window.scrollY||0)}}function jt(){let t=bt().prefetchTTL;return typeof t=="number"&&t>=0?t:Se}function Ce(t,e){for(S.delete(t);S.size>=Ee;){let n=S.keys().next().value;if(n===void 0)break;S.delete(n)}S.set(t,e)}function Pe(t){let e=S.get(t);if(e&&(S.delete(t),!(mt()-e.at>jt())))return e}function Et(t){if(t===void 0){S.clear(),T.clear();return}let e=it(t);S.delete(e),T.delete(e)}function St(t){return/text\/html|application\/xhtml\+xml/i.test(t)}function G(t){return/^\s*(<!doctype html|<html|<head|<body)/i.test(t)}function Ne(t){if(dt.has(t)||dt.size>=Le)return;dt.add(t);let e=document.createElement("link");e.rel="prefetch",e.as="script",e.href=t,document.head.appendChild(e)}function At(t){let e=it(t),n=S.get(e);if(n&&mt()-n.at<=jt())return Promise.resolve();let r=T.get(e);if(r)return r;let o=fetch(e,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let s=i.headers.get("content-type")||"",a=i.url||e;if(new URL(a,location.href).origin!==location.origin)return;let c=await i.text();if(!(St(s)||s===""&&G(c))||T.get(e)!==o)return;Ce(e,{html:c,url:a,status:i.status,at:mt()});let u=new Set;document.querySelectorAll("script[src]").forEach(l=>u.add(l.src));for(let l of Ot(c,a,u))Ne(l)}).catch(()=>{}).finally(()=>{T.get(e)===o&&T.delete(e)});return T.set(e,o),o}function Lt(t){if(t.hasAttribute("data-krate-external")||t.hasAttribute("download"))return!1;let e=t.getAttribute("href");if(!e||e.startsWith("javascript:"))return!1;let n;try{n=new URL(e,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=t.getAttribute("target");return!(r&&r!=="_self")}function _t(t){let e=t.getAttribute("data-prefetch");return t.hasAttribute("data-prefetch")&&e!=="false"&&e!=="0"}function Me(t){let e=window.requestIdleCallback;typeof e=="function"?e(t,{timeout:1e3}):setTimeout(t,50)}function et(t){let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest("a[data-prefetch]");if(!n||!_t(n)||!Lt(n))return;let r=n.getAttribute("href");if(!r)return;let o=new URL(r,location.href).href;if(x(o)===A)return;let i=W.get(n);i&&clearTimeout(i);let s=setTimeout(()=>{W.delete(n),At(o)},Re);W.set(n,s)}function $t(){H&&document.querySelectorAll("a[data-prefetch]").forEach(t=>{_t(t)&&H.observe(t)})}function He(){document.addEventListener("mouseover",et),document.addEventListener("focusin",et),typeof IntersectionObserver<"u"&&(H=new IntersectionObserver(t=>{for(let e of t){if(!e.isIntersecting)continue;let n=e.target,r=n.getAttribute("href");if(r&&Lt(n)&&_t(n)){let o=new URL(r,location.href).href;x(o)!==A&&Me(()=>{At(o)})}H.unobserve(e.target)}},{rootMargin:"200px"}),$t())}function De(){let t=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof t!="function"||!t("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]'))try{let e=document.createElement("script");e.type="speculationrules";let n=U();e.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:n+"/*"},{not:{href_matches:n+"/__krate/*"}},{not:{href_matches:n+"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(e)}catch{}}function Jt(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function Vt(){return bt().viewTransitions===!1||Jt()?!1:typeof document.startViewTransition=="function"}function w(t){return t.getElementById("root")||t.body}function Ie(){let t=document.querySelector("template[data-krate-loading]");if(t&&t.content&&J.length===0){let e=t.content.cloneNode(!0);J=Array.from(e.childNodes),document.body.appendChild(e)}if(!Vt()&&!Jt()){let e=w(document);e.style.transition=`opacity ${Te}ms ease`,e.style.opacity="0"}}function Tt(){for(let e of J)e.parentNode&&e.parentNode.removeChild(e);J=[];let t=w(document);t.style.opacity==="0"&&(t.style.opacity="")}function zt(t){t.querySelectorAll("[data-view-transition]").forEach(e=>{let n=e.getAttribute("data-view-transition");n&&(e.style.viewTransitionName=n);let r=e.getAttribute("data-view-transition-class");r&&e.style.setProperty("view-transition-class",r)})}var Ue=3e3;function Ke(t,e){let n=[];t.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u.getAttribute("href");if(!l)return;let p=new URL(l,e).href;n.includes(p)||n.push(p)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u;l.href&&(n.includes(l.href)&&!r.has(l.href)?r.set(l.href,l):o.push(l))});let i=[],s=[],a=null;n.forEach((u,l)=>{let p=r.get(u)||null;if(!p){let h=document.createElement("link");if(h.rel="stylesheet",h.href=u,s.push(new Promise(g=>{let f=()=>{h.removeEventListener("load",f),h.removeEventListener("error",f),g()};h.addEventListener("load",f),h.addEventListener("error",f)})),i.push({link:h,media:h.getAttribute("media")}),h.media="not all",a)a.after(h);else{let g=n.slice(l+1).map(f=>r.get(f)).find(f=>!!f);g?g.before(h):document.head.appendChild(h)}p=h}a=p});let c=Promise.resolve();if(s.length>0){let u,l=new Promise(p=>{u=setTimeout(p,Ue)});c=Promise.race([Promise.all(s).then(()=>{}),l]).then(()=>clearTimeout(u))}return{ready:c,commit(){for(let{link:u,media:l}of i)l===null?u.removeAttribute("media"):u.setAttribute("media",l);o.forEach(u=>u.remove())},abort(){i.forEach(({link:u})=>u.remove())}}}var Nt='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Oe(t){document.head.querySelectorAll(Nt).forEach(e=>e.remove()),t.head.querySelectorAll(Nt).forEach(e=>{document.head.appendChild(document.importNode(e,!0))})}var gt=null;function Mt(t){let e={};if(t)for(let n of Array.from(t.attributes))e[n.name]=n.value;return e}function yt(t){return{html:Mt(t.documentElement),body:Mt(t.body)}}function Be(t){let e=gt??yt(document),n=yt(t),r=(o,i,s)=>{if(o)for(let a of new Set([...Object.keys(i),...Object.keys(s)]))i[a]!==s[a]&&(s[a]===void 0?o.removeAttribute(a):o.setAttribute(a,s[a]))};r(document.documentElement,e.html,n.html),r(document.body,e.body,n.body),gt=n}function Gt(t,e){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return t.querySelectorAll("script[src]").forEach(i=>{let s=i.getAttribute("src");if(!s)return;let a=(i.getAttribute("type")||"").toLowerCase();if(a&&a!=="module"&&a!=="text/javascript"&&a!=="application/javascript")return;let c=Kt(s,e);!n.has(c)&&!o.has(c)&&(o.add(c),r.push({src:c,module:a==="module"}))}),r}function Yt(t){return new Promise(e=>{let n=document.createElement("script");n.src=t.src,t.module&&(n.type="module"),kt.test(t.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>e(!0),n.onerror=()=>e(!1),document.body.appendChild(n)})}var nt=new Set;function Xt(t){t.querySelectorAll("script[data-krate-boot]").forEach(e=>{let n=e.textContent||"";if(!n||nt.has(n))return;nt.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function Fe(t){if(!t||t==="#")return null;let e=t.slice(1);try{e=decodeURIComponent(e)}catch{}return document.getElementById(e)||document.getElementsByName(e)[0]||null}function Rt(t){let e=Fe(t);if(!e)return!1;try{e.scrollIntoView({block:"start"})}catch{}return!0}function We(t,e){if(e.kind==="pop"){let r=e.restoreKey?L.get(e.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(t,location.href).hash;Rt(n)||e.scroll&&e.kind!=="refresh"&&window.scrollTo(0,0)}var Z=null;function je(){let t=document.activeElement;if(t&&t!==document.body&&t.isConnected&&t!==Z)return;let e=w(document);e.hasAttribute("tabindex")||(e.setAttribute("tabindex","-1"),Z=e,e.addEventListener("blur",()=>{Z===e&&(e.removeAttribute("tabindex"),Z=null)},{once:!0}));try{e.focus({preventScroll:!0})}catch{}}var Ht="__krate-route-announcer";function $e(){let t=document.getElementById(Ht);t||(t=document.createElement("div"),t.id=Ht,t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),t.setAttribute("role","status"),t.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0"),document.body.appendChild(t));let e=w(document).querySelector("h1"),n=document.title||(e&&e.textContent?e.textContent.trim():"")||O(location.pathname);t.textContent=n}function at(){let t=pt(O(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(e=>{let n=e.getAttribute("href"),r="";try{r=n?pt(O(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===t?o="exact":r&&r!=="/"&&t.startsWith(r+"/")&&(o="segment"),o==="exact"?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),o?e.setAttribute("data-krate-active",o):e.removeAttribute("data-krate-active")})}function Dt(t){let e=U()+t;return q.has(e)?Promise.resolve(q.get(e)??null):fetch(e,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&G(r)?r:null;return q.set(e,o),o}).catch(()=>null)}async function Je(t,e){let n=it(t.url);if(!t.bypassCache){let p=T.get(n);if(p&&await p,e.aborted)return{ok:!1,aborted:!0};let h=Pe(n);if(h){let g=new URL(t.url,location.href).hash,f=g&&!new URL(h.url,location.href).hash?h.url+g:h.url;return{ok:!0,doc:{html:h.html,url:f,status:h.status}}}}let r;try{r=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:e,cache:t.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||e.aborted?{ok:!1,aborted:!0}:b("krate:navigate-error",{url:t.url,status:0,error:p},!0)?{ok:!1,hard:t.url}:{ok:!1,aborted:!0}}let o=r.url||n;if(new URL(o,location.href).origin!==location.origin)return{ok:!1,hard:o};let i=r.headers.get("content-type")||"",s="";try{s=await r.text()}catch(p){if(p?.name==="AbortError"||e.aborted)return{ok:!1,aborted:!0};s=""}if(e.aborted)return{ok:!1,aborted:!0};let a=St(i)||i===""&&G(s),c=new URL(t.url,location.href).hash,u=c&&!new URL(o).hash?o+c:o;if(r.ok)return a?{ok:!0,doc:{html:s,url:u,status:r.status}}:{ok:!1,hard:u};if(b("krate:navigate-error",{url:t.url,status:r.status}),a&&G(s))return{ok:!0,doc:{html:s,url:u,status:r.status}};let l=null;return r.status===404||r.status===410?l=await Dt("/404.html"):r.status>=500&&(l=await Dt("/500.html")),e.aborted?{ok:!1,aborted:!0}:l?{ok:!0,doc:{html:l,url:u,status:r.status}}:{ok:!1,hard:u}}async function ct(t){let e=location.href;if(t.kind!=="pop"){if(!b("krate:navigate-start",{url:t.url,from:e,kind:t.kind},!0))return}else b("krate:navigate-start",{url:t.url,from:e,kind:t.kind});let n=++_;k&&k.abort();let r=new AbortController;k=r,D("loading"),!t.bypassCache&&S.has(it(t.url))||Ie();let i;try{i=await Je(t,r.signal)}finally{k===r&&(k=void 0)}if(n===_){if(!i.ok){Tt(),D("idle"),"hard"in i&&V(i.hard,t.kind==="replace"||t.kind==="refresh");return}await Ve(i.doc,t,n)}}async function Ve(t,e,n){let r=new DOMParser().parseFromString(t.html,"text/html"),o=t.url,i=w(r),s=w(document);e.kind==="push"&&Y(m);let a=Qt(r),c=Xe(N,a,location.href,o,r),u=Ke(r,o);if(await u.ready,n!==_){u.abort();return}if(await ze(()=>{let g=r.querySelector("title");g&&(document.title=g.textContent||"");let f=globalThis;if(c.keep.length>0&&typeof f.krateDisposeExcept=="function"?f.krateDisposeExcept(c.keep):typeof f.disposeAll=="function"&&f.disposeAll(),c.region){let{live:v,next:d}=c.region;rt(v[0],v[1]);let E=K(d[0],d[1]).map(y=>document.importNode(y,!0));for(let y of E)v[1].parentNode.insertBefore(y,v[1]);for(let y of c.slots){rt(y.live[0],y.live[1]);for(let B of K(y.next[0],y.next[1]))y.live[1].parentNode.insertBefore(document.importNode(B,!0),y.live[1])}Ge(s,i)}else{let v=Array.from(i.childNodes).map(d=>document.importNode(d,!0));s.replaceChildren(...v)}N=c.chain,X.clear(),u.commit(),Oe(r),Be(r),zt(document)}),n!==_)return;Tt(),e.kind==="push"?(m=I(),history.pushState(z(m,e.state),"",o)):e.kind==="replace"?(L.delete(m),m=I(),history.replaceState(z(m,e.state),"",o)):e.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):e.restoreKey&&(m=e.restoreKey),A=x(location.href),M=A,ee(r),Qe(r),We(o,e),e.kind!=="pop"&&e.kind!=="refresh"&&je(),e.kind!=="refresh"&&$e(),at(),b("krate:navigate",{url:location.href,status:t.status}),wt(location.href),D("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(g=>g.remove()),Xt(r);let p=Gt(r,o);Ut(c.skip);let h=await Promise.all(p.map(Yt));if(Ut([]),n===_){if(h.some(g=>!g)){b("krate:navigate-error",{url:location.href,status:t.status,error:"script-load"}),V(location.href,!0);return}ot(),b("krate:navigate-end",{url:location.href,status:t.status})}}function ze(t){if(!Vt())return t(),Promise.resolve();let e=!1,n=()=>{e||(e=!0,t())};try{let r=document.startViewTransition(n);r&&r.finished&&typeof r.finished.catch=="function"&&r.finished.catch(()=>{}),r&&r.ready&&typeof r.ready.catch=="function"&&r.ready.catch(()=>{});let o=r&&r.updateCallbackDone;if(o&&typeof o.then=="function")return o.then(()=>n(),()=>n())}catch{}return n(),Promise.resolve()}var N=[];function Qt(t){let e=t.getElementById("__krate_route");if(!e)return[];try{let n=JSON.parse(e.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return F("unreadable #__krate_route route info; layouts will be remounted"),[]}}function It(t,e){let n=O(new URL(t,location.href).pathname).split("/").filter(Boolean);return(e<0?n:n.slice(0,e)).join("/")}function P(t,e,n="kl:"){let o=(t.ownerDocument||t).createTreeWalker(t,128),i=n+e,s="/"+n+e;for(;o.nextNode();){let a=o.currentNode;if(a.nodeValue===i){for(let c=a.nextSibling;c;c=c.nextSibling)if(c.nodeType===8&&c.nodeValue===s)return[a,c];return null}}return null}function K(t,e){let n=[];for(let r=t.nextSibling;r&&r!==e;r=r.nextSibling)n.push(r);return n}function rt(t,e){let n=globalThis.disposeNode;for(let r of K(t,e))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function Ge(t,e){let n=":scope > template[data-krate-loading]";t.querySelectorAll(n).forEach(r=>r.remove()),e.querySelectorAll(n).forEach(r=>t.appendChild(document.importNode(r,!0)))}function Ut(t){let e=globalThis.krateKeepScopes;typeof e=="function"&&e(t)}function Ye(t){let e=globalThis.krateScopeFailed;return typeof e=="function"&&!!e(t)}function Xe(t,e,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:e},s=0;for(;s<t.length&&s<e.length;){let f=t[s],v=e[s];if(f.id!==v.id||f.k!==v.k||f.k!=="layout"&&f.k!=="error"||It(n,f.d)!==It(r,v.d)||f.k==="error"&&Ye(f.id))break;if(!f.p||!v.p){F(`layout ${v.f||v.id} is remounted on this navigation: ${v.why||f.why||"not persistable"}`);break}s++}if(s===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return F("the runtime has no krateDisposeExcept; layouts are remounted"),i;let a=e[s-1].id,c=P(w(document),a),u=P(w(o),a);if(!c||!u)return F(`layout ${e[s-1].f||a} boundary markers are missing; the whole page is swapped`),i;let l=t.slice(0,s).map(f=>f.id),p=l.slice(),h=[],g=e.slice();for(let f=0;f<s;f++){let v=t[f].s||[],d=[];for(let E of e[f].s||[]){let y=v.find(pe=>pe.key===E.key),B=P(w(document),E.key,"ks:"),ut=P(w(o),E.key,"ks:");if(y&&B&&(E.src!=="page"||!ut)){l.push(y.scope),p.push(y.scope,E.scope),d.push({...E,scope:y.scope,src:y.src});continue}if(B&&ut){h.push({live:B,next:ut}),d.push(E);continue}return F(`slot @${E.n} markers are missing; the whole page is swapped`),i}g[f]={...e[f],s:d}}return{keep:l,skip:p,region:{live:c,next:u},slots:h,chain:g}}var X=new Map,M="";function vt(t){let e=t.replace(/^\/+|\/+$/g,"");return e?e.split("/").map(n=>n.startsWith("[[...")&&n.endsWith("]]")?{kind:3,text:n.slice(5,-2)}:n.startsWith("[...")&&n.endsWith("]")?{kind:2,text:n.slice(4,-1)}:n.startsWith("[")&&n.endsWith("]")?{kind:1,text:n.slice(1,-1)}:{kind:0,text:n}):[]}function Zt(t,e){let n=vt(e),r=t.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let s=0;s<n.length;s++){let a=n[s];if(a.kind>=2){if(s!==n.length-1)return null;let c=o.slice(s);return a.kind===2&&c.length===0||c.some(u=>u==="")?null:(i[a.text]=c.map(ht).join("/"),i)}if(s>=o.length)return null;if(a.kind===1){if(!o[s])return null;i[a.text]=ht(o[s])}else if(ht(o[s])!==a.text)return null}return o.length===n.length?i:null}function ht(t){try{return decodeURIComponent(t)}catch{return t}}function qt(t,e){let n=vt(t),r=vt(e);for(let o=0;o<n.length&&o<r.length;o++){if(n[o].kind!==r[o].kind)return n[o].kind-r[o].kind;if(n[o].kind===0&&n[o].text!==r[o].text)return n[o].text<r[o].text?-1:1}return n.length!==r.length?r.length-n.length:t<e?-1:t>e?1:0}function xt(t){let e=O(new URL(t,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of N)for(let o of r.s||[])for(let i of o.i||[])Zt(e,i)&&(!n||qt(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:e},pattern:i});return n&&!P(w(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function te(t,e){N=N.map(n=>n.s&&n.s.some(r=>r.key===t)?{...n,s:n.s.map(r=>r.key===t?e:r)}:n)}function ee(t){let e="",n=t.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(e=r.r)}catch{}globalThis.__KRATE_ROUTE__=e;for(let r of Array.from(t.querySelectorAll("script:not([src])"))){let o=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(r.textContent||"");if(o){try{globalThis.__KRATE_PARAMS__=JSON.parse(o[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function Qe(t){let e=t.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!e){n&&n.remove();return}let r=document.importNode(e,!0);n?n.replaceWith(r):document.head.appendChild(r)}function ne(t){let e=globalThis.krateDisposeScopes;typeof e=="function"&&e(t)}async function Ct(t,e){let n=location.href;if(t.kind!=="pop"&&!b("krate:navigate-start",{url:t.url,from:n,kind:t.kind,intercept:e.slot.n},!0))return;let r=++_;k&&k.abort();let o=new AbortController;k=o,D("loading");let i=location.origin+U()+"/"+_e+"/"+e.slot.key+(e.path?"/"+e.path:""),s="",a=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:t.bypassCache?"no-cache":"default"});s=await d.text(),a=d.ok&&(St(d.headers.get("content-type")||"")||G(s)),a||b("krate:navigate-error",{url:t.url,status:d.status,intercept:e.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;b("krate:navigate-error",{url:t.url,status:0,error:d,intercept:e.slot.n})}finally{k===o&&(k=void 0)}if(r!==_)return;let c=a?new DOMParser().parseFromString(s,"text/html"):null,u=c?P(w(c),e.slot.key,"ks:"):null,l=P(w(document),e.slot.key,"ks:"),p=null;try{let d=c&&c.getElementById("__krate_route");p=d&&JSON.parse(d.textContent||"{}").frag||null}catch{p=null}if(!c||!u||!l||!p||p.key!==e.slot.key||!p.scope){try{console.warn(`[krate router] intercepting route for ${t.url} (slot @${e.slot.n}) could not be loaded; navigating to the page`)}catch{}return D("idle"),ct({...t})}if(t.kind==="push"&&Y(m),e.slot.src!=="intercept"){X.set(m,{key:e.slot.key,nodes:K(l[0],l[1]),slot:e.slot,path:M});for(let d of K(l[0],l[1]))d.parentNode.removeChild(d)}else ne([e.slot.scope]),rt(l[0],l[1]);for(let d of K(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let h=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>h.add(d.href)),c.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let E=new URL(d.getAttribute("href"),i).href;if(h.has(E))return;let y=document.createElement("link");y.rel="stylesheet",y.href=E,document.head.appendChild(y)}),te(e.slot.key,{...e.slot,scope:p.scope,src:"intercept"}),Xt(c);let g={__krate:"",state:t.state===void 0?null:t.state,__kint:{key:e.slot.key,base:M}};t.kind==="push"?(m=I(),g.__krate=m,history.pushState(g,"",t.url)):t.kind==="replace"?(m=I(),g.__krate=m,history.replaceState(g,"",t.url)):t.kind==="pop"&&t.restoreKey&&(m=t.restoreKey),A=x(location.href),ee(c),at(),b("krate:navigate",{url:location.href,status:200,intercept:e.slot.n}),wt(location.href),D("idle");let f=Gt(c,i),v=await Promise.all(f.map(Yt));if(r===_){if(v.some(d=>!d)){b("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:e.slot.n}),V(location.href,!0);return}ot(),b("krate:navigate-end",{url:location.href,status:200,intercept:e.slot.n})}}function Ze(t,e){let n=P(w(document),t.key,"ks:"),r=N.flatMap(i=>i.s||[]).find(i=>i.key===t.key);if(!n||!r||r.src!=="intercept")return!1;ne([r.scope]),rt(n[0],n[1]);for(let i of t.nodes)n[1].parentNode.insertBefore(i,n[1]);te(t.key,t.slot),X.delete(e),m=e,A=x(location.href);let o=L.get(e);return o!==void 0&&window.scrollTo(0,o),at(),b("krate:navigate",{url:location.href,status:200}),wt(location.href),st(),!0}function qe(t){return x(t)===A}function re(){j==="loading"&&(_++,k&&k.abort(),k=void 0,Tt(),D("idle"))}function tn(t,e){re(),Y(m),(t!==location.href||e.state!==void 0)&&(e.kind==="replace"?history.replaceState(z(m||I(),e.state),"",t):(m=I(),history.pushState(z(m,e.state),"",t)));let n=new URL(t).hash;!Rt(n)&&e.scroll&&!n&&window.scrollTo(0,0),st()}function lt(t){let e;try{e=new URL(t.url,location.href)}catch{return V(t.url),Promise.resolve()}if(e.origin!==location.origin)return V(e.href,t.kind==="replace"),Promise.resolve();if(t.url=e.href,(t.kind==="push"||t.kind==="replace")&&qe(e.href)&&(e.hash||e.href===location.href))return tn(e.href,t),Promise.resolve();if(t.kind==="push"||t.kind==="replace"){let n=xt(e.href);if(n)return Ct(t,n)}return ct(t)}function oe(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest("a[data-krate-link]");if(!n||!Lt(n))return;let r=n.getAttribute("href");r&&(t.preventDefault(),lt({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function ie(t){if(t.defaultPrevented)return;let e=t.target;if(!e||e.tagName!=="FORM"||e.hasAttribute("data-krate-reload"))return;let n=t.submitter||null;if((n&&n.getAttribute("formmethod")||e.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||e.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||e.getAttribute("action")||"",s;try{s=new URL(i||location.href,location.href)}catch{return}if(s.origin!==location.origin||s.protocol.indexOf("http")!==0)return;let a;try{a=n?new FormData(e,n):new FormData(e)}catch{a=new FormData(e),n&&n.name&&a.append(n.name,n.value)}let c=new URLSearchParams;for(let[u,l]of a.entries()){if(typeof l!="string")return;c.append(u,l)}t.preventDefault(),s.search=c.toString(),s.hash="",lt({url:s.href,kind:"push",scroll:!0})}function se(t){Y(m);let e=tt(t.state),n=location.href;if(x(n)===A){re(),m=e||m;let i=e?L.get(e):void 0;i!==void 0?window.scrollTo(0,i):Rt(location.hash),st();return}let r=e?X.get(e):void 0;if(r&&e&&r.path===x(n)&&r.path===M&&Ze(r,e))return;let o=t.state&&typeof t.state=="object"?t.state.__kint:null;if(o&&o.base===M){let i=xt(n);if(i&&i.slot.key===o.key){Ct({url:n,kind:"pop",scroll:!1,restoreKey:e},i);return}}ct({url:n,kind:"pop",scroll:!0,restoreKey:e})}function ae(){Et(),ue()}function ce(){Y(m);try{history.scrollRestoration="auto"}catch{}}function le(){try{history.scrollRestoration="manual"}catch{}}function ot(){$t(),at(),zt(document),document.querySelectorAll("script[src]").forEach(t=>{kt.test(t.src)||t.setAttribute("data-krate-spa","")})}function ue(){if(!R||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(A!==M){let t=xt(location.href);if(t&&t.slot.src==="intercept")return Ct({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},t)}return ct({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function fe(t,e={}){return R?lt({url:C(t),kind:"push",scroll:e.scroll!==!1,state:e.state}):(typeof location<"u"&&location.assign(C(t)),Promise.resolve())}function de(t,e={}){return R?lt({url:C(t),kind:"replace",scroll:e.scroll!==!1,state:e.state}):(typeof location<"u"&&location.replace(C(t)),Promise.resolve())}var en={push:fe,replace:de,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:ue,prefetch(t){if(!R||typeof location>"u")return Promise.resolve();let e;try{e=new URL(C(t),location.href)}catch{return Promise.resolve()}return e.origin!==location.origin?Promise.resolve():At(e.href)},subscribe:Wt,getState:Ft,invalidate:Et};function nn(t,e={}){return R?(e.replace?de(t,e):fe(t,e),!1):(typeof location<"u"&&(e.replace?location.replace(C(t)):location.assign(C(t))),!0)}function he(){if(!(typeof document>"u")){if(R){ot();return}if(R=!0,document.querySelectorAll("script[data-krate-boot]").forEach(t=>nt.add(t.textContent||"")),A=x(location.href),N=Qt(document),gt=yt(document),M=A,m=tt(history.state)||I(),tt(history.state)===void 0)try{history.replaceState(z(m,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",oe),document.addEventListener("submit",ie),window.addEventListener("popstate",se),window.addEventListener("krate:revalidate",ae),window.addEventListener("pagehide",ce),window.addEventListener("pageshow",le),He(),De(),ot()}}function rn(){he()}function on(){if(R){R=!1,document.removeEventListener("click",oe),document.removeEventListener("submit",ie),window.removeEventListener("popstate",se),window.removeEventListener("krate:revalidate",ae),window.removeEventListener("pagehide",ce),window.removeEventListener("pageshow",le),document.removeEventListener("mouseover",et),document.removeEventListener("focusin",et);for(let t of W.values())clearTimeout(t);W=new Map,H&&(H.disconnect(),H=null),k&&k.abort(),k=void 0,_++,S.clear(),T.clear(),L.clear(),q.clear(),nt.clear(),$.clear(),j="idle",J=[],N=[],X.clear(),M=""}}return be(sn);})();
1
+ var __krate_exports=(()=>{var ft=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var ve=(t,e)=>{for(var n in e)ft(t,n,{get:e[n],enumerable:!0})},ke=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ge(e))!ye.call(t,o)&&o!==n&&ft(t,o,{get:()=>e[o],enumerable:!(r=me(e,o))||r.enumerable});return t};var be=t=>ke(ft({},"__esModule",{value:!0}),t);var sn={};ve(sn,{compareRouteSpecificity:()=>qt,destroyRouter:()=>on,getHistoryState:()=>xe,getNavigationState:()=>Ft,initRouter:()=>he,invalidatePrefetchCache:()=>Et,krateRouter:()=>en,matchRoutePattern:()=>Zt,navigate:()=>nn,pageAssetURLs:()=>Ot,reinitRouter:()=>rn,subscribeNavigation:()=>Wt});var we="__krate_cfg__";function Q(){let t=globalThis;if(t.__KRATE_CFG__)return t.__KRATE_CFG__;let e=t.document,n=e&&typeof e.getElementById=="function"?e.getElementById(we):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return t.__KRATE_CFG__=r,r}catch{}return{}}function U(){let t=Q(),e=t&&t.basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function C(t){let e=U();return e&&t.charCodeAt(0)===47&&t.charCodeAt(1)!==47?e+t:t}var kt=/\/chunks\/runtime\.[^/]+\.js$/;function bt(){return Q()}function O(t){let e=U();if(e&&(t===e||t.startsWith(e+"/"))){let n=t.slice(e.length);return n===""?"/":n}return t}function pt(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function F(t){if(bt().dev)try{console.warn("[krate router] "+t)}catch{}}function Kt(t,e){if(/^(https?:)?\/\//.test(t)||t.startsWith("/"))return new URL(t,e).href;let n=e;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(t,n).href}function Ot(t,e,n){let r=new DOMParser().parseFromString(t,"text/html"),o=[],i=new Set,s=a=>{if(!a)return;let c;try{c=Kt(a,e)}catch{return}i.has(c)||n.has(c)||kt.test(c)||(i.add(c),o.push(c))};return r.querySelectorAll("script[src]").forEach(a=>s(a.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(a=>s(a.getAttribute("href"))),o}var R=!1,_=0,k,Pt=0,m="",A="",j="idle",$=new Set,S=new Map,T=new Map,Ee=30,Se=3e4,L=new Map,Ae=50,dt=new Set,Le=128,q=new Map,W=new Map,H=null,J=[],_e="_krate/i",Te=150,Re=200;function mt(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function I(){return Pt++,Date.now().toString(36)+"-"+Pt.toString(36)}function it(t){try{let e=new URL(t,location.href);return e.hash="",e.href}catch{return t}}function x(t){let e=new URL(t,location.href);return pt(e.pathname)+e.search}function V(t,e=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(t,e);return}e?location.replace(t):location.assign(t)}function z(t,e){return{__krate:t,state:e===void 0?null:e}}function tt(t){if(t&&typeof t=="object"&&typeof t.__krate=="string")return t.__krate}function xe(){if(typeof history>"u")return null;let t=history.state;return tt(t)!==void 0?t.state:t}function Bt(){let t=new URL(location.href);return{url:t.href,pathname:O(t.pathname),search:t.search,hash:t.hash,status:j}}function Ft(){return typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:Bt()}function st(){if($.size===0)return;let t=Bt();for(let e of Array.from($))try{e(t)}catch(n){console.error(n)}}function D(t){j!==t&&(j=t,st())}function Wt(t){return $.add(t),()=>{$.delete(t)}}function b(t,e,n=!1){try{let r=new CustomEvent(t,{detail:e,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function wt(t){try{let e=globalThis.__krate_onNavigation;typeof e=="function"&&e(t)}catch{}}function Y(t){if(t){if(L.delete(t),L.size>=Ae){let e=L.keys().next().value;e!==void 0&&L.delete(e)}L.set(t,window.scrollY||0)}}function jt(){let t=bt().prefetchTTL;return typeof t=="number"&&t>=0?t:Se}function Ce(t,e){for(S.delete(t);S.size>=Ee;){let n=S.keys().next().value;if(n===void 0)break;S.delete(n)}S.set(t,e)}function Pe(t){let e=S.get(t);if(e&&(S.delete(t),!(mt()-e.at>jt())))return e}function Et(t){if(t===void 0){S.clear(),T.clear();return}let e=it(t);S.delete(e),T.delete(e)}function St(t){return/text\/html|application\/xhtml\+xml/i.test(t)}function G(t){return/^\s*(<!doctype html|<html|<head|<body)/i.test(t)}function Ne(t){if(dt.has(t)||dt.size>=Le)return;dt.add(t);let e=document.createElement("link");e.rel="prefetch",e.as="script",e.href=t,document.head.appendChild(e)}function At(t){let e=it(t),n=S.get(e);if(n&&mt()-n.at<=jt())return Promise.resolve();let r=T.get(e);if(r)return r;let o=fetch(e,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let s=i.headers.get("content-type")||"",a=i.url||e;if(new URL(a,location.href).origin!==location.origin)return;let c=await i.text();if(!(St(s)||s===""&&G(c))||T.get(e)!==o)return;Ce(e,{html:c,url:a,status:i.status,at:mt()});let u=new Set;document.querySelectorAll("script[src]").forEach(l=>u.add(l.src));for(let l of Ot(c,a,u))Ne(l)}).catch(()=>{}).finally(()=>{T.get(e)===o&&T.delete(e)});return T.set(e,o),o}function Lt(t){if(t.hasAttribute("data-krate-external")||t.hasAttribute("download"))return!1;let e=t.getAttribute("href");if(!e||e.startsWith("javascript:"))return!1;let n;try{n=new URL(e,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=t.getAttribute("target");return!(r&&r!=="_self")}function _t(t){let e=t.getAttribute("data-prefetch");return t.hasAttribute("data-prefetch")&&e!=="false"&&e!=="0"}function Me(t){let e=window.requestIdleCallback;typeof e=="function"?e(t,{timeout:1e3}):setTimeout(t,50)}function et(t){let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest("a[data-prefetch]");if(!n||!_t(n)||!Lt(n))return;let r=n.getAttribute("href");if(!r)return;let o=new URL(r,location.href).href;if(x(o)===A)return;let i=W.get(n);i&&clearTimeout(i);let s=setTimeout(()=>{W.delete(n),At(o)},Re);W.set(n,s)}function $t(){H&&document.querySelectorAll("a[data-prefetch]").forEach(t=>{_t(t)&&H.observe(t)})}function He(){document.addEventListener("mouseover",et),document.addEventListener("focusin",et),typeof IntersectionObserver<"u"&&(H=new IntersectionObserver(t=>{for(let e of t){if(!e.isIntersecting)continue;let n=e.target,r=n.getAttribute("href");if(r&&Lt(n)&&_t(n)){let o=new URL(r,location.href).href;x(o)!==A&&Me(()=>{At(o)})}H.unobserve(e.target)}},{rootMargin:"200px"}),$t())}function De(){let t=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof t!="function"||!t("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]'))try{let e=document.createElement("script");e.type="speculationrules";let n=U();e.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:n+"/*"},{not:{href_matches:n+"/__krate/*"}},{not:{href_matches:n+"/api/*"}}]},eagerness:"moderate"}]});let r=o=>{o&&o.blockedURI==="inline"&&/^script-src/.test(String(o.effectiveDirective||o.violatedDirective||""))&&(e.remove(),document.removeEventListener("securitypolicyviolation",r))};document.addEventListener("securitypolicyviolation",r),document.head.appendChild(e)}catch{}}function Jt(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function Vt(){return bt().viewTransitions===!1||Jt()?!1:typeof document.startViewTransition=="function"}function w(t){return t.getElementById("root")||t.body}function Ie(){let t=document.querySelector("template[data-krate-loading]");if(t&&t.content&&J.length===0){let e=t.content.cloneNode(!0);J=Array.from(e.childNodes),document.body.appendChild(e)}if(!Vt()&&!Jt()){let e=w(document);e.style.transition=`opacity ${Te}ms ease`,e.style.opacity="0"}}function Tt(){for(let e of J)e.parentNode&&e.parentNode.removeChild(e);J=[];let t=w(document);t.style.opacity==="0"&&(t.style.opacity="")}function zt(t){t.querySelectorAll("[data-view-transition]").forEach(e=>{let n=e.getAttribute("data-view-transition");n&&(e.style.viewTransitionName=n);let r=e.getAttribute("data-view-transition-class");r&&e.style.setProperty("view-transition-class",r)})}var Ue=3e3;function Ke(t,e){let n=[];t.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u.getAttribute("href");if(!l)return;let p=new URL(l,e).href;n.includes(p)||n.push(p)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u;l.href&&(n.includes(l.href)&&!r.has(l.href)?r.set(l.href,l):o.push(l))});let i=[],s=[],a=null;n.forEach((u,l)=>{let p=r.get(u)||null;if(!p){let h=document.createElement("link");if(h.rel="stylesheet",h.href=u,s.push(new Promise(g=>{let f=()=>{h.removeEventListener("load",f),h.removeEventListener("error",f),g()};h.addEventListener("load",f),h.addEventListener("error",f)})),i.push({link:h,media:h.getAttribute("media")}),h.media="not all",a)a.after(h);else{let g=n.slice(l+1).map(f=>r.get(f)).find(f=>!!f);g?g.before(h):document.head.appendChild(h)}p=h}a=p});let c=Promise.resolve();if(s.length>0){let u,l=new Promise(p=>{u=setTimeout(p,Ue)});c=Promise.race([Promise.all(s).then(()=>{}),l]).then(()=>clearTimeout(u))}return{ready:c,commit(){for(let{link:u,media:l}of i)l===null?u.removeAttribute("media"):u.setAttribute("media",l);o.forEach(u=>u.remove())},abort(){i.forEach(({link:u})=>u.remove())}}}var Nt='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Oe(t){document.head.querySelectorAll(Nt).forEach(e=>e.remove()),t.head.querySelectorAll(Nt).forEach(e=>{document.head.appendChild(document.importNode(e,!0))})}var gt=null;function Mt(t){let e={};if(t)for(let n of Array.from(t.attributes))e[n.name]=n.value;return e}function yt(t){return{html:Mt(t.documentElement),body:Mt(t.body)}}function Be(t){let e=gt??yt(document),n=yt(t),r=(o,i,s)=>{if(o)for(let a of new Set([...Object.keys(i),...Object.keys(s)]))i[a]!==s[a]&&(s[a]===void 0?o.removeAttribute(a):o.setAttribute(a,s[a]))};r(document.documentElement,e.html,n.html),r(document.body,e.body,n.body),gt=n}function Gt(t,e){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return t.querySelectorAll("script[src]").forEach(i=>{let s=i.getAttribute("src");if(!s)return;let a=(i.getAttribute("type")||"").toLowerCase();if(a&&a!=="module"&&a!=="text/javascript"&&a!=="application/javascript")return;let c=Kt(s,e);!n.has(c)&&!o.has(c)&&(o.add(c),r.push({src:c,module:a==="module"}))}),r}function Yt(t){return new Promise(e=>{let n=document.createElement("script");n.src=t.src,t.module&&(n.type="module"),kt.test(t.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>e(!0),n.onerror=()=>e(!1),document.body.appendChild(n)})}var nt=new Set;function Xt(t){t.querySelectorAll("script[data-krate-boot]").forEach(e=>{let n=e.textContent||"";if(!n||nt.has(n))return;nt.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function Fe(t){if(!t||t==="#")return null;let e=t.slice(1);try{e=decodeURIComponent(e)}catch{}return document.getElementById(e)||document.getElementsByName(e)[0]||null}function Rt(t){let e=Fe(t);if(!e)return!1;try{e.scrollIntoView({block:"start"})}catch{}return!0}function We(t,e){if(e.kind==="pop"){let r=e.restoreKey?L.get(e.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(t,location.href).hash;Rt(n)||e.scroll&&e.kind!=="refresh"&&window.scrollTo(0,0)}var Z=null;function je(){let t=document.activeElement;if(t&&t!==document.body&&t.isConnected&&t!==Z)return;let e=w(document);e.hasAttribute("tabindex")||(e.setAttribute("tabindex","-1"),Z=e,e.addEventListener("blur",()=>{Z===e&&(e.removeAttribute("tabindex"),Z=null)},{once:!0}));try{e.focus({preventScroll:!0})}catch{}}var Ht="__krate-route-announcer";function $e(){let t=document.getElementById(Ht);t||(t=document.createElement("div"),t.id=Ht,t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),t.setAttribute("role","status"),t.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0"),document.body.appendChild(t));let e=w(document).querySelector("h1"),n=document.title||(e&&e.textContent?e.textContent.trim():"")||O(location.pathname);t.textContent=n}function at(){let t=pt(O(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(e=>{let n=e.getAttribute("href"),r="";try{r=n?pt(O(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===t?o="exact":r&&r!=="/"&&t.startsWith(r+"/")&&(o="segment"),o==="exact"?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),o?e.setAttribute("data-krate-active",o):e.removeAttribute("data-krate-active")})}function Dt(t){let e=U()+t;return q.has(e)?Promise.resolve(q.get(e)??null):fetch(e,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&G(r)?r:null;return q.set(e,o),o}).catch(()=>null)}async function Je(t,e){let n=it(t.url);if(!t.bypassCache){let p=T.get(n);if(p&&await p,e.aborted)return{ok:!1,aborted:!0};let h=Pe(n);if(h){let g=new URL(t.url,location.href).hash,f=g&&!new URL(h.url,location.href).hash?h.url+g:h.url;return{ok:!0,doc:{html:h.html,url:f,status:h.status}}}}let r;try{r=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:e,cache:t.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||e.aborted?{ok:!1,aborted:!0}:b("krate:navigate-error",{url:t.url,status:0,error:p},!0)?{ok:!1,hard:t.url}:{ok:!1,aborted:!0}}let o=r.url||n;if(new URL(o,location.href).origin!==location.origin)return{ok:!1,hard:o};let i=r.headers.get("content-type")||"",s="";try{s=await r.text()}catch(p){if(p?.name==="AbortError"||e.aborted)return{ok:!1,aborted:!0};s=""}if(e.aborted)return{ok:!1,aborted:!0};let a=St(i)||i===""&&G(s),c=new URL(t.url,location.href).hash,u=c&&!new URL(o).hash?o+c:o;if(r.ok)return a?{ok:!0,doc:{html:s,url:u,status:r.status}}:{ok:!1,hard:u};if(b("krate:navigate-error",{url:t.url,status:r.status}),a&&G(s))return{ok:!0,doc:{html:s,url:u,status:r.status}};let l=null;return r.status===404||r.status===410?l=await Dt("/404.html"):r.status>=500&&(l=await Dt("/500.html")),e.aborted?{ok:!1,aborted:!0}:l?{ok:!0,doc:{html:l,url:u,status:r.status}}:{ok:!1,hard:u}}async function ct(t){let e=location.href;if(t.kind!=="pop"){if(!b("krate:navigate-start",{url:t.url,from:e,kind:t.kind},!0))return}else b("krate:navigate-start",{url:t.url,from:e,kind:t.kind});let n=++_;k&&k.abort();let r=new AbortController;k=r,D("loading"),!t.bypassCache&&S.has(it(t.url))||Ie();let i;try{i=await Je(t,r.signal)}finally{k===r&&(k=void 0)}if(n===_){if(!i.ok){Tt(),D("idle"),"hard"in i&&V(i.hard,t.kind==="replace"||t.kind==="refresh");return}await Ve(i.doc,t,n)}}async function Ve(t,e,n){let r=new DOMParser().parseFromString(t.html,"text/html"),o=t.url,i=w(r),s=w(document);e.kind==="push"&&Y(m);let a=Qt(r),c=Xe(N,a,location.href,o,r),u=Ke(r,o);if(await u.ready,n!==_){u.abort();return}if(await ze(()=>{let g=r.querySelector("title");g&&(document.title=g.textContent||"");let f=globalThis;if(c.keep.length>0&&typeof f.krateDisposeExcept=="function"?f.krateDisposeExcept(c.keep):typeof f.disposeAll=="function"&&f.disposeAll(),c.region){let{live:v,next:d}=c.region;rt(v[0],v[1]);let E=K(d[0],d[1]).map(y=>document.importNode(y,!0));for(let y of E)v[1].parentNode.insertBefore(y,v[1]);for(let y of c.slots){rt(y.live[0],y.live[1]);for(let B of K(y.next[0],y.next[1]))y.live[1].parentNode.insertBefore(document.importNode(B,!0),y.live[1])}Ge(s,i)}else{let v=Array.from(i.childNodes).map(d=>document.importNode(d,!0));s.replaceChildren(...v)}N=c.chain,X.clear(),u.commit(),Oe(r),Be(r),zt(document)}),n!==_)return;Tt(),e.kind==="push"?(m=I(),history.pushState(z(m,e.state),"",o)):e.kind==="replace"?(L.delete(m),m=I(),history.replaceState(z(m,e.state),"",o)):e.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):e.restoreKey&&(m=e.restoreKey),A=x(location.href),M=A,ee(r),Qe(r),We(o,e),e.kind!=="pop"&&e.kind!=="refresh"&&je(),e.kind!=="refresh"&&$e(),at(),b("krate:navigate",{url:location.href,status:t.status}),wt(location.href),D("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(g=>g.remove()),Xt(r);let p=Gt(r,o);Ut(c.skip);let h=await Promise.all(p.map(Yt));if(Ut([]),n===_){if(h.some(g=>!g)){b("krate:navigate-error",{url:location.href,status:t.status,error:"script-load"}),V(location.href,!0);return}ot(),b("krate:navigate-end",{url:location.href,status:t.status})}}function ze(t){if(!Vt())return t(),Promise.resolve();let e=!1,n=()=>{e||(e=!0,t())};try{let r=document.startViewTransition(n);r&&r.finished&&typeof r.finished.catch=="function"&&r.finished.catch(()=>{}),r&&r.ready&&typeof r.ready.catch=="function"&&r.ready.catch(()=>{});let o=r&&r.updateCallbackDone;if(o&&typeof o.then=="function")return o.then(()=>n(),()=>n())}catch{}return n(),Promise.resolve()}var N=[];function Qt(t){let e=t.getElementById("__krate_route");if(!e)return[];try{let n=JSON.parse(e.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return F("unreadable #__krate_route route info; layouts will be remounted"),[]}}function It(t,e){let n=O(new URL(t,location.href).pathname).split("/").filter(Boolean);return(e<0?n:n.slice(0,e)).join("/")}function P(t,e,n="kl:"){let o=(t.ownerDocument||t).createTreeWalker(t,128),i=n+e,s="/"+n+e;for(;o.nextNode();){let a=o.currentNode;if(a.nodeValue===i){for(let c=a.nextSibling;c;c=c.nextSibling)if(c.nodeType===8&&c.nodeValue===s)return[a,c];return null}}return null}function K(t,e){let n=[];for(let r=t.nextSibling;r&&r!==e;r=r.nextSibling)n.push(r);return n}function rt(t,e){let n=globalThis.disposeNode;for(let r of K(t,e))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function Ge(t,e){let n=":scope > template[data-krate-loading]";t.querySelectorAll(n).forEach(r=>r.remove()),e.querySelectorAll(n).forEach(r=>t.appendChild(document.importNode(r,!0)))}function Ut(t){let e=globalThis.krateKeepScopes;typeof e=="function"&&e(t)}function Ye(t){let e=globalThis.krateScopeFailed;return typeof e=="function"&&!!e(t)}function Xe(t,e,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:e},s=0;for(;s<t.length&&s<e.length;){let f=t[s],v=e[s];if(f.id!==v.id||f.k!==v.k||f.k!=="layout"&&f.k!=="error"||It(n,f.d)!==It(r,v.d)||f.k==="error"&&Ye(f.id))break;if(!f.p||!v.p){F(`layout ${v.f||v.id} is remounted on this navigation: ${v.why||f.why||"not persistable"}`);break}s++}if(s===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return F("the runtime has no krateDisposeExcept; layouts are remounted"),i;let a=e[s-1].id,c=P(w(document),a),u=P(w(o),a);if(!c||!u)return F(`layout ${e[s-1].f||a} boundary markers are missing; the whole page is swapped`),i;let l=t.slice(0,s).map(f=>f.id),p=l.slice(),h=[],g=e.slice();for(let f=0;f<s;f++){let v=t[f].s||[],d=[];for(let E of e[f].s||[]){let y=v.find(pe=>pe.key===E.key),B=P(w(document),E.key,"ks:"),ut=P(w(o),E.key,"ks:");if(y&&B&&(E.src!=="page"||!ut)){l.push(y.scope),p.push(y.scope,E.scope),d.push({...E,scope:y.scope,src:y.src});continue}if(B&&ut){h.push({live:B,next:ut}),d.push(E);continue}return F(`slot @${E.n} markers are missing; the whole page is swapped`),i}g[f]={...e[f],s:d}}return{keep:l,skip:p,region:{live:c,next:u},slots:h,chain:g}}var X=new Map,M="";function vt(t){let e=t.replace(/^\/+|\/+$/g,"");return e?e.split("/").map(n=>n.startsWith("[[...")&&n.endsWith("]]")?{kind:3,text:n.slice(5,-2)}:n.startsWith("[...")&&n.endsWith("]")?{kind:2,text:n.slice(4,-1)}:n.startsWith("[")&&n.endsWith("]")?{kind:1,text:n.slice(1,-1)}:{kind:0,text:n}):[]}function Zt(t,e){let n=vt(e),r=t.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let s=0;s<n.length;s++){let a=n[s];if(a.kind>=2){if(s!==n.length-1)return null;let c=o.slice(s);return a.kind===2&&c.length===0||c.some(u=>u==="")?null:(i[a.text]=c.map(ht).join("/"),i)}if(s>=o.length)return null;if(a.kind===1){if(!o[s])return null;i[a.text]=ht(o[s])}else if(ht(o[s])!==a.text)return null}return o.length===n.length?i:null}function ht(t){try{return decodeURIComponent(t)}catch{return t}}function qt(t,e){let n=vt(t),r=vt(e);for(let o=0;o<n.length&&o<r.length;o++){if(n[o].kind!==r[o].kind)return n[o].kind-r[o].kind;if(n[o].kind===0&&n[o].text!==r[o].text)return n[o].text<r[o].text?-1:1}return n.length!==r.length?r.length-n.length:t<e?-1:t>e?1:0}function xt(t){let e=O(new URL(t,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of N)for(let o of r.s||[])for(let i of o.i||[])Zt(e,i)&&(!n||qt(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:e},pattern:i});return n&&!P(w(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function te(t,e){N=N.map(n=>n.s&&n.s.some(r=>r.key===t)?{...n,s:n.s.map(r=>r.key===t?e:r)}:n)}function ee(t){let e="",n=t.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(e=r.r)}catch{}globalThis.__KRATE_ROUTE__=e;for(let r of Array.from(t.querySelectorAll("script:not([src])"))){let o=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(r.textContent||"");if(o){try{globalThis.__KRATE_PARAMS__=JSON.parse(o[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function Qe(t){let e=t.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!e){n&&n.remove();return}let r=document.importNode(e,!0);n?n.replaceWith(r):document.head.appendChild(r)}function ne(t){let e=globalThis.krateDisposeScopes;typeof e=="function"&&e(t)}async function Ct(t,e){let n=location.href;if(t.kind!=="pop"&&!b("krate:navigate-start",{url:t.url,from:n,kind:t.kind,intercept:e.slot.n},!0))return;let r=++_;k&&k.abort();let o=new AbortController;k=o,D("loading");let i=location.origin+U()+"/"+_e+"/"+e.slot.key+(e.path?"/"+e.path:""),s="",a=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:t.bypassCache?"no-cache":"default"});s=await d.text(),a=d.ok&&(St(d.headers.get("content-type")||"")||G(s)),a||b("krate:navigate-error",{url:t.url,status:d.status,intercept:e.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;b("krate:navigate-error",{url:t.url,status:0,error:d,intercept:e.slot.n})}finally{k===o&&(k=void 0)}if(r!==_)return;let c=a?new DOMParser().parseFromString(s,"text/html"):null,u=c?P(w(c),e.slot.key,"ks:"):null,l=P(w(document),e.slot.key,"ks:"),p=null;try{let d=c&&c.getElementById("__krate_route");p=d&&JSON.parse(d.textContent||"{}").frag||null}catch{p=null}if(!c||!u||!l||!p||p.key!==e.slot.key||!p.scope){try{console.warn(`[krate router] intercepting route for ${t.url} (slot @${e.slot.n}) could not be loaded; navigating to the page`)}catch{}return D("idle"),ct({...t})}if(t.kind==="push"&&Y(m),e.slot.src!=="intercept"){X.set(m,{key:e.slot.key,nodes:K(l[0],l[1]),slot:e.slot,path:M});for(let d of K(l[0],l[1]))d.parentNode.removeChild(d)}else ne([e.slot.scope]),rt(l[0],l[1]);for(let d of K(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let h=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>h.add(d.href)),c.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let E=new URL(d.getAttribute("href"),i).href;if(h.has(E))return;let y=document.createElement("link");y.rel="stylesheet",y.href=E,document.head.appendChild(y)}),te(e.slot.key,{...e.slot,scope:p.scope,src:"intercept"}),Xt(c);let g={__krate:"",state:t.state===void 0?null:t.state,__kint:{key:e.slot.key,base:M}};t.kind==="push"?(m=I(),g.__krate=m,history.pushState(g,"",t.url)):t.kind==="replace"?(m=I(),g.__krate=m,history.replaceState(g,"",t.url)):t.kind==="pop"&&t.restoreKey&&(m=t.restoreKey),A=x(location.href),ee(c),at(),b("krate:navigate",{url:location.href,status:200,intercept:e.slot.n}),wt(location.href),D("idle");let f=Gt(c,i),v=await Promise.all(f.map(Yt));if(r===_){if(v.some(d=>!d)){b("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:e.slot.n}),V(location.href,!0);return}ot(),b("krate:navigate-end",{url:location.href,status:200,intercept:e.slot.n})}}function Ze(t,e){let n=P(w(document),t.key,"ks:"),r=N.flatMap(i=>i.s||[]).find(i=>i.key===t.key);if(!n||!r||r.src!=="intercept")return!1;ne([r.scope]),rt(n[0],n[1]);for(let i of t.nodes)n[1].parentNode.insertBefore(i,n[1]);te(t.key,t.slot),X.delete(e),m=e,A=x(location.href);let o=L.get(e);return o!==void 0&&window.scrollTo(0,o),at(),b("krate:navigate",{url:location.href,status:200}),wt(location.href),st(),!0}function qe(t){return x(t)===A}function re(){j==="loading"&&(_++,k&&k.abort(),k=void 0,Tt(),D("idle"))}function tn(t,e){re(),Y(m),(t!==location.href||e.state!==void 0)&&(e.kind==="replace"?history.replaceState(z(m||I(),e.state),"",t):(m=I(),history.pushState(z(m,e.state),"",t)));let n=new URL(t).hash;!Rt(n)&&e.scroll&&!n&&window.scrollTo(0,0),st()}function lt(t){let e;try{e=new URL(t.url,location.href)}catch{return V(t.url),Promise.resolve()}if(e.origin!==location.origin)return V(e.href,t.kind==="replace"),Promise.resolve();if(t.url=e.href,(t.kind==="push"||t.kind==="replace")&&qe(e.href)&&(e.hash||e.href===location.href))return tn(e.href,t),Promise.resolve();if(t.kind==="push"||t.kind==="replace"){let n=xt(e.href);if(n)return Ct(t,n)}return ct(t)}function oe(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest("a[data-krate-link]");if(!n||!Lt(n))return;let r=n.getAttribute("href");r&&(t.preventDefault(),lt({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function ie(t){if(t.defaultPrevented)return;let e=t.target;if(!e||e.tagName!=="FORM"||e.hasAttribute("data-krate-reload"))return;let n=t.submitter||null;if((n&&n.getAttribute("formmethod")||e.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||e.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||e.getAttribute("action")||"",s;try{s=new URL(i||location.href,location.href)}catch{return}if(s.origin!==location.origin||s.protocol.indexOf("http")!==0)return;let a;try{a=n?new FormData(e,n):new FormData(e)}catch{a=new FormData(e),n&&n.name&&a.append(n.name,n.value)}let c=new URLSearchParams;for(let[u,l]of a.entries()){if(typeof l!="string")return;c.append(u,l)}t.preventDefault(),s.search=c.toString(),s.hash="",lt({url:s.href,kind:"push",scroll:!0})}function se(t){Y(m);let e=tt(t.state),n=location.href;if(x(n)===A){re(),m=e||m;let i=e?L.get(e):void 0;i!==void 0?window.scrollTo(0,i):Rt(location.hash),st();return}let r=e?X.get(e):void 0;if(r&&e&&r.path===x(n)&&r.path===M&&Ze(r,e))return;let o=t.state&&typeof t.state=="object"?t.state.__kint:null;if(o&&o.base===M){let i=xt(n);if(i&&i.slot.key===o.key){Ct({url:n,kind:"pop",scroll:!1,restoreKey:e},i);return}}ct({url:n,kind:"pop",scroll:!0,restoreKey:e})}function ae(){Et(),ue()}function ce(){Y(m);try{history.scrollRestoration="auto"}catch{}}function le(){try{history.scrollRestoration="manual"}catch{}}function ot(){$t(),at(),zt(document),document.querySelectorAll("script[src]").forEach(t=>{kt.test(t.src)||t.setAttribute("data-krate-spa","")})}function ue(){if(!R||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(A!==M){let t=xt(location.href);if(t&&t.slot.src==="intercept")return Ct({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},t)}return ct({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function fe(t,e={}){return R?lt({url:C(t),kind:"push",scroll:e.scroll!==!1,state:e.state}):(typeof location<"u"&&location.assign(C(t)),Promise.resolve())}function de(t,e={}){return R?lt({url:C(t),kind:"replace",scroll:e.scroll!==!1,state:e.state}):(typeof location<"u"&&location.replace(C(t)),Promise.resolve())}var en={push:fe,replace:de,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:ue,prefetch(t){if(!R||typeof location>"u")return Promise.resolve();let e;try{e=new URL(C(t),location.href)}catch{return Promise.resolve()}return e.origin!==location.origin?Promise.resolve():At(e.href)},subscribe:Wt,getState:Ft,invalidate:Et};function nn(t,e={}){return R?(e.replace?de(t,e):fe(t,e),!1):(typeof location<"u"&&(e.replace?location.replace(C(t)):location.assign(C(t))),!0)}function he(){if(!(typeof document>"u")){if(R){ot();return}if(R=!0,document.querySelectorAll("script[data-krate-boot]").forEach(t=>nt.add(t.textContent||"")),A=x(location.href),N=Qt(document),gt=yt(document),M=A,m=tt(history.state)||I(),tt(history.state)===void 0)try{history.replaceState(z(m,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",oe),document.addEventListener("submit",ie),window.addEventListener("popstate",se),window.addEventListener("krate:revalidate",ae),window.addEventListener("pagehide",ce),window.addEventListener("pageshow",le),He(),De(),ot()}}function rn(){he()}function on(){if(R){R=!1,document.removeEventListener("click",oe),document.removeEventListener("submit",ie),window.removeEventListener("popstate",se),window.removeEventListener("krate:revalidate",ae),window.removeEventListener("pagehide",ce),window.removeEventListener("pageshow",le),document.removeEventListener("mouseover",et),document.removeEventListener("focusin",et);for(let t of W.values())clearTimeout(t);W=new Map,H&&(H.disconnect(),H=null),k&&k.abort(),k=void 0,_++,S.clear(),T.clear(),L.clear(),q.clear(),nt.clear(),$.clear(),j="idle",J=[],N=[],X.clear(),M=""}}return be(sn);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }