@async/framework 0.11.9 → 0.11.10
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/CHANGELOG.md +13 -0
- package/browser.js +31 -2
- package/browser.min.js +1 -1
- package/browser.ts +31 -2
- package/browser.umd.js +31 -2
- package/browser.umd.min.js +1 -1
- package/framework.ts +31 -2
- package/package.json +1 -1
- package/server.js +31 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.10 - 2026-06-18
|
|
4
|
+
|
|
5
|
+
- Routed automatic microtask scheduler flush failures through an explicit error
|
|
6
|
+
channel so failed jobs no longer surface as unhandled promise rejections.
|
|
7
|
+
- Reported automatic flush failures to configured `onError` handlers or
|
|
8
|
+
`globalThis.reportError`, with scheduler metadata for phase, scope, and key,
|
|
9
|
+
while preserving manual `scheduler.flush()` rejection behavior.
|
|
10
|
+
- Added regression coverage for automatic `onError` reporting, `reportError`
|
|
11
|
+
delivery without unhandled rejections, and manual flush rejection metadata.
|
|
12
|
+
- Bundle size from bundled TypeScript source: `browser.ts` 184,238 B raw /
|
|
13
|
+
34,642 B gzip -> `browser.min.js` 78,267 B raw / 23,232 B gzip
|
|
14
|
+
(-105,971 B raw, -11,410 B gzip).
|
|
15
|
+
|
|
3
16
|
## 0.11.9 - 2026-06-18
|
|
4
17
|
|
|
5
18
|
- Normalized scheduler batch thenables with `Promise.resolve(value)` before
|
package/browser.js
CHANGED
|
@@ -3239,7 +3239,7 @@ const __schedulerModule = (() => {
|
|
|
3239
3239
|
scheduled = true;
|
|
3240
3240
|
scheduleMicrotask(() => {
|
|
3241
3241
|
if (!destroyed) {
|
|
3242
|
-
void api.flush();
|
|
3242
|
+
void api.flush().catch(reportAutomaticFlushError);
|
|
3243
3243
|
}
|
|
3244
3244
|
});
|
|
3245
3245
|
}
|
|
@@ -3275,12 +3275,22 @@ const __schedulerModule = (() => {
|
|
|
3275
3275
|
if (onError) {
|
|
3276
3276
|
onError(error, job);
|
|
3277
3277
|
} else {
|
|
3278
|
-
throw error;
|
|
3278
|
+
throw annotateSchedulerError(error, job);
|
|
3279
3279
|
}
|
|
3280
3280
|
}
|
|
3281
3281
|
}
|
|
3282
3282
|
}
|
|
3283
3283
|
|
|
3284
|
+
function reportAutomaticFlushError(error) {
|
|
3285
|
+
if (typeof globalThis.reportError === "function") {
|
|
3286
|
+
globalThis.reportError(error);
|
|
3287
|
+
return;
|
|
3288
|
+
}
|
|
3289
|
+
setTimeout(() => {
|
|
3290
|
+
throw error;
|
|
3291
|
+
}, 0);
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3284
3294
|
function hasJobs() {
|
|
3285
3295
|
for (const queue of queues.values()) {
|
|
3286
3296
|
if (queue.some((job) => !job.canceled)) {
|
|
@@ -3339,6 +3349,25 @@ const __schedulerModule = (() => {
|
|
|
3339
3349
|
return (typeof scope === "object" && scope !== null) || typeof scope === "function";
|
|
3340
3350
|
}
|
|
3341
3351
|
|
|
3352
|
+
function annotateSchedulerError(error, job) {
|
|
3353
|
+
if (!error || (typeof error !== "object" && typeof error !== "function")) {
|
|
3354
|
+
return error;
|
|
3355
|
+
}
|
|
3356
|
+
try {
|
|
3357
|
+
Object.defineProperty(error, "scheduler", {
|
|
3358
|
+
configurable: true,
|
|
3359
|
+
value: {
|
|
3360
|
+
phase: job.phase,
|
|
3361
|
+
scope: job.scope,
|
|
3362
|
+
key: job.key
|
|
3363
|
+
}
|
|
3364
|
+
});
|
|
3365
|
+
} catch {
|
|
3366
|
+
// Non-extensible thrown values still need to propagate through the chosen error channel.
|
|
3367
|
+
}
|
|
3368
|
+
return error;
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3342
3371
|
function scheduleMicrotask(fn) {
|
|
3343
3372
|
if (typeof queueMicrotask === "function") {
|
|
3344
3373
|
queueMicrotask(fn);
|
package/browser.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(()=>{const e=Symbol.for("@async/framework.asyncSignal");return{asyncSignal:function t(r,n){if("string"!=typeof r||0===r.length)throw new TypeError("asyncSignal(id, fn) requires a non-empty string id.");if("function"!=typeof n)throw new TypeError("asyncSignal(id, fn) requires a function.");let o,s,a,i=!1,c=null,u="idle",l=0,f=r,p=0,h=!1;const d=new Set,y=new Set,g={[e]:!0,kind:"async-signal",get id(){return f},get value(){return o},get loading(){return i},get error(){return c},get status(){return u},get version(){return l},set:e=>(o=e,i=!1,c=null,u="ready",$(),o),refresh(){if(!s||h)throw new Error(`Async signal "${f}" is not registered.`);v(a,new Error(`Async signal "${f}" refreshed.`));const e=s,t=l+1;l=t,i=!0,c=null,u="loading";const r=((e,t,r)=>{const n=new AbortController,o=n.signal,s=((e,t)=>{const r=e._context?.()??{},n={signals:e,router:r.router,loader:r.loader,cache:r.cache,abort:t,scheduler:r.scheduler};return{signals:e,server:"function"==typeof r.server?._withContext?r.server._withContext(n):r.server,router:r.router,loader:r.loader,cache:r.cache,scheduler:r.scheduler}})(e,o),a={token:++p,version:r,registry:e,id:t,controller:n,abort:o,...s};return((e,t,r)=>{Object.defineProperty(e,"cancel",{configurable:!0,enumerable:!1,value(e){r(e)}})})(o,0,e=>{v(a,e,{settle:!0,notifyChange:!0})}),a})(e,f,t);a=r,$();const d=(e=>({signals:e.signals,id:e.id,get server(){return e.server},get router(){return e.router},get loader(){return e.loader},get cache(){return e.cache},get scheduler(){return e.scheduler},get version(){return e.version},get abort(){return e.abort},refresh:()=>g.refresh()}))(r);let b;try{b=e._collectDependencies(()=>n.call(d))}catch(e){return w(r,e),Promise.reject(e)}return((e,t)=>{if(m(t)){for(const e of y)e();y.clear();for(const r of e){const e=String(r).split(".")[0];e&&e!==f&&y.add(t.registry.subscribe(r,()=>E()))}}})(b.dependencies,r),Promise.resolve(b.value).then(e=>m(r)?(o=e,i=!1,c=null,u="ready",a=void 0,$(),o):o,e=>m(r)?(w(r,e),o):o)},cancel:e=>(b(e,{settle:!0,notifyChange:!0}),o),subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return d.add(e),()=>d.delete(e)},snapshot:()=>({value:o,loading:i,error:c,status:u,version:l}),_cloneSignalDeclaration:()=>t(r,n),_restore:(e={})=>(e=>!(!e||"object"!=typeof e||Array.isArray(e))&&(Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))))(e)?(b(new Error(`Async signal "${f}" restored from snapshot.`)),o=e.value,i=Boolean(e.loading),c=e.error??null,u="string"==typeof e.status?e.status:(({value:e,loading:t,error:r})=>t?"loading":r?"error":void 0===e?"idle":"ready")({value:o,loading:i,error:c}),Number.isFinite(e.version)&&(l=e.version),$(),g):g.set(e),_bindRegistry(e,t){s=e,f=t;const r=()=>{h||s!==e||"idle"!==u||g.refresh()},n=s._context?.().scheduler;n?n.enqueue("async",r,{scope:f,key:`asyncSignal:${f}:initial`}):queueMicrotask(r)},_dispose(){if(!h){h=!0,(()=>{const e=s?._context?.().scheduler;e?.cancelScope?.(f)})(),b(new Error(`Async signal "${f}" disposed.`));for(const e of y)e();y.clear(),d.clear(),s=void 0}}};function w(e,t){m(e)&&(i=!1,c=t,u="error",a=void 0,$())}function m(e){return Boolean(e)&&!h&&a===e&&e.token===p&&e.registry===s&&e.id===f&&!e.abort.aborted}function b(e,t={}){const r=a,n=Boolean(r)||i;r?v(r,e):n&&(p+=1),t.settle&&n&&!h&&S(t.notifyChange)}function v(e,t,r={}){if(!e)return;const n=a===e;n&&(p+=1,a=void 0),e.abort.aborted||e.controller.abort(t),n&&r.settle&&!h&&S(r.notifyChange)}function S(e=!1){const t=void 0===o?"idle":"ready",r=i||null!==c||u!==t;i=!1,c=null,u=t,e&&r&&$()}function E(){if(h||!s)return;v(a,new Error(`Async signal "${f}" dependency changed.`));const e=s?._context?.().scheduler;e?e.enqueue("async",()=>g.refresh(),{scope:f,key:`asyncSignal:${f}:refresh`}):g.refresh()}function $(){for(const e of[...d])e(g)}return g},isAsyncSignal:t=>Boolean(t?.[e])}})(),t=(()=>{const e=new Set(["handler","component","asyncSignal","partial","route"]);function t(t={}){const r=(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("registryAssets.baseUrl must be a non-empty string.");return a(e)||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?s(e):`/${o(e)}`})(t.baseUrl??"_async"),n={component:"component",handler:"handler",asyncSignal:"asyncSignal",partial:"partial",route:"route",...t.paths??{}};for(const[t,r]of Object.entries(n))if(e.has(t)&&("string"!=typeof r||0===r.length))throw new TypeError(`Registry asset path for "${t}" must be a non-empty string.`);return{baseUrl:r,paths:n}}function r(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.url)}function n(t,n,i,c){if(!e.has(t))throw new Error(`Registry type "${t}" does not support lazy descriptors.`);if(!r(i))throw new TypeError(`Registry descriptor for "${t}:${n}" requires a url.`);const{path:u,hash:l}=(e=>{const t=e.indexOf("#");return-1===t?{path:e,hash:""}:{path:e.slice(0,t),hash:e.slice(t+1)}})(i.url),f=((e,t,r)=>{if(a(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=r.paths[e]??e;return((...e)=>{const[t,...r]=e;return[s(t),...r.map(o)].filter(Boolean).join("/")})(r.baseUrl,n,t)})(t,u,c),p=l?[l]:((e,t)=>{const r=[],n=e.split(".").filter(Boolean).at(-1),o=t.split("/").filter(Boolean).at(-1)?.replace(/\.[^.]+$/,"");for(const e of[n,o,"default"])e&&!r.includes(e)&&r.push(e);return r})(n,u);return{moduleUrl:f,exportNames:p,url:l?`${f}#${l}`:f}}function o(e){return String(e).replace(/^\/+|\/+$/g,"")}function s(e){return String(e).replace(/\/+$/g,"")}function a(e){return/^[A-Za-z][A-Za-z\d+.-]*:/.test(e)}function i(e){return!e||"object"!=typeof e||Array.isArray(e)?JSON.stringify(e):JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]]))}return{defineRegistrySnapshot:(e={})=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("defineRegistrySnapshot(snapshot) requires an object.");return e},createLazyRegistry:(e={})=>{const o=t(e.registryAssets??e.assets),s=e.importModule??(e=>import(e)),a=new Map,i=new Map;return{registryAssets:o,resolveUrl:(e,t,r)=>n(e,t,r,o),async resolve(e,t,c){if(!r(c))return c;const u=`${e}:${t}`;if(i.has(u))return i.get(u);const l=n(e,t,c,o);let f,p=a.get(l.moduleUrl);p||(p=Promise.resolve().then(()=>s(l.moduleUrl)),a.set(l.moduleUrl,p));try{f=await p}catch(r){throw a.get(l.moduleUrl)===p&&a.delete(l.moduleUrl),new Error(`Lazy ${e} "${t}" failed to import ${l.moduleUrl}: ${h=r,h instanceof Error?h.message:String(h)}`,{cause:r})}var h;const d=((e,t,r,n)=>{for(const r of t)if(r in e)return e[r];throw new Error(`Lazy ${r} "${n}" did not export ${t.map(e=>`"${e}"`).join(", ")}.`)})(f,l.exportNames,e,t);return i.set(u,d),d},inspect:()=>({registryAssets:o,modules:[...a.keys()],exports:[...i.keys()]})}},normalizeRegistryAssets:t,isLazyDescriptor:r,sameRegistryValue:(e,t)=>e===t||!(!r(e)||!r(t))&&i(e)===i(t),publicRegistryValue:(e,t)=>r(e)?{...e}:{id:t}}})(),r=(()=>{const{publicRegistryValue:e}=t,r=new Set(["signal","handler","server","partial","route","component","asyncSignal"]),n=new Set(["cache.browser","cache.server"]),o=new Set(["cache.browser.entries","cache.server.entries"]),s=new Set([...r,...n,...o]);function a(e){if(!s.has(e))throw new Error(`Unknown Async registry type "${e}".`);return e}function i(e,t){if("string"!=typeof t||0===t.length)throw new TypeError(`${e} id must be a non-empty string.`)}function c(t,r,n,s){return"server"===t&&"browser"===s.target?e(n,r):o.has(t)?n?.value:n}function u(e,t){return"cache.server.entries"===e&&"browser"===t}function l(e){const t={};for(const[r,n]of e)t[r]="function"==typeof n?.snapshot?n.snapshot():n?.value??n;return t}function f(t){const r={};for(const[n,o]of t)r[n]=e(o,n);return r}function p(e){return Object.fromEntries(e)}function h(e){const t={};for(const[r,n]of e)t[r]=n?.value;return t}function d(e){return e&&"object"==typeof e&&Object.hasOwn(e,"value")?e:{value:e}}return{createRegistryStore:function e(t={},n={}){const o=n.backing??{signal:new Map,handler:new Map,server:new Map,partial:new Map,route:new Map,component:new Map,asyncSignal:new Map,cache:{browser:new Map,server:new Map},cacheEntries:{browser:new Map,server:new Map}},s=n.target??"server",y={target:s,register(e,t,r){const n=y._map(e);if(i(e,t),n.has(t))throw new Error(`${e} "${t}" is already registered.`);return n.set(t,r),t},registerMany(e,t={}){for(const[r,n]of Object.entries(t??{}))y.register(e,r,n);return y},set(e,t,r){const n=y._map(e);return i(e,t),n.set(t,r),r},unregister:(e,t)=>y.delete(e,t),delete:(e,t)=>y._map(e).delete(t),keys:e=>u(e,s)?[]:[...y._map(e).keys()],entries(e,t={}){const r=a(e);return u(r,t.target??s)?[]:[...y._map(r)].map(([e,n])=>[e,c(r,e,n,{target:s,...t})])},has:(e,t)=>(i(e,t),!u(e,s)&&y._map(e).has(t)),get(e,t,r={}){i(e,t);const n=a(e);if(u(n,r.target??s))return;const o=y._map(n).get(t);return void 0!==o?c(n,t,o,{target:s,...r}):void 0},snapshot(e={}){const t=e.target??s;return{signal:l(o.signal),handler:f(o.handler),server:f(o.server),partial:f(o.partial),route:p(o.route),component:f(o.component),asyncSignal:f(o.asyncSignal),cache:{browser:p(o.cache.browser),server:p(o.cache.server)},entries:{browser:h(o.cacheEntries.browser),server:"browser"===t?{}:h(o.cacheEntries.server)}}},rawSnapshot:()=>({signal:Object.fromEntries(o.signal),handler:Object.fromEntries(o.handler),server:Object.fromEntries(o.server),partial:Object.fromEntries(o.partial),route:Object.fromEntries(o.route),component:Object.fromEntries(o.component),asyncSignal:Object.fromEntries(o.asyncSignal),cache:{browser:Object.fromEntries(o.cache.browser),server:Object.fromEntries(o.cache.server)}}),view:(t={})=>e(void 0,{backing:o,target:t.target??s}),_map(e){const t=a(e);if(r.has(t))return o[t];if("cache.browser"===t)return o.cache.browser;if("cache.server"===t)return o.cache.server;if("cache.browser.entries"===t)return o.cacheEntries.browser;if("cache.server.entries"===t)return o.cacheEntries.server;throw new Error(`Unknown Async registry type "${e}".`)}};return((e,t={})=>{e.registerMany("signal",t.signal),e.registerMany("handler",t.handler),e.registerMany("server",t.server),e.registerMany("partial",t.partial),e.registerMany("route",t.route),e.registerMany("component",t.component),e.registerMany("asyncSignal",t.asyncSignal),e.registerMany("cache.browser",t.cache?.browser),e.registerMany("cache.server",t.cache?.server);const r=t.entries??{};for(const[t,n]of Object.entries(r.browser??{}))e.set("cache.browser.entries",t,d(n));for(const[t,n]of Object.entries(r.server??{}))e.set("cache.server.entries",t,d(n))})(y,t),y},attachRegistryInspection:(e,t,r)=>(Object.defineProperty(e,"registry",{configurable:!0,enumerable:!0,value:t}),e.keys=()=>t.keys(r),e.entries=()=>t.entries(r),e.inspect=()=>t.entries(r),e)}})(),n=(()=>{const{attachRegistryInspection:e,createRegistryStore:t}=r,n=Symbol.for("@async/framework.cacheDefinition");function o(e={}){return{[n]:!0,kind:"cache-definition",store:e.store??"memory",ttl:e.ttl}}function s(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache id must be a non-empty string.")}function a(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache key must be a non-empty string.")}return{defineCache:o,createCacheRegistry:(r={},{now:i=()=>Date.now(),registry:c,type:u="cache.browser"}={})=>{const l=c??t(),f=l._map(u),p=l._map(`${u}.entries`),h=new Map,d=e({register(e,t=o()){s(e);const r=(e=>e?.[n]?e:o(e))(t);if(f.has(e))throw new Error(`Cache "${e}" is already registered.`);return f.set(e,r),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))d.register(t,r);return d},unregister:e=>(s(e),f.delete(e)),resolve:e=>(s(e),f.get(e)),get:e=>(a(e),y(e).value),set(e,t,r={}){a(e);const n=r.ttl??((e,t)=>{if(void 0!==t)return f.get(t);if(f.has(e))return f.get(e);const r=e.split(":")[0];return f.get(r)})(e,r.cache)?.ttl;return p.set(e,{value:t,expiresAt:void 0===n?void 0:i()+n}),t},async getOrSet(e,t,r={}){if(a(e),"function"!=typeof t)throw new TypeError("cache.getOrSet(key, fn) requires a function.");const n=y(e);if(n.found)return n.value;if(h.has(e))return h.get(e);let o;return o=Promise.resolve().then(t).then(t=>(h.get(e)===o&&d.set(e,t,r),t)).finally(()=>{h.get(e)===o&&h.delete(e)}),h.set(e,o),o},delete:e=>(a(e),h.delete(e),p.delete(e)),clear(e){if(void 0===e)return p.clear(),h.clear(),d;for(const t of[...p.keys()])t.startsWith(e)&&p.delete(t);for(const t of[...h.keys()])t.startsWith(e)&&h.delete(t);return d},snapshot(){const e={};for(const[t]of p){const{found:r,value:n}=y(t);r&&void 0!==n&&(e[t]=n)}return e},restore(e={}){for(const[t,r]of Object.entries(e??{}))d.set(t,r);return d},entryKeys:()=>[...p.keys()],entryEntries:()=>l.entries(`${u}.entries`),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))f.has(t)||d.register(t,r);return d}},l,u);return d.registerMany(r),d;function y(e){const t=p.get(e);return t?void 0!==t.expiresAt&&t.expiresAt<=i()?(p.delete(e),{found:!1,value:void 0}):{found:!0,value:t.value}:{found:!1,value:void 0}}}}})(),o=(()=>{const e=Object.freeze({async:["async:"],class:["class:"],signal:["signal:"],on:["on:"]});function t(t={}){return{async:r(t.async,e.async),class:r(t.class,e.class),signal:r(t.signal,e.signal),on:r(t.on,e.on)}}function r(e,t){return(null==e?t:Array.isArray(e)?e:[e]).map(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Attribute prefixes must be non-empty strings.");return e})}return{defineAttributeConfig:(e={})=>t(e),normalizeAttributeConfig:t,attributeName:(e,r,n)=>t(e)[r][0]+n,readAttribute:(e,r,n,o)=>{for(const s of t(r)[n]){const t=`${s}${o}`;if(e.hasAttribute?.(t))return e.getAttribute(t)}return null},matchAttribute:(e,r,n)=>{for(const o of t(r)[n])if(e.startsWith(o))return e.slice(o.length);return null}}})(),s=(()=>{const{asyncSignal:n,isAsyncSignal:o}=e,{attachRegistryInspection:s,createRegistryStore:a}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t,u=Symbol.for("@async/framework.signal"),l=Symbol.for("@async/framework.computed"),f=Symbol.for("@async/framework.effect"),p=Symbol.for("@async/framework.signalRef"),h=[];function d(e){let t=e;const r=new Set;return{[u]:!0,kind:"signal",get value(){return t},set value(e){this.set(e)},set:e=>(Object.is(t,e)||(t=e,(()=>{for(const e of[...r])e(t)})()),t),update(e){return this.set(e(t))},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return r.add(e),()=>r.delete(e)},snapshot:()=>t,_cloneSignalDeclaration:()=>d(t)}}function y(e){return"function"==typeof e?._cloneSignalDeclaration?e._cloneSignalDeclaration():g(e)?d("function"==typeof e.snapshot?e.snapshot():e.value):d(e)}function g(e){return Boolean(e&&"object"==typeof e&&"function"==typeof e.subscribe)}function w(e,t){let r=e;for(const e of t){if(null==r)return;r=r[e]}return r}function m(e,t,r){const n=b(e,t[0]);let o=n;for(let e=0;e<t.length-1;e+=1){const r=t[e],n=t[e+1];o[r]=b(o[r],n),o=o[r]}return o[t.at(-1)]=r,n}function b(e,t){return Array.isArray(e)?[...e]:e&&"object"==typeof e?{...e}:(r=t,String(Number(r))===String(r)?[]:{});var r}function v(e,t){const r=e.get(t);if(!r)throw new Error(`Signal "${t}" is not registered.`);return r}function S(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal id must be a non-empty string.")}return{createSignal:d,computed:function e(t){if("function"!=typeof t)throw new TypeError("computed(fn) requires a function.");const r=d(void 0);return{[l]:!0,kind:"computed",get value(){return r.value},set:e=>r.set(e),update:e=>r.update(e),subscribe:e=>r.subscribe(e),snapshot:()=>r.snapshot(),_cloneSignalDeclaration:()=>e(t),_bindRegistry:(e,n)=>e.effect(()=>{r.set(t.call({signals:e,id:n,server:e._context?.().server,router:e._context?.().router,loader:e._context?.().loader,cache:e._context?.().cache,scheduler:e._context?.().scheduler}))})}},effect:function e(t){if("function"!=typeof t)throw new TypeError("effect(fn) requires a function.");return{[f]:!0,kind:"effect",fn:t,_cloneSignalDeclaration:()=>e(t),_bindRegistry:e=>e.effect(t)}},createSignalRegistry:function(e={},t={}){const r=t.registry??a(),u=t.type??"signal",l=r._map(u),f=r._map("asyncSignal"),b=t.lazyRegistry??i(t),E=new Map,$={},j=new Set;let A=0,O=0;for(const e of l.keys())if(f.has(e))throw new Error(`Signal "${e}" is already registered.`);const R=s({register(e,t){if(S(e),l.has(e)||f.has(e))throw new Error(`Signal "${e}" is already registered.`);const r=(e=>g(e)?e:d(e))(t);return l.set(e,r),_(e,r),R.ref(e)},registerMany(e){for(const[t,r]of Object.entries(e??{}))R.register(t,r);return R},unregister(e){S(e);const t=l.has(e),r=f.has(e);return!(!t&&!r||(t&&(E.get(e)?.(),E.delete(e),l.get(e)?._dispose?.(),l.delete(e),j.delete(e)),f.delete(e),0))},ensure:(e,t)=>(S(e),T(e),l.has(e)||R.register(e,d(t)),R.ref(e)),has:e=>l.has(e)||f.has(e),get(e){const t=k(e);return(e=>{const t=h.at(-1);t&&t.add(e)})(t.path),((e,t)=>{if(o(e)&&t[0]?.startsWith("$")){const r=((e,t)=>{switch(t){case"$value":return e.value;case"$loading":return e.loading;case"$error":return e.error;case"$status":return e.status;case"$version":return e.version;default:return}})(e,t[0]);return w(r,t.slice(1))}return w(e.value,t)})(v(l,t.id),t.parts)},set(e,t){const r=k(e),n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},update(e,t){if("function"!=typeof t)throw new TypeError("update(path, fn) requires a function.");return R.set(e,t(R.get(e)))},ref:e=>(S(e),T(e),((e,t)=>({[p]:!0,kind:"signal-ref",id:t,get value(){return e.get(t)},set value(r){e.set(t,r)},get loading(){return e._entry(t).loading??!1},get error(){return e._entry(t).error??null},get status(){return e._entry(t).status??"ready"},get version(){return e._entry(t).version??0},get:()=>e.get(t),set:r=>e.set(t,r),update:r=>e.update(t,r),subscribe:r=>e.subscribe(t,r),refresh(){const r=e._entry(t);if("function"!=typeof r.refresh)throw new Error(`Signal "${t}" cannot refresh.`);return r.refresh()},cancel(r){const n=e._entry(t);if("function"!=typeof n.cancel)throw new Error(`Signal "${t}" cannot cancel.`);return n.cancel(r)},toString:()=>t,[Symbol.toPrimitive]:()=>t}))(R,e)),subscribe(e,t,r={}){if("function"!=typeof t)throw new TypeError("subscribe(path, fn) requires a function.");const n=k(e),o=v(l,n.id),s=++A;return o.subscribe(()=>{((e,t={})=>{const r=t.scheduler;if(!r||"sync"===t.phase)return e();r.enqueue(t.phase??"effect",e,{scope:t.scope,key:t.key})})(()=>t(R.get(n.path),{id:n.id,path:n.path,signal:o}),{...r,key:r.key??`signal:${n.path}:${s}`})})},snapshot(){const e={};for(const[t,r]of l)e[t]="function"==typeof r.snapshot?r.snapshot():r.value;return e},asyncSignal:(e,t)=>(R.register(e,n(e,t)),R.ref(e)),effect(e,t={}){let r,n=[],o=!1;const s=t.scheduler,a=++O,i=()=>{if(o)return;"function"==typeof r&&r();for(const e of n)e();n=[];const t=R._collectDependencies(()=>e.call({signals:R,server:$.server,router:$.router,loader:$.loader,cache:$.cache,scheduler:$.scheduler}));r=t.value,n=t.dependencies.map(e=>R.subscribe(e,c))},c=()=>{s?s.enqueue(t.phase??"effect",i,{scope:t.scope,key:t.key??`effect:${a}`}):i()};return i(),()=>{o=!0,"function"==typeof r&&r();for(const e of n)e()}},destroy(){for(const e of E.values())e();E.clear();for(const e of l.values())e._dispose?.();l.clear()},_collectDependencies(e){const t=new Set;h.push(t);try{return{value:e(),dependencies:[...t]}}finally{h.pop()}},_entry:e=>(T(e),v(l,e)),_setPath(e,t){const r=(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const[t,...r]=e.split(".");return{id:t,parts:r,path:e}})(e);l.has(r.id)||(f.has(r.id)?T(r.id):R.register(r.id,d(0===r.parts.length?t:{})));const n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},_setContext:(e={})=>(Object.assign($,e),R),_context:()=>$,_adoptMany(e={}){for(const[t,r]of Object.entries(e??{})){if(!l.has(t)){if(f.has(t))throw new Error(`Signal "${t}" is already registered.`);const e=y(r);l.set(t,e),_(t,e);continue}_(t,l.get(t))}return R}},r,u);for(const[e,t]of l)_(e,t);return R.registerMany(e),R;function _(e,t){if(j.has(e)||"function"!=typeof t?._bindRegistry)return;j.add(e);const r=t._bindRegistry(R,e);"function"==typeof r&&E.set(e,r)}function k(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const t=e.split(".");for(let r=t.length;r>0;r-=1){const n=t.slice(0,r).join(".");if(l.has(n)||f.has(n))return T(n),{id:n,parts:t.slice(r),path:e}}const[r,...n]=t;return{id:r,parts:n,path:e}}function T(e){if(l.has(e)||!f.has(e))return;const t=f.get(e);if(!c(t)&&"function"!=typeof t)throw new TypeError(`Async signal "${e}" must be a function or lazy descriptor.`);const r=n(e,async function(...r){const n=await b.resolve("asyncSignal",e,t);if("function"!=typeof n)throw new TypeError(`Async signal "${e}" did not resolve to a function.`);return n.apply(this,r)});l.set(e,r),_(e,r)}},cloneSignalDeclaration:y,isSignalRef:e=>Boolean(e?.[p]),signal:d}})(),a=(()=>{const{isSignalRef:e}=s,{attributeName:t,matchAttribute:r,normalizeAttributeConfig:n}=o,a=Symbol.for("@async/framework.template"),i=Symbol.for("@async/framework.rawHtml");function c(e){return Boolean(e?.[a])}function u(e,t={}){if(c(e)){const r=p(t);let n="";for(let t=0;t<e.strings.length;t+=1)n+=e.strings[t],t<e.values.length&&(n+=l(e.values[t],{...r,attribute:h(e.strings[t])}));return n}return l(e,p(t))}function l(n,o=p()){return n?.[i]?n.html:c(n)?u(n,o):o.attribute?((n,o)=>{const s=r(o.attribute.name,o.attributes,"signal"),a=r(o.attribute.name,o.attributes,"class"),i=((t,r)=>e(t)?t.id:"string"==typeof t&&r.signals?.has?.(t)?t:null)(n,o);if("value"===o.attribute.name&&i){const r=((t,r)=>e(t)?t.value:"string"==typeof t&&r.signals?.has?.(t)?r.signals.get(t):t)(n,o),s=t(o.attributes,"signal","value");return`${d(r)}${o.attribute.quote} ${s}=${o.attribute.quote}${d(i)}`}if(null!=s||null!=a){if(i)return d(i);if((e=>Boolean(e&&"object"==typeof e))(n))return d(((e,t)=>"function"!=typeof t.bind?e:t.bind(e))(n,o))}return f(n,o)})(n,o):Array.isArray(n)?n.map(e=>l(e,o)).join(""):e(n)?d(n.value):null==n||!1===n?"":d(n)}function f(t,r){return Array.isArray(t)?t.map(e=>f(e,r)).join(""):e(t)?d(t.value):null==t||!1===t?"":d(t)}function p(e={}){return{...e,attributes:n(e.attributes)}}function h(e){const t=e.match(/(?:^|[\s<])([^\s"'=<>`]+)\s*=\s*(["'])$/);return t?{name:t[1],quote:t[2]}:null}function d(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}return{html:(e,...t)=>({[a]:!0,strings:e,values:t}),isTemplateResult:c,rawHtml:e=>({[i]:!0,html:String(e??"")}),renderTemplate:u,escapeHtml:d}})(),i=(()=>{const{attributeName:e}=o,{escapeHtml:n,rawHtml:s,renderTemplate:i}=a,{attachRegistryInspection:c,createRegistryStore:u}=r,{createLazyRegistry:l,isLazyDescriptor:f}=t,p=Symbol.for("@async/framework.component");let h=0;function d(e){if("function"!=typeof e)throw new TypeError("defineComponent(fn) requires a function.");return Object.defineProperty(e,p,{configurable:!0,value:!0}),e}function y(e){return Boolean(e?.[p])}function g(e,t){if("string"!=typeof t||0===t.length)throw new TypeError("Scoped signal or handler name must be a non-empty string.");return`${e}.${t}`}function w(e){return e.displayName||e.name||"anonymous"}return{defineComponent:d,createComponentRegistry:function(e={},t={}){const r=t.registry??u(),n=t.type??"component",o=r._map(n),s=t.lazyRegistry??l(t),a=new Map,i=c({register(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");if(!y(t)&&"function"!=typeof t&&!f(t))throw new TypeError(`Component "${e}" must be a component function.`);if(o.has(e))throw new Error(`Component "${e}" is already registered.`);return o.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))i.register(t,r);return i},unregister(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");return a.delete(e),o.delete(e)},resolve(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");const t=o.get(e);return f(t)?(a.has(e)||a.set(e,async function(...r){const o=await s.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Component "${e}" did not resolve to a function.`);return o.apply(this,r)}),a.get(e)):t},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)||i.register(t,r);return i}},r,n);return i.registerMany(e),i},isComponent:y,renderComponent:function t(r,o={},a,c="component"){if(!y(r)&&"function"!=typeof r)throw new TypeError("renderComponent(Component) requires a component function.");const u=`${c}.${w(r)}.${++h}`,l=[],f=[],p=[],d=[],m=[],b={attributes:a.attributes,signals:a.signals,bind(e){const t=a.loader?._registerBinding?.(e);if(!t)throw new Error("Inline template bindings require a Loader.");return m.push(t),t}},v=e=>i(e,b),S=(({runtime:r,scope:o,cleanups:a,attachHooks:i,visibleHooks:c,destroyHooks:u,renderScopedTemplate:l})=>{const{signals:f,handlers:p,loader:h,server:d,router:y,cache:w,scheduler:m}=r,b=new WeakMap;let v=0,S=0;const E={scope:o,signals:f,handlers:p,loader:h,server:d,router:y,cache:w,scheduler:m,signal(e,t){if(1===arguments.length){const t=g(o,"signal."+ ++S),r=f.ensure(t,e);return a.push(()=>f.unregister?.(t)),r}const r=g(o,e),n=!f.has(r),s=f.ensure(r,t);return n&&a.push(()=>f.unregister?.(r)),s},computed(e,t){const r=g(o,e),n=!f.has(r),s=f.ensure(r,void 0);n&&a.push(()=>f.unregister?.(r));const i=f.effect(()=>{f.set(r,t.call(E))});return a.push(i),s},asyncSignal(e,t){const r=g(o,e),n=!f.has(r);return f.has(r)||f.asyncSignal(r,t),n&&a.push(()=>f.unregister?.(r)),f.ref(r)},effect(e){const t=f.effect(()=>e.call(E),{scheduler:m,phase:"effect",scope:o});return a.push(t),t},handler(e,t){if("function"==typeof e&&void 0===t){const t=e;if(b.has(t))return b.get(t);const r=$("handler."+ ++v,t);return b.set(t,r),r}if("function"!=typeof t)throw new TypeError("this.handler(name, fn) or this.handler(fn) requires a function.");return $(e,t)},render(e,n={}){const u=t(e,n,r,o);return a.push(u.cleanup),i.push(e=>u.attach(e)),c.push(e=>u.visible(e,h._observeVisible)),s(u.html)},suspense(t,o){const a=t?.id;if(!a)throw new TypeError("this.suspense(signalRef, views) requires a signal ref.");const i=(e=>{const t="function"==typeof e?{ready:e}:e;if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("this.suspense(signalRef, views) requires views to be a function or object.");for(const e of["loading","ready","error"])if(Object.hasOwn(t,e)&&void 0!==t[e]&&"function"!=typeof t[e])throw new TypeError(`this.suspense(signalRef, views) view "${e}" must be a function.`);return t})(o),c=[];for(const o of["loading","ready","error"]){const s=i[o];if(!s)continue;const u=e(r.attributes,"async",o),f=l(s.call(E,t));c.push(`<template ${u}="${n(a)}">${f}</template>`)}return s(c.join(""))},on(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component lifecycle event must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Component lifecycle "${e}" requires a function.`);const r="mount"===e?"attach":e;if("attach"!==r)if("visible"!==r){if("destroy"!==r)throw new Error(`Unsupported component lifecycle event "${e}".`);u.push(()=>t.call(E))}else c.push(e=>t.call(E,e));else i.push(e=>t.call(E,e))},onMount(e){E.on("attach",e)},onVisible(e){E.on("visible",e)}};return E;function $(e,t){const r=g(o,e);return p.register(r,e=>t.call({...E,...e},e)),a.push(()=>p.unregister?.(r)),r}})({runtime:a,scope:u,cleanups:l,attachHooks:f,visibleHooks:p,destroyHooks:d,renderScopedTemplate:v}),E=r.call(S,o);if(E&&"function"==typeof E.then)throw new TypeError(`Component "${w(r)}" returned a Promise. Async components are not supported by synchronous renderComponent(). Use an async partial or handler instead.`);return{html:v(E),attach(e){for(let t=0;t<f.length;t+=1){const r=f[t];a.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&l.push(t)},{scope:u,key:`attach:${t}`})??$(r,e)}},mount(e){this.attach(e)},visible(e,t){if(0===p.length)return;const r=t(e,()=>{for(let t=0;t<p.length;t+=1){const r=p[t];a.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&l.push(t)},{scope:u,key:`visible:${t}`})??j(r,e)}});"function"==typeof r&&l.push(r)},cleanup(){for(;d.length>0;)d.pop()?.();for(a.scheduler?.markScopeDestroyed(u);l.length>0;)l.pop()?.();for(;m.length>0;)a.loader?._releaseBinding?.(m.pop())}};function $(e,t){const r=e(t);"function"==typeof r&&l.push(r)}function j(e,t){const r=e(t);"function"==typeof r&&l.push(r)}},component:d}})(),c=(()=>{const e=Symbol.for("@async/framework.serverResult"),t=Symbol("@async/framework.serverResultInvocation");async function r(e,r={}){if(!d(e))return e;const n=((e={})=>e[t]??{applied:new WeakSet})(r);if(n.applied.has(e))return e;if(n.applied.add(e),e.error)throw(o=e.error)instanceof Error?o:o&&"object"==typeof o&&"string"==typeof o.message?Object.assign(new Error(o.message),o):new Error(String(o));var o;if(e.signals&&r.signals)for(const[t,n]of Object.entries(e.signals))r.signals.set?.(t,n);return e.cache?.browser&&r.cache?.restore&&r.cache.restore(e.cache.browser),e.boundary&&Object.hasOwn(e,"html")&&r.loader?.swap?.(e.boundary,e.html),e.redirect&&await(r.router?.navigate?.(e.redirect)),e}async function n(e,t={}){return await r(e,t),o(e)}function o(e){return d(e)?Object.hasOwn(e,"value")?e.value:void 0:e}function s(e={}){const r=e[t]??{applied:new WeakSet};return{...e,[t]:r}}function a(e={}){const t=f(e);if(t)return p(new t.ownerDocument.defaultView.FormData(t));const r=e.element??e.el??e.event?.target;return r?{value:"value"in r?r.value:void 0,checked:"checked"in r?r.checked:void 0,dataset:r.dataset?{...r.dataset}:{}}:{}}function i(e,t={},r=()=>({})){const n=new Map;return function o(s){const a=s.join(".");if(n.has(a))return n.get(a);const c=new Proxy(async(...t)=>{if(0===s.length)throw new Error("Server namespace is not directly callable.");const n=r()??{};return e(s.join("."),t,n)},{get(n,a){if("then"!==a)return a in n?n[a]:0===s.length&&"_withContext"===a?(n={})=>i(e,t,()=>({...r()??{},...n})):0===s.length&&"run"===a&&"function"==typeof t.run?(e,n=[],o={})=>t.run(e,n,{...r()??{},...o}):0===s.length&&Object.hasOwn(t,a)?t[a]:a===Symbol.toStringTag?"AsyncServerNamespace":"toString"===a?()=>0===s.length?"server":`server.${s.join(".")}`:o([...s,String(a)])}});return n.set(a,c),c}([])}function c(e=[],t){const r={};for(const n of e)r[n]=u(t,n);return r}function u(e,t){if(!e||"function"!=typeof e.get)throw new Error(`Signal "${t}" cannot be read without a signal registry.`);return e.get(t)}function l(e,t,{forServer:r}={}){if(("$event"===e||"$el"===e)&&r)throw new Error(`${e} cannot be passed to a server command.`);if("$event"===e)return t.event;if("$el"===e)return t.element??t.el;if("$value"===e){const e=t.element??t.el??t.event?.target;return e?.value}if("$checked"===e){const e=t.element??t.el??t.event?.target;return e?.checked}if("$form"===e){const e=f(t);return e?p(new e.ownerDocument.defaultView.FormData(e)):{}}if("$dataset"===e){const e=t.element??t.el??t.event?.target;return e?.dataset?{...e.dataset}:{}}throw new Error(`Event local "${e}" is not supported.`)}function f(e){const t=e.event,r=e.element??e.el??t?.target;return"FORM"===r?.tagName?r:"submit"===t?.type&&"FORM"===t.target?.tagName?t.target:"submit"===t?.type&&r?.form?r.form:null}function p(e){const t={};for(const[r,n]of e.entries())Object.hasOwn(t,r)?t[r]=Array.isArray(t[r])?[...t[r],n]:[t[r],n]:t[r]=n;return t}function h(e,t=new Set){if("bigint"==typeof e)throw new Error("Server proxy JSON transport does not support BigInt values.");if(null==e||"object"!=typeof e)return;if(t.has(e))throw new Error("Server proxy JSON transport does not support circular values.");t.add(e);const r=Object.prototype.toString.call(e);if("[object File]"===r||"[object Blob]"===r||"[object FormData]"===r)throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");if(((e,t=Object.prototype.toString.call(e))=>"[object URLSearchParams]"===t||"[object Headers]"===t||"[object Request]"===t||"[object Response]"===t||"[object ReadableStream]"===t||"[object ArrayBuffer]"===t||ArrayBuffer.isView(e))(e,r))throw new Error("Server proxy JSON transport does not support URLSearchParams, Headers, Request, Response, ReadableStream, ArrayBuffer, or typed array values yet.");if(Array.isArray(e)){for(const r of e)h(r,t);t.delete(e)}else{for(const r of Object.values(e))h(r,t);t.delete(e)}}function d(t){return!(!t||"object"!=typeof t||Array.isArray(t)||!0!==t[e]&&1!==t.__async_server_result__)}function y(e){if("string"!=typeof e||0===e.length)throw new TypeError("Server function id must be a non-empty string.")}return{createServerProxy:({endpoint:e="/__async/server",transport:t,signals:r,loader:o,router:u,cache:l,scheduler:f,headers:p={}}={})=>{if("function"!=typeof t)throw new TypeError("createServerProxy(...) requires a transport function.");const d={signals:r,loader:o,router:u,cache:l,scheduler:f};async function g(r,o=[],i={}){y(r);const u=s({...d,...i}),l={args:o,input:i.input??a(u),signals:i.signalValues??c(i.signalPaths,u.signals)};h(l);const f=await t(((e,t)=>`${String(e).replace(/\/$/,"")}/${encodeURIComponent(t)}`)(e,r),{method:"POST",headers:{"content-type":"application/json",...p},body:JSON.stringify(l),signal:i.abort});if(((e,t)=>{if(!t||"object"!=typeof t)throw new Error(`Server function "${e}" transport returned an invalid response: expected a fetch Response-like object.`);if("boolean"!=typeof t.ok)throw new Error(`Server function "${e}" transport returned an invalid response: missing boolean ok.`);if(!t.headers||"function"!=typeof t.headers.get)throw new Error(`Server function "${e}" transport returned an invalid response: missing headers.get(name).`)})(r,f),!f.ok)throw new Error(`Server function "${r}" failed with ${f.status}.`);return n(await(async(e,t)=>{if(204===t.status)return;if((t.headers.get("content-type")??"").includes("application/json")){if("function"!=typeof t.json)throw new Error(`Server function "${e}" transport returned an invalid response: missing json().`);try{return await t.json()}catch(t){throw new Error(`Server function "${e}" returned invalid JSON: ${r=t,r instanceof Error?r.message:String(r)}`,{cause:t})}}var r;if("function"!=typeof t.text)throw new Error(`Server function "${e}" transport returned an invalid response: missing text().`);return t.text()})(r,f),u)}return i(g,{run:g,_setContext(e={}){Object.assign(d,e)}},()=>d)},resolveServerCommandArguments:(e,t={})=>{const r=[],n={},o=[];for(const s of e){if("local"===s.type){r.push(l(s.name,t,{forServer:!0}));continue}const e=u(t.signals,s.path);r.push(e),n[s.path]=e,o.push(s.path)}return{args:r,signalValues:n,signalPaths:o}},applyServerResult:r,consumeServerResult:n,unwrapServerResult:o,createServerResultContext:s,defaultInput:a,createServerNamespace:i,createSignalReader:e=>e&&"function"!=typeof e.get?{get:t=>((e,t)=>String(t).split(".").reduce((e,t)=>e?.[t],e))(e,t),snapshot:()=>({...e})}:e,assertServerId:y}})(),u=(()=>{const{defaultInput:e,resolveServerCommandArguments:n}=c,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:a,isLazyDescriptor:i}=t,u=new Set(["prevent","preventDefault","stopPropagation","stopImmediatePropagation"]),l={prevent:f,preventDefault:f,stopPropagation(){this.event?.stopPropagation?.()},stopImmediatePropagation(){this.event?.stopImmediatePropagation?.()}};function f(){this.event?.preventDefault?.()}function p(e){if("string"!=typeof e||0===e.trim().length)throw new TypeError("Handler ref must be a non-empty string.");return e.split(";").map(e=>e.trim()).filter(Boolean).map(d)}function h(e){if("string"!=typeof e||0===e.length)throw new TypeError("Handler id must be a non-empty string.")}function d(e){if(e.startsWith("server."))return(e=>{const t=e.indexOf("(");if(-1===t||!e.endsWith(")"))throw new Error(`Server command "${e}" must be called with parentheses.`);const r=e.slice(7,t).trim();if(!(e=>/^[^.\s();]+(?:\.[^.\s();]+)*$/.test(e))(r))throw new Error(`Server command "${e}" has an invalid function id.`);return{type:"server",id:r,args:(n=e.slice(t+1,-1),0===n.trim().length?[]:n.split(",").map(e=>e.trim()).filter(Boolean).map(y))};var n})(e);if(e.includes("(")||e.includes(")"))throw new Error(`Command "${e}" is not supported.`);return{type:"handler",id:e}}function y(e){if(!/^[^\s,();]+$/.test(e))throw new Error(`Argument "${e}" is not supported.`);return e.startsWith("$")?{type:"local",name:e}:{type:"signal",path:e}}return{createHandlerRegistry:function(t={},r={}){const c=r.registry??s(),f=r.type??"handler",d=c._map(f),y=r.lazyRegistry??a(r),g=new Map,w=o({register(e,t){if(h(e),"function"!=typeof t&&!i(t))throw new TypeError(`Handler "${e}" must be a function.`);if(d.has(e))throw new Error(`Handler "${e}" is already registered.`);return d.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))w.register(t,r);return w},unregister:e=>(h(e),g.delete(e),d.delete(e)),resolve(e){h(e);const t=d.get(e);return i(t)?(g.has(e)||g.set(e,async function(...r){const n=await y.resolve(f,e,t);if("function"!=typeof n)throw new TypeError(`Handler "${e}" did not resolve to a function.`);return n.apply(this,r)}),g.get(e)):t},async run(t,r={}){const o=p(t),s=[];let a=!1;const i={...r,handlers:w,input:r.input??e(r),stop(){a=!0}};for(const e of o){if(a)break;if("server"===e.type){if(!i.server||"function"!=typeof i.server.run)throw new Error(`Server command "${e.id}" cannot run without a server registry.`);const t=n(e.args,i),r=await i.server.run(e.id,t.args,{...i,signalPaths:t.signalPaths,signalValues:t.signalValues});s.push(r);continue}const t=w.resolve(e.id);if(!t)throw new Error(`Handler "${e.id}" is not registered.`);const r=await t.call(i,i);u.has(e.id)&&t===l[e.id]||s.push(r)}return s},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))d.has(t)||w.register(t,r);return w}},c,f);return((e,t)=>{for(const[r,n]of Object.entries(l))if(t.has(r)){if(t.get(r)!==n)throw new Error(`Handler "${r}" is already registered.`)}else e.register(r,n)})(w,d),w.registerMany(t),w},parseHandlerRef:p,isHandlerToken:e=>u.has(e)}})(),l=(()=>{const e=["binding","lifecycle","effect","async","post"];function t(e){return"object"==typeof e&&null!==e||"function"==typeof e}function r(){}return{createScheduler:(n={})=>{const o=[...n.phases??e],s=new Map(o.map(e=>[e,[]])),a=new Map,i=new WeakSet,c=new Set,u=new WeakMap,l="function"==typeof n.onError?n.onError:void 0,f=n.maxDepth??100,p=n.strategy??"microtask";let h=!1,d=!1,y=!1,g=0,w=0,m=0;const b={strategy:p,phases:o,batch(e){if("function"!=typeof e)throw new TypeError("scheduler.batch(fn) requires a function.");j(),g+=1;let t=!1;try{const r=e();return r&&"function"==typeof r.then?(t=!0,Promise.resolve(r).finally(()=>{g-=1,v()})):r}finally{!t&&g>0&&(g-=1,v())}},enqueue(e,t,n={}){if(j(),(e=>{if(!s.has(e))throw new Error(`Unknown scheduler phase "${e}".`)})(e),"function"!=typeof t)throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");const o=n.scope;if(A(o))return r;const i=void 0===n.key?void 0:`${e}:${(e=>void 0===e?"global":"object"==typeof e&&null!==e||"function"==typeof e?(u.has(e)||u.set(e,"scope:"+ ++m),u.get(e)):String(e))(o)}:${String(n.key)}`;if(i&&a.has(i))return a.get(i).cancel;const c={id:++w,phase:e,fn:t,scope:o,boundary:n.boundary,key:i,canceled:!1,cancel(){c.canceled=!0,c.key&&a.delete(c.key)}};return s.get(e).push(c),c.key&&a.set(c.key,c),v(),c.cancel},afterFlush:(e,t={})=>b.enqueue("post",e,t),async flush(){if(j(),d)return;y=!1,d=!0;let e=0;try{for(;E();){if(e+=1,e>f)throw new Error(`Scheduler exceeded maxDepth ${f}.`);for(const e of o)await S(e)}}finally{d=!1,E()&&v()}},async flushScope(e){if(j(),d)return;y=!1,d=!0;let t=0;try{for(;$(e);){if(t+=1,t>f)throw new Error(`Scheduler exceeded maxDepth ${f}.`);for(const t of o)await S(t,e)}}finally{d=!1,E()&&v()}},cancelScope(e){if(void 0===e)return b;for(const t of s.values())for(const r of t)r.scope===e&&r.cancel();return b},markScopeDestroyed:e=>(void 0!==e&&(t(e)?i.add(e):c.add(e),b.cancelScope(e)),b),reviveScope:e=>(void 0!==e&&(t(e)?i.delete(e):c.delete(e)),b),isScopeDestroyed:e=>A(e),inspect(){const e={};for(const[t,r]of s)e[t]=r.filter(e=>!e.canceled).length;return{strategy:p,phases:[...o],pending:e,scopesDestroyed:c.size,flushing:d,scheduled:y}},destroy(){h=!0;for(const e of s.values()){for(const t of e)t.cancel();e.length=0}a.clear(),c.clear()}};return b;function v(){var e;"manual"===p||h||d||g>0||y||(y=!0,e=()=>{h||b.flush()},"function"!=typeof queueMicrotask?Promise.resolve().then(e):queueMicrotask(e))}async function S(e,t){const r=s.get(e),n=[],o=[];for(const e of r.splice(0))e.canceled||(void 0===t||e.scope===t?o.push(e):n.push(e));r.push(...n);for(const e of o)if(e.key&&a.delete(e.key),!e.canceled&&!A(e.scope))try{await e.fn()}catch(t){if(!l)throw t;l(t,e)}}function E(){for(const e of s.values())if(e.some(e=>!e.canceled))return!0;return!1}function $(e){for(const t of s.values())if(t.some(t=>!t.canceled&&t.scope===e))return!0;return!1}function j(){if(h)throw new Error("Scheduler has been destroyed.")}function A(e){return void 0!==e&&(t(e)?i.has(e):c.has(e))}}}})(),f=(()=>{const{renderComponent:e}=i,{createHandlerRegistry:t}=u,{createScheduler:r}=l,{createSignalRegistry:n,isSignalRef:a}=s,{matchAttribute:c,normalizeAttributeConfig:f,readAttribute:p}=o,h="__async:inline:";function d({root:o,signals:s,handlers:i,server:u,router:l,cache:d,attributes:E,scheduler:R}={}){const T=o?.ownerDocument??o??globalThis.document,q=o??T,C=s??n(),M=i??t(),x=R??r(),D=!R,L=f(E),B=new Set,P=new WeakMap,N=new WeakMap,z=new WeakSet,H=new WeakSet,W=new WeakMap,U=new WeakSet,V=new Map,I=new WeakMap;let F=0,J=!1;const K={root:q,signals:C,handlers:M,server:u,router:l,cache:d,scheduler:x,attributes:L,start:()=>(ne(),K.scan(q),K),scan:(e=q)=>(ne(),(e=>{for(const t of A(e))x.reviveScope?.(t)})(e),(e=>{for(const t of A(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,L,"signal");if(r){if("text"===r){const r=t.getAttribute(e);G(t,`text:${r}`,r,e=>{t.textContent=e??""});continue}if("value"===r){const r=t.getAttribute(e);G(t,`value:${r}`,r,e=>{"value"in t&&t.value!==String(e??"")?t.value=e??"":"value"in t||t.setAttribute("value",e??"")}),Q(t,r);continue}if(r.startsWith("attr:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`attr:${n}:${o}`,o,e=>$(t,n,e));continue}if(r.startsWith("prop:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`prop:${n}:${o}`,o,e=>j(t,n,e));continue}if(r.startsWith("class:")){const n=r.slice(6),o=t.getAttribute(e);""===n||"{}"===n?Y(t,n,o):G(t,`class:${n}:${o}`,o,e=>{t.classList.toggle(n,Boolean(e))});continue}if("class"===r){const r=t.getAttribute(e);Y(t,"{}",r)}}}})(e),(e=>{for(const t of A(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,L,"class");null!=r&&Y(t,r,t.getAttribute(e))}})(e),(e=>{for(const t of A(e))if("function"==typeof t.getAttributeNames)for(const e of t.getAttributeNames()){const r=c(e,L,"on");r&&"attach"!==r&&"mount"!==r&&"visible"!==r&&Z(t,r,t.getAttribute(e))}})(e),(e=>{for(const t of A(e)){if(U.has(t))continue;const e=O(t,L);if(null!=e){if(!W.has(t)){const r=S(t,e,L);if(0===Object.keys(r).length||!C.has(e))continue;const n={id:e,templates:r,cleanup:C.subscribe(`${e}.$status`,()=>{x.enqueue("binding",()=>X(t),{scope:t,key:`boundary:${e}`})})};W.set(t,n),oe(n.cleanup,t)}X(t)}}})(e),(e=>{for(const t of A(e)){const e=ee(t,["attach","mount"]);if(0!==e.length&&!z.has(t)){z.add(t);for(const r of e)ue(t,()=>te(t,r),`attach:${r}`)}}for(const t of A(e)){const e=p(t,L,"on","visible");null!=e&&(H.has(t)||(H.add(t),oe(re(t,()=>ue(t,()=>te(t,e),`visible:${e}`)),t)))}})(e),K),swap(e,t){ne();const r=((e,t,r)=>{for(const n of A(e))if(O(n,r)===String(t))return n;return null})(q,e,L);if(!r)throw new Error(`Boundary "${e}" was not found.`);return ae(r),r.replaceChildren(_(t,T)),K.scan(r),r},mount(t,r,n={}){ne();const o=e(r,n,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,attributes:L});return ae(t),t.replaceChildren(_(o.html,t.ownerDocument)),K.scan(t),o.mount(t),o.visible(t,K._observeVisible),oe(o.cleanup,t,"children"),o},destroy(){if(!J){J=!0,(e=>{for(const t of A(e))x.markScopeDestroyed(t)})(q);for(const e of[...B])se(e);B.clear(),D&&x.destroy()}},_observeVisible:(e,t)=>re(e,t),_registerBinding(e){const t=`${h}${++F}`;return V.set(t,e),t},_releaseBinding(e){V.delete(e)}};function Z(e,t,r){const n=`${t}:${r}`,o=P.get(e)??new Set;if(o.has(n))return;o.add(n),P.set(e,o);const s=async t=>{try{await x.batch(()=>M.run(r,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,event:t,element:e,el:e,root:q}))}catch(t){k(e,t)}};e.addEventListener(t,s),oe(()=>e.removeEventListener(t,s),e)}function Y(e,t,r){if(""===t||"{}"===t){const t=b(e);let n=new Set;return void G(e,`class:{}:${r}`,r,r=>{const o=y(r),s=b(e);for(const e of n)o.has(e)||t.has(e)||s.delete(e);for(const e of o)s.add(e);v(e,s),n=o},{rawInline:!0})}G(e,`class:${t}:${r}`,r,r=>{((e,t,r)=>{const n=b(e);for(const e of y(t))r?n.add(e):n.delete(e);v(e,n)})(e,t,Boolean(r))})}function G(e,t,r,n,o={}){const s=N.get(e)??new Set;if(s.has(t))return;s.add(t),N.set(e,s);const a=()=>((e,t={})=>{if(m(e)){const r=V.get(e);return t.rawInline?r:g(r)}return C.get(e)})(r,o);n(a()),oe(((e,t)=>{if(!m(e))return C.subscribe(e,t);const r=w(V.get(e)).map(e=>e.subscribe(t));return()=>{for(const e of r)e()}})(r,()=>{x.enqueue("binding",()=>n(a()),{scope:e,key:t})}),e)}function Q(e,t){Z(e,"input",`__async:set:${t}`),Z(e,"change",`__async:set:${t}`),M.resolve(`__async:set:${t}`)||M.register(`__async:set:${t}`,({element:e})=>{((e,t)=>{if(!m(e))return C.set(e,t);const r=V.get(e);if(a(r))return r.set(t);throw new Error(`Inline binding "${e}" is not writable.`)})(t,e.value)})}function X(e){const t=W.get(e);if(!t)return;const r=C.get(`${t.id}.$status`),n=((e,t)=>"ready"===t?e.ready??e.loading??e.error:"error"===t?e.error??e.ready??e.loading:e.loading??e.ready??e.error)(t.templates,r);if(n){ae(e),e.replaceChildren(n.content.cloneNode(!0)),U.add(e);try{K.scan(e)}finally{U.delete(e)}}}function ee(e,t){const r=[];for(const n of t){const t=p(e,L,"on",n);null!=t&&r.push(t)}return r}async function te(e,t){try{const r=await M.run(t,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,element:e,el:e,root:q});for(const t of r)"function"==typeof t&&oe(t,e)}catch(t){k(e,t)}}function re(e,t){const r=(e.ownerDocument?.defaultView??globalThis).IntersectionObserver??globalThis.IntersectionObserver;if(!r)return x.enqueue("lifecycle",()=>{J||t(e)},{scope:e,key:"visible:fallback"}),()=>{};const n=new r(r=>{r.some(e=>e.isIntersecting)&&(n.disconnect(),t(e))});return n.observe(e),()=>n.disconnect()}function ne(){if(J)throw new Error("Loader has been destroyed.")}function oe(e,t,r="self"){if("function"!=typeof e)return e;if(B.add(e),t){const n=I.get(t)??[];n.push({cleanup:e,mode:r}),I.set(t,n)}return e}function se(e){"function"==typeof e&&B.has(e)&&(B.delete(e),e())}function ae(e){ce(e,"children");for(const t of[...e.childNodes??[]])ie(t)}function ie(e){if(1===e.nodeType)for(const t of A(e))ce(t),x.markScopeDestroyed(t)}function ce(e,t){const r=I.get(e);if(!r)return;const n=[];for(const e of r)t&&e.mode!==t?n.push(e):se(e.cleanup);n.length>0?I.set(e,n):I.delete(e)}function ue(e,t,r){x.enqueue("lifecycle",t,{scope:e,key:r})}return C._setContext?.({server:K.server,router:K.router,loader:K,cache:K.cache,scheduler:x}),K.server?._setContext?.({signals:C,handlers:M,loader:K,router:K.router,cache:K.cache,scheduler:x}),K}function y(e,t=new Set){if(null==e||!1===e)return t;if(a(e)){const r=e.value;return!0===r?(t.add(e.id.split(".").at(-1)),t):y(r,t)}if("string"==typeof e){for(const r of e.split(/\s+/).filter(Boolean))t.add(r);return t}if(Array.isArray(e)){for(const r of e)y(r,t);return t}if("object"==typeof e){for(const[r,n]of Object.entries(e))(a(n)?n.value:n)&&y(r,t);return t}return!0!==e&&t.add(String(e)),t}function g(e){return a(e)?e.value:Array.isArray(e)?e.map(g):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,g(t)])):e}function w(e,t=new Map){if(a(e))return t.set(e.id,e),[...t.values()];if(Array.isArray(e)){for(const r of e)w(r,t);return[...t.values()]}if(e&&"object"==typeof e)for(const r of Object.values(e))w(r,t);return[...t.values()]}function m(e){return"string"==typeof e&&e.startsWith(h)}function b(e){return y(e.getAttribute("class")??"")}function v(e,t){const r=[...t].join(" ");0!==r.length?e.setAttribute("class",r):e.removeAttribute("class")}function S(e,t,r){const n={};for(const o of[...e.children].filter(e=>"TEMPLATE"===e.tagName))E(o,"loading",t,e,r)&&(n.loading=o),E(o,"ready",t,e,r)&&(n.ready=o),E(o,"error",t,e,r)&&(n.error=o);return n}function E(e,t,r,n,o){return p(e,o,"async",t)===r||R(n)&&e.hasAttribute?.(t)}function $(e,t,r){if(!1===r||null==r)return e.removeAttribute(t),void(t in e&&(e[t]=!1));e.setAttribute(t,!0===r?"":String(r)),t in e&&(e[t]=r)}function j(e,t,r){e[t]=null!=r?r:""}function A(e){return(e=>{const t=[];return 1===e?.nodeType&&e.matches?.("*")&&t.push(e),t.push(...e?.querySelectorAll?.("*")??[]),t})(e)}function O(e,t){return R(e)&&e.hasAttribute?.("for")?e.getAttribute("for"):p(e,t,"async","boundary")}function R(e){return"ASYNC-SUSPENSE"===e?.tagName}function _(e,t){if(11===e?.nodeType)return e;if("TEMPLATE"===e?.tagName)return e.content.cloneNode(!0);if(e?.nodeType){const r=t.createDocumentFragment();return r.append(e),r}const r=t.createElement("template");return r.innerHTML=String(e??""),r.content.cloneNode(!0)}function k(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;e.dispatchEvent(new r("async:error",{bubbles:!0,detail:{error:t}}))}return{Loader:d,AsyncLoader:d}})(),p=(()=>{const{isTemplateResult:e,renderTemplate:n}=a,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t;function u(e,t={}){return r=e,Boolean(r&&"object"==typeof r&&!Array.isArray(r)&&(Object.hasOwn(r,"html")||Object.hasOwn(r,"signals")||Object.hasOwn(r,"boundary")||Object.hasOwn(r,"redirect")||Object.hasOwn(r,"status")||Object.hasOwn(r,"cache")))?{...e,html:Object.hasOwn(e,"html")?l(e.html,t):e.html}:{html:l(e,t)};var r}function l(t,r){return t?.nodeType||"string"==typeof t?t:(e(t),n(t,function(e){return{attributes:e.loader?.attributes,signals:e.signals,bind:e.loader?._registerBinding?.bind(e.loader)}}(r)))}function f(e){if("string"!=typeof e||0===e.length)throw new TypeError("Partial id must be a non-empty string.")}return{createPartialRegistry:function(e={},t={}){const r=t.registry??s(),n=t.type??"partial",a=r._map(n),l=t.lazyRegistry??i(t),p=new Map,h=o({register(e,t){if(f(e),"function"!=typeof t&&!c(t))throw new TypeError(`Partial "${e}" must be a function.`);if(a.has(e))throw new Error(`Partial "${e}" is already registered.`);return a.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))h.register(t,r);return h},unregister:e=>(f(e),p.delete(e),a.delete(e)),resolve(e){f(e);const t=a.get(e);return c(t)?(p.has(e)||p.set(e,async function(...r){const o=await l.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Partial "${e}" did not resolve to a function.`);return o.apply(this,r)}),p.get(e)):t},async render(e,t={},r={}){f(e);const n=h.resolve(e);if(!n)throw new Error(`Partial "${e}" is not registered.`);const o={...r,id:e,props:t,cache:r.cache,partials:h};return u(await n.call(o,t),o)},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))a.has(t)||h.register(t,r);return h}},r,n);return h.registerMany(e),h},normalizePartialResult:u}})(),h=(()=>{const{Loader:e}=f,{createHandlerRegistry:t}=u,{createScheduler:n}=l,{createSignalRegistry:a}=s,{applyServerResult:i}=c,{createRegistryStore:p}=r,{normalizeAttributeConfig:h}=o;function d(e,t={}){return{...t,partial:e}}const y=d,g=new Set(["csr","spa","ssr","mpa"]);function w(e={},t={}){const r=t.registry??p(),n=t.type??"route",o=r._map(n),s=[],a={registry:r,register(e,t){if(j(e),s.some(t=>t.pattern===e))throw new Error(`Route "${e}" is already registered.`);const r=m(e,t);return o.set(e,r.definition),s.push(r),E(s),r},registerMany(e){for(const[t,r]of Object.entries(e??{}))a.register(t,r);return a},unregister(e){j(e);const t=s.findIndex(t=>t.pattern===e);return-1!==t&&s.splice(t,1),o.delete(e)},match(e){const t=(e=>e instanceof URL?e:new URL(String(e),globalThis.location?.href??"http://localhost/"))(e).pathname;for(const e of s){const r=e.regex.exec(t);if(!r)continue;const n={};return e.keys.forEach((e,t)=>{n[e]=S(r[t+1]??"")}),{pattern:e.pattern,params:n,route:e.definition}}return null},entries:()=>s.map(({pattern:e,definition:t})=>({pattern:e,route:t})),keys:()=>[...o.keys()],inspect:()=>r.entries(n),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)?i(t,o.get(t)):a.register(t,r);return a}};for(const[e,t]of o)i(e,t);return a.registerMany(e),a;function i(e,t){if(s.some(t=>t.pattern===e))return;const r=m(e,t);o.set(e,r.definition),s.push(r),E(s)}}function m(e,t){const r="string"==typeof t?d(t):t,{regex:n,keys:o}=(e=>{const t=[];if("*"===e)return{regex:/^.*$/,keys:t};if("/"===e)return{regex:/^\/$/,keys:t};const r=e.split("/").map(e=>e.startsWith(":")?(t.push(e.slice(1)),"([^/]+)"):String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return{regex:new RegExp(`^${r}$`),keys:t}})(e);return{pattern:e,regex:n,keys:o,score:$(e),definition:r}}function b(e,t){return e?.closest?.(t)}function v(e){return Object.fromEntries(e.searchParams.entries())}function S(e){try{return decodeURIComponent(e)}catch{return e}}function E(e){e.sort((e,t)=>t.score-e.score||t.pattern.length-e.pattern.length)}function $(e){return"*"===e?-1:e.split("/").filter(Boolean).reduce((e,t)=>"*"===t?e:t.startsWith(":")?e+2:e+4,"/"===e?3:0)}function j(e){if("string"!=typeof e||"*"!==e&&!e.startsWith("/"))throw new TypeError('Route pattern must be a path string or "*".')}return{defineRoute:d,createRouteRegistry:w,createRouter:({mode:r="ssr",root:o,boundary:s="route",routes:c=w(),loader:u,signals:l,handlers:f,server:p,cache:d,partials:y,attributes:m,scheduler:S}={})=>{(e=>{if(!g.has(e))throw new TypeError(`Unknown router mode "${e}".`)})(r);const E=o?.ownerDocument??o??globalThis.document,$=o??E,j=l??u?.signals??a(),A=f??u?.handlers??t(),O=S??u?.scheduler??n(),R=!S&&!u?.scheduler,_=h(m??u?.attributes),k=u??e({root:$,signals:j,handlers:A,server:p,cache:d,scheduler:O,attributes:_}),T=!u,q=new Set;let C,M=!1,x=0;const D={mode:r,root:$,boundary:s,routes:c,loader:k,signals:j,handlers:A,server:p,cache:d,partials:y,scheduler:O,attributes:_,start:()=>(I(),k.router=D,j._setContext?.({router:D,loader:k,server:p,cache:d,scheduler:O}),T&&k.start(),"mpa"===r||"ssr"===r?(N(),D):((()=>{const e=e=>{const t=b(e.target,"a[href]");t&&!((e,t)=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;if(t.target||t.hasAttribute("download"))return!0;const r=V(t.href),n=U();return r.origin!==n.origin||((e,t,r)=>e.origin===t.origin&&e.pathname===t.pathname&&e.search===t.search&&(e.hash!==t.hash||!0===r.getAttribute?.("href")?.startsWith("#")))(r,n,t)})(e,t)&&(e.preventDefault(),W(D.navigate(t.href)))},t=e=>{const t=b(e.target,"form");t&&!(e=>"get"!==String(e.method||"get").toLowerCase()||V(e.action).origin!==U().origin)(t)&&(e.preventDefault(),W(D.navigate((e=>{const t=V(e.action||e.ownerDocument.defaultView.location.href),r=new e.ownerDocument.defaultView.FormData(e);return t.search=new URLSearchParams(r).toString(),t.href})(t))))},r=()=>W(D.navigate(U(),{history:!1}));$.addEventListener?.("click",e),$.addEventListener?.("submit",t),E.defaultView?.addEventListener?.("popstate",r),q.add(()=>$.removeEventListener?.("click",e)),q.add(()=>$.removeEventListener?.("submit",t)),q.add(()=>E.defaultView?.removeEventListener?.("popstate",r))})(),"csr"===r?(W(D.navigate(U(),{replace:!0,initial:!0,source:"client"})),D):(N(),D))),match:e=>c.match(V(e)),prefetch(e){if(I(),"mpa"===r||"ssr"===r)return Promise.resolve(null);const t=D.match(e);return t?.route?.partial&&y?.resolve?.(t.route.partial)?y.render(t.route.partial,t.params,{...L(t),prefetch:!0}):Promise.resolve(null)},navigate:async(e,t={})=>(I(),"mpa"===r||"ssr"===r?(E.defaultView?.location?.assign?.(e),null):(async(e,t={})=>{const r=D.match(e);if(!r)return B(e,null),(e=>{z(e,null,{pending:!1,error:new Error(`No route matched ${e.pathname}${e.search}`)})})(e),null;const n=B(e,r);z(e,r,{pending:!0,error:null});try{if(!r.route?.partial||!y?.resolve?.(r.route.partial)){const t=new Error(`Route "${e.pathname}" does not have a registered partial.`);return P(n)&&H({pending:!1,error:t}),null}const o=await y.render(r.route.partial,r.params,L(r,n));return P(n)?(await(async(e,t,r,n)=>{P(n)&&(await i(e,{signals:j,loader:k,router:D,cache:d,scheduler:O,abort:n?.abort}),await O.flush(),P(n)&&(null==e?.html||e.boundary||e.redirect||(k.swap(s,e.html),await O.flush()),e?.redirect||!1===r.history||(r.replace?E.defaultView?.history?.replaceState?.({},"",t.href):E.defaultView?.history?.pushState?.({},"",t.href))))})(o,e,t,n),P(n)?(H({pending:!1,error:null}),o):null):null}catch(e){if(!P(n))return null;throw H({pending:!1,error:e}),e}})(V(e),t)),destroy(){if(!M){M=!0,C?.controller.abort(new Error("Router has been destroyed."));for(const e of q)e();q.clear(),R&&O.destroy()}}};return D;function L(e,t){return{params:e.params,route:e.route,router:D,signals:j,handlers:A,loader:k,server:p,cache:d,scheduler:O,abort:t?.abort}}function B(e,t){C?.controller.abort(new Error(`Router navigation superseded by ${e.pathname}${e.search}.`));const r=new AbortController,n={id:++x,controller:r,abort:r.signal,target:e,matched:t};return C=n,n}function P(e){return!M&&e&&C?.id===e.id&&!e.abort.aborted}function N(){const e=U();z(e,D.match(e),{pending:!1,error:null})}function z(e,t,r={}){j.ensure("router",{}),H({url:e.href,path:e.pathname,query:v(e),params:t?.params??{},route:t?.route??null,...r})}function H(e){j.ensure("router",{});for(const[t,r]of Object.entries(e))j.set(`router.${t}`,r)}function W(e){e.catch(e=>{M||(H({pending:!1,error:e}),((e,t)=>{const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;"function"==typeof r&&e.dispatchEvent?.(new r("async:error",{bubbles:!0,detail:{error:t}}))})($,e))})}function U(){return V(E.defaultView?.location?.href??"http://localhost/")}function V(e){return e instanceof URL?e:new URL(String(e),E.defaultView?.location?.href??"http://localhost/")}function I(){if(M)throw new Error("Router has been destroyed.")}},route:y}})(),d=(()=>{const{createCacheRegistry:e}=n,{createComponentRegistry:a}=i,{createHandlerRegistry:d}=u,{Loader:y}=f,{createPartialRegistry:g}=p,{createRouteRegistry:w,createRouter:m}=h,{createScheduler:b}=l,{createServerNamespace:v}=c,{cloneSignalDeclaration:S,createSignal:E,createSignalRegistry:$}=s,{createRegistryStore:j}=r,{attributeName:A,normalizeAttributeConfig:O}=o,{createLazyRegistry:R,defineRegistrySnapshot:_,sameRegistryValue:k}=t,T=new Set(["signal","handler","server","partial","route","component","asyncSignal"]);function q(e,t={}){const r=j(void 0,{target:"browser"}),n=new Set,o=t.createRuntime??C,s={registry:r,use(e,t){const o=((e,t)=>{const r={signal:{},handler:{},server:{},partial:{},route:{},component:{},asyncSignal:{},cache:{browser:{},server:{}}};if("string"==typeof e){if(!T.has(e))throw new Error(`Unknown Async registry type "${e}".`);return r[e]=F(e,t),r}if(!e||"object"!=typeof e)throw new TypeError("Async.use(...) requires a registry type or module object.");for(const[t,n]of Object.entries(e))if("cache"!==t){if(!T.has(t))throw new Error(`Unknown Async registry type "${t}".`);r[t]=F(t,n)}else r.cache.browser={...n?.browser??{}},r.cache.server={...n?.server??{}};return r})(e,t);((e,t)=>{for(const r of T)B(e,r,t[r]);B(e,"cache.browser",t.cache.browser),B(e,"cache.server",t.cache.server)})(r,o);for(const e of n)e._applyUse(o);return s},snapshot:()=>r.rawSnapshot(),start(e={}){const t=o(s,e).start();return s.runtime=t,t},attachRoot:e=>(e=>(e.runtime||e.start(),e.runtime))(s).attachRoot(e),detachRoot:e=>s.runtime?.detachRoot(e)??s,applySnapshot:(e,t={})=>s.runtime?(s.runtime.applySnapshot(e,t),s):(((e,t={},r={})=>{const n=z(t);for(const[t,o]of Object.entries(n.signal))N(e,"signal",t,E(o),r);for(const t of["handler","server","partial","route","component","asyncSignal"])for(const[o,s]of Object.entries(n[t]))N(e,t,o,s,r)})(r,e,t),s),inspectRoots:()=>s.runtime?.inspectRoots()??{count:0,roots:[]},_attach:e=>(n.add(e),()=>s._detach(e)),_detach(e){n.delete(e)}};return e&&s.use(e),s}function C(t=M,r={}){const n=(o=t,Boolean(o&&"function"==typeof o.use&&"function"==typeof o.snapshot&&o.registry)?t:q(t??{}));var o;const s=r.target??"browser",i=r.scheduler??r.loader?.scheduler??b({strategy:"server"===s?"manual":"microtask"}),c=!r.scheduler&&!r.loader?.scheduler,u=O(r.attributes),l=r.lazyRegistry??R({registryAssets:r.registryAssets,importModule:r.importModule}),f=r.registry??((e,{target:t}={})=>{const r=e.rawSnapshot();return j({...r,signal:L(r.signal)},{target:t})})(n.registry,{target:s}),p=r.signals??$(void 0,{registry:f,type:"signal",lazyRegistry:l}),h=r.handlers??d(void 0,{registry:f,type:"handler",lazyRegistry:l}),v=e(void 0,{registry:f,type:"cache.server"}),S=e(void 0,{registry:f,type:"cache.browser"}),E=r.serverFactory??I,A=r.server??E(void 0,{registry:f,type:"server"}),_=r.partials??g(void 0,{registry:f,type:"partial",lazyRegistry:l}),k=r.routes??w(void 0,{registry:f,type:"route"}),T=r.components??a(void 0,{registry:f,type:"component",lazyRegistry:l}),C=r.loader||Object.hasOwn(r,"root")?r.root:null;let B=r.loader,N=r.router,H=!1,W=()=>{},F=!1,J=!1;const Z=new Map,Y=C??globalThis.document,G=r.snapshot??("browser"===s?x(Y,{attributes:u}):void 0);((e,t)=>{try{e.cache=t}catch{}})(A,v);const Q={app:n,registry:f,target:s,signals:p,handlers:h,server:A,partials:_,routes:k,components:T,browser:{cache:S},loader:B,router:N,scheduler:i,attributes:u,start:()=>(ne(),F||(F=!0,"server"!==s?(te({cache:S}),p._setContext?.({server:A,loader:B,cache:S,scheduler:i}),B?(X(B.root,B),B.start(),ee(B.root)):null!=C&&Q.attachRoot(C)):(te({cache:v}),p._setContext?.({server:A,cache:v,scheduler:i}))),Q),use:(e,t)=>(n.use(e,t),Q),attachRoot(e){if(ne(),"server"===s)throw new Error("Server runtimes cannot attach DOM roots.");if(!e)throw new TypeError("runtime.attachRoot(root) requires a root.");if(Z.has(e))return Q;const t=0===Z.size&&B?B:y({root:e,signals:p,handlers:h,server:A,cache:S,scheduler:i,attributes:u});return X(e,t),t.start(),te({cache:S}),p._setContext?.({server:A,loader:Q.loader,cache:S,scheduler:i}),ee(e),Q},detachRoot(e){if(ne(),"server"===s)return Q;if(null==e){for(const e of new Set(Z.values()))e.destroy?.();return Z.clear(),N?.destroy?.(),N=void 0,H=!1,B=void 0,Q.loader=void 0,Q.router=void 0,Q}const t=Z.get(e);if(!t)return Q;if(t.destroy?.(),Z.delete(e),B===t){N?.destroy?.(),N=void 0,H=!1;const e=Z.values().next().value;B=e,Q.loader=e,Q.router=void 0,e&&ee(e.root)}return Q},inspectRoots:()=>({count:Z.size,roots:[...Z].map(([e,t])=>({root:e,loader:t,primary:t===B}))}),applySnapshot:(e,t={})=>(((e,t={},r={})=>{const n=z(t);P(e,"asyncSignal",n.asyncSignal,null,r);for(const[t,r]of Object.entries(n.signal))U(e.signals,t,r);e.browser.cache.restore(n.cache.browser),P(e,"handler",n.handler,e.handlers,r),P(e,"server",n.server,e.server,r),P(e,"partial",n.partial,e.partials,r),P(e,"route",n.route,e.routes,r),P(e,"component",n.component,e.components,r)})(Q,e,t),Q),async render(e){ne(),te({cache:v}),p._setContext?.({server:A,cache:v,scheduler:i});const t=k.match(e);if(!t)return await i.flush(),{html:K("",{status:404,signals:p,browserCache:S,boundary:r.boundary??"route",attributes:u}),status:404,signals:p.snapshot(),cache:{browser:S.snapshot()}};const n=t.route.partial,o=n&&_.resolve(n)?await _.render(n,t.params,{params:t.params,route:t.route,signals:p,handlers:h,server:A,cache:v,browserCache:S,partials:_,scheduler:i,...re()}):{html:""};if(o.signals)for(const[e,t]of Object.entries(o.signals))V(p,e,t);o.cache?.browser&&S.restore(o.cache.browser),await i.flush();const s=o.status??200;return{html:K(o.html,{status:s,signals:p,browserCache:S,boundary:o.boundary??r.boundary??"route",attributes:u}),status:s,signals:p.snapshot(),cache:{browser:S.snapshot()}}},destroy(){if(J)return;J=!0,W(),N?.destroy?.();const e=new Set(Z.values());for(const t of e)t.destroy?.();Z.clear(),B&&!e.has(B)&&B?.destroy?.(),p.destroy?.(),c&&i.destroy()},_applyUse(e){((e,t)=>{D(e.signals,e.registry,t.signal),D(e.handlers,e.registry,t.handler),D(e.server,e.registry,t.server),D(e.partials,e.registry,t.partial),D(e.routes,e.registry,t.route),D(e.components,e.registry,t.component),((e,t,r)=>{if(r&&0!==Object.keys(r).length)for(const[n,o]of Object.entries(r))e.has(t,n)||e.register(t,n,o)})(e.registry,"asyncSignal",t.asyncSignal),D(e.browser.cache,e.registry,t.cache.browser),D(e.server.cache,e.registry,t.cache.server)})(Q,e)}};return A.cache=v,Q.server.cache=v,Q.applySnapshot(G,{strict:r.strictSnapshots??!0}),W=n._attach(Q),Q;function X(e,t){Z.set(e,t),B||(B=t,Q.loader=t),t.server=A,t.cache=S,t.scheduler=i}function ee(e){!1!==N&&!H&&(N||((e,t)=>Boolean(t.routerOptions||t.mode||e.entries().length>0))(k,r))&&Q.loader&&(N=N??m({mode:r.mode??"ssr",root:e,boundary:r.boundary??"route",routes:k,loader:Q.loader,signals:p,handlers:h,server:A,cache:S,partials:_,scheduler:i,attributes:u}),Q.router=N,Q.loader.router=N,te({cache:S,router:N}),N.start(),H=!0)}function te(e={}){const t=(e=>"function"==typeof e?.registerMany)(A)?v:e.cache;A._setContext?.({signals:p,loader:B,router:N,cache:t,scheduler:i,requestContext:r.requestContext,...re()})}function re(){const e=(t=r.requestContext)?"function"==typeof t.get?t.get()??{}:"function"==typeof t.getStore?t.getStore()??{}:{}:{};var t;return{requestContext:e,request:e.request??r.request,headers:e.headers??r.headers,cookies:e.cookies??r.cookies,locals:e.locals??r.locals}}function ne(){if(J)throw new Error("Async app runtime has been destroyed.")}}const M=q();function x(e=globalThis.document,{attributes:t}={}){const r=O(t),n=A(r,"async","snapshot"),o=e?.ownerDocument??e??globalThis.document,s=e??o;if(!s?.querySelectorAll&&!o?.querySelectorAll)return{};const a={};for(const e of new Set([s,o]))if(e?.querySelectorAll)for(const t of e.querySelectorAll("script[type='application/json'], script")){if(!t.hasAttribute?.(n))continue;const e=t.textContent?.trim()??"";if(!e)continue;let r;try{r=JSON.parse(e)}catch(e){throw new Error(`Could not parse Async snapshot: ${e instanceof Error?e.message:String(e)}`)}H(a,r,{strict:!0})}return a}function D(e,t,r){r&&0!==Object.keys(r).length&&(e?.registry!==t?e?.registerMany?.(r):e._adoptMany?.(r))}function L(e={}){const t={};for(const[r,n]of Object.entries(e??{}))t[r]=S(n);return t}function B(e,t,r){for(const[n,o]of Object.entries(r??{}))e.register(t,n,o)}function P(e,t,r,n,o={}){if(r&&0!==Object.keys(r).length){for(const[n,s]of Object.entries(r)){if("asyncSignal"===t&&e.signals?.has?.(n)&&!e.registry.has(t,n))throw new Error(`Signal "${n}" is already registered.`);N(e.registry,t,n,s,o)}n?._adoptMany?.(r)}}function N(e,t,r,n,o={}){const s=o.strict??!0,a=e._map(t);if(a.has(r)){if(k(a.get(r),n)||W(a.get(r),n))return;if(s)throw new Error(`${t} "${r}" is already registered with a different value.`)}else e.set(t,r,n)}function z(e={}){return{signal:{...e.signals??{},...e.signal??{}},handler:{...e.handler??{}},server:{...e.server??{}},partial:{...e.partial??{}},route:{...e.route??{}},component:{...e.component??{}},asyncSignal:{...e.asyncSignal??{}},cache:{browser:{...e.entries?.browser??{},...e.cache?.browser??{}}}}}function H(e,t,r={}){const n=z(_(t));e.signal={...e.signal??e.signals??{},...n.signal},e.signals=e.signal,e.cache={...e.cache??{},browser:{...e.cache?.browser??{},...n.cache.browser}};for(const t of["handler","server","partial","route","component","asyncSignal"]){e[t]=e[t]??{};for(const[o,s]of Object.entries(n[t]))if(Object.hasOwn(e[t],o)){if(k(e[t][o],s)||W(e[t][o],s))continue;if(r.strict??1)throw new Error(`${t} "${o}" is already declared with a different value.`)}else e[t][o]=s}return e}function W(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function U(e,t,r){if(e.has?.(t)){const n=e._entry?.(t);return"function"==typeof n?._restore&&(e=>!(!e||"object"!=typeof e||Array.isArray(e))&&(Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))))(r)?void n._restore(r):void e.set(t,r)}e.register(t,E(r))}function V(e,t,r){if("function"==typeof e._setPath)return void e._setPath(t,r);const n=String(t).split(".")[0];e.has?.(n)?e.set(t,r):(e.register(n,E(t===n?r:{})),t!==n&&e.set(t,r))}function I(e={},t={}){const r=t.registry??j(),n=t.type??"server",o={},s={registry:r,register:(e,t)=>(r.register(n,e,t),e),registerMany(e){for(const[t,r]of Object.entries(e??{}))s.register(t,r);return s},unregister:e=>r.unregister(n,e),resolve(){},async run(e){throw new Error(`Server command "${e}" cannot run without a server proxy or server registry.`)},keys:()=>r.keys(n),entries:()=>r.entries(n),inspect:()=>r.entries(n),_setContext:(e={})=>(Object.assign(o,e),s),_adoptMany:()=>s};return s.registerMany(e),v((e,t,r)=>s.run(e,t,r),s,()=>o)}function F(e,t={}){if("signal"!==e)return{...t??{}};const r={};for(const[e,n]of Object.entries(t??{}))r[e]=J(n);return r}function J(e){return e&&"object"==typeof e&&"function"==typeof e.subscribe?e:E(e)}function K(e,{signals:t,browserCache:r,boundary:n,attributes:o}){const s={signals:t.snapshot(),cache:{browser:r.snapshot()}},a=A(o,"async","boundary"),i=A(o,"async","snapshot");return`<section ${a}="${c=n,String(c).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}">${e??""}</section><script type="application/json" ${i}>${(e=>JSON.stringify(e).replaceAll("<","\\u003c"))(s)}<\/script>`;var c}return{defineApp:q,createApp:C,readSnapshot:x,Async:M}})(),y=(()=>{function e(e){if("string"!=typeof e||0===e.length)throw new TypeError("Boundary patch boundary must be a non-empty string.")}function t(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))}return{createBoundaryReceiver:(r={})=>{const n=r.loader,o=r.signals??n?.signals,s=r.cache??n?.cache,a=r.scheduler??n?.scheduler,i=r.router??n?.router,c=r.recentLimit??50,u=!0===r.throwOnError,l="function"==typeof r.onApply?r.onApply:void 0,f="function"==typeof r.onIgnore?r.onIgnore:void 0,p="function"==typeof r.onError?r.onError:void 0,h="function"==typeof r.isScopeDestroyed?r.isScopeDestroyed:e=>a?.isScopeDestroyed?.(e)??a?.inspectDestroyed?.(e)??!1;if(!n||"function"!=typeof n.swap)throw new TypeError("createBoundaryReceiver(...) requires a loader with swap(boundary, html).");if(!Number.isInteger(c)||c<0)throw new TypeError("createBoundaryReceiver(...) recentLimit must be a non-negative integer.");const d=new Map,y=[];let g=!1;const w={async apply(r){if(g)throw new Error("Boundary receiver has been destroyed.");const c=(r=>{if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError("receiver.apply(patch) requires a boundary patch object.");if(e(r.boundary),"number"!=typeof r.seq||!Number.isFinite(r.seq))throw new TypeError("Boundary patch seq must be a finite number.");if(void 0!==r.signals&&!t(r.signals))throw new TypeError("Boundary patch signals must be an object.");if(void 0!==r.cache&&!t(r.cache))throw new TypeError("Boundary patch cache must be an object.");if(void 0!==r.cache?.browser&&!t(r.cache.browser))throw new TypeError("Boundary patch cache.browser must be an object.");if(void 0!==r.redirect&&("string"!=typeof r.redirect||0===r.redirect.length))throw new TypeError("Boundary patch redirect must be a non-empty string.");if(void 0!==r.parentScope&&"string"!=typeof r.parentScope)throw new TypeError("Boundary patch parentScope must be a string.");if(void 0!==r.scope&&"string"!=typeof r.scope)throw new TypeError("Boundary patch scope must be a string.");const n=Object.hasOwn(r,"html")&&null!=r.html,o=r.signals&&Object.keys(r.signals).length>0,s=r.cache?.browser&&Object.keys(r.cache.browser).length>0,a=Boolean(r.redirect),i=Object.hasOwn(r,"error");if(!(n||o||s||a||i))throw new TypeError("Boundary patch must include html, signals, cache.browser, redirect, or error.");return r})(r),y=(w=c.boundary,d.has(w)||d.set(w,{lastSeq:-1/0,applied:0,ignored:0,errored:0,lastStatus:void 0}),d.get(w));var w,b;if(c.seq<=y.lastSeq){const e={status:"ignored-stale",boundary:c.boundary,seq:c.seq,lastSeq:y.lastSeq};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(void 0!==c.parentScope&&h(c.parentScope)){const e={status:"ignored-destroyed",boundary:c.boundary,seq:c.seq,parentScope:c.parentScope};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(y.lastSeq=c.seq,Object.hasOwn(c,"error")){const e=(b=c.error)instanceof Error?b:b&&"object"==typeof b&&"string"==typeof b.message?Object.assign(new Error(b.message),b):new Error(String(b)),t={status:"errored",boundary:c.boundary,seq:c.seq,error:e};if(y.errored+=1,y.lastStatus=t.status,m(t),p?.(e,t,r),u)throw e;return t}if(c.signals){if(!o||"function"!=typeof o.set)throw new Error("Boundary patch includes signals, but no signal registry is available.");for(const[e,t]of Object.entries(c.signals))o.set(e,t)}if(c.cache?.browser){if(!s||"function"!=typeof s.restore)throw new Error("Boundary patch includes browser cache, but no cache registry is available.");s.restore(c.cache.browser)}if(null!=c.html&&n.swap(c.boundary,c.html),await(async(e,t)=>{e&&(void 0===t||"function"!=typeof e.flushScope?"function"==typeof e.flush&&await e.flush():await e.flushScope(t))})(a,c.scope),c.redirect){await(async(e,t,r)=>{if(t&&"function"==typeof t.navigate)return void await t.navigate(e);const n=r?.root?.ownerDocument?.defaultView?.location??globalThis.location;n?.assign?.(e)})(c.redirect,i,n);const e={status:"redirected",boundary:c.boundary,seq:c.seq,redirect:c.redirect};return y.applied+=1,y.lastStatus=e.status,m(e),l?.(e,r),e}const v={status:"applied",boundary:c.boundary,seq:c.seq};return y.applied+=1,y.lastStatus=v.status,m(v),l?.(v,r),v},inspect(){const e={};for(const[t,r]of d)e[t]={lastSeq:r.lastSeq,applied:r.applied,ignored:r.ignored,lastStatus:r.lastStatus},r.errored>0&&(e[t].errored=r.errored);return{destroyed:g,boundaries:e,recent:y.map(e=>({...e}))}},reset(t){if(void 0===t)return d.clear(),y.length=0,w;e(t),d.delete(t);for(let e=y.length-1;e>=0;e-=1)y[e].boundary===t&&y.splice(e,1);return w},destroy(){g=!0,d.clear(),y.length=0}};return w;function m(e){if(0!==c)for(y.push((e=>{const t={boundary:e.boundary,seq:e.seq,status:e.status};return"ignored-stale"===e.status&&(t.lastSeq=e.lastSeq),"ignored-destroyed"===e.status&&void 0!==e.parentScope&&(t.parentScope=e.parentScope),"redirected"===e.status&&(t.redirect=e.redirect),t})(e));y.length>c;)y.shift()}}}})(),g=(()=>{function e(e){return e?.reason??new Error("Operation aborted")}return{delay:(t,r)=>r?.aborted?Promise.reject(e(r)):new Promise((n,o)=>{let s=setTimeout(()=>{s=void 0,r?.removeEventListener?.("abort",a),n()},t);function a(){void 0!==s&&clearTimeout(s),s=void 0,r?.removeEventListener?.("abort",a),o(e(r))}r?.addEventListener?.("abort",a,{once:!0})})}})(),w=(()=>{const{Async:e}=d;return{defineAsyncContainerElement:function(t={}){const r=t.tagName??"async-container",n=t.customElements??globalThis.customElements;if(!n)throw new Error("defineAsyncContainerElement(...) requires customElements.");const o=n.get(r);if(o)return o;const s=t.app??t.Async??e,a=t.HTMLElement??t.window?.HTMLElement??globalThis.HTMLElement;if(!a)throw new Error("defineAsyncContainerElement(...) requires HTMLElement.");class i extends a{connectedCallback(){if(this.__asyncAttached)return;const e=s.runtime??s.start?.();e?.attachRoot?.(this),this.__asyncRuntime=e,this.__asyncAttached=!0}disconnectedCallback(){this.__asyncAttached&&(this.__asyncRuntime?.detachRoot?.(this),this.__asyncRuntime=void 0,this.__asyncAttached=!1)}}return n.define(r,i),i},defineAsyncSuspenseElement:(e={})=>{const t=e.tagName??"async-suspense",r=e.customElements??globalThis.customElements;if(!r)throw new Error("defineAsyncSuspenseElement(...) requires customElements.");const n=r.get(t);if(n)return n;const o=e.HTMLElement??e.window?.HTMLElement??globalThis.HTMLElement;if(!o)throw new Error("defineAsyncSuspenseElement(...) requires HTMLElement.");class s extends o{}return r.define(t,s),s}}})(),{asyncSignal:m}=e,{Async:b}=d,{createApp:v}=d,{defineApp:S}=d,{readSnapshot:E}=d,{attributeName:$}=o,{defineAttributeConfig:j}=o,{createBoundaryReceiver:A}=y,{createCacheRegistry:O}=n,{defineCache:R}=n,{component:_}=i,{createComponentRegistry:k}=i,{defineComponent:T}=i,{delay:q}=g,{defineAsyncContainerElement:C}=w,{defineAsyncSuspenseElement:M}=w,{createHandlerRegistry:x}=u,{html:D}=a,{createLazyRegistry:L}=t,{defineRegistrySnapshot:B}=t,{Loader:P}=f,{AsyncLoader:N}=f,{createPartialRegistry:z}=p,{createRegistryStore:H}=r,{createRouteRegistry:W}=h,{createRouter:U}=h,{defineRoute:V}=h,{route:I}=h,{createScheduler:F}=l,{applyServerResult:J}=c,{createServerProxy:K}=c,{resolveServerCommandArguments:Z}=c,{unwrapServerResult:Y}=c,{computed:G}=s,{createSignal:Q}=s,{createSignalRegistry:X}=s,{effect:ee}=s,{signal:te}=s;export{m as asyncSignal,b as Async,v as createApp,S as defineApp,E as readSnapshot,$ as attributeName,j as defineAttributeConfig,A as createBoundaryReceiver,O as createCacheRegistry,R as defineCache,_ as component,k as createComponentRegistry,T as defineComponent,q as delay,C as defineAsyncContainerElement,M as defineAsyncSuspenseElement,x as createHandlerRegistry,D as html,L as createLazyRegistry,B as defineRegistrySnapshot,P as Loader,N as AsyncLoader,z as createPartialRegistry,H as createRegistryStore,W as createRouteRegistry,U as createRouter,V as defineRoute,I as route,F as createScheduler,J as applyServerResult,K as createServerProxy,Z as resolveServerCommandArguments,Y as unwrapServerResult,G as computed,Q as createSignal,X as createSignalRegistry,ee as effect,te as signal};
|
|
1
|
+
const e=(()=>{const e=Symbol.for("@async/framework.asyncSignal");return{asyncSignal:function t(r,n){if("string"!=typeof r||0===r.length)throw new TypeError("asyncSignal(id, fn) requires a non-empty string id.");if("function"!=typeof n)throw new TypeError("asyncSignal(id, fn) requires a function.");let o,s,a,i=!1,c=null,u="idle",l=0,f=r,p=0,h=!1;const d=new Set,y=new Set,g={[e]:!0,kind:"async-signal",get id(){return f},get value(){return o},get loading(){return i},get error(){return c},get status(){return u},get version(){return l},set:e=>(o=e,i=!1,c=null,u="ready",$(),o),refresh(){if(!s||h)throw new Error(`Async signal "${f}" is not registered.`);v(a,new Error(`Async signal "${f}" refreshed.`));const e=s,t=l+1;l=t,i=!0,c=null,u="loading";const r=((e,t,r)=>{const n=new AbortController,o=n.signal,s=((e,t)=>{const r=e._context?.()??{},n={signals:e,router:r.router,loader:r.loader,cache:r.cache,abort:t,scheduler:r.scheduler};return{signals:e,server:"function"==typeof r.server?._withContext?r.server._withContext(n):r.server,router:r.router,loader:r.loader,cache:r.cache,scheduler:r.scheduler}})(e,o),a={token:++p,version:r,registry:e,id:t,controller:n,abort:o,...s};return((e,t,r)=>{Object.defineProperty(e,"cancel",{configurable:!0,enumerable:!1,value(e){r(e)}})})(o,0,e=>{v(a,e,{settle:!0,notifyChange:!0})}),a})(e,f,t);a=r,$();const d=(e=>({signals:e.signals,id:e.id,get server(){return e.server},get router(){return e.router},get loader(){return e.loader},get cache(){return e.cache},get scheduler(){return e.scheduler},get version(){return e.version},get abort(){return e.abort},refresh:()=>g.refresh()}))(r);let b;try{b=e._collectDependencies(()=>n.call(d))}catch(e){return w(r,e),Promise.reject(e)}return((e,t)=>{if(m(t)){for(const e of y)e();y.clear();for(const r of e){const e=String(r).split(".")[0];e&&e!==f&&y.add(t.registry.subscribe(r,()=>E()))}}})(b.dependencies,r),Promise.resolve(b.value).then(e=>m(r)?(o=e,i=!1,c=null,u="ready",a=void 0,$(),o):o,e=>m(r)?(w(r,e),o):o)},cancel:e=>(b(e,{settle:!0,notifyChange:!0}),o),subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return d.add(e),()=>d.delete(e)},snapshot:()=>({value:o,loading:i,error:c,status:u,version:l}),_cloneSignalDeclaration:()=>t(r,n),_restore:(e={})=>(e=>!(!e||"object"!=typeof e||Array.isArray(e))&&(Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))))(e)?(b(new Error(`Async signal "${f}" restored from snapshot.`)),o=e.value,i=Boolean(e.loading),c=e.error??null,u="string"==typeof e.status?e.status:(({value:e,loading:t,error:r})=>t?"loading":r?"error":void 0===e?"idle":"ready")({value:o,loading:i,error:c}),Number.isFinite(e.version)&&(l=e.version),$(),g):g.set(e),_bindRegistry(e,t){s=e,f=t;const r=()=>{h||s!==e||"idle"!==u||g.refresh()},n=s._context?.().scheduler;n?n.enqueue("async",r,{scope:f,key:`asyncSignal:${f}:initial`}):queueMicrotask(r)},_dispose(){if(!h){h=!0,(()=>{const e=s?._context?.().scheduler;e?.cancelScope?.(f)})(),b(new Error(`Async signal "${f}" disposed.`));for(const e of y)e();y.clear(),d.clear(),s=void 0}}};function w(e,t){m(e)&&(i=!1,c=t,u="error",a=void 0,$())}function m(e){return Boolean(e)&&!h&&a===e&&e.token===p&&e.registry===s&&e.id===f&&!e.abort.aborted}function b(e,t={}){const r=a,n=Boolean(r)||i;r?v(r,e):n&&(p+=1),t.settle&&n&&!h&&S(t.notifyChange)}function v(e,t,r={}){if(!e)return;const n=a===e;n&&(p+=1,a=void 0),e.abort.aborted||e.controller.abort(t),n&&r.settle&&!h&&S(r.notifyChange)}function S(e=!1){const t=void 0===o?"idle":"ready",r=i||null!==c||u!==t;i=!1,c=null,u=t,e&&r&&$()}function E(){if(h||!s)return;v(a,new Error(`Async signal "${f}" dependency changed.`));const e=s?._context?.().scheduler;e?e.enqueue("async",()=>g.refresh(),{scope:f,key:`asyncSignal:${f}:refresh`}):g.refresh()}function $(){for(const e of[...d])e(g)}return g},isAsyncSignal:t=>Boolean(t?.[e])}})(),t=(()=>{const e=new Set(["handler","component","asyncSignal","partial","route"]);function t(t={}){const r=(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("registryAssets.baseUrl must be a non-empty string.");return a(e)||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?s(e):`/${o(e)}`})(t.baseUrl??"_async"),n={component:"component",handler:"handler",asyncSignal:"asyncSignal",partial:"partial",route:"route",...t.paths??{}};for(const[t,r]of Object.entries(n))if(e.has(t)&&("string"!=typeof r||0===r.length))throw new TypeError(`Registry asset path for "${t}" must be a non-empty string.`);return{baseUrl:r,paths:n}}function r(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.url)}function n(t,n,i,c){if(!e.has(t))throw new Error(`Registry type "${t}" does not support lazy descriptors.`);if(!r(i))throw new TypeError(`Registry descriptor for "${t}:${n}" requires a url.`);const{path:u,hash:l}=(e=>{const t=e.indexOf("#");return-1===t?{path:e,hash:""}:{path:e.slice(0,t),hash:e.slice(t+1)}})(i.url),f=((e,t,r)=>{if(a(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=r.paths[e]??e;return((...e)=>{const[t,...r]=e;return[s(t),...r.map(o)].filter(Boolean).join("/")})(r.baseUrl,n,t)})(t,u,c),p=l?[l]:((e,t)=>{const r=[],n=e.split(".").filter(Boolean).at(-1),o=t.split("/").filter(Boolean).at(-1)?.replace(/\.[^.]+$/,"");for(const e of[n,o,"default"])e&&!r.includes(e)&&r.push(e);return r})(n,u);return{moduleUrl:f,exportNames:p,url:l?`${f}#${l}`:f}}function o(e){return String(e).replace(/^\/+|\/+$/g,"")}function s(e){return String(e).replace(/\/+$/g,"")}function a(e){return/^[A-Za-z][A-Za-z\d+.-]*:/.test(e)}function i(e){return!e||"object"!=typeof e||Array.isArray(e)?JSON.stringify(e):JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]]))}return{defineRegistrySnapshot:(e={})=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("defineRegistrySnapshot(snapshot) requires an object.");return e},createLazyRegistry:(e={})=>{const o=t(e.registryAssets??e.assets),s=e.importModule??(e=>import(e)),a=new Map,i=new Map;return{registryAssets:o,resolveUrl:(e,t,r)=>n(e,t,r,o),async resolve(e,t,c){if(!r(c))return c;const u=`${e}:${t}`;if(i.has(u))return i.get(u);const l=n(e,t,c,o);let f,p=a.get(l.moduleUrl);p||(p=Promise.resolve().then(()=>s(l.moduleUrl)),a.set(l.moduleUrl,p));try{f=await p}catch(r){throw a.get(l.moduleUrl)===p&&a.delete(l.moduleUrl),new Error(`Lazy ${e} "${t}" failed to import ${l.moduleUrl}: ${h=r,h instanceof Error?h.message:String(h)}`,{cause:r})}var h;const d=((e,t,r,n)=>{for(const r of t)if(r in e)return e[r];throw new Error(`Lazy ${r} "${n}" did not export ${t.map(e=>`"${e}"`).join(", ")}.`)})(f,l.exportNames,e,t);return i.set(u,d),d},inspect:()=>({registryAssets:o,modules:[...a.keys()],exports:[...i.keys()]})}},normalizeRegistryAssets:t,isLazyDescriptor:r,sameRegistryValue:(e,t)=>e===t||!(!r(e)||!r(t))&&i(e)===i(t),publicRegistryValue:(e,t)=>r(e)?{...e}:{id:t}}})(),r=(()=>{const{publicRegistryValue:e}=t,r=new Set(["signal","handler","server","partial","route","component","asyncSignal"]),n=new Set(["cache.browser","cache.server"]),o=new Set(["cache.browser.entries","cache.server.entries"]),s=new Set([...r,...n,...o]);function a(e){if(!s.has(e))throw new Error(`Unknown Async registry type "${e}".`);return e}function i(e,t){if("string"!=typeof t||0===t.length)throw new TypeError(`${e} id must be a non-empty string.`)}function c(t,r,n,s){return"server"===t&&"browser"===s.target?e(n,r):o.has(t)?n?.value:n}function u(e,t){return"cache.server.entries"===e&&"browser"===t}function l(e){const t={};for(const[r,n]of e)t[r]="function"==typeof n?.snapshot?n.snapshot():n?.value??n;return t}function f(t){const r={};for(const[n,o]of t)r[n]=e(o,n);return r}function p(e){return Object.fromEntries(e)}function h(e){const t={};for(const[r,n]of e)t[r]=n?.value;return t}function d(e){return e&&"object"==typeof e&&Object.hasOwn(e,"value")?e:{value:e}}return{createRegistryStore:function e(t={},n={}){const o=n.backing??{signal:new Map,handler:new Map,server:new Map,partial:new Map,route:new Map,component:new Map,asyncSignal:new Map,cache:{browser:new Map,server:new Map},cacheEntries:{browser:new Map,server:new Map}},s=n.target??"server",y={target:s,register(e,t,r){const n=y._map(e);if(i(e,t),n.has(t))throw new Error(`${e} "${t}" is already registered.`);return n.set(t,r),t},registerMany(e,t={}){for(const[r,n]of Object.entries(t??{}))y.register(e,r,n);return y},set(e,t,r){const n=y._map(e);return i(e,t),n.set(t,r),r},unregister:(e,t)=>y.delete(e,t),delete:(e,t)=>y._map(e).delete(t),keys:e=>u(e,s)?[]:[...y._map(e).keys()],entries(e,t={}){const r=a(e);return u(r,t.target??s)?[]:[...y._map(r)].map(([e,n])=>[e,c(r,e,n,{target:s,...t})])},has:(e,t)=>(i(e,t),!u(e,s)&&y._map(e).has(t)),get(e,t,r={}){i(e,t);const n=a(e);if(u(n,r.target??s))return;const o=y._map(n).get(t);return void 0!==o?c(n,t,o,{target:s,...r}):void 0},snapshot(e={}){const t=e.target??s;return{signal:l(o.signal),handler:f(o.handler),server:f(o.server),partial:f(o.partial),route:p(o.route),component:f(o.component),asyncSignal:f(o.asyncSignal),cache:{browser:p(o.cache.browser),server:p(o.cache.server)},entries:{browser:h(o.cacheEntries.browser),server:"browser"===t?{}:h(o.cacheEntries.server)}}},rawSnapshot:()=>({signal:Object.fromEntries(o.signal),handler:Object.fromEntries(o.handler),server:Object.fromEntries(o.server),partial:Object.fromEntries(o.partial),route:Object.fromEntries(o.route),component:Object.fromEntries(o.component),asyncSignal:Object.fromEntries(o.asyncSignal),cache:{browser:Object.fromEntries(o.cache.browser),server:Object.fromEntries(o.cache.server)}}),view:(t={})=>e(void 0,{backing:o,target:t.target??s}),_map(e){const t=a(e);if(r.has(t))return o[t];if("cache.browser"===t)return o.cache.browser;if("cache.server"===t)return o.cache.server;if("cache.browser.entries"===t)return o.cacheEntries.browser;if("cache.server.entries"===t)return o.cacheEntries.server;throw new Error(`Unknown Async registry type "${e}".`)}};return((e,t={})=>{e.registerMany("signal",t.signal),e.registerMany("handler",t.handler),e.registerMany("server",t.server),e.registerMany("partial",t.partial),e.registerMany("route",t.route),e.registerMany("component",t.component),e.registerMany("asyncSignal",t.asyncSignal),e.registerMany("cache.browser",t.cache?.browser),e.registerMany("cache.server",t.cache?.server);const r=t.entries??{};for(const[t,n]of Object.entries(r.browser??{}))e.set("cache.browser.entries",t,d(n));for(const[t,n]of Object.entries(r.server??{}))e.set("cache.server.entries",t,d(n))})(y,t),y},attachRegistryInspection:(e,t,r)=>(Object.defineProperty(e,"registry",{configurable:!0,enumerable:!0,value:t}),e.keys=()=>t.keys(r),e.entries=()=>t.entries(r),e.inspect=()=>t.entries(r),e)}})(),n=(()=>{const{attachRegistryInspection:e,createRegistryStore:t}=r,n=Symbol.for("@async/framework.cacheDefinition");function o(e={}){return{[n]:!0,kind:"cache-definition",store:e.store??"memory",ttl:e.ttl}}function s(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache id must be a non-empty string.")}function a(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache key must be a non-empty string.")}return{defineCache:o,createCacheRegistry:(r={},{now:i=()=>Date.now(),registry:c,type:u="cache.browser"}={})=>{const l=c??t(),f=l._map(u),p=l._map(`${u}.entries`),h=new Map,d=e({register(e,t=o()){s(e);const r=(e=>e?.[n]?e:o(e))(t);if(f.has(e))throw new Error(`Cache "${e}" is already registered.`);return f.set(e,r),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))d.register(t,r);return d},unregister:e=>(s(e),f.delete(e)),resolve:e=>(s(e),f.get(e)),get:e=>(a(e),y(e).value),set(e,t,r={}){a(e);const n=r.ttl??((e,t)=>{if(void 0!==t)return f.get(t);if(f.has(e))return f.get(e);const r=e.split(":")[0];return f.get(r)})(e,r.cache)?.ttl;return p.set(e,{value:t,expiresAt:void 0===n?void 0:i()+n}),t},async getOrSet(e,t,r={}){if(a(e),"function"!=typeof t)throw new TypeError("cache.getOrSet(key, fn) requires a function.");const n=y(e);if(n.found)return n.value;if(h.has(e))return h.get(e);let o;return o=Promise.resolve().then(t).then(t=>(h.get(e)===o&&d.set(e,t,r),t)).finally(()=>{h.get(e)===o&&h.delete(e)}),h.set(e,o),o},delete:e=>(a(e),h.delete(e),p.delete(e)),clear(e){if(void 0===e)return p.clear(),h.clear(),d;for(const t of[...p.keys()])t.startsWith(e)&&p.delete(t);for(const t of[...h.keys()])t.startsWith(e)&&h.delete(t);return d},snapshot(){const e={};for(const[t]of p){const{found:r,value:n}=y(t);r&&void 0!==n&&(e[t]=n)}return e},restore(e={}){for(const[t,r]of Object.entries(e??{}))d.set(t,r);return d},entryKeys:()=>[...p.keys()],entryEntries:()=>l.entries(`${u}.entries`),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))f.has(t)||d.register(t,r);return d}},l,u);return d.registerMany(r),d;function y(e){const t=p.get(e);return t?void 0!==t.expiresAt&&t.expiresAt<=i()?(p.delete(e),{found:!1,value:void 0}):{found:!0,value:t.value}:{found:!1,value:void 0}}}}})(),o=(()=>{const e=Object.freeze({async:["async:"],class:["class:"],signal:["signal:"],on:["on:"]});function t(t={}){return{async:r(t.async,e.async),class:r(t.class,e.class),signal:r(t.signal,e.signal),on:r(t.on,e.on)}}function r(e,t){return(null==e?t:Array.isArray(e)?e:[e]).map(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Attribute prefixes must be non-empty strings.");return e})}return{defineAttributeConfig:(e={})=>t(e),normalizeAttributeConfig:t,attributeName:(e,r,n)=>t(e)[r][0]+n,readAttribute:(e,r,n,o)=>{for(const s of t(r)[n]){const t=`${s}${o}`;if(e.hasAttribute?.(t))return e.getAttribute(t)}return null},matchAttribute:(e,r,n)=>{for(const o of t(r)[n])if(e.startsWith(o))return e.slice(o.length);return null}}})(),s=(()=>{const{asyncSignal:n,isAsyncSignal:o}=e,{attachRegistryInspection:s,createRegistryStore:a}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t,u=Symbol.for("@async/framework.signal"),l=Symbol.for("@async/framework.computed"),f=Symbol.for("@async/framework.effect"),p=Symbol.for("@async/framework.signalRef"),h=[];function d(e){let t=e;const r=new Set;return{[u]:!0,kind:"signal",get value(){return t},set value(e){this.set(e)},set:e=>(Object.is(t,e)||(t=e,(()=>{for(const e of[...r])e(t)})()),t),update(e){return this.set(e(t))},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return r.add(e),()=>r.delete(e)},snapshot:()=>t,_cloneSignalDeclaration:()=>d(t)}}function y(e){return"function"==typeof e?._cloneSignalDeclaration?e._cloneSignalDeclaration():g(e)?d("function"==typeof e.snapshot?e.snapshot():e.value):d(e)}function g(e){return Boolean(e&&"object"==typeof e&&"function"==typeof e.subscribe)}function w(e,t){let r=e;for(const e of t){if(null==r)return;r=r[e]}return r}function m(e,t,r){const n=b(e,t[0]);let o=n;for(let e=0;e<t.length-1;e+=1){const r=t[e],n=t[e+1];o[r]=b(o[r],n),o=o[r]}return o[t.at(-1)]=r,n}function b(e,t){return Array.isArray(e)?[...e]:e&&"object"==typeof e?{...e}:(r=t,String(Number(r))===String(r)?[]:{});var r}function v(e,t){const r=e.get(t);if(!r)throw new Error(`Signal "${t}" is not registered.`);return r}function S(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal id must be a non-empty string.")}return{createSignal:d,computed:function e(t){if("function"!=typeof t)throw new TypeError("computed(fn) requires a function.");const r=d(void 0);return{[l]:!0,kind:"computed",get value(){return r.value},set:e=>r.set(e),update:e=>r.update(e),subscribe:e=>r.subscribe(e),snapshot:()=>r.snapshot(),_cloneSignalDeclaration:()=>e(t),_bindRegistry:(e,n)=>e.effect(()=>{r.set(t.call({signals:e,id:n,server:e._context?.().server,router:e._context?.().router,loader:e._context?.().loader,cache:e._context?.().cache,scheduler:e._context?.().scheduler}))})}},effect:function e(t){if("function"!=typeof t)throw new TypeError("effect(fn) requires a function.");return{[f]:!0,kind:"effect",fn:t,_cloneSignalDeclaration:()=>e(t),_bindRegistry:e=>e.effect(t)}},createSignalRegistry:function(e={},t={}){const r=t.registry??a(),u=t.type??"signal",l=r._map(u),f=r._map("asyncSignal"),b=t.lazyRegistry??i(t),E=new Map,$={},j=new Set;let A=0,O=0;for(const e of l.keys())if(f.has(e))throw new Error(`Signal "${e}" is already registered.`);const R=s({register(e,t){if(S(e),l.has(e)||f.has(e))throw new Error(`Signal "${e}" is already registered.`);const r=(e=>g(e)?e:d(e))(t);return l.set(e,r),_(e,r),R.ref(e)},registerMany(e){for(const[t,r]of Object.entries(e??{}))R.register(t,r);return R},unregister(e){S(e);const t=l.has(e),r=f.has(e);return!(!t&&!r||(t&&(E.get(e)?.(),E.delete(e),l.get(e)?._dispose?.(),l.delete(e),j.delete(e)),f.delete(e),0))},ensure:(e,t)=>(S(e),T(e),l.has(e)||R.register(e,d(t)),R.ref(e)),has:e=>l.has(e)||f.has(e),get(e){const t=k(e);return(e=>{const t=h.at(-1);t&&t.add(e)})(t.path),((e,t)=>{if(o(e)&&t[0]?.startsWith("$")){const r=((e,t)=>{switch(t){case"$value":return e.value;case"$loading":return e.loading;case"$error":return e.error;case"$status":return e.status;case"$version":return e.version;default:return}})(e,t[0]);return w(r,t.slice(1))}return w(e.value,t)})(v(l,t.id),t.parts)},set(e,t){const r=k(e),n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},update(e,t){if("function"!=typeof t)throw new TypeError("update(path, fn) requires a function.");return R.set(e,t(R.get(e)))},ref:e=>(S(e),T(e),((e,t)=>({[p]:!0,kind:"signal-ref",id:t,get value(){return e.get(t)},set value(r){e.set(t,r)},get loading(){return e._entry(t).loading??!1},get error(){return e._entry(t).error??null},get status(){return e._entry(t).status??"ready"},get version(){return e._entry(t).version??0},get:()=>e.get(t),set:r=>e.set(t,r),update:r=>e.update(t,r),subscribe:r=>e.subscribe(t,r),refresh(){const r=e._entry(t);if("function"!=typeof r.refresh)throw new Error(`Signal "${t}" cannot refresh.`);return r.refresh()},cancel(r){const n=e._entry(t);if("function"!=typeof n.cancel)throw new Error(`Signal "${t}" cannot cancel.`);return n.cancel(r)},toString:()=>t,[Symbol.toPrimitive]:()=>t}))(R,e)),subscribe(e,t,r={}){if("function"!=typeof t)throw new TypeError("subscribe(path, fn) requires a function.");const n=k(e),o=v(l,n.id),s=++A;return o.subscribe(()=>{((e,t={})=>{const r=t.scheduler;if(!r||"sync"===t.phase)return e();r.enqueue(t.phase??"effect",e,{scope:t.scope,key:t.key})})(()=>t(R.get(n.path),{id:n.id,path:n.path,signal:o}),{...r,key:r.key??`signal:${n.path}:${s}`})})},snapshot(){const e={};for(const[t,r]of l)e[t]="function"==typeof r.snapshot?r.snapshot():r.value;return e},asyncSignal:(e,t)=>(R.register(e,n(e,t)),R.ref(e)),effect(e,t={}){let r,n=[],o=!1;const s=t.scheduler,a=++O,i=()=>{if(o)return;"function"==typeof r&&r();for(const e of n)e();n=[];const t=R._collectDependencies(()=>e.call({signals:R,server:$.server,router:$.router,loader:$.loader,cache:$.cache,scheduler:$.scheduler}));r=t.value,n=t.dependencies.map(e=>R.subscribe(e,c))},c=()=>{s?s.enqueue(t.phase??"effect",i,{scope:t.scope,key:t.key??`effect:${a}`}):i()};return i(),()=>{o=!0,"function"==typeof r&&r();for(const e of n)e()}},destroy(){for(const e of E.values())e();E.clear();for(const e of l.values())e._dispose?.();l.clear()},_collectDependencies(e){const t=new Set;h.push(t);try{return{value:e(),dependencies:[...t]}}finally{h.pop()}},_entry:e=>(T(e),v(l,e)),_setPath(e,t){const r=(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const[t,...r]=e.split(".");return{id:t,parts:r,path:e}})(e);l.has(r.id)||(f.has(r.id)?T(r.id):R.register(r.id,d(0===r.parts.length?t:{})));const n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},_setContext:(e={})=>(Object.assign($,e),R),_context:()=>$,_adoptMany(e={}){for(const[t,r]of Object.entries(e??{})){if(!l.has(t)){if(f.has(t))throw new Error(`Signal "${t}" is already registered.`);const e=y(r);l.set(t,e),_(t,e);continue}_(t,l.get(t))}return R}},r,u);for(const[e,t]of l)_(e,t);return R.registerMany(e),R;function _(e,t){if(j.has(e)||"function"!=typeof t?._bindRegistry)return;j.add(e);const r=t._bindRegistry(R,e);"function"==typeof r&&E.set(e,r)}function k(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const t=e.split(".");for(let r=t.length;r>0;r-=1){const n=t.slice(0,r).join(".");if(l.has(n)||f.has(n))return T(n),{id:n,parts:t.slice(r),path:e}}const[r,...n]=t;return{id:r,parts:n,path:e}}function T(e){if(l.has(e)||!f.has(e))return;const t=f.get(e);if(!c(t)&&"function"!=typeof t)throw new TypeError(`Async signal "${e}" must be a function or lazy descriptor.`);const r=n(e,async function(...r){const n=await b.resolve("asyncSignal",e,t);if("function"!=typeof n)throw new TypeError(`Async signal "${e}" did not resolve to a function.`);return n.apply(this,r)});l.set(e,r),_(e,r)}},cloneSignalDeclaration:y,isSignalRef:e=>Boolean(e?.[p]),signal:d}})(),a=(()=>{const{isSignalRef:e}=s,{attributeName:t,matchAttribute:r,normalizeAttributeConfig:n}=o,a=Symbol.for("@async/framework.template"),i=Symbol.for("@async/framework.rawHtml");function c(e){return Boolean(e?.[a])}function u(e,t={}){if(c(e)){const r=p(t);let n="";for(let t=0;t<e.strings.length;t+=1)n+=e.strings[t],t<e.values.length&&(n+=l(e.values[t],{...r,attribute:h(e.strings[t])}));return n}return l(e,p(t))}function l(n,o=p()){return n?.[i]?n.html:c(n)?u(n,o):o.attribute?((n,o)=>{const s=r(o.attribute.name,o.attributes,"signal"),a=r(o.attribute.name,o.attributes,"class"),i=((t,r)=>e(t)?t.id:"string"==typeof t&&r.signals?.has?.(t)?t:null)(n,o);if("value"===o.attribute.name&&i){const r=((t,r)=>e(t)?t.value:"string"==typeof t&&r.signals?.has?.(t)?r.signals.get(t):t)(n,o),s=t(o.attributes,"signal","value");return`${d(r)}${o.attribute.quote} ${s}=${o.attribute.quote}${d(i)}`}if(null!=s||null!=a){if(i)return d(i);if((e=>Boolean(e&&"object"==typeof e))(n))return d(((e,t)=>"function"!=typeof t.bind?e:t.bind(e))(n,o))}return f(n,o)})(n,o):Array.isArray(n)?n.map(e=>l(e,o)).join(""):e(n)?d(n.value):null==n||!1===n?"":d(n)}function f(t,r){return Array.isArray(t)?t.map(e=>f(e,r)).join(""):e(t)?d(t.value):null==t||!1===t?"":d(t)}function p(e={}){return{...e,attributes:n(e.attributes)}}function h(e){const t=e.match(/(?:^|[\s<])([^\s"'=<>`]+)\s*=\s*(["'])$/);return t?{name:t[1],quote:t[2]}:null}function d(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}return{html:(e,...t)=>({[a]:!0,strings:e,values:t}),isTemplateResult:c,rawHtml:e=>({[i]:!0,html:String(e??"")}),renderTemplate:u,escapeHtml:d}})(),i=(()=>{const{attributeName:e}=o,{escapeHtml:n,rawHtml:s,renderTemplate:i}=a,{attachRegistryInspection:c,createRegistryStore:u}=r,{createLazyRegistry:l,isLazyDescriptor:f}=t,p=Symbol.for("@async/framework.component");let h=0;function d(e){if("function"!=typeof e)throw new TypeError("defineComponent(fn) requires a function.");return Object.defineProperty(e,p,{configurable:!0,value:!0}),e}function y(e){return Boolean(e?.[p])}function g(e,t){if("string"!=typeof t||0===t.length)throw new TypeError("Scoped signal or handler name must be a non-empty string.");return`${e}.${t}`}function w(e){return e.displayName||e.name||"anonymous"}return{defineComponent:d,createComponentRegistry:function(e={},t={}){const r=t.registry??u(),n=t.type??"component",o=r._map(n),s=t.lazyRegistry??l(t),a=new Map,i=c({register(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");if(!y(t)&&"function"!=typeof t&&!f(t))throw new TypeError(`Component "${e}" must be a component function.`);if(o.has(e))throw new Error(`Component "${e}" is already registered.`);return o.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))i.register(t,r);return i},unregister(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");return a.delete(e),o.delete(e)},resolve(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");const t=o.get(e);return f(t)?(a.has(e)||a.set(e,async function(...r){const o=await s.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Component "${e}" did not resolve to a function.`);return o.apply(this,r)}),a.get(e)):t},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)||i.register(t,r);return i}},r,n);return i.registerMany(e),i},isComponent:y,renderComponent:function t(r,o={},a,c="component"){if(!y(r)&&"function"!=typeof r)throw new TypeError("renderComponent(Component) requires a component function.");const u=`${c}.${w(r)}.${++h}`,l=[],f=[],p=[],d=[],m=[],b={attributes:a.attributes,signals:a.signals,bind(e){const t=a.loader?._registerBinding?.(e);if(!t)throw new Error("Inline template bindings require a Loader.");return m.push(t),t}},v=e=>i(e,b),S=(({runtime:r,scope:o,cleanups:a,attachHooks:i,visibleHooks:c,destroyHooks:u,renderScopedTemplate:l})=>{const{signals:f,handlers:p,loader:h,server:d,router:y,cache:w,scheduler:m}=r,b=new WeakMap;let v=0,S=0;const E={scope:o,signals:f,handlers:p,loader:h,server:d,router:y,cache:w,scheduler:m,signal(e,t){if(1===arguments.length){const t=g(o,"signal."+ ++S),r=f.ensure(t,e);return a.push(()=>f.unregister?.(t)),r}const r=g(o,e),n=!f.has(r),s=f.ensure(r,t);return n&&a.push(()=>f.unregister?.(r)),s},computed(e,t){const r=g(o,e),n=!f.has(r),s=f.ensure(r,void 0);n&&a.push(()=>f.unregister?.(r));const i=f.effect(()=>{f.set(r,t.call(E))});return a.push(i),s},asyncSignal(e,t){const r=g(o,e),n=!f.has(r);return f.has(r)||f.asyncSignal(r,t),n&&a.push(()=>f.unregister?.(r)),f.ref(r)},effect(e){const t=f.effect(()=>e.call(E),{scheduler:m,phase:"effect",scope:o});return a.push(t),t},handler(e,t){if("function"==typeof e&&void 0===t){const t=e;if(b.has(t))return b.get(t);const r=$("handler."+ ++v,t);return b.set(t,r),r}if("function"!=typeof t)throw new TypeError("this.handler(name, fn) or this.handler(fn) requires a function.");return $(e,t)},render(e,n={}){const u=t(e,n,r,o);return a.push(u.cleanup),i.push(e=>u.attach(e)),c.push(e=>u.visible(e,h._observeVisible)),s(u.html)},suspense(t,o){const a=t?.id;if(!a)throw new TypeError("this.suspense(signalRef, views) requires a signal ref.");const i=(e=>{const t="function"==typeof e?{ready:e}:e;if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("this.suspense(signalRef, views) requires views to be a function or object.");for(const e of["loading","ready","error"])if(Object.hasOwn(t,e)&&void 0!==t[e]&&"function"!=typeof t[e])throw new TypeError(`this.suspense(signalRef, views) view "${e}" must be a function.`);return t})(o),c=[];for(const o of["loading","ready","error"]){const s=i[o];if(!s)continue;const u=e(r.attributes,"async",o),f=l(s.call(E,t));c.push(`<template ${u}="${n(a)}">${f}</template>`)}return s(c.join(""))},on(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component lifecycle event must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Component lifecycle "${e}" requires a function.`);const r="mount"===e?"attach":e;if("attach"!==r)if("visible"!==r){if("destroy"!==r)throw new Error(`Unsupported component lifecycle event "${e}".`);u.push(()=>t.call(E))}else c.push(e=>t.call(E,e));else i.push(e=>t.call(E,e))},onMount(e){E.on("attach",e)},onVisible(e){E.on("visible",e)}};return E;function $(e,t){const r=g(o,e);return p.register(r,e=>t.call({...E,...e},e)),a.push(()=>p.unregister?.(r)),r}})({runtime:a,scope:u,cleanups:l,attachHooks:f,visibleHooks:p,destroyHooks:d,renderScopedTemplate:v}),E=r.call(S,o);if(E&&"function"==typeof E.then)throw new TypeError(`Component "${w(r)}" returned a Promise. Async components are not supported by synchronous renderComponent(). Use an async partial or handler instead.`);return{html:v(E),attach(e){for(let t=0;t<f.length;t+=1){const r=f[t];a.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&l.push(t)},{scope:u,key:`attach:${t}`})??$(r,e)}},mount(e){this.attach(e)},visible(e,t){if(0===p.length)return;const r=t(e,()=>{for(let t=0;t<p.length;t+=1){const r=p[t];a.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&l.push(t)},{scope:u,key:`visible:${t}`})??j(r,e)}});"function"==typeof r&&l.push(r)},cleanup(){for(;d.length>0;)d.pop()?.();for(a.scheduler?.markScopeDestroyed(u);l.length>0;)l.pop()?.();for(;m.length>0;)a.loader?._releaseBinding?.(m.pop())}};function $(e,t){const r=e(t);"function"==typeof r&&l.push(r)}function j(e,t){const r=e(t);"function"==typeof r&&l.push(r)}},component:d}})(),c=(()=>{const e=Symbol.for("@async/framework.serverResult"),t=Symbol("@async/framework.serverResultInvocation");async function r(e,r={}){if(!d(e))return e;const n=((e={})=>e[t]??{applied:new WeakSet})(r);if(n.applied.has(e))return e;if(n.applied.add(e),e.error)throw(o=e.error)instanceof Error?o:o&&"object"==typeof o&&"string"==typeof o.message?Object.assign(new Error(o.message),o):new Error(String(o));var o;if(e.signals&&r.signals)for(const[t,n]of Object.entries(e.signals))r.signals.set?.(t,n);return e.cache?.browser&&r.cache?.restore&&r.cache.restore(e.cache.browser),e.boundary&&Object.hasOwn(e,"html")&&r.loader?.swap?.(e.boundary,e.html),e.redirect&&await(r.router?.navigate?.(e.redirect)),e}async function n(e,t={}){return await r(e,t),o(e)}function o(e){return d(e)?Object.hasOwn(e,"value")?e.value:void 0:e}function s(e={}){const r=e[t]??{applied:new WeakSet};return{...e,[t]:r}}function a(e={}){const t=f(e);if(t)return p(new t.ownerDocument.defaultView.FormData(t));const r=e.element??e.el??e.event?.target;return r?{value:"value"in r?r.value:void 0,checked:"checked"in r?r.checked:void 0,dataset:r.dataset?{...r.dataset}:{}}:{}}function i(e,t={},r=()=>({})){const n=new Map;return function o(s){const a=s.join(".");if(n.has(a))return n.get(a);const c=new Proxy(async(...t)=>{if(0===s.length)throw new Error("Server namespace is not directly callable.");const n=r()??{};return e(s.join("."),t,n)},{get(n,a){if("then"!==a)return a in n?n[a]:0===s.length&&"_withContext"===a?(n={})=>i(e,t,()=>({...r()??{},...n})):0===s.length&&"run"===a&&"function"==typeof t.run?(e,n=[],o={})=>t.run(e,n,{...r()??{},...o}):0===s.length&&Object.hasOwn(t,a)?t[a]:a===Symbol.toStringTag?"AsyncServerNamespace":"toString"===a?()=>0===s.length?"server":`server.${s.join(".")}`:o([...s,String(a)])}});return n.set(a,c),c}([])}function c(e=[],t){const r={};for(const n of e)r[n]=u(t,n);return r}function u(e,t){if(!e||"function"!=typeof e.get)throw new Error(`Signal "${t}" cannot be read without a signal registry.`);return e.get(t)}function l(e,t,{forServer:r}={}){if(("$event"===e||"$el"===e)&&r)throw new Error(`${e} cannot be passed to a server command.`);if("$event"===e)return t.event;if("$el"===e)return t.element??t.el;if("$value"===e){const e=t.element??t.el??t.event?.target;return e?.value}if("$checked"===e){const e=t.element??t.el??t.event?.target;return e?.checked}if("$form"===e){const e=f(t);return e?p(new e.ownerDocument.defaultView.FormData(e)):{}}if("$dataset"===e){const e=t.element??t.el??t.event?.target;return e?.dataset?{...e.dataset}:{}}throw new Error(`Event local "${e}" is not supported.`)}function f(e){const t=e.event,r=e.element??e.el??t?.target;return"FORM"===r?.tagName?r:"submit"===t?.type&&"FORM"===t.target?.tagName?t.target:"submit"===t?.type&&r?.form?r.form:null}function p(e){const t={};for(const[r,n]of e.entries())Object.hasOwn(t,r)?t[r]=Array.isArray(t[r])?[...t[r],n]:[t[r],n]:t[r]=n;return t}function h(e,t=new Set){if("bigint"==typeof e)throw new Error("Server proxy JSON transport does not support BigInt values.");if(null==e||"object"!=typeof e)return;if(t.has(e))throw new Error("Server proxy JSON transport does not support circular values.");t.add(e);const r=Object.prototype.toString.call(e);if("[object File]"===r||"[object Blob]"===r||"[object FormData]"===r)throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");if(((e,t=Object.prototype.toString.call(e))=>"[object URLSearchParams]"===t||"[object Headers]"===t||"[object Request]"===t||"[object Response]"===t||"[object ReadableStream]"===t||"[object ArrayBuffer]"===t||ArrayBuffer.isView(e))(e,r))throw new Error("Server proxy JSON transport does not support URLSearchParams, Headers, Request, Response, ReadableStream, ArrayBuffer, or typed array values yet.");if(Array.isArray(e)){for(const r of e)h(r,t);t.delete(e)}else{for(const r of Object.values(e))h(r,t);t.delete(e)}}function d(t){return!(!t||"object"!=typeof t||Array.isArray(t)||!0!==t[e]&&1!==t.__async_server_result__)}function y(e){if("string"!=typeof e||0===e.length)throw new TypeError("Server function id must be a non-empty string.")}return{createServerProxy:({endpoint:e="/__async/server",transport:t,signals:r,loader:o,router:u,cache:l,scheduler:f,headers:p={}}={})=>{if("function"!=typeof t)throw new TypeError("createServerProxy(...) requires a transport function.");const d={signals:r,loader:o,router:u,cache:l,scheduler:f};async function g(r,o=[],i={}){y(r);const u=s({...d,...i}),l={args:o,input:i.input??a(u),signals:i.signalValues??c(i.signalPaths,u.signals)};h(l);const f=await t(((e,t)=>`${String(e).replace(/\/$/,"")}/${encodeURIComponent(t)}`)(e,r),{method:"POST",headers:{"content-type":"application/json",...p},body:JSON.stringify(l),signal:i.abort});if(((e,t)=>{if(!t||"object"!=typeof t)throw new Error(`Server function "${e}" transport returned an invalid response: expected a fetch Response-like object.`);if("boolean"!=typeof t.ok)throw new Error(`Server function "${e}" transport returned an invalid response: missing boolean ok.`);if(!t.headers||"function"!=typeof t.headers.get)throw new Error(`Server function "${e}" transport returned an invalid response: missing headers.get(name).`)})(r,f),!f.ok)throw new Error(`Server function "${r}" failed with ${f.status}.`);return n(await(async(e,t)=>{if(204===t.status)return;if((t.headers.get("content-type")??"").includes("application/json")){if("function"!=typeof t.json)throw new Error(`Server function "${e}" transport returned an invalid response: missing json().`);try{return await t.json()}catch(t){throw new Error(`Server function "${e}" returned invalid JSON: ${r=t,r instanceof Error?r.message:String(r)}`,{cause:t})}}var r;if("function"!=typeof t.text)throw new Error(`Server function "${e}" transport returned an invalid response: missing text().`);return t.text()})(r,f),u)}return i(g,{run:g,_setContext(e={}){Object.assign(d,e)}},()=>d)},resolveServerCommandArguments:(e,t={})=>{const r=[],n={},o=[];for(const s of e){if("local"===s.type){r.push(l(s.name,t,{forServer:!0}));continue}const e=u(t.signals,s.path);r.push(e),n[s.path]=e,o.push(s.path)}return{args:r,signalValues:n,signalPaths:o}},applyServerResult:r,consumeServerResult:n,unwrapServerResult:o,createServerResultContext:s,defaultInput:a,createServerNamespace:i,createSignalReader:e=>e&&"function"!=typeof e.get?{get:t=>((e,t)=>String(t).split(".").reduce((e,t)=>e?.[t],e))(e,t),snapshot:()=>({...e})}:e,assertServerId:y}})(),u=(()=>{const{defaultInput:e,resolveServerCommandArguments:n}=c,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:a,isLazyDescriptor:i}=t,u=new Set(["prevent","preventDefault","stopPropagation","stopImmediatePropagation"]),l={prevent:f,preventDefault:f,stopPropagation(){this.event?.stopPropagation?.()},stopImmediatePropagation(){this.event?.stopImmediatePropagation?.()}};function f(){this.event?.preventDefault?.()}function p(e){if("string"!=typeof e||0===e.trim().length)throw new TypeError("Handler ref must be a non-empty string.");return e.split(";").map(e=>e.trim()).filter(Boolean).map(d)}function h(e){if("string"!=typeof e||0===e.length)throw new TypeError("Handler id must be a non-empty string.")}function d(e){if(e.startsWith("server."))return(e=>{const t=e.indexOf("(");if(-1===t||!e.endsWith(")"))throw new Error(`Server command "${e}" must be called with parentheses.`);const r=e.slice(7,t).trim();if(!(e=>/^[^.\s();]+(?:\.[^.\s();]+)*$/.test(e))(r))throw new Error(`Server command "${e}" has an invalid function id.`);return{type:"server",id:r,args:(n=e.slice(t+1,-1),0===n.trim().length?[]:n.split(",").map(e=>e.trim()).filter(Boolean).map(y))};var n})(e);if(e.includes("(")||e.includes(")"))throw new Error(`Command "${e}" is not supported.`);return{type:"handler",id:e}}function y(e){if(!/^[^\s,();]+$/.test(e))throw new Error(`Argument "${e}" is not supported.`);return e.startsWith("$")?{type:"local",name:e}:{type:"signal",path:e}}return{createHandlerRegistry:function(t={},r={}){const c=r.registry??s(),f=r.type??"handler",d=c._map(f),y=r.lazyRegistry??a(r),g=new Map,w=o({register(e,t){if(h(e),"function"!=typeof t&&!i(t))throw new TypeError(`Handler "${e}" must be a function.`);if(d.has(e))throw new Error(`Handler "${e}" is already registered.`);return d.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))w.register(t,r);return w},unregister:e=>(h(e),g.delete(e),d.delete(e)),resolve(e){h(e);const t=d.get(e);return i(t)?(g.has(e)||g.set(e,async function(...r){const n=await y.resolve(f,e,t);if("function"!=typeof n)throw new TypeError(`Handler "${e}" did not resolve to a function.`);return n.apply(this,r)}),g.get(e)):t},async run(t,r={}){const o=p(t),s=[];let a=!1;const i={...r,handlers:w,input:r.input??e(r),stop(){a=!0}};for(const e of o){if(a)break;if("server"===e.type){if(!i.server||"function"!=typeof i.server.run)throw new Error(`Server command "${e.id}" cannot run without a server registry.`);const t=n(e.args,i),r=await i.server.run(e.id,t.args,{...i,signalPaths:t.signalPaths,signalValues:t.signalValues});s.push(r);continue}const t=w.resolve(e.id);if(!t)throw new Error(`Handler "${e.id}" is not registered.`);const r=await t.call(i,i);u.has(e.id)&&t===l[e.id]||s.push(r)}return s},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))d.has(t)||w.register(t,r);return w}},c,f);return((e,t)=>{for(const[r,n]of Object.entries(l))if(t.has(r)){if(t.get(r)!==n)throw new Error(`Handler "${r}" is already registered.`)}else e.register(r,n)})(w,d),w.registerMany(t),w},parseHandlerRef:p,isHandlerToken:e=>u.has(e)}})(),l=(()=>{const e=["binding","lifecycle","effect","async","post"];function t(e){return"object"==typeof e&&null!==e||"function"==typeof e}function r(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)return e;try{Object.defineProperty(e,"scheduler",{configurable:!0,value:{phase:t.phase,scope:t.scope,key:t.key}})}catch{}return e}function n(){}return{createScheduler:(o={})=>{const s=[...o.phases??e],a=new Map(s.map(e=>[e,[]])),i=new Map,c=new WeakSet,u=new Set,l=new WeakMap,f="function"==typeof o.onError?o.onError:void 0,p=o.maxDepth??100,h=o.strategy??"microtask";let d=!1,y=!1,g=!1,w=0,m=0,b=0;const v={strategy:h,phases:s,batch(e){if("function"!=typeof e)throw new TypeError("scheduler.batch(fn) requires a function.");O(),w+=1;let t=!1;try{const r=e();return r&&"function"==typeof r.then?(t=!0,Promise.resolve(r).finally(()=>{w-=1,S()})):r}finally{!t&&w>0&&(w-=1,S())}},enqueue(e,t,r={}){if(O(),(e=>{if(!a.has(e))throw new Error(`Unknown scheduler phase "${e}".`)})(e),"function"!=typeof t)throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");const o=r.scope;if(R(o))return n;const s=void 0===r.key?void 0:`${e}:${(e=>void 0===e?"global":"object"==typeof e&&null!==e||"function"==typeof e?(l.has(e)||l.set(e,"scope:"+ ++b),l.get(e)):String(e))(o)}:${String(r.key)}`;if(s&&i.has(s))return i.get(s).cancel;const c={id:++m,phase:e,fn:t,scope:o,boundary:r.boundary,key:s,canceled:!1,cancel(){c.canceled=!0,c.key&&i.delete(c.key)}};return a.get(e).push(c),c.key&&i.set(c.key,c),S(),c.cancel},afterFlush:(e,t={})=>v.enqueue("post",e,t),async flush(){if(O(),y)return;g=!1,y=!0;let e=0;try{for(;j();){if(e+=1,e>p)throw new Error(`Scheduler exceeded maxDepth ${p}.`);for(const e of s)await E(e)}}finally{y=!1,j()&&S()}},async flushScope(e){if(O(),y)return;g=!1,y=!0;let t=0;try{for(;A(e);){if(t+=1,t>p)throw new Error(`Scheduler exceeded maxDepth ${p}.`);for(const t of s)await E(t,e)}}finally{y=!1,j()&&S()}},cancelScope(e){if(void 0===e)return v;for(const t of a.values())for(const r of t)r.scope===e&&r.cancel();return v},markScopeDestroyed:e=>(void 0!==e&&(t(e)?c.add(e):u.add(e),v.cancelScope(e)),v),reviveScope:e=>(void 0!==e&&(t(e)?c.delete(e):u.delete(e)),v),isScopeDestroyed:e=>R(e),inspect(){const e={};for(const[t,r]of a)e[t]=r.filter(e=>!e.canceled).length;return{strategy:h,phases:[...s],pending:e,scopesDestroyed:u.size,flushing:y,scheduled:g}},destroy(){d=!0;for(const e of a.values()){for(const t of e)t.cancel();e.length=0}i.clear(),u.clear()}};return v;function S(){var e;"manual"===h||d||y||w>0||g||(g=!0,e=()=>{d||v.flush().catch($)},"function"!=typeof queueMicrotask?Promise.resolve().then(e):queueMicrotask(e))}async function E(e,t){const n=a.get(e),o=[],s=[];for(const e of n.splice(0))e.canceled||(void 0===t||e.scope===t?s.push(e):o.push(e));n.push(...o);for(const e of s)if(e.key&&i.delete(e.key),!e.canceled&&!R(e.scope))try{await e.fn()}catch(t){if(!f)throw r(t,e);f(t,e)}}function $(e){"function"!=typeof globalThis.reportError?setTimeout(()=>{throw e},0):globalThis.reportError(e)}function j(){for(const e of a.values())if(e.some(e=>!e.canceled))return!0;return!1}function A(e){for(const t of a.values())if(t.some(t=>!t.canceled&&t.scope===e))return!0;return!1}function O(){if(d)throw new Error("Scheduler has been destroyed.")}function R(e){return void 0!==e&&(t(e)?c.has(e):u.has(e))}}}})(),f=(()=>{const{renderComponent:e}=i,{createHandlerRegistry:t}=u,{createScheduler:r}=l,{createSignalRegistry:n,isSignalRef:a}=s,{matchAttribute:c,normalizeAttributeConfig:f,readAttribute:p}=o,h="__async:inline:";function d({root:o,signals:s,handlers:i,server:u,router:l,cache:d,attributes:E,scheduler:R}={}){const T=o?.ownerDocument??o??globalThis.document,q=o??T,C=s??n(),M=i??t(),x=R??r(),D=!R,L=f(E),B=new Set,P=new WeakMap,N=new WeakMap,z=new WeakSet,H=new WeakSet,W=new WeakMap,U=new WeakSet,V=new Map,I=new WeakMap;let F=0,J=!1;const K={root:q,signals:C,handlers:M,server:u,router:l,cache:d,scheduler:x,attributes:L,start:()=>(ne(),K.scan(q),K),scan:(e=q)=>(ne(),(e=>{for(const t of A(e))x.reviveScope?.(t)})(e),(e=>{for(const t of A(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,L,"signal");if(r){if("text"===r){const r=t.getAttribute(e);G(t,`text:${r}`,r,e=>{t.textContent=e??""});continue}if("value"===r){const r=t.getAttribute(e);G(t,`value:${r}`,r,e=>{"value"in t&&t.value!==String(e??"")?t.value=e??"":"value"in t||t.setAttribute("value",e??"")}),Q(t,r);continue}if(r.startsWith("attr:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`attr:${n}:${o}`,o,e=>$(t,n,e));continue}if(r.startsWith("prop:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`prop:${n}:${o}`,o,e=>j(t,n,e));continue}if(r.startsWith("class:")){const n=r.slice(6),o=t.getAttribute(e);""===n||"{}"===n?Y(t,n,o):G(t,`class:${n}:${o}`,o,e=>{t.classList.toggle(n,Boolean(e))});continue}if("class"===r){const r=t.getAttribute(e);Y(t,"{}",r)}}}})(e),(e=>{for(const t of A(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,L,"class");null!=r&&Y(t,r,t.getAttribute(e))}})(e),(e=>{for(const t of A(e))if("function"==typeof t.getAttributeNames)for(const e of t.getAttributeNames()){const r=c(e,L,"on");r&&"attach"!==r&&"mount"!==r&&"visible"!==r&&Z(t,r,t.getAttribute(e))}})(e),(e=>{for(const t of A(e)){if(U.has(t))continue;const e=O(t,L);if(null!=e){if(!W.has(t)){const r=S(t,e,L);if(0===Object.keys(r).length||!C.has(e))continue;const n={id:e,templates:r,cleanup:C.subscribe(`${e}.$status`,()=>{x.enqueue("binding",()=>X(t),{scope:t,key:`boundary:${e}`})})};W.set(t,n),oe(n.cleanup,t)}X(t)}}})(e),(e=>{for(const t of A(e)){const e=ee(t,["attach","mount"]);if(0!==e.length&&!z.has(t)){z.add(t);for(const r of e)ue(t,()=>te(t,r),`attach:${r}`)}}for(const t of A(e)){const e=p(t,L,"on","visible");null!=e&&(H.has(t)||(H.add(t),oe(re(t,()=>ue(t,()=>te(t,e),`visible:${e}`)),t)))}})(e),K),swap(e,t){ne();const r=((e,t,r)=>{for(const n of A(e))if(O(n,r)===String(t))return n;return null})(q,e,L);if(!r)throw new Error(`Boundary "${e}" was not found.`);return ae(r),r.replaceChildren(_(t,T)),K.scan(r),r},mount(t,r,n={}){ne();const o=e(r,n,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,attributes:L});return ae(t),t.replaceChildren(_(o.html,t.ownerDocument)),K.scan(t),o.mount(t),o.visible(t,K._observeVisible),oe(o.cleanup,t,"children"),o},destroy(){if(!J){J=!0,(e=>{for(const t of A(e))x.markScopeDestroyed(t)})(q);for(const e of[...B])se(e);B.clear(),D&&x.destroy()}},_observeVisible:(e,t)=>re(e,t),_registerBinding(e){const t=`${h}${++F}`;return V.set(t,e),t},_releaseBinding(e){V.delete(e)}};function Z(e,t,r){const n=`${t}:${r}`,o=P.get(e)??new Set;if(o.has(n))return;o.add(n),P.set(e,o);const s=async t=>{try{await x.batch(()=>M.run(r,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,event:t,element:e,el:e,root:q}))}catch(t){k(e,t)}};e.addEventListener(t,s),oe(()=>e.removeEventListener(t,s),e)}function Y(e,t,r){if(""===t||"{}"===t){const t=b(e);let n=new Set;return void G(e,`class:{}:${r}`,r,r=>{const o=y(r),s=b(e);for(const e of n)o.has(e)||t.has(e)||s.delete(e);for(const e of o)s.add(e);v(e,s),n=o},{rawInline:!0})}G(e,`class:${t}:${r}`,r,r=>{((e,t,r)=>{const n=b(e);for(const e of y(t))r?n.add(e):n.delete(e);v(e,n)})(e,t,Boolean(r))})}function G(e,t,r,n,o={}){const s=N.get(e)??new Set;if(s.has(t))return;s.add(t),N.set(e,s);const a=()=>((e,t={})=>{if(m(e)){const r=V.get(e);return t.rawInline?r:g(r)}return C.get(e)})(r,o);n(a()),oe(((e,t)=>{if(!m(e))return C.subscribe(e,t);const r=w(V.get(e)).map(e=>e.subscribe(t));return()=>{for(const e of r)e()}})(r,()=>{x.enqueue("binding",()=>n(a()),{scope:e,key:t})}),e)}function Q(e,t){Z(e,"input",`__async:set:${t}`),Z(e,"change",`__async:set:${t}`),M.resolve(`__async:set:${t}`)||M.register(`__async:set:${t}`,({element:e})=>{((e,t)=>{if(!m(e))return C.set(e,t);const r=V.get(e);if(a(r))return r.set(t);throw new Error(`Inline binding "${e}" is not writable.`)})(t,e.value)})}function X(e){const t=W.get(e);if(!t)return;const r=C.get(`${t.id}.$status`),n=((e,t)=>"ready"===t?e.ready??e.loading??e.error:"error"===t?e.error??e.ready??e.loading:e.loading??e.ready??e.error)(t.templates,r);if(n){ae(e),e.replaceChildren(n.content.cloneNode(!0)),U.add(e);try{K.scan(e)}finally{U.delete(e)}}}function ee(e,t){const r=[];for(const n of t){const t=p(e,L,"on",n);null!=t&&r.push(t)}return r}async function te(e,t){try{const r=await M.run(t,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,element:e,el:e,root:q});for(const t of r)"function"==typeof t&&oe(t,e)}catch(t){k(e,t)}}function re(e,t){const r=(e.ownerDocument?.defaultView??globalThis).IntersectionObserver??globalThis.IntersectionObserver;if(!r)return x.enqueue("lifecycle",()=>{J||t(e)},{scope:e,key:"visible:fallback"}),()=>{};const n=new r(r=>{r.some(e=>e.isIntersecting)&&(n.disconnect(),t(e))});return n.observe(e),()=>n.disconnect()}function ne(){if(J)throw new Error("Loader has been destroyed.")}function oe(e,t,r="self"){if("function"!=typeof e)return e;if(B.add(e),t){const n=I.get(t)??[];n.push({cleanup:e,mode:r}),I.set(t,n)}return e}function se(e){"function"==typeof e&&B.has(e)&&(B.delete(e),e())}function ae(e){ce(e,"children");for(const t of[...e.childNodes??[]])ie(t)}function ie(e){if(1===e.nodeType)for(const t of A(e))ce(t),x.markScopeDestroyed(t)}function ce(e,t){const r=I.get(e);if(!r)return;const n=[];for(const e of r)t&&e.mode!==t?n.push(e):se(e.cleanup);n.length>0?I.set(e,n):I.delete(e)}function ue(e,t,r){x.enqueue("lifecycle",t,{scope:e,key:r})}return C._setContext?.({server:K.server,router:K.router,loader:K,cache:K.cache,scheduler:x}),K.server?._setContext?.({signals:C,handlers:M,loader:K,router:K.router,cache:K.cache,scheduler:x}),K}function y(e,t=new Set){if(null==e||!1===e)return t;if(a(e)){const r=e.value;return!0===r?(t.add(e.id.split(".").at(-1)),t):y(r,t)}if("string"==typeof e){for(const r of e.split(/\s+/).filter(Boolean))t.add(r);return t}if(Array.isArray(e)){for(const r of e)y(r,t);return t}if("object"==typeof e){for(const[r,n]of Object.entries(e))(a(n)?n.value:n)&&y(r,t);return t}return!0!==e&&t.add(String(e)),t}function g(e){return a(e)?e.value:Array.isArray(e)?e.map(g):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,g(t)])):e}function w(e,t=new Map){if(a(e))return t.set(e.id,e),[...t.values()];if(Array.isArray(e)){for(const r of e)w(r,t);return[...t.values()]}if(e&&"object"==typeof e)for(const r of Object.values(e))w(r,t);return[...t.values()]}function m(e){return"string"==typeof e&&e.startsWith(h)}function b(e){return y(e.getAttribute("class")??"")}function v(e,t){const r=[...t].join(" ");0!==r.length?e.setAttribute("class",r):e.removeAttribute("class")}function S(e,t,r){const n={};for(const o of[...e.children].filter(e=>"TEMPLATE"===e.tagName))E(o,"loading",t,e,r)&&(n.loading=o),E(o,"ready",t,e,r)&&(n.ready=o),E(o,"error",t,e,r)&&(n.error=o);return n}function E(e,t,r,n,o){return p(e,o,"async",t)===r||R(n)&&e.hasAttribute?.(t)}function $(e,t,r){if(!1===r||null==r)return e.removeAttribute(t),void(t in e&&(e[t]=!1));e.setAttribute(t,!0===r?"":String(r)),t in e&&(e[t]=r)}function j(e,t,r){e[t]=null!=r?r:""}function A(e){return(e=>{const t=[];return 1===e?.nodeType&&e.matches?.("*")&&t.push(e),t.push(...e?.querySelectorAll?.("*")??[]),t})(e)}function O(e,t){return R(e)&&e.hasAttribute?.("for")?e.getAttribute("for"):p(e,t,"async","boundary")}function R(e){return"ASYNC-SUSPENSE"===e?.tagName}function _(e,t){if(11===e?.nodeType)return e;if("TEMPLATE"===e?.tagName)return e.content.cloneNode(!0);if(e?.nodeType){const r=t.createDocumentFragment();return r.append(e),r}const r=t.createElement("template");return r.innerHTML=String(e??""),r.content.cloneNode(!0)}function k(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;e.dispatchEvent(new r("async:error",{bubbles:!0,detail:{error:t}}))}return{Loader:d,AsyncLoader:d}})(),p=(()=>{const{isTemplateResult:e,renderTemplate:n}=a,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t;function u(e,t={}){return r=e,Boolean(r&&"object"==typeof r&&!Array.isArray(r)&&(Object.hasOwn(r,"html")||Object.hasOwn(r,"signals")||Object.hasOwn(r,"boundary")||Object.hasOwn(r,"redirect")||Object.hasOwn(r,"status")||Object.hasOwn(r,"cache")))?{...e,html:Object.hasOwn(e,"html")?l(e.html,t):e.html}:{html:l(e,t)};var r}function l(t,r){return t?.nodeType||"string"==typeof t?t:(e(t),n(t,function(e){return{attributes:e.loader?.attributes,signals:e.signals,bind:e.loader?._registerBinding?.bind(e.loader)}}(r)))}function f(e){if("string"!=typeof e||0===e.length)throw new TypeError("Partial id must be a non-empty string.")}return{createPartialRegistry:function(e={},t={}){const r=t.registry??s(),n=t.type??"partial",a=r._map(n),l=t.lazyRegistry??i(t),p=new Map,h=o({register(e,t){if(f(e),"function"!=typeof t&&!c(t))throw new TypeError(`Partial "${e}" must be a function.`);if(a.has(e))throw new Error(`Partial "${e}" is already registered.`);return a.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))h.register(t,r);return h},unregister:e=>(f(e),p.delete(e),a.delete(e)),resolve(e){f(e);const t=a.get(e);return c(t)?(p.has(e)||p.set(e,async function(...r){const o=await l.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Partial "${e}" did not resolve to a function.`);return o.apply(this,r)}),p.get(e)):t},async render(e,t={},r={}){f(e);const n=h.resolve(e);if(!n)throw new Error(`Partial "${e}" is not registered.`);const o={...r,id:e,props:t,cache:r.cache,partials:h};return u(await n.call(o,t),o)},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))a.has(t)||h.register(t,r);return h}},r,n);return h.registerMany(e),h},normalizePartialResult:u}})(),h=(()=>{const{Loader:e}=f,{createHandlerRegistry:t}=u,{createScheduler:n}=l,{createSignalRegistry:a}=s,{applyServerResult:i}=c,{createRegistryStore:p}=r,{normalizeAttributeConfig:h}=o;function d(e,t={}){return{...t,partial:e}}const y=d,g=new Set(["csr","spa","ssr","mpa"]);function w(e={},t={}){const r=t.registry??p(),n=t.type??"route",o=r._map(n),s=[],a={registry:r,register(e,t){if(j(e),s.some(t=>t.pattern===e))throw new Error(`Route "${e}" is already registered.`);const r=m(e,t);return o.set(e,r.definition),s.push(r),E(s),r},registerMany(e){for(const[t,r]of Object.entries(e??{}))a.register(t,r);return a},unregister(e){j(e);const t=s.findIndex(t=>t.pattern===e);return-1!==t&&s.splice(t,1),o.delete(e)},match(e){const t=(e=>e instanceof URL?e:new URL(String(e),globalThis.location?.href??"http://localhost/"))(e).pathname;for(const e of s){const r=e.regex.exec(t);if(!r)continue;const n={};return e.keys.forEach((e,t)=>{n[e]=S(r[t+1]??"")}),{pattern:e.pattern,params:n,route:e.definition}}return null},entries:()=>s.map(({pattern:e,definition:t})=>({pattern:e,route:t})),keys:()=>[...o.keys()],inspect:()=>r.entries(n),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)?i(t,o.get(t)):a.register(t,r);return a}};for(const[e,t]of o)i(e,t);return a.registerMany(e),a;function i(e,t){if(s.some(t=>t.pattern===e))return;const r=m(e,t);o.set(e,r.definition),s.push(r),E(s)}}function m(e,t){const r="string"==typeof t?d(t):t,{regex:n,keys:o}=(e=>{const t=[];if("*"===e)return{regex:/^.*$/,keys:t};if("/"===e)return{regex:/^\/$/,keys:t};const r=e.split("/").map(e=>e.startsWith(":")?(t.push(e.slice(1)),"([^/]+)"):String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return{regex:new RegExp(`^${r}$`),keys:t}})(e);return{pattern:e,regex:n,keys:o,score:$(e),definition:r}}function b(e,t){return e?.closest?.(t)}function v(e){return Object.fromEntries(e.searchParams.entries())}function S(e){try{return decodeURIComponent(e)}catch{return e}}function E(e){e.sort((e,t)=>t.score-e.score||t.pattern.length-e.pattern.length)}function $(e){return"*"===e?-1:e.split("/").filter(Boolean).reduce((e,t)=>"*"===t?e:t.startsWith(":")?e+2:e+4,"/"===e?3:0)}function j(e){if("string"!=typeof e||"*"!==e&&!e.startsWith("/"))throw new TypeError('Route pattern must be a path string or "*".')}return{defineRoute:d,createRouteRegistry:w,createRouter:({mode:r="ssr",root:o,boundary:s="route",routes:c=w(),loader:u,signals:l,handlers:f,server:p,cache:d,partials:y,attributes:m,scheduler:S}={})=>{(e=>{if(!g.has(e))throw new TypeError(`Unknown router mode "${e}".`)})(r);const E=o?.ownerDocument??o??globalThis.document,$=o??E,j=l??u?.signals??a(),A=f??u?.handlers??t(),O=S??u?.scheduler??n(),R=!S&&!u?.scheduler,_=h(m??u?.attributes),k=u??e({root:$,signals:j,handlers:A,server:p,cache:d,scheduler:O,attributes:_}),T=!u,q=new Set;let C,M=!1,x=0;const D={mode:r,root:$,boundary:s,routes:c,loader:k,signals:j,handlers:A,server:p,cache:d,partials:y,scheduler:O,attributes:_,start:()=>(I(),k.router=D,j._setContext?.({router:D,loader:k,server:p,cache:d,scheduler:O}),T&&k.start(),"mpa"===r||"ssr"===r?(N(),D):((()=>{const e=e=>{const t=b(e.target,"a[href]");t&&!((e,t)=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;if(t.target||t.hasAttribute("download"))return!0;const r=V(t.href),n=U();return r.origin!==n.origin||((e,t,r)=>e.origin===t.origin&&e.pathname===t.pathname&&e.search===t.search&&(e.hash!==t.hash||!0===r.getAttribute?.("href")?.startsWith("#")))(r,n,t)})(e,t)&&(e.preventDefault(),W(D.navigate(t.href)))},t=e=>{const t=b(e.target,"form");t&&!(e=>"get"!==String(e.method||"get").toLowerCase()||V(e.action).origin!==U().origin)(t)&&(e.preventDefault(),W(D.navigate((e=>{const t=V(e.action||e.ownerDocument.defaultView.location.href),r=new e.ownerDocument.defaultView.FormData(e);return t.search=new URLSearchParams(r).toString(),t.href})(t))))},r=()=>W(D.navigate(U(),{history:!1}));$.addEventListener?.("click",e),$.addEventListener?.("submit",t),E.defaultView?.addEventListener?.("popstate",r),q.add(()=>$.removeEventListener?.("click",e)),q.add(()=>$.removeEventListener?.("submit",t)),q.add(()=>E.defaultView?.removeEventListener?.("popstate",r))})(),"csr"===r?(W(D.navigate(U(),{replace:!0,initial:!0,source:"client"})),D):(N(),D))),match:e=>c.match(V(e)),prefetch(e){if(I(),"mpa"===r||"ssr"===r)return Promise.resolve(null);const t=D.match(e);return t?.route?.partial&&y?.resolve?.(t.route.partial)?y.render(t.route.partial,t.params,{...L(t),prefetch:!0}):Promise.resolve(null)},navigate:async(e,t={})=>(I(),"mpa"===r||"ssr"===r?(E.defaultView?.location?.assign?.(e),null):(async(e,t={})=>{const r=D.match(e);if(!r)return B(e,null),(e=>{z(e,null,{pending:!1,error:new Error(`No route matched ${e.pathname}${e.search}`)})})(e),null;const n=B(e,r);z(e,r,{pending:!0,error:null});try{if(!r.route?.partial||!y?.resolve?.(r.route.partial)){const t=new Error(`Route "${e.pathname}" does not have a registered partial.`);return P(n)&&H({pending:!1,error:t}),null}const o=await y.render(r.route.partial,r.params,L(r,n));return P(n)?(await(async(e,t,r,n)=>{P(n)&&(await i(e,{signals:j,loader:k,router:D,cache:d,scheduler:O,abort:n?.abort}),await O.flush(),P(n)&&(null==e?.html||e.boundary||e.redirect||(k.swap(s,e.html),await O.flush()),e?.redirect||!1===r.history||(r.replace?E.defaultView?.history?.replaceState?.({},"",t.href):E.defaultView?.history?.pushState?.({},"",t.href))))})(o,e,t,n),P(n)?(H({pending:!1,error:null}),o):null):null}catch(e){if(!P(n))return null;throw H({pending:!1,error:e}),e}})(V(e),t)),destroy(){if(!M){M=!0,C?.controller.abort(new Error("Router has been destroyed."));for(const e of q)e();q.clear(),R&&O.destroy()}}};return D;function L(e,t){return{params:e.params,route:e.route,router:D,signals:j,handlers:A,loader:k,server:p,cache:d,scheduler:O,abort:t?.abort}}function B(e,t){C?.controller.abort(new Error(`Router navigation superseded by ${e.pathname}${e.search}.`));const r=new AbortController,n={id:++x,controller:r,abort:r.signal,target:e,matched:t};return C=n,n}function P(e){return!M&&e&&C?.id===e.id&&!e.abort.aborted}function N(){const e=U();z(e,D.match(e),{pending:!1,error:null})}function z(e,t,r={}){j.ensure("router",{}),H({url:e.href,path:e.pathname,query:v(e),params:t?.params??{},route:t?.route??null,...r})}function H(e){j.ensure("router",{});for(const[t,r]of Object.entries(e))j.set(`router.${t}`,r)}function W(e){e.catch(e=>{M||(H({pending:!1,error:e}),((e,t)=>{const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;"function"==typeof r&&e.dispatchEvent?.(new r("async:error",{bubbles:!0,detail:{error:t}}))})($,e))})}function U(){return V(E.defaultView?.location?.href??"http://localhost/")}function V(e){return e instanceof URL?e:new URL(String(e),E.defaultView?.location?.href??"http://localhost/")}function I(){if(M)throw new Error("Router has been destroyed.")}},route:y}})(),d=(()=>{const{createCacheRegistry:e}=n,{createComponentRegistry:a}=i,{createHandlerRegistry:d}=u,{Loader:y}=f,{createPartialRegistry:g}=p,{createRouteRegistry:w,createRouter:m}=h,{createScheduler:b}=l,{createServerNamespace:v}=c,{cloneSignalDeclaration:S,createSignal:E,createSignalRegistry:$}=s,{createRegistryStore:j}=r,{attributeName:A,normalizeAttributeConfig:O}=o,{createLazyRegistry:R,defineRegistrySnapshot:_,sameRegistryValue:k}=t,T=new Set(["signal","handler","server","partial","route","component","asyncSignal"]);function q(e,t={}){const r=j(void 0,{target:"browser"}),n=new Set,o=t.createRuntime??C,s={registry:r,use(e,t){const o=((e,t)=>{const r={signal:{},handler:{},server:{},partial:{},route:{},component:{},asyncSignal:{},cache:{browser:{},server:{}}};if("string"==typeof e){if(!T.has(e))throw new Error(`Unknown Async registry type "${e}".`);return r[e]=F(e,t),r}if(!e||"object"!=typeof e)throw new TypeError("Async.use(...) requires a registry type or module object.");for(const[t,n]of Object.entries(e))if("cache"!==t){if(!T.has(t))throw new Error(`Unknown Async registry type "${t}".`);r[t]=F(t,n)}else r.cache.browser={...n?.browser??{}},r.cache.server={...n?.server??{}};return r})(e,t);((e,t)=>{for(const r of T)B(e,r,t[r]);B(e,"cache.browser",t.cache.browser),B(e,"cache.server",t.cache.server)})(r,o);for(const e of n)e._applyUse(o);return s},snapshot:()=>r.rawSnapshot(),start(e={}){const t=o(s,e).start();return s.runtime=t,t},attachRoot:e=>(e=>(e.runtime||e.start(),e.runtime))(s).attachRoot(e),detachRoot:e=>s.runtime?.detachRoot(e)??s,applySnapshot:(e,t={})=>s.runtime?(s.runtime.applySnapshot(e,t),s):(((e,t={},r={})=>{const n=z(t);for(const[t,o]of Object.entries(n.signal))N(e,"signal",t,E(o),r);for(const t of["handler","server","partial","route","component","asyncSignal"])for(const[o,s]of Object.entries(n[t]))N(e,t,o,s,r)})(r,e,t),s),inspectRoots:()=>s.runtime?.inspectRoots()??{count:0,roots:[]},_attach:e=>(n.add(e),()=>s._detach(e)),_detach(e){n.delete(e)}};return e&&s.use(e),s}function C(t=M,r={}){const n=(o=t,Boolean(o&&"function"==typeof o.use&&"function"==typeof o.snapshot&&o.registry)?t:q(t??{}));var o;const s=r.target??"browser",i=r.scheduler??r.loader?.scheduler??b({strategy:"server"===s?"manual":"microtask"}),c=!r.scheduler&&!r.loader?.scheduler,u=O(r.attributes),l=r.lazyRegistry??R({registryAssets:r.registryAssets,importModule:r.importModule}),f=r.registry??((e,{target:t}={})=>{const r=e.rawSnapshot();return j({...r,signal:L(r.signal)},{target:t})})(n.registry,{target:s}),p=r.signals??$(void 0,{registry:f,type:"signal",lazyRegistry:l}),h=r.handlers??d(void 0,{registry:f,type:"handler",lazyRegistry:l}),v=e(void 0,{registry:f,type:"cache.server"}),S=e(void 0,{registry:f,type:"cache.browser"}),E=r.serverFactory??I,A=r.server??E(void 0,{registry:f,type:"server"}),_=r.partials??g(void 0,{registry:f,type:"partial",lazyRegistry:l}),k=r.routes??w(void 0,{registry:f,type:"route"}),T=r.components??a(void 0,{registry:f,type:"component",lazyRegistry:l}),C=r.loader||Object.hasOwn(r,"root")?r.root:null;let B=r.loader,N=r.router,H=!1,W=()=>{},F=!1,J=!1;const Z=new Map,Y=C??globalThis.document,G=r.snapshot??("browser"===s?x(Y,{attributes:u}):void 0);((e,t)=>{try{e.cache=t}catch{}})(A,v);const Q={app:n,registry:f,target:s,signals:p,handlers:h,server:A,partials:_,routes:k,components:T,browser:{cache:S},loader:B,router:N,scheduler:i,attributes:u,start:()=>(ne(),F||(F=!0,"server"!==s?(te({cache:S}),p._setContext?.({server:A,loader:B,cache:S,scheduler:i}),B?(X(B.root,B),B.start(),ee(B.root)):null!=C&&Q.attachRoot(C)):(te({cache:v}),p._setContext?.({server:A,cache:v,scheduler:i}))),Q),use:(e,t)=>(n.use(e,t),Q),attachRoot(e){if(ne(),"server"===s)throw new Error("Server runtimes cannot attach DOM roots.");if(!e)throw new TypeError("runtime.attachRoot(root) requires a root.");if(Z.has(e))return Q;const t=0===Z.size&&B?B:y({root:e,signals:p,handlers:h,server:A,cache:S,scheduler:i,attributes:u});return X(e,t),t.start(),te({cache:S}),p._setContext?.({server:A,loader:Q.loader,cache:S,scheduler:i}),ee(e),Q},detachRoot(e){if(ne(),"server"===s)return Q;if(null==e){for(const e of new Set(Z.values()))e.destroy?.();return Z.clear(),N?.destroy?.(),N=void 0,H=!1,B=void 0,Q.loader=void 0,Q.router=void 0,Q}const t=Z.get(e);if(!t)return Q;if(t.destroy?.(),Z.delete(e),B===t){N?.destroy?.(),N=void 0,H=!1;const e=Z.values().next().value;B=e,Q.loader=e,Q.router=void 0,e&&ee(e.root)}return Q},inspectRoots:()=>({count:Z.size,roots:[...Z].map(([e,t])=>({root:e,loader:t,primary:t===B}))}),applySnapshot:(e,t={})=>(((e,t={},r={})=>{const n=z(t);P(e,"asyncSignal",n.asyncSignal,null,r);for(const[t,r]of Object.entries(n.signal))U(e.signals,t,r);e.browser.cache.restore(n.cache.browser),P(e,"handler",n.handler,e.handlers,r),P(e,"server",n.server,e.server,r),P(e,"partial",n.partial,e.partials,r),P(e,"route",n.route,e.routes,r),P(e,"component",n.component,e.components,r)})(Q,e,t),Q),async render(e){ne(),te({cache:v}),p._setContext?.({server:A,cache:v,scheduler:i});const t=k.match(e);if(!t)return await i.flush(),{html:K("",{status:404,signals:p,browserCache:S,boundary:r.boundary??"route",attributes:u}),status:404,signals:p.snapshot(),cache:{browser:S.snapshot()}};const n=t.route.partial,o=n&&_.resolve(n)?await _.render(n,t.params,{params:t.params,route:t.route,signals:p,handlers:h,server:A,cache:v,browserCache:S,partials:_,scheduler:i,...re()}):{html:""};if(o.signals)for(const[e,t]of Object.entries(o.signals))V(p,e,t);o.cache?.browser&&S.restore(o.cache.browser),await i.flush();const s=o.status??200;return{html:K(o.html,{status:s,signals:p,browserCache:S,boundary:o.boundary??r.boundary??"route",attributes:u}),status:s,signals:p.snapshot(),cache:{browser:S.snapshot()}}},destroy(){if(J)return;J=!0,W(),N?.destroy?.();const e=new Set(Z.values());for(const t of e)t.destroy?.();Z.clear(),B&&!e.has(B)&&B?.destroy?.(),p.destroy?.(),c&&i.destroy()},_applyUse(e){((e,t)=>{D(e.signals,e.registry,t.signal),D(e.handlers,e.registry,t.handler),D(e.server,e.registry,t.server),D(e.partials,e.registry,t.partial),D(e.routes,e.registry,t.route),D(e.components,e.registry,t.component),((e,t,r)=>{if(r&&0!==Object.keys(r).length)for(const[n,o]of Object.entries(r))e.has(t,n)||e.register(t,n,o)})(e.registry,"asyncSignal",t.asyncSignal),D(e.browser.cache,e.registry,t.cache.browser),D(e.server.cache,e.registry,t.cache.server)})(Q,e)}};return A.cache=v,Q.server.cache=v,Q.applySnapshot(G,{strict:r.strictSnapshots??!0}),W=n._attach(Q),Q;function X(e,t){Z.set(e,t),B||(B=t,Q.loader=t),t.server=A,t.cache=S,t.scheduler=i}function ee(e){!1!==N&&!H&&(N||((e,t)=>Boolean(t.routerOptions||t.mode||e.entries().length>0))(k,r))&&Q.loader&&(N=N??m({mode:r.mode??"ssr",root:e,boundary:r.boundary??"route",routes:k,loader:Q.loader,signals:p,handlers:h,server:A,cache:S,partials:_,scheduler:i,attributes:u}),Q.router=N,Q.loader.router=N,te({cache:S,router:N}),N.start(),H=!0)}function te(e={}){const t=(e=>"function"==typeof e?.registerMany)(A)?v:e.cache;A._setContext?.({signals:p,loader:B,router:N,cache:t,scheduler:i,requestContext:r.requestContext,...re()})}function re(){const e=(t=r.requestContext)?"function"==typeof t.get?t.get()??{}:"function"==typeof t.getStore?t.getStore()??{}:{}:{};var t;return{requestContext:e,request:e.request??r.request,headers:e.headers??r.headers,cookies:e.cookies??r.cookies,locals:e.locals??r.locals}}function ne(){if(J)throw new Error("Async app runtime has been destroyed.")}}const M=q();function x(e=globalThis.document,{attributes:t}={}){const r=O(t),n=A(r,"async","snapshot"),o=e?.ownerDocument??e??globalThis.document,s=e??o;if(!s?.querySelectorAll&&!o?.querySelectorAll)return{};const a={};for(const e of new Set([s,o]))if(e?.querySelectorAll)for(const t of e.querySelectorAll("script[type='application/json'], script")){if(!t.hasAttribute?.(n))continue;const e=t.textContent?.trim()??"";if(!e)continue;let r;try{r=JSON.parse(e)}catch(e){throw new Error(`Could not parse Async snapshot: ${e instanceof Error?e.message:String(e)}`)}H(a,r,{strict:!0})}return a}function D(e,t,r){r&&0!==Object.keys(r).length&&(e?.registry!==t?e?.registerMany?.(r):e._adoptMany?.(r))}function L(e={}){const t={};for(const[r,n]of Object.entries(e??{}))t[r]=S(n);return t}function B(e,t,r){for(const[n,o]of Object.entries(r??{}))e.register(t,n,o)}function P(e,t,r,n,o={}){if(r&&0!==Object.keys(r).length){for(const[n,s]of Object.entries(r)){if("asyncSignal"===t&&e.signals?.has?.(n)&&!e.registry.has(t,n))throw new Error(`Signal "${n}" is already registered.`);N(e.registry,t,n,s,o)}n?._adoptMany?.(r)}}function N(e,t,r,n,o={}){const s=o.strict??!0,a=e._map(t);if(a.has(r)){if(k(a.get(r),n)||W(a.get(r),n))return;if(s)throw new Error(`${t} "${r}" is already registered with a different value.`)}else e.set(t,r,n)}function z(e={}){return{signal:{...e.signals??{},...e.signal??{}},handler:{...e.handler??{}},server:{...e.server??{}},partial:{...e.partial??{}},route:{...e.route??{}},component:{...e.component??{}},asyncSignal:{...e.asyncSignal??{}},cache:{browser:{...e.entries?.browser??{},...e.cache?.browser??{}}}}}function H(e,t,r={}){const n=z(_(t));e.signal={...e.signal??e.signals??{},...n.signal},e.signals=e.signal,e.cache={...e.cache??{},browser:{...e.cache?.browser??{},...n.cache.browser}};for(const t of["handler","server","partial","route","component","asyncSignal"]){e[t]=e[t]??{};for(const[o,s]of Object.entries(n[t]))if(Object.hasOwn(e[t],o)){if(k(e[t][o],s)||W(e[t][o],s))continue;if(r.strict??1)throw new Error(`${t} "${o}" is already declared with a different value.`)}else e[t][o]=s}return e}function W(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function U(e,t,r){if(e.has?.(t)){const n=e._entry?.(t);return"function"==typeof n?._restore&&(e=>!(!e||"object"!=typeof e||Array.isArray(e))&&(Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))))(r)?void n._restore(r):void e.set(t,r)}e.register(t,E(r))}function V(e,t,r){if("function"==typeof e._setPath)return void e._setPath(t,r);const n=String(t).split(".")[0];e.has?.(n)?e.set(t,r):(e.register(n,E(t===n?r:{})),t!==n&&e.set(t,r))}function I(e={},t={}){const r=t.registry??j(),n=t.type??"server",o={},s={registry:r,register:(e,t)=>(r.register(n,e,t),e),registerMany(e){for(const[t,r]of Object.entries(e??{}))s.register(t,r);return s},unregister:e=>r.unregister(n,e),resolve(){},async run(e){throw new Error(`Server command "${e}" cannot run without a server proxy or server registry.`)},keys:()=>r.keys(n),entries:()=>r.entries(n),inspect:()=>r.entries(n),_setContext:(e={})=>(Object.assign(o,e),s),_adoptMany:()=>s};return s.registerMany(e),v((e,t,r)=>s.run(e,t,r),s,()=>o)}function F(e,t={}){if("signal"!==e)return{...t??{}};const r={};for(const[e,n]of Object.entries(t??{}))r[e]=J(n);return r}function J(e){return e&&"object"==typeof e&&"function"==typeof e.subscribe?e:E(e)}function K(e,{signals:t,browserCache:r,boundary:n,attributes:o}){const s={signals:t.snapshot(),cache:{browser:r.snapshot()}},a=A(o,"async","boundary"),i=A(o,"async","snapshot");return`<section ${a}="${c=n,String(c).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}">${e??""}</section><script type="application/json" ${i}>${(e=>JSON.stringify(e).replaceAll("<","\\u003c"))(s)}<\/script>`;var c}return{defineApp:q,createApp:C,readSnapshot:x,Async:M}})(),y=(()=>{function e(e){if("string"!=typeof e||0===e.length)throw new TypeError("Boundary patch boundary must be a non-empty string.")}function t(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))}return{createBoundaryReceiver:(r={})=>{const n=r.loader,o=r.signals??n?.signals,s=r.cache??n?.cache,a=r.scheduler??n?.scheduler,i=r.router??n?.router,c=r.recentLimit??50,u=!0===r.throwOnError,l="function"==typeof r.onApply?r.onApply:void 0,f="function"==typeof r.onIgnore?r.onIgnore:void 0,p="function"==typeof r.onError?r.onError:void 0,h="function"==typeof r.isScopeDestroyed?r.isScopeDestroyed:e=>a?.isScopeDestroyed?.(e)??a?.inspectDestroyed?.(e)??!1;if(!n||"function"!=typeof n.swap)throw new TypeError("createBoundaryReceiver(...) requires a loader with swap(boundary, html).");if(!Number.isInteger(c)||c<0)throw new TypeError("createBoundaryReceiver(...) recentLimit must be a non-negative integer.");const d=new Map,y=[];let g=!1;const w={async apply(r){if(g)throw new Error("Boundary receiver has been destroyed.");const c=(r=>{if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError("receiver.apply(patch) requires a boundary patch object.");if(e(r.boundary),"number"!=typeof r.seq||!Number.isFinite(r.seq))throw new TypeError("Boundary patch seq must be a finite number.");if(void 0!==r.signals&&!t(r.signals))throw new TypeError("Boundary patch signals must be an object.");if(void 0!==r.cache&&!t(r.cache))throw new TypeError("Boundary patch cache must be an object.");if(void 0!==r.cache?.browser&&!t(r.cache.browser))throw new TypeError("Boundary patch cache.browser must be an object.");if(void 0!==r.redirect&&("string"!=typeof r.redirect||0===r.redirect.length))throw new TypeError("Boundary patch redirect must be a non-empty string.");if(void 0!==r.parentScope&&"string"!=typeof r.parentScope)throw new TypeError("Boundary patch parentScope must be a string.");if(void 0!==r.scope&&"string"!=typeof r.scope)throw new TypeError("Boundary patch scope must be a string.");const n=Object.hasOwn(r,"html")&&null!=r.html,o=r.signals&&Object.keys(r.signals).length>0,s=r.cache?.browser&&Object.keys(r.cache.browser).length>0,a=Boolean(r.redirect),i=Object.hasOwn(r,"error");if(!(n||o||s||a||i))throw new TypeError("Boundary patch must include html, signals, cache.browser, redirect, or error.");return r})(r),y=(w=c.boundary,d.has(w)||d.set(w,{lastSeq:-1/0,applied:0,ignored:0,errored:0,lastStatus:void 0}),d.get(w));var w,b;if(c.seq<=y.lastSeq){const e={status:"ignored-stale",boundary:c.boundary,seq:c.seq,lastSeq:y.lastSeq};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(void 0!==c.parentScope&&h(c.parentScope)){const e={status:"ignored-destroyed",boundary:c.boundary,seq:c.seq,parentScope:c.parentScope};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(y.lastSeq=c.seq,Object.hasOwn(c,"error")){const e=(b=c.error)instanceof Error?b:b&&"object"==typeof b&&"string"==typeof b.message?Object.assign(new Error(b.message),b):new Error(String(b)),t={status:"errored",boundary:c.boundary,seq:c.seq,error:e};if(y.errored+=1,y.lastStatus=t.status,m(t),p?.(e,t,r),u)throw e;return t}if(c.signals){if(!o||"function"!=typeof o.set)throw new Error("Boundary patch includes signals, but no signal registry is available.");for(const[e,t]of Object.entries(c.signals))o.set(e,t)}if(c.cache?.browser){if(!s||"function"!=typeof s.restore)throw new Error("Boundary patch includes browser cache, but no cache registry is available.");s.restore(c.cache.browser)}if(null!=c.html&&n.swap(c.boundary,c.html),await(async(e,t)=>{e&&(void 0===t||"function"!=typeof e.flushScope?"function"==typeof e.flush&&await e.flush():await e.flushScope(t))})(a,c.scope),c.redirect){await(async(e,t,r)=>{if(t&&"function"==typeof t.navigate)return void await t.navigate(e);const n=r?.root?.ownerDocument?.defaultView?.location??globalThis.location;n?.assign?.(e)})(c.redirect,i,n);const e={status:"redirected",boundary:c.boundary,seq:c.seq,redirect:c.redirect};return y.applied+=1,y.lastStatus=e.status,m(e),l?.(e,r),e}const v={status:"applied",boundary:c.boundary,seq:c.seq};return y.applied+=1,y.lastStatus=v.status,m(v),l?.(v,r),v},inspect(){const e={};for(const[t,r]of d)e[t]={lastSeq:r.lastSeq,applied:r.applied,ignored:r.ignored,lastStatus:r.lastStatus},r.errored>0&&(e[t].errored=r.errored);return{destroyed:g,boundaries:e,recent:y.map(e=>({...e}))}},reset(t){if(void 0===t)return d.clear(),y.length=0,w;e(t),d.delete(t);for(let e=y.length-1;e>=0;e-=1)y[e].boundary===t&&y.splice(e,1);return w},destroy(){g=!0,d.clear(),y.length=0}};return w;function m(e){if(0!==c)for(y.push((e=>{const t={boundary:e.boundary,seq:e.seq,status:e.status};return"ignored-stale"===e.status&&(t.lastSeq=e.lastSeq),"ignored-destroyed"===e.status&&void 0!==e.parentScope&&(t.parentScope=e.parentScope),"redirected"===e.status&&(t.redirect=e.redirect),t})(e));y.length>c;)y.shift()}}}})(),g=(()=>{function e(e){return e?.reason??new Error("Operation aborted")}return{delay:(t,r)=>r?.aborted?Promise.reject(e(r)):new Promise((n,o)=>{let s=setTimeout(()=>{s=void 0,r?.removeEventListener?.("abort",a),n()},t);function a(){void 0!==s&&clearTimeout(s),s=void 0,r?.removeEventListener?.("abort",a),o(e(r))}r?.addEventListener?.("abort",a,{once:!0})})}})(),w=(()=>{const{Async:e}=d;return{defineAsyncContainerElement:function(t={}){const r=t.tagName??"async-container",n=t.customElements??globalThis.customElements;if(!n)throw new Error("defineAsyncContainerElement(...) requires customElements.");const o=n.get(r);if(o)return o;const s=t.app??t.Async??e,a=t.HTMLElement??t.window?.HTMLElement??globalThis.HTMLElement;if(!a)throw new Error("defineAsyncContainerElement(...) requires HTMLElement.");class i extends a{connectedCallback(){if(this.__asyncAttached)return;const e=s.runtime??s.start?.();e?.attachRoot?.(this),this.__asyncRuntime=e,this.__asyncAttached=!0}disconnectedCallback(){this.__asyncAttached&&(this.__asyncRuntime?.detachRoot?.(this),this.__asyncRuntime=void 0,this.__asyncAttached=!1)}}return n.define(r,i),i},defineAsyncSuspenseElement:(e={})=>{const t=e.tagName??"async-suspense",r=e.customElements??globalThis.customElements;if(!r)throw new Error("defineAsyncSuspenseElement(...) requires customElements.");const n=r.get(t);if(n)return n;const o=e.HTMLElement??e.window?.HTMLElement??globalThis.HTMLElement;if(!o)throw new Error("defineAsyncSuspenseElement(...) requires HTMLElement.");class s extends o{}return r.define(t,s),s}}})(),{asyncSignal:m}=e,{Async:b}=d,{createApp:v}=d,{defineApp:S}=d,{readSnapshot:E}=d,{attributeName:$}=o,{defineAttributeConfig:j}=o,{createBoundaryReceiver:A}=y,{createCacheRegistry:O}=n,{defineCache:R}=n,{component:_}=i,{createComponentRegistry:k}=i,{defineComponent:T}=i,{delay:q}=g,{defineAsyncContainerElement:C}=w,{defineAsyncSuspenseElement:M}=w,{createHandlerRegistry:x}=u,{html:D}=a,{createLazyRegistry:L}=t,{defineRegistrySnapshot:B}=t,{Loader:P}=f,{AsyncLoader:N}=f,{createPartialRegistry:z}=p,{createRegistryStore:H}=r,{createRouteRegistry:W}=h,{createRouter:U}=h,{defineRoute:V}=h,{route:I}=h,{createScheduler:F}=l,{applyServerResult:J}=c,{createServerProxy:K}=c,{resolveServerCommandArguments:Z}=c,{unwrapServerResult:Y}=c,{computed:G}=s,{createSignal:Q}=s,{createSignalRegistry:X}=s,{effect:ee}=s,{signal:te}=s;export{m as asyncSignal,b as Async,v as createApp,S as defineApp,E as readSnapshot,$ as attributeName,j as defineAttributeConfig,A as createBoundaryReceiver,O as createCacheRegistry,R as defineCache,_ as component,k as createComponentRegistry,T as defineComponent,q as delay,C as defineAsyncContainerElement,M as defineAsyncSuspenseElement,x as createHandlerRegistry,D as html,L as createLazyRegistry,B as defineRegistrySnapshot,P as Loader,N as AsyncLoader,z as createPartialRegistry,H as createRegistryStore,W as createRouteRegistry,U as createRouter,V as defineRoute,I as route,F as createScheduler,J as applyServerResult,K as createServerProxy,Z as resolveServerCommandArguments,Y as unwrapServerResult,G as computed,Q as createSignal,X as createSignalRegistry,ee as effect,te as signal};
|
package/browser.ts
CHANGED
|
@@ -3240,7 +3240,7 @@ const __schedulerModule = (() => {
|
|
|
3240
3240
|
scheduled = true;
|
|
3241
3241
|
scheduleMicrotask(() => {
|
|
3242
3242
|
if (!destroyed) {
|
|
3243
|
-
void api.flush();
|
|
3243
|
+
void api.flush().catch(reportAutomaticFlushError);
|
|
3244
3244
|
}
|
|
3245
3245
|
});
|
|
3246
3246
|
}
|
|
@@ -3276,12 +3276,22 @@ const __schedulerModule = (() => {
|
|
|
3276
3276
|
if (onError) {
|
|
3277
3277
|
onError(error, job);
|
|
3278
3278
|
} else {
|
|
3279
|
-
throw error;
|
|
3279
|
+
throw annotateSchedulerError(error, job);
|
|
3280
3280
|
}
|
|
3281
3281
|
}
|
|
3282
3282
|
}
|
|
3283
3283
|
}
|
|
3284
3284
|
|
|
3285
|
+
function reportAutomaticFlushError(error) {
|
|
3286
|
+
if (typeof globalThis.reportError === "function") {
|
|
3287
|
+
globalThis.reportError(error);
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3290
|
+
setTimeout(() => {
|
|
3291
|
+
throw error;
|
|
3292
|
+
}, 0);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3285
3295
|
function hasJobs() {
|
|
3286
3296
|
for (const queue of queues.values()) {
|
|
3287
3297
|
if (queue.some((job) => !job.canceled)) {
|
|
@@ -3340,6 +3350,25 @@ const __schedulerModule = (() => {
|
|
|
3340
3350
|
return (typeof scope === "object" && scope !== null) || typeof scope === "function";
|
|
3341
3351
|
}
|
|
3342
3352
|
|
|
3353
|
+
function annotateSchedulerError(error, job) {
|
|
3354
|
+
if (!error || (typeof error !== "object" && typeof error !== "function")) {
|
|
3355
|
+
return error;
|
|
3356
|
+
}
|
|
3357
|
+
try {
|
|
3358
|
+
Object.defineProperty(error, "scheduler", {
|
|
3359
|
+
configurable: true,
|
|
3360
|
+
value: {
|
|
3361
|
+
phase: job.phase,
|
|
3362
|
+
scope: job.scope,
|
|
3363
|
+
key: job.key
|
|
3364
|
+
}
|
|
3365
|
+
});
|
|
3366
|
+
} catch {
|
|
3367
|
+
// Non-extensible thrown values still need to propagate through the chosen error channel.
|
|
3368
|
+
}
|
|
3369
|
+
return error;
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3343
3372
|
function scheduleMicrotask(fn) {
|
|
3344
3373
|
if (typeof queueMicrotask === "function") {
|
|
3345
3374
|
queueMicrotask(fn);
|
package/browser.umd.js
CHANGED
|
@@ -3250,7 +3250,7 @@
|
|
|
3250
3250
|
scheduled = true;
|
|
3251
3251
|
scheduleMicrotask(() => {
|
|
3252
3252
|
if (!destroyed) {
|
|
3253
|
-
void api.flush();
|
|
3253
|
+
void api.flush().catch(reportAutomaticFlushError);
|
|
3254
3254
|
}
|
|
3255
3255
|
});
|
|
3256
3256
|
}
|
|
@@ -3286,12 +3286,22 @@
|
|
|
3286
3286
|
if (onError) {
|
|
3287
3287
|
onError(error, job);
|
|
3288
3288
|
} else {
|
|
3289
|
-
throw error;
|
|
3289
|
+
throw annotateSchedulerError(error, job);
|
|
3290
3290
|
}
|
|
3291
3291
|
}
|
|
3292
3292
|
}
|
|
3293
3293
|
}
|
|
3294
3294
|
|
|
3295
|
+
function reportAutomaticFlushError(error) {
|
|
3296
|
+
if (typeof globalThis.reportError === "function") {
|
|
3297
|
+
globalThis.reportError(error);
|
|
3298
|
+
return;
|
|
3299
|
+
}
|
|
3300
|
+
setTimeout(() => {
|
|
3301
|
+
throw error;
|
|
3302
|
+
}, 0);
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3295
3305
|
function hasJobs() {
|
|
3296
3306
|
for (const queue of queues.values()) {
|
|
3297
3307
|
if (queue.some((job) => !job.canceled)) {
|
|
@@ -3350,6 +3360,25 @@
|
|
|
3350
3360
|
return (typeof scope === "object" && scope !== null) || typeof scope === "function";
|
|
3351
3361
|
}
|
|
3352
3362
|
|
|
3363
|
+
function annotateSchedulerError(error, job) {
|
|
3364
|
+
if (!error || (typeof error !== "object" && typeof error !== "function")) {
|
|
3365
|
+
return error;
|
|
3366
|
+
}
|
|
3367
|
+
try {
|
|
3368
|
+
Object.defineProperty(error, "scheduler", {
|
|
3369
|
+
configurable: true,
|
|
3370
|
+
value: {
|
|
3371
|
+
phase: job.phase,
|
|
3372
|
+
scope: job.scope,
|
|
3373
|
+
key: job.key
|
|
3374
|
+
}
|
|
3375
|
+
});
|
|
3376
|
+
} catch {
|
|
3377
|
+
// Non-extensible thrown values still need to propagate through the chosen error channel.
|
|
3378
|
+
}
|
|
3379
|
+
return error;
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3353
3382
|
function scheduleMicrotask(fn) {
|
|
3354
3383
|
if (typeof queueMicrotask === "function") {
|
|
3355
3384
|
queueMicrotask(fn);
|
package/browser.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){const t=function(){"use strict";const e=(()=>{const e=Symbol.for("@async/framework.asyncSignal");return{asyncSignal:function t(r,n){if("string"!=typeof r||0===r.length)throw new TypeError("asyncSignal(id, fn) requires a non-empty string id.");if("function"!=typeof n)throw new TypeError("asyncSignal(id, fn) requires a function.");let o,s,a,i=!1,c=null,u="idle",l=0,f=r,p=0,d=!1;const h=new Set,y=new Set,g={[e]:!0,kind:"async-signal",get id(){return f},get value(){return o},get loading(){return i},get error(){return c},get status(){return u},get version(){return l},set:e=>(o=e,i=!1,c=null,u="ready",$(),o),refresh(){if(!s||d)throw new Error(`Async signal "${f}" is not registered.`);v(a,new Error(`Async signal "${f}" refreshed.`));const e=s,t=l+1;l=t,i=!0,c=null,u="loading";const r=function(e,t,r){const n=new AbortController,o=n.signal,s=function(e,t){const r=e._context?.()??{},n={signals:e,router:r.router,loader:r.loader,cache:r.cache,abort:t,scheduler:r.scheduler};return{signals:e,server:"function"==typeof r.server?._withContext?r.server._withContext(n):r.server,router:r.router,loader:r.loader,cache:r.cache,scheduler:r.scheduler}}(e,o),a={token:++p,version:r,registry:e,id:t,controller:n,abort:o,...s};return function(e,t,r){Object.defineProperty(e,"cancel",{configurable:!0,enumerable:!1,value(e){"function"!=typeof r?t.abort(e):r(e)}})}(o,n,e=>{v(a,e,{settle:!0,notifyChange:!0})}),a}(e,f,t);a=r,$();const h=function(e){return{signals:e.signals,id:e.id,get server(){return e.server},get router(){return e.router},get loader(){return e.loader},get cache(){return e.cache},get scheduler(){return e.scheduler},get version(){return e.version},get abort(){return e.abort},refresh:()=>g.refresh()}}(r);let b;try{b=e._collectDependencies(()=>n.call(h))}catch(e){return w(r,e),Promise.reject(e)}return function(e,t){if(m(t)){for(const e of y)e();y.clear();for(const r of e){const e=String(r).split(".")[0];e&&e!==f&&y.add(t.registry.subscribe(r,()=>E()))}}}(b.dependencies,r),Promise.resolve(b.value).then(e=>m(r)?(o=e,i=!1,c=null,u="ready",a=void 0,$(),o):o,e=>m(r)?(w(r,e),o):o)},cancel:e=>(b(e,{settle:!0,notifyChange:!0}),o),subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return h.add(e),()=>h.delete(e)},snapshot:()=>({value:o,loading:i,error:c,status:u,version:l}),_cloneSignalDeclaration:()=>t(r,n),_restore:(e={})=>function(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))}(e)?(b(new Error(`Async signal "${f}" restored from snapshot.`)),o=e.value,i=Boolean(e.loading),c=e.error??null,u="string"==typeof e.status?e.status:function({value:e,loading:t,error:r}){return t?"loading":r?"error":void 0===e?"idle":"ready"}({value:o,loading:i,error:c}),Number.isFinite(e.version)&&(l=e.version),$(),g):g.set(e),_bindRegistry(e,t){s=e,f=t;const r=()=>{d||s!==e||"idle"!==u||g.refresh()},n=s._context?.().scheduler;n?n.enqueue("async",r,{scope:f,key:`asyncSignal:${f}:initial`}):queueMicrotask(r)},_dispose(){if(!d){d=!0,function(){const e=s?._context?.().scheduler;e?.cancelScope?.(f)}(),b(new Error(`Async signal "${f}" disposed.`));for(const e of y)e();y.clear(),h.clear(),s=void 0}}};function w(e,t){m(e)&&(i=!1,c=t,u="error",a=void 0,$())}function m(e){return Boolean(e)&&!d&&a===e&&e.token===p&&e.registry===s&&e.id===f&&!e.abort.aborted}function b(e,t={}){const r=a,n=Boolean(r)||i;r?v(r,e):n&&(p+=1),t.settle&&n&&!d&&S(t.notifyChange)}function v(e,t,r={}){if(!e)return;const n=a===e;n&&(p+=1,a=void 0),e.abort.aborted||e.controller.abort(t),n&&r.settle&&!d&&S(r.notifyChange)}function S(e=!1){const t=void 0===o?"idle":"ready",r=i||null!==c||u!==t;i=!1,c=null,u=t,e&&r&&$()}function E(){if(d||!s)return;v(a,new Error(`Async signal "${f}" dependency changed.`));const e=s?._context?.().scheduler;e?e.enqueue("async",()=>g.refresh(),{scope:f,key:`asyncSignal:${f}:refresh`}):g.refresh()}function $(){for(const e of[...h])e(g)}return g},isAsyncSignal:function(t){return Boolean(t?.[e])}}})(),t=(()=>{const e=new Set(["handler","component","asyncSignal","partial","route"]);function t(t={}){const r=function(e){if("string"!=typeof e||0===e.length)throw new TypeError("registryAssets.baseUrl must be a non-empty string.");return i(e)||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?a(e):`/${s(e)}`}(t.baseUrl??"_async"),n={component:"component",handler:"handler",asyncSignal:"asyncSignal",partial:"partial",route:"route",...t.paths??{}};for(const[t,r]of Object.entries(n))if(e.has(t)&&("string"!=typeof r||0===r.length))throw new TypeError(`Registry asset path for "${t}" must be a non-empty string.`);return{baseUrl:r,paths:n}}function r(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.url)}function n(t,n,c,u){if(!e.has(t))throw new Error(`Registry type "${t}" does not support lazy descriptors.`);if(!r(c))throw new TypeError(`Registry descriptor for "${t}:${n}" requires a url.`);const{path:l,hash:f}=function(e){const t=e.indexOf("#");return-1===t?{path:e,hash:""}:{path:e.slice(0,t),hash:e.slice(t+1)}}(c.url),p=function(e,t,r){if(i(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=r.paths[e]??e;return function(...e){const[t,...r]=e;return[a(t),...r.map(s)].filter(Boolean).join("/")}(r.baseUrl,n,t)}(t,l,u);return{moduleUrl:p,exportNames:f?[f]:o(n,l),url:f?`${p}#${f}`:p}}function o(e,t){const r=[],n=e.split(".").filter(Boolean).at(-1),o=t.split("/").filter(Boolean).at(-1)?.replace(/\.[^.]+$/,"");for(const e of[n,o,"default"])e&&!r.includes(e)&&r.push(e);return r}function s(e){return String(e).replace(/^\/+|\/+$/g,"")}function a(e){return String(e).replace(/\/+$/g,"")}function i(e){return/^[A-Za-z][A-Za-z\d+.-]*:/.test(e)}function c(e){return!e||"object"!=typeof e||Array.isArray(e)?JSON.stringify(e):JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]]))}return{defineRegistrySnapshot:function(e={}){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("defineRegistrySnapshot(snapshot) requires an object.");return e},createLazyRegistry:function(e={}){const o=t(e.registryAssets??e.assets),s=e.importModule??(e=>import(e)),a=new Map,i=new Map;return{registryAssets:o,resolveUrl:(e,t,r)=>n(e,t,r,o),async resolve(e,t,c){if(!r(c))return c;const u=`${e}:${t}`;if(i.has(u))return i.get(u);const l=n(e,t,c,o);let f,p=a.get(l.moduleUrl);p||(p=Promise.resolve().then(()=>s(l.moduleUrl)),a.set(l.moduleUrl,p));try{f=await p}catch(r){throw a.get(l.moduleUrl)===p&&a.delete(l.moduleUrl),new Error(`Lazy ${e} "${t}" failed to import ${l.moduleUrl}: ${d=r,d instanceof Error?d.message:String(d)}`,{cause:r})}var d;const h=function(e,t,r,n){for(const r of t)if(r in e)return e[r];throw new Error(`Lazy ${r} "${n}" did not export ${t.map(e=>`"${e}"`).join(", ")}.`)}(f,l.exportNames,e,t);return i.set(u,h),h},inspect:()=>({registryAssets:o,modules:[...a.keys()],exports:[...i.keys()]})}},normalizeRegistryAssets:t,isLazyDescriptor:r,sameRegistryValue:function(e,t){return e===t||!(!r(e)||!r(t))&&c(e)===c(t)},publicRegistryValue:function(e,t){return r(e)?{...e}:{id:t}}}})(),r=(()=>{const{publicRegistryValue:e}=t,r=new Set(["signal","handler","server","partial","route","component","asyncSignal"]),n=new Set(["cache.browser","cache.server"]),o=new Set(["cache.browser.entries","cache.server.entries"]),s=new Set([...r,...n,...o]);function a(e){if(!s.has(e))throw new Error(`Unknown Async registry type "${e}".`);return e}function i(e,t){if("string"!=typeof t||0===t.length)throw new TypeError(`${e} id must be a non-empty string.`)}function c(t,r,n,s){return"server"===t&&"browser"===s.target?e(n,r):o.has(t)?n?.value:n}function u(e,t){return"cache.server.entries"===e&&"browser"===t}function l(e){const t={};for(const[r,n]of e)t[r]="function"==typeof n?.snapshot?n.snapshot():n?.value??n;return t}function f(t){const r={};for(const[n,o]of t)r[n]=e(o,n);return r}function p(e){return Object.fromEntries(e)}function d(e){const t={};for(const[r,n]of e)t[r]=n?.value;return t}function h(e){return e&&"object"==typeof e&&Object.hasOwn(e,"value")?e:{value:e}}return{createRegistryStore:function e(t={},n={}){const o=n.backing??{signal:new Map,handler:new Map,server:new Map,partial:new Map,route:new Map,component:new Map,asyncSignal:new Map,cache:{browser:new Map,server:new Map},cacheEntries:{browser:new Map,server:new Map}},s=n.target??"server",y={target:s,register(e,t,r){const n=y._map(e);if(i(e,t),n.has(t))throw new Error(`${e} "${t}" is already registered.`);return n.set(t,r),t},registerMany(e,t={}){for(const[r,n]of Object.entries(t??{}))y.register(e,r,n);return y},set(e,t,r){const n=y._map(e);return i(e,t),n.set(t,r),r},unregister:(e,t)=>y.delete(e,t),delete:(e,t)=>y._map(e).delete(t),keys:e=>u(e,s)?[]:[...y._map(e).keys()],entries(e,t={}){const r=a(e);return u(r,t.target??s)?[]:[...y._map(r)].map(([e,n])=>[e,c(r,e,n,{target:s,...t})])},has:(e,t)=>(i(e,t),!u(e,s)&&y._map(e).has(t)),get(e,t,r={}){i(e,t);const n=a(e);if(u(n,r.target??s))return;const o=y._map(n).get(t);return void 0!==o?c(n,t,o,{target:s,...r}):void 0},snapshot(e={}){const t=e.target??s;return{signal:l(o.signal),handler:f(o.handler),server:f(o.server),partial:f(o.partial),route:p(o.route),component:f(o.component),asyncSignal:f(o.asyncSignal),cache:{browser:p(o.cache.browser),server:p(o.cache.server)},entries:{browser:d(o.cacheEntries.browser),server:"browser"===t?{}:d(o.cacheEntries.server)}}},rawSnapshot:()=>({signal:Object.fromEntries(o.signal),handler:Object.fromEntries(o.handler),server:Object.fromEntries(o.server),partial:Object.fromEntries(o.partial),route:Object.fromEntries(o.route),component:Object.fromEntries(o.component),asyncSignal:Object.fromEntries(o.asyncSignal),cache:{browser:Object.fromEntries(o.cache.browser),server:Object.fromEntries(o.cache.server)}}),view:(t={})=>e(void 0,{backing:o,target:t.target??s}),_map(e){const t=a(e);if(r.has(t))return o[t];if("cache.browser"===t)return o.cache.browser;if("cache.server"===t)return o.cache.server;if("cache.browser.entries"===t)return o.cacheEntries.browser;if("cache.server.entries"===t)return o.cacheEntries.server;throw new Error(`Unknown Async registry type "${e}".`)}};return function(e,t={}){e.registerMany("signal",t.signal),e.registerMany("handler",t.handler),e.registerMany("server",t.server),e.registerMany("partial",t.partial),e.registerMany("route",t.route),e.registerMany("component",t.component),e.registerMany("asyncSignal",t.asyncSignal),e.registerMany("cache.browser",t.cache?.browser),e.registerMany("cache.server",t.cache?.server);const r=t.entries??{};for(const[t,n]of Object.entries(r.browser??{}))e.set("cache.browser.entries",t,h(n));for(const[t,n]of Object.entries(r.server??{}))e.set("cache.server.entries",t,h(n))}(y,t),y},attachRegistryInspection:function(e,t,r){return Object.defineProperty(e,"registry",{configurable:!0,enumerable:!0,value:t}),e.keys=()=>t.keys(r),e.entries=()=>t.entries(r),e.inspect=()=>t.entries(r),e}}})(),n=(()=>{const{attachRegistryInspection:e,createRegistryStore:t}=r,n=Symbol.for("@async/framework.cacheDefinition");function o(e={}){return{[n]:!0,kind:"cache-definition",store:e.store??"memory",ttl:e.ttl}}function s(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache id must be a non-empty string.")}function a(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache key must be a non-empty string.")}return{defineCache:o,createCacheRegistry:function(r={},{now:i=()=>Date.now(),registry:c,type:u="cache.browser"}={}){const l=c??t(),f=l._map(u),p=l._map(`${u}.entries`),d=new Map,h=e({register(e,t=o()){s(e);const r=function(e){return e?.[n]?e:o(e)}(t);if(f.has(e))throw new Error(`Cache "${e}" is already registered.`);return f.set(e,r),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))h.register(t,r);return h},unregister:e=>(s(e),f.delete(e)),resolve:e=>(s(e),f.get(e)),get:e=>(a(e),y(e).value),set(e,t,r={}){a(e);const n=r.ttl??function(e,t){if(void 0!==t)return f.get(t);if(f.has(e))return f.get(e);const r=e.split(":")[0];return f.get(r)}(e,r.cache)?.ttl;return p.set(e,{value:t,expiresAt:void 0===n?void 0:i()+n}),t},async getOrSet(e,t,r={}){if(a(e),"function"!=typeof t)throw new TypeError("cache.getOrSet(key, fn) requires a function.");const n=y(e);if(n.found)return n.value;if(d.has(e))return d.get(e);let o;return o=Promise.resolve().then(t).then(t=>(d.get(e)===o&&h.set(e,t,r),t)).finally(()=>{d.get(e)===o&&d.delete(e)}),d.set(e,o),o},delete:e=>(a(e),d.delete(e),p.delete(e)),clear(e){if(void 0===e)return p.clear(),d.clear(),h;for(const t of[...p.keys()])t.startsWith(e)&&p.delete(t);for(const t of[...d.keys()])t.startsWith(e)&&d.delete(t);return h},snapshot(){const e={};for(const[t]of p){const{found:r,value:n}=y(t);r&&void 0!==n&&(e[t]=n)}return e},restore(e={}){for(const[t,r]of Object.entries(e??{}))h.set(t,r);return h},entryKeys:()=>[...p.keys()],entryEntries:()=>l.entries(`${u}.entries`),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))f.has(t)||h.register(t,r);return h}},l,u);return h.registerMany(r),h;function y(e){const t=p.get(e);return t?void 0!==t.expiresAt&&t.expiresAt<=i()?(p.delete(e),{found:!1,value:void 0}):{found:!0,value:t.value}:{found:!1,value:void 0}}}}})(),o=(()=>{const e=Object.freeze({async:["async:"],class:["class:"],signal:["signal:"],on:["on:"]});function t(t={}){return{async:r(t.async,e.async),class:r(t.class,e.class),signal:r(t.signal,e.signal),on:r(t.on,e.on)}}function r(e,t){return(null==e?t:Array.isArray(e)?e:[e]).map(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Attribute prefixes must be non-empty strings.");return e})}return{defineAttributeConfig:function(e={}){return t(e)},normalizeAttributeConfig:t,attributeName:function(e,r,n){return t(e)[r][0]+n},readAttribute:function(e,r,n,o){for(const s of t(r)[n]){const t=`${s}${o}`;if(e.hasAttribute?.(t))return e.getAttribute(t)}return null},matchAttribute:function(e,r,n){for(const o of t(r)[n])if(e.startsWith(o))return e.slice(o.length);return null}}})(),s=(()=>{const{asyncSignal:n,isAsyncSignal:o}=e,{attachRegistryInspection:s,createRegistryStore:a}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t,u=Symbol.for("@async/framework.signal"),l=Symbol.for("@async/framework.computed"),f=Symbol.for("@async/framework.effect"),p=Symbol.for("@async/framework.signalRef"),d=[];function h(e){let t=e;const r=new Set;return{[u]:!0,kind:"signal",get value(){return t},set value(e){this.set(e)},set:e=>(Object.is(t,e)||(t=e,function(){for(const e of[...r])e(t)}()),t),update(e){return this.set(e(t))},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return r.add(e),()=>r.delete(e)},snapshot:()=>t,_cloneSignalDeclaration:()=>h(t)}}function y(e){return"function"==typeof e?._cloneSignalDeclaration?e._cloneSignalDeclaration():g(e)?h("function"==typeof e.snapshot?e.snapshot():e.value):h(e)}function g(e){return Boolean(e&&"object"==typeof e&&"function"==typeof e.subscribe)}function w(e,t){let r=e;for(const e of t){if(null==r)return;r=r[e]}return r}function m(e,t,r){const n=b(e,t[0]);let o=n;for(let e=0;e<t.length-1;e+=1){const r=t[e],n=t[e+1];o[r]=b(o[r],n),o=o[r]}return o[t.at(-1)]=r,n}function b(e,t){return Array.isArray(e)?[...e]:e&&"object"==typeof e?{...e}:(r=t,String(Number(r))===String(r)?[]:{});var r}function v(e,t){const r=e.get(t);if(!r)throw new Error(`Signal "${t}" is not registered.`);return r}function S(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal id must be a non-empty string.")}return{createSignal:h,computed:function e(t){if("function"!=typeof t)throw new TypeError("computed(fn) requires a function.");const r=h(void 0);return{[l]:!0,kind:"computed",get value(){return r.value},set:e=>r.set(e),update:e=>r.update(e),subscribe:e=>r.subscribe(e),snapshot:()=>r.snapshot(),_cloneSignalDeclaration:()=>e(t),_bindRegistry:(e,n)=>e.effect(()=>{r.set(t.call({signals:e,id:n,server:e._context?.().server,router:e._context?.().router,loader:e._context?.().loader,cache:e._context?.().cache,scheduler:e._context?.().scheduler}))})}},effect:function e(t){if("function"!=typeof t)throw new TypeError("effect(fn) requires a function.");return{[f]:!0,kind:"effect",fn:t,_cloneSignalDeclaration:()=>e(t),_bindRegistry:e=>e.effect(t)}},createSignalRegistry:function(e={},t={}){const r=t.registry??a(),u=t.type??"signal",l=r._map(u),f=r._map("asyncSignal"),b=t.lazyRegistry??i(t),E=new Map,$={},A=new Set;let j=0,R=0;for(const e of l.keys())if(f.has(e))throw new Error(`Signal "${e}" is already registered.`);const O=s({register(e,t){if(S(e),l.has(e)||f.has(e))throw new Error(`Signal "${e}" is already registered.`);const r=function(e){return g(e)?e:h(e)}(t);return l.set(e,r),_(e,r),O.ref(e)},registerMany(e){for(const[t,r]of Object.entries(e??{}))O.register(t,r);return O},unregister(e){S(e);const t=l.has(e),r=f.has(e);return!(!t&&!r||(t&&(E.get(e)?.(),E.delete(e),l.get(e)?._dispose?.(),l.delete(e),A.delete(e)),f.delete(e),0))},ensure:(e,t)=>(S(e),T(e),l.has(e)||O.register(e,h(t)),O.ref(e)),has:e=>l.has(e)||f.has(e),get(e){const t=k(e);return function(e){const t=d.at(-1);t&&t.add(e)}(t.path),function(e,t){if(o(e)&&t[0]?.startsWith("$"))return w(function(e,t){switch(t){case"$value":return e.value;case"$loading":return e.loading;case"$error":return e.error;case"$status":return e.status;case"$version":return e.version;default:return}}(e,t[0]),t.slice(1));return w(e.value,t)}(v(l,t.id),t.parts)},set(e,t){const r=k(e),n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},update(e,t){if("function"!=typeof t)throw new TypeError("update(path, fn) requires a function.");return O.set(e,t(O.get(e)))},ref:e=>(S(e),T(e),function(e,t){return{[p]:!0,kind:"signal-ref",id:t,get value(){return e.get(t)},set value(r){e.set(t,r)},get loading(){return e._entry(t).loading??!1},get error(){return e._entry(t).error??null},get status(){return e._entry(t).status??"ready"},get version(){return e._entry(t).version??0},get:()=>e.get(t),set:r=>e.set(t,r),update:r=>e.update(t,r),subscribe:r=>e.subscribe(t,r),refresh(){const r=e._entry(t);if("function"!=typeof r.refresh)throw new Error(`Signal "${t}" cannot refresh.`);return r.refresh()},cancel(r){const n=e._entry(t);if("function"!=typeof n.cancel)throw new Error(`Signal "${t}" cannot cancel.`);return n.cancel(r)},toString:()=>t,[Symbol.toPrimitive]:()=>t}}(O,e)),subscribe(e,t,r={}){if("function"!=typeof t)throw new TypeError("subscribe(path, fn) requires a function.");const n=k(e),o=v(l,n.id),s=++j;return o.subscribe(()=>{!function(e,t={}){const r=t.scheduler;r&&"sync"!==t.phase?r.enqueue(t.phase??"effect",e,{scope:t.scope,key:t.key}):e()}(()=>t(O.get(n.path),{id:n.id,path:n.path,signal:o}),{...r,key:r.key??`signal:${n.path}:${s}`})})},snapshot(){const e={};for(const[t,r]of l)e[t]="function"==typeof r.snapshot?r.snapshot():r.value;return e},asyncSignal:(e,t)=>(O.register(e,n(e,t)),O.ref(e)),effect(e,t={}){let r,n=[],o=!1;const s=t.scheduler,a=++R,i=()=>{if(o)return;"function"==typeof r&&r();for(const e of n)e();n=[];const t=O._collectDependencies(()=>e.call({signals:O,server:$.server,router:$.router,loader:$.loader,cache:$.cache,scheduler:$.scheduler}));r=t.value,n=t.dependencies.map(e=>O.subscribe(e,c))},c=()=>{s?s.enqueue(t.phase??"effect",i,{scope:t.scope,key:t.key??`effect:${a}`}):i()};return i(),()=>{o=!0,"function"==typeof r&&r();for(const e of n)e()}},destroy(){for(const e of E.values())e();E.clear();for(const e of l.values())e._dispose?.();l.clear()},_collectDependencies(e){const t=new Set;d.push(t);try{return{value:e(),dependencies:[...t]}}finally{d.pop()}},_entry:e=>(T(e),v(l,e)),_setPath(e,t){const r=function(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const[t,...r]=e.split(".");return{id:t,parts:r,path:e}}(e);l.has(r.id)||(f.has(r.id)?T(r.id):O.register(r.id,h(0===r.parts.length?t:{})));const n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},_setContext:(e={})=>(Object.assign($,e),O),_context:()=>$,_adoptMany(e={}){for(const[t,r]of Object.entries(e??{})){if(!l.has(t)){if(f.has(t))throw new Error(`Signal "${t}" is already registered.`);const e=y(r);l.set(t,e),_(t,e);continue}_(t,l.get(t))}return O}},r,u);for(const[e,t]of l)_(e,t);return O.registerMany(e),O;function _(e,t){if(A.has(e)||"function"!=typeof t?._bindRegistry)return;A.add(e);const r=t._bindRegistry(O,e);"function"==typeof r&&E.set(e,r)}function k(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const t=e.split(".");for(let r=t.length;r>0;r-=1){const n=t.slice(0,r).join(".");if(l.has(n)||f.has(n))return T(n),{id:n,parts:t.slice(r),path:e}}const[r,...n]=t;return{id:r,parts:n,path:e}}function T(e){if(l.has(e)||!f.has(e))return;const t=f.get(e);if(!c(t)&&"function"!=typeof t)throw new TypeError(`Async signal "${e}" must be a function or lazy descriptor.`);const r=n(e,async function(...r){const n=await b.resolve("asyncSignal",e,t);if("function"!=typeof n)throw new TypeError(`Async signal "${e}" did not resolve to a function.`);return n.apply(this,r)});l.set(e,r),_(e,r)}},cloneSignalDeclaration:y,isSignalRef:function(e){return Boolean(e?.[p])},signal:h}})(),a=(()=>{const{isSignalRef:e}=s,{attributeName:t,matchAttribute:r,normalizeAttributeConfig:n}=o,a=Symbol.for("@async/framework.template"),i=Symbol.for("@async/framework.rawHtml");function c(e){return Boolean(e?.[a])}function u(e,t={}){if(c(e)){const r=p(t);let n="";for(let t=0;t<e.strings.length;t+=1)n+=e.strings[t],t<e.values.length&&(n+=l(e.values[t],{...r,attribute:d(e.strings[t])}));return n}return l(e,p(t))}function l(n,o=p()){return n?.[i]?n.html:c(n)?u(n,o):o.attribute?function(n,o){const s=r(o.attribute.name,o.attributes,"signal"),a=r(o.attribute.name,o.attributes,"class"),i=function(t,r){return e(t)?t.id:"string"==typeof t&&r.signals?.has?.(t)?t:null}(n,o);if("value"===o.attribute.name&&i){const r=function(t,r){return e(t)?t.value:"string"==typeof t&&r.signals?.has?.(t)?r.signals.get(t):t}(n,o),s=t(o.attributes,"signal","value");return`${h(r)}${o.attribute.quote} ${s}=${o.attribute.quote}${h(i)}`}if(null!=s||null!=a){if(i)return h(i);if(function(e){return Boolean(e&&"object"==typeof e)}(n))return h(function(e,t){return"function"!=typeof t.bind?e:t.bind(e)}(n,o))}return f(n,o)}(n,o):Array.isArray(n)?n.map(e=>l(e,o)).join(""):e(n)?h(n.value):null==n||!1===n?"":h(n)}function f(t,r){return Array.isArray(t)?t.map(e=>f(e,r)).join(""):e(t)?h(t.value):null==t||!1===t?"":h(t)}function p(e={}){return{...e,attributes:n(e.attributes)}}function d(e){const t=e.match(/(?:^|[\s<])([^\s"'=<>`]+)\s*=\s*(["'])$/);return t?{name:t[1],quote:t[2]}:null}function h(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}return{html:function(e,...t){return{[a]:!0,strings:e,values:t}},isTemplateResult:c,rawHtml:function(e){return{[i]:!0,html:String(e??"")}},renderTemplate:u,escapeHtml:h}})(),i=(()=>{const{attributeName:e}=o,{escapeHtml:n,rawHtml:s,renderTemplate:i}=a,{attachRegistryInspection:c,createRegistryStore:u}=r,{createLazyRegistry:l,isLazyDescriptor:f}=t,p=Symbol.for("@async/framework.component");let d=0;function h(e){if("function"!=typeof e)throw new TypeError("defineComponent(fn) requires a function.");return Object.defineProperty(e,p,{configurable:!0,value:!0}),e}function y(e){return Boolean(e?.[p])}function g(t,r={},o,a="component"){if(!y(t)&&"function"!=typeof t)throw new TypeError("renderComponent(Component) requires a component function.");const c=`${a}.${m(t)}.${++d}`,u=[],l=[],f=[],p=[],h=[],b={attributes:o.attributes,signals:o.signals,bind(e){const t=o.loader?._registerBinding?.(e);if(!t)throw new Error("Inline template bindings require a Loader.");return h.push(t),t}},v=e=>i(e,b),S=function({runtime:t,scope:r,cleanups:o,attachHooks:a,visibleHooks:i,destroyHooks:c,renderScopedTemplate:u}){const{signals:l,handlers:f,loader:p,server:d,router:h,cache:y,scheduler:m}=t,b=new WeakMap;let v=0,S=0;const E={scope:r,signals:l,handlers:f,loader:p,server:d,router:h,cache:y,scheduler:m,signal(e,t){if(1===arguments.length){const t=w(r,"signal."+ ++S),n=l.ensure(t,e);return o.push(()=>l.unregister?.(t)),n}const n=w(r,e),s=!l.has(n),a=l.ensure(n,t);return s&&o.push(()=>l.unregister?.(n)),a},computed(e,t){const n=w(r,e),s=!l.has(n),a=l.ensure(n,void 0);s&&o.push(()=>l.unregister?.(n));const i=l.effect(()=>{l.set(n,t.call(E))});return o.push(i),a},asyncSignal(e,t){const n=w(r,e),s=!l.has(n);return l.has(n)||l.asyncSignal(n,t),s&&o.push(()=>l.unregister?.(n)),l.ref(n)},effect(e){const t=l.effect(()=>e.call(E),{scheduler:m,phase:"effect",scope:r});return o.push(t),t},handler(e,t){if("function"==typeof e&&void 0===t){const t=e;if(b.has(t))return b.get(t);const r=$("handler."+ ++v,t);return b.set(t,r),r}if("function"!=typeof t)throw new TypeError("this.handler(name, fn) or this.handler(fn) requires a function.");return $(e,t)},render(e,n={}){const c=g(e,n,t,r);return o.push(c.cleanup),a.push(e=>c.attach(e)),i.push(e=>c.visible(e,p._observeVisible)),s(c.html)},suspense(r,o){const a=r?.id;if(!a)throw new TypeError("this.suspense(signalRef, views) requires a signal ref.");const i=function(e){const t="function"==typeof e?{ready:e}:e;if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("this.suspense(signalRef, views) requires views to be a function or object.");for(const e of["loading","ready","error"])if(Object.hasOwn(t,e)&&void 0!==t[e]&&"function"!=typeof t[e])throw new TypeError(`this.suspense(signalRef, views) view "${e}" must be a function.`);return t}(o),c=[];for(const o of["loading","ready","error"]){const s=i[o];if(!s)continue;const l=e(t.attributes,"async",o),f=u(s.call(E,r));c.push(`<template ${l}="${n(a)}">${f}</template>`)}return s(c.join(""))},on(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component lifecycle event must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Component lifecycle "${e}" requires a function.`);const r="mount"===e?"attach":e;if("attach"!==r)if("visible"!==r){if("destroy"!==r)throw new Error(`Unsupported component lifecycle event "${e}".`);c.push(()=>t.call(E))}else i.push(e=>t.call(E,e));else a.push(e=>t.call(E,e))},onMount(e){E.on("attach",e)},onVisible(e){E.on("visible",e)}};return E;function $(e,t){const n=w(r,e);return f.register(n,e=>t.call({...E,...e},e)),o.push(()=>f.unregister?.(n)),n}}({runtime:o,scope:c,cleanups:u,attachHooks:l,visibleHooks:f,destroyHooks:p,renderScopedTemplate:v}),E=t.call(S,r);if(E&&"function"==typeof E.then)throw new TypeError(`Component "${m(t)}" returned a Promise. Async components are not supported by synchronous renderComponent(). Use an async partial or handler instead.`);return{html:v(E),attach(e){for(let t=0;t<l.length;t+=1){const r=l[t];o.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&u.push(t)},{scope:c,key:`attach:${t}`})??$(r,e)}},mount(e){this.attach(e)},visible(e,t){if(0===f.length)return;const r=t(e,()=>{for(let t=0;t<f.length;t+=1){const r=f[t];o.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&u.push(t)},{scope:c,key:`visible:${t}`})??A(r,e)}});"function"==typeof r&&u.push(r)},cleanup(){for(;p.length>0;)p.pop()?.();for(o.scheduler?.markScopeDestroyed(c);u.length>0;)u.pop()?.();for(;h.length>0;)o.loader?._releaseBinding?.(h.pop())}};function $(e,t){const r=e(t);"function"==typeof r&&u.push(r)}function A(e,t){const r=e(t);"function"==typeof r&&u.push(r)}}function w(e,t){if("string"!=typeof t||0===t.length)throw new TypeError("Scoped signal or handler name must be a non-empty string.");return`${e}.${t}`}function m(e){return e.displayName||e.name||"anonymous"}return{defineComponent:h,createComponentRegistry:function(e={},t={}){const r=t.registry??u(),n=t.type??"component",o=r._map(n),s=t.lazyRegistry??l(t),a=new Map,i=c({register(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");if(!y(t)&&"function"!=typeof t&&!f(t))throw new TypeError(`Component "${e}" must be a component function.`);if(o.has(e))throw new Error(`Component "${e}" is already registered.`);return o.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))i.register(t,r);return i},unregister(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");return a.delete(e),o.delete(e)},resolve(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");const t=o.get(e);return f(t)?(a.has(e)||a.set(e,async function(...r){const o=await s.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Component "${e}" did not resolve to a function.`);return o.apply(this,r)}),a.get(e)):t},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)||i.register(t,r);return i}},r,n);return i.registerMany(e),i},isComponent:y,renderComponent:g,component:h}})(),c=(()=>{const e=Symbol.for("@async/framework.serverResult"),t=Symbol("@async/framework.serverResultInvocation");async function r(e,r={}){if(!h(e))return e;const n=function(e={}){return e[t]??{applied:new WeakSet}}(r);if(n.applied.has(e))return e;if(n.applied.add(e),e.error)throw(o=e.error)instanceof Error?o:o&&"object"==typeof o&&"string"==typeof o.message?Object.assign(new Error(o.message),o):new Error(String(o));var o;if(e.signals&&r.signals)for(const[t,n]of Object.entries(e.signals))r.signals.set?.(t,n);return e.cache?.browser&&r.cache?.restore&&r.cache.restore(e.cache.browser),e.boundary&&Object.hasOwn(e,"html")&&r.loader?.swap?.(e.boundary,e.html),e.redirect&&await(r.router?.navigate?.(e.redirect)),e}async function n(e,t={}){return await r(e,t),o(e)}function o(e){return h(e)?Object.hasOwn(e,"value")?e.value:void 0:e}function s(e={}){const r=e[t]??{applied:new WeakSet};return{...e,[t]:r}}function a(e={}){const t=f(e);if(t)return p(new t.ownerDocument.defaultView.FormData(t));const r=e.element??e.el??e.event?.target;return r?{value:"value"in r?r.value:void 0,checked:"checked"in r?r.checked:void 0,dataset:r.dataset?{...r.dataset}:{}}:{}}function i(e,t={},r=()=>({})){const n=new Map;return function o(s){const a=s.join(".");if(n.has(a))return n.get(a);const c=new Proxy(async(...t)=>{if(0===s.length)throw new Error("Server namespace is not directly callable.");const n=r()??{};return e(s.join("."),t,n)},{get(n,a){if("then"!==a)return a in n?n[a]:0===s.length&&"_withContext"===a?(n={})=>i(e,t,()=>({...r()??{},...n})):0===s.length&&"run"===a&&"function"==typeof t.run?(e,n=[],o={})=>t.run(e,n,{...r()??{},...o}):0===s.length&&Object.hasOwn(t,a)?t[a]:a===Symbol.toStringTag?"AsyncServerNamespace":"toString"===a?()=>0===s.length?"server":`server.${s.join(".")}`:o([...s,String(a)])}});return n.set(a,c),c}([])}function c(e=[],t){const r={};for(const n of e)r[n]=u(t,n);return r}function u(e,t){if(!e||"function"!=typeof e.get)throw new Error(`Signal "${t}" cannot be read without a signal registry.`);return e.get(t)}function l(e,t,{forServer:r}={}){if(("$event"===e||"$el"===e)&&r)throw new Error(`${e} cannot be passed to a server command.`);if("$event"===e)return t.event;if("$el"===e)return t.element??t.el;if("$value"===e){const e=t.element??t.el??t.event?.target;return e?.value}if("$checked"===e){const e=t.element??t.el??t.event?.target;return e?.checked}if("$form"===e){const e=f(t);return e?p(new e.ownerDocument.defaultView.FormData(e)):{}}if("$dataset"===e){const e=t.element??t.el??t.event?.target;return e?.dataset?{...e.dataset}:{}}throw new Error(`Event local "${e}" is not supported.`)}function f(e){const t=e.event,r=e.element??e.el??t?.target;return"FORM"===r?.tagName?r:"submit"===t?.type&&"FORM"===t.target?.tagName?t.target:"submit"===t?.type&&r?.form?r.form:null}function p(e){const t={};for(const[r,n]of e.entries())Object.hasOwn(t,r)?t[r]=Array.isArray(t[r])?[...t[r],n]:[t[r],n]:t[r]=n;return t}function d(e,t=new Set){if("bigint"==typeof e)throw new Error("Server proxy JSON transport does not support BigInt values.");if(null==e||"object"!=typeof e)return;if(t.has(e))throw new Error("Server proxy JSON transport does not support circular values.");t.add(e);const r=Object.prototype.toString.call(e);if("[object File]"===r||"[object Blob]"===r||"[object FormData]"===r)throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");if(function(e,t=Object.prototype.toString.call(e)){return"[object URLSearchParams]"===t||"[object Headers]"===t||"[object Request]"===t||"[object Response]"===t||"[object ReadableStream]"===t||"[object ArrayBuffer]"===t||ArrayBuffer.isView(e)}(e,r))throw new Error("Server proxy JSON transport does not support URLSearchParams, Headers, Request, Response, ReadableStream, ArrayBuffer, or typed array values yet.");if(Array.isArray(e)){for(const r of e)d(r,t);t.delete(e)}else{for(const r of Object.values(e))d(r,t);t.delete(e)}}function h(t){return!(!t||"object"!=typeof t||Array.isArray(t)||!0!==t[e]&&1!==t.__async_server_result__)}function y(e){if("string"!=typeof e||0===e.length)throw new TypeError("Server function id must be a non-empty string.")}return{createServerProxy:function({endpoint:e="/__async/server",transport:t,signals:r,loader:o,router:u,cache:l,scheduler:f,headers:p={}}={}){if("function"!=typeof t)throw new TypeError("createServerProxy(...) requires a transport function.");const h={signals:r,loader:o,router:u,cache:l,scheduler:f};async function g(r,o=[],i={}){y(r);const u=s({...h,...i}),l={args:o,input:i.input??a(u),signals:i.signalValues??c(i.signalPaths,u.signals)};d(l);const f=await t(function(e,t){return`${String(e).replace(/\/$/,"")}/${encodeURIComponent(t)}`}(e,r),{method:"POST",headers:{"content-type":"application/json",...p},body:JSON.stringify(l),signal:i.abort});if(function(e,t){if(!t||"object"!=typeof t)throw new Error(`Server function "${e}" transport returned an invalid response: expected a fetch Response-like object.`);if("boolean"!=typeof t.ok)throw new Error(`Server function "${e}" transport returned an invalid response: missing boolean ok.`);if(!t.headers||"function"!=typeof t.headers.get)throw new Error(`Server function "${e}" transport returned an invalid response: missing headers.get(name).`)}(r,f),!f.ok)throw new Error(`Server function "${r}" failed with ${f.status}.`);return n(await async function(e,t){if(204===t.status)return;if((t.headers.get("content-type")??"").includes("application/json")){if("function"!=typeof t.json)throw new Error(`Server function "${e}" transport returned an invalid response: missing json().`);try{return await t.json()}catch(t){throw new Error(`Server function "${e}" returned invalid JSON: ${r=t,r instanceof Error?r.message:String(r)}`,{cause:t})}}var r;if("function"!=typeof t.text)throw new Error(`Server function "${e}" transport returned an invalid response: missing text().`);return t.text()}(r,f),u)}return i(g,{run:g,_setContext(e={}){Object.assign(h,e)}},()=>h)},resolveServerCommandArguments:function(e,t={}){const r=[],n={},o=[];for(const s of e){if("local"===s.type){r.push(l(s.name,t,{forServer:!0}));continue}const e=u(t.signals,s.path);r.push(e),n[s.path]=e,o.push(s.path)}return{args:r,signalValues:n,signalPaths:o}},applyServerResult:r,consumeServerResult:n,unwrapServerResult:o,createServerResultContext:s,defaultInput:a,createServerNamespace:i,createSignalReader:function(e){return e&&"function"!=typeof e.get?{get:t=>function(e,t){return String(t).split(".").reduce((e,t)=>e?.[t],e)}(e,t),snapshot:()=>({...e})}:e},assertServerId:y}})(),u=(()=>{const{defaultInput:e,resolveServerCommandArguments:n}=c,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:a,isLazyDescriptor:i}=t,u=new Set(["prevent","preventDefault","stopPropagation","stopImmediatePropagation"]),l={prevent:f,preventDefault:f,stopPropagation(){this.event?.stopPropagation?.()},stopImmediatePropagation(){this.event?.stopImmediatePropagation?.()}};function f(){this.event?.preventDefault?.()}function p(e){if("string"!=typeof e||0===e.trim().length)throw new TypeError("Handler ref must be a non-empty string.");return e.split(";").map(e=>e.trim()).filter(Boolean).map(h)}function d(e){if("string"!=typeof e||0===e.length)throw new TypeError("Handler id must be a non-empty string.")}function h(e){if(e.startsWith("server."))return function(e){const t=e.indexOf("(");if(-1===t||!e.endsWith(")"))throw new Error(`Server command "${e}" must be called with parentheses.`);const r=e.slice(7,t).trim();if(!function(e){return/^[^.\s();]+(?:\.[^.\s();]+)*$/.test(e)}(r))throw new Error(`Server command "${e}" has an invalid function id.`);return{type:"server",id:r,args:y(e.slice(t+1,-1))}}(e);if(e.includes("(")||e.includes(")"))throw new Error(`Command "${e}" is not supported.`);return{type:"handler",id:e}}function y(e){return 0===e.trim().length?[]:e.split(",").map(e=>e.trim()).filter(Boolean).map(g)}function g(e){if(!/^[^\s,();]+$/.test(e))throw new Error(`Argument "${e}" is not supported.`);return e.startsWith("$")?{type:"local",name:e}:{type:"signal",path:e}}return{createHandlerRegistry:function(t={},r={}){const c=r.registry??s(),f=r.type??"handler",h=c._map(f),y=r.lazyRegistry??a(r),g=new Map,w=o({register(e,t){if(d(e),"function"!=typeof t&&!i(t))throw new TypeError(`Handler "${e}" must be a function.`);if(h.has(e))throw new Error(`Handler "${e}" is already registered.`);return h.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))w.register(t,r);return w},unregister:e=>(d(e),g.delete(e),h.delete(e)),resolve(e){d(e);const t=h.get(e);return i(t)?(g.has(e)||g.set(e,async function(...r){const n=await y.resolve(f,e,t);if("function"!=typeof n)throw new TypeError(`Handler "${e}" did not resolve to a function.`);return n.apply(this,r)}),g.get(e)):t},async run(t,r={}){const o=p(t),s=[];let a=!1;const i={...r,handlers:w,input:r.input??e(r),stop(){a=!0}};for(const e of o){if(a)break;if("server"===e.type){if(!i.server||"function"!=typeof i.server.run)throw new Error(`Server command "${e.id}" cannot run without a server registry.`);const t=n(e.args,i),r=await i.server.run(e.id,t.args,{...i,signalPaths:t.signalPaths,signalValues:t.signalValues});s.push(r);continue}const t=w.resolve(e.id);if(!t)throw new Error(`Handler "${e.id}" is not registered.`);const r=await t.call(i,i);u.has(e.id)&&t===l[e.id]||s.push(r)}return s},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))h.has(t)||w.register(t,r);return w}},c,f);return function(e,t){for(const[r,n]of Object.entries(l))if(t.has(r)){if(t.get(r)!==n)throw new Error(`Handler "${r}" is already registered.`)}else e.register(r,n)}(w,h),w.registerMany(t),w},parseHandlerRef:p,isHandlerToken:function(e){return u.has(e)}}})(),l=(()=>{const e=["binding","lifecycle","effect","async","post"];function t(e){return"object"==typeof e&&null!==e||"function"==typeof e}function r(){}return{createScheduler:function(n={}){const o=[...n.phases??e],s=new Map(o.map(e=>[e,[]])),a=new Map,i=new WeakSet,c=new Set,u=new WeakMap,l="function"==typeof n.onError?n.onError:void 0,f=n.maxDepth??100,p=n.strategy??"microtask";let d=!1,h=!1,y=!1,g=0,w=0,m=0;const b={strategy:p,phases:o,batch(e){if("function"!=typeof e)throw new TypeError("scheduler.batch(fn) requires a function.");A(),g+=1;let t=!1;try{const r=e();return r&&"function"==typeof r.then?(t=!0,Promise.resolve(r).finally(()=>{g-=1,v()})):r}finally{!t&&g>0&&(g-=1,v())}},enqueue(e,t,n={}){if(A(),function(e){if(!s.has(e))throw new Error(`Unknown scheduler phase "${e}".`)}(e),"function"!=typeof t)throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");const o=n.scope;if(j(o))return r;const i=void 0===n.key?void 0:`${e}:${function(e){return void 0===e?"global":"object"==typeof e&&null!==e||"function"==typeof e?(u.has(e)||u.set(e,"scope:"+ ++m),u.get(e)):String(e)}(o)}:${String(n.key)}`;if(i&&a.has(i))return a.get(i).cancel;const c={id:++w,phase:e,fn:t,scope:o,boundary:n.boundary,key:i,canceled:!1,cancel(){c.canceled=!0,c.key&&a.delete(c.key)}};return s.get(e).push(c),c.key&&a.set(c.key,c),v(),c.cancel},afterFlush:(e,t={})=>b.enqueue("post",e,t),async flush(){if(A(),h)return;y=!1,h=!0;let e=0;try{for(;E();){if(e+=1,e>f)throw new Error(`Scheduler exceeded maxDepth ${f}.`);for(const e of o)await S(e)}}finally{h=!1,E()&&v()}},async flushScope(e){if(A(),h)return;y=!1,h=!0;let t=0;try{for(;$(e);){if(t+=1,t>f)throw new Error(`Scheduler exceeded maxDepth ${f}.`);for(const t of o)await S(t,e)}}finally{h=!1,E()&&v()}},cancelScope(e){if(void 0===e)return b;for(const t of s.values())for(const r of t)r.scope===e&&r.cancel();return b},markScopeDestroyed:e=>(void 0!==e&&(t(e)?i.add(e):c.add(e),b.cancelScope(e)),b),reviveScope:e=>(void 0!==e&&(t(e)?i.delete(e):c.delete(e)),b),isScopeDestroyed:e=>j(e),inspect(){const e={};for(const[t,r]of s)e[t]=r.filter(e=>!e.canceled).length;return{strategy:p,phases:[...o],pending:e,scopesDestroyed:c.size,flushing:h,scheduled:y}},destroy(){d=!0;for(const e of s.values()){for(const t of e)t.cancel();e.length=0}a.clear(),c.clear()}};return b;function v(){var e;"manual"===p||d||h||g>0||y||(y=!0,e=()=>{d||b.flush()},"function"!=typeof queueMicrotask?Promise.resolve().then(e):queueMicrotask(e))}async function S(e,t){const r=s.get(e),n=[],o=[];for(const e of r.splice(0))e.canceled||(void 0===t||e.scope===t?o.push(e):n.push(e));r.push(...n);for(const e of o)if(e.key&&a.delete(e.key),!e.canceled&&!j(e.scope))try{await e.fn()}catch(t){if(!l)throw t;l(t,e)}}function E(){for(const e of s.values())if(e.some(e=>!e.canceled))return!0;return!1}function $(e){for(const t of s.values())if(t.some(t=>!t.canceled&&t.scope===e))return!0;return!1}function A(){if(d)throw new Error("Scheduler has been destroyed.")}function j(e){return void 0!==e&&(t(e)?i.has(e):c.has(e))}}}})(),f=(()=>{const{renderComponent:e}=i,{createHandlerRegistry:t}=u,{createScheduler:r}=l,{createSignalRegistry:n,isSignalRef:a}=s,{matchAttribute:c,normalizeAttributeConfig:f,readAttribute:p}=o,d="__async:inline:";function h({root:o,signals:s,handlers:i,server:u,router:l,cache:h,attributes:E,scheduler:O}={}){const T=o?.ownerDocument??o??globalThis.document,C=o??T,q=s??n(),M=i??t(),x=O??r(),L=!O,D=f(E),B=new Set,P=new WeakMap,N=new WeakMap,z=new WeakSet,H=new WeakSet,U=new WeakMap,W=new WeakSet,V=new Map,I=new WeakMap;let F=0,J=!1;const K={root:C,signals:q,handlers:M,server:u,router:l,cache:h,scheduler:x,attributes:D,start:()=>(ne(),K.scan(C),K),scan:(e=C)=>(ne(),function(e){for(const t of j(e))x.reviveScope?.(t)}(e),function(e){for(const t of j(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"signal");if(r){if("text"===r){const r=t.getAttribute(e);G(t,`text:${r}`,r,e=>{t.textContent=e??""});continue}if("value"===r){const r=t.getAttribute(e);G(t,`value:${r}`,r,e=>{"value"in t&&t.value!==String(e??"")?t.value=e??"":"value"in t||t.setAttribute("value",e??"")}),Q(t,r);continue}if(r.startsWith("attr:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`attr:${n}:${o}`,o,e=>$(t,n,e));continue}if(r.startsWith("prop:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`prop:${n}:${o}`,o,e=>A(t,n,e));continue}if(r.startsWith("class:")){const n=r.slice(6),o=t.getAttribute(e);""===n||"{}"===n?Y(t,n,o):G(t,`class:${n}:${o}`,o,e=>{t.classList.toggle(n,Boolean(e))});continue}if("class"===r){const r=t.getAttribute(e);Y(t,"{}",r)}}}}(e),function(e){for(const t of j(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"class");null!=r&&Y(t,r,t.getAttribute(e))}}(e),function(e){for(const t of j(e))if("function"==typeof t.getAttributeNames)for(const e of t.getAttributeNames()){const r=c(e,D,"on");r&&"attach"!==r&&"mount"!==r&&"visible"!==r&&Z(t,r,t.getAttribute(e))}}(e),function(e){for(const t of j(e)){if(W.has(t))continue;const e=R(t,D);if(null!=e){if(!U.has(t)){const r=S(t,e,D);if(0===Object.keys(r).length||!q.has(e))continue;const n={id:e,templates:r,cleanup:q.subscribe(`${e}.$status`,()=>{x.enqueue("binding",()=>X(t),{scope:t,key:`boundary:${e}`})})};U.set(t,n),oe(n.cleanup,t)}X(t)}}}(e),function(e){for(const t of j(e)){const e=ee(t,["attach","mount"]);if(0!==e.length&&!z.has(t)){z.add(t);for(const r of e)ue(t,()=>te(t,r),`attach:${r}`)}}for(const t of j(e)){const e=p(t,D,"on","visible");null!=e&&(H.has(t)||(H.add(t),oe(re(t,()=>ue(t,()=>te(t,e),`visible:${e}`)),t)))}}(e),K),swap(e,t){ne();const r=function(e,t,r){for(const n of j(e))if(R(n,r)===String(t))return n;return null}(C,e,D);if(!r)throw new Error(`Boundary "${e}" was not found.`);return ae(r),r.replaceChildren(_(t,T)),K.scan(r),r},mount(t,r,n={}){ne();const o=e(r,n,{signals:q,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,attributes:D});return ae(t),t.replaceChildren(_(o.html,t.ownerDocument)),K.scan(t),o.mount(t),o.visible(t,K._observeVisible),oe(o.cleanup,t,"children"),o},destroy(){if(!J){J=!0,function(e){for(const t of j(e))x.markScopeDestroyed(t)}(C);for(const e of[...B])se(e);B.clear(),L&&x.destroy()}},_observeVisible:(e,t)=>re(e,t),_registerBinding(e){const t=`${d}${++F}`;return V.set(t,e),t},_releaseBinding(e){V.delete(e)}};function Z(e,t,r){const n=`${t}:${r}`,o=P.get(e)??new Set;if(o.has(n))return;o.add(n),P.set(e,o);const s=async t=>{try{await x.batch(()=>M.run(r,{signals:q,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,event:t,element:e,el:e,root:C}))}catch(t){k(e,t)}};e.addEventListener(t,s),oe(()=>e.removeEventListener(t,s),e)}function Y(e,t,r){if(""===t||"{}"===t){const t=b(e);let n=new Set;return void G(e,`class:{}:${r}`,r,r=>{const o=y(r),s=b(e);for(const e of n)o.has(e)||t.has(e)||s.delete(e);for(const e of o)s.add(e);v(e,s),n=o},{rawInline:!0})}G(e,`class:${t}:${r}`,r,r=>{!function(e,t,r){const n=b(e);for(const e of y(t))r?n.add(e):n.delete(e);v(e,n)}(e,t,Boolean(r))})}function G(e,t,r,n,o={}){const s=N.get(e)??new Set;if(s.has(t))return;s.add(t),N.set(e,s);const a=()=>function(e,t={}){if(m(e)){const r=V.get(e);return t.rawInline?r:g(r)}return q.get(e)}(r,o);n(a()),oe(function(e,t){if(!m(e))return q.subscribe(e,t);const r=w(V.get(e)).map(e=>e.subscribe(t));return()=>{for(const e of r)e()}}(r,()=>{x.enqueue("binding",()=>n(a()),{scope:e,key:t})}),e)}function Q(e,t){Z(e,"input",`__async:set:${t}`),Z(e,"change",`__async:set:${t}`),M.resolve(`__async:set:${t}`)||M.register(`__async:set:${t}`,({element:e})=>{!function(e,t){if(!m(e))return q.set(e,t);const r=V.get(e);if(a(r))return r.set(t);throw new Error(`Inline binding "${e}" is not writable.`)}(t,e.value)})}function X(e){const t=U.get(e);if(!t)return;const r=q.get(`${t.id}.$status`),n=function(e,t){return"ready"===t?e.ready??e.loading??e.error:"error"===t?e.error??e.ready??e.loading:e.loading??e.ready??e.error}(t.templates,r);if(n){ae(e),e.replaceChildren(n.content.cloneNode(!0)),W.add(e);try{K.scan(e)}finally{W.delete(e)}}}function ee(e,t){const r=[];for(const n of t){const t=p(e,D,"on",n);null!=t&&r.push(t)}return r}async function te(e,t){try{const r=await M.run(t,{signals:q,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,element:e,el:e,root:C});for(const t of r)"function"==typeof t&&oe(t,e)}catch(t){k(e,t)}}function re(e,t){const r=(e.ownerDocument?.defaultView??globalThis).IntersectionObserver??globalThis.IntersectionObserver;if(!r)return x.enqueue("lifecycle",()=>{J||t(e)},{scope:e,key:"visible:fallback"}),()=>{};const n=new r(r=>{r.some(e=>e.isIntersecting)&&(n.disconnect(),t(e))});return n.observe(e),()=>n.disconnect()}function ne(){if(J)throw new Error("Loader has been destroyed.")}function oe(e,t,r="self"){if("function"!=typeof e)return e;if(B.add(e),t){const n=I.get(t)??[];n.push({cleanup:e,mode:r}),I.set(t,n)}return e}function se(e){"function"==typeof e&&B.has(e)&&(B.delete(e),e())}function ae(e){ce(e,"children");for(const t of[...e.childNodes??[]])ie(t)}function ie(e){if(1===e.nodeType)for(const t of j(e))ce(t),x.markScopeDestroyed(t)}function ce(e,t){const r=I.get(e);if(!r)return;const n=[];for(const e of r)t&&e.mode!==t?n.push(e):se(e.cleanup);n.length>0?I.set(e,n):I.delete(e)}function ue(e,t,r){x.enqueue("lifecycle",t,{scope:e,key:r})}return q._setContext?.({server:K.server,router:K.router,loader:K,cache:K.cache,scheduler:x}),K.server?._setContext?.({signals:q,handlers:M,loader:K,router:K.router,cache:K.cache,scheduler:x}),K}function y(e,t=new Set){if(null==e||!1===e)return t;if(a(e)){const r=e.value;return!0===r?(t.add(e.id.split(".").at(-1)),t):y(r,t)}if("string"==typeof e){for(const r of e.split(/\s+/).filter(Boolean))t.add(r);return t}if(Array.isArray(e)){for(const r of e)y(r,t);return t}if("object"==typeof e){for(const[r,n]of Object.entries(e))(a(n)?n.value:n)&&y(r,t);return t}return!0!==e&&t.add(String(e)),t}function g(e){return a(e)?e.value:Array.isArray(e)?e.map(g):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,g(t)])):e}function w(e,t=new Map){if(a(e))return t.set(e.id,e),[...t.values()];if(Array.isArray(e)){for(const r of e)w(r,t);return[...t.values()]}if(e&&"object"==typeof e)for(const r of Object.values(e))w(r,t);return[...t.values()]}function m(e){return"string"==typeof e&&e.startsWith(d)}function b(e){return y(e.getAttribute("class")??"")}function v(e,t){const r=[...t].join(" ");0!==r.length?e.setAttribute("class",r):e.removeAttribute("class")}function S(e,t,r){const n={};for(const o of[...e.children].filter(e=>"TEMPLATE"===e.tagName))E(o,"loading",t,e,r)&&(n.loading=o),E(o,"ready",t,e,r)&&(n.ready=o),E(o,"error",t,e,r)&&(n.error=o);return n}function E(e,t,r,n,o){return p(e,o,"async",t)===r||O(n)&&e.hasAttribute?.(t)}function $(e,t,r){if(!1===r||null==r)return e.removeAttribute(t),void(t in e&&(e[t]=!1));e.setAttribute(t,!0===r?"":String(r)),t in e&&(e[t]=r)}function A(e,t,r){e[t]=null!=r?r:""}function j(e){return function(e,t){const r=[];return 1===e?.nodeType&&e.matches?.(t)&&r.push(e),r.push(...e?.querySelectorAll?.(t)??[]),r}(e,"*")}function R(e,t){return O(e)&&e.hasAttribute?.("for")?e.getAttribute("for"):p(e,t,"async","boundary")}function O(e){return"ASYNC-SUSPENSE"===e?.tagName}function _(e,t){if(11===e?.nodeType)return e;if("TEMPLATE"===e?.tagName)return e.content.cloneNode(!0);if(e?.nodeType){const r=t.createDocumentFragment();return r.append(e),r}const r=t.createElement("template");return r.innerHTML=String(e??""),r.content.cloneNode(!0)}function k(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;e.dispatchEvent(new r("async:error",{bubbles:!0,detail:{error:t}}))}return{Loader:h,AsyncLoader:h}})(),p=(()=>{const{isTemplateResult:e,renderTemplate:n}=a,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t;function u(e,t={}){return r=e,Boolean(r&&"object"==typeof r&&!Array.isArray(r)&&(Object.hasOwn(r,"html")||Object.hasOwn(r,"signals")||Object.hasOwn(r,"boundary")||Object.hasOwn(r,"redirect")||Object.hasOwn(r,"status")||Object.hasOwn(r,"cache")))?{...e,html:Object.hasOwn(e,"html")?l(e.html,t):e.html}:{html:l(e,t)};var r}function l(t,r){return t?.nodeType||"string"==typeof t?t:(e(t),n(t,function(e){return{attributes:e.loader?.attributes,signals:e.signals,bind:e.loader?._registerBinding?.bind(e.loader)}}(r)))}function f(e){if("string"!=typeof e||0===e.length)throw new TypeError("Partial id must be a non-empty string.")}return{createPartialRegistry:function(e={},t={}){const r=t.registry??s(),n=t.type??"partial",a=r._map(n),l=t.lazyRegistry??i(t),p=new Map,d=o({register(e,t){if(f(e),"function"!=typeof t&&!c(t))throw new TypeError(`Partial "${e}" must be a function.`);if(a.has(e))throw new Error(`Partial "${e}" is already registered.`);return a.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))d.register(t,r);return d},unregister:e=>(f(e),p.delete(e),a.delete(e)),resolve(e){f(e);const t=a.get(e);return c(t)?(p.has(e)||p.set(e,async function(...r){const o=await l.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Partial "${e}" did not resolve to a function.`);return o.apply(this,r)}),p.get(e)):t},async render(e,t={},r={}){f(e);const n=d.resolve(e);if(!n)throw new Error(`Partial "${e}" is not registered.`);const o={...r,id:e,props:t,cache:r.cache,partials:d};return u(await n.call(o,t),o)},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))a.has(t)||d.register(t,r);return d}},r,n);return d.registerMany(e),d},normalizePartialResult:u}})(),d=(()=>{const{Loader:e}=f,{createHandlerRegistry:t}=u,{createScheduler:n}=l,{createSignalRegistry:a}=s,{applyServerResult:i}=c,{createRegistryStore:p}=r,{normalizeAttributeConfig:d}=o;function h(e,t={}){return{...t,partial:e}}const y=h,g=new Set(["csr","spa","ssr","mpa"]);function w(e={},t={}){const r=t.registry??p(),n=t.type??"route",o=r._map(n),s=[],a={registry:r,register(e,t){if(A(e),s.some(t=>t.pattern===e))throw new Error(`Route "${e}" is already registered.`);const r=m(e,t);return o.set(e,r.definition),s.push(r),E(s),r},registerMany(e){for(const[t,r]of Object.entries(e??{}))a.register(t,r);return a},unregister(e){A(e);const t=s.findIndex(t=>t.pattern===e);return-1!==t&&s.splice(t,1),o.delete(e)},match(e){const t=function(e){return e instanceof URL?e:new URL(String(e),globalThis.location?.href??"http://localhost/")}(e).pathname;for(const e of s){const r=e.regex.exec(t);if(!r)continue;const n={};return e.keys.forEach((e,t)=>{n[e]=S(r[t+1]??"")}),{pattern:e.pattern,params:n,route:e.definition}}return null},entries:()=>s.map(({pattern:e,definition:t})=>({pattern:e,route:t})),keys:()=>[...o.keys()],inspect:()=>r.entries(n),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)?i(t,o.get(t)):a.register(t,r);return a}};for(const[e,t]of o)i(e,t);return a.registerMany(e),a;function i(e,t){if(s.some(t=>t.pattern===e))return;const r=m(e,t);o.set(e,r.definition),s.push(r),E(s)}}function m(e,t){const r="string"==typeof t?h(t):t,{regex:n,keys:o}=function(e){const t=[];if("*"===e)return{regex:/^.*$/,keys:t};if("/"===e)return{regex:/^\/$/,keys:t};const r=e.split("/").map(e=>e.startsWith(":")?(t.push(e.slice(1)),"([^/]+)"):String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return{regex:new RegExp(`^${r}$`),keys:t}}(e);return{pattern:e,regex:n,keys:o,score:$(e),definition:r}}function b(e,t){return e?.closest?.(t)}function v(e){return Object.fromEntries(e.searchParams.entries())}function S(e){try{return decodeURIComponent(e)}catch{return e}}function E(e){e.sort((e,t)=>t.score-e.score||t.pattern.length-e.pattern.length)}function $(e){return"*"===e?-1:e.split("/").filter(Boolean).reduce((e,t)=>"*"===t?e:t.startsWith(":")?e+2:e+4,"/"===e?3:0)}function A(e){if("string"!=typeof e||"*"!==e&&!e.startsWith("/"))throw new TypeError('Route pattern must be a path string or "*".')}return{defineRoute:h,createRouteRegistry:w,createRouter:function({mode:r="ssr",root:o,boundary:s="route",routes:c=w(),loader:u,signals:l,handlers:f,server:p,cache:h,partials:y,attributes:m,scheduler:S}={}){!function(e){if(!g.has(e))throw new TypeError(`Unknown router mode "${e}".`)}(r);const E=o?.ownerDocument??o??globalThis.document,$=o??E,A=l??u?.signals??a(),j=f??u?.handlers??t(),R=S??u?.scheduler??n(),O=!S&&!u?.scheduler,_=d(m??u?.attributes),k=u??e({root:$,signals:A,handlers:j,server:p,cache:h,scheduler:R,attributes:_}),T=!u,C=new Set;let q,M=!1,x=0;const L={mode:r,root:$,boundary:s,routes:c,loader:k,signals:A,handlers:j,server:p,cache:h,partials:y,scheduler:R,attributes:_,start:()=>(I(),k.router=L,A._setContext?.({router:L,loader:k,server:p,cache:h,scheduler:R}),T&&k.start(),"mpa"===r||"ssr"===r?(N(),L):(function(){const e=e=>{const t=b(e.target,"a[href]");t&&!function(e,t){if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;if(t.target||t.hasAttribute("download"))return!0;const r=V(t.href),n=W();return r.origin!==n.origin||function(e,t,r){return e.origin===t.origin&&e.pathname===t.pathname&&e.search===t.search&&(e.hash!==t.hash||!0===r.getAttribute?.("href")?.startsWith("#"))}(r,n,t)}(e,t)&&(e.preventDefault(),U(L.navigate(t.href)))},t=e=>{const t=b(e.target,"form");t&&!function(e){return"get"!==String(e.method||"get").toLowerCase()||V(e.action).origin!==W().origin}(t)&&(e.preventDefault(),U(L.navigate(function(e){const t=V(e.action||e.ownerDocument.defaultView.location.href),r=new e.ownerDocument.defaultView.FormData(e);return t.search=new URLSearchParams(r).toString(),t.href}(t))))},r=()=>U(L.navigate(W(),{history:!1}));$.addEventListener?.("click",e),$.addEventListener?.("submit",t),E.defaultView?.addEventListener?.("popstate",r),C.add(()=>$.removeEventListener?.("click",e)),C.add(()=>$.removeEventListener?.("submit",t)),C.add(()=>E.defaultView?.removeEventListener?.("popstate",r))}(),"csr"===r?(U(L.navigate(W(),{replace:!0,initial:!0,source:"client"})),L):(N(),L))),match:e=>c.match(V(e)),prefetch(e){if(I(),"mpa"===r||"ssr"===r)return Promise.resolve(null);const t=L.match(e);return t?.route?.partial&&y?.resolve?.(t.route.partial)?y.render(t.route.partial,t.params,{...D(t),prefetch:!0}):Promise.resolve(null)},navigate:async(e,t={})=>(I(),"mpa"===r||"ssr"===r?(E.defaultView?.location?.assign?.(e),null):async function(e,t={}){const r=L.match(e);if(!r)return B(e,null),function(e){z(e,null,{pending:!1,error:new Error(`No route matched ${e.pathname}${e.search}`)})}(e),null;const n=B(e,r);z(e,r,{pending:!0,error:null});try{if(!r.route?.partial||!y?.resolve?.(r.route.partial)){const t=new Error(`Route "${e.pathname}" does not have a registered partial.`);return P(n)&&H({pending:!1,error:t}),null}const o=await y.render(r.route.partial,r.params,D(r,n));return P(n)?(await async function(e,t,r,n){P(n)&&(await i(e,{signals:A,loader:k,router:L,cache:h,scheduler:R,abort:n?.abort}),await R.flush(),P(n)&&(null==e?.html||e.boundary||e.redirect||(k.swap(s,e.html),await R.flush()),e?.redirect||!1===r.history||(r.replace?E.defaultView?.history?.replaceState?.({},"",t.href):E.defaultView?.history?.pushState?.({},"",t.href))))}(o,e,t,n),P(n)?(H({pending:!1,error:null}),o):null):null}catch(e){if(!P(n))return null;throw H({pending:!1,error:e}),e}}(V(e),t)),destroy(){if(!M){M=!0,q?.controller.abort(new Error("Router has been destroyed."));for(const e of C)e();C.clear(),O&&R.destroy()}}};return L;function D(e,t){return{params:e.params,route:e.route,router:L,signals:A,handlers:j,loader:k,server:p,cache:h,scheduler:R,abort:t?.abort}}function B(e,t){q?.controller.abort(new Error(`Router navigation superseded by ${e.pathname}${e.search}.`));const r=new AbortController,n={id:++x,controller:r,abort:r.signal,target:e,matched:t};return q=n,n}function P(e){return!M&&e&&q?.id===e.id&&!e.abort.aborted}function N(){const e=W();z(e,L.match(e),{pending:!1,error:null})}function z(e,t,r={}){A.ensure("router",{}),H({url:e.href,path:e.pathname,query:v(e),params:t?.params??{},route:t?.route??null,...r})}function H(e){A.ensure("router",{});for(const[t,r]of Object.entries(e))A.set(`router.${t}`,r)}function U(e){e.catch(e=>{M||(H({pending:!1,error:e}),function(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;"function"==typeof r&&e.dispatchEvent?.(new r("async:error",{bubbles:!0,detail:{error:t}}))}($,e))})}function W(){return V(E.defaultView?.location?.href??"http://localhost/")}function V(e){return e instanceof URL?e:new URL(String(e),E.defaultView?.location?.href??"http://localhost/")}function I(){if(M)throw new Error("Router has been destroyed.")}},route:y}})(),h=(()=>{const{createCacheRegistry:e}=n,{createComponentRegistry:a}=i,{createHandlerRegistry:h}=u,{Loader:y}=f,{createPartialRegistry:g}=p,{createRouteRegistry:w,createRouter:m}=d,{createScheduler:b}=l,{createServerNamespace:v}=c,{cloneSignalDeclaration:S,createSignal:E,createSignalRegistry:$}=s,{createRegistryStore:A}=r,{attributeName:j,normalizeAttributeConfig:R}=o,{createLazyRegistry:O,defineRegistrySnapshot:_,sameRegistryValue:k}=t,T=new Set(["signal","handler","server","partial","route","component","asyncSignal"]);function C(e,t={}){const r=A(void 0,{target:"browser"}),n=new Set,o=t.createRuntime??q,s={registry:r,use(e,t){const o=function(e,t){const r={signal:{},handler:{},server:{},partial:{},route:{},component:{},asyncSignal:{},cache:{browser:{},server:{}}};if("string"==typeof e){if(!T.has(e))throw new Error(`Unknown Async registry type "${e}".`);return r[e]=F(e,t),r}if(!e||"object"!=typeof e)throw new TypeError("Async.use(...) requires a registry type or module object.");for(const[t,n]of Object.entries(e))if("cache"!==t){if(!T.has(t))throw new Error(`Unknown Async registry type "${t}".`);r[t]=F(t,n)}else r.cache.browser={...n?.browser??{}},r.cache.server={...n?.server??{}};return r}(e,t);!function(e,t){for(const r of T)B(e,r,t[r]);B(e,"cache.browser",t.cache.browser),B(e,"cache.server",t.cache.server)}(r,o);for(const e of n)e._applyUse(o);return s},snapshot:()=>r.rawSnapshot(),start(e={}){const t=o(s,e).start();return s.runtime=t,t},attachRoot:e=>function(e){return e.runtime||e.start(),e.runtime}(s).attachRoot(e),detachRoot:e=>s.runtime?.detachRoot(e)??s,applySnapshot:(e,t={})=>s.runtime?(s.runtime.applySnapshot(e,t),s):(function(e,t={},r={}){const n=z(t);for(const[t,o]of Object.entries(n.signal))N(e,"signal",t,E(o),r);for(const t of["handler","server","partial","route","component","asyncSignal"])for(const[o,s]of Object.entries(n[t]))N(e,t,o,s,r)}(r,e,t),s),inspectRoots:()=>s.runtime?.inspectRoots()??{count:0,roots:[]},_attach:e=>(n.add(e),()=>s._detach(e)),_detach(e){n.delete(e)}};return e&&s.use(e),s}function q(t=M,r={}){const n=(q=t,Boolean(q&&"function"==typeof q.use&&"function"==typeof q.snapshot&&q.registry)?t:C(t??{})),o=r.target??"browser",s=r.scheduler??r.loader?.scheduler??b({strategy:"server"===o?"manual":"microtask"}),i=!r.scheduler&&!r.loader?.scheduler,c=R(r.attributes),u=r.lazyRegistry??O({registryAssets:r.registryAssets,importModule:r.importModule}),l=r.registry??function(e,{target:t}={}){const r=e.rawSnapshot();return A({...r,signal:D(r.signal)},{target:t})}(n.registry,{target:o}),f=r.signals??$(void 0,{registry:l,type:"signal",lazyRegistry:u}),p=r.handlers??h(void 0,{registry:l,type:"handler",lazyRegistry:u}),d=e(void 0,{registry:l,type:"cache.server"}),v=e(void 0,{registry:l,type:"cache.browser"}),S=r.serverFactory??I,E=r.server??S(void 0,{registry:l,type:"server"}),j=r.partials??g(void 0,{registry:l,type:"partial",lazyRegistry:u}),_=r.routes??w(void 0,{registry:l,type:"route"}),k=r.components??a(void 0,{registry:l,type:"component",lazyRegistry:u}),T=r.loader||Object.hasOwn(r,"root")?r.root:null;var q;let B=r.loader,N=r.router,H=!1,U=()=>{},F=!1,J=!1;const Z=new Map,Y=T??globalThis.document,G=r.snapshot??("browser"===o?x(Y,{attributes:c}):void 0);!function(e,t){try{e.cache=t}catch{}}(E,d);const Q={app:n,registry:l,target:o,signals:f,handlers:p,server:E,partials:j,routes:_,components:k,browser:{cache:v},loader:B,router:N,scheduler:s,attributes:c,start:()=>(ne(),F||(F=!0,"server"!==o?(te({cache:v}),f._setContext?.({server:E,loader:B,cache:v,scheduler:s}),B?(X(B.root,B),B.start(),ee(B.root)):null!=T&&Q.attachRoot(T)):(te({cache:d}),f._setContext?.({server:E,cache:d,scheduler:s}))),Q),use:(e,t)=>(n.use(e,t),Q),attachRoot(e){if(ne(),"server"===o)throw new Error("Server runtimes cannot attach DOM roots.");if(!e)throw new TypeError("runtime.attachRoot(root) requires a root.");if(Z.has(e))return Q;const t=0===Z.size&&B?B:y({root:e,signals:f,handlers:p,server:E,cache:v,scheduler:s,attributes:c});return X(e,t),t.start(),te({cache:v}),f._setContext?.({server:E,loader:Q.loader,cache:v,scheduler:s}),ee(e),Q},detachRoot(e){if(ne(),"server"===o)return Q;if(null==e){for(const e of new Set(Z.values()))e.destroy?.();return Z.clear(),N?.destroy?.(),N=void 0,H=!1,B=void 0,Q.loader=void 0,Q.router=void 0,Q}const t=Z.get(e);if(!t)return Q;if(t.destroy?.(),Z.delete(e),B===t){N?.destroy?.(),N=void 0,H=!1;const e=Z.values().next().value;B=e,Q.loader=e,Q.router=void 0,e&&ee(e.root)}return Q},inspectRoots:()=>({count:Z.size,roots:[...Z].map(([e,t])=>({root:e,loader:t,primary:t===B}))}),applySnapshot:(e,t={})=>(function(e,t={},r={}){const n=z(t);P(e,"asyncSignal",n.asyncSignal,null,r);for(const[t,r]of Object.entries(n.signal))W(e.signals,t,r);e.browser.cache.restore(n.cache.browser),P(e,"handler",n.handler,e.handlers,r),P(e,"server",n.server,e.server,r),P(e,"partial",n.partial,e.partials,r),P(e,"route",n.route,e.routes,r),P(e,"component",n.component,e.components,r)}(Q,e,t),Q),async render(e){ne(),te({cache:d}),f._setContext?.({server:E,cache:d,scheduler:s});const t=_.match(e);if(!t)return await s.flush(),{html:K("",{status:404,signals:f,browserCache:v,boundary:r.boundary??"route",attributes:c}),status:404,signals:f.snapshot(),cache:{browser:v.snapshot()}};const n=t.route.partial,o=n&&j.resolve(n)?await j.render(n,t.params,{params:t.params,route:t.route,signals:f,handlers:p,server:E,cache:d,browserCache:v,partials:j,scheduler:s,...re()}):{html:""};if(o.signals)for(const[e,t]of Object.entries(o.signals))V(f,e,t);o.cache?.browser&&v.restore(o.cache.browser),await s.flush();const a=o.status??200;return{html:K(o.html,{status:a,signals:f,browserCache:v,boundary:o.boundary??r.boundary??"route",attributes:c}),status:a,signals:f.snapshot(),cache:{browser:v.snapshot()}}},destroy(){if(J)return;J=!0,U(),N?.destroy?.();const e=new Set(Z.values());for(const t of e)t.destroy?.();Z.clear(),B&&!e.has(B)&&B?.destroy?.(),f.destroy?.(),i&&s.destroy()},_applyUse(e){!function(e,t){L(e.signals,e.registry,t.signal),L(e.handlers,e.registry,t.handler),L(e.server,e.registry,t.server),L(e.partials,e.registry,t.partial),L(e.routes,e.registry,t.route),L(e.components,e.registry,t.component),function(e,t,r){if(r&&0!==Object.keys(r).length)for(const[n,o]of Object.entries(r))e.has(t,n)||e.register(t,n,o)}(e.registry,"asyncSignal",t.asyncSignal),L(e.browser.cache,e.registry,t.cache.browser),L(e.server.cache,e.registry,t.cache.server)}(Q,e)}};return E.cache=d,Q.server.cache=d,Q.applySnapshot(G,{strict:r.strictSnapshots??!0}),U=n._attach(Q),Q;function X(e,t){Z.set(e,t),B||(B=t,Q.loader=t),t.server=E,t.cache=v,t.scheduler=s}function ee(e){!1!==N&&!H&&(N||function(e,t){return Boolean(t.routerOptions||t.mode||e.entries().length>0)}(_,r))&&Q.loader&&(N=N??m({mode:r.mode??"ssr",root:e,boundary:r.boundary??"route",routes:_,loader:Q.loader,signals:f,handlers:p,server:E,cache:v,partials:j,scheduler:s,attributes:c}),Q.router=N,Q.loader.router=N,te({cache:v,router:N}),N.start(),H=!0)}function te(e={}){const t=function(e){return"function"==typeof e?.registerMany}(E)?d:e.cache;E._setContext?.({signals:f,loader:B,router:N,cache:t,scheduler:s,requestContext:r.requestContext,...re()})}function re(){const e=(t=r.requestContext)?"function"==typeof t.get?t.get()??{}:"function"==typeof t.getStore?t.getStore()??{}:{}:{};var t;return{requestContext:e,request:e.request??r.request,headers:e.headers??r.headers,cookies:e.cookies??r.cookies,locals:e.locals??r.locals}}function ne(){if(J)throw new Error("Async app runtime has been destroyed.")}}const M=C();function x(e=globalThis.document,{attributes:t}={}){const r=R(t),n=j(r,"async","snapshot"),o=e?.ownerDocument??e??globalThis.document,s=e??o;if(!s?.querySelectorAll&&!o?.querySelectorAll)return{};const a={};for(const e of new Set([s,o]))if(e?.querySelectorAll)for(const t of e.querySelectorAll("script[type='application/json'], script")){if(!t.hasAttribute?.(n))continue;const e=t.textContent?.trim()??"";if(!e)continue;let r;try{r=JSON.parse(e)}catch(e){throw new Error(`Could not parse Async snapshot: ${e instanceof Error?e.message:String(e)}`)}H(a,r,{strict:!0})}return a}function L(e,t,r){r&&0!==Object.keys(r).length&&(e?.registry!==t?e?.registerMany?.(r):e._adoptMany?.(r))}function D(e={}){const t={};for(const[r,n]of Object.entries(e??{}))t[r]=S(n);return t}function B(e,t,r){for(const[n,o]of Object.entries(r??{}))e.register(t,n,o)}function P(e,t,r,n,o={}){if(r&&0!==Object.keys(r).length){for(const[n,s]of Object.entries(r)){if("asyncSignal"===t&&e.signals?.has?.(n)&&!e.registry.has(t,n))throw new Error(`Signal "${n}" is already registered.`);N(e.registry,t,n,s,o)}n?._adoptMany?.(r)}}function N(e,t,r,n,o={}){const s=o.strict??!0,a=e._map(t);if(a.has(r)){if(k(a.get(r),n)||U(a.get(r),n))return;if(s)throw new Error(`${t} "${r}" is already registered with a different value.`)}else e.set(t,r,n)}function z(e={}){return{signal:{...e.signals??{},...e.signal??{}},handler:{...e.handler??{}},server:{...e.server??{}},partial:{...e.partial??{}},route:{...e.route??{}},component:{...e.component??{}},asyncSignal:{...e.asyncSignal??{}},cache:{browser:{...e.entries?.browser??{},...e.cache?.browser??{}}}}}function H(e,t,r={}){const n=z(_(t));e.signal={...e.signal??e.signals??{},...n.signal},e.signals=e.signal,e.cache={...e.cache??{},browser:{...e.cache?.browser??{},...n.cache.browser}};for(const t of["handler","server","partial","route","component","asyncSignal"]){e[t]=e[t]??{};for(const[o,s]of Object.entries(n[t]))if(Object.hasOwn(e[t],o)){if(k(e[t][o],s)||U(e[t][o],s))continue;if(r.strict??1)throw new Error(`${t} "${o}" is already declared with a different value.`)}else e[t][o]=s}return e}function U(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function W(e,t,r){if(e.has?.(t)){const n=e._entry?.(t);return"function"==typeof n?._restore&&function(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))}(r)?void n._restore(r):void e.set(t,r)}e.register(t,E(r))}function V(e,t,r){if("function"==typeof e._setPath)return void e._setPath(t,r);const n=String(t).split(".")[0];e.has?.(n)?e.set(t,r):(e.register(n,E(t===n?r:{})),t!==n&&e.set(t,r))}function I(e={},t={}){const r=t.registry??A(),n=t.type??"server",o={},s={registry:r,register:(e,t)=>(r.register(n,e,t),e),registerMany(e){for(const[t,r]of Object.entries(e??{}))s.register(t,r);return s},unregister:e=>r.unregister(n,e),resolve(){},async run(e){throw new Error(`Server command "${e}" cannot run without a server proxy or server registry.`)},keys:()=>r.keys(n),entries:()=>r.entries(n),inspect:()=>r.entries(n),_setContext:(e={})=>(Object.assign(o,e),s),_adoptMany:()=>s};return s.registerMany(e),v((e,t,r)=>s.run(e,t,r),s,()=>o)}function F(e,t={}){if("signal"!==e)return{...t??{}};const r={};for(const[e,n]of Object.entries(t??{}))r[e]=J(n);return r}function J(e){return e&&"object"==typeof e&&"function"==typeof e.subscribe?e:E(e)}function K(e,{signals:t,browserCache:r,boundary:n,attributes:o}){const s={signals:t.snapshot(),cache:{browser:r.snapshot()}},a=j(o,"async","boundary"),i=j(o,"async","snapshot");return`<section ${a}="${c=n,String(c).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}">${e??""}</section><script type="application/json" ${i}>${function(e){return JSON.stringify(e).replaceAll("<","\\u003c")}(s)}<\/script>`;var c}return{defineApp:C,createApp:q,readSnapshot:x,Async:M}})(),y=(()=>{function e(e){if("string"!=typeof e||0===e.length)throw new TypeError("Boundary patch boundary must be a non-empty string.")}function t(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))}return{createBoundaryReceiver:function(r={}){const n=r.loader,o=r.signals??n?.signals,s=r.cache??n?.cache,a=r.scheduler??n?.scheduler,i=r.router??n?.router,c=r.recentLimit??50,u=!0===r.throwOnError,l="function"==typeof r.onApply?r.onApply:void 0,f="function"==typeof r.onIgnore?r.onIgnore:void 0,p="function"==typeof r.onError?r.onError:void 0,d="function"==typeof r.isScopeDestroyed?r.isScopeDestroyed:e=>a?.isScopeDestroyed?.(e)??a?.inspectDestroyed?.(e)??!1;if(!n||"function"!=typeof n.swap)throw new TypeError("createBoundaryReceiver(...) requires a loader with swap(boundary, html).");if(!Number.isInteger(c)||c<0)throw new TypeError("createBoundaryReceiver(...) recentLimit must be a non-negative integer.");const h=new Map,y=[];let g=!1;const w={async apply(r){if(g)throw new Error("Boundary receiver has been destroyed.");const c=function(r){if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError("receiver.apply(patch) requires a boundary patch object.");if(e(r.boundary),"number"!=typeof r.seq||!Number.isFinite(r.seq))throw new TypeError("Boundary patch seq must be a finite number.");if(void 0!==r.signals&&!t(r.signals))throw new TypeError("Boundary patch signals must be an object.");if(void 0!==r.cache&&!t(r.cache))throw new TypeError("Boundary patch cache must be an object.");if(void 0!==r.cache?.browser&&!t(r.cache.browser))throw new TypeError("Boundary patch cache.browser must be an object.");if(void 0!==r.redirect&&("string"!=typeof r.redirect||0===r.redirect.length))throw new TypeError("Boundary patch redirect must be a non-empty string.");if(void 0!==r.parentScope&&"string"!=typeof r.parentScope)throw new TypeError("Boundary patch parentScope must be a string.");if(void 0!==r.scope&&"string"!=typeof r.scope)throw new TypeError("Boundary patch scope must be a string.");const n=Object.hasOwn(r,"html")&&null!=r.html,o=r.signals&&Object.keys(r.signals).length>0,s=r.cache?.browser&&Object.keys(r.cache.browser).length>0,a=Boolean(r.redirect),i=Object.hasOwn(r,"error");if(!(n||o||s||a||i))throw new TypeError("Boundary patch must include html, signals, cache.browser, redirect, or error.");return r}(r),y=(w=c.boundary,h.has(w)||h.set(w,{lastSeq:-1/0,applied:0,ignored:0,errored:0,lastStatus:void 0}),h.get(w));var w,b;if(c.seq<=y.lastSeq){const e={status:"ignored-stale",boundary:c.boundary,seq:c.seq,lastSeq:y.lastSeq};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(void 0!==c.parentScope&&d(c.parentScope)){const e={status:"ignored-destroyed",boundary:c.boundary,seq:c.seq,parentScope:c.parentScope};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(y.lastSeq=c.seq,Object.hasOwn(c,"error")){const e=(b=c.error)instanceof Error?b:b&&"object"==typeof b&&"string"==typeof b.message?Object.assign(new Error(b.message),b):new Error(String(b)),t={status:"errored",boundary:c.boundary,seq:c.seq,error:e};if(y.errored+=1,y.lastStatus=t.status,m(t),p?.(e,t,r),u)throw e;return t}if(c.signals){if(!o||"function"!=typeof o.set)throw new Error("Boundary patch includes signals, but no signal registry is available.");for(const[e,t]of Object.entries(c.signals))o.set(e,t)}if(c.cache?.browser){if(!s||"function"!=typeof s.restore)throw new Error("Boundary patch includes browser cache, but no cache registry is available.");s.restore(c.cache.browser)}if(null!=c.html&&n.swap(c.boundary,c.html),await async function(e,t){e&&(void 0===t||"function"!=typeof e.flushScope?"function"==typeof e.flush&&await e.flush():await e.flushScope(t))}(a,c.scope),c.redirect){await async function(e,t,r){if(t&&"function"==typeof t.navigate)return void await t.navigate(e);const n=r?.root?.ownerDocument?.defaultView?.location??globalThis.location;n?.assign?.(e)}(c.redirect,i,n);const e={status:"redirected",boundary:c.boundary,seq:c.seq,redirect:c.redirect};return y.applied+=1,y.lastStatus=e.status,m(e),l?.(e,r),e}const v={status:"applied",boundary:c.boundary,seq:c.seq};return y.applied+=1,y.lastStatus=v.status,m(v),l?.(v,r),v},inspect(){const e={};for(const[t,r]of h)e[t]={lastSeq:r.lastSeq,applied:r.applied,ignored:r.ignored,lastStatus:r.lastStatus},r.errored>0&&(e[t].errored=r.errored);return{destroyed:g,boundaries:e,recent:y.map(e=>({...e}))}},reset(t){if(void 0===t)return h.clear(),y.length=0,w;e(t),h.delete(t);for(let e=y.length-1;e>=0;e-=1)y[e].boundary===t&&y.splice(e,1);return w},destroy(){g=!0,h.clear(),y.length=0}};return w;function m(e){if(0!==c)for(y.push(function(e){const t={boundary:e.boundary,seq:e.seq,status:e.status};return"ignored-stale"===e.status&&(t.lastSeq=e.lastSeq),"ignored-destroyed"===e.status&&void 0!==e.parentScope&&(t.parentScope=e.parentScope),"redirected"===e.status&&(t.redirect=e.redirect),t}(e));y.length>c;)y.shift()}}}})(),g=(()=>{function e(e){return e?.reason??new Error("Operation aborted")}return{delay:function(t,r){return r?.aborted?Promise.reject(e(r)):new Promise((n,o)=>{let s=setTimeout(function(){s=void 0,r?.removeEventListener?.("abort",a),n()},t);function a(){void 0!==s&&clearTimeout(s),s=void 0,r?.removeEventListener?.("abort",a),o(e(r))}r?.addEventListener?.("abort",a,{once:!0})})}}})(),w=(()=>{const{Async:e}=h;return{defineAsyncContainerElement:function(t={}){const r=t.tagName??"async-container",n=t.customElements??globalThis.customElements;if(!n)throw new Error("defineAsyncContainerElement(...) requires customElements.");const o=n.get(r);if(o)return o;const s=t.app??t.Async??e,a=t.HTMLElement??t.window?.HTMLElement??globalThis.HTMLElement;if(!a)throw new Error("defineAsyncContainerElement(...) requires HTMLElement.");class i extends a{connectedCallback(){if(this.__asyncAttached)return;const e=s.runtime??s.start?.();e?.attachRoot?.(this),this.__asyncRuntime=e,this.__asyncAttached=!0}disconnectedCallback(){this.__asyncAttached&&(this.__asyncRuntime?.detachRoot?.(this),this.__asyncRuntime=void 0,this.__asyncAttached=!1)}}return n.define(r,i),i},defineAsyncSuspenseElement:function(e={}){const t=e.tagName??"async-suspense",r=e.customElements??globalThis.customElements;if(!r)throw new Error("defineAsyncSuspenseElement(...) requires customElements.");const n=r.get(t);if(n)return n;const o=e.HTMLElement??e.window?.HTMLElement??globalThis.HTMLElement;if(!o)throw new Error("defineAsyncSuspenseElement(...) requires HTMLElement.");class s extends o{}return r.define(t,s),s}}})(),{asyncSignal:m}=e,{Async:b}=h,{createApp:v}=h,{defineApp:S}=h,{readSnapshot:E}=h,{attributeName:$}=o,{defineAttributeConfig:A}=o,{createBoundaryReceiver:j}=y,{createCacheRegistry:R}=n,{defineCache:O}=n,{component:_}=i,{createComponentRegistry:k}=i,{defineComponent:T}=i,{delay:C}=g,{defineAsyncContainerElement:q}=w,{defineAsyncSuspenseElement:M}=w,{createHandlerRegistry:x}=u,{html:L}=a,{createLazyRegistry:D}=t,{defineRegistrySnapshot:B}=t,{Loader:P}=f,{AsyncLoader:N}=f,{createPartialRegistry:z}=p,{createRegistryStore:H}=r,{createRouteRegistry:U}=d,{createRouter:W}=d,{defineRoute:V}=d,{route:I}=d,{createScheduler:F}=l,{applyServerResult:J}=c,{createServerProxy:K}=c,{resolveServerCommandArguments:Z}=c,{unwrapServerResult:Y}=c,{computed:G}=s,{createSignal:Q}=s,{createSignalRegistry:X}=s,{effect:ee}=s,{signal:te}=s,re={asyncSignal:m,Async:b,createApp:v,defineApp:S,readSnapshot:E,attributeName:$,defineAttributeConfig:A,createBoundaryReceiver:j,createCacheRegistry:R,defineCache:O,component:_,createComponentRegistry:k,defineComponent:T,delay:C,defineAsyncContainerElement:q,defineAsyncSuspenseElement:M,createHandlerRegistry:x,html:L,createLazyRegistry:D,defineRegistrySnapshot:B,Loader:P,AsyncLoader:N,createPartialRegistry:z,createRegistryStore:H,createRouteRegistry:U,createRouter:W,defineRoute:V,route:I,createScheduler:F,applyServerResult:J,createServerProxy:K,resolveServerCommandArguments:Z,unwrapServerResult:Y,computed:G,createSignal:Q,createSignalRegistry:X,effect:ee,signal:te};return function(e,t){const r=Object.keys(e).filter(e=>"Async"!==e&&Object.prototype.hasOwnProperty.call(t,e));if(r.length>0)throw new Error(`UMD Async namespace export conflict: ${r.join(", ")}.`)}(re,b),Object.assign(b,re),b.Async=b,b}();"function"==typeof define&&define.amd?define([],()=>t):"object"==typeof module&&module.exports?module.exports=t:(e.AsyncFramework=t,e.Async=t)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this);
|
|
1
|
+
!function(e){const t=function(){"use strict";const e=(()=>{const e=Symbol.for("@async/framework.asyncSignal");return{asyncSignal:function t(r,n){if("string"!=typeof r||0===r.length)throw new TypeError("asyncSignal(id, fn) requires a non-empty string id.");if("function"!=typeof n)throw new TypeError("asyncSignal(id, fn) requires a function.");let o,s,a,i=!1,c=null,u="idle",l=0,f=r,p=0,h=!1;const d=new Set,y=new Set,g={[e]:!0,kind:"async-signal",get id(){return f},get value(){return o},get loading(){return i},get error(){return c},get status(){return u},get version(){return l},set:e=>(o=e,i=!1,c=null,u="ready",$(),o),refresh(){if(!s||h)throw new Error(`Async signal "${f}" is not registered.`);v(a,new Error(`Async signal "${f}" refreshed.`));const e=s,t=l+1;l=t,i=!0,c=null,u="loading";const r=function(e,t,r){const n=new AbortController,o=n.signal,s=function(e,t){const r=e._context?.()??{},n={signals:e,router:r.router,loader:r.loader,cache:r.cache,abort:t,scheduler:r.scheduler};return{signals:e,server:"function"==typeof r.server?._withContext?r.server._withContext(n):r.server,router:r.router,loader:r.loader,cache:r.cache,scheduler:r.scheduler}}(e,o),a={token:++p,version:r,registry:e,id:t,controller:n,abort:o,...s};return function(e,t,r){Object.defineProperty(e,"cancel",{configurable:!0,enumerable:!1,value(e){"function"!=typeof r?t.abort(e):r(e)}})}(o,n,e=>{v(a,e,{settle:!0,notifyChange:!0})}),a}(e,f,t);a=r,$();const d=function(e){return{signals:e.signals,id:e.id,get server(){return e.server},get router(){return e.router},get loader(){return e.loader},get cache(){return e.cache},get scheduler(){return e.scheduler},get version(){return e.version},get abort(){return e.abort},refresh:()=>g.refresh()}}(r);let b;try{b=e._collectDependencies(()=>n.call(d))}catch(e){return w(r,e),Promise.reject(e)}return function(e,t){if(m(t)){for(const e of y)e();y.clear();for(const r of e){const e=String(r).split(".")[0];e&&e!==f&&y.add(t.registry.subscribe(r,()=>E()))}}}(b.dependencies,r),Promise.resolve(b.value).then(e=>m(r)?(o=e,i=!1,c=null,u="ready",a=void 0,$(),o):o,e=>m(r)?(w(r,e),o):o)},cancel:e=>(b(e,{settle:!0,notifyChange:!0}),o),subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return d.add(e),()=>d.delete(e)},snapshot:()=>({value:o,loading:i,error:c,status:u,version:l}),_cloneSignalDeclaration:()=>t(r,n),_restore:(e={})=>function(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))}(e)?(b(new Error(`Async signal "${f}" restored from snapshot.`)),o=e.value,i=Boolean(e.loading),c=e.error??null,u="string"==typeof e.status?e.status:function({value:e,loading:t,error:r}){return t?"loading":r?"error":void 0===e?"idle":"ready"}({value:o,loading:i,error:c}),Number.isFinite(e.version)&&(l=e.version),$(),g):g.set(e),_bindRegistry(e,t){s=e,f=t;const r=()=>{h||s!==e||"idle"!==u||g.refresh()},n=s._context?.().scheduler;n?n.enqueue("async",r,{scope:f,key:`asyncSignal:${f}:initial`}):queueMicrotask(r)},_dispose(){if(!h){h=!0,function(){const e=s?._context?.().scheduler;e?.cancelScope?.(f)}(),b(new Error(`Async signal "${f}" disposed.`));for(const e of y)e();y.clear(),d.clear(),s=void 0}}};function w(e,t){m(e)&&(i=!1,c=t,u="error",a=void 0,$())}function m(e){return Boolean(e)&&!h&&a===e&&e.token===p&&e.registry===s&&e.id===f&&!e.abort.aborted}function b(e,t={}){const r=a,n=Boolean(r)||i;r?v(r,e):n&&(p+=1),t.settle&&n&&!h&&S(t.notifyChange)}function v(e,t,r={}){if(!e)return;const n=a===e;n&&(p+=1,a=void 0),e.abort.aborted||e.controller.abort(t),n&&r.settle&&!h&&S(r.notifyChange)}function S(e=!1){const t=void 0===o?"idle":"ready",r=i||null!==c||u!==t;i=!1,c=null,u=t,e&&r&&$()}function E(){if(h||!s)return;v(a,new Error(`Async signal "${f}" dependency changed.`));const e=s?._context?.().scheduler;e?e.enqueue("async",()=>g.refresh(),{scope:f,key:`asyncSignal:${f}:refresh`}):g.refresh()}function $(){for(const e of[...d])e(g)}return g},isAsyncSignal:function(t){return Boolean(t?.[e])}}})(),t=(()=>{const e=new Set(["handler","component","asyncSignal","partial","route"]);function t(t={}){const r=function(e){if("string"!=typeof e||0===e.length)throw new TypeError("registryAssets.baseUrl must be a non-empty string.");return i(e)||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?a(e):`/${s(e)}`}(t.baseUrl??"_async"),n={component:"component",handler:"handler",asyncSignal:"asyncSignal",partial:"partial",route:"route",...t.paths??{}};for(const[t,r]of Object.entries(n))if(e.has(t)&&("string"!=typeof r||0===r.length))throw new TypeError(`Registry asset path for "${t}" must be a non-empty string.`);return{baseUrl:r,paths:n}}function r(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.url)}function n(t,n,c,u){if(!e.has(t))throw new Error(`Registry type "${t}" does not support lazy descriptors.`);if(!r(c))throw new TypeError(`Registry descriptor for "${t}:${n}" requires a url.`);const{path:l,hash:f}=function(e){const t=e.indexOf("#");return-1===t?{path:e,hash:""}:{path:e.slice(0,t),hash:e.slice(t+1)}}(c.url),p=function(e,t,r){if(i(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=r.paths[e]??e;return function(...e){const[t,...r]=e;return[a(t),...r.map(s)].filter(Boolean).join("/")}(r.baseUrl,n,t)}(t,l,u);return{moduleUrl:p,exportNames:f?[f]:o(n,l),url:f?`${p}#${f}`:p}}function o(e,t){const r=[],n=e.split(".").filter(Boolean).at(-1),o=t.split("/").filter(Boolean).at(-1)?.replace(/\.[^.]+$/,"");for(const e of[n,o,"default"])e&&!r.includes(e)&&r.push(e);return r}function s(e){return String(e).replace(/^\/+|\/+$/g,"")}function a(e){return String(e).replace(/\/+$/g,"")}function i(e){return/^[A-Za-z][A-Za-z\d+.-]*:/.test(e)}function c(e){return!e||"object"!=typeof e||Array.isArray(e)?JSON.stringify(e):JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]]))}return{defineRegistrySnapshot:function(e={}){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("defineRegistrySnapshot(snapshot) requires an object.");return e},createLazyRegistry:function(e={}){const o=t(e.registryAssets??e.assets),s=e.importModule??(e=>import(e)),a=new Map,i=new Map;return{registryAssets:o,resolveUrl:(e,t,r)=>n(e,t,r,o),async resolve(e,t,c){if(!r(c))return c;const u=`${e}:${t}`;if(i.has(u))return i.get(u);const l=n(e,t,c,o);let f,p=a.get(l.moduleUrl);p||(p=Promise.resolve().then(()=>s(l.moduleUrl)),a.set(l.moduleUrl,p));try{f=await p}catch(r){throw a.get(l.moduleUrl)===p&&a.delete(l.moduleUrl),new Error(`Lazy ${e} "${t}" failed to import ${l.moduleUrl}: ${h=r,h instanceof Error?h.message:String(h)}`,{cause:r})}var h;const d=function(e,t,r,n){for(const r of t)if(r in e)return e[r];throw new Error(`Lazy ${r} "${n}" did not export ${t.map(e=>`"${e}"`).join(", ")}.`)}(f,l.exportNames,e,t);return i.set(u,d),d},inspect:()=>({registryAssets:o,modules:[...a.keys()],exports:[...i.keys()]})}},normalizeRegistryAssets:t,isLazyDescriptor:r,sameRegistryValue:function(e,t){return e===t||!(!r(e)||!r(t))&&c(e)===c(t)},publicRegistryValue:function(e,t){return r(e)?{...e}:{id:t}}}})(),r=(()=>{const{publicRegistryValue:e}=t,r=new Set(["signal","handler","server","partial","route","component","asyncSignal"]),n=new Set(["cache.browser","cache.server"]),o=new Set(["cache.browser.entries","cache.server.entries"]),s=new Set([...r,...n,...o]);function a(e){if(!s.has(e))throw new Error(`Unknown Async registry type "${e}".`);return e}function i(e,t){if("string"!=typeof t||0===t.length)throw new TypeError(`${e} id must be a non-empty string.`)}function c(t,r,n,s){return"server"===t&&"browser"===s.target?e(n,r):o.has(t)?n?.value:n}function u(e,t){return"cache.server.entries"===e&&"browser"===t}function l(e){const t={};for(const[r,n]of e)t[r]="function"==typeof n?.snapshot?n.snapshot():n?.value??n;return t}function f(t){const r={};for(const[n,o]of t)r[n]=e(o,n);return r}function p(e){return Object.fromEntries(e)}function h(e){const t={};for(const[r,n]of e)t[r]=n?.value;return t}function d(e){return e&&"object"==typeof e&&Object.hasOwn(e,"value")?e:{value:e}}return{createRegistryStore:function e(t={},n={}){const o=n.backing??{signal:new Map,handler:new Map,server:new Map,partial:new Map,route:new Map,component:new Map,asyncSignal:new Map,cache:{browser:new Map,server:new Map},cacheEntries:{browser:new Map,server:new Map}},s=n.target??"server",y={target:s,register(e,t,r){const n=y._map(e);if(i(e,t),n.has(t))throw new Error(`${e} "${t}" is already registered.`);return n.set(t,r),t},registerMany(e,t={}){for(const[r,n]of Object.entries(t??{}))y.register(e,r,n);return y},set(e,t,r){const n=y._map(e);return i(e,t),n.set(t,r),r},unregister:(e,t)=>y.delete(e,t),delete:(e,t)=>y._map(e).delete(t),keys:e=>u(e,s)?[]:[...y._map(e).keys()],entries(e,t={}){const r=a(e);return u(r,t.target??s)?[]:[...y._map(r)].map(([e,n])=>[e,c(r,e,n,{target:s,...t})])},has:(e,t)=>(i(e,t),!u(e,s)&&y._map(e).has(t)),get(e,t,r={}){i(e,t);const n=a(e);if(u(n,r.target??s))return;const o=y._map(n).get(t);return void 0!==o?c(n,t,o,{target:s,...r}):void 0},snapshot(e={}){const t=e.target??s;return{signal:l(o.signal),handler:f(o.handler),server:f(o.server),partial:f(o.partial),route:p(o.route),component:f(o.component),asyncSignal:f(o.asyncSignal),cache:{browser:p(o.cache.browser),server:p(o.cache.server)},entries:{browser:h(o.cacheEntries.browser),server:"browser"===t?{}:h(o.cacheEntries.server)}}},rawSnapshot:()=>({signal:Object.fromEntries(o.signal),handler:Object.fromEntries(o.handler),server:Object.fromEntries(o.server),partial:Object.fromEntries(o.partial),route:Object.fromEntries(o.route),component:Object.fromEntries(o.component),asyncSignal:Object.fromEntries(o.asyncSignal),cache:{browser:Object.fromEntries(o.cache.browser),server:Object.fromEntries(o.cache.server)}}),view:(t={})=>e(void 0,{backing:o,target:t.target??s}),_map(e){const t=a(e);if(r.has(t))return o[t];if("cache.browser"===t)return o.cache.browser;if("cache.server"===t)return o.cache.server;if("cache.browser.entries"===t)return o.cacheEntries.browser;if("cache.server.entries"===t)return o.cacheEntries.server;throw new Error(`Unknown Async registry type "${e}".`)}};return function(e,t={}){e.registerMany("signal",t.signal),e.registerMany("handler",t.handler),e.registerMany("server",t.server),e.registerMany("partial",t.partial),e.registerMany("route",t.route),e.registerMany("component",t.component),e.registerMany("asyncSignal",t.asyncSignal),e.registerMany("cache.browser",t.cache?.browser),e.registerMany("cache.server",t.cache?.server);const r=t.entries??{};for(const[t,n]of Object.entries(r.browser??{}))e.set("cache.browser.entries",t,d(n));for(const[t,n]of Object.entries(r.server??{}))e.set("cache.server.entries",t,d(n))}(y,t),y},attachRegistryInspection:function(e,t,r){return Object.defineProperty(e,"registry",{configurable:!0,enumerable:!0,value:t}),e.keys=()=>t.keys(r),e.entries=()=>t.entries(r),e.inspect=()=>t.entries(r),e}}})(),n=(()=>{const{attachRegistryInspection:e,createRegistryStore:t}=r,n=Symbol.for("@async/framework.cacheDefinition");function o(e={}){return{[n]:!0,kind:"cache-definition",store:e.store??"memory",ttl:e.ttl}}function s(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache id must be a non-empty string.")}function a(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache key must be a non-empty string.")}return{defineCache:o,createCacheRegistry:function(r={},{now:i=()=>Date.now(),registry:c,type:u="cache.browser"}={}){const l=c??t(),f=l._map(u),p=l._map(`${u}.entries`),h=new Map,d=e({register(e,t=o()){s(e);const r=function(e){return e?.[n]?e:o(e)}(t);if(f.has(e))throw new Error(`Cache "${e}" is already registered.`);return f.set(e,r),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))d.register(t,r);return d},unregister:e=>(s(e),f.delete(e)),resolve:e=>(s(e),f.get(e)),get:e=>(a(e),y(e).value),set(e,t,r={}){a(e);const n=r.ttl??function(e,t){if(void 0!==t)return f.get(t);if(f.has(e))return f.get(e);const r=e.split(":")[0];return f.get(r)}(e,r.cache)?.ttl;return p.set(e,{value:t,expiresAt:void 0===n?void 0:i()+n}),t},async getOrSet(e,t,r={}){if(a(e),"function"!=typeof t)throw new TypeError("cache.getOrSet(key, fn) requires a function.");const n=y(e);if(n.found)return n.value;if(h.has(e))return h.get(e);let o;return o=Promise.resolve().then(t).then(t=>(h.get(e)===o&&d.set(e,t,r),t)).finally(()=>{h.get(e)===o&&h.delete(e)}),h.set(e,o),o},delete:e=>(a(e),h.delete(e),p.delete(e)),clear(e){if(void 0===e)return p.clear(),h.clear(),d;for(const t of[...p.keys()])t.startsWith(e)&&p.delete(t);for(const t of[...h.keys()])t.startsWith(e)&&h.delete(t);return d},snapshot(){const e={};for(const[t]of p){const{found:r,value:n}=y(t);r&&void 0!==n&&(e[t]=n)}return e},restore(e={}){for(const[t,r]of Object.entries(e??{}))d.set(t,r);return d},entryKeys:()=>[...p.keys()],entryEntries:()=>l.entries(`${u}.entries`),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))f.has(t)||d.register(t,r);return d}},l,u);return d.registerMany(r),d;function y(e){const t=p.get(e);return t?void 0!==t.expiresAt&&t.expiresAt<=i()?(p.delete(e),{found:!1,value:void 0}):{found:!0,value:t.value}:{found:!1,value:void 0}}}}})(),o=(()=>{const e=Object.freeze({async:["async:"],class:["class:"],signal:["signal:"],on:["on:"]});function t(t={}){return{async:r(t.async,e.async),class:r(t.class,e.class),signal:r(t.signal,e.signal),on:r(t.on,e.on)}}function r(e,t){return(null==e?t:Array.isArray(e)?e:[e]).map(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Attribute prefixes must be non-empty strings.");return e})}return{defineAttributeConfig:function(e={}){return t(e)},normalizeAttributeConfig:t,attributeName:function(e,r,n){return t(e)[r][0]+n},readAttribute:function(e,r,n,o){for(const s of t(r)[n]){const t=`${s}${o}`;if(e.hasAttribute?.(t))return e.getAttribute(t)}return null},matchAttribute:function(e,r,n){for(const o of t(r)[n])if(e.startsWith(o))return e.slice(o.length);return null}}})(),s=(()=>{const{asyncSignal:n,isAsyncSignal:o}=e,{attachRegistryInspection:s,createRegistryStore:a}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t,u=Symbol.for("@async/framework.signal"),l=Symbol.for("@async/framework.computed"),f=Symbol.for("@async/framework.effect"),p=Symbol.for("@async/framework.signalRef"),h=[];function d(e){let t=e;const r=new Set;return{[u]:!0,kind:"signal",get value(){return t},set value(e){this.set(e)},set:e=>(Object.is(t,e)||(t=e,function(){for(const e of[...r])e(t)}()),t),update(e){return this.set(e(t))},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return r.add(e),()=>r.delete(e)},snapshot:()=>t,_cloneSignalDeclaration:()=>d(t)}}function y(e){return"function"==typeof e?._cloneSignalDeclaration?e._cloneSignalDeclaration():g(e)?d("function"==typeof e.snapshot?e.snapshot():e.value):d(e)}function g(e){return Boolean(e&&"object"==typeof e&&"function"==typeof e.subscribe)}function w(e,t){let r=e;for(const e of t){if(null==r)return;r=r[e]}return r}function m(e,t,r){const n=b(e,t[0]);let o=n;for(let e=0;e<t.length-1;e+=1){const r=t[e],n=t[e+1];o[r]=b(o[r],n),o=o[r]}return o[t.at(-1)]=r,n}function b(e,t){return Array.isArray(e)?[...e]:e&&"object"==typeof e?{...e}:(r=t,String(Number(r))===String(r)?[]:{});var r}function v(e,t){const r=e.get(t);if(!r)throw new Error(`Signal "${t}" is not registered.`);return r}function S(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal id must be a non-empty string.")}return{createSignal:d,computed:function e(t){if("function"!=typeof t)throw new TypeError("computed(fn) requires a function.");const r=d(void 0);return{[l]:!0,kind:"computed",get value(){return r.value},set:e=>r.set(e),update:e=>r.update(e),subscribe:e=>r.subscribe(e),snapshot:()=>r.snapshot(),_cloneSignalDeclaration:()=>e(t),_bindRegistry:(e,n)=>e.effect(()=>{r.set(t.call({signals:e,id:n,server:e._context?.().server,router:e._context?.().router,loader:e._context?.().loader,cache:e._context?.().cache,scheduler:e._context?.().scheduler}))})}},effect:function e(t){if("function"!=typeof t)throw new TypeError("effect(fn) requires a function.");return{[f]:!0,kind:"effect",fn:t,_cloneSignalDeclaration:()=>e(t),_bindRegistry:e=>e.effect(t)}},createSignalRegistry:function(e={},t={}){const r=t.registry??a(),u=t.type??"signal",l=r._map(u),f=r._map("asyncSignal"),b=t.lazyRegistry??i(t),E=new Map,$={},A=new Set;let j=0,R=0;for(const e of l.keys())if(f.has(e))throw new Error(`Signal "${e}" is already registered.`);const O=s({register(e,t){if(S(e),l.has(e)||f.has(e))throw new Error(`Signal "${e}" is already registered.`);const r=function(e){return g(e)?e:d(e)}(t);return l.set(e,r),k(e,r),O.ref(e)},registerMany(e){for(const[t,r]of Object.entries(e??{}))O.register(t,r);return O},unregister(e){S(e);const t=l.has(e),r=f.has(e);return!(!t&&!r||(t&&(E.get(e)?.(),E.delete(e),l.get(e)?._dispose?.(),l.delete(e),A.delete(e)),f.delete(e),0))},ensure:(e,t)=>(S(e),T(e),l.has(e)||O.register(e,d(t)),O.ref(e)),has:e=>l.has(e)||f.has(e),get(e){const t=_(e);return function(e){const t=h.at(-1);t&&t.add(e)}(t.path),function(e,t){if(o(e)&&t[0]?.startsWith("$"))return w(function(e,t){switch(t){case"$value":return e.value;case"$loading":return e.loading;case"$error":return e.error;case"$status":return e.status;case"$version":return e.version;default:return}}(e,t[0]),t.slice(1));return w(e.value,t)}(v(l,t.id),t.parts)},set(e,t){const r=_(e),n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},update(e,t){if("function"!=typeof t)throw new TypeError("update(path, fn) requires a function.");return O.set(e,t(O.get(e)))},ref:e=>(S(e),T(e),function(e,t){return{[p]:!0,kind:"signal-ref",id:t,get value(){return e.get(t)},set value(r){e.set(t,r)},get loading(){return e._entry(t).loading??!1},get error(){return e._entry(t).error??null},get status(){return e._entry(t).status??"ready"},get version(){return e._entry(t).version??0},get:()=>e.get(t),set:r=>e.set(t,r),update:r=>e.update(t,r),subscribe:r=>e.subscribe(t,r),refresh(){const r=e._entry(t);if("function"!=typeof r.refresh)throw new Error(`Signal "${t}" cannot refresh.`);return r.refresh()},cancel(r){const n=e._entry(t);if("function"!=typeof n.cancel)throw new Error(`Signal "${t}" cannot cancel.`);return n.cancel(r)},toString:()=>t,[Symbol.toPrimitive]:()=>t}}(O,e)),subscribe(e,t,r={}){if("function"!=typeof t)throw new TypeError("subscribe(path, fn) requires a function.");const n=_(e),o=v(l,n.id),s=++j;return o.subscribe(()=>{!function(e,t={}){const r=t.scheduler;r&&"sync"!==t.phase?r.enqueue(t.phase??"effect",e,{scope:t.scope,key:t.key}):e()}(()=>t(O.get(n.path),{id:n.id,path:n.path,signal:o}),{...r,key:r.key??`signal:${n.path}:${s}`})})},snapshot(){const e={};for(const[t,r]of l)e[t]="function"==typeof r.snapshot?r.snapshot():r.value;return e},asyncSignal:(e,t)=>(O.register(e,n(e,t)),O.ref(e)),effect(e,t={}){let r,n=[],o=!1;const s=t.scheduler,a=++R,i=()=>{if(o)return;"function"==typeof r&&r();for(const e of n)e();n=[];const t=O._collectDependencies(()=>e.call({signals:O,server:$.server,router:$.router,loader:$.loader,cache:$.cache,scheduler:$.scheduler}));r=t.value,n=t.dependencies.map(e=>O.subscribe(e,c))},c=()=>{s?s.enqueue(t.phase??"effect",i,{scope:t.scope,key:t.key??`effect:${a}`}):i()};return i(),()=>{o=!0,"function"==typeof r&&r();for(const e of n)e()}},destroy(){for(const e of E.values())e();E.clear();for(const e of l.values())e._dispose?.();l.clear()},_collectDependencies(e){const t=new Set;h.push(t);try{return{value:e(),dependencies:[...t]}}finally{h.pop()}},_entry:e=>(T(e),v(l,e)),_setPath(e,t){const r=function(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const[t,...r]=e.split(".");return{id:t,parts:r,path:e}}(e);l.has(r.id)||(f.has(r.id)?T(r.id):O.register(r.id,d(0===r.parts.length?t:{})));const n=v(l,r.id);if(0===r.parts.length)return n.set(t);const o=m(n.value,r.parts,t);return n.set(o),t},_setContext:(e={})=>(Object.assign($,e),O),_context:()=>$,_adoptMany(e={}){for(const[t,r]of Object.entries(e??{})){if(!l.has(t)){if(f.has(t))throw new Error(`Signal "${t}" is already registered.`);const e=y(r);l.set(t,e),k(t,e);continue}k(t,l.get(t))}return O}},r,u);for(const[e,t]of l)k(e,t);return O.registerMany(e),O;function k(e,t){if(A.has(e)||"function"!=typeof t?._bindRegistry)return;A.add(e);const r=t._bindRegistry(O,e);"function"==typeof r&&E.set(e,r)}function _(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const t=e.split(".");for(let r=t.length;r>0;r-=1){const n=t.slice(0,r).join(".");if(l.has(n)||f.has(n))return T(n),{id:n,parts:t.slice(r),path:e}}const[r,...n]=t;return{id:r,parts:n,path:e}}function T(e){if(l.has(e)||!f.has(e))return;const t=f.get(e);if(!c(t)&&"function"!=typeof t)throw new TypeError(`Async signal "${e}" must be a function or lazy descriptor.`);const r=n(e,async function(...r){const n=await b.resolve("asyncSignal",e,t);if("function"!=typeof n)throw new TypeError(`Async signal "${e}" did not resolve to a function.`);return n.apply(this,r)});l.set(e,r),k(e,r)}},cloneSignalDeclaration:y,isSignalRef:function(e){return Boolean(e?.[p])},signal:d}})(),a=(()=>{const{isSignalRef:e}=s,{attributeName:t,matchAttribute:r,normalizeAttributeConfig:n}=o,a=Symbol.for("@async/framework.template"),i=Symbol.for("@async/framework.rawHtml");function c(e){return Boolean(e?.[a])}function u(e,t={}){if(c(e)){const r=p(t);let n="";for(let t=0;t<e.strings.length;t+=1)n+=e.strings[t],t<e.values.length&&(n+=l(e.values[t],{...r,attribute:h(e.strings[t])}));return n}return l(e,p(t))}function l(n,o=p()){return n?.[i]?n.html:c(n)?u(n,o):o.attribute?function(n,o){const s=r(o.attribute.name,o.attributes,"signal"),a=r(o.attribute.name,o.attributes,"class"),i=function(t,r){return e(t)?t.id:"string"==typeof t&&r.signals?.has?.(t)?t:null}(n,o);if("value"===o.attribute.name&&i){const r=function(t,r){return e(t)?t.value:"string"==typeof t&&r.signals?.has?.(t)?r.signals.get(t):t}(n,o),s=t(o.attributes,"signal","value");return`${d(r)}${o.attribute.quote} ${s}=${o.attribute.quote}${d(i)}`}if(null!=s||null!=a){if(i)return d(i);if(function(e){return Boolean(e&&"object"==typeof e)}(n))return d(function(e,t){return"function"!=typeof t.bind?e:t.bind(e)}(n,o))}return f(n,o)}(n,o):Array.isArray(n)?n.map(e=>l(e,o)).join(""):e(n)?d(n.value):null==n||!1===n?"":d(n)}function f(t,r){return Array.isArray(t)?t.map(e=>f(e,r)).join(""):e(t)?d(t.value):null==t||!1===t?"":d(t)}function p(e={}){return{...e,attributes:n(e.attributes)}}function h(e){const t=e.match(/(?:^|[\s<])([^\s"'=<>`]+)\s*=\s*(["'])$/);return t?{name:t[1],quote:t[2]}:null}function d(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}return{html:function(e,...t){return{[a]:!0,strings:e,values:t}},isTemplateResult:c,rawHtml:function(e){return{[i]:!0,html:String(e??"")}},renderTemplate:u,escapeHtml:d}})(),i=(()=>{const{attributeName:e}=o,{escapeHtml:n,rawHtml:s,renderTemplate:i}=a,{attachRegistryInspection:c,createRegistryStore:u}=r,{createLazyRegistry:l,isLazyDescriptor:f}=t,p=Symbol.for("@async/framework.component");let h=0;function d(e){if("function"!=typeof e)throw new TypeError("defineComponent(fn) requires a function.");return Object.defineProperty(e,p,{configurable:!0,value:!0}),e}function y(e){return Boolean(e?.[p])}function g(t,r={},o,a="component"){if(!y(t)&&"function"!=typeof t)throw new TypeError("renderComponent(Component) requires a component function.");const c=`${a}.${m(t)}.${++h}`,u=[],l=[],f=[],p=[],d=[],b={attributes:o.attributes,signals:o.signals,bind(e){const t=o.loader?._registerBinding?.(e);if(!t)throw new Error("Inline template bindings require a Loader.");return d.push(t),t}},v=e=>i(e,b),S=function({runtime:t,scope:r,cleanups:o,attachHooks:a,visibleHooks:i,destroyHooks:c,renderScopedTemplate:u}){const{signals:l,handlers:f,loader:p,server:h,router:d,cache:y,scheduler:m}=t,b=new WeakMap;let v=0,S=0;const E={scope:r,signals:l,handlers:f,loader:p,server:h,router:d,cache:y,scheduler:m,signal(e,t){if(1===arguments.length){const t=w(r,"signal."+ ++S),n=l.ensure(t,e);return o.push(()=>l.unregister?.(t)),n}const n=w(r,e),s=!l.has(n),a=l.ensure(n,t);return s&&o.push(()=>l.unregister?.(n)),a},computed(e,t){const n=w(r,e),s=!l.has(n),a=l.ensure(n,void 0);s&&o.push(()=>l.unregister?.(n));const i=l.effect(()=>{l.set(n,t.call(E))});return o.push(i),a},asyncSignal(e,t){const n=w(r,e),s=!l.has(n);return l.has(n)||l.asyncSignal(n,t),s&&o.push(()=>l.unregister?.(n)),l.ref(n)},effect(e){const t=l.effect(()=>e.call(E),{scheduler:m,phase:"effect",scope:r});return o.push(t),t},handler(e,t){if("function"==typeof e&&void 0===t){const t=e;if(b.has(t))return b.get(t);const r=$("handler."+ ++v,t);return b.set(t,r),r}if("function"!=typeof t)throw new TypeError("this.handler(name, fn) or this.handler(fn) requires a function.");return $(e,t)},render(e,n={}){const c=g(e,n,t,r);return o.push(c.cleanup),a.push(e=>c.attach(e)),i.push(e=>c.visible(e,p._observeVisible)),s(c.html)},suspense(r,o){const a=r?.id;if(!a)throw new TypeError("this.suspense(signalRef, views) requires a signal ref.");const i=function(e){const t="function"==typeof e?{ready:e}:e;if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("this.suspense(signalRef, views) requires views to be a function or object.");for(const e of["loading","ready","error"])if(Object.hasOwn(t,e)&&void 0!==t[e]&&"function"!=typeof t[e])throw new TypeError(`this.suspense(signalRef, views) view "${e}" must be a function.`);return t}(o),c=[];for(const o of["loading","ready","error"]){const s=i[o];if(!s)continue;const l=e(t.attributes,"async",o),f=u(s.call(E,r));c.push(`<template ${l}="${n(a)}">${f}</template>`)}return s(c.join(""))},on(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component lifecycle event must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Component lifecycle "${e}" requires a function.`);const r="mount"===e?"attach":e;if("attach"!==r)if("visible"!==r){if("destroy"!==r)throw new Error(`Unsupported component lifecycle event "${e}".`);c.push(()=>t.call(E))}else i.push(e=>t.call(E,e));else a.push(e=>t.call(E,e))},onMount(e){E.on("attach",e)},onVisible(e){E.on("visible",e)}};return E;function $(e,t){const n=w(r,e);return f.register(n,e=>t.call({...E,...e},e)),o.push(()=>f.unregister?.(n)),n}}({runtime:o,scope:c,cleanups:u,attachHooks:l,visibleHooks:f,destroyHooks:p,renderScopedTemplate:v}),E=t.call(S,r);if(E&&"function"==typeof E.then)throw new TypeError(`Component "${m(t)}" returned a Promise. Async components are not supported by synchronous renderComponent(). Use an async partial or handler instead.`);return{html:v(E),attach(e){for(let t=0;t<l.length;t+=1){const r=l[t];o.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&u.push(t)},{scope:c,key:`attach:${t}`})??$(r,e)}},mount(e){this.attach(e)},visible(e,t){if(0===f.length)return;const r=t(e,()=>{for(let t=0;t<f.length;t+=1){const r=f[t];o.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&u.push(t)},{scope:c,key:`visible:${t}`})??A(r,e)}});"function"==typeof r&&u.push(r)},cleanup(){for(;p.length>0;)p.pop()?.();for(o.scheduler?.markScopeDestroyed(c);u.length>0;)u.pop()?.();for(;d.length>0;)o.loader?._releaseBinding?.(d.pop())}};function $(e,t){const r=e(t);"function"==typeof r&&u.push(r)}function A(e,t){const r=e(t);"function"==typeof r&&u.push(r)}}function w(e,t){if("string"!=typeof t||0===t.length)throw new TypeError("Scoped signal or handler name must be a non-empty string.");return`${e}.${t}`}function m(e){return e.displayName||e.name||"anonymous"}return{defineComponent:d,createComponentRegistry:function(e={},t={}){const r=t.registry??u(),n=t.type??"component",o=r._map(n),s=t.lazyRegistry??l(t),a=new Map,i=c({register(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");if(!y(t)&&"function"!=typeof t&&!f(t))throw new TypeError(`Component "${e}" must be a component function.`);if(o.has(e))throw new Error(`Component "${e}" is already registered.`);return o.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))i.register(t,r);return i},unregister(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");return a.delete(e),o.delete(e)},resolve(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");const t=o.get(e);return f(t)?(a.has(e)||a.set(e,async function(...r){const o=await s.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Component "${e}" did not resolve to a function.`);return o.apply(this,r)}),a.get(e)):t},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)||i.register(t,r);return i}},r,n);return i.registerMany(e),i},isComponent:y,renderComponent:g,component:d}})(),c=(()=>{const e=Symbol.for("@async/framework.serverResult"),t=Symbol("@async/framework.serverResultInvocation");async function r(e,r={}){if(!d(e))return e;const n=function(e={}){return e[t]??{applied:new WeakSet}}(r);if(n.applied.has(e))return e;if(n.applied.add(e),e.error)throw(o=e.error)instanceof Error?o:o&&"object"==typeof o&&"string"==typeof o.message?Object.assign(new Error(o.message),o):new Error(String(o));var o;if(e.signals&&r.signals)for(const[t,n]of Object.entries(e.signals))r.signals.set?.(t,n);return e.cache?.browser&&r.cache?.restore&&r.cache.restore(e.cache.browser),e.boundary&&Object.hasOwn(e,"html")&&r.loader?.swap?.(e.boundary,e.html),e.redirect&&await(r.router?.navigate?.(e.redirect)),e}async function n(e,t={}){return await r(e,t),o(e)}function o(e){return d(e)?Object.hasOwn(e,"value")?e.value:void 0:e}function s(e={}){const r=e[t]??{applied:new WeakSet};return{...e,[t]:r}}function a(e={}){const t=f(e);if(t)return p(new t.ownerDocument.defaultView.FormData(t));const r=e.element??e.el??e.event?.target;return r?{value:"value"in r?r.value:void 0,checked:"checked"in r?r.checked:void 0,dataset:r.dataset?{...r.dataset}:{}}:{}}function i(e,t={},r=()=>({})){const n=new Map;return function o(s){const a=s.join(".");if(n.has(a))return n.get(a);const c=new Proxy(async(...t)=>{if(0===s.length)throw new Error("Server namespace is not directly callable.");const n=r()??{};return e(s.join("."),t,n)},{get(n,a){if("then"!==a)return a in n?n[a]:0===s.length&&"_withContext"===a?(n={})=>i(e,t,()=>({...r()??{},...n})):0===s.length&&"run"===a&&"function"==typeof t.run?(e,n=[],o={})=>t.run(e,n,{...r()??{},...o}):0===s.length&&Object.hasOwn(t,a)?t[a]:a===Symbol.toStringTag?"AsyncServerNamespace":"toString"===a?()=>0===s.length?"server":`server.${s.join(".")}`:o([...s,String(a)])}});return n.set(a,c),c}([])}function c(e=[],t){const r={};for(const n of e)r[n]=u(t,n);return r}function u(e,t){if(!e||"function"!=typeof e.get)throw new Error(`Signal "${t}" cannot be read without a signal registry.`);return e.get(t)}function l(e,t,{forServer:r}={}){if(("$event"===e||"$el"===e)&&r)throw new Error(`${e} cannot be passed to a server command.`);if("$event"===e)return t.event;if("$el"===e)return t.element??t.el;if("$value"===e){const e=t.element??t.el??t.event?.target;return e?.value}if("$checked"===e){const e=t.element??t.el??t.event?.target;return e?.checked}if("$form"===e){const e=f(t);return e?p(new e.ownerDocument.defaultView.FormData(e)):{}}if("$dataset"===e){const e=t.element??t.el??t.event?.target;return e?.dataset?{...e.dataset}:{}}throw new Error(`Event local "${e}" is not supported.`)}function f(e){const t=e.event,r=e.element??e.el??t?.target;return"FORM"===r?.tagName?r:"submit"===t?.type&&"FORM"===t.target?.tagName?t.target:"submit"===t?.type&&r?.form?r.form:null}function p(e){const t={};for(const[r,n]of e.entries())Object.hasOwn(t,r)?t[r]=Array.isArray(t[r])?[...t[r],n]:[t[r],n]:t[r]=n;return t}function h(e,t=new Set){if("bigint"==typeof e)throw new Error("Server proxy JSON transport does not support BigInt values.");if(null==e||"object"!=typeof e)return;if(t.has(e))throw new Error("Server proxy JSON transport does not support circular values.");t.add(e);const r=Object.prototype.toString.call(e);if("[object File]"===r||"[object Blob]"===r||"[object FormData]"===r)throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");if(function(e,t=Object.prototype.toString.call(e)){return"[object URLSearchParams]"===t||"[object Headers]"===t||"[object Request]"===t||"[object Response]"===t||"[object ReadableStream]"===t||"[object ArrayBuffer]"===t||ArrayBuffer.isView(e)}(e,r))throw new Error("Server proxy JSON transport does not support URLSearchParams, Headers, Request, Response, ReadableStream, ArrayBuffer, or typed array values yet.");if(Array.isArray(e)){for(const r of e)h(r,t);t.delete(e)}else{for(const r of Object.values(e))h(r,t);t.delete(e)}}function d(t){return!(!t||"object"!=typeof t||Array.isArray(t)||!0!==t[e]&&1!==t.__async_server_result__)}function y(e){if("string"!=typeof e||0===e.length)throw new TypeError("Server function id must be a non-empty string.")}return{createServerProxy:function({endpoint:e="/__async/server",transport:t,signals:r,loader:o,router:u,cache:l,scheduler:f,headers:p={}}={}){if("function"!=typeof t)throw new TypeError("createServerProxy(...) requires a transport function.");const d={signals:r,loader:o,router:u,cache:l,scheduler:f};async function g(r,o=[],i={}){y(r);const u=s({...d,...i}),l={args:o,input:i.input??a(u),signals:i.signalValues??c(i.signalPaths,u.signals)};h(l);const f=await t(function(e,t){return`${String(e).replace(/\/$/,"")}/${encodeURIComponent(t)}`}(e,r),{method:"POST",headers:{"content-type":"application/json",...p},body:JSON.stringify(l),signal:i.abort});if(function(e,t){if(!t||"object"!=typeof t)throw new Error(`Server function "${e}" transport returned an invalid response: expected a fetch Response-like object.`);if("boolean"!=typeof t.ok)throw new Error(`Server function "${e}" transport returned an invalid response: missing boolean ok.`);if(!t.headers||"function"!=typeof t.headers.get)throw new Error(`Server function "${e}" transport returned an invalid response: missing headers.get(name).`)}(r,f),!f.ok)throw new Error(`Server function "${r}" failed with ${f.status}.`);return n(await async function(e,t){if(204===t.status)return;if((t.headers.get("content-type")??"").includes("application/json")){if("function"!=typeof t.json)throw new Error(`Server function "${e}" transport returned an invalid response: missing json().`);try{return await t.json()}catch(t){throw new Error(`Server function "${e}" returned invalid JSON: ${r=t,r instanceof Error?r.message:String(r)}`,{cause:t})}}var r;if("function"!=typeof t.text)throw new Error(`Server function "${e}" transport returned an invalid response: missing text().`);return t.text()}(r,f),u)}return i(g,{run:g,_setContext(e={}){Object.assign(d,e)}},()=>d)},resolveServerCommandArguments:function(e,t={}){const r=[],n={},o=[];for(const s of e){if("local"===s.type){r.push(l(s.name,t,{forServer:!0}));continue}const e=u(t.signals,s.path);r.push(e),n[s.path]=e,o.push(s.path)}return{args:r,signalValues:n,signalPaths:o}},applyServerResult:r,consumeServerResult:n,unwrapServerResult:o,createServerResultContext:s,defaultInput:a,createServerNamespace:i,createSignalReader:function(e){return e&&"function"!=typeof e.get?{get:t=>function(e,t){return String(t).split(".").reduce((e,t)=>e?.[t],e)}(e,t),snapshot:()=>({...e})}:e},assertServerId:y}})(),u=(()=>{const{defaultInput:e,resolveServerCommandArguments:n}=c,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:a,isLazyDescriptor:i}=t,u=new Set(["prevent","preventDefault","stopPropagation","stopImmediatePropagation"]),l={prevent:f,preventDefault:f,stopPropagation(){this.event?.stopPropagation?.()},stopImmediatePropagation(){this.event?.stopImmediatePropagation?.()}};function f(){this.event?.preventDefault?.()}function p(e){if("string"!=typeof e||0===e.trim().length)throw new TypeError("Handler ref must be a non-empty string.");return e.split(";").map(e=>e.trim()).filter(Boolean).map(d)}function h(e){if("string"!=typeof e||0===e.length)throw new TypeError("Handler id must be a non-empty string.")}function d(e){if(e.startsWith("server."))return function(e){const t=e.indexOf("(");if(-1===t||!e.endsWith(")"))throw new Error(`Server command "${e}" must be called with parentheses.`);const r=e.slice(7,t).trim();if(!function(e){return/^[^.\s();]+(?:\.[^.\s();]+)*$/.test(e)}(r))throw new Error(`Server command "${e}" has an invalid function id.`);return{type:"server",id:r,args:y(e.slice(t+1,-1))}}(e);if(e.includes("(")||e.includes(")"))throw new Error(`Command "${e}" is not supported.`);return{type:"handler",id:e}}function y(e){return 0===e.trim().length?[]:e.split(",").map(e=>e.trim()).filter(Boolean).map(g)}function g(e){if(!/^[^\s,();]+$/.test(e))throw new Error(`Argument "${e}" is not supported.`);return e.startsWith("$")?{type:"local",name:e}:{type:"signal",path:e}}return{createHandlerRegistry:function(t={},r={}){const c=r.registry??s(),f=r.type??"handler",d=c._map(f),y=r.lazyRegistry??a(r),g=new Map,w=o({register(e,t){if(h(e),"function"!=typeof t&&!i(t))throw new TypeError(`Handler "${e}" must be a function.`);if(d.has(e))throw new Error(`Handler "${e}" is already registered.`);return d.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))w.register(t,r);return w},unregister:e=>(h(e),g.delete(e),d.delete(e)),resolve(e){h(e);const t=d.get(e);return i(t)?(g.has(e)||g.set(e,async function(...r){const n=await y.resolve(f,e,t);if("function"!=typeof n)throw new TypeError(`Handler "${e}" did not resolve to a function.`);return n.apply(this,r)}),g.get(e)):t},async run(t,r={}){const o=p(t),s=[];let a=!1;const i={...r,handlers:w,input:r.input??e(r),stop(){a=!0}};for(const e of o){if(a)break;if("server"===e.type){if(!i.server||"function"!=typeof i.server.run)throw new Error(`Server command "${e.id}" cannot run without a server registry.`);const t=n(e.args,i),r=await i.server.run(e.id,t.args,{...i,signalPaths:t.signalPaths,signalValues:t.signalValues});s.push(r);continue}const t=w.resolve(e.id);if(!t)throw new Error(`Handler "${e.id}" is not registered.`);const r=await t.call(i,i);u.has(e.id)&&t===l[e.id]||s.push(r)}return s},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))d.has(t)||w.register(t,r);return w}},c,f);return function(e,t){for(const[r,n]of Object.entries(l))if(t.has(r)){if(t.get(r)!==n)throw new Error(`Handler "${r}" is already registered.`)}else e.register(r,n)}(w,d),w.registerMany(t),w},parseHandlerRef:p,isHandlerToken:function(e){return u.has(e)}}})(),l=(()=>{const e=["binding","lifecycle","effect","async","post"];function t(e){return"object"==typeof e&&null!==e||"function"==typeof e}function r(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)return e;try{Object.defineProperty(e,"scheduler",{configurable:!0,value:{phase:t.phase,scope:t.scope,key:t.key}})}catch{}return e}function n(){}return{createScheduler:function(o={}){const s=[...o.phases??e],a=new Map(s.map(e=>[e,[]])),i=new Map,c=new WeakSet,u=new Set,l=new WeakMap,f="function"==typeof o.onError?o.onError:void 0,p=o.maxDepth??100,h=o.strategy??"microtask";let d=!1,y=!1,g=!1,w=0,m=0,b=0;const v={strategy:h,phases:s,batch(e){if("function"!=typeof e)throw new TypeError("scheduler.batch(fn) requires a function.");R(),w+=1;let t=!1;try{const r=e();return r&&"function"==typeof r.then?(t=!0,Promise.resolve(r).finally(()=>{w-=1,S()})):r}finally{!t&&w>0&&(w-=1,S())}},enqueue(e,t,r={}){if(R(),function(e){if(!a.has(e))throw new Error(`Unknown scheduler phase "${e}".`)}(e),"function"!=typeof t)throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");const o=r.scope;if(O(o))return n;const s=void 0===r.key?void 0:`${e}:${function(e){return void 0===e?"global":"object"==typeof e&&null!==e||"function"==typeof e?(l.has(e)||l.set(e,"scope:"+ ++b),l.get(e)):String(e)}(o)}:${String(r.key)}`;if(s&&i.has(s))return i.get(s).cancel;const c={id:++m,phase:e,fn:t,scope:o,boundary:r.boundary,key:s,canceled:!1,cancel(){c.canceled=!0,c.key&&i.delete(c.key)}};return a.get(e).push(c),c.key&&i.set(c.key,c),S(),c.cancel},afterFlush:(e,t={})=>v.enqueue("post",e,t),async flush(){if(R(),y)return;g=!1,y=!0;let e=0;try{for(;A();){if(e+=1,e>p)throw new Error(`Scheduler exceeded maxDepth ${p}.`);for(const e of s)await E(e)}}finally{y=!1,A()&&S()}},async flushScope(e){if(R(),y)return;g=!1,y=!0;let t=0;try{for(;j(e);){if(t+=1,t>p)throw new Error(`Scheduler exceeded maxDepth ${p}.`);for(const t of s)await E(t,e)}}finally{y=!1,A()&&S()}},cancelScope(e){if(void 0===e)return v;for(const t of a.values())for(const r of t)r.scope===e&&r.cancel();return v},markScopeDestroyed:e=>(void 0!==e&&(t(e)?c.add(e):u.add(e),v.cancelScope(e)),v),reviveScope:e=>(void 0!==e&&(t(e)?c.delete(e):u.delete(e)),v),isScopeDestroyed:e=>O(e),inspect(){const e={};for(const[t,r]of a)e[t]=r.filter(e=>!e.canceled).length;return{strategy:h,phases:[...s],pending:e,scopesDestroyed:u.size,flushing:y,scheduled:g}},destroy(){d=!0;for(const e of a.values()){for(const t of e)t.cancel();e.length=0}i.clear(),u.clear()}};return v;function S(){var e;"manual"===h||d||y||w>0||g||(g=!0,e=()=>{d||v.flush().catch($)},"function"!=typeof queueMicrotask?Promise.resolve().then(e):queueMicrotask(e))}async function E(e,t){const n=a.get(e),o=[],s=[];for(const e of n.splice(0))e.canceled||(void 0===t||e.scope===t?s.push(e):o.push(e));n.push(...o);for(const e of s)if(e.key&&i.delete(e.key),!e.canceled&&!O(e.scope))try{await e.fn()}catch(t){if(!f)throw r(t,e);f(t,e)}}function $(e){"function"!=typeof globalThis.reportError?setTimeout(()=>{throw e},0):globalThis.reportError(e)}function A(){for(const e of a.values())if(e.some(e=>!e.canceled))return!0;return!1}function j(e){for(const t of a.values())if(t.some(t=>!t.canceled&&t.scope===e))return!0;return!1}function R(){if(d)throw new Error("Scheduler has been destroyed.")}function O(e){return void 0!==e&&(t(e)?c.has(e):u.has(e))}}}})(),f=(()=>{const{renderComponent:e}=i,{createHandlerRegistry:t}=u,{createScheduler:r}=l,{createSignalRegistry:n,isSignalRef:a}=s,{matchAttribute:c,normalizeAttributeConfig:f,readAttribute:p}=o,h="__async:inline:";function d({root:o,signals:s,handlers:i,server:u,router:l,cache:d,attributes:E,scheduler:O}={}){const T=o?.ownerDocument??o??globalThis.document,C=o??T,q=s??n(),M=i??t(),x=O??r(),L=!O,D=f(E),P=new Set,B=new WeakMap,N=new WeakMap,z=new WeakSet,H=new WeakSet,U=new WeakMap,W=new WeakSet,V=new Map,I=new WeakMap;let F=0,J=!1;const K={root:C,signals:q,handlers:M,server:u,router:l,cache:d,scheduler:x,attributes:D,start:()=>(ne(),K.scan(C),K),scan:(e=C)=>(ne(),function(e){for(const t of j(e))x.reviveScope?.(t)}(e),function(e){for(const t of j(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"signal");if(r){if("text"===r){const r=t.getAttribute(e);G(t,`text:${r}`,r,e=>{t.textContent=e??""});continue}if("value"===r){const r=t.getAttribute(e);G(t,`value:${r}`,r,e=>{"value"in t&&t.value!==String(e??"")?t.value=e??"":"value"in t||t.setAttribute("value",e??"")}),Q(t,r);continue}if(r.startsWith("attr:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`attr:${n}:${o}`,o,e=>$(t,n,e));continue}if(r.startsWith("prop:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`prop:${n}:${o}`,o,e=>A(t,n,e));continue}if(r.startsWith("class:")){const n=r.slice(6),o=t.getAttribute(e);""===n||"{}"===n?Y(t,n,o):G(t,`class:${n}:${o}`,o,e=>{t.classList.toggle(n,Boolean(e))});continue}if("class"===r){const r=t.getAttribute(e);Y(t,"{}",r)}}}}(e),function(e){for(const t of j(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"class");null!=r&&Y(t,r,t.getAttribute(e))}}(e),function(e){for(const t of j(e))if("function"==typeof t.getAttributeNames)for(const e of t.getAttributeNames()){const r=c(e,D,"on");r&&"attach"!==r&&"mount"!==r&&"visible"!==r&&Z(t,r,t.getAttribute(e))}}(e),function(e){for(const t of j(e)){if(W.has(t))continue;const e=R(t,D);if(null!=e){if(!U.has(t)){const r=S(t,e,D);if(0===Object.keys(r).length||!q.has(e))continue;const n={id:e,templates:r,cleanup:q.subscribe(`${e}.$status`,()=>{x.enqueue("binding",()=>X(t),{scope:t,key:`boundary:${e}`})})};U.set(t,n),oe(n.cleanup,t)}X(t)}}}(e),function(e){for(const t of j(e)){const e=ee(t,["attach","mount"]);if(0!==e.length&&!z.has(t)){z.add(t);for(const r of e)ue(t,()=>te(t,r),`attach:${r}`)}}for(const t of j(e)){const e=p(t,D,"on","visible");null!=e&&(H.has(t)||(H.add(t),oe(re(t,()=>ue(t,()=>te(t,e),`visible:${e}`)),t)))}}(e),K),swap(e,t){ne();const r=function(e,t,r){for(const n of j(e))if(R(n,r)===String(t))return n;return null}(C,e,D);if(!r)throw new Error(`Boundary "${e}" was not found.`);return ae(r),r.replaceChildren(k(t,T)),K.scan(r),r},mount(t,r,n={}){ne();const o=e(r,n,{signals:q,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,attributes:D});return ae(t),t.replaceChildren(k(o.html,t.ownerDocument)),K.scan(t),o.mount(t),o.visible(t,K._observeVisible),oe(o.cleanup,t,"children"),o},destroy(){if(!J){J=!0,function(e){for(const t of j(e))x.markScopeDestroyed(t)}(C);for(const e of[...P])se(e);P.clear(),L&&x.destroy()}},_observeVisible:(e,t)=>re(e,t),_registerBinding(e){const t=`${h}${++F}`;return V.set(t,e),t},_releaseBinding(e){V.delete(e)}};function Z(e,t,r){const n=`${t}:${r}`,o=B.get(e)??new Set;if(o.has(n))return;o.add(n),B.set(e,o);const s=async t=>{try{await x.batch(()=>M.run(r,{signals:q,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,event:t,element:e,el:e,root:C}))}catch(t){_(e,t)}};e.addEventListener(t,s),oe(()=>e.removeEventListener(t,s),e)}function Y(e,t,r){if(""===t||"{}"===t){const t=b(e);let n=new Set;return void G(e,`class:{}:${r}`,r,r=>{const o=y(r),s=b(e);for(const e of n)o.has(e)||t.has(e)||s.delete(e);for(const e of o)s.add(e);v(e,s),n=o},{rawInline:!0})}G(e,`class:${t}:${r}`,r,r=>{!function(e,t,r){const n=b(e);for(const e of y(t))r?n.add(e):n.delete(e);v(e,n)}(e,t,Boolean(r))})}function G(e,t,r,n,o={}){const s=N.get(e)??new Set;if(s.has(t))return;s.add(t),N.set(e,s);const a=()=>function(e,t={}){if(m(e)){const r=V.get(e);return t.rawInline?r:g(r)}return q.get(e)}(r,o);n(a()),oe(function(e,t){if(!m(e))return q.subscribe(e,t);const r=w(V.get(e)).map(e=>e.subscribe(t));return()=>{for(const e of r)e()}}(r,()=>{x.enqueue("binding",()=>n(a()),{scope:e,key:t})}),e)}function Q(e,t){Z(e,"input",`__async:set:${t}`),Z(e,"change",`__async:set:${t}`),M.resolve(`__async:set:${t}`)||M.register(`__async:set:${t}`,({element:e})=>{!function(e,t){if(!m(e))return q.set(e,t);const r=V.get(e);if(a(r))return r.set(t);throw new Error(`Inline binding "${e}" is not writable.`)}(t,e.value)})}function X(e){const t=U.get(e);if(!t)return;const r=q.get(`${t.id}.$status`),n=function(e,t){return"ready"===t?e.ready??e.loading??e.error:"error"===t?e.error??e.ready??e.loading:e.loading??e.ready??e.error}(t.templates,r);if(n){ae(e),e.replaceChildren(n.content.cloneNode(!0)),W.add(e);try{K.scan(e)}finally{W.delete(e)}}}function ee(e,t){const r=[];for(const n of t){const t=p(e,D,"on",n);null!=t&&r.push(t)}return r}async function te(e,t){try{const r=await M.run(t,{signals:q,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,element:e,el:e,root:C});for(const t of r)"function"==typeof t&&oe(t,e)}catch(t){_(e,t)}}function re(e,t){const r=(e.ownerDocument?.defaultView??globalThis).IntersectionObserver??globalThis.IntersectionObserver;if(!r)return x.enqueue("lifecycle",()=>{J||t(e)},{scope:e,key:"visible:fallback"}),()=>{};const n=new r(r=>{r.some(e=>e.isIntersecting)&&(n.disconnect(),t(e))});return n.observe(e),()=>n.disconnect()}function ne(){if(J)throw new Error("Loader has been destroyed.")}function oe(e,t,r="self"){if("function"!=typeof e)return e;if(P.add(e),t){const n=I.get(t)??[];n.push({cleanup:e,mode:r}),I.set(t,n)}return e}function se(e){"function"==typeof e&&P.has(e)&&(P.delete(e),e())}function ae(e){ce(e,"children");for(const t of[...e.childNodes??[]])ie(t)}function ie(e){if(1===e.nodeType)for(const t of j(e))ce(t),x.markScopeDestroyed(t)}function ce(e,t){const r=I.get(e);if(!r)return;const n=[];for(const e of r)t&&e.mode!==t?n.push(e):se(e.cleanup);n.length>0?I.set(e,n):I.delete(e)}function ue(e,t,r){x.enqueue("lifecycle",t,{scope:e,key:r})}return q._setContext?.({server:K.server,router:K.router,loader:K,cache:K.cache,scheduler:x}),K.server?._setContext?.({signals:q,handlers:M,loader:K,router:K.router,cache:K.cache,scheduler:x}),K}function y(e,t=new Set){if(null==e||!1===e)return t;if(a(e)){const r=e.value;return!0===r?(t.add(e.id.split(".").at(-1)),t):y(r,t)}if("string"==typeof e){for(const r of e.split(/\s+/).filter(Boolean))t.add(r);return t}if(Array.isArray(e)){for(const r of e)y(r,t);return t}if("object"==typeof e){for(const[r,n]of Object.entries(e))(a(n)?n.value:n)&&y(r,t);return t}return!0!==e&&t.add(String(e)),t}function g(e){return a(e)?e.value:Array.isArray(e)?e.map(g):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,g(t)])):e}function w(e,t=new Map){if(a(e))return t.set(e.id,e),[...t.values()];if(Array.isArray(e)){for(const r of e)w(r,t);return[...t.values()]}if(e&&"object"==typeof e)for(const r of Object.values(e))w(r,t);return[...t.values()]}function m(e){return"string"==typeof e&&e.startsWith(h)}function b(e){return y(e.getAttribute("class")??"")}function v(e,t){const r=[...t].join(" ");0!==r.length?e.setAttribute("class",r):e.removeAttribute("class")}function S(e,t,r){const n={};for(const o of[...e.children].filter(e=>"TEMPLATE"===e.tagName))E(o,"loading",t,e,r)&&(n.loading=o),E(o,"ready",t,e,r)&&(n.ready=o),E(o,"error",t,e,r)&&(n.error=o);return n}function E(e,t,r,n,o){return p(e,o,"async",t)===r||O(n)&&e.hasAttribute?.(t)}function $(e,t,r){if(!1===r||null==r)return e.removeAttribute(t),void(t in e&&(e[t]=!1));e.setAttribute(t,!0===r?"":String(r)),t in e&&(e[t]=r)}function A(e,t,r){e[t]=null!=r?r:""}function j(e){return function(e,t){const r=[];return 1===e?.nodeType&&e.matches?.(t)&&r.push(e),r.push(...e?.querySelectorAll?.(t)??[]),r}(e,"*")}function R(e,t){return O(e)&&e.hasAttribute?.("for")?e.getAttribute("for"):p(e,t,"async","boundary")}function O(e){return"ASYNC-SUSPENSE"===e?.tagName}function k(e,t){if(11===e?.nodeType)return e;if("TEMPLATE"===e?.tagName)return e.content.cloneNode(!0);if(e?.nodeType){const r=t.createDocumentFragment();return r.append(e),r}const r=t.createElement("template");return r.innerHTML=String(e??""),r.content.cloneNode(!0)}function _(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;e.dispatchEvent(new r("async:error",{bubbles:!0,detail:{error:t}}))}return{Loader:d,AsyncLoader:d}})(),p=(()=>{const{isTemplateResult:e,renderTemplate:n}=a,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t;function u(e,t={}){return r=e,Boolean(r&&"object"==typeof r&&!Array.isArray(r)&&(Object.hasOwn(r,"html")||Object.hasOwn(r,"signals")||Object.hasOwn(r,"boundary")||Object.hasOwn(r,"redirect")||Object.hasOwn(r,"status")||Object.hasOwn(r,"cache")))?{...e,html:Object.hasOwn(e,"html")?l(e.html,t):e.html}:{html:l(e,t)};var r}function l(t,r){return t?.nodeType||"string"==typeof t?t:(e(t),n(t,function(e){return{attributes:e.loader?.attributes,signals:e.signals,bind:e.loader?._registerBinding?.bind(e.loader)}}(r)))}function f(e){if("string"!=typeof e||0===e.length)throw new TypeError("Partial id must be a non-empty string.")}return{createPartialRegistry:function(e={},t={}){const r=t.registry??s(),n=t.type??"partial",a=r._map(n),l=t.lazyRegistry??i(t),p=new Map,h=o({register(e,t){if(f(e),"function"!=typeof t&&!c(t))throw new TypeError(`Partial "${e}" must be a function.`);if(a.has(e))throw new Error(`Partial "${e}" is already registered.`);return a.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))h.register(t,r);return h},unregister:e=>(f(e),p.delete(e),a.delete(e)),resolve(e){f(e);const t=a.get(e);return c(t)?(p.has(e)||p.set(e,async function(...r){const o=await l.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Partial "${e}" did not resolve to a function.`);return o.apply(this,r)}),p.get(e)):t},async render(e,t={},r={}){f(e);const n=h.resolve(e);if(!n)throw new Error(`Partial "${e}" is not registered.`);const o={...r,id:e,props:t,cache:r.cache,partials:h};return u(await n.call(o,t),o)},_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))a.has(t)||h.register(t,r);return h}},r,n);return h.registerMany(e),h},normalizePartialResult:u}})(),h=(()=>{const{Loader:e}=f,{createHandlerRegistry:t}=u,{createScheduler:n}=l,{createSignalRegistry:a}=s,{applyServerResult:i}=c,{createRegistryStore:p}=r,{normalizeAttributeConfig:h}=o;function d(e,t={}){return{...t,partial:e}}const y=d,g=new Set(["csr","spa","ssr","mpa"]);function w(e={},t={}){const r=t.registry??p(),n=t.type??"route",o=r._map(n),s=[],a={registry:r,register(e,t){if(A(e),s.some(t=>t.pattern===e))throw new Error(`Route "${e}" is already registered.`);const r=m(e,t);return o.set(e,r.definition),s.push(r),E(s),r},registerMany(e){for(const[t,r]of Object.entries(e??{}))a.register(t,r);return a},unregister(e){A(e);const t=s.findIndex(t=>t.pattern===e);return-1!==t&&s.splice(t,1),o.delete(e)},match(e){const t=function(e){return e instanceof URL?e:new URL(String(e),globalThis.location?.href??"http://localhost/")}(e).pathname;for(const e of s){const r=e.regex.exec(t);if(!r)continue;const n={};return e.keys.forEach((e,t)=>{n[e]=S(r[t+1]??"")}),{pattern:e.pattern,params:n,route:e.definition}}return null},entries:()=>s.map(({pattern:e,definition:t})=>({pattern:e,route:t})),keys:()=>[...o.keys()],inspect:()=>r.entries(n),_adoptMany(e={}){for(const[t,r]of Object.entries(e??{}))o.has(t)?i(t,o.get(t)):a.register(t,r);return a}};for(const[e,t]of o)i(e,t);return a.registerMany(e),a;function i(e,t){if(s.some(t=>t.pattern===e))return;const r=m(e,t);o.set(e,r.definition),s.push(r),E(s)}}function m(e,t){const r="string"==typeof t?d(t):t,{regex:n,keys:o}=function(e){const t=[];if("*"===e)return{regex:/^.*$/,keys:t};if("/"===e)return{regex:/^\/$/,keys:t};const r=e.split("/").map(e=>e.startsWith(":")?(t.push(e.slice(1)),"([^/]+)"):String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return{regex:new RegExp(`^${r}$`),keys:t}}(e);return{pattern:e,regex:n,keys:o,score:$(e),definition:r}}function b(e,t){return e?.closest?.(t)}function v(e){return Object.fromEntries(e.searchParams.entries())}function S(e){try{return decodeURIComponent(e)}catch{return e}}function E(e){e.sort((e,t)=>t.score-e.score||t.pattern.length-e.pattern.length)}function $(e){return"*"===e?-1:e.split("/").filter(Boolean).reduce((e,t)=>"*"===t?e:t.startsWith(":")?e+2:e+4,"/"===e?3:0)}function A(e){if("string"!=typeof e||"*"!==e&&!e.startsWith("/"))throw new TypeError('Route pattern must be a path string or "*".')}return{defineRoute:d,createRouteRegistry:w,createRouter:function({mode:r="ssr",root:o,boundary:s="route",routes:c=w(),loader:u,signals:l,handlers:f,server:p,cache:d,partials:y,attributes:m,scheduler:S}={}){!function(e){if(!g.has(e))throw new TypeError(`Unknown router mode "${e}".`)}(r);const E=o?.ownerDocument??o??globalThis.document,$=o??E,A=l??u?.signals??a(),j=f??u?.handlers??t(),R=S??u?.scheduler??n(),O=!S&&!u?.scheduler,k=h(m??u?.attributes),_=u??e({root:$,signals:A,handlers:j,server:p,cache:d,scheduler:R,attributes:k}),T=!u,C=new Set;let q,M=!1,x=0;const L={mode:r,root:$,boundary:s,routes:c,loader:_,signals:A,handlers:j,server:p,cache:d,partials:y,scheduler:R,attributes:k,start:()=>(I(),_.router=L,A._setContext?.({router:L,loader:_,server:p,cache:d,scheduler:R}),T&&_.start(),"mpa"===r||"ssr"===r?(N(),L):(function(){const e=e=>{const t=b(e.target,"a[href]");t&&!function(e,t){if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;if(t.target||t.hasAttribute("download"))return!0;const r=V(t.href),n=W();return r.origin!==n.origin||function(e,t,r){return e.origin===t.origin&&e.pathname===t.pathname&&e.search===t.search&&(e.hash!==t.hash||!0===r.getAttribute?.("href")?.startsWith("#"))}(r,n,t)}(e,t)&&(e.preventDefault(),U(L.navigate(t.href)))},t=e=>{const t=b(e.target,"form");t&&!function(e){return"get"!==String(e.method||"get").toLowerCase()||V(e.action).origin!==W().origin}(t)&&(e.preventDefault(),U(L.navigate(function(e){const t=V(e.action||e.ownerDocument.defaultView.location.href),r=new e.ownerDocument.defaultView.FormData(e);return t.search=new URLSearchParams(r).toString(),t.href}(t))))},r=()=>U(L.navigate(W(),{history:!1}));$.addEventListener?.("click",e),$.addEventListener?.("submit",t),E.defaultView?.addEventListener?.("popstate",r),C.add(()=>$.removeEventListener?.("click",e)),C.add(()=>$.removeEventListener?.("submit",t)),C.add(()=>E.defaultView?.removeEventListener?.("popstate",r))}(),"csr"===r?(U(L.navigate(W(),{replace:!0,initial:!0,source:"client"})),L):(N(),L))),match:e=>c.match(V(e)),prefetch(e){if(I(),"mpa"===r||"ssr"===r)return Promise.resolve(null);const t=L.match(e);return t?.route?.partial&&y?.resolve?.(t.route.partial)?y.render(t.route.partial,t.params,{...D(t),prefetch:!0}):Promise.resolve(null)},navigate:async(e,t={})=>(I(),"mpa"===r||"ssr"===r?(E.defaultView?.location?.assign?.(e),null):async function(e,t={}){const r=L.match(e);if(!r)return P(e,null),function(e){z(e,null,{pending:!1,error:new Error(`No route matched ${e.pathname}${e.search}`)})}(e),null;const n=P(e,r);z(e,r,{pending:!0,error:null});try{if(!r.route?.partial||!y?.resolve?.(r.route.partial)){const t=new Error(`Route "${e.pathname}" does not have a registered partial.`);return B(n)&&H({pending:!1,error:t}),null}const o=await y.render(r.route.partial,r.params,D(r,n));return B(n)?(await async function(e,t,r,n){B(n)&&(await i(e,{signals:A,loader:_,router:L,cache:d,scheduler:R,abort:n?.abort}),await R.flush(),B(n)&&(null==e?.html||e.boundary||e.redirect||(_.swap(s,e.html),await R.flush()),e?.redirect||!1===r.history||(r.replace?E.defaultView?.history?.replaceState?.({},"",t.href):E.defaultView?.history?.pushState?.({},"",t.href))))}(o,e,t,n),B(n)?(H({pending:!1,error:null}),o):null):null}catch(e){if(!B(n))return null;throw H({pending:!1,error:e}),e}}(V(e),t)),destroy(){if(!M){M=!0,q?.controller.abort(new Error("Router has been destroyed."));for(const e of C)e();C.clear(),O&&R.destroy()}}};return L;function D(e,t){return{params:e.params,route:e.route,router:L,signals:A,handlers:j,loader:_,server:p,cache:d,scheduler:R,abort:t?.abort}}function P(e,t){q?.controller.abort(new Error(`Router navigation superseded by ${e.pathname}${e.search}.`));const r=new AbortController,n={id:++x,controller:r,abort:r.signal,target:e,matched:t};return q=n,n}function B(e){return!M&&e&&q?.id===e.id&&!e.abort.aborted}function N(){const e=W();z(e,L.match(e),{pending:!1,error:null})}function z(e,t,r={}){A.ensure("router",{}),H({url:e.href,path:e.pathname,query:v(e),params:t?.params??{},route:t?.route??null,...r})}function H(e){A.ensure("router",{});for(const[t,r]of Object.entries(e))A.set(`router.${t}`,r)}function U(e){e.catch(e=>{M||(H({pending:!1,error:e}),function(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;"function"==typeof r&&e.dispatchEvent?.(new r("async:error",{bubbles:!0,detail:{error:t}}))}($,e))})}function W(){return V(E.defaultView?.location?.href??"http://localhost/")}function V(e){return e instanceof URL?e:new URL(String(e),E.defaultView?.location?.href??"http://localhost/")}function I(){if(M)throw new Error("Router has been destroyed.")}},route:y}})(),d=(()=>{const{createCacheRegistry:e}=n,{createComponentRegistry:a}=i,{createHandlerRegistry:d}=u,{Loader:y}=f,{createPartialRegistry:g}=p,{createRouteRegistry:w,createRouter:m}=h,{createScheduler:b}=l,{createServerNamespace:v}=c,{cloneSignalDeclaration:S,createSignal:E,createSignalRegistry:$}=s,{createRegistryStore:A}=r,{attributeName:j,normalizeAttributeConfig:R}=o,{createLazyRegistry:O,defineRegistrySnapshot:k,sameRegistryValue:_}=t,T=new Set(["signal","handler","server","partial","route","component","asyncSignal"]);function C(e,t={}){const r=A(void 0,{target:"browser"}),n=new Set,o=t.createRuntime??q,s={registry:r,use(e,t){const o=function(e,t){const r={signal:{},handler:{},server:{},partial:{},route:{},component:{},asyncSignal:{},cache:{browser:{},server:{}}};if("string"==typeof e){if(!T.has(e))throw new Error(`Unknown Async registry type "${e}".`);return r[e]=F(e,t),r}if(!e||"object"!=typeof e)throw new TypeError("Async.use(...) requires a registry type or module object.");for(const[t,n]of Object.entries(e))if("cache"!==t){if(!T.has(t))throw new Error(`Unknown Async registry type "${t}".`);r[t]=F(t,n)}else r.cache.browser={...n?.browser??{}},r.cache.server={...n?.server??{}};return r}(e,t);!function(e,t){for(const r of T)P(e,r,t[r]);P(e,"cache.browser",t.cache.browser),P(e,"cache.server",t.cache.server)}(r,o);for(const e of n)e._applyUse(o);return s},snapshot:()=>r.rawSnapshot(),start(e={}){const t=o(s,e).start();return s.runtime=t,t},attachRoot:e=>function(e){return e.runtime||e.start(),e.runtime}(s).attachRoot(e),detachRoot:e=>s.runtime?.detachRoot(e)??s,applySnapshot:(e,t={})=>s.runtime?(s.runtime.applySnapshot(e,t),s):(function(e,t={},r={}){const n=z(t);for(const[t,o]of Object.entries(n.signal))N(e,"signal",t,E(o),r);for(const t of["handler","server","partial","route","component","asyncSignal"])for(const[o,s]of Object.entries(n[t]))N(e,t,o,s,r)}(r,e,t),s),inspectRoots:()=>s.runtime?.inspectRoots()??{count:0,roots:[]},_attach:e=>(n.add(e),()=>s._detach(e)),_detach(e){n.delete(e)}};return e&&s.use(e),s}function q(t=M,r={}){const n=(q=t,Boolean(q&&"function"==typeof q.use&&"function"==typeof q.snapshot&&q.registry)?t:C(t??{})),o=r.target??"browser",s=r.scheduler??r.loader?.scheduler??b({strategy:"server"===o?"manual":"microtask"}),i=!r.scheduler&&!r.loader?.scheduler,c=R(r.attributes),u=r.lazyRegistry??O({registryAssets:r.registryAssets,importModule:r.importModule}),l=r.registry??function(e,{target:t}={}){const r=e.rawSnapshot();return A({...r,signal:D(r.signal)},{target:t})}(n.registry,{target:o}),f=r.signals??$(void 0,{registry:l,type:"signal",lazyRegistry:u}),p=r.handlers??d(void 0,{registry:l,type:"handler",lazyRegistry:u}),h=e(void 0,{registry:l,type:"cache.server"}),v=e(void 0,{registry:l,type:"cache.browser"}),S=r.serverFactory??I,E=r.server??S(void 0,{registry:l,type:"server"}),j=r.partials??g(void 0,{registry:l,type:"partial",lazyRegistry:u}),k=r.routes??w(void 0,{registry:l,type:"route"}),_=r.components??a(void 0,{registry:l,type:"component",lazyRegistry:u}),T=r.loader||Object.hasOwn(r,"root")?r.root:null;var q;let P=r.loader,N=r.router,H=!1,U=()=>{},F=!1,J=!1;const Z=new Map,Y=T??globalThis.document,G=r.snapshot??("browser"===o?x(Y,{attributes:c}):void 0);!function(e,t){try{e.cache=t}catch{}}(E,h);const Q={app:n,registry:l,target:o,signals:f,handlers:p,server:E,partials:j,routes:k,components:_,browser:{cache:v},loader:P,router:N,scheduler:s,attributes:c,start:()=>(ne(),F||(F=!0,"server"!==o?(te({cache:v}),f._setContext?.({server:E,loader:P,cache:v,scheduler:s}),P?(X(P.root,P),P.start(),ee(P.root)):null!=T&&Q.attachRoot(T)):(te({cache:h}),f._setContext?.({server:E,cache:h,scheduler:s}))),Q),use:(e,t)=>(n.use(e,t),Q),attachRoot(e){if(ne(),"server"===o)throw new Error("Server runtimes cannot attach DOM roots.");if(!e)throw new TypeError("runtime.attachRoot(root) requires a root.");if(Z.has(e))return Q;const t=0===Z.size&&P?P:y({root:e,signals:f,handlers:p,server:E,cache:v,scheduler:s,attributes:c});return X(e,t),t.start(),te({cache:v}),f._setContext?.({server:E,loader:Q.loader,cache:v,scheduler:s}),ee(e),Q},detachRoot(e){if(ne(),"server"===o)return Q;if(null==e){for(const e of new Set(Z.values()))e.destroy?.();return Z.clear(),N?.destroy?.(),N=void 0,H=!1,P=void 0,Q.loader=void 0,Q.router=void 0,Q}const t=Z.get(e);if(!t)return Q;if(t.destroy?.(),Z.delete(e),P===t){N?.destroy?.(),N=void 0,H=!1;const e=Z.values().next().value;P=e,Q.loader=e,Q.router=void 0,e&&ee(e.root)}return Q},inspectRoots:()=>({count:Z.size,roots:[...Z].map(([e,t])=>({root:e,loader:t,primary:t===P}))}),applySnapshot:(e,t={})=>(function(e,t={},r={}){const n=z(t);B(e,"asyncSignal",n.asyncSignal,null,r);for(const[t,r]of Object.entries(n.signal))W(e.signals,t,r);e.browser.cache.restore(n.cache.browser),B(e,"handler",n.handler,e.handlers,r),B(e,"server",n.server,e.server,r),B(e,"partial",n.partial,e.partials,r),B(e,"route",n.route,e.routes,r),B(e,"component",n.component,e.components,r)}(Q,e,t),Q),async render(e){ne(),te({cache:h}),f._setContext?.({server:E,cache:h,scheduler:s});const t=k.match(e);if(!t)return await s.flush(),{html:K("",{status:404,signals:f,browserCache:v,boundary:r.boundary??"route",attributes:c}),status:404,signals:f.snapshot(),cache:{browser:v.snapshot()}};const n=t.route.partial,o=n&&j.resolve(n)?await j.render(n,t.params,{params:t.params,route:t.route,signals:f,handlers:p,server:E,cache:h,browserCache:v,partials:j,scheduler:s,...re()}):{html:""};if(o.signals)for(const[e,t]of Object.entries(o.signals))V(f,e,t);o.cache?.browser&&v.restore(o.cache.browser),await s.flush();const a=o.status??200;return{html:K(o.html,{status:a,signals:f,browserCache:v,boundary:o.boundary??r.boundary??"route",attributes:c}),status:a,signals:f.snapshot(),cache:{browser:v.snapshot()}}},destroy(){if(J)return;J=!0,U(),N?.destroy?.();const e=new Set(Z.values());for(const t of e)t.destroy?.();Z.clear(),P&&!e.has(P)&&P?.destroy?.(),f.destroy?.(),i&&s.destroy()},_applyUse(e){!function(e,t){L(e.signals,e.registry,t.signal),L(e.handlers,e.registry,t.handler),L(e.server,e.registry,t.server),L(e.partials,e.registry,t.partial),L(e.routes,e.registry,t.route),L(e.components,e.registry,t.component),function(e,t,r){if(r&&0!==Object.keys(r).length)for(const[n,o]of Object.entries(r))e.has(t,n)||e.register(t,n,o)}(e.registry,"asyncSignal",t.asyncSignal),L(e.browser.cache,e.registry,t.cache.browser),L(e.server.cache,e.registry,t.cache.server)}(Q,e)}};return E.cache=h,Q.server.cache=h,Q.applySnapshot(G,{strict:r.strictSnapshots??!0}),U=n._attach(Q),Q;function X(e,t){Z.set(e,t),P||(P=t,Q.loader=t),t.server=E,t.cache=v,t.scheduler=s}function ee(e){!1!==N&&!H&&(N||function(e,t){return Boolean(t.routerOptions||t.mode||e.entries().length>0)}(k,r))&&Q.loader&&(N=N??m({mode:r.mode??"ssr",root:e,boundary:r.boundary??"route",routes:k,loader:Q.loader,signals:f,handlers:p,server:E,cache:v,partials:j,scheduler:s,attributes:c}),Q.router=N,Q.loader.router=N,te({cache:v,router:N}),N.start(),H=!0)}function te(e={}){const t=function(e){return"function"==typeof e?.registerMany}(E)?h:e.cache;E._setContext?.({signals:f,loader:P,router:N,cache:t,scheduler:s,requestContext:r.requestContext,...re()})}function re(){const e=(t=r.requestContext)?"function"==typeof t.get?t.get()??{}:"function"==typeof t.getStore?t.getStore()??{}:{}:{};var t;return{requestContext:e,request:e.request??r.request,headers:e.headers??r.headers,cookies:e.cookies??r.cookies,locals:e.locals??r.locals}}function ne(){if(J)throw new Error("Async app runtime has been destroyed.")}}const M=C();function x(e=globalThis.document,{attributes:t}={}){const r=R(t),n=j(r,"async","snapshot"),o=e?.ownerDocument??e??globalThis.document,s=e??o;if(!s?.querySelectorAll&&!o?.querySelectorAll)return{};const a={};for(const e of new Set([s,o]))if(e?.querySelectorAll)for(const t of e.querySelectorAll("script[type='application/json'], script")){if(!t.hasAttribute?.(n))continue;const e=t.textContent?.trim()??"";if(!e)continue;let r;try{r=JSON.parse(e)}catch(e){throw new Error(`Could not parse Async snapshot: ${e instanceof Error?e.message:String(e)}`)}H(a,r,{strict:!0})}return a}function L(e,t,r){r&&0!==Object.keys(r).length&&(e?.registry!==t?e?.registerMany?.(r):e._adoptMany?.(r))}function D(e={}){const t={};for(const[r,n]of Object.entries(e??{}))t[r]=S(n);return t}function P(e,t,r){for(const[n,o]of Object.entries(r??{}))e.register(t,n,o)}function B(e,t,r,n,o={}){if(r&&0!==Object.keys(r).length){for(const[n,s]of Object.entries(r)){if("asyncSignal"===t&&e.signals?.has?.(n)&&!e.registry.has(t,n))throw new Error(`Signal "${n}" is already registered.`);N(e.registry,t,n,s,o)}n?._adoptMany?.(r)}}function N(e,t,r,n,o={}){const s=o.strict??!0,a=e._map(t);if(a.has(r)){if(_(a.get(r),n)||U(a.get(r),n))return;if(s)throw new Error(`${t} "${r}" is already registered with a different value.`)}else e.set(t,r,n)}function z(e={}){return{signal:{...e.signals??{},...e.signal??{}},handler:{...e.handler??{}},server:{...e.server??{}},partial:{...e.partial??{}},route:{...e.route??{}},component:{...e.component??{}},asyncSignal:{...e.asyncSignal??{}},cache:{browser:{...e.entries?.browser??{},...e.cache?.browser??{}}}}}function H(e,t,r={}){const n=z(k(t));e.signal={...e.signal??e.signals??{},...n.signal},e.signals=e.signal,e.cache={...e.cache??{},browser:{...e.cache?.browser??{},...n.cache.browser}};for(const t of["handler","server","partial","route","component","asyncSignal"]){e[t]=e[t]??{};for(const[o,s]of Object.entries(n[t]))if(Object.hasOwn(e[t],o)){if(_(e[t][o],s)||U(e[t][o],s))continue;if(r.strict??1)throw new Error(`${t} "${o}" is already declared with a different value.`)}else e[t][o]=s}return e}function U(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function W(e,t,r){if(e.has?.(t)){const n=e._entry?.(t);return"function"==typeof n?._restore&&function(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Object.hasOwn(e,"value")&&(Object.hasOwn(e,"loading")||Object.hasOwn(e,"error")||Object.hasOwn(e,"status")||Object.hasOwn(e,"version"))}(r)?void n._restore(r):void e.set(t,r)}e.register(t,E(r))}function V(e,t,r){if("function"==typeof e._setPath)return void e._setPath(t,r);const n=String(t).split(".")[0];e.has?.(n)?e.set(t,r):(e.register(n,E(t===n?r:{})),t!==n&&e.set(t,r))}function I(e={},t={}){const r=t.registry??A(),n=t.type??"server",o={},s={registry:r,register:(e,t)=>(r.register(n,e,t),e),registerMany(e){for(const[t,r]of Object.entries(e??{}))s.register(t,r);return s},unregister:e=>r.unregister(n,e),resolve(){},async run(e){throw new Error(`Server command "${e}" cannot run without a server proxy or server registry.`)},keys:()=>r.keys(n),entries:()=>r.entries(n),inspect:()=>r.entries(n),_setContext:(e={})=>(Object.assign(o,e),s),_adoptMany:()=>s};return s.registerMany(e),v((e,t,r)=>s.run(e,t,r),s,()=>o)}function F(e,t={}){if("signal"!==e)return{...t??{}};const r={};for(const[e,n]of Object.entries(t??{}))r[e]=J(n);return r}function J(e){return e&&"object"==typeof e&&"function"==typeof e.subscribe?e:E(e)}function K(e,{signals:t,browserCache:r,boundary:n,attributes:o}){const s={signals:t.snapshot(),cache:{browser:r.snapshot()}},a=j(o,"async","boundary"),i=j(o,"async","snapshot");return`<section ${a}="${c=n,String(c).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}">${e??""}</section><script type="application/json" ${i}>${function(e){return JSON.stringify(e).replaceAll("<","\\u003c")}(s)}<\/script>`;var c}return{defineApp:C,createApp:q,readSnapshot:x,Async:M}})(),y=(()=>{function e(e){if("string"!=typeof e||0===e.length)throw new TypeError("Boundary patch boundary must be a non-empty string.")}function t(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))}return{createBoundaryReceiver:function(r={}){const n=r.loader,o=r.signals??n?.signals,s=r.cache??n?.cache,a=r.scheduler??n?.scheduler,i=r.router??n?.router,c=r.recentLimit??50,u=!0===r.throwOnError,l="function"==typeof r.onApply?r.onApply:void 0,f="function"==typeof r.onIgnore?r.onIgnore:void 0,p="function"==typeof r.onError?r.onError:void 0,h="function"==typeof r.isScopeDestroyed?r.isScopeDestroyed:e=>a?.isScopeDestroyed?.(e)??a?.inspectDestroyed?.(e)??!1;if(!n||"function"!=typeof n.swap)throw new TypeError("createBoundaryReceiver(...) requires a loader with swap(boundary, html).");if(!Number.isInteger(c)||c<0)throw new TypeError("createBoundaryReceiver(...) recentLimit must be a non-negative integer.");const d=new Map,y=[];let g=!1;const w={async apply(r){if(g)throw new Error("Boundary receiver has been destroyed.");const c=function(r){if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError("receiver.apply(patch) requires a boundary patch object.");if(e(r.boundary),"number"!=typeof r.seq||!Number.isFinite(r.seq))throw new TypeError("Boundary patch seq must be a finite number.");if(void 0!==r.signals&&!t(r.signals))throw new TypeError("Boundary patch signals must be an object.");if(void 0!==r.cache&&!t(r.cache))throw new TypeError("Boundary patch cache must be an object.");if(void 0!==r.cache?.browser&&!t(r.cache.browser))throw new TypeError("Boundary patch cache.browser must be an object.");if(void 0!==r.redirect&&("string"!=typeof r.redirect||0===r.redirect.length))throw new TypeError("Boundary patch redirect must be a non-empty string.");if(void 0!==r.parentScope&&"string"!=typeof r.parentScope)throw new TypeError("Boundary patch parentScope must be a string.");if(void 0!==r.scope&&"string"!=typeof r.scope)throw new TypeError("Boundary patch scope must be a string.");const n=Object.hasOwn(r,"html")&&null!=r.html,o=r.signals&&Object.keys(r.signals).length>0,s=r.cache?.browser&&Object.keys(r.cache.browser).length>0,a=Boolean(r.redirect),i=Object.hasOwn(r,"error");if(!(n||o||s||a||i))throw new TypeError("Boundary patch must include html, signals, cache.browser, redirect, or error.");return r}(r),y=(w=c.boundary,d.has(w)||d.set(w,{lastSeq:-1/0,applied:0,ignored:0,errored:0,lastStatus:void 0}),d.get(w));var w,b;if(c.seq<=y.lastSeq){const e={status:"ignored-stale",boundary:c.boundary,seq:c.seq,lastSeq:y.lastSeq};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(void 0!==c.parentScope&&h(c.parentScope)){const e={status:"ignored-destroyed",boundary:c.boundary,seq:c.seq,parentScope:c.parentScope};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(y.lastSeq=c.seq,Object.hasOwn(c,"error")){const e=(b=c.error)instanceof Error?b:b&&"object"==typeof b&&"string"==typeof b.message?Object.assign(new Error(b.message),b):new Error(String(b)),t={status:"errored",boundary:c.boundary,seq:c.seq,error:e};if(y.errored+=1,y.lastStatus=t.status,m(t),p?.(e,t,r),u)throw e;return t}if(c.signals){if(!o||"function"!=typeof o.set)throw new Error("Boundary patch includes signals, but no signal registry is available.");for(const[e,t]of Object.entries(c.signals))o.set(e,t)}if(c.cache?.browser){if(!s||"function"!=typeof s.restore)throw new Error("Boundary patch includes browser cache, but no cache registry is available.");s.restore(c.cache.browser)}if(null!=c.html&&n.swap(c.boundary,c.html),await async function(e,t){e&&(void 0===t||"function"!=typeof e.flushScope?"function"==typeof e.flush&&await e.flush():await e.flushScope(t))}(a,c.scope),c.redirect){await async function(e,t,r){if(t&&"function"==typeof t.navigate)return void await t.navigate(e);const n=r?.root?.ownerDocument?.defaultView?.location??globalThis.location;n?.assign?.(e)}(c.redirect,i,n);const e={status:"redirected",boundary:c.boundary,seq:c.seq,redirect:c.redirect};return y.applied+=1,y.lastStatus=e.status,m(e),l?.(e,r),e}const v={status:"applied",boundary:c.boundary,seq:c.seq};return y.applied+=1,y.lastStatus=v.status,m(v),l?.(v,r),v},inspect(){const e={};for(const[t,r]of d)e[t]={lastSeq:r.lastSeq,applied:r.applied,ignored:r.ignored,lastStatus:r.lastStatus},r.errored>0&&(e[t].errored=r.errored);return{destroyed:g,boundaries:e,recent:y.map(e=>({...e}))}},reset(t){if(void 0===t)return d.clear(),y.length=0,w;e(t),d.delete(t);for(let e=y.length-1;e>=0;e-=1)y[e].boundary===t&&y.splice(e,1);return w},destroy(){g=!0,d.clear(),y.length=0}};return w;function m(e){if(0!==c)for(y.push(function(e){const t={boundary:e.boundary,seq:e.seq,status:e.status};return"ignored-stale"===e.status&&(t.lastSeq=e.lastSeq),"ignored-destroyed"===e.status&&void 0!==e.parentScope&&(t.parentScope=e.parentScope),"redirected"===e.status&&(t.redirect=e.redirect),t}(e));y.length>c;)y.shift()}}}})(),g=(()=>{function e(e){return e?.reason??new Error("Operation aborted")}return{delay:function(t,r){return r?.aborted?Promise.reject(e(r)):new Promise((n,o)=>{let s=setTimeout(function(){s=void 0,r?.removeEventListener?.("abort",a),n()},t);function a(){void 0!==s&&clearTimeout(s),s=void 0,r?.removeEventListener?.("abort",a),o(e(r))}r?.addEventListener?.("abort",a,{once:!0})})}}})(),w=(()=>{const{Async:e}=d;return{defineAsyncContainerElement:function(t={}){const r=t.tagName??"async-container",n=t.customElements??globalThis.customElements;if(!n)throw new Error("defineAsyncContainerElement(...) requires customElements.");const o=n.get(r);if(o)return o;const s=t.app??t.Async??e,a=t.HTMLElement??t.window?.HTMLElement??globalThis.HTMLElement;if(!a)throw new Error("defineAsyncContainerElement(...) requires HTMLElement.");class i extends a{connectedCallback(){if(this.__asyncAttached)return;const e=s.runtime??s.start?.();e?.attachRoot?.(this),this.__asyncRuntime=e,this.__asyncAttached=!0}disconnectedCallback(){this.__asyncAttached&&(this.__asyncRuntime?.detachRoot?.(this),this.__asyncRuntime=void 0,this.__asyncAttached=!1)}}return n.define(r,i),i},defineAsyncSuspenseElement:function(e={}){const t=e.tagName??"async-suspense",r=e.customElements??globalThis.customElements;if(!r)throw new Error("defineAsyncSuspenseElement(...) requires customElements.");const n=r.get(t);if(n)return n;const o=e.HTMLElement??e.window?.HTMLElement??globalThis.HTMLElement;if(!o)throw new Error("defineAsyncSuspenseElement(...) requires HTMLElement.");class s extends o{}return r.define(t,s),s}}})(),{asyncSignal:m}=e,{Async:b}=d,{createApp:v}=d,{defineApp:S}=d,{readSnapshot:E}=d,{attributeName:$}=o,{defineAttributeConfig:A}=o,{createBoundaryReceiver:j}=y,{createCacheRegistry:R}=n,{defineCache:O}=n,{component:k}=i,{createComponentRegistry:_}=i,{defineComponent:T}=i,{delay:C}=g,{defineAsyncContainerElement:q}=w,{defineAsyncSuspenseElement:M}=w,{createHandlerRegistry:x}=u,{html:L}=a,{createLazyRegistry:D}=t,{defineRegistrySnapshot:P}=t,{Loader:B}=f,{AsyncLoader:N}=f,{createPartialRegistry:z}=p,{createRegistryStore:H}=r,{createRouteRegistry:U}=h,{createRouter:W}=h,{defineRoute:V}=h,{route:I}=h,{createScheduler:F}=l,{applyServerResult:J}=c,{createServerProxy:K}=c,{resolveServerCommandArguments:Z}=c,{unwrapServerResult:Y}=c,{computed:G}=s,{createSignal:Q}=s,{createSignalRegistry:X}=s,{effect:ee}=s,{signal:te}=s,re={asyncSignal:m,Async:b,createApp:v,defineApp:S,readSnapshot:E,attributeName:$,defineAttributeConfig:A,createBoundaryReceiver:j,createCacheRegistry:R,defineCache:O,component:k,createComponentRegistry:_,defineComponent:T,delay:C,defineAsyncContainerElement:q,defineAsyncSuspenseElement:M,createHandlerRegistry:x,html:L,createLazyRegistry:D,defineRegistrySnapshot:P,Loader:B,AsyncLoader:N,createPartialRegistry:z,createRegistryStore:H,createRouteRegistry:U,createRouter:W,defineRoute:V,route:I,createScheduler:F,applyServerResult:J,createServerProxy:K,resolveServerCommandArguments:Z,unwrapServerResult:Y,computed:G,createSignal:Q,createSignalRegistry:X,effect:ee,signal:te};return function(e,t){const r=Object.keys(e).filter(e=>"Async"!==e&&Object.prototype.hasOwnProperty.call(t,e));if(r.length>0)throw new Error(`UMD Async namespace export conflict: ${r.join(", ")}.`)}(re,b),Object.assign(b,re),b.Async=b,b}();"function"==typeof define&&define.amd?define([],()=>t):"object"==typeof module&&module.exports?module.exports=t:(e.AsyncFramework=t,e.Async=t)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this);
|
package/framework.ts
CHANGED
|
@@ -3242,7 +3242,7 @@ const __schedulerModule = (() => {
|
|
|
3242
3242
|
scheduled = true;
|
|
3243
3243
|
scheduleMicrotask(() => {
|
|
3244
3244
|
if (!destroyed) {
|
|
3245
|
-
void api.flush();
|
|
3245
|
+
void api.flush().catch(reportAutomaticFlushError);
|
|
3246
3246
|
}
|
|
3247
3247
|
});
|
|
3248
3248
|
}
|
|
@@ -3278,12 +3278,22 @@ const __schedulerModule = (() => {
|
|
|
3278
3278
|
if (onError) {
|
|
3279
3279
|
onError(error, job);
|
|
3280
3280
|
} else {
|
|
3281
|
-
throw error;
|
|
3281
|
+
throw annotateSchedulerError(error, job);
|
|
3282
3282
|
}
|
|
3283
3283
|
}
|
|
3284
3284
|
}
|
|
3285
3285
|
}
|
|
3286
3286
|
|
|
3287
|
+
function reportAutomaticFlushError(error) {
|
|
3288
|
+
if (typeof globalThis.reportError === "function") {
|
|
3289
|
+
globalThis.reportError(error);
|
|
3290
|
+
return;
|
|
3291
|
+
}
|
|
3292
|
+
setTimeout(() => {
|
|
3293
|
+
throw error;
|
|
3294
|
+
}, 0);
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3287
3297
|
function hasJobs() {
|
|
3288
3298
|
for (const queue of queues.values()) {
|
|
3289
3299
|
if (queue.some((job) => !job.canceled)) {
|
|
@@ -3342,6 +3352,25 @@ const __schedulerModule = (() => {
|
|
|
3342
3352
|
return (typeof scope === "object" && scope !== null) || typeof scope === "function";
|
|
3343
3353
|
}
|
|
3344
3354
|
|
|
3355
|
+
function annotateSchedulerError(error, job) {
|
|
3356
|
+
if (!error || (typeof error !== "object" && typeof error !== "function")) {
|
|
3357
|
+
return error;
|
|
3358
|
+
}
|
|
3359
|
+
try {
|
|
3360
|
+
Object.defineProperty(error, "scheduler", {
|
|
3361
|
+
configurable: true,
|
|
3362
|
+
value: {
|
|
3363
|
+
phase: job.phase,
|
|
3364
|
+
scope: job.scope,
|
|
3365
|
+
key: job.key
|
|
3366
|
+
}
|
|
3367
|
+
});
|
|
3368
|
+
} catch {
|
|
3369
|
+
// Non-extensible thrown values still need to propagate through the chosen error channel.
|
|
3370
|
+
}
|
|
3371
|
+
return error;
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3345
3374
|
function scheduleMicrotask(fn) {
|
|
3346
3375
|
if (typeof queueMicrotask === "function") {
|
|
3347
3376
|
queueMicrotask(fn);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@async/framework",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
4
4
|
"description": "No-build Loader app runtime with browser and server entrypoints, signals, command events, route partials, cache split, SSR activation, and streaming boundaries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./server.js",
|
package/server.js
CHANGED
|
@@ -3241,7 +3241,7 @@ const __schedulerModule = (() => {
|
|
|
3241
3241
|
scheduled = true;
|
|
3242
3242
|
scheduleMicrotask(() => {
|
|
3243
3243
|
if (!destroyed) {
|
|
3244
|
-
void api.flush();
|
|
3244
|
+
void api.flush().catch(reportAutomaticFlushError);
|
|
3245
3245
|
}
|
|
3246
3246
|
});
|
|
3247
3247
|
}
|
|
@@ -3277,12 +3277,22 @@ const __schedulerModule = (() => {
|
|
|
3277
3277
|
if (onError) {
|
|
3278
3278
|
onError(error, job);
|
|
3279
3279
|
} else {
|
|
3280
|
-
throw error;
|
|
3280
|
+
throw annotateSchedulerError(error, job);
|
|
3281
3281
|
}
|
|
3282
3282
|
}
|
|
3283
3283
|
}
|
|
3284
3284
|
}
|
|
3285
3285
|
|
|
3286
|
+
function reportAutomaticFlushError(error) {
|
|
3287
|
+
if (typeof globalThis.reportError === "function") {
|
|
3288
|
+
globalThis.reportError(error);
|
|
3289
|
+
return;
|
|
3290
|
+
}
|
|
3291
|
+
setTimeout(() => {
|
|
3292
|
+
throw error;
|
|
3293
|
+
}, 0);
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3286
3296
|
function hasJobs() {
|
|
3287
3297
|
for (const queue of queues.values()) {
|
|
3288
3298
|
if (queue.some((job) => !job.canceled)) {
|
|
@@ -3341,6 +3351,25 @@ const __schedulerModule = (() => {
|
|
|
3341
3351
|
return (typeof scope === "object" && scope !== null) || typeof scope === "function";
|
|
3342
3352
|
}
|
|
3343
3353
|
|
|
3354
|
+
function annotateSchedulerError(error, job) {
|
|
3355
|
+
if (!error || (typeof error !== "object" && typeof error !== "function")) {
|
|
3356
|
+
return error;
|
|
3357
|
+
}
|
|
3358
|
+
try {
|
|
3359
|
+
Object.defineProperty(error, "scheduler", {
|
|
3360
|
+
configurable: true,
|
|
3361
|
+
value: {
|
|
3362
|
+
phase: job.phase,
|
|
3363
|
+
scope: job.scope,
|
|
3364
|
+
key: job.key
|
|
3365
|
+
}
|
|
3366
|
+
});
|
|
3367
|
+
} catch {
|
|
3368
|
+
// Non-extensible thrown values still need to propagate through the chosen error channel.
|
|
3369
|
+
}
|
|
3370
|
+
return error;
|
|
3371
|
+
}
|
|
3372
|
+
|
|
3344
3373
|
function scheduleMicrotask(fn) {
|
|
3345
3374
|
if (typeof queueMicrotask === "function") {
|
|
3346
3375
|
queueMicrotask(fn);
|