@jasonshimmy/custom-elements-runtime 0.1.1 → 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: (o, l, f) => (o[l] = f, 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(o) {
7
- n.push(o), o(t);
8
- }
9
- function i() {
10
- return t;
11
- }
12
- function s() {
13
- n.forEach((o) => o(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: i };
29
+ return [J([], "whenChain-empty")];
16
30
  }
17
- class B extends EventTarget {
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
+ };
38
+ }
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,26 +52,26 @@ 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(), i = this.eventCounters.get(t);
35
- if (!i || r - i.window > 1e3)
36
- this.eventCounters.set(t, { count: 1, window: r });
37
- else if (i.count++, i.count > 50 && (console.error(`Event storm detected for "${t}": ${i.count} events in 1 second. Throttling...`), i.count > 100)) {
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 });
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
46
68
  }));
47
69
  const s = this.handlers[t];
48
- s && s.forEach((o) => {
70
+ s && s.forEach((i) => {
49
71
  try {
50
- o(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) => {
96
- const i = this.on(t, (s) => {
97
- i(), n(s), r(s);
116
+ once(t, r) {
117
+ return new Promise((n) => {
118
+ const o = this.on(t, (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 i = r ?? t.key;
144
- return { tag: e, key: i, props: t, children: n };
145
- }
146
- function I(e) {
147
- return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
148
- }
149
- function R(e) {
150
- return typeof e == "object" && e !== null && "tag" in e && !I(e);
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 };
151
179
  }
152
- function le(e, t) {
153
- return e.key != null ? e : { ...e, key: t };
180
+ function ne(e) {
181
+ return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
154
182
  }
155
- function ce(e, t = [], n = {}) {
156
- const r = {}, i = {}, s = {}, o = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
157
- let l;
158
- for (; l = o.exec(e); ) {
159
- const f = l[1], u = l[2], p = (l[4] || l[6]) ?? "", d = p.match(/^{{(\d+)}}$/);
160
- let c = d ? t[Number(d[1])] ?? null : p;
161
- if (d || (c === "true" ? c = !0 : c === "false" ? c = !1 : c === "null" ? c = null : isNaN(Number(c)) || (c = Number(c))), f === ":")
162
- typeof c == "boolean" ? i[u] = c : c != null && (r[u] = c);
163
- else if (f === "@") {
164
- const y = "on" + u.charAt(0).toUpperCase() + u.slice(1);
165
- r[y] = typeof c == "function" ? c : typeof n[c] == "function" ? n[c] : void 0;
166
- } else if (f === "#") {
167
- const [y, ...h] = u.split("."), S = [...h];
168
- let m = c, a = [...S];
169
- if (y === "model" && typeof m == "string" && m.includes(".")) {
170
- const b = ["trim", "number", "lazy"], g = m.split(".");
171
- let x = m;
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
- m = x, a.push(...w);
176
- }
177
- s[y] = {
178
- value: m,
179
- modifiers: a
180
- };
181
- } else u === "ref" ? r.ref = c : i[u] = c;
182
- }
183
- return { props: r, attrs: i, directives: s };
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;
184
194
  }
185
- function fe(e, t, n) {
186
- function r(a, b) {
187
- return P("#text", {}, a, b);
188
- }
189
- let i = "";
190
- for (let a = 0; a < e.length; a++)
191
- i += e[a], a < t.length && (i += `{{${a}}}`);
192
- const s = /<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g, o = [];
193
- let l = null, f, u = [], p = null, d = {}, c, y = 0, h = [];
194
- function S(a) {
195
- !a || typeof a != "object" || I(a) || (a.props || a.attrs ? (a.props && (d.props || (d.props = {}), Object.assign(d.props, a.props)), a.attrs && (d.attrs || (d.attrs = {}), Object.keys(a.attrs).forEach((b) => {
196
- if (b === "style" && d.attrs.style) {
197
- const g = d.attrs.style.replace(
198
- /;?\s*$/,
199
- ""
200
- ), x = a.attrs.style.replace(/^;?\s*/, "");
201
- d.attrs.style = g + "; " + x;
202
- } else if (b === "class" && d.attrs.class) {
203
- const g = d.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
- d.attrs.class = w.join(" ");
207
- } else
208
- d.attrs[b] = a.attrs[b];
209
- }))) : (d.props || (d.props = {}), Object.assign(d.props, a)));
210
- }
211
- function m(a, b) {
212
- const g = p ? u : 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;
226
- }
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) ? m(w, `${b}-${x}`) : w !== null && typeof w == "object" ? S(w) : g.push(r(String(w), `${b}-${x}`));
232
- }
233
- return;
234
- }
235
- if (a !== null && typeof a == "object") {
236
- S(a);
237
- return;
238
- }
239
- g.push(r(String(a), b));
240
- }
241
- for (; f = s.exec(i); )
242
- if (f[1]) {
243
- const a = f[1], b = f[0][1] === "/", g = f[0][f[0].length - 2] === "/", {
244
- props: x,
245
- attrs: w,
246
- directives: k
247
- } = ce(f[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 M = $.attrs.class || "", O = [
275
- .../* @__PURE__ */ new Set([
276
- ...M.split(/\s+/).filter(Boolean),
277
- ...E
278
- ])
279
- ];
280
- $.attrs.class = O.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 O = [];
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`), O.push(`${N}: ${X}`);
321
- }
322
- E = O.join("; ") + (O.length > 0 ? ";" : "");
323
- }
324
- const M = $.attrs.style || "";
325
- $.attrs.style = M + (M && !M.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
- d,
334
- u.length === 1 && R(u[0]) && u[0].tag === "#text" ? typeof u[0].children == "string" ? u[0].children : "" : u.length ? u : void 0,
335
- c
336
- ), _ = o.pop();
337
- _ ? (p = _.tag, d = _.props, c = _.key, u = _.children, u.push(v)) : l = v;
338
- } else g ? (p ? u : h).push(P(a, $, void 0, void 0)) : (p && o.push({
339
- tag: p,
340
- props: d,
341
- children: u,
342
- key: c
343
- }), p = a, d = $, u = []);
344
- } else if (typeof f[3] < "u") {
345
- const a = Number(f[3]), b = t[a], g = `interp-${a}`;
346
- m(b, g);
347
- } else if (f[4]) {
348
- const a = f[4], b = p ? u : 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
- m($, C);
355
- } else {
356
- const k = `text-${y++}`;
357
- b.push(r(x, k));
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);
358
209
  }
359
- }
360
210
  }
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
211
  }
374
- function Me(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);
212
+ function te(e, t) {
213
+ return t.split(".").reduce((r, n) => r?.[n], e);
377
214
  }
378
- function Oe(e, t) {
379
- return K(e ? t : [], "when-block");
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);
229
+ }
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);
237
+ }
380
238
  }
381
- function Ne(e, t) {
382
- return e.map((n, r) => {
383
- const i = typeof n == "object" ? n?.key ?? n?.id ?? `idx-${r}` : String(n);
384
- return K(t(n, r), `each-${i}`);
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;
243
+ }
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));
250
+ }
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 de(...e);
398
- }
399
- };
253
+ function $e(e, t, r, n) {
254
+ e.onConnected && !r && (e.onConnected(t), n(!0));
400
255
  }
401
- function de(...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("."), i = r.pop();
421
- if (!i) return;
422
- const s = r.reduce((o, l) => (l in o || (o[l] = {}), o[l]), e);
423
- s[i] = n;
273
+ function se(e, t, r) {
274
+ const n = t.split("."), o = n.pop();
275
+ if (!o) return;
276
+ const s = n.reduce((i, a) => (a in i || (i[a] = {}), i[a]), e);
277
+ s[o] = r;
424
278
  }
425
- function ue(e, t, n, r, i, s, o) {
279
+ function _e(e, t, r, n, o, s, i) {
426
280
  if (!s) return;
427
- const l = t.includes("lazy"), f = t.includes("trim"), u = t.includes("number"), p = () => {
428
- const m = s._state || s;
429
- return z(m, e);
281
+ const a = t.includes("lazy"), l = t.includes("trim"), f = t.includes("number"), p = () => {
282
+ const y = s._state || s;
283
+ return R(y, e);
430
284
  }, d = p();
431
- let c = "text";
432
- const y = r?.type;
433
- if (o instanceof HTMLInputElement ? c = y || o.type || "text" : o instanceof HTMLSelectElement ? c = "select" : o instanceof HTMLTextAreaElement && (c = "textarea"), c === "checkbox")
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")
434
288
  if (Array.isArray(d)) {
435
- const m = o?.getAttribute("value") || r?.value || "", a = d.includes(m);
436
- o && o.checked !== a && (n.checked = a);
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 m = o?.getAttribute("true-value") || !0, a = d === m;
439
- o && o.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 (c === "radio") {
442
- const m = r?.value || "", a = d === m;
443
- o && o.checked !== a && (n.checked = a);
444
- } else if (c === "select")
445
- if (o && o.hasAttribute("multiple")) {
446
- const m = o, a = Array.isArray(d) ? d : [];
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")
299
+ if (i && i.hasAttribute("multiple")) {
300
+ const y = i, c = Array.isArray(d) ? d : [];
447
301
  setTimeout(() => {
448
- Array.from(m.options).forEach((b) => {
449
- const g = a.includes(b.value);
302
+ Array.from(y.options).forEach((b) => {
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
- o instanceof HTMLSelectElement && o.value !== String(d) && (o.value = String(d));
309
+ i instanceof HTMLSelectElement && i.value !== String(d) && (i.value = String(d));
456
310
  }, 0);
457
311
  else {
458
- const m = String(d ?? "");
459
- (!o || o.value !== m) && (n.value = d);
312
+ const y = String(d ?? "");
313
+ (!i || i.value !== y) && (r.value = d);
460
314
  }
461
- const h = l || c === "checkbox" || c === "radio" || c === "select" ? "change" : "input", S = (m) => {
462
- if (m.isComposing || i._isComposing || m.isTrusted === !1) return;
463
- const a = m.target;
464
- if (a._modelUpdating) return;
315
+ const h = a || u === "checkbox" || u === "radio" || u === "select" ? "change" : "input", C = (y) => {
316
+ if (y.isComposing || o._isComposing || y.isTrusted === !1) return;
317
+ const c = y.target;
318
+ if (c._modelUpdating) return;
465
319
  const b = p();
466
- let g = a.value;
467
- if (c === "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 (c === "radio")
482
- g = a.getAttribute("value") || a.value;
483
- else if (c === "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 (f && (g = g.trim()), u) {
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 $ = m.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 (i[h] = S, c === "text" || c === "textarea") {
501
- const m = () => {
502
- i._isComposing = !0;
503
- }, a = (b) => {
504
- i._isComposing = !1;
354
+ if (o[h] = C, u === "text" || u === "textarea") {
355
+ const y = () => {
356
+ o._isComposing = !0;
357
+ }, c = (b) => {
358
+ o._isComposing = !1;
505
359
  const g = b.target;
506
360
  setTimeout(() => {
507
361
  if (g) {
508
- let x = g.value;
509
- if (f && (x = x.trim()), u) {
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
- i.compositionstart = m, i.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
- const i = JSON.parse(e);
527
- if (typeof i == "object")
528
- for (const [s, o] of Object.entries(i))
529
- t[s] = o;
380
+ const o = JSON.parse(e);
381
+ if (typeof o == "object")
382
+ for (const [s, i] of Object.entries(o))
383
+ t[s] = i;
530
384
  } catch {
531
- const i = z(r, e);
532
- n[e] = i;
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), i = t.style || "", s = r ? "" : "none";
538
- if (i) {
539
- const o = i.split(";").filter(Boolean), l = o.findIndex(
540
- (f) => f.trim().startsWith("display:")
389
+ function Ee(e, t, r) {
390
+ if (!r) return;
391
+ const n = R(r, e), o = t.style || "", s = n ? "" : "none";
392
+ if (o) {
393
+ const i = o.split(";").filter(Boolean), a = i.findIndex(
394
+ (l) => l.trim().startsWith("display:")
541
395
  );
542
- l >= 0 ? o[l] = `display: ${s}` : o.push(`display: ${s}`), t.style = o.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);
549
- let i = [];
550
- typeof r == "string" ? i = [r] : Array.isArray(r) ? i = r.filter(Boolean) : typeof r == "object" && (i = Object.entries(r).filter(([, l]) => !!l).map(([l]) => l));
551
- const s = t.class || "", o = s ? `${s} ${i.join(" ")}`.trim() : i.join(" ");
552
- o && (t.class = o);
400
+ function Te(e, t, r) {
401
+ if (!r) return;
402
+ const n = R(r, e);
403
+ let o = [];
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));
405
+ const s = t.class || "", i = s ? `${s} ${o.join(" ")}`.trim() : o.join(" ");
406
+ i && (t.class = i);
553
407
  }
554
- function ye(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;
561
- let i = "";
562
- if (typeof r == "string")
563
- i = r;
564
- else if (r && typeof r == "object") {
565
- const o = [];
566
- for (const [l, f] of Object.entries(r))
567
- if (f != null && f !== "") {
568
- const u = l.replace(
414
+ n = e;
415
+ let o = "";
416
+ if (typeof n == "string")
417
+ o = n;
418
+ else if (n && typeof n == "object") {
419
+ const i = [];
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
- (c) => `-${c.toLowerCase()}`
424
+ (u) => `-${u.toLowerCase()}`
571
425
  ), p = [
572
426
  "width",
573
427
  "height",
@@ -594,98 +448,98 @@ function ye(e, t, n) {
594
448
  "min-height",
595
449
  "max-height"
596
450
  ];
597
- let d = String(f);
598
- typeof f == "number" && p.includes(u) && (d = `${f}px`), o.push(`${u}: ${d}`);
451
+ let d = String(l);
452
+ typeof l == "number" && p.includes(f) && (d = `${l}px`), i.push(`${f}: ${d}`);
599
453
  }
600
- i = o.join("; ") + (o.length > 0 ? ";" : "");
454
+ o = i.join("; ") + (i.length > 0 ? ";" : "");
601
455
  }
602
456
  const s = t.style || "";
603
- t.style = s + (s && !s.endsWith(";") ? "; " : "") + i;
457
+ t.style = s + (s && !s.endsWith(";") ? "; " : "") + o;
604
458
  }
605
- function ie(e, t, n, r) {
606
- const i = {}, s = { ...r || {} }, o = {};
607
- for (const [l, f] of Object.entries(e)) {
608
- const { value: u, modifiers: p } = f;
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
- ue(
612
- typeof u == "string" ? u : String(u),
465
+ _e(
466
+ typeof f == "string" ? f : String(f),
613
467
  p,
614
- i,
615
- s,
616
468
  o,
469
+ s,
470
+ i,
617
471
  t,
618
- n
472
+ r
619
473
  );
620
474
  break;
621
475
  case "bind":
622
- pe(u, i, s, t);
476
+ Ae(f, o, s, t);
623
477
  break;
624
478
  case "show":
625
- he(u, s, t);
479
+ Ee(f, s, t);
626
480
  break;
627
481
  case "class":
628
- ge(u, s, t);
482
+ Te(f, s, t);
629
483
  break;
630
484
  case "style":
631
- ye(u, s, t);
485
+ je(f, s, t);
632
486
  break;
633
487
  }
634
488
  }
635
- return { props: i, attrs: s, listeners: o };
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
- return e.map((o) => {
641
- if (!o || typeof o != "object") return o;
642
- let l = o.props?.key ?? o.key;
643
- if (!l) {
644
- const d = o.tag || "node", c = o.props?.attrs?.id ?? o.props?.attrs?.name ?? o.props?.attrs?.["data-key"] ?? "";
645
- l = c ? `${t}:${d}:${c}` : `${t}:${d}`;
494
+ return e.map((i) => {
495
+ if (!i || typeof i != "object") return i;
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 f = l, u = 1;
648
- for (; s.has(f); )
649
- f = `${l}#${u++}`;
650
- s.add(f);
651
- let p = o.children;
652
- return Array.isArray(p) && (p = Z(p, f)), { ...o, key: f, children: p };
501
+ let l = a, f = 1;
502
+ for (; s.has(l); )
503
+ l = `${a}#${f++}`;
504
+ s.add(l);
505
+ let p = i.children;
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, i = n.children;
657
- return Array.isArray(i) && (i = Z(i, r)), { ...n, key: r, children: i };
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 me(e, t, n, r) {
660
- const i = n.directives ?? {}, s = ie(
661
- i,
662
- r,
513
+ function Le(e, t, r, n) {
514
+ const o = r.directives ?? {}, s = pe(
515
+ o,
516
+ n,
663
517
  e,
664
- n.attrs
665
- ), o = {
518
+ r.attrs
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
- }, f = t.props ?? {}, u = o;
674
- for (const c in { ...f, ...u }) {
675
- const y = f[c], h = u[c];
676
- y !== h && (c === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? e.value !== h && (e.value = h ?? "") : c === "checked" && e instanceof HTMLInputElement ? e.checked = !!h : c.startsWith("on") && typeof h == "function" ? (typeof y == "function" && e.removeEventListener(c.slice(2).toLowerCase(), y), e.addEventListener(c.slice(2).toLowerCase(), h)) : h == null || h === !1 ? e.removeAttribute(c) : e.setAttribute(c, 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 [c, y] of Object.entries(
532
+ for (const [u, m] of Object.entries(
679
533
  s.listeners || {}
680
534
  ))
681
- e.addEventListener(c, y);
682
- const p = t.attrs ?? {}, d = l;
683
- for (const c in { ...p, ...d }) {
684
- const y = p[c], h = d[c];
685
- y !== h && (h == null || h === !1 ? e.removeAttribute(c) : e.setAttribute(c, 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") {
@@ -695,359 +549,291 @@ function T(e, t, n) {
695
549
  return e.key != null && (d.key = e.key), d;
696
550
  }
697
551
  if (e.tag === "#anchor") {
698
- const d = e, c = Array.isArray(d.children) ? d.children : [], y = document.createTextNode(""), h = document.createTextNode("");
699
- d.key != null && (y.key = `${d.key}:start`, h.key = `${d.key}:end`), d._startNode = y, d._endNode = h;
700
- const S = document.createDocumentFragment();
701
- S.appendChild(y);
702
- for (const m of c)
703
- S.appendChild(T(m, 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: i = {}, attrs: s = {}, directives: o = {} } = e.props ?? {}, l = ie(o, t, r, s), f = {
709
- ...i,
710
- ...l.props
711
- }, u = {
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 = {
563
+ ...o,
564
+ ...a.props
565
+ }, f = {
712
566
  ...s,
713
- ...l.attrs
567
+ ...a.attrs
714
568
  };
715
- for (const d in u) {
716
- const c = u[d];
717
- typeof c == "boolean" ? c && r.setAttribute(d, "") : c != null && r.setAttribute(d, String(c));
718
- }
719
569
  for (const d in f) {
720
- const c = f[d];
721
- if (d === "value" && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement))
722
- r.value = c ?? "";
723
- else if (d === "checked" && r instanceof HTMLInputElement)
724
- r.checked = !!c;
725
- else if (d.startsWith("on") && typeof c == "function")
726
- r.addEventListener(d.slice(2).toLowerCase(), c);
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 (d.startsWith("on") && c === void 0)
582
+ if (d.startsWith("on") && u === void 0)
729
583
  continue;
730
- c == null || c === !1 ? r.removeAttribute(d) : r.setAttribute(d, String(c));
584
+ u == null || u === !1 ? n.removeAttribute(d) : n.setAttribute(d, String(u));
731
585
  }
732
586
  }
733
- for (const [d, c] of Object.entries(
734
- l.listeners || {}
587
+ for (const [d, u] of Object.entries(
588
+ a.listeners || {}
735
589
  ))
736
- r.addEventListener(d, c);
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))
592
+ if (typeof e != "string" && p && r && (r[p] = n), Array.isArray(e.children))
739
593
  for (const d of e.children)
740
- r.appendChild(T(d, t, n));
741
- else typeof e.children == "string" && (r.textContent = e.children);
742
- return r;
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, i) {
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), o = Array.isArray(t) ? t : [], l = /* @__PURE__ */ new Map();
751
- for (const y of o)
752
- y && y.key != null && l.set(y.key, y);
753
- const f = /* @__PURE__ */ new Map();
754
- for (const y of s) {
755
- const h = y.key;
756
- h != null && f.set(h, y);
603
+ if (!Array.isArray(r)) return;
604
+ const s = Array.from(e.childNodes), i = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
605
+ for (const m of i)
606
+ m && m.key != null && a.set(m.key, m);
607
+ const l = /* @__PURE__ */ new Map();
608
+ for (const m of s) {
609
+ const h = m.key;
610
+ h != null && l.set(h, m);
757
611
  }
758
- const u = /* @__PURE__ */ new Set();
612
+ const f = /* @__PURE__ */ new Set();
759
613
  let p = e.firstChild;
760
- function d(y, h) {
761
- let S = y;
762
- for (; S && (u.add(S), S !== h); )
763
- S = S.nextSibling;
764
- }
765
- function c(y, h, S, m) {
766
- const a = [];
767
- let b = y.nextSibling;
614
+ function d(m, h) {
615
+ let C = m;
616
+ for (; C && (f.add(C), C !== h); )
617
+ C = C.nextSibling;
618
+ }
619
+ function u(m, h, C, y) {
620
+ const c = [];
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 : [];
771
- if (m.some((w) => w && w.key != null) || g.some((w) => w && w.key != null)) {
623
+ c.push(b), b = b.nextSibling;
624
+ const g = Array.isArray(C) ? C : [];
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 = y.nextSibling;
781
- for (const v of m) {
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
- m.length
654
+ y.length
801
655
  );
802
656
  for (let k = 0; k < w; k++) {
803
- const $ = g[k], C = m[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
- for (let k = w; k < m.length; k++)
807
- e.insertBefore(T(m[k], r), h);
808
- for (let k = w; k < a.length; k++)
809
- e.removeChild(a[k]);
660
+ for (let k = w; k < y.length; 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 y of n) {
666
+ for (const m of r) {
813
667
  let h;
814
- if (y.tag === "#anchor") {
815
- const S = y.key, m = `${S}:start`, a = `${S}:end`;
816
- let b = f.get(m), g = f.get(a);
817
- const x = Array.isArray(y.children) ? y.children : [];
818
- if (b || (b = document.createTextNode(""), b.key = m), g || (g = document.createTextNode(""), g.key = a), y._startNode = b, y._endNode = g, !e.contains(b) || !e.contains(g)) {
668
+ if (m.tag === "#anchor") {
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
- c(
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
684
  d(b, g), p = g.nextSibling;
831
685
  continue;
832
686
  }
833
- if (y.key != null && f.has(y.key)) {
834
- const S = l.get(y.key);
835
- h = D(
836
- f.get(y.key),
837
- S,
838
- y,
839
- r,
840
- i
841
- ), u.add(h), h !== p && e.contains(h) && (p && !e.contains(p) && (p = null), e.insertBefore(h, p));
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,
692
+ m,
693
+ n,
694
+ o
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(y, r, i), p && !e.contains(p) && (p = null), e.insertBefore(h, p), u.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
- for (const y of s)
847
- if (!u.has(y) && e.contains(y)) {
848
- if (y instanceof HTMLElement && i)
849
- for (const h in i)
850
- i[h] === y && delete i[h];
851
- e.removeChild(y);
852
- }
700
+ for (const m of s)
701
+ !f.has(m) && e.contains(m) && (z(m, o), e.removeChild(m));
853
702
  }
854
- function D(e, t, n, r, i) {
855
- if (t && typeof t != "string" && t.props?.ref && i && delete i[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 o = document.createTextNode(n);
861
- return e.parentNode?.replaceChild(o, e), o;
709
+ const i = document.createTextNode(r);
710
+ return e.parentNode?.replaceChild(i, e), i;
862
711
  }
863
712
  }
864
- if (n && typeof n != "string" && n.tag === "#anchor") {
865
- const o = n, l = Array.isArray(o.children) ? o.children : [], f = o._startNode ?? document.createTextNode(""), u = o._endNode ?? document.createTextNode("");
866
- o.key != null && (f.key = `${o.key}:start`, u.key = `${o.key}:end`), o._startNode = f, o._endNode = u;
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(f);
869
- for (const d of l)
870
- p.appendChild(T(d, r));
871
- return p.appendChild(u), e.parentNode?.replaceChild(p, e), f;
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) {
874
- const o = document.createComment("removed");
875
- return e.parentNode?.replaceChild(o, e), o;
722
+ if (!r) {
723
+ z(e, o);
724
+ const i = document.createComment("removed");
725
+ return e.parentNode?.replaceChild(i, e), i;
876
726
  }
877
727
  if (!t || typeof t == "string") {
878
- const o = T(n, r, i);
879
- return typeof n != "string" && n.props?.ref && i && (i[n.props.ref] = o), e.parentNode?.replaceChild(o, e), o;
880
- }
881
- if (n.tag === "#anchor") {
882
- const o = Array.isArray(n.children) ? n.children : [], l = n._startNode ?? document.createTextNode(""), f = n._endNode ?? document.createTextNode("");
883
- n.key != null && (l.key = `${n.key}:start`, f.key = `${n.key}:end`), n._startNode = l, n._endNode = f;
884
- const u = document.createDocumentFragment();
885
- u.appendChild(l);
886
- for (const p of o)
887
- u.appendChild(T(p, r));
888
- return u.appendChild(f), e.parentNode?.replaceChild(u, e), l;
889
- }
890
- if (typeof t != "string" && typeof n != "string" && t.tag === n.tag && t.key === n.key) {
891
- const o = e;
892
- return me(o, t.props || {}, n.props || {}, r), be(o, t.children, n.children, r, i), typeof n != "string" && n.props?.ref && i && (i[n.props.ref] = o), o;
893
- }
894
- const s = T(n, r, i);
895
- return typeof n != "string" && n.props?.ref && i && (i[n.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
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);
737
+ for (const p of i)
738
+ f.appendChild(T(p, n));
739
+ return f.appendChild(l), e.parentNode?.replaceChild(f, e), a;
740
+ }
741
+ if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
742
+ const i = e;
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;
744
+ }
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 i = (p) => p.key == null ? { ...p, key: "__root__" } : p;
899
- let s = Array.isArray(t) ? { tag: "div", key: "__root__", children: t } : i(t);
900
- s = Z(s, String(s.key ?? "root"));
901
- const o = e._prevVNode ?? null, l = e._prevDom ?? e.firstChild ?? null;
902
- let f;
903
- o && l ? typeof o != "string" && typeof s != "string" && o.tag === s.tag && o.key === s.key ? f = D(l, o, s, n, r) : (f = T(s, n, r), e.replaceChild(f, l)) : (f = T(s, n, r), e.firstChild ? e.replaceChild(f, e.firstChild) : e.appendChild(f));
904
- const u = [];
905
- for (let p = 0; p < e.childNodes.length; p++) {
906
- const d = e.childNodes[p];
907
- if (d !== f && d.nodeName !== "STYLE") {
908
- if (d instanceof HTMLElement && r)
909
- for (const c in r)
910
- r[c] === d && delete r[c];
911
- u.push(d);
912
- }
913
- }
914
- u.forEach((p) => e.removeChild(p)), e._prevVNode = s, e._prevDom = f;
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));
759
+ }
760
+ l.forEach((f) => e.removeChild(f)), e._prevVNode = o, e._prevDom = a;
915
761
  }
916
- function oe(e) {
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;
767
+ }
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 {
780
+ all: isolate;
928
781
  box-sizing: border-box;
929
- border-width: 0;
930
- border-style: solid;
931
- border-color: currentColor;
932
- }
933
- :host {
934
- font-size: 16px;
935
- line-height: 1.5;
936
- font-family: ui-sans-serif, system-ui, sans-serif;
937
- -webkit-text-size-adjust: 100%;
938
- text-size-adjust: 100%;
939
- color: inherit;
940
- background-color: transparent;
941
- }
942
- *, ::before, ::after {
943
- -webkit-tap-highlight-color: transparent;
782
+ border: 0 solid currentColor;
944
783
  margin: 0;
945
784
  padding: 0;
946
785
  font: inherit;
947
786
  vertical-align: baseline;
948
787
  background: transparent;
949
788
  color: inherit;
789
+ -webkit-tap-highlight-color: transparent;
950
790
  }
951
- button, input, optgroup, select, textarea {
952
- font: inherit;
953
- color: inherit;
791
+ :host {
792
+ display: contents;
793
+ font: 16px/1.5 ui-sans-serif, system-ui, sans-serif;
794
+ -webkit-text-size-adjust: 100%;
795
+ text-size-adjust: 100%;
796
+ }
797
+ button, input, select, textarea {
954
798
  background: transparent;
955
- border: none;
956
799
  outline: none;
957
- margin: 0;
958
- padding: 0;
959
- }
960
- textarea {
961
- resize: vertical;
962
- }
963
- progress {
964
- vertical-align: baseline;
965
- }
966
- button, textarea {
967
- overflow: visible;
968
- }
969
- input[type="search"]::-webkit-search-decoration,
970
- input[type="search"]::-webkit-search-cancel-button,
971
- input[type="search"]::-webkit-search-results-button,
972
- input[type="search"]::-webkit-search-results-decoration {
973
- -webkit-appearance: none;
974
800
  }
801
+ textarea { resize: vertical }
802
+ progress { vertical-align: baseline }
803
+ button, textarea { overflow: visible }
975
804
  img, svg, video, canvas, audio, iframe, embed, object {
976
805
  display: block;
977
806
  max-width: 100%;
978
807
  height: auto;
979
- vertical-align: middle;
980
- }
981
- select {
982
- text-transform: none;
983
- }
984
- optgroup {
985
- font-weight: bold;
986
- }
987
- fieldset {
988
- border: none;
989
- }
990
- svg {
991
- fill: currentColor;
992
- stroke: none;
993
808
  }
994
- a {
995
- color: inherit;
996
- text-decoration: inherit;
997
- }
998
- a, button {
809
+ svg { fill: currentColor; stroke: none }
810
+ a { text-decoration: inherit; cursor: pointer }
811
+ button, [type=button], [type=reset], [type=submit] {
999
812
  cursor: pointer;
1000
- }
1001
- input[type="file"] {
1002
- border: 0;
1003
- }
1004
- button, [type="button"], [type="reset"], [type="submit"] {
1005
813
  appearance: button;
1006
- background-color: transparent;
1007
- background-image: none;
1008
- }
1009
- [type='button'], [type='reset'], [type='submit'] {
814
+ background: none;
1010
815
  -webkit-user-select: none;
1011
816
  user-select: none;
1012
817
  }
1013
- ::-webkit-input-placeholder { color: inherit; opacity: 0.5; }
1014
- ::placeholder { color: inherit; opacity: 0.5; }
818
+ ::-webkit-input-placeholder, ::placeholder {
819
+ color: inherit; opacity: .5;
820
+ }
1015
821
  *:focus {
1016
- outline: 2px solid #3b82f6;
822
+ outline: 2px solid var(--color-blue-500, #3b82f6);
1017
823
  outline-offset: 2px;
1018
824
  }
1019
- ol, ul {
1020
- list-style: none;
1021
- }
1022
- table {
1023
- border-collapse: collapse;
1024
- border-spacing: 0;
1025
- }
1026
- strong {
1027
- font-weight: bolder;
1028
- }
825
+ ol, ul { list-style: none }
826
+ table { border-collapse: collapse }
1029
827
  sub, sup {
1030
- font-size: 0.75em;
828
+ font-size: .75em;
1031
829
  line-height: 0;
1032
830
  position: relative;
1033
- vertical-align: baseline;
1034
- }
1035
- sub {
1036
- bottom: -0.25em;
1037
- }
1038
- sup {
1039
- top: -0.5em;
1040
- }
1041
- [disabled] {
1042
- cursor: not-allowed;
1043
831
  }
1044
- [hidden] {
1045
- display: none;
1046
- }
1047
- [aria-disabled="true"] {
1048
- cursor: not-allowed;
1049
- }
1050
- `, ke = {
832
+ sub { bottom: -.25em }
833
+ sup { top: -.5em }
834
+ [disabled], [aria-disabled=true] { cursor: not-allowed }
835
+ [hidden] { display: none }
836
+ `, Ne = {
1051
837
  gray: {
1052
838
  50: "var(--color-gray-50, #f9fafb)",
1053
839
  100: "var(--color-gray-100, #f3f4f6)",
@@ -1060,6 +846,18 @@ const we = `
1060
846
  800: "var(--color-gray-800, #1f2937)",
1061
847
  900: "var(--color-gray-900, #111827)"
1062
848
  },
849
+ neutral: {
850
+ 50: "var(--color-neutral-50, #fafafa)",
851
+ 100: "var(--color-neutral-100, #f5f5f5)",
852
+ 200: "var(--color-neutral-200, #e5e5e5)",
853
+ 300: "var(--color-neutral-300, #d4d4d4)",
854
+ 400: "var(--color-neutral-400, #a3a3a3)",
855
+ 500: "var(--color-neutral-500, #737373)",
856
+ 600: "var(--color-neutral-600, #525252)",
857
+ 700: "var(--color-neutral-700, #404040)",
858
+ 800: "var(--color-neutral-800, #262626)",
859
+ 900: "var(--color-neutral-900, #171717)"
860
+ },
1063
861
  slate: {
1064
862
  50: "var(--color-slate-50, #f8fafc)",
1065
863
  100: "var(--color-slate-100, #f1f5f9)",
@@ -1170,7 +968,7 @@ const we = `
1170
968
  },
1171
969
  white: { DEFAULT: "var(--color-white, #ffffff)" },
1172
970
  black: { DEFAULT: "var(--color-black, #000000)" }
1173
- }, F = {
971
+ }, Q = {
1174
972
  /* Display */
1175
973
  block: "display:block;",
1176
974
  inline: "display:inline;",
@@ -1179,6 +977,26 @@ const we = `
1179
977
  "inline-flex": "display:inline-flex;",
1180
978
  grid: "display:grid;",
1181
979
  hidden: "display:none;",
980
+ /* Sizing & Spacing */
981
+ "w-full": "width:100%;",
982
+ "w-screen": "width:100dvw;",
983
+ "h-full": "height:100%;",
984
+ "h-screen": "height:100dvw;",
985
+ "max-w-full": "max-width:100%;",
986
+ "max-h-full": "max-height:100%;",
987
+ "min-w-0": "min-width:0;",
988
+ "min-h-0": "min-height:0;",
989
+ "m-auto": "margin:auto;",
990
+ "mx-auto": "margin-inline:auto;",
991
+ "my-auto": "margin-block:auto;",
992
+ /* Overflow */
993
+ "overflow-auto": "overflow:auto;",
994
+ "overflow-hidden": "overflow:hidden;",
995
+ "overflow-visible": "overflow:visible;",
996
+ "overflow-scroll": "overflow:scroll;",
997
+ /* Pointer Events */
998
+ "pointer-events-none": "pointer-events:none;",
999
+ "pointer-events-auto": "pointer-events:auto;",
1182
1000
  /* Accessibility */
1183
1001
  "sr-only": "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;",
1184
1002
  "not-sr-only": "position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip:auto;white-space:normal;",
@@ -1283,7 +1101,28 @@ const we = `
1283
1101
  "items-stretch": "align-items:stretch;",
1284
1102
  "justify-center": "justify-content:center;",
1285
1103
  "justify-start": "justify-content:flex-start;",
1104
+ "justify-between": "justify-content:space-between;",
1105
+ "justify-around": "justify-content:space-around;",
1106
+ "justify-evenly": "justify-content:space-evenly;",
1286
1107
  "justify-end": "justify-content:flex-end;",
1108
+ "flex-wrap": "flex-wrap:wrap;",
1109
+ "flex-nowrap": "flex-wrap:nowrap;",
1110
+ "flex-wrap-reverse": "flex-wrap:wrap-reverse;",
1111
+ "content-center": "align-content:center;",
1112
+ "content-start": "align-content:flex-start;",
1113
+ "content-end": "align-content:flex-end;",
1114
+ "content-between": "align-content:space-between;",
1115
+ "content-around": "align-content:space-around;",
1116
+ "content-stretch": "align-content:stretch;",
1117
+ "self-auto": "align-self:auto;",
1118
+ "self-start": "align-self:flex-start;",
1119
+ "self-end": "align-self:flex-end;",
1120
+ "self-center": "align-self:center;",
1121
+ "self-stretch": "align-self:stretch;",
1122
+ "flex-1": "flex:1 1 0%;",
1123
+ "flex-auto": "flex:1 1 auto;",
1124
+ "flex-initial": "flex:0 1 auto;",
1125
+ "flex-none": "flex:0 0 auto;",
1287
1126
  "flex-col": "flex-direction:column;",
1288
1127
  "flex-row": "flex-direction:row;",
1289
1128
  grow: "flex-grow:1;",
@@ -1303,7 +1142,7 @@ const we = `
1303
1142
  "transition-colors": "transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;",
1304
1143
  "transition-opacity": "transition-property:opacity;",
1305
1144
  "transition-transform": "transition-property:transform;"
1306
- }, _e = "0.25rem", ee = {
1145
+ }, Pe = "var(--spacing, 0.25rem)", le = {
1307
1146
  m: ["margin"],
1308
1147
  mx: ["margin-inline"],
1309
1148
  my: ["margin-block"],
@@ -1321,6 +1160,12 @@ const we = `
1321
1160
  inset: ["inset"],
1322
1161
  "inset-x": ["inset-inline"],
1323
1162
  "inset-y": ["inset-block"],
1163
+ h: ["height"],
1164
+ w: ["width"],
1165
+ "min-h": ["min-height"],
1166
+ "min-w": ["min-width"],
1167
+ "max-h": ["max-height"],
1168
+ "max-w": ["max-width"],
1324
1169
  top: ["top"],
1325
1170
  bottom: ["bottom"],
1326
1171
  left: ["left"],
@@ -1328,7 +1173,7 @@ const we = `
1328
1173
  gap: ["gap"],
1329
1174
  "gap-x": ["column-gap"],
1330
1175
  "gap-y": ["row-gap"]
1331
- }, $e = {
1176
+ }, Oe = {
1332
1177
  // State variants
1333
1178
  before: (e, t) => `${e}::before{${t}}`,
1334
1179
  after: (e, t) => `${e}::after{${t}}`,
@@ -1354,7 +1199,7 @@ const we = `
1354
1199
  "peer-focus": (e, t) => `.peer:focus ~ ${e}{${t}}`,
1355
1200
  "peer-checked": (e, t) => `.peer:checked ~ ${e}{${t}}`,
1356
1201
  "peer-disabled": (e, t) => `.peer:disabled ~ ${e}{${t}}`
1357
- }, te = {
1202
+ }, ce = {
1358
1203
  // Responsive
1359
1204
  sm: "(min-width:640px)",
1360
1205
  md: "(min-width:768px)",
@@ -1363,23 +1208,23 @@ const we = `
1363
1208
  "2xl": "(min-width:1536px)",
1364
1209
  // Dark mode (now plain string)
1365
1210
  dark: "(prefers-color-scheme: dark)"
1366
- }, V = ["sm", "md", "lg", "xl", "2xl"];
1367
- function U(e) {
1368
- const t = e.startsWith("-"), r = (t ? e.slice(1) : e).split("-");
1369
- if (r.length < 2) return null;
1370
- const i = r.slice(0, -1).join("-"), s = r[r.length - 1], o = parseFloat(s);
1371
- if (Number.isNaN(o) || !ee[i]) return null;
1372
- const l = t ? "-" : "";
1373
- return ee[i].map((f) => `${f}:calc(${l}${_e} * ${o});`).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("");
1374
1219
  }
1375
- function re(e) {
1376
- const t = e.replace("#", ""), n = parseInt(t, 16), r = n >> 16 & 255, i = n >> 8 & 255, s = n & 255;
1377
- return `${r} ${i} ${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}`;
1378
1223
  }
1379
- function Se(e) {
1224
+ function We(e) {
1380
1225
  const t = /^(bg|text|border|shadow|outline|caret|accent)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1381
1226
  if (!t) return null;
1382
- const [, n, r, i = "DEFAULT"] = t, s = ke[r]?.[i];
1227
+ const [, r, n, o = "DEFAULT"] = t, s = Ne[n]?.[o];
1383
1228
  return s ? `${{
1384
1229
  bg: "background-color",
1385
1230
  text: "color",
@@ -1388,43 +1233,43 @@ function Se(e) {
1388
1233
  outline: "outline-color",
1389
1234
  caret: "caret-color",
1390
1235
  accent: "accent-color"
1391
- }[n]}:${s};` : null;
1236
+ }[r]}:${s};` : null;
1392
1237
  }
1393
- function Ce(e) {
1394
- const [t, n] = e.split("/");
1395
- if (!n) return { base: t };
1396
- const r = parseInt(n, 10);
1397
- 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 };
1398
1243
  }
1399
- function q(e) {
1400
- const { base: t, opacity: n } = Ce(e), r = Se(t);
1401
- if (r) {
1402
- if (n !== void 0) {
1403
- 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);
1404
1249
  if (s) {
1405
- const o = re(s[0]);
1406
- return r.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${n})`);
1250
+ const i = fe(s[0]);
1251
+ return n.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${r})`);
1407
1252
  }
1408
1253
  }
1409
- return r;
1254
+ return n;
1410
1255
  }
1411
- const i = W(t);
1412
- if (i && n !== void 0) {
1413
- const s = /#([0-9a-f]{6})/i.exec(i);
1256
+ const o = V(t);
1257
+ if (o && r !== void 0) {
1258
+ const s = /#([0-9a-f]{6})/i.exec(o);
1414
1259
  if (s) {
1415
- const o = re(s[0]);
1416
- return i.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${n})`);
1260
+ const i = fe(s[0]);
1261
+ return o.replace(/#([0-9a-f]{6})/i, `rgb(${i} / ${r})`);
1417
1262
  }
1418
1263
  }
1419
- return i;
1264
+ return o;
1420
1265
  }
1421
- function W(e) {
1422
- const t = e.indexOf("-["), n = e.endsWith("]");
1423
- if (t > 0 && n) {
1424
- const r = e.slice(0, t);
1425
- let i = e.slice(t + 2, -1);
1426
- i = i.replace(/_/g, " ");
1427
- const o = {
1266
+ function V(e) {
1267
+ const t = e.indexOf("-["), r = e.endsWith("]");
1268
+ if (t > 0 && r) {
1269
+ const n = e.slice(0, t);
1270
+ let o = e.slice(t + 2, -1);
1271
+ o = o.replace(/_/g, " ");
1272
+ const i = {
1428
1273
  bg: "background-color",
1429
1274
  text: "color",
1430
1275
  p: "padding",
@@ -1463,108 +1308,145 @@ function W(e) {
1463
1308
  weight: "font-weight",
1464
1309
  leading: "line-height",
1465
1310
  z: "z-index"
1466
- }[r] ?? r.replace(/_/g, "-");
1467
- if (o && i) return `${o}:${i};`;
1311
+ }[n] ?? n.replace(/_/g, "-");
1312
+ if (i && o) return `${i}:${o};`;
1468
1313
  }
1469
1314
  return null;
1470
1315
  }
1471
- function Ae(e) {
1316
+ function He(e) {
1472
1317
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1473
1318
  }
1474
- function Ee(e) {
1475
- const t = /class\s*=\s*["']([^"']+)["']/g, n = [];
1476
- let r;
1477
- for (; r = t.exec(e); ) {
1478
- let i = "", s = !1;
1479
- for (const o of r[1])
1480
- o === "[" && (s = !0), o === "]" && (s = !1), o === " " && !s ? (i && n.push(i), i = "") : i += o;
1481
- i && n.push(i);
1482
- }
1483
- return n.filter(Boolean);
1319
+ function Ie(e) {
1320
+ const t = /class\s*=\s*["']([^"']+)["']/g, r = [];
1321
+ let n;
1322
+ for (; n = t.exec(e); ) {
1323
+ let o = "", s = !1;
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);
1327
+ }
1328
+ return r.filter(Boolean);
1484
1329
  }
1485
- const ne = /* @__PURE__ */ new Map(), Te = 16;
1486
- function je(e) {
1487
- const t = Date.now(), n = ne.get(e);
1488
- if (n && t - n.timestamp < Te) return n.css;
1489
- const r = Ee(e), i = new Set(r), s = [], o = [], l = [], f = [], u = {};
1490
- function p(h, S = !1) {
1491
- const m = (S ? "dark|" : "") + h;
1492
- if (m in u) return u[m];
1493
- const a = c(h, S);
1494
- return u[m] = a, a;
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;
1495
1340
  }
1496
1341
  function d(h) {
1497
- const S = h.some((a) => V.includes(a)), m = h.includes("dark");
1498
- return h.length === 0 ? 1 : !S && !m ? 2 : S && !m ? 3 : 4;
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;
1499
1344
  }
1500
- function c(h, S = !1) {
1501
- const m = h.split(":"), a = m.find(
1502
- (_) => F[_] || U(_) || q(_) || W(_)
1345
+ function u(h, C = !1) {
1346
+ const y = h.split(":"), c = y.find(
1347
+ ($) => Q[$] || X($) || Y($) || V($)
1503
1348
  );
1504
- if (!a) return null;
1505
- 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);
1506
1351
  if (!b) return null;
1507
- let g = `.${Ae(h)}`, x = b;
1508
- const w = m.indexOf(a);
1509
- let k = w >= 0 ? m.slice(0, w) : [];
1510
- S && (k = k.filter((_) => _ !== "dark"));
1511
- const $ = k.filter((_) => V.includes(_)), C = $.length ? $[$.length - 1] : null;
1512
- for (const _ of k) {
1513
- if (V.includes(_)) continue;
1514
- const A = $e[_];
1515
- typeof A == "function" && (g = A(g, x).replace(/\{.*$/, ""));
1352
+ let g = `.${He(h)}`, v = b;
1353
+ const w = y.indexOf(c);
1354
+ let k = w >= 0 ? y.slice(0, w) : [];
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(/\{.*$/, ""));
1516
1361
  }
1517
- let v = `${g}{${x}}`;
1518
- 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;
1519
1364
  }
1520
- for (const h of i) {
1521
- const S = h.split(":"), m = S.find(
1522
- (x) => F[x] || U(x) || q(x) || W(x)
1365
+ for (const h of o) {
1366
+ const C = h.split(":"), y = C.find(
1367
+ (v) => Q[v] || X(v) || Y(v) || V(v)
1523
1368
  );
1524
- if (!m) continue;
1525
- const a = S.indexOf(m), b = a >= 0 ? S.slice(0, a) : [], g = d(b);
1369
+ if (!y) continue;
1370
+ const c = C.indexOf(y), b = c >= 0 ? C.slice(0, c) : [], g = d(b);
1526
1371
  if (g === 4) {
1527
- const x = p(h, !0);
1528
- x && f.push(x);
1372
+ const v = p(h, !0);
1373
+ v && l.push(v);
1529
1374
  } else {
1530
- const x = p(h);
1531
- x && (g === 1 ? s.push(x) : g === 2 ? o.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));
1532
1377
  }
1533
1378
  }
1534
- const y = [...s, ...o, ...l, ...f].join("");
1535
- return ne.set(e, { css: y, timestamp: t }), y;
1379
+ const m = [...s, ...i, ...a, ...l].join("");
1380
+ return ue.set(e, { css: m, timestamp: t }), m;
1536
1381
  }
1537
- const Le = /* @__PURE__ */ new Map();
1538
- function Q(e) {
1539
- 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);
1540
1402
  }
1541
- function J(e) {
1542
- return typeof e == "string" ? e.replace(
1543
- /[&<>"']/g,
1544
- (t) => ({
1545
- "&": "&amp;",
1546
- "<": "&lt;",
1547
- ">": "&gt;",
1548
- '"': "&quot;",
1549
- "'": "&#39;"
1550
- })[t]
1551
- ) : 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));
1552
1410
  }
1553
- function He(e, ...t) {
1554
- let n = "";
1555
- for (let r = 0; r < e.length; r++)
1556
- n += e[r], r < t.length && (n += t[r]);
1557
- 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);
1558
1423
  }
1559
- function Ie(e, t, n) {
1560
- let r = Q(e);
1561
- r.includes("-") || (r = `cer-${r}`);
1562
- let i;
1563
- typeof t == "function" ? i = { ...n, render: t } : i = t, typeof i.onError != "function" && (i.onError = (s, o) => {
1564
- console.error(`[${r}] Error:`, s, o);
1565
- }), Le.set(r, i), typeof window < "u" && !customElements.get(r) && customElements.define(r, ze(i));
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}`);
1444
+ let 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));
1566
1448
  }
1567
- function ze(e) {
1449
+ function Qe(e) {
1568
1450
  if (!e.render)
1569
1451
  throw new Error(
1570
1452
  "Component must have a render function"
@@ -1584,6 +1466,24 @@ function ze(e) {
1584
1466
  _initializing = !0;
1585
1467
  _styleSheet = null;
1586
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
+ }
1587
1487
  _cfg;
1588
1488
  _lastRenderTime = 0;
1589
1489
  _renderCount = 0;
@@ -1596,43 +1496,98 @@ function ze(e) {
1596
1496
  value: this._refs,
1597
1497
  writable: !1,
1598
1498
  enumerable: !1,
1599
- // Hide from iteration to avoid proxy traps
1600
1499
  configurable: !1
1601
- }), this.context = t, Object.keys(e).forEach((n) => {
1602
- const r = e[n];
1603
- typeof r == "function" && !n.startsWith("on") && (this.context[n] = (...i) => r(...i, this.context));
1604
- }), this._applyProps(e), this._applyComputed(e), this._initializing = !1, this._initWatchers(e), this._render(e);
1500
+ }), Object.defineProperty(t, "requestRender", {
1501
+ value: () => this.requestRender(),
1502
+ writable: !1,
1503
+ enumerable: !1,
1504
+ configurable: !1
1505
+ }), this.context = t, this._applyProps(e), Object.defineProperty(this.context, "emit", {
1506
+ value: (r, n, o) => {
1507
+ this.dispatchEvent(
1508
+ new CustomEvent(r, {
1509
+ detail: n,
1510
+ bubbles: !0,
1511
+ composed: !0,
1512
+ ...o || {}
1513
+ })
1514
+ );
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);
1517
+ },
1518
+ writable: !1,
1519
+ enumerable: !1,
1520
+ configurable: !1
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);
1527
+ this.addEventListener(o, (s) => {
1528
+ const i = typeof this[r] == "function" ? this[r] : this.context[r];
1529
+ typeof i == "function" && i(s.detail, this.context);
1530
+ });
1531
+ }
1532
+ }), this._applyComputed(e), this._initializing = !1, this._initWatchers(e), this._render(e);
1605
1533
  }
1606
1534
  connectedCallback() {
1607
1535
  this._runLogicWithinErrorBoundary(e, () => {
1608
- 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
+ );
1609
1544
  });
1610
1545
  }
1611
1546
  disconnectedCallback() {
1612
1547
  this._runLogicWithinErrorBoundary(e, () => {
1613
- 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
+ );
1614
1568
  });
1615
1569
  }
1616
- attributeChangedCallback(t, n, r) {
1570
+ attributeChangedCallback(t, r, n) {
1617
1571
  this._runLogicWithinErrorBoundary(e, () => {
1618
- this._applyProps(e), e.onAttributeChanged && e.onAttributeChanged(
1572
+ this._applyProps(e), Se(
1573
+ e,
1619
1574
  t,
1620
- n,
1621
1575
  r,
1576
+ n,
1622
1577
  this.context
1623
1578
  );
1624
1579
  });
1625
1580
  }
1626
1581
  static get observedAttributes() {
1627
- return e.props ? Object.keys(e.props).map(Q) : [];
1582
+ return e.props ? Object.keys(e.props).map(ne) : [];
1628
1583
  }
1629
1584
  _applyComputed(t) {
1630
1585
  this._runLogicWithinErrorBoundary(e, () => {
1631
- t.computed && Object.entries(t.computed).forEach(([n, r]) => {
1632
- Object.defineProperty(this.context, n, {
1586
+ t.computed && Object.entries(t.computed).forEach(([r, n]) => {
1587
+ Object.defineProperty(this.context, r, {
1633
1588
  get: () => {
1634
- const i = r(this.context);
1635
- return J(i);
1589
+ const o = n(this.context);
1590
+ return ee(o);
1636
1591
  },
1637
1592
  enumerable: !0
1638
1593
  });
@@ -1642,90 +1597,69 @@ function ze(e) {
1642
1597
  // --- Render ---
1643
1598
  _render(t) {
1644
1599
  this._runLogicWithinErrorBoundary(t, () => {
1645
- if (!this.shadowRoot) return;
1646
- if (this._templateLoading && t.loadingTemplate) {
1647
- this._renderOutput(t.loadingTemplate(this.context));
1648
- return;
1649
- }
1650
- if (this._templateError && t.errorTemplate) {
1651
- this._renderOutput(t.errorTemplate(this._templateError, this.context));
1652
- return;
1653
- }
1654
- const n = t.render(this.context);
1655
- if (n instanceof Promise) {
1656
- this._templateLoading = !0, n.then((r) => (this._templateLoading = !1, this._templateError = null, this._renderOutput(r), r)).catch((r) => {
1657
- if (this._templateLoading = !1, this._templateError = r, t.errorTemplate) {
1658
- const i = t.errorTemplate(r, this.context);
1659
- return this._renderOutput(i), i;
1660
- }
1661
- throw r;
1662
- }), t.loadingTemplate && this._renderOutput(t.loadingTemplate(this.context));
1663
- return;
1664
- }
1665
- 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
+ );
1666
1616
  });
1667
1617
  }
1668
- // --- Helper to render output ---
1669
- _renderOutput(t) {
1670
- if (!this.shadowRoot) return;
1671
- const n = new Proxy(this.context, {
1672
- get: (r, i) => i === "_requestRender" ? () => this._requestRender() : i === "context" ? r : typeof i == "string" && i.includes(".") ? i.split(".").reduce((s, o) => s?.[o], r) : r[i],
1673
- set: (r, i, s) => {
1674
- if (typeof i == "string" && i.includes(".")) {
1675
- const o = i.split("."), l = o.pop();
1676
- if (!l) return !1;
1677
- const f = o.reduce((u, p) => (p in u || (u[p] = {}), u[p]), r);
1678
- return f[l] = s, !0;
1679
- }
1680
- return r[i] = s, !0;
1681
- }
1682
- });
1683
- xe(
1684
- this.shadowRoot,
1685
- Array.isArray(t) ? t : [t],
1686
- n,
1687
- this._refs
1688
- ), this._lastHtmlStringForJitCSS = this.shadowRoot.innerHTML;
1618
+ requestRender() {
1619
+ this._requestRender();
1689
1620
  }
1690
1621
  _requestRender() {
1691
- if (this._renderTimeoutId !== null && clearTimeout(this._renderTimeoutId), Date.now() - this._lastRenderTime < 16) {
1692
- if (this._renderCount++, this._renderCount > 10) {
1693
- console.warn(
1694
- `[${this.tagName}] Potential infinite render loop detected. Skipping render.`
1695
- ), this._renderTimeoutId = null;
1696
- return;
1697
- }
1698
- } else
1699
- this._renderCount = 0;
1700
- this._renderTimeoutId = setTimeout(() => {
1701
- this._lastRenderTime = Date.now(), this._render(this._cfg), this._renderTimeoutId = null;
1702
- }, 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
+ });
1703
1639
  }
1704
1640
  // --- Style ---
1705
- _applyStyle(t) {
1641
+ _applyStyle(t, r) {
1706
1642
  this._runLogicWithinErrorBoundary(t, () => {
1707
- if (!this.shadowRoot) return;
1708
- const n = je(this._lastHtmlStringForJitCSS);
1709
- if (!t.style && (!n || n.trim() === "")) {
1710
- this._styleSheet = null, this.shadowRoot.adoptedStyleSheets = [G()];
1711
- return;
1712
- }
1713
- let r = "";
1714
- t.style && (typeof t.style == "string" ? r = t.style : typeof t.style == "function" && (r = t.style(this.context)));
1715
- let i = ve(`${r}
1716
- ${n}
1717
- `);
1718
- i = oe(i), this._styleSheet || (this._styleSheet = new CSSStyleSheet()), (this._styleSheet.cssRules.length === 0 || this._styleSheet.toString() !== i) && this._styleSheet.replaceSync(i), 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
+ );
1719
1653
  });
1720
1654
  }
1721
1655
  // --- Error Boundary function ---
1722
- _runLogicWithinErrorBoundary(t, n) {
1656
+ _runLogicWithinErrorBoundary(t, r) {
1723
1657
  this._hasError && (this._hasError = !1);
1724
1658
  try {
1725
- n();
1726
- } catch (r) {
1727
- this._hasError = !0, t.onError && t.onError(r, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1728
- 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,
1729
1663
  this.context
1730
1664
  ));
1731
1665
  }
@@ -1733,11 +1667,11 @@ ${n}
1733
1667
  // --- State, props, computed ---
1734
1668
  _initContext(t) {
1735
1669
  try {
1736
- let n = function(i, s = "") {
1737
- return Array.isArray(i) ? new Proxy(i, {
1738
- get(o, l, f) {
1739
- const u = Reflect.get(o, l, f);
1740
- return typeof u == "function" && typeof l == "string" && [
1670
+ let r = function(o, s = "") {
1671
+ return Array.isArray(o) ? new Proxy(o, {
1672
+ get(i, a, l) {
1673
+ const f = Reflect.get(i, a, l);
1674
+ return typeof f == "function" && typeof a == "string" && [
1741
1675
  "push",
1742
1676
  "pop",
1743
1677
  "shift",
@@ -1745,128 +1679,477 @@ ${n}
1745
1679
  "splice",
1746
1680
  "sort",
1747
1681
  "reverse"
1748
- ].includes(l) ? function(...d) {
1749
- const c = u.apply(o, d);
1750
- if (!r._initializing) {
1751
- const y = s || "root";
1752
- r._triggerWatchers(y, o), r._render(t);
1682
+ ].includes(a) ? function(...d) {
1683
+ const u = f.apply(i, d);
1684
+ if (!n._initializing) {
1685
+ const m = s || "root";
1686
+ n._triggerWatchers(m, i), n._render(t);
1753
1687
  }
1754
- return c;
1755
- } : u;
1688
+ return u;
1689
+ } : f;
1756
1690
  },
1757
- set(o, l, f) {
1758
- if (o[l] = f, !r._initializing) {
1759
- const u = s ? `${s}.${String(l)}` : String(l);
1760
- r._triggerWatchers(u, f), 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);
1761
1695
  }
1762
1696
  return !0;
1763
1697
  },
1764
- deleteProperty(o, l) {
1765
- if (delete o[l], !r._initializing) {
1766
- const f = s ? `${s}.${String(l)}` : String(l);
1767
- r._triggerWatchers(f, 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);
1768
1702
  }
1769
1703
  return !0;
1770
1704
  }
1771
- }) : i && typeof i == "object" ? (Object.keys(i).forEach((o) => {
1772
- const l = s ? `${s}.${o}` : o;
1773
- i[o] = n(i[o], l);
1774
- }), new Proxy(i, {
1775
- set(o, l, f) {
1776
- const u = s ? `${s}.${String(l)}` : String(l);
1777
- return o[l] = n(f, u), r._initializing || (r._triggerWatchers(
1778
- u,
1779
- o[l]
1780
- ), r._render(t)), !0;
1705
+ }) : o && typeof o == "object" ? (Object.keys(o).forEach((i) => {
1706
+ const a = s ? `${s}.${i}` : i;
1707
+ o[i] = r(o[i], a);
1708
+ }), new Proxy(o, {
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;
1781
1715
  },
1782
- get(o, l, f) {
1783
- return Reflect.get(o, l, f);
1716
+ get(i, a, l) {
1717
+ return Reflect.get(i, a, l);
1784
1718
  }
1785
- })) : i;
1719
+ })) : o;
1786
1720
  };
1787
- const r = this;
1788
- return n({ ...t.state });
1721
+ const n = this;
1722
+ return r({ ...t.state });
1789
1723
  } catch {
1790
1724
  return {};
1791
1725
  }
1792
1726
  }
1793
1727
  _initWatchers(t) {
1794
- if (t.watch)
1795
- for (const [n, r] of Object.entries(t.watch)) {
1796
- let i, s = {};
1797
- if (Array.isArray(r) ? (i = r[0], s = r[1] || {}) : i = r, this._watchers.set(n, {
1798
- callback: i,
1799
- options: s,
1800
- oldValue: this._getNestedValue(n)
1801
- }), s.immediate)
1802
- try {
1803
- const o = this._getNestedValue(n);
1804
- i(o, void 0, this.context);
1805
- } catch (o) {
1806
- console.error(`Error in immediate watcher for "${n}":`, o);
1807
- }
1808
- }
1728
+ this._runLogicWithinErrorBoundary(t, () => {
1729
+ xe(
1730
+ this.context,
1731
+ this._watchers,
1732
+ t.watch || {}
1733
+ );
1734
+ });
1809
1735
  }
1810
- _getNestedValue(t) {
1811
- return t.split(".").reduce(
1812
- (n, r) => n?.[r],
1813
- this.context
1814
- );
1736
+ _triggerWatchers(t, r) {
1737
+ we(this.context, this._watchers, t, r);
1815
1738
  }
1816
- _triggerWatchers(t, n) {
1817
- const r = (s, o) => {
1818
- if (s === o) return !0;
1819
- if (typeof s != typeof o || typeof s != "object" || s === null || o === null) return !1;
1820
- if (Array.isArray(s) && Array.isArray(o))
1821
- return s.length !== o.length ? !1 : s.every((u, p) => r(u, o[p]));
1822
- const l = Object.keys(s), f = Object.keys(o);
1823
- return l.length !== f.length ? !1 : l.every((u) => r(s[u], o[u]));
1824
- }, i = this._watchers.get(t);
1825
- if (i && !r(n, i.oldValue))
1739
+ _applyProps(t) {
1740
+ this._runLogicWithinErrorBoundary(t, () => {
1826
1741
  try {
1827
- i.callback(n, i.oldValue, this.context), i.oldValue = n;
1828
- } catch (s) {
1829
- 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));
1830
1745
  }
1831
- for (const [s, o] of this._watchers.entries())
1832
- if (o.options.deep && t.startsWith(s + "."))
1833
- try {
1834
- const l = this._getNestedValue(s);
1835
- r(l, o.oldValue) || (o.callback(l, o.oldValue, this.context), o.oldValue = l);
1836
- } catch (l) {
1837
- console.error(`Error in deep watcher for "${s}":`, l);
1838
- }
1746
+ });
1839
1747
  }
1840
- _applyProps(t) {
1841
- try {
1842
- let n = function(r, i) {
1843
- return i === Boolean ? r === "true" : i === Number ? Number(r) : r;
1844
- };
1845
- if (!t.props) return;
1846
- Object.entries(t.props).forEach(([r, i]) => {
1847
- const s = this.getAttribute(Q(r));
1848
- s !== null ? this.context[r] = J(
1849
- n(s, i.type)
1850
- ) : "default" in i && i.default !== void 0 && (this.context[r] = J(i.default));
1851
- });
1852
- } catch (n) {
1853
- this._hasError = !0, t.onError && t.onError(n, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1854
- n,
1855
- this.context
1856
- ));
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);
1857
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;
1858
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 ? ";" : "");
1931
+ }
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
+ }
1967
+ }
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
1859
2054
  };
1860
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
+ }
1861
2133
  export {
1862
- Ie as component,
1863
- ze as createElementClass,
1864
- Re as createStore,
1865
- He as css,
1866
- Ne as each,
1867
- Be as eventBus,
1868
- Me as html,
1869
- Pe as match,
1870
- Oe 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
1871
2154
  };
1872
2155
  //# sourceMappingURL=custom-elements-runtime.es.js.map