@real-router/core 0.35.2 → 0.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import { PluginApi as PluginApi$1, DefaultDependencies, Router, RoutesApi, DependenciesApi, LifecycleApi } from '@real-router/types';
2
+ export { DependenciesApi, LifecycleApi, RoutesApi } from '@real-router/types';
3
+ import { a as RouteTree, R as Router$1 } from './index.d-DDimDpYc.js';
4
+
5
+ interface PluginApi extends Omit<PluginApi$1, "getTree"> {
6
+ getTree: () => RouteTree;
7
+ }
8
+
9
+ declare function getPluginApi<Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>): PluginApi;
10
+
11
+ declare function getRoutesApi<Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>): RoutesApi<Dependencies>;
12
+
13
+ declare function getDependenciesApi<Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>): DependenciesApi<Dependencies>;
14
+
15
+ declare function getLifecycleApi<Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>): LifecycleApi<Dependencies>;
16
+
17
+ declare function cloneRouter<Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>, dependencies?: Dependencies): Router$1<Dependencies>;
18
+
19
+ export { type PluginApi, cloneRouter, getDependenciesApi, getLifecycleApi, getPluginApi, getRoutesApi };
@@ -0,0 +1 @@
1
+ var e=require("@real-router/logger"),t=require("@real-router/fsm"),r=Object.freeze({ROUTER_NOT_STARTED:"NOT_STARTED",NO_START_PATH_OR_STATE:"NO_START_PATH_OR_STATE",ROUTER_ALREADY_STARTED:"ALREADY_STARTED",ROUTE_NOT_FOUND:"ROUTE_NOT_FOUND",SAME_STATES:"SAME_STATES",CANNOT_DEACTIVATE:"CANNOT_DEACTIVATE",CANNOT_ACTIVATE:"CANNOT_ACTIVATE",TRANSITION_ERR:"TRANSITION_ERR",TRANSITION_CANCELLED:"CANCELLED",ROUTER_DISPOSED:"DISPOSED",PLUGIN_CONFLICT:"PLUGIN_CONFLICT"}),n="@@router/UNKNOWN_ROUTE",o="onStart",i="onStop",a="onTransitionStart",s="onTransitionCancel",c="onTransitionSuccess",u="onTransitionError",d="$start",l="$stop",f="$$start",h="$$cancel",p="$$success",m="$$error",g=new Set([d,f,p,m,h,l]),v={maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxEventDepth:5,maxLifecycleHandlers:200},w={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxEventDepth:{min:0,max:100},maxLifecycleHandlers:{min:0,max:1e4}},y=["replace","reload","force","forceDeactivate","redirected"],b=/\S/,S=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function T(e,t){return new TypeError(`[router.${e}] ${t}`)}function E(e,t=new WeakSet){if(null==e)return!0;const r=typeof e;if("string"===r||"boolean"===r)return!0;if("number"===r)return Number.isFinite(e);if("function"===r||"symbol"===r)return!1;if(Array.isArray(e))return!t.has(e)&&(t.add(e),e.every(e=>E(e,t)));if("object"===r){if(t.has(e))return!1;t.add(e);const r=Object.getPrototypeOf(e);return(null===r||r===Object.prototype)&&Object.values(e).every(e=>E(e,t))}return!1}function P(e){if(null==e)return!0;const t=typeof e;return"string"===t||"boolean"===t||"number"===t&&Number.isFinite(e)}function $(e){if("object"!=typeof e||null===e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);if(null!==t&&t!==Object.prototype)return!1;let r=!1;for(const t in e){if(!Object.hasOwn(e,t))continue;const n=e[t];if(!P(n)){const e=typeof n;if("function"===e||"symbol"===e)return!1;r=!0;break}}return!r||E(e)}function A(e){return"string"==typeof e}function O(e){return"boolean"==typeof e}function D(e,t){return e in t}function R(e,t){if("string"!=typeof e)throw T(t,"Route name must be a string, got "+typeof e);if(""!==e){if(!b.test(e))throw T(t,"Route name cannot contain only whitespace");if(e.length>1e4)throw T(t,"Route name exceeds maximum length of 10000 characters. This is a technical safety limit.");if(!e.startsWith("@@")&&!S.test(e))throw T(t,`Invalid route name "${e}". Each segment must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens. Segments are separated by dots (e.g., "users.profile").`)}}function N(e){return null===e?"null":Array.isArray(e)?`array[${e.length}]`:"object"==typeof e?"constructor"in e&&"Object"!==e.constructor.name?e.constructor.name:"object":typeof e}function C(e,t){if(!function(e){return"object"==typeof e&&null!==e&&function(e){return function(e){return"string"==typeof e&&(""===e||!(e.length>1e4)&&(!!e.startsWith("@@")||S.test(e)))}(e.name)&&"string"==typeof e.path&&$(e.params)}(e)}(e))throw new TypeError(`[${t}] Invalid state structure: ${N(e)}. Expected State object with name, params, and path properties.`)}var j=new WeakSet;function F(e){if(null!==e&&"object"==typeof e&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))for(const t of e)F(t);else for(const t in e)F(e[t])}function x(e){return e?(j.has(e)||(F(e),j.add(e)),e):e}function L(e){return{warn:Math.floor(.2*e),error:Math.floor(.5*e)}}var M=new Set(Object.values(r)),k=new Set(["code","segment","path","redirect"]),I=new Set(["setCode","setErrorInstance","setAdditionalFields","hasField","getField","toJSON"]),_=class extends Error{segment;path;redirect;code;constructor(e,{message:t,segment:r,path:n,redirect:o,...i}={}){super(t??e),this.code=e,this.segment=r,this.path=n,this.redirect=o?function(e){if(!e)return e;if(null===(t=e)||"object"!=typeof t||"string"!=typeof t.name||"string"!=typeof t.path||"object"!=typeof t.params||null===t.params)throw new TypeError("[deepFreezeState] Expected valid State object, got: "+typeof e);var t;const r=structuredClone(e),n=new WeakSet;return function e(t){if(null===t||"object"!=typeof t)return;if(n.has(t))return;n.add(t),Object.freeze(t);const r=Array.isArray(t)?t:Object.values(t);for(const t of r)e(t)}(r),r}(o):void 0;for(const[e,t]of Object.entries(i)){if(k.has(e))throw new TypeError(`[RouterError] Cannot set reserved property "${e}"`);I.has(e)||(this[e]=t)}}setCode(e){this.code=e,M.has(this.message)&&(this.message=e)}setErrorInstance(e){if(!e)throw new TypeError("[RouterError.setErrorInstance] err parameter is required and must be an Error instance");this.message=e.message,this.cause=e.cause,this.stack=e.stack??""}setAdditionalFields(e){for(const[t,r]of Object.entries(e)){if(k.has(t))throw new TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${t}"`);I.has(t)||(this[t]=r)}}hasField(e){return e in this}getField(e){return this[e]}toJSON(){const e={code:this.code,message:this.message};void 0!==this.segment&&(e.segment=this.segment),void 0!==this.path&&(e.path=this.path),void 0!==this.redirect&&(e.redirect=this.redirect);const t=new Set(["code","message","segment","path","redirect","stack"]);for(const r in this)Object.hasOwn(this,r)&&!t.has(r)&&(e[r]=this[r]);return e}};function U(e){if(e())throw new _(r.ROUTER_DISPOSED)}var B=new WeakMap;function G(e){const t=B.get(e);if(!t)throw new TypeError("[real-router] Invalid router instance — not found in internals registry");return t}function V(e,t,r){return(...n)=>{const o=r.get(e);return o&&0!==o.length?function(e,t,r){let n=t;for(const t of e){const e=n;n=(...r)=>t(e,...r)}return n(...r)}(o,t,n):t(...n)}}function q(e){return`(${e.replaceAll(/(^<|>$)/g,"")})`}var z=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,W=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,Q=/\?(.+)$/,H=/[^\w!$'()*+,.:;|~-]/gu,J=/[^\w!$'()*+,.:;|~-]/u,Y={default:e=>J.test(e)?e.replaceAll(H,e=>encodeURIComponent(e)):e,uri:encodeURI,uriComponent:encodeURIComponent,none:e=>e},Z={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e};function K(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function X(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function ee(e){const t={};if(0===e.length)return t;const r=e.split("&");for(const e of r){const r=e.indexOf("=");-1===r?t[e]="":t[e.slice(0,r)]=e.slice(r+1)}return t}function te(e){const t=[];for(const r of Object.keys(e)){const n=e[r],o=encodeURIComponent(r);t.push(""===n?o:`${o}=${encodeURIComponent(String(n))}`)}return t.join("&")}function re(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function ne(e){let t=0;for(;t<e.length;)if("%"===e[t]){if(t+2>=e.length)return!1;const r=e.codePointAt(t+1)??0,n=e.codePointAt(t+2)??0;if(!re(r)||!re(n))return!1;t+=3}else t++;return!0}var oe=/<[^>]*>/g;function ie(e,t,r,n,o){const i=""===t.fullName;i||n.push(t);const a=t.absolute,s=t.paramMeta.pathPattern,c=a&&s.startsWith("~")?s.slice(1):s,u=(a?c:s).replaceAll(oe,""),d=a?u:(f=u,""===(l=r)?f:""===f?l:l+f);var l,f;let h=o;i||(h=function(e,t,r,n,o,i){const a=(g=n,X(r)===X(g)),s=Object.freeze([...o]),c=function(e){const t={};for(const r of e)t[r.fullName]=r.paramTypeMap;return Object.freeze(t)}(s),u=X(r),d=function(e,t){const r=[];e.length>0&&r.push(...e);for(const e of t)e.paramMeta.queryParams.length>0&&r.push(...e.paramMeta.queryParams);return r}(e.rootQueryParams,o),l=function(e){const t=new Map;for(const r of e)for(const[e,n]of r.paramMeta.constraintPatterns)t.set(e,n);return t}(o),f=a?X(n):u,{buildStaticParts:h,buildParamSlots:p}=function(e,t,r){const n=new Set,o=new Set;for(const e of t){for(const t of e.paramMeta.urlParams)n.add(t);for(const t of e.paramMeta.spatParams)o.add(t)}if(0===n.size)return{buildStaticParts:[e],buildParamSlots:[]};const i=[],a=[],s=/[:*]([\w]+)(?:<[^>]*>)?(\?)?/gu;let c,u=0;for(;null!==(c=s.exec(e));){const t=c[1],n="?"===c[2];i.push(e.slice(u,c.index));const s=o.has(t);a.push({paramName:t,isOptional:n,encoder:s?e=>{const t=Y[r],n=e.split("/");let o=t(n[0]);for(let e=1;e<n.length;e++)o+=`/${t(n[e])}`;return o}:Y[r]}),u=c.index+c[0].length}return i.push(e.slice(u)),{buildStaticParts:i,buildParamSlots:a}}(f,a?o.slice(0,-1):o,e.options.urlParamsEncoding),m={name:t.fullName,parent:i,depth:o.length-1,matchSegments:s,meta:c,declaredQueryParams:d,declaredQueryParamsSet:new Set(d),hasTrailingSlash:r.length>1&&r.endsWith("/"),constraintPatterns:l,hasConstraints:l.size>0,buildStaticParts:h,buildParamSlots:p,buildParamNamesSet:new Set(p.map(e=>e.paramName))};var g;return e.routesByName.set(t.fullName,m),e.segmentsByName.set(t.fullName,s),e.metaByName.set(t.fullName,c),a?function(e,t,r){var n,o;n=t,(function(e,t,r){const n=X(r);if("/"===n||""===n)return t;let o=t,i=1;const a=n.length;for(;i<=a;){const t=n.indexOf("/",i),r=-1===t?a:t;if(r<=i)break;o=se(e,o,n.slice(i,r)),i=r+1}return o}(o=e,o.root,r)).slashChildRoute=n;const i=X(r),a=e.options.caseSensitive?i:i.toLowerCase();e.staticCache.has(a)&&e.staticCache.set(a,t)}(e,m,n):function(e,t,r,n,o){if(function(e,t,r){const n=X(r);"/"!==n?ae(e,e.root,n,1,t):e.root.route=t}(e,t,r),0===o.paramMeta.urlParams.length){const r=e.options.caseSensitive?n:n.toLowerCase();e.staticCache.set(r,t)}}(e,m,r,u,t),m}(e,t,d,a?"":r,n,o));for(const r of t.children.values())ie(e,r,d,n,h);i||n.pop()}function ae(e,t,r,n,o){const i=r.length;for(;n<=i;){const a=r.indexOf("/",n),s=-1===a?i:a,c=r.slice(n,s);if(c.endsWith("?")){const n=c.slice(1).replaceAll(oe,"").replace(/\?$/,"");return t.paramChild??={node:K(),name:n},ae(e,t.paramChild.node,r,s+1,o),void(s>=i?t.route??=o:ae(e,t,r,s+1,o))}t=se(e,t,c),n=s+1}t.route=o}function se(e,t,r){if(r.startsWith("*")){const e=r.slice(1);return t.splatChild??={node:K(),name:e},t.splatChild.node}if(r.startsWith(":")){const e=r.slice(1).replaceAll(oe,"").replace(/\?$/,"");return t.paramChild??={node:K(),name:e},t.paramChild.node}const n=e.options.caseSensitive?r:r.toLowerCase();return n in t.staticChildren||(t.staticChildren[n]=K()),t.staticChildren[n]}var ce=/[\u0080-\uFFFF]/,ue=class{get options(){return this.#e}#e;#t=K();#r=new Map;#n=new Map;#o=new Map;#i=new Map;#a="";#s=[];constructor(e){this.#e={caseSensitive:e?.caseSensitive??!0,strictTrailingSlash:e?.strictTrailingSlash??!1,strictQueryParams:e?.strictQueryParams??!1,urlParamsEncoding:e?.urlParamsEncoding??"default",parseQueryString:e?.parseQueryString??ee,buildQueryString:e?.buildQueryString??te}}registerTree(e){this.#s=e.paramMeta.queryParams,ie({root:this.#t,options:this.#e,routesByName:this.#r,segmentsByName:this.#n,metaByName:this.#o,staticCache:this.#i,rootQueryParams:this.#s},e,"",[],null)}match(e){const t=this.#c(e);if(!t)return;const[r,n,o]=t,i=this.#e.caseSensitive?n:n.toLowerCase(),a=this.#i.get(i);if(a){if(this.#e.strictTrailingSlash&&!this.#u(r,a))return;return this.#d(a,{},o)}const s={},c=this.#l(n,s);return!c||this.#e.strictTrailingSlash&&!this.#u(r,c)||c.hasConstraints&&!this.#f(s,c)||!this.#h(s)?void 0:this.#d(c,s,o)}buildPath(e,t,r){const n=this.#r.get(e);if(!n)throw new Error(`[SegmentMatcher.buildPath] '${e}' is not defined`);n.hasConstraints&&t&&this.#p(n,e,t);const o=this.#m(n,t),i=this.#g(o,r?.trailingSlash),a=this.#v(n,t,r?.queryParamsMode);return i+(a?`?${a}`:"")}getSegmentsByName(e){return this.#n.get(e)}getMetaByName(e){return this.#o.get(e)}hasRoute(e){return this.#r.has(e)}setRootPath(e){this.#a=e}#p(e,t,r){for(const[n,o]of e.constraintPatterns){const e=r[n];if(null!=e){const r="object"==typeof e?JSON.stringify(e):String(e);if(!o.pattern.test(r))throw new Error(`[SegmentMatcher.buildPath] '${t}' — param '${n}' value '${r}' does not match constraint '${o.constraint}'`)}}}#m(e,t){const r=e.buildStaticParts,n=e.buildParamSlots;if(0===n.length)return this.#a+r[0];let o=this.#a+r[0];for(const[e,i]of n.entries()){const n=t?.[i.paramName];if(null==n){if(!i.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${i.paramName}'`);o.length>1&&o.endsWith("/")&&(o=o.slice(0,-1)),o+=r[e+1];continue}const a="object"==typeof n?JSON.stringify(n):String(n);o+=i.encoder(a)+r[e+1]}return o}#g(e,t){return"always"!==t||e.endsWith("/")?"never"===t&&"/"!==e&&e.endsWith("/")?e.slice(0,-1):e:`${e}/`}#v(e,t,r){if(!t)return"";const n={};let o=!1;for(const r of e.declaredQueryParams)r in t&&(n[r]=t[r],o=!0);if("loose"===r)for(const r in t)!Object.hasOwn(t,r)||e.declaredQueryParamsSet.has(r)||e.buildParamNamesSet.has(r)||(n[r]=t[r],o=!0);return o?this.#e.buildQueryString(n):""}#c(e){if(""===e&&(e="/"),!e.startsWith("/"))return;const t=e.indexOf("#");if(-1!==t&&(e=e.slice(0,t)),ce.test(e))return;if(this.#a.length>0){if(!e.startsWith(this.#a))return;e=e.slice(this.#a.length)||"/"}const r=e.indexOf("?"),n=-1===r?e:e.slice(0,r),o=-1===r?void 0:e.slice(r+1);return n.includes("//")?void 0:[n,X(n),o]}#d(e,t,r){if(void 0!==r){const n=this.#e.parseQueryString(r);if(this.#e.strictQueryParams){const t=e.declaredQueryParamsSet;for(const e of Object.keys(n))if(!t.has(e))return}for(const e of Object.keys(n))t[e]=n[e]}return{segments:e.matchSegments,params:t,meta:e.meta}}#u(e,t){return(e.length>1&&e.endsWith("/"))===t.hasTrailingSlash}#l(e,t){return 1===e.length?this.#t.slashChildRoute??this.#t.route:this.#w(this.#t,e,1,t)}#w(e,t,r,n){let o=e;const i=t.length;for(;r<=i;){const e=t.indexOf("/",r),a=-1===e?i:e,s=t.slice(r,a),c=this.#e.caseSensitive?s:s.toLowerCase();let u;if(c in o.staticChildren)u=o.staticChildren[c];else{if(!o.paramChild){if(o.splatChild){const e={},i=this.#w(o.splatChild.node,t,r,e);return i?(Object.assign(n,e),i):(n[o.splatChild.name]=t.slice(r),o.splatChild.node.route)}return}u=o.paramChild.node,n[o.paramChild.name]=s}o=u,r=a+1}return o.slashChildRoute??o.route}#h(e){const t=this.#e.urlParamsEncoding;if("none"===t)return!0;const r=Z[t];for(const t in e){const n=e[t];if(n.includes("%")){if(!ne(n))return!1;e[t]=r(n)}}return!0}#f(e,t){for(const[r,n]of t.constraintPatterns)if(!n.pattern.test(e[r]))return!1;return!0}},de=e=>{const t=e.indexOf("%"),r=e.indexOf("+");if(-1===t&&-1===r)return e;const n=-1===r?e:e.split("+").join(" ");return-1===t?n:decodeURIComponent(n)},le=e=>{const t=typeof e;if("string"!==t&&"number"!==t&&"boolean"!==t)throw new TypeError(`[search-params] Array element must be a string, number, or boolean — received ${"object"===t&&null===e?"null":t}`);return encodeURIComponent(e)},fe={none:{encodeArray:(e,t)=>t.map(t=>`${e}=${le(t)}`).join("&")},brackets:{encodeArray:(e,t)=>t.map(t=>`${e}[]=${le(t)}`).join("&")},index:{encodeArray:(e,t)=>t.map((t,r)=>`${e}[${r}]=${le(t)}`).join("&")},comma:{encodeArray:(e,t)=>`${e}=${t.map(e=>le(e)).join(",")}`}},he={none:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:e=>e},string:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:e=>"true"===e||"false"!==e&&null,decodeValue:e=>e},"empty-true":{encode:(e,t)=>t?e:`${e}=false`,decodeUndefined:()=>!0,decodeRaw:()=>null,decodeValue:e=>e}},pe={default:{encode:e=>e},hidden:{encode:()=>""}},me=(e,t,r)=>({boolean:he[t],null:pe[r],array:fe[e]}),ge={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:he.none,null:pe.default,array:fe.none}},ve=e=>{if(!e||void 0===e.arrayFormat&&void 0===e.booleanFormat&&void 0===e.nullFormat)return ge;const t=e.arrayFormat??"none",r=e.booleanFormat??"none",n=e.nullFormat??"default";return{arrayFormat:t,booleanFormat:r,nullFormat:n,strategies:me(t,r,n)}},we=e=>encodeURIComponent(e),ye=(e,t,r)=>{const n=we(e);switch(typeof t){case"string":case"number":default:return`${n}=${we(t)}`;case"boolean":return r.strategies.boolean.encode(n,t);case"object":return null===t?r.strategies.null.encode(n):Array.isArray(t)?r.strategies.array.encodeArray(n,t):`${n}=${we(t)}`}};function be(e,t,r,n,o){const i=e.indexOf("=",t),a=-1!==i&&i<r,s=e.slice(t,a?i:r),{name:c,hasBrackets:u}=function(e){const t=e.indexOf("[");return-1===t?{name:e,hasBrackets:!1}:{name:e.slice(0,t),hasBrackets:!0}}(s);var d,l,f,h,p;!function(e,t,r,n){const o=e[t];void 0===o?e[t]=n?[r]:r:Array.isArray(o)?o.push(r):e[t]=[o,r]}(n,de(c),(d=e,l=i,f=r,h=a,p=o,p?((e,t)=>{if(void 0===e)return t.boolean.decodeUndefined();const r=t.boolean.decodeRaw(e);if(null!==r)return r;const n=de(e);return t.boolean.decodeValue(n)})(h?d.slice(l+1,f):void 0,p):h?de(d.slice(l+1,f)):null),u)}function Se(e,t){const r=e.path,n=r.startsWith("~"),o=n?r.slice(1):r,i={name:e.name,path:o,absolute:n,children:[],parent:t,nonAbsoluteChildren:[],fullName:""};if(e.children)for(const t of e.children){const e=Se(t,i);i.children.push(e)}return i}function Te(e,t){return e.endsWith("/")&&t.startsWith("/")?e+t.slice(1):e+t}function Ee(e){const t=new Map;for(const r of e)t.set(r.name,r);return t}function Pe(e,t,r){const n=function(e){const t=[],r=[],n=[],o={},i=new Map,a=e.replaceAll(W,"$1"),s=Q.exec(a);if(null!==s){const t=s[1].split("&");for(const e of t){const t=e.trim();t.length>0&&(r.push(t),o[t]="query")}e=e.slice(0,s.index)}let c;for(;null!==(c=z.exec(e));){const e=c[2],r=c[3];if("*"===c[1])n.push(e),t.push(e),o[e]="url";else if(t.push(e),o[e]="url",r){const t=`^${q(r)}$`;i.set(e,{pattern:new RegExp(t),constraint:r})}}return{urlParams:t,queryParams:r,spatParams:n,paramTypeMap:o,constraintPatterns:i,pathPattern:e}}(e.path),o=function(e){const t={};for(const r of e.urlParams)t[r]="url";for(const r of e.queryParams)t[r]="query";return t}(n),i={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:n,nonAbsoluteChildren:void 0,fullName:"",staticPath:null,paramTypeMap:o};var a;i.fullName=(a=i,a.parent?.name?`${a.parent.fullName}.${a.name}`:a.name);const{childrenMap:s,nonAbsoluteChildren:c}=function(e,t,r){const n=[],o=[];for(const i of e){const e=Pe(i,t,r);n.push(e),e.absolute||o.push(e)}return{childrenMap:Ee(n),nonAbsoluteChildren:o}}(e.children,i,r);return i.children=s,i.nonAbsoluteChildren=c,i.staticPath=function(e){if(!e.path)return null;const{urlParams:t,queryParams:r,spatParams:n}=e.paramMeta;if(t.length>0||r.length>0||n.length>0)return null;const o=[];let i=e.parent;for(;i?.path;)o.unshift(i),i=i.parent;let a="";for(const e of o){const{urlParams:t,queryParams:r,spatParams:n}=e.paramMeta;if(t.length>0||r.length>0||n.length>0)return null;a=e.absolute?e.path:Te(a,e.path)}return e.absolute?e.path:Te(a,e.path)}(i),r&&(Object.freeze(c),Object.freeze(o),Object.freeze(i.children),Object.freeze(i)),i}function $e(e,t,r,n){return function(e,t){const r=[];return{add(e){return r.push(e),this},addMany(e){return r.push(...e),this},build:n=>function(e,t=!0){return Pe(e,null,t)}(function(e,t,r){const n=Se({name:e,path:t},null);for(const e of r){const t=Se(e,n);n.children.push(t)}return n}(e,t,r),!n?.skipFreeze)}}(e,t).addMany(r).build(n)}function Ae(e){const t={name:e.name,path:e.absolute?`~${e.path}`:e.path};return e.children.size>0&&(t.children=[...e.children.values()].map(e=>Ae(e))),t}function Oe(e){const t=e?.queryParams;return new ue({...void 0===e?.caseSensitive?void 0:{caseSensitive:e.caseSensitive},...void 0===e?.strictTrailingSlash?void 0:{strictTrailingSlash:e.strictTrailingSlash},...void 0===e?.strictQueryParams?void 0:{strictQueryParams:e.strictQueryParams},...void 0===e?.urlParamsEncoding?void 0:{urlParamsEncoding:e.urlParamsEncoding},parseQueryString:e=>((e,t)=>{const r=(e=>{const t=e.indexOf("?");return-1===t?e:e.slice(t+1)})(e);if(""===r||"?"===r)return{};if(!t)return function(e){const t={};return function(e,t){let r=0;const n=e.length;for(;r<n;){let o=e.indexOf("&",r);-1===o&&(o=n),be(e,r,o,t),r=o+1}}(e,t),t}(r);const n=ve(t),o={};let i=0;const a=r.length;for(;i<a;){let e=r.indexOf("&",i);-1===e&&(e=a),be(r,i,e,o,n.strategies),i=e+1}return o})(e,t),buildQueryString:e=>((e,t)=>{const r=Object.keys(e);if(0===r.length)return"";const n=ve(t),o=[];for(const t of r){const r=e[t];if(void 0===r)continue;const i=ye(t,r,n);i&&o.push(i)}return o.join("&")})(e,t)})}function De(e,t){return new TypeError(`[router.${e}] ${t}`)}var Re=/^[A-Z_a-z][\w-]*$/,Ne=/\S/;function Ce(e){return null===e?"null":"object"==typeof e?"constructor"in e&&"Object"!==e.constructor.name?e.constructor.name:"object":typeof e}function je(e,t){if(!t.includes("."))return e.children.get(t);let r=e;for(const e of t.split("."))if(r=r.children.get(e),!r)return;return r}function Fe(e,t,r,n="",o,i){!function(e,t){if(!e||"object"!=typeof e)throw new TypeError(`[router.${t}] Route must be an object, got ${Ce(e)}`);const r=Object.getPrototypeOf(e);if(r!==Object.prototype&&null!==r)throw new TypeError(`[router.${t}] Route must be a plain object, got ${Ce(e)}`);if(function(e){for(const t of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,t);if(r&&(r.get||r.set))return!0}return!1}(e))throw new TypeError(`[router.${t}] Route must not have getters or setters`)}(e,t);const a=e;!function(e,t){if("string"!=typeof e.name)throw new TypeError(`[router.${t}] Route name must be a string, got ${Ce(e.name)}`);const r=e.name;if(""===r)throw new TypeError(`[router.${t}] Route name cannot be empty`);if(!Ne.test(r))throw new TypeError(`[router.${t}] Route name cannot contain only whitespace`);if(r.length>1e4)throw new TypeError(`[router.${t}] Route name exceeds maximum length of 10000 characters`);if(!r.startsWith("@@")){if(r.includes("."))throw new TypeError(`[router.${t}] Route name "${r}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`);if(!Re.test(r))throw new TypeError(`[router.${t}] Invalid route name "${r}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`)}}(a,t),function(e,t,r,n){if("string"!=typeof e){let t;throw t=null===e?"null":Array.isArray(e)?"array":typeof e,De(r,`Route path must be a string, got ${t}`)}if(""===e)return;if(/\s/.test(e))throw De(r,`Invalid path for route "${t}": whitespace not allowed in "${e}"`);if(!/^([/?~]|[^/]+$)/.test(e))throw De(r,`Route "${t}" has invalid path format: "${e}". Path should start with '/', '~', '?' or be a relative segment.`);if(e.includes("//"))throw De(r,`Invalid path for route "${t}": double slashes not allowed in "${e}"`);const o=n&&Object.values(n.paramTypeMap).includes("url");if(e.startsWith("~")&&o)throw De(r,`Absolute path "${e}" cannot be used under parent route with URL parameters`)}(a.path,a.name,t,r),function(e,t){if(void 0!==e.encodeParams&&"function"!=typeof e.encodeParams)throw new TypeError(`[router.${t}] Route "${String(e.name)}" encodeParams must be a function`)}(a,t),function(e,t){if(void 0!==e.decodeParams&&"function"!=typeof e.decodeParams)throw new TypeError(`[router.${t}] Route "${String(e.name)}" decodeParams must be a function`)}(a,t);const s=a.name,c=n?`${n}.${s}`:s;r&&c&&function(e,t,r){if(je(e,t))throw new Error(`[router.${r}] Route "${t}" already exists`)}(r,c,t),o&&function(e,t,r){if(e.has(t))throw new Error(`[router.${r}] Duplicate route "${t}" in batch`);e.add(t)}(o,c,t);const u=a.path,d=n;if(r&&function(e,t,r,n){const o=""===t?e:je(e,t);if(o)for(const e of o.children.values())if(e.path===r)throw new Error(`[router.${n}] Path "${r}" is already defined`)}(r,d,u,t),i&&function(e,t,r,n){const o=e.get(t);if(o?.has(r))throw new Error(`[router.${n}] Path "${r}" is already defined`);o?o.add(r):e.set(t,new Set([r]))}(i,d,u,t),void 0!==a.children){if(!Array.isArray(a.children))throw new TypeError(`[router.${t}] Route "${s}" children must be an array, got ${Ce(a.children)}`);for(const e of a.children)Fe(e,t,r,c,o,i)}}function xe(e,t){if(void 0!==e.canActivate&&"function"!=typeof e.canActivate)throw new TypeError(`[router.addRoute] canActivate must be a function for route "${t}", got ${N(e.canActivate)}`);if(void 0!==e.canDeactivate&&"function"!=typeof e.canDeactivate)throw new TypeError(`[router.addRoute] canDeactivate must be a function for route "${t}", got ${N(e.canDeactivate)}`);if(void 0!==e.defaultParams){const r=e.defaultParams;if(null===r||"object"!=typeof r||Array.isArray(r))throw new TypeError(`[router.addRoute] defaultParams must be an object for route "${t}", got ${N(e.defaultParams)}`)}if("AsyncFunction"===e.decodeParams?.constructor.name)throw new TypeError(`[router.addRoute] decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if("AsyncFunction"===e.encodeParams?.constructor.name)throw new TypeError(`[router.addRoute] encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(function(e,t){if(void 0!==e&&"function"==typeof e){const r="AsyncFunction"===e.constructor.name,n=e.toString().includes("__awaiter");if(r||n)throw new TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}}(e.forwardTo,t),e.children)for(const r of e.children)xe(r,`${t}.${r.name}`)}function Le(e){const t=new Set,r=/[*:]([A-Z_a-z]\w*)/g;let n;for(;null!==(n=r.exec(e));)t.add(n[1]);return t}function Me(e){const t=new Set;for(const r of e)for(const e of Le(r))t.add(e);return t}function ke(e,t,r="",n=[]){for(const o of e){const e=r?`${r}.${o.name}`:o.name,i=[...n,o.path];if(e===t)return i;if(o.children&&t.startsWith(`${e}.`))return ke(o.children,t,e,i)}throw new Error(`[internal] collectPathsToRoute: route "${t}" not found`)}function Ie(e,t=""){const r=new Set;for(const n of e){const e=t?`${t}.${n.name}`:n.name;if(r.add(e),n.children)for(const t of Ie(n.children,e))r.add(t)}return r}function _e(e,t=""){const r=new Map;for(const n of e){const e=t?`${t}.${n.name}`:n.name;if(n.forwardTo&&"string"==typeof n.forwardTo&&r.set(e,n.forwardTo),n.children)for(const[t,o]of _e(n.children,e))r.set(t,o)}return r}function Ue(e,t,r,n){return t?function(e){const t=new Set;for(const r of e){for(const e of r.paramMeta.urlParams)t.add(e);for(const e of r.paramMeta.spatParams)t.add(e)}return t}(function(e,t){const r=[],n=t.includes(".")?t.split("."):[t];""!==e.path&&r.push(e);let o=e;for(const e of n){const t=o.children.get(e);if(!t)return null;r.push(t),o=t}return r}(r,e)):Me(ke(n,e))}function Be(e,t,r,n,o){const i=function(e,t){const r=t.split(".");let n=e;for(const e of r)if(n=n.children.get(e),!n)return!1;return!0}(o,t),a=n.has(t);if(!i&&!a)throw new Error(`[router.addRoute] forwardTo target "${t}" does not exist for route "${e}"`);const s=Me(ke(r,e)),c=[...Ue(t,i,o,r)].filter(e=>!s.has(e));if(c.length>0)throw new Error(`[router.addRoute] forwardTo target "${t}" requires params [${c.join(", ")}] that are not available in source route "${e}"`)}function Ge(e,t,r=100){const n=new Set,o=[e];let i=e;for(;t[i];){const e=t[i];if(n.has(e)){const t=o.indexOf(e),r=[...o.slice(t),e];throw new Error(`Circular forwardTo: ${r.join(" → ")}`)}if(n.add(i),o.push(e),i=e,o.length>r)throw new Error(`forwardTo chain exceeds maximum depth (${r}): ${o.join(" → ")}`)}return i}function Ve(e,t,r){const n=Ie(e),o=_e(e),i={...t};for(const[e,t]of o)i[e]=t;for(const[t,i]of o)Be(t,i,e,n,r);for(const e of Object.keys(i))Ge(e,i)}function qe(e,t){if(e.startsWith("@@"))throw new Error(`[router.${t}] Route name "${e}" uses the reserved "@@" prefix. Routes with this prefix are internal and cannot be modified through the public API.`)}function ze(e,t){for(const r of e)r&&"object"==typeof r&&"string"==typeof r.name&&(qe(r.name,t),r.children&&ze(r.children,t))}function We(e){for(const t of e){if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`[router.addRoute] Route must be an object, got ${N(t)}`);xe(t,t.name)}}function Qe(e,t,r){if(!A(e))throw new TypeError(`[router.${r}] Invalid routeName: ${N(e)}. Expected string.`);if(!$(t))throw new TypeError(`[router.${r}] Invalid routeParams: ${N(t)}. Expected plain object.`)}function He(e,t){if("AsyncFunction"===e.constructor.name||e.toString().includes("__awaiter"))throw new TypeError(`[real-router] updateRoute: ${t} cannot be an async function`)}function Je(e,t){if(null!=e){if("function"!=typeof e)throw new TypeError(`[real-router] updateRoute: ${t} must be a function or null, got ${typeof e}`);He(e,t)}}function Ye(e,t,r,n){if(n&&t){let e=t;for(const t of n.split("."))if(e=e.children.get(t),!e)throw new Error(`[router.addRoute] Parent route "${n}" does not exist`)}const o=new Set,i=new Map;for(const r of e)Fe(r,"addRoute",t,n??"",o,i);t&&r&&Ve(e,r,t)}function Ze(t){return!t||(e.logger.error("router.clearRoutes","Cannot clear routes while navigation is in progress. Wait for navigation to complete."),!1)}function Ke(e,t,r,n,o){if(!r(e))throw new ReferenceError(`[real-router] updateRoute: route "${e}" does not exist`);if(null!=t&&"string"==typeof t){if(!r(t))throw new Error(`[real-router] updateRoute: forwardTo target "${t}" does not exist`);(function(e,t,r){const n=r.getSegmentsByName(e),o=r.getSegmentsByName(t),i=function(e){const t=new Set;for(const r of e)for(const e of r.paramMeta.urlParams)t.add(e);return t}(n),a=[];for(const e of o)for(const t of e.paramMeta.urlParams)a.push(t);const s=a.filter(e=>!i.has(e));if(s.length>0)throw new Error(`[real-router] forwardTo target "${t}" requires params [${s.join(", ")}] that are not available in source route "${e}"`)})(e,t,n),function(e,t,r){Ge(e,{...r.forwardMap,[e]:t})}(e,t,o)}}function Xe(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function et(e){const t={name:e.name,path:e.path};return e.children&&(t.children=e.children.map(e=>et(e))),t}function tt(e,t,r=""){for(let n=0;n<e.length;n++){const o=e[n],i=r?`${r}.${o.name}`:o.name;if(i===t)return e.splice(n,1),!0;if(o.children&&t.startsWith(`${i}.`)&&tt(o.children,t,i))return!0}return!1}function rt(e,t){for(const r of Object.keys(e))t(r)&&delete e[r]}var nt=new Set;function ot(e,t,r){const n=$e("",t,e),o=Oe(r);return o.registerTree(n),{tree:n,matcher:o}}function it(e,t){const r=ot(e.definitions,e.rootPath,e.matcherOptions);e.tree=r.tree,e.matcher=r.matcher,e.resolvedForwardMap=ut(e.config,t)}function at(e){const t=ot(e.definitions,e.rootPath,e.matcherOptions);e.tree=t.tree,e.matcher=t.matcher}function st(e){ct(e),at(e)}function ct(e){e.definitions.length=0,Object.assign(e.config,Xe()),e.resolvedForwardMap=Object.create(null),e.routeCustomFields=Object.create(null)}function ut(e,t){return t?lt(e):dt(e)}function dt(e){const t=Object.create(null);for(const r of Object.keys(e.forwardMap))t[r]=Ge(r,e.forwardMap);return t}function lt(e){const t=Object.create(null);for(const r of Object.keys(e.forwardMap)){let n=r;for(;e.forwardMap[n];)n=e.forwardMap[n];t[r]=n}return t}function ft(t,r,n,o,i,a,s){const c=new Set(["name","path","children","canActivate","canDeactivate","forwardTo","encodeParams","decodeParams","defaultParams"]),u=Object.fromEntries(Object.entries(t).filter(([e])=>!c.has(e)));Object.keys(u).length>0&&(o[r]=u),t.canActivate&&(s?s.addActivateGuard(r,t.canActivate):i.set(r,t.canActivate)),t.canDeactivate&&(s?s.addDeactivateGuard(r,t.canDeactivate):a.set(r,t.canDeactivate)),t.forwardTo&&function(t,r,n){if(t.canActivate&&e.logger.warn("real-router",`Route "${r}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${"string"==typeof t.forwardTo?t.forwardTo:"[dynamic]"}".`),t.canDeactivate&&e.logger.warn("real-router",`Route "${r}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${"string"==typeof t.forwardTo?t.forwardTo:"[dynamic]"}".`),"function"==typeof t.forwardTo){const e="AsyncFunction"===t.forwardTo.constructor.name,n=t.forwardTo.toString().includes("__awaiter");if(e||n)throw new TypeError(`forwardTo callback cannot be async for route "${r}". Async functions break matchPath/buildPath.`)}"string"==typeof t.forwardTo?n.forwardMap[r]=t.forwardTo:n.forwardFnMap[r]=t.forwardTo}(t,r,n),t.decodeParams&&(n.decoders[r]=e=>t.decodeParams?.(e)??e),t.encodeParams&&(n.encoders[r]=e=>t.encodeParams?.(e)??e),t.defaultParams&&(n.defaultParams[r]=t.defaultParams)}function ht(e,t,r,n,o,i,a=""){for(const s of e){const e=a?`${a}.${s.name}`:s.name;ft(s,e,t,r,n,o,i),s.children&&ht(s.children,t,r,n,o,i,e)}}function pt(e,t,r=""){for(const n of e){const e=r?`${r}.${n.name}`:n.name;if(e===t)return n;if(n.children&&t.startsWith(`${e}.`))return pt(n.children,t,e)}}function mt(e,t,r,n){const o={name:e.name,path:e.path},i=r.forwardFnMap[t],a=r.forwardMap[t];void 0!==i?o.forwardTo=i:void 0!==a&&(o.forwardTo=a),t in r.defaultParams&&(o.defaultParams=r.defaultParams[t]),t in r.decoders&&(o.decodeParams=r.decoders[t]),t in r.encoders&&(o.encodeParams=r.encoders[t]);const[s,c]=n;return t in c&&(o.canActivate=c[t]),t in s&&(o.canDeactivate=s[t]),e.children&&(o.children=e.children.map(e=>mt(e,`${t}.${e.name}`,r,n))),o}function gt(e,t,r,n){if(n){const t=pt(e.definitions,n);t.children??=[];for(const e of r)t.children.push(et(e))}else for(const t of r)e.definitions.push(et(t));ht(r,e.config,e.routeCustomFields,e.pendingCanActivate,e.pendingCanDeactivate,e.depsStore,n??""),e.treeOperations.commitTreeChanges(e,t)}function vt(e,t,r){return!!tt(e.definitions,r)&&(function(e,t,r,n){const o=t=>t===e||t.startsWith(`${e}.`);rt(t.decoders,o),rt(t.encoders,o),rt(t.defaultParams,o),rt(t.forwardMap,o),rt(t.forwardFnMap,o),rt(r,o),rt(t.forwardMap,e=>o(t.forwardMap[e]));const[i,a]=n.getFactories();for(const e of Object.keys(a))o(e)&&n.clearCanActivate(e);for(const e of Object.keys(i))o(e)&&n.clearCanDeactivate(e)}(r,e.config,e.routeCustomFields,e.lifecycleNamespace),e.treeOperations.commitTreeChanges(e,t),!0)}function wt(e,t){const r=e.matcher.getSegmentsByName(t);if(!r)return;const n=r.at(-1),o=e.treeOperations.nodeToDefinition(n),i=e.lifecycleNamespace.getFactories();return mt(o,t,e.config,i)}function yt(e,t){if("string"!=typeof e)throw new TypeError(`[router.${t}]: dependency name must be a string, got ${typeof e}`)}function bt(e,t){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${t}] Invalid argument: expected plain object, received ${N(e)}`);for(const r in e)if(Object.getOwnPropertyDescriptor(e,r)?.get)throw new TypeError(`[router.${t}] Getters not allowed: "${r}"`)}function St(e,t){if(!O(e)&&"function"!=typeof e)throw new TypeError(`[router.${t}] Handler must be a boolean or factory function, got ${N(e)}`)}function Tt(e,t,r){if(e)throw new Error(`[router.${r}] Cannot modify route "${t}" during its own registration`)}function Et(e,t,r=v.maxLifecycleHandlers){if(0!==r&&e>=r)throw new Error(`[router.${t}] Lifecycle handler limit exceeded (${r}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`)}function Pt(e){const t=G(e),r=t.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,n){U(t.isDisposed),t.noValidate||(R(e,"addActivateGuard"),St(n,"addActivateGuard")),r.addCanActivate(e,n,t.noValidate)},addDeactivateGuard(e,n){U(t.isDisposed),t.noValidate||(R(e,"addDeactivateGuard"),St(n,"addDeactivateGuard")),r.addCanDeactivate(e,n,t.noValidate)},removeActivateGuard(e){U(t.isDisposed),t.noValidate||R(e,"removeActivateGuard"),r.clearCanActivate(e)},removeDeactivateGuard(e){U(t.isDisposed),t.noValidate||R(e,"removeDeactivateGuard"),r.clearCanDeactivate(e)}}}var $t={maxListeners:0,warnListeners:0,maxEventDepth:0},At=class extends Error{},Ot=class{#e=new Map;#t=null;#o=$t;#a;#r;constructor(e){e?.limits&&(this.#o=e.limits),this.#a=e?.onListenerError??null,this.#r=e?.onListenerWarn??null}static validateCallback(e,t){if("function"!=typeof e)throw new TypeError(`Expected callback to be a function for event ${t}`)}setLimits(e){this.#o=e}on(e,t){const r=this.#n(e);if(r.has(t))throw new Error(`Duplicate listener for "${e}"`);const{maxListeners:n,warnListeners:o}=this.#o;if(0!==o&&r.size===o&&this.#r?.(e,o),0!==n&&r.size>=n)throw new Error(`Listener limit (${n}) reached for "${e}"`);return r.add(t),()=>{this.off(e,t)}}off(e,t){this.#e.get(e)?.delete(t)}emit(e,...t){const r=this.#e.get(e);r&&0!==r.size&&(0!==this.#o.maxEventDepth?this.#i(r,e,t):this.#c(r,e,t))}clearAll(){this.#e.clear(),this.#t=null}listenerCount(e){return this.#e.get(e)?.size??0}#c(e,t,r){const n=[...e];for(const e of n)try{this.#u(e,r)}catch(e){this.#a?.(t,e)}}#u(e,t){switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;case 3:e(t[0],t[1],t[2]);break;default:Function.prototype.apply.call(e,void 0,t)}}#i(e,t,r){this.#t??=new Map;const n=this.#t,o=n.get(t)??0;if(o>=this.#o.maxEventDepth)throw new At(`Maximum recursion depth (${this.#o.maxEventDepth}) exceeded for event: ${t}`);try{n.set(t,o+1);const i=[...e];for(const e of i)try{this.#u(e,r)}catch(e){if(e instanceof At)throw e;this.#a?.(t,e)}}finally{n.set(t,n.get(t)-1)}}#n(e){const t=this.#e.get(e);if(t)return t;const r=new Set;return this.#e.set(e,r),r}},Dt="IDLE",Rt="STARTING",Nt="READY",Ct="TRANSITIONING",jt="DISPOSED",Ft="START",xt="STARTED",Lt="NAVIGATE",Mt="COMPLETE",kt="FAIL",It="CANCEL",_t="STOP",Ut="DISPOSE",Bt={initial:Dt,context:null,transitions:{[Dt]:{[Ft]:Rt,[Ut]:jt},[Rt]:{[xt]:Nt,[kt]:Dt},[Nt]:{[Lt]:Ct,[kt]:Nt,[_t]:Dt},[Ct]:{[Lt]:Ct,[Mt]:Nt,[It]:Nt,[kt]:Nt},[jt]:{}}},Gt={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0,noValidate:!1},Vt={trailingSlash:["strict","never","always","preserve"],queryParamsMode:["default","strict","loose"],urlParamsEncoding:["default","uri","uriComponent","none"]},qt={arrayFormat:["none","brackets","index","comma"],booleanFormat:["none","string","empty-true"],nullFormat:["default","hidden"]};function zt(e){Object.freeze(e);for(const t of Object.keys(e)){const r=e[t];r&&"object"==typeof r&&r.constructor===Object&&zt(r)}return e}function Wt(e,t){return"function"==typeof e?e(t):e}function Qt(e,t,r){if("function"==typeof t&&("defaultRoute"===e||"defaultParams"===e))return;const n=Gt[e];if(n&&"object"==typeof n)return function(e,t,r){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${r}] Invalid type for "${t}": expected plain object, got ${N(e)}`);for(const n in e)if(Object.getOwnPropertyDescriptor(e,n)?.get)throw new TypeError(`[router.${r}] Getters not allowed in "${t}": "${n}"`)}(t,e,r),void("queryParams"===e&&function(e,t){for(const r in e){if(!D(r,qt)){const e=Object.keys(qt).map(e=>`"${e}"`).join(", ");throw new TypeError(`[router.${t}] Unknown queryParams key: "${r}". Valid keys: ${e}`)}const n=e[r],o=qt[r];if(!o.includes(n)){const e=o.map(e=>`"${e}"`).join(", ");throw new TypeError(`[router.${t}] Invalid value for queryParams.${r}: expected one of ${e}, got "${String(n)}"`)}}}(t,r));if(typeof t!=typeof n)throw new TypeError(`[router.${r}] Invalid type for "${e}": expected ${typeof n}, got ${typeof t}`);e in Vt&&function(e,t,r){const n=Vt[e];if(!n.includes(t)){const o=n.map(e=>`"${e}"`).join(", ");throw new TypeError(`[router.${r}] Invalid value for "${e}": expected one of ${o}, got "${String(t)}"`)}}(e,t,r)}function Ht(e,t,r){if("limits"===e)return void 0!==t&&function(e,t){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${t}]: invalid limits: expected plain object, got ${typeof e}`);for(const[r,n]of Object.entries(e)){if(!Object.hasOwn(w,r))throw new TypeError(`[router.${t}]: unknown limit: "${r}"`);void 0!==n&&Jt(r,n,t)}}(t,r),!0;throw new TypeError(`[router.${r}] Unknown option: "${e}"`)}function Jt(e,t,r){if("number"!=typeof t||!Number.isInteger(t))throw new TypeError(`[router.${r}]: limit "${e}" must be an integer, got ${String(t)}`);const n=w[e];if(t<n.min||t>n.max)throw new RangeError(`[router.${r}]: limit "${e}" must be between ${n.min} and ${n.max}, got ${t}`)}var Yt=class{#y;constructor(e={}){this.#y=zt({...Gt,...e})}static validateOptions(e,t){!function(e,t){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${t}] Invalid options: expected plain object, got ${N(e)}`);for(const[r,n]of Object.entries(e))D(r,Gt)?void 0!==n&&Qt(r,n,t):Ht(r,n,t)}(e,t)}get(){return this.#y}};function Zt(e,t){return e===t||!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every((e,r)=>Zt(e,t[r]))}var Kt,Xt,er=class{#b=0;#S=void 0;#T=void 0;#E;#P=new Map;static validateAreStatesEqualArgs(e,t,r){if(null!=e&&C(e,"areStatesEqual"),null!=t&&C(t,"areStatesEqual"),void 0!==r&&"boolean"!=typeof r)throw new TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${N(r)}. Expected boolean.`)}get(){return this.#S}set(e){this.#T=this.#S,this.#S=e?x(e):void 0}getPrevious(){return this.#T}reset(){this.#S=void 0,this.#T=void 0,this.#P.clear(),this.#b=0}setDependencies(e){this.#E=e}makeState(e,t,r,n,o){const i=n?{...n,id:o??++this.#b,params:n.params}:void 0,a=this.#E.getDefaultParams();let s;return s=Object.hasOwn(a,e)?{...a[e],...t}:t?{...t}:{},x({name:e,params:s,path:r??this.#E.buildPath(e,t),meta:i})}areStatesEqual(e,t,r=!0){if(!e||!t)return!!e==!!t;if(e.name!==t.name)return!1;if(r){const r=e.meta?.params??t.meta?.params;return(r?function(e){const t=[];for(const r in e){const n=e[r];for(const e in n)"url"===n[e]&&t.push(e)}return t}(r):this.#$(e.name)).every(r=>Zt(e.params[r],t.params[r]))}const n=Object.keys(e.params),o=Object.keys(t.params);return n.length===o.length&&n.every(r=>r in t.params&&Zt(e.params[r],t.params[r]))}#$(e){const t=this.#P.get(e);if(void 0!==t)return t;const r=this.#E.getUrlParams(e);return this.#P.set(e,r),r}},tr={[o]:d,[i]:l,[c]:p,[a]:f,[u]:m,[s]:h},rr=Object.keys(tr).filter(e=>D(e,tr)),nr="router.usePlugin",or=class t{#A=new Set;#O=new Set;#E;#D=v;static validateUsePluginArgs(e){!function(e){for(const[t,r]of e.entries())if("function"!=typeof r)throw new TypeError(`[router.usePlugin] Expected plugin factory function at index ${t}, got ${N(r)}`)}(e)}static validatePlugin(e){!function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError(`[router.usePlugin] Plugin factory must return an object, got ${N(e)}`);if("function"==typeof e.then)throw new TypeError("[router.usePlugin] Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.");for(const t in e)if("teardown"!==t&&!D(t,tr))throw new TypeError(`[router.usePlugin] Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`)}(e)}static validatePluginLimit(e,t,r){!function(e,t,r=v.maxPlugins){if(0!==r&&e+t>r)throw new Error(`[router.usePlugin] Plugin limit exceeded (${r}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`)}(e,t,r)}static validateNoDuplicatePlugins(e,t){for(const r of e)if(t(r))throw new Error("[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.")}setDependencies(e){this.#E=e}setLimits(e){this.#D=e}count(){return this.#A.size}use(...t){if(this.#R(t.length),1===t.length){const r=t[0],n=this.#N(r);this.#A.add(r);let o=!1;const i=()=>{if(!o){o=!0,this.#A.delete(r),this.#O.delete(i);try{n()}catch(t){e.logger.error(nr,"Error during cleanup:",t)}}};return this.#O.add(i),i}const r=this.#C(t),n=[];try{for(const e of r){const t=this.#N(e);n.push({factory:e,cleanup:t})}}catch(t){for(const{cleanup:t}of n)try{t()}catch(t){e.logger.error(nr,"Cleanup error:",t)}throw t}for(const{factory:e}of n)this.#A.add(e);let o=!1;const i=()=>{if(!o){o=!0,this.#O.delete(i);for(const{factory:e}of n)this.#A.delete(e);for(const{cleanup:t}of n)try{t()}catch(t){e.logger.error(nr,"Error during cleanup:",t)}}};return this.#O.add(i),i}getAll(){return[...this.#A]}has(e){return this.#A.has(e)}disposeAll(){for(const e of this.#O)e();this.#A.clear(),this.#O.clear()}#R(t){const r=this.#D.maxPlugins;if(0===r)return;const n=t+this.#A.size,{warn:o,error:i}=L(r);n>=i?e.logger.error(nr,`${n} plugins registered! This is excessive and will impact performance. Hard limit at ${r}.`):n>=o&&e.logger.warn(nr,`${n} plugins registered. Consider if all are necessary.`)}#C(t){const r=new Set;for(const n of t)r.has(n)?e.logger.warn(nr,"Duplicate factory in batch, will be registered once"):r.add(n);return r}#N(r){const n=this.#E.compileFactory(r);t.validatePlugin(n),Object.freeze(n);const o=[];for(const t of rr)t in n&&("function"==typeof n[t]?(o.push(this.#E.addEventListener(tr[t],n[t])),"onStart"===t&&this.#E.canNavigate()&&e.logger.warn(nr,"Router already started, onStart will not be called")):e.logger.warn(nr,`Property '${t}' is not a function, skipping`));return()=>{for(const e of o)e();"function"==typeof n.teardown&&n.teardown()}}},ir=class{#j=new Map;#F=new Map;#x=new Map;#L=new Map;#M=new Set;#k=new Set;#I=new Set;#E;#D=v;setDependencies(e){this.#E=e}setLimits(e){this.#D=e}addCanActivate(e,t,r,n=!1){n?this.#k.add(e):this.#k.delete(e),r||Tt(this.#M.has(e),e,"addActivateGuard");const o=this.#F.has(e);o||r||Et(this.#F.size+1,"addActivateGuard",this.#D.maxLifecycleHandlers),this.#_("activate",e,t,this.#F,this.#L,"canActivate",o)}addCanDeactivate(e,t,r,n=!1){n?this.#I.add(e):this.#I.delete(e),r||Tt(this.#M.has(e),e,"addDeactivateGuard");const o=this.#j.has(e);o||r||Et(this.#j.size+1,"addDeactivateGuard",this.#D.maxLifecycleHandlers),this.#_("deactivate",e,t,this.#j,this.#x,"canDeactivate",o)}clearCanActivate(e){this.#F.delete(e),this.#L.delete(e),this.#k.delete(e)}clearCanDeactivate(e){this.#j.delete(e),this.#x.delete(e),this.#I.delete(e)}clearAll(){this.#F.clear(),this.#L.clear(),this.#j.clear(),this.#x.clear(),this.#k.clear(),this.#I.clear()}clearDefinitionGuards(){for(const e of this.#k)this.#F.delete(e),this.#L.delete(e);for(const e of this.#I)this.#j.delete(e),this.#x.delete(e);this.#k.clear(),this.#I.clear()}getFactories(){const e={},t={};for(const[t,r]of this.#j)e[t]=r;for(const[e,r]of this.#F)t[e]=r;return[e,t]}getFunctions(){return[this.#x,this.#L]}canNavigateTo(e,t,r,n){for(const t of e)if(!this.#U(this.#x,t,r,n,"canNavigateTo"))return!1;for(const e of t)if(!this.#U(this.#L,e,r,n,"canNavigateTo"))return!1;return!0}#_(t,r,n,o,i,a,s){s?e.logger.warn(`router.${a}`,`Overwriting existing ${t} handler for route "${r}"`):this.#R(o.size+1,a);const c=O(n)?function(e){const t=()=>e;return()=>t}(n):n;o.set(r,c),this.#M.add(r);try{const e=this.#E.compileFactory(c);if("function"!=typeof e)throw new TypeError(`[router.${a}] Factory must return a function, got ${N(e)}`);i.set(r,e)}catch(e){throw o.delete(r),e}finally{this.#M.delete(r)}}#U(t,r,n,o,i){const a=t.get(r);if(!a)return!0;try{const t=a(n,o);return"boolean"==typeof t?t:(e.logger.warn(`router.${i}`,`Guard for "${r}" returned a Promise. Sync check cannot resolve async guards — returning false.`),!1)}catch{return!1}}#R(t,r){const n=this.#D.maxLifecycleHandlers;if(0===n)return;const{warn:o,error:i}=L(n);t>=i?e.logger.error(`router.${r}`,`${t} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):t>=o&&e.logger.warn(`router.${r}`,`${t} lifecycle handlers registered. Consider consolidating logic.`)}},ar=".";function sr(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t}function cr(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t}function ur(e,t,r){const n=t.meta?.params[e];if(!n||"object"!=typeof n)return!0;for(const e of Object.keys(n)){const n=t.params[e],o=r.params[e];if(cr(n)&&cr(o)&&String(n)!==String(o))return!1}return!0}function dr(e){if(!e)return[""];const t=e.indexOf(ar);if(-1===t)return[e];const r=e.indexOf(ar,t+1);if(-1===r)return[e.slice(0,t),e];const n=e.indexOf(ar,r+1);return-1===n?[e.slice(0,t),e.slice(0,r),e]:-1===e.indexOf(ar,n+1)?[e.slice(0,t),e.slice(0,r),e.slice(0,n),e]:function(e){const t=e.split(ar),r=t.length,n=[t[0]];let o=t[0].length;for(let i=1;i<r-1;i++)o+=1+t[i].length,n.push(e.slice(0,o));return n.push(e),n}(e)}var lr=null;function fr(e,t){if(!t)return{intersection:"",toActivate:dr(e.name),toDeactivate:[]};if(void 0===e.meta?.params&&void 0===t.meta?.params)return{intersection:"",toActivate:dr(e.name),toDeactivate:sr(dr(t.name))};const r=dr(e.name),n=dr(t.name),o=function(e,t,r,n,o){for(let i=0;i<o;i++){const o=r[i];if(o!==n[i])return i;if(!ur(o,e,t))return i}return o}(e,t,r,n,Math.min(n.length,r.length)),i=[];for(let e=n.length-1;e>=o;e--)i.push(n[e]);const a=r.slice(o);return{intersection:o>0?n[o-1]:"",toDeactivate:i,toActivate:a}}function hr(e,t,r){if(r?.reload)return fr(e,t);if(null!==lr&&e===Kt&&t===Xt)return lr;const n=fr(e,t);return Kt=e,Xt=t,lr=n,n}function pr(e,t){var r;return{name:t??(r=e.segments,r.at(-1)?.fullName??""),params:e.params,meta:e.meta}}var mr=class{#B;get#E(){return this.#B.depsStore}constructor(e=[],t=!1,r){this.#B=function(e,t,r){const n=[],o=Xe(),i=Object.create(null),a=new Map,s=new Map;for(const t of e)n.push(et(t));const{tree:c,matcher:u}=ot(n,"",r);return ht(e,o,i,a,s,void 0,""),{definitions:n,config:o,tree:c,matcher:u,resolvedForwardMap:t?lt(o):dt(o),routeCustomFields:i,rootPath:"",matcherOptions:r,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:a,pendingCanDeactivate:s,treeOperations:{commitTreeChanges:it,resetStore:st,nodeToDefinition:Ae,validateRoutes:Ye}}}(e,t,r)}static shouldUpdateNode(e){return(t,r)=>{if(!t||"object"!=typeof t||!("name"in t))throw new TypeError("[router.shouldUpdateNode] toState must be valid State object");if(t.transition?.reload)return!0;if(""===e&&!r)return!0;const{intersection:n,toActivate:o,toDeactivate:i}=hr(t,r);return e===n||!!o.includes(e)||i.includes(e)}}setDependencies(e){this.#B.depsStore=e;for(const[t,r]of this.#B.pendingCanActivate)e.addActivateGuard(t,r);this.#B.pendingCanActivate.clear();for(const[t,r]of this.#B.pendingCanDeactivate)e.addDeactivateGuard(t,r);this.#B.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#B.lifecycleNamespace=e}setRootPath(e){this.#B.rootPath=e,at(this.#B)}hasRoute(e){return this.#B.matcher.hasRoute(e)}clearRoutes(){st(this.#B)}buildPath(e,t,r){if(e===n)return A(t?.path)?t.path:"";const o=Object.hasOwn(this.#B.config.defaultParams,e)?{...this.#B.config.defaultParams[e],...t}:t??{},i="function"==typeof this.#B.config.encoders[e]?this.#B.config.encoders[e]({...o}):o,a=r?.trailingSlash;return this.#B.matcher.buildPath(e,i,{trailingSlash:"never"===a||"always"===a?a:void 0,queryParamsMode:r?.queryParamsMode})}matchPath(e,t){const r=t,n=this.#B.matcher.match(e);if(!n)return;const o=pr(n),{name:i,params:a,meta:s}=o,c="function"==typeof this.#B.config.decoders[i]?this.#B.config.decoders[i](a):a,{name:u,params:d}=this.#E.forwardState(i,c);let l=e;if(r.rewritePathOnMatch){const e="function"==typeof this.#B.config.encoders[u]?this.#B.config.encoders[u]({...d}):d,t=r.trailingSlash;l=this.#B.matcher.buildPath(u,e,{trailingSlash:"never"===t||"always"===t?t:void 0,queryParamsMode:r.queryParamsMode})}return this.#E.makeState(u,d,l,{params:s})}forwardState(e,t){if(Object.hasOwn(this.#B.config.forwardFnMap,e)){const r=this.#G(e,t),n=this.#B.config.forwardFnMap[e],o=this.#V(e,n,t);return{name:o,params:this.#G(o,r)}}const r=this.#B.resolvedForwardMap[e]??e;if(r!==e&&Object.hasOwn(this.#B.config.forwardFnMap,r)){const n=this.#G(e,t),o=this.#B.config.forwardFnMap[r],i=this.#V(r,o,t);return{name:i,params:this.#G(i,n)}}if(r!==e){const n=this.#G(e,t);return{name:r,params:this.#G(r,n)}}return{name:e,params:this.#G(e,t)}}buildStateResolved(e,t){const r=this.#B.matcher.getSegmentsByName(e);if(r)return pr({segments:r,params:t,meta:this.#B.matcher.getMetaByName(e)},e)}buildStateWithSegmentsResolved(e,t){const r=this.#B.matcher.getSegmentsByName(e);if(r)return{state:pr({segments:r,params:t,meta:this.#B.matcher.getMetaByName(e)},e),segments:r}}isActiveRoute(e,t={},r=!1,n=!0){nt.has(e)||(R(e,"isActiveRoute"),nt.add(e));const o=this.#E.getState();if(!o)return!1;const i=o.name;if(i!==e&&!i.startsWith(`${e}.`)&&!e.startsWith(`${i}.`))return!1;const a=this.#B.config.defaultParams[e];if(r||i===e){const r=a?{...a,...t}:t;return this.#E.areStatesEqual({name:e,params:r,path:""},o,n)}const s=o.params;return!!function(e,t){for(const r in e)if(e[r]!==t[r])return!1;return!0}(t,s)&&(!a||function(e,t,r){for(const n in e)if(!(n in r)&&e[n]!==t[n])return!1;return!0}(a,s,t))}getUrlParams(e){const t=this.#B.matcher.getSegmentsByName(e);return t?function(e){const t=[];for(const r of e)for(const e of r.paramMeta.urlParams)t.push(e);return t}(t):[]}getStore(){return this.#B}#G(e,t){return Object.hasOwn(this.#B.config.defaultParams,e)?{...this.#B.config.defaultParams[e],...t}:t}#V(e,t,r){const n=new Set([e]);let o=t(this.#E.getDependency,r),i=0;if("string"!=typeof o)throw new TypeError("forwardTo callback must return a string, got "+typeof o);for(;i<100;){if(void 0===this.#B.matcher.getSegmentsByName(o))throw new Error(`Route "${o}" does not exist`);if(n.has(o)){const e=[...n,o].join(" → ");throw new Error(`Circular forwardTo detected: ${e}`)}if(n.add(o),Object.hasOwn(this.#B.config.forwardFnMap,o)){o=(0,this.#B.config.forwardFnMap[o])(this.#E.getDependency,r),i++;continue}const e=this.#B.config.forwardMap[o];if(void 0===e)return o;o=e,i++}throw new Error("forwardTo exceeds maximum depth of 100")}};function gr(e,t,r){if(e instanceof _)throw e.setCode(t),e;throw new _(t,function(e,t){const r={segment:t};if(e instanceof Error)return{...r,message:e.message,stack:e.stack,..."cause"in e&&void 0!==e.cause&&{cause:e.cause}};if(e&&"object"==typeof e){const t={};for(const[r,n]of Object.entries(e))vr.has(r)||(t[r]=n);return{...r,...t}}return r}(e,r))}var vr=new Set(["code","segment","path","redirect"]);async function wr(e,t,n,o,i,a,s){const c=o.filter(t=>e.has(t));if(0===c.length)return;let u;for(const o of c){if(a())throw new _(r.TRANSITION_CANCELLED);const c=e.get(o);try{u=await c(t,n,s)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw new _(r.TRANSITION_CANCELLED,{reason:s.reason});gr(e,i,o)}if(!u)throw new _(i,{segment:o})}}var yr=[n];Object.freeze(yr);var br={replace:!0};Object.freeze(br);var Sr=class{#E;#q=null;static validateNavigateArgs(e){!function(e){if("string"!=typeof e)throw new TypeError(`[router.navigate] Invalid route name: expected string, got ${N(e)}`)}(e)}static validateNavigateToDefaultArgs(e){!function(e){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`[router.navigateToDefault] Invalid options: ${N(e)}. Expected NavigationOptions object.`)}(e)}static validateNavigationOptions(e,t){!function(e,t){if(!function(e){if("object"!=typeof e||null===e||Array.isArray(e))return!1;const t=e;for(const e of y){const r=t[e];if(void 0!==r&&"boolean"!=typeof r)return!1}const r=t.signal;return!(void 0!==r&&!(r instanceof AbortSignal))}(e))throw new TypeError(`[router.${t}] Invalid options: ${N(e)}. Expected NavigationOptions object.`)}(e,t)}setDependencies(e){this.#E=e}async navigate(e,t,o){if(!this.#E.canNavigate())throw new _(r.ROUTER_NOT_STARTED);const i=this.#E,a=i.buildStateWithSegments(e,t);if(!a){const e=new _(r.ROUTE_NOT_FOUND);throw i.emitTransitionError(void 0,i.getState(),e),e}const{state:s}=a,c=i.makeState(s.name,s.params,i.buildPath(s.name,s.params),{params:s.meta}),u=i.getState();if(o=function(e,t){return t?.name!==n||e.replace?e:{...e,replace:!0}}(o,u),u&&!o.reload&&!o.force&&i.areStatesEqual(u,c,!1)){const e=new _(r.SAME_STATES);throw i.emitTransitionError(c,u,e),e}this.#z();const d=new AbortController;if(this.#q=d,o.signal){if(o.signal.aborted)throw this.#q=null,new _(r.TRANSITION_CANCELLED,{reason:o.signal.reason});o.signal.addEventListener("abort",()=>{d.abort(o.signal?.reason)},{once:!0,signal:d.signal})}i.startTransition(c,u);try{const{state:e,meta:t}=await async function(e,t,o,i,a){const[s,c]=e.getLifecycleFunctions(),u=t.name===n,d=()=>a.aborted||!e.isActive(),{toDeactivate:l,toActivate:f,intersection:h}=hr(t,o,void 0===i.reload?void 0:{reload:i.reload}),p=!u&&f.length>0;if(o&&!i.forceDeactivate&&l.length>0&&await wr(s,t,o,l,r.CANNOT_DEACTIVATE,d,a),d())throw new _(r.TRANSITION_CANCELLED);if(p&&await wr(c,t,o,f,r.CANNOT_ACTIVATE,d,a),d())throw new _(r.TRANSITION_CANCELLED);if(o)for(const t of l)!f.includes(t)&&s.has(t)&&e.clearCanDeactivate(t);return{state:t,meta:{phase:"activating",segments:{deactivated:l,activated:f,intersection:h}}}}(i,c,u,o,d.signal);if(e.name===n||i.hasRoute(e.name)){const r=function(e,t,r,n){const o={phase:t.phase,...void 0!==r?.name&&{from:r.name},reason:"success",segments:t.segments,...void 0!==n.reload&&{reload:n.reload},...void 0!==n.redirected&&{redirected:n.redirected}};return Object.freeze(o.segments.deactivated),Object.freeze(o.segments.activated),Object.freeze(o.segments),Object.freeze(o),{...e,transition:o}}(e,t,u,o);i.setState(r);const n=void 0===o.signal?o:function({signal:e,...t}){return t}(o);return i.sendTransitionDone(r,u,n),r}{const t=new _(r.ROUTE_NOT_FOUND,{routeName:e.name});throw i.sendTransitionFail(e,u,t),t}}catch(e){throw function(e,t,n,o){t.code!==r.TRANSITION_CANCELLED&&t.code!==r.ROUTE_NOT_FOUND&&e.sendTransitionFail(n,o,t)}(i,e,c,u),e}finally{d.abort(),this.#q===d&&(this.#q=null)}}async navigateToDefault(e){const t=this.#E;if(!t.getOptions().defaultRoute)throw new _(r.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"});const{route:n,params:o}=t.resolveDefault();if(!n)throw new _(r.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"});return this.navigate(n,o,e)}navigateToNotFound(e){this.#z();const t=this.#E.getState(),r=t?dr(t.name).toReversed():[];Object.freeze(r);const o={deactivated:r,activated:yr,intersection:""};Object.freeze(o);const i={phase:"activating",...t&&{from:t.name},reason:"success",segments:o};Object.freeze(i);const a={name:n,params:{},path:e,transition:i};return Object.freeze(a),this.#E.setState(a),this.#E.emitTransitionSuccess(a,t,br),a}abortCurrentNavigation(){this.#q?.abort(new _(r.TRANSITION_CANCELLED)),this.#q=null}#z(){this.#E.isTransitioning()&&(e.logger.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request."),this.#q?.abort(new _(r.TRANSITION_CANCELLED)),this.#E.cancelNavigation())}},Tr={replace:!0};Object.freeze(Tr);var Er=class{#E;static validateStartArgs(e){if(1!==e.length||"string"!=typeof e[0])throw new Error("[router.start] Expected exactly 1 string argument (startPath).")}setDependencies(e){this.#E=e}async start(e){const t=this.#E,n=t.getOptions(),o=t.matchPath(e);if(!o&&!n.allowNotFound){const n=new _(r.ROUTE_NOT_FOUND,{path:e});throw t.emitTransitionError(void 0,void 0,n),n}return t.completeStart(),o?t.navigate(o.name,o.params,Tr):t.navigateToNotFound(e)}stop(){this.#E.clearState()}},Pr=class{#W;#Q;#H;constructor(e){this.#W=e.routerFSM,this.#Q=e.emitter,this.#H=void 0,this.#J()}static validateSubscribeListener(e){if("function"!=typeof e)throw new TypeError("[router.subscribe] Expected a function. For Observable pattern use @real-router/rx package")}emitRouterStart(){this.#Q.emit(d)}emitRouterStop(){this.#Q.emit(l)}emitTransitionStart(e,t){this.#Q.emit(f,e,t)}emitTransitionSuccess(e,t,r){this.#Q.emit(p,e,t,r)}emitTransitionError(e,t,r){this.#Q.emit(m,e,t,r)}emitTransitionCancel(e,t){this.#Q.emit(h,e,t)}sendStart(){this.#W.send(Ft)}sendStop(){this.#W.send(_t)}sendDispose(){this.#W.send(Ut)}sendStarted(){this.#W.send(xt)}sendNavigate(e,t){this.#H=e,this.#W.send(Lt,{toState:e,fromState:t})}sendComplete(e,t,r={}){const n=this.#H;this.#W.send(Mt,{state:e,fromState:t,opts:r}),this.#H===n&&(this.#H=void 0)}sendFail(e,t,r){const n=this.#H;this.#W.send(kt,{toState:e,fromState:t,error:r}),this.#H===n&&(this.#H=void 0)}sendFailSafe(e,t,r){this.isReady()?this.sendFail(e,t,r):this.emitTransitionError(e,t,r)}sendCancel(e,t){const r=this.#H;this.#W.send(It,{toState:e,fromState:t}),this.#H===r&&(this.#H=void 0)}canBeginTransition(){return this.#W.canSend(Lt)}canStart(){return this.#W.canSend(Ft)}canCancel(){return this.#W.canSend(It)}isActive(){const e=this.#W.getState();return e!==Dt&&e!==jt}isDisposed(){return this.#W.getState()===jt}isTransitioning(){return this.#W.getState()===Ct}isReady(){return this.#W.getState()===Nt}getCurrentToState(){return this.#H}addEventListener(e,t){return this.#Q.on(e,t)}subscribe(e){return this.#Q.on(p,(t,r)=>{e({route:t,previousRoute:r})})}clearAll(){this.#Q.clearAll()}setLimits(e){this.#Q.setLimits(e)}sendCancelIfTransitioning(e){this.canCancel()&&this.sendCancel(this.#H,e)}#J(){const e=this.#W;e.on(Rt,xt,()=>{this.emitRouterStart()}),e.on(Nt,_t,()=>{this.emitRouterStop()}),e.on(Nt,Lt,e=>{this.emitTransitionStart(e.toState,e.fromState)}),e.on(Ct,Mt,e=>{this.emitTransitionSuccess(e.state,e.fromState,e.opts)}),e.on(Ct,It,e=>{this.emitTransitionCancel(e.toState,e.fromState)}),e.on(Rt,kt,e=>{this.emitTransitionError(e.toState,e.fromState,e.error)}),e.on(Nt,kt,e=>{this.emitTransitionError(e.toState,e.fromState,e.error)}),e.on(Ct,kt,e=>{this.emitTransitionError(e.toState,e.fromState,e.error)})}},$r=new _(r.ROUTER_ALREADY_STARTED),Ar=new Set(["all","warn-error","error-only"]);var Or=class{router;options;limits;dependenciesStore;state;routes;routeLifecycle;plugins;navigation;lifecycle;eventBus;constructor(e){this.router=e.router,this.options=e.options,this.limits=e.limits,this.dependenciesStore=e.dependenciesStore,this.state=e.state,this.routes=e.routes,this.routeLifecycle=e.routeLifecycle,this.plugins=e.plugins,this.navigation=e.navigation,this.lifecycle=e.lifecycle,this.eventBus=e.eventBus}wireLimits(){this.dependenciesStore.limits=this.limits,this.plugins.setLimits(this.limits),this.eventBus.setLimits({maxListeners:this.limits.maxListeners,warnListeners:this.limits.warnListeners,maxEventDepth:this.limits.maxEventDepth}),this.routeLifecycle.setLimits(this.limits)}wireRouteLifecycleDeps(){const e={compileFactory:this.createCompileFactory()};this.routeLifecycle.setDependencies(e)}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(e,t)=>{this.routeLifecycle.addCanActivate(e,t,!0,!0)},addDeactivateGuard:(e,t)=>{this.routeLifecycle.addCanDeactivate(e,t,!0,!0)},makeState:(e,t,r,n)=>this.state.makeState(e,t,r,n),getState:()=>this.state.get(),areStatesEqual:(e,t,r)=>this.state.areStatesEqual(e,t,r),getDependency:e=>this.dependenciesStore.dependencies[e],forwardState:(e,t)=>{const r=G(this.router);return r.noValidate||Qe(e,t,"forwardState"),r.forwardState(e,t)}}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wirePluginsDeps(){const e={addEventListener:(e,t)=>this.eventBus.addEventListener(e,t),canNavigate:()=>this.eventBus.canBeginTransition(),compileFactory:this.createCompileFactory()};this.plugins.setDependencies(e)}wireNavigationDeps(){this.navigation.setDependencies({getOptions:()=>this.options.get(),hasRoute:e=>this.routes.hasRoute(e),getState:()=>this.state.get(),setState:e=>{this.state.set(e)},buildStateWithSegments:(e,t)=>{const r=G(this.router);r.noValidate||Qe(e,t,"navigate");const{name:n,params:o}=r.forwardState(e,t);return this.routes.buildStateWithSegmentsResolved(n,o)},makeState:(e,t,r,n)=>this.state.makeState(e,t,r,n),buildPath:(e,t)=>G(this.router).buildPath(e,t),areStatesEqual:(e,t,r)=>this.state.areStatesEqual(e,t,r),resolveDefault:()=>{const e=this.options.get();return{route:Wt(e.defaultRoute,e=>this.dependenciesStore.dependencies[e]),params:Wt(e.defaultParams,e=>this.dependenciesStore.dependencies[e])}},startTransition:(e,t)=>{this.eventBus.sendNavigate(e,t)},cancelNavigation:()=>{this.eventBus.sendCancel(this.eventBus.getCurrentToState(),this.state.get())},sendTransitionDone:(e,t,r)=>{this.eventBus.sendComplete(e,t,r)},sendTransitionFail:(e,t,r)=>{this.eventBus.sendFail(e,t,r)},emitTransitionError:(e,t,r)=>{this.eventBus.sendFailSafe(e,t,r)},emitTransitionSuccess:(e,t,r)=>{this.eventBus.emitTransitionSuccess(e,t,r)},canNavigate:()=>this.eventBus.canBeginTransition(),getLifecycleFunctions:()=>this.routeLifecycle.getFunctions(),isActive:()=>this.router.isActive(),isTransitioning:()=>this.eventBus.isTransitioning(),clearCanDeactivate:e=>{this.routeLifecycle.clearCanDeactivate(e)}})}wireLifecycleDeps(){this.lifecycle.setDependencies({getOptions:()=>this.options.get(),navigate:(e,t,r)=>this.navigation.navigate(e,t,r),navigateToNotFound:e=>this.navigation.navigateToNotFound(e),clearState:()=>{this.state.set(void 0)},matchPath:e=>this.routes.matchPath(e,this.options.get()),completeStart:()=>{this.eventBus.sendStarted()},emitTransitionError:(e,t,r)=>{this.eventBus.sendFail(e,t,r)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getStore().config.defaultParams,buildPath:(e,t)=>G(this.router).buildPath(e,t),getUrlParams:e=>this.routes.getUrlParams(e)})}createCompileFactory(){const{router:e,dependenciesStore:t}=this;return r=>r(e,e=>t.dependencies[e])}},Dr=class n{#y;#D;#Y;#Z;#K;#X;#A;#ee;#te;#re;#ne;constructor(r=[],n={},o={}){n.logger&&function(e){if("object"!=typeof e||null===e)throw new TypeError("Logger config must be an object");const t=e;for(const e of Object.keys(t))if("level"!==e&&"callback"!==e)throw new TypeError(`Unknown logger config property: "${e}"`);if("level"in t&&void 0!==t.level&&("string"!=typeof(r=t.level)||!Ar.has(r)))throw new TypeError(`Invalid logger level: ${function(e){return"string"==typeof e?`"${e}"`:"object"==typeof e?JSON.stringify(e):String(e)}(t.level)}. Expected: "all" | "warn-error" | "error-only"`);var r;if("callback"in t&&void 0!==t.callback&&"function"!=typeof t.callback)throw new TypeError("Logger callback must be a function, got "+typeof t.callback);return!0}(n.logger)&&(e.logger.configure(n.logger),delete n.logger),Yt.validateOptions(n,"constructor");const i=n.noValidate??!1;i||bt(o,"constructor"),!i&&r.length>0&&(We(r),Ye(r)),this.#y=new Yt(n),this.#D=function(e={}){return{...v,...e}}(n.limits),this.#Y=function(e={}){const t=Object.create(null);for(const r in e)void 0!==e[r]&&(t[r]=e[r]);return{dependencies:t,limits:v}}(o),this.#Z=new er,this.#K=new mr(r,i,function(e){return{strictTrailingSlash:"strict"===e.trailingSlash,strictQueryParams:"strict"===e.queryParamsMode,urlParamsEncoding:e.urlParamsEncoding,queryParams:e.queryParams}}(this.#y.get())),this.#X=new ir,this.#A=new or,this.#ee=new Sr,this.#te=new Er,this.#ne=i;const a=new t.FSM(Bt),s=new Ot({onListenerError:(t,r)=>{e.logger.error("Router",`Error in listener for ${t}:`,r)},onListenerWarn:(t,r)=>{e.logger.warn("router.addEventListener",`Event "${t}" has ${r} listeners — possible memory leak`)}});var c;this.#re=new Pr({routerFSM:a,emitter:s}),(c=new Or({router:this,options:this.#y,limits:this.#D,dependenciesStore:this.#Y,state:this.#Z,routes:this.#K,routeLifecycle:this.#X,plugins:this.#A,navigation:this.#ee,lifecycle:this.#te,eventBus:this.#re})).wireLimits(),c.wireRouteLifecycleDeps(),c.wireRoutesDeps(),c.wirePluginsDeps(),c.wireNavigationDeps(),c.wireLifecycleDeps(),c.wireStateDeps();const u=new Map;var d;d={makeState:(e,t,r,n,o)=>this.#Z.makeState(e,t,r,n,o),forwardState:V("forwardState",(e,t)=>this.#K.forwardState(e,t),u),buildStateResolved:(e,t)=>this.#K.buildStateResolved(e,t),matchPath:(e,t)=>this.#K.matchPath(e,t),getOptions:()=>this.#y.get(),addEventListener:(e,t)=>this.#re.addEventListener(e,t),buildPath:V("buildPath",(e,t)=>this.#K.buildPath(e,t??{},this.#y.get()),u),start:V("start",e=>(i||Er.validateStartArgs([e]),this.#te.start(e)),u),interceptors:u,setRootPath:e=>{this.#K.setRootPath(e)},getRootPath:()=>this.#K.getStore().rootPath,getTree:()=>this.#K.getStore().tree,isDisposed:()=>this.#re.isDisposed(),noValidate:i,dependenciesGetStore:()=>this.#Y,cloneOptions:()=>({...this.#y.get()}),cloneDependencies:()=>({...this.#Y.dependencies}),getLifecycleFactories:()=>this.#X.getFactories(),getPluginFactories:()=>this.#A.getAll(),routeGetStore:()=>this.#K.getStore(),getStateName:()=>this.#Z.get()?.name,isTransitioning:()=>this.#re.isTransitioning(),clearState:()=>{this.#Z.set(void 0)},setState:e=>{this.#Z.set(e)},routerExtensions:[]},B.set(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)}isActiveRoute(t,r,n,o){return this.#ne||function(e,t,r,n){if(!A(e))throw new TypeError("Route name must be a string");if(void 0!==t&&!$(t))throw new TypeError("[router.isActiveRoute] Invalid params structure");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError("[router.isActiveRoute] strictEquality must be a boolean, got "+typeof r);if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("[router.isActiveRoute] ignoreQueryParams must be a boolean, got "+typeof n)}(t,r,n,o),""===t?(e.logger.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#K.isActiveRoute(t,r,n,o)}buildPath(e,t){return this.#ne||function(e){if(!A(e)||""===e)throw new TypeError("[real-router] buildPath: route must be a non-empty string, got "+("string"==typeof e?'""':typeof e))}(e),G(this).buildPath(e,t)}getState(){return this.#Z.get()}getPreviousState(){return this.#Z.getPrevious()}areStatesEqual(e,t,r=!0){return this.#ne||er.validateAreStatesEqualArgs(e,t,r),this.#Z.areStatesEqual(e,t,r)}shouldUpdateNode(e){return this.#ne||function(e){if(!A(e))throw new TypeError("[router.shouldUpdateNode] nodeName must be a string, got "+typeof e)}(e),mr.shouldUpdateNode(e)}isActive(){return this.#re.isActive()}start(e){if(!this.#re.canStart())return Promise.reject($r);this.#re.sendStart();const t=G(this).start(e).catch(e=>{throw this.#re.isReady()&&(this.#te.stop(),this.#re.sendStop()),e});return n.#oe(t),t}stop(){return this.#ee.abortCurrentNavigation(),this.#re.sendCancelIfTransitioning(this.#Z.get()),this.#re.isReady()||this.#re.isTransitioning()?(this.#te.stop(),this.#re.sendStop(),this):this}dispose(){if(this.#re.isDisposed())return;this.#ee.abortCurrentNavigation(),this.#re.sendCancelIfTransitioning(this.#Z.get()),(this.#re.isReady()||this.#re.isTransitioning())&&(this.#te.stop(),this.#re.sendStop()),this.#re.sendDispose(),this.#re.clearAll(),this.#A.disposeAll();const e=G(this);for(const t of e.routerExtensions)for(const e of t.keys)delete this[e];e.routerExtensions.length=0,this.#K.clearRoutes(),this.#X.clearAll(),this.#Z.reset(),this.#Y.dependencies=Object.create(null),this.#ie()}canNavigateTo(e,t){if(this.#ne||R(e,"canNavigateTo"),!this.#K.hasRoute(e))return!1;const r=G(this),{name:n,params:o}=r.forwardState(e,t??{}),i=this.#Z.makeState(n,o),a=this.#Z.get(),{toDeactivate:s,toActivate:c}=hr(i,a);return this.#X.canNavigateTo(s,c,i,a)}usePlugin(...e){return this.#ne||(or.validateUsePluginArgs(e),or.validatePluginLimit(this.#A.count(),e.length,this.#D.maxPlugins),or.validateNoDuplicatePlugins(e,this.#A.has.bind(this.#A))),this.#A.use(...e)}subscribe(e){return this.#ne||Pr.validateSubscribeListener(e),this.#re.subscribe(e)}navigate(e,t,r){this.#ne||Sr.validateNavigateArgs(e);const o=r??{};this.#ne||Sr.validateNavigationOptions(o,"navigate");const i=this.#ee.navigate(e,t??{},o);return n.#oe(i),i}navigateToDefault(e){this.#ne||Sr.validateNavigateToDefaultArgs(e);const t=e??{};this.#ne||Sr.validateNavigationOptions(t,"navigateToDefault");const r=this.#ee.navigateToDefault(t);return n.#oe(r),r}navigateToNotFound(e){if(!this.#re.isActive())throw new _(r.ROUTER_NOT_STARTED);const t=e??this.#Z.get().path;return this.#ee.navigateToNotFound(t)}static#ae=t=>{t instanceof _&&(t.code===r.SAME_STATES||t.code===r.TRANSITION_CANCELLED||t.code===r.ROUTER_NOT_STARTED||t.code===r.ROUTE_NOT_FOUND)||e.logger.error("router.navigate","Unexpected navigation error",t)};static#oe(e){e.catch(n.#ae)}#ie(){this.navigate=Rr,this.navigateToDefault=Rr,this.navigateToNotFound=Rr,this.start=Rr,this.stop=Rr,this.usePlugin=Rr,this.subscribe=Rr,this.canNavigateTo=Rr}};function Rr(){throw new _(r.ROUTER_DISPOSED)}exports.cloneRouter=function(e,t){const n=G(e);if(n.isDisposed())throw new _(r.ROUTER_DISPOSED);n.noValidate||function(e){if(void 0!==e){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[cloneRouter] Invalid dependencies: expected plain object or undefined, received ${N(e)}`);for(const t in e)if(Object.getOwnPropertyDescriptor(e,t)?.get)throw new TypeError(`[cloneRouter] Getters not allowed in dependencies: "${t}"`)}}(t);const o=n.routeGetStore(),i=[...o.tree.children.values()].map(e=>Ae(e)),a=o.config,s=o.resolvedForwardMap,c=o.routeCustomFields,u=n.cloneOptions(),d=n.cloneDependencies(),[l,f]=n.getLifecycleFactories(),h=n.getPluginFactories(),p={...d,...t},m=new Dr(i,u,p),g=Pt(m);for(const[e,t]of Object.entries(l))g.addDeactivateGuard(e,t);for(const[e,t]of Object.entries(f))g.addActivateGuard(e,t);h.length>0&&m.usePlugin(...h);const v=G(m).routeGetStore();return Object.assign(v.config.decoders,a.decoders),Object.assign(v.config.encoders,a.encoders),Object.assign(v.config.defaultParams,a.defaultParams),Object.assign(v.config.forwardMap,a.forwardMap),Object.assign(v.config.forwardFnMap,a.forwardFnMap),Object.assign(v.resolvedForwardMap,s),Object.assign(v.routeCustomFields,c),m},exports.getDependenciesApi=function(t){const r=G(t);return{get:e=>{r.noValidate||yt(e,"getDependency");const t=r.dependenciesGetStore().dependencies[e];return r.noValidate||function(e,t){if(void 0===e)throw new ReferenceError(`[router.getDependency]: dependency "${t}" not found`)}(t,e),t},getAll:()=>({...r.dependenciesGetStore().dependencies}),set:(t,n)=>{U(r.isDisposed),r.noValidate||function(e){if("string"!=typeof e)throw new TypeError("[router.setDependency]: dependency name must be a string, got "+typeof e)}(t),function(t,r,n){if(void 0===n)return!1;if(Object.hasOwn(t.dependencies,r)){const o=t.dependencies[r],i=o!==n,a=Number.isNaN(o)&&Number.isNaN(n);i&&!a&&e.logger.warn("router.setDependency","Router dependency already exists and is being overwritten:",r)}else!function(t,r){const n=t.limits.maxDependencies;if(0===n)return;const o=Object.keys(t.dependencies).length,{warn:i,error:a}=L(n);if(o===i)e.logger.warn(`router.${r}`,`${i} dependencies registered. Consider if all are necessary.`);else if(o===a)e.logger.error(`router.${r}`,`${a} dependencies registered! This indicates architectural problems. Hard limit at ${n}.`);else if(o>=n)throw new Error(`[router.${r}] Dependency limit exceeded (${n}). Current: ${o}. This is likely a bug in your code. If you genuinely need more dependencies, your architecture needs refactoring.`)}(t,"setDependency");t.dependencies[r]=n}(r.dependenciesGetStore(),t,n)},setAll:t=>{U(r.isDisposed);const n=r.dependenciesGetStore();r.noValidate||(bt(t,"setDependencies"),function(e,t,r,n=v.maxDependencies){if(0===n)return;const o=e+t;if(o>=n)throw new Error(`[router.${"setDependencies"}] Dependency limit exceeded (${n}). Current: ${o}. This is likely a bug in your code.`)}(Object.keys(n.dependencies).length,Object.keys(t).length,0,n.limits.maxDependencies)),function(t,r){const n=[];for(const e in r)void 0!==r[e]&&(Object.hasOwn(t.dependencies,e)&&n.push(e),t.dependencies[e]=r[e]);n.length>0&&e.logger.warn("router.setDependencies","Overwritten:",n.join(", "))}(n,t)},remove:t=>{U(r.isDisposed),r.noValidate||yt(t,"removeDependency");const n=r.dependenciesGetStore();Object.hasOwn(n.dependencies,t)||e.logger.warn("router.removeDependency",`Attempted to remove non-existent dependency: "${N(t)}"`),delete n.dependencies[t]},reset:()=>{U(r.isDisposed),r.dependenciesGetStore().dependencies=Object.create(null)},has:e=>(r.noValidate||yt(e,"hasDependency"),Object.hasOwn(r.dependenciesGetStore().dependencies,e))}},exports.getLifecycleApi=Pt,exports.getPluginApi=function(e){const t=G(e);return{makeState:(e,r,n,o,i)=>(t.noValidate||function(e,t,r,n){if(!A(e))throw new TypeError(`[router.makeState] Invalid name: ${N(e)}. Expected string.`);if(void 0!==t&&!$(t))throw new TypeError(`[router.makeState] Invalid params: ${N(t)}. Expected plain object.`);if(void 0!==r&&!A(r))throw new TypeError(`[router.makeState] Invalid path: ${N(r)}. Expected string.`);if(void 0!==n&&"number"!=typeof n)throw new TypeError(`[router.makeState] Invalid forceId: ${N(n)}. Expected number.`)}(e,r,n,i),t.makeState(e,r,n,o,i)),buildState:(e,r)=>{t.noValidate||Qe(e,r,"buildState");const{name:n,params:o}=t.forwardState(e,r);return t.buildStateResolved(n,o)},forwardState:(e,r)=>(t.noValidate||Qe(e,r,"forwardState"),t.forwardState(e,r)),matchPath:e=>(t.noValidate||function(e){if(!A(e))throw new TypeError("[real-router] matchPath: path must be a string, got "+typeof e)}(e),t.matchPath(e,t.getOptions())),setRootPath:e=>{U(t.isDisposed),t.noValidate||function(e){if("string"!=typeof e)throw new TypeError(`[router.setRootPath] rootPath must be a string, got ${N(e)}`)}(e),t.setRootPath(e)},getRootPath:t.getRootPath,addEventListener:(e,r)=>(U(t.isDisposed),t.noValidate||function(e,t){if(function(e){if(!g.has(e))throw new Error(`Invalid event name: ${String(e)}`)}(e),"function"!=typeof t)throw new TypeError(`Expected callback to be a function for event ${e}`)}(e,r),t.addEventListener(e,r)),buildNavigationState:(e,r={})=>{t.noValidate||Qe(e,r,"buildNavigationState");const{name:n,params:o}=t.forwardState(e,r),i=t.buildStateResolved(n,o);if(i)return t.makeState(i.name,i.params,t.buildPath(i.name,i.params),{params:i.meta})},getOptions:t.getOptions,getTree:t.getTree,addInterceptor:(e,r)=>{U(t.isDisposed);let n=t.interceptors.get(e);return n||(n=[],t.interceptors.set(e,n)),n.push(r),()=>{const e=n.indexOf(r);-1!==e&&n.splice(e,1)}},extendRouter:n=>{U(t.isDisposed);const o=Object.keys(n);for(const t of o)if(t in e)throw new _(r.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${t}" already exists`});for(const t of o)e[t]=n[t];const i={keys:o};t.routerExtensions.push(i);let a=!1;return()=>{if(a)return;a=!0;for(const t of i.keys)delete e[t];const r=t.routerExtensions.indexOf(i);-1!==r&&t.routerExtensions.splice(r,1)}}}},exports.getRoutesApi=function(t){const r=G(t),n=r.routeGetStore(),o=r.noValidate;return{add:(e,t)=>{U(r.isDisposed);const i=Array.isArray(e)?e:[e],a=t?.parent;r.noValidate||(void 0!==a&&function(e){if("string"!=typeof e||""===e)throw new TypeError(`[router.addRoute] parent option must be a non-empty string, got ${N(e)}`);R(e,"addRoute")}(a),ze(i,"addRoute"),We(i),n.treeOperations.validateRoutes(i,n.tree,n.config.forwardMap,a)),gt(n,o,i,a)},remove:t=>{U(r.isDisposed),r.noValidate||(function(e){R(e,"removeRoute")}(t),qe(t,"removeRoute"));const i=function(t,r,n){if(r){const n=r===t,o=r.startsWith(`${t}.`);if(n||o)return e.logger.warn("router.removeRoute",`Cannot remove route "${t}" — it is currently active${n?"":` (current: "${r}")`}. Navigate away first.`),!1}return n&&e.logger.warn("router.removeRoute",`Route "${t}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}(t,r.getStateName(),r.isTransitioning());i&&(vt(n,o,t)||e.logger.warn("router.removeRoute",`Route "${t}" not found. No changes made.`))},update:(t,i)=>{U(r.isDisposed),r.noValidate||(function(e,t){if(R(e,"updateRoute"),""===e)throw new ReferenceError("[router.updateRoute] Invalid name: empty string. Cannot update root node.");if(null===t)throw new TypeError("[real-router] updateRoute: updates must be an object, got null");if("object"!=typeof t||Array.isArray(t))throw new TypeError(`[real-router] updateRoute: updates must be an object, got ${N(t)}`)}(t,i),qe(t,"updateRoute"));const{forwardTo:a,defaultParams:s,decodeParams:c,encodeParams:u,canActivate:d,canDeactivate:l}=i;r.noValidate||function(e,t,r,n){if(null!=e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError(`[real-router] updateRoute: forwardTo must be a string, function, or null, got ${N(e)}`);"function"==typeof e&&He(e,"forwardTo callback")}if(null!=t&&("object"!=typeof t||Array.isArray(t)))throw new TypeError(`[real-router] updateRoute: defaultParams must be an object or null, got ${N(t)}`);Je(r,"decodeParams"),Je(n,"encodeParams")}(a,s,c,u),r.isTransitioning()&&e.logger.error("router.updateRoute",`Updating route "${t}" while navigation is in progress. This may cause unexpected behavior.`),r.noValidate||Ke(t,a,e=>n.matcher.hasRoute(e),n.matcher,n.config),function(e,t,r,n){if(void 0!==n.forwardTo&&(e.resolvedForwardMap=function(e,t,r,n,o){return null===t?(delete r.forwardMap[e],delete r.forwardFnMap[e]):"string"==typeof t?(delete r.forwardFnMap[e],r.forwardMap[e]=t):(delete r.forwardMap[e],r.forwardFnMap[e]=t),o(r,n)}(r,n.forwardTo,e.config,t,ut)),void 0!==n.defaultParams&&(null===n.defaultParams?delete e.config.defaultParams[r]:e.config.defaultParams[r]=n.defaultParams),void 0!==n.decodeParams)if(null===n.decodeParams)delete e.config.decoders[r];else{const t=n.decodeParams;e.config.decoders[r]=e=>t(e)??e}if(void 0!==n.encodeParams)if(null===n.encodeParams)delete e.config.encoders[r];else{const t=n.encodeParams;e.config.encoders[r]=e=>t(e)??e}}(n,o,t,{forwardTo:a,defaultParams:s,decodeParams:c,encodeParams:u}),void 0!==d&&(null===d?n.lifecycleNamespace.clearCanActivate(t):n.lifecycleNamespace.addCanActivate(t,d,o,!0)),void 0!==l&&(null===l?n.lifecycleNamespace.clearCanDeactivate(t):n.lifecycleNamespace.addCanDeactivate(t,l,o,!0))},clear:()=>{U(r.isDisposed),Ze(r.isTransitioning())&&(n.treeOperations.resetStore(n),n.lifecycleNamespace.clearAll(),r.clearState())},has:e=>(r.noValidate||R(e,"hasRoute"),n.matcher.hasRoute(e)),get:e=>(r.noValidate||R(e,"getRoute"),wt(n,e)),getConfig:e=>function(e,t){if(e.matcher.hasRoute(t))return e.routeCustomFields[t]}(n,e),replace:e=>{U(r.isDisposed);const i=Array.isArray(e)?e:[e];if(!Ze(r.isTransitioning()))return;r.noValidate||(ze(i,"replaceRoutes"),We(i),n.treeOperations.validateRoutes(i));const a=t.getState()?.path;!function(e,t,r,n,o){ct(e),e.lifecycleNamespace.clearDefinitionGuards();for(const t of r)e.definitions.push(et(t));if(ht(r,e.config,e.routeCustomFields,e.pendingCanActivate,e.pendingCanDeactivate,e.depsStore,""),e.treeOperations.commitTreeChanges(e,t),void 0!==o){const e=n.matchPath(o,n.getOptions());e?n.setState(e):n.clearState()}}(n,o,i,r,a)}}};//# sourceMappingURL=api.js.map