@krate/runtime 0.5.0-rc.12 → 0.5.0-rc.14

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.
@@ -58,3 +58,5 @@ export declare function cookies(): ActionCookies;
58
58
  * `{ redirect: url }` from the action has the same effect.
59
59
  */
60
60
  export declare function redirect(url: string): never;
61
+ /** redirect() that a page or API route answers with 308 instead of 307 (a server action still navigates the client). */
62
+ export declare function permanentRedirect(url: string): never;
@@ -101,3 +101,10 @@ export function redirect(url) {
101
101
  err.__krateRedirect = url;
102
102
  throw err;
103
103
  }
104
+ /** redirect() that a page or API route answers with 308 instead of 307 (a server action still navigates the client). */
105
+ export function permanentRedirect(url) {
106
+ const err = new Error('Server action redirect to ' + url);
107
+ err.__krateRedirect = url;
108
+ err.__krateRedirectStatus = 308;
109
+ throw err;
110
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns the sealed token for the values `action.bind(null, ...values)` fixed.
3
+ * `path` names the prop for error messages (`props.action`).
4
+ */
5
+ export declare function sealBoundArgs(id: string, values: unknown[], path: string): string;
@@ -0,0 +1,105 @@
1
+ // Seals the arguments a server action was bound to with .bind() when the action
2
+ // crosses into a client component, in the format of the closure tokens of inline
3
+ // server actions (compiler/internal/build/inline_actions.go): AES-256-GCM, the
4
+ // action id as associated data, a "k1." prefix. The server action endpoint opens
5
+ // the token and puts the values in front of the client's own arguments, so the
6
+ // browser never sees or sends them.
7
+ const MAX_URL_TOKEN = 3500;
8
+ function builtin(name) {
9
+ const get = globalThis.process?.getBuiltinModule;
10
+ if (typeof get !== 'function') {
11
+ throw new Error('sealing bound server action arguments needs Node.js (process.getBuiltinModule)');
12
+ }
13
+ return get(name);
14
+ }
15
+ function actionSecret() {
16
+ const proc = globalThis.process;
17
+ let secret = proc?.env?.KRATE_ACTION_SECRET || '';
18
+ if (!secret && !globalThis[Symbol.for('krate.action.deployed')]) {
19
+ const fs = builtin('node:fs');
20
+ const path = builtin('node:path');
21
+ const dir = proc?.env?.KRATE_ACTION_DIR || path.join(proc?.env?.KRATE_ROOT || proc?.cwd?.() || '.', '.krate', 'actions');
22
+ try {
23
+ secret = JSON.parse(fs.readFileSync(path.join(dir, 'manifest.json'), 'utf8')).key || '';
24
+ }
25
+ catch {
26
+ secret = '';
27
+ }
28
+ }
29
+ if (!secret) {
30
+ throw new Error('bound server action arguments need an encryption key: set KRATE_ACTION_SECRET, or run the server from a build whose .krate/actions/manifest.json holds one');
31
+ }
32
+ return secret;
33
+ }
34
+ function describe(v) {
35
+ if (typeof v === 'function')
36
+ return 'a function';
37
+ if (typeof v === 'symbol')
38
+ return 'a symbol';
39
+ if (typeof v === 'number')
40
+ return 'the number ' + v;
41
+ if (v && typeof v.then === 'function')
42
+ return 'a Promise (await it before binding it)';
43
+ const proto = v && Object.getPrototypeOf(v);
44
+ return proto && proto.constructor && proto.constructor.name ? 'a ' + proto.constructor.name + ' instance' : 'a non-plain object';
45
+ }
46
+ function encode(v, where, seen) {
47
+ if (v === null || typeof v === 'string' || typeof v === 'boolean')
48
+ return v;
49
+ if (typeof v === 'number') {
50
+ if (!Number.isFinite(v))
51
+ throw new TypeError(where + ', which is ' + describe(v));
52
+ return v;
53
+ }
54
+ if (v === undefined)
55
+ return { $: 'u' };
56
+ if (typeof v === 'bigint')
57
+ return { $: 'n', v: v.toString() };
58
+ if (v instanceof Date)
59
+ return { $: 'd', v: v.toISOString() };
60
+ if (typeof v === 'function' || typeof v === 'symbol')
61
+ throw new TypeError(where + ', which is ' + describe(v));
62
+ if (seen.has(v))
63
+ throw new TypeError(where + ', which is circular');
64
+ seen.add(v);
65
+ try {
66
+ if (Array.isArray(v))
67
+ return v.map((x, i) => encode(x, where + '[' + i + ']', seen));
68
+ const proto = Object.getPrototypeOf(v);
69
+ if (proto !== Object.prototype && proto !== null)
70
+ throw new TypeError(where + ', which is ' + describe(v));
71
+ const out = {};
72
+ for (const k of Object.keys(v))
73
+ out[k] = encode(v[k], where + '.' + k, seen);
74
+ return Object.prototype.hasOwnProperty.call(out, '$') ? { $: 'o', v: out } : out;
75
+ }
76
+ finally {
77
+ seen.delete(v);
78
+ }
79
+ }
80
+ /**
81
+ * Returns the sealed token for the values `action.bind(null, ...values)` fixed.
82
+ * `path` names the prop for error messages (`props.action`).
83
+ */
84
+ export function sealBoundArgs(id, values, path) {
85
+ const encoded = values.map((v, i) => {
86
+ try {
87
+ return encode(v, `argument ${i + 1}`, new Set());
88
+ }
89
+ catch (e) {
90
+ throw new TypeError(`Prop \`${path}\` is a server action bound to a value that cannot be sent to a client component: ${e.message}. ` +
91
+ 'Only strings, numbers, booleans, null, undefined, bigint, Date, and plain objects and arrays of those can be bound; read anything else inside the action.');
92
+ }
93
+ });
94
+ const crypto = builtin('node:crypto');
95
+ const key = crypto.createHash('sha256').update('krate-inline-action\0' + actionSecret()).digest();
96
+ const iv = crypto.randomBytes(12);
97
+ const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
98
+ cipher.setAAD(Buffer.from(id));
99
+ const body = Buffer.concat([cipher.update(JSON.stringify(encoded), 'utf8'), cipher.final()]);
100
+ const token = 'k1.' + Buffer.concat([iv, body, cipher.getAuthTag()]).toString('base64url');
101
+ if (token.length > MAX_URL_TOKEN) {
102
+ throw new RangeError(`Prop \`${path}\` is a server action bound to ${token.length} bytes of data; bind ids and look the rest up inside the action`);
103
+ }
104
+ return token;
105
+ }
package/dist/actions.js CHANGED
@@ -413,9 +413,15 @@ export function stripActionURL(url) {
413
413
  try {
414
414
  const raw = new URLSearchParams(url.slice(i + 1)).get(ACTION_ARGS_FIELD);
415
415
  const leading = raw ? JSON.parse(raw) : null;
416
+ const bound = new URLSearchParams(url.slice(i + 1)).get('__krate_bound');
417
+ const keep = [];
416
418
  if (Array.isArray(leading) && typeof leading[0] === 'string' && leading[0].startsWith('k1.')) {
417
- return base + '?' + ACTION_ARGS_FIELD + '=' + encodeURIComponent(JSON.stringify([leading[0]]));
419
+ keep.push(ACTION_ARGS_FIELD + '=' + encodeURIComponent(JSON.stringify([leading[0]])));
418
420
  }
421
+ if (bound && bound.startsWith('k1.'))
422
+ keep.push('__krate_bound=' + encodeURIComponent(bound));
423
+ if (keep.length > 0)
424
+ return base + '?' + keep.join('&');
419
425
  }
420
426
  catch {
421
427
  // not a token: strip like any native query
@@ -32,6 +32,8 @@ export interface CacheScope {
32
32
  errorCaught?: boolean;
33
33
  /** Head tags the render asked for (react-dom preload, preconnect, ...), deduplicated. */
34
34
  hints?: Set<string>;
35
+ /** Islands rendered so far, by module and export: the next one's occurrence number (see islandIdPrefix). */
36
+ islands?: Map<string, number>;
35
37
  }
36
38
  /** Minimal AsyncLocalStorage shape (the Node class satisfies it). */
37
39
  export interface AsyncStore<T> {
@@ -2,6 +2,8 @@ export type FlightHooks = {
2
2
  isAction(v: unknown): string | undefined;
3
3
  isJSX(v: unknown): boolean;
4
4
  fail(path: string, what: string, hint?: string): Error;
5
+ /** Seals the arguments an action was bound to (see action-seal.ts); absent where nothing can be sealed. */
6
+ sealBound?(id: string, bound: unknown[], path: string): string;
5
7
  };
6
8
  export declare function describeValue(v: unknown): string;
7
9
  export declare function encodeProp(v: unknown, path: string, hooks: FlightHooks): unknown;
@@ -60,8 +60,19 @@ export function encodeProp(v, path, hooks) {
60
60
  return tag("Y", key);
61
61
  }
62
62
  const action = hooks.isAction(v);
63
- if (action !== undefined)
63
+ if (action !== undefined) {
64
+ // Arguments pre-filled with .bind() travel sealed in the action URL, never in
65
+ // the clear; an inline action's closure token is already part of its URL.
66
+ const f = v;
67
+ if (Array.isArray(f.$$krateBound) && f.$$krateBound.length > 0 && !action.includes("__krate_args=")) {
68
+ if (!hooks.sealBound || typeof f.$$krateAction !== "string") {
69
+ throw hooks.fail(path, "a server action with bound arguments", "bound arguments can only be sealed for a \"use server\" function; pass the values as props instead");
70
+ }
71
+ const token = hooks.sealBound(f.$$krateAction, f.$$krateBound, path);
72
+ return { __krateAction: action + (action.includes("?") ? "&" : "?") + "__krate_bound=" + encodeURIComponent(token) };
73
+ }
64
74
  return { __krateAction: action };
75
+ }
65
76
  if (Array.isArray(v))
66
77
  return v.map((x, i) => encodeProp(x, `${path}[${i}]`, hooks));
67
78
  if (typeof v === "object") {
@@ -81,8 +81,14 @@ export function compareRouteSpecificity(a, b) {
81
81
  if (sa[i].kind === 0 && sa[i].text !== sb[i].text)
82
82
  return strCompare(sa[i].text, sb[i].text);
83
83
  }
84
- if (sa.length !== sb.length)
84
+ if (sa.length !== sb.length) {
85
+ // A trailing optional catch-all is the less specific: "shop" answers /shop before "shop/[[...x]]".
86
+ if (sa.length > sb.length && sa[sb.length].kind === 3)
87
+ return 1;
88
+ if (sb.length > sa.length && sb[sa.length].kind === 3)
89
+ return -1;
85
90
  return sb.length - sa.length;
91
+ }
86
92
  return strCompare(a, b);
87
93
  }
88
94
  export function normalizeRoutePattern(p) {
@@ -611,6 +611,9 @@ function updateIsland(l, n, jobs) {
611
611
  const old = parse(l.json);
612
612
  const changed = retaken || JSON.stringify(props) !== JSON.stringify(old ? old.p || {} : null);
613
613
  raw.p = props;
614
+ // The island keeps the useId() prefix it mounted with.
615
+ if (old && old.i !== undefined)
616
+ raw.i = old.i;
614
617
  l.start.data = OPEN + escapeComment(JSON.stringify(raw));
615
618
  // Nested islands in its slots may have replaced their nodes: the sets
616
619
  // follow the document before the island renders again.
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var v=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var n in e)v(t,n,{get:e[n],enumerable:!0})},X=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Q(e))!V.call(t,r)&&r!==n&&v(t,r,{get:()=>e[r],enumerable:!(o=U(e,r))||o.enumerable});return t};var Y=t=>X(v({},"__esModule",{value:!0}),t);var vt={};z(vt,{ACTION_ARGS_FIELD:()=>p,ServerActionError:()=>w,__krateAction:()=>at,__krateActionState:()=>mt,__krateAssignRef:()=>ut,__krateBeginAction:()=>F,__krateBindFormAction:()=>ft,__krateFormStatusMount:()=>ct,__krateOptimistic:()=>gt,callServerAction:()=>y,getFormStatus:()=>lt,installActionForms:()=>W,isActionPending:()=>it,isServerAction:()=>G,reportActionError:()=>_,requestFormReset:()=>dt,runActionTransition:()=>b,setActionTransitionRunner:()=>st,stripActionURL:()=>N,submitFormAction:()=>K,takeFlash:()=>J});var Z="__krate_cfg__";function R(){let t=globalThis;if(t.__KRATE_CFG__)return t.__KRATE_CFG__;let e=t.document,n=e&&typeof e.getElementById=="function"?e.getElementById(Z):null;if(n)try{let o=JSON.parse(n.textContent||"{}");if(o&&typeof o=="object")return t.__KRATE_CFG__=o,o}catch{}return{}}function h(){let t=R(),e=t&&t.basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function C(t){let e=h();return e&&t.charCodeAt(0)===47&&t.charCodeAt(1)!==47?e+t:t}var P=window.createEffect;var O=window.krateRunEvent;var d=window.krateTransitionWrites,L=window.onCleanup;var p="__krate_args",w=class extends Error{constructor(e,n,o){super(e),this.name="ServerActionError",this.status=n,o&&(this.digest=o)}};function G(t){return typeof t=="function"&&typeof t.$$krateAction=="string"}var S=0;function tt(t){let e=nt(t);if(!e)return;let n=globalThis.navigate;typeof n=="function"?n(e):typeof location<"u"&&location.assign(C(e))}function et(t){typeof location>"u"||!/^https?:\/\//i.test(t)||location.assign(t)}function nt(t){return!t||!t.startsWith("/")||t.startsWith("//")||t.includes("\\")||/[\u0000-\u001F\u007F]/.test(t)?"":t}function ot(t){if(typeof window>"u"||typeof CustomEvent>"u")return;let e={paths:t&&Array.isArray(t.paths)?t.paths:[],tags:t&&Array.isArray(t.tags)?t.tags:[]};window.dispatchEvent(new CustomEvent("krate:revalidate",{detail:e}))}function rt(t,e,n){let o=t?t.error:void 0;if(o&&typeof o=="object")return new w(o.message||"Server action failed",e,o.digest);let r=t&&(t.details||(typeof o=="string"?o:""))||n||"Server action failed";return new w(r,e)}async function y(t,e){let n={accept:"application/json","x-krate-action":"fetch"};typeof location<"u"&&(n["x-krate-return"]=location.pathname+location.search);let o,r=e[e.length-1];if(typeof FormData<"u"&&r instanceof FormData){let s=new FormData;r.forEach((u,l)=>{l!==p&&s.append(l,u)});let c=e.slice(0,-1);c.length>0&&s.set(p,JSON.stringify(c)),o=s}else n["content-type"]="application/json",o=JSON.stringify({args:e});let a=await fetch(t,{method:"POST",credentials:"same-origin",headers:n,body:o}),i=null;try{i=await a.json()}catch{i=null}if(!a.ok||!i||i.ok===!1)throw rt(i,a.status,a.statusText);return i.revalidated&&ot(i.revalidation),typeof i.redirect=="string"&&i.redirect&&(S++,i.external?et(i.redirect):tt(i.redirect)),i.result}function B(t,e){let n=h()+"/__krate/action/"+t,o=function(...r){return y(n,e.concat(r))};return Object.defineProperty(o,"actionUrl",{value:n}),Object.defineProperty(o,"$$krateAction",{value:t}),Object.defineProperty(o,"$$krateBound",{value:e}),Object.defineProperty(o,"bind",{value:(r,...a)=>B(t,e.concat(a))}),o.toString=()=>n,o}function at(t){return B(t,[])}var f=0,x=new Set;function F(){f++;let t=!1;return()=>{t||(t=!0,f--,f===0&&d(()=>{for(let e of Array.from(x))e()}))}}function it(){return f>0}var I=t=>{let e=F(),n;try{n=t()}catch(o){return e(),Promise.reject(o)}return Promise.resolve(n).finally(e)},q=I;function st(t){q=t||I}function b(t){return q(t)}function _(t,e){let n=globalThis;if(typeof n.__krateActionError=="function")try{if(n.__krateActionError(t,e)===!0)return}catch{}let o=e||(typeof document<"u"?document:null),r=!1;if(o&&typeof CustomEvent<"u"){let a=new CustomEvent("krate:action-error",{bubbles:!0,cancelable:!0,detail:{error:t}});r=!o.dispatchEvent(a)}r||console.error("krate server action:",t)}var T=Object.freeze({pending:!1,data:null,method:null,action:null}),k=new WeakMap;function $(t){let e=k.get(t);return e||(e={status:T,subs:new Set,running:0,resetRequested:!1},k.set(t,e)),e}function D(t,e){t.status=e;for(let n of Array.from(t.subs))n(e)}function ct(t,e){let n=null;for(let a=t?t.parentElement:null;a;a=a.parentElement)if(a.tagName==="FORM"){n=a;break}if(!n)return()=>{};let o=$(n),r=a=>{e.status&&e.status(a),e.pending&&e.pending(a.pending),e.data&&e.data(a.data),e.method&&e.method(a.method),e.action&&e.action(a.action)};return o.subs.add(r),r(o.status),()=>{o.subs.delete(r)}}function ut(t,e){typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e)}function lt(t){return k.get(t)?.status||T}function j(t){let e=Array.from(t.querySelectorAll("[data-kattr-value],[data-kattr-checked]")).map(n=>({el:n,value:n.value,checked:n.checked}));t.reset();for(let n of e)n.el.hasAttribute("data-kattr-value")&&(n.el.value=n.value),n.el.hasAttribute("data-kattr-checked")&&(n.el.checked=n.checked)}function dt(t){let e=k.get(t);if(e&&e.running>0){e.resetRequested=!0;return}j(t)}function ft(t,e){t&&(t.__krateFormAction=e,t.tagName==="FORM"?(t.removeAttribute("action"),t.removeAttribute("method")):(t.removeAttribute("formaction"),t.removeAttribute("formmethod")),t.removeAttribute("data-krate-action"))}function M(t){if(!t)return null;let e=t.__krateFormAction;if(typeof e!="function")return null;try{return e()}catch{return null}}function pt(t,e){if(e&&e!==t){let o=M(e);if(typeof o=="function")return{fn:o};if(e.hasAttribute("data-krate-action"))return{url:e.formAction||t.action};if(e.hasAttribute("formaction"))return null}let n=M(t);return typeof n=="function"?{fn:n}:t.hasAttribute("data-krate-action")?{url:t.action}:null}function wt(t,e){let n;try{n=e?new FormData(t,e):new FormData(t)}catch{n=new FormData(t);let o=e;o&&o.name&&n.append(o.name,o.value)}return n}function N(t){let e=t.indexOf("?");if(e===-1)return t;let n=t.slice(0,e);try{let o=new URLSearchParams(t.slice(e+1)).get(p),r=o?JSON.parse(o):null;if(Array.isArray(r)&&typeof r[0]=="string"&&r[0].startsWith("k1."))return n+"?"+p+"="+encodeURIComponent(JSON.stringify([r[0]]))}catch{}return n}async function K(t,e,n,o=null,r){let a=$(t),i=(o&&o.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase();a.running++,D(a,{pending:!0,data:n,method:i,action:e||r||null}),t.setAttribute("data-krate-action-pending","1");let s=!1;try{await b(async()=>{let c=e;if(c&&typeof c.__krateRun=="function"){s=await c.__krateRun(n);return}typeof c=="function"?await c(n):r&&await y(N(r),[n]),s=!0})}catch(c){_(c,t)}finally{a.running--,a.running===0&&(t.removeAttribute("data-krate-action-pending"),d(()=>D(a,T)),(s||a.resetRequested)&&(a.resetRequested=!1,s&&t.hasAttribute("data-krate-reload")?location.reload():j(t)))}return s}function kt(t){let e=t.target;if(!e||e.tagName!=="FORM"||t.defaultPrevented)return;let n=t.submitter||null,o=pt(e,n);if(!o)return;t.preventDefault();let r=wt(e,n);O("submit",!0,()=>{K(e,o.fn,r,n,o.url)})}function W(t=typeof document<"u"?document:void 0){if(!t)return;let e=t.defaultView;!e||e.__krateActionBound||(e.__krateActionBound=!0,t.addEventListener("submit",kt,!1))}function A(t){try{let e=t.split(".")[0].replace(/-/g,"+").replace(/_/g,"/"),n=atob(e+"=".repeat((4-e.length%4)%4));return JSON.parse(decodeURIComponent(escape(n)))}catch{return null}}function J(t){if(typeof document>"u")return{found:!1};let e=/(?:^|;\s*)krate_flash=([^;]*)/.exec(document.cookie||"");if(e){let o=A(e[1]);return o&&o.a===t?(document.cookie="krate_flash=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax",H(t),{found:!0,value:o.r}):{found:!1}}let n=document.querySelectorAll("[data-krate-flash]");for(let o=0;o<n.length;o++){let r=A(n[o].getAttribute("data-krate-flash")||"");if(r&&r.a===t)return H(t),{found:!0,value:r.r}}return{found:!1}}function H(t){let e=document.querySelectorAll("[data-krate-flash]");for(let n=0;n<e.length;n++){let o=A(e[n].getAttribute("data-krate-flash")||"");o&&o.a===t&&e[n].parentNode?.removeChild(e[n])}}function mt(t,e,n,o){let r=[],a=!1;if(G(t)){let u=J(t.$$krateAction);u.found&&n(u.value)}let i=async()=>{for(a=!0;r.length>0;){let u=r.shift(),l=!1;try{let m=S,g=await b(()=>t(e(),u.payload));S===m&&d(()=>n(g)),l=!0}catch(m){let g=r.splice(0);for(let E of g)E.end(),E.done(!1);_(m)}finally{d(()=>{u.end(),u.done(l)})}}a=!1,d(()=>o(!1))},s=u=>new Promise(l=>{r.push({payload:u,end:F(),done:l}),o(!0),a||i()}),c=(u=>{s(u)});return c.__krateRun=s,c}function gt(t,e,n){let o=[],r=i=>{let s=i;for(let c of o)s=n?n(s,c):c;return s};P(()=>{e(r(t()))});let a=()=>{o.length!==0&&(o=[],e(t()))};return x.add(a),L(()=>{x.delete(a)}),i=>{o.push(i),e(r(t())),f===0&&queueMicrotask(()=>{f===0&&a()})}}typeof document<"u"&&W(document);return Y(vt);})();
1
+ var __krate_exports=(()=>{var h=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var n in e)h(t,n,{get:e[n],enumerable:!0})},X=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Q(e))!V.call(t,r)&&r!==n&&h(t,r,{get:()=>e[r],enumerable:!(o=J(e,r))||o.enumerable});return t};var Y=t=>X(h({},"__esModule",{value:!0}),t);var ht={};z(ht,{ACTION_ARGS_FIELD:()=>p,ServerActionError:()=>w,__krateAction:()=>at,__krateActionState:()=>mt,__krateAssignRef:()=>ut,__krateBeginAction:()=>_,__krateBindFormAction:()=>ft,__krateFormStatusMount:()=>ct,__krateOptimistic:()=>gt,callServerAction:()=>y,getFormStatus:()=>lt,installActionForms:()=>W,isActionPending:()=>it,isServerAction:()=>G,reportActionError:()=>F,requestFormReset:()=>dt,runActionTransition:()=>b,setActionTransitionRunner:()=>st,stripActionURL:()=>N,submitFormAction:()=>K,takeFlash:()=>U});var Z="__krate_cfg__";function R(){let t=globalThis;if(t.__KRATE_CFG__)return t.__KRATE_CFG__;let e=t.document,n=e&&typeof e.getElementById=="function"?e.getElementById(Z):null;if(n)try{let o=JSON.parse(n.textContent||"{}");if(o&&typeof o=="object")return t.__KRATE_CFG__=o,o}catch{}return{}}function v(){let t=R(),e=t&&t.basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function C(t){let e=v();return e&&t.charCodeAt(0)===47&&t.charCodeAt(1)!==47?e+t:t}var P=window.createEffect;var O=window.krateRunEvent;var d=window.krateTransitionWrites,L=window.onCleanup;var p="__krate_args",w=class extends Error{constructor(e,n,o){super(e),this.name="ServerActionError",this.status=n,o&&(this.digest=o)}};function G(t){return typeof t=="function"&&typeof t.$$krateAction=="string"}var S=0;function tt(t){let e=nt(t);if(!e)return;let n=globalThis.navigate;typeof n=="function"?n(e):typeof location<"u"&&location.assign(C(e))}function et(t){typeof location>"u"||!/^https?:\/\//i.test(t)||location.assign(t)}function nt(t){return!t||!t.startsWith("/")||t.startsWith("//")||t.includes("\\")||/[\u0000-\u001F\u007F]/.test(t)?"":t}function ot(t){if(typeof window>"u"||typeof CustomEvent>"u")return;let e={paths:t&&Array.isArray(t.paths)?t.paths:[],tags:t&&Array.isArray(t.tags)?t.tags:[]};window.dispatchEvent(new CustomEvent("krate:revalidate",{detail:e}))}function rt(t,e,n){let o=t?t.error:void 0;if(o&&typeof o=="object")return new w(o.message||"Server action failed",e,o.digest);let r=t&&(t.details||(typeof o=="string"?o:""))||n||"Server action failed";return new w(r,e)}async function y(t,e){let n={accept:"application/json","x-krate-action":"fetch"};typeof location<"u"&&(n["x-krate-return"]=location.pathname+location.search);let o,r=e[e.length-1];if(typeof FormData<"u"&&r instanceof FormData){let s=new FormData;r.forEach((u,l)=>{l!==p&&s.append(l,u)});let c=e.slice(0,-1);c.length>0&&s.set(p,JSON.stringify(c)),o=s}else n["content-type"]="application/json",o=JSON.stringify({args:e});let a=await fetch(t,{method:"POST",credentials:"same-origin",headers:n,body:o}),i=null;try{i=await a.json()}catch{i=null}if(!a.ok||!i||i.ok===!1)throw rt(i,a.status,a.statusText);return i.revalidated&&ot(i.revalidation),typeof i.redirect=="string"&&i.redirect&&(S++,i.external?et(i.redirect):tt(i.redirect)),i.result}function B(t,e){let n=v()+"/__krate/action/"+t,o=function(...r){return y(n,e.concat(r))};return Object.defineProperty(o,"actionUrl",{value:n}),Object.defineProperty(o,"$$krateAction",{value:t}),Object.defineProperty(o,"$$krateBound",{value:e}),Object.defineProperty(o,"bind",{value:(r,...a)=>B(t,e.concat(a))}),o.toString=()=>n,o}function at(t){return B(t,[])}var f=0,x=new Set;function _(){f++;let t=!1;return()=>{t||(t=!0,f--,f===0&&d(()=>{for(let e of Array.from(x))e()}))}}function it(){return f>0}var I=t=>{let e=_(),n;try{n=t()}catch(o){return e(),Promise.reject(o)}return Promise.resolve(n).finally(e)},j=I;function st(t){j=t||I}function b(t){return j(t)}function F(t,e){let n=globalThis;if(typeof n.__krateActionError=="function")try{if(n.__krateActionError(t,e)===!0)return}catch{}let o=e||(typeof document<"u"?document:null),r=!1;if(o&&typeof CustomEvent<"u"){let a=new CustomEvent("krate:action-error",{bubbles:!0,cancelable:!0,detail:{error:t}});r=!o.dispatchEvent(a)}r||console.error("krate server action:",t)}var T=Object.freeze({pending:!1,data:null,method:null,action:null}),k=new WeakMap;function q(t){let e=k.get(t);return e||(e={status:T,subs:new Set,running:0,resetRequested:!1},k.set(t,e)),e}function D(t,e){t.status=e;for(let n of Array.from(t.subs))n(e)}function ct(t,e){let n=null;for(let a=t?t.parentElement:null;a;a=a.parentElement)if(a.tagName==="FORM"){n=a;break}if(!n)return()=>{};let o=q(n),r=a=>{e.status&&e.status(a),e.pending&&e.pending(a.pending),e.data&&e.data(a.data),e.method&&e.method(a.method),e.action&&e.action(a.action)};return o.subs.add(r),r(o.status),()=>{o.subs.delete(r)}}function ut(t,e){typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e)}function lt(t){return k.get(t)?.status||T}function $(t){let e=Array.from(t.querySelectorAll("[data-kattr-value],[data-kattr-checked]")).map(n=>({el:n,value:n.value,checked:n.checked}));t.reset();for(let n of e)n.el.hasAttribute("data-kattr-value")&&(n.el.value=n.value),n.el.hasAttribute("data-kattr-checked")&&(n.el.checked=n.checked)}function dt(t){let e=k.get(t);if(e&&e.running>0){e.resetRequested=!0;return}$(t)}function ft(t,e){t&&(t.__krateFormAction=e,t.tagName==="FORM"?(t.removeAttribute("action"),t.removeAttribute("method")):(t.removeAttribute("formaction"),t.removeAttribute("formmethod")),t.removeAttribute("data-krate-action"))}function M(t){if(!t)return null;let e=t.__krateFormAction;if(typeof e!="function")return null;try{return e()}catch{return null}}function pt(t,e){if(e&&e!==t){let o=M(e);if(typeof o=="function")return{fn:o};if(e.hasAttribute("data-krate-action"))return{url:e.formAction||t.action};if(e.hasAttribute("formaction"))return null}let n=M(t);return typeof n=="function"?{fn:n}:t.hasAttribute("data-krate-action")?{url:t.action}:null}function wt(t,e){let n;try{n=e?new FormData(t,e):new FormData(t)}catch{n=new FormData(t);let o=e;o&&o.name&&n.append(o.name,o.value)}return n}function N(t){let e=t.indexOf("?");if(e===-1)return t;let n=t.slice(0,e);try{let o=new URLSearchParams(t.slice(e+1)).get(p),r=o?JSON.parse(o):null,a=new URLSearchParams(t.slice(e+1)).get("__krate_bound"),i=[];if(Array.isArray(r)&&typeof r[0]=="string"&&r[0].startsWith("k1.")&&i.push(p+"="+encodeURIComponent(JSON.stringify([r[0]]))),a&&a.startsWith("k1.")&&i.push("__krate_bound="+encodeURIComponent(a)),i.length>0)return n+"?"+i.join("&")}catch{}return n}async function K(t,e,n,o=null,r){let a=q(t),i=(o&&o.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase();a.running++,D(a,{pending:!0,data:n,method:i,action:e||r||null}),t.setAttribute("data-krate-action-pending","1");let s=!1;try{await b(async()=>{let c=e;if(c&&typeof c.__krateRun=="function"){s=await c.__krateRun(n);return}typeof c=="function"?await c(n):r&&await y(N(r),[n]),s=!0})}catch(c){F(c,t)}finally{a.running--,a.running===0&&(t.removeAttribute("data-krate-action-pending"),d(()=>D(a,T)),(s||a.resetRequested)&&(a.resetRequested=!1,s&&t.hasAttribute("data-krate-reload")?location.reload():$(t)))}return s}function kt(t){let e=t.target;if(!e||e.tagName!=="FORM"||t.defaultPrevented)return;let n=t.submitter||null,o=pt(e,n);if(!o)return;t.preventDefault();let r=wt(e,n);O("submit",!0,()=>{K(e,o.fn,r,n,o.url)})}function W(t=typeof document<"u"?document:void 0){if(!t)return;let e=t.defaultView;!e||e.__krateActionBound||(e.__krateActionBound=!0,t.addEventListener("submit",kt,!1))}function A(t){try{let e=t.split(".")[0].replace(/-/g,"+").replace(/_/g,"/"),n=atob(e+"=".repeat((4-e.length%4)%4));return JSON.parse(decodeURIComponent(escape(n)))}catch{return null}}function U(t){if(typeof document>"u")return{found:!1};let e=/(?:^|;\s*)krate_flash=([^;]*)/.exec(document.cookie||"");if(e){let o=A(e[1]);return o&&o.a===t?(document.cookie="krate_flash=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax",H(t),{found:!0,value:o.r}):{found:!1}}let n=document.querySelectorAll("[data-krate-flash]");for(let o=0;o<n.length;o++){let r=A(n[o].getAttribute("data-krate-flash")||"");if(r&&r.a===t)return H(t),{found:!0,value:r.r}}return{found:!1}}function H(t){let e=document.querySelectorAll("[data-krate-flash]");for(let n=0;n<e.length;n++){let o=A(e[n].getAttribute("data-krate-flash")||"");o&&o.a===t&&e[n].parentNode?.removeChild(e[n])}}function mt(t,e,n,o){let r=[],a=!1;if(G(t)){let u=U(t.$$krateAction);u.found&&n(u.value)}let i=async()=>{for(a=!0;r.length>0;){let u=r.shift(),l=!1;try{let m=S,g=await b(()=>t(e(),u.payload));S===m&&d(()=>n(g)),l=!0}catch(m){let g=r.splice(0);for(let E of g)E.end(),E.done(!1);F(m)}finally{d(()=>{u.end(),u.done(l)})}}a=!1,d(()=>o(!1))},s=u=>new Promise(l=>{r.push({payload:u,end:_(),done:l}),o(!0),a||i()}),c=(u=>{s(u)});return c.__krateRun=s,c}function gt(t,e,n){let o=[],r=i=>{let s=i;for(let c of o)s=n?n(s,c):c;return s};P(()=>{e(r(t()))});let a=()=>{o.length!==0&&(o=[],e(t()))};return x.add(a),L(()=>{x.delete(a)}),i=>{o.push(i),e(r(t())),f===0&&queueMicrotask(()=>{f===0&&a()})}}typeof document<"u"&&W(document);return Y(ht);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var m=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},M=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of I(t))!B.call(e,o)&&o!==n&&m(e,o,{get:()=>t[o],enumerable:!(r=q(t,o))||r.enumerable});return e};var G=e=>M(m({},"__esModule",{value:!0}),e);var se={};U(se,{forbidden:()=>A,krateLayoutSegments:()=>z,krateMatchParams:()=>W,krateResetNavigation:()=>$,krateRouteStore:()=>j,notFound:()=>T,permanentRedirect:()=>oe,redirect:()=>F,unauthorized:()=>_,useParams:()=>Q,usePathname:()=>Z,useRouter:()=>te,useSearchParams:()=>Y,useSelectedLayoutSegment:()=>re,useSelectedLayoutSegments:()=>ne});var b=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 T(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function C(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function A(){return C(403)}function _(){return C(401)}function x(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},r=[];for(let o of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!s){r.push(o);continue}let u=n[s[3]];u!==void 0&&u!==""&&r.push(...u.split("/").filter(Boolean))}return{path:"/"+r.join("/"),route:t,params:n}}function w(e){try{return decodeURIComponent(e)}catch{return e}}function E(){return x().path}function O(){let e=i(),t=new URLSearchParams;for(let[n,r]of Object.entries(e&&e.searchParams||{}))t.append(n,String(r));return t}function N(){let{route:e,params:t}=x(),n={};for(let r of e.split("/").filter(Boolean)){let o=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!o)continue;let s=t[o[3]];s===void 0||s===""||(n[o[3]]=o[2]?s.split("/").filter(Boolean).map(w):w(s))}return n}function d(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function P(){return{push:d("push"),replace:d("replace"),back:d("back"),forward:d("forward"),refresh:d("refresh"),prefetch:()=>{}}}function k(e,t){return x().path.split("/").filter(Boolean).map(w).slice(typeof t=="number"?t:0)}function D(e,t){let n=k(e,t);return n.length>0?n[0]:null}var H=window.getNavigationState,S=window.subscribeNavigation,a=window.krateRouter;function J(){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 y(){if(typeof location>"u")return{pathname:"/",search:"",route:""};let{pathname:e,search:t}=H();return{pathname:V(e),search:t,route:J()}}var p=null;function l(){if(p)return p;let[e,t]=b(y());if(p=e,typeof window<"u"){let n=()=>{let r=y(),o=e();(r.pathname!==o.pathname||r.search!==o.search||r.route!==o.route)&&t(r)};S(n),window.addEventListener("krate:navigate-end",n)}return e}function j(){let e=null;return{subscribe:r=>{let o=S(r);return typeof window<"u"&&window.addEventListener("krate:navigate-end",r),()=>{o(),typeof window<"u"&&window.removeEventListener("krate:navigate-end",r)}},getSnapshot:()=>{let r=y();return e&&e.pathname===r.pathname&&e.search===r.search&&e.route===r.route?e:(e=r,r)}}}function W(e,t){return L(e,t)}function z(e,t){return e.split("/").filter(Boolean).map(f).slice(typeof t=="number"?t:0)}function $(){p=null}function g(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function Z(){if(i())return E();let e=l(),t=c(()=>e().pathname);return g(t,()=>t())}function Y(){if(i())return O();let e=l(),t=c(()=>new URLSearchParams(e().search));return g(t,()=>e().search)}function f(e){try{return decodeURIComponent(e)}catch{return e}}function L(e,t){let n={};if(!e)return n;let r=e.split("/").filter(Boolean),o=t.split("/").filter(Boolean);for(let s=0;s<r.length;s++){let u=r[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(u);if(!h)continue;let R=h[3];if(h[2]){let v=o.slice(s).map(f);return v.length>0&&(n[R]=v),n}s<o.length&&(n[R]=f(o[s]))}return n}function Q(){if(i())return N();let e=l(),t=c(()=>{let n=e();return L(n.route,n.pathname)});return g(t,()=>JSON.stringify(t()))}var ee={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 te(){return i()?P():ee}function ne(e,t){if(i())return k(e,t);let n=l(),r=typeof t=="number"?t:0,o=c(()=>n().pathname.split("/").filter(Boolean).map(f).slice(r));return g(o,()=>o().join("/"))}function re(e,t){if(i())return D(e,t);let n=l(),r=typeof t=="number"?t:0,o=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(f);return s.length>r?s[r]:null});return g(o,()=>String(o()))}function F(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function oe(e){return F(e)}return G(se);})();
1
+ var __krate_exports=(()=>{var m=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},U=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of q(t))!I.call(e,o)&&o!==n&&m(e,o,{get:()=>t[o],enumerable:!(r=F(t,o))||r.enumerable});return e};var M=e=>U(m({},"__esModule",{value:!0}),e);var se={};B(se,{forbidden:()=>_,krateLayoutSegments:()=>W,krateMatchParams:()=>V,krateResetNavigation:()=>z,krateRouteStore:()=>J,notFound:()=>T,permanentRedirect:()=>oe,redirect:()=>re,unauthorized:()=>A,useParams:()=>Y,usePathname:()=>$,useRouter:()=>ee,useSearchParams:()=>Z,useSelectedLayoutSegment:()=>ne,useSelectedLayoutSegments:()=>te});var b=window.createSignal;var c=window.krateDerived;var G=Symbol.for("krate.request.store");function i(){let e=globalThis[G];return e&&typeof e.getStore=="function"?e.getStore():void 0}function T(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function C(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function _(){return C(403)}function A(){return C(401)}function x(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},r=[];for(let o of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!s){r.push(o);continue}let u=n[s[3]];u!==void 0&&u!==""&&r.push(...u.split("/").filter(Boolean))}return{path:"/"+r.join("/"),route:t,params:n}}function w(e){try{return decodeURIComponent(e)}catch{return e}}function E(){return x().path}function O(){let e=i(),t=new URLSearchParams;for(let[n,r]of Object.entries(e&&e.searchParams||{}))t.append(n,String(r));return t}function N(){let{route:e,params:t}=x(),n={};for(let r of e.split("/").filter(Boolean)){let o=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!o)continue;let s=t[o[3]];s===void 0||s===""||(n[o[3]]=o[2]?s.split("/").filter(Boolean).map(w):w(s))}return n}function d(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function P(){return{push:d("push"),replace:d("replace"),back:d("back"),forward:d("forward"),refresh:d("refresh"),prefetch:()=>{}}}function k(e,t){return x().path.split("/").filter(Boolean).map(w).slice(typeof t=="number"?t:0)}function D(e,t){let n=k(e,t);return n.length>0?n[0]:null}var H=window.getNavigationState,S=window.subscribeNavigation,a=window.krateRouter;function K(){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 j(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}function R(){if(typeof location>"u")return{pathname:"/",search:"",route:""};let{pathname:e,search:t}=H();return{pathname:j(e),search:t,route:K()}}var p=null;function l(){if(p)return p;let[e,t]=b(R());if(p=e,typeof window<"u"){let n=()=>{let r=R(),o=e();(r.pathname!==o.pathname||r.search!==o.search||r.route!==o.route)&&t(r)};S(n),window.addEventListener("krate:navigate-end",n)}return e}function J(){let e=null;return{subscribe:r=>{let o=S(r);return typeof window<"u"&&window.addEventListener("krate:navigate-end",r),()=>{o(),typeof window<"u"&&window.removeEventListener("krate:navigate-end",r)}},getSnapshot:()=>{let r=R();return e&&e.pathname===r.pathname&&e.search===r.search&&e.route===r.route?e:(e=r,r)}}}function V(e,t){return L(e,t)}function W(e,t){return e.split("/").filter(Boolean).map(f).slice(typeof t=="number"?t:0)}function z(){p=null}function g(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function $(){if(i())return E();let e=l(),t=c(()=>e().pathname);return g(t,()=>t())}function Z(){if(i())return O();let e=l(),t=c(()=>new URLSearchParams(e().search));return g(t,()=>e().search)}function f(e){try{return decodeURIComponent(e)}catch{return e}}function L(e,t){let n={};if(!e)return n;let r=e.split("/").filter(Boolean),o=t.split("/").filter(Boolean);for(let s=0;s<r.length;s++){let u=r[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(u);if(!h)continue;let y=h[3];if(h[2]){let v=o.slice(s).map(f);return v.length>0&&(n[y]=v),n}s<o.length&&(n[y]=f(o[s]))}return n}function Y(){if(i())return N();let e=l(),t=c(()=>{let n=e();return L(n.route,n.pathname)});return g(t,()=>JSON.stringify(t()))}var Q={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 ee(){return i()?P():Q}function te(e,t){if(i())return k(e,t);let n=l(),r=typeof t=="number"?t:0,o=c(()=>n().pathname.split("/").filter(Boolean).map(f).slice(r));return g(o,()=>o().join("/"))}function ne(e,t){if(i())return D(e,t);let n=l(),r=typeof t=="number"?t:0,o=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(f);return s.length>r?s[r]:null});return g(o,()=>String(o()))}function re(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function oe(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t.__krateRedirectStatus=308,t}return M(se);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var Pe=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var qt=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qt(t))!Zt.call(e,o)&&o!==n&&Pe(e,o,{get:()=>t[o],enumerable:!(r=Yt(t,o))||r.enumerable});return e};var tn=e=>en(Pe({},"__esModule",{value:!0}),e);var qn={};qt(qn,{compareRouteSpecificity:()=>Ht,destroyRouter:()=>Zn,getHistoryState:()=>hn,getNavigationState:()=>dt,initRouter:()=>zt,invalidatePrefetchCache:()=>We,krateRouter:()=>le,matchRoutePattern:()=>Mt,navigate:()=>Yn,pageAssetURLs:()=>at,reinitRouter:()=>Qn,subscribeNavigation:()=>ht});var nn="__krate_cfg__";function fe(){let e=globalThis;if(e.__KRATE_CFG__)return e.__KRATE_CFG__;let t=e.document,n=t&&typeof t.getElementById=="function"?t.getElementById(nn):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return e.__KRATE_CFG__=r,r}catch{}return{}}function G(){let e=fe(),t=e&&e.basePath||"";return!t||t==="/"?"":"/"+t.replace(/^\/+|\/+$/g,"")}function M(e){let t=G();return t&&e.charCodeAt(0)===47&&e.charCodeAt(1)!==47?t+e:e}var rn=/\/chunks\/runtime\.[^/]+\.js$/,st=/\/chunks\/(?:runtime\.[^/]+|c\/[^/]+)\.js$/;function ke(){return fe()}function z(e){let t=G();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function Me(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function te(e){if(ke().dev)try{console.warn("[krate router] "+e)}catch{}}function Fe(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(e,n).href}function at(e,t,n){let r=typeof e=="string"?new DOMParser().parseFromString(e,"text/html"):e,o=[],i=new Set,a=s=>{if(!s)return;let c;try{c=Fe(s,t)}catch{return}i.has(c)||n.has(c)||rn.test(c)||(i.add(c),o.push(c))};return r.querySelectorAll("script[src]").forEach(s=>a(s.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(s=>a(s.getAttribute("href"))),o}var R=!1,re=Symbol.for("krate.router");function V(){if(R)return null;let e=globalThis,t=e[re];if(!t&&typeof document<"u"&&lt()&&typeof e.initRouter=="function"){try{e.initRouter()}catch(n){console.error(n)}t=e[re]}return t&&t!==le?t:null}function ct(){let e=globalThis.navigate;return lt()&&typeof e=="function"?e:null}function lt(){let e=globalThis.krateRouter;return!!e&&e!==le}var L=0,v,Ye=0,f="",_="",X="idle",oe=new Set,A=new Map,C=new Map,on=30,sn=3e4,N=new Map,an=50,Ne=new Set,cn=128,he=new Map,b=new Map,ln=10,ne=0,J="",K=new Map,F=null,me=[],U,un="_krate/i",fn=200,dn=100,ut="data-krate-navigating";function He(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function j(){return Ye++,Date.now().toString(36)+"-"+Ye.toString(36)}function Y(e){try{let t=new URL(e,location.href);return t.hash="",t.href}catch{return e}}function E(e){let t=new URL(e,location.href);return Me(t.pathname)+t.search}function ie(e,t=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(e,t);return}t?location.replace(e):location.assign(e)}function se(e,t){return{__krate:e,state:t===void 0?null:t}}function pe(e){if(e&&typeof e=="object"&&typeof e.__krate=="string")return e.__krate}function hn(){if(typeof history>"u")return null;let e=history.state;return pe(e)!==void 0?e.state:e}function ft(){let e=new URL(location.href);return{url:e.href,pathname:z(e.pathname),search:e.search,hash:e.hash,status:X}}function dt(){let e=V();return e?e.getState():typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:ft()}function be(){if(oe.size===0)return;let e=ft();for(let t of Array.from(oe))try{t(e)}catch(n){console.error(n)}}function B(e){if(X!==e){X=e;try{document.documentElement.toggleAttribute(ut,e==="loading")}catch{}be()}}function ht(e){let t=V();return t?t.subscribe(e):(oe.add(e),()=>{oe.delete(e)})}function k(e,t,n=!1){try{let r=new CustomEvent(e,{detail:t,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function Be(e){try{let t=globalThis.__krate_onNavigation;typeof t=="function"&&t(e)}catch{}}function ae(e){if(e){if(N.delete(e),N.size>=an){let t=N.keys().next().value;t!==void 0&&N.delete(t)}N.set(e,window.scrollY||0)}}function mt(){let e=ke().prefetchTTL;return typeof e=="number"&&e>=0?e:sn}function mn(e,t){for(A.delete(e);A.size>=on;){let n=A.keys().next().value;if(n===void 0)break;A.delete(n)}A.set(e,t)}function pn(e){let t=A.get(e);if(t&&(A.delete(e),!(He()-t.at>mt())))return t}function We(e){if(ne++,e===void 0){A.clear(),C.clear(),b.clear();return}let t=Y(e);A.delete(t),C.delete(t),b.forEach((n,r)=>{Y(n.url)===t&&b.delete(r)})}function je(e,t){if(e){for(b.delete(e);b.size>=ln;){let n=b.keys().next().value;if(n===void 0)break;b.delete(n)}b.set(e,t)}}function gn(e,t){if(ce())return;let n=ne;vt(()=>{b.has(e)||n!==ne||fetch(Y(t),{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async r=>{if(!r.ok||/no-store/i.test(r.headers.get("cache-control")||""))return;let o=r.url||Y(t);if(E(o)!==E(t))return;let i=r.headers.get("content-type")||"",a=await r.text();(Ee(i)||i===""&&Q(a))&&(n!==ne||b.has(e)||!R||je(e,{html:a,url:t,status:r.status}))}).catch(()=>{})})}function Ee(e){return/text\/html|application\/xhtml\+xml/i.test(e)}function Q(e){return/^\s*(<!doctype html|<html|<head|<body)/i.test(e)}function Qe(e,t="script"){if(Ne.has(e)||Ne.size>=cn)return;Ne.add(e);let n=document.createElement("link");n.rel="prefetch",n.as=t,n.href=e,document.head.appendChild(n)}function yn(e,t){let n=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(o=>n.add(o.href));let r=[];return e.querySelectorAll('link[rel="stylesheet"][href]').forEach(o=>{try{let i=new URL(o.getAttribute("href"),t).href;!n.has(i)&&!r.includes(i)&&r.push(i)}catch{}}),r}function pt(){let e=new Set;document.querySelectorAll("script[src]").forEach(t=>e.add(t.src));try{for(let t of performance.getEntriesByType("resource"))e.add(t.name)}catch{}return e}function we(e){let t=Y(e),n=A.get(t);if(n&&He()-n.at<=mt())return Promise.resolve();let r=C.get(t);if(r)return r;let o=fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let a=i.headers.get("content-type")||"",s=i.url||t;if(new URL(s,location.href).origin!==location.origin)return;let c=await i.text();if(!(Ee(a)||a===""&&Q(c))||C.get(t)!==o)return;mn(t,{html:c,url:s,status:i.status,at:He()});let u=new DOMParser().parseFromString(c,"text/html");for(let l of yn(u,s))Qe(l,"style");for(let l of at(u,s,pt()))Qe(l)}).catch(()=>{}).finally(()=>{C.get(t)===o&&C.delete(t)});return C.set(t,o),o}function Ve(e){if(e.hasAttribute("data-krate-external")||e.hasAttribute("download"))return!1;let t=e.getAttribute("href");if(!t||t.startsWith("javascript:"))return!1;let n;try{n=new URL(t,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=e.getAttribute("target");return!(r&&r!=="_self")}function gt(e){let t=e.getAttribute("data-prefetch");return e.hasAttribute("data-prefetch")&&t!=="false"&&t!=="0"}var vn=5,De=0;function ce(){let e=navigator.connection;return e?e.saveData===!0||e.effectiveType==="slow-2g"||e.effectiveType==="2g":!1}function yt(e){if(!gt(e))return!1;let t=e.getAttribute("data-prefetch");return t==="viewport"||ke().prefetch==="viewport"&&t!=="intent"}function vt(e){let t=window.requestIdleCallback;typeof t=="function"?t(e,{timeout:1e3}):setTimeout(e,50)}function kt(e){let t=e.target;if(!t||typeof t.closest!="function")return null;let n=t.closest("a[data-prefetch]");if(!n||!gt(n)||!Ve(n)||ce())return null;let r=n.getAttribute("href");if(!r)return null;let o=new URL(r,location.href).href;return E(o)===_?null:{a:n,url:o}}function ge(e){let t=kt(e);if(!t)return;let{a:n,url:r}=t,o=K.get(n);o&&clearTimeout(o);let i=setTimeout(()=>{K.delete(n),we(r)},fn);K.set(n,i)}function bt(e){if(typeof e.button=="number"&&e.button!==0)return;let t=kt(e);if(!t)return;let n=K.get(t.a);n&&(clearTimeout(n),K.delete(t.a)),we(t.url)}var Et=["touchstart",typeof PointerEvent=="function"?"pointerdown":"mousedown"];function wt(){De=0,!(!F||ce())&&document.querySelectorAll("a[data-prefetch]").forEach(e=>{yt(e)&&F.observe(e)})}function kn(){document.addEventListener("mouseover",ge),document.addEventListener("focusin",ge);for(let e of Et)document.addEventListener(e,bt,{passive:!0});typeof IntersectionObserver<"u"&&(F=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let n=t.target,r=n.getAttribute("href");if(r&&Ve(n)&&yt(n)&&De<vn&&!ce()){let o=new URL(r,location.href).href;E(o)!==_&&(De++,vt(()=>{we(o)}))}F.unobserve(t.target)}},{rootMargin:"200px"}),wt())}function bn(){let e=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof e!="function"||!e("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]')&&!ce())try{let t=document.createElement("script");t.type="speculationrules";let n=G();t.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"&&String(o.effectiveDirective||o.violatedDirective||"").startsWith("script-src")&&(t.remove(),document.removeEventListener("securitypolicyviolation",r))};document.addEventListener("securitypolicyviolation",r),document.head.appendChild(t)}catch{}}function En(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function wn(){return ke().viewTransitions===!1||En()?!1:typeof document.startViewTransition=="function"}function S(e){return e.getElementById("root")||e.body}function Sn(){U!==void 0&&clearTimeout(U),U=setTimeout(()=>{U=void 0;let e=document.querySelector("template[data-krate-loading]");if(X!=="loading"||!e||!e.content||me.length>0)return;let t=e.content.cloneNode(!0);me=Array.from(t.childNodes),document.body.appendChild(t)},dn)}function Se(){U!==void 0&&(clearTimeout(U),U=void 0);for(let e of me)e.parentNode&&e.parentNode.removeChild(e);me=[]}function St(e){e.querySelectorAll("[data-view-transition]").forEach(t=>{let n=t.getAttribute("data-view-transition");n&&(t.style.viewTransitionName=n);let r=t.getAttribute("data-view-transition-class");r&&t.style.setProperty("view-transition-class",r)})}var Tn=3e3;function Tt(e){return new Promise(t=>{let n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),t()};e.addEventListener("load",n),e.addEventListener("error",n)})}function At(e){if(e.length===0)return Promise.resolve();let t,n=new Promise(r=>{t=setTimeout(r,Tn)});return Promise.race([Promise.all(e).then(()=>{}),n]).then(()=>clearTimeout(t))}function An(e,t){let n=[];e.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{let u=c.getAttribute("href");if(!u)return;let l=new URL(u,t).href;n.includes(l)||n.push(l)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{let u=c;u.href&&(n.includes(u.href)&&!r.has(u.href)?r.set(u.href,u):o.push(u))});let i=[],a=[],s=null;return n.forEach((c,u)=>{let l=r.get(c)||null;if(!l){let m=document.createElement("link");if(m.rel="stylesheet",m.href=c,a.push(Tt(m)),i.push({link:m,media:m.getAttribute("media")}),m.media="not all",s)s.after(m);else{let p=n.slice(u+1).map(g=>r.get(g)).find(g=>!!g);p?p.before(m):document.head.appendChild(m)}l=m}s=l}),{ready:At(a),commit(){for(let{link:c,media:u}of i)u===null?c.removeAttribute("media"):c.setAttribute("media",u);o.forEach(c=>c.remove())},abort(){i.forEach(({link:c})=>c.remove())}}}var Ze='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Ln(e){document.head.querySelectorAll(Ze).forEach(t=>t.remove()),e.head.querySelectorAll(Ze).forEach(t=>{document.head.appendChild(document.importNode(t,!0))})}var Ie=null;function qe(e){let t={};if(e)for(let n of Array.from(e.attributes))t[n.name]=n.value;return t}function Oe(e){return{html:qe(e.documentElement),body:qe(e.body)}}function Rn(e){let t=Ie??Oe(document),n=Oe(e),r=(o,i,a)=>{if(o)for(let s of new Set([...Object.keys(i),...Object.keys(a)]))i[s]!==a[s]&&(a[s]===void 0?o.removeAttribute(s):o.setAttribute(s,a[s]))};r(document.documentElement,t.html,n.html),r(document.body,t.body,n.body),Ie=n}function Ue(e,t){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return e.querySelectorAll("script[src]").forEach(i=>{let a=i.getAttribute("src");if(!a)return;let s=(i.getAttribute("type")||"").toLowerCase();if(s&&s!=="module"&&s!=="text/javascript"&&s!=="application/javascript")return;let c=Fe(a,t);!n.has(c)&&!o.has(c)&&(o.add(c),r.push({src:c,module:s==="module"}))}),r}function _n(e,t,n){let r=pt(),o=[],i=[],a=(s,c,u)=>{if(r.has(s))return;r.add(s);let l=document.createElement("link");c?l.rel="modulepreload":(l.rel="preload",l.as="script"),u!==null&&l.setAttribute("crossorigin",u),l.href=s,i.push(Tt(l)),o.push(l),document.head.appendChild(l)};for(let s of n)a(s.src,s.module,null);return e.querySelectorAll('link[rel="modulepreload"][href]').forEach(s=>{try{a(Fe(s.getAttribute("href"),t),!0,s.getAttribute("crossorigin"))}catch{}}),{ready:At(i),remove(){o.forEach(s=>s.remove())}}}function Lt(e){return new Promise(t=>{let n=document.createElement("script");n.src=e.src,e.module?n.type="module":n.async=!1,st.test(e.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>t(!0),n.onerror=()=>t(!1),document.body.appendChild(n)})}var ye=new Set;function Rt(e){e.querySelectorAll("script[data-krate-boot]").forEach(t=>{let n=t.textContent||"";if(!n||ye.has(n))return;ye.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function Pn(e){if(!e||e==="#")return null;let t=e.slice(1);try{t=decodeURIComponent(t)}catch{}return document.getElementById(t)||document.getElementsByName(t)[0]||null}function $e(e){let t=Pn(e);if(!t)return!1;try{t.scrollIntoView({block:"start"})}catch{}return!0}function Nn(e,t){if(t.kind==="pop"){let r=t.restoreKey?N.get(t.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(e,location.href).hash;$e(n)||t.scroll&&t.kind!=="refresh"&&window.scrollTo(0,0)}var de=null,Cn=["name","type","role","aria-label","placeholder","data-testid","data-slot","href"];function _t(e){let t=e.tagName;for(let n of Cn){let r=e.getAttribute(n);r!==null&&(t+="\0"+n+"="+r)}return t}function Pt(e,t,n){return Array.from(e.getElementsByTagName(n)).filter(r=>_t(r)===t)}function xn(e,t,n){if(!t.contains(e))return!1;if(!n.region)return!0;let r=o=>!!(o[0].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)&&!!(o[1].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING);return r(n.region.live)||n.slots.some(o=>r(o.live))}function Mn(e,t){let n=document.activeElement;if(!n||n===document.body||n===e||!xn(n,e,t))return null;let r=_t(n),o=n,i=null,a=null;try{i=typeof o.selectionStart=="number"?o.selectionStart:null,a=typeof o.selectionEnd=="number"?o.selectionEnd:null}catch{}return{id:n.id,sig:r,index:Pt(e,r,n.tagName).indexOf(n),start:i,end:a}}function et(e){let t=document.activeElement;return!!t&&t!==document.body&&t!==e&&e.contains(t)}function tt(e,t){let n=t.sig.split("\0")[0],r=t.id?document.getElementById(t.id):null;if((!r||!e.contains(r))&&(r=Pt(e,t.sig,n)[t.index]??null),!(!r||typeof r.focus!="function"))try{r.focus({preventScroll:!0});let o=r;if(t.start!==null&&t.end!==null&&document.activeElement===r&&typeof o.setSelectionRange=="function"){let i=o.value.length;o.setSelectionRange(Math.min(t.start,i),Math.min(t.end,i))}}catch{}}function Hn(){let e=document.activeElement;if(e&&e!==document.body&&e.isConnected&&e!==de)return;let t=S(document);t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),de=t,t.addEventListener("blur",()=>{de===t&&(t.removeAttribute("tabindex"),de=null)},{once:!0}));try{t.focus({preventScroll:!0})}catch{}}var nt="__krate-route-announcer";function Dn(){let e=document.getElementById(nt);e||(e=document.createElement("div"),e.id=nt,e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.setAttribute("role","status"),e.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(e));let t=S(document).querySelector("h1"),n=document.title||(t&&t.textContent?t.textContent.trim():"")||z(location.pathname);e.textContent=n}function Te(){let e=Me(z(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(t=>{let n=t.getAttribute("href"),r="";try{r=n?Me(z(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===e?o="exact":r&&r!=="/"&&e.startsWith(r+"/")&&(o="segment"),o==="exact"?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),o?t.setAttribute("data-krate-active",o):t.removeAttribute("data-krate-active")})}function rt(e){let t=G()+e;return he.has(t)?Promise.resolve(he.get(t)??null):fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&Q(r)?r:null;return he.set(t,o),o}).catch(()=>null)}function In(e){if(e.kind!=="pop"||!e.restoreKey||e.bypassCache)return;let t=b.get(e.restoreKey);return t&&E(t.url)===E(e.url)?t:void 0}async function On(e,t){let n=Y(e.url),r=In(e);if(r)return{ok:!0,doc:{html:r.html,url:e.url,status:r.status}};if(!e.bypassCache){let p=C.get(n);if(p&&await p,t.aborted)return{ok:!1,aborted:!0};let g=pn(n);if(g){let h=new URL(e.url,location.href).hash,y=h&&!new URL(g.url,location.href).hash?g.url+h:g.url;return{ok:!0,doc:{html:g.html,url:y,status:g.status}}}}Sn();let o;try{o=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:t,cache:e.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||t.aborted?{ok:!1,aborted:!0}:k("krate:navigate-error",{url:e.url,status:0,error:p},!0)?{ok:!1,hard:e.url}:{ok:!1,aborted:!0}}let i=o.url||n;if(new URL(i,location.href).origin!==location.origin)return{ok:!1,hard:i};let a=o.headers.get("content-type")||"",s="";try{s=await o.text()}catch(p){if(p?.name==="AbortError"||t.aborted)return{ok:!1,aborted:!0};s=""}if(t.aborted)return{ok:!1,aborted:!0};let c=Ee(a)||a===""&&Q(s),u=new URL(e.url,location.href).hash,l=u&&!new URL(i).hash?i+u:i;if(o.ok)return c?{ok:!0,doc:{html:s,url:l,status:o.status}}:{ok:!1,hard:l};if(k("krate:navigate-error",{url:e.url,status:o.status}),c&&Q(s))return{ok:!0,doc:{html:s,url:l,status:o.status}};let m=null;return o.status===404||o.status===410?m=await rt("/404.html"):o.status>=500&&(m=await rt("/500.html")),t.aborted?{ok:!1,aborted:!0}:m?{ok:!0,doc:{html:m,url:l,status:o.status}}:{ok:!1,hard:l}}async function Ae(e){let t=location.href;if(e.kind!=="pop"){if(!k("krate:navigate-start",{url:e.url,from:t,kind:e.kind},!0))return}else k("krate:navigate-start",{url:e.url,from:t,kind:e.kind});let n=++L;v&&v.abort();let r=new AbortController;v=r,B("loading");let o;try{o=await On(e,r.signal)}finally{v===r&&(v=void 0)}if(n===L){if(!o.ok){Se(),B("idle"),"hard"in o&&ie(o.hard,e.kind==="replace"||e.kind==="refresh");return}await Un(o.doc,e,n)}}async function Un(e,t,n){let r=new DOMParser().parseFromString(e.html,"text/html"),o=e.url,i=S(r),a=S(document),s=An(r,o),c=_n(r,o,Ue(r,o));if(await Promise.all([s.ready,c.ready]),n!==L){s.abort(),c.remove();return}let u=f,l=location.href;t.kind==="push"&&ae(f);let m=xt(r),p=$n(D,m,location.href,o,r),g=E(o).split("?")[0]===x.split("?")[0],h=null,y=null,d=[];if(await Wn(()=>{g&&(h=Mn(a,p));let P=document.activeElement;y=P&&P!==document.body&&a.contains(P)?P:null;let Xt=y?Fn(y):null,Xe=r.querySelector("title");Xe&&(document.title=Xe.textContent||"");let ue=globalThis;p.keep.length>0&&typeof ue.krateDisposeExcept=="function"?ue.krateDisposeExcept(p.keep):typeof ue.disposeAll=="function"&&ue.disposeAll();let Re={sameProps:!g},_e=I=>{let ee=document.createDocumentFragment();for(let O of I)ee.appendChild(document.importNode(O,!0));return Array.from(ee.childNodes)};if(p.region){let{live:I,next:ee}=p.region;d=Ce(I[0].parentNode,I[0],I[1],_e(W(ee[0],ee[1])),Re);for(let O of p.slots)d.push(...Ce(O.live[0].parentNode,O.live[0],O.live[1],_e(W(O.next[0],O.next[1])),Re));jn(a,i)}else d=Ce(a,null,null,_e(Array.from(i.childNodes)),Re);D=p.chain,Z.forEach(I=>Ct(I.nodes)),Z.clear(),s.commit(),Ln(r),Rn(r),St(document),y&&y.isConnected?(document.activeElement!==y&&Bn(y,Xt),h=null):h&&tt(a,h)},t.kind!=="refresh"&&!g),n!==L){c.remove();return}Se(),t.kind==="push"?(f=j(),history.pushState(se(f,t.state),"",o)):t.kind==="replace"?(N.delete(f),b.delete(f),f=j(),history.replaceState(se(f,t.state),"",o)):t.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):t.restoreKey&&(f=t.restoreKey),e.status>=200&&e.status<300&&je(f,{html:e.html,url:location.href,status:e.status}),t.kind==="push"&&u&&u===J?(J="",gn(u,l)):t.kind==="replace"&&u===J&&(J=""),_=E(location.href),x=_,It(r),Gn(r),Nn(o,t),t.kind!=="pop"&&t.kind!=="refresh"&&Hn(),t.kind!=="refresh"&&Dn(),Te(),k("krate:navigate",{url:location.href,status:e.status}),Be(location.href),B("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(P=>P.remove()),Rt(r);let T=Ue(r,o);it(p.skip);let q=await Promise.all(T.map(Lt));if(it([]),c.remove(),n!==L)return;if(q.some(P=>!P)){k("krate:navigate-error",{url:location.href,status:e.status,error:"script-load"}),ie(location.href,!0);return}ve(),k("krate:navigate-end",{url:location.href,status:e.status});let $=h;$&&!et(a)&&(await Kn(d),n===L&&!et(a)&&tt(a,$))}function Nt(){let e=globalThis.__krateIslandSwap;return e&&typeof e.swap=="function"&&typeof e.unmount=="function"?e:null}function Ce(e,t,n,r,o){let i=Nt();if(i)return i.swap(e,t,n,r,o);if(t&&n){Ge(t,n);for(let a of r)e.insertBefore(a,n)}else e.replaceChildren(...r);return[]}function Ct(e){let t=Nt();t&&t.unmount(e)}function Kn(e){let t=globalThis.__krateIslandsReady,n=Promise.all([...e,t&&typeof t.then=="function"?t:null]);return Promise.race([n,new Promise(r=>setTimeout(r,3e3))])}function Fn(e){let t=e;try{return typeof t.selectionStart=="number"&&typeof t.selectionEnd=="number"?[t.selectionStart,t.selectionEnd]:null}catch{return null}}function Bn(e,t){try{e.focus({preventScroll:!0}),t&&document.activeElement===e&&typeof e.setSelectionRange=="function"&&e.setSelectionRange(t[0],t[1])}catch{}}function Wn(e,t=!0){if(!t||!wn())return e(),Promise.resolve();let n=!1,r=()=>{n||(n=!0,e())};try{let o=document.startViewTransition(r);o&&o.finished&&typeof o.finished.catch=="function"&&o.finished.catch(()=>{}),o&&o.ready&&typeof o.ready.catch=="function"&&o.ready.catch(()=>{});let i=o&&o.updateCallbackDone;if(i&&typeof i.then=="function")return i.then(()=>r(),()=>r())}catch{}return r(),Promise.resolve()}var D=[];function xt(e){let t=e.getElementById("__krate_route");if(!t)return[];try{let n=JSON.parse(t.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return te("unreadable #__krate_route route info; layouts will be remounted"),[]}}function ot(e,t){let n=z(new URL(e,location.href).pathname).split("/").filter(Boolean);return(t<0?n:n.slice(0,t)).join("/")}function H(e,t,n="kl:"){let o=(e.ownerDocument||e).createTreeWalker(e,128),i=n+t,a="/"+n+t;for(;o.nextNode();){let s=o.currentNode;if(s.nodeValue===i){for(let c=s.nextSibling;c;c=c.nextSibling)if(c.nodeType===8&&c.nodeValue===a)return[s,c];return null}}return null}function W(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function Ge(e,t){let n=globalThis.disposeNode;Ct(W(e,t));for(let r of W(e,t))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function jn(e,t){let n=":scope > template[data-krate-loading]";e.querySelectorAll(n).forEach(r=>r.remove()),t.querySelectorAll(n).forEach(r=>e.appendChild(document.importNode(r,!0)))}function it(e){let t=globalThis.krateKeepScopes;typeof t=="function"&&t(e)}function Vn(e){let t=globalThis.krateScopeFailed;return typeof t=="function"&&!!t(e)}function $n(e,t,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:t},a=0;for(;a<e.length&&a<t.length;){let h=e[a],y=t[a];if(h.id!==y.id||h.k!==y.k||h.k!=="layout"&&h.k!=="error"||ot(n,h.d)!==ot(r,y.d)||h.k==="error"&&Vn(h.id))break;if(!h.p||!y.p){te(`layout ${y.f||y.id} is remounted on this navigation: ${y.why||h.why||"not persistable"}`);break}a++}if(a===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return te("the runtime has no krateDisposeExcept; layouts are remounted"),i;let s=t[a-1].id,c=H(S(document),s),u=H(S(o),s);if(!c||!u)return te(`layout ${t[a-1].f||s} boundary markers are missing; the whole page is swapped`),i;let l=e.slice(0,a).map(h=>h.id),m=l.slice(),p=[],g=t.slice();for(let h=0;h<a;h++){let y=e[h].s||[],d=[];for(let w of t[h].s||[]){let T=y.find(P=>P.key===w.key),q=H(S(document),w.key,"ks:"),$=H(S(o),w.key,"ks:");if(T&&q&&(w.src!=="page"||!$)){l.push(T.scope),m.push(T.scope,w.scope),d.push({...w,scope:T.scope,src:T.src});continue}if(q&&$){p.push({live:q,next:$}),d.push(w);continue}return te(`slot @${w.n} markers are missing; the whole page is swapped`),i}g[h]={...t[h],s:d}}return{keep:l,skip:m,region:{live:c,next:u},slots:p,chain:g}}var Z=new Map,x="";function Ke(e){let t=e.replace(/^\/+|\/+$/g,"");return t?t.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 Mt(e,t){let n=Ke(t),r=e.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let a=0;a<n.length;a++){let s=n[a];if(s.kind>=2){if(a!==n.length-1)return null;let c=o.slice(a);return s.kind===2&&c.length===0||c.some(u=>u==="")?null:(i[s.text]=c.map(xe).join("/"),i)}if(a>=o.length)return null;if(s.kind===1){if(!o[a])return null;i[s.text]=xe(o[a])}else if(xe(o[a])!==s.text)return null}return o.length===n.length?i:null}function xe(e){try{return decodeURIComponent(e)}catch{return e}}function Ht(e,t){let n=Ke(e),r=Ke(t);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:e<t?-1:e>t?1:0}function Je(e){let t=z(new URL(e,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of D)for(let o of r.s||[])for(let i of o.i||[])Mt(t,i)&&(!n||Ht(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:t},pattern:i});return n&&!H(S(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Dt(e,t){D=D.map(n=>n.s&&n.s.some(r=>r.key===e)?{...n,s:n.s.map(r=>r.key===e?t:r)}:n)}function It(e){let t="",n=e.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(t=r.r)}catch{}globalThis.__KRATE_ROUTE__=t;for(let r of Array.from(e.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 Gn(e){let t=e.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!t){n&&n.remove();return}let r=document.importNode(t,!0);n?n.replaceWith(r):document.head.appendChild(r)}function Ot(e){let t=globalThis.krateDisposeScopes;typeof t=="function"&&t(e)}async function ze(e,t){let n=location.href;if(e.kind!=="pop"&&!k("krate:navigate-start",{url:e.url,from:n,kind:e.kind,intercept:t.slot.n},!0))return;let r=++L;v&&v.abort();let o=new AbortController;v=o,B("loading");let i=location.origin+G()+"/"+un+"/"+t.slot.key+(t.path?"/"+t.path:""),a="",s=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:e.bypassCache?"no-cache":"default"});a=await d.text(),s=d.ok&&(Ee(d.headers.get("content-type")||"")||Q(a)),s||k("krate:navigate-error",{url:e.url,status:d.status,intercept:t.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;k("krate:navigate-error",{url:e.url,status:0,error:d,intercept:t.slot.n})}finally{v===o&&(v=void 0)}if(r!==L)return;let c=s?new DOMParser().parseFromString(a,"text/html"):null,u=c?H(S(c),t.slot.key,"ks:"):null,l=H(S(document),t.slot.key,"ks:"),m=null;try{let d=c&&c.getElementById("__krate_route");m=d&&JSON.parse(d.textContent||"{}").frag||null}catch{m=null}if(!c||!u||!l||!m||m.key!==t.slot.key||!m.scope){try{console.warn(`[krate router] intercepting route for ${e.url} (slot @${t.slot.n}) could not be loaded; navigating to the page`)}catch{}return B("idle"),Ae({...e})}if(e.kind==="push"&&ae(f),t.slot.src!=="intercept"){Z.set(f,{key:t.slot.key,nodes:W(l[0],l[1]),slot:t.slot,path:x});for(let d of W(l[0],l[1]))d.parentNode.removeChild(d)}else Ot([t.slot.scope]),Ge(l[0],l[1]);for(let d of W(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let p=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>p.add(d.href)),c.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let w=new URL(d.getAttribute("href"),i).href;if(p.has(w))return;let T=document.createElement("link");T.rel="stylesheet",T.href=w,document.head.appendChild(T)}),Dt(t.slot.key,{...t.slot,scope:m.scope,src:"intercept"}),Rt(c);let g={__krate:"",state:e.state===void 0?null:e.state,__kint:{key:t.slot.key,base:x}};e.kind==="push"?(f=j(),g.__krate=f,history.pushState(g,"",e.url)):e.kind==="replace"?(f=j(),g.__krate=f,history.replaceState(g,"",e.url)):e.kind==="pop"&&e.restoreKey&&(f=e.restoreKey),_=E(location.href),It(c),Te(),k("krate:navigate",{url:location.href,status:200,intercept:t.slot.n}),Be(location.href),B("idle");let h=Ue(c,i),y=await Promise.all(h.map(Lt));if(r===L){if(y.some(d=>!d)){k("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:t.slot.n}),ie(location.href,!0);return}ve(),k("krate:navigate-end",{url:location.href,status:200,intercept:t.slot.n})}}function Jn(e,t){let n=H(S(document),e.key,"ks:"),r=D.flatMap(i=>i.s||[]).find(i=>i.key===e.key);if(!n||!r||r.src!=="intercept")return!1;Ot([r.scope]),Ge(n[0],n[1]);for(let i of e.nodes)n[1].parentNode.insertBefore(i,n[1]);Dt(e.key,e.slot),Z.delete(t),f=t,_=E(location.href);let o=N.get(t);return o!==void 0&&window.scrollTo(0,o),Te(),k("krate:navigate",{url:location.href,status:200}),Be(location.href),be(),!0}function zn(e){return E(e)===_}function Ut(){X==="loading"&&(L++,v&&v.abort(),v=void 0,Se(),B("idle"))}function Xn(e,t){if(Ut(),ae(f),e!==location.href||t.state!==void 0)if(t.kind==="replace")history.replaceState(se(f||j(),t.state),"",e);else{let r=b.get(f);f=j(),history.pushState(se(f,t.state),"",e),r&&je(f,{...r,url:e})}let n=new URL(e).hash;!$e(n)&&t.scroll&&!n&&window.scrollTo(0,0),be()}function Le(e){let t;try{t=new URL(e.url,location.href)}catch{return ie(e.url),Promise.resolve()}if(t.origin!==location.origin)return ie(t.href,e.kind==="replace"),Promise.resolve();if(e.url=t.href,(e.kind==="push"||e.kind==="replace")&&zn(t.href)&&(t.hash||t.href===location.href))return Xn(t.href,e),Promise.resolve();if(e.kind==="push"||e.kind==="replace"){let n=Je(t.href);if(n)return ze(e,n)}return Ae(e)}function Kt(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-krate-link]");if(!n||!Ve(n))return;let r=n.getAttribute("href");r&&(e.preventDefault(),Le({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function Ft(e){if(e.defaultPrevented)return;let t=e.target;if(!t||t.tagName!=="FORM"||t.hasAttribute("data-krate-reload"))return;let n=e.submitter||null;if((n&&n.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||t.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||t.getAttribute("action")||"",a;try{a=new URL(i||location.href,location.href)}catch{return}if(a.origin!==location.origin||a.protocol.indexOf("http")!==0)return;let s;try{s=n?new FormData(t,n):new FormData(t)}catch{s=new FormData(t),n&&n.name&&s.append(n.name,n.value)}let c=new URLSearchParams;for(let[u,l]of s.entries()){if(typeof l!="string")return;c.append(u,l)}e.preventDefault(),a.search=c.toString(),a.hash="",Le({url:a.href,kind:"push",scroll:!0})}function Bt(e){ae(f);let t=pe(e.state),n=location.href;if(E(n)===_){Ut(),f=t||f;let i=t?N.get(t):void 0;i!==void 0?window.scrollTo(0,i):$e(location.hash),be();return}let r=t?Z.get(t):void 0;if(r&&t&&r.path===E(n)&&r.path===x&&Jn(r,t))return;let o=e.state&&typeof e.state=="object"?e.state.__kint:null;if(o&&o.base===x){let i=Je(n);if(i&&i.slot.key===o.key){ze({url:n,kind:"pop",scroll:!1,restoreKey:t},i);return}}Ae({url:n,kind:"pop",scroll:!0,restoreKey:t})}function Wt(){We(),$t()}function jt(){ae(f);try{history.scrollRestoration="auto"}catch{}}function Vt(){try{history.scrollRestoration="manual"}catch{}}function ve(){wt(),Te(),St(document),document.querySelectorAll("script[src]").forEach(e=>{st.test(e.src)||e.setAttribute("data-krate-spa","")})}function $t(){let e=V();if(e)return e.refresh();if(!R||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(_!==x){let t=Je(location.href);if(t&&t.slot.src==="intercept")return ze({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},t)}return Ae({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function Gt(e,t={}){if(!R){let n=V();if(n)return n.push(e,t);let r=ct();return r?r(e,{...t,replace:!1}):typeof location<"u"&&location.assign(M(e)),Promise.resolve()}return Le({url:M(e),kind:"push",scroll:t.scroll!==!1,state:t.state})}function Jt(e,t={}){if(!R){let n=V();if(n)return n.replace(e,t);let r=ct();return r?r(e,{...t,replace:!0}):typeof location<"u"&&location.replace(M(e)),Promise.resolve()}return Le({url:M(e),kind:"replace",scroll:t.scroll!==!1,state:t.state})}var le={push:Gt,replace:Jt,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:$t,prefetch(e){let t=V();if(t)return t.prefetch(e);if(!R||typeof location>"u")return Promise.resolve();let n;try{n=new URL(M(e),location.href)}catch{return Promise.resolve()}return n.origin!==location.origin?Promise.resolve():we(n.href)},subscribe:ht,getState:dt,invalidate:We};function Yn(e,t={}){return R||V()?(t.replace?Jt(e,t):Gt(e,t),!1):(typeof location<"u"&&(t.replace?location.replace(M(e)):location.assign(M(e))),!0)}function zt(){if(!(typeof document>"u")){if(R){ve();return}if(R=!0,globalThis[re]=le,document.querySelectorAll("script[data-krate-boot]").forEach(e=>ye.add(e.textContent||"")),_=E(location.href),D=xt(document),Ie=Oe(document),x=_,f=pe(history.state)||j(),J=f,pe(history.state)===void 0)try{history.replaceState(se(f,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",Kt),document.addEventListener("submit",Ft),window.addEventListener("popstate",Bt),window.addEventListener("krate:revalidate",Wt),window.addEventListener("pagehide",jt),window.addEventListener("pageshow",Vt),kn(),bn(),ve()}}function Qn(){zt()}function Zn(){if(R){R=!1,globalThis[re]===le&&delete globalThis[re],document.removeEventListener("click",Kt),document.removeEventListener("submit",Ft),window.removeEventListener("popstate",Bt),window.removeEventListener("krate:revalidate",Wt),window.removeEventListener("pagehide",jt),window.removeEventListener("pageshow",Vt),document.removeEventListener("mouseover",ge),document.removeEventListener("focusin",ge);for(let e of Et)document.removeEventListener(e,bt);for(let e of K.values())clearTimeout(e);K=new Map,F&&(F.disconnect(),F=null),v&&v.abort(),v=void 0,L++,A.clear(),C.clear(),b.clear(),J="",ne++,N.clear(),he.clear(),ye.clear(),oe.clear(),X="idle",document.documentElement.removeAttribute(ut),Se(),D=[],Z.clear(),x=""}}return tn(qn);})();
1
+ var __krate_exports=(()=>{var Ce=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.prototype.hasOwnProperty;var nn=(e,t)=>{for(var n in t)Ce(e,n,{get:t[n],enumerable:!0})},rn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of en(t))!tn.call(e,o)&&o!==n&&Ce(e,o,{get:()=>t[o],enumerable:!(r=qt(t,o))||r.enumerable});return e};var on=e=>rn(Ce({},"__esModule",{value:!0}),e);var rr={};nn(rr,{compareRouteSpecificity:()=>Ot,destroyRouter:()=>nr,getHistoryState:()=>gn,getNavigationState:()=>pt,initRouter:()=>Qt,invalidatePrefetchCache:()=>Ve,krateRouter:()=>fe,matchRoutePattern:()=>It,navigate:()=>er,pageAssetURLs:()=>ut,reinitRouter:()=>tr,subscribeNavigation:()=>gt});var sn="__krate_cfg__";function me(){let e=globalThis;if(e.__KRATE_CFG__)return e.__KRATE_CFG__;let t=e.document,n=t&&typeof t.getElementById=="function"?t.getElementById(sn):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return e.__KRATE_CFG__=r,r}catch{}return{}}function $(){let e=me(),t=e&&e.basePath||"";return!t||t==="/"?"":"/"+t.replace(/^\/+|\/+$/g,"")}function M(e){let t=$();return t&&e.charCodeAt(0)===47&&e.charCodeAt(1)!==47?t+e:e}var an=/\/chunks\/runtime\.[^/]+\.js$/,lt=/\/chunks\/(?:runtime\.[^/]+|c\/[^/]+)\.js$/;function we(){return me()}function J(e){let t=$();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function De(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function ne(e){if(we().dev)try{console.warn("[krate router] "+e)}catch{}}function We(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(e,n).href}function ut(e,t,n){let r=typeof e=="string"?new DOMParser().parseFromString(e,"text/html"):e,o=[],i=new Set,a=s=>{if(!s)return;let c;try{c=We(s,t)}catch{return}i.has(c)||n.has(c)||an.test(c)||(i.add(c),o.push(c))};return r.querySelectorAll("script[src]").forEach(s=>a(s.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(s=>a(s.getAttribute("href"))),o}var L=!1,ie=Symbol.for("krate.router");function V(){if(L)return null;let e=globalThis,t=e[ie];if(!t&&typeof document<"u"&&dt()&&typeof e.initRouter=="function"){try{e.initRouter()}catch(n){console.error(n)}t=e[ie]}return t&&t!==fe?t:null}function ft(){let e=globalThis.navigate;return dt()&&typeof e=="function"?e:null}function dt(){let e=globalThis.krateRouter;return!!e&&e!==fe}var T=0,k,Ze=0,d="",_="",z="idle",se=new Set,A=new Map,N=new Map,cn=30,ln=3e4,P=new Map,un=50,xe=new Set,fn=128,ge=new Map,E=new Map,dn=10,oe=0,G="",K=new Map,B=null,ye=[],F,hn="_krate/i",mn=200,pn=100,ht="data-krate-navigating";function Ie(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function j(){return Ze++,Date.now().toString(36)+"-"+Ze.toString(36)}function X(e){try{let t=new URL(e,location.href);return t.hash="",t.href}catch{return e}}function w(e){let t=new URL(e,location.href);return De(t.pathname)+t.search}function Y(e,t=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(e,t);return}t?location.replace(e):location.assign(e)}function ae(e,t){return{__krate:e,state:t===void 0?null:t}}function ve(e){if(e&&typeof e=="object"&&typeof e.__krate=="string")return e.__krate}function gn(){if(typeof history>"u")return null;let e=history.state;return ve(e)!==void 0?e.state:e}function mt(){let e=new URL(location.href);return{url:e.href,pathname:J(e.pathname),search:e.search,hash:e.hash,status:z}}function pt(){let e=V();return e?e.getState():typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:mt()}function Se(){if(se.size===0)return;let e=mt();for(let t of Array.from(se))try{t(e)}catch(n){console.error(n)}}function D(e){if(z!==e){z=e;try{document.documentElement.toggleAttribute(ht,e==="loading")}catch{}Se()}}function gt(e){let t=V();return t?t.subscribe(e):(se.add(e),()=>{se.delete(e)})}function b(e,t,n=!1){try{let r=new CustomEvent(e,{detail:t,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function je(e){try{let t=globalThis.__krate_onNavigation;typeof t=="function"&&t(e)}catch{}}function le(e){if(e){if(P.delete(e),P.size>=un){let t=P.keys().next().value;t!==void 0&&P.delete(t)}P.set(e,window.scrollY||0)}}function yt(){let e=we().prefetchTTL;return typeof e=="number"&&e>=0?e:ln}function yn(e,t){for(A.delete(e);A.size>=cn;){let n=A.keys().next().value;if(n===void 0)break;A.delete(n)}A.set(e,t)}function vn(e){let t=A.get(e);if(t&&(A.delete(e),!(Ie()-t.at>yt())))return t}function Ve(e){if(oe++,e===void 0){A.clear(),N.clear(),E.clear();return}let t=X(e);A.delete(t),N.delete(t),E.forEach((n,r)=>{X(n.url)===t&&E.delete(r)})}function $e(e,t){if(e){for(E.delete(e);E.size>=dn;){let n=E.keys().next().value;if(n===void 0)break;E.delete(n)}E.set(e,t)}}function kn(e,t){if(ue())return;let n=oe;Et(()=>{E.has(e)||n!==oe||fetch(X(t),{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async r=>{if(!r.ok||/no-store/i.test(r.headers.get("cache-control")||""))return;let o=r.url||X(t);if(w(o)!==w(t))return;let i=r.headers.get("content-type")||"",a=await r.text();(Ae(i)||i===""&&Q(a))&&(n!==oe||E.has(e)||!L||$e(e,{html:a,url:t,status:r.status}))}).catch(()=>{})})}function Ae(e){return/text\/html|application\/xhtml\+xml/i.test(e)}function Q(e){return/^\s*(<!doctype html|<html|<head|<body)/i.test(e)}function qe(e,t="script"){if(xe.has(e)||xe.size>=fn)return;xe.add(e);let n=document.createElement("link");n.rel="prefetch",n.as=t,n.href=e,document.head.appendChild(n)}function bn(e,t){let n=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(o=>n.add(o.href));let r=[];return e.querySelectorAll('link[rel="stylesheet"][href]').forEach(o=>{try{let i=new URL(o.getAttribute("href"),t).href;!n.has(i)&&!r.includes(i)&&r.push(i)}catch{}}),r}function vt(){let e=new Set;document.querySelectorAll("script[src]").forEach(t=>e.add(t.src));try{for(let t of performance.getEntriesByType("resource"))e.add(t.name)}catch{}return e}function Te(e){let t=X(e),n=A.get(t);if(n&&Ie()-n.at<=yt())return Promise.resolve();let r=N.get(t);if(r)return r;let o=fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let a=i.headers.get("content-type")||"",s=i.url||t;if(new URL(s,location.href).origin!==location.origin)return;let c=await i.text();if(!(Ae(a)||a===""&&Q(c))||N.get(t)!==o)return;yn(t,{html:c,url:s,status:i.status,at:Ie()});let u=new DOMParser().parseFromString(c,"text/html");for(let l of bn(u,s))qe(l,"style");for(let l of ut(u,s,vt()))qe(l)}).catch(()=>{}).finally(()=>{N.get(t)===o&&N.delete(t)});return N.set(t,o),o}function Ge(e){if(e.hasAttribute("data-krate-external")||e.hasAttribute("download"))return!1;let t=e.getAttribute("href");if(!t||t.startsWith("javascript:"))return!1;let n;try{n=new URL(t,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=e.getAttribute("target");return!(r&&r!=="_self")}function kt(e){let t=e.getAttribute("data-prefetch");return e.hasAttribute("data-prefetch")&&t!=="false"&&t!=="0"}var En=5,Oe=0;function ue(){let e=navigator.connection;return e?e.saveData===!0||e.effectiveType==="slow-2g"||e.effectiveType==="2g":!1}function bt(e){if(!kt(e))return!1;let t=e.getAttribute("data-prefetch");return t==="viewport"||we().prefetch==="viewport"&&t!=="intent"}function Et(e){let t=window.requestIdleCallback;typeof t=="function"?t(e,{timeout:1e3}):setTimeout(e,50)}function wt(e){let t=e.target;if(!t||typeof t.closest!="function")return null;let n=t.closest("a[data-prefetch]");if(!n||!kt(n)||!Ge(n)||ue())return null;let r=n.getAttribute("href");if(!r)return null;let o=new URL(r,location.href).href;return w(o)===_?null:{a:n,url:o}}function ke(e){let t=wt(e);if(!t)return;let{a:n,url:r}=t,o=K.get(n);o&&clearTimeout(o);let i=setTimeout(()=>{K.delete(n),Te(r)},mn);K.set(n,i)}function St(e){if(typeof e.button=="number"&&e.button!==0)return;let t=wt(e);if(!t)return;let n=K.get(t.a);n&&(clearTimeout(n),K.delete(t.a)),Te(t.url)}var At=["touchstart",typeof PointerEvent=="function"?"pointerdown":"mousedown"];function Tt(){Oe=0,!(!B||ue())&&document.querySelectorAll("a[data-prefetch]").forEach(e=>{bt(e)&&B.observe(e)})}function wn(){document.addEventListener("mouseover",ke),document.addEventListener("focusin",ke);for(let e of At)document.addEventListener(e,St,{passive:!0});typeof IntersectionObserver<"u"&&(B=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let n=t.target,r=n.getAttribute("href");if(r&&Ge(n)&&bt(n)&&Oe<En&&!ue()){let o=new URL(r,location.href).href;w(o)!==_&&(Oe++,Et(()=>{Te(o)}))}B.unobserve(t.target)}},{rootMargin:"200px"}),Tt())}function Sn(){let e=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof e!="function"||!e("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]')&&!ue())try{let t=document.createElement("script");t.type="speculationrules";let n=$();t.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"&&String(o.effectiveDirective||o.violatedDirective||"").startsWith("script-src")&&(t.remove(),document.removeEventListener("securitypolicyviolation",r))};document.addEventListener("securitypolicyviolation",r),document.head.appendChild(t)}catch{}}function An(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function Tn(){return we().viewTransitions===!1||An()?!1:typeof document.startViewTransition=="function"}function S(e){return e.getElementById("root")||e.body}function Ln(){F!==void 0&&clearTimeout(F),F=setTimeout(()=>{F=void 0;let e=document.querySelector("template[data-krate-loading]");if(z!=="loading"||!e||!e.content||ye.length>0)return;let t=e.content.cloneNode(!0);ye=Array.from(t.childNodes),document.body.appendChild(t)},pn)}function ce(){F!==void 0&&(clearTimeout(F),F=void 0);for(let e of ye)e.parentNode&&e.parentNode.removeChild(e);ye=[]}function Lt(e){e.querySelectorAll("[data-view-transition]").forEach(t=>{let n=t.getAttribute("data-view-transition");n&&(t.style.viewTransitionName=n);let r=t.getAttribute("data-view-transition-class");r&&t.style.setProperty("view-transition-class",r)})}var _n=3e3;function _t(e){return new Promise(t=>{let n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),t()};e.addEventListener("load",n),e.addEventListener("error",n)})}function Rt(e){if(e.length===0)return Promise.resolve();let t,n=new Promise(r=>{t=setTimeout(r,_n)});return Promise.race([Promise.all(e).then(()=>{}),n]).then(()=>clearTimeout(t))}function Rn(e,t){let n=[];e.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{let u=c.getAttribute("href");if(!u)return;let l=new URL(u,t).href;n.includes(l)||n.push(l)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{let u=c;u.href&&(n.includes(u.href)&&!r.has(u.href)?r.set(u.href,u):o.push(u))});let i=[],a=[],s=null;return n.forEach((c,u)=>{let l=r.get(c)||null;if(!l){let m=document.createElement("link");if(m.rel="stylesheet",m.href=c,a.push(_t(m)),i.push({link:m,media:m.getAttribute("media")}),m.media="not all",s)s.after(m);else{let y=n.slice(u+1).map(h=>r.get(h)).find(h=>!!h);y?y.before(m):document.head.appendChild(m)}l=m}s=l}),{ready:Rt(a),commit(){for(let{link:c,media:u}of i)u===null?c.removeAttribute("media"):c.setAttribute("media",u);o.forEach(c=>c.remove())},abort(){i.forEach(({link:c})=>c.remove())}}}var et='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Pn(e){document.head.querySelectorAll(et).forEach(t=>t.remove()),e.head.querySelectorAll(et).forEach(t=>{document.head.appendChild(document.importNode(t,!0))})}var Ue=null;function tt(e){let t={};if(e)for(let n of Array.from(e.attributes))t[n.name]=n.value;return t}function Fe(e){return{html:tt(e.documentElement),body:tt(e.body)}}function Nn(e){let t=Ue??Fe(document),n=Fe(e),r=(o,i,a)=>{if(o)for(let s of new Set([...Object.keys(i),...Object.keys(a)]))i[s]!==a[s]&&(a[s]===void 0?o.removeAttribute(s):o.setAttribute(s,a[s]))};r(document.documentElement,t.html,n.html),r(document.body,t.body,n.body),Ue=n}function Ke(e,t){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return e.querySelectorAll("script[src]").forEach(i=>{let a=i.getAttribute("src");if(!a)return;let s=(i.getAttribute("type")||"").toLowerCase();if(s&&s!=="module"&&s!=="text/javascript"&&s!=="application/javascript")return;let c=We(a,t);!n.has(c)&&!o.has(c)&&(o.add(c),r.push({src:c,module:s==="module"}))}),r}function Cn(e,t,n){let r=vt(),o=[],i=[],a=(s,c,u)=>{if(r.has(s))return;r.add(s);let l=document.createElement("link");c?l.rel="modulepreload":(l.rel="preload",l.as="script"),u!==null&&l.setAttribute("crossorigin",u),l.href=s,i.push(_t(l)),o.push(l),document.head.appendChild(l)};for(let s of n)a(s.src,s.module,null);return e.querySelectorAll('link[rel="modulepreload"][href]').forEach(s=>{try{a(We(s.getAttribute("href"),t),!0,s.getAttribute("crossorigin"))}catch{}}),{ready:Rt(i),remove(){o.forEach(s=>s.remove())}}}function Pt(e){return new Promise(t=>{let n=document.createElement("script");n.src=e.src,e.module?n.type="module":n.async=!1,lt.test(e.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>t(!0),n.onerror=()=>t(!1),document.body.appendChild(n)})}var be=new Set;function Nt(e){e.querySelectorAll("script[data-krate-boot]").forEach(t=>{let n=t.textContent||"";if(!n||be.has(n))return;be.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function xn(e){if(!e||e==="#")return null;let t=e.slice(1);try{t=decodeURIComponent(t)}catch{}return document.getElementById(t)||document.getElementsByName(t)[0]||null}function Je(e){let t=xn(e);if(!t)return!1;try{t.scrollIntoView({block:"start"})}catch{}return!0}function Mn(e,t){if(t.kind==="pop"){let r=t.restoreKey?P.get(t.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(e,location.href).hash;Je(n)||t.scroll&&t.kind!=="refresh"&&window.scrollTo(0,0)}var pe=null,Hn=["name","type","role","aria-label","placeholder","data-testid","data-slot","href"];function Ct(e){let t=e.tagName;for(let n of Hn){let r=e.getAttribute(n);r!==null&&(t+="\0"+n+"="+r)}return t}function xt(e,t,n){return Array.from(e.getElementsByTagName(n)).filter(r=>Ct(r)===t)}function Dn(e,t,n){if(!t.contains(e))return!1;if(!n.region)return!0;let r=o=>!!(o[0].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)&&!!(o[1].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING);return r(n.region.live)||n.slots.some(o=>r(o.live))}function In(e,t){let n=document.activeElement;if(!n||n===document.body||n===e||!Dn(n,e,t))return null;let r=Ct(n),o=n,i=null,a=null;try{i=typeof o.selectionStart=="number"?o.selectionStart:null,a=typeof o.selectionEnd=="number"?o.selectionEnd:null}catch{}return{id:n.id,sig:r,index:xt(e,r,n.tagName).indexOf(n),start:i,end:a}}function nt(e){let t=document.activeElement;return!!t&&t!==document.body&&t!==e&&e.contains(t)}function rt(e,t){let n=t.sig.split("\0")[0],r=t.id?document.getElementById(t.id):null;if((!r||!e.contains(r))&&(r=xt(e,t.sig,n)[t.index]??null),!(!r||typeof r.focus!="function"))try{r.focus({preventScroll:!0});let o=r;if(t.start!==null&&t.end!==null&&document.activeElement===r&&typeof o.setSelectionRange=="function"){let i=o.value.length;o.setSelectionRange(Math.min(t.start,i),Math.min(t.end,i))}}catch{}}function On(){let e=document.activeElement;if(e&&e!==document.body&&e.isConnected&&e!==pe)return;let t=S(document);t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),pe=t,t.addEventListener("blur",()=>{pe===t&&(t.removeAttribute("tabindex"),pe=null)},{once:!0}));try{t.focus({preventScroll:!0})}catch{}}var ot="__krate-route-announcer";function Un(){let e=document.getElementById(ot);e||(e=document.createElement("div"),e.id=ot,e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.setAttribute("role","status"),e.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(e));let t=S(document).querySelector("h1"),n=document.title||(t&&t.textContent?t.textContent.trim():"")||J(location.pathname);e.textContent=n}function Le(){let e=De(J(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(t=>{let n=t.getAttribute("href"),r="";try{r=n?De(J(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===e?o="exact":r&&r!=="/"&&e.startsWith(r+"/")&&(o="segment"),o==="exact"?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),o?t.setAttribute("data-krate-active",o):t.removeAttribute("data-krate-active")})}function it(e){let t=$()+e;return ge.has(t)?Promise.resolve(ge.get(t)??null):fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&Q(r)?r:null;return ge.set(t,o),o}).catch(()=>null)}function Fn(e){if(e.kind!=="pop"||!e.restoreKey||e.bypassCache)return;let t=E.get(e.restoreKey);return t&&w(t.url)===w(e.url)?t:void 0}async function Kn(e,t){let n=X(e.url),r=Fn(e);if(r)return{ok:!0,doc:{html:r.html,url:e.url,status:r.status}};if(!e.bypassCache){let y=N.get(n);if(y&&await y,t.aborted)return{ok:!1,aborted:!0};let h=vn(n);if(h){let p=new URL(e.url,location.href).hash,g=p&&!new URL(h.url,location.href).hash?h.url+p:h.url;return{ok:!0,doc:{html:h.html,url:g,status:h.status}}}}Ln();let o;try{o=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:t,cache:e.bypassCache?"no-cache":"default"})}catch(y){return y?.name==="AbortError"||t.aborted?{ok:!1,aborted:!0}:b("krate:navigate-error",{url:e.url,status:0,error:y},!0)?{ok:!1,hard:e.url}:{ok:!1,aborted:!0}}let i=o.url||n;if(new URL(i,location.href).origin!==location.origin)return{ok:!1,hard:i};let a=o.headers.get("content-type")||"",s="";try{s=await o.text()}catch(y){if(y?.name==="AbortError"||t.aborted)return{ok:!1,aborted:!0};s=""}if(t.aborted)return{ok:!1,aborted:!0};let c=Ae(a)||a===""&&Q(s),u=new URL(e.url,location.href).hash,l=u&&!new URL(i).hash?i+u:i;if(o.ok)return c?{ok:!0,doc:{html:s,url:l,status:o.status}}:{ok:!1,hard:l};if(b("krate:navigate-error",{url:e.url,status:o.status}),c&&Q(s))return{ok:!0,doc:{html:s,url:l,status:o.status}};let m=null;return o.status===404||o.status===410?m=await it("/404.html"):o.status>=500&&(m=await it("/500.html")),t.aborted?{ok:!1,aborted:!0}:m?{ok:!0,doc:{html:m,url:l,status:o.status}}:{ok:!1,hard:l}}async function _e(e){let t=location.href;if(e.kind!=="pop"){if(!b("krate:navigate-start",{url:e.url,from:t,kind:e.kind},!0))return}else b("krate:navigate-start",{url:e.url,from:t,kind:e.kind});let n=++T;k&&k.abort();let r=new AbortController;k=r,D("loading");let o;try{o=await Kn(e,r.signal)}finally{k===r&&(k=void 0)}if(n===T){if(!o.ok){ce(),D("idle"),"hard"in o&&Y(o.hard,e.kind==="replace"||e.kind==="refresh");return}await Bn(o.doc,e,n)}}function st(e){let t=e.querySelector('meta[name="krate-build"]');return t&&t.getAttribute("content")||""}var re;async function Bn(e,t,n){let r=new DOMParser().parseFromString(e.html,"text/html"),o=e.url;re===void 0&&(re=st(document));let i=st(r);if(re&&i&&i!==re){ce(),D("idle"),Y(o,t.kind!=="push");return}let a=S(r),s=S(document),c=Rn(r,o),u=Cn(r,o,Ke(r,o));if(await Promise.all([c.ready,u.ready]),n!==T){c.abort(),u.remove();return}let l=d,m=location.href;t.kind==="push"&&le(d);let y=Dt(r),h=zn(I,y,location.href,o,r),p=w(o).split("?")[0]===C.split("?")[0],g=null,f=null,v=[];if(await $n(()=>{p&&(g=In(s,h));let x=document.activeElement;f=x&&x!==document.body&&s.contains(x)?x:null;let Zt=f?jn(f):null,Qe=r.querySelector("title");Qe&&(document.title=Qe.textContent||"");let he=globalThis;h.keep.length>0&&typeof he.krateDisposeExcept=="function"?he.krateDisposeExcept(h.keep):typeof he.disposeAll=="function"&&he.disposeAll();let Pe={sameProps:!p},Ne=O=>{let te=document.createDocumentFragment();for(let U of O)te.appendChild(document.importNode(U,!0));return Array.from(te.childNodes)};if(h.region){let{live:O,next:te}=h.region;v=Me(O[0].parentNode,O[0],O[1],Ne(W(te[0],te[1])),Pe);for(let U of h.slots)v.push(...Me(U.live[0].parentNode,U.live[0],U.live[1],Ne(W(U.next[0],U.next[1])),Pe));Gn(s,a)}else v=Me(s,null,null,Ne(Array.from(a.childNodes)),Pe);I=h.chain,Z.forEach(O=>Ht(O.nodes)),Z.clear(),c.commit(),Pn(r),Nn(r),Lt(document),f&&f.isConnected?(document.activeElement!==f&&Vn(f,Zt),g=null):g&&rt(s,g)},t.kind!=="refresh"&&!p),n!==T){u.remove();return}ce(),t.kind==="push"?(d=j(),history.pushState(ae(d,t.state),"",o)):t.kind==="replace"?(P.delete(d),E.delete(d),d=j(),history.replaceState(ae(d,t.state),"",o)):t.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):t.restoreKey&&(d=t.restoreKey),e.status>=200&&e.status<300&&$e(d,{html:e.html,url:location.href,status:e.status}),t.kind==="push"&&l&&l===G?(G="",kn(l,m)):t.kind==="replace"&&l===G&&(G=""),_=w(location.href),C=_,Ft(r),Xn(r),Mn(o,t),t.kind!=="pop"&&t.kind!=="refresh"&&On(),t.kind!=="refresh"&&Un(),Le(),b("krate:navigate",{url:location.href,status:e.status}),je(location.href),D("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(x=>x.remove()),Nt(r);let q=Ke(r,o);ct(h.skip);let ee=await Promise.all(q.map(Pt));if(ct([]),u.remove(),n!==T)return;if(ee.some(x=>!x)){b("krate:navigate-error",{url:location.href,status:e.status,error:"script-load"}),Y(location.href,!0);return}Ee(),b("krate:navigate-end",{url:location.href,status:e.status});let de=g;de&&!nt(s)&&(await Wn(v),n===T&&!nt(s)&&rt(s,de))}function Mt(){let e=globalThis.__krateIslandSwap;return e&&typeof e.swap=="function"&&typeof e.unmount=="function"?e:null}function Me(e,t,n,r,o){let i=Mt();if(i)return i.swap(e,t,n,r,o);if(t&&n){ze(t,n);for(let a of r)e.insertBefore(a,n)}else e.replaceChildren(...r);return[]}function Ht(e){let t=Mt();t&&t.unmount(e)}function Wn(e){let t=globalThis.__krateIslandsReady,n=Promise.all([...e,t&&typeof t.then=="function"?t:null]);return Promise.race([n,new Promise(r=>setTimeout(r,3e3))])}function jn(e){let t=e;try{return typeof t.selectionStart=="number"&&typeof t.selectionEnd=="number"?[t.selectionStart,t.selectionEnd]:null}catch{return null}}function Vn(e,t){try{e.focus({preventScroll:!0}),t&&document.activeElement===e&&typeof e.setSelectionRange=="function"&&e.setSelectionRange(t[0],t[1])}catch{}}function $n(e,t=!0){if(!t||!Tn())return e(),Promise.resolve();let n=!1,r=()=>{n||(n=!0,e())};try{let o=document.startViewTransition(r);o&&o.finished&&typeof o.finished.catch=="function"&&o.finished.catch(()=>{}),o&&o.ready&&typeof o.ready.catch=="function"&&o.ready.catch(()=>{});let i=o&&o.updateCallbackDone;if(i&&typeof i.then=="function")return i.then(()=>r(),()=>r())}catch{}return r(),Promise.resolve()}var I=[];function Dt(e){let t=e.getElementById("__krate_route");if(!t)return[];try{let n=JSON.parse(t.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return ne("unreadable #__krate_route route info; layouts will be remounted"),[]}}function at(e,t){let n=J(new URL(e,location.href).pathname).split("/").filter(Boolean);return(t<0?n:n.slice(0,t)).join("/")}function H(e,t,n="kl:"){let o=(e.ownerDocument||e).createTreeWalker(e,128),i=n+t,a="/"+n+t;for(;o.nextNode();){let s=o.currentNode;if(s.nodeValue===i){for(let c=s.nextSibling;c;c=c.nextSibling)if(c.nodeType===8&&c.nodeValue===a)return[s,c];return null}}return null}function W(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function ze(e,t){let n=globalThis.disposeNode;Ht(W(e,t));for(let r of W(e,t))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function Gn(e,t){let n=":scope > template[data-krate-loading]";e.querySelectorAll(n).forEach(r=>r.remove()),t.querySelectorAll(n).forEach(r=>e.appendChild(document.importNode(r,!0)))}function ct(e){let t=globalThis.krateKeepScopes;typeof t=="function"&&t(e)}function Jn(e){let t=globalThis.krateScopeFailed;return typeof t=="function"&&!!t(e)}function zn(e,t,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:t},a=0;for(;a<e.length&&a<t.length;){let p=e[a],g=t[a];if(p.id!==g.id||p.k!==g.k||p.k!=="layout"&&p.k!=="error"||at(n,p.d)!==at(r,g.d)||p.k==="error"&&Jn(p.id))break;if(!p.p||!g.p){ne(`layout ${g.f||g.id} is remounted on this navigation: ${g.why||p.why||"not persistable"}`);break}a++}if(a===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return ne("the runtime has no krateDisposeExcept; layouts are remounted"),i;let s=t[a-1].id,c=H(S(document),s),u=H(S(o),s);if(!c||!u)return ne(`layout ${t[a-1].f||s} boundary markers are missing; the whole page is swapped`),i;let l=e.slice(0,a).map(p=>p.id),m=l.slice(),y=[],h=t.slice();for(let p=0;p<a;p++){let g=e[p].s||[],f=[];for(let v of t[p].s||[]){let R=g.find(de=>de.key===v.key),q=H(S(document),v.key,"ks:"),ee=H(S(o),v.key,"ks:");if(R&&q&&(v.src!=="page"||!ee)){l.push(R.scope),m.push(R.scope,v.scope),f.push({...v,scope:R.scope,src:R.src});continue}if(q&&ee){y.push({live:q,next:ee}),f.push(v);continue}return ne(`slot @${v.n} markers are missing; the whole page is swapped`),i}h[p]={...t[p],s:f}}return{keep:l,skip:m,region:{live:c,next:u},slots:y,chain:h}}var Z=new Map,C="";function Be(e){let t=e.replace(/^\/+|\/+$/g,"");return t?t.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 It(e,t){let n=Be(t),r=e.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let a=0;a<n.length;a++){let s=n[a];if(s.kind>=2){if(a!==n.length-1)return null;let c=o.slice(a);return s.kind===2&&c.length===0||c.some(u=>u==="")?null:(i[s.text]=c.map(He).join("/"),i)}if(a>=o.length)return null;if(s.kind===1){if(!o[a])return null;i[s.text]=He(o[a])}else if(He(o[a])!==s.text)return null}return o.length===n.length?i:null}function He(e){try{return decodeURIComponent(e)}catch{return e}}function Ot(e,t){let n=Be(e),r=Be(t);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:e<t?-1:e>t?1:0}function Xe(e){let t=J(new URL(e,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of I)for(let o of r.s||[])for(let i of o.i||[])It(t,i)&&(!n||Ot(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:t},pattern:i});return n&&!H(S(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Ut(e,t){I=I.map(n=>n.s&&n.s.some(r=>r.key===e)?{...n,s:n.s.map(r=>r.key===e?t:r)}:n)}function Ft(e){let t="",n=e.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(t=r.r)}catch{}globalThis.__KRATE_ROUTE__=t;for(let r of Array.from(e.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 Xn(e){let t=e.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!t){n&&n.remove();return}let r=document.importNode(t,!0);n?n.replaceWith(r):document.head.appendChild(r)}function Kt(e){let t=globalThis.krateDisposeScopes;typeof t=="function"&&t(e)}async function Ye(e,t){let n=location.href;if(e.kind!=="pop"&&!b("krate:navigate-start",{url:e.url,from:n,kind:e.kind,intercept:t.slot.n},!0))return;let r=++T;k&&k.abort();let o=new AbortController;k=o,D("loading");let i=location.origin+$()+"/"+hn+"/"+t.slot.key+(t.path?"/"+t.path:""),a="",s=!1;try{let f=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:e.bypassCache?"no-cache":"default"});a=await f.text(),s=f.ok&&(Ae(f.headers.get("content-type")||"")||Q(a)),s||b("krate:navigate-error",{url:e.url,status:f.status,intercept:t.slot.n})}catch(f){if(f?.name==="AbortError"||o.signal.aborted)return;b("krate:navigate-error",{url:e.url,status:0,error:f,intercept:t.slot.n})}finally{k===o&&(k=void 0)}if(r!==T)return;let c=s?new DOMParser().parseFromString(a,"text/html"):null,u=c?H(S(c),t.slot.key,"ks:"):null,l=H(S(document),t.slot.key,"ks:"),m=null;try{let f=c&&c.getElementById("__krate_route");m=f&&JSON.parse(f.textContent||"{}").frag||null}catch{m=null}if(!c||!u||!l||!m||m.key!==t.slot.key||!m.scope){try{console.warn(`[krate router] intercepting route for ${e.url} (slot @${t.slot.n}) could not be loaded; navigating to the page`)}catch{}return D("idle"),_e({...e})}if(e.kind==="push"&&le(d),t.slot.src!=="intercept"){Z.set(d,{key:t.slot.key,nodes:W(l[0],l[1]),slot:t.slot,path:C});for(let f of W(l[0],l[1]))f.parentNode.removeChild(f)}else Kt([t.slot.scope]),ze(l[0],l[1]);for(let f of W(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(f,!0),l[1]);let y=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(f=>y.add(f.href)),c.querySelectorAll('link[rel="stylesheet"][href]').forEach(f=>{let v=new URL(f.getAttribute("href"),i).href;if(y.has(v))return;let R=document.createElement("link");R.rel="stylesheet",R.href=v,document.head.appendChild(R)}),Ut(t.slot.key,{...t.slot,scope:m.scope,src:"intercept"}),Nt(c);let h={__krate:"",state:e.state===void 0?null:e.state,__kint:{key:t.slot.key,base:C}};e.kind==="push"?(d=j(),h.__krate=d,history.pushState(h,"",e.url)):e.kind==="replace"?(d=j(),h.__krate=d,history.replaceState(h,"",e.url)):e.kind==="pop"&&e.restoreKey&&(d=e.restoreKey),_=w(location.href),Ft(c),Le(),b("krate:navigate",{url:location.href,status:200,intercept:t.slot.n}),je(location.href),D("idle");let p=Ke(c,i),g=await Promise.all(p.map(Pt));if(r===T){if(g.some(f=>!f)){b("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:t.slot.n}),Y(location.href,!0);return}Ee(),b("krate:navigate-end",{url:location.href,status:200,intercept:t.slot.n})}}function Yn(e,t){let n=H(S(document),e.key,"ks:"),r=I.flatMap(i=>i.s||[]).find(i=>i.key===e.key);if(!n||!r||r.src!=="intercept")return!1;Kt([r.scope]),ze(n[0],n[1]);for(let i of e.nodes)n[1].parentNode.insertBefore(i,n[1]);Ut(e.key,e.slot),Z.delete(t),d=t,_=w(location.href);let o=P.get(t);return o!==void 0&&window.scrollTo(0,o),Le(),b("krate:navigate",{url:location.href,status:200}),je(location.href),Se(),!0}function Qn(e){return w(e)===_}function Bt(){z==="loading"&&(T++,k&&k.abort(),k=void 0,ce(),D("idle"))}function Zn(e,t){if(Bt(),le(d),e!==location.href||t.state!==void 0)if(t.kind==="replace")history.replaceState(ae(d||j(),t.state),"",e);else{let r=E.get(d);d=j(),history.pushState(ae(d,t.state),"",e),r&&$e(d,{...r,url:e})}let n=new URL(e).hash;!Je(n)&&t.scroll&&!n&&window.scrollTo(0,0),Se()}function Re(e){let t;try{t=new URL(e.url,location.href)}catch{return Y(e.url),Promise.resolve()}if(t.origin!==location.origin)return Y(t.href,e.kind==="replace"),Promise.resolve();if(e.url=t.href,(e.kind==="push"||e.kind==="replace")&&Qn(t.href)&&(t.hash||t.href===location.href))return Zn(t.href,e),Promise.resolve();if(e.kind==="push"||e.kind==="replace"){let n=Xe(t.href);if(n)return Ye(e,n)}return _e(e)}function Wt(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-krate-link]");if(!n||!Ge(n))return;let r=n.getAttribute("href");r&&(e.preventDefault(),Re({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function qn(e,t){let n=r=>{if(!r)return!1;let o=r;return!!(o.__krateForm||o.__krateFormAction)||r.hasAttribute("data-krate-action")};return n(e)||n(t)}function jt(e){if(e.defaultPrevented)return;let t=e.target;if(!t||t.tagName!=="FORM"||t.hasAttribute("data-krate-reload"))return;let n=e.submitter||null;if(qn(t,n)||(n&&n.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||t.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||t.getAttribute("action")||"",a;try{a=new URL(i||location.href,location.href)}catch{return}if(a.origin!==location.origin||a.protocol.indexOf("http")!==0)return;let s;try{s=n?new FormData(t,n):new FormData(t)}catch{s=new FormData(t),n&&n.name&&s.append(n.name,n.value)}let c=new URLSearchParams;for(let[u,l]of s.entries()){if(typeof l!="string")return;c.append(u,l)}e.preventDefault(),a.search=c.toString(),a.hash="",Re({url:a.href,kind:"push",scroll:!0})}function Vt(e){le(d);let t=ve(e.state),n=location.href;if(w(n)===_){Bt(),d=t||d;let i=t?P.get(t):void 0;i!==void 0?window.scrollTo(0,i):Je(location.hash),Se();return}let r=t?Z.get(t):void 0;if(r&&t&&r.path===w(n)&&r.path===C&&Yn(r,t))return;let o=e.state&&typeof e.state=="object"?e.state.__kint:null;if(o&&o.base===C){let i=Xe(n);if(i&&i.slot.key===o.key){Ye({url:n,kind:"pop",scroll:!1,restoreKey:t},i);return}}_e({url:n,kind:"pop",scroll:!0,restoreKey:t})}function $t(){Ve(),zt()}function Gt(){le(d);try{history.scrollRestoration="auto"}catch{}}function Jt(){try{history.scrollRestoration="manual"}catch{}}function Ee(){Tt(),Le(),Lt(document),document.querySelectorAll("script[src]").forEach(e=>{lt.test(e.src)||e.setAttribute("data-krate-spa","")})}function zt(){let e=V();if(e)return e.refresh();if(!L||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(_!==C){let t=Xe(location.href);if(t&&t.slot.src==="intercept")return Ye({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},t)}return _e({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function Xt(e,t={}){if(!L){let n=V();if(n)return n.push(e,t);let r=ft();return r?r(e,{...t,replace:!1}):typeof location<"u"&&location.assign(M(e)),Promise.resolve()}return Re({url:M(e),kind:"push",scroll:t.scroll!==!1,state:t.state})}function Yt(e,t={}){if(!L){let n=V();if(n)return n.replace(e,t);let r=ft();return r?r(e,{...t,replace:!0}):typeof location<"u"&&location.replace(M(e)),Promise.resolve()}return Re({url:M(e),kind:"replace",scroll:t.scroll!==!1,state:t.state})}var fe={push:Xt,replace:Yt,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:zt,prefetch(e){let t=V();if(t)return t.prefetch(e);if(!L||typeof location>"u")return Promise.resolve();let n;try{n=new URL(M(e),location.href)}catch{return Promise.resolve()}return n.origin!==location.origin?Promise.resolve():Te(n.href)},subscribe:gt,getState:pt,invalidate:Ve};function er(e,t={}){return L||V()?(t.replace?Yt(e,t):Xt(e,t),!1):(typeof location<"u"&&(t.replace?location.replace(M(e)):location.assign(M(e))),!0)}function Qt(){if(!(typeof document>"u")){if(L){Ee();return}if(L=!0,globalThis[ie]=fe,document.querySelectorAll("script[data-krate-boot]").forEach(e=>be.add(e.textContent||"")),_=w(location.href),I=Dt(document),Ue=Fe(document),C=_,d=ve(history.state)||j(),G=d,ve(history.state)===void 0)try{history.replaceState(ae(d,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",Wt),document.addEventListener("submit",jt),window.addEventListener("popstate",Vt),window.addEventListener("krate:revalidate",$t),window.addEventListener("pagehide",Gt),window.addEventListener("pageshow",Jt),wn(),Sn(),Ee()}}function tr(){Qt()}function nr(){if(L){L=!1,re=void 0,globalThis[ie]===fe&&delete globalThis[ie],document.removeEventListener("click",Wt),document.removeEventListener("submit",jt),window.removeEventListener("popstate",Vt),window.removeEventListener("krate:revalidate",$t),window.removeEventListener("pagehide",Gt),window.removeEventListener("pageshow",Jt),document.removeEventListener("mouseover",ke),document.removeEventListener("focusin",ke);for(let e of At)document.removeEventListener(e,St);for(let e of K.values())clearTimeout(e);K=new Map,B&&(B.disconnect(),B=null),k&&k.abort(),k=void 0,T++,A.clear(),N.clear(),E.clear(),G="",oe++,P.clear(),ge.clear(),be.clear(),se.clear(),z="idle",document.documentElement.removeAttribute(ht),ce(),I=[],Z.clear(),C=""}}return on(rr);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }