@jasonshimmy/custom-elements-runtime 2.5.2 → 2.5.5

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.
Files changed (94) hide show
  1. package/README.md +115 -40
  2. package/dist/css/colors.d.ts +14 -0
  3. package/dist/custom-elements-runtime.cjs.js +6 -1
  4. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  5. package/dist/custom-elements-runtime.colors.cjs.js +2 -0
  6. package/dist/custom-elements-runtime.colors.cjs.js.map +1 -0
  7. package/dist/custom-elements-runtime.colors.es.js +279 -0
  8. package/dist/custom-elements-runtime.colors.es.js.map +1 -0
  9. package/dist/custom-elements-runtime.directive-enhancements.es.js +1 -1
  10. package/dist/custom-elements-runtime.es.js +258 -166
  11. package/dist/custom-elements-runtime.es.js.map +1 -1
  12. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
  13. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  14. package/dist/custom-elements-runtime.event-bus.es.js +28 -25
  15. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  16. package/dist/custom-elements-runtime.router.cjs.js +20 -20
  17. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  18. package/dist/custom-elements-runtime.router.es.js +549 -531
  19. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  20. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  21. package/dist/custom-elements-runtime.ssr.es.js +12 -8
  22. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  23. package/dist/custom-elements-runtime.store.cjs.js +1 -1
  24. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  25. package/dist/custom-elements-runtime.store.es.js +5 -5
  26. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  27. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  28. package/dist/custom-elements-runtime.transitions.es.js +1 -1
  29. package/dist/event-bus.d.ts +17 -4
  30. package/dist/index.d.ts +13 -5
  31. package/dist/keep-alive.d.ts +50 -0
  32. package/dist/{logger-BuUYv7C_.js → logger-BvkEbVM4.js} +15 -11
  33. package/dist/logger-BvkEbVM4.js.map +1 -0
  34. package/dist/logger-CSALKaYm.cjs +2 -0
  35. package/dist/logger-CSALKaYm.cjs.map +1 -0
  36. package/dist/namespace-helpers-4qeKVqQw.cjs +5 -0
  37. package/dist/namespace-helpers-4qeKVqQw.cjs.map +1 -0
  38. package/dist/namespace-helpers-DcD_6_K1.js +989 -0
  39. package/dist/namespace-helpers-DcD_6_K1.js.map +1 -0
  40. package/dist/router/active-proxy.d.ts +5 -0
  41. package/dist/router/component-loader.d.ts +11 -0
  42. package/dist/router/instance.d.ts +11 -0
  43. package/dist/router/matcher.d.ts +14 -0
  44. package/dist/router/path-utils.d.ts +48 -0
  45. package/dist/router/types.d.ts +134 -0
  46. package/dist/router.d.ts +6 -208
  47. package/dist/runtime/builtin-components.d.ts +78 -0
  48. package/dist/runtime/component/element-class.d.ts +4 -0
  49. package/dist/runtime/component/factory.d.ts +39 -0
  50. package/dist/runtime/component/registry.d.ts +16 -0
  51. package/dist/runtime/component.d.ts +3 -50
  52. package/dist/runtime/discovery-state.d.ts +30 -0
  53. package/dist/runtime/hooks.d.ts +115 -0
  54. package/dist/runtime/logger.d.ts +19 -1
  55. package/dist/runtime/monitoring/health-monitor.d.ts +22 -65
  56. package/dist/runtime/reactive.d.ts +39 -7
  57. package/dist/runtime/render.d.ts +20 -4
  58. package/dist/runtime/scheduler.d.ts +69 -2
  59. package/dist/runtime/template-compiler/impl.d.ts +14 -0
  60. package/dist/runtime/template-compiler/lru-cache.d.ts +20 -0
  61. package/dist/runtime/template-compiler/props-parser.d.ts +15 -0
  62. package/dist/runtime/template-compiler/vnode-utils.d.ts +5 -0
  63. package/dist/runtime/template-compiler.d.ts +5 -28
  64. package/dist/runtime/types.d.ts +10 -0
  65. package/dist/runtime/vdom-directives.d.ts +71 -0
  66. package/dist/runtime/vdom-helpers.d.ts +126 -0
  67. package/dist/runtime/vdom-patch.d.ts +67 -0
  68. package/dist/runtime/vdom.d.ts +16 -140
  69. package/dist/ssr.d.ts +2 -1
  70. package/dist/teleport.d.ts +68 -0
  71. package/dist/template-compiler-CA4YRaBu.cjs +23 -0
  72. package/dist/template-compiler-CA4YRaBu.cjs.map +1 -0
  73. package/dist/template-compiler-CJFwjLCP.js +3981 -0
  74. package/dist/template-compiler-CJFwjLCP.js.map +1 -0
  75. package/dist/transitions-DPZiuXb9.cjs +330 -0
  76. package/dist/transitions-DPZiuXb9.cjs.map +1 -0
  77. package/dist/{transitions-Bx0Nc9zR.js → transitions-Di5wW9yc.js} +1072 -632
  78. package/dist/transitions-Di5wW9yc.js.map +1 -0
  79. package/dist/transitions.d.ts +1 -1
  80. package/package.json +18 -11
  81. package/dist/logger-BuUYv7C_.js.map +0 -1
  82. package/dist/logger-DiXdWaF-.cjs +0 -2
  83. package/dist/logger-DiXdWaF-.cjs.map +0 -1
  84. package/dist/namespace-helpers-BCVTzhAO.cjs +0 -5
  85. package/dist/namespace-helpers-BCVTzhAO.cjs.map +0 -1
  86. package/dist/namespace-helpers-CF28TyaG.js +0 -786
  87. package/dist/namespace-helpers-CF28TyaG.js.map +0 -1
  88. package/dist/template-compiler-CXHEnaBh.cjs +0 -17
  89. package/dist/template-compiler-CXHEnaBh.cjs.map +0 -1
  90. package/dist/template-compiler-DD_VZrte.js +0 -3729
  91. package/dist/template-compiler-DD_VZrte.js.map +0 -1
  92. package/dist/transitions-Bx0Nc9zR.js.map +0 -1
  93. package/dist/transitions-DfcqL-X4.cjs +0 -302
  94. package/dist/transitions-DfcqL-X4.cjs.map +0 -1
@@ -1,222 +1,368 @@
1
- import { c as st, h as L, a as ct, b as it, g as vt, f as bt } from "./template-compiler-DD_VZrte.js";
2
- import { f as et, r as Y, c as T } from "./namespace-helpers-CF28TyaG.js";
1
+ import { a as y, d as I } from "./logger-BvkEbVM4.js";
2
+ import { f as rt, r as tt, c as T } from "./namespace-helpers-DcD_6_K1.js";
3
+ import { c as st, h as F, k as ct, l as it, b as bt, n as wt } from "./template-compiler-CJFwjLCP.js";
3
4
  import { createStore as lt } from "./custom-elements-runtime.store.es.js";
4
- import { d as I, a as g } from "./logger-BuUYv7C_.js";
5
- import { match as wt } from "./custom-elements-runtime.directives.es.js";
5
+ import { match as St } from "./custom-elements-runtime.directives.es.js";
6
6
  const ut = {
7
7
  enabled: !0,
8
8
  offset: 0,
9
9
  timeoutMs: 2e3
10
- }, at = (t) => t ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(t)) : {}, St = (t) => {
10
+ }, at = (t) => t ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(t)) : {}, Rt = (t) => {
11
11
  if (!t || Object.keys(t).length === 0) return "";
12
12
  try {
13
13
  return "?" + new URLSearchParams(t).toString();
14
14
  } catch {
15
15
  return "";
16
16
  }
17
- }, ft = (t) => t ? /^\s*javascript\s*:/i.test(t) : !1, H = (t) => /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t) || t.startsWith("//"), Rt = (t) => {
17
+ }, ft = (t) => t ? /^\s*javascript\s*:/i.test(t) : !1, Z = (t) => /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t) || t.startsWith("//"), $t = (t) => {
18
18
  try {
19
19
  return decodeURIComponent(t);
20
20
  } catch {
21
21
  return t;
22
22
  }
23
- }, $t = (t) => {
24
- if (!t) return "";
25
- const r = x(t);
26
- return r === "/" ? "" : r;
27
- }, ht = /* @__PURE__ */ new WeakMap();
28
- function Et(t) {
29
- return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
30
- }
31
- function x(t) {
23
+ };
24
+ function C(t) {
32
25
  if (!t) return "/";
33
26
  let r = t.replace(/\/+/g, "/");
34
27
  return r.startsWith("/") || (r = "/" + r), r.length > 1 && r.endsWith("/") && (r = r.slice(0, -1)), r;
35
28
  }
29
+ const Et = (t) => {
30
+ if (!t) return "";
31
+ const r = C(t);
32
+ return r === "/" ? "" : r;
33
+ }, ht = /* @__PURE__ */ new WeakMap();
36
34
  function Ct(t) {
37
- const r = t.path || "/", a = x(r), y = a === "/" ? [] : a.split("/").filter(Boolean), o = [], i = [];
38
- for (let u = 0; u < y.length; u++) {
39
- const f = y[u];
40
- if (f === "*") {
41
- if (u !== y.length - 1)
42
- return g(
35
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36
+ }
37
+ function At(t) {
38
+ const r = t.path || "/", g = C(r), a = g === "/" ? [] : g.split("/").filter(Boolean), i = [], o = [];
39
+ for (let l = 0; l < a.length; l++) {
40
+ const u = a[l];
41
+ if (u === "*") {
42
+ if (l !== a.length - 1)
43
+ return y(
43
44
  `Route '${t.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`
44
45
  ), { invalid: !0 };
45
- const E = `splat${o.length}`;
46
- o.push(E), i.push("__SPLAT__");
46
+ const A = `splat${i.length}`;
47
+ i.push(A), o.push("__SPLAT__");
47
48
  continue;
48
49
  }
49
- const b = f.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
50
- if (b) {
51
- const E = b[1], M = !!b[2];
52
- if (M && u !== y.length - 1)
53
- return g(
54
- `Route '${t.path}' contains a splat param ':${E}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`
50
+ const d = u.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
51
+ if (d) {
52
+ const A = d[1], k = !!d[2];
53
+ if (k && l !== a.length - 1)
54
+ return y(
55
+ `Route '${t.path}' contains a splat param ':${A}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`
55
56
  ), { invalid: !0 };
56
- o.push(E), i.push(M ? "__SPLAT__" : "([^/]+)");
57
+ i.push(A), o.push(k ? "__SPLAT__" : "([^/]+)");
57
58
  continue;
58
59
  }
59
- i.push(Et(f));
60
+ o.push(Ct(u));
60
61
  }
61
- let l;
62
- if (i.length === 0)
63
- l = "^/$";
64
- else if (i[i.length - 1] === "__SPLAT__") {
65
- const f = i.slice(0, -1).join("/");
66
- f ? l = `^/${f}(?:/(.*))?(?:/)?$` : l = "^(?:/(.*))?(?:/)?$";
62
+ let b;
63
+ if (o.length === 0)
64
+ b = "^/$";
65
+ else if (o[o.length - 1] === "__SPLAT__") {
66
+ const u = o.slice(0, -1).join("/");
67
+ u ? b = `^/${u}(?:/(.*))?(?:/)?$` : b = "^(?:/(.*))?(?:/)?$";
67
68
  } else
68
- l = `^/${i.join("/")}(?:/)?$`;
69
+ b = `^/${o.join("/")}(?:/)?$`;
69
70
  try {
70
- return { regex: new RegExp(l), paramNames: o };
71
- } catch (u) {
72
- return g(`Failed to compile route regex for '${t.path}': ${String(u)}`), { invalid: !0 };
71
+ return { regex: new RegExp(b), paramNames: i };
72
+ } catch (l) {
73
+ return y(`Failed to compile route regex for '${t.path}': ${String(l)}`), { invalid: !0 };
73
74
  }
74
75
  }
75
- const Z = (t, r) => {
76
- const a = x(r);
77
- for (const y of t) {
78
- let o = ht.get(y);
79
- if (o || (o = Ct(y), ht.set(y, o)), o.invalid) continue;
80
- const { regex: i, paramNames: l } = o, u = i.exec(a);
81
- if (u) {
82
- const f = {};
83
- for (let b = 0; b < l.length; b++) {
84
- const E = u[b + 1] || "";
85
- f[l[b]] = E ? Rt(E) : "";
76
+ const Q = (t, r) => {
77
+ const g = C(r);
78
+ for (const a of t) {
79
+ let i = ht.get(a);
80
+ if (i || (i = At(a), ht.set(a, i)), i.invalid) continue;
81
+ const { regex: o, paramNames: b } = i, l = o.exec(g);
82
+ if (l) {
83
+ const u = {};
84
+ for (let d = 0; d < b.length; d++) {
85
+ const A = l[d + 1] || "";
86
+ u[b[d]] = A ? $t(A) : "";
86
87
  }
87
- return { route: y, params: f };
88
+ return { route: a, params: u };
88
89
  }
89
90
  }
90
91
  return { route: null, params: {} };
91
92
  };
92
- function tt(t, r) {
93
- for (const a of t)
94
- if (Z([a], r).route !== null) return a;
93
+ function et(t, r) {
94
+ for (const g of t)
95
+ if (Q([g], r).route !== null) return g;
95
96
  return null;
96
97
  }
98
+ function Lt(t, r) {
99
+ return Q(t, r);
100
+ }
97
101
  const pt = 50;
98
- let Q = {}, W = {};
102
+ let J = {}, U = {};
99
103
  function xt() {
100
- Q = {}, W = {};
104
+ J = {}, U = {};
101
105
  }
102
- function At() {
103
- const t = Object.entries(Q);
106
+ function kt() {
107
+ const t = Object.entries(J);
104
108
  if (t.length <= pt) return;
105
- const a = t.sort(
106
- ([, y], [, o]) => y.lastAccessed - o.lastAccessed
109
+ const g = t.sort(
110
+ ([, a], [, i]) => a.lastAccessed - i.lastAccessed
107
111
  ).slice(
108
112
  0,
109
113
  t.length - pt
110
114
  );
111
- for (const [y] of a)
112
- delete Q[y];
115
+ for (const [a] of g)
116
+ delete J[a];
113
117
  }
114
- async function kt(t) {
118
+ async function Pt(t) {
115
119
  if (t.component) return t.component;
116
120
  if (t.load) {
117
- const r = Q[t.path];
121
+ const r = J[t.path];
118
122
  if (r)
119
123
  return r.lastAccessed = Date.now(), r.component;
120
- if (W[t.path] !== void 0)
121
- return W[t.path];
122
- const a = typeof window > "u";
124
+ if (U[t.path] !== void 0)
125
+ return U[t.path];
126
+ const g = typeof window > "u";
123
127
  try {
124
- const y = t.load().then((o) => {
125
- At();
126
- const i = o.default;
127
- return Q[t.path] = {
128
- component: i,
128
+ const a = t.load().then((i) => {
129
+ kt();
130
+ const o = i.default;
131
+ return J[t.path] = {
132
+ component: o,
129
133
  lastAccessed: Date.now()
130
- }, delete W[t.path], i;
131
- }).catch((o) => {
132
- delete W[t.path];
133
- const i = o instanceof Error ? o.message : String(o);
134
- throw a && I(
135
- `SSR component load failed for route: ${t.path}. ${i}`
134
+ }, delete U[t.path], o;
135
+ }).catch((i) => {
136
+ delete U[t.path];
137
+ const o = i instanceof Error ? i.message : String(i);
138
+ throw g && I(
139
+ `SSR component load failed for route: ${t.path}. ${o}`
136
140
  ), new Error(
137
- `Failed to load component for route: ${t.path}. ${i}`
141
+ `Failed to load component for route: ${t.path}. ${o}`
138
142
  );
139
143
  });
140
- return W[t.path] = y, await y;
141
- } catch (y) {
142
- const o = y instanceof Error ? y.message : String(y);
144
+ return U[t.path] = a, await a;
145
+ } catch (a) {
146
+ const i = a instanceof Error ? a.message : String(a);
143
147
  throw new Error(
144
- `Failed to load component for route: ${t.path}. ${o}`
148
+ `Failed to load component for route: ${t.path}. ${i}`,
149
+ { cause: a }
145
150
  );
146
151
  }
147
152
  }
148
153
  throw new Error(`No component or loader defined for route: ${t.path}`);
149
154
  }
150
- function Pt(t) {
151
- const { routes: r, base: a = "", initialUrl: y, scrollToFragment: o = !0 } = t, i = $t(a), l = typeof o == "boolean" ? { ...ut, enabled: o } : { ...ut, ...o };
152
- let u, f, b, E, M, B, K;
153
- const q = /* @__PURE__ */ new Set(), F = 10;
155
+ let v = null;
156
+ function _t(t) {
157
+ v = t;
158
+ }
159
+ function dt() {
160
+ return v;
161
+ }
162
+ const W = /* @__PURE__ */ new Set();
163
+ let D = null;
164
+ function gt() {
165
+ if (D) {
166
+ try {
167
+ D();
168
+ } catch {
169
+ }
170
+ D = null;
171
+ }
172
+ if (v)
173
+ try {
174
+ let t = !1;
175
+ D = v.subscribe((r) => {
176
+ t = !0;
177
+ for (const g of W)
178
+ try {
179
+ g(r);
180
+ } catch {
181
+ }
182
+ });
183
+ try {
184
+ E.base = v.base;
185
+ } catch {
186
+ }
187
+ if (t) {
188
+ const r = v.getCurrent();
189
+ for (const g of W)
190
+ try {
191
+ g(r);
192
+ } catch {
193
+ }
194
+ } else {
195
+ const r = v.getCurrent();
196
+ for (const g of W)
197
+ try {
198
+ g(r);
199
+ } catch {
200
+ }
201
+ }
202
+ try {
203
+ typeof window < "u" && rt();
204
+ } catch {
205
+ }
206
+ } catch {
207
+ D = null;
208
+ }
209
+ }
210
+ function qt() {
211
+ gt();
212
+ }
213
+ const E = {
214
+ store: {
215
+ subscribe(t) {
216
+ if (v) return v.store.subscribe(t);
217
+ try {
218
+ t({ path: "/", params: {}, query: {} });
219
+ } catch {
220
+ }
221
+ return () => {
222
+ };
223
+ },
224
+ getState() {
225
+ return v ? v.getCurrent() : { path: "/", params: {}, query: {} };
226
+ },
227
+ setState(t) {
228
+ if (v)
229
+ try {
230
+ v.store.setState(
231
+ t
232
+ );
233
+ } catch {
234
+ }
235
+ }
236
+ },
237
+ subscribe(t) {
238
+ if (typeof t != "function")
239
+ return y("activeRouterProxy.subscribe: listener must be a function"), () => {
240
+ };
241
+ if (W.add(t), v)
242
+ if (!D)
243
+ gt();
244
+ else
245
+ try {
246
+ const r = v.getCurrent();
247
+ r && t(r);
248
+ } catch (r) {
249
+ y("activeRouterProxy subscription failed", r);
250
+ }
251
+ else
252
+ try {
253
+ t({ path: "/", params: {}, query: {} });
254
+ } catch (r) {
255
+ y("activeRouterProxy fallback state delivery failed", r);
256
+ }
257
+ return () => {
258
+ try {
259
+ if (W.delete(t), W.size === 0 && D) {
260
+ try {
261
+ D();
262
+ } catch (r) {
263
+ y("activeRouterProxy inner unsubscribe failed", r);
264
+ }
265
+ D = null;
266
+ }
267
+ } catch (r) {
268
+ y("activeRouterProxy unsubscribe failed", r);
269
+ }
270
+ };
271
+ },
272
+ getCurrent() {
273
+ return v ? v.getCurrent() : { path: "/", params: {}, query: {} };
274
+ },
275
+ async push(t) {
276
+ return v ? v.push(t) : Promise.resolve();
277
+ },
278
+ async replace(t) {
279
+ return v ? v.replace(t) : Promise.resolve();
280
+ },
281
+ back() {
282
+ if (v)
283
+ return v.back();
284
+ },
285
+ matchRoute(t) {
286
+ return v ? v.matchRoute(t) : { route: null, params: {} };
287
+ },
288
+ resolveRouteComponent(t) {
289
+ return v ? v.resolveRouteComponent(t) : Promise.reject(new Error("No active router"));
290
+ },
291
+ base: "",
292
+ scrollToFragment(t) {
293
+ return v ? v.scrollToFragment(t) : Promise.resolve(!1);
294
+ }
295
+ };
296
+ function Tt(t) {
297
+ const { routes: r, base: g = "", initialUrl: a, scrollToFragment: i = !0 } = t, o = Et(g), b = typeof i == "boolean" ? { ...ut, enabled: i } : { ...ut, ...i };
298
+ let l, u, d, A, k, L, j;
299
+ const _ = /* @__PURE__ */ new Set(), B = 10;
154
300
  let P = 0;
155
- const J = async (s, c) => {
156
- const e = tt(r, s.path);
301
+ const X = async (s, c) => {
302
+ const e = et(r, s.path);
157
303
  if (!e || !e.beforeEnter) return !0;
158
304
  try {
159
305
  const n = await e.beforeEnter(s, c);
160
306
  if (typeof n == "string") {
161
- const d = `${s.path}->${n}`;
162
- return q.has(d) || P >= F ? (I(`Redirect loop detected: ${d}`), !1) : n;
307
+ const p = `${s.path}->${n}`;
308
+ return _.has(p) || P >= B ? (I(`Redirect loop detected: ${p}`), !1) : n;
163
309
  }
164
310
  return n !== !1;
165
311
  } catch (n) {
166
312
  I("beforeEnter error", n);
167
313
  try {
168
- b.setState(c);
314
+ d.setState(c);
169
315
  } catch {
170
316
  }
171
317
  throw n;
172
318
  }
173
- }, rt = async (s, c) => {
174
- const e = tt(r, s.path);
319
+ }, G = async (s, c) => {
320
+ const e = et(r, s.path);
175
321
  if (!e || !e.onEnter) return !0;
176
322
  try {
177
323
  const n = await e.onEnter(s, c);
178
324
  if (typeof n == "string") {
179
- const d = `${s.path}->${n}`;
180
- return q.has(d) || P >= F ? (I(`Redirect loop detected: ${d}`), !1) : n;
325
+ const p = `${s.path}->${n}`;
326
+ return _.has(p) || P >= B ? (I(`Redirect loop detected: ${p}`), !1) : n;
181
327
  }
182
328
  return n !== !1;
183
329
  } catch (n) {
184
330
  I("onEnter error", n);
185
331
  try {
186
- b.setState(c);
332
+ d.setState(c);
187
333
  } catch {
188
334
  }
189
335
  throw n;
190
336
  }
191
- }, X = (s, c) => {
192
- const e = tt(r, s.path);
337
+ }, nt = (s, c) => {
338
+ const e = et(r, s.path);
193
339
  if (!(!e || !e.afterEnter))
194
340
  try {
195
341
  e.afterEnter(s, c);
196
342
  } catch (n) {
197
343
  I("afterEnter error", n);
198
344
  }
199
- }, k = /* @__PURE__ */ new Map(), U = 100, O = (s) => {
200
- if (k.has(s))
201
- return k.get(s);
202
- const c = Z(r, s);
203
- if (k.size >= U) {
204
- const e = Math.floor(U * 0.25), n = Array.from(k.keys());
205
- for (let d = 0; d < e && d < n.length; d++)
206
- k.delete(n[d]);
345
+ }, z = /* @__PURE__ */ new Map(), M = 100, O = (s) => {
346
+ if (z.has(s))
347
+ return z.get(s);
348
+ const c = Q(r, s);
349
+ if (z.size >= M) {
350
+ const e = Math.floor(M * 0.25), n = Array.from(z.keys());
351
+ for (let p = 0; p < e && p < n.length; p++)
352
+ z.delete(n[p]);
207
353
  }
208
- return k.set(s, c), c;
209
- }, G = () => {
354
+ return z.set(s, c), c;
355
+ }, Y = () => {
210
356
  };
211
- async function p(s, c = 0) {
357
+ async function K(s, c = 0) {
212
358
  try {
213
359
  const e = document.getElementById(s);
214
360
  if (!e)
215
361
  return !1;
216
362
  if (c > 0)
217
363
  try {
218
- const n = e.getBoundingClientRect(), d = Math.max(0, window.scrollY + n.top - c);
219
- typeof window.scrollTo == "function" && window.scrollTo({ top: d, behavior: "auto" });
364
+ const n = e.getBoundingClientRect(), p = Math.max(0, window.scrollY + n.top - c);
365
+ typeof window.scrollTo == "function" && window.scrollTo({ top: p, behavior: "auto" });
220
366
  } catch {
221
367
  try {
222
368
  e.scrollIntoView();
@@ -243,95 +389,95 @@ function Pt(t) {
243
389
  return !1;
244
390
  }
245
391
  }
246
- function $(s, c = 0, e = 2e3) {
392
+ function h(s, c = 0, e = 2e3) {
247
393
  return new Promise((n) => {
248
- let d = !1, v = null;
249
- const w = Date.now(), S = (A) => {
250
- d || (d = !0, v && clearTimeout(v), n(A));
251
- }, R = async () => {
252
- if (!d)
394
+ let p = !1, m = null;
395
+ const w = Date.now(), S = (x) => {
396
+ p || (p = !0, m && clearTimeout(m), n(x));
397
+ }, $ = async () => {
398
+ if (!p)
253
399
  try {
254
- if (await p(s, c))
400
+ if (await K(s, c))
255
401
  return S(!0);
256
- const A = async () => {
257
- if (d) return;
402
+ const x = async () => {
403
+ if (p) return;
258
404
  if (Date.now() - w >= e)
259
405
  return S(!1);
260
406
  try {
261
- if (await p(s, c))
407
+ if (await K(s, c))
262
408
  return S(!0);
263
- requestAnimationFrame(A);
264
- } catch (gt) {
265
- g("Scroll retry attempt failed:", gt), requestAnimationFrame(A);
409
+ requestAnimationFrame(x);
410
+ } catch (vt) {
411
+ y("Scroll retry attempt failed:", vt), requestAnimationFrame(x);
266
412
  }
267
413
  };
268
- requestAnimationFrame(A);
269
- } catch (A) {
270
- g("Initial scroll attempt failed:", A), S(!1);
414
+ requestAnimationFrame(x);
415
+ } catch (x) {
416
+ y("Initial scroll attempt failed:", x), S(!1);
271
417
  }
272
418
  };
273
- v = setTimeout(() => {
419
+ m = setTimeout(() => {
274
420
  S(!1);
275
- }, e), R().catch((A) => {
276
- g("Scroll attempt failed:", A), S(!1);
421
+ }, e), $().catch((x) => {
422
+ y("Scroll attempt failed:", x), S(!1);
277
423
  });
278
424
  });
279
425
  }
280
- let h = !1;
281
- const _ = async (s, c = !1) => {
282
- if (h) {
283
- g(`Navigation to ${s} blocked - navigation already in progress`);
426
+ let R = !1;
427
+ const f = async (s, c = !1) => {
428
+ if (R) {
429
+ y(`Navigation to ${s} blocked - navigation already in progress`);
284
430
  return;
285
431
  }
286
- h = !0, P = 0, q.clear();
432
+ R = !0, P = 0, _.clear();
287
433
  try {
288
- await D(s, c);
434
+ await N(s, c);
289
435
  } finally {
290
- h = !1, P = 0, q.clear();
436
+ R = !1, P = 0, _.clear();
291
437
  }
292
- }, N = (s) => {
293
- const c = s.indexOf("#"), e = c >= 0 ? s.slice(c + 1) : "", n = c >= 0 ? s.slice(0, c) : s, d = n.indexOf("?"), v = d >= 0 ? n.slice(0, d) : n, w = d >= 0 ? at(n.slice(d)) : {}, S = v.startsWith(i) ? v.slice(i.length) : v;
438
+ }, q = (s) => {
439
+ const c = s.indexOf("#"), e = c >= 0 ? s.slice(c + 1) : "", n = c >= 0 ? s.slice(0, c) : s, p = n.indexOf("?"), m = p >= 0 ? n.slice(0, p) : n, w = p >= 0 ? at(n.slice(p)) : {}, S = m.startsWith(o) ? m.slice(o.length) : m;
294
440
  return {
295
- path: x(S || "/"),
441
+ path: C(S || "/"),
296
442
  query: w,
297
443
  fragment: e
298
444
  };
299
- }, D = async (s, c = !1) => {
445
+ }, N = async (s, c = !1) => {
300
446
  try {
301
- const e = N(s), n = O(e.path);
447
+ const e = q(s), n = O(e.path);
302
448
  if (!n.route) throw new Error(`No route found for ${e.path}`);
303
- const d = b.getState(), v = {
449
+ const p = d.getState(), m = {
304
450
  path: e.path,
305
451
  params: n.params,
306
452
  query: e.query,
307
453
  fragment: e.fragment
308
- }, w = await J(v, d);
454
+ }, w = await X(m, p);
309
455
  if (w === !1) return;
310
456
  if (typeof w == "string") {
311
457
  P++;
312
- const R = `${v.path}->${w}`;
313
- q.add(R), await D(w, !0);
458
+ const $ = `${m.path}->${w}`;
459
+ _.add($), await N(w, !0);
314
460
  return;
315
461
  }
316
- const S = await rt(v, d);
462
+ const S = await G(m, p);
317
463
  if (S === !1) return;
318
464
  if (typeof S == "string") {
319
465
  P++;
320
- const R = `${v.path}->${S}`;
321
- q.add(R), await D(S, !0);
466
+ const $ = `${m.path}->${S}`;
467
+ _.add($), await N(S, !0);
322
468
  return;
323
469
  }
324
470
  if (typeof window < "u" && typeof document < "u") {
325
- const R = St(e.query), A = i + e.path + (R || "") + (e.fragment ? "#" + e.fragment : "");
326
- c ? window.history.replaceState({}, "", A) : window.history.pushState({}, "", A);
471
+ const $ = Rt(e.query), x = o + e.path + ($ || "") + (e.fragment ? "#" + e.fragment : "");
472
+ c ? window.history.replaceState({}, "", x) : window.history.pushState({}, "", x);
327
473
  }
328
- if (b.setState(v), X(v, d), typeof window < "u" && typeof document < "u")
474
+ if (d.setState(m), nt(m, p), typeof window < "u" && typeof document < "u")
329
475
  try {
330
- const R = v.fragment;
331
- l.enabled && R && $(
332
- String(R),
333
- l.offset,
334
- l.timeoutMs
476
+ const $ = m.fragment;
477
+ b.enabled && $ && h(
478
+ String($),
479
+ b.offset,
480
+ b.timeoutMs
335
481
  ).catch(() => {
336
482
  });
337
483
  } catch {
@@ -340,15 +486,15 @@ function Pt(t) {
340
486
  if (I("Navigation error:", e), e instanceof Error && (e.stack?.includes("runBeforeEnter") || e.stack?.includes("runOnEnter")))
341
487
  throw e;
342
488
  try {
343
- const n = b.getState();
344
- if (!Z(r, n.path).route) {
345
- let v = r.find((w) => w.path === "/");
346
- if (v || (v = r.find(
489
+ const n = d.getState();
490
+ if (!Q(r, n.path).route) {
491
+ let m = r.find((w) => w.path === "/");
492
+ if (m || (m = r.find(
347
493
  (w) => !w.path.includes(":") && !w.path.includes("*")
348
- )), !v && r.length > 0 && (v = r[0]), v) {
349
- const w = Z(r, v.path);
350
- b.setState({
351
- path: v.path,
494
+ )), !m && r.length > 0 && (m = r[0]), m) {
495
+ const w = Q(r, m.path);
496
+ d.setState({
497
+ path: m.path,
352
498
  params: w.params,
353
499
  query: {}
354
500
  });
@@ -356,7 +502,7 @@ function Pt(t) {
356
502
  I("No fallback route available for error recovery");
357
503
  }
358
504
  } catch (n) {
359
- g(
505
+ y(
360
506
  "State recovery failed during navigation error:",
361
507
  n
362
508
  );
@@ -370,274 +516,139 @@ function Pt(t) {
370
516
  for (const e of s) {
371
517
  if (!e.path)
372
518
  return I("Router configuration error: Route missing path", e), !1;
373
- c.has(e.path) && g(`Duplicate route path detected: ${e.path}`), c.add(e.path), !e.component && !e.load && g(`Route '${e.path}' has no component or load function`);
519
+ c.has(e.path) && y(`Duplicate route path detected: ${e.path}`), c.add(e.path), !e.component && !e.load && y(`Route '${e.path}' has no component or load function`);
374
520
  }
375
521
  return !0;
376
- })(r), typeof window > "u" || typeof y < "u") {
522
+ })(r), typeof window > "u" || typeof a < "u") {
377
523
  for (const s of r)
378
524
  O(s.path);
379
- g(`Pre-compiled ${r.length} routes for SSR`);
525
+ y(`Pre-compiled ${r.length} routes for SSR`);
380
526
  }
381
- if (typeof window < "u" && typeof document < "u" && typeof y > "u") {
382
- u = () => {
527
+ if (typeof window < "u" && typeof document < "u" && typeof a > "u") {
528
+ l = () => {
383
529
  try {
384
- const e = new URL(window.location.href), n = e.pathname, d = n.startsWith(i) ? n.slice(i.length) : n, v = x(d || "/"), w = at(e.search), S = e.hash && e.hash.length ? e.hash.slice(1) : "";
385
- return { path: v, query: w, fragment: S };
530
+ const e = new URL(window.location.href), n = e.pathname, p = n.startsWith(o) ? n.slice(o.length) : n, m = C(p || "/"), w = at(e.search), S = e.hash && e.hash.length ? e.hash.slice(1) : "";
531
+ return { path: m, query: w, fragment: S };
386
532
  } catch (e) {
387
- return g("Invalid URL detected, falling back to safe defaults", e), { path: "/", query: {}, fragment: "" };
533
+ return y("Invalid URL detected, falling back to safe defaults", e), { path: "/", query: {}, fragment: "" };
388
534
  }
389
- }, f = u();
390
- const s = O(f.path);
391
- b = lt({
392
- path: f.path,
535
+ }, u = l();
536
+ const s = O(u.path);
537
+ d = lt({
538
+ path: u.path,
393
539
  params: s.params,
394
- query: f.query,
395
- fragment: f.fragment
396
- }), E = async (e = !1) => {
397
- const n = u();
398
- await _(n.path, e);
540
+ query: u.query,
541
+ fragment: u.fragment
542
+ }), A = async (e = !1) => {
543
+ const n = l();
544
+ await f(n.path, e);
399
545
  };
400
- const c = () => E(!0);
401
- window.addEventListener("popstate", c), M = (e) => _(e, !1), B = (e) => _(e, !0), K = () => window.history.back();
546
+ const c = () => A(!0);
547
+ window.addEventListener("popstate", c), k = (e) => f(e, !1), L = (e) => f(e, !0), j = () => window.history.back();
402
548
  } else {
403
- u = () => {
549
+ l = () => {
404
550
  try {
405
- const e = new URL(y || "/", "http://localhost"), n = e.pathname, d = n.startsWith(i) ? n.slice(i.length) : n, v = x(d || "/"), w = at(e.search), S = e.hash && e.hash.length ? e.hash.slice(1) : "";
406
- return { path: v, query: w, fragment: S };
551
+ const e = new URL(a || "/", "http://localhost"), n = e.pathname, p = n.startsWith(o) ? n.slice(o.length) : n, m = C(p || "/"), w = at(e.search), S = e.hash && e.hash.length ? e.hash.slice(1) : "";
552
+ return { path: m, query: w, fragment: S };
407
553
  } catch (e) {
408
- return g(
554
+ return y(
409
555
  "Invalid SSR URL detected, falling back to safe defaults",
410
556
  e
411
557
  ), { path: "/", query: {}, fragment: "" };
412
558
  }
413
- }, f = u();
414
- const s = O(f.path);
415
- b = lt({
416
- path: f.path,
559
+ }, u = l();
560
+ const s = O(u.path);
561
+ d = lt({
562
+ path: u.path,
417
563
  params: s.params,
418
- query: f.query,
419
- fragment: f.fragment
420
- }), E = async () => {
421
- const e = u();
564
+ query: u.query,
565
+ fragment: u.fragment
566
+ }), A = async () => {
567
+ const e = l();
422
568
  await c(e.path);
423
569
  };
424
570
  const c = async (e) => {
425
- if (P++, P > F) {
571
+ if (P++, P > B) {
426
572
  I(`SSR redirect depth exceeded for path: ${e}`);
427
573
  return;
428
574
  }
429
575
  try {
430
- const n = N(e), d = O(n.path);
431
- if (!d.route) throw new Error(`No route found for ${n.path}`);
432
- const v = b.getState(), w = {
576
+ const n = q(e), p = O(n.path);
577
+ if (!p.route) throw new Error(`No route found for ${n.path}`);
578
+ const m = d.getState(), w = {
433
579
  path: n.path,
434
- params: d.params,
580
+ params: p.params,
435
581
  query: n.query,
436
582
  fragment: n.fragment
437
- }, S = tt(r, w.path);
583
+ }, S = et(r, w.path);
438
584
  if (S?.beforeEnter) {
439
- const R = await S.beforeEnter(w, v);
440
- if (typeof R == "string") {
441
- const A = `${w.path}->${R}`;
442
- q.add(A), await c(R);
585
+ const $ = await S.beforeEnter(w, m);
586
+ if (typeof $ == "string") {
587
+ const x = `${w.path}->${$}`;
588
+ _.add(x), await c($);
443
589
  return;
444
590
  }
445
- if (R === !1) return;
591
+ if ($ === !1) return;
446
592
  }
447
593
  if (S?.onEnter) {
448
- const R = await S.onEnter(w, v);
449
- if (typeof R == "string") {
450
- const A = `${w.path}->${R}`;
451
- q.add(A), await c(R);
594
+ const $ = await S.onEnter(w, m);
595
+ if (typeof $ == "string") {
596
+ const x = `${w.path}->${$}`;
597
+ _.add(x), await c($);
452
598
  return;
453
599
  }
454
- if (R === !1) return;
600
+ if ($ === !1) return;
455
601
  }
456
- b.setState(w), S?.afterEnter && S.afterEnter(w, v);
602
+ d.setState(w), S?.afterEnter && S.afterEnter(w, m);
457
603
  } catch (n) {
458
604
  throw I("SSR navigation error:", n), n;
459
605
  }
460
606
  };
461
- M = async (e) => (P = 0, q.clear(), c(e)), B = async (e) => (P = 0, q.clear(), c(e)), K = () => {
607
+ k = async (e) => (P = 0, _.clear(), c(e)), L = async (e) => (P = 0, _.clear(), c(e)), j = () => {
462
608
  };
463
609
  }
464
610
  return {
465
- _cleanupScrollState: G,
466
- store: b,
467
- push: M,
468
- replace: B,
469
- back: K,
470
- subscribe: b.subscribe,
611
+ _cleanupScrollState: Y,
612
+ store: d,
613
+ push: k,
614
+ replace: L,
615
+ back: j,
616
+ subscribe: d.subscribe,
471
617
  matchRoute: (s) => O(s),
472
- getCurrent: () => b.getState(),
473
- resolveRouteComponent: kt,
474
- base: i,
618
+ getCurrent: () => d.getState(),
619
+ resolveRouteComponent: Pt,
620
+ base: o,
475
621
  // Public API: allow components or tests to explicitly request scrolling to
476
622
  // a fragment when they know their DOM is ready. Returns true if scrolled.
477
623
  scrollToFragment: (s) => {
478
- const c = s || b.getState().fragment;
479
- return !c || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : $(
624
+ const c = s || d.getState().fragment;
625
+ return !c || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : h(
480
626
  c,
481
- l.offset,
482
- l.timeoutMs
627
+ b.offset,
628
+ b.timeoutMs
483
629
  );
484
630
  }
485
631
  };
486
632
  }
487
- function Nt(t, r) {
488
- return Z(t, r);
489
- }
490
- let m = null;
491
- const j = /* @__PURE__ */ new Set();
492
- let z = null;
493
- function mt() {
494
- if (z) {
495
- try {
496
- z();
497
- } catch {
498
- }
499
- z = null;
500
- }
501
- if (m)
502
- try {
503
- let t = !1;
504
- z = m.subscribe((r) => {
505
- t = !0;
506
- for (const a of j)
507
- try {
508
- a(r);
509
- } catch {
510
- }
511
- });
512
- try {
513
- C.base = m.base;
514
- } catch {
515
- }
516
- if (t) {
517
- const r = m.getCurrent();
518
- for (const a of j)
519
- try {
520
- a(r);
521
- } catch {
522
- }
523
- } else {
524
- const r = m.getCurrent();
525
- for (const a of j)
526
- try {
527
- a(r);
528
- } catch {
529
- }
530
- }
531
- try {
532
- typeof window < "u" && et();
533
- } catch {
534
- }
535
- } catch {
536
- z = null;
537
- }
538
- }
539
- const C = {
540
- store: {
541
- subscribe(t) {
542
- if (m) return m.store.subscribe(t);
543
- try {
544
- t({ path: "/", params: {}, query: {} });
545
- } catch {
546
- }
547
- return () => {
548
- };
549
- },
550
- getState() {
551
- return m ? m.getCurrent() : { path: "/", params: {}, query: {} };
552
- },
553
- setState(t) {
554
- if (m)
555
- try {
556
- m.store.setState(
557
- t
558
- );
559
- } catch {
560
- }
561
- }
562
- },
563
- subscribe(t) {
564
- if (typeof t != "function")
565
- return g("activeRouterProxy.subscribe: listener must be a function"), () => {
566
- };
567
- if (j.add(t), m)
568
- if (!z)
569
- mt();
570
- else
571
- try {
572
- const r = m.getCurrent();
573
- r && t(r);
574
- } catch (r) {
575
- g("activeRouterProxy subscription failed", r);
576
- }
577
- else
578
- try {
579
- t({ path: "/", params: {}, query: {} });
580
- } catch (r) {
581
- g("activeRouterProxy fallback state delivery failed", r);
582
- }
583
- return () => {
584
- try {
585
- if (j.delete(t), j.size === 0 && z) {
586
- try {
587
- z();
588
- } catch (r) {
589
- g("activeRouterProxy inner unsubscribe failed", r);
590
- }
591
- z = null;
592
- }
593
- } catch (r) {
594
- g("activeRouterProxy unsubscribe failed", r);
595
- }
596
- };
597
- },
598
- getCurrent() {
599
- return m ? m.getCurrent() : { path: "/", params: {}, query: {} };
600
- },
601
- async push(t) {
602
- return m ? m.push(t) : Promise.resolve();
603
- },
604
- async replace(t) {
605
- return m ? m.replace(t) : Promise.resolve();
606
- },
607
- back() {
608
- if (m)
609
- return m.back();
610
- },
611
- matchRoute(t) {
612
- return m ? m.matchRoute(t) : { route: null, params: {} };
613
- },
614
- resolveRouteComponent(t) {
615
- return m ? m.resolveRouteComponent(t) : Promise.reject(new Error("No active router"));
616
- },
617
- base: "",
618
- scrollToFragment(t) {
619
- return m ? m.scrollToFragment(t) : Promise.resolve(!1);
620
- }
621
- };
622
- function zt(t) {
633
+ function Ft(t) {
623
634
  xt();
624
- const r = Pt(t);
625
- if (m)
635
+ const r = Tt(t), g = dt();
636
+ if (g)
626
637
  try {
627
- m._cleanupScrollState?.();
638
+ g._cleanupScrollState?.();
628
639
  } catch {
629
640
  }
630
- m = r;
641
+ _t(r);
631
642
  try {
632
- mt();
643
+ qt();
633
644
  try {
634
- typeof window < "u" && et();
645
+ typeof window < "u" && rt();
635
646
  } catch {
636
647
  }
637
648
  try {
638
649
  typeof window < "u" && queueMicrotask(() => {
639
650
  try {
640
- et();
651
+ rt();
641
652
  } catch {
642
653
  }
643
654
  });
@@ -646,16 +657,16 @@ function zt(t) {
646
657
  } catch {
647
658
  }
648
659
  return st("router-view", async () => {
649
- if (!m) return L`<div>Router not initialized.</div>`;
650
- const a = Y(C.getCurrent()), y = typeof window > "u";
660
+ if (!dt()) return F`<div>Router not initialized.</div>`;
661
+ const a = tt(E.getCurrent()), i = typeof window > "u";
651
662
  let o;
652
- y || (ct(() => {
663
+ i || (ct(() => {
653
664
  try {
654
- typeof C.subscribe == "function" && (o = C.subscribe((l) => {
665
+ typeof E.subscribe == "function" && (o = E.subscribe((l) => {
655
666
  try {
656
- l && typeof l == "object" && typeof l.path == "string" ? a.value = l : (g("router-view received invalid state", l), a.value = { path: "/", params: {}, query: {} });
667
+ l && typeof l == "object" && typeof l.path == "string" ? a.value = l : (y("router-view received invalid state", l), a.value = { path: "/", params: {}, query: {} });
657
668
  } catch (u) {
658
- g("router-view subscription update failed", u);
669
+ y("router-view subscription update failed", u);
659
670
  try {
660
671
  a.value = { path: "/", params: {}, query: {} };
661
672
  } catch {
@@ -663,36 +674,36 @@ function zt(t) {
663
674
  }
664
675
  }));
665
676
  } catch (l) {
666
- g("router-view subscribe failed", l);
677
+ y("router-view subscribe failed", l);
667
678
  }
668
679
  }), it(() => {
669
680
  if (typeof o == "function") {
670
681
  try {
671
682
  o();
672
683
  } catch (l) {
673
- g("router-view unsubscribe failed", l);
684
+ y("router-view unsubscribe failed", l);
674
685
  }
675
686
  o = void 0;
676
687
  }
677
688
  }));
678
- const i = C.matchRoute(a.value.path);
679
- if (!i || !i.route) return L`<div>Not found</div>`;
689
+ const b = E.matchRoute(a.value.path);
690
+ if (!b || !b.route) return F`<div>Not found</div>`;
680
691
  try {
681
- const u = await C.resolveRouteComponent(
682
- i.route
692
+ const u = await E.resolveRouteComponent(
693
+ b.route
683
694
  );
684
695
  if (typeof u == "string")
685
696
  return { tag: u, props: {}, children: [] };
686
697
  if (typeof u == "function") {
687
- const f = u();
688
- return (f instanceof Promise ? f : Promise.resolve(f)).then((E) => typeof E == "string" ? { tag: E, props: {}, children: [] } : E);
698
+ const d = u();
699
+ return (d instanceof Promise ? d : Promise.resolve(d)).then((k) => typeof k == "string" ? { tag: k, props: {}, children: [] } : k);
689
700
  }
690
- return L`<div>Invalid route component</div>`;
701
+ return F`<div>Invalid route component</div>`;
691
702
  } catch {
692
- return L`<div>Invalid route component</div>`;
703
+ return F`<div>Invalid route component</div>`;
693
704
  }
694
705
  }), st("router-link", () => {
695
- const a = vt({
706
+ const a = bt({
696
707
  to: "",
697
708
  tag: "a",
698
709
  replace: !1,
@@ -705,32 +716,32 @@ function zt(t) {
705
716
  // allow host `class` and `style` attributes to be read via useProps
706
717
  class: "",
707
718
  style: ""
708
- }), y = typeof window > "u", o = Y(C.getCurrent()), i = o.value?.path || "/", l = String(a.to || ""), u = y ? {
709
- isExactActive: dt(
710
- i,
719
+ }), i = typeof window > "u", o = tt(E.getCurrent()), b = o.value?.path || "/", l = String(a.to || ""), u = i ? {
720
+ isExactActive: yt(
721
+ b,
711
722
  l,
712
- C.base
723
+ E.base
713
724
  ),
714
- isActive: yt(
715
- i,
725
+ isActive: mt(
726
+ b,
716
727
  l,
717
- C.base
728
+ E.base
718
729
  ),
719
- isExternal: H(l) || !!a.external
730
+ isExternal: Z(l) || !!a.external
720
731
  } : null;
721
- let f;
722
- bt(() => "a,button{display:inline-block;}");
723
- const b = Y(a.class || ""), E = Y(a.style || "");
724
- if (!y) {
725
- let p = null;
726
- ct(($) => {
732
+ let d;
733
+ wt(() => "a,button{display:inline-block;}");
734
+ const A = tt(a.class || ""), k = tt(a.style || "");
735
+ if (!i) {
736
+ let h = null;
737
+ ct((R) => {
727
738
  try {
728
- if (typeof C.subscribe == "function") {
729
- f = C.subscribe((h) => {
739
+ if (typeof E.subscribe == "function") {
740
+ d = E.subscribe((f) => {
730
741
  try {
731
- h && typeof h == "object" && typeof h.path == "string" ? o.value = h : (g("router-link received invalid state", h), o.value = { path: "/", params: {}, query: {} });
732
- } catch (_) {
733
- g("router-link subscription update failed", _);
742
+ f && typeof f == "object" && typeof f.path == "string" ? o.value = f : (y("router-link received invalid state", f), o.value = { path: "/", params: {}, query: {} });
743
+ } catch (q) {
744
+ y("router-link subscription update failed", q);
734
745
  try {
735
746
  o.value = { path: "/", params: {}, query: {} };
736
747
  } catch {
@@ -738,187 +749,194 @@ function zt(t) {
738
749
  }
739
750
  });
740
751
  try {
741
- const h = C.getCurrent();
742
- h && typeof h.path == "string" && (o.value = h);
743
- } catch (h) {
744
- g("router-link initial state sync failed", h);
752
+ const f = E.getCurrent();
753
+ f && typeof f.path == "string" && (o.value = f);
754
+ } catch (f) {
755
+ y("router-link initial state sync failed", f);
745
756
  }
746
- p = setInterval(() => {
757
+ h = setInterval(() => {
747
758
  try {
748
- const h = C.getCurrent();
749
- h && typeof h.path == "string" && JSON.stringify(o.value) !== JSON.stringify(h) && (o.value = h);
759
+ const f = E.getCurrent();
760
+ f && typeof f.path == "string" && JSON.stringify(o.value) !== JSON.stringify(f) && (o.value = f);
750
761
  } catch {
751
762
  }
752
763
  }, 100);
753
764
  }
754
- } catch (h) {
755
- g("router-link subscribe failed", h);
765
+ } catch (f) {
766
+ y("router-link subscribe failed", f);
756
767
  }
757
768
  try {
758
- const h = $?._host;
759
- if (h instanceof HTMLElement) {
760
- const _ = h.getAttribute("class"), N = h.getAttribute("style");
761
- _ && (b.value = _), N && (E.value = N), _ !== null && h.removeAttribute("class"), N !== null && h.removeAttribute("style");
769
+ const f = R?._host;
770
+ if (f instanceof HTMLElement) {
771
+ const q = f.getAttribute("class"), N = f.getAttribute("style");
772
+ q && (A.value = q), N && (k.value = N), q !== null && f.removeAttribute("class"), N !== null && f.removeAttribute("style");
762
773
  try {
763
- $?._requestRender?.();
774
+ R?._requestRender?.();
764
775
  try {
765
- et();
776
+ rt();
766
777
  } catch {
767
778
  }
768
779
  } catch {
769
780
  }
770
781
  }
771
- } catch (h) {
772
- g("router-link host migration failed", h);
782
+ } catch (f) {
783
+ y("router-link host migration failed", f);
773
784
  }
774
785
  }), it(() => {
775
- if (typeof f == "function")
786
+ if (typeof d == "function")
776
787
  try {
777
- f();
778
- } catch ($) {
779
- g("router-link unsubscribe failed", $);
788
+ d();
789
+ } catch (R) {
790
+ y("router-link unsubscribe failed", R);
780
791
  } finally {
781
- f = void 0;
792
+ d = void 0;
782
793
  }
783
- if (p)
794
+ if (h)
784
795
  try {
785
- clearInterval(p);
786
- } catch ($) {
787
- g("router-link sync interval cleanup failed", $);
796
+ clearInterval(h);
797
+ } catch (R) {
798
+ y("router-link sync interval cleanup failed", R);
788
799
  } finally {
789
- p = null;
800
+ h = null;
790
801
  }
791
802
  });
792
803
  }
793
- const M = T(() => {
794
- if (y && u)
804
+ const L = T(() => {
805
+ if (i && u)
795
806
  return u.isExactActive;
796
807
  try {
797
- const p = C.base ?? "", $ = a.to || "";
798
- return !o.value || typeof o.value.path != "string" ? !1 : dt(o.value.path, $, p);
799
- } catch (p) {
800
- return g("isExactActive computation error", p), !1;
808
+ const h = E.base ?? "", R = a.to || "";
809
+ return !o.value || typeof o.value.path != "string" ? !1 : yt(o.value.path, R, h);
810
+ } catch (h) {
811
+ return y("isExactActive computation error", h), !1;
801
812
  }
802
- }), B = T(() => {
803
- if (y && u)
813
+ }), j = T(() => {
814
+ if (i && u)
804
815
  return u.isActive;
805
816
  try {
806
- const p = C.base ?? "", $ = a.to || "";
807
- return !o.value || typeof o.value.path != "string" ? !1 : a.exact ? M.value : yt(o.value.path, $, p);
808
- } catch (p) {
809
- return g("isActive computation error", p), !1;
817
+ const h = E.base ?? "", R = a.to || "";
818
+ return !o.value || typeof o.value.path != "string" ? !1 : a.exact ? L.value : mt(o.value.path, R, h);
819
+ } catch (h) {
820
+ return y("isActive computation error", h), !1;
810
821
  }
811
- }), K = T(() => {
812
- const p = String(a.to || "");
813
- if (ft(p)) return null;
814
- if (H(p)) return p;
815
- const [$, h] = p.split("#"), [_, N] = ($ || "").split("?"), D = C.base ?? "";
816
- let V = _ || "/";
817
- if (D && D !== "/") {
818
- const nt = x(D), s = x(V);
819
- s.startsWith(nt) ? V = s.slice(nt.length) || "/" : V = s;
822
+ }), _ = T(() => {
823
+ const h = String(a.to || "");
824
+ if (ft(h)) return null;
825
+ if (Z(h)) return h;
826
+ const [R, f] = h.split("#"), [q, N] = (R || "").split("?"), V = E.base ?? "";
827
+ let H = q || "/";
828
+ if (V && V !== "/") {
829
+ const s = C(V), c = C(H);
830
+ c.startsWith(s) ? H = c.slice(s.length) || "/" : H = c;
820
831
  }
821
- const ot = x(V || "/");
822
- return D + ot + (N ? "?" + N : "") + (h ? "#" + h : "");
823
- }), q = T(() => {
824
- const $ = (b && b.value || a.class || "").split(/\s+/).filter(Boolean), h = {};
825
- for (const _ of $) h[_] = !0;
826
- return h;
827
- }), F = T(() => ({
828
- ...q.value,
829
- [a.activeClass || "active"]: B.value,
830
- [a.exactActiveClass || "exact-active"]: M.value
831
- })), P = T(
832
- () => Object.keys(F.value).filter((p) => F.value[p]).join(" ")
833
- ), J = T(() => a.tag || "a"), rt = T(() => J.value === "button"), X = T(
834
- () => M.value ? a.ariaCurrentValue : null
835
- ), k = T(() => !!a.disabled), U = T(() => {
836
- const p = String(a.to || "");
837
- return (H(p) || !!a.external) && J.value === "a";
838
- }), O = T(
839
- () => E && E.value || a.style || ""
840
- ), G = (p) => {
841
- if (p.defaultPrevented || p.button !== 0 || p.metaKey || p.altKey || p.ctrlKey || p.shiftKey)
832
+ const ot = C(H || "/");
833
+ return V + ot + (N ? "?" + N : "") + (f ? "#" + f : "");
834
+ }), B = T(() => {
835
+ const R = (A && A.value || a.class || "").split(/\s+/).filter(Boolean), f = {};
836
+ for (const q of R) f[q] = !0;
837
+ return f;
838
+ }), P = T(() => ({
839
+ ...B.value,
840
+ [a.activeClass || "active"]: j.value,
841
+ [a.exactActiveClass || "exact-active"]: L.value
842
+ })), X = T(
843
+ () => Object.keys(P.value).filter((h) => P.value[h]).join(" ")
844
+ ), G = T(() => a.tag || "a"), nt = T(() => G.value === "button"), z = T(
845
+ () => L.value ? a.ariaCurrentValue : null
846
+ ), M = T(() => !!a.disabled), O = T(() => {
847
+ const h = String(a.to || "");
848
+ return (Z(h) || !!a.external) && G.value === "a";
849
+ }), Y = T(
850
+ () => k && k.value || a.style || ""
851
+ ), K = (h) => {
852
+ if (h.defaultPrevented || h.button !== 0 || h.metaKey || h.altKey || h.ctrlKey || h.shiftKey)
842
853
  return;
843
- if (k.value) {
844
- p.preventDefault();
854
+ if (M.value) {
855
+ h.preventDefault();
845
856
  return;
846
857
  }
847
- const $ = String(a.to || "");
848
- if (ft($)) {
858
+ const R = String(a.to || "");
859
+ if (ft(R)) {
849
860
  try {
850
- p.preventDefault();
861
+ h.preventDefault();
851
862
  } catch {
852
863
  }
853
- g("Blocked unsafe javascript: URI in router-link.to");
864
+ y("Blocked unsafe javascript: URI in router-link.to");
854
865
  return;
855
866
  }
856
- U.value || (p.preventDefault(), a.replace ? C.replace(a.to) : C.push(a.to));
867
+ O.value || (h.preventDefault(), a.replace ? E.replace(a.to) : E.push(a.to));
857
868
  };
858
- return L`
859
- ${wt().when(
860
- rt.value,
861
- L`
869
+ return F`
870
+ ${St().when(
871
+ nt.value,
872
+ F`
862
873
  <button
863
874
  part="button"
864
- class="${P.value}"
865
- style="${O.value || null}"
866
- aria-current="${X.value}"
867
- disabled="${k.value ? "" : null}"
868
- aria-disabled="${k.value ? "true" : null}"
869
- tabindex="${k.value ? "-1" : null}"
870
- @click="${G}"
875
+ class="${X.value}"
876
+ style="${Y.value || null}"
877
+ aria-current="${z.value}"
878
+ disabled="${M.value ? "" : null}"
879
+ aria-disabled="${M.value ? "true" : null}"
880
+ tabindex="${M.value ? "-1" : null}"
881
+ @click="${K}"
871
882
  >
872
883
  <slot></slot>
873
884
  </button>
874
885
  `
875
- ).otherwise(L`
886
+ ).otherwise(F`
876
887
  <a
877
888
  part="link"
878
- href="${k.value ? null : K.value}"
879
- class="${P.value}"
880
- style="${O.value || null}"
881
- aria-current="${X.value}"
882
- aria-disabled="${k.value ? "true" : null}"
883
- tabindex="${k.value ? "-1" : null}"
884
- target="${U.value ? "_blank" : null}"
885
- rel="${U.value ? "noopener noreferrer" : null}"
886
- @click="${G}"
889
+ href="${M.value ? null : _.value}"
890
+ class="${X.value}"
891
+ style="${Y.value || null}"
892
+ aria-current="${z.value}"
893
+ aria-disabled="${M.value ? "true" : null}"
894
+ tabindex="${M.value ? "-1" : null}"
895
+ target="${O.value ? "_blank" : null}"
896
+ rel="${O.value ? "noopener noreferrer" : null}"
897
+ @click="${K}"
887
898
  ><slot></slot
888
899
  ></a>
889
900
  `).done()}
890
901
  `;
891
902
  }), r;
892
903
  }
893
- function dt(t, r, a) {
894
- if (H(r)) return !1;
895
- let o = (r.split("#")[0] || "/").split("?")[0];
896
- if (a && a !== "/") {
897
- const u = x(a), f = x(o);
898
- f.startsWith(u) ? o = f.slice(u.length) || "/" : o = f;
904
+ function yt(t, r, g) {
905
+ if (Z(r)) return !1;
906
+ let i = (r.split("#")[0] || "/").split("?")[0];
907
+ if (g && g !== "/") {
908
+ const l = C(g), u = C(i);
909
+ u.startsWith(l) ? i = u.slice(l.length) || "/" : i = u;
899
910
  }
900
- const i = x(t), l = x(o);
901
- return i === l;
911
+ const o = C(t), b = C(i);
912
+ return o === b;
902
913
  }
903
- function yt(t, r, a) {
904
- if (H(r)) return !1;
905
- let o = (r.split("#")[0] || "/").split("?")[0];
906
- if (a && a !== "/") {
907
- const u = x(a), f = x(o);
908
- f.startsWith(u) ? o = f.slice(u.length) || "/" : o = f;
914
+ function mt(t, r, g) {
915
+ if (Z(r)) return !1;
916
+ let i = (r.split("#")[0] || "/").split("?")[0];
917
+ if (g && g !== "/") {
918
+ const l = C(g), u = C(i);
919
+ u.startsWith(l) ? i = u.slice(l.length) || "/" : i = u;
909
920
  }
910
- const i = x(t), l = x(o);
911
- return l === "/" ? i === "/" : i === l ? !0 : i.startsWith(l.endsWith("/") ? l : l + "/");
921
+ const o = C(t), b = C(i);
922
+ return b === "/" ? o === "/" : o === b ? !0 : o.startsWith(b.endsWith("/") ? b : b + "/");
912
923
  }
913
924
  export {
914
- C as activeRouterProxy,
915
- zt as initRouter,
916
- Z as matchRoute,
917
- Nt as matchRouteSSR,
918
- x as normalizePathForRoute,
925
+ ut as DEFAULT_SCROLL_CONFIG,
926
+ E as activeRouterProxy,
927
+ Et as canonicalizeBase,
928
+ xt as clearComponentCache,
929
+ et as findMatchedRoute,
930
+ Ft as initRouter,
931
+ Z as isAbsoluteUrl,
932
+ ft as isDangerousScheme,
933
+ Q as matchRoute,
934
+ Lt as matchRouteSSR,
935
+ C as normalizePathForRoute,
919
936
  at as parseQuery,
920
- kt as resolveRouteComponent,
921
- St as serializeQuery,
922
- Pt as useRouter
937
+ Pt as resolveRouteComponent,
938
+ $t as safeDecode,
939
+ Rt as serializeQuery,
940
+ Tt as useRouter
923
941
  };
924
942
  //# sourceMappingURL=custom-elements-runtime.router.es.js.map