@real-router/validation-plugin 0.28.2 → 0.28.3

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.
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@real-router/core/api"),t=require("@real-router/core/utils"),n=require("@real-router/core/validation"),r=require("@real-router/core");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 ee(e){if(Array.isArray(e))return!0;let t=l(e);return t===null||t===Object.prototype}function te(e,t){let n=Array.isArray(e)?e:u(e);for(let e of n)t.push(e)}function f(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}var p=class{container;constructor(e){this.container=e}};function m(e,t,n,r){return n.has(e)?!1:r.has(e)?!0:ee(e)?(n.add(e),t.push(new p(e)),te(e,t),!0):!1}function h(e){let t=[e],n=new WeakSet,r=new WeakSet;for(;t.length>0;){let e=t.pop();if(e instanceof p){n.delete(e.container),r.add(e.container);continue}if(e!=null){if(typeof e==`object`){if(!m(e,t,n,r))return!1;continue}if(!f(e))return!1}}return!0}function ne(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}function g(e){try{return _(e)}catch{return!1}}function _(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(!ne(r)){let e=typeof r;if(e===`function`||e===`symbol`)return!1;n=!0;break}}return!n||h(e)}const re=[`replace`,`reload`,`force`,`forceDeactivate`,`redirected`,`revalidate`];function ie(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;for(let e of re){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 ae=/\S/,v=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function y(e,n){return(0,t.raiser)(`router`,e).type`${n}`}function oe(e){return typeof e==`string`?e===``?!0:e.length>1e4?!1:e.startsWith(`@@`)?!0:v.test(e):!1}function se(e){return oe(e.name)&&typeof e.path==`string`&&g(e.params)}function b(e){return typeof e!=`object`||!e?!1:se(e)}function x(e,t){if(typeof e!=`string`)throw y(t,`Route name must be a string, got ${typeof e}`);if(e!==``){if(!ae.test(e))throw y(t,`Route name cannot contain only whitespace`);if(e.length>1e4)throw y(t,`Route name exceeds maximum length of 10000 characters. This is a technical safety limit.`);if(!e.startsWith(`@@`)&&!v.test(e))throw y(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 S(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 C=Object.entries,ce=[`defaultParams`,`defaultSearch`],le=e=>new Map(C(e)),ue=(e,t)=>{let n=C(e);return n.length!==t.size||n.some(([e,n])=>!t.has(e)||!Object.is(t.get(e),n))};var de=class{#e=new Map;#t=new Set;watch(e){for(let t of ce){let n=e[t],r=n?.deref();n!==void 0&&r!==void 0&&this.#e.set(t,{ref:n,before:le(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&&ue(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 fe=(0,t.raiser)(`cloneRouter`),pe=(0,t.raiser)(`router`,`getDependency`),me=(0,t.raiser)(`router`,`setDependency`),w=Object.keys,he=Object.getOwnPropertyDescriptor,ge=Object.getPrototypeOf,_e=Object;function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=ge(e);return t===null||t.constructor===_e}function ve(e,n){if(typeof e!=`string`)throw(0,t.raiser)(`router`,n).type`dependency name must be a string, got ${typeof e}`}function ye(e){if(typeof e!=`string`)throw me.type`dependency name must be a string, got ${typeof e}`}function be(e,n){if(!T(e))throw(0,t.raiser)(`router`,n).type`Invalid argument: expected plain object, received ${S(e)}`;for(let r of w(e))if(he(e,r)?.get)throw(0,t.raiser)(`router`,n).type`Getters not allowed: "${r}"`}function xe(e,n,r,i){if(r===0)return;let a=new Set(n),o=0;for(let t of w(e))a.has(t)||(o+=1);let s=n.length;if(s+o>r)throw(0,t.raiser)(`router`,i).range`Dependency limit exceeded (${r}). Current: ${s}, this batch adds ${o}.`}function Se(e,t){if(e===void 0)throw pe.ref`dependency "${t}" not found`}function Ce(e,n,r,i){if(n===0)return;let{warn:o,error:s}=a(n);if(e>=n)throw(0,t.raiser)(`router`,r).range`Dependency limit exceeded (${n}). Current: ${e}.`;e===s?i.error(`router.${r}`,`${e} dependencies registered! This indicates architectural problems. Hard limit at ${n}.`):e===o&&i.warn(`router.${r}`,`${e} dependencies registered. Consider if all are necessary.`)}function we(e){if(e!==void 0){if(!T(e))throw fe.type`Invalid dependencies: expected plain object or undefined, received ${typeof e}`;for(let t of w(e))if(he(e,t)?.get)throw fe.type`Getters not allowed in dependencies: "${t}"`}}function Te(e,t,n){n.warn(`router.${t}`,`Router dependency already exists and is being overwritten:`,e)}function Ee(e,t,n){n.warn(`router.${t}`,`Overwritten:`,e.join(`, `))}function De(e,t){t.warn(`router.removeDependency`,`Attempted to remove non-existent dependency: "${typeof e==`string`?e:String(e)}"`)}const Oe=(0,t.raiser)(`router`,`addEventListener`),ke=Object.values,Ae=new Set(ke(r.events));function je(e){if(!Ae.has(e))throw Oe.type`Invalid event name: ${String(e)}. Must be one of: $start, $stop, $$start, $$leaveApprove, $$cancel, $$success, $$error`}function Me(e,t){if(je(e),typeof t!=`function`)throw Oe.type`callback must be a function, got ${typeof t}`}function Ne(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 Pe(e,n){if(!s(e)&&typeof e!=`function`)throw(0,t.raiser)(`router`,n).type`Handler must be a boolean or factory function, got ${S(e)}`}function Fe(e,n,r=i.maxLifecycleHandlers){if(r!==0&&e>=r)throw(0,t.raiser)(`router`,n).range`Lifecycle handler limit exceeded (${r}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`}function Ie(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 Le(e,t,n,r){r.warn(`router.${n}`,`Overwriting existing ${t} handler for route "${e}"`)}function Re(e,t,n){n.warn(`router.${t}`,`Guard for "${e}" returned a Promise. Sync check cannot resolve async guards — returning false.`)}const E=(0,t.raiser)(`router`,`start`),D=(0,t.raiser)(`router`,`navigateToState`),ze=(0,t.raiser)(`router`,`navigateToDefault`),Be=(0,t.raiser)(`router`,`navigate`),Ve=Object.hasOwn,He=Object.getPrototypeOf;function Ue(e){if(typeof e!=`string`)throw Be.type`Invalid route name: expected string, got ${S(e)}`}function We(e){if(e!==void 0&&(typeof e!=`object`||!e))throw ze.type`Invalid options: ${S(e)}. Expected NavigationOptions object.`}function Ge(e){if(typeof e!=`object`||!e)throw D.type`Invalid state: ${S(e)}. Expected State object.`;let t=e;if(!o(t.name))throw D.type`Invalid state.name: ${S(t.name)}. Expected string.`;if(!g(t.params))throw D.type`Invalid state.params: ${S(t.params)}. Expected plain object.`;if(!o(t.path))throw D.type`Invalid state.path: ${S(t.path)}. Expected string.`}function O(e,n){if(!ie(e))throw(0,t.raiser)(`router`,n).type`Invalid options: ${S(e)}. Expected NavigationOptions object.`}const Ke=/[\u0000-\u001F\u007F]/;function qe(e,n){for(let r in e){if(!Ve(e,r))continue;let i=e[r],a=typeof i;if(a===`symbol`||a===`bigint`)throw(0,t.raiser)(`router`,n).type`param "${r}" cannot be a ${a} — it does not round-trip through the URL path. Use a string, number, or boolean.`;if(a===`string`&&Ke.test(i))throw(0,t.raiser)(`router`,n).type`param "${r}" must not contain control characters (NUL / C0 / DEL) — they corrupt the URL path.`}}function k(e,n){if(e===void 0)return;let r=e!==null&&He(e);if(Array.isArray(e)||r!==null&&r!==Object.prototype)throw(0,t.raiser)(`router`,n).type`params must be a plain object, got ${S(e)}`}function A(e,n){if(e!==void 0&&(qe(e,n),!g(e)))throw(0,t.raiser)(`router`,n).type`params must be a plain object, got ${S(e)}`}function j(e,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw(0,t.raiser)(`router`,n).type`search must be a plain object, got ${S(e)}`}function Je(e){if(e!==void 0&&typeof e!=`string`)throw E.type`path must be a string, got ${S(e)}.`;if(typeof e==`string`){if(Ke.test(e))throw E.type`path must not contain control characters (NUL / C0 / DEL).`;if(e!==``&&!e.startsWith(`/`))throw E.type`path must start with "/", got "${e}".`}}const Ye=Object.entries,Xe=Object.hasOwn,M=Object.keys,Ze=Object.getPrototypeOf,N={trailingSlash:[`strict`,`never`,`always`,`preserve`],queryParamsMode:[`default`,`strict`,`loose`],urlParamsEncoding:[`default`,`uri`,`uriComponent`,`none`]},Qe={arrayFormat:!0,booleanFormat:!0,nullFormat:!0,numberFormat:!0},$e=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})),et={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 tt(e,n,r){if(typeof n!=`number`||!Number.isInteger(n))throw(0,t.raiser)(`router`,r).type`limit "${e}" must be an integer, got ${String(n)}`;let i=et[e];if(n<i.min||n>i.max)throw(0,t.raiser)(`router`,r).range`limit "${e}" must be between ${i.min} and ${i.max}, got ${n}`}function nt(e){let t=Ze(e);return t===null||t===Object.prototype}function rt(e,n){if(!e||typeof e!=`object`||!nt(e))throw(0,t.raiser)(`router`,n).type`invalid limits: expected plain object, got ${typeof e}`;for(let[r,i]of Ye(e)){if(!Xe(et,r))throw(0,t.raiser)(`router`,n).type`unknown limit: "${r}"`;i!==void 0&&tt(r,i,n)}let{warnListeners:r,maxListeners:i}=e;if(typeof r==`number`&&typeof i==`number`&&i>0&&r>i)throw(0,t.raiser)(`router`,n).range`"limits.warnListeners" (${r}) must not exceed "limits.maxListeners" (${i}) — the warning channel would be unreachable`}function P(e,n,r,i){if(e!==void 0&&(typeof e!=`string`||!r.includes(e))){let a=r.map(e=>`"${e}"`).join(`, `),o=typeof e==`string`?e:`(${typeof e})`;throw(0,t.raiser)(`router`,i).type`Invalid "${n}": "${o}". Must be one of: ${a}`}}function it(e,n){if(e!==void 0&&typeof e!=`string`&&typeof e!=`function`)throw(0,t.raiser)(`router`,n).type`Invalid "defaultRoute": expected string or function, got ${typeof e}`}function F(e,n,r){if(e!==void 0&&typeof e!=`function`&&(!e||typeof e!=`object`||Array.isArray(e)||!nt(e)))throw(0,t.raiser)(`router`,r).type`Invalid "${n}": expected plain object or function, got ${typeof e}`}function at(e,n){if(e===void 0)return;if(!e||typeof e!=`object`||Array.isArray(e))throw(0,t.raiser)(`router`,n).type`Invalid "queryParams": expected plain object`;let r=e;for(let e of M(r))if(!c(e,Qe))throw(0,t.raiser)(`router`,n).type`Invalid "queryParams.${e}": unknown option`}function ot(e,n){if(!e||typeof e!=`object`||Array.isArray(e))throw(0,t.raiser)(`router`,n).type`Invalid options: expected plain object`;let r=e;for(let e of M(r))if(!$e.has(e))throw(0,t.raiser)(`router`,n).type`Unknown option: "${e}"`;if(it(r.defaultRoute,n),F(r.defaultParams,`defaultParams`,n),F(r.defaultSearch,`defaultSearch`,n),P(r.trailingSlash,`trailingSlash`,N.trailingSlash,n),P(r.queryParamsMode,`queryParamsMode`,N.queryParamsMode,n),P(r.urlParamsEncoding,`urlParamsEncoding`,N.urlParamsEncoding,n),r.allowNotFound!==void 0&&typeof r.allowNotFound!=`boolean`)throw(0,t.raiser)(`router`,n).type`Invalid "allowNotFound": expected boolean, got ${typeof r.allowNotFound}`;if(r.rewritePathOnMatch!==void 0&&typeof r.rewritePathOnMatch!=`boolean`)throw(0,t.raiser)(`router`,n).type`Invalid "rewritePathOnMatch": expected boolean, got ${typeof r.rewritePathOnMatch}`;if(r.caseSensitive!==void 0&&typeof r.caseSensitive!=`boolean`)throw(0,t.raiser)(`router`,n).type`Invalid "caseSensitive": expected boolean, got ${typeof r.caseSensitive}`;at(r.queryParams,n),r.limits!==void 0&&rt(r.limits,n)}const I=(0,t.raiser)(`router`,`usePlugin`),st=Object.hasOwn,L=`router.usePlugin`,ct={onStart:!0,onStop:!0,onTransitionStart:!0,onTransitionLeaveApprove:!0,onTransitionSuccess:!0,onTransitionError:!0,onTransitionCancel:!0};function lt(e,t,n=i.maxPlugins){if(n!==0&&e+t>n)throw I.range`Plugin limit exceeded (${n}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`}function ut(e,t){if(t.includes(e))throw I.plain`Plugin factory already registered. To re-register, first unsubscribe the existing plugin.`}function dt(e,t,n){if(t===0)return;let{warn:r,error:i}=a(t);e>=i?n.error(L,`${e} plugins registered! This is excessive. Hard limit at ${t}.`):e>=r&&n.warn(L,`${e} plugins registered. Consider if all are necessary.`)}function ft(e){for(let t in e)if(!(t===`teardown`||st(ct,t)))throw I.type`Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`}function pt(e){e.warn(L,`Duplicate factory in batch, will be registered once`)}function mt(e,t){t.warn(L,`Property '${e}' is not a function, skipping`)}function ht(e,t){e===`onStart`&&t.warn(L,`Router already started, onStart will not be called`)}const gt=(0,t.raiser)(`router`,`navigateToDefault`),R=(0,t.raiser)(`validation-plugin`),z=Object.entries,_t=Object.getOwnPropertyDescriptor,vt=Object.keys;function B(e,t,n=``){for(let r of e){let e=n?`${n}.${r.name}`:r.name;t(r,e),r.children&&B(r.children,t,e)}}function V(e,t){let n=[];return B(e,(e,r)=>{let i=t(e);i!==void 0&&n.push([r,i])}),n}function yt(e,t){try{return(0,r.resolveForwardChain)(e,t)}catch(e){let t=e.message.replace(/^\[router\] /u,``);throw R.plain({cause:e})`${t}`}}function H(e,t,n){let r=e;if(r.constructor.name===`AsyncFunction`||r.toString().includes(`__awaiter`))throw R.type`Route "${n}" ${t} cannot be async`}function bt(e){B(e,(e,t)=>{if(typeof e.name!=`string`||!e.name)throw R.type`validateExistingRoutes: route has invalid name: ${e.name}`;if(typeof e.path!=`string`)throw R.type`validateExistingRoutes: route "${t}" has non-string path (${typeof e.path})`})}function xt(e,t){for(let[n,r]of z(e)){if(!t.hasRoute(r))throw R.plain`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 R.plain`validateForwardToConsistency: forwardTo target "${r}" requires params [${i.join(`, `)}] not available in source route "${n}"`}for(let t of vt(e))yt(t,e)}function St(e,t){for(let[n,r]of e)if(typeof r!=`object`||!r||Array.isArray(r))throw R.type`validateRoutePropertiesStore: route "${n}" ${t} must be a plain object, got ${Array.isArray(r)?`array`:typeof r}`}function Ct(e){let t=V(e,e=>e.decodeParams),n=V(e,e=>e.encodeParams),r=V(e,e=>typeof e.forwardTo==`string`?void 0:e.forwardTo);for(let[e,n]of t){if(typeof n!=`function`)throw R.type`validateRoutePropertiesStore: route "${e}" decoder must be a function, got ${typeof n}`;H(n,`decoder`,e)}for(let[e,t]of n){if(typeof t!=`function`)throw R.type`validateRoutePropertiesStore: route "${e}" encoder must be a function, got ${typeof t}`;H(t,`encoder`,e)}St(V(e,e=>e.defaultParams),`defaultParams`),St(V(e,e=>e.defaultSearch),`defaultSearch`);for(let[e,t]of r){if(typeof t!=`function`)throw R.type`validateRoutePropertiesStore: route "${e}" forwardTo callback must be a function, got ${typeof t}`;H(t,`forwardTo callback`,e)}}function wt(e,t){for(let[n,r]of z(e))if(!t.hasRoute(r))throw R.plain`validateForwardToTargetsStore: forwardTo target "${r}" does not exist for route "${n}"`}function Tt(e,t){for(let t of vt(e))if(_t(e,t)?.get)throw R.type`validateDependenciesStructure: dependency "${t}" must not use a getter`;for(let[e,n]of z(t))if(!Number.isInteger(n))throw R.type`validateDependenciesStructure: deps.limits.${e} must be an integer, got ${String(n)}`}function Et(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 R.range`validateLimitsConsistency: dependency count (${t}) exceeds maxDependencies limit (${a})`}function Dt(e,t){return typeof e==`string`&&e!==``&&!t.hasRoute(e)}function Ot(e,t){if(Dt(e,t))throw R.plain`defaultRoute resolved to non-existent route: "${e}"`}function kt(e,t){if(Dt(e,t))throw gt.plain`defaultRoute callback resolved to non-existent route: "${e}"`}function At(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 U=(0,t.raiser)(`router`,`addRoute`),jt=Object.keys;function Mt(e,t){if(e!==void 0){if(typeof e!=`string`&&typeof e!=`function`)throw U.type`forwardTo must be a string or function for route "${t}", got ${S(e)}`;if(typeof e==`function`){let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw U.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}}}function Nt(e,t,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw U.type`${t} must be an object for route "${n}", got ${S(e)}`}function Pt(e,t){if(e.canActivate!==void 0&&typeof e.canActivate!=`function`)throw U.type`canActivate must be a function for route "${t}", got ${S(e.canActivate)}`;if(e.canDeactivate!==void 0&&typeof e.canDeactivate!=`function`)throw U.type`canDeactivate must be a function for route "${t}", got ${S(e.canDeactivate)}`;if(Nt(e.defaultParams,`defaultParams`,t),Nt(e.defaultSearch,`defaultSearch`,t),e.decodeParams?.constructor.name===`AsyncFunction`)throw U.type`decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`;if(e.encodeParams?.constructor.name===`AsyncFunction`)throw U.type`encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`;if(Mt(e.forwardTo,t),e.children)for(let n of e.children)Pt(n,`${t}.${n.name}`)}function Ft(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 It(e){let t=new Set;for(let n of e)for(let e of Ft(n))t.add(e);return t}function W(e,n,r=``,i=[]){for(let t of e){let e=r?`${r}.${t.name}`:t.name,a=[...i,t.path];if(e===n)return a;if(t.children&&n.startsWith(`${e}.`))return W(t.children,n,e,a)}throw t.internalDefect.plain`collectPathsToRoute: route "${n}" not found`}function Lt(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 Lt(r.children,e))n.add(t)}return n}function Rt(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 Rt(r.children,e))n.set(t,i)}return n}function zt(e,t,n,r){return t?new Set(n.getUrlParams(e)):It(W(r,e))}const Bt=new Set;function Vt(e,t,n,r,i,a){let o=i.hasRoute(t),s=r.has(t);if(!o&&!s)throw U.ref`forwardTo target "${t}" does not exist for route "${e}"`;let c=new Set([...a,...It(W(n,e))]),l=[...zt(t,o,i,n)].filter(e=>!c.has(e));if(l.length>0)throw U.plain`forwardTo target "${t}" requires params [${l.join(`, `)}] that are not available in source route "${e}"`}function Ht(e,n,i,a){let o=Lt(e),s=a?new Set([...o].map(e=>`${a}.${e}`)):o,c=a?new Set(i.getUrlParams(a)):Bt,l=Rt(e),u={...n};for(let[e,n]of l)(0,t.putField)(u,e,n);for(let[t,n]of l)Vt(t,n,e,s,i,c);for(let e of jt(u))(0,r.resolveForwardChain)(e,u)}const G=(0,t.raiser)(`router`,`updateRoute`),K=(0,t.raiser)(`router`,`addRoute`),Ut=(0,t.raiser)(`router`,`shouldUpdateNode`),Wt=(0,t.raiser)(`router`,`matchPath`),Gt=(0,t.raiser)(`router`,`buildPath`),q=(0,t.raiser)(`router`,`isActiveRoute`),Kt=(0,t.raiser)(`router`,`setRootPath`);function J(e,n){if(e.startsWith(`@@`))throw(0,t.raiser)(`router`,n).plain`Route name "${e}" uses the reserved "${`@@`}" prefix. Routes with this prefix are internal and cannot be modified through the public API.`}function qt(e,t){for(let n of e)n&&typeof n==`object`&&typeof n.name==`string`&&(J(n.name,t),n.children&&qt(n.children,t))}function Jt(e){x(e,`removeRoute`)}function Yt(e){if(typeof e!=`string`)throw Kt.type`rootPath must be a string, got ${S(e)}`}function Y(e){return e.constructor.name===`AsyncFunction`||String(e).includes(`__awaiter`)}function Xt(e){let t=e;if(t.canActivate!==void 0&&typeof t.canActivate!=`function`)throw K.type`canActivate must be a function, got ${S(t.canActivate)}`;if(t.canDeactivate!==void 0&&typeof t.canDeactivate!=`function`)throw K.type`canDeactivate must be a function, got ${S(t.canDeactivate)}`}function Zt(e){let t=e,n=t.name;if(t.decodeParams!==void 0&&Y(t.decodeParams))throw K.type`decodeParams cannot be async for route "${String(n)}"`;if(t.encodeParams!==void 0&&Y(t.encodeParams))throw K.type`encodeParams cannot be async for route "${String(n)}"`;if(typeof t.forwardTo==`function`&&Y(t.forwardTo))throw K.type`forwardTo callback cannot be async for route "${String(n)}"`}function Qt(e){for(let t of e){if(typeof t!=`object`||!t||Array.isArray(t))throw K.type`Route must be an object, got ${S(t)}`;Pt(t,t.name)}}function $t(e){if(typeof e!=`string`||e===``)throw K.type`parent option must be a non-empty string, got ${S(e)}`;x(e,`addRoute`)}function en(e,t,n,r){if(!o(e))throw q.type`name must be a string, got ${typeof e}`;if(k(t,`isActiveRoute`),n!==void 0&&typeof n!=`boolean`)throw q.type`strictEquality must be a boolean, got ${typeof n}`;if(r!==void 0&&typeof r!=`boolean`)throw q.type`ignoreQueryParams must be a boolean, got ${typeof r}`}function X(e,n,r){if(!o(e))throw(0,t.raiser)(`router`,r).type`Invalid routeName: ${S(e)}. Expected string.`;if(!g(n))throw(0,t.raiser)(`router`,r).type`Invalid routeParams: ${S(n)}. Expected plain object.`}function tn(e,t){if(x(e,`updateRoute`),e===``)throw G.ref`Invalid name: empty string. Cannot update root node.`;if(t===null)throw G.type`updates must be an object, got null`;if(typeof t!=`object`||Array.isArray(t))throw G.type`updates must be an object, got ${S(t)}`}function nn(e,t){if(e.constructor.name===`AsyncFunction`||e.toString().includes(`__awaiter`))throw G.type`${t} cannot be an async function`}function Z(e,t){if(e!=null){if(typeof e!=`function`)throw G.type`${t} must be a function or null, got ${typeof e}`;nn(e,t)}}function rn(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 G.type`forwardTo must be a string, function, or null, got ${S(t)}`;typeof t==`function`&&nn(t,`forwardTo callback`)}an(n,`defaultParams`),an(r,`defaultSearch`),Z(i,`decodeParams`),Z(a,`encodeParams`),Z(o,`canActivate`),Z(s,`canDeactivate`)}function an(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw G.type`${t} must be an object or null, got ${S(e)}`}function on(e){if(!o(e)||e===``)throw Gt.type`route must be a non-empty string, got ${typeof e==`string`?`""`:typeof e}`}function sn(e){let t=new Set;return function(r,i){let a=(0,n.findMisChanneledKey)(i,e(r));if(a===void 0)return;let o=`${r} ${a}`;t.has(o)||(t.add(o),console.warn(`[router] Route "${r}" 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 cn(e){if(!o(e))throw Wt.type`path must be a string, got ${typeof e}`}function ln(e){if(!o(e))throw Ut.type`nodeName must be a string, got ${typeof e}`}function un(e,t,r,i,a){if(a){let e=t;for(let t of a.split(`.`))if(e=e.children.get(t),!e)throw K.ref`Parent route "${a}" does not exist`}let o=new Set,s=new Map;for(let r of e)(0,n.validateRoute)(r,`addRoute`,t,a??``,o,s);Ht(e,i,r,a)}function dn(e,t,n){let r=new Set(n.getUrlParams(e)),i=n.getUrlParams(t).filter(e=>!r.has(e));if(i.length>0)throw G.plain`forwardTo target "${t}" requires params [${i.join(`, `)}] that are not available in source route "${e}"`}function fn(e,t,n){let i={...n,[e]:t};(0,r.resolveForwardChain)(e,i)}function pn(e,t,n,r){if(!n.hasRoute(e))throw G.ref`route "${e}" does not exist`;if(t!=null&&typeof t==`string`){if(!n.hasRoute(t))throw G.plain`forwardTo target "${t}" does not exist`;dn(e,t,n),fn(e,t,r)}}const Q=(0,t.raiser)(`router`,`makeState`);function mn(e,t,n){if(!o(e))throw Q.type`Invalid name: ${S(e)}. Expected string.`;if(t!==void 0&&!g(t))throw Q.type`Invalid params: ${S(t)}. Expected plain object.`;if(n!==void 0&&!o(n))throw Q.type`Invalid path: ${S(n)}. Expected string.`}function hn(){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 gn(){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.`))}}const _n=(0,t.raiser)(`validation-plugin`),vn=(0,t.raiser)(`router`,`addRoute`),$=(0,t.raiser)(`router`,`areStatesEqual`);function yn(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 bn(e,t){let n=[];for(let r of e.getTree().children.keys())n.push(t.get(r));return n}function xn(e,t,n){let r=sn(t=>e.getDeclaredQueryNames(t));return{routes:{validateBuildPathArgs(e,t){on(e),r(e,t)},validateMatchPathArgs:cn,validateIsActiveRouteArgs(e,t,n,i){en(e,t,n,i),r(e,t)},validateShouldUpdateNodeArgs:ln,validateStateBuilderArgs:X,validateRouteName(e,t){x(e,t)},validateSetRootPathArgs:Yt},options:{validateOptions:ot,validateResolvedDefaultRoute(e){kt(e,t)}},dependencies:{validateDependencyName:ve,validateSetDependencyArgs(e,t,n){ye(e)},validateDependenciesObject(t,n){be(t,n),xe(t,e.getDependencyKeys(),e.getResolvedLimits().maxDependencies,n)},validateDependencyExists(e,t){Se(t,e)},validateDependencyCount(t,n,r){Ce(t,n,r,e.logger)},validateCloneArgs:we,warnOverwrite(t,n){Te(t,n,e.logger)},warnBatchOverwrite(t,n){Ee(t,n,e.logger)},warnRemoveNonExistent(t){De(t,e.logger)}},plugins:{validatePluginLimit(e,t){lt(e,1,t?.maxPlugins)},validateNoDuplicatePlugins:ut,validatePluginKeys:ft,validateCountThresholds(t){dt(t,e.getOptions().limits?.maxPlugins??i.maxPlugins,e.logger)},warnBatchDuplicates(){pt(e.logger)},warnPluginMethodType(t){mt(t,e.logger)}},lifecycle:{validateHandlerLimit(t,n){Fe(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers)},validateCountThresholds(t,n){Ie(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers,e.logger)},warnOverwrite(t,n,r){Le(t,n,r,e.logger)},warnAsyncGuardSync(t,n){Re(t,n,e.logger)}},navigation:{validateNavigateToDefaultArgs(t){We(t),n.check(e.logger)},validateNavigateToStateArgs:Ge,validateNavigationOptions:O,validateParamsShape:k,validateSearch:j,validateStartArgs:Je},state:{validateMakeStateArgs:mn,reportDroppedQueryKey:hn(),reportUndeclaredParamKey:gn(),validateAreStatesEqualArgs(e,t,n){if(!b(e))throw $.type`Invalid state1: ${S(e)}. Expected State object.`;if(!b(t))throw $.type`Invalid state2: ${S(t)}. Expected State object.`;if(n!==void 0&&!s(n))throw $.type`Invalid ignoreQueryParams: ${S(n)}. Expected boolean.`}},eventBus:{validateListenerArgs(e,t){Me(e,t)},validateCountThresholds(t,n,r){let a=e.getOptions().limits?.maxListeners??i.maxListeners;Ne(t,n,r,e.logger,a)}}}}function Sn(){return t=>{let r=(0,n.getInternals)(t),i=(0,e.getPluginApi)(t);if(t.isActive())throw _n.code(`VALIDATION_PLUGIN_AFTER_START`)`must be registered before router.start()`;if(r.validator!==null)throw _n.code(`VALIDATION_PLUGIN_ALREADY_INSTALLED`)`is already installed on this router — a clone re-runs plugin factories, so it needs no usePlugin of its own`;let a=new de;a.watch(i.getAdoptedOrigins());let o=yn(i),s=xn(i,o,a),c=()=>{r.validator===s&&(r.validator=null)};r.validator=s;try{let n=bn(i,(0,e.getRoutesApi)(t)),a=i.getForwardMap(),s=i.getResolvedLimits(),c=i.getOptions();bt(n),xt(a,o),Ct(n),wt(a,o),Tt(r.dependenciesGetStore().dependencies,s),Et(c,i.getDependencyKeys().length,s.maxDependencies),r.validator.options.validateOptions(c,`constructor (retrospective)`),typeof c.defaultRoute==`string`&&Ot(c.defaultRoute,o)}catch(e){throw c(),e}let l=i.addInterceptor(`start`,(e,t)=>{try{At(i.getExternalGuardNames(),o,i.logger)}catch{}return e(t)}),u=i.addCheck(`buildPath:params`,e=>{A(e,`buildPath`)}),d=i.addCheck(`buildPathResolved:params`,e=>{A(e,`buildPathResolved`)}),ee=i.addCheck(`canNavigateTo:entry`,(e,t,n)=>{x(e,`canNavigateTo`),k(t,`canNavigateTo`),j(n,`canNavigateTo`)}),te=i.addCheck(`canNavigateTo:params`,e=>{A(e,`canNavigateTo`)}),f=i.addCheck(`navigate:entry`,(e,t,n,r)=>{Ue(e),k(t,`navigate`),j(n,`navigate`),O(r,`navigate`)}),p=i.addCheck(`navigate:params`,e=>{A(e,`navigate`)}),m=e=>{for(let t of e)Xt(t),Zt(t),t.children!==void 0&&m(t.children)},h=(e,t,n)=>{if(m(e),n!==void 0&&($t(n),!o.hasRoute(n)))throw vn.ref`Parent route "${n}" does not exist`;qt(e,t),Qt(e),un(e,i.getTree(),o,i.getForwardMap(),n)},ne=i.addCheck(`addRoute:batch`,(e,t)=>{h(e,`addRoute`,t)}),g=i.addCheck(`replaceRoutes:batch`,e=>{h(e,`replaceRoutes`,void 0)}),_=i.addCheck(`removeRoute:entry`,e=>{Jt(e),J(e,`removeRoute`)}),re=i.addCheck(`updateRoute:entry`,(e,t)=>{let n=t;tn(e,t),J(e,`updateRoute`),rn({forwardTo:n.forwardTo,defaultParams:n.defaultParams,defaultSearch:n.defaultSearch,decodeParams:n.decodeParams,encodeParams:n.encodeParams,canActivate:n.canActivate,canDeactivate:n.canDeactivate}),pn(e,n.forwardTo,o,i.getForwardMap())}),ie=i.addCheck(`hasRoute:entry`,e=>{x(e,`hasRoute`)}),ae=i.addCheck(`getRoute:entry`,e=>{x(e,`getRoute`)}),v=i.addCheck(`forwardState:entry`,(e,t,n)=>{X(e,t,`forwardState`),j(n,`forwardState`)}),y=i.addCheck(`buildNavigationState:state`,(e,t,n)=>{j(n,`buildNavigationState`),X(e,t,`buildNavigationState`)}),oe=i.addCheck(`addActivateGuard:entry`,(e,t)=>{x(e,`addActivateGuard`),Pe(t,`addActivateGuard`)}),se=i.addCheck(`addDeactivateGuard:entry`,(e,t)=>{x(e,`addDeactivateGuard`),Pe(t,`addDeactivateGuard`)}),b=i.addCheck(`removeActivateGuard:entry`,e=>{x(e,`removeActivateGuard`)}),S=i.addCheck(`removeDeactivateGuard:entry`,e=>{x(e,`removeDeactivateGuard`)}),C=i.subscribeDiagnostic(`PLUGIN_AFTER_START`,e=>{ht(e,i.logger)});return{teardown(){u(),d(),ee(),te(),f(),p(),ne(),g(),_(),re(),ie(),ae(),v(),y(),oe(),se(),b(),S(),C(),l(),c()}}}}exports.validationPlugin=Sn;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@real-router/core/api"),t=require("@real-router/core/utils"),n=require("@real-router/core/validation"),r=require("@real-router/core");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 ee(e){if(Array.isArray(e))return!0;let t=l(e);return t===null||t===Object.prototype}function te(e,t){let n=Array.isArray(e)?e:u(e);for(let e of n)t.push(e)}function f(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}var p=class{container;constructor(e){this.container=e}};function m(e,t,n,r){return n.has(e)?!1:r.has(e)?!0:ee(e)?(n.add(e),t.push(new p(e)),te(e,t),!0):!1}function h(e){let t=[e],n=new WeakSet,r=new WeakSet;for(;t.length>0;){let e=t.pop();if(e instanceof p){n.delete(e.container),r.add(e.container);continue}if(e!=null){if(typeof e==`object`){if(!m(e,t,n,r))return!1;continue}if(!f(e))return!1}}return!0}function ne(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}function g(e){try{return _(e)}catch{return!1}}function _(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(!ne(r)){let e=typeof r;if(e===`function`||e===`symbol`)return!1;n=!0;break}}return!n||h(e)}const re=[`replace`,`reload`,`force`,`forceDeactivate`,`redirected`,`revalidate`];function ie(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;for(let e of re){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 ae=/\S/,v=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function y(e,n){return(0,t.raiser)(`router`,e).type`${n}`}function oe(e){return typeof e==`string`?e===``?!0:e.length>1e4?!1:e.startsWith(`@@`)?!0:v.test(e):!1}function se(e){return oe(e.name)&&typeof e.path==`string`&&g(e.params)}function b(e){return typeof e!=`object`||!e?!1:se(e)}function x(e,t){if(typeof e!=`string`)throw y(t,`Route name must be a string, got ${typeof e}`);if(e!==``){if(!ae.test(e))throw y(t,`Route name cannot contain only whitespace`);if(e.length>1e4)throw y(t,`Route name exceeds maximum length of 10000 characters. This is a technical safety limit.`);if(!e.startsWith(`@@`)&&!v.test(e))throw y(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 S(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 C=Object.entries,ce=[`defaultParams`,`defaultSearch`],le=e=>new Map(C(e)),ue=(e,t)=>{let n=C(e);return n.length!==t.size||n.some(([e,n])=>!t.has(e)||!Object.is(t.get(e),n))};var de=class{#e=new Map;#t=new Set;watch(e){for(let t of ce){let n=e[t],r=n?.deref();n!==void 0&&r!==void 0&&this.#e.set(t,{ref:n,before:le(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&&ue(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 fe=(0,t.raiser)(`cloneRouter`),pe=(0,t.raiser)(`router`,`getDependency`),me=(0,t.raiser)(`router`,`setDependency`),w=Object.keys,he=Object.getOwnPropertyDescriptor,ge=Object.getPrototypeOf,_e=Object;function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=ge(e);return t===null||t.constructor===_e}function ve(e,n){if(typeof e!=`string`)throw(0,t.raiser)(`router`,n).type`dependency name must be a string, got ${typeof e}`}function ye(e){if(typeof e!=`string`)throw me.type`dependency name must be a string, got ${typeof e}`}function be(e,n){if(!T(e))throw(0,t.raiser)(`router`,n).type`Invalid argument: expected plain object, received ${S(e)}`;for(let r of w(e))if(he(e,r)?.get)throw(0,t.raiser)(`router`,n).type`Getters not allowed: "${r}"`}function xe(e,n,r,i){if(r===0)return;let a=new Set(n),o=0;for(let t of w(e))a.has(t)||(o+=1);let s=n.length;if(s+o>r)throw(0,t.raiser)(`router`,i).range`Dependency limit exceeded (${r}). Current: ${s}, this batch adds ${o}.`}function Se(e,t){if(e===void 0)throw pe.ref`dependency "${t}" not found`}function Ce(e,n,r,i){if(n===0)return;let{warn:o,error:s}=a(n);if(e>=n)throw(0,t.raiser)(`router`,r).range`Dependency limit exceeded (${n}). Current: ${e}.`;e===s?i.error(`router.${r}`,`${e} dependencies registered! This indicates architectural problems. Hard limit at ${n}.`):e===o&&i.warn(`router.${r}`,`${e} dependencies registered. Consider if all are necessary.`)}function we(e){if(e!==void 0){if(!T(e))throw fe.type`Invalid dependencies: expected plain object or undefined, received ${typeof e}`;for(let t of w(e))if(he(e,t)?.get)throw fe.type`Getters not allowed in dependencies: "${t}"`}}function Te(e,t,n){n.warn(`router.${t}`,`Router dependency already exists and is being overwritten:`,e)}function Ee(e,t,n){n.warn(`router.${t}`,`Overwritten:`,e.join(`, `))}function De(e,t){t.warn(`router.removeDependency`,`Attempted to remove non-existent dependency: "${typeof e==`string`?e:String(e)}"`)}const Oe=(0,t.raiser)(`router`,`addEventListener`),ke=Object.values,Ae=new Set(ke(r.events));function je(e){if(!Ae.has(e))throw Oe.type`Invalid event name: ${String(e)}. Must be one of: $start, $stop, $$start, $$leaveApprove, $$cancel, $$success, $$error`}function Me(e,t){if(je(e),typeof t!=`function`)throw Oe.type`callback must be a function, got ${typeof t}`}function Ne(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 Pe(e,n){if(!s(e)&&typeof e!=`function`)throw(0,t.raiser)(`router`,n).type`Handler must be a boolean or factory function, got ${S(e)}`}function Fe(e,n,r=i.maxLifecycleHandlers){if(r!==0&&e>=r)throw(0,t.raiser)(`router`,n).range`Lifecycle handler limit exceeded (${r}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`}function Ie(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 Le(e,t,n,r){r.warn(`router.${n}`,`Overwriting existing ${t} handler for route "${e}"`)}function Re(e,t,n){n.warn(`router.${t}`,`Guard for "${e}" returned a Promise. Sync check cannot resolve async guards — returning false.`)}const E=(0,t.raiser)(`router`,`start`),D=(0,t.raiser)(`router`,`navigateToState`),ze=(0,t.raiser)(`router`,`navigateToDefault`),Be=(0,t.raiser)(`router`,`navigate`),Ve=Object.hasOwn,He=Object.getPrototypeOf;function Ue(e){if(typeof e!=`string`)throw Be.type`Invalid route name: expected string, got ${S(e)}`}function We(e){if(e!==void 0&&(typeof e!=`object`||!e))throw ze.type`Invalid options: ${S(e)}. Expected NavigationOptions object.`}function Ge(e){if(typeof e!=`object`||!e)throw D.type`Invalid state: ${S(e)}. Expected State object.`;let t=e;if(!o(t.name))throw D.type`Invalid state.name: ${S(t.name)}. Expected string.`;if(!g(t.params))throw D.type`Invalid state.params: ${S(t.params)}. Expected plain object.`;if(!o(t.path))throw D.type`Invalid state.path: ${S(t.path)}. Expected string.`}function O(e,n){if(!ie(e))throw(0,t.raiser)(`router`,n).type`Invalid options: ${S(e)}. Expected NavigationOptions object.`}const Ke=/[\u0000-\u001F\u007F]/;function qe(e,n){for(let r in e){if(!Ve(e,r))continue;let i=e[r],a=typeof i;if(a===`symbol`||a===`bigint`)throw(0,t.raiser)(`router`,n).type`param "${r}" cannot be a ${a} — it does not round-trip through the URL path. Use a string, number, or boolean.`;if(a===`string`&&Ke.test(i))throw(0,t.raiser)(`router`,n).type`param "${r}" must not contain control characters (NUL / C0 / DEL) — they corrupt the URL path.`}}function k(e,n){if(e===void 0)return;let r=e!==null&&He(e);if(Array.isArray(e)||r!==null&&r!==Object.prototype)throw(0,t.raiser)(`router`,n).type`params must be a plain object, got ${S(e)}`}function A(e,n){if(e!==void 0&&(qe(e,n),!g(e)))throw(0,t.raiser)(`router`,n).type`params must be a plain object, got ${S(e)}`}function j(e,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw(0,t.raiser)(`router`,n).type`search must be a plain object, got ${S(e)}`}function Je(e){if(e!==void 0&&typeof e!=`string`)throw E.type`path must be a string, got ${S(e)}.`;if(typeof e==`string`){if(Ke.test(e))throw E.type`path must not contain control characters (NUL / C0 / DEL).`;if(e!==``&&!e.startsWith(`/`))throw E.type`path must start with "/", got "${e}".`}}const Ye=Object.entries,Xe=Object.hasOwn,M=Object.keys,Ze=Object.getPrototypeOf,N={trailingSlash:[`strict`,`never`,`always`,`preserve`],queryParamsMode:[`default`,`strict`,`loose`],urlParamsEncoding:[`default`,`uri`,`uriComponent`,`none`]},Qe={arrayFormat:!0,booleanFormat:!0,nullFormat:!0,numberFormat:!0},$e=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})),et={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 tt(e,n,r){if(typeof n!=`number`||!Number.isInteger(n))throw(0,t.raiser)(`router`,r).type`limit "${e}" must be an integer, got ${String(n)}`;let i=et[e];if(n<i.min||n>i.max)throw(0,t.raiser)(`router`,r).range`limit "${e}" must be between ${i.min} and ${i.max}, got ${n}`}function nt(e){let t=Ze(e);return t===null||t===Object.prototype}function rt(e,n){if(!e||typeof e!=`object`||!nt(e))throw(0,t.raiser)(`router`,n).type`invalid limits: expected plain object, got ${typeof e}`;for(let[r,i]of Ye(e)){if(!Xe(et,r))throw(0,t.raiser)(`router`,n).type`unknown limit: "${r}"`;i!==void 0&&tt(r,i,n)}let{warnListeners:r,maxListeners:i}=e;if(typeof r==`number`&&typeof i==`number`&&i>0&&r>i)throw(0,t.raiser)(`router`,n).range`"limits.warnListeners" (${r}) must not exceed "limits.maxListeners" (${i}) — the warning channel would be unreachable`}function P(e,n,r,i){if(e!==void 0&&(typeof e!=`string`||!r.includes(e))){let a=r.map(e=>`"${e}"`).join(`, `),o=typeof e==`string`?e:`(${typeof e})`;throw(0,t.raiser)(`router`,i).type`Invalid "${n}": "${o}". Must be one of: ${a}`}}function it(e,n){if(e!==void 0&&typeof e!=`string`&&typeof e!=`function`)throw(0,t.raiser)(`router`,n).type`Invalid "defaultRoute": expected string or function, got ${typeof e}`}function F(e,n,r){if(e!==void 0&&typeof e!=`function`&&(!e||typeof e!=`object`||Array.isArray(e)||!nt(e)))throw(0,t.raiser)(`router`,r).type`Invalid "${n}": expected plain object or function, got ${typeof e}`}function at(e,n){if(e===void 0)return;if(!e||typeof e!=`object`||Array.isArray(e))throw(0,t.raiser)(`router`,n).type`Invalid "queryParams": expected plain object`;let r=e;for(let e of M(r))if(!c(e,Qe))throw(0,t.raiser)(`router`,n).type`Invalid "queryParams.${e}": unknown option`}function ot(e,n){if(!e||typeof e!=`object`||Array.isArray(e))throw(0,t.raiser)(`router`,n).type`Invalid options: expected plain object`;let r=e;for(let e of M(r))if(!$e.has(e))throw(0,t.raiser)(`router`,n).type`Unknown option: "${e}"`;if(it(r.defaultRoute,n),F(r.defaultParams,`defaultParams`,n),F(r.defaultSearch,`defaultSearch`,n),P(r.trailingSlash,`trailingSlash`,N.trailingSlash,n),P(r.queryParamsMode,`queryParamsMode`,N.queryParamsMode,n),P(r.urlParamsEncoding,`urlParamsEncoding`,N.urlParamsEncoding,n),r.allowNotFound!==void 0&&typeof r.allowNotFound!=`boolean`)throw(0,t.raiser)(`router`,n).type`Invalid "allowNotFound": expected boolean, got ${typeof r.allowNotFound}`;if(r.rewritePathOnMatch!==void 0&&typeof r.rewritePathOnMatch!=`boolean`)throw(0,t.raiser)(`router`,n).type`Invalid "rewritePathOnMatch": expected boolean, got ${typeof r.rewritePathOnMatch}`;if(r.caseSensitive!==void 0&&typeof r.caseSensitive!=`boolean`)throw(0,t.raiser)(`router`,n).type`Invalid "caseSensitive": expected boolean, got ${typeof r.caseSensitive}`;at(r.queryParams,n),r.limits!==void 0&&rt(r.limits,n)}const I=(0,t.raiser)(`router`,`usePlugin`),st=Object.hasOwn,L=`router.usePlugin`,ct={onStart:!0,onStop:!0,onTransitionStart:!0,onTransitionLeaveApprove:!0,onTransitionSuccess:!0,onTransitionError:!0,onTransitionCancel:!0};function lt(e,t,n=i.maxPlugins){if(n!==0&&e+t>n)throw I.range`Plugin limit exceeded (${n}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`}function ut(e,t){if(t.includes(e))throw I.plain`Plugin factory already registered. To re-register, first unsubscribe the existing plugin.`}function dt(e,t,n){if(t===0)return;let{warn:r,error:i}=a(t);e>=i?n.error(L,`${e} plugins registered! This is excessive. Hard limit at ${t}.`):e>=r&&n.warn(L,`${e} plugins registered. Consider if all are necessary.`)}function ft(e){for(let t in e)if(!(t===`teardown`||st(ct,t)))throw I.type`Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`}function pt(e){e.warn(L,`Duplicate factory in batch, will be registered once`)}function mt(e,t){t.warn(L,`Property '${e}' is not a function, skipping`)}function ht(e,t){e===`onStart`&&t.warn(L,`Router already started, onStart will not be called`)}const gt=(0,t.raiser)(`router`,`navigateToDefault`),R=(0,t.raiser)(`validation-plugin`),z=Object.entries,_t=Object.getOwnPropertyDescriptor,vt=Object.keys;function B(e,t,n=``){for(let r of e){let e=n?`${n}.${r.name}`:r.name;t(r,e),r.children&&B(r.children,t,e)}}function V(e,t){let n=[];return B(e,(e,r)=>{let i=t(e);i!==void 0&&n.push([r,i])}),n}function yt(e,t){try{return(0,r.resolveForwardChain)(e,t)}catch(e){let t=e.message.replace(/^\[router\] /u,``);throw R.plain({cause:e})`${t}`}}function H(e,t,n){let r=e;if(r.constructor.name===`AsyncFunction`||r.toString().includes(`__awaiter`))throw R.type`Route "${n}" ${t} cannot be async`}function bt(e){B(e,(e,t)=>{if(typeof e.name!=`string`||!e.name)throw R.type`validateExistingRoutes: route has invalid name: ${e.name}`;if(typeof e.path!=`string`)throw R.type`validateExistingRoutes: route "${t}" has non-string path (${typeof e.path})`})}function xt(e,t){for(let[n,r]of z(e)){if(!t.hasRoute(r))throw R.plain`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 R.plain`validateForwardToConsistency: forwardTo target "${r}" requires params [${i.join(`, `)}] not available in source route "${n}"`}for(let t of vt(e))yt(t,e)}function St(e,t){for(let[n,r]of e)if(typeof r!=`object`||!r||Array.isArray(r))throw R.type`validateRoutePropertiesStore: route "${n}" ${t} must be a plain object, got ${Array.isArray(r)?`array`:typeof r}`}function Ct(e){let t=V(e,e=>e.decodeParams),n=V(e,e=>e.encodeParams),r=V(e,e=>typeof e.forwardTo==`string`?void 0:e.forwardTo);for(let[e,n]of t){if(typeof n!=`function`)throw R.type`validateRoutePropertiesStore: route "${e}" decoder must be a function, got ${typeof n}`;H(n,`decoder`,e)}for(let[e,t]of n){if(typeof t!=`function`)throw R.type`validateRoutePropertiesStore: route "${e}" encoder must be a function, got ${typeof t}`;H(t,`encoder`,e)}St(V(e,e=>e.defaultParams),`defaultParams`),St(V(e,e=>e.defaultSearch),`defaultSearch`);for(let[e,t]of r){if(typeof t!=`function`)throw R.type`validateRoutePropertiesStore: route "${e}" forwardTo callback must be a function, got ${typeof t}`;H(t,`forwardTo callback`,e)}}function wt(e,t){for(let[n,r]of z(e))if(!t.hasRoute(r))throw R.plain`validateForwardToTargetsStore: forwardTo target "${r}" does not exist for route "${n}"`}function Tt(e,t){for(let t of vt(e))if(_t(e,t)?.get)throw R.type`validateDependenciesStructure: dependency "${t}" must not use a getter`;for(let[e,n]of z(t))if(!Number.isInteger(n))throw R.type`validateDependenciesStructure: deps.limits.${e} must be an integer, got ${String(n)}`}function Et(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 R.range`validateLimitsConsistency: dependency count (${t}) exceeds maxDependencies limit (${a})`}function Dt(e,t){return typeof e==`string`&&e!==``&&!t.hasRoute(e)}function Ot(e,t){if(Dt(e,t))throw R.plain`defaultRoute resolved to non-existent route: "${e}"`}function kt(e,t){if(Dt(e,t))throw gt.plain`defaultRoute callback resolved to non-existent route: "${e}"`}function At(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 U=(0,t.raiser)(`router`,`addRoute`),jt=Object.keys;function Mt(e,t){if(e!==void 0){if(typeof e!=`string`&&typeof e!=`function`)throw U.type`forwardTo must be a string or function for route "${t}", got ${S(e)}`;if(typeof e==`function`){let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw U.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}}}function Nt(e,t,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw U.type`${t} must be an object for route "${n}", got ${S(e)}`}function Pt(e,t){if(e.canActivate!==void 0&&typeof e.canActivate!=`function`)throw U.type`canActivate must be a function for route "${t}", got ${S(e.canActivate)}`;if(e.canDeactivate!==void 0&&typeof e.canDeactivate!=`function`)throw U.type`canDeactivate must be a function for route "${t}", got ${S(e.canDeactivate)}`;Nt(e.defaultParams,`defaultParams`,t),Nt(e.defaultSearch,`defaultSearch`,t);let{decodeParams:n,encodeParams:r}=e;if(typeof n==`function`&&n.constructor.name===`AsyncFunction`)throw U.type`decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`;if(typeof r==`function`&&r.constructor.name===`AsyncFunction`)throw U.type`encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`;if(Mt(e.forwardTo,t),e.children)for(let n of e.children)Pt(n,`${t}.${n.name}`)}function Ft(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 It(e){let t=new Set;for(let n of e)for(let e of Ft(n))t.add(e);return t}function W(e,n,r=``,i=[]){for(let t of e){let e=r?`${r}.${t.name}`:t.name,a=[...i,t.path];if(e===n)return a;if(t.children&&n.startsWith(`${e}.`))return W(t.children,n,e,a)}throw t.internalDefect.plain`collectPathsToRoute: route "${n}" not found`}function Lt(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 Lt(r.children,e))n.add(t)}return n}function Rt(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 Rt(r.children,e))n.set(t,i)}return n}function zt(e,t,n,r){return t?new Set(n.getUrlParams(e)):It(W(r,e))}const Bt=new Set;function Vt(e,t,n,r,i,a){let o=i.hasRoute(t),s=r.has(t);if(!o&&!s)throw U.ref`forwardTo target "${t}" does not exist for route "${e}"`;let c=new Set([...a,...It(W(n,e))]),l=[...zt(t,o,i,n)].filter(e=>!c.has(e));if(l.length>0)throw U.plain`forwardTo target "${t}" requires params [${l.join(`, `)}] that are not available in source route "${e}"`}function Ht(e,n,i,a){let o=Lt(e),s=a?new Set([...o].map(e=>`${a}.${e}`)):o,c=a?new Set(i.getUrlParams(a)):Bt,l=Rt(e),u={...n};for(let[e,n]of l)(0,t.putField)(u,e,n);for(let[t,n]of l)Vt(t,n,e,s,i,c);for(let e of jt(u))(0,r.resolveForwardChain)(e,u)}const G=(0,t.raiser)(`router`,`updateRoute`),K=(0,t.raiser)(`router`,`addRoute`),Ut=(0,t.raiser)(`router`,`shouldUpdateNode`),Wt=(0,t.raiser)(`router`,`matchPath`),Gt=(0,t.raiser)(`router`,`buildPath`),q=(0,t.raiser)(`router`,`isActiveRoute`),Kt=(0,t.raiser)(`router`,`setRootPath`);function J(e,n){if(e.startsWith(`@@`))throw(0,t.raiser)(`router`,n).plain`Route name "${e}" uses the reserved "${`@@`}" prefix. Routes with this prefix are internal and cannot be modified through the public API.`}function qt(e,t){for(let n of e)n&&typeof n==`object`&&typeof n.name==`string`&&(J(n.name,t),n.children&&qt(n.children,t))}function Jt(e){x(e,`removeRoute`)}function Yt(e){if(typeof e!=`string`)throw Kt.type`rootPath must be a string, got ${S(e)}`}function Y(e){return e.constructor.name===`AsyncFunction`||String(e).includes(`__awaiter`)}function Xt(e){let t=e;if(t.canActivate!==void 0&&typeof t.canActivate!=`function`)throw K.type`canActivate must be a function, got ${S(t.canActivate)}`;if(t.canDeactivate!==void 0&&typeof t.canDeactivate!=`function`)throw K.type`canDeactivate must be a function, got ${S(t.canDeactivate)}`}function Zt(e){let t=e,n=t.name;if(typeof t.decodeParams==`function`&&Y(t.decodeParams))throw K.type`decodeParams cannot be async for route "${String(n)}"`;if(typeof t.encodeParams==`function`&&Y(t.encodeParams))throw K.type`encodeParams cannot be async for route "${String(n)}"`;if(typeof t.forwardTo==`function`&&Y(t.forwardTo))throw K.type`forwardTo callback cannot be async for route "${String(n)}"`}function Qt(e){for(let t of e){if(typeof t!=`object`||!t||Array.isArray(t))throw K.type`Route must be an object, got ${S(t)}`;Pt(t,t.name)}}function $t(e){if(typeof e!=`string`||e===``)throw K.type`parent option must be a non-empty string, got ${S(e)}`;x(e,`addRoute`)}function en(e,t,n,r){if(!o(e))throw q.type`name must be a string, got ${typeof e}`;if(k(t,`isActiveRoute`),n!==void 0&&typeof n!=`boolean`)throw q.type`strictEquality must be a boolean, got ${typeof n}`;if(r!==void 0&&typeof r!=`boolean`)throw q.type`ignoreQueryParams must be a boolean, got ${typeof r}`}function X(e,n,r){if(!o(e))throw(0,t.raiser)(`router`,r).type`Invalid routeName: ${S(e)}. Expected string.`;if(!g(n))throw(0,t.raiser)(`router`,r).type`Invalid routeParams: ${S(n)}. Expected plain object.`}function tn(e,t){if(x(e,`updateRoute`),e===``)throw G.ref`Invalid name: empty string. Cannot update root node.`;if(t===null)throw G.type`updates must be an object, got null`;if(typeof t!=`object`||Array.isArray(t))throw G.type`updates must be an object, got ${S(t)}`}function nn(e,t){if(e.constructor.name===`AsyncFunction`||e.toString().includes(`__awaiter`))throw G.type`${t} cannot be an async function`}function Z(e,t){if(e!=null){if(typeof e!=`function`)throw G.type`${t} must be a function or null, got ${typeof e}`;nn(e,t)}}function rn(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 G.type`forwardTo must be a string, function, or null, got ${S(t)}`;typeof t==`function`&&nn(t,`forwardTo callback`)}an(n,`defaultParams`),an(r,`defaultSearch`),Z(i,`decodeParams`),Z(a,`encodeParams`),Z(o,`canActivate`),Z(s,`canDeactivate`)}function an(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw G.type`${t} must be an object or null, got ${S(e)}`}function on(e){if(!o(e)||e===``)throw Gt.type`route must be a non-empty string, got ${typeof e==`string`?`""`:typeof e}`}function sn(e){let t=new Set;return function(r,i){let a=(0,n.findMisChanneledKey)(i,e(r));if(a===void 0)return;let o=`${r} ${a}`;t.has(o)||(t.add(o),console.warn(`[router] Route "${r}" 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 cn(e){if(!o(e))throw Wt.type`path must be a string, got ${typeof e}`}function ln(e){if(!o(e))throw Ut.type`nodeName must be a string, got ${typeof e}`}function un(e,t,r,i,a){if(a){let e=t;for(let t of a.split(`.`))if(e=e.children.get(t),!e)throw K.ref`Parent route "${a}" does not exist`}let o=new Set,s=new Map;for(let r of e)(0,n.validateRoute)(r,`addRoute`,t,a??``,o,s);Ht(e,i,r,a)}function dn(e,t,n){let r=new Set(n.getUrlParams(e)),i=n.getUrlParams(t).filter(e=>!r.has(e));if(i.length>0)throw G.plain`forwardTo target "${t}" requires params [${i.join(`, `)}] that are not available in source route "${e}"`}function fn(e,t,n){let i={...n,[e]:t};(0,r.resolveForwardChain)(e,i)}function pn(e,t,n,r){if(!n.hasRoute(e))throw G.ref`route "${e}" does not exist`;if(t!=null&&typeof t==`string`){if(!n.hasRoute(t))throw G.plain`forwardTo target "${t}" does not exist`;dn(e,t,n),fn(e,t,r)}}const Q=(0,t.raiser)(`router`,`makeState`);function mn(e,t,n){if(!o(e))throw Q.type`Invalid name: ${S(e)}. Expected string.`;if(t!==void 0&&!g(t))throw Q.type`Invalid params: ${S(t)}. Expected plain object.`;if(n!==void 0&&!o(n))throw Q.type`Invalid path: ${S(n)}. Expected string.`}function hn(){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 gn(){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.`))}}const _n=(0,t.raiser)(`validation-plugin`),vn=(0,t.raiser)(`router`,`addRoute`),$=(0,t.raiser)(`router`,`areStatesEqual`);function yn(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 bn(e,t){let n=[];for(let r of e.getTree().children.keys())n.push(t.get(r));return n}function xn(e,t,n){let r=sn(t=>e.getDeclaredQueryNames(t));return{routes:{validateBuildPathArgs(e,t){on(e),r(e,t)},validateMatchPathArgs:cn,validateIsActiveRouteArgs(e,t,n,i){en(e,t,n,i),r(e,t)},validateShouldUpdateNodeArgs:ln,validateStateBuilderArgs:X,validateRouteName(e,t){x(e,t)},validateSetRootPathArgs:Yt},options:{validateOptions:ot,validateResolvedDefaultRoute(e){kt(e,t)}},dependencies:{validateDependencyName:ve,validateSetDependencyArgs(e,t,n){ye(e)},validateDependenciesObject(t,n){be(t,n),xe(t,e.getDependencyKeys(),e.getResolvedLimits().maxDependencies,n)},validateDependencyExists(e,t){Se(t,e)},validateDependencyCount(t,n,r){Ce(t,n,r,e.logger)},validateCloneArgs:we,warnOverwrite(t,n){Te(t,n,e.logger)},warnBatchOverwrite(t,n){Ee(t,n,e.logger)},warnRemoveNonExistent(t){De(t,e.logger)}},plugins:{validatePluginLimit(e,t){lt(e,1,t?.maxPlugins)},validateNoDuplicatePlugins:ut,validatePluginKeys:ft,validateCountThresholds(t){dt(t,e.getOptions().limits?.maxPlugins??i.maxPlugins,e.logger)},warnBatchDuplicates(){pt(e.logger)},warnPluginMethodType(t){mt(t,e.logger)}},lifecycle:{validateHandlerLimit(t,n){Fe(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers)},validateCountThresholds(t,n){Ie(t,n,e.getOptions().limits?.maxLifecycleHandlers??i.maxLifecycleHandlers,e.logger)},warnOverwrite(t,n,r){Le(t,n,r,e.logger)},warnAsyncGuardSync(t,n){Re(t,n,e.logger)}},navigation:{validateNavigateToDefaultArgs(t){We(t),n.check(e.logger)},validateNavigateToStateArgs:Ge,validateNavigationOptions:O,validateParamsShape:k,validateSearch:j,validateStartArgs:Je},state:{validateMakeStateArgs:mn,reportDroppedQueryKey:hn(),reportUndeclaredParamKey:gn(),validateAreStatesEqualArgs(e,t,n){if(!b(e))throw $.type`Invalid state1: ${S(e)}. Expected State object.`;if(!b(t))throw $.type`Invalid state2: ${S(t)}. Expected State object.`;if(n!==void 0&&!s(n))throw $.type`Invalid ignoreQueryParams: ${S(n)}. Expected boolean.`}},eventBus:{validateListenerArgs(e,t){Me(e,t)},validateCountThresholds(t,n,r){let a=e.getOptions().limits?.maxListeners??i.maxListeners;Ne(t,n,r,e.logger,a)}}}}function Sn(){return t=>{let r=(0,n.getInternals)(t),i=(0,e.getPluginApi)(t);if(t.isActive())throw _n.code(`VALIDATION_PLUGIN_AFTER_START`)`must be registered before router.start()`;if(r.validator!==null)throw _n.code(`VALIDATION_PLUGIN_ALREADY_INSTALLED`)`is already installed on this router — a clone re-runs plugin factories, so it needs no usePlugin of its own`;let a=new de;a.watch(i.getAdoptedOrigins());let o=yn(i),s=xn(i,o,a),c=()=>{r.validator===s&&(r.validator=null)};r.validator=s;try{let n=bn(i,(0,e.getRoutesApi)(t)),a=i.getForwardMap(),s=i.getResolvedLimits(),c=i.getOptions();bt(n),xt(a,o),Ct(n),wt(a,o),Tt(r.dependenciesGetStore().dependencies,s),Et(c,i.getDependencyKeys().length,s.maxDependencies),r.validator.options.validateOptions(c,`constructor (retrospective)`),typeof c.defaultRoute==`string`&&Ot(c.defaultRoute,o)}catch(e){throw c(),e}let l=i.addInterceptor(`start`,(e,t)=>{try{At(i.getExternalGuardNames(),o,i.logger)}catch{}return e(t)}),u=i.addCheck(`buildPath:params`,e=>{A(e,`buildPath`)}),d=i.addCheck(`buildPathResolved:params`,e=>{A(e,`buildPathResolved`)}),ee=i.addCheck(`canNavigateTo:entry`,(e,t,n)=>{x(e,`canNavigateTo`),k(t,`canNavigateTo`),j(n,`canNavigateTo`)}),te=i.addCheck(`canNavigateTo:params`,e=>{A(e,`canNavigateTo`)}),f=i.addCheck(`navigate:entry`,(e,t,n,r)=>{Ue(e),k(t,`navigate`),j(n,`navigate`),O(r,`navigate`)}),p=i.addCheck(`navigate:params`,e=>{A(e,`navigate`)}),m=e=>{for(let t of e)Xt(t),Zt(t),t.children!==void 0&&m(t.children)},h=(e,t,n)=>{if(m(e),n!==void 0&&($t(n),!o.hasRoute(n)))throw vn.ref`Parent route "${n}" does not exist`;qt(e,t),Qt(e),un(e,i.getTree(),o,i.getForwardMap(),n)},ne=i.addCheck(`addRoute:batch`,(e,t)=>{h(e,`addRoute`,t)}),g=i.addCheck(`replaceRoutes:batch`,e=>{h(e,`replaceRoutes`,void 0)}),_=i.addCheck(`removeRoute:entry`,e=>{Jt(e),J(e,`removeRoute`)}),re=i.addCheck(`updateRoute:entry`,(e,t)=>{let n=t;tn(e,t),J(e,`updateRoute`),rn({forwardTo:n.forwardTo,defaultParams:n.defaultParams,defaultSearch:n.defaultSearch,decodeParams:n.decodeParams,encodeParams:n.encodeParams,canActivate:n.canActivate,canDeactivate:n.canDeactivate}),pn(e,n.forwardTo,o,i.getForwardMap())}),ie=i.addCheck(`hasRoute:entry`,e=>{x(e,`hasRoute`)}),ae=i.addCheck(`getRoute:entry`,e=>{x(e,`getRoute`)}),v=i.addCheck(`forwardState:entry`,(e,t,n)=>{X(e,t,`forwardState`),j(n,`forwardState`)}),y=i.addCheck(`buildNavigationState:state`,(e,t,n)=>{j(n,`buildNavigationState`),X(e,t,`buildNavigationState`)}),oe=i.addCheck(`addActivateGuard:entry`,(e,t)=>{x(e,`addActivateGuard`),Pe(t,`addActivateGuard`)}),se=i.addCheck(`addDeactivateGuard:entry`,(e,t)=>{x(e,`addDeactivateGuard`),Pe(t,`addDeactivateGuard`)}),b=i.addCheck(`removeActivateGuard:entry`,e=>{x(e,`removeActivateGuard`)}),S=i.addCheck(`removeDeactivateGuard:entry`,e=>{x(e,`removeDeactivateGuard`)}),C=i.subscribeDiagnostic(`PLUGIN_AFTER_START`,e=>{ht(e,i.logger)});return{teardown(){u(),d(),ee(),te(),f(),p(),ne(),g(),_(),re(),ie(),ae(),v(),y(),oe(),se(),b(),S(),C(),l(),c()}}}}exports.validationPlugin=Sn;
2
2
  //# sourceMappingURL=index.js.map