@kitbag/router 0.8.0 → 0.8.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/kitbag-router.d.ts +14 -17
- package/dist/kitbag-router.js +95 -93
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -254,9 +254,9 @@ declare type CreateRouteOptionsMatched = CreateRouteOptions & WithHooks & (WithH
|
|
|
254
254
|
* const router = createRouter(routes)
|
|
255
255
|
* ```
|
|
256
256
|
*/
|
|
257
|
-
export declare function createRouter<const
|
|
257
|
+
export declare function createRouter<const TRoutes extends Routes, const TOptions extends RouterOptions>(routes: TRoutes, options?: TOptions): Router<TRoutes, TOptions>;
|
|
258
258
|
|
|
259
|
-
export declare function createRouter<const
|
|
259
|
+
export declare function createRouter<const TRoutes extends Routes, const TOptions extends RouterOptions>(arrayOfRoutes: TRoutes[], options?: TOptions): Router<TRoutes, TOptions>;
|
|
260
260
|
|
|
261
261
|
/**
|
|
262
262
|
* An error thrown when duplicate parameters are detected in a route.
|
|
@@ -576,7 +576,7 @@ declare type QueryParamsWithParamNameExtracted<T extends string> = {
|
|
|
576
576
|
};
|
|
577
577
|
|
|
578
578
|
/**
|
|
579
|
-
* Represents the state of currently registered router,
|
|
579
|
+
* Represents the state of currently registered router, and route meta. Used to provide correct type context for
|
|
580
580
|
* components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
|
|
581
581
|
*
|
|
582
582
|
* @example
|
|
@@ -584,7 +584,6 @@ declare type QueryParamsWithParamNameExtracted<T extends string> = {
|
|
|
584
584
|
* declare module '@kitbag/router' {
|
|
585
585
|
* interface Register {
|
|
586
586
|
* router: typeof router
|
|
587
|
-
* rejections: ["NotAuthorized"],
|
|
588
587
|
* routeMeta: { public?: boolean }
|
|
589
588
|
* }
|
|
590
589
|
* }
|
|
@@ -597,8 +596,8 @@ export declare interface Register {
|
|
|
597
596
|
* Represents the possible Rejections registered within {@link Register}
|
|
598
597
|
*/
|
|
599
598
|
export declare type RegisteredRejectionType = Register extends {
|
|
600
|
-
|
|
601
|
-
} ?
|
|
599
|
+
router: Router<Routes, infer TOptions extends RouterOptions>;
|
|
600
|
+
} ? keyof TOptions['rejections'] | BuiltInRejectionType : BuiltInRejectionType;
|
|
602
601
|
|
|
603
602
|
/**
|
|
604
603
|
* Represents the a map of all possible route names with corresponding Route registered within {@link Register}
|
|
@@ -777,7 +776,7 @@ declare type RouteHookPushResponse<T extends Routes> = {
|
|
|
777
776
|
*/
|
|
778
777
|
declare type RouteHookRejectResponse = {
|
|
779
778
|
status: 'REJECT';
|
|
780
|
-
type:
|
|
779
|
+
type: RegisteredRejectionType;
|
|
781
780
|
};
|
|
782
781
|
|
|
783
782
|
/**
|
|
@@ -809,7 +808,7 @@ declare type RouteParams<TPath extends string | Path | undefined, TQuery extends
|
|
|
809
808
|
|
|
810
809
|
declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypesWithoutLosingOptional<RouteGetByKey<TRoutes, TKey>>;
|
|
811
810
|
|
|
812
|
-
export declare type Router<TRoutes extends Routes = any> = Plugin_2 & {
|
|
811
|
+
export declare type Router<TRoutes extends Routes = any, __TOptions extends RouterOptions = any> = Plugin_2 & {
|
|
813
812
|
/**
|
|
814
813
|
* Manages the current route state.
|
|
815
814
|
*/
|
|
@@ -964,7 +963,11 @@ export declare type RouterOptions = {
|
|
|
964
963
|
* Determines what assets are prefetched when router-link is rendered for a specific route
|
|
965
964
|
*/
|
|
966
965
|
prefetch?: PrefetchConfig;
|
|
967
|
-
|
|
966
|
+
/**
|
|
967
|
+
* Components assigned to each type of rejection your router supports.
|
|
968
|
+
*/
|
|
969
|
+
rejections?: Partial<Record<string, Component>>;
|
|
970
|
+
};
|
|
968
971
|
|
|
969
972
|
declare type RouterPush<TRoutes extends Routes = any> = {
|
|
970
973
|
<TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterPushArgs<TRoutes, TSource>): Promise<void>;
|
|
@@ -979,21 +982,15 @@ declare type RouterPushOptions<TState = unknown> = {
|
|
|
979
982
|
state?: Partial<TState>;
|
|
980
983
|
};
|
|
981
984
|
|
|
982
|
-
export declare type RouterReject = (type:
|
|
985
|
+
export declare type RouterReject = (type: RegisteredRejectionType) => void;
|
|
983
986
|
|
|
984
987
|
declare type RouterRejection = Ref<null | {
|
|
985
|
-
type:
|
|
988
|
+
type: RegisteredRejectionType;
|
|
986
989
|
component: Component;
|
|
987
990
|
}>;
|
|
988
991
|
|
|
989
|
-
declare type RouterRejectionComponents = {
|
|
990
|
-
rejections?: Partial<Record<RouterRejectionType, Component>>;
|
|
991
|
-
};
|
|
992
|
-
|
|
993
992
|
export declare const routerRejectionKey: InjectionKey<RouterRejection>;
|
|
994
993
|
|
|
995
|
-
declare type RouterRejectionType = BuiltInRejectionType | RegisteredRejectionType;
|
|
996
|
-
|
|
997
994
|
declare type RouterReplace<TRoutes extends Routes> = {
|
|
998
995
|
<TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterReplaceArgs<TRoutes, TSource>): Promise<void>;
|
|
999
996
|
(url: Url, options?: RouterReplaceOptions): Promise<void>;
|
package/dist/kitbag-router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Me = Object.defineProperty;
|
|
2
2
|
var Te = (t, e, n) => e in t ? Me(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var V = (t, e, n) => (Te(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
-
import { inject as yt, defineComponent as ct, h as ut, toRefs as Fe, reactive as
|
|
4
|
+
import { inject as yt, defineComponent as ct, h as ut, toRefs as Fe, reactive as oe, ref as Ie, markRaw as it, defineAsyncComponent as Je, toRef as Qe, computed as j, toValue as xt, watch as ae, onUnmounted as se, openBlock as ce, createElementBlock as Ge, normalizeClass as Ke, renderSlot as ue, normalizeProps as ie, guardReactiveProps as ze, unref as ft, resolveComponent as Ye, provide as Xe, mergeProps as Ze, createBlock as tn, resolveDynamicComponent as en, createCommentVNode as nn } from "vue";
|
|
5
5
|
class rn extends Error {
|
|
6
6
|
/**
|
|
7
7
|
* Constructs a new DuplicateParamsError instance with a message indicating the problematic parameter.
|
|
@@ -27,9 +27,9 @@ class on extends Error {
|
|
|
27
27
|
super(`useRoute called with incorrect route. Given ${e}, expected ${n}`);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const fe = Symbol();
|
|
31
31
|
function Ht() {
|
|
32
|
-
const t = yt(
|
|
32
|
+
const t = yt(fe);
|
|
33
33
|
if (!t)
|
|
34
34
|
throw new Ct();
|
|
35
35
|
return t;
|
|
@@ -52,13 +52,13 @@ function cn(t, e) {
|
|
|
52
52
|
function Y(t) {
|
|
53
53
|
return Array.isArray(t) ? t : [t];
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function le(t, e) {
|
|
56
56
|
return t.filter((n) => e === n).length;
|
|
57
57
|
}
|
|
58
58
|
function et(...t) {
|
|
59
59
|
const e = t.flatMap((n) => Array.isArray(n) ? n : Object.keys(n).map(un));
|
|
60
60
|
for (const n of e)
|
|
61
|
-
if (
|
|
61
|
+
if (le(e, n) > 1)
|
|
62
62
|
throw new rn(n);
|
|
63
63
|
}
|
|
64
64
|
function un(t) {
|
|
@@ -97,7 +97,7 @@ function pn(t, e) {
|
|
|
97
97
|
function mn(t) {
|
|
98
98
|
return "host" in t && !!t.host;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function he(t) {
|
|
101
101
|
return "parent" in t && !!t.parent;
|
|
102
102
|
}
|
|
103
103
|
function Nt(t) {
|
|
@@ -109,7 +109,7 @@ function Ut(t) {
|
|
|
109
109
|
function dn(t) {
|
|
110
110
|
return "state" in t && !!t.state;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function pe(t, e) {
|
|
113
113
|
return {
|
|
114
114
|
...e,
|
|
115
115
|
path: fn(t.path, e.path),
|
|
@@ -121,7 +121,7 @@ function me(t, e) {
|
|
|
121
121
|
depth: t.depth + 1
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function me() {
|
|
125
125
|
return typeof window < "u" && typeof window.document < "u";
|
|
126
126
|
}
|
|
127
127
|
function gn(t, e) {
|
|
@@ -174,7 +174,7 @@ const C = {
|
|
|
174
174
|
throw e();
|
|
175
175
|
return t;
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, de = {
|
|
178
178
|
get: (t, { invalid: e }) => {
|
|
179
179
|
if (t === "true")
|
|
180
180
|
return !0;
|
|
@@ -187,7 +187,7 @@ const C = {
|
|
|
187
187
|
throw e();
|
|
188
188
|
return t.toString();
|
|
189
189
|
}
|
|
190
|
-
},
|
|
190
|
+
}, ge = {
|
|
191
191
|
get: (t, { invalid: e }) => {
|
|
192
192
|
const n = Number(t);
|
|
193
193
|
if (isNaN(n))
|
|
@@ -199,7 +199,7 @@ const C = {
|
|
|
199
199
|
throw e();
|
|
200
200
|
return t.toString();
|
|
201
201
|
}
|
|
202
|
-
},
|
|
202
|
+
}, Re = {
|
|
203
203
|
get: (t, { invalid: e }) => {
|
|
204
204
|
const n = new Date(t);
|
|
205
205
|
if (isNaN(n.getTime()))
|
|
@@ -211,7 +211,7 @@ const C = {
|
|
|
211
211
|
throw e();
|
|
212
212
|
return t.toISOString();
|
|
213
213
|
}
|
|
214
|
-
},
|
|
214
|
+
}, ye = {
|
|
215
215
|
get: (t, { invalid: e }) => {
|
|
216
216
|
try {
|
|
217
217
|
return JSON.parse(t);
|
|
@@ -238,13 +238,13 @@ function ot(t, e, n = !1) {
|
|
|
238
238
|
if (e === String)
|
|
239
239
|
return Pn.get(t, C);
|
|
240
240
|
if (e === Boolean)
|
|
241
|
-
return
|
|
241
|
+
return de.get(t, C);
|
|
242
242
|
if (e === Number)
|
|
243
|
-
return
|
|
243
|
+
return ge.get(t, C);
|
|
244
244
|
if (e === Date)
|
|
245
|
-
return
|
|
245
|
+
return Re.get(t, C);
|
|
246
246
|
if (e === JSON)
|
|
247
|
-
return
|
|
247
|
+
return ye.get(t, C);
|
|
248
248
|
if (vn(e))
|
|
249
249
|
return e(t, C);
|
|
250
250
|
if (Et(e))
|
|
@@ -263,13 +263,13 @@ function at(t, e, n = !1) {
|
|
|
263
263
|
throw new X();
|
|
264
264
|
}
|
|
265
265
|
if (e === Boolean)
|
|
266
|
-
return
|
|
266
|
+
return de.set(t, C);
|
|
267
267
|
if (e === Number)
|
|
268
|
-
return
|
|
268
|
+
return ge.set(t, C);
|
|
269
269
|
if (e === Date)
|
|
270
|
-
return
|
|
270
|
+
return Re.set(t, C);
|
|
271
271
|
if (e === JSON)
|
|
272
|
-
return
|
|
272
|
+
return ye.set(t, C);
|
|
273
273
|
if (Et(e))
|
|
274
274
|
return e.set(t, C);
|
|
275
275
|
try {
|
|
@@ -313,7 +313,7 @@ function Q(t, e) {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
var lt = "beforeunload", Sn = "hashchange",
|
|
316
|
+
var lt = "beforeunload", Sn = "hashchange", ve = "popstate";
|
|
317
317
|
function Jt(t) {
|
|
318
318
|
t === void 0 && (t = {});
|
|
319
319
|
var e = t, n = e.window, r = n === void 0 ? document.defaultView : n, o = r.history;
|
|
@@ -355,7 +355,7 @@ function Jt(t) {
|
|
|
355
355
|
O(d);
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
r.addEventListener(
|
|
358
|
+
r.addEventListener(ve, c);
|
|
359
359
|
var u = N.Pop, l = a(), p = l[0], f = l[1], w = tt(), m = tt();
|
|
360
360
|
p == null && (p = 0, o.replaceState(F({}, o.state, {
|
|
361
361
|
idx: p
|
|
@@ -493,7 +493,7 @@ function An(t) {
|
|
|
493
493
|
g(i);
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
r.addEventListener(
|
|
496
|
+
r.addEventListener(ve, c), r.addEventListener(Sn, function() {
|
|
497
497
|
var i = a(), h = i[1];
|
|
498
498
|
G(h) !== G(f) && c();
|
|
499
499
|
});
|
|
@@ -732,16 +732,16 @@ function st(t) {
|
|
|
732
732
|
}
|
|
733
733
|
return e;
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const we = Symbol();
|
|
736
736
|
function xn() {
|
|
737
|
-
const t = yt(
|
|
737
|
+
const t = yt(we);
|
|
738
738
|
if (!t)
|
|
739
739
|
throw new Ct();
|
|
740
740
|
return t;
|
|
741
741
|
}
|
|
742
|
-
const
|
|
742
|
+
const Ee = Symbol("isRouterRouteSymbol");
|
|
743
743
|
function kn(t) {
|
|
744
|
-
return typeof t == "object" && t !== null &&
|
|
744
|
+
return typeof t == "object" && t !== null && Ee in t;
|
|
745
745
|
}
|
|
746
746
|
function Bn(t, e) {
|
|
747
747
|
function n(p, f, w) {
|
|
@@ -758,7 +758,7 @@ function Bn(t, e) {
|
|
|
758
758
|
};
|
|
759
759
|
return e(t.name, m, w);
|
|
760
760
|
}
|
|
761
|
-
const { matched: r, matches: o, name: a, query: s, params: c, state: u } = Fe(t), l =
|
|
761
|
+
const { matched: r, matches: o, name: a, query: s, params: c, state: u } = Fe(t), l = oe({
|
|
762
762
|
matched: r,
|
|
763
763
|
matches: o,
|
|
764
764
|
state: u,
|
|
@@ -766,7 +766,7 @@ function Bn(t, e) {
|
|
|
766
766
|
params: c,
|
|
767
767
|
name: a,
|
|
768
768
|
update: n,
|
|
769
|
-
[
|
|
769
|
+
[Ee]: !0
|
|
770
770
|
});
|
|
771
771
|
return new Proxy(l, {
|
|
772
772
|
get: (p, f, w) => f === "params" ? new Proxy(t.params, {
|
|
@@ -780,9 +780,13 @@ function Bn(t, e) {
|
|
|
780
780
|
}) : Reflect.get(p, f, w)
|
|
781
781
|
});
|
|
782
782
|
}
|
|
783
|
+
const Pe = Symbol();
|
|
783
784
|
function Ln(t, e) {
|
|
784
|
-
const n =
|
|
785
|
-
Object.assign(n, {
|
|
785
|
+
const n = oe({ ...t }), r = (s) => {
|
|
786
|
+
Object.assign(n, {
|
|
787
|
+
[Pe]: !1,
|
|
788
|
+
...s
|
|
789
|
+
});
|
|
786
790
|
}, o = n, a = Bn(o, e);
|
|
787
791
|
return {
|
|
788
792
|
currentRoute: o,
|
|
@@ -844,7 +848,7 @@ function Cn({ mode: t, listener: e }) {
|
|
|
844
848
|
function Hn(t = "auto") {
|
|
845
849
|
switch (t) {
|
|
846
850
|
case "auto":
|
|
847
|
-
return
|
|
851
|
+
return me() ? Jt() : Qt();
|
|
848
852
|
case "browser":
|
|
849
853
|
return Jt();
|
|
850
854
|
case "memory":
|
|
@@ -1067,44 +1071,42 @@ function Se(t) {
|
|
|
1067
1071
|
getAll: (n) => e.getAll(n)
|
|
1068
1072
|
};
|
|
1069
1073
|
}
|
|
1070
|
-
const Yt = Symbol();
|
|
1071
1074
|
function Dn({
|
|
1072
1075
|
rejections: t
|
|
1073
1076
|
}) {
|
|
1074
|
-
const e = (
|
|
1075
|
-
const
|
|
1077
|
+
const e = (a) => {
|
|
1078
|
+
const s = {
|
|
1076
1079
|
...t
|
|
1077
1080
|
};
|
|
1078
|
-
return it(
|
|
1079
|
-
}, n = (
|
|
1080
|
-
const
|
|
1081
|
-
name:
|
|
1082
|
-
component:
|
|
1081
|
+
return it(s[a] ?? Wn(a));
|
|
1082
|
+
}, n = (a) => {
|
|
1083
|
+
const s = it(e(a)), c = {
|
|
1084
|
+
name: a,
|
|
1085
|
+
component: s,
|
|
1083
1086
|
meta: {},
|
|
1084
1087
|
state: {}
|
|
1085
1088
|
};
|
|
1086
1089
|
return {
|
|
1087
|
-
matched:
|
|
1088
|
-
matches: [
|
|
1089
|
-
name:
|
|
1090
|
+
matched: c,
|
|
1091
|
+
matches: [c],
|
|
1092
|
+
name: a,
|
|
1090
1093
|
query: Se(""),
|
|
1091
1094
|
params: {},
|
|
1092
1095
|
state: {},
|
|
1093
|
-
[
|
|
1096
|
+
[Pe]: !0
|
|
1094
1097
|
};
|
|
1095
|
-
}, r = (
|
|
1096
|
-
if (!
|
|
1097
|
-
|
|
1098
|
+
}, r = (a) => {
|
|
1099
|
+
if (!a) {
|
|
1100
|
+
o.value = null;
|
|
1098
1101
|
return;
|
|
1099
1102
|
}
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
},
|
|
1103
|
+
const s = e(a);
|
|
1104
|
+
o.value = { type: a, component: s };
|
|
1105
|
+
}, o = Ie(null);
|
|
1103
1106
|
return {
|
|
1104
|
-
setRejection:
|
|
1105
|
-
rejection:
|
|
1106
|
-
getRejectionRoute: n
|
|
1107
|
-
isRejectionRoute: r
|
|
1107
|
+
setRejection: r,
|
|
1108
|
+
rejection: o,
|
|
1109
|
+
getRejectionRoute: n
|
|
1108
1110
|
};
|
|
1109
1111
|
}
|
|
1110
1112
|
class Mn extends Error {
|
|
@@ -1255,7 +1257,7 @@ class nr extends Error {
|
|
|
1255
1257
|
function rr(t) {
|
|
1256
1258
|
if (t)
|
|
1257
1259
|
return t;
|
|
1258
|
-
if (
|
|
1260
|
+
if (me())
|
|
1259
1261
|
return window.location.toString();
|
|
1260
1262
|
throw new nr();
|
|
1261
1263
|
}
|
|
@@ -1299,15 +1301,15 @@ const cr = (t) => "name" in t.matched && !!t.matched.name, ur = (t, e) => {
|
|
|
1299
1301
|
function fr(t) {
|
|
1300
1302
|
const { searchParams: e, pathname: n } = K(t), r = -1, o = 1;
|
|
1301
1303
|
return (a, s) => {
|
|
1302
|
-
const c =
|
|
1304
|
+
const c = Xt(a, e), u = Yt(a, n), l = Xt(s, e), p = Yt(s, n);
|
|
1303
1305
|
return a.depth > s.depth ? r : a.depth < s.depth ? o : c + u > l + p ? r : c + u < l + p ? o : 0;
|
|
1304
1306
|
};
|
|
1305
1307
|
}
|
|
1306
|
-
function
|
|
1308
|
+
function Yt(t, e) {
|
|
1307
1309
|
const n = Object.keys(t.path.params).filter((o) => o.startsWith("?")).map((o) => o), r = n.filter((o) => Be(e, t.path.toString(), o) === void 0);
|
|
1308
1310
|
return n.length - r.length;
|
|
1309
1311
|
}
|
|
1310
|
-
function
|
|
1312
|
+
function Xt(t, e) {
|
|
1311
1313
|
const n = new URLSearchParams(t.query.toString()), r = Array.from(n.keys()), o = r.filter((a) => !e.has(a));
|
|
1312
1314
|
return r.length - o.length;
|
|
1313
1315
|
}
|
|
@@ -1338,7 +1340,7 @@ function pr(t, e, n) {
|
|
|
1338
1340
|
}
|
|
1339
1341
|
return at(void 0, n, gt);
|
|
1340
1342
|
}
|
|
1341
|
-
const
|
|
1343
|
+
const Zt = (t, e) => {
|
|
1342
1344
|
const n = {};
|
|
1343
1345
|
for (const [r, o] of Object.entries(t)) {
|
|
1344
1346
|
const a = pr(e, r, o);
|
|
@@ -1385,7 +1387,7 @@ function He(t, e) {
|
|
|
1385
1387
|
function Dt(t) {
|
|
1386
1388
|
return t === void 0 ? "" : t;
|
|
1387
1389
|
}
|
|
1388
|
-
function
|
|
1390
|
+
function te(t, e) {
|
|
1389
1391
|
return {
|
|
1390
1392
|
path: t,
|
|
1391
1393
|
params: Wt(t, e),
|
|
@@ -1396,9 +1398,9 @@ function dr(t) {
|
|
|
1396
1398
|
return vt(t) && typeof t.path == "string";
|
|
1397
1399
|
}
|
|
1398
1400
|
function Ve(t) {
|
|
1399
|
-
return t === void 0 ?
|
|
1401
|
+
return t === void 0 ? te("", {}) : dr(t) ? t : te(t, {});
|
|
1400
1402
|
}
|
|
1401
|
-
function
|
|
1403
|
+
function ee(t, e) {
|
|
1402
1404
|
return {
|
|
1403
1405
|
query: t,
|
|
1404
1406
|
params: Wt(t, e),
|
|
@@ -1409,7 +1411,7 @@ function gr(t) {
|
|
|
1409
1411
|
return vt(t) && typeof t.query == "string";
|
|
1410
1412
|
}
|
|
1411
1413
|
function je(t) {
|
|
1412
|
-
return t === void 0 ?
|
|
1414
|
+
return t === void 0 ? ee("", {}) : gr(t) ? t : ee(t, {});
|
|
1413
1415
|
}
|
|
1414
1416
|
function I(t) {
|
|
1415
1417
|
const e = Dt(t.name), n = Ve(t.path), r = je(t.query), o = t.meta ?? {}, a = dn(t) ? t.state : {}, s = it({ meta: {}, state: {}, ...t }), c = {
|
|
@@ -1423,7 +1425,7 @@ function I(t) {
|
|
|
1423
1425
|
depth: 1,
|
|
1424
1426
|
host: He("", {}),
|
|
1425
1427
|
prefetch: t.prefetch
|
|
1426
|
-
}, u =
|
|
1428
|
+
}, u = he(t) ? pe(t.parent, c) : c;
|
|
1427
1429
|
return et(u.path.params, u.query.params), u;
|
|
1428
1430
|
}
|
|
1429
1431
|
function Rr(t, e) {
|
|
@@ -1447,14 +1449,14 @@ class yr extends Error {
|
|
|
1447
1449
|
function vr(t) {
|
|
1448
1450
|
const e = t.map(({ name: n }) => n);
|
|
1449
1451
|
for (const n of e)
|
|
1450
|
-
if (
|
|
1452
|
+
if (le(e, n) > 1)
|
|
1451
1453
|
throw new yr(n);
|
|
1452
1454
|
}
|
|
1453
|
-
function jr(t, e
|
|
1454
|
-
const n = ln(t) ? t.flat() : t, r = Rr(n, e.base);
|
|
1455
|
+
function jr(t, e) {
|
|
1456
|
+
const n = ln(t) ? t.flat() : t, r = Rr(n, e == null ? void 0 : e.base);
|
|
1455
1457
|
vr(r);
|
|
1456
1458
|
const o = er(r), a = Cn({
|
|
1457
|
-
mode: e.historyMode,
|
|
1459
|
+
mode: e == null ? void 0 : e.historyMode,
|
|
1458
1460
|
listener: ({ location: y }) => {
|
|
1459
1461
|
const k = G(y);
|
|
1460
1462
|
A(k, { state: y.state });
|
|
@@ -1508,14 +1510,14 @@ function jr(t, e = {}) {
|
|
|
1508
1510
|
const nt = { ...k }, At = o(y, nt);
|
|
1509
1511
|
return A(At, nt);
|
|
1510
1512
|
}
|
|
1511
|
-
const q = { ..._ }, T = o(y, k ?? {}, q), W = bt(y), St =
|
|
1513
|
+
const q = { ..._ }, T = o(y, k ?? {}, q), W = bt(y), St = Zt((W == null ? void 0 : W.state) ?? {}, q.state);
|
|
1512
1514
|
return A(T, { ...q, state: St });
|
|
1513
1515
|
}, $ = (y, k, _) => {
|
|
1514
1516
|
if (D(y)) {
|
|
1515
1517
|
const nt = { ...k, replace: !0 }, At = o(y, nt);
|
|
1516
1518
|
return A(At, nt);
|
|
1517
1519
|
}
|
|
1518
|
-
const q = { ..._, replace: !0 }, T = o(y, k ?? {}, q), W = bt(y), St =
|
|
1520
|
+
const q = { ..._, replace: !0 }, T = o(y, k ?? {}, q), W = bt(y), St = Zt((W == null ? void 0 : W.state) ?? {}, q.state);
|
|
1519
1521
|
return A(T, { ...q, state: St });
|
|
1520
1522
|
}, O = (y) => R(y), g = (y, k = {}) => {
|
|
1521
1523
|
if (!D(y)) {
|
|
@@ -1524,14 +1526,14 @@ function jr(t, e = {}) {
|
|
|
1524
1526
|
}
|
|
1525
1527
|
if (!L(y))
|
|
1526
1528
|
return Bt(r, y);
|
|
1527
|
-
}, { setRejection: R, rejection: P, getRejectionRoute: b } = Dn(e), d = b("NotFound"), { currentRoute: i, routerRoute: h, updateRoute: v } = Ln(d, U);
|
|
1529
|
+
}, { setRejection: R, rejection: P, getRejectionRoute: b } = Dn(e ?? {}), d = b("NotFound"), { currentRoute: i, routerRoute: h, updateRoute: v } = Ln(d, U);
|
|
1528
1530
|
a.startListening();
|
|
1529
|
-
const E = rr(e.initialUrl), x = a.location.state, { host: B } = K(E), L = $n(B), H = A(E, { replace: !0, state: x });
|
|
1531
|
+
const E = rr(e == null ? void 0 : e.initialUrl), x = a.location.state, { host: B } = K(E), L = $n(B), H = A(E, { replace: !0, state: x });
|
|
1530
1532
|
function bt(y) {
|
|
1531
1533
|
return r.find((k) => k.name === y);
|
|
1532
1534
|
}
|
|
1533
1535
|
function De(y) {
|
|
1534
|
-
y.component("RouterView", Ur), y.component("RouterLink", Nr), y.provide(
|
|
1536
|
+
y.component("RouterView", Ur), y.component("RouterLink", Nr), y.provide(we, P), y.provide(be, u), y.provide(fe, It);
|
|
1535
1537
|
}
|
|
1536
1538
|
const It = {
|
|
1537
1539
|
route: h,
|
|
@@ -1553,7 +1555,7 @@ function jr(t, e = {}) {
|
|
|
1553
1555
|
onAfterRouteEnter: w,
|
|
1554
1556
|
onBeforeRouteUpdate: m,
|
|
1555
1557
|
onAfterRouteLeave: S,
|
|
1556
|
-
prefetch: e.prefetch
|
|
1558
|
+
prefetch: e == null ? void 0 : e.prefetch
|
|
1557
1559
|
};
|
|
1558
1560
|
return It;
|
|
1559
1561
|
}
|
|
@@ -1596,7 +1598,7 @@ function Lt(t, e) {
|
|
|
1596
1598
|
const Sr = Je(() => new Promise((t) => {
|
|
1597
1599
|
t({ default: { template: "" } });
|
|
1598
1600
|
}));
|
|
1599
|
-
function
|
|
1601
|
+
function ne(t) {
|
|
1600
1602
|
return t.name === Sr.name && "setup" in t;
|
|
1601
1603
|
}
|
|
1602
1604
|
function Ar(t, e = {}, n = {}) {
|
|
@@ -1609,7 +1611,7 @@ function Ar(t, e = {}, n = {}) {
|
|
|
1609
1611
|
throw f instanceof X && console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`, f), f;
|
|
1610
1612
|
}
|
|
1611
1613
|
}), u = j(() => r.find(c.value, s.value)), l = j(() => !!u.value && r.route.matches.includes(u.value.matched)), p = j(() => !!u.value && r.route.matched === u.value.matched);
|
|
1612
|
-
return
|
|
1614
|
+
return ae(u, (f) => {
|
|
1613
1615
|
if (!f)
|
|
1614
1616
|
return;
|
|
1615
1617
|
const { prefetch: w } = r, { prefetch: m } = s.value;
|
|
@@ -1632,8 +1634,8 @@ function xr(t, { routerPrefetch: e, linkPrefetch: n }) {
|
|
|
1632
1634
|
routePrefetch: r.prefetch,
|
|
1633
1635
|
routerPrefetch: e,
|
|
1634
1636
|
linkPrefetch: n
|
|
1635
|
-
}, "components") && (Nt(r) &&
|
|
1636
|
-
|
|
1637
|
+
}, "components") && (Nt(r) && ne(r.component) && r.component.setup(), Ut(r) && Object.values(r.components).forEach((a) => {
|
|
1638
|
+
ne(a) && a.setup();
|
|
1637
1639
|
}));
|
|
1638
1640
|
});
|
|
1639
1641
|
}
|
|
@@ -1657,7 +1659,7 @@ function Br(t, e) {
|
|
|
1657
1659
|
if (!kr(n.route, t, e))
|
|
1658
1660
|
throw new on(t, n.route.name);
|
|
1659
1661
|
}
|
|
1660
|
-
return
|
|
1662
|
+
return ae(n.route, r, { immediate: !0, deep: !0 }), n.route;
|
|
1661
1663
|
}
|
|
1662
1664
|
const _e = Symbol();
|
|
1663
1665
|
function Tt() {
|
|
@@ -1672,13 +1674,13 @@ function qe() {
|
|
|
1672
1674
|
function We(t) {
|
|
1673
1675
|
return (e) => {
|
|
1674
1676
|
const n = Tt(), o = qe().addBeforeRouteHook({ lifecycle: t, hook: e, depth: n, timing: "component" });
|
|
1675
|
-
return
|
|
1677
|
+
return se(o), o;
|
|
1676
1678
|
};
|
|
1677
1679
|
}
|
|
1678
1680
|
function Ft(t) {
|
|
1679
1681
|
return (e) => {
|
|
1680
1682
|
const n = Tt(), o = qe().addAfterRouteHook({ lifecycle: t, hook: e, depth: n, timing: "component" });
|
|
1681
|
-
return
|
|
1683
|
+
return se(o), o;
|
|
1682
1684
|
};
|
|
1683
1685
|
}
|
|
1684
1686
|
const Or = We("onBeforeRouteUpdate"), _r = We("onBeforeRouteLeave"), qr = Ft("onAfterRouteEnter"), Wr = Ft("onAfterRouteUpdate"), Dr = Ft("onAfterRouteLeave"), Lr = ["href"], Nr = /* @__PURE__ */ ct({
|
|
@@ -1701,12 +1703,12 @@ const Or = We("onBeforeRouteUpdate"), _r = We("onBeforeRouteLeave"), qr = Ft("on
|
|
|
1701
1703
|
function p(f) {
|
|
1702
1704
|
f.preventDefault(), n.push(a.value, o.value);
|
|
1703
1705
|
}
|
|
1704
|
-
return (f, w) => (
|
|
1706
|
+
return (f, w) => (ce(), Ge("a", {
|
|
1705
1707
|
href: r.value,
|
|
1706
1708
|
class: Ke(["router-link", u.value]),
|
|
1707
1709
|
onClick: p
|
|
1708
1710
|
}, [
|
|
1709
|
-
|
|
1711
|
+
ue(f.$slots, "default", ie(ze({ resolved: r.value, isMatch: ft(s), isExactMatch: ft(c), isExternal: l.value })))
|
|
1710
1712
|
], 10, Lr));
|
|
1711
1713
|
}
|
|
1712
1714
|
}), Ur = /* @__PURE__ */ ct({
|
|
@@ -1724,7 +1726,7 @@ const Or = We("onBeforeRouteUpdate"), _r = We("onBeforeRouteLeave"), qr = Ft("on
|
|
|
1724
1726
|
if (!f)
|
|
1725
1727
|
return null;
|
|
1726
1728
|
const w = c(f), m = l(f);
|
|
1727
|
-
return w ? m ? gn(w, () => m(n.params)) : w : null;
|
|
1729
|
+
return w ? m ? (n.params, gn(w, () => m(n.params))) : w : null;
|
|
1728
1730
|
});
|
|
1729
1731
|
function c(f) {
|
|
1730
1732
|
return u(f)[e];
|
|
@@ -1738,19 +1740,19 @@ const Or = We("onBeforeRouteUpdate"), _r = We("onBeforeRouteLeave"), qr = Ft("on
|
|
|
1738
1740
|
function p(f) {
|
|
1739
1741
|
return Ut(f) ? f.props ?? {} : Nt(f) ? { default: f.props } : {};
|
|
1740
1742
|
}
|
|
1741
|
-
return (f, w) => s.value ?
|
|
1742
|
-
(
|
|
1743
|
+
return (f, w) => s.value ? ue(f.$slots, "default", ie(Ze({ key: 0 }, { route: ft(n), component: s.value, rejection: ft(r) })), () => [
|
|
1744
|
+
(ce(), tn(en(s.value)))
|
|
1743
1745
|
]) : nn("", !0);
|
|
1744
1746
|
}
|
|
1745
1747
|
});
|
|
1746
1748
|
function $r(t) {
|
|
1747
1749
|
return vt(t) && typeof t.host == "string";
|
|
1748
1750
|
}
|
|
1749
|
-
function
|
|
1751
|
+
function re(t) {
|
|
1750
1752
|
return $r(t) ? t : He(t, {});
|
|
1751
1753
|
}
|
|
1752
1754
|
function Mr(t) {
|
|
1753
|
-
const e = Dt(t.name), n = Ve(t.path), r = je(t.query), o = t.meta ?? {}, a = mn(t) ?
|
|
1755
|
+
const e = Dt(t.name), n = Ve(t.path), r = je(t.query), o = t.meta ?? {}, a = mn(t) ? re(t.host) : re(""), s = it({ meta: {}, state: {}, ...t }), c = {
|
|
1754
1756
|
matched: s,
|
|
1755
1757
|
matches: [s],
|
|
1756
1758
|
name: e,
|
|
@@ -1760,7 +1762,7 @@ function Mr(t) {
|
|
|
1760
1762
|
meta: o,
|
|
1761
1763
|
depth: 1,
|
|
1762
1764
|
state: {}
|
|
1763
|
-
}, u =
|
|
1765
|
+
}, u = he(t) ? pe(t.parent, c) : c;
|
|
1764
1766
|
return et(u.path.params, u.query.params, u.host.params), u;
|
|
1765
1767
|
}
|
|
1766
1768
|
export {
|
|
@@ -1781,10 +1783,10 @@ export {
|
|
|
1781
1783
|
Dr as onAfterRouteUpdate,
|
|
1782
1784
|
Or as onBeforeRouteLeave,
|
|
1783
1785
|
_r as onBeforeRouteUpdate,
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1786
|
+
te as path,
|
|
1787
|
+
ee as query,
|
|
1788
|
+
fe as routerInjectionKey,
|
|
1789
|
+
we as routerRejectionKey,
|
|
1788
1790
|
Ar as useLink,
|
|
1789
1791
|
xn as useRejection,
|
|
1790
1792
|
Br as useRoute,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(y=typeof globalThis<"u"?globalThis:y||self,i(y["@kitbag/router"]={},y.Vue))})(this,function(y,i){"use strict";var dr=Object.defineProperty;var Rr=(y,i,F)=>i in y?dr(y,i,{enumerable:!0,configurable:!0,writable:!0,value:F}):y[i]=F;var O=(y,i,F)=>(Rr(y,typeof i!="symbol"?i+"":i,F),F);class F extends Error{constructor(e){super(`Invalid Param "${e}": Router does not support multiple params by the same name. All param names must be unique.`)}}class it extends Error{constructor(){super("Router not installed")}}class Ft extends Error{constructor(e,n){super(`useRoute called with incorrect route. Given ${e}, expected ${n}`)}}const Pt=Symbol();function ft(){const t=i.inject(Pt);if(!t)throw new it;return t}class X extends Error{}class We extends Error{constructor(e){super(`Child property on meta for ${e} conflicts with the parent meta.`)}}function Te(t,e){return Me(t,e),{...t,...e}}function Me(t,e){const n=Object.keys(t).find(r=>r in e&&typeof e[r]!=typeof t[r]);if(n)throw new We(n)}function Z(t){return Array.isArray(t)?t:[t]}function Jt(t,e){return t.filter(n=>e===n).length}function tt(...t){const e=t.flatMap(n=>Array.isArray(n)?n:Object.keys(n).map(Ie));for(const n of e)if(Jt(e,n)>1)throw new F(n)}function Ie(t){return t.startsWith("?")?t.slice(1):t}function Fe(t,e){tt(t.params,e.params);const n=`${t.path}${e.path}`;return{path:n,params:{...t.params,...e.params},toString:()=>n}}function lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Je(t){return t.every(e=>Array.isArray(e))}function ht(t){return typeof t=="string"&&t.length>0}function Qe(t,e){tt(t.params,e.params);const n=[t.query,e.query].filter(ht).join("&");return{query:n,params:{...t.params,...e.params},toString:()=>n}}function Ge(t,e){return tt(t,e),{...t,...e}}function Ke(t){return"host"in t&&!!t.host}function Qt(t){return"parent"in t&&!!t.parent}function bt(t){return"component"in t&&!!t.component}function St(t){return"components"in t&&!!t.components}function ze(t){return"state"in t&&!!t.state}function Gt(t,e){return{...e,path:Fe(t.path,e.path),query:Qe(t.query,e.query),meta:Te(t.meta,e.meta),state:Ge(t.state,e.state),matches:[...t.matches,e.matched],host:t.host,depth:t.depth+1}}function Kt(){return typeof window<"u"&&typeof window.document<"u"}function zt(t,e){return i.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=e();return"then"in n?()=>i.h(Ye(t,n)):()=>i.h(t,n)}})}function Ye(t,e){return i.defineComponent({name:"AsyncPropsWrapper",expose:[],async setup(){const n=await e;return()=>i.h(t,n)}})}const W="[",J="]";function Xe(t){return t!==String&&t!==Boolean&&t!==Number&&t!==Date}function Ze(t){return typeof t=="function"&&Xe(t)}function pt(t){return typeof t=="object"&&"get"in t&&typeof t.get=="function"&&"set"in t&&typeof t.set=="function"}function Yt(t){return pt(t)&&t.defaultValue!==void 0}function tn(t,e){return ne(t,e)}function en(t,e){return t[e]??String}const j={invalid:t=>{throw new X(t)}},nn={get:t=>t,set:(t,{invalid:e})=>{if(typeof t!="string")throw e();return t}},Xt={get:(t,{invalid:e})=>{if(t==="true")return!0;if(t==="false")return!1;throw e()},set:(t,{invalid:e})=>{if(typeof t!="boolean")throw e();return t.toString()}},Zt={get:(t,{invalid:e})=>{const n=Number(t);if(isNaN(n))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="number")throw e();return t.toString()}},te={get:(t,{invalid:e})=>{const n=new Date(t);if(isNaN(n.getTime()))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="object"||!(t instanceof Date))throw e();return t.toISOString()}},ee={get:(t,{invalid:e})=>{try{return JSON.parse(t)}catch{throw e()}},set:(t,{invalid:e})=>{try{return JSON.stringify(t)}catch{throw e()}}};function ot(t,e,n=!1){if(t===void 0||!ht(t)){if(Yt(e))return e.defaultValue;if(n)return;throw new X}if(e===String)return nn.get(t,j);if(e===Boolean)return Xt.get(t,j);if(e===Number)return Zt.get(t,j);if(e===Date)return te.get(t,j);if(e===JSON)return ee.get(t,j);if(Ze(e))return e(t,j);if(pt(e))return e.get(t,j);if(e instanceof RegExp){if(e.test(t))return t;throw new X}return t}function at(t,e,n=!1){if(t===void 0){if(n)return"";throw new X}if(e===Boolean)return Xt.set(t,j);if(e===Number)return Zt.set(t,j);if(e===Date)return te.set(t,j);if(e===JSON)return ee.set(t,j);if(pt(e))return e.set(t,j);try{return t.toString()}catch{throw new X}}function ne(t,e){return pt(t)?{...t,defaultValue:e??t.defaultValue}:{get:n=>ot(n,t),set:n=>at(n,t),defaultValue:e}}function Q(){return Q=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(this,arguments)}var N;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(N||(N={}));var et=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function K(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}var mt="beforeunload",rn="hashchange",re="popstate";function oe(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var R=r.location,f=R.pathname,p=R.search,E=R.hash,b=o.state||{};return[b.idx,et({pathname:f,search:p,hash:E,state:b.usr||null,key:b.key||"default"})]}var s=null;function c(){if(s)d.call(s),s=null;else{var R=N.Pop,f=a(),p=f[0],E=f[1];if(d.length)if(p!=null){var b=m-p;b&&(s={action:R,location:E,retry:function(){S(b*-1)}},S(b))}else process.env.NODE_ENV!=="production"&&K(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else _(R)}}r.addEventListener(re,c);var u=N.Pop,h=a(),m=h[0],l=h[1],P=nt(),d=nt();m==null&&(m=0,o.replaceState(Q({},o.state,{idx:m}),""));function k(R){return typeof R=="string"?R:z(R)}function x(R,f){return f===void 0&&(f=null),et(Q({pathname:l.pathname,hash:"",search:""},typeof R=="string"?st(R):R,{state:f,key:Rt()}))}function $(R,f){return[{usr:R.state,key:R.key,idx:f},k(R)]}function H(R,f,p){return!d.length||(d.call({action:R,location:f,retry:p}),!1)}function _(R){u=R;var f=a();m=f[0],l=f[1],P.call({action:u,location:l})}function g(R,f){var p=N.Push,E=x(R,f);function b(){g(R,f)}if(H(p,E,b)){var B=$(E,m+1),U=B[0],C=B[1];try{o.pushState(U,"",C)}catch{r.location.assign(C)}_(p)}}function w(R,f){var p=N.Replace,E=x(R,f);function b(){w(R,f)}if(H(p,E,b)){var B=$(E,m),U=B[0],C=B[1];o.replaceState(U,"",C),_(p)}}function S(R){o.go(R)}var A={get action(){return u},get location(){return l},createHref:k,push:g,replace:w,go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(f){return P.push(f)},block:function(f){var p=d.push(f);return d.length===1&&r.addEventListener(mt,dt),function(){p(),d.length||r.removeEventListener(mt,dt)}}};return A}function on(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var f=st(r.location.hash.substr(1)),p=f.pathname,E=p===void 0?"/":p,b=f.search,B=b===void 0?"":b,U=f.hash,C=U===void 0?"":U,V=o.state||{};return[V.idx,et({pathname:E,search:B,hash:C,state:V.usr||null,key:V.key||"default"})]}var s=null;function c(){if(s)d.call(s),s=null;else{var f=N.Pop,p=a(),E=p[0],b=p[1];if(d.length)if(E!=null){var B=m-E;B&&(s={action:f,location:b,retry:function(){A(B*-1)}},A(B))}else process.env.NODE_ENV!=="production"&&K(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else g(f)}}r.addEventListener(re,c),r.addEventListener(rn,function(){var f=a(),p=f[1];z(p)!==z(l)&&c()});var u=N.Pop,h=a(),m=h[0],l=h[1],P=nt(),d=nt();m==null&&(m=0,o.replaceState(Q({},o.state,{idx:m}),""));function k(){var f=document.querySelector("base"),p="";if(f&&f.getAttribute("href")){var E=r.location.href,b=E.indexOf("#");p=b===-1?E:E.slice(0,b)}return p}function x(f){return k()+"#"+(typeof f=="string"?f:z(f))}function $(f,p){return p===void 0&&(p=null),et(Q({pathname:l.pathname,hash:"",search:""},typeof f=="string"?st(f):f,{state:p,key:Rt()}))}function H(f,p){return[{usr:f.state,key:f.key,idx:p},x(f)]}function _(f,p,E){return!d.length||(d.call({action:f,location:p,retry:E}),!1)}function g(f){u=f;var p=a();m=p[0],l=p[1],P.call({action:u,location:l})}function w(f,p){var E=N.Push,b=$(f,p);function B(){w(f,p)}if(process.env.NODE_ENV!=="production"&&K(b.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(f)+")"),_(E,b,B)){var U=H(b,m+1),C=U[0],V=U[1];try{o.pushState(C,"",V)}catch{r.location.assign(V)}g(E)}}function S(f,p){var E=N.Replace,b=$(f,p);function B(){S(f,p)}if(process.env.NODE_ENV!=="production"&&K(b.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(f)+")"),_(E,b,B)){var U=H(b,m),C=U[0],V=U[1];o.replaceState(C,"",V),g(E)}}function A(f){o.go(f)}var R={get action(){return u},get location(){return l},createHref:x,push:w,replace:S,go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(p){return P.push(p)},block:function(p){var E=d.push(p);return d.length===1&&r.addEventListener(mt,dt),function(){E(),d.length||r.removeEventListener(mt,dt)}}};return R}function ae(t){t===void 0&&(t={});var e=t,n=e.initialEntries,r=n===void 0?["/"]:n,o=e.initialIndex,a=r.map(function(g){var w=et(Q({pathname:"/",search:"",hash:"",state:null,key:Rt()},typeof g=="string"?st(g):g));return process.env.NODE_ENV!=="production"&&K(w.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(g)+")"),w}),s=se(o??a.length-1,0,a.length-1),c=N.Pop,u=a[s],h=nt(),m=nt();function l(g){return typeof g=="string"?g:z(g)}function P(g,w){return w===void 0&&(w=null),et(Q({pathname:u.pathname,search:"",hash:""},typeof g=="string"?st(g):g,{state:w,key:Rt()}))}function d(g,w,S){return!m.length||(m.call({action:g,location:w,retry:S}),!1)}function k(g,w){c=g,u=w,h.call({action:c,location:u})}function x(g,w){var S=N.Push,A=P(g,w);function R(){x(g,w)}process.env.NODE_ENV!=="production"&&K(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(g)+")"),d(S,A,R)&&(s+=1,a.splice(s,a.length,A),k(S,A))}function $(g,w){var S=N.Replace,A=P(g,w);function R(){$(g,w)}process.env.NODE_ENV!=="production"&&K(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(g)+")"),d(S,A,R)&&(a[s]=A,k(S,A))}function H(g){var w=se(s+g,0,a.length-1),S=N.Pop,A=a[w];function R(){H(g)}d(S,A,R)&&(s=w,k(S,A))}var _={get index(){return s},get action(){return c},get location(){return u},createHref:l,push:x,replace:$,go:H,back:function(){H(-1)},forward:function(){H(1)},listen:function(w){return h.push(w)},block:function(w){return m.push(w)}};return _}function se(t,e,n){return Math.min(Math.max(t,e),n)}function dt(t){t.preventDefault(),t.returnValue=""}function nt(){var t=[];return{get length(){return t.length},push:function(n){return t.push(n),function(){t=t.filter(function(r){return r!==n})}},call:function(n){t.forEach(function(r){return r&&r(n)})}}}function Rt(){return Math.random().toString(36).substr(2,8)}function z(t){var e=t.pathname,n=e===void 0?"/":e,r=t.search,o=r===void 0?"":r,a=t.hash,s=a===void 0?"":a;return o&&o!=="?"&&(n+=o.charAt(0)==="?"?o:"?"+o),s&&s!=="#"&&(n+=s.charAt(0)==="#"?s:"#"+s),n}function st(t){var e={};if(t){var n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));var r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}const At=Symbol();function ce(){const t=i.inject(At);if(!t)throw new it;return t}const ue=Symbol("isRouterRouteSymbol");function an(t){return typeof t=="object"&&t!==null&&ue in t}function sn(t,e){function n(m,l,P){if(typeof m=="object"){const k={...t.params,...m};return e(t.name,k,l)}const d={...t.params,[m]:l};return e(t.name,d,P)}const{matched:r,matches:o,name:a,query:s,params:c,state:u}=i.toRefs(t),h=i.reactive({matched:r,matches:o,state:u,query:s,params:c,name:a,update:n,[ue]:!0});return new Proxy(h,{get:(m,l,P)=>l==="params"?new Proxy(t.params,{set(d,k,x){return n(k,x),!0}}):l==="state"?new Proxy(t.state,{set(d,k,x){return n({},{state:{...t.state,[k]:x}}),!0}}):Reflect.get(m,l,P)})}function cn(t,e){const n=i.reactive({...t}),r=s=>{Object.assign(n,{...s})},o=n,a=sn(o,e);return{currentRoute:o,routerRoute:a,updateRoute:r}}function Y(t){return!t.startsWith("http")?fn(t):un(t)}function un(t){const{protocol:e,host:n,pathname:r,search:o,searchParams:a,hash:s}=new URL(t,t);return{protocol:e,host:n,pathname:r,search:o,searchParams:a,hash:s}}function fn(t){const{pathname:e,search:n,searchParams:r,hash:o}=new URL(t,"https://localhost");return{pathname:e,search:n,searchParams:r,hash:o}}function ln(t){return e=>{const{host:n}=Y(e);return!(n===void 0||n===t)}}function hn({mode:t,listener:e}){const n=pn(t),r=(u,h)=>{if(h!=null&&h.replace)return n.replace(u,h.state);n.push(u,h==null?void 0:h.state)},o=()=>{const u=z(n.location);return n.replace(u)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(e)},stopListening:()=>{a==null||a()}}}function pn(t="auto"){switch(t){case"auto":return Kt()?oe():ae();case"browser":return oe();case"memory":return ae();case"hash":return on();default:const e=t;throw new Error(`Switch is not exhaustive for mode: ${e}`)}}class gt{constructor(){O(this,"onBeforeRouteEnter",new Set);O(this,"onBeforeRouteUpdate",new Set);O(this,"onBeforeRouteLeave",new Set);O(this,"onAfterRouteEnter",new Set);O(this,"onAfterRouteUpdate",new Set);O(this,"onAfterRouteLeave",new Set)}}class ie extends Error{}class ct extends Error{constructor(n){super("Error occurred during a router push operation.");O(this,"to");this.to=n}}class kt extends Error{constructor(n){super(`Routing action rejected: ${n}`);O(this,"type");this.type=n}}function mn(t,e){const n=new gt;return t.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&xt(t,e,o)&&Z(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&Lt(t,e,o)&&Z(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&Bt(t,e,o)&&Z(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function dn(t,e){const n=new gt;return t.matches.forEach((r,o)=>{r.onAfterRouteEnter&&xt(t,e,o)&&Z(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&Lt(t,e,o)&&Z(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onAfterRouteLeave&&Bt(t,e,o)&&Z(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function T(t){return typeof t!="string"?!1:/^(https?:\/\/|\/).*/g.test(t)}function Rn(){const t=s=>{throw new kt(s)},e=(...s)=>{throw new ct(s)},n=(s,c,u)=>{if(T(s)){const l=c??{};throw new ct([s,{...l,replace:!0}])}const h=c,m=u??{};throw new ct([s,h,{...m,replace:!0}])},r=()=>{throw new ie};async function o({to:s,from:c,hooks:u}){const{global:h,component:m}=u,l=mn(s,c),P=[...h.onBeforeRouteEnter,...l.onBeforeRouteEnter,...h.onBeforeRouteUpdate,...l.onBeforeRouteUpdate,...m.onBeforeRouteUpdate,...h.onBeforeRouteLeave,...l.onBeforeRouteLeave,...m.onBeforeRouteLeave];try{const d=P.map(k=>k(s,{from:c,reject:t,push:e,replace:n,abort:r}));await Promise.all(d)}catch(d){if(d instanceof ct)return{status:"PUSH",to:d.to};if(d instanceof kt)return{status:"REJECT",type:d.type};if(d instanceof ie)return{status:"ABORT"};throw d}return{status:"SUCCESS"}}async function a({to:s,from:c,hooks:u}){const{global:h,component:m}=u,l=dn(s,c),P=[...m.onAfterRouteLeave,...l.onAfterRouteLeave,...h.onAfterRouteLeave,...m.onAfterRouteUpdate,...l.onAfterRouteUpdate,...h.onAfterRouteUpdate,...m.onAfterRouteEnter,...l.onAfterRouteEnter,...h.onAfterRouteEnter];try{const d=P.map(k=>k(s,{from:c,reject:t,push:e,replace:n}));await Promise.all(d)}catch(d){if(d instanceof ct)return{status:"PUSH",to:d.to};if(d instanceof kt)return{status:"REJECT",type:d.type};throw d}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const xt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},Bt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},Lt=(t,e,n)=>t.matches[n]===(e==null?void 0:e.matches[n]);function fe(t){switch(t){case"onBeforeRouteEnter":case"onAfterRouteEnter":return xt;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Lt;case"onBeforeRouteLeave":case"onAfterRouteLeave":return Bt;default:throw new Error(`Switch is not exhaustive for lifecycle: ${t}`)}}class gn{constructor(){O(this,"global",new gt);O(this,"component",new gt)}addBeforeRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=fe(e),s=this[n][e],c=(u,h)=>{if(a(u,h.from,r))return o(u,h)};return s.add(c),()=>s.delete(c)}addAfterRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=fe(e),s=this[n][e],c=(u,h)=>{if(a(u,h.from,r))return o(u,h)};return s.add(c),()=>s.delete(c)}}const le=Symbol();function yn(){const t=new gn;return{onBeforeRouteEnter:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:c,timing:"global",depth:0}),onBeforeRouteUpdate:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:c,timing:"global",depth:0}),onBeforeRouteLeave:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:c,timing:"global",depth:0}),onAfterRouteEnter:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:c,timing:"global",depth:0}),onAfterRouteUpdate:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:c,timing:"global",depth:0}),onAfterRouteLeave:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:c,timing:"global",depth:0}),hooks:t}}function wn(t){return i.defineComponent(()=>()=>i.h("h1",t),{name:t,props:[]})}function he(t){const e=new URLSearchParams(t);return{get:n=>e.get(n),getAll:n=>e.getAll(n)}}const pe=Symbol();function vn({rejections:t}){const e=s=>{const c={...t};return i.markRaw(c[s]??wn(s))},n=s=>{const c=i.markRaw(e(s)),u={name:s,component:c,meta:{},state:{}};return{matched:u,matches:[u],name:s,query:he(""),params:{},state:{},[pe]:!0}},r=s=>pe in s,o=s=>{if(!s){a.value=null;return}const c=e(s);a.value={type:s,component:c}},a=i.ref(null);return{setRejection:o,rejection:a,getRejectionRoute:n,isRejectionRoute:r}}class En extends Error{constructor(e){super(`Route not found: "${e}"`)}}function Ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pn(t,e){const n=Array.from(t.matchAll(e));if(n.length===0)return[t];let r=0;const o=n.reduce((s,c)=>{const u=Ut(t.slice(r,c.index));u.length&&s.push(u);const[h]=c;return s.push(h),r=c.index+h.length,s},[]),a=t.slice(r);return a&&o.push(a),o}function bn(t){const e=me(t.path.toString());return new RegExp(`^${e}$`,"i")}function Sn(t){const e=new URLSearchParams(t.query.toString());return Array.from(e.entries()).filter(([,n])=>!Ct(n)).map(([n,r])=>{const o=me(r);return new RegExp(`${Ut(n)}=${o}(&|$)`,"i")})}function me(t){return Pn(t,new RegExp(An,"g")).map(e=>e.startsWith(W)?de(e):Ut(e)).join("")}function de(t){return[kn,xn].reduce((e,n)=>n(e),t)}const An=`\\${W}\\??([\\w-_]+)\\${J}`,Nt=`\\${W}\\?([\\w-_]+)\\${J}`,Re=`\\${W}([\\w-_]+)\\${J}`;function kn(t){return t.replace(new RegExp(Nt,"g"),".*")}function Ct(t){return new RegExp(Nt,"g").test(t)}function xn(t){return t.replace(new RegExp(Re,"g"),".+")}function yt(t){const[e]=wt(t,new RegExp(Nt,"g")),[n]=wt(t,new RegExp(Re,"g"));return e??n}function wt(t,e){return Array.from(t.matchAll(e)).flatMap(([,...r])=>r.map(o=>ht(o)?o:""))}function ge(t,e,n){const r=we(e,n),[o]=wt(t,r);return o}function ye(t,e){if(!e)return t;const{name:n,param:r,value:o}=e,a=we(t,n);return wt(t,a).reduce((c,u)=>u===void 0?c:c.replace(u,()=>at(o,r,n.startsWith("?"))),t)}function we(t,e){const n=[Bn,Ln,de].reduce((r,o)=>o(r,e),t);return new RegExp(n,"g")}function Bn(t,e){if(!e.startsWith("?"))return t;const n=new RegExp(`\\${W}\\${e}\\${J}`,"g");return t.replace(n,"(.*)")}function Ln(t,e){if(e.startsWith("?"))return t;const n=new RegExp(`\\${W}${e}\\${J}`,"g");return t.replace(n,"(.+)")}function ve(t,...e){return e.reduce((n,r)=>{if(!r)return n;const o=new URLSearchParams(r).toString();return Object.keys(o).length===0?n:n.includes("?")?`${n}&${o}`:`${n}?${o}`},t)}function Un(t,e={}){const{params:n={},query:r}=e,o=Nn(t.host,n),a=Cn(t.path,n),s=$n(t.query,n);return ve(`${o}${a}`,s,r)}function Nn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,a])=>{const s=yt(`${W}${o}${J}`);return s?ye(r,{name:o,param:a,value:e[s]}):r},n)}function Cn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,a])=>{const s=yt(`${W}${o}${J}`);return s?ye(r,{name:o,param:a,value:e[s]}):r},n)}function $n(t,e){const n=t.toString();if(!n)return{};const r=new URLSearchParams(n);return Array.from(r.entries()).reduce((o,[a,s])=>{const c=yt(s);if(!c)return{...o,[a]:s};const h=at(e[c],t.params[c],Ct(s)),m=e[c]===void 0&&h==="";return Ct(s)&&m?o:{...o,[a]:h}},{})}function jn(t){return(e,n,r)=>{if(T(e))return ve(e,(n??{}).query);const o=n??{},a=r??{},s=t.find(u=>u.name===e);if(!s)throw new En(String(e));return Un(s,{params:o,query:a.query})}}class Hn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function Vn(t){if(t)return t;if(Kt())return window.location.toString();throw new Hn}const On=(t,e)=>{try{Ee(t,e)}catch{return!1}return!0},Ee=(t,e)=>{const{pathname:n,search:r}=Y(e);return{..._n(t.path,n),...qn(t.query,r)}};function _n(t,e){const n={},r=decodeURIComponent(e);for(const[o,a]of Object.entries(t.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,u=ge(r,t.toString(),o),h=ot(u,a,s);n[c]=h}return n}function qn(t,e){const n={},r=new URLSearchParams(e);for(const[o,a]of Object.entries(t.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,u=r.get(c)??void 0,h=ot(u,a,s);n[c]=h}return n}const Dn=t=>"name"in t.matched&&!!t.matched.name,Wn=(t,e)=>{const{pathname:n}=Y(e);return bn(t).test(n)},Tn=(t,e)=>{const{search:n}=Y(e);return Sn(t).every(o=>o.test(n))};function Mn(t){const{searchParams:e,pathname:n}=Y(t),r=-1,o=1;return(a,s)=>{const c=be(a,e),u=Pe(a,n),h=be(s,e),m=Pe(s,n);return a.depth>s.depth?r:a.depth<s.depth?o:c+u>h+m?r:c+u<h+m?o:0}}function Pe(t,e){const n=Object.keys(t.path.params).filter(o=>o.startsWith("?")).map(o=>o),r=n.filter(o=>ge(e,t.path.toString(),o)===void 0);return n.length-r.length}function be(t,e){const n=new URLSearchParams(t.query.toString()),r=Array.from(n.keys()),o=r.filter(a=>!e.has(a));return r.length-o.length}function Se(t){return!!t&&typeof t=="object"}const vt=!0;function In(t,e,n){if(Se(t)&&e in t){const r=t[e];if(typeof r=="string")return ot(r,n,vt)}return ot(void 0,n,vt)}function Fn(t,e){const n={};for(const[r,o]of Object.entries(t)){const a=In(e,r,o);n[r]=a}return n}function Jn(t,e,n){if(Se(t)&&e in t){const r=t[e];return at(r,n,vt)}return at(void 0,n,vt)}const Ae=(t,e)=>{const n={};for(const[r,o]of Object.entries(t)){const a=Jn(e,r,o);n[r]=a}return n},Qn=[Dn,Wn,Tn,On];function $t(t,e,n){const r=Mn(e),o=t.filter(c=>Qn.every(u=>u(c,e))).sort(r);if(o.length===0)return;const[a]=o,{search:s}=Y(e);return{matched:a.matched,matches:a.matches,name:a.name,query:he(s),params:Ee(a,e),state:Fn(a.state,n)}}function jt(t,e){const n=new RegExp(`\\${W}(\\??[\\w-_]+)\\${J}`,"g");return Array.from(t.matchAll(n)).reduce((o,[a,s])=>{const c=yt(a);if(!c)return o;const u=en(e,c);return tt([c],o),o[s]=u,o},{})}function ke(t,e){return{host:t,params:jt(t,e),toString:()=>t}}function Ht(t){return t===void 0?"":t}function Vt(t,e){return{path:t,params:jt(t,e),toString:()=>t}}function Gn(t){return lt(t)&&typeof t.path=="string"}function xe(t){return t===void 0?Vt("",{}):Gn(t)?t:Vt(t,{})}function Ot(t,e){return{query:t,params:jt(t,e),toString:()=>t}}function Kn(t){return lt(t)&&typeof t.query=="string"}function Be(t){return t===void 0?Ot("",{}):Kn(t)?t:Ot(t,{})}function M(t){const e=Ht(t.name),n=xe(t.path),r=Be(t.query),o=t.meta??{},a=ze(t)?t.state:{},s=i.markRaw({meta:{},state:{},...t}),c={matched:s,matches:[s],name:e,path:n,query:r,meta:o,state:a,depth:1,host:ke("",{}),prefetch:t.prefetch},u=Qt(t)?Gt(t.parent,c):c;return tt(u.path.params,u.query.params),u}function zn(t,e){if(!ht(e))return t;const n=M({path:e});return t.map(r=>M({parent:n,...r}))}class Yn extends Error{constructor(e){super(`Invalid Name "${e}": Router does not support multiple routes with the same name. All name names must be unique.`)}}function Xn(t){const e=t.map(({name:n})=>n);for(const n of e)if(Jt(e,n)>1)throw new Yn(n)}function Zn(t,e={}){const n=Je(t)?t.flat():t,r=zn(n,e.base);Xn(r);const o=jn(r),a=hn({mode:e.historyMode,listener:({location:v})=>{const L=z(v);x(L,{state:v.state})}}),{runBeforeRouteHooks:s,runAfterRouteHooks:c}=Rn(),{hooks:u,onBeforeRouteEnter:h,onAfterRouteUpdate:m,onBeforeRouteLeave:l,onAfterRouteEnter:P,onBeforeRouteUpdate:d,onAfterRouteLeave:k}=yn();async function x(v,L={}){if(a.stopListening(),C(v))return a.update(v,L);const q=$t(r,v,L.state)??A("NotFound"),D={...f},rt=await s({to:q,from:D,hooks:u});switch(rt.status){case"ABORT":return;case"PUSH":a.update(v,L),await $(...rt.to);return;case"REJECT":a.update(v,L),w(rt.type),E(q);break;case"SUCCESS":a.update(v,L),w(null),E(q);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(rt)}`)}const G=await c({to:q,from:D,hooks:u});switch(G.status){case"PUSH":await $(...G.to);break;case"REJECT":w(G.type);break;case"SUCCESS":break;default:const I=G;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(I)}`)}a.startListening()}const $=(v,L,q)=>{if(T(v)){const ut={...L},It=o(v,ut);return x(It,ut)}const D={...q},G=o(v,L??{},D),I=Tt(v),Mt=Ae((I==null?void 0:I.state)??{},D.state);return x(G,{...D,state:Mt})},H=(v,L,q)=>{if(T(v)){const ut={...L,replace:!0},It=o(v,ut);return x(It,ut)}const D={...q,replace:!0},G=o(v,L??{},D),I=Tt(v),Mt=Ae((I==null?void 0:I.state)??{},D.state);return x(G,{...D,state:Mt})},_=v=>w(v),g=(v,L={})=>{if(!T(v)){const q=o(v,L);return $t(r,q)}if(!C(v))return $t(r,v)},{setRejection:w,rejection:S,getRejectionRoute:A}=vn(e),R=A("NotFound"),{currentRoute:f,routerRoute:p,updateRoute:E}=cn(R,$);a.startListening();const b=Vn(e.initialUrl),B=a.location.state,{host:U}=Y(b),C=ln(U),V=x(b,{replace:!0,state:B});function Tt(v){return r.find(L=>L.name===v)}function mr(v){v.component("RouterView",_e),v.component("RouterLink",Oe),v.provide(At,S),v.provide(le,u),v.provide(Pt,De)}const De={route:p,resolve:o,push:$,replace:H,reject:_,find:g,refresh:a.refresh,forward:a.forward,back:a.back,go:a.go,install:mr,initialized:V,isExternal:C,onBeforeRouteEnter:h,onAfterRouteUpdate:m,onBeforeRouteLeave:l,onAfterRouteEnter:P,onBeforeRouteUpdate:d,onAfterRouteLeave:k,prefetch:e.prefetch};return De}const Et={template:"<div>This is component</div>"},_t=M({name:"parentA",path:"/parentA/[paramA]"}),Le=M({parent:_t,name:"parentA.childA",path:"/[?paramB]"}),tr=M({parent:_t,name:"parentA.childB",path:"/[paramD]",component:Et}),er=M({parent:Le,name:"parentA.childA.grandChildA",path:"/[paramC]",component:Et});M({name:"parentB",path:"/parentB",component:Et}),M({name:"parentC",path:"/",component:Et});const nr={components:!0};function rr({routerPrefetch:t,routePrefetch:e,linkPrefetch:n},r){return qt(n,r)??qt(e,r)??qt(t,r)??nr[r]}function qt(t,e){return lt(t)?t[e]:t}const or=i.defineAsyncComponent(()=>new Promise(t=>{t({default:{template:""}})}));function Ue(t){return t.name===or.name&&"setup"in t}function Ne(t,e={},n={}){const r=ft(),o=i.toRef(t),a=i.computed(()=>T(o.value)?{}:i.toValue(e)),s=i.computed(()=>T(o.value)?i.toValue(e):i.toValue(n)),c=i.computed(()=>{if(T(o.value))return o.value;try{return r.resolve(o.value,a.value,s.value)}catch(l){throw l instanceof X&&console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`,l),l}}),u=i.computed(()=>r.find(c.value,s.value)),h=i.computed(()=>!!u.value&&r.route.matches.includes(u.value.matched)),m=i.computed(()=>!!u.value&&r.route.matched===u.value.matched);return i.watch(u,l=>{if(!l)return;const{prefetch:P}=r,{prefetch:d}=s.value;ar(l,{routerPrefetch:P,linkPrefetch:d})},{immediate:!0}),{route:u,href:c,isMatch:h,isExactMatch:m,push:l=>r.push(c.value,{},{...s.value,...l}),replace:l=>r.replace(c.value,{},{...s.value,...l})}}function ar(t,{routerPrefetch:e,linkPrefetch:n}){t.matches.forEach(r=>{rr({routePrefetch:r.prefetch,routerPrefetch:e,linkPrefetch:n},"components")&&(bt(r)&&Ue(r.component)&&r.component.setup(),St(r)&&Object.values(r.components).forEach(a=>{Ue(a)&&a.setup()}))})}function Ce(t,e,{exact:n}={}){if(!an(t))return!1;if(e===void 0)return!0;const r=t.matches.map(o=>Ht(o.name));if(n){const o=r.at(-1);return e===o}return r.includes(e)}function $e(t,e){const n=ft();function r(){if(!t)return;if(!Ce(n.route,t,e))throw new Ft(t,n.route.name)}return i.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const je=Symbol();function Dt(){return i.inject(je,0)}function He(){const t=i.inject(le);if(!t)throw new it;return t}function Ve(t){return e=>{const n=Dt(),o=He().addBeforeRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}function Wt(t){return e=>{const n=Dt(),o=He().addAfterRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}const sr=Ve("onBeforeRouteUpdate"),cr=Ve("onBeforeRouteLeave"),ur=Wt("onAfterRouteEnter"),ir=Wt("onAfterRouteUpdate"),fr=Wt("onAfterRouteLeave"),lr=["href"],Oe=i.defineComponent({__name:"routerLink",props:{to:{},prefetch:{type:[Boolean,Object],default:void 0},query:{},replace:{type:Boolean},state:{}},setup(t){const e=t,n=ft(),r=i.computed(()=>T(e.to)?e.to:e.to(n.resolve)),o=i.computed(()=>{const{to:l,...P}=e;return P}),{href:a,isMatch:s,isExactMatch:c}=Ne(r,o),u=i.computed(()=>({"router-link--match":s.value,"router-link--exact-match":c.value})),h=i.computed(()=>n.isExternal(r.value));function m(l){l.preventDefault(),n.push(a.value,o.value)}return(l,P)=>(i.openBlock(),i.createElementBlock("a",{href:r.value,class:i.normalizeClass(["router-link",u.value]),onClick:m},[i.renderSlot(l.$slots,"default",i.normalizeProps(i.guardReactiveProps({resolved:r.value,isMatch:i.unref(s),isExactMatch:i.unref(c),isExternal:h.value})))],10,lr))}}),_e=i.defineComponent({__name:"routerView",props:{name:{}},setup(t){const{name:e="default"}=t,n=$e(),r=ce(),o=Dt(),a=i.resolveComponent("RouterView",!0);i.provide(je,o+1);const s=i.computed(()=>{if(r.value)return r.value.component;const l=n.matches.at(o);if(!l)return null;const P=c(l),d=h(l);return P?d?zt(P,()=>d(n.params)):P:null});function c(l){return u(l)[e]}function u(l){return St(l)?l.components:bt(l)?{default:l.component}:typeof a=="string"?{}:{default:a}}function h(l){return m(l)[e]}function m(l){return St(l)?l.props??{}:bt(l)?{default:l.props}:{}}return(l,P)=>s.value?i.renderSlot(l.$slots,"default",i.normalizeProps(i.mergeProps({key:0},{route:i.unref(n),component:s.value,rejection:i.unref(r)})),()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.value)))]):i.createCommentVNode("",!0)}});function hr(t){return lt(t)&&typeof t.host=="string"}function qe(t){return hr(t)?t:ke(t,{})}function pr(t){const e=Ht(t.name),n=xe(t.path),r=Be(t.query),o=t.meta??{},a=Ke(t)?qe(t.host):qe(""),s=i.markRaw({meta:{},state:{},...t}),c={matched:s,matches:[s],name:e,host:a,path:n,query:r,meta:o,depth:1,state:{}},u=Qt(t)?Gt(t.parent,c):c;return tt(u.path.params,u.query.params,u.host.params),u}y.DuplicateParamsError=F,y.RouterLink=Oe,y.RouterNotInstalledError=it,y.RouterView=_e,y.UseRouteInvalidError=Ft,y.component=zt,y.createExternalRoute=pr,y.createParam=ne,y.createRoute=M,y.createRouter=Zn,y.isParamWithDefault=Yt,y.isRoute=Ce,y.onAfterRouteEnter=ur,y.onAfterRouteLeave=ir,y.onAfterRouteUpdate=fr,y.onBeforeRouteLeave=sr,y.onBeforeRouteUpdate=cr,y.path=Vt,y.query=Ot,y.routerInjectionKey=Pt,y.routerRejectionKey=At,y.useLink=Ne,y.useRejection=ce,y.useRoute=$e,y.useRouter=ft,y.withDefault=tn,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(y,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(y=typeof globalThis<"u"?globalThis:y||self,i(y["@kitbag/router"]={},y.Vue))})(this,function(y,i){"use strict";var dr=Object.defineProperty;var Rr=(y,i,F)=>i in y?dr(y,i,{enumerable:!0,configurable:!0,writable:!0,value:F}):y[i]=F;var O=(y,i,F)=>(Rr(y,typeof i!="symbol"?i+"":i,F),F);class F extends Error{constructor(e){super(`Invalid Param "${e}": Router does not support multiple params by the same name. All param names must be unique.`)}}class it extends Error{constructor(){super("Router not installed")}}class Ft extends Error{constructor(e,n){super(`useRoute called with incorrect route. Given ${e}, expected ${n}`)}}const Pt=Symbol();function ft(){const t=i.inject(Pt);if(!t)throw new it;return t}class X extends Error{}class We extends Error{constructor(e){super(`Child property on meta for ${e} conflicts with the parent meta.`)}}function Te(t,e){return Me(t,e),{...t,...e}}function Me(t,e){const n=Object.keys(t).find(r=>r in e&&typeof e[r]!=typeof t[r]);if(n)throw new We(n)}function Z(t){return Array.isArray(t)?t:[t]}function Jt(t,e){return t.filter(n=>e===n).length}function tt(...t){const e=t.flatMap(n=>Array.isArray(n)?n:Object.keys(n).map(Ie));for(const n of e)if(Jt(e,n)>1)throw new F(n)}function Ie(t){return t.startsWith("?")?t.slice(1):t}function Fe(t,e){tt(t.params,e.params);const n=`${t.path}${e.path}`;return{path:n,params:{...t.params,...e.params},toString:()=>n}}function lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Je(t){return t.every(e=>Array.isArray(e))}function ht(t){return typeof t=="string"&&t.length>0}function Qe(t,e){tt(t.params,e.params);const n=[t.query,e.query].filter(ht).join("&");return{query:n,params:{...t.params,...e.params},toString:()=>n}}function Ge(t,e){return tt(t,e),{...t,...e}}function Ke(t){return"host"in t&&!!t.host}function Qt(t){return"parent"in t&&!!t.parent}function bt(t){return"component"in t&&!!t.component}function St(t){return"components"in t&&!!t.components}function ze(t){return"state"in t&&!!t.state}function Gt(t,e){return{...e,path:Fe(t.path,e.path),query:Qe(t.query,e.query),meta:Te(t.meta,e.meta),state:Ge(t.state,e.state),matches:[...t.matches,e.matched],host:t.host,depth:t.depth+1}}function Kt(){return typeof window<"u"&&typeof window.document<"u"}function zt(t,e){return i.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=e();return"then"in n?()=>i.h(Ye(t,n)):()=>i.h(t,n)}})}function Ye(t,e){return i.defineComponent({name:"AsyncPropsWrapper",expose:[],async setup(){const n=await e;return()=>i.h(t,n)}})}const W="[",J="]";function Xe(t){return t!==String&&t!==Boolean&&t!==Number&&t!==Date}function Ze(t){return typeof t=="function"&&Xe(t)}function pt(t){return typeof t=="object"&&"get"in t&&typeof t.get=="function"&&"set"in t&&typeof t.set=="function"}function Yt(t){return pt(t)&&t.defaultValue!==void 0}function tn(t,e){return ne(t,e)}function en(t,e){return t[e]??String}const j={invalid:t=>{throw new X(t)}},nn={get:t=>t,set:(t,{invalid:e})=>{if(typeof t!="string")throw e();return t}},Xt={get:(t,{invalid:e})=>{if(t==="true")return!0;if(t==="false")return!1;throw e()},set:(t,{invalid:e})=>{if(typeof t!="boolean")throw e();return t.toString()}},Zt={get:(t,{invalid:e})=>{const n=Number(t);if(isNaN(n))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="number")throw e();return t.toString()}},te={get:(t,{invalid:e})=>{const n=new Date(t);if(isNaN(n.getTime()))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="object"||!(t instanceof Date))throw e();return t.toISOString()}},ee={get:(t,{invalid:e})=>{try{return JSON.parse(t)}catch{throw e()}},set:(t,{invalid:e})=>{try{return JSON.stringify(t)}catch{throw e()}}};function ot(t,e,n=!1){if(t===void 0||!ht(t)){if(Yt(e))return e.defaultValue;if(n)return;throw new X}if(e===String)return nn.get(t,j);if(e===Boolean)return Xt.get(t,j);if(e===Number)return Zt.get(t,j);if(e===Date)return te.get(t,j);if(e===JSON)return ee.get(t,j);if(Ze(e))return e(t,j);if(pt(e))return e.get(t,j);if(e instanceof RegExp){if(e.test(t))return t;throw new X}return t}function at(t,e,n=!1){if(t===void 0){if(n)return"";throw new X}if(e===Boolean)return Xt.set(t,j);if(e===Number)return Zt.set(t,j);if(e===Date)return te.set(t,j);if(e===JSON)return ee.set(t,j);if(pt(e))return e.set(t,j);try{return t.toString()}catch{throw new X}}function ne(t,e){return pt(t)?{...t,defaultValue:e??t.defaultValue}:{get:n=>ot(n,t),set:n=>at(n,t),defaultValue:e}}function Q(){return Q=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(this,arguments)}var N;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(N||(N={}));var et=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function K(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}var mt="beforeunload",rn="hashchange",re="popstate";function oe(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var R=r.location,f=R.pathname,p=R.search,E=R.hash,b=o.state||{};return[b.idx,et({pathname:f,search:p,hash:E,state:b.usr||null,key:b.key||"default"})]}var c=null;function s(){if(c)d.call(c),c=null;else{var R=N.Pop,f=a(),p=f[0],E=f[1];if(d.length)if(p!=null){var b=m-p;b&&(c={action:R,location:E,retry:function(){S(b*-1)}},S(b))}else process.env.NODE_ENV!=="production"&&K(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else _(R)}}r.addEventListener(re,s);var u=N.Pop,h=a(),m=h[0],l=h[1],P=nt(),d=nt();m==null&&(m=0,o.replaceState(Q({},o.state,{idx:m}),""));function k(R){return typeof R=="string"?R:z(R)}function x(R,f){return f===void 0&&(f=null),et(Q({pathname:l.pathname,hash:"",search:""},typeof R=="string"?ct(R):R,{state:f,key:Rt()}))}function $(R,f){return[{usr:R.state,key:R.key,idx:f},k(R)]}function H(R,f,p){return!d.length||(d.call({action:R,location:f,retry:p}),!1)}function _(R){u=R;var f=a();m=f[0],l=f[1],P.call({action:u,location:l})}function g(R,f){var p=N.Push,E=x(R,f);function b(){g(R,f)}if(H(p,E,b)){var B=$(E,m+1),U=B[0],C=B[1];try{o.pushState(U,"",C)}catch{r.location.assign(C)}_(p)}}function w(R,f){var p=N.Replace,E=x(R,f);function b(){w(R,f)}if(H(p,E,b)){var B=$(E,m),U=B[0],C=B[1];o.replaceState(U,"",C),_(p)}}function S(R){o.go(R)}var A={get action(){return u},get location(){return l},createHref:k,push:g,replace:w,go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(f){return P.push(f)},block:function(f){var p=d.push(f);return d.length===1&&r.addEventListener(mt,dt),function(){p(),d.length||r.removeEventListener(mt,dt)}}};return A}function on(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var f=ct(r.location.hash.substr(1)),p=f.pathname,E=p===void 0?"/":p,b=f.search,B=b===void 0?"":b,U=f.hash,C=U===void 0?"":U,V=o.state||{};return[V.idx,et({pathname:E,search:B,hash:C,state:V.usr||null,key:V.key||"default"})]}var c=null;function s(){if(c)d.call(c),c=null;else{var f=N.Pop,p=a(),E=p[0],b=p[1];if(d.length)if(E!=null){var B=m-E;B&&(c={action:f,location:b,retry:function(){A(B*-1)}},A(B))}else process.env.NODE_ENV!=="production"&&K(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else g(f)}}r.addEventListener(re,s),r.addEventListener(rn,function(){var f=a(),p=f[1];z(p)!==z(l)&&s()});var u=N.Pop,h=a(),m=h[0],l=h[1],P=nt(),d=nt();m==null&&(m=0,o.replaceState(Q({},o.state,{idx:m}),""));function k(){var f=document.querySelector("base"),p="";if(f&&f.getAttribute("href")){var E=r.location.href,b=E.indexOf("#");p=b===-1?E:E.slice(0,b)}return p}function x(f){return k()+"#"+(typeof f=="string"?f:z(f))}function $(f,p){return p===void 0&&(p=null),et(Q({pathname:l.pathname,hash:"",search:""},typeof f=="string"?ct(f):f,{state:p,key:Rt()}))}function H(f,p){return[{usr:f.state,key:f.key,idx:p},x(f)]}function _(f,p,E){return!d.length||(d.call({action:f,location:p,retry:E}),!1)}function g(f){u=f;var p=a();m=p[0],l=p[1],P.call({action:u,location:l})}function w(f,p){var E=N.Push,b=$(f,p);function B(){w(f,p)}if(process.env.NODE_ENV!=="production"&&K(b.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(f)+")"),_(E,b,B)){var U=H(b,m+1),C=U[0],V=U[1];try{o.pushState(C,"",V)}catch{r.location.assign(V)}g(E)}}function S(f,p){var E=N.Replace,b=$(f,p);function B(){S(f,p)}if(process.env.NODE_ENV!=="production"&&K(b.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(f)+")"),_(E,b,B)){var U=H(b,m),C=U[0],V=U[1];o.replaceState(C,"",V),g(E)}}function A(f){o.go(f)}var R={get action(){return u},get location(){return l},createHref:x,push:w,replace:S,go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(p){return P.push(p)},block:function(p){var E=d.push(p);return d.length===1&&r.addEventListener(mt,dt),function(){E(),d.length||r.removeEventListener(mt,dt)}}};return R}function ae(t){t===void 0&&(t={});var e=t,n=e.initialEntries,r=n===void 0?["/"]:n,o=e.initialIndex,a=r.map(function(g){var w=et(Q({pathname:"/",search:"",hash:"",state:null,key:Rt()},typeof g=="string"?ct(g):g));return process.env.NODE_ENV!=="production"&&K(w.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(g)+")"),w}),c=ce(o??a.length-1,0,a.length-1),s=N.Pop,u=a[c],h=nt(),m=nt();function l(g){return typeof g=="string"?g:z(g)}function P(g,w){return w===void 0&&(w=null),et(Q({pathname:u.pathname,search:"",hash:""},typeof g=="string"?ct(g):g,{state:w,key:Rt()}))}function d(g,w,S){return!m.length||(m.call({action:g,location:w,retry:S}),!1)}function k(g,w){s=g,u=w,h.call({action:s,location:u})}function x(g,w){var S=N.Push,A=P(g,w);function R(){x(g,w)}process.env.NODE_ENV!=="production"&&K(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(g)+")"),d(S,A,R)&&(c+=1,a.splice(c,a.length,A),k(S,A))}function $(g,w){var S=N.Replace,A=P(g,w);function R(){$(g,w)}process.env.NODE_ENV!=="production"&&K(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(g)+")"),d(S,A,R)&&(a[c]=A,k(S,A))}function H(g){var w=ce(c+g,0,a.length-1),S=N.Pop,A=a[w];function R(){H(g)}d(S,A,R)&&(c=w,k(S,A))}var _={get index(){return c},get action(){return s},get location(){return u},createHref:l,push:x,replace:$,go:H,back:function(){H(-1)},forward:function(){H(1)},listen:function(w){return h.push(w)},block:function(w){return m.push(w)}};return _}function ce(t,e,n){return Math.min(Math.max(t,e),n)}function dt(t){t.preventDefault(),t.returnValue=""}function nt(){var t=[];return{get length(){return t.length},push:function(n){return t.push(n),function(){t=t.filter(function(r){return r!==n})}},call:function(n){t.forEach(function(r){return r&&r(n)})}}}function Rt(){return Math.random().toString(36).substr(2,8)}function z(t){var e=t.pathname,n=e===void 0?"/":e,r=t.search,o=r===void 0?"":r,a=t.hash,c=a===void 0?"":a;return o&&o!=="?"&&(n+=o.charAt(0)==="?"?o:"?"+o),c&&c!=="#"&&(n+=c.charAt(0)==="#"?c:"#"+c),n}function ct(t){var e={};if(t){var n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));var r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}const At=Symbol();function se(){const t=i.inject(At);if(!t)throw new it;return t}const ue=Symbol("isRouterRouteSymbol");function an(t){return typeof t=="object"&&t!==null&&ue in t}function cn(t,e){function n(m,l,P){if(typeof m=="object"){const k={...t.params,...m};return e(t.name,k,l)}const d={...t.params,[m]:l};return e(t.name,d,P)}const{matched:r,matches:o,name:a,query:c,params:s,state:u}=i.toRefs(t),h=i.reactive({matched:r,matches:o,state:u,query:c,params:s,name:a,update:n,[ue]:!0});return new Proxy(h,{get:(m,l,P)=>l==="params"?new Proxy(t.params,{set(d,k,x){return n(k,x),!0}}):l==="state"?new Proxy(t.state,{set(d,k,x){return n({},{state:{...t.state,[k]:x}}),!0}}):Reflect.get(m,l,P)})}const ie=Symbol();function sn(t,e){const n=i.reactive({...t}),r=c=>{Object.assign(n,{[ie]:!1,...c})},o=n,a=cn(o,e);return{currentRoute:o,routerRoute:a,updateRoute:r}}function Y(t){return!t.startsWith("http")?fn(t):un(t)}function un(t){const{protocol:e,host:n,pathname:r,search:o,searchParams:a,hash:c}=new URL(t,t);return{protocol:e,host:n,pathname:r,search:o,searchParams:a,hash:c}}function fn(t){const{pathname:e,search:n,searchParams:r,hash:o}=new URL(t,"https://localhost");return{pathname:e,search:n,searchParams:r,hash:o}}function ln(t){return e=>{const{host:n}=Y(e);return!(n===void 0||n===t)}}function hn({mode:t,listener:e}){const n=pn(t),r=(u,h)=>{if(h!=null&&h.replace)return n.replace(u,h.state);n.push(u,h==null?void 0:h.state)},o=()=>{const u=z(n.location);return n.replace(u)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(e)},stopListening:()=>{a==null||a()}}}function pn(t="auto"){switch(t){case"auto":return Kt()?oe():ae();case"browser":return oe();case"memory":return ae();case"hash":return on();default:const e=t;throw new Error(`Switch is not exhaustive for mode: ${e}`)}}class gt{constructor(){O(this,"onBeforeRouteEnter",new Set);O(this,"onBeforeRouteUpdate",new Set);O(this,"onBeforeRouteLeave",new Set);O(this,"onAfterRouteEnter",new Set);O(this,"onAfterRouteUpdate",new Set);O(this,"onAfterRouteLeave",new Set)}}class fe extends Error{}class st extends Error{constructor(n){super("Error occurred during a router push operation.");O(this,"to");this.to=n}}class kt extends Error{constructor(n){super(`Routing action rejected: ${n}`);O(this,"type");this.type=n}}function mn(t,e){const n=new gt;return t.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&xt(t,e,o)&&Z(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&Lt(t,e,o)&&Z(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&Bt(t,e,o)&&Z(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function dn(t,e){const n=new gt;return t.matches.forEach((r,o)=>{r.onAfterRouteEnter&&xt(t,e,o)&&Z(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&Lt(t,e,o)&&Z(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onAfterRouteLeave&&Bt(t,e,o)&&Z(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function T(t){return typeof t!="string"?!1:/^(https?:\/\/|\/).*/g.test(t)}function Rn(){const t=c=>{throw new kt(c)},e=(...c)=>{throw new st(c)},n=(c,s,u)=>{if(T(c)){const l=s??{};throw new st([c,{...l,replace:!0}])}const h=s,m=u??{};throw new st([c,h,{...m,replace:!0}])},r=()=>{throw new fe};async function o({to:c,from:s,hooks:u}){const{global:h,component:m}=u,l=mn(c,s),P=[...h.onBeforeRouteEnter,...l.onBeforeRouteEnter,...h.onBeforeRouteUpdate,...l.onBeforeRouteUpdate,...m.onBeforeRouteUpdate,...h.onBeforeRouteLeave,...l.onBeforeRouteLeave,...m.onBeforeRouteLeave];try{const d=P.map(k=>k(c,{from:s,reject:t,push:e,replace:n,abort:r}));await Promise.all(d)}catch(d){if(d instanceof st)return{status:"PUSH",to:d.to};if(d instanceof kt)return{status:"REJECT",type:d.type};if(d instanceof fe)return{status:"ABORT"};throw d}return{status:"SUCCESS"}}async function a({to:c,from:s,hooks:u}){const{global:h,component:m}=u,l=dn(c,s),P=[...m.onAfterRouteLeave,...l.onAfterRouteLeave,...h.onAfterRouteLeave,...m.onAfterRouteUpdate,...l.onAfterRouteUpdate,...h.onAfterRouteUpdate,...m.onAfterRouteEnter,...l.onAfterRouteEnter,...h.onAfterRouteEnter];try{const d=P.map(k=>k(c,{from:s,reject:t,push:e,replace:n}));await Promise.all(d)}catch(d){if(d instanceof st)return{status:"PUSH",to:d.to};if(d instanceof kt)return{status:"REJECT",type:d.type};throw d}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const xt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},Bt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},Lt=(t,e,n)=>t.matches[n]===(e==null?void 0:e.matches[n]);function le(t){switch(t){case"onBeforeRouteEnter":case"onAfterRouteEnter":return xt;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Lt;case"onBeforeRouteLeave":case"onAfterRouteLeave":return Bt;default:throw new Error(`Switch is not exhaustive for lifecycle: ${t}`)}}class gn{constructor(){O(this,"global",new gt);O(this,"component",new gt)}addBeforeRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=le(e),c=this[n][e],s=(u,h)=>{if(a(u,h.from,r))return o(u,h)};return c.add(s),()=>c.delete(s)}addAfterRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=le(e),c=this[n][e],s=(u,h)=>{if(a(u,h.from,r))return o(u,h)};return c.add(s),()=>c.delete(s)}}const he=Symbol();function yn(){const t=new gn;return{onBeforeRouteEnter:s=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:s,timing:"global",depth:0}),onBeforeRouteUpdate:s=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:s,timing:"global",depth:0}),onBeforeRouteLeave:s=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:s,timing:"global",depth:0}),onAfterRouteEnter:s=>t.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:s,timing:"global",depth:0}),onAfterRouteUpdate:s=>t.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:s,timing:"global",depth:0}),onAfterRouteLeave:s=>t.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:s,timing:"global",depth:0}),hooks:t}}function wn(t){return i.defineComponent(()=>()=>i.h("h1",t),{name:t,props:[]})}function pe(t){const e=new URLSearchParams(t);return{get:n=>e.get(n),getAll:n=>e.getAll(n)}}function vn({rejections:t}){const e=a=>{const c={...t};return i.markRaw(c[a]??wn(a))},n=a=>{const c=i.markRaw(e(a)),s={name:a,component:c,meta:{},state:{}};return{matched:s,matches:[s],name:a,query:pe(""),params:{},state:{},[ie]:!0}},r=a=>{if(!a){o.value=null;return}const c=e(a);o.value={type:a,component:c}},o=i.ref(null);return{setRejection:r,rejection:o,getRejectionRoute:n}}class En extends Error{constructor(e){super(`Route not found: "${e}"`)}}function Ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pn(t,e){const n=Array.from(t.matchAll(e));if(n.length===0)return[t];let r=0;const o=n.reduce((c,s)=>{const u=Ut(t.slice(r,s.index));u.length&&c.push(u);const[h]=s;return c.push(h),r=s.index+h.length,c},[]),a=t.slice(r);return a&&o.push(a),o}function bn(t){const e=me(t.path.toString());return new RegExp(`^${e}$`,"i")}function Sn(t){const e=new URLSearchParams(t.query.toString());return Array.from(e.entries()).filter(([,n])=>!Ct(n)).map(([n,r])=>{const o=me(r);return new RegExp(`${Ut(n)}=${o}(&|$)`,"i")})}function me(t){return Pn(t,new RegExp(An,"g")).map(e=>e.startsWith(W)?de(e):Ut(e)).join("")}function de(t){return[kn,xn].reduce((e,n)=>n(e),t)}const An=`\\${W}\\??([\\w-_]+)\\${J}`,Nt=`\\${W}\\?([\\w-_]+)\\${J}`,Re=`\\${W}([\\w-_]+)\\${J}`;function kn(t){return t.replace(new RegExp(Nt,"g"),".*")}function Ct(t){return new RegExp(Nt,"g").test(t)}function xn(t){return t.replace(new RegExp(Re,"g"),".+")}function yt(t){const[e]=wt(t,new RegExp(Nt,"g")),[n]=wt(t,new RegExp(Re,"g"));return e??n}function wt(t,e){return Array.from(t.matchAll(e)).flatMap(([,...r])=>r.map(o=>ht(o)?o:""))}function ge(t,e,n){const r=we(e,n),[o]=wt(t,r);return o}function ye(t,e){if(!e)return t;const{name:n,param:r,value:o}=e,a=we(t,n);return wt(t,a).reduce((s,u)=>u===void 0?s:s.replace(u,()=>at(o,r,n.startsWith("?"))),t)}function we(t,e){const n=[Bn,Ln,de].reduce((r,o)=>o(r,e),t);return new RegExp(n,"g")}function Bn(t,e){if(!e.startsWith("?"))return t;const n=new RegExp(`\\${W}\\${e}\\${J}`,"g");return t.replace(n,"(.*)")}function Ln(t,e){if(e.startsWith("?"))return t;const n=new RegExp(`\\${W}${e}\\${J}`,"g");return t.replace(n,"(.+)")}function ve(t,...e){return e.reduce((n,r)=>{if(!r)return n;const o=new URLSearchParams(r).toString();return Object.keys(o).length===0?n:n.includes("?")?`${n}&${o}`:`${n}?${o}`},t)}function Un(t,e={}){const{params:n={},query:r}=e,o=Nn(t.host,n),a=Cn(t.path,n),c=$n(t.query,n);return ve(`${o}${a}`,c,r)}function Nn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,a])=>{const c=yt(`${W}${o}${J}`);return c?ye(r,{name:o,param:a,value:e[c]}):r},n)}function Cn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,a])=>{const c=yt(`${W}${o}${J}`);return c?ye(r,{name:o,param:a,value:e[c]}):r},n)}function $n(t,e){const n=t.toString();if(!n)return{};const r=new URLSearchParams(n);return Array.from(r.entries()).reduce((o,[a,c])=>{const s=yt(c);if(!s)return{...o,[a]:c};const h=at(e[s],t.params[s],Ct(c)),m=e[s]===void 0&&h==="";return Ct(c)&&m?o:{...o,[a]:h}},{})}function jn(t){return(e,n,r)=>{if(T(e))return ve(e,(n??{}).query);const o=n??{},a=r??{},c=t.find(u=>u.name===e);if(!c)throw new En(String(e));return Un(c,{params:o,query:a.query})}}class Hn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function Vn(t){if(t)return t;if(Kt())return window.location.toString();throw new Hn}const On=(t,e)=>{try{Ee(t,e)}catch{return!1}return!0},Ee=(t,e)=>{const{pathname:n,search:r}=Y(e);return{..._n(t.path,n),...qn(t.query,r)}};function _n(t,e){const n={},r=decodeURIComponent(e);for(const[o,a]of Object.entries(t.params)){const c=o.startsWith("?"),s=c?o.slice(1):o,u=ge(r,t.toString(),o),h=ot(u,a,c);n[s]=h}return n}function qn(t,e){const n={},r=new URLSearchParams(e);for(const[o,a]of Object.entries(t.params)){const c=o.startsWith("?"),s=c?o.slice(1):o,u=r.get(s)??void 0,h=ot(u,a,c);n[s]=h}return n}const Dn=t=>"name"in t.matched&&!!t.matched.name,Wn=(t,e)=>{const{pathname:n}=Y(e);return bn(t).test(n)},Tn=(t,e)=>{const{search:n}=Y(e);return Sn(t).every(o=>o.test(n))};function Mn(t){const{searchParams:e,pathname:n}=Y(t),r=-1,o=1;return(a,c)=>{const s=be(a,e),u=Pe(a,n),h=be(c,e),m=Pe(c,n);return a.depth>c.depth?r:a.depth<c.depth?o:s+u>h+m?r:s+u<h+m?o:0}}function Pe(t,e){const n=Object.keys(t.path.params).filter(o=>o.startsWith("?")).map(o=>o),r=n.filter(o=>ge(e,t.path.toString(),o)===void 0);return n.length-r.length}function be(t,e){const n=new URLSearchParams(t.query.toString()),r=Array.from(n.keys()),o=r.filter(a=>!e.has(a));return r.length-o.length}function Se(t){return!!t&&typeof t=="object"}const vt=!0;function In(t,e,n){if(Se(t)&&e in t){const r=t[e];if(typeof r=="string")return ot(r,n,vt)}return ot(void 0,n,vt)}function Fn(t,e){const n={};for(const[r,o]of Object.entries(t)){const a=In(e,r,o);n[r]=a}return n}function Jn(t,e,n){if(Se(t)&&e in t){const r=t[e];return at(r,n,vt)}return at(void 0,n,vt)}const Ae=(t,e)=>{const n={};for(const[r,o]of Object.entries(t)){const a=Jn(e,r,o);n[r]=a}return n},Qn=[Dn,Wn,Tn,On];function $t(t,e,n){const r=Mn(e),o=t.filter(s=>Qn.every(u=>u(s,e))).sort(r);if(o.length===0)return;const[a]=o,{search:c}=Y(e);return{matched:a.matched,matches:a.matches,name:a.name,query:pe(c),params:Ee(a,e),state:Fn(a.state,n)}}function jt(t,e){const n=new RegExp(`\\${W}(\\??[\\w-_]+)\\${J}`,"g");return Array.from(t.matchAll(n)).reduce((o,[a,c])=>{const s=yt(a);if(!s)return o;const u=en(e,s);return tt([s],o),o[c]=u,o},{})}function ke(t,e){return{host:t,params:jt(t,e),toString:()=>t}}function Ht(t){return t===void 0?"":t}function Vt(t,e){return{path:t,params:jt(t,e),toString:()=>t}}function Gn(t){return lt(t)&&typeof t.path=="string"}function xe(t){return t===void 0?Vt("",{}):Gn(t)?t:Vt(t,{})}function Ot(t,e){return{query:t,params:jt(t,e),toString:()=>t}}function Kn(t){return lt(t)&&typeof t.query=="string"}function Be(t){return t===void 0?Ot("",{}):Kn(t)?t:Ot(t,{})}function M(t){const e=Ht(t.name),n=xe(t.path),r=Be(t.query),o=t.meta??{},a=ze(t)?t.state:{},c=i.markRaw({meta:{},state:{},...t}),s={matched:c,matches:[c],name:e,path:n,query:r,meta:o,state:a,depth:1,host:ke("",{}),prefetch:t.prefetch},u=Qt(t)?Gt(t.parent,s):s;return tt(u.path.params,u.query.params),u}function zn(t,e){if(!ht(e))return t;const n=M({path:e});return t.map(r=>M({parent:n,...r}))}class Yn extends Error{constructor(e){super(`Invalid Name "${e}": Router does not support multiple routes with the same name. All name names must be unique.`)}}function Xn(t){const e=t.map(({name:n})=>n);for(const n of e)if(Jt(e,n)>1)throw new Yn(n)}function Zn(t,e){const n=Je(t)?t.flat():t,r=zn(n,e==null?void 0:e.base);Xn(r);const o=jn(r),a=hn({mode:e==null?void 0:e.historyMode,listener:({location:v})=>{const L=z(v);x(L,{state:v.state})}}),{runBeforeRouteHooks:c,runAfterRouteHooks:s}=Rn(),{hooks:u,onBeforeRouteEnter:h,onAfterRouteUpdate:m,onBeforeRouteLeave:l,onAfterRouteEnter:P,onBeforeRouteUpdate:d,onAfterRouteLeave:k}=yn();async function x(v,L={}){if(a.stopListening(),C(v))return a.update(v,L);const q=$t(r,v,L.state)??A("NotFound"),D={...f},rt=await c({to:q,from:D,hooks:u});switch(rt.status){case"ABORT":return;case"PUSH":a.update(v,L),await $(...rt.to);return;case"REJECT":a.update(v,L),w(rt.type),E(q);break;case"SUCCESS":a.update(v,L),w(null),E(q);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(rt)}`)}const G=await s({to:q,from:D,hooks:u});switch(G.status){case"PUSH":await $(...G.to);break;case"REJECT":w(G.type);break;case"SUCCESS":break;default:const I=G;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(I)}`)}a.startListening()}const $=(v,L,q)=>{if(T(v)){const ut={...L},It=o(v,ut);return x(It,ut)}const D={...q},G=o(v,L??{},D),I=Tt(v),Mt=Ae((I==null?void 0:I.state)??{},D.state);return x(G,{...D,state:Mt})},H=(v,L,q)=>{if(T(v)){const ut={...L,replace:!0},It=o(v,ut);return x(It,ut)}const D={...q,replace:!0},G=o(v,L??{},D),I=Tt(v),Mt=Ae((I==null?void 0:I.state)??{},D.state);return x(G,{...D,state:Mt})},_=v=>w(v),g=(v,L={})=>{if(!T(v)){const q=o(v,L);return $t(r,q)}if(!C(v))return $t(r,v)},{setRejection:w,rejection:S,getRejectionRoute:A}=vn(e??{}),R=A("NotFound"),{currentRoute:f,routerRoute:p,updateRoute:E}=sn(R,$);a.startListening();const b=Vn(e==null?void 0:e.initialUrl),B=a.location.state,{host:U}=Y(b),C=ln(U),V=x(b,{replace:!0,state:B});function Tt(v){return r.find(L=>L.name===v)}function mr(v){v.component("RouterView",_e),v.component("RouterLink",Oe),v.provide(At,S),v.provide(he,u),v.provide(Pt,De)}const De={route:p,resolve:o,push:$,replace:H,reject:_,find:g,refresh:a.refresh,forward:a.forward,back:a.back,go:a.go,install:mr,initialized:V,isExternal:C,onBeforeRouteEnter:h,onAfterRouteUpdate:m,onBeforeRouteLeave:l,onAfterRouteEnter:P,onBeforeRouteUpdate:d,onAfterRouteLeave:k,prefetch:e==null?void 0:e.prefetch};return De}const Et={template:"<div>This is component</div>"},_t=M({name:"parentA",path:"/parentA/[paramA]"}),Le=M({parent:_t,name:"parentA.childA",path:"/[?paramB]"}),tr=M({parent:_t,name:"parentA.childB",path:"/[paramD]",component:Et}),er=M({parent:Le,name:"parentA.childA.grandChildA",path:"/[paramC]",component:Et});M({name:"parentB",path:"/parentB",component:Et}),M({name:"parentC",path:"/",component:Et});const nr={components:!0};function rr({routerPrefetch:t,routePrefetch:e,linkPrefetch:n},r){return qt(n,r)??qt(e,r)??qt(t,r)??nr[r]}function qt(t,e){return lt(t)?t[e]:t}const or=i.defineAsyncComponent(()=>new Promise(t=>{t({default:{template:""}})}));function Ue(t){return t.name===or.name&&"setup"in t}function Ne(t,e={},n={}){const r=ft(),o=i.toRef(t),a=i.computed(()=>T(o.value)?{}:i.toValue(e)),c=i.computed(()=>T(o.value)?i.toValue(e):i.toValue(n)),s=i.computed(()=>{if(T(o.value))return o.value;try{return r.resolve(o.value,a.value,c.value)}catch(l){throw l instanceof X&&console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`,l),l}}),u=i.computed(()=>r.find(s.value,c.value)),h=i.computed(()=>!!u.value&&r.route.matches.includes(u.value.matched)),m=i.computed(()=>!!u.value&&r.route.matched===u.value.matched);return i.watch(u,l=>{if(!l)return;const{prefetch:P}=r,{prefetch:d}=c.value;ar(l,{routerPrefetch:P,linkPrefetch:d})},{immediate:!0}),{route:u,href:s,isMatch:h,isExactMatch:m,push:l=>r.push(s.value,{},{...c.value,...l}),replace:l=>r.replace(s.value,{},{...c.value,...l})}}function ar(t,{routerPrefetch:e,linkPrefetch:n}){t.matches.forEach(r=>{rr({routePrefetch:r.prefetch,routerPrefetch:e,linkPrefetch:n},"components")&&(bt(r)&&Ue(r.component)&&r.component.setup(),St(r)&&Object.values(r.components).forEach(a=>{Ue(a)&&a.setup()}))})}function Ce(t,e,{exact:n}={}){if(!an(t))return!1;if(e===void 0)return!0;const r=t.matches.map(o=>Ht(o.name));if(n){const o=r.at(-1);return e===o}return r.includes(e)}function $e(t,e){const n=ft();function r(){if(!t)return;if(!Ce(n.route,t,e))throw new Ft(t,n.route.name)}return i.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const je=Symbol();function Dt(){return i.inject(je,0)}function He(){const t=i.inject(he);if(!t)throw new it;return t}function Ve(t){return e=>{const n=Dt(),o=He().addBeforeRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}function Wt(t){return e=>{const n=Dt(),o=He().addAfterRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}const cr=Ve("onBeforeRouteUpdate"),sr=Ve("onBeforeRouteLeave"),ur=Wt("onAfterRouteEnter"),ir=Wt("onAfterRouteUpdate"),fr=Wt("onAfterRouteLeave"),lr=["href"],Oe=i.defineComponent({__name:"routerLink",props:{to:{},prefetch:{type:[Boolean,Object],default:void 0},query:{},replace:{type:Boolean},state:{}},setup(t){const e=t,n=ft(),r=i.computed(()=>T(e.to)?e.to:e.to(n.resolve)),o=i.computed(()=>{const{to:l,...P}=e;return P}),{href:a,isMatch:c,isExactMatch:s}=Ne(r,o),u=i.computed(()=>({"router-link--match":c.value,"router-link--exact-match":s.value})),h=i.computed(()=>n.isExternal(r.value));function m(l){l.preventDefault(),n.push(a.value,o.value)}return(l,P)=>(i.openBlock(),i.createElementBlock("a",{href:r.value,class:i.normalizeClass(["router-link",u.value]),onClick:m},[i.renderSlot(l.$slots,"default",i.normalizeProps(i.guardReactiveProps({resolved:r.value,isMatch:i.unref(c),isExactMatch:i.unref(s),isExternal:h.value})))],10,lr))}}),_e=i.defineComponent({__name:"routerView",props:{name:{}},setup(t){const{name:e="default"}=t,n=$e(),r=se(),o=Dt(),a=i.resolveComponent("RouterView",!0);i.provide(je,o+1);const c=i.computed(()=>{if(r.value)return r.value.component;const l=n.matches.at(o);if(!l)return null;const P=s(l),d=h(l);return P?d?(n.params,zt(P,()=>d(n.params))):P:null});function s(l){return u(l)[e]}function u(l){return St(l)?l.components:bt(l)?{default:l.component}:typeof a=="string"?{}:{default:a}}function h(l){return m(l)[e]}function m(l){return St(l)?l.props??{}:bt(l)?{default:l.props}:{}}return(l,P)=>c.value?i.renderSlot(l.$slots,"default",i.normalizeProps(i.mergeProps({key:0},{route:i.unref(n),component:c.value,rejection:i.unref(r)})),()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(c.value)))]):i.createCommentVNode("",!0)}});function hr(t){return lt(t)&&typeof t.host=="string"}function qe(t){return hr(t)?t:ke(t,{})}function pr(t){const e=Ht(t.name),n=xe(t.path),r=Be(t.query),o=t.meta??{},a=Ke(t)?qe(t.host):qe(""),c=i.markRaw({meta:{},state:{},...t}),s={matched:c,matches:[c],name:e,host:a,path:n,query:r,meta:o,depth:1,state:{}},u=Qt(t)?Gt(t.parent,s):s;return tt(u.path.params,u.query.params,u.host.params),u}y.DuplicateParamsError=F,y.RouterLink=Oe,y.RouterNotInstalledError=it,y.RouterView=_e,y.UseRouteInvalidError=Ft,y.component=zt,y.createExternalRoute=pr,y.createParam=ne,y.createRoute=M,y.createRouter=Zn,y.isParamWithDefault=Yt,y.isRoute=Ce,y.onAfterRouteEnter=ur,y.onAfterRouteLeave=ir,y.onAfterRouteUpdate=fr,y.onBeforeRouteLeave=cr,y.onBeforeRouteUpdate=sr,y.path=Vt,y.query=Ot,y.routerInjectionKey=Pt,y.routerRejectionKey=At,y.useLink=Ne,y.useRejection=se,y.useRoute=$e,y.useRouter=ft,y.withDefault=tn,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|