@jasonshimmy/custom-elements-runtime 0.1.2 → 0.1.3

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,20 +1,42 @@
1
- function Re(e) {
2
- let t = new Proxy(e, {
3
- set: (i, l, c) => (i[l] = c, s(), !0)
1
+ function rt(e, t) {
2
+ return J(e ? t : [], "when-block");
3
+ }
4
+ function nt(e, t) {
5
+ return e.map((r, n) => {
6
+ const o = typeof r == "object" ? r?.key ?? r?.id ?? `idx-${n}` : String(r);
7
+ return J(t(r, n), `each-${o}`);
4
8
  });
5
- const n = [];
6
- function r(i) {
7
- n.push(i), i(t);
8
- }
9
- function o() {
10
- return t;
11
- }
12
- function s() {
13
- n.forEach((i) => i(t));
9
+ }
10
+ function be() {
11
+ const e = [];
12
+ return {
13
+ when(t, r) {
14
+ return e.push([t, r]), this;
15
+ },
16
+ otherwise(t) {
17
+ return e.push([!0, t]), this;
18
+ },
19
+ done() {
20
+ return ve(...e);
21
+ }
22
+ };
23
+ }
24
+ function ve(...e) {
25
+ for (let t = 0; t < e.length; t++) {
26
+ const [r, n] = e[t];
27
+ if (r) return [J(n, `whenChain-branch-${t}`)];
14
28
  }
15
- return { subscribe: r, getState: o };
29
+ return [J([], "whenChain-empty")];
30
+ }
31
+ function J(e, t) {
32
+ const r = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
33
+ return {
34
+ tag: "#anchor",
35
+ key: t,
36
+ children: r
37
+ };
16
38
  }
17
- class B extends EventTarget {
39
+ class P extends EventTarget {
18
40
  handlers = {};
19
41
  static instance;
20
42
  eventCounters = /* @__PURE__ */ new Map();
@@ -22,7 +44,7 @@ class B extends EventTarget {
22
44
  * Returns the singleton instance of GlobalEventBus
23
45
  */
24
46
  static getInstance() {
25
- return B.instance || (B.instance = new B()), B.instance;
47
+ return P.instance || (P.instance = new P()), P.instance;
26
48
  }
27
49
  // Enhanced emit method with better typing and event storm protection
28
50
  /**
@@ -30,16 +52,16 @@ class B extends EventTarget {
30
52
  * @param eventName - Name of the event
31
53
  * @param data - Optional event payload
32
54
  */
33
- emit(t, n) {
34
- const r = Date.now(), o = this.eventCounters.get(t);
35
- if (!o || r - o.window > 1e3)
36
- this.eventCounters.set(t, { count: 1, window: r });
55
+ emit(t, r) {
56
+ const n = Date.now(), o = this.eventCounters.get(t);
57
+ if (!o || n - o.window > 1e3)
58
+ this.eventCounters.set(t, { count: 1, window: n });
37
59
  else if (o.count++, o.count > 50 && (console.error(`Event storm detected for "${t}": ${o.count} events in 1 second. Throttling...`), o.count > 100)) {
38
60
  console.warn(`Blocking further "${t}" events to prevent infinite loop`);
39
61
  return;
40
62
  }
41
63
  this.dispatchEvent(new CustomEvent(t, {
42
- detail: n,
64
+ detail: r,
43
65
  bubbles: !1,
44
66
  // Global events don't need to bubble
45
67
  cancelable: !0
@@ -47,9 +69,9 @@ class B extends EventTarget {
47
69
  const s = this.handlers[t];
48
70
  s && s.forEach((i) => {
49
71
  try {
50
- i(n);
51
- } catch (l) {
52
- console.error(`Error in global event handler for "${t}":`, l);
72
+ i(r);
73
+ } catch (a) {
74
+ console.error(`Error in global event handler for "${t}":`, a);
53
75
  }
54
76
  });
55
77
  }
@@ -58,17 +80,17 @@ class B extends EventTarget {
58
80
  * @param eventName - Name of the event
59
81
  * @param handler - Handler function
60
82
  */
61
- on(t, n) {
62
- return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(n), () => this.off(t, n);
83
+ on(t, r) {
84
+ return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(r), () => this.off(t, r);
63
85
  }
64
86
  /**
65
87
  * Remove a specific handler for a global event.
66
88
  * @param eventName - Name of the event
67
89
  * @param handler - Handler function to remove
68
90
  */
69
- off(t, n) {
70
- const r = this.handlers[t];
71
- r && r.delete(n);
91
+ off(t, r) {
92
+ const n = this.handlers[t];
93
+ n && n.delete(r);
72
94
  }
73
95
  /**
74
96
  * Remove all handlers for a specific event.
@@ -83,18 +105,18 @@ class B extends EventTarget {
83
105
  * @param handler - CustomEvent handler
84
106
  * @param options - AddEventListener options
85
107
  */
86
- listen(t, n, r) {
87
- return this.addEventListener(t, n, r), () => this.removeEventListener(t, n);
108
+ listen(t, r, n) {
109
+ return this.addEventListener(t, r, n), () => this.removeEventListener(t, r);
88
110
  }
89
111
  /**
90
112
  * Register a one-time event handler. Returns a promise that resolves with the event data.
91
113
  * @param eventName - Name of the event
92
114
  * @param handler - Handler function
93
115
  */
94
- once(t, n) {
95
- return new Promise((r) => {
116
+ once(t, r) {
117
+ return new Promise((n) => {
96
118
  const o = this.on(t, (s) => {
97
- o(), n(s), r(s);
119
+ o(), r(s), n(s);
98
120
  });
99
121
  });
100
122
  }
@@ -124,10 +146,10 @@ class B extends EventTarget {
124
146
  */
125
147
  getEventStats() {
126
148
  const t = {};
127
- for (const [n, r] of this.eventCounters.entries())
128
- t[n] = {
129
- count: r.count,
130
- handlersCount: this.getHandlerCount(n)
149
+ for (const [r, n] of this.eventCounters.entries())
150
+ t[r] = {
151
+ count: n.count,
152
+ handlersCount: this.getHandlerCount(r)
131
153
  };
132
154
  return t;
133
155
  }
@@ -138,436 +160,268 @@ class B extends EventTarget {
138
160
  this.eventCounters.clear();
139
161
  }
140
162
  }
141
- const Be = B.getInstance();
142
- function P(e, t = {}, n, r) {
143
- const o = r ?? t.key;
144
- return { tag: e, key: o, props: t, children: n };
163
+ const H = P.getInstance(), ot = (e, t) => H.emit(e, t), it = (e, t) => H.on(e, t), st = (e, t) => H.off(e, t), at = (e, t) => H.once(e, t), lt = (e, t, r) => H.listen(e, t, r);
164
+ function ie(e) {
165
+ let t = new Proxy(e, {
166
+ set: (i, a, l) => (i[a] = l, s(), !0)
167
+ });
168
+ const r = [];
169
+ function n(i) {
170
+ r.push(i), i(t);
171
+ }
172
+ function o() {
173
+ return t;
174
+ }
175
+ function s() {
176
+ r.forEach((i) => i(t));
177
+ }
178
+ return { subscribe: n, getState: o };
145
179
  }
146
- function I(e) {
147
- return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
180
+ function ne(e) {
181
+ return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
148
182
  }
149
- function R(e) {
150
- return typeof e == "object" && e !== null && "tag" in e && !I(e);
183
+ function ee(e) {
184
+ return typeof e == "string" ? e.replace(
185
+ /[&<>"']/g,
186
+ (t) => ({
187
+ "&": "&amp;",
188
+ "<": "&lt;",
189
+ ">": "&gt;",
190
+ '"': "&quot;",
191
+ "'": "&#39;"
192
+ })[t]
193
+ ) : e;
151
194
  }
152
- function le(e, t) {
153
- return e.key != null ? e : { ...e, key: t };
195
+ function xe(e, t, r) {
196
+ if (r)
197
+ for (const [n, o] of Object.entries(r)) {
198
+ let s, i = {};
199
+ if (Array.isArray(o) ? (s = o[0], i = o[1] || {}) : s = o, t.set(n, {
200
+ callback: s,
201
+ options: i,
202
+ oldValue: te(e, n)
203
+ }), i.immediate)
204
+ try {
205
+ const a = te(e, n);
206
+ s(a, void 0, e);
207
+ } catch (a) {
208
+ console.error(`Error in immediate watcher for "${n}":`, a);
209
+ }
210
+ }
154
211
  }
155
- function ce(e, t = [], n = {}) {
156
- const r = {}, o = {}, s = {}, i = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
157
- let l;
158
- for (; l = i.exec(e); ) {
159
- const c = l[1], d = l[2], p = (l[4] || l[6]) ?? "", u = p.match(/^{{(\d+)}}$/);
160
- let f = u ? t[Number(u[1])] ?? null : p;
161
- if (u || (f === "true" ? f = !0 : f === "false" ? f = !1 : f === "null" ? f = null : isNaN(Number(f)) || (f = Number(f))), c === ":")
162
- typeof f == "boolean" ? o[d] = f : f != null && (r[d] = f);
163
- else if (c === "@") {
164
- const m = "on" + d.charAt(0).toUpperCase() + d.slice(1);
165
- r[m] = typeof f == "function" ? f : typeof n[f] == "function" ? n[f] : void 0;
166
- } else if (c === "#") {
167
- const [m, ...h] = d.split("."), S = [...h];
168
- let y = f, a = [...S];
169
- if (m === "model" && typeof y == "string" && y.includes(".")) {
170
- const b = ["trim", "number", "lazy"], g = y.split(".");
171
- let x = y;
172
- const w = [];
173
- for (let k = g.length - 1; k > 0 && b.includes(g[k]); k--)
174
- w.unshift(g[k]), x = g.slice(0, k).join(".");
175
- y = x, a.push(...w);
176
- }
177
- s[m] = {
178
- value: y,
179
- modifiers: a
180
- };
181
- } else d === "ref" ? r.ref = f : o[d] = f;
182
- }
183
- return { props: r, attrs: o, directives: s };
212
+ function te(e, t) {
213
+ return t.split(".").reduce((r, n) => r?.[n], e);
184
214
  }
185
- function fe(e, t, n) {
186
- function r(a, b) {
187
- return P("#text", {}, a, b);
188
- }
189
- let o = "";
190
- for (let a = 0; a < e.length; a++)
191
- o += e[a], a < t.length && (o += `{{${a}}}`);
192
- const s = /<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g, i = [];
193
- let l = null, c, d = [], p = null, u = {}, f, m = 0, h = [];
194
- function S(a) {
195
- !a || typeof a != "object" || I(a) || (a.props || a.attrs ? (a.props && (u.props || (u.props = {}), Object.assign(u.props, a.props)), a.attrs && (u.attrs || (u.attrs = {}), Object.keys(a.attrs).forEach((b) => {
196
- if (b === "style" && u.attrs.style) {
197
- const g = u.attrs.style.replace(
198
- /;?\s*$/,
199
- ""
200
- ), x = a.attrs.style.replace(/^;?\s*/, "");
201
- u.attrs.style = g + "; " + x;
202
- } else if (b === "class" && u.attrs.class) {
203
- const g = u.attrs.class.trim().split(/\s+/).filter(Boolean), x = a.attrs.class.trim().split(/\s+/).filter(Boolean), w = [
204
- .../* @__PURE__ */ new Set([...g, ...x])
205
- ];
206
- u.attrs.class = w.join(" ");
207
- } else
208
- u.attrs[b] = a.attrs[b];
209
- }))) : (u.props || (u.props = {}), Object.assign(u.props, a)));
210
- }
211
- function y(a, b) {
212
- const g = p ? d : h;
213
- if (I(a)) {
214
- const x = a.key ?? b;
215
- let w = a.children;
216
- g.push({
217
- ...a,
218
- key: x,
219
- children: w
220
- });
221
- return;
222
- }
223
- if (R(a)) {
224
- g.push(le(a, void 0));
225
- return;
215
+ function we(e, t, r, n) {
216
+ const o = (i, a) => {
217
+ if (i === a) return !0;
218
+ if (typeof i != typeof a || typeof i != "object" || i === null || a === null) return !1;
219
+ if (Array.isArray(i) && Array.isArray(a))
220
+ return i.length !== a.length ? !1 : i.every((p, d) => o(p, a[d]));
221
+ const l = Object.keys(i), f = Object.keys(a);
222
+ return l.length !== f.length ? !1 : l.every((p) => o(i[p], a[p]));
223
+ }, s = t.get(r);
224
+ if (s && !o(n, s.oldValue))
225
+ try {
226
+ s.callback(n, s.oldValue, e), s.oldValue = n;
227
+ } catch (i) {
228
+ console.error(`Error in watcher for "${r}":`, i);
226
229
  }
227
- if (Array.isArray(a)) {
228
- if (a.length === 0) return;
229
- for (let x = 0; x < a.length; x++) {
230
- const w = a[x];
231
- I(w) || R(w) || Array.isArray(w) ? y(w, `${b}-${x}`) : w !== null && typeof w == "object" ? S(w) : g.push(r(String(w), `${b}-${x}`));
230
+ for (const [i, a] of t.entries())
231
+ if (a.options.deep && r.startsWith(i + "."))
232
+ try {
233
+ const l = te(e, i);
234
+ o(l, a.oldValue) || (a.callback(l, a.oldValue, e), a.oldValue = l);
235
+ } catch (l) {
236
+ console.error(`Error in deep watcher for "${i}":`, l);
232
237
  }
233
- return;
234
- }
235
- if (a !== null && typeof a == "object") {
236
- S(a);
237
- return;
238
- }
239
- g.push(r(String(a), b));
238
+ }
239
+ function ke(e, t, r) {
240
+ if (!t.props) return;
241
+ function n(o, s) {
242
+ return s === Boolean ? o === "true" : s === Number ? Number(o) : o;
240
243
  }
241
- for (; c = s.exec(o); )
242
- if (c[1]) {
243
- const a = c[1], b = c[0][1] === "/", g = c[0][c[0].length - 2] === "/", {
244
- props: x,
245
- attrs: w,
246
- directives: k
247
- } = ce(c[2] || "", t, n), $ = { props: {}, attrs: {} };
248
- for (const v in x) $.props[v] = x[v];
249
- for (const v in w) $.attrs[v] = w[v];
250
- for (const [v, _] of Object.entries(k))
251
- if (v === "bind")
252
- if (typeof _.value == "object" && _.value !== null)
253
- for (const [A, E] of Object.entries(_.value))
254
- typeof E == "boolean" ? $.attrs[A] = E : E != null && ($.attrs[A] = String(E));
255
- else _.value != null && ($.attrs[v] = String(_.value));
256
- else if (v === "show") {
257
- const A = !!_.value;
258
- $.attrs.style = ($.attrs.style || "") + (A ? "" : "; display: none !important");
259
- } else if (v === "class") {
260
- const A = _.value;
261
- let E = [];
262
- if (typeof A == "string")
263
- E = A.split(/\s+/).filter(Boolean);
264
- else if (Array.isArray(A)) {
265
- for (const j of A)
266
- if (typeof j == "string")
267
- E.push(...j.split(/\s+/).filter(Boolean));
268
- else if (j && typeof j == "object")
269
- for (const [L, N] of Object.entries(j))
270
- N && E.push(...L.split(/\s+/).filter(Boolean));
271
- } else if (A && typeof A == "object")
272
- for (const [j, L] of Object.entries(A))
273
- L && E.push(...j.split(/\s+/).filter(Boolean));
274
- const O = $.attrs.class || "", M = [
275
- .../* @__PURE__ */ new Set([
276
- ...O.split(/\s+/).filter(Boolean),
277
- ...E
278
- ])
279
- ];
280
- $.attrs.class = M.join(" ");
281
- } else if (v === "style") {
282
- const A = _.value;
283
- let E = "";
284
- if (typeof A == "string")
285
- E = A;
286
- else if (A && typeof A == "object") {
287
- const M = [];
288
- for (const [j, L] of Object.entries(A))
289
- if (L != null && L !== "") {
290
- const N = j.replace(
291
- /[A-Z]/g,
292
- (ae) => `-${ae.toLowerCase()}`
293
- ), se = [
294
- "width",
295
- "height",
296
- "top",
297
- "right",
298
- "bottom",
299
- "left",
300
- "margin",
301
- "margin-top",
302
- "margin-right",
303
- "margin-bottom",
304
- "margin-left",
305
- "padding",
306
- "padding-top",
307
- "padding-right",
308
- "padding-bottom",
309
- "padding-left",
310
- "font-size",
311
- "line-height",
312
- "border-width",
313
- "border-radius",
314
- "min-width",
315
- "max-width",
316
- "min-height",
317
- "max-height"
318
- ];
319
- let X = String(L);
320
- typeof L == "number" && se.includes(N) && (X = `${L}px`), M.push(`${N}: ${X}`);
321
- }
322
- E = M.join("; ") + (M.length > 0 ? ";" : "");
323
- }
324
- const O = $.attrs.style || "";
325
- $.attrs.style = O + (O && !O.endsWith(";") ? "; " : "") + E;
326
- }
327
- const C = {};
328
- for (const [v, _] of Object.entries(k))
329
- ["bind", "show", "class", "style"].includes(v) || (C[v] = _);
330
- if (Object.keys(C).length > 0 && ($.directives = C), b) {
331
- const v = P(
332
- p,
333
- u,
334
- d.length === 1 && R(d[0]) && d[0].tag === "#text" ? typeof d[0].children == "string" ? d[0].children : "" : d.length ? d : void 0,
335
- f
336
- ), _ = i.pop();
337
- _ ? (p = _.tag, u = _.props, f = _.key, d = _.children, d.push(v)) : l = v;
338
- } else g ? (p ? d : h).push(P(a, $, void 0, void 0)) : (p && i.push({
339
- tag: p,
340
- props: u,
341
- children: d,
342
- key: f
343
- }), p = a, u = $, d = []);
344
- } else if (typeof c[3] < "u") {
345
- const a = Number(c[3]), b = t[a], g = `interp-${a}`;
346
- y(b, g);
347
- } else if (c[4]) {
348
- const a = c[4], b = p ? d : h, g = a.split(/({{\d+}})/);
349
- for (const x of g) {
350
- if (!x) continue;
351
- const w = x.match(/^{{(\d+)}}$/);
352
- if (w) {
353
- const k = Number(w[1]), $ = t[k], C = `interp-${k}`;
354
- y($, C);
355
- } else {
356
- const k = `text-${m++}`;
357
- b.push(r(x, k));
358
- }
359
- }
244
+ Object.entries(t.props).forEach(([o, s]) => {
245
+ if (s.type === Function && typeof e[o] == "function")
246
+ r[o] = e[o];
247
+ else {
248
+ const i = e.getAttribute(ne(o));
249
+ i !== null ? r[o] = ee(n(i, s.type)) : "default" in s && s.default !== void 0 && (r[o] = ee(s.default));
360
250
  }
361
- if (l)
362
- return R(l) && Array.isArray(l.children) && (l.children = l.children.filter(
363
- (a) => R(a) ? a.tag !== "#text" || typeof a.children == "string" && a.children.trim() !== "" : !0
364
- // keep non-element VNodes (including anchors) as-is
365
- )), l;
366
- if (h.length > 0) {
367
- const a = h.filter(
368
- (b) => R(b) ? b.tag !== "#text" || typeof b.children == "string" && b.children.trim() !== "" : !0
369
- );
370
- return a.length === 1 ? a[0] : a;
371
- }
372
- return P("div", {}, "", "fallback-root");
373
- }
374
- function Oe(e, ...t) {
375
- const n = t[t.length - 1], r = typeof n == "object" && n && !Array.isArray(n) ? n : void 0;
376
- return fe(e, t, r);
377
- }
378
- function Me(e, t) {
379
- return K(e ? t : [], "when-block");
380
- }
381
- function Ne(e, t) {
382
- return e.map((n, r) => {
383
- const o = typeof n == "object" ? n?.key ?? n?.id ?? `idx-${r}` : String(n);
384
- return K(t(n, r), `each-${o}`);
385
251
  });
386
252
  }
387
- function Pe() {
388
- const e = [];
389
- return {
390
- when(t, n) {
391
- return e.push([t, n]), this;
392
- },
393
- otherwise(t) {
394
- return e.push([!0, t]), this;
395
- },
396
- done() {
397
- return ue(...e);
398
- }
399
- };
253
+ function $e(e, t, r, n) {
254
+ e.onConnected && !r && (e.onConnected(t), n(!0));
400
255
  }
401
- function ue(...e) {
402
- for (let t = 0; t < e.length; t++) {
403
- const [n, r] = e[t];
404
- if (n) return [K(r, `whenChain-branch-${t}`)];
405
- }
406
- return [K([], "whenChain-empty")];
256
+ function Ce(e, t, r, n, o, s, i, a) {
257
+ e.onDisconnected && e.onDisconnected(t), r.forEach((l) => l()), n(), o(), s(!1), i(null), a(!1);
407
258
  }
408
- function K(e, t) {
409
- const n = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
410
- return {
411
- tag: "#anchor",
412
- key: t,
413
- children: n
414
- };
259
+ function Se(e, t, r, n, o) {
260
+ e.onAttributeChanged && e.onAttributeChanged(t, r, n, o);
415
261
  }
416
262
  function z(e, t) {
417
- return t.split(".").reduce((n, r) => n?.[r], e);
263
+ if (t && e instanceof HTMLElement) {
264
+ for (const r in t)
265
+ t[r] === e && delete t[r];
266
+ for (const r of Array.from(e.childNodes))
267
+ z(r, t);
268
+ }
269
+ }
270
+ function R(e, t) {
271
+ return t.split(".").reduce((r, n) => r?.[n], e);
418
272
  }
419
- function Y(e, t, n) {
420
- const r = t.split("."), o = r.pop();
273
+ function se(e, t, r) {
274
+ const n = t.split("."), o = n.pop();
421
275
  if (!o) return;
422
- const s = r.reduce((i, l) => (l in i || (i[l] = {}), i[l]), e);
423
- s[o] = n;
276
+ const s = n.reduce((i, a) => (a in i || (i[a] = {}), i[a]), e);
277
+ s[o] = r;
424
278
  }
425
- function de(e, t, n, r, o, s, i) {
279
+ function _e(e, t, r, n, o, s, i) {
426
280
  if (!s) return;
427
- const l = t.includes("lazy"), c = t.includes("trim"), d = t.includes("number"), p = () => {
281
+ const a = t.includes("lazy"), l = t.includes("trim"), f = t.includes("number"), p = () => {
428
282
  const y = s._state || s;
429
- return z(y, e);
430
- }, u = p();
431
- let f = "text";
432
- const m = r?.type;
433
- if (i instanceof HTMLInputElement ? f = m || i.type || "text" : i instanceof HTMLSelectElement ? f = "select" : i instanceof HTMLTextAreaElement && (f = "textarea"), f === "checkbox")
434
- if (Array.isArray(u)) {
435
- const y = i?.getAttribute("value") || r?.value || "", a = u.includes(y);
436
- i && i.checked !== a && (n.checked = a);
283
+ return R(y, e);
284
+ }, d = p();
285
+ let u = "text";
286
+ const m = n?.type;
287
+ if (i instanceof HTMLInputElement ? u = m || i.type || "text" : i instanceof HTMLSelectElement ? u = "select" : i instanceof HTMLTextAreaElement && (u = "textarea"), u === "checkbox")
288
+ if (Array.isArray(d)) {
289
+ const y = i?.getAttribute("value") || n?.value || "", c = d.includes(y);
290
+ i && i.checked !== c && (r.checked = c);
437
291
  } else {
438
- const y = i?.getAttribute("true-value") || !0, a = u === y;
439
- i && i.checked !== a && (n.checked = a);
292
+ const y = i?.getAttribute("true-value") || !0, c = d === y;
293
+ i && i.checked !== c && (r.checked = c);
440
294
  }
441
- else if (f === "radio") {
442
- const y = r?.value || "", a = u === y;
443
- i && i.checked !== a && (n.checked = a);
444
- } else if (f === "select")
295
+ else if (u === "radio") {
296
+ const y = n?.value || "", c = d === y;
297
+ i && i.checked !== c && (r.checked = c);
298
+ } else if (u === "select")
445
299
  if (i && i.hasAttribute("multiple")) {
446
- const y = i, a = Array.isArray(u) ? u : [];
300
+ const y = i, c = Array.isArray(d) ? d : [];
447
301
  setTimeout(() => {
448
302
  Array.from(y.options).forEach((b) => {
449
- const g = a.includes(b.value);
303
+ const g = c.includes(b.value);
450
304
  b.selected !== g && (b.selected = g);
451
305
  });
452
306
  }, 0);
453
307
  } else
454
308
  setTimeout(() => {
455
- i instanceof HTMLSelectElement && i.value !== String(u) && (i.value = String(u));
309
+ i instanceof HTMLSelectElement && i.value !== String(d) && (i.value = String(d));
456
310
  }, 0);
457
311
  else {
458
- const y = String(u ?? "");
459
- (!i || i.value !== y) && (n.value = u);
312
+ const y = String(d ?? "");
313
+ (!i || i.value !== y) && (r.value = d);
460
314
  }
461
- const h = l || f === "checkbox" || f === "radio" || f === "select" ? "change" : "input", S = (y) => {
315
+ const h = a || u === "checkbox" || u === "radio" || u === "select" ? "change" : "input", C = (y) => {
462
316
  if (y.isComposing || o._isComposing || y.isTrusted === !1) return;
463
- const a = y.target;
464
- if (a._modelUpdating) return;
317
+ const c = y.target;
318
+ if (c._modelUpdating) return;
465
319
  const b = p();
466
- let g = a.value;
467
- if (f === "checkbox")
320
+ let g = c.value;
321
+ if (u === "checkbox")
468
322
  if (Array.isArray(b)) {
469
- const $ = a.getAttribute("value") || "", C = [...b];
470
- if (a.checked)
471
- C.includes($) || C.push($);
323
+ const S = c.getAttribute("value") || "", _ = [...b];
324
+ if (c.checked)
325
+ _.includes(S) || _.push(S);
472
326
  else {
473
- const v = C.indexOf($);
474
- v > -1 && C.splice(v, 1);
327
+ const x = _.indexOf(S);
328
+ x > -1 && _.splice(x, 1);
475
329
  }
476
- g = C;
330
+ g = _;
477
331
  } else {
478
- const $ = a.getAttribute("true-value") || !0, C = a.getAttribute("false-value") || !1;
479
- g = a.checked ? $ : C;
332
+ const S = c.getAttribute("true-value") || !0, _ = c.getAttribute("false-value") || !1;
333
+ g = c.checked ? S : _;
480
334
  }
481
- else if (f === "radio")
482
- g = a.getAttribute("value") || a.value;
483
- else if (f === "select" && a.multiple) {
484
- const $ = a;
485
- g = Array.from($.selectedOptions).map(
486
- (C) => C.value
335
+ else if (u === "radio")
336
+ g = c.getAttribute("value") || c.value;
337
+ else if (u === "select" && c.multiple) {
338
+ const S = c;
339
+ g = Array.from(S.selectedOptions).map(
340
+ (_) => _.value
487
341
  );
488
- } else if (c && (g = g.trim()), d) {
489
- const $ = Number(g);
490
- isNaN($) || (g = $);
342
+ } else if (l && (g = g.trim()), f) {
343
+ const S = Number(g);
344
+ isNaN(S) || (g = S);
491
345
  }
492
- const x = s._state || s, w = z(x, e);
346
+ const v = s._state || s, w = R(v, e);
493
347
  if (Array.isArray(g) && Array.isArray(w) ? JSON.stringify([...g].sort()) !== JSON.stringify([...w].sort()) : g !== w) {
494
- const $ = y.target;
495
- $._modelUpdating = !0, Y(x, e, g), setTimeout(() => {
496
- $._modelUpdating = !1;
348
+ const S = y.target;
349
+ S._modelUpdating = !0, se(v, e, g), setTimeout(() => {
350
+ S._modelUpdating = !1;
497
351
  }, 0), s._requestRender && s._requestRender();
498
352
  }
499
353
  };
500
- if (o[h] = S, f === "text" || f === "textarea") {
354
+ if (o[h] = C, u === "text" || u === "textarea") {
501
355
  const y = () => {
502
356
  o._isComposing = !0;
503
- }, a = (b) => {
357
+ }, c = (b) => {
504
358
  o._isComposing = !1;
505
359
  const g = b.target;
506
360
  setTimeout(() => {
507
361
  if (g) {
508
- let x = g.value;
509
- if (c && (x = x.trim()), d) {
510
- const C = Number(x);
511
- isNaN(C) || (x = C);
362
+ let v = g.value;
363
+ if (l && (v = v.trim()), f) {
364
+ const _ = Number(v);
365
+ isNaN(_) || (v = _);
512
366
  }
513
- const w = s._state || s, k = z(w, e);
514
- (Array.isArray(x) && Array.isArray(k) ? JSON.stringify([...x].sort()) !== JSON.stringify([...k].sort()) : x !== k) && (g && (g._modelUpdating = !0, setTimeout(() => {
367
+ const w = s._state || s, k = R(w, e);
368
+ (Array.isArray(v) && Array.isArray(k) ? JSON.stringify([...v].sort()) !== JSON.stringify([...k].sort()) : v !== k) && (g && (g._modelUpdating = !0, setTimeout(() => {
515
369
  g._modelUpdating = !1;
516
- }, 0)), Y(w, e, x), s._requestRender && s._requestRender());
370
+ }, 0)), se(w, e, v), s._requestRender && s._requestRender());
517
371
  }
518
372
  }, 0);
519
373
  };
520
- o.compositionstart = y, o.compositionend = a;
374
+ o.compositionstart = y, o.compositionend = c;
521
375
  }
522
376
  }
523
- function pe(e, t, n, r) {
524
- if (r)
377
+ function Ae(e, t, r, n) {
378
+ if (n)
525
379
  try {
526
380
  const o = JSON.parse(e);
527
381
  if (typeof o == "object")
528
382
  for (const [s, i] of Object.entries(o))
529
383
  t[s] = i;
530
384
  } catch {
531
- const o = z(r, e);
532
- n[e] = o;
385
+ const o = R(n, e);
386
+ r[e] = o;
533
387
  }
534
388
  }
535
- function he(e, t, n) {
536
- if (!n) return;
537
- const r = z(n, e), o = t.style || "", s = r ? "" : "none";
389
+ function Ee(e, t, r) {
390
+ if (!r) return;
391
+ const n = R(r, e), o = t.style || "", s = n ? "" : "none";
538
392
  if (o) {
539
- const i = o.split(";").filter(Boolean), l = i.findIndex(
540
- (c) => c.trim().startsWith("display:")
393
+ const i = o.split(";").filter(Boolean), a = i.findIndex(
394
+ (l) => l.trim().startsWith("display:")
541
395
  );
542
- l >= 0 ? i[l] = `display: ${s}` : i.push(`display: ${s}`), t.style = i.join("; ");
396
+ a >= 0 ? i[a] = `display: ${s}` : i.push(`display: ${s}`), t.style = i.join("; ");
543
397
  } else
544
398
  t.style = `display: ${s}`;
545
399
  }
546
- function ge(e, t, n) {
547
- if (!n) return;
548
- const r = z(n, e);
400
+ function Te(e, t, r) {
401
+ if (!r) return;
402
+ const n = R(r, e);
549
403
  let o = [];
550
- typeof r == "string" ? o = [r] : Array.isArray(r) ? o = r.filter(Boolean) : typeof r == "object" && (o = Object.entries(r).filter(([, l]) => !!l).map(([l]) => l));
404
+ typeof n == "string" ? o = [n] : Array.isArray(n) ? o = n.filter(Boolean) : typeof n == "object" && (o = Object.entries(n).filter(([, a]) => !!a).map(([a]) => a));
551
405
  const s = t.class || "", i = s ? `${s} ${o.join(" ")}`.trim() : o.join(" ");
552
406
  i && (t.class = i);
553
407
  }
554
- function me(e, t, n) {
555
- let r;
408
+ function je(e, t, r) {
409
+ let n;
556
410
  if (typeof e == "string") {
557
- if (!n) return;
558
- r = z(n, e);
411
+ if (!r) return;
412
+ n = R(r, e);
559
413
  } else
560
- r = e;
414
+ n = e;
561
415
  let o = "";
562
- if (typeof r == "string")
563
- o = r;
564
- else if (r && typeof r == "object") {
416
+ if (typeof n == "string")
417
+ o = n;
418
+ else if (n && typeof n == "object") {
565
419
  const i = [];
566
- for (const [l, c] of Object.entries(r))
567
- if (c != null && c !== "") {
568
- const d = l.replace(
420
+ for (const [a, l] of Object.entries(n))
421
+ if (l != null && l !== "") {
422
+ const f = a.replace(
569
423
  /[A-Z]/g,
570
- (f) => `-${f.toLowerCase()}`
424
+ (u) => `-${u.toLowerCase()}`
571
425
  ), p = [
572
426
  "width",
573
427
  "height",
@@ -594,336 +448,334 @@ function me(e, t, n) {
594
448
  "min-height",
595
449
  "max-height"
596
450
  ];
597
- let u = String(c);
598
- typeof c == "number" && p.includes(d) && (u = `${c}px`), i.push(`${d}: ${u}`);
451
+ let d = String(l);
452
+ typeof l == "number" && p.includes(f) && (d = `${l}px`), i.push(`${f}: ${d}`);
599
453
  }
600
454
  o = i.join("; ") + (i.length > 0 ? ";" : "");
601
455
  }
602
456
  const s = t.style || "";
603
457
  t.style = s + (s && !s.endsWith(";") ? "; " : "") + o;
604
458
  }
605
- function ie(e, t, n, r) {
606
- const o = {}, s = { ...r || {} }, i = {};
607
- for (const [l, c] of Object.entries(e)) {
608
- const { value: d, modifiers: p } = c;
609
- switch (l) {
459
+ function pe(e, t, r, n) {
460
+ const o = {}, s = { ...n || {} }, i = {};
461
+ for (const [a, l] of Object.entries(e)) {
462
+ const { value: f, modifiers: p } = l;
463
+ switch (a) {
610
464
  case "model":
611
- de(
612
- typeof d == "string" ? d : String(d),
465
+ _e(
466
+ typeof f == "string" ? f : String(f),
613
467
  p,
614
468
  o,
615
469
  s,
616
470
  i,
617
471
  t,
618
- n
472
+ r
619
473
  );
620
474
  break;
621
475
  case "bind":
622
- pe(d, o, s, t);
476
+ Ae(f, o, s, t);
623
477
  break;
624
478
  case "show":
625
- he(d, s, t);
479
+ Ee(f, s, t);
626
480
  break;
627
481
  case "class":
628
- ge(d, s, t);
482
+ Te(f, s, t);
629
483
  break;
630
484
  case "style":
631
- me(d, s, t);
485
+ je(f, s, t);
632
486
  break;
633
487
  }
634
488
  }
635
489
  return { props: o, attrs: s, listeners: i };
636
490
  }
637
- function Z(e, t) {
491
+ function re(e, t) {
638
492
  if (Array.isArray(e)) {
639
493
  const s = /* @__PURE__ */ new Set();
640
494
  return e.map((i) => {
641
495
  if (!i || typeof i != "object") return i;
642
- let l = i.props?.key ?? i.key;
643
- if (!l) {
644
- const u = i.tag || "node", f = i.props?.attrs?.id ?? i.props?.attrs?.name ?? i.props?.attrs?.["data-key"] ?? "";
645
- l = f ? `${t}:${u}:${f}` : `${t}:${u}`;
496
+ let a = i.props?.key ?? i.key;
497
+ if (!a) {
498
+ const d = i.tag || "node", u = i.props?.attrs?.id ?? i.props?.attrs?.name ?? i.props?.attrs?.["data-key"] ?? "";
499
+ a = u ? `${t}:${d}:${u}` : `${t}:${d}`;
646
500
  }
647
- let c = l, d = 1;
648
- for (; s.has(c); )
649
- c = `${l}#${d++}`;
650
- s.add(c);
501
+ let l = a, f = 1;
502
+ for (; s.has(l); )
503
+ l = `${a}#${f++}`;
504
+ s.add(l);
651
505
  let p = i.children;
652
- return Array.isArray(p) && (p = Z(p, c)), { ...i, key: c, children: p };
506
+ return Array.isArray(p) && (p = re(p, l)), { ...i, key: l, children: p };
653
507
  });
654
508
  }
655
- const n = e;
656
- let r = n.props?.key ?? n.key ?? t, o = n.children;
657
- return Array.isArray(o) && (o = Z(o, r)), { ...n, key: r, children: o };
509
+ const r = e;
510
+ let n = r.props?.key ?? r.key ?? t, o = r.children;
511
+ return Array.isArray(o) && (o = re(o, n)), { ...r, key: n, children: o };
658
512
  }
659
- function ye(e, t, n, r) {
660
- const o = n.directives ?? {}, s = ie(
513
+ function Le(e, t, r, n) {
514
+ const o = r.directives ?? {}, s = pe(
661
515
  o,
662
- r,
516
+ n,
663
517
  e,
664
- n.attrs
518
+ r.attrs
665
519
  ), i = {
666
520
  ...t.props,
667
- ...n.props,
521
+ ...r.props,
668
522
  ...s.props
669
- }, l = {
523
+ }, a = {
670
524
  ...t.attrs,
671
- ...n.attrs,
525
+ ...r.attrs,
672
526
  ...s.attrs
673
- }, c = t.props ?? {}, d = i;
674
- for (const f in { ...c, ...d }) {
675
- const m = c[f], h = d[f];
676
- m !== h && (f === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? e.value !== h && (e.value = h ?? "") : f === "checked" && e instanceof HTMLInputElement ? e.checked = !!h : f.startsWith("on") && typeof h == "function" ? (typeof m == "function" && e.removeEventListener(f.slice(2).toLowerCase(), m), e.addEventListener(f.slice(2).toLowerCase(), h)) : h == null || h === !1 ? e.removeAttribute(f) : e.setAttribute(f, String(h)));
527
+ }, l = t.props ?? {}, f = i;
528
+ for (const u in { ...l, ...f }) {
529
+ const m = l[u], h = f[u];
530
+ m !== h && (u === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? e.value !== h && (e.value = h ?? "") : u === "checked" && e instanceof HTMLInputElement ? e.checked = !!h : u.startsWith("on") && typeof h == "function" ? (typeof m == "function" && e.removeEventListener(u.slice(2).toLowerCase(), m), e.addEventListener(u.slice(2).toLowerCase(), h)) : h == null || h === !1 ? e.removeAttribute(u) : e.setAttribute(u, String(h)));
677
531
  }
678
- for (const [f, m] of Object.entries(
532
+ for (const [u, m] of Object.entries(
679
533
  s.listeners || {}
680
534
  ))
681
- e.addEventListener(f, m);
682
- const p = t.attrs ?? {}, u = l;
683
- for (const f in { ...p, ...u }) {
684
- const m = p[f], h = u[f];
685
- m !== h && (h == null || h === !1 ? e.removeAttribute(f) : e.setAttribute(f, String(h)));
535
+ e.addEventListener(u, m);
536
+ const p = t.attrs ?? {}, d = a;
537
+ for (const u in { ...p, ...d }) {
538
+ const m = p[u], h = d[u];
539
+ m !== h && (h == null || h === !1 ? e.removeAttribute(u) : e.setAttribute(u, String(h)));
686
540
  }
687
541
  }
688
- function T(e, t, n) {
542
+ function T(e, t, r) {
689
543
  if (typeof e == "string")
690
544
  return document.createTextNode(e);
691
545
  if (e.tag === "#text") {
692
- const u = document.createTextNode(
546
+ const d = document.createTextNode(
693
547
  typeof e.children == "string" ? e.children : ""
694
548
  );
695
- return e.key != null && (u.key = e.key), u;
549
+ return e.key != null && (d.key = e.key), d;
696
550
  }
697
551
  if (e.tag === "#anchor") {
698
- const u = e, f = Array.isArray(u.children) ? u.children : [], m = document.createTextNode(""), h = document.createTextNode("");
699
- u.key != null && (m.key = `${u.key}:start`, h.key = `${u.key}:end`), u._startNode = m, u._endNode = h;
700
- const S = document.createDocumentFragment();
701
- S.appendChild(m);
702
- for (const y of f)
703
- S.appendChild(T(y, t));
704
- return S.appendChild(h), S;
705
- }
706
- const r = document.createElement(e.tag);
707
- e.key != null && (r.key = e.key);
708
- const { props: o = {}, attrs: s = {}, directives: i = {} } = e.props ?? {}, l = ie(i, t, r, s), c = {
552
+ const d = e, u = Array.isArray(d.children) ? d.children : [], m = document.createTextNode(""), h = document.createTextNode("");
553
+ d.key != null && (m.key = `${d.key}:start`, h.key = `${d.key}:end`), d._startNode = m, d._endNode = h;
554
+ const C = document.createDocumentFragment();
555
+ C.appendChild(m);
556
+ for (const y of u)
557
+ C.appendChild(T(y, t));
558
+ return C.appendChild(h), C;
559
+ }
560
+ const n = document.createElement(e.tag);
561
+ e.key != null && (n.key = e.key);
562
+ const { props: o = {}, attrs: s = {}, directives: i = {} } = e.props ?? {}, a = pe(i, t, n, s), l = {
709
563
  ...o,
710
- ...l.props
711
- }, d = {
564
+ ...a.props
565
+ }, f = {
712
566
  ...s,
713
- ...l.attrs
567
+ ...a.attrs
714
568
  };
715
- for (const u in d) {
716
- const f = d[u];
717
- typeof f == "boolean" ? f && r.setAttribute(u, "") : f != null && r.setAttribute(u, String(f));
718
- }
719
- for (const u in c) {
720
- const f = c[u];
721
- if (u === "value" && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement))
722
- r.value = f ?? "";
723
- else if (u === "checked" && r instanceof HTMLInputElement)
724
- r.checked = !!f;
725
- else if (u.startsWith("on") && typeof f == "function")
726
- r.addEventListener(u.slice(2).toLowerCase(), f);
569
+ for (const d in f) {
570
+ const u = f[d];
571
+ typeof u == "boolean" ? u && n.setAttribute(d, "") : u != null && n.setAttribute(d, String(u));
572
+ }
573
+ for (const d in l) {
574
+ const u = l[d];
575
+ if (d === "value" && (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement))
576
+ n.value = u ?? "";
577
+ else if (d === "checked" && n instanceof HTMLInputElement)
578
+ n.checked = !!u;
579
+ else if (d.startsWith("on") && typeof u == "function")
580
+ n.addEventListener(d.slice(2).toLowerCase(), u);
727
581
  else {
728
- if (u.startsWith("on") && f === void 0)
582
+ if (d.startsWith("on") && u === void 0)
729
583
  continue;
730
- f == null || f === !1 ? r.removeAttribute(u) : r.setAttribute(u, String(f));
584
+ u == null || u === !1 ? n.removeAttribute(d) : n.setAttribute(d, String(u));
731
585
  }
732
586
  }
733
- for (const [u, f] of Object.entries(
734
- l.listeners || {}
587
+ for (const [d, u] of Object.entries(
588
+ a.listeners || {}
735
589
  ))
736
- r.addEventListener(u, f);
590
+ n.addEventListener(d, u);
737
591
  const p = e.props?.ref ?? (e.props?.props && e.props.props.ref);
738
- if (typeof e != "string" && p && n && (n[p] = r), Array.isArray(e.children))
739
- for (const u of e.children)
740
- r.appendChild(T(u, t, n));
741
- else typeof e.children == "string" && (r.textContent = e.children);
742
- return r;
592
+ if (typeof e != "string" && p && r && (r[p] = n), Array.isArray(e.children))
593
+ for (const d of e.children)
594
+ n.appendChild(T(d, t, r));
595
+ else typeof e.children == "string" && (n.textContent = e.children);
596
+ return n;
743
597
  }
744
- function be(e, t, n, r, o) {
745
- if (typeof n == "string") {
746
- e.textContent !== n && (e.textContent = n);
598
+ function Be(e, t, r, n, o) {
599
+ if (typeof r == "string") {
600
+ e.textContent !== r && (e.textContent = r);
747
601
  return;
748
602
  }
749
- if (!Array.isArray(n)) return;
750
- const s = Array.from(e.childNodes), i = Array.isArray(t) ? t : [], l = /* @__PURE__ */ new Map();
603
+ if (!Array.isArray(r)) return;
604
+ const s = Array.from(e.childNodes), i = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
751
605
  for (const m of i)
752
- m && m.key != null && l.set(m.key, m);
753
- const c = /* @__PURE__ */ new Map();
606
+ m && m.key != null && a.set(m.key, m);
607
+ const l = /* @__PURE__ */ new Map();
754
608
  for (const m of s) {
755
609
  const h = m.key;
756
- h != null && c.set(h, m);
610
+ h != null && l.set(h, m);
757
611
  }
758
- const d = /* @__PURE__ */ new Set();
612
+ const f = /* @__PURE__ */ new Set();
759
613
  let p = e.firstChild;
760
- function u(m, h) {
761
- let S = m;
762
- for (; S && (d.add(S), S !== h); )
763
- S = S.nextSibling;
614
+ function d(m, h) {
615
+ let C = m;
616
+ for (; C && (f.add(C), C !== h); )
617
+ C = C.nextSibling;
764
618
  }
765
- function f(m, h, S, y) {
766
- const a = [];
619
+ function u(m, h, C, y) {
620
+ const c = [];
767
621
  let b = m.nextSibling;
768
622
  for (; b && b !== h; )
769
- a.push(b), b = b.nextSibling;
770
- const g = Array.isArray(S) ? S : [];
623
+ c.push(b), b = b.nextSibling;
624
+ const g = Array.isArray(C) ? C : [];
771
625
  if (y.some((w) => w && w.key != null) || g.some((w) => w && w.key != null)) {
772
626
  const w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
773
- for (const v of g)
774
- v && v.key != null && w.set(v.key, v);
775
- for (const v of a) {
776
- const _ = v.key;
777
- _ != null && k.set(_, v);
627
+ for (const x of g)
628
+ x && x.key != null && w.set(x.key, x);
629
+ for (const x of c) {
630
+ const $ = x.key;
631
+ $ != null && k.set($, x);
778
632
  }
779
- const $ = /* @__PURE__ */ new Set();
780
- let C = m.nextSibling;
781
- for (const v of y) {
782
- let _;
783
- if (v.key != null && k.has(v.key)) {
784
- const A = w.get(v.key);
785
- _ = D(
786
- k.get(v.key),
633
+ const S = /* @__PURE__ */ new Set();
634
+ let _ = m.nextSibling;
635
+ for (const x of y) {
636
+ let $;
637
+ if (x.key != null && k.has(x.key)) {
638
+ const A = w.get(x.key);
639
+ $ = K(
640
+ k.get(x.key),
787
641
  A,
788
- v,
789
- r
790
- ), $.add(_), _ !== C && e.contains(_) && e.insertBefore(_, C);
642
+ x,
643
+ n
644
+ ), S.add($), $ !== _ && e.contains($) && e.insertBefore($, _);
791
645
  } else
792
- _ = T(v, r), e.insertBefore(_, C), $.add(_);
793
- C = _.nextSibling;
646
+ $ = T(x, n), e.insertBefore($, _), S.add($);
647
+ _ = $.nextSibling;
794
648
  }
795
- for (const v of a)
796
- !$.has(v) && e.contains(v) && e.removeChild(v);
649
+ for (const x of c)
650
+ !S.has(x) && e.contains(x) && e.removeChild(x);
797
651
  } else {
798
652
  const w = Math.min(
799
653
  g.length,
800
654
  y.length
801
655
  );
802
656
  for (let k = 0; k < w; k++) {
803
- const $ = g[k], C = y[k], v = D(a[k], $, C, r);
804
- v !== a[k] && (e.insertBefore(v, a[k]), e.removeChild(a[k]));
657
+ const S = g[k], _ = y[k], x = K(c[k], S, _, n);
658
+ x !== c[k] && (e.insertBefore(x, c[k]), e.removeChild(c[k]));
805
659
  }
806
660
  for (let k = w; k < y.length; k++)
807
- e.insertBefore(T(y[k], r), h);
808
- for (let k = w; k < a.length; k++)
809
- e.removeChild(a[k]);
661
+ e.insertBefore(T(y[k], n), h);
662
+ for (let k = w; k < c.length; k++)
663
+ e.removeChild(c[k]);
810
664
  }
811
665
  }
812
- for (const m of n) {
666
+ for (const m of r) {
813
667
  let h;
814
668
  if (m.tag === "#anchor") {
815
- const S = m.key, y = `${S}:start`, a = `${S}:end`;
816
- let b = c.get(y), g = c.get(a);
817
- const x = Array.isArray(m.children) ? m.children : [];
818
- if (b || (b = document.createTextNode(""), b.key = y), g || (g = document.createTextNode(""), g.key = a), m._startNode = b, m._endNode = g, !e.contains(b) || !e.contains(g)) {
669
+ const C = m.key, y = `${C}:start`, c = `${C}:end`;
670
+ let b = l.get(y), g = l.get(c);
671
+ const v = Array.isArray(m.children) ? m.children : [];
672
+ if (b || (b = document.createTextNode(""), b.key = y), g || (g = document.createTextNode(""), g.key = c), m._startNode = b, m._endNode = g, !e.contains(b) || !e.contains(g)) {
819
673
  e.insertBefore(b, p);
820
- for (const w of x)
821
- e.insertBefore(T(w, r), p);
674
+ for (const w of v)
675
+ e.insertBefore(T(w, n), p);
822
676
  e.insertBefore(g, p);
823
677
  } else
824
- f(
678
+ u(
825
679
  b,
826
680
  g,
827
- l.get(S)?.children,
828
- x
681
+ a.get(C)?.children,
682
+ v
829
683
  );
830
- u(b, g), p = g.nextSibling;
684
+ d(b, g), p = g.nextSibling;
831
685
  continue;
832
686
  }
833
- if (m.key != null && c.has(m.key)) {
834
- const S = l.get(m.key);
835
- h = D(
836
- c.get(m.key),
837
- S,
687
+ if (m.key != null && l.has(m.key)) {
688
+ const C = a.get(m.key);
689
+ h = K(
690
+ l.get(m.key),
691
+ C,
838
692
  m,
839
- r,
693
+ n,
840
694
  o
841
- ), d.add(h), h !== p && e.contains(h) && (p && !e.contains(p) && (p = null), e.insertBefore(h, p));
695
+ ), f.add(h), h !== p && e.contains(h) && (p && !e.contains(p) && (p = null), e.insertBefore(h, p));
842
696
  } else
843
- h = T(m, r, o), p && !e.contains(p) && (p = null), e.insertBefore(h, p), d.add(h);
697
+ h = T(m, n, o), p && !e.contains(p) && (p = null), e.insertBefore(h, p), f.add(h);
844
698
  p = h.nextSibling;
845
699
  }
846
700
  for (const m of s)
847
- if (!d.has(m) && e.contains(m)) {
848
- if (m instanceof HTMLElement && o)
849
- for (const h in o)
850
- o[h] === m && delete o[h];
851
- e.removeChild(m);
852
- }
701
+ !f.has(m) && e.contains(m) && (z(m, o), e.removeChild(m));
853
702
  }
854
- function D(e, t, n, r, o) {
855
- if (t && typeof t != "string" && t.props?.ref && o && delete o[t.props.ref], t === n) return e;
856
- if (typeof n == "string") {
703
+ function K(e, t, r, n, o) {
704
+ if (t && typeof t != "string" && t.props?.ref && o && z(e, o), t === r) return e;
705
+ if (typeof r == "string") {
857
706
  if (e.nodeType === Node.TEXT_NODE)
858
- return e.textContent !== n && (e.textContent = n), e;
707
+ return e.textContent !== r && (e.textContent = r), e;
859
708
  {
860
- const i = document.createTextNode(n);
709
+ const i = document.createTextNode(r);
861
710
  return e.parentNode?.replaceChild(i, e), i;
862
711
  }
863
712
  }
864
- if (n && typeof n != "string" && n.tag === "#anchor") {
865
- const i = n, l = Array.isArray(i.children) ? i.children : [], c = i._startNode ?? document.createTextNode(""), d = i._endNode ?? document.createTextNode("");
866
- i.key != null && (c.key = `${i.key}:start`, d.key = `${i.key}:end`), i._startNode = c, i._endNode = d;
713
+ if (r && typeof r != "string" && r.tag === "#anchor") {
714
+ const i = r, a = Array.isArray(i.children) ? i.children : [], l = i._startNode ?? document.createTextNode(""), f = i._endNode ?? document.createTextNode("");
715
+ i.key != null && (l.key = `${i.key}:start`, f.key = `${i.key}:end`), i._startNode = l, i._endNode = f;
867
716
  const p = document.createDocumentFragment();
868
- p.appendChild(c);
869
- for (const u of l)
870
- p.appendChild(T(u, r));
871
- return p.appendChild(d), e.parentNode?.replaceChild(p, e), c;
717
+ p.appendChild(l);
718
+ for (const d of a)
719
+ p.appendChild(T(d, n));
720
+ return p.appendChild(f), e.parentNode?.replaceChild(p, e), l;
872
721
  }
873
- if (!n) {
722
+ if (!r) {
723
+ z(e, o);
874
724
  const i = document.createComment("removed");
875
725
  return e.parentNode?.replaceChild(i, e), i;
876
726
  }
877
727
  if (!t || typeof t == "string") {
878
- const i = T(n, r, o);
879
- return typeof n != "string" && n.props?.ref && o && (o[n.props.ref] = i), e.parentNode?.replaceChild(i, e), i;
880
- }
881
- if (n.tag === "#anchor") {
882
- const i = Array.isArray(n.children) ? n.children : [], l = n._startNode ?? document.createTextNode(""), c = n._endNode ?? document.createTextNode("");
883
- n.key != null && (l.key = `${n.key}:start`, c.key = `${n.key}:end`), n._startNode = l, n._endNode = c;
884
- const d = document.createDocumentFragment();
885
- d.appendChild(l);
728
+ z(e, o);
729
+ const i = T(r, n, o);
730
+ return typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), e.parentNode?.replaceChild(i, e), i;
731
+ }
732
+ if (r.tag === "#anchor") {
733
+ const i = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), l = r._endNode ?? document.createTextNode("");
734
+ r.key != null && (a.key = `${r.key}:start`, l.key = `${r.key}:end`), r._startNode = a, r._endNode = l;
735
+ const f = document.createDocumentFragment();
736
+ f.appendChild(a);
886
737
  for (const p of i)
887
- d.appendChild(T(p, r));
888
- return d.appendChild(c), e.parentNode?.replaceChild(d, e), l;
738
+ f.appendChild(T(p, n));
739
+ return f.appendChild(l), e.parentNode?.replaceChild(f, e), a;
889
740
  }
890
- if (typeof t != "string" && typeof n != "string" && t.tag === n.tag && t.key === n.key) {
741
+ if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
891
742
  const i = e;
892
- return ye(i, t.props || {}, n.props || {}, r), be(i, t.children, n.children, r, o), typeof n != "string" && n.props?.ref && o && (o[n.props.ref] = i), i;
743
+ return Le(i, t.props || {}, r.props || {}, n), Be(i, t.children, r.children, n, o), typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), i;
893
744
  }
894
- const s = T(n, r, o);
895
- return typeof n != "string" && n.props?.ref && o && (o[n.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
745
+ z(e, o);
746
+ const s = T(r, n, o);
747
+ return typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
896
748
  }
897
- function xe(e, t, n, r) {
898
- const o = (p) => p.key == null ? { ...p, key: "__root__" } : p;
899
- let s = Array.isArray(t) ? { tag: "div", key: "__root__", children: t } : o(t);
900
- s = Z(s, String(s.key ?? "root"));
901
- const i = e._prevVNode ?? null, l = e._prevDom ?? e.firstChild ?? null;
902
- let c;
903
- i && l ? typeof i != "string" && typeof s != "string" && i.tag === s.tag && i.key === s.key ? c = D(l, i, s, n, r) : (c = T(s, n, r), e.replaceChild(c, l)) : (c = T(s, n, r), e.firstChild ? e.replaceChild(c, e.firstChild) : e.appendChild(c));
904
- const d = [];
905
- for (let p = 0; p < e.childNodes.length; p++) {
906
- const u = e.childNodes[p];
907
- if (u !== c && u.nodeName !== "STYLE") {
908
- if (u instanceof HTMLElement && r)
909
- for (const f in r)
910
- r[f] === u && delete r[f];
911
- d.push(u);
912
- }
749
+ function ze(e, t, r, n) {
750
+ let o;
751
+ Array.isArray(t) ? t.length === 1 ? (o = t[0], o && typeof o == "object" && o.key == null && (o = { ...o, key: "__root__" })) : o = { tag: "div", key: "__root__", children: t } : (o = t, o && typeof o == "object" && o.key == null && (o = { ...o, key: "__root__" })), o = re(o, String(o.key ?? "root"));
752
+ const s = e._prevVNode ?? null, i = e._prevDom ?? e.firstChild ?? null;
753
+ let a;
754
+ s && i ? typeof s != "string" && typeof o != "string" && s.tag === o.tag && s.key === o.key ? a = K(i, s, o, r, n) : (a = T(o, r, n), e.replaceChild(a, i)) : (a = T(o, r, n), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
755
+ const l = [];
756
+ for (let f = 0; f < e.childNodes.length; f++) {
757
+ const p = e.childNodes[f];
758
+ p !== a && p.nodeName !== "STYLE" && (z(p, n), l.push(p));
913
759
  }
914
- d.forEach((p) => e.removeChild(p)), e._prevVNode = s, e._prevDom = c;
760
+ l.forEach((f) => e.removeChild(f)), e._prevVNode = o, e._prevDom = a;
761
+ }
762
+ function he(e, ...t) {
763
+ let r = "";
764
+ for (let n = 0; n < e.length; n++)
765
+ r += e[n], n < t.length && (r += t[n]);
766
+ return r;
915
767
  }
916
- function oe(e) {
768
+ function ge(e) {
917
769
  return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
918
770
  }
919
- let H = null;
920
- function G() {
921
- return H || (H = new CSSStyleSheet(), H.replaceSync(oe(we))), H;
771
+ let q = null;
772
+ function ae() {
773
+ return q || (q = new CSSStyleSheet(), q.replaceSync(ge(Me))), q;
922
774
  }
923
- function ve(e) {
775
+ function Re(e) {
924
776
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
925
777
  }
926
- const we = `
778
+ const Me = he`
927
779
  :host, *, ::before, ::after {
928
780
  all: isolate;
929
781
  box-sizing: border-box;
@@ -981,7 +833,7 @@ const we = `
981
833
  sup { top: -.5em }
982
834
  [disabled], [aria-disabled=true] { cursor: not-allowed }
983
835
  [hidden] { display: none }
984
- `, ke = {
836
+ `, Ne = {
985
837
  gray: {
986
838
  50: "var(--color-gray-50, #f9fafb)",
987
839
  100: "var(--color-gray-100, #f3f4f6)",
@@ -1116,7 +968,7 @@ const we = `
1116
968
  },
1117
969
  white: { DEFAULT: "var(--color-white, #ffffff)" },
1118
970
  black: { DEFAULT: "var(--color-black, #000000)" }
1119
- }, F = {
971
+ }, Q = {
1120
972
  /* Display */
1121
973
  block: "display:block;",
1122
974
  inline: "display:inline;",
@@ -1290,7 +1142,7 @@ const we = `
1290
1142
  "transition-colors": "transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;",
1291
1143
  "transition-opacity": "transition-property:opacity;",
1292
1144
  "transition-transform": "transition-property:transform;"
1293
- }, _e = "var(--spacing, 0.25rem)", ee = {
1145
+ }, Pe = "var(--spacing, 0.25rem)", le = {
1294
1146
  m: ["margin"],
1295
1147
  mx: ["margin-inline"],
1296
1148
  my: ["margin-block"],
@@ -1321,7 +1173,7 @@ const we = `
1321
1173
  gap: ["gap"],
1322
1174
  "gap-x": ["column-gap"],
1323
1175
  "gap-y": ["row-gap"]
1324
- }, $e = {
1176
+ }, Oe = {
1325
1177
  // State variants
1326
1178
  before: (e, t) => `${e}::before{${t}}`,
1327
1179
  after: (e, t) => `${e}::after{${t}}`,
@@ -1347,7 +1199,7 @@ const we = `
1347
1199
  "peer-focus": (e, t) => `.peer:focus ~ ${e}{${t}}`,
1348
1200
  "peer-checked": (e, t) => `.peer:checked ~ ${e}{${t}}`,
1349
1201
  "peer-disabled": (e, t) => `.peer:disabled ~ ${e}{${t}}`
1350
- }, te = {
1202
+ }, ce = {
1351
1203
  // Responsive
1352
1204
  sm: "(min-width:640px)",
1353
1205
  md: "(min-width:768px)",
@@ -1356,23 +1208,23 @@ const we = `
1356
1208
  "2xl": "(min-width:1536px)",
1357
1209
  // Dark mode (now plain string)
1358
1210
  dark: "(prefers-color-scheme: dark)"
1359
- }, V = ["sm", "md", "lg", "xl", "2xl"];
1360
- function U(e) {
1361
- const t = e.startsWith("-"), r = (t ? e.slice(1) : e).split("-");
1362
- if (r.length < 2) return null;
1363
- const o = r.slice(0, -1).join("-"), s = r[r.length - 1], i = parseFloat(s);
1364
- if (Number.isNaN(i) || !ee[o]) return null;
1365
- const l = t ? "-" : "";
1366
- return ee[o].map((c) => `${c}:calc(${l}${_e} * ${i});`).join("");
1211
+ }, Z = ["sm", "md", "lg", "xl", "2xl"];
1212
+ function X(e) {
1213
+ const t = e.startsWith("-"), n = (t ? e.slice(1) : e).split("-");
1214
+ if (n.length < 2) return null;
1215
+ const o = n.slice(0, -1).join("-"), s = n[n.length - 1], i = parseFloat(s);
1216
+ if (Number.isNaN(i) || !le[o]) return null;
1217
+ const a = t ? "-" : "";
1218
+ return le[o].map((l) => `${l}:calc(${a}${Pe} * ${i});`).join("");
1367
1219
  }
1368
- function re(e) {
1369
- const t = e.replace("#", ""), n = parseInt(t, 16), r = n >> 16 & 255, o = n >> 8 & 255, s = n & 255;
1370
- return `${r} ${o} ${s}`;
1220
+ function fe(e) {
1221
+ const t = e.replace("#", ""), r = parseInt(t, 16), n = r >> 16 & 255, o = r >> 8 & 255, s = r & 255;
1222
+ return `${n} ${o} ${s}`;
1371
1223
  }
1372
- function Se(e) {
1224
+ function We(e) {
1373
1225
  const t = /^(bg|text|border|shadow|outline|caret|accent)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1374
1226
  if (!t) return null;
1375
- const [, n, r, o = "DEFAULT"] = t, s = ke[r]?.[o];
1227
+ const [, r, n, o = "DEFAULT"] = t, s = Ne[n]?.[o];
1376
1228
  return s ? `${{
1377
1229
  bg: "background-color",
1378
1230
  text: "color",
@@ -1381,40 +1233,40 @@ function Se(e) {
1381
1233
  outline: "outline-color",
1382
1234
  caret: "caret-color",
1383
1235
  accent: "accent-color"
1384
- }[n]}:${s};` : null;
1236
+ }[r]}:${s};` : null;
1385
1237
  }
1386
- function Ce(e) {
1387
- const [t, n] = e.split("/");
1388
- if (!n) return { base: t };
1389
- const r = parseInt(n, 10);
1390
- return isNaN(r) || r < 0 || r > 100 ? { base: t } : { base: t, opacity: r / 100 };
1238
+ function De(e) {
1239
+ const [t, r] = e.split("/");
1240
+ if (!r) return { base: t };
1241
+ const n = parseInt(r, 10);
1242
+ return isNaN(n) || n < 0 || n > 100 ? { base: t } : { base: t, opacity: n / 100 };
1391
1243
  }
1392
- function q(e) {
1393
- const { base: t, opacity: n } = Ce(e), r = Se(t);
1394
- if (r) {
1395
- if (n !== void 0) {
1396
- const s = /#([0-9a-f]{6})/i.exec(r);
1244
+ function Y(e) {
1245
+ const { base: t, opacity: r } = De(e), n = We(t);
1246
+ if (n) {
1247
+ if (r !== void 0) {
1248
+ const s = /#([0-9a-f]{6})/i.exec(n);
1397
1249
  if (s) {
1398
- const i = re(s[0]);
1399
- return r.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${n})`);
1250
+ const i = fe(s[0]);
1251
+ return n.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${r})`);
1400
1252
  }
1401
1253
  }
1402
- return r;
1254
+ return n;
1403
1255
  }
1404
- const o = W(t);
1405
- if (o && n !== void 0) {
1256
+ const o = V(t);
1257
+ if (o && r !== void 0) {
1406
1258
  const s = /#([0-9a-f]{6})/i.exec(o);
1407
1259
  if (s) {
1408
- const i = re(s[0]);
1409
- return o.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${n})`);
1260
+ const i = fe(s[0]);
1261
+ return o.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${r})`);
1410
1262
  }
1411
1263
  }
1412
1264
  return o;
1413
1265
  }
1414
- function W(e) {
1415
- const t = e.indexOf("-["), n = e.endsWith("]");
1416
- if (t > 0 && n) {
1417
- const r = e.slice(0, t);
1266
+ function V(e) {
1267
+ const t = e.indexOf("-["), r = e.endsWith("]");
1268
+ if (t > 0 && r) {
1269
+ const n = e.slice(0, t);
1418
1270
  let o = e.slice(t + 2, -1);
1419
1271
  o = o.replace(/_/g, " ");
1420
1272
  const i = {
@@ -1456,108 +1308,145 @@ function W(e) {
1456
1308
  weight: "font-weight",
1457
1309
  leading: "line-height",
1458
1310
  z: "z-index"
1459
- }[r] ?? r.replace(/_/g, "-");
1311
+ }[n] ?? n.replace(/_/g, "-");
1460
1312
  if (i && o) return `${i}:${o};`;
1461
1313
  }
1462
1314
  return null;
1463
1315
  }
1464
- function Ae(e) {
1316
+ function He(e) {
1465
1317
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1466
1318
  }
1467
- function Ee(e) {
1468
- const t = /class\s*=\s*["']([^"']+)["']/g, n = [];
1469
- let r;
1470
- for (; r = t.exec(e); ) {
1319
+ function Ie(e) {
1320
+ const t = /class\s*=\s*["']([^"']+)["']/g, r = [];
1321
+ let n;
1322
+ for (; n = t.exec(e); ) {
1471
1323
  let o = "", s = !1;
1472
- for (const i of r[1])
1473
- i === "[" && (s = !0), i === "]" && (s = !1), i === " " && !s ? (o && n.push(o), o = "") : o += i;
1474
- o && n.push(o);
1324
+ for (const i of n[1])
1325
+ i === "[" && (s = !0), i === "]" && (s = !1), i === " " && !s ? (o && r.push(o), o = "") : o += i;
1326
+ o && r.push(o);
1475
1327
  }
1476
- return n.filter(Boolean);
1328
+ return r.filter(Boolean);
1477
1329
  }
1478
- const ne = /* @__PURE__ */ new Map(), Te = 16;
1479
- function je(e) {
1480
- const t = Date.now(), n = ne.get(e);
1481
- if (n && t - n.timestamp < Te) return n.css;
1482
- const r = Ee(e), o = new Set(r), s = [], i = [], l = [], c = [], d = {};
1483
- function p(h, S = !1) {
1484
- const y = (S ? "dark|" : "") + h;
1485
- if (y in d) return d[y];
1486
- const a = f(h, S);
1487
- return d[y] = a, a;
1488
- }
1489
- function u(h) {
1490
- const S = h.some((a) => V.includes(a)), y = h.includes("dark");
1491
- return h.length === 0 ? 1 : !S && !y ? 2 : S && !y ? 3 : 4;
1492
- }
1493
- function f(h, S = !1) {
1494
- const y = h.split(":"), a = y.find(
1495
- (_) => F[_] || U(_) || q(_) || W(_)
1330
+ const ue = /* @__PURE__ */ new Map(), qe = 16;
1331
+ function Fe(e) {
1332
+ const t = Date.now(), r = ue.get(e);
1333
+ if (r && t - r.timestamp < qe) return r.css;
1334
+ const n = Ie(e), o = new Set(n), s = [], i = [], a = [], l = [], f = {};
1335
+ function p(h, C = !1) {
1336
+ const y = (C ? "dark|" : "") + h;
1337
+ if (y in f) return f[y];
1338
+ const c = u(h, C);
1339
+ return f[y] = c, c;
1340
+ }
1341
+ function d(h) {
1342
+ const C = h.some((c) => Z.includes(c)), y = h.includes("dark");
1343
+ return h.length === 0 ? 1 : !C && !y ? 2 : C && !y ? 3 : 4;
1344
+ }
1345
+ function u(h, C = !1) {
1346
+ const y = h.split(":"), c = y.find(
1347
+ ($) => Q[$] || X($) || Y($) || V($)
1496
1348
  );
1497
- if (!a) return null;
1498
- const b = F[a] ?? U(a) ?? q(a) ?? W(a);
1349
+ if (!c) return null;
1350
+ const b = Q[c] ?? X(c) ?? Y(c) ?? V(c);
1499
1351
  if (!b) return null;
1500
- let g = `.${Ae(h)}`, x = b;
1501
- const w = y.indexOf(a);
1352
+ let g = `.${He(h)}`, v = b;
1353
+ const w = y.indexOf(c);
1502
1354
  let k = w >= 0 ? y.slice(0, w) : [];
1503
- S && (k = k.filter((_) => _ !== "dark"));
1504
- const $ = k.filter((_) => V.includes(_)), C = $.length ? $[$.length - 1] : null;
1505
- for (const _ of k) {
1506
- if (V.includes(_)) continue;
1507
- const A = $e[_];
1508
- typeof A == "function" && (g = A(g, x).replace(/\{.*$/, ""));
1355
+ C && (k = k.filter(($) => $ !== "dark"));
1356
+ const S = k.filter(($) => Z.includes($)), _ = S.length ? S[S.length - 1] : null;
1357
+ for (const $ of k) {
1358
+ if (Z.includes($)) continue;
1359
+ const A = Oe[$];
1360
+ typeof A == "function" && (g = A(g, v).replace(/\{.*$/, ""));
1509
1361
  }
1510
- let v = `${g}{${x}}`;
1511
- return S && C ? v = `@media (prefers-color-scheme: dark) and ${te[C]}{${v}}` : S ? v = `@media (prefers-color-scheme: dark){${v}}` : C && (v = `@media ${te[C]}{${v}}`), v;
1362
+ let x = `${g}{${v}}`;
1363
+ return C && _ ? x = `@media (prefers-color-scheme: dark) and ${ce[_]}{${x}}` : C ? x = `@media (prefers-color-scheme: dark){${x}}` : _ && (x = `@media ${ce[_]}{${x}}`), x;
1512
1364
  }
1513
1365
  for (const h of o) {
1514
- const S = h.split(":"), y = S.find(
1515
- (x) => F[x] || U(x) || q(x) || W(x)
1366
+ const C = h.split(":"), y = C.find(
1367
+ (v) => Q[v] || X(v) || Y(v) || V(v)
1516
1368
  );
1517
1369
  if (!y) continue;
1518
- const a = S.indexOf(y), b = a >= 0 ? S.slice(0, a) : [], g = u(b);
1370
+ const c = C.indexOf(y), b = c >= 0 ? C.slice(0, c) : [], g = d(b);
1519
1371
  if (g === 4) {
1520
- const x = p(h, !0);
1521
- x && c.push(x);
1372
+ const v = p(h, !0);
1373
+ v && l.push(v);
1522
1374
  } else {
1523
- const x = p(h);
1524
- x && (g === 1 ? s.push(x) : g === 2 ? i.push(x) : g === 3 && l.push(x));
1375
+ const v = p(h);
1376
+ v && (g === 1 ? s.push(v) : g === 2 ? i.push(v) : g === 3 && a.push(v));
1525
1377
  }
1526
1378
  }
1527
- const m = [...s, ...i, ...l, ...c].join("");
1528
- return ne.set(e, { css: m, timestamp: t }), m;
1379
+ const m = [...s, ...i, ...a, ...l].join("");
1380
+ return ue.set(e, { css: m, timestamp: t }), m;
1529
1381
  }
1530
- const Le = /* @__PURE__ */ new Map();
1531
- function Q(e) {
1532
- return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1382
+ function Ke(e, t, r, n, o, s, i, a) {
1383
+ if (!e) return;
1384
+ if (t.loadingTemplate && r.isLoading) {
1385
+ M(e, t.loadingTemplate(r), r, n, o);
1386
+ return;
1387
+ }
1388
+ if (t.errorTemplate && r.hasError) {
1389
+ r.error instanceof Error && M(e, t.errorTemplate(r.error, r), r, n, o);
1390
+ return;
1391
+ }
1392
+ const l = t.render(r);
1393
+ if (l instanceof Promise) {
1394
+ s(!0), l.then((f) => {
1395
+ s(!1), i(null), M(e, f, r, n, o), a(e.innerHTML);
1396
+ }).catch((f) => {
1397
+ s(!1), i(f), t.errorTemplate && M(e, t.errorTemplate(f, r), r, n, o);
1398
+ }), t.loadingTemplate && M(e, t.loadingTemplate(r), r, n, o);
1399
+ return;
1400
+ }
1401
+ M(e, l, r, n, o), a(e.innerHTML);
1533
1402
  }
1534
- function J(e) {
1535
- return typeof e == "string" ? e.replace(
1536
- /[&<>"']/g,
1537
- (t) => ({
1538
- "&": "&amp;",
1539
- "<": "&lt;",
1540
- ">": "&gt;",
1541
- '"': "&quot;",
1542
- "'": "&#39;"
1543
- })[t]
1544
- ) : e;
1403
+ function M(e, t, r, n, o) {
1404
+ e && (ze(
1405
+ e,
1406
+ Array.isArray(t) ? t : [t],
1407
+ r,
1408
+ n
1409
+ ), o(e.innerHTML));
1545
1410
  }
1546
- function He(e, ...t) {
1547
- let n = "";
1548
- for (let r = 0; r < e.length; r++)
1549
- n += e[r], r < t.length && (n += t[r]);
1550
- return n;
1411
+ function Ve(e, t, r, n, o, s, i) {
1412
+ if (s !== null && clearTimeout(s), Date.now() - t < 16) {
1413
+ if (o(r + 1), r > 10) {
1414
+ console.warn("Potential infinite render loop detected. Skipping render."), i(null);
1415
+ return;
1416
+ }
1417
+ } else
1418
+ o(0);
1419
+ const l = setTimeout(() => {
1420
+ n(Date.now()), e(), i(null);
1421
+ }, 0);
1422
+ i(l);
1551
1423
  }
1552
- function Ie(e, t, n) {
1553
- let r = Q(e);
1554
- r.includes("-") || (r = `cer-${r}`);
1424
+ function Ue(e, t, r, n, o, s) {
1425
+ if (!e) return;
1426
+ const i = Fe(n);
1427
+ if (!t.style && (!i || i.trim() === "")) {
1428
+ s(null), e.adoptedStyleSheets = [ae()];
1429
+ return;
1430
+ }
1431
+ let a = "";
1432
+ t.style && (typeof t.style == "string" ? a = t.style : typeof t.style == "function" && (a = t.style(r)));
1433
+ let l = Re(`${a}
1434
+ ${i}
1435
+ `);
1436
+ l = ge(l);
1437
+ let f = o;
1438
+ f || (f = new CSSStyleSheet()), (f.cssRules.length === 0 || f.toString() !== l) && f.replaceSync(l), e.adoptedStyleSheets = [ae(), f], s(f);
1439
+ }
1440
+ const Je = /* @__PURE__ */ new Map();
1441
+ function de(e, t, r) {
1442
+ let n = ne(e);
1443
+ n.includes("-") || (n = `cer-${n}`);
1555
1444
  let o;
1556
- typeof t == "function" ? o = { ...n, render: t } : o = t, typeof o.onError != "function" && (o.onError = (s, i) => {
1557
- console.error(`[${r}] Error:`, s, i);
1558
- }), Le.set(r, o), typeof window < "u" && !customElements.get(r) && customElements.define(r, ze(o));
1445
+ typeof t == "function" ? o = { ...r, render: t } : o = t, typeof o.onError != "function" && (o.onError = (s, i) => {
1446
+ console.error(`[${n}] Error:`, s, i);
1447
+ }), Je.set(n, o), typeof window < "u" && !customElements.get(n) && customElements.define(n, Qe(o));
1559
1448
  }
1560
- function ze(e) {
1449
+ function Qe(e) {
1561
1450
  if (!e.render)
1562
1451
  throw new Error(
1563
1452
  "Component must have a render function"
@@ -1577,6 +1466,24 @@ function ze(e) {
1577
1466
  _initializing = !0;
1578
1467
  _styleSheet = null;
1579
1468
  _lastHtmlStringForJitCSS = "";
1469
+ /**
1470
+ * Returns the last rendered HTML string for JIT CSS.
1471
+ */
1472
+ get lastHtmlStringForJitCSS() {
1473
+ return this._lastHtmlStringForJitCSS;
1474
+ }
1475
+ /**
1476
+ * Returns true if the component is currently loading.
1477
+ */
1478
+ get isLoading() {
1479
+ return this._templateLoading;
1480
+ }
1481
+ /**
1482
+ * Returns the last error thrown during rendering, or null if none.
1483
+ */
1484
+ get lastError() {
1485
+ return this._templateError;
1486
+ }
1580
1487
  _cfg;
1581
1488
  _lastRenderTime = 0;
1582
1489
  _renderCount = 0;
@@ -1590,30 +1497,35 @@ function ze(e) {
1590
1497
  writable: !1,
1591
1498
  enumerable: !1,
1592
1499
  configurable: !1
1500
+ }), Object.defineProperty(t, "requestRender", {
1501
+ value: () => this.requestRender(),
1502
+ writable: !1,
1503
+ enumerable: !1,
1504
+ configurable: !1
1593
1505
  }), this.context = t, this._applyProps(e), Object.defineProperty(this.context, "emit", {
1594
- value: (n, r, o) => {
1506
+ value: (r, n, o) => {
1595
1507
  this.dispatchEvent(
1596
- new CustomEvent(n, {
1597
- detail: r,
1508
+ new CustomEvent(r, {
1509
+ detail: n,
1598
1510
  bubbles: !0,
1599
1511
  composed: !0,
1600
1512
  ...o || {}
1601
1513
  })
1602
1514
  );
1603
- const s = `on${n.charAt(0).toUpperCase()}${n.slice(1)}`, i = typeof this[s] == "function" ? this[s] : void 0, l = typeof this.context[s] == "function" ? this.context[s] : void 0, c = typeof e[s] == "function" ? e[s] : void 0;
1604
- i && i(r, this.context), l && l !== i && l(r, this.context), c && c !== i && c !== l && c(r, this.context);
1515
+ const s = `on${r.charAt(0).toUpperCase()}${r.slice(1)}`, i = typeof this[s] == "function" ? this[s] : void 0, a = typeof this.context[s] == "function" ? this.context[s] : void 0, l = typeof e[s] == "function" ? e[s] : void 0;
1516
+ i && i(n, this.context), a && a !== i && a(n, this.context), l && l !== i && l !== a && l(n, this.context);
1605
1517
  },
1606
1518
  writable: !1,
1607
1519
  enumerable: !1,
1608
1520
  configurable: !1
1609
- }), Object.keys(e).forEach((n) => {
1610
- const r = e[n];
1611
- if (typeof r == "function" && !n.startsWith("on"))
1612
- this.context[n] = (...o) => r(...o, this.context);
1613
- else if (n.startsWith("on") && n.length > 2 && n[2] === n[2].toUpperCase()) {
1614
- const o = n.slice(2, 3).toLowerCase() + n.slice(3);
1521
+ }), Object.keys(e).forEach((r) => {
1522
+ const n = e[r];
1523
+ if (typeof n == "function" && !r.startsWith("on"))
1524
+ this.context[r] = (...o) => n(...o, this.context);
1525
+ else if (r.startsWith("on") && r.length > 2 && r[2] === r[2].toUpperCase()) {
1526
+ const o = r.slice(2, 3).toLowerCase() + r.slice(3);
1615
1527
  this.addEventListener(o, (s) => {
1616
- const i = typeof this[n] == "function" ? this[n] : this.context[n];
1528
+ const i = typeof this[r] == "function" ? this[r] : this.context[r];
1617
1529
  typeof i == "function" && i(s.detail, this.context);
1618
1530
  });
1619
1531
  }
@@ -1621,34 +1533,61 @@ function ze(e) {
1621
1533
  }
1622
1534
  connectedCallback() {
1623
1535
  this._runLogicWithinErrorBoundary(e, () => {
1624
- e.onConnected && !this._mounted && (e.onConnected(this.context), this._mounted = !0);
1536
+ $e(
1537
+ e,
1538
+ this.context,
1539
+ this._mounted,
1540
+ (t) => {
1541
+ this._mounted = t;
1542
+ }
1543
+ );
1625
1544
  });
1626
1545
  }
1627
1546
  disconnectedCallback() {
1628
1547
  this._runLogicWithinErrorBoundary(e, () => {
1629
- e.onDisconnected && e.onDisconnected(this.context), this._listeners.forEach((t) => t()), this._listeners = [], this._watchers.clear(), this._templateLoading = !1, this._templateError = null, this._mounted = !1;
1548
+ Ce(
1549
+ e,
1550
+ this.context,
1551
+ this._listeners,
1552
+ () => {
1553
+ this._listeners = [];
1554
+ },
1555
+ () => {
1556
+ this._watchers.clear();
1557
+ },
1558
+ (t) => {
1559
+ this._templateLoading = t;
1560
+ },
1561
+ (t) => {
1562
+ this._templateError = t;
1563
+ },
1564
+ (t) => {
1565
+ this._mounted = t;
1566
+ }
1567
+ );
1630
1568
  });
1631
1569
  }
1632
- attributeChangedCallback(t, n, r) {
1570
+ attributeChangedCallback(t, r, n) {
1633
1571
  this._runLogicWithinErrorBoundary(e, () => {
1634
- this._applyProps(e), e.onAttributeChanged && e.onAttributeChanged(
1572
+ this._applyProps(e), Se(
1573
+ e,
1635
1574
  t,
1636
- n,
1637
1575
  r,
1576
+ n,
1638
1577
  this.context
1639
1578
  );
1640
1579
  });
1641
1580
  }
1642
1581
  static get observedAttributes() {
1643
- return e.props ? Object.keys(e.props).map(Q) : [];
1582
+ return e.props ? Object.keys(e.props).map(ne) : [];
1644
1583
  }
1645
1584
  _applyComputed(t) {
1646
1585
  this._runLogicWithinErrorBoundary(e, () => {
1647
- t.computed && Object.entries(t.computed).forEach(([n, r]) => {
1648
- Object.defineProperty(this.context, n, {
1586
+ t.computed && Object.entries(t.computed).forEach(([r, n]) => {
1587
+ Object.defineProperty(this.context, r, {
1649
1588
  get: () => {
1650
- const o = r(this.context);
1651
- return J(o);
1589
+ const o = n(this.context);
1590
+ return ee(o);
1652
1591
  },
1653
1592
  enumerable: !0
1654
1593
  });
@@ -1658,90 +1597,69 @@ function ze(e) {
1658
1597
  // --- Render ---
1659
1598
  _render(t) {
1660
1599
  this._runLogicWithinErrorBoundary(t, () => {
1661
- if (!this.shadowRoot) return;
1662
- if (this._templateLoading && t.loadingTemplate) {
1663
- this._renderOutput(t.loadingTemplate(this.context));
1664
- return;
1665
- }
1666
- if (this._templateError && t.errorTemplate) {
1667
- this._renderOutput(t.errorTemplate(this._templateError, this.context));
1668
- return;
1669
- }
1670
- const n = t.render(this.context);
1671
- if (n instanceof Promise) {
1672
- this._templateLoading = !0, n.then((r) => (this._templateLoading = !1, this._templateError = null, this._renderOutput(r), r)).catch((r) => {
1673
- if (this._templateLoading = !1, this._templateError = r, t.errorTemplate) {
1674
- const o = t.errorTemplate(r, this.context);
1675
- return this._renderOutput(o), o;
1676
- }
1677
- throw r;
1678
- }), t.loadingTemplate && this._renderOutput(t.loadingTemplate(this.context));
1679
- return;
1680
- }
1681
- this._renderOutput(n), this._applyStyle(t);
1600
+ Ke(
1601
+ this.shadowRoot,
1602
+ t,
1603
+ this.context,
1604
+ this._refs,
1605
+ (r) => {
1606
+ this._lastHtmlStringForJitCSS = r, typeof this.onHtmlStringUpdate == "function" && this.onHtmlStringUpdate(r);
1607
+ },
1608
+ (r) => {
1609
+ this._templateLoading = r, typeof this.onLoadingStateChange == "function" && this.onLoadingStateChange(r);
1610
+ },
1611
+ (r) => {
1612
+ this._templateError = r, typeof this.onErrorStateChange == "function" && this.onErrorStateChange(r);
1613
+ },
1614
+ (r) => this._applyStyle(t, r)
1615
+ );
1682
1616
  });
1683
1617
  }
1684
- // --- Helper to render output ---
1685
- _renderOutput(t) {
1686
- if (!this.shadowRoot) return;
1687
- const n = new Proxy(this.context, {
1688
- get: (r, o) => o === "_requestRender" ? () => this._requestRender() : o === "context" ? r : typeof o == "string" && o.includes(".") ? o.split(".").reduce((s, i) => s?.[i], r) : r[o],
1689
- set: (r, o, s) => {
1690
- if (typeof o == "string" && o.includes(".")) {
1691
- const i = o.split("."), l = i.pop();
1692
- if (!l) return !1;
1693
- const c = i.reduce((d, p) => (p in d || (d[p] = {}), d[p]), r);
1694
- return c[l] = s, !0;
1695
- }
1696
- return r[o] = s, !0;
1697
- }
1698
- });
1699
- xe(
1700
- this.shadowRoot,
1701
- Array.isArray(t) ? t : [t],
1702
- n,
1703
- this._refs
1704
- ), this._lastHtmlStringForJitCSS = this.shadowRoot.innerHTML;
1618
+ requestRender() {
1619
+ this._requestRender();
1705
1620
  }
1706
1621
  _requestRender() {
1707
- if (this._renderTimeoutId !== null && clearTimeout(this._renderTimeoutId), Date.now() - this._lastRenderTime < 16) {
1708
- if (this._renderCount++, this._renderCount > 10) {
1709
- console.warn(
1710
- `[${this.tagName}] Potential infinite render loop detected. Skipping render.`
1711
- ), this._renderTimeoutId = null;
1712
- return;
1713
- }
1714
- } else
1715
- this._renderCount = 0;
1716
- this._renderTimeoutId = setTimeout(() => {
1717
- this._lastRenderTime = Date.now(), this._render(this._cfg), this._renderTimeoutId = null;
1718
- }, 0);
1622
+ this._runLogicWithinErrorBoundary(this._cfg, () => {
1623
+ Ve(
1624
+ () => this._render(this._cfg),
1625
+ this._lastRenderTime,
1626
+ this._renderCount,
1627
+ (t) => {
1628
+ this._lastRenderTime = t;
1629
+ },
1630
+ (t) => {
1631
+ this._renderCount = t;
1632
+ },
1633
+ this._renderTimeoutId,
1634
+ (t) => {
1635
+ this._renderTimeoutId = t;
1636
+ }
1637
+ );
1638
+ });
1719
1639
  }
1720
1640
  // --- Style ---
1721
- _applyStyle(t) {
1641
+ _applyStyle(t, r) {
1722
1642
  this._runLogicWithinErrorBoundary(t, () => {
1723
- if (!this.shadowRoot) return;
1724
- const n = je(this._lastHtmlStringForJitCSS);
1725
- if (!t.style && (!n || n.trim() === "")) {
1726
- this._styleSheet = null, this.shadowRoot.adoptedStyleSheets = [G()];
1727
- return;
1728
- }
1729
- let r = "";
1730
- t.style && (typeof t.style == "string" ? r = t.style : typeof t.style == "function" && (r = t.style(this.context)));
1731
- let o = ve(`${r}
1732
- ${n}
1733
- `);
1734
- o = oe(o), this._styleSheet || (this._styleSheet = new CSSStyleSheet()), (this._styleSheet.cssRules.length === 0 || this._styleSheet.toString() !== o) && this._styleSheet.replaceSync(o), this.shadowRoot.adoptedStyleSheets = [G(), this._styleSheet];
1643
+ Ue(
1644
+ this.shadowRoot,
1645
+ t,
1646
+ this.context,
1647
+ r,
1648
+ this._styleSheet,
1649
+ (n) => {
1650
+ this._styleSheet = n;
1651
+ }
1652
+ );
1735
1653
  });
1736
1654
  }
1737
1655
  // --- Error Boundary function ---
1738
- _runLogicWithinErrorBoundary(t, n) {
1656
+ _runLogicWithinErrorBoundary(t, r) {
1739
1657
  this._hasError && (this._hasError = !1);
1740
1658
  try {
1741
- n();
1742
- } catch (r) {
1743
- this._hasError = !0, t.onError && t.onError(r, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1744
- r,
1659
+ r();
1660
+ } catch (n) {
1661
+ this._hasError = !0, t.onError && t.onError(n, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1662
+ n,
1745
1663
  this.context
1746
1664
  ));
1747
1665
  }
@@ -1749,11 +1667,11 @@ ${n}
1749
1667
  // --- State, props, computed ---
1750
1668
  _initContext(t) {
1751
1669
  try {
1752
- let n = function(o, s = "") {
1670
+ let r = function(o, s = "") {
1753
1671
  return Array.isArray(o) ? new Proxy(o, {
1754
- get(i, l, c) {
1755
- const d = Reflect.get(i, l, c);
1756
- return typeof d == "function" && typeof l == "string" && [
1672
+ get(i, a, l) {
1673
+ const f = Reflect.get(i, a, l);
1674
+ return typeof f == "function" && typeof a == "string" && [
1757
1675
  "push",
1758
1676
  "pop",
1759
1677
  "shift",
@@ -1761,132 +1679,477 @@ ${n}
1761
1679
  "splice",
1762
1680
  "sort",
1763
1681
  "reverse"
1764
- ].includes(l) ? function(...u) {
1765
- const f = d.apply(i, u);
1766
- if (!r._initializing) {
1682
+ ].includes(a) ? function(...d) {
1683
+ const u = f.apply(i, d);
1684
+ if (!n._initializing) {
1767
1685
  const m = s || "root";
1768
- r._triggerWatchers(m, i), r._render(t);
1686
+ n._triggerWatchers(m, i), n._render(t);
1769
1687
  }
1770
- return f;
1771
- } : d;
1688
+ return u;
1689
+ } : f;
1772
1690
  },
1773
- set(i, l, c) {
1774
- if (i[l] = c, !r._initializing) {
1775
- const d = s ? `${s}.${String(l)}` : String(l);
1776
- r._triggerWatchers(d, c), r._render(t);
1691
+ set(i, a, l) {
1692
+ if (i[a] = l, !n._initializing) {
1693
+ const f = s ? `${s}.${String(a)}` : String(a);
1694
+ n._triggerWatchers(f, l), n._render(t);
1777
1695
  }
1778
1696
  return !0;
1779
1697
  },
1780
- deleteProperty(i, l) {
1781
- if (delete i[l], !r._initializing) {
1782
- const c = s ? `${s}.${String(l)}` : String(l);
1783
- r._triggerWatchers(c, void 0), r._render(t);
1698
+ deleteProperty(i, a) {
1699
+ if (delete i[a], !n._initializing) {
1700
+ const l = s ? `${s}.${String(a)}` : String(a);
1701
+ n._triggerWatchers(l, void 0), n._render(t);
1784
1702
  }
1785
1703
  return !0;
1786
1704
  }
1787
1705
  }) : o && typeof o == "object" ? (Object.keys(o).forEach((i) => {
1788
- const l = s ? `${s}.${i}` : i;
1789
- o[i] = n(o[i], l);
1706
+ const a = s ? `${s}.${i}` : i;
1707
+ o[i] = r(o[i], a);
1790
1708
  }), new Proxy(o, {
1791
- set(i, l, c) {
1792
- const d = s ? `${s}.${String(l)}` : String(l);
1793
- return i[l] = n(c, d), r._initializing || (r._triggerWatchers(
1794
- d,
1795
- i[l]
1796
- ), r._render(t)), !0;
1709
+ set(i, a, l) {
1710
+ const f = s ? `${s}.${String(a)}` : String(a);
1711
+ return i[a] = r(l, f), n._initializing || (n._triggerWatchers(
1712
+ f,
1713
+ i[a]
1714
+ ), n._render(t)), !0;
1797
1715
  },
1798
- get(i, l, c) {
1799
- return Reflect.get(i, l, c);
1716
+ get(i, a, l) {
1717
+ return Reflect.get(i, a, l);
1800
1718
  }
1801
1719
  })) : o;
1802
1720
  };
1803
- const r = this;
1804
- return n({ ...t.state });
1721
+ const n = this;
1722
+ return r({ ...t.state });
1805
1723
  } catch {
1806
1724
  return {};
1807
1725
  }
1808
1726
  }
1809
1727
  _initWatchers(t) {
1810
- if (t.watch)
1811
- for (const [n, r] of Object.entries(t.watch)) {
1812
- let o, s = {};
1813
- if (Array.isArray(r) ? (o = r[0], s = r[1] || {}) : o = r, this._watchers.set(n, {
1814
- callback: o,
1815
- options: s,
1816
- oldValue: this._getNestedValue(n)
1817
- }), s.immediate)
1818
- try {
1819
- const i = this._getNestedValue(n);
1820
- o(i, void 0, this.context);
1821
- } catch (i) {
1822
- console.error(`Error in immediate watcher for "${n}":`, i);
1823
- }
1824
- }
1728
+ this._runLogicWithinErrorBoundary(t, () => {
1729
+ xe(
1730
+ this.context,
1731
+ this._watchers,
1732
+ t.watch || {}
1733
+ );
1734
+ });
1825
1735
  }
1826
- _getNestedValue(t) {
1827
- return t.split(".").reduce(
1828
- (n, r) => n?.[r],
1829
- this.context
1830
- );
1736
+ _triggerWatchers(t, r) {
1737
+ we(this.context, this._watchers, t, r);
1831
1738
  }
1832
- _triggerWatchers(t, n) {
1833
- const r = (s, i) => {
1834
- if (s === i) return !0;
1835
- if (typeof s != typeof i || typeof s != "object" || s === null || i === null) return !1;
1836
- if (Array.isArray(s) && Array.isArray(i))
1837
- return s.length !== i.length ? !1 : s.every((d, p) => r(d, i[p]));
1838
- const l = Object.keys(s), c = Object.keys(i);
1839
- return l.length !== c.length ? !1 : l.every((d) => r(s[d], i[d]));
1840
- }, o = this._watchers.get(t);
1841
- if (o && !r(n, o.oldValue))
1739
+ _applyProps(t) {
1740
+ this._runLogicWithinErrorBoundary(t, () => {
1842
1741
  try {
1843
- o.callback(n, o.oldValue, this.context), o.oldValue = n;
1844
- } catch (s) {
1845
- console.error(`Error in watcher for "${t}":`, s);
1742
+ ke(this, t, this.context);
1743
+ } catch (r) {
1744
+ this._hasError = !0, t.onError && t.onError(r, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(r, this.context));
1846
1745
  }
1847
- for (const [s, i] of this._watchers.entries())
1848
- if (i.options.deep && t.startsWith(s + "."))
1849
- try {
1850
- const l = this._getNestedValue(s);
1851
- r(l, i.oldValue) || (i.callback(l, i.oldValue, this.context), i.oldValue = l);
1852
- } catch (l) {
1853
- console.error(`Error in deep watcher for "${s}":`, l);
1854
- }
1746
+ });
1855
1747
  }
1856
- _applyProps(t) {
1857
- try {
1858
- let n = function(r, o) {
1859
- return o === Boolean ? r === "true" : o === Number ? Number(r) : r;
1860
- };
1861
- if (!t.props) return;
1862
- Object.entries(t.props).forEach(([r, o]) => {
1863
- if (o.type === Function && typeof this[r] == "function")
1864
- this.context[r] = this[r];
1865
- else {
1866
- const s = this.getAttribute(Q(r));
1867
- s !== null ? this.context[r] = J(
1868
- n(s, o.type)
1869
- ) : "default" in o && o.default !== void 0 && (this.context[r] = J(o.default));
1748
+ };
1749
+ }
1750
+ function F(e, t = {}, r, n) {
1751
+ const o = n ?? t.key;
1752
+ return { tag: e, key: o, props: t, children: r };
1753
+ }
1754
+ function U(e) {
1755
+ return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
1756
+ }
1757
+ function N(e) {
1758
+ return typeof e == "object" && e !== null && "tag" in e && !U(e);
1759
+ }
1760
+ function Ze(e, t) {
1761
+ return e.key != null ? e : { ...e, key: t };
1762
+ }
1763
+ function Xe(e, t = [], r = {}) {
1764
+ const n = {}, o = {}, s = {}, i = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
1765
+ let a;
1766
+ for (; a = i.exec(e); ) {
1767
+ const l = a[1], f = a[2], p = (a[4] || a[6]) ?? "", d = p.match(/^{{(\d+)}}$/);
1768
+ let u = d ? t[Number(d[1])] ?? null : p;
1769
+ if (d || (u === "true" ? u = !0 : u === "false" ? u = !1 : u === "null" ? u = null : isNaN(Number(u)) || (u = Number(u))), l === ":")
1770
+ typeof u == "boolean" ? o[f] = u : u != null && (n[f] = u);
1771
+ else if (l === "@") {
1772
+ const m = "on" + f.charAt(0).toUpperCase() + f.slice(1);
1773
+ n[m] = typeof u == "function" ? u : typeof r[u] == "function" ? r[u] : void 0;
1774
+ } else if (l === "#") {
1775
+ const [m, ...h] = f.split("."), C = [...h];
1776
+ let y = u, c = [...C];
1777
+ if (m === "model" && typeof y == "string" && y.includes(".")) {
1778
+ const b = ["trim", "number", "lazy"], g = y.split(".");
1779
+ let v = y;
1780
+ const w = [];
1781
+ for (let k = g.length - 1; k > 0 && b.includes(g[k]); k--)
1782
+ w.unshift(g[k]), v = g.slice(0, k).join(".");
1783
+ y = v, c.push(...w);
1784
+ }
1785
+ s[m] = {
1786
+ value: y,
1787
+ modifiers: c
1788
+ };
1789
+ } else f === "ref" ? n.ref = u : o[f] = u;
1790
+ }
1791
+ return { props: n, attrs: o, directives: s };
1792
+ }
1793
+ function Ye(e, t, r) {
1794
+ function n(c, b) {
1795
+ return F("#text", {}, c, b);
1796
+ }
1797
+ let o = "";
1798
+ for (let c = 0; c < e.length; c++)
1799
+ o += e[c], c < t.length && (o += `{{${c}}}`);
1800
+ const s = /<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g, i = [];
1801
+ let a = null, l, f = [], p = null, d = {}, u, m = 0, h = [];
1802
+ function C(c) {
1803
+ !c || typeof c != "object" || U(c) || (c.props || c.attrs ? (c.props && (d.props || (d.props = {}), Object.assign(d.props, c.props)), c.attrs && (d.attrs || (d.attrs = {}), Object.keys(c.attrs).forEach((b) => {
1804
+ if (b === "style" && d.attrs.style) {
1805
+ const g = d.attrs.style.replace(
1806
+ /;?\s*$/,
1807
+ ""
1808
+ ), v = c.attrs.style.replace(/^;?\s*/, "");
1809
+ d.attrs.style = g + "; " + v;
1810
+ } else if (b === "class" && d.attrs.class) {
1811
+ const g = d.attrs.class.trim().split(/\s+/).filter(Boolean), v = c.attrs.class.trim().split(/\s+/).filter(Boolean), w = [
1812
+ .../* @__PURE__ */ new Set([...g, ...v])
1813
+ ];
1814
+ d.attrs.class = w.join(" ");
1815
+ } else
1816
+ d.attrs[b] = c.attrs[b];
1817
+ }))) : (d.props || (d.props = {}), Object.assign(d.props, c)));
1818
+ }
1819
+ function y(c, b) {
1820
+ const g = p ? f : h;
1821
+ if (U(c)) {
1822
+ const v = c.key ?? b;
1823
+ let w = c.children;
1824
+ g.push({
1825
+ ...c,
1826
+ key: v,
1827
+ children: w
1828
+ });
1829
+ return;
1830
+ }
1831
+ if (N(c)) {
1832
+ g.push(Ze(c, void 0));
1833
+ return;
1834
+ }
1835
+ if (Array.isArray(c)) {
1836
+ if (c.length === 0) return;
1837
+ for (let v = 0; v < c.length; v++) {
1838
+ const w = c[v];
1839
+ U(w) || N(w) || Array.isArray(w) ? y(w, `${b}-${v}`) : w !== null && typeof w == "object" ? C(w) : g.push(n(String(w), `${b}-${v}`));
1840
+ }
1841
+ return;
1842
+ }
1843
+ if (c !== null && typeof c == "object") {
1844
+ C(c);
1845
+ return;
1846
+ }
1847
+ g.push(n(String(c), b));
1848
+ }
1849
+ for (; l = s.exec(o); )
1850
+ if (l[1]) {
1851
+ const c = l[1], b = l[0][1] === "/", g = l[0][l[0].length - 2] === "/", {
1852
+ props: v,
1853
+ attrs: w,
1854
+ directives: k
1855
+ } = Xe(l[2] || "", t, r), S = { props: {}, attrs: {} };
1856
+ for (const x in v) S.props[x] = v[x];
1857
+ for (const x in w) S.attrs[x] = w[x];
1858
+ for (const [x, $] of Object.entries(k))
1859
+ if (x === "bind")
1860
+ if (typeof $.value == "object" && $.value !== null)
1861
+ for (const [A, E] of Object.entries($.value))
1862
+ typeof E == "boolean" ? S.attrs[A] = E : E != null && (S.attrs[A] = String(E));
1863
+ else $.value != null && (S.attrs[x] = String($.value));
1864
+ else if (x === "show") {
1865
+ const A = !!$.value;
1866
+ S.attrs.style = (S.attrs.style || "") + (A ? "" : "; display: none !important");
1867
+ } else if (x === "class") {
1868
+ const A = $.value;
1869
+ let E = [];
1870
+ if (typeof A == "string")
1871
+ E = A.split(/\s+/).filter(Boolean);
1872
+ else if (Array.isArray(A)) {
1873
+ for (const j of A)
1874
+ if (typeof j == "string")
1875
+ E.push(...j.split(/\s+/).filter(Boolean));
1876
+ else if (j && typeof j == "object")
1877
+ for (const [L, I] of Object.entries(j))
1878
+ I && E.push(...L.split(/\s+/).filter(Boolean));
1879
+ } else if (A && typeof A == "object")
1880
+ for (const [j, L] of Object.entries(A))
1881
+ L && E.push(...j.split(/\s+/).filter(Boolean));
1882
+ const O = S.attrs.class || "", W = [
1883
+ .../* @__PURE__ */ new Set([
1884
+ ...O.split(/\s+/).filter(Boolean),
1885
+ ...E
1886
+ ])
1887
+ ];
1888
+ S.attrs.class = W.join(" ");
1889
+ } else if (x === "style") {
1890
+ const A = $.value;
1891
+ let E = "";
1892
+ if (typeof A == "string")
1893
+ E = A;
1894
+ else if (A && typeof A == "object") {
1895
+ const W = [];
1896
+ for (const [j, L] of Object.entries(A))
1897
+ if (L != null && L !== "") {
1898
+ const I = j.replace(
1899
+ /[A-Z]/g,
1900
+ (ye) => `-${ye.toLowerCase()}`
1901
+ ), me = [
1902
+ "width",
1903
+ "height",
1904
+ "top",
1905
+ "right",
1906
+ "bottom",
1907
+ "left",
1908
+ "margin",
1909
+ "margin-top",
1910
+ "margin-right",
1911
+ "margin-bottom",
1912
+ "margin-left",
1913
+ "padding",
1914
+ "padding-top",
1915
+ "padding-right",
1916
+ "padding-bottom",
1917
+ "padding-left",
1918
+ "font-size",
1919
+ "line-height",
1920
+ "border-width",
1921
+ "border-radius",
1922
+ "min-width",
1923
+ "max-width",
1924
+ "min-height",
1925
+ "max-height"
1926
+ ];
1927
+ let oe = String(L);
1928
+ typeof L == "number" && me.includes(I) && (oe = `${L}px`), W.push(`${I}: ${oe}`);
1929
+ }
1930
+ E = W.join("; ") + (W.length > 0 ? ";" : "");
1870
1931
  }
1871
- });
1872
- } catch (n) {
1873
- this._hasError = !0, t.onError && t.onError(n, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1874
- n,
1875
- this.context
1876
- ));
1932
+ const O = S.attrs.style || "";
1933
+ S.attrs.style = O + (O && !O.endsWith(";") ? "; " : "") + E;
1934
+ }
1935
+ const _ = {};
1936
+ for (const [x, $] of Object.entries(k))
1937
+ ["bind", "show", "class", "style"].includes(x) || (_[x] = $);
1938
+ if (Object.keys(_).length > 0 && (S.directives = _), b) {
1939
+ const x = F(
1940
+ p,
1941
+ d,
1942
+ f.length === 1 && N(f[0]) && f[0].tag === "#text" ? typeof f[0].children == "string" ? f[0].children : "" : f.length ? f : void 0,
1943
+ u
1944
+ ), $ = i.pop();
1945
+ $ ? (p = $.tag, d = $.props, u = $.key, f = $.children, f.push(x)) : a = x;
1946
+ } else g ? (p ? f : h).push(F(c, S, void 0, void 0)) : (p && i.push({
1947
+ tag: p,
1948
+ props: d,
1949
+ children: f,
1950
+ key: u
1951
+ }), p = c, d = S, f = []);
1952
+ } else if (typeof l[3] < "u") {
1953
+ const c = Number(l[3]), b = t[c], g = `interp-${c}`;
1954
+ y(b, g);
1955
+ } else if (l[4]) {
1956
+ const c = l[4], b = p ? f : h, g = c.split(/({{\d+}})/);
1957
+ for (const v of g) {
1958
+ if (!v) continue;
1959
+ const w = v.match(/^{{(\d+)}}$/);
1960
+ if (w) {
1961
+ const k = Number(w[1]), S = t[k], _ = `interp-${k}`;
1962
+ y(S, _);
1963
+ } else {
1964
+ const k = `text-${m++}`;
1965
+ b.push(n(v, k));
1966
+ }
1877
1967
  }
1878
1968
  }
1969
+ if (a)
1970
+ return N(a) && Array.isArray(a.children) && (a.children = a.children.filter(
1971
+ (c) => N(c) ? c.tag !== "#text" || typeof c.children == "string" && c.children.trim() !== "" : !0
1972
+ // keep non-element VNodes (including anchors) as-is
1973
+ )), a;
1974
+ if (h.length > 0) {
1975
+ const c = h.filter(
1976
+ (b) => N(b) ? b.tag !== "#text" || typeof b.children == "string" && b.children.trim() !== "" : !0
1977
+ );
1978
+ return c.length === 1 ? c[0] : c;
1979
+ }
1980
+ return F("div", {}, "", "fallback-root");
1981
+ }
1982
+ function B(e, ...t) {
1983
+ const r = t[t.length - 1], n = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
1984
+ return Ye(e, t, n);
1985
+ }
1986
+ const Ge = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, D = (e, t) => {
1987
+ for (const r of e) {
1988
+ const n = [], o = r.path.replace(/:[^/]+/g, (a) => (n.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${o}$`), i = t.match(s);
1989
+ if (i) {
1990
+ const a = {};
1991
+ return n.forEach((l, f) => {
1992
+ a[l] = i[f + 1];
1993
+ }), { route: r, params: a };
1994
+ }
1995
+ }
1996
+ return { route: null, params: {} };
1997
+ }, G = {};
1998
+ async function et(e) {
1999
+ if (e.component) return e.component;
2000
+ if (e.load) {
2001
+ if (G[e.path]) return G[e.path];
2002
+ try {
2003
+ const t = await e.load();
2004
+ return G[e.path] = t.default, t.default;
2005
+ } catch {
2006
+ throw new Error(`Failed to load component for route: ${e.path}`);
2007
+ }
2008
+ }
2009
+ throw new Error(`No component or loader defined for route: ${e.path}`);
2010
+ }
2011
+ function tt(e) {
2012
+ const { routes: t, base: r = "" } = e;
2013
+ let n, o, s, i, a, l, f;
2014
+ if (typeof window < "u" && typeof document < "u") {
2015
+ n = () => {
2016
+ const d = new URL(window.location.href), u = d.pathname.replace(r, "") || "/", m = Ge(d.search);
2017
+ return { path: u, query: m };
2018
+ }, o = n();
2019
+ const p = D(t, o.path);
2020
+ s = ie({
2021
+ path: o.path,
2022
+ params: p.params,
2023
+ query: o.query
2024
+ }), i = () => {
2025
+ const d = n(), u = D(t, d.path), m = s.getState();
2026
+ m.path = d.path, m.params = u.params, m.query = d.query;
2027
+ }, window.addEventListener("popstate", i), a = (d) => {
2028
+ window.history.pushState({}, "", r + d), i();
2029
+ }, l = (d) => {
2030
+ window.history.replaceState({}, "", r + d), i();
2031
+ }, f = () => window.history.back();
2032
+ } else {
2033
+ n = () => ({ path: "/", query: {} }), o = n();
2034
+ const p = D(t, o.path);
2035
+ s = ie({
2036
+ path: o.path,
2037
+ params: p.params,
2038
+ query: o.query
2039
+ }), i = () => {
2040
+ }, a = () => {
2041
+ }, l = () => {
2042
+ }, f = () => {
2043
+ };
2044
+ }
2045
+ return {
2046
+ store: s,
2047
+ push: a,
2048
+ replace: l,
2049
+ back: f,
2050
+ subscribe: s.subscribe,
2051
+ matchRoute: (p) => D(t, p),
2052
+ getCurrent: () => s.getState(),
2053
+ resolveRouteComponent: et
1879
2054
  };
1880
2055
  }
2056
+ function ct(e, t) {
2057
+ return D(e, t);
2058
+ }
2059
+ function ft(e) {
2060
+ const t = tt(e);
2061
+ return de("router-view", {
2062
+ async render() {
2063
+ if (!t) return B`<div>Router not initialized.</div>`;
2064
+ const r = t.getCurrent(), { path: n } = r, o = t.matchRoute(n);
2065
+ if (!o.route) return B`<div>Not found</div>`;
2066
+ let s = o.route.component;
2067
+ if (o.route.load) {
2068
+ const i = await o.route.load();
2069
+ typeof i.default == "string" && (s = i.default);
2070
+ }
2071
+ return typeof s == "string" ? B`<${s}></${s}>` : B`<div>Invalid route component</div>`;
2072
+ },
2073
+ onConnected(r) {
2074
+ t && typeof t.subscribe == "function" && t.subscribe(() => {
2075
+ typeof r.requestRender == "function" && r.requestRender();
2076
+ });
2077
+ }
2078
+ }), de("router-link", {
2079
+ state: {},
2080
+ props: {
2081
+ to: { type: String, default: "" },
2082
+ tag: { type: String, default: "a" },
2083
+ replace: { type: Boolean, default: !1 },
2084
+ exact: { type: Boolean, default: !1 },
2085
+ activeClass: { type: String, default: "active" },
2086
+ exactActiveClass: { type: String, default: "exact-active" },
2087
+ ariaCurrentValue: { type: String, default: "page" },
2088
+ disabled: { type: Boolean, default: !1 },
2089
+ external: { type: Boolean, default: !1 },
2090
+ style: { type: String, default: he`
2091
+ [aria-disabled="true"] {
2092
+ pointer-events: none;
2093
+ opacity: 0.5;
2094
+ }
2095
+ ` }
2096
+ },
2097
+ style: (r) => r.props.style,
2098
+ render: (r) => {
2099
+ const n = t.getCurrent(), o = r.props.to, s = r.props.exact, i = r.props.exactActiveClass, a = r.props.activeClass, l = r.props.ariaCurrentValue, f = r.props.tag, p = r.props.disabled, d = r.props.external, u = n.path === o, m = s ? u : n && typeof n.path == "string" ? n.path.startsWith(o) : !1, h = u ? i : m ? a : "", C = u ? `aria-current="${l}"` : "", y = f === "button", c = p ? y ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", b = d && (f === "a" || !f) ? 'target="_blank" rel="noopener noreferrer"' : "";
2100
+ return B`
2101
+ ${be().when(y, B`
2102
+ <button
2103
+ part="button"
2104
+ class="${h}"
2105
+ ${C}
2106
+ ${c}
2107
+ ${b}
2108
+ data-on-click="navigate"
2109
+ ><slot></slot></button>
2110
+ `).otherwise(B`
2111
+ <a
2112
+ part="link"
2113
+ href="${o}"
2114
+ class="${h}"
2115
+ ${C}
2116
+ ${c}
2117
+ ${b}
2118
+ data-on-click="navigate"
2119
+ ><slot></slot></a>
2120
+ `).done()}
2121
+ `;
2122
+ },
2123
+ navigate: (r, n) => {
2124
+ const { disabled: o, external: s, tag: i, replace: a, to: l } = n.props;
2125
+ if (o) {
2126
+ r.preventDefault();
2127
+ return;
2128
+ }
2129
+ s && (i === "a" || !i) || (r.preventDefault(), a ? t.replace(l) : t.push(l));
2130
+ }
2131
+ }), t;
2132
+ }
1881
2133
  export {
1882
- Ie as component,
1883
- ze as createElementClass,
1884
- Re as createStore,
1885
- He as css,
1886
- Ne as each,
1887
- Be as eventBus,
1888
- Oe as html,
1889
- Pe as match,
1890
- Me as when
2134
+ P as GlobalEventBus,
2135
+ de as component,
2136
+ ie as createStore,
2137
+ he as css,
2138
+ nt as each,
2139
+ ot as emit,
2140
+ H as eventBus,
2141
+ B as html,
2142
+ ft as initRouter,
2143
+ lt as listen,
2144
+ be as match,
2145
+ D as matchRoute,
2146
+ ct as matchRouteSSR,
2147
+ st as off,
2148
+ it as on,
2149
+ at as once,
2150
+ Ge as parseQuery,
2151
+ et as resolveRouteComponent,
2152
+ tt as useRouter,
2153
+ rt as when
1891
2154
  };
1892
2155
  //# sourceMappingURL=custom-elements-runtime.es.js.map