@real-router/core 0.173.1 → 0.173.2

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.
@@ -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 ee,F as x,M as te,N as ne,O as S,P as C,R as w,S as T,T as re,V as E,_ as ie,a as ae,b as D,c as oe,d as se,f as ce,g as le,h as O,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??={},S(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??={},S(r,a,o)):(i=!0,n?.(a));return i?De(r??x):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??=ee(),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)&&(S(r,n,t[n]),i=!0);if(n===`loose`)for(let n of zt(t))e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(S(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):(re(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):(re(r,a),o)}u=e.node,S(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 S(r,e.name,t.slice(n)),i.route;let a={},o=this.#v(i,t,n,a);return o?(re(r,a),o):(S(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&&S(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 ln(e){if(e())throw j(new D(N.ROUTER_DISPOSED,{message:`[router] this router is disposed — dispose() is terminal`}))}function un(e,t){an.set(e,t),Object.defineProperty(e,on,{value:!0})}function dn(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 fn={start:`start`,forwardState:`forwardState`},R={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`},z={"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`},pn=y(`router`),mn=()=>void 0;function B(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),mn))throw pn.type`Async checks are not supported: the check at "${t}" returned a thenable. A check refuses by throwing synchronously.`}function hn(e,t){return(e.get(t)?.length??0)>0}function gn(e,t,n){return((...r)=>{let i=n.get(e);return!i||i.length===0?t(...r):dn(i,t,r)})}function _n(e,t,n,r,i){return(a,o,s)=>{let c=n.get(e);return!c||c.length===0?t(a,o,s):dn(c,t,i(a,o,s),r)}}const vn=y(`router`,`addEventListener`),yn=y(`router`,`subscribeChanges`),bn=y(`router`,`addInterceptor`),xn=y(`router`,`addCheck`),Sn=y(`router`,`extendRouter`),V=y(`router`),Cn=Object.keys,wn=Object.values,Tn=Object.hasOwn,En=Object.getOwnPropertyDescriptor,Dn=Object.getPrototypeOf,On=Object,kn=new Set(wn(v));function An(e){if(!kn.has(e))throw vn.type`Invalid event name: ${String(e)}. Must be one of: ${[...kn].join(`, `)}`}function jn(e){if(typeof e!=`function`)throw vn.type`callback must be a function, got ${typeof e}`}function Mn(e){if(typeof e!=`function`)throw yn.type`Expected a function`}function Nn(e,t){if(typeof e!=`string`||!Tn(fn,e))throw bn.type`Invalid method: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Cn(fn).join(`, `)}`;if(typeof t!=`function`)throw bn.type`interceptor must be a function, got ${typeof t}`}function Pn(e,t){if(typeof e!=`string`||!Tn(z,e))throw xn.type`Invalid position: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Cn(z).join(`, `)}`;if(typeof t!=`function`)throw xn.type`check must be a function, got ${typeof t}`}function Fn(e,t){if(typeof e!=`string`)throw y(`router`,t).type`Route name must be a string, got ${typeof e}`}function In(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 Ln(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Dn(e);return t===null||t.constructor===On}function Rn(e){if(!Ln(e))throw V.type`dependencies must be a plain object`}function zn(e){return e===null?`null`:typeof e==`object`?`a non-plain object`:typeof e}function Bn(e){if(!Ln(e))throw Sn.type`extensions must be a plain object, got ${zn(e)}`}function Vn(e,t){Rn(e);let n=e,r=[];for(let e of Cn(n)){if(En(n,e)?.get)throw V.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 Hn(e){let t=[];for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw V.type`route must be a non-array object`;d(e,`addRoute`);let r={...e},i=r.children;i&&S(r,`children`,Hn(i)),t.push(r)}return t}const Un=new Set([`all`,`warn-error`,`error-only`,`none`]);function Wn(e){return typeof e==`string`&&Un.has(e)}function Gn(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function Kn(e){for(let t of Cn(e))if(![`level`,`callback`,`callbackIgnoresLevel`].includes(t))throw V.type`Unknown logger config property: "${t}"`}function qn(e){if(!Tn(e,`level`))return;let t=e.level;if(t!==void 0){if(!Wn(t))throw V.type`Invalid logger level: ${Gn(t)}. Expected: "all" | "warn-error" | "error-only" | "none"`;return t}}function Jn(e){if(!Tn(e,`callbackIgnoresLevel`))return;let t=e.callbackIgnoresLevel;if(t!==void 0){if(typeof t!=`boolean`)throw V.type`Logger callbackIgnoresLevel must be a boolean, got ${typeof t}`;return t}}function Yn(e){if(typeof e!=`object`||!e)throw V.type`Logger config must be an object`;let t=e;Kn(t);let n=ee(),r=qn(t);if(r!==void 0&&(n.level=r),Tn(t,`callback`)){let e=t.callback;if(e!==void 0&&typeof e!=`function`)throw V.type`Logger callback must be a function, got ${typeof e}`;n.callback=e}let i=Jn(t);return i!==void 0&&(n.callbackIgnoresLevel=i),n}const Xn=Object.create,Zn=Object.freeze,Qn=Object.defineProperty;function $n(e,t,n){e[t]=n}function er(e,t){return e.dependencies[t]}function tr(e){e.dependencies=Xn(null)}function nr(e){return ve({...e.dependencies})}function rr(e,t,n){let r=Xn(null),i=e,a=r;Vn(i,(e,t)=>{$n(a,e,t)});let o={dependencies:r,limits:t,diagnostics:Zn(n)};return Qn(o,`diagnostics`,{writable:!1,configurable:!1}),o}const ir={defaultRoute:``,defaultParams:{},defaultSearch:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:s,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0},ar=[`strict`,`never`,`always`,`preserve`],or=[`default`,`strict`,`loose`];function sr(e){return e!==void 0&&ar.includes(e)?e:ir.trailingSlash}function cr(e){return e!==void 0&&or.includes(e)?e:ir.queryParamsMode}const lr=y(`router`);function ur(e){if(!e||typeof e!=`object`||Array.isArray(e))throw lr.type`options must be a plain object`}const dr=Object.freeze;var fr=class{#e;constructor(e={}){this.#e=dr(ve({...ir,...e}))}static validateOptionsIsObject(e){ur(e)}get(){return this.#e}};function pr(e,t){return typeof e==`function`?e(t):e}const mr=Object.keys;function hr(e,t,n,r,i){let a=e.pathNames(t);if(a!==void 0)for(let e of mr(n))!r.includes(e)&&!a.includes(e)&&i(t,e)}function H(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,C),l=i?.diagnoseUndeclared===!0?e.reportUndeclaredParamKey:void 0;l&&hr(e,s,c,e.queryNames(s),l);let u=e.defaultParams(s),d=e.defaultSearch(s);if((o.search===void 0||o.search===x)&&u===void 0&&d===void 0)return{name:s,path:c,query:x};let f=e.queryNames(s),p=e.reportDroppedQueryKey,m=i?.resolveForward===!1?we(d,c,f):d,h=ge(o.search,x),g=ce(m,h);return{name:s,path:se(u,c),query:e.admitsUndeclaredQuery()?g:Oe(g,e.printedQueryNames(s),t=>{p!==void 0&&e.pathNames(s)!==void 0&&p(s,t)})}}function gr(e,t){return t.buildPath(e.name,e.path,e.query)}const _r=Object.freeze;function vr(e,t){let n={name:e.name,params:e.path,search:e.query,path:t,context:{},transition:te};return _r(n.params),n}function U(e,t){return oe(vr(e,t))}function yr(e,t){return vr(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=H(a,t,n??C,r,{resolveForward:!1});return e(`makeState`,o.name,o.path,a.queryNames(o.name)),U(o,i??gr(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)):ie(e.params,t.params)&&ie(e.search,t.search):!1}};const xr=Object.keys,Sr={[E.ROUTER_START]:v.ROUTER_START,[E.ROUTER_STOP]:v.ROUTER_STOP,[E.TRANSITION_SUCCESS]:v.TRANSITION_SUCCESS,[E.TRANSITION_START]:v.TRANSITION_START,[E.TRANSITION_LEAVE_APPROVE]:v.TRANSITION_LEAVE_APPROVE,[E.TRANSITION_ERROR]:v.TRANSITION_ERROR,[E.TRANSITION_CANCEL]:v.TRANSITION_CANCEL},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(R.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(R.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(z[`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(R.PLUGIN_AFTER_START,e)):this.#n.emitDiagnostic(R.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:z[`canActivate:count`],counted:R.CAN_ACTIVATE_COUNT,overwritten:R.CAN_ACTIVATE_OVERWRITE},deactivate:{count:z[`canDeactivate:count`],counted:R.CAN_DEACTIVATE_COUNT,overwritten:R.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(R.SYNC_GUARD_THENABLE,t,i)):this.#d.emitDiagnostic(R.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=Object.freeze,zr=Object.keys,Br=[];Object.freeze(Br);function Vr(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 Hr(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):ae(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(!Hr(i[e],a[e]))return!1;return!0}function Ur(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of zr(i))if(!Hr(n.params[e],r.params[e])||!Hr(n.search[e],r.search[e]))return!1;return!0}function Wr(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!Ur(a,e,t,n))return o}return a}const Gr=new Map;function G(e){let t=Gr.get(e);if(t)return t;let n=Kr(e);return Rr(n),Gr.set(e,n),n}function Kr(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]:Vr(e)}let qr,Jr,Yr=null,Xr,Zr,Qr=null;function $r(e,t,n){if(!t)return{intersection:``,toActivate:G(e.name),toDeactivate:Br};let r=n(e.name),i=n(t.name);if(!r&&!i)return{intersection:``,toActivate:G(e.name),toDeactivate:G(t.name)};let a=G(e.name),o=G(t.name),s=Math.min(o.length,a.length),c=Wr(r??i,e,t,a,o,s),l;if(c>=o.length)l=Br;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 ei(e,t,n){if(Yr!==null&&e===qr&&t===Jr)return Yr;if(Qr!==null&&e===Xr&&t===Zr)return Qr;let r=$r(e,t,n);return Xr=qr,Zr=Jr,Qr=Yr,qr=e,Jr=t,Yr=r,r}const ti=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`,`defaultSearch`]),ni=Object.freeze,K=Object.create,ri=Object.hasOwn,ii=Object.keys;function ai(){return{decoders:K(null),encoders:K(null),defaultParams:K(null),defaultSearch:K(null),forwardMap:K(null),forwardFnMap:K(null)}}function oi(e){return ii(e.forwardMap).length>0||ii(e.forwardFnMap).length>0}function si(e,t){for(let n of ii(t))Object.assign(e[n],t[n])}function ci(e,t){for(let n in e)if(ri(t,n)&&!ae(e[n],t[n]))return!1;return!0}function li(e){return typeof e==`string`?e:`<non-string>`}function ui(e,t){for(let n in e)if(!ae(e[n],t[n]))return!1;return!0}function di(e){let t={name:e.name,path:e.path};return e.children&&S(t,`children`,e.children.map(e=>di(e))),t}function fi(e,t,n){if(n.add(t),e.children)for(let r of e.children)fi(r,`${t}.${r.name}`,n)}function pi(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t){e.splice(r,1);let t=new Set;return fi(i,a,t),t}if(i.children&&t.startsWith(`${a}.`)){let e=pi(i.children,t,a);if(e)return e}}}function mi(e,t){for(let n of ii(e))t(n)&&delete e[n]}function hi(e,t){let n=t.search(/[?#]/),r=n===-1?t:t.slice(0,n);if(r===`/`||r.endsWith(`/`))return t;let i=e.search(/[?#]/),a=i===-1?e:e.slice(0,i);return a.length>1&&a.endsWith(`/`)?`${r}/${n===-1?``:t.slice(n)}`:t}function gi(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}const _i=ni([]);function vi(e,t,n){let r=n.get(t);if(r!==void 0)return r;let i=e.getSegmentsByName(t);if(!i)return _i;let a=ni(gi(i));return n.set(t,a),a}function yi(e,t){return vi(e.matcher,t,e.urlParamsCache)}const bi=ni([]);function xi(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=e.getDeclaredQueryParams(t);if(!a)return bi;let o=vi(e,t,n),s=ni(a.filter(e=>!o.includes(e)));return r.set(t,s),s}function Si(e,t){return e.getDeclaredQueryParams(t)??bi}function Ci(e,t){return xi(e.matcher,t,e.urlParamsCache,e.queryParamsCache)}function wi(e,t,n){let r=new Map,i=new Map;Te(t.defaultParams,t=>xi(e,t,r,i),n)}const Ti=y(`router`);function Ei(e,t,n=100){let r=String(e),i=new Set,a=[r],o=r;for(;;){let e=t[o];if(!e)break;let r=String(e);if(i.has(r)){let e=a.indexOf(r),t=[...a.slice(e),r];throw Ti.plain`Circular forwardTo: ${t.join(` → `)}`}if(i.add(o),a.push(r),o=r,a.length>n)throw Ti.plain`forwardTo chain exceeds maximum depth (${n}): ${a.join(` → `)}`}return o}const Di=y(`router`),Oi=y(`router`,`addRoute`),ki=Object.freeze,q=Object.create,Ai=Object.entries,ji=Object.keys,Mi=Object.defineProperty,Ni=Object.fromEntries;function Pi(e,t,n){let r=$t(``,t,e),i=nn(n);return i.registerTree(r),{tree:r,matcher:i}}function Fi(e,t=e.definitions){let n=Pi(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Ii(e,t){let n=Pi(e.definitions,t,e.matcherOptions);wi(n.matcher,e.config,`setRootPath`),e.rootPath=t,e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Li(e,t){Fi(e,t),Bi(e,Vi(e.config))}function Ri(e){zi(e),Fi(e,[])}function zi(e){Object.assign(e.config,ai()),Bi(e,q(null)),e.routeCustomFields=q(null)}function Bi(e,t){e.resolvedForwardMap=t,e.hasAnyForward=oi(e.config)}function Vi(e){let t=q(null);for(let n of ji(e.forwardMap))t[n]=Ei(n,e.forwardMap);return t}function Hi(e,t){if(typeof e!=`function`){if(typeof e!=`string`&&e!==null)throw Di.type`forwardTo must be a string or function for route "${t}", got ${typeof e}`;return}let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw Di.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}function Ui(e,t,n){t&&p(`encodeParams`,t,n,void 0),e&&p(`decodeParams`,e,n,void 0)}function Wi(e,t,n,r){if(Hi(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 Gi(e,t,n,r,i,a,o){let{decodeParams:s,encodeParams:c}=e;Ui(s,c,t);let l=Ni(Ai(e).filter(([e])=>!ti.has(e)));ji(l).length>0&&(r[t]=ki(l)),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&Wi(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;Gi(s,e,t,n,r,i,a),s.children&&Ki(s.children,t,n,r,i,a,e)}}function qi(e){let t=ai();return si(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 Yi(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&Yi(r.children,e,n)}}function Xi(e,t,n){let r=new Set;Yi(e,t,e=>{if(r.has(e))throw y(`router`,n).plain`Duplicate route "${e}" in batch`;r.add(e)})}function Zi(e,t){if(Fn(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 Qi(e,t){for(let n of e)Zi(n.name,t),n.children&&Qi(n.children,t)}function $i(e,n){for(let r of e)t(r.name,n),r.children&&$i(r.children,n)}function ea(e,t){for(let n of e)o(n.name,t),n.children&&ea(n.children,t)}function ta(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 na(e,t,n){if(Qi(t,`addRoute`),$i(t,`addRoute`),ea(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw Oi.plain`Parent route "${n}" does not exist`;Yi(t,n??``,t=>{if(e.matcher.hasRoute(t))throw Oi.plain`Route "${t}" already exists`}),Xi(t,n??``,`addRoute`),ta(t,n??``,`addRoute`)}function ra({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=Vi(n),{tree:d,matcher:f}=Pi(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function ia(e,t,n,r){return ra({definitions:Ji(e.definitions,t.map(e=>di(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:qi(e.config),routeCustomFields:Object.assign(q(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function aa(e,t,n,r){return ra({definitions:e.map(e=>di(e)),routesForHandlers:e,config:ai(),routeCustomFields:q(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function oa(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function sa(e,t){return{activate:oa(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:oa(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function ca(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??sa(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(),Bi(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 J(e){return e===null?e:e||void 0}function la(e,t){return t==null?t:k(e,t)}function ua(e,t,n,r){let{forwardTo:a,defaultParams:o,defaultSearch:s,decodeParams:c,encodeParams:l,canActivate:u,canDeactivate:d}=r,f=J(a),p=la(`defaultParams`,J(o)),m=la(`defaultSearch`,J(s)),h=J(c),g=J(l),_=J(u),v=J(d);p!=null&&i(`updateRoute`,n,p,Ci(e,n),"this route's `defaultParams`","Move it to `defaultSearch`"),Ui(h,g,n);let y=f===void 0?void 0:da(n,f,e.config),b=fa(e,n,r),ee=_==null?void 0:t.compileGuardFactory(_,`canActivate`),x=v==null?void 0:t.compileGuardFactory(v,`canDeactivate`);return t.preflightHandlerLimit(ee===void 0?[]:[n],x===void 0?[]:[n],!1),b!==void 0&&(ji(b).length>0?e.routeCustomFields[n]=ki(b):delete e.routeCustomFields[n]),y!==void 0&&(e.config.forwardMap=y.forwardMap,e.config.forwardFnMap=y.forwardFnMap,Bi(e,y.resolved)),ma(e,n,{defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}),ha(t,`activate`,n,_,ee),ha(t,`deactivate`,n,v,x),{forwardTo:f,defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}}function da(e,t,n){Hi(t,e);let r=Object.assign(q(null),n.forwardMap),i=Object.assign(q(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:Vi({...n,forwardMap:r})}}function fa(e,t,n){let r;for(let i of ji(n)){if(ti.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:S(r,i,a))}return r}function pa(e,t,n){n!==void 0&&(n===null?delete e[t]:e[t]=n)}function ma(e,t,n){if(pa(e.config.defaultParams,t,n.defaultParams),pa(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 ha(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 ga(e,t,n,r){let i=e;Qi(i,`addRoute`),$i(i,void 0),ea(i,void 0),Xi(i,``,`addRoute`);let a=aa(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:oi(a.config),routeCustomFields:a.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,treeChanged:ki(r),revalidating:!1,pendingCanActivate:a.pendingCanActivate,pendingCanDeactivate:a.pendingCanDeactivate};return wi(o.matcher,o.config,`addRoute`),Mi(o,`matcherOptions`,{writable:!1,configurable:!1}),Mi(o,`treeChanged`,{writable:!1,configurable:!1}),o}function _a(e,t,n){Mi(e,t,{value:n,writable:!1,configurable:!1})}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=sr(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=ga(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}=ei(n,r,t);return e===i||a.includes(e)?!0:o.includes(e)}}isRevalidating(){return this.#e.revalidating}setDependencies(e){_a(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){_a(this.#e,`lifecycleNamespace`,e)}setRootPath(e){Ii(this.#e,e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){Ri(this.#e)}buildPath(e,t,n,r){if(e===w.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===w.UNKNOWN_ROUTE?this.#r.port.buildPath(e,ge(t,C),n??x):gr(H(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},B(this.#r.checks,z[`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=H(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:cr(r.queryParamsMode)}),sr(i)===`preserve`&&(g=hi(t,g))}catch{g=t}return U(f,g)}forwardState(e,t,n){let r=n??x;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=C,n=x,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 "${li(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 yi(this.#e,e)}getQueryParams(e){return Ci(this.#e,e)}getPrintedQueryParams(e){return Si(this.#e.matcher,e)}getStore(){return this.#e}getPort(){return this.#r.port}#i(e,t,n,r,i){try{return this.#a(e,t,n,r,i)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Reading the arguments for route "${li(e)}" threw while resolving the active-link state; treating the link as inactive.`,t),!1}}#a(e,t,n,r,i){let a=this.#r.getState();if(!a)return!1;let o=a.name;if(o!==e&&!o.startsWith(`${e}.`)&&!e.startsWith(`${o}.`))return!1;let s=H(this.#r.port,e,t,n,{resolveForward:!1});if(r||o===e){let e=yr(s,``);return!this.#r.areStatesEqual(e,a,!0)||!ci(s.path,a.params)?!1:i||ie(e.search,a.search)}return!(!o.startsWith(`${e}.`)||!ci(s.path,a.params)||!i&&!ui(s.query,a.search))}#o(e){let t=[],n=e;for(;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),C),search:ge(ye(a,r),x)}}#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:cr(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 D(N.ROUTER_NOT_STARTED),Ea=new D(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 D&&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!==w.UNKNOWN_ROUTE&&!e.hasRoute(n.name)){let i=j(new D(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 D(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 D&&e.code===N.TRANSITION_CANCELLED}function za(e){return Ra(e)?e:j(new D(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 D(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 D?Wa(e,t):j(new D(t,Ka(e,n)))}function Wa(e,t){let{code:n,message:r,...i}=e.toJSON(),a=new D(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)&&S(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 D(t,{segment:n}))}function Ja(e,t,n,r,i,a,o,s,c,l,u){if(!c())throw j(new D(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 D(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 D(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}=ei(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!==w.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=le(n),o=a?.aborted===!0?a:void 0;n=ue(n),r=e.getState();let s=O(n,`reload`),c=O(n,`force`),l=O(n,`replace`),u=O(n,`redirected`),d=O(n,`forceDeactivate`)===!0,f=r?.name===w.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:ee,hasGuards:x}=m,te=t;if(!x){let t=ho(e,m);if(t!==void 0)return t}if(x){let n=oo(m),i=()=>!n.signal.aborted,a=n.signal,o=$a(g,_,v,y,b,ee,t,r,a,i,()=>{if(e.sendLeaveApprove(m),e.hasLeaveListeners())return e.awaitLeaveListeners(te,r,a)},e.warnNonBooleanGuard);if(o!==void 0)return po(e,o,m,n);if(!i())throw j(new D(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 D(N.TRANSITION_CANCELLED,{reason:a.reason}));if(await Promise.race([t,l]),!i())throw j(new D(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 D(N.TRANSITION_CANCELLED,{reason:t.reason}))}const _o=Object.freeze,vo=y(`router`,`navigateToNotFound`),yo=Object.freeze([w.UNKNOWN_ROUTE]),bo=Object.freeze({replace:!0});function xo(e,t,n){go(e,void 0);let r=e.getState(),i=r?G(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:w.UNKNOWN_ROUTE,params:C,search:x,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 D(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!==w.UNKNOWN_ROUTE&&!n.hasRoute(r)){let e=j(new D(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,C),search:he(e.search,x),path:e.path,context:{...e.context},transition:te};return oe(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 D&&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 D(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 D(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 D(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=Object.create,No=Object.entries,Po=Object.hasOwn,Fo=Object.values,Io=new WeakMap;function Lo(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 T.plain`transitions["${e}"]["${t}"].when is not a function`;if(i!==void 0&&typeof i!=`function`)throw T.plain`transitions["${e}"]["${t}"].update is not a function`;return{target:n.target,when:r,update:i}}function Ro(e){let t=Io.get(e);if(t!==void 0)return t;let n=e,r=Mo(null);for(let[e,t]of No(n)){let n=Mo(null);for(let[r,i]of No(t))i!==void 0&&(n[r]=Lo(e,r,i));r[e]=n}for(let e of Fo(r))for(let t of Fo(e))if(t!==void 0&&r[t.target]===void 0)throw T.plain`state "${t.target}" is not declared in config.transitions`;return Io.set(e,r),r}var zo=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=Ro(e.transitions),this.#a[t]===void 0)throw T.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 T.plain`state "${e}" is not declared in config.transitions`;if(!Po(r,t))throw T.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 Bo(){return{inflight:void 0,current:void 0,previous:void 0}}const Vo=(e,t)=>t?.nav===void 0||t.nav===e.inflight,Ho=(e,t)=>t!==void 0&&t===e.inflight&&t.externalSignal?.aborted!==!0,Uo=(e,t)=>{e.previous=e.current,e.current=oe(t)},Wo=(e,t)=>{Uo(e,t.toState),e.inflight=void 0},Go=(e,t)=>{Uo(e,t.toState)},Ko=e=>{e.previous=e.current,e.current=void 0},qo=e=>{e.current=void 0,e.previous=void 0,e.inflight=void 0},Jo=(e,t)=>{e.inflight=t},Yo={[X.IDLE]:{[Z.START]:X.STARTING,[Z.DISPOSE]:{target:X.DISPOSED,update:qo}},[X.STARTING]:{[Z.STARTED]:X.READY,[Z.FAIL]:X.IDLE,[Z.STOP]:{target:X.IDLE,update:Ko},[Z.DISPOSE]:{target:X.DISPOSED,update:qo}},[X.READY]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Jo},[Z.SYSTEM_COMMIT]:{target:X.READY,update:Go},[Z.STOP]:{target:X.IDLE,update:Ko},[Z.DISPOSE]:{target:X.DISPOSED,update:qo}},[X.TRANSITION_STARTED]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Jo},[Z.LEAVE_APPROVE]:X.LEAVE_APPROVED,[Z.CANCEL]:X.READY,[Z.FAIL]:{target:X.READY,when:Vo},[Z.DISPOSE]:{target:X.DISPOSED,update:qo}},[X.LEAVE_APPROVED]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Jo},[Z.COMPLETE]:{target:X.READY,when:Ho,update:Wo},[Z.CANCEL]:X.READY,[Z.FAIL]:{target:X.READY,when:Vo},[Z.DISPOSE]:{target:X.DISPOSED,update:qo}},[X.DISPOSED]:{}};function Xo(){return new zo({initial:X.IDLE,context:Bo(),transitions:Yo})}const Zo={},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 D&&e.code===N.TRANSITION_CANCELLED?e:j(new D(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,C),search:he(n.search,x),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 Zo;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(),Zo}#i(e,t){this.emitDiagnostic(R.LISTENER_COUNT,this.#t.listenerCount(e)+1,e,t)}#a(){if(this.isDisposed())return new D(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 D(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):Zo;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 D(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!==ir.defaultParams&&e!==ir.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 D(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=Yn(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=>er(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)=>{B(L(e.router).checks,t,...n)},hasChecks:t=>hn(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)=>{B(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(R.UNDECLARED_PARAM_KEY,t,n)},i=(t,n)=>{e.eventBus.emitDiagnostic(R.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(R.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:()=>cr(e.options.get().queryParamsMode)===`loose`,get reportDroppedQueryKey(){return e.eventBus.diagnosticListenerCount(R.DROPPED_QUERY_KEY)>0?i:void 0},get reportUndeclaredParamKey(){return e.eventBus.diagnosticListenerCount(R.UNDECLARED_PARAM_KEY)>0?r:void 0},get reportCodecRoundTrip(){return e.eventBus.diagnosticListenerCount(R.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)=>{B(L(t.router).checks,z[`navigate:state`],r,i);let o=H(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=U(o,gr(o,n));return n.reportCodecRoundTrip?.(s),s},resolveDefault:()=>{let e=t.options.get(),n=L(t.router),r=pr(e.defaultRoute,i),a=pr(e.defaultParams,i),o=pr(e.defaultSearch,i);return typeof e.defaultRoute==`function`&&B(n.checks,z[`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(R.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?Yn(a):void 0);this.#f=s,this.#p=e=>{Ma(e)||s.error(`router.start`,`Unexpected start error`,e)},fr.validateOptionsIsObject(n),Rn(r);let c=Hn(t),l=fs(o);this.#r=us(o),this.#e=new fr(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=rr(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=Xo();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)}},_=_n(fn.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??C),search:c?s:M(s)}}),y=_n(fn.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??C,a)},this.#m=gn(fn.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 B(b.checks,z[`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 B(b.checks,z[`buildPathResolved:entry`],t,n),B(b.checks,z[`buildPathResolved:params`],r),this.#o.buildPathFromIntent(e,r??C,n)},port:()=>this.#o.getPort(),matchPath:(e,t)=>(B(b.checks,z[`matchPath:entry`],e),this.#o.matchPath(e,t??this.#e.get())),getOptions:()=>this.#e.get(),getAdoptedOrigins:()=>this.#r,addEventListener:(e,t)=>{ln(b.isDisposed),An(e),jn(t);let n=this.#d.addEventListener(e,t,`addEventListener`);return ln(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)=>(ln(b.isDisposed),B(h,z[`navigateToState:entry`],t,n),this.#y(),e.#g(this.#l.navigateToState(t,n??ne))),interceptors:m,checks:h,setRootPath:e=>{B(h,z[`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:nr(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 D(N.ROUTE_NOT_FOUND,{routeName:r}));return this.#d.systemCommit({toState:e,fromState:t,opts:n},r)},routerExtensions:[],contextClaimRecords:new Map};un(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 B(a.checks,z[`isActiveRoute:entry`],e,t,n,r,i),this.#d.diagnosticListenerCount(R.IS_ACTIVE_ROUTE)>0&&this.#d.emitDiagnostic(R.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);B(r.checks,z[`buildPath:entry`],e,t,n),this.#d.diagnosticListenerCount(R.BUILD_PATH)>0&&this.#d.emitDiagnostic(R.BUILD_PATH,e,t);let i=A(t);return B(r.checks,z[`buildPath:params`],i),this.#h(e,i??C,n)}getState(){return this.#a.get()}getPreviousState(){return this.#a.getPrevious()}areStatesEqual(e,t,n=!0){return B(L(this).checks,z[`areStatesEqual:entry`],e,t,n),this.#a.areStatesEqual(e,t,n)}shouldUpdateNode(e){return B(L(this).checks,z[`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(),tr(this.#i),this.#S()}canNavigateTo(e,t,n){let r=L(this);B(r.checks,z[`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(B(r.checks,z[`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=H(a,e,i??C,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=U(o,gr(o,a))}catch{return!1}let c=this.#a.get(),{toDeactivate:l,toActivate:u}=ei(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(hn(n,z[`usePlugin:count`])&&B(n,z[`usePlugin:count`],this.#c.count(),new Set(t).size,this.#t.maxPlugins),hn(n,z[`usePlugin:entry`])){let e=this.#c.getAll();for(let r of t)B(n,z[`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??ne):(o=t,s=n,c=r,l=i??ne),cn(a,`navigate`,o,s),B(a.checks,z[`navigate:entry`],o,s,c,l);let u;try{u=A(s)}catch(e){return Promise.reject(e)}return B(a.checks,z[`navigate:params`],u),e.#g(this.#l.navigate(o,u??C,c,l))}navigateToDefault(t){this.#y();let n=L(this);return B(n.checks,z[`navigateToDefault:entry`],t),this.#d.emitDiagnostic(R.NAVIGATE_TO_DEFAULT),ln(n.isDisposed),e.#g(this.#l.navigateToDefault(t??ne))}navigateToNotFound(e){if(this.#y(),!this.#d.isActive())throw j(new D(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(),B(L(this).checks,z[`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 D(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{$n as A,z as B,ei as C,tr as D,H as E,Fn as F,cn as G,hn as H,Mn as I,en as K,Hn as L,Bn as M,In as N,er as O,Nn as P,Vn as R,yi as S,gr as T,B as U,L as V,ln as W,Ei as _,ea as a,mi as b,Qi as c,ia as d,aa as f,Ri as g,sa as h,na as i,Pn as j,nr as k,Zi as l,Li as m,Bi as n,Xi as o,ua as p,tn as q,ca as r,ta as s,Ws as t,$i as u,wi as v,U as w,pi as x,si as y,R as z};
2
+ //# sourceMappingURL=Router-Ca3uBjYG.mjs.map