@krate/runtime 0.4.0-rc.3 → 0.4.0-rc.4

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.
@@ -0,0 +1,373 @@
1
+ var __krate_exports = (() => {
2
+ // src/dev-overlay.ts
3
+ function devConfig() {
4
+ const raw = window.__KRATE_DEV__;
5
+ const runtime = window.__KRATE_CFG__;
6
+ return {
7
+ sse: raw?.sse ?? "/__krate/hotreload",
8
+ errors: raw?.errors ?? "/__krate/client-error",
9
+ open: raw?.open ?? "/__krate/open",
10
+ overlay: raw?.overlay ?? true,
11
+ toolbar: raw?.toolbar ?? true,
12
+ basePath: raw?.basePath ?? runtime?.basePath ?? ""
13
+ };
14
+ }
15
+ function esc(s) {
16
+ return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
17
+ }
18
+ function norm(p) {
19
+ return p.replace(/\/+$/, "") || "/";
20
+ }
21
+ function stripBase(pathname, basePath) {
22
+ if (basePath && (pathname === basePath || pathname.startsWith(basePath + "/"))) {
23
+ const rest = pathname.slice(basePath.length);
24
+ return rest === "" ? "/" : rest;
25
+ }
26
+ return pathname;
27
+ }
28
+ function routeMatches(pattern, pathname, basePath = "") {
29
+ const a = norm(stripBase(pathname, basePath)).split("/");
30
+ const b = norm(pattern).split("/");
31
+ for (let i = 0; i < b.length; i++) {
32
+ const s = b[i];
33
+ if (s.charAt(0) === "[") {
34
+ if (s.indexOf("[...") === 0) return true;
35
+ continue;
36
+ }
37
+ if (s !== a[i]) return false;
38
+ }
39
+ return a.length === b.length;
40
+ }
41
+ var ICON_RELOAD = '<svg class="ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-2.64-6.36"/><path d="M21 3v6h-6"/></svg>';
42
+ var ICON_ALERT = '<svg class="ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>';
43
+ var STYLE = `
44
+ :host { all: initial; }
45
+ * { box-sizing: border-box; }
46
+
47
+ /* ── palette ─────────────────────────────────────────────────────────── */
48
+ :host {
49
+ --red: #f87171;
50
+ --green: #34d399;
51
+ --bg: #111114;
52
+ --bg-2: #17171c;
53
+ --line: #2a2a31;
54
+ --fg: #e5e7eb;
55
+ --muted: #9ca3af;
56
+ }
57
+
58
+ /* ── toolbar ─────────────────────────────────────────────────────────── */
59
+ .toolbar {
60
+ position: fixed; left: 50%; bottom: 0; z-index: 2147483001;
61
+ transform: translate(-50%, 54%);
62
+ transition: transform .28s cubic-bezier(.22,.61,.36,1),
63
+ border-top-color .35s ease;
64
+ display: flex; align-items: stretch; gap: 2px;
65
+ background: var(--bg);
66
+ border: 1px solid var(--line);
67
+ border-top: 3px solid var(--green);
68
+ border-radius: 16px 16px 0 0;
69
+ padding: 7px 8px 9px;
70
+ box-shadow: 0 -10px 30px rgba(0,0,0,.45);
71
+ font: 12px/1.3 ui-sans-serif, system-ui, -apple-system, sans-serif;
72
+ color: var(--fg);
73
+ }
74
+ .toolbar:hover, .toolbar:focus-within { transform: translate(-50%, 0); }
75
+ .toolbar.bad { border-top-color: var(--red); }
76
+
77
+ .tb-btn {
78
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
79
+ gap: 3px; min-width: 56px; padding: 5px 10px;
80
+ background: transparent; border: 1px solid transparent; border-radius: 11px;
81
+ color: var(--muted); cursor: pointer; font: inherit;
82
+ transition: color .15s ease, background .15s ease;
83
+ }
84
+ .tb-btn:hover { color: var(--fg); background: rgba(255,255,255,.06); }
85
+ .tb-btn .ic { display: block; width: 18px; height: 18px; }
86
+ .tb-btn .tb-label { font-size: 10px; letter-spacing: .02em; }
87
+ .toolbar.bad .tb-btn.errors { color: var(--red); }
88
+
89
+ .tb-center {
90
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
91
+ gap: 1px; min-width: 130px; padding: 2px 16px;
92
+ }
93
+ .tb-center .brand { font-size: 12px; font-weight: 700; letter-spacing: .05em; color: #f3f4f6; }
94
+ .tb-center .route {
95
+ font-size: 10px; color: var(--muted);
96
+ max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
97
+ }
98
+
99
+ /* ── overlay ─────────────────────────────────────────────────────────── */
100
+ .overlay {
101
+ position: fixed; inset: 0; z-index: 2147483000;
102
+ background: rgba(9, 9, 11, 0.72); backdrop-filter: blur(6px);
103
+ display: flex; align-items: flex-start; justify-content: center;
104
+ padding: 4vh 16px; overflow: auto;
105
+ font: 13px/1.5 "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
106
+ color: var(--fg);
107
+ }
108
+ .overlay[hidden] { display: none; }
109
+ .card {
110
+ width: min(920px, 100%); background: var(--bg);
111
+ border: 1px solid var(--line);
112
+ border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,0.5); overflow: hidden;
113
+ }
114
+ .card-head {
115
+ display: flex; align-items: center; gap: 10px; padding: 14px 18px;
116
+ border-bottom: 1px solid var(--line); background: var(--bg-2);
117
+ }
118
+ .title { font-weight: 600; font-size: 14px; color: var(--red); }
119
+ .count { color: var(--muted); font-size: 12px; }
120
+ .spacer { flex: 1; }
121
+ .btn {
122
+ border: 1px solid var(--line); background: transparent; color: var(--muted);
123
+ border-radius: 9px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 12px;
124
+ transition: color .15s ease, background .15s ease, border-color .15s ease;
125
+ }
126
+ .btn:hover { color: var(--fg); background: rgba(255,255,255,.06); border-color: #44444f; }
127
+ .list { padding: 6px 0; }
128
+ .diag { padding: 14px 18px; border-bottom: 1px solid #1f1f26; }
129
+ .diag:last-child { border-bottom: none; }
130
+ .actions { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
131
+ .loc {
132
+ display: inline-flex; align-items: center; gap: 6px; color: #60a5fa;
133
+ background: transparent; border: none; padding: 0; cursor: pointer;
134
+ font: inherit; font-size: 12px;
135
+ }
136
+ .loc:hover { text-decoration: underline; }
137
+ .msg { color: #f3f4f6; white-space: pre-wrap; word-break: break-word; }
138
+ .frame {
139
+ margin-top: 10px; background: #0b0b0e; border: 1px solid #26262e;
140
+ border-radius: 7px; padding: 8px 10px; overflow-x: auto; white-space: pre;
141
+ }
142
+ .frame .src { color: #cbd5e1; }
143
+ .frame .caret { color: var(--red); }
144
+ .hint { margin-top: 8px; color: #a3e635; }
145
+ .stack {
146
+ margin-top: 10px; color: var(--muted); white-space: pre-wrap; word-break: break-word;
147
+ max-height: 320px; overflow: auto;
148
+ }
149
+ `;
150
+ var KrateDev = class {
151
+ constructor() {
152
+ this.cfg = devConfig();
153
+ this.buildDiags = [];
154
+ this.runtimeErrors = [];
155
+ this.seen = /* @__PURE__ */ new Set();
156
+ }
157
+ init() {
158
+ const host = document.createElement("div");
159
+ host.id = "krate-dev-root";
160
+ (document.body || document.documentElement).appendChild(host);
161
+ this.shadow = host.attachShadow({ mode: "open" });
162
+ const style = document.createElement("style");
163
+ style.textContent = STYLE;
164
+ this.shadow.appendChild(style);
165
+ this.overlay = document.createElement("div");
166
+ this.overlay.className = "overlay";
167
+ this.overlay.hidden = true;
168
+ this.overlay.innerHTML = '<div class="card"><div class="card-head"><span class="title"></span><span class="count"></span><span class="spacer"></span><button class="btn close" type="button">Dismiss (Esc)</button></div><div class="list"></div></div>';
169
+ this.shadow.appendChild(this.overlay);
170
+ this.title = this.overlay.querySelector(".title");
171
+ this.list = this.overlay.querySelector(".list");
172
+ if (this.cfg.toolbar) {
173
+ this.toolbar = document.createElement("div");
174
+ this.toolbar.className = "toolbar";
175
+ this.toolbar.innerHTML = '<button class="tb-btn errors" type="button" title="Show errors">' + ICON_ALERT + '<span class="tb-label">Errors</span></button><div class="tb-center"><span class="brand">krate</span><span class="route"></span></div><button class="tb-btn reload" type="button" title="Reload">' + ICON_RELOAD + '<span class="tb-label">Reload</span></button>';
176
+ this.shadow.appendChild(this.toolbar);
177
+ this.routeEl = this.toolbar.querySelector(".route");
178
+ this.routeEl.textContent = location.pathname;
179
+ this.watchLocation();
180
+ }
181
+ this.shadow.addEventListener("click", (e) => this.onClick(e));
182
+ document.addEventListener("keydown", (e) => {
183
+ if (e.key === "Escape") this.hide();
184
+ });
185
+ this.connectSSE();
186
+ this.captureRuntimeErrors();
187
+ }
188
+ onClick(e) {
189
+ const t = e.target.closest(".btn, .loc, .tb-btn");
190
+ if (!t) return;
191
+ if (t.classList.contains("tb-btn")) t.blur();
192
+ if (t.classList.contains("close")) {
193
+ this.hide();
194
+ return;
195
+ }
196
+ if (t.classList.contains("errors") || t.classList.contains("toggle")) {
197
+ if (this.overlay.hidden) this.show();
198
+ else this.hide();
199
+ return;
200
+ }
201
+ if (t.classList.contains("reload")) {
202
+ location.reload();
203
+ return;
204
+ }
205
+ if (t.classList.contains("loc") || t.classList.contains("open")) {
206
+ this.openInEditor(t.getAttribute("data-file") || "", t.getAttribute("data-line") || "");
207
+ }
208
+ }
209
+ openInEditor(file, line) {
210
+ if (!file) return;
211
+ const url = this.cfg.open + "?file=" + encodeURIComponent(file) + "&line=" + encodeURIComponent(line);
212
+ fetch(url).catch(() => {
213
+ });
214
+ }
215
+ /** Keep the toolbar route label in sync with SPA (history) navigation. */
216
+ watchLocation() {
217
+ const update = () => {
218
+ if (this.routeEl) this.routeEl.textContent = location.pathname;
219
+ };
220
+ window.addEventListener("popstate", update);
221
+ const h = history;
222
+ const push = h.pushState.bind(history);
223
+ h.pushState = function(...args) {
224
+ const r = push(...args);
225
+ update();
226
+ return r;
227
+ };
228
+ const replace = h.replaceState.bind(history);
229
+ h.replaceState = function(...args) {
230
+ const r = replace(...args);
231
+ update();
232
+ return r;
233
+ };
234
+ setInterval(update, 500);
235
+ }
236
+ connectSSE() {
237
+ let sse;
238
+ try {
239
+ sse = new EventSource(this.cfg.sse);
240
+ } catch {
241
+ return;
242
+ }
243
+ sse.addEventListener("reload", (e) => {
244
+ try {
245
+ const d = JSON.parse(e.data);
246
+ if (d.pages && Array.isArray(d.pages) && !d.pages.some((p) => routeMatches(p, location.pathname, this.cfg.basePath))) {
247
+ return;
248
+ }
249
+ } catch {
250
+ }
251
+ location.reload();
252
+ });
253
+ sse.addEventListener("build-error", (e) => {
254
+ try {
255
+ const d = JSON.parse(e.data);
256
+ this.buildDiags = Array.isArray(d.diagnostics) ? d.diagnostics : [];
257
+ } catch {
258
+ this.buildDiags = [];
259
+ }
260
+ this.setStatus(this.buildDiags.length === 0);
261
+ this.render();
262
+ });
263
+ sse.addEventListener("client-error", (e) => {
264
+ try {
265
+ const d = JSON.parse(e.data);
266
+ if (d.clientError) this.addRuntime("Runtime Error", d.clientError.message, d.clientError.stack);
267
+ } catch {
268
+ }
269
+ });
270
+ }
271
+ captureRuntimeErrors() {
272
+ window.addEventListener("error", (e) => {
273
+ const stack = e.error?.stack || "";
274
+ this.report({
275
+ message: e.message || "Unknown error",
276
+ stack,
277
+ url: e.filename,
278
+ line: e.lineno,
279
+ col: e.colno,
280
+ kind: "error"
281
+ });
282
+ this.addRuntime("Runtime Error", e.message || "Unknown error", stack);
283
+ });
284
+ window.addEventListener("unhandledrejection", (e) => {
285
+ const reason = e.reason;
286
+ const message = reason instanceof Error ? reason.message : String(reason);
287
+ const stack = reason instanceof Error ? reason.stack : "";
288
+ this.report({ message, stack, url: location.href, kind: "unhandledrejection" });
289
+ this.addRuntime("Unhandled Promise Rejection", message, stack);
290
+ });
291
+ }
292
+ report(payload) {
293
+ const key = payload.message + "|" + (payload.stack || "");
294
+ if (this.seen.has(key)) return;
295
+ this.seen.add(key);
296
+ try {
297
+ const body = JSON.stringify(payload);
298
+ if (navigator.sendBeacon) {
299
+ navigator.sendBeacon(this.cfg.errors, new Blob([body], { type: "application/json" }));
300
+ } else {
301
+ fetch(this.cfg.errors, { method: "POST", body, headers: { "Content-Type": "application/json" }, keepalive: true });
302
+ }
303
+ } catch {
304
+ }
305
+ }
306
+ addRuntime(title, message, stack) {
307
+ this.runtimeErrors.push({ title, message, stack });
308
+ this.setStatus(false);
309
+ this.render();
310
+ }
311
+ setStatus(ok) {
312
+ if (!this.toolbar) return;
313
+ this.toolbar.classList.toggle("bad", !ok);
314
+ }
315
+ frameHTML(d) {
316
+ if (!d.source) return "";
317
+ const col = Math.max(1, d.col || 1);
318
+ const caret = " ".repeat(col - 1) + "^";
319
+ return '<div class="frame"><span class="src">' + esc(d.source) + '</span>\n<span class="caret">' + esc(caret) + "</span></div>";
320
+ }
321
+ diagHTML(d) {
322
+ let actions = "";
323
+ if (d.file) {
324
+ const loc = d.file + (d.line ? ":" + d.line + (d.col ? ":" + d.col : "") : "");
325
+ actions = '<div class="actions"><button class="loc" data-file="' + esc(d.file) + '" data-line="' + esc(d.line || "") + '">' + esc(loc) + '</button><button class="btn open" data-file="' + esc(d.file) + '" data-line="' + esc(d.line || "") + '">Open in editor</button></div>';
326
+ }
327
+ const hint = d.hint ? '<div class="hint">hint: ' + esc(d.hint) + "</div>" : "";
328
+ return '<div class="diag">' + actions + '<div class="msg">' + esc(d.message) + "</div>" + this.frameHTML(d) + hint + "</div>";
329
+ }
330
+ runtimeHTML(r) {
331
+ const stack = r.stack ? '<div class="stack">' + esc(r.stack) + "</div>" : "";
332
+ return '<div class="diag"><div class="msg">' + esc(r.message) + "</div>" + stack + "</div>";
333
+ }
334
+ render() {
335
+ const total = this.buildDiags.length + this.runtimeErrors.length;
336
+ if (total === 0) {
337
+ this.hide();
338
+ return;
339
+ }
340
+ this.title.textContent = this.buildDiags.length > 0 ? "Compilation failed" : "Runtime error";
341
+ let html = "";
342
+ for (const d of this.buildDiags) html += this.diagHTML(d);
343
+ for (const r of this.runtimeErrors) html += this.runtimeHTML(r);
344
+ this.list.innerHTML = html;
345
+ this.overlay.querySelector(".count").textContent = total > 1 ? String(total) : "";
346
+ if (this.cfg.overlay) this.overlay.hidden = false;
347
+ }
348
+ show() {
349
+ if (this.buildDiags.length + this.runtimeErrors.length > 0) this.overlay.hidden = false;
350
+ }
351
+ hide() {
352
+ this.overlay.hidden = true;
353
+ }
354
+ };
355
+ function initDevOverlay() {
356
+ if (typeof window === "undefined" || typeof document === "undefined") return;
357
+ if (window.__krate_dev_overlay) return;
358
+ window.__krate_dev_overlay = true;
359
+ try {
360
+ new KrateDev().init();
361
+ } catch (err) {
362
+ console.error("[krate] dev overlay failed to initialise", err);
363
+ }
364
+ }
365
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
366
+ if (document.readyState === "loading") {
367
+ document.addEventListener("DOMContentLoaded", initDevOverlay, { once: true });
368
+ } else {
369
+ initDevOverlay();
370
+ }
371
+ }
372
+ })();
373
+ for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var F=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var tt=(e,t)=>{for(var n in t)F(e,n,{get:t[n],enumerable:!0})},nt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ze(t))!et.call(e,s)&&s!==n&&F(e,s,{get:()=>t[s],enumerable:!(r=Qe(t,s))||r.enumerable});return e};var rt=e=>nt(F({},"__esModule",{value:!0}),e);var Wt={};tt(Wt,{Slot:()=>qt,clearNodes:()=>_e,clearPersisted:()=>ct,cloneElement:()=>zt,clsx:()=>de,cn:()=>Kt,conditional:()=>Mt,createCSSChoice:()=>ft,createCSSFlags:()=>dt,createCSSGroup:()=>pt,createCSSRange:()=>gt,createCSSStack:()=>ht,createCSSToggle:()=>ut,createContext:()=>st,createEffect:()=>A,createMemo:()=>bt,createReducer:()=>vt,createResource:()=>Pt,createSignal:()=>x,cva:()=>Vt,disposeAll:()=>at,disposeNode:()=>N,forwardRef:()=>Et,h:()=>At,hydrate:()=>Rt,initRouter:()=>De,insert:()=>wt,mount:()=>Ct,onCleanup:()=>D,onMount:()=>Tt,readDurableState:()=>G,readPersisted:()=>Q,reconcile:()=>Lt,reconcileTrees:()=>ae,reinitRouter:()=>Ht,resetContexts:()=>$,resolvePersist:()=>J,subscribePersist:()=>ee,twMerge:()=>pe,useRef:()=>xt,writePersisted:()=>Z});var ot=0,M=new Map;function $(){for(let[e,t]of M)if(t.length>0){let n=t[0];M.set(e,[n])}}function st(e){let t=ot++;return M.set(t,[e]),{id:t,defaultValue:e,Provider:n=>{let r=M.get(t)||[e];r.push(n.value),M.set(t,r);let s=document.createElement("div");if(s.style.display="contents",n.children)for(let c of n.children)c instanceof Node?s.appendChild(c):c!=null&&s.appendChild(document.createTextNode(String(c)));return r.pop(),r.length===0&&r.push(e),s},useContext:()=>{let n=M.get(t);return n&&n.length>0?n[n.length-1]:e}}}function it(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var X=it();function Re(){return typeof window<"u"}function Y(e){if(e&&typeof e=="object")return e;if(!Re())return X;try{return e==="session"?window.sessionStorage:e==="memory"?X:window.localStorage}catch{return X}}function J(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function G(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let s=r[e];if(typeof s=="string")try{return{found:!0,value:t(s)}}catch{return{found:!0,value:s}}return{found:!0,value:s}}function Q(e){let t=Y(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function Z(e,t){let n=Y(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function ct(e){let t=Y(e.store);try{t.removeItem(e.key)}catch{}}var V=new Map,Ce=!1;function lt(){Ce||!Re()||(Ce=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=V.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ee(e,t){if(!e.sync)return()=>{};let n=V.get(e.key)??new Set;return n.add(t),V.set(e.key,n),lt(),()=>{n.delete(t),n.size===0&&V.delete(e.key)}}var C=[],Pe=[],te=!1,O=new Set,ne=[],re=[],j=!1;function Le(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function oe(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function at(){for(let e of O)oe(e);O.clear();for(let e of ne)try{e()}catch{}ne.length=0,re.length=0,j=!1,$()}function ft(e,t){return x(e)}function ut(e,t){return x(e)}function dt(e,t){let n={};for(let s of e){let[c]=x(!1);n[s]=c}return[n,(s,c)=>{}]}function pt(e,t){return x(e)}function gt(e,t){return x(e)}function ht(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function x(e,t){let n=e,r=null;if(t?.persist){r=J(t.persist);let a=G(r.key,r.deserialize);if(a.found)n=a.value;else{let l=Q(r);l.found&&(n=l.value)}}let s=new Set,c=()=>{let a=C[C.length-1];return a&&!a.disposed&&(s.add(a),a.sources.add(s)),n},f=()=>{let a=Array.from(s);for(let l of a){if(l.disposed){s.delete(l);continue}if(l.running){l.rerun=!0;continue}l.queued||(l.queued=!0,re.push(l))}mt()},y=a=>{let l=typeof a=="function"?a(n):a;l!==n&&(n=l,r&&Z(r,n),f())};if(r&&r.sync){let a=r,l=ee(a,S=>{if(S!==null)try{let g=a.deserialize(S);g!==n&&(n=g,f())}catch{}});D(l)}return[c,y]}function mt(){j||(j=!0,queueMicrotask(yt))}function yt(){j=!1;let e=re.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,C.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{C.pop(),e.running=!1}}function A(e){let t=Le(e);return O.add(t),q(t),()=>{oe(t),O.delete(t)}}function D(e){let t=C[C.length-1];t?t.cleanups.push(e):ne.push(e)}function Tt(e){Pe.push(e),te||(te=!0,queueMicrotask(St))}function St(){te=!1;let e=Pe.splice(0);for(let t of e)t()}function bt(e){let[t,n]=x(void 0),r=Le(()=>{let c=e();n(c)});O.add(r),q(r);let s=C[C.length-1];return s&&s.cleanups.push(()=>{r.disposed||(oe(r),O.delete(r))}),t}function vt(e,t){let[n,r]=x(t);return[n,c=>r(f=>e(f,c))]}function xt(e){return{current:e}}function Et(e){return t=>e(t,t.ref||(()=>{}))}var kt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},se=new WeakMap;function Oe(e,t){let n=se.get(e);n||(n=[],se.set(e,n)),n.push(t)}function N(e){let t=se.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)N(e.childNodes[n])}function Nt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function _e(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;N(r),n.removeChild(r),r=s}}function wt(e,t,n){let r=Nt(n);r?(_e(n,r),ie(e,t,r)):ie(e,t,null)}function ie(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)ie(e,r,n)}}function Me(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),s=kt[r]||r,c=`__krate_${s}`,f=e[c];f&&e.removeEventListener(s,f),e.addEventListener(s,n),e[c]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function He(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)He(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Oe(n,A(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function At(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,c]of Object.entries(t))typeof c=="function"&&!s.startsWith("on")?Oe(r,A(()=>Me(r,s,c()))):Me(r,s,c);for(let s of n)He(r,s);return r}function Ie(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Ct(e,t){let n=Ie(t),r=!1;A(()=>{r||(r=!0,n.appendChild(e()))})}function Rt(e,t){let n=Ie(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&N(r)}function Pt(e,t){let[n,r]=x(void 0),[s,c]=x(!0),[f,y]=x(void 0),[a,l]=x("unresolved"),[S,g]=x(0),d,m=()=>typeof e=="function"?e():e,b=async()=>{d&&d.abort(),d=new AbortController;let w=d,K=m();l(S()>0?"refreshing":"loading"),c(!0),y(void 0);try{let R=await t(K,{signal:w.signal});w.signal.aborted||(r(()=>R),l("ready"))}catch(R){R?.name!=="AbortError"&&!w.signal.aborted&&(y(R),l("error"))}finally{w.signal.aborted||c(!1)}};A(()=>{typeof e=="function"&&e.length===0&&e(),S(),b(),D(()=>{d&&(d.abort(),d=void 0)})});let T=function(){return n()};return Object.defineProperties(T,{loading:{get:()=>s()},error:{get:()=>f()},state:{get:()=>a()}}),[T,{mutate:w=>{r(w)},refetch:()=>{g(w=>w+1)}}]}function Lt(e,t,n,r,s,c){let f=[],y=t.nextSibling;for(;y&&y!==n;)f.push(y),y=y.nextSibling;if(c){let a=new Map;for(let g of f){let d=g.__k;d!=null&&a.set(d,g)}let l=[],S=new Set;for(let g=0;g<r.length;g++){let d=r[g],m=c(d);S.add(m);let b=s(d,g);b.__k=m,l.push(b)}for(let[g,d]of a)!S.has(g)&&d.parentNode===e&&(N(d),e.removeChild(d));for(let g=0;g<l.length;g++){let d=l[g],m=g===0?t:l[g-1];d!==m.nextSibling&&e.insertBefore(d,m.nextSibling)}}else{let a=Math.max(f.length,r.length);for(let l=0;l<a;l++)if(l<r.length){let S=s(r[l],l);l<f.length?f[l]!==S&&(N(f[l]),e.replaceChild(S,f[l])):e.insertBefore(S,n)}else l<f.length&&f[l].parentNode===e&&(N(f[l]),e.removeChild(f[l]))}}function Mt(e,t,n,r,s,c){let f=null;A(()=>{let a=r()?s():c?c():null;f?a?(N(f),e.replaceChild(a,f)):(N(f),e.removeChild(f)):a&&e.insertBefore(a,n),f=a})}function _(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Ke(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,c=t.attributes[r].value;n.add(s),e.getAttribute(s)!==c&&e.setAttribute(s,c)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function ce(e,t){let n=document.importNode(t,!0);return e.parentNode&&(N(e),e.parentNode.replaceChild(n,e)),n}function Ve(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function le(e,t){if(!Ve(e,t))return ce(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?ce(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return _(n)!==_(r)?ce(n,r):(Ke(n,r),je(n,r),n)}function je(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let d=0;d<r.length;d++)if(_(n[d])!==_(r[d])){g=!1;break}if(g){for(let d=0;d<r.length;d++)le(n[d],r[d]);return}}let s=new Map,c=[];n.forEach((g,d)=>{let m=_(g);m!=null?s.has(m)||s.set(m,d):c.push(d)});let f=new Set,y=0,a=null,l=0,S=()=>{for(;l<c.length&&f.has(c[l]);)l++;return l<c.length?c[l]:-1};for(let g of r){let d=_(g),m;if(d!=null&&s.has(d)){let b=s.get(d);s.delete(d),f.add(b);let T=n[b];b<y?e.insertBefore(T,a):y=b,m=le(T,g)}else if(d==null){let b=S();if(b>=0&&Ve(n[b],g)){f.add(b);let T=n[b];T.parentNode===e&&T.nextSibling!==a&&e.insertBefore(T,a),m=le(T,g)}else m=document.importNode(g,!0),e.insertBefore(m,a)}else m=document.importNode(g,!0),e.insertBefore(m,a);a=m.nextSibling}n.forEach((g,d)=>{!f.has(d)&&g.parentNode===e&&(N(g),e.removeChild(g))})}function ae(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}Ke(n,r),je(n,r)}var fe=!1,H,z=null,P=new Map,Ot=30,I=new Map,_t=50,qe=/\/chunks\/runtime\.[^/]+\.js$/;function De(){if(typeof document>"u"||fe)return;fe=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,s=null,c=new Map,f=null;function y(o){for(let i of e.split(", ")){let u=o.querySelector(i.trim());if(u)return u}return o.body}function a(o){if(o.hasAttribute("data-krate-external"))return!1;let i=o.getAttribute("href");return!(!i||i.startsWith("#")||i.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function l(o){P.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>{if(i){if(P.size>=Ot){let u=P.keys().next().value;u!==void 0&&P.delete(u)}P.set(o,i)}}).catch(()=>{})}function S(){document.addEventListener("mouseover",m),document.addEventListener("focusin",m),typeof IntersectionObserver<"u"&&(f=new IntersectionObserver(o=>{for(let i of o)if(i.isIntersecting){let u=i.target,p=u.getAttribute("href");if(p&&a(u)){let h=new URL(p,location.origin).href;l(h)}f.unobserve(i.target)}},{rootMargin:"200px"}),g())}function g(){f&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{f.observe(o)})}function d(){document.removeEventListener("mouseover",m),document.removeEventListener("focusin",m);for(let o of c.values())clearTimeout(o);c.clear(),f&&(f.disconnect(),f=null)}function m(o){let i=o.target.closest("a[data-prefetch]");if(!i||!a(i))return;let u=i.getAttribute("href");if(!u)return;let p=new URL(u,location.origin).href;if(P.has(p))return;let h=c.get(i);h&&clearTimeout(h);let v=setTimeout(()=>{c.delete(i),l(p)},n);c.set(i,v)}function b(o){let i=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),u=i.nextNode();for(;u;){let p=u;for(let h of Object.keys(p))h.indexOf("__krate_")===0&&delete p[h];u=i.nextNode()}}let T=null;function ge(){let o=y(document),i=document.querySelector("template[data-krate-loading]");i&&i.content&&o&&(T=i.content.cloneNode(!0),document.body.appendChild(T)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function w(){T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let o=y(document);o&&(o.style.opacity="1")}function K(o){try{let i=globalThis.__krate_onNavigation;typeof i=="function"&&i(o)}catch{}}function R(o,i,u,p={}){let{replace:h=!1,scroll:v=!0,restoreScroll:L=!1}=p,W=new DOMParser().parseFromString(o,"text/html"),Ee=y(W),B=y(document);if(!Ee||!B){location.href=i;return}let ke=W.querySelector("title");ke&&(document.title=ke.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),b(B),ae(B,Ee);let Ne=W.querySelectorAll('link[rel="stylesheet"]'),we=new Set;Ne.forEach(E=>{let k=E.getAttribute("href");k&&we.add(k)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(E=>{let k=E.getAttribute("href");k&&!we.has(k)&&E.remove()});let Ae=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(E=>{Ae.add(E.href)}),Ne.forEach(E=>{let k=E.getAttribute("href");if(k&&!Ae.has(k)){let U=document.createElement("link");U.rel="stylesheet",U.href=k,document.head.appendChild(U)}}),Ue(u,i).then(()=>{try{$e(),g()}catch(E){try{let k=globalThis.__krate_onHydrationError;typeof k=="function"&&k(E)}catch{}location.href=i}}),w();let Ge=location.pathname+location.search;if(h)history.replaceState({},"",i);else{if(!L){if(I.size>=_t){let E=I.keys().next().value;E!==void 0&&I.delete(E)}I.set(Ge,window.scrollY)}history.pushState({},"",i)}he(i,{restoreScroll:L,scroll:v}),me(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:i}})),K(i)}function Be(o){let i=o.indexOf("#");if(i<0||i===o.length-1)return!1;let u=o.slice(i);try{let p=document.querySelector(u);if(p)return p.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function he(o,i){if(i.restoreScroll){let u=I.get(o);if(u!==void 0){window.scrollTo(0,u);return}}Be(o)||i.scroll&&window.scrollTo(0,0)}function me(){let o=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(i=>{let u=i.getAttribute("href");if(!u){i.removeAttribute("aria-current");return}let p=u;try{p=new URL(u,location.origin).pathname}catch{return}p===o||o==="/"&&(p===""||p==="/")||p!=="/"&&p.length>1&&o.startsWith(p)?i.setAttribute("aria-current","page"):i.removeAttribute("aria-current")})}function Ue(o,i){return o.length===0?Promise.resolve():Promise.all(o.map(u=>{let p=u.getAttribute("src");return p?Fe(p,i):Promise.resolve()})).then(()=>{})}function Fe(o,i){return new Promise(u=>{let p=document.createElement("script"),h=ye(o,i);p.src=h,qe.test(h)||p.setAttribute("data-krate-spa",""),p.onload=()=>u(),p.onerror=()=>u(),document.body.appendChild(p)})}function ye(o,i){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,i).href;let u=i;if(!u.endsWith("/")){let p=u.lastIndexOf("/");u=p>0?u.slice(0,p+1):"/"}return new URL(o,u).href}function $e(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Xe(o,i){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",i),K(i),document.open(),document.write(o),document.close()}function Ye(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function Je(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(s=o,o)).catch(()=>null)}function Te(o,i){document.querySelectorAll("script[data-krate-spa]").forEach(h=>h.remove());let u=[],p=new Set;return document.querySelectorAll("script[src]").forEach(h=>{p.add(h.src)}),o.querySelectorAll("script[src]").forEach(h=>{let v=h.getAttribute("src");v&&!p.has(ye(v,i))&&u.push(h)}),u}function Se(o,i={}){let u=P.get(o);if(u){let v=new DOMParser().parseFromString(u,"text/html");R(u,o,Te(v,o),i);return}ge(),H&&H.abort(),H=new AbortController;let p=H.signal;fetch(o,{headers:{Accept:"text/html"},signal:p}).then(h=>h.ok?h.text().then(v=>{let xe=new DOMParser().parseFromString(v,"text/html");R(v,o,Te(xe,o),i)}):(h.status>=500?Je():Ye()).then(L=>{L?Xe(L,o):location.href=o})).catch(h=>{h?.name!=="AbortError"&&(w(),location.href=o)}).finally(()=>{H&&!p.aborted&&(H=void 0)})}let be=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let i=o.target.closest("a[data-krate-link]");if(!i||!a(i))return;o.preventDefault();let u=i.getAttribute("href");if(!u)return;let p=new URL(u,location.origin).href,h=i.hasAttribute("data-krate-replace"),v=i.getAttribute("data-krate-scroll")!=="false";if(u===location.pathname+location.search+location.hash){h&&history.replaceState({},"",u),he(p,{scroll:v});return}Se(p,{replace:h,scroll:v})},ve=()=>{Se(location.href,{restoreScroll:!0})};document.addEventListener("click",be),window.addEventListener("popstate",ve),S(),me(),document.querySelectorAll("script[src]").forEach(o=>{qe.test(o.src)||o.setAttribute("data-krate-spa","")}),z=()=>{document.removeEventListener("click",be),window.removeEventListener("popstate",ve),d()}}function Ht(){z&&(z(),z=null),fe=!1,De()}function ue(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)ue(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function de(...e){let t=[];for(let n of e)ue(n,t);return t.join(" ")}function pe(...e){let t=[];for(let s of e)ue(s,t);let n=new Map,r=[];for(let s of t){let c=It(s);n.has(c)||r.push(c),n.set(c,s)}return r.map(s=>n.get(s)).join(" ")}function It(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),c=s>=0?t.slice(0,s):t,f=s>=0?t.slice(s+1,s+2):"";return n+c+(f&&/[0-9]/.test(f)?"-"+f:"")}function Kt(...e){return pe(de(...e))}function Vt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let c={};for(let a of Object.keys(n)){let l=s?.[a]??r[a];l!=null&&(c[a]=String(l))}let f=[e];for(let a of Object.keys(n)){let l=c[a];l&&n[a][l]&&f.push(n[a][l])}for(let a of t?.compoundVariants??[])if(jt(a,c,r)){let l=a.class;typeof l=="string"&&f.push(l)}let y=s?.class??s?.className;return typeof y=="string"&&f.push(y),pe(de(f))}}function jt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],c=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(c))return!1}else if(s!==c)return!1}return!0}function qt(e){let t=ze(e?.children);return t?(We(t,e),t):null}function ze(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=ze(t);if(n)return n}return null}return e instanceof Node?e:null}function We(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let s=e.getAttribute("class"),c=s?s+" "+String(r):String(r);e.setAttribute("class",c);continue}if(n==="style"&&typeof r=="object"){for(let[s,c]of Object.entries(r))e.style.setProperty(Dt(s),String(c));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function Dt(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function zt(e,t,...n){if(!(e instanceof Node))return e;if(t&&We(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return rt(Wt);})();
1
+ var __krate_exports=(()=>{var X=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var n in t)X(e,n,{get:t[n],enumerable:!0})},ut=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ct(t))!at.call(e,i)&&i!==n&&X(e,i,{get:()=>t[i],enumerable:!(r=st(t,i))||r.enumerable});return e};var ft=e=>ut(X({},"__esModule",{value:!0}),e);var en={};lt(en,{Slot:()=>Gt,clearNodes:()=>He,clearPersisted:()=>ht,cloneElement:()=>Zt,clsx:()=>he,cn:()=>Yt,conditional:()=>jt,createCSSChoice:()=>Tt,createCSSFlags:()=>St,createCSSGroup:()=>vt,createCSSRange:()=>Et,createCSSStack:()=>xt,createCSSToggle:()=>bt,createContext:()=>pt,createEffect:()=>A,createMemo:()=>Ct,createReducer:()=>Rt,createResource:()=>Vt,createSignal:()=>v,cva:()=>Jt,disposeAll:()=>yt,disposeNode:()=>k,forwardRef:()=>Pt,h:()=>Ht,hydrate:()=>Kt,initRouter:()=>Be,insert:()=>Ot,mount:()=>It,navigate:()=>Wt,onCleanup:()=>U,onMount:()=>Nt,readDurableState:()=>te,readPersisted:()=>ne,reconcile:()=>qt,reconcileTrees:()=>Dt,reinitRouter:()=>Ft,resetContexts:()=>G,resolvePersist:()=>ee,subscribePersist:()=>oe,twMerge:()=>me,useRef:()=>Lt,writePersisted:()=>re});var dt=0,_=new Map;function G(){for(let[e,t]of _)if(t.length>0){let n=t[0];_.set(e,[n])}}function pt(e){let t=dt++;return _.set(t,[e]),{id:t,defaultValue:e,Provider:n=>{let r=_.get(t)||[e];r.push(n.value),_.set(t,r);let i=document.createElement("div");if(i.style.display="contents",n.children)for(let c of n.children)c instanceof Node?i.appendChild(c):c!=null&&i.appendChild(document.createTextNode(String(c)));return r.pop(),r.length===0&&r.push(e),i},useContext:()=>{let n=_.get(t);return n&&n.length>0?n[n.length-1]:e}}}function gt(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var Q=gt();function Le(){return typeof window<"u"}function Z(e){if(e&&typeof e=="object")return e;if(!Le())return Q;try{return e==="session"?window.sessionStorage:e==="memory"?Q:window.localStorage}catch{return Q}}function ee(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function te(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let i=r[e];if(typeof i=="string")try{return{found:!0,value:t(i)}}catch{return{found:!0,value:i}}return{found:!0,value:i}}function ne(e){let t=Z(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function re(e,t){let n=Z(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function ht(e){let t=Z(e.store);try{t.removeItem(e.key)}catch{}}var j=new Map,Re=!1;function mt(){Re||!Le()||(Re=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=j.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function oe(e,t){if(!e.sync)return()=>{};let n=j.get(e.key)??new Set;return n.add(t),j.set(e.key,n),mt(),()=>{n.delete(t),n.size===0&&j.delete(e.key)}}var L=[],Pe=[],ie=!1,O=new Set,se=[],ce=[],D=!1;function Me(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function ae(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function yt(){for(let e of O)ae(e);O.clear();for(let e of se)try{e()}catch{}se.length=0,ce.length=0,D=!1,G()}function Tt(e,t){return v(e)}function bt(e,t){return v(e)}function St(e,t){let n={};for(let i of e){let[c]=v(!1);n[i]=c}return[n,(i,c)=>{}]}function vt(e,t){return v(e)}function Et(e,t){return v(e)}function xt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function v(e,t){let n=e,r=null;if(t?.persist){r=ee(t.persist);let u=te(r.key,r.deserialize);if(u.found)n=u.value;else{let a=ne(r);a.found&&(n=a.value)}}let i=new Set,c=()=>{let u=L[L.length-1];return u&&!u.disposed&&(i.add(u),u.sources.add(i)),n},f=()=>{let u=Array.from(i);for(let a of u){if(a.disposed){i.delete(a);continue}if(a.running){a.rerun=!0;continue}a.queued||(a.queued=!0,ce.push(a))}wt()},b=u=>{let a=typeof u=="function"?u(n):u;a!==n&&(n=a,r&&re(r,n),f())};if(r&&r.sync){let u=r,a=oe(u,S=>{if(S!==null)try{let g=u.deserialize(S);g!==n&&(n=g,f())}catch{}});U(a)}return[c,b]}function wt(){D||(D=!0,queueMicrotask(kt))}function kt(){D=!1;let e=ce.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,z(t),t.rerun&&!t.disposed&&(t.rerun=!1,z(t)))}function z(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,L.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{L.pop(),e.running=!1}}function A(e){let t=Me(e);return O.add(t),z(t),()=>{ae(t),O.delete(t)}}function U(e){let t=L[L.length-1];t?t.cleanups.push(e):se.push(e)}function Nt(e){Pe.push(e),ie||(ie=!0,queueMicrotask(At))}function At(){ie=!1;let e=Pe.splice(0);for(let t of e)t()}function Ct(e){let[t,n]=v(void 0),r=Me(()=>{let c=e();n(c)});O.add(r),z(r);let i=L[L.length-1];return i&&i.cleanups.push(()=>{r.disposed||(ae(r),O.delete(r))}),t}function Rt(e,t){let[n,r]=v(t);return[n,c=>r(f=>e(f,c))]}function Lt(e){return{current:e}}function Pt(e){return t=>e(t,t.ref||(()=>{}))}var Mt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},le=new WeakMap;function Oe(e,t){let n=le.get(e);n||(n=[],le.set(e,n)),n.push(t)}function k(e){let t=le.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)k(e.childNodes[n])}function _t(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function He(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let i=r.nextSibling;k(r),n.removeChild(r),r=i}}function Ot(e,t,n){let r=_t(n);r?(He(n,r),ue(e,t,r)):ue(e,t,null)}function ue(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)ue(e,r,n)}}function _e(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),i=Mt[r]||r,c=`__krate_${i}`,f=e[c];f&&e.removeEventListener(i,f),e.addEventListener(i,n),e[c]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function Ie(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Ie(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Oe(n,A(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function Ht(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[i,c]of Object.entries(t))typeof c=="function"&&!i.startsWith("on")?Oe(r,A(()=>_e(r,i,c()))):_e(r,i,c);for(let i of n)Ie(r,i);return r}function Ke(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function It(e,t){let n=Ke(t),r=!1;A(()=>{r||(r=!0,n.appendChild(e()))})}function Kt(e,t){let n=Ke(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&k(r)}function Vt(e,t){let[n,r]=v(void 0),[i,c]=v(!0),[f,b]=v(void 0),[u,a]=v("unresolved"),[S,g]=v(0),d,y=()=>typeof e=="function"?e():e,T=async()=>{d&&d.abort(),d=new AbortController;let N=d,V=y();a(S()>0?"refreshing":"loading"),c(!0),b(void 0);try{let C=await t(V,{signal:N.signal});N.signal.aborted||(r(()=>C),a("ready"))}catch(C){C?.name!=="AbortError"&&!N.signal.aborted&&(b(C),a("error"))}finally{N.signal.aborted||c(!1)}};A(()=>{typeof e=="function"&&e.length===0&&e(),S(),T(),U(()=>{d&&(d.abort(),d=void 0)})});let E=function(){return n()};return Object.defineProperties(E,{loading:{get:()=>i()},error:{get:()=>f()},state:{get:()=>u()}}),[E,{mutate:N=>{r(N)},refetch:()=>{g(N=>N+1)}}]}function qt(e,t,n,r,i,c){let f=[],b=t.nextSibling;for(;b&&b!==n;)f.push(b),b=b.nextSibling;if(c){let u=new Map;for(let g of f){let d=g.__k;d!=null&&u.set(d,g)}let a=[],S=new Set;for(let g=0;g<r.length;g++){let d=r[g],y=c(d);S.add(y);let T=i(d,g);T.__k=y,a.push(T)}for(let[g,d]of u)!S.has(g)&&d.parentNode===e&&(k(d),e.removeChild(d));for(let g=0;g<a.length;g++){let d=a[g],y=g===0?t:a[g-1];d!==y.nextSibling&&e.insertBefore(d,y.nextSibling)}}else{let u=Math.max(f.length,r.length);for(let a=0;a<u;a++)if(a<r.length){let S=i(r[a],a);a<f.length?f[a]!==S&&(k(f[a]),e.replaceChild(S,f[a])):e.insertBefore(S,n)}else a<f.length&&f[a].parentNode===e&&(k(f[a]),e.removeChild(f[a]))}}function jt(e,t,n,r,i,c){let f=null;A(()=>{let u=r()?i():c?c():null;f?u?(k(f),e.replaceChild(u,f)):(k(f),e.removeChild(f)):u&&e.insertBefore(u,n),f=u})}function H(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Ve(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let i=t.attributes[r].name,c=t.attributes[r].value;n.add(i),e.getAttribute(i)!==c&&e.setAttribute(i,c)}for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r].name;n.has(i)||e.removeAttribute(i)}}function fe(e,t){let n=document.importNode(t,!0);return e.parentNode&&(k(e),e.parentNode.replaceChild(n,e)),n}function qe(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function de(e,t){if(!qe(e,t))return fe(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?fe(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return H(n)!==H(r)?fe(n,r):(Ve(n,r),je(n,r),n)}function je(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let d=0;d<r.length;d++)if(H(n[d])!==H(r[d])){g=!1;break}if(g){for(let d=0;d<r.length;d++)de(n[d],r[d]);return}}let i=new Map,c=[];n.forEach((g,d)=>{let y=H(g);y!=null?i.has(y)||i.set(y,d):c.push(d)});let f=new Set,b=0,u=null,a=0,S=()=>{for(;a<c.length&&f.has(c[a]);)a++;return a<c.length?c[a]:-1};for(let g of r){let d=H(g),y;if(d!=null&&i.has(d)){let T=i.get(d);i.delete(d),f.add(T);let E=n[T];T<b?e.insertBefore(E,u):b=T,y=de(E,g)}else if(d==null){let T=S();if(T>=0&&qe(n[T],g)){f.add(T);let E=n[T];E.parentNode===e&&E.nextSibling!==u&&e.insertBefore(E,u),y=de(E,g)}else y=document.importNode(g,!0),e.insertBefore(y,u)}else y=document.importNode(g,!0),e.insertBefore(y,u);u=y.nextSibling}n.forEach((g,d)=>{!f.has(d)&&g.parentNode===e&&(k(g),e.removeChild(g))})}function Dt(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let i=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(i,n);return}Ve(n,r),je(n,r)}var pe=!1,I,W=null,B=0,P=new Map,zt=30,K=new Map,Ut=50,De=/\/chunks\/runtime\.[^/]+\.js$/;function Ue(){return globalThis.__KRATE_CFG__||{}}function Bt(){let e=Ue().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function ze(e){let t=Bt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var F=null;function Wt(e,t={}){return F?(F(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function Be(){if(typeof document>"u"||pe)return;pe=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,i=null,c=new Map,f=null;function b(o){for(let s of e.split(", ")){let l=o.querySelector(s.trim());if(l)return l}return o.body}function u(o){if(o.hasAttribute("data-krate-external"))return!1;let s=o.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function a(o){P.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(P.size>=zt){let l=P.keys().next().value;l!==void 0&&P.delete(l)}P.set(o,s)}}).catch(()=>{})}function S(){document.addEventListener("mouseover",y),document.addEventListener("focusin",y),typeof IntersectionObserver<"u"&&(f=new IntersectionObserver(o=>{for(let s of o)if(s.isIntersecting){let l=s.target,p=l.getAttribute("href");if(p&&u(l)){let h=new URL(p,location.origin).href;a(h)}f.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){f&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{f.observe(o)})}function d(){document.removeEventListener("mouseover",y),document.removeEventListener("focusin",y);for(let o of c.values())clearTimeout(o);c.clear(),f&&(f.disconnect(),f=null)}function y(o){let s=o.target.closest("a[data-prefetch]");if(!s||!u(s))return;let l=s.getAttribute("href");if(!l)return;let p=new URL(l,location.origin).href;if(P.has(p))return;let h=c.get(s);h&&clearTimeout(h);let m=setTimeout(()=>{c.delete(s),a(p)},n);c.set(s,m)}let T=null;function E(){if(C())return;let o=b(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&o&&(T=s.content.cloneNode(!0),document.body.appendChild(T)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function $(){if(C())return;T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let o=b(document);o&&(o.style.opacity="1")}function N(o){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(o)}catch{}}function V(o,s){try{window.dispatchEvent(new CustomEvent(o,{detail:{url:s}}))}catch{}}function C(){if(Ue().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function $e(o){let s=o.querySelectorAll('link[rel="stylesheet"]'),l=new Set;s.forEach(h=>{let m=h.getAttribute("href");m&&l.add(new URL(m,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(h=>{let m=h.href;m&&!l.has(m)&&h.remove()});let p=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(h=>p.add(h.href)),s.forEach(h=>{let m=h.getAttribute("href");if(!m)return;let x=new URL(m,location.origin).href;if(!p.has(x)){let R=document.createElement("link");R.rel="stylesheet",R.href=x,document.head.appendChild(R)}})}function ye(o){o.querySelectorAll("[data-view-transition]").forEach(s=>{let l=s.getAttribute("data-view-transition");l&&(s.style.viewTransitionName=l)})}function Ye(){let o=b(document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1");try{o.focus({preventScroll:!0})}catch{try{o.focus()}catch{}}}}function Je(){let o=HTMLScriptElement.supports;if(!(typeof o!="function"||!o("speculationrules")))try{let s=document.createElement("script");s.type="speculationrules",s.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(s)}catch{}}function Te(o){return o.getElementById("root")||o.body}let be='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Xe(o){document.head.querySelectorAll(be).forEach(s=>s.remove()),o.head.querySelectorAll(be).forEach(s=>{document.head.appendChild(document.importNode(s,!0))})}function Se(o,s,l,p={}){let{replace:h=!1,scroll:m=!0,restoreScroll:x=!1}=p,M=new DOMParser().parseFromString(o,"text/html"),Ae=Te(M),Ce=Te(document);if(!Ae||!Ce){location.href=s;return}V("krate:navigate-start",s);let J=()=>{let w=M.querySelector("title");w&&(document.title=w.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let q=Array.from(Ae.childNodes).map(it=>document.importNode(it,!0));Ce.replaceChildren(...q),$e(M),Xe(M),ye(document)};if(C())try{let w=document.startViewTransition(J);w&&w.finished&&typeof w.finished.catch=="function"&&w.finished.catch(()=>{})}catch{J()}else J();Qe(l,s).then(()=>{try{et(),g()}catch(w){try{let q=globalThis.__krate_onHydrationError;typeof q=="function"&&q(w)}catch{}location.href=s}}),$();let ot=location.pathname+location.search;if(h)history.replaceState({},"",s);else{if(!x){if(K.size>=Ut){let w=K.keys().next().value;w!==void 0&&K.delete(w)}K.set(ot,window.scrollY)}history.pushState({},"",s)}ve(s,{restoreScroll:x,scroll:m}),x||Ye(),Ee(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),V("krate:navigate-end",s),N(s)}function Ge(o){let s=o.indexOf("#");if(s<0||s===o.length-1)return!1;let l=o.slice(s);try{let p=document.querySelector(l);if(p)return p.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function ve(o,s){if(s.restoreScroll){let l=K.get(o);if(l!==void 0){window.scrollTo(0,l);return}}Ge(o)||s.scroll&&window.scrollTo(0,0)}function Ee(){let o=ze(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(s=>{let l=s.getAttribute("href");if(!l){s.removeAttribute("aria-current");return}let p=l;try{p=ze(new URL(l,location.origin).pathname)}catch{return}p===o||o==="/"&&(p===""||p==="/")||p!=="/"&&p.length>1&&o.startsWith(p)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function Qe(o,s){return o.length===0?Promise.resolve():Promise.all(o.map(l=>{let p=l.getAttribute("src");return p?Ze(p,s):Promise.resolve()})).then(()=>{})}function Ze(o,s){return new Promise(l=>{let p=document.createElement("script"),h=xe(o,s);p.src=h,De.test(h)||p.setAttribute("data-krate-spa",""),p.onload=()=>l(),p.onerror=()=>l(),document.body.appendChild(p)})}function xe(o,s){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,s).href;let l=s;if(!l.endsWith("/")){let p=l.lastIndexOf("/");l=p>0?l.slice(0,p+1):"/"}return new URL(o,l).href}function et(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function tt(o,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),N(s),document.open(),document.write(o),document.close()}function nt(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function rt(){return i!==null?Promise.resolve(i):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(i=o,o)).catch(()=>null)}function we(o,s){document.querySelectorAll("script[data-krate-spa]").forEach(h=>h.remove());let l=[],p=new Set;return document.querySelectorAll("script[src]").forEach(h=>{p.add(h.src)}),o.querySelectorAll("script[src]").forEach(h=>{let m=h.getAttribute("src");m&&!p.has(xe(m,s))&&l.push(h)}),l}function Y(o,s={}){let l=++B,p=P.get(o);if(p){let x=new DOMParser().parseFromString(p,"text/html");Se(p,o,we(x,o),s);return}E(),I&&I.abort(),I=new AbortController;let h=I.signal;fetch(o,{headers:{Accept:"text/html"},signal:h}).then(m=>{if(l===B)return m.ok?m.text().then(x=>{if(l!==B)return;let M=new DOMParser().parseFromString(x,"text/html");Se(x,o,we(M,o),s)}):(m.status>=500?rt():nt()).then(R=>{l===B&&(R?tt(R,o):location.href=o)})}).catch(m=>{m?.name!=="AbortError"&&($(),location.href=o)}).finally(()=>{I&&!h.aborted&&(I=void 0)})}let ke=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let s=o.target.closest("a[data-krate-link]");if(!s||!u(s))return;o.preventDefault();let l=s.getAttribute("href");if(!l)return;let p=new URL(l,location.origin).href,h=s.hasAttribute("data-krate-replace"),m=s.getAttribute("data-krate-scroll")!=="false";if(l===location.pathname+location.search+location.hash){h&&history.replaceState({},"",l),ve(p,{scroll:m});return}Y(p,{replace:h,scroll:m})},Ne=()=>{Y(location.href,{restoreScroll:!0})};document.addEventListener("click",ke),window.addEventListener("popstate",Ne),S(),Je(),Ee(),ye(document),F=(o,s={})=>{let l=!0;try{l=new URL(o,location.href).origin===location.origin}catch{l=!1}if(!l){location.href=o;return}Y(new URL(o,location.href).href,s)},document.querySelectorAll("script[src]").forEach(o=>{De.test(o.src)||o.setAttribute("data-krate-spa","")}),W=()=>{document.removeEventListener("click",ke),window.removeEventListener("popstate",Ne),d(),F=null}}function Ft(){W&&(W(),W=null),pe=!1,Be()}function ge(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)ge(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function he(...e){let t=[];for(let n of e)ge(n,t);return t.join(" ")}function me(...e){let t=[];for(let i of e)ge(i,t);let n=new Map,r=[];for(let i of t){let c=$t(i);n.has(c)||r.push(c),n.set(c,i)}return r.map(i=>n.get(i)).join(" ")}function $t(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let i=t.indexOf("-"),c=i>=0?t.slice(0,i):t,f=i>=0?t.slice(i+1,i+2):"";return n+c+(f&&/[0-9]/.test(f)?"-"+f:"")}function Yt(...e){return me(he(...e))}function Jt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return i=>{let c={};for(let u of Object.keys(n)){let a=i?.[u]??r[u];a!=null&&(c[u]=String(a))}let f=[e];for(let u of Object.keys(n)){let a=c[u];a&&n[u][a]&&f.push(n[u][a])}for(let u of t?.compoundVariants??[])if(Xt(u,c,r)){let a=u.class;typeof a=="string"&&f.push(a)}let b=i?.class??i?.className;return typeof b=="string"&&f.push(b),me(he(f))}}function Xt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let i=e[r],c=t[r]??n[r]??void 0;if(Array.isArray(i)){if(!i.includes(c))return!1}else if(i!==c)return!1}return!0}function Gt(e){let t=We(e?.children);return t?(Fe(t,e),t):null}function We(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=We(t);if(n)return n}return null}return e instanceof Node?e:null}function Fe(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let i=e.getAttribute("class"),c=i?i+" "+String(r):String(r);e.setAttribute("class",c);continue}if(n==="style"&&typeof r=="object"){for(let[i,c]of Object.entries(r))e.style.setProperty(Qt(i),String(c));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function Qt(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Zt(e,t,...n){if(!(e instanceof Node))return e;if(t&&Fe(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return ft(en);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var X=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(e,t)=>{for(var n in t)X(e,n,{get:t[n],enumerable:!0})},it=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of tt(t))!nt.call(e,i)&&i!==n&&X(e,i,{get:()=>t[i],enumerable:!(r=et(t,i))||r.enumerable});return e};var st=e=>it(X({},"__esModule",{value:!0}),e);var Wt={};rt(Wt,{Fragment:()=>Nt,Slot:()=>Ft,clearNodes:()=>Ie,clearPersisted:()=>lt,cloneElement:()=>Ut,clsx:()=>fe,cn:()=>Kt,conditional:()=>It,createCSSChoice:()=>gt,createCSSFlags:()=>bt,createCSSGroup:()=>mt,createCSSRange:()=>pt,createCSSStack:()=>ht,createCSSToggle:()=>ft,createContext:()=>at,createEffect:()=>S,createMemo:()=>At,createReducer:()=>yt,createResource:()=>Pt,createSignal:()=>A,cva:()=>qt,disposeAll:()=>dt,disposeNode:()=>L,forwardRef:()=>Lt,h:()=>z,hydrate:()=>Ct,initRouter:()=>Fe,insert:()=>kt,jsx:()=>Be,jsxs:()=>Rt,mount:()=>wt,onCleanup:()=>q,onMount:()=>Et,readDurableState:()=>Q,readPersisted:()=>Z,reconcile:()=>Ot,reconcileTrees:()=>ce,reinitRouter:()=>Bt,resetContexts:()=>G,resolvePersist:()=>$,subscribePersist:()=>te,twMerge:()=>be,useRef:()=>Mt,writePersisted:()=>ee});var ot=0,N=new Map;function G(){for(let[e,t]of N)if(t.length>0){let n=t[0];N.set(e,[n])}}function at(e){let t=ot++;return N.set(t,[e]),{id:t,defaultValue:e,Provider:n=>{let r=N.get(t)||[e];r.push(n.value),N.set(t,r);let i=document.createElement("div");if(i.style.display="contents",n.children)for(let a of n.children)a instanceof Node?i.appendChild(a):a!=null&&i.appendChild(document.createTextNode(String(a)));return r.pop(),r.length===0&&r.push(e),i},useContext:()=>{let n=N.get(t);return n&&n.length>0?n[n.length-1]:e}}}function ut(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var J=ut();function Ce(){return typeof window<"u"}function Y(e){if(e&&typeof e=="object")return e;if(!Ce())return J;try{return e==="session"?window.sessionStorage:e==="memory"?J:window.localStorage}catch{return J}}function $(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function Q(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let i=r[e];if(typeof i=="string")try{return{found:!0,value:t(i)}}catch{return{found:!0,value:i}}return{found:!0,value:i}}function Z(e){let t=Y(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function ee(e,t){let n=Y(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function lt(e){let t=Y(e.store);try{t.removeItem(e.key)}catch{}}var B=new Map,we=!1;function ct(){we||!Ce()||(we=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=B.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function te(e,t){if(!e.sync)return()=>{};let n=B.get(e.key)??new Set;return n.add(t),B.set(e.key,n),ct(),()=>{n.delete(t),n.size===0&&B.delete(e.key)}}var k=[],Pe=[],ne=!1,R=new Set,re=[],ie=[],V=!1;function Ne(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function se(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function dt(){for(let e of R)se(e);R.clear();for(let e of re)try{e()}catch{}re.length=0,ie.length=0,V=!1,G()}function gt(e,t){return A(e)}function ft(e,t){return A(e)}function bt(e,t){let n={};for(let i of e){let[a]=A(!1);n[i]=a}return[n,(i,a)=>{}]}function mt(e,t){return A(e)}function pt(e,t){return A(e)}function ht(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function A(e,t){let n=e,r=null;if(t?.persist){r=$(t.persist);let c=Q(r.key,r.deserialize);if(c.found)n=c.value;else{let u=Z(r);u.found&&(n=u.value)}}let i=new Set,a=()=>{let c=k[k.length-1];return c&&!c.disposed&&(i.add(c),c.sources.add(i)),n},l=()=>{let c=Array.from(i);for(let u of c){if(u.disposed){i.delete(u);continue}if(u.running){u.rerun=!0;continue}u.queued||(u.queued=!0,ie.push(u))}Tt()},h=c=>{let u=typeof c=="function"?c(n):c;u!==n&&(n=u,r&&ee(r,n),l())};if(r&&r.sync){let c=r,u=te(c,v=>{if(v!==null)try{let b=c.deserialize(v);b!==n&&(n=b,l())}catch{}});q(u)}return[a,h]}function Tt(){V||(V=!0,queueMicrotask(vt))}function vt(){V=!1;let e=ie.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,K(t),t.rerun&&!t.disposed&&(t.rerun=!1,K(t)))}function K(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,k.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{k.pop(),e.running=!1}}function S(e){let t=Ne(e);return R.add(t),K(t),()=>{se(t),R.delete(t)}}function q(e){let t=k[k.length-1];t?t.cleanups.push(e):re.push(e)}function Et(e){Pe.push(e),ne||(ne=!0,queueMicrotask(Ht))}function Ht(){ne=!1;let e=Pe.splice(0);for(let t of e)t()}function At(e){let[t,n]=A(void 0),r=Ne(()=>{let a=e();n(a)});R.add(r),K(r);let i=k[k.length-1];return i&&i.cleanups.push(()=>{r.disposed||(se(r),R.delete(r))}),t}function yt(e,t){let[n,r]=A(t);return[n,a=>r(l=>e(l,a))]}function Mt(e){return{current:e}}function Lt(e){return t=>e(t,t.ref||(()=>{}))}var xt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},oe=new WeakMap;function Oe(e,t){let n=oe.get(e);n||(n=[],oe.set(e,n)),n.push(t)}function L(e){let t=oe.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)L(e.childNodes[n])}function St(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Ie(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let i=r.nextSibling;L(r),n.removeChild(r),r=i}}function kt(e,t,n){let r=St(n);r?(Ie(n,r),ae(e,t,r)):ae(e,t,null)}function ae(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)ae(e,r,n)}}function Re(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),i=xt[r]||r,a=`__krate_${i}`,l=e[a];l&&e.removeEventListener(i,l),e.addEventListener(i,n),e[a]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function _e(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)_e(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Oe(n,S(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function z(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[i,a]of Object.entries(t))typeof a=="function"&&!i.startsWith("on")?Oe(r,S(()=>Re(r,i,a()))):Re(r,i,a);for(let i of n)_e(r,i);return r}function De(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function wt(e,t){let n=De(t),r=!1;S(()=>{r||(r=!0,n.appendChild(e()))})}function Ct(e,t){let n=De(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&L(r)}function Pt(e,t){let[n,r]=A(void 0),[i,a]=A(!0),[l,h]=A(void 0),[c,u]=A("unresolved"),[v,b]=A(0),g,p=()=>typeof e=="function"?e():e,E=async()=>{g&&g.abort(),g=new AbortController;let x=g,D=p();u(v()>0?"refreshing":"loading"),a(!0),h(void 0);try{let w=await t(D,{signal:x.signal});x.signal.aborted||(r(()=>w),u("ready"))}catch(w){w?.name!=="AbortError"&&!x.signal.aborted&&(h(w),u("error"))}finally{x.signal.aborted||a(!1)}};S(()=>{typeof e=="function"&&e.length===0&&e(),v(),E(),q(()=>{g&&(g.abort(),g=void 0)})});let T=function(){return n()};return Object.defineProperties(T,{loading:{get:()=>i()},error:{get:()=>l()},state:{get:()=>c()}}),[T,{mutate:x=>{r(x)},refetch:()=>{b(x=>x+1)}}]}function Nt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let i of r)i instanceof Node?t.appendChild(i):t.appendChild(document.createTextNode(String(i)))}return t}function Be(e,t,n){let r=e;if(!t)return z(r,null);let{children:i,...a}=t,l=i!==void 0?Array.isArray(i)?i:[i]:[];return z(r,Object.keys(a).length>0?a:null,...l)}function Rt(e,t,n){return Be(e,t,n)}function Ot(e,t,n,r,i,a){let l=[],h=t.nextSibling;for(;h&&h!==n;)l.push(h),h=h.nextSibling;if(a){let c=new Map;for(let b of l){let g=b.__k;g!=null&&c.set(g,b)}let u=[],v=new Set;for(let b=0;b<r.length;b++){let g=r[b],p=a(g);v.add(p);let E=i(g,b);E.__k=p,u.push(E)}for(let[b,g]of c)!v.has(b)&&g.parentNode===e&&(L(g),e.removeChild(g));for(let b=0;b<u.length;b++){let g=u[b],p=b===0?t:u[b-1];g!==p.nextSibling&&e.insertBefore(g,p.nextSibling)}}else{let c=Math.max(l.length,r.length);for(let u=0;u<c;u++)if(u<r.length){let v=i(r[u],u);u<l.length?l[u]!==v&&(L(l[u]),e.replaceChild(v,l[u])):e.insertBefore(v,n)}else u<l.length&&l[u].parentNode===e&&(L(l[u]),e.removeChild(l[u]))}}function It(e,t,n,r,i,a){let l=null;S(()=>{let c=r()?i():a?a():null;l?c?(L(l),e.replaceChild(c,l)):(L(l),e.removeChild(l)):c&&e.insertBefore(c,n),l=c})}function O(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Ve(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let i=t.attributes[r].name,a=t.attributes[r].value;n.add(i),e.getAttribute(i)!==a&&e.setAttribute(i,a)}for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r].name;n.has(i)||e.removeAttribute(i)}}function ue(e,t){let n=document.importNode(t,!0);return e.parentNode&&(L(e),e.parentNode.replaceChild(n,e)),n}function Ke(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function le(e,t){if(!Ke(e,t))return ue(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?ue(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return O(n)!==O(r)?ue(n,r):(Ve(n,r),qe(n,r),n)}function qe(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let b=!0;for(let g=0;g<r.length;g++)if(O(n[g])!==O(r[g])){b=!1;break}if(b){for(let g=0;g<r.length;g++)le(n[g],r[g]);return}}let i=new Map,a=[];n.forEach((b,g)=>{let p=O(b);p!=null?i.has(p)||i.set(p,g):a.push(g)});let l=new Set,h=0,c=null,u=0,v=()=>{for(;u<a.length&&l.has(a[u]);)u++;return u<a.length?a[u]:-1};for(let b of r){let g=O(b),p;if(g!=null&&i.has(g)){let E=i.get(g);i.delete(g),l.add(E);let T=n[E];E<h?e.insertBefore(T,c):h=E,p=le(T,b)}else if(g==null){let E=v();if(E>=0&&Ke(n[E],b)){l.add(E);let T=n[E];T.parentNode===e&&T.nextSibling!==c&&e.insertBefore(T,c),p=le(T,b)}else p=document.importNode(b,!0),e.insertBefore(p,c)}else p=document.importNode(b,!0),e.insertBefore(p,c);c=p.nextSibling}n.forEach((b,g)=>{!l.has(g)&&b.parentNode===e&&(L(b),e.removeChild(b))})}function ce(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let i=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(i,n);return}Ve(n,r),qe(n,r)}var de=!1,I,F=null,C=new Map,_t=30,_=new Map,Dt=50,ze=/\/chunks\/runtime\.[^/]+\.js$/;function Fe(){if(typeof document>"u"||de)return;de=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,i=null,a=new Map,l=null;function h(s){for(let o of e.split(", ")){let d=s.querySelector(o.trim());if(d)return d}return s.body}function c(s){if(s.hasAttribute("data-krate-external"))return!1;let o=s.getAttribute("href");return!(!o||o.startsWith("#")||o.startsWith("javascript:")||s.origin!==location.origin||s.target==="_blank")}function u(s){C.has(s)||fetch(s,{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>{if(o){if(C.size>=_t){let d=C.keys().next().value;d!==void 0&&C.delete(d)}C.set(s,o)}}).catch(()=>{})}function v(){document.addEventListener("mouseover",p),document.addEventListener("focusin",p),typeof IntersectionObserver<"u"&&(l=new IntersectionObserver(s=>{for(let o of s)if(o.isIntersecting){let d=o.target,f=d.getAttribute("href");if(f&&c(d)){let m=new URL(f,location.origin).href;u(m)}l.unobserve(o.target)}},{rootMargin:"200px"}),b())}function b(){l&&document.querySelectorAll("a[data-prefetch]").forEach(s=>{l.observe(s)})}function g(){document.removeEventListener("mouseover",p),document.removeEventListener("focusin",p);for(let s of a.values())clearTimeout(s);a.clear(),l&&(l.disconnect(),l=null)}function p(s){let o=s.target.closest("a[data-prefetch]");if(!o||!c(o))return;let d=o.getAttribute("href");if(!d)return;let f=new URL(d,location.origin).href;if(C.has(f))return;let m=a.get(o);m&&clearTimeout(m);let H=setTimeout(()=>{a.delete(o),u(f)},n);a.set(o,H)}function E(s){let o=document.createTreeWalker(s,NodeFilter.SHOW_ELEMENT),d=o.nextNode();for(;d;){let f=d;for(let m of Object.keys(f))m.indexOf("__krate_")===0&&delete f[m];d=o.nextNode()}}let T=null;function me(){let s=h(document),o=document.querySelector("template[data-krate-loading]");o&&o.content&&s&&(T=o.content.cloneNode(!0),document.body.appendChild(T)),s&&(s.style.transition=`opacity ${t}ms ease`,s.style.opacity="0")}function x(){T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let s=h(document);s&&(s.style.opacity="1")}function D(s){try{let o=globalThis.__krate_onNavigation;typeof o=="function"&&o(s)}catch{}}function w(s,o,d,f={}){let{replace:m=!1,scroll:H=!0,restoreScroll:P=!1}=f,j=new DOMParser().parseFromString(s,"text/html"),Me=h(j),U=h(document);if(!Me||!U){location.href=o;return}let Le=j.querySelector("title");Le&&(document.title=Le.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),E(U),ce(U,Me);let xe=j.querySelectorAll('link[rel="stylesheet"]'),Se=new Set;xe.forEach(y=>{let M=y.getAttribute("href");M&&Se.add(M)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(y=>{let M=y.getAttribute("href");M&&!Se.has(M)&&y.remove()});let ke=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(y=>{ke.add(y.href)}),xe.forEach(y=>{let M=y.getAttribute("href");if(M&&!ke.has(M)){let W=document.createElement("link");W.rel="stylesheet",W.href=M,document.head.appendChild(W)}}),Xe(d,o).then(()=>{try{Je(),b()}catch(y){try{let M=globalThis.__krate_onHydrationError;typeof M=="function"&&M(y)}catch{}location.href=o}}),x();let Ze=location.pathname+location.search;if(m)history.replaceState({},"",o);else{if(!P){if(_.size>=Dt){let y=_.keys().next().value;y!==void 0&&_.delete(y)}_.set(Ze,window.scrollY)}history.pushState({},"",o)}pe(o,{restoreScroll:P,scroll:H}),he(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:o}})),D(o)}function We(s){let o=s.indexOf("#");if(o<0||o===s.length-1)return!1;let d=s.slice(o);try{let f=document.querySelector(d);if(f)return f.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function pe(s,o){if(o.restoreScroll){let d=_.get(s);if(d!==void 0){window.scrollTo(0,d);return}}We(s)||o.scroll&&window.scrollTo(0,0)}function he(){let s=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(o=>{let d=o.getAttribute("href");if(!d){o.removeAttribute("aria-current");return}let f=d;try{f=new URL(d,location.origin).pathname}catch{return}f===s||s==="/"&&(f===""||f==="/")||f!=="/"&&f.length>1&&s.startsWith(f)?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")})}function Xe(s,o){return s.length===0?Promise.resolve():Promise.all(s.map(d=>{let f=d.getAttribute("src");return f?Ge(f,o):Promise.resolve()})).then(()=>{})}function Ge(s,o){return new Promise(d=>{let f=document.createElement("script"),m=Te(s,o);f.src=m,ze.test(m)||f.setAttribute("data-krate-spa",""),f.onload=()=>d(),f.onerror=()=>d(),document.body.appendChild(f)})}function Te(s,o){if(/^(https?:)?\/\//.test(s)||s.startsWith("/"))return new URL(s,o).href;let d=o;if(!d.endsWith("/")){let f=d.lastIndexOf("/");d=f>0?d.slice(0,f+1):"/"}return new URL(s,d).href}function Je(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Ye(s,o){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",o),D(o),document.open(),document.write(s),document.close()}function $e(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>(r=s,s)).catch(()=>null)}function Qe(){return i!==null?Promise.resolve(i):fetch("/500.html",{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>(i=s,s)).catch(()=>null)}function ve(s,o){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let d=[],f=new Set;return document.querySelectorAll("script[src]").forEach(m=>{f.add(m.src)}),s.querySelectorAll("script[src]").forEach(m=>{let H=m.getAttribute("src");H&&!f.has(Te(H,o))&&d.push(m)}),d}function Ee(s,o={}){let d=C.get(s);if(d){let H=new DOMParser().parseFromString(d,"text/html");w(d,s,ve(H,s),o);return}me(),I&&I.abort(),I=new AbortController;let f=I.signal;fetch(s,{headers:{Accept:"text/html"},signal:f}).then(m=>m.ok?m.text().then(H=>{let ye=new DOMParser().parseFromString(H,"text/html");w(H,s,ve(ye,s),o)}):(m.status>=500?Qe():$e()).then(P=>{P?Ye(P,s):location.href=s})).catch(m=>{m?.name!=="AbortError"&&(x(),location.href=s)}).finally(()=>{I&&!f.aborted&&(I=void 0)})}let He=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey)return;let o=s.target.closest("a[data-krate-link]");if(!o||!c(o))return;s.preventDefault();let d=o.getAttribute("href");if(!d)return;let f=new URL(d,location.origin).href,m=o.hasAttribute("data-krate-replace"),H=o.getAttribute("data-krate-scroll")!=="false";if(d===location.pathname+location.search+location.hash){m&&history.replaceState({},"",d),pe(f,{scroll:H});return}Ee(f,{replace:m,scroll:H})},Ae=()=>{Ee(location.href,{restoreScroll:!0})};document.addEventListener("click",He),window.addEventListener("popstate",Ae),v(),he(),document.querySelectorAll("script[src]").forEach(s=>{ze.test(s.src)||s.setAttribute("data-krate-spa","")}),F=()=>{document.removeEventListener("click",He),window.removeEventListener("popstate",Ae),g()}}function Bt(){F&&(F(),F=null),de=!1,Fe()}function ge(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)ge(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function fe(...e){let t=[];for(let n of e)ge(n,t);return t.join(" ")}function be(...e){let t=[];for(let i of e)ge(i,t);let n=new Map,r=[];for(let i of t){let a=Vt(i);n.has(a)||r.push(a),n.set(a,i)}return r.map(i=>n.get(i)).join(" ")}function Vt(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let i=t.indexOf("-"),a=i>=0?t.slice(0,i):t,l=i>=0?t.slice(i+1,i+2):"";return n+a+(l&&/[0-9]/.test(l)?"-"+l:"")}function Kt(...e){return be(fe(...e))}function qt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return i=>{let a={};for(let c of Object.keys(n)){let u=i?.[c]??r[c];u!=null&&(a[c]=String(u))}let l=[e];for(let c of Object.keys(n)){let u=a[c];u&&n[c][u]&&l.push(n[c][u])}for(let c of t?.compoundVariants??[])if(zt(c,a,r)){let u=c.class;typeof u=="string"&&l.push(u)}let h=i?.class??i?.className;return typeof h=="string"&&l.push(h),be(fe(l))}}function zt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let i=e[r],a=t[r]??n[r]??void 0;if(Array.isArray(i)){if(!i.includes(a))return!1}else if(i!==a)return!1}return!0}function Ft(e){let t=je(e?.children);return t?(Ue(t,e),t):null}function je(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=je(t);if(n)return n}return null}return e instanceof Node?e:null}function Ue(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let i=e.getAttribute("class"),a=i?i+" "+String(r):String(r);e.setAttribute("class",a);continue}if(n==="style"&&typeof r=="object"){for(let[i,a]of Object.entries(r))e.style.setProperty(jt(i),String(a));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function jt(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Ut(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ue(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return st(Wt);})();
1
+ var __krate_exports=(()=>{var $=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ct=Object.prototype.hasOwnProperty;var dt=(e,t)=>{for(var n in t)$(e,n,{get:t[n],enumerable:!0})},gt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of lt(t))!ct.call(e,s)&&s!==n&&$(e,s,{get:()=>t[s],enumerable:!(r=ut(t,s))||r.enumerable});return e};var ft=e=>gt($({},"__esModule",{value:!0}),e);var rn={};dt(rn,{Fragment:()=>Kt,Slot:()=>en,clearNodes:()=>_e,clearPersisted:()=>ht,cloneElement:()=>nn,clsx:()=>pe,cn:()=>$t,conditional:()=>Ft,createCSSChoice:()=>Et,createCSSFlags:()=>Ht,createCSSGroup:()=>yt,createCSSRange:()=>Mt,createCSSStack:()=>Lt,createCSSToggle:()=>At,createContext:()=>mt,createEffect:()=>S,createMemo:()=>Ct,createReducer:()=>Nt,createResource:()=>Vt,createSignal:()=>A,cva:()=>Qt,disposeAll:()=>vt,disposeNode:()=>L,forwardRef:()=>Rt,h:()=>j,hydrate:()=>Bt,initRouter:()=>We,insert:()=>_t,jsx:()=>Ve,jsxs:()=>qt,mount:()=>Dt,navigate:()=>Gt,onCleanup:()=>F,onMount:()=>kt,readDurableState:()=>ne,readPersisted:()=>re,reconcile:()=>zt,reconcileTrees:()=>jt,reinitRouter:()=>Jt,resetContexts:()=>Q,resolvePersist:()=>te,subscribePersist:()=>se,twMerge:()=>he,useRef:()=>Pt,writePersisted:()=>ie});var bt=0,R=new Map;function Q(){for(let[e,t]of R)if(t.length>0){let n=t[0];R.set(e,[n])}}function mt(e){let t=bt++;return R.set(t,[e]),{id:t,defaultValue:e,Provider:n=>{let r=R.get(t)||[e];r.push(n.value),R.set(t,r);let s=document.createElement("div");if(s.style.display="contents",n.children)for(let a of n.children)a instanceof Node?s.appendChild(a):a!=null&&s.appendChild(document.createTextNode(String(a)));return r.pop(),r.length===0&&r.push(e),s},useContext:()=>{let n=R.get(t);return n&&n.length>0?n[n.length-1]:e}}}function pt(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var Z=pt();function Ne(){return typeof window<"u"}function ee(e){if(e&&typeof e=="object")return e;if(!Ne())return Z;try{return e==="session"?window.sessionStorage:e==="memory"?Z:window.localStorage}catch{return Z}}function te(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function ne(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let s=r[e];if(typeof s=="string")try{return{found:!0,value:t(s)}}catch{return{found:!0,value:s}}return{found:!0,value:s}}function re(e){let t=ee(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function ie(e,t){let n=ee(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function ht(e){let t=ee(e.store);try{t.removeItem(e.key)}catch{}}var K=new Map,Ce=!1;function Tt(){Ce||!Ne()||(Ce=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=K.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function se(e,t){if(!e.sync)return()=>{};let n=K.get(e.key)??new Set;return n.add(t),K.set(e.key,n),Tt(),()=>{n.delete(t),n.size===0&&K.delete(e.key)}}var C=[],Pe=[],oe=!1,O=new Set,ae=[],ue=[],q=!1;function Re(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function le(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function vt(){for(let e of O)le(e);O.clear();for(let e of ae)try{e()}catch{}ae.length=0,ue.length=0,q=!1,Q()}function Et(e,t){return A(e)}function At(e,t){return A(e)}function Ht(e,t){let n={};for(let s of e){let[a]=A(!1);n[s]=a}return[n,(s,a)=>{}]}function yt(e,t){return A(e)}function Mt(e,t){return A(e)}function Lt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function A(e,t){let n=e,r=null;if(t?.persist){r=te(t.persist);let d=ne(r.key,r.deserialize);if(d.found)n=d.value;else{let u=re(r);u.found&&(n=u.value)}}let s=new Set,a=()=>{let d=C[C.length-1];return d&&!d.disposed&&(s.add(d),d.sources.add(s)),n},c=()=>{let d=Array.from(s);for(let u of d){if(u.disposed){s.delete(u);continue}if(u.running){u.rerun=!0;continue}u.queued||(u.queued=!0,ue.push(u))}xt()},v=d=>{let u=typeof d=="function"?d(n):d;u!==n&&(n=u,r&&ie(r,n),c())};if(r&&r.sync){let d=r,u=se(d,E=>{if(E!==null)try{let b=d.deserialize(E);b!==n&&(n=b,c())}catch{}});F(u)}return[a,v]}function xt(){q||(q=!0,queueMicrotask(St))}function St(){q=!1;let e=ue.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,z(t),t.rerun&&!t.disposed&&(t.rerun=!1,z(t)))}function z(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,C.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{C.pop(),e.running=!1}}function S(e){let t=Re(e);return O.add(t),z(t),()=>{le(t),O.delete(t)}}function F(e){let t=C[C.length-1];t?t.cleanups.push(e):ae.push(e)}function kt(e){Pe.push(e),oe||(oe=!0,queueMicrotask(wt))}function wt(){oe=!1;let e=Pe.splice(0);for(let t of e)t()}function Ct(e){let[t,n]=A(void 0),r=Re(()=>{let a=e();n(a)});O.add(r),z(r);let s=C[C.length-1];return s&&s.cleanups.push(()=>{r.disposed||(le(r),O.delete(r))}),t}function Nt(e,t){let[n,r]=A(t);return[n,a=>r(c=>e(c,a))]}function Pt(e){return{current:e}}function Rt(e){return t=>e(t,t.ref||(()=>{}))}var Ot={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},ce=new WeakMap;function Ie(e,t){let n=ce.get(e);n||(n=[],ce.set(e,n)),n.push(t)}function L(e){let t=ce.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)L(e.childNodes[n])}function It(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function _e(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;L(r),n.removeChild(r),r=s}}function _t(e,t,n){let r=It(n);r?(_e(n,r),de(e,t,r)):de(e,t,null)}function de(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)de(e,r,n)}}function Oe(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),s=Ot[r]||r,a=`__krate_${s}`,c=e[a];c&&e.removeEventListener(s,c),e.addEventListener(s,n),e[a]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function De(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)De(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ie(n,S(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function j(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,a]of Object.entries(t))typeof a=="function"&&!s.startsWith("on")?Ie(r,S(()=>Oe(r,s,a()))):Oe(r,s,a);for(let s of n)De(r,s);return r}function Be(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Dt(e,t){let n=Be(t),r=!1;S(()=>{r||(r=!0,n.appendChild(e()))})}function Bt(e,t){let n=Be(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&L(r)}function Vt(e,t){let[n,r]=A(void 0),[s,a]=A(!0),[c,v]=A(void 0),[d,u]=A("unresolved"),[E,b]=A(0),g,h=()=>typeof e=="function"?e():e,T=async()=>{g&&g.abort(),g=new AbortController;let x=g,B=h();u(E()>0?"refreshing":"loading"),a(!0),v(void 0);try{let k=await t(B,{signal:x.signal});x.signal.aborted||(r(()=>k),u("ready"))}catch(k){k?.name!=="AbortError"&&!x.signal.aborted&&(v(k),u("error"))}finally{x.signal.aborted||a(!1)}};S(()=>{typeof e=="function"&&e.length===0&&e(),E(),T(),F(()=>{g&&(g.abort(),g=void 0)})});let H=function(){return n()};return Object.defineProperties(H,{loading:{get:()=>s()},error:{get:()=>c()},state:{get:()=>d()}}),[H,{mutate:x=>{r(x)},refetch:()=>{b(x=>x+1)}}]}function Kt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let s of r)s instanceof Node?t.appendChild(s):t.appendChild(document.createTextNode(String(s)))}return t}function Ve(e,t,n){let r=e;if(!t)return j(r,null);let{children:s,...a}=t,c=s!==void 0?Array.isArray(s)?s:[s]:[];return j(r,Object.keys(a).length>0?a:null,...c)}function qt(e,t,n){return Ve(e,t,n)}function zt(e,t,n,r,s,a){let c=[],v=t.nextSibling;for(;v&&v!==n;)c.push(v),v=v.nextSibling;if(a){let d=new Map;for(let b of c){let g=b.__k;g!=null&&d.set(g,b)}let u=[],E=new Set;for(let b=0;b<r.length;b++){let g=r[b],h=a(g);E.add(h);let T=s(g,b);T.__k=h,u.push(T)}for(let[b,g]of d)!E.has(b)&&g.parentNode===e&&(L(g),e.removeChild(g));for(let b=0;b<u.length;b++){let g=u[b],h=b===0?t:u[b-1];g!==h.nextSibling&&e.insertBefore(g,h.nextSibling)}}else{let d=Math.max(c.length,r.length);for(let u=0;u<d;u++)if(u<r.length){let E=s(r[u],u);u<c.length?c[u]!==E&&(L(c[u]),e.replaceChild(E,c[u])):e.insertBefore(E,n)}else u<c.length&&c[u].parentNode===e&&(L(c[u]),e.removeChild(c[u]))}}function Ft(e,t,n,r,s,a){let c=null;S(()=>{let d=r()?s():a?a():null;c?d?(L(c),e.replaceChild(d,c)):(L(c),e.removeChild(c)):d&&e.insertBefore(d,n),c=d})}function I(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Ke(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,a=t.attributes[r].value;n.add(s),e.getAttribute(s)!==a&&e.setAttribute(s,a)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function ge(e,t){let n=document.importNode(t,!0);return e.parentNode&&(L(e),e.parentNode.replaceChild(n,e)),n}function qe(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function fe(e,t){if(!qe(e,t))return ge(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?ge(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return I(n)!==I(r)?ge(n,r):(Ke(n,r),ze(n,r),n)}function ze(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let b=!0;for(let g=0;g<r.length;g++)if(I(n[g])!==I(r[g])){b=!1;break}if(b){for(let g=0;g<r.length;g++)fe(n[g],r[g]);return}}let s=new Map,a=[];n.forEach((b,g)=>{let h=I(b);h!=null?s.has(h)||s.set(h,g):a.push(g)});let c=new Set,v=0,d=null,u=0,E=()=>{for(;u<a.length&&c.has(a[u]);)u++;return u<a.length?a[u]:-1};for(let b of r){let g=I(b),h;if(g!=null&&s.has(g)){let T=s.get(g);s.delete(g),c.add(T);let H=n[T];T<v?e.insertBefore(H,d):v=T,h=fe(H,b)}else if(g==null){let T=E();if(T>=0&&qe(n[T],b)){c.add(T);let H=n[T];H.parentNode===e&&H.nextSibling!==d&&e.insertBefore(H,d),h=fe(H,b)}else h=document.importNode(b,!0),e.insertBefore(h,d)}else h=document.importNode(b,!0),e.insertBefore(h,d);d=h.nextSibling}n.forEach((b,g)=>{!c.has(g)&&b.parentNode===e&&(L(b),e.removeChild(b))})}function jt(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}Ke(n,r),ze(n,r)}var be=!1,_,W=null,U=0,N=new Map,Ut=30,D=new Map,Wt=50,Fe=/\/chunks\/runtime\.[^/]+\.js$/;function Ue(){return globalThis.__KRATE_CFG__||{}}function Xt(){let e=Ue().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function je(e){let t=Xt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var X=null;function Gt(e,t={}){return X?(X(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function We(){if(typeof document>"u"||be)return;be=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,s=null,a=new Map,c=null;function v(i){for(let o of e.split(", ")){let l=i.querySelector(o.trim());if(l)return l}return i.body}function d(i){if(i.hasAttribute("data-krate-external"))return!1;let o=i.getAttribute("href");return!(!o||o.startsWith("#")||o.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function u(i){N.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>{if(o){if(N.size>=Ut){let l=N.keys().next().value;l!==void 0&&N.delete(l)}N.set(i,o)}}).catch(()=>{})}function E(){document.addEventListener("mouseover",h),document.addEventListener("focusin",h),typeof IntersectionObserver<"u"&&(c=new IntersectionObserver(i=>{for(let o of i)if(o.isIntersecting){let l=o.target,f=l.getAttribute("href");if(f&&d(l)){let m=new URL(f,location.origin).href;u(m)}c.unobserve(o.target)}},{rootMargin:"200px"}),b())}function b(){c&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{c.observe(i)})}function g(){document.removeEventListener("mouseover",h),document.removeEventListener("focusin",h);for(let i of a.values())clearTimeout(i);a.clear(),c&&(c.disconnect(),c=null)}function h(i){let o=i.target.closest("a[data-prefetch]");if(!o||!d(o))return;let l=o.getAttribute("href");if(!l)return;let f=new URL(l,location.origin).href;if(N.has(f))return;let m=a.get(o);m&&clearTimeout(m);let p=setTimeout(()=>{a.delete(o),u(f)},n);a.set(o,p)}let T=null;function H(){if(k())return;let i=v(document),o=document.querySelector("template[data-krate-loading]");o&&o.content&&i&&(T=o.content.cloneNode(!0),document.body.appendChild(T)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function G(){if(k())return;T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let i=v(document);i&&(i.style.opacity="1")}function x(i){try{let o=globalThis.__krate_onNavigation;typeof o=="function"&&o(i)}catch{}}function B(i,o){try{window.dispatchEvent(new CustomEvent(i,{detail:{url:o}}))}catch{}}function k(){if(Ue().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function Je(i){let o=i.querySelectorAll('link[rel="stylesheet"]'),l=new Set;o.forEach(m=>{let p=m.getAttribute("href");p&&l.add(new URL(p,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>{let p=m.href;p&&!l.has(p)&&m.remove()});let f=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>f.add(m.href)),o.forEach(m=>{let p=m.getAttribute("href");if(!p)return;let y=new URL(p,location.origin).href;if(!f.has(y)){let w=document.createElement("link");w.rel="stylesheet",w.href=y,document.head.appendChild(w)}})}function Te(i){i.querySelectorAll("[data-view-transition]").forEach(o=>{let l=o.getAttribute("data-view-transition");l&&(o.style.viewTransitionName=l)})}function Ye(){let i=v(document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1");try{i.focus({preventScroll:!0})}catch{try{i.focus()}catch{}}}}function $e(){let i=HTMLScriptElement.supports;if(!(typeof i!="function"||!i("speculationrules")))try{let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(o)}catch{}}function ve(i){return i.getElementById("root")||i.body}let Ee='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Qe(i){document.head.querySelectorAll(Ee).forEach(o=>o.remove()),i.head.querySelectorAll(Ee).forEach(o=>{document.head.appendChild(document.importNode(o,!0))})}function Ae(i,o,l,f={}){let{replace:m=!1,scroll:p=!0,restoreScroll:y=!1}=f,P=new DOMParser().parseFromString(i,"text/html"),ke=ve(P),we=ve(document);if(!ke||!we){location.href=o;return}B("krate:navigate-start",o);let Y=()=>{let M=P.querySelector("title");M&&(document.title=M.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let V=Array.from(ke.childNodes).map(at=>document.importNode(at,!0));we.replaceChildren(...V),Je(P),Qe(P),Te(document)};if(k())try{let M=document.startViewTransition(Y);M&&M.finished&&typeof M.finished.catch=="function"&&M.finished.catch(()=>{})}catch{Y()}else Y();et(l,o).then(()=>{try{nt(),b()}catch(M){try{let V=globalThis.__krate_onHydrationError;typeof V=="function"&&V(M)}catch{}location.href=o}}),G();let ot=location.pathname+location.search;if(m)history.replaceState({},"",o);else{if(!y){if(D.size>=Wt){let M=D.keys().next().value;M!==void 0&&D.delete(M)}D.set(ot,window.scrollY)}history.pushState({},"",o)}He(o,{restoreScroll:y,scroll:p}),y||Ye(),ye(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:o}})),B("krate:navigate-end",o),x(o)}function Ze(i){let o=i.indexOf("#");if(o<0||o===i.length-1)return!1;let l=i.slice(o);try{let f=document.querySelector(l);if(f)return f.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function He(i,o){if(o.restoreScroll){let l=D.get(i);if(l!==void 0){window.scrollTo(0,l);return}}Ze(i)||o.scroll&&window.scrollTo(0,0)}function ye(){let i=je(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(o=>{let l=o.getAttribute("href");if(!l){o.removeAttribute("aria-current");return}let f=l;try{f=je(new URL(l,location.origin).pathname)}catch{return}f===i||i==="/"&&(f===""||f==="/")||f!=="/"&&f.length>1&&i.startsWith(f)?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")})}function et(i,o){return i.length===0?Promise.resolve():Promise.all(i.map(l=>{let f=l.getAttribute("src");return f?tt(f,o):Promise.resolve()})).then(()=>{})}function tt(i,o){return new Promise(l=>{let f=document.createElement("script"),m=Me(i,o);f.src=m,Fe.test(m)||f.setAttribute("data-krate-spa",""),f.onload=()=>l(),f.onerror=()=>l(),document.body.appendChild(f)})}function Me(i,o){if(/^(https?:)?\/\//.test(i)||i.startsWith("/"))return new URL(i,o).href;let l=o;if(!l.endsWith("/")){let f=l.lastIndexOf("/");l=f>0?l.slice(0,f+1):"/"}return new URL(i,l).href}function nt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function rt(i,o){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",o),x(o),document.open(),document.write(i),document.close()}function it(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(r=i,i)).catch(()=>null)}function st(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(s=i,i)).catch(()=>null)}function Le(i,o){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let l=[],f=new Set;return document.querySelectorAll("script[src]").forEach(m=>{f.add(m.src)}),i.querySelectorAll("script[src]").forEach(m=>{let p=m.getAttribute("src");p&&!f.has(Me(p,o))&&l.push(m)}),l}function J(i,o={}){let l=++U,f=N.get(i);if(f){let y=new DOMParser().parseFromString(f,"text/html");Ae(f,i,Le(y,i),o);return}H(),_&&_.abort(),_=new AbortController;let m=_.signal;fetch(i,{headers:{Accept:"text/html"},signal:m}).then(p=>{if(l===U)return p.ok?p.text().then(y=>{if(l!==U)return;let P=new DOMParser().parseFromString(y,"text/html");Ae(y,i,Le(P,i),o)}):(p.status>=500?st():it()).then(w=>{l===U&&(w?rt(w,i):location.href=i)})}).catch(p=>{p?.name!=="AbortError"&&(G(),location.href=i)}).finally(()=>{_&&!m.aborted&&(_=void 0)})}let xe=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let o=i.target.closest("a[data-krate-link]");if(!o||!d(o))return;i.preventDefault();let l=o.getAttribute("href");if(!l)return;let f=new URL(l,location.origin).href,m=o.hasAttribute("data-krate-replace"),p=o.getAttribute("data-krate-scroll")!=="false";if(l===location.pathname+location.search+location.hash){m&&history.replaceState({},"",l),He(f,{scroll:p});return}J(f,{replace:m,scroll:p})},Se=()=>{J(location.href,{restoreScroll:!0})};document.addEventListener("click",xe),window.addEventListener("popstate",Se),E(),$e(),ye(),Te(document),X=(i,o={})=>{let l=!0;try{l=new URL(i,location.href).origin===location.origin}catch{l=!1}if(!l){location.href=i;return}J(new URL(i,location.href).href,o)},document.querySelectorAll("script[src]").forEach(i=>{Fe.test(i.src)||i.setAttribute("data-krate-spa","")}),W=()=>{document.removeEventListener("click",xe),window.removeEventListener("popstate",Se),g(),X=null}}function Jt(){W&&(W(),W=null),be=!1,We()}function me(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)me(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function pe(...e){let t=[];for(let n of e)me(n,t);return t.join(" ")}function he(...e){let t=[];for(let s of e)me(s,t);let n=new Map,r=[];for(let s of t){let a=Yt(s);n.has(a)||r.push(a),n.set(a,s)}return r.map(s=>n.get(s)).join(" ")}function Yt(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),a=s>=0?t.slice(0,s):t,c=s>=0?t.slice(s+1,s+2):"";return n+a+(c&&/[0-9]/.test(c)?"-"+c:"")}function $t(...e){return he(pe(...e))}function Qt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let a={};for(let d of Object.keys(n)){let u=s?.[d]??r[d];u!=null&&(a[d]=String(u))}let c=[e];for(let d of Object.keys(n)){let u=a[d];u&&n[d][u]&&c.push(n[d][u])}for(let d of t?.compoundVariants??[])if(Zt(d,a,r)){let u=d.class;typeof u=="string"&&c.push(u)}let v=s?.class??s?.className;return typeof v=="string"&&c.push(v),he(pe(c))}}function Zt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],a=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(a))return!1}else if(s!==a)return!1}return!0}function en(e){let t=Xe(e?.children);return t?(Ge(t,e),t):null}function Xe(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Xe(t);if(n)return n}return null}return e instanceof Node?e:null}function Ge(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let s=e.getAttribute("class"),a=s?s+" "+String(r):String(r);e.setAttribute("class",a);continue}if(n==="style"&&typeof r=="object"){for(let[s,a]of Object.entries(r))e.style.setProperty(tn(s),String(a));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function tn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function nn(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ge(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return ft(rn);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
package/dist/router.d.ts CHANGED
@@ -1,3 +1,15 @@
1
+ export interface NavigateOptions {
2
+ replace?: boolean;
3
+ scroll?: boolean;
4
+ /** State stored on the new history entry. */
5
+ state?: unknown;
6
+ }
7
+ /**
8
+ * Programmatic SPA navigation. Falls back to a full page load when the router
9
+ * has not initialized (e.g. before hydration). Returns false when handled
10
+ * client-side, true when a full navigation was triggered.
11
+ */
12
+ export declare function navigate(url: string, opts?: NavigateOptions): boolean;
1
13
  export declare function initRouter(): void;
2
14
  /** Dispose old effects, re-register router listeners for new page. */
3
15
  export declare function reinitRouter(): void;