@jasonshimmy/custom-elements-runtime 0.0.17 → 0.1.1

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,20 @@
1
- function ze(e) {
1
+ function Re(e) {
2
2
  let t = new Proxy(e, {
3
- set: (o, c, d) => (o[c] = d, s(), !0)
3
+ set: (o, l, f) => (o[l] = f, s(), !0)
4
4
  });
5
- const r = [];
6
- function n(o) {
7
- r.push(o), o(t);
5
+ const n = [];
6
+ function r(o) {
7
+ n.push(o), o(t);
8
8
  }
9
9
  function i() {
10
10
  return t;
11
11
  }
12
12
  function s() {
13
- r.forEach((o) => o(t));
13
+ n.forEach((o) => o(t));
14
14
  }
15
- return { subscribe: n, getState: i };
15
+ return { subscribe: r, getState: i };
16
16
  }
17
- class R extends EventTarget {
17
+ class B extends EventTarget {
18
18
  handlers = {};
19
19
  static instance;
20
20
  eventCounters = /* @__PURE__ */ new Map();
@@ -22,7 +22,7 @@ class R extends EventTarget {
22
22
  * Returns the singleton instance of GlobalEventBus
23
23
  */
24
24
  static getInstance() {
25
- return R.instance || (R.instance = new R()), R.instance;
25
+ return B.instance || (B.instance = new B()), B.instance;
26
26
  }
27
27
  // Enhanced emit method with better typing and event storm protection
28
28
  /**
@@ -30,16 +30,16 @@ class R extends EventTarget {
30
30
  * @param eventName - Name of the event
31
31
  * @param data - Optional event payload
32
32
  */
33
- emit(t, r) {
34
- const n = Date.now(), i = this.eventCounters.get(t);
35
- if (!i || n - i.window > 1e3)
36
- this.eventCounters.set(t, { count: 1, window: n });
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
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)) {
38
38
  console.warn(`Blocking further "${t}" events to prevent infinite loop`);
39
39
  return;
40
40
  }
41
41
  this.dispatchEvent(new CustomEvent(t, {
42
- detail: r,
42
+ detail: n,
43
43
  bubbles: !1,
44
44
  // Global events don't need to bubble
45
45
  cancelable: !0
@@ -47,9 +47,9 @@ class R extends EventTarget {
47
47
  const s = this.handlers[t];
48
48
  s && s.forEach((o) => {
49
49
  try {
50
- o(r);
51
- } catch (c) {
52
- console.error(`Error in global event handler for "${t}":`, c);
50
+ o(n);
51
+ } catch (l) {
52
+ console.error(`Error in global event handler for "${t}":`, l);
53
53
  }
54
54
  });
55
55
  }
@@ -58,17 +58,17 @@ class R extends EventTarget {
58
58
  * @param eventName - Name of the event
59
59
  * @param handler - Handler function
60
60
  */
61
- on(t, r) {
62
- return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(r), () => this.off(t, r);
61
+ on(t, n) {
62
+ return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(n), () => this.off(t, n);
63
63
  }
64
64
  /**
65
65
  * Remove a specific handler for a global event.
66
66
  * @param eventName - Name of the event
67
67
  * @param handler - Handler function to remove
68
68
  */
69
- off(t, r) {
70
- const n = this.handlers[t];
71
- n && n.delete(r);
69
+ off(t, n) {
70
+ const r = this.handlers[t];
71
+ r && r.delete(n);
72
72
  }
73
73
  /**
74
74
  * Remove all handlers for a specific event.
@@ -83,18 +83,18 @@ class R extends EventTarget {
83
83
  * @param handler - CustomEvent handler
84
84
  * @param options - AddEventListener options
85
85
  */
86
- listen(t, r, n) {
87
- return this.addEventListener(t, r, n), () => this.removeEventListener(t, r);
86
+ listen(t, n, r) {
87
+ return this.addEventListener(t, n, r), () => this.removeEventListener(t, n);
88
88
  }
89
89
  /**
90
90
  * Register a one-time event handler. Returns a promise that resolves with the event data.
91
91
  * @param eventName - Name of the event
92
92
  * @param handler - Handler function
93
93
  */
94
- once(t, r) {
95
- return new Promise((n) => {
94
+ once(t, n) {
95
+ return new Promise((r) => {
96
96
  const i = this.on(t, (s) => {
97
- i(), r(s), n(s);
97
+ i(), n(s), r(s);
98
98
  });
99
99
  });
100
100
  }
@@ -124,10 +124,10 @@ class R extends EventTarget {
124
124
  */
125
125
  getEventStats() {
126
126
  const t = {};
127
- for (const [r, n] of this.eventCounters.entries())
128
- t[r] = {
129
- count: n.count,
130
- handlersCount: this.getHandlerCount(r)
127
+ for (const [n, r] of this.eventCounters.entries())
128
+ t[n] = {
129
+ count: r.count,
130
+ handlersCount: this.getHandlerCount(n)
131
131
  };
132
132
  return t;
133
133
  }
@@ -138,127 +138,126 @@ class R extends EventTarget {
138
138
  this.eventCounters.clear();
139
139
  }
140
140
  }
141
- const Re = R.getInstance();
142
- function P(e, t = {}, r, n) {
143
- const i = n ?? t.key;
144
- return { tag: e, key: i, props: t, children: r };
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
145
  }
146
146
  function I(e) {
147
147
  return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
148
148
  }
149
- function z(e) {
149
+ function R(e) {
150
150
  return typeof e == "object" && e !== null && "tag" in e && !I(e);
151
151
  }
152
152
  function le(e, t) {
153
153
  return e.key != null ? e : { ...e, key: t };
154
154
  }
155
- function ce(e, t = [], r = {}) {
156
- const n = {}, i = {}, s = {}, o = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
157
- let c;
158
- for (; c = o.exec(e); ) {
159
- const d = c[1], a = c[2], u = (c[4] || c[6]) ?? "", y = u.match(/^{{(\d+)}}$/);
160
- let f = y ? t[Number(y[1])] ?? null : u;
161
- if (y || (f === "true" ? f = !0 : f === "false" ? f = !1 : f === "null" ? f = null : isNaN(Number(f)) || (f = Number(f))), d === ":")
162
- typeof f == "boolean" ? i[a] = f : f != null && (n[a] = f);
163
- else if (d === "@") {
164
- const w = "on" + a.charAt(0).toUpperCase() + a.slice(1);
165
- n[w] = typeof f == "function" ? f : typeof r[f] == "function" ? r[f] : void 0;
166
- } else if (d === "#") {
167
- const [w, ...p] = a.split("."), S = [...p];
168
- let g = f, l = [...S];
169
- if (w === "model" && typeof g == "string" && g.includes(".")) {
170
- const b = ["trim", "number", "lazy"], m = g.split(".");
171
- let h = g;
172
- const x = [];
173
- for (let C = m.length - 1; C > 0 && b.includes(m[C]); C--)
174
- x.unshift(m[C]), h = m.slice(0, C).join(".");
175
- g = h, l.push(...x);
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
176
  }
177
- s[w] = {
178
- value: g,
179
- modifiers: l
177
+ s[y] = {
178
+ value: m,
179
+ modifiers: a
180
180
  };
181
- } else
182
- i[a] = f;
181
+ } else u === "ref" ? r.ref = c : i[u] = c;
183
182
  }
184
- return { props: n, attrs: i, directives: s };
183
+ return { props: r, attrs: i, directives: s };
185
184
  }
186
- function fe(e, t, r) {
187
- function n(l, b) {
188
- return P("#text", {}, l, b);
185
+ function fe(e, t, n) {
186
+ function r(a, b) {
187
+ return P("#text", {}, a, b);
189
188
  }
190
189
  let i = "";
191
- for (let l = 0; l < e.length; l++)
192
- i += e[l], l < t.length && (i += `{{${l}}}`);
190
+ for (let a = 0; a < e.length; a++)
191
+ i += e[a], a < t.length && (i += `{{${a}}}`);
193
192
  const s = /<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g, o = [];
194
- let c = null, d, a = [], u = null, y = {}, f, w = 0, p = [];
195
- function S(l) {
196
- !l || typeof l != "object" || I(l) || (l.props || l.attrs ? (l.props && (y.props || (y.props = {}), Object.assign(y.props, l.props)), l.attrs && (y.attrs || (y.attrs = {}), Object.keys(l.attrs).forEach((b) => {
197
- if (b === "style" && y.attrs.style) {
198
- const m = y.attrs.style.replace(
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(
199
198
  /;?\s*$/,
200
199
  ""
201
- ), h = l.attrs.style.replace(/^;?\s*/, "");
202
- y.attrs.style = m + "; " + h;
203
- } else if (b === "class" && y.attrs.class) {
204
- const m = y.attrs.class.trim().split(/\s+/).filter(Boolean), h = l.attrs.class.trim().split(/\s+/).filter(Boolean), x = [
205
- .../* @__PURE__ */ new Set([...m, ...h])
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])
206
205
  ];
207
- y.attrs.class = x.join(" ");
206
+ d.attrs.class = w.join(" ");
208
207
  } else
209
- y.attrs[b] = l.attrs[b];
210
- }))) : (y.props || (y.props = {}), Object.assign(y.props, l)));
211
- }
212
- function g(l, b) {
213
- const m = u ? a : p;
214
- if (I(l)) {
215
- const h = l.key ?? b;
216
- let x = l.children;
217
- m.push({
218
- ...l,
219
- key: h,
220
- children: x
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
221
220
  });
222
221
  return;
223
222
  }
224
- if (z(l)) {
225
- m.push(le(l, void 0));
223
+ if (R(a)) {
224
+ g.push(le(a, void 0));
226
225
  return;
227
226
  }
228
- if (Array.isArray(l)) {
229
- if (l.length === 0) return;
230
- for (let h = 0; h < l.length; h++) {
231
- const x = l[h];
232
- I(x) || z(x) || Array.isArray(x) ? g(x, `${b}-${h}`) : x !== null && typeof x == "object" ? S(x) : m.push(n(String(x), `${b}-${h}`));
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}`));
233
232
  }
234
233
  return;
235
234
  }
236
- if (l !== null && typeof l == "object") {
237
- S(l);
235
+ if (a !== null && typeof a == "object") {
236
+ S(a);
238
237
  return;
239
238
  }
240
- m.push(n(String(l), b));
241
- }
242
- for (; d = s.exec(i); )
243
- if (d[1]) {
244
- const l = d[1], b = d[0][1] === "/", m = d[0][d[0].length - 2] === "/", {
245
- props: h,
246
- attrs: x,
247
- directives: C
248
- } = ce(d[2] || "", t, r), k = { props: {}, attrs: {} };
249
- for (const _ in h) k.props[_] = h[_];
250
- for (const _ in x) k.attrs[_] = x[_];
251
- for (const [_, $] of Object.entries(C))
252
- if (_ === "bind")
253
- if (typeof $.value == "object" && $.value !== null)
254
- for (const [A, E] of Object.entries($.value))
255
- typeof E == "boolean" ? k.attrs[A] = E : E != null && (k.attrs[A] = String(E));
256
- else $.value != null && (k.attrs[_] = String($.value));
257
- else if (_ === "show") {
258
- const A = !!$.value;
259
- k.attrs.style = (k.attrs.style || "") + (A ? "" : "; display: none !important");
260
- } else if (_ === "class") {
261
- const A = $.value;
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;
262
261
  let E = [];
263
262
  if (typeof A == "string")
264
263
  E = A.split(/\s+/).filter(Boolean);
@@ -267,20 +266,20 @@ function fe(e, t, r) {
267
266
  if (typeof j == "string")
268
267
  E.push(...j.split(/\s+/).filter(Boolean));
269
268
  else if (j && typeof j == "object")
270
- for (const [L, M] of Object.entries(j))
271
- M && E.push(...L.split(/\s+/).filter(Boolean));
269
+ for (const [L, N] of Object.entries(j))
270
+ N && E.push(...L.split(/\s+/).filter(Boolean));
272
271
  } else if (A && typeof A == "object")
273
272
  for (const [j, L] of Object.entries(A))
274
273
  L && E.push(...j.split(/\s+/).filter(Boolean));
275
- const B = k.attrs.class || "", O = [
274
+ const M = $.attrs.class || "", O = [
276
275
  .../* @__PURE__ */ new Set([
277
- ...B.split(/\s+/).filter(Boolean),
276
+ ...M.split(/\s+/).filter(Boolean),
278
277
  ...E
279
278
  ])
280
279
  ];
281
- k.attrs.class = O.join(" ");
282
- } else if (_ === "style") {
283
- const A = $.value;
280
+ $.attrs.class = O.join(" ");
281
+ } else if (v === "style") {
282
+ const A = _.value;
284
283
  let E = "";
285
284
  if (typeof A == "string")
286
285
  E = A;
@@ -288,7 +287,7 @@ function fe(e, t, r) {
288
287
  const O = [];
289
288
  for (const [j, L] of Object.entries(A))
290
289
  if (L != null && L !== "") {
291
- const M = j.replace(
290
+ const N = j.replace(
292
291
  /[A-Z]/g,
293
292
  (ae) => `-${ae.toLowerCase()}`
294
293
  ), se = [
@@ -318,78 +317,78 @@ function fe(e, t, r) {
318
317
  "max-height"
319
318
  ];
320
319
  let X = String(L);
321
- typeof L == "number" && se.includes(M) && (X = `${L}px`), O.push(`${M}: ${X}`);
320
+ typeof L == "number" && se.includes(N) && (X = `${L}px`), O.push(`${N}: ${X}`);
322
321
  }
323
322
  E = O.join("; ") + (O.length > 0 ? ";" : "");
324
323
  }
325
- const B = k.attrs.style || "";
326
- k.attrs.style = B + (B && !B.endsWith(";") ? "; " : "") + E;
324
+ const M = $.attrs.style || "";
325
+ $.attrs.style = M + (M && !M.endsWith(";") ? "; " : "") + E;
327
326
  }
328
- const v = {};
329
- for (const [_, $] of Object.entries(C))
330
- ["bind", "show", "class", "style"].includes(_) || (v[_] = $);
331
- if (Object.keys(v).length > 0 && (k.directives = v), b) {
332
- const _ = P(
333
- u,
334
- y,
335
- a.length === 1 && z(a[0]) && a[0].tag === "#text" ? typeof a[0].children == "string" ? a[0].children : "" : a.length ? a : void 0,
336
- f
337
- ), $ = o.pop();
338
- $ ? (u = $.tag, y = $.props, f = $.key, a = $.children, a.push(_)) : c = _;
339
- } else m ? (u ? a : p).push(P(l, k, void 0, void 0)) : (u && o.push({
340
- tag: u,
341
- props: y,
342
- children: a,
343
- key: f
344
- }), u = l, y = k, a = []);
345
- } else if (typeof d[3] < "u") {
346
- const l = Number(d[3]), b = t[l], m = `interp-${l}`;
347
- g(b, m);
348
- } else if (d[4]) {
349
- const l = d[4], b = u ? a : p, m = l.split(/({{\d+}})/);
350
- for (const h of m) {
351
- if (!h) continue;
352
- const x = h.match(/^{{(\d+)}}$/);
353
- if (x) {
354
- const C = Number(x[1]), k = t[C], v = `interp-${C}`;
355
- g(k, v);
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);
356
355
  } else {
357
- const C = `text-${w++}`;
358
- b.push(n(h, C));
356
+ const k = `text-${y++}`;
357
+ b.push(r(x, k));
359
358
  }
360
359
  }
361
360
  }
362
- if (c)
363
- return z(c) && Array.isArray(c.children) && (c.children = c.children.filter(
364
- (l) => z(l) ? l.tag !== "#text" || typeof l.children == "string" && l.children.trim() !== "" : !0
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
365
364
  // keep non-element VNodes (including anchors) as-is
366
- )), c;
367
- if (p.length > 0) {
368
- const l = p.filter(
369
- (b) => z(b) ? b.tag !== "#text" || typeof b.children == "string" && b.children.trim() !== "" : !0
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
370
369
  );
371
- return l.length === 1 ? l[0] : l;
370
+ return a.length === 1 ? a[0] : a;
372
371
  }
373
372
  return P("div", {}, "", "fallback-root");
374
373
  }
375
- function Be(e, ...t) {
376
- const r = t[t.length - 1], n = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
377
- return fe(e, t, n);
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);
378
377
  }
379
378
  function Oe(e, t) {
380
- return W(e ? t : [], "when-block");
379
+ return K(e ? t : [], "when-block");
381
380
  }
382
- function Me(e, t) {
383
- return e.map((r, n) => {
384
- const i = typeof r == "object" ? r?.key ?? r?.id ?? `idx-${n}` : String(r);
385
- return W(t(r, n), `each-${i}`);
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}`);
386
385
  });
387
386
  }
388
387
  function Pe() {
389
388
  const e = [];
390
389
  return {
391
- when(t, r) {
392
- return e.push([t, r]), this;
390
+ when(t, n) {
391
+ return e.push([t, n]), this;
393
392
  },
394
393
  otherwise(t) {
395
394
  return e.push([!0, t]), this;
@@ -401,175 +400,175 @@ function Pe() {
401
400
  }
402
401
  function de(...e) {
403
402
  for (let t = 0; t < e.length; t++) {
404
- const [r, n] = e[t];
405
- if (r) return [W(n, `whenChain-branch-${t}`)];
403
+ const [n, r] = e[t];
404
+ if (n) return [K(r, `whenChain-branch-${t}`)];
406
405
  }
407
- return [W([], "whenChain-empty")];
406
+ return [K([], "whenChain-empty")];
408
407
  }
409
- function W(e, t) {
410
- const r = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
408
+ function K(e, t) {
409
+ const n = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
411
410
  return {
412
411
  tag: "#anchor",
413
412
  key: t,
414
- children: r
413
+ children: n
415
414
  };
416
415
  }
417
- function N(e, t) {
418
- return t.split(".").reduce((r, n) => r?.[n], e);
416
+ function z(e, t) {
417
+ return t.split(".").reduce((n, r) => n?.[r], e);
419
418
  }
420
- function Y(e, t, r) {
421
- const n = t.split("."), i = n.pop();
419
+ function Y(e, t, n) {
420
+ const r = t.split("."), i = r.pop();
422
421
  if (!i) return;
423
- const s = n.reduce((o, c) => (c in o || (o[c] = {}), o[c]), e);
424
- s[i] = r;
422
+ const s = r.reduce((o, l) => (l in o || (o[l] = {}), o[l]), e);
423
+ s[i] = n;
425
424
  }
426
- function ue(e, t, r, n, i, s, o) {
425
+ function ue(e, t, n, r, i, s, o) {
427
426
  if (!s) return;
428
- const c = t.includes("lazy"), d = t.includes("trim"), a = t.includes("number"), u = () => {
429
- const g = s._state || s;
430
- return N(g, e);
431
- }, y = u();
432
- let f = "text";
433
- const w = n?.type;
434
- if (o instanceof HTMLInputElement ? f = w || o.type || "text" : o instanceof HTMLSelectElement ? f = "select" : o instanceof HTMLTextAreaElement && (f = "textarea"), f === "checkbox")
435
- if (Array.isArray(y)) {
436
- const g = o?.getAttribute("value") || n?.value || "", l = y.includes(g);
437
- o && o.checked !== l && (r.checked = l);
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);
430
+ }, 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")
434
+ if (Array.isArray(d)) {
435
+ const m = o?.getAttribute("value") || r?.value || "", a = d.includes(m);
436
+ o && o.checked !== a && (n.checked = a);
438
437
  } else {
439
- const g = o?.getAttribute("true-value") || !0, l = y === g;
440
- o && o.checked !== l && (r.checked = l);
438
+ const m = o?.getAttribute("true-value") || !0, a = d === m;
439
+ o && o.checked !== a && (n.checked = a);
441
440
  }
442
- else if (f === "radio") {
443
- const g = n?.value || "", l = y === g;
444
- o && o.checked !== l && (r.checked = l);
445
- } else if (f === "select")
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")
446
445
  if (o && o.hasAttribute("multiple")) {
447
- const g = o, l = Array.isArray(y) ? y : [];
446
+ const m = o, a = Array.isArray(d) ? d : [];
448
447
  setTimeout(() => {
449
- Array.from(g.options).forEach((b) => {
450
- const m = l.includes(b.value);
451
- b.selected !== m && (b.selected = m);
448
+ Array.from(m.options).forEach((b) => {
449
+ const g = a.includes(b.value);
450
+ b.selected !== g && (b.selected = g);
452
451
  });
453
452
  }, 0);
454
453
  } else
455
454
  setTimeout(() => {
456
- o instanceof HTMLSelectElement && o.value !== String(y) && (o.value = String(y));
455
+ o instanceof HTMLSelectElement && o.value !== String(d) && (o.value = String(d));
457
456
  }, 0);
458
457
  else {
459
- const g = String(y ?? "");
460
- (!o || o.value !== g) && (r.value = y);
461
- }
462
- const p = c || f === "checkbox" || f === "radio" || f === "select" ? "change" : "input", S = (g) => {
463
- if (g.isComposing || i._isComposing || g.isTrusted === !1) return;
464
- const l = g.target;
465
- if (l._modelUpdating) return;
466
- const b = u();
467
- let m = l.value;
468
- if (f === "checkbox")
458
+ const m = String(d ?? "");
459
+ (!o || o.value !== m) && (n.value = d);
460
+ }
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;
465
+ const b = p();
466
+ let g = a.value;
467
+ if (c === "checkbox")
469
468
  if (Array.isArray(b)) {
470
- const k = l.getAttribute("value") || "", v = [...b];
471
- if (l.checked)
472
- v.includes(k) || v.push(k);
469
+ const $ = a.getAttribute("value") || "", C = [...b];
470
+ if (a.checked)
471
+ C.includes($) || C.push($);
473
472
  else {
474
- const _ = v.indexOf(k);
475
- _ > -1 && v.splice(_, 1);
473
+ const v = C.indexOf($);
474
+ v > -1 && C.splice(v, 1);
476
475
  }
477
- m = v;
476
+ g = C;
478
477
  } else {
479
- const k = l.getAttribute("true-value") || !0, v = l.getAttribute("false-value") || !1;
480
- m = l.checked ? k : v;
478
+ const $ = a.getAttribute("true-value") || !0, C = a.getAttribute("false-value") || !1;
479
+ g = a.checked ? $ : C;
481
480
  }
482
- else if (f === "radio")
483
- m = l.getAttribute("value") || l.value;
484
- else if (f === "select" && l.multiple) {
485
- const k = l;
486
- m = Array.from(k.selectedOptions).map(
487
- (v) => v.value
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
488
487
  );
489
- } else if (d && (m = m.trim()), a) {
490
- const k = Number(m);
491
- isNaN(k) || (m = k);
488
+ } else if (f && (g = g.trim()), u) {
489
+ const $ = Number(g);
490
+ isNaN($) || (g = $);
492
491
  }
493
- const h = s._state || s, x = N(h, e);
494
- if (Array.isArray(m) && Array.isArray(x) ? JSON.stringify([...m].sort()) !== JSON.stringify([...x].sort()) : m !== x) {
495
- const k = g.target;
496
- k._modelUpdating = !0, Y(h, e, m), setTimeout(() => {
497
- k._modelUpdating = !1;
492
+ const x = s._state || s, w = z(x, e);
493
+ 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;
498
497
  }, 0), s._requestRender && s._requestRender();
499
498
  }
500
499
  };
501
- if (i[p] = S, f === "text" || f === "textarea") {
502
- const g = () => {
500
+ if (i[h] = S, c === "text" || c === "textarea") {
501
+ const m = () => {
503
502
  i._isComposing = !0;
504
- }, l = (b) => {
503
+ }, a = (b) => {
505
504
  i._isComposing = !1;
506
- const m = b.target;
505
+ const g = b.target;
507
506
  setTimeout(() => {
508
- if (m) {
509
- let h = m.value;
510
- if (d && (h = h.trim()), a) {
511
- const v = Number(h);
512
- isNaN(v) || (h = v);
507
+ if (g) {
508
+ let x = g.value;
509
+ if (f && (x = x.trim()), u) {
510
+ const C = Number(x);
511
+ isNaN(C) || (x = C);
513
512
  }
514
- const x = s._state || s, C = N(x, e);
515
- (Array.isArray(h) && Array.isArray(C) ? JSON.stringify([...h].sort()) !== JSON.stringify([...C].sort()) : h !== C) && (m && (m._modelUpdating = !0, setTimeout(() => {
516
- m._modelUpdating = !1;
517
- }, 0)), Y(x, e, h), s._requestRender && s._requestRender());
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(() => {
515
+ g._modelUpdating = !1;
516
+ }, 0)), Y(w, e, x), s._requestRender && s._requestRender());
518
517
  }
519
518
  }, 0);
520
519
  };
521
- i.compositionstart = g, i.compositionend = l;
520
+ i.compositionstart = m, i.compositionend = a;
522
521
  }
523
522
  }
524
- function he(e, t, r, n) {
525
- if (n)
523
+ function pe(e, t, n, r) {
524
+ if (r)
526
525
  try {
527
526
  const i = JSON.parse(e);
528
527
  if (typeof i == "object")
529
528
  for (const [s, o] of Object.entries(i))
530
529
  t[s] = o;
531
530
  } catch {
532
- const i = N(n, e);
533
- r[e] = i;
531
+ const i = z(r, e);
532
+ n[e] = i;
534
533
  }
535
534
  }
536
- function pe(e, t, r) {
537
- if (!r) return;
538
- const n = N(r, e), i = t.style || "", s = n ? "" : "none";
535
+ function he(e, t, n) {
536
+ if (!n) return;
537
+ const r = z(n, e), i = t.style || "", s = r ? "" : "none";
539
538
  if (i) {
540
- const o = i.split(";").filter(Boolean), c = o.findIndex(
541
- (d) => d.trim().startsWith("display:")
539
+ const o = i.split(";").filter(Boolean), l = o.findIndex(
540
+ (f) => f.trim().startsWith("display:")
542
541
  );
543
- c >= 0 ? o[c] = `display: ${s}` : o.push(`display: ${s}`), t.style = o.join("; ");
542
+ l >= 0 ? o[l] = `display: ${s}` : o.push(`display: ${s}`), t.style = o.join("; ");
544
543
  } else
545
544
  t.style = `display: ${s}`;
546
545
  }
547
- function ge(e, t, r) {
548
- if (!r) return;
549
- const n = N(r, e);
546
+ function ge(e, t, n) {
547
+ if (!n) return;
548
+ const r = z(n, e);
550
549
  let i = [];
551
- typeof n == "string" ? i = [n] : Array.isArray(n) ? i = n.filter(Boolean) : typeof n == "object" && (i = Object.entries(n).filter(([, c]) => !!c).map(([c]) => c));
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));
552
551
  const s = t.class || "", o = s ? `${s} ${i.join(" ")}`.trim() : i.join(" ");
553
552
  o && (t.class = o);
554
553
  }
555
- function me(e, t, r) {
556
- let n;
554
+ function ye(e, t, n) {
555
+ let r;
557
556
  if (typeof e == "string") {
558
- if (!r) return;
559
- n = N(r, e);
557
+ if (!n) return;
558
+ r = z(n, e);
560
559
  } else
561
- n = e;
560
+ r = e;
562
561
  let i = "";
563
- if (typeof n == "string")
564
- i = n;
565
- else if (n && typeof n == "object") {
562
+ if (typeof r == "string")
563
+ i = r;
564
+ else if (r && typeof r == "object") {
566
565
  const o = [];
567
- for (const [c, d] of Object.entries(n))
568
- if (d != null && d !== "") {
569
- const a = c.replace(
566
+ for (const [l, f] of Object.entries(r))
567
+ if (f != null && f !== "") {
568
+ const u = l.replace(
570
569
  /[A-Z]/g,
571
- (f) => `-${f.toLowerCase()}`
572
- ), u = [
570
+ (c) => `-${c.toLowerCase()}`
571
+ ), p = [
573
572
  "width",
574
573
  "height",
575
574
  "top",
@@ -595,41 +594,41 @@ function me(e, t, r) {
595
594
  "min-height",
596
595
  "max-height"
597
596
  ];
598
- let y = String(d);
599
- typeof d == "number" && u.includes(a) && (y = `${d}px`), o.push(`${a}: ${y}`);
597
+ let d = String(f);
598
+ typeof f == "number" && p.includes(u) && (d = `${f}px`), o.push(`${u}: ${d}`);
600
599
  }
601
600
  i = o.join("; ") + (o.length > 0 ? ";" : "");
602
601
  }
603
602
  const s = t.style || "";
604
603
  t.style = s + (s && !s.endsWith(";") ? "; " : "") + i;
605
604
  }
606
- function ie(e, t, r, n) {
607
- const i = {}, s = { ...n || {} }, o = {};
608
- for (const [c, d] of Object.entries(e)) {
609
- const { value: a, modifiers: u } = d;
610
- switch (c) {
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) {
611
610
  case "model":
612
611
  ue(
613
- typeof a == "string" ? a : String(a),
614
- u,
612
+ typeof u == "string" ? u : String(u),
613
+ p,
615
614
  i,
616
615
  s,
617
616
  o,
618
617
  t,
619
- r
618
+ n
620
619
  );
621
620
  break;
622
621
  case "bind":
623
- he(a, i, s, t);
622
+ pe(u, i, s, t);
624
623
  break;
625
624
  case "show":
626
- pe(a, s, t);
625
+ he(u, s, t);
627
626
  break;
628
627
  case "class":
629
- ge(a, s, t);
628
+ ge(u, s, t);
630
629
  break;
631
630
  case "style":
632
- me(a, s, t);
631
+ ye(u, s, t);
633
632
  break;
634
633
  }
635
634
  }
@@ -640,274 +639,286 @@ function Z(e, t) {
640
639
  const s = /* @__PURE__ */ new Set();
641
640
  return e.map((o) => {
642
641
  if (!o || typeof o != "object") return o;
643
- let c = o.props?.key ?? o.key;
644
- if (!c) {
645
- const y = o.tag || "node", f = o.props?.attrs?.id ?? o.props?.attrs?.name ?? o.props?.attrs?.["data-key"] ?? "";
646
- c = f ? `${t}:${y}:${f}` : `${t}:${y}`;
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}`;
647
646
  }
648
- let d = c, a = 1;
649
- for (; s.has(d); )
650
- d = `${c}#${a++}`;
651
- s.add(d);
652
- let u = o.children;
653
- return Array.isArray(u) && (u = Z(u, d)), { ...o, key: d, children: u };
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 };
654
653
  });
655
654
  }
656
- const r = e;
657
- let n = r.props?.key ?? r.key ?? t, i = r.children;
658
- return Array.isArray(i) && (i = Z(i, n)), { ...r, key: n, children: i };
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 };
659
658
  }
660
- function ye(e, t, r, n) {
661
- const i = r.directives ?? {}, s = ie(
659
+ function me(e, t, n, r) {
660
+ const i = n.directives ?? {}, s = ie(
662
661
  i,
663
- n,
662
+ r,
664
663
  e,
665
- r.attrs
664
+ n.attrs
666
665
  ), o = {
667
666
  ...t.props,
668
- ...r.props,
667
+ ...n.props,
669
668
  ...s.props
670
- }, c = {
669
+ }, l = {
671
670
  ...t.attrs,
672
- ...r.attrs,
671
+ ...n.attrs,
673
672
  ...s.attrs
674
- }, d = t.props ?? {}, a = o;
675
- for (const f in { ...d, ...a }) {
676
- const w = d[f], p = a[f];
677
- w !== p && (f === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? e.value !== p && (e.value = p ?? "") : f === "checked" && e instanceof HTMLInputElement ? e.checked = !!p : f.startsWith("on") && typeof p == "function" ? (typeof w == "function" && e.removeEventListener(f.slice(2).toLowerCase(), w), e.addEventListener(f.slice(2).toLowerCase(), p)) : p == null || p === !1 ? e.removeAttribute(f) : e.setAttribute(f, String(p)));
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)));
678
677
  }
679
- for (const [f, w] of Object.entries(
678
+ for (const [c, y] of Object.entries(
680
679
  s.listeners || {}
681
680
  ))
682
- e.addEventListener(f, w);
683
- const u = t.attrs ?? {}, y = c;
684
- for (const f in { ...u, ...y }) {
685
- const w = u[f], p = y[f];
686
- w !== p && (p == null || p === !1 ? e.removeAttribute(f) : e.setAttribute(f, String(p)));
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)));
687
686
  }
688
687
  }
689
- function T(e, t) {
688
+ function T(e, t, n) {
690
689
  if (typeof e == "string")
691
690
  return document.createTextNode(e);
692
691
  if (e.tag === "#text") {
693
- const a = document.createTextNode(
692
+ const d = document.createTextNode(
694
693
  typeof e.children == "string" ? e.children : ""
695
694
  );
696
- return e.key != null && (a.key = e.key), a;
695
+ return e.key != null && (d.key = e.key), d;
697
696
  }
698
697
  if (e.tag === "#anchor") {
699
- const a = e, u = Array.isArray(a.children) ? a.children : [], y = document.createTextNode(""), f = document.createTextNode("");
700
- a.key != null && (y.key = `${a.key}:start`, f.key = `${a.key}:end`), a._startNode = y, a._endNode = f;
701
- const w = document.createDocumentFragment();
702
- w.appendChild(y);
703
- for (const p of u)
704
- w.appendChild(T(p, t));
705
- return w.appendChild(f), w;
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;
706
705
  }
707
706
  const r = document.createElement(e.tag);
708
707
  e.key != null && (r.key = e.key);
709
- const { props: n = {}, attrs: i = {}, directives: s = {} } = e.props ?? {}, o = ie(s, t, r, i), c = {
710
- ...n,
711
- ...o.props
712
- }, d = {
708
+ const { props: i = {}, attrs: s = {}, directives: o = {} } = e.props ?? {}, l = ie(o, t, r, s), f = {
713
709
  ...i,
714
- ...o.attrs
710
+ ...l.props
711
+ }, u = {
712
+ ...s,
713
+ ...l.attrs
715
714
  };
716
- for (const a in d) {
717
- const u = d[a];
718
- typeof u == "boolean" ? u && r.setAttribute(a, "") : u != null && r.setAttribute(a, String(u));
719
- }
720
- for (const a in c) {
721
- const u = c[a];
722
- if (a === "value" && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement))
723
- r.value = u ?? "";
724
- else if (a === "checked" && r instanceof HTMLInputElement)
725
- r.checked = !!u;
726
- else if (a.startsWith("on") && typeof u == "function")
727
- r.addEventListener(a.slice(2).toLowerCase(), u);
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
+ 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);
728
727
  else {
729
- if (a.startsWith("on") && u === void 0)
728
+ if (d.startsWith("on") && c === void 0)
730
729
  continue;
731
- u == null || u === !1 ? r.removeAttribute(a) : r.setAttribute(a, String(u));
730
+ c == null || c === !1 ? r.removeAttribute(d) : r.setAttribute(d, String(c));
732
731
  }
733
732
  }
734
- for (const [a, u] of Object.entries(
735
- o.listeners || {}
733
+ for (const [d, c] of Object.entries(
734
+ l.listeners || {}
736
735
  ))
737
- r.addEventListener(a, u);
738
- if (Array.isArray(e.children))
739
- for (const a of e.children)
740
- r.appendChild(T(a, t));
736
+ r.addEventListener(d, c);
737
+ const p = e.props?.ref ?? (e.props?.props && e.props.props.ref);
738
+ if (typeof e != "string" && p && n && (n[p] = r), Array.isArray(e.children))
739
+ for (const d of e.children)
740
+ r.appendChild(T(d, t, n));
741
741
  else typeof e.children == "string" && (r.textContent = e.children);
742
742
  return r;
743
743
  }
744
- function be(e, t, r, n) {
745
- if (typeof r == "string") {
746
- e.textContent !== r && (e.textContent = r);
744
+ function be(e, t, n, r, i) {
745
+ if (typeof n == "string") {
746
+ e.textContent !== n && (e.textContent = n);
747
747
  return;
748
748
  }
749
- if (!Array.isArray(r)) return;
750
- const i = Array.from(e.childNodes), s = Array.isArray(t) ? t : [], o = /* @__PURE__ */ new Map();
751
- for (const f of s)
752
- f && f.key != null && o.set(f.key, f);
753
- const c = /* @__PURE__ */ new Map();
754
- for (const f of i) {
755
- const w = f.key;
756
- w != null && c.set(w, f);
757
- }
758
- const d = /* @__PURE__ */ new Set();
759
- let a = e.firstChild;
760
- function u(f, w) {
761
- let p = f;
762
- for (; p && (d.add(p), p !== w); )
763
- p = p.nextSibling;
764
- }
765
- function y(f, w, p, S) {
766
- const g = [];
767
- let l = f.nextSibling;
768
- for (; l && l !== w; )
769
- g.push(l), l = l.nextSibling;
770
- const b = Array.isArray(p) ? p : [];
771
- if (S.some((h) => h && h.key != null) || b.some((h) => h && h.key != null)) {
772
- const h = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
773
- for (const v of b)
774
- v && v.key != null && h.set(v.key, v);
775
- for (const v of g) {
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);
757
+ }
758
+ const u = /* @__PURE__ */ new Set();
759
+ 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;
768
+ 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)) {
772
+ 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
776
  const _ = v.key;
777
- _ != null && x.set(_, v);
777
+ _ != null && k.set(_, v);
778
778
  }
779
- const C = /* @__PURE__ */ new Set();
780
- let k = f.nextSibling;
781
- for (const v of S) {
779
+ const $ = /* @__PURE__ */ new Set();
780
+ let C = y.nextSibling;
781
+ for (const v of m) {
782
782
  let _;
783
- if (v.key != null && x.has(v.key)) {
784
- const $ = h.get(v.key);
783
+ if (v.key != null && k.has(v.key)) {
784
+ const A = w.get(v.key);
785
785
  _ = D(
786
- x.get(v.key),
787
- $,
786
+ k.get(v.key),
787
+ A,
788
788
  v,
789
- n
790
- ), C.add(_), _ !== k && e.contains(_) && e.insertBefore(_, k);
789
+ r
790
+ ), $.add(_), _ !== C && e.contains(_) && e.insertBefore(_, C);
791
791
  } else
792
- _ = T(v, n), e.insertBefore(_, k), C.add(_);
793
- k = _.nextSibling;
792
+ _ = T(v, r), e.insertBefore(_, C), $.add(_);
793
+ C = _.nextSibling;
794
794
  }
795
- for (const v of g)
796
- !C.has(v) && e.contains(v) && e.removeChild(v);
795
+ for (const v of a)
796
+ !$.has(v) && e.contains(v) && e.removeChild(v);
797
797
  } else {
798
- const h = Math.min(
799
- b.length,
800
- S.length
798
+ const w = Math.min(
799
+ g.length,
800
+ m.length
801
801
  );
802
- for (let x = 0; x < h; x++) {
803
- const C = b[x], k = S[x], v = D(g[x], C, k, n);
804
- v !== g[x] && (e.insertBefore(v, g[x]), e.removeChild(g[x]));
802
+ 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]));
805
805
  }
806
- for (let x = h; x < S.length; x++)
807
- e.insertBefore(T(S[x], n), w);
808
- for (let x = h; x < g.length; x++)
809
- e.removeChild(g[x]);
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]);
810
810
  }
811
811
  }
812
- for (const f of r) {
813
- let w;
814
- if (f.tag === "#anchor") {
815
- const p = f.key, S = `${p}:start`, g = `${p}:end`;
816
- let l = c.get(S), b = c.get(g);
817
- const m = Array.isArray(f.children) ? f.children : [];
818
- if (l || (l = document.createTextNode(""), l.key = S), b || (b = document.createTextNode(""), b.key = g), f._startNode = l, f._endNode = b, !e.contains(l) || !e.contains(b)) {
819
- e.insertBefore(l, a);
820
- for (const h of m)
821
- e.insertBefore(T(h, n), a);
822
- e.insertBefore(b, a);
812
+ for (const y of n) {
813
+ 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)) {
819
+ e.insertBefore(b, p);
820
+ for (const w of x)
821
+ e.insertBefore(T(w, r), p);
822
+ e.insertBefore(g, p);
823
823
  } else
824
- y(
825
- l,
824
+ c(
826
825
  b,
827
- o.get(p)?.children,
828
- m
826
+ g,
827
+ l.get(S)?.children,
828
+ x
829
829
  );
830
- u(l, b), a = b.nextSibling;
830
+ d(b, g), p = g.nextSibling;
831
831
  continue;
832
832
  }
833
- if (f.key != null && c.has(f.key)) {
834
- const p = o.get(f.key);
835
- w = D(
836
- c.get(f.key),
837
- p,
838
- f,
839
- n
840
- ), d.add(w), w !== a && e.contains(w) && (a && !e.contains(a) && (a = null), e.insertBefore(w, a));
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));
841
842
  } else
842
- w = T(f, n), a && !e.contains(a) && (a = null), e.insertBefore(w, a), d.add(w);
843
- a = w.nextSibling;
844
- }
845
- for (const f of i)
846
- !d.has(f) && e.contains(f) && e.removeChild(f);
843
+ h = T(y, r, i), p && !e.contains(p) && (p = null), e.insertBefore(h, p), u.add(h);
844
+ p = h.nextSibling;
845
+ }
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
+ }
847
853
  }
848
- function D(e, t, r, n) {
849
- if (t === r) return e;
850
- if (typeof r == "string") {
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") {
851
857
  if (e.nodeType === Node.TEXT_NODE)
852
- return e.textContent !== r && (e.textContent = r), e;
858
+ return e.textContent !== n && (e.textContent = n), e;
853
859
  {
854
- const s = document.createTextNode(r);
855
- return e.parentNode?.replaceChild(s, e), s;
860
+ const o = document.createTextNode(n);
861
+ return e.parentNode?.replaceChild(o, e), o;
856
862
  }
857
863
  }
858
- if (r && typeof r != "string" && r.tag === "#anchor") {
859
- const s = r, o = Array.isArray(s.children) ? s.children : [], c = s._startNode ?? document.createTextNode(""), d = s._endNode ?? document.createTextNode("");
860
- s.key != null && (c.key = `${s.key}:start`, d.key = `${s.key}:end`), s._startNode = c, s._endNode = d;
861
- const a = document.createDocumentFragment();
862
- a.appendChild(c);
863
- for (const u of o)
864
- a.appendChild(T(u, n));
865
- return a.appendChild(d), e.parentNode?.replaceChild(a, e), c;
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;
867
+ 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;
866
872
  }
867
- if (!r) {
868
- const s = document.createComment("removed");
869
- return e.parentNode?.replaceChild(s, e), s;
873
+ if (!n) {
874
+ const o = document.createComment("removed");
875
+ return e.parentNode?.replaceChild(o, e), o;
870
876
  }
871
877
  if (!t || typeof t == "string") {
872
- const s = T(r, n);
873
- return e.parentNode?.replaceChild(s, e), s;
874
- }
875
- if (r.tag === "#anchor") {
876
- const s = Array.isArray(r.children) ? r.children : [], o = r._startNode ?? document.createTextNode(""), c = r._endNode ?? document.createTextNode("");
877
- r.key != null && (o.key = `${r.key}:start`, c.key = `${r.key}:end`), r._startNode = o, r._endNode = c;
878
- const d = document.createDocumentFragment();
879
- d.appendChild(o);
880
- for (const a of s)
881
- d.appendChild(T(a, n));
882
- return d.appendChild(c), e.parentNode?.replaceChild(d, e), o;
883
- }
884
- if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
885
- const s = e;
886
- return ye(s, t.props || {}, r.props || {}, n), be(s, t.children, r.children, n), s;
887
- }
888
- const i = T(r, n);
889
- return e.parentNode?.replaceChild(i, e), i;
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;
890
896
  }
891
- function xe(e, t, r) {
892
- const n = (a) => a.key == null ? { ...a, key: "__root__" } : a;
893
- let i = Array.isArray(t) ? { tag: "div", key: "__root__", children: t } : n(t);
894
- i = Z(i, String(i.key ?? "root"));
895
- const s = e._prevVNode ?? null, o = e._prevDom ?? e.firstChild ?? null;
896
- let c;
897
- s && o ? typeof s != "string" && typeof i != "string" && s.tag === i.tag && s.key === i.key ? c = D(o, s, i, r) : (c = T(i, r), e.replaceChild(c, o)) : (c = T(i, r), e.firstChild ? e.replaceChild(c, e.firstChild) : e.appendChild(c));
898
- const d = [];
899
- for (let a = 0; a < e.childNodes.length; a++) {
900
- const u = e.childNodes[a];
901
- u !== c && u.nodeName !== "STYLE" && d.push(u);
902
- }
903
- d.forEach((a) => e.removeChild(a)), e._prevVNode = i, e._prevDom = c;
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;
904
915
  }
905
916
  function oe(e) {
906
917
  return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
907
918
  }
908
- let V = null;
919
+ let H = null;
909
920
  function G() {
910
- return V || (V = new CSSStyleSheet(), V.replaceSync(oe(we))), V;
921
+ return H || (H = new CSSStyleSheet(), H.replaceSync(oe(we))), H;
911
922
  }
912
923
  function ve(e) {
913
924
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
@@ -1159,7 +1170,7 @@ const we = `
1159
1170
  },
1160
1171
  white: { DEFAULT: "var(--color-white, #ffffff)" },
1161
1172
  black: { DEFAULT: "var(--color-black, #000000)" }
1162
- }, K = {
1173
+ }, F = {
1163
1174
  /* Display */
1164
1175
  block: "display:block;",
1165
1176
  inline: "display:inline;",
@@ -1352,23 +1363,23 @@ const we = `
1352
1363
  "2xl": "(min-width:1536px)",
1353
1364
  // Dark mode (now plain string)
1354
1365
  dark: "(prefers-color-scheme: dark)"
1355
- }, F = ["sm", "md", "lg", "xl", "2xl"];
1366
+ }, V = ["sm", "md", "lg", "xl", "2xl"];
1356
1367
  function U(e) {
1357
- const t = e.startsWith("-"), n = (t ? e.slice(1) : e).split("-");
1358
- if (n.length < 2) return null;
1359
- const i = n.slice(0, -1).join("-"), s = n[n.length - 1], o = parseFloat(s);
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);
1360
1371
  if (Number.isNaN(o) || !ee[i]) return null;
1361
- const c = t ? "-" : "";
1362
- return ee[i].map((d) => `${d}:calc(${c}${_e} * ${o});`).join("");
1372
+ const l = t ? "-" : "";
1373
+ return ee[i].map((f) => `${f}:calc(${l}${_e} * ${o});`).join("");
1363
1374
  }
1364
1375
  function re(e) {
1365
- const t = e.replace("#", ""), r = parseInt(t, 16), n = r >> 16 & 255, i = r >> 8 & 255, s = r & 255;
1366
- return `${n} ${i} ${s}`;
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}`;
1367
1378
  }
1368
1379
  function Se(e) {
1369
1380
  const t = /^(bg|text|border|shadow|outline|caret|accent)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1370
1381
  if (!t) return null;
1371
- const [, r, n, i = "DEFAULT"] = t, s = ke[n]?.[i];
1382
+ const [, n, r, i = "DEFAULT"] = t, s = ke[r]?.[i];
1372
1383
  return s ? `${{
1373
1384
  bg: "background-color",
1374
1385
  text: "color",
@@ -1377,40 +1388,40 @@ function Se(e) {
1377
1388
  outline: "outline-color",
1378
1389
  caret: "caret-color",
1379
1390
  accent: "accent-color"
1380
- }[r]}:${s};` : null;
1391
+ }[n]}:${s};` : null;
1381
1392
  }
1382
1393
  function Ce(e) {
1383
- const [t, r] = e.split("/");
1384
- if (!r) return { base: t };
1385
- const n = parseInt(r, 10);
1386
- return isNaN(n) || n < 0 || n > 100 ? { base: t } : { base: t, opacity: n / 100 };
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 };
1387
1398
  }
1388
1399
  function q(e) {
1389
- const { base: t, opacity: r } = Ce(e), n = Se(t);
1390
- if (n) {
1391
- if (r !== void 0) {
1392
- const s = /#([0-9a-f]{6})/i.exec(n);
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);
1393
1404
  if (s) {
1394
1405
  const o = re(s[0]);
1395
- return n.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
1406
+ return r.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${n})`);
1396
1407
  }
1397
1408
  }
1398
- return n;
1409
+ return r;
1399
1410
  }
1400
- const i = H(t);
1401
- if (i && r !== void 0) {
1411
+ const i = W(t);
1412
+ if (i && n !== void 0) {
1402
1413
  const s = /#([0-9a-f]{6})/i.exec(i);
1403
1414
  if (s) {
1404
1415
  const o = re(s[0]);
1405
- return i.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
1416
+ return i.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${n})`);
1406
1417
  }
1407
1418
  }
1408
1419
  return i;
1409
1420
  }
1410
- function H(e) {
1411
- const t = e.indexOf("-["), r = e.endsWith("]");
1412
- if (t > 0 && r) {
1413
- const n = e.slice(0, t);
1421
+ function W(e) {
1422
+ const t = e.indexOf("-["), n = e.endsWith("]");
1423
+ if (t > 0 && n) {
1424
+ const r = e.slice(0, t);
1414
1425
  let i = e.slice(t + 2, -1);
1415
1426
  i = i.replace(/_/g, " ");
1416
1427
  const o = {
@@ -1452,7 +1463,7 @@ function H(e) {
1452
1463
  weight: "font-weight",
1453
1464
  leading: "line-height",
1454
1465
  z: "z-index"
1455
- }[n] ?? n.replace(/_/g, "-");
1466
+ }[r] ?? r.replace(/_/g, "-");
1456
1467
  if (o && i) return `${o}:${i};`;
1457
1468
  }
1458
1469
  return null;
@@ -1461,67 +1472,67 @@ function Ae(e) {
1461
1472
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1462
1473
  }
1463
1474
  function Ee(e) {
1464
- const t = /class\s*=\s*["']([^"']+)["']/g, r = [];
1465
- let n;
1466
- for (; n = t.exec(e); ) {
1475
+ const t = /class\s*=\s*["']([^"']+)["']/g, n = [];
1476
+ let r;
1477
+ for (; r = t.exec(e); ) {
1467
1478
  let i = "", s = !1;
1468
- for (const o of n[1])
1469
- o === "[" && (s = !0), o === "]" && (s = !1), o === " " && !s ? (i && r.push(i), i = "") : i += o;
1470
- i && r.push(i);
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);
1471
1482
  }
1472
- return r.filter(Boolean);
1483
+ return n.filter(Boolean);
1473
1484
  }
1474
1485
  const ne = /* @__PURE__ */ new Map(), Te = 16;
1475
1486
  function je(e) {
1476
- const t = Date.now(), r = ne.get(e);
1477
- if (r && t - r.timestamp < Te) return r.css;
1478
- const n = Ee(e), i = new Set(n), s = [], o = [], c = [], d = [], a = {};
1479
- function u(p, S = !1) {
1480
- const g = (S ? "dark|" : "") + p;
1481
- if (g in a) return a[g];
1482
- const l = f(p, S);
1483
- return a[g] = l, l;
1484
- }
1485
- function y(p) {
1486
- const S = p.some((l) => F.includes(l)), g = p.includes("dark");
1487
- return p.length === 0 ? 1 : !S && !g ? 2 : S && !g ? 3 : 4;
1488
- }
1489
- function f(p, S = !1) {
1490
- const g = p.split(":"), l = g.find(
1491
- ($) => K[$] || U($) || q($) || H($)
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;
1495
+ }
1496
+ 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;
1499
+ }
1500
+ function c(h, S = !1) {
1501
+ const m = h.split(":"), a = m.find(
1502
+ (_) => F[_] || U(_) || q(_) || W(_)
1492
1503
  );
1493
- if (!l) return null;
1494
- const b = K[l] ?? U(l) ?? q(l) ?? H(l);
1504
+ if (!a) return null;
1505
+ const b = F[a] ?? U(a) ?? q(a) ?? W(a);
1495
1506
  if (!b) return null;
1496
- let m = `.${Ae(p)}`, h = b;
1497
- const x = g.indexOf(l);
1498
- let C = x >= 0 ? g.slice(0, x) : [];
1499
- S && (C = C.filter(($) => $ !== "dark"));
1500
- const k = C.filter(($) => F.includes($)), v = k.length ? k[k.length - 1] : null;
1501
- for (const $ of C) {
1502
- if (F.includes($)) continue;
1503
- const A = $e[$];
1504
- typeof A == "function" && (m = A(m, h).replace(/\{.*$/, ""));
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(/\{.*$/, ""));
1505
1516
  }
1506
- let _ = `${m}{${h}}`;
1507
- return S && v ? _ = `@media (prefers-color-scheme: dark) and ${te[v]}{${_}}` : S ? _ = `@media (prefers-color-scheme: dark){${_}}` : v && (_ = `@media ${te[v]}{${_}}`), _;
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;
1508
1519
  }
1509
- for (const p of i) {
1510
- const S = p.split(":"), g = S.find(
1511
- (h) => K[h] || U(h) || q(h) || H(h)
1520
+ for (const h of i) {
1521
+ const S = h.split(":"), m = S.find(
1522
+ (x) => F[x] || U(x) || q(x) || W(x)
1512
1523
  );
1513
- if (!g) continue;
1514
- const l = S.indexOf(g), b = l >= 0 ? S.slice(0, l) : [], m = y(b);
1515
- if (m === 4) {
1516
- const h = u(p, !0);
1517
- h && d.push(h);
1524
+ if (!m) continue;
1525
+ const a = S.indexOf(m), b = a >= 0 ? S.slice(0, a) : [], g = d(b);
1526
+ if (g === 4) {
1527
+ const x = p(h, !0);
1528
+ x && f.push(x);
1518
1529
  } else {
1519
- const h = u(p);
1520
- h && (m === 1 ? s.push(h) : m === 2 ? o.push(h) : m === 3 && c.push(h));
1530
+ const x = p(h);
1531
+ x && (g === 1 ? s.push(x) : g === 2 ? o.push(x) : g === 3 && l.push(x));
1521
1532
  }
1522
1533
  }
1523
- const w = [...s, ...o, ...c, ...d].join("");
1524
- return ne.set(e, { css: w, timestamp: t }), w;
1534
+ const y = [...s, ...o, ...l, ...f].join("");
1535
+ return ne.set(e, { css: y, timestamp: t }), y;
1525
1536
  }
1526
1537
  const Le = /* @__PURE__ */ new Map();
1527
1538
  function Q(e) {
@@ -1539,21 +1550,21 @@ function J(e) {
1539
1550
  })[t]
1540
1551
  ) : e;
1541
1552
  }
1542
- function Ve(e, ...t) {
1543
- let r = "";
1544
- for (let n = 0; n < e.length; n++)
1545
- r += e[n], n < t.length && (r += t[n]);
1546
- return r;
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;
1547
1558
  }
1548
- function Ie(e, t, r) {
1549
- let n = Q(e);
1550
- n.includes("-") || (n = `cer-${n}`);
1559
+ function Ie(e, t, n) {
1560
+ let r = Q(e);
1561
+ r.includes("-") || (r = `cer-${r}`);
1551
1562
  let i;
1552
- typeof t == "function" ? i = { ...r, render: t } : i = t, typeof i.onError != "function" && (i.onError = (s, o) => {
1553
- console.error(`[${n}] Error:`, s, o);
1554
- }), Le.set(n, i), typeof window < "u" && !customElements.get(n) && customElements.define(n, Ne(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));
1555
1566
  }
1556
- function Ne(e) {
1567
+ function ze(e) {
1557
1568
  if (!e.render)
1558
1569
  throw new Error(
1559
1570
  "Component must have a render function"
@@ -1563,6 +1574,7 @@ function Ne(e) {
1563
1574
  }
1564
1575
  } : class extends HTMLElement {
1565
1576
  context;
1577
+ _refs = {};
1566
1578
  _listeners = [];
1567
1579
  _watchers = /* @__PURE__ */ new Map();
1568
1580
  /** @internal */
@@ -1578,9 +1590,17 @@ function Ne(e) {
1578
1590
  _templateLoading = !1;
1579
1591
  _templateError = null;
1580
1592
  constructor() {
1581
- super(), this.attachShadow({ mode: "open" }), this._cfg = e, this.context = this._initContext(e), Object.keys(e).forEach((t) => {
1582
- const r = e[t];
1583
- typeof r == "function" && !t.startsWith("on") && (this.context[t] = (...n) => r(...n, this.context));
1593
+ super(), this.attachShadow({ mode: "open" }), this._cfg = e;
1594
+ const t = this._initContext(e);
1595
+ Object.defineProperty(t, "refs", {
1596
+ value: this._refs,
1597
+ writable: !1,
1598
+ enumerable: !1,
1599
+ // Hide from iteration to avoid proxy traps
1600
+ 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));
1584
1604
  }), this._applyProps(e), this._applyComputed(e), this._initializing = !1, this._initWatchers(e), this._render(e);
1585
1605
  }
1586
1606
  connectedCallback() {
@@ -1593,12 +1613,12 @@ function Ne(e) {
1593
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;
1594
1614
  });
1595
1615
  }
1596
- attributeChangedCallback(t, r, n) {
1616
+ attributeChangedCallback(t, n, r) {
1597
1617
  this._runLogicWithinErrorBoundary(e, () => {
1598
1618
  this._applyProps(e), e.onAttributeChanged && e.onAttributeChanged(
1599
1619
  t,
1600
- r,
1601
1620
  n,
1621
+ r,
1602
1622
  this.context
1603
1623
  );
1604
1624
  });
@@ -1608,10 +1628,10 @@ function Ne(e) {
1608
1628
  }
1609
1629
  _applyComputed(t) {
1610
1630
  this._runLogicWithinErrorBoundary(e, () => {
1611
- t.computed && Object.entries(t.computed).forEach(([r, n]) => {
1612
- Object.defineProperty(this.context, r, {
1631
+ t.computed && Object.entries(t.computed).forEach(([n, r]) => {
1632
+ Object.defineProperty(this.context, n, {
1613
1633
  get: () => {
1614
- const i = n(this.context);
1634
+ const i = r(this.context);
1615
1635
  return J(i);
1616
1636
  },
1617
1637
  enumerable: !0
@@ -1631,39 +1651,40 @@ function Ne(e) {
1631
1651
  this._renderOutput(t.errorTemplate(this._templateError, this.context));
1632
1652
  return;
1633
1653
  }
1634
- const r = t.render(this.context);
1635
- if (r instanceof Promise) {
1636
- this._templateLoading = !0, r.then((n) => (this._templateLoading = !1, this._templateError = null, this._renderOutput(n), n)).catch((n) => {
1637
- if (this._templateLoading = !1, this._templateError = n, t.errorTemplate) {
1638
- const i = t.errorTemplate(n, this.context);
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);
1639
1659
  return this._renderOutput(i), i;
1640
1660
  }
1641
- throw n;
1661
+ throw r;
1642
1662
  }), t.loadingTemplate && this._renderOutput(t.loadingTemplate(this.context));
1643
1663
  return;
1644
1664
  }
1645
- this._renderOutput(r), this._applyStyle(t);
1665
+ this._renderOutput(n), this._applyStyle(t);
1646
1666
  });
1647
1667
  }
1648
1668
  // --- Helper to render output ---
1649
1669
  _renderOutput(t) {
1650
1670
  if (!this.shadowRoot) return;
1651
- const r = new Proxy(this.context, {
1652
- get: (n, i) => i === "_requestRender" ? () => this._requestRender() : i === "context" ? n : typeof i == "string" && i.includes(".") ? i.split(".").reduce((s, o) => s?.[o], n) : n[i],
1653
- set: (n, i, s) => {
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) => {
1654
1674
  if (typeof i == "string" && i.includes(".")) {
1655
- const o = i.split("."), c = o.pop();
1656
- if (!c) return !1;
1657
- const d = o.reduce((a, u) => (u in a || (a[u] = {}), a[u]), n);
1658
- return d[c] = s, !0;
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;
1659
1679
  }
1660
- return n[i] = s, !0;
1680
+ return r[i] = s, !0;
1661
1681
  }
1662
1682
  });
1663
1683
  xe(
1664
1684
  this.shadowRoot,
1665
1685
  Array.isArray(t) ? t : [t],
1666
- r
1686
+ n,
1687
+ this._refs
1667
1688
  ), this._lastHtmlStringForJitCSS = this.shadowRoot.innerHTML;
1668
1689
  }
1669
1690
  _requestRender() {
@@ -1684,27 +1705,27 @@ function Ne(e) {
1684
1705
  _applyStyle(t) {
1685
1706
  this._runLogicWithinErrorBoundary(t, () => {
1686
1707
  if (!this.shadowRoot) return;
1687
- const r = je(this._lastHtmlStringForJitCSS);
1688
- if (!t.style && (!r || r.trim() === "")) {
1708
+ const n = je(this._lastHtmlStringForJitCSS);
1709
+ if (!t.style && (!n || n.trim() === "")) {
1689
1710
  this._styleSheet = null, this.shadowRoot.adoptedStyleSheets = [G()];
1690
1711
  return;
1691
1712
  }
1692
- let n = "";
1693
- t.style && (typeof t.style == "string" ? n = t.style : typeof t.style == "function" && (n = t.style(this.context)));
1694
- let i = ve(`${n}
1695
- ${r}
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}
1696
1717
  `);
1697
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];
1698
1719
  });
1699
1720
  }
1700
1721
  // --- Error Boundary function ---
1701
- _runLogicWithinErrorBoundary(t, r) {
1722
+ _runLogicWithinErrorBoundary(t, n) {
1702
1723
  this._hasError && (this._hasError = !1);
1703
1724
  try {
1704
- r();
1705
- } catch (n) {
1706
- this._hasError = !0, t.onError && t.onError(n, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1707
- n,
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,
1708
1729
  this.context
1709
1730
  ));
1710
1731
  }
@@ -1712,11 +1733,11 @@ ${r}
1712
1733
  // --- State, props, computed ---
1713
1734
  _initContext(t) {
1714
1735
  try {
1715
- let r = function(i, s = "") {
1736
+ let n = function(i, s = "") {
1716
1737
  return Array.isArray(i) ? new Proxy(i, {
1717
- get(o, c, d) {
1718
- const a = Reflect.get(o, c, d);
1719
- return typeof a == "function" && typeof c == "string" && [
1738
+ get(o, l, f) {
1739
+ const u = Reflect.get(o, l, f);
1740
+ return typeof u == "function" && typeof l == "string" && [
1720
1741
  "push",
1721
1742
  "pop",
1722
1743
  "shift",
@@ -1724,113 +1745,113 @@ ${r}
1724
1745
  "splice",
1725
1746
  "sort",
1726
1747
  "reverse"
1727
- ].includes(c) ? function(...y) {
1728
- const f = a.apply(o, y);
1729
- if (!n._initializing) {
1730
- const w = s || "root";
1731
- n._triggerWatchers(w, o), n._render(t);
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);
1732
1753
  }
1733
- return f;
1734
- } : a;
1754
+ return c;
1755
+ } : u;
1735
1756
  },
1736
- set(o, c, d) {
1737
- if (o[c] = d, !n._initializing) {
1738
- const a = s ? `${s}.${String(c)}` : String(c);
1739
- n._triggerWatchers(a, d), n._render(t);
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);
1740
1761
  }
1741
1762
  return !0;
1742
1763
  },
1743
- deleteProperty(o, c) {
1744
- if (delete o[c], !n._initializing) {
1745
- const d = s ? `${s}.${String(c)}` : String(c);
1746
- n._triggerWatchers(d, void 0), n._render(t);
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);
1747
1768
  }
1748
1769
  return !0;
1749
1770
  }
1750
1771
  }) : i && typeof i == "object" ? (Object.keys(i).forEach((o) => {
1751
- const c = s ? `${s}.${o}` : o;
1752
- i[o] = r(i[o], c);
1772
+ const l = s ? `${s}.${o}` : o;
1773
+ i[o] = n(i[o], l);
1753
1774
  }), new Proxy(i, {
1754
- set(o, c, d) {
1755
- const a = s ? `${s}.${String(c)}` : String(c);
1756
- return o[c] = r(d, a), n._initializing || (n._triggerWatchers(
1757
- a,
1758
- o[c]
1759
- ), n._render(t)), !0;
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;
1760
1781
  },
1761
- get(o, c, d) {
1762
- return Reflect.get(o, c, d);
1782
+ get(o, l, f) {
1783
+ return Reflect.get(o, l, f);
1763
1784
  }
1764
1785
  })) : i;
1765
1786
  };
1766
- const n = this;
1767
- return r({ ...t.state });
1787
+ const r = this;
1788
+ return n({ ...t.state });
1768
1789
  } catch {
1769
1790
  return {};
1770
1791
  }
1771
1792
  }
1772
1793
  _initWatchers(t) {
1773
1794
  if (t.watch)
1774
- for (const [r, n] of Object.entries(t.watch)) {
1795
+ for (const [n, r] of Object.entries(t.watch)) {
1775
1796
  let i, s = {};
1776
- if (Array.isArray(n) ? (i = n[0], s = n[1] || {}) : i = n, this._watchers.set(r, {
1797
+ if (Array.isArray(r) ? (i = r[0], s = r[1] || {}) : i = r, this._watchers.set(n, {
1777
1798
  callback: i,
1778
1799
  options: s,
1779
- oldValue: this._getNestedValue(r)
1800
+ oldValue: this._getNestedValue(n)
1780
1801
  }), s.immediate)
1781
1802
  try {
1782
- const o = this._getNestedValue(r);
1803
+ const o = this._getNestedValue(n);
1783
1804
  i(o, void 0, this.context);
1784
1805
  } catch (o) {
1785
- console.error(`Error in immediate watcher for "${r}":`, o);
1806
+ console.error(`Error in immediate watcher for "${n}":`, o);
1786
1807
  }
1787
1808
  }
1788
1809
  }
1789
1810
  _getNestedValue(t) {
1790
1811
  return t.split(".").reduce(
1791
- (r, n) => r?.[n],
1812
+ (n, r) => n?.[r],
1792
1813
  this.context
1793
1814
  );
1794
1815
  }
1795
- _triggerWatchers(t, r) {
1796
- const n = (s, o) => {
1816
+ _triggerWatchers(t, n) {
1817
+ const r = (s, o) => {
1797
1818
  if (s === o) return !0;
1798
1819
  if (typeof s != typeof o || typeof s != "object" || s === null || o === null) return !1;
1799
1820
  if (Array.isArray(s) && Array.isArray(o))
1800
- return s.length !== o.length ? !1 : s.every((a, u) => n(a, o[u]));
1801
- const c = Object.keys(s), d = Object.keys(o);
1802
- return c.length !== d.length ? !1 : c.every((a) => n(s[a], o[a]));
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]));
1803
1824
  }, i = this._watchers.get(t);
1804
- if (i && !n(r, i.oldValue))
1825
+ if (i && !r(n, i.oldValue))
1805
1826
  try {
1806
- i.callback(r, i.oldValue, this.context), i.oldValue = r;
1827
+ i.callback(n, i.oldValue, this.context), i.oldValue = n;
1807
1828
  } catch (s) {
1808
1829
  console.error(`Error in watcher for "${t}":`, s);
1809
1830
  }
1810
1831
  for (const [s, o] of this._watchers.entries())
1811
1832
  if (o.options.deep && t.startsWith(s + "."))
1812
1833
  try {
1813
- const c = this._getNestedValue(s);
1814
- n(c, o.oldValue) || (o.callback(c, o.oldValue, this.context), o.oldValue = c);
1815
- } catch (c) {
1816
- console.error(`Error in deep watcher for "${s}":`, c);
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);
1817
1838
  }
1818
1839
  }
1819
1840
  _applyProps(t) {
1820
1841
  try {
1821
- let r = function(n, i) {
1822
- return i === Boolean ? n === "true" : i === Number ? Number(n) : n;
1842
+ let n = function(r, i) {
1843
+ return i === Boolean ? r === "true" : i === Number ? Number(r) : r;
1823
1844
  };
1824
1845
  if (!t.props) return;
1825
- Object.entries(t.props).forEach(([n, i]) => {
1826
- const s = this.getAttribute(Q(n));
1827
- s !== null ? this.context[n] = J(
1828
- r(s, i.type)
1829
- ) : "default" in i && i.default !== void 0 && (this.context[n] = J(i.default));
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));
1830
1851
  });
1831
- } catch (r) {
1832
- this._hasError = !0, t.onError && t.onError(r, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(
1833
- r,
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,
1834
1855
  this.context
1835
1856
  ));
1836
1857
  }
@@ -1839,12 +1860,12 @@ ${r}
1839
1860
  }
1840
1861
  export {
1841
1862
  Ie as component,
1842
- Ne as createElementClass,
1843
- ze as createStore,
1844
- Ve as css,
1845
- Me as each,
1846
- Re as eventBus,
1847
- Be as html,
1863
+ ze as createElementClass,
1864
+ Re as createStore,
1865
+ He as css,
1866
+ Ne as each,
1867
+ Be as eventBus,
1868
+ Me as html,
1848
1869
  Pe as match,
1849
1870
  Oe as when
1850
1871
  };