@real-router/core 0.172.0 → 0.173.1

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 (101) hide show
  1. package/dist/cjs/Router-CENrI5VW.js +2 -0
  2. package/dist/cjs/Router-CENrI5VW.js.map +1 -0
  3. package/dist/cjs/Router.d.ts.map +1 -1
  4. package/dist/cjs/api.js +1 -1
  5. package/dist/cjs/api.js.map +1 -1
  6. package/dist/cjs/engine/createMatcher.d.ts +0 -17
  7. package/dist/cjs/engine/createMatcher.d.ts.map +1 -1
  8. package/dist/cjs/engine/index.d.ts +2 -2
  9. package/dist/cjs/engine/search-params/index.d.ts +1 -1
  10. package/dist/cjs/helpers-BCSkINAR.js.map +1 -1
  11. package/dist/cjs/index.js +1 -1
  12. package/dist/cjs/route-batch-k_yzIZTV.js +2 -0
  13. package/dist/cjs/route-batch-k_yzIZTV.js.map +1 -0
  14. package/dist/cjs/types/api.d.ts +3 -6
  15. package/dist/cjs/types/api.d.ts.map +1 -1
  16. package/dist/cjs/types/base.d.ts +3 -6
  17. package/dist/cjs/types/base.d.ts.map +1 -1
  18. package/dist/cjs/types.d.ts +1 -7
  19. package/dist/cjs/types.d.ts.map +1 -1
  20. package/dist/cjs/validation.d.ts +9 -11
  21. package/dist/cjs/validation.js +1 -1
  22. package/dist/esm/Router-CFnIWPT3.mjs +2 -0
  23. package/dist/esm/Router-CFnIWPT3.mjs.map +1 -0
  24. package/dist/esm/Router.d.mts.map +1 -1
  25. package/dist/esm/api.mjs +1 -1
  26. package/dist/esm/api.mjs.map +1 -1
  27. package/dist/esm/engine/createMatcher.d.mts +0 -17
  28. package/dist/esm/engine/createMatcher.d.mts.map +1 -1
  29. package/dist/esm/engine/index.d.mts +2 -2
  30. package/dist/esm/engine/search-params/index.d.mts +1 -1
  31. package/dist/esm/helpers-LeSZEDaV.mjs.map +1 -1
  32. package/dist/esm/index.mjs +1 -1
  33. package/dist/esm/route-batch-LdEAJqGb.mjs +2 -0
  34. package/dist/esm/route-batch-LdEAJqGb.mjs.map +1 -0
  35. package/dist/esm/types/api.d.mts +3 -6
  36. package/dist/esm/types/api.d.mts.map +1 -1
  37. package/dist/esm/types/base.d.mts +3 -6
  38. package/dist/esm/types/base.d.mts.map +1 -1
  39. package/dist/esm/types.d.mts +1 -7
  40. package/dist/esm/types.d.mts.map +1 -1
  41. package/dist/esm/validation.d.mts +9 -11
  42. package/dist/esm/validation.mjs +1 -1
  43. package/package.json +1 -1
  44. package/dist/cjs/Router-CbpheBEo.js +0 -2
  45. package/dist/cjs/Router-CbpheBEo.js.map +0 -1
  46. package/dist/cjs/dependenciesStore.d.ts +0 -36
  47. package/dist/cjs/dependenciesStore.d.ts.map +0 -1
  48. package/dist/cjs/internals-C0q224rS.js +0 -2
  49. package/dist/cjs/internals-C0q224rS.js.map +0 -1
  50. package/dist/cjs/internals.d.ts +0 -158
  51. package/dist/cjs/internals.d.ts.map +0 -1
  52. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts +0 -191
  53. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts.map +0 -1
  54. package/dist/cjs/namespaces/RouteLifecycleNamespace/index.d.ts +0 -3
  55. package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts +0 -17
  56. package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts.map +0 -1
  57. package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.d.ts +0 -7
  58. package/dist/cjs/namespaces/RoutesNamespace/index.d.ts +0 -4
  59. package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts +0 -105
  60. package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts.map +0 -1
  61. package/dist/cjs/namespaces/RoutesNamespace/types.d.ts +0 -71
  62. package/dist/cjs/namespaces/RoutesNamespace/types.d.ts.map +0 -1
  63. package/dist/cjs/pipeline/buildURL.d.ts +0 -2
  64. package/dist/cjs/pipeline/canonicalize.d.ts +0 -3
  65. package/dist/cjs/pipeline/index.d.ts +0 -22
  66. package/dist/cjs/pipeline/materialize.d.ts +0 -2
  67. package/dist/cjs/pipeline/port.d.ts +0 -193
  68. package/dist/cjs/pipeline/port.d.ts.map +0 -1
  69. package/dist/cjs/pipeline/types.d.ts +0 -1
  70. package/dist/cjs/transitionPath.d.ts +0 -1
  71. package/dist/cjs/types/internal.d.ts +0 -23
  72. package/dist/cjs/types/internal.d.ts.map +0 -1
  73. package/dist/esm/Router-DYuv6lN0.mjs +0 -2
  74. package/dist/esm/Router-DYuv6lN0.mjs.map +0 -1
  75. package/dist/esm/dependenciesStore.d.mts +0 -36
  76. package/dist/esm/dependenciesStore.d.mts.map +0 -1
  77. package/dist/esm/internals-JRDAPvLO.mjs +0 -2
  78. package/dist/esm/internals-JRDAPvLO.mjs.map +0 -1
  79. package/dist/esm/internals.d.mts +0 -158
  80. package/dist/esm/internals.d.mts.map +0 -1
  81. package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts +0 -191
  82. package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts.map +0 -1
  83. package/dist/esm/namespaces/RouteLifecycleNamespace/index.d.mts +0 -3
  84. package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts +0 -17
  85. package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts.map +0 -1
  86. package/dist/esm/namespaces/RoutesNamespace/RoutesNamespace.d.mts +0 -7
  87. package/dist/esm/namespaces/RoutesNamespace/index.d.mts +0 -4
  88. package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts +0 -105
  89. package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts.map +0 -1
  90. package/dist/esm/namespaces/RoutesNamespace/types.d.mts +0 -71
  91. package/dist/esm/namespaces/RoutesNamespace/types.d.mts.map +0 -1
  92. package/dist/esm/pipeline/buildURL.d.mts +0 -2
  93. package/dist/esm/pipeline/canonicalize.d.mts +0 -3
  94. package/dist/esm/pipeline/index.d.mts +0 -22
  95. package/dist/esm/pipeline/materialize.d.mts +0 -2
  96. package/dist/esm/pipeline/port.d.mts +0 -193
  97. package/dist/esm/pipeline/port.d.mts.map +0 -1
  98. package/dist/esm/pipeline/types.d.mts +0 -1
  99. package/dist/esm/transitionPath.d.mts +0 -1
  100. package/dist/esm/types/internal.d.mts +0 -23
  101. package/dist/esm/types/internal.d.mts.map +0 -1
@@ -0,0 +1,2 @@
1
+ import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,o as l,p as u,r as d,s as f,t as p,u as m,v as h,y as g}from"./route-batch-LdEAJqGb.mjs";import{A as _,B as v,C as y,D as b,E as x,F as S,M as ee,N as te,O as C,P as w,R as T,S as E,T as ne,V as D,_ as re,a as ie,b as O,c as ae,d as oe,f as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,n as he,o as k,p as ge,r as _e,s as ve,t as A,u as ye,v as be,w as xe,x as j,y as M,z as N}from"./helpers-LeSZEDaV.mjs";const Se=Object.entries,Ce=Object.hasOwn;function we(e,t,n){if(e===void 0||n.length===0)return e;let r,i=!1;for(let[a,o]of Se(e))Ce(t,a)&&t[a]!==void 0&&n.includes(a)?i=!0:(r??={},C(r,a,o));return r===void 0?i?void 0:e:r}function Te(e,t,n){for(let[r,a]of Se(e))i(n,r,a,t(r),"this route's `defaultParams`","Move it to `defaultSearch`")}const Ee=Object.entries,De=Object.freeze;function Oe(e,t,n){let r,i=!1;for(let[a,o]of Ee(e))t.includes(a)?(r??={},C(r,a,o)):(i=!0,n?.(a));return i?De(r??S):e}function ke(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=ke(t,o);o.children.push(e)}return o}function Ae(e,t,n){let r=ke({name:e,path:t},null);for(let e of n){let t=ke(e,r);r.children.push(t)}return r}const je=/[^\w!$'()*+,.:;|~-]/gu,Me=/[^\w!$'()*+,.:;|~-]/u,Ne=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Pe=e=>t=>{try{return e(t)}catch{return e(t.replaceAll(Ne,`�`))}},Fe=Pe(e=>e.replaceAll(je,e=>encodeURIComponent(e))),Ie={default:e=>Me.test(e)?Fe(e):e,uri:Pe(encodeURI),uriComponent:Pe(encodeURIComponent),none:e=>e},Le={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e},Re={default:`%2F`,uri:`/`,uriComponent:`%2F`,none:`/`},ze=(e,t)=>{let n=Ie[t],r=Re[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},Be=Object.freeze(Object.create(null));function Ve(){return{staticChildren:Be,hasChildren:!1,paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function P(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e}function He(e,t){return e===``?t:t===``?e:e.endsWith(`/`)&&t.startsWith(`/`)?e+t.slice(1):e+t}function Ue(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function We(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(!Ue(n)||!Ue(r))return!1;t+=3}else t++;return!0}const Ge=Object.freeze([]),Ke=Object.freeze(new Set),qe=Object.freeze([]),Je=Object.freeze({}),Ye=Object.freeze({}),Xe=Object.freeze({});function Ze(e,t){let n=e.kind===`splat`;return{paramName:e.name,encoder:n?e=>ze(e,t):Ie[t]}}function Qe(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:qe};let o=[],s=[],l=``,u=a(e),d=u.length-1;for(let[e,t]of u.entries()){let r=c(t);(`error`in r||r.kind!==`splat`||e===d)&&(e>0&&(l+=`/`),`error`in r||r.kind===`static`?l+=t:(o.push(l),l=``,s.push(Ze(r,n))))}return o.push(l),{buildStaticParts:o,buildParamSlots:s}}const F=y(`router`);function $e(e,t,n){throw F.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 et(){throw F.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 tt(e){throw F.plain`Fused parameter marker in segment "${e}": a ':'/'*' marker must begin a segment — write 'a/:b', not 'a:b'.`}function nt(e){throw F.plain`Trailing parameter marker in segment "${e}": a param name cannot end in a bare ':' or '*'. Drop the stray marker.`}function rt(e){throw F.plain`Optional params are not supported: "${e}" — declare two sibling routes instead, one with the segment and one without.`}function it(e){throw F.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 at(e){throw F.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 ot(e,t){switch(e){case`name-less`:return et();case`trailing-marker`:return nt(t);case`fused-marker`:return tt(t);case`optional-removed`:return rt(t);case`constraint-removed`:return it(t)}}function st(e,t){let n=new Set,r=``;for(let e of t){if(n.has(e)){r=e;break}n.add(e)}throw F.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 ct(e,t){throw F.plain`Invalid query-param declaration "${t}" in route "${e}": a query-param name cannot contain '<' or '>'. Rename it.`}function lt(e){throw F.plain`Double slashes are not allowed in path "${e}": the route would build a URL its own matcher refuses. Remove the empty segment.`}function ut(e,t){throw F.plain`Duplicate route path: routes "${e}" and "${t}" resolve to the same URL — the later would shadow the earlier. Give them distinct paths.`}function dt(e,t){throw F.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 ft(e,t){return e.paramChild?e.paramChild.name!==t&&$e(e.paramChild.name,t,`:`):e.paramChild={node:Ve(),name:t},e.paramChild.node}function pt(e,t){return e.splatChild?e.splatChild.name!==t&&$e(e.splatChild.name,t,`*`):e.splatChild={node:Ve(),name:t},e.splatChild.node}const mt=Object.create;function ht(e,t){e.route!==void 0&&e.route!==t&&ut(e.route.name,t.name),e.route=t}function gt(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1}function _t(e,t,n){let r=P(n);r===`/`?ht(e.root,t):vt(e,e.root,r,1,t)}function vt(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=St(e,t,s),r=o+1}ht(t,i)}function yt(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(`*`)&&dt(t.name,n);let a=bt(e,n);a.slashChildRoute=t}function bt(e,t){return xt(e,e.root,t)}function xt(e,t,n){let r=P(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=St(e,i,s),a=n+1}return i}function St(e,t,n){let r=c(n);if(`error`in r&&et(),r.kind===`splat`){let e=pt(t,r.name);return t.hasChildren=!0,e}if(r.kind===`param`){let e=ft(t,r.name);return t.hasChildren=!0,e}gt(n)&&at(n);let i=e.options.caseSensitive?n:n.toLowerCase();return i in t.staticChildren||(t.staticChildren===Be&&(t.staticChildren=mt(null)),t.staticChildren[i]=Ve(),t.hasChildren=!0),t.staticChildren[i]}const Ct=Object.freeze,wt=Object.hasOwn;function Tt(e){let t=a(e);for(let[n,r]of t.entries())r===``&&n>0&&n<t.length-1&&lt(e)}function Et(e){for(let t of a(e)){let e=c(t);`error`in e&&ot(e.error,t)}}function Dt(e,t,r,i,a){let o=t.fullName===``;o||i.push(t);let s=t.absolute,c=t.paramMeta===n?t.path:t.paramMeta.pathPattern,l=s&&c.startsWith(`~`)?c.slice(1):c,u=s?l:c;Tt(t.path),Et(u);let d=u,f=s?d:He(r,d),p=o?a:Ot(e,t,f,s?``:r,i,a);for(let n of t.children.values())Dt(e,n,f,i,p);o||i.pop()}function Ot(e,t,n,r,i,a){let o=Nt(n,r),s=Ct([...i]),c=kt(s),l=P(n),u=Ct(Pt(e.rootQueryParams,i)),{buildStaticParts:d,buildParamSlots:f}=Qe(o?P(r):l,o?i.slice(0,-1):i,e.options.urlParamsEncoding,e.rootUrlParams),p=f.map(e=>e.paramName),m=p.length===0?Ke:new Set(p);m.size!==p.length&&st(t.fullName,p),Ft(t.fullName,u);let h={name:t.fullName,parent:a,matchSegments:s,meta:c,declaredQueryParams:u,declaredQueryParamsSet:u.length===0?Ke: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=Ct({segments:h.matchSegments,params:Je,search:Ye,meta:h.meta})),e.routesByName.set(t.fullName,h),o?jt(e,h,r):Mt(e,h,n,l,t),h}function kt(e){let t;for(let n of e)At(n.paramTypeMap)&&(t??=x(),t[n.fullName]=n.paramTypeMap);return t===void 0?Xe:Ct(xe(b(t)))}function At(e){for(let t in e)if(wt(e,t))return!0;return!1}function jt(e,t,n){yt(e,t,n);let r=P(n),i=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.has(i)&&e.staticCache.set(i,t)}function Mt(e,t,n,r,i){if(_t(e,t,n),i.paramMeta.urlParams.length===0){let n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}function Nt(e,t){return P(e)===P(t)}function Pt(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?Ge:n}function Ft(e,t){for(let n of t)r.test(n)&&ct(e,n)}const It=y(`router`,`buildPath`),Lt=Symbol.for(`real-router.searchParams.configFault`),Rt=Object.hasOwn,zt=Object.keys,Bt=Object.getOwnPropertyDescriptor;function Vt(e){try{return Bt(e,Lt)?.configurable===!1}catch{return!1}}function Ht(e){return typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):String(e)}const Ut=Object.freeze({});function Wt(e,t){return e===`strict`?t?`always`:`never`:e}var Gt=class{get options(){return this.#e}#e;#t=Ve();#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=Rt(Ie,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:Le[this.#e.urlParamsEncoding]}registerTree(e){this.#a=e.paramMeta.queryParams,Dt({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 It.plain`'${e}' is not defined`;let a=this.#l(i,t),o=this.#u(a,Wt(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&&Rt(t,a.paramName)?t[a.paramName]:void 0;if(r==null)throw It.plain`Missing required param '${a.paramName}'`;if(r===``)throw It.plain`Missing required param '${a.paramName}' (empty string)`;let o=a.encoder(Ht(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)Rt(t,n)&&(C(r,n,t[n]),i=!0);if(n===`loose`)for(let n of zt(t))e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(C(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=P(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=Ut;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(Vt(e))throw e;return}if(this.#e.strictQueryParams){let t=e.declaredQueryParamsSet;for(let e of zt(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),l=o?c:c.toLowerCase(),u;if(l in i.staticChildren){let e=i.staticChildren[l];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):(ne(r,a),o)}u=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):(ne(r,a),o)}u=e.node,C(r,e.name,c)}else if(i.splatChild)return this.#y(i.splatChild,t,n,r);else return;i=u,n=s+1}return i.slashChildRoute??i.route}#y(e,t,n,r){let i=e.node;if(!i.hasChildren)return C(r,e.name,t.slice(n)),i.route;let a={},o=this.#v(i,t,n,a);return o?(ne(r,a),o):(C(r,e.name,t.slice(n)),i.route)}#b(e){let t=this.#c;if(!t)return!0;for(let n of zt(e)){let r=e[n];if(r.includes(`%`)){if(!We(r))return!1;try{e[n]=t(r)}catch{return!1}}}return!0}};const I=Object.freeze,Kt=Object.freeze(new Map),qt=Object.freeze([]);function Jt(e){return e.parent?.name?`${e.parent.fullName}.${e.name}`:e.name}function Yt(e){let t=new Map;for(let n of e)t.set(n.name,n);return t}function Xt(e,t){let n=[],r=[];for(let i of e){let e=Zt(i,t);n.push(e),e.absolute||r.push(e)}return{childrenMap:Yt(n),nonAbsoluteChildren:r}}function Zt(e,t){let r=u(e.path),i=r.urlParams.length===0&&r.queryParams.length===0&&r.pathPattern===e.path?n:r,a=i.paramTypeMap,o={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:i,nonAbsoluteChildren:void 0,fullName:``,paramTypeMap:a};if(o.fullName=Jt(o),e.children.length===0)o.children=Kt,o.nonAbsoluteChildren=qt;else{let{childrenMap:t,nonAbsoluteChildren:n}=Xt(e.children,o);o.children=t,o.nonAbsoluteChildren=n,I(o.nonAbsoluteChildren),I(o.children)}return I(a),I(i.urlParams),I(i.queryParams),I(i),I(o),o}function Qt(e){return Zt(e,null)}function $t(e,t,n){return Qt(Ae(e,t,n))}function en(e){let t=e.absolute?`~${e.path}`:e.path,n={name:e.name,path:t};return e.children.size>0&&C(n,`children`,Array.from(e.children.values(),en)),n}function tn(e){return Array.from(e.children.values(),en)}function nn(e){let t=e?.queryParams,n=m(t);return new Gt({...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=>f(e,n),buildQueryString:e=>l(e,n)})}function rn(e,t){let n=e?.then;return typeof n==`function`&&(new Promise((t,r)=>{Reflect.apply(n,e,[t,r])}).catch(t),!0)}const an=new WeakMap,on=Symbol.for(`real-router.router`);function sn(e){try{return e?.[on]===!0}catch{return!1}}function L(e){let t=an.get(e);if(!t)throw TypeError(sn(e)?"[real-router] This IS a router, but not one this copy of @real-router/core built. Core identifies a router by object identity, so it is either wrapped in a Proxy (Vue `reactive()` / Pinia — store it with `markRaw`), or your dependency tree holds two copies of @real-router/core — dedupe it to one.":`[real-router] Invalid router instance — not found in internals registry`);return t}function cn(e,t,n,r){i(t,n,r,e.getDeclaredQueryNames(n))}function R(e){if(e())throw j(new O(N.ROUTER_DISPOSED,{message:`[router] this router is disposed — dispose() is terminal`}))}function ln(e,t){an.set(e,t),Object.defineProperty(e,on,{value:!0})}function un(e,t,n,r){let i=t;for(let t of e){let e=i,n=r===void 0?e:(...t)=>r(e(...t));i=(...e)=>t(n,...e)}return i(...n)}const dn={start:`start`,forwardState:`forwardState`},z={PLUGIN_AFTER_START:`PLUGIN_AFTER_START`,SET_DEPENDENCY_COUNT:`SET_DEPENDENCY_COUNT`,SET_DEPENDENCIES_COUNT:`SET_DEPENDENCIES_COUNT`,SET_DEPENDENCY_OVERWRITE:`SET_DEPENDENCY_OVERWRITE`,SET_DEPENDENCIES_OVERWRITE:`SET_DEPENDENCIES_OVERWRITE`,REMOVE_DEPENDENCY_MISSING:`REMOVE_DEPENDENCY_MISSING`,USE_PLUGIN_COUNT:`USE_PLUGIN_COUNT`,USE_PLUGIN_DUPLICATE_IN_BATCH:`USE_PLUGIN_DUPLICATE_IN_BATCH`,USE_PLUGIN_HOOK_NOT_FUNCTION:`USE_PLUGIN_HOOK_NOT_FUNCTION`,CAN_ACTIVATE_COUNT:`CAN_ACTIVATE_COUNT`,CAN_DEACTIVATE_COUNT:`CAN_DEACTIVATE_COUNT`,CAN_ACTIVATE_OVERWRITE:`CAN_ACTIVATE_OVERWRITE`,CAN_DEACTIVATE_OVERWRITE:`CAN_DEACTIVATE_OVERWRITE`,SYNC_GUARD_THENABLE:`SYNC_GUARD_THENABLE`,SYNC_GUARD_NON_BOOLEAN:`SYNC_GUARD_NON_BOOLEAN`,GUARD_NON_BOOLEAN:`GUARD_NON_BOOLEAN`,LISTENER_COUNT:`LISTENER_COUNT`,NAVIGATE_TO_DEFAULT:`NAVIGATE_TO_DEFAULT`,BUILD_PATH:`BUILD_PATH`,IS_ACTIVE_ROUTE:`IS_ACTIVE_ROUTE`,DROPPED_QUERY_KEY:`DROPPED_QUERY_KEY`,UNDECLARED_PARAM_KEY:`UNDECLARED_PARAM_KEY`,CODEC_ROUND_TRIP:`CODEC_ROUND_TRIP`},B={"buildPath:params":`buildPath:params`,"buildPathResolved:params":`buildPathResolved:params`,"canNavigateTo:entry":`canNavigateTo:entry`,"canNavigateTo:params":`canNavigateTo:params`,"navigate:entry":`navigate:entry`,"navigate:params":`navigate:params`,"addRoute:batch":`addRoute:batch`,"replaceRoutes:batch":`replaceRoutes:batch`,"removeRoute:entry":`removeRoute:entry`,"updateRoute:entry":`updateRoute:entry`,"hasRoute:entry":`hasRoute:entry`,"getRoute:entry":`getRoute:entry`,"forwardState:entry":`forwardState:entry`,"buildNavigationState:state":`buildNavigationState:state`,"addActivateGuard:entry":`addActivateGuard:entry`,"addDeactivateGuard:entry":`addDeactivateGuard:entry`,"removeActivateGuard:entry":`removeActivateGuard:entry`,"removeDeactivateGuard:entry":`removeDeactivateGuard:entry`,"getDependency:entry":`getDependency:entry`,"getDependency:value":`getDependency:value`,"setDependency:entry":`setDependency:entry`,"setDependency:count":`setDependency:count`,"setDependencies:entry":`setDependencies:entry`,"setDependencies:count":`setDependencies:count`,"removeDependency:entry":`removeDependency:entry`,"hasDependency:entry":`hasDependency:entry`,"cloneRouter:entry":`cloneRouter:entry`,"usePlugin:count":`usePlugin:count`,"usePlugin:entry":`usePlugin:entry`,"usePlugin:plugin":`usePlugin:plugin`,"canActivate:count":`canActivate:count`,"canDeactivate:count":`canDeactivate:count`,"navigateToState:entry":`navigateToState:entry`,"setRootPath:entry":`setRootPath:entry`,"navigateToDefault:entry":`navigateToDefault:entry`,"navigateToDefault:route":`navigateToDefault:route`,"start:entry":`start:entry`,"buildPath:entry":`buildPath:entry`,"buildPathResolved:entry":`buildPathResolved:entry`,"isActiveRoute:entry":`isActiveRoute:entry`,"areStatesEqual:entry":`areStatesEqual:entry`,"shouldUpdateNode:entry":`shouldUpdateNode:entry`,"matchPath:entry":`matchPath:entry`,"matchPath:decoded":`matchPath:decoded`,"makeState:state":`makeState:state`,"navigate:state":`navigate:state`},fn=y(`router`),pn=()=>void 0;function V(e,t,...n){let r=e.get(t);if(r===void 0)return;let i=r.length;for(let e=0;e<i&&e<r.length;e++)if(rn(r[e](...n),pn))throw fn.type`Async checks are not supported: the check at "${t}" returned a thenable. A check refuses by throwing synchronously.`}function mn(e,t){return(e.get(t)?.length??0)>0}function hn(e,t,n){return((...r)=>{let i=n.get(e);return!i||i.length===0?t(...r):un(i,t,r)})}function gn(e,t,n,r,i){return(a,o,s)=>{let c=n.get(e);return!c||c.length===0?t(a,o,s):un(c,t,i(a,o,s),r)}}const _n=y(`router`,`addEventListener`),vn=y(`router`,`subscribeChanges`),yn=y(`router`,`addInterceptor`),bn=y(`router`,`addCheck`),xn=y(`router`,`extendRouter`),H=y(`router`),Sn=Object.keys,Cn=Object.values,wn=Object.hasOwn,Tn=Object.getOwnPropertyDescriptor,En=Object.getPrototypeOf,Dn=Object,On=new Set(Cn(v));function kn(e){if(!On.has(e))throw _n.type`Invalid event name: ${String(e)}. Must be one of: ${[...On].join(`, `)}`}function An(e){if(typeof e!=`function`)throw _n.type`callback must be a function, got ${typeof e}`}function jn(e){if(typeof e!=`function`)throw vn.type`Expected a function`}function Mn(e,t){if(typeof e!=`string`||!wn(dn,e))throw yn.type`Invalid method: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Sn(dn).join(`, `)}`;if(typeof t!=`function`)throw yn.type`interceptor must be a function, got ${typeof t}`}function Nn(e,t){if(typeof e!=`string`||!wn(B,e))throw bn.type`Invalid position: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Sn(B).join(`, `)}`;if(typeof t!=`function`)throw bn.type`check must be a function, got ${typeof t}`}function Pn(e,t){if(typeof e!=`string`)throw y(`router`,t).type`Route name must be a string, got ${typeof e}`}function Fn(e,t){if(e===``)throw y(`router`,t).type`A guard on the root node "" never runs: no navigation activates or deactivates the root`}function In(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=En(e);return t===null||t.constructor===Dn}function Ln(e){if(!In(e))throw H.type`dependencies must be a plain object`}function Rn(e){return e===null?`null`:typeof e==`object`?`a non-plain object`:typeof e}function zn(e){if(!In(e))throw xn.type`extensions must be a plain object, got ${Rn(e)}`}function Bn(e,t){Ln(e);let n=e,r=[];for(let e of Sn(n)){if(Tn(n,e)?.get)throw H.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 Vn(e){let t=[];for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw H.type`route must be a non-array object`;d(e,`addRoute`);let r={...e},i=r.children;i&&C(r,`children`,Vn(i)),t.push(r)}return t}const Hn=new Set([`all`,`warn-error`,`error-only`,`none`]);function Un(e){return typeof e==`string`&&Hn.has(e)}function Wn(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function Gn(e){for(let t of Sn(e))if(![`level`,`callback`,`callbackIgnoresLevel`].includes(t))throw H.type`Unknown logger config property: "${t}"`}function Kn(e){if(!wn(e,`level`))return;let t=e.level;if(t!==void 0){if(!Un(t))throw H.type`Invalid logger level: ${Wn(t)}. Expected: "all" | "warn-error" | "error-only" | "none"`;return t}}function qn(e){if(!wn(e,`callbackIgnoresLevel`))return;let t=e.callbackIgnoresLevel;if(t!==void 0){if(typeof t!=`boolean`)throw H.type`Logger callbackIgnoresLevel must be a boolean, got ${typeof t}`;return t}}function Jn(e){if(typeof e!=`object`||!e)throw H.type`Logger config must be an object`;let t=e;Gn(t);let n=x(),r=Kn(t);if(r!==void 0&&(n.level=r),wn(t,`callback`)){let e=t.callback;if(e!==void 0&&typeof e!=`function`)throw H.type`Logger callback must be a function, got ${typeof e}`;n.callback=e}let i=qn(t);return i!==void 0&&(n.callbackIgnoresLevel=i),n}const Yn=Object.create,Xn=Object.freeze,Zn=Object.defineProperty;function Qn(e,t,n){e[t]=n}function $n(e,t){return e.dependencies[t]}function er(e){e.dependencies=Yn(null)}function tr(e){return ve({...e.dependencies})}function nr(e,t,n){let r=Yn(null),i=e,a=r;Bn(i,(e,t)=>{Qn(a,e,t)});let o={dependencies:r,limits:t,diagnostics:Xn(n)};return Zn(o,`diagnostics`,{writable:!1,configurable:!1}),o}const rr={defaultRoute:``,defaultParams:{},defaultSearch:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:s,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0},ir=[`strict`,`never`,`always`,`preserve`],ar=[`default`,`strict`,`loose`];function or(e){return e!==void 0&&ir.includes(e)?e:rr.trailingSlash}function sr(e){return e!==void 0&&ar.includes(e)?e:rr.queryParamsMode}const cr=y(`router`);function lr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw cr.type`options must be a plain object`}const ur=Object.freeze;var dr=class{#e;constructor(e={}){this.#e=ur(ve({...rr,...e}))}static validateOptionsIsObject(e){lr(e)}get(){return this.#e}};function fr(e,t){return typeof e==`function`?e(t):e}const pr=Object.keys;function mr(e,t,n,r,i){let a=e.pathNames(t);if(a!==void 0)for(let e of pr(n))!r.includes(e)&&!a.includes(e)&&i(t,e)}function U(e,t,n,r,i){let a=String(t),o=i?.resolveForward===!1?{name:a,params:n,search:r}:e.resolveForward(a,n,r),s=o.name,c=ge(o.params,w),l=i?.diagnoseUndeclared===!0?e.reportUndeclaredParamKey:void 0;l&&mr(e,s,c,e.queryNames(s),l);let u=e.defaultParams(s),d=e.defaultSearch(s);if((o.search===void 0||o.search===S)&&u===void 0&&d===void 0)return{name:s,path:c,query:S};let f=e.queryNames(s),p=e.reportDroppedQueryKey,m=i?.resolveForward===!1?we(d,c,f):d,h=ge(o.search,S),g=se(m,h);return{name:s,path:oe(u,c),query:e.admitsUndeclaredQuery()?g:Oe(g,e.printedQueryNames(s),t=>{p!==void 0&&e.pathNames(s)!==void 0&&p(s,t)})}}function hr(e,t){return t.buildPath(e.name,e.path,e.query)}const gr=Object.freeze;function _r(e,t){let n={name:e.name,params:e.path,search:e.query,path:t,context:{},transition:ee};return gr(n.params),n}function vr(e,t){return ae(_r(e,t))}function yr(e,t){return _r(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(t,n,r,i){let a=this.#t.port(),o=U(a,t,n??w,r,{resolveForward:!1});return e(`makeState`,o.name,o.path,a.queryNames(o.name)),vr(o,i??hr(o,a))}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;let r=e.name;return r===t.name?n?be(e.params,t.params,this.#t.getUrlParams(r)):re(e.params,t.params)&&re(e.search,t.search):!1}};const xr=Object.keys,Sr={[D.ROUTER_START]:v.ROUTER_START,[D.ROUTER_STOP]:v.ROUTER_STOP,[D.TRANSITION_SUCCESS]:v.TRANSITION_SUCCESS,[D.TRANSITION_START]:v.TRANSITION_START,[D.TRANSITION_LEAVE_APPROVE]:v.TRANSITION_LEAVE_APPROVE,[D.TRANSITION_ERROR]:v.TRANSITION_ERROR,[D.TRANSITION_CANCEL]:v.TRANSITION_CANCEL},Cr=xr(Sr),wr=y(`router`,`usePlugin`);function Tr(e){if(e)throw wr.code(N.ROUTER_DISPOSED)`cannot install a plugin on a disposed router — dispose() is terminal`}function Er(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 Dr=Object.freeze;function Or(e,t){try{rn(e(),t)}catch(e){t(e)}}var kr=class e{#e=new Set;#t=new Set;#n;static validatePlugin(e){Er(e)}static validateNotDisposed(e){Tr(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...e){if(this.#n.emitDiagnostic(z.USE_PLUGIN_COUNT,this.#e.size+e.length),e.length===1){let t=e[0],n=this.#o(t);this.#e.add(t);let r=!1,i=()=>{r||(r=!0,this.#e.delete(t),this.#t.delete(i),Or(n,this.#r))};return this.#t.add(i),i}let t=this.#a(e),n=[];try{for(let e of t){let t=this.#o(e);n.push({factory:e,cleanup:t})}}catch(e){for(let{cleanup:e}of n)Or(e,this.#i);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)Or(e,this.#r)}};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=>{this.#n.logger.error(`router`,`Error during cleanup:`,e)};#i=e=>{this.#n.logger.error(`router.usePlugin`,`Cleanup error:`,e)};#a(e){let t=new Set;for(let n of e)t.has(n)?this.#n.emitDiagnostic(z.USE_PLUGIN_DUPLICATE_IN_BATCH):t.add(n);return t}#o(t){e.validateNotDisposed(this.#n.isDisposed());let n=this.#n.compileFactory(t);e.validatePlugin(n),this.#n.runChecks(B[`usePlugin:plugin`],n),Dr(n);let r=[];for(let e of Cr)e in n&&(typeof n[e]==`function`?(r.push(this.#n.addEventListener(Sr[e],n[e])),e===`onStart`&&this.#n.canNavigate()&&this.#n.emitDiagnostic(z.PLUGIN_AFTER_START,e)):this.#n.emitDiagnostic(z.USE_PLUGIN_HOOK_NOT_FUNCTION,e));let i=()=>{for(let e of r)e();if(typeof n.teardown==`function`)return n.teardown()};return this.#n.isDisposed()&&Or(i,this.#i),e.validateNotDisposed(this.#n.isDisposed()),i}};const W=Object.create,Ar=()=>!0,jr=()=>!1,Mr=()=>Ar,Nr=()=>jr;function Pr(e){return e?Mr:Nr}const Fr={activate:{count:B[`canActivate:count`],counted:z.CAN_ACTIVATE_COUNT,overwritten:z.CAN_ACTIVATE_OVERWRITE},deactivate:{count:B[`canDeactivate:count`],counted:z.CAN_DEACTIVATE_COUNT,overwritten:z.CAN_DEACTIVATE_OVERWRITE}};function Ir(e,t,n){n===void 0?e.delete(t):e.set(t,n)}var Lr=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){this.#f(`activate`,e,n),this.#f(`deactivate`,t,n)}addCanActivate(e,t,n,r){this.#p(`activate`,e,t,n,`canActivate`,r)}addCanDeactivate(e,t,n,r){this.#p(`deactivate`,e,t,n,`canDeactivate`,r)}clearCanActivate(e,t){this.#m(`activate`,e,t)}clearCanDeactivate(e,t){this.#m(`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.#h(`activate`,e):this.#a.delete(e);for(let e of this.#n.keys())this.#o.delete(e),this.#r.has(e)?this.#h(`deactivate`,e):this.#i.delete(e);this.#e.clear(),this.#n.clear()}getFactories(){let e=W(null),t=W(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=W(null),t=W(null),n=W(null),r=W(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.#v(this.#i,t,n,r,i))return!1;for(let e of t)if(!this.#v(this.#a,e,n,r,i))return!1;return!0}compileGuardFactory(e,t){let n=typeof e==`boolean`?Pr(e):e,r=this.#d.compileFactory(n);if(typeof r!=`function`)throw y(`router`,t).type`Factory must return a function, got ${typeof r}`;return r}#f(e,t,n){let r=Fr[e].count;if(!this.#d.hasChecks(r))return;let{definition:i,external:a}=this.#_(e),o=0;for(let e of t)(n?a.has(e):i.has(e)||a.has(e))||o++;if(o===0)return;let s=n?a.size:this.getHandlerCount(e);this.#d.runChecks(r,s+o-1)}#p(e,t,n,r,i,a){let o=this.#_(e),s=e===`activate`?this.#a:this.#i,c=r?o.definition:o.external,l=r?o.external:o.definition,u=Fr[e];if(c.has(t)||l.has(t))this.#d.emitDiagnostic(u.overwritten,t);else if(this.#d.hasChecks(u.count)||this.#d.diagnosticListenerCount(u.counted)>0){let t=this.getHandlerCount(e);this.#d.runChecks(u.count,t),this.#d.emitDiagnostic(u.counted,t+1)}let d=typeof n==`boolean`?Pr(n):n,f=c.get(t),p=this.#g(e),m=r?p.definition:p.external,h=m.get(t);c.set(t,d);let g=r&&l.has(t);try{let e=a??this.compileGuardFactory(d,i);m.set(t,e),g||s.set(t,e)}catch(n){throw Ir(c,t,f),Ir(m,t,h),this.#h(e,t),n}}#m(e,t,n){let{definition:r,external:i}=this.#_(e),a=this.#g(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.#h(e,t)}#h(e,t){let n=this.#g(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)}#g(e){return e===`activate`?{definition:this.#c,external:this.#l}:{definition:this.#o,external:this.#s}}#_(e){return e===`activate`?{definition:this.#e,external:this.#t}:{definition:this.#n,external:this.#r}}#v(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:(typeof e?.then==`function`?(Promise.resolve(e).catch(()=>void 0),this.#d.emitDiagnostic(z.SYNC_GUARD_THENABLE,t,i)):this.#d.emitDiagnostic(z.SYNC_GUARD_NON_BOOLEAN,t,e,i),!1)}catch(e){return this.#d.logger.warn(`router.${i}`,`Guard for "${t}" threw — treated as navigation-blocking (returned false)`,e),!1}}};const Rr=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`,`defaultSearch`]),zr=Object.freeze,G=Object.create,Br=Object.hasOwn,Vr=Object.keys;function Hr(){return{decoders:G(null),encoders:G(null),defaultParams:G(null),defaultSearch:G(null),forwardMap:G(null),forwardFnMap:G(null)}}function Ur(e){return Vr(e.forwardMap).length>0||Vr(e.forwardFnMap).length>0}function Wr(e,t){for(let n of Vr(t))Object.assign(e[n],t[n])}function Gr(e,t){for(let n in e)if(Br(t,n)&&!ie(e[n],t[n]))return!1;return!0}function Kr(e){return typeof e==`string`?e:`<non-string>`}function qr(e,t){for(let n in e)if(!ie(e[n],t[n]))return!1;return!0}function Jr(e){let t={name:e.name,path:e.path};return e.children&&C(t,`children`,e.children.map(e=>Jr(e))),t}function Yr(e,t,n){if(n.add(t),e.children)for(let r of e.children)Yr(r,`${t}.${r.name}`,n)}function Xr(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 Yr(i,a,t),t}if(i.children&&t.startsWith(`${a}.`)){let e=Xr(i.children,t,a);if(e)return e}}}function Zr(e,t){for(let n of Vr(e))t(n)&&delete e[n]}function Qr(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 $r(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}const ei=zr([]);function ti(e,t,n){let r=n.get(t);if(r!==void 0)return r;let i=e.getSegmentsByName(t);if(!i)return ei;let a=zr($r(i));return n.set(t,a),a}function ni(e,t){return ti(e.matcher,t,e.urlParamsCache)}const ri=zr([]);function ii(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=e.getDeclaredQueryParams(t);if(!a)return ri;let o=ti(e,t,n),s=zr(a.filter(e=>!o.includes(e)));return r.set(t,s),s}function ai(e,t){return e.getDeclaredQueryParams(t)??ri}function oi(e,t){return ii(e.matcher,t,e.urlParamsCache,e.queryParamsCache)}function si(e,t,n){let r=new Map,i=new Map;Te(t.defaultParams,t=>ii(e,t,r,i),n)}const ci=y(`router`);function li(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 ci.plain`Circular forwardTo: ${t.join(` → `)}`}if(i.add(o),a.push(r),o=r,a.length>n)throw ci.plain`forwardTo chain exceeds maximum depth (${n}): ${a.join(` → `)}`}return o}const ui=y(`router`),di=y(`router`,`addRoute`),fi=Object.freeze,K=Object.create,pi=Object.entries,mi=Object.keys,hi=Object.defineProperty,gi=Object.fromEntries;function _i(e,t,n){let r=$t(``,t,e),i=nn(n);return i.registerTree(r),{tree:r,matcher:i}}function vi(e,t=e.definitions){let n=_i(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function yi(e,t){let n=_i(e.definitions,t,e.matcherOptions);si(n.matcher,e.config,`setRootPath`),e.rootPath=t,e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function bi(e,t){vi(e,t),Ci(e,wi(e.config))}function xi(e){Si(e),vi(e,[])}function Si(e){Object.assign(e.config,Hr()),Ci(e,K(null)),e.routeCustomFields=K(null)}function Ci(e,t){e.resolvedForwardMap=t,e.hasAnyForward=Ur(e.config)}function wi(e){let t=K(null);for(let n of mi(e.forwardMap))t[n]=li(n,e.forwardMap);return t}function Ti(e,t){if(typeof e!=`function`){if(typeof e!=`string`&&e!==null)throw ui.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 ui.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}function Ei(e,t,n){t&&p(`encodeParams`,t,n,void 0),e&&p(`decodeParams`,e,n,void 0)}function Di(e,t,n,r){if(Ti(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 Oi(e,t,n,r,i,a,o){let{decodeParams:s,encodeParams:c}=e;Ei(s,c,t);let l=gi(pi(e).filter(([e])=>!Rr.has(e)));mi(l).length>0&&(r[t]=fi(l)),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&Di(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 ki(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;Oi(s,e,t,n,r,i,a),s.children&&ki(s.children,t,n,r,i,a,e)}}function Ai(e){let t=Hr();return Wr(t,e),t}function ji(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]:ji(n,t,i)}})}function Mi(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&Mi(r.children,e,n)}}function Ni(e,t,n){let r=new Set;Mi(e,t,e=>{if(r.has(e))throw y(`router`,n).plain`Duplicate route "${e}" in batch`;r.add(e)})}function Pi(e,t){if(Pn(e,t),e.startsWith(`@@`))throw y(`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 Fi(e,t){for(let n of e)Pi(n.name,t),n.children&&Fi(n.children,t)}function Ii(e,n){for(let r of e)t(r.name,n),r.children&&Ii(r.children,n)}function Li(e,t){for(let n of e)o(n.name,t),n.children&&Li(n.children,t)}function Ri(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 y(`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 zi(e,t,n){if(Fi(t,`addRoute`),Ii(t,`addRoute`),Li(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw di.plain`Parent route "${n}" does not exist`;Mi(t,n??``,t=>{if(e.matcher.hasRoute(t))throw di.plain`Route "${t}" already exists`}),Ni(t,n??``,`addRoute`),Ri(t,n??``,`addRoute`)}function Bi({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:o,logger:s}){let c=new Map,l=new Map;ki(t,n,r,c,l,s,i);let u=wi(n),{tree:d,matcher:f}=_i(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function Vi(e,t,n,r){return Bi({definitions:ji(e.definitions,t.map(e=>Jr(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:Ai(e.config),routeCustomFields:Object.assign(K(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function Hi(e,t,n,r){return Bi({definitions:e.map(e=>Jr(e)),routesForHandlers:e,config:Hr(),routeCustomFields:K(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function Ui(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function Wi(e,t){return{activate:Ui(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:Ui(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function Gi(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??Wi(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(),Ci(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 q(e){return e===null?e:e||void 0}function Ki(e,t){return t==null?t:k(e,t)}function qi(e,t,n,r){let{forwardTo:a,defaultParams:o,defaultSearch:s,decodeParams:c,encodeParams:l,canActivate:u,canDeactivate:d}=r,f=q(a),p=Ki(`defaultParams`,q(o)),m=Ki(`defaultSearch`,q(s)),h=q(c),g=q(l),_=q(u),v=q(d);p!=null&&i(`updateRoute`,n,p,oi(e,n),"this route's `defaultParams`","Move it to `defaultSearch`"),Ei(h,g,n);let y=f===void 0?void 0:Ji(n,f,e.config),b=Yi(e,n,r),x=_==null?void 0:t.compileGuardFactory(_,`canActivate`),S=v==null?void 0:t.compileGuardFactory(v,`canDeactivate`);return t.preflightHandlerLimit(x===void 0?[]:[n],S===void 0?[]:[n],!1),b!==void 0&&(mi(b).length>0?e.routeCustomFields[n]=fi(b):delete e.routeCustomFields[n]),y!==void 0&&(e.config.forwardMap=y.forwardMap,e.config.forwardFnMap=y.forwardFnMap,Ci(e,y.resolved)),Zi(e,n,{defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}),Qi(t,`activate`,n,_,x),Qi(t,`deactivate`,n,v,S),{forwardTo:f,defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}}function Ji(e,t,n){Ti(t,e);let r=Object.assign(K(null),n.forwardMap),i=Object.assign(K(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:wi({...n,forwardMap:r})}}function Yi(e,t,n){let r;for(let i of mi(n)){if(Rr.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:C(r,i,a))}return r}function Xi(e,t,n){n!==void 0&&(n===null?delete e[t]:e[t]=n)}function Zi(e,t,n){if(Xi(e.config.defaultParams,t,n.defaultParams),Xi(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 Qi(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 $i(e,t,n,r){let i=e;Fi(i,`addRoute`),Ii(i,void 0),Li(i,void 0),Ni(i,``,`addRoute`);let a=Hi(i,``,t,n),o={get definitions(){return tn(o.tree)},config:a.config,tree:a.tree,matcher:a.matcher,urlParamsCache:new Map,queryParamsCache:new Map,resolvedForwardMap:a.resolvedForwardMap,hasAnyForward:Ur(a.config),routeCustomFields:a.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,treeChanged:fi(r),revalidating:!1,pendingCanActivate:a.pendingCanActivate,pendingCanDeactivate:a.pendingCanDeactivate};return si(o.matcher,o.config,`addRoute`),hi(o,`matcherOptions`,{writable:!1,configurable:!1}),hi(o,`treeChanged`,{writable:!1,configurable:!1}),o}function ea(e,t,n){hi(e,t,{value:n,writable:!1,configurable:!1})}const ta=Object.freeze,na=Object.keys,ra=[];Object.freeze(ra);function ia(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}function aa(e,t){if(e===t)return!0;let n=Array.isArray(e),r=Array.isArray(t);if(!n&&!r)return pe(e)&&pe(t)?me(e)===me(t):ie(e,t);let i=n?e:[e],a=r?t:[t],o=i.length;if(o!==a.length)return!1;for(let e=0;e<o;e++)if(!aa(i[e],a[e]))return!1;return!0}function oa(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of na(i))if(!aa(n.params[e],r.params[e])||!aa(n.search[e],r.search[e]))return!1;return!0}function sa(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!oa(a,e,t,n))return o}return a}const ca=new Map;function J(e){let t=ca.get(e);if(t)return t;let n=la(e);return ta(n),ca.set(e,n),n}function la(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]:ia(e)}let ua,da,fa=null,pa,ma,ha=null;function ga(e,t,n){if(!t)return{intersection:``,toActivate:J(e.name),toDeactivate:ra};let r=n(e.name),i=n(t.name);if(!r&&!i)return{intersection:``,toActivate:J(e.name),toDeactivate:J(t.name)};let a=J(e.name),o=J(t.name),s=Math.min(o.length,a.length),c=sa(r??i,e,t,a,o,s),l;if(c>=o.length)l=ra;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 _a(e,t,n){if(fa!==null&&e===ua&&t===da)return fa;if(ha!==null&&e===pa&&t===ma)return ha;let r=ga(e,t,n);return pa=ua,ma=da,ha=fa,ua=e,da=t,fa=r,r}const va=y(`router`),ya=y(`router`,`shouldUpdateNode`),ba=Object.freeze,Y=Object.hasOwn;function xa(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,search:e.search,meta:e.meta}}function Sa(e){let t=or(e);return t===`preserve`?void 0:t}var Ca=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,n,r){this.#e=$i(e,t,n,r)}static shouldUpdateNode(e,t){return(n,r)=>{if(!(n&&typeof n==`object`&&`name`in n))throw ya.type`toState must be valid State object`;if(n.transition?.reload||e===``)return!0;let{intersection:i,toActivate:a,toDeactivate:o}=_a(n,r,t);return e===i||a.includes(e)?!0:o.includes(e)}}isRevalidating(){return this.#e.revalidating}setDependencies(e){ea(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){ea(this.#e,`lifecycleNamespace`,e)}setRootPath(e){yi(this.#e,e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){xi(this.#e)}buildPath(e,t,n,r){if(e===T.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??t,a.search??n,this.#c(r))}return this.#e.matcher.buildPath(e,t,n,this.#c(r))}buildPathFromIntent(e,t,n){return e===T.UNKNOWN_ROUTE?this.#r.port.buildPath(e,ge(t,w),n??S):hr(U(this.#r.port,e,t,n,{resolveForward:!1}),this.#r.port)}matchPath(t,n){let r=n,a=this.#e.matcher.match(t);if(!a)return;let o=xa(a),{name:s}=o,c=M(o.params),l=M(o.search),u=this.#e.config.decoders[s],d;if(typeof u==`function`){d=u({params:c,search:l});let e=d,t=e.params,n=t??c;d={params:n,search:e.search??l},V(this.#r.checks,B[`matchPath:decoded`],s,t),i(`matchPath`,s,n,this.getQueryParams(s),"the `params` returned by this route's `decodeParams`")}else d={params:c,search:l};let f=U(this.#r.port,s,d.params,d.search),p=f.name;e(`matchPath`,f.name,f.path,this.getQueryParams(f.name));let m=f.path,h=f.query,g=t;if(r.rewritePathOnMatch)try{let e=this.#e.config.encoders[p],n=typeof e==`function`?e({params:{...m},search:{...h}}):{params:m,search:h},i=r.trailingSlash;g=this.#e.matcher.buildPath(p,n.params??m,n.search??h,{trailingSlash:Sa(i),queryParamsMode:sr(r.queryParamsMode)}),or(i)===`preserve`&&(g=Qr(t,g))}catch{g=t}return vr(f,g)}forwardState(e,t,n){let r=n??S;if(Y(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&&Y(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 xa({segments:n,params:t,search:{},meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(e,t=w,n=S,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(!Y(this.#e.config.forwardMap,a)&&!Y(this.#e.config.forwardFnMap,a))return!1;let o;try{o=this.forwardState(e,t,n)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Dynamic forwardTo of route "${Kr(e)}" threw while resolving the active-link destination; treating the link as inactive.`,t),!1}return this.#i(o.name,o.params,o.search,r,i)}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){return ni(this.#e,e)}getQueryParams(e){return oi(this.#e,e)}getPrintedQueryParams(e){return ai(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 "${Kr(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=U(this.#r.port,e,t,n,{resolveForward:!1});if(r||o===e){let e=yr(s,``);return!this.#r.areStatesEqual(e,a,!0)||!Gr(s.path,a.params)?!1:i||re(e.search,a.search)}return!(!o.startsWith(`${e}.`)||!Gr(s.path,a.params)||!i&&!qr(s.query,a.search))}#o(e){let t=[],n=e;for(;Y(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=ye(this.#e.config.defaultParams[e],i),a=ye(this.#e.config.defaultSearch[e],a);return{name:e,params:ge(ye(i,n),w),search:ge(ye(a,r),S)}}#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=ba({trailingSlash:Sa(e?.trailingSlash),queryParamsMode:sr(e?.queryParamsMode)}),this.#t)}#l(e,t,n){let r=A(n),i=new Set([e]),a=[e],o=t(this.#r.getDependency,r),s=0;if(typeof o!=`string`)throw va.type`forwardTo callback must return a string, got ${typeof o}`;for(;s<100;){if(this.#e.matcher.getSegmentsByName(o)===void 0)throw va.plain`Route "${o}" does not exist`;if(i.has(o)){let e=[...i,o].join(` → `);throw va.plain`Circular forwardTo: ${e}`}if(i.add(o),Y(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 va.plain`forwardTo exceeds maximum depth of ${100}`}};const wa=y(`router`),Ta=new O(N.ROUTER_NOT_STARTED),Ea=new O(N.SAME_STATES),Da=wa.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(Ta),Object.freeze(Ea),Object.freeze(Da);const Oa=Promise.reject(Ta),ka=Promise.reject(Ea),Aa=Promise.reject(Da);Oa.catch(()=>{}),ka.catch(()=>{}),Aa.catch(()=>{});const ja=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 Ma(e){return e instanceof O&&ja.has(e.code)}const Na=new Set([Oa,ka,Aa]),Pa=Object.freeze;function Fa(e){let{fromState:t,toDeactivate:n,toActivate:r,intersection:i}=e;Pa(n),Pa(r);let a={phase:`activating`,reason:`success`,segments:Pa({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),Pa(a)}function Ia(e,t){let{toState:n,fromState:r,toDeactivate:i,toActivate:a}=t;if(n.name!==T.UNKNOWN_ROUTE&&!e.hasRoute(n.name)){let i=j(new O(N.ROUTE_NOT_FOUND,{routeName:n.name}));throw e.sendTransitionFail(r,i,t),i}let o=t,s={...n,transition:Fa(t)},c=Pa(s);t.toState=c;let l=e.canCommitTransition(o);if(!l)throw j(new O(N.TRANSITION_CANCELLED));for(let n of i)!a.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n,l);return e.sendTransitionDone(o),c}const La=Object.entries;function Ra(e){return e instanceof O&&e.code===N.TRANSITION_CANCELLED}function za(e){return Ra(e)?e:j(new O(N.TRANSITION_CANCELLED,{reason:e}))}function Ba(e,t,n,r){Ra(t)?e.cancelIfInFlight(r,t):e.isTransitioning()&&e.sendTransitionFail(n,t,r)}function Va(e,t,n){if(fe(e)&&Ua(e,t,n),e instanceof DOMException&&e.name===`AbortError`)throw j(new O(N.TRANSITION_CANCELLED));if(Ra(e))throw e;Ua(e,t,n)}function Ha(e){return fe(e)?Wa(e,N.CANNOT_DEACTIVATE):e}function Ua(e,t,n){throw e instanceof O?Wa(e,t):j(new O(t,Ka(e,n)))}function Wa(e,t){let{code:n,message:r,...i}=e.toJSON(),a=new O(n,{...i,message:r});return a.setCode(t),a.stack=e.stack??``,j(a)}const Ga=new Set([`code`,`segment`,`path`,`then`]);function Ka(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 La(e))n!==`__proto__`&&!Ga.has(n)&&C(t,n,r);return{...n,...t}}return n}async function qa(e,t,n,r){let i;try{i=await e}catch(e){Va(e,t,n);return}if(i!==!0)throw i!==!1&&r(n,i),j(new O(t,{segment:n}))}function Ja(e,t,n,r,i,a,o,s,c,l,u){if(!c())throw j(new O(N.TRANSITION_CANCELLED));if(e===1){let n=l();return n===void 0?void 0:{phase:e,index:t+1,pending:n}}let d=n[t],f=r.get(d);if(!f)return;let p;try{p=f(a,o,s)}catch(e){Va(e,i,d)}if(p!==!0){if(p!==!1){let n=Ya(p,i,d);if(n!==void 0)return{phase:e,index:t+1,pending:n};u(d,p)}throw j(new O(i,{segment:d}))}}function Ya(e,t,n){let r;try{r=e?.then}catch(e){Va(e,t,n)}if(typeof r==`function`)return new Promise((t,n)=>{Reflect.apply(r,e,[t,n])})}function Xa(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=e===1,h=e===0;if(!m&&!(h?o:s))return;let g=h?i:a,_=m?1:g.length,v=h?n:r,y=h?N.CANNOT_DEACTIVATE:N.CANNOT_ACTIVATE;for(let n=t;n<_;n++){let t=Ja(e,n,g,v,y,c,l,u,d,f,p);if(t!==void 0)return t}}function Za(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let m=f;m<=2;m++){let h=Xa(m,m===f?p:0,e,t,n,r,i,a,o,s,c,l,u,d);if(h!==void 0)return h}}async function Qa(e,t,n,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 qa(p.pending,e?N.CANNOT_DEACTIVATE:N.CANNOT_ACTIVATE,(e?r:i)[p.index-1],f)}p=Za(t,n,r,i,a,o,s,c,l,u,d,f,p.phase,p.index)}}function $a(e,t,n,r,i,a,o,s,c,l,u,d){let f=Za(e,t,n,r,i,a,o,s,c,l,u,d,0,0);return f===void 0?void 0:Qa(f,e,t,n,r,i,a,o,s,c,l,u,d)}const eo=Object.freeze,to=Object.freeze([]),no=new Map;function ro(e,t){return t?eo({...e,replace:!0}):e}function io(e,t,n,r){return!!e&&!t&&!n&&e.path===r.path}function ao(e,t){if(e.size===0)return!1;for(let n of t)if(e.has(n))return!0;return!1}function oo(e){let t=e.controller;if(t!==void 0)return t;let n=new AbortController;return e.cancelReason!==void 0&&(n.abort(e.cancelReason),_(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,n,r,i,a,o,s,c,l){go(e,a);let u=e.hasLeaveListeners()||e.hasPreCommitListeners(),d={toState:t,fromState:n,opts:r,suspendable:i!==void 0||u,forceDeactivate:l,toDeactivate:to,toActivate:to,intersection:``,canDeactivateFunctions:no,canActivateFunctions:no,shouldDeactivate:!1,shouldActivate:!1,hasGuards:!1,controller:void 0,cancelReason:void 0,detachExternalBridge:void 0,externalSignal:i,reload:o,replace:s,redirected:c};if(!e.startTransition(d))throw j(new O(N.TRANSITION_CANCELLED));return d}function lo(e,t){return e.sendLeaveApprove(t),Ia(e,t)}function uo(e,t){let[n,r]=e.getLifecycleFunctions(),{toDeactivate:i,toActivate:a,intersection:o}=_a(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!==T.UNKNOWN_ROUTE&&a.length>0,t.hasGuards=t.shouldDeactivate&&ao(n,i)||t.shouldActivate&&ao(r,a)}function fo(e,t,n){let r,i;try{let a=ce(n),o=a?.aborted===!0?a:void 0;n=ue(n),r=e.getState();let s=le(n,`reload`),c=le(n,`force`),l=le(n,`replace`),u=le(n,`redirected`),d=le(n,`forceDeactivate`)===!0,f=r?.name===T.UNKNOWN_ROUTE&&!l,p=f||l;if(n=ro(n,f),io(r,s,c,t))return e.emitTransitionError(t,r,Ea),ka;let m=co(e,t,r,n,a,o,s,p,u,d);i=m;let h=m.externalSignal;if(h?.aborted===!0&&e.cancelNavigation(h.reason),uo(e,m),so(e,m),!m.hasGuards&&!m.suspendable)return lo(e,m);let{canDeactivateFunctions:g,canActivateFunctions:_,toDeactivate:v,toActivate:y,shouldDeactivate:b,shouldActivate:x,hasGuards:S}=m,ee=t;if(!S){let t=ho(e,m);if(t!==void 0)return t}if(S){let n=oo(m),i=()=>!n.signal.aborted,a=n.signal,o=$a(g,_,v,y,b,x,t,r,a,i,()=>{if(e.sendLeaveApprove(m),e.hasLeaveListeners())return e.awaitLeaveListeners(ee,r,a)},e.warnNonBooleanGuard);if(o!==void 0)return po(e,o,m,n);if(!i())throw j(new O(N.TRANSITION_CANCELLED))}return Ia(e,m)}catch(t){let n=mo(e,t,{nav:i,fromState:r});return _(n),Promise.reject(n)}}async function po(e,t,n,r){let i=()=>!r.signal.aborted,a=n.externalSignal,o,s=!1,c,l=new Promise(e=>{r.signal.aborted?e():(o=()=>{e()},r.signal.addEventListener(`abort`,o,{once:!0}))});t.catch(()=>{});try{if(a?.aborted)throw j(new O(N.TRANSITION_CANCELLED,{reason:a.reason}));if(await Promise.race([t,l]),!i())throw j(new O(N.TRANSITION_CANCELLED));let r=Ia(e,n);return s=!0,r}catch(t){let r=i()?t:za(t);throw c=r,Ba(e,r,n.fromState,n),_(r),r}finally{o&&r.signal.removeEventListener(`abort`,o),s||(r.abort(c),_(r.signal.reason))}}function mo(e,t,n){let{nav:r}=n;if(e.dispatchAbort(r?.controller,t),r!==void 0){let i=r.cancelReason===void 0?t:za(t);return Ba(e,i,n.fromState,r),i}return t}function ho(e,t){let{toState:n,fromState:r}=t;if(e.hasLeaveListeners()&&oo(t),e.sendLeaveApprove(t),e.hasLeaveListeners()){let i=oo(t),a=e.awaitLeaveListeners(n,r,i.signal);return a===void 0?void 0:po(e,a,t,i)}}function go(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 j(new O(N.TRANSITION_CANCELLED,{reason:t.reason}))}const _o=Object.freeze,vo=y(`router`,`navigateToNotFound`),yo=Object.freeze([T.UNKNOWN_ROUTE]),bo=Object.freeze({replace:!0});function xo(e,t,n){go(e,void 0);let r=e.getState(),i=r?J(r.name).toReversed():[];_o(i);let a={deactivated:i,activated:yo,intersection:``};_o(a);let o={phase:`activating`,...r&&{from:r.name},reason:`success`,replace:!0,segments:a};_o(o);let s={name:T.UNKNOWN_ROUTE,params:w,search:S,path:t,transition:o,context:{}};if(_o(s),n&&r!==void 0&&!e.canDeactivateCurrent(i,s,r)){let n=vo.code(N.CANNOT_DEACTIVATE,{path:t})`a canDeactivate guard on "${r.name}" refused to leave for ${t}`;throw e.emitTransitionError(void 0,r,n),n}return e.systemCommit(s,r,bo)}function So(e,t){return xo(e,t,!0)}function Co(e,t){return xo(e,t,!1)}const wo=y(`router`,`navigateToState`),To=y(`router`,`navigateToDefault`);var Eo=class{#e;#t;#n=0;#r=0;setDependencies(e){this.#e=e,this.#t=t=>{Ma(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 So(this.#e,e)}finally{this.#r--}}isCommittingNotFound(){return this.#r>0}revalidateToNotFound(e){return Co(this.#e,e)}isPreparing(){return this.#n>0}#i(e){return e instanceof Promise&&!Na.has(e)&&e.catch(this.#t),e}#a(e,t,n,r){let i=this.#e;if(!i.canNavigate())return i.isStarting()?Aa:Oa;let a;this.#n++;try{a=i.buildNavigateState(e,t,n)}catch(e){return Promise.reject(e)}finally{this.#n--}if(!a){let t=j(new O(N.ROUTE_NOT_FOUND,{routeName:e}));return i.emitTransitionError(void 0,i.getState(),t),Promise.reject(t)}return fo(this.#e,a,r)}#o(e,t){let n=this.#e;if(!n.canNavigate())return n.isStarting()?Aa:Oa;let r=e.name;if(r!==T.UNKNOWN_ROUTE&&!n.hasRoute(r)){let e=j(new O(N.ROUTE_NOT_FOUND,{routeName:r}));return n.emitTransitionError(void 0,n.getState(),e),Promise.reject(e)}let i=h(e.params,n.getQueryParams(r));if(i!==void 0){let e=wo.code(N.WRONG_CHANNEL,{routeName:r})`${g(r,i,"`state.params`")}`;return n.emitTransitionError(void 0,n.getState(),e),Promise.reject(e)}let a;try{a=this.#s(e,r)}catch(e){return Promise.reject(e)}return fo(this.#e,a,t)}#s(e,t){let n={name:t,params:he(e.params,w),search:he(e.search,S),path:e.path,context:{...e.context},transition:ee};return ae(n)}#c(e){let t=this.#e;if(!t.getOptions().defaultRoute)return Promise.reject(To.code(N.ROUTE_NOT_FOUND)`no defaultRoute is configured — pass one to createRouter, or navigate to a route by name`);let n,r,i;this.#n++;try{({route:n,params:r,search:i}=t.resolveDefault())}catch(e){return Promise.reject(e)}finally{this.#n--}return n?typeof n==`string`?this.#a(n,r,i,e):Promise.reject(To.code(N.ROUTE_NOT_FOUND)`defaultRoute resolved to ${typeof n}, which cannot name a route`):Promise.reject(To.code(N.ROUTE_NOT_FOUND)`defaultRoute resolved to an empty name`)}};const Do={},Oo=y(`router`,`start`),ko=Object.freeze({replace:!0});function Ao(e){return e instanceof O&&e.code===N.ROUTE_NOT_FOUND}var jo=class{#e;setDependencies(e){this.#e=e}async start(e){let t=this.#e;if(t.isIdle())throw j(new O(N.TRANSITION_CANCELLED));let n=t.getOptions();if(typeof e!=`string`)throw Oo.type`path must be a string, got ${typeof e}`;let r=t.getRootPath(),i=t.matchPath(e);if(!i&&!n.allowNotFound){let t=new O(N.ROUTE_NOT_FOUND,{path:e});throw j(t)}if(t.completeStart(),i!==void 0&&t.getRootPath()!==r&&(i=t.matchPath(e),!i&&!n.allowNotFound))throw j(new O(N.ROUTE_NOT_FOUND,{path:e}));if(i)try{return await t.navigateToState(i,ko)}catch(r){if(!n.allowNotFound||!Ao(r))throw r;return t.navigateToNotFound(e)}return t.navigateToNotFound(e)}};const Mo={},No=Object.create,Po=Object.entries,Fo=Object.hasOwn,Io=Object.values,Lo=new WeakMap;function Ro(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 E.plain`transitions["${e}"]["${t}"].when is not a function`;if(i!==void 0&&typeof i!=`function`)throw E.plain`transitions["${e}"]["${t}"].update is not a function`;return{target:n.target,when:r,update:i}}function zo(e){let t=Lo.get(e);if(t!==void 0)return t;let n=e,r=No(null);for(let[e,t]of Po(n)){let n=No(null);for(let[r,i]of Po(t))i!==void 0&&(n[r]=Ro(e,r,i));r[e]=n}for(let e of Io(r))for(let t of Io(e))if(t!==void 0&&r[t.target]===void 0)throw E.plain`state "${t.target}" is not declared in config.transitions`;return Lo.set(e,r),r}var Bo=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=zo(e.transitions),this.#a[t]===void 0)throw E.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 E.plain`state "${e}" is not declared in config.transitions`;if(!Fo(r,t))throw E.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 X={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},Z={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 Vo(){return{inflight:void 0,current:void 0,previous:void 0}}const Ho=(e,t)=>t?.nav===void 0||t.nav===e.inflight,Uo=(e,t)=>t!==void 0&&t===e.inflight&&t.externalSignal?.aborted!==!0,Wo=(e,t)=>{e.previous=e.current,e.current=ae(t)},Go=(e,t)=>{Wo(e,t.toState),e.inflight=void 0},Ko=(e,t)=>{Wo(e,t.toState)},qo=e=>{e.previous=e.current,e.current=void 0},Jo=e=>{e.current=void 0,e.previous=void 0,e.inflight=void 0},Yo=(e,t)=>{e.inflight=t},Xo={[X.IDLE]:{[Z.START]:X.STARTING,[Z.DISPOSE]:{target:X.DISPOSED,update:Jo}},[X.STARTING]:{[Z.STARTED]:X.READY,[Z.FAIL]:X.IDLE,[Z.STOP]:{target:X.IDLE,update:qo},[Z.DISPOSE]:{target:X.DISPOSED,update:Jo}},[X.READY]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Yo},[Z.SYSTEM_COMMIT]:{target:X.READY,update:Ko},[Z.STOP]:{target:X.IDLE,update:qo},[Z.DISPOSE]:{target:X.DISPOSED,update:Jo}},[X.TRANSITION_STARTED]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Yo},[Z.LEAVE_APPROVE]:X.LEAVE_APPROVED,[Z.CANCEL]:X.READY,[Z.FAIL]:{target:X.READY,when:Ho},[Z.DISPOSE]:{target:X.DISPOSED,update:Jo}},[X.LEAVE_APPROVED]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Yo},[Z.COMPLETE]:{target:X.READY,when:Uo,update:Go},[Z.CANCEL]:X.READY,[Z.FAIL]:{target:X.READY,when:Ho},[Z.DISPOSE]:{target:X.DISPOSED,update:Jo}},[X.DISPOSED]:{}};function Zo(){return new Bo({initial:X.IDLE,context:Vo(),transitions:Xo})}const Qo=y(`router`,`subscribe`),$o=y(`router`,`subscribeChanges`),es=y(`router`,`subscribeDiagnostic`),ts=y(`router`,`subscribeLeave`),ns=Object.freeze,rs=`TREE_CHANGED`;function is(e){return e instanceof Error?e:Error(String(e))}function as(e,t,n){return new Promise((r,i)=>{let a=()=>{let e=n.reason;i(e instanceof O&&e.code===N.TRANSITION_CANCELLED?e:j(new O(N.TRANSITION_CANCELLED,{reason:e})))};n.aborted?(Promise.allSettled(e),a()):(n.addEventListener(`abort`,a,{once:!0}),Promise.allSettled(e).then(e=>{if(n.removeEventListener(`abort`,a),n.aborted)return;if(t!==void 0){i(is(Ha(t)));return}let o=e.find(e=>e.status===`rejected`);o===void 0?r():i(is(Ha(o.reason)))}))})}function os(e,t,n){return e.addEventListener(`abort`,t,{once:!0}),()=>{n(),e.removeEventListener(`abort`,t)}}var ss=class{#e;#t;#n=[];#r=0;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#o()}static validateSubscribeListener(e){if(typeof e!=`function`)throw Qo.type`Expected a function. For Observable pattern use observable(router) from @real-router/rx`}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw ts.type`Expected a function`}emitRouterStart(){this.#r++;try{this.#t.emit(v.ROUTER_START)}finally{this.#r--}}emitRouterStop(){this.#t.emit(v.ROUTER_STOP)}emitTransitionStart(e,t,n){this.#r++;try{this.#t.emit(v.TRANSITION_START,e,t)}finally{this.#r--}}emitTransitionSuccess(e,t,n){this.#r++;try{this.#t.emit(v.TRANSITION_SUCCESS,e,t,n)}finally{this.#r--}}emitTransitionError(e,t,n){this.#r++;try{this.#t.emit(v.TRANSITION_ERROR,e,t,n)}finally{this.#r--}}emitTransitionCancel(e,t){this.#r++;try{this.#t.emit(v.TRANSITION_CANCEL,e,t)}finally{this.#r--}}emitTransitionLeaveApprove(e,t){this.#r++;try{this.#t.emit(v.TRANSITION_LEAVE_APPROVE,e,t)}finally{this.#r--}}dispatchAbort(e,t){if(e!==void 0){this.#r++;try{e.abort(t),_(e.signal.reason)}finally{this.#r--}}}isProcessing(){return this.#r>0}emitTreeChanged(e){this.#t.emit(rs,e)}isEmittingTreeChanged(){return this.#t.isDispatching(rs)}subscribeTreeChanged(e){if(this.isDisposed())throw $o.code(N.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(rs,t=>e(t))}emitDiagnostic(e,...t){this.#t.emit(e,...t)}subscribeDiagnostic(e,t){if(this.isDisposed())throw es.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(rs)}diagnosticListenerCount(e){return this.#t.listenerCount(e)}sendStart(){this.#e.send(Z.START)}sendStop(){this.#e.send(Z.STOP)}sendStopForDispose(){this.#r++;try{this.#e.send(Z.STOP)}finally{this.#r--}}sendDispose(){this.#e.send(Z.DISPOSE)}sendStarted(){this.#e.send(Z.STARTED)}sendNavigate(e){return this.#e.send(Z.NAVIGATE,e)===X.TRANSITION_STARTED}canCommitTransition(e){return this.#e.canSend(Z.COMPLETE,e)}sendComplete(e){this.#e.send(Z.COMPLETE,e)}sendLeaveApprove(e){this.#e.send(Z.LEAVE_APPROVE,e)}sendFail(e,t,n){this.#e.send(Z.FAIL,{nav:n,fromState:e,error:t})}sendCancel(e,t){this.#e.send(Z.CANCEL,{fromState:e,reason:t})}systemCommit(e,t){let{toState:n}=e,r=n.transition,i={name:t,params:he(n.params,w),search:he(n.search,S),path:n.path,context:{...n.context},...r!=null&&{transition:_e(r)}};if(!this.#e.canSend(Z.SYSTEM_COMMIT))throw j(this.#a());return this.#e.send(Z.SYSTEM_COMMIT,{...e,toState:i}),i}canBeginTransition(){return this.#e.canSend(Z.NAVIGATE)}canStart(){return this.#e.canSend(Z.START)}canCancel(){return this.#e.canSend(Z.CANCEL)}isActive(){let e=this.#e.getState();return e!==X.IDLE&&e!==X.DISPOSED}isDisposed(){return this.#e.getState()===X.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===X.TRANSITION_STARTED||e===X.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===X.LEAVE_APPROVED}isReady(){return this.#e.getState()===X.READY}isStarting(){return this.#e.getState()===X.STARTING}isIdle(){return this.#e.getState()===X.IDLE}addEventListener(e,t,n){return this.#i(e,n),this.#t.on(e,t)}subscribe(e){if(this.isDisposed()||(this.#i(v.TRANSITION_SUCCESS,`subscribe`),this.isDisposed()))throw Qo.code(N.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(v.TRANSITION_SUCCESS,(t,n)=>e({route:t,previousRoute:n}))}subscribeLeave(e){if(this.isDisposed())throw ts.code(N.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;this.#n.push(e);let t=!1;return()=>{if(t)return;t=!0;let n=this.#n.indexOf(e);n!==-1&&this.#n.splice(n,1)}}hasLeaveListeners(){return this.#n.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=ns({route:t,nextRoute:e,signal:n}),i,a,o=[...this.#n];this.#r++;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.#r--}if(i===void 0){if(a!==void 0)throw is(Ha(a))}else return as(i,a,n)}clearAll(){this.#t.clearAll(),this.#n.length=0}setLimits(e){this.#t.setLimits(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 Mo;let n=os(t,()=>{this.sendCancelIfPossible(this.#e.getContext().current,t.reason)},()=>{e.detachExternalBridge=void 0});return e.cancelReason===void 0?e.detachExternalBridge=n:n(),Mo}#i(e,t){this.emitDiagnostic(z.LISTENER_COUNT,this.#t.listenerCount(e)+1,e,t)}#a(){if(this.isDisposed())return new O(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 O(N.ROUTER_NOT_STARTED,{message:e})}#o(){let e=this.#e;e.on(X.STARTING,Z.STARTED,()=>{this.emitRouterStart()}),e.on(X.READY,Z.STOP,()=>{this.emitRouterStop()});let t=e=>{let t=e.externalSignal!==void 0&&(this.hasLeaveListeners()||this.hasPreCommitListeners())?this.bridgeExternalSignal(e):Mo;this.emitTransitionStart(e.toState,e.fromState,t)};e.on(X.READY,Z.NAVIGATE,t),e.on(X.TRANSITION_STARTED,Z.NAVIGATE,t),e.on(X.LEAVE_APPROVED,Z.NAVIGATE,t),e.on(X.TRANSITION_STARTED,Z.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(X.LEAVE_APPROVED,Z.COMPLETE,e=>{e.detachExternalBridge?.(),this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let n=e=>{let{fromState:t,reason:n}=e,r=this.#e.getContext().inflight,i=n??j(new O(N.TRANSITION_CANCELLED));r.cancelReason=i,this.dispatchAbort(r.controller,i),r.detachExternalBridge?.(),this.emitTransitionCancel(r.toState,t)};e.on(X.TRANSITION_STARTED,Z.CANCEL,n),e.on(X.LEAVE_APPROVED,Z.CANCEL,n),e.on(X.READY,Z.SYSTEM_COMMIT,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let r=e=>{let t=this.#e.getContext().inflight;t?.detachExternalBridge?.(),this.emitTransitionError(t?.toState,e.fromState,e.error)};e.on(X.LEAVE_APPROVED,Z.FAIL,r),e.on(X.TRANSITION_STARTED,Z.FAIL,r),e.on(X.STARTING,Z.FAIL,e=>{this.emitTransitionError(void 0,e.fromState,e.error)})}};const cs=Object.freeze;function ls(e){return ds(e)&&!Object.isFrozen(e)&&e!==rr.defaultParams&&e!==rr.defaultSearch}function us(e){let{defaultParams:t,defaultSearch:n}=e;return cs({...ls(t)&&{defaultParams:new WeakRef(t)},...ls(n)&&{defaultSearch:new WeakRef(n)}})}function ds(e){return typeof e==`object`&&!!e}function fs(e){let t={...e};return e.limits!=null&&(t.limits=k(`limits`,e.limits)),ds(e.defaultParams)&&(t.defaultParams=k(`defaultParams`,e.defaultParams)),ds(e.defaultSearch)&&(t.defaultSearch=k(`defaultSearch`,e.defaultSearch)),t}const ps=Object.keys,ms=Object.freeze;function hs(e={}){let t={...de,...e};return ms({maxDependencies:Number(t.maxDependencies),maxPlugins:Number(t.maxPlugins),maxListeners:Number(t.maxListeners),warnListeners:Number(t.warnListeners),maxLifecycleHandlers:Number(t.maxLifecycleHandlers)})}function gs(e){return e==null?void 0:ms(ps(e))}const _s=y(`router`),vs=Object.freeze,ys=Object.freeze({});function bs(e,t){let n;try{n=t[e]}catch(t){throw _s.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 _s.type({cause:t})`Invalid "queryParams.${e}": its value cannot be converted to a string.`}}}function xs(e){if(e==null)return`default`;try{return String(e)}catch(e){throw _s.type({cause:e})`Invalid "urlParamsEncoding": coercing it threw.`}}function Ss(e){if(!e)return ys;let t=bs(`arrayFormat`,e),n=bs(`booleanFormat`,e),r=bs(`nullFormat`,e),i=bs(`numberFormat`,e);return vs({...t!==void 0&&{arrayFormat:t},...n!==void 0&&{booleanFormat:n},...r!==void 0&&{nullFormat:r},...i!==void 0&&{numberFormat:i}})}function Cs(e){return vs({strictTrailingSlash:e.trailingSlash===`strict`,caseSensitive:e.caseSensitive,strictQueryParams:e.queryParamsMode===`strict`,urlParamsEncoding:xs(e.urlParamsEncoding),queryParams:Ss(e.queryParams)})}const ws=new O(N.ROUTER_ALREADY_STARTED);Object.freeze(ws);const Ts=y(`router`),Es={maxListeners:0,warnListeners:0};var Ds=class{#e=new Map;#t=new Set;#n=null;#r=Es;#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 Ts.plain`Duplicate listener for "${e}"`;let{maxListeners:i,warnListeners:a}=this.#r;if(i!==0&&r>=i)throw Ts.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 Os=Object.freeze({log:0,warn:1,error:2}),ks=Object.freeze({all:0,"warn-error":1,"error-only":2,none:3}),As=Object.hasOwn;var js=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=Jn(e),n=t.level;n!==void 0&&(this.#e.level=n,this.#t=ks[n]),As(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=Os[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 Ms(e){let t=t=>$n(e.dependenciesStore,t),n=Ns(e.router,t),r=Rs(e);Ps(e),Fs(e,n),Is(e,r,t),Ls(e,n),zs(e,r,t),Bs(e),Vs(e,r)}function Ns(e,t){return n=>n(e,t)}function Ps(e){e.eventBus.setLimits({maxListeners:e.limits.maxListeners,warnListeners:e.limits.warnListeners})}function Fs(e,t){let n={logger:L(e.router).logger,compileFactory:t,runChecks:(t,...n)=>{V(L(e.router).checks,t,...n)},hasChecks:t=>mn(L(e.router).checks,t),emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)},diagnosticListenerCount:t=>e.eventBus.diagnosticListenerCount(t)};e.routeLifecycle.setDependencies(n)}function Is(e,t,n){let r={logger:L(e.router).logger,checks:L(e.router).checks,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:n};e.routes.setDependencies(r),e.routes.setLifecycleNamespace(e.routeLifecycle)}function Ls(e,t){let n={logger:L(e.router).logger,addEventListener:(t,n)=>e.eventBus.addEventListener(t,n,`usePlugin`),canNavigate:()=>e.eventBus.canBeginTransition(),compileFactory:t,isDisposed:()=>e.eventBus.isDisposed(),runChecks:(t,...n)=>{V(L(e.router).checks,t,...n)},emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)}};e.plugins.setDependencies(n)}function Rs(e){let t=L(e.router),n=e.routes.getStore(),r=(t,n)=>{e.eventBus.emitDiagnostic(z.UNDECLARED_PARAM_KEY,t,n)},i=(t,n)=>{e.eventBus.emitDiagnostic(z.DROPPED_QUERY_KEY,t,n)},a=t=>{let r=e.routes.getUrlParams(t),i=n.tree.paramMeta.urlParams;return i.length===0?r:[...i,...r]},o=t=>{let{name:r}=t,i={encode:n.config.encoders[r],decode:n.config.decoders[r]};(i.encode!==void 0||i.decode!==void 0)&&e.eventBus.emitDiagnostic(z.CODEC_ROUND_TRIP,t,i,a(r))};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)?a(t):void 0,admitsUndeclaredQuery:()=>sr(e.options.get().queryParamsMode)===`loose`,get reportDroppedQueryKey(){return e.eventBus.diagnosticListenerCount(z.DROPPED_QUERY_KEY)>0?i:void 0},get reportUndeclaredParamKey(){return e.eventBus.diagnosticListenerCount(z.UNDECLARED_PARAM_KEY)>0?r:void 0},get reportCodecRoundTrip(){return e.eventBus.diagnosticListenerCount(z.CODEC_ROUND_TRIP)>0?o:void 0}}}function zs(t,n,r){let i=e=>r(e),a={logger:L(t.router).logger,getOptions:()=>t.options.get(),hasRoute:e=>t.routes.hasRoute(e),getQueryParams:e=>t.routes.getQueryParams(e),getMetaForState:e=>t.routes.getMetaForState(e),getState:()=>t.state.get(),buildNavigateState:(r,i,a)=>{V(L(t.router).checks,B[`navigate:state`],r,i);let o=U(n,r,i,a,{diagnoseUndeclared:!0});if(t.routes.getMetaForState(o.name)===void 0)return;e(`navigate`,o.name,o.path,n.queryNames(o.name));let s=vr(o,hr(o,n));return n.reportCodecRoundTrip?.(s),s},resolveDefault:()=>{let e=t.options.get(),n=L(t.router),r=fr(e.defaultRoute,i),a=fr(e.defaultParams,i),o=fr(e.defaultSearch,i);return typeof e.defaultRoute==`function`&&V(n.checks,B[`navigateToDefault:route`],r),{route:r,params:a,search:o}},startTransition:e=>t.eventBus.sendNavigate(e),systemCommit:(e,n,r)=>t.eventBus.systemCommit({toState:e,fromState:n,opts:r},e.name),cancelNavigation:e=>{t.eventBus.sendCancelIfPossible(t.state.get(),e)},cancelIfInFlight:(e,n)=>{t.eventBus.sendCancelIfInFlight(e,t.state.get(),n)},dispatchAbort:(e,n)=>{t.eventBus.dispatchAbort(e,n)},bridgeExternalSignal:e=>{t.eventBus.bridgeExternalSignal(e)},canCommitTransition:e=>t.eventBus.canCommitTransition(e)?Do:void 0,sendTransitionDone:e=>{t.eventBus.sendComplete(e)},sendTransitionFail:(e,n,r)=>{t.eventBus.sendFail(e,n,r)},emitTransitionError:(e,n,r)=>{t.eventBus.emitTransitionError(e,n,r)},sendLeaveApprove:e=>{t.eventBus.sendLeaveApprove(e)},canNavigate:()=>t.eventBus.canBeginTransition(),isStarting:()=>t.eventBus.isStarting(),getLifecycleFunctions:()=>t.routeLifecycle.getFunctions(),warnNonBooleanGuard:(e,n)=>{t.eventBus.emitDiagnostic(z.GUARD_NON_BOOLEAN,e,n)},canDeactivateCurrent:(e,n,r)=>t.routeLifecycle.canNavigateTo(e,[],n,r,`navigateToNotFound`),isTransitioning:()=>t.eventBus.isTransitioning(),clearCanDeactivate:(e,n)=>{t.routeLifecycle.clearCanDeactivate(e,`external`)},hasLeaveListeners:()=>t.eventBus.hasLeaveListeners(),hasPreCommitListeners:()=>t.eventBus.hasPreCommitListeners(),awaitLeaveListeners:(e,n,r)=>t.eventBus.awaitLeaveListeners(e,n,r)};t.navigation.setDependencies(a)}function Bs(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 Vs(e,t){e.state.setDependencies({port:()=>t,getUrlParams:t=>e.routes.getUrlParams(t)})}const Hs=y(`router`,`navigateToNotFound`),Us=y(`router`,`start`),Q=y(`router`);var Ws=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;constructor(t=[],n={},r={}){let{logger:a,...o}=n,s=new js(a?Jn(a):void 0);this.#f=s,this.#p=e=>{Ma(e)||s.error(`router.start`,`Unexpected start error`,e)},dr.validateOptionsIsObject(n),Ln(r);let c=Vn(t),l=fs(o);this.#r=us(o),this.#e=new dr(l),this.#t=hs(l.limits),this.#n=gs(l.limits);let u={emit:(e,...t)=>{this.#d.emitDiagnostic(e,...t)},listenerCount:e=>this.#d.diagnosticListenerCount(e)};this.#i=nr(r,this.#t,u),this.#a=new br;let d={emit:e=>{this.#d.emitTreeChanged(e)},subscribe:e=>this.#d.subscribeTreeChanged(e),listenerCount:()=>this.#d.treeChangedListenerCount(),isEmitting:()=>this.#d.isEmittingTreeChanged()};this.#o=new Ca(c,Cs(this.#e.get()),s,d),this.#s=new Lr,this.#c=new kr,this.#l=new Eo,this.#u=new jo;let f=Zo();this.#a.setContext(f.getContext());let p=new Ds({onListenerError:(e,t)=>{s.error(`router`,`Error in listener for ${e}:`,t)},onListenerWarn:(e,t)=>{s.warn(`router`,`Event "${e}" has ${t} listeners — possible memory leak`)}});this.#d=new ss({routerFSM:f,emitter:p});let m=new Map,h=new Map,g=e=>{let t=e.params,n=e.search;return{name:e.name,params:t==null?t:M(t),search:n==null?n:M(n)}},_=gn(dn.forwardState,(e,t,n)=>this.#o.forwardState(e,t,n),m,g,Gs),v=((e,t,n)=>{let r=_(e,t,n),a=r.name,o=r.params;i(`forwardState`,a,o,this.#o.getQueryParams(a),()=>a===e?"the `params` bag leaving the forwardState chain":`the \`params\` bag leaving the forwardState chain (forwarded here from "${e}")`);let s=r.search,c=s==null;return{name:a,params:M(o??w),search:c?s:M(s)}}),y=gn(dn.forwardState,(e,t,n)=>({name:e,params:t,search:n}),m,g,Gs);this.#h=(e,t,n)=>{let r=y(e,t,n),i=r.params,a=r.search;return this.#o.buildPathFromIntent(r.name,i??w,a)},this.#m=hn(dn.start,e=>this.#u.start(e),m);let b={logger:s,makeState:(e,t,n,r)=>{cn(b,`makeState`,e,t);let i=A(t);return V(b.checks,B[`makeState:state`],e,i,n,r),this.#a.makeState(e,i,n,r)},getMetaForState:e=>this.#o.getMetaForState(e),getDeclaredQueryNames:e=>this.#o.getQueryParams(e),forwardState:v,buildStateResolved:(e,t)=>this.#o.buildStateResolved(e,t),buildPathResolved:(e,t,n)=>{let r=A(t);return V(b.checks,B[`buildPathResolved:entry`],t,n),V(b.checks,B[`buildPathResolved:params`],r),this.#o.buildPathFromIntent(e,r??w,n)},port:()=>this.#o.getPort(),matchPath:(e,t)=>(V(b.checks,B[`matchPath:entry`],e),this.#o.matchPath(e,t??this.#e.get())),getOptions:()=>this.#e.get(),getAdoptedOrigins:()=>this.#r,addEventListener:(e,t)=>{R(b.isDisposed),kn(e),An(t);let n=this.#d.addEventListener(e,t,`addEventListener`);return R(b.isDisposed),n},subscribeDiagnostic:(e,t)=>this.#d.subscribeDiagnostic(e,t),emitTransitionError:e=>{this.#d.emitTransitionError(void 0,this.#a.get(),e)},navigateToNotFound:e=>{if(this.#y(),e!==void 0&&typeof e!=`string`)throw Hs.type`path must be a string, got ${typeof e}`;return this.#l.navigateToNotFound(e)},revalidateToNotFound:e=>(this.#b(),this.#l.revalidateToNotFound(e)),start:e=>this.start(e),navigateToState:(t,n)=>(R(b.isDisposed),V(h,B[`navigateToState:entry`],t,n),this.#y(),e.#g(this.#l.navigateToState(t,n??te))),interceptors:m,checks:h,setRootPath:e=>{V(h,B[`setRootPath:entry`],e),this.#o.setRootPath(e)},getRootPath:()=>this.#o.getStore().rootPath,getTree:()=>this.#o.getStore().tree,isDisposed:()=>this.#d.isDisposed(),dependenciesGetStore:()=>this.#i,getCloneState:()=>({options:{...this.#e.get()},dependencies:tr(this.#i),pluginFactories:this.#c.getAll(),loggerConfig:s.getConfig(),limits:this.#t,limitKeys:this.#n}),routeGetStore:()=>this.#o.getStore(),getStateName:()=>this.#a.get()?.name,isTransitioning:()=>this.#d.isTransitioning(),systemCommit:(e,t,n)=>{this.#b();let r=e.name;if(r!==`@@router/UNKNOWN_ROUTE`&&!this.#o.hasRoute(r))throw j(new O(N.ROUTE_NOT_FOUND,{routeName:r}));return this.#d.systemCommit({toState:e,fromState:t,opts:n},r)},routerExtensions:[],contextClaimRecords:new Map};ln(this,b),Ms({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=L(this);return V(a.checks,B[`isActiveRoute:entry`],e,t,n,r,i),this.#d.diagnosticListenerCount(z.IS_ACTIVE_ROUTE)>0&&this.#d.emitDiagnostic(z.IS_ACTIVE_ROUTE,e,t),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=L(this);V(r.checks,B[`buildPath:entry`],e,t,n),this.#d.diagnosticListenerCount(z.BUILD_PATH)>0&&this.#d.emitDiagnostic(z.BUILD_PATH,e,t);let i=A(t);return V(r.checks,B[`buildPath:params`],i),this.#h(e,i??w,n)}getState(){return this.#a.get()}getPreviousState(){return this.#a.getPrevious()}areStatesEqual(e,t,n=!0){return V(L(this).checks,B[`areStatesEqual:entry`],e,t,n),this.#a.areStatesEqual(e,t,n)}shouldUpdateNode(e){return V(L(this).checks,B[`shouldUpdateNode:entry`],e),Ca.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=L(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(),er(this.#i),this.#S()}canNavigateTo(e,t,n){let r=L(this);V(r.checks,B[`canNavigateTo:entry`],e,t,n);let i;try{i=A(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(V(r.checks,B[`canNavigateTo:params`],i),!this.#o.hasRoute(e)||h(t,this.#o.getQueryParams(e))!==void 0)return!1;let a=this.#o.getPort(),o;try{o=U(a,e,i??w,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 s;try{s=vr(o,hr(o,a))}catch{return!1}let c=this.#a.get(),{toDeactivate:l,toActivate:u}=_a(s,c,e=>this.#o.getMetaForState(e));return this.#s.canNavigateTo(l,u,s,c,`canNavigateTo`)}usePlugin(...e){kr.validateNotDisposed(this.#d.isDisposed());let t=e.filter(Boolean);if(t.length===0)return()=>{};let{checks:n}=L(this);if(mn(n,B[`usePlugin:count`])&&V(n,B[`usePlugin:count`],this.#c.count(),new Set(t).size,this.#t.maxPlugins),mn(n,B[`usePlugin:entry`])){let e=this.#c.getAll();for(let r of t)V(n,B[`usePlugin:entry`],r,e)}return this.#c.use(...t)}subscribe(e){return ss.validateSubscribeListener(e),this.#d.subscribe(e)}subscribeLeave(e){return ss.validateSubscribeLeaveListener(e),this.#d.subscribeLeave(e)}isLeaveApproved(){return this.#d.isLeaveApproved()}navigate(t,n,r,i){this.#y();let a=L(this),o,s,c,l;typeof t==`object`&&t?(o=t.name,s=t.params,c=t.search,l=n??te):(o=t,s=n,c=r,l=i??te),cn(a,`navigate`,o,s),V(a.checks,B[`navigate:entry`],o,s,c,l);let u;try{u=A(s)}catch(e){return Promise.reject(e)}return V(a.checks,B[`navigate:params`],u),e.#g(this.#l.navigate(o,u??w,c,l))}navigateToDefault(t){this.#y();let n=L(this);return V(n.checks,B[`navigateToDefault:entry`],t),this.#d.emitDiagnostic(z.NAVIGATE_TO_DEFAULT),R(n.isDisposed),e.#g(this.#l.navigateToDefault(t??te))}navigateToNotFound(e){if(this.#y(),!this.#d.isActive())throw j(new O(N.ROUTER_NOT_STARTED));if(e!==void 0&&typeof e!=`string`)throw Hs.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 Hs.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(ws);this.#y(),V(L(this).checks,B[`start:entry`],e),this.#d.sendStart();let t;try{let n=this.#m(e);t=typeof n?.then==`function`?n:Promise.reject(Us.type`a \`start\` interceptor returned without calling next(). Every start interceptor must return \`next(path)\`.`)}catch(e){t=Promise.reject(e)}return t.then(e=>(this.#v(),e),e=>this.#x(e))}#v(){if(this.#d.isIdle())throw j(new O(N.TRANSITION_CANCELLED))}#y(){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(...)).`}#b(){this.#o.isRevalidating()||this.#y()}#x(e){throw this.#v(),this.#d.isReady()&&this.#a.get()===void 0?this.#d.sendStop():this.#d.isStarting()&&this.#d.sendFail(void 0,e),e}#S(){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 Gs(e,t,n){return[e,A(t),A(n)]}export{Qn as A,B,ni as C,er as D,U as E,Pn as F,cn as G,mn as H,jn as I,en as K,Vn as L,zn as M,Fn as N,$n as O,Mn as P,Bn as R,Xr as S,hr as T,V as U,L as V,R as W,xi as _,zi as a,Wr as b,Ri as c,Ii as d,Vi as f,Wi as g,bi as h,Gi as i,Nn as j,tr as k,Fi as l,qi as m,_a as n,Li as o,Hi as p,tn as q,Ci as r,Ni as s,Ws as t,Pi as u,li as v,vr as w,Zr as x,si as y,z};
2
+ //# sourceMappingURL=Router-CFnIWPT3.mjs.map