@real-router/core 0.151.0 → 0.153.0

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.
Files changed (31) hide show
  1. package/dist/cjs/Router-D_PECJh7.js +2 -0
  2. package/dist/cjs/Router-D_PECJh7.js.map +1 -0
  3. package/dist/cjs/Router.d.ts.map +1 -1
  4. package/dist/cjs/RouterError-aGkUvcJJ.js.map +1 -1
  5. package/dist/cjs/api/getRoutesApi.d.ts.map +1 -1
  6. package/dist/cjs/api.js +1 -1
  7. package/dist/cjs/api.js.map +1 -1
  8. package/dist/cjs/index.js +1 -1
  9. package/dist/cjs/internals-BEKzn5ug.js.map +1 -1
  10. package/dist/cjs/internals.d.ts +13 -4
  11. package/dist/cjs/internals.d.ts.map +1 -1
  12. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts +5 -1
  13. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts.map +1 -1
  14. package/dist/esm/Router-BC15vNmz.mjs +2 -0
  15. package/dist/esm/Router-BC15vNmz.mjs.map +1 -0
  16. package/dist/esm/Router.d.mts.map +1 -1
  17. package/dist/esm/RouterError-DyPeuufj.mjs.map +1 -1
  18. package/dist/esm/api/getRoutesApi.d.mts.map +1 -1
  19. package/dist/esm/api.mjs +1 -1
  20. package/dist/esm/api.mjs.map +1 -1
  21. package/dist/esm/index.mjs +1 -1
  22. package/dist/esm/internals-BNRNi6Fp.mjs.map +1 -1
  23. package/dist/esm/internals.d.mts +13 -4
  24. package/dist/esm/internals.d.mts.map +1 -1
  25. package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts +5 -1
  26. package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/cjs/Router-vdonCekD.js +0 -2
  29. package/dist/cjs/Router-vdonCekD.js.map +0 -1
  30. package/dist/esm/Router-BMHsXAXA.mjs +0 -2
  31. package/dist/esm/Router-BMHsXAXA.mjs.map +0 -1
@@ -167,7 +167,11 @@ export declare class RouteLifecycleNamespace<Dependencies extends DefaultDepende
167
167
  * @returns Tuple of [canDeactivateFunctions, canActivateFunctions] as Maps
168
168
  */
169
169
  getFunctions(): [Map<string, GuardFn>, Map<string, GuardFn>];
170
- canNavigateTo(toDeactivate: string[], toActivate: string[], toState: State, fromState: State | undefined): boolean;
170
+ /**
171
+ * `methodName` is the door the caller typed; it names a throwing guard's log
172
+ * and the validator's async-guard warning (#2821).
173
+ */
174
+ canNavigateTo(toDeactivate: string[], toActivate: string[], toState: State, fromState: State | undefined, methodName: string): boolean;
171
175
  /**
172
176
  * Compiles a guard factory to its `GuardFn` WITHOUT registering it — surfaces
173
177
  * a throwing / non-function factory eagerly. The prepare-then-commit
@@ -1 +1 @@
1
- {"version":3,"file":"RouteLifecycleNamespace.d.ts","names":[],"sources":["../../../../src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.ts"],"mappings":";;;;;;;;;;;;;;YA8DY;;;;;;;;;;;;;;;;;;;;;qBAsBC,wBACX,qBAAqB,sBAAsB;;EAwD3C,gBAAgB,MAAM,2BAA2B;EAIjD,gBAAgB;;;;;;;;;;;;;;;;;;;;EA8ChB,sBACE,eAAe,kBACf,iBAAiB,kBACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkFF,eACE,cACA,SAAS,eAAe,yBACxB,2BACA,gBAAgB;;;;;;EAiBlB,iBACE,cACA,SAAS,eAAe,yBACxB,2BACA,gBAAgB;;;;;;;;;;EAqBlB,iBAAiB,cAAc,OAAO;;;;;;;;;;;;;;;;;;EAqBtC,mBAAmB,cAAc,OAAO;;;;;EAQxC;;;;;;;;;;;;;;;;;EA6BA;;;;;;;;;;;EAmCA,iBACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;;;;;;EA4ChC;IACE,aACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;IAEhC,WACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;;;;;;;EA+ClC,iBAAiB,YAAY,UAAU,YAAY;EAInD,cACE,wBACA,sBACA,SAAS,OACT,WAAW;;;;;;;;;;;;;;EA8Cb,oBACE,SAAS,eAAe,yBACxB,qBACC"}
1
+ {"version":3,"file":"RouteLifecycleNamespace.d.ts","names":[],"sources":["../../../../src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.ts"],"mappings":";;;;;;;;;;;;;;YA8DY;;;;;;;;;;;;;;;;;;;;;qBAsBC,wBACX,qBAAqB,sBAAsB;;EAwD3C,gBAAgB,MAAM,2BAA2B;EAIjD,gBAAgB;;;;;;;;;;;;;;;;;;;;EA8ChB,sBACE,eAAe,kBACf,iBAAiB,kBACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkFF,eACE,cACA,SAAS,eAAe,yBACxB,2BACA,gBAAgB;;;;;;EAiBlB,iBACE,cACA,SAAS,eAAe,yBACxB,2BACA,gBAAgB;;;;;;;;;;EAqBlB,iBAAiB,cAAc,OAAO;;;;;;;;;;;;;;;;;;EAqBtC,mBAAmB,cAAc,OAAO;;;;;EAQxC;;;;;;;;;;;;;;;;;EA6BA;;;;;;;;;;;EAmCA,iBACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;;;;;;EA4ChC;IACE,aACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;IAEhC,WACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;;;;;;;EA+ClC,iBAAiB,YAAY,UAAU,YAAY;;;;;EAQnD,cACE,wBACA,sBACA,SAAS,OACT,WAAW,mBACX;;;;;;;;;;;;;;EA8CF,oBACE,SAAS,eAAe,yBACxB,qBACC"}
@@ -0,0 +1,2 @@
1
+ import{S as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,x as v,y}from"./RouterError-DyPeuufj.mjs";import{C as b,S as x,_ as S,a as ee,b as te,c as C,d as ne,g as re,h as ie,i as ae,l as oe,m as se,n as w,o as T,p as ce,r as E,s as le,t as ue,u as de,v as fe,w as pe,x as me,y as he}from"./internals-BNRNi6Fp.mjs";import{_ as D,a as ge,c as _e,d as ve,f as O,g as ye,h as be,i as xe,l as Se,m as Ce,n as we,o as k,p as A,r as Te,s as Ee,t as j,u as De}from"./helpers-BXXeSrT8.mjs";const Oe=Object.entries,ke=Object.hasOwn;function Ae(e,t,n){if(e===void 0||n.length===0)return e;let r,i=!1;for(let[a,o]of Oe(e))ke(t,a)&&t[a]!==void 0&&n.includes(a)?i=!0:(r??={},l(r,a,o));return r===void 0?i?void 0:e:r}function je(e,t,n){for(let[r,i]of Oe(e))me(n,r,i,t(r),"this route's `defaultParams`","Move it to `defaultSearch`")}const Me=Object.entries,Ne=Object.freeze;function Pe(e,t,n){let r,i=!1;for(let[a,o]of Me(e))t.includes(a)?(r??={},l(r,a,o)):(i=!0,n?.(a));return i?Ne(r??o):e}function Fe(e,t){let n=e.path,r=n.startsWith(`~`),i=r?n.slice(1):n,a=i!==``&&!i.startsWith(`/`)&&!i.startsWith(`?`)?`/${i}`:i,o={name:e.name,path:a,absolute:r,children:[],parent:t};if(e.children)for(let t of e.children){let e=Fe(t,o);o.children.push(e)}return o}function Ie(e,t,n){let r=Fe({name:e,path:t},null);for(let e of n){let t=Fe(e,r);r.children.push(t)}return r}const Le=/[^\w!$'()*+,.:;|~-]/gu,Re=/[^\w!$'()*+,.:;|~-]/u,ze=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Be=e=>t=>{try{return e(t)}catch{return e(t.replaceAll(ze,`�`))}},Ve=Be(e=>e.replaceAll(Le,e=>encodeURIComponent(e))),He={default:e=>Re.test(e)?Ve(e):e,uri:Be(encodeURI),uriComponent:Be(encodeURIComponent),none:e=>e},Ue={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e},We={default:`%2F`,uri:`/`,uriComponent:`%2F`,none:`/`},Ge=(e,t)=>{let n=He[t],r=We[t],i=String(e).split(`/`),a=n(i[0]);for(let e=1;e<i.length;e++)a+=(i[e-1]===``?r:`/`)+n(i[e]);return a},Ke=Object.freeze(Object.create(null));function qe(){return{staticChildren:Ke,hasChildren:!1,paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function M(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e}function Je(e,t){return e===``?t:t===``?e:e.endsWith(`/`)&&t.startsWith(`/`)?e+t.slice(1):e+t}function Ye(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Xe(e){let t=0;for(;t<e.length;)if(e.codePointAt(t)===37){if(t+2>=e.length)return!1;let n=e.codePointAt(t+1)??0,r=e.codePointAt(t+2)??0;if(!Ye(n)||!Ye(r))return!1;t+=3}else t++;return!0}const Ze=Object.freeze([]),Qe=Object.freeze(new Set),$e=Object.freeze([]),et=Object.freeze({}),tt=Object.freeze({}),nt=Object.freeze({});function rt(e,t){let n=e.kind===`splat`;return{paramName:e.name,encoder:n?e=>Ge(e,t):He[t]}}function it(e,t,n,r){let i=new Set(r);for(let e of t)for(let t of e.paramMeta.urlParams)i.add(t);if(i.size===0)return{buildStaticParts:[e],buildParamSlots:$e};let a=[],o=[],s=``,c=te(e),l=c.length-1;for(let[e,t]of c.entries()){let r=he(t);(`error`in r||r.kind!==`splat`||e===l)&&(e>0&&(s+=`/`),`error`in r||r.kind===`static`?s+=t:(a.push(s),s=``,o.push(rt(r,n))))}return a.push(s),{buildStaticParts:a,buildParamSlots:o}}const N=c(`router`);function at(e,t,n){throw N.plain`Parameter name conflict at the same path position: '${n}${e}' and '${n}${t}'. One position binds one name across every route that shares it. Rename one — e.g. use '${n}${e}' in both.`}function ot(){throw N.plain`Empty parameter name: a ':'/'*' marker must be followed by a name (e.g. ':id', '*rest'), and a segment cannot end in a bare '?'.`}function st(e){throw N.plain`Fused parameter marker in segment "${e}": a ':'/'*' marker must begin a segment — write 'a/:b', not 'a:b'.`}function ct(e){throw N.plain`Trailing parameter marker in segment "${e}": a param name cannot end in a bare ':' or '*'. Drop the stray marker.`}function lt(e){throw N.plain`Optional params are not supported: "${e}" — declare two sibling routes instead, one with the segment and one without.`}function ut(e){throw N.plain`Regex constraints are not supported: '<' and '>' are reserved in path segments ("${e}"). Match it as a plain string and validate the value in a canActivate guard.`}function dt(e){throw N.plain`Non-ASCII static segment "${e}": match compares static keys raw and rejects non-ASCII input, so this route can never match. Percent-encode it (e.g. "/caf%C3%A9") or use a param.`}function ft(e,t){switch(e){case`name-less`:return ot();case`trailing-marker`:return ct(t);case`fused-marker`:return st(t);case`optional-removed`:return lt(t);case`constraint-removed`:return ut(t)}}function pt(e,t){let n=new Set,r=``;for(let e of t){if(n.has(e)){r=e;break}n.add(e)}throw N.plain`Duplicate parameter name '${r}' in route "${e}": a name must be unique within a route — the second position overwrites the first. Rename one.`}function mt(e,t){throw N.plain`Invalid query-param declaration "${t}" in route "${e}": a query-param name cannot contain '<' or '>'. Rename it.`}function ht(e){throw N.plain`Double slashes are not allowed in path "${e}": the route would build a URL its own matcher refuses. Remove the empty segment.`}function gt(e,t){throw N.plain`Duplicate route path: routes "${e}" and "${t}" resolve to the same URL — the later would shadow the earlier. Give them distinct paths.`}function _t(e,t){throw N.plain`Index route "${e}" (path "/") under the splat parent "${t}" is unreachable: the wildcard match never reaches the index node. Give the index a distinct path, or make the parent static.`}function vt(e,t){return e.paramChild?e.paramChild.name!==t&&at(e.paramChild.name,t,`:`):e.paramChild={node:qe(),name:t},e.paramChild.node}function yt(e,t){return e.splatChild?e.splatChild.name!==t&&at(e.splatChild.name,t,`*`):e.splatChild={node:qe(),name:t},e.splatChild.node}const bt=Object.create;function xt(e,t){e.route!==void 0&&e.route!==t&&gt(e.route.name,t.name),e.route=t}function St(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1}function Ct(e,t,n){let r=M(n);r===`/`?xt(e.root,t):wt(e,e.root,r,1,t)}function wt(e,t,n,r,i){let a=n.length;for(;r<=a;){let i=n.indexOf(`/`,r),o=i===-1?a:i,s=n.slice(r,o);t=Ot(e,t,s),r=o+1}xt(t,i)}function Tt(e,t,n){let r=n.length;for(;r>1&&n.codePointAt(r-1)===47;)--r;let i=n.slice(0,r);i.slice(i.lastIndexOf(`/`)+1).startsWith(`*`)&&_t(t.name,n);let a=Et(e,n);a.slashChildRoute=t}function Et(e,t){return Dt(e,e.root,t)}function Dt(e,t,n){let r=M(n);if(r===`/`||r===``)return t;let i=t,a=1,o=r.length;for(;a<=o;){let t=r.indexOf(`/`,a),n=t===-1?o:t;if(n<=a)break;let s=r.slice(a,n);i=Ot(e,i,s),a=n+1}return i}function Ot(e,t,n){let r=he(n);if(`error`in r&&ot(),r.kind===`splat`){let e=yt(t,r.name);return t.hasChildren=!0,e}if(r.kind===`param`){let e=vt(t,r.name);return t.hasChildren=!0,e}St(n)&&dt(n);let i=e.options.caseSensitive?n:n.toLowerCase();return i in t.staticChildren||(t.staticChildren===Ke&&(t.staticChildren=bt(null)),t.staticChildren[i]=qe(),t.hasChildren=!0),t.staticChildren[i]}const kt=Object.freeze,At=Object.hasOwn;function jt(e){let t=te(e);for(let[n,r]of t.entries())r===``&&n>0&&n<t.length-1&&ht(e)}function Mt(e){for(let t of te(e)){let e=he(t);`error`in e&&ft(e.error,t)}}function Nt(e,t,n,r,i){let a=t.fullName===``;a||r.push(t);let o=t.absolute,s=t.paramMeta===re?t.path:t.paramMeta.pathPattern,c=o&&s.startsWith(`~`)?s.slice(1):s,l=o?c:s;jt(t.path),Mt(l);let u=l,d=o?u:Je(n,u),f=a?i:Pt(e,t,d,o?``:n,r,i);for(let n of t.children.values())Nt(e,n,d,r,f);a||r.pop()}function Pt(e,t,n,r,i,a){let o=zt(n,r),s=kt([...i]),c=Ft(s),l=M(n),u=kt(Bt(e.rootQueryParams,i)),{buildStaticParts:d,buildParamSlots:f}=it(o?M(r):l,o?i.slice(0,-1):i,e.options.urlParamsEncoding,e.rootUrlParams),p=f.map(e=>e.paramName),m=p.length===0?Qe:new Set(p);m.size!==p.length&&pt(t.fullName,p),Vt(t.fullName,u);let h={name:t.fullName,parent:a,matchSegments:s,meta:c,declaredQueryParams:u,declaredQueryParamsSet:u.length===0?Qe:new Set(u),hasTrailingSlash:n.length>1&&n.endsWith(`/`),buildStaticParts:d,buildParamSlots:f,buildParamNamesSet:m,cachedResult:void 0};return t.paramMeta.urlParams.length===0&&(h.cachedResult=kt({segments:h.matchSegments,params:et,search:tt,meta:h.meta})),e.routesByName.set(t.fullName,h),o?Lt(e,h,r):Rt(e,h,n,l,t),h}function Ft(e){let n;for(let t of e)It(t.paramTypeMap)&&(n??=h(),n[t.fullName]=t.paramTypeMap);return n===void 0?nt:kt(t(r(n)))}function It(e){for(let t in e)if(At(e,t))return!0;return!1}function Lt(e,t,n){Tt(e,t,n);let r=M(n),i=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.has(i)&&e.staticCache.set(i,t)}function Rt(e,t,n,r,i){if(Ct(e,t,n),i.paramMeta.urlParams.length===0){let n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}function zt(e,t){return M(e)===M(t)}function Bt(e,t){let n=[];e.length>0&&n.push(...e);for(let e of t)e.paramMeta.queryParams.length>0&&n.push(...e.paramMeta.queryParams);return n.length===0?Ze:n}function Vt(e,t){for(let n of t)S.test(n)&&mt(e,n)}const Ht=c(`router`,`buildPath`),Ut=Symbol.for(`real-router.searchParams.configFault`),Wt=Object.hasOwn,Gt=Object.keys,Kt=Object.getOwnPropertyDescriptor;function qt(e){try{return Kt(e,Ut)?.configurable===!1}catch{return!1}}function Jt(e){return typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):String(e)}const Yt=Object.freeze({});function Xt(e,t){return e===`strict`?t?`always`:`never`:e}var Zt=class{get options(){return this.#e}#e;#t=qe();#n=new Map;#r=new Map;#i={cleanPath:``,normalized:``,queryString:void 0};#a=[];#o=``;#s;#c;constructor(e){let t=e.urlParamsEncoding??`default`,n=typeof t==`string`?t:String(t),r=Wt(He,n)?n:`default`;this.#e={caseSensitive:e.caseSensitive??!0,strictTrailingSlash:e.strictTrailingSlash??!1,strictQueryParams:e.strictQueryParams??!1,urlParamsEncoding:r,parseQueryString:e.parseQueryString,buildQueryString:e.buildQueryString},this.#s=this.#e.caseSensitive,this.#c=this.#e.urlParamsEncoding===`none`?null:Ue[this.#e.urlParamsEncoding]}registerTree(e){this.#a=e.paramMeta.queryParams,Nt({root:this.#t,options:this.#e,routesByName:this.#n,staticCache:this.#r,rootQueryParams:this.#a,rootUrlParams:e.paramMeta.urlParams},e,``,[],null)}match(e){if(!this.#f(e))return;let{cleanPath:t,normalized:n,queryString:r}=this.#i,i=this.#s?n:n.toLowerCase(),a=this.#r.get(i);if(a)return this.#e.strictTrailingSlash&&!this.#g(t,a)?void 0:r===void 0&&a.cachedResult?a.cachedResult:this.#m(a,{},r);let o={},s=this.#_(n,o);if(s&&(!this.#e.strictTrailingSlash||this.#g(t,s))&&this.#b(o))return this.#m(s,o,r)}buildPath(e,t,n,r){let i=this.#n.get(e);if(!i)throw Ht.plain`'${e}' is not defined`;let a=this.#l(i,t),o=this.#u(a,Xt(r?.trailingSlash,i.hasTrailingSlash)),s=this.#d(i,n??t,r?.queryParamsMode);return o+(s?`?${s}`:``)}getSegmentsByName(e){return this.#n.get(e)?.matchSegments}getMetaByName(e){return this.#n.get(e)?.meta}getDeclaredQueryParams(e){return this.#n.get(e)?.declaredQueryParams}hasRoute(e){return this.#n.has(e)}#l(e,t){let n=e.buildStaticParts,r=e.buildParamSlots;if(r.length===0)return n[0];let i=n[0];for(let[e,a]of r.entries()){let r=t!=null&&Wt(t,a.paramName)?t[a.paramName]:void 0;if(r==null)throw Ht.plain`Missing required param '${a.paramName}'`;if(r===``)throw Ht.plain`Missing required param '${a.paramName}' (empty string)`;let o=a.encoder(Jt(r));i+=o+n[e+1]}return i}#u(e,t){return t===`always`&&!e.endsWith(`/`)?`${e}/`:t===`never`&&e!==`/`&&e.endsWith(`/`)?e.slice(0,-1):e}#d(e,t,n){if(!t||e.declaredQueryParams.length===0&&n!==`loose`)return``;let r={},i=!1;for(let n of e.declaredQueryParams)Wt(t,n)&&(l(r,n,t[n]),i=!0);if(n===`loose`)for(let n of Gt(t))e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(l(r,n,t[n]),i=!0);return i?this.#e.buildQueryString(r):``}#f(e){if(e===``&&(e=`/`),e.codePointAt(0)!==47)return!1;let t=this.#p(e);if(t===-2)return!1;t===-3&&(e=this.#o);let n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):void 0;if(r!==void 0){let e=r.indexOf(`#`);e!==-1&&(r=r.slice(0,e))}let i=M(n);return this.#i.cleanPath=n,this.#i.normalized=i,this.#i.queryString=r,!0}#p(e){let t=!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===35)return this.#o=e.slice(0,n),-3;if(r===63)return n;if(r>=128)return-2;if(r===47){if(t)return-2;t=!0}else t=!1}return-1}#m(e,t,n){let r=Yt;if(n!==void 0){let t=this.#h(e,n);if(t===void 0)return;r=t}return{segments:e.matchSegments,params:t,search:r,meta:e.meta}}#h(e,t){let n;try{n=this.#e.parseQueryString(t)}catch(e){if(qt(e))throw e;return}if(this.#e.strictQueryParams){let t=e.declaredQueryParamsSet;for(let e of Gt(n))if(!t.has(e))return}return n}#g(e,t){return(e.length>1&&e.endsWith(`/`))===t.hasTrailingSlash}#_(e,t){return e.length===1?this.#t.slashChildRoute??this.#t.route:this.#v(this.#t,e,1,t)}#v(e,t,n,r){let i=e,a=t.length,o=this.#s;for(;n<=a;){let e=t.indexOf(`/`,n),s=e===-1?a:e,c=t.slice(n,s),u=o?c:c.toLowerCase(),d;if(u in i.staticChildren){let e=i.staticChildren[u];if(i.splatChild!==void 0){let a={},o=this.#v(e,t,s+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(f(r,a),o)}d=e}else if(i.paramChild){let e=i.paramChild;if(i.splatChild!==void 0){let a={[e.name]:c},o=this.#v(e.node,t,s+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(f(r,a),o)}d=e.node,l(r,e.name,c)}else if(i.splatChild)return this.#y(i.splatChild,t,n,r);else return;i=d,n=s+1}return i.slashChildRoute??i.route}#y(e,t,n,r){let i=e.node;if(!i.hasChildren)return l(r,e.name,t.slice(n)),i.route;let a={},o=this.#v(i,t,n,a);return o?(f(r,a),o):(l(r,e.name,t.slice(n)),i.route)}#b(e){let t=this.#c;if(!t)return!0;for(let n of Gt(e)){let r=e[n];if(r.includes(`%`)){if(!Xe(r))return!1;try{e[n]=t(r)}catch{return!1}}}return!0}};const P=Object.freeze,Qt=Object.freeze(new Map),$t=Object.freeze([]);function en(e){return e.parent?.name?`${e.parent.fullName}.${e.name}`:e.name}function tn(e){let t=new Map;for(let n of e)t.set(n.name,n);return t}function nn(e,t){let n=[],r=[];for(let i of e){let e=rn(i,t);n.push(e),e.absolute||r.push(e)}return{childrenMap:tn(n),nonAbsoluteChildren:r}}function rn(e,t){let n=fe(e.path),r=n.urlParams.length===0&&n.queryParams.length===0&&n.pathPattern===e.path?re:n,i=r.paramTypeMap,a={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:r,nonAbsoluteChildren:void 0,fullName:``,paramTypeMap:i};if(a.fullName=en(a),e.children.length===0)a.children=Qt,a.nonAbsoluteChildren=$t;else{let{childrenMap:t,nonAbsoluteChildren:n}=nn(e.children,a);a.children=t,a.nonAbsoluteChildren=n,P(a.nonAbsoluteChildren),P(a.children)}return P(i),P(r.urlParams),P(r.queryParams),P(r),P(a),a}function an(e){return rn(e,null)}function on(e,t,n){return an(Ie(e,t,n))}function sn(e){let t=e.absolute?`~${e.path}`:e.path,n={name:e.name,path:t};return e.children.size>0&&l(n,`children`,Array.from(e.children.values(),sn)),n}function cn(e){return Array.from(e.children.values(),sn)}const ln=e=>{let t=e.indexOf(`%`),n=e.indexOf(`+`);if(t===-1&&n===-1)return e;let r=n===-1?e:e.replaceAll(`+`,` `);return t===-1?r:decodeURIComponent(r)},un=(e,t)=>{if(e===void 0)return t.boolean.decodeUndefined();let n=t.boolean.decodeRaw(e);if(n!==null)return n;let r=ln(e),i=t.number.decode(r);return i===null?t.boolean.decodeValue(r):i},dn=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,fn=e=>{try{return encodeURIComponent(e)}catch(t){if(!(t instanceof URIError))throw t;return encodeURIComponent(String(e).replaceAll(dn,`�`))}},pn=c(`router`),mn=e=>{let t=typeof e;if(t!==`string`&&t!==`number`&&t!==`boolean`)throw pn.type`Invalid query value: an array element must be a string, number, or boolean — received ${t}`;return fn(e)},hn=(e,t,n,r)=>{let i=`${e}${n}`,a=[];for(let e of t)if(e===null){let e=r.encode(i);e&&a.push(e)}else a.push(`${i}=${mn(e)}`);return a.join(`&`)},gn={none:{encodeArray:(e,t,n)=>hn(e,t,``,n)},brackets:{encodeArray:(e,t,n)=>hn(e,t,`[]`,n)},index:{encodeArray:(e,t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=`${e}[${i}]`;if(a===null){let e=n.encode(t);e&&r.push(e)}else r.push(`${t}=${mn(a)}`)}return r.join(`&`)},indexed:!0},comma:{encodeArray:(e,t)=>{let n=[];for(let e of t)e!==null&&n.push(mn(e));return n.length===0?``:`${e}=${n.join(`,`)}`},decodeValue:e=>e.includes(`,`)?e.split(`,`):null}},_n={none:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:e=>e},auto:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:e=>e===`true`||e!==`false`&&null,decodeValue:e=>e},"empty-true":{encode:(e,t)=>t?e:`${e}=false`,decodeUndefined:()=>!0,decodeRaw:e=>e===`true`||e!==`false`&&null,decodeValue:e=>e}},vn={default:{encode:e=>e},hidden:{encode:()=>``}},yn={auto:{decode:e=>{let t=e.length;if(t===0)return null;let n=+(e.codePointAt(0)===45);if(n===t||t-n>1&&e.codePointAt(n)===48&&e.codePointAt(n+1)!==46)return null;let r=!1;for(let i=n;i<t;i++){let a=e.codePointAt(i);if(!(a!==void 0&&a>=48&&a<=57)){if(a===46&&!r&&i!==n&&i!==t-1)r=!0;else return null}}let i=Number(e);return String(i)!==e||!Number.isSafeInteger(i)&&!r?null:i}},none:{decode:()=>null}},bn=c(`router`),xn=Object.defineProperty,Sn=Object.keys,Cn=Object.hasOwn,wn=Symbol.for(`real-router.searchParams.configFault`),Tn=(e,t,n)=>{let r=typeof t==`string`?t:String(t);if(!Cn(e,r)){let t=bn.type`Invalid "queryParams.${n}": "${r}" — expected ${Sn(e).map(e=>`"${e}"`).join(` | `)}`;throw xn(t,wn,{value:!0}),t}return e[r]},En=(e,t,n,r)=>({boolean:Tn(_n,t,`booleanFormat`),null:Tn(vn,n,`nullFormat`),number:Tn(yn,r,`numberFormat`),array:Tn(gn,e,`arrayFormat`)}),Dn=Object.freeze({boolean:_n.auto,null:vn.default,number:yn.auto,array:gn.none}),F=Object.freeze({arrayFormat:`none`,booleanFormat:`auto`,nullFormat:`default`,numberFormat:`auto`}),On=Object.freeze({...F,strategies:Dn}),kn=e=>{if(!e||e.arrayFormat===void 0&&e.booleanFormat===void 0&&e.nullFormat===void 0&&e.numberFormat===void 0)return On;let t=e.arrayFormat??F.arrayFormat,n=e.booleanFormat??F.booleanFormat,r=e.nullFormat??F.nullFormat,i=e.numberFormat??F.numberFormat;return{arrayFormat:t,booleanFormat:n,nullFormat:r,numberFormat:i,strategies:En(t,n,r,i)}},An=e=>fn(e),jn=(e,t,n)=>{let r=An(e);switch(typeof t){case`string`:case`number`:return`${r}=${An(t)}`;case`boolean`:return n.strategies.boolean.encode(r,t);case`object`:return t===null?n.strategies.null.encode(r):Array.isArray(t)?n.strategies.array.encodeArray(r,t,n.strategies.null):`${r}=${An(t)}`;default:return`${r}=${An(t)}`}},Mn=Object.hasOwn,Nn=Object.keys;function Pn(e,t,n){l(e,t,n)}function Fn(e,t,n,r){if(!Mn(e,t)){Pn(e,t,r?[n]:n);return}let i=e[t];Array.isArray(i)?i.push(n):Pn(e,t,[i,n])}function In(e,t,n){let r=t+1,i=0,a=!1;for(;r<n;){let t=e.codePointAt(r);if(t===93)return a?i:null;if(t!==void 0&&t>=48&&t<=57)i=i*10+(t-48),a=!0,r++;else return null}return null}function Ln(e,t,n){let{searchPart:r,nameEnd:i,nameSourceEnd:a,rawValue:o,decodedName:s}=e,c=In(r,i,a);if(c===null)return!1;let l=un(o,t),u=n.get(s);return u===void 0?n.set(s,[[c,l]]):u.push([c,l]),!0}function Rn(e,t,n,r,i,a,o){let s=a!==-1&&a<n?e.slice(a+1,n):void 0,c=s===void 0?n:a,l=c,u=!1;for(let n=t;n<c;n++)if(e.codePointAt(n)===91){l=n,u=!0;break}let d=ln(e.slice(t,l));if(!(o!==void 0&&u&&Ln({searchPart:e,nameEnd:l,nameSourceEnd:c,rawValue:s,decodedName:d},i,o))){if(!u&&s!==void 0&&i.array.decodeValue){let e=i.array.decodeValue(s);if(e){for(let t of e)Fn(r,d,un(t,i),!0);return}}Fn(r,d,un(s,i),u)}}const zn=(e,t)=>{if(e===``||e===`?`)return{};let n={};return Bn(e,n,t.strategies),n};function Bn(e,t,n){let r=n.array.indexed?new Map:void 0,i=0,a=e.length,o=-2;for(;i<a;){let s=e.indexOf(`&`,i);s===-1&&(s=a),s>i&&(o!==-1&&o<i&&(o=e.indexOf(`=`,i)),Rn(e,i,s,t,n,o,r)),i=s+1}if(r!==void 0)for(let[e,n]of r)n.sort((e,t)=>e[0]-t[0]),Pn(t,e,n.map(e=>e[1]))}const Vn=(e,t)=>{let n=Nn(e);if(n.length===0)return``;let r=[];for(let i of n){let n=e[i];if(n===void 0)continue;let a=jn(i,n,t);a&&r.push(a)}return r.join(`&`)};function Hn(e){let t=e?.queryParams,n=kn(t);return new Zt({...e?.caseSensitive!==void 0&&{caseSensitive:e.caseSensitive},...e?.strictTrailingSlash!==void 0&&{strictTrailingSlash:e.strictTrailingSlash},...e?.strictQueryParams!==void 0&&{strictQueryParams:e.strictQueryParams},...e?.urlParamsEncoding!==void 0&&{urlParamsEncoding:e.urlParamsEncoding},parseQueryString:e=>zn(e,n),buildQueryString:e=>Vn(e,n)})}const Un=c(`router`,`addEventListener`),Wn=c(`router`,`subscribeChanges`),Gn=c(`router`,`addInterceptor`),Kn=c(`router`,`addCheck`),qn=c(`router`,`extendRouter`),I=c(`router`),Jn=Object.keys,Yn=Object.values,Xn=Object.hasOwn,Zn=Object.getOwnPropertyDescriptor,Qn=Object.getPrototypeOf,$n=Object,er=new Set(Yn(v));function tr(e){if(!er.has(e))throw Un.type`Invalid event name: ${String(e)}. Must be one of: ${[...er].join(`, `)}`}function nr(e){if(typeof e!=`function`)throw Un.type`callback must be a function, got ${typeof e}`}function rr(e){if(typeof e!=`function`)throw Wn.type`Expected a function`}function ir(e,t){if(typeof e!=`string`||!Xn(E,e))throw Gn.type`Invalid method: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Jn(E).join(`, `)}`;if(typeof t!=`function`)throw Gn.type`interceptor must be a function, got ${typeof t}`}function ar(e,t){if(typeof e!=`string`||!Xn(w,e))throw Kn.type`Invalid position: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Jn(w).join(`, `)}`;if(typeof t!=`function`)throw Kn.type`check must be a function, got ${typeof t}`}function or(e,t){if(typeof e!=`string`)throw c(`router`,t).type`Route name must be a string, got ${typeof e}`}function sr(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Qn(e);return t===null||t.constructor===$n}function cr(e){if(!sr(e))throw I.type`dependencies must be a plain object`}function lr(e){return e===null?`null`:typeof e==`object`?`a non-plain object`:typeof e}function ur(e){if(!sr(e))throw qn.type`extensions must be a plain object, got ${lr(e)}`}function dr(e,t){cr(e);let n=e,r=[];for(let e of Jn(n)){if(Zn(n,e)?.get)throw I.type`dependencies cannot contain getters: "${e}"`;let t=n[e];t!==void 0&&r.push([e,t])}for(let[e,n]of r)t(e,n)}function fr(e){let t=[];for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw I.type`route must be a non-array object`;ce(e,`addRoute`);let r={...e},i=r.children;i&&l(r,`children`,fr(i)),t.push(r)}return t}const pr=new Set([`all`,`warn-error`,`error-only`,`none`]);function mr(e){return typeof e==`string`&&pr.has(e)}function hr(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function gr(e){for(let t of Jn(e))if(t!==`level`&&t!==`callback`&&t!==`callbackIgnoresLevel`)throw I.type`Unknown logger config property: "${t}"`}function _r(e){if(!Xn(e,`level`))return;let t=e.level;if(t!==void 0){if(!mr(t))throw I.type`Invalid logger level: ${hr(t)}. Expected: "all" | "warn-error" | "error-only" | "none"`;return t}}function vr(e){if(!Xn(e,`callbackIgnoresLevel`))return;let t=e.callbackIgnoresLevel;if(t!==void 0){if(typeof t!=`boolean`)throw I.type`Logger callbackIgnoresLevel must be a boolean, got ${typeof t}`;return t}}function yr(e){if(typeof e!=`object`||!e)throw I.type`Logger config must be an object`;let t=e;gr(t);let n=h(),r=_r(t);if(r!==void 0&&(n.level=r),Xn(t,`callback`)){let e=t.callback;if(e!==void 0&&typeof e!=`function`)throw I.type`Logger callback must be a function, got ${typeof e}`;n.callback=e}let i=vr(t);return i!==void 0&&(n.callbackIgnoresLevel=i),n}const br=Object.create;function xr(e,t,n){e[t]=n}function Sr(e,t){return e.dependencies[t]}function Cr(e){e.dependencies=br(null)}function wr(e){return Ee({...e.dependencies})}function Tr(e,t){let n=br(null),r=e,i=n;return dr(r,(e,t)=>{xr(i,e,t)}),{dependencies:n,limits:t}}const L={defaultRoute:``,defaultParams:{},defaultSearch:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:F,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0},Er=[`strict`,`never`,`always`,`preserve`],Dr=[`default`,`strict`,`loose`];function Or(e){return e!==void 0&&Er.includes(e)?e:L.trailingSlash}function kr(e){return e!==void 0&&Dr.includes(e)?e:L.queryParamsMode}const Ar=c(`router`);function jr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Ar.type`options must be a plain object`}const Mr=Object.freeze;var Nr=class{#e;constructor(e={}){this.#e=Mr(Ee({...L,...e}))}static validateOptionsIsObject(e){jr(e)}get(){return this.#e}};function Pr(e,t){return typeof e==`function`?e(t):e}const Fr=Object.keys;function Ir(e,t,n,r,i){let a=e.pathNames(t);if(a!==void 0)for(let e of Fr(n))!r.includes(e)&&!a.includes(e)&&i(t,e)}function R(e,t,n,r,i){let a=String(t),c=i?.resolveForward===!1?{name:a,params:n,search:r}:e.resolveForward(a,n,r),l=c.name,u=O(c.params,s),d=i?.diagnoseUndeclared===!0?e.reportUndeclaredParamKey:void 0;d&&Ir(e,l,u,e.queryNames(l),d);let f=e.defaultParams(l),p=e.defaultSearch(l);if((c.search===void 0||c.search===o)&&f===void 0&&p===void 0)return{name:l,path:u,query:o};let m=e.queryNames(l),h=e.reportDroppedQueryKey,g=i?.resolveForward===!1?Ae(p,u,m):p,_=O(c.search,o),v=ve(g,_);return{name:l,path:De(f,u),query:e.admitsUndeclaredQuery()?v:Pe(v,e.printedQueryNames(l),t=>{h!==void 0&&e.pathNames(l)!==void 0&&h(l,t)})}}function z(e,t){return t.buildPath(e.name,e.path,e.query)}const Lr=Object.freeze;function Rr(e,t){let n={name:e.name,params:e.path,search:e.query,path:t,context:{},transition:p};return Lr(n.params),n}function B(e,t){return _e(Rr(e,t))}function zr(e,t){return Rr(e,t)}var Br=class{#e;#t;get(){return this.#e.current}getPrevious(){return this.#e.previous}setContext(e){this.#e=e}setDependencies(e){this.#t=e}makeState(e,t,n,r){let i=this.#t.port(),a=R(i,e,t??s,n,{resolveForward:!1});return x(`makeState`,a.name,a.path,i.queryNames(a.name)),B(a,r??z(a,i))}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;let r=e.name;return r===t.name?n?ye(e.params,t.params,this.#t.getUrlParams(r)):be(e.params,t.params)&&be(e.search,t.search):!1}};const Vr=Object.keys,Hr={[e.ROUTER_START]:v.ROUTER_START,[e.ROUTER_STOP]:v.ROUTER_STOP,[e.TRANSITION_SUCCESS]:v.TRANSITION_SUCCESS,[e.TRANSITION_START]:v.TRANSITION_START,[e.TRANSITION_LEAVE_APPROVE]:v.TRANSITION_LEAVE_APPROVE,[e.TRANSITION_ERROR]:v.TRANSITION_ERROR,[e.TRANSITION_CANCEL]:v.TRANSITION_CANCEL},Ur=Vr(Hr),Wr=c(`router`,`usePlugin`);function Gr(e){if(!(e&&typeof e==`object`)||Array.isArray(e))throw Wr.type`Plugin factory must return an object, got ${typeof e}`;if(typeof e.then==`function`)throw Wr.type`Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.`}const Kr=Object.freeze;var qr=class e{#e=new Set;#t=new Set;#n;static validatePlugin(e){Gr(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...e){if(this.#n.getValidator()?.plugins.validateCountThresholds(this.#e.size+e.length),e.length===1){let t=e[0],n=this.#i(t);this.#e.add(t);let r=!1,i=()=>{if(!r){r=!0,this.#e.delete(t),this.#t.delete(i);try{n()}catch(e){this.#n.logger.error(`router`,`Error during cleanup:`,e)}}};return this.#t.add(i),i}let t=this.#r(e),n=[];try{for(let e of t){let t=this.#i(e);n.push({factory:e,cleanup:t})}}catch(e){for(let{cleanup:e}of n)try{e()}catch(e){this.#n.logger.error(`router.usePlugin`,`Cleanup error:`,e)}throw e}for(let{factory:e}of n)this.#e.add(e);let r=!1,i=()=>{if(!r){r=!0,this.#t.delete(i);for(let{factory:e}of n)this.#e.delete(e);for(let{cleanup:e}of n)try{e()}catch(e){this.#n.logger.error(`router`,`Error during cleanup:`,e)}}};return this.#t.add(i),i}getAll(){return[...this.#e]}disposeAll(){for(let e of this.#t)e();this.#e.clear(),this.#t.clear()}#r(e){let t=new Set;for(let n of e)t.has(n)?this.#n.getValidator()?.plugins.warnBatchDuplicates(e):t.add(n);return t}#i(t){let n=this.#n.compileFactory(t);e.validatePlugin(n),this.#n.getValidator()?.plugins.validatePluginKeys(n),Kr(n);let r=[];for(let e of Ur)e in n&&(typeof n[e]==`function`?(r.push(this.#n.addEventListener(Hr[e],n[e])),e===`onStart`&&this.#n.canNavigate()&&this.#n.emitDiagnostic(ue.PLUGIN_AFTER_START,e)):this.#n.getValidator()?.plugins.warnPluginMethodType(e));return()=>{for(let e of r)e();typeof n.teardown==`function`&&n.teardown()}}};const V=Object.create,Jr=()=>!0,Yr=()=>!1,Xr=()=>Jr,Zr=()=>Yr;function Qr(e){return e?Xr:Zr}function $r(e,t,n){n===void 0?e.delete(t):e.set(t,n)}var ei=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=[this.#i,this.#a];#d;setDependencies(e){this.#d=e}getHandlerCount(e){let t=e===`activate`?this.#e:this.#n,n=e===`activate`?this.#t:this.#r;if(t.size===0)return n.size;if(n.size===0)return t.size;let r=new Set(t.keys());for(let e of n.keys())r.add(e);return r.size}preflightHandlerLimit(e,t,n){let r=this.#d.getValidator();if(!r)return;let i=(e,t,i)=>{let{definition:a,external:o}=this.#g(e),s=0;for(let e of t)(n?o.has(e):a.has(e)||o.has(e))||s++;if(s===0)return;let c=n?o.size:this.getHandlerCount(e);r.lifecycle.validateHandlerLimit(c+s-1,i)};i(`activate`,e,`canActivate`),i(`deactivate`,t,`canDeactivate`)}addCanActivate(e,t,n,r){this.#f(`activate`,e,t,n,`canActivate`,r)}addCanDeactivate(e,t,n,r){this.#f(`deactivate`,e,t,n,`canDeactivate`,r)}clearCanActivate(e,t){this.#p(`activate`,e,t)}clearCanDeactivate(e,t){this.#p(`deactivate`,e,t)}clearAll(){this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#a.clear(),this.#i.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#l.clear()}clearDefinitionGuards(){for(let e of this.#e.keys())this.#c.delete(e),this.#t.has(e)?this.#m(`activate`,e):this.#a.delete(e);for(let e of this.#n.keys())this.#o.delete(e),this.#r.has(e)?this.#m(`deactivate`,e):this.#i.delete(e);this.#e.clear(),this.#n.clear()}getFactories(){let e=V(null),t=V(null);for(let[t,n]of this.#n)e[t]=n;for(let[t,n]of this.#r)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,n]of this.#t)t[e]=n;return[e,t]}getFactoriesByOrigin(){let e=V(null),t=V(null),n=V(null),r=V(null);for(let[t,n]of this.#n)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,t]of this.#r)n[e]=t;for(let[e,t]of this.#t)r[e]=t;return{definition:[e,t],external:[n,r]}}getFunctions(){return this.#u}canNavigateTo(e,t,n,r,i){for(let t of e)if(!this.#_(this.#i,t,n,r,i))return!1;for(let e of t)if(!this.#_(this.#a,e,n,r,i))return!1;return!0}compileGuardFactory(e,t){let n=typeof e==`boolean`?Qr(e):e,r=this.#d.compileFactory(n);if(typeof r!=`function`)throw c(`router`,t).type`Factory must return a function, got ${typeof r}`;return r}#f(e,t,n,r,i,a){let o=this.#g(e),s=e===`activate`?this.#a:this.#i,c=r?o.definition:o.external,l=r?o.external:o.definition;if(c.has(t)||l.has(t))this.#d.getValidator()?.lifecycle.warnOverwrite(t,e,i);else{let t=this.#d.getValidator();if(t){let n=this.getHandlerCount(e);t.lifecycle.validateHandlerLimit(n,i),t.lifecycle.validateCountThresholds(n+1,i)}}let u=typeof n==`boolean`?Qr(n):n,d=c.get(t),f=this.#h(e),p=r?f.definition:f.external,m=p.get(t);c.set(t,u);let h=r&&l.has(t);try{let e=a??this.compileGuardFactory(u,i);p.set(t,e),h||s.set(t,e)}catch(n){throw $r(c,t,d),$r(p,t,m),this.#m(e,t),n}}#p(e,t,n){let{definition:r,external:i}=this.#g(e),a=this.#h(e),o=n!==`external`&&r.delete(t),s=n!==`definition`&&i.delete(t);o&&a.definition.delete(t),s&&a.external.delete(t),(o||s)&&this.#m(e,t)}#m(e,t){let n=this.#h(e),r=e===`activate`?this.#a:this.#i,i=n.external.get(t)??n.definition.get(t);i?r.set(t,i):r.delete(t)}#h(e){return e===`activate`?{definition:this.#c,external:this.#l}:{definition:this.#o,external:this.#s}}#g(e){return e===`activate`?{definition:this.#e,external:this.#t}:{definition:this.#n,external:this.#r}}#_(e,t,n,r,i){let a=e.get(t);if(!a)return!0;try{let e=a(n,r);return typeof e==`boolean`?e:(Promise.resolve(e).catch(()=>void 0),this.#d.getValidator()?.lifecycle.warnAsyncGuardSync(t,i),!1)}catch(e){return this.#d.logger.warn(`router.${i}`,`Guard for "${t}" threw — treated as navigation-blocking (returned false)`,e),!1}}};const ti=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`,`defaultSearch`]),ni=Object.freeze,H=Object.create,ri=Object.hasOwn,ii=Object.keys;function ai(){return{decoders:H(null),encoders:H(null),defaultParams:H(null),defaultSearch:H(null),forwardMap:H(null),forwardFnMap:H(null)}}function oi(e){return ii(e.forwardMap).length>0||ii(e.forwardFnMap).length>0}function si(e,t){for(let n of ii(t))Object.assign(e[n],t[n])}function ci(e,t){for(let n in e)if(ri(t,n)&&!ge(e[n],t[n]))return!1;return!0}function li(e){return typeof e==`string`?e:`<non-string>`}function ui(e,t){for(let n in e)if(!ge(e[n],t[n]))return!1;return!0}function di(e){let t={name:e.name,path:e.path};return e.children&&l(t,`children`,e.children.map(e=>di(e))),t}function fi(e,t,n){if(n.add(t),e.children)for(let r of e.children)fi(r,`${t}.${r.name}`,n)}function pi(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t){e.splice(r,1);let t=new Set;return fi(i,a,t),t}if(i.children&&t.startsWith(`${a}.`)){let e=pi(i.children,t,a);if(e)return e}}}function mi(e,t){for(let n of ii(e))t(n)&&delete e[n]}function hi(e,t){let n=t.search(/[?#]/),r=n===-1?t:t.slice(0,n);if(r===`/`||r.endsWith(`/`))return t;let i=e.search(/[?#]/),a=i===-1?e:e.slice(0,i);return a.length>1&&a.endsWith(`/`)?`${r}/${n===-1?``:t.slice(n)}`:t}function gi(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}const _i=ni([]);function vi(e,t,n){let r=n.get(t);if(r!==void 0)return r;let i=e.getSegmentsByName(t);if(!i)return _i;let a=ni(gi(i));return n.set(t,a),a}function yi(e,t){return vi(e.matcher,t,e.urlParamsCache)}const bi=ni([]);function xi(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=e.getDeclaredQueryParams(t);if(!a)return bi;let o=vi(e,t,n),s=ni(a.filter(e=>!o.includes(e)));return r.set(t,s),s}function Si(e,t){return e.getDeclaredQueryParams(t)??bi}function Ci(e,t){return xi(e.matcher,t,e.urlParamsCache,e.queryParamsCache)}function wi(e,t,n){let r=new Map,i=new Map;je(t.defaultParams,t=>xi(e,t,r,i),n)}const Ti=c(`router`);function Ei(e,t,n=100){let r=String(e),i=new Set,a=[r],o=r;for(;;){let e=t[o];if(!e)break;let r=String(e);if(i.has(r)){let e=a.indexOf(r),t=[...a.slice(e),r];throw Ti.plain`Circular forwardTo: ${t.join(` → `)}`}if(i.add(o),a.push(r),o=r,a.length>n)throw Ti.plain`forwardTo chain exceeds maximum depth (${n}): ${a.join(` → `)}`}return o}const Di=c(`router`),Oi=c(`router`,`addRoute`),ki=Object.freeze,U=Object.create,Ai=Object.entries,ji=Object.keys,Mi=Object.defineProperty,Ni=Object.fromEntries;function Pi(e,t,n){let r=on(``,t,e),i=Hn(n);return i.registerTree(r),{tree:r,matcher:i}}function Fi(e,t=e.definitions){let n=Pi(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Ii(e,t){let n=Pi(e.definitions,t,e.matcherOptions);wi(n.matcher,e.config,`setRootPath`),e.rootPath=t,e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Li(e,t){Fi(e,t),W(e,Bi(e.config))}function Ri(e){zi(e),Fi(e,[])}function zi(e){Object.assign(e.config,ai()),W(e,U(null)),e.routeCustomFields=U(null)}function W(e,t){e.resolvedForwardMap=t,e.hasAnyForward=oi(e.config)}function Bi(e){let t=U(null);for(let n of ji(e.forwardMap))t[n]=Ei(n,e.forwardMap);return t}function Vi(e,t){if(typeof e!=`function`){if(typeof e!=`string`&&e!==null)throw Di.type`forwardTo must be a string or function for route "${t}", got ${typeof e}`;return}let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw Di.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}function Hi(e,t,n){t&&ne(`encodeParams`,t,n,void 0),e&&ne(`decodeParams`,e,n,void 0)}function Ui(e,t,n,r){if(Vi(e.forwardTo,t),e.canActivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${n}".`)}if(e.canDeactivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${n}".`)}typeof e.forwardTo==`string`?n.forwardMap[t]=e.forwardTo:n.forwardFnMap[t]=e.forwardTo}function Wi(e,t,n,r,i,a,o){let{decodeParams:s,encodeParams:c}=e;Hi(s,c,t);let l=Ni(Ai(e).filter(([e])=>!ti.has(e)));ji(l).length>0&&(r[t]=ki(l)),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&Ui(e,t,n,o),s&&(n.decoders[t]=e=>s(e)??e),c&&(n.encoders[t]=e=>c(e)??e),e.defaultParams&&(n.defaultParams[t]=k(`defaultParams`,e.defaultParams)),e.defaultSearch&&(n.defaultSearch[t]=k(`defaultSearch`,e.defaultSearch))}function Gi(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;Wi(s,e,t,n,r,i,a),s.children&&Gi(s.children,t,n,r,i,a,e)}}function Ki(e){let t=ai();return si(t,e),t}function qi(e,t,n){if(n.length===0)return[...e,...t];let[r,...i]=n;return e.map(e=>{if(e.name!==r)return e;let n=e.children??[];return{...e,children:i.length===0?[...n,...t]:qi(n,t,i)}})}function Ji(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&Ji(r.children,e,n)}}function Yi(e,t,n){let r=new Set;Ji(e,t,e=>{if(r.has(e))throw c(`router`,n).plain`Duplicate route "${e}" in batch`;r.add(e)})}function Xi(e,t){if(or(e,t),e.startsWith(`@@`))throw c(`router`,t).plain`Route name "${e}" uses the reserved "${`@@`}" prefix. Routes with this prefix are internal and cannot be modified through the public API.`}function Zi(e,t){for(let n of e)Xi(n.name,t),n.children&&Zi(n.children,t)}function Qi(e,t){for(let n of e)ie(n.name,t),n.children&&Qi(n.children,t)}function $i(e,t){for(let n of e)se(n.name,t),n.children&&$i(n.children,t)}function ea(e,t,n){let r=new Map,i=(e,t)=>{for(let a of e){let e=r.get(t);if(e?.has(a.path))throw c(`router`,n).plain`Path "${a.path}" is already defined`;e?e.add(a.path):r.set(t,new Set([a.path])),a.children&&i(a.children,t?`${t}.${a.name}`:a.name)}};i(e,t)}function ta(e,t,n){if(Zi(t,`addRoute`),Qi(t,`addRoute`),$i(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw Oi.plain`Parent route "${n}" does not exist`;Ji(t,n??``,t=>{if(e.matcher.hasRoute(t))throw Oi.plain`Route "${t}" already exists`}),Yi(t,n??``,`addRoute`),ea(t,n??``,`addRoute`)}function na({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:o,logger:s}){let c=new Map,l=new Map;Gi(t,n,r,c,l,s,i);let u=Bi(n),{tree:d,matcher:f}=Pi(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function ra(e,t,n,r){return na({definitions:qi(e.definitions,t.map(e=>di(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:Ki(e.config),routeCustomFields:Object.assign(U(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function ia(e,t,n,r){return na({definitions:e.map(e=>di(e)),routesForHandlers:e,config:ai(),routeCustomFields:U(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function aa(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function oa(e,t){return{activate:aa(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:aa(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function sa(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??oa(t,r);Object.assign(e.config,t.config),e.routeCustomFields=t.routeCustomFields,e.tree=t.tree,e.matcher=t.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear(),W(e,t.resolvedForwardMap);for(let[e,t,n]of i)r.addActivateGuard(e,t,n);for(let[e,t,n]of a)r.addDeactivateGuard(e,t,n)}function G(e){return e===null?e:e||void 0}function ca(e,t){return t==null?t:k(e,t)}function la(e,t,n,r){let{forwardTo:i,defaultParams:a,defaultSearch:o,decodeParams:s,encodeParams:c,canActivate:l,canDeactivate:u}=r,d=G(i),f=ca(`defaultParams`,G(a)),p=ca(`defaultSearch`,G(o)),m=G(s),h=G(c),g=G(l),_=G(u);f!=null&&me(`updateRoute`,n,f,Ci(e,n),"this route's `defaultParams`","Move it to `defaultSearch`"),Hi(m,h,n);let v=d===void 0?void 0:ua(n,d,e.config),y=da(e,n,r),b=g==null?void 0:t.compileGuardFactory(g,`canActivate`),x=_==null?void 0:t.compileGuardFactory(_,`canDeactivate`);return t.preflightHandlerLimit(b===void 0?[]:[n],x===void 0?[]:[n],!1),y!==void 0&&(ji(y).length>0?e.routeCustomFields[n]=ki(y):delete e.routeCustomFields[n]),v!==void 0&&(e.config.forwardMap=v.forwardMap,e.config.forwardFnMap=v.forwardFnMap,W(e,v.resolved)),pa(e,n,{defaultParams:f,defaultSearch:p,decodeParams:m,encodeParams:h}),ma(t,`activate`,n,g,b),ma(t,`deactivate`,n,_,x),{forwardTo:d,defaultParams:f,defaultSearch:p,decodeParams:m,encodeParams:h}}function ua(e,t,n){Vi(t,e);let r=Object.assign(U(null),n.forwardMap),i=Object.assign(U(null),n.forwardFnMap);return t===null?(delete r[e],delete i[e]):typeof t==`string`?(delete i[e],r[e]=t):(delete r[e],i[e]=t),{forwardMap:r,forwardFnMap:i,resolved:Bi({...n,forwardMap:r})}}function da(e,t,n){let r;for(let i of ji(n)){if(ti.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:l(r,i,a))}return r}function fa(e,t,n){n!==void 0&&(n===null?delete e[t]:e[t]=n)}function pa(e,t,n){if(fa(e.config.defaultParams,t,n.defaultParams),fa(e.config.defaultSearch,t,n.defaultSearch),n.decodeParams!==void 0){if(n.decodeParams===null)delete e.config.decoders[t];else{let r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}}if(n.encodeParams!==void 0){if(n.encodeParams===null)delete e.config.encoders[t];else{let r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}}function ma(e,t,n,r,i){r!==void 0&&(t===`activate`?r===null?e.clearCanActivate(n,`definition`):e.addCanActivate(n,r,!0,i):r===null?e.clearCanDeactivate(n,`definition`):e.addCanDeactivate(n,r,!0,i))}function ha(e,t,n){let r=e;Zi(r,`addRoute`),Qi(r,void 0),$i(r,void 0),Yi(r,``,`addRoute`);let i=ia(r,``,t,n),a={get definitions(){return cn(a.tree)},config:i.config,tree:i.tree,matcher:i.matcher,urlParamsCache:new Map,queryParamsCache:new Map,resolvedForwardMap:i.resolvedForwardMap,hasAnyForward:oi(i.config),routeCustomFields:i.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,revalidating:!1,pendingCanActivate:i.pendingCanActivate,pendingCanDeactivate:i.pendingCanDeactivate};return wi(a.matcher,a.config,`addRoute`),Mi(a,`matcherOptions`,{writable:!1,configurable:!1}),a}const ga=Object.freeze,_a=Object.keys,va=[];Object.freeze(va);function ya(e){let t=e.split(`.`),n=t.length,r=[t[0]],i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}const ba=new Set([`string`,`number`,`boolean`]);function xa(e){return ba.has(typeof e)}function Sa(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of _a(i)){let t=n.params[e],i=r.params[e];if(xa(t)&&xa(i)&&String(t)!==String(i))return!1}return!0}function Ca(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!Sa(a,e,t,n))return o}return a}const wa=new Map;function K(e){let t=wa.get(e);if(t)return t;let n=Ta(e);return ga(n),wa.set(e,n),n}function Ta(e){if(!e)return[``];let t=e.indexOf(`.`);if(t===-1)return[e];let n=e.indexOf(`.`,t+1);if(n===-1)return[e.slice(0,t),e];let r=e.indexOf(`.`,n+1);return r===-1?[e.slice(0,t),e.slice(0,n),e]:e.indexOf(`.`,r+1)===-1?[e.slice(0,t),e.slice(0,n),e.slice(0,r),e]:ya(e)}let Ea,Da,Oa=null,ka,Aa,ja=null;function Ma(e,t,n){if(!t)return{intersection:``,toActivate:K(e.name),toDeactivate:va};let r=n(e.name),i=n(t.name);if(!r&&!i)return{intersection:``,toActivate:K(e.name),toDeactivate:K(t.name)};let a=K(e.name),o=K(t.name),s=Math.min(o.length,a.length),c=Ca(r??i,e,t,a,o,s),l;if(c>=o.length)l=va;else if(c===0&&o.length===1)l=o;else{l=[];for(let e=o.length-1;e>=c;e--)l.push(o[e])}let u=c===0?a:a.slice(c);return{intersection:c>0?o[c-1]:``,toDeactivate:l,toActivate:u}}function Na(e,t,n){if(Oa!==null&&e===Ea&&t===Da)return Oa;if(ja!==null&&e===ka&&t===Aa)return ja;let r=Ma(e,t,n);return ka=Ea,Aa=Da,ja=Oa,Ea=e,Da=t,Oa=r,r}const Pa=c(`router`),Fa=c(`router`,`shouldUpdateNode`),Ia=Object.freeze,q=Object.hasOwn;function La(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,search:e.search,meta:e.meta}}function Ra(e){let t=Or(e);return t===`preserve`?void 0:t}var za=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,n){this.#e=ha(e,t,n)}static shouldUpdateNode(e,t){return(n,r)=>{if(!(n&&typeof n==`object`&&`name`in n))throw Fa.type`toState must be valid State object`;if(n.transition?.reload||e===``)return!0;let{intersection:i,toActivate:a,toDeactivate:o}=Na(n,r,t);return e===i||a.includes(e)?!0:o.includes(e)}}isRevalidating(){return this.#e.revalidating}setDependencies(e){this.#e.depsStore=e}flushPendingGuards(){let e=this.#r;for(let[t,n]of this.#e.pendingCanActivate)e.addActivateGuard(t,n);this.#e.pendingCanActivate.clear();for(let[t,n]of this.#e.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#e.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#e.lifecycleNamespace=e}setRootPath(e){Ii(this.#e,e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){Ri(this.#e)}buildPath(e,t,n,r){if(e===y.UNKNOWN_ROUTE)return typeof t.path==`string`?t.path:``;let i=this.#e.config.encoders[e];if(typeof i==`function`){let a=i({params:{...t},search:{...n}});return this.#e.matcher.buildPath(e,a.params,a.search,this.#c(r))}return this.#e.matcher.buildPath(e,t,n,this.#c(r))}buildPathFromIntent(e,t,n){return e===y.UNKNOWN_ROUTE?this.#r.port.buildPath(e,O(t,s),n??o):z(R(this.#r.port,e,t,n,{resolveForward:!1}),this.#r.port)}matchPath(e,t){let n=t,r=this.#e.matcher.match(e);if(!r)return;let i=La(r),{name:a}=i,o=D(i.params),s=D(i.search),c=this.#e.config.decoders[a],l;if(typeof c==`function`){l=c({params:o,search:s});let e=l.params;l={params:e,search:l.search},this.#r.getValidator()?.routes.validateStateBuilderArgs(a,e,`matchPath`),me(`matchPath`,a,e,this.getQueryParams(a),"the `params` returned by this route's `decodeParams`")}else l={params:o,search:s};let u=R(this.#r.port,a,l.params,l.search),d=u.name;x(`matchPath`,u.name,u.path,this.getQueryParams(u.name));let f=u.path,p=u.query,m=e;if(n.rewritePathOnMatch){let t=this.#e.config.encoders[d],r=typeof t==`function`?t({params:f,search:p}):{params:f,search:p},i=n.trailingSlash;try{m=this.#e.matcher.buildPath(d,r.params,r.search,{trailingSlash:Ra(i),queryParamsMode:kr(n.queryParamsMode)}),Or(i)===`preserve`&&(m=hi(e,m))}catch{m=e}}return B(u,m)}forwardState(e,t,n){let r=n??o;if(q(this.#e.config.forwardFnMap,e)){let n=this.#e.config.forwardFnMap[e],{target:i,chain:a,params:o}=this.#l(e,n,t);return this.#s(i,a,o,r)}let i=this.#e.resolvedForwardMap[e]??e;if(i!==e&&q(this.#e.config.forwardFnMap,i)){let n=this.#e.config.forwardFnMap[i],{target:a,chain:o,params:s}=this.#l(i,n,t);return this.#s(a,[...this.#o(e),...o],s,r)}return i===e?{name:e,params:t,search:r}:this.#s(i,this.#o(e),t,r)}buildStateResolved(e,t){let n=this.#e.matcher.getSegmentsByName(e);if(n)return La({segments:n,params:t,search:{},meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(e,t=s,n=o,r=!1,i=!0){if(this.#i(e,t,n,r,i))return!0;if(!this.#e.hasAnyForward)return!1;let a;try{a=typeof e==`string`?e:String(e)}catch{return!1}if(!q(this.#e.config.forwardMap,a)&&!q(this.#e.config.forwardFnMap,a))return!1;let c;try{c=this.forwardState(e,t,n)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Dynamic forwardTo of route "${li(e)}" threw while resolving the active-link destination; treating the link as inactive.`,t),!1}return this.#i(c.name,c.params,c.search,r,i)}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){return yi(this.#e,e)}getQueryParams(e){return Ci(this.#e,e)}getPrintedQueryParams(e){return Si(this.#e.matcher,e)}getStore(){return this.#e}getPort(){return this.#r.port}#i(e,t,n,r,i){try{return this.#a(e,t,n,r,i)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Reading the arguments for route "${li(e)}" threw while resolving the active-link state; treating the link as inactive.`,t),!1}}#a(e,t,n,r,i){let a=this.#r.getState();if(!a)return!1;let o=a.name;if(o!==e&&!o.startsWith(`${e}.`)&&!e.startsWith(`${o}.`))return!1;let s=R(this.#r.port,e,t,n,{resolveForward:!1});if(r||o===e){let e=zr(s,``);return!this.#r.areStatesEqual(e,a,!0)||!ci(s.path,a.params)?!1:i||be(e.search,a.search)}return!(!o.startsWith(`${e}.`)||!ci(s.path,a.params)||!i&&!ui(s.query,a.search))}#o(e){let t=[],n=e;for(;q(this.#e.config.forwardMap,n);)t.push(n),n=this.#e.config.forwardMap[n];return t}#s(e,t,n,r){let i,a;for(let e of t)i=Se(this.#e.config.defaultParams[e],i),a=Se(this.#e.config.defaultSearch[e],a);return{name:e,params:O(Se(i,n),s),search:O(Se(a,r),o)}}#c(e){return this.#t?(e!==this.#n&&this.#r.logger.warn(`router.buildPath`,"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957)."),this.#t):(this.#n=e,this.#t=Ia({trailingSlash:Ra(e?.trailingSlash),queryParamsMode:kr(e?.queryParamsMode)}),this.#t)}#l(e,t,n){let r=j(n),i=new Set([e]),a=[e],o=t(this.#r.getDependency,r),s=0;if(typeof o!=`string`)throw Pa.type`forwardTo callback must return a string, got ${typeof o}`;for(;s<100;){if(this.#e.matcher.getSegmentsByName(o)===void 0)throw Pa.plain`Route "${o}" does not exist`;if(i.has(o)){let e=[...i,o].join(` → `);throw Pa.plain`Circular forwardTo: ${e}`}if(i.add(o),q(this.#e.config.forwardFnMap,o)){let e=this.#e.config.forwardFnMap[o];a.push(o),o=e(this.#r.getDependency,r),s++;continue}let e=this.#e.config.forwardMap[o];if(e!==void 0)a.push(o),o=e,s++;else return{target:o,chain:a,params:r}}throw Pa.plain`forwardTo exceeds maximum depth of ${100}`}};const Ba=c(`router`),Va=new g(n.ROUTER_NOT_STARTED),Ha=new g(n.SAME_STATES),Ua=Ba.code(n.ROUTER_NOT_STARTED)`cannot commit before the start navigation does — the boot would overwrite it; defer with queueMicrotask/await, or navigate after start() resolves`;Object.freeze(Va),Object.freeze(Ha),Object.freeze(Ua);const Wa=Promise.reject(Va),Ga=Promise.reject(Ha),Ka=Promise.reject(Ua);Wa.catch(()=>{}),Ga.catch(()=>{}),Ka.catch(()=>{});const qa=new Set([n.SAME_STATES,n.TRANSITION_CANCELLED,n.ROUTER_NOT_STARTED,n.ROUTE_NOT_FOUND,n.CANNOT_ACTIVATE,n.CANNOT_DEACTIVATE,n.ROUTER_ALREADY_STARTED]);function Ja(e){return e instanceof g&&qa.has(e.code)}const Ya=new Set([Wa,Ga,Ka]),J=Object.freeze;function Xa(e){let{fromState:t,toDeactivate:n,toActivate:r,intersection:i}=e;J(n),J(r);let a={phase:`activating`,reason:`success`,segments:J({deactivated:n,activated:r,intersection:i})};return t?.name!==void 0&&(a.from=t.name),e.reload!==void 0&&(a.reload=e.reload),e.replace!==void 0&&(a.replace=e.replace),e.redirected!==void 0&&(a.redirected=e.redirected),J(a)}function Za(e,t){let{toState:r,fromState:i,toDeactivate:a,toActivate:o}=t;if(r.name!==y.UNKNOWN_ROUTE&&!e.hasRoute(r.name)){let a=d(new g(n.ROUTE_NOT_FOUND,{routeName:r.name}));throw e.sendTransitionFail(i,a,t),a}let s=t,c={...r,transition:Xa(t)},l=J(c);t.toState=l;let u=e.canCommitTransition(s);if(!u)throw d(new g(n.TRANSITION_CANCELLED));for(let n of a)!o.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n,u);return e.sendTransitionDone(s),l}const Qa=Object.entries;function $a(e){return e instanceof g&&e.code===n.TRANSITION_CANCELLED}function eo(e){return $a(e)?e:d(new g(n.TRANSITION_CANCELLED,{reason:e}))}function to(e,t,n,r){$a(t)?e.cancelIfInFlight(r,t):e.isTransitioning()&&e.sendTransitionFail(n,t,r)}function no(e,t,r){if(_(e)&&io(e,t,r),e instanceof DOMException&&e.name===`AbortError`)throw d(new g(n.TRANSITION_CANCELLED));if($a(e))throw e;io(e,t,r)}function ro(e){return _(e)?ao(e,n.CANNOT_DEACTIVATE):e}function io(e,t,n){throw e instanceof g?ao(e,t):d(new g(t,so(e,n)))}function ao(e,t){let{code:n,message:r,...i}=e.toJSON(),a=new g(n,{...i,message:r});return a.setCode(t),a.stack=e.stack??``,d(a)}const oo=new Set([`code`,`segment`,`path`,`then`]);function so(e,t){let n={segment:t};if(e instanceof Error){let t=e.message,r=e.stack,i=`cause`in e?e.cause:void 0;return{...n,message:t,stack:r,...i!==void 0&&{cause:i}}}if(e&&typeof e==`object`){let t={};for(let[n,r]of Qa(e))n!==`__proto__`&&!oo.has(n)&&l(t,n,r);return{...n,...t}}return n}async function co(e,t,n){let r;try{r=await e}catch(e){no(e,t,n);return}if(!r)throw d(new g(t,{segment:n}))}function lo(e,t,r,i,a,o,s,c,l,u){if(!l())throw d(new g(n.TRANSITION_CANCELLED));if(e===1){let n=u();return n===void 0?void 0:{phase:e,index:t+1,pending:n}}let f=r[t],p=i.get(f);if(!p)return;let m=!1;try{m=p(o,s,c)}catch(e){no(e,a,f)}let h;try{h=m.then}catch(e){no(e,a,f)}if(typeof h==`function`){let n=m;return{phase:e,index:t+1,pending:new Promise((e,t)=>{Reflect.apply(h,n,[e,t])})}}if(!m)throw d(new g(a,{segment:f}))}function uo(e,t,r,i,a,o,s,c,l,u,d,f,p){let m=e===1,h=e===0;if(!m&&!(h?s:c))return;let g=h?a:o,_=m?1:g.length,v=h?r:i,y=h?n.CANNOT_DEACTIVATE:n.CANNOT_ACTIVATE;for(let n=t;n<_;n++){let t=lo(e,n,g,v,y,l,u,d,f,p);if(t!==void 0)return t}}function fo(e,t,n,r,i,a,o,s,c,l,u,d,f){for(let p=d;p<=2;p++){let m=uo(p,p===d?f:0,e,t,n,r,i,a,o,s,c,l,u);if(m!==void 0)return m}}async function po(e,t,r,i,a,o,s,c,l,u,d,f){let p=e;for(;p!==void 0;){if(p.phase===1)await p.pending;else{let e=p.phase===0;await co(p.pending,e?n.CANNOT_DEACTIVATE:n.CANNOT_ACTIVATE,(e?i:a)[p.index-1])}p=fo(t,r,i,a,o,s,c,l,u,d,f,p.phase,p.index)}}function mo(e,t,n,r,i,a,o,s,c,l,u){let d=fo(e,t,n,r,i,a,o,s,c,l,u,0,0);return d===void 0?void 0:po(d,e,t,n,r,i,a,o,s,c,l,u)}const ho=Object.freeze,go=Object.freeze([]),_o=new Map;function vo(e,t){return t?ho({...e,replace:!0}):e}function yo(e,t,n,r){return!!e&&!t&&!n&&e.path===r.path}function bo(e,t){if(e.size===0)return!1;for(let n of t)if(e.has(n))return!0;return!1}function xo(e){let t=e.controller;if(t!==void 0)return t;let n=new AbortController;return e.cancelReason!==void 0&&(n.abort(e.cancelReason),i(n.signal.reason)),e.controller=n,n}function So(e,t){t.externalSignal!==void 0&&t.cancelReason===void 0&&t.hasGuards&&e.bridgeExternalSignal(t)}function Co(e,t,r,i,a,o,s,c,l,u){Ao(e,o);let f=e.hasLeaveListeners()||e.hasPreCommitListeners(),p={toState:t,fromState:r,opts:i,suspendable:a!==void 0||f,forceDeactivate:u,toDeactivate:go,toActivate:go,intersection:``,canDeactivateFunctions:_o,canActivateFunctions:_o,shouldDeactivate:!1,shouldActivate:!1,hasGuards:!1,controller:void 0,cancelReason:void 0,detachExternalBridge:void 0,externalSignal:a,reload:s,replace:c,redirected:l};if(!e.startTransition(p))throw d(new g(n.TRANSITION_CANCELLED));return p}function wo(e,t){return e.sendLeaveApprove(t),Za(e,t)}function To(e,t){let[n,r]=e.getLifecycleFunctions(),{toDeactivate:i,toActivate:a,intersection:o}=Na(t.toState,t.fromState,t=>e.getMetaForState(t));t.canDeactivateFunctions=n,t.canActivateFunctions=r,t.toDeactivate=i,t.toActivate=a,t.intersection=o,t.shouldDeactivate=!!t.fromState&&!t.forceDeactivate&&i.length>0,t.shouldActivate=t.toState.name!==y.UNKNOWN_ROUTE&&a.length>0,t.hasGuards=t.shouldDeactivate&&bo(n,i)||t.shouldActivate&&bo(r,a)}function Eo(e,t,r){let a,o;try{let i=Ce(r),s=i?.aborted===!0?i:void 0;r=xe(r),a=e.getState();let c=A(r,`reload`),l=A(r,`force`),u=A(r,`replace`),f=A(r,`redirected`),p=A(r,`forceDeactivate`)===!0,m=a?.name===y.UNKNOWN_ROUTE&&!u,h=m||u;if(r=vo(r,m),yo(a,c,l,t))return e.emitTransitionError(t,a,Ha),Ga;let _=Co(e,t,a,r,i,s,c,h,f,p);o=_;let v=_.externalSignal;if(v?.aborted===!0&&e.cancelNavigation(v.reason),To(e,_),So(e,_),!_.hasGuards&&!_.suspendable)return wo(e,_);let{canDeactivateFunctions:b,canActivateFunctions:x,toDeactivate:S,toActivate:ee,shouldDeactivate:te,shouldActivate:C,hasGuards:ne}=_,re=t;if(!ne){let t=ko(e,_);if(t!==void 0)return t}if(ne){let r=xo(_),i=()=>!r.signal.aborted,o=r.signal,s=mo(b,x,S,ee,te,C,t,a,o,i,()=>{if(e.sendLeaveApprove(_),e.hasLeaveListeners())return e.awaitLeaveListeners(re,a,o)});if(s!==void 0)return Do(e,s,_,r);if(!i())throw d(new g(n.TRANSITION_CANCELLED))}return Za(e,_)}catch(t){let n=Oo(e,t,{nav:o,fromState:a});return i(n),Promise.reject(n)}}async function Do(e,t,r,a){let o=()=>!a.signal.aborted,s=r.externalSignal,c,l=!1,u,f=new Promise(e=>{a.signal.aborted?e():(c=()=>{e()},a.signal.addEventListener(`abort`,c,{once:!0}))});t.catch(()=>{});try{if(s?.aborted)throw d(new g(n.TRANSITION_CANCELLED,{reason:s.reason}));if(await Promise.race([t,f]),!o())throw d(new g(n.TRANSITION_CANCELLED));let i=Za(e,r);return l=!0,i}catch(t){let n=o()?t:eo(t);throw u=n,to(e,n,r.fromState,r),i(n),n}finally{c&&a.signal.removeEventListener(`abort`,c),l||(a.abort(u),i(a.signal.reason))}}function Oo(e,t,n){let{nav:r}=n;if(e.dispatchAbort(r?.controller,t),r!==void 0){let i=r.cancelReason===void 0?t:eo(t);return to(e,i,n.fromState,r),i}return t}function ko(e,t){let{toState:n,fromState:r}=t;if(e.hasLeaveListeners()&&xo(t),e.sendLeaveApprove(t),e.hasLeaveListeners()){let i=xo(t),a=e.awaitLeaveListeners(n,r,i.signal);return a===void 0?void 0:Do(e,a,t,i)}}function Ao(e,t){if(e.isTransitioning()&&(e.logger.warn(`router`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),e.cancelNavigation()),t!==void 0)throw d(new g(n.TRANSITION_CANCELLED,{reason:t.reason}))}const jo=Object.freeze,Mo=c(`router`,`navigateToNotFound`),No=Object.freeze([y.UNKNOWN_ROUTE]),Po=Object.freeze({replace:!0});function Fo(e,t,r){Ao(e,void 0);let i=e.getState(),a=i?K(i.name).toReversed():[];jo(a);let c={deactivated:a,activated:No,intersection:``};jo(c);let l={phase:`activating`,...i&&{from:i.name},reason:`success`,replace:!0,segments:c};jo(l);let u={name:y.UNKNOWN_ROUTE,params:s,search:o,path:t,transition:l,context:{}};if(jo(u),r&&i!==void 0&&!e.canDeactivateCurrent(a,u,i)){let r=Mo.code(n.CANNOT_DEACTIVATE,{path:t})`a canDeactivate guard on "${i.name}" refused to leave for ${t}`;throw e.emitTransitionError(void 0,i,r),r}return e.systemCommit(u,i,Po)}function Io(e,t){return Fo(e,t,!0)}function Lo(e,t){return Fo(e,t,!1)}const Ro=c(`router`,`navigateToState`),zo=c(`router`,`navigateToDefault`);var Bo=class{#e;#t;#n=0;#r=0;setDependencies(e){this.#e=e,this.#t=t=>{Ja(t)||e.logger.error(`router`,`Unexpected navigation error`,t)}}navigate(e,t,n,r){return this.#i(this.#a(e,t,n,r))}navigateToState(e,t){return this.#i(this.#o(e,t))}navigateToDefault(e){return this.#i(this.#c(e))}navigateToNotFound(e){this.#r++;try{return Io(this.#e,e)}finally{this.#r--}}isCommittingNotFound(){return this.#r>0}revalidateToNotFound(e){return Lo(this.#e,e)}isPreparing(){return this.#n>0}#i(e){return e instanceof Promise&&!Ya.has(e)&&e.catch(this.#t),e}#a(e,t,r,i){let a=this.#e;if(!a.canNavigate())return a.isStarting()?Ka:Wa;let o;this.#n++;try{o=a.buildNavigateState(e,t,r)}catch(e){return Promise.reject(e)}finally{this.#n--}if(!o){let t=d(new g(n.ROUTE_NOT_FOUND,{routeName:e}));return a.emitTransitionError(void 0,a.getState(),t),Promise.reject(t)}return Eo(this.#e,o,i)}#o(e,t){let r=this.#e;if(!r.canNavigate())return r.isStarting()?Ka:Wa;let i=e.name;if(i!==y.UNKNOWN_ROUTE&&!r.hasRoute(i)){let e=d(new g(n.ROUTE_NOT_FOUND,{routeName:i}));return r.emitTransitionError(void 0,r.getState(),e),Promise.reject(e)}let a=b(e.params,r.getQueryParams(i));if(a!==void 0){let e=Ro.code(n.WRONG_CHANNEL,{routeName:i})`${pe(i,a,"`state.params`")}`;return r.emitTransitionError(void 0,r.getState(),e),Promise.reject(e)}let o;try{o=this.#s(e,i)}catch(e){return Promise.reject(e)}return Eo(this.#e,o,t)}#s(e,t){let n={name:t,params:we(e.params,s),search:we(e.search,o),path:e.path,context:{...e.context},transition:p};return _e(n)}#c(e){let t=this.#e;if(!t.getOptions().defaultRoute)return Promise.reject(zo.code(n.ROUTE_NOT_FOUND)`no defaultRoute is configured — pass one to createRouter, or navigate to a route by name`);let r,i,a;this.#n++;try{({route:r,params:i,search:a}=t.resolveDefault())}catch(e){return Promise.reject(e)}finally{this.#n--}return r?typeof r==`string`?this.#a(r,i,a,e):Promise.reject(zo.code(n.ROUTE_NOT_FOUND)`defaultRoute resolved to ${typeof r}, which cannot name a route`):Promise.reject(zo.code(n.ROUTE_NOT_FOUND)`defaultRoute resolved to an empty name`)}};const Vo={},Ho=c(`router`,`start`),Uo=Object.freeze({replace:!0});function Wo(e){return e instanceof g&&e.code===n.ROUTE_NOT_FOUND}var Go=class{#e;setDependencies(e){this.#e=e}async start(e){let t=this.#e;if(t.isIdle())throw d(new g(n.TRANSITION_CANCELLED));let r=t.getOptions();if(typeof e!=`string`)throw Ho.type`path must be a string, got ${typeof e}`;let i=t.getRootPath(),a=t.matchPath(e);if(!a&&!r.allowNotFound){let t=new g(n.ROUTE_NOT_FOUND,{path:e});throw d(t)}if(t.completeStart(),a!==void 0&&t.getRootPath()!==i&&(a=t.matchPath(e),!a&&!r.allowNotFound))throw d(new g(n.ROUTE_NOT_FOUND,{path:e}));if(a)try{return await t.navigateToState(a,Uo)}catch(n){if(!r.allowNotFound||!Wo(n))throw n;return t.navigateToNotFound(e)}return t.navigateToNotFound(e)}};const Ko={},qo=Object.create,Jo=Object.entries,Yo=Object.hasOwn,Xo=Object.values,Zo=new WeakMap;function Qo(e,t,n){if(typeof n==`string`)return{target:n,when:void 0,update:void 0};let r=n.when,i=n.update;if(r!==void 0&&typeof r!=`function`)throw m.plain`transitions["${e}"]["${t}"].when is not a function`;if(i!==void 0&&typeof i!=`function`)throw m.plain`transitions["${e}"]["${t}"].update is not a function`;return{target:n.target,when:r,update:i}}function $o(e){let t=Zo.get(e);if(t!==void 0)return t;let n=e,r=qo(null);for(let[e,t]of Jo(n)){let n=qo(null);for(let[r,i]of Jo(t))i!==void 0&&(n[r]=Qo(e,r,i));r[e]=n}for(let e of Xo(r))for(let t of Xo(e))if(t!==void 0&&r[t.target]===void 0)throw m.plain`state "${t.target}" is not declared in config.transitions`;return Zo.set(e,r),r}var es=class{#e;#t;#n=0;#r=null;#i;#a;#o=[];constructor(e){let t=e.initial;if(this.#e=t,this.#i=e.context,this.#a=$o(e.transitions),this.#a[t]===void 0)throw m.plain`state "${t}" is not declared in config.transitions`;this.#t=this.#a[t]}send(e,t){let n=this.#t[e];if(n===void 0)return this.#e;let r=t,i=n.when;if(i!==void 0&&!i(this.#i,r))return this.#e;let a=n.target,o=n.update,s=this.#e;if(this.#e=a,this.#t=this.#a[a],o?.(this.#i,r),this.#r!==null){let t=this.#r.get(s)?.get(e);t!==void 0&&t(r)}if(this.#n>0){let t={from:s,to:a,event:e,payload:r};for(let e of this.#o)e!==null&&e(t)}return this.#e}canSend(e,t){let n=this.#t[e];return n===void 0?!1:n.when===void 0||n.when(this.#i,t)}getState(){return this.#e}getContext(){return this.#i}on(e,t,n){let r=this.#a[e];if(r===void 0)throw m.plain`state "${e}" is not declared in config.transitions`;if(!Yo(r,t))throw m.plain`event "${t}" has no edge from state "${e}"`;this.#r??=new Map;let i=this.#r.get(e);i||(i=new Map,this.#r.set(e,i));let a=n;return i.set(t,a),()=>{let n=this.#r?.get(e);n?.get(t)===a&&n.delete(t)}}onTransition(e){let t=this.#o.indexOf(null),n;t===-1?(n=this.#o.length,this.#o.push(e)):(this.#o[t]=e,n=t),this.#n++;let r=!0;return()=>{r&&(r=!1,this.#o[n]=null,this.#n--)}}};const Y={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},X={START:`START`,STARTED:`STARTED`,NAVIGATE:`NAVIGATE`,LEAVE_APPROVE:`LEAVE_APPROVE`,COMPLETE:`COMPLETE`,FAIL:`FAIL`,CANCEL:`CANCEL`,STOP:`STOP`,DISPOSE:`DISPOSE`,SYSTEM_COMMIT:`SYSTEM_COMMIT`};function ts(){return{inflight:void 0,current:void 0,previous:void 0}}const ns=(e,t)=>t?.nav===void 0||t.nav===e.inflight,rs=(e,t)=>t!==void 0&&t===e.inflight&&t.externalSignal?.aborted!==!0,is=(e,t)=>{e.previous=e.current,e.current=_e(t)},as=(e,t)=>{is(e,t.toState),e.inflight=void 0},os=(e,t)=>{is(e,t.toState)},ss=e=>{e.previous=e.current,e.current=void 0},Z=e=>{e.current=void 0,e.previous=void 0,e.inflight=void 0},cs=(e,t)=>{e.inflight=t},ls={[Y.IDLE]:{[X.START]:Y.STARTING,[X.DISPOSE]:{target:Y.DISPOSED,update:Z}},[Y.STARTING]:{[X.STARTED]:Y.READY,[X.FAIL]:Y.IDLE,[X.STOP]:{target:Y.IDLE,update:ss},[X.DISPOSE]:{target:Y.DISPOSED,update:Z}},[Y.READY]:{[X.NAVIGATE]:{target:Y.TRANSITION_STARTED,update:cs},[X.SYSTEM_COMMIT]:{target:Y.READY,update:os},[X.STOP]:{target:Y.IDLE,update:ss},[X.DISPOSE]:{target:Y.DISPOSED,update:Z}},[Y.TRANSITION_STARTED]:{[X.NAVIGATE]:{target:Y.TRANSITION_STARTED,update:cs},[X.LEAVE_APPROVE]:Y.LEAVE_APPROVED,[X.CANCEL]:Y.READY,[X.FAIL]:{target:Y.READY,when:ns},[X.DISPOSE]:{target:Y.DISPOSED,update:Z}},[Y.LEAVE_APPROVED]:{[X.NAVIGATE]:{target:Y.TRANSITION_STARTED,update:cs},[X.COMPLETE]:{target:Y.READY,when:rs,update:as},[X.CANCEL]:Y.READY,[X.FAIL]:{target:Y.READY,when:ns},[X.DISPOSE]:{target:Y.DISPOSED,update:Z}},[Y.DISPOSED]:{}};function us(){return new es({initial:Y.IDLE,context:ts(),transitions:ls})}const ds=c(`router`,`subscribe`),fs=c(`router`,`subscribeChanges`),ps=c(`router`,`subscribeDiagnostic`),ms=c(`router`,`subscribeLeave`),hs=Object.freeze,gs=`TREE_CHANGED`;function _s(e){return e instanceof Error?e:Error(String(e))}function vs(e,t,r){return new Promise((i,a)=>{let o=()=>{let e=r.reason;a(e instanceof g&&e.code===n.TRANSITION_CANCELLED?e:d(new g(n.TRANSITION_CANCELLED,{reason:e})))};r.aborted?(Promise.allSettled(e),o()):(r.addEventListener(`abort`,o,{once:!0}),Promise.allSettled(e).then(e=>{if(r.removeEventListener(`abort`,o),r.aborted)return;if(t!==void 0){a(_s(ro(t)));return}let n=e.find(e=>e.status===`rejected`);n===void 0?i():a(_s(ro(n.reason)))}))})}function ys(e,t,n){return e.addEventListener(`abort`,t,{once:!0}),()=>{n(),e.removeEventListener(`abort`,t)}}var bs=class{#e;#t;#n;#r=[];#i=0;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#s()}static validateSubscribeListener(e){if(typeof e!=`function`)throw ds.type`Expected a function. For Observable pattern use observable(router) from @real-router/rx`}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw ms.type`Expected a function`}emitRouterStart(){this.#i++;try{this.#t.emit(v.ROUTER_START)}finally{this.#i--}}emitRouterStop(){this.#t.emit(v.ROUTER_STOP)}emitTransitionStart(e,t,n){this.#i++;try{this.#t.emit(v.TRANSITION_START,e,t)}finally{this.#i--}}emitTransitionSuccess(e,t,n){this.#i++;try{this.#t.emit(v.TRANSITION_SUCCESS,e,t,n)}finally{this.#i--}}emitTransitionError(e,t,n){this.#i++;try{this.#t.emit(v.TRANSITION_ERROR,e,t,n)}finally{this.#i--}}emitTransitionCancel(e,t){this.#i++;try{this.#t.emit(v.TRANSITION_CANCEL,e,t)}finally{this.#i--}}emitTransitionLeaveApprove(e,t){this.#i++;try{this.#t.emit(v.TRANSITION_LEAVE_APPROVE,e,t)}finally{this.#i--}}dispatchAbort(e,t){if(e!==void 0){this.#i++;try{e.abort(t),i(e.signal.reason)}finally{this.#i--}}}isProcessing(){return this.#i>0}emitTreeChanged(e){this.#t.emit(gs,e)}isEmittingTreeChanged(){return this.#t.isDispatching(gs)}subscribeTreeChanged(e){if(this.isDisposed())throw fs.code(n.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(gs,t=>{e(t)})}emitDiagnostic(e,...t){this.#t.emit(e,...t)}subscribeDiagnostic(e,t){if(this.isDisposed())throw ps.code(n.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(e,(...e)=>{t(...e)})}treeChangedListenerCount(){return this.#t.listenerCount(gs)}sendStart(){this.#e.send(X.START)}sendStop(){this.#e.send(X.STOP)}sendStopForDispose(){this.#i++;try{this.#e.send(X.STOP)}finally{this.#i--}}sendDispose(){this.#e.send(X.DISPOSE)}sendStarted(){this.#e.send(X.STARTED)}sendNavigate(e){return this.#e.send(X.NAVIGATE,e)===Y.TRANSITION_STARTED}canCommitTransition(e){return this.#e.canSend(X.COMPLETE,e)}sendComplete(e){this.#e.send(X.COMPLETE,e)}sendLeaveApprove(e){this.#e.send(X.LEAVE_APPROVE,e)}sendFail(e,t,n){this.#e.send(X.FAIL,{nav:n,fromState:e,error:t})}sendCancel(e,t){this.#e.send(X.CANCEL,{fromState:e,reason:t})}systemCommit(e,t){let{toState:n}=e,r=n.transition,i={name:t,params:we(n.params,s),search:we(n.search,o),path:n.path,context:{...n.context},...r!=null&&{transition:Te(r)}};if(!this.#e.canSend(X.SYSTEM_COMMIT))throw d(this.#o());return this.#e.send(X.SYSTEM_COMMIT,{...e,toState:i}),i}canBeginTransition(){return this.#e.canSend(X.NAVIGATE)}canStart(){return this.#e.canSend(X.START)}canCancel(){return this.#e.canSend(X.CANCEL)}isActive(){let e=this.#e.getState();return e!==Y.IDLE&&e!==Y.DISPOSED}isDisposed(){return this.#e.getState()===Y.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===Y.TRANSITION_STARTED||e===Y.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===Y.LEAVE_APPROVED}isReady(){return this.#e.getState()===Y.READY}isStarting(){return this.#e.getState()===Y.STARTING}isIdle(){return this.#e.getState()===Y.IDLE}addEventListener(e,t,n){return this.#a(e,n),this.#t.on(e,t)}subscribe(e){if(this.isDisposed())throw ds.code(n.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#a(v.TRANSITION_SUCCESS,`subscribe`),this.#t.on(v.TRANSITION_SUCCESS,(t,n)=>e({route:t,previousRoute:n}))}subscribeLeave(e){if(this.isDisposed())throw ms.code(n.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;this.#r.push(e);let t=!1;return()=>{if(t)return;t=!0;let n=this.#r.indexOf(e);n!==-1&&this.#r.splice(n,1)}}hasLeaveListeners(){return this.#r.length>0}hasPreCommitListeners(){return this.#t.listenerCount(v.TRANSITION_START)>0||this.#t.listenerCount(v.TRANSITION_LEAVE_APPROVE)>0}awaitLeaveListeners(e,t,n){if(t===void 0)return;let r=hs({route:t,nextRoute:e,signal:n}),i,a,o=[...this.#r];this.#i++;try{for(let e of o)try{let t=e(r);t!==void 0&&typeof t.then==`function`&&(i??=[],i.push(t))}catch(e){a===void 0&&(a=e)}}finally{this.#i--}if(i===void 0){if(a!==void 0)throw _s(ro(a))}else return vs(i,a,n)}clearAll(){this.#t.clearAll(),this.#r.length=0}setLimits(e){this.#t.setLimits(e)}setValidatorAccessor(e){this.#n=e}sendCancelIfPossible(e,t){this.canCancel()&&this.sendCancel(e,t)}sendCancelIfInFlight(e,t,n){this.#e.getContext().inflight===e&&this.sendCancelIfPossible(t,n)}bridgeExternalSignal(e){let t=e.externalSignal;if(t===void 0||e.detachExternalBridge!==void 0)return Ko;let n=ys(t,()=>{this.sendCancelIfPossible(this.#e.getContext().current,t.reason)},()=>{e.detachExternalBridge=void 0});return e.cancelReason===void 0?e.detachExternalBridge=n:n(),Ko}#a(e,t){let n=this.#n?.();n&&n.eventBus.validateCountThresholds(this.#t.listenerCount(e)+1,e,t)}#o(){if(this.isDisposed())return new g(n.ROUTER_DISPOSED,{message:`[router] cannot commit a state on a disposed router — dispose() is terminal`});let e;return e=this.isTransitioning()?`[router] cannot commit a state while a transition is in flight — the navigation in progress commits its own`:this.isStarting()?`[router] cannot commit before the start navigation does — the boot would overwrite it; await start() first`:`[router] cannot commit a state before the router has started`,new g(n.ROUTER_NOT_STARTED,{message:e})}#s(){let e=this.#e;e.on(Y.STARTING,X.STARTED,()=>{this.emitRouterStart()}),e.on(Y.READY,X.STOP,()=>{this.emitRouterStop()});let t=e=>{let t=e.externalSignal!==void 0&&(this.hasLeaveListeners()||this.hasPreCommitListeners())?this.bridgeExternalSignal(e):Ko;this.emitTransitionStart(e.toState,e.fromState,t)};e.on(Y.READY,X.NAVIGATE,t),e.on(Y.TRANSITION_STARTED,X.NAVIGATE,t),e.on(Y.LEAVE_APPROVED,X.NAVIGATE,t),e.on(Y.TRANSITION_STARTED,X.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(Y.LEAVE_APPROVED,X.COMPLETE,e=>{e.detachExternalBridge?.(),this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let r=e=>{let{fromState:t,reason:r}=e,i=this.#e.getContext().inflight,a=r??d(new g(n.TRANSITION_CANCELLED));i.cancelReason=a,this.dispatchAbort(i.controller,a),i.detachExternalBridge?.(),this.emitTransitionCancel(i.toState,t)};e.on(Y.TRANSITION_STARTED,X.CANCEL,r),e.on(Y.LEAVE_APPROVED,X.CANCEL,r),e.on(Y.READY,X.SYSTEM_COMMIT,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let i=e=>{let t=this.#e.getContext().inflight;t?.detachExternalBridge?.(),this.emitTransitionError(t?.toState,e.fromState,e.error)};e.on(Y.LEAVE_APPROVED,X.FAIL,i),e.on(Y.TRANSITION_STARTED,X.FAIL,i),e.on(Y.STARTING,X.FAIL,e=>{this.emitTransitionError(void 0,e.fromState,e.error)})}};const xs=Object.freeze;function Ss(e){return ws(e)&&!Object.isFrozen(e)&&e!==L.defaultParams&&e!==L.defaultSearch}function Cs(e){let{defaultParams:t,defaultSearch:n}=e;return xs({...Ss(t)&&{defaultParams:new WeakRef(t)},...Ss(n)&&{defaultSearch:new WeakRef(n)}})}function ws(e){return typeof e==`object`&&!!e}function Ts(e){let t={...e};return e.limits!=null&&(t.limits=k(`limits`,e.limits)),ws(e.defaultParams)&&(t.defaultParams=k(`defaultParams`,e.defaultParams)),ws(e.defaultSearch)&&(t.defaultSearch=k(`defaultSearch`,e.defaultSearch)),t}const Es=Object.keys,Ds=Object.freeze;function Os(e={}){let t={...a,...e};return Ds({maxDependencies:Number(t.maxDependencies),maxPlugins:Number(t.maxPlugins),maxListeners:Number(t.maxListeners),warnListeners:Number(t.warnListeners),maxLifecycleHandlers:Number(t.maxLifecycleHandlers)})}function ks(e){return e==null?void 0:Ds(Es(e))}const As=c(`router`),js=Object.freeze,Ms=Object.freeze({});function Ns(e,t){let n;try{n=t[e]}catch(t){throw As.type({cause:t})`Invalid "queryParams.${e}": reading it threw.`}if(n!=null){if(typeof n==`string`)return n;try{return String(n)}catch(t){throw As.type({cause:t})`Invalid "queryParams.${e}": its value cannot be converted to a string.`}}}function Ps(e){if(e==null)return`default`;try{return String(e)}catch(e){throw As.type({cause:e})`Invalid "urlParamsEncoding": coercing it threw.`}}function Fs(e){if(!e)return Ms;let t=Ns(`arrayFormat`,e),n=Ns(`booleanFormat`,e),r=Ns(`nullFormat`,e),i=Ns(`numberFormat`,e);return js({...t!==void 0&&{arrayFormat:t},...n!==void 0&&{booleanFormat:n},...r!==void 0&&{nullFormat:r},...i!==void 0&&{numberFormat:i}})}function Is(e){return js({strictTrailingSlash:e.trailingSlash===`strict`,caseSensitive:e.caseSensitive,strictQueryParams:e.queryParamsMode===`strict`,urlParamsEncoding:Ps(e.urlParamsEncoding),queryParams:Fs(e.queryParams)})}const Ls=new g(n.ROUTER_ALREADY_STARTED);Object.freeze(Ls);const Rs=c(`router`),zs={maxListeners:0,warnListeners:0};var Bs=class{#e=new Map;#t=new Set;#n=null;#r=zs;#i;#a;constructor(e){e?.limits&&(this.#r=e.limits),this.#i=e?.onListenerError??null,this.#a=e?.onListenerWarn??null}setLimits(e){this.#r=e}on(e,t){let n=this.#e.get(e),r=n?.size??0;if(n?.has(t))throw Rs.plain`Duplicate listener for "${e}"`;let{maxListeners:i,warnListeners:a}=this.#r;if(i!==0&&r>=i)throw Rs.plain`Listener limit (${i}) reached for "${e}"`;a!==0&&r===a&&this.#a!==null&&(this.#n??=new Set,this.#n.has(e)||(this.#a(e,a),this.#n.add(e)));let o=n;return o===void 0&&(o=new Set,this.#e.set(e,o)),o.add(t),()=>{this.off(e,t)}}off(e,t){let n=this.#e.get(e);n&&(n.delete(t),n.size===0&&(this.#e.delete(e),this.#n?.delete(e)))}emit(e,t,n,r,i){let a=this.#e.get(e);if(!a||a.size===0||this.#t.has(e))return;let o=arguments.length-1;this.#t.add(e);try{if(a.size===1){let[s]=a;this.#o(e,s,o,t,n,r,i)}else{let s=[...a];for(let a of s)this.#o(e,a,o,t,n,r,i)}}finally{this.#t.delete(e)}}clearAll(){this.#e.clear(),this.#n=null}listenerCount(e){return this.#e.get(e)?.size??0}isDispatching(e){return this.#t.has(e)}#o(e,t,n,r,i,a,o){try{let s=this.#s(t,n,r,i,a,o),c=s?.then;typeof c==`function`&&new Promise((e,t)=>{c.call(s,e,t)}).catch(t=>{this.#i?.(e,t)})}catch(t){this.#i?.(e,t)}}#s(e,t,n,r,i,a){switch(t){case 0:return e();case 1:return e(n);case 2:return e(n,r);case 3:return e(n,r,i);default:return e(n,r,i,a)}}};const Vs=Object.freeze({log:0,warn:1,error:2}),Hs=Object.freeze({all:0,"warn-error":1,"error-only":2,none:3}),Us=Object.hasOwn;var Ws=class{#e={level:`all`,callback:void 0,callbackIgnoresLevel:!1};#t=0;#n=!1;constructor(e){e&&this.configure(e)}isInCallback(){return this.#n}configure(e){let t=yr(e),n=t.level;n!==void 0&&(this.#e.level=n,this.#t=Hs[n]),Us(t,`callback`)&&(this.#e.callback=t.callback),t.callbackIgnoresLevel!==void 0&&(this.#e.callbackIgnoresLevel=t.callbackIgnoresLevel)}getConfig(){return{level:this.#e.level,callback:this.#e.callback,callbackIgnoresLevel:this.#e.callbackIgnoresLevel}}log(e,t,...n){this.#r(`log`,e,t,n)}warn(e,t,...n){this.#r(`warn`,e,t,n)}error(e,t,...n){this.#r(`error`,e,t,n)}#r(e,t,n,r){if(this.#e.level===`none`&&!this.#e.callbackIgnoresLevel)return;let i=Vs[e]<this.#t;i||this.#i(e,t,n,r),this.#a(e,t,n,i,r)}#i(e,t,n,r){if(typeof console<`u`&&typeof console[e]==`function`){let i=t?`[${t}] ${n}`:n;console[e](i,...r)}}#a(e,t,n,r,i){if(!(!this.#e.callback||!this.#e.callbackIgnoresLevel&&r)&&!this.#n){this.#n=!0;try{let r=this.#e.callback(e,t,n,...i);r!=null&&typeof r.then==`function`&&Promise.resolve(r).catch(e=>{this.#o(`[router] Error in async callback:`,e)})}catch(e){this.#o(`[router] Error in callback:`,e)}finally{this.#n=!1}}}#o(e,t){typeof console<`u`&&typeof console.error==`function`&&console.error(e,t)}};function Gs(e){let t=t=>Sr(e.dependenciesStore,t),n=Ks(e.router,t),r=Qs(e),i=()=>T(e.router).validator;qs(e),Js(e,i),Ys(e,n,i),Xs(e,r,i,t),Zs(e,n,i),$s(e,r,t),ec(e),tc(e,r)}function Ks(e,t){return n=>n(e,t)}function qs(e){e.eventBus.setLimits({maxListeners:e.limits.maxListeners,warnListeners:e.limits.warnListeners})}function Js(e,t){e.eventBus.setValidatorAccessor(t)}function Ys(e,t,n){let r={logger:T(e.router).logger,compileFactory:t,getValidator:n};e.routeLifecycle.setDependencies(r)}function Xs(e,t,n,r){let i={logger:T(e.router).logger,getValidator:n,port:t,addActivateGuard:(t,n,r)=>{e.routeLifecycle.addCanActivate(t,n,!0,r)},addDeactivateGuard:(t,n,r)=>{e.routeLifecycle.addCanDeactivate(t,n,!0,r)},compileGuard:(t,n)=>e.routeLifecycle.compileGuardFactory(t,n),getState:()=>e.state.get(),areStatesEqual:(t,n,r)=>e.state.areStatesEqual(t,n,r),getDependency:r};e.routes.setDependencies(i),e.routes.setLifecycleNamespace(e.routeLifecycle)}function Zs(e,t,n){let r={logger:T(e.router).logger,addEventListener:(t,n)=>e.eventBus.addEventListener(t,n,`usePlugin`),canNavigate:()=>e.eventBus.canBeginTransition(),compileFactory:t,getValidator:n,emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)}};e.plugins.setDependencies(r)}function Qs(e){let t=T(e.router),n=e.routes.getStore(),r=(e,n)=>{t.validator?.state.reportUndeclaredParamKey(e,n)},i=(e,n)=>{t.validator?.state.reportDroppedQueryKey(e,n)};return{resolveForward:(e,n,r)=>t.forwardState(e,n,r),defaultParams:e=>n.config.defaultParams[e],defaultSearch:e=>n.config.defaultSearch[e],buildPath:(t,n,r)=>e.routes.buildPath(t,n,r,e.options.get()),queryNames:t=>e.routes.getQueryParams(t),printedQueryNames:t=>e.routes.getPrintedQueryParams(t),pathNames:t=>e.routes.hasRoute(t)?e.routes.getUrlParams(t):void 0,admitsUndeclaredQuery:()=>kr(e.options.get().queryParamsMode)===`loose`,get reportDroppedQueryKey(){return t.validator?i:void 0},get reportUndeclaredParamKey(){return t.validator?r:void 0}}}function $s(e,t,n){let r=e=>n(e),i={logger:T(e.router).logger,getOptions:()=>e.options.get(),hasRoute:t=>e.routes.hasRoute(t),getQueryParams:t=>e.routes.getQueryParams(t),getMetaForState:t=>e.routes.getMetaForState(t),getState:()=>e.state.get(),buildNavigateState:(n,r,i)=>{T(e.router).validator?.routes.validateStateBuilderArgs(n,r,`navigate`);let a=R(t,n,r,i,{diagnoseUndeclared:!0});if(e.routes.getMetaForState(a.name)!==void 0)return x(`navigate`,a.name,a.path,t.queryNames(a.name)),B(a,z(a,t))},resolveDefault:()=>{let t=e.options.get(),n=T(e.router),i=Pr(t.defaultRoute,r),a=Pr(t.defaultParams,r),o=Pr(t.defaultSearch,r);return typeof t.defaultRoute==`function`&&n.validator?.options.validateResolvedDefaultRoute(i),{route:i,params:a,search:o}},startTransition:t=>e.eventBus.sendNavigate(t),systemCommit:(t,n,r)=>e.eventBus.systemCommit({toState:t,fromState:n,opts:r},t.name),cancelNavigation:t=>{e.eventBus.sendCancelIfPossible(e.state.get(),t)},cancelIfInFlight:(t,n)=>{e.eventBus.sendCancelIfInFlight(t,e.state.get(),n)},dispatchAbort:(t,n)=>{e.eventBus.dispatchAbort(t,n)},bridgeExternalSignal:t=>{e.eventBus.bridgeExternalSignal(t)},canCommitTransition:t=>e.eventBus.canCommitTransition(t)?Vo:void 0,sendTransitionDone:t=>{e.eventBus.sendComplete(t)},sendTransitionFail:(t,n,r)=>{e.eventBus.sendFail(t,n,r)},emitTransitionError:(t,n,r)=>{e.eventBus.emitTransitionError(t,n,r)},sendLeaveApprove:t=>{e.eventBus.sendLeaveApprove(t)},canNavigate:()=>e.eventBus.canBeginTransition(),isStarting:()=>e.eventBus.isStarting(),getLifecycleFunctions:()=>e.routeLifecycle.getFunctions(),canDeactivateCurrent:(t,n,r)=>e.routeLifecycle.canNavigateTo(t,[],n,r,`navigateToNotFound`),isTransitioning:()=>e.eventBus.isTransitioning(),clearCanDeactivate:(t,n)=>{e.routeLifecycle.clearCanDeactivate(t,`external`)},hasLeaveListeners:()=>e.eventBus.hasLeaveListeners(),hasPreCommitListeners:()=>e.eventBus.hasPreCommitListeners(),awaitLeaveListeners:(t,n,r)=>e.eventBus.awaitLeaveListeners(t,n,r)};e.navigation.setDependencies(i)}function ec(e){e.lifecycle.setDependencies({getOptions:()=>e.options.get(),navigateToState:(t,n)=>e.navigation.navigateToState(t,n),navigateToNotFound:t=>e.navigation.navigateToNotFound(t),matchPath:t=>e.routes.matchPath(t,e.options.get()),getRootPath:()=>e.routes.getStore().rootPath,completeStart:()=>{e.eventBus.sendStarted()},isIdle:()=>e.eventBus.isIdle()})}function tc(e,t){e.state.setDependencies({port:()=>t,getUrlParams:t=>e.routes.getUrlParams(t)})}const nc=c(`router`,`navigateToNotFound`),rc=c(`router`,`usePlugin`),ic=c(`router`,`start`),Q=c(`router`);var ac=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;constructor(t=[],r={},i={}){let{logger:a,...o}=r,c=new Ws(a?yr(a):void 0);this.#f=c,this.#p=e=>{Ja(e)||c.error(`router.start`,`Unexpected start error`,e)},Nr.validateOptionsIsObject(r),cr(i);let l=fr(t),f=Ts(o);this.#r=Cs(o),this.#e=new Nr(f),this.#t=Os(f.limits),this.#n=ks(f.limits),this.#i=Tr(i,this.#t),this.#a=new Br,this.#o=new za(l,Is(this.#e.get()),c),this.#s=new ei,this.#c=new qr,this.#l=new Bo,this.#u=new Go;let p=us();this.#a.setContext(p.getContext());let m=new Bs({onListenerError:(e,t)=>{c.error(`router`,`Error in listener for ${e}:`,t)},onListenerWarn:(e,t)=>{c.warn(`router`,`Event "${e}" has ${t} listeners — possible memory leak`)}});this.#d=new bs({routerFSM:p,emitter:m});let h=new Map,_=new Map,v=e=>{let t=e.params,n=e.search;return{name:e.name,params:t==null?t:D(t),search:n==null?n:D(n)}},y=ee(E.forwardState,(e,t,n)=>this.#o.forwardState(e,t,n),h,v,oc),b=((e,t,n)=>{let r=y(e,t,n),i=r.name,a=r.params;me(`forwardState`,i,a,this.#o.getQueryParams(i),()=>i===e?"the `params` bag leaving the forwardState chain":`the \`params\` bag leaving the forwardState chain (forwarded here from "${e}")`);let o=r.search,c=o==null;return{name:i,params:D(a??s),search:c?o:D(o)}}),x=ee(E.forwardState,(e,t,n)=>({name:e,params:t,search:n}),h,v,oc);this.#h=(e,t,n)=>{let r=x(e,t,n),i=r.params,a=r.search;return this.#o.buildPathFromIntent(r.name,i??s,a)},this.#m=ae(E.start,e=>this.#u.start(e),h);let S={logger:c,makeState:(e,t,n,r)=>{de(S,`makeState`,e,t);let i=j(t);return S.validator?.state.validateMakeStateArgs(e,i,r),S.validator?.navigation.validateSearch(n,`makeState`),this.#a.makeState(e,i,n,r)},getMetaForState:e=>this.#o.getMetaForState(e),getDeclaredQueryNames:e=>this.#o.getQueryParams(e),forwardState:b,buildStateResolved:(e,t)=>this.#o.buildStateResolved(e,t),buildPathResolved:(e,t,n)=>{let r=j(t);return S.validator?.navigation.validateParamsShape(t,`buildPathResolved`),S.validator?.navigation.validateSearch(n,`buildPathResolved`),C(S.checks,w[`buildPathResolved:params`],r),this.#o.buildPathFromIntent(e,r??s,n)},port:()=>this.#o.getPort(),matchPath:(e,t)=>(S.validator?.routes.validateMatchPathArgs(e),this.#o.matchPath(e,t??this.#e.get())),getOptions:()=>this.#e.get(),getAdoptedOrigins:()=>this.#r,addEventListener:(e,t)=>(oe(S.isDisposed),tr(e),nr(t),S.validator?.eventBus.validateListenerArgs(e,t),this.#d.addEventListener(e,t,`addEventListener`)),subscribeDiagnostic:(e,t)=>this.#d.subscribeDiagnostic(e,t),treeChanged:{emit:e=>{this.#d.emitTreeChanged(e)},subscribe:e=>this.#d.subscribeTreeChanged(e),listenerCount:()=>this.#d.treeChangedListenerCount(),isEmitting:()=>this.#d.isEmittingTreeChanged()},emitTransitionError:e=>{this.#d.emitTransitionError(void 0,this.#a.get(),e)},navigateToNotFound:e=>{if(this.#v(),e!==void 0&&typeof e!=`string`)throw nc.type`path must be a string, got ${typeof e}`;return this.#l.navigateToNotFound(e)},revalidateToNotFound:e=>(this.#y(),this.#l.revalidateToNotFound(e)),start:e=>this.start(e),navigateToState:(t,n)=>(oe(S.isDisposed),S.validator?.navigation.validateNavigateToStateArgs(t),n!==void 0&&S.validator?.navigation.validateNavigationOptions(n,`navigateToState`),this.#v(),e.#g(this.#l.navigateToState(t,n??u))),interceptors:h,checks:_,setRootPath:e=>{S.validator?.routes.validateSetRootPathArgs(e),this.#o.setRootPath(e)},getRootPath:()=>this.#o.getStore().rootPath,getTree:()=>this.#o.getStore().tree,isDisposed:()=>this.#d.isDisposed(),validator:null,dependenciesGetStore:()=>this.#i,getCloneState:()=>({options:{...this.#e.get()},dependencies:wr(this.#i),pluginFactories:this.#c.getAll(),loggerConfig:c.getConfig(),limits:this.#t,limitKeys:this.#n}),routeGetStore:()=>this.#o.getStore(),getStateName:()=>this.#a.get()?.name,isTransitioning:()=>this.#d.isTransitioning(),systemCommit:(e,t,r)=>{this.#y();let i=e.name;if(i!==`@@router/UNKNOWN_ROUTE`&&!this.#o.hasRoute(i))throw d(new g(n.ROUTE_NOT_FOUND,{routeName:i}));return this.#d.systemCommit({toState:e,fromState:t,opts:r},i)},routerExtensions:[],contextClaimRecords:new Map};le(this,S),Gs({router:this,options:this.#e,limits:this.#t,dependenciesStore:this.#i,state:this.#a,routes:this.#o,routeLifecycle:this.#s,plugins:this.#c,navigation:this.#l,lifecycle:this.#u,eventBus:this.#d}),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeLeave=this.subscribeLeave.bind(this),this.isLeaveApproved=this.isLeaveApproved.bind(this);try{this.#o.flushPendingGuards()}catch(e){throw this.dispose(),e}}isActiveRoute(e,t,n,r,i){let a=T(this);return a.validator?.routes.validateIsActiveRouteArgs(e,t,r,i),a.validator?.navigation.validateSearch(n,`isActiveRoute`),a.validator?.routes.validateRouteName(e,`isActiveRoute`),e===``?(a.logger.warn(`router.isActiveRoute`,`isActiveRoute("") called with empty string. Root node is not considered a parent of any route.`),!1):this.#o.isActiveRoute(e,t,n,r,i)}buildPath(e,t,n){let r=T(this);r.validator?.routes.validateBuildPathArgs(e,t),r.validator?.navigation.validateParamsShape(t,`buildPath`),r.validator?.navigation.validateSearch(n,`buildPath`);let i=j(t);return C(r.checks,w[`buildPath:params`],i),this.#h(e,i??s,n)}getState(){return this.#a.get()}getPreviousState(){return this.#a.getPrevious()}areStatesEqual(e,t,n=!0){return T(this).validator?.state.validateAreStatesEqualArgs(e,t,n),this.#a.areStatesEqual(e,t,n)}shouldUpdateNode(e){return T(this).validator?.routes.validateShouldUpdateNodeArgs(e),za.shouldUpdateNode(e,e=>this.#o.getMetaForState(e))}isActive(){return this.#d.isActive()}start(e){let t=this.#_(e);return t.catch(this.#p),t}stop(){return this.#d.sendCancelIfPossible(this.#a.get()),!this.#d.isReady()&&!this.#d.isTransitioning()&&!this.#d.isStarting()||this.#d.sendStop(),this}dispose(){if(this.#d.isDisposed())return;this.#d.sendCancelIfPossible(this.#a.get()),(this.#d.isReady()||this.#d.isTransitioning())&&this.#d.sendStopForDispose(),this.#d.sendDispose(),this.#d.clearAll(),this.#c.disposeAll();let e=T(this);for(let t of e.routerExtensions)for(let e of t.keys)delete this[e];e.routerExtensions.length=0,e.contextClaimRecords.clear(),e.interceptors.clear(),e.checks.clear(),this.#o.clearRoutes(),this.#s.clearAll(),Cr(this.#i),this.#x()}canNavigateTo(e,t,n){let r=T(this);C(r.checks,w[`canNavigateTo:entry`],e,t,n);let i;try{i=j(t)}catch(t){return r.logger.warn(`router.canNavigateTo`,`Reading the params bag for route "${e}" threw; treating the route as unreachable.`,t),!1}if(C(r.checks,w[`canNavigateTo:params`],i),!this.#o.hasRoute(e)||b(t,this.#o.getQueryParams(e))!==void 0)return!1;let a=this.#o.getPort(),o;try{o=R(a,e,i??s,n)}catch(t){return r.logger.warn(`router.canNavigateTo`,`Resolving route "${e}" threw while answering the predicate; treating the route as unreachable.`,t),!1}let c;try{c=B(o,z(o,a))}catch{return!1}let l=this.#a.get(),{toDeactivate:u,toActivate:d}=Na(c,l,e=>this.#o.getMetaForState(e));return this.#s.canNavigateTo(u,d,c,l,`canNavigateTo`)}usePlugin(...e){if(this.#d.isDisposed())throw rc.code(n.ROUTER_DISPOSED)`cannot install a plugin on a disposed router — dispose() is terminal`;let t=e.filter(Boolean);if(t.length===0)return()=>{};let r=T(this);r.validator?.plugins.validatePluginLimit(this.#c.count(),this.#t);for(let e of t)r.validator?.plugins.validateNoDuplicatePlugins(e,this.#c.getAll());return this.#c.use(...t)}subscribe(e){return bs.validateSubscribeListener(e),this.#d.subscribe(e)}subscribeLeave(e){return bs.validateSubscribeLeaveListener(e),this.#d.subscribeLeave(e)}isLeaveApproved(){return this.#d.isLeaveApproved()}navigate(t,n,r,i){this.#v();let a=T(this),o,c,l,d;typeof t==`object`&&t?(o=t.name,c=t.params,l=t.search,d=n??u):(o=t,c=n,l=r,d=i??u),de(a,`navigate`,o,c),C(a.checks,w[`navigate:entry`],o,c,l,d);let f;try{f=j(c)}catch(e){return Promise.reject(e)}return C(a.checks,w[`navigate:params`],f),e.#g(this.#l.navigate(o,f??s,l,d))}navigateToDefault(t){this.#v();let n=T(this);n.validator?.navigation.validateNavigateToDefaultArgs(t);let r=t??u;return n.validator?.navigation.validateNavigationOptions(r,`navigateToDefault`),e.#g(this.#l.navigateToDefault(r))}navigateToNotFound(e){if(this.#v(),!this.#d.isActive())throw d(new g(n.ROUTER_NOT_STARTED));if(e!==void 0&&typeof e!=`string`)throw nc.type`path must be a string, got ${typeof e}`;if(e!==void 0)return this.#l.navigateToNotFound(e);let t=this.#a.get();if(t===void 0)throw nc.code(n.ROUTER_NOT_STARTED)`cannot derive the path before the start navigation commits — pass an explicit path`;return this.#l.navigateToNotFound(t.path)}static#g(e){return e instanceof Promise?e:Promise.resolve(e)}#_(e){if(!this.#d.canStart())return Promise.reject(Ls);this.#v(),T(this).validator?.navigation.validateStartArgs(e),this.#d.sendStart();let t;try{let n=this.#m(e);t=typeof n?.then==`function`?n:Promise.reject(ic.type`a \`start\` interceptor returned without calling next(). Every start interceptor must return \`next(path)\`.`)}catch(e){t=Promise.reject(e)}return t.catch(e=>this.#b(e))}#v(){if(this.#f.isInCallback())throw Q.code(n.REENTRANT_NAVIGATION)`cannot start a navigation from inside the logger's callback — core logs from the middle of its own operations, and a navigation started there would run inside the one being logged. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#d.isProcessing())throw Q.code(n.REENTRANT_NAVIGATION)`cannot start a navigation from inside a router event listener or an abort listener of a navigation's signal — the nested navigation would commit a state the outer one overwrites. Defer it: queueMicrotask(() => router.navigate(...)), await the current transition, or use an async listener.`;if(this.#l.isPreparing())throw Q.code(n.REENTRANT_NAVIGATION)`cannot start a navigation from inside a forwardState interceptor, a route's encodeParams or dynamic forwardTo callback, or a defaultRoute/defaultParams/defaultSearch option callback — they run while a navigation is being prepared, before it is announced. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#l.isCommittingNotFound())throw Q.code(n.REENTRANT_NAVIGATION)`cannot start a navigation from inside a canDeactivate guard that navigateToNotFound() consults — the 404 commits from the state read before the guard was asked. A guard does not redirect: return false to stay, or defer the navigation: queueMicrotask(() => router.navigate(...)).`;if(this.#o.isRevalidating())throw Q.code(n.REENTRANT_NAVIGATION)`cannot start a navigation from inside replace()'s revalidation — the revalidation would then defer to a commit that may never happen. Defer it: queueMicrotask(() => router.navigate(...)).`}#y(){this.#o.isRevalidating()||this.#v()}#b(e){throw this.#d.isReady()&&this.#a.get()===void 0?this.#d.sendStop():this.#d.isStarting()&&this.#d.sendFail(void 0,e),e}#x(){this.navigate=$,this.navigateToDefault=$,this.navigateToNotFound=$,this.start=$,this.stop=$,this.usePlugin=$,this.subscribe=$,this.subscribeLeave=$,this.canNavigateTo=$}};function $(){throw Q.code(n.ROUTER_DISPOSED)`this router is disposed — dispose() is terminal and swapped every method to refuse`}function oc(e,t,n){return[e,j(t),j(n)]}export{xr as A,yi as C,Cr as D,R as E,rr as F,fr as I,dr as L,ur as M,ir as N,Sr as O,or as P,sn as R,pi as S,z as T,Ri as _,ta as a,si as b,ea as c,Qi as d,ra as f,oa as g,Li as h,sa as i,ar as j,wr as k,Zi as l,la as m,Na as n,$i as o,ia as p,W as r,Yi as s,ac as t,Xi as u,Ei as v,B as w,mi as x,wi as y,cn as z};
2
+ //# sourceMappingURL=Router-BC15vNmz.mjs.map