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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,490 @@
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
+ var B64_VLQ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
29
+ function decodeVLQ(str) {
30
+ const out = [];
31
+ let shift = 0;
32
+ let value = 0;
33
+ for (let i = 0; i < str.length; i++) {
34
+ const digit = B64_VLQ.indexOf(str[i]);
35
+ if (digit === -1) continue;
36
+ const cont = (digit & 32) !== 0;
37
+ value += (digit & 31) << shift;
38
+ if (cont) {
39
+ shift += 5;
40
+ continue;
41
+ }
42
+ const neg = (value & 1) === 1;
43
+ value >>= 1;
44
+ out.push(neg ? -value : value);
45
+ value = 0;
46
+ shift = 0;
47
+ }
48
+ return out;
49
+ }
50
+ function decodeMappings(mappings) {
51
+ const lines = [];
52
+ let src = 0;
53
+ let srcLine = 0;
54
+ let srcCol = 0;
55
+ for (const line of mappings.split(";")) {
56
+ const segs = [];
57
+ let genCol = 0;
58
+ if (line) {
59
+ for (const part of line.split(",")) {
60
+ if (!part) continue;
61
+ const nums = decodeVLQ(part);
62
+ genCol += nums[0] || 0;
63
+ if (nums.length >= 4) {
64
+ src += nums[1];
65
+ srcLine += nums[2];
66
+ srcCol += nums[3];
67
+ segs.push({ genCol, src, srcLine, srcCol });
68
+ }
69
+ }
70
+ }
71
+ lines.push(segs);
72
+ }
73
+ return lines;
74
+ }
75
+ var mapCache = /* @__PURE__ */ new Map();
76
+ async function loadSourceMap(url) {
77
+ const cached = mapCache.get(url);
78
+ if (cached) return cached;
79
+ const p = (async () => {
80
+ try {
81
+ if (/^[a-z]+:\/\//i.test(url) && !url.startsWith(location.origin)) return null;
82
+ const res = await fetch(url + ".map");
83
+ if (!res.ok) return null;
84
+ const json = await res.json();
85
+ if (!json || typeof json.mappings !== "string") return null;
86
+ return { sources: json.sources || [], lines: decodeMappings(json.mappings) };
87
+ } catch {
88
+ return null;
89
+ }
90
+ })();
91
+ mapCache.set(url, p);
92
+ return p;
93
+ }
94
+ function parseStackFrame(line) {
95
+ const patterns = [
96
+ /^(.*?)((?:https?:)?\/\/[^\s)]+|\/[^\s):]+):(\d+):(\d+)(.*)$/
97
+ ];
98
+ for (const re of patterns) {
99
+ const m = re.exec(line);
100
+ if (!m) continue;
101
+ return { prefix: m[1], url: m[2], line: Number(m[3]), col: Number(m[4]), suffix: m[5] };
102
+ }
103
+ return null;
104
+ }
105
+ function remapLocation(map, line, col) {
106
+ const segs = map.lines[line - 1];
107
+ if (!segs || segs.length === 0) return null;
108
+ let best = null;
109
+ for (const s of segs) {
110
+ if (s.genCol <= col - 1) best = s;
111
+ else break;
112
+ }
113
+ if (!best) best = segs[0];
114
+ const source = map.sources[best.src] || "";
115
+ return { source, line: best.srcLine + 1, col: best.srcCol + 1 };
116
+ }
117
+ async function symbolicateStack(stack) {
118
+ if (!stack || stack.indexOf(".js") === -1) return stack;
119
+ const lines = stack.split("\n");
120
+ const out = await Promise.all(
121
+ lines.map(async (line) => {
122
+ const frame = parseStackFrame(line);
123
+ if (!frame) return line;
124
+ const map = await loadSourceMap(frame.url);
125
+ if (!map) return line;
126
+ const loc = remapLocation(map, frame.line, frame.col);
127
+ if (!loc) return line;
128
+ return frame.prefix + loc.source + ":" + loc.line + ":" + loc.col + frame.suffix;
129
+ })
130
+ );
131
+ return out.join("\n");
132
+ }
133
+ function routeMatches(pattern, pathname, basePath = "") {
134
+ const a = norm(stripBase(pathname, basePath)).split("/");
135
+ const b = norm(pattern).split("/");
136
+ for (let i = 0; i < b.length; i++) {
137
+ const s = b[i];
138
+ if (s.charAt(0) === "[") {
139
+ if (s.indexOf("[...") === 0) return true;
140
+ continue;
141
+ }
142
+ if (s !== a[i]) return false;
143
+ }
144
+ return a.length === b.length;
145
+ }
146
+ 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>';
147
+ 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>';
148
+ var STYLE = `
149
+ :host { all: initial; }
150
+ * { box-sizing: border-box; }
151
+
152
+ /* palette */
153
+ :host {
154
+ --red: #f87171;
155
+ --green: #34d399;
156
+ --bg: #111114;
157
+ --bg-2: #17171c;
158
+ --line: #2a2a31;
159
+ --fg: #e5e7eb;
160
+ --muted: #9ca3af;
161
+ }
162
+
163
+ /* toolbar */
164
+ .toolbar {
165
+ position: fixed; left: 50%; bottom: 0; z-index: 2147483001;
166
+ transform: translate(-50%, 54%);
167
+ transition: transform .28s cubic-bezier(.22,.61,.36,1),
168
+ border-top-color .35s ease;
169
+ display: flex; align-items: stretch; gap: 2px;
170
+ background: var(--bg);
171
+ border: 1px solid var(--line);
172
+ border-top: 3px solid var(--green);
173
+ border-radius: 16px 16px 0 0;
174
+ padding: 7px 8px 9px;
175
+ box-shadow: 0 -10px 30px rgba(0,0,0,.45);
176
+ font: 12px/1.3 ui-sans-serif, system-ui, -apple-system, sans-serif;
177
+ color: var(--fg);
178
+ }
179
+ .toolbar:hover, .toolbar:focus-within { transform: translate(-50%, 0); }
180
+ .toolbar.bad { border-top-color: var(--red); }
181
+
182
+ .tb-btn {
183
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
184
+ gap: 3px; min-width: 56px; padding: 5px 10px;
185
+ background: transparent; border: 1px solid transparent; border-radius: 11px;
186
+ color: var(--muted); cursor: pointer; font: inherit;
187
+ transition: color .15s ease, background .15s ease;
188
+ }
189
+ .tb-btn:hover { color: var(--fg); background: rgba(255,255,255,.06); }
190
+ .tb-btn .ic { display: block; width: 18px; height: 18px; }
191
+ .tb-btn .tb-label { font-size: 10px; letter-spacing: .02em; }
192
+ .toolbar.bad .tb-btn.errors { color: var(--red); }
193
+
194
+ .tb-center {
195
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
196
+ gap: 1px; min-width: 130px; padding: 2px 16px;
197
+ }
198
+ .tb-center .brand { font-size: 12px; font-weight: 700; letter-spacing: .05em; color: #f3f4f6; }
199
+ .tb-center .route {
200
+ font-size: 10px; color: var(--muted);
201
+ max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
202
+ }
203
+
204
+ /* overlay */
205
+ .overlay {
206
+ position: fixed; inset: 0; z-index: 2147483000;
207
+ background: rgba(9, 9, 11, 0.72); backdrop-filter: blur(6px);
208
+ display: flex; align-items: flex-start; justify-content: center;
209
+ padding: 4vh 16px; overflow: auto;
210
+ font: 13px/1.5 "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
211
+ color: var(--fg);
212
+ }
213
+ .overlay[hidden] { display: none; }
214
+ .card {
215
+ width: min(920px, 100%); background: var(--bg);
216
+ border: 1px solid var(--line);
217
+ border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,0.5); overflow: hidden;
218
+ }
219
+ .card-head {
220
+ display: flex; align-items: center; gap: 10px; padding: 14px 18px;
221
+ border-bottom: 1px solid var(--line); background: var(--bg-2);
222
+ }
223
+ .title { font-weight: 600; font-size: 14px; color: var(--red); }
224
+ .count { color: var(--muted); font-size: 12px; }
225
+ .spacer { flex: 1; }
226
+ .btn {
227
+ border: 1px solid var(--line); background: transparent; color: var(--muted);
228
+ border-radius: 9px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 12px;
229
+ transition: color .15s ease, background .15s ease, border-color .15s ease;
230
+ }
231
+ .btn:hover { color: var(--fg); background: rgba(255,255,255,.06); border-color: #44444f; }
232
+ .list { padding: 6px 0; }
233
+ .diag { padding: 14px 18px; border-bottom: 1px solid #1f1f26; }
234
+ .diag:last-child { border-bottom: none; }
235
+ .actions { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
236
+ .loc {
237
+ display: inline-flex; align-items: center; gap: 6px; color: #60a5fa;
238
+ background: transparent; border: none; padding: 0; cursor: pointer;
239
+ font: inherit; font-size: 12px;
240
+ }
241
+ .loc:hover { text-decoration: underline; }
242
+ .msg { color: #f3f4f6; white-space: pre-wrap; word-break: break-word; }
243
+ .frame {
244
+ margin-top: 10px; background: #0b0b0e; border: 1px solid #26262e;
245
+ border-radius: 7px; padding: 8px 10px; overflow-x: auto; white-space: pre;
246
+ }
247
+ .frame .src { color: #cbd5e1; }
248
+ .frame .caret { color: var(--red); }
249
+ .hint { margin-top: 8px; color: #a3e635; }
250
+ .stack {
251
+ margin-top: 10px; color: var(--muted); white-space: pre-wrap; word-break: break-word;
252
+ max-height: 320px; overflow: auto;
253
+ }
254
+ `;
255
+ var KrateDev = class {
256
+ constructor() {
257
+ this.cfg = devConfig();
258
+ this.buildDiags = [];
259
+ this.runtimeErrors = [];
260
+ this.seen = /* @__PURE__ */ new Set();
261
+ }
262
+ init() {
263
+ const host = document.createElement("div");
264
+ host.id = "krate-dev-root";
265
+ (document.body || document.documentElement).appendChild(host);
266
+ this.shadow = host.attachShadow({ mode: "open" });
267
+ const style = document.createElement("style");
268
+ style.textContent = STYLE;
269
+ this.shadow.appendChild(style);
270
+ this.overlay = document.createElement("div");
271
+ this.overlay.className = "overlay";
272
+ this.overlay.hidden = true;
273
+ 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>';
274
+ this.shadow.appendChild(this.overlay);
275
+ this.title = this.overlay.querySelector(".title");
276
+ this.list = this.overlay.querySelector(".list");
277
+ if (this.cfg.toolbar) {
278
+ this.toolbar = document.createElement("div");
279
+ this.toolbar.className = "toolbar";
280
+ 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>';
281
+ this.shadow.appendChild(this.toolbar);
282
+ this.routeEl = this.toolbar.querySelector(".route");
283
+ this.routeEl.textContent = location.pathname;
284
+ this.watchLocation();
285
+ }
286
+ this.shadow.addEventListener("click", (e) => this.onClick(e));
287
+ document.addEventListener("keydown", (e) => {
288
+ if (e.key === "Escape") this.hide();
289
+ });
290
+ this.connectSSE();
291
+ this.captureRuntimeErrors();
292
+ }
293
+ onClick(e) {
294
+ const t = e.target.closest(".btn, .loc, .tb-btn");
295
+ if (!t) return;
296
+ if (t.classList.contains("tb-btn")) t.blur();
297
+ if (t.classList.contains("close")) {
298
+ this.hide();
299
+ return;
300
+ }
301
+ if (t.classList.contains("errors") || t.classList.contains("toggle")) {
302
+ if (this.overlay.hidden) this.show();
303
+ else this.hide();
304
+ return;
305
+ }
306
+ if (t.classList.contains("reload")) {
307
+ location.reload();
308
+ return;
309
+ }
310
+ if (t.classList.contains("loc") || t.classList.contains("open")) {
311
+ this.openInEditor(t.getAttribute("data-file") || "", t.getAttribute("data-line") || "");
312
+ }
313
+ }
314
+ openInEditor(file, line) {
315
+ if (!file) return;
316
+ const url = this.cfg.open + "?file=" + encodeURIComponent(file) + "&line=" + encodeURIComponent(line);
317
+ fetch(url).catch(() => {
318
+ });
319
+ }
320
+ /** Keep the toolbar route label in sync with SPA (history) navigation. */
321
+ watchLocation() {
322
+ const update = () => {
323
+ if (this.routeEl) this.routeEl.textContent = location.pathname;
324
+ };
325
+ window.addEventListener("popstate", update);
326
+ const h = history;
327
+ const push = h.pushState.bind(history);
328
+ h.pushState = function(...args) {
329
+ const r = push(...args);
330
+ update();
331
+ return r;
332
+ };
333
+ const replace = h.replaceState.bind(history);
334
+ h.replaceState = function(...args) {
335
+ const r = replace(...args);
336
+ update();
337
+ return r;
338
+ };
339
+ setInterval(update, 500);
340
+ }
341
+ connectSSE() {
342
+ let sse;
343
+ try {
344
+ sse = new EventSource(this.cfg.sse);
345
+ } catch {
346
+ return;
347
+ }
348
+ sse.addEventListener("reload", (e) => {
349
+ try {
350
+ const d = JSON.parse(e.data);
351
+ if (d.pages && Array.isArray(d.pages) && !d.pages.some((p) => routeMatches(p, location.pathname, this.cfg.basePath))) {
352
+ return;
353
+ }
354
+ } catch {
355
+ }
356
+ location.reload();
357
+ });
358
+ sse.addEventListener("build-error", (e) => {
359
+ try {
360
+ const d = JSON.parse(e.data);
361
+ this.buildDiags = Array.isArray(d.diagnostics) ? d.diagnostics : [];
362
+ } catch {
363
+ this.buildDiags = [];
364
+ }
365
+ this.setStatus(this.buildDiags.length === 0);
366
+ this.render();
367
+ });
368
+ sse.addEventListener("client-error", (e) => {
369
+ try {
370
+ const d = JSON.parse(e.data);
371
+ if (!d.clientError) return;
372
+ const err = d.clientError;
373
+ this.addRuntime("Runtime Error", err.message, err.stack);
374
+ } catch {
375
+ }
376
+ });
377
+ }
378
+ captureRuntimeErrors() {
379
+ window.addEventListener("error", (e) => {
380
+ const stack = e.error?.stack || "";
381
+ const message = e.message || "Unknown error";
382
+ this.report({
383
+ message,
384
+ stack,
385
+ url: e.filename,
386
+ line: e.lineno,
387
+ col: e.colno,
388
+ kind: "error"
389
+ });
390
+ this.addRuntime("Runtime Error", message, stack);
391
+ });
392
+ window.addEventListener("unhandledrejection", (e) => {
393
+ const reason = e.reason;
394
+ const message = reason instanceof Error ? reason.message : String(reason);
395
+ const stack = reason instanceof Error ? reason.stack : "";
396
+ this.report({ message, stack, url: location.href, kind: "unhandledrejection" });
397
+ this.addRuntime("Unhandled Promise Rejection", message, stack);
398
+ });
399
+ }
400
+ report(payload) {
401
+ const key = payload.message + "|" + (payload.stack || "");
402
+ if (this.seen.has(key)) return;
403
+ this.seen.add(key);
404
+ try {
405
+ const body = JSON.stringify(payload);
406
+ if (navigator.sendBeacon) {
407
+ navigator.sendBeacon(this.cfg.errors, new Blob([body], { type: "application/json" }));
408
+ } else {
409
+ fetch(this.cfg.errors, { method: "POST", body, headers: { "Content-Type": "application/json" }, keepalive: true });
410
+ }
411
+ } catch {
412
+ }
413
+ }
414
+ addRuntime(title, message, stack) {
415
+ const entry = { title, message, stack };
416
+ this.runtimeErrors.push(entry);
417
+ this.setStatus(false);
418
+ this.render();
419
+ if (stack) {
420
+ void symbolicateStack(stack).then((mapped) => {
421
+ if (mapped && mapped !== stack) {
422
+ entry.stack = mapped;
423
+ this.render();
424
+ }
425
+ });
426
+ }
427
+ }
428
+ setStatus(ok) {
429
+ if (!this.toolbar) return;
430
+ this.toolbar.classList.toggle("bad", !ok);
431
+ }
432
+ frameHTML(d) {
433
+ if (!d.source) return "";
434
+ const col = Math.max(1, d.col || 1);
435
+ const caret = " ".repeat(col - 1) + "^";
436
+ return '<div class="frame"><span class="src">' + esc(d.source) + '</span>\n<span class="caret">' + esc(caret) + "</span></div>";
437
+ }
438
+ diagHTML(d) {
439
+ let actions = "";
440
+ if (d.file) {
441
+ const loc = d.file + (d.line ? ":" + d.line + (d.col ? ":" + d.col : "") : "");
442
+ 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>';
443
+ }
444
+ const hint = d.hint ? '<div class="hint">hint: ' + esc(d.hint) + "</div>" : "";
445
+ return '<div class="diag">' + actions + '<div class="msg">' + esc(d.message) + "</div>" + this.frameHTML(d) + hint + "</div>";
446
+ }
447
+ runtimeHTML(r) {
448
+ const stack = r.stack ? '<div class="stack">' + esc(r.stack) + "</div>" : "";
449
+ return '<div class="diag"><div class="msg">' + esc(r.message) + "</div>" + stack + "</div>";
450
+ }
451
+ render() {
452
+ const total = this.buildDiags.length + this.runtimeErrors.length;
453
+ if (total === 0) {
454
+ this.hide();
455
+ return;
456
+ }
457
+ this.title.textContent = this.buildDiags.length > 0 ? "Compilation failed" : "Runtime error";
458
+ let html = "";
459
+ for (const d of this.buildDiags) html += this.diagHTML(d);
460
+ for (const r of this.runtimeErrors) html += this.runtimeHTML(r);
461
+ this.list.innerHTML = html;
462
+ this.overlay.querySelector(".count").textContent = total > 1 ? String(total) : "";
463
+ if (this.cfg.overlay) this.overlay.hidden = false;
464
+ }
465
+ show() {
466
+ if (this.buildDiags.length + this.runtimeErrors.length > 0) this.overlay.hidden = false;
467
+ }
468
+ hide() {
469
+ this.overlay.hidden = true;
470
+ }
471
+ };
472
+ function initDevOverlay() {
473
+ if (typeof window === "undefined" || typeof document === "undefined") return;
474
+ if (window.__krate_dev_overlay) return;
475
+ window.__krate_dev_overlay = true;
476
+ try {
477
+ new KrateDev().init();
478
+ } catch (err) {
479
+ console.error("[krate] dev overlay failed to initialise", err);
480
+ }
481
+ }
482
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
483
+ if (document.readyState === "loading") {
484
+ document.addEventListener("DOMContentLoaded", initDevOverlay, { once: true });
485
+ } else {
486
+ initDevOverlay();
487
+ }
488
+ }
489
+ })();
490
+ 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 G=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lt(t))!ut.call(e,i)&&i!==n&&G(e,i,{get:()=>t[i],enumerable:!(r=at(t,i))||r.enumerable});return e};var pt=e=>dt(G({},"__esModule",{value:!0}),e);var rn={};ft(rn,{Slot:()=>en,clearNodes:()=>Ie,clearPersisted:()=>St,cloneElement:()=>nn,clsx:()=>ye,cn:()=>Gt,conditional:()=>zt,createCSSChoice:()=>bt,createCSSFlags:()=>Et,createCSSGroup:()=>wt,createCSSRange:()=>kt,createCSSStack:()=>Ct,createCSSToggle:()=>xt,createContext:()=>Z,createEffect:()=>N,createMemo:()=>Pt,createReducer:()=>Mt,createResource:()=>Dt,createScope:()=>ht,createScopeFlags:()=>mt,createSignal:()=>b,cva:()=>Qt,disposeAll:()=>vt,disposeNode:()=>k,forwardRef:()=>Ot,h:()=>Vt,hydrate:()=>jt,initRouter:()=>We,insert:()=>It,mount:()=>qt,navigate:()=>Yt,onCleanup:()=>U,onMount:()=>Rt,readDurableState:()=>re,readPersisted:()=>oe,reconcile:()=>Ft,reconcileTrees:()=>Ut,reinitRouter:()=>Jt,resetContexts:()=>Q,resolvePersist:()=>ne,subscribePersist:()=>se,twMerge:()=>Se,useRef:()=>_t,writePersisted:()=>ie});var gt=0,_=new Map;function Q(){for(let[e,t]of _)if(t.length>0){let n=t[0];_.set(e,[n])}}function ht(){return Z({})}function mt(){return Z({})}function Z(e){let t=gt++;_.set(t,[e]);let n=()=>{let r=_.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let i=_.get(t)||[e];i.push(r.value),_.set(t,i);let c=document.createElement("div");if(c.style.display="contents",r.children)for(let a of r.children)a instanceof Node?c.appendChild(a):a!=null&&c.appendChild(document.createTextNode(String(a)));return i.pop(),i.length===0&&i.push(e),c},useContext:n,use:n}}function yt(){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 ee=yt();function Me(){return typeof window<"u"}function te(e){if(e&&typeof e=="object")return e;if(!Me())return ee;try{return e==="session"?window.sessionStorage:e==="memory"?ee:window.localStorage}catch{return ee}}function ne(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 re(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 oe(e){let t=te(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=te(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function St(e){let t=te(e.store);try{t.removeItem(e.key)}catch{}}var j=new Map,Pe=!1;function Tt(){Pe||!Me()||(Pe=!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 se(e,t){if(!e.sync)return()=>{};let n=j.get(e.key)??new Set;return n.add(t),j.set(e.key,n),Tt(),()=>{n.delete(t),n.size===0&&j.delete(e.key)}}var L=[],_e=[],ce=!1,O=new Set,ae=[],le=[],D=!1;function Oe(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function ue(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)ue(e);O.clear();for(let e of ae)try{e()}catch{}ae.length=0,le.length=0,D=!1,Q()}function bt(e,t){return z(b(e))}function xt(e,t){return z(b(e))}function Et(e,t){let n={};for(let c of e){let[a]=b(!1);n[c]=a}let i=[n,(c,a)=>{}];return i.trigger=c=>({"data-krate-scope":"trigger",value:c}),i.panel=c=>({"data-krate-scope":"panel",value:c}),i.close=()=>({"data-krate-scope":"close"}),i}function wt(e,t){return z(b(e))}function kt(e,t){return z(b(e))}function z(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function Ct(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function b(e,t){let n=e,r=null;if(t?.persist){r=ne(t.persist);let f=re(r.key,r.deserialize);if(f.found)n=f.value;else{let l=oe(r);l.found&&(n=l.value)}}let i=new Set,c=()=>{let f=L[L.length-1];return f&&!f.disposed&&(i.add(f),f.sources.add(i)),n},a=()=>{let f=Array.from(i);for(let l of f){if(l.disposed){i.delete(l);continue}if(l.running){l.rerun=!0;continue}l.queued||(l.queued=!0,le.push(l))}Nt()},S=f=>{let l=typeof f=="function"?f(n):f;l!==n&&(n=l,r&&ie(r,n),a())};if(r&&r.sync){let f=r,l=se(f,h=>{if(h!==null)try{let g=f.deserialize(h);g!==n&&(n=g,a())}catch{}});U(l)}return[c,S]}function Nt(){D||(D=!0,queueMicrotask(At))}function At(){D=!1;let e=le.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,F(t),t.rerun&&!t.disposed&&(t.rerun=!1,F(t)))}function F(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 N(e){let t=Oe(e);return O.add(t),F(t),()=>{ue(t),O.delete(t)}}function U(e){let t=L[L.length-1];t?t.cleanups.push(e):ae.push(e)}function Rt(e){_e.push(e),ce||(ce=!0,queueMicrotask(Lt))}function Lt(){ce=!1;let e=_e.splice(0);for(let t of e)t()}function Pt(e){let[t,n]=b(void 0),r=Oe(()=>{let c=e();n(c)});O.add(r),F(r);let i=L[L.length-1];return i&&i.cleanups.push(()=>{r.disposed||(ue(r),O.delete(r))}),t}function Mt(e,t){let[n,r]=b(t);return[n,c=>r(a=>e(a,c))]}function _t(e){return{current:e}}function Ot(e){return t=>e(t,t.ref||(()=>{}))}var Ht={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},fe=new WeakMap;function Ke(e,t){let n=fe.get(e);n||(n=[],fe.set(e,n)),n.push(t)}function k(e){let t=fe.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 Kt(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;k(r),n.removeChild(r),r=i}}function It(e,t,n){let r=Kt(n);r?(Ie(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 He(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=Ht[r]||r,c=`__krate_${i}`,a=e[c];a&&e.removeEventListener(i,a),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 Ve(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Ve(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ke(n,N(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function Vt(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")?Ke(r,N(()=>He(r,i,c()))):He(r,i,c);for(let i of n)Ve(r,i);return r}function qe(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function qt(e,t){let n=qe(t),r=!1;N(()=>{r||(r=!0,n.appendChild(e()))})}function jt(e,t){let n=qe(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&k(r)}function Dt(e,t){let[n,r]=b(void 0),[i,c]=b(!0),[a,S]=b(void 0),[f,l]=b("unresolved"),[h,g]=b(0),p,v=()=>typeof e=="function"?e():e,T=async()=>{p&&p.abort(),p=new AbortController;let C=p,V=v();l(h()>0?"refreshing":"loading"),c(!0),S(void 0);try{let A=await t(V,{signal:C.signal});C.signal.aborted||(r(()=>A),l("ready"))}catch(A){A?.name!=="AbortError"&&!C.signal.aborted&&(S(A),l("error"))}finally{C.signal.aborted||c(!1)}};N(()=>{typeof e=="function"&&e.length===0&&e(),h(),T(),U(()=>{p&&(p.abort(),p=void 0)})});let x=function(){return n()};return Object.defineProperties(x,{loading:{get:()=>i()},error:{get:()=>a()},state:{get:()=>f()}}),[x,{mutate:C=>{r(C)},refetch:()=>{g(C=>C+1)}}]}function Ft(e,t,n,r,i,c){let a=[],S=t.nextSibling;for(;S&&S!==n;)a.push(S),S=S.nextSibling;if(c){let f=new Map;for(let h of a){let g=h.__k;g!=null&&!f.has(g)&&f.set(g,h)}let l=[];for(let h=0;h<r.length;h++){let g=c(r[h]),p=f.get(g);p?f.delete(g):(p=i(r[h],h),p.__k=g),l.push(p)}for(let h of f.values())h.parentNode===e&&(k(h),e.removeChild(h));for(let h=0;h<l.length;h++){let g=h===0?t:l[h-1];l[h]!==g.nextSibling&&e.insertBefore(l[h],g.nextSibling)}}else{let f=Math.max(a.length,r.length);for(let l=0;l<f;l++)if(l<r.length){let h=i(r[l],l);l<a.length?a[l]!==h&&(k(a[l]),e.replaceChild(h,a[l])):e.insertBefore(h,n)}else l<a.length&&a[l].parentNode===e&&(k(a[l]),e.removeChild(a[l]))}}function zt(e,t,n,r,i,c){let a=null;N(()=>{let f=r()?i():c?c():null;a?f?(k(a),e.replaceChild(f,a)):(k(a),e.removeChild(a)):f&&e.insertBefore(f,n),a=f})}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 je(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 pe(e,t){let n=document.importNode(t,!0);return e.parentNode&&(k(e),e.parentNode.replaceChild(n,e)),n}function De(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function ge(e,t){if(!De(e,t))return pe(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?pe(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return H(n)!==H(r)?pe(n,r):(je(n,r),Fe(n,r),n)}function Fe(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let p=0;p<r.length;p++)if(H(n[p])!==H(r[p])){g=!1;break}if(g){for(let p=0;p<r.length;p++)ge(n[p],r[p]);return}}let i=new Map,c=[];n.forEach((g,p)=>{let v=H(g);v!=null?i.has(v)||i.set(v,p):c.push(p)});let a=new Set,S=0,f=null,l=0,h=()=>{for(;l<c.length&&a.has(c[l]);)l++;return l<c.length?c[l]:-1};for(let g of r){let p=H(g),v;if(p!=null&&i.has(p)){let T=i.get(p);i.delete(p),a.add(T);let x=n[T];T<S?e.insertBefore(x,f):S=T,v=ge(x,g)}else if(p==null){let T=h();if(T>=0&&De(n[T],g)){a.add(T);let x=n[T];x.parentNode===e&&x.nextSibling!==f&&e.insertBefore(x,f),v=ge(x,g)}else v=document.importNode(g,!0),e.insertBefore(v,f)}else v=document.importNode(g,!0),e.insertBefore(v,f);f=v.nextSibling}n.forEach((g,p)=>{!a.has(p)&&g.parentNode===e&&(k(g),e.removeChild(g))})}function Ut(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}je(n,r),Fe(n,r)}var he=!1,K,W=null,B=0,P=new Map,Bt=30,I=new Map,Wt=50,ze=/\/chunks\/runtime\.[^/]+\.js$/;function Be(){return globalThis.__KRATE_CFG__||{}}function $t(){let e=Be().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function Ue(e){let t=$t();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var $=null;function Yt(e,t={}){return $?($(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function We(){if(typeof document>"u"||he)return;he=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,i=null,c=new Map,a=null;function S(o){for(let s of e.split(", ")){let u=o.querySelector(s.trim());if(u)return u}return o.body}function f(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 l(o){P.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(P.size>=Bt){let u=P.keys().next().value;u!==void 0&&P.delete(u)}P.set(o,s)}}).catch(()=>{})}function h(){document.addEventListener("mouseover",v),document.addEventListener("focusin",v),typeof IntersectionObserver<"u"&&(a=new IntersectionObserver(o=>{for(let s of o)if(s.isIntersecting){let u=s.target,d=u.getAttribute("href");if(d&&f(u)){let m=new URL(d,location.origin).href;l(m)}a.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){a&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{a.observe(o)})}function p(){document.removeEventListener("mouseover",v),document.removeEventListener("focusin",v);for(let o of c.values())clearTimeout(o);c.clear(),a&&(a.disconnect(),a=null)}function v(o){let s=o.target.closest("a[data-prefetch]");if(!s||!f(s))return;let u=s.getAttribute("href");if(!u)return;let d=new URL(u,location.origin).href;if(P.has(d))return;let m=c.get(s);m&&clearTimeout(m);let y=setTimeout(()=>{c.delete(s),l(d)},n);c.set(s,y)}let T=null;function x(){if(A())return;let o=S(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 Y(){if(A())return;T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let o=S(document);o&&(o.style.opacity="1")}function C(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 A(){if(Be().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(o){let s=o.querySelectorAll('link[rel="stylesheet"]'),u=new Set;s.forEach(m=>{let y=m.getAttribute("href");y&&u.add(new URL(y,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>{let y=m.href;y&&!u.has(y)&&m.remove()});let d=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>d.add(m.href)),s.forEach(m=>{let y=m.getAttribute("href");if(!y)return;let E=new URL(y,location.origin).href;if(!d.has(E)){let R=document.createElement("link");R.rel="stylesheet",R.href=E,document.head.appendChild(R)}})}function Te(o){o.querySelectorAll("[data-view-transition]").forEach(s=>{let u=s.getAttribute("data-view-transition");u&&(s.style.viewTransitionName=u)})}function Xe(){let o=S(document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1");try{o.focus({preventScroll:!0})}catch{try{o.focus()}catch{}}}}function Ge(){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 ve(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 Qe(o){document.head.querySelectorAll(be).forEach(s=>s.remove()),o.head.querySelectorAll(be).forEach(s=>{document.head.appendChild(document.importNode(s,!0))})}function xe(o,s,u,d={}){let{replace:m=!1,scroll:y=!0,restoreScroll:E=!1}=d,M=new DOMParser().parseFromString(o,"text/html"),Re=ve(M),Le=ve(document);if(!Re||!Le){location.href=s;return}V("krate:navigate-start",s);let X=()=>{let w=M.querySelector("title");w&&(document.title=w.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let q=Array.from(Re.childNodes).map(ct=>document.importNode(ct,!0));Le.replaceChildren(...q),Je(M),Qe(M),Te(document)};if(A())try{let w=document.startViewTransition(X);w&&w.finished&&typeof w.finished.catch=="function"&&w.finished.catch(()=>{})}catch{X()}else X();et(u,s).then(()=>{try{nt(),g()}catch(w){try{let q=globalThis.__krate_onHydrationError;typeof q=="function"&&q(w)}catch{}location.href=s}}),Y();let st=location.pathname+location.search;if(m)history.replaceState({},"",s);else{if(!E){if(I.size>=Wt){let w=I.keys().next().value;w!==void 0&&I.delete(w)}I.set(st,window.scrollY)}history.pushState({},"",s)}Ee(s,{restoreScroll:E,scroll:y}),E||Xe(),we(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),V("krate:navigate-end",s),C(s)}function Ze(o){let s=o.indexOf("#");if(s<0||s===o.length-1)return!1;let u=o.slice(s);try{let d=document.querySelector(u);if(d)return d.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Ee(o,s){if(s.restoreScroll){let u=I.get(o);if(u!==void 0){window.scrollTo(0,u);return}}Ze(o)||s.scroll&&window.scrollTo(0,0)}function we(){let o=Ue(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(s=>{let u=s.getAttribute("href");if(!u){s.removeAttribute("aria-current");return}let d=u;try{d=Ue(new URL(u,location.origin).pathname)}catch{return}d===o||o==="/"&&(d===""||d==="/")||d!=="/"&&d.length>1&&o.startsWith(d)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function et(o,s){return o.length===0?Promise.resolve():Promise.all(o.map(u=>{let d=u.getAttribute("src");return d?tt(d,s):Promise.resolve()})).then(()=>{})}function tt(o,s){return new Promise(u=>{let d=document.createElement("script"),m=ke(o,s);d.src=m,ze.test(m)||d.setAttribute("data-krate-spa",""),d.onload=()=>u(),d.onerror=()=>u(),document.body.appendChild(d)})}function ke(o,s){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,s).href;let u=s;if(!u.endsWith("/")){let d=u.lastIndexOf("/");u=d>0?u.slice(0,d+1):"/"}return new URL(o,u).href}function nt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function rt(o,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),C(s),document.open(),document.write(o),document.close()}function ot(){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 it(){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 Ce(o,s){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let u=[],d=new Set;return document.querySelectorAll("script[src]").forEach(m=>{d.add(m.src)}),o.querySelectorAll("script[src]").forEach(m=>{let y=m.getAttribute("src");y&&!d.has(ke(y,s))&&u.push(m)}),u}function J(o,s={}){let u=++B,d=P.get(o);if(d){let E=new DOMParser().parseFromString(d,"text/html");xe(d,o,Ce(E,o),s);return}x(),K&&K.abort(),K=new AbortController;let m=K.signal;fetch(o,{headers:{Accept:"text/html"},signal:m}).then(y=>{if(u===B)return y.ok?y.text().then(E=>{if(u!==B)return;let M=new DOMParser().parseFromString(E,"text/html");xe(E,o,Ce(M,o),s)}):(y.status>=500?it():ot()).then(R=>{u===B&&(R?rt(R,o):location.href=o)})}).catch(y=>{y?.name!=="AbortError"&&(Y(),location.href=o)}).finally(()=>{K&&!m.aborted&&(K=void 0)})}let Ne=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||!f(s))return;o.preventDefault();let u=s.getAttribute("href");if(!u)return;let d=new URL(u,location.origin).href,m=s.hasAttribute("data-krate-replace"),y=s.getAttribute("data-krate-scroll")!=="false";if(u===location.pathname+location.search+location.hash){m&&history.replaceState({},"",u),Ee(d,{scroll:y});return}J(d,{replace:m,scroll:y})},Ae=()=>{J(location.href,{restoreScroll:!0})};document.addEventListener("click",Ne),window.addEventListener("popstate",Ae),h(),Ge(),we(),Te(document),$=(o,s={})=>{let u=!0;try{u=new URL(o,location.href).origin===location.origin}catch{u=!1}if(!u){location.href=o;return}J(new URL(o,location.href).href,s)},document.querySelectorAll("script[src]").forEach(o=>{ze.test(o.src)||o.setAttribute("data-krate-spa","")}),W=()=>{document.removeEventListener("click",Ne),window.removeEventListener("popstate",Ae),p(),$=null}}function Jt(){W&&(W(),W=null),he=!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 ye(...e){let t=[];for(let n of e)me(n,t);return t.join(" ")}function Se(...e){let t=[];for(let i of e)me(i,t);let n=new Map,r=[];for(let i of t){let c=Xt(i);n.has(c)||r.push(c),n.set(c,i)}return r.map(i=>n.get(i)).join(" ")}function Xt(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,a=i>=0?t.slice(i+1,i+2):"";return n+c+(a&&/[0-9]/.test(a)?"-"+a:"")}function Gt(...e){return Se(ye(...e))}function Qt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return i=>{let c={};for(let f of Object.keys(n)){let l=i?.[f]??r[f];l!=null&&(c[f]=String(l))}let a=[e];for(let f of Object.keys(n)){let l=c[f];l&&n[f][l]&&a.push(n[f][l])}for(let f of t?.compoundVariants??[])if(Zt(f,c,r)){let l=f.class;typeof l=="string"&&a.push(l)}let S=i?.class??i?.className;return typeof S=="string"&&a.push(S),Se(ye(a))}}function Zt(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 en(e){let t=$e(e?.children);return t?(Ye(t,e),t):null}function $e(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=$e(t);if(n)return n}return null}return e instanceof Node?e:null}function Ye(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(tn(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 tn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function nn(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ye(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 pt(rn);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }