@krate/runtime 0.5.0-rc.18 → 0.5.0-rc.19

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.
@@ -13,7 +13,7 @@ export interface ActionCookieOptions {
13
13
  expires?: Date;
14
14
  httpOnly?: boolean;
15
15
  secure?: boolean;
16
- sameSite?: 'Strict' | 'Lax' | 'None' | boolean;
16
+ sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none' | boolean;
17
17
  }
18
18
  /** Cookie access for the current action request. */
19
19
  export interface ActionCookies {
@@ -16,7 +16,9 @@ function actionSecret() {
16
16
  const proc = globalThis.process;
17
17
  let secret = proc?.env?.KRATE_ACTION_SECRET || '';
18
18
  if (!secret && !globalThis[Symbol.for('krate.action.deployed')]) {
19
- const fs = builtin('node:fs');
19
+ // Named in parts: this runs only on a Node server. A Workers bundle has
20
+ // no filesystem and takes the key from KRATE_ACTION_SECRET.
21
+ const fs = builtin(['node', 'fs'].join(':'));
20
22
  const path = builtin('node:path');
21
23
  const dir = proc?.env?.KRATE_ACTION_DIR || path.join(proc?.env?.KRATE_ROOT || proc?.cwd?.() || '.', '.krate', 'actions');
22
24
  try {
@@ -95,9 +97,19 @@ export function sealBoundArgs(id, values, path) {
95
97
  const key = crypto.createHash('sha256').update('krate-inline-action\0' + actionSecret()).digest();
96
98
  const iv = crypto.randomBytes(12);
97
99
  const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
98
- cipher.setAAD(Buffer.from(id));
99
- const body = Buffer.concat([cipher.update(JSON.stringify(encoded), 'utf8'), cipher.final()]);
100
- const token = 'k1.' + Buffer.concat([iv, body, cipher.getAuthTag()]).toString('base64url');
100
+ const text = new TextEncoder();
101
+ cipher.setAAD(text.encode(id));
102
+ const parts = [iv, cipher.update(text.encode(JSON.stringify(encoded))), cipher.final(), cipher.getAuthTag()];
103
+ const raw = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
104
+ let at = 0;
105
+ for (const p of parts) {
106
+ raw.set(p, at);
107
+ at += p.length;
108
+ }
109
+ let bin = '';
110
+ for (let i = 0; i < raw.length; i++)
111
+ bin += String.fromCharCode(raw[i]);
112
+ const token = 'k1.' + btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
101
113
  if (token.length > MAX_URL_TOKEN) {
102
114
  throw new RangeError(`Prop \`${path}\` is a server action bound to ${token.length} bytes of data; bind ids and look the rest up inside the action`);
103
115
  }
@@ -22,7 +22,7 @@ function suspenseTag(props) {
22
22
  return props.children ?? null;
23
23
  }
24
24
  function linkTag(props) {
25
- const { children, prefetch: _prefetch, replace: _replace, scroll: _scroll, ...rest } = props;
25
+ const { children, prefetch: _prefetch, replace: _replace, scroll: _scroll, passHref: _passHref, ...rest } = props;
26
26
  return h("a", rest, children);
27
27
  }
28
28
  // The typed tags keep the prop types of their global declarations.
@@ -9,7 +9,7 @@ export const DEFAULT_SETTINGS = {
9
9
  openOnRuntime: true,
10
10
  consoleIssues: true,
11
11
  showWarnings: true,
12
- collapsed: false,
12
+ collapsed: true,
13
13
  };
14
14
  const CORNERS = ['bl', 'br', 'tl', 'tr'];
15
15
  const THEMES = ['system', 'dark', 'light'];
package/dist/highlight.js CHANGED
@@ -301,10 +301,12 @@ function shouldHighlight(ranges, idx, line) {
301
301
  return [false, idx];
302
302
  }
303
303
  /** Writes tokens as chroma's HTML formatter does (class mode, no line numbers). */
304
- function format(tokens, ranges) {
304
+ function format(tokens, spec) {
305
305
  const lines = splitLines(tokens);
306
- // Line wrappers only carry the highlight class, so unmarked code omits them.
307
- const wrap = ranges.length > 0;
306
+ const ranges = spec ? parseLineRanges(spec).sort((a, b) => a[0] - b[0]) : [];
307
+ // Line wrappers are written whenever a spec is given, even one that marks no
308
+ // line; code without one omits them.
309
+ const wrap = spec !== undefined || ranges.length > 0;
308
310
  let html = "";
309
311
  let idx = 0;
310
312
  for (let i = 0; i < lines.length; i++) {
@@ -362,7 +364,7 @@ export function highlight(code, lang, lines, limits = {}) {
362
364
  finally {
363
365
  deadline = Infinity;
364
366
  }
365
- return format(out, lines ? parseLineRanges(lines).sort((a, b) => a[0] - b[0]) : []);
367
+ return format(out, lines);
366
368
  }
367
369
  function longestLine(s) {
368
370
  let best = 0;
@@ -423,7 +425,7 @@ export function plainLines(code, lines) {
423
425
  let m;
424
426
  while ((m = re.exec(text)) !== null)
425
427
  out.push(["", m[0]]);
426
- return format(out, lines ? parseLineRanges(lines).sort((a, b) => a[0] - b[0]) : []);
428
+ return format(out, lines);
427
429
  }
428
430
  /** Names of the registered languages, for tests. */
429
431
  export function loadedLanguages() {
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { krateCondSwap, krateCondDetached, krateCondReset, krateSanitizeAttr, BL
16
16
  export { Fragment, jsx, jsxs } from './jsx-runtime.js';
17
17
  export { initRouter, reinitRouter, destroyRouter, navigate, krateRouter, subscribeNavigation, getNavigationState, getHistoryState, invalidatePrefetchCache, } from './router.js';
18
18
  export type { NavigateOptions, NavigationState } from './router.js';
19
- export { usePathname, useSearchParams, useParams, useRouter, useSelectedLayoutSegment, useSelectedLayoutSegments, redirect, permanentRedirect, notFound, forbidden, unauthorized, } from './navigation.js';
19
+ export { usePathname, useSearchParams, useParams, useRouter, krateCurrentRoute, useSelectedLayoutSegment, useSelectedLayoutSegments, redirect, permanentRedirect, notFound, forbidden, unauthorized, } from './navigation.js';
20
20
  export type { AppRouterInstance } from './navigation.js';
21
21
  export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
22
22
  export type { ClassValue, CVAConfig } from './class-helpers.js';
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { krateHighlightInit, krateHighlight } from './highlight-bind.js';
9
9
  export { krateCondSwap, krateCondDetached, krateCondReset, krateSanitizeAttr, BLOCKED_URL } from './slots.js';
10
10
  export { Fragment, jsx, jsxs } from './jsx-runtime.js';
11
11
  export { initRouter, reinitRouter, destroyRouter, navigate, krateRouter, subscribeNavigation, getNavigationState, getHistoryState, invalidatePrefetchCache, } from './router.js';
12
- export { usePathname, useSearchParams, useParams, useRouter, useSelectedLayoutSegment, useSelectedLayoutSegments, redirect, permanentRedirect, notFound, forbidden, unauthorized, } from './navigation.js';
12
+ export { usePathname, useSearchParams, useParams, useRouter, krateCurrentRoute, useSelectedLayoutSegment, useSelectedLayoutSegments, redirect, permanentRedirect, notFound, forbidden, unauthorized, } from './navigation.js';
13
13
  export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
14
14
  export { krateParam } from './hook-args.js';
15
15
  export { createContext, createScope, createScopeFlags, resetContexts } from './context.js';
@@ -10,6 +10,12 @@ declare global {
10
10
  namespace Krate {
11
11
  interface TypedRoutes {
12
12
  }
13
+ /**
14
+ * Set by `@krate/runtime/react-types` (`{ react: true }`) so props typed
15
+ * with React's types (event handlers, refs, HTML props) are accepted.
16
+ */
17
+ interface ReactCompat {
18
+ }
13
19
  }
14
20
  /**
15
21
  * A navigation target. When the project has generated route types,
@@ -23,6 +29,17 @@ declare global {
23
29
  /** A server action imported from a "use server" module, or a URL. */
24
30
  type KrateFormAction = string | ((formData: FormData) => unknown | Promise<unknown>);
25
31
  namespace JSX {
32
+ type RefCallback = Krate.ReactCompat extends {
33
+ react: true;
34
+ } ? (el: any) => unknown : (el: globalThis.Element) => void;
35
+ type CompatStyle = Krate.ReactCompat extends {
36
+ react: true;
37
+ } ? object : never;
38
+ type TrustedInnerHTML = Krate.ReactCompat extends {
39
+ react: true;
40
+ } ? string | {
41
+ toString(): string;
42
+ } : string;
26
43
  interface Element extends Node {
27
44
  }
28
45
  interface ElementChildrenAttribute {
@@ -84,7 +101,7 @@ declare global {
84
101
  'aria-posinset'?: number;
85
102
  'aria-pressed'?: boolean | 'false' | 'mixed' | 'true';
86
103
  'aria-readonly'?: Booleanish;
87
- 'aria-relevant'?: 'additions' | 'additions text' | 'all' | 'removals' | 'text';
104
+ 'aria-relevant'?: 'additions' | 'additions text' | 'additions removals' | 'all' | 'removals' | 'removals additions' | 'removals text' | 'text' | 'text additions' | 'text removals';
88
105
  'aria-required'?: Booleanish;
89
106
  'aria-roledescription'?: string;
90
107
  'aria-rowcount'?: number;
@@ -98,9 +115,11 @@ declare global {
98
115
  'aria-valuenow'?: number;
99
116
  'aria-valuetext'?: string;
100
117
  }
101
- interface EventHandler<E extends Event = Event> {
102
- (event: E): void;
103
- }
118
+ type EventHandler<E extends Event = Event> = Krate.ReactCompat extends {
119
+ react: true;
120
+ } ? {
121
+ bivarianceHack(event: any): void;
122
+ }['bivarianceHack'] : (event: E) => void;
104
123
  interface ClipboardEventHandler {
105
124
  onCopy?: EventHandler<ClipboardEvent>;
106
125
  onCut?: EventHandler<ClipboardEvent>;
@@ -204,13 +223,13 @@ declare global {
204
223
  }
205
224
  interface DOMAttributes extends IntrinsicAttributes {
206
225
  children?: unknown[] | unknown;
207
- key?: string | number;
226
+ key?: string | number | bigint | null;
208
227
  /** Assigns the mounted DOM element. Pass a mutable holder (`ref={myRef}`), a callback (`ref={el => ...}`), or an element. */
209
- ref?: ((el: globalThis.Element) => void) | {
228
+ ref?: RefCallback | {
210
229
  current: globalThis.Element | null;
211
230
  } | globalThis.Element | null;
212
231
  slot?: string;
213
- style?: CSSProperties | string;
232
+ style?: CSSProperties | string | CompatStyle;
214
233
  part?: string;
215
234
  exportparts?: string;
216
235
  }
@@ -219,8 +238,8 @@ declare global {
219
238
  accesskey?: string;
220
239
  class?: string;
221
240
  className?: string;
222
- contentEditable?: Booleanish | 'inherit' | 'false' | 'true';
223
- contenteditable?: Booleanish | 'inherit' | 'false' | 'true';
241
+ contentEditable?: Booleanish | 'inherit' | 'plaintext-only' | 'false' | 'true';
242
+ contenteditable?: Booleanish | 'inherit' | 'plaintext-only' | 'false' | 'true';
224
243
  contextMenu?: string;
225
244
  contextmenu?: string;
226
245
  dir?: string;
@@ -257,14 +276,14 @@ declare global {
257
276
  security?: string;
258
277
  unselectable?: 'on' | 'off';
259
278
  is?: string;
260
- popover?: 'auto' | 'manual' | boolean;
279
+ popover?: 'auto' | 'manual' | '' | boolean;
261
280
  popovertarget?: string;
262
281
  popovertargetaction?: 'toggle' | 'show' | 'hide';
263
282
  writingSuggestions?: 'mark' | 'suggestion';
264
283
  inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
265
284
  placeholder?: string;
266
285
  dangerouslySetInnerHTML?: {
267
- __html: string;
286
+ __html: TrustedInnerHTML;
268
287
  };
269
288
  }
270
289
  interface AnchorHTMLAttributes extends HTMLAttributes {
@@ -273,7 +292,7 @@ declare global {
273
292
  hrefLang?: string;
274
293
  media?: string;
275
294
  ping?: string;
276
- referrerPolicy?: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
295
+ referrerPolicy?: '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
277
296
  rel?: string;
278
297
  target?: string;
279
298
  type?: string;
@@ -386,11 +405,11 @@ declare global {
386
405
  /** Initial checked state of an uncontrolled checkbox or radio. */
387
406
  defaultChecked?: boolean;
388
407
  /** Initial value of an uncontrolled input. */
389
- defaultValue?: string | number;
408
+ defaultValue?: string | number | readonly string[];
390
409
  crossOrigin?: string;
391
410
  disabled?: boolean | string;
392
411
  form?: string;
393
- formAction?: string;
412
+ formAction?: KrateFormAction;
394
413
  formaction?: string;
395
414
  formEncType?: string;
396
415
  formMethod?: string;
@@ -415,16 +434,16 @@ declare global {
415
434
  src?: string;
416
435
  step?: number | string;
417
436
  type?: string;
418
- value?: string | number;
437
+ value?: string | number | readonly string[];
419
438
  width?: number | string;
420
- onChange?: (event: Event & {
439
+ onChange?: EventHandler<Event & {
421
440
  target: HTMLInputElement;
422
441
  currentTarget: HTMLInputElement;
423
- }) => void;
424
- onInput?: (event: Event & {
442
+ }>;
443
+ onInput?: EventHandler<Event & {
425
444
  target: HTMLInputElement;
426
445
  currentTarget: HTMLInputElement;
427
- }) => void;
446
+ }>;
428
447
  }
429
448
  interface SelectHTMLAttributes extends Omit<HTMLAttributes, 'onChange'> {
430
449
  autoComplete?: string;
@@ -437,11 +456,11 @@ declare global {
437
456
  name?: string;
438
457
  required?: boolean | string;
439
458
  size?: number;
440
- value?: string | number;
441
- onChange?: (event: Event & {
459
+ value?: string | number | readonly string[];
460
+ onChange?: EventHandler<Event & {
442
461
  target: HTMLSelectElement;
443
462
  currentTarget: HTMLSelectElement;
444
- }) => void;
463
+ }>;
445
464
  }
446
465
  interface TextareaHTMLAttributes extends Omit<HTMLAttributes, 'onChange' | 'onInput'> {
447
466
  autoComplete?: string;
@@ -462,22 +481,22 @@ declare global {
462
481
  readonly?: boolean;
463
482
  required?: boolean | string;
464
483
  rows?: number;
465
- value?: string | number;
484
+ value?: string | number | readonly string[];
466
485
  wrap?: string;
467
- onChange?: (event: Event & {
486
+ onChange?: EventHandler<Event & {
468
487
  target: HTMLTextAreaElement;
469
488
  currentTarget: HTMLTextAreaElement;
470
- }) => void;
471
- onInput?: (event: Event & {
489
+ }>;
490
+ onInput?: EventHandler<Event & {
472
491
  target: HTMLTextAreaElement;
473
492
  currentTarget: HTMLTextAreaElement;
474
- }) => void;
493
+ }>;
475
494
  }
476
495
  interface ButtonHTMLAttributes extends Omit<HTMLAttributes, 'onClick'> {
477
496
  autoFocus?: boolean;
478
497
  disabled?: boolean | string;
479
498
  form?: string;
480
- formAction?: string;
499
+ formAction?: KrateFormAction;
481
500
  formEncType?: string;
482
501
  formMethod?: string;
483
502
  formNoValidate?: boolean;
@@ -487,15 +506,15 @@ declare global {
487
506
  popovertargetaction?: 'toggle' | 'show' | 'hide';
488
507
  required?: boolean | string;
489
508
  type?: 'submit' | 'reset' | 'button';
490
- value?: string;
491
- onClick?: (event: MouseEvent & {
509
+ value?: string | number | readonly string[];
510
+ onClick?: EventHandler<MouseEvent & {
492
511
  target: HTMLButtonElement;
493
512
  currentTarget: HTMLButtonElement;
494
- }) => void;
513
+ }>;
495
514
  }
496
515
  interface FormHTMLAttributes extends Omit<HTMLAttributes, 'onSubmit' | 'onReset'> {
497
516
  acceptCharset?: string;
498
- action?: string;
517
+ action?: KrateFormAction;
499
518
  autoComplete?: string;
500
519
  encType?: string;
501
520
  method?: string;
@@ -503,14 +522,14 @@ declare global {
503
522
  noValidate?: boolean;
504
523
  rel?: string;
505
524
  target?: string;
506
- onSubmit?: (event: Event & {
525
+ onSubmit?: EventHandler<Event & {
507
526
  target: HTMLFormElement;
508
527
  currentTarget: HTMLFormElement;
509
- }) => void;
510
- onReset?: (event: Event & {
528
+ }>;
529
+ onReset?: EventHandler<Event & {
511
530
  target: HTMLFormElement;
512
531
  currentTarget: HTMLFormElement;
513
- }) => void;
532
+ }>;
514
533
  }
515
534
  interface InsHTMLAttributes extends HTMLAttributes {
516
535
  cite?: string;
@@ -522,7 +541,7 @@ declare global {
522
541
  form?: string;
523
542
  }
524
543
  interface LiHTMLAttributes extends HTMLAttributes {
525
- value?: string | number;
544
+ value?: string | number | readonly string[];
526
545
  type?: string;
527
546
  }
528
547
  interface LinkHTMLAttributes extends HTMLAttributes {
@@ -570,7 +589,7 @@ declare global {
570
589
  max?: number | string;
571
590
  min?: number | string;
572
591
  optimum?: number;
573
- value?: string | number;
592
+ value?: string | number | readonly string[];
574
593
  }
575
594
  interface ObjectHTMLAttributes extends HTMLAttributes {
576
595
  classID?: string;
@@ -595,7 +614,7 @@ declare global {
595
614
  disabled?: boolean | string;
596
615
  label?: string;
597
616
  selected?: boolean | string;
598
- value?: string | number;
617
+ value?: string | number | readonly string[];
599
618
  }
600
619
  interface OutputHTMLAttributes extends HTMLAttributes {
601
620
  for?: string;
@@ -604,7 +623,7 @@ declare global {
604
623
  }
605
624
  interface ProgressHTMLAttributes extends HTMLAttributes {
606
625
  max?: number | string;
607
- value?: string | number;
626
+ value?: string | number | readonly string[];
608
627
  }
609
628
  interface QuoteHTMLAttributes extends HTMLAttributes {
610
629
  cite?: string;
@@ -659,7 +678,7 @@ declare global {
659
678
  headers?: string;
660
679
  rowSpan?: number;
661
680
  rowspan?: number;
662
- scope?: 'col' | 'colgroup' | 'row' | 'rowgroup';
681
+ scope?: 'col' | 'colgroup' | 'row' | 'rowgroup' | (string & {});
663
682
  width?: number | string;
664
683
  }
665
684
  interface TimeHTMLAttributes extends HTMLAttributes {
@@ -681,11 +700,11 @@ declare global {
681
700
  }
682
701
  interface SVGAttributes extends AriaAttributes, ClipboardEventHandler, CompositionEventHandler, FocusEventHandler, FormEventHandler, KeyboardEventHandler, MouseEventHandler, PointerEventHandler, TouchEventHandler, WheelEventHandler, AnimationEventHandler, TransitionEventHandler, UIEventHandler, MediaEventHandler, DOMAttributes {
683
702
  children?: unknown[] | unknown;
684
- key?: string | number;
685
- ref?: ((el: globalThis.Element) => void) | {
703
+ key?: string | number | bigint | null;
704
+ ref?: RefCallback | {
686
705
  current: globalThis.Element | null;
687
706
  } | globalThis.Element | null;
688
- style?: CSSProperties | string;
707
+ style?: CSSProperties | string | CompatStyle;
689
708
  class?: string;
690
709
  className?: string;
691
710
  id?: string;
@@ -933,7 +952,7 @@ declare global {
933
952
  xmlns?: string;
934
953
  xmlnsXlink?: string;
935
954
  'xmlns:xlink'?: string;
936
- xmlSpace?: 'default' | 'preserve';
955
+ xmlSpace?: 'default' | 'preserve' | (string & {});
937
956
  'xml:space'?: 'default' | 'preserve';
938
957
  xmlLang?: string;
939
958
  'xml:lang'?: string;
@@ -962,7 +981,7 @@ declare global {
962
981
  transformBox?: string;
963
982
  color?: string;
964
983
  dangerouslySetInnerHTML?: {
965
- __html: string;
984
+ __html: TrustedInnerHTML;
966
985
  };
967
986
  }
968
987
  interface IntrinsicElements {
@@ -1170,6 +1189,8 @@ declare global {
1170
1189
  replace?: boolean;
1171
1190
  /** Scroll to the top on navigation (default: true). */
1172
1191
  scroll?: boolean;
1192
+ /** Accepted for Next.js code and ignored: the anchor always carries the href. */
1193
+ passHref?: boolean;
1173
1194
  /** Open in a new tab. */
1174
1195
  target?: "_blank" | "_self" | "_parent" | "_top" | string;
1175
1196
  rel?: string;
@@ -1180,8 +1201,10 @@ declare global {
1180
1201
  __jsxProps: {};
1181
1202
  }
1182
1203
  }
1204
+ /** A build-time inlined SVG icon. `size` sets both `width` and `height`. */
1183
1205
  function Icon(props: {
1184
1206
  name: string;
1207
+ size?: number | string;
1185
1208
  } & JSX.SVGAttributes): JSX.Element;
1186
1209
  function Head(props: {
1187
1210
  children?: any;
package/dist/krate-dev.js CHANGED
@@ -13,7 +13,7 @@ var __krate_exports=(()=>{var ze="https://krate.js.org/docs/reference/diagnostic
13
13
  `+" ".repeat(e.col-1)+"^":""))),e.hint&&s.push("","Hint: "+e.hint),e.stack&&e.kind!=="build"&&s.push("","Stack:","",U("",e.stack)),e.hostStack&&s.push("","Host stack:","",U("",e.hostStack)),e.server?.log?.length&&s.push("","Last console lines:","",U("",e.server.log.join(`
14
14
  `))),s.join(`
15
15
  `)+`
16
- `}function J(e){let t=[],n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=new TextDecoder,s=0;for(;e.length-s>=4;){let o=n.getUint32(s),i=s+4+o;if(e.length<i+2)break;let a=r.decode(e.subarray(s+4,i)),l=n.getUint16(i);i+=2;let c=!0;for(let p=0;p<l;p++){if(e.length<i+4){c=!1;break}if(i+=4+n.getUint32(i),e.length<i){c=!1;break}}if(!c)break;try{t.push(JSON.parse(a))}catch{}s=i}return{values:t,rest:e.subarray(s)}}function Q(e){let t=e?.data,n=t&&typeof t=="object"?t.stack:void 0;return typeof n=="string"?n:""}function ge(e){let t=e.time?new Date(e.time).toLocaleTimeString():"",n=e.durNs?(e.durNs/1e6>=10?Math.round(e.durNs/1e6):Math.round(e.durNs/1e5)/10)+"ms":"",r=e.code?" "+e.code+(e.message?": "+e.message:""):"";return[t,e.kind,e.fn,n].filter(Boolean).join(" ")+r}function K(e){return!Number.isFinite(e)||e<0?"n/a":e>=1<<30?(e/(1<<30)).toFixed(2)+" GiB":e>=1<<20?(e/(1<<20)).toFixed(1)+" MiB":e>=1024?Math.round(e/1024)+" KiB":Math.round(e)+" B"}function he(){let e=typeof performance<"u"?performance.memory:void 0;return e&&typeof e.usedJSHeapSize=="number"?e.usedJSHeapSize:null}function me(e,t,n){let r=[];if(e&&e.procs){for(let s of e.procs)r.push([s.role+" ("+s.pid+")","PSS "+K(s.pss)+" / private dirty "+K(s.privateDirty)]);e.total&&r.push(["total","PSS "+K(e.total.pss)+" / private dirty "+K(e.total.privateDirty)])}else r.push(["processes","unavailable"]);return r.push(["DOM nodes",String(t)]),r.push(["JS heap",n===null?"unavailable in this engine (see the web process row)":K(n)]),r}var be;function k(e,t){return(be||fetch)(e,t)}var ve=15e3,nn=2e3,ee=class{constructor(){this.list=[]}add(t){this.list.push(t),this.list.length>50&&this.list.shift(),this.onChange?.()}near(t){return this.list.filter(n=>n.t>=t-ve&&n.t<=t+nn)}};function Ue(e){try{let t=new URL(e,typeof location<"u"?location.href:"http://localhost/");return/^\/__krate\//.test(t.pathname)}catch{return!1}}function Je(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){let t=e;if(typeof t.url=="string")return t.url;if(typeof t.href=="string")return t.href}return String(e)}function We(e){try{let t=new URL(e,location.href);return t.origin===location.origin?t.pathname+t.search:t.href}catch{return e}}function Ve(e,t=globalThis){let n=[],r=()=>typeof performance<"u"?performance.now():Date.now(),s=t.fetch;if(typeof s=="function"){be=s.bind(t);let i=function(a,l){let c=Je(a),p=String(l?.method||a&&typeof a=="object"&&a.method||"GET").toUpperCase(),u=r(),f=s.apply(this,arguments);return Ue(c)?f:f.then(g=>{try{g&&g.status>=400&&e.add({method:p,url:c,status:g.status,ms:Math.round(r()-u),t:Date.now()})}catch{}return g},g=>{try{g&&typeof g=="object"&&g.name==="AbortError"||e.add({method:p,url:c,status:0,error:g instanceof Error?g.message:String(g),ms:Math.round(r()-u),t:Date.now()})}catch{}throw g})};t.fetch=i,n.push(()=>{t.fetch===i&&(t.fetch=s),be=void 0})}let o=t.XMLHttpRequest;if(typeof o=="function"&&o.prototype){let i=o.prototype,a=i.open,l=i.send;i.open=function(c,p){return this.__kdReq={method:String(c||"GET").toUpperCase(),url:Je(p)},a.apply(this,arguments)},i.send=function(){let c=this.__kdReq;if(c&&!Ue(c.url)){let p=r(),u=!1,f=g=>{if(!u){u=!0;try{let v=g?0:Number(this.status)||0;(g||v>=400||v===0)&&e.add({method:c.method,url:c.url,status:v,error:g||(v===0?"network error":void 0),ms:Math.round(r()-p),t:Date.now()})}catch{}}};this.addEventListener("load",()=>f()),this.addEventListener("error",()=>f("network error")),this.addEventListener("timeout",()=>f("timed out"))}return l.apply(this,arguments)},n.push(()=>{i.open=a,i.send=l})}return()=>{for(let i of n.splice(0))i()}}var rn="__krate_cfg__";function Ge(){let e=globalThis;if(e.__KRATE_CFG__)return e.__KRATE_CFG__;let t=e.document,n=t&&typeof t.getElementById=="function"?t.getElementById(rn):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return e.__KRATE_CFG__=r,r}catch{}return{}}function Xe(){try{return location.protocol==="krate:"||location.origin==="https://app.localhost"}catch{return!1}}function Ze(){let e=window.__KRATE_DEV__,t=Ge(),n=Xe();return{standalone:!!e?.standalone,sse:e?.sse??"/__krate/hotreload",frames:e?.frames??(n?"/__krate/hmr":""),events:e?.events??(n?"/__krate/dev/events":""),memory:e?.memory??(n?"/__krate/dev/memory":""),errors:e?.errors??(n?"/__krate/dev/client-error":"/__krate/client-error"),open:e?.open??"/__krate/open",api:e?.api??"",version:e?.version??"",overlay:e?.overlay??!0,toolbar:e?.toolbar??!0,basePath:e?.basePath??t?.basePath??"",page:e?.page}}function d(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(e){return d(e).replace(/`([^`]+)`/g,"<code>$1</code>")}function $e(e){return e.replace(/\/+$/,"")||"/"}function sn(e,t){if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function te(e,t,n=""){let r=$e(sn(t,n)).split("/"),s=$e(e).split("/");for(let o=0;o<s.length;o++){let i=s[o];if(i.charAt(0)==="["){if(i.indexOf("[...")===0)return!0;continue}if(i!==r[o])return!1}return r.length===s.length}function ke(e){if(e instanceof Error)return e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function y(e){if(!e||e<0)return"0";let t=e/1024;return t>=100?String(Math.round(t)):t.toFixed(1).replace(/\.0$/,"")}function C(e){return e===void 0||!Number.isFinite(e)?"":e<10?e.toFixed(1)+"ms":e<1e3?Math.round(e)+"ms":(e/1e3).toFixed(e<1e4?1:0)+"s"}function E(e){let t=new Date(e),n=r=>String(r).padStart(2,"0");return n(t.getHours())+":"+n(t.getMinutes())+":"+n(t.getSeconds())}function A(e){let t=e.replace(/\\/g,"/").lastIndexOf("/");return t===-1?e:e.slice(t+1)}function Ye(e){let t=e.replace(/\\/g,"/"),n=t.lastIndexOf("/");return n===-1?"":t.slice(0,n+1)}function x(e,t,n=t+"s"){return e+" "+(e===1?t:n)}function j(){try{let e=navigator,t=e.userAgentData?.platform||e.platform||e.userAgent||"";return/mac|iphone|ipad/i.test(t)}catch{return!1}}function Qe(e,t){let n=typeof e.composedPath=="function"?e.composedPath():[],r=n[0]||e.target;if(!r||!r.tagName||t&&n.includes(t))return!1;let s=r.tagName;if(s==="TEXTAREA"||s==="SELECT")return!0;if(s==="INPUT"){let o=(r.type||"text").toLowerCase();return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(o)}return r.isContentEditable===!0||r.getAttribute?.("contenteditable")==="true"}async function _(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;opacity:0;left:-9999px",document.body.appendChild(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}var xe={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}}};var tt="krate:dev-overlay",on={corner:"bl",theme:"system",editor:"",openOnRuntime:!0,consoleIssues:!0,showWarnings:!0,collapsed:!1},an=["bl","br","tl","tr"],ln=["system","dark","light"];function nt(){let e={...on};try{let t=JSON.parse(xe.get(tt)||"{}");an.includes(t.corner)&&(e.corner=t.corner),ln.includes(t.theme)&&(e.theme=t.theme),typeof t.editor=="string"&&/^[\w.-]{0,40}$/.test(t.editor)&&(e.editor=t.editor);for(let n of["openOnRuntime","consoleIssues","showWarnings","collapsed"])typeof t[n]=="boolean"&&(e[n]=t[n])}catch{}return e}function rt(e){xe.set(tt,JSON.stringify(e))}function st(e,t,n,r){return(t<r/2?"t":"b")+(e<n/2?"l":"r")}function ot(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;switch(e.code){case"KeyK":return"menu";case"KeyI":return"inspect";case"KeyE":return"issues";case"Period":return"hide"}return null}var et={Alt:"option",Mod:"command",Shift:"arrow-big-up",Enter:"corner-down-left"},dn={Alt:"Alt",Mod:"Ctrl",Shift:"Shift",Enter:"Enter"};function it(e,t=j()){return t&&et[e]?b(et[e]):d(dn[e]||e)}function D(e,t=j()){return'<span class="kbd">'+e.map(n=>it(n,t)).join(t?"":" ")+"</span>"}function N(e,t=j()){return e.map(n=>'<span class="kbd">'+it(n,t)+"</span>").join("")}var cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function lt(e){let t=[],n=0,r=0;for(let s=0;s<e.length;s++){let o=cn.indexOf(e[s]);if(o===-1)continue;let i=(o&32)!==0;if(r+=(o&31)<<n,i){n+=5;continue}let a=(r&1)===1;r>>=1,t.push(a?-r:r),r=0,n=0}return t}function dt(e){let t=[],n=0,r=0,s=0;for(let o of e.split(";")){let i=[],a=0;if(o)for(let l of o.split(",")){if(!l)continue;let c=lt(l);a+=c[0]||0,c.length===1?i.push({genCol:a,src:-1,srcLine:0,srcCol:0}):c.length>=4&&(n+=c[1],r+=c[2],s+=c[3],i.push({genCol:a,src:n,srcLine:r,srcCol:s}))}t.push(i)}return t}var at=new Map;function un(e,t,n){let r=n?.get("SourceMap")||n?.get("X-SourceMap"),s=r?r.trim():"";if(!s){let o=/\/[/*][#@]\s*sourceMappingURL=([^\s'"*]+)/g,i;for(;i=o.exec(t);)s=i[1]}if(!s)return null;try{return new URL(s,e).href}catch{return null}}async function pn(e){let t=at.get(e);if(t)return t;let n=(async()=>{try{let r=new URL(e,location.href);if(r.protocol!==location.protocol||r.host!==location.host)return null;let s=await k(r.href);if(!s.ok)return null;let o=un(r.href,await s.text(),s.headers);if(!o)return null;let i=new URL(o);if(i.protocol!=="data:"&&(i.protocol!==location.protocol||i.host!==location.host))return null;let a=await k(o);if(!a.ok)return null;let l=await a.json();return!l||typeof l.mappings!="string"?null:{sources:l.sources||[],lines:dt(l.mappings)}}catch{return null}})();return at.set(e,n),n}function ct(e){let t=[/^(.*?)((?:[a-z][a-z0-9+.-]*:)?\/\/[^\s)]+|\/[^\s):]+):(\d+):(\d+)(.*)$/];for(let n of t){let r=n.exec(e);if(r)return{prefix:r[1],url:r[2],line:Number(r[3]),col:Number(r[4]),suffix:r[5]}}return null}function fn(e,t,n){let r=null,s=e.lines[t-1];if(s&&s.length>0){for(let i of s)if(i.genCol<=n-1)r=i;else break;r||(r=s[0])}else{for(let i=Math.min(t-1,e.lines.length)-1;i>=0&&!r;i--){let a=e.lines[i];a&&a.length>0&&(r=a[a.length-1])}if(!r)return null}return r.src<0?null:{source:e.sources[r.src]||"",line:r.srcLine+1,col:r.srcCol+1}}async function ne(e){if(!e||!e.includes(".js"))return e;let t=e.split(`
16
+ `}function J(e){let t=[],n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=new TextDecoder,s=0;for(;e.length-s>=4;){let o=n.getUint32(s),i=s+4+o;if(e.length<i+2)break;let a=r.decode(e.subarray(s+4,i)),l=n.getUint16(i);i+=2;let c=!0;for(let p=0;p<l;p++){if(e.length<i+4){c=!1;break}if(i+=4+n.getUint32(i),e.length<i){c=!1;break}}if(!c)break;try{t.push(JSON.parse(a))}catch{}s=i}return{values:t,rest:e.subarray(s)}}function Q(e){let t=e?.data,n=t&&typeof t=="object"?t.stack:void 0;return typeof n=="string"?n:""}function ge(e){let t=e.time?new Date(e.time).toLocaleTimeString():"",n=e.durNs?(e.durNs/1e6>=10?Math.round(e.durNs/1e6):Math.round(e.durNs/1e5)/10)+"ms":"",r=e.code?" "+e.code+(e.message?": "+e.message:""):"";return[t,e.kind,e.fn,n].filter(Boolean).join(" ")+r}function K(e){return!Number.isFinite(e)||e<0?"n/a":e>=1<<30?(e/(1<<30)).toFixed(2)+" GiB":e>=1<<20?(e/(1<<20)).toFixed(1)+" MiB":e>=1024?Math.round(e/1024)+" KiB":Math.round(e)+" B"}function he(){let e=typeof performance<"u"?performance.memory:void 0;return e&&typeof e.usedJSHeapSize=="number"?e.usedJSHeapSize:null}function me(e,t,n){let r=[];if(e&&e.procs){for(let s of e.procs)r.push([s.role+" ("+s.pid+")","PSS "+K(s.pss)+" / private dirty "+K(s.privateDirty)]);e.total&&r.push(["total","PSS "+K(e.total.pss)+" / private dirty "+K(e.total.privateDirty)])}else r.push(["processes","unavailable"]);return r.push(["DOM nodes",String(t)]),r.push(["JS heap",n===null?"unavailable in this engine (see the web process row)":K(n)]),r}var be;function k(e,t){return(be||fetch)(e,t)}var ve=15e3,nn=2e3,ee=class{constructor(){this.list=[]}add(t){this.list.push(t),this.list.length>50&&this.list.shift(),this.onChange?.()}near(t){return this.list.filter(n=>n.t>=t-ve&&n.t<=t+nn)}};function Ue(e){try{let t=new URL(e,typeof location<"u"?location.href:"http://localhost/");return/^\/__krate\//.test(t.pathname)}catch{return!1}}function Je(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){let t=e;if(typeof t.url=="string")return t.url;if(typeof t.href=="string")return t.href}return String(e)}function We(e){try{let t=new URL(e,location.href);return t.origin===location.origin?t.pathname+t.search:t.href}catch{return e}}function Ve(e,t=globalThis){let n=[],r=()=>typeof performance<"u"?performance.now():Date.now(),s=t.fetch;if(typeof s=="function"){be=s.bind(t);let i=function(a,l){let c=Je(a),p=String(l?.method||a&&typeof a=="object"&&a.method||"GET").toUpperCase(),u=r(),f=s.apply(this,arguments);return Ue(c)?f:f.then(g=>{try{g&&g.status>=400&&e.add({method:p,url:c,status:g.status,ms:Math.round(r()-u),t:Date.now()})}catch{}return g},g=>{try{g&&typeof g=="object"&&g.name==="AbortError"||e.add({method:p,url:c,status:0,error:g instanceof Error?g.message:String(g),ms:Math.round(r()-u),t:Date.now()})}catch{}throw g})};t.fetch=i,n.push(()=>{t.fetch===i&&(t.fetch=s),be=void 0})}let o=t.XMLHttpRequest;if(typeof o=="function"&&o.prototype){let i=o.prototype,a=i.open,l=i.send;i.open=function(c,p){return this.__kdReq={method:String(c||"GET").toUpperCase(),url:Je(p)},a.apply(this,arguments)},i.send=function(){let c=this.__kdReq;if(c&&!Ue(c.url)){let p=r(),u=!1,f=g=>{if(!u){u=!0;try{let v=g?0:Number(this.status)||0;(g||v>=400||v===0)&&e.add({method:c.method,url:c.url,status:v,error:g||(v===0?"network error":void 0),ms:Math.round(r()-p),t:Date.now()})}catch{}}};this.addEventListener("load",()=>f()),this.addEventListener("error",()=>f("network error")),this.addEventListener("timeout",()=>f("timed out"))}return l.apply(this,arguments)},n.push(()=>{i.open=a,i.send=l})}return()=>{for(let i of n.splice(0))i()}}var rn="__krate_cfg__";function Ge(){let e=globalThis;if(e.__KRATE_CFG__)return e.__KRATE_CFG__;let t=e.document,n=t&&typeof t.getElementById=="function"?t.getElementById(rn):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return e.__KRATE_CFG__=r,r}catch{}return{}}function Xe(){try{return location.protocol==="krate:"||location.origin==="https://app.localhost"}catch{return!1}}function Ze(){let e=window.__KRATE_DEV__,t=Ge(),n=Xe();return{standalone:!!e?.standalone,sse:e?.sse??"/__krate/hotreload",frames:e?.frames??(n?"/__krate/hmr":""),events:e?.events??(n?"/__krate/dev/events":""),memory:e?.memory??(n?"/__krate/dev/memory":""),errors:e?.errors??(n?"/__krate/dev/client-error":"/__krate/client-error"),open:e?.open??"/__krate/open",api:e?.api??"",version:e?.version??"",overlay:e?.overlay??!0,toolbar:e?.toolbar??!0,basePath:e?.basePath??t?.basePath??"",page:e?.page}}function d(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(e){return d(e).replace(/`([^`]+)`/g,"<code>$1</code>")}function $e(e){return e.replace(/\/+$/,"")||"/"}function sn(e,t){if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function te(e,t,n=""){let r=$e(sn(t,n)).split("/"),s=$e(e).split("/");for(let o=0;o<s.length;o++){let i=s[o];if(i.charAt(0)==="["){if(i.indexOf("[...")===0)return!0;continue}if(i!==r[o])return!1}return r.length===s.length}function ke(e){if(e instanceof Error)return e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function y(e){if(!e||e<0)return"0";let t=e/1024;return t>=100?String(Math.round(t)):t.toFixed(1).replace(/\.0$/,"")}function C(e){return e===void 0||!Number.isFinite(e)?"":e<10?e.toFixed(1)+"ms":e<1e3?Math.round(e)+"ms":(e/1e3).toFixed(e<1e4?1:0)+"s"}function E(e){let t=new Date(e),n=r=>String(r).padStart(2,"0");return n(t.getHours())+":"+n(t.getMinutes())+":"+n(t.getSeconds())}function A(e){let t=e.replace(/\\/g,"/").lastIndexOf("/");return t===-1?e:e.slice(t+1)}function Ye(e){let t=e.replace(/\\/g,"/"),n=t.lastIndexOf("/");return n===-1?"":t.slice(0,n+1)}function x(e,t,n=t+"s"){return e+" "+(e===1?t:n)}function j(){try{let e=navigator,t=e.userAgentData?.platform||e.platform||e.userAgent||"";return/mac|iphone|ipad/i.test(t)}catch{return!1}}function Qe(e,t){let n=typeof e.composedPath=="function"?e.composedPath():[],r=n[0]||e.target;if(!r||!r.tagName||t&&n.includes(t))return!1;let s=r.tagName;if(s==="TEXTAREA"||s==="SELECT")return!0;if(s==="INPUT"){let o=(r.type||"text").toLowerCase();return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(o)}return r.isContentEditable===!0||r.getAttribute?.("contenteditable")==="true"}async function _(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;opacity:0;left:-9999px",document.body.appendChild(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}var xe={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}}};var tt="krate:dev-overlay",on={corner:"bl",theme:"system",editor:"",openOnRuntime:!0,consoleIssues:!0,showWarnings:!0,collapsed:!0},an=["bl","br","tl","tr"],ln=["system","dark","light"];function nt(){let e={...on};try{let t=JSON.parse(xe.get(tt)||"{}");an.includes(t.corner)&&(e.corner=t.corner),ln.includes(t.theme)&&(e.theme=t.theme),typeof t.editor=="string"&&/^[\w.-]{0,40}$/.test(t.editor)&&(e.editor=t.editor);for(let n of["openOnRuntime","consoleIssues","showWarnings","collapsed"])typeof t[n]=="boolean"&&(e[n]=t[n])}catch{}return e}function rt(e){xe.set(tt,JSON.stringify(e))}function st(e,t,n,r){return(t<r/2?"t":"b")+(e<n/2?"l":"r")}function ot(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;switch(e.code){case"KeyK":return"menu";case"KeyI":return"inspect";case"KeyE":return"issues";case"Period":return"hide"}return null}var et={Alt:"option",Mod:"command",Shift:"arrow-big-up",Enter:"corner-down-left"},dn={Alt:"Alt",Mod:"Ctrl",Shift:"Shift",Enter:"Enter"};function it(e,t=j()){return t&&et[e]?b(et[e]):d(dn[e]||e)}function D(e,t=j()){return'<span class="kbd">'+e.map(n=>it(n,t)).join(t?"":" ")+"</span>"}function N(e,t=j()){return e.map(n=>'<span class="kbd">'+it(n,t)+"</span>").join("")}var cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function lt(e){let t=[],n=0,r=0;for(let s=0;s<e.length;s++){let o=cn.indexOf(e[s]);if(o===-1)continue;let i=(o&32)!==0;if(r+=(o&31)<<n,i){n+=5;continue}let a=(r&1)===1;r>>=1,t.push(a?-r:r),r=0,n=0}return t}function dt(e){let t=[],n=0,r=0,s=0;for(let o of e.split(";")){let i=[],a=0;if(o)for(let l of o.split(",")){if(!l)continue;let c=lt(l);a+=c[0]||0,c.length===1?i.push({genCol:a,src:-1,srcLine:0,srcCol:0}):c.length>=4&&(n+=c[1],r+=c[2],s+=c[3],i.push({genCol:a,src:n,srcLine:r,srcCol:s}))}t.push(i)}return t}var at=new Map;function un(e,t,n){let r=n?.get("SourceMap")||n?.get("X-SourceMap"),s=r?r.trim():"";if(!s){let o=/\/[/*][#@]\s*sourceMappingURL=([^\s'"*]+)/g,i;for(;i=o.exec(t);)s=i[1]}if(!s)return null;try{return new URL(s,e).href}catch{return null}}async function pn(e){let t=at.get(e);if(t)return t;let n=(async()=>{try{let r=new URL(e,location.href);if(r.protocol!==location.protocol||r.host!==location.host)return null;let s=await k(r.href);if(!s.ok)return null;let o=un(r.href,await s.text(),s.headers);if(!o)return null;let i=new URL(o);if(i.protocol!=="data:"&&(i.protocol!==location.protocol||i.host!==location.host))return null;let a=await k(o);if(!a.ok)return null;let l=await a.json();return!l||typeof l.mappings!="string"?null:{sources:l.sources||[],lines:dt(l.mappings)}}catch{return null}})();return at.set(e,n),n}function ct(e){let t=[/^(.*?)((?:[a-z][a-z0-9+.-]*:)?\/\/[^\s)]+|\/[^\s):]+):(\d+):(\d+)(.*)$/];for(let n of t){let r=n.exec(e);if(r)return{prefix:r[1],url:r[2],line:Number(r[3]),col:Number(r[4]),suffix:r[5]}}return null}function fn(e,t,n){let r=null,s=e.lines[t-1];if(s&&s.length>0){for(let i of s)if(i.genCol<=n-1)r=i;else break;r||(r=s[0])}else{for(let i=Math.min(t-1,e.lines.length)-1;i>=0&&!r;i--){let a=e.lines[i];a&&a.length>0&&(r=a[a.length-1])}if(!r)return null}return r.src<0?null:{source:e.sources[r.src]||"",line:r.srcLine+1,col:r.srcCol+1}}async function ne(e){if(!e||!e.includes(".js"))return e;let t=e.split(`
17
17
  `);return(await Promise.all(t.map(async r=>{let s=ct(r);if(!s)return r;let o=await pn(s.url);if(!o)return r;let i=fn(o,s.line,s.col);return!i||!i.source||i.source==="krate-hydration.js"?r:s.prefix+i.source+":"+i.line+":"+i.col+s.suffix}))).join(`
18
18
  `)}var gn=`
19
19
  --kd-bg:#101013;--kd-raise:#16161a;--kd-raise2:#1d1d22;--kd-hover:rgba(255,255,255,.05);
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var m=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},K=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of q(t))!I.call(e,o)&&o!==n&&m(e,o,{get:()=>t[o],enumerable:!(r=F(t,o))||r.enumerable});return e};var G=e=>K(m({},"__esModule",{value:!0}),e);var ae={};M(ae,{forbidden:()=>C,krateLayoutSegments:()=>$,krateMarkPrerenderUnknown:()=>R,krateMatchParams:()=>W,krateResetNavigation:()=>Y,krateRouteStore:()=>X,notFound:()=>v,permanentRedirect:()=>ie,redirect:()=>se,unauthorized:()=>A,useParams:()=>ee,usePathname:()=>Z,useRouter:()=>ne,useSearchParams:()=>Q,useSelectedLayoutSegment:()=>oe,useSelectedLayoutSegments:()=>re});var T=window.createSignal;var c=window.krateDerived;var J=Symbol.for("krate.request.store");function i(){let e=globalThis[J];return e&&typeof e.getStore=="function"?e.getStore():void 0}function v(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function E(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function C(){return E(403)}function A(){return E(401)}var ge=64*1024*1024;function S(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},r=[];for(let o of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!s){r.push(o);continue}let u=n[s[3]];u!==void 0&&u!==""&&r.push(...u.split("/").filter(Boolean))}return{path:"/"+r.join("/"),route:t,params:n}}function w(e){try{return decodeURIComponent(e)}catch{return e}}function O(){return S().path}function N(){let e=i(),t=new URLSearchParams;for(let[n,r]of Object.entries(e&&e.searchParams||{}))t.append(n,String(r));return t}function D(){let{route:e,params:t}=S(),n={};for(let r of e.split("/").filter(Boolean)){let o=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!o)continue;let s=t[o[3]];s===void 0||s===""||(n[o[3]]=o[2]?s.split("/").filter(Boolean).map(w):w(s))}return n}function f(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function P(){return{push:f("push"),replace:f("replace"),back:f("back"),forward:f("forward"),refresh:f("refresh"),prefetch:()=>{}}}function x(e,t){return S().path.split("/").filter(Boolean).map(w).slice(typeof t=="number"?t:0)}function L(e,t){let n=x(e,t);return n.length>0?n[0]:null}var B=window.getNavigationState,k=window.subscribeNavigation,a=window.krateRouter;function V(){let e=globalThis.__KRATE_ROUTE__;if(typeof e=="string")return e;if(typeof document>"u")return"";let t=document.getElementById("__krate_page");if(!t)return"";try{let n=JSON.parse(t.textContent||"{}");return typeof n.r=="string"?n.r:""}catch{return""}}function H(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}function z(){let e=globalThis.__KRATE_PRERENDER__;return e&&typeof e.pathname=="string"?{pathname:H(e.pathname),search:"",route:typeof e.route=="string"?e.route:""}:(R(),{pathname:"/",search:"",route:""})}function R(){typeof location<"u"||(globalThis.__KRATE_PRERENDER_NAV_UNKNOWN__=!0)}function y(){if(typeof location>"u")return z();let{pathname:e,search:t}=B();return{pathname:H(e),search:t,route:V()}}var p=null;function g(){if(p)return p;let[e,t]=T(y());if(p=e,typeof window<"u"){let n=()=>{let r=y(),o=e();(r.pathname!==o.pathname||r.search!==o.search||r.route!==o.route)&&t(r)};k(n),window.addEventListener("krate:navigate-end",n)}return e}function X(){let e=null;return{subscribe:r=>{let o=k(r);return typeof window<"u"&&window.addEventListener("krate:navigate-end",r),()=>{o(),typeof window<"u"&&window.removeEventListener("krate:navigate-end",r)}},getSnapshot:()=>{let r=y();return e&&e.pathname===r.pathname&&e.search===r.search&&e.route===r.route?e:(e=r,r)}}}function W(e,t){return U(e,t)}function $(e,t){return e.split("/").filter(Boolean).map(d).slice(typeof t=="number"?t:0)}function Y(){p=null}function l(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function Z(){if(i())return O();let e=g(),t=c(()=>e().pathname);return l(t,()=>t())}function Q(){if(i())return N();R();let e=g(),t=c(()=>new URLSearchParams(e().search));return l(t,()=>e().search)}function d(e){try{return decodeURIComponent(e)}catch{return e}}function U(e,t){let n={};if(!e)return n;let r=e.split("/").filter(Boolean),o=t.split("/").filter(Boolean);for(let s=0;s<r.length;s++){let u=r[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(u);if(!h)continue;let b=h[3];if(h[2]){let _=o.slice(s).map(d);return _.length>0&&(n[b]=_),n}s<o.length&&(n[b]=d(o[s]))}return n}function ee(){if(i())return D();let e=g(),t=c(()=>{let n=e();return U(n.route,n.pathname)});return l(t,()=>JSON.stringify(t()))}var te={push:(e,t)=>{a.push(e,t)},replace:(e,t)=>{a.replace(e,t)},back:()=>a.back(),forward:()=>a.forward(),refresh:()=>{a.refresh()},prefetch:e=>{a.prefetch(e)}};function ne(){return i()?P():te}function re(e,t){if(i())return x(e,t);let n=g(),r=typeof t=="number"?t:0,o=c(()=>n().pathname.split("/").filter(Boolean).map(d).slice(r));return l(o,()=>o().join("/"))}function oe(e,t){if(i())return L(e,t);let n=g(),r=typeof t=="number"?t:0,o=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(d);return s.length>r?s[r]:null});return l(o,()=>String(o()))}function se(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function ie(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t.__krateRedirectStatus=308,t}return G(ae);})();
1
+ var __krate_exports=(()=>{var m=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},J=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of M(t))!K.call(e,o)&&o!==n&&m(e,o,{get:()=>t[o],enumerable:!(r=I(t,o))||r.enumerable});return e};var V=e=>J(m({},"__esModule",{value:!0}),e);var fe={};G(fe,{forbidden:()=>D,krateCurrentRoute:()=>Y,krateLayoutSegments:()=>Q,krateMarkPrerenderUnknown:()=>v,krateMatchParams:()=>Z,krateResetNavigation:()=>ee,krateRouteStore:()=>$,notFound:()=>N,permanentRedirect:()=>ue,redirect:()=>ce,unauthorized:()=>L,useParams:()=>re,usePathname:()=>te,useRouter:()=>se,useSearchParams:()=>ne,useSelectedLayoutSegment:()=>ae,useSelectedLayoutSegments:()=>ie});var O=window.createSignal;var c=window.krateDerived;var j=Symbol.for("krate.request.store");function i(){let e=globalThis[j];return e&&typeof e.getStore=="function"?e.getStore():void 0}function N(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function P(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function D(){return P(403)}function L(){return P(401)}var he=64*1024*1024;function S(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},r=[];for(let o of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!s){r.push(o);continue}let f=n[s[3]];f!==void 0&&f!==""&&r.push(...f.split("/").filter(Boolean))}return{path:"/"+r.join("/"),route:t,params:n}}function w(e){try{return decodeURIComponent(e)}catch{return e}}function x(){return S().path}function k(){let e=i(),t=new URLSearchParams;for(let[n,r]of Object.entries(e&&e.searchParams||{}))t.append(n,String(r));return t}function y(){let{route:e,params:t}=S(),n={};for(let r of e.split("/").filter(Boolean)){let o=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!o)continue;let s=t[o[3]];s===void 0||s===""||(n[o[3]]=o[2]?s.split("/").filter(Boolean).map(w):w(s))}return n}function d(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function B(){return{push:d("push"),replace:d("replace"),back:d("back"),forward:d("forward"),refresh:d("refresh"),prefetch:()=>{}}}function R(e,t){return S().path.split("/").filter(Boolean).map(w).slice(typeof t=="number"?t:0)}function H(e,t){let n=R(e,t);return n.length>0?n[0]:null}var U=window.getNavigationState,b=window.subscribeNavigation,a=window.krateRouter;function X(){let e=globalThis.__KRATE_ROUTE__;if(typeof e=="string")return e;if(typeof document>"u")return"";let t=document.getElementById("__krate_page");if(!t)return"";try{let n=JSON.parse(t.textContent||"{}");return typeof n.r=="string"?n.r:""}catch{return""}}function q(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}function W(){let e=globalThis.__KRATE_PRERENDER__;return e&&typeof e.pathname=="string"?{pathname:q(e.pathname),search:"",route:typeof e.route=="string"?e.route:""}:(v(),{pathname:"/",search:"",route:""})}function v(){typeof location<"u"||(globalThis.__KRATE_PRERENDER_NAV_UNKNOWN__=!0)}function T(){if(typeof location>"u")return W();let{pathname:e,search:t}=U();return{pathname:q(e),search:t,route:X()}}var p=null;function u(){if(p)return p;let[e,t]=O(T());if(p=e,typeof window<"u"){let n=()=>{let r=T(),o=e();(r.pathname!==o.pathname||r.search!==o.search||r.route!==o.route)&&t(r)};b(n),window.addEventListener("krate:navigate-end",n)}return e}function $(){let e=null;return{subscribe:r=>{let o=b(r);return typeof window<"u"&&window.addEventListener("krate:navigate-end",r),()=>{o(),typeof window<"u"&&window.removeEventListener("krate:navigate-end",r)}},getSnapshot:()=>{let r=T();return e&&e.pathname===r.pathname&&e.search===r.search&&e.route===r.route?e:(e=r,r)}}}var F="",_=null;function Y(){if(i()){let n=y();return{pathname:x(),search:k().toString(),params:n}}let e=u()(),t=e.pathname+"\0"+e.search+"\0"+e.route;return(!_||t!==F)&&(F=t,_={pathname:e.pathname,search:e.search.replace(/^\?/,""),params:E(e.route,e.pathname)}),_}function Z(e,t){return E(e,t)}function Q(e,t){return e.split("/").filter(Boolean).map(g).slice(typeof t=="number"?t:0)}function ee(){p=null}function l(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function te(){if(i())return x();let e=u(),t=c(()=>e().pathname);return l(t,()=>t())}function ne(){if(i())return k();v();let e=u(),t=c(()=>new URLSearchParams(e().search));return l(t,()=>e().search)}function g(e){try{return decodeURIComponent(e)}catch{return e}}function E(e,t){let n={};if(!e)return n;let r=e.split("/").filter(Boolean),o=t.split("/").filter(Boolean);for(let s=0;s<r.length;s++){let f=r[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(f);if(!h)continue;let C=h[3];if(h[2]){let A=o.slice(s).map(g);return A.length>0&&(n[C]=A),n}s<o.length&&(n[C]=g(o[s]))}return n}function re(){if(i())return y();let e=u(),t=c(()=>{let n=e();return E(n.route,n.pathname)});return l(t,()=>JSON.stringify(t()))}var oe={push:(e,t)=>{a.push(e,t)},replace:(e,t)=>{a.replace(e,t)},back:()=>a.back(),forward:()=>a.forward(),refresh:()=>{a.refresh()},prefetch:e=>{a.prefetch(e)}};function se(){return i()?B():oe}function ie(e,t){if(i())return R(e,t);let n=u(),r=typeof t=="number"?t:0,o=c(()=>n().pathname.split("/").filter(Boolean).map(g).slice(r));return l(o,()=>o().join("/"))}function ae(e,t){if(i())return H(e,t);let n=u(),r=typeof t=="number"?t:0,o=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(g);return s.length>r?s[r]:null});return l(o,()=>String(o()))}function ce(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function ue(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t.__krateRedirectStatus=308,t}return V(fe);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -271,6 +271,7 @@
271
271
  "krateCondSwap",
272
272
  "krateContextRows",
273
273
  "krateControl",
274
+ "krateCurrentRoute",
274
275
  "krateCurrentScope",
275
276
  "krateCustomProp",
276
277
  "krateDepsOf",
@@ -462,6 +463,7 @@
462
463
  "file": "krate-f-navigation.js",
463
464
  "exports": [
464
465
  "forbidden",
466
+ "krateCurrentRoute",
465
467
  "krateLayoutSegments",
466
468
  "krateMarkPrerenderUnknown",
467
469
  "krateMatchParams",
@@ -857,6 +859,7 @@
857
859
  ],
858
860
  "navigation.js": [
859
861
  "forbidden",
862
+ "krateCurrentRoute",
860
863
  "krateLayoutSegments",
861
864
  "krateMarkPrerenderUnknown",
862
865
  "krateMatchParams",