@real-router/core 0.78.0 → 0.79.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.
- package/README.md +1 -1
- package/dist/cjs/Router-BRuC-daj.js +2 -0
- package/dist/cjs/Router-BRuC-daj.js.map +1 -0
- package/dist/cjs/api.d.ts +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/buildParamMeta-DniluAIV.js +2 -0
- package/dist/cjs/buildParamMeta-DniluAIV.js.map +1 -0
- package/dist/cjs/{cloneRouter-a6LJt-zh.js → cloneRouter-3AOUeQ8M.js} +2 -2
- package/dist/cjs/{cloneRouter-a6LJt-zh.js.map → cloneRouter-3AOUeQ8M.js.map} +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{types-xg2zHVF6.d.ts → types-DaXCTxi1.d.ts} +1 -34
- package/dist/cjs/types-DaXCTxi1.d.ts.map +1 -0
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.d.ts +1 -1
- package/dist/cjs/validation.d.ts.map +1 -1
- package/dist/cjs/validation.js +1 -1
- package/dist/cjs/validation.js.map +1 -1
- package/dist/esm/Router-DikzugaD.mjs +2 -0
- package/dist/esm/Router-DikzugaD.mjs.map +1 -0
- package/dist/esm/api.d.mts +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/buildParamMeta-bOLhLF9h.mjs +2 -0
- package/dist/esm/buildParamMeta-bOLhLF9h.mjs.map +1 -0
- package/dist/esm/{cloneRouter-CqS4kTs8.mjs → cloneRouter-CAh5vA3l.mjs} +2 -2
- package/dist/esm/{cloneRouter-CqS4kTs8.mjs.map → cloneRouter-CAh5vA3l.mjs.map} +1 -1
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{types-xg2zHVF6.d.mts → types-DaXCTxi1.d.mts} +1 -34
- package/dist/esm/types-DaXCTxi1.d.mts.map +1 -0
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.d.mts +1 -1
- package/dist/esm/validation.d.mts.map +1 -1
- package/dist/esm/validation.mjs +1 -1
- package/dist/esm/validation.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-D6NzRxBA.js +0 -2
- package/dist/cjs/Router-D6NzRxBA.js.map +0 -1
- package/dist/cjs/buildParamMeta-CkG6cUIl.js +0 -2
- package/dist/cjs/buildParamMeta-CkG6cUIl.js.map +0 -1
- package/dist/cjs/types-xg2zHVF6.d.ts.map +0 -1
- package/dist/esm/Router-De0Gr9Ll.mjs +0 -2
- package/dist/esm/Router-De0Gr9Ll.mjs.map +0 -1
- package/dist/esm/buildParamMeta-Bl0uORu6.mjs +0 -2
- package/dist/esm/buildParamMeta-Bl0uORu6.mjs.map +0 -1
- package/dist/esm/types-xg2zHVF6.d.mts.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=new WeakMap;function t(t){let n=e.get(t);if(!n)throw TypeError(`[real-router] Invalid router instance — not found in internals registry`);return n}function n(t,n){e.set(t,n)}function r(e,t,n){let r=t;for(let t of e){let e=r;r=(...n)=>t(e,...n)}return r(...n)}function i(e,t,n){return((...i)=>{let a=n.get(e);return!a||a.length===0?t(...i):r(a,t,i)})}function a(e,t,n){return(i,a)=>{let o=n.get(e);return!o||o.length===0?t(i,a):r(o,t,[i,a])}}const o=`[^>]*`;function s(e){let t=!1;for(let n of e)if(n===`<`)t=!0;else if(n===`>`){if(!t)return!1;t=!1}return!t}const c=/[<>]/u,l=e=>e===58||e===42;function u(e){let t=[],n=0,r=!1;for(let i=0;i<e.length;i+=1){let a=e.charCodeAt(i);a===60?r=!0:a===62?r=!1:a===47&&!r&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function d(e){let t=e.length;if(t===0)return{kind:`static`,text:``};if(!l(e.charCodeAt(0))){for(let n=0;n<t;n+=1){let r=e.charCodeAt(n);if(r===60)return{error:`constraint-in-static`};if(l(r)&&n+1<t&&e.charCodeAt(n+1)!==60)return{error:`fused-marker`}}return e.charCodeAt(t-1)===63?{error:`name-less`}:{kind:`static`,text:e}}let n=e.charCodeAt(0)===42,r=1;for(;r<t;){let t=e.charCodeAt(r);if(t===60||t===63)break;r+=1}let i=e.slice(1,r);if(i.length===0)return{error:`name-less`};if(l(i.charCodeAt(i.length-1)))return{error:`trailing-marker`};let a,o=!1;if(r<t)if(e.charCodeAt(r)===60){let n=e.indexOf(`>`,r+1);if(n===-1)return{error:`unbalanced-constraint`};if(n===r+1)return{error:`empty-constraint`};a=e.slice(r,n+1);let i=n+1;if(i<t)if(e.charCodeAt(i)===63)o=!0;else return{error:`fused-constraint-suffix`}}else o=!0;return n?o?{error:`optional-splat`}:{kind:`splat`,name:i}:a===void 0?{kind:`param`,name:i,optional:o}:{kind:`param`,name:i,constraint:a,optional:o}}function f(e){for(let t of u(e)){let e=d(t);if(`error`in e)return e.error}}function p(e){let t=u(e);for(let e=2;e<t.length;e+=1)if(t[e].startsWith(`*`)&&m(t[e-1])&&m(t[e-2]))return!0;return!1}function m(e){return e.startsWith(`:`)&&e.endsWith(`?`)}function h(e){return`(${e.slice(1,-1)})`}function g(e,t){try{return RegExp(`^${h(e)}$`)}catch{throw Error(`[buildParamMeta] Invalid constraint '${e}' on parameter '${t}': the body between '<' and '>' must be a valid regular expression (e.g. '<[0-9]+>', '<[a-z]+>').`)}}const _=new RegExp(String.raw`([:*]${`[^/?<]+`}(?:<${o}>)?)\?(?=[/?]|$)`,`g`),v=RegExp(`<${o}>`,`g`),y=/\?(.+)$/;function b(e){return e.replaceAll(v,e=>`<${`x`.repeat(e.length-2)}>`).replaceAll(_,`$1\0`)}const x=Object.freeze([]),S=Object.freeze({}),C=new Map,w=Object.freeze({urlParams:x,queryParams:x,spatParams:x,paramTypeMap:S,constraintPatterns:C,pathPattern:``});function T(e,t,n,r,i){for(let a of u(e)){if(a.length===0)continue;let e=d(a);`error`in e||e.kind===`static`||(t.push(e.name),r[e.name]=`url`,e.kind===`splat`?n.push(e.name):e.constraint!==void 0&&i.set(e.name,{pattern:g(e.constraint,e.name),constraint:e.constraint}))}}function E(e){let t=[],n=[],r=[],i={},a=new Map,o=y.exec(b(e));if(o!==null){let t=e.slice(o.index+1).split(`&`);for(let e of t){let t=e.trim();t.length>0&&(n.push(t),i[t]=`query`)}e=e.slice(0,o.index)}return T(e,t,r,i,a),D(t,n,r,i,a,e)}function D(e,t,n,r,i,a){return{urlParams:e.length===0?x:e,queryParams:t.length===0?x:t,spatParams:n.length===0?x:n,paramTypeMap:e.length===0&&t.length===0?S:r,constraintPatterns:i.size===0?C:i,pathPattern:a}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return a}});
|
|
2
|
-
//# sourceMappingURL=buildParamMeta-CkG6cUIl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildParamMeta-CkG6cUIl.js","names":[],"sources":["../../src/internals.ts","../../src/engine/path-matcher/constraint-grammar.ts","../../src/engine/path-matcher/parseSegment.ts","../../src/engine/path-matcher/buildParamMeta.ts"],"sourcesContent":["import type { RouteTree } from \"./engine\";\nimport type { DependenciesStore } from \"./namespaces\";\nimport type { RoutesStore } from \"./namespaces/RoutesNamespace\";\nimport type { Router as RouterClass } from \"./Router\";\nimport type {\n DefaultDependencies,\n EventName,\n LoggerConfig,\n NavigationOptions,\n Options,\n Params,\n Plugin,\n Router as RouterInterface,\n RouterLogger,\n RouteTreeState,\n SimpleState,\n State,\n TreeChangedEvent,\n Unsubscribe,\n EventMethodMap,\n PluginFactory,\n} from \"./types\";\nimport type { RouterValidator } from \"./types/RouterValidator\";\nimport type { SerializedRouterState } from \"./utils\";\n\nexport interface RouterInternals<\n D extends DefaultDependencies = DefaultDependencies,\n> {\n readonly makeState: <P extends Params = Params>(\n name: string,\n params?: P,\n path?: string,\n meta?: Record<string, Record<string, \"url\" | \"query\">>,\n ) => State<P>;\n\n readonly forwardState: <P extends Params = Params>(\n routeName: string,\n routeParams: P,\n ) => SimpleState<P>;\n\n readonly buildStateResolved: (\n resolvedName: string,\n resolvedParams: Params,\n ) => RouteTreeState | undefined;\n\n readonly matchPath: <P extends Params = Params>(\n path: string,\n options?: Options,\n ) => State<P> | undefined;\n\n readonly getOptions: () => Options;\n\n readonly addEventListener: <E extends EventName>(\n eventName: E,\n cb: Plugin[EventMethodMap[E]],\n ) => Unsubscribe;\n\n /**\n * Route-tree mutation channel — internal access for the `getRoutesApi`\n * wrapper. A dedicated bridge is required because the public\n * `addEventListener<E extends EventName>` structurally rejects\n * `\"TREE_CHANGED\"` (it is not in the public `EventName` union), is strict on\n * duplicates, and exposes neither `emit` nor `listenerCount`.\n */\n readonly treeChanged: {\n readonly emit: (event: TreeChangedEvent) => void;\n readonly subscribe: (\n handler: (event: TreeChangedEvent) => void,\n ) => Unsubscribe;\n readonly listenerCount: () => number;\n /**\n * True while a `TREE_CHANGED` emit is on the stack — `getRoutesApi` reads it\n * to reject reentrant route-CRUD from a `subscribeChanges` handler (#1032).\n */\n readonly isEmitting: () => boolean;\n };\n\n readonly buildPath: (route: string, params?: Params) => string;\n\n readonly emitTransitionError: (error: Error) => void;\n\n /**\n * Emits `TRANSITION_SUCCESS` directly (no FSM transition) — used by\n * `getRoutesApi().replace()` to notify `router.subscribe` listeners when a\n * structural replace revalidates the active state (#950). Mirrors the success\n * emission `completeTransition` / `navigateToNotFound` perform.\n */\n readonly emitTransitionSuccess: (\n toState: State,\n fromState: State | undefined,\n opts?: NavigationOptions,\n ) => void;\n\n /**\n * Commits the not-found (`UNKNOWN_ROUTE`) state for `path` and emits\n * `TRANSITION_SUCCESS` — the `NavigationNamespace.navigateToNotFound`\n * primitive. `replace()` uses it when a structural replace drops the active\n * route, so subscribers are notified instead of the state silently clearing\n * (#950).\n */\n readonly navigateToNotFound: (path: string) => State;\n\n readonly start: (path: string) => Promise<State>;\n\n /**\n * Plugin-only navigation entry point — delegates to\n * `NavigationNamespace.navigateToState` (`getPluginApi(router).navigateToState`).\n * Hidden from `Router`/`Navigator` to keep the userland surface minimal;\n * see `core-types/src/api.ts` for usage docs.\n */\n readonly navigateToState: (\n state: State,\n options?: NavigationOptions,\n ) => Promise<State>;\n\n /* eslint-disable @typescript-eslint/no-explicit-any -- heterogeneous map: stores different InterceptorFn<M> types under different keys */\n readonly interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n readonly setRootPath: (rootPath: string) => void;\n readonly getRootPath: () => string;\n\n readonly getTree: () => RouteTree;\n\n readonly isDisposed: () => boolean;\n\n validator: RouterValidator | null;\n\n // Per-router logger instance (built from `options.logger` in the Router\n // constructor). The facade reads it as `getInternals(this).logger`; namespaces\n // receive it via their deps at wiring; plugins reach it through\n // `getPluginApi(router).logger`. Replaces the former process-global singleton\n // from the standalone `@real-router/logger` package (now folded into\n // `foundation/logger`), whose `configure()` leaked across routers (#724).\n readonly logger: RouterLogger;\n\n // Dependencies (issue #172)\n readonly dependenciesGetStore: () => DependenciesStore<D>;\n\n // Clone support (issue #173, consolidated #964). One accessor for the\n // source-side snapshot a clone carries over besides the route store, so a new\n // clone-relevant subsystem is wired in a single place instead of being spread\n // across separate methods.\n readonly getCloneState: () => {\n options: Options;\n dependencies: Record<string, unknown>;\n pluginFactories: PluginFactory<D>[];\n // Resolved logger config of the base router, so a clone can build its OWN\n // logger inheriting the base's level/callback. Frozen `options` do NOT carry\n // `logger` (stripped in the constructor), so `options` above can't convey it;\n // cloneRouter merges a per-request override (traceId) over this snapshot.\n loggerConfig: LoggerConfig;\n };\n\n // Consolidated route data store (issue #174 Phase 2)\n readonly routeGetStore: () => RoutesStore<D>;\n\n // Cross-namespace state (issue #174)\n readonly getStateName: () => string | undefined;\n readonly isTransitioning: () => boolean;\n readonly clearState: () => void;\n readonly setState: (state: State) => void;\n readonly routerExtensions: { keys: string[] }[];\n readonly contextClaimRecords: Set<string>;\n\n /**\n * One-shot hydration scratchpad populated by `hydrateRouter` immediately\n * before delegating to `router.start(parsed.path)` and cleared in the\n * matching `finally`. SSR loader plugins read this slot directly via\n * `getInternals(router).hydrationState` to short-circuit their own loader\n * call when the server-resolved namespace value is already present in the\n * parsed state (#596). `null` outside of an active `hydrateRouter`\n * invocation.\n */\n hydrationState: SerializedRouterState | null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- existential type: stores RouterInternals for all Dependencies types\nconst internals = new WeakMap<object, RouterInternals<any>>();\n\nexport function getInternals<D extends DefaultDependencies>(\n router: RouterInterface<D>,\n): RouterInternals<D> {\n const ctx = internals.get(router);\n\n if (!ctx) {\n throw new TypeError(\n \"[real-router] Invalid router instance — not found in internals registry\",\n );\n }\n\n return ctx as RouterInternals<D>;\n}\n\nexport function registerInternals<D extends DefaultDependencies>(\n router: RouterClass<D>,\n ctx: RouterInternals<D>,\n): void {\n internals.set(router, ctx);\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument -- internal chain execution: type safety enforced at public API boundary (PluginApi.addInterceptor) */\nfunction executeInterceptorChain<T>(\n interceptors: ((next: (...args: any[]) => any, ...args: any[]) => any)[],\n original: (...args: any[]) => T,\n args: any[],\n): T {\n let chain = original as (...args: any[]) => any;\n\n for (const interceptor of interceptors) {\n const prev = chain;\n\n chain = (...chainArgs: any[]) => interceptor(prev, ...chainArgs);\n }\n\n return chain(...args) as T;\n}\n\n/**\n * Variadic interceptor wrapper — wraps a function of any arity, returning the\n * same callable type `T`. Use {@link createBinaryInterceptable} instead when the\n * wrapped method takes exactly two args and the caller needs the precise\n * `(a, b) => r` signature preserved (the variadic form widens args to `any[]`).\n */\nexport function createInterceptable<T extends (...args: any[]) => any>(\n name: string,\n original: T,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): T {\n return ((...args: any[]) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(...args);\n }\n\n return executeInterceptorChain(chain, original, args);\n }) as T;\n}\n\n/**\n * Two-argument interceptor wrapper — preserves the exact `(a: A, b: B) => R`\n * signature, which the variadic {@link createInterceptable} cannot express\n * (it widens args to `any[]`). Used for the binary interceptable methods\n * `forwardState(routeName, routeParams)` and `buildPath(route, params)`.\n */\nexport function createBinaryInterceptable<A, B, R>(\n name: string,\n original: (a: A, b: B) => R,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): (a: A, b: B) => R {\n return (arg1: A, arg2: B) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(arg1, arg2);\n }\n\n return executeInterceptorChain(chain, original, [arg1, arg2]);\n };\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument */\n","/**\n * Single source of truth for the constraint-delimiter `<...>` grammar (#804).\n *\n * Before this module the `<...>` grammar was re-spelled independently in 6\n * places across `path-matcher` + `route-tree`, with a live `+`/`*` desync\n * between the match side (`<[^>]+>`) and the strip/build side (`<[^>]*>`) — the\n * exact \"two desynced regexes\" class #738 unified for the param-*name* axis.\n * This module is the constraint-axis counterpart of `PARAM_NAME_PATTERN`:\n *\n * - `CONSTRAINT_BODY_PATTERN` — the one atom every constraint-parsing regex\n * (match / strip / build) derives from, so they can never disagree again.\n * - `isConstraintBalanced` — the one balance predicate the route-tree gate and\n * the `registerTree` backstop consume, so no layer re-rolls the scan.\n *\n * @module constraint-grammar\n */\n\n/**\n * Constraint body between `<` and `>`: any run of characters except the\n * closing `>`. Canonical quantifier is `*` (empties allowed at the *grammar*\n * level; the semantically-useless empty `<>` is rejected at the route-tree gate\n * and the `registerTree` backstop, not smuggled through — see #804 §3.3). Every\n * regex that parses `<...>` derives from this constant via interpolation, so the\n * match / strip / build phases share one definition — the same discipline\n * `PARAM_NAME_PATTERN` established for the param-name axis (#738).\n */\nexport const CONSTRAINT_BODY_PATTERN = \"[^>]*\";\n\n/**\n * Reports whether a path's `<...>` constraint delimiters are balanced.\n *\n * Single linear scan: a `<` opens a constraint and the first following `>`\n * closes it; a `<` inside the body is allowed (`<[a<b]>`). A `>` seen outside a\n * constraint, or a `<` left unclosed at the end, is a stray/unbalanced\n * delimiter.\n *\n * Implemented as a scan rather than a `replaceAll(new RegExp(...), \"\")` strip so\n * the intent — delimiter *balance*, not HTML *sanitization* — is unambiguous to\n * both readers and static analysis (the regex strip is the classic\n * incomplete-tag-sanitizer pattern CodeQL flags, which this is not).\n *\n * Authoritative in the producing layer (#804): `route-tree`'s `validateRoutePath`\n * gate and `path-matcher`'s own `registerTree` backstop both consume this — the\n * opt-in/gate validators never reimplement the scan (same axis as #1047).\n */\nexport function isConstraintBalanced(path: string): boolean {\n let insideConstraint = false;\n\n for (const char of path) {\n if (char === \"<\") {\n insideConstraint = true;\n } else if (char === \">\") {\n if (!insideConstraint) {\n return false; // stray `>` with no open `<`\n }\n\n insideConstraint = false;\n }\n }\n\n return !insideConstraint; // a still-open `<` is an unclosed constraint\n}\n\n/**\n * A query-param NAME may not contain `<`/`>` (#1242 §5.1) — such a char is a\n * constraint delimiter leaked into the query, e.g. a reverse-order modifier typo\n * `/a/:b?<\\d+>` parses the `?` as the query start, making `<\\d+>` the query name.\n * Single-sourced so the route-tree gate and the `registerTree` backstop share one\n * definition of \"invalid query-name char\".\n */\nexport const INVALID_QUERY_NAME_RGX = /[<>]/u;\n","/**\n * Canonical route-segment tokenizer.\n *\n * The single owner of \"where does a name / marker / constraint end\" for ONE\n * path segment (post-`/`-split). It replaces the five name-boundary compositions\n * of `PARAM_NAME_PATTERN` currently spread across `buildParamMeta` (L1),\n * `registration` (L2 build + L3 trie), and `route-tree`'s validation gate (L4),\n * so those layers can never disagree on a boundary (the gate↔backstop drift\n * class — #858 / #1050 / #1150 / #1311 / #1149 / #1324).\n *\n * A single left-to-right `charCodeAt` scan produces either a token tuple or a\n * typed error. Grammar (RFC §4):\n * 1. Leading `:`/`*` → param/splat; otherwise `static` (a marker glued *after* a\n * static prefix ⇒ `fused-marker`; a `<...>` in a marker-less segment ⇒\n * `constraint-in-static`; a trailing `?` on a marker-less segment ⇒ `name-less`\n * — the optional modifier has no param name, #1241 / `/faq?`).\n * 2. name = any char except `<`/`?` (no `/` remains inside a segment); a name\n * ending in a bare `:`/`*` ⇒ `trailing-marker` (#1324). A *mid* marker stays\n * a name char — `:a:b` → name `a:b`, preserved.\n * 3. empty name ⇒ `name-less` (#858).\n * 4. constraint = `<...>` after the name; unbalanced/`<>` ⇒ `unbalanced`/`empty`\n * (#804); text after `>` other than a trailing `?` ⇒ `fused-constraint-suffix`\n * (#1150).\n * 5. a trailing `?` ⇒ optional; on a splat ⇒ `optional-splat` (#1149).\n *\n * @module parseSegment\n */\n\n/* eslint-disable unicorn/prefer-code-point, sonarjs/cognitive-complexity -- charCodeAt code-unit scan + a single inlined branchy pass are this RFC's char-scan perf basis (§9); the same deliberate choices as registration/trie.ts hasNonAsciiSegment (#1285) and SegmentMatcher's inlined #traverseFrom (:550). Markers compared are ASCII (`:` `*` `<` `?`, < 0x80). */\n\n/** A successfully tokenized segment. */\nexport type SegmentTokens =\n | { readonly kind: \"static\"; readonly text: string }\n | {\n readonly kind: \"param\";\n readonly name: string;\n readonly constraint?: string;\n readonly optional: boolean;\n }\n | { readonly kind: \"splat\"; readonly name: string };\n\n/** Grammar-shape rejections, each mirroring an existing registration guard. */\nexport type SegmentErrorCode =\n | \"name-less\" // #858 — a marker with no name\n | \"trailing-marker\" // #1324 — a param name ending in a bare `:`/`*`\n | \"fused-marker\" // #1050 — a marker glued after a static prefix\n | \"fused-constraint-suffix\" // #1150 — static text after a constraint's `>`\n | \"constraint-in-static\" // #1311 — a `<...>` in a marker-less segment\n | \"optional-splat\" // #1149 — `*name?`\n | \"unbalanced-constraint\" // #804 — `<` with no matching `>`\n | \"empty-constraint\"; // #804 — `<>` (compiles to a never-matching `^()$`)\n\nexport interface SegmentError {\n readonly error: SegmentErrorCode;\n}\n\nconst COLON = 58; // :\nconst STAR = 42; // *\nconst LT = 60; // <\nconst GT = 62; // >\nconst QUESTION = 63; // ?\nconst SLASH = 47; // /\n\nconst isMarker = (code: number): boolean => code === COLON || code === STAR;\n\n/**\n * Splits a path into its `/`-delimited segments — but NOT on a `/` inside a\n * `<...>` constraint, whose body may legally contain `/` (e.g. `:id<a/b>`, which\n * the current whole-path `buildParamMeta` scan tolerates). First-`>` semantics,\n * matching the constraint grammar (`<[^>]*>`). This is the **segmentation** half\n * of the path-grammar unification: `parseSegment` owns the per-segment grammar,\n * `splitPathSegments` owns where a segment begins and ends. Reused by every layer\n * that must go from a path string to per-segment tokens (L1 now; L3 in a later\n * phase), so segmentation itself can never drift.\n *\n * @param path - a route path (query already stripped by the caller)\n * @returns the segments in order, including empty leading/trailing/`//` segments\n * (the caller skips empties, matching the current behaviour)\n */\nexport function splitPathSegments(path: string): string[] {\n const segments: string[] = [];\n let start = 0;\n let inConstraint = false;\n\n for (let i = 0; i < path.length; i += 1) {\n const code = path.charCodeAt(i);\n\n if (code === LT) {\n inConstraint = true;\n } else if (code === GT) {\n inConstraint = false;\n } else if (code === SLASH && !inConstraint) {\n segments.push(path.slice(start, i));\n start = i + 1;\n }\n }\n\n segments.push(path.slice(start));\n\n return segments;\n}\n\n/**\n * Tokenizes a single path segment (already split on `/`).\n *\n * @param segment - one `/`-delimited segment of a route path\n * @returns the segment's tokens, or a typed grammar error\n */\nexport function parseSegment(segment: string): SegmentTokens | SegmentError {\n const length = segment.length;\n\n if (length === 0) {\n return { kind: \"static\", text: \"\" };\n }\n\n // ---- static segment (no leading marker) -------------------------------\n if (!isMarker(segment.charCodeAt(0))) {\n for (let i = 0; i < length; i += 1) {\n const code = segment.charCodeAt(i);\n\n // A `<...>` in a marker-less segment reshapes the route (#1311).\n if (code === LT) {\n return { error: \"constraint-in-static\" };\n }\n\n // A marker glued after a static prefix is extracted as a param by build/meta\n // but compiled as a static literal by the trie (#1050) — reject it as fused.\n // Two placements are NOT fused: a marker ENDING the segment (a static ending in\n // `:`/`*` — `/a:`, `/a*`, F2 — caught by `i + 1 < length` being false), and a\n // marker followed by `<` (the constraint-in-static case `a<b>`, caught by the\n // `<` branch above). Every OTHER following char is fused — including a `?`\n // (`a:?`): that shape never reaches the tokenizer through a real path (a `?`\n // after a bare marker is not a valid `:name?` optional, so the query mask strips\n // it before `/`-segmentation), so a direct call correctly reports fused-marker.\n if (\n isMarker(code) &&\n i + 1 < length &&\n segment.charCodeAt(i + 1) !== LT\n ) {\n return { error: \"fused-marker\" };\n }\n }\n\n // A trailing `?` is the optional modifier; on a marker-less segment (no param\n // name) it is an optional-with-no-name — name-less (#858/#1241, `/faq?`). The\n // backstop rejects it by the SAME rule: its `endsWith(\"?\")` optional fork routes\n // the segment to `extractParamName` → this tokenizer. Owning the `?` modifier\n // here (not just in the marker branches) is what lets the gate and backstop\n // agree on it — otherwise the gate reads `faq?` as a valid static (#1324 §4).\n if (segment.charCodeAt(length - 1) === QUESTION) {\n return { error: \"name-less\" };\n }\n\n return { kind: \"static\", text: segment };\n }\n\n const splat = segment.charCodeAt(0) === STAR;\n\n // ---- name: up to the first `<` or `?` (a segment holds no `/`) ---------\n let cursor = 1;\n\n while (cursor < length) {\n const code = segment.charCodeAt(cursor);\n\n if (code === LT || code === QUESTION) {\n break;\n }\n\n cursor += 1;\n }\n\n const name = segment.slice(1, cursor);\n\n if (name.length === 0) {\n return { error: \"name-less\" }; // #858\n }\n\n if (isMarker(name.charCodeAt(name.length - 1))) {\n return { error: \"trailing-marker\" }; // #1324\n }\n\n // ---- constraint + optional --------------------------------------------\n let constraint: string | undefined;\n let optional = false;\n\n if (cursor < length) {\n if (segment.charCodeAt(cursor) === LT) {\n const close = segment.indexOf(\">\", cursor + 1);\n\n if (close === -1) {\n return { error: \"unbalanced-constraint\" }; // #804\n }\n\n if (close === cursor + 1) {\n return { error: \"empty-constraint\" }; // #804 — `<>`\n }\n\n constraint = segment.slice(cursor, close + 1);\n\n const after = close + 1;\n\n if (after < length) {\n // Only a trailing `?` may follow a constraint (matches the current\n // `(\\?)?` capture); any other text is fused (#1150).\n if (segment.charCodeAt(after) === QUESTION) {\n optional = true;\n } else {\n return { error: \"fused-constraint-suffix\" };\n }\n }\n } else {\n // segment.charCodeAt(cursor) === QUESTION\n optional = true;\n }\n }\n\n if (splat) {\n if (optional) {\n return { error: \"optional-splat\" }; // #1149\n }\n\n return { kind: \"splat\", name };\n }\n\n return constraint === undefined\n ? { kind: \"param\", name, optional }\n : { kind: \"param\", name, constraint, optional };\n}\n\n/**\n * Returns the first per-segment grammar error in a path, or `undefined` if every\n * segment tokenizes cleanly.\n *\n * The **validation-facing** entry over the tokenizer: `route-tree`'s\n * `validateRoutePath` calls this instead of re-running its own split+parse loop,\n * so the gate and the matcher's own grammar cannot drift (#1324) and the loop\n * stays single-sourced here — the tokenizer primitives (`parseSegment`,\n * `splitPathSegments`) need not leak into the package's public surface. An empty\n * segment tokenizes as `static` (never an error), so leading/trailing/`//`\n * empties are skipped naturally.\n *\n * @param path - a route path (query already stripped by the caller)\n * @returns the first `SegmentErrorCode` (scanned left to right), or `undefined`\n */\nexport function findSegmentGrammarError(\n path: string,\n): SegmentErrorCode | undefined {\n for (const segment of splitPathSegments(path)) {\n const token = parseSegment(segment);\n\n if (\"error\" in token) {\n return token.error;\n }\n }\n\n return undefined;\n}\n\n/**\n * Whether a path places ≥2 optional params DIRECTLY before a splat\n * (`/:a?/:b?/*rest`, `/:a<c>?/:b<c>?/*rest`, #1287). A single trie slot carries\n * only one optional→splat fork, so the outer optional's mark overwrites the\n * inner's — the omit-outer/take-inner form silently reshapes into the splat.\n *\n * A whole-path (cross-segment) property that `parseSegment` cannot decide per\n * segment — so, like `isConstraintBalanced`, it is shared verbatim between the\n * matcher's `registerTree` backstop and `route-tree`'s validation gate, and the\n * two cannot drift. Runs on the RAW path: `splitPathSegments` is constraint-aware,\n * so a `<[^/]+>` body does not break the segment split.\n */\nexport function hasMultipleOptionalsBeforeSplat(path: string): boolean {\n const segments = splitPathSegments(path);\n\n for (let i = 2; i < segments.length; i += 1) {\n if (\n segments[i].startsWith(\"*\") &&\n isOptionalParamSegment(segments[i - 1]) &&\n isOptionalParamSegment(segments[i - 2])\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction isOptionalParamSegment(segment: string): boolean {\n return segment.startsWith(\":\") && segment.endsWith(\"?\");\n}\n","/**\n * Route Parameter Metadata Extraction.\n *\n * Extracts parameter metadata from route path patterns without requiring\n * a full path-parser instance. Replaces parser.urlParams/queryParams/spatParams.\n *\n * @module buildParamMeta\n */\n\nimport { CONSTRAINT_BODY_PATTERN } from \"./constraint-grammar\";\nimport { parseSegment, splitPathSegments } from \"./parseSegment\";\n\nimport type { ConstraintPattern, ParamMeta } from \"./types\";\n\n/**\n * Extracts the regex pattern from a constraint string.\n *\n * @param constraint - Constraint string (e.g., \"<\\\\d+>\")\n * @returns Regex capture group pattern (e.g., \"(\\\\d+)\")\n */\nfunction extractConstraintPattern(constraint: string): string {\n // Strip the \"<\"/\">\" delimiters. parseSegment guarantees the `<body>` shape\n // (balanced, non-empty body — #804), so a plain slice is exact — and avoids\n // the regex-strip idiom the incomplete-multi-character-sanitization SAST\n // class flags (semgrep/CodeQL).\n return `(${constraint.slice(1, -1)})`;\n}\n\n/**\n * Compiles a `<...>` constraint body to its anchored `^(…)$` matcher, rejecting a\n * body that is not a valid regular expression (`<*x>`, `<(>`, `<[>`) with a clear\n * error. Without this, an invalid body would surface as a raw V8 `SyntaxError`\n * (\"Invalid regular expression … Nothing to repeat\") deep inside tree-building\n * (`computeCaches`) OR the validation gate (both call `buildParamMeta`) — this is\n * the single constraint-compilation site, so one guard covers every consumer.\n */\nfunction compileConstraintPattern(\n constraint: string,\n paramName: string,\n): RegExp {\n try {\n return new RegExp(`^${extractConstraintPattern(constraint)}$`);\n } catch {\n throw new Error(\n `[buildParamMeta] Invalid constraint '${constraint}' on parameter '${paramName}': ` +\n `the body between '<' and '>' must be a valid regular expression (e.g. '<[0-9]+>', '<[a-z]+>').`,\n );\n }\n}\n\n/**\n * Canonical param-name character class: any char except `/`, `?`, `<`.\n *\n * **Single source of truth** for \"what characters a parameter name may contain\"\n * (#738), now consumed by the whole-path query-mask (`OPTIONAL_PARAM_MARKER_RGX`\n * below). The route-tree gate reads the per-segment grammar through `parseSegment`\n * (`findSegmentGrammarError`), not this char class. The\n * per-segment name grammar itself lives in `parseSegment` (the tokenizer this\n * module now consumes for URL-param extraction), so `match()` / `buildPath()`\n * cannot disagree on a name.\n */\nexport const PARAM_NAME_PATTERN = \"[^/?<]+\";\n\n// The optional-param marker `?` ends at a segment boundary (`/`), the start of a\n// query string (`?`, e.g. `/:id??tab`), or end of input. Including `?` in the\n// lookahead is what stops the optional marker being mistaken for the query\n// separator when a query follows an optional param directly.\nconst OPTIONAL_PARAM_MARKER_RGX = new RegExp(\n String.raw`([:*]${PARAM_NAME_PATTERN}(?:<${CONSTRAINT_BODY_PATTERN}>)?)\\?(?=[/?]|$)`,\n \"g\",\n);\n\n// Matches a `<...>` constraint body; used to neutralize `?` inside constraints\n// before query detection. Delimiter grammar derives from the single\n// `CONSTRAINT_BODY_PATTERN` atom (#804) so match/strip/build cannot desync.\n\nconst CONSTRAINT_RGX = new RegExp(`<${CONSTRAINT_BODY_PATTERN}>`, \"g\");\n\n/**\n * Regex for matching query parameters in path patterns.\n *\n * Matches query string portion after \"?\" in path.\n *\n * @example\n * ```\n * \"/search?q&page\" → matches \"q&page\"\n * ```\n */\n// eslint-disable-next-line sonarjs/super-linear-regex -- bounded input from route definitions, not user input\nconst QUERY_PARAM_RGX = /\\?(.+)$/;\n\n/**\n * Length-preserving mask used only to locate the real query separator `?`.\n *\n * Two kinds of `?` must NOT be mistaken for the query separator:\n * - the optional-param marker (`:id?`),\n * - a `?` inside a `<...>` constraint (e.g. the lazy quantifier in `:id<\\d?>`).\n *\n * Both are neutralized in place (same length, so the match index maps back onto\n * the original `path`). Without this, `/a/:id<\\d?>` was split at the constraint's\n * `?`, producing `queryParams:[\">\"]`, a truncated `pathPattern`, and a lost\n * constraint — crashing `start()` with `Missing required param` (#738).\n */\nfunction maskForQueryDetection(path: string): string {\n // Blank constraint interiors: \"<\\d?>\" → \"<xxx>\" (length preserved).\n const constraintsMasked = path.replaceAll(\n CONSTRAINT_RGX,\n (constraint) => `<${\"x\".repeat(constraint.length - 2)}>`,\n );\n\n // Replace the optional-param `?` with NUL (length preserved, never a `?`).\n return constraintsMasked.replaceAll(OPTIONAL_PARAM_MARKER_RGX, \"$1\u0000\");\n}\n\n/**\n * Builds parameter metadata from a route path pattern.\n *\n * Extracts URL parameters, query parameters, and splat parameters\n * from the path pattern string.\n *\n * @param path - Route path pattern (e.g., \"/users/:id/posts/:postId?q\")\n * @returns Parameter metadata object\n *\n * @example\n * ```typescript\n * buildParamMeta(\"/users/:id\")\n * // → {\n * // urlParams: [\"id\"],\n * // queryParams: [],\n * // spatParams: [],\n * // paramTypeMap: { id: \"url\" }\n * // }\n *\n * buildParamMeta(\"/search?q&page\")\n * // → {\n * // urlParams: [],\n * // queryParams: [\"q\", \"page\"],\n * // spatParams: [],\n * // paramTypeMap: { q: \"query\", page: \"query\" }\n * // }\n *\n * buildParamMeta(\"/files/*path\")\n * // → {\n * // urlParams: [\"path\"],\n * // queryParams: [],\n * // spatParams: [\"path\"],\n * // paramTypeMap: { path: \"url\" }\n * // }\n *\n * buildParamMeta(\"/users/:id/posts/:postId?q&page\")\n * // → {\n * // urlParams: [\"id\", \"postId\"],\n * // queryParams: [\"q\", \"page\"],\n * // spatParams: [],\n * // paramTypeMap: { id: \"url\", postId: \"url\", q: \"query\", page: \"query\" }\n * // }\n * ```\n */\n// Shared frozen sentinels for the common no-params case — avoid a fresh empty\n// array/object/Map per route (#1009). ParamMeta fields are Readonly*; match/build\n// only read them, and computeCaches' Object.freeze on the arrays/object is a\n// no-op on an already-frozen shared instance.\nconst EMPTY_PARAM_NAMES: readonly string[] = Object.freeze([]);\nconst EMPTY_PARAM_TYPE_MAP: Readonly<Record<string, \"url\" | \"query\">> =\n Object.freeze({});\nconst EMPTY_CONSTRAINTS: ReadonlyMap<string, ConstraintPattern> = new Map();\n\n// Whole-meta shared sentinel for the fully-static case: every collection is a\n// #1009 sentinel AND pathPattern degenerates to the input path itself (no query\n// to strip), so the 6-field wrapper carries zero per-route information. The\n// RETAINING caller (route-tree's computeCaches) swaps a matching fresh result\n// for this instance — buildParamMeta itself keeps returning fresh objects so\n// the validation gate can read the real pathPattern of arbitrary input paths.\n// `pathPattern` is \"\" here; the one stored-meta reader (`registerNode`) falls\n// back to `node.path` on identity match.\nexport const EMPTY_PARAM_META: ParamMeta = Object.freeze({\n urlParams: EMPTY_PARAM_NAMES,\n queryParams: EMPTY_PARAM_NAMES,\n spatParams: EMPTY_PARAM_NAMES,\n paramTypeMap: EMPTY_PARAM_TYPE_MAP,\n constraintPatterns: EMPTY_CONSTRAINTS,\n pathPattern: \"\",\n});\n\n/**\n * Extracts URL/splat params + constraints from a path's segments into the given\n * accumulators via the canonical `parseSegment` tokenizer (RFC Phase 2). Split\n * out of `buildParamMeta` so the builder stays under the cognitive-complexity\n * budget (like `shareEmptyCollections`). A malformed segment (token errors) or a\n * `static` segment contributes nothing — a malformed route is rejected downstream\n * before it compiles, so its meta is moot (this includes the #1324 trailing-marker\n * family the old whole-path scan swallowed into a param name: the enumerated §8\n * flip, affecting only that dead route's unused meta until the trie migrates).\n */\nfunction collectUrlParams(\n path: string,\n urlParams: string[],\n spatParams: string[],\n paramTypeMap: Record<string, \"url\" | \"query\">,\n constraintPatterns: Map<string, ConstraintPattern>,\n): void {\n for (const segment of splitPathSegments(path)) {\n if (segment.length === 0) {\n continue;\n }\n\n const token = parseSegment(segment);\n\n if (\"error\" in token || token.kind === \"static\") {\n continue;\n }\n\n urlParams.push(token.name);\n paramTypeMap[token.name] = \"url\";\n\n if (token.kind === \"splat\") {\n spatParams.push(token.name);\n } else if (token.constraint !== undefined) {\n constraintPatterns.set(token.name, {\n pattern: compileConstraintPattern(token.constraint, token.name),\n constraint: token.constraint,\n });\n }\n }\n}\n\nexport function buildParamMeta(path: string): ParamMeta {\n const urlParams: string[] = [];\n const queryParams: string[] = [];\n const spatParams: string[] = [];\n const paramTypeMap: Record<string, \"url\" | \"query\"> = {};\n const constraintPatterns = new Map<string, ConstraintPattern>();\n\n // Locate the real query separator on a length-preserving mask (so the index\n // maps back onto `path`) that hides the optional-param `?` marker and any `?`\n // inside a `<...>` constraint.\n const queryMatch = QUERY_PARAM_RGX.exec(maskForQueryDetection(path));\n\n if (queryMatch !== null) {\n const queryString = path.slice(queryMatch.index + 1);\n const params = queryString.split(\"&\");\n\n for (const param of params) {\n const paramName = param.trim();\n\n if (paramName.length > 0) {\n queryParams.push(paramName);\n paramTypeMap[paramName] = \"query\";\n }\n }\n\n path = path.slice(0, queryMatch.index);\n }\n\n collectUrlParams(\n path,\n urlParams,\n spatParams,\n paramTypeMap,\n constraintPatterns,\n );\n\n return shareEmptyCollections(\n urlParams,\n queryParams,\n spatParams,\n paramTypeMap,\n constraintPatterns,\n path,\n );\n}\n\n// #1009: swap each freshly-built empty collection for a shared frozen sentinel\n// — factored out of buildParamMeta so the hot builder stays under the cognitive-\n// complexity budget. match/build only read these (Readonly*), and computeCaches'\n// Object.freeze is a no-op on an already-frozen shared instance.\nfunction shareEmptyCollections(\n urlParams: string[],\n queryParams: string[],\n spatParams: string[],\n paramTypeMap: Record<string, \"url\" | \"query\">,\n constraintPatterns: Map<string, ConstraintPattern>,\n pathPattern: string,\n): ParamMeta {\n return {\n urlParams: urlParams.length === 0 ? EMPTY_PARAM_NAMES : urlParams,\n queryParams: queryParams.length === 0 ? EMPTY_PARAM_NAMES : queryParams,\n spatParams: spatParams.length === 0 ? EMPTY_PARAM_NAMES : spatParams,\n paramTypeMap:\n urlParams.length === 0 && queryParams.length === 0\n ? EMPTY_PARAM_TYPE_MAP\n : paramTypeMap,\n constraintPatterns:\n constraintPatterns.size === 0 ? EMPTY_CONSTRAINTS : constraintPatterns,\n pathPattern,\n };\n}\n"],"mappings":"AAqLA,MAAM,EAAY,IAAI,QAEtB,SAAgB,EACd,EACoB,CACpB,IAAM,EAAM,EAAU,IAAI,CAAM,EAEhC,GAAI,CAAC,EACH,MAAU,UACR,yEACF,EAGF,OAAO,CACT,CAEA,SAAgB,EACd,EACA,EACM,CACN,EAAU,IAAI,EAAQ,CAAG,CAC3B,CAGA,SAAS,EACP,EACA,EACA,EACG,CACH,IAAI,EAAQ,EAEZ,IAAK,IAAM,KAAe,EAAc,CACtC,IAAM,EAAO,EAEb,GAAS,GAAG,IAAqB,EAAY,EAAM,GAAG,CAAS,CACjE,CAEA,OAAO,EAAM,GAAG,CAAI,CACtB,CAQA,SAAgB,EACd,EACA,EACA,EAIG,CACH,QAAS,GAAG,IAAgB,CAC1B,IAAM,EAAQ,EAAa,IAAI,CAAI,EAMnC,MAJI,CAAC,GAAS,EAAM,SAAW,EACtB,EAAS,GAAG,CAAI,EAGlB,EAAwB,EAAO,EAAU,CAAI,CACtD,EACF,CAQA,SAAgB,EACd,EACA,EACA,EAImB,CACnB,OAAQ,EAAS,IAAY,CAC3B,IAAM,EAAQ,EAAa,IAAI,CAAI,EAMnC,MAJI,CAAC,GAAS,EAAM,SAAW,EACtB,EAAS,EAAM,CAAI,EAGrB,EAAwB,EAAO,EAAU,CAAC,EAAM,CAAI,CAAC,CAC9D,CACF,CCnPA,MAAa,EAA0B,QAmBvC,SAAgB,EAAqB,EAAuB,CAC1D,IAAI,EAAmB,GAEvB,IAAK,IAAM,KAAQ,EACjB,GAAI,IAAS,IACX,EAAmB,QACd,GAAI,IAAS,IAAK,CACvB,GAAI,CAAC,EACH,MAAO,GAGT,EAAmB,EACrB,CAGF,MAAO,CAAC,CACV,CASA,MAAa,EAAyB,QCPhC,EAAY,GAA0B,IAAS,IAAS,IAAS,GAgBvE,SAAgB,EAAkB,EAAwB,CACxD,IAAM,EAAqB,CAAC,EACxB,EAAQ,EACR,EAAe,GAEnB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,GAAK,EAAG,CACvC,IAAM,EAAO,EAAK,WAAW,CAAC,EAE1B,IAAS,GACX,EAAe,GACN,IAAS,GAClB,EAAe,GACN,IAAS,IAAS,CAAC,IAC5B,EAAS,KAAK,EAAK,MAAM,EAAO,CAAC,CAAC,EAClC,EAAQ,EAAI,EAEhB,CAIA,OAFA,EAAS,KAAK,EAAK,MAAM,CAAK,CAAC,EAExB,CACT,CAQA,SAAgB,EAAa,EAA+C,CAC1E,IAAM,EAAS,EAAQ,OAEvB,GAAI,IAAW,EACb,MAAO,CAAE,KAAM,SAAU,KAAM,EAAG,EAIpC,GAAI,CAAC,EAAS,EAAQ,WAAW,CAAC,CAAC,EAAG,CACpC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,GAAK,EAAG,CAClC,IAAM,EAAO,EAAQ,WAAW,CAAC,EAGjC,GAAI,IAAS,GACX,MAAO,CAAE,MAAO,sBAAuB,EAYzC,GACE,EAAS,CAAI,GACb,EAAI,EAAI,GACR,EAAQ,WAAW,EAAI,CAAC,IAAM,GAE9B,MAAO,CAAE,MAAO,cAAe,CAEnC,CAYA,OAJI,EAAQ,WAAW,EAAS,CAAC,IAAM,GAC9B,CAAE,MAAO,WAAY,EAGvB,CAAE,KAAM,SAAU,KAAM,CAAQ,CACzC,CAEA,IAAM,EAAQ,EAAQ,WAAW,CAAC,IAAM,GAGpC,EAAS,EAEb,KAAO,EAAS,GAAQ,CACtB,IAAM,EAAO,EAAQ,WAAW,CAAM,EAEtC,GAAI,IAAS,IAAM,IAAS,GAC1B,MAGF,GAAU,CACZ,CAEA,IAAM,EAAO,EAAQ,MAAM,EAAG,CAAM,EAEpC,GAAI,EAAK,SAAW,EAClB,MAAO,CAAE,MAAO,WAAY,EAG9B,GAAI,EAAS,EAAK,WAAW,EAAK,OAAS,CAAC,CAAC,EAC3C,MAAO,CAAE,MAAO,iBAAkB,EAIpC,IAAI,EACA,EAAW,GAEf,GAAI,EAAS,EACX,GAAI,EAAQ,WAAW,CAAM,IAAM,GAAI,CACrC,IAAM,EAAQ,EAAQ,QAAQ,IAAK,EAAS,CAAC,EAE7C,GAAI,IAAU,GACZ,MAAO,CAAE,MAAO,uBAAwB,EAG1C,GAAI,IAAU,EAAS,EACrB,MAAO,CAAE,MAAO,kBAAmB,EAGrC,EAAa,EAAQ,MAAM,EAAQ,EAAQ,CAAC,EAE5C,IAAM,EAAQ,EAAQ,EAEtB,GAAI,EAAQ,EAGV,GAAI,EAAQ,WAAW,CAAK,IAAM,GAChC,EAAW,QAEX,MAAO,CAAE,MAAO,yBAA0B,CAGhD,KAEE,GAAW,GAYf,OARI,EACE,EACK,CAAE,MAAO,gBAAiB,EAG5B,CAAE,KAAM,QAAS,MAAK,EAGxB,IAAe,IAAA,GAClB,CAAE,KAAM,QAAS,OAAM,UAAS,EAChC,CAAE,KAAM,QAAS,OAAM,aAAY,UAAS,CAClD,CAiBA,SAAgB,EACd,EAC8B,CAC9B,IAAK,IAAM,KAAW,EAAkB,CAAI,EAAG,CAC7C,IAAM,EAAQ,EAAa,CAAO,EAElC,GAAI,UAAW,EACb,OAAO,EAAM,KAEjB,CAGF,CAcA,SAAgB,EAAgC,EAAuB,CACrE,IAAM,EAAW,EAAkB,CAAI,EAEvC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAS,OAAQ,GAAK,EACxC,GACE,EAAS,EAAE,CAAC,WAAW,GAAG,GAC1B,EAAuB,EAAS,EAAI,EAAE,GACtC,EAAuB,EAAS,EAAI,EAAE,EAEtC,MAAO,GAIX,MAAO,EACT,CAEA,SAAS,EAAuB,EAA0B,CACxD,OAAO,EAAQ,WAAW,GAAG,GAAK,EAAQ,SAAS,GAAG,CACxD,CC5QA,SAAS,EAAyB,EAA4B,CAK5D,MAAO,IAAI,EAAW,MAAM,EAAG,EAAE,EAAE,EACrC,CAUA,SAAS,EACP,EACA,EACQ,CACR,GAAI,CACF,OAAW,OAAO,IAAI,EAAyB,CAAU,EAAE,EAAE,CAC/D,MAAQ,CACN,MAAU,MACR,wCAAwC,EAAW,kBAAkB,EAAU,kGAEjF,CACF,CACF,CAaA,MAMM,EAA4B,IAAI,OACpC,OAAO,GAAG,QAAQ,UAAmB,MAAM,EAAwB,kBACnE,GACF,EAMM,EAAqB,OAAO,IAAI,EAAwB,GAAI,GAAG,EAa/D,EAAkB,UAcxB,SAAS,EAAsB,EAAsB,CAQnD,OAN0B,EAAK,WAC7B,EACC,GAAe,IAAI,IAAI,OAAO,EAAW,OAAS,CAAC,EAAE,EAIjC,CAAC,CAAC,WAAW,EAA2B,MAAK,CACtE,CAkDA,MAAM,EAAuC,OAAO,OAAO,CAAC,CAAC,EACvD,EACJ,OAAO,OAAO,CAAC,CAAC,EACZ,EAA4D,IAAI,IAUzD,EAA8B,OAAO,OAAO,CACvD,UAAW,EACX,YAAa,EACb,WAAY,EACZ,aAAc,EACd,mBAAoB,EACpB,YAAa,EACf,CAAC,EAYD,SAAS,EACP,EACA,EACA,EACA,EACA,EACM,CACN,IAAK,IAAM,KAAW,EAAkB,CAAI,EAAG,CAC7C,GAAI,EAAQ,SAAW,EACrB,SAGF,IAAM,EAAQ,EAAa,CAAO,EAE9B,UAAW,GAAS,EAAM,OAAS,WAIvC,EAAU,KAAK,EAAM,IAAI,EACzB,EAAa,EAAM,MAAQ,MAEvB,EAAM,OAAS,QACjB,EAAW,KAAK,EAAM,IAAI,EACjB,EAAM,aAAe,IAAA,IAC9B,EAAmB,IAAI,EAAM,KAAM,CACjC,QAAS,EAAyB,EAAM,WAAY,EAAM,IAAI,EAC9D,WAAY,EAAM,UACpB,CAAC,EAEL,CACF,CAEA,SAAgB,EAAe,EAAyB,CACtD,IAAM,EAAsB,CAAC,EACvB,EAAwB,CAAC,EACzB,EAAuB,CAAC,EACxB,EAAgD,CAAC,EACjD,EAAqB,IAAI,IAKzB,EAAa,EAAgB,KAAK,EAAsB,CAAI,CAAC,EAEnE,GAAI,IAAe,KAAM,CAEvB,IAAM,EADc,EAAK,MAAM,EAAW,MAAQ,CACzB,CAAC,CAAC,MAAM,GAAG,EAEpC,IAAK,IAAM,KAAS,EAAQ,CAC1B,IAAM,EAAY,EAAM,KAAK,EAEzB,EAAU,OAAS,IACrB,EAAY,KAAK,CAAS,EAC1B,EAAa,GAAa,QAE9B,CAEA,EAAO,EAAK,MAAM,EAAG,EAAW,KAAK,CACvC,CAUA,OARA,EACE,EACA,EACA,EACA,EACA,CACF,EAEO,EACL,EACA,EACA,EACA,EACA,EACA,CACF,CACF,CAMA,SAAS,EACP,EACA,EACA,EACA,EACA,EACA,EACW,CACX,MAAO,CACL,UAAW,EAAU,SAAW,EAAI,EAAoB,EACxD,YAAa,EAAY,SAAW,EAAI,EAAoB,EAC5D,WAAY,EAAW,SAAW,EAAI,EAAoB,EAC1D,aACE,EAAU,SAAW,GAAK,EAAY,SAAW,EAC7C,EACA,EACN,mBACE,EAAmB,OAAS,EAAI,EAAoB,EACtD,aACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-xg2zHVF6.d.ts","names":[],"sources":["../../src/engine/path-matcher/types.ts","../../src/engine/builder/types.ts"],"mappings":";;AAeA;;;;;;;;AAaqB;UAbJ,iBAAA;EAmBS;;;;;EAAA,SAbf,OAAA,EAAS,MAAM;EAyDgB;;;;;EAAA,SAlD/B,UAAA;AAAA;;;;UAMM,SAAA;EAmDN;;AAAW;AAetB;;EAfW,SA7CA,SAAA;EA4DsB;AAAA;AAMjC;;;EANiC,SArDtB,WAAA;EAgEU;;;;;EAAA,SAzDV,UAAA;EA4DsB;;;;;EAAA,SArDtB,YAAA,EAAc,QAAA,CAAS,MAAA;EAkDb;;;;;;;;;;AAGmB;AAwCxC;;;;EA3CqB,SAjCV,kBAAA,EAAoB,WAAA,SAAoB,iBAAA;EAsIlC;;;;;EAAA,SA/HN,WAAA;AAAA;;;;;;;;;KAeC,qBAAA;AAAA,UAMK,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA,EAAU,WAAA,SAAoB,gBAAA;EAAA,SAC9B,mBAAA,WAA8B,gBAAA;EAAA,SAC9B,SAAA,EAAW,SAAA;EAAA,SACX,YAAA,EAAc,QAAA,CAAS,MAAA;AAAA;;;;UAwCjB,gBAAA;EAAA,SACN,eAAA;EAAA,SACA,aAAa;AAAA;AAAA,UAwDP,WAAA;EAAA,SACN,QAAA,WAAmB,gBAAA;EAAA,SACnB,MAAA,EAAQ,QAAA,CAAS,MAAA;EAAA,SACjB,IAAA,EAAM,QAAA,CAAS,MAAA,SAAe,MAAA;AAAA;AAAA,UAOxB,qBAAA;EACf,aAAA;EACA,mBAAA;EACA,iBAAA;EACA,iBAAA,GAAoB,qBAAA;EACpB,gBAAA,GAAmB,WAAA,aAAwB,MAAA;EAC3C,gBAAA,GAAmB,MAAA,EAAQ,MAAA;AAAA;AAAA,UAGZ,sBAAA;EAAA,SACN,aAAA;EAAA,SACA,mBAAA;EAAA,SACA,iBAAA;EAAA,SACA,iBAAA,EAAmB,qBAAA;EAAA,SACnB,gBAAA,GAAmB,WAAA,aAAwB,MAAA;EAAA,SAC3C,gBAAA,GAAmB,MAAA,EAAQ,MAAA;AAAA;;;;AAjNjB;AAMrB;UCjBiB,eAAA;EAAA,CACd,GAAA;EACD,IAAA;EACA,IAAA;EACA,QAAA,GAAW,eAAe;AAAA;;;;;;;;;;;UAiBX,SAAA;ED+CN;EAAA,SC3CA,IAAA;ED2CW;EAAA,SCxCX,IAAA;EDuDsB;EAAA,SCpDtB,QAAA;EDoDsB;EAAA,SCjDtB,QAAA,EAAU,WAAA,SAAoB,SAAA;EDuDxB;EAAA,SCpDN,SAAA,EAAW,SAAA;;WAKX,MAAA,EAAQ,SAAA;EDoDE;EAAA,SCjDV,mBAAA,WAA8B,SAAA;EDmDnB;EAAA,SChDX,QAAA;EDiDc;;;;;EAAA,SC1Cd,YAAA,EAAc,QAAA,CAAS,MAAA;AAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,s as l,t as u,u as d}from"./buildParamMeta-Bl0uORu6.mjs";const f=Object.freeze({ROUTER_NOT_STARTED:`NOT_STARTED`,NO_START_PATH_OR_STATE:`NO_START_PATH_OR_STATE`,ROUTER_ALREADY_STARTED:`ALREADY_STARTED`,ROUTE_NOT_FOUND:`ROUTE_NOT_FOUND`,SAME_STATES:`SAME_STATES`,CANNOT_DEACTIVATE:`CANNOT_DEACTIVATE`,CANNOT_ACTIVATE:`CANNOT_ACTIVATE`,TRANSITION_ERR:`TRANSITION_ERR`,TRANSITION_CANCELLED:`CANCELLED`,ROUTER_DISPOSED:`DISPOSED`,PLUGIN_CONFLICT:`PLUGIN_CONFLICT`,CONTEXT_NAMESPACE_ALREADY_CLAIMED:`CONTEXT_NAMESPACE_ALREADY_CLAIMED`,REENTRANT_NAVIGATION:`REENTRANT_NAVIGATION`,REENTRANT_TREE_MUTATION:`REENTRANT_TREE_MUTATION`}),p=`@@router/UNKNOWN_ROUTE`,m={UNKNOWN_ROUTE:p},h={ROUTER_START:`onStart`,ROUTER_STOP:`onStop`,TRANSITION_START:`onTransitionStart`,TRANSITION_LEAVE_APPROVE:`onTransitionLeaveApprove`,TRANSITION_CANCEL:`onTransitionCancel`,TRANSITION_SUCCESS:`onTransitionSuccess`,TRANSITION_ERROR:`onTransitionError`},g={ROUTER_START:`$start`,ROUTER_STOP:`$stop`,TRANSITION_START:`$$start`,TRANSITION_LEAVE_APPROVE:`$$leaveApprove`,TRANSITION_CANCEL:`$$cancel`,TRANSITION_SUCCESS:`$$success`,TRANSITION_ERROR:`$$error`},_={maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200},v=Object.freeze({}),ee=Object.freeze({deactivated:Object.freeze([]),activated:Object.freeze([]),intersection:``}),y=Object.freeze({phase:`activating`,reason:`success`,segments:ee}),te={maxListeners:0,warnListeners:0};var ne=class{#e=new Map;#t=new Set;#n=null;#r=te;#i;#a;constructor(e){e?.limits&&(this.#r=e.limits),this.#i=e?.onListenerError??null,this.#a=e?.onListenerWarn??null}static validateCallback(e,t){if(typeof e!=`function`)throw TypeError(`Expected callback to be a function for event ${t}`)}setLimits(e){this.#r=e}on(e,t){let n=this.#e.get(e),r=n?.size??0;if(n?.has(t))throw Error(`Duplicate listener for "${e}"`);let{maxListeners:i,warnListeners:a}=this.#r;if(i!==0&&r>=i)throw Error(`Listener limit (${i}) reached for "${e}"`);a!==0&&r===a&&this.#a!==null&&(this.#n??=new Set,this.#n.has(e)||(this.#a(e,a),this.#n.add(e)));let o=n;return o===void 0&&(o=new Set,this.#e.set(e,o)),o.add(t),()=>{this.off(e,t)}}off(e,t){let n=this.#e.get(e);n&&(n.delete(t),n.size===0&&(this.#e.delete(e),this.#n?.delete(e)))}emit(e,t,n,r,i){let a=this.#e.get(e);if(!a||a.size===0||this.#t.has(e))return;let o=arguments.length-1;this.#t.add(e);try{if(a.size===1){let[s]=a;this.#o(e,s,o,t,n,r,i)}else{let s=[...a];for(let a of s)this.#o(e,a,o,t,n,r,i)}}finally{this.#t.delete(e)}}clearAll(){this.#e.clear(),this.#n=null}listenerCount(e){return this.#e.get(e)?.size??0}isDispatching(e){return this.#t.has(e)}#o(e,t,n,r,i,a,o){try{let s=this.#s(t,n,r,i,a,o);s!=null&&typeof s.then==`function`&&Promise.resolve(s).catch(t=>{this.#i?.(e,t)})}catch(t){this.#i?.(e,t)}}#s(e,t,n,r,i,a){switch(t){case 0:return e();case 1:return e(n);case 2:return e(n,r);case 3:return e(n,r,i);default:return e(n,r,i,a)}}};const re=Object.freeze({log:0,warn:1,error:2}),b=Object.freeze({all:0,"warn-error":1,"error-only":2,none:3});var ie=class{#e={level:`all`,callbackIgnoresLevel:!1};#t=0;#n=!1;constructor(e){e&&this.configure(e)}configure(e){let t=e.level;if(t!==void 0){if(!Object.hasOwn(b,t))throw Error(`Invalid log level: "${t}". Valid levels are: ${Object.keys(b).join(`, `)}`);this.#e.level=t,this.#t=b[t]}Object.hasOwn(e,`callback`)&&(this.#e.callback=e.callback);let n=e.callbackIgnoresLevel;n!==void 0&&(this.#e.callbackIgnoresLevel=n)}getConfig(){return{level:this.#e.level,callback:this.#e.callback,callbackIgnoresLevel:this.#e.callbackIgnoresLevel}}log(e,t,...n){this.#r(`log`,e,t,n)}warn(e,t,...n){this.#r(`warn`,e,t,n)}error(e,t,...n){this.#r(`error`,e,t,n)}#r(e,t,n,r){if(this.#e.level===`none`&&!this.#e.callbackIgnoresLevel)return;let i=re[e]<this.#t;i||this.#i(e,t,n,r),this.#a(e,t,n,i,r)}#i(e,t,n,r){if(typeof console<`u`&&typeof console[e]==`function`){let i=t?`[${t}] ${n}`:n;console[e](i,...r)}}#a(e,t,n,r,i){if(!(!this.#e.callback||!this.#e.callbackIgnoresLevel&&r)&&!this.#n){this.#n=!0;try{let r=this.#e.callback(e,t,n,...i);r!=null&&typeof r.then==`function`&&Promise.resolve(r).catch(e=>{this.#o(`[Logger] Error in async callback:`,e)})}catch(e){this.#o(`[Logger] Error in callback:`,e)}finally{this.#n=!1}}}#o(e,t){typeof console<`u`&&typeof console.error==`function`&&console.error(e,t)}};function ae(e){if(!e||typeof e!=`object`||e.constructor!==Object)throw TypeError(`dependencies must be a plain object`);for(let t in e)if(Object.getOwnPropertyDescriptor(e,t)?.get)throw TypeError(`dependencies cannot contain getters: "${t}"`)}function x(e,t){for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`route must be a non-array object`);t?.routes.guardRouteCallbacks(n),t?.routes.guardNoAsyncCallbacks(n);let r=n.children;r&&x(r,t)}}const oe=new Set([`all`,`warn-error`,`error-only`,`none`]);function se(e){return typeof e==`string`&&oe.has(e)}function ce(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function le(e){if(typeof e!=`object`)throw TypeError(`Logger config must be an object`);let t=e;for(let e of Object.keys(t))if(e!==`level`&&e!==`callback`&&e!==`callbackIgnoresLevel`)throw TypeError(`Unknown logger config property: "${e}"`);if(`level`in t&&t.level!==void 0&&!se(t.level))throw TypeError(`Invalid logger level: ${ce(t.level)}. Expected: "all" | "warn-error" | "error-only" | "none"`);if(`callback`in t&&t.callback!==void 0&&typeof t.callback!=`function`)throw TypeError(`Logger callback must be a function, got ${typeof t.callback}`);if(`callbackIgnoresLevel`in t&&t.callbackIgnoresLevel!==void 0&&typeof t.callbackIgnoresLevel!=`boolean`)throw TypeError(`Logger callbackIgnoresLevel must be a boolean, got ${typeof t.callbackIgnoresLevel}`)}function ue(e){return Object.freeze(e)}function de(e={}){return{..._,...e}}function S(e){if(e===void 0)return e;let t;for(let n in e){if(!Object.hasOwn(e,n))continue;let r=e[n];r!==void 0&&(t??={},t[n]=r)}return t??v}function fe(e={}){let t=Object.create(null);for(let n in e)e[n]!==void 0&&(t[n]=e[n]);return{dependencies:t,limits:_}}function C(e,t){let n=e.path,r=n.startsWith(`~`),i=r?n.slice(1):n,a={name:e.name,path:i,absolute:r,children:[],parent:t};if(e.children)for(let t of e.children){let e=C(t,a);a.children.push(e)}return a}function pe(e,t,n){let r=C({name:e,path:t},null);for(let e of n){let t=C(e,r);r.children.push(t)}return r}const me=/[^\w!$'()*+,.:;|~-]/gu,he=/[^\w!$'()*+,.:;|~-]/u,ge=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,_e=e=>t=>{try{return e(t)}catch{return e(t.replaceAll(ge,`�`))}},ve=_e(e=>e.replaceAll(me,e=>encodeURIComponent(e))),ye={default:e=>he.test(e)?ve(e):e,uri:_e(encodeURI),uriComponent:_e(encodeURIComponent),none:e=>e},be={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e},xe=(e,t)=>{let n=ye[t],r=String(e).split(`/`),i=n(r[0]);for(let e=1;e<r.length;e++)i+=`/`+n(r[e]);return i},Se=Object.freeze(Object.create(null));function w(){return{staticChildren:Se,hasChildren:!1,paramChild:void 0,splatChild:void 0,route:void 0,routeIsStrong:!1,slashChildRoute:void 0}}function T(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e}function Ce(e,t){return e===``?t:t===``?e:e+t}function we(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Te(e){let t=0;for(;t<e.length;)if(e.codePointAt(t)===37){if(t+2>=e.length)return!1;let n=e.codePointAt(t+1)??0,r=e.codePointAt(t+2)??0;if(!we(n)||!we(r))return!1;t+=3}else t++;return!0}const Ee=Object.freeze([]),De=Object.freeze(new Set),Oe=Object.freeze(new Map),ke=Object.freeze([]),Ae=Object.freeze({}),je=Object.freeze({}),Me=RegExp(`<${l}>`,`g`);function Ne(e,t,n){let r=t.has(e.name);return{paramName:e.name,isOptional:e.kind===`param`?e.optional:!1,encoder:r?e=>xe(e,n):ye[n]}}function Pe(t,n,r){let i=new Set,a=new Set;for(let e of n){for(let t of e.paramMeta.urlParams)i.add(t);for(let t of e.paramMeta.spatParams)a.add(t)}if(i.size===0)return{buildStaticParts:[t],buildParamSlots:ke};let o=[],c=[],l=``,u=s(t);for(let[t,n]of u.entries()){t>0&&(l+=`/`);let i=e(n);if(`error`in i||i.kind===`static`){l+=n;continue}o.push(l),l=``,c.push(Ne(i,a,r))}return o.push(l),{buildStaticParts:o,buildParamSlots:c}}function Fe(e,t,n){throw Error(`[SegmentMatcher.registerTree] Parameter name conflict at the same path position: '${n}${e}' and '${n}${t}'. A parametric URL segment binds to a single name across every route that shares that position — the value cannot be captured under two names. Rename one so both routes agree (e.g. use '${n}${e}' in both).`)}function Ie(){throw Error(`[SegmentMatcher.registerTree] Empty parameter name: a parameter marker (':' or '*') or an optional '?' must be followed by a name (e.g. ':id', '*rest', ':id?'). A name-less marker or modifier would capture under an empty key at match but emit a literal at build — the two disagree, so it is rejected.`)}function Le(e){throw Error(`[SegmentMatcher.registerTree] Fused parameter marker in segment "${e}": a ':'/'*' marker must begin a segment (e.g. 'a/:b', not 'a:b'). build extracts it as a param while the trie treats the segment as a literal — the two disagree.`)}function Re(e){throw Error(`[SegmentMatcher.registerTree] Trailing parameter marker in segment "${e}": a param name cannot end in a bare ':' or '*' (e.g. ':y*' — the name is 'y' plus a stray marker). build/meta would capture the marker into the name while the gate rejects it as name-less — the two disagree, so it is rejected.`)}function ze(e){throw Error(`[SegmentMatcher.registerTree] Two optional params directly before a splat in "${e}": a single trie slot carries only one optional→splat fork, so the outer optional would overwrite the inner and the omit-outer/take-inner form would silently reshape into the splat. Split into separate routes, or drop the '?' on one.`)}function Be(e){throw Error(`[SegmentMatcher.registerTree] Non-ASCII static segment "${e}": match rejects non-ASCII input and compares static keys raw, so this route would never match. Percent-encode it (e.g. "/caf%C3%A9") or use a param.`)}function Ve(e){throw Error(`[SegmentMatcher.registerTree] Optional splat "${e}" is not supported: a splat cannot be optional — build emits multi-segment URLs the matcher rejects. Use a required splat "*name".`)}function He(e){throw Error(`[SegmentMatcher.registerTree] Optional param ":${e}?" before a splat must be constrained: an unconstrained optional before a splat is ambiguous (every multi-segment value has two readings). Add a constraint, e.g. ":${e}<[a-z]+>?", or model it as two routes.`)}function Ue(e){throw Error(`[SegmentMatcher.registerTree] Unbalanced constraint delimiter ('<' or '>') in path "${e}": every '<' must be closed by a '>'. A stray delimiter desyncs match vs build (buildPath would emit a URL match rejects).`)}function We(e){throw Error(`[SegmentMatcher.registerTree] Empty constraint '<>' in path "${e}": a constraint body must be non-empty (e.g. '<[0-9]+>'). An empty '<>' compiles to a never-matching pattern.`)}function Ge(e){throw Error(`[SegmentMatcher.registerTree] Text fused to a constraint '>' in path "${e}": a '<...>' constraint must end its segment or be followed by '/' or an optional '?' — use "/:id<...>/rest", not "/:id<...>rest".`)}function Ke(e){throw Error(`[SegmentMatcher.registerTree] Constraint '<...>' in a static segment in path "${e}": a '<...>' constraint must follow a parameter marker (':' or '*') — a static segment carrying '<...>' is silently stripped. Attach it to a param (e.g. "/:id<...>") or drop it.`)}function qe(e,t,n){switch(e){case`name-less`:return Ie();case`trailing-marker`:return Re(t);case`fused-marker`:return Le(t);case`optional-splat`:return Ve(t);case`empty-constraint`:return We(n);case`fused-constraint-suffix`:return Ge(n);case`constraint-in-static`:return Ke(n);case`unbalanced-constraint`:return Ue(n)}}function Je(e,t){let n=new Set,r=``;for(let e of t){if(n.has(e)){r=e;break}n.add(e)}throw Error(`[SegmentMatcher.registerTree] Duplicate parameter name ':${r}' in route "${e}": a param name must be unique within a route — two positions cannot both bind ':${r}' (the second silently overwrites the first). Rename one.`)}function Ye(e,t){throw Error(`[SegmentMatcher.registerTree] Invalid query-param declaration "${t}" in route "${e}": a query-param name cannot contain '<' or '>'. This is a reverse-order modifier typo that leaked a constraint into the query — put the optional '?' AFTER the constraint (':id<...>?', not ':id?<...>'). It would never round-trip.`)}function Xe(e,t){throw Error(`[SegmentMatcher.registerTree] Name collision in route "${e}": "${t}" is declared as BOTH a path param (':${t}') and a query param ('?${t}'). buildPath would emit its value twice (once in the path, once in the query). Rename one.`)}function Ze(e,t){throw Error(`[SegmentMatcher.registerTree] Duplicate route path: routes "${e}" and "${t}" resolve to the same URL. The later registration would silently shadow the earlier (its deep link would resolve to the other route). Give them distinct paths.`)}function Qe(e,t){throw Error(`[SegmentMatcher.registerTree] Index route "${e}" (path "/") under the dynamic parent "${t}" is not supported: the index cannot reliably replace the parent on every form of its path — under an optional param it binds only the present form, under a splat it is unreachable. Give the index a distinct path, or make the parent static.`)}function E(t){let n=e(t);return(`error`in n||n.kind===`static`)&&Ie(),n.name}function $e(e,t,n){return e.paramChild?e.paramChild.name!==t&&!n.has(e)&&Fe(e.paramChild.name,t,`:`):(e.paramChild={node:w(),name:t,fork:void 0},n.add(e)),e.paramChild.node}function et(e,t,n,r,i,a){let o=t.constraintPatterns.get(n)?.pattern;if(e.paramChild&&e.splatChild){o===void 0&&He(n),e.paramChild.fork={constraint:o};return}let s=i+1;if(s<=a){let t=r.indexOf(`/`,s),n=r.slice(s,t===-1?a:t);e.paramChild&&n.startsWith(`:`)&&!n.endsWith(`?`)&&(e.paramChild.fork={skipName:E(n)})}}function tt(e,t,n){if(!t.hasConstraints||!n.startsWith(`:`)||e.paramChild===void 0)return;let r=t.constraintPatterns.get(E(n))?.pattern;if(r===void 0)return;let i=e.paramChild;i.fork?.constraint===void 0?i.fork={...i.fork,constraint:r}:i.fork.constraint.source!==r.source&&(i.fork={...i.fork,constraint:RegExp(`(?:${i.fork.constraint.source})|(?:${r.source})`,i.fork.constraint.flags)})}function nt(e,t,n){return e.splatChild?e.splatChild.name!==t&&!n.has(e)&&Fe(e.splatChild.name,t,`*`):(e.splatChild={node:w(),name:t},n.add(e)),e.splatChild.node}function rt(e,t){e.route!==void 0&&e.route!==t&&e.routeIsStrong===!0&&Ze(e.route.name,t.name),e.route=t,e.routeIsStrong=!0}function it(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1}function at(e,t,n){let r=T(n);if(r===`/`){rt(e.root,t);return}let i=new Set,a=new Map;D(e,e.root,r,1,t,i,a)}function D(e,t,n,r,i,a,o){let s=o.get(t);if(s===void 0)s=new Set,o.set(t,s);else if(s.has(r))return;s.add(r);let c=n.length;for(;r<=c;){let s=n.indexOf(`/`,r),l=s===-1?c:s,u=n.slice(r,l);if(u.endsWith(`?`)){let r=E(u);D(e,$e(t,r,a),n,l+1,i,a,o),l>=c?t.route??=i:D(e,t,n,l+1,i,a,o),et(t,i,r,n,l,c);return}let d=t;t=lt(e,t,u,a),tt(d,i,u),r=l+1}rt(t,i)}function ot(e,t,n){let r=n.slice(n.lastIndexOf(`/`)+1),i=n.split(`/`).some(e=>e.startsWith(`:`)&&e.endsWith(`?`)),a=r.startsWith(`*`);(i||a)&&Qe(t.name,n);let o=st(e,n);o.slashChildRoute=t}function st(e,t){return ct(e,e.root,t)}function ct(e,t,n){let r=T(n);if(r===`/`||r===``)return t;let i=t,a=1,o=r.length,s=new Set;for(;a<=o;){let t=r.indexOf(`/`,a),n=t===-1?o:t;if(n<=a)break;let c=r.slice(a,n);i=lt(e,i,c,s),a=n+1}return i}function lt(e,t,n,r){if(n.startsWith(`*`)){let e=nt(t,E(n),r);return t.hasChildren=!0,e}if(n.startsWith(`:`)){let e=$e(t,E(n),r);return t.hasChildren=!0,e}it(n)&&Be(n);let i=e.options.caseSensitive?n:n.toLowerCase();return i in t.staticChildren||(t.staticChildren===Se&&(t.staticChildren=Object.create(null)),t.staticChildren[i]=w(),t.hasChildren=!0),t.staticChildren[i]}function ut(t,n,r,o,c){let l=n.fullName===``;l||o.push(n);let d=n.absolute,f=n.paramMeta===u?n.path:n.paramMeta.pathPattern,p=d&&f.startsWith(`~`)?f.slice(1):f,m=d?p:f;a(m)||Ue(m);for(let t of s(m)){let n=e(t);`error`in n&&qe(n.error,t,m)}let h=m.replaceAll(Me,``);i(m)&&ze(m);let g=d?h:Ce(r,h),_=l?c:dt(t,n,g,d?``:r,o,c);for(let e of n.children.values())ut(t,e,g,o,_);l||o.pop()}function dt(e,t,n,r,i,a){let o=gt(n,r),s=Object.freeze([...i]),c=ft(s),l=T(n),u=_t(e.rootQueryParams,i),d=vt(i),{buildStaticParts:f,buildParamSlots:p}=Pe(o?T(r):l,o?i.slice(0,-1):i,e.options.urlParamsEncoding),m=p.map(e=>e.paramName),h=m.length===0?De:new Set(m);h.size!==m.length&&Je(t.fullName,m),yt(t.fullName,u,h);let g={name:t.fullName,parent:a,matchSegments:s,meta:c,declaredQueryParams:u,declaredQueryParamsSet:u.length===0?De:new Set(u),hasTrailingSlash:n.length>1&&n.endsWith(`/`),constraintPatterns:d,hasConstraints:d.size>0,buildStaticParts:f,buildParamSlots:p,buildParamNamesSet:h,cachedResult:void 0};return t.paramMeta.urlParams.length===0&&(g.cachedResult=Object.freeze({segments:g.matchSegments,params:Ae,meta:g.meta})),e.routesByName.set(t.fullName,g),o?mt(e,g,r):ht(e,g,n,l,t),g}function ft(e){let t;for(let n of e)pt(n.paramTypeMap)&&(t??={},t[n.fullName]=n.paramTypeMap);return t===void 0?je:Object.freeze(t)}function pt(e){for(let t in e)if(Object.hasOwn(e,t))return!0;return!1}function mt(e,t,n){ot(e,t,n);let r=T(n),i=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.has(i)&&e.staticCache.set(i,t)}function ht(e,t,n,r,i){if(at(e,t,n),i.paramMeta.urlParams.length===0){let n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}function gt(e,t){return T(e)===T(t)}function _t(e,t){let n=[];e.length>0&&n.push(...e);for(let e of t)e.paramMeta.queryParams.length>0&&n.push(...e.paramMeta.queryParams);return n.length===0?Ee:n}function vt(e){let t=new Map;for(let n of e)for(let[e,r]of n.paramMeta.constraintPatterns)t.set(e,r);return t.size===0?Oe:t}function yt(e,n,r){for(let i of n)t.test(i)&&Ye(e,i),r.has(i)&&Xe(e,i)}function bt(e){return typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):String(e)}function xt(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}var St=class{get options(){return this.#e}#e;#t=w();#n=new Map;#r=new Map;#i={cleanPath:``,normalized:``,queryString:void 0};#a=[];#o=``;#s;#c;constructor(e){this.#e={caseSensitive:e.caseSensitive??!0,strictTrailingSlash:e.strictTrailingSlash??!1,strictQueryParams:e.strictQueryParams??!1,urlParamsEncoding:e.urlParamsEncoding??`default`,parseQueryString:e.parseQueryString,buildQueryString:e.buildQueryString},this.#s=this.#e.caseSensitive,this.#c=this.#e.urlParamsEncoding===`none`?null:be[this.#e.urlParamsEncoding]}registerTree(e){this.#a=e.paramMeta.queryParams,ut({root:this.#t,options:this.#e,routesByName:this.#n,staticCache:this.#r,rootQueryParams:this.#a},e,``,[],null)}match(e){if(!this.#p(e))return;let{cleanPath:t,normalized:n,queryString:r}=this.#i,i=this.#s?n:n.toLowerCase(),a=this.#r.get(i);if(a)return this.#e.strictTrailingSlash&&!this.#_(t,a)?void 0:r===void 0&&a.cachedResult?a.cachedResult:this.#h(a,{},r);let o={},s=this.#v(n,o);if(s&&!(this.#e.strictTrailingSlash&&!this.#_(t,s))&&this.#S(o)&&!(s.hasConstraints&&!this.#w(o,s)))return this.#h(s,o,r)}buildPath(e,t,n){let r=this.#n.get(e);if(!r)throw Error(`[SegmentMatcher.buildPath] '${e}' is not defined`);r.hasConstraints&&t&&this.#l(r,e,t);let i=this.#u(r,t),a=this.#d(i,n?.trailingSlash),o=this.#f(r,t,n?.queryParamsMode);return a+(o?`?${o}`:``)}getSegmentsByName(e){return this.#n.get(e)?.matchSegments}getMetaByName(e){return this.#n.get(e)?.meta}hasRoute(e){return this.#n.has(e)}#l(e,t,n){for(let[r,i]of e.constraintPatterns){let e=n[r];if(e!=null){let n=typeof e==`object`?JSON.stringify(e):String(e);if(!i.pattern.test(n))throw Error(`[SegmentMatcher.buildPath] '${t}' — param '${r}' value '${n}' does not match constraint '${i.constraint}'`)}}}#u(e,t){let n=e.buildStaticParts,r=e.buildParamSlots;if(r.length===0)return n[0];let i=n[0];for(let[e,a]of r.entries()){let r=t?.[a.paramName];if(r==null){if(!a.isOptional)throw Error(`[SegmentMatcher.buildPath] Missing required param '${a.paramName}'`);i.length>1?i=i.slice(0,-1):n[e+1].startsWith(`/`)&&(i=``),i+=n[e+1];continue}if(r===``&&!a.isOptional)throw Error(`[SegmentMatcher.buildPath] Missing required param '${a.paramName}' (empty string)`);let o=a.encoder(bt(r));i+=o+n[e+1]}return i}#d(e,t){return t===`always`&&!e.endsWith(`/`)?`${e}/`:t===`never`&&e!==`/`&&e.endsWith(`/`)?e.slice(0,-1):e}#f(e,t,n){if(!t||e.declaredQueryParams.length===0&&n!==`loose`)return``;let r={},i=!1;for(let n of e.declaredQueryParams)n in t&&(r[n]=t[n],i=!0);if(n===`loose`)for(let n in t)Object.hasOwn(t,n)&&!e.declaredQueryParamsSet.has(n)&&!e.buildParamNamesSet.has(n)&&(r[n]=t[n],i=!0);return i?this.#e.buildQueryString(r):``}#p(e){if(e===``&&(e=`/`),e.codePointAt(0)!==47)return!1;let t=this.#m(e);if(t===-2)return!1;t===-3&&(e=this.#o);let n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):void 0;if(r!==void 0){let e=r.indexOf(`#`);e!==-1&&(r=r.slice(0,e))}let i=T(n);return this.#i.cleanPath=n,this.#i.normalized=i,this.#i.queryString=r,!0}#m(e){let t=!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===35)return this.#o=e.slice(0,n),-3;if(r===63)return n;if(r>=128)return-2;if(r===47){if(t)return-2;t=!0}else t=!1}return-1}#h(e,t,n){if(!(n!==void 0&&!this.#g(e,t,n)))return{segments:e.matchSegments,params:t,meta:e.meta}}#g(e,t,n){let r;try{r=this.#e.parseQueryString(n)}catch{return!1}if(this.#e.strictQueryParams){let n=e.declaredQueryParamsSet;for(let e in r){if(!n.has(e))return!1;xt(t,e,r[e])}}else for(let e in r)xt(t,e,r[e]);return!0}#_(e,t){return(e.length>1&&e.endsWith(`/`))===t.hasTrailingSlash}#v(e,t){return e.length===1?this.#t.slashChildRoute??this.#t.route:this.#y(this.#t,e,1,t)}#y(e,t,n,r){let i=e,a=t.length,o=this.#s;for(;n<=a;){let e=t.indexOf(`/`,n),s=e===-1?a:e,c=t.slice(n,s),l=o?c:c.toLowerCase(),u;if(l in i.staticChildren)u=i.staticChildren[l];else if(i.paramChild){let e=i.paramChild,o=e.fork;if(i.splatChild!==void 0){if(o?.constraint!==void 0&&!this.#x(o.constraint,c))return this.#b(i.splatChild,t,n,r);let l={[o?.skipName!==void 0&&s>=a?o.skipName:e.name]:c},u=this.#y(e.node,t,s+1,l);return u!==void 0&&(!u.hasConstraints||this.#C(u,l))?(Object.assign(r,l),u):this.#b(i.splatChild,t,n,r)}u=e.node,o?.skipName!==void 0&&s>=a?r[o.skipName]=c:r[e.name]=c}else if(i.splatChild)return this.#b(i.splatChild,t,n,r);else return;i=u,n=s+1}return i.slashChildRoute??i.route}#b(e,t,n,r){let i=e.node;if(!i.hasChildren)return r[e.name]=t.slice(n),i.route;let a={},o=this.#y(i,t,n,a);return o&&(!o.hasConstraints||this.#C(o,a))?(Object.assign(r,a),o):(r[e.name]=t.slice(n),i.route)}#x(e,t){try{return e.test(this.#c?this.#c(t):t)}catch{return!1}}#S(e){let t=this.#c;if(!t)return!0;for(let n in e){let r=e[n];if(r.includes(`%`)){if(!Te(r))return!1;try{e[n]=t(r)}catch{return!1}}}return!0}#C(e,t){let n=this.#c;for(let[r,i]of e.constraintPatterns){if(!Object.hasOwn(t,r))continue;let e=t[r];if(n&&e.includes(`%`))try{e=n(e)}catch{return!1}if(!i.pattern.test(e))return!1}return!0}#w(e,t){for(let[n,r]of t.constraintPatterns)if(Object.hasOwn(e,n)&&!r.pattern.test(e[n]))return!1;return!0}};const Ct=Object.freeze(new Map),wt=Object.freeze([]);function Tt(e){return e.parent?.name?`${e.parent.fullName}.${e.name}`:e.name}function Et(e){let t=new Map;for(let n of e)t.set(n.name,n);return t}function Dt(e,t){let n=[],r=[];for(let i of e){let e=Ot(i,t);n.push(e),e.absolute||r.push(e)}return{childrenMap:Et(n),nonAbsoluteChildren:r}}function Ot(e,t){let n=o(e.path),r=n.urlParams.length===0&&n.queryParams.length===0&&n.spatParams.length===0&&n.constraintPatterns.size===0&&n.pathPattern===e.path?u:n,i=r.paramTypeMap,a={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:r,nonAbsoluteChildren:void 0,fullName:``,paramTypeMap:i};if(a.fullName=Tt(a),e.children.length===0)a.children=Ct,a.nonAbsoluteChildren=wt;else{let{childrenMap:t,nonAbsoluteChildren:n}=Dt(e.children,a);a.children=t,a.nonAbsoluteChildren=n,Object.freeze(a.nonAbsoluteChildren),Object.freeze(a.children)}return Object.freeze(i),Object.freeze(r.urlParams),Object.freeze(r.queryParams),Object.freeze(r.spatParams),Object.freeze(r),Object.freeze(a),a}function kt(e){return Ot(e,null)}function At(e,t,n){return kt(pe(e,t,n))}function O(e){let t=e.absolute?`~${e.path}`:e.path,n={name:e.name,path:t};return e.children.size>0&&(n.children=Array.from(e.children.values(),O)),n}function jt(e){return Array.from(e.children.values(),O)}const Mt=e=>{let t=e.indexOf(`%`),n=e.indexOf(`+`);if(t===-1&&n===-1)return e;let r=n===-1?e:e.replaceAll(`+`,` `);return t===-1?r:decodeURIComponent(r)},Nt=(e,t)=>{if(e===void 0)return t.boolean.decodeUndefined();let n=t.boolean.decodeRaw(e);if(n!==null)return n;let r=Mt(e),i=t.number.decode(r);return i===null?t.boolean.decodeValue(r):i},Pt=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Ft=e=>{try{return encodeURIComponent(e)}catch(t){if(!(t instanceof URIError))throw t;return encodeURIComponent(String(e).replaceAll(Pt,`�`))}},k=e=>{let t=typeof e;if(t!==`string`&&t!==`number`&&t!==`boolean`)throw TypeError(`[search-params] Array element must be a string, number, or boolean — received ${t}`);return Ft(e)},It=(e,t,n,r)=>{let i=`${e}${n}`,a=[];for(let e of t)if(e===null){let e=r.encode(i);e&&a.push(e)}else a.push(`${i}=${k(e)}`);return a.join(`&`)},Lt={none:{encodeArray:(e,t,n)=>It(e,t,``,n)},brackets:{encodeArray:(e,t,n)=>It(e,t,`[]`,n)},index:{encodeArray:(e,t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=`${e}[${i}]`;if(a===null){let e=n.encode(t);e&&r.push(e)}else r.push(`${t}=${k(a)}`)}return r.join(`&`)},indexed:!0},comma:{encodeArray:(e,t)=>{let n=[];for(let e of t)e!==null&&n.push(k(e));return n.length===0?``:`${e}=${n.join(`,`)}`},decodeValue:e=>e.includes(`,`)?e.split(`,`):null}},Rt={none:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:e=>e},auto:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:e=>e===`true`?!0:e===`false`?!1:null,decodeValue:e=>e},"empty-true":{encode:(e,t)=>t?e:`${e}=false`,decodeUndefined:()=>!0,decodeRaw:e=>e===`true`?!0:e===`false`?!1:null,decodeValue:e=>e}},zt={default:{encode:e=>e},hidden:{encode:()=>``}},Bt={auto:{decode:e=>{let t=e.length;if(t===0)return null;let n=+(e.codePointAt(0)===45);if(n===t||t-n>1&&e.codePointAt(n)===48&&e.codePointAt(n+1)!==46)return null;let r=!1;for(let i=n;i<t;i++){let a=e.codePointAt(i);if(!(a!==void 0&&a>=48&&a<=57)){if(a===46&&!r&&i!==n&&i!==t-1){r=!0;continue}return null}}let i=Number(e);return Object.is(i,-0)||!Number.isSafeInteger(i)&&!r?null:i}},none:{decode:()=>null}},A=(e,t,n,r)=>{if(e===void 0)throw TypeError(`[search-params] Unknown ${t} "${n}" — expected ${r}`);return e},Vt=(e,t,n,r)=>({boolean:A(Rt[t],`booleanFormat`,t,`"none" | "auto" | "empty-true"`),null:A(zt[n],`nullFormat`,n,`"default" | "hidden"`),number:A(Bt[r],`numberFormat`,r,`"none" | "auto"`),array:A(Lt[e],`arrayFormat`,e,`"none" | "brackets" | "index" | "comma"`)}),Ht={boolean:Rt.auto,null:zt.default,number:Bt.auto,array:Lt.none},j={arrayFormat:`none`,booleanFormat:`auto`,nullFormat:`default`,numberFormat:`auto`},Ut={...j,strategies:Ht},Wt=e=>{if(!e||e.arrayFormat===void 0&&e.booleanFormat===void 0&&e.nullFormat===void 0&&e.numberFormat===void 0)return Ut;let t=e.arrayFormat??j.arrayFormat,n=e.booleanFormat??j.booleanFormat,r=e.nullFormat??j.nullFormat,i=e.numberFormat??j.numberFormat;return{arrayFormat:t,booleanFormat:n,nullFormat:r,numberFormat:i,strategies:Vt(t,n,r,i)}},M=e=>Ft(e),Gt=(e,t,n)=>{let r=M(e);switch(typeof t){case`string`:case`number`:return`${r}=${M(t)}`;case`boolean`:return n.strategies.boolean.encode(r,t);case`object`:return t===null?n.strategies.null.encode(r):Array.isArray(t)?n.strategies.array.encodeArray(r,t,n.strategies.null):`${r}=${M(t)}`;default:return`${r}=${M(t)}`}};function N(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Kt(e,t,n,r){if(!Object.hasOwn(e,t)){N(e,t,r?[n]:n);return}let i=e[t];Array.isArray(i)?i.push(n):N(e,t,[i,n])}function qt(e,t,n,r,i){return Nt(r?e.slice(t+1,n):void 0,i)}function Jt(e,t,n){let r=t+1,i=0,a=!1;for(;r<n;){let t=e.codePointAt(r);if(t===93)return a?i:null;if(t!==void 0&&t>=48&&t<=57){i=i*10+(t-48),a=!0,r++;continue}return null}return null}function Yt(e,t,n){let{searchPart:r,nameEnd:i,nameSourceEnd:a,eqPos:o,end:s,hasValue:c,decodedName:l}=e,u=Jt(r,i,a);if(u===null)return!1;let d=qt(r,o,s,c,t),f=n.get(l);return f===void 0?n.set(l,[[u,d]]):f.push([u,d]),!0}function Xt(e,t,n,r,i,a,o){let s=a!==-1&&a<n,c=s?a:n,l=c,u=!1;for(let n=t;n<c;n++)if(e.codePointAt(n)===91){l=n,u=!0;break}let d=Mt(e.slice(t,l));if(!(o!==void 0&&u&&Yt({searchPart:e,nameEnd:l,nameSourceEnd:c,eqPos:a,end:n,hasValue:s,decodedName:d},i,o))){if(!u&&s&&i.array.decodeValue){let t=e.slice(a+1,n),o=i.array.decodeValue(t);if(o){for(let e of o)Kt(r,d,Nt(e,i),!0);return}}Kt(r,d,qt(e,a,n,s,i),u)}}const Zt=(e,t)=>{if(e===``||e===`?`)return{};let n={};return Qt(e,n,Wt(t).strategies),n};function Qt(e,t,n){let r=n.array.indexed?new Map:void 0,i=0,a=e.length,o=-2;for(;i<a;){let s=e.indexOf(`&`,i);s===-1&&(s=a),s>i&&(o!==-1&&o<i&&(o=e.indexOf(`=`,i)),Xt(e,i,s,t,n,o,r)),i=s+1}if(r!==void 0)for(let[e,n]of r)n.sort((e,t)=>e[0]-t[0]),N(t,e,n.map(e=>e[1]))}const $t=(e,t)=>{let n=Object.keys(e);if(n.length===0)return``;let r=Wt(t),i=[];for(let t of n){let n=e[t];if(n===void 0)continue;let a=Gt(t,n,r);a&&i.push(a)}return i.join(`&`)};function en(e){let t=e?.queryParams;return new St({...e?.caseSensitive!==void 0&&{caseSensitive:e.caseSensitive},...e?.strictTrailingSlash!==void 0&&{strictTrailingSlash:e.strictTrailingSlash},...e?.strictQueryParams!==void 0&&{strictQueryParams:e.strictQueryParams},...e?.urlParamsEncoding!==void 0&&{urlParamsEncoding:e.urlParamsEncoding},parseQueryString:e=>Zt(e,t),buildQueryString:e=>$t(e,t)})}const tn={defaultRoute:``,defaultParams:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:j,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0};function nn(e){Object.freeze(e);for(let t of Object.values(e))t&&typeof t==`object`&&t.constructor===Object&&nn(t);return e}function rn(e,t){return typeof e==`function`?e(t):e}function an(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.constructor] options must be a plain object`)}var on=class{#e;constructor(e={}){this.#e=nn({...tn,...e})}static validateOptionsIsObject(e){an(e)}get(){return this.#e}};function P(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!P(e[n],t[n]))return!1;return!0}return!1}const sn=new WeakMap;function F(e){return sn.get(e)}function cn(e,t){sn.set(e,t)}var ln=class{#e=void 0;#t=void 0;#n;get(){return this.#e}set(e){this.#t=this.#e,this.#e=e?ue(e):void 0}getPrevious(){return this.#t}reset(){this.#e=void 0,this.#t=void 0}setDependencies(e){this.#n=e}makeState(e,t,n,r,i){let a=this.#n.getDefaultParams(),o=Object.hasOwn(a,e),s;s=o?Object.freeze({...a[e],...t}):!t||t===v?v:Object.freeze({...t});let c={name:e,params:s,path:n??this.#n.buildPath(e,t),context:{},...!i&&{transition:y}};return r&&cn(c,r),i?c:ue(c)}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;if(e.name!==t.name)return!1;if(n){let n=this.#n.getUrlParams(e.name);for(let r of n)if(!P(e.params[r],t.params[r]))return!1;return!0}let r=Object.keys(e.params),i=Object.keys(t.params);if(r.length!==i.length)return!1;for(let n of r)if(!(n in t.params)||!P(e.params[n],t.params[n]))return!1;return!0}};const un={[h.ROUTER_START]:g.ROUTER_START,[h.ROUTER_STOP]:g.ROUTER_STOP,[h.TRANSITION_SUCCESS]:g.TRANSITION_SUCCESS,[h.TRANSITION_START]:g.TRANSITION_START,[h.TRANSITION_LEAVE_APPROVE]:g.TRANSITION_LEAVE_APPROVE,[h.TRANSITION_ERROR]:g.TRANSITION_ERROR,[h.TRANSITION_CANCEL]:g.TRANSITION_CANCEL},dn=Object.keys(un),I=`router.usePlugin`;function fn(e){if(!(e&&typeof e==`object`)||Array.isArray(e))throw TypeError(`[router.usePlugin] Plugin factory must return an object, got ${typeof e}`);if(typeof e.then==`function`)throw TypeError(`[router.usePlugin] Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.`)}var pn=class e{#e=new Set;#t=new Set;#n;static validatePlugin(e){fn(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...e){if(this.#n.getValidator()?.plugins.validateCountThresholds(this.#e.size+e.length),e.length===1){let t=e[0],n=this.#i(t);this.#e.add(t);let r=!1,i=()=>{if(!r){r=!0,this.#e.delete(t),this.#t.delete(i);try{n()}catch(e){this.#n.logger.error(I,`Error during cleanup:`,e)}}};return this.#t.add(i),i}let t=this.#r(e),n=[];try{for(let e of t){let t=this.#i(e);n.push({factory:e,cleanup:t})}}catch(e){for(let{cleanup:e}of n)try{e()}catch(e){this.#n.logger.error(I,`Cleanup error:`,e)}throw e}for(let{factory:e}of n)this.#e.add(e);let r=!1,i=()=>{if(!r){r=!0,this.#t.delete(i);for(let{factory:e}of n)this.#e.delete(e);for(let{cleanup:e}of n)try{e()}catch(e){this.#n.logger.error(I,`Error during cleanup:`,e)}}};return this.#t.add(i),i}getAll(){return[...this.#e]}has(e){return this.#e.has(e)}disposeAll(){for(let e of this.#t)e();this.#e.clear(),this.#t.clear()}#r(e){let t=new Set;for(let n of e)t.has(n)?this.#n.getValidator()?.plugins.warnBatchDuplicates(e):t.add(n);return t}#i(t){let n=this.#n.compileFactory(t);e.validatePlugin(n),this.#n.getValidator()?.plugins.validatePluginKeys(n),Object.freeze(n);let r=[];for(let e of dn)e in n&&(typeof n[e]==`function`?(r.push(this.#n.addEventListener(un[e],n[e])),e===`onStart`&&this.#n.canNavigate()&&this.#n.getValidator()?.plugins.warnPluginAfterStart(e)):this.#n.getValidator()?.plugins.warnPluginMethodType(e));return()=>{for(let e of r)e();typeof n.teardown==`function`&&n.teardown()}}};const mn=()=>!0,hn=()=>!1,gn=()=>mn,_n=()=>hn;function vn(e){return e?gn:_n}var yn=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#a=new Map;#o=[this.#i,this.#a];#s;setDependencies(e){this.#s=e}getHandlerCount(e){let t=e===`activate`?this.#e:this.#n,n=e===`activate`?this.#t:this.#r;if(t.size===0)return n.size;if(n.size===0)return t.size;let r=new Set(t.keys());for(let e of n.keys())r.add(e);return r.size}preflightHandlerLimit(e,t,n){let r=this.#s.getValidator();if(!r)return;let i=(e,t,i)=>{let{definition:a,external:o}=this.#d(e),s=0;for(let e of t)(n?o.has(e):a.has(e)||o.has(e))||s++;if(s===0)return;let c=n?o.size:this.getHandlerCount(e);r.lifecycle.validateHandlerLimit(c+s-1,i)};i(`activate`,e,`canActivate`),i(`deactivate`,t,`canDeactivate`)}addCanActivate(e,t,n=!1,r){this.#c(`activate`,e,t,n,`canActivate`,r)}addCanDeactivate(e,t,n=!1,r){this.#c(`deactivate`,e,t,n,`canDeactivate`,r)}clearCanActivate(e,t){this.#l(`activate`,e,t)}clearCanDeactivate(e,t){this.#l(`deactivate`,e,t)}clearAll(){this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#a.clear(),this.#i.clear()}clearDefinitionGuards(){for(let e of this.#e.keys())this.#t.has(e)?this.#u(`activate`,e):this.#a.delete(e);for(let e of this.#n.keys())this.#r.has(e)?this.#u(`deactivate`,e):this.#i.delete(e);this.#e.clear(),this.#n.clear()}getFactories(){let e={},t={};for(let[t,n]of this.#n)e[t]=n;for(let[t,n]of this.#r)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,n]of this.#t)t[e]=n;return[e,t]}getFactoriesByOrigin(){let e={},t={},n={},r={};for(let[t,n]of this.#n)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,t]of this.#r)n[e]=t;for(let[e,t]of this.#t)r[e]=t;return{definition:[e,t],external:[n,r]}}getFunctions(){return this.#o}canNavigateTo(e,t,n,r){for(let t of e)if(!this.#f(this.#i,t,n,r,`canNavigateTo`))return!1;for(let e of t)if(!this.#f(this.#a,e,n,r,`canNavigateTo`))return!1;return!0}compileGuardFactory(e,t){let n=typeof e==`boolean`?vn(e):e,r=this.#s.compileFactory(n);if(typeof r!=`function`)throw TypeError(`[router.${t}] Factory must return a function, got ${typeof r}`);return r}#c(e,t,n,r,i,a){let o=this.#d(e),s=e===`activate`?this.#a:this.#i,c=r?o.definition:o.external,l=r?o.external:o.definition;if(c.has(t)||l.has(t))this.#s.getValidator()?.lifecycle.warnOverwrite(t,e,i);else{let t=this.#s.getValidator();if(t){let n=this.getHandlerCount(e);t.lifecycle.validateHandlerLimit(n,i),t.lifecycle.validateCountThresholds(n+1,i)}}let u=typeof n==`boolean`?vn(n):n,d=c.get(t);c.set(t,u);let f=r&&l.has(t);try{let e=a??this.compileGuardFactory(u,i);f||s.set(t,e)}catch(n){throw d===void 0?c.delete(t):c.set(t,d),this.#u(e,t),n}}#l(e,t,n){let{definition:r,external:i}=this.#d(e),a=n===`external`?!1:r.delete(t),o=n===`definition`?!1:i.delete(t);(a||o)&&this.#u(e,t)}#u(e,t){let n=this.#d(e),r=e===`activate`?this.#a:this.#i,i=n.external.get(t)??n.definition.get(t);if(!i){r.delete(t);return}try{let e=this.#s.compileFactory(i);if(typeof e!=`function`){r.delete(t);return}r.set(t,e)}catch{r.delete(t)}}#d(e){return e===`activate`?{definition:this.#e,external:this.#t}:{definition:this.#n,external:this.#r}}#f(e,t,n,r,i){let a=e.get(t);if(!a)return!0;try{let e=a(n,r);return typeof e==`boolean`?e:(this.#s.getValidator()?.lifecycle.warnAsyncGuardSync(t,i),!1)}catch(e){return this.#s.logger.warn(`router.${i}`,`Guard for "${t}" threw — treated as navigation-blocking (returned false)`,e),!1}}};const bn=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`]);function L(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function xn(e,t){for(let n of Object.keys(t))Object.assign(e[n],t[n])}function Sn(e,t){for(let n in e)if(e[n]!==t[n])return!1;return!0}function Cn(e,t,n){for(let r in e)if(!(r in n)&&e[r]!==t[r])return!1;return!0}function wn(e,t){if(!t||!Tn(e,t))return e;let n={};for(let r in e)t[r]!==`query`&&(n[r]=e[r]);return n}function Tn(e,t){for(let n in e)if(t[n]===`query`)return!0;return!1}function R(e){let t={name:e.name,path:e.path};return e.children&&(t.children=e.children.map(e=>R(e))),t}function En(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t)return e.splice(r,1),!0;if(i.children&&t.startsWith(`${a}.`)&&En(i.children,t,a))return!0}return!1}function Dn(e,t){for(let n of Object.keys(e))t(n)&&delete e[n]}function On(e,t){let n=t.search(/[?#]/),r=n===-1?t:t.slice(0,n);if(r===`/`||r.endsWith(`/`))return t;let i=e.search(/[?#]/),a=i===-1?e:e.slice(0,i);return a.length>1&&a.endsWith(`/`)?`${r}/${n===-1?``:t.slice(n)}`:t}function kn(e,t,n=100){let r=new Set,i=[e],a=e;for(;t[a];){let e=t[a];if(r.has(e)){let t=i.indexOf(e),n=[...i.slice(t),e];throw Error(`Circular forwardTo: ${n.join(` → `)}`)}if(r.add(a),i.push(e),a=e,i.length>n)throw Error(`forwardTo chain exceeds maximum depth (${n}): ${i.join(` → `)}`)}return a}function An(e,t,n){let r=At(``,t,e),i=en(n);return i.registerTree(r),{tree:r,matcher:i}}function z(e,t=e.definitions){let n=An(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear()}function jn(e,t){z(e,t),e.resolvedForwardMap=B(e.config)}function Mn(e){Nn(e),z(e,[])}function Nn(e){Object.assign(e.config,L()),e.resolvedForwardMap=Object.create(null),e.routeCustomFields=Object.create(null)}function B(e){let t=Object.create(null);for(let n of Object.keys(e.forwardMap))t[n]=kn(n,e.forwardMap);return t}function Pn(e,t){if(typeof e!=`function`)return;let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw TypeError(`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}function Fn(e,t,n,r){if(e.canActivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`real-router`,`Route "${t}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${n}".`)}if(e.canDeactivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`real-router`,`Route "${t}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${n}".`)}Pn(e.forwardTo,t),typeof e.forwardTo==`string`?n.forwardMap[t]=e.forwardTo:n.forwardFnMap[t]=e.forwardTo}function In(e,t,n,r,i,a,o){let s=Object.fromEntries(Object.entries(e).filter(([e])=>!bn.has(e)));Object.keys(s).length>0&&(r[t]=s),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&Fn(e,t,n,o),e.decodeParams&&(n.decoders[t]=t=>e.decodeParams?.(t)??t),e.encodeParams&&(n.encoders[t]=t=>e.encodeParams?.(t)??t),e.defaultParams&&(n.defaultParams[t]=e.defaultParams)}function Ln(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;In(s,e,t,n,r,i,a),s.children&&Ln(s.children,t,n,r,i,a,e)}}function Rn(e){let t=L();return xn(t,e),t}function zn(e,t,n){if(n.length===0)return[...e,...t];let[r,...i]=n;return e.map(e=>{if(e.name!==r)return e;let n=e.children??[];return{...e,children:i.length===0?[...n,...t]:zn(n,t,i)}})}function Bn(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&Bn(r.children,e,n)}}function V(e,t,n){let r=new Set;Bn(e,t,e=>{if(r.has(e))throw Error(`[router.${n}] Duplicate route "${e}" in batch`);r.add(e)})}function Vn(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 H(e,t){for(let n of e)Vn(n.name,t),n.children&&H(n.children,t)}function Hn(e,t,n){let r=new Map,i=(e,t)=>{for(let a of e){let e=r.get(t);if(e?.has(a.path))throw Error(`[router.${n}] Path "${a.path}" is already defined`);e?e.add(a.path):r.set(t,new Set([a.path])),a.children&&i(a.children,t?`${t}.${a.name}`:a.name)}};i(e,t)}function Un(e,t,n){if(H(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw Error(`[router.addRoute] Parent route "${n}" does not exist`);Bn(t,n??``,t=>{if(e.matcher.hasRoute(t))throw Error(`[router.addRoute] Route "${t}" already exists`)}),V(t,n??``,`addRoute`),Hn(t,n??``,`addRoute`)}function Wn({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:o,logger:s}){let c=new Map,l=new Map;Ln(t,n,r,c,l,s,i);let u=B(n),{tree:d,matcher:f}=An(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function Gn(e,t,n,r){return Wn({definitions:zn(e.definitions,t.map(e=>R(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:Rn(e.config),routeCustomFields:Object.assign(Object.create(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function Kn(e,t,n,r){return Wn({definitions:e.map(e=>R(e)),routesForHandlers:e,config:L(),routeCustomFields:Object.create(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function qn(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function Jn(e,t){return{activate:qn(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:qn(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function Yn(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??Jn(t,r);Object.assign(e.config,t.config),e.routeCustomFields=t.routeCustomFields,e.tree=t.tree,e.matcher=t.matcher,e.urlParamsCache.clear(),e.resolvedForwardMap=t.resolvedForwardMap;for(let[e,t,n]of i)r.addActivateGuard(e,t,n);for(let[e,t,n]of a)r.addDeactivateGuard(e,t,n)}function Xn(e,t,n,r){let{forwardTo:i,defaultParams:a,decodeParams:o,encodeParams:s,canActivate:c,canDeactivate:l}=r,u=i===void 0?void 0:Zn(n,i,e.config),d=Qn(e,n,r),f=c==null?void 0:t.compileGuardFactory(c,`canActivate`),p=l==null?void 0:t.compileGuardFactory(l,`canDeactivate`);return t.preflightHandlerLimit(f===void 0?[]:[n],p===void 0?[]:[n],!1),d!==void 0&&(Object.keys(d).length>0?e.routeCustomFields[n]=d:delete e.routeCustomFields[n]),u!==void 0&&(e.config.forwardMap=u.forwardMap,e.config.forwardFnMap=u.forwardFnMap,e.resolvedForwardMap=u.resolved),$n(e,n,{defaultParams:a,decodeParams:o,encodeParams:s}),er(t,`activate`,n,c,f),er(t,`deactivate`,n,l,p),{forwardTo:i,defaultParams:a,decodeParams:o,encodeParams:s}}function Zn(e,t,n){Pn(t,e);let r=Object.assign(Object.create(null),n.forwardMap),i=Object.assign(Object.create(null),n.forwardFnMap);return t===null?(delete r[e],delete i[e]):typeof t==`string`?(delete i[e],r[e]=t):(delete r[e],i[e]=t),{forwardMap:r,forwardFnMap:i,resolved:B({...n,forwardMap:r})}}function Qn(e,t,n){let r;for(let i of Object.keys(n)){if(bn.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:r[i]=a)}return r}function $n(e,t,n){if(n.defaultParams!==void 0&&(n.defaultParams===null?delete e.config.defaultParams[t]:e.config.defaultParams[t]=n.defaultParams),n.decodeParams!==void 0)if(n.decodeParams===null)delete e.config.decoders[t];else{let r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}if(n.encodeParams!==void 0)if(n.encodeParams===null)delete e.config.encoders[t];else{let r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}function er(e,t,n,r,i){r!==void 0&&(t===`activate`?r===null?e.clearCanActivate(n,`definition`):e.addCanActivate(n,r,!0,i):r===null?e.clearCanDeactivate(n,`definition`):e.addCanDeactivate(n,r,!0,i))}function tr(e,t,n){H(e,`addRoute`),V(e,``,`addRoute`);let r=Kn(e,``,t,n),i={get definitions(){return jt(i.tree)},config:r.config,tree:r.tree,matcher:r.matcher,urlParamsCache:new Map,resolvedForwardMap:r.resolvedForwardMap,routeCustomFields:r.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:r.pendingCanActivate,pendingCanDeactivate:r.pendingCanDeactivate};return i}const U=[];Object.freeze(U);function nr(e){let t=e.split(`.`),n=t.length,r=[t[0]],i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}const rr=new Set([`string`,`number`,`boolean`]);function ir(e){return rr.has(typeof e)}function ar(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of Object.keys(i)){let t=n.params[e],i=r.params[e];if(ir(t)&&ir(i)&&String(t)!==String(i))return!1}return!0}function or(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!ar(a,e,t,n))return o}return a}const sr=new Map;function W(e){let t=sr.get(e);if(t)return t;let n=cr(e);return Object.freeze(n),sr.set(e,n),n}function cr(e){if(!e)return[``];let t=e.indexOf(`.`);if(t===-1)return[e];let n=e.indexOf(`.`,t+1);if(n===-1)return[e.slice(0,t),e];let r=e.indexOf(`.`,n+1);return r===-1?[e.slice(0,t),e.slice(0,n),e]:e.indexOf(`.`,r+1)===-1?[e.slice(0,t),e.slice(0,n),e.slice(0,r),e]:nr(e)}let lr,ur,G=null,dr,fr,pr=null;function mr(e,t){if(!t)return{intersection:``,toActivate:W(e.name),toDeactivate:U};let n=F(e),r=F(t);if(!n&&!r)return{intersection:``,toActivate:W(e.name),toDeactivate:W(t.name)};let i=W(e.name),a=W(t.name),o=Math.min(a.length,i.length),s=or(n??r,e,t,i,a,o),c;if(s>=a.length)c=U;else if(s===0&&a.length===1)c=a;else{c=[];for(let e=a.length-1;e>=s;e--)c.push(a[e])}let l=s===0?i:i.slice(s);return{intersection:s>0?a[s-1]:``,toDeactivate:c,toActivate:l}}function K(e,t){if(G!==null&&e===lr&&t===ur)return G;if(pr!==null&&e===dr&&t===fr)return pr;let n=mr(e,t);return dr=lr,fr=ur,pr=G,lr=e,ur=t,G=n,n}function hr(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}function gr(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,meta:e.meta}}var _r=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,n){this.#e=tr(e,t,n)}static shouldUpdateNode(e){return(t,n)=>{if(!(t&&typeof t==`object`&&`name`in t))throw TypeError(`[router.shouldUpdateNode] toState must be valid State object`);if(t.transition.reload||e===``)return!0;let{intersection:r,toActivate:i,toDeactivate:a}=K(t,n);return e===r||i.includes(e)?!0:a.includes(e)}}setDependencies(e){this.#e.depsStore=e}flushPendingGuards(){let e=this.#r;for(let[t,n]of this.#e.pendingCanActivate)e.addActivateGuard(t,n);this.#e.pendingCanActivate.clear();for(let[t,n]of this.#e.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#e.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#e.lifecycleNamespace=e}setRootPath(e){this.#e.rootPath=e,z(this.#e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){Mn(this.#e)}buildPath(e,t,n){if(e===m.UNKNOWN_ROUTE)return typeof t?.path==`string`?t.path:``;let r=Object.hasOwn(this.#e.config.defaultParams,e)?{...this.#e.config.defaultParams[e],...t}:t??{},i=typeof this.#e.config.encoders[e]==`function`?this.#e.config.encoders[e]({...r}):r;return this.#e.matcher.buildPath(e,i,this.#a(n))}matchPath(e,t){let n=t,r=this.#e.matcher.match(e);if(!r)return;let{name:i,params:a,meta:o}=gr(r),s=typeof this.#e.config.decoders[i]==`function`?this.#e.config.decoders[i](a):a,{name:c,params:l}=this.#r.forwardState(i,s),u=e;if(n.rewritePathOnMatch){let t=typeof this.#e.config.encoders[c]==`function`?this.#e.config.encoders[c]({...l}):l,r=n.trailingSlash;try{u=this.#e.matcher.buildPath(c,t,{trailingSlash:r===`never`||r===`always`?r:void 0,queryParamsMode:n.queryParamsMode}),r===`preserve`&&(u=On(e,u))}catch{u=e}}return this.#r.makeState(c,l,u,o)}forwardState(e,t){if(Object.hasOwn(this.#e.config.forwardFnMap,e)){let n=this.#i(e,t),r=this.#e.config.forwardFnMap[e],i=this.#o(e,r,t);return{name:i,params:this.#i(i,n)}}let n=this.#e.resolvedForwardMap[e]??e;if(n!==e&&Object.hasOwn(this.#e.config.forwardFnMap,n)){let r=this.#i(e,t),i=this.#e.config.forwardFnMap[n],a=this.#o(n,i,t);return{name:a,params:this.#i(a,r)}}if(n!==e){let r=this.#i(e,t);return{name:n,params:this.#i(n,r)}}return{name:e,params:this.#i(e,t)}}buildStateResolved(e,t){let n=this.#e.matcher.getSegmentsByName(e);if(n)return gr({segments:n,params:t,meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(e,t={},n=!1,r=!0){let i=this.#r.getState();if(!i)return!1;let a=i.name;if(a!==e&&!a.startsWith(`${e}.`)&&!e.startsWith(`${a}.`))return!1;let o=this.#e.config.defaultParams[e];if(n||a===e){let n={name:e,params:o?{...o,...t}:t,path:``,transition:y,context:{}};return this.#r.areStatesEqual(n,i,r)}if(!a.startsWith(`${e}.`))return!1;let s=i.params;return Sn(t,s)?o?Cn(r?wn(o,this.#e.matcher.getMetaByName(e)?.[e]):o,s,t):!0:!1}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){let t=this.#e.urlParamsCache.get(e);if(t!==void 0)return t;let n=this.#e.matcher.getSegmentsByName(e),r=n?hr(n):[];return this.#e.urlParamsCache.set(e,r),r}getStore(){return this.#e}#i(e,t){return Object.hasOwn(this.#e.config.defaultParams,e)?{...this.#e.config.defaultParams[e],...t}:t}#a(e){if(this.#t)return e!==this.#n&&this.#r.logger.warn(`router.buildPath`,"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957)."),this.#t;this.#n=e;let t=e?.trailingSlash;return this.#t=Object.freeze({trailingSlash:t===`never`||t===`always`?t:void 0,queryParamsMode:e?.queryParamsMode}),this.#t}#o(e,t,n){let r=new Set([e]),i=t(this.#r.getDependency,n),a=0;if(typeof i!=`string`)throw TypeError(`forwardTo callback must return a string, got ${typeof i}`);for(;a<100;){if(this.#e.matcher.getSegmentsByName(i)===void 0)throw Error(`Route "${i}" does not exist`);if(r.has(i)){let e=[...r,i].join(` → `);throw Error(`Circular forwardTo: ${e}`)}if(r.add(i),Object.hasOwn(this.#e.config.forwardFnMap,i)){let e=this.#e.config.forwardFnMap[i];i=e(this.#r.getDependency,n),a++;continue}let e=this.#e.config.forwardMap[i];if(e!==void 0){i=e,a++;continue}return i}throw Error(`forwardTo exceeds maximum depth of 100`)}};const vr=new Set(Object.values(f)),yr=new Set([`code`,`segment`,`path`]),br=new Set([`setCode`,`setErrorInstance`,`setAdditionalFields`,`hasField`,`getField`,`toJSON`]);var q=class extends Error{segment;path;code;constructor(e,{message:t,segment:n,path:r,...i}={}){super(t??e),this.name=`RouterError`,this.code=e,this.segment=n,this.path=r;for(let[e,t]of Object.entries(i)){if(yr.has(e))throw TypeError(`[RouterError] Cannot set reserved property "${e}"`);br.has(e)||(this[e]=t)}}setCode(e){this.code=e,vr.has(this.message)&&(this.message=e)}setErrorInstance(e){if(!e)throw TypeError(`[RouterError.setErrorInstance] err parameter is required and must be an Error instance`);this.message=e.message,this.cause=e.cause,this.stack=e.stack??``}setAdditionalFields(e){for(let[t,n]of Object.entries(e)){if(yr.has(t))throw TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${t}"`);br.has(t)||(this[t]=n)}}hasField(e){return e in this}getField(e){return this[e]}toJSON(){let e={code:this.code,message:this.message};this.segment!==void 0&&(e.segment=this.segment),this.path!==void 0&&(e.path=this.path);let t=new Set([`code`,`message`,`segment`,`path`,`stack`,`name`]);for(let n in this)Object.hasOwn(this,n)&&!t.has(n)&&(e[n]=this[n]);return e}};const xr=new q(f.ROUTER_NOT_STARTED),Sr=new q(f.ROUTE_NOT_FOUND),Cr=new q(f.SAME_STATES),wr=Promise.reject(xr),Tr=Promise.reject(Sr),Er=Promise.reject(Cr);wr.catch(()=>{}),Tr.catch(()=>{}),Er.catch(()=>{});function Dr(e,t,n,r,i){Object.freeze(n),Object.freeze(r);let a={phase:`activating`,reason:`success`,segments:Object.freeze({deactivated:n,activated:r,intersection:i})};return e?.name!==void 0&&(a.from=e.name),t.reload!==void 0&&(a.reload=t.reload),t.replace!==void 0&&(a.replace=t.replace),t.redirected!==void 0&&(a.redirected=t.redirected),Object.freeze(a)}function Or({signal:e,...t}){return t}function kr(e,t){let{toState:n,fromState:r,opts:i,toDeactivate:a,toActivate:o,intersection:s}=t;if(n.name!==m.UNKNOWN_ROUTE&&!e.hasRoute(n.name)){let t=new q(f.ROUTE_NOT_FOUND,{routeName:n.name});throw e.sendTransitionFail(n,r,t),t}if(r)for(let n of a)!o.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n);n.transition=Dr(r,i,a,o,s);let c=Object.freeze(n);e.setState(c);let l=i.signal===void 0?i:Or(i);return e.sendTransitionDone(c,r,l),c}function Ar(e,t,n,r){let i=t;i.code===f.TRANSITION_CANCELLED||i.code===f.ROUTE_NOT_FOUND||e.sendTransitionFail(n,r,i)}function jr(e,t,n){if(e instanceof DOMException&&e.name===`AbortError`)throw new q(f.TRANSITION_CANCELLED);if(e instanceof q&&e.code===f.TRANSITION_CANCELLED)throw e;Mr(e,t,n)}function Mr(e,t,n){throw e instanceof q?(e.setCode(t),e):new q(t,Pr(e,n))}const Nr=new Set([`code`,`segment`,`path`,`then`]);function Pr(e,t){let n={segment:t};if(e instanceof Error)return{...n,message:e.message,stack:e.stack,...`cause`in e&&e.cause!==void 0&&{cause:e.cause}};if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))Nr.has(n)||(t[n]=r);return{...n,...t}}return n}async function Fr(e,t,n){let r;try{r=await e}catch(e){jr(e,t,n);return}if(!r)throw new q(t,{segment:n})}async function Ir(e,t,n,r,i,a,o,s,c,l){await Fr(c,n,l);for(let c=s;c<t.length;c++){if(!o())throw new q(f.TRANSITION_CANCELLED);let s=t[c],l=e.get(s);if(!l)continue;let u=!1;try{u=l(r,i,a)}catch(e){jr(e,n,s)}if(u instanceof Promise){await Fr(u,n,s);continue}if(!u)throw new q(n,{segment:s})}}async function Lr(e,t,n,r,i,a,o,s,c){if(await e,!s())throw new q(f.TRANSITION_CANCELLED);let l=c();if(l!==void 0&&(await l,!s()))throw new q(f.TRANSITION_CANCELLED);if(r){let e=J(t,n,f.CANNOT_ACTIVATE,i,a,o,s);if(e!==void 0&&await e,!s())throw new q(f.TRANSITION_CANCELLED)}}function Rr(e,t,n,r,i,a,o,s,c,l,u){if(i){let i=J(e,n,f.CANNOT_DEACTIVATE,o,s,c,l);if(i!==void 0)return Lr(i,t,r,a,o,s,c,l,u)}if(!l())throw new q(f.TRANSITION_CANCELLED);let d=u();if(d!==void 0)return zr(d,a?t:void 0,r,o,s,c,l);if(a)return J(t,r,f.CANNOT_ACTIVATE,o,s,c,l)}async function zr(e,t,n,r,i,a,o){if(await e,!o())throw new q(f.TRANSITION_CANCELLED);if(t!==void 0){let e=J(t,n,f.CANNOT_ACTIVATE,r,i,a,o);if(e!==void 0&&await e,!o())throw new q(f.TRANSITION_CANCELLED)}}function J(e,t,n,r,i,a,o){for(let[s,c]of t.entries()){if(!o())throw new q(f.TRANSITION_CANCELLED);let l=e.get(c);if(!l)continue;let u=!1;try{u=l(r,i,a)}catch(e){jr(e,n,c)}if(u instanceof Promise)return Ir(e,t,n,r,i,a,o,s+1,u,c);if(!u)throw new q(n,{segment:c})}}const Br=Object.freeze([m.UNKNOWN_ROUTE]),Vr=Object.freeze({replace:!0});function Hr(e,t){return t?.name===m.UNKNOWN_ROUTE&&!e.replace?{...e,replace:!0}:e}function Ur(e,t,n){return!!e&&!t.reload&&!t.force&&e.path===n.path}var Wr=class{lastSyncResolved=!1;lastSyncRejected=!1;#e;#t=null;#n=0;setDependencies(e){this.#e=e}navigate(e,t,n){this.lastSyncResolved=!1;let r=this.#e;if(!r.canNavigate())return this.lastSyncRejected=!0,wr;let i;try{i=r.buildNavigateState(e,t)}catch(e){return Promise.reject(e)}return i?this.#r(i,n):(r.emitTransitionError(void 0,r.getState(),Sr),this.lastSyncRejected=!0,Tr)}navigateToState(e,t){this.lastSyncResolved=!1;let n=this.#e;if(!n.canNavigate())return this.lastSyncRejected=!0,wr;if(e.name!==m.UNKNOWN_ROUTE&&!n.hasRoute(e.name)){let t=new q(f.ROUTE_NOT_FOUND,{routeName:e.name});return n.emitTransitionError(void 0,n.getState(),t),Promise.reject(t)}let r={name:e.name,params:e.params,path:e.path,context:{...e.context}},i=F(e);return i!==void 0&&cn(r,i),this.#r(r,t)}navigateToDefault(e){this.lastSyncResolved=!1;let t=this.#e;if(!t.getOptions().defaultRoute)return Promise.reject(new q(f.ROUTE_NOT_FOUND,{routeName:`defaultRoute not configured`}));let n,r;try{({route:n,params:r}=t.resolveDefault())}catch(e){return Promise.reject(e)}return n?this.navigate(n,r,e):Promise.reject(new q(f.ROUTE_NOT_FOUND,{routeName:`defaultRoute resolved to empty`}))}navigateToNotFound(e){if(!this.#e.isActive())throw new q(f.ROUTER_DISPOSED);this.#c();let t=this.#e.getState(),n=t?W(t.name).toReversed():[];Object.freeze(n);let r={deactivated:n,activated:Br,intersection:``};Object.freeze(r);let i={phase:`activating`,...t&&{from:t.name},reason:`success`,replace:!0,segments:r};Object.freeze(i);let a={name:m.UNKNOWN_ROUTE,params:v,path:e,transition:i,context:{}};return Object.freeze(a),this.#e.setState(a),this.#e.emitTransitionSuccess(a,t,Vr),a}abortCurrentController(e){this.#t?.abort(e??new q(f.TRANSITION_CANCELLED)),this.#t=null}#r(e,t){let n=this.#e,r,i=!1,a=null;try{if(r=n.getState(),t=Hr(t,r),Ur(r,t,e))return n.emitTransitionError(e,r,Cr),this.lastSyncRejected=!0,Er;this.#c(t.signal);let o=++this.#n,s=t.signal!==void 0||n.hasLeaveListeners()||n.hasPreCommitListeners();n.startTransition(e,r),i=!0;let[c,l]=n.getLifecycleFunctions(),u=e.name===m.UNKNOWN_ROUTE,d=K(e,r),{toDeactivate:p,toActivate:h,intersection:g}=d,_=r&&!t.forceDeactivate&&p.length>0,v=!u&&h.length>0,ee=c.size>0||l.size>0,y=e;if(!ee){let e=this.#o(y,r,o,t,d,c);if(e!==void 0)return e}if(ee){a=new AbortController,this.#t=a;let i=()=>this.#n===o&&n.isActive(),s=a.signal,u=Rr(c,l,p,h,!!_,v,e,r,s,i,()=>{if(n.sendLeaveApprove(y,r),n.hasLeaveListeners())return n.awaitLeaveListeners(y,r,s)});if(u!==void 0)return this.#i(u,{toState:e,fromState:r,opts:t,toDeactivate:p,toActivate:h,intersection:g,canDeactivateFunctions:c},a,o);if(!i())throw new q(f.TRANSITION_CANCELLED);this.#s(a,!1)}if(s&&(!n.isActive()||t.signal?.aborted===!0))throw new q(f.TRANSITION_CANCELLED);let te=kr(n,{toState:e,fromState:r,opts:t,toDeactivate:p,toActivate:h,intersection:g,canDeactivateFunctions:c});return this.lastSyncResolved=!0,Promise.resolve(te)}catch(t){return this.#a(t,a,i,e,r),Promise.reject(t)}}async#i(e,t,n,r){let i=this.#e,a=()=>this.#n===r&&!n.signal.aborted&&i.isActive(),o=t.opts.signal,s,c,l=!1,u,d=new Promise(e=>{if(n.signal.aborted){e();return}c=()=>{e()},n.signal.addEventListener(`abort`,c,{once:!0})});e.catch(()=>{});try{if(o){if(o.aborted)throw new q(f.TRANSITION_CANCELLED,{reason:o.reason});s=()=>{i.cancelNavigation(o.reason)},o.addEventListener(`abort`,s,{once:!0})}if(await Promise.race([e,d]),!a())throw new q(f.TRANSITION_CANCELLED);let n=kr(i,t);return l=!0,n}catch(e){throw u=e,Ar(i,e,t.toState,t.fromState),e}finally{s&&o?.removeEventListener(`abort`,s),c&&n.signal.removeEventListener(`abort`,c),this.#s(n,!l,u)}}#a(e,t,n,r,i){t&&this.#s(t,!0,e),n&&r&&Ar(this.#e,e,r,i)}#o(e,t,n,r,i,a){let o=this.#e;if(o.sendLeaveApprove(e,t),o.hasLeaveListeners()){let s=new AbortController;this.#t=s;let c;try{c=o.awaitLeaveListeners(e,t,s.signal)}catch(e){throw this.#s(s,!0,e),e}if(c!==void 0)return this.#i(c,{toState:e,fromState:t,opts:r,toDeactivate:i.toDeactivate,toActivate:i.toActivate,intersection:i.intersection,canDeactivateFunctions:a},s,n);this.#s(s,!1);return}}#s(e,t,n){t&&e.abort(n),this.#t===e&&(this.#t=null)}#c(e){if(this.#e.isTransitioning()&&(this.#e.logger.warn(`router.navigate`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),this.#e.cancelNavigation()),e?.aborted)throw new q(f.TRANSITION_CANCELLED,{reason:e.reason})}};const Gr=Object.freeze({replace:!0});var Kr=class{#e;setDependencies(e){this.#e=e}async start(e){let t=this.#e;if(t.isIdle())throw new q(f.TRANSITION_CANCELLED);let n=t.getOptions();if(typeof e!=`string`)throw TypeError(`[router.start] path must be a string, got ${typeof e}`);let r=t.matchPath(e);if(!r&&!n.allowNotFound){let n=new q(f.ROUTE_NOT_FOUND,{path:e});throw t.emitTransitionError(void 0,void 0,n),n}return t.completeStart(),r?t.navigateToState(r,Gr):t.navigateToNotFound(e)}stop(){this.#e.clearState()}};function qr(e,t,n){let r=e[t];if(r===void 0)throw Error(`[FSM.${n}] state "${t}" is not declared in config.transitions`);return r}var Jr=class{#e;#t;#n=0;#r=null;#i;#a;#o=[];constructor(e){this.#e=e.initial,this.#i=e.context,this.#a=e.transitions,this.#t=qr(e.transitions,e.initial,`constructor`);for(let t of Object.keys(e.transitions)){let n=e.transitions[t];for(let t of Object.keys(n)){let r=n[t];r!==void 0&&qr(e.transitions,r,`constructor`)}}}send(e,...t){let n=this.#t[e];if(n===void 0)return this.#e;let r=this.#e;this.#e=n,this.#t=this.#a[n];let i=t[0];if(this.#r!==null){let t=this.#r.get(r)?.get(e);t!==void 0&&t(i)}if(this.#n>0){let t={from:r,to:n,event:e,payload:i};for(let e of this.#o)e!==null&&e(t)}return this.#e}canSend(e){return this.#t[e]!==void 0}getState(){return this.#e}getContext(){return this.#i}on(e,t,n){qr(this.#a,e,`on`),this.#r??=new Map;let r=this.#r.get(e);r||(r=new Map,this.#r.set(e,r));let i=n;return r.set(t,i),()=>{let n=this.#r?.get(e);n?.get(t)===i&&n.delete(t)}}onTransition(e){let t=this.#o.indexOf(null),n;t===-1?(n=this.#o.length,this.#o.push(e)):(this.#o[t]=e,n=t),this.#n++;let r=!0;return()=>{r&&(r=!1,this.#o[n]=null,this.#n--)}}};const Y={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},X={START:`START`,STARTED:`STARTED`,NAVIGATE:`NAVIGATE`,LEAVE_APPROVE:`LEAVE_APPROVE`,COMPLETE:`COMPLETE`,FAIL:`FAIL`,CANCEL:`CANCEL`,STOP:`STOP`,DISPOSE:`DISPOSE`},Yr={initial:Y.IDLE,context:null,transitions:{[Y.IDLE]:{[X.START]:Y.STARTING,[X.DISPOSE]:Y.DISPOSED},[Y.STARTING]:{[X.STARTED]:Y.READY,[X.FAIL]:Y.IDLE,[X.STOP]:Y.IDLE,[X.DISPOSE]:Y.DISPOSED},[Y.READY]:{[X.NAVIGATE]:Y.TRANSITION_STARTED,[X.FAIL]:Y.READY,[X.STOP]:Y.IDLE,[X.DISPOSE]:Y.DISPOSED},[Y.TRANSITION_STARTED]:{[X.NAVIGATE]:Y.TRANSITION_STARTED,[X.LEAVE_APPROVE]:Y.LEAVE_APPROVED,[X.CANCEL]:Y.READY,[X.FAIL]:Y.READY,[X.DISPOSE]:Y.DISPOSED},[Y.LEAVE_APPROVED]:{[X.NAVIGATE]:Y.TRANSITION_STARTED,[X.COMPLETE]:Y.READY,[X.CANCEL]:Y.READY,[X.FAIL]:Y.READY,[X.DISPOSE]:Y.DISPOSED},[Y.DISPOSED]:{}}};function Xr(){return new Jr(Yr)}const Z=`TREE_CHANGED`;function Q(e){return e instanceof Error?e:Error(String(e))}function Zr(e,t,n){return new Promise((r,i)=>{let a=()=>{let e=n.reason;i(e instanceof q&&e.code===f.TRANSITION_CANCELLED?e:new q(f.TRANSITION_CANCELLED,{reason:e}))};if(n.aborted){a();return}n.addEventListener(`abort`,a,{once:!0}),Promise.allSettled(e).then(e=>{if(n.removeEventListener(`abort`,a),n.aborted)return;if(t!==void 0){i(Q(t));return}let o=e.find(e=>e.status===`rejected`);if(o!==void 0){i(Q(o.reason));return}r()})})}var Qr=class{#e;#t;#n;#r;#i=[];#a=0;#o;#s;#c;#l;#u;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#n=e.abortController,this.#o=void 0,this.#p()}static validateSubscribeListener(e){if(typeof e!=`function`)throw TypeError(`[router.subscribe] Expected a function. For Observable pattern use observable(router) from @real-router/rx`)}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw TypeError(`[router.subscribeLeave] Expected a function`)}emitRouterStart(){this.#t.emit(g.ROUTER_START)}emitRouterStop(){this.#t.emit(g.ROUTER_STOP)}emitTransitionStart(e,t){this.#a++;try{this.#t.emit(g.TRANSITION_START,e,t)}finally{this.#a--}}emitTransitionSuccess(e,t,n){this.#a++;try{this.#t.emit(g.TRANSITION_SUCCESS,e,t,n)}finally{this.#a--}}emitTransitionError(e,t,n){this.#a++;try{this.#t.emit(g.TRANSITION_ERROR,e,t,n)}finally{this.#a--}}emitTransitionCancel(e,t){this.#a++;try{this.#t.emit(g.TRANSITION_CANCEL,e,t)}finally{this.#a--}}emitTransitionLeaveApprove(e,t){this.#a++;try{this.#t.emit(g.TRANSITION_LEAVE_APPROVE,e,t)}finally{this.#a--}}isProcessing(){return this.#a>0}emitTreeChanged(e){this.#t.emit(Z,e)}isEmittingTreeChanged(){return this.#t.isDispatching(Z)}subscribeTreeChanged(e){if(this.isDisposed())throw new q(f.ROUTER_DISPOSED);return this.#t.on(Z,t=>{e(t)})}treeChangedListenerCount(){return this.#t.listenerCount(Z)}sendStart(){this.#e.send(X.START)}sendStop(){this.#e.send(X.STOP)}sendDispose(){this.#e.send(X.DISPOSE)}sendStarted(){this.#e.send(X.STARTED)}sendNavigate(e,t){this.#o=e,this.#e.send(X.NAVIGATE,{toState:e,fromState:t})}sendComplete(e,t,n={}){this.#e.send(X.COMPLETE,{toState:e,fromState:t,opts:n}),this.#o=void 0}sendLeaveApprove(e,t){this.#e.send(X.LEAVE_APPROVE,{toState:e,fromState:t})}sendFail(e,t,n){this.#s=e,this.#c=t,this.#l=n,this.#e.send(X.FAIL),this.#o=void 0}sendFailSafe(e,t,n){this.isReady()?this.sendFail(e,t,n):this.emitTransitionError(e,t,n)}sendCancel(e,t,n){this.#s=e,this.#c=t,this.#u=n,this.#e.send(X.CANCEL),this.#o=void 0}canBeginTransition(){return this.#e.canSend(X.NAVIGATE)}canStart(){return this.#e.canSend(X.START)}canCancel(){return this.#e.canSend(X.CANCEL)}isActive(){let e=this.#e.getState();return e!==Y.IDLE&&e!==Y.DISPOSED}isDisposed(){return this.#e.getState()===Y.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===Y.TRANSITION_STARTED||e===Y.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===Y.LEAVE_APPROVED}isReady(){return this.#e.getState()===Y.READY}isStarting(){return this.#e.getState()===Y.STARTING}isIdle(){return this.#e.getState()===Y.IDLE}addEventListener(e,t){return this.#d(e,`addEventListener`),this.#t.on(e,t)}subscribe(e){if(this.isDisposed())throw new q(f.ROUTER_DISPOSED);return this.#d(g.TRANSITION_SUCCESS,`subscribe`),this.#t.on(g.TRANSITION_SUCCESS,(t,n)=>e({route:t,previousRoute:n}))}subscribeLeave(e){if(this.isDisposed())throw new q(f.ROUTER_DISPOSED);this.#i.push(e);let t=!1;return()=>{if(t)return;t=!0;let n=this.#i.indexOf(e);n!==-1&&this.#i.splice(n,1)}}hasLeaveListeners(){return this.#i.length>0}hasPreCommitListeners(){return this.#t.listenerCount(g.TRANSITION_START)>0||this.#t.listenerCount(g.TRANSITION_LEAVE_APPROVE)>0}awaitLeaveListeners(e,t,n){if(t===void 0)return;let r=Object.freeze({route:t,nextRoute:e,signal:n}),i,a,o=[...this.#i];this.#a++;try{for(let e of o)try{let t=e(r);t!==void 0&&typeof t.then==`function`&&(i??=[],i.push(t))}catch(e){a===void 0&&(a=e)}}finally{this.#a--}if(i===void 0){if(a!==void 0)throw Q(a);return}return Zr(i,a,n)}clearAll(){this.#t.clearAll(),this.#i.length=0}setLimits(e){this.#t.setLimits(e)}setValidatorAccessor(e){this.#r=e}sendCancelIfPossible(e,t){let n=this.#o;!this.canCancel()||n===void 0||this.sendCancel(n,e,t)}#d(e,t){let n=this.#r?.();n&&n.eventBus.validateCountThresholds(this.#t.listenerCount(e)+1,e,t)}#f(){this.emitTransitionError(this.#s,this.#c,this.#l),this.#s=void 0,this.#c=void 0,this.#l=void 0}#p(){let e=this.#e;e.on(Y.STARTING,X.STARTED,()=>{this.emitRouterStart()}),e.on(Y.READY,X.STOP,()=>{this.emitRouterStop()});let t=e=>{this.emitTransitionStart(e.toState,e.fromState)};e.on(Y.READY,X.NAVIGATE,t),e.on(Y.TRANSITION_STARTED,X.NAVIGATE,t),e.on(Y.LEAVE_APPROVED,X.NAVIGATE,t),e.on(Y.TRANSITION_STARTED,X.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(Y.LEAVE_APPROVED,X.COMPLETE,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let n=()=>{let e=this.#s,t=this.#u;this.#u=void 0,this.#n(t),e!==void 0&&this.emitTransitionCancel(e,this.#c)};e.on(Y.TRANSITION_STARTED,X.CANCEL,n),e.on(Y.LEAVE_APPROVED,X.CANCEL,n),e.on(Y.LEAVE_APPROVED,X.FAIL,()=>{this.#f()}),e.on(Y.STARTING,X.FAIL,()=>{this.#f()}),e.on(Y.READY,X.FAIL,()=>{this.#f()}),e.on(Y.TRANSITION_STARTED,X.FAIL,()=>{this.#f()})}};const $r=new q(f.ROUTER_ALREADY_STARTED);function ei(e){let t=ti(e),n=()=>r(e.router).validator;ni(e),ri(e,n),ii(e,t,n),ai(e),oi(e,t,n),si(e),ci(e),li(e)}function ti(e){let{router:t,dependenciesStore:n}=e,r=e=>n.dependencies[e];return e=>e(t,r)}function ni(e){e.dependenciesStore.limits=e.limits,e.eventBus.setLimits({maxListeners:e.limits.maxListeners,warnListeners:e.limits.warnListeners})}function ri(e,t){e.eventBus.setValidatorAccessor(t)}function ii(e,t,n){let i={logger:r(e.router).logger,compileFactory:t,getValidator:n};e.routeLifecycle.setDependencies(i)}function ai(e){let t={logger:r(e.router).logger,addActivateGuard:(t,n,r)=>{e.routeLifecycle.addCanActivate(t,n,!0,r)},addDeactivateGuard:(t,n,r)=>{e.routeLifecycle.addCanDeactivate(t,n,!0,r)},compileGuard:(t,n)=>e.routeLifecycle.compileGuardFactory(t,n),makeState:(t,n,r,i)=>e.state.makeState(t,n,r,i),getState:()=>e.state.get(),areStatesEqual:(t,n,r)=>e.state.areStatesEqual(t,n,r),getDependency:t=>e.dependenciesStore.dependencies[t],forwardState:(t,n)=>{let i=r(e.router);return i.validator?.routes.validateStateBuilderArgs(t,n,`forwardState`),i.forwardState(t,n)}};e.routes.setDependencies(t),e.routes.setLifecycleNamespace(e.routeLifecycle)}function oi(e,t,n){let i={logger:r(e.router).logger,addEventListener:(t,n)=>e.eventBus.addEventListener(t,n),canNavigate:()=>e.eventBus.canBeginTransition(),compileFactory:t,getValidator:n};e.plugins.setDependencies(i)}function si(e){let t={logger:r(e.router).logger,getOptions:()=>e.options.get(),hasRoute:t=>e.routes.hasRoute(t),getState:()=>e.state.get(),setState:t=>{e.state.set(t)},buildNavigateState:(t,n)=>{let i=r(e.router);i.validator?.routes.validateStateBuilderArgs(t,n,`navigate`);let a=i.forwardState(t,n),o=a.name,s=S(a.params),c=e.routes.getMetaForState(o);if(c===void 0)return;let l=i.buildPath(o,s);return e.state.makeState(o,s,l,c,!0)},resolveDefault:()=>{let t=e.options.get(),n=r(e.router),i=rn(t.defaultRoute,t=>e.dependenciesStore.dependencies[t]),a=rn(t.defaultParams,t=>e.dependenciesStore.dependencies[t]);return typeof t.defaultRoute==`function`&&n.validator?.options.validateResolvedDefaultRoute(i,n.routeGetStore()),{route:i,params:a}},startTransition:(t,n)=>{e.eventBus.sendNavigate(t,n)},cancelNavigation:t=>{e.eventBus.sendCancelIfPossible(e.state.get(),t)},sendTransitionDone:(t,n,r)=>{e.eventBus.sendComplete(t,n,r)},sendTransitionFail:(t,n,r)=>{e.eventBus.sendFail(t,n,r)},emitTransitionError:(t,n,r)=>{e.eventBus.sendFailSafe(t,n,r)},emitTransitionSuccess:(t,n,r)=>{e.eventBus.emitTransitionSuccess(t,n,r)},sendLeaveApprove:(t,n)=>{e.eventBus.sendLeaveApprove(t,n)},canNavigate:()=>e.eventBus.canBeginTransition(),getLifecycleFunctions:()=>e.routeLifecycle.getFunctions(),isActive:()=>e.router.isActive(),isTransitioning:()=>e.eventBus.isTransitioning(),clearCanDeactivate:t=>{e.routeLifecycle.clearCanDeactivate(t,`external`)},hasLeaveListeners:()=>e.eventBus.hasLeaveListeners(),hasPreCommitListeners:()=>e.eventBus.hasPreCommitListeners(),awaitLeaveListeners:(t,n,r)=>e.eventBus.awaitLeaveListeners(t,n,r)};e.navigation.setDependencies(t)}function ci(e){e.lifecycle.setDependencies({getOptions:()=>e.options.get(),navigateToState:(t,n)=>e.navigation.navigateToState(t,n),navigateToNotFound:t=>e.navigation.navigateToNotFound(t),clearState:()=>{e.state.set(void 0)},matchPath:t=>e.routes.matchPath(t,e.options.get()),completeStart:()=>{e.eventBus.sendStarted()},isIdle:()=>e.eventBus.isIdle(),emitTransitionError:(t,n,r)=>{e.eventBus.sendFail(t,n,r)}})}function li(e){e.state.setDependencies({getDefaultParams:()=>e.routes.getStore().config.defaultParams,buildPath:(t,n)=>r(e.router).buildPath(t,n),getUrlParams:t=>e.routes.getUrlParams(t)})}const ui=Object.freeze({}),di=new Set([f.SAME_STATES,f.TRANSITION_CANCELLED,f.ROUTER_NOT_STARTED,f.ROUTE_NOT_FOUND,f.CANNOT_ACTIVATE,f.CANNOT_DEACTIVATE]);var fi=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(t=[],r={},i={}){let{logger:a,...o}=r;a&&le(a);let s=new ie(a);this.#u=t=>{e.#f(t)||s.error(`router.navigate`,`Unexpected navigation error`,t)},this.#d=t=>{e.#f(t)||s.error(`router.start`,`Unexpected start error`,t)},on.validateOptionsIsObject(r),ae(i),t.length>0&&x(t),this.#e=new on(o),this.#t=de(o.limits),this.#n=fe(i),this.#r=new ln,this.#i=new _r(t,pi(this.#e.get()),s),this.#a=new yn,this.#o=new pn,this.#s=new Wr,this.#c=new Kr;let l=Xr(),u=new ne({onListenerError:(e,t)=>{s.error(`Router`,`Error in listener for ${e}:`,t)},onListenerWarn:(e,t)=>{s.warn(`router.addEventListener`,`Event "${e}" has ${t} listeners — possible memory leak`)}});this.#l=new Qr({routerFSM:l,emitter:u,abortController:e=>{this.#s.abortCurrentController(e)}});let f=new Map;c(this,{logger:s,makeState:(e,t,n,r)=>this.#r.makeState(e,t,n,r),forwardState:d(`forwardState`,(e,t)=>this.#i.forwardState(e,t),f),buildStateResolved:(e,t)=>this.#i.buildStateResolved(e,t),matchPath:(e,t)=>this.#i.matchPath(e,t),getOptions:()=>this.#e.get(),addEventListener:(e,t)=>this.#l.addEventListener(e,t),treeChanged:{emit:e=>{this.#l.emitTreeChanged(e)},subscribe:e=>this.#l.subscribeTreeChanged(e),listenerCount:()=>this.#l.treeChangedListenerCount(),isEmitting:()=>this.#l.isEmittingTreeChanged()},buildPath:d(`buildPath`,(e,t)=>this.#i.buildPath(e,t??v,this.#e.get()),f),emitTransitionError:e=>{this.#l.sendFailSafe(void 0,this.#r.get(),e)},emitTransitionSuccess:(e,t,n)=>{this.#l.emitTransitionSuccess(e,t,n)},navigateToNotFound:e=>this.#s.navigateToNotFound(e),start:n(`start`,e=>this.#c.start(e),f),navigateToState:(e,t)=>{this.#m();let n=this.#s.navigateToState(e,t??ui);return this.#s.lastSyncResolved?this.#s.lastSyncResolved=!1:this.#s.lastSyncRejected?this.#s.lastSyncRejected=!1:this.#p(n),n},interceptors:f,setRootPath:e=>{this.#i.setRootPath(e)},getRootPath:()=>this.#i.getStore().rootPath,getTree:()=>this.#i.getStore().tree,isDisposed:()=>this.#l.isDisposed(),validator:null,dependenciesGetStore:()=>this.#n,getCloneState:()=>({options:{...this.#e.get()},dependencies:{...this.#n.dependencies},pluginFactories:this.#o.getAll(),loggerConfig:s.getConfig()}),routeGetStore:()=>this.#i.getStore(),getStateName:()=>this.#r.get()?.name,isTransitioning:()=>this.#l.isTransitioning(),clearState:()=>{this.#r.set(void 0)},setState:e=>{this.#r.set(e)},routerExtensions:[],contextClaimRecords:new Set,hydrationState:null}),ei({router:this,options:this.#e,limits:this.#t,dependenciesStore:this.#n,state:this.#r,routes:this.#i,routeLifecycle:this.#a,plugins:this.#o,navigation:this.#s,lifecycle:this.#c,eventBus:this.#l}),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeLeave=this.subscribeLeave.bind(this),this.isLeaveApproved=this.isLeaveApproved.bind(this);try{this.#i.flushPendingGuards()}catch(e){throw this.dispose(),e}}isActiveRoute(e,t,n,i){return r(this).validator?.routes.validateIsActiveRouteArgs(e,t,n,i),r(this).validator?.routes.validateRouteName(e,`isActiveRoute`),e===``?(r(this).logger.warn(`real-router`,`isActiveRoute("") called with empty string. Root node is not considered a parent of any route.`),!1):this.#i.isActiveRoute(e,t,n,i)}buildPath(e,t){let n=r(this);return n.validator?.routes.validateBuildPathArgs(e),n.validator?.navigation.validateParams(t,`buildPath`),n.buildPath(e,S(t))}getState(){return this.#r.get()}getPreviousState(){return this.#r.getPrevious()}areStatesEqual(e,t,n=!0){return r(this).validator?.state.validateAreStatesEqualArgs(e,t,n),this.#r.areStatesEqual(e,t,n)}shouldUpdateNode(e){return r(this).validator?.routes.validateShouldUpdateNodeArgs(e),_r.shouldUpdateNode(e)}isActive(){return this.#l.isActive()}start(e){if(!this.#l.canStart())return Promise.reject($r);r(this).validator?.navigation.validateStartArgs(e),this.#l.sendStart();let t;try{let n=r(this).start(e);t=typeof n?.then==`function`?n:Promise.reject(TypeError("[router.start] a `start` interceptor returned without calling next(). Every start interceptor must return `next(path)`."))}catch(e){t=Promise.reject(e)}let n=t.catch(e=>this.#h(e));return this.#p(n,this.#d),n}stop(){return this.#l.sendCancelIfPossible(this.#r.get()),!this.#l.isReady()&&!this.#l.isTransitioning()&&!this.#l.isStarting()?this:(this.#c.stop(),this.#l.sendStop(),this)}dispose(){if(this.#l.isDisposed())return;this.#l.sendCancelIfPossible(this.#r.get()),(this.#l.isReady()||this.#l.isTransitioning())&&(this.#c.stop(),this.#l.sendStop()),this.#l.sendDispose(),this.#l.clearAll(),this.#o.disposeAll();let e=r(this);for(let t of e.routerExtensions)for(let e of t.keys)delete this[e];e.routerExtensions.length=0,e.contextClaimRecords.clear(),e.interceptors.clear(),this.#i.clearRoutes(),this.#a.clearAll(),this.#r.reset(),this.#n.dependencies=Object.create(null),this.#g()}canNavigateTo(e,t){let n=r(this);if(n.validator?.routes.validateRouteName(e,`canNavigateTo`),n.validator?.navigation.validateParams(t,`canNavigateTo`),!this.#i.hasRoute(e))return!1;let{name:i,params:a}=n.forwardState(e,t??{}),o;try{let e=S(a),t=this.#i.getMetaForState(i),r=n.buildPath(i,e);o=this.#r.makeState(i,e,r,t,!0)}catch{return!1}let s=this.#r.get(),{toDeactivate:c,toActivate:l}=K(o,s);return this.#a.canNavigateTo(c,l,o,s)}usePlugin(...e){if(this.#l.isDisposed())throw new q(f.ROUTER_DISPOSED);let t=e.filter(Boolean);if(t.length===0)return()=>{};let n=r(this);n.validator?.plugins.validatePluginLimit(this.#o.count(),this.#t);for(let e of t)n.validator?.plugins.validateNoDuplicatePlugins(e,this.#o.getAll());return this.#o.use(...t)}subscribe(e){return Qr.validateSubscribeListener(e),this.#l.subscribe(e)}subscribeLeave(e){return Qr.validateSubscribeLeaveListener(e),this.#l.subscribeLeave(e)}isLeaveApproved(){return this.#l.isLeaveApproved()}navigate(e,t,n){this.#m();let i=r(this);i.validator?.navigation.validateNavigateArgs(e),i.validator?.navigation.validateParams(t,`navigate`);let a=n??ui;i.validator?.navigation.validateNavigationOptions(a,`navigate`);let o=this.#s.navigate(e,t??v,a);return this.#s.lastSyncResolved?this.#s.lastSyncResolved=!1:this.#s.lastSyncRejected?this.#s.lastSyncRejected=!1:this.#p(o),o}navigateToDefault(e){this.#m();let t=r(this);t.validator?.navigation.validateNavigateToDefaultArgs(e);let n=e??ui;t.validator?.navigation.validateNavigationOptions(n,`navigateToDefault`);let i=this.#s.navigateToDefault(n);return this.#s.lastSyncResolved?this.#s.lastSyncResolved=!1:this.#s.lastSyncRejected?this.#s.lastSyncRejected=!1:this.#p(i),i}navigateToNotFound(e){if(this.#m(),!this.#l.isActive())throw new q(f.ROUTER_NOT_STARTED);if(e!==void 0&&typeof e!=`string`)throw TypeError(`[router.navigateToNotFound] path must be a string, got ${typeof e}`);if(e!==void 0)return this.#s.navigateToNotFound(e);let t=this.#r.get();if(t===void 0)throw new q(f.ROUTER_NOT_STARTED,{message:`[router.navigateToNotFound] cannot derive the path before the start navigation commits — pass an explicit path`});return this.#s.navigateToNotFound(t.path)}static#f(e){return e instanceof q&&di.has(e.code)}#p(e,t=this.#u){e.catch(t)}#m(){if(this.#l.isProcessing())throw new q(f.REENTRANT_NAVIGATION)}#h(e){throw this.#l.isReady()&&this.#r.get()===void 0?(this.#c.stop(),this.#l.sendStop()):this.#l.isStarting()&&this.#l.sendFail(void 0,void 0,e),e}#g(){this.navigate=$,this.navigateToDefault=$,this.navigateToNotFound=$,this.start=$,this.stop=$,this.usePlugin=$,this.subscribe=$,this.subscribeLeave=$,this.canNavigateTo=$}};function $(){throw new q(f.ROUTER_DISPOSED)}function pi(e){return{strictTrailingSlash:e.trailingSlash===`strict`,caseSensitive:e.caseSensitive,strictQueryParams:e.queryParamsMode===`strict`,urlParamsEncoding:e.urlParamsEncoding,queryParams:e.queryParams}}export{p as C,g as E,x as S,f as T,xn as _,Un as a,O as b,H as c,Kn as d,Xn as f,kn as g,Mn as h,Yn as i,Vn as l,Jn as m,q as n,V as o,jn as p,K as r,Hn as s,fi as t,Gn as u,Dn as v,m as w,jt as x,En as y};
|
|
2
|
-
//# sourceMappingURL=Router-De0Gr9Ll.mjs.map
|