@jasonshimmy/custom-elements-runtime 3.2.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { r as y, t as x } from "./logger-L25axmB-.js";
2
- import { J as nt, R as T, V as et, _ as bt, h as st, i as wt, m as it, y as St } from "./hooks-_3xP4G2N.js";
3
- import { n as ct, t as U } from "./template-compiler-Cs5axmn4.js";
4
- import { match as Rt } from "./custom-elements-runtime.directives.es.js";
5
- import { createStore as lt } from "./custom-elements-runtime.store.es.js";
6
- var ut = {
1
+ import { r as y, t as k } from "./logger-L25axmB-.js";
2
+ import { J as nt, R as L, V as et, _ as St, h as st, i as it, m as ct, y as Rt } from "./hooks-_3xP4G2N.js";
3
+ import { n as lt, t as U } from "./template-compiler-Cs5axmn4.js";
4
+ import { match as Et } from "./custom-elements-runtime.directives.es.js";
5
+ import { createStore as ut } from "./custom-elements-runtime.store.es.js";
6
+ var ft = {
7
7
  enabled: !0,
8
8
  offset: 0,
9
9
  timeoutMs: 2e3
@@ -14,32 +14,32 @@ var ut = {
14
14
  } catch {
15
15
  return "";
16
16
  }
17
- }, ft = (t) => t ? /^\s*javascript\s*:/i.test(t) : !1, Z = (t) => /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t) || t.startsWith("//"), Et = (t) => {
17
+ }, ht = (t) => t ? /^\s*javascript\s*:/i.test(t) : !1, K = (t) => /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t) || t.startsWith("//"), Ct = (t) => {
18
18
  try {
19
19
  return decodeURIComponent(t);
20
20
  } catch {
21
21
  return t;
22
22
  }
23
23
  };
24
- function E(t) {
24
+ function C(t) {
25
25
  if (!t) return "/";
26
26
  let r = t.replace(/\/+/g, "/");
27
27
  return r.startsWith("/") || (r = "/" + r), r.length > 1 && r.endsWith("/") && (r = r.slice(0, -1)), r;
28
28
  }
29
- var Ct = (t) => {
29
+ var xt = (t) => {
30
30
  if (!t) return "";
31
- const r = E(t);
31
+ const r = C(t);
32
32
  return r === "/" ? "" : r;
33
- }, ht = /* @__PURE__ */ new WeakMap();
34
- function xt(t) {
33
+ }, pt = /* @__PURE__ */ new WeakMap();
34
+ function At(t) {
35
35
  return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36
36
  }
37
- function At(t) {
38
- const r = E(t.path || "/"), f = r === "/" ? [] : r.split("/").filter(Boolean), a = [], i = [];
39
- for (let m = 0; m < f.length; m++) {
40
- const g = f[m];
37
+ function kt(t) {
38
+ const r = C(t.path || "/"), h = r === "/" ? [] : r.split("/").filter(Boolean), a = [], i = [];
39
+ for (let m = 0; m < h.length; m++) {
40
+ const g = h[m];
41
41
  if (g === "*") {
42
- if (m !== f.length - 1)
42
+ if (m !== h.length - 1)
43
43
  return y(`Route '${t.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`), { invalid: !0 };
44
44
  const c = `splat${a.length}`;
45
45
  a.push(c), i.push("__SPLAT__");
@@ -47,13 +47,13 @@ function At(t) {
47
47
  }
48
48
  const v = g.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
49
49
  if (v) {
50
- const c = v[1], S = !!v[2];
51
- if (S && m !== f.length - 1)
50
+ const c = v[1], R = !!v[2];
51
+ if (R && m !== h.length - 1)
52
52
  return y(`Route '${t.path}' contains a splat param ':${c}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`), { invalid: !0 };
53
- a.push(c), i.push(S ? "__SPLAT__" : "([^/]+)");
53
+ a.push(c), i.push(R ? "__SPLAT__" : "([^/]+)");
54
54
  continue;
55
55
  }
56
- i.push(xt(g));
56
+ i.push(At(g));
57
57
  }
58
58
  let o;
59
59
  if (i.length === 0) o = "^/$";
@@ -71,16 +71,16 @@ function At(t) {
71
71
  }
72
72
  }
73
73
  var Q = (t, r) => {
74
- const f = E(r);
74
+ const h = C(r);
75
75
  for (const a of t) {
76
- let i = ht.get(a);
77
- if (i || (i = At(a), ht.set(a, i)), i.invalid) continue;
78
- const { regex: o, paramNames: m } = i, g = o.exec(f);
76
+ let i = pt.get(a);
77
+ if (i || (i = kt(a), pt.set(a, i)), i.invalid) continue;
78
+ const { regex: o, paramNames: m } = i, g = o.exec(h);
79
79
  if (g) {
80
80
  const v = {};
81
81
  for (let c = 0; c < m.length; c++) {
82
- const S = g[c + 1] || "";
83
- v[m[c]] = S ? Et(S) : "";
82
+ const R = g[c + 1] || "";
83
+ v[m[c]] = R ? Ct(R) : "";
84
84
  }
85
85
  return {
86
86
  route: a,
@@ -94,34 +94,34 @@ var Q = (t, r) => {
94
94
  };
95
95
  };
96
96
  function rt(t, r) {
97
- for (const f of t) if (Q([f], r).route !== null) return f;
97
+ for (const h of t) if (Q([h], r).route !== null) return h;
98
98
  return null;
99
99
  }
100
100
  function Ft(t, r) {
101
- const f = r.split("?")[0].split("#")[0];
102
- return Q(t, f);
101
+ const h = r.split("?")[0].split("#")[0];
102
+ return Q(t, h);
103
103
  }
104
- var pt = 50, J = {}, B = {};
105
- function kt() {
104
+ var dt = 50, J = {}, B = {};
105
+ function Pt() {
106
106
  J = {}, B = {};
107
107
  }
108
- function Pt() {
108
+ function _t() {
109
109
  const t = Object.entries(J);
110
- if (t.length <= pt) return;
111
- const r = t.sort(([, f], [, a]) => f.lastAccessed - a.lastAccessed).slice(0, t.length - pt);
112
- for (const [f] of r) delete J[f];
110
+ if (t.length <= dt) return;
111
+ const r = t.sort(([, h], [, a]) => h.lastAccessed - a.lastAccessed).slice(0, t.length - dt);
112
+ for (const [h] of r) delete J[h];
113
113
  }
114
- async function _t(t) {
114
+ async function gt(t) {
115
115
  if (t.component) return t.component;
116
116
  if (t.load) {
117
117
  const r = J[t.path];
118
118
  if (r)
119
119
  return r.lastAccessed = Date.now(), r.component;
120
120
  if (B[t.path] !== void 0) return B[t.path];
121
- const f = typeof window > "u";
121
+ const h = typeof window > "u";
122
122
  try {
123
123
  const a = t.load().then((i) => {
124
- Pt();
124
+ _t();
125
125
  const o = i.default;
126
126
  return J[t.path] = {
127
127
  component: o,
@@ -130,7 +130,7 @@ async function _t(t) {
130
130
  }).catch((i) => {
131
131
  delete B[t.path];
132
132
  const o = i instanceof Error ? i.message : String(i);
133
- throw f && x(`SSR component load failed for route: ${t.path}. ${o}`), new Error(`Failed to load component for route: ${t.path}. ${o}`);
133
+ throw h && k(`SSR component load failed for route: ${t.path}. ${o}`), new Error(`Failed to load component for route: ${t.path}. ${o}`);
134
134
  });
135
135
  return B[t.path] = a, await a;
136
136
  } catch (a) {
@@ -144,41 +144,41 @@ var d = null;
144
144
  function qt(t) {
145
145
  d = t;
146
146
  }
147
- function dt() {
147
+ function yt() {
148
148
  return d;
149
149
  }
150
- var K = /* @__PURE__ */ new Set(), O = null;
151
- function vt() {
152
- if (O) {
150
+ var V = /* @__PURE__ */ new Set(), D = null;
151
+ function bt() {
152
+ if (D) {
153
153
  try {
154
- O();
154
+ D();
155
155
  } catch {
156
156
  }
157
- O = null;
157
+ D = null;
158
158
  }
159
159
  if (d) try {
160
160
  let t = !1;
161
- O = d.subscribe((r) => {
161
+ D = d.subscribe((r) => {
162
162
  t = !0;
163
- for (const f of K) try {
164
- f(r);
163
+ for (const h of V) try {
164
+ h(r);
165
165
  } catch {
166
166
  }
167
167
  });
168
168
  try {
169
- A.base = d.base;
169
+ x.base = d.base;
170
170
  } catch {
171
171
  }
172
172
  if (t) {
173
173
  const r = d.getCurrent();
174
- for (const f of K) try {
175
- f(r);
174
+ for (const h of V) try {
175
+ h(r);
176
176
  } catch {
177
177
  }
178
178
  } else {
179
179
  const r = d.getCurrent();
180
- for (const f of K) try {
181
- f(r);
180
+ for (const h of V) try {
181
+ h(r);
182
182
  } catch {
183
183
  }
184
184
  }
@@ -187,13 +187,13 @@ function vt() {
187
187
  } catch {
188
188
  }
189
189
  } catch {
190
- O = null;
190
+ D = null;
191
191
  }
192
192
  }
193
193
  function Tt() {
194
- vt();
194
+ bt();
195
195
  }
196
- var A = {
196
+ var x = {
197
197
  store: {
198
198
  subscribe(t) {
199
199
  if (d) return d.store.subscribe(t);
@@ -227,7 +227,7 @@ var A = {
227
227
  if (typeof t != "function")
228
228
  return y("activeRouterProxy.subscribe: listener must be a function"), () => {
229
229
  };
230
- if (K.add(t), d) if (!O) vt();
230
+ if (V.add(t), d) if (!D) bt();
231
231
  else try {
232
232
  const r = d.getCurrent();
233
233
  r && t(r);
@@ -245,13 +245,13 @@ var A = {
245
245
  }
246
246
  return () => {
247
247
  try {
248
- if (K.delete(t), K.size === 0 && O) {
248
+ if (V.delete(t), V.size === 0 && D) {
249
249
  try {
250
- O();
250
+ D();
251
251
  } catch (r) {
252
252
  y("activeRouterProxy inner unsubscribe failed", r);
253
253
  }
254
- O = null;
254
+ D = null;
255
255
  }
256
256
  } catch (r) {
257
257
  y("activeRouterProxy unsubscribe failed", r);
@@ -293,29 +293,29 @@ var A = {
293
293
  }
294
294
  };
295
295
  function It(t) {
296
- const { routes: r, base: f = "", initialUrl: a, scrollToFragment: i = !0 } = t, o = Ct(f), m = typeof i == "boolean" ? {
297
- ...ut,
296
+ const { routes: r, base: h = "", initialUrl: a, scrollToFragment: i = !0 } = t, o = xt(h), m = typeof i == "boolean" ? {
297
+ ...ft,
298
298
  enabled: i
299
299
  } : {
300
- ...ut,
300
+ ...ft,
301
301
  ...i
302
302
  };
303
- let g, v, c, S, I, z, V, X = () => {
303
+ let g, v, c, R, M, z, H, X = () => {
304
304
  };
305
- const _ = /* @__PURE__ */ new Set(), W = 10;
306
- let k = 0;
305
+ const T = /* @__PURE__ */ new Set(), W = 10;
306
+ let P = 0;
307
307
  const G = async (s, l) => {
308
308
  const e = rt(r, s.path);
309
309
  if (!e || !e.beforeEnter) return !0;
310
310
  try {
311
311
  const n = await e.beforeEnter(s, l);
312
312
  if (typeof n == "string") {
313
- const u = `${s.path}->${n}`;
314
- return _.has(u) || k >= W ? (x(`Redirect loop detected: ${u}`), !1) : n;
313
+ const f = `${s.path}->${n}`;
314
+ return T.has(f) || P >= W ? (k(`Redirect loop detected: ${f}`), !1) : n;
315
315
  }
316
316
  return n !== !1;
317
317
  } catch (n) {
318
- x("beforeEnter error", n);
318
+ k("beforeEnter error", n);
319
319
  try {
320
320
  c.setState(l);
321
321
  } catch {
@@ -328,12 +328,12 @@ function It(t) {
328
328
  try {
329
329
  const n = await e.onEnter(s, l);
330
330
  if (typeof n == "string") {
331
- const u = `${s.path}->${n}`;
332
- return _.has(u) || k >= W ? (x(`Redirect loop detected: ${u}`), !1) : n;
331
+ const f = `${s.path}->${n}`;
332
+ return T.has(f) || P >= W ? (k(`Redirect loop detected: ${f}`), !1) : n;
333
333
  }
334
334
  return n !== !1;
335
335
  } catch (n) {
336
- x("onEnter error", n);
336
+ k("onEnter error", n);
337
337
  try {
338
338
  c.setState(l);
339
339
  } catch {
@@ -345,20 +345,20 @@ function It(t) {
345
345
  if (!(!e || !e.afterEnter))
346
346
  try {
347
347
  const n = e.afterEnter(s, l);
348
- n instanceof Promise && n.catch((u) => {
349
- x("afterEnter async error", u);
348
+ n instanceof Promise && n.catch((f) => {
349
+ k("afterEnter async error", f);
350
350
  });
351
351
  } catch (n) {
352
- x("afterEnter error", n);
352
+ k("afterEnter error", n);
353
353
  }
354
- }, C = /* @__PURE__ */ new Map(), j = 100, M = (s) => {
355
- if (C.has(s)) return C.get(s);
354
+ }, A = /* @__PURE__ */ new Map(), j = 100, N = (s) => {
355
+ if (A.has(s)) return A.get(s);
356
356
  const l = Q(r, s);
357
- if (C.size >= j) {
358
- const e = Math.floor(j * 0.25), n = Array.from(C.keys());
359
- for (let u = 0; u < e && u < n.length; u++) C.delete(n[u]);
357
+ if (A.size >= j) {
358
+ const e = Math.floor(j * 0.25), n = Array.from(A.keys());
359
+ for (let f = 0; f < e && f < n.length; f++) A.delete(n[f]);
360
360
  }
361
- return C.set(s, l), l;
361
+ return A.set(s, l), l;
362
362
  }, tt = () => {
363
363
  };
364
364
  async function p(s, l = 0) {
@@ -366,9 +366,9 @@ function It(t) {
366
366
  const e = document.getElementById(s);
367
367
  if (!e) return !1;
368
368
  if (l > 0) try {
369
- const n = e.getBoundingClientRect(), u = Math.max(0, window.scrollY + n.top - l);
369
+ const n = e.getBoundingClientRect(), f = Math.max(0, window.scrollY + n.top - l);
370
370
  typeof window.scrollTo == "function" && window.scrollTo({
371
- top: u,
371
+ top: f,
372
372
  behavior: "auto"
373
373
  });
374
374
  } catch {
@@ -396,105 +396,105 @@ function It(t) {
396
396
  return !1;
397
397
  }
398
398
  }
399
- function $(s, l = 0, e = 2e3) {
399
+ function w(s, l = 0, e = 2e3) {
400
400
  return new Promise((n) => {
401
- let u = !1, R = null, w = null;
402
- const P = Date.now(), b = (L) => {
403
- u || (u = !0, R && clearTimeout(R), w !== null && cancelAnimationFrame(w), n(L));
401
+ let f = !1, E = null, S = null;
402
+ const q = Date.now(), b = (O) => {
403
+ f || (f = !0, E && clearTimeout(E), S !== null && cancelAnimationFrame(S), n(O));
404
404
  }, F = async () => {
405
- if (!u)
405
+ if (!f)
406
406
  try {
407
407
  if (await p(s, l)) return b(!0);
408
- const L = async () => {
409
- if (!u) {
410
- if (Date.now() - P >= e) return b(!1);
408
+ const O = async () => {
409
+ if (!f) {
410
+ if (Date.now() - q >= e) return b(!1);
411
411
  try {
412
412
  if (await p(s, l)) return b(!0);
413
- w = requestAnimationFrame(L);
414
- } catch (gt) {
415
- y("Scroll retry attempt failed:", gt), w = requestAnimationFrame(L);
413
+ S = requestAnimationFrame(O);
414
+ } catch (wt) {
415
+ y("Scroll retry attempt failed:", wt), S = requestAnimationFrame(O);
416
416
  }
417
417
  }
418
418
  };
419
- w = requestAnimationFrame(L);
420
- } catch (L) {
421
- y("Initial scroll attempt failed:", L), b(!1);
419
+ S = requestAnimationFrame(O);
420
+ } catch (O) {
421
+ y("Initial scroll attempt failed:", O), b(!1);
422
422
  }
423
423
  };
424
- R = setTimeout(() => {
424
+ E = setTimeout(() => {
425
425
  b(!1);
426
- }, e), F().catch((L) => {
427
- y("Scroll attempt failed:", L), b(!1);
426
+ }, e), F().catch((O) => {
427
+ y("Scroll attempt failed:", O), b(!1);
428
428
  });
429
429
  });
430
430
  }
431
- let h = !1;
432
- const q = async (s, l = !1) => {
433
- if (h) {
431
+ let _ = !1;
432
+ const I = async (s, l = !1) => {
433
+ if (_) {
434
434
  y(`Navigation to ${s} blocked - navigation already in progress`);
435
435
  return;
436
436
  }
437
- h = !0, k = 0, _.clear();
437
+ _ = !0, P = 0, T.clear();
438
438
  try {
439
- await D(s, l);
439
+ await $(s, l);
440
440
  } finally {
441
- h = !1, k = 0, _.clear();
441
+ _ = !1, P = 0, T.clear();
442
442
  }
443
- }, N = (s) => {
444
- const l = s.indexOf("#"), e = l >= 0 ? s.slice(l + 1) : "", n = l >= 0 ? s.slice(0, l) : s, u = n.indexOf("?"), R = u >= 0 ? n.slice(0, u) : n, w = u >= 0 ? ot(n.slice(u)) : {};
443
+ }, u = (s) => {
444
+ const l = s.indexOf("#"), e = l >= 0 ? s.slice(l + 1) : "", n = l >= 0 ? s.slice(0, l) : s, f = n.indexOf("?"), E = f >= 0 ? n.slice(0, f) : n, S = f >= 0 ? ot(n.slice(f)) : {};
445
445
  return {
446
- path: E((R.startsWith(o) ? R.slice(o.length) : R) || "/"),
447
- query: w,
446
+ path: C((E.startsWith(o) ? E.slice(o.length) : E) || "/"),
447
+ query: S,
448
448
  fragment: e
449
449
  };
450
- }, D = async (s, l = !1) => {
450
+ }, $ = async (s, l = !1) => {
451
451
  try {
452
- const e = N(s), n = M(e.path);
452
+ const e = u(s), n = N(e.path);
453
453
  if (!n.route) throw new Error(`No route found for ${e.path}`);
454
- const u = c.getState(), R = {
454
+ const f = c.getState(), E = {
455
455
  path: e.path,
456
456
  params: n.params,
457
457
  query: e.query,
458
458
  fragment: e.fragment
459
- }, w = await G(R, u);
460
- if (w === !1) return;
461
- if (typeof w == "string") {
462
- k++;
463
- const b = `${R.path}->${w}`;
464
- _.add(b), await D(w, !0);
459
+ }, S = await G(E, f);
460
+ if (S === !1) return;
461
+ if (typeof S == "string") {
462
+ P++;
463
+ const b = `${E.path}->${S}`;
464
+ T.add(b), await $(S, !0);
465
465
  return;
466
466
  }
467
- const P = await at(R, u);
468
- if (P === !1) return;
469
- if (typeof P == "string") {
470
- k++;
471
- const b = `${R.path}->${P}`;
472
- _.add(b), await D(P, !0);
467
+ const q = await at(E, f);
468
+ if (q === !1) return;
469
+ if (typeof q == "string") {
470
+ P++;
471
+ const b = `${E.path}->${q}`;
472
+ T.add(b), await $(q, !0);
473
473
  return;
474
474
  }
475
475
  if (typeof window < "u" && typeof document < "u") {
476
476
  const b = $t(e.query), F = o + e.path + (b || "") + (e.fragment ? "#" + e.fragment : "");
477
477
  l ? window.history.replaceState({}, "", F) : window.history.pushState({}, "", F);
478
478
  }
479
- if (c.setState(R), Y(R, u), typeof window < "u" && typeof document < "u") try {
480
- const b = R.fragment;
481
- m.enabled && b && $(String(b), m.offset, m.timeoutMs).catch(() => {
479
+ if (c.setState(E), Y(E, f), typeof window < "u" && typeof document < "u") try {
480
+ const b = E.fragment;
481
+ m.enabled && b && w(String(b), m.offset, m.timeoutMs).catch(() => {
482
482
  });
483
483
  } catch {
484
484
  }
485
485
  } catch (e) {
486
- if (x("Navigation error:", e), e instanceof Error && (e.stack?.includes("runBeforeEnter") || e.stack?.includes("runOnEnter"))) throw e;
486
+ if (k("Navigation error:", e), e instanceof Error && (e.stack?.includes("runBeforeEnter") || e.stack?.includes("runOnEnter"))) throw e;
487
487
  try {
488
488
  if (!Q(r, c.getState().path).route) {
489
- let n = r.find((u) => u.path === "/");
490
- if (n || (n = r.find((u) => !u.path.includes(":") && !u.path.includes("*"))), !n && r.length > 0 && (n = r[0]), n) {
491
- const u = Q(r, n.path);
489
+ let n = r.find((f) => f.path === "/");
490
+ if (n || (n = r.find((f) => !f.path.includes(":") && !f.path.includes("*"))), !n && r.length > 0 && (n = r[0]), n) {
491
+ const f = Q(r, n.path);
492
492
  c.setState({
493
493
  path: n.path,
494
- params: u.params,
494
+ params: f.params,
495
495
  query: {}
496
496
  });
497
- } else x("No fallback route available for error recovery");
497
+ } else k("No fallback route available for error recovery");
498
498
  }
499
499
  } catch (n) {
500
500
  y("State recovery failed during navigation error:", n);
@@ -503,16 +503,16 @@ function It(t) {
503
503
  };
504
504
  if (((s) => {
505
505
  if (!s || s.length === 0)
506
- return x("Router configuration error: No routes provided"), !1;
506
+ return k("Router configuration error: No routes provided"), !1;
507
507
  const l = /* @__PURE__ */ new Set();
508
508
  for (const e of s) {
509
509
  if (!e.path)
510
- return x("Router configuration error: Route missing path", e), !1;
510
+ return k("Router configuration error: Route missing path", e), !1;
511
511
  l.has(e.path) && y(`Duplicate route path detected: ${e.path}`), l.add(e.path), !e.component && !e.load && y(`Route '${e.path}' has no component or load function`);
512
512
  }
513
513
  return !0;
514
514
  })(r), typeof window > "u" || typeof a < "u") {
515
- for (const s of r) M(s.path);
515
+ for (const s of r) N(s.path);
516
516
  y(`Pre-compiled ${r.length} routes for SSR`);
517
517
  }
518
518
  if (typeof window < "u" && typeof document < "u" && typeof a > "u") {
@@ -520,7 +520,7 @@ function It(t) {
520
520
  try {
521
521
  const e = new URL(window.location.href), n = e.pathname;
522
522
  return {
523
- path: E((n.startsWith(o) ? n.slice(o.length) : n) || "/"),
523
+ path: C((n.startsWith(o) ? n.slice(o.length) : n) || "/"),
524
524
  query: ot(e.search),
525
525
  fragment: e.hash && e.hash.length ? e.hash.slice(1) : ""
526
526
  };
@@ -532,19 +532,19 @@ function It(t) {
532
532
  };
533
533
  }
534
534
  }, v = g();
535
- const s = M(v.path);
536
- c = lt({
535
+ const s = N(v.path);
536
+ c = ut({
537
537
  path: v.path,
538
538
  params: s.params,
539
539
  query: v.query,
540
540
  fragment: v.fragment
541
- }), S = async (e = !1) => {
542
- await q(g().path, e);
541
+ }), R = async (e = !1) => {
542
+ await I(g().path, e);
543
543
  };
544
- const l = () => S(!0);
545
- window.addEventListener("popstate", l), X = () => window.removeEventListener("popstate", l), I = (e) => q(e, !1), z = (e) => q(e, !0), V = () => window.history.back(), queueMicrotask(() => {
546
- q(v.path, !0).catch((e) => {
547
- x("Initial navigation error:", e);
544
+ const l = () => R(!0);
545
+ window.addEventListener("popstate", l), X = () => window.removeEventListener("popstate", l), M = (e) => I(e, !1), z = (e) => I(e, !0), H = () => window.history.back(), queueMicrotask(() => {
546
+ I(v.path, !0).catch((e) => {
547
+ k("Initial navigation error:", e);
548
548
  });
549
549
  });
550
550
  } else {
@@ -552,7 +552,7 @@ function It(t) {
552
552
  try {
553
553
  const e = new URL(a || "/", "http://localhost"), n = e.pathname;
554
554
  return {
555
- path: E((n.startsWith(o) ? n.slice(o.length) : n) || "/"),
555
+ path: C((n.startsWith(o) ? n.slice(o.length) : n) || "/"),
556
556
  query: ot(e.search),
557
557
  fragment: e.hash && e.hash.length ? e.hash.slice(1) : ""
558
558
  };
@@ -564,83 +564,83 @@ function It(t) {
564
564
  };
565
565
  }
566
566
  }, v = g();
567
- const s = M(v.path);
568
- c = lt({
567
+ const s = N(v.path);
568
+ c = ut({
569
569
  path: v.path,
570
570
  params: s.params,
571
571
  query: v.query,
572
572
  fragment: v.fragment
573
- }), S = async () => {
573
+ }), R = async () => {
574
574
  await l(g().path);
575
575
  };
576
576
  const l = async (e) => {
577
- if (k++, k > W) {
578
- x(`SSR redirect depth exceeded for path: ${e}`);
577
+ if (P++, P > W) {
578
+ k(`SSR redirect depth exceeded for path: ${e}`);
579
579
  return;
580
580
  }
581
581
  try {
582
- const n = N(e), u = M(n.path);
583
- if (!u.route) throw new Error(`No route found for ${n.path}`);
584
- const R = c.getState(), w = {
582
+ const n = u(e), f = N(n.path);
583
+ if (!f.route) throw new Error(`No route found for ${n.path}`);
584
+ const E = c.getState(), S = {
585
585
  path: n.path,
586
- params: u.params,
586
+ params: f.params,
587
587
  query: n.query,
588
588
  fragment: n.fragment
589
- }, P = rt(r, w.path);
590
- if (P?.beforeEnter) {
591
- const b = await P.beforeEnter(w, R);
589
+ }, q = rt(r, S.path);
590
+ if (q?.beforeEnter) {
591
+ const b = await q.beforeEnter(S, E);
592
592
  if (typeof b == "string") {
593
- const F = `${w.path}->${b}`;
594
- _.add(F), await l(b);
593
+ const F = `${S.path}->${b}`;
594
+ T.add(F), await l(b);
595
595
  return;
596
596
  }
597
597
  if (b === !1) return;
598
598
  }
599
- if (P?.onEnter) {
600
- const b = await P.onEnter(w, R);
599
+ if (q?.onEnter) {
600
+ const b = await q.onEnter(S, E);
601
601
  if (typeof b == "string") {
602
- const F = `${w.path}->${b}`;
603
- _.add(F), await l(b);
602
+ const F = `${S.path}->${b}`;
603
+ T.add(F), await l(b);
604
604
  return;
605
605
  }
606
606
  if (b === !1) return;
607
607
  }
608
- c.setState(w), P?.afterEnter && P.afterEnter(w, R);
608
+ c.setState(S), q?.afterEnter && q.afterEnter(S, E);
609
609
  } catch (n) {
610
- throw x("SSR navigation error:", n), n;
610
+ throw k("SSR navigation error:", n), n;
611
611
  }
612
612
  };
613
- I = async (e) => (k = 0, _.clear(), l(e)), z = async (e) => (k = 0, _.clear(), l(e)), V = () => {
613
+ M = async (e) => (P = 0, T.clear(), l(e)), z = async (e) => (P = 0, T.clear(), l(e)), H = () => {
614
614
  };
615
615
  }
616
616
  return {
617
617
  _cleanupScrollState: tt,
618
618
  destroy: X,
619
619
  store: c,
620
- push: I,
620
+ push: M,
621
621
  replace: z,
622
- back: V,
622
+ back: H,
623
623
  subscribe: c.subscribe,
624
- matchRoute: (s) => M(s),
624
+ matchRoute: (s) => N(s),
625
625
  getCurrent: () => c.getState(),
626
- resolveRouteComponent: _t,
626
+ resolveRouteComponent: gt,
627
627
  base: o,
628
628
  scrollToFragment: (s) => {
629
629
  const l = s || c.getState().fragment;
630
- return !l || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : $(l, m.offset, m.timeoutMs);
630
+ return !l || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : w(l, m.offset, m.timeoutMs);
631
631
  }
632
632
  };
633
633
  }
634
634
  function zt(t) {
635
- kt();
636
- const r = It(t), f = dt();
637
- if (f) {
635
+ Pt();
636
+ const r = It(t), h = yt();
637
+ if (h) {
638
638
  try {
639
- f.destroy();
639
+ h.destroy();
640
640
  } catch {
641
641
  }
642
642
  try {
643
- f._cleanupScrollState?.();
643
+ h._cleanupScrollState?.();
644
644
  } catch {
645
645
  }
646
646
  }
@@ -662,12 +662,12 @@ function zt(t) {
662
662
  }
663
663
  } catch {
664
664
  }
665
- return ct("router-view", async () => {
666
- const a = wt()?._router, i = a ?? A;
667
- if (!dt() && !a) return U`<div>Router not initialized.</div>`;
665
+ return lt("router-view", async () => {
666
+ const a = it()?._router, i = a ?? x;
667
+ if (!yt() && !a) return U`<div>Router not initialized.</div>`;
668
668
  const o = et(i.getCurrent()), m = typeof window > "u";
669
669
  let g;
670
- m || (it(() => {
670
+ m || (ct(() => {
671
671
  try {
672
672
  typeof i.subscribe == "function" && (g = i.subscribe((c) => {
673
673
  try {
@@ -676,8 +676,8 @@ function zt(t) {
676
676
  params: {},
677
677
  query: {}
678
678
  });
679
- } catch (S) {
680
- y("router-view subscription update failed", S);
679
+ } catch (R) {
680
+ y("router-view subscription update failed", R);
681
681
  try {
682
682
  o.value = {
683
683
  path: "/",
@@ -711,19 +711,19 @@ function zt(t) {
711
711
  children: []
712
712
  };
713
713
  if (typeof c == "function") {
714
- const S = c();
715
- return (S instanceof Promise ? S : Promise.resolve(S)).then((I) => typeof I == "string" ? {
716
- tag: I,
714
+ const R = c();
715
+ return (R instanceof Promise ? R : Promise.resolve(R)).then((M) => typeof M == "string" ? {
716
+ tag: M,
717
717
  props: {},
718
718
  children: []
719
- } : I);
719
+ } : M);
720
720
  }
721
721
  return U`<div>Invalid route component</div>`;
722
722
  } catch {
723
723
  return U`<div>Invalid route component</div>`;
724
724
  }
725
- }), ct("router-link", () => {
726
- const a = bt({
725
+ }), lt("router-link", () => {
726
+ const a = St({
727
727
  to: "",
728
728
  tag: "a",
729
729
  replace: !1,
@@ -735,28 +735,38 @@ function zt(t) {
735
735
  external: !1,
736
736
  class: "",
737
737
  style: ""
738
- }), i = typeof window > "u", o = et(A.getCurrent()), m = o.value?.path || "/", g = String(a.to || ""), v = i ? {
739
- isExactActive: yt(m, g, A.base),
740
- isActive: mt(m, g, A.base),
741
- isExternal: Z(g) || !!a.external
738
+ }), i = typeof window > "u", o = et(x.getCurrent()), m = o.value?.path || "/", g = String(a.to || ""), v = i ? {
739
+ isExactActive: mt(m, g, x.base),
740
+ isActive: vt(m, g, x.base),
741
+ isExternal: K(g) || !!a.external
742
742
  } : null;
743
743
  let c;
744
- St(() => "a,button{display:inline-block;}");
745
- const S = et(a.class || ""), I = et(a.style || "");
744
+ Rt(() => "a,button{display:inline-block;}");
745
+ const R = et(a.class || ""), M = et(a.style || "");
746
746
  if (!i) {
747
- let p = null;
748
- it(($) => {
747
+ const p = it(), w = p?._host ?? null;
748
+ let _ = null, I = null;
749
+ ct(() => {
750
+ w instanceof HTMLElement && (I = () => {
751
+ const u = String(a.to || "");
752
+ if (u && !K(u)) try {
753
+ const { route: $ } = x.matchRoute(u);
754
+ $?.load && gt($).catch(() => {
755
+ });
756
+ } catch {
757
+ }
758
+ }, w.addEventListener("mouseenter", I, { once: !0 }));
749
759
  try {
750
- if (typeof A.subscribe == "function") {
751
- c = A.subscribe((h) => {
760
+ if (typeof x.subscribe == "function") {
761
+ c = x.subscribe((u) => {
752
762
  try {
753
- h && typeof h == "object" && typeof h.path == "string" ? o.value = h : (y("router-link received invalid state", h), o.value = {
763
+ u && typeof u == "object" && typeof u.path == "string" ? o.value = u : (y("router-link received invalid state", u), o.value = {
754
764
  path: "/",
755
765
  params: {},
756
766
  query: {}
757
767
  });
758
- } catch (q) {
759
- y("router-link subscription update failed", q);
768
+ } catch ($) {
769
+ y("router-link subscription update failed", $);
760
770
  try {
761
771
  o.value = {
762
772
  path: "/",
@@ -768,29 +778,28 @@ function zt(t) {
768
778
  }
769
779
  });
770
780
  try {
771
- const h = A.getCurrent();
772
- h && typeof h.path == "string" && (o.value = h);
773
- } catch (h) {
774
- y("router-link initial state sync failed", h);
781
+ const u = x.getCurrent();
782
+ u && typeof u.path == "string" && (o.value = u);
783
+ } catch (u) {
784
+ y("router-link initial state sync failed", u);
775
785
  }
776
- p = setInterval(() => {
786
+ _ = setInterval(() => {
777
787
  try {
778
- const h = A.getCurrent();
779
- h && typeof h.path == "string" && JSON.stringify(o.value) !== JSON.stringify(h) && (o.value = h);
788
+ const u = x.getCurrent();
789
+ u && typeof u.path == "string" && JSON.stringify(o.value) !== JSON.stringify(u) && (o.value = u);
780
790
  } catch {
781
791
  }
782
792
  }, 100);
783
793
  }
784
- } catch (h) {
785
- y("router-link subscribe failed", h);
794
+ } catch (u) {
795
+ y("router-link subscribe failed", u);
786
796
  }
787
797
  try {
788
- const h = $?._host;
789
- if (typeof HTMLElement < "u" && h instanceof HTMLElement) {
790
- const q = h.getAttribute("class"), N = h.getAttribute("style");
791
- q && (S.value = q), N && (I.value = N), q !== null && h.removeAttribute("class"), N !== null && h.removeAttribute("style");
798
+ if (w instanceof HTMLElement) {
799
+ const u = w.getAttribute("class"), $ = w.getAttribute("style");
800
+ u && (R.value = u), $ && (M.value = $), u !== null && w.removeAttribute("class"), $ !== null && w.removeAttribute("style");
792
801
  try {
793
- $?._requestRender?.();
802
+ p?._requestRender?.();
794
803
  try {
795
804
  nt();
796
805
  } catch {
@@ -798,68 +807,74 @@ function zt(t) {
798
807
  } catch {
799
808
  }
800
809
  }
801
- } catch (h) {
802
- y("router-link host migration failed", h);
810
+ } catch (u) {
811
+ y("router-link host migration failed", u);
803
812
  }
804
813
  }), st(() => {
814
+ if (I && w instanceof HTMLElement) try {
815
+ w.removeEventListener("mouseenter", I);
816
+ } catch {
817
+ } finally {
818
+ I = null;
819
+ }
805
820
  if (typeof c == "function") try {
806
821
  c();
807
- } catch ($) {
808
- y("router-link unsubscribe failed", $);
822
+ } catch (u) {
823
+ y("router-link unsubscribe failed", u);
809
824
  } finally {
810
825
  c = void 0;
811
826
  }
812
- if (p) try {
813
- clearInterval(p);
814
- } catch ($) {
815
- y("router-link sync interval cleanup failed", $);
827
+ if (_) try {
828
+ clearInterval(_);
829
+ } catch (u) {
830
+ y("router-link sync interval cleanup failed", u);
816
831
  } finally {
817
- p = null;
832
+ _ = null;
818
833
  }
819
834
  });
820
835
  }
821
- const z = T(() => {
836
+ const z = L(() => {
822
837
  if (i && v) return v.isExactActive;
823
838
  try {
824
- const p = A.base ?? "", $ = a.to || "";
825
- return !o.value || typeof o.value.path != "string" ? !1 : yt(o.value.path, $, p);
839
+ const p = x.base ?? "", w = a.to || "";
840
+ return !o.value || typeof o.value.path != "string" ? !1 : mt(o.value.path, w, p);
826
841
  } catch (p) {
827
842
  return y("isExactActive computation error", p), !1;
828
843
  }
829
- }), V = T(() => {
844
+ }), H = L(() => {
830
845
  if (i && v) return v.isActive;
831
846
  try {
832
- const p = A.base ?? "", $ = a.to || "";
833
- return !o.value || typeof o.value.path != "string" ? !1 : a.exact ? z.value : mt(o.value.path, $, p);
847
+ const p = x.base ?? "", w = a.to || "";
848
+ return !o.value || typeof o.value.path != "string" ? !1 : a.exact ? z.value : vt(o.value.path, w, p);
834
849
  } catch (p) {
835
850
  return y("isActive computation error", p), !1;
836
851
  }
837
- }), X = T(() => {
852
+ }), X = L(() => {
838
853
  const p = String(a.to || "");
839
- if (ft(p)) return null;
840
- if (Z(p)) return p;
841
- const [$, h] = p.split("#"), [q, N] = ($ || "").split("?"), D = A.base ?? "";
842
- let H = q || "/";
843
- if (D && D !== "/") {
844
- const s = E(D), l = E(H);
845
- l.startsWith(s) ? H = l.slice(s.length) || "/" : H = l;
854
+ if (ht(p)) return null;
855
+ if (K(p)) return p;
856
+ const [w, _] = p.split("#"), [I, u] = (w || "").split("?"), $ = x.base ?? "";
857
+ let Z = I || "/";
858
+ if ($ && $ !== "/") {
859
+ const s = C($), l = C(Z);
860
+ l.startsWith(s) ? Z = l.slice(s.length) || "/" : Z = l;
846
861
  }
847
- return D + E(H || "/") + (N ? "?" + N : "") + (h ? "#" + h : "");
848
- }), _ = T(() => {
849
- const p = (S && S.value || a.class || "").split(/\s+/).filter(Boolean), $ = {};
850
- for (const h of p) $[h] = !0;
851
- return $;
852
- }), W = T(() => ({
853
- ..._.value,
854
- [a.activeClass || "active"]: V.value,
862
+ return $ + C(Z || "/") + (u ? "?" + u : "") + (_ ? "#" + _ : "");
863
+ }), T = L(() => {
864
+ const p = (R && R.value || a.class || "").split(/\s+/).filter(Boolean), w = {};
865
+ for (const _ of p) w[_] = !0;
866
+ return w;
867
+ }), W = L(() => ({
868
+ ...T.value,
869
+ [a.activeClass || "active"]: H.value,
855
870
  [a.exactActiveClass || "exact-active"]: z.value
856
- })), k = T(() => Object.keys(W.value).filter((p) => W.value[p]).join(" ")), G = T(() => a.tag || "a"), at = T(() => G.value === "button"), Y = T(() => z.value ? a.ariaCurrentValue : null), C = T(() => !!a.disabled), j = T(() => (Z(String(a.to || "")) || !!a.external) && G.value === "a"), M = T(() => I && I.value || a.style || ""), tt = (p) => {
871
+ })), P = L(() => Object.keys(W.value).filter((p) => W.value[p]).join(" ")), G = L(() => a.tag || "a"), at = L(() => G.value === "button"), Y = L(() => z.value ? a.ariaCurrentValue : null), A = L(() => !!a.disabled), j = L(() => (K(String(a.to || "")) || !!a.external) && G.value === "a"), N = L(() => M && M.value || a.style || ""), tt = (p) => {
857
872
  if (!(p.defaultPrevented || p.button !== 0 || p.metaKey || p.altKey || p.ctrlKey || p.shiftKey)) {
858
- if (C.value) {
873
+ if (A.value) {
859
874
  p.preventDefault();
860
875
  return;
861
876
  }
862
- if (ft(String(a.to || ""))) {
877
+ if (ht(String(a.to || ""))) {
863
878
  try {
864
879
  p.preventDefault();
865
880
  } catch {
@@ -867,19 +882,19 @@ function zt(t) {
867
882
  y("Blocked unsafe javascript: URI in router-link.to");
868
883
  return;
869
884
  }
870
- j.value || (p.preventDefault(), a.replace ? A.replace(a.to) : A.push(a.to));
885
+ j.value || (p.preventDefault(), a.replace ? x.replace(a.to) : x.push(a.to));
871
886
  }
872
887
  };
873
888
  return U`
874
- ${Rt().when(at.value, U`
889
+ ${Et().when(at.value, U`
875
890
  <button
876
891
  part="button"
877
- class="${k.value}"
878
- style="${M.value || null}"
892
+ class="${P.value}"
893
+ style="${N.value || null}"
879
894
  aria-current="${Y.value}"
880
- disabled="${C.value ? "" : null}"
881
- aria-disabled="${C.value ? "true" : null}"
882
- tabindex="${C.value ? "-1" : null}"
895
+ disabled="${A.value ? "" : null}"
896
+ aria-disabled="${A.value ? "true" : null}"
897
+ tabindex="${A.value ? "-1" : null}"
883
898
  @click="${tt}"
884
899
  >
885
900
  <slot></slot>
@@ -887,12 +902,12 @@ function zt(t) {
887
902
  `).otherwise(U`
888
903
  <a
889
904
  part="link"
890
- href="${C.value ? null : X.value}"
891
- class="${k.value}"
892
- style="${M.value || null}"
905
+ href="${A.value ? null : X.value}"
906
+ class="${P.value}"
907
+ style="${N.value || null}"
893
908
  aria-current="${Y.value}"
894
- aria-disabled="${C.value ? "true" : null}"
895
- tabindex="${C.value ? "-1" : null}"
909
+ aria-disabled="${A.value ? "true" : null}"
910
+ tabindex="${A.value ? "-1" : null}"
896
911
  target="${j.value ? "_blank" : null}"
897
912
  rel="${j.value ? "noopener noreferrer" : null}"
898
913
  @click="${tt}"
@@ -902,40 +917,40 @@ function zt(t) {
902
917
  `;
903
918
  }), r;
904
919
  }
905
- function yt(t, r, f) {
906
- if (Z(r)) return !1;
920
+ function mt(t, r, h) {
921
+ if (K(r)) return !1;
907
922
  let a = (r.split("#")[0] || "/").split("?")[0];
908
- if (f && f !== "/") {
909
- const i = E(f), o = E(a);
923
+ if (h && h !== "/") {
924
+ const i = C(h), o = C(a);
910
925
  o.startsWith(i) ? a = o.slice(i.length) || "/" : a = o;
911
926
  }
912
- return E(t) === E(a);
927
+ return C(t) === C(a);
913
928
  }
914
- function mt(t, r, f) {
915
- if (Z(r)) return !1;
929
+ function vt(t, r, h) {
930
+ if (K(r)) return !1;
916
931
  let a = (r.split("#")[0] || "/").split("?")[0];
917
- if (f && f !== "/") {
918
- const m = E(f), g = E(a);
932
+ if (h && h !== "/") {
933
+ const m = C(h), g = C(a);
919
934
  g.startsWith(m) ? a = g.slice(m.length) || "/" : a = g;
920
935
  }
921
- const i = E(t), o = E(a);
936
+ const i = C(t), o = C(a);
922
937
  return o === "/" ? i === "/" : i === o ? !0 : i.startsWith(o.endsWith("/") ? o : o + "/");
923
938
  }
924
939
  export {
925
- ut as DEFAULT_SCROLL_CONFIG,
926
- A as activeRouterProxy,
927
- Ct as canonicalizeBase,
928
- kt as clearComponentCache,
940
+ ft as DEFAULT_SCROLL_CONFIG,
941
+ x as activeRouterProxy,
942
+ xt as canonicalizeBase,
943
+ Pt as clearComponentCache,
929
944
  rt as findMatchedRoute,
930
945
  zt as initRouter,
931
- Z as isAbsoluteUrl,
932
- ft as isDangerousScheme,
946
+ K as isAbsoluteUrl,
947
+ ht as isDangerousScheme,
933
948
  Q as matchRoute,
934
949
  Ft as matchRouteSSR,
935
- E as normalizePathForRoute,
950
+ C as normalizePathForRoute,
936
951
  ot as parseQuery,
937
- _t as resolveRouteComponent,
938
- Et as safeDecode,
952
+ gt as resolveRouteComponent,
953
+ Ct as safeDecode,
939
954
  $t as serializeQuery,
940
955
  It as useRouter
941
956
  };