@real-router/validation-plugin 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/validationPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;wBAobgB,iBACd,qBAAqB,sBAAsB,wBACxC,cAAc"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/validationPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;wBA0XgB,iBACd,qBAAqB,sBAAsB,wBACxC,cAAc"}
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@real-router/core"),t=require("@real-router/core/api"),n=require("@real-router/core/utils"),r=require("@real-router/core/validation");const i=Object.freeze({maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200});function a(e){return{warn:Math.floor(e*.2),error:Math.floor(e*.5)}}function o(e){return typeof e==`string`}function s(e){return typeof e==`boolean`}function c(e,t){return e in t}const l=Object.getPrototypeOf,u=Object.values,d=Object.hasOwn;function f(e){if(Array.isArray(e))return!0;let t=l(e);return t===null||t===Object.prototype}function p(e,t){let n=Array.isArray(e)?e:u(e);for(let e of n)t.push(e)}function m(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}var h=class{container;constructor(e){this.container=e}};function g(e,t,n,r){return n.has(e)?!1:r.has(e)?!0:f(e)?(n.add(e),t.push(new h(e)),p(e,t),!0):!1}function _(e){let t=[e],n=new WeakSet,r=new WeakSet;for(;t.length>0;){let e=t.pop();if(e instanceof h){n.delete(e.container),r.add(e.container);continue}if(e!=null){if(typeof e==`object`){if(!g(e,t,n,r))return!1;continue}if(!m(e))return!1}}return!0}function ee(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}function v(e){try{return te(e)}catch{return!1}}function te(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=l(e);if(t!==null&&t!==Object.prototype)return!1;let n=!1;for(let t in e){if(!d(e,t))continue;let r=e[t];if(!ee(r)){let e=typeof r;if(e===`function`||e===`symbol`)return!1;n=!0;break}}return!n||_(e)}const ne=[`replace`,`reload`,`force`,`forceDeactivate`,`redirected`,`revalidate`];function re(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;for(let e of ne){let n=t[e];if(n!==void 0&&typeof n!=`boolean`)return!1}let n=t.signal;return n===void 0||n instanceof AbortSignal}const ie=/\S/,y=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function b(e,t){return TypeError(`[router.${e}] ${t}`)}function ae(e){return typeof e==`string`?e===``?!0:e.length>1e4?!1:e.startsWith(`@@`)?!0:y.test(e):!1}function oe(e){return ae(e.name)&&typeof e.path==`string`&&v(e.params)}function x(e){return typeof e!=`object`||!e?!1:oe(e)}function S(e,t){if(typeof e!=`string`)throw b(t,`Route name must be a string, got ${typeof e}`);if(e!==``){if(!ie.test(e))throw b(t,`Route name cannot contain only whitespace`);if(e.length>1e4)throw b(t,`Route name exceeds maximum length of 10000 characters. This is a technical safety limit.`);if(!e.startsWith(`@@`)&&!y.test(e))throw b(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 C(e){if(e===null)return`null`;if(Array.isArray(e))return`array[${e.length}]`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`&&t.name!==`Object`)return t.name||`object`}catch{}return`object`}return typeof e}const w=Object.entries,se=[`defaultParams`,`defaultSearch`],ce=e=>new Map(w(e)),le=(e,t)=>{let n=w(e);return n.length!==t.size||n.some(([e,n])=>!t.has(e)||!Object.is(t.get(e),n))};var ue=class{#e=new Map;#t=new Set;watch(e){for(let t of se){let n=e[t],r=n?.deref();n!==void 0&&r!==void 0&&this.#e.set(t,{ref:n,before:ce(r)})}}check(e){for(let[t,{ref:n,before:r}]of this.#e){if(this.#t.has(t))continue;let i=n.deref();i!==void 0&&le(i,r)&&(this.#t.add(t),e.warn(`router.navigateToDefault`,`mutating \`${t}\` after createRouter() no longer affects routing — the router copied it at construction. Use the callback form (\`${t}: () => ({ … })\`), which is resolved at the point of use.`))}}};const T=Object.keys,E=Object.getOwnPropertyDescriptor,de=Object.getPrototypeOf,fe=Object;function D(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=de(e);return t===null||t.constructor===fe}function pe(e,t){if(typeof e!=`string`)throw TypeError(`[router.${t}] dependency name must be a string, got ${typeof e}`)}function me(e){if(typeof e!=`string`)throw TypeError(`[router.setDependency] dependency name must be a string, got ${typeof e}`)}function he(e,t){if(!D(e))throw TypeError(`[router.${t}] Invalid argument: expected plain object, received ${C(e)}`);for(let n of T(e))if(E(e,n)?.get)throw TypeError(`[router.${t}] Getters not allowed: "${n}"`)}function ge(e,t,n,r){if(n===0)return;let i=new Set(t),a=0;for(let t of T(e))i.has(t)||(a+=1);let o=t.length;if(o+a>n)throw RangeError(`[router.${r}] Dependency limit exceeded (${n}). Current: ${o}, this batch adds ${a}.`)}function _e(e,t){if(e===void 0)throw ReferenceError(`[router.getDependency] dependency "${t}" not found`)}function ve(e,t,n,r){if(t===0)return;let{warn:i,error:o}=a(t);if(e>=t)throw RangeError(`[router.${n}] Dependency limit exceeded (${t}). Current: ${e}.`);e===o?r.error(`router.${n}`,`${e} dependencies registered! This indicates architectural problems. Hard limit at ${t}.`):e===i&&r.warn(`router.${n}`,`${e} dependencies registered. Consider if all are necessary.`)}function ye(e){if(e!==void 0){if(!D(e))throw TypeError(`[cloneRouter] Invalid dependencies: expected plain object or undefined, received ${typeof e}`);for(let t of T(e))if(E(e,t)?.get)throw TypeError(`[cloneRouter] Getters not allowed in dependencies: "${t}"`)}}function be(e,t,n){n.warn(`router.${t}`,`Router dependency already exists and is being overwritten:`,e)}function xe(e,t,n){n.warn(`router.${t}`,`Overwritten:`,e.join(`, `))}function Se(e,t){t.warn(`router.removeDependency`,`Attempted to remove non-existent dependency: "${typeof e==`string`?e:String(e)}"`)}const Ce=Object.values,we=new Set(Ce(e.events));function Te(e){if(!we.has(e))throw TypeError(`[router.addEventListener] Invalid event name: ${String(e)}. Must be one of: $start, $stop, $$start, $$leaveApprove, $$cancel, $$success, $$error`)}function Ee(e,t){if(Te(e),typeof t!=`function`)throw TypeError(`[router.addEventListener] callback must be a function, got ${typeof t}`)}function De(e,t,n,r,o=i.maxListeners){if(o===0)return;let{warn:s,error:c}=a(o);e>=c?r.error(`router.${n}`,`${e} listeners registered for "${t}"! This is excessive. Hard limit at ${o}.`):e>=s&&r.warn(`router.${n}`,`${e} listeners registered for "${t}". Consider whether all are necessary — a growing count usually means a missing unsubscribe.`)}function Oe(e,t){if(!s(e)&&typeof e!=`function`)throw TypeError(`[router.${t}] Handler must be a boolean or factory function, got ${C(e)}`)}function ke(e,t,n=i.maxLifecycleHandlers){if(n!==0&&e>=n)throw RangeError(`[router.${t}] Lifecycle handler limit exceeded (${n}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`)}function Ae(e,t,n,r){if(n===0)return;let{warn:i,error:o}=a(n);e>=o?r.error(`router.${t}`,`${e} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):e>=i&&r.warn(`router.${t}`,`${e} lifecycle handlers registered. Consider consolidating logic.`)}function je(e,t,n,r){r.warn(`router.${n}`,`Overwriting existing ${t} handler for route "${e}"`)}function Me(e,t,n){n.warn(`router.${t}`,`Guard for "${e}" returned a Promise. Sync check cannot resolve async guards — returning false.`)}const Ne=Object.hasOwn,Pe=Object.getPrototypeOf;function Fe(e){if(typeof e!=`string`)throw TypeError(`[router.navigate] Invalid route name: expected string, got ${C(e)}`)}function Ie(e){if(e!==void 0&&(typeof e!=`object`||!e))throw TypeError(`[router.navigateToDefault] Invalid options: ${C(e)}. Expected NavigationOptions object.`)}function Le(e){if(typeof e!=`object`||!e)throw TypeError(`[router.navigateToState] Invalid state: ${C(e)}. Expected State object.`);let t=e;if(!o(t.name))throw TypeError(`[router.navigateToState] Invalid state.name: ${C(t.name)}. Expected string.`);if(!v(t.params))throw TypeError(`[router.navigateToState] Invalid state.params: ${C(t.params)}. Expected plain object.`);if(!o(t.path))throw TypeError(`[router.navigateToState] Invalid state.path: ${C(t.path)}. Expected string.`)}function O(e,t){if(!re(e))throw TypeError(`[router.${t}] Invalid options: ${C(e)}. Expected NavigationOptions object.`)}const Re=/[\u0000-\u001F\u007F]/;function ze(e,t){for(let n in e){if(!Ne(e,n))continue;let r=e[n],i=typeof r;if(i===`symbol`||i===`bigint`)throw TypeError(`[router.${t}] param "${n}" cannot be a ${i} — it does not round-trip through the URL path. Use a string, number, or boolean.`);if(i===`string`&&Re.test(r))throw TypeError(`[router.${t}] param "${n}" must not contain control characters (NUL / C0 / DEL) — they corrupt the URL path.`)}}function k(e,t){if(e===void 0)return;let n=e!==null&&Pe(e);if(Array.isArray(e)||n!==null&&n!==Object.prototype)throw TypeError(`[router.${t}] params must be a plain object, got ${C(e)}`)}function A(e,t){if(e!==void 0&&(ze(e,t),!v(e)))throw TypeError(`[router.${t}] params must be a plain object, got ${C(e)}`)}function j(e,t){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.${t}] search must be a plain object, got ${C(e)}`)}function Be(e){if(e!==void 0&&typeof e!=`string`)throw TypeError(`[router.start] path must be a string, got ${C(e)}.`);if(typeof e==`string`){if(Re.test(e))throw TypeError(`[router.start] path must not contain control characters (NUL / C0 / DEL).`);if(e!==``&&!e.startsWith(`/`))throw TypeError(`[router.start] path must start with "/", got "${e}".`)}}const Ve=Object.entries,He=Object.hasOwn,M=Object.keys,Ue=Object.getPrototypeOf,N={trailingSlash:[`strict`,`never`,`always`,`preserve`],queryParamsMode:[`default`,`strict`,`loose`],urlParamsEncoding:[`default`,`uri`,`uriComponent`,`none`]},We={arrayFormat:!0,booleanFormat:!0,nullFormat:!0,numberFormat:!0},Ge=new Set(M({defaultRoute:!0,defaultParams:!0,defaultSearch:!0,trailingSlash:!0,caseSensitive:!0,queryParamsMode:!0,queryParams:!0,urlParamsEncoding:!0,allowNotFound:!0,rewritePathOnMatch:!0,logger:!0,limits:!0})),P={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxLifecycleHandlers:{min:0,max:1e4}};function Ke(e,t,n){if(typeof t!=`number`||!Number.isInteger(t))throw TypeError(`[router.${n}] limit "${e}" must be an integer, got ${String(t)}`);let r=P[e];if(t<r.min||t>r.max)throw RangeError(`[router.${n}] limit "${e}" must be between ${r.min} and ${r.max}, got ${t}`)}function F(e){let t=Ue(e);return t===null||t===Object.prototype}function qe(e,t){if(!e||typeof e!=`object`||!F(e))throw TypeError(`[router.${t}] invalid limits: expected plain object, got ${typeof e}`);for(let[n,r]of Ve(e)){if(!He(P,n))throw TypeError(`[router.${t}] unknown limit: "${n}"`);r!==void 0&&Ke(n,r,t)}let{warnListeners:n,maxListeners:r}=e;if(typeof n==`number`&&typeof r==`number`&&r>0&&n>r)throw RangeError(`[router.${t}] "limits.warnListeners" (${n}) must not exceed "limits.maxListeners" (${r}) — the warning channel would be unreachable`)}function I(e,t,n,r){if(e!==void 0&&(typeof e!=`string`||!n.includes(e))){let i=n.map(e=>`"${e}"`).join(`, `);throw TypeError(`[router.${r}] Invalid "${t}": "${typeof e==`string`?e:`(${typeof e})`}". Must be one of: ${i}`)}}function Je(e,t){if(e!==void 0&&typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.${t}] Invalid "defaultRoute": expected string or function, got ${typeof e}`)}function L(e,t,n){if(e!==void 0&&typeof e!=`function`&&(!e||typeof e!=`object`||Array.isArray(e)||!F(e)))throw TypeError(`[router.${n}] Invalid "${t}": expected plain object or function, got ${typeof e}`)}function Ye(e,t){if(e===void 0)return;if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid "queryParams": expected plain object`);let n=e;for(let e of M(n))if(!c(e,We))throw TypeError(`[router.${t}] Invalid "queryParams.${e}": unknown option`)}function Xe(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid options: expected plain object`);let n=e;for(let e of M(n))if(!Ge.has(e))throw TypeError(`[router.${t}] Unknown option: "${e}"`);if(Je(n.defaultRoute,t),L(n.defaultParams,`defaultParams`,t),L(n.defaultSearch,`defaultSearch`,t),I(n.trailingSlash,`trailingSlash`,N.trailingSlash,t),I(n.queryParamsMode,`queryParamsMode`,N.queryParamsMode,t),I(n.urlParamsEncoding,`urlParamsEncoding`,N.urlParamsEncoding,t),n.allowNotFound!==void 0&&typeof n.allowNotFound!=`boolean`)throw TypeError(`[router.${t}] Invalid "allowNotFound": expected boolean, got ${typeof n.allowNotFound}`);if(n.rewritePathOnMatch!==void 0&&typeof n.rewritePathOnMatch!=`boolean`)throw TypeError(`[router.${t}] Invalid "rewritePathOnMatch": expected boolean, got ${typeof n.rewritePathOnMatch}`);if(n.caseSensitive!==void 0&&typeof n.caseSensitive!=`boolean`)throw TypeError(`[router.${t}] Invalid "caseSensitive": expected boolean, got ${typeof n.caseSensitive}`);Ye(n.queryParams,t),n.limits!==void 0&&qe(n.limits,t)}const Ze=Object.hasOwn,R=`router.usePlugin`,Qe={onStart:!0,onStop:!0,onTransitionStart:!0,onTransitionLeaveApprove:!0,onTransitionSuccess:!0,onTransitionError:!0,onTransitionCancel:!0};function $e(e,t,n=i.maxPlugins){if(n!==0&&e+t>n)throw RangeError(`[router.usePlugin] Plugin limit exceeded (${n}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`)}function et(e,t){if(t.includes(e))throw Error(`[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.`)}function tt(e,t,n){if(t===0)return;let{warn:r,error:i}=a(t);e>=i?n.error(R,`${e} plugins registered! This is excessive. Hard limit at ${t}.`):e>=r&&n.warn(R,`${e} plugins registered. Consider if all are necessary.`)}function nt(e){for(let t in e)if(!(t===`teardown`||Ze(Qe,t)))throw TypeError(`[router.usePlugin] Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`)}function rt(e){e.warn(R,`Duplicate factory in batch, will be registered once`)}function it(e,t){t.warn(R,`Property '${e}' is not a function, skipping`)}function at(e,t){e===`onStart`&&t.warn(R,`Router already started, onStart will not be called`)}const z=Object.entries,ot=Object.getOwnPropertyDescriptor,B=Object.keys;function V(e,t,n=``){for(let r of e){let e=n?`${n}.${r.name}`:r.name;t(r,e),r.children&&V(r.children,t,e)}}function H(e,t){let n=[];return V(e,(e,r)=>{let i=t(e);i!==void 0&&n.push([r,i])}),n}function st(t,n){try{return(0,e.resolveForwardChain)(t,n)}catch(e){throw Error(`[validation-plugin] ${e.message}`,{cause:e})}}function U(e,t,n){let r=e;if(r.constructor.name===`AsyncFunction`||r.toString().includes(`__awaiter`))throw TypeError(`[validation-plugin] Route "${n}" ${t} cannot be async`)}function ct(e){V(e,(e,t)=>{if(typeof e.name!=`string`||!e.name)throw TypeError(`[validation-plugin] validateExistingRoutes: route has invalid name: ${e.name}`);if(typeof e.path!=`string`)throw TypeError(`[validation-plugin] validateExistingRoutes: route "${t}" has non-string path (${typeof e.path})`)})}function lt(e,t){for(let[n,r]of z(e)){if(!t.hasRoute(r))throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${r}" does not exist in tree (source route: "${n}")`);let e=new Set(t.getUrlParams(n)),i=[...new Set(t.getUrlParams(r))].filter(t=>!e.has(t));if(i.length>0)throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${r}" requires params [${i.join(`, `)}] not available in source route "${n}"`)}for(let t of B(e))st(t,e)}function W(e,t){for(let[n,r]of e)if(typeof r!=`object`||!r||Array.isArray(r))throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${n}" ${t} must be a plain object, got ${Array.isArray(r)?`array`:typeof r}`)}function ut(e){let t=H(e,e=>e.decodeParams),n=H(e,e=>e.encodeParams),r=H(e,e=>typeof e.forwardTo==`string`?void 0:e.forwardTo);for(let[e,n]of t){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" decoder must be a function, got ${typeof n}`);U(n,`decoder`,e)}for(let[e,t]of n){if(typeof t!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" encoder must be a function, got ${typeof t}`);U(t,`encoder`,e)}W(H(e,e=>e.defaultParams),`defaultParams`),W(H(e,e=>e.defaultSearch),`defaultSearch`);for(let[e,t]of r){if(typeof t!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" forwardTo callback must be a function, got ${typeof t}`);U(t,`forwardTo callback`,e)}}function dt(e,t){for(let[n,r]of z(e))if(!t.hasRoute(r))throw Error(`[validation-plugin] validateForwardToTargetsStore: forwardTo target "${r}" does not exist for route "${n}"`)}function ft(e,t){for(let t of B(e))if(ot(e,t)?.get)throw TypeError(`[validation-plugin] validateDependenciesStructure: dependency "${t}" must not use a getter`);for(let[e,n]of z(t))if(!Number.isInteger(n))throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.limits.${e} must be an integer, got ${String(n)}`)}function pt(e,t,n){let r=e&&typeof e==`object`?e:{},i=(r.limits&&typeof r.limits==`object`?r.limits:{}).maxDependencies,a=typeof i==`number`?i:n;if(a>0&&t>a)throw RangeError(`[validation-plugin] validateLimitsConsistency: dependency count (${t}) exceeds maxDependencies limit (${a})`)}function G(e,t){if(typeof e==`string`&&e&&!t.hasRoute(e))throw Error(`[validation-plugin] defaultRoute resolved to non-existent route: "${e}"`)}function mt(e,t,n){for(let r of e)t.hasRoute(r)||n.warn(`router.start`,`Guard registered for route "${r}", which the route tree does not contain. It will never run unless that route is added. Check the name for a typo.`)}const ht=Object.keys;function gt(e,t){if(e!==void 0){if(typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.addRoute] forwardTo must be a string or function for route "${t}", got ${C(e)}`);if(typeof e==`function`){let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}}}function K(e,t,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.addRoute] ${t} must be an object for route "${n}", got ${C(e)}`)}function q(e,t){if(e.canActivate!==void 0&&typeof e.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function for route "${t}", got ${C(e.canActivate)}`);if(e.canDeactivate!==void 0&&typeof e.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function for route "${t}", got ${C(e.canDeactivate)}`);if(K(e.defaultParams,`defaultParams`,t),K(e.defaultSearch,`defaultSearch`,t),e.decodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(e.encodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(gt(e.forwardTo,t),e.children)for(let n of e.children)q(n,`${t}.${n.name}`)}function _t(e){let t=new Set,n=/[*:]([A-Z_a-z]\w*)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);return t}function J(e){let t=new Set;for(let n of e)for(let e of _t(n))t.add(e);return t}function Y(e,t,n=``,r=[]){for(let i of e){let e=n?`${n}.${i.name}`:i.name,a=[...r,i.path];if(e===t)return a;if(i.children&&t.startsWith(`${e}.`))return Y(i.children,t,e,a)}throw Error(`[internal] collectPathsToRoute: route "${t}" not found`)}function X(e,t=``){let n=new Set;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(n.add(e),r.children)for(let t of X(r.children,e))n.add(t)}return n}function vt(e,t=``){let n=new Map;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(r.forwardTo&&typeof r.forwardTo==`string`&&n.set(e,r.forwardTo),r.children)for(let[t,i]of vt(r.children,e))n.set(t,i)}return n}function yt(e,t,n,r){return t?new Set(n.getUrlParams(e)):J(Y(r,e))}const bt=new Set;function xt(e,t,n,r,i,a){let o=i.hasRoute(t),s=r.has(t);if(!o&&!s)throw ReferenceError(`[router.addRoute] forwardTo target "${t}" does not exist for route "${e}"`);let c=new Set([...a,...J(Y(n,e))]),l=[...yt(t,o,i,n)].filter(e=>!c.has(e));if(l.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${l.join(`, `)}] that are not available in source route "${e}"`)}function St(t,r,i,a){let o=X(t),s=a?new Set([...o].map(e=>`${a}.${e}`)):o,c=a?new Set(i.getUrlParams(a)):bt,l=vt(t),u={...r};for(let[e,t]of l)(0,n.putField)(u,e,t);for(let[e,n]of l)xt(e,n,t,s,i,c);for(let t of ht(u))(0,e.resolveForwardChain)(t,u)}function Ct(e,t){if(e.startsWith(`@@`))throw 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 wt(e,t){for(let n of e)n&&typeof n==`object`&&typeof n.name==`string`&&(Ct(n.name,t),n.children&&wt(n.children,t))}function Tt(e){S(e,`removeRoute`)}function Et(e){if(typeof e!=`string`)throw TypeError(`[router.setRootPath] rootPath must be a string, got ${C(e)}`)}function Z(e){return e.constructor.name===`AsyncFunction`||String(e).includes(`__awaiter`)}function Dt(e){let t=e;if(t.canActivate!==void 0&&typeof t.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function, got ${C(t.canActivate)}`);if(t.canDeactivate!==void 0&&typeof t.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function, got ${C(t.canDeactivate)}`)}function Ot(e){let t=e,n=t.name;if(t.decodeParams!==void 0&&Z(t.decodeParams))throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${String(n)}"`);if(t.encodeParams!==void 0&&Z(t.encodeParams))throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${String(n)}"`);if(typeof t.forwardTo==`function`&&Z(t.forwardTo))throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${String(n)}"`)}function kt(e){for(let t of e){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`[router.addRoute] Route must be an object, got ${C(t)}`);q(t,t.name)}}function At(e){if(typeof e!=`string`||e===``)throw TypeError(`[router.addRoute] parent option must be a non-empty string, got ${C(e)}`);S(e,`addRoute`)}function jt(e,t,n,r){if(!o(e))throw TypeError(`[router.isActiveRoute] name must be a string, got ${typeof e}`);if(k(t,`isActiveRoute`),n!==void 0&&typeof n!=`boolean`)throw TypeError(`[router.isActiveRoute] strictEquality must be a boolean, got ${typeof n}`);if(r!==void 0&&typeof r!=`boolean`)throw TypeError(`[router.isActiveRoute] ignoreQueryParams must be a boolean, got ${typeof r}`)}function Mt(e,t,n){if(!o(e))throw TypeError(`[router.${n}] Invalid routeName: ${C(e)}. Expected string.`);if(!v(t))throw TypeError(`[router.${n}] Invalid routeParams: ${C(t)}. Expected plain object.`)}function Nt(e,t){if(S(e,`updateRoute`),e===``)throw ReferenceError(`[router.updateRoute] Invalid name: empty string. Cannot update root node.`);if(t===null)throw TypeError(`[router.updateRoute] updates must be an object, got null`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`[router.updateRoute] updates must be an object, got ${C(t)}`)}function Pt(e,t){if(e.constructor.name===`AsyncFunction`||e.toString().includes(`__awaiter`))throw TypeError(`[router.updateRoute] ${t} cannot be an async function`)}function Q(e,t){if(e!=null){if(typeof e!=`function`)throw TypeError(`[router.updateRoute] ${t} must be a function or null, got ${typeof e}`);Pt(e,t)}}function Ft(e){let{forwardTo:t,defaultParams:n,defaultSearch:r,decodeParams:i,encodeParams:a,canActivate:o,canDeactivate:s}=e;if(t!=null){if(typeof t!=`string`&&typeof t!=`function`)throw TypeError(`[router.updateRoute] forwardTo must be a string, function, or null, got ${C(t)}`);typeof t==`function`&&Pt(t,`forwardTo callback`)}$(n,`defaultParams`),$(r,`defaultSearch`),Q(i,`decodeParams`),Q(a,`encodeParams`),Q(o,`canActivate`),Q(s,`canDeactivate`)}function $(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw TypeError(`[router.updateRoute] ${t} must be an object or null, got ${C(e)}`)}function It(e){if(!o(e)||e===``)throw TypeError(`[router.buildPath] route must be a non-empty string, got ${typeof e==`string`?`""`:typeof e}`)}function Lt(e){let t=new Set;return function(n,i){let a=(0,r.findMisChanneledKey)(i,e(n));if(a===void 0)return;let o=`${n} ${a}`;t.has(o)||(t.add(o),console.warn(`[router] Route "${n}" declares \`${a}\` as a query param, but it was given in the \`params\` bag — the path channel. The URL is built without it, so the href does not match what you asked for; a plain click throws, but a ⌘-click, a copied link and server-rendered markup all follow the wrong URL in silence. Pass it in \`search\` instead.`))}}function Rt(e){if(!o(e))throw TypeError(`[router.matchPath] path must be a string, got ${typeof e}`)}function zt(e){if(!o(e))throw TypeError(`[router.shouldUpdateNode] nodeName must be a string, got ${typeof e}`)}function Bt(e,t,n,i,a){if(a){let e=t;for(let t of a.split(`.`))if(e=e.children.get(t),!e)throw ReferenceError(`[router.addRoute] Parent route "${a}" does not exist`)}let o=new Set,s=new Map;for(let n of e)(0,r.validateRoute)(n,`addRoute`,t,a??``,o,s);St(e,i,n,a)}function Vt(e,t,n){let r=new Set(n.getUrlParams(e)),i=n.getUrlParams(t).filter(e=>!r.has(e));if(i.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${i.join(`, `)}] that are not available in source route "${e}"`)}function Ht(t,n,r){let i={...r,[t]:n};(0,e.resolveForwardChain)(t,i)}function Ut(e,t,n,r){if(!n.hasRoute(e))throw ReferenceError(`[router.updateRoute] route "${e}" does not exist`);if(t!=null&&typeof t==`string`){if(!n.hasRoute(t))throw Error(`[router.updateRoute] forwardTo target "${t}" does not exist`);Vt(e,t,n),Ht(e,t,r)}}function Wt(e,t,n){if(!o(e))throw TypeError(`[router.makeState] Invalid name: ${C(e)}. Expected string.`);if(t!==void 0&&!v(t))throw TypeError(`[router.makeState] Invalid params: ${C(t)}. Expected plain object.`);if(n!==void 0&&!o(n))throw TypeError(`[router.makeState] Invalid path: ${C(n)}. Expected string.`)}function Gt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Query key "${n}" is not declared on route "${t}" (\`?${n}\`), so the current \`queryParamsMode\` will not print it — it was dropped from \`state.search\` rather than published beside a \`state.path\` that cannot show it. Declare it on the route path, or use \`queryParamsMode: "loose"\` to keep undeclared keys. A \`defaultSearch\` entry for "${n}" is dead config in this mode for the same reason.`))}}function Kt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Param "${n}" is declared nowhere on route "${t}" — neither as a path slot (:${n}) nor as a query param (?${n}), so it stays in state.params but never reaches the URL. The state will not round-trip: matchPath(state.path) cannot recover it. Declare it on the route path if it belongs in the URL, or pass it through the search channel; keep it here only if it is deliberately app-level data.`))}}function qt(e){return{hasRoute:t=>{let n=e.getTree();for(let e of t.split(`.`))if(n=n?.children.get(e),!n)return!1;return!0},getUrlParams:t=>e.getUrlParams(t)}}function Jt(e,t){let n=[];for(let r of e.getTree().children.keys())n.push(t.get(r));return n}function Yt(e,t,n){let r=Lt(t=>e.getDeclaredQueryNames(t));return{routes:{validateBuildPathArgs(e,t){It(e),r(e,t)},validateMatchPathArgs:Rt,validateIsActiveRouteArgs(e,t,n,i){jt(e,t,n,i),r(e,t)},validateShouldUpdateNodeArgs:zt,validateStateBuilderArgs:Mt,validateAddRouteArgs(e){kt(e)},validateRoutes(n,r){Bt(n,e.getTree(),t,e.getForwardMap(),r)},validateRemoveRouteArgs:Tt,validateUpdateRouteBasicArgs:Nt,validateUpdateRoutePropertyTypes(e,t){let n=t;Ft({forwardTo:n.forwardTo,defaultParams:n.defaultParams,defaultSearch:n.defaultSearch,decodeParams:n.decodeParams,encodeParams:n.encodeParams,canActivate:n.canActivate,canDeactivate:n.canDeactivate})},validateUpdateRoute(n,r){let i=r.forwardTo;Ut(n,i,t,e.getForwardMap())},validateParentOption(e){if(At(e),!t.hasRoute(e))throw ReferenceError(`[router.addRoute] Parent route "${e}" does not exist`)},validateRouteName(e,t){S(e,t)},throwIfInternalRoute(e,t){Ct(e,t)},throwIfInternalRouteInArray(e,t){wt(e,t)},validateSetRootPathArgs:Et,guardRouteCallbacks:Dt,guardNoAsyncCallbacks:Ot},options:{validateOptions:Xe,validateResolvedDefaultRoute(e){G(e,t)}},dependencies:{validateDependencyName:pe,validateSetDependencyArgs(e,t,n){me(e)},validateDependenciesObject(t,n){he(t,n),ge(t,e.getDependencyKeys(),e.getResolvedLimits().maxDependencies,n)},validateDependencyExists(e,t){_e(t,e)},validateDependencyCount(t,n,r){ve(t,n,r,e.logger)},validateCloneArgs:ye,warnOverwrite(t,n){be(t,n,e.logger)},warnBatchOverwrite(t,n){xe(t,n,e.logger)},warnRemoveNonExistent(t){Se(t,e.logger)}},plugins:{validatePluginLimit(e,t){$e(e,1,t?.maxPlugins)},validateNoDuplicatePlugins:et,validatePluginKeys:nt,validateCountThresholds(t){tt(t,e.getOptions().limits?.maxPlugins??i.maxPlugins,e.logger)},warnBatchDuplicates(){rt(e.logger)},warnPluginMethodType(t){it(t,e.logger)},warnPluginAfterStart(t){at(t,e.logger)}},lifecycle:{validateHandler:Oe,validateHandlerLimit(t,n){ke(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers)},validateCountThresholds(t,n){Ae(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers,e.logger)},warnOverwrite(t,n,r){je(t,n,r,e.logger)},warnAsyncGuardSync(t,n){Me(t,n,e.logger)}},navigation:{validateNavigateToDefaultArgs(t){Ie(t),n.check(e.logger)},validateNavigateToStateArgs:Le,validateNavigationOptions:O,validateParamsShape:k,validateSearch:j,validateStartArgs:Be},state:{validateMakeStateArgs:Wt,reportDroppedQueryKey:Gt(),reportUndeclaredParamKey:Kt(),validateAreStatesEqualArgs(e,t,n){if(!x(e))throw TypeError(`[router.areStatesEqual] Invalid state1: ${C(e)}. Expected State object.`);if(!x(t))throw TypeError(`[router.areStatesEqual] Invalid state2: ${C(t)}. Expected State object.`);if(n!==void 0&&!s(n))throw TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${C(n)}. Expected boolean.`)}},eventBus:{validateListenerArgs(e,t){Ee(e,t)},validateCountThresholds(t,n,r){let a=e.getOptions().limits?.maxListeners??i.maxListeners;De(t,n,r,e.logger,a)}}}}function Xt(){return i=>{let a=(0,r.getInternals)(i),o=(0,t.getPluginApi)(i);if(i.isActive())throw(0,n.freezeThrownError)(new e.RouterError(`VALIDATION_PLUGIN_AFTER_START`,{message:`validation-plugin must be registered before router.start()`}));if(a.validator!==null)throw(0,n.freezeThrownError)(new e.RouterError(`VALIDATION_PLUGIN_ALREADY_INSTALLED`,{message:`validation-plugin is already installed on this router — a clone re-runs plugin factories, so it needs no usePlugin of its own`}));let s=new ue;s.watch(o.getAdoptedOrigins());let c=qt(o),l=Yt(o,c,s),u=()=>{a.validator===l&&(a.validator=null)};a.validator=l;try{let e=Jt(o,(0,t.getRoutesApi)(i)),n=o.getForwardMap(),r=o.getResolvedLimits(),s=o.getOptions();ct(e),lt(n,c),ut(e),dt(n,c),ft(a.dependenciesGetStore().dependencies,r),pt(s,o.getDependencyKeys().length,r.maxDependencies),a.validator.options.validateOptions(s,`constructor (retrospective)`),typeof s.defaultRoute==`string`&&G(s.defaultRoute,c)}catch(e){throw u(),e}let d=o.addInterceptor(`start`,(e,t)=>{try{mt(o.getExternalGuardNames(),c,o.logger)}catch{}return e(t)}),f=o.addCheck(`buildPath:params`,e=>{A(e,`buildPath`)}),p=o.addCheck(`buildPathResolved:params`,e=>{A(e,`buildPathResolved`)}),m=o.addCheck(`canNavigateTo:entry`,(e,t,n)=>{S(e,`canNavigateTo`),k(t,`canNavigateTo`),j(n,`canNavigateTo`)}),h=o.addCheck(`canNavigateTo:params`,e=>{A(e,`canNavigateTo`)}),g=o.addCheck(`navigate:entry`,(e,t,n,r)=>{Fe(e),k(t,`navigate`),j(n,`navigate`),O(r,`navigate`)}),_=o.addCheck(`navigate:params`,e=>{A(e,`navigate`)});return{teardown(){f(),p(),m(),h(),g(),_(),d(),u()}}}}exports.validationPlugin=Xt;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@real-router/core"),t=require("@real-router/core/api"),n=require("@real-router/core/utils"),r=require("@real-router/core/validation");const i=Object.freeze({maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200});function a(e){return{warn:Math.floor(e*.2),error:Math.floor(e*.5)}}function o(e){return typeof e==`string`}function s(e){return typeof e==`boolean`}function c(e,t){return e in t}const l=Object.getPrototypeOf,u=Object.values,d=Object.hasOwn;function f(e){if(Array.isArray(e))return!0;let t=l(e);return t===null||t===Object.prototype}function p(e,t){let n=Array.isArray(e)?e:u(e);for(let e of n)t.push(e)}function m(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}var h=class{container;constructor(e){this.container=e}};function ee(e,t,n,r){return n.has(e)?!1:r.has(e)?!0:f(e)?(n.add(e),t.push(new h(e)),p(e,t),!0):!1}function g(e){let t=[e],n=new WeakSet,r=new WeakSet;for(;t.length>0;){let e=t.pop();if(e instanceof h){n.delete(e.container),r.add(e.container);continue}if(e!=null){if(typeof e==`object`){if(!ee(e,t,n,r))return!1;continue}if(!m(e))return!1}}return!0}function _(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}function v(e){try{return te(e)}catch{return!1}}function te(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=l(e);if(t!==null&&t!==Object.prototype)return!1;let n=!1;for(let t in e){if(!d(e,t))continue;let r=e[t];if(!_(r)){let e=typeof r;if(e===`function`||e===`symbol`)return!1;n=!0;break}}return!n||g(e)}const ne=[`replace`,`reload`,`force`,`forceDeactivate`,`redirected`,`revalidate`];function y(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;for(let e of ne){let n=t[e];if(n!==void 0&&typeof n!=`boolean`)return!1}let n=t.signal;return n===void 0||n instanceof AbortSignal}const b=/\S/,x=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function S(e,t){return TypeError(`[router.${e}] ${t}`)}function re(e){return typeof e==`string`?e===``?!0:e.length>1e4?!1:e.startsWith(`@@`)?!0:x.test(e):!1}function ie(e){return re(e.name)&&typeof e.path==`string`&&v(e.params)}function ae(e){return typeof e!=`object`||!e?!1:ie(e)}function C(e,t){if(typeof e!=`string`)throw S(t,`Route name must be a string, got ${typeof e}`);if(e!==``){if(!b.test(e))throw S(t,`Route name cannot contain only whitespace`);if(e.length>1e4)throw S(t,`Route name exceeds maximum length of 10000 characters. This is a technical safety limit.`);if(!e.startsWith(`@@`)&&!x.test(e))throw S(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 w(e){if(e===null)return`null`;if(Array.isArray(e))return`array[${e.length}]`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`&&t.name!==`Object`)return t.name||`object`}catch{}return`object`}return typeof e}const T=Object.entries,oe=[`defaultParams`,`defaultSearch`],se=e=>new Map(T(e)),ce=(e,t)=>{let n=T(e);return n.length!==t.size||n.some(([e,n])=>!t.has(e)||!Object.is(t.get(e),n))};var le=class{#e=new Map;#t=new Set;watch(e){for(let t of oe){let n=e[t],r=n?.deref();n!==void 0&&r!==void 0&&this.#e.set(t,{ref:n,before:se(r)})}}check(e){for(let[t,{ref:n,before:r}]of this.#e){if(this.#t.has(t))continue;let i=n.deref();i!==void 0&&ce(i,r)&&(this.#t.add(t),e.warn(`router.navigateToDefault`,`mutating \`${t}\` after createRouter() no longer affects routing — the router copied it at construction. Use the callback form (\`${t}: () => ({ … })\`), which is resolved at the point of use.`))}}};const E=Object.keys,D=Object.getOwnPropertyDescriptor,ue=Object.getPrototypeOf,de=Object;function O(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=ue(e);return t===null||t.constructor===de}function fe(e,t){if(typeof e!=`string`)throw TypeError(`[router.${t}] dependency name must be a string, got ${typeof e}`)}function pe(e){if(typeof e!=`string`)throw TypeError(`[router.setDependency] dependency name must be a string, got ${typeof e}`)}function me(e,t){if(!O(e))throw TypeError(`[router.${t}] Invalid argument: expected plain object, received ${w(e)}`);for(let n of E(e))if(D(e,n)?.get)throw TypeError(`[router.${t}] Getters not allowed: "${n}"`)}function he(e,t,n,r){if(n===0)return;let i=new Set(t),a=0;for(let t of E(e))i.has(t)||(a+=1);let o=t.length;if(o+a>n)throw RangeError(`[router.${r}] Dependency limit exceeded (${n}). Current: ${o}, this batch adds ${a}.`)}function ge(e,t){if(e===void 0)throw ReferenceError(`[router.getDependency] dependency "${t}" not found`)}function _e(e,t,n,r){if(t===0)return;let{warn:i,error:o}=a(t);if(e>=t)throw RangeError(`[router.${n}] Dependency limit exceeded (${t}). Current: ${e}.`);e===o?r.error(`router.${n}`,`${e} dependencies registered! This indicates architectural problems. Hard limit at ${t}.`):e===i&&r.warn(`router.${n}`,`${e} dependencies registered. Consider if all are necessary.`)}function ve(e){if(e!==void 0){if(!O(e))throw TypeError(`[cloneRouter] Invalid dependencies: expected plain object or undefined, received ${typeof e}`);for(let t of E(e))if(D(e,t)?.get)throw TypeError(`[cloneRouter] Getters not allowed in dependencies: "${t}"`)}}function ye(e,t,n){n.warn(`router.${t}`,`Router dependency already exists and is being overwritten:`,e)}function be(e,t,n){n.warn(`router.${t}`,`Overwritten:`,e.join(`, `))}function xe(e,t){t.warn(`router.removeDependency`,`Attempted to remove non-existent dependency: "${typeof e==`string`?e:String(e)}"`)}const Se=Object.values,Ce=new Set(Se(e.events));function we(e){if(!Ce.has(e))throw TypeError(`[router.addEventListener] Invalid event name: ${String(e)}. Must be one of: $start, $stop, $$start, $$leaveApprove, $$cancel, $$success, $$error`)}function Te(e,t){if(we(e),typeof t!=`function`)throw TypeError(`[router.addEventListener] callback must be a function, got ${typeof t}`)}function Ee(e,t,n,r,o=i.maxListeners){if(o===0)return;let{warn:s,error:c}=a(o);e>=c?r.error(`router.${n}`,`${e} listeners registered for "${t}"! This is excessive. Hard limit at ${o}.`):e>=s&&r.warn(`router.${n}`,`${e} listeners registered for "${t}". Consider whether all are necessary — a growing count usually means a missing unsubscribe.`)}function De(e,t){if(!s(e)&&typeof e!=`function`)throw TypeError(`[router.${t}] Handler must be a boolean or factory function, got ${w(e)}`)}function Oe(e,t,n=i.maxLifecycleHandlers){if(n!==0&&e>=n)throw RangeError(`[router.${t}] Lifecycle handler limit exceeded (${n}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`)}function ke(e,t,n,r){if(n===0)return;let{warn:i,error:o}=a(n);e>=o?r.error(`router.${t}`,`${e} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):e>=i&&r.warn(`router.${t}`,`${e} lifecycle handlers registered. Consider consolidating logic.`)}function Ae(e,t,n,r){r.warn(`router.${n}`,`Overwriting existing ${t} handler for route "${e}"`)}function je(e,t,n){n.warn(`router.${t}`,`Guard for "${e}" returned a Promise. Sync check cannot resolve async guards — returning false.`)}const Me=Object.hasOwn,Ne=Object.getPrototypeOf;function Pe(e){if(typeof e!=`string`)throw TypeError(`[router.navigate] Invalid route name: expected string, got ${w(e)}`)}function Fe(e){if(e!==void 0&&(typeof e!=`object`||!e))throw TypeError(`[router.navigateToDefault] Invalid options: ${w(e)}. Expected NavigationOptions object.`)}function Ie(e){if(typeof e!=`object`||!e)throw TypeError(`[router.navigateToState] Invalid state: ${w(e)}. Expected State object.`);let t=e;if(!o(t.name))throw TypeError(`[router.navigateToState] Invalid state.name: ${w(t.name)}. Expected string.`);if(!v(t.params))throw TypeError(`[router.navigateToState] Invalid state.params: ${w(t.params)}. Expected plain object.`);if(!o(t.path))throw TypeError(`[router.navigateToState] Invalid state.path: ${w(t.path)}. Expected string.`)}function k(e,t){if(!y(e))throw TypeError(`[router.${t}] Invalid options: ${w(e)}. Expected NavigationOptions object.`)}const Le=/[\u0000-\u001F\u007F]/;function Re(e,t){for(let n in e){if(!Me(e,n))continue;let r=e[n],i=typeof r;if(i===`symbol`||i===`bigint`)throw TypeError(`[router.${t}] param "${n}" cannot be a ${i} — it does not round-trip through the URL path. Use a string, number, or boolean.`);if(i===`string`&&Le.test(r))throw TypeError(`[router.${t}] param "${n}" must not contain control characters (NUL / C0 / DEL) — they corrupt the URL path.`)}}function A(e,t){if(e===void 0)return;let n=e!==null&&Ne(e);if(Array.isArray(e)||n!==null&&n!==Object.prototype)throw TypeError(`[router.${t}] params must be a plain object, got ${w(e)}`)}function j(e,t){if(e!==void 0&&(Re(e,t),!v(e)))throw TypeError(`[router.${t}] params must be a plain object, got ${w(e)}`)}function M(e,t){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.${t}] search must be a plain object, got ${w(e)}`)}function ze(e){if(e!==void 0&&typeof e!=`string`)throw TypeError(`[router.start] path must be a string, got ${w(e)}.`);if(typeof e==`string`){if(Le.test(e))throw TypeError(`[router.start] path must not contain control characters (NUL / C0 / DEL).`);if(e!==``&&!e.startsWith(`/`))throw TypeError(`[router.start] path must start with "/", got "${e}".`)}}const Be=Object.entries,Ve=Object.hasOwn,N=Object.keys,He=Object.getPrototypeOf,P={trailingSlash:[`strict`,`never`,`always`,`preserve`],queryParamsMode:[`default`,`strict`,`loose`],urlParamsEncoding:[`default`,`uri`,`uriComponent`,`none`]},Ue={arrayFormat:!0,booleanFormat:!0,nullFormat:!0,numberFormat:!0},We=new Set(N({defaultRoute:!0,defaultParams:!0,defaultSearch:!0,trailingSlash:!0,caseSensitive:!0,queryParamsMode:!0,queryParams:!0,urlParamsEncoding:!0,allowNotFound:!0,rewritePathOnMatch:!0,logger:!0,limits:!0})),F={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxLifecycleHandlers:{min:0,max:1e4}};function Ge(e,t,n){if(typeof t!=`number`||!Number.isInteger(t))throw TypeError(`[router.${n}] limit "${e}" must be an integer, got ${String(t)}`);let r=F[e];if(t<r.min||t>r.max)throw RangeError(`[router.${n}] limit "${e}" must be between ${r.min} and ${r.max}, got ${t}`)}function I(e){let t=He(e);return t===null||t===Object.prototype}function Ke(e,t){if(!e||typeof e!=`object`||!I(e))throw TypeError(`[router.${t}] invalid limits: expected plain object, got ${typeof e}`);for(let[n,r]of Be(e)){if(!Ve(F,n))throw TypeError(`[router.${t}] unknown limit: "${n}"`);r!==void 0&&Ge(n,r,t)}let{warnListeners:n,maxListeners:r}=e;if(typeof n==`number`&&typeof r==`number`&&r>0&&n>r)throw RangeError(`[router.${t}] "limits.warnListeners" (${n}) must not exceed "limits.maxListeners" (${r}) — the warning channel would be unreachable`)}function L(e,t,n,r){if(e!==void 0&&(typeof e!=`string`||!n.includes(e))){let i=n.map(e=>`"${e}"`).join(`, `);throw TypeError(`[router.${r}] Invalid "${t}": "${typeof e==`string`?e:`(${typeof e})`}". Must be one of: ${i}`)}}function qe(e,t){if(e!==void 0&&typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.${t}] Invalid "defaultRoute": expected string or function, got ${typeof e}`)}function R(e,t,n){if(e!==void 0&&typeof e!=`function`&&(!e||typeof e!=`object`||Array.isArray(e)||!I(e)))throw TypeError(`[router.${n}] Invalid "${t}": expected plain object or function, got ${typeof e}`)}function Je(e,t){if(e===void 0)return;if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid "queryParams": expected plain object`);let n=e;for(let e of N(n))if(!c(e,Ue))throw TypeError(`[router.${t}] Invalid "queryParams.${e}": unknown option`)}function Ye(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid options: expected plain object`);let n=e;for(let e of N(n))if(!We.has(e))throw TypeError(`[router.${t}] Unknown option: "${e}"`);if(qe(n.defaultRoute,t),R(n.defaultParams,`defaultParams`,t),R(n.defaultSearch,`defaultSearch`,t),L(n.trailingSlash,`trailingSlash`,P.trailingSlash,t),L(n.queryParamsMode,`queryParamsMode`,P.queryParamsMode,t),L(n.urlParamsEncoding,`urlParamsEncoding`,P.urlParamsEncoding,t),n.allowNotFound!==void 0&&typeof n.allowNotFound!=`boolean`)throw TypeError(`[router.${t}] Invalid "allowNotFound": expected boolean, got ${typeof n.allowNotFound}`);if(n.rewritePathOnMatch!==void 0&&typeof n.rewritePathOnMatch!=`boolean`)throw TypeError(`[router.${t}] Invalid "rewritePathOnMatch": expected boolean, got ${typeof n.rewritePathOnMatch}`);if(n.caseSensitive!==void 0&&typeof n.caseSensitive!=`boolean`)throw TypeError(`[router.${t}] Invalid "caseSensitive": expected boolean, got ${typeof n.caseSensitive}`);Je(n.queryParams,t),n.limits!==void 0&&Ke(n.limits,t)}const Xe=Object.hasOwn,z=`router.usePlugin`,Ze={onStart:!0,onStop:!0,onTransitionStart:!0,onTransitionLeaveApprove:!0,onTransitionSuccess:!0,onTransitionError:!0,onTransitionCancel:!0};function Qe(e,t,n=i.maxPlugins){if(n!==0&&e+t>n)throw RangeError(`[router.usePlugin] Plugin limit exceeded (${n}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`)}function $e(e,t){if(t.includes(e))throw Error(`[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.`)}function et(e,t,n){if(t===0)return;let{warn:r,error:i}=a(t);e>=i?n.error(z,`${e} plugins registered! This is excessive. Hard limit at ${t}.`):e>=r&&n.warn(z,`${e} plugins registered. Consider if all are necessary.`)}function tt(e){for(let t in e)if(!(t===`teardown`||Xe(Ze,t)))throw TypeError(`[router.usePlugin] Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`)}function nt(e){e.warn(z,`Duplicate factory in batch, will be registered once`)}function rt(e,t){t.warn(z,`Property '${e}' is not a function, skipping`)}function it(e,t){e===`onStart`&&t.warn(z,`Router already started, onStart will not be called`)}const B=Object.entries,at=Object.getOwnPropertyDescriptor,V=Object.keys;function H(e,t,n=``){for(let r of e){let e=n?`${n}.${r.name}`:r.name;t(r,e),r.children&&H(r.children,t,e)}}function U(e,t){let n=[];return H(e,(e,r)=>{let i=t(e);i!==void 0&&n.push([r,i])}),n}function ot(t,n){try{return(0,e.resolveForwardChain)(t,n)}catch(e){throw Error(`[validation-plugin] ${e.message}`,{cause:e})}}function W(e,t,n){let r=e;if(r.constructor.name===`AsyncFunction`||r.toString().includes(`__awaiter`))throw TypeError(`[validation-plugin] Route "${n}" ${t} cannot be async`)}function st(e){H(e,(e,t)=>{if(typeof e.name!=`string`||!e.name)throw TypeError(`[validation-plugin] validateExistingRoutes: route has invalid name: ${e.name}`);if(typeof e.path!=`string`)throw TypeError(`[validation-plugin] validateExistingRoutes: route "${t}" has non-string path (${typeof e.path})`)})}function ct(e,t){for(let[n,r]of B(e)){if(!t.hasRoute(r))throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${r}" does not exist in tree (source route: "${n}")`);let e=new Set(t.getUrlParams(n)),i=[...new Set(t.getUrlParams(r))].filter(t=>!e.has(t));if(i.length>0)throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${r}" requires params [${i.join(`, `)}] not available in source route "${n}"`)}for(let t of V(e))ot(t,e)}function G(e,t){for(let[n,r]of e)if(typeof r!=`object`||!r||Array.isArray(r))throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${n}" ${t} must be a plain object, got ${Array.isArray(r)?`array`:typeof r}`)}function lt(e){let t=U(e,e=>e.decodeParams),n=U(e,e=>e.encodeParams),r=U(e,e=>typeof e.forwardTo==`string`?void 0:e.forwardTo);for(let[e,n]of t){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" decoder must be a function, got ${typeof n}`);W(n,`decoder`,e)}for(let[e,t]of n){if(typeof t!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" encoder must be a function, got ${typeof t}`);W(t,`encoder`,e)}G(U(e,e=>e.defaultParams),`defaultParams`),G(U(e,e=>e.defaultSearch),`defaultSearch`);for(let[e,t]of r){if(typeof t!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" forwardTo callback must be a function, got ${typeof t}`);W(t,`forwardTo callback`,e)}}function ut(e,t){for(let[n,r]of B(e))if(!t.hasRoute(r))throw Error(`[validation-plugin] validateForwardToTargetsStore: forwardTo target "${r}" does not exist for route "${n}"`)}function dt(e,t){for(let t of V(e))if(at(e,t)?.get)throw TypeError(`[validation-plugin] validateDependenciesStructure: dependency "${t}" must not use a getter`);for(let[e,n]of B(t))if(!Number.isInteger(n))throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.limits.${e} must be an integer, got ${String(n)}`)}function ft(e,t,n){let r=e&&typeof e==`object`?e:{},i=(r.limits&&typeof r.limits==`object`?r.limits:{}).maxDependencies,a=typeof i==`number`?i:n;if(a>0&&t>a)throw RangeError(`[validation-plugin] validateLimitsConsistency: dependency count (${t}) exceeds maxDependencies limit (${a})`)}function K(e,t){if(typeof e==`string`&&e&&!t.hasRoute(e))throw Error(`[validation-plugin] defaultRoute resolved to non-existent route: "${e}"`)}function pt(e,t,n){for(let r of e)t.hasRoute(r)||n.warn(`router.start`,`Guard registered for route "${r}", which the route tree does not contain. It will never run unless that route is added. Check the name for a typo.`)}const mt=Object.keys;function ht(e,t){if(e!==void 0){if(typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.addRoute] forwardTo must be a string or function for route "${t}", got ${w(e)}`);if(typeof e==`function`){let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}}}function q(e,t,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.addRoute] ${t} must be an object for route "${n}", got ${w(e)}`)}function J(e,t){if(e.canActivate!==void 0&&typeof e.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function for route "${t}", got ${w(e.canActivate)}`);if(e.canDeactivate!==void 0&&typeof e.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function for route "${t}", got ${w(e.canDeactivate)}`);if(q(e.defaultParams,`defaultParams`,t),q(e.defaultSearch,`defaultSearch`,t),e.decodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(e.encodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(ht(e.forwardTo,t),e.children)for(let n of e.children)J(n,`${t}.${n.name}`)}function gt(e){let t=new Set,n=/[*:]([A-Z_a-z]\w*)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);return t}function Y(e){let t=new Set;for(let n of e)for(let e of gt(n))t.add(e);return t}function X(e,t,n=``,r=[]){for(let i of e){let e=n?`${n}.${i.name}`:i.name,a=[...r,i.path];if(e===t)return a;if(i.children&&t.startsWith(`${e}.`))return X(i.children,t,e,a)}throw Error(`[internal] collectPathsToRoute: route "${t}" not found`)}function _t(e,t=``){let n=new Set;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(n.add(e),r.children)for(let t of _t(r.children,e))n.add(t)}return n}function vt(e,t=``){let n=new Map;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(r.forwardTo&&typeof r.forwardTo==`string`&&n.set(e,r.forwardTo),r.children)for(let[t,i]of vt(r.children,e))n.set(t,i)}return n}function yt(e,t,n,r){return t?new Set(n.getUrlParams(e)):Y(X(r,e))}const bt=new Set;function xt(e,t,n,r,i,a){let o=i.hasRoute(t),s=r.has(t);if(!o&&!s)throw ReferenceError(`[router.addRoute] forwardTo target "${t}" does not exist for route "${e}"`);let c=new Set([...a,...Y(X(n,e))]),l=[...yt(t,o,i,n)].filter(e=>!c.has(e));if(l.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${l.join(`, `)}] that are not available in source route "${e}"`)}function St(t,r,i,a){let o=_t(t),s=a?new Set([...o].map(e=>`${a}.${e}`)):o,c=a?new Set(i.getUrlParams(a)):bt,l=vt(t),u={...r};for(let[e,t]of l)(0,n.putField)(u,e,t);for(let[e,n]of l)xt(e,n,t,s,i,c);for(let t of mt(u))(0,e.resolveForwardChain)(t,u)}function Z(e,t){if(e.startsWith(`@@`))throw 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 Ct(e,t){for(let n of e)n&&typeof n==`object`&&typeof n.name==`string`&&(Z(n.name,t),n.children&&Ct(n.children,t))}function wt(e){C(e,`removeRoute`)}function Tt(e){if(typeof e!=`string`)throw TypeError(`[router.setRootPath] rootPath must be a string, got ${w(e)}`)}function Q(e){return e.constructor.name===`AsyncFunction`||String(e).includes(`__awaiter`)}function Et(e){let t=e;if(t.canActivate!==void 0&&typeof t.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function, got ${w(t.canActivate)}`);if(t.canDeactivate!==void 0&&typeof t.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function, got ${w(t.canDeactivate)}`)}function Dt(e){let t=e,n=t.name;if(t.decodeParams!==void 0&&Q(t.decodeParams))throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${String(n)}"`);if(t.encodeParams!==void 0&&Q(t.encodeParams))throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${String(n)}"`);if(typeof t.forwardTo==`function`&&Q(t.forwardTo))throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${String(n)}"`)}function Ot(e){for(let t of e){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`[router.addRoute] Route must be an object, got ${w(t)}`);J(t,t.name)}}function kt(e){if(typeof e!=`string`||e===``)throw TypeError(`[router.addRoute] parent option must be a non-empty string, got ${w(e)}`);C(e,`addRoute`)}function At(e,t,n,r){if(!o(e))throw TypeError(`[router.isActiveRoute] name must be a string, got ${typeof e}`);if(A(t,`isActiveRoute`),n!==void 0&&typeof n!=`boolean`)throw TypeError(`[router.isActiveRoute] strictEquality must be a boolean, got ${typeof n}`);if(r!==void 0&&typeof r!=`boolean`)throw TypeError(`[router.isActiveRoute] ignoreQueryParams must be a boolean, got ${typeof r}`)}function jt(e,t,n){if(!o(e))throw TypeError(`[router.${n}] Invalid routeName: ${w(e)}. Expected string.`);if(!v(t))throw TypeError(`[router.${n}] Invalid routeParams: ${w(t)}. Expected plain object.`)}function Mt(e,t){if(C(e,`updateRoute`),e===``)throw ReferenceError(`[router.updateRoute] Invalid name: empty string. Cannot update root node.`);if(t===null)throw TypeError(`[router.updateRoute] updates must be an object, got null`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`[router.updateRoute] updates must be an object, got ${w(t)}`)}function Nt(e,t){if(e.constructor.name===`AsyncFunction`||e.toString().includes(`__awaiter`))throw TypeError(`[router.updateRoute] ${t} cannot be an async function`)}function $(e,t){if(e!=null){if(typeof e!=`function`)throw TypeError(`[router.updateRoute] ${t} must be a function or null, got ${typeof e}`);Nt(e,t)}}function Pt(e){let{forwardTo:t,defaultParams:n,defaultSearch:r,decodeParams:i,encodeParams:a,canActivate:o,canDeactivate:s}=e;if(t!=null){if(typeof t!=`string`&&typeof t!=`function`)throw TypeError(`[router.updateRoute] forwardTo must be a string, function, or null, got ${w(t)}`);typeof t==`function`&&Nt(t,`forwardTo callback`)}Ft(n,`defaultParams`),Ft(r,`defaultSearch`),$(i,`decodeParams`),$(a,`encodeParams`),$(o,`canActivate`),$(s,`canDeactivate`)}function Ft(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw TypeError(`[router.updateRoute] ${t} must be an object or null, got ${w(e)}`)}function It(e){if(!o(e)||e===``)throw TypeError(`[router.buildPath] route must be a non-empty string, got ${typeof e==`string`?`""`:typeof e}`)}function Lt(e){let t=new Set;return function(n,i){let a=(0,r.findMisChanneledKey)(i,e(n));if(a===void 0)return;let o=`${n} ${a}`;t.has(o)||(t.add(o),console.warn(`[router] Route "${n}" declares \`${a}\` as a query param, but it was given in the \`params\` bag — the path channel. The URL is built without it, so the href does not match what you asked for; a plain click throws, but a ⌘-click, a copied link and server-rendered markup all follow the wrong URL in silence. Pass it in \`search\` instead.`))}}function Rt(e){if(!o(e))throw TypeError(`[router.matchPath] path must be a string, got ${typeof e}`)}function zt(e){if(!o(e))throw TypeError(`[router.shouldUpdateNode] nodeName must be a string, got ${typeof e}`)}function Bt(e,t,n,i,a){if(a){let e=t;for(let t of a.split(`.`))if(e=e.children.get(t),!e)throw ReferenceError(`[router.addRoute] Parent route "${a}" does not exist`)}let o=new Set,s=new Map;for(let n of e)(0,r.validateRoute)(n,`addRoute`,t,a??``,o,s);St(e,i,n,a)}function Vt(e,t,n){let r=new Set(n.getUrlParams(e)),i=n.getUrlParams(t).filter(e=>!r.has(e));if(i.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${i.join(`, `)}] that are not available in source route "${e}"`)}function Ht(t,n,r){let i={...r,[t]:n};(0,e.resolveForwardChain)(t,i)}function Ut(e,t,n,r){if(!n.hasRoute(e))throw ReferenceError(`[router.updateRoute] route "${e}" does not exist`);if(t!=null&&typeof t==`string`){if(!n.hasRoute(t))throw Error(`[router.updateRoute] forwardTo target "${t}" does not exist`);Vt(e,t,n),Ht(e,t,r)}}function Wt(e,t,n){if(!o(e))throw TypeError(`[router.makeState] Invalid name: ${w(e)}. Expected string.`);if(t!==void 0&&!v(t))throw TypeError(`[router.makeState] Invalid params: ${w(t)}. Expected plain object.`);if(n!==void 0&&!o(n))throw TypeError(`[router.makeState] Invalid path: ${w(n)}. Expected string.`)}function Gt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Query key "${n}" is not declared on route "${t}" (\`?${n}\`), so the current \`queryParamsMode\` will not print it — it was dropped from \`state.search\` rather than published beside a \`state.path\` that cannot show it. Declare it on the route path, or use \`queryParamsMode: "loose"\` to keep undeclared keys. A \`defaultSearch\` entry for "${n}" is dead config in this mode for the same reason.`))}}function Kt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Param "${n}" is declared nowhere on route "${t}" — neither as a path slot (:${n}) nor as a query param (?${n}), so it stays in state.params but never reaches the URL. The state will not round-trip: matchPath(state.path) cannot recover it. Declare it on the route path if it belongs in the URL, or pass it through the search channel; keep it here only if it is deliberately app-level data.`))}}function qt(e){return{hasRoute:t=>{let n=e.getTree();for(let e of t.split(`.`))if(n=n?.children.get(e),!n)return!1;return!0},getUrlParams:t=>e.getUrlParams(t)}}function Jt(e,t){let n=[];for(let r of e.getTree().children.keys())n.push(t.get(r));return n}function Yt(e,t,n){let r=Lt(t=>e.getDeclaredQueryNames(t));return{routes:{validateBuildPathArgs(e,t){It(e),r(e,t)},validateMatchPathArgs:Rt,validateIsActiveRouteArgs(e,t,n,i){At(e,t,n,i),r(e,t)},validateShouldUpdateNodeArgs:zt,validateStateBuilderArgs:jt,validateRouteName(e,t){C(e,t)},validateSetRootPathArgs:Tt},options:{validateOptions:Ye,validateResolvedDefaultRoute(e){K(e,t)}},dependencies:{validateDependencyName:fe,validateSetDependencyArgs(e,t,n){pe(e)},validateDependenciesObject(t,n){me(t,n),he(t,e.getDependencyKeys(),e.getResolvedLimits().maxDependencies,n)},validateDependencyExists(e,t){ge(t,e)},validateDependencyCount(t,n,r){_e(t,n,r,e.logger)},validateCloneArgs:ve,warnOverwrite(t,n){ye(t,n,e.logger)},warnBatchOverwrite(t,n){be(t,n,e.logger)},warnRemoveNonExistent(t){xe(t,e.logger)}},plugins:{validatePluginLimit(e,t){Qe(e,1,t?.maxPlugins)},validateNoDuplicatePlugins:$e,validatePluginKeys:tt,validateCountThresholds(t){et(t,e.getOptions().limits?.maxPlugins??i.maxPlugins,e.logger)},warnBatchDuplicates(){nt(e.logger)},warnPluginMethodType(t){rt(t,e.logger)},warnPluginAfterStart(t){it(t,e.logger)}},lifecycle:{validateHandler:De,validateHandlerLimit(t,n){Oe(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers)},validateCountThresholds(t,n){ke(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers,e.logger)},warnOverwrite(t,n,r){Ae(t,n,r,e.logger)},warnAsyncGuardSync(t,n){je(t,n,e.logger)}},navigation:{validateNavigateToDefaultArgs(t){Fe(t),n.check(e.logger)},validateNavigateToStateArgs:Ie,validateNavigationOptions:k,validateParamsShape:A,validateSearch:M,validateStartArgs:ze},state:{validateMakeStateArgs:Wt,reportDroppedQueryKey:Gt(),reportUndeclaredParamKey:Kt(),validateAreStatesEqualArgs(e,t,n){if(!ae(e))throw TypeError(`[router.areStatesEqual] Invalid state1: ${w(e)}. Expected State object.`);if(!ae(t))throw TypeError(`[router.areStatesEqual] Invalid state2: ${w(t)}. Expected State object.`);if(n!==void 0&&!s(n))throw TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${w(n)}. Expected boolean.`)}},eventBus:{validateListenerArgs(e,t){Te(e,t)},validateCountThresholds(t,n,r){let a=e.getOptions().limits?.maxListeners??i.maxListeners;Ee(t,n,r,e.logger,a)}}}}function Xt(){return i=>{let a=(0,r.getInternals)(i),o=(0,t.getPluginApi)(i);if(i.isActive())throw(0,n.freezeThrownError)(new e.RouterError(`VALIDATION_PLUGIN_AFTER_START`,{message:`validation-plugin must be registered before router.start()`}));if(a.validator!==null)throw(0,n.freezeThrownError)(new e.RouterError(`VALIDATION_PLUGIN_ALREADY_INSTALLED`,{message:`validation-plugin is already installed on this router — a clone re-runs plugin factories, so it needs no usePlugin of its own`}));let s=new le;s.watch(o.getAdoptedOrigins());let c=qt(o),l=Yt(o,c,s),u=()=>{a.validator===l&&(a.validator=null)};a.validator=l;try{let e=Jt(o,(0,t.getRoutesApi)(i)),n=o.getForwardMap(),r=o.getResolvedLimits(),s=o.getOptions();st(e),ct(n,c),lt(e),ut(n,c),dt(a.dependenciesGetStore().dependencies,r),ft(s,o.getDependencyKeys().length,r.maxDependencies),a.validator.options.validateOptions(s,`constructor (retrospective)`),typeof s.defaultRoute==`string`&&K(s.defaultRoute,c)}catch(e){throw u(),e}let d=o.addInterceptor(`start`,(e,t)=>{try{pt(o.getExternalGuardNames(),c,o.logger)}catch{}return e(t)}),f=o.addCheck(`buildPath:params`,e=>{j(e,`buildPath`)}),p=o.addCheck(`buildPathResolved:params`,e=>{j(e,`buildPathResolved`)}),m=o.addCheck(`canNavigateTo:entry`,(e,t,n)=>{C(e,`canNavigateTo`),A(t,`canNavigateTo`),M(n,`canNavigateTo`)}),h=o.addCheck(`canNavigateTo:params`,e=>{j(e,`canNavigateTo`)}),ee=o.addCheck(`navigate:entry`,(e,t,n,r)=>{Pe(e),A(t,`navigate`),M(n,`navigate`),k(r,`navigate`)}),g=o.addCheck(`navigate:params`,e=>{j(e,`navigate`)}),_=e=>{for(let t of e)Et(t),Dt(t),t.children!==void 0&&_(t.children)},v=(e,t,n)=>{if(_(e),n!==void 0&&(kt(n),!c.hasRoute(n)))throw ReferenceError(`[router.addRoute] Parent route "${n}" does not exist`);Ct(e,t),Ot(e),Bt(e,o.getTree(),c,o.getForwardMap(),n)},te=o.addCheck(`addRoute:batch`,(e,t)=>{v(e,`addRoute`,t)}),ne=o.addCheck(`replaceRoutes:batch`,e=>{v(e,`replaceRoutes`,void 0)}),y=o.addCheck(`removeRoute:entry`,e=>{wt(e),Z(e,`removeRoute`)}),b=o.addCheck(`updateRoute:entry`,(e,t)=>{let n=t;Mt(e,t),Z(e,`updateRoute`),Pt({forwardTo:n.forwardTo,defaultParams:n.defaultParams,defaultSearch:n.defaultSearch,decodeParams:n.decodeParams,encodeParams:n.encodeParams,canActivate:n.canActivate,canDeactivate:n.canDeactivate}),Ut(e,n.forwardTo,c,o.getForwardMap())}),x=o.addCheck(`hasRoute:entry`,e=>{C(e,`hasRoute`)}),S=o.addCheck(`getRoute:entry`,e=>{C(e,`getRoute`)});return{teardown(){f(),p(),m(),h(),ee(),g(),te(),ne(),y(),b(),x(),S(),d(),u()}}}}exports.validationPlugin=Xt;
2
2
  //# sourceMappingURL=index.js.map