yvee 0.1.6 → 0.1.7
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.
- package/README.md +46 -18
- package/dist/index-k6eg1j41.js +3 -0
- package/dist/index.d.ts +90 -5
- package/dist/index.js +2 -2
- package/dist/jsx-runtime.js +2 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Yvee is a TypeScript UI framework with reactive state, a TSX renderer, browser
|
|
4
4
|
element helpers, client-side routing and guards, server-side rendering, and
|
|
5
5
|
browser storage and network helpers. It ships as one dependency-free package,
|
|
6
|
-
`yvee@0.1.
|
|
6
|
+
`yvee@0.1.7`.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -25,20 +25,20 @@ After changing Yvee source, rebuild the package so consumers that import the
|
|
|
25
25
|
build see the new code and declarations. Restart the consumer's dev server when
|
|
26
26
|
its bundler caches linked dependencies.
|
|
27
27
|
|
|
28
|
-
The package exposes
|
|
29
|
-
`
|
|
28
|
+
The package exposes its root entry and the JSX runtime subpaths through the
|
|
29
|
+
`exports` map: `yvee`, `yvee/jsx-runtime` and `yvee/jsx-dev-runtime`. Source
|
|
30
|
+
folders are not stable package subpaths.
|
|
30
31
|
|
|
31
32
|
## TypeScript and TSX setup
|
|
32
33
|
|
|
33
|
-
Yvee
|
|
34
|
-
`.tsx` extension and
|
|
34
|
+
Yvee uses the automatic JSX runtime, so `.tsx` files need **no import** for
|
|
35
|
+
JSX. Add a `.tsx` extension and point TypeScript (and Bun 1.4+) at Yvee:
|
|
35
36
|
|
|
36
37
|
```json
|
|
37
38
|
{
|
|
38
39
|
"compilerOptions": {
|
|
39
|
-
"jsx": "react",
|
|
40
|
-
"
|
|
41
|
-
"jsxFragmentFactory": "frag",
|
|
40
|
+
"jsx": "react-jsx",
|
|
41
|
+
"jsxImportSource": "yvee",
|
|
42
42
|
"moduleResolution": "bundler",
|
|
43
43
|
"module": "esnext",
|
|
44
44
|
"target": "esnext",
|
|
@@ -47,9 +47,37 @@ Yvee's TSX elements use its `dom` factory and `frag` fragment factory. Add a
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
Bun 1.4+ is recommended because its transpiler and `Bun.build` honor the same
|
|
51
|
+
`jsx` settings. Oven users can forward them explicitly with the optional
|
|
52
|
+
`jsx` and `tsconfig` build options.
|
|
53
|
+
|
|
54
|
+
### JSX runtime exports
|
|
55
|
+
|
|
56
|
+
`yvee/jsx-runtime` exports `jsx`, `jsxs` and `Fragment`;
|
|
57
|
+
`yvee/jsx-dev-runtime` exports `jsxDEV` and `Fragment`. TypeScript and Bun
|
|
58
|
+
select the right module from `jsxImportSource` and the build mode, so you never
|
|
59
|
+
import these by hand. The component contract is unchanged: components receive
|
|
60
|
+
`(props, ...children)`, children are never on `props`, and a `key` passed in
|
|
61
|
+
JSX stays in the attribute object (classic parity).
|
|
62
|
+
|
|
63
|
+
Classic JSX factories remain supported for existing code. To keep using them,
|
|
64
|
+
set `"jsx": "react"`, `"jsxFactory": "dom"` and
|
|
65
|
+
`"jsxFragmentFactory": "frag"`, then import `dom`/`frag` from `"yvee"` in TSX
|
|
66
|
+
modules:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"compilerOptions": {
|
|
71
|
+
"jsx": "react",
|
|
72
|
+
"jsxFactory": "dom",
|
|
73
|
+
"jsxFragmentFactory": "frag"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A consuming bundler must compile TypeScript/TSX and include Yvee's browser code
|
|
79
|
+
in its client bundle. Yvee does not currently ship a framework-specific CLI or
|
|
80
|
+
bundler plugin.
|
|
53
81
|
|
|
54
82
|
## Quick start
|
|
55
83
|
|
|
@@ -57,7 +85,7 @@ Pages are classes decorated with a route path. Register them on an app and
|
|
|
57
85
|
mount it into an element that already exists in the host HTML:
|
|
58
86
|
|
|
59
87
|
```tsx
|
|
60
|
-
import { Page, Yvee,
|
|
88
|
+
import { Page, Yvee, route } from "yvee";
|
|
61
89
|
|
|
62
90
|
@route("/")
|
|
63
91
|
class HomePage extends Page {
|
|
@@ -88,7 +116,7 @@ const unmount = await app.render({ id: "app-root" });
|
|
|
88
116
|
State values can be read directly by DOM children and supported attributes:
|
|
89
117
|
|
|
90
118
|
```tsx
|
|
91
|
-
import { State
|
|
119
|
+
import { State } from "yvee";
|
|
92
120
|
|
|
93
121
|
const count = State(0);
|
|
94
122
|
const button = (
|
|
@@ -105,11 +133,11 @@ new Yvee({ base: "/my-project/", client: "/my-project/client.js" });
|
|
|
105
133
|
|
|
106
134
|
## Component authoring
|
|
107
135
|
|
|
108
|
-
A Yvee component is a function called by
|
|
136
|
+
A Yvee component is a function called by the renderer. Attributes are its first
|
|
109
137
|
argument; **JSX children are rest arguments**:
|
|
110
138
|
|
|
111
139
|
```tsx
|
|
112
|
-
import {
|
|
140
|
+
import type { DOMContext } from "yvee";
|
|
113
141
|
|
|
114
142
|
function Card(props: { title: string }, ...children: DOMContext[]) {
|
|
115
143
|
return (
|
|
@@ -127,9 +155,9 @@ const view = (
|
|
|
127
155
|
);
|
|
128
156
|
```
|
|
129
157
|
|
|
130
|
-
> **Children are not on `props`.** Because
|
|
131
|
-
> rest arguments, `props.children` is always `undefined`, and rendering
|
|
132
|
-
> silently drops the children. Type the props parameter as your own props
|
|
158
|
+
> **Children are not on `props`.** Because the renderer forwards JSX children
|
|
159
|
+
> only as rest arguments, `props.children` is always `undefined`, and rendering
|
|
160
|
+
> it silently drops the children. Type the props parameter as your own props
|
|
133
161
|
> object and render the `...children` rest parameter instead. (`DOMComponent`
|
|
134
162
|
> and `DOMComponentProps` describe this shape for typed components.)
|
|
135
163
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var f=(t)=>typeof t==="boolean",r=(t)=>Array.isArray(t),o=(t)=>typeof t==="function",s=(t)=>t!==null&&typeof t==="object",i=(t)=>s(t)&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null);class e extends Map{obj(t){if(t)Object.entries(t).forEach(([x,O])=>this.set(x,O));return this}init(t,x){if(!this.has(t))this.set(t,x);return this.get(t)}}var u=(t,x)=>{if(!x.has(t))x.set(t,new e);return x.get(t)},a=(t,x)=>{if(!x.has(t))x.set(t,[]);return x.get(t)},h=(t)=>Object.entries(t),c=(t)=>JSON.stringify(t),m=(t)=>{if(t.startsWith("webkit"))t=`-${t}`;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},g=(t)=>Array.from({length:t},(M,b)=>{let D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+(b?"0123456789":"");return D.charAt(Math.floor(Math.random()*D.length))}).join("");class n{tag;attr;ctx;constructor(t,x,O){this.tag=t;this.attr=x;this.ctx=O;if(t&&!/^[A-Za-z][A-Za-z0-9._:-]*$/.test(t))throw TypeError(`Invalid DOM tag name: ${t}`)}}async function l(t,x={},...O){if(o(t))return await t(x??{},...O);return new n(t,x??{},O)}var y=async(t,...x)=>new n("",{},x);function A(t,x,O){let{children:M,...b}=x??{},D=O!=null?{...b,key:O}:b,P=Array.isArray(M)?M:M===void 0?[]:[M];return l(t,D,...P)}function d(t,x,O){return A(t,x,O)}function p(t,x,O){return A(t,x,O)}function w(t,x,O,M,b,D){return A(t,x,O)}function v(t,...x){return y(t??{},...x)}
|
|
3
|
+
export{f,r,o,s,i,e,u,a,h,c,m,g,n,l,y,d,p,w,v};
|
package/dist/index.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ declare class Elem<T extends Elements = HTMLElement> extends Eget<T> {
|
|
|
101
101
|
animate(keyframes: KFType, onComplete?: fn<any, void>): this;
|
|
102
102
|
query(query: string): T | null;
|
|
103
103
|
queryAll(query: string): T[];
|
|
104
|
-
newChild<P>(element: keyof HTMLElementTagNameMap, props?: Record<string, P>): Elem<HTMLElement | HTMLObjectElement | HTMLMapElement | HTMLDataElement | HTMLScriptElement | HTMLStyleElement | HTMLHtmlElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement |
|
|
104
|
+
newChild<P>(element: keyof HTMLElementTagNameMap, props?: Record<string, P>): Elem<HTMLElement | HTMLObjectElement | HTMLMapElement | HTMLLinkElement | HTMLDataElement | HTMLScriptElement | HTMLStyleElement | HTMLHtmlElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement>;
|
|
105
105
|
newChildNS<P>(element: keyof SVGElementTagNameMap, props?: Record<string, P>): Elem<SVGSymbolElement | SVGFilterElement | SVGScriptElement | SVGStyleElement | SVGAElement | SVGTitleElement | SVGAnimateElement | SVGAnimateMotionElement | SVGAnimateTransformElement | SVGCircleElement | SVGClipPathElement | SVGDefsElement | SVGDescElement | SVGEllipseElement | SVGFEBlendElement | SVGFEColorMatrixElement | SVGFEComponentTransferElement | SVGFECompositeElement | SVGFEConvolveMatrixElement | SVGFEDiffuseLightingElement | SVGFEDisplacementMapElement | SVGFEDistantLightElement | SVGFEDropShadowElement | SVGFEFloodElement | SVGFEFuncAElement | SVGFEFuncBElement | SVGFEFuncGElement | SVGFEFuncRElement | SVGFEGaussianBlurElement | SVGFEImageElement | SVGFEMergeElement | SVGFEMergeNodeElement | SVGFEMorphologyElement | SVGFEOffsetElement | SVGFEPointLightElement | SVGFESpecularLightingElement | SVGFESpotLightElement | SVGFETileElement | SVGFETurbulenceElement | SVGForeignObjectElement | SVGGElement | SVGImageElement | SVGLineElement | SVGLinearGradientElement | SVGMarkerElement | SVGMaskElement | SVGMetadataElement | SVGMPathElement | SVGPathElement | SVGPatternElement | SVGPolygonElement | SVGPolylineElement | SVGRadialGradientElement | SVGRectElement | SVGSetElement | SVGStopElement | SVGSVGElement | SVGSwitchElement | SVGTextElement | SVGTextPathElement | SVGTSpanElement | SVGUseElement | SVGViewElement>;
|
|
106
106
|
get<K extends keyof T>(property: K): T[K];
|
|
107
107
|
get(property: string): unknown;
|
|
@@ -1438,11 +1438,11 @@ interface PageFetchContext<TData extends Record<string, unknown>> {
|
|
|
1438
1438
|
resources: DisposalScope;
|
|
1439
1439
|
}
|
|
1440
1440
|
declare class MissingPage extends Page {
|
|
1441
|
-
body():
|
|
1441
|
+
body(): maybePromise<DOM>;
|
|
1442
1442
|
}
|
|
1443
1443
|
declare class FailurePage extends Page {
|
|
1444
1444
|
status: number;
|
|
1445
|
-
body():
|
|
1445
|
+
body(): maybePromise<DOM>;
|
|
1446
1446
|
}
|
|
1447
1447
|
|
|
1448
1448
|
type Constructor<T = object> = new (...args: any[]) => T;
|
|
@@ -1749,7 +1749,79 @@ declare class Yvee<T extends Record<string, unknown> = Record<string, unknown>>
|
|
|
1749
1749
|
private load;
|
|
1750
1750
|
}
|
|
1751
1751
|
|
|
1752
|
+
/**
|
|
1753
|
+
* Automatic JSX runtime for Yvee (`"jsx": "react-jsx"`,
|
|
1754
|
+
* `"jsxImportSource": "yvee"`).
|
|
1755
|
+
*
|
|
1756
|
+
* Bun and TypeScript import `jsx`/`jsxs` from `yvee/jsx-runtime` (or `jsxDEV`
|
|
1757
|
+
* from `yvee/jsx-dev-runtime` in development). JSX children arrive on the
|
|
1758
|
+
* props object here and are forwarded to {@link dom} as rest arguments, so
|
|
1759
|
+
* component authors keep the usual `(props, ...children)` contract. Nothing
|
|
1760
|
+
* needs to be imported in `.tsx` files; classic `dom`/`frag` usage keeps
|
|
1761
|
+
* working unchanged.
|
|
1762
|
+
*/
|
|
1763
|
+
type JsxType = Parameters<typeof dom>[0];
|
|
1764
|
+
type JsxProps = Record<string, unknown> & {
|
|
1765
|
+
children?: DOMContext | DOMContext[] | undefined;
|
|
1766
|
+
};
|
|
1767
|
+
/**
|
|
1768
|
+
* Compile target for a JSX element with zero or one child.
|
|
1769
|
+
*
|
|
1770
|
+
* Bun and TypeScript call this from automatic-runtime output; it renders the
|
|
1771
|
+
* element through {@link dom} and returns the same promise.
|
|
1772
|
+
*/
|
|
1773
|
+
declare function jsx(type: JsxType, props: JsxProps | null, key?: unknown): Promise<DOM>;
|
|
1774
|
+
/**
|
|
1775
|
+
* Compile target for a JSX element with multiple static children.
|
|
1776
|
+
*
|
|
1777
|
+
* Behaves like {@link jsx}: array `children` are forwarded as rest arguments.
|
|
1778
|
+
*/
|
|
1779
|
+
declare function jsxs(type: JsxType, props: JsxProps | null, key?: unknown): Promise<DOM>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Development-runtime compile target.
|
|
1782
|
+
*
|
|
1783
|
+
* Identical to {@link jsx}; the source/self debugging arguments are accepted
|
|
1784
|
+
* for compatibility and ignored.
|
|
1785
|
+
*/
|
|
1786
|
+
declare function jsxDEV(type: JsxType, props: JsxProps | null, key?: unknown, _isStatic?: boolean, _source?: unknown, _self?: unknown): Promise<DOM>;
|
|
1787
|
+
/**
|
|
1788
|
+
* JSX fragment component (`<>…</>`).
|
|
1789
|
+
*
|
|
1790
|
+
* Null or omitted attributes are accepted because the automatic runtime does
|
|
1791
|
+
* not pass a props object for fragments.
|
|
1792
|
+
*/
|
|
1793
|
+
declare function Fragment(attr?: DOMAttr | null, ...ctx: DOMContext[]): Promise<DOM>;
|
|
1794
|
+
/**
|
|
1795
|
+
* JSX types resolved by TypeScript from the `jsxImportSource` module when the
|
|
1796
|
+
* automatic runtime is enabled.
|
|
1797
|
+
*
|
|
1798
|
+
* Mirrors the global `JSX` namespace declared by the renderer.
|
|
1799
|
+
*/
|
|
1800
|
+
declare namespace JSX {
|
|
1801
|
+
type Element = maybePromise<DOM>;
|
|
1802
|
+
interface IntrinsicElements extends ElementAttributes, SVGAttributes {
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Allows JSX children on components whose props type does not declare
|
|
1806
|
+
* `children`.
|
|
1807
|
+
*
|
|
1808
|
+
* The automatic runtime type-checker merges children into the attribute
|
|
1809
|
+
* object; Yvee forwards them to components as rest arguments, never on
|
|
1810
|
+
* `props`, so this only satisfies the attribute merge.
|
|
1811
|
+
*/
|
|
1812
|
+
interface IntrinsicAttributes {
|
|
1813
|
+
children?: unknown;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1752
1817
|
declare const REGION_LEVEL: unique symbol;
|
|
1818
|
+
/** Metadata `regionTree` records for one level id. */
|
|
1819
|
+
interface RegionLevelMetadata {
|
|
1820
|
+
/** View rendered by the bare level id. */
|
|
1821
|
+
readonly defaultView: string;
|
|
1822
|
+
/** Declared view segments, in declaration order. */
|
|
1823
|
+
readonly views: readonly string[];
|
|
1824
|
+
}
|
|
1753
1825
|
/** Context passed to a level chrome module. */
|
|
1754
1826
|
interface RegionChromeContext {
|
|
1755
1827
|
/** Page that owns the region. */
|
|
@@ -1802,8 +1874,21 @@ declare function regionLevel(options: RegionLevelOptions): RegionLevel;
|
|
|
1802
1874
|
* `Page.regions` expects. Plain loaders are copied through unchanged; each
|
|
1803
1875
|
* `regionLevel` adds its level id (the default view) and one composite
|
|
1804
1876
|
* `<level>/<view>` id per view, all rendered inside the level chrome.
|
|
1877
|
+
*
|
|
1878
|
+
* Level ids and default views are recorded on the result and are readable
|
|
1879
|
+
* through `regionLevelIds` and `defaultViewFor`; they never appear as keys.
|
|
1805
1880
|
*/
|
|
1806
1881
|
declare function regionTree(entries: Record<string, RegionLoader | RegionLevel>): Record<string, RegionLoader>;
|
|
1882
|
+
/**
|
|
1883
|
+
* Level ids recorded by `regionTree`, in declaration order; empty for maps
|
|
1884
|
+
* without level metadata (such as hand-built `Page.regions`).
|
|
1885
|
+
*/
|
|
1886
|
+
declare function regionLevelIds(regions: Record<string, RegionLoader>): readonly string[];
|
|
1887
|
+
/**
|
|
1888
|
+
* Default view of a level id from `regionTree`, or `undefined` for non-level
|
|
1889
|
+
* or unknown ids.
|
|
1890
|
+
*/
|
|
1891
|
+
declare function defaultViewFor(regions: Record<string, RegionLoader>, regionId: string): string | undefined;
|
|
1807
1892
|
|
|
1808
1893
|
/**
|
|
1809
1894
|
* `true` when the module is evaluated in a browser (a global `window` exists).
|
|
@@ -1983,5 +2068,5 @@ declare function renderJSONScript(value: unknown, options: {
|
|
|
1983
2068
|
nonce?: string;
|
|
1984
2069
|
}): string;
|
|
1985
2070
|
|
|
1986
|
-
export { $, ATTR, BrowserStore, Column, DOM, DbRepository, Derived, DisposalScope, Elem, EventStream, FailurePage, Field, HTTPError, HeadDefaults, IDNotConnected, IndexedDatabase, MissingPage, Page, QState, RecState, RecStateful, Ref, RefState, RouteBook, Schema, Scope, SetState, SetStateful, SocketController, SocketHub, State, StateEffect, StateHook, StateLoaded, Stateful, Stored, StoredValue, Toggled, VersionedValue, Yvee, allGuards, applyHead, attr_value, batch, buildReturnTo, createGuard, dom, error, eventStream, eventStreams, frag, getElementById, hook, interpolate, isClient, loaded, local, normalizePath, page, paramsGuard, readCookie, readReturnTo, regionLevel, regionTree, renderContent, renderDom, renderJSONScript, requestForm, requestJSON, requireGuard, route, serializePayload, session, setContentRenderer, shallowEqual, socketRoute, t, toURL, use, useRef, whenGuard };
|
|
1987
|
-
export type { $_, CSSStyle, Cleanup, ColumnType, Constructor, ContentRenderer, ContextGuard, CsrfOptions, DOMAttr, DOMComponent, DOMComponentProps, DOMContext, DOMEvents, DOMNode, DOMRenderable, DOMValue, DVal, DerivedOptions, DerivedValue, Disposable, EAttr, ElementAttributes, Elements, Equality, EventMap, FieldScopeSet, FormRequestOptions, FormResult, Guard, GuardApp, GuardContext, GuardContextInput, GuardFactory, GuardFallback, GuardPredicate, GuardRedirect, GuardRejection, GuardResult, HeadConfig, HeadResult, IRecStateful, ISetStateful, IStateful, JSONRequestOptions, JsonMessageOptions, Layout, MessageFailure, MountOptions, OpenOptions, PageFetchContext, RegionCache, RegionChromeContext, RegionChromeLoader, RegionChromeModule, RegionEnterContext, RegionGuard, RegionGuardContext, RegionLeaveContext, RegionLevel, RegionLevelOptions, RegionLoader, RegionModule, RenderResult, RenderedContent, RenderedDOM, RequestRetry, RouteEntry, SVGAttributes, ScopeDecorator, ScopeProxy, ScopeSet, ServerDataContext, ServerOptions, ServerRenderer, ServerRequest, ServerStatusResult, SocketConnectionState, SocketLoadOptions, StateHookOptions, StateOptions, StateUpdate, StorageChange, StorageSchema, StorageWatchOptions, StreamHandlers, StreamOptions, TagNames, Transport, YveeOptions, YveeURL, _$, aAttr, areaAttr, audioAttr, baseAttr, blockquoteAttr, buttonAttr, c_events, canvasAttr, colAttr, colgroupAttr, contenteditableAttr, dataAttr, delAttr, detailsAttr, dialogAttr, embedAttr, errorStatus, fieldsetAttr, formAttr, iframeAttr, imgAttr, inputAttr, insAttr, labelAttr, liAttr, linkAttr, mapAttr, menuAttr, metaAttr, meterAttr, objectAttr, olAttr, optgroupAttr, optionAttr, outputAttr, paramAttr, progressAttr, qAttr, renderedDom, scriptAttr, selectAttr, sourceAttr, statefulValue, styleAttr, successStatus, svgAttr, svgEAttr, svgETextAttr, tdAttr, textareaAttr, thAttr, timeAttr, trackAttr, videoAttr };
|
|
2071
|
+
export { $, ATTR, BrowserStore, Column, DOM, DbRepository, Derived, DisposalScope, Elem, EventStream, FailurePage, Field, Fragment, HTTPError, HeadDefaults, IDNotConnected, IndexedDatabase, JSX, MissingPage, Page, QState, RecState, RecStateful, Ref, RefState, RouteBook, Schema, Scope, SetState, SetStateful, SocketController, SocketHub, State, StateEffect, StateHook, StateLoaded, Stateful, Stored, StoredValue, Toggled, VersionedValue, Yvee, allGuards, applyHead, attr_value, batch, buildReturnTo, createGuard, defaultViewFor, dom, error, eventStream, eventStreams, frag, getElementById, hook, interpolate, isClient, jsx, jsxDEV, jsxs, loaded, local, normalizePath, page, paramsGuard, readCookie, readReturnTo, regionLevel, regionLevelIds, regionTree, renderContent, renderDom, renderJSONScript, requestForm, requestJSON, requireGuard, route, serializePayload, session, setContentRenderer, shallowEqual, socketRoute, t, toURL, use, useRef, whenGuard };
|
|
2072
|
+
export type { $_, CSSStyle, Cleanup, ColumnType, Constructor, ContentRenderer, ContextGuard, CsrfOptions, DOMAttr, DOMComponent, DOMComponentProps, DOMContext, DOMEvents, DOMNode, DOMRenderable, DOMValue, DVal, DerivedOptions, DerivedValue, Disposable, EAttr, ElementAttributes, Elements, Equality, EventMap, FieldScopeSet, FormRequestOptions, FormResult, Guard, GuardApp, GuardContext, GuardContextInput, GuardFactory, GuardFallback, GuardPredicate, GuardRedirect, GuardRejection, GuardResult, HeadConfig, HeadResult, IRecStateful, ISetStateful, IStateful, JSONRequestOptions, JsonMessageOptions, Layout, MessageFailure, MountOptions, OpenOptions, PageFetchContext, RegionCache, RegionChromeContext, RegionChromeLoader, RegionChromeModule, RegionEnterContext, RegionGuard, RegionGuardContext, RegionLeaveContext, RegionLevel, RegionLevelMetadata, RegionLevelOptions, RegionLoader, RegionModule, RenderResult, RenderedContent, RenderedDOM, RequestRetry, RouteEntry, SVGAttributes, ScopeDecorator, ScopeProxy, ScopeSet, ServerDataContext, ServerOptions, ServerRenderer, ServerRequest, ServerStatusResult, SocketConnectionState, SocketLoadOptions, StateHookOptions, StateOptions, StateUpdate, StorageChange, StorageSchema, StorageWatchOptions, StreamHandlers, StreamOptions, TagNames, Transport, YveeOptions, YveeURL, _$, aAttr, areaAttr, audioAttr, baseAttr, blockquoteAttr, buttonAttr, c_events, canvasAttr, colAttr, colgroupAttr, contenteditableAttr, dataAttr, delAttr, detailsAttr, dialogAttr, embedAttr, errorStatus, fieldsetAttr, formAttr, iframeAttr, imgAttr, inputAttr, insAttr, labelAttr, liAttr, linkAttr, mapAttr, menuAttr, metaAttr, meterAttr, objectAttr, olAttr, optgroupAttr, optionAttr, outputAttr, paramAttr, progressAttr, qAttr, renderedDom, scriptAttr, selectAttr, sourceAttr, statefulValue, styleAttr, successStatus, svgAttr, svgEAttr, svgETextAttr, tdAttr, textareaAttr, thAttr, timeAttr, trackAttr, videoAttr };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var Se=(e)=>typeof e==="function",Ut=(e)=>typeof e==="number"&&!Number.isNaN(e),q=Object.assign,$t=(e)=>Object.entries(e),ze=(e)=>{if(e.startsWith("webkit"))e=`-${e}`;return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},Qn=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),jt=(e)=>Qn.has(e.toLowerCase()),_e=(e)=>{if(Array.isArray(e))return e.filter((t)=>t!==void 0).join(" ");if(typeof e==="function")return _e(e());if(e===void 0||e===null)return"";if(typeof e==="boolean")return e?"":"false";if(typeof e==="object")try{return JSON.stringify(e)??""}catch{return String(e)}return String(e)},Nt=(e)=>typeof e==="object"&&e!==null&&("value"in e);var P=(e)=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function M(e,t){if(!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(e))throw TypeError(`Invalid attribute name: ${e}`);let n=e.toLowerCase();if(n.startsWith("on")||n==="srcdoc")throw TypeError(`Executable attribute is not supported: ${e}`);if(t===!1||t==null)return;let r=String(t);if(n==="srcset"||n==="imagesrcset"){if(/data:/i.test(r))throw TypeError("Data URLs are not supported in srcset.");for(let o of r.split(","))Gt(o.trim().split(/\s+/)[0]??"",n)}else if(["href","src","action","formaction","poster","cite","background","xlink:href","data"].includes(n))Gt(r,n)}function Gt(e,t){let n=e.replace(/[\u0000-\u0020\u007f]/g,""),r=/^([a-z][a-z0-9+.-]*):/i.exec(n)?.[1]?.toLowerCase();if(!r||["http","https"].includes(r))return;if((t==="href"||t==="xlink:href")&&["mailto","tel","data"].includes(r))return;if(t==="src"&&/^data:image\/(?:png|gif|jpeg|webp|avif);base64,[a-z0-9+/=]*$/i.test(n))return;throw TypeError(`Unsupported URL scheme in ${t}: ${r}`)}function z(e,t){let n=String(t??"");if(new RegExp(`</${e}(?:[\\t\\n\\f\\r />]|$)`,"i").test(n)||e==="script"&&/<!--|<script[\t\n\f\r />]/i.test(n))throw TypeError(`Unsafe inline ${e} content; use an external file or serializePayload for JSON.`);return n}function qt(e){let t=JSON.stringify(e,(n,r)=>{if(typeof r==="bigint"||typeof r==="function"||typeof r==="symbol"||r===void 0||typeof r==="number"&&!Number.isFinite(r))throw TypeError("Bootstrap payload must contain JSON-serializable values.");return r});if(t===void 0)throw TypeError("Bootstrap payload must be JSON-serializable.");return t.replace(/[<>&\u2028\u2029]/g,(n)=>`\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Ee(e,t){return`<script type="application/json" id="${P(t.id)}"${t.nonce===void 0?"":` nonce="${P(t.nonce)}"`}>${qt(e)}</script>`}class We{e;opt;constructor(e){this.e=e;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(e,t={}){return this.e.e.animate(e,{...this.opt,...t})}get slide(){let e=({x:t=0,y:n=0},r={})=>{q(this.opt,r);let o=[[t,n],[0,0]].map(([i,s])=>({transform:`translateX(${i}rem) translateY(${s}rem)`}));return this.e.animate(o,this.opt),this};return{left:(t={})=>e({x:-2},t),right:(t={})=>e({x:2},t),up:(t={})=>e({y:2},t),down:(t={})=>e({y:-2},t)}}fade(e={}){q(this.opt,e);let t=[0,1].map((n)=>({opacity:n}));return this.e.animate(t,this.opt),this}shake(e="Y",t={}){q(this.opt,t);let n=[0,5,-5,5,0].map((r)=>({transform:`translate${e}(${r}px)`}));return this.e.animate(n,this.opt),this}color(e=[],t={}){q(this.opt,t);let n=Array.isArray(e)?e.map((r)=>({color:r})):{color:e};return this.e.animate(n,this.opt),this}bg(e=[],t={}){q(this.opt,t);let n=Array.isArray(e)?e.map((r)=>({backgroundColor:r})):{backgroundColor:e};return this.e.animate(n,this.opt),this}bounce(e=1,t={}){q(this.opt,t);let n=[0.5,e,1].map((r)=>({transform:`scale(${r})`}));return this.e.animate(n,this.opt),this}}var ae,Yt=(e)=>(ae=e,()=>{if(ae===e)ae=void 0}),Ft=async(e,t)=>{if(ae)return ae(e,t);return{html:(e==null?"":String(e)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};class Je{e;_query;constructor(e,t){this.e=e;this._query=t}get a(){return new We(this)}get all(){if(this._query){let e=document.querySelectorAll(this._query);if(e.length)return Array.from(e).map((t)=>t)}return[]}get attr(){let e=this.e;return{has:(t)=>e.hasAttribute(t),get:(t)=>e.getAttribute(t),del:(t)=>(e.removeAttribute(t),this),set:(t)=>{for(let[n,r]of Object.entries(t)){if(r===void 0)continue;let o=_e(r);if(M(n,o),jt(n)&&typeof r==="boolean")e.toggleAttribute(n,r);else e.setAttribute(n,o)}return this}}}get children(){return Array.from(this.e.children).map((e)=>new U(e))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return"disabled"in this.e?Boolean(this.e.disabled):!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let e=this.e.offsetParent;if(e)return new U(e);return}get parent(){let e=this.e.parentElement;if(e)return new U(e);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let e=this.e.style,t=this;return{set:(n,r=0)=>{let o=e,i=()=>{$t(n).forEach(([s,a])=>{if(a===void 0)return;let u=Nt(a)?a.value:a;if(s in o){if(o[String(s)]!==u)o[String(s)]=u}else if(u!==null)e.setProperty(String(s),String(u));else e.removeProperty(String(s))})};if(Se(r))t.e.addEventListener("transitionend",r,{once:!0});if(Ut(r))setTimeout(i,r);else i();return t},get:(n)=>{let r=ze(String(n));return e.getPropertyValue(r)},del:(...n)=>(n.forEach((r)=>{let o=ze(String(r));e.removeProperty(o)}),t)}}get submit(){if(!(this.e instanceof HTMLFormElement))return!1;return this.e.requestSubmit(),!0}get tag(){return this.e.tagName.toLowerCase()}get value(){return"value"in this.e?this.e.value??"":""}get unload(){return()=>{this.e.remove()}}async updateContent(e,t){let n=await Ft(e,Xn(this.id));if(t==="inner")this.e.innerHTML=n.html;else this.e.insertAdjacentHTML(t,n.html);await n.commit?.()}set append(e){this.updateContent(e,"beforeend")}set appendfirst(e){this.updateContent(e,"afterbegin")}set inner(e){this.updateContent(e,"inner")}set disabled(e){let t=this.e;if("disabled"in t)t.disabled=e}set id(e){this.e.id=e}set value(e){if("value"in this.e)this.e.value=e}}var Xn=(e)=>e?`${e}-0`:e;class U extends Je{add(...e){let t=e.flatMap((n)=>n.trim().split(/\s+/)).filter(Boolean);if(t.length)this.e.classList.add(...t);return()=>{if(t.length)this.e.classList.remove(...t)}}remove(...e){let t=e.flatMap((n)=>n.trim().split(/\s+/)).filter(Boolean);if(t.length)this.e.classList.remove(...t);return this}toggle(e,t){let n=typeof e!="string"?e.apply(this):e;return this.e.classList.toggle(n,t)}toggled(e,t){if(e)this.add(t);else this.remove(t);return this}clear(){return this.e.classList.remove(...Array.from(this.e.classList)),this}hasNode(e){return this.e.contains(e)}has(...e){let t=this.e.classList;return e.every((n)=>t.contains(n))}insert(e){return{HTML:(...t)=>(t.forEach((n)=>{this.e.insertAdjacentHTML(e,n)}),this),element:(...t)=>(t.forEach((n)=>{this.e.insertAdjacentElement(e,n)}),this),text:(...t)=>(t.forEach((n)=>{this.e.insertAdjacentText(e,n)}),this)}}is(e){let t=this.e.classList,n=this.e.tagName.toLocaleLowerCase(),r=!e.dom||e.dom.toLowerCase()===n,o=Array.isArray(e.class)?e.class:e.class?[e.class]:[];return r&&o.every((i)=>t.contains(i))}on(e,t,n=!1){let r=!1;if(e.indexOf("touch")>-1)r=!0;return this.e.addEventListener(e,t,{capture:n,passive:r}),this}remove_on(e,t,n=!1){return this.e.removeEventListener(e,t,n),this}timed(e,t=250){return setTimeout(()=>e(this),t),this}animate(e,t,n){let r={duration:300,easing:"ease",fill:"forwards"};if(Se(t))n=t;else q(r,t);let o=this.e.animate(e,r);if(n)o.finished.then(n);return this}query(e){return this.e.querySelector(e)}queryAll(e){let t=this.e.querySelectorAll(e);if(t.length)return Array.from(t).map((n)=>n);return[]}newChild(e,t={}){let n=document.createElement(e);return this.e.appendChild(n),Object.assign(n,t),new U(n)}newChildNS(e,t={}){let n=document.createElementNS("http://www.w3.org/2000/svg",e);return this.e.appendChild(n),Object.assign(n,t),new U(n)}get(e){return this.e[e]}}var de=new Map,Bt=(e)=>{if(e===null||typeof e!=="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},j=(e)=>{if(typeof document>"u")return;let t=de.get(e);if(t?.isConnected&&t.id===e)return t;de.delete(e);let n=document.getElementById(e);if(!n)return;return de.set(e,n),n};function Vt(){let e=[];for(let[t,n]of de)if(!n.isConnected||n.id!==t)e.push(t),de.delete(t);return e}function So(e,t){if(typeof e!=="string"&&!Bt(e))return new U(e);if(typeof document>"u")return;let n=t??document,r=(o)=>{let i=n.querySelector(o);return i?new U(i,o):void 0};if(typeof e==="string")return r(e);if(Bt(e)){let o=e,i=[];if(o.id)i.push(`#${CSS.escape(o.id)}`);if(o.class){let a=o.class.trim().split(/\s+/).filter(Boolean).map((u)=>`.${CSS.escape(u)}`);i.push(...a)}if(!i.length)return;let s=i.join("");return r(s)}return}function Co(e,t,n){return e?t:n}class Kt extends EventTarget{current;constructor(e){super();this.current=e}get value(){return this.current}get clone(){if(typeof Element<"u"&&this.current instanceof Element)return this.current;return structuredClone(this.current)}set value(e){if(Object.is(this.current,e))return;this.current=e,this.dispatchEvent(new CustomEvent("updated",{detail:e}))}}class Ce{state=new Kt(void 0);get element(){return this.state.value}set element(e){this.state.value=e}get $(){return this.state.value}}var Do=()=>new Ce;var Ze=0,Qe=new Set;function zt(e){if(Ze)Qe.add(e);else e()}function er(e){Ze++;try{let t=e();if(t&&typeof t.then==="function")throw Promise.resolve(t).catch(()=>{}),TypeError("batch callbacks must be synchronous.");return t}finally{if(--Ze===0){let t=[...Qe];Qe.clear();for(let n of t)n()}}}var Xe=(e)=>typeof e==="boolean",N=(e)=>Array.isArray(e),G=(e)=>typeof e==="function",Z=(e)=>e!==null&&typeof e==="object",_=(e)=>Z(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);class T extends Map{obj(e){if(e)Object.entries(e).forEach(([t,n])=>this.set(t,n));return this}init(e,t){if(!this.has(e))this.set(e,t);return this.get(e)}}var Pe=(e,t)=>{if(!t.has(e))t.set(e,new T);return t.get(e)},Q=(e,t)=>{if(!t.has(e))t.set(e,[]);return t.get(e)},_t=(e)=>Object.entries(e),ce=(e)=>JSON.stringify(e),Wt=(e)=>{if(e.startsWith("webkit"))e=`-${e}`;return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},Jt=(e)=>Array.from({length:e},(r,o)=>{let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+(o?"0123456789":"");return i.charAt(Math.floor(Math.random()*i.length))}).join("");var et=0;async function ue(e,t,{id:n=`stateHook:${++et}`,init:r,signal:o,scope:i}={}){o?.throwIfAborted(),i?.signal.throwIfAborted();let s=[],a=()=>t.map((d)=>d.value),u=async()=>{await e(...a())};for(let d of t)s.push(await d.hook(u)(n));let c=()=>{s.splice(0).forEach((d)=>d()),o?.removeEventListener("abort",c)};o?.addEventListener("abort",c,{once:!0}),i?.defer(c);try{if(r)await u()}catch(d){throw c(),d}if(o?.aborted||i?.disposed)c();return c}async function tr(e,t,{id:n=`stateLoad:${++et}`,init:r,signal:o,scope:i}={}){o?.throwIfAborted(),i?.signal.throwIfAborted();let s=[],a=()=>t.map((d)=>d.value),u=async()=>{await e(...a())};for(let d of t)s.push(d.loaded(u)(n));let c=()=>{s.splice(0).forEach((d)=>d()),o?.removeEventListener("abort",c)};o?.addEventListener("abort",c,{once:!0}),i?.defer(c);try{if(r)await u()}catch(d){throw c(),d}if(o?.aborted||i?.disposed)c();return c}function nr(e,t,n=!1){return[e,t,n,!1]}function rr(e,t,n=!1){return[e,t,n,!0]}async function or(e,t,n={}){n.signal?.throwIfAborted(),n.scope?.signal.throwIfAborted();let r,o,i=[],s=!1,a=()=>{s=!0,r?.abort(),o?.(),i.splice(0).forEach((d)=>d()),n.signal?.removeEventListener("abort",a)},u=async(d)=>{if(s)return;r?.abort(),o?.();let l=new AbortController;r=l;let p=()=>l.abort();if(d.signal.addEventListener("abort",p,{once:!0}),o=()=>d.signal.removeEventListener("abort",p),d.signal.aborted)p();try{await e({signal:l.signal,isCurrent:()=>!l.signal.aborted&&d.isCurrent()},...t.map((f)=>f.value))}catch(f){throw l.abort(),o?.(),f}},c=n.id??`stateEffect:${++et}`;n.signal?.addEventListener("abort",a,{once:!0}),n.scope?.defer(a);try{for(let d of t)i.push(await d.hook(u)(c));if(n.init){let d=new AbortController;await u({signal:d.signal,isCurrent:()=>!s})}if(n.signal?.aborted||n.scope?.disposed)a()}catch(d){throw a(),d}return a}function ir(e,t){if(Object.is(e,t))return!0;let n=Array.isArray(e)&&Array.isArray(t);if(!n&&!(_(e)&&_(t)))return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(n&&e.length!==t.length)return!1;let r=(a)=>Reflect.ownKeys(a).filter((u)=>Object.prototype.propertyIsEnumerable.call(a,u)),o=e,i=t,s=r(o);return s.length===r(i).length&&s.every((a)=>Object.prototype.propertyIsEnumerable.call(i,a)&&Object.is(Reflect.get(o,a),Reflect.get(i,a)))}class H extends EventTarget{options;hooks=new T;loads=new T;states=new T;_value;listening=!1;controller=new AbortController;pending=new Set;failures=[];emit=()=>{this.controller.abort(),this.controller=new AbortController,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))};end;constructor(e,t={}){super();this.options=t;this._value=e}get value(){return this._value}get clone(){return structuredClone(this._value)}set value(e){let t=this.options.equals??Object.is;if(t!==!1&&t(this._value,e))return;this._value=e,this.dispatch()}async flush(){while(this.pending.size)await Promise.all([...this.pending]);let e=this.failures.splice(0);if(e.length===1)throw e[0];if(e.length)throw AggregateError(e,"State updates failed.")}report(e){this.failures.push(e);let t=new CustomEvent("error",{detail:e,cancelable:!0});this.dispatchEvent(t);try{if(this.options.onError)this.options.onError(e);else if(!t.defaultPrevented)console.error("Yvee state update failed",e)}catch(n){console.error("Yvee state error handler failed",n)}}async update(e,t){let n=[],r=async(o)=>{try{await o()}catch(i){if(t.isCurrent())n.push(i)}};for(let[o,i]of[...this.hooks.entries()]){if(!t.isCurrent())return;if(this.hooks.get(o)!==i)continue;await r(()=>i(t))}for(let[o,i]of this.states){let s=j(o);if(!s||!i.size){this.states.delete(o);continue}for(let[a,u]of[...i.entries()]){if(!t.isCurrent())return;let c=()=>t.isCurrent()&&this.states.get(o)?.get(a)===u&&j(o)===s;if(!c())continue;await r(()=>u.call(s,e,{signal:t.signal,isCurrent:c}))}}if(!t.isCurrent())return;if(!n.length){for(let[o,i]of[...this.loads.entries()]){if(!t.isCurrent())return;if(this.loads.get(o)===i)await r(i)}if(t.isCurrent())this.dispatchEvent(new CustomEvent("loaded",{detail:e}))}if(n.length===1)throw n[0];if(n.length)throw AggregateError(n,"State subscribers failed.")}listen(){if(this.options.signal?.aborted)return()=>{};if(!this.listening){let e=(n)=>{let r=this.controller,o={signal:r.signal,isCurrent:()=>!r.signal.aborted},i,s=new Promise((c)=>{let d=()=>c();r.signal.addEventListener("abort",d,{once:!0}),i=()=>r.signal.removeEventListener("abort",d)}),a=this.update(n.detail,o).catch((c)=>{if(o.isCurrent())this.report(c)}),u=Promise.race([a,s]).finally(()=>{i(),this.pending.delete(u),this.stopListeningWhenUnused()});this.pending.add(u)},t=()=>this.end?.();this.options.signal?.addEventListener("abort",t,{once:!0}),this.addEventListener("updated",e,this.options),this.listening=!0,this.end=()=>{this.removeEventListener("updated",e,this.options),this.options.signal?.removeEventListener("abort",t),this.controller.abort(),this.listening=!1,this.end=void 0}}return this.end}stopListeningWhenUnused(){if(!this.states.size&&!this.hooks.size&&!this.loads.size)this.end?.()}call(e,t){return async(n)=>(Pe(n,this.states).set(t,e),this.listen(),()=>{let r=this.states.get(n);if(r?.get(t)===e)r.delete(t);if(r&&!r.size)this.states.delete(n);this.stopListeningWhenUnused()})}hook(e){return async(t)=>(this.hooks.set(t,e),this.listen(),()=>{if(this.hooks.get(t)===e)this.hooks.delete(t);this.stopListeningWhenUnused()})}loaded(e){return(t)=>(this.loads.set(t,e),this.listen(),()=>{if(this.loads.get(t)===e)this.loads.delete(t);this.stopListeningWhenUnused()})}dispatch(){zt(this.emit)}}class Zt extends H{constructor(e,t={}){super(new Set(e),t)}add(e){if(this._value.has(e))return;this._value.add(e),this.dispatch()}delete(e){if(!this._value.has(e))return;this._value.delete(e),this.dispatch()}has(e){return this._value.has(e)}clear(){if(!this._value.size)return;this._value.clear(),this.dispatch()}}class Qt extends H{constructor(e,t={}){super(e,t)}set(e,t){let n=this._value[e];if(!Object.hasOwn(this._value,e)||!Object.is(n,t))this._value[e]=t,this.dispatch()}delete(e){if(Object.hasOwn(this._value,e))delete this._value[e],this.dispatch()}entries(){return Object.entries(this._value)}}function D(e,t={}){return new H(e,t)}function Vo(e,t={}){return new Zt(e,t)}function Ko(e,t={}){return new Qt(e,t)}function zo(e,t=!1){return D(e,{equals:t?Object.is:!1})}function tt(){return new Map}var Xt=tt();function le(e,t=Xt){let n=Object.entries(e);for(let[o,i]of n){if(!o.trim())throw TypeError("Scope names must not be empty.");if(t.has(o))throw Error(`Scope already registered: ${o}`);if(i===null||typeof i!=="object"||Array.isArray(i)||![Object.prototype,null].includes(Object.getPrototypeOf(i)))throw TypeError(`Scope must be a plain object: ${o}`)}let r=n.map(([o,i])=>[o,Object.seal({...i})]);for(let[o,i]of r)t.set(o,i)}function re(e,t=Xt){let n=t.get(e);if(!n)throw Error(`Scope is not registered: ${e}`);return n}class en{constructor(){}static create(e){let t=tt();return le(e,t),{use:(n)=>re(n,t)}}static register(e){return le(e),{use:(t)=>re(t)}}static use(e){return re(e)}}var sr=en;class tn{static register(e){return le(e),{use:(t)=>nn.use(t)}}static use(e){return new Proxy({},{get(t,n){return(r,o)=>{if(o.kind!=="field")throw TypeError("Field scope can only decorate class fields.");return function(){let i=re(e);if(!Object.hasOwn(i,n))throw Error(`Scope field is not registered: ${e}.${String(n)}`);return Reflect.get(i,n)}}}})}}var nn=tn;class rn{state;dev;constructor(e,t){Object.seal(e);for(let n in e){let r=e[n];if(typeof r==="object"&&r!==null)Object.seal(r)}this.state=e,this.dev=t?.dev??!1}get __(){return this.state}bind(e){for(let[t,n]of Object.entries(e)){let r=t;if(this.state[r]!=null){if(this.dev)console.warn(`[Stored] ${String(r)} already bound`);continue}if(this.state[r]=n,this.dev)console.log(`[Stored] bound ${String(r)}`)}}set(e,t,n){let r=this.state[e];if(typeof r!=="object"||r===null)throw Error(`${String(e)} is not an object`);if(r[t]=n,this.dev)console.log(`[Stored] updated ${String(e)}.${String(t)} \u2192`,n)}fn(e){return()=>e(this.state)}safe(e){let t=this.state[e];if(t==null)throw Error(`${String(e)} not bound`);return t}}var nt=new Map,Le=new Map,fe=new Map;class on{url;stream;handlers=new Map;closed=!1;constructor(e,t=!1){this.url=e;let n=nt.get(e);if(n&&n.withCredentials!==t)throw TypeError(`Event stream ${e} is already open with different credentials settings.`);if(!n){if(typeof EventSource>"u")throw Error("EventSource is not available in this environment.");n=new EventSource(e,{withCredentials:t}),nt.set(e,n),Le.set(e,new Map)}this.stream=n;let r=fe.get(e);if(!r)r=new Set,fe.set(e,r);r.add(this)}on(e){let t=Le.get(this.url);for(let[n,r]of Object.entries(e)){if(this.closed)break;let o=this.handlers.get(n);if(!o)o=new Set,this.handlers.set(n,o);if(o.has(r))continue;o.add(r);let i=t.get(n);if(!i)i=new Set,t.set(n,i);if(!i.has(r))i.add(r),this.stream.addEventListener(n,r)}return this}off(e,t){let n=Le.get(this.url);if(!n)return this;let r=e?[e]:[...this.handlers.keys()];for(let o of r){let i=this.handlers.get(o);if(!i)continue;let s=t?i.has(t)?[t]:[]:[...i],a=n.get(o);for(let u of s)if(i.delete(u),![...fe.get(this.url)??[]].some((d)=>d!==this&&d.handlers.get(o)?.has(u)))this.stream.removeEventListener(o,u),a?.delete(u);if(!i.size)this.handlers.delete(o);if(a&&!a.size)n.delete(o)}return this}close(){if(this.closed)return;this.off(),this.closed=!0;let e=fe.get(this.url);if(e?.delete(this),!e?.size)this.stream.close(),fe.delete(this.url),Le.delete(this.url),nt.delete(this.url)}}function ai(e,t=!0){return new on(e,t)}class Y{type;primaryKey=!1;required=!1;isUnique=!1;indexed=!1;autoIncrement=!1;hasDefault=!1;defaultValue;constructor(e){this.type=e}get primary(){return this.primaryKey=!0,this}get notNull(){return this.required=!0,this}get index(){return this.indexed=!0,this}get unique(){return this.indexed=!0,this.isUnique=!0,this}get defaultNow(){if(this.type!=="date")throw TypeError("defaultNow requires a timestamp column.");return this.default(()=>new Date)}default(e){return this.hasDefault=!0,this.defaultValue=e,this}value(){return typeof this.defaultValue==="function"?this.defaultValue():structuredClone(this.defaultValue)}validate(e,t){if(t===void 0||t===null){if(this.required||this.primaryKey&&!this.autoIncrement)throw TypeError(`Column '${e}' is required.`);return}if(!(this.type==="json"||this.type==="text"&&typeof t==="string"||this.type==="boolean"&&typeof t==="boolean"||this.type==="number"&&typeof t==="number"&&Number.isFinite(t)||this.type==="integer"&&typeof t==="number"&&Number.isSafeInteger(t)||this.type==="date"&&t instanceof Date&&Number.isFinite(t.getTime())))throw TypeError(`Column '${e}' must be ${this.type}.`)}}var ar={text:()=>new Y("text"),int:()=>new Y("integer"),number:()=>new Y("number"),boolean:()=>new Y("boolean"),timestamp:()=>new Y("date"),json:()=>new Y("json"),serial:()=>{let e=new Y("integer");return e.autoIncrement=!0,e}};class sn{table;definitions;keyPath;autoIncrement;constructor(e,t){this.table=e;this.definitions=t;if(!e)throw TypeError("An object store name is required.");let n=this.entries().filter(([,i])=>i.primaryKey);if(n.length!==1)throw TypeError(`Store '${e}' requires exactly one primary column.`);let[r,o]=n[0];this.keyPath=r,this.autoIncrement=o.autoIncrement;for(let[i,s]of this.entries()){if(!/^[A-Za-z_$][\w$]*$/.test(i))throw TypeError(`Invalid field name '${i}'.`);if(s.autoIncrement&&!s.primaryKey)throw TypeError(`Serial column '${i}' must be the primary key.`);if((s.primaryKey||s.indexed)&&!["text","integer","number","date"].includes(s.type))throw TypeError(`Column '${i}' cannot be an IndexedDB key or index.`)}}entries(){return Object.entries(this.definitions)}prepare(e){let t={...e};for(let[n,r]of this.entries()){if(t[n]===void 0&&r.hasDefault)t[n]=r.value();if(r.autoIncrement&&t[n]===void 0){delete t[n];continue}r.validate(n,t[n])}return t}upgrade(e,t){let n=e.objectStoreNames.contains(this.table)?t.objectStore(this.table):e.createObjectStore(this.table,{keyPath:this.keyPath,autoIncrement:this.autoIncrement});if(n.keyPath!==this.keyPath||n.autoIncrement!==this.autoIncrement)throw Error(`Changing the primary key of '${this.table}' requires an explicit data migration.`);for(let[r,o]of this.entries()){if(!o.indexed||o.primaryKey)continue;if(n.indexNames.contains(r)){let i=n.index(r);if(i.keyPath===r&&i.unique===o.isUnique&&!i.multiEntry)continue;n.deleteIndex(r)}n.createIndex(r,r,{unique:o.isUnique})}}}function W(e,t,n,r){return new Promise((o,i)=>{let s=e.transaction(t,n),a,u;s.oncomplete=()=>o(a),s.onabort=()=>i(u??s.error??Error("IndexedDB transaction aborted."));let c=(d)=>{u=d,s.abort()};try{r(s.objectStore(t),(d)=>{a=d},c)}catch(d){c(d)}})}class Ae{db;schema;constructor(e,t){this.db=e;this.schema=t}insert(e){let t=this.schema.prepare(e);return W(this.db,this.schema.table,"readwrite",(n,r)=>{n.add(t).onsuccess=(o)=>r(o.target.result)})}put(e){let t=this.schema.prepare(e);return W(this.db,this.schema.table,"readwrite",(n,r)=>{let o=n.put(t);o.onsuccess=()=>r(o.result)})}find(e){return W(this.db,this.schema.table,"readonly",(t,n)=>{let r=t.get(e);r.onsuccess=()=>n(r.result)})}findAll(e,t){return this.readAll(void 0,e,t)}findByIndex(e,t,n){return this.readAll(e,t,n)}readAll(e,t,n){if(n!==void 0&&(!Number.isInteger(n)||n<1||n>4294967295))throw RangeError("Limit must be an integer between 1 and 4294967295.");return W(this.db,this.schema.table,"readonly",(r,o)=>{let i=(e===void 0?r:r.index(e)).getAll(t,n);i.onsuccess=()=>o(i.result)})}update(e,t){if(Object.hasOwn(t,this.schema.keyPath))throw TypeError("Updates cannot change the primary key.");return W(this.db,this.schema.table,"readwrite",(n,r,o)=>{let i=n.get(e);i.onsuccess=()=>{if(i.result===void 0){r(void 0);return}try{let s=this.schema.prepare({...i.result,...t});n.put(s).onsuccess=()=>r(s)}catch(s){o(s)}}})}count(e){return W(this.db,this.schema.table,"readonly",(t,n)=>{let r=t.count(e);r.onsuccess=()=>n(r.result)})}delete(e){return W(this.db,this.schema.table,"readwrite",(t,n)=>{t.delete(e).onsuccess=()=>n(void 0)})}clear(){return W(this.db,this.schema.table,"readwrite",(e,t)=>{e.clear().onsuccess=()=>t(void 0)})}}class rt{connection;schemas;constructor(e,t){this.connection=e;this.schemas=t}static open(e,t,n,r={}){if(!e||!Number.isSafeInteger(t)||t<1)return Promise.reject(TypeError("A database name and positive integer version are required."));if(new Set(n.map((i)=>i.table)).size!==n.length)return Promise.reject(TypeError("Object store names must be unique."));let o=r.factory??globalThis.indexedDB;if(!o)return Promise.reject(Error("IndexedDB is unavailable in this environment."));return new Promise((i,s)=>{let a=o.open(e,t),u;a.onblocked=(c)=>r.onBlocked?.(c),a.onerror=()=>s(u??a.error),a.onupgradeneeded=(c)=>{let d=a.transaction;try{for(let l of n)l.upgrade(a.result,d);r.upgrade?.(a.result,d,c.oldVersion,c.newVersion)}catch(l){u=l,d.abort()}},a.onsuccess=()=>{let c=a.result;c.onversionchange=()=>c.close();try{for(let d of n){let p=c.transaction(d.table,"readonly").objectStore(d.table);if(p.keyPath!==d.keyPath||p.autoIncrement!==d.autoIncrement)throw Error(`Schema '${d.table}' changed; increase the database version.`);for(let[f,h]of d.entries()){if(!h.indexed||h.primaryKey)continue;if(!p.indexNames.contains(f)||p.index(f).unique!==h.isUnique||p.index(f).keyPath!==f||p.index(f).multiEntry)throw Error(`Index '${d.table}.${f}' changed; increase the database version.`)}}i(new rt(c,new Set(n)))}catch(d){c.close(),s(d)}}})}repository(e){if(!this.schemas.has(e))throw Error(`Schema '${e.table}' was not registered when opening this database.`);return new Ae(this.connection,e)}close(){this.connection.close()}}async function Ri(e,t,n={}){n.signal?.throwIfAborted(),n.scope?.signal.throwIfAborted();let r=()=>{let c=t(...e.map((d)=>d.value));if(c!=null&&typeof c.then==="function")throw Promise.resolve(c).catch(()=>{}),TypeError("Derived calculations must be synchronous; use StateEffect for async work.");return c},o=new H(r(),n),i=o.flush.bind(o),s=!1,a=await ue(async()=>{if(!s)o.value=r();await i()},e,n);o.flush=async()=>{await Promise.all(e.map((c)=>c.flush())),await i()};let u=()=>{s=!0,a()};return n.scope?.defer(u),Object.defineProperty(o,"dispose",{value:u}),o}class k{controller=new AbortController;cleanups=new Set;get signal(){return this.controller.signal}get disposed(){return this.signal.aborted}defer(e){let t=!0,n=()=>{if(!t)return;t=!1,this.cleanups.delete(n),e()};if(this.disposed)n();else this.cleanups.add(n);return n}own(e){return this.defer(()=>{if("dispose"in e)e.dispose();else e.close()}),e}listen(e,t,n,r){if(this.disposed)return()=>{};return e.addEventListener(t,n,r),this.defer(()=>e.removeEventListener(t,n,r))}timeout(e,t){if(this.disposed)return()=>{};let n=setTimeout(()=>{if(r(),!this.disposed)e()},t),r=this.defer(()=>clearTimeout(n));return r}dispose(){if(this.disposed)return;this.controller.abort();let e=[];for(let t of[...this.cleanups].reverse())try{t()}catch(n){e.push(n)}if(e.length)throw AggregateError(e,"Resource cleanup failed.")}}class L{tag;attr;ctx;constructor(e,t,n){this.tag=e;this.attr=t;this.ctx=n;if(e&&!/^[A-Za-z][A-Za-z0-9._:-]*$/.test(e))throw TypeError(`Invalid DOM tag name: ${e}`)}}async function F(e,t={},...n){if(G(e))return await e(t??{},...n);return new L(e,t??{},n)}var Di=async(e,...t)=>new L("",{},t);class x{nonce;counter;baseId;constructor(e,t=0,n){this.nonce=n;this.baseId=e||Jt(4),this.counter=Number.isSafeInteger(t)&&t>=0?t:0}static fromId(e,t){let n=/^(.*)-(\d+)$/.exec(e);if(!n||!n[1])return new x(e,0,t);return new x(n[1],Number(n[2]),t)}get id(){return`${this.baseId}-${this.counter}`}get nextId(){return`${this.baseId}-${this.counter++}`}get childId(){return x.fromId(`${this.nextId}-0`,this.nonce)}append(e="h"){return x.fromId(`${e}${this.id}`,this.nonce)}}var dr=(e,t,n)=>(e.addEventListener(t,n),()=>{e.removeEventListener(t,n)}),pe={},he={};class oe{tokens=new Map;events=new T;states=new T;windowEvents=new T;documentEvents=new T;resetST=new T;resetEV=new T;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(e){let{id:t,events:n,states:r}=e;if(t){if(n.size)this.events.set(t,n);if(r.length)this.states.set(t,r)}return this}push(e){return e.events.forEach((t,n)=>{t.forEach((r,o)=>{Pe(n,this.events).set(o,r)})}),e.states.forEach((t,n)=>{Q(n,this.states).push(...t)}),this}async stage(e=()=>!0){for(let[t,n]of[...this.events.entries()]){if(!e())return this;this.events.delete(t);let r=j(t);if(!r)continue;let o={};this.tokens.set(t,o);let i=()=>e()&&this.tokens.get(t)===o&&j(t)===r,s=(c)=>{if(i())Q(t,this.resetEV).push(c);else c()},a=n.get("ready");if(a){let c=await a.apply(r,[r]);if(G(c))s(c)}if(!i())return this;let u=0;for(let[c,d]of n.entries()){if(!i())return this;switch(c){case"ready":break;case"element":{let f=await d.apply(r,[r]);if(G(f))s(f)}break;case"states":case"state":let l=await d.apply(r,[r]);if(!i())return this;let p=N(l[0])?l:l[0]?[l]:[];if(!p.length)break;for(let f of p){let[h,g,v,y]=f;if(!g||g.length===0)continue;let b=N(g)?g:[g];if(!b.length)break;let R=()=>b.map((S)=>S.value),m=()=>h(...R());if(v)await m();if(!i())return this;if(y){for(let S of b)Q(t,this.resetST).push(S.loaded(m)(`${t}_loaded${u++}`));continue}for(let S of b)Q(t,this.resetST).push(await S.call(m,`${t}_state${u}`)(t));u++}break;case"paste":if(c.startsWith("doc")){let f=c.replace(/^doc/,"");this.documentEvents.init(f,new T).set(t,d)}else this.documentEvents.init(c,new T).set(t,d);break;case"resize":case"beforeunload":case"popstate":this.windowEvents.init(c,new T).set(t,d);break;default:if(c.startsWith("win")){let f=c.replace(/^win/,"");this.windowEvents.init(f,new T).set(t,d)}else Q(t,this.resetEV).push(dr(r,c,d))}}}this.processWindowEvents,this.processDocumentEvents;for(let[t,n]of[...this.states.entries()]){if(!e())return this;if(this.states.delete(t),!j(t))continue;let r=this.tokens.get(t)??{};this.tokens.set(t,r);for(let o of n){let i=await o(t);if(!e()||this.tokens.get(t)!==r)return i(),this;Q(t,this.resetST).push(i)}}return this}get processWindowEvents(){let e=(t,n)=>{let r=!1,o=(s)=>{if(!r)window.requestAnimationFrame(()=>{n.forEach((a,u)=>{let c=j(u);if(c)a.call(c,s);else this.windowEvents.get(t)?.delete(u)}),r=!1}),r=!0},i=(s)=>{n.forEach((a,u)=>{let c=j(u);if(c)a.call(c,s);else this.windowEvents.get(t)?.delete(u)})};return window.addEventListener(t,t==="scroll"?o:i),()=>{window.removeEventListener(t,t==="scroll"?o:i)}};return this.windowEvents.forEach((t,n)=>{if(t.size){if(!pe[n])pe[n]=e(n,t)}else if(pe[n])pe[n](),delete pe[n]}),this}get processDocumentEvents(){let e=(t,n)=>{let r=!1,o=(s)=>{if(!r)window.requestAnimationFrame(()=>{n.forEach((a,u)=>{let c=j(u);if(c)a.call(c,s);else this.documentEvents.get(t)?.delete(u)}),r=!1}),r=!0},i=(s)=>{n.forEach((a,u)=>{let c=j(u);if(c)a.call(c,s);else this.documentEvents.get(t)?.delete(u)})};return document.addEventListener(t,t==="scroll"?o:i),()=>{document.removeEventListener(t,t==="scroll"?o:i)}};return this.documentEvents.forEach((t,n)=>{if(t.size){if(!he[n])he[n]=e(n,t)}else if(he[n])he[n](),delete he[n]}),this}reset(e){let t=[];if(e.forEach((n)=>{this.tokens.delete(n),this.events.delete(n),this.states.delete(n),this.windowEvents.forEach((r,o)=>{if(r.has(n))r.delete(n)}),this.documentEvents.forEach((r,o)=>{if(r.has(n))r.delete(n)});for(let r of[...this.resetEV.get(n)??[],...this.resetST.get(n)??[]])try{r()}catch(o){t.push(o)}this.resetST.delete(n),this.resetEV.delete(n)}),this.processWindowEvents,this.processDocumentEvents,t.length)throw AggregateError(t,"One or more OZ element cleanups failed.");return this}resetScope(e){let t=new Set([...this.tokens.keys(),...this.events.keys(),...this.states.keys(),...this.resetEV.keys(),...this.resetST.keys()]);for(let r of[...this.windowEvents.values(),...this.documentEvents.values()])for(let o of r.keys())t.add(o);let n=[...t].filter((r)=>r===e||r.startsWith(`${e}-`));return this.reset(n),this}async RPS(e,t=()=>!0){if(!t())return this;let n=Vt();if(this.reset(n),e){let r=e.keys;if(r.length)await this.reset(r).push(e).stage(t)}return this.processWindowEvents,this.processDocumentEvents,this}}var I=new oe;class ge{xid;IDM;map=new T;states=[];events=new T;OZ;internalId;constructor(e,t=new x,n){this.xid=e;this.IDM=t;this.OZ=n??new oe}attr_push(e,t,n){let r=n??e;if(M(r,void 0),n==="style"&&!/^(?:--[A-Za-z0-9_-]+|-?[A-Za-z][A-Za-z0-9-]*)$/.test(e))return;if(!this.map.has(r))this.map.set(r,[]);let o=n?`${Wt(e)}:${t};`:t;this.map.get(r).push(o)}get attr(){let e=[""];return this.map.forEach((t,n)=>{let r=t.join("");e.push(r?`${n}="${r}"`:n)}),e.join(" ")}set id(e){if(!this.map.has("id"))this.internalId=e,this.map.set("id",[P(e)])}get id(){return this.internalId??this.map.get("id")?.join("")}setId(e){this.internalId=e}}var ot,dn=(e)=>{ot=e},cr=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],an=(e)=>cr.includes(e.toLowerCase()),Oe=async(e,t)=>{let n=await Promise.resolve(e);if(N(n)){let r=[];for(let o of n)r.push(await Oe(o,t));return r.join("")}else if(n instanceof L){if(!ot)throw Error("The DOM renderer has not been initialized.");let{ctx:r,oz:o}=await ot(n,t.IDM);return t.OZ.push(o),r}else if(Z(n)){if(n instanceof Set)return P([...n].join(" "));return P(ce(n))}else if(G(n))return await Oe(n(),t);else if(n!==void 0&&n!==null)return P(n);return""},Me=async(e,t,n)=>{let r=t?x.fromId(t,n):new x(void 0,0,n),o=new ge(r.id,r);return{ctx:await Oe(e,o),catt:o}};async function ur(e,t,n){let r=this.id;if(r){let{ctx:o,catt:i}=await Me(e,r,t);if(n&&!n.isCurrent())return!1;if(this.innerHTML!==o)return this.innerHTML=o,await I.RPS(i.OZ,n?.isCurrent),!0}return!1}var it=async(e,t,n,r=[])=>{if(N(e))for(let o of e)await it(o,e.length,n,r);else if(e instanceof H)if(t>1)await it(await F("div",{},e),t,n,r);else{let o=e.value,i=o instanceof L?"dom":"ctx",{ctx:s,catt:a}=await Me(o,n.xid+"-0",n.IDM.nonce);n.xid=a.xid,r.push(s),n.OZ.push(a.OZ),n.states.push(e.call(function(u,c){return ur.call(this,u,n.IDM.nonce,c)},i))}else r.push(await Oe(e,n))};class st{tag;ctx;closing;constructor(e="",t){this.tag=e;this.ctx=t;let n=an(e);this.closing=n?"":`</${e}>`}async process(e,t=this.ctx,n=[]){for(let r of t)await it(await Promise.resolve(r),t.length,e,n);return n.join("")}async get(e){let t=e.xid,n,r=this.tag.toLowerCase();if(r==="script"||r==="style"){let o=async(i)=>{let s=await i;if(Array.isArray(s))return(await Promise.all(s.map(o))).join("");if(typeof s==="function")return o(s());if(s==null)return"";if(typeof s!=="string"&&typeof s!=="number")throw TypeError("Inline script/style children must be static text.");return String(s)};n=z(r,await o(this.ctx))}else n=await this.process(e);if(!this.tag)return n;if(e.events.size||e.states.length)e.id=t;if(an(this.tag)){if(n)throw TypeError(`<${this.tag}> cannot contain child content.`);return`<${this.tag}${e.attr}>`}return`<${this.tag}${e.attr}>${n}${this.closing}`}}var lr=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),at=(e)=>lr.has(e.toLowerCase()),me=(e)=>{if(N(e))return P(e.filter((t)=>t!==void 0).join(" "));if(_(e))return P(ce(e));if(G(e))return me(e());if(e===void 0||e===null)return"";return Xe(e)?e?"":"false":P(String(e))},X=(e)=>{if(N(e))return e.filter((t)=>t!==void 0).join(" ");if(_(e))return ce(e);if(G(e))return X(e());if(e===void 0||e===null)return"";return Xe(e)?e?"":"false":String(e)};var fr=(e)=>/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(e),pr=(e)=>/^(?:--[A-Za-z0-9_-]+|-?[A-Za-z][A-Za-z0-9-]*)$/.test(e);function hr(e,t){switch(t??e){case"style":return function(n){this.style.setProperty(e,X(n))};default:return function(n){if(at(e)&&(typeof n==="boolean"||n==null)){this.toggleAttribute(e,n===!0);return}let r=X(n);M(e,r),this.setAttribute(e,r)}}}class dt{attr;constructor(e={}){this.attr=e}get(e,t=this.attr,n){let r=(o,i)=>{if(n!=="style"&&at(o)&&(i===!1||i===null))return;if(n!=="style"&&!(i instanceof H)&&!Z(i))M(o,X(i));if(N(i)){if(!n)M(o,X(i));e.attr_push(o,me(i),n)}else if(i instanceof H){let s=n?`${n}_${o}`:o;e.states.push(i.call(hr(o,n),s)),r(o,i.value)}else if(Z(i)){if(_(i)&&!n)this.get(e,i,o)}else e.attr_push(o,me(i),n)};_t(t).forEach(([o,i])=>{let s=String(o);if(!(n==="style"?pr(s):fr(s)))return;if(s==="id"&&i!==void 0)e.setId(X(i instanceof H?i.value:i));if(s==="ref"){if(i instanceof Ce)e.events.obj({element(){i.element=this}})}else if(["on"].includes(s))Z(t.on)&&e.events.obj(t.on);else{if(i===void 0)return;r(s,i)}})}unload(e){let t;if(e in this.attr)t=this.attr[e],delete this.attr[e];return t}}async function ee(e,t=new x){let{tag:n,attr:r,ctx:o}=await Promise.resolve(e),i=t instanceof x?t:x.fromId(t),s=i.nextId,a=new ge(s,i),u=["script","style"].includes(n.toLowerCase())&&i.nonce!==void 0?{...r,nonce:i.nonce}:r,c=new dt(u),d=new st(n,o);return c.get(a),{ctx:await d.get(a),oz:a.OZ.set(a),id:a.id}}dn(ee);Yt(async(e,t)=>{let{ctx:n,catt:r}=await Me(e,t);return{html:n,commit:()=>I.RPS(r.OZ).then(()=>{return})}});function C(e){if(e===void 0)return[];return Array.isArray(e)?e:[e]}function E(e,t){return{...e,...t,base:[...C(e.base),...C(t.base)],meta:[...C(e.meta),...C(t.meta)],link:[...C(e.link),...C(t.link)],script:[...C(e.script),...C(t.script)],css:[...C(e.css),...C(t.css)],js:[...C(e.js),...C(t.js)],elements:[...C(e.elements),...C(t.elements)]}}function B(e){if(e instanceof L)return{elements:[e]};if(typeof e==="string")return{style:e};return e??{}}class ye{values={};head(e){let t=B(e);if(t.title!==void 0)this.values.title=t.title;let n=[this.values.style,t.style].filter(Boolean).join(`
|
|
3
|
-
`);if(n)this.values.style=n;if(t.description!==void 0)this.values.description=t.description;for(let r of["base","meta","link","script","css","js","elements"]){let o=t[r];if(o===void 0)continue;let i=this.values[r],s=i===void 0?[]:Array.isArray(i)?i:[i],a=Array.isArray(o)?o:[o];this.values[r]=[...s,...a]}}}function we(e){let t=String(e.base?.at(-1)?.href??"/"),n=new URL(t,"http://yvee.local"),r=t.startsWith("/"),o=(c)=>{if(!c.startsWith("./")&&!c.startsWith("../"))return c;let d=new URL(c,n);return r?`${d.pathname}${d.search}${d.hash}`:d.href},i=(c,d)=>{let l=c[d];if(typeof l!=="string")return c;let p=o(l);return p===l?c:{...c,[d]:p}},s=(c,d)=>{let l=!1,p=c.map((f)=>{let h=d(f);if(h!==f)l=!0;return h});return l?p:c},a=(c)=>{if(!Array.isArray(c))return o(c);return s(c,o)},u={...e};if(e.link)u.link=s(e.link,(c)=>i(c,"href"));if(e.script)u.script=s(e.script,(c)=>i(c,"src"));if(e.css!==void 0)u.css=a(e.css);if(e.js!==void 0)u.js=a(e.js);return u}async function ve(e,t,n,r){let o=new x(n,0,r),i=new oe,s=[],a;for(let u of e){let c=await ct(u,t),d=await ee(c,o);s.push(d.ctx),i.push(d.oz),a=d.id??a}return{ctx:s.join(""),oz:i,id:a}}async function ct(e,t){let n=await Promise.resolve(e);if(Array.isArray(n)){let i=[];for(let s of n)i.push(await ct(s,t));return i}if(!(n instanceof L))return n;let r=[];for(let i of n.ctx)r.push(await ct(i,t));let o=n.tag?{...n.attr,"data-yv":t}:n.attr;return new L(n.tag,o,r)}function ut(e){let t=new Set;return{ready:Promise.all(e.map((r)=>new Promise((o)=>{let i=!1,s=()=>{if(i)return;i=!0,t.delete(s),window.clearTimeout(a),r.removeEventListener("load",s),r.removeEventListener("error",s),o()},a=window.setTimeout(s,8000);t.add(s),r.addEventListener("load",s,{once:!0}),r.addEventListener("error",s,{once:!0})}))).then(()=>{return}),cancel(){for(let r of[...t])r()}}}function He(e,t,n={}){if(typeof document>"u")return Object.assign(()=>{},{ready:Promise.resolve(),async activate(){},cancel(){}});e=we(e);let r=document.title,o=e.title??"",i=[],s,a,u=[],c=!n.deferTitle,d=!1,l=!1,p=ut([]);if(c&&e.title!==void 0)document.title=o,d=!0;let f=(y,b)=>{if(y==="script"&&typeof b.src==="string"){let m=new URL(b.src,document.baseURI).href,S=String(b.type??"").toLowerCase();if(Array.from(document.head.querySelectorAll("script[src]")).find((It)=>It.src===m&&It.type.toLowerCase()===S))return}let R=document.createElement(y);for(let[m,S]of Object.entries(b)){if(m==="body"||S===void 0)continue;if(M(m,S),typeof S==="boolean")R.toggleAttribute(m,S);else R.setAttribute(m,String(S))}if((y==="script"||y==="style")&&n.nonce!==void 0)R.setAttribute("nonce",n.nonce);if(R.dataset.yv=t,y==="script"&&b.body)R.textContent=z("script",b.body);if(document.head.append(R),i.push(R),y==="link"&&String(b.rel??"").toLowerCase()==="stylesheet")u.push(R)},h=n.idSeed??`${t}:h`,g=(async()=>{if(!n.keepExisting)De(t);let y=e.base?.at(-1);if(y)document.head.querySelectorAll("base").forEach((m)=>m.remove()),f("base",y);if(e.description)f("meta",{name:"description",content:e.description});for(let m of e.meta??[])f("meta",m);for(let m of e.link??[])f("link",m);let b=C(e.css);for(let m of b)f("link",{rel:"stylesheet",href:m});for(let m of e.script??[])f("script",m);let R=C(e.js);for(let m of R)f("script",{src:m});if(e.style){let m=document.createElement("style");if(m.textContent=z("style",e.style),n.nonce!==void 0)m.setAttribute("nonce",n.nonce);m.dataset.yv=t,document.head.append(m),i.push(m)}if(e.elements?.length){if(a=await ve(e.elements,t,h,n.nonce),l)return;let m=document.createElement("template");m.innerHTML=a.ctx;let S=Array.from(m.content.children);for(let O of S){if(O instanceof HTMLTitleElement){if(s=O,n.deferTitle)continue;d=!0}document.head.append(O),i.push(O)}u.push(...S.filter((O)=>O instanceof HTMLLinkElement&&O.rel.toLowerCase()==="stylesheet"))}if(p=ut(u),await p.ready,c&&a)await I.RPS(a.oz,()=>!l&&c)})(),v=()=>{if(l)return;l=!0;try{if(p.cancel(),c&&a)I.resetScope(h)}finally{let y=s?.textContent??o,b=d&&document.title===y;if(i.forEach((R)=>R.remove()),s?.remove(),b)document.title=r}};return v.ready=g.catch((y)=>{throw v(),y}),v.activate=async()=>{if(l||c)return;if(r=document.title,c=!0,s)document.head.querySelectorAll("title").forEach((y)=>{if(y!==s)y.remove()}),document.head.append(s),i.push(s),d=!0;else if(e.title!==void 0)document.title=o,d=!0;if(a)await I.RPS(a.oz,()=>!l&&c)},v.cancel=()=>p.cancel(),v}function De(e){if(typeof document>"u")return;document.head.querySelectorAll("[data-yv]").forEach((t)=>{if(t.getAttribute("data-yv")!==e)return;if(t instanceof HTMLScriptElement&&t.hasAttribute("src"))return;t.remove()})}var lt=typeof window<"u";var V=(e)=>{let t=e.split(/[?#]/,1)[0]||"/",r=(t.startsWith("/")?t:`/${t}`).replace(/\/{2,}/g,"/");return r.length>1?r.replace(/\/+$/,""):"/"},A=(e)=>{let t=typeof window>"u"?"http://localhost":window.location.href,n=e instanceof URL?e:new URL(e,t);return{path:V(n.pathname),search:n.search,hash:n.hash,params:n.searchParams}},w=(e)=>`${e.path}${e.search}${e.hash}`;var ft=new WeakMap,cn=(e)=>(...t)=>e(...t),un=(...e)=>(t)=>(ft.set(t,[...e,...ft.get(t)??[]]),t),Ie=(e)=>ft.get(e)??[];function ln(e,t){return pn(t,"returnTo",w(e))}function fn(e){if(typeof e==="string"){let t=e.indexOf("?");if(t===-1)return;let n=e.indexOf("#",t),r=e.slice(t+1,n===-1?void 0:n);return new URLSearchParams(r).get("returnTo")??void 0}if(e instanceof URL)return e.searchParams.get("returnTo")??void 0;return e.params.get("returnTo")??void 0}function pn(e,t,n){let r=e.indexOf("#"),o=r===-1?e:e.slice(0,r),i=r===-1?"":e.slice(r),s=`${t}=${encodeURIComponent(n)}`,a=o.indexOf("?");if(a===-1)return`${o}?${s}${i}`;let u=o.slice(0,a),c=o.slice(a+1),d=!c||c.endsWith("&")?"":"&";return`${u}?${c}${d}${s}${i}`}function gr(e,t){if(e.kind!=="redirect"||e.returnTo===void 0||e.returnTo===!1)return e;let{returnTo:n,...r}=e;return{...r,to:pn(e.to,"returnTo",n===!0?w(t):n)}}async function be(e,t){let n={...t,server:t.server??!lt};for(let r of e){n.signal.throwIfAborted();let o=await r(n);if(n.signal.throwIfAborted(),o&&o.kind!=="allow")return gr(o,n.url)}return{kind:"allow"}}function Re(e,t){return be(e,t)}function pt(e,t={kind:"stop"}){return async(n)=>await e(n)?{kind:"allow"}:typeof t==="function"?t(n):t}function hn(...e){return async(t)=>{for(let n of e){t.signal.throwIfAborted();let r=await n(t);if(t.signal.throwIfAborted(),r&&r.kind!=="allow")return r}return{kind:"allow"}}}function gn(e,t){return async(n)=>await e(n)?t(n):{kind:"allow"}}function mn(e,t={kind:"stop"}){return pt(async(n)=>{for(let[r,o]of Object.entries(e)){let i=n.params[r];if(i===void 0||!await o(i,n))return!1}return!0},t)}var ie;function yn(){let e={consumed:!1,closed:!1};return ie=e,e}function ht(e){if(e.closed=!0,ie===e)ie=void 0}function mr(){return ie&&!ie.closed?ie:void 0}class Ue{resources=new k;url={path:"/",search:"",hash:"",params:new URLSearchParams};path="/";params={};data={};error;status=200;#e=typeof document>"u"?void 0:mr();regionParam;defaultRegion;rememberRegion;regions;keepAlive;regionGuards;refreshOnRegionChange;strictRegions;region=D("");regionContent=D(void 0);regionResources=new k;ssrData(){if(typeof document>"u")return this.data;let e=this.#e;if(!e||e.closed||e.consumed)return;return e.consumed=!0,this.data}}class Te extends Ue{body(){return F("main",{role:"status"},"Page not found: ",this.path)}}class te extends Ue{status=500;body(){return F("main",{role:"alert"},"This page could not be loaded.")}}var wn=new WeakMap;function wt(e){return Boolean(e?.regions&&Object.keys(e.regions).length&&e.regionParam)}function gt(e){if(!e.regions)return;if(e.defaultRegion&&e.regions[e.defaultRegion])return e.defaultRegion;return Object.keys(e.regions)[0]}function ne(e,t){if(!e.regions||!e.regionParam)return;let n=t.params.get(e.regionParam);if(n&&e.regions[n])return{id:n};if(n){let o=gt(e);return o===void 0?{unknown:n}:{unknown:n,id:o}}let r=gt(e);return r===void 0?void 0:{id:r}}function $e(e,t){let n=e.regions?.[t];if(!n)return Promise.reject(Error(`Unknown Yvee region: ${t}`));let r=wn.get(e);if(!r)r=new Map,wn.set(e,r);let o=r.get(t);if(!o)o=n(),r.set(t,o);return o}async function je(e,t){let n=t.head;if(n===void 0)return;let r=typeof n==="function"?await n({page:e}):await n;if(r===void 0||r===null)return;return B(r)}var mt=new WeakMap,yr=5,wr={get:()=>{return},set:()=>{}};function vr(e){let t=e.keepAlive;if(t===void 0)return 0;let n=t===!0?yr:t;return Number.isFinite(n)&&n>0?Math.floor(n):0}function Ne(e,t){let n=vr(e);if(!n)return wr;let r=mt.get(e);if(!r)r=new Map,mt.set(e,r);let o=r;return{get:()=>o.get(t),set:(i)=>{o.delete(t),o.set(t,i);while(o.size>n){let s=o.keys().next();if(s.done)break;o.delete(s.value)}}}}function bn(e){mt.delete(e)}var yt=new WeakMap;function Rn(e){if(!e||typeof e.querySelectorAll!=="function")return[];try{return Array.from(e.querySelectorAll("[data-scroll-key]"))}catch{return[]}}function Tn(e){let t=typeof e.getAttribute==="function"?e.getAttribute("data-scroll-key"):null;return t?t:void 0}function xn(e,t,n=Sn()){let r=Rn(n);if(!r.length)return;let o=yt.get(e);if(!o)o=new Map,yt.set(e,o);let i=o.get(t);if(!i)i=new Map,o.set(t,i);for(let s of r){let a=Tn(s);if(!a)continue;i.set(a,{top:s.scrollTop,left:s.scrollLeft})}}function kn(e,t,n=Sn()){let r=yt.get(e)?.get(t);if(!r||r.size===0)return!1;let o=!1;for(let i of Rn(n)){let s=Tn(i);if(!s)continue;let a=r.get(s);if(!a)continue;i.scrollTop=a.top,i.scrollLeft=a.left,o=!0}return o}function Sn(){return typeof document>"u"?void 0:document}function En(e,t,n){let r=vn(e,n),o=vn(t,n);return r.length===o.length&&r.every(([i,s],a)=>i===o[a][0]&&s===o[a][1])}function Ge(e,t){if(!e.regions||!e.regionParam)return;let n=t.params.get(e.regionParam);if(!n||e.regions[n])return;let r=gt(e);if(!r)return;let o=new URLSearchParams(t.params);o.set(e.regionParam,r);let i=o.toString();return{...t,search:i?`?${i}`:"",params:o}}var Cn="yvee:region",xe=new Map;function vt(e){return`${Cn}:${e}`}function qe(e,t,n){if(!e.rememberRegion||!e.regions||!e.regionParam)return;if(!e.regions[n])return;let r={regionParam:e.regionParam,id:n,regionIds:Object.keys(e.regions)};xe.set(t.path,r);let o=bt();if(!o)return;try{o.setItem(vt(t.path),JSON.stringify(r))}catch{}}function Pn(e){let t=xe.get(e)??Rr(e);if(!t)return;if(!t.regionIds.includes(t.id)){br(e);return}return xe.set(e,t),t}function br(e){let t=bt();if(e!==void 0){if(xe.delete(e),!t)return;try{t.removeItem(vt(e))}catch{}return}if(xe.clear(),!t)return;try{for(let n=t.length-1;n>=0;n--){let r=t.key(n);if(r?.startsWith(`${Cn}:`))t.removeItem(r)}}catch{}}function bt(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function Rr(e){let t=bt();if(!t)return;try{return Tr(t.getItem(vt(e)))}catch{return}}function Tr(e){if(!e)return;try{let t=JSON.parse(e);if(!t.regionParam||!t.id)return;if(!Array.isArray(t.regionIds))return;if(!t.regionIds.every((n)=>typeof n==="string"))return;return{regionParam:t.regionParam,id:t.id,regionIds:t.regionIds}}catch{return}}function vn(e,t){let n=[];for(let[r,o]of e.params)if(r!==t)n.push([r,o]);return n.sort(([r,o],[i,s])=>r===i?o<s?-1:o>s?1:0:r<i?-1:1),n}async function Ye({app:e,routes:t,globalGuards:n,errors:r,error:o,url:i,data:s,signal:a}){let u=t.find(i.path),c=u?.entry.controller,d=o??(c?void 0:404),l=r.get(d??404)??(d===404?Te:te),p=d===void 0&&c?new c:new l;if(d!==void 0)p.status=d;Ln(p,i,u?.params,s),On(p,a);try{let f=await be([...n,...Ie(p.constructor)],{app:e,page:p,url:i,params:p.params,data:p.data,signal:a});if(f.kind!=="allow")return J(p),f;let h=await An(p,i,e,a);if("decision"in h)return J(p),h.decision;return{...h,url:i,dispose:Mn(p)}}catch(f){if(J(p),a.aborted)throw a.reason??f;return Pr({app:e,errors:r,globalGuards:n,url:i,data:s,failure:f,signal:a,original:p})}}function Ln(e,t,n,r){e.url=t,e.path=t.path,e.params=n??{},e.data=Object.assign(Object.create(null),e.data,r)}async function An(e,t,n,r){if(r.aborted)throw r.reason??Error("Page load aborted.");if(xr(e),e.fetch){let l=await e.fetch({url:t,params:e.params,data:e.data,signal:e.resources.signal,resources:e.resources});Object.assign(e.data,l)}if(r.aborted)throw r.reason??Error("Page load aborted.");let o=await kr(e,n,r);if(o.decision)return{decision:o.decision};if(r.aborted)throw r.reason??Error("Page load aborted.");let i=await e.body?.();if(r.aborted)throw r.reason??Error("Page load aborted.");let{bodyValue:s,moduleHead:a}=await Er(i,e);r.throwIfAborted();let u=await e.head?.();r.throwIfAborted();let c=E(B(a),B(u)),d=o.head?E(c,o.head):c;return{kind:"ready",status:e.status,head:d,...o.head?{regionHead:o.head}:{},baseHead:c,body:Array.isArray(s)?s:[s??""],page:e}}function xr(e){if(!e.strictRegions)return;if(ne(e,e.url)?.unknown!==void 0)throw new Response(null,{status:404})}async function kr(e,t,n){if(!e.regions||!e.regionParam)return{};let r=ne(e,e.url);if(!r?.id)return{};let o=r.id,i=await Sr(e,t,o,n);if(i)return{decision:i};e.region.value=o;let s=await $e(e,o);e.regionContent.value=await s.default({page:e,cache:Ne(e,o)});let a=await je(e,s);return a===void 0?{}:{head:a}}async function Sr(e,t,n,r){let o=e.regionGuards?.[n];if(!o||o.length===0)return;let i=await Re(o,{app:t,page:e,url:e.url,params:e.params,data:e.data,signal:r,region:n,from:void 0});return i.kind==="allow"?void 0:i}async function Er(e,t){if(!Cr(e))return{bodyValue:e,moduleHead:void 0};let n=typeof e.head==="function"?await e.head({page:t}):await e.head;return{bodyValue:typeof e.default==="function"?await e.default({page:t}):await e.default,moduleHead:n}}function Cr(e){return typeof e==="object"&&e!==null&&"default"in e}async function Pr({app:e,errors:t,globalGuards:n,url:r,data:o,failure:i,signal:s,original:a}){let u=i instanceof Response&&i.status>=400?i.status:500,c=t.get(u)??(u===404?Te:te);if(a.constructor===c)throw i;let d=new c;Ln(d,r,a.params,o),d.error=i,d.status=u,On(d,s);try{let l=await be([...n,...Ie(d.constructor)],{app:e,page:d,url:r,params:d.params,data:d.data,signal:s});if(l.kind!=="allow")return J(d),l;let p=await An(d,r,e,s);if("decision"in p)return J(d),p.decision;return{...p,url:r,failure:i,dispose:Mn(d)}}catch(l){if(J(d),s.aborted)throw s.reason??l;throw AggregateError([i,l],"Yvee error page failed to render.")}}function On(e,t){let n=()=>{try{J(e)}catch(r){console.error("Yvee aborted page cleanup failed",r)}};if(t.aborted)n();else t.addEventListener("abort",n,{once:!0}),e.resources.defer(()=>t.removeEventListener("abort",n))}function J(e){let t=[];try{e.regionResources.dispose()}catch(n){t.push(n)}try{e.resources.dispose()}catch(n){t.push(n)}if(bn(e),t.length===1)throw t[0];if(t.length)throw AggregateError(t,"Yvee page cleanup failed.")}function Mn(e){return()=>J(e)}async function Hn({element:e,id:t,className:n,root:r,layout:o,hydrate:i=!0,nonce:s,isCurrent:a}){let u=o?await o(r):r,c=u instanceof L?u:F("main",{class:n},u),d=await ee(c,new x(e.id||t,0,s));if(a&&!a())return;let l=document.createElement("template");if(l.innerHTML=d.ctx,!i||e.innerHTML!==l.innerHTML)e.innerHTML=d.ctx;await I.RPS(d.oz,a)}class Rt{options;previousScrollRestoration;started=!1;handlePop=(e)=>this.options.onPop(A(location.href),e.state);handleClick=(e)=>{if(!this.isEligibleClick(e))return;let t=e.target.closest("a");if(!t)return;let n=this.options.root?.();if(n&&t.closest("[data-app]")!==n)return;let r=new URL(t.href,location.href);if(r.origin!==location.origin||!this.isWithinBase(r.pathname))return;e.preventDefault(),this.options.navigate(`${r.pathname}${r.search}${r.hash}`)};constructor(e){this.options=e}start(){if(this.started)return;if(this.started=!0,this.options.history!==!1)this.previousScrollRestoration=history.scrollRestoration,history.scrollRestoration="manual",window.addEventListener("popstate",this.handlePop);document.addEventListener("click",this.handleClick)}stop(){if(!this.started)return;if(this.started=!1,typeof window<"u")window.removeEventListener("popstate",this.handlePop);if(typeof document<"u")document.removeEventListener("click",this.handleClick);if(this.previousScrollRestoration!==void 0)history.scrollRestoration=this.previousScrollRestoration,this.previousScrollRestoration=void 0}isEligibleClick(e){if(e.defaultPrevented||e.button!==0)return!1;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;if(!(e.target instanceof Element))return!1;let t=e.target.closest("a");return Boolean(t&&!t.target&&!t.hasAttribute("download"))}isWithinBase(e){let t=this.options.base==="/"?"/":`${this.options.base.replace(/\/$/,"")}/`;return t==="/"||e===t.slice(0,-1)||e.startsWith(t)}}class xt{options;displayedEntry;nextEntryId=0;scrollPositions=new Map;constructor(e){this.options=e}pop(e,t){this.captureDisplayedScroll();let n=w(e),r=this.scrollPositions.get(this.entryKey(t)??"")??Dn(t)??this.scrollPositions.get(n);if(r)this.rememberScroll(n,r);return r}initialize(e){this.trackDisplayedEntry(),this.rememberScroll(w(e),Dn(history.state)??Tt())}getScroll(e){return this.scrollPositions.get(e)}beginTransition(){this.displayedEntry=void 0}reset(){this.displayedEntry=void 0,this.scrollPositions.clear()}restoreAddress(e){if(this.options.enabled&&location.protocol!=="file:")history.replaceState(history.state,"",w(e))}write(e,t,n=!1,r){if(!this.options.enabled||location.protocol==="file:")return;let o=n?"replaceState":"pushState",i=r??(n?Tt():{x:0,y:0});history[o]({...t,path:w(e),scroll:i,yveeScrollEntry:this.newEntryKey()},"",w(e))}newEntryKey(){return`yv:${this.options.id}:${Date.now()}:${++this.nextEntryId}`}entryKey(e){if(e&&typeof e==="object"&&"yveeScrollEntry"in e&&typeof e.yveeScrollEntry==="string")return e.yveeScrollEntry;return}trackDisplayedEntry(){let e=this.options.enabled&&location.protocol!=="file:",t=e?this.entryKey(history.state):void 0;if(this.displayedEntry=t??this.newEntryKey(),e&&!t)history.replaceState({...history.state,yveeScrollEntry:this.displayedEntry},"")}captureDisplayedScroll(){let e=this.options.currentURL();if(!e||!this.displayedEntry)return;let t=Tt();return this.rememberScroll(this.displayedEntry,t),this.rememberScroll(w(e),t),this.displayedEntry=void 0,t}saveCurrentScroll(){let e=this.captureDisplayedScroll();if(!e||!this.options.enabled||location.protocol==="file:")return;history.replaceState({...history.state,path:w(this.options.currentURL()),scroll:e},"")}rememberScroll(e,t){if(this.scrollPositions.delete(e),this.scrollPositions.set(e,t),this.scrollPositions.size>100){let n=this.scrollPositions.keys().next().value;if(n)this.scrollPositions.delete(n)}}replaceAddressIfNeeded(e){if(!this.options.enabled||location.protocol==="file:")return;if(w(e)===`${location.pathname}${location.search}${location.hash}`)return;history.replaceState(history.state,"",w(e))}}function Tt(){return{x:window.scrollX,y:window.scrollY}}function Dn(e){if(!e||typeof e!=="object"||!("scroll"in e))return;let t=e.scroll;if(!t||typeof t!=="object"||!("x"in t)||!("y"in t))return;if(typeof t.x!=="number"||typeof t.y!=="number")return;return{x:t.x,y:t.y}}class kt{options;constructor(e){this.options=e}async restoreScroll(e,t,n){let r=e??this.options.history.getScroll(w(n));await new Promise((o)=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this.options.isCurrent(t))In(()=>{if(r)window.scrollTo(r.x,r.y);else window.scrollTo(0,0)}),this.options.history.trackDisplayedEntry();o()})))}async scrollToRoute(e,t){if(await new Promise((n)=>requestAnimationFrame(()=>n())),!this.options.isCurrent(t))return;if(e.hash){let n=document.getElementById(decodeURIComponent(e.hash.slice(1)));if(n){In(()=>n.scrollIntoView()),this.options.history.trackDisplayedEntry();return}}await this.restoreScroll(void 0,t,e)}}function In(e){if(!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){e();return}let t=document.documentElement,n=t.style.scrollBehavior;t.style.scrollBehavior="auto";try{e()}finally{t.style.scrollBehavior=n}}class St{id;element;status;constructor(e,t){this.id=e;this.element=t}dispose(){this.status?.remove(),this.status=void 0}mount(){let e=document.createElement("div");e.dataset.yveeRouteStatus=this.id,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.append(e),this.status=e}commit(e,t){let n=this.element();if(!t()||!n)return;let r=e.hash?document.getElementById(decodeURIComponent(e.hash.slice(1))):null,o=r&&(n===r||n.contains(r))?r:(n.matches("[data-yvee-focus]")?n:null)??n.querySelector("[data-yvee-focus]")??(n.matches("h1")?n:null)??n.querySelector("h1")??(n.tagName==="BODY"?null:n);if(o){let s=!o.hasAttribute("tabindex");if(s)o.setAttribute("tabindex","-1");if(o.focus({preventScroll:!0}),s){if(document.activeElement===o)o.addEventListener("blur",()=>{if(o.getAttribute("tabindex")==="-1")o.removeAttribute("tabindex")},{once:!0});else if(o.getAttribute("tabindex")==="-1")o.removeAttribute("tabindex")}}let i=this.status;if(!i)return;i.textContent="",requestAnimationFrame(()=>{if(t()&&i.isConnected)i.textContent=document.title||o?.textContent?.trim()||e.path})}}class Et{options;active;nonce;base;regionHead;pending=new Set;committedHead;committedBody;constructor(e){this.options=e}remember(e,t){this.committedBody=e,this.committedHead=t}reset(){this.committedHead=void 0,this.committedBody=void 0,this.base=void 0,this.regionHead=void 0}async setBody(e,t){this.options.root.value=e;try{await this.options.root.flush()}catch(n){if(this.options.isCurrent(t)&&this.committedBody){this.options.root.value=this.committedBody;try{await this.options.root.flush()}catch(r){throw AggregateError([n,r],"Route commit and rollback failed.")}}throw n}}async activate(e,t){this.active?.();try{await e.activate()}catch(n){if(this.options.isCurrent(t)){e();try{if(this.committedBody)this.options.root.value=this.committedBody,await this.options.root.flush();if(this.committedHead){let r=this.stage(this.committedHead,t);await r.ready,await r.activate(),this.active=r,this.releasePending(r)}}catch(r){throw AggregateError([n,r],"Head commit and rollback failed.")}}throw n}}releasePending(e){this.pending.delete(e)}releaseActive(){let e=this.active;this.active=void 0,e?.()}discardPending(){let e=[...this.pending];this.pending.clear();let t=[];for(let n of e)try{n()}catch(r){t.push(r)}if(t.length)throw AggregateError(t,"Pending head cleanup failed.")}stage(e,t){let n=He(e,`${this.options.id}-r${t}`,{keepExisting:!0,deferTitle:!0,idSeed:`${this.options.id}:h`,...this.nonce===void 0?{}:{nonce:this.nonce}});return this.pending.add(n),n}}class Fe{options;navigation;history;scroll;accessibility;view;nonce;element;mounted=!1;booting=!1;bootQueue;ignoreURLHook=!1;revision=0;mountEpoch=0;redirects=0;stopPage;pendingPages=new Set;currentURL;activePage;regionEpoch=0;pendingNavigation;stopURL;activeLoad;regionGuardRun;constructor(e){this.options=e;this.history=new xt({id:e.id,enabled:e.useHistory,currentURL:()=>this.currentURL}),this.scroll=new kt({history:this.history,isCurrent:(t)=>this.mounted&&t===this.revision}),this.accessibility=new St(e.id,()=>this.element),this.view=new Et({id:e.id,root:e.root,isCurrent:(t)=>this.mounted&&t===this.revision}),this.navigation=new Rt({base:e.base,history:e.useHistory,root:()=>this.element,onPop:(t,n)=>this.handlePop(t,n),navigate:(t)=>this.navigate(t)})}async mount(e={}){this.unmount();let t=this.revision;try{return await this.mountAtRevision(e,t)}catch(n){if(t===this.revision)this.unmount(),this.options.onError?.(n,this.initialURL());throw n}}async mountAtRevision(e,t){this.options.onMount?.(),this.nonce=e.nonce,this.view.nonce=e.nonce;let n=this.mountEpoch,r=()=>{if(n===this.mountEpoch)this.unmount()};if(this.element=e.id?document.getElementById(e.id)??void 0:document.body,!this.element)throw Error(`Yvee mount element not found: ${e.id}`);if(!document.body.id)document.body.id=e.id??this.options.id;this.element.dataset.app=this.options.id,this.mounted=!0,this.booting=!0,this.bootQueue=void 0,this.navigation.start(),this.options.onLoading(!0);let o=await this.resolveInitialPage(this.initialURL());if(!this.mounted||t!==this.revision){if(o.kind==="ready")o.dispose?.();return r}if(o.kind==="ready"){if(o.dispose)this.pendingPages.add(o.dispose);if(o.failure!==void 0)this.options.onError?.(o.failure,o.url);let i=o.page?Ge(o.page,o.url):void 0;if(i)o.url=i,o.page.url=i,this.history.write(i,void 0,!0);this.options.url.value=o.url,this.options.root.value=o.body;let s=E(this.options.getHead(),o.baseHead??o.head),a=this.view.stage(o.baseHead?E(s,o.regionHead??{}):E(this.options.getHead(),o.head),t);if(this.view.base=s,this.view.regionHead=o.regionHead,this.view.active=a,await a.ready,!this.mounted||t!==this.revision)return a(),r;De("root"),await a.activate(),this.view.releasePending(a);let u=this.options.getLayout();if(await Hn({element:this.element,id:this.options.id,root:this.options.root,isCurrent:()=>this.mounted&&t===this.revision,...this.nonce===void 0?{}:{nonce:this.nonce},...e.className?{className:e.className}:{},...e.hydrate===void 0?{}:{hydrate:e.hydrate},...u?{layout:u}:{}}),!this.mounted||t!==this.revision)return r;if(this.accessibility.mount(),this.stopPage=o.dispose,this.activePage=o.page,o.page)qe(o.page,o.url,o.page.region.value);if(o.dispose)this.pendingPages.delete(o.dispose);this.view.remember(o.body,E(this.options.getHead(),o.head)),this.currentURL=o.url,this.history.initialize(o.url)}if(this.options.onLoading(!1),await this.watchURL(),!this.mounted||t!==this.revision)return r;return this.settleBoot(),r}navigate(e,t,n=!1){let r=typeof e==="string"?A(e):A(`${e.path}${e.search}${e.hash}`);if(this.booting){this.queueBootNavigation(r,t,n);return}let o=this.rememberedTarget(r);if(w(o)===w(this.options.url.value))return;if(!this.mounted){this.options.url.value=o;return}if(this.isHashNavigation(o)){this.navigateHash(o,t,n);return}let i=this.regionNavigation(o);if(i==="apply"){this.navigateRegion(o,t,n);return}if(i==="noop")return;this.history.saveCurrentScroll();let s=w(o),a=n||o.hash?void 0:this.history.getScroll(s);if(this.history.write(o,t,n,a),this.options.useHistory&&location.protocol!=="file:")this.pendingNavigation={key:s,replace:n,...a?{scroll:a}:{}};this.options.url.value=o}queueBootNavigation(e,t,n){let r=this.currentURL??this.initialURL();if(w(e)===w(r)){if(this.bootQueue?.kind!=="pop")this.bootQueue=void 0;return}let o={kind:"navigate",target:w(e),replace:n};if(t!==void 0)o.state=t;this.bootQueue=o}settleBoot(){this.booting=!1;let e=this.bootQueue;if(this.bootQueue=void 0,!e||!this.mounted)return;if(e.kind==="pop"){this.handlePop(e.url,e.state);return}this.navigate(e.target,e.state,e.replace)}handlePop(e,t){if(this.booting){this.bootQueue={kind:"pop",url:e,state:t};return}let n=this.isHashOnlyPop(e),r=!n&&this.isRegionOnlyPop(e),o=this.currentURL,i=this.history.pop(e,t);if(this.pendingNavigation=void 0,this.updateURL(e),n)this.applyHashPop(e);else if(r&&o)this.applyRegionPop(o,e,i);else this.transition(e,!0,i)}isHashOnlyPop(e){let t=this.currentURL;return Boolean(this.mounted&&t&&!this.activeLoad&&!this.pendingNavigation&&e.path===t.path&&e.search===t.search&&e.hash!==t.hash)}applyHashPop(e){this.currentURL=e;let t=this.revision;this.scroll.scrollToRoute(e,t).then(()=>{if(this.mounted&&t===this.revision)this.history.trackDisplayedEntry()}).catch((n)=>{if(this.mounted&&t===this.revision)this.options.onError?.(n,e)})}rememberedTarget(e){if(!this.mounted||this.activeLoad||this.pendingNavigation)return e;if(this.currentURL&&e.path===this.currentURL.path)return e;let t=Pn(e.path);if(!t||e.params.has(t.regionParam))return e;let n=new URLSearchParams(e.params);n.set(t.regionParam,t.id);let r=n.toString();return{...e,search:r?`?${r}`:"",params:n}}back(){if(typeof history<"u")history.back()}forward(){if(typeof history<"u")history.forward()}isHashNavigation(e){let t=this.currentURL;return Boolean(t&&!this.activeLoad&&!this.pendingNavigation&&e.path===t.path&&e.search===t.search&&e.hash!==t.hash)}navigateHash(e,t,n=!1){let r=this.revision;this.history.saveCurrentScroll(),this.history.write(e,t,n),this.currentURL=e,this.updateURL(e),this.scroll.scrollToRoute(e,r).then(()=>{if(this.mounted&&r===this.revision)this.history.trackDisplayedEntry()}).catch((o)=>{if(this.mounted&&r===this.revision)this.options.onError?.(o,e)})}regionNavigation(e){let t=this.currentURL,n=this.activePage;if(!this.mounted||!t)return;if(this.activeLoad||this.pendingNavigation)return;if(!wt(n))return;if(!this.isRegionURL(e,n))return;let r=ne(n,e)?.id;if(!r)return;if(Ge(n,e))return"apply";if(r!==n.region.value)return"apply";return e.hash===t.hash?"noop":"apply"}isRegionOnlyPop(e){if(!this.mounted||!this.currentURL)return!1;if(this.activeLoad||this.pendingNavigation)return!1;let t=this.activePage;return Boolean(t&&wt(t)&&this.isRegionURL(e,t))}isRegionURL(e,t){let n=this.currentURL;return e.path===n.path&&En(e,n,t.regionParam)}async navigateRegion(e,t,n){let r=this.activePage,o=this.currentURL;if(!r||!o)return;let i=ne(r,e),s=i?.id;if(!i||s===void 0)return;let a=this.revision;if(r.strictRegions&&i.unknown!==void 0){if(this.mounted&&a===this.revision)this.options.onError?.(Error(`Unknown Yvee region: ${i.unknown}`),e);return}if(s!==r.region.value){let c=this.regionEpoch,d=await this.regionGuardDecision(r,e,s,r.region.value);if(d==="stale")return;if(!this.mounted||a!==this.revision||this.activePage!==r||c!==this.regionEpoch)return;if(d.kind==="stop")return;if(d.kind==="redirect"){this.regionGuardRedirect(d,e);return}if(r.regionWillLeave){try{await r.regionWillLeave({from:r.region.value,to:s,url:e,params:r.params,data:r.data,signal:r.resources.signal})}catch(l){if(this.mounted&&a===this.revision)this.options.onError?.(l,e);return}if(!this.mounted||a!==this.revision||this.activePage!==r||c!==this.regionEpoch)return}}this.history.saveCurrentScroll(),this.history.write(e,t,n),this.currentURL=e,this.updateURL(e),this.history.trackDisplayedEntry();let u={epoch:++this.regionEpoch,revision:a};this.swapRegion(r,e,s,u).then((c)=>{if(c==="failed"){if(this.isRegionCurrent(r,u))this.rollbackRegion(o,n);return}if(c!=="applied"||!this.isRegionCurrent(r,u))return;this.redirects=0;let d=this.canonicalizeRegion(r,e);if(!d.hash)return;this.scroll.scrollToRoute(d,a).catch((l)=>{if(this.mounted&&a===this.revision)this.options.onError?.(l,d)})})}canonicalizeRegion(e,t){let n=Ge(e,t);if(!n)return t;return this.history.write(n,void 0,!0),this.currentURL=n,this.updateURL(n),this.history.trackDisplayedEntry(),n}async applyRegionPop(e,t,n){let r=this.activePage;if(!r)return;let o=ne(r,t),i=o?.id;if(!o||i===void 0)return;this.currentURL=t;let s=this.revision,a=(f)=>{if(this.mounted&&s===this.revision)this.options.onError?.(f,t)},u=()=>{if(t.hash)this.scroll.scrollToRoute(t,s).catch(a);else this.scroll.restoreScroll(n,s,t).catch(a)},c=(f)=>{if(!this.mounted||s!==this.revision)return;if(this.currentURL=e,this.restoreURL(e),f!==void 0)this.options.onError?.(f,t)};if(r.strictRegions&&o.unknown!==void 0){c(Error(`Unknown Yvee region: ${o.unknown}`));return}if(i===r.region.value){u();return}let d=this.regionEpoch,l=await this.regionGuardDecision(r,t,i,r.region.value);if(l==="stale")return;if(!this.mounted||s!==this.revision||this.activePage!==r||this.currentURL!==t||d!==this.regionEpoch)return;if(l.kind==="stop"){c();return}if(l.kind==="redirect"){this.regionGuardRedirect(l,t);return}if(r.regionWillLeave){try{await r.regionWillLeave({from:r.region.value,to:i,url:t,params:r.params,data:r.data,signal:r.resources.signal})}catch(f){c(f);return}if(!this.mounted||s!==this.revision||this.activePage!==r||this.currentURL!==t||d!==this.regionEpoch)return}let p={epoch:++this.regionEpoch,revision:s};this.swapRegion(r,t,i,p).then((f)=>{if(!this.mounted||s!==this.revision)return;if(f==="applied")this.redirects=0,u();else if(f==="failed")this.restoreURL(e)})}async regionGuardDecision(e,t,n,r){let o=e.regionGuards?.[n];if(!o||o.length===0)return{kind:"allow"};this.abortRegionGuards();let i=new AbortController;this.regionGuardRun=i;try{return await Re(o,{app:this.options.app,page:e,url:t,params:e.params,data:e.data,signal:i.signal,region:n,from:r})}catch(s){if(i.signal.aborted)return"stale";return this.options.onError?.(s,t),{kind:"stop"}}}regionGuardRedirect(e,t){if(++this.redirects>10){this.options.onError?.(Error("Yvee redirect limit exceeded."),t);return}this.navigate(e.to,void 0,e.replace??!0)}abortRegionGuards(){let e=this.regionGuardRun;this.regionGuardRun=void 0;try{e?.abort()}catch{}}async swapRegion(e,t,n,r){if(n===e.region.value)return"applied";xn(e,e.region.value,this.scrollRoot());let o;try{o=await $e(e,n)}catch(h){if(!this.isRegionCurrent(e,r))return"stale";return this.options.onError?.(h,t),"failed"}if(!this.isRegionCurrent(e,r))return"stale";let i;if(e.refreshOnRegionChange&&e.fetch){i=new k;try{let h=await e.fetch({url:t,params:e.params,data:e.data,signal:i.signal,resources:i});Object.assign(e.data,h)}catch(h){if(this.disposeScope(i,t),!this.isRegionCurrent(e,r))return"stale";return this.options.onError?.(h,t),"failed"}if(!this.isRegionCurrent(e,r))return this.disposeScope(i,t),"stale"}let s=e.regionResources,a=e.region.value,u=this.view.regionHead;try{s.dispose()}catch(h){this.options.onError?.(h,t)}let c=i??new k;e.regionResources=c,e.region.value=n;let d;try{d=await je(e,o)}catch(h){if(this.disposeScope(c,t),!this.isRegionCurrent(e,r))return"stale";return e.regionResources=new k,e.region.value=a,this.options.onError?.(h,t),"failed"}if(!this.isRegionCurrent(e,r))return this.disposeScope(c,t),"stale";let l=Ne(e,n),p=l.get(),f;try{f=await o.default({page:e,cache:{get:()=>p,set:(h)=>{if(this.isRegionCurrent(e,r))l.set(h)}}})}catch(h){if(this.disposeScope(c,t),!this.isRegionCurrent(e,r))return"stale";return e.regionResources=new k,e.region.value=a,this.options.onError?.(h,t),"failed"}if(!this.isRegionCurrent(e,r))return this.disposeScope(c,t),"stale";if((d||u)&&this.view.base){try{if(!await this.commitRegionHead(e,d,u,t,r))return this.disposeScope(c,t),"stale"}catch(h){if(this.disposeScope(c,t),!this.isRegionCurrent(e,r))return"stale";return e.regionResources=new k,e.region.value=a,this.options.onError?.(h,t),"failed"}if(!this.isRegionCurrent(e,r))return this.disposeScope(c,t),"stale"}e.regionContent.value=f;try{await e.regionContent.flush()}catch(h){this.options.onError?.(h,t)}return qe(e,t,n),this.restoreRegionScrollAfterFrame(e,n,r),this.fireRegionDidEnter(e,n,t,r),"applied"}async commitRegionHead(e,t,n,r,o){let i=this.view.base,s=this.view.stage(E(i,t??{}),o.revision),a=this.view.active;try{if(await s.ready,!this.isRegionCurrent(e,o)){try{s()}catch(u){this.options.onError?.(u,r)}return!1}if(a?.(),await s.activate(),!this.isRegionCurrent(e,o)){try{s()}catch(u){this.options.onError?.(u,r)}return!1}}catch(u){try{s()}catch(c){this.options.onError?.(c,r)}try{let c=this.view.stage(E(i,n??{}),o.revision);await c.ready,await c.activate(),this.view.active=c,this.view.regionHead=n,this.view.releasePending(c)}catch(c){throw AggregateError([u,c],"Region head commit and rollback failed.")}throw u}return this.view.active=s,this.view.regionHead=t,this.view.releasePending(s),!0}disposeScope(e,t){try{e.dispose()}catch(n){this.options.onError?.(n,t)}}restoreRegionScrollAfterFrame(e,t,n){Lr(()=>{if(!this.mounted||this.activePage!==e||n.epoch!==this.regionEpoch)return;kn(e,t,this.scrollRoot())})}fireRegionDidEnter(e,t,n,r){if(!e.regionDidEnter)return;Promise.resolve().then(()=>e.regionDidEnter({region:t})).catch((i)=>{if(this.isRegionCurrent(e,r))this.options.onError?.(i,n)})}scrollRoot(){if(this.element)return this.element;return typeof document>"u"?void 0:document}isRegionCurrent(e,t){return this.mounted&&this.activePage===e&&t.epoch===this.regionEpoch&&t.revision===this.revision}rollbackRegion(e,t){if(this.currentURL=e,!t&&this.options.useHistory&&location.protocol!=="file:"){this.updateURL(e),history.back();return}this.restoreURL(e)}async resolveInitialPage(e){let t=e,n=new AbortController;this.activeLoad=n;let r=document.body,o=r.dataset.error;delete r.dataset.error;try{let i=Number(o),s=await this.options.load(e,n.signal,i>=400&&i<=599?i:void 0),a=0;while(s.kind==="redirect"){if(++a>10)throw Error("Yvee redirect limit exceeded.");e=A(s.to),s=await this.options.load(e,n.signal)}if(w(e)!==w(t))this.history.write(e,void 0,!0);if(s.kind==="ready")Un(s.status,r);else if(o!==void 0)r.dataset.error=o;return s}catch(i){if(o!==void 0)r.dataset.error=o;throw i}finally{if(this.activeLoad===n)this.activeLoad=void 0}}async transition(e,t=!1,n){let r=this.revision+1;try{await this.runTransition(e,t,n)}catch(o){if(!this.mounted||r!==this.revision)return;let i=[o];try{this.view.discardPending()}catch(s){i.push(s)}try{this.discardPendingPages()}catch(s){i.push(s)}if(this.options.onLoading(!1),this.options.onError?.(i.length===1?o:AggregateError(i,"Transition cleanup failed."),e),this.currentURL)this.cancelNavigation(e,t)}}async runTransition(e,t=!1,n){let r=++this.revision;this.regionEpoch++,this.abortRegionGuards(),this.history.beginTransition(),this.view.discardPending(),this.discardPendingPages(),this.activeLoad?.abort();let o=new AbortController;this.activeLoad=o,this.options.onLoading(!0);let i;try{i=await this.options.load(e,o.signal)}catch(c){if(this.activeLoad!==o||!this.mounted)return;if(this.activeLoad=void 0,this.options.onLoading(!1),this.options.onError?.(c,e),this.currentURL)this.cancelNavigation(e,t);return}if(!this.mounted||r!==this.revision||o.signal.aborted){if(i.kind==="ready")i.dispose?.();return}if(this.activeLoad=void 0,i.kind==="stop"){if(this.options.onLoading(!1),this.currentURL)this.cancelNavigation(e,t);return}if(i.kind==="redirect"){this.options.onLoading(!1),this.followRedirect(i);return}if(i.dispose)this.pendingPages.add(i.dispose);if(this.redirects=0,i.failure!==void 0)this.options.onError?.(i.failure,i.url);let s=this.view.stage(E(this.options.getHead(),i.head),r);if(await s.ready,!this.mounted||r!==this.revision||o.signal.aborted){s();return}if(await this.view.setBody(i.body,r),!this.mounted||r!==this.revision||o.signal.aborted){s();return}let a=this.pendingNavigation?.key===w(e)?this.pendingNavigation.scroll:void 0;if(await this.view.activate(s,r),!this.mounted||r!==this.revision){s();return}this.view.active=s,this.view.releasePending(s),this.clearPendingNavigation(e);let u=this.stopPage;if(this.stopPage=i.dispose,this.activePage=i.page,i.page)qe(i.page,i.url,i.page.region.value);if(i.dispose)this.pendingPages.delete(i.dispose);try{u?.()}catch(c){this.options.onError?.(c,i.url)}if(this.view.base=E(this.options.getHead(),i.baseHead??i.head),this.view.regionHead=i.regionHead,this.view.remember(i.body,E(this.options.getHead(),i.head)),this.currentURL=i.url,Un(i.status),!this.options.useHistory){this.accessibility.commit(i.url,()=>this.mounted&&r===this.revision),this.options.onLoading(!1);return}if(t)await this.scroll.restoreScroll(n,r,i.url);else if(this.history.replaceAddressIfNeeded(i.url),a&&!i.url.hash)await this.scroll.restoreScroll(a,r,i.url);else await this.scroll.scrollToRoute(i.url,r);if(this.mounted&&r===this.revision)this.accessibility.commit(i.url,()=>this.mounted&&r===this.revision),this.options.onLoading(!1)}async watchURL(){this.stopURL=await ue(async(e)=>{if(!this.mounted||this.ignoreURLHook)return;await this.transition(e)},[this.options.url],{id:`${this.options.id}_url`})}followRedirect(e){if(++this.redirects>10)throw Error("Yvee redirect limit exceeded.");this.navigate(e.to,void 0,e.replace??!0)}cancelNavigation(e,t){let n=this.pendingNavigation;if(this.pendingNavigation=void 0,!t&&n?.key===w(e)&&!n.replace&&this.options.useHistory&&location.protocol!=="file:"){this.updateURL(this.currentURL),history.back();return}this.restoreURL(this.currentURL)}clearPendingNavigation(e){if(this.pendingNavigation?.key===w(e))this.pendingNavigation=void 0}restoreURL(e){this.history.restoreAddress(e),this.updateURL(e),this.history.trackDisplayedEntry()}updateURL(e){this.ignoreURLHook=!0;try{this.options.url.value=e}finally{this.ignoreURLHook=!1}}initialURL(){return A(location.protocol==="file:"?"/":location.href)}dispose(){this.unmount()}discardPendingPages(){let e=[...this.pendingPages];this.pendingPages.clear();let t=[];for(let n of e)try{n()}catch(r){t.push(r)}if(t.length)throw AggregateError(t,"Pending page cleanup failed.")}unmount(){this.mountEpoch++,this.mounted=!1,this.booting=!1,this.bootQueue=void 0,this.revision++;let e=this.stopURL;this.stopURL=void 0;let t=this.stopPage;this.stopPage=void 0;let n=this.activeLoad;this.activeLoad=void 0,this.activePage=void 0,this.regionEpoch++;let r=[],o=(i)=>{try{i()}catch(s){r.push(s)}};if(o(()=>n?.abort()),o(()=>this.abortRegionGuards()),o(()=>e?.()),o(()=>this.view.releaseActive()),o(()=>this.view.discardPending()),o(()=>this.discardPendingPages()),o(()=>this.navigation.stop()),o(()=>{if(this.element?.id)I.resetScope(this.element.id)}),o(()=>t?.()),o(()=>this.accessibility.dispose()),this.element?.dataset.app===this.options.id)delete this.element.dataset.app;if(o(()=>this.options.onUnmount()),this.options.onLoading(!1),this.currentURL=void 0,this.view.reset(),this.pendingNavigation=void 0,this.history.reset(),r.length)throw AggregateError(r,"App disposal failed.")}}function Un(e,t=document.body){if(e>=400)t.dataset.error=String(e);else delete t.dataset.error}function Lr(e){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(e);return}setTimeout(()=>e(0),0)}var $n=new WeakMap;function Ar(e){if(!Number.isInteger(e)||e<400||e>599)throw RangeError("Expected an HTTP error status between 400 and 599.");return(t)=>($n.set(t,e),t)}var jn=(e)=>$n.get(e),Ct=new WeakMap,Nn=(e,t)=>(n)=>{let r=Ct.get(n)??[];return Ct.set(n,[...r,{path:e,transport:t}]),n},Gn=(e="/")=>Nn(e,"page"),Or=Gn,Mr=(e="/")=>Nn(e,"socket"),qn=(e)=>Ct.get(e)??[];function Hr(e,t){let n=V(t),r=V(e),s=V(`${n==="/"?"":n}/${r==="/"?"":r}`),a=[];if(s==="/")return{path:s,expression:/^\/?$/,names:a};let c=s.slice(1).split("/").map((d)=>{if(!d.startsWith(":"))return d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let l=d.slice(1);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(l)||a.includes(l))throw TypeError(`Invalid route parameter: ${d}`);return a.push(l),"([^/]+)"}).join("/");return{path:s,expression:new RegExp(`^/${c}/?$`),names:a}}class Be{base;entries=[];constructor(e="/"){this.base=e}add(e,t,n="page"){let r=Hr(e,this.base);if(this.entries.some((s)=>s.path===r.path&&s.transport===n))throw Error(`Route already registered: ${r.path}`);let i={...r,controller:t,transport:n};return this.entries.push(i),i}find(e,t="page"){let n=V(e);for(let r of this.entries){if(r.transport!==t)continue;let o=r.expression.exec(n);if(!o)continue;let i={};return r.names.forEach((s,a)=>{i[s]=decodeURIComponent(o[a+1]??"")}),{entry:r,params:i}}return}all(e){return this.entries.filter((t)=>!e||t.transport===e)}}var Dr=(e,t)=>{let n=0;return e.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g,(r,o)=>{let i=Array.isArray(t)?t[n++]:t[o];return encodeURIComponent(String(i??""))})};function Pt(e,t=new WeakMap){if(e===null||typeof e!=="object"){if(typeof e==="function"||typeof e==="symbol")throw TypeError("SSR data must be plain data; use dataFactory for request-owned services.");return e}let n=t.get(e);if(n)return n;let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&r!==null)throw TypeError("SSR data must be plain data; use dataFactory for request-owned services.");let o=Array.isArray(e)?[]:Object.create(r);t.set(e,o);for(let i of Reflect.ownKeys(e)){if(Array.isArray(e)&&i==="length")continue;let s=Object.getOwnPropertyDescriptor(e,i);if(!("value"in s))throw TypeError("SSR data must not contain accessors.");Object.defineProperty(o,i,{value:Pt(s.value,t),enumerable:s.enumerable??!1,configurable:!0,writable:!0})}if(Array.isArray(e))o.length=e.length;return Object.freeze(o)}function Bn(e,t={}){let n=t.id??e.id,r=async(o)=>{let{url:i,data:s,error:a,nonce:u}=o,c=Gr(i),d=o.signal??new AbortController().signal,l=[],p,f=!1,h;try{d.throwIfAborted();let g=s??t.data??e.data,v=t.dataFactory?await t.dataFactory({...o,signal:d,onDispose:(O)=>{l.push(O)}}):Pt(g);d.throwIfAborted();let y=await Yn(e,c,v,a,d);if(y.kind==="stop"){if(h="guard-stop",y=await Yn({...e,guards:[]},c,v,403,d),y.kind==="stop"){let O=new te;O.status=403,y={kind:"ready",status:403,body:[O.body()],head:{},url:c}}}if(y.dispose)l.push(y.dispose);let b=E(e.defaults,y.head),R=await Ir(y.body,e.layout,t.class,n,u),m=y.status,S=await Ur(R,b,n,m,u,v,t.dataFactory?g:void 0);return d.throwIfAborted(),{html:S,status:m,...h===void 0?{}:{reason:h}}}catch(g){throw p=g,f=!0,g}finally{let g=[];for(let v of l.reverse())try{await v()}catch(y){g.push(y)}if(g.length)throw AggregateError(f?[p,...g]:g,"SSR request cleanup failed.")}};return Object.assign(async(o)=>(await r(o)).html,{withStatus:r})}async function Yn(e,t,n,r,o){let i=t;for(let s=0;s<=10;s++){let a=await Ye({app:e.app,routes:e.routes,globalGuards:e.guards,errors:e.errors,...r===void 0?{}:{error:r},url:i,data:n,signal:o});if(a.kind!=="redirect")return a;if(s===10)throw Error("Yvee redirect limit exceeded during server rendering.");r=void 0,i=A(a.to)}throw Error("Yvee redirect limit exceeded during server rendering.")}async function Ir(e,t,n,r,o){let i=D(e),s=t?await t(i):i,a=s instanceof L?s:F("main",{class:n},s);return(await ee(a,new x(r,0,o))).ctx}async function Ur(e,t,n,r,o,i,s){return["<!doctype html>",'<html lang="en">',`<head>${await jr(t,"root",o)}${$r(i,o,s)}</head>`,`<body id="${Vn(n)}"${r>=400?` data-error="${Number(r)}"`:""}>${e}</body>`,"</html>"].join("")}function $r(e,t,n){let r={id:"ssr",...t===void 0?{}:{nonce:t}};try{return Ee(e,r)}catch(o){if(n===void 0||!(o instanceof TypeError))throw o;try{return Ee(n,r)}catch(i){if(!(i instanceof TypeError))throw i;return""}}}async function jr(e,t,n){e=we(e);let r=[],o=e.base?.at(-1);if(o)r.push(`<base${K(o,t)}>`);if(e.description)r.push(`<meta${K({name:"description",content:e.description},t)}>`);for(let i of e.meta??[])r.push(`<meta${K(i,t)}>`);for(let i of e.script??[]){let{body:s,...a}=i;r.push(`<script${K({...a,...n===void 0?{}:{nonce:n}},t)}>${z("script",s)}</script>`)}for(let i of Fn(e.js))r.push(`<script${K({src:i,...n===void 0?{}:{nonce:n}},t)}></script>`);if(e.title)r.push(`<title${K({},t)}>${Nr(e.title)}</title>`);if(e.style)r.push(`<style${K({...n===void 0?{}:{nonce:n}},t)}>${z("style",e.style)}</style>`);for(let i of e.link??[])r.push(`<link${K(i,t)}>`);for(let i of Fn(e.css))r.push(`<link${K({rel:"stylesheet",href:i},t)}>`);if(e.elements?.length)r.push((await ve(e.elements,t,`${t}:h`,n)).ctx);return r.join("")}function K(e,t){let n={...e,"data-yv":t};return Object.entries(n).map(([r,o])=>{if(M(r,o),o===!1)return"";if(o===!0)return` ${r}`;return` ${r}="${Vn(o)}"`}).join("")}var Vn=P,Nr=P;function Fn(e){if(e===void 0)return[];return Array.isArray(e)?e:[e]}function Gr(e){if(typeof e==="string"||e instanceof URL)return A(e);return A(`${e.path}${e.search}${e.hash}`)}class Kn{connection;path="/";params={};state=D("connecting");queue=[];disposed=!1;open(e){}message(e){}close(e){}error(e){}messageError(e,t,n){console.error(`Yvee socket ${t} failed`,e)}send(e){let t=this.connection;if(t&&t.readyState===WebSocket.OPEN){this.transmit(t,e);return}if(!this.disposed)this.queue.push(e)}sendJson(e){if(this.connection?.readyState===WebSocket.OPEN)this.connection.send(JSON.stringify(e))}attach(e){this.connection=e,this.state.value="connecting"}opened(){this.state.value="open"}flush(){let e=this.connection;if(!e||e.readyState!==WebSocket.OPEN)return;while(this.queue.length)this.transmit(e,this.queue.shift())}closed(){this.state.value="closed"}dispose(){this.disposed=!0,this.queue.length=0,this.state.value="closed"}transmit(e,t){try{e.send(JSON.stringify(t))}catch(n){console.error("Yvee socket send failed",n)}}onMessage(e,t={}){let n=this.message.bind(this);return this.message=async(r)=>{let o=(s,a)=>{if(t.onError)t.onError(s,a,r);else this.messageError(s,a,r)};try{await n(r)}catch(s){o(s,"handler")}let i;try{if(typeof r.data!=="string")throw TypeError("Expected a JSON text frame.");i=JSON.parse(r.data)}catch(s){o(s,"parse");return}try{if(t.validate&&!t.validate(i))throw TypeError("Socket payload validation failed.")}catch(s){o(s,"validation");return}try{await e(i,r)}catch(s){o(s,"handler")}},this}}class Ve{app;connections=new Map;constructor(e){this.app=e}load(e,t={}){if(t.signal?.throwIfAborted(),typeof WebSocket>"u")throw Error("WebSocket is not available in this environment.");let n=typeof location>"u"?"http://localhost":location.href,r=new URL(e,n);if(r.protocol==="https:")r.protocol="wss:";else if(r.protocol==="http:")r.protocol="ws:";else if(!["ws:","wss:"].includes(r.protocol))throw TypeError("Unsupported WebSocket protocol.");let o=this.app.routes.find(r.pathname,"socket");if(!o)throw Error(`No WebSocket route matches ${e}`);let i=this.connections.get(e);if(i)return i.controller;let s=t.retry?.attempts??0,a=t.retry?.delay??250,u=t.retry?.maxDelay??30000;if(!Number.isSafeInteger(s)||s<0||!Number.isFinite(a)||a<0||!Number.isFinite(u)||u<a)throw RangeError("Invalid WebSocket retry policy.");let d=new o.entry.controller;d.path=e,d.params=o.params;let l=new k;if(this.connections.set(e,{controller:d,scope:l}),l.defer(()=>{if(this.connections.get(e)?.controller===d)this.connections.delete(e)}),l.defer(()=>d.dispose()),t.signal)l.listen(t.signal,"abort",()=>this.unload(e),{once:!0});let p=0,f=(g)=>console.error("Yvee socket callback failed",g),h=()=>{if(l.disposed)return;let g=new WebSocket(r);d.attach(g);let v=new k,y=l.defer(()=>v.dispose());v.defer(()=>{if(g.readyState<WebSocket.CLOSING)g.close()}),v.listen(g,"open",(b)=>{d.opened();try{Promise.resolve(d.open(b)).catch(f)}catch(R){f(R)}d.flush()}),v.listen(g,"message",(b)=>{try{Promise.resolve(d.message(b)).catch(f)}catch(R){f(R)}}),v.listen(g,"error",(b)=>{try{Promise.resolve(d.error(b)).catch(f)}catch(R){f(R)}}),v.listen(g,"close",(b)=>{y(),d.closed();try{Promise.resolve(d.close(b)).catch(f)}catch(R){f(R)}if(l.disposed)return;if(p<s)l.timeout(()=>{try{h()}catch(R){f(R),l.dispose()}},Math.min(u,a*2**p++));else l.dispose()})};try{h()}catch(g){throw l.dispose(),g}return d}unload(e){this.connections.get(e)?.scope.dispose()}closeAll(){let e=[];for(let{scope:t}of[...this.connections.values()])try{t.dispose()}catch(n){e.push(n)}if(e.length)throw AggregateError(e,"Socket cleanup failed.")}}class zn extends ye{id;routes;url;loading;socket;history;data={};resources=new k;root;pageErrors=new Map;globalGuards=[];client;layout;onError;constructor(e={}){super();let t=V(e.base??"/"),n=e.history??!0;this.id=e.id??Math.random().toString(36).slice(2,9),this.url=D(A("/")),this.loading=D(!1),this.root=D([],{onError(){}}),this.routes=new Be(t),this.socket=new Ve(this),this.head({base:[{href:t==="/"?"/":`${t}/`}],meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],script:[{type:"module",src:Yr(e.client??".")}],...e.index?{js:e.index}:{}}),this.client=new Fe({id:this.id,base:t,useHistory:n,url:this.url,root:this.root,app:this,load:(r,o,i)=>this.load(r,o,i),getHead:()=>this.values,getLayout:()=>this.layout,onLoading:(r)=>{this.loading.value=r},onError:(r,o)=>{if(this.onError)this.onError(r,o);else console.error("Yvee page transition failed",r)},onMount:()=>{if(this.resources.disposed)this.resources=new k},onUnmount:()=>{let r=[];try{this.resources.dispose()}catch(o){r.push(o)}try{this.socket.closeAll()}catch(o){r.push(o)}if(r.length)throw AggregateError(r,"Owned app resources failed to close.")}}),this.history={navigate:(r,o)=>this.client.navigate(r,o),replace:(r,o)=>this.client.navigate(r,o,!0),back:()=>this.client.back(),forward:()=>this.client.forward()}}Main(e){return this.layout=e,this}use(...e){return this.globalGuards.push(...e),this}head(e){return super.head(e),this}route(e){return(t)=>(this.routes.add(e,t),t)}error(e,t){return this.pageErrors.set(e,t),this}register(...e){for(let t of e){let n=jn(t);if(n!==void 0)this.error(n,t);for(let r of qn(t))this.routes.add(r.path,t,r.transport)}return this}listRoutes(e){return this.routes.all(e)}listPaths(){return[...new Set(this.routes.all("page").map(({path:e})=>e.split("/").map((t)=>t.startsWith(":")?t.slice(1):t).join("/")))]}renderHTML(e,t={}){return this.server()({...t,url:e})}render(e={}){let t=typeof document<"u";this.data=e.data??(t?qr():void 0)??{};let n=t?yn():void 0,r=this.server({...e.id?{id:e.id}:{},...e.class?{class:e.class}:{},data:this.data}),o=t?this.client.mount({...e.id?{id:e.id}:{},...e.class?{className:e.class}:{},...e.hydrate===void 0?{}:{hydrate:e.hydrate},...e.nonce===void 0?{}:{nonce:e.nonce}}).then(()=>{document.body.dataset.yveeReady="true"}):Promise.resolve(()=>{});if(n)o.then(()=>ht(n),()=>ht(n));o.catch(()=>{});let i=Object.assign((s)=>r(s),{withStatus:r.withStatus});return Object.assign(i,{then:o.then.bind(o),catch:o.catch.bind(o),finally:o.finally.bind(o),app:this})}dispose(){this.client.dispose()}server(e={}){return Bn({id:this.id,defaults:this.values,routes:this.routes,errors:this.pageErrors,guards:this.globalGuards,data:this.data,...this.layout?{layout:this.layout}:{},app:this},e)}load(e,t,n){return Ye({app:this,routes:this.routes,globalGuards:this.globalGuards,errors:this.pageErrors,url:e,data:this.data,...n===void 0?{}:{error:n},signal:t})}}function qr(){let e=document.getElementById("ssr");if(!e?.textContent)return;try{let t=JSON.parse(e.textContent);if(typeof t==="object"&&t!==null&&!Array.isArray(t))return t;throw TypeError("Yvee SSR payload must be a JSON object.")}catch(t){console.error("Could not read Yvee SSR payload",t);return}}function Yr(e){let t=e.startsWith("/")||e.startsWith(".")?e:`/${e}`;return/\.js(?:[?#]|$)/i.test(t)?t:`${t.replace(/\/+$/,"")}/index.js`}function Fr(e){return e}function Br(e){let t={};for(let[n,r]of Object.entries(e))if(Vr(r))Kr(t,n,r);else Lt(t,n,r);return t}function Vr(e){return typeof e!=="function"}function Kr(e,t,n){let r=Object.keys(n.views);if(r.length===0)throw Error(`Yvee region level "${t}" has no views.`);let o=n.default??r[0];if(!Object.hasOwn(n.views,o))throw Error(`Yvee region level "${t}" default view "${o}" is not declared.`);Lt(e,t,_n(t,n.chrome,n.views[o]));for(let i of r)Lt(e,`${t}/${i}`,_n(t,n.chrome,n.views[i]))}function Lt(e,t,n){if(Object.hasOwn(e,t))throw Error(`Duplicate Yvee region id "${t}" in region tree.`);e[t]=n}var zr={get:()=>{return},set:()=>{}},At=new WeakMap;function _r(e,t,n){let r=At.get(e);if(!r)r=new Map,At.set(e,r);r.set(t,n)}function Wr(e,t){return At.get(e)?.get(t)}function _n(e,t,n){return async()=>{let[r,o]=await Promise.all([t(),n()]),i={default:async({page:a,cache:u})=>{let c=await o.default({page:a,cache:u});return _r(a,e,c),r.default({page:a,cache:zr,outlet:Wr(a,e)})}},s=Jr(r,o);if(s)i.head=s;return i}}function Jr(e,t){if(e.head===void 0&&t.head===void 0)return;return async({page:n})=>{let[r,o]=await Promise.all([Wn(n,e),Wn(n,t)]);if(!r)return o;if(!o)return r;return E(r,o)}}async function Wn(e,t){let n=t.head;if(n===void 0)return;let r=typeof n==="function"?await n({page:e}):await n;if(r===void 0||r===null)return;return B(r)}class Ot{store;base;schema;key;constructor(e,t,n){this.store=e;this.base=t;this.schema=n;if(!Number.isSafeInteger(n.version)||n.version<1)throw TypeError("Storage versions must be positive integers.");this.key=`${t}:v${n.version}`}get(){if(this.store.has(this.key))return this.check(this.store.get(this.key).value);for(let e=this.schema.version-1;e>=1;e--){let t=`${this.base}:v${e}`;if(!this.store.has(t))continue;let n=this.store.get(t).value;for(let o=e+1;o<=this.schema.version;o++){let i=this.schema.migrations?.[o];if(!i)throw Error(`Missing storage migration to version ${o}.`);n=i(n)}let r=this.check(n);return this.store.set(this.key,r),r}return this.check(this.schema.fallback())}set(e){return this.store.set(this.key,this.check(e)),this}remove(){return this.store.remove(this.key),this}watch(e,t){return this.store.watch(this.key,e,t)}check(e){if(!this.schema.validate(e))throw TypeError(`Invalid stored value for '${this.key}'.`);return e}}class ke{storeName;key;current;constructor(e,t,n){this.storeName=e;this.key=t;this.current=n}get value(){return this.current}set value(e){this.current=e}set(e){return this.current=e,this}save(){if(typeof window<"u")this.storage().setItem(this.key,JSON.stringify(this.current));return this}remove(){if(typeof window<"u")this.storage().removeItem(this.key);return this}as={str:()=>String(this.current??""),int:()=>Number.parseInt(String(this.current),10),float:()=>Number.parseFloat(String(this.current)),bool:()=>this.current===!0||this.current==="true"||this.current===1,json:()=>this.current};storage(){return this.storeName==="localStorage"?window.localStorage:window.sessionStorage}}class Ke{storeName;constructor(e){this.storeName=e}versioned(e,t){return new Ot(this,e,t)}watch(e,t,{signal:n,scope:r}={}){if(typeof window>"u"||n?.aborted||r?.disposed)return()=>{};let o=window,i=this.storage();i.getItem(e);let s=(u)=>{if(u.storageArea===i&&(u.key===e||u.key===null))t({key:u.key,oldValue:u.oldValue,newValue:u.newValue})},a=()=>{o.removeEventListener("storage",s),n?.removeEventListener("abort",a)};return o.addEventListener("storage",s),n?.addEventListener("abort",a,{once:!0}),r?r.defer(a):a}get(e,t){let n=typeof t==="function"?t:void 0,r;if(typeof window<"u")try{let o=this.storage().getItem(e);if(o!==null){let i=JSON.parse(o);if(!n)r=i;else if(n(i))r=i}}catch{r=void 0}if(n)return new ke(this.storeName,e,r);return new ke(this.storeName,e,r===void 0?t:r)}set(e,t){return new ke(this.storeName,e,t).save()}remove(e){if(typeof window<"u")this.storage().removeItem(e);return this}has(e){return typeof window<"u"&&this.storage().getItem(e)!==null}storage(){return this.storeName==="localStorage"?window.localStorage:window.sessionStorage}}var Zr=new Ke("localStorage"),Qr=new Ke("sessionStorage");function Mt(e){if(typeof document>"u"||typeof document.cookie!=="string")return;let t=`${e}=`;for(let n of document.cookie.split(";")){let r=n.trim();if(!r.startsWith(t))continue;let o=r.slice(t.length);try{return decodeURIComponent(o)}catch{return o}}return}function Dt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Xr(e){if(!Dt(e))return;if(typeof e.error==="string"&&e.error)return e.error;if(typeof e.message==="string"&&e.message)return e.message;return}class se extends Error{response;body;constructor(e,t,n){super(t??Xr(n)??`HTTP ${e.status} ${e.statusText}`);this.response=e;if(this.name="HTTPError",n!==void 0)this.body=n}static async fromResponse(e,t){let n;try{n=await e.clone().json()}catch{n=void 0}return new se(e,t,n)}}var Ht=new Map;function eo(e){if(!e)return;let t=e===!0?{}:e;return{header:t.header??"x-csrf-token",field:t.field??"csrfToken",endpoint:t.endpoint??"/csrf"}}function to(){if(typeof document>"u"||typeof document.querySelector!=="function")return;return document.querySelector('meta[name="csrf-token"]')?.getAttribute("content")||void 0}async function no(e,t,n){let r=Ht.get(e);if(r)return r;let o={method:"GET",headers:{accept:"application/json"}};if(n)o.signal=n;let i=(async()=>{let s=await t(e,o);if(!s.ok)throw await se.fromResponse(s);let a;try{a=await s.json()}catch{throw TypeError(`CSRF token endpoint ${e} did not return JSON.`)}let u=Dt(a)?typeof a.csrfToken==="string"?a.csrfToken:typeof a.token==="string"?a.token:void 0:void 0;if(!u)throw TypeError(`CSRF token endpoint ${e} returned no token.`);return u})().catch((s)=>{throw Ht.delete(e),s});return Ht.set(e,i),i}async function ro(e,t,n){let r=Mt("csrf_token")??to();if(r)return r;if(e.endpoint===!1)throw TypeError("No CSRF token is available; enable minting or provide a csrf_token cookie or meta tag.");return no(e.endpoint,t,n)}async function oo(e,t,n,r){let o=await ro(t,n,r),i=new Headers(e.headers);i.set(t.header,o);let s=e.body,a=i.get("content-type");if(typeof s==="string"&&(a===null||a.includes("json"))){let u;try{u=JSON.parse(s)}catch{u=void 0}if(Dt(u)&&!Object.hasOwn(u,t.field)){if(u[t.field]=o,s=JSON.stringify(u),a===null)i.set("content-type","application/json")}}return{...e,headers:i,...s===void 0?{}:{body:s}}}function Jn(e,t){return t?.throwIfAborted(),new Promise((n,r)=>{let o=()=>{clearTimeout(i),r(t?.reason)},i=setTimeout(()=>{t?.removeEventListener("abort",o),n()},e);t?.addEventListener("abort",o,{once:!0})})}async function Zn(e,t){let{validate:n,retry:r,fetch:o=globalThis.fetch,csrf:i,...s}=t,a=s,u=a.signal===void 0?e instanceof Request?e.signal:void 0:a.signal,c=(a.method??(e instanceof Request?e.method:"GET")).toUpperCase(),d=r?.attempts??0,l=r?.delayMs??100;if(!Number.isInteger(d)||d<0||d>5||!Number.isFinite(l)||l<0)throw TypeError("Retries require 0\u20135 additional attempts and a finite nonnegative delay.");if(d&&(!["GET","HEAD","OPTIONS"].includes(c)||a.body!=null||e instanceof Request&&e.body!==null))throw TypeError("Only bodyless GET, HEAD and OPTIONS requests may retry.");let p=eo(i);if(p)a=await oo(a,p,o,u);for(let f=0;;f++){u?.throwIfAborted();let h;try{h=await o(e,a)}catch(v){if(u?.throwIfAborted(),f>=d||!(v instanceof TypeError))throw v;await Jn(l,u);continue}if(u?.throwIfAborted(),!h.ok){let v=await se.fromResponse(h);if(f>=d||![408,429,500,502,503,504].includes(h.status))throw v;await h.body?.cancel(),await Jn(l,u);continue}let g=await h.json();if(u?.throwIfAborted(),!n(g))throw TypeError("Response JSON failed validation.");return g}}async function io(e,t={}){let{data:n,body:r,validate:o,csrf:i,fetch:s,method:a="POST",headers:u,...c}=t,d,l=async(p,f)=>{let h=await(s??globalThis.fetch)(p,f);return d=h,h};try{let p=new Headers(u),f=r??null;if(f===null&&n!==void 0){if(f=JSON.stringify(n),!p.has("content-type"))p.set("content-type","application/json")}let h={...c,method:a,headers:p,body:f,fetch:l,validate:o??((v)=>!0)};if(i!==void 0)h.csrf=i;let g=await Zn(e,h);return{ok:!0,status:d?.status??0,data:g}}catch(p){if(p instanceof se)return{ok:!1,status:p.response.status,error:p.message};let f=d?.status??0;if(d?.ok&&(f===204||f===205))return{ok:!0,status:f,data:void 0};return{ok:!1,status:f,error:p instanceof Error?p.message:String(p)}}}function so(e,t={},n={}){if(n.signal?.throwIfAborted(),typeof EventSource>"u")throw Error("EventSource is not available in this environment.");let r=new EventSource(e,{withCredentials:n.withCredentials??!1}),o=new k,i=r.close.bind(r);o.defer(i),r.close=()=>o.dispose();for(let[s,a]of Object.entries(t))if(a)o.listen(r,s,a);if(n.signal)o.listen(n.signal,"abort",()=>r.close(),{once:!0});return r}export{So as $,dt as ATTR,Ke as BrowserStore,Y as Column,L as DOM,Ae as DbRepository,Ri as Derived,k as DisposalScope,U as Elem,on as EventStream,te as FailurePage,nn as Field,se as HTTPError,ye as HeadDefaults,Vt as IDNotConnected,rt as IndexedDatabase,Te as MissingPage,Ue as Page,zo as QState,Ko as RecState,Qt as RecStateful,Ce as Ref,Kt as RefState,Be as RouteBook,sn as Schema,sr as Scope,Vo as SetState,Zt as SetStateful,Kn as SocketController,Ve as SocketHub,D as State,or as StateEffect,ue as StateHook,tr as StateLoaded,H as Stateful,rn as Stored,ke as StoredValue,Co as Toggled,Ot as VersionedValue,zn as Yvee,hn as allGuards,He as applyHead,me as attr_value,er as batch,ln as buildReturnTo,cn as createGuard,F as dom,Ar as error,ai as eventStream,so as eventStreams,Di as frag,j as getElementById,nr as hook,Dr as interpolate,lt as isClient,rr as loaded,Zr as local,V as normalizePath,Gn as page,mn as paramsGuard,Mt as readCookie,fn as readReturnTo,Fr as regionLevel,Br as regionTree,Ft as renderContent,ee as renderDom,Ee as renderJSONScript,io as requestForm,Zn as requestJSON,pt as requireGuard,Or as route,qt as serializePayload,Qr as session,Yt as setContentRenderer,ir as shallowEqual,Mr as socketRoute,ar as t,A as toURL,un as use,Do as useRef,gn as whenGuard};
|
|
2
|
+
import{f,r,o,s,i,e,u,a,h,c,m,g,n,l,y,d,p,w,v}from"./index-k6eg1j41.js";var Ie=(t)=>typeof t==="function",Vt=(t)=>typeof t==="number"&&!Number.isNaN(t),ne=Object.assign,Kt=(t)=>Object.entries(t),nt=(t)=>{if(t.startsWith("webkit"))t=`-${t}`;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},or=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),_t=(t)=>or.has(t.toLowerCase()),rt=(t)=>{if(Array.isArray(t))return t.filter((b)=>b!==void 0).join(" ");if(typeof t==="function")return rt(t());if(t===void 0||t===null)return"";if(typeof t==="boolean")return t?"":"false";if(typeof t==="object")try{return JSON.stringify(t)??""}catch{return String(t)}return String(t)},zt=(t)=>typeof t==="object"&&t!==null&&("value"in t);var _=(t)=>String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function J(t,b){if(!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(t))throw TypeError(`Invalid attribute name: ${t}`);let R=t.toLowerCase();if(R.startsWith("on")||R==="srcdoc")throw TypeError(`Executable attribute is not supported: ${t}`);if(b===!1||b==null)return;let T=String(b);if(R==="srcset"||R==="imagesrcset"){if(/data:/i.test(T))throw TypeError("Data URLs are not supported in srcset.");for(let x of T.split(","))Wt(x.trim().split(/\s+/)[0]??"",R)}else if(["href","src","action","formaction","poster","cite","background","xlink:href","data"].includes(R))Wt(T,R)}function Wt(t,b){let R=t.replace(/[\u0000-\u0020\u007f]/g,""),T=/^([a-z][a-z0-9+.-]*):/i.exec(R)?.[1]?.toLowerCase();if(!T||["http","https"].includes(T))return;if((b==="href"||b==="xlink:href")&&["mailto","tel","data"].includes(T))return;if(b==="src"&&/^data:image\/(?:png|gif|jpeg|webp|avif);base64,[a-z0-9+/=]*$/i.test(R))return;throw TypeError(`Unsupported URL scheme in ${b}: ${T}`)}function ae(t,b){let R=String(b??"");if(new RegExp(`</${t}(?:[\\t\\n\\f\\r />]|$)`,"i").test(R)||t==="script"&&/<!--|<script[\t\n\f\r />]/i.test(R))throw TypeError(`Unsafe inline ${t} content; use an external file or serializePayload for JSON.`);return R}function Jt(t){let b=JSON.stringify(t,(R,T)=>{if(typeof T==="bigint"||typeof T==="function"||typeof T==="symbol"||T===void 0||typeof T==="number"&&!Number.isFinite(T))throw TypeError("Bootstrap payload must contain JSON-serializable values.");return T});if(b===void 0)throw TypeError("Bootstrap payload must be JSON-serializable.");return b.replace(/[<>&\u2028\u2029]/g,(R)=>`\\u${R.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Ue(t,b){return`<script type="application/json" id="${_(b.id)}"${b.nonce===void 0?"":` nonce="${_(b.nonce)}"`}>${Jt(t)}</script>`}class ot{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,b={}){return this.e.e.animate(t,{...this.opt,...b})}get slide(){let t=({x:b=0,y:R=0},T={})=>{ne(this.opt,T);let x=[[b,R],[0,0]].map(([S,k])=>({transform:`translateX(${S}rem) translateY(${k}rem)`}));return this.e.animate(x,this.opt),this};return{left:(b={})=>t({x:-2},b),right:(b={})=>t({x:2},b),up:(b={})=>t({y:2},b),down:(b={})=>t({y:-2},b)}}fade(t={}){ne(this.opt,t);let b=[0,1].map((R)=>({opacity:R}));return this.e.animate(b,this.opt),this}shake(t="Y",b={}){ne(this.opt,b);let R=[0,5,-5,5,0].map((T)=>({transform:`translate${t}(${T}px)`}));return this.e.animate(R,this.opt),this}color(t=[],b={}){ne(this.opt,b);let R=Array.isArray(t)?t.map((T)=>({color:T})):{color:t};return this.e.animate(R,this.opt),this}bg(t=[],b={}){ne(this.opt,b);let R=Array.isArray(t)?t.map((T)=>({backgroundColor:T})):{backgroundColor:t};return this.e.animate(R,this.opt),this}bounce(t=1,b={}){ne(this.opt,b);let R=[0.5,t,1].map((T)=>({transform:`scale(${T})`}));return this.e.animate(R,this.opt),this}}var ve,Zt=(t)=>(ve=t,()=>{if(ve===t)ve=void 0}),Qt=async(t,b)=>{if(ve)return ve(t,b);return{html:(t==null?"":String(t)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};class it{e;_query;constructor(t,b){this.e=t;this._query=b}get a(){return new ot(this)}get all(){if(this._query){let t=document.querySelectorAll(this._query);if(t.length)return Array.from(t).map((b)=>b)}return[]}get attr(){let t=this.e;return{has:(b)=>t.hasAttribute(b),get:(b)=>t.getAttribute(b),del:(b)=>(t.removeAttribute(b),this),set:(b)=>{for(let[R,T]of Object.entries(b)){if(T===void 0)continue;let x=rt(T);if(J(R,x),_t(R)&&typeof T==="boolean")t.toggleAttribute(R,T);else t.setAttribute(R,x)}return this}}}get children(){return Array.from(this.e.children).map((t)=>new ee(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return"disabled"in this.e?Boolean(this.e.disabled):!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new ee(t);return}get parent(){let t=this.e.parentElement;if(t)return new ee(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,b=this;return{set:(R,T=0)=>{let x=t,S=()=>{Kt(R).forEach(([k,E])=>{if(E===void 0)return;let C=zt(E)?E.value:E;if(k in x){if(x[String(k)]!==C)x[String(k)]=C}else if(C!==null)t.setProperty(String(k),String(C));else t.removeProperty(String(k))})};if(Ie(T))b.e.addEventListener("transitionend",T,{once:!0});if(Vt(T))setTimeout(S,T);else S();return b},get:(R)=>{let T=nt(String(R));return t.getPropertyValue(T)},del:(...R)=>(R.forEach((T)=>{let x=nt(String(T));t.removeProperty(x)}),b)}}get submit(){if(!(this.e instanceof HTMLFormElement))return!1;return this.e.requestSubmit(),!0}get tag(){return this.e.tagName.toLowerCase()}get value(){return"value"in this.e?this.e.value??"":""}get unload(){return()=>{this.e.remove()}}async updateContent(t,b){let R=await Qt(t,ir(this.id));if(b==="inner")this.e.innerHTML=R.html;else this.e.insertAdjacentHTML(b,R.html);await R.commit?.()}set append(t){this.updateContent(t,"beforeend")}set appendfirst(t){this.updateContent(t,"afterbegin")}set inner(t){this.updateContent(t,"inner")}set disabled(t){let b=this.e;if("disabled"in b)b.disabled=t}set id(t){this.e.id=t}set value(t){if("value"in this.e)this.e.value=t}}var ir=(t)=>t?`${t}-0`:t;class ee extends it{add(...t){let b=t.flatMap((R)=>R.trim().split(/\s+/)).filter(Boolean);if(b.length)this.e.classList.add(...b);return()=>{if(b.length)this.e.classList.remove(...b)}}remove(...t){let b=t.flatMap((R)=>R.trim().split(/\s+/)).filter(Boolean);if(b.length)this.e.classList.remove(...b);return this}toggle(t,b){let R=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(R,b)}toggled(t,b){if(t)this.add(b);else this.remove(b);return this}clear(){return this.e.classList.remove(...Array.from(this.e.classList)),this}hasNode(t){return this.e.contains(t)}has(...t){let b=this.e.classList;return t.every((R)=>b.contains(R))}insert(t){return{HTML:(...b)=>(b.forEach((R)=>{this.e.insertAdjacentHTML(t,R)}),this),element:(...b)=>(b.forEach((R)=>{this.e.insertAdjacentElement(t,R)}),this),text:(...b)=>(b.forEach((R)=>{this.e.insertAdjacentText(t,R)}),this)}}is(t){let b=this.e.classList,R=this.e.tagName.toLocaleLowerCase(),T=!t.dom||t.dom.toLowerCase()===R,x=Array.isArray(t.class)?t.class:t.class?[t.class]:[];return T&&x.every((S)=>b.contains(S))}on(t,b,R=!1){let T=!1;if(t.indexOf("touch")>-1)T=!0;return this.e.addEventListener(t,b,{capture:R,passive:T}),this}remove_on(t,b,R=!1){return this.e.removeEventListener(t,b,R),this}timed(t,b=250){return setTimeout(()=>t(this),b),this}animate(t,b,R){let T={duration:300,easing:"ease",fill:"forwards"};if(Ie(b))R=b;else ne(T,b);let x=this.e.animate(t,T);if(R)x.finished.then(R);return this}query(t){return this.e.querySelector(t)}queryAll(t){let b=this.e.querySelectorAll(t);if(b.length)return Array.from(b).map((R)=>R);return[]}newChild(t,b={}){let R=document.createElement(t);return this.e.appendChild(R),Object.assign(R,b),new ee(R)}newChildNS(t,b={}){let R=document.createElementNS("http://www.w3.org/2000/svg",t);return this.e.appendChild(R),Object.assign(R,b),new ee(R)}get(t){return this.e[t]}}var we=new Map,Xt=(t)=>{if(t===null||typeof t!=="object")return!1;let b=Object.getPrototypeOf(t);return b===Object.prototype||b===null},te=(t)=>{if(typeof document>"u")return;let b=we.get(t);if(b?.isConnected&&b.id===t)return b;we.delete(t);let R=document.getElementById(t);if(!R)return;return we.set(t,R),R};function en(){let t=[];for(let[b,R]of we)if(!R.isConnected||R.id!==b)t.push(b),we.delete(b);return t}function Oo(t,b){if(typeof t!=="string"&&!Xt(t))return new ee(t);if(typeof document>"u")return;let R=b??document,T=(x)=>{let S=R.querySelector(x);return S?new ee(S,x):void 0};if(typeof t==="string")return T(t);if(Xt(t)){let x=t,S=[];if(x.id)S.push(`#${CSS.escape(x.id)}`);if(x.class){let E=x.class.trim().split(/\s+/).filter(Boolean).map((C)=>`.${CSS.escape(C)}`);S.push(...E)}if(!S.length)return;let k=S.join("");return T(k)}return}function Io(t,b,R){return t?b:R}class tn extends EventTarget{current;constructor(t){super();this.current=t}get value(){return this.current}get clone(){if(typeof Element<"u"&&this.current instanceof Element)return this.current;return structuredClone(this.current)}set value(t){if(Object.is(this.current,t))return;this.current=t,this.dispatchEvent(new CustomEvent("updated",{detail:t}))}}class $e{state=new tn(void 0);get element(){return this.state.value}set element(t){this.state.value=t}get $(){return this.state.value}}var Yo=()=>new $e;var st=0,at=new Set;function nn(t){if(st)at.add(t);else t()}function sr(t){st++;try{let b=t();if(b&&typeof b.then==="function")throw Promise.resolve(b).catch(()=>{}),TypeError("batch callbacks must be synchronous.");return b}finally{if(--st===0){let b=[...at];at.clear();for(let R of b)R()}}}var dt=0;async function be(t,b,{id:R=`stateHook:${++dt}`,init:T,signal:x,scope:S}={}){x?.throwIfAborted(),S?.signal.throwIfAborted();let k=[],E=()=>b.map((L)=>L.value),C=async()=>{await t(...E())};for(let L of b)k.push(await L.hook(C)(R));let P=()=>{k.splice(0).forEach((L)=>L()),x?.removeEventListener("abort",P)};x?.addEventListener("abort",P,{once:!0}),S?.defer(P);try{if(T)await C()}catch(L){throw P(),L}if(x?.aborted||S?.disposed)P();return P}async function ar(t,b,{id:R=`stateLoad:${++dt}`,init:T,signal:x,scope:S}={}){x?.throwIfAborted(),S?.signal.throwIfAborted();let k=[],E=()=>b.map((L)=>L.value),C=async()=>{await t(...E())};for(let L of b)k.push(L.loaded(C)(R));let P=()=>{k.splice(0).forEach((L)=>L()),x?.removeEventListener("abort",P)};x?.addEventListener("abort",P,{once:!0}),S?.defer(P);try{if(T)await C()}catch(L){throw P(),L}if(x?.aborted||S?.disposed)P();return P}function dr(t,b,R=!1){return[t,b,R,!1]}function cr(t,b,R=!1){return[t,b,R,!0]}async function ur(t,b,R={}){R.signal?.throwIfAborted(),R.scope?.signal.throwIfAborted();let T,x,S=[],k=!1,E=()=>{k=!0,T?.abort(),x?.(),S.splice(0).forEach((L)=>L()),R.signal?.removeEventListener("abort",E)},C=async(L)=>{if(k)return;T?.abort(),x?.();let A=new AbortController;T=A;let M=()=>A.abort();if(L.signal.addEventListener("abort",M,{once:!0}),x=()=>L.signal.removeEventListener("abort",M),L.signal.aborted)M();try{await t({signal:A.signal,isCurrent:()=>!A.signal.aborted&&L.isCurrent()},...b.map((H)=>H.value))}catch(H){throw A.abort(),x?.(),H}},P=R.id??`stateEffect:${++dt}`;R.signal?.addEventListener("abort",E,{once:!0}),R.scope?.defer(E);try{for(let L of b)S.push(await L.hook(C)(P));if(R.init){let L=new AbortController;await C({signal:L.signal,isCurrent:()=>!k})}if(R.signal?.aborted||R.scope?.disposed)E()}catch(L){throw E(),L}return E}function lr(t,b){if(Object.is(t,b))return!0;let R=Array.isArray(t)&&Array.isArray(b);if(!R&&!(i(t)&&i(b)))return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(b))return!1;if(R&&t.length!==b.length)return!1;let T=(E)=>Reflect.ownKeys(E).filter((C)=>Object.prototype.propertyIsEnumerable.call(E,C)),x=t,S=b,k=T(x);return k.length===T(S).length&&k.every((E)=>Object.prototype.propertyIsEnumerable.call(S,E)&&Object.is(Reflect.get(x,E),Reflect.get(S,E)))}class Z extends EventTarget{options;hooks=new e;loads=new e;states=new e;_value;listening=!1;controller=new AbortController;pending=new Set;failures=[];emit=()=>{this.controller.abort(),this.controller=new AbortController,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))};end;constructor(t,b={}){super();this.options=b;this._value=t}get value(){return this._value}get clone(){return structuredClone(this._value)}set value(t){let b=this.options.equals??Object.is;if(b!==!1&&b(this._value,t))return;this._value=t,this.dispatch()}async flush(){while(this.pending.size)await Promise.all([...this.pending]);let t=this.failures.splice(0);if(t.length===1)throw t[0];if(t.length)throw AggregateError(t,"State updates failed.")}report(t){this.failures.push(t);let b=new CustomEvent("error",{detail:t,cancelable:!0});this.dispatchEvent(b);try{if(this.options.onError)this.options.onError(t);else if(!b.defaultPrevented)console.error("Yvee state update failed",t)}catch(R){console.error("Yvee state error handler failed",R)}}async update(t,b){let R=[],T=async(x)=>{try{await x()}catch(S){if(b.isCurrent())R.push(S)}};for(let[x,S]of[...this.hooks.entries()]){if(!b.isCurrent())return;if(this.hooks.get(x)!==S)continue;await T(()=>S(b))}for(let[x,S]of this.states){let k=te(x);if(!k||!S.size){this.states.delete(x);continue}for(let[E,C]of[...S.entries()]){if(!b.isCurrent())return;let P=()=>b.isCurrent()&&this.states.get(x)?.get(E)===C&&te(x)===k;if(!P())continue;await T(()=>C.call(k,t,{signal:b.signal,isCurrent:P}))}}if(!b.isCurrent())return;if(!R.length){for(let[x,S]of[...this.loads.entries()]){if(!b.isCurrent())return;if(this.loads.get(x)===S)await T(S)}if(b.isCurrent())this.dispatchEvent(new CustomEvent("loaded",{detail:t}))}if(R.length===1)throw R[0];if(R.length)throw AggregateError(R,"State subscribers failed.")}listen(){if(this.options.signal?.aborted)return()=>{};if(!this.listening){let t=(R)=>{let T=this.controller,x={signal:T.signal,isCurrent:()=>!T.signal.aborted},S,k=new Promise((P)=>{let L=()=>P();T.signal.addEventListener("abort",L,{once:!0}),S=()=>T.signal.removeEventListener("abort",L)}),E=this.update(R.detail,x).catch((P)=>{if(x.isCurrent())this.report(P)}),C=Promise.race([E,k]).finally(()=>{S(),this.pending.delete(C),this.stopListeningWhenUnused()});this.pending.add(C)},b=()=>this.end?.();this.options.signal?.addEventListener("abort",b,{once:!0}),this.addEventListener("updated",t,this.options),this.listening=!0,this.end=()=>{this.removeEventListener("updated",t,this.options),this.options.signal?.removeEventListener("abort",b),this.controller.abort(),this.listening=!1,this.end=void 0}}return this.end}stopListeningWhenUnused(){if(!this.states.size&&!this.hooks.size&&!this.loads.size)this.end?.()}call(t,b){return async(R)=>(u(R,this.states).set(b,t),this.listen(),()=>{let T=this.states.get(R);if(T?.get(b)===t)T.delete(b);if(T&&!T.size)this.states.delete(R);this.stopListeningWhenUnused()})}hook(t){return async(b)=>(this.hooks.set(b,t),this.listen(),()=>{if(this.hooks.get(b)===t)this.hooks.delete(b);this.stopListeningWhenUnused()})}loaded(t){return(b)=>(this.loads.set(b,t),this.listen(),()=>{if(this.loads.get(b)===t)this.loads.delete(b);this.stopListeningWhenUnused()})}dispatch(){nn(this.emit)}}class rn extends Z{constructor(t,b={}){super(new Set(t),b)}add(t){if(this._value.has(t))return;this._value.add(t),this.dispatch()}delete(t){if(!this._value.has(t))return;this._value.delete(t),this.dispatch()}has(t){return this._value.has(t)}clear(){if(!this._value.size)return;this._value.clear(),this.dispatch()}}class on extends Z{constructor(t,b={}){super(t,b)}set(t,b){let R=this._value[t];if(!Object.hasOwn(this._value,t)||!Object.is(R,b))this._value[t]=b,this.dispatch()}delete(t){if(Object.hasOwn(this._value,t))delete this._value[t],this.dispatch()}entries(){return Object.entries(this._value)}}function Q(t,b={}){return new Z(t,b)}function Qo(t,b={}){return new rn(t,b)}function Xo(t,b={}){return new on(t,b)}function ei(t,b=!1){return Q(t,{equals:b?Object.is:!1})}function ct(){return new Map}var sn=ct();function Re(t,b=sn){let R=Object.entries(t);for(let[x,S]of R){if(!x.trim())throw TypeError("Scope names must not be empty.");if(b.has(x))throw Error(`Scope already registered: ${x}`);if(S===null||typeof S!=="object"||Array.isArray(S)||![Object.prototype,null].includes(Object.getPrototypeOf(S)))throw TypeError(`Scope must be a plain object: ${x}`)}let T=R.map(([x,S])=>[x,Object.seal({...S})]);for(let[x,S]of T)b.set(x,S)}function he(t,b=sn){let R=b.get(t);if(!R)throw Error(`Scope is not registered: ${t}`);return R}class an{constructor(){}static create(t){let b=ct();return Re(t,b),{use:(R)=>he(R,b)}}static register(t){return Re(t),{use:(b)=>he(b)}}static use(t){return he(t)}}var fr=an;class dn{static register(t){return Re(t),{use:(b)=>cn.use(b)}}static use(t){return new Proxy({},{get(b,R){return(T,x)=>{if(x.kind!=="field")throw TypeError("Field scope can only decorate class fields.");return function(){let S=he(t);if(!Object.hasOwn(S,R))throw Error(`Scope field is not registered: ${t}.${String(R)}`);return Reflect.get(S,R)}}}})}}var cn=dn;class un{state;dev;constructor(t,b){Object.seal(t);for(let R in t){let T=t[R];if(typeof T==="object"&&T!==null)Object.seal(T)}this.state=t,this.dev=b?.dev??!1}get __(){return this.state}bind(t){for(let[b,R]of Object.entries(t)){let T=b;if(this.state[T]!=null){if(this.dev)console.warn(`[Stored] ${String(T)} already bound`);continue}if(this.state[T]=R,this.dev)console.log(`[Stored] bound ${String(T)}`)}}set(t,b,R){let T=this.state[t];if(typeof T!=="object"||T===null)throw Error(`${String(t)} is not an object`);if(T[b]=R,this.dev)console.log(`[Stored] updated ${String(t)}.${String(b)} \u2192`,R)}fn(t){return()=>t(this.state)}safe(t){let b=this.state[t];if(b==null)throw Error(`${String(t)} not bound`);return b}}var ut=new Map,Ne=new Map,Te=new Map;class ln{url;stream;handlers=new Map;closed=!1;constructor(t,b=!1){this.url=t;let R=ut.get(t);if(R&&R.withCredentials!==b)throw TypeError(`Event stream ${t} is already open with different credentials settings.`);if(!R){if(typeof EventSource>"u")throw Error("EventSource is not available in this environment.");R=new EventSource(t,{withCredentials:b}),ut.set(t,R),Ne.set(t,new Map)}this.stream=R;let T=Te.get(t);if(!T)T=new Set,Te.set(t,T);T.add(this)}on(t){let b=Ne.get(this.url);for(let[R,T]of Object.entries(t)){if(this.closed)break;let x=this.handlers.get(R);if(!x)x=new Set,this.handlers.set(R,x);if(x.has(T))continue;x.add(T);let S=b.get(R);if(!S)S=new Set,b.set(R,S);if(!S.has(T))S.add(T),this.stream.addEventListener(R,T)}return this}off(t,b){let R=Ne.get(this.url);if(!R)return this;let T=t?[t]:[...this.handlers.keys()];for(let x of T){let S=this.handlers.get(x);if(!S)continue;let k=b?S.has(b)?[b]:[]:[...S],E=R.get(x);for(let C of k)if(S.delete(C),![...Te.get(this.url)??[]].some((L)=>L!==this&&L.handlers.get(x)?.has(C)))this.stream.removeEventListener(x,C),E?.delete(C);if(!S.size)this.handlers.delete(x);if(E&&!E.size)R.delete(x)}return this}close(){if(this.closed)return;this.off(),this.closed=!0;let t=Te.get(this.url);if(t?.delete(this),!t?.size)this.stream.close(),Te.delete(this.url),Ne.delete(this.url),ut.delete(this.url)}}function hi(t,b=!0){return new ln(t,b)}class re{type;primaryKey=!1;required=!1;isUnique=!1;indexed=!1;autoIncrement=!1;hasDefault=!1;defaultValue;constructor(t){this.type=t}get primary(){return this.primaryKey=!0,this}get notNull(){return this.required=!0,this}get index(){return this.indexed=!0,this}get unique(){return this.indexed=!0,this.isUnique=!0,this}get defaultNow(){if(this.type!=="date")throw TypeError("defaultNow requires a timestamp column.");return this.default(()=>new Date)}default(t){return this.hasDefault=!0,this.defaultValue=t,this}value(){return typeof this.defaultValue==="function"?this.defaultValue():structuredClone(this.defaultValue)}validate(t,b){if(b===void 0||b===null){if(this.required||this.primaryKey&&!this.autoIncrement)throw TypeError(`Column '${t}' is required.`);return}if(!(this.type==="json"||this.type==="text"&&typeof b==="string"||this.type==="boolean"&&typeof b==="boolean"||this.type==="number"&&typeof b==="number"&&Number.isFinite(b)||this.type==="integer"&&typeof b==="number"&&Number.isSafeInteger(b)||this.type==="date"&&b instanceof Date&&Number.isFinite(b.getTime())))throw TypeError(`Column '${t}' must be ${this.type}.`)}}var pr={text:()=>new re("text"),int:()=>new re("integer"),number:()=>new re("number"),boolean:()=>new re("boolean"),timestamp:()=>new re("date"),json:()=>new re("json"),serial:()=>{let t=new re("integer");return t.autoIncrement=!0,t}};class fn{table;definitions;keyPath;autoIncrement;constructor(t,b){this.table=t;this.definitions=b;if(!t)throw TypeError("An object store name is required.");let R=this.entries().filter(([,S])=>S.primaryKey);if(R.length!==1)throw TypeError(`Store '${t}' requires exactly one primary column.`);let[T,x]=R[0];this.keyPath=T,this.autoIncrement=x.autoIncrement;for(let[S,k]of this.entries()){if(!/^[A-Za-z_$][\w$]*$/.test(S))throw TypeError(`Invalid field name '${S}'.`);if(k.autoIncrement&&!k.primaryKey)throw TypeError(`Serial column '${S}' must be the primary key.`);if((k.primaryKey||k.indexed)&&!["text","integer","number","date"].includes(k.type))throw TypeError(`Column '${S}' cannot be an IndexedDB key or index.`)}}entries(){return Object.entries(this.definitions)}prepare(t){let b={...t};for(let[R,T]of this.entries()){if(b[R]===void 0&&T.hasDefault)b[R]=T.value();if(T.autoIncrement&&b[R]===void 0){delete b[R];continue}T.validate(R,b[R])}return b}upgrade(t,b){let R=t.objectStoreNames.contains(this.table)?b.objectStore(this.table):t.createObjectStore(this.table,{keyPath:this.keyPath,autoIncrement:this.autoIncrement});if(R.keyPath!==this.keyPath||R.autoIncrement!==this.autoIncrement)throw Error(`Changing the primary key of '${this.table}' requires an explicit data migration.`);for(let[T,x]of this.entries()){if(!x.indexed||x.primaryKey)continue;if(R.indexNames.contains(T)){let S=R.index(T);if(S.keyPath===T&&S.unique===x.isUnique&&!S.multiEntry)continue;R.deleteIndex(T)}R.createIndex(T,T,{unique:x.isUnique})}}}function de(t,b,R,T){return new Promise((x,S)=>{let k=t.transaction(b,R),E,C;k.oncomplete=()=>x(E),k.onabort=()=>S(C??k.error??Error("IndexedDB transaction aborted."));let P=(L)=>{C=L,k.abort()};try{T(k.objectStore(b),(L)=>{E=L},P)}catch(L){P(L)}})}class je{db;schema;constructor(t,b){this.db=t;this.schema=b}insert(t){let b=this.schema.prepare(t);return de(this.db,this.schema.table,"readwrite",(R,T)=>{R.add(b).onsuccess=(x)=>T(x.target.result)})}put(t){let b=this.schema.prepare(t);return de(this.db,this.schema.table,"readwrite",(R,T)=>{let x=R.put(b);x.onsuccess=()=>T(x.result)})}find(t){return de(this.db,this.schema.table,"readonly",(b,R)=>{let T=b.get(t);T.onsuccess=()=>R(T.result)})}findAll(t,b){return this.readAll(void 0,t,b)}findByIndex(t,b,R){return this.readAll(t,b,R)}readAll(t,b,R){if(R!==void 0&&(!Number.isInteger(R)||R<1||R>4294967295))throw RangeError("Limit must be an integer between 1 and 4294967295.");return de(this.db,this.schema.table,"readonly",(T,x)=>{let S=(t===void 0?T:T.index(t)).getAll(b,R);S.onsuccess=()=>x(S.result)})}update(t,b){if(Object.hasOwn(b,this.schema.keyPath))throw TypeError("Updates cannot change the primary key.");return de(this.db,this.schema.table,"readwrite",(R,T,x)=>{let S=R.get(t);S.onsuccess=()=>{if(S.result===void 0){T(void 0);return}try{let k=this.schema.prepare({...S.result,...b});R.put(k).onsuccess=()=>T(k)}catch(k){x(k)}}})}count(t){return de(this.db,this.schema.table,"readonly",(b,R)=>{let T=b.count(t);T.onsuccess=()=>R(T.result)})}delete(t){return de(this.db,this.schema.table,"readwrite",(b,R)=>{b.delete(t).onsuccess=()=>R(void 0)})}clear(){return de(this.db,this.schema.table,"readwrite",(t,b)=>{t.clear().onsuccess=()=>b(void 0)})}}class lt{connection;schemas;constructor(t,b){this.connection=t;this.schemas=b}static open(t,b,R,T={}){if(!t||!Number.isSafeInteger(b)||b<1)return Promise.reject(TypeError("A database name and positive integer version are required."));if(new Set(R.map((S)=>S.table)).size!==R.length)return Promise.reject(TypeError("Object store names must be unique."));let x=T.factory??globalThis.indexedDB;if(!x)return Promise.reject(Error("IndexedDB is unavailable in this environment."));return new Promise((S,k)=>{let E=x.open(t,b),C;E.onblocked=(P)=>T.onBlocked?.(P),E.onerror=()=>k(C??E.error),E.onupgradeneeded=(P)=>{let L=E.transaction;try{for(let A of R)A.upgrade(E.result,L);T.upgrade?.(E.result,L,P.oldVersion,P.newVersion)}catch(A){C=A,L.abort()}},E.onsuccess=()=>{let P=E.result;P.onversionchange=()=>P.close();try{for(let L of R){let M=P.transaction(L.table,"readonly").objectStore(L.table);if(M.keyPath!==L.keyPath||M.autoIncrement!==L.autoIncrement)throw Error(`Schema '${L.table}' changed; increase the database version.`);for(let[H,O]of L.entries()){if(!O.indexed||O.primaryKey)continue;if(!M.indexNames.contains(H)||M.index(H).unique!==O.isUnique||M.index(H).keyPath!==H||M.index(H).multiEntry)throw Error(`Index '${L.table}.${H}' changed; increase the database version.`)}}S(new lt(P,new Set(R)))}catch(L){P.close(),k(L)}}})}repository(t){if(!this.schemas.has(t))throw Error(`Schema '${t.table}' was not registered when opening this database.`);return new je(this.connection,t)}close(){this.connection.close()}}async function Pi(t,b,R={}){R.signal?.throwIfAborted(),R.scope?.signal.throwIfAborted();let T=()=>{let P=b(...t.map((L)=>L.value));if(P!=null&&typeof P.then==="function")throw Promise.resolve(P).catch(()=>{}),TypeError("Derived calculations must be synchronous; use StateEffect for async work.");return P},x=new Z(T(),R),S=x.flush.bind(x),k=!1,E=await be(async()=>{if(!k)x.value=T();await S()},t,R);x.flush=async()=>{await Promise.all(t.map((P)=>P.flush())),await S()};let C=()=>{k=!0,E()};return R.scope?.defer(C),Object.defineProperty(x,"dispose",{value:C}),x}class F{controller=new AbortController;cleanups=new Set;get signal(){return this.controller.signal}get disposed(){return this.signal.aborted}defer(t){let b=!0,R=()=>{if(!b)return;b=!1,this.cleanups.delete(R),t()};if(this.disposed)R();else this.cleanups.add(R);return R}own(t){return this.defer(()=>{if("dispose"in t)t.dispose();else t.close()}),t}listen(t,b,R,T){if(this.disposed)return()=>{};return t.addEventListener(b,R,T),this.defer(()=>t.removeEventListener(b,R,T))}timeout(t,b){if(this.disposed)return()=>{};let R=setTimeout(()=>{if(T(),!this.disposed)t()},b),T=this.defer(()=>clearTimeout(R));return T}dispose(){if(this.disposed)return;this.controller.abort();let t=[];for(let b of[...this.cleanups].reverse())try{b()}catch(R){t.push(R)}if(t.length)throw AggregateError(t,"Resource cleanup failed.")}}class Y{nonce;counter;baseId;constructor(t,b=0,R){this.nonce=R;this.baseId=t||g(4),this.counter=Number.isSafeInteger(b)&&b>=0?b:0}static fromId(t,b){let R=/^(.*)-(\d+)$/.exec(t);if(!R||!R[1])return new Y(t,0,b);return new Y(R[1],Number(R[2]),b)}get id(){return`${this.baseId}-${this.counter}`}get nextId(){return`${this.baseId}-${this.counter++}`}get childId(){return Y.fromId(`${this.nextId}-0`,this.nonce)}append(t="h"){return Y.fromId(`${t}${this.id}`,this.nonce)}}var hr=(t,b,R)=>(t.addEventListener(b,R),()=>{t.removeEventListener(b,R)}),xe={},Se={};class ge{tokens=new Map;events=new e;states=new e;windowEvents=new e;documentEvents=new e;resetST=new e;resetEV=new e;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:b,events:R,states:T}=t;if(b){if(R.size)this.events.set(b,R);if(T.length)this.states.set(b,T)}return this}push(t){return t.events.forEach((b,R)=>{b.forEach((T,x)=>{u(R,this.events).set(x,T)})}),t.states.forEach((b,R)=>{a(R,this.states).push(...b)}),this}async stage(t=()=>!0){for(let[b,R]of[...this.events.entries()]){if(!t())return this;this.events.delete(b);let T=te(b);if(!T)continue;let x={};this.tokens.set(b,x);let S=()=>t()&&this.tokens.get(b)===x&&te(b)===T,k=(P)=>{if(S())a(b,this.resetEV).push(P);else P()},E=R.get("ready");if(E){let P=await E.apply(T,[T]);if(o(P))k(P)}if(!S())return this;let C=0;for(let[P,L]of R.entries()){if(!S())return this;switch(P){case"ready":break;case"element":{let H=await L.apply(T,[T]);if(o(H))k(H)}break;case"states":case"state":let A=await L.apply(T,[T]);if(!S())return this;let M=r(A[0])?A:A[0]?[A]:[];if(!M.length)break;for(let H of M){let[O,D,j,U]=H;if(!D||D.length===0)continue;let G=r(D)?D:[D];if(!G.length)break;let q=()=>G.map((B)=>B.value),I=()=>O(...q());if(j)await I();if(!S())return this;if(U){for(let B of G)a(b,this.resetST).push(B.loaded(I)(`${b}_loaded${C++}`));continue}for(let B of G)a(b,this.resetST).push(await B.call(I,`${b}_state${C}`)(b));C++}break;case"paste":if(P.startsWith("doc")){let H=P.replace(/^doc/,"");this.documentEvents.init(H,new e).set(b,L)}else this.documentEvents.init(P,new e).set(b,L);break;case"resize":case"beforeunload":case"popstate":this.windowEvents.init(P,new e).set(b,L);break;default:if(P.startsWith("win")){let H=P.replace(/^win/,"");this.windowEvents.init(H,new e).set(b,L)}else a(b,this.resetEV).push(hr(T,P,L))}}}this.processWindowEvents,this.processDocumentEvents;for(let[b,R]of[...this.states.entries()]){if(!t())return this;if(this.states.delete(b),!te(b))continue;let T=this.tokens.get(b)??{};this.tokens.set(b,T);for(let x of R){let S=await x(b);if(!t()||this.tokens.get(b)!==T)return S(),this;a(b,this.resetST).push(S)}}return this}get processWindowEvents(){let t=(b,R)=>{let T=!1,x=(k)=>{if(!T)window.requestAnimationFrame(()=>{R.forEach((E,C)=>{let P=te(C);if(P)E.call(P,k);else this.windowEvents.get(b)?.delete(C)}),T=!1}),T=!0},S=(k)=>{R.forEach((E,C)=>{let P=te(C);if(P)E.call(P,k);else this.windowEvents.get(b)?.delete(C)})};return window.addEventListener(b,b==="scroll"?x:S),()=>{window.removeEventListener(b,b==="scroll"?x:S)}};return this.windowEvents.forEach((b,R)=>{if(b.size){if(!xe[R])xe[R]=t(R,b)}else if(xe[R])xe[R](),delete xe[R]}),this}get processDocumentEvents(){let t=(b,R)=>{let T=!1,x=(k)=>{if(!T)window.requestAnimationFrame(()=>{R.forEach((E,C)=>{let P=te(C);if(P)E.call(P,k);else this.documentEvents.get(b)?.delete(C)}),T=!1}),T=!0},S=(k)=>{R.forEach((E,C)=>{let P=te(C);if(P)E.call(P,k);else this.documentEvents.get(b)?.delete(C)})};return document.addEventListener(b,b==="scroll"?x:S),()=>{document.removeEventListener(b,b==="scroll"?x:S)}};return this.documentEvents.forEach((b,R)=>{if(b.size){if(!Se[R])Se[R]=t(R,b)}else if(Se[R])Se[R](),delete Se[R]}),this}reset(t){let b=[];if(t.forEach((R)=>{this.tokens.delete(R),this.events.delete(R),this.states.delete(R),this.windowEvents.forEach((T,x)=>{if(T.has(R))T.delete(R)}),this.documentEvents.forEach((T,x)=>{if(T.has(R))T.delete(R)});for(let T of[...this.resetEV.get(R)??[],...this.resetST.get(R)??[]])try{T()}catch(x){b.push(x)}this.resetST.delete(R),this.resetEV.delete(R)}),this.processWindowEvents,this.processDocumentEvents,b.length)throw AggregateError(b,"One or more OZ element cleanups failed.");return this}resetScope(t){let b=new Set([...this.tokens.keys(),...this.events.keys(),...this.states.keys(),...this.resetEV.keys(),...this.resetST.keys()]);for(let T of[...this.windowEvents.values(),...this.documentEvents.values()])for(let x of T.keys())b.add(x);let R=[...b].filter((T)=>T===t||T.startsWith(`${t}-`));return this.reset(R),this}async RPS(t,b=()=>!0){if(!b())return this;let R=en();if(this.reset(R),t){let T=t.keys;if(T.length)await this.reset(T).push(t).stage(b)}return this.processWindowEvents,this.processDocumentEvents,this}}var X=new ge;class ke{xid;IDM;map=new e;states=[];events=new e;OZ;internalId;constructor(t,b=new Y,R){this.xid=t;this.IDM=b;this.OZ=R??new ge}attr_push(t,b,R){let T=R??t;if(J(T,void 0),R==="style"&&!/^(?:--[A-Za-z0-9_-]+|-?[A-Za-z][A-Za-z0-9-]*)$/.test(t))return;if(!this.map.has(T))this.map.set(T,[]);let x=R?`${m(t)}:${b};`:b;this.map.get(T).push(x)}get attr(){let t=[""];return this.map.forEach((b,R)=>{let T=b.join("");t.push(T?`${R}="${T}"`:R)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.internalId=t,this.map.set("id",[_(t)])}get id(){return this.internalId??this.map.get("id")?.join("")}setId(t){this.internalId=t}}var ft,hn=(t)=>{ft=t},gr=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],pn=(t)=>gr.includes(t.toLowerCase()),Ge=async(t,b)=>{let R=await Promise.resolve(t);if(r(R)){let T=[];for(let x of R)T.push(await Ge(x,b));return T.join("")}else if(R instanceof n){if(!ft)throw Error("The DOM renderer has not been initialized.");let{ctx:T,oz:x}=await ft(R,b.IDM);return b.OZ.push(x),T}else if(s(R)){if(R instanceof Set)return _([...R].join(" "));return _(c(R))}else if(o(R))return await Ge(R(),b);else if(R!==void 0&&R!==null)return _(R);return""},qe=async(t,b,R)=>{let T=b?Y.fromId(b,R):new Y(void 0,0,R),x=new ke(T.id,T);return{ctx:await Ge(t,x),catt:x}};async function mr(t,b,R){let T=this.id;if(T){let{ctx:x,catt:S}=await qe(t,T,b);if(R&&!R.isCurrent())return!1;if(this.innerHTML!==x)return this.innerHTML=x,await X.RPS(S.OZ,R?.isCurrent),!0}return!1}var pt=async(t,b,R,T=[])=>{if(r(t))for(let x of t)await pt(x,t.length,R,T);else if(t instanceof Z)if(b>1)await pt(await l("div",{},t),b,R,T);else{let x=t.value,S=x instanceof n?"dom":"ctx",{ctx:k,catt:E}=await qe(x,R.xid+"-0",R.IDM.nonce);R.xid=E.xid,T.push(k),R.OZ.push(E.OZ),R.states.push(t.call(function(C,P){return mr.call(this,C,R.IDM.nonce,P)},S))}else T.push(await Ge(t,R))};class ht{tag;ctx;closing;constructor(t="",b){this.tag=t;this.ctx=b;let R=pn(t);this.closing=R?"":`</${t}>`}async process(t,b=this.ctx,R=[]){for(let T of b)await pt(await Promise.resolve(T),b.length,t,R);return R.join("")}async get(t){let b=t.xid,R,T=this.tag.toLowerCase();if(T==="script"||T==="style"){let x=async(S)=>{let k=await S;if(Array.isArray(k))return(await Promise.all(k.map(x))).join("");if(typeof k==="function")return x(k());if(k==null)return"";if(typeof k!=="string"&&typeof k!=="number")throw TypeError("Inline script/style children must be static text.");return String(k)};R=ae(T,await x(this.ctx))}else R=await this.process(t);if(!this.tag)return R;if(t.events.size||t.states.length)t.id=b;if(pn(this.tag)){if(R)throw TypeError(`<${this.tag}> cannot contain child content.`);return`<${this.tag}${t.attr}>`}return`<${this.tag}${t.attr}>${R}${this.closing}`}}var yr=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),gt=(t)=>yr.has(t.toLowerCase()),Ee=(t)=>{if(r(t))return _(t.filter((b)=>b!==void 0).join(" "));if(i(t))return _(c(t));if(o(t))return Ee(t());if(t===void 0||t===null)return"";return f(t)?t?"":"false":_(String(t))},ue=(t)=>{if(r(t))return t.filter((b)=>b!==void 0).join(" ");if(i(t))return c(t);if(o(t))return ue(t());if(t===void 0||t===null)return"";return f(t)?t?"":"false":String(t)};var vr=(t)=>/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(t),wr=(t)=>/^(?:--[A-Za-z0-9_-]+|-?[A-Za-z][A-Za-z0-9-]*)$/.test(t);function br(t,b){switch(b??t){case"style":return function(R){this.style.setProperty(t,ue(R))};default:return function(R){if(gt(t)&&(typeof R==="boolean"||R==null)){this.toggleAttribute(t,R===!0);return}let T=ue(R);J(t,T),this.setAttribute(t,T)}}}class mt{attr;constructor(t={}){this.attr=t}get(t,b=this.attr,R){let T=(x,S)=>{if(R!=="style"&>(x)&&(S===!1||S===null))return;if(R!=="style"&&!(S instanceof Z)&&!s(S))J(x,ue(S));if(r(S)){if(!R)J(x,ue(S));t.attr_push(x,Ee(S),R)}else if(S instanceof Z){let k=R?`${R}_${x}`:x;t.states.push(S.call(br(x,R),k)),T(x,S.value)}else if(s(S)){if(i(S)&&!R)this.get(t,S,x)}else t.attr_push(x,Ee(S),R)};h(b).forEach(([x,S])=>{let k=String(x);if(!(R==="style"?wr(k):vr(k)))return;if(k==="id"&&S!==void 0)t.setId(ue(S instanceof Z?S.value:S));if(k==="ref"){if(S instanceof $e)t.events.obj({element(){S.element=this}})}else if(["on"].includes(k))s(b.on)&&t.events.obj(b.on);else{if(S===void 0)return;T(k,S)}})}unload(t){let b;if(t in this.attr)b=this.attr[t],delete this.attr[t];return b}}async function le(t,b=new Y){let{tag:R,attr:T,ctx:x}=await Promise.resolve(t),S=b instanceof Y?b:Y.fromId(b),k=S.nextId,E=new ke(k,S),C=["script","style"].includes(R.toLowerCase())&&S.nonce!==void 0?{...T,nonce:S.nonce}:T,P=new mt(C),L=new ht(R,x);return P.get(E),{ctx:await L.get(E),oz:E.OZ.set(E),id:E.id}}hn(le);Zt(async(t,b)=>{let{ctx:R,catt:T}=await qe(t,b);return{html:R,commit:()=>X.RPS(T.OZ).then(()=>{return})}});function K(t){if(t===void 0)return[];return Array.isArray(t)?t:[t]}function V(t,b){return{...t,...b,base:[...K(t.base),...K(b.base)],meta:[...K(t.meta),...K(b.meta)],link:[...K(t.link),...K(b.link)],script:[...K(t.script),...K(b.script)],css:[...K(t.css),...K(b.css)],js:[...K(t.js),...K(b.js)],elements:[...K(t.elements),...K(b.elements)]}}function oe(t){if(t instanceof n)return{elements:[t]};if(typeof t==="string")return{style:t};return t??{}}class Le{values={};head(t){let b=oe(t);if(b.title!==void 0)this.values.title=b.title;let R=[this.values.style,b.style].filter(Boolean).join(`
|
|
3
|
+
`);if(R)this.values.style=R;if(b.description!==void 0)this.values.description=b.description;for(let T of["base","meta","link","script","css","js","elements"]){let x=b[T];if(x===void 0)continue;let S=this.values[T],k=S===void 0?[]:Array.isArray(S)?S:[S],E=Array.isArray(x)?x:[x];this.values[T]=[...k,...E]}}}function Pe(t){let b=String(t.base?.at(-1)?.href??"/"),R=new URL(b,"http://yvee.local"),T=b.startsWith("/"),x=(P)=>{if(!P.startsWith("./")&&!P.startsWith("../"))return P;let L=new URL(P,R);return T?`${L.pathname}${L.search}${L.hash}`:L.href},S=(P,L)=>{let A=P[L];if(typeof A!=="string")return P;let M=x(A);return M===A?P:{...P,[L]:M}},k=(P,L)=>{let A=!1,M=P.map((H)=>{let O=L(H);if(O!==H)A=!0;return O});return A?M:P},E=(P)=>{if(!Array.isArray(P))return x(P);return k(P,x)},C={...t};if(t.link)C.link=k(t.link,(P)=>S(P,"href"));if(t.script)C.script=k(t.script,(P)=>S(P,"src"));if(t.css!==void 0)C.css=E(t.css);if(t.js!==void 0)C.js=E(t.js);return C}async function Ce(t,b,R,T){let x=new Y(R,0,T),S=new ge,k=[],E;for(let C of t){let P=await yt(C,b),L=await le(P,x);k.push(L.ctx),S.push(L.oz),E=L.id??E}return{ctx:k.join(""),oz:S,id:E}}async function yt(t,b){let R=await Promise.resolve(t);if(Array.isArray(R)){let S=[];for(let k of R)S.push(await yt(k,b));return S}if(!(R instanceof n))return R;let T=[];for(let S of R.ctx)T.push(await yt(S,b));let x=R.tag?{...R.attr,"data-yv":b}:R.attr;return new n(R.tag,x,T)}function vt(t){let b=new Set;return{ready:Promise.all(t.map((T)=>new Promise((x)=>{let S=!1,k=()=>{if(S)return;S=!0,b.delete(k),window.clearTimeout(E),T.removeEventListener("load",k),T.removeEventListener("error",k),x()},E=window.setTimeout(k,8000);b.add(k),T.addEventListener("load",k,{once:!0}),T.addEventListener("error",k,{once:!0})}))).then(()=>{return}),cancel(){for(let T of[...b])T()}}}function Ye(t,b,R={}){if(typeof document>"u")return Object.assign(()=>{},{ready:Promise.resolve(),async activate(){},cancel(){}});t=Pe(t);let T=document.title,x=t.title??"",S=[],k,E,C=[],P=!R.deferTitle,L=!1,A=!1,M=vt([]);if(P&&t.title!==void 0)document.title=x,L=!0;let H=(U,G)=>{if(U==="script"&&typeof G.src==="string"){let I=new URL(G.src,document.baseURI).href,B=String(G.type??"").toLowerCase();if(Array.from(document.head.querySelectorAll("script[src]")).find((Bt)=>Bt.src===I&&Bt.type.toLowerCase()===B))return}let q=document.createElement(U);for(let[I,B]of Object.entries(G)){if(I==="body"||B===void 0)continue;if(J(I,B),typeof B==="boolean")q.toggleAttribute(I,B);else q.setAttribute(I,String(B))}if((U==="script"||U==="style")&&R.nonce!==void 0)q.setAttribute("nonce",R.nonce);if(q.dataset.yv=b,U==="script"&&G.body)q.textContent=ae("script",G.body);if(document.head.append(q),S.push(q),U==="link"&&String(G.rel??"").toLowerCase()==="stylesheet")C.push(q)},O=R.idSeed??`${b}:h`,D=(async()=>{if(!R.keepExisting)Fe(b);let U=t.base?.at(-1);if(U)document.head.querySelectorAll("base").forEach((I)=>I.remove()),H("base",U);if(t.description)H("meta",{name:"description",content:t.description});for(let I of t.meta??[])H("meta",I);for(let I of t.link??[])H("link",I);let G=K(t.css);for(let I of G)H("link",{rel:"stylesheet",href:I});for(let I of t.script??[])H("script",I);let q=K(t.js);for(let I of q)H("script",{src:I});if(t.style){let I=document.createElement("style");if(I.textContent=ae("style",t.style),R.nonce!==void 0)I.setAttribute("nonce",R.nonce);I.dataset.yv=b,document.head.append(I),S.push(I)}if(t.elements?.length){if(E=await Ce(t.elements,b,O,R.nonce),A)return;let I=document.createElement("template");I.innerHTML=E.ctx;let B=Array.from(I.content.children);for(let W of B){if(W instanceof HTMLTitleElement){if(k=W,R.deferTitle)continue;L=!0}document.head.append(W),S.push(W)}C.push(...B.filter((W)=>W instanceof HTMLLinkElement&&W.rel.toLowerCase()==="stylesheet"))}if(M=vt(C),await M.ready,P&&E)await X.RPS(E.oz,()=>!A&&P)})(),j=()=>{if(A)return;A=!0;try{if(M.cancel(),P&&E)X.resetScope(O)}finally{let U=k?.textContent??x,G=L&&document.title===U;if(S.forEach((q)=>q.remove()),k?.remove(),G)document.title=T}};return j.ready=D.catch((U)=>{throw j(),U}),j.activate=async()=>{if(A||P)return;if(T=document.title,P=!0,k)document.head.querySelectorAll("title").forEach((U)=>{if(U!==k)U.remove()}),document.head.append(k),S.push(k),L=!0;else if(t.title!==void 0)document.title=x,L=!0;if(E)await X.RPS(E.oz,()=>!A&&P)},j.cancel=()=>M.cancel(),j}function Fe(t){if(typeof document>"u")return;document.head.querySelectorAll("[data-yv]").forEach((b)=>{if(b.getAttribute("data-yv")!==t)return;if(b instanceof HTMLScriptElement&&b.hasAttribute("src"))return;b.remove()})}var wt=typeof window<"u";var ie=(t)=>{let b=t.split(/[?#]/,1)[0]||"/",T=(b.startsWith("/")?b:`/${b}`).replace(/\/{2,}/g,"/");return T.length>1?T.replace(/\/+$/,""):"/"},z=(t)=>{let b=typeof window>"u"?"http://localhost":window.location.href,R=t instanceof URL?t:new URL(t,b);return{path:ie(R.pathname),search:R.search,hash:R.hash,params:R.searchParams}},N=(t)=>`${t.path}${t.search}${t.hash}`;var bt=new WeakMap,gn=(t)=>(...b)=>t(...b),mn=(...t)=>(b)=>(bt.set(b,[...t,...bt.get(b)??[]]),b),Be=(t)=>bt.get(t)??[];function yn(t,b){return wn(b,"returnTo",N(t))}function vn(t){if(typeof t==="string"){let b=t.indexOf("?");if(b===-1)return;let R=t.indexOf("#",b),T=t.slice(b+1,R===-1?void 0:R);return new URLSearchParams(T).get("returnTo")??void 0}if(t instanceof URL)return t.searchParams.get("returnTo")??void 0;return t.params.get("returnTo")??void 0}function wn(t,b,R){let T=t.indexOf("#"),x=T===-1?t:t.slice(0,T),S=T===-1?"":t.slice(T),k=`${b}=${encodeURIComponent(R)}`,E=x.indexOf("?");if(E===-1)return`${x}?${k}${S}`;let C=x.slice(0,E),P=x.slice(E+1),L=!P||P.endsWith("&")?"":"&";return`${C}?${P}${L}${k}${S}`}function Rr(t,b){if(t.kind!=="redirect"||t.returnTo===void 0||t.returnTo===!1)return t;let{returnTo:R,...T}=t;return{...T,to:wn(t.to,"returnTo",R===!0?N(b):R)}}async function Ae(t,b){let R={...b,server:b.server??!wt};for(let T of t){R.signal.throwIfAborted();let x=await T(R);if(R.signal.throwIfAborted(),x&&x.kind!=="allow")return Rr(x,R.url)}return{kind:"allow"}}function He(t,b){return Ae(t,b)}function Rt(t,b={kind:"stop"}){return async(R)=>await t(R)?{kind:"allow"}:typeof b==="function"?b(R):b}function bn(...t){return async(b)=>{for(let R of t){b.signal.throwIfAborted();let T=await R(b);if(b.signal.throwIfAborted(),T&&T.kind!=="allow")return T}return{kind:"allow"}}}function Rn(t,b){return async(R)=>await t(R)?b(R):{kind:"allow"}}function Tn(t,b={kind:"stop"}){return Rt(async(R)=>{for(let[T,x]of Object.entries(t)){let S=R.params[T];if(S===void 0||!await x(S,R))return!1}return!0},b)}var me;function xn(){let t={consumed:!1,closed:!1};return me=t,t}function Tt(t){if(t.closed=!0,me===t)me=void 0}function Tr(){return me&&!me.closed?me:void 0}class Ve{resources=new F;url={path:"/",search:"",hash:"",params:new URLSearchParams};path="/";params={};data={};error;status=200;#e=typeof document>"u"?void 0:Tr();regionParam;defaultRegion;rememberRegion;regions;keepAlive;regionGuards;refreshOnRegionChange;strictRegions;region=Q("");regionContent=Q(void 0);regionResources=new F;ssrData(){if(typeof document>"u")return this.data;let t=this.#e;if(!t||t.closed||t.consumed)return;return t.consumed=!0,this.data}}class Me extends Ve{body(){return p("main",{role:"status",children:["Page not found: ",this.path]})}}class fe extends Ve{status=500;body(){return d("main",{role:"alert",children:"This page could not be loaded."})}}var Sn=new WeakMap;function Et(t){return Boolean(t?.regions&&Object.keys(t.regions).length&&t.regionParam)}function xt(t){if(!t.regions)return;if(t.defaultRegion&&t.regions[t.defaultRegion])return t.defaultRegion;return Object.keys(t.regions)[0]}function pe(t,b){if(!t.regions||!t.regionParam)return;let R=b.params.get(t.regionParam);if(R&&t.regions[R])return{id:R};if(R){let x=xt(t);return x===void 0?{unknown:R}:{unknown:R,id:x}}let T=xt(t);return T===void 0?void 0:{id:T}}function Ke(t,b){let R=t.regions?.[b];if(!R)return Promise.reject(Error(`Unknown Yvee region: ${b}`));let T=Sn.get(t);if(!T)T=new Map,Sn.set(t,T);let x=T.get(b);if(!x)x=R(),T.set(b,x);return x}async function _e(t,b){let R=b.head;if(R===void 0)return;let T=typeof R==="function"?await R({page:t}):await R;if(T===void 0||T===null)return;return oe(T)}var St=new WeakMap,xr=5,Sr={get:()=>{return},set:()=>{}};function kr(t){let b=t.keepAlive;if(b===void 0)return 0;let R=b===!0?xr:b;return Number.isFinite(R)&&R>0?Math.floor(R):0}function ze(t,b){let R=kr(t);if(!R)return Sr;let T=St.get(t);if(!T)T=new Map,St.set(t,T);let x=T;return{get:()=>x.get(b),set:(S)=>{x.delete(b),x.set(b,S);while(x.size>R){let k=x.keys().next();if(k.done)break;x.delete(k.value)}}}}function En(t){St.delete(t)}var kt=new WeakMap;function Ln(t){if(!t||typeof t.querySelectorAll!=="function")return[];try{return Array.from(t.querySelectorAll("[data-scroll-key]"))}catch{return[]}}function Pn(t){let b=typeof t.getAttribute==="function"?t.getAttribute("data-scroll-key"):null;return b?b:void 0}function Cn(t,b,R=Hn()){let T=Ln(R);if(!T.length)return;let x=kt.get(t);if(!x)x=new Map,kt.set(t,x);let S=x.get(b);if(!S)S=new Map,x.set(b,S);for(let k of T){let E=Pn(k);if(!E)continue;S.set(E,{top:k.scrollTop,left:k.scrollLeft})}}function An(t,b,R=Hn()){let T=kt.get(t)?.get(b);if(!T||T.size===0)return!1;let x=!1;for(let S of Ln(R)){let k=Pn(S);if(!k)continue;let E=T.get(k);if(!E)continue;S.scrollTop=E.top,S.scrollLeft=E.left,x=!0}return x}function Hn(){return typeof document>"u"?void 0:document}function Mn(t,b,R){let T=kn(t,R),x=kn(b,R);return T.length===x.length&&T.every(([S,k],E)=>S===x[E][0]&&k===x[E][1])}function We(t,b){if(!t.regions||!t.regionParam)return;let R=b.params.get(t.regionParam);if(!R||t.regions[R])return;let T=xt(t);if(!T)return;let x=new URLSearchParams(b.params);x.set(t.regionParam,T);let S=x.toString();return{...b,search:S?`?${S}`:"",params:x}}var On="yvee:region",Oe=new Map;function Lt(t){return`${On}:${t}`}function Je(t,b,R){if(!t.rememberRegion||!t.regions||!t.regionParam)return;if(!t.regions[R])return;let T={regionParam:t.regionParam,id:R,regionIds:Object.keys(t.regions)};Oe.set(b.path,T);let x=Pt();if(!x)return;try{x.setItem(Lt(b.path),JSON.stringify(T))}catch{}}function Dn(t){let b=Oe.get(t)??Lr(t);if(!b)return;if(!b.regionIds.includes(b.id)){Er(t);return}return Oe.set(t,b),b}function Er(t){let b=Pt();if(t!==void 0){if(Oe.delete(t),!b)return;try{b.removeItem(Lt(t))}catch{}return}if(Oe.clear(),!b)return;try{for(let R=b.length-1;R>=0;R--){let T=b.key(R);if(T?.startsWith(`${On}:`))b.removeItem(T)}}catch{}}function Pt(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function Lr(t){let b=Pt();if(!b)return;try{return Pr(b.getItem(Lt(t)))}catch{return}}function Pr(t){if(!t)return;try{let b=JSON.parse(t);if(!b.regionParam||!b.id)return;if(!Array.isArray(b.regionIds))return;if(!b.regionIds.every((R)=>typeof R==="string"))return;return{regionParam:b.regionParam,id:b.id,regionIds:b.regionIds}}catch{return}}function kn(t,b){let R=[];for(let[T,x]of t.params)if(T!==b)R.push([T,x]);return R.sort(([T,x],[S,k])=>T===S?x<k?-1:x>k?1:0:T<S?-1:1),R}async function Ze({app:t,routes:b,globalGuards:R,errors:T,error:x,url:S,data:k,signal:E}){let C=b.find(S.path),P=C?.entry.controller,L=x??(P?void 0:404),A=T.get(L??404)??(L===404?Me:fe),M=L===void 0&&P?new P:new A;if(L!==void 0)M.status=L;In(M,S,C?.params,k),$n(M,E);try{let H=await Ae([...R,...Be(M.constructor)],{app:t,page:M,url:S,params:M.params,data:M.data,signal:E});if(H.kind!=="allow")return ce(M),H;let O=await Un(M,S,t,E);if("decision"in O)return ce(M),O.decision;return{...O,url:S,dispose:Nn(M)}}catch(H){if(ce(M),E.aborted)throw E.reason??H;return Dr({app:t,errors:T,globalGuards:R,url:S,data:k,failure:H,signal:E,original:M})}}function In(t,b,R,T){t.url=b,t.path=b.path,t.params=R??{},t.data=Object.assign(Object.create(null),t.data,T)}async function Un(t,b,R,T){if(T.aborted)throw T.reason??Error("Page load aborted.");if(Cr(t),t.fetch){let A=await t.fetch({url:b,params:t.params,data:t.data,signal:t.resources.signal,resources:t.resources});Object.assign(t.data,A)}if(T.aborted)throw T.reason??Error("Page load aborted.");let x=await Ar(t,R,T);if(x.decision)return{decision:x.decision};if(T.aborted)throw T.reason??Error("Page load aborted.");let S=await t.body?.();if(T.aborted)throw T.reason??Error("Page load aborted.");let{bodyValue:k,moduleHead:E}=await Mr(S,t);T.throwIfAborted();let C=await t.head?.();T.throwIfAborted();let P=V(oe(E),oe(C)),L=x.head?V(P,x.head):P;return{kind:"ready",status:t.status,head:L,...x.head?{regionHead:x.head}:{},baseHead:P,body:Array.isArray(k)?k:[k??""],page:t}}function Cr(t){if(!t.strictRegions)return;if(pe(t,t.url)?.unknown!==void 0)throw new Response(null,{status:404})}async function Ar(t,b,R){if(!t.regions||!t.regionParam)return{};let T=pe(t,t.url);if(!T?.id)return{};let x=T.id,S=await Hr(t,b,x,R);if(S)return{decision:S};t.region.value=x;let k=await Ke(t,x);t.regionContent.value=await k.default({page:t,cache:ze(t,x)});let E=await _e(t,k);return E===void 0?{}:{head:E}}async function Hr(t,b,R,T){let x=t.regionGuards?.[R];if(!x||x.length===0)return;let S=await He(x,{app:b,page:t,url:t.url,params:t.params,data:t.data,signal:T,region:R,from:void 0});return S.kind==="allow"?void 0:S}async function Mr(t,b){if(!Or(t))return{bodyValue:t,moduleHead:void 0};let R=typeof t.head==="function"?await t.head({page:b}):await t.head;return{bodyValue:typeof t.default==="function"?await t.default({page:b}):await t.default,moduleHead:R}}function Or(t){return typeof t==="object"&&t!==null&&"default"in t}async function Dr({app:t,errors:b,globalGuards:R,url:T,data:x,failure:S,signal:k,original:E}){let C=S instanceof Response&&S.status>=400?S.status:500,P=b.get(C)??(C===404?Me:fe);if(E.constructor===P)throw S;let L=new P;In(L,T,E.params,x),L.error=S,L.status=C,$n(L,k);try{let A=await Ae([...R,...Be(L.constructor)],{app:t,page:L,url:T,params:L.params,data:L.data,signal:k});if(A.kind!=="allow")return ce(L),A;let M=await Un(L,T,t,k);if("decision"in M)return ce(L),M.decision;return{...M,url:T,failure:S,dispose:Nn(L)}}catch(A){if(ce(L),k.aborted)throw k.reason??A;throw AggregateError([S,A],"Yvee error page failed to render.")}}function $n(t,b){let R=()=>{try{ce(t)}catch(T){console.error("Yvee aborted page cleanup failed",T)}};if(b.aborted)R();else b.addEventListener("abort",R,{once:!0}),t.resources.defer(()=>b.removeEventListener("abort",R))}function ce(t){let b=[];try{t.regionResources.dispose()}catch(R){b.push(R)}try{t.resources.dispose()}catch(R){b.push(R)}if(En(t),b.length===1)throw b[0];if(b.length)throw AggregateError(b,"Yvee page cleanup failed.")}function Nn(t){return()=>ce(t)}async function jn({element:t,id:b,className:R,root:T,layout:x,hydrate:S=!0,nonce:k,isCurrent:E}){let C=x?await x(T):T,P=C instanceof n?C:d("main",{class:R,children:C}),L=await le(P,new Y(t.id||b,0,k));if(E&&!E())return;let A=document.createElement("template");if(A.innerHTML=L.ctx,!S||t.innerHTML!==A.innerHTML)t.innerHTML=L.ctx;await X.RPS(L.oz,E)}class Ct{options;previousScrollRestoration;started=!1;handlePop=(t)=>this.options.onPop(z(location.href),t.state);handleClick=(t)=>{if(!this.isEligibleClick(t))return;let b=t.target.closest("a");if(!b)return;let R=this.options.root?.();if(R&&b.closest("[data-app]")!==R)return;let T=new URL(b.href,location.href);if(T.origin!==location.origin||!this.isWithinBase(T.pathname))return;t.preventDefault(),this.options.navigate(`${T.pathname}${T.search}${T.hash}`)};constructor(t){this.options=t}start(){if(this.started)return;if(this.started=!0,this.options.history!==!1)this.previousScrollRestoration=history.scrollRestoration,history.scrollRestoration="manual",window.addEventListener("popstate",this.handlePop);document.addEventListener("click",this.handleClick)}stop(){if(!this.started)return;if(this.started=!1,typeof window<"u")window.removeEventListener("popstate",this.handlePop);if(typeof document<"u")document.removeEventListener("click",this.handleClick);if(this.previousScrollRestoration!==void 0)history.scrollRestoration=this.previousScrollRestoration,this.previousScrollRestoration=void 0}isEligibleClick(t){if(t.defaultPrevented||t.button!==0)return!1;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return!1;if(!(t.target instanceof Element))return!1;let b=t.target.closest("a");return Boolean(b&&!b.target&&!b.hasAttribute("download"))}isWithinBase(t){let b=this.options.base==="/"?"/":`${this.options.base.replace(/\/$/,"")}/`;return b==="/"||t===b.slice(0,-1)||t.startsWith(b)}}class Ht{options;displayedEntry;nextEntryId=0;scrollPositions=new Map;constructor(t){this.options=t}pop(t,b){this.captureDisplayedScroll();let R=N(t),T=this.scrollPositions.get(this.entryKey(b)??"")??Gn(b)??this.scrollPositions.get(R);if(T)this.rememberScroll(R,T);return T}initialize(t){this.trackDisplayedEntry(),this.rememberScroll(N(t),Gn(history.state)??At())}getScroll(t){return this.scrollPositions.get(t)}beginTransition(){this.displayedEntry=void 0}reset(){this.displayedEntry=void 0,this.scrollPositions.clear()}restoreAddress(t){if(this.options.enabled&&location.protocol!=="file:")history.replaceState(history.state,"",N(t))}write(t,b,R=!1,T){if(!this.options.enabled||location.protocol==="file:")return;let x=R?"replaceState":"pushState",S=T??(R?At():{x:0,y:0});history[x]({...b,path:N(t),scroll:S,yveeScrollEntry:this.newEntryKey()},"",N(t))}newEntryKey(){return`yv:${this.options.id}:${Date.now()}:${++this.nextEntryId}`}entryKey(t){if(t&&typeof t==="object"&&"yveeScrollEntry"in t&&typeof t.yveeScrollEntry==="string")return t.yveeScrollEntry;return}trackDisplayedEntry(){let t=this.options.enabled&&location.protocol!=="file:",b=t?this.entryKey(history.state):void 0;if(this.displayedEntry=b??this.newEntryKey(),t&&!b)history.replaceState({...history.state,yveeScrollEntry:this.displayedEntry},"")}captureDisplayedScroll(){let t=this.options.currentURL();if(!t||!this.displayedEntry)return;let b=At();return this.rememberScroll(this.displayedEntry,b),this.rememberScroll(N(t),b),this.displayedEntry=void 0,b}saveCurrentScroll(){let t=this.captureDisplayedScroll();if(!t||!this.options.enabled||location.protocol==="file:")return;history.replaceState({...history.state,path:N(this.options.currentURL()),scroll:t},"")}rememberScroll(t,b){if(this.scrollPositions.delete(t),this.scrollPositions.set(t,b),this.scrollPositions.size>100){let R=this.scrollPositions.keys().next().value;if(R)this.scrollPositions.delete(R)}}replaceAddressIfNeeded(t){if(!this.options.enabled||location.protocol==="file:")return;if(N(t)===`${location.pathname}${location.search}${location.hash}`)return;history.replaceState(history.state,"",N(t))}}function At(){return{x:window.scrollX,y:window.scrollY}}function Gn(t){if(!t||typeof t!=="object"||!("scroll"in t))return;let b=t.scroll;if(!b||typeof b!=="object"||!("x"in b)||!("y"in b))return;if(typeof b.x!=="number"||typeof b.y!=="number")return;return{x:b.x,y:b.y}}class Mt{options;constructor(t){this.options=t}async restoreScroll(t,b,R){let T=t??this.options.history.getScroll(N(R));await new Promise((x)=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this.options.isCurrent(b))qn(()=>{if(T)window.scrollTo(T.x,T.y);else window.scrollTo(0,0)}),this.options.history.trackDisplayedEntry();x()})))}async scrollToRoute(t,b){if(await new Promise((R)=>requestAnimationFrame(()=>R())),!this.options.isCurrent(b))return;if(t.hash){let R=document.getElementById(decodeURIComponent(t.hash.slice(1)));if(R){qn(()=>R.scrollIntoView()),this.options.history.trackDisplayedEntry();return}}await this.restoreScroll(void 0,b,t)}}function qn(t){if(!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){t();return}let b=document.documentElement,R=b.style.scrollBehavior;b.style.scrollBehavior="auto";try{t()}finally{b.style.scrollBehavior=R}}class Ot{id;element;status;constructor(t,b){this.id=t;this.element=b}dispose(){this.status?.remove(),this.status=void 0}mount(){let t=document.createElement("div");t.dataset.yveeRouteStatus=this.id,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.append(t),this.status=t}commit(t,b){let R=this.element();if(!b()||!R)return;let T=t.hash?document.getElementById(decodeURIComponent(t.hash.slice(1))):null,x=T&&(R===T||R.contains(T))?T:(R.matches("[data-yvee-focus]")?R:null)??R.querySelector("[data-yvee-focus]")??(R.matches("h1")?R:null)??R.querySelector("h1")??(R.tagName==="BODY"?null:R);if(x){let k=!x.hasAttribute("tabindex");if(k)x.setAttribute("tabindex","-1");if(x.focus({preventScroll:!0}),k){if(document.activeElement===x)x.addEventListener("blur",()=>{if(x.getAttribute("tabindex")==="-1")x.removeAttribute("tabindex")},{once:!0});else if(x.getAttribute("tabindex")==="-1")x.removeAttribute("tabindex")}}let S=this.status;if(!S)return;S.textContent="",requestAnimationFrame(()=>{if(b()&&S.isConnected)S.textContent=document.title||x?.textContent?.trim()||t.path})}}class Dt{options;active;nonce;base;regionHead;pending=new Set;committedHead;committedBody;constructor(t){this.options=t}remember(t,b){this.committedBody=t,this.committedHead=b}reset(){this.committedHead=void 0,this.committedBody=void 0,this.base=void 0,this.regionHead=void 0}async setBody(t,b){this.options.root.value=t;try{await this.options.root.flush()}catch(R){if(this.options.isCurrent(b)&&this.committedBody){this.options.root.value=this.committedBody;try{await this.options.root.flush()}catch(T){throw AggregateError([R,T],"Route commit and rollback failed.")}}throw R}}async activate(t,b){this.active?.();try{await t.activate()}catch(R){if(this.options.isCurrent(b)){t();try{if(this.committedBody)this.options.root.value=this.committedBody,await this.options.root.flush();if(this.committedHead){let T=this.stage(this.committedHead,b);await T.ready,await T.activate(),this.active=T,this.releasePending(T)}}catch(T){throw AggregateError([R,T],"Head commit and rollback failed.")}}throw R}}releasePending(t){this.pending.delete(t)}releaseActive(){let t=this.active;this.active=void 0,t?.()}discardPending(){let t=[...this.pending];this.pending.clear();let b=[];for(let R of t)try{R()}catch(T){b.push(T)}if(b.length)throw AggregateError(b,"Pending head cleanup failed.")}stage(t,b){let R=Ye(t,`${this.options.id}-r${b}`,{keepExisting:!0,deferTitle:!0,idSeed:`${this.options.id}:h`,...this.nonce===void 0?{}:{nonce:this.nonce}});return this.pending.add(R),R}}class Qe{options;navigation;history;scroll;accessibility;view;nonce;element;mounted=!1;booting=!1;bootQueue;ignoreURLHook=!1;revision=0;mountEpoch=0;redirects=0;stopPage;pendingPages=new Set;currentURL;activePage;regionEpoch=0;pendingNavigation;stopURL;activeLoad;regionGuardRun;constructor(t){this.options=t;this.history=new Ht({id:t.id,enabled:t.useHistory,currentURL:()=>this.currentURL}),this.scroll=new Mt({history:this.history,isCurrent:(b)=>this.mounted&&b===this.revision}),this.accessibility=new Ot(t.id,()=>this.element),this.view=new Dt({id:t.id,root:t.root,isCurrent:(b)=>this.mounted&&b===this.revision}),this.navigation=new Ct({base:t.base,history:t.useHistory,root:()=>this.element,onPop:(b,R)=>this.handlePop(b,R),navigate:(b)=>this.navigate(b)})}async mount(t={}){this.unmount();let b=this.revision;try{return await this.mountAtRevision(t,b)}catch(R){if(b===this.revision)this.unmount(),this.options.onError?.(R,this.initialURL());throw R}}async mountAtRevision(t,b){this.options.onMount?.(),this.nonce=t.nonce,this.view.nonce=t.nonce;let R=this.mountEpoch,T=()=>{if(R===this.mountEpoch)this.unmount()};if(this.element=t.id?document.getElementById(t.id)??void 0:document.body,!this.element)throw Error(`Yvee mount element not found: ${t.id}`);if(!document.body.id)document.body.id=t.id??this.options.id;this.element.dataset.app=this.options.id,this.mounted=!0,this.booting=!0,this.bootQueue=void 0,this.navigation.start(),this.options.onLoading(!0);let x=await this.resolveInitialPage(this.initialURL());if(!this.mounted||b!==this.revision){if(x.kind==="ready")x.dispose?.();return T}if(x.kind==="ready"){if(x.dispose)this.pendingPages.add(x.dispose);if(x.failure!==void 0)this.options.onError?.(x.failure,x.url);let S=x.page?We(x.page,x.url):void 0;if(S)x.url=S,x.page.url=S,this.history.write(S,void 0,!0);this.options.url.value=x.url,this.options.root.value=x.body;let k=V(this.options.getHead(),x.baseHead??x.head),E=this.view.stage(x.baseHead?V(k,x.regionHead??{}):V(this.options.getHead(),x.head),b);if(this.view.base=k,this.view.regionHead=x.regionHead,this.view.active=E,await E.ready,!this.mounted||b!==this.revision)return E(),T;Fe("root"),await E.activate(),this.view.releasePending(E);let C=this.options.getLayout();if(await jn({element:this.element,id:this.options.id,root:this.options.root,isCurrent:()=>this.mounted&&b===this.revision,...this.nonce===void 0?{}:{nonce:this.nonce},...t.className?{className:t.className}:{},...t.hydrate===void 0?{}:{hydrate:t.hydrate},...C?{layout:C}:{}}),!this.mounted||b!==this.revision)return T;if(this.accessibility.mount(),this.stopPage=x.dispose,this.activePage=x.page,x.page)Je(x.page,x.url,x.page.region.value);if(x.dispose)this.pendingPages.delete(x.dispose);this.view.remember(x.body,V(this.options.getHead(),x.head)),this.currentURL=x.url,this.history.initialize(x.url)}if(this.options.onLoading(!1),await this.watchURL(),!this.mounted||b!==this.revision)return T;return this.settleBoot(),T}navigate(t,b,R=!1){let T=typeof t==="string"?z(t):z(`${t.path}${t.search}${t.hash}`);if(this.booting){this.queueBootNavigation(T,b,R);return}let x=this.rememberedTarget(T);if(N(x)===N(this.options.url.value))return;if(!this.mounted){this.options.url.value=x;return}if(this.isHashNavigation(x)){this.navigateHash(x,b,R);return}let S=this.regionNavigation(x);if(S==="apply"){this.navigateRegion(x,b,R);return}if(S==="noop")return;this.history.saveCurrentScroll();let k=N(x),E=R||x.hash?void 0:this.history.getScroll(k);if(this.history.write(x,b,R,E),this.options.useHistory&&location.protocol!=="file:")this.pendingNavigation={key:k,replace:R,...E?{scroll:E}:{}};this.options.url.value=x}queueBootNavigation(t,b,R){let T=this.currentURL??this.initialURL();if(N(t)===N(T)){if(this.bootQueue?.kind!=="pop")this.bootQueue=void 0;return}let x={kind:"navigate",target:N(t),replace:R};if(b!==void 0)x.state=b;this.bootQueue=x}settleBoot(){this.booting=!1;let t=this.bootQueue;if(this.bootQueue=void 0,!t||!this.mounted)return;if(t.kind==="pop"){this.handlePop(t.url,t.state);return}this.navigate(t.target,t.state,t.replace)}handlePop(t,b){if(this.booting){this.bootQueue={kind:"pop",url:t,state:b};return}let R=this.isHashOnlyPop(t),T=!R&&this.isRegionOnlyPop(t),x=this.currentURL,S=this.history.pop(t,b);if(this.pendingNavigation=void 0,this.updateURL(t),R)this.applyHashPop(t);else if(T&&x)this.applyRegionPop(x,t,S);else this.transition(t,!0,S)}isHashOnlyPop(t){let b=this.currentURL;return Boolean(this.mounted&&b&&!this.activeLoad&&!this.pendingNavigation&&t.path===b.path&&t.search===b.search&&t.hash!==b.hash)}applyHashPop(t){this.currentURL=t;let b=this.revision;this.scroll.scrollToRoute(t,b).then(()=>{if(this.mounted&&b===this.revision)this.history.trackDisplayedEntry()}).catch((R)=>{if(this.mounted&&b===this.revision)this.options.onError?.(R,t)})}rememberedTarget(t){if(!this.mounted||this.activeLoad||this.pendingNavigation)return t;if(this.currentURL&&t.path===this.currentURL.path)return t;let b=Dn(t.path);if(!b||t.params.has(b.regionParam))return t;let R=new URLSearchParams(t.params);R.set(b.regionParam,b.id);let T=R.toString();return{...t,search:T?`?${T}`:"",params:R}}back(){if(typeof history<"u")history.back()}forward(){if(typeof history<"u")history.forward()}isHashNavigation(t){let b=this.currentURL;return Boolean(b&&!this.activeLoad&&!this.pendingNavigation&&t.path===b.path&&t.search===b.search&&t.hash!==b.hash)}navigateHash(t,b,R=!1){let T=this.revision;this.history.saveCurrentScroll(),this.history.write(t,b,R),this.currentURL=t,this.updateURL(t),this.scroll.scrollToRoute(t,T).then(()=>{if(this.mounted&&T===this.revision)this.history.trackDisplayedEntry()}).catch((x)=>{if(this.mounted&&T===this.revision)this.options.onError?.(x,t)})}regionNavigation(t){let b=this.currentURL,R=this.activePage;if(!this.mounted||!b)return;if(this.activeLoad||this.pendingNavigation)return;if(!Et(R))return;if(!this.isRegionURL(t,R))return;let T=pe(R,t)?.id;if(!T)return;if(We(R,t))return"apply";if(T!==R.region.value)return"apply";return t.hash===b.hash?"noop":"apply"}isRegionOnlyPop(t){if(!this.mounted||!this.currentURL)return!1;if(this.activeLoad||this.pendingNavigation)return!1;let b=this.activePage;return Boolean(b&&Et(b)&&this.isRegionURL(t,b))}isRegionURL(t,b){let R=this.currentURL;return t.path===R.path&&Mn(t,R,b.regionParam)}async navigateRegion(t,b,R){let T=this.activePage,x=this.currentURL;if(!T||!x)return;let S=pe(T,t),k=S?.id;if(!S||k===void 0)return;let E=this.revision;if(T.strictRegions&&S.unknown!==void 0){if(this.mounted&&E===this.revision)this.options.onError?.(Error(`Unknown Yvee region: ${S.unknown}`),t);return}if(k!==T.region.value){let P=this.regionEpoch,L=await this.regionGuardDecision(T,t,k,T.region.value);if(L==="stale")return;if(!this.mounted||E!==this.revision||this.activePage!==T||P!==this.regionEpoch)return;if(L.kind==="stop")return;if(L.kind==="redirect"){this.regionGuardRedirect(L,t);return}if(T.regionWillLeave){try{await T.regionWillLeave({from:T.region.value,to:k,url:t,params:T.params,data:T.data,signal:T.resources.signal})}catch(A){if(this.mounted&&E===this.revision)this.options.onError?.(A,t);return}if(!this.mounted||E!==this.revision||this.activePage!==T||P!==this.regionEpoch)return}}this.history.saveCurrentScroll(),this.history.write(t,b,R),this.currentURL=t,this.updateURL(t),this.history.trackDisplayedEntry();let C={epoch:++this.regionEpoch,revision:E};this.swapRegion(T,t,k,C).then((P)=>{if(P==="failed"){if(this.isRegionCurrent(T,C))this.rollbackRegion(x,R);return}if(P!=="applied"||!this.isRegionCurrent(T,C))return;this.redirects=0;let L=this.canonicalizeRegion(T,t);if(!L.hash)return;this.scroll.scrollToRoute(L,E).catch((A)=>{if(this.mounted&&E===this.revision)this.options.onError?.(A,L)})})}canonicalizeRegion(t,b){let R=We(t,b);if(!R)return b;return this.history.write(R,void 0,!0),this.currentURL=R,this.updateURL(R),this.history.trackDisplayedEntry(),R}async applyRegionPop(t,b,R){let T=this.activePage;if(!T)return;let x=pe(T,b),S=x?.id;if(!x||S===void 0)return;this.currentURL=b;let k=this.revision,E=(H)=>{if(this.mounted&&k===this.revision)this.options.onError?.(H,b)},C=()=>{if(b.hash)this.scroll.scrollToRoute(b,k).catch(E);else this.scroll.restoreScroll(R,k,b).catch(E)},P=(H)=>{if(!this.mounted||k!==this.revision)return;if(this.currentURL=t,this.restoreURL(t),H!==void 0)this.options.onError?.(H,b)};if(T.strictRegions&&x.unknown!==void 0){P(Error(`Unknown Yvee region: ${x.unknown}`));return}if(S===T.region.value){C();return}let L=this.regionEpoch,A=await this.regionGuardDecision(T,b,S,T.region.value);if(A==="stale")return;if(!this.mounted||k!==this.revision||this.activePage!==T||this.currentURL!==b||L!==this.regionEpoch)return;if(A.kind==="stop"){P();return}if(A.kind==="redirect"){this.regionGuardRedirect(A,b);return}if(T.regionWillLeave){try{await T.regionWillLeave({from:T.region.value,to:S,url:b,params:T.params,data:T.data,signal:T.resources.signal})}catch(H){P(H);return}if(!this.mounted||k!==this.revision||this.activePage!==T||this.currentURL!==b||L!==this.regionEpoch)return}let M={epoch:++this.regionEpoch,revision:k};this.swapRegion(T,b,S,M).then((H)=>{if(!this.mounted||k!==this.revision)return;if(H==="applied")this.redirects=0,C();else if(H==="failed")this.restoreURL(t)})}async regionGuardDecision(t,b,R,T){let x=t.regionGuards?.[R];if(!x||x.length===0)return{kind:"allow"};this.abortRegionGuards();let S=new AbortController;this.regionGuardRun=S;try{return await He(x,{app:this.options.app,page:t,url:b,params:t.params,data:t.data,signal:S.signal,region:R,from:T})}catch(k){if(S.signal.aborted)return"stale";return this.options.onError?.(k,b),{kind:"stop"}}}regionGuardRedirect(t,b){if(++this.redirects>10){this.options.onError?.(Error("Yvee redirect limit exceeded."),b);return}this.navigate(t.to,void 0,t.replace??!0)}abortRegionGuards(){let t=this.regionGuardRun;this.regionGuardRun=void 0;try{t?.abort()}catch{}}async swapRegion(t,b,R,T){if(R===t.region.value)return"applied";Cn(t,t.region.value,this.scrollRoot());let x;try{x=await Ke(t,R)}catch(O){if(!this.isRegionCurrent(t,T))return"stale";return this.options.onError?.(O,b),"failed"}if(!this.isRegionCurrent(t,T))return"stale";let S;if(t.refreshOnRegionChange&&t.fetch){S=new F;try{let O=await t.fetch({url:b,params:t.params,data:t.data,signal:S.signal,resources:S});Object.assign(t.data,O)}catch(O){if(this.disposeScope(S,b),!this.isRegionCurrent(t,T))return"stale";return this.options.onError?.(O,b),"failed"}if(!this.isRegionCurrent(t,T))return this.disposeScope(S,b),"stale"}let k=t.regionResources,E=t.region.value,C=this.view.regionHead;try{k.dispose()}catch(O){this.options.onError?.(O,b)}let P=S??new F;t.regionResources=P,t.region.value=R;let L;try{L=await _e(t,x)}catch(O){if(this.disposeScope(P,b),!this.isRegionCurrent(t,T))return"stale";return t.regionResources=new F,t.region.value=E,this.options.onError?.(O,b),"failed"}if(!this.isRegionCurrent(t,T))return this.disposeScope(P,b),"stale";let A=ze(t,R),M=A.get(),H;try{H=await x.default({page:t,cache:{get:()=>M,set:(O)=>{if(this.isRegionCurrent(t,T))A.set(O)}}})}catch(O){if(this.disposeScope(P,b),!this.isRegionCurrent(t,T))return"stale";return t.regionResources=new F,t.region.value=E,this.options.onError?.(O,b),"failed"}if(!this.isRegionCurrent(t,T))return this.disposeScope(P,b),"stale";if((L||C)&&this.view.base){try{if(!await this.commitRegionHead(t,L,C,b,T))return this.disposeScope(P,b),"stale"}catch(O){if(this.disposeScope(P,b),!this.isRegionCurrent(t,T))return"stale";return t.regionResources=new F,t.region.value=E,this.options.onError?.(O,b),"failed"}if(!this.isRegionCurrent(t,T))return this.disposeScope(P,b),"stale"}t.regionContent.value=H;try{await t.regionContent.flush()}catch(O){this.options.onError?.(O,b)}return Je(t,b,R),this.restoreRegionScrollAfterFrame(t,R,T),this.fireRegionDidEnter(t,R,b,T),"applied"}async commitRegionHead(t,b,R,T,x){let S=this.view.base,k=this.view.stage(V(S,b??{}),x.revision),E=this.view.active;try{if(await k.ready,!this.isRegionCurrent(t,x)){try{k()}catch(C){this.options.onError?.(C,T)}return!1}if(E?.(),await k.activate(),!this.isRegionCurrent(t,x)){try{k()}catch(C){this.options.onError?.(C,T)}return!1}}catch(C){try{k()}catch(P){this.options.onError?.(P,T)}try{let P=this.view.stage(V(S,R??{}),x.revision);await P.ready,await P.activate(),this.view.active=P,this.view.regionHead=R,this.view.releasePending(P)}catch(P){throw AggregateError([C,P],"Region head commit and rollback failed.")}throw C}return this.view.active=k,this.view.regionHead=b,this.view.releasePending(k),!0}disposeScope(t,b){try{t.dispose()}catch(R){this.options.onError?.(R,b)}}restoreRegionScrollAfterFrame(t,b,R){Ir(()=>{if(!this.mounted||this.activePage!==t||R.epoch!==this.regionEpoch)return;An(t,b,this.scrollRoot())})}fireRegionDidEnter(t,b,R,T){if(!t.regionDidEnter)return;Promise.resolve().then(()=>t.regionDidEnter({region:b})).catch((S)=>{if(this.isRegionCurrent(t,T))this.options.onError?.(S,R)})}scrollRoot(){if(this.element)return this.element;return typeof document>"u"?void 0:document}isRegionCurrent(t,b){return this.mounted&&this.activePage===t&&b.epoch===this.regionEpoch&&b.revision===this.revision}rollbackRegion(t,b){if(this.currentURL=t,!b&&this.options.useHistory&&location.protocol!=="file:"){this.updateURL(t),history.back();return}this.restoreURL(t)}async resolveInitialPage(t){let b=t,R=new AbortController;this.activeLoad=R;let T=document.body,x=T.dataset.error;delete T.dataset.error;try{let S=Number(x),k=await this.options.load(t,R.signal,S>=400&&S<=599?S:void 0),E=0;while(k.kind==="redirect"){if(++E>10)throw Error("Yvee redirect limit exceeded.");t=z(k.to),k=await this.options.load(t,R.signal)}if(N(t)!==N(b))this.history.write(t,void 0,!0);if(k.kind==="ready")Yn(k.status,T);else if(x!==void 0)T.dataset.error=x;return k}catch(S){if(x!==void 0)T.dataset.error=x;throw S}finally{if(this.activeLoad===R)this.activeLoad=void 0}}async transition(t,b=!1,R){let T=this.revision+1;try{await this.runTransition(t,b,R)}catch(x){if(!this.mounted||T!==this.revision)return;let S=[x];try{this.view.discardPending()}catch(k){S.push(k)}try{this.discardPendingPages()}catch(k){S.push(k)}if(this.options.onLoading(!1),this.options.onError?.(S.length===1?x:AggregateError(S,"Transition cleanup failed."),t),this.currentURL)this.cancelNavigation(t,b)}}async runTransition(t,b=!1,R){let T=++this.revision;this.regionEpoch++,this.abortRegionGuards(),this.history.beginTransition(),this.view.discardPending(),this.discardPendingPages(),this.activeLoad?.abort();let x=new AbortController;this.activeLoad=x,this.options.onLoading(!0);let S;try{S=await this.options.load(t,x.signal)}catch(P){if(this.activeLoad!==x||!this.mounted)return;if(this.activeLoad=void 0,this.options.onLoading(!1),this.options.onError?.(P,t),this.currentURL)this.cancelNavigation(t,b);return}if(!this.mounted||T!==this.revision||x.signal.aborted){if(S.kind==="ready")S.dispose?.();return}if(this.activeLoad=void 0,S.kind==="stop"){if(this.options.onLoading(!1),this.currentURL)this.cancelNavigation(t,b);return}if(S.kind==="redirect"){this.options.onLoading(!1),this.followRedirect(S);return}if(S.dispose)this.pendingPages.add(S.dispose);if(this.redirects=0,S.failure!==void 0)this.options.onError?.(S.failure,S.url);let k=this.view.stage(V(this.options.getHead(),S.head),T);if(await k.ready,!this.mounted||T!==this.revision||x.signal.aborted){k();return}if(await this.view.setBody(S.body,T),!this.mounted||T!==this.revision||x.signal.aborted){k();return}let E=this.pendingNavigation?.key===N(t)?this.pendingNavigation.scroll:void 0;if(await this.view.activate(k,T),!this.mounted||T!==this.revision){k();return}this.view.active=k,this.view.releasePending(k),this.clearPendingNavigation(t);let C=this.stopPage;if(this.stopPage=S.dispose,this.activePage=S.page,S.page)Je(S.page,S.url,S.page.region.value);if(S.dispose)this.pendingPages.delete(S.dispose);try{C?.()}catch(P){this.options.onError?.(P,S.url)}if(this.view.base=V(this.options.getHead(),S.baseHead??S.head),this.view.regionHead=S.regionHead,this.view.remember(S.body,V(this.options.getHead(),S.head)),this.currentURL=S.url,Yn(S.status),!this.options.useHistory){this.accessibility.commit(S.url,()=>this.mounted&&T===this.revision),this.options.onLoading(!1);return}if(b)await this.scroll.restoreScroll(R,T,S.url);else if(this.history.replaceAddressIfNeeded(S.url),E&&!S.url.hash)await this.scroll.restoreScroll(E,T,S.url);else await this.scroll.scrollToRoute(S.url,T);if(this.mounted&&T===this.revision)this.accessibility.commit(S.url,()=>this.mounted&&T===this.revision),this.options.onLoading(!1)}async watchURL(){this.stopURL=await be(async(t)=>{if(!this.mounted||this.ignoreURLHook)return;await this.transition(t)},[this.options.url],{id:`${this.options.id}_url`})}followRedirect(t){if(++this.redirects>10)throw Error("Yvee redirect limit exceeded.");this.navigate(t.to,void 0,t.replace??!0)}cancelNavigation(t,b){let R=this.pendingNavigation;if(this.pendingNavigation=void 0,!b&&R?.key===N(t)&&!R.replace&&this.options.useHistory&&location.protocol!=="file:"){this.updateURL(this.currentURL),history.back();return}this.restoreURL(this.currentURL)}clearPendingNavigation(t){if(this.pendingNavigation?.key===N(t))this.pendingNavigation=void 0}restoreURL(t){this.history.restoreAddress(t),this.updateURL(t),this.history.trackDisplayedEntry()}updateURL(t){this.ignoreURLHook=!0;try{this.options.url.value=t}finally{this.ignoreURLHook=!1}}initialURL(){return z(location.protocol==="file:"?"/":location.href)}dispose(){this.unmount()}discardPendingPages(){let t=[...this.pendingPages];this.pendingPages.clear();let b=[];for(let R of t)try{R()}catch(T){b.push(T)}if(b.length)throw AggregateError(b,"Pending page cleanup failed.")}unmount(){this.mountEpoch++,this.mounted=!1,this.booting=!1,this.bootQueue=void 0,this.revision++;let t=this.stopURL;this.stopURL=void 0;let b=this.stopPage;this.stopPage=void 0;let R=this.activeLoad;this.activeLoad=void 0,this.activePage=void 0,this.regionEpoch++;let T=[],x=(S)=>{try{S()}catch(k){T.push(k)}};if(x(()=>R?.abort()),x(()=>this.abortRegionGuards()),x(()=>t?.()),x(()=>this.view.releaseActive()),x(()=>this.view.discardPending()),x(()=>this.discardPendingPages()),x(()=>this.navigation.stop()),x(()=>{if(this.element?.id)X.resetScope(this.element.id)}),x(()=>b?.()),x(()=>this.accessibility.dispose()),this.element?.dataset.app===this.options.id)delete this.element.dataset.app;if(x(()=>this.options.onUnmount()),this.options.onLoading(!1),this.currentURL=void 0,this.view.reset(),this.pendingNavigation=void 0,this.history.reset(),T.length)throw AggregateError(T,"App disposal failed.")}}function Yn(t,b=document.body){if(t>=400)b.dataset.error=String(t);else delete b.dataset.error}function Ir(t){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(t);return}setTimeout(()=>t(0),0)}var Fn=new WeakMap;function Ur(t){if(!Number.isInteger(t)||t<400||t>599)throw RangeError("Expected an HTTP error status between 400 and 599.");return(b)=>(Fn.set(b,t),b)}var Bn=(t)=>Fn.get(t),It=new WeakMap,Vn=(t,b)=>(R)=>{let T=It.get(R)??[];return It.set(R,[...T,{path:t,transport:b}]),R},Kn=(t="/")=>Vn(t,"page"),$r=Kn,Nr=(t="/")=>Vn(t,"socket"),_n=(t)=>It.get(t)??[];function jr(t,b){let R=ie(b),T=ie(t),k=ie(`${R==="/"?"":R}/${T==="/"?"":T}`),E=[];if(k==="/")return{path:k,expression:/^\/?$/,names:E};let P=k.slice(1).split("/").map((L)=>{if(!L.startsWith(":"))return L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let A=L.slice(1);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(A)||E.includes(A))throw TypeError(`Invalid route parameter: ${L}`);return E.push(A),"([^/]+)"}).join("/");return{path:k,expression:new RegExp(`^/${P}/?$`),names:E}}class Xe{base;entries=[];constructor(t="/"){this.base=t}add(t,b,R="page"){let T=jr(t,this.base);if(this.entries.some((k)=>k.path===T.path&&k.transport===R))throw Error(`Route already registered: ${T.path}`);let S={...T,controller:b,transport:R};return this.entries.push(S),S}find(t,b="page"){let R=ie(t);for(let T of this.entries){if(T.transport!==b)continue;let x=T.expression.exec(R);if(!x)continue;let S={};return T.names.forEach((k,E)=>{S[k]=decodeURIComponent(x[E+1]??"")}),{entry:T,params:S}}return}all(t){return this.entries.filter((b)=>!t||b.transport===t)}}var Gr=(t,b)=>{let R=0;return t.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g,(T,x)=>{let S=Array.isArray(b)?b[R++]:b[x];return encodeURIComponent(String(S??""))})};function Ut(t,b=new WeakMap){if(t===null||typeof t!=="object"){if(typeof t==="function"||typeof t==="symbol")throw TypeError("SSR data must be plain data; use dataFactory for request-owned services.");return t}let R=b.get(t);if(R)return R;let T=Object.getPrototypeOf(t);if(!Array.isArray(t)&&T!==Object.prototype&&T!==null)throw TypeError("SSR data must be plain data; use dataFactory for request-owned services.");let x=Array.isArray(t)?[]:Object.create(T);b.set(t,x);for(let S of Reflect.ownKeys(t)){if(Array.isArray(t)&&S==="length")continue;let k=Object.getOwnPropertyDescriptor(t,S);if(!("value"in k))throw TypeError("SSR data must not contain accessors.");Object.defineProperty(x,S,{value:Ut(k.value,b),enumerable:k.enumerable??!1,configurable:!0,writable:!0})}if(Array.isArray(t))x.length=t.length;return Object.freeze(x)}function Jn(t,b={}){let R=b.id??t.id,T=async(x)=>{let{url:S,data:k,error:E,nonce:C}=x,P=Kr(S),L=x.signal??new AbortController().signal,A=[],M,H=!1,O;try{L.throwIfAborted();let D=k??b.data??t.data,j=b.dataFactory?await b.dataFactory({...x,signal:L,onDispose:(W)=>{A.push(W)}}):Ut(D);L.throwIfAborted();let U=await zn(t,P,j,E,L);if(U.kind==="stop"){if(O="guard-stop",U=await zn({...t,guards:[]},P,j,403,L),U.kind==="stop"){let W=new fe;W.status=403,U={kind:"ready",status:403,body:[W.body()],head:{},url:P}}}if(U.dispose)A.push(U.dispose);let G=V(t.defaults,U.head),q=await qr(U.body,t.layout,b.class,R,C),I=U.status,B=await Yr(q,G,R,I,C,j,b.dataFactory?D:void 0);return L.throwIfAborted(),{html:B,status:I,...O===void 0?{}:{reason:O}}}catch(D){throw M=D,H=!0,D}finally{let D=[];for(let j of A.reverse())try{await j()}catch(U){D.push(U)}if(D.length)throw AggregateError(H?[M,...D]:D,"SSR request cleanup failed.")}};return Object.assign(async(x)=>(await T(x)).html,{withStatus:T})}async function zn(t,b,R,T,x){let S=b;for(let k=0;k<=10;k++){let E=await Ze({app:t.app,routes:t.routes,globalGuards:t.guards,errors:t.errors,...T===void 0?{}:{error:T},url:S,data:R,signal:x});if(E.kind!=="redirect")return E;if(k===10)throw Error("Yvee redirect limit exceeded during server rendering.");T=void 0,S=z(E.to)}throw Error("Yvee redirect limit exceeded during server rendering.")}async function qr(t,b,R,T,x){let S=Q(t),k=b?await b(S):S,E=k instanceof n?k:d("main",{class:R,children:k});return(await le(E,new Y(T,0,x))).ctx}async function Yr(t,b,R,T,x,S,k){return["<!doctype html>",'<html lang="en">',`<head>${await Br(b,"root",x)}${Fr(S,x,k)}</head>`,`<body id="${Zn(R)}"${T>=400?` data-error="${Number(T)}"`:""}>${t}</body>`,"</html>"].join("")}function Fr(t,b,R){let T={id:"ssr",...b===void 0?{}:{nonce:b}};try{return Ue(t,T)}catch(x){if(R===void 0||!(x instanceof TypeError))throw x;try{return Ue(R,T)}catch(S){if(!(S instanceof TypeError))throw S;return""}}}async function Br(t,b,R){t=Pe(t);let T=[],x=t.base?.at(-1);if(x)T.push(`<base${se(x,b)}>`);if(t.description)T.push(`<meta${se({name:"description",content:t.description},b)}>`);for(let S of t.meta??[])T.push(`<meta${se(S,b)}>`);for(let S of t.script??[]){let{body:k,...E}=S;T.push(`<script${se({...E,...R===void 0?{}:{nonce:R}},b)}>${ae("script",k)}</script>`)}for(let S of Wn(t.js))T.push(`<script${se({src:S,...R===void 0?{}:{nonce:R}},b)}></script>`);if(t.title)T.push(`<title${se({},b)}>${Vr(t.title)}</title>`);if(t.style)T.push(`<style${se({...R===void 0?{}:{nonce:R}},b)}>${ae("style",t.style)}</style>`);for(let S of t.link??[])T.push(`<link${se(S,b)}>`);for(let S of Wn(t.css))T.push(`<link${se({rel:"stylesheet",href:S},b)}>`);if(t.elements?.length)T.push((await Ce(t.elements,b,`${b}:h`,R)).ctx);return T.join("")}function se(t,b){let R={...t,"data-yv":b};return Object.entries(R).map(([T,x])=>{if(J(T,x),x===!1)return"";if(x===!0)return` ${T}`;return` ${T}="${Zn(x)}"`}).join("")}var Zn=_,Vr=_;function Wn(t){if(t===void 0)return[];return Array.isArray(t)?t:[t]}function Kr(t){if(typeof t==="string"||t instanceof URL)return z(t);return z(`${t.path}${t.search}${t.hash}`)}class Qn{connection;path="/";params={};state=Q("connecting");queue=[];disposed=!1;open(t){}message(t){}close(t){}error(t){}messageError(t,b,R){console.error(`Yvee socket ${b} failed`,t)}send(t){let b=this.connection;if(b&&b.readyState===WebSocket.OPEN){this.transmit(b,t);return}if(!this.disposed)this.queue.push(t)}sendJson(t){if(this.connection?.readyState===WebSocket.OPEN)this.connection.send(JSON.stringify(t))}attach(t){this.connection=t,this.state.value="connecting"}opened(){this.state.value="open"}flush(){let t=this.connection;if(!t||t.readyState!==WebSocket.OPEN)return;while(this.queue.length)this.transmit(t,this.queue.shift())}closed(){this.state.value="closed"}dispose(){this.disposed=!0,this.queue.length=0,this.state.value="closed"}transmit(t,b){try{t.send(JSON.stringify(b))}catch(R){console.error("Yvee socket send failed",R)}}onMessage(t,b={}){let R=this.message.bind(this);return this.message=async(T)=>{let x=(k,E)=>{if(b.onError)b.onError(k,E,T);else this.messageError(k,E,T)};try{await R(T)}catch(k){x(k,"handler")}let S;try{if(typeof T.data!=="string")throw TypeError("Expected a JSON text frame.");S=JSON.parse(T.data)}catch(k){x(k,"parse");return}try{if(b.validate&&!b.validate(S))throw TypeError("Socket payload validation failed.")}catch(k){x(k,"validation");return}try{await t(S,T)}catch(k){x(k,"handler")}},this}}class et{app;connections=new Map;constructor(t){this.app=t}load(t,b={}){if(b.signal?.throwIfAborted(),typeof WebSocket>"u")throw Error("WebSocket is not available in this environment.");let R=typeof location>"u"?"http://localhost":location.href,T=new URL(t,R);if(T.protocol==="https:")T.protocol="wss:";else if(T.protocol==="http:")T.protocol="ws:";else if(!["ws:","wss:"].includes(T.protocol))throw TypeError("Unsupported WebSocket protocol.");let x=this.app.routes.find(T.pathname,"socket");if(!x)throw Error(`No WebSocket route matches ${t}`);let S=this.connections.get(t);if(S)return S.controller;let k=b.retry?.attempts??0,E=b.retry?.delay??250,C=b.retry?.maxDelay??30000;if(!Number.isSafeInteger(k)||k<0||!Number.isFinite(E)||E<0||!Number.isFinite(C)||C<E)throw RangeError("Invalid WebSocket retry policy.");let L=new x.entry.controller;L.path=t,L.params=x.params;let A=new F;if(this.connections.set(t,{controller:L,scope:A}),A.defer(()=>{if(this.connections.get(t)?.controller===L)this.connections.delete(t)}),A.defer(()=>L.dispose()),b.signal)A.listen(b.signal,"abort",()=>this.unload(t),{once:!0});let M=0,H=(D)=>console.error("Yvee socket callback failed",D),O=()=>{if(A.disposed)return;let D=new WebSocket(T);L.attach(D);let j=new F,U=A.defer(()=>j.dispose());j.defer(()=>{if(D.readyState<WebSocket.CLOSING)D.close()}),j.listen(D,"open",(G)=>{L.opened();try{Promise.resolve(L.open(G)).catch(H)}catch(q){H(q)}L.flush()}),j.listen(D,"message",(G)=>{try{Promise.resolve(L.message(G)).catch(H)}catch(q){H(q)}}),j.listen(D,"error",(G)=>{try{Promise.resolve(L.error(G)).catch(H)}catch(q){H(q)}}),j.listen(D,"close",(G)=>{U(),L.closed();try{Promise.resolve(L.close(G)).catch(H)}catch(q){H(q)}if(A.disposed)return;if(M<k)A.timeout(()=>{try{O()}catch(q){H(q),A.dispose()}},Math.min(C,E*2**M++));else A.dispose()})};try{O()}catch(D){throw A.dispose(),D}return L}unload(t){this.connections.get(t)?.scope.dispose()}closeAll(){let t=[];for(let{scope:b}of[...this.connections.values()])try{b.dispose()}catch(R){t.push(R)}if(t.length)throw AggregateError(t,"Socket cleanup failed.")}}class Xn extends Le{id;routes;url;loading;socket;history;data={};resources=new F;root;pageErrors=new Map;globalGuards=[];client;layout;onError;constructor(t={}){super();let b=ie(t.base??"/"),R=t.history??!0;this.id=t.id??Math.random().toString(36).slice(2,9),this.url=Q(z("/")),this.loading=Q(!1),this.root=Q([],{onError(){}}),this.routes=new Xe(b),this.socket=new et(this),this.head({base:[{href:b==="/"?"/":`${b}/`}],meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],script:[{type:"module",src:zr(t.client??".")}],...t.index?{js:t.index}:{}}),this.client=new Qe({id:this.id,base:b,useHistory:R,url:this.url,root:this.root,app:this,load:(T,x,S)=>this.load(T,x,S),getHead:()=>this.values,getLayout:()=>this.layout,onLoading:(T)=>{this.loading.value=T},onError:(T,x)=>{if(this.onError)this.onError(T,x);else console.error("Yvee page transition failed",T)},onMount:()=>{if(this.resources.disposed)this.resources=new F},onUnmount:()=>{let T=[];try{this.resources.dispose()}catch(x){T.push(x)}try{this.socket.closeAll()}catch(x){T.push(x)}if(T.length)throw AggregateError(T,"Owned app resources failed to close.")}}),this.history={navigate:(T,x)=>this.client.navigate(T,x),replace:(T,x)=>this.client.navigate(T,x,!0),back:()=>this.client.back(),forward:()=>this.client.forward()}}Main(t){return this.layout=t,this}use(...t){return this.globalGuards.push(...t),this}head(t){return super.head(t),this}route(t){return(b)=>(this.routes.add(t,b),b)}error(t,b){return this.pageErrors.set(t,b),this}register(...t){for(let b of t){let R=Bn(b);if(R!==void 0)this.error(R,b);for(let T of _n(b))this.routes.add(T.path,b,T.transport)}return this}listRoutes(t){return this.routes.all(t)}listPaths(){return[...new Set(this.routes.all("page").map(({path:t})=>t.split("/").map((b)=>b.startsWith(":")?b.slice(1):b).join("/")))]}renderHTML(t,b={}){return this.server()({...b,url:t})}render(t={}){let b=typeof document<"u";this.data=t.data??(b?_r():void 0)??{};let R=b?xn():void 0,T=this.server({...t.id?{id:t.id}:{},...t.class?{class:t.class}:{},data:this.data}),x=b?this.client.mount({...t.id?{id:t.id}:{},...t.class?{className:t.class}:{},...t.hydrate===void 0?{}:{hydrate:t.hydrate},...t.nonce===void 0?{}:{nonce:t.nonce}}).then(()=>{document.body.dataset.yveeReady="true"}):Promise.resolve(()=>{});if(R)x.then(()=>Tt(R),()=>Tt(R));x.catch(()=>{});let S=Object.assign((k)=>T(k),{withStatus:T.withStatus});return Object.assign(S,{then:x.then.bind(x),catch:x.catch.bind(x),finally:x.finally.bind(x),app:this})}dispose(){this.client.dispose()}server(t={}){return Jn({id:this.id,defaults:this.values,routes:this.routes,errors:this.pageErrors,guards:this.globalGuards,data:this.data,...this.layout?{layout:this.layout}:{},app:this},t)}load(t,b,R){return Ze({app:this,routes:this.routes,globalGuards:this.globalGuards,errors:this.pageErrors,url:t,data:this.data,...R===void 0?{}:{error:R},signal:b})}}function _r(){let t=document.getElementById("ssr");if(!t?.textContent)return;try{let b=JSON.parse(t.textContent);if(typeof b==="object"&&b!==null&&!Array.isArray(b))return b;throw TypeError("Yvee SSR payload must be a JSON object.")}catch(b){console.error("Could not read Yvee SSR payload",b);return}}function zr(t){let b=t.startsWith("/")||t.startsWith(".")?t:`/${t}`;return/\.js(?:[?#]|$)/i.test(b)?b:`${b.replace(/\/+$/,"")}/index.js`}var jt=Symbol("Yvee region level metadata");function Wr(t){return t}function Jr(t){let b={},R={};for(let[T,x]of Object.entries(t))if(Xr(x))R[T]=eo(b,T,x);else $t(b,T,x);return Object.defineProperty(b,jt,{value:R}),b}function Zr(t){let b=t[jt];return b?Object.keys(b):[]}function Qr(t,b){return t[jt]?.[b]?.defaultView}function Xr(t){return typeof t!=="function"}function eo(t,b,R){let T=Object.keys(R.views);if(T.length===0)throw Error(`Yvee region level "${b}" has no views.`);let x=R.default??T[0];if(!Object.hasOwn(R.views,x))throw Error(`Yvee region level "${b}" default view "${x}" is not declared.`);$t(t,b,er(b,R.chrome,R.views[x]));for(let S of T)$t(t,`${b}/${S}`,er(b,R.chrome,R.views[S]));return{defaultView:x,views:T}}function $t(t,b,R){if(Object.hasOwn(t,b))throw Error(`Duplicate Yvee region id "${b}" in region tree.`);t[b]=R}var to={get:()=>{return},set:()=>{}},Nt=new WeakMap;function no(t,b,R){let T=Nt.get(t);if(!T)T=new Map,Nt.set(t,T);T.set(b,R)}function ro(t,b){return Nt.get(t)?.get(b)}function er(t,b,R){return async()=>{let[T,x]=await Promise.all([b(),R()]),S={default:async({page:E,cache:C})=>{let P=await x.default({page:E,cache:C});return no(E,t,P),T.default({page:E,cache:to,outlet:ro(E,t)})}},k=oo(T,x);if(k)S.head=k;return S}}function oo(t,b){if(t.head===void 0&&b.head===void 0)return;return async({page:R})=>{let[T,x]=await Promise.all([tr(R,t),tr(R,b)]);if(!T)return x;if(!x)return T;return V(T,x)}}async function tr(t,b){let R=b.head;if(R===void 0)return;let T=typeof R==="function"?await R({page:t}):await R;if(T===void 0||T===null)return;return oe(T)}class Gt{store;base;schema;key;constructor(t,b,R){this.store=t;this.base=b;this.schema=R;if(!Number.isSafeInteger(R.version)||R.version<1)throw TypeError("Storage versions must be positive integers.");this.key=`${b}:v${R.version}`}get(){if(this.store.has(this.key))return this.check(this.store.get(this.key).value);for(let t=this.schema.version-1;t>=1;t--){let b=`${this.base}:v${t}`;if(!this.store.has(b))continue;let R=this.store.get(b).value;for(let x=t+1;x<=this.schema.version;x++){let S=this.schema.migrations?.[x];if(!S)throw Error(`Missing storage migration to version ${x}.`);R=S(R)}let T=this.check(R);return this.store.set(this.key,T),T}return this.check(this.schema.fallback())}set(t){return this.store.set(this.key,this.check(t)),this}remove(){return this.store.remove(this.key),this}watch(t,b){return this.store.watch(this.key,t,b)}check(t){if(!this.schema.validate(t))throw TypeError(`Invalid stored value for '${this.key}'.`);return t}}class De{storeName;key;current;constructor(t,b,R){this.storeName=t;this.key=b;this.current=R}get value(){return this.current}set value(t){this.current=t}set(t){return this.current=t,this}save(){if(typeof window<"u")this.storage().setItem(this.key,JSON.stringify(this.current));return this}remove(){if(typeof window<"u")this.storage().removeItem(this.key);return this}as={str:()=>String(this.current??""),int:()=>Number.parseInt(String(this.current),10),float:()=>Number.parseFloat(String(this.current)),bool:()=>this.current===!0||this.current==="true"||this.current===1,json:()=>this.current};storage(){return this.storeName==="localStorage"?window.localStorage:window.sessionStorage}}class tt{storeName;constructor(t){this.storeName=t}versioned(t,b){return new Gt(this,t,b)}watch(t,b,{signal:R,scope:T}={}){if(typeof window>"u"||R?.aborted||T?.disposed)return()=>{};let x=window,S=this.storage();S.getItem(t);let k=(C)=>{if(C.storageArea===S&&(C.key===t||C.key===null))b({key:C.key,oldValue:C.oldValue,newValue:C.newValue})},E=()=>{x.removeEventListener("storage",k),R?.removeEventListener("abort",E)};return x.addEventListener("storage",k),R?.addEventListener("abort",E,{once:!0}),T?T.defer(E):E}get(t,b){let R=typeof b==="function"?b:void 0,T;if(typeof window<"u")try{let x=this.storage().getItem(t);if(x!==null){let S=JSON.parse(x);if(!R)T=S;else if(R(S))T=S}}catch{T=void 0}if(R)return new De(this.storeName,t,T);return new De(this.storeName,t,T===void 0?b:T)}set(t,b){return new De(this.storeName,t,b).save()}remove(t){if(typeof window<"u")this.storage().removeItem(t);return this}has(t){return typeof window<"u"&&this.storage().getItem(t)!==null}storage(){return this.storeName==="localStorage"?window.localStorage:window.sessionStorage}}var io=new tt("localStorage"),so=new tt("sessionStorage");function qt(t){if(typeof document>"u"||typeof document.cookie!=="string")return;let b=`${t}=`;for(let R of document.cookie.split(";")){let T=R.trim();if(!T.startsWith(b))continue;let x=T.slice(b.length);try{return decodeURIComponent(x)}catch{return x}}return}function Ft(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function ao(t){if(!Ft(t))return;if(typeof t.error==="string"&&t.error)return t.error;if(typeof t.message==="string"&&t.message)return t.message;return}class ye extends Error{response;body;constructor(t,b,R){super(b??ao(R)??`HTTP ${t.status} ${t.statusText}`);this.response=t;if(this.name="HTTPError",R!==void 0)this.body=R}static async fromResponse(t,b){let R;try{R=await t.clone().json()}catch{R=void 0}return new ye(t,b,R)}}var Yt=new Map;function co(t){if(!t)return;let b=t===!0?{}:t;return{header:b.header??"x-csrf-token",field:b.field??"csrfToken",endpoint:b.endpoint??"/csrf"}}function uo(){if(typeof document>"u"||typeof document.querySelector!=="function")return;return document.querySelector('meta[name="csrf-token"]')?.getAttribute("content")||void 0}async function lo(t,b,R){let T=Yt.get(t);if(T)return T;let x={method:"GET",headers:{accept:"application/json"}};if(R)x.signal=R;let S=(async()=>{let k=await b(t,x);if(!k.ok)throw await ye.fromResponse(k);let E;try{E=await k.json()}catch{throw TypeError(`CSRF token endpoint ${t} did not return JSON.`)}let C=Ft(E)?typeof E.csrfToken==="string"?E.csrfToken:typeof E.token==="string"?E.token:void 0:void 0;if(!C)throw TypeError(`CSRF token endpoint ${t} returned no token.`);return C})().catch((k)=>{throw Yt.delete(t),k});return Yt.set(t,S),S}async function fo(t,b,R){let T=qt("csrf_token")??uo();if(T)return T;if(t.endpoint===!1)throw TypeError("No CSRF token is available; enable minting or provide a csrf_token cookie or meta tag.");return lo(t.endpoint,b,R)}async function po(t,b,R,T){let x=await fo(b,R,T),S=new Headers(t.headers);S.set(b.header,x);let k=t.body,E=S.get("content-type");if(typeof k==="string"&&(E===null||E.includes("json"))){let C;try{C=JSON.parse(k)}catch{C=void 0}if(Ft(C)&&!Object.hasOwn(C,b.field)){if(C[b.field]=x,k=JSON.stringify(C),E===null)S.set("content-type","application/json")}}return{...t,headers:S,...k===void 0?{}:{body:k}}}function nr(t,b){return b?.throwIfAborted(),new Promise((R,T)=>{let x=()=>{clearTimeout(S),T(b?.reason)},S=setTimeout(()=>{b?.removeEventListener("abort",x),R()},t);b?.addEventListener("abort",x,{once:!0})})}async function rr(t,b){let{validate:R,retry:T,fetch:x=globalThis.fetch,csrf:S,...k}=b,E=k,C=E.signal===void 0?t instanceof Request?t.signal:void 0:E.signal,P=(E.method??(t instanceof Request?t.method:"GET")).toUpperCase(),L=T?.attempts??0,A=T?.delayMs??100;if(!Number.isInteger(L)||L<0||L>5||!Number.isFinite(A)||A<0)throw TypeError("Retries require 0\u20135 additional attempts and a finite nonnegative delay.");if(L&&(!["GET","HEAD","OPTIONS"].includes(P)||E.body!=null||t instanceof Request&&t.body!==null))throw TypeError("Only bodyless GET, HEAD and OPTIONS requests may retry.");let M=co(S);if(M)E=await po(E,M,x,C);for(let H=0;;H++){C?.throwIfAborted();let O;try{O=await x(t,E)}catch(j){if(C?.throwIfAborted(),H>=L||!(j instanceof TypeError))throw j;await nr(A,C);continue}if(C?.throwIfAborted(),!O.ok){let j=await ye.fromResponse(O);if(H>=L||![408,429,500,502,503,504].includes(O.status))throw j;await O.body?.cancel(),await nr(A,C);continue}let D=await O.json();if(C?.throwIfAborted(),!R(D))throw TypeError("Response JSON failed validation.");return D}}async function ho(t,b={}){let{data:R,body:T,validate:x,csrf:S,fetch:k,method:E="POST",headers:C,...P}=b,L,A=async(M,H)=>{let O=await(k??globalThis.fetch)(M,H);return L=O,O};try{let M=new Headers(C),H=T??null;if(H===null&&R!==void 0){if(H=JSON.stringify(R),!M.has("content-type"))M.set("content-type","application/json")}let O={...P,method:E,headers:M,body:H,fetch:A,validate:x??((j)=>!0)};if(S!==void 0)O.csrf=S;let D=await rr(t,O);return{ok:!0,status:L?.status??0,data:D}}catch(M){if(M instanceof ye)return{ok:!1,status:M.response.status,error:M.message};let H=L?.status??0;if(L?.ok&&(H===204||H===205))return{ok:!0,status:H,data:void 0};return{ok:!1,status:H,error:M instanceof Error?M.message:String(M)}}}function go(t,b={},R={}){if(R.signal?.throwIfAborted(),typeof EventSource>"u")throw Error("EventSource is not available in this environment.");let T=new EventSource(t,{withCredentials:R.withCredentials??!1}),x=new F,S=T.close.bind(T);x.defer(S),T.close=()=>x.dispose();for(let[k,E]of Object.entries(b))if(E)x.listen(T,k,E);if(R.signal)x.listen(R.signal,"abort",()=>T.close(),{once:!0});return T}export{Oo as $,mt as ATTR,tt as BrowserStore,re as Column,n as DOM,je as DbRepository,Pi as Derived,F as DisposalScope,ee as Elem,ln as EventStream,fe as FailurePage,cn as Field,v as Fragment,ye as HTTPError,Le as HeadDefaults,en as IDNotConnected,lt as IndexedDatabase,Me as MissingPage,Ve as Page,ei as QState,Xo as RecState,on as RecStateful,$e as Ref,tn as RefState,Xe as RouteBook,fn as Schema,fr as Scope,Qo as SetState,rn as SetStateful,Qn as SocketController,et as SocketHub,Q as State,ur as StateEffect,be as StateHook,ar as StateLoaded,Z as Stateful,un as Stored,De as StoredValue,Io as Toggled,Gt as VersionedValue,Xn as Yvee,bn as allGuards,Ye as applyHead,Ee as attr_value,sr as batch,yn as buildReturnTo,gn as createGuard,Qr as defaultViewFor,l as dom,Ur as error,hi as eventStream,go as eventStreams,y as frag,te as getElementById,dr as hook,Gr as interpolate,wt as isClient,d as jsx,w as jsxDEV,p as jsxs,cr as loaded,io as local,ie as normalizePath,Kn as page,Tn as paramsGuard,qt as readCookie,vn as readReturnTo,Wr as regionLevel,Zr as regionLevelIds,Jr as regionTree,Qt as renderContent,le as renderDom,Ue as renderJSONScript,ho as requestForm,rr as requestJSON,Rt as requireGuard,$r as route,Jt as serializePayload,so as session,Zt as setContentRenderer,lr as shallowEqual,Nr as socketRoute,pr as t,z as toURL,mn as use,Yo as useRef,Rn as whenGuard};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yvee",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "TypeScript UI framework with reactive state, a TSX renderer, client-side routing with guards, server-side rendering, and browser storage and network helpers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./jsx-runtime": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/jsx-runtime.js"
|
|
29
|
+
},
|
|
30
|
+
"./jsx-dev-runtime": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/jsx-runtime.js"
|
|
25
33
|
}
|
|
26
34
|
},
|
|
27
35
|
"sideEffects": false,
|