@jasonshimmy/custom-elements-runtime 0.2.3 → 0.2.4

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,13 +1,13 @@
1
- function yt(e, t) {
2
- return te(e ? t : [], "when-block");
1
+ function vt(e, t) {
2
+ return fe(e ? t : [], "when-block");
3
3
  }
4
- function mt(e, t) {
4
+ function xt(e, t) {
5
5
  return e.map((r, o) => {
6
6
  const n = typeof r == "object" ? r?.key ?? r?.id ?? `idx-${o}` : String(r);
7
- return te(t(r, o), `each-${n}`);
7
+ return fe(t(r, o), `each-${n}`);
8
8
  });
9
9
  }
10
- function Re() {
10
+ function Oe() {
11
11
  const e = [];
12
12
  return {
13
13
  when(t, r) {
@@ -17,18 +17,18 @@ function Re() {
17
17
  return e.push([!0, t]), this;
18
18
  },
19
19
  done() {
20
- return Be(...e);
20
+ return Pe(...e);
21
21
  }
22
22
  };
23
23
  }
24
- function Be(...e) {
24
+ function Pe(...e) {
25
25
  for (let t = 0; t < e.length; t++) {
26
26
  const [r, o] = e[t];
27
- if (r) return [te(o, `whenChain-branch-${t}`)];
27
+ if (r) return [fe(o, `whenChain-branch-${t}`)];
28
28
  }
29
- return [te([], "whenChain-empty")];
29
+ return [fe([], "whenChain-empty")];
30
30
  }
31
- function te(e, t) {
31
+ function fe(e, t) {
32
32
  const r = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
33
33
  return {
34
34
  tag: "#anchor",
@@ -36,7 +36,7 @@ function te(e, t) {
36
36
  children: r
37
37
  };
38
38
  }
39
- class U extends EventTarget {
39
+ class G extends EventTarget {
40
40
  handlers = {};
41
41
  static instance;
42
42
  eventCounters = /* @__PURE__ */ new Map();
@@ -44,9 +44,8 @@ class U extends EventTarget {
44
44
  * Returns the singleton instance of GlobalEventBus
45
45
  */
46
46
  static getInstance() {
47
- return U.instance || (U.instance = new U()), U.instance;
47
+ return G.instance || (G.instance = new G()), G.instance;
48
48
  }
49
- // Enhanced emit method with better typing and event storm protection
50
49
  /**
51
50
  * Emit a global event with optional data. Includes event storm protection.
52
51
  * @param eventName - Name of the event
@@ -56,20 +55,18 @@ class U extends EventTarget {
56
55
  const o = Date.now(), n = this.eventCounters.get(t);
57
56
  if (!n || o - n.window > 1e3)
58
57
  this.eventCounters.set(t, { count: 1, window: o });
59
- else if (n.count++, n.count > 50 && (console.error(`Event storm detected for "${t}": ${n.count} events in 1 second. Throttling...`), n.count > 100)) {
60
- console.warn(`Blocking further "${t}" events to prevent infinite loop`);
58
+ else if (n.count++, n.count > 50 && n.count > 100)
61
59
  return;
62
- }
63
60
  this.dispatchEvent(new CustomEvent(t, {
64
61
  detail: r,
65
62
  bubbles: !1,
66
63
  // Global events don't need to bubble
67
64
  cancelable: !0
68
65
  }));
69
- const s = this.handlers[t];
70
- s && s.forEach((i) => {
66
+ const i = this.handlers[t];
67
+ i && i.forEach((s) => {
71
68
  try {
72
- i(r);
69
+ s(r);
73
70
  } catch (a) {
74
71
  console.error(`Error in global event handler for "${t}":`, a);
75
72
  }
@@ -115,8 +112,8 @@ class U extends EventTarget {
115
112
  */
116
113
  once(t, r) {
117
114
  return new Promise((o) => {
118
- const n = this.on(t, (s) => {
119
- n(), r(s), o(s);
115
+ const n = this.on(t, (i) => {
116
+ n(), r(i), o(i);
120
117
  });
121
118
  });
122
119
  }
@@ -160,8 +157,8 @@ class U extends EventTarget {
160
157
  this.eventCounters.clear();
161
158
  }
162
159
  }
163
- const Z = U.getInstance(), bt = (e, t) => Z.emit(e, t), vt = (e, t) => Z.on(e, t), wt = (e, t) => Z.off(e, t), xt = (e, t) => Z.once(e, t), kt = (e, t, r) => Z.listen(e, t, r);
164
- function we(e) {
160
+ const re = G.getInstance(), wt = (e, t) => re.emit(e, t), kt = (e, t) => re.on(e, t), $t = (e, t) => re.off(e, t), _t = (e, t) => re.once(e, t), St = (e, t, r) => re.listen(e, t, r);
161
+ function $e(e) {
165
162
  let t = { ...e };
166
163
  const r = [];
167
164
  function o(a) {
@@ -170,19 +167,19 @@ function we(e) {
170
167
  function n() {
171
168
  return t;
172
169
  }
173
- function s(a) {
174
- const l = typeof a == "function" ? a(t) : a;
175
- t = { ...t, ...l }, i();
170
+ function i(a) {
171
+ const f = typeof a == "function" ? a(t) : a;
172
+ t = { ...t, ...f }, s();
176
173
  }
177
- function i() {
174
+ function s() {
178
175
  r.forEach((a) => a(t));
179
176
  }
180
- return { subscribe: o, getState: n, setState: s };
177
+ return { subscribe: o, getState: n, setState: i };
181
178
  }
182
- function me(e) {
179
+ function J(e) {
183
180
  return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
184
181
  }
185
- function pe(e) {
182
+ function H(e) {
186
183
  return typeof e == "string" ? e.replace(
187
184
  /[&<>"']/g,
188
185
  (t) => ({
@@ -194,247 +191,242 @@ function pe(e) {
194
191
  })[t]
195
192
  ) : e;
196
193
  }
197
- function Pe(e, t, r) {
194
+ function N(e, t) {
195
+ return typeof t == "string" ? t.split(".").reduce((r, o) => r?.[o], e) : t;
196
+ }
197
+ function se(e, t, r) {
198
+ const o = String(t).split("."), n = o.pop();
199
+ if (!n) return;
200
+ const i = o.reduce((s, a) => (s[a] == null && (s[a] = {}), s[a]), e);
201
+ i[n] = r;
202
+ }
203
+ function Ne(e, t, r) {
198
204
  if (r)
199
205
  for (const [o, n] of Object.entries(r)) {
200
- let s, i = {};
201
- if (Array.isArray(n) ? (s = n[0], i = n[1] || {}) : s = n, t.set(o, {
202
- callback: s,
203
- options: i,
204
- oldValue: he(e, o)
205
- }), i.immediate)
206
+ let i, s = {};
207
+ if (Array.isArray(n) ? (i = n[0], s = n[1] || {}) : i = n, t.set(o, {
208
+ callback: i,
209
+ options: s,
210
+ oldValue: N(e, o)
211
+ }), s.immediate)
206
212
  try {
207
- const a = he(e, o);
208
- s(a, void 0, e);
213
+ const a = N(e, o);
214
+ i(a, void 0, e);
209
215
  } catch (a) {
210
216
  console.error(`Error in immediate watcher for "${o}":`, a);
211
217
  }
212
218
  }
213
219
  }
214
- function he(e, t) {
215
- return t.split(".").reduce((r, o) => r?.[o], e);
216
- }
217
- function Oe(e, t, r, o) {
218
- const n = (i, a) => {
219
- if (i === a) return !0;
220
- if (typeof i != typeof a || typeof i != "object" || i === null || a === null) return !1;
221
- if (Array.isArray(i) && Array.isArray(a))
222
- return i.length !== a.length ? !1 : i.every((p, y) => n(p, a[y]));
223
- const l = Object.keys(i), f = Object.keys(a);
224
- return l.length !== f.length ? !1 : l.every((p) => n(i[p], a[p]));
225
- }, s = t.get(r);
226
- if (s && !n(o, s.oldValue))
220
+ function Me(e, t, r, o) {
221
+ const n = (s, a) => {
222
+ if (s === a) return !0;
223
+ if (typeof s != typeof a || typeof s != "object" || s === null || a === null) return !1;
224
+ if (Array.isArray(s) && Array.isArray(a))
225
+ return s.length !== a.length ? !1 : s.every((d, m) => n(d, a[m]));
226
+ const f = Object.keys(s), u = Object.keys(a);
227
+ return f.length !== u.length ? !1 : f.every((d) => n(s[d], a[d]));
228
+ }, i = t.get(r);
229
+ if (i && !n(o, i.oldValue))
227
230
  try {
228
- s.callback(o, s.oldValue, e), s.oldValue = o;
229
- } catch (i) {
230
- console.error(`Error in watcher for "${r}":`, i);
231
+ i.callback(o, i.oldValue, e), i.oldValue = o;
232
+ } catch (s) {
233
+ console.error(`Error in watcher for "${r}":`, s);
231
234
  }
232
- for (const [i, a] of t.entries())
233
- if (a.options.deep && r.startsWith(i + "."))
235
+ for (const [s, a] of t.entries())
236
+ if (a.options.deep && r.startsWith(s + "."))
234
237
  try {
235
- const l = he(e, i);
236
- n(l, a.oldValue) || (a.callback(l, a.oldValue, e), a.oldValue = l);
237
- } catch (l) {
238
- console.error(`Error in deep watcher for "${i}":`, l);
238
+ const f = N(e, s);
239
+ n(f, a.oldValue) || (a.callback(f, a.oldValue, e), a.oldValue = f);
240
+ } catch (f) {
241
+ console.error(`Error in deep watcher for "${s}":`, f);
239
242
  }
240
243
  }
241
- function Me(e, t, r) {
244
+ function We(e, t, r) {
242
245
  if (!t.props) return;
243
- function o(n, s) {
244
- return s === Boolean ? n === "true" : s === Number ? Number(n) : n;
246
+ function o(n, i) {
247
+ return i === Boolean ? n === "true" : i === Number ? Number(n) : n;
245
248
  }
246
- Object.entries(t.props).forEach(([n, s]) => {
247
- if (s.type === Function && typeof e[n] == "function")
249
+ Object.entries(t.props).forEach(([n, i]) => {
250
+ if (i.type === Function && typeof e[n] == "function")
248
251
  r[n] = e[n];
249
252
  else {
250
- const i = e.getAttribute(me(n));
251
- i !== null ? r[n] = pe(o(i, s.type)) : "default" in s && s.default !== void 0 && (r[n] = pe(s.default));
253
+ const s = e.getAttribute(J(n));
254
+ s !== null ? r[n] = H(o(s, i.type)) : "default" in i && i.default !== void 0 && (r[n] = H(i.default));
252
255
  }
253
256
  });
254
257
  }
255
- function Ne(e, t, r, o) {
258
+ function qe(e, t, r, o) {
256
259
  e.onConnected && !r && (e.onConnected(t), o(!0));
257
260
  }
258
- function We(e, t, r, o, n, s, i, a) {
259
- e.onDisconnected && e.onDisconnected(t), r.forEach((l) => l()), o(), n(), s(!1), i(null), a(!1);
261
+ function De(e, t, r, o, n, i, s, a) {
262
+ e.onDisconnected && e.onDisconnected(t), r.forEach((f) => f()), o(), n(), i(!1), s(null), a(!1);
260
263
  }
261
- function De(e, t, r, o, n) {
264
+ function Ie(e, t, r, o, n) {
262
265
  e.onAttributeChanged && e.onAttributeChanged(t, r, o, n);
263
266
  }
264
- function q(e, t) {
267
+ function V(e, t) {
265
268
  if (t && e instanceof HTMLElement) {
266
269
  for (const r in t)
267
270
  t[r] === e && delete t[r];
268
271
  for (const r of Array.from(e.childNodes))
269
- q(r, t);
270
- }
271
- }
272
- function I(e, t) {
273
- return typeof t == "string" ? t.split(".").reduce((r, o) => r?.[o], e) : t;
274
- }
275
- function xe(e, t, r) {
276
- const o = t.split("."), n = o.pop();
277
- if (!n) return;
278
- const s = o.reduce((i, a) => (a in i || (i[a] = {}), i[a]), e);
279
- s[n] = r;
280
- }
281
- function qe(e, t, r, o, n, s, i) {
282
- if (!s) return;
283
- const a = t.includes("lazy"), l = t.includes("trim"), f = t.includes("number"), p = () => {
284
- const h = s._state || s;
285
- return I(h, e);
286
- }, y = p();
287
- let c = "text";
288
- const x = o?.type;
289
- if (i instanceof HTMLInputElement ? c = x || i.type || "text" : i instanceof HTMLSelectElement ? c = "select" : i instanceof HTMLTextAreaElement && (c = "textarea"), c === "checkbox")
290
- if (Array.isArray(y)) {
291
- const h = i?.getAttribute("value") || o?.value || "", u = y.includes(h);
292
- i && i.checked !== u && (r.checked = u);
293
- } else {
294
- const h = i?.getAttribute("true-value") || !0, u = y === h;
295
- i && i.checked !== u && (r.checked = u);
272
+ V(r, t);
273
+ }
274
+ }
275
+ function He(e, t, r, o, n, i, s, a) {
276
+ if (!i) return;
277
+ const f = t.includes("lazy"), u = t.includes("trim"), d = t.includes("number"), m = () => N(i._state || i, e), l = m();
278
+ let h = "text";
279
+ s instanceof HTMLInputElement ? h = o?.type || s.type || "text" : s instanceof HTMLSelectElement ? h = "select" : s instanceof HTMLTextAreaElement && (h = "textarea");
280
+ const w = s instanceof HTMLInputElement || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement, v = w ? h === "checkbox" || h === "radio" ? "checked" : "value" : a ?? "modelValue";
281
+ if (h === "checkbox")
282
+ if (Array.isArray(l))
283
+ r[v] = l.includes(String(s?.getAttribute("value") ?? o?.value ?? ""));
284
+ else {
285
+ const x = s?.getAttribute("true-value") ?? !0;
286
+ r[v] = l === x;
296
287
  }
297
- else if (c === "radio") {
298
- const h = o?.value || "", u = y === h;
299
- i && i.checked !== u && (r.checked = u);
300
- } else if (c === "select")
301
- if (i && i.hasAttribute("multiple")) {
302
- const h = i, u = Array.isArray(y) ? y : [];
288
+ else if (h === "radio")
289
+ r[v] = l === (o?.value ?? "");
290
+ else if (h === "select")
291
+ if (s && s.hasAttribute("multiple") && s instanceof HTMLSelectElement) {
292
+ const x = Array.isArray(l) ? l.map(String) : [];
303
293
  setTimeout(() => {
304
- Array.from(h.options).forEach((g) => {
305
- const b = u.includes(g.value);
306
- g.selected !== b && (g.selected = b);
294
+ Array.from(s.options).forEach((c) => {
295
+ c.selected = x.includes(c.value);
307
296
  });
308
- }, 0);
297
+ }, 0), r[v] = Array.isArray(l) ? l : [];
309
298
  } else
310
- setTimeout(() => {
311
- i instanceof HTMLSelectElement && i.value !== String(y) && (i.value = String(y));
312
- }, 0);
299
+ r[v] = l;
313
300
  else {
314
- const h = String(y ?? "");
315
- (!i || i.value !== h) && (r.value = y);
316
- }
317
- const w = a || c === "checkbox" || c === "radio" || c === "select" ? "change" : "input", k = (h) => {
318
- if (h.isComposing || n._isComposing || h.isTrusted === !1) return;
319
- const u = h.target;
320
- if (u._modelUpdating) return;
321
- const g = p();
322
- let b = u.value;
323
- if (c === "checkbox")
324
- if (Array.isArray(g)) {
325
- const $ = u.getAttribute("value") || "", _ = [...g];
326
- if (u.checked)
327
- _.includes($) || _.push($);
301
+ r[v] = l;
302
+ try {
303
+ const x = J(v);
304
+ o && (o[x] = l);
305
+ } catch {
306
+ }
307
+ }
308
+ const b = f || h === "checkbox" || h === "radio" || h === "select" ? "change" : "input", y = (x) => {
309
+ if (x.isComposing || n._isComposing || x.isTrusted === !1) return;
310
+ const c = x.target;
311
+ if (!c || c._modelUpdating) return;
312
+ let g = c.value;
313
+ if (h === "checkbox") {
314
+ const C = m();
315
+ if (Array.isArray(C)) {
316
+ const S = c.getAttribute("value") ?? "", A = Array.from(C);
317
+ if (c.checked)
318
+ A.includes(S) || A.push(S);
328
319
  else {
329
- const C = _.indexOf($);
330
- C > -1 && _.splice(C, 1);
320
+ const T = A.indexOf(S);
321
+ T > -1 && A.splice(T, 1);
331
322
  }
332
- b = _;
323
+ g = A;
333
324
  } else {
334
- const $ = u.getAttribute("true-value") || !0, _ = u.getAttribute("false-value") || !1;
335
- b = u.checked ? $ : _;
325
+ const S = c.getAttribute("true-value") ?? !0, A = c.getAttribute("false-value") ?? !1;
326
+ g = c.checked ? S : A;
336
327
  }
337
- else if (c === "radio")
338
- b = u.getAttribute("value") || u.value;
339
- else if (c === "select" && u.multiple) {
340
- const $ = u;
341
- b = Array.from($.selectedOptions).map(
342
- (_) => _.value
343
- );
344
- } else if (l && (b = b.trim()), f) {
345
- const $ = Number(b);
346
- isNaN($) || (b = $);
328
+ } else if (h === "radio")
329
+ g = c.getAttribute("value") ?? c.value;
330
+ else if (h === "select" && c.multiple)
331
+ g = Array.from(c.selectedOptions).map((C) => C.value);
332
+ else if (u && typeof g == "string" && (g = g.trim()), d) {
333
+ const C = Number(g);
334
+ isNaN(C) || (g = C);
347
335
  }
348
- const d = s._state || s, v = I(d, e);
349
- if (Array.isArray(b) && Array.isArray(v) ? JSON.stringify([...b].sort()) !== JSON.stringify([...v].sort()) : b !== v) {
350
- const $ = h.target;
351
- $._modelUpdating = !0, xe(d, e, b), setTimeout(() => {
352
- $._modelUpdating = !1;
353
- }, 0), s._requestRender && s._requestRender();
336
+ const p = i._state || i, _ = N(p, e);
337
+ if (Array.isArray(g) && Array.isArray(_) ? JSON.stringify([...g].sort()) !== JSON.stringify([..._].sort()) : g !== _) {
338
+ c._modelUpdating = !0;
339
+ try {
340
+ se(p, e, g), i._requestRender && i._requestRender();
341
+ } finally {
342
+ setTimeout(() => c._modelUpdating = !1, 0);
343
+ }
354
344
  }
355
345
  };
356
- if (n[w] = k, c === "text" || c === "textarea") {
357
- const h = () => {
358
- n._isComposing = !0;
359
- }, u = (g) => {
360
- n._isComposing = !1;
361
- const b = g.target;
362
- setTimeout(() => {
363
- if (b) {
364
- let d = b.value;
365
- if (l && (d = d.trim()), f) {
366
- const _ = Number(d);
367
- isNaN(_) || (d = _);
368
- }
369
- const v = s._state || s, m = I(v, e);
370
- (Array.isArray(d) && Array.isArray(m) ? JSON.stringify([...d].sort()) !== JSON.stringify([...m].sort()) : d !== m) && (b && (b._modelUpdating = !0, setTimeout(() => {
371
- b._modelUpdating = !1;
372
- }, 0)), xe(v, e, d), s._requestRender && s._requestRender());
346
+ w ? n[b] = y : n[`update:${J(v)}`] = (x) => {
347
+ const c = i._state || i, g = x.detail !== void 0 ? x.detail : x.target?.value, p = N(c, e);
348
+ (Array.isArray(g) && Array.isArray(p) ? JSON.stringify([...g].sort()) !== JSON.stringify([...p].sort()) : g !== p) && (se(c, e, g), i._requestRender && i._requestRender());
349
+ }, (h === "text" || h === "textarea") && (n.compositionstart = (() => n._isComposing = !0), n.compositionend = (x) => {
350
+ n._isComposing = !1;
351
+ const c = x.target;
352
+ c && setTimeout(() => {
353
+ const g = c.value, p = i._state || i, _ = N(p, e);
354
+ let E = g;
355
+ if (u && (E = E.trim()), d) {
356
+ const S = Number(E);
357
+ isNaN(S) || (E = S);
358
+ }
359
+ if (Array.isArray(E) && Array.isArray(_) ? JSON.stringify([...E].sort()) !== JSON.stringify([..._].sort()) : E !== _) {
360
+ c._modelUpdating = !0;
361
+ try {
362
+ se(p, e, E), i._requestRender && i._requestRender();
363
+ } finally {
364
+ setTimeout(() => c._modelUpdating = !1, 0);
373
365
  }
374
- }, 0);
375
- };
376
- n.compositionstart = h, n.compositionend = u;
377
- }
366
+ }
367
+ }, 0);
368
+ });
378
369
  }
379
- function Ae(e) {
380
- return e.slice(2).charAt(0).toLowerCase() + e.slice(3);
370
+ function Le(e) {
371
+ const t = e.slice(2);
372
+ return t ? t.charAt(0).toLowerCase() + t.slice(1) : "";
381
373
  }
382
- function Ie(e, t, r, o) {
374
+ function Fe(e, t, r, o) {
383
375
  if (o) {
384
376
  if (typeof e == "object" && e !== null)
385
- for (const [n, s] of Object.entries(e))
386
- t[n] = s;
377
+ for (const [n, i] of Object.entries(e))
378
+ t[n] = i;
387
379
  else if (typeof e == "string")
388
380
  try {
389
381
  const n = JSON.parse(e);
390
382
  if (typeof n == "object" && n !== null) {
391
- for (const [s, i] of Object.entries(n))
392
- t[s] = i;
383
+ for (const [i, s] of Object.entries(n))
384
+ t[i] = s;
393
385
  return;
394
386
  }
395
387
  } catch {
396
- const n = I(o, e);
388
+ const n = N(o, e);
397
389
  r[e] = n;
398
390
  }
399
391
  }
400
392
  }
401
- function He(e, t, r) {
393
+ function Ke(e, t, r) {
402
394
  if (!r) return;
403
- const o = I(r, e), n = t.style || "", s = o ? "" : "none";
395
+ const o = N(r, e), n = t.style || "", i = o ? "" : "none";
404
396
  if (n) {
405
- const i = n.split(";").filter(Boolean), a = i.findIndex(
406
- (l) => l.trim().startsWith("display:")
397
+ const s = n.split(";").filter(Boolean), a = s.findIndex(
398
+ (f) => f.trim().startsWith("display:")
407
399
  );
408
- a >= 0 ? i[a] = `display: ${s}` : i.push(`display: ${s}`), t.style = i.join("; ");
400
+ a >= 0 ? s[a] = `display: ${i}` : s.push(`display: ${i}`), t.style = s.join("; ");
409
401
  } else
410
- t.style = `display: ${s}`;
402
+ t.style = `display: ${i}`;
411
403
  }
412
- function Fe(e, t, r) {
404
+ function Ue(e, t, r) {
413
405
  if (!r) return;
414
- const o = I(r, e);
406
+ const o = N(r, e);
415
407
  let n = [];
416
408
  typeof o == "string" ? n = [o] : Array.isArray(o) ? n = o.filter(Boolean) : typeof o == "object" && (n = Object.entries(o).filter(([, a]) => !!a).flatMap(([a]) => a.split(/\s+/).filter(Boolean)));
417
- const s = t.class || "", i = s ? `${s} ${n.join(" ")}`.trim() : n.join(" ");
418
- i && (t.class = i);
409
+ const i = t.class || "", s = i ? `${i} ${n.join(" ")}`.trim() : n.join(" ");
410
+ s && (t.class = s);
419
411
  }
420
- function Ue(e, t, r) {
412
+ function Ve(e, t, r) {
421
413
  let o;
422
414
  if (typeof e == "string") {
423
415
  if (!r) return;
424
- o = I(r, e);
416
+ o = N(r, e);
425
417
  } else
426
418
  o = e;
427
419
  let n = "";
428
420
  if (typeof o == "string")
429
421
  n = o;
430
422
  else if (o && typeof o == "object") {
431
- const i = [];
432
- for (const [a, l] of Object.entries(o))
433
- if (l != null && l !== "") {
434
- const f = a.replace(
423
+ const s = [];
424
+ for (const [a, f] of Object.entries(o))
425
+ if (f != null && f !== "") {
426
+ const u = a.replace(
435
427
  /[A-Z]/g,
436
- (c) => `-${c.toLowerCase()}`
437
- ), p = [
428
+ (l) => `-${l.toLowerCase()}`
429
+ ), d = [
438
430
  "width",
439
431
  "height",
440
432
  "top",
@@ -460,359 +452,391 @@ function Ue(e, t, r) {
460
452
  "min-height",
461
453
  "max-height"
462
454
  ];
463
- let y = String(l);
464
- typeof l == "number" && p.includes(f) && (y = `${l}px`), i.push(`${f}: ${y}`);
455
+ let m = String(f);
456
+ typeof f == "number" && d.includes(u) && (m = `${f}px`), s.push(`${u}: ${m}`);
465
457
  }
466
- n = i.join("; ") + (i.length > 0 ? ";" : "");
467
- }
468
- const s = t.style || "";
469
- t.style = s + (s && !s.endsWith(";") ? "; " : "") + n;
470
- }
471
- function Te(e, t, r, o) {
472
- const n = {}, s = { ...o || {} }, i = {};
473
- for (const [a, l] of Object.entries(e)) {
474
- const { value: f, modifiers: p } = l;
458
+ n = s.join("; ") + (s.length > 0 ? ";" : "");
459
+ }
460
+ const i = t.style || "";
461
+ t.style = i + (i && !i.endsWith(";") ? "; " : "") + n;
462
+ }
463
+ function Re(e, t, r, o) {
464
+ const n = {}, i = { ...o || {} }, s = {};
465
+ for (const [a, f] of Object.entries(e)) {
466
+ const { value: u, modifiers: d, arg: m } = f;
467
+ if (a === "model" || a.startsWith("model:")) {
468
+ const l = a.split(":"), h = l.length > 1 ? l[1] : m;
469
+ He(
470
+ typeof u == "string" ? u : String(u),
471
+ d,
472
+ n,
473
+ i,
474
+ s,
475
+ t,
476
+ r,
477
+ h
478
+ );
479
+ continue;
480
+ }
475
481
  switch (a) {
476
- case "model":
477
- qe(
478
- typeof f == "string" ? f : String(f),
479
- p,
480
- n,
481
- s,
482
- i,
483
- t,
484
- r
485
- );
486
- break;
487
482
  case "bind":
488
- Ie(f, n, s, t);
483
+ Fe(u, n, i, t);
489
484
  break;
490
485
  case "show":
491
- He(f, s, t);
486
+ Ke(u, i, t);
492
487
  break;
493
488
  case "class":
494
- Fe(f, s, t);
489
+ Ue(u, i, t);
495
490
  break;
496
491
  case "style":
497
- Ue(f, s, t);
492
+ Ve(u, i, t);
498
493
  break;
499
494
  }
500
495
  }
501
- return { props: n, attrs: s, listeners: i };
496
+ return { props: n, attrs: i, listeners: s };
502
497
  }
503
- function ge(e, t) {
498
+ function ke(e, t) {
504
499
  if (Array.isArray(e)) {
505
- const s = /* @__PURE__ */ new Set();
506
- return e.map((i) => {
507
- if (!i || typeof i != "object") return i;
508
- let a = i.props?.key ?? i.key;
500
+ const i = /* @__PURE__ */ new Set();
501
+ return e.map((s) => {
502
+ if (!s || typeof s != "object") return s;
503
+ let a = s.props?.key ?? s.key;
509
504
  if (!a) {
510
- const y = i.tag || "node", c = i.props?.attrs?.id ?? i.props?.attrs?.name ?? i.props?.attrs?.["data-key"] ?? "";
511
- a = c ? `${t}:${y}:${c}` : `${t}:${y}`;
505
+ const m = s.tag || "node", l = s.props?.attrs?.id ?? s.props?.attrs?.name ?? s.props?.attrs?.["data-key"] ?? "";
506
+ a = l ? `${t}:${m}:${l}` : `${t}:${m}`;
512
507
  }
513
- let l = a, f = 1;
514
- for (; s.has(l); )
515
- l = `${a}#${f++}`;
516
- s.add(l);
517
- let p = i.children;
518
- return Array.isArray(p) && (p = ge(p, l)), { ...i, key: l, children: p };
508
+ let f = a, u = 1;
509
+ for (; i.has(f); )
510
+ f = `${a}#${u++}`;
511
+ i.add(f);
512
+ let d = s.children;
513
+ return Array.isArray(d) && (d = ke(d, f)), { ...s, key: f, children: d };
519
514
  });
520
515
  }
521
516
  const r = e;
522
517
  let o = r.props?.key ?? r.key ?? t, n = r.children;
523
- return Array.isArray(n) && (n = ge(n, o)), { ...r, key: o, children: n };
518
+ return Array.isArray(n) && (n = ke(n, o)), { ...r, key: o, children: n };
524
519
  }
525
- function Ke(e, t, r, o) {
526
- const n = r.directives ?? {}, s = Te(
520
+ function Je(e, t, r, o) {
521
+ const n = r.directives ?? {}, i = Re(
527
522
  n,
528
523
  o,
529
524
  e,
530
525
  r.attrs
531
- ), i = {
526
+ ), s = {
532
527
  ...t.props,
533
528
  ...r.props,
534
- ...s.props
529
+ ...i.props
535
530
  }, a = {
536
531
  ...t.attrs,
537
532
  ...r.attrs,
538
- ...s.attrs
539
- }, l = t.props ?? {}, f = i;
540
- for (const c in { ...l, ...f }) {
541
- const x = l[c], w = f[c];
542
- if (x !== w)
543
- if (c === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement))
533
+ ...i.attrs
534
+ }, f = t.props ?? {}, u = s;
535
+ for (const l in { ...f, ...u }) {
536
+ const h = f[l], w = u[l];
537
+ if (h !== w) {
538
+ if (l === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement))
544
539
  e.value !== w && (e.value = w ?? "");
545
- else if (c === "checked" && e instanceof HTMLInputElement)
540
+ else if (l === "checked" && e instanceof HTMLInputElement)
546
541
  e.checked = !!w;
547
- else if (c.startsWith("on") && typeof w == "function") {
548
- const k = Ae(c);
549
- typeof x == "function" && e.removeEventListener(k, x), e.addEventListener(k, w);
550
- } else w == null || w === !1 ? e.removeAttribute(c) : e.setAttribute(c, String(w));
542
+ else if (l.startsWith("on") && typeof w == "function") {
543
+ const $ = Le(l);
544
+ typeof h == "function" && e.removeEventListener($, h), e.addEventListener($, w);
545
+ } else if (w == null || w === !1)
546
+ e.removeAttribute(l);
547
+ else if ((r?.isCustomElement ?? t?.isCustomElement ?? !1) || l in e)
548
+ try {
549
+ e[l] = w;
550
+ } catch {
551
+ }
552
+ }
551
553
  }
552
- for (const [c, x] of Object.entries(
553
- s.listeners || {}
554
+ for (const [l, h] of Object.entries(
555
+ i.listeners || {}
554
556
  ))
555
- e.addEventListener(c, x);
556
- const p = t.attrs ?? {}, y = a;
557
- for (const c in { ...p, ...y }) {
558
- const x = p[c], w = y[c];
559
- x !== w && (w == null || w === !1 ? e.removeAttribute(c) : e.setAttribute(c, String(w)));
557
+ e.addEventListener(l, h);
558
+ const d = t.attrs ?? {}, m = a;
559
+ for (const l in { ...d, ...m }) {
560
+ const h = d[l], w = m[l];
561
+ h !== w && (w == null || w === !1 ? e.removeAttribute(l) : e.setAttribute(l, String(w)));
560
562
  }
561
563
  }
562
- function P(e, t, r) {
564
+ function M(e, t, r) {
563
565
  if (typeof e == "string")
564
566
  return document.createTextNode(e);
565
567
  if (e.tag === "#text") {
566
- const y = document.createTextNode(
568
+ const m = document.createTextNode(
567
569
  typeof e.children == "string" ? e.children : ""
568
570
  );
569
- return e.key != null && (y.key = e.key), y;
571
+ return e.key != null && (m.key = e.key), m;
570
572
  }
571
573
  if (e.tag === "#anchor") {
572
- const y = e, c = Array.isArray(y.children) ? y.children : [], x = document.createTextNode(""), w = document.createTextNode("");
573
- y.key != null && (x.key = `${y.key}:start`, w.key = `${y.key}:end`), y._startNode = x, y._endNode = w;
574
- const k = document.createDocumentFragment();
575
- k.appendChild(x);
576
- for (const h of c) {
577
- const u = P(h, t);
578
- k.appendChild(u);
574
+ const m = e, l = Array.isArray(m.children) ? m.children : [], h = document.createTextNode(""), w = document.createTextNode("");
575
+ m.key != null && (h.key = `${m.key}:start`, w.key = `${m.key}:end`), m._startNode = h, m._endNode = w;
576
+ const $ = document.createDocumentFragment();
577
+ $.appendChild(h);
578
+ for (const v of l) {
579
+ const b = M(v, t);
580
+ $.appendChild(b);
579
581
  }
580
- return k.appendChild(w), k;
582
+ return $.appendChild(w), $;
581
583
  }
582
584
  const o = document.createElement(e.tag);
583
585
  e.key != null && (o.key = e.key);
584
- const { props: n = {}, attrs: s = {}, directives: i = {} } = e.props ?? {}, a = Te(i, t, o, s), l = {
586
+ const { props: n = {}, attrs: i = {}, directives: s = {} } = e.props ?? {}, a = Re(s, t, o, i), f = {
585
587
  ...n,
586
588
  ...a.props
587
- }, f = {
588
- ...s,
589
+ }, u = {
590
+ ...i,
589
591
  ...a.attrs
590
592
  };
591
- for (const y in f) {
592
- const c = f[y];
593
- if (typeof y != "string" || /\[object Object\]/.test(y)) {
594
- typeof window < "u" && window.console && console.warn("Skipping invalid attribute key:", y, c);
595
- continue;
596
- }
597
- typeof c == "boolean" ? c && o.setAttribute(y, "") : c != null && o.setAttribute(y, c);
598
- }
599
- for (const y in l) {
600
- const c = l[y];
601
- if (typeof y != "string" || /\[object Object\]/.test(y)) {
602
- typeof window < "u" && window.console && console.warn("Skipping invalid prop key:", y, c);
603
- continue;
604
- }
605
- if (y === "value" && (o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement))
606
- o.value = c ?? "";
607
- else if (y === "checked" && o instanceof HTMLInputElement)
608
- o.checked = !!c;
609
- else if (y.startsWith("on") && typeof c == "function")
610
- o.addEventListener(Ae(y), c);
611
- else {
612
- if (y.startsWith("on") && c === void 0)
613
- continue;
614
- c == null || c === !1 ? o.removeAttribute(y) : o.setAttribute(y, String(c));
615
- }
593
+ for (const m in u) {
594
+ const l = u[m];
595
+ typeof m != "string" || /\[object Object\]/.test(m) || (typeof l == "boolean" ? l && o.setAttribute(m, "") : l != null && o.setAttribute(m, l));
596
+ }
597
+ for (const m in f) {
598
+ const l = f[m];
599
+ if (!(typeof m != "string" || /\[object Object\]/.test(m)))
600
+ if (m === "value" && (o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement))
601
+ o.value = l ?? "";
602
+ else if (m === "checked" && o instanceof HTMLInputElement)
603
+ o.checked = !!l;
604
+ else if (m.startsWith("on") && typeof l == "function")
605
+ o.addEventListener(Le(m), l);
606
+ else {
607
+ if (m.startsWith("on") && l === void 0)
608
+ continue;
609
+ if (l == null || l === !1)
610
+ o.removeAttribute(m);
611
+ else if ((e.props?.isCustomElement ?? !1) || m in o)
612
+ try {
613
+ o[m] = l;
614
+ } catch {
615
+ }
616
+ }
616
617
  }
617
- for (const [y, c] of Object.entries(
618
+ for (const [m, l] of Object.entries(
618
619
  a.listeners || {}
619
620
  ))
620
- o.addEventListener(y, c);
621
- const p = e.props?.ref ?? (e.props?.props && e.props.props.ref);
622
- if (typeof e != "string" && p && r && (r[p] = o), Array.isArray(e.children))
623
- for (const y of e.children)
624
- o.appendChild(P(y, t, r));
621
+ o.addEventListener(m, l);
622
+ const d = e.props?.ref ?? (e.props?.props && e.props.props.ref);
623
+ typeof e != "string" && d && r && (r[d] = o);
624
+ try {
625
+ if (typeof o._applyProps == "function")
626
+ try {
627
+ o._applyProps(o._cfg);
628
+ } catch {
629
+ }
630
+ typeof o.requestRender == "function" ? o.requestRender() : typeof o._render == "function" && o._render(o._cfg);
631
+ } catch {
632
+ }
633
+ if (Array.isArray(e.children))
634
+ for (const m of e.children)
635
+ o.appendChild(M(m, t, r));
625
636
  else typeof e.children == "string" && (o.textContent = e.children);
626
637
  return o;
627
638
  }
628
- function Ve(e, t, r, o, n) {
639
+ function Ze(e, t, r, o, n) {
629
640
  if (typeof r == "string") {
630
641
  e.textContent !== r && (e.textContent = r);
631
642
  return;
632
643
  }
633
644
  if (!Array.isArray(r)) return;
634
- const s = Array.from(e.childNodes), i = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
635
- for (const x of i)
636
- x && x.key != null && a.set(x.key, x);
637
- const l = /* @__PURE__ */ new Map();
638
- for (const x of s) {
639
- const w = x.key;
640
- w != null && l.set(w, x);
641
- }
642
- const f = /* @__PURE__ */ new Set();
643
- let p = e.firstChild;
644
- function y(x, w) {
645
- let k = x;
646
- for (; k && (f.add(k), k !== w); )
647
- k = k.nextSibling;
648
- }
649
- function c(x, w, k, h) {
650
- const u = [];
651
- let g = x.nextSibling;
652
- for (; g && g !== w; )
653
- u.push(g), g = g.nextSibling;
654
- const b = Array.isArray(k) ? k : [];
655
- if (h.some((v) => v && v.key != null) || b.some((v) => v && v.key != null)) {
656
- const v = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
657
- for (const C of b)
658
- C && C.key != null && v.set(C.key, C);
659
- for (const C of u) {
660
- const E = C.key;
661
- E != null && m.set(E, C);
645
+ const i = Array.from(e.childNodes), s = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
646
+ for (const h of s)
647
+ h && h.key != null && a.set(h.key, h);
648
+ const f = /* @__PURE__ */ new Map();
649
+ for (const h of i) {
650
+ const w = h.key;
651
+ w != null && f.set(w, h);
652
+ }
653
+ const u = /* @__PURE__ */ new Set();
654
+ let d = e.firstChild;
655
+ function m(h, w) {
656
+ let $ = h;
657
+ for (; $ && (u.add($), $ !== w); )
658
+ $ = $.nextSibling;
659
+ }
660
+ function l(h, w, $, v) {
661
+ const b = [];
662
+ let y = h.nextSibling;
663
+ for (; y && y !== w; )
664
+ b.push(y), y = y.nextSibling;
665
+ const x = Array.isArray($) ? $ : [];
666
+ if (v.some((g) => g && g.key != null) || x.some((g) => g && g.key != null)) {
667
+ const g = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
668
+ for (const C of x)
669
+ C && C.key != null && g.set(C.key, C);
670
+ for (const C of b) {
671
+ const S = C.key;
672
+ S != null && p.set(S, C);
662
673
  }
663
- const $ = /* @__PURE__ */ new Set();
664
- let _ = x.nextSibling;
665
- for (const C of h) {
666
- let E;
667
- if (C.key != null && m.has(C.key)) {
668
- const j = v.get(C.key);
669
- E = X(
670
- m.get(C.key),
671
- j,
674
+ const _ = /* @__PURE__ */ new Set();
675
+ let E = h.nextSibling;
676
+ for (const C of v) {
677
+ let S;
678
+ if (C.key != null && p.has(C.key)) {
679
+ const A = g.get(C.key);
680
+ S = ae(
681
+ p.get(C.key),
682
+ A,
672
683
  C,
673
684
  o
674
- ), $.add(E), E !== _ && e.contains(E) && e.insertBefore(E, _);
685
+ ), _.add(S), S !== E && e.contains(S) && e.insertBefore(S, E);
675
686
  } else
676
- E = P(C, o), e.insertBefore(E, _), $.add(E);
677
- _ = E.nextSibling;
687
+ S = M(C, o), e.insertBefore(S, E), _.add(S);
688
+ E = S.nextSibling;
678
689
  }
679
- for (const C of u)
680
- !$.has(C) && e.contains(C) && e.removeChild(C);
690
+ for (const C of b)
691
+ !_.has(C) && e.contains(C) && e.removeChild(C);
681
692
  } else {
682
- const v = Math.min(
683
- b.length,
684
- h.length
693
+ const g = Math.min(
694
+ x.length,
695
+ v.length
685
696
  );
686
- for (let m = 0; m < v; m++) {
687
- const $ = b[m], _ = h[m], C = X(u[m], $, _, o);
688
- C !== u[m] && (e.insertBefore(C, u[m]), e.removeChild(u[m]));
697
+ for (let p = 0; p < g; p++) {
698
+ const _ = x[p], E = v[p], C = ae(b[p], _, E, o);
699
+ C !== b[p] && (e.insertBefore(C, b[p]), e.removeChild(b[p]));
689
700
  }
690
- for (let m = v; m < h.length; m++)
691
- e.insertBefore(P(h[m], o), w);
692
- for (let m = v; m < u.length; m++)
693
- e.removeChild(u[m]);
701
+ for (let p = g; p < v.length; p++)
702
+ e.insertBefore(M(v[p], o), w);
703
+ for (let p = g; p < b.length; p++)
704
+ e.removeChild(b[p]);
694
705
  }
695
706
  }
696
- for (const x of r) {
707
+ for (const h of r) {
697
708
  let w;
698
- if (x.tag === "#anchor") {
699
- const k = x.key, h = `${k}:start`, u = `${k}:end`;
700
- let g = l.get(h), b = l.get(u);
701
- const d = Array.isArray(x.children) ? x.children : [];
702
- if (g || (g = document.createTextNode(""), g.key = h), b || (b = document.createTextNode(""), b.key = u), x._startNode = g, x._endNode = b, !e.contains(g) || !e.contains(b)) {
703
- e.insertBefore(g, p);
704
- for (const v of d)
705
- e.insertBefore(P(v, o), p);
706
- e.insertBefore(b, p);
709
+ if (h.tag === "#anchor") {
710
+ const $ = h.key, v = `${$}:start`, b = `${$}:end`;
711
+ let y = f.get(v), x = f.get(b);
712
+ const c = Array.isArray(h.children) ? h.children : [];
713
+ if (y || (y = document.createTextNode(""), y.key = v), x || (x = document.createTextNode(""), x.key = b), h._startNode = y, h._endNode = x, !e.contains(y) || !e.contains(x)) {
714
+ e.insertBefore(y, d);
715
+ for (const g of c)
716
+ e.insertBefore(M(g, o), d);
717
+ e.insertBefore(x, d);
707
718
  } else
708
- c(
709
- g,
710
- b,
711
- a.get(k)?.children,
712
- d
719
+ l(
720
+ y,
721
+ x,
722
+ a.get($)?.children,
723
+ c
713
724
  );
714
- y(g, b), p = b.nextSibling;
725
+ m(y, x), d = x.nextSibling;
715
726
  continue;
716
727
  }
717
- if (x.key != null && l.has(x.key)) {
718
- const k = a.get(x.key);
719
- w = X(
720
- l.get(x.key),
721
- k,
722
- x,
728
+ if (h.key != null && f.has(h.key)) {
729
+ const $ = a.get(h.key);
730
+ w = ae(
731
+ f.get(h.key),
732
+ $,
733
+ h,
723
734
  o,
724
735
  n
725
- ), f.add(w), w !== p && e.contains(w) && (p && !e.contains(p) && (p = null), e.insertBefore(w, p));
736
+ ), u.add(w), w !== d && e.contains(w) && (d && !e.contains(d) && (d = null), e.insertBefore(w, d));
726
737
  } else
727
- w = P(x, o, n), p && !e.contains(p) && (p = null), e.insertBefore(w, p), f.add(w);
728
- p = w.nextSibling;
738
+ w = M(h, o, n), d && !e.contains(d) && (d = null), e.insertBefore(w, d), u.add(w);
739
+ d = w.nextSibling;
729
740
  }
730
- for (const x of s)
731
- !f.has(x) && e.contains(x) && (q(x, n), e.removeChild(x));
741
+ for (const h of i)
742
+ !u.has(h) && e.contains(h) && (V(h, n), e.removeChild(h));
732
743
  }
733
- function X(e, t, r, o, n) {
734
- if (t && typeof t != "string" && t.props?.ref && n && q(e, n), t === r) return e;
744
+ function ae(e, t, r, o, n) {
745
+ if (t && typeof t != "string" && t.props?.ref && n && V(e, n), t === r) return e;
735
746
  if (typeof r == "string") {
736
747
  if (e.nodeType === Node.TEXT_NODE)
737
748
  return e.textContent !== r && (e.textContent = r), e;
738
749
  {
739
- const i = document.createTextNode(r);
740
- return e.parentNode?.replaceChild(i, e), i;
750
+ const s = document.createTextNode(r);
751
+ return e.parentNode?.replaceChild(s, e), s;
741
752
  }
742
753
  }
743
754
  if (r && typeof r != "string" && r.tag === "#anchor") {
744
- const i = r, a = Array.isArray(i.children) ? i.children : [], l = i._startNode ?? document.createTextNode(""), f = i._endNode ?? document.createTextNode("");
745
- i.key != null && (l.key = `${i.key}:start`, f.key = `${i.key}:end`), i._startNode = l, i._endNode = f;
746
- const p = document.createDocumentFragment();
747
- p.appendChild(l);
748
- for (const y of a) {
749
- const c = P(y, o);
750
- p.appendChild(c);
755
+ const s = r, a = Array.isArray(s.children) ? s.children : [], f = s._startNode ?? document.createTextNode(""), u = s._endNode ?? document.createTextNode("");
756
+ s.key != null && (f.key = `${s.key}:start`, u.key = `${s.key}:end`), s._startNode = f, s._endNode = u;
757
+ const d = document.createDocumentFragment();
758
+ d.appendChild(f);
759
+ for (const m of a) {
760
+ const l = M(m, o);
761
+ d.appendChild(l);
751
762
  }
752
- return p.appendChild(f), e.parentNode?.replaceChild(p, e), l;
763
+ return d.appendChild(u), e.parentNode?.replaceChild(d, e), f;
753
764
  }
754
765
  if (!r) {
755
- q(e, n);
756
- const i = document.createComment("removed");
757
- return e.parentNode?.replaceChild(i, e), i;
766
+ V(e, n);
767
+ const s = document.createComment("removed");
768
+ return e.parentNode?.replaceChild(s, e), s;
758
769
  }
759
770
  if (!t || typeof t == "string") {
760
- q(e, n);
761
- const i = P(r, o, n);
762
- return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = i), e.parentNode?.replaceChild(i, e), i;
771
+ V(e, n);
772
+ const s = M(r, o, n);
773
+ return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
763
774
  }
764
775
  if (r.tag === "#anchor") {
765
- const i = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), l = r._endNode ?? document.createTextNode("");
766
- r.key != null && (a.key = `${r.key}:start`, l.key = `${r.key}:end`), r._startNode = a, r._endNode = l;
767
- const f = document.createDocumentFragment();
768
- f.appendChild(a);
769
- for (const p of i)
770
- f.appendChild(P(p, o));
771
- return f.appendChild(l), e.parentNode?.replaceChild(f, e), a;
776
+ const s = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), f = r._endNode ?? document.createTextNode("");
777
+ r.key != null && (a.key = `${r.key}:start`, f.key = `${r.key}:end`), r._startNode = a, r._endNode = f;
778
+ const u = document.createDocumentFragment();
779
+ u.appendChild(a);
780
+ for (const d of s)
781
+ u.appendChild(M(d, o));
782
+ return u.appendChild(f), e.parentNode?.replaceChild(u, e), a;
772
783
  }
773
784
  if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
774
- const i = e;
775
- return Ke(i, t.props || {}, r.props || {}, o), Ve(i, t.children, r.children, o, n), typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = i), i;
785
+ const s = e;
786
+ return Je(s, t.props || {}, r.props || {}, o), Ze(s, t.children, r.children, o, n), typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = s), s;
776
787
  }
777
- q(e, n);
778
- const s = P(r, o, n);
779
- return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
788
+ V(e, n);
789
+ const i = M(r, o, n);
790
+ return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = i), e.parentNode?.replaceChild(i, e), i;
780
791
  }
781
- function Je(e, t, r, o) {
792
+ function Ye(e, t, r, o) {
782
793
  let n;
783
794
  Array.isArray(t) ? t.length === 1 ? (n = t[0], n && typeof n == "object" && n.key == null && (n = { ...n, key: "__root__" })) : n = { tag: "div", key: "__root__", children: t } : (n = t, n && typeof n == "object" && n.key == null && (n = { ...n, key: "__root__" })), n && typeof n == "object" && n.tag === "#anchor" && (n = {
784
795
  tag: "div",
785
796
  key: "__anchor_root__",
786
797
  props: { attrs: { "data-anchor-block-root": "", key: "__anchor_root__" } },
787
798
  children: [n]
788
- }), n = ge(n, String(n.key ?? "root"));
789
- const s = e._prevVNode ?? null, i = e._prevDom ?? e.firstChild ?? null;
799
+ }), n = ke(n, String(n.key ?? "root"));
800
+ const i = e._prevVNode ?? null, s = e._prevDom ?? e.firstChild ?? null;
790
801
  let a;
791
- s && i ? typeof s != "string" && typeof n != "string" && s.tag === n.tag && s.key === n.key ? a = X(i, s, n, r, o) : (a = P(n, r, o), e.replaceChild(a, i)) : (a = P(n, r, o), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
792
- const l = [];
793
- for (let f = 0; f < e.childNodes.length; f++) {
794
- const p = e.childNodes[f];
795
- p !== a && p.nodeName !== "STYLE" && (q(p, o), l.push(p));
796
- }
797
- l.forEach((f) => e.removeChild(f)), e._prevVNode = n, e._prevDom = a;
802
+ i && s ? typeof i != "string" && typeof n != "string" && i.tag === n.tag && i.key === n.key ? a = ae(s, i, n, r, o) : (a = M(n, r, o), e.replaceChild(a, s)) : (a = M(n, r, o), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
803
+ const f = [];
804
+ for (let u = 0; u < e.childNodes.length; u++) {
805
+ const d = e.childNodes[u];
806
+ d !== a && d.nodeName !== "STYLE" && (V(d, o), f.push(d));
807
+ }
808
+ f.forEach((u) => e.removeChild(u)), e._prevVNode = n, e._prevDom = a;
809
+ }
810
+ function he(e) {
811
+ if (typeof e == "string") return H(e);
812
+ if (e.tag === "#text")
813
+ return typeof e.children == "string" ? H(e.children) : "";
814
+ if (e.tag === "#anchor")
815
+ return (Array.isArray(e.children) ? e.children.filter(Boolean) : []).map(he).join("");
816
+ let t = "";
817
+ e.props && e.props.attrs && (t = Object.entries(e.props.attrs).map(([n, i]) => ` ${n}="${H(String(i))}"`).join(""));
818
+ let r = "";
819
+ e.props && (r = Object.entries(e.props).filter(([n]) => n !== "attrs" && n !== "directives" && n !== "ref" && n !== "key").map(([n, i]) => ` ${n}="${H(String(i))}"`).join(""));
820
+ const o = Array.isArray(e.children) ? e.children.filter(Boolean).map(he).join("") : typeof e.children == "string" ? H(e.children) : e.children ? he(e.children) : "";
821
+ return `<${e.tag}${t}${r}>${o}</${e.tag}>`;
798
822
  }
799
- function je(e, ...t) {
823
+ function ze(e, ...t) {
800
824
  let r = "";
801
825
  for (let o = 0; o < e.length; o++)
802
826
  r += e[o], o < t.length && (r += t[o]);
803
827
  return r;
804
828
  }
805
- function Le(e) {
829
+ function Be(e) {
806
830
  return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
807
831
  }
808
- let Y = null;
809
- function ke() {
810
- return Y || (Y = new CSSStyleSheet(), Y.replaceSync(Le(Ye))), Y;
832
+ let oe = null;
833
+ function _e() {
834
+ return oe || (oe = new CSSStyleSheet(), oe.replaceSync(Be(Qe))), oe;
811
835
  }
812
- function Ze(e) {
836
+ function Ge(e) {
813
837
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
814
838
  }
815
- const Ye = je`
839
+ const Qe = ze`
816
840
  :host, *, ::before, ::after {
817
841
  all: isolate;
818
842
  box-sizing: border-box;
@@ -870,7 +894,7 @@ const Ye = je`
870
894
  sup { top: -.5em }
871
895
  [disabled], [aria-disabled=true] { cursor: not-allowed }
872
896
  [hidden] { display: none }
873
- `, Qe = {
897
+ `, Xe = {
874
898
  gray: {
875
899
  50: "var(--color-gray-50, #f9fafb)",
876
900
  100: "var(--color-gray-100, #f3f4f6)",
@@ -1007,7 +1031,7 @@ const Ye = je`
1007
1031
  black: { DEFAULT: "var(--color-black, #000000)" },
1008
1032
  transparent: { DEFAULT: "var(--color-transparent, transparent)" },
1009
1033
  current: { DEFAULT: "var(--color-current, currentColor)" }
1010
- }, se = {
1034
+ }, ge = {
1011
1035
  /* Display */
1012
1036
  block: "display:block;",
1013
1037
  inline: "display:inline;",
@@ -1184,7 +1208,7 @@ const Ye = je`
1184
1208
  "z-30": "z-index:30;",
1185
1209
  "z-40": "z-index:40;",
1186
1210
  "z-50": "z-index:50;"
1187
- }, Xe = "0.25rem", $e = {
1211
+ }, et = "0.25rem", Se = {
1188
1212
  m: ["margin"],
1189
1213
  mx: ["margin-inline"],
1190
1214
  my: ["margin-block"],
@@ -1216,34 +1240,34 @@ const Ye = je`
1216
1240
  "gap-x": ["column-gap"],
1217
1241
  "gap-y": ["row-gap"]
1218
1242
  };
1219
- function B(e, t) {
1243
+ function P(e, t) {
1220
1244
  let r = 0, o = 0;
1221
1245
  for (let n = 0; n < e.length; n++) {
1222
- const s = e[n];
1223
- if (s === "[") r++;
1224
- else if (s === "]" && r > 0) r--;
1225
- else if (s === "(") o++;
1226
- else if (s === ")" && o > 0) o--;
1227
- else if (r === 0 && o === 0 && (s === ">" || s === "+" || s === "~" || s === " "))
1246
+ const i = e[n];
1247
+ if (i === "[") r++;
1248
+ else if (i === "]" && r > 0) r--;
1249
+ else if (i === "(") o++;
1250
+ else if (i === ")" && o > 0) o--;
1251
+ else if (r === 0 && o === 0 && (i === ">" || i === "+" || i === "~" || i === " "))
1228
1252
  return e.slice(0, n) + t + e.slice(n);
1229
1253
  }
1230
1254
  return e + t;
1231
1255
  }
1232
- const Ge = {
1256
+ const tt = {
1233
1257
  before: (e, t) => `${e}::before{${t}}`,
1234
1258
  after: (e, t) => `${e}::after{${t}}`,
1235
- hover: (e, t) => `${B(e, ":hover")}{${t}}`,
1236
- focus: (e, t) => `${B(e, ":focus")}{${t}}`,
1237
- active: (e, t) => `${B(e, ":active")}{${t}}`,
1238
- disabled: (e, t) => `${B(e, ":disabled")}{${t}}`,
1239
- visited: (e, t) => `${B(e, ":visited")}{${t}}`,
1240
- checked: (e, t) => `${B(e, ":checked")}{${t}}`,
1241
- first: (e, t) => `${B(e, ":first-child")}{${t}}`,
1242
- last: (e, t) => `${B(e, ":last-child")}{${t}}`,
1243
- odd: (e, t) => `${B(e, ":nth-child(odd)")}{${t}}`,
1244
- even: (e, t) => `${B(e, ":nth-child(even)")}{${t}}`,
1245
- "focus-within": (e, t) => `${B(e, ":focus-within")}{${t}}`,
1246
- "focus-visible": (e, t) => `${B(e, ":focus-visible")}{${t}}`,
1259
+ hover: (e, t) => `${P(e, ":hover")}{${t}}`,
1260
+ focus: (e, t) => `${P(e, ":focus")}{${t}}`,
1261
+ active: (e, t) => `${P(e, ":active")}{${t}}`,
1262
+ disabled: (e, t) => `${P(e, ":disabled")}{${t}}`,
1263
+ visited: (e, t) => `${P(e, ":visited")}{${t}}`,
1264
+ checked: (e, t) => `${P(e, ":checked")}{${t}}`,
1265
+ first: (e, t) => `${P(e, ":first-child")}{${t}}`,
1266
+ last: (e, t) => `${P(e, ":last-child")}{${t}}`,
1267
+ odd: (e, t) => `${P(e, ":nth-child(odd)")}{${t}}`,
1268
+ even: (e, t) => `${P(e, ":nth-child(even)")}{${t}}`,
1269
+ "focus-within": (e, t) => `${P(e, ":focus-within")}{${t}}`,
1270
+ "focus-visible": (e, t) => `${P(e, ":focus-visible")}{${t}}`,
1247
1271
  "group-hover": (e, t) => `.group:hover ${e}{${t}}`,
1248
1272
  "group-focus": (e, t) => `.group:focus ${e}{${t}}`,
1249
1273
  "group-active": (e, t) => `.group:active ${e}{${t}}`,
@@ -1252,7 +1276,7 @@ const Ge = {
1252
1276
  "peer-focus": (e, t) => `.peer:focus ~ ${e}{${t}}`,
1253
1277
  "peer-checked": (e, t) => `.peer:checked ~ ${e}{${t}}`,
1254
1278
  "peer-disabled": (e, t) => `.peer:disabled ~ ${e}{${t}}`
1255
- }, ae = {
1279
+ }, ye = {
1256
1280
  // Responsive
1257
1281
  sm: "(min-width:640px)",
1258
1282
  md: "(min-width:768px)",
@@ -1261,24 +1285,24 @@ const Ge = {
1261
1285
  "2xl": "(min-width:1536px)",
1262
1286
  // Dark mode (now plain string)
1263
1287
  dark: "(prefers-color-scheme: dark)"
1264
- }, ce = ["sm", "md", "lg", "xl", "2xl"];
1265
- function le(e) {
1288
+ }, me = ["sm", "md", "lg", "xl", "2xl"];
1289
+ function be(e) {
1266
1290
  const t = e.startsWith("-"), o = (t ? e.slice(1) : e).split("-");
1267
1291
  if (o.length < 2) return null;
1268
- const n = o.slice(0, -1).join("-"), s = o[o.length - 1], i = parseFloat(s);
1269
- if (Number.isNaN(i) || !$e[n]) return null;
1292
+ const n = o.slice(0, -1).join("-"), i = o[o.length - 1], s = parseFloat(i);
1293
+ if (Number.isNaN(s) || !Se[n]) return null;
1270
1294
  const a = t ? "-" : "";
1271
- return $e[n].map((l) => `${l}:calc(${a}${Xe} * ${i});`).join("");
1295
+ return Se[n].map((f) => `${f}:calc(${a}${et} * ${s});`).join("");
1272
1296
  }
1273
- function Se(e) {
1274
- const t = e.replace("#", ""), r = parseInt(t, 16), o = r >> 16 & 255, n = r >> 8 & 255, s = r & 255;
1275
- return `${o} ${n} ${s}`;
1297
+ function Ce(e) {
1298
+ const t = e.replace("#", ""), r = parseInt(t, 16), o = r >> 16 & 255, n = r >> 8 & 255, i = r & 255;
1299
+ return `${o} ${n} ${i}`;
1276
1300
  }
1277
- function et(e) {
1301
+ function rt(e) {
1278
1302
  const t = /^(bg|text|border|decoration|shadow|outline|caret|accent|fill|stroke)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1279
1303
  if (!t) return null;
1280
- const [, r, o, n = "DEFAULT"] = t, s = Qe[o]?.[n];
1281
- return s ? `${{
1304
+ const [, r, o, n = "DEFAULT"] = t, i = Xe[o]?.[n];
1305
+ return i ? `${{
1282
1306
  bg: "background-color",
1283
1307
  decoration: "text-decoration-color",
1284
1308
  text: "color",
@@ -1290,49 +1314,49 @@ function et(e) {
1290
1314
  placeholder: "placeholder-color",
1291
1315
  fill: "fill-color",
1292
1316
  stroke: "stroke-color"
1293
- }[r]}:${s};` : null;
1317
+ }[r]}:${i};` : null;
1294
1318
  }
1295
- function tt(e) {
1319
+ function nt(e) {
1296
1320
  const [t, r] = e.split("/");
1297
1321
  if (!r) return { base: t };
1298
1322
  const o = parseInt(r, 10);
1299
1323
  return isNaN(o) || o < 0 || o > 100 ? { base: t } : { base: t, opacity: o / 100 };
1300
1324
  }
1301
- function fe(e) {
1302
- const { base: t, opacity: r } = tt(e), o = et(t);
1325
+ function ve(e) {
1326
+ const { base: t, opacity: r } = nt(e), o = rt(t);
1303
1327
  if (o) {
1304
1328
  if (r !== void 0) {
1305
- const s = /#([0-9a-f]{6})/i.exec(o);
1306
- if (s) {
1307
- const i = Se(s[0]);
1308
- return o.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${r})`);
1329
+ const i = /#([0-9a-f]{6})/i.exec(o);
1330
+ if (i) {
1331
+ const s = Ce(i[0]);
1332
+ return o.replace(/#([0-9a-f]{6})/i, `rgb(${s} / ${r})`);
1309
1333
  }
1310
1334
  }
1311
1335
  return o;
1312
1336
  }
1313
- const n = G(t);
1337
+ const n = le(t);
1314
1338
  if (n && r !== void 0) {
1315
- const s = /#([0-9a-f]{6})/i.exec(n);
1316
- if (s) {
1317
- const i = Se(s[0]);
1318
- return n.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${r})`);
1339
+ const i = /#([0-9a-f]{6})/i.exec(n);
1340
+ if (i) {
1341
+ const s = Ce(i[0]);
1342
+ return n.replace(/#([0-9a-f]{6})/i, `rgb(${s} / ${r})`);
1319
1343
  }
1320
1344
  }
1321
1345
  return n;
1322
1346
  }
1323
- function ue(e) {
1347
+ function xe(e) {
1324
1348
  const t = /^opacity-(\d{1,3})$/.exec(e);
1325
1349
  if (!t) return null;
1326
1350
  const r = parseInt(t[1], 10);
1327
1351
  return r < 0 || r > 100 ? null : `opacity:${r / 100};`;
1328
1352
  }
1329
- function G(e) {
1353
+ function le(e) {
1330
1354
  if (e.startsWith("[") && e.endsWith("]") && !e.includes("-[")) {
1331
1355
  const n = e.slice(1, -1).trim().match(/^([a-zA-Z][a-zA-Z0-9-]*)\s*:(.*)$/);
1332
1356
  if (n) {
1333
- const s = n[1].trim();
1334
- let i = n[2].trim();
1335
- return i = i.replace(/url\('\s*([^']*?)\s*'\)/g, 'url("$1")'), i = i.replace(/^'([^']*)'$/g, '"$1"'), `${s}:${i};`;
1357
+ const i = n[1].trim();
1358
+ let s = n[2].trim();
1359
+ return s = s.replace(/url\('\s*([^']*?)\s*'\)/g, 'url("$1")'), s = s.replace(/^'([^']*)'$/g, '"$1"'), `${i}:${s};`;
1336
1360
  }
1337
1361
  return null;
1338
1362
  }
@@ -1341,7 +1365,7 @@ function G(e) {
1341
1365
  const o = e.slice(0, t);
1342
1366
  let n = e.slice(t + 2, -1);
1343
1367
  n = n.replace(/_/g, " ");
1344
- const s = {
1368
+ const i = {
1345
1369
  bg: "background-color",
1346
1370
  text: "color",
1347
1371
  shadow: "box-shadow",
@@ -1385,12 +1409,12 @@ function G(e) {
1385
1409
  };
1386
1410
  if (o === "rotate")
1387
1411
  return `transform:rotate(${n});`;
1388
- const i = s[o] ?? o.replace(/_/g, "-");
1389
- if (i && n) return `${i}:${n};`;
1412
+ const s = i[o] ?? o.replace(/_/g, "-");
1413
+ if (s && n) return `${s}:${n};`;
1390
1414
  }
1391
1415
  return null;
1392
1416
  }
1393
- function rt(e) {
1417
+ function ot(e) {
1394
1418
  if (e.startsWith("[") && e.endsWith("]")) {
1395
1419
  const r = e.slice(1, -1);
1396
1420
  return r.includes("&") ? r : e;
@@ -1402,10 +1426,10 @@ function rt(e) {
1402
1426
  }
1403
1427
  return null;
1404
1428
  }
1405
- function nt(e) {
1429
+ function it(e) {
1406
1430
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1407
1431
  }
1408
- function ot(e) {
1432
+ function st(e) {
1409
1433
  const t = /class\s*=\s*(['"])(.*?)\1/g, r = [];
1410
1434
  let o;
1411
1435
  for (; o = t.exec(e); ) {
@@ -1414,32 +1438,32 @@ function ot(e) {
1414
1438
  }
1415
1439
  return r.filter(Boolean);
1416
1440
  }
1417
- const _e = /* @__PURE__ */ new Map(), it = 16;
1418
- function st(e) {
1419
- const t = Date.now(), r = _e.get(e);
1420
- if (r && t - r.timestamp < it) return r.css;
1421
- const o = ot(e), n = new Set(o), s = [], i = [], a = [], l = [], f = {};
1422
- function p(h, u = !1) {
1423
- const g = (u ? "dark|" : "") + h;
1424
- if (g in f) return f[g];
1425
- const b = w(h, u);
1426
- return f[g] = b, b;
1427
- }
1428
- function y(h) {
1429
- const u = h.some((b) => ce.includes(b)), g = h.includes("dark");
1430
- return h.length === 0 ? 1 : !u && !g ? 2 : u && !g ? 3 : 4;
1431
- }
1432
- function c(h) {
1433
- const u = [];
1434
- let g = "", b = 0, d = 0;
1435
- for (let v = 0; v < h.length; v++) {
1436
- const m = h[v];
1437
- m === "[" ? b++ : m === "]" && b > 0 ? b-- : m === "(" ? d++ : m === ")" && d > 0 && d--, m === ":" && b === 0 && d === 0 ? (u.push(g), g = "") : g += m;
1441
+ const Ee = /* @__PURE__ */ new Map(), at = 16;
1442
+ function lt(e) {
1443
+ const t = Date.now(), r = Ee.get(e);
1444
+ if (r && t - r.timestamp < at) return r.css;
1445
+ const o = st(e), n = new Set(o), i = [], s = [], a = [], f = [], u = {};
1446
+ function d(v, b = !1) {
1447
+ const y = (b ? "dark|" : "") + v;
1448
+ if (y in u) return u[y];
1449
+ const x = w(v, b);
1450
+ return u[y] = x, x;
1451
+ }
1452
+ function m(v) {
1453
+ const b = v.some((x) => me.includes(x)), y = v.includes("dark");
1454
+ return v.length === 0 ? 1 : !b && !y ? 2 : b && !y ? 3 : 4;
1455
+ }
1456
+ function l(v) {
1457
+ const b = [];
1458
+ let y = "", x = 0, c = 0;
1459
+ for (let g = 0; g < v.length; g++) {
1460
+ const p = v[g];
1461
+ p === "[" ? x++ : p === "]" && x > 0 ? x-- : p === "(" ? c++ : p === ")" && c > 0 && c--, p === ":" && x === 0 && c === 0 ? (b.push(y), y = "") : y += p;
1438
1462
  }
1439
- return g && u.push(g), u;
1463
+ return y && b.push(y), b;
1440
1464
  }
1441
- function x(h) {
1442
- switch (h) {
1465
+ function h(v) {
1466
+ switch (v) {
1443
1467
  case "hover":
1444
1468
  return ":hover";
1445
1469
  case "focus":
@@ -1468,207 +1492,210 @@ function st(e) {
1468
1492
  return null;
1469
1493
  }
1470
1494
  }
1471
- function w(h, u = !1) {
1472
- const g = c(h);
1473
- (h.includes("mask-image") || h.includes("sm: hover") || h.includes("sm:hover") || h.includes("mask.svg")) && console.error("DEBUG generateRule:", h, g);
1474
- let b = !1;
1475
- const d = g.find((S) => (S.startsWith("!") && (b = !0, S = S.slice(1)), se[S] || le(S) || ue(S) || fe(S) || G(S)));
1476
- if (!d) return null;
1477
- const v = d.replace(/^!/, ""), m = se[v] ?? le(v) ?? ue(v) ?? fe(v) ?? G(v);
1478
- if (!m) return null;
1479
- const $ = g.indexOf(d);
1480
- let _ = $ >= 0 ? g.slice(0, $) : [];
1481
- u && (_ = _.filter((S) => S !== "dark"));
1482
- const C = `.${nt(h)}`, E = "__SUBJECT__", j = b ? m.replace(/;$/, " !important;") : m;
1483
- let A = E;
1484
- const re = [];
1485
- for (const S of _)
1486
- S.startsWith("group-") ? (A = `.group:${S.slice(6)} ${A}`, re.push(S)) : S.startsWith("peer-") && (A = A.replace(E, `.peer:${S.slice(5)}~${E}`), re.push(S));
1487
- _ = _.filter((S) => !re.includes(S));
1488
- const ne = [], be = [];
1489
- let W = null;
1490
- for (const S of _) {
1491
- if (S === "dark" || ce.includes(S)) continue;
1492
- const M = rt(S);
1493
- if (M) {
1494
- W = M;
1495
+ function w(v, b = !1) {
1496
+ const y = l(v);
1497
+ let x = !1;
1498
+ const c = y.find((k) => (k.startsWith("!") && (x = !0, k = k.slice(1)), ge[k] || be(k) || xe(k) || ve(k) || le(k)));
1499
+ if (!c) return null;
1500
+ const g = c.replace(/^!/, ""), p = ge[g] ?? be(g) ?? xe(g) ?? ve(g) ?? le(g);
1501
+ if (!p) return null;
1502
+ const _ = y.indexOf(c);
1503
+ let E = _ >= 0 ? y.slice(0, _) : [];
1504
+ b && (E = E.filter((k) => k !== "dark"));
1505
+ const C = `.${it(v)}`, S = "__SUBJECT__", A = x ? p.replace(/;$/, " !important;") : p;
1506
+ let T = S;
1507
+ const Q = [];
1508
+ for (const k of E)
1509
+ k.startsWith("group-") ? (T = `.group:${k.slice(6)} ${T}`, Q.push(k)) : k.startsWith("peer-") && (T = T.replace(S, `.peer:${k.slice(5)}~${S}`), Q.push(k));
1510
+ E = E.filter((k) => !Q.includes(k));
1511
+ const X = [], de = [];
1512
+ let q = null;
1513
+ for (const k of E) {
1514
+ if (k === "dark" || me.includes(k)) continue;
1515
+ const B = ot(k);
1516
+ if (B) {
1517
+ q = B;
1495
1518
  continue;
1496
1519
  }
1497
- const L = x(S);
1498
- if (L) {
1499
- W ? be.push(L) : ne.push(L);
1520
+ const z = h(k);
1521
+ if (z) {
1522
+ q ? de.push(z) : X.push(z);
1500
1523
  continue;
1501
1524
  }
1502
- const R = Ge[S];
1503
- typeof R == "function" && (A = R(A, j).split("{")[0]);
1525
+ const O = tt[k];
1526
+ typeof O == "function" && (T = O(T, A).split("{")[0]);
1504
1527
  }
1505
- function ze(S, M) {
1506
- if (!M) return S;
1507
- let L = 0, R = 0;
1508
- if (S.length && (S[0] === ">" || S[0] === "+" || S[0] === "~" || S[0] === " ")) {
1509
- let T = 1;
1510
- for (; T < S.length && S[T] === " "; ) T++;
1511
- for (; T < S.length; T++) {
1512
- const z = S[T];
1513
- if (z === "[" ? L++ : z === "]" && L > 0 ? L-- : z === "(" ? R++ : z === ")" && R > 0 && R--, L === 0 && R === 0 && (S[T] === ">" || S[T] === "+" || S[T] === "~" || S[T] === " "))
1514
- return S.slice(0, T) + M + S.slice(T);
1528
+ function I(k, B) {
1529
+ if (!B) return k;
1530
+ let z = 0, O = 0;
1531
+ if (k.length && (k[0] === ">" || k[0] === "+" || k[0] === "~" || k[0] === " ")) {
1532
+ let j = 1;
1533
+ for (; j < k.length && k[j] === " "; ) j++;
1534
+ for (; j < k.length; j++) {
1535
+ const R = k[j];
1536
+ if (R === "[" ? z++ : R === "]" && z > 0 ? z-- : R === "(" ? O++ : R === ")" && O > 0 && O--, z === 0 && O === 0 && (k[j] === ">" || k[j] === "+" || k[j] === "~" || k[j] === " "))
1537
+ return k.slice(0, j) + B + k.slice(j);
1515
1538
  }
1516
- return S + M;
1539
+ return k + B;
1517
1540
  }
1518
- for (let T = 0; T < S.length; T++) {
1519
- const z = S[T];
1520
- if (z === "[" ? L++ : z === "]" && L > 0 ? L-- : z === "(" ? R++ : z === ")" && R > 0 && R--, L === 0 && R === 0 && (z === ">" || z === "+" || z === "~" || z === " "))
1521
- return S.slice(0, T) + M + S.slice(T);
1541
+ for (let j = 0; j < k.length; j++) {
1542
+ const R = k[j];
1543
+ if (R === "[" ? z++ : R === "]" && z > 0 ? z-- : R === "(" ? O++ : R === ")" && O > 0 && O--, z === 0 && O === 0 && (R === ">" || R === "+" || R === "~" || R === " "))
1544
+ return k.slice(0, j) + B + k.slice(j);
1522
1545
  }
1523
- return S + M;
1546
+ return k + B;
1524
1547
  }
1525
- const oe = ne.join(""), K = be.join("");
1526
- if (W)
1527
- if (W.includes("&")) {
1528
- const S = W.indexOf("&"), M = W.slice(0, S), L = W.slice(S + 1), R = E + oe, T = A;
1529
- if (ne.length === 0)
1530
- A = T.replace(E, M + R + K + L);
1548
+ const Z = X.join(""), F = de.join("");
1549
+ if (q)
1550
+ if (q.includes("&")) {
1551
+ const k = q.indexOf("&"), B = q.slice(0, k), z = q.slice(k + 1), O = S + Z, j = T;
1552
+ if (X.length === 0)
1553
+ T = j.replace(S, B + O + F + z);
1531
1554
  else {
1532
- const z = ze(L, K);
1533
- A = T.replace(E, M + R + z);
1555
+ const R = I(z, F);
1556
+ T = j.replace(S, B + O + R);
1534
1557
  }
1535
1558
  } else
1536
- A = A.replace(E, `${W}${E + oe}`), K && (A = A.replace(E, `${E}${K}`));
1559
+ T = T.replace(S, `${q}${S + Z}`), F && (T = T.replace(S, `${S}${F}`));
1537
1560
  else
1538
- A = E + oe + K;
1539
- A = A.replace(new RegExp(E, "g"), C);
1540
- let O = `${A}{${j}}`;
1541
- const ie = _.filter((S) => ce.includes(S)), H = ie.length ? ie[ie.length - 1] : null, ve = _.includes("dark");
1542
- return u && H ? O = `@media (prefers-color-scheme: dark) and ${ae[H]}{${O}}` : u ? O = `@media (prefers-color-scheme: dark){${O}}` : ve && H ? O = `@media (prefers-color-scheme: dark) and ${ae[H]}{${O}}` : ve ? O = `@media (prefers-color-scheme: dark){${O}}` : H && (O = `@media ${ae[H]}{${O}}`), O;
1543
- }
1544
- for (const h of n) {
1545
- const u = c(h), g = u.find(
1546
- (m) => se[m] || le(m) || ue(m) || fe(m) || G(m)
1561
+ T = S + Z + F;
1562
+ T = T.replace(new RegExp(S, "g"), C);
1563
+ let L = `${T}{${A}}`;
1564
+ const K = E.filter((k) => me.includes(k)), D = K.length ? K[K.length - 1] : null, ne = E.includes("dark");
1565
+ return b && D ? L = `@media (prefers-color-scheme: dark) and ${ye[D]}{${L}}` : b ? L = `@media (prefers-color-scheme: dark){${L}}` : ne && D ? L = `@media (prefers-color-scheme: dark) and ${ye[D]}{${L}}` : ne ? L = `@media (prefers-color-scheme: dark){${L}}` : D && (L = `@media ${ye[D]}{${L}}`), L;
1566
+ }
1567
+ for (const v of n) {
1568
+ const b = l(v), y = b.find(
1569
+ (p) => ge[p] || be(p) || xe(p) || ve(p) || le(p)
1547
1570
  );
1548
- if (!g) continue;
1549
- const b = u.indexOf(g), d = b >= 0 ? u.slice(0, b) : [], v = y(d);
1550
- if (v === 4) {
1551
- const m = p(h, !0);
1552
- m && l.push(m);
1571
+ if (!y) continue;
1572
+ const x = b.indexOf(y), c = x >= 0 ? b.slice(0, x) : [], g = m(c);
1573
+ if (g === 4) {
1574
+ const p = d(v, !0);
1575
+ p && f.push(p);
1553
1576
  } else {
1554
- const m = p(h);
1555
- m && (v === 1 ? s.push(m) : v === 2 ? i.push(m) : v === 3 && a.push(m));
1577
+ const p = d(v);
1578
+ p && (g === 1 ? i.push(p) : g === 2 ? s.push(p) : g === 3 && a.push(p));
1556
1579
  }
1557
1580
  }
1558
- const k = [...s, ...i, ...a, ...l].join("");
1559
- return _e.set(e, { css: k, timestamp: t }), k;
1581
+ const $ = [...i, ...s, ...a, ...f].join("");
1582
+ return Ee.set(e, { css: $, timestamp: t }), $;
1560
1583
  }
1561
- const J = [];
1562
- function at(e, t, r, o, n, s, i, a) {
1584
+ const te = [];
1585
+ function ct(e, t, r, o, n, i, s, a) {
1563
1586
  if (e) {
1564
- J.push(r);
1587
+ te.push(r);
1565
1588
  try {
1566
1589
  if (t.loadingTemplate && r.isLoading) {
1567
- F(e, t.loadingTemplate(r), r, o, n);
1590
+ Y(e, t.loadingTemplate(r), r, o, n);
1568
1591
  return;
1569
1592
  }
1570
1593
  if (t.errorTemplate && r.hasError) {
1571
- r.error instanceof Error && F(e, t.errorTemplate(r.error, r), r, o, n);
1594
+ r.error instanceof Error && Y(e, t.errorTemplate(r.error, r), r, o, n);
1572
1595
  return;
1573
1596
  }
1574
- const l = t.render(r);
1575
- if (l instanceof Promise) {
1576
- s(!0), l.then((f) => {
1577
- s(!1), i(null), F(e, f, r, o, n), a(e.innerHTML);
1578
- }).catch((f) => {
1579
- s(!1), i(f), t.errorTemplate && F(e, t.errorTemplate(f, r), r, o, n);
1580
- }), t.loadingTemplate && F(e, t.loadingTemplate(r), r, o, n);
1597
+ const f = t.render(r);
1598
+ if (f instanceof Promise) {
1599
+ i(!0), f.then((u) => {
1600
+ i(!1), s(null), Y(e, u, r, o, n), a(e.innerHTML);
1601
+ }).catch((u) => {
1602
+ i(!1), s(u), t.errorTemplate && Y(e, t.errorTemplate(u, r), r, o, n);
1603
+ }), t.loadingTemplate && Y(e, t.loadingTemplate(r), r, o, n);
1581
1604
  return;
1582
1605
  }
1583
- F(e, l, r, o, n), a(e.innerHTML);
1606
+ Y(e, f, r, o, n), a(e.innerHTML);
1584
1607
  } finally {
1585
- J.pop();
1608
+ te.pop();
1586
1609
  }
1587
1610
  }
1588
1611
  }
1589
- function F(e, t, r, o, n) {
1590
- e && (Je(
1612
+ function Y(e, t, r, o, n) {
1613
+ e && (Ye(
1591
1614
  e,
1592
1615
  Array.isArray(t) ? t : [t],
1593
1616
  r,
1594
1617
  o
1595
1618
  ), n(e.innerHTML));
1596
1619
  }
1597
- function ct(e, t, r, o, n, s, i) {
1598
- if (s !== null && clearTimeout(s), Date.now() - t < 16) {
1620
+ function ft(e, t, r, o, n, i, s) {
1621
+ if (i !== null && clearTimeout(i), Date.now() - t < 16) {
1599
1622
  if (n(r + 1), r > 10) {
1600
- console.warn("Potential infinite render loop detected. Skipping render."), i(null);
1623
+ s(null);
1601
1624
  return;
1602
1625
  }
1603
1626
  } else
1604
1627
  n(0);
1605
- const l = setTimeout(() => {
1606
- o(Date.now()), e(), i(null);
1628
+ const f = setTimeout(() => {
1629
+ o(Date.now()), e(), s(null);
1607
1630
  }, 0);
1608
- i(l);
1631
+ s(f);
1609
1632
  }
1610
- function lt(e, t, r, o, n, s) {
1633
+ function ut(e, t, r, o, n, i) {
1611
1634
  if (!e) return;
1612
- const i = st(o);
1613
- if (!t.style && (!i || i.trim() === "")) {
1614
- s(null), e.adoptedStyleSheets = [ke()];
1635
+ const s = lt(o);
1636
+ if (!t.style && (!s || s.trim() === "")) {
1637
+ i(null), e.adoptedStyleSheets = [_e()];
1615
1638
  return;
1616
1639
  }
1617
1640
  let a = "";
1618
1641
  t.style && (typeof t.style == "string" ? a = t.style : typeof t.style == "function" && (a = t.style(r)));
1619
- let l = Ze(`${a}
1620
- ${i}
1642
+ let f = Ge(`${a}
1643
+ ${s}
1621
1644
  `);
1622
- l = Le(l);
1623
- let f = n;
1624
- f || (f = new CSSStyleSheet()), (f.cssRules.length === 0 || f.toString() !== l) && f.replaceSync(l), e.adoptedStyleSheets = [ke(), f], s(f);
1645
+ f = Be(f);
1646
+ let u = n;
1647
+ u || (u = new CSSStyleSheet()), (u.cssRules.length === 0 || u.toString() !== f) && u.replaceSync(f), e.adoptedStyleSheets = [_e(), u], i(u);
1648
+ }
1649
+ const ue = /* @__PURE__ */ new Map(), Ae = Symbol.for("cer.registry");
1650
+ if (typeof window < "u") {
1651
+ const e = globalThis;
1652
+ e[Ae] || (e[Ae] = ue);
1625
1653
  }
1626
- const ye = /* @__PURE__ */ new Map();
1627
- function Ce(e, t, r) {
1628
- let o = me(e);
1654
+ function Te(e, t, r) {
1655
+ let o = J(e);
1629
1656
  o.includes("-") || (o = `cer-${o}`);
1630
1657
  let n;
1631
- typeof t == "function" ? n = { ...r, render: t } : n = t, typeof n.onError != "function" && (n.onError = (s, i) => {
1632
- console.error(`[${o}] Error:`, s, i);
1658
+ typeof t == "function" ? n = { ...r, render: t } : n = t, typeof n.onError != "function" && (n.onError = (i, s) => {
1659
+ console.error(`[${o}] Error:`, i, s);
1633
1660
  });
1634
1661
  try {
1635
- const s = /* @__PURE__ */ new Set([
1662
+ const i = /* @__PURE__ */ new Set([
1636
1663
  "refs",
1637
1664
  "requestRender",
1638
1665
  "error",
1639
1666
  "hasError",
1640
1667
  "isLoading",
1641
1668
  "emit"
1642
- ]), i = [];
1669
+ ]), s = [];
1643
1670
  if (n.state && typeof n.state == "object" && Object.keys(n.state).forEach((a) => {
1644
- s.has(a) && i.push(a);
1671
+ i.has(a) && s.push(a);
1645
1672
  }), n.props && typeof n.props == "object" && Object.keys(n.props).forEach((a) => {
1646
- s.has(a) && i.push(a);
1673
+ i.has(a) && s.push(a);
1647
1674
  }), n.computed && typeof n.computed == "object" && Object.keys(n.computed).forEach((a) => {
1648
- s.has(a) && i.push(a);
1649
- }), i.length > 0) {
1650
- const a = Array.from(new Set(i));
1675
+ i.has(a) && s.push(a);
1676
+ }), s.length > 0) {
1677
+ const a = Array.from(new Set(s));
1651
1678
  console.warn(
1652
1679
  `[${o}] Reserved runtime context keys used in component config: ${a.join(", ")}. These names are provided by the runtime (for example: refs, error, emit). Rename your state/prop/computed keys (e.g. 'error' -> 'errorMessage') to avoid collisions and TypeScript type conflicts.`
1653
1680
  );
1654
1681
  }
1655
1682
  } catch {
1656
1683
  }
1657
- if (ye.set(o, n), typeof window < "u")
1684
+ if (ue.set(o, n), typeof window < "u")
1658
1685
  if (!customElements.get(o))
1659
- customElements.define(o, ft(o, n));
1686
+ customElements.define(o, dt(o, n));
1660
1687
  else
1661
1688
  try {
1662
- document.querySelectorAll(o).forEach((s) => {
1689
+ document.querySelectorAll(o).forEach((i) => {
1663
1690
  try {
1664
- typeof s._cfg < "u" && (s._cfg = n), typeof s._render == "function" && s._render(n);
1691
+ typeof i._cfg < "u" && (i._cfg = n), typeof i._render == "function" && i._render(n);
1665
1692
  } catch {
1666
1693
  }
1667
1694
  });
1668
1695
  } catch {
1669
1696
  }
1670
1697
  }
1671
- function ft(e, t) {
1698
+ function dt(e, t) {
1672
1699
  if (!t.render)
1673
1700
  throw new Error(
1674
1701
  "Component must have a render function"
@@ -1712,7 +1739,7 @@ function ft(e, t) {
1712
1739
  _templateLoading = !1;
1713
1740
  _templateError = null;
1714
1741
  constructor() {
1715
- super(), this.attachShadow({ mode: "open" }), this._cfg = ye.get(e) || t;
1742
+ super(), this.attachShadow({ mode: "open" }), this._cfg = ue.get(e) || t;
1716
1743
  const r = this._initContext(t);
1717
1744
  Object.defineProperty(r, "refs", {
1718
1745
  value: this._refs,
@@ -1724,13 +1751,13 @@ function ft(e, t) {
1724
1751
  writable: !1,
1725
1752
  enumerable: !1,
1726
1753
  configurable: !1
1727
- }), this.context = r, this._applyProps(t), Object.defineProperty(this.context, "emit", {
1728
- value: (n, s, i) => {
1754
+ }), this.context = r, Object.defineProperty(this.context, "emit", {
1755
+ value: (n, i, s) => {
1729
1756
  const a = new CustomEvent(n, {
1730
- detail: s,
1757
+ detail: i,
1731
1758
  bubbles: !0,
1732
1759
  composed: !0,
1733
- ...i || {}
1760
+ ...s || {}
1734
1761
  });
1735
1762
  return this.dispatchEvent(a), !a.defaultPrevented;
1736
1763
  },
@@ -1738,15 +1765,15 @@ function ft(e, t) {
1738
1765
  enumerable: !1,
1739
1766
  configurable: !1
1740
1767
  });
1741
- const o = ye.get(e) || t;
1768
+ const o = ue.get(e) || t;
1742
1769
  Object.keys(o).forEach((n) => {
1743
- const s = o[n];
1744
- typeof s == "function" && (this.context[n] = (...i) => s(...i, this.context));
1770
+ const i = o[n];
1771
+ typeof i == "function" && (this.context[n] = (...s) => i(...s, this.context));
1745
1772
  }), this._applyComputed(o), this._initializing = !1, this._initWatchers(o), this._render(o);
1746
1773
  }
1747
1774
  connectedCallback() {
1748
1775
  this._runLogicWithinErrorBoundary(t, () => {
1749
- Ne(
1776
+ this._applyProps(t), qe(
1750
1777
  t,
1751
1778
  this.context,
1752
1779
  this._mounted,
@@ -1758,7 +1785,7 @@ function ft(e, t) {
1758
1785
  }
1759
1786
  disconnectedCallback() {
1760
1787
  this._runLogicWithinErrorBoundary(t, () => {
1761
- We(
1788
+ De(
1762
1789
  t,
1763
1790
  this.context,
1764
1791
  this._listeners,
@@ -1782,7 +1809,7 @@ function ft(e, t) {
1782
1809
  }
1783
1810
  attributeChangedCallback(r, o, n) {
1784
1811
  this._runLogicWithinErrorBoundary(t, () => {
1785
- this._applyProps(t), De(
1812
+ this._applyProps(t), Ie(
1786
1813
  t,
1787
1814
  r,
1788
1815
  o,
@@ -1792,15 +1819,15 @@ function ft(e, t) {
1792
1819
  });
1793
1820
  }
1794
1821
  static get observedAttributes() {
1795
- return t.props ? Object.keys(t.props).map(me) : [];
1822
+ return t.props ? Object.keys(t.props).map(J) : [];
1796
1823
  }
1797
1824
  _applyComputed(r) {
1798
1825
  this._runLogicWithinErrorBoundary(t, () => {
1799
1826
  r.computed && Object.entries(r.computed).forEach(([o, n]) => {
1800
1827
  Object.defineProperty(this.context, o, {
1801
1828
  get: () => {
1802
- const s = n(this.context);
1803
- return pe(s);
1829
+ const i = n(this.context);
1830
+ return H(i);
1804
1831
  },
1805
1832
  enumerable: !0
1806
1833
  });
@@ -1810,7 +1837,7 @@ function ft(e, t) {
1810
1837
  // --- Render ---
1811
1838
  _render(r) {
1812
1839
  this._runLogicWithinErrorBoundary(r, () => {
1813
- at(
1840
+ ct(
1814
1841
  this.shadowRoot,
1815
1842
  r,
1816
1843
  this.context,
@@ -1833,7 +1860,7 @@ function ft(e, t) {
1833
1860
  }
1834
1861
  _requestRender() {
1835
1862
  this._runLogicWithinErrorBoundary(this._cfg, () => {
1836
- ct(
1863
+ ft(
1837
1864
  () => this._render(this._cfg),
1838
1865
  this._lastRenderTime,
1839
1866
  this._renderCount,
@@ -1853,7 +1880,7 @@ function ft(e, t) {
1853
1880
  // --- Style ---
1854
1881
  _applyStyle(r, o) {
1855
1882
  this._runLogicWithinErrorBoundary(r, () => {
1856
- lt(
1883
+ ut(
1857
1884
  this.shadowRoot,
1858
1885
  r,
1859
1886
  this.context,
@@ -1880,11 +1907,11 @@ function ft(e, t) {
1880
1907
  // --- State, props, computed ---
1881
1908
  _initContext(r) {
1882
1909
  try {
1883
- let o = function(s, i = "") {
1884
- return Array.isArray(s) ? new Proxy(s, {
1885
- get(a, l, f) {
1886
- const p = Reflect.get(a, l, f);
1887
- return typeof p == "function" && typeof l == "string" && [
1910
+ let o = function(i, s = "") {
1911
+ return Array.isArray(i) ? new Proxy(i, {
1912
+ get(a, f, u) {
1913
+ const d = Reflect.get(a, f, u);
1914
+ return typeof d == "function" && typeof f == "string" && [
1888
1915
  "push",
1889
1916
  "pop",
1890
1917
  "shift",
@@ -1892,44 +1919,44 @@ function ft(e, t) {
1892
1919
  "splice",
1893
1920
  "sort",
1894
1921
  "reverse"
1895
- ].includes(l) ? function(...c) {
1896
- const x = p.apply(a, c);
1922
+ ].includes(f) ? function(...l) {
1923
+ const h = d.apply(a, l);
1897
1924
  if (!n._initializing) {
1898
- const w = i || "root";
1925
+ const w = s || "root";
1899
1926
  n._triggerWatchers(w, a), n._render(r);
1900
1927
  }
1901
- return x;
1902
- } : p;
1928
+ return h;
1929
+ } : d;
1903
1930
  },
1904
- set(a, l, f) {
1905
- if (a[l] = f, !n._initializing) {
1906
- const p = i ? `${i}.${String(l)}` : String(l);
1907
- n._triggerWatchers(p, f), n._render(r);
1931
+ set(a, f, u) {
1932
+ if (a[f] = u, !n._initializing) {
1933
+ const d = s ? `${s}.${String(f)}` : String(f);
1934
+ n._triggerWatchers(d, u), n._render(r);
1908
1935
  }
1909
1936
  return !0;
1910
1937
  },
1911
- deleteProperty(a, l) {
1912
- if (delete a[l], !n._initializing) {
1913
- const f = i ? `${i}.${String(l)}` : String(l);
1914
- n._triggerWatchers(f, void 0), n._render(r);
1938
+ deleteProperty(a, f) {
1939
+ if (delete a[f], !n._initializing) {
1940
+ const u = s ? `${s}.${String(f)}` : String(f);
1941
+ n._triggerWatchers(u, void 0), n._render(r);
1915
1942
  }
1916
1943
  return !0;
1917
1944
  }
1918
- }) : s && typeof s == "object" ? (Object.keys(s).forEach((a) => {
1919
- const l = i ? `${i}.${a}` : a;
1920
- s[a] = o(s[a], l);
1921
- }), new Proxy(s, {
1922
- set(a, l, f) {
1923
- const p = i ? `${i}.${String(l)}` : String(l);
1924
- return a[l] = o(f, p), n._initializing || (n._triggerWatchers(
1925
- p,
1926
- a[l]
1945
+ }) : i && typeof i == "object" ? (Object.keys(i).forEach((a) => {
1946
+ const f = s ? `${s}.${a}` : a;
1947
+ i[a] = o(i[a], f);
1948
+ }), new Proxy(i, {
1949
+ set(a, f, u) {
1950
+ const d = s ? `${s}.${String(f)}` : String(f);
1951
+ return a[f] = o(u, d), n._initializing || (n._triggerWatchers(
1952
+ d,
1953
+ a[f]
1927
1954
  ), n._render(r)), !0;
1928
1955
  },
1929
- get(a, l, f) {
1930
- return Reflect.get(a, l, f);
1956
+ get(a, f, u) {
1957
+ return Reflect.get(a, f, u);
1931
1958
  }
1932
- })) : s;
1959
+ })) : i;
1933
1960
  };
1934
1961
  const n = this;
1935
1962
  return o({ ...r.state });
@@ -1939,7 +1966,7 @@ function ft(e, t) {
1939
1966
  }
1940
1967
  _initWatchers(r) {
1941
1968
  this._runLogicWithinErrorBoundary(r, () => {
1942
- Pe(
1969
+ Ne(
1943
1970
  this.context,
1944
1971
  this._watchers,
1945
1972
  r.watch || {}
@@ -1947,12 +1974,12 @@ function ft(e, t) {
1947
1974
  });
1948
1975
  }
1949
1976
  _triggerWatchers(r, o) {
1950
- Oe(this.context, this._watchers, r, o);
1977
+ Me(this.context, this._watchers, r, o);
1951
1978
  }
1952
1979
  _applyProps(r) {
1953
1980
  this._runLogicWithinErrorBoundary(r, () => {
1954
1981
  try {
1955
- Me(this, r, this.context);
1982
+ We(this, r, this.context);
1956
1983
  } catch (o) {
1957
1984
  this._hasError = !0, r.onError && r.onError(o, this.context), r.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = r.errorFallback(o, this.context));
1958
1985
  }
@@ -1960,102 +1987,103 @@ function ft(e, t) {
1960
1987
  }
1961
1988
  };
1962
1989
  }
1963
- function V(e, t = {}, r, o) {
1990
+ function ee(e, t = {}, r, o) {
1964
1991
  const n = o ?? t.key;
1965
1992
  return { tag: e, key: n, props: t, children: r };
1966
1993
  }
1967
- function ee(e) {
1994
+ function ce(e) {
1968
1995
  return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
1969
1996
  }
1970
- function Q(e) {
1971
- return typeof e == "object" && e !== null && "tag" in e && !ee(e);
1997
+ function ie(e) {
1998
+ return typeof e == "object" && e !== null && "tag" in e && !ce(e);
1972
1999
  }
1973
- function ut(e, t) {
2000
+ function pt(e, t) {
1974
2001
  return e.key != null ? e : { ...e, key: t };
1975
2002
  }
1976
- function dt(e, t = [], r = {}) {
1977
- const o = {}, n = {}, s = {}, i = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
2003
+ function ht(e, t = [], r = {}) {
2004
+ const o = {}, n = {}, i = {}, s = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
1978
2005
  let a;
1979
- for (; a = i.exec(e); ) {
1980
- const l = a[1], f = a[2], p = (a[4] || a[6]) ?? "", y = p.match(/^{{(\d+)}}$/);
1981
- let c = y ? t[Number(y[1])] ?? null : p;
1982
- y || (c === "true" ? c = !0 : c === "false" ? c = !1 : c === "null" ? c = null : isNaN(Number(c)) || (c = Number(c)));
1983
- const x = ["model", "bind", "show", "class", "style"];
1984
- if (l === ":") {
1985
- const [w, ...k] = f.split(".");
1986
- if (x.includes(w)) {
1987
- const h = [...k];
1988
- s[w] = {
1989
- value: c,
1990
- modifiers: h
2006
+ for (; a = s.exec(e); ) {
2007
+ const f = a[1], u = a[2], d = (a[4] || a[6]) ?? "", m = d.match(/^{{(\d+)}}$/);
2008
+ let l = m ? t[Number(m[1])] ?? null : d;
2009
+ m || (l === "true" ? l = !0 : l === "false" ? l = !1 : l === "null" ? l = null : isNaN(Number(l)) || (l = Number(l)));
2010
+ const h = ["model", "bind", "show", "class", "style"];
2011
+ if (f === ":") {
2012
+ const [w, $] = u.split(":"), [v, ...b] = w.split(".");
2013
+ if (h.includes(v)) {
2014
+ const y = [...b], x = v === "model" && $ ? `model:${$}` : v;
2015
+ i[x] = {
2016
+ value: l,
2017
+ modifiers: y,
2018
+ arg: $
1991
2019
  };
1992
2020
  } else
1993
- n[f] = c;
1994
- } else if (l === "@") {
1995
- const w = "on" + f.charAt(0).toUpperCase() + f.slice(1);
1996
- o[w] = typeof c == "function" ? c : typeof r[c] == "function" ? r[c] : void 0;
1997
- } else f === "ref" ? o.ref = c : n[f] = c;
1998
- }
1999
- return { props: o, attrs: n, directives: s };
2000
- }
2001
- function pt(e, t, r) {
2002
- const o = J.length > 0 ? J[J.length - 1] : void 0, n = r ?? o;
2003
- function s(d, v) {
2004
- return V("#text", {}, d, v);
2005
- }
2006
- let i = "";
2007
- for (let d = 0; d < e.length; d++)
2008
- i += e[d], d < t.length && (i += `{{${d}}}`);
2009
- const a = /<\/?([a-zA-Z0-9-]+)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s>]+))?)*)\s*\/?>|{{(\d+)}}|([^<]+)/g, l = [];
2010
- let f, p = [], y = null, c = {}, x, w = 0, k = [];
2011
- function h(d) {
2012
- !d || typeof d != "object" || ee(d) || (d.props || d.attrs ? (d.props && (c.props || (c.props = {}), Object.assign(c.props, d.props)), d.attrs && (c.attrs || (c.attrs = {}), Object.keys(d.attrs).forEach((v) => {
2013
- if (v === "style" && c.attrs.style) {
2014
- const m = c.attrs.style.replace(
2021
+ n[u] = l;
2022
+ } else if (f === "@") {
2023
+ const w = "on" + u.charAt(0).toUpperCase() + u.slice(1);
2024
+ o[w] = typeof l == "function" ? l : typeof r[l] == "function" ? r[l] : void 0;
2025
+ } else u === "ref" ? o.ref = l : n[u] = l;
2026
+ }
2027
+ return { props: o, attrs: n, directives: i };
2028
+ }
2029
+ function gt(e, t, r) {
2030
+ const o = te.length > 0 ? te[te.length - 1] : void 0, n = r ?? o;
2031
+ function i(c, g) {
2032
+ return ee("#text", {}, c, g);
2033
+ }
2034
+ let s = "";
2035
+ for (let c = 0; c < e.length; c++)
2036
+ s += e[c], c < t.length && (s += `{{${c}}}`);
2037
+ const a = /<\/?([a-zA-Z0-9-]+)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s>]+))?)*)\s*\/?>|{{(\d+)}}|([^<]+)/g, f = [];
2038
+ let u, d = [], m = null, l = {}, h, w = 0, $ = [];
2039
+ function v(c) {
2040
+ !c || typeof c != "object" || ce(c) || (c.props || c.attrs ? (c.props && (l.props || (l.props = {}), Object.assign(l.props, c.props)), c.attrs && (l.attrs || (l.attrs = {}), Object.keys(c.attrs).forEach((g) => {
2041
+ if (g === "style" && l.attrs.style) {
2042
+ const p = l.attrs.style.replace(
2015
2043
  /;?\s*$/,
2016
2044
  ""
2017
- ), $ = d.attrs.style.replace(/^;?\s*/, "");
2018
- c.attrs.style = m + "; " + $;
2019
- } else if (v === "class" && c.attrs.class) {
2020
- const m = c.attrs.class.trim().split(/\s+/).filter(Boolean), $ = d.attrs.class.trim().split(/\s+/).filter(Boolean), _ = [
2021
- .../* @__PURE__ */ new Set([...m, ...$])
2045
+ ), _ = c.attrs.style.replace(/^;?\s*/, "");
2046
+ l.attrs.style = p + "; " + _;
2047
+ } else if (g === "class" && l.attrs.class) {
2048
+ const p = l.attrs.class.trim().split(/\s+/).filter(Boolean), _ = c.attrs.class.trim().split(/\s+/).filter(Boolean), E = [
2049
+ .../* @__PURE__ */ new Set([...p, ..._])
2022
2050
  ];
2023
- c.attrs.class = _.join(" ");
2051
+ l.attrs.class = E.join(" ");
2024
2052
  } else
2025
- c.attrs[v] = d.attrs[v];
2026
- }))) : (c.props || (c.props = {}), Object.assign(c.props, d)));
2027
- }
2028
- function u(d, v) {
2029
- const m = y ? p : k;
2030
- if (ee(d)) {
2031
- const $ = d.key ?? v;
2032
- let _ = d.children;
2033
- m.push({
2034
- ...d,
2035
- key: $,
2036
- children: _
2053
+ l.attrs[g] = c.attrs[g];
2054
+ }))) : (l.props || (l.props = {}), Object.assign(l.props, c)));
2055
+ }
2056
+ function b(c, g) {
2057
+ const p = m ? d : $;
2058
+ if (ce(c)) {
2059
+ const _ = c.key ?? g;
2060
+ let E = c.children;
2061
+ p.push({
2062
+ ...c,
2063
+ key: _,
2064
+ children: E
2037
2065
  });
2038
2066
  return;
2039
2067
  }
2040
- if (Q(d)) {
2041
- m.push(ut(d, void 0));
2068
+ if (ie(c)) {
2069
+ p.push(pt(c, void 0));
2042
2070
  return;
2043
2071
  }
2044
- if (Array.isArray(d)) {
2045
- if (d.length === 0) return;
2046
- for (let $ = 0; $ < d.length; $++) {
2047
- const _ = d[$];
2048
- ee(_) || Q(_) || Array.isArray(_) ? u(_, `${v}-${$}`) : _ !== null && typeof _ == "object" ? h(_) : m.push(s(String(_), `${v}-${$}`));
2072
+ if (Array.isArray(c)) {
2073
+ if (c.length === 0) return;
2074
+ for (let _ = 0; _ < c.length; _++) {
2075
+ const E = c[_];
2076
+ ce(E) || ie(E) || Array.isArray(E) ? b(E, `${g}-${_}`) : E !== null && typeof E == "object" ? v(E) : p.push(i(String(E), `${g}-${_}`));
2049
2077
  }
2050
2078
  return;
2051
2079
  }
2052
- if (d !== null && typeof d == "object") {
2053
- h(d);
2080
+ if (c !== null && typeof c == "object") {
2081
+ v(c);
2054
2082
  return;
2055
2083
  }
2056
- m.push(s(String(d), v));
2084
+ p.push(i(String(c), g));
2057
2085
  }
2058
- const g = /* @__PURE__ */ new Set([
2086
+ const y = /* @__PURE__ */ new Set([
2059
2087
  "area",
2060
2088
  "base",
2061
2089
  "br",
@@ -2071,232 +2099,257 @@ function pt(e, t, r) {
2071
2099
  "track",
2072
2100
  "wbr"
2073
2101
  ]);
2074
- for (; f = a.exec(i); )
2075
- if (f[1]) {
2076
- const d = f[1], v = f[0][1] === "/", m = f[0][f[0].length - 2] === "/" || g.has(d), {
2077
- props: $,
2078
- attrs: _,
2102
+ for (; u = a.exec(s); )
2103
+ if (u[1]) {
2104
+ const c = u[1], g = u[0][1] === "/", p = u[0][u[0].length - 2] === "/" || y.has(c), {
2105
+ props: _,
2106
+ attrs: E,
2079
2107
  directives: C
2080
- } = dt(f[2] || "", t, n), E = { props: {}, attrs: {} };
2081
- for (const j in $) E.props[j] = $[j];
2082
- for (const j in _) E.attrs[j] = _[j];
2083
- if (Object.keys(C).length > 0 && (E.directives = { ...C }), v) {
2084
- const j = V(
2085
- y,
2086
- c,
2087
- p.length === 1 && Q(p[0]) && p[0].tag === "#text" ? typeof p[0].children == "string" ? p[0].children : "" : p.length ? p : void 0,
2088
- x
2089
- ), A = l.pop();
2090
- A ? (y = A.tag, c = A.props, x = A.key, p = A.children, p.push(j)) : (k.push(j), y = null, c = {}, x = void 0, p = []);
2091
- } else m ? y ? p.push(V(d, E, void 0, void 0)) : k.push(V(d, E, void 0, void 0)) : (y && l.push({
2092
- tag: y,
2093
- props: c,
2094
- children: p,
2095
- key: x
2096
- }), y = d, c = E, p = []);
2097
- } else if (typeof f[3] < "u") {
2098
- const d = Number(f[3]), v = t[d], m = `interp-${d}`;
2099
- u(v, m);
2100
- } else if (f[4]) {
2101
- const d = f[4], v = y ? p : k, m = d.split(/({{\d+}})/);
2102
- for (const $ of m) {
2103
- if (!$) continue;
2104
- const _ = $.match(/^{{(\d+)}}$/);
2105
- if (_) {
2106
- const C = Number(_[1]), E = t[C], j = `interp-${C}`;
2107
- u(E, j);
2108
+ } = ht(u[2] || "", t, n), S = { props: {}, attrs: {} };
2109
+ for (const A in _) S.props[A] = _[A];
2110
+ for (const A in E) S.attrs[A] = E[A];
2111
+ if (C && Object.keys(C).some((A) => A === "model" || A.startsWith("model:")))
2112
+ try {
2113
+ const A = Symbol.for("cer.registry"), T = globalThis[A], Q = !!(T && typeof T.has == "function" && T.has(c)), X = !!(n && (n.__customElements instanceof Set && n.__customElements.has(c) || Array.isArray(n.__isCustomElements) && n.__isCustomElements.includes(c)));
2114
+ if (!!(c.includes("-") || X || Q))
2115
+ for (const I of Object.keys(C)) {
2116
+ if (I !== "model" && !I.startsWith("model:")) continue;
2117
+ const Z = C[I], F = Z.arg ?? (I.includes(":") ? I.split(":", 2)[1] : void 0), L = Z.value, K = F ?? "modelValue", D = N, ne = se, k = n ? n._state || n : void 0;
2118
+ let B;
2119
+ typeof L == "string" && n ? B = D(k, L) : B = L, S.props[K] = B;
2120
+ try {
2121
+ const j = J(K);
2122
+ S.attrs || (S.attrs = {}), B !== void 0 && (S.attrs[j] = B);
2123
+ } catch {
2124
+ }
2125
+ S.isCustomElement = !0;
2126
+ const z = `update:${J(K)}`, O = "on" + z.charAt(0).toUpperCase() + z.slice(1);
2127
+ S.props[O] = function(j) {
2128
+ const R = j.detail !== void 0 ? j.detail : j.target ? j.target.value : void 0;
2129
+ if (!k) return;
2130
+ const pe = D(k, typeof L == "string" ? L : String(L));
2131
+ (Array.isArray(R) && Array.isArray(pe) ? JSON.stringify([...R].sort()) !== JSON.stringify([...pe].sort()) : R !== pe) && (ne(k, typeof L == "string" ? L : String(L), R), n?.requestRender ? n.requestRender() : n?._requestRender && n._requestRender());
2132
+ }, delete C[I];
2133
+ }
2134
+ } catch {
2135
+ }
2136
+ if (Object.keys(C).length > 0 && (S.directives = { ...C }), g) {
2137
+ const A = ee(
2138
+ m,
2139
+ l,
2140
+ d.length === 1 && ie(d[0]) && d[0].tag === "#text" ? typeof d[0].children == "string" ? d[0].children : "" : d.length ? d : void 0,
2141
+ h
2142
+ ), T = f.pop();
2143
+ T ? (m = T.tag, l = T.props, h = T.key, d = T.children, d.push(A)) : ($.push(A), m = null, l = {}, h = void 0, d = []);
2144
+ } else p ? m ? d.push(ee(c, S, void 0, void 0)) : $.push(ee(c, S, void 0, void 0)) : (m && f.push({
2145
+ tag: m,
2146
+ props: l,
2147
+ children: d,
2148
+ key: h
2149
+ }), m = c, l = S, d = []);
2150
+ } else if (typeof u[3] < "u") {
2151
+ const c = Number(u[3]), g = t[c], p = `interp-${c}`;
2152
+ b(g, p);
2153
+ } else if (u[4]) {
2154
+ const c = u[4], g = m ? d : $, p = c.split(/({{\d+}})/);
2155
+ for (const _ of p) {
2156
+ if (!_) continue;
2157
+ const E = _.match(/^{{(\d+)}}$/);
2158
+ if (E) {
2159
+ const C = Number(E[1]), S = t[C], A = `interp-${C}`;
2160
+ b(S, A);
2108
2161
  } else {
2109
2162
  const C = `text-${w++}`;
2110
- v.push(s($, C));
2163
+ g.push(i(_, C));
2111
2164
  }
2112
2165
  }
2113
2166
  }
2114
- const b = k.filter((d) => Q(d) && d.tag === "#text" ? typeof d.children == "string" && d.children.trim() !== "" : !0);
2115
- return b.length === 1 ? b[0] : b.length > 1 ? b : V("div", {}, "", "fallback-root");
2167
+ const x = $.filter((c) => ie(c) && c.tag === "#text" ? typeof c.children == "string" && c.children.trim() !== "" : !0);
2168
+ return x.length === 1 ? x[0] : x.length > 1 ? x : ee("div", {}, "", "fallback-root");
2116
2169
  }
2117
- function D(e, ...t) {
2170
+ function U(e, ...t) {
2118
2171
  const r = t[t.length - 1], o = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
2119
- return pt(e, t, o);
2172
+ return gt(e, t, o);
2120
2173
  }
2121
- const Ee = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, N = (e, t) => {
2174
+ const je = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, W = (e, t) => {
2122
2175
  for (const r of e) {
2123
- const o = [], n = r.path.replace(/:[^/]+/g, (a) => (o.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${n}$`), i = t.match(s);
2124
- if (i) {
2176
+ const o = [], n = r.path.replace(/:[^/]+/g, (a) => (o.push(a.slice(1)), "([^/]+)")), i = new RegExp(`^${n}$`), s = t.match(i);
2177
+ if (s) {
2125
2178
  const a = {};
2126
- return o.forEach((l, f) => {
2127
- a[l] = i[f + 1];
2179
+ return o.forEach((f, u) => {
2180
+ a[f] = s[u + 1];
2128
2181
  }), { route: r, params: a };
2129
2182
  }
2130
2183
  }
2131
2184
  return { route: null, params: {} };
2132
- }, de = {};
2133
- async function ht(e) {
2185
+ }, we = {};
2186
+ async function yt(e) {
2134
2187
  if (e.component) return e.component;
2135
2188
  if (e.load) {
2136
- if (de[e.path]) return de[e.path];
2189
+ if (we[e.path]) return we[e.path];
2137
2190
  try {
2138
2191
  const t = await e.load();
2139
- return de[e.path] = t.default, t.default;
2192
+ return we[e.path] = t.default, t.default;
2140
2193
  } catch {
2141
2194
  throw new Error(`Failed to load component for route: ${e.path}`);
2142
2195
  }
2143
2196
  }
2144
2197
  throw new Error(`No component or loader defined for route: ${e.path}`);
2145
2198
  }
2146
- function gt(e) {
2199
+ function mt(e) {
2147
2200
  const { routes: t, base: r = "", initialUrl: o } = e;
2148
- let n, s, i, a, l, f, p;
2149
- const y = async (k, h) => {
2150
- const u = t.find((g) => N([g], k.path).route !== null);
2151
- if (u?.beforeEnter)
2201
+ let n, i, s, a, f, u, d;
2202
+ const m = async ($, v) => {
2203
+ const b = t.find((y) => W([y], $.path).route !== null);
2204
+ if (b?.beforeEnter)
2152
2205
  try {
2153
- const g = await u.beforeEnter(k, h);
2154
- return typeof g == "string" ? (await w(g, !0), !1) : g !== !1;
2155
- } catch (g) {
2156
- return console.error("beforeEnter error", g), !1;
2206
+ const y = await b.beforeEnter($, v);
2207
+ return typeof y == "string" ? (await w(y, !0), !1) : y !== !1;
2208
+ } catch (y) {
2209
+ return console.error("beforeEnter error", y), !1;
2157
2210
  }
2158
2211
  return !0;
2159
- }, c = async (k, h) => {
2160
- const u = t.find((g) => N([g], k.path).route !== null);
2161
- if (u?.onEnter)
2212
+ }, l = async ($, v) => {
2213
+ const b = t.find((y) => W([y], $.path).route !== null);
2214
+ if (b?.onEnter)
2162
2215
  try {
2163
- const g = await u.onEnter(k, h);
2164
- return typeof g == "string" ? (await w(g, !0), !1) : g !== !1;
2165
- } catch (g) {
2166
- return console.error("onEnter error", g), !1;
2216
+ const y = await b.onEnter($, v);
2217
+ return typeof y == "string" ? (await w(y, !0), !1) : y !== !1;
2218
+ } catch (y) {
2219
+ return console.error("onEnter error", y), !1;
2167
2220
  }
2168
2221
  return !0;
2169
- }, x = (k, h) => {
2170
- const u = t.find((g) => N([g], k.path).route !== null);
2171
- if (u?.afterEnter)
2222
+ }, h = ($, v) => {
2223
+ const b = t.find((y) => W([y], $.path).route !== null);
2224
+ if (b?.afterEnter)
2172
2225
  try {
2173
- u.afterEnter(k, h);
2174
- } catch (g) {
2175
- console.error("afterEnter error", g);
2226
+ b.afterEnter($, v);
2227
+ } catch (y) {
2228
+ console.error("afterEnter error", y);
2176
2229
  }
2177
- }, w = async (k, h = !1) => {
2230
+ }, w = async ($, v = !1) => {
2178
2231
  try {
2179
- const u = {
2180
- path: k.replace(r, "") || "/",
2232
+ const b = {
2233
+ path: $.replace(r, "") || "/",
2181
2234
  query: {}
2182
- }, g = N(t, u.path);
2183
- if (!g) throw new Error(`No route found for ${u.path}`);
2184
- const b = i.getState(), d = {
2185
- path: u.path,
2186
- params: g.params,
2187
- query: u.query
2235
+ }, y = W(t, b.path);
2236
+ if (!y) throw new Error(`No route found for ${b.path}`);
2237
+ const x = s.getState(), c = {
2238
+ path: b.path,
2239
+ params: y.params,
2240
+ query: b.query
2188
2241
  };
2189
- if (!await y(d, b) || !await c(d, b)) return;
2190
- typeof window < "u" && typeof document < "u" && (h ? window.history.replaceState({}, "", r + k) : window.history.pushState({}, "", r + k)), i.setState(d), x(d, b);
2191
- } catch (u) {
2192
- console.error("Navigation error:", u);
2242
+ if (!await m(c, x) || !await l(c, x)) return;
2243
+ typeof window < "u" && typeof document < "u" && (v ? window.history.replaceState({}, "", r + $) : window.history.pushState({}, "", r + $)), s.setState(c), h(c, x);
2244
+ } catch (b) {
2245
+ console.error("Navigation error:", b);
2193
2246
  }
2194
2247
  };
2195
2248
  if (typeof window < "u" && typeof document < "u") {
2196
2249
  n = () => {
2197
- const h = new URL(window.location.href), u = h.pathname.replace(r, "") || "/", g = Ee(h.search);
2198
- return { path: u, query: g };
2199
- }, s = n();
2200
- const k = N(t, s.path);
2201
- i = we({
2202
- path: s.path,
2203
- params: k.params,
2204
- query: s.query
2205
- }), a = async (h = !1) => {
2206
- const u = n();
2207
- await w(u.path, h);
2208
- }, window.addEventListener("popstate", () => a(!0)), l = (h) => w(h, !1), f = (h) => w(h, !0), p = () => window.history.back();
2250
+ const v = new URL(window.location.href), b = v.pathname.replace(r, "") || "/", y = je(v.search);
2251
+ return { path: b, query: y };
2252
+ }, i = n();
2253
+ const $ = W(t, i.path);
2254
+ s = $e({
2255
+ path: i.path,
2256
+ params: $.params,
2257
+ query: i.query
2258
+ }), a = async (v = !1) => {
2259
+ const b = n();
2260
+ await w(b.path, v);
2261
+ }, window.addEventListener("popstate", () => a(!0)), f = (v) => w(v, !1), u = (v) => w(v, !0), d = () => window.history.back();
2209
2262
  } else {
2210
2263
  n = () => {
2211
- const u = new URL(o || "/", "http://localhost"), g = u.pathname.replace(r, "") || "/", b = Ee(u.search);
2212
- return { path: g, query: b };
2213
- }, s = n();
2214
- const k = N(t, s.path);
2215
- i = we({
2216
- path: s.path,
2217
- params: k.params,
2218
- query: s.query
2264
+ const b = new URL(o || "/", "http://localhost"), y = b.pathname.replace(r, "") || "/", x = je(b.search);
2265
+ return { path: y, query: x };
2266
+ }, i = n();
2267
+ const $ = W(t, i.path);
2268
+ s = $e({
2269
+ path: i.path,
2270
+ params: $.params,
2271
+ query: i.query
2219
2272
  }), a = async () => {
2220
- const u = n();
2221
- await h(u.path);
2273
+ const b = n();
2274
+ await v(b.path);
2222
2275
  };
2223
- const h = async (u) => {
2276
+ const v = async (b) => {
2224
2277
  try {
2225
- const g = {
2226
- path: u.replace(r, "") || "/",
2278
+ const y = {
2279
+ path: b.replace(r, "") || "/",
2227
2280
  query: {}
2228
- }, b = N(t, g.path);
2229
- if (!b) throw new Error(`No route found for ${g.path}`);
2230
- const d = i.getState(), v = {
2231
- path: g.path,
2232
- params: b.params,
2233
- query: g.query
2234
- }, m = t.find(($) => N([$], v.path).route !== null);
2235
- if (m?.beforeEnter)
2281
+ }, x = W(t, y.path);
2282
+ if (!x) throw new Error(`No route found for ${y.path}`);
2283
+ const c = s.getState(), g = {
2284
+ path: y.path,
2285
+ params: x.params,
2286
+ query: y.query
2287
+ }, p = t.find((_) => W([_], g.path).route !== null);
2288
+ if (p?.beforeEnter)
2236
2289
  try {
2237
- const $ = await m.beforeEnter(v, d);
2238
- if (typeof $ == "string") {
2239
- await h($);
2290
+ const _ = await p.beforeEnter(g, c);
2291
+ if (typeof _ == "string") {
2292
+ await v(_);
2240
2293
  return;
2241
2294
  }
2242
- if ($ === !1) return;
2295
+ if (_ === !1) return;
2243
2296
  } catch {
2244
2297
  return;
2245
2298
  }
2246
- if (m?.onEnter)
2299
+ if (p?.onEnter)
2247
2300
  try {
2248
- const $ = await m.onEnter(v, d);
2249
- if (typeof $ == "string") {
2250
- await h($);
2301
+ const _ = await p.onEnter(g, c);
2302
+ if (typeof _ == "string") {
2303
+ await v(_);
2251
2304
  return;
2252
2305
  }
2253
- if ($ === !1) return;
2306
+ if (_ === !1) return;
2254
2307
  } catch {
2255
2308
  return;
2256
2309
  }
2257
- if (i.setState(v), m?.afterEnter)
2310
+ if (s.setState(g), p?.afterEnter)
2258
2311
  try {
2259
- m.afterEnter(v, d);
2312
+ p.afterEnter(g, c);
2260
2313
  } catch {
2261
2314
  }
2262
2315
  } catch {
2263
2316
  }
2264
2317
  };
2265
- l = async (u) => h(u), f = async (u) => h(u), p = () => {
2318
+ f = async (b) => v(b), u = async (b) => v(b), d = () => {
2266
2319
  };
2267
2320
  }
2268
2321
  return {
2269
- store: i,
2270
- push: l,
2271
- replace: f,
2272
- back: p,
2273
- subscribe: i.subscribe,
2274
- matchRoute: (k) => N(t, k),
2275
- getCurrent: () => i.getState(),
2276
- resolveRouteComponent: ht
2322
+ store: s,
2323
+ push: f,
2324
+ replace: u,
2325
+ back: d,
2326
+ subscribe: s.subscribe,
2327
+ matchRoute: ($) => W(t, $),
2328
+ getCurrent: () => s.getState(),
2329
+ resolveRouteComponent: yt
2277
2330
  };
2278
2331
  }
2279
- function $t(e, t) {
2280
- return N(e, t);
2332
+ function Ct(e, t) {
2333
+ return W(e, t);
2281
2334
  }
2282
- function St(e) {
2283
- const t = gt(e);
2284
- return Ce("router-view", {
2335
+ function Et(e) {
2336
+ const t = mt(e);
2337
+ return Te("router-view", {
2285
2338
  async render() {
2286
- if (!t) return D`<div>Router not initialized.</div>`;
2339
+ if (!t) return U`<div>Router not initialized.</div>`;
2287
2340
  const r = t.getCurrent(), { path: o } = r, n = t.matchRoute(o);
2288
- if (!n.route) return D`<div>Not found</div>`;
2341
+ if (!n.route) return U`<div>Not found</div>`;
2289
2342
  try {
2290
- const s = await t.resolveRouteComponent(n.route);
2291
- if (typeof s == "string")
2292
- return { tag: s, props: {}, children: [] };
2293
- if (typeof s == "function") {
2294
- const i = s(), a = i instanceof Promise ? await i : i;
2343
+ const i = await t.resolveRouteComponent(n.route);
2344
+ if (typeof i == "string")
2345
+ return { tag: i, props: {}, children: [] };
2346
+ if (typeof i == "function") {
2347
+ const s = i(), a = s instanceof Promise ? await s : s;
2295
2348
  return typeof a == "string" ? { tag: a, props: {}, children: [] } : a;
2296
2349
  }
2297
- return D`<div>Invalid route component</div>`;
2350
+ return U`<div>Invalid route component</div>`;
2298
2351
  } catch {
2299
- return D`<div>Invalid route component</div>`;
2352
+ return U`<div>Invalid route component</div>`;
2300
2353
  }
2301
2354
  },
2302
2355
  onConnected(r) {
@@ -2304,7 +2357,7 @@ function St(e) {
2304
2357
  typeof r.requestRender == "function" && r.requestRender();
2305
2358
  });
2306
2359
  }
2307
- }), Ce("router-link", {
2360
+ }), Te("router-link", {
2308
2361
  state: {},
2309
2362
  props: {
2310
2363
  to: { type: String, default: "" },
@@ -2317,7 +2370,7 @@ function St(e) {
2317
2370
  disabled: { type: Boolean, default: !1 },
2318
2371
  external: { type: Boolean, default: !1 },
2319
2372
  class: { type: String, default: "" },
2320
- style: { type: String, default: je`
2373
+ style: { type: String, default: ze`
2321
2374
  [aria-disabled="true"] {
2322
2375
  pointer-events: none;
2323
2376
  opacity: 0.5;
@@ -2326,32 +2379,32 @@ function St(e) {
2326
2379
  },
2327
2380
  style: (r) => r.style,
2328
2381
  render: (r) => {
2329
- const o = t.getCurrent(), n = r.to, s = r.exact, i = r.exactActiveClass, a = r.activeClass, l = r.ariaCurrentValue, f = r.tag, p = r.disabled, y = r.external, c = o.path === n, x = s ? c : o && typeof o.path == "string" ? o.path.startsWith(n) : !1, w = c ? `aria-current="${l}"` : "", k = (r.class || "").split(/\s+/).filter(Boolean), h = {};
2330
- for (const v of k) h[v] = !0;
2331
- const u = {
2332
- ...h,
2382
+ const o = t.getCurrent(), n = r.to, i = r.exact, s = r.exactActiveClass, a = r.activeClass, f = r.ariaCurrentValue, u = r.tag, d = r.disabled, m = r.external, l = o.path === n, h = i ? l : o && typeof o.path == "string" ? o.path.startsWith(n) : !1, w = l ? `aria-current="${f}"` : "", $ = (r.class || "").split(/\s+/).filter(Boolean), v = {};
2383
+ for (const g of $) v[g] = !0;
2384
+ const b = {
2385
+ ...v,
2333
2386
  // Also include the configurable names (may duplicate the above)
2334
- [a]: x,
2335
- [i]: c
2336
- }, g = f === "button", b = p ? g ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", d = y && (f === "a" || !f) ? 'target="_blank" rel="noopener noreferrer"' : "";
2337
- return D`
2338
- ${Re().when(g, D`
2387
+ [a]: h,
2388
+ [s]: l
2389
+ }, y = u === "button", x = d ? y ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", c = m && (u === "a" || !u) ? 'target="_blank" rel="noopener noreferrer"' : "";
2390
+ return U`
2391
+ ${Oe().when(y, U`
2339
2392
  <button
2340
2393
  part="button"
2341
- :class="${u}"
2394
+ :class="${b}"
2342
2395
  ${w}
2343
- ${b}
2344
- ${d}
2396
+ ${x}
2397
+ ${c}
2345
2398
  @click="navigate"
2346
2399
  ><slot></slot></button>
2347
- `).otherwise(D`
2400
+ `).otherwise(U`
2348
2401
  <a
2349
2402
  part="link"
2350
2403
  href="${n}"
2351
- :class="${u}"
2404
+ :class="${b}"
2352
2405
  ${w}
2353
- ${b}
2354
- ${d}
2406
+ ${x}
2407
+ ${c}
2355
2408
  @click="navigate"
2356
2409
  ><slot></slot></a>
2357
2410
  `).done()}
@@ -2367,25 +2420,26 @@ function St(e) {
2367
2420
  }), t;
2368
2421
  }
2369
2422
  export {
2370
- U as GlobalEventBus,
2371
- Ce as component,
2372
- we as createStore,
2373
- je as css,
2374
- mt as each,
2375
- bt as emit,
2376
- Z as eventBus,
2377
- D as html,
2378
- St as initRouter,
2379
- kt as listen,
2380
- Re as match,
2381
- N as matchRoute,
2382
- $t as matchRouteSSR,
2383
- wt as off,
2384
- vt as on,
2385
- xt as once,
2386
- Ee as parseQuery,
2387
- ht as resolveRouteComponent,
2388
- gt as useRouter,
2389
- yt as when
2423
+ G as GlobalEventBus,
2424
+ Te as component,
2425
+ $e as createStore,
2426
+ ze as css,
2427
+ xt as each,
2428
+ wt as emit,
2429
+ re as eventBus,
2430
+ U as html,
2431
+ Et as initRouter,
2432
+ St as listen,
2433
+ Oe as match,
2434
+ W as matchRoute,
2435
+ Ct as matchRouteSSR,
2436
+ $t as off,
2437
+ kt as on,
2438
+ _t as once,
2439
+ je as parseQuery,
2440
+ he as renderToString,
2441
+ yt as resolveRouteComponent,
2442
+ mt as useRouter,
2443
+ vt as when
2390
2444
  };
2391
2445
  //# sourceMappingURL=custom-elements-runtime.es.js.map