@real-router/core 0.169.0 → 0.170.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Router-COzfk9Vd.js → Router-CVlGn_WA.js} +2 -2
- package/dist/cjs/Router-CVlGn_WA.js.map +1 -0
- package/dist/cjs/Router.d.ts.map +1 -1
- package/dist/cjs/api/cloneRouter.d.ts +1 -0
- package/dist/cjs/api/cloneRouter.d.ts.map +1 -1
- package/dist/cjs/api/getDependenciesApi.d.ts +2 -0
- package/dist/cjs/api/getDependenciesApi.d.ts.map +1 -1
- package/dist/cjs/api/getLifecycleApi.d.ts +2 -0
- package/dist/cjs/api/getLifecycleApi.d.ts.map +1 -1
- package/dist/cjs/api/getPluginApi.d.ts +1 -0
- package/dist/cjs/api/getPluginApi.d.ts.map +1 -1
- package/dist/cjs/api/getRoutesApi.d.ts +2 -0
- package/dist/cjs/api/getRoutesApi.d.ts.map +1 -1
- package/dist/cjs/api/types.d.ts +3 -1
- package/dist/cjs/api/types.d.ts.map +1 -1
- package/dist/cjs/api.d.ts +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/channels/defaults.d.ts +1 -0
- package/dist/cjs/channels/guard.d.ts +1 -0
- package/dist/cjs/channels/guard.d.ts.map +1 -1
- package/dist/cjs/channels/index.d.ts +23 -0
- package/dist/cjs/channels/modeGate.d.ts +1 -0
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/createRouter.d.ts +1 -0
- package/dist/cjs/createRouter.d.ts.map +1 -1
- package/dist/cjs/dependenciesStore.d.ts +1 -0
- package/dist/cjs/dependenciesStore.d.ts.map +1 -1
- package/dist/cjs/engine/builder/createRouteTree.d.ts +8 -0
- package/dist/cjs/engine/builder/index.d.ts +8 -0
- package/dist/cjs/engine/builder/types.d.ts +8 -0
- package/dist/cjs/engine/builder/types.d.ts.map +1 -1
- package/dist/cjs/engine/createMatcher.d.ts +12 -1
- package/dist/cjs/engine/createMatcher.d.ts.map +1 -1
- package/dist/cjs/engine/index.d.ts +20 -0
- package/dist/cjs/engine/operations/query.d.ts +8 -0
- package/dist/cjs/engine/operations/routeTreeToDefinitions.d.ts +9 -0
- package/dist/cjs/engine/operations/types.d.ts +8 -0
- package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts +1 -0
- package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts.map +1 -1
- package/dist/cjs/engine/path-matcher/buildParamMeta.d.ts +8 -0
- package/dist/cjs/engine/path-matcher/buildParamMeta.d.ts.map +1 -1
- package/dist/cjs/engine/path-matcher/index.d.ts +5 -0
- package/dist/cjs/engine/path-matcher/parseSegment.d.ts +1 -0
- package/dist/cjs/engine/path-matcher/pathUtils.d.ts +1 -0
- package/dist/cjs/engine/search-params/encode.d.ts +10 -0
- package/dist/cjs/engine/search-params/index.d.ts +11 -0
- package/dist/cjs/engine/search-params/searchParams.d.ts +10 -0
- package/dist/cjs/engine/search-params/strategies/array.d.ts +7 -0
- package/dist/cjs/engine/search-params/strategies/boolean.d.ts +6 -0
- package/dist/cjs/engine/search-params/strategies/index.d.ts +14 -0
- package/dist/cjs/engine/search-params/strategies/null.d.ts +9 -0
- package/dist/cjs/engine/search-params/strategies/number.d.ts +6 -0
- package/dist/cjs/engine/types.d.ts +12 -0
- package/dist/cjs/engine/validation/route-batch.d.ts +7 -0
- package/dist/cjs/engine/validation/route-batch.d.ts.map +1 -1
- package/dist/cjs/engine/validation/route-name.d.ts +1 -0
- package/dist/cjs/getNavigator.d.ts +1 -0
- package/dist/cjs/getNavigator.d.ts.map +1 -1
- package/dist/cjs/{helpers-CfUevk4y.js → helpers-BCSkINAR.js} +1 -1
- package/dist/cjs/helpers-BCSkINAR.js.map +1 -0
- package/dist/cjs/helpers.d.ts +1 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals-2KakrCBP.js +2 -0
- package/dist/cjs/internals-2KakrCBP.js.map +1 -0
- package/dist/cjs/internals.d.ts +9 -10
- package/dist/cjs/internals.d.ts.map +1 -1
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts +1 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts.map +1 -1
- package/dist/cjs/namespaces/RouteLifecycleNamespace/index.d.ts +3 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts +1 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts.map +1 -1
- package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.d.ts +7 -0
- package/dist/cjs/namespaces/RoutesNamespace/index.d.ts +4 -0
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts +5 -2
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts.map +1 -1
- package/dist/cjs/namespaces/RoutesNamespace/types.d.ts +3 -1
- package/dist/cjs/namespaces/RoutesNamespace/types.d.ts.map +1 -1
- package/dist/cjs/pipeline/buildURL.d.ts +2 -0
- package/dist/cjs/pipeline/canonicalize.d.ts +3 -0
- package/dist/cjs/pipeline/index.d.ts +22 -0
- package/dist/cjs/pipeline/materialize.d.ts +2 -0
- package/dist/cjs/pipeline/port.d.ts +1 -0
- package/dist/cjs/pipeline/port.d.ts.map +1 -1
- package/dist/cjs/pipeline/types.d.ts +1 -0
- package/dist/cjs/transitionPath.d.ts +1 -0
- package/dist/cjs/types/api.d.ts +7 -5
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/internal.d.ts +17 -0
- package/dist/cjs/types/internal.d.ts.map +1 -1
- package/dist/cjs/types/route-node-types.d.ts +13 -0
- package/dist/cjs/types/route-node-types.d.ts.map +1 -1
- package/dist/cjs/types/router.d.ts +9 -2
- package/dist/cjs/types/router.d.ts.map +1 -1
- package/dist/cjs/types/tree-changed.d.ts +11 -0
- package/dist/cjs/types/tree-changed.d.ts.map +1 -1
- package/dist/cjs/types.d.ts +2 -2
- package/dist/cjs/utils.d.ts +53 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.d.ts +14 -3
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/Router-BTlEfQMO.mjs +2 -0
- package/dist/esm/Router-BTlEfQMO.mjs.map +1 -0
- package/dist/esm/Router.d.mts.map +1 -1
- package/dist/esm/api/cloneRouter.d.mts +1 -0
- package/dist/esm/api/cloneRouter.d.mts.map +1 -1
- package/dist/esm/api/getDependenciesApi.d.mts +2 -0
- package/dist/esm/api/getDependenciesApi.d.mts.map +1 -1
- package/dist/esm/api/getLifecycleApi.d.mts +2 -0
- package/dist/esm/api/getLifecycleApi.d.mts.map +1 -1
- package/dist/esm/api/getPluginApi.d.mts +1 -0
- package/dist/esm/api/getPluginApi.d.mts.map +1 -1
- package/dist/esm/api/getRoutesApi.d.mts +2 -0
- package/dist/esm/api/getRoutesApi.d.mts.map +1 -1
- package/dist/esm/api/types.d.mts +3 -1
- package/dist/esm/api/types.d.mts.map +1 -1
- package/dist/esm/api.d.mts +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/channels/defaults.d.mts +1 -0
- package/dist/esm/channels/guard.d.mts +1 -0
- package/dist/esm/channels/guard.d.mts.map +1 -1
- package/dist/esm/channels/index.d.mts +23 -0
- package/dist/esm/channels/modeGate.d.mts +1 -0
- package/dist/esm/constants.d.mts +1 -0
- package/dist/esm/constants.d.mts.map +1 -1
- package/dist/esm/createRouter.d.mts +1 -0
- package/dist/esm/createRouter.d.mts.map +1 -1
- package/dist/esm/dependenciesStore.d.mts +1 -0
- package/dist/esm/dependenciesStore.d.mts.map +1 -1
- package/dist/esm/engine/builder/createRouteTree.d.mts +8 -0
- package/dist/esm/engine/builder/index.d.mts +8 -0
- package/dist/esm/engine/builder/types.d.mts +8 -0
- package/dist/esm/engine/builder/types.d.mts.map +1 -1
- package/dist/esm/engine/createMatcher.d.mts +12 -1
- package/dist/esm/engine/createMatcher.d.mts.map +1 -1
- package/dist/esm/engine/index.d.mts +20 -0
- package/dist/esm/engine/operations/query.d.mts +8 -0
- package/dist/esm/engine/operations/routeTreeToDefinitions.d.mts +9 -0
- package/dist/esm/engine/operations/types.d.mts +8 -0
- package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts +1 -0
- package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts.map +1 -1
- package/dist/esm/engine/path-matcher/buildParamMeta.d.mts +8 -0
- package/dist/esm/engine/path-matcher/buildParamMeta.d.mts.map +1 -1
- package/dist/esm/engine/path-matcher/index.d.mts +5 -0
- package/dist/esm/engine/path-matcher/parseSegment.d.mts +1 -0
- package/dist/esm/engine/path-matcher/pathUtils.d.mts +1 -0
- package/dist/esm/engine/search-params/encode.d.mts +10 -0
- package/dist/esm/engine/search-params/index.d.mts +11 -0
- package/dist/esm/engine/search-params/searchParams.d.mts +10 -0
- package/dist/esm/engine/search-params/strategies/array.d.mts +7 -0
- package/dist/esm/engine/search-params/strategies/boolean.d.mts +6 -0
- package/dist/esm/engine/search-params/strategies/index.d.mts +14 -0
- package/dist/esm/engine/search-params/strategies/null.d.mts +9 -0
- package/dist/esm/engine/search-params/strategies/number.d.mts +6 -0
- package/dist/esm/engine/types.d.mts +12 -0
- package/dist/esm/engine/validation/route-batch.d.mts +7 -0
- package/dist/esm/engine/validation/route-batch.d.mts.map +1 -1
- package/dist/esm/engine/validation/route-name.d.mts +1 -0
- package/dist/esm/getNavigator.d.mts +1 -0
- package/dist/esm/getNavigator.d.mts.map +1 -1
- package/dist/esm/{helpers-BFYPM3MT.mjs → helpers-LeSZEDaV.mjs} +1 -1
- package/dist/esm/helpers-LeSZEDaV.mjs.map +1 -0
- package/dist/esm/helpers.d.mts +1 -0
- package/dist/esm/helpers.d.mts.map +1 -1
- package/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/{internals-CATE9FGw.mjs → internals-D17AclZw.mjs} +2 -2
- package/dist/esm/internals-D17AclZw.mjs.map +1 -0
- package/dist/esm/internals.d.mts +9 -10
- package/dist/esm/internals.d.mts.map +1 -1
- package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts +1 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts.map +1 -1
- package/dist/esm/namespaces/RouteLifecycleNamespace/index.d.mts +3 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts +1 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts.map +1 -1
- package/dist/esm/namespaces/RoutesNamespace/RoutesNamespace.d.mts +7 -0
- package/dist/esm/namespaces/RoutesNamespace/index.d.mts +4 -0
- package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts +5 -2
- package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts.map +1 -1
- package/dist/esm/namespaces/RoutesNamespace/types.d.mts +3 -1
- package/dist/esm/namespaces/RoutesNamespace/types.d.mts.map +1 -1
- package/dist/esm/pipeline/buildURL.d.mts +2 -0
- package/dist/esm/pipeline/canonicalize.d.mts +3 -0
- package/dist/esm/pipeline/index.d.mts +22 -0
- package/dist/esm/pipeline/materialize.d.mts +2 -0
- package/dist/esm/pipeline/port.d.mts +1 -0
- package/dist/esm/pipeline/port.d.mts.map +1 -1
- package/dist/esm/pipeline/types.d.mts +1 -0
- package/dist/esm/transitionPath.d.mts +1 -0
- package/dist/esm/types/api.d.mts +7 -5
- package/dist/esm/types/api.d.mts.map +1 -1
- package/dist/esm/types/internal.d.mts +17 -0
- package/dist/esm/types/internal.d.mts.map +1 -1
- package/dist/esm/types/route-node-types.d.mts +13 -0
- package/dist/esm/types/route-node-types.d.mts.map +1 -1
- package/dist/esm/types/router.d.mts +9 -2
- package/dist/esm/types/router.d.mts.map +1 -1
- package/dist/esm/types/tree-changed.d.mts +11 -0
- package/dist/esm/types/tree-changed.d.mts.map +1 -1
- package/dist/esm/types.d.mts +2 -2
- package/dist/esm/utils.d.mts +53 -1
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.d.mts +14 -3
- package/dist/esm/validation.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-COzfk9Vd.js.map +0 -1
- package/dist/cjs/helpers-CfUevk4y.js.map +0 -1
- package/dist/cjs/internals-C-m8EvAR.js +0 -2
- package/dist/cjs/internals-C-m8EvAR.js.map +0 -1
- package/dist/cjs/types/RouterValidator.d.ts +0 -11
- package/dist/cjs/types/RouterValidator.d.ts.map +0 -1
- package/dist/esm/Router-BT91vH4Q.mjs +0 -2
- package/dist/esm/Router-BT91vH4Q.mjs.map +0 -1
- package/dist/esm/helpers-BFYPM3MT.mjs.map +0 -1
- package/dist/esm/internals-CATE9FGw.mjs.map +0 -1
- package/dist/esm/types/RouterValidator.d.mts +0 -11
- package/dist/esm/types/RouterValidator.d.mts.map +0 -1
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Router types and interfaces.
|
|
3
|
+
*
|
|
4
|
+
* Factory types (PluginFactory, GuardFnFactory) and
|
|
5
|
+
* route config types (Route, RouteConfigUpdate) use self-referencing Router<D>
|
|
6
|
+
* within this single file to resolve circular dependencies.
|
|
7
|
+
*/
|
|
2
8
|
import { NavigationTarget, Params, ParamsSearch, RouterError, SearchParams, State, Unsubscribe, UrlChannels } from "./base.js";
|
|
3
|
-
import { LimitsConfig } from "./limits.js";
|
|
4
9
|
import { NavigationOptions } from "../types.js";
|
|
10
|
+
import { LimitsConfig } from "./limits.js";
|
|
11
|
+
import { QueryParamsMode, QueryParamsOptions } from "./route-node-types.js";
|
|
5
12
|
export type LogLevel = "log" | "warn" | "error";
|
|
6
13
|
export type LogLevelConfig = "all" | "warn-error" | "error-only" | "none";
|
|
7
14
|
export type LogCallback = (level: LogLevel, context: string, message: string, ...args: unknown[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","names":[],"sources":["../../../src/types/router.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","names":[],"sources":["../../../src/types/router.ts"],"mappings":";;;;;;;;;;;YA6BY;YAEA;YAEA,eACV,OAAO,UACP,iBACA,oBACG;iBAGY;EACf,OAAO;EACP,WAAW;EACX;;;;;;;;;;;;;iBAce;EACf,MAAM,iBAAiB,oBAAoB;EAC3C,OAAO,iBAAiB,oBAAoB;EAC5C,QAAQ,iBAAiB,oBAAoB;;;;;;YAOnC,qBAAqB,0BAC/B,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa;;;;;YAO7D,kBAAkB,0BAC5B,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa,IACvE,QAAQ;;;;;YAOE,sBAAsB,0BAChC,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa,OACpE;;;;;YAMO,sBAAsB,0BAChC,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa,OACpE;;;;;;;iBAQY;WACN,gBAAgB;WAChB,gBAAgB;;;;;;;;;;;;;;iBAeV,QACf,qBAAqB,sBAAsB;;;;;;;EAQ3C,uBAAuB,qBAAqB;;;;;;;;;;;;;EAc5C,eAAe,SAAS,sBAAsB;;;;;;;;;;;;;;;;EAiB9C,eAAe,eAAe,sBAAsB;;;;;;;;;;;;;EAcpD;;;;;;;;;;;;;;;;;;EAmBA;;;;;;;;;;EAWA;;;;;;EAOA,iBAAiB;;;;;;;;;;;EAYjB,cAAc;;;;;;;EAQd;;;;;;;;;;EAWA;;;;;;EAOA,SAAS,QAAQ;;;;;;;EAQjB,SAAS,QAAQ;;;;;;;;;;;;;;;;YAiBP,aAAa;YAEb,WACV,SAAS,OACT,WAAW,mBACX,SAAS,0BACI;YAEH;iBAEK;EACf;EACA;EACA,qBAAqB,SAAS,OAAO,YAAY;EACjD,4BAA4B,SAAS,OAAO,YAAY;EACxD,sBAAsB,SAAS,OAAO,YAAY;;;;;;;;EAQlD,qBACE,SAAS,mBACT,WAAW,mBACX,KAAK;EAEP,uBACE,SAAS,OACT,WAAW,mBACX,MAAM;;;;;EAMR;;iBAGe;EACf,OAAO;EACP,gBAAgB;;YAGN,eAAe,OAAO;iBAEjB;EACf,OAAO;EACP,WAAW;EACX,QAAQ;;YAGE,WAAW,OAAO,sBAAsB;iBAEnC;GACd;EACD,OAAO;EACP,SAAS;EACT;;iBAGe;EACf,aAAa;;;;;;;;;;;iBAYE;EAGf;KACG,QAAQ,kBAAkB,UAAU,oBAAoB,QAAQ;KAE/D,mBACA,cAAc,QACd,cAAc,cACd,UAAU,oBACT,QAAQ;;EAEb,gBAAgB;EAChB,gBACE,cACA,SAAS,QACT,SAAS,cACT,0BACA;EAEF,gBACE,cACA,SAAS,QACT,SAAS;EAEX,YAAY,UAAU,gBAAgB;EACtC,iBAAiB,UAAU,YAAY;EACvC;;;;;;;;;iBAUe,OAAO,UAAU,sBAAsB;GAGrD;EAED,gBACE,cACA,SAAS,QACT,SAAS,cACT,0BACA;EAGF,YAAY,eAAe,SAAS,QAAQ,SAAS;EAErD,WAAW,UAAU,SAAS,aAAa,MAAM;EAEjD,wBAAwB;EAExB,iBACE,QAAQ,mBACR,QAAQ,mBACR;EAGF,mBACE,sBACI,SAAS,OAAO,YAAY;EAElC;EAEA,QAAQ,sBAAsB,QAAQ;EAEtC;EAEA;EAEA,gBACE,cACA,SAAS,QACT,SAAS;EAGX,eACK,UAAU,cAAc,qCACxB;EAEL,YAAY,UAAU,gBAAgB;EAEtC,iBAAiB,UAAU,YAAY;EAEvC;EAIA;KACG,QAAQ,kBAAkB,UAAU,oBAAoB,QAAQ;KAE/D,mBACA,cAAc,QACd,cAAc,cACd,UAAU,oBACT,QAAQ;;EAGb,oBAAoB,UAAU,sBAAsB,QAAQ;EAE5D,qBAAqB,kBAAkB;;;;;;YAW7B,cACV,qBAAqB,sBAAsB,wBAE3C,QAAQ,OAAO,eACf,gBAAgB,gBAAgB,cAAc,KAAK,MAAM,aAAa,OACnE;;;;;YAMO,eACV,qBAAqB,sBAAsB,wBAE3C,QAAQ,OAAO,eACf,gBAAgB,gBAAgB,cAAc,KAAK,MAAM,aAAa,OACnE;;;;iBASY,MACf,qBAAqB,sBAAsB;GAE1C;;EAED;;EAEA;;EAEA,cAAc,eAAe;;EAE7B,gBAAgB,eAAe;;;;;;;;;;EAU/B,qBAAqB,kBAAkB;;EAEvC,WAAW,MAAM;;;;;;;;EAQjB,gBAAgB,UAAU,iBAAiB;;;;;;;;;;;;;;;;;EAiB3C,gBAAgB,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;EAkB1C,gBAAgB;;;;;;;;;EAShB,gBAAgB;;;;;;;;;KAUb,aAAa,KAAK,eAAc,6BACjC,IACA,+BACc,aAAa,IAAI,aAAa,EAAE,WAC5C;;;;;;;;;;;;;;YAeM,cACV,qBAAqB,sBAAsB,uBACzC,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BN,kBACf,qBAAqB,sBAAsB;;EAG3C,qBAAqB,kBAAkB;;EAEvC,gBAAgB;;EAEhB,gBAAgB;;EAEhB,iBAAiB,UAAU,gBAAgB;;EAE3C,iBAAiB,UAAU,iBAAiB;;EAE5C,cAAc,eAAe;;EAE7B,gBAAgB,eAAe"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload types for the internal `TREE_CHANGED` event — the post-commit,
|
|
3
|
+
* fire-and-forget signal emitted after a structural route-tree mutation through
|
|
4
|
+
* `getRoutesApi(router)`.
|
|
5
|
+
*
|
|
6
|
+
* The event is observed via `getRoutesApi(router).subscribeChanges(handler)`.
|
|
7
|
+
* It is intentionally NOT part of the public `EventName` union, `Plugin`
|
|
8
|
+
* interface, or `events.*` registry: tree mutations are an infrastructural
|
|
9
|
+
* concern (DevTools, microfrontends, plugin coordination), not an app-level
|
|
10
|
+
* event. See `.claude/rfc-tree-mutation-event.md` for the full rationale.
|
|
11
|
+
*/
|
|
1
12
|
import { DefaultDependencies, ReadonlyRoute, RouteConfigUpdate } from "./router.js";
|
|
2
13
|
/**
|
|
3
14
|
* The subset of {@link RouteConfigUpdate} fields that count as **structural**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-changed.d.ts","names":[],"sources":["../../../src/types/tree-changed.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tree-changed.d.ts","names":[],"sources":["../../../src/types/tree-changed.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;YA0BY,oBACV,qBAAqB,sBAAsB,uBACzC,KACF,kBAAkB;iBAQH,eACf,qBAAqB,sBAAsB;WAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgCA,gBAAgB,cAAc;;WAE9B;;iBAGM,kBACf,qBAAqB,sBAAsB;WAElC;WACA;;;;;;;;;;;;WAYA,yBAAyB,cAAc;;iBAGjC,kBACf,qBAAqB,sBAAsB;WAElC;WACA;;;;;;;;;;;WAWA,OAAO,SAAS,oBAAoB;;iBAG9B,mBACf,qBAAqB,sBAAsB;WAElC;;;;;;;;WAQA,kBAAkB,cAAc;;;;;;;;WAQhC,gBAAgB,cAAc;;iBAGxB,iBACf,qBAAqB,sBAAsB;WAElC;;;;;;;;;;WAUA,kBAAkB,cAAc;;iBAG1B;WACN;;WAEA;;WAEA;;;;;;;;;;;;;;;;YAiBC,iBACV,qBAAqB,sBAAsB,uBAEzC,eAAe,gBACf,kBAAkB,gBAClB,kBAAkB,gBAClB,mBAAmB,gBACnB,sBACA,iBAAiB"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState } from "./types/route-node-types.js";
|
|
2
2
|
import { NavigationTarget, ParamValue, Params, ParamsSearch, RouterError, SearchParamPrimitive, SearchParamValue, SearchParams, SerializedRouterState, SimpleState, State, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe, UrlChannels } from "./types/base.js";
|
|
3
|
-
import { LimitsConfig } from "./types/limits.js";
|
|
4
3
|
import { AdoptedOrigins, AnyOptions, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, DefaultSearchCallback, ForwardToCallback, GuardFn, GuardFnFactory, LeaveFn, LeaveState, Listener, LogCallback, LogLevel, LogLevelConfig, LoggerConfig, Navigator, Options, Plugin, PluginFactory, ReadonlyRoute, Route, RouteConfigUpdate, Router, RouterLogger, SubscribeFn, SubscribeState, Subscription } from "./types/router.js";
|
|
4
|
+
import { LimitsConfig } from "./types/limits.js";
|
|
5
5
|
import { ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventMethodMap, EventName, EventToNameMap, EventToPluginMap, EventsKeys, PluginMethod } from "./types/constants.js";
|
|
6
|
-
import { TreeChangedAdd, TreeChangedClear, TreeChangedEvent, TreeChangedRemove, TreeChangedReplace, TreeChangedUpdate, TreeStructuralPatch } from "./types/tree-changed.js";
|
|
7
6
|
import { CheckFn, CheckPositionMap, ContextNamespaceClaim, DependenciesApi, DiagnosticEventMap, InterceptableMethodMap, InterceptorFn, LifecycleApi, PluginApi, RoutesApi } from "./types/api.js";
|
|
7
|
+
import { TreeChangedAdd, TreeChangedClear, TreeChangedEvent, TreeChangedRemove, TreeChangedReplace, TreeChangedUpdate, TreeStructuralPatch } from "./types/tree-changed.js";
|
|
8
8
|
/**
|
|
9
9
|
* Empty interface extended by plugins via module augmentation to declare
|
|
10
10
|
* typed `state.context.<namespace>` fields.
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,4 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Subpath export: core's own DISCIPLINE primitives.
|
|
3
|
+
*
|
|
4
|
+
* ⚑ This is not "core's utils" and deliberately does not grow into one. It
|
|
5
|
+
* carries core's own DISCIPLINE primitives — the rules a plugin has to obey for
|
|
6
|
+
* the same reason core does, published so there is one implementation rather
|
|
7
|
+
* than one per package. A candidate earns its place by being such a rule, not
|
|
8
|
+
* by being useful.
|
|
9
|
+
*
|
|
10
|
+
* **INGESTION (#1852)** — a bag handed in contributes DATA, and nothing else. No
|
|
11
|
+
* trap, no accessor, no inherited member of it — and no accessor an application
|
|
12
|
+
* put on the DESTINATION's prototype chain — may change what ends up stored.
|
|
13
|
+
*
|
|
14
|
+
* The router obeys that rule at every write of its own — the set is DERIVED by
|
|
15
|
+
* `tests/functional/computed-key-write-authority-1852.test.ts`, not listed here,
|
|
16
|
+
* so no count in prose can go stale against it. Why a PLUGIN has to obey it too
|
|
17
|
+
* is the README's "Ingestion primitives" section, which owns that explanation —
|
|
18
|
+
* pointed at rather than restated, because a rule with two homes goes stale in
|
|
19
|
+
* one of them.
|
|
20
|
+
*
|
|
21
|
+
* ⚠ What that section does not carry is the measured blast radius, and the two
|
|
22
|
+
* shipped plugins fail DIFFERENTLY on one and the same input:
|
|
23
|
+
* `persistent-params` loses a key from the URL with no error at all, while
|
|
24
|
+
* `search-schema` throws out of the navigation.
|
|
25
|
+
*
|
|
26
|
+
* **Why it is published rather than copied.** A copy per package is exactly how
|
|
27
|
+
* this class acquired its earlier partial fixes — #855, #1191 and #1788 each
|
|
28
|
+
* special-cased the literal `"__proto__"` in one file, none of them closed the
|
|
29
|
+
* class, and all three had to be replaced here. The primitive ships once.
|
|
30
|
+
*
|
|
31
|
+
* ⚠ **Why the plugins cannot just use `Object.create(null)` instead.** They can,
|
|
32
|
+
* semantically: a plugin's record never escapes — core copies it into a bag of
|
|
33
|
+
* its own, so a prototype-less one does not reach `state.params` (measured).
|
|
34
|
+
* What stops it is the price. V8 keeps such an object in dictionary mode, so the
|
|
35
|
+
* cost lands on every later READ: measured end-to-end, `buildPath` through
|
|
36
|
+
* `persistent-params` went **+19.5 %**, the same shape the same change measures
|
|
37
|
+
* inside core — the figures are in `putField`'s docblock and are not repeated
|
|
38
|
+
* here, because a number repeated is a number that goes stale in more than one
|
|
39
|
+
* place. `putField` asks the chain once and pays only
|
|
40
|
+
* where it answers.
|
|
41
|
+
*
|
|
42
|
+
* ⚠ Not the same subpath as the retired `@real-router/core/utils` (#1543). That
|
|
43
|
+
* one held SSR helpers and was removed BECAUSE its content was SSR-specific and
|
|
44
|
+
* belonged in `@real-router/ssr-utils` — a reason that does not transfer: this
|
|
45
|
+
* content is core's own discipline, applied inside core first.
|
|
46
|
+
*
|
|
47
|
+
* ⚠ **Nothing written in THIS file reaches a consumer.** A re-export's docblock
|
|
48
|
+
* is not emitted — `dist/esm/utils.d.mts` is the re-export lines and nothing
|
|
49
|
+
* else — while the declaration sites' own docblocks ship in full. So a contract
|
|
50
|
+
* a plugin has to obey belongs where the function is DECLARED; what belongs
|
|
51
|
+
* here is why the subpath carries the entry at all.
|
|
52
|
+
*/
|
|
2
53
|
import { copyFields, putField } from "./utils/ingest.js";
|
|
3
54
|
import { adoptChannel } from "./helpers.js";
|
|
55
|
+
import { freezeThrownError, internalDefect, raiser } from "./RouterError.js";
|
|
4
56
|
export { adoptChannel, copyFields, freezeThrownError, internalDefect, putField, raiser };
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-BCSkINAR.js");exports.adoptChannel=e.t,exports.copyFields=e.T,exports.freezeThrownError=e.x,exports.internalDefect=e.S,exports.putField=e.O,exports.raiser=e.C;
|
package/dist/cjs/validation.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin-facing subpath: router internals, the routing engine's surface and
|
|
3
|
+
* the rules core applies, re-exported so a plugin depends on
|
|
4
|
+
* `@real-router/core` alone and needs no second copy of a rule.
|
|
5
|
+
*
|
|
6
|
+
* `@real-router/validation-plugin` reaches `getInternals` for what `PluginApi`
|
|
7
|
+
* does not hand out; which members it reads is the `getInternals` row of the
|
|
8
|
+
* "what SHIPPED code outside core reaches for" cell in
|
|
9
|
+
* `tests/functional/door-census/consumers.test.ts`.
|
|
10
|
+
*/
|
|
1
11
|
import { buildParamMeta } from "./engine/path-matcher/buildParamMeta.js";
|
|
2
12
|
import { RouteTree } from "./engine/builder/types.js";
|
|
3
13
|
import { Matcher } from "./engine/createMatcher.js";
|
|
4
14
|
import { validateRoute } from "./engine/validation/route-batch.js";
|
|
5
|
-
import { RouterValidator } from "./types/RouterValidator.js";
|
|
6
|
-
import { areParamValuesEqual } from "./helpers.js";
|
|
7
15
|
import { RouterInternals, getInternals } from "./internals.js";
|
|
16
|
+
import "./channels/index.js";
|
|
8
17
|
import { findMisChanneledKey } from "./channels/guard.js";
|
|
9
|
-
|
|
18
|
+
import { areParamValuesEqual } from "./helpers.js";
|
|
19
|
+
import "./engine/index.js";
|
|
20
|
+
export { type Matcher, type RouteTree, type RouterInternals, areParamValuesEqual, buildParamMeta, findMisChanneledKey, getInternals, validateRoute };
|
package/dist/cjs/validation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./internals-2KakrCBP.js"),t=require("./helpers-BCSkINAR.js");exports.areParamValuesEqual=t.a,exports.buildParamMeta=e.b,exports.findMisChanneledKey=e.T,exports.getInternals=e.o,exports.validateRoute=e.m;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,E as t,S as n,T as r,_ as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as ee,w as x,x as S,y as te}from"./internals-D17AclZw.mjs";import{A as C,B as w,C as T,D as E,E as ne,F as D,M as re,N as ie,O,P as k,R as A,S as j,T as ae,V as M,_ as oe,a as se,b as N,c as ce,d as le,f as ue,g as de,h as fe,i as pe,j as me,k as he,l as ge,m as _e,n as ve,o as P,p as ye,r as be,s as xe,t as F,u as Se,v as Ce,w as we,x as I,y as L,z as R}from"./helpers-LeSZEDaV.mjs";const Te=Object.entries,Ee=Object.hasOwn;function De(e,t,n){if(e===void 0||n.length===0)return e;let r,i=!1;for(let[a,o]of Te(e))Ee(t,a)&&t[a]!==void 0&&n.includes(a)?i=!0:(r??={},O(r,a,o));return r===void 0?i?void 0:e:r}function Oe(t,n,r){for(let[i,a]of Te(t))e(r,i,a,n(i),"this route's `defaultParams`","Move it to `defaultSearch`")}const ke=Object.entries,Ae=Object.freeze;function je(e,t,n){let r,i=!1;for(let[a,o]of ke(e))t.includes(a)?(r??={},O(r,a,o)):(i=!0,n?.(a));return i?Ae(r??D):e}function Me(e,t){let n=e.path,r=n.startsWith(`~`),i=r?n.slice(1):n,a=i!==``&&!i.startsWith(`/`)&&!i.startsWith(`?`)?`/${i}`:i,o={name:e.name,path:a,absolute:r,children:[],parent:t};if(e.children)for(let t of e.children){let e=Me(t,o);o.children.push(e)}return o}function Ne(e,t,n){let r=Me({name:e,path:t},null);for(let e of n){let t=Me(e,r);r.children.push(t)}return r}const Pe=/[^\w!$'()*+,.:;|~-]/gu,Fe=/[^\w!$'()*+,.:;|~-]/u,Ie=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Le=e=>t=>{try{return e(t)}catch{return e(t.replaceAll(Ie,`�`))}},Re=Le(e=>e.replaceAll(Pe,e=>encodeURIComponent(e))),ze={default:e=>Fe.test(e)?Re(e):e,uri:Le(encodeURI),uriComponent:Le(encodeURIComponent),none:e=>e},Be={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e},Ve={default:`%2F`,uri:`/`,uriComponent:`%2F`,none:`/`},He=(e,t)=>{let n=ze[t],r=Ve[t],i=String(e).split(`/`),a=n(i[0]);for(let e=1;e<i.length;e++)a+=(i[e-1]===``?r:`/`)+n(i[e]);return a},Ue=Object.freeze(Object.create(null));function We(){return{staticChildren:Ue,hasChildren:!1,paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function z(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e}function Ge(e,t){return e===``?t:t===``?e:e.endsWith(`/`)&&t.startsWith(`/`)?e+t.slice(1):e+t}function Ke(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function qe(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(!Ke(n)||!Ke(r))return!1;t+=3}else t++;return!0}const Je=Object.freeze([]),Ye=Object.freeze(new Set),Xe=Object.freeze([]),Ze=Object.freeze({}),Qe=Object.freeze({}),$e=Object.freeze({});function et(e,t){let n=e.kind===`splat`;return{paramName:e.name,encoder:n?e=>He(e,t):ze[t]}}function tt(e,t,r,i){let a=new Set(i);for(let e of t)for(let t of e.paramMeta.urlParams)a.add(t);if(a.size===0)return{buildStaticParts:[e],buildParamSlots:Xe};let o=[],s=[],c=``,l=n(e),u=l.length-1;for(let[e,t]of l.entries()){let n=S(t);(`error`in n||n.kind!==`splat`||e===u)&&(e>0&&(c+=`/`),`error`in n||n.kind===`static`?c+=t:(o.push(c),c=``,s.push(et(n,r))))}return o.push(c),{buildStaticParts:o,buildParamSlots:s}}const B=T(`router`);function nt(e,t,n){throw B.plain`Parameter name conflict at the same path position: '${n}${e}' and '${n}${t}'. One position binds one name across every route that shares it. Rename one — e.g. use '${n}${e}' in both.`}function rt(){throw B.plain`Empty parameter name: a ':'/'*' marker must be followed by a name (e.g. ':id', '*rest'), and a segment cannot end in a bare '?'.`}function it(e){throw B.plain`Fused parameter marker in segment "${e}": a ':'/'*' marker must begin a segment — write 'a/:b', not 'a:b'.`}function at(e){throw B.plain`Trailing parameter marker in segment "${e}": a param name cannot end in a bare ':' or '*'. Drop the stray marker.`}function ot(e){throw B.plain`Optional params are not supported: "${e}" — declare two sibling routes instead, one with the segment and one without.`}function st(e){throw B.plain`Regex constraints are not supported: '<' and '>' are reserved in path segments ("${e}"). Match it as a plain string and validate the value in a canActivate guard.`}function ct(e){throw B.plain`Non-ASCII static segment "${e}": match compares static keys raw and rejects non-ASCII input, so this route can never match. Percent-encode it (e.g. "/caf%C3%A9") or use a param.`}function lt(e,t){switch(e){case`name-less`:return rt();case`trailing-marker`:return at(t);case`fused-marker`:return it(t);case`optional-removed`:return ot(t);case`constraint-removed`:return st(t)}}function ut(e,t){let n=new Set,r=``;for(let e of t){if(n.has(e)){r=e;break}n.add(e)}throw B.plain`Duplicate parameter name '${r}' in route "${e}": a name must be unique within a route — the second position overwrites the first. Rename one.`}function dt(e,t){throw B.plain`Invalid query-param declaration "${t}" in route "${e}": a query-param name cannot contain '<' or '>'. Rename it.`}function ft(e){throw B.plain`Double slashes are not allowed in path "${e}": the route would build a URL its own matcher refuses. Remove the empty segment.`}function pt(e,t){throw B.plain`Duplicate route path: routes "${e}" and "${t}" resolve to the same URL — the later would shadow the earlier. Give them distinct paths.`}function mt(e,t){throw B.plain`Index route "${e}" (path "/") under the splat parent "${t}" is unreachable: the wildcard match never reaches the index node. Give the index a distinct path, or make the parent static.`}function ht(e,t){return e.paramChild?e.paramChild.name!==t&&nt(e.paramChild.name,t,`:`):e.paramChild={node:We(),name:t},e.paramChild.node}function gt(e,t){return e.splatChild?e.splatChild.name!==t&&nt(e.splatChild.name,t,`*`):e.splatChild={node:We(),name:t},e.splatChild.node}const _t=Object.create;function vt(e,t){e.route!==void 0&&e.route!==t&&pt(e.route.name,t.name),e.route=t}function yt(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1}function bt(e,t,n){let r=z(n);r===`/`?vt(e.root,t):xt(e,e.root,r,1,t)}function xt(e,t,n,r,i){let a=n.length;for(;r<=a;){let i=n.indexOf(`/`,r),o=i===-1?a:i,s=n.slice(r,o);t=Tt(e,t,s),r=o+1}vt(t,i)}function St(e,t,n){let r=n.length;for(;r>1&&n.codePointAt(r-1)===47;)--r;let i=n.slice(0,r);i.slice(i.lastIndexOf(`/`)+1).startsWith(`*`)&&mt(t.name,n);let a=Ct(e,n);a.slashChildRoute=t}function Ct(e,t){return wt(e,e.root,t)}function wt(e,t,n){let r=z(n);if(r===`/`||r===``)return t;let i=t,a=1,o=r.length;for(;a<=o;){let t=r.indexOf(`/`,a),n=t===-1?o:t;if(n<=a)break;let s=r.slice(a,n);i=Tt(e,i,s),a=n+1}return i}function Tt(e,t,n){let r=S(n);if(`error`in r&&rt(),r.kind===`splat`){let e=gt(t,r.name);return t.hasChildren=!0,e}if(r.kind===`param`){let e=ht(t,r.name);return t.hasChildren=!0,e}yt(n)&&ct(n);let i=e.options.caseSensitive?n:n.toLowerCase();return i in t.staticChildren||(t.staticChildren===Ue&&(t.staticChildren=_t(null)),t.staticChildren[i]=We(),t.hasChildren=!0),t.staticChildren[i]}const Et=Object.freeze,Dt=Object.hasOwn;function Ot(e){let t=n(e);for(let[n,r]of t.entries())r===``&&n>0&&n<t.length-1&&ft(e)}function kt(e){for(let t of n(e)){let e=S(t);`error`in e&<(e.error,t)}}function At(e,t,n,r,i){let a=t.fullName===``;a||r.push(t);let o=t.absolute,s=t.paramMeta===ee?t.path:t.paramMeta.pathPattern,c=o&&s.startsWith(`~`)?s.slice(1):s,l=o?c:s;Ot(t.path),kt(l);let u=l,d=o?u:Ge(n,u),f=a?i:jt(e,t,d,o?``:n,r,i);for(let n of t.children.values())At(e,n,d,r,f);a||r.pop()}function jt(e,t,n,r,i,a){let o=It(n,r),s=Et([...i]),c=Mt(s),l=z(n),u=Et(Lt(e.rootQueryParams,i)),{buildStaticParts:d,buildParamSlots:f}=tt(o?z(r):l,o?i.slice(0,-1):i,e.options.urlParamsEncoding,e.rootUrlParams),p=f.map(e=>e.paramName),m=p.length===0?Ye:new Set(p);m.size!==p.length&&ut(t.fullName,p),Rt(t.fullName,u);let h={name:t.fullName,parent:a,matchSegments:s,meta:c,declaredQueryParams:u,declaredQueryParamsSet:u.length===0?Ye:new Set(u),hasTrailingSlash:n.length>1&&n.endsWith(`/`),buildStaticParts:d,buildParamSlots:f,buildParamNamesSet:m,cachedResult:void 0};return t.paramMeta.urlParams.length===0&&(h.cachedResult=Et({segments:h.matchSegments,params:Ze,search:Qe,meta:h.meta})),e.routesByName.set(t.fullName,h),o?Pt(e,h,r):Ft(e,h,n,l,t),h}function Mt(e){let t;for(let n of e)Nt(n.paramTypeMap)&&(t??=ne(),t[n.fullName]=n.paramTypeMap);return t===void 0?$e:Et(we(E(t)))}function Nt(e){for(let t in e)if(Dt(e,t))return!0;return!1}function Pt(e,t,n){St(e,t,n);let r=z(n),i=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.has(i)&&e.staticCache.set(i,t)}function Ft(e,t,n,r,i){if(bt(e,t,n),i.paramMeta.urlParams.length===0){let n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}function It(e,t){return z(e)===z(t)}function Lt(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?Je:n}function Rt(e,t){for(let n of t)te.test(n)&&dt(e,n)}const zt=T(`router`,`buildPath`),Bt=Symbol.for(`real-router.searchParams.configFault`),Vt=Object.hasOwn,Ht=Object.keys,Ut=Object.getOwnPropertyDescriptor;function Wt(e){try{return Ut(e,Bt)?.configurable===!1}catch{return!1}}function Gt(e){return typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):String(e)}const Kt=Object.freeze({});function qt(e,t){return e===`strict`?t?`always`:`never`:e}var Jt=class{get options(){return this.#e}#e;#t=We();#n=new Map;#r=new Map;#i={cleanPath:``,normalized:``,queryString:void 0};#a=[];#o=``;#s;#c;constructor(e){let t=e.urlParamsEncoding??`default`,n=typeof t==`string`?t:String(t),r=Vt(ze,n)?n:`default`;this.#e={caseSensitive:e.caseSensitive??!0,strictTrailingSlash:e.strictTrailingSlash??!1,strictQueryParams:e.strictQueryParams??!1,urlParamsEncoding:r,parseQueryString:e.parseQueryString,buildQueryString:e.buildQueryString},this.#s=this.#e.caseSensitive,this.#c=this.#e.urlParamsEncoding===`none`?null:Be[this.#e.urlParamsEncoding]}registerTree(e){this.#a=e.paramMeta.queryParams,At({root:this.#t,options:this.#e,routesByName:this.#n,staticCache:this.#r,rootQueryParams:this.#a,rootUrlParams:e.paramMeta.urlParams},e,``,[],null)}match(e){if(!this.#f(e))return;let{cleanPath:t,normalized:n,queryString:r}=this.#i,i=this.#s?n:n.toLowerCase(),a=this.#r.get(i);if(a)return this.#e.strictTrailingSlash&&!this.#g(t,a)?void 0:r===void 0&&a.cachedResult?a.cachedResult:this.#m(a,{},r);let o={},s=this.#_(n,o);if(s&&(!this.#e.strictTrailingSlash||this.#g(t,s))&&this.#b(o))return this.#m(s,o,r)}buildPath(e,t,n,r){let i=this.#n.get(e);if(!i)throw zt.plain`'${e}' is not defined`;let a=this.#l(i,t),o=this.#u(a,qt(r?.trailingSlash,i.hasTrailingSlash)),s=this.#d(i,n??t,r?.queryParamsMode);return o+(s?`?${s}`:``)}getSegmentsByName(e){return this.#n.get(e)?.matchSegments}getMetaByName(e){return this.#n.get(e)?.meta}getDeclaredQueryParams(e){return this.#n.get(e)?.declaredQueryParams}hasRoute(e){return this.#n.has(e)}#l(e,t){let n=e.buildStaticParts,r=e.buildParamSlots;if(r.length===0)return n[0];let i=n[0];for(let[e,a]of r.entries()){let r=t!=null&&Vt(t,a.paramName)?t[a.paramName]:void 0;if(r==null)throw zt.plain`Missing required param '${a.paramName}'`;if(r===``)throw zt.plain`Missing required param '${a.paramName}' (empty string)`;let o=a.encoder(Gt(r));i+=o+n[e+1]}return i}#u(e,t){return t===`always`&&!e.endsWith(`/`)?`${e}/`:t===`never`&&e!==`/`&&e.endsWith(`/`)?e.slice(0,-1):e}#d(e,t,n){if(!t||e.declaredQueryParams.length===0&&n!==`loose`)return``;let r={},i=!1;for(let n of e.declaredQueryParams)Vt(t,n)&&(O(r,n,t[n]),i=!0);if(n===`loose`)for(let n of Ht(t))e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(O(r,n,t[n]),i=!0);return i?this.#e.buildQueryString(r):``}#f(e){if(e===``&&(e=`/`),e.codePointAt(0)!==47)return!1;let t=this.#p(e);if(t===-2)return!1;t===-3&&(e=this.#o);let n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):void 0;if(r!==void 0){let e=r.indexOf(`#`);e!==-1&&(r=r.slice(0,e))}let i=z(n);return this.#i.cleanPath=n,this.#i.normalized=i,this.#i.queryString=r,!0}#p(e){let t=!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===35)return this.#o=e.slice(0,n),-3;if(r===63)return n;if(r>=128)return-2;if(r===47){if(t)return-2;t=!0}else t=!1}return-1}#m(e,t,n){let r=Kt;if(n!==void 0){let t=this.#h(e,n);if(t===void 0)return;r=t}return{segments:e.matchSegments,params:t,search:r,meta:e.meta}}#h(e,t){let n;try{n=this.#e.parseQueryString(t)}catch(e){if(Wt(e))throw e;return}if(this.#e.strictQueryParams){let t=e.declaredQueryParamsSet;for(let e of Ht(n))if(!t.has(e))return}return n}#g(e,t){return(e.length>1&&e.endsWith(`/`))===t.hasTrailingSlash}#_(e,t){return e.length===1?this.#t.slashChildRoute??this.#t.route:this.#v(this.#t,e,1,t)}#v(e,t,n,r){let i=e,a=t.length,o=this.#s;for(;n<=a;){let e=t.indexOf(`/`,n),s=e===-1?a:e,c=t.slice(n,s),l=o?c:c.toLowerCase(),u;if(l in i.staticChildren){let e=i.staticChildren[l];if(i.splatChild!==void 0){let a={},o=this.#v(e,t,s+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(ae(r,a),o)}u=e}else if(i.paramChild){let e=i.paramChild;if(i.splatChild!==void 0){let a={[e.name]:c},o=this.#v(e.node,t,s+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(ae(r,a),o)}u=e.node,O(r,e.name,c)}else if(i.splatChild)return this.#y(i.splatChild,t,n,r);else return;i=u,n=s+1}return i.slashChildRoute??i.route}#y(e,t,n,r){let i=e.node;if(!i.hasChildren)return O(r,e.name,t.slice(n)),i.route;let a={},o=this.#v(i,t,n,a);return o?(ae(r,a),o):(O(r,e.name,t.slice(n)),i.route)}#b(e){let t=this.#c;if(!t)return!0;for(let n of Ht(e)){let r=e[n];if(r.includes(`%`)){if(!qe(r))return!1;try{e[n]=t(r)}catch{return!1}}}return!0}};const V=Object.freeze,Yt=Object.freeze(new Map),Xt=Object.freeze([]);function Zt(e){return e.parent?.name?`${e.parent.fullName}.${e.name}`:e.name}function Qt(e){let t=new Map;for(let n of e)t.set(n.name,n);return t}function $t(e,t){let n=[],r=[];for(let i of e){let e=en(i,t);n.push(e),e.absolute||r.push(e)}return{childrenMap:Qt(n),nonAbsoluteChildren:r}}function en(e,t){let n=o(e.path),r=n.urlParams.length===0&&n.queryParams.length===0&&n.pathPattern===e.path?ee: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=Zt(a),e.children.length===0)a.children=Yt,a.nonAbsoluteChildren=Xt;else{let{childrenMap:t,nonAbsoluteChildren:n}=$t(e.children,a);a.children=t,a.nonAbsoluteChildren=n,V(a.nonAbsoluteChildren),V(a.children)}return V(i),V(r.urlParams),V(r.queryParams),V(r),V(a),a}function tn(e){return en(e,null)}function nn(e,t,n){return tn(Ne(e,t,n))}function rn(e){let t=e.absolute?`~${e.path}`:e.path,n={name:e.name,path:t};return e.children.size>0&&O(n,`children`,Array.from(e.children.values(),rn)),n}function an(e){return Array.from(e.children.values(),rn)}const on=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)},sn=(e,t)=>{if(e===void 0)return t.boolean.decodeUndefined();let n=t.boolean.decodeRaw(e);if(n!==null)return n;let r=on(e),i=t.number.decode(r);return i===null?t.boolean.decodeValue(r):i},cn=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,ln=e=>{try{return encodeURIComponent(e)}catch(t){if(!(t instanceof URIError))throw t;return encodeURIComponent(String(e).replaceAll(cn,`�`))}},un=T(`router`),dn=e=>{let t=typeof e;if(t!==`string`&&t!==`number`&&t!==`boolean`)throw un.type`Invalid query value: an array element must be a string, number, or boolean — received ${t}`;return ln(e)},fn=(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}=${dn(e)}`);return a.join(`&`)},pn={none:{encodeArray:(e,t,n)=>fn(e,t,``,n)},brackets:{encodeArray:(e,t,n)=>fn(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}=${dn(a)}`)}return r.join(`&`)},indexed:!0},comma:{encodeArray:(e,t)=>{let n=[];for(let e of t)e!==null&&n.push(dn(e));return n.length===0?``:`${e}=${n.join(`,`)}`},decodeValue:e=>e.includes(`,`)?e.split(`,`):null}},mn={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`||e!==`false`&&null,decodeValue:e=>e},"empty-true":{encode:(e,t)=>t?e:`${e}=false`,decodeUndefined:()=>!0,decodeRaw:e=>e===`true`||e!==`false`&&null,decodeValue:e=>e}},hn={default:{encode:e=>e},hidden:{encode:()=>``}},gn={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;else return null}}let i=Number(e);return String(i)!==e||!Number.isSafeInteger(i)&&!r?null:i}},none:{decode:()=>null}},_n=T(`router`),vn=Object.defineProperty,yn=Object.keys,bn=Object.hasOwn,xn=Symbol.for(`real-router.searchParams.configFault`),Sn=(e,t,n)=>{let r=typeof t==`string`?t:String(t);if(!bn(e,r)){let t=_n.type`Invalid "queryParams.${n}": "${r}" — expected ${yn(e).map(e=>`"${e}"`).join(` | `)}`;throw vn(t,xn,{value:!0}),t}return e[r]},Cn=(e,t,n,r)=>({boolean:Sn(mn,t,`booleanFormat`),null:Sn(hn,n,`nullFormat`),number:Sn(gn,r,`numberFormat`),array:Sn(pn,e,`arrayFormat`)}),wn=Object.freeze({boolean:mn.auto,null:hn.default,number:gn.auto,array:pn.none}),H=Object.freeze({arrayFormat:`none`,booleanFormat:`auto`,nullFormat:`default`,numberFormat:`auto`}),Tn=Object.freeze({...H,strategies:wn}),En=e=>{if(!e||e.arrayFormat===void 0&&e.booleanFormat===void 0&&e.nullFormat===void 0&&e.numberFormat===void 0)return Tn;let t=e.arrayFormat??H.arrayFormat,n=e.booleanFormat??H.booleanFormat,r=e.nullFormat??H.nullFormat,i=e.numberFormat??H.numberFormat;return{arrayFormat:t,booleanFormat:n,nullFormat:r,numberFormat:i,strategies:Cn(t,n,r,i)}},Dn=e=>ln(e),On=(e,t,n)=>{let r=Dn(e);switch(typeof t){case`string`:case`number`:return`${r}=${Dn(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}=${Dn(t)}`;default:return`${r}=${Dn(t)}`}},kn=Object.hasOwn,An=Object.keys;function jn(e,t,n){O(e,t,n)}function Mn(e,t,n,r){if(!kn(e,t)){jn(e,t,r?[n]:n);return}let i=e[t];Array.isArray(i)?i.push(n):jn(e,t,[i,n])}function Nn(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++;else return null}return null}function Pn(e,t,n){let{searchPart:r,nameEnd:i,nameSourceEnd:a,rawValue:o,decodedName:s}=e,c=Nn(r,i,a);if(c===null)return!1;let l=sn(o,t),u=n.get(s);return u===void 0?n.set(s,[[c,l]]):u.push([c,l]),!0}function Fn(e,t,n,r,i,a,o){let s=a!==-1&&a<n?e.slice(a+1,n):void 0,c=s===void 0?n:a,l=c,u=!1;for(let n=t;n<c;n++)if(e.codePointAt(n)===91){l=n,u=!0;break}let d=on(e.slice(t,l));if(!(o!==void 0&&u&&Pn({searchPart:e,nameEnd:l,nameSourceEnd:c,rawValue:s,decodedName:d},i,o))){if(!u&&s!==void 0&&i.array.decodeValue){let e=i.array.decodeValue(s);if(e){for(let t of e)Mn(r,d,sn(t,i),!0);return}}Mn(r,d,sn(s,i),u)}}const In=(e,t)=>{if(e===``||e===`?`)return{};let n={};return Ln(e,n,t.strategies),n};function Ln(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)),Fn(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]),jn(t,e,n.map(e=>e[1]))}const Rn=(e,t)=>{let n=An(e);if(n.length===0)return``;let r=[];for(let i of n){let n=e[i];if(n===void 0)continue;let a=On(i,n,t);a&&r.push(a)}return r.join(`&`)};function zn(e){let t=e?.queryParams,n=En(t);return new Jt({...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=>In(e,n),buildQueryString:e=>Rn(e,n)})}const Bn=T(`router`,`addEventListener`),Vn=T(`router`,`subscribeChanges`),Hn=T(`router`,`addInterceptor`),Un=T(`router`,`addCheck`),Wn=T(`router`,`extendRouter`),U=T(`router`),Gn=Object.keys,Kn=Object.values,qn=Object.hasOwn,Jn=Object.getOwnPropertyDescriptor,Yn=Object.getPrototypeOf,Xn=Object,Zn=new Set(Kn(w));function Qn(e){if(!Zn.has(e))throw Bn.type`Invalid event name: ${String(e)}. Must be one of: ${[...Zn].join(`, `)}`}function $n(e){if(typeof e!=`function`)throw Bn.type`callback must be a function, got ${typeof e}`}function er(e){if(typeof e!=`function`)throw Vn.type`Expected a function`}function tr(e,t){if(typeof e!=`string`||!qn(_,e))throw Hn.type`Invalid method: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Gn(_).join(`, `)}`;if(typeof t!=`function`)throw Hn.type`interceptor must be a function, got ${typeof t}`}function nr(e,t){if(typeof e!=`string`||!qn(m,e))throw Un.type`Invalid position: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Gn(m).join(`, `)}`;if(typeof t!=`function`)throw Un.type`check must be a function, got ${typeof t}`}function rr(e,t){if(typeof e!=`string`)throw T(`router`,t).type`Route name must be a string, got ${typeof e}`}function ir(e,t){if(e===``)throw T(`router`,t).type`A guard on the root node "" never runs: no navigation activates or deactivates the root`}function ar(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Yn(e);return t===null||t.constructor===Xn}function or(e){if(!ar(e))throw U.type`dependencies must be a plain object`}function sr(e){return e===null?`null`:typeof e==`object`?`a non-plain object`:typeof e}function cr(e){if(!ar(e))throw Wn.type`extensions must be a plain object, got ${sr(e)}`}function lr(e,t){or(e);let n=e,r=[];for(let e of Gn(n)){if(Jn(n,e)?.get)throw U.type`dependencies cannot contain getters: "${e}"`;let t=n[e];t!==void 0&&r.push([e,t])}for(let[e,n]of r)t(e,n)}function ur(e){let t=[];for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw U.type`route must be a non-array object`;d(e,`addRoute`);let r={...e},i=r.children;i&&O(r,`children`,ur(i)),t.push(r)}return t}const dr=new Set([`all`,`warn-error`,`error-only`,`none`]);function fr(e){return typeof e==`string`&&dr.has(e)}function pr(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function mr(e){for(let t of Gn(e))if(t!==`level`&&t!==`callback`&&t!==`callbackIgnoresLevel`)throw U.type`Unknown logger config property: "${t}"`}function hr(e){if(!qn(e,`level`))return;let t=e.level;if(t!==void 0){if(!fr(t))throw U.type`Invalid logger level: ${pr(t)}. Expected: "all" | "warn-error" | "error-only" | "none"`;return t}}function gr(e){if(!qn(e,`callbackIgnoresLevel`))return;let t=e.callbackIgnoresLevel;if(t!==void 0){if(typeof t!=`boolean`)throw U.type`Logger callbackIgnoresLevel must be a boolean, got ${typeof t}`;return t}}function _r(e){if(typeof e!=`object`||!e)throw U.type`Logger config must be an object`;let t=e;mr(t);let n=ne(),r=hr(t);if(r!==void 0&&(n.level=r),qn(t,`callback`)){let e=t.callback;if(e!==void 0&&typeof e!=`function`)throw U.type`Logger callback must be a function, got ${typeof e}`;n.callback=e}let i=gr(t);return i!==void 0&&(n.callbackIgnoresLevel=i),n}const vr=Object.create,yr=Object.freeze,br=Object.defineProperty;function xr(e,t,n){e[t]=n}function Sr(e,t){return e.dependencies[t]}function Cr(e){e.dependencies=vr(null)}function wr(e){return xe({...e.dependencies})}function Tr(e,t,n){let r=vr(null),i=e,a=r;lr(i,(e,t)=>{xr(a,e,t)});let o={dependencies:r,limits:t,diagnostics:yr(n)};return br(o,`diagnostics`,{writable:!1,configurable:!1}),o}const Er={defaultRoute:``,defaultParams:{},defaultSearch:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:H,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0},Dr=[`strict`,`never`,`always`,`preserve`],Or=[`default`,`strict`,`loose`];function kr(e){return e!==void 0&&Dr.includes(e)?e:Er.trailingSlash}function Ar(e){return e!==void 0&&Or.includes(e)?e:Er.queryParamsMode}const jr=T(`router`);function Mr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw jr.type`options must be a plain object`}const Nr=Object.freeze;var Pr=class{#e;constructor(e={}){this.#e=Nr(xe({...Er,...e}))}static validateOptionsIsObject(e){Mr(e)}get(){return this.#e}};function Fr(e,t){return typeof e==`function`?e(t):e}const Ir=Object.keys;function Lr(e,t,n,r,i){let a=e.pathNames(t);if(a!==void 0)for(let e of Ir(n))!r.includes(e)&&!a.includes(e)&&i(t,e)}function W(e,t,n,r,i){let a=String(t),o=i?.resolveForward===!1?{name:a,params:n,search:r}:e.resolveForward(a,n,r),s=o.name,c=ye(o.params,k),l=i?.diagnoseUndeclared===!0?e.reportUndeclaredParamKey:void 0;l&&Lr(e,s,c,e.queryNames(s),l);let u=e.defaultParams(s),d=e.defaultSearch(s);if((o.search===void 0||o.search===D)&&u===void 0&&d===void 0)return{name:s,path:c,query:D};let f=e.queryNames(s),p=e.reportDroppedQueryKey,m=i?.resolveForward===!1?De(d,c,f):d,h=ye(o.search,D),g=ue(m,h);return{name:s,path:le(u,c),query:e.admitsUndeclaredQuery()?g:je(g,e.printedQueryNames(s),t=>{p!==void 0&&e.pathNames(s)!==void 0&&p(s,t)})}}function Rr(e,t){return t.buildPath(e.name,e.path,e.query)}const zr=Object.freeze;function Br(e,t){let n={name:e.name,params:e.path,search:e.query,path:t,context:{},transition:re};return zr(n.params),n}function Vr(e,t){return ce(Br(e,t))}function Hr(e,t){return Br(e,t)}var Ur=class{#e;#t;get(){return this.#e.current}getPrevious(){return this.#e.previous}setContext(e){this.#e=e}setDependencies(e){this.#t=e}makeState(e,t,n,r){let i=this.#t.port(),a=W(i,e,t??k,n,{resolveForward:!1});return x(`makeState`,a.name,a.path,i.queryNames(a.name)),Vr(a,r??Rr(a,i))}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;let r=e.name;return r===t.name?n?Ce(e.params,t.params,this.#t.getUrlParams(r)):oe(e.params,t.params)&&oe(e.search,t.search):!1}};const Wr=Object.keys,Gr={[M.ROUTER_START]:w.ROUTER_START,[M.ROUTER_STOP]:w.ROUTER_STOP,[M.TRANSITION_SUCCESS]:w.TRANSITION_SUCCESS,[M.TRANSITION_START]:w.TRANSITION_START,[M.TRANSITION_LEAVE_APPROVE]:w.TRANSITION_LEAVE_APPROVE,[M.TRANSITION_ERROR]:w.TRANSITION_ERROR,[M.TRANSITION_CANCEL]:w.TRANSITION_CANCEL},Kr=Wr(Gr),qr=T(`router`,`usePlugin`);function Jr(e){if(e)throw qr.code(R.ROUTER_DISPOSED)`cannot install a plugin on a disposed router — dispose() is terminal`}function Yr(e){if(!(e&&typeof e==`object`)||Array.isArray(e))throw qr.type`Plugin factory must return an object, got ${typeof e}`;if(typeof e.then==`function`)throw qr.type`Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.`}const Xr=Object.freeze;function Zr(e,t){try{l(e(),t)}catch(e){t(e)}}var Qr=class e{#e=new Set;#t=new Set;#n;static validatePlugin(e){Yr(e)}static validateNotDisposed(e){Jr(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...e){if(this.#n.emitDiagnostic(y.USE_PLUGIN_COUNT,this.#e.size+e.length),e.length===1){let t=e[0],n=this.#o(t);this.#e.add(t);let r=!1,i=()=>{r||(r=!0,this.#e.delete(t),this.#t.delete(i),Zr(n,this.#r))};return this.#t.add(i),i}let t=this.#a(e),n=[];try{for(let e of t){let t=this.#o(e);n.push({factory:e,cleanup:t})}}catch(e){for(let{cleanup:e}of n)Zr(e,this.#i);throw e}for(let{factory:e}of n)this.#e.add(e);let r=!1,i=()=>{if(!r){r=!0,this.#t.delete(i);for(let{factory:e}of n)this.#e.delete(e);for(let{cleanup:e}of n)Zr(e,this.#r)}};return this.#t.add(i),i}getAll(){return[...this.#e]}disposeAll(){for(let e of this.#t)e();this.#e.clear(),this.#t.clear()}#r=e=>{this.#n.logger.error(`router`,`Error during cleanup:`,e)};#i=e=>{this.#n.logger.error(`router.usePlugin`,`Cleanup error:`,e)};#a(e){let t=new Set;for(let n of e)t.has(n)?this.#n.emitDiagnostic(y.USE_PLUGIN_DUPLICATE_IN_BATCH):t.add(n);return t}#o(t){e.validateNotDisposed(this.#n.isDisposed());let n=this.#n.compileFactory(t);e.validatePlugin(n),this.#n.runChecks(m[`usePlugin:plugin`],n),Xr(n);let r=[];for(let e of Kr)e in n&&(typeof n[e]==`function`?(r.push(this.#n.addEventListener(Gr[e],n[e])),e===`onStart`&&this.#n.canNavigate()&&this.#n.emitDiagnostic(y.PLUGIN_AFTER_START,e)):this.#n.emitDiagnostic(y.USE_PLUGIN_HOOK_NOT_FUNCTION,e));let i=()=>{for(let e of r)e();if(typeof n.teardown==`function`)return n.teardown()};return this.#n.isDisposed()&&Zr(i,this.#i),e.validateNotDisposed(this.#n.isDisposed()),i}};const G=Object.create,$r=()=>!0,ei=()=>!1,ti=()=>$r,ni=()=>ei;function ri(e){return e?ti:ni}const ii={activate:{count:m[`canActivate:count`],counted:y.CAN_ACTIVATE_COUNT,overwritten:y.CAN_ACTIVATE_OVERWRITE},deactivate:{count:m[`canDeactivate:count`],counted:y.CAN_DEACTIVATE_COUNT,overwritten:y.CAN_DEACTIVATE_OVERWRITE}};function ai(e,t,n){n===void 0?e.delete(t):e.set(t,n)}var oi=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=[this.#i,this.#a];#d;setDependencies(e){this.#d=e}getHandlerCount(e){let t=e===`activate`?this.#e:this.#n,n=e===`activate`?this.#t:this.#r;if(t.size===0)return n.size;if(n.size===0)return t.size;let r=new Set(t.keys());for(let e of n.keys())r.add(e);return r.size}preflightHandlerLimit(e,t,n){this.#f(`activate`,e,n),this.#f(`deactivate`,t,n)}addCanActivate(e,t,n,r){this.#p(`activate`,e,t,n,`canActivate`,r)}addCanDeactivate(e,t,n,r){this.#p(`deactivate`,e,t,n,`canDeactivate`,r)}clearCanActivate(e,t){this.#m(`activate`,e,t)}clearCanDeactivate(e,t){this.#m(`deactivate`,e,t)}clearAll(){this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#a.clear(),this.#i.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#l.clear()}clearDefinitionGuards(){for(let e of this.#e.keys())this.#c.delete(e),this.#t.has(e)?this.#h(`activate`,e):this.#a.delete(e);for(let e of this.#n.keys())this.#o.delete(e),this.#r.has(e)?this.#h(`deactivate`,e):this.#i.delete(e);this.#e.clear(),this.#n.clear()}getFactories(){let e=G(null),t=G(null);for(let[t,n]of this.#n)e[t]=n;for(let[t,n]of this.#r)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,n]of this.#t)t[e]=n;return[e,t]}getFactoriesByOrigin(){let e=G(null),t=G(null),n=G(null),r=G(null);for(let[t,n]of this.#n)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,t]of this.#r)n[e]=t;for(let[e,t]of this.#t)r[e]=t;return{definition:[e,t],external:[n,r]}}getFunctions(){return this.#u}canNavigateTo(e,t,n,r,i){for(let t of e)if(!this.#v(this.#i,t,n,r,i))return!1;for(let e of t)if(!this.#v(this.#a,e,n,r,i))return!1;return!0}compileGuardFactory(e,t){let n=typeof e==`boolean`?ri(e):e,r=this.#d.compileFactory(n);if(typeof r!=`function`)throw T(`router`,t).type`Factory must return a function, got ${typeof r}`;return r}#f(e,t,n){let r=ii[e].count;if(!this.#d.hasChecks(r))return;let{definition:i,external:a}=this.#_(e),o=0;for(let e of t)(n?a.has(e):i.has(e)||a.has(e))||o++;if(o===0)return;let s=n?a.size:this.getHandlerCount(e);this.#d.runChecks(r,s+o-1)}#p(e,t,n,r,i,a){let o=this.#_(e),s=e===`activate`?this.#a:this.#i,c=r?o.definition:o.external,l=r?o.external:o.definition,u=ii[e];if(c.has(t)||l.has(t))this.#d.emitDiagnostic(u.overwritten,t);else if(this.#d.hasChecks(u.count)||this.#d.diagnosticListenerCount(u.counted)>0){let t=this.getHandlerCount(e);this.#d.runChecks(u.count,t),this.#d.emitDiagnostic(u.counted,t+1)}let d=typeof n==`boolean`?ri(n):n,f=c.get(t),p=this.#g(e),m=r?p.definition:p.external,h=m.get(t);c.set(t,d);let g=r&&l.has(t);try{let e=a??this.compileGuardFactory(d,i);m.set(t,e),g||s.set(t,e)}catch(n){throw ai(c,t,f),ai(m,t,h),this.#h(e,t),n}}#m(e,t,n){let{definition:r,external:i}=this.#_(e),a=this.#g(e),o=n!==`external`&&r.delete(t),s=n!==`definition`&&i.delete(t);o&&a.definition.delete(t),s&&a.external.delete(t),(o||s)&&this.#h(e,t)}#h(e,t){let n=this.#g(e),r=e===`activate`?this.#a:this.#i,i=n.external.get(t)??n.definition.get(t);i?r.set(t,i):r.delete(t)}#g(e){return e===`activate`?{definition:this.#c,external:this.#l}:{definition:this.#o,external:this.#s}}#_(e){return e===`activate`?{definition:this.#e,external:this.#t}:{definition:this.#n,external:this.#r}}#v(e,t,n,r,i){let a=e.get(t);if(!a)return!0;try{let e=a(n,r);return typeof e==`boolean`?e:(typeof e?.then==`function`?(Promise.resolve(e).catch(()=>void 0),this.#d.emitDiagnostic(y.SYNC_GUARD_THENABLE,t,i)):this.#d.emitDiagnostic(y.SYNC_GUARD_NON_BOOLEAN,t,e,i),!1)}catch(e){return this.#d.logger.warn(`router.${i}`,`Guard for "${t}" threw — treated as navigation-blocking (returned false)`,e),!1}}};const si=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`,`defaultSearch`]),ci=Object.freeze,K=Object.create,li=Object.hasOwn,ui=Object.keys;function di(){return{decoders:K(null),encoders:K(null),defaultParams:K(null),defaultSearch:K(null),forwardMap:K(null),forwardFnMap:K(null)}}function fi(e){return ui(e.forwardMap).length>0||ui(e.forwardFnMap).length>0}function pi(e,t){for(let n of ui(t))Object.assign(e[n],t[n])}function mi(e,t){for(let n in e)if(li(t,n)&&!se(e[n],t[n]))return!1;return!0}function hi(e){return typeof e==`string`?e:`<non-string>`}function gi(e,t){for(let n in e)if(!se(e[n],t[n]))return!1;return!0}function _i(e){let t={name:e.name,path:e.path};return e.children&&O(t,`children`,e.children.map(e=>_i(e))),t}function vi(e,t,n){if(n.add(t),e.children)for(let r of e.children)vi(r,`${t}.${r.name}`,n)}function yi(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t){e.splice(r,1);let t=new Set;return vi(i,a,t),t}if(i.children&&t.startsWith(`${a}.`)){let e=yi(i.children,t,a);if(e)return e}}}function bi(e,t){for(let n of ui(e))t(n)&&delete e[n]}function xi(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 Si(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}const Ci=ci([]);function wi(e,t,n){let r=n.get(t);if(r!==void 0)return r;let i=e.getSegmentsByName(t);if(!i)return Ci;let a=ci(Si(i));return n.set(t,a),a}function Ti(e,t){return wi(e.matcher,t,e.urlParamsCache)}const Ei=ci([]);function Di(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=e.getDeclaredQueryParams(t);if(!a)return Ei;let o=wi(e,t,n),s=ci(a.filter(e=>!o.includes(e)));return r.set(t,s),s}function Oi(e,t){return e.getDeclaredQueryParams(t)??Ei}function ki(e,t){return Di(e.matcher,t,e.urlParamsCache,e.queryParamsCache)}function Ai(e,t,n){let r=new Map,i=new Map;Oe(t.defaultParams,t=>Di(e,t,r,i),n)}const ji=T(`router`);function Mi(e,t,n=100){let r=String(e),i=new Set,a=[r],o=r;for(;;){let e=t[o];if(!e)break;let r=String(e);if(i.has(r)){let e=a.indexOf(r),t=[...a.slice(e),r];throw ji.plain`Circular forwardTo: ${t.join(` → `)}`}if(i.add(o),a.push(r),o=r,a.length>n)throw ji.plain`forwardTo chain exceeds maximum depth (${n}): ${a.join(` → `)}`}return o}const Ni=T(`router`),Pi=T(`router`,`addRoute`),Fi=Object.freeze,q=Object.create,Ii=Object.entries,Li=Object.keys,Ri=Object.defineProperty,zi=Object.fromEntries;function Bi(e,t,n){let r=nn(``,t,e),i=zn(n);return i.registerTree(r),{tree:r,matcher:i}}function Vi(e,t=e.definitions){let n=Bi(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Hi(e,t){let n=Bi(e.definitions,t,e.matcherOptions);Ai(n.matcher,e.config,`setRootPath`),e.rootPath=t,e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Ui(e,t){Vi(e,t),Ki(e,qi(e.config))}function Wi(e){Gi(e),Vi(e,[])}function Gi(e){Object.assign(e.config,di()),Ki(e,q(null)),e.routeCustomFields=q(null)}function Ki(e,t){e.resolvedForwardMap=t,e.hasAnyForward=fi(e.config)}function qi(e){let t=q(null);for(let n of Li(e.forwardMap))t[n]=Mi(n,e.forwardMap);return t}function Ji(e,t){if(typeof e!=`function`){if(typeof e!=`string`&&e!==null)throw Ni.type`forwardTo must be a string or function for route "${t}", got ${typeof e}`;return}let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw Ni.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}function Yi(e,t,n){t&&g(`encodeParams`,t,n,void 0),e&&g(`decodeParams`,e,n,void 0)}function Xi(e,t,n,r){if(Ji(e.forwardTo,t),e.canActivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${n}".`)}if(e.canDeactivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${n}".`)}typeof e.forwardTo==`string`?n.forwardMap[t]=e.forwardTo:n.forwardFnMap[t]=e.forwardTo}function Zi(e,t,n,r,i,a,o){let{decodeParams:s,encodeParams:c}=e;Yi(s,c,t);let l=zi(Ii(e).filter(([e])=>!si.has(e)));Li(l).length>0&&(r[t]=Fi(l)),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&Xi(e,t,n,o),s&&(n.decoders[t]=e=>s(e)??e),c&&(n.encoders[t]=e=>c(e)??e),e.defaultParams&&(n.defaultParams[t]=P(`defaultParams`,e.defaultParams)),e.defaultSearch&&(n.defaultSearch[t]=P(`defaultSearch`,e.defaultSearch))}function Qi(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;Zi(s,e,t,n,r,i,a),s.children&&Qi(s.children,t,n,r,i,a,e)}}function $i(e){let t=di();return pi(t,e),t}function ea(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]:ea(n,t,i)}})}function ta(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&ta(r.children,e,n)}}function na(e,t,n){let r=new Set;ta(e,t,e=>{if(r.has(e))throw T(`router`,n).plain`Duplicate route "${e}" in batch`;r.add(e)})}function ra(e,t){if(rr(e,t),e.startsWith(`@@`))throw T(`router`,t).plain`Route name "${e}" uses the reserved "${`@@`}" prefix. Routes with this prefix are internal and cannot be modified through the public API.`}function ia(e,t){for(let n of e)ra(n.name,t),n.children&&ia(n.children,t)}function aa(e,t){for(let n of e)i(n.name,t),n.children&&aa(n.children,t)}function oa(e,t){for(let n of e)u(n.name,t),n.children&&oa(n.children,t)}function sa(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 T(`router`,n).plain`Path "${a.path}" is already defined`;e?e.add(a.path):r.set(t,new Set([a.path])),a.children&&i(a.children,t?`${t}.${a.name}`:a.name)}};i(e,t)}function ca(e,t,n){if(ia(t,`addRoute`),aa(t,`addRoute`),oa(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw Pi.plain`Parent route "${n}" does not exist`;ta(t,n??``,t=>{if(e.matcher.hasRoute(t))throw Pi.plain`Route "${t}" already exists`}),na(t,n??``,`addRoute`),sa(t,n??``,`addRoute`)}function la({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:o,logger:s}){let c=new Map,l=new Map;Qi(t,n,r,c,l,s,i);let u=qi(n),{tree:d,matcher:f}=Bi(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function ua(e,t,n,r){return la({definitions:ea(e.definitions,t.map(e=>_i(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:$i(e.config),routeCustomFields:Object.assign(q(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function da(e,t,n,r){return la({definitions:e.map(e=>_i(e)),routesForHandlers:e,config:di(),routeCustomFields:q(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function fa(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function pa(e,t){return{activate:fa(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:fa(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function ma(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??pa(t,r);Object.assign(e.config,t.config),e.routeCustomFields=t.routeCustomFields,e.tree=t.tree,e.matcher=t.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear(),Ki(e,t.resolvedForwardMap);for(let[e,t,n]of i)r.addActivateGuard(e,t,n);for(let[e,t,n]of a)r.addDeactivateGuard(e,t,n)}function J(e){return e===null?e:e||void 0}function ha(e,t){return t==null?t:P(e,t)}function ga(t,n,r,i){let{forwardTo:a,defaultParams:o,defaultSearch:s,decodeParams:c,encodeParams:l,canActivate:u,canDeactivate:d}=i,f=J(a),p=ha(`defaultParams`,J(o)),m=ha(`defaultSearch`,J(s)),h=J(c),g=J(l),_=J(u),v=J(d);p!=null&&e(`updateRoute`,r,p,ki(t,r),"this route's `defaultParams`","Move it to `defaultSearch`"),Yi(h,g,r);let y=f===void 0?void 0:_a(r,f,t.config),b=va(t,r,i),ee=_==null?void 0:n.compileGuardFactory(_,`canActivate`),x=v==null?void 0:n.compileGuardFactory(v,`canDeactivate`);return n.preflightHandlerLimit(ee===void 0?[]:[r],x===void 0?[]:[r],!1),b!==void 0&&(Li(b).length>0?t.routeCustomFields[r]=Fi(b):delete t.routeCustomFields[r]),y!==void 0&&(t.config.forwardMap=y.forwardMap,t.config.forwardFnMap=y.forwardFnMap,Ki(t,y.resolved)),ba(t,r,{defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}),xa(n,`activate`,r,_,ee),xa(n,`deactivate`,r,v,x),{forwardTo:f,defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}}function _a(e,t,n){Ji(t,e);let r=Object.assign(q(null),n.forwardMap),i=Object.assign(q(null),n.forwardFnMap);return t===null?(delete r[e],delete i[e]):typeof t==`string`?(delete i[e],r[e]=t):(delete r[e],i[e]=t),{forwardMap:r,forwardFnMap:i,resolved:qi({...n,forwardMap:r})}}function va(e,t,n){let r;for(let i of Li(n)){if(si.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:O(r,i,a))}return r}function ya(e,t,n){n!==void 0&&(n===null?delete e[t]:e[t]=n)}function ba(e,t,n){if(ya(e.config.defaultParams,t,n.defaultParams),ya(e.config.defaultSearch,t,n.defaultSearch),n.decodeParams!==void 0){if(n.decodeParams===null)delete e.config.decoders[t];else{let r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}}if(n.encodeParams!==void 0){if(n.encodeParams===null)delete e.config.encoders[t];else{let r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}}function xa(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 Sa(e,t,n,r){let i=e;ia(i,`addRoute`),aa(i,void 0),oa(i,void 0),na(i,``,`addRoute`);let a=da(i,``,t,n),o={get definitions(){return an(o.tree)},config:a.config,tree:a.tree,matcher:a.matcher,urlParamsCache:new Map,queryParamsCache:new Map,resolvedForwardMap:a.resolvedForwardMap,hasAnyForward:fi(a.config),routeCustomFields:a.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,treeChanged:Fi(r),revalidating:!1,pendingCanActivate:a.pendingCanActivate,pendingCanDeactivate:a.pendingCanDeactivate};return Ai(o.matcher,o.config,`addRoute`),Ri(o,`matcherOptions`,{writable:!1,configurable:!1}),Ri(o,`treeChanged`,{writable:!1,configurable:!1}),o}function Ca(e,t,n){Ri(e,t,{value:n,writable:!1,configurable:!1})}const wa=Object.freeze,Ta=Object.keys,Ea=[];Object.freeze(Ea);function Da(e){let t=e.split(`.`),n=t.length,r=[t[0]],i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}function Oa(e,t){if(e===t)return!0;let n=Array.isArray(e),r=Array.isArray(t);if(!n&&!r)return ge(e)&&ge(t)?_e(e)===_e(t):se(e,t);let i=n?e:[e],a=r?t:[t],o=i.length;if(o!==a.length)return!1;for(let e=0;e<o;e++)if(!Oa(i[e],a[e]))return!1;return!0}function ka(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of Ta(i))if(!Oa(n.params[e],r.params[e])||!Oa(n.search[e],r.search[e]))return!1;return!0}function Aa(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!ka(a,e,t,n))return o}return a}const ja=new Map;function Y(e){let t=ja.get(e);if(t)return t;let n=Ma(e);return wa(n),ja.set(e,n),n}function Ma(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]:Da(e)}let Na,Pa,Fa=null,Ia,La,Ra=null;function za(e,t,n){if(!t)return{intersection:``,toActivate:Y(e.name),toDeactivate:Ea};let r=n(e.name),i=n(t.name);if(!r&&!i)return{intersection:``,toActivate:Y(e.name),toDeactivate:Y(t.name)};let a=Y(e.name),o=Y(t.name),s=Math.min(o.length,a.length),c=Aa(r??i,e,t,a,o,s),l;if(c>=o.length)l=Ea;else if(c===0&&o.length===1)l=o;else{l=[];for(let e=o.length-1;e>=c;e--)l.push(o[e])}let u=c===0?a:a.slice(c);return{intersection:c>0?o[c-1]:``,toDeactivate:l,toActivate:u}}function Ba(e,t,n){if(Fa!==null&&e===Na&&t===Pa)return Fa;if(Ra!==null&&e===Ia&&t===La)return Ra;let r=za(e,t,n);return Ia=Na,La=Pa,Ra=Fa,Na=e,Pa=t,Fa=r,r}const Va=T(`router`),Ha=T(`router`,`shouldUpdateNode`),Ua=Object.freeze,X=Object.hasOwn;function Wa(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,search:e.search,meta:e.meta}}function Ga(e){let t=kr(e);return t===`preserve`?void 0:t}var Ka=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,n,r){this.#e=Sa(e,t,n,r)}static shouldUpdateNode(e,t){return(n,r)=>{if(!(n&&typeof n==`object`&&`name`in n))throw Ha.type`toState must be valid State object`;if(n.transition?.reload||e===``)return!0;let{intersection:i,toActivate:a,toDeactivate:o}=Ba(n,r,t);return e===i||a.includes(e)?!0:o.includes(e)}}isRevalidating(){return this.#e.revalidating}setDependencies(e){Ca(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){Ca(this.#e,`lifecycleNamespace`,e)}setRootPath(e){Hi(this.#e,e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){Wi(this.#e)}buildPath(e,t,n,r){if(e===A.UNKNOWN_ROUTE)return typeof t.path==`string`?t.path:``;let i=this.#e.config.encoders[e];if(typeof i==`function`){let a=i({params:{...t},search:{...n}});return this.#e.matcher.buildPath(e,a.params??t,a.search??n,this.#c(r))}return this.#e.matcher.buildPath(e,t,n,this.#c(r))}buildPathFromIntent(e,t,n){return e===A.UNKNOWN_ROUTE?this.#r.port.buildPath(e,ye(t,k),n??D):Rr(W(this.#r.port,e,t,n,{resolveForward:!1}),this.#r.port)}matchPath(t,n){let r=n,i=this.#e.matcher.match(t);if(!i)return;let a=Wa(i),{name:o}=a,s=L(a.params),c=L(a.search),l=this.#e.config.decoders[o],u;if(typeof l==`function`){u=l({params:s,search:c});let t=u,n=t.params,r=n??s;u={params:r,search:t.search??c},p(this.#r.checks,m[`matchPath:decoded`],o,n),e(`matchPath`,o,r,this.getQueryParams(o),"the `params` returned by this route's `decodeParams`")}else u={params:s,search:c};let d=W(this.#r.port,o,u.params,u.search),f=d.name;x(`matchPath`,d.name,d.path,this.getQueryParams(d.name));let h=d.path,g=d.query,_=t;if(r.rewritePathOnMatch){let e=this.#e.config.encoders[f],n=typeof e==`function`?e({params:h,search:g}):{params:h,search:g},i=r.trailingSlash;try{_=this.#e.matcher.buildPath(f,n.params??h,n.search??g,{trailingSlash:Ga(i),queryParamsMode:Ar(r.queryParamsMode)}),kr(i)===`preserve`&&(_=xi(t,_))}catch{_=t}}return Vr(d,_)}forwardState(e,t,n){let r=n??D;if(X(this.#e.config.forwardFnMap,e)){let n=this.#e.config.forwardFnMap[e],{target:i,chain:a,params:o}=this.#l(e,n,t);return this.#s(i,a,o,r)}let i=this.#e.resolvedForwardMap[e]??e;if(i!==e&&X(this.#e.config.forwardFnMap,i)){let n=this.#e.config.forwardFnMap[i],{target:a,chain:o,params:s}=this.#l(i,n,t);return this.#s(a,[...this.#o(e),...o],s,r)}return i===e?{name:e,params:t,search:r}:this.#s(i,this.#o(e),t,r)}buildStateResolved(e,t){let n=this.#e.matcher.getSegmentsByName(e);if(n)return Wa({segments:n,params:t,search:{},meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(e,t=k,n=D,r=!1,i=!0){if(this.#i(e,t,n,r,i))return!0;if(!this.#e.hasAnyForward)return!1;let a;try{a=typeof e==`string`?e:String(e)}catch{return!1}if(!X(this.#e.config.forwardMap,a)&&!X(this.#e.config.forwardFnMap,a))return!1;let o;try{o=this.forwardState(e,t,n)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Dynamic forwardTo of route "${hi(e)}" threw while resolving the active-link destination; treating the link as inactive.`,t),!1}return this.#i(o.name,o.params,o.search,r,i)}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){return Ti(this.#e,e)}getQueryParams(e){return ki(this.#e,e)}getPrintedQueryParams(e){return Oi(this.#e.matcher,e)}getStore(){return this.#e}getPort(){return this.#r.port}#i(e,t,n,r,i){try{return this.#a(e,t,n,r,i)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Reading the arguments for route "${hi(e)}" threw while resolving the active-link state; treating the link as inactive.`,t),!1}}#a(e,t,n,r,i){let a=this.#r.getState();if(!a)return!1;let o=a.name;if(o!==e&&!o.startsWith(`${e}.`)&&!e.startsWith(`${o}.`))return!1;let s=W(this.#r.port,e,t,n,{resolveForward:!1});if(r||o===e){let e=Hr(s,``);return!this.#r.areStatesEqual(e,a,!0)||!mi(s.path,a.params)?!1:i||oe(e.search,a.search)}return!(!o.startsWith(`${e}.`)||!mi(s.path,a.params)||!i&&!gi(s.query,a.search))}#o(e){let t=[],n=e;for(;X(this.#e.config.forwardMap,n);)t.push(n),n=this.#e.config.forwardMap[n];return t}#s(e,t,n,r){let i,a;for(let e of t)i=Se(this.#e.config.defaultParams[e],i),a=Se(this.#e.config.defaultSearch[e],a);return{name:e,params:ye(Se(i,n),k),search:ye(Se(a,r),D)}}#c(e){return this.#t?(e!==this.#n&&this.#r.logger.warn(`router.buildPath`,"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957)."),this.#t):(this.#n=e,this.#t=Ua({trailingSlash:Ga(e?.trailingSlash),queryParamsMode:Ar(e?.queryParamsMode)}),this.#t)}#l(e,t,n){let r=F(n),i=new Set([e]),a=[e],o=t(this.#r.getDependency,r),s=0;if(typeof o!=`string`)throw Va.type`forwardTo callback must return a string, got ${typeof o}`;for(;s<100;){if(this.#e.matcher.getSegmentsByName(o)===void 0)throw Va.plain`Route "${o}" does not exist`;if(i.has(o)){let e=[...i,o].join(` → `);throw Va.plain`Circular forwardTo: ${e}`}if(i.add(o),X(this.#e.config.forwardFnMap,o)){let e=this.#e.config.forwardFnMap[o];a.push(o),o=e(this.#r.getDependency,r),s++;continue}let e=this.#e.config.forwardMap[o];if(e!==void 0)a.push(o),o=e,s++;else return{target:o,chain:a,params:r}}throw Va.plain`forwardTo exceeds maximum depth of ${100}`}};const qa=T(`router`),Ja=new N(R.ROUTER_NOT_STARTED),Ya=new N(R.SAME_STATES),Xa=qa.code(R.ROUTER_NOT_STARTED)`cannot commit before the start navigation does — the boot would overwrite it; defer with queueMicrotask/await, or navigate after start() resolves`;Object.freeze(Ja),Object.freeze(Ya),Object.freeze(Xa);const Za=Promise.reject(Ja),Qa=Promise.reject(Ya),$a=Promise.reject(Xa);Za.catch(()=>{}),Qa.catch(()=>{}),$a.catch(()=>{});const eo=new Set([R.SAME_STATES,R.TRANSITION_CANCELLED,R.ROUTER_NOT_STARTED,R.ROUTE_NOT_FOUND,R.CANNOT_ACTIVATE,R.CANNOT_DEACTIVATE,R.ROUTER_ALREADY_STARTED]);function to(e){return e instanceof N&&eo.has(e.code)}const no=new Set([Za,Qa,$a]),ro=Object.freeze;function io(e){let{fromState:t,toDeactivate:n,toActivate:r,intersection:i}=e;ro(n),ro(r);let a={phase:`activating`,reason:`success`,segments:ro({deactivated:n,activated:r,intersection:i})};return t?.name!==void 0&&(a.from=t.name),e.reload!==void 0&&(a.reload=e.reload),e.replace!==void 0&&(a.replace=e.replace),e.redirected!==void 0&&(a.redirected=e.redirected),ro(a)}function ao(e,t){let{toState:n,fromState:r,toDeactivate:i,toActivate:a}=t;if(n.name!==A.UNKNOWN_ROUTE&&!e.hasRoute(n.name)){let i=I(new N(R.ROUTE_NOT_FOUND,{routeName:n.name}));throw e.sendTransitionFail(r,i,t),i}let o=t,s={...n,transition:io(t)},c=ro(s);t.toState=c;let l=e.canCommitTransition(o);if(!l)throw I(new N(R.TRANSITION_CANCELLED));for(let n of i)!a.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n,l);return e.sendTransitionDone(o),c}const oo=Object.entries;function so(e){return e instanceof N&&e.code===R.TRANSITION_CANCELLED}function co(e){return so(e)?e:I(new N(R.TRANSITION_CANCELLED,{reason:e}))}function lo(e,t,n,r){so(t)?e.cancelIfInFlight(r,t):e.isTransitioning()&&e.sendTransitionFail(n,t,r)}function uo(e,t,n){if(he(e)&&po(e,t,n),e instanceof DOMException&&e.name===`AbortError`)throw I(new N(R.TRANSITION_CANCELLED));if(so(e))throw e;po(e,t,n)}function fo(e){return he(e)?mo(e,R.CANNOT_DEACTIVATE):e}function po(e,t,n){throw e instanceof N?mo(e,t):I(new N(t,go(e,n)))}function mo(e,t){let{code:n,message:r,...i}=e.toJSON(),a=new N(n,{...i,message:r});return a.setCode(t),a.stack=e.stack??``,I(a)}const ho=new Set([`code`,`segment`,`path`,`then`]);function go(e,t){let n={segment:t};if(e instanceof Error){let t=e.message,r=e.stack,i=`cause`in e?e.cause:void 0;return{...n,message:t,stack:r,...i!==void 0&&{cause:i}}}if(e&&typeof e==`object`){let t={};for(let[n,r]of oo(e))n!==`__proto__`&&!ho.has(n)&&O(t,n,r);return{...n,...t}}return n}async function _o(e,t,n,r){let i;try{i=await e}catch(e){uo(e,t,n);return}if(i!==!0)throw i!==!1&&r(n,i),I(new N(t,{segment:n}))}function vo(e,t,n,r,i,a,o,s,c,l,u){if(!c())throw I(new N(R.TRANSITION_CANCELLED));if(e===1){let n=l();return n===void 0?void 0:{phase:e,index:t+1,pending:n}}let d=n[t],f=r.get(d);if(!f)return;let p;try{p=f(a,o,s)}catch(e){uo(e,i,d)}if(p!==!0){if(p!==!1){let n=yo(p,i,d);if(n!==void 0)return{phase:e,index:t+1,pending:n};u(d,p)}throw I(new N(i,{segment:d}))}}function yo(e,t,n){let r;try{r=e?.then}catch(e){uo(e,t,n)}if(typeof r==`function`)return new Promise((t,n)=>{Reflect.apply(r,e,[t,n])})}function bo(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=e===1,h=e===0;if(!m&&!(h?o:s))return;let g=h?i:a,_=m?1:g.length,v=h?n:r,y=h?R.CANNOT_DEACTIVATE:R.CANNOT_ACTIVATE;for(let n=t;n<_;n++){let t=vo(e,n,g,v,y,c,l,u,d,f,p);if(t!==void 0)return t}}function xo(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let m=f;m<=2;m++){let h=bo(m,m===f?p:0,e,t,n,r,i,a,o,s,c,l,u,d);if(h!==void 0)return h}}async function So(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=e;for(;p!==void 0;){if(p.phase===1)await p.pending;else{let e=p.phase===0;await _o(p.pending,e?R.CANNOT_DEACTIVATE:R.CANNOT_ACTIVATE,(e?r:i)[p.index-1],f)}p=xo(t,n,r,i,a,o,s,c,l,u,d,f,p.phase,p.index)}}function Co(e,t,n,r,i,a,o,s,c,l,u,d){let f=xo(e,t,n,r,i,a,o,s,c,l,u,d,0,0);return f===void 0?void 0:So(f,e,t,n,r,i,a,o,s,c,l,u,d)}const wo=Object.freeze,To=Object.freeze([]),Eo=new Map;function Do(e,t){return t?wo({...e,replace:!0}):e}function Oo(e,t,n,r){return!!e&&!t&&!n&&e.path===r.path}function ko(e,t){if(e.size===0)return!1;for(let n of t)if(e.has(n))return!0;return!1}function Ao(e){let t=e.controller;if(t!==void 0)return t;let n=new AbortController;return e.cancelReason!==void 0&&(n.abort(e.cancelReason),C(n.signal.reason)),e.controller=n,n}function jo(e,t){t.externalSignal!==void 0&&t.cancelReason===void 0&&t.hasGuards&&e.bridgeExternalSignal(t)}function Mo(e,t,n,r,i,a,o,s,c,l){zo(e,a);let u=e.hasLeaveListeners()||e.hasPreCommitListeners(),d={toState:t,fromState:n,opts:r,suspendable:i!==void 0||u,forceDeactivate:l,toDeactivate:To,toActivate:To,intersection:``,canDeactivateFunctions:Eo,canActivateFunctions:Eo,shouldDeactivate:!1,shouldActivate:!1,hasGuards:!1,controller:void 0,cancelReason:void 0,detachExternalBridge:void 0,externalSignal:i,reload:o,replace:s,redirected:c};if(!e.startTransition(d))throw I(new N(R.TRANSITION_CANCELLED));return d}function No(e,t){return e.sendLeaveApprove(t),ao(e,t)}function Po(e,t){let[n,r]=e.getLifecycleFunctions(),{toDeactivate:i,toActivate:a,intersection:o}=Ba(t.toState,t.fromState,t=>e.getMetaForState(t));t.canDeactivateFunctions=n,t.canActivateFunctions=r,t.toDeactivate=i,t.toActivate=a,t.intersection=o,t.shouldDeactivate=!!t.fromState&&!t.forceDeactivate&&i.length>0,t.shouldActivate=t.toState.name!==A.UNKNOWN_ROUTE&&a.length>0,t.hasGuards=t.shouldDeactivate&&ko(n,i)||t.shouldActivate&&ko(r,a)}function Fo(e,t,n){let r,i;try{let a=de(n),o=a?.aborted===!0?a:void 0;n=pe(n),r=e.getState();let s=fe(n,`reload`),c=fe(n,`force`),l=fe(n,`replace`),u=fe(n,`redirected`),d=fe(n,`forceDeactivate`)===!0,f=r?.name===A.UNKNOWN_ROUTE&&!l,p=f||l;if(n=Do(n,f),Oo(r,s,c,t))return e.emitTransitionError(t,r,Ya),Qa;let m=Mo(e,t,r,n,a,o,s,p,u,d);i=m;let h=m.externalSignal;if(h?.aborted===!0&&e.cancelNavigation(h.reason),Po(e,m),jo(e,m),!m.hasGuards&&!m.suspendable)return No(e,m);let{canDeactivateFunctions:g,canActivateFunctions:_,toDeactivate:v,toActivate:y,shouldDeactivate:b,shouldActivate:ee,hasGuards:x}=m,S=t;if(!x){let t=Ro(e,m);if(t!==void 0)return t}if(x){let n=Ao(m),i=()=>!n.signal.aborted,a=n.signal,o=Co(g,_,v,y,b,ee,t,r,a,i,()=>{if(e.sendLeaveApprove(m),e.hasLeaveListeners())return e.awaitLeaveListeners(S,r,a)},e.warnNonBooleanGuard);if(o!==void 0)return Io(e,o,m,n);if(!i())throw I(new N(R.TRANSITION_CANCELLED))}return ao(e,m)}catch(t){let n=Lo(e,t,{nav:i,fromState:r});return C(n),Promise.reject(n)}}async function Io(e,t,n,r){let i=()=>!r.signal.aborted,a=n.externalSignal,o,s=!1,c,l=new Promise(e=>{r.signal.aborted?e():(o=()=>{e()},r.signal.addEventListener(`abort`,o,{once:!0}))});t.catch(()=>{});try{if(a?.aborted)throw I(new N(R.TRANSITION_CANCELLED,{reason:a.reason}));if(await Promise.race([t,l]),!i())throw I(new N(R.TRANSITION_CANCELLED));let r=ao(e,n);return s=!0,r}catch(t){let r=i()?t:co(t);throw c=r,lo(e,r,n.fromState,n),C(r),r}finally{o&&r.signal.removeEventListener(`abort`,o),s||(r.abort(c),C(r.signal.reason))}}function Lo(e,t,n){let{nav:r}=n;if(e.dispatchAbort(r?.controller,t),r!==void 0){let i=r.cancelReason===void 0?t:co(t);return lo(e,i,n.fromState,r),i}return t}function Ro(e,t){let{toState:n,fromState:r}=t;if(e.hasLeaveListeners()&&Ao(t),e.sendLeaveApprove(t),e.hasLeaveListeners()){let i=Ao(t),a=e.awaitLeaveListeners(n,r,i.signal);return a===void 0?void 0:Io(e,a,t,i)}}function zo(e,t){if(e.isTransitioning()&&(e.logger.warn(`router`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),e.cancelNavigation()),t!==void 0)throw I(new N(R.TRANSITION_CANCELLED,{reason:t.reason}))}const Bo=Object.freeze,Vo=T(`router`,`navigateToNotFound`),Ho=Object.freeze([A.UNKNOWN_ROUTE]),Uo=Object.freeze({replace:!0});function Wo(e,t,n){zo(e,void 0);let r=e.getState(),i=r?Y(r.name).toReversed():[];Bo(i);let a={deactivated:i,activated:Ho,intersection:``};Bo(a);let o={phase:`activating`,...r&&{from:r.name},reason:`success`,replace:!0,segments:a};Bo(o);let s={name:A.UNKNOWN_ROUTE,params:k,search:D,path:t,transition:o,context:{}};if(Bo(s),n&&r!==void 0&&!e.canDeactivateCurrent(i,s,r)){let n=Vo.code(R.CANNOT_DEACTIVATE,{path:t})`a canDeactivate guard on "${r.name}" refused to leave for ${t}`;throw e.emitTransitionError(void 0,r,n),n}return e.systemCommit(s,r,Uo)}function Go(e,t){return Wo(e,t,!0)}function Ko(e,t){return Wo(e,t,!1)}const qo=T(`router`,`navigateToState`),Jo=T(`router`,`navigateToDefault`);var Yo=class{#e;#t;#n=0;#r=0;setDependencies(e){this.#e=e,this.#t=t=>{to(t)||e.logger.error(`router`,`Unexpected navigation error`,t)}}navigate(e,t,n,r){return this.#i(this.#a(e,t,n,r))}navigateToState(e,t){return this.#i(this.#o(e,t))}navigateToDefault(e){return this.#i(this.#c(e))}navigateToNotFound(e){this.#r++;try{return Go(this.#e,e)}finally{this.#r--}}isCommittingNotFound(){return this.#r>0}revalidateToNotFound(e){return Ko(this.#e,e)}isPreparing(){return this.#n>0}#i(e){return e instanceof Promise&&!no.has(e)&&e.catch(this.#t),e}#a(e,t,n,r){let i=this.#e;if(!i.canNavigate())return i.isStarting()?$a:Za;let a;this.#n++;try{a=i.buildNavigateState(e,t,n)}catch(e){return Promise.reject(e)}finally{this.#n--}if(!a){let t=I(new N(R.ROUTE_NOT_FOUND,{routeName:e}));return i.emitTransitionError(void 0,i.getState(),t),Promise.reject(t)}return Fo(this.#e,a,r)}#o(e,n){let i=this.#e;if(!i.canNavigate())return i.isStarting()?$a:Za;let a=e.name;if(a!==A.UNKNOWN_ROUTE&&!i.hasRoute(a)){let e=I(new N(R.ROUTE_NOT_FOUND,{routeName:a}));return i.emitTransitionError(void 0,i.getState(),e),Promise.reject(e)}let o=r(e.params,i.getQueryParams(a));if(o!==void 0){let e=qo.code(R.WRONG_CHANNEL,{routeName:a})`${t(a,o,"`state.params`")}`;return i.emitTransitionError(void 0,i.getState(),e),Promise.reject(e)}let s;try{s=this.#s(e,a)}catch(e){return Promise.reject(e)}return Fo(this.#e,s,n)}#s(e,t){let n={name:t,params:ve(e.params,k),search:ve(e.search,D),path:e.path,context:{...e.context},transition:re};return ce(n)}#c(e){let t=this.#e;if(!t.getOptions().defaultRoute)return Promise.reject(Jo.code(R.ROUTE_NOT_FOUND)`no defaultRoute is configured — pass one to createRouter, or navigate to a route by name`);let n,r,i;this.#n++;try{({route:n,params:r,search:i}=t.resolveDefault())}catch(e){return Promise.reject(e)}finally{this.#n--}return n?typeof n==`string`?this.#a(n,r,i,e):Promise.reject(Jo.code(R.ROUTE_NOT_FOUND)`defaultRoute resolved to ${typeof n}, which cannot name a route`):Promise.reject(Jo.code(R.ROUTE_NOT_FOUND)`defaultRoute resolved to an empty name`)}};const Xo={},Zo=T(`router`,`start`),Qo=Object.freeze({replace:!0});function $o(e){return e instanceof N&&e.code===R.ROUTE_NOT_FOUND}var es=class{#e;setDependencies(e){this.#e=e}async start(e){let t=this.#e;if(t.isIdle())throw I(new N(R.TRANSITION_CANCELLED));let n=t.getOptions();if(typeof e!=`string`)throw Zo.type`path must be a string, got ${typeof e}`;let r=t.getRootPath(),i=t.matchPath(e);if(!i&&!n.allowNotFound){let t=new N(R.ROUTE_NOT_FOUND,{path:e});throw I(t)}if(t.completeStart(),i!==void 0&&t.getRootPath()!==r&&(i=t.matchPath(e),!i&&!n.allowNotFound))throw I(new N(R.ROUTE_NOT_FOUND,{path:e}));if(i)try{return await t.navigateToState(i,Qo)}catch(r){if(!n.allowNotFound||!$o(r))throw r;return t.navigateToNotFound(e)}return t.navigateToNotFound(e)}};const ts={},ns=Object.create,rs=Object.entries,is=Object.hasOwn,as=Object.values,os=new WeakMap;function ss(e,t,n){if(typeof n==`string`)return{target:n,when:void 0,update:void 0};let r=n.when,i=n.update;if(r!==void 0&&typeof r!=`function`)throw j.plain`transitions["${e}"]["${t}"].when is not a function`;if(i!==void 0&&typeof i!=`function`)throw j.plain`transitions["${e}"]["${t}"].update is not a function`;return{target:n.target,when:r,update:i}}function cs(e){let t=os.get(e);if(t!==void 0)return t;let n=e,r=ns(null);for(let[e,t]of rs(n)){let n=ns(null);for(let[r,i]of rs(t))i!==void 0&&(n[r]=ss(e,r,i));r[e]=n}for(let e of as(r))for(let t of as(e))if(t!==void 0&&r[t.target]===void 0)throw j.plain`state "${t.target}" is not declared in config.transitions`;return os.set(e,r),r}var ls=class{#e;#t;#n=0;#r=null;#i;#a;#o=[];constructor(e){let t=e.initial;if(this.#e=t,this.#i=e.context,this.#a=cs(e.transitions),this.#a[t]===void 0)throw j.plain`state "${t}" is not declared in config.transitions`;this.#t=this.#a[t]}send(e,t){let n=this.#t[e];if(n===void 0)return this.#e;let r=t,i=n.when;if(i!==void 0&&!i(this.#i,r))return this.#e;let a=n.target,o=n.update,s=this.#e;if(this.#e=a,this.#t=this.#a[a],o?.(this.#i,r),this.#r!==null){let t=this.#r.get(s)?.get(e);t!==void 0&&t(r)}if(this.#n>0){let t={from:s,to:a,event:e,payload:r};for(let e of this.#o)e!==null&&e(t)}return this.#e}canSend(e,t){let n=this.#t[e];return n===void 0?!1:n.when===void 0||n.when(this.#i,t)}getState(){return this.#e}getContext(){return this.#i}on(e,t,n){let r=this.#a[e];if(r===void 0)throw j.plain`state "${e}" is not declared in config.transitions`;if(!is(r,t))throw j.plain`event "${t}" has no edge from state "${e}"`;this.#r??=new Map;let i=this.#r.get(e);i||(i=new Map,this.#r.set(e,i));let a=n;return i.set(t,a),()=>{let n=this.#r?.get(e);n?.get(t)===a&&n.delete(t)}}onTransition(e){let t=this.#o.indexOf(null),n;t===-1?(n=this.#o.length,this.#o.push(e)):(this.#o[t]=e,n=t),this.#n++;let r=!0;return()=>{r&&(r=!1,this.#o[n]=null,this.#n--)}}};const Z={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},Q={START:`START`,STARTED:`STARTED`,NAVIGATE:`NAVIGATE`,LEAVE_APPROVE:`LEAVE_APPROVE`,COMPLETE:`COMPLETE`,FAIL:`FAIL`,CANCEL:`CANCEL`,STOP:`STOP`,DISPOSE:`DISPOSE`,SYSTEM_COMMIT:`SYSTEM_COMMIT`};function us(){return{inflight:void 0,current:void 0,previous:void 0}}const ds=(e,t)=>t?.nav===void 0||t.nav===e.inflight,fs=(e,t)=>t!==void 0&&t===e.inflight&&t.externalSignal?.aborted!==!0,ps=(e,t)=>{e.previous=e.current,e.current=ce(t)},ms=(e,t)=>{ps(e,t.toState),e.inflight=void 0},hs=(e,t)=>{ps(e,t.toState)},gs=e=>{e.previous=e.current,e.current=void 0},_s=e=>{e.current=void 0,e.previous=void 0,e.inflight=void 0},vs=(e,t)=>{e.inflight=t},ys={[Z.IDLE]:{[Q.START]:Z.STARTING,[Q.DISPOSE]:{target:Z.DISPOSED,update:_s}},[Z.STARTING]:{[Q.STARTED]:Z.READY,[Q.FAIL]:Z.IDLE,[Q.STOP]:{target:Z.IDLE,update:gs},[Q.DISPOSE]:{target:Z.DISPOSED,update:_s}},[Z.READY]:{[Q.NAVIGATE]:{target:Z.TRANSITION_STARTED,update:vs},[Q.SYSTEM_COMMIT]:{target:Z.READY,update:hs},[Q.STOP]:{target:Z.IDLE,update:gs},[Q.DISPOSE]:{target:Z.DISPOSED,update:_s}},[Z.TRANSITION_STARTED]:{[Q.NAVIGATE]:{target:Z.TRANSITION_STARTED,update:vs},[Q.LEAVE_APPROVE]:Z.LEAVE_APPROVED,[Q.CANCEL]:Z.READY,[Q.FAIL]:{target:Z.READY,when:ds},[Q.DISPOSE]:{target:Z.DISPOSED,update:_s}},[Z.LEAVE_APPROVED]:{[Q.NAVIGATE]:{target:Z.TRANSITION_STARTED,update:vs},[Q.COMPLETE]:{target:Z.READY,when:fs,update:ms},[Q.CANCEL]:Z.READY,[Q.FAIL]:{target:Z.READY,when:ds},[Q.DISPOSE]:{target:Z.DISPOSED,update:_s}},[Z.DISPOSED]:{}};function bs(){return new ls({initial:Z.IDLE,context:us(),transitions:ys})}const xs=T(`router`,`subscribe`),Ss=T(`router`,`subscribeChanges`),Cs=T(`router`,`subscribeDiagnostic`),ws=T(`router`,`subscribeLeave`),Ts=Object.freeze,Es=`TREE_CHANGED`;function Ds(e){return e instanceof Error?e:Error(String(e))}function Os(e,t,n){return new Promise((r,i)=>{let a=()=>{let e=n.reason;i(e instanceof N&&e.code===R.TRANSITION_CANCELLED?e:I(new N(R.TRANSITION_CANCELLED,{reason:e})))};n.aborted?(Promise.allSettled(e),a()):(n.addEventListener(`abort`,a,{once:!0}),Promise.allSettled(e).then(e=>{if(n.removeEventListener(`abort`,a),n.aborted)return;if(t!==void 0){i(Ds(fo(t)));return}let o=e.find(e=>e.status===`rejected`);o===void 0?r():i(Ds(fo(o.reason)))}))})}function ks(e,t,n){return e.addEventListener(`abort`,t,{once:!0}),()=>{n(),e.removeEventListener(`abort`,t)}}var As=class{#e;#t;#n=[];#r=0;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#o()}static validateSubscribeListener(e){if(typeof e!=`function`)throw xs.type`Expected a function. For Observable pattern use observable(router) from @real-router/rx`}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw ws.type`Expected a function`}emitRouterStart(){this.#r++;try{this.#t.emit(w.ROUTER_START)}finally{this.#r--}}emitRouterStop(){this.#t.emit(w.ROUTER_STOP)}emitTransitionStart(e,t,n){this.#r++;try{this.#t.emit(w.TRANSITION_START,e,t)}finally{this.#r--}}emitTransitionSuccess(e,t,n){this.#r++;try{this.#t.emit(w.TRANSITION_SUCCESS,e,t,n)}finally{this.#r--}}emitTransitionError(e,t,n){this.#r++;try{this.#t.emit(w.TRANSITION_ERROR,e,t,n)}finally{this.#r--}}emitTransitionCancel(e,t){this.#r++;try{this.#t.emit(w.TRANSITION_CANCEL,e,t)}finally{this.#r--}}emitTransitionLeaveApprove(e,t){this.#r++;try{this.#t.emit(w.TRANSITION_LEAVE_APPROVE,e,t)}finally{this.#r--}}dispatchAbort(e,t){if(e!==void 0){this.#r++;try{e.abort(t),C(e.signal.reason)}finally{this.#r--}}}isProcessing(){return this.#r>0}emitTreeChanged(e){this.#t.emit(Es,e)}isEmittingTreeChanged(){return this.#t.isDispatching(Es)}subscribeTreeChanged(e){if(this.isDisposed())throw Ss.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(Es,t=>e(t))}emitDiagnostic(e,...t){this.#t.emit(e,...t)}subscribeDiagnostic(e,t){if(this.isDisposed())throw Cs.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(e,(...e)=>t(...e))}treeChangedListenerCount(){return this.#t.listenerCount(Es)}diagnosticListenerCount(e){return this.#t.listenerCount(e)}sendStart(){this.#e.send(Q.START)}sendStop(){this.#e.send(Q.STOP)}sendStopForDispose(){this.#r++;try{this.#e.send(Q.STOP)}finally{this.#r--}}sendDispose(){this.#e.send(Q.DISPOSE)}sendStarted(){this.#e.send(Q.STARTED)}sendNavigate(e){return this.#e.send(Q.NAVIGATE,e)===Z.TRANSITION_STARTED}canCommitTransition(e){return this.#e.canSend(Q.COMPLETE,e)}sendComplete(e){this.#e.send(Q.COMPLETE,e)}sendLeaveApprove(e){this.#e.send(Q.LEAVE_APPROVE,e)}sendFail(e,t,n){this.#e.send(Q.FAIL,{nav:n,fromState:e,error:t})}sendCancel(e,t){this.#e.send(Q.CANCEL,{fromState:e,reason:t})}systemCommit(e,t){let{toState:n}=e,r=n.transition,i={name:t,params:ve(n.params,k),search:ve(n.search,D),path:n.path,context:{...n.context},...r!=null&&{transition:be(r)}};if(!this.#e.canSend(Q.SYSTEM_COMMIT))throw I(this.#a());return this.#e.send(Q.SYSTEM_COMMIT,{...e,toState:i}),i}canBeginTransition(){return this.#e.canSend(Q.NAVIGATE)}canStart(){return this.#e.canSend(Q.START)}canCancel(){return this.#e.canSend(Q.CANCEL)}isActive(){let e=this.#e.getState();return e!==Z.IDLE&&e!==Z.DISPOSED}isDisposed(){return this.#e.getState()===Z.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===Z.TRANSITION_STARTED||e===Z.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===Z.LEAVE_APPROVED}isReady(){return this.#e.getState()===Z.READY}isStarting(){return this.#e.getState()===Z.STARTING}isIdle(){return this.#e.getState()===Z.IDLE}addEventListener(e,t,n){return this.#i(e,n),this.#t.on(e,t)}subscribe(e){if(this.isDisposed()||(this.#i(w.TRANSITION_SUCCESS,`subscribe`),this.isDisposed()))throw xs.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(w.TRANSITION_SUCCESS,(t,n)=>e({route:t,previousRoute:n}))}subscribeLeave(e){if(this.isDisposed())throw ws.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;this.#n.push(e);let t=!1;return()=>{if(t)return;t=!0;let n=this.#n.indexOf(e);n!==-1&&this.#n.splice(n,1)}}hasLeaveListeners(){return this.#n.length>0}hasPreCommitListeners(){return this.#t.listenerCount(w.TRANSITION_START)>0||this.#t.listenerCount(w.TRANSITION_LEAVE_APPROVE)>0}awaitLeaveListeners(e,t,n){if(t===void 0)return;let r=Ts({route:t,nextRoute:e,signal:n}),i,a,o=[...this.#n];this.#r++;try{for(let e of o)try{let t=e(r);t!==void 0&&typeof t.then==`function`&&(i??=[],i.push(t))}catch(e){a===void 0&&(a=e)}}finally{this.#r--}if(i===void 0){if(a!==void 0)throw Ds(fo(a))}else return Os(i,a,n)}clearAll(){this.#t.clearAll(),this.#n.length=0}setLimits(e){this.#t.setLimits(e)}sendCancelIfPossible(e,t){this.canCancel()&&this.sendCancel(e,t)}sendCancelIfInFlight(e,t,n){this.#e.getContext().inflight===e&&this.sendCancelIfPossible(t,n)}bridgeExternalSignal(e){let t=e.externalSignal;if(t===void 0||e.detachExternalBridge!==void 0)return ts;let n=ks(t,()=>{this.sendCancelIfPossible(this.#e.getContext().current,t.reason)},()=>{e.detachExternalBridge=void 0});return e.cancelReason===void 0?e.detachExternalBridge=n:n(),ts}#i(e,t){this.emitDiagnostic(y.LISTENER_COUNT,this.#t.listenerCount(e)+1,e,t)}#a(){if(this.isDisposed())return new N(R.ROUTER_DISPOSED,{message:`[router] cannot commit a state on a disposed router — dispose() is terminal`});let e;return e=this.isTransitioning()?`[router] cannot commit a state while a transition is in flight — the navigation in progress commits its own`:this.isStarting()?`[router] cannot commit before the start navigation does — the boot would overwrite it; await start() first`:`[router] cannot commit a state before the router has started`,new N(R.ROUTER_NOT_STARTED,{message:e})}#o(){let e=this.#e;e.on(Z.STARTING,Q.STARTED,()=>{this.emitRouterStart()}),e.on(Z.READY,Q.STOP,()=>{this.emitRouterStop()});let t=e=>{let t=e.externalSignal!==void 0&&(this.hasLeaveListeners()||this.hasPreCommitListeners())?this.bridgeExternalSignal(e):ts;this.emitTransitionStart(e.toState,e.fromState,t)};e.on(Z.READY,Q.NAVIGATE,t),e.on(Z.TRANSITION_STARTED,Q.NAVIGATE,t),e.on(Z.LEAVE_APPROVED,Q.NAVIGATE,t),e.on(Z.TRANSITION_STARTED,Q.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(Z.LEAVE_APPROVED,Q.COMPLETE,e=>{e.detachExternalBridge?.(),this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let n=e=>{let{fromState:t,reason:n}=e,r=this.#e.getContext().inflight,i=n??I(new N(R.TRANSITION_CANCELLED));r.cancelReason=i,this.dispatchAbort(r.controller,i),r.detachExternalBridge?.(),this.emitTransitionCancel(r.toState,t)};e.on(Z.TRANSITION_STARTED,Q.CANCEL,n),e.on(Z.LEAVE_APPROVED,Q.CANCEL,n),e.on(Z.READY,Q.SYSTEM_COMMIT,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let r=e=>{let t=this.#e.getContext().inflight;t?.detachExternalBridge?.(),this.emitTransitionError(t?.toState,e.fromState,e.error)};e.on(Z.LEAVE_APPROVED,Q.FAIL,r),e.on(Z.TRANSITION_STARTED,Q.FAIL,r),e.on(Z.STARTING,Q.FAIL,e=>{this.emitTransitionError(void 0,e.fromState,e.error)})}};const js=Object.freeze;function Ms(e){return Ps(e)&&!Object.isFrozen(e)&&e!==Er.defaultParams&&e!==Er.defaultSearch}function Ns(e){let{defaultParams:t,defaultSearch:n}=e;return js({...Ms(t)&&{defaultParams:new WeakRef(t)},...Ms(n)&&{defaultSearch:new WeakRef(n)}})}function Ps(e){return typeof e==`object`&&!!e}function Fs(e){let t={...e};return e.limits!=null&&(t.limits=P(`limits`,e.limits)),Ps(e.defaultParams)&&(t.defaultParams=P(`defaultParams`,e.defaultParams)),Ps(e.defaultSearch)&&(t.defaultSearch=P(`defaultSearch`,e.defaultSearch)),t}const Is=Object.keys,Ls=Object.freeze;function Rs(e={}){let t={...me,...e};return Ls({maxDependencies:Number(t.maxDependencies),maxPlugins:Number(t.maxPlugins),maxListeners:Number(t.maxListeners),warnListeners:Number(t.warnListeners),maxLifecycleHandlers:Number(t.maxLifecycleHandlers)})}function zs(e){return e==null?void 0:Ls(Is(e))}const Bs=T(`router`),Vs=Object.freeze,Hs=Object.freeze({});function Us(e,t){let n;try{n=t[e]}catch(t){throw Bs.type({cause:t})`Invalid "queryParams.${e}": reading it threw.`}if(n!=null){if(typeof n==`string`)return n;try{return String(n)}catch(t){throw Bs.type({cause:t})`Invalid "queryParams.${e}": its value cannot be converted to a string.`}}}function Ws(e){if(e==null)return`default`;try{return String(e)}catch(e){throw Bs.type({cause:e})`Invalid "urlParamsEncoding": coercing it threw.`}}function Gs(e){if(!e)return Hs;let t=Us(`arrayFormat`,e),n=Us(`booleanFormat`,e),r=Us(`nullFormat`,e),i=Us(`numberFormat`,e);return Vs({...t!==void 0&&{arrayFormat:t},...n!==void 0&&{booleanFormat:n},...r!==void 0&&{nullFormat:r},...i!==void 0&&{numberFormat:i}})}function Ks(e){return Vs({strictTrailingSlash:e.trailingSlash===`strict`,caseSensitive:e.caseSensitive,strictQueryParams:e.queryParamsMode===`strict`,urlParamsEncoding:Ws(e.urlParamsEncoding),queryParams:Gs(e.queryParams)})}const qs=new N(R.ROUTER_ALREADY_STARTED);Object.freeze(qs);const Js=T(`router`),Ys={maxListeners:0,warnListeners:0};var Xs=class{#e=new Map;#t=new Set;#n=null;#r=Ys;#i;#a;constructor(e){e?.limits&&(this.#r=e.limits),this.#i=e?.onListenerError??null,this.#a=e?.onListenerWarn??null}setLimits(e){this.#r=e}on(e,t){let n=this.#e.get(e),r=n?.size??0;if(n?.has(t))throw Js.plain`Duplicate listener for "${e}"`;let{maxListeners:i,warnListeners:a}=this.#r;if(i!==0&&r>=i)throw Js.plain`Listener limit (${i}) reached for "${e}"`;a!==0&&r===a&&this.#a!==null&&(this.#n??=new Set,this.#n.has(e)||(this.#a(e,a),this.#n.add(e)));let o=n;return o===void 0&&(o=new Set,this.#e.set(e,o)),o.add(t),()=>{this.off(e,t)}}off(e,t){let n=this.#e.get(e);n&&(n.delete(t),n.size===0&&(this.#e.delete(e),this.#n?.delete(e)))}emit(e,t,n,r,i){let a=this.#e.get(e);if(!a||a.size===0||this.#t.has(e))return;let o=arguments.length-1;this.#t.add(e);try{if(a.size===1){let[s]=a;this.#o(e,s,o,t,n,r,i)}else{let s=[...a];for(let a of s)this.#o(e,a,o,t,n,r,i)}}finally{this.#t.delete(e)}}clearAll(){this.#e.clear(),this.#n=null}listenerCount(e){return this.#e.get(e)?.size??0}isDispatching(e){return this.#t.has(e)}#o(e,t,n,r,i,a,o){try{let s=this.#s(t,n,r,i,a,o),c=s?.then;typeof c==`function`&&new Promise((e,t)=>{c.call(s,e,t)}).catch(t=>{this.#i?.(e,t)})}catch(t){this.#i?.(e,t)}}#s(e,t,n,r,i,a){switch(t){case 0:return e();case 1:return e(n);case 2:return e(n,r);case 3:return e(n,r,i);default:return e(n,r,i,a)}}};const Zs=Object.freeze({log:0,warn:1,error:2}),Qs=Object.freeze({all:0,"warn-error":1,"error-only":2,none:3}),$s=Object.hasOwn;var ec=class{#e={level:`all`,callback:void 0,callbackIgnoresLevel:!1};#t=0;#n=!1;constructor(e){e&&this.configure(e)}isInCallback(){return this.#n}configure(e){let t=_r(e),n=t.level;n!==void 0&&(this.#e.level=n,this.#t=Qs[n]),$s(t,`callback`)&&(this.#e.callback=t.callback),t.callbackIgnoresLevel!==void 0&&(this.#e.callbackIgnoresLevel=t.callbackIgnoresLevel)}getConfig(){return{level:this.#e.level,callback:this.#e.callback,callbackIgnoresLevel:this.#e.callbackIgnoresLevel}}log(e,t,...n){this.#r(`log`,e,t,n)}warn(e,t,...n){this.#r(`warn`,e,t,n)}error(e,t,...n){this.#r(`error`,e,t,n)}#r(e,t,n,r){if(this.#e.level===`none`&&!this.#e.callbackIgnoresLevel)return;let i=Zs[e]<this.#t;i||this.#i(e,t,n,r),this.#a(e,t,n,i,r)}#i(e,t,n,r){if(typeof console<`u`&&typeof console[e]==`function`){let i=t?`[${t}] ${n}`:n;console[e](i,...r)}}#a(e,t,n,r,i){if(!(!this.#e.callback||!this.#e.callbackIgnoresLevel&&r)&&!this.#n){this.#n=!0;try{let r=this.#e.callback(e,t,n,...i);r!=null&&typeof r.then==`function`&&Promise.resolve(r).catch(e=>{this.#o(`[router] Error in async callback:`,e)})}catch(e){this.#o(`[router] Error in callback:`,e)}finally{this.#n=!1}}}#o(e,t){typeof console<`u`&&typeof console.error==`function`&&console.error(e,t)}};function tc(e){let t=t=>Sr(e.dependenciesStore,t),n=nc(e.router,t),r=sc(e);rc(e),ic(e,n),ac(e,r,t),oc(e,n),cc(e,r,t),lc(e),uc(e,r)}function nc(e,t){return n=>n(e,t)}function rc(e){e.eventBus.setLimits({maxListeners:e.limits.maxListeners,warnListeners:e.limits.warnListeners})}function ic(e,t){let n={logger:h(e.router).logger,compileFactory:t,runChecks:(t,...n)=>{p(h(e.router).checks,t,...n)},hasChecks:t=>v(h(e.router).checks,t),emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)},diagnosticListenerCount:t=>e.eventBus.diagnosticListenerCount(t)};e.routeLifecycle.setDependencies(n)}function ac(e,t,n){let r={logger:h(e.router).logger,checks:h(e.router).checks,port:t,addActivateGuard:(t,n,r)=>{e.routeLifecycle.addCanActivate(t,n,!0,r)},addDeactivateGuard:(t,n,r)=>{e.routeLifecycle.addCanDeactivate(t,n,!0,r)},compileGuard:(t,n)=>e.routeLifecycle.compileGuardFactory(t,n),getState:()=>e.state.get(),areStatesEqual:(t,n,r)=>e.state.areStatesEqual(t,n,r),getDependency:n};e.routes.setDependencies(r),e.routes.setLifecycleNamespace(e.routeLifecycle)}function oc(e,t){let n={logger:h(e.router).logger,addEventListener:(t,n)=>e.eventBus.addEventListener(t,n,`usePlugin`),canNavigate:()=>e.eventBus.canBeginTransition(),compileFactory:t,isDisposed:()=>e.eventBus.isDisposed(),runChecks:(t,...n)=>{p(h(e.router).checks,t,...n)},emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)}};e.plugins.setDependencies(n)}function sc(e){let t=h(e.router),n=e.routes.getStore(),r=(t,n)=>{e.eventBus.emitDiagnostic(y.UNDECLARED_PARAM_KEY,t,n)},i=(t,n)=>{e.eventBus.emitDiagnostic(y.DROPPED_QUERY_KEY,t,n)},a=t=>{let r=e.routes.getUrlParams(t),i=n.tree.paramMeta.urlParams;return i.length===0?r:[...i,...r]},o=t=>{let{name:r}=t,i={encode:n.config.encoders[r],decode:n.config.decoders[r]};(i.encode!==void 0||i.decode!==void 0)&&e.eventBus.emitDiagnostic(y.CODEC_ROUND_TRIP,t,i,a(r))};return{resolveForward:(e,n,r)=>t.forwardState(e,n,r),defaultParams:e=>n.config.defaultParams[e],defaultSearch:e=>n.config.defaultSearch[e],buildPath:(t,n,r)=>e.routes.buildPath(t,n,r,e.options.get()),queryNames:t=>e.routes.getQueryParams(t),printedQueryNames:t=>e.routes.getPrintedQueryParams(t),pathNames:t=>e.routes.hasRoute(t)?a(t):void 0,admitsUndeclaredQuery:()=>Ar(e.options.get().queryParamsMode)===`loose`,get reportDroppedQueryKey(){return e.eventBus.diagnosticListenerCount(y.DROPPED_QUERY_KEY)>0?i:void 0},get reportUndeclaredParamKey(){return e.eventBus.diagnosticListenerCount(y.UNDECLARED_PARAM_KEY)>0?r:void 0},get reportCodecRoundTrip(){return e.eventBus.diagnosticListenerCount(y.CODEC_ROUND_TRIP)>0?o:void 0}}}function cc(e,t,n){let r=e=>n(e),i={logger:h(e.router).logger,getOptions:()=>e.options.get(),hasRoute:t=>e.routes.hasRoute(t),getQueryParams:t=>e.routes.getQueryParams(t),getMetaForState:t=>e.routes.getMetaForState(t),getState:()=>e.state.get(),buildNavigateState:(n,r,i)=>{p(h(e.router).checks,m[`navigate:state`],n,r);let a=W(t,n,r,i,{diagnoseUndeclared:!0});if(e.routes.getMetaForState(a.name)===void 0)return;x(`navigate`,a.name,a.path,t.queryNames(a.name));let o=Vr(a,Rr(a,t));return t.reportCodecRoundTrip?.(o),o},resolveDefault:()=>{let t=e.options.get(),n=h(e.router),i=Fr(t.defaultRoute,r),a=Fr(t.defaultParams,r),o=Fr(t.defaultSearch,r);return typeof t.defaultRoute==`function`&&p(n.checks,m[`navigateToDefault:route`],i),{route:i,params:a,search:o}},startTransition:t=>e.eventBus.sendNavigate(t),systemCommit:(t,n,r)=>e.eventBus.systemCommit({toState:t,fromState:n,opts:r},t.name),cancelNavigation:t=>{e.eventBus.sendCancelIfPossible(e.state.get(),t)},cancelIfInFlight:(t,n)=>{e.eventBus.sendCancelIfInFlight(t,e.state.get(),n)},dispatchAbort:(t,n)=>{e.eventBus.dispatchAbort(t,n)},bridgeExternalSignal:t=>{e.eventBus.bridgeExternalSignal(t)},canCommitTransition:t=>e.eventBus.canCommitTransition(t)?Xo:void 0,sendTransitionDone:t=>{e.eventBus.sendComplete(t)},sendTransitionFail:(t,n,r)=>{e.eventBus.sendFail(t,n,r)},emitTransitionError:(t,n,r)=>{e.eventBus.emitTransitionError(t,n,r)},sendLeaveApprove:t=>{e.eventBus.sendLeaveApprove(t)},canNavigate:()=>e.eventBus.canBeginTransition(),isStarting:()=>e.eventBus.isStarting(),getLifecycleFunctions:()=>e.routeLifecycle.getFunctions(),warnNonBooleanGuard:(t,n)=>{e.eventBus.emitDiagnostic(y.GUARD_NON_BOOLEAN,t,n)},canDeactivateCurrent:(t,n,r)=>e.routeLifecycle.canNavigateTo(t,[],n,r,`navigateToNotFound`),isTransitioning:()=>e.eventBus.isTransitioning(),clearCanDeactivate:(t,n)=>{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(i)}function lc(e){e.lifecycle.setDependencies({getOptions:()=>e.options.get(),navigateToState:(t,n)=>e.navigation.navigateToState(t,n),navigateToNotFound:t=>e.navigation.navigateToNotFound(t),matchPath:t=>e.routes.matchPath(t,e.options.get()),getRootPath:()=>e.routes.getStore().rootPath,completeStart:()=>{e.eventBus.sendStarted()},isIdle:()=>e.eventBus.isIdle()})}function uc(e,t){e.state.setDependencies({port:()=>t,getUrlParams:t=>e.routes.getUrlParams(t)})}const dc=T(`router`,`navigateToNotFound`),fc=T(`router`,`start`),pc=T(`router`);var mc=class t{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;constructor(n=[],r={},i={}){let{logger:o,...l}=r,u=new ec(o?_r(o):void 0);this.#f=u,this.#p=e=>{to(e)||u.error(`router.start`,`Unexpected start error`,e)},Pr.validateOptionsIsObject(r),or(i);let d=ur(n),h=Fs(l);this.#r=Ns(l),this.#e=new Pr(h),this.#t=Rs(h.limits),this.#n=zs(h.limits);let g={emit:(e,...t)=>{this.#d.emitDiagnostic(e,...t)},listenerCount:e=>this.#d.diagnosticListenerCount(e)};this.#i=Tr(i,this.#t,g),this.#a=new Ur;let v={emit:e=>{this.#d.emitTreeChanged(e)},subscribe:e=>this.#d.subscribeTreeChanged(e),listenerCount:()=>this.#d.treeChangedListenerCount(),isEmitting:()=>this.#d.isEmittingTreeChanged()};this.#o=new Ka(d,Ks(this.#e.get()),u,v),this.#s=new oi,this.#c=new Qr,this.#l=new Yo,this.#u=new es;let y=bs();this.#a.setContext(y.getContext());let ee=new Xs({onListenerError:(e,t)=>{u.error(`router`,`Error in listener for ${e}:`,t)},onListenerWarn:(e,t)=>{u.warn(`router`,`Event "${e}" has ${t} listeners — possible memory leak`)}});this.#d=new As({routerFSM:y,emitter:ee});let x=new Map,S=new Map,te=e=>{let t=e.params,n=e.search;return{name:e.name,params:t==null?t:L(t),search:n==null?n:L(n)}},C=a(_.forwardState,(e,t,n)=>this.#o.forwardState(e,t,n),x,te,hc),w=((t,n,r)=>{let i=C(t,n,r),a=i.name,o=i.params;e(`forwardState`,a,o,this.#o.getQueryParams(a),()=>a===t?"the `params` bag leaving the forwardState chain":`the \`params\` bag leaving the forwardState chain (forwarded here from "${t}")`);let s=i.search,c=s==null;return{name:a,params:L(o??k),search:c?s:L(s)}}),T=a(_.forwardState,(e,t,n)=>({name:e,params:t,search:n}),x,te,hc);this.#h=(e,t,n)=>{let r=T(e,t,n),i=r.params,a=r.search;return this.#o.buildPathFromIntent(r.name,i??k,a)},this.#m=f(_.start,e=>this.#u.start(e),x);let E={logger:u,makeState:(e,t,n,r)=>{c(E,`makeState`,e,t);let i=F(t);return p(E.checks,m[`makeState:state`],e,i,n,r),this.#a.makeState(e,i,n,r)},getMetaForState:e=>this.#o.getMetaForState(e),getDeclaredQueryNames:e=>this.#o.getQueryParams(e),forwardState:w,buildStateResolved:(e,t)=>this.#o.buildStateResolved(e,t),buildPathResolved:(e,t,n)=>{let r=F(t);return p(E.checks,m[`buildPathResolved:entry`],t,n),p(E.checks,m[`buildPathResolved:params`],r),this.#o.buildPathFromIntent(e,r??k,n)},port:()=>this.#o.getPort(),matchPath:(e,t)=>(p(E.checks,m[`matchPath:entry`],e),this.#o.matchPath(e,t??this.#e.get())),getOptions:()=>this.#e.get(),getAdoptedOrigins:()=>this.#r,addEventListener:(e,t)=>{b(E.isDisposed),Qn(e),$n(t);let n=this.#d.addEventListener(e,t,`addEventListener`);return b(E.isDisposed),n},subscribeDiagnostic:(e,t)=>this.#d.subscribeDiagnostic(e,t),emitTransitionError:e=>{this.#d.emitTransitionError(void 0,this.#a.get(),e)},navigateToNotFound:e=>{if(this.#v(),e!==void 0&&typeof e!=`string`)throw dc.type`path must be a string, got ${typeof e}`;return this.#l.navigateToNotFound(e)},revalidateToNotFound:e=>(this.#y(),this.#l.revalidateToNotFound(e)),start:e=>this.start(e),navigateToState:(e,n)=>(b(E.isDisposed),p(S,m[`navigateToState:entry`],e,n),this.#v(),t.#g(this.#l.navigateToState(e,n??ie))),interceptors:x,checks:S,setRootPath:e=>{p(S,m[`setRootPath:entry`],e),this.#o.setRootPath(e)},getRootPath:()=>this.#o.getStore().rootPath,getTree:()=>this.#o.getStore().tree,isDisposed:()=>this.#d.isDisposed(),dependenciesGetStore:()=>this.#i,getCloneState:()=>({options:{...this.#e.get()},dependencies:wr(this.#i),pluginFactories:this.#c.getAll(),loggerConfig:u.getConfig(),limits:this.#t,limitKeys:this.#n}),routeGetStore:()=>this.#o.getStore(),getStateName:()=>this.#a.get()?.name,isTransitioning:()=>this.#d.isTransitioning(),systemCommit:(e,t,n)=>{this.#y();let r=e.name;if(r!==`@@router/UNKNOWN_ROUTE`&&!this.#o.hasRoute(r))throw I(new N(R.ROUTE_NOT_FOUND,{routeName:r}));return this.#d.systemCommit({toState:e,fromState:t,opts:n},r)},routerExtensions:[],contextClaimRecords:new Map};s(this,E),tc({router:this,options:this.#e,limits:this.#t,dependenciesStore:this.#i,state:this.#a,routes:this.#o,routeLifecycle:this.#s,plugins:this.#c,navigation:this.#l,lifecycle:this.#u,eventBus:this.#d}),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeLeave=this.subscribeLeave.bind(this),this.isLeaveApproved=this.isLeaveApproved.bind(this);try{this.#o.flushPendingGuards()}catch(e){throw this.dispose(),e}}isActiveRoute(e,t,n,r,i){let a=h(this);return p(a.checks,m[`isActiveRoute:entry`],e,t,n,r,i),this.#d.diagnosticListenerCount(y.IS_ACTIVE_ROUTE)>0&&this.#d.emitDiagnostic(y.IS_ACTIVE_ROUTE,e,t),e===``?(a.logger.warn(`router.isActiveRoute`,`isActiveRoute("") called with empty string. Root node is not considered a parent of any route.`),!1):this.#o.isActiveRoute(e,t,n,r,i)}buildPath(e,t,n){let r=h(this);p(r.checks,m[`buildPath:entry`],e,t,n),this.#d.diagnosticListenerCount(y.BUILD_PATH)>0&&this.#d.emitDiagnostic(y.BUILD_PATH,e,t);let i=F(t);return p(r.checks,m[`buildPath:params`],i),this.#h(e,i??k,n)}getState(){return this.#a.get()}getPreviousState(){return this.#a.getPrevious()}areStatesEqual(e,t,n=!0){return p(h(this).checks,m[`areStatesEqual:entry`],e,t,n),this.#a.areStatesEqual(e,t,n)}shouldUpdateNode(e){return p(h(this).checks,m[`shouldUpdateNode:entry`],e),Ka.shouldUpdateNode(e,e=>this.#o.getMetaForState(e))}isActive(){return this.#d.isActive()}start(e){let t=this.#_(e);return t.catch(this.#p),t}stop(){return this.#d.sendCancelIfPossible(this.#a.get()),!this.#d.isReady()&&!this.#d.isTransitioning()&&!this.#d.isStarting()||this.#d.sendStop(),this}dispose(){if(this.#d.isDisposed())return;this.#d.sendCancelIfPossible(this.#a.get()),(this.#d.isReady()||this.#d.isTransitioning())&&this.#d.sendStopForDispose(),this.#d.sendDispose(),this.#d.clearAll(),this.#c.disposeAll();let e=h(this);for(let t of e.routerExtensions)for(let e of t.keys)delete this[e];e.routerExtensions.length=0,e.contextClaimRecords.clear(),e.interceptors.clear(),e.checks.clear(),this.#o.clearRoutes(),this.#s.clearAll(),Cr(this.#i),this.#x()}canNavigateTo(e,t,n){let i=h(this);p(i.checks,m[`canNavigateTo:entry`],e,t,n);let a;try{a=F(t)}catch(t){return i.logger.warn(`router.canNavigateTo`,`Reading the params bag for route "${e}" threw; treating the route as unreachable.`,t),!1}if(p(i.checks,m[`canNavigateTo:params`],a),!this.#o.hasRoute(e)||r(t,this.#o.getQueryParams(e))!==void 0)return!1;let o=this.#o.getPort(),s;try{s=W(o,e,a??k,n)}catch(t){return i.logger.warn(`router.canNavigateTo`,`Resolving route "${e}" threw while answering the predicate; treating the route as unreachable.`,t),!1}let c;try{c=Vr(s,Rr(s,o))}catch{return!1}let l=this.#a.get(),{toDeactivate:u,toActivate:d}=Ba(c,l,e=>this.#o.getMetaForState(e));return this.#s.canNavigateTo(u,d,c,l,`canNavigateTo`)}usePlugin(...e){Qr.validateNotDisposed(this.#d.isDisposed());let t=e.filter(Boolean);if(t.length===0)return()=>{};let{checks:n}=h(this);if(v(n,m[`usePlugin:count`])&&p(n,m[`usePlugin:count`],this.#c.count(),new Set(t).size,this.#t.maxPlugins),v(n,m[`usePlugin:entry`])){let e=this.#c.getAll();for(let r of t)p(n,m[`usePlugin:entry`],r,e)}return this.#c.use(...t)}subscribe(e){return As.validateSubscribeListener(e),this.#d.subscribe(e)}subscribeLeave(e){return As.validateSubscribeLeaveListener(e),this.#d.subscribeLeave(e)}isLeaveApproved(){return this.#d.isLeaveApproved()}navigate(e,n,r,i){this.#v();let a=h(this),o,s,l,u;typeof e==`object`&&e?(o=e.name,s=e.params,l=e.search,u=n??ie):(o=e,s=n,l=r,u=i??ie),c(a,`navigate`,o,s),p(a.checks,m[`navigate:entry`],o,s,l,u);let d;try{d=F(s)}catch(e){return Promise.reject(e)}return p(a.checks,m[`navigate:params`],d),t.#g(this.#l.navigate(o,d??k,l,u))}navigateToDefault(e){this.#v();let n=h(this);return p(n.checks,m[`navigateToDefault:entry`],e),this.#d.emitDiagnostic(y.NAVIGATE_TO_DEFAULT),b(n.isDisposed),t.#g(this.#l.navigateToDefault(e??ie))}navigateToNotFound(e){if(this.#v(),!this.#d.isActive())throw I(new N(R.ROUTER_NOT_STARTED));if(e!==void 0&&typeof e!=`string`)throw dc.type`path must be a string, got ${typeof e}`;if(e!==void 0)return this.#l.navigateToNotFound(e);let t=this.#a.get();if(t===void 0)throw dc.code(R.ROUTER_NOT_STARTED)`cannot derive the path before the start navigation commits — pass an explicit path`;return this.#l.navigateToNotFound(t.path)}static#g(e){return e instanceof Promise?e:Promise.resolve(e)}#_(e){if(!this.#d.canStart())return Promise.reject(qs);this.#v(),p(h(this).checks,m[`start:entry`],e),this.#d.sendStart();let t;try{let n=this.#m(e);t=typeof n?.then==`function`?n:Promise.reject(fc.type`a \`start\` interceptor returned without calling next(). Every start interceptor must return \`next(path)\`.`)}catch(e){t=Promise.reject(e)}return t.catch(e=>this.#b(e))}#v(){if(this.#f.isInCallback())throw pc.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside the logger's callback — core logs from the middle of its own operations, and a navigation started there would run inside the one being logged. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#d.isProcessing())throw pc.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside a router event listener or an abort listener of a navigation's signal — the nested navigation would commit a state the outer one overwrites. Defer it: queueMicrotask(() => router.navigate(...)), await the current transition, or use an async listener.`;if(this.#l.isPreparing())throw pc.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside a forwardState interceptor, a route's encodeParams or dynamic forwardTo callback, or a defaultRoute/defaultParams/defaultSearch option callback — they run while a navigation is being prepared, before it is announced. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#l.isCommittingNotFound())throw pc.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside a canDeactivate guard that navigateToNotFound() consults — the 404 commits from the state read before the guard was asked. A guard does not redirect: return false to stay, or defer the navigation: queueMicrotask(() => router.navigate(...)).`;if(this.#o.isRevalidating())throw pc.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside replace()'s revalidation — the revalidation would then defer to a commit that may never happen. Defer it: queueMicrotask(() => router.navigate(...)).`}#y(){this.#o.isRevalidating()||this.#v()}#b(e){throw this.#d.isReady()&&this.#a.get()===void 0?this.#d.sendStop():this.#d.isStarting()&&this.#d.sendFail(void 0,e),e}#x(){this.navigate=$,this.navigateToDefault=$,this.navigateToNotFound=$,this.start=$,this.stop=$,this.usePlugin=$,this.subscribe=$,this.subscribeLeave=$,this.canNavigateTo=$}};function $(){throw pc.code(R.ROUTER_DISPOSED)`this router is disposed — dispose() is terminal and swapped every method to refuse`}function hc(e,t,n){return[e,F(t),F(n)]}export{xr as A,an as B,Ti as C,Cr as D,W as E,rr as F,er as I,ur as L,cr as M,ir as N,Sr as O,tr as P,lr as R,yi as S,Rr as T,Wi as _,ca as a,pi as b,sa as c,aa as d,ua as f,pa as g,Ui as h,ma as i,nr as j,wr as k,ia as l,ga as m,Ba as n,oa as o,da as p,Ki as r,na as s,mc as t,ra as u,Mi as v,Vr as w,bi as x,Ai as y,rn as z};
|
|
2
|
+
//# sourceMappingURL=Router-BTlEfQMO.mjs.map
|