@kitbag/router 0.4.1 → 0.4.2

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.
@@ -36,12 +36,12 @@ function Rt() {
36
36
  }
37
37
  class I extends Error {
38
38
  }
39
- function T(t) {
39
+ function W(t) {
40
40
  return typeof t != "string" ? !1 : /^(https?:\/\/|\/).*/g.test(t);
41
41
  }
42
42
  function He(t, e = {}, n = {}) {
43
43
  const r = Rt(), o = H(() => ft(t)), a = H(() => ft(e)), s = H(() => ft(n)), c = H(() => {
44
- if (T(o.value))
44
+ if (W(o.value))
45
45
  return o.value;
46
46
  try {
47
47
  return r.resolve(o.value, a.value, s.value);
@@ -191,7 +191,7 @@ function De() {
191
191
  }, e = (...s) => {
192
192
  throw new G(s);
193
193
  }, n = (s, c, u) => {
194
- if (T(s)) {
194
+ if (W(s)) {
195
195
  const d = c ?? {};
196
196
  throw new G([s, { ...d, replace: !0 }]);
197
197
  }
@@ -364,7 +364,7 @@ const Jn = zt("onBeforeRouteUpdate"), Kn = zt("onBeforeRouteLeave"), Qn = Et("on
364
364
  replace: { type: Boolean }
365
365
  },
366
366
  setup(t) {
367
- const e = t, n = Rt(), r = H(() => T(e.to) ? e.to : e.to(n.resolve)), o = H(() => {
367
+ const e = t, n = Rt(), r = H(() => W(e.to) ? e.to : e.to(n.resolve)), o = H(() => {
368
368
  const { to: d, ...b } = e;
369
369
  return b;
370
370
  }), { href: a, isMatch: s, isExactMatch: c } = He(r), u = H(() => ({
@@ -616,7 +616,7 @@ var K = process.env.NODE_ENV !== "production" ? function(t) {
616
616
  } : function(t) {
617
617
  return t;
618
618
  };
619
- function D(t, e) {
619
+ function M(t, e) {
620
620
  if (!t) {
621
621
  typeof console < "u" && console.warn(e);
622
622
  try {
@@ -656,7 +656,7 @@ function Ht(t) {
656
656
  }
657
657
  }, P(w));
658
658
  } else
659
- process.env.NODE_ENV !== "production" && D(
659
+ process.env.NODE_ENV !== "production" && M(
660
660
  !1,
661
661
  // TODO: Write up a doc that explains our blocking strategy in
662
662
  // detail and link to it here so people can understand better what
@@ -673,7 +673,7 @@ function Ht(t) {
673
673
  idx: h
674
674
  }), ""));
675
675
  function E(m) {
676
- return typeof m == "string" ? m : M(m);
676
+ return typeof m == "string" ? m : T(m);
677
677
  }
678
678
  function j(m, i) {
679
679
  return i === void 0 && (i = null), K(_({
@@ -794,7 +794,7 @@ function nn(t) {
794
794
  }
795
795
  }, S(x));
796
796
  } else
797
- process.env.NODE_ENV !== "production" && D(
797
+ process.env.NODE_ENV !== "production" && M(
798
798
  !1,
799
799
  // TODO: Write up a doc that explains our blocking strategy in
800
800
  // detail and link to it here so people can understand better
@@ -807,7 +807,7 @@ function nn(t) {
807
807
  }
808
808
  r.addEventListener(ae, c), r.addEventListener(en, function() {
809
809
  var i = a(), l = i[1];
810
- M(l) !== M(d) && c();
810
+ T(l) !== T(d) && c();
811
811
  });
812
812
  var u = L.Pop, f = a(), h = f[0], d = f[1], b = Q(), p = Q();
813
813
  h == null && (h = 0, o.replaceState(_({}, o.state, {
@@ -822,7 +822,7 @@ function nn(t) {
822
822
  return l;
823
823
  }
824
824
  function j(i) {
825
- return E() + "#" + (typeof i == "string" ? i : M(i));
825
+ return E() + "#" + (typeof i == "string" ? i : T(i));
826
826
  }
827
827
  function V(i, l) {
828
828
  return l === void 0 && (l = null), K(_({
@@ -861,7 +861,7 @@ function nn(t) {
861
861
  function x() {
862
862
  g(i, l);
863
863
  }
864
- if (process.env.NODE_ENV !== "production" && D(w.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(i) + ")"), U(v, w, x)) {
864
+ if (process.env.NODE_ENV !== "production" && M(w.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(i) + ")"), U(v, w, x)) {
865
865
  var y = B(w, h + 1), k = y[0], A = y[1];
866
866
  try {
867
867
  o.pushState(k, "", A);
@@ -876,7 +876,7 @@ function nn(t) {
876
876
  function x() {
877
877
  P(i, l);
878
878
  }
879
- if (process.env.NODE_ENV !== "production" && D(w.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(i) + ")"), U(v, w, x)) {
879
+ if (process.env.NODE_ENV !== "production" && M(w.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(i) + ")"), U(v, w, x)) {
880
880
  var y = B(w, h), k = y[0], A = y[1];
881
881
  o.replaceState(k, "", A), R(v);
882
882
  }
@@ -923,10 +923,10 @@ function Nt(t) {
923
923
  state: null,
924
924
  key: at()
925
925
  }, typeof R == "string" ? z(R) : R));
926
- return process.env.NODE_ENV !== "production" && D(g.pathname.charAt(0) === "/", "Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: " + JSON.stringify(R) + ")"), g;
926
+ return process.env.NODE_ENV !== "production" && M(g.pathname.charAt(0) === "/", "Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: " + JSON.stringify(R) + ")"), g;
927
927
  }), s = $t(o ?? a.length - 1, 0, a.length - 1), c = L.Pop, u = a[s], f = Q(), h = Q();
928
928
  function d(R) {
929
- return typeof R == "string" ? R : M(R);
929
+ return typeof R == "string" ? R : T(R);
930
930
  }
931
931
  function b(R, g) {
932
932
  return g === void 0 && (g = null), K(_({
@@ -956,14 +956,14 @@ function Nt(t) {
956
956
  function m() {
957
957
  j(R, g);
958
958
  }
959
- process.env.NODE_ENV !== "production" && D(u.pathname.charAt(0) === "/", "Relative pathnames are not supported in memory history.push(" + JSON.stringify(R) + ")"), p(P, S, m) && (s += 1, a.splice(s, a.length, S), E(P, S));
959
+ process.env.NODE_ENV !== "production" && M(u.pathname.charAt(0) === "/", "Relative pathnames are not supported in memory history.push(" + JSON.stringify(R) + ")"), p(P, S, m) && (s += 1, a.splice(s, a.length, S), E(P, S));
960
960
  }
961
961
  function V(R, g) {
962
962
  var P = L.Replace, S = b(R, g);
963
963
  function m() {
964
964
  V(R, g);
965
965
  }
966
- process.env.NODE_ENV !== "production" && D(u.pathname.charAt(0) === "/", "Relative pathnames are not supported in memory history.replace(" + JSON.stringify(R) + ")"), p(P, S, m) && (a[s] = S, E(P, S));
966
+ process.env.NODE_ENV !== "production" && M(u.pathname.charAt(0) === "/", "Relative pathnames are not supported in memory history.replace(" + JSON.stringify(R) + ")"), p(P, S, m) && (a[s] = S, E(P, S));
967
967
  }
968
968
  function B(R) {
969
969
  var g = $t(s + R, 0, a.length - 1), P = L.Pop, S = a[g];
@@ -1030,7 +1030,7 @@ function Q() {
1030
1030
  function at() {
1031
1031
  return Math.random().toString(36).substr(2, 8);
1032
1032
  }
1033
- function M(t) {
1033
+ function T(t) {
1034
1034
  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;
1035
1035
  return o && o !== "?" && (n += o.charAt(0) === "?" ? o : "?" + o), s && s !== "#" && (n += s.charAt(0) === "#" ? s : "#" + s), n;
1036
1036
  }
@@ -1150,7 +1150,7 @@ function yn(t, e, n) {
1150
1150
  }
1151
1151
  function le(t) {
1152
1152
  return (e, n, r) => {
1153
- if (T(e))
1153
+ if (W(e))
1154
1154
  return fe(e, (n ?? {}).query);
1155
1155
  const o = n ?? {}, a = r ?? {}, s = t.find((u) => u.key === e);
1156
1156
  if (!s)
@@ -1163,7 +1163,7 @@ function le(t) {
1163
1163
  });
1164
1164
  };
1165
1165
  }
1166
- function W(t) {
1166
+ function q(t) {
1167
1167
  return !t.startsWith("http") ? vn(t) : gn(t);
1168
1168
  }
1169
1169
  function gn(t) {
@@ -1201,7 +1201,7 @@ const wn = (t, e) => {
1201
1201
  }
1202
1202
  return !0;
1203
1203
  }, pe = (t, e) => {
1204
- const { pathname: n, search: r } = W(e);
1204
+ const { pathname: n, search: r } = q(e);
1205
1205
  return {
1206
1206
  ...En(t.path, n),
1207
1207
  ...Pn(t.query, r)
@@ -1224,17 +1224,17 @@ function Pn(t, e) {
1224
1224
  return n;
1225
1225
  }
1226
1226
  const bn = (t) => "name" in t.matched && !!t.matched.name, Sn = (t, e) => {
1227
- const { host: n } = W(e), { host: r } = W(t.path.toString());
1227
+ const { host: n } = q(e), { host: r } = q(t.path.toString());
1228
1228
  return n === r;
1229
1229
  }, kn = (t, e) => {
1230
- const { pathname: n } = W(e);
1230
+ const { pathname: n } = q(e);
1231
1231
  return sn(t).test(n);
1232
1232
  }, xn = (t, e) => {
1233
- const { search: n } = W(e);
1233
+ const { search: n } = q(e);
1234
1234
  return cn(t).every((o) => o.test(n));
1235
1235
  };
1236
1236
  function An(t) {
1237
- const { searchParams: e, pathname: n } = W(t), r = -1, o = 1;
1237
+ const { searchParams: e, pathname: n } = q(t), r = -1, o = 1;
1238
1238
  return (a, s) => {
1239
1239
  const c = Vt(a, e), u = jt(a, n), f = Vt(s, e), h = jt(s, n);
1240
1240
  return c + u > f + h ? r : c + u < f + h ? o : a.depth > s.depth ? r : a.depth < s.depth ? o : 0;
@@ -1259,7 +1259,7 @@ function pt(t, e) {
1259
1259
  const n = An(e), r = t.filter((u) => Ln.every((f) => f(u, e))).sort(n);
1260
1260
  if (r.length === 0)
1261
1261
  return;
1262
- const [o] = r, { search: a } = W(e), s = he(a), c = pe(o, e);
1262
+ const [o] = r, { search: a } = q(e), s = he(a), c = pe(o, e);
1263
1263
  return {
1264
1264
  matched: o.matched,
1265
1265
  matches: o.matches,
@@ -1271,7 +1271,7 @@ function pt(t, e) {
1271
1271
  function Un(t) {
1272
1272
  return (e, n = {}) => {
1273
1273
  const r = le(t);
1274
- if (T(e)) {
1274
+ if (W(e)) {
1275
1275
  const a = r(e);
1276
1276
  return pt(t, a);
1277
1277
  }
@@ -1288,7 +1288,7 @@ function Bn({ mode: t, listener: e }) {
1288
1288
  return n.replace(u);
1289
1289
  n.push(u);
1290
1290
  }, o = () => {
1291
- const u = M(n.location);
1291
+ const u = T(n.location);
1292
1292
  return n.replace(u);
1293
1293
  };
1294
1294
  let a;
@@ -1372,15 +1372,17 @@ class jn extends Error {
1372
1372
  function Vn(t) {
1373
1373
  if (t)
1374
1374
  return t;
1375
- if (de())
1376
- return window.location.toString();
1375
+ if (de()) {
1376
+ const { pathname: e, search: n, hash: r } = q(window.location.toString());
1377
+ return [e, n, r].join("");
1378
+ }
1377
1379
  throw new jn();
1378
1380
  }
1379
1381
  function Zn(t, e = {}) {
1380
1382
  const n = le(t), r = Bn({
1381
1383
  mode: e.historyMode,
1382
1384
  listener: () => {
1383
- const y = M(location);
1385
+ const y = T(location);
1384
1386
  p(y);
1385
1387
  }
1386
1388
  }), { runBeforeRouteHooks: o, runAfterRouteHooks: a } = De(), {
@@ -1394,21 +1396,21 @@ function Zn(t, e = {}) {
1394
1396
  } = Te();
1395
1397
  async function p(y, { replace: k } = {}) {
1396
1398
  r.stopListening();
1397
- const A = pt(t, y) ?? g("NotFound"), C = { ...S }, q = await o({ to: A, from: C, hooks: s });
1398
- switch (q.status) {
1399
+ const A = pt(t, y) ?? g("NotFound"), C = { ...S }, D = await o({ to: A, from: C, hooks: s });
1400
+ switch (D.status) {
1399
1401
  case "ABORT":
1400
1402
  return;
1401
1403
  case "PUSH":
1402
- r.update(y, { replace: k }), await E(...q.to);
1404
+ r.update(y, { replace: k }), await E(...D.to);
1403
1405
  return;
1404
1406
  case "REJECT":
1405
- r.update(y, { replace: k }), U(q.type), i(A);
1407
+ r.update(y, { replace: k }), U(D.type), i(A);
1406
1408
  break;
1407
1409
  case "SUCCESS":
1408
1410
  r.update(y, { replace: k }), U(null), i(A);
1409
1411
  break;
1410
1412
  default:
1411
- throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(q)}`);
1413
+ throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(D)}`);
1412
1414
  }
1413
1415
  const O = await a({ to: A, from: C, hooks: s });
1414
1416
  switch (O.status) {
@@ -1427,19 +1429,19 @@ function Zn(t, e = {}) {
1427
1429
  r.startListening();
1428
1430
  }
1429
1431
  const E = (y, k, A) => {
1430
- if (T(y)) {
1432
+ if (W(y)) {
1431
1433
  const Z = { ...k }, ge = n(y, Z);
1432
1434
  return p(ge, { replace: Z.replace });
1433
1435
  }
1434
1436
  const C = { ...A }, O = n(y, k ?? {}, C);
1435
1437
  return p(O, { replace: C.replace });
1436
1438
  }, j = (y, k, A) => {
1437
- if (T(y)) {
1439
+ if (W(y)) {
1438
1440
  const O = { ...k, replace: !0 };
1439
1441
  return E(y, O);
1440
1442
  }
1441
- const C = k ?? {}, q = { ...A, replace: !0 };
1442
- return E(y, C, q);
1443
+ const C = k ?? {}, D = { ...A, replace: !0 };
1444
+ return E(y, C, D);
1443
1445
  }, V = (y) => U(y), B = Un(t), { setRejection: U, rejection: R, getRejectionRoute: g } = $n(e), P = g("NotFound"), { currentRoute: S, routerRoute: m, updateRoute: i } = rn(P, E);
1444
1446
  r.startListening();
1445
1447
  const l = Vn(e.initialUrl), v = p(l, { replace: !0 });
@@ -1 +1 @@
1
- (function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p["@kitbag/router"]={},p.Vue))})(this,function(p,u){"use strict";var jn=Object.defineProperty;var Hn=(p,u,$)=>u in p?jn(p,u,{enumerable:!0,configurable:!0,writable:!0,value:$}):p[u]=$;var C=(p,u,$)=>(Hn(p,typeof u!="symbol"?u+"":u,$),$);class $ 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 et extends Error{constructor(){super("Router not installed")}}class Bt extends Error{constructor(e,n){super(`useRoute called with incorrect route. Given ${e}, expected ${n}`)}}const ft=Symbol();function nt(){const t=u.inject(ft);if(!t)throw new et;return t}class K extends Error{}function M(t){return typeof t!="string"?!1:/^(https?:\/\/|\/).*/g.test(t)}function jt(t,e={},n={}){const r=nt(),o=u.computed(()=>u.toValue(t)),a=u.computed(()=>u.toValue(e)),c=u.computed(()=>u.toValue(n)),s=u.computed(()=>{if(M(o.value))return o.value;try{return r.resolve(o.value,a.value,c.value)}catch(R){throw R instanceof K&&console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`,R),R}}),f=u.computed(()=>r.find(s.value,c.value)),l=u.computed(()=>!!f.value&&r.route.matches.includes(f.value.matched)),d=u.computed(()=>!!f.value&&r.route.matched===f.value.matched);return{route:f,href:s,isMatch:l,isExactMatch:d,push:R=>r.push(s.value,{},{...c.value,...R}),replace:R=>r.replace(s.value,{},{...c.value,...R})}}const lt=Symbol();function Ht(){const t=u.inject(lt);if(!t)throw new et;return t}function Nt(t,e){return[t,e].filter(n=>!!n).join(".")}const $t=Symbol("isRouterRouteSymbol");function ge(t){return typeof t=="object"&&t!==null&&$t in t}function we(t,e){function n(l,d,R){if(typeof l=="object"){const m={...t.params,...l};return e(t.key,m,d)}const k={...t.params,[l]:d};return e(t.key,k,R)}const{matched:r,matches:o,key:a,query:c,params:s}=u.toRefs(t),f=u.reactive({matched:r,matches:o,query:c,params:s,key:a,update:n,[$t]:!0});return new Proxy(f,{get:(l,d,R)=>d==="params"?new Proxy(t.params,{set(k,m,b){return n(m,b),!0}}):Reflect.get(l,d,R)})}function Ct(t,e,{exact:n}={}){if(!ge(t))return!1;if(e===void 0)return!0;const r=ve(t);if(n){const o=r.at(-1);return e===o}return r.includes(e)}function ve(t){return t.matches.map(n=>n.name).reduce((n,r)=>{const o=n.pop(),a=r?[Nt(o,r)]:[];return o?[...n,o,...a]:a},[])}function Vt(t,{exact:e}={}){const n=nt();function r(){if(!t)return;if(!Ct(n.route,t,{exact:e}))throw new Bt(t,n.route.key)}return u.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const Ot=Symbol();function ht(){return u.inject(Ot,0)}class rt{constructor(){C(this,"onBeforeRouteEnter",new Set);C(this,"onBeforeRouteUpdate",new Set);C(this,"onBeforeRouteLeave",new Set);C(this,"onAfterRouteEnter",new Set);C(this,"onAfterRouteUpdate",new Set);C(this,"onAfterRouteLeave",new Set)}}class _t extends Error{}class X extends Error{constructor(n){super("Error occurred during a router push operation.");C(this,"to");this.to=n}}class pt extends Error{constructor(n){super(`Routing action rejected: ${n}`);C(this,"type");this.type=n}}function Q(t){return Array.isArray(t)?t:[t]}function Ee(t,e){const n=new rt;return t.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&dt(t,e,o)&&Q(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&Rt(t,e,o)&&Q(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&mt(t,e,o)&&Q(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function Pe(t,e){const n=new rt;return t.matches.forEach((r,o)=>{r.onAfterRouteEnter&&dt(t,e,o)&&Q(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&Rt(t,e,o)&&Q(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onAfterRouteLeave&&mt(t,e,o)&&Q(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function be(){const t=c=>{throw new pt(c)},e=(...c)=>{throw new X(c)},n=(c,s,f)=>{if(M(c)){const R=s??{};throw new X([c,{...R,replace:!0}])}const l=s,d=f??{};throw new X([c,l,{...d,replace:!0}])},r=()=>{throw new _t};async function o({to:c,from:s,hooks:f}){const{global:l,component:d}=f,R=Ee(c,s),k=[...l.onBeforeRouteEnter,...R.onBeforeRouteEnter,...l.onBeforeRouteUpdate,...R.onBeforeRouteUpdate,...d.onBeforeRouteUpdate,...l.onBeforeRouteLeave,...R.onBeforeRouteLeave,...d.onBeforeRouteLeave];try{const m=k.map(b=>b(c,{from:s,reject:t,push:e,replace:n,abort:r}));await Promise.all(m)}catch(m){if(m instanceof X)return{status:"PUSH",to:m.to};if(m instanceof pt)return{status:"REJECT",type:m.type};if(m instanceof _t)return{status:"ABORT"};throw m}return{status:"SUCCESS"}}async function a({to:c,from:s,hooks:f}){const{global:l,component:d}=f,R=Pe(c,s),k=[...d.onAfterRouteLeave,...R.onAfterRouteLeave,...l.onAfterRouteLeave,...d.onAfterRouteUpdate,...R.onAfterRouteUpdate,...l.onAfterRouteUpdate,...d.onAfterRouteEnter,...R.onAfterRouteEnter,...l.onAfterRouteEnter];try{const m=k.map(b=>b(c,{from:s,reject:t,push:e,replace:n}));await Promise.all(m)}catch(m){if(m instanceof X)return{status:"PUSH",to:m.to};if(m instanceof pt)return{status:"REJECT",type:m.type};throw m}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const dt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},mt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},Rt=(t,e,n)=>t.matches[n]===(e==null?void 0:e.matches[n]);function qt(t){switch(t){case"onBeforeRouteEnter":case"onAfterRouteEnter":return dt;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Rt;case"onBeforeRouteLeave":case"onAfterRouteLeave":return mt;default:throw new Error(`Switch is not exhaustive for lifecycle: ${t}`)}}class Se{constructor(){C(this,"global",new rt);C(this,"component",new rt)}addBeforeRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=qt(e),c=this[n][e],s=(f,l)=>{if(a(f,l.from,r))return o(f,l)};return c.add(s),()=>c.delete(s)}addAfterRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=qt(e),c=this[n][e],s=(f,l)=>{if(a(f,l.from,r))return o(f,l)};return c.add(s),()=>c.delete(s)}}const Dt=Symbol();function ke(){const t=new Se;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 Mt(){const t=u.inject(Dt);if(!t)throw new et;return t}function Tt(t){return e=>{const n=ht(),o=Mt().addBeforeRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return u.onUnmounted(o),o}}function yt(t){return e=>{const n=ht(),o=Mt().addAfterRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return u.onUnmounted(o),o}}const Ae=Tt("onBeforeRouteUpdate"),Le=Tt("onBeforeRouteLeave"),Ue=yt("onAfterRouteEnter"),xe=yt("onAfterRouteUpdate"),Be=yt("onAfterRouteLeave"),je=["href"],Wt=u.defineComponent({__name:"routerLink",props:{to:{type:[String,Function]},query:{},replace:{type:Boolean}},setup(t){const e=t,n=nt(),r=u.computed(()=>M(e.to)?e.to:e.to(n.resolve)),o=u.computed(()=>{const{to:R,...k}=e;return k}),{href:a,isMatch:c,isExactMatch:s}=jt(r),f=u.computed(()=>({"router-link--match":c.value,"router-link--exact-match":s.value})),l=u.computed(()=>{const{host:R}=new URL(r.value,window.location.origin);return R!==window.location.host});function d(R){R.preventDefault(),n.push(a.value,o.value)}return(R,k)=>(u.openBlock(),u.createElementBlock("a",{href:r.value,class:u.normalizeClass(["router-link",f.value]),onClick:d},[u.renderSlot(R.$slots,"default",u.normalizeProps(u.guardReactiveProps({resolved:r.value,isMatch:u.unref(c),isExactMatch:u.unref(s),isExternal:l.value})))],10,je))}});function gt(t){return"children"in t}function It(t){return gt(t)&&!("component"in t)&&!("components"in t)}function Ft(t){return typeof t=="object"&&t!==null&&"component"in t}function Jt(t){return typeof t=="object"&&t!==null&&"components"in t}const wt=u.defineComponent({__name:"routerView",props:{name:{}},setup(t){const{name:e="default"}=t,n=Vt(),r=Ht(),o=ht();u.provide(Ot,o+1);const a=u.computed(()=>{if(r.value)return r.value.component;const s=n.matches.at(o);if(!s)return null;const l=c(s)[e];return l?typeof l=="function"?u.defineAsyncComponent(l):l:null});function c(s){return Jt(s)?s.components:Ft(s)?{default:s.component}:{}}return(s,f)=>u.renderSlot(s.$slots,"default",u.normalizeProps(u.guardReactiveProps({route:u.unref(n),component:a.value,rejection:u.unref(r)})),()=>[(u.openBlock(),u.createBlock(u.resolveDynamicComponent(a.value)))])}});function He(t,e){return u.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=e();return"then"in n?()=>u.h(Ne(t,n)):()=>u.h(t,n)}})}function Ne(t,e){return u.defineComponent({name:"AsyncPropsWrapper",expose:[],async setup(){const n=await e;return()=>u.h(t,n)}})}const Kt=Symbol();function vt(t){return Kt in t}function $e(t){return{[Kt]:!0,...St(t)}}const T="[",G="]";function Ce(t){return t!==String&&t!==Boolean&&t!==Number&&t!==Date}function Qt(t){return typeof t=="function"&&Ce(t)}function Z(t){return typeof t=="object"&&"get"in t&&typeof t.get=="function"&&"set"in t&&typeof t.set=="function"}function Gt(t){return Z(t)&&t.defaultValue!==void 0}function Ve(t,e){return St(t,e)}function Et(t){return typeof t=="string"&&t.length>0}function Oe(t,e){return t[e]??String}const H={invalid:t=>{throw new K(t)}},_e={get:t=>t,set:(t,{invalid:e})=>{if(typeof t!="string")throw e();return t}},zt={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()}},Yt={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()}},Xt={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()}},Zt={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 Pt(t,e){if(t===void 0||!Et(t)){if(Gt(e))return e.defaultValue;if(vt(e))return;throw new K}if(e===String)return _e.get(t,H);if(e===Boolean)return zt.get(t,H);if(e===Number)return Yt.get(t,H);if(e===Date)return Xt.get(t,H);if(e===JSON)return Zt.get(t,H);if(Qt(e))return e(t,H);if(Z(e))return e.get(t,H);if(e instanceof RegExp){if(e.test(t))return t;throw new K}return t}function bt(t,e){if(t===void 0){if(vt(e))return"";throw new K}if(e===Boolean)return zt.set(t,H);if(e===Number)return Yt.set(t,H);if(e===Date)return Xt.set(t,H);if(e===JSON)return Zt.set(t,H);if(Z(e))return e.set(t,H);try{return t.toString()}catch{throw new K}}function St(t,e){return Z(t)?{...t,defaultValue:e??t.defaultValue}:{get:n=>Pt(n,t),set:n=>bt(n,t),defaultValue:e}}function _(){return _=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},_.apply(this,arguments)}var B;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(B||(B={}));var z=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function W(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}var ot="beforeunload",qe="hashchange",te="popstate";function ee(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var y=r.location,i=y.pathname,h=y.search,E=y.hash,P=o.state||{};return[P.idx,z({pathname:i,search:h,hash:E,state:P.usr||null,key:P.key||"default"})]}var c=null;function s(){if(c)m.call(c),c=null;else{var y=B.Pop,i=a(),h=i[0],E=i[1];if(m.length)if(h!=null){var P=d-h;P&&(c={action:y,location:E,retry:function(){S(P*-1)}},S(P))}else process.env.NODE_ENV!=="production"&&W(!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 j(y)}}r.addEventListener(te,s);var f=B.Pop,l=a(),d=l[0],R=l[1],k=Y(),m=Y();d==null&&(d=0,o.replaceState(_({},o.state,{idx:d}),""));function b(y){return typeof y=="string"?y:I(y)}function V(y,i){return i===void 0&&(i=null),z(_({pathname:R.pathname,hash:"",search:""},typeof y=="string"?tt(y):y,{state:i,key:ct()}))}function O(y,i){return[{usr:y.state,key:y.key,idx:i},b(y)]}function N(y,i,h){return!m.length||(m.call({action:y,location:i,retry:h}),!1)}function j(y){f=y;var i=a();d=i[0],R=i[1],k.call({action:f,location:R})}function g(y,i){var h=B.Push,E=V(y,i);function P(){g(y,i)}if(N(h,E,P)){var U=O(E,d+1),w=U[0],L=U[1];try{o.pushState(w,"",L)}catch{r.location.assign(L)}j(h)}}function v(y,i){var h=B.Replace,E=V(y,i);function P(){v(y,i)}if(N(h,E,P)){var U=O(E,d),w=U[0],L=U[1];o.replaceState(w,"",L),j(h)}}function S(y){o.go(y)}var A={get action(){return f},get location(){return R},createHref:b,push:g,replace:v,go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(i){return k.push(i)},block:function(i){var h=m.push(i);return m.length===1&&r.addEventListener(ot,at),function(){h(),m.length||r.removeEventListener(ot,at)}}};return A}function De(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var i=tt(r.location.hash.substr(1)),h=i.pathname,E=h===void 0?"/":h,P=i.search,U=P===void 0?"":P,w=i.hash,L=w===void 0?"":w,x=o.state||{};return[x.idx,z({pathname:E,search:U,hash:L,state:x.usr||null,key:x.key||"default"})]}var c=null;function s(){if(c)m.call(c),c=null;else{var i=B.Pop,h=a(),E=h[0],P=h[1];if(m.length)if(E!=null){var U=d-E;U&&(c={action:i,location:P,retry:function(){A(U*-1)}},A(U))}else process.env.NODE_ENV!=="production"&&W(!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(i)}}r.addEventListener(te,s),r.addEventListener(qe,function(){var i=a(),h=i[1];I(h)!==I(R)&&s()});var f=B.Pop,l=a(),d=l[0],R=l[1],k=Y(),m=Y();d==null&&(d=0,o.replaceState(_({},o.state,{idx:d}),""));function b(){var i=document.querySelector("base"),h="";if(i&&i.getAttribute("href")){var E=r.location.href,P=E.indexOf("#");h=P===-1?E:E.slice(0,P)}return h}function V(i){return b()+"#"+(typeof i=="string"?i:I(i))}function O(i,h){return h===void 0&&(h=null),z(_({pathname:R.pathname,hash:"",search:""},typeof i=="string"?tt(i):i,{state:h,key:ct()}))}function N(i,h){return[{usr:i.state,key:i.key,idx:h},V(i)]}function j(i,h,E){return!m.length||(m.call({action:i,location:h,retry:E}),!1)}function g(i){f=i;var h=a();d=h[0],R=h[1],k.call({action:f,location:R})}function v(i,h){var E=B.Push,P=O(i,h);function U(){v(i,h)}if(process.env.NODE_ENV!=="production"&&W(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(i)+")"),j(E,P,U)){var w=N(P,d+1),L=w[0],x=w[1];try{o.pushState(L,"",x)}catch{r.location.assign(x)}g(E)}}function S(i,h){var E=B.Replace,P=O(i,h);function U(){S(i,h)}if(process.env.NODE_ENV!=="production"&&W(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(i)+")"),j(E,P,U)){var w=N(P,d),L=w[0],x=w[1];o.replaceState(L,"",x),g(E)}}function A(i){o.go(i)}var y={get action(){return f},get location(){return R},createHref:V,push:v,replace:S,go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(h){return k.push(h)},block:function(h){var E=m.push(h);return m.length===1&&r.addEventListener(ot,at),function(){E(),m.length||r.removeEventListener(ot,at)}}};return y}function ne(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 v=z(_({pathname:"/",search:"",hash:"",state:null,key:ct()},typeof g=="string"?tt(g):g));return process.env.NODE_ENV!=="production"&&W(v.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(g)+")"),v}),c=re(o??a.length-1,0,a.length-1),s=B.Pop,f=a[c],l=Y(),d=Y();function R(g){return typeof g=="string"?g:I(g)}function k(g,v){return v===void 0&&(v=null),z(_({pathname:f.pathname,search:"",hash:""},typeof g=="string"?tt(g):g,{state:v,key:ct()}))}function m(g,v,S){return!d.length||(d.call({action:g,location:v,retry:S}),!1)}function b(g,v){s=g,f=v,l.call({action:s,location:f})}function V(g,v){var S=B.Push,A=k(g,v);function y(){V(g,v)}process.env.NODE_ENV!=="production"&&W(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(g)+")"),m(S,A,y)&&(c+=1,a.splice(c,a.length,A),b(S,A))}function O(g,v){var S=B.Replace,A=k(g,v);function y(){O(g,v)}process.env.NODE_ENV!=="production"&&W(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(g)+")"),m(S,A,y)&&(a[c]=A,b(S,A))}function N(g){var v=re(c+g,0,a.length-1),S=B.Pop,A=a[v];function y(){N(g)}m(S,A,y)&&(c=v,b(S,A))}var j={get index(){return c},get action(){return s},get location(){return f},createHref:R,push:V,replace:O,go:N,back:function(){N(-1)},forward:function(){N(1)},listen:function(v){return l.push(v)},block:function(v){return d.push(v)}};return j}function re(t,e,n){return Math.min(Math.max(t,e),n)}function at(t){t.preventDefault(),t.returnValue=""}function Y(){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 ct(){return Math.random().toString(36).substr(2,8)}function I(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 tt(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}function Me(t,e){const n=u.reactive({...t}),r=c=>{Object.assign(n,{...c})},o=n,a=we(o,e);return{currentRoute:o,routerRoute:a,updateRoute:r}}class Te extends Error{constructor(e){super(`Route disabled: "${e}"`)}}class We extends Error{constructor(e){super(`Route not found: "${e}"`)}}function Ie(t){const e=kt(t.path.toString());return new RegExp(`^${e}$`,"i")}function Fe(t){const e=new URLSearchParams(t.query.toString());return Array.from(e.entries()).filter(([,n])=>!ae(n)).map(([n,r])=>new RegExp(`${n}=${kt(r)}(&|$)`,"i"))}function kt(t){return[Je,Ke].reduce((e,n)=>n(e),t)}const At=`\\${T}\\?([\\w-_]+)\\${G}`,oe=`\\${T}([\\w-_]+)\\${G}`;function Je(t){return t.replace(new RegExp(At,"g"),".*")}function ae(t){return new RegExp(At,"g").test(t)}function Ke(t){return t.replace(new RegExp(oe,"g"),".+")}function Qe(t){const[e]=st(t,new RegExp(At,"g")),[n]=st(t,new RegExp(oe,"g"));return e??n}function st(t,e){return Array.from(t.matchAll(e)).flatMap(([,...r])=>r.map(o=>Et(o)?o:""))}function ce(t,e,n){const r=se(e,n),[o]=st(t,r);return o}function Ge(t,e){if(!e)return t;const{name:n,param:r,value:o}=e,a=se(t,n);return st(t,a).reduce((s,f)=>f===void 0?s:s.replace(f,()=>bt(o,r)),t)}function se(t,e){const n=[ze,Ye,kt].reduce((r,o)=>o(r,e),t);return new RegExp(n,"g")}function ze(t,e){const n=new RegExp(`(\\${T}\\?${e})\\${G}`,"g");return t.replace(n,"(.*)")}function Ye(t,e){const n=new RegExp(`(\\${T}${e})\\${G}`,"g");return t.replace(n,"(.+)")}function ie(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 Xe(t,e={}){const{params:n={},query:r}=e,o={...t.path.params,...t.query.params},a=t.path.toString(),c=t.query.toString(),s=Ze(a,o,n),f=tn(c,o,n);return ie(s,f,r)}function Ze(t,e,n){return t.length?Object.entries(e).reduce((r,[o,a])=>Ge(r,{name:o,param:a,value:n[o]}),t):t}function tn(t,e,n){if(!t.length)return{};const r=new URLSearchParams(t);return Array.from(r.entries()).reduce((o,[a,c])=>{const s=Qe(c);if(!s)return{...o,[a]:c};const l=bt(n[s],e[s]),d=n[s]===void 0&&l==="";return ae(c)&&d?o:{...o,[a]:l}},{})}function ue(t){return(e,n,r)=>{if(M(e))return ie(e,(n??{}).query);const o=n??{},a=r??{},c=t.find(f=>f.key===e);if(!c)throw new We(String(e));if(c.matched.disabled)throw new Te(String(e));return Xe(c,{params:o,query:a.query})}}function F(t){return!t.startsWith("http")?nn(t):en(t)}function en(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 nn(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 fe(t){const e=new URLSearchParams(t);return{get:n=>e.get(n),getAll:n=>e.getAll(n)}}const rn=(t,e)=>{try{le(t,e)}catch{return!1}return!0},le=(t,e)=>{const{pathname:n,search:r}=F(e);return{...on(t.path,n),...an(t.query,r)}};function on(t,e){const n={},r=decodeURIComponent(e);for(const[o,a]of Object.entries(t.params)){const c=ce(r,t.toString(),o),s=Pt(c,a);n[o]=s}return n}function an(t,e){const n={},r=new URLSearchParams(e);for(const[o,a]of Object.entries(t.params)){const c=r.get(o)??void 0,s=Pt(c,a);n[o]=s}return n}const cn=t=>"name"in t.matched&&!!t.matched.name,sn=(t,e)=>{const{host:n}=F(e),{host:r}=F(t.path.toString());return n===r},un=(t,e)=>{const{pathname:n}=F(e);return Ie(t).test(n)},fn=(t,e)=>{const{search:n}=F(e);return Fe(t).every(o=>o.test(n))};function ln(t){const{searchParams:e,pathname:n}=F(t),r=-1,o=1;return(a,c)=>{const s=pe(a,e),f=he(a,n),l=pe(c,e),d=he(c,n);return s+f>l+d?r:s+f<l+d?o:a.depth>c.depth?r:a.depth<c.depth?o:0}}function he(t,e){const n=Object.entries(t.path.params).filter(([,o])=>vt(o)).map(([o])=>o),r=n.filter(o=>ce(e,t.path.toString(),o)===void 0);return n.length-r.length}function pe(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}const hn=[cn,sn,un,fn,rn];function Lt(t,e){const n=ln(e),r=t.filter(f=>hn.every(l=>l(f,e))).sort(n);if(r.length===0)return;const[o]=r,{search:a}=F(e),c=fe(a),s=le(o,e);return{matched:o.matched,matches:o.matches,key:o.key,query:c,params:s}}function pn(t){return(e,n={})=>{const r=ue(t);if(M(e)){const a=r(e);return Lt(t,a)}const o=r(e,n);return Lt(t,o)}}function de(){return typeof window<"u"&&typeof window.document<"u"}function dn({mode:t,listener:e}){const n=mn(t),r=(f,l)=>{if(l!=null&&l.replace)return n.replace(f);n.push(f)},o=()=>{const f=I(n.location);return n.replace(f)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(e)},stopListening:()=>{a==null||a()}}}function mn(t="auto"){switch(t){case"auto":return de()?ee():ne();case"browser":return ee();case"memory":return ne();case"hash":return De();default:const e=t;throw new Error(`Switch is not exhaustive for mode: ${e}`)}}function Rn(t){return u.defineComponent(()=>()=>u.h("h1",t),{name:t,props:[]})}const me=Symbol();function yn({rejections:t}){const e=c=>{const s={...t};return u.markRaw(s[c]??Rn(c))},n=c=>{const s=u.markRaw(e(c)),f={name:c,path:"",component:s,meta:{}};return{matched:f,matches:[f],key:c,query:fe(""),params:{},[me]:!0}},r=c=>me in c,o=c=>{if(!c){a.value=null;return}const s=e(c);a.value={type:c,component:s}},a=u.ref(null);return{setRejection:o,rejection:a,getRejectionRoute:n,isRejectionRoute:r}}class gn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function wn(t){if(t)return t;if(de())return window.location.toString();throw new gn}function vn(t,e={}){const n=ue(t),r=dn({mode:e.historyMode,listener:()=>{const w=I(location);m(w)}}),{runBeforeRouteHooks:o,runAfterRouteHooks:a}=be(),{hooks:c,onBeforeRouteEnter:s,onAfterRouteUpdate:f,onBeforeRouteLeave:l,onAfterRouteEnter:d,onBeforeRouteUpdate:R,onAfterRouteLeave:k}=ke();async function m(w,{replace:L}={}){r.stopListening();const x=Lt(t,w)??v("NotFound"),q={...A},J=await o({to:x,from:q,hooks:c});switch(J.status){case"ABORT":return;case"PUSH":r.update(w,{replace:L}),await b(...J.to);return;case"REJECT":r.update(w,{replace:L}),j(J.type),i(x);break;case"SUCCESS":r.update(w,{replace:L}),j(null),i(x);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(J)}`)}const D=await a({to:x,from:q,hooks:c});switch(D.status){case"PUSH":await b(...D.to);break;case"REJECT":j(D.type);break;case"SUCCESS":break;default:const ut=D;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(ut)}`)}r.startListening()}const b=(w,L,x)=>{if(M(w)){const ut={...L},Bn=n(w,ut);return m(Bn,{replace:ut.replace})}const q={...x},D=n(w,L??{},q);return m(D,{replace:q.replace})},V=(w,L,x)=>{if(M(w)){const D={...L,replace:!0};return b(w,D)}const q=L??{},J={...x,replace:!0};return b(w,q,J)},O=w=>j(w),N=pn(t),{setRejection:j,rejection:g,getRejectionRoute:v}=yn(e),S=v("NotFound"),{currentRoute:A,routerRoute:y,updateRoute:i}=Me(S,b);r.startListening();const h=wn(e.initialUrl),E=m(h,{replace:!0});function P(w){w.component("RouterView",wt),w.component("RouterLink",Wt),w.provide(ft,U),w.provide(lt,g),w.provide(Dt,c)}const U={route:y,resolve:n,push:b,replace:V,reject:O,find:N,refresh:r.refresh,forward:r.forward,back:r.back,go:r.go,install:P,initialized:E,onBeforeRouteEnter:s,onAfterRouteUpdate:f,onBeforeRouteLeave:l,onAfterRouteEnter:d,onBeforeRouteUpdate:R,onAfterRouteLeave:k};return U}function Re(t,e){const n=new RegExp(`\\${T}\\??([\\w-_]+)\\${G}`,"g");return Array.from(t.matchAll(n)).reduce((o,[a,c])=>{const s=a.startsWith(`${T}?`),f=Oe(e,c);if(c in o)throw new $(c);return o[c]=s?$e(f):f,o},{})}function Ut(t,e){return{path:t,params:Re(t,e),toString:()=>t}}function xt(t,e){const n=Object.keys(t),r=Object.keys(e),o=n.find(a=>r.includes(a));return o?{key:o,hasDuplicates:!0}:{key:void 0,hasDuplicates:!1}}function En(t,e){const{hasDuplicates:n,key:r}=xt(t.params,e.params);if(n)throw new $(r);return Ut(`${t.path}${e.path}`,{...t.params,...e.params})}function it(t,e){return{query:t,params:Re(t,e),toString:()=>t}}function Pn(t,e){const{hasDuplicates:n,key:r}=xt(t.params,e.params);if(n)throw new $(r);const o=[t.query,e.query].filter(Et).join("&");return it(o,{...t.params,...e.params})}function ye(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bn(t){return ye(t)&&typeof t.path=="string"}function Sn(t){return bn(t)?t:Ut(t,{})}function kn(t){return ye(t)&&typeof t.query=="string"}function An(t){return t===void 0?it("",{}):kn(t)?t:it(t,{})}function Ln(t){const e=t.reduce((n,r)=>{const o=Un(r);return gt(r)&&n.push(...r.children.map(a=>({...a,key:Nt(o.key,a.key),path:En(o.path,a.path),query:Pn(o.query,a.query),matches:[o.matched,...a.matches],depth:a.depth+1}))),n.push(o),n},[]);return e.forEach(({path:n,query:r})=>{const{hasDuplicates:o,key:a}=xt(n.params,r.params);if(o)throw new $(a)}),e}function Un(t){const e=xn(t),n=Sn(t.path),r=An(t.query),o=u.markRaw({meta:{},...e});return{matched:o,matches:[o],key:t.name??"",path:n,query:r,depth:1,disabled:t.disabled??!1}}function xn(t){return It(t)?{...t,component:wt}:t}p.DuplicateParamsError=$,p.RouterLink=Wt,p.RouterNotInstalledError=et,p.RouterView=wt,p.UseRouteInvalidError=Bt,p.component=He,p.createParam=St,p.createRouter=vn,p.createRoutes=Ln,p.isParamGetSet=Z,p.isParamGetter=Qt,p.isParamWithDefault=Gt,p.isParentRoute=gt,p.isParentRouteWithoutComponent=It,p.isRoute=Ct,p.isRouteWithComponent=Ft,p.isRouteWithComponents=Jt,p.onAfterRouteEnter=Ue,p.onAfterRouteLeave=xe,p.onAfterRouteUpdate=Be,p.onBeforeRouteLeave=Ae,p.onBeforeRouteUpdate=Le,p.paramEnd=G,p.paramStart=T,p.path=Ut,p.query=it,p.routerInjectionKey=ft,p.routerRejectionKey=lt,p.useLink=jt,p.useRejection=Ht,p.useRoute=Vt,p.useRouter=nt,p.withDefault=Ve,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
1
+ (function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p["@kitbag/router"]={},p.Vue))})(this,function(p,u){"use strict";var jn=Object.defineProperty;var Hn=(p,u,$)=>u in p?jn(p,u,{enumerable:!0,configurable:!0,writable:!0,value:$}):p[u]=$;var C=(p,u,$)=>(Hn(p,typeof u!="symbol"?u+"":u,$),$);class $ 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 et extends Error{constructor(){super("Router not installed")}}class Bt extends Error{constructor(e,n){super(`useRoute called with incorrect route. Given ${e}, expected ${n}`)}}const ft=Symbol();function nt(){const t=u.inject(ft);if(!t)throw new et;return t}class K extends Error{}function T(t){return typeof t!="string"?!1:/^(https?:\/\/|\/).*/g.test(t)}function jt(t,e={},n={}){const r=nt(),o=u.computed(()=>u.toValue(t)),a=u.computed(()=>u.toValue(e)),c=u.computed(()=>u.toValue(n)),s=u.computed(()=>{if(T(o.value))return o.value;try{return r.resolve(o.value,a.value,c.value)}catch(R){throw R instanceof K&&console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`,R),R}}),f=u.computed(()=>r.find(s.value,c.value)),l=u.computed(()=>!!f.value&&r.route.matches.includes(f.value.matched)),d=u.computed(()=>!!f.value&&r.route.matched===f.value.matched);return{route:f,href:s,isMatch:l,isExactMatch:d,push:R=>r.push(s.value,{},{...c.value,...R}),replace:R=>r.replace(s.value,{},{...c.value,...R})}}const lt=Symbol();function Ht(){const t=u.inject(lt);if(!t)throw new et;return t}function Nt(t,e){return[t,e].filter(n=>!!n).join(".")}const $t=Symbol("isRouterRouteSymbol");function ge(t){return typeof t=="object"&&t!==null&&$t in t}function we(t,e){function n(l,d,R){if(typeof l=="object"){const m={...t.params,...l};return e(t.key,m,d)}const k={...t.params,[l]:d};return e(t.key,k,R)}const{matched:r,matches:o,key:a,query:c,params:s}=u.toRefs(t),f=u.reactive({matched:r,matches:o,query:c,params:s,key:a,update:n,[$t]:!0});return new Proxy(f,{get:(l,d,R)=>d==="params"?new Proxy(t.params,{set(k,m,b){return n(m,b),!0}}):Reflect.get(l,d,R)})}function Ct(t,e,{exact:n}={}){if(!ge(t))return!1;if(e===void 0)return!0;const r=ve(t);if(n){const o=r.at(-1);return e===o}return r.includes(e)}function ve(t){return t.matches.map(n=>n.name).reduce((n,r)=>{const o=n.pop(),a=r?[Nt(o,r)]:[];return o?[...n,o,...a]:a},[])}function Vt(t,{exact:e}={}){const n=nt();function r(){if(!t)return;if(!Ct(n.route,t,{exact:e}))throw new Bt(t,n.route.key)}return u.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const Ot=Symbol();function ht(){return u.inject(Ot,0)}class rt{constructor(){C(this,"onBeforeRouteEnter",new Set);C(this,"onBeforeRouteUpdate",new Set);C(this,"onBeforeRouteLeave",new Set);C(this,"onAfterRouteEnter",new Set);C(this,"onAfterRouteUpdate",new Set);C(this,"onAfterRouteLeave",new Set)}}class _t extends Error{}class X extends Error{constructor(n){super("Error occurred during a router push operation.");C(this,"to");this.to=n}}class pt extends Error{constructor(n){super(`Routing action rejected: ${n}`);C(this,"type");this.type=n}}function Q(t){return Array.isArray(t)?t:[t]}function Ee(t,e){const n=new rt;return t.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&dt(t,e,o)&&Q(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&Rt(t,e,o)&&Q(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&mt(t,e,o)&&Q(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function Pe(t,e){const n=new rt;return t.matches.forEach((r,o)=>{r.onAfterRouteEnter&&dt(t,e,o)&&Q(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&Rt(t,e,o)&&Q(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onAfterRouteLeave&&mt(t,e,o)&&Q(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function be(){const t=c=>{throw new pt(c)},e=(...c)=>{throw new X(c)},n=(c,s,f)=>{if(T(c)){const R=s??{};throw new X([c,{...R,replace:!0}])}const l=s,d=f??{};throw new X([c,l,{...d,replace:!0}])},r=()=>{throw new _t};async function o({to:c,from:s,hooks:f}){const{global:l,component:d}=f,R=Ee(c,s),k=[...l.onBeforeRouteEnter,...R.onBeforeRouteEnter,...l.onBeforeRouteUpdate,...R.onBeforeRouteUpdate,...d.onBeforeRouteUpdate,...l.onBeforeRouteLeave,...R.onBeforeRouteLeave,...d.onBeforeRouteLeave];try{const m=k.map(b=>b(c,{from:s,reject:t,push:e,replace:n,abort:r}));await Promise.all(m)}catch(m){if(m instanceof X)return{status:"PUSH",to:m.to};if(m instanceof pt)return{status:"REJECT",type:m.type};if(m instanceof _t)return{status:"ABORT"};throw m}return{status:"SUCCESS"}}async function a({to:c,from:s,hooks:f}){const{global:l,component:d}=f,R=Pe(c,s),k=[...d.onAfterRouteLeave,...R.onAfterRouteLeave,...l.onAfterRouteLeave,...d.onAfterRouteUpdate,...R.onAfterRouteUpdate,...l.onAfterRouteUpdate,...d.onAfterRouteEnter,...R.onAfterRouteEnter,...l.onAfterRouteEnter];try{const m=k.map(b=>b(c,{from:s,reject:t,push:e,replace:n}));await Promise.all(m)}catch(m){if(m instanceof X)return{status:"PUSH",to:m.to};if(m instanceof pt)return{status:"REJECT",type:m.type};throw m}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const dt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},mt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},Rt=(t,e,n)=>t.matches[n]===(e==null?void 0:e.matches[n]);function qt(t){switch(t){case"onBeforeRouteEnter":case"onAfterRouteEnter":return dt;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Rt;case"onBeforeRouteLeave":case"onAfterRouteLeave":return mt;default:throw new Error(`Switch is not exhaustive for lifecycle: ${t}`)}}class Se{constructor(){C(this,"global",new rt);C(this,"component",new rt)}addBeforeRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=qt(e),c=this[n][e],s=(f,l)=>{if(a(f,l.from,r))return o(f,l)};return c.add(s),()=>c.delete(s)}addAfterRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=qt(e),c=this[n][e],s=(f,l)=>{if(a(f,l.from,r))return o(f,l)};return c.add(s),()=>c.delete(s)}}const Dt=Symbol();function ke(){const t=new Se;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 Mt(){const t=u.inject(Dt);if(!t)throw new et;return t}function Tt(t){return e=>{const n=ht(),o=Mt().addBeforeRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return u.onUnmounted(o),o}}function yt(t){return e=>{const n=ht(),o=Mt().addAfterRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return u.onUnmounted(o),o}}const Ae=Tt("onBeforeRouteUpdate"),Le=Tt("onBeforeRouteLeave"),Ue=yt("onAfterRouteEnter"),xe=yt("onAfterRouteUpdate"),Be=yt("onAfterRouteLeave"),je=["href"],Wt=u.defineComponent({__name:"routerLink",props:{to:{type:[String,Function]},query:{},replace:{type:Boolean}},setup(t){const e=t,n=nt(),r=u.computed(()=>T(e.to)?e.to:e.to(n.resolve)),o=u.computed(()=>{const{to:R,...k}=e;return k}),{href:a,isMatch:c,isExactMatch:s}=jt(r),f=u.computed(()=>({"router-link--match":c.value,"router-link--exact-match":s.value})),l=u.computed(()=>{const{host:R}=new URL(r.value,window.location.origin);return R!==window.location.host});function d(R){R.preventDefault(),n.push(a.value,o.value)}return(R,k)=>(u.openBlock(),u.createElementBlock("a",{href:r.value,class:u.normalizeClass(["router-link",f.value]),onClick:d},[u.renderSlot(R.$slots,"default",u.normalizeProps(u.guardReactiveProps({resolved:r.value,isMatch:u.unref(c),isExactMatch:u.unref(s),isExternal:l.value})))],10,je))}});function gt(t){return"children"in t}function It(t){return gt(t)&&!("component"in t)&&!("components"in t)}function Ft(t){return typeof t=="object"&&t!==null&&"component"in t}function Jt(t){return typeof t=="object"&&t!==null&&"components"in t}const wt=u.defineComponent({__name:"routerView",props:{name:{}},setup(t){const{name:e="default"}=t,n=Vt(),r=Ht(),o=ht();u.provide(Ot,o+1);const a=u.computed(()=>{if(r.value)return r.value.component;const s=n.matches.at(o);if(!s)return null;const l=c(s)[e];return l?typeof l=="function"?u.defineAsyncComponent(l):l:null});function c(s){return Jt(s)?s.components:Ft(s)?{default:s.component}:{}}return(s,f)=>u.renderSlot(s.$slots,"default",u.normalizeProps(u.guardReactiveProps({route:u.unref(n),component:a.value,rejection:u.unref(r)})),()=>[(u.openBlock(),u.createBlock(u.resolveDynamicComponent(a.value)))])}});function He(t,e){return u.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=e();return"then"in n?()=>u.h(Ne(t,n)):()=>u.h(t,n)}})}function Ne(t,e){return u.defineComponent({name:"AsyncPropsWrapper",expose:[],async setup(){const n=await e;return()=>u.h(t,n)}})}const Kt=Symbol();function vt(t){return Kt in t}function $e(t){return{[Kt]:!0,...St(t)}}const W="[",G="]";function Ce(t){return t!==String&&t!==Boolean&&t!==Number&&t!==Date}function Qt(t){return typeof t=="function"&&Ce(t)}function Z(t){return typeof t=="object"&&"get"in t&&typeof t.get=="function"&&"set"in t&&typeof t.set=="function"}function Gt(t){return Z(t)&&t.defaultValue!==void 0}function Ve(t,e){return St(t,e)}function Et(t){return typeof t=="string"&&t.length>0}function Oe(t,e){return t[e]??String}const H={invalid:t=>{throw new K(t)}},_e={get:t=>t,set:(t,{invalid:e})=>{if(typeof t!="string")throw e();return t}},zt={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()}},Yt={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()}},Xt={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()}},Zt={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 Pt(t,e){if(t===void 0||!Et(t)){if(Gt(e))return e.defaultValue;if(vt(e))return;throw new K}if(e===String)return _e.get(t,H);if(e===Boolean)return zt.get(t,H);if(e===Number)return Yt.get(t,H);if(e===Date)return Xt.get(t,H);if(e===JSON)return Zt.get(t,H);if(Qt(e))return e(t,H);if(Z(e))return e.get(t,H);if(e instanceof RegExp){if(e.test(t))return t;throw new K}return t}function bt(t,e){if(t===void 0){if(vt(e))return"";throw new K}if(e===Boolean)return zt.set(t,H);if(e===Number)return Yt.set(t,H);if(e===Date)return Xt.set(t,H);if(e===JSON)return Zt.set(t,H);if(Z(e))return e.set(t,H);try{return t.toString()}catch{throw new K}}function St(t,e){return Z(t)?{...t,defaultValue:e??t.defaultValue}:{get:n=>Pt(n,t),set:n=>bt(n,t),defaultValue:e}}function _(){return _=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},_.apply(this,arguments)}var B;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(B||(B={}));var z=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function I(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}var ot="beforeunload",qe="hashchange",te="popstate";function ee(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var y=r.location,i=y.pathname,h=y.search,E=y.hash,P=o.state||{};return[P.idx,z({pathname:i,search:h,hash:E,state:P.usr||null,key:P.key||"default"})]}var c=null;function s(){if(c)m.call(c),c=null;else{var y=B.Pop,i=a(),h=i[0],E=i[1];if(m.length)if(h!=null){var P=d-h;P&&(c={action:y,location:E,retry:function(){S(P*-1)}},S(P))}else process.env.NODE_ENV!=="production"&&I(!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 j(y)}}r.addEventListener(te,s);var f=B.Pop,l=a(),d=l[0],R=l[1],k=Y(),m=Y();d==null&&(d=0,o.replaceState(_({},o.state,{idx:d}),""));function b(y){return typeof y=="string"?y:F(y)}function V(y,i){return i===void 0&&(i=null),z(_({pathname:R.pathname,hash:"",search:""},typeof y=="string"?tt(y):y,{state:i,key:ct()}))}function O(y,i){return[{usr:y.state,key:y.key,idx:i},b(y)]}function N(y,i,h){return!m.length||(m.call({action:y,location:i,retry:h}),!1)}function j(y){f=y;var i=a();d=i[0],R=i[1],k.call({action:f,location:R})}function g(y,i){var h=B.Push,E=V(y,i);function P(){g(y,i)}if(N(h,E,P)){var U=O(E,d+1),w=U[0],L=U[1];try{o.pushState(w,"",L)}catch{r.location.assign(L)}j(h)}}function v(y,i){var h=B.Replace,E=V(y,i);function P(){v(y,i)}if(N(h,E,P)){var U=O(E,d),w=U[0],L=U[1];o.replaceState(w,"",L),j(h)}}function S(y){o.go(y)}var A={get action(){return f},get location(){return R},createHref:b,push:g,replace:v,go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(i){return k.push(i)},block:function(i){var h=m.push(i);return m.length===1&&r.addEventListener(ot,at),function(){h(),m.length||r.removeEventListener(ot,at)}}};return A}function De(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var i=tt(r.location.hash.substr(1)),h=i.pathname,E=h===void 0?"/":h,P=i.search,U=P===void 0?"":P,w=i.hash,L=w===void 0?"":w,x=o.state||{};return[x.idx,z({pathname:E,search:U,hash:L,state:x.usr||null,key:x.key||"default"})]}var c=null;function s(){if(c)m.call(c),c=null;else{var i=B.Pop,h=a(),E=h[0],P=h[1];if(m.length)if(E!=null){var U=d-E;U&&(c={action:i,location:P,retry:function(){A(U*-1)}},A(U))}else process.env.NODE_ENV!=="production"&&I(!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(i)}}r.addEventListener(te,s),r.addEventListener(qe,function(){var i=a(),h=i[1];F(h)!==F(R)&&s()});var f=B.Pop,l=a(),d=l[0],R=l[1],k=Y(),m=Y();d==null&&(d=0,o.replaceState(_({},o.state,{idx:d}),""));function b(){var i=document.querySelector("base"),h="";if(i&&i.getAttribute("href")){var E=r.location.href,P=E.indexOf("#");h=P===-1?E:E.slice(0,P)}return h}function V(i){return b()+"#"+(typeof i=="string"?i:F(i))}function O(i,h){return h===void 0&&(h=null),z(_({pathname:R.pathname,hash:"",search:""},typeof i=="string"?tt(i):i,{state:h,key:ct()}))}function N(i,h){return[{usr:i.state,key:i.key,idx:h},V(i)]}function j(i,h,E){return!m.length||(m.call({action:i,location:h,retry:E}),!1)}function g(i){f=i;var h=a();d=h[0],R=h[1],k.call({action:f,location:R})}function v(i,h){var E=B.Push,P=O(i,h);function U(){v(i,h)}if(process.env.NODE_ENV!=="production"&&I(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(i)+")"),j(E,P,U)){var w=N(P,d+1),L=w[0],x=w[1];try{o.pushState(L,"",x)}catch{r.location.assign(x)}g(E)}}function S(i,h){var E=B.Replace,P=O(i,h);function U(){S(i,h)}if(process.env.NODE_ENV!=="production"&&I(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(i)+")"),j(E,P,U)){var w=N(P,d),L=w[0],x=w[1];o.replaceState(L,"",x),g(E)}}function A(i){o.go(i)}var y={get action(){return f},get location(){return R},createHref:V,push:v,replace:S,go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(h){return k.push(h)},block:function(h){var E=m.push(h);return m.length===1&&r.addEventListener(ot,at),function(){E(),m.length||r.removeEventListener(ot,at)}}};return y}function ne(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 v=z(_({pathname:"/",search:"",hash:"",state:null,key:ct()},typeof g=="string"?tt(g):g));return process.env.NODE_ENV!=="production"&&I(v.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(g)+")"),v}),c=re(o??a.length-1,0,a.length-1),s=B.Pop,f=a[c],l=Y(),d=Y();function R(g){return typeof g=="string"?g:F(g)}function k(g,v){return v===void 0&&(v=null),z(_({pathname:f.pathname,search:"",hash:""},typeof g=="string"?tt(g):g,{state:v,key:ct()}))}function m(g,v,S){return!d.length||(d.call({action:g,location:v,retry:S}),!1)}function b(g,v){s=g,f=v,l.call({action:s,location:f})}function V(g,v){var S=B.Push,A=k(g,v);function y(){V(g,v)}process.env.NODE_ENV!=="production"&&I(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(g)+")"),m(S,A,y)&&(c+=1,a.splice(c,a.length,A),b(S,A))}function O(g,v){var S=B.Replace,A=k(g,v);function y(){O(g,v)}process.env.NODE_ENV!=="production"&&I(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(g)+")"),m(S,A,y)&&(a[c]=A,b(S,A))}function N(g){var v=re(c+g,0,a.length-1),S=B.Pop,A=a[v];function y(){N(g)}m(S,A,y)&&(c=v,b(S,A))}var j={get index(){return c},get action(){return s},get location(){return f},createHref:R,push:V,replace:O,go:N,back:function(){N(-1)},forward:function(){N(1)},listen:function(v){return l.push(v)},block:function(v){return d.push(v)}};return j}function re(t,e,n){return Math.min(Math.max(t,e),n)}function at(t){t.preventDefault(),t.returnValue=""}function Y(){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 ct(){return Math.random().toString(36).substr(2,8)}function F(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 tt(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}function Me(t,e){const n=u.reactive({...t}),r=c=>{Object.assign(n,{...c})},o=n,a=we(o,e);return{currentRoute:o,routerRoute:a,updateRoute:r}}class Te extends Error{constructor(e){super(`Route disabled: "${e}"`)}}class We extends Error{constructor(e){super(`Route not found: "${e}"`)}}function Ie(t){const e=kt(t.path.toString());return new RegExp(`^${e}$`,"i")}function Fe(t){const e=new URLSearchParams(t.query.toString());return Array.from(e.entries()).filter(([,n])=>!ae(n)).map(([n,r])=>new RegExp(`${n}=${kt(r)}(&|$)`,"i"))}function kt(t){return[Je,Ke].reduce((e,n)=>n(e),t)}const At=`\\${W}\\?([\\w-_]+)\\${G}`,oe=`\\${W}([\\w-_]+)\\${G}`;function Je(t){return t.replace(new RegExp(At,"g"),".*")}function ae(t){return new RegExp(At,"g").test(t)}function Ke(t){return t.replace(new RegExp(oe,"g"),".+")}function Qe(t){const[e]=st(t,new RegExp(At,"g")),[n]=st(t,new RegExp(oe,"g"));return e??n}function st(t,e){return Array.from(t.matchAll(e)).flatMap(([,...r])=>r.map(o=>Et(o)?o:""))}function ce(t,e,n){const r=se(e,n),[o]=st(t,r);return o}function Ge(t,e){if(!e)return t;const{name:n,param:r,value:o}=e,a=se(t,n);return st(t,a).reduce((s,f)=>f===void 0?s:s.replace(f,()=>bt(o,r)),t)}function se(t,e){const n=[ze,Ye,kt].reduce((r,o)=>o(r,e),t);return new RegExp(n,"g")}function ze(t,e){const n=new RegExp(`(\\${W}\\?${e})\\${G}`,"g");return t.replace(n,"(.*)")}function Ye(t,e){const n=new RegExp(`(\\${W}${e})\\${G}`,"g");return t.replace(n,"(.+)")}function ie(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 Xe(t,e={}){const{params:n={},query:r}=e,o={...t.path.params,...t.query.params},a=t.path.toString(),c=t.query.toString(),s=Ze(a,o,n),f=tn(c,o,n);return ie(s,f,r)}function Ze(t,e,n){return t.length?Object.entries(e).reduce((r,[o,a])=>Ge(r,{name:o,param:a,value:n[o]}),t):t}function tn(t,e,n){if(!t.length)return{};const r=new URLSearchParams(t);return Array.from(r.entries()).reduce((o,[a,c])=>{const s=Qe(c);if(!s)return{...o,[a]:c};const l=bt(n[s],e[s]),d=n[s]===void 0&&l==="";return ae(c)&&d?o:{...o,[a]:l}},{})}function ue(t){return(e,n,r)=>{if(T(e))return ie(e,(n??{}).query);const o=n??{},a=r??{},c=t.find(f=>f.key===e);if(!c)throw new We(String(e));if(c.matched.disabled)throw new Te(String(e));return Xe(c,{params:o,query:a.query})}}function q(t){return!t.startsWith("http")?nn(t):en(t)}function en(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 nn(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 fe(t){const e=new URLSearchParams(t);return{get:n=>e.get(n),getAll:n=>e.getAll(n)}}const rn=(t,e)=>{try{le(t,e)}catch{return!1}return!0},le=(t,e)=>{const{pathname:n,search:r}=q(e);return{...on(t.path,n),...an(t.query,r)}};function on(t,e){const n={},r=decodeURIComponent(e);for(const[o,a]of Object.entries(t.params)){const c=ce(r,t.toString(),o),s=Pt(c,a);n[o]=s}return n}function an(t,e){const n={},r=new URLSearchParams(e);for(const[o,a]of Object.entries(t.params)){const c=r.get(o)??void 0,s=Pt(c,a);n[o]=s}return n}const cn=t=>"name"in t.matched&&!!t.matched.name,sn=(t,e)=>{const{host:n}=q(e),{host:r}=q(t.path.toString());return n===r},un=(t,e)=>{const{pathname:n}=q(e);return Ie(t).test(n)},fn=(t,e)=>{const{search:n}=q(e);return Fe(t).every(o=>o.test(n))};function ln(t){const{searchParams:e,pathname:n}=q(t),r=-1,o=1;return(a,c)=>{const s=pe(a,e),f=he(a,n),l=pe(c,e),d=he(c,n);return s+f>l+d?r:s+f<l+d?o:a.depth>c.depth?r:a.depth<c.depth?o:0}}function he(t,e){const n=Object.entries(t.path.params).filter(([,o])=>vt(o)).map(([o])=>o),r=n.filter(o=>ce(e,t.path.toString(),o)===void 0);return n.length-r.length}function pe(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}const hn=[cn,sn,un,fn,rn];function Lt(t,e){const n=ln(e),r=t.filter(f=>hn.every(l=>l(f,e))).sort(n);if(r.length===0)return;const[o]=r,{search:a}=q(e),c=fe(a),s=le(o,e);return{matched:o.matched,matches:o.matches,key:o.key,query:c,params:s}}function pn(t){return(e,n={})=>{const r=ue(t);if(T(e)){const a=r(e);return Lt(t,a)}const o=r(e,n);return Lt(t,o)}}function de(){return typeof window<"u"&&typeof window.document<"u"}function dn({mode:t,listener:e}){const n=mn(t),r=(f,l)=>{if(l!=null&&l.replace)return n.replace(f);n.push(f)},o=()=>{const f=F(n.location);return n.replace(f)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(e)},stopListening:()=>{a==null||a()}}}function mn(t="auto"){switch(t){case"auto":return de()?ee():ne();case"browser":return ee();case"memory":return ne();case"hash":return De();default:const e=t;throw new Error(`Switch is not exhaustive for mode: ${e}`)}}function Rn(t){return u.defineComponent(()=>()=>u.h("h1",t),{name:t,props:[]})}const me=Symbol();function yn({rejections:t}){const e=c=>{const s={...t};return u.markRaw(s[c]??Rn(c))},n=c=>{const s=u.markRaw(e(c)),f={name:c,path:"",component:s,meta:{}};return{matched:f,matches:[f],key:c,query:fe(""),params:{},[me]:!0}},r=c=>me in c,o=c=>{if(!c){a.value=null;return}const s=e(c);a.value={type:c,component:s}},a=u.ref(null);return{setRejection:o,rejection:a,getRejectionRoute:n,isRejectionRoute:r}}class gn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function wn(t){if(t)return t;if(de()){const{pathname:e,search:n,hash:r}=q(window.location.toString());return[e,n,r].join("")}throw new gn}function vn(t,e={}){const n=ue(t),r=dn({mode:e.historyMode,listener:()=>{const w=F(location);m(w)}}),{runBeforeRouteHooks:o,runAfterRouteHooks:a}=be(),{hooks:c,onBeforeRouteEnter:s,onAfterRouteUpdate:f,onBeforeRouteLeave:l,onAfterRouteEnter:d,onBeforeRouteUpdate:R,onAfterRouteLeave:k}=ke();async function m(w,{replace:L}={}){r.stopListening();const x=Lt(t,w)??v("NotFound"),D={...A},J=await o({to:x,from:D,hooks:c});switch(J.status){case"ABORT":return;case"PUSH":r.update(w,{replace:L}),await b(...J.to);return;case"REJECT":r.update(w,{replace:L}),j(J.type),i(x);break;case"SUCCESS":r.update(w,{replace:L}),j(null),i(x);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(J)}`)}const M=await a({to:x,from:D,hooks:c});switch(M.status){case"PUSH":await b(...M.to);break;case"REJECT":j(M.type);break;case"SUCCESS":break;default:const ut=M;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(ut)}`)}r.startListening()}const b=(w,L,x)=>{if(T(w)){const ut={...L},Bn=n(w,ut);return m(Bn,{replace:ut.replace})}const D={...x},M=n(w,L??{},D);return m(M,{replace:D.replace})},V=(w,L,x)=>{if(T(w)){const M={...L,replace:!0};return b(w,M)}const D=L??{},J={...x,replace:!0};return b(w,D,J)},O=w=>j(w),N=pn(t),{setRejection:j,rejection:g,getRejectionRoute:v}=yn(e),S=v("NotFound"),{currentRoute:A,routerRoute:y,updateRoute:i}=Me(S,b);r.startListening();const h=wn(e.initialUrl),E=m(h,{replace:!0});function P(w){w.component("RouterView",wt),w.component("RouterLink",Wt),w.provide(ft,U),w.provide(lt,g),w.provide(Dt,c)}const U={route:y,resolve:n,push:b,replace:V,reject:O,find:N,refresh:r.refresh,forward:r.forward,back:r.back,go:r.go,install:P,initialized:E,onBeforeRouteEnter:s,onAfterRouteUpdate:f,onBeforeRouteLeave:l,onAfterRouteEnter:d,onBeforeRouteUpdate:R,onAfterRouteLeave:k};return U}function Re(t,e){const n=new RegExp(`\\${W}\\??([\\w-_]+)\\${G}`,"g");return Array.from(t.matchAll(n)).reduce((o,[a,c])=>{const s=a.startsWith(`${W}?`),f=Oe(e,c);if(c in o)throw new $(c);return o[c]=s?$e(f):f,o},{})}function Ut(t,e){return{path:t,params:Re(t,e),toString:()=>t}}function xt(t,e){const n=Object.keys(t),r=Object.keys(e),o=n.find(a=>r.includes(a));return o?{key:o,hasDuplicates:!0}:{key:void 0,hasDuplicates:!1}}function En(t,e){const{hasDuplicates:n,key:r}=xt(t.params,e.params);if(n)throw new $(r);return Ut(`${t.path}${e.path}`,{...t.params,...e.params})}function it(t,e){return{query:t,params:Re(t,e),toString:()=>t}}function Pn(t,e){const{hasDuplicates:n,key:r}=xt(t.params,e.params);if(n)throw new $(r);const o=[t.query,e.query].filter(Et).join("&");return it(o,{...t.params,...e.params})}function ye(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bn(t){return ye(t)&&typeof t.path=="string"}function Sn(t){return bn(t)?t:Ut(t,{})}function kn(t){return ye(t)&&typeof t.query=="string"}function An(t){return t===void 0?it("",{}):kn(t)?t:it(t,{})}function Ln(t){const e=t.reduce((n,r)=>{const o=Un(r);return gt(r)&&n.push(...r.children.map(a=>({...a,key:Nt(o.key,a.key),path:En(o.path,a.path),query:Pn(o.query,a.query),matches:[o.matched,...a.matches],depth:a.depth+1}))),n.push(o),n},[]);return e.forEach(({path:n,query:r})=>{const{hasDuplicates:o,key:a}=xt(n.params,r.params);if(o)throw new $(a)}),e}function Un(t){const e=xn(t),n=Sn(t.path),r=An(t.query),o=u.markRaw({meta:{},...e});return{matched:o,matches:[o],key:t.name??"",path:n,query:r,depth:1,disabled:t.disabled??!1}}function xn(t){return It(t)?{...t,component:wt}:t}p.DuplicateParamsError=$,p.RouterLink=Wt,p.RouterNotInstalledError=et,p.RouterView=wt,p.UseRouteInvalidError=Bt,p.component=He,p.createParam=St,p.createRouter=vn,p.createRoutes=Ln,p.isParamGetSet=Z,p.isParamGetter=Qt,p.isParamWithDefault=Gt,p.isParentRoute=gt,p.isParentRouteWithoutComponent=It,p.isRoute=Ct,p.isRouteWithComponent=Ft,p.isRouteWithComponents=Jt,p.onAfterRouteEnter=Ue,p.onAfterRouteLeave=xe,p.onAfterRouteUpdate=Be,p.onBeforeRouteLeave=Ae,p.onBeforeRouteUpdate=Le,p.paramEnd=G,p.paramStart=W,p.path=Ut,p.query=it,p.routerInjectionKey=ft,p.routerRejectionKey=lt,p.useLink=jt,p.useRejection=Ht,p.useRoute=Vt,p.useRouter=nt,p.withDefault=Ve,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kitbag/router",
3
3
  "private": false,
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "bugs": {
6
6
  "url": "https://github.com/kitbagjs/router/issues"
7
7
  },