@jasonshimmy/custom-elements-runtime 0.0.2 → 0.0.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ class Q {
3
3
  listeners = [];
4
4
  constructor(t) {
5
5
  this.state = new Proxy(t, {
6
- set: (n, r, i) => (n[r] = i, this.notify(), !0)
6
+ set: (n, r, o) => (n[r] = o, this.notify(), !0)
7
7
  });
8
8
  }
9
9
  subscribe(t) {
@@ -33,10 +33,10 @@ class y extends EventTarget {
33
33
  * @param data - Optional event payload
34
34
  */
35
35
  emit(t, n) {
36
- const r = Date.now(), i = this.eventCounters.get(t);
37
- if (!i || r - i.window > 1e3)
36
+ const r = Date.now(), o = this.eventCounters.get(t);
37
+ if (!o || r - o.window > 1e3)
38
38
  this.eventCounters.set(t, { count: 1, window: r });
39
- else if (i.count++, i.count > 50 && (console.error(`Event storm detected for "${t}": ${i.count} events in 1 second. Throttling...`), i.count > 100)) {
39
+ else if (o.count++, o.count > 50 && (console.error(`Event storm detected for "${t}": ${o.count} events in 1 second. Throttling...`), o.count > 100)) {
40
40
  console.warn(`Blocking further "${t}" events to prevent infinite loop`);
41
41
  return;
42
42
  }
@@ -47,9 +47,9 @@ class y extends EventTarget {
47
47
  cancelable: !0
48
48
  }));
49
49
  const s = this.handlers[t];
50
- s && s.forEach((o) => {
50
+ s && s.forEach((i) => {
51
51
  try {
52
- o(n);
52
+ i(n);
53
53
  } catch (a) {
54
54
  console.error(`Error in global event handler for "${t}":`, a);
55
55
  }
@@ -95,8 +95,8 @@ class y extends EventTarget {
95
95
  */
96
96
  once(t, n) {
97
97
  return new Promise((r) => {
98
- const i = this.on(t, (s) => {
99
- i(), n(s), r(s);
98
+ const o = this.on(t, (s) => {
99
+ o(), n(s), r(s);
100
100
  });
101
101
  });
102
102
  }
@@ -158,10 +158,10 @@ function W(e) {
158
158
  function F(e, t = {}) {
159
159
  q || console.warn("[SSR] renderToString should only be used on the server");
160
160
  try {
161
- const n = e.state, r = W(n), i = e.template(n, r);
161
+ const n = e.state, r = W(n), o = e.template(n, r);
162
162
  let s = "";
163
163
  t.includeStyles && e.style && (s = `<style>${typeof e.style == "function" ? e.style(n) : e.style}</style>`);
164
- const o = t.sanitizeAttributes ? t.sanitizeAttributes(e.attrs || {}) : e.attrs || {}, a = Object.entries(o).map(([d, f]) => `${H(d)}="${H(f)}"`).join(" "), l = `${a ? `<${e.tag} ${a}>` : `<${e.tag}>`}${s}${i}</${e.tag}>`;
164
+ const i = t.sanitizeAttributes ? t.sanitizeAttributes(e.attrs || {}) : e.attrs || {}, a = Object.entries(i).map(([d, f]) => `${H(d)}="${H(f)}"`).join(" "), l = `${a ? `<${e.tag} ${a}>` : `<${e.tag}>`}${s}${o}</${e.tag}>`;
165
165
  return t.prettyPrint ? G(l) : l;
166
166
  } catch (n) {
167
167
  return console.error(`[SSR] Error rendering ${e.tag}:`, n), `<${e.tag}><div style="color: red;">SSR Error: ${K(String(n))}</div></${e.tag}>`;
@@ -172,18 +172,18 @@ function tt(e, t = {}) {
172
172
  components: /* @__PURE__ */ new Map(),
173
173
  styles: /* @__PURE__ */ new Set()
174
174
  }, r = [];
175
- e.forEach((o) => {
176
- if (n.components.set(o.tag, o), o.style) {
177
- const c = typeof o.style == "function" ? o.style(o.state) : o.style;
175
+ e.forEach((i) => {
176
+ if (n.components.set(i.tag, i), i.style) {
177
+ const c = typeof i.style == "function" ? i.style(i.state) : i.style;
178
178
  n.styles.add(c);
179
179
  }
180
- const a = F(o, { ...t, includeStyles: !1 });
180
+ const a = F(i, { ...t, includeStyles: !1 });
181
181
  r.push(a);
182
182
  });
183
- const i = Array.from(n.styles).join(`
183
+ const o = Array.from(n.styles).join(`
184
184
  `);
185
185
  return { html: r.join(`
186
- `), styles: i, context: n };
186
+ `), styles: o, context: n };
187
187
  }
188
188
  function et(e) {
189
189
  const t = Array.from(e.components.entries()).map(([n, r]) => ({
@@ -243,8 +243,8 @@ function w(e, t) {
243
243
  if (Array.isArray(t[n])) {
244
244
  for (const r of t[n])
245
245
  if (r && typeof r == "object") {
246
- for (const i in r)
247
- if (typeof r[i] == "string" && e === r[i])
246
+ for (const o in r)
247
+ if (typeof r[o] == "string" && e === r[o])
248
248
  return $(e);
249
249
  }
250
250
  }
@@ -252,33 +252,33 @@ function w(e, t) {
252
252
  return String(e);
253
253
  }
254
254
  function nt(e, ...t) {
255
- function n(r, i, s) {
255
+ function n(r, o, s) {
256
256
  if (Array.isArray(r)) {
257
- const o = r.map((a) => n(a, i, s));
258
- return o.some((a) => a instanceof Promise) ? Promise.all(o).then((a) => a.join("")) : o.join("");
257
+ const i = r.map((a) => n(a, o, s));
258
+ return i.some((a) => a instanceof Promise) ? Promise.all(i).then((a) => a.join("")) : i.join("");
259
259
  }
260
260
  if (typeof r == "function") {
261
- const o = n(r(i, s), i, s);
262
- return o instanceof Promise, o;
261
+ const i = n(r(o, s), o, s);
262
+ return i instanceof Promise, i;
263
263
  }
264
264
  return r == null ? "" : r instanceof Promise ? r : String(r);
265
265
  }
266
- return (r, i) => {
267
- let s = "", o = !1;
266
+ return (r, o) => {
267
+ let s = "", i = !1;
268
268
  const a = [];
269
269
  for (let c = 0; c < e.length; c++)
270
270
  if (s += e[c], c < t.length) {
271
271
  let l = t[c];
272
272
  const d = e[c], f = /data-on-[a-z]+="?$/.test(d);
273
- l = n(l, r, i), l instanceof Promise ? (o = !0, a.push(l)) : /=\s*"?$/.test(d) && typeof l == "string" && !f ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), s += l) : !f && !/=\s*"?$/.test(d) ? s += w(l, r) : s += l;
273
+ l = n(l, r, o), l instanceof Promise ? (i = !0, a.push(l)) : /=\s*"?$/.test(d) && typeof l == "string" && !f ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), s += l) : !f && !/=\s*"?$/.test(d) ? s += w(l, r) : s += l;
274
274
  }
275
- return o ? Promise.all(a).then((c) => {
275
+ return i ? Promise.all(a).then((c) => {
276
276
  let l = "", d = 0;
277
277
  for (let f = 0; f < e.length; f++)
278
278
  if (l += e[f], f < t.length) {
279
279
  let u = t[f];
280
280
  const h = e[f], m = /data-on-[a-z]+="?$/.test(h);
281
- u = n(u, r, i), u instanceof Promise ? l += c[d++] : /=\s*"?$/.test(h) && typeof u == "string" && !m ? (u = u.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), l += u) : !m && !/=\s*"?$/.test(h) ? l += w(u, r) : l += u;
281
+ u = n(u, r, o), u instanceof Promise ? l += c[d++] : /=\s*"?$/.test(h) && typeof u == "string" && !m ? (u = u.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), l += u) : !m && !/=\s*"?$/.test(h) ? l += w(u, r) : l += u;
282
282
  }
283
283
  return l;
284
284
  }) : s;
@@ -286,20 +286,20 @@ function nt(e, ...t) {
286
286
  }
287
287
  function rt(e, ...t) {
288
288
  const n = "compiled-" + Math.random().toString(36).slice(2);
289
- function r(s, o, a) {
290
- return Array.isArray(s) ? s.map((c) => r(c, o, a)).join("") : typeof s == "function" ? r(s(o, a), o, a) : s == null ? "" : String(s);
289
+ function r(s, i, a) {
290
+ return Array.isArray(s) ? s.map((c) => r(c, i, a)).join("") : typeof s == "function" ? r(s(i, a), i, a) : s == null ? "" : String(s);
291
291
  }
292
- const i = (s, o) => {
292
+ const o = (s, i) => {
293
293
  let a = "";
294
294
  for (let c = 0; c < e.length; c++)
295
295
  if (a += e[c], c < t.length) {
296
296
  let l = t[c];
297
297
  const d = e[c], f = /data-on-[a-z]+="?$/.test(d);
298
- l = r(l, s, o), /=\s*"?$/.test(d) && typeof l == "string" && !f ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), a += l) : !f && !/=\s*"?$/.test(d) ? a += w(l, s) : a += l ?? "";
298
+ l = r(l, s, i), /=\s*"?$/.test(d) && typeof l == "string" && !f ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), a += l) : !f && !/=\s*"?$/.test(d) ? a += w(l, s) : a += l ?? "";
299
299
  }
300
300
  return a;
301
301
  };
302
- return i.id = n, i;
302
+ return o.id = n, o;
303
303
  }
304
304
  function st(e, ...t) {
305
305
  let n = "";
@@ -314,7 +314,7 @@ function ot(e) {
314
314
  return Object.entries(e).map(([t, n]) => `${t}: ${n}`).join("; ");
315
315
  }
316
316
  function U(e, t, n) {
317
- const [r, ...i] = n.split("|").map((a) => a.trim());
317
+ const [r, ...o] = n.split("|").map((a) => a.trim());
318
318
  if (!r || r === "__proto__" || r === "constructor" || r === "prototype") return;
319
319
  function s(a, c, l) {
320
320
  const d = c.split(".");
@@ -323,7 +323,7 @@ function U(e, t, n) {
323
323
  d[u] in f || (f[d[u]] = {}), f = f[d[u]];
324
324
  f[d[d.length - 1]] = l;
325
325
  }
326
- const o = (a) => {
326
+ const i = (a) => {
327
327
  let c;
328
328
  if (e instanceof HTMLInputElement && e.type === "checkbox") {
329
329
  c = e.value;
@@ -341,7 +341,7 @@ function U(e, t, n) {
341
341
  l !== null || d !== null ? e.checked ? s(t, r, l) : s(t, r, d !== null ? d : !1) : s(t, r, e.checked);
342
342
  } else e instanceof HTMLInputElement && e.type === "radio" ? (c = e.value, s(t, r, c), ((e.form || e.closest("form") || e.getRootNode()) instanceof Element ? (e.form || e.closest("form") || e.getRootNode()).querySelectorAll(`input[type="radio"][name="${e.name}"][data-model="${n}"]`) : []).forEach((d) => {
343
343
  d.checked = d.value === String(c);
344
- })) : (c = e.value, e instanceof HTMLInputElement && e.type === "number" && (c = Number(c)), i.includes("trim") && typeof c == "string" && (c = c.trim()), i.includes("number") && (c = Number(c)), s(t, r, c));
344
+ })) : (c = e.value, e instanceof HTMLInputElement && e.type === "number" && (c = Number(c)), o.includes("trim") && typeof c == "string" && (c = c.trim()), o.includes("number") && (c = Number(c)), s(t, r, c));
345
345
  if ("_vnode" in e && typeof e._vnode == "object" && e._vnode?.props && (e._vnode.props.value = c), a.type === "input" && (e._isDirty = !0), a.type === "keydown" && a.key === "Enter" && (e._isDirty = !1, e instanceof HTMLElement && e.isConnected)) {
346
346
  let l = e.parentElement;
347
347
  for (; l && !(l instanceof HTMLElement && l.shadowRoot); )
@@ -350,7 +350,7 @@ function U(e, t, n) {
350
350
  }
351
351
  a.type === "blur" && (e._isDirty = !1);
352
352
  };
353
- e.addEventListener("input", o), e.addEventListener("change", o), e.addEventListener("keydown", o), e.addEventListener("blur", o);
353
+ e.addEventListener("input", i), e.addEventListener("change", i), e.addEventListener("keydown", i), e.addEventListener("blur", i);
354
354
  }
355
355
  const R = (() => {
356
356
  try {
@@ -361,35 +361,35 @@ const R = (() => {
361
361
  return typeof window < "u" ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" : !1;
362
362
  })();
363
363
  function at(e, t = {}) {
364
- const { development: n = R, cache: r = !0, optimize: i = !0 } = t, s = N(e);
364
+ const { development: n = R, cache: r = !0, optimize: o = !0 } = t, s = N(e);
365
365
  if (r && T.has(s)) {
366
366
  if (n) {
367
- const o = E.get(s) || {
367
+ const i = E.get(s) || {
368
368
  compilationTime: 0,
369
369
  renderTime: 0,
370
370
  updateTime: 0,
371
371
  cacheHits: 0,
372
372
  cacheMisses: 0
373
373
  };
374
- o.cacheHits++, E.set(s, o);
374
+ i.cacheHits++, E.set(s, i);
375
375
  }
376
376
  return T.get(s);
377
377
  }
378
378
  if (n) {
379
- const o = E.get(s) || {
379
+ const i = E.get(s) || {
380
380
  compilationTime: 0,
381
381
  renderTime: 0,
382
382
  updateTime: 0,
383
383
  cacheHits: 0,
384
384
  cacheMisses: 0
385
385
  };
386
- o.cacheMisses++, E.set(s, o);
386
+ i.cacheMisses++, E.set(s, i);
387
387
  }
388
388
  try {
389
- const o = B(e, { development: n, optimize: i });
390
- return r && T.set(s, o), o;
391
- } catch (o) {
392
- return n && (console.error("[Template Compiler] Error compiling template:", o), console.error("[Template Compiler] Template:", e)), {
389
+ const i = B(e, { development: n, optimize: o });
390
+ return r && T.set(s, i), i;
391
+ } catch (i) {
392
+ return n && (console.error("[Template Compiler] Error compiling template:", i), console.error("[Template Compiler] Template:", e)), {
393
393
  statics: [e],
394
394
  dynamics: [],
395
395
  fragment: null,
@@ -437,14 +437,14 @@ class X {
437
437
  }
438
438
  compile() {
439
439
  this.parseTemplate();
440
- const t = this.createStaticFragment(), n = N(this.template), r = (i, s) => {
441
- let o = "";
440
+ const t = this.createStaticFragment(), n = N(this.template), r = (o, s) => {
441
+ let i = "";
442
442
  for (let a = 0; a < this.statics.length; a++)
443
- if (o += this.statics[a], a < this.dynamics.length) {
444
- let c = this.dynamics[a].getValue(i, s);
443
+ if (i += this.statics[a], a < this.dynamics.length) {
444
+ let c = this.dynamics[a].getValue(o, s);
445
445
  if (c instanceof Promise)
446
446
  return Promise.all(this.dynamics.map((l) => {
447
- const d = l.getValue(i, s);
447
+ const d = l.getValue(o, s);
448
448
  return d instanceof Promise ? d : Promise.resolve(d);
449
449
  })).then((l) => {
450
450
  let d = "";
@@ -452,9 +452,9 @@ class X {
452
452
  d += this.statics[f], f < l.length && (d += l[f]);
453
453
  return d;
454
454
  });
455
- o += c;
455
+ i += c;
456
456
  }
457
- return o;
457
+ return i;
458
458
  };
459
459
  return {
460
460
  statics: this.statics,
@@ -471,7 +471,7 @@ class X {
471
471
  for (; (r = t.exec(this.template)) !== null; ) {
472
472
  const s = this.template.slice(n, r.index);
473
473
  this.statics.push(s);
474
- let o = s.match(/([a-zA-Z0-9_-]+)\s*=\s*"?$/), a = o ? o[1] : void 0, c;
474
+ let i = s.match(/([a-zA-Z0-9_-]+)\s*=\s*"?$/), a = i ? i[1] : void 0, c;
475
475
  if (s.endsWith('style="color:'))
476
476
  a = "style", c = "color";
477
477
  else if (a === "style") {
@@ -481,34 +481,34 @@ class X {
481
481
  const l = r[1].trim();
482
482
  this.analyzeDynamicExpression(l, this.dynamics.length, a, c), n = r.index + r[0].length;
483
483
  }
484
- const i = this.template.slice(n);
485
- this.statics.push(i);
484
+ const o = this.template.slice(n);
485
+ this.statics.push(o);
486
486
  }
487
- analyzeDynamicExpression(t, n, r, i) {
488
- let s = "text", o;
489
- r ? r === "class" ? (s = "class", o = "class") : r === "style" ? (s = "style", o = i || "style") : r === "value" ? (s = "property", o = "value") : (s = "attribute", o = r) : t.includes("class.") ? (s = "class", o = t.split(".")[1]) : t.includes("style.") ? (s = "style", o = t.split(".")[1]) : t.includes("@") ? (s = "event", o = t.split("@")[1]) : t === "class" ? (s = "class", o = "class") : t === "style" ? (s = "style", o = "style") : t === "value" ? (s = "property", o = "value") : t === "title" && (s = "attribute", o = "title");
487
+ analyzeDynamicExpression(t, n, r, o) {
488
+ let s = "text", i;
489
+ r ? r === "class" ? (s = "class", i = "class") : r === "style" ? (s = "style", i = o || "style") : r === "value" ? (s = "property", i = "value") : (s = "attribute", i = r) : t.includes("class.") ? (s = "class", i = t.split(".")[1]) : t.includes("style.") ? (s = "style", i = t.split(".")[1]) : t.includes("@") ? (s = "event", i = t.split("@")[1]) : t === "class" ? (s = "class", i = "class") : t === "style" ? (s = "style", i = "style") : t === "value" ? (s = "property", i = "value") : t === "title" && (s = "attribute", i = "title");
490
490
  const a = `__DYNAMIC_${n}__`, c = this.statics.join(a);
491
491
  let l = Z(c, a);
492
492
  this.statics.length === 2 && s !== "text" ? l = [0] : this.statics.length === 2 && l.length === 0 && (l = [0]), this.dynamics.push({
493
493
  path: l,
494
494
  type: s,
495
- target: o,
495
+ target: i,
496
496
  getValue: this.createValueGetter(t)
497
497
  });
498
498
  }
499
499
  createValueGetter(t) {
500
500
  return (n, r) => {
501
501
  try {
502
- let i;
502
+ let o;
503
503
  if (t && typeof t == "function")
504
- i = t(n);
504
+ o = t(n);
505
505
  else if (typeof t == "string" && t.startsWith("state.")) {
506
506
  const s = t.slice(6);
507
- i = n[s];
508
- } else typeof t == "string" && /^[a-zA-Z0-9_$]+$/.test(t) ? i = n[t] : (typeof t == "string" && t.includes("("), i = "");
509
- return i;
510
- } catch (i) {
511
- return this.options.development && console.warn(`[Template Compiler] Error evaluating expression: ${t}`, i), "";
507
+ o = n[s];
508
+ } else typeof t == "string" && /^[a-zA-Z0-9_$]+$/.test(t) ? o = n[t] : (typeof t == "string" && t.includes("("), o = "");
509
+ return o;
510
+ } catch (o) {
511
+ return this.options.development && console.warn(`[Template Compiler] Error evaluating expression: ${t}`, o), "";
512
512
  }
513
513
  };
514
514
  }
@@ -519,10 +519,10 @@ class X {
519
519
  const t = this.statics.join("");
520
520
  if (!t.trim())
521
521
  return null;
522
- const r = new DOMParser().parseFromString(t, "text/html"), i = document.createDocumentFragment();
522
+ const r = new DOMParser().parseFromString(t, "text/html"), o = document.createDocumentFragment();
523
523
  for (; r.body.firstChild; )
524
- i.appendChild(r.body.firstChild);
525
- return i;
524
+ o.appendChild(r.body.firstChild);
525
+ return o;
526
526
  } catch (t) {
527
527
  return this.options.development && console.warn("[Template Compiler] Could not create static fragment:", t), null;
528
528
  }
@@ -534,10 +534,10 @@ function O(e, t) {
534
534
  return e;
535
535
  let n = e;
536
536
  for (let r = 0; r < t.length; r++) {
537
- const i = t[r];
538
- if (!n.childNodes || n.childNodes.length <= i)
537
+ const o = t[r];
538
+ if (!n.childNodes || n.childNodes.length <= o)
539
539
  return null;
540
- n = n.childNodes[i];
540
+ n = n.childNodes[o];
541
541
  }
542
542
  return n;
543
543
  } catch {
@@ -548,16 +548,16 @@ function j(e, t, n) {
548
548
  let r;
549
549
  return e.fragment && !e.hasDynamics ? r = e.fragment.cloneNode(!0) : r = Y(e, t, n), r;
550
550
  }
551
- function V(e, t, n, r, i) {
551
+ function V(e, t, n, r, o) {
552
552
  if (e.hasDynamics)
553
553
  for (const s of e.dynamics)
554
554
  try {
555
- const o = s.getValue(n, r);
556
- if (i !== void 0 && s.getValue(i, r) === o)
555
+ const i = s.getValue(n, r);
556
+ if (o !== void 0 && s.getValue(o, r) === i)
557
557
  continue;
558
- I(t, s, o);
559
- } catch (o) {
560
- console.warn("[Template Compiler] Error applying update:", o);
558
+ I(t, s, i);
559
+ } catch (i) {
560
+ console.warn("[Template Compiler] Error applying update:", i);
561
561
  }
562
562
  }
563
563
  function Y(e, t, n) {
@@ -572,28 +572,28 @@ function Y(e, t, n) {
572
572
  }
573
573
  if (typeof document > "u")
574
574
  return new DocumentFragment();
575
- const s = new DOMParser().parseFromString(r, "text/html"), o = document.createDocumentFragment();
575
+ const s = new DOMParser().parseFromString(r, "text/html"), i = document.createDocumentFragment();
576
576
  for (; s.body.firstChild; )
577
- o.appendChild(s.body.firstChild);
577
+ i.appendChild(s.body.firstChild);
578
578
  for (const a of e.dynamics) {
579
- const c = a.getValue(t, n), l = O(o, a.path);
579
+ const c = a.getValue(t, n), l = O(i, a.path);
580
580
  I(l, a, c);
581
581
  }
582
- return o;
582
+ return i;
583
583
  }
584
584
  function I(e, t, n) {
585
585
  try {
586
586
  if (t.type === "text") {
587
- const i = document.createTreeWalker(
587
+ const o = document.createTreeWalker(
588
588
  e,
589
589
  NodeFilter.SHOW_TEXT
590
590
  );
591
- let s = !1, o;
592
- for (; o = i.nextNode(); ) {
593
- const c = o.textContent || "";
591
+ let s = !1, i;
592
+ for (; i = o.nextNode(); ) {
593
+ const c = i.textContent || "";
594
594
  if (c.includes("Count: ")) {
595
595
  const l = c.replace(/Count: \d+/, `Count: ${n}`);
596
- o.textContent = l, s = !0;
596
+ i.textContent = l, s = !0;
597
597
  }
598
598
  }
599
599
  if (s) return;
@@ -607,8 +607,8 @@ function I(e, t, n) {
607
607
  switch (t.type) {
608
608
  case "attribute":
609
609
  if (r.nodeType === Node.ELEMENT_NODE && t.target) {
610
- const i = r;
611
- n == null || n === "" ? i.removeAttribute(t.target) : i.setAttribute(t.target, String(n));
610
+ const o = r;
611
+ n == null || n === "" ? o.removeAttribute(t.target) : o.setAttribute(t.target, String(n));
612
612
  }
613
613
  break;
614
614
  case "property":
@@ -616,14 +616,14 @@ function I(e, t, n) {
616
616
  break;
617
617
  case "class":
618
618
  if (r.nodeType === Node.ELEMENT_NODE && t.target) {
619
- const i = r;
620
- i.className = n == null ? "" : String(n), i.setAttribute("class", n == null ? "" : String(n));
619
+ const o = r;
620
+ o.className = n == null ? "" : String(n), o.setAttribute("class", n == null ? "" : String(n));
621
621
  }
622
622
  break;
623
623
  case "style":
624
624
  if (r.nodeType === Node.ELEMENT_NODE && t.target) {
625
- const i = r;
626
- i.style[t.target] = n == null ? "" : String(n), i.setAttribute("style", n == null ? `${t.target}:` : `${t.target}:${n}`);
625
+ const o = r;
626
+ o.style[t.target] = n == null ? "" : String(n), o.setAttribute("style", n == null ? `${t.target}:` : `${t.target}:${n}`);
627
627
  }
628
628
  break;
629
629
  default:
@@ -642,8 +642,8 @@ function N(e) {
642
642
  }
643
643
  return `tpl_${Math.abs(t).toString(36)}`;
644
644
  }
645
- function x(e, t, n, r, i) {
646
- return r && i ? `${t}.${e}[${n}]:${r}:${i}` : r ? `${t}.${e}[${n}]:${r}` : `${t}.${e}[${n}]`;
645
+ function x(e, t, n, r, o) {
646
+ return r && o ? `${t}.${e}[${n}]:${r}:${o}` : r ? `${t}.${e}[${n}]:${r}` : `${t}.${e}[${n}]`;
647
647
  }
648
648
  function D(e, t, n) {
649
649
  if (!(!e || !(e instanceof Element)) && e.contains(n) && n.parentNode === e)
@@ -685,7 +685,7 @@ function J(e) {
685
685
  type: "#fragment",
686
686
  key: void 0,
687
687
  props: {},
688
- children: n.map((i, s) => k(i, "#fragment", s)),
688
+ children: n.map((o, s) => k(o, "#fragment", s)),
689
689
  dom: void 0
690
690
  };
691
691
  }
@@ -695,23 +695,23 @@ function k(e, t = "", n = 0) {
695
695
  if (e.nodeType === Node.TEXT_NODE)
696
696
  return !e.nodeValue || /^\s*$/.test(e.nodeValue) ? { type: "#whitespace", key: void 0, props: {}, children: [], dom: void 0 } : { type: "#text", key: x("#text", t, n), props: { nodeValue: e.nodeValue }, children: [], dom: e };
697
697
  if (e.nodeType === Node.ELEMENT_NODE) {
698
- const r = e, i = {};
698
+ const r = e, o = {};
699
699
  Array.from(r.attributes).forEach((l) => {
700
- i[l.name] = l.value;
700
+ o[l.name] = l.value;
701
701
  });
702
702
  const s = r.tagName.toLowerCase();
703
- let o;
703
+ let i;
704
704
  if ((s === "input" || s === "select" || s === "textarea") && r.hasAttribute("data-model")) {
705
705
  const l = r.getAttribute("data-model"), d = r.getAttribute("type") ?? "";
706
- o = `${s}:${l}:${d}`, i["data-uid"] = o, r.setAttribute("data-uid", o);
706
+ i = `${s}:${l}:${d}`, o["data-uid"] = i, r.setAttribute("data-uid", i);
707
707
  let f = r.getAttribute("value"), u = r.getAttribute("checked");
708
- f && (i.value = f), u && (i.checked = u);
709
- } else s === "input" || s === "textarea" || s === "select" || r.hasAttribute("contenteditable") ? (o = `${s}:${t}:${n}`, i["data-uid"] = o, r.setAttribute("data-uid", o)) : (o = x(s, t, n), s === "li" && (i["data-uid"] = o, r.setAttribute("data-uid", o)));
710
- const a = Array.from(r.childNodes).map((l, d) => k(l, o, d));
708
+ f && (o.value = f), u && (o.checked = u);
709
+ } else s === "input" || s === "textarea" || s === "select" || r.hasAttribute("contenteditable") ? (i = `${s}:${t}:${n}`, o["data-uid"] = i, r.setAttribute("data-uid", i)) : (i = x(s, t, n), s === "li" && (o["data-uid"] = i, r.setAttribute("data-uid", i)));
710
+ const a = Array.from(r.childNodes).map((l, d) => k(l, i, d));
711
711
  return {
712
712
  type: s,
713
- key: o,
714
- props: i,
713
+ key: i,
714
+ props: o,
715
715
  children: a,
716
716
  dom: r
717
717
  };
@@ -723,17 +723,17 @@ function L(e, t, n) {
723
723
  function r(c) {
724
724
  return !!c && c.type !== "#whitespace" && !(c.type === "#text" && (!c.props?.nodeValue || /^\s*$/.test(c.props.nodeValue)));
725
725
  }
726
- const i = Array.isArray(t.children) ? t.children.filter(r) : [], s = Array.isArray(n.children) ? n.children.filter(r) : [], o = n.type === "input" || n.type === "select" || n.type === "textarea";
726
+ const o = Array.isArray(t.children) ? t.children.filter(r) : [], s = Array.isArray(n.children) ? n.children.filter(r) : [], i = n.type === "input" || n.type === "select" || n.type === "textarea";
727
727
  if (t.type !== n.type || t.key !== n.key) {
728
728
  const c = g(n);
729
729
  if (c instanceof Node && t.dom instanceof Node && e.contains(t.dom)) {
730
- if (D(e, c, t.dom), o && n.props && e.firstChild instanceof HTMLInputElement) {
730
+ if (D(e, c, t.dom), i && n.props && e.firstChild instanceof HTMLInputElement) {
731
731
  const l = e.firstChild;
732
732
  l.type === "radio" || l.type, l.value = n.props.value, l.setAttribute("value", n.props.value), "checked" in n.props && (l.checked = n.props.checked === !0 || n.props.checked === "true");
733
733
  }
734
734
  } else if (c instanceof Node)
735
735
  if (c) {
736
- if (e.appendChild(c), n.dom = c, o && n.props && e.firstChild instanceof HTMLInputElement) {
736
+ if (e.appendChild(c), n.dom = c, i && n.props && e.firstChild instanceof HTMLInputElement) {
737
737
  const l = e.firstChild;
738
738
  l.type === "radio" ? l.setAttribute("value", n.props.value) : (l.type, l.value = n.props.value, l.setAttribute("value", n.props.value)), "checked" in n.props && (l.checked = n.props.checked === !0 || n.props.checked === "true");
739
739
  }
@@ -743,7 +743,7 @@ function L(e, t, n) {
743
743
  n.dom = void 0;
744
744
  return;
745
745
  }
746
- if (o && t.dom instanceof HTMLElement && n.props) {
746
+ if (i && t.dom instanceof HTMLElement && n.props) {
747
747
  for (const [c, l] of Object.entries(n.props))
748
748
  if (c === "value" && e.firstChild instanceof HTMLInputElement)
749
749
  e.firstChild.value = l;
@@ -756,8 +756,8 @@ function L(e, t, n) {
756
756
  }
757
757
  else
758
758
  t.dom.setAttribute(c, l);
759
- for (let c = n.children.length; c < i.length; c++)
760
- i[c] && i[c].dom && t.dom && t.dom.contains(i[c].dom) && t.dom.removeChild(i[c].dom);
759
+ for (let c = n.children.length; c < o.length; c++)
760
+ o[c] && o[c].dom && t.dom && t.dom.contains(o[c].dom) && t.dom.removeChild(o[c].dom);
761
761
  return;
762
762
  }
763
763
  const a = t.dom;
@@ -791,11 +791,11 @@ function L(e, t, n) {
791
791
  }
792
792
  if (a instanceof Element) {
793
793
  const c = /* @__PURE__ */ new Map();
794
- i.forEach((u) => u.key && c.set(u.key, u));
794
+ o.forEach((u) => u.key && c.set(u.key, u));
795
795
  const l = new Set(s.map((u) => u.key));
796
796
  let d = [];
797
797
  for (let u = 0; u < s.length; u++) {
798
- const h = s[u], m = h.key ? c.get(h.key) : i[u];
798
+ const h = s[u], m = h.key ? c.get(h.key) : o[u];
799
799
  let p;
800
800
  const A = h.type === "input" || h.type === "select" || h.type === "textarea";
801
801
  if (m && m.dom && (!A || m.type === h.type && m.key === h.key))
@@ -817,7 +817,7 @@ function L(e, t, n) {
817
817
  }
818
818
  h.dom = p, p && d.push(p);
819
819
  }
820
- for (i.forEach((u) => {
820
+ for (o.forEach((u) => {
821
821
  !l.has(u.key) && u.dom && a.contains(u.dom) && a.removeChild(u.dom);
822
822
  }); a.childNodes.length > s.length; )
823
823
  a.removeChild(a.lastChild);
@@ -836,9 +836,9 @@ function L(e, t, n) {
836
836
  }
837
837
  }
838
838
  function M(e, t) {
839
- const n = [], r = t ? Object.keys(t) : [], i = { ...e };
839
+ const n = [], r = t ? Object.keys(t) : [], o = { ...e };
840
840
  let s = null;
841
- function o(d) {
841
+ function i(d) {
842
842
  return n.push(d), () => {
843
843
  const f = n.indexOf(d);
844
844
  f !== -1 && n.splice(f, 1);
@@ -852,7 +852,7 @@ function M(e, t) {
852
852
  if (c.has(d)) return c.get(d);
853
853
  const f = new Proxy(d, {
854
854
  get(u, h, m) {
855
- if (h === "subscribe") return o;
855
+ if (h === "subscribe") return i;
856
856
  if (h === "set") return a;
857
857
  if (t && r.includes(h))
858
858
  return t[h](s);
@@ -874,7 +874,7 @@ function M(e, t) {
874
874
  });
875
875
  return c.set(d, f), f;
876
876
  }
877
- return s = l(i), s;
877
+ return s = l(o), s;
878
878
  }
879
879
  const v = [];
880
880
  function ct(e) {
@@ -882,11 +882,11 @@ function ct(e) {
882
882
  }
883
883
  function _(e, t = /* @__PURE__ */ new WeakSet()) {
884
884
  if (e === null || typeof e != "object" || t.has(e)) return e;
885
- if (t.add(e), Array.isArray(e)) return e.map((i) => _(i, t));
885
+ if (t.add(e), Array.isArray(e)) return e.map((o) => _(o, t));
886
886
  Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null && Object.setPrototypeOf(e, null);
887
887
  const n = ["__proto__", "constructor", "prototype"], r = /* @__PURE__ */ Object.create(null);
888
- for (const i of Object.keys(e))
889
- n.includes(i) || (r[i] = _(e[i], t));
888
+ for (const o of Object.keys(e))
889
+ n.includes(o) || (r[o] = _(e[o], t));
890
890
  return r;
891
891
  }
892
892
  function S(e) {
@@ -947,18 +947,18 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
947
947
  attributeChangedCallback(e, t, n) {
948
948
  if (!(e === "__proto__" || e === "constructor" || e === "prototype") && this.stateObj && e in this.stateObj) {
949
949
  const r = typeof this.config?.state?.[e];
950
- let i = n;
950
+ let o = n;
951
951
  if (n === null)
952
- i = void 0;
952
+ o = void 0;
953
953
  else if (r === "number")
954
- if (i === void 0 || i === "")
955
- i = this.config?.state?.[e];
954
+ if (o === void 0 || o === "")
955
+ o = this.config?.state?.[e];
956
956
  else {
957
- const s = Number(i);
958
- i = isNaN(s) ? this.config?.state?.[e] : s;
957
+ const s = Number(o);
958
+ o = isNaN(s) ? this.config?.state?.[e] : s;
959
959
  }
960
- else r === "boolean" && (i = i === "true");
961
- i = _(i), this.stateObj[e] !== i && (this.config?.debug && console.log("[runtime] state update:", { name: e, value: i }), this.stateObj[e] = i, this.render());
960
+ else r === "boolean" && (o = o === "true");
961
+ o = _(o), this.stateObj[e] !== o && (this.config?.debug && console.log("[runtime] state update:", { name: e, value: o }), this.stateObj[e] = o, this.render());
962
962
  }
963
963
  }
964
964
  /**
@@ -968,14 +968,14 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
968
968
  this.shadowRoot && (this.shadowRoot.querySelectorAll("input[data-model]").forEach((e) => {
969
969
  const t = e.getAttribute("data-model");
970
970
  if (!t || !this.stateObj || typeof this.stateObj[t] > "u") return;
971
- const n = e, r = String(this.stateObj[t]), i = document.activeElement === n;
971
+ const n = e, r = String(this.stateObj[t]), o = document.activeElement === n;
972
972
  n._hasDirtyListener || (n.addEventListener("input", () => {
973
973
  n._isDirty = !0;
974
974
  }), n.addEventListener("blur", () => {
975
975
  n._isDirty = !1;
976
976
  }), n._hasDirtyListener = !0);
977
977
  const s = !!n._isDirty;
978
- i || s || n.type !== "radio" && n.type !== "checkbox" && n.value !== r && (n.value = r);
978
+ o || s || n.type !== "radio" && n.type !== "checkbox" && n.value !== r && (n.value = r);
979
979
  }), this.rebindEventListeners());
980
980
  }
981
981
  /**
@@ -993,12 +993,12 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
993
993
  if (!t || !this.stateObj || typeof this.stateObj[t] > "u") return;
994
994
  const n = e, r = String(this.stateObj[t]);
995
995
  if (n.type === "checkbox") {
996
- const i = this.stateObj[t];
997
- if (Array.isArray(i))
998
- n.checked = i.includes(n.value);
996
+ const o = this.stateObj[t];
997
+ if (Array.isArray(o))
998
+ n.checked = o.includes(n.value);
999
999
  else {
1000
- const s = n.getAttribute("data-true-value"), o = n.getAttribute("data-false-value");
1001
- s !== null || o !== null ? String(i) === s ? n.checked = !0 : String(i) === o ? n.checked = !1 : i === !0 ? n.checked = !0 : n.checked = !1 : n.checked = i === !0 || i === "true" || i === 1;
1000
+ const s = n.getAttribute("data-true-value"), i = n.getAttribute("data-false-value");
1001
+ s !== null || i !== null ? String(o) === s ? n.checked = !0 : String(o) === i ? n.checked = !1 : o === !0 ? n.checked = !0 : n.checked = !1 : n.checked = o === !0 || o === "true" || o === 1;
1002
1002
  }
1003
1003
  } else n.type === "radio" || (n.value = r);
1004
1004
  }), this.shadowRoot.querySelectorAll("textarea[data-model]").forEach((e) => {
@@ -1019,17 +1019,17 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1019
1019
  e._listItemModelListener && (e.removeEventListener("input", e._listItemModelListener), e.removeEventListener("change", e._listItemModelListener), delete e._listItemModelListener);
1020
1020
  const n = t.match(/^([a-zA-Z0-9_]+)\[(\d+)\]\.([a-zA-Z0-9_]+)$/);
1021
1021
  if (n) {
1022
- const [, i, s, o] = n, a = parseInt(s, 10), c = this.stateObj[i];
1023
- e instanceof HTMLInputElement && e.type === "checkbox" && (e.checked = !!(Array.isArray(c) && c[a] && c[a][o]));
1022
+ const [, o, s, i] = n, a = parseInt(s, 10), c = this.stateObj[o];
1023
+ e instanceof HTMLInputElement && e.type === "checkbox" && (e.checked = !!(Array.isArray(c) && c[a] && c[a][i]));
1024
1024
  const l = (d) => {
1025
- !Array.isArray(c) || !c[a] || (e instanceof HTMLInputElement && e.type === "checkbox" ? c[a][o] = e.checked : c[a][o] = e.value);
1025
+ !Array.isArray(c) || !c[a] || (e instanceof HTMLInputElement && e.type === "checkbox" ? c[a][i] = e.checked : c[a][i] = e.value);
1026
1026
  };
1027
1027
  e.addEventListener("input", l), e.addEventListener("change", l), e._listItemModelListener = l;
1028
1028
  return;
1029
1029
  }
1030
1030
  const r = t.match(/^([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)((?:\|[a-zA-Z0-9_]+)*)$/);
1031
1031
  if (r) {
1032
- const [, i, s, o] = r, a = this.stateObj[i], c = o ? o.split("|").map((d) => d.trim()).filter(Boolean) : [];
1032
+ const [, o, s, i] = r, a = this.stateObj[o], c = i ? i.split("|").map((d) => d.trim()).filter(Boolean) : [];
1033
1033
  e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked = !!(a && a[s]) : e instanceof HTMLInputElement && (e.value = a ? String(a[s] ?? "") : "");
1034
1034
  const l = (d) => {
1035
1035
  if (!a) return;
@@ -1053,8 +1053,8 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1053
1053
  if (!(!n || !(n in this.stateObj)))
1054
1054
  if (t instanceof HTMLInputElement)
1055
1055
  if (t.type === "checkbox") {
1056
- const r = this.stateObj[n], i = t.getAttribute("data-true-value"), s = t.getAttribute("data-false-value");
1057
- Array.isArray(r) ? t.checked = r.includes(t.value) : i !== null || s !== null ? String(r) === i ? t.checked = !0 : String(r) === s ? t.checked = !1 : r === !0 ? t.checked = !0 : t.checked = !1 : t.checked = r === !0 || r === "true" || r === 1;
1056
+ const r = this.stateObj[n], o = t.getAttribute("data-true-value"), s = t.getAttribute("data-false-value");
1057
+ Array.isArray(r) ? t.checked = r.includes(t.value) : o !== null || s !== null ? String(r) === o ? t.checked = !0 : String(r) === s ? t.checked = !1 : r === !0 ? t.checked = !0 : t.checked = !1 : t.checked = r === !0 || r === "true" || r === 1;
1058
1058
  } else t.type === "radio" ? t.checked = t.value === String(this.stateObj[n]) : t.value = String(this.stateObj[n] ?? "");
1059
1059
  else (t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) && (t.value = String(this.stateObj[n] ?? ""));
1060
1060
  }));
@@ -1087,20 +1087,20 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1087
1087
  this.scheduleRender();
1088
1088
  })), this.api = {
1089
1089
  state: this.stateObj,
1090
- emit: (s, o) => this.dispatchEvent(new CustomEvent(s, { detail: o, bubbles: !0 })),
1091
- onGlobal: (s, o) => {
1092
- const a = C.on(s, o);
1090
+ emit: (s, i) => this.dispatchEvent(new CustomEvent(s, { detail: i, bubbles: !0 })),
1091
+ onGlobal: (s, i) => {
1092
+ const a = C.on(s, i);
1093
1093
  return this._globalUnsubscribes.push(a), a;
1094
1094
  },
1095
- offGlobal: (s, o) => C.off(s, o),
1096
- emitGlobal: (s, o) => C.emit(s, o)
1095
+ offGlobal: (s, i) => C.off(s, i),
1096
+ emitGlobal: (s, i) => C.emit(s, i)
1097
1097
  }, Object.keys(this.config).forEach((s) => {
1098
1098
  if (s.startsWith("on") && s.length > 2 && typeof this.config[s] == "function") {
1099
- const o = s.charAt(2).toLowerCase() + s.slice(3), a = (c) => {
1099
+ const i = s.charAt(2).toLowerCase() + s.slice(3), a = (c) => {
1100
1100
  const l = c.detail ?? c;
1101
1101
  this.config[s](l, this.api.state, this.api);
1102
1102
  };
1103
- this.addEventListener(o, a), this._autoWiredHandlers[o] || (this._autoWiredHandlers[o] = []), this._autoWiredHandlers[o].push(a);
1103
+ this.addEventListener(i, a), this._autoWiredHandlers[i] || (this._autoWiredHandlers[i] = []), this._autoWiredHandlers[i].push(a);
1104
1104
  }
1105
1105
  }), this.attachShadow({ mode: "open" }), n.style) {
1106
1106
  const s = document.createElement("style");
@@ -1109,22 +1109,22 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1109
1109
  if (typeof this.config.hydrate == "function") {
1110
1110
  const s = this.shadowRoot?.querySelectorAll("[data-hydrate]");
1111
1111
  try {
1112
- s && s.length > 0 ? s.forEach((o) => {
1112
+ s && s.length > 0 ? s.forEach((i) => {
1113
1113
  try {
1114
- this.config.hydrate(o, this.stateObj, this.api);
1114
+ this.config.hydrate(i, this.stateObj, this.api);
1115
1115
  } catch (a) {
1116
1116
  typeof this.config.onError == "function" && this.config.onError(a instanceof Error ? a : new Error(String(a)), this.api.state, this.api), this._handleRenderError(a);
1117
1117
  }
1118
1118
  }) : this.config.hydrate(this.shadowRoot, this.stateObj, this.api);
1119
- } catch (o) {
1120
- typeof this.config.onError == "function" && this.config.onError(o instanceof Error ? o : new Error(String(o)), this.api.state, this.api), this._handleRenderError(o);
1119
+ } catch (i) {
1120
+ typeof this.config.onError == "function" && this.config.onError(i instanceof Error ? i : new Error(String(i)), this.api.state, this.api), this._handleRenderError(i);
1121
1121
  }
1122
1122
  }
1123
1123
  if (this.hasAttribute("data-hydrated") ? this.processRefs() : this.render(), !this._mountedCalled && typeof this.config.onMounted == "function")
1124
1124
  try {
1125
1125
  const s = this.config.onMounted(this.api.state, this.api);
1126
- S(s) ? s.catch((o) => {
1127
- typeof this.config.onError == "function" && this.config.onError(o, this.api.state, this.api), this._handleRenderError(o);
1126
+ S(s) ? s.catch((i) => {
1127
+ typeof this.config.onError == "function" && this.config.onError(i, this.api.state, this.api), this._handleRenderError(i);
1128
1128
  }).finally(() => {
1129
1129
  this._mountedCalled = !0;
1130
1130
  }) : this._mountedCalled = !0;
@@ -1215,11 +1215,11 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1215
1215
  if (!this.shadowRoot) return;
1216
1216
  ["data-on-input", "data-on-change", "data-on-blur", "data-on-click"].forEach((t) => {
1217
1217
  this.shadowRoot.querySelectorAll(`[${t}]`).forEach((n) => {
1218
- const r = t.replace("data-on-", ""), i = n.getAttribute(t);
1219
- if (!i || typeof this.config[i] != "function") return;
1218
+ const r = t.replace("data-on-", ""), o = n.getAttribute(t);
1219
+ if (!o || typeof this.config[o] != "function") return;
1220
1220
  n._boundHandlers && n._boundHandlers[r] && n.removeEventListener(r, n._boundHandlers[r]);
1221
- const s = this.config[i], o = (a) => s.call(this, a);
1222
- n.addEventListener(r, o), n._boundHandlers || (n._boundHandlers = {}), n._boundHandlers[r] = o;
1221
+ const s = this.config[o], i = (a) => s.call(this, a);
1222
+ n.addEventListener(r, i), n._boundHandlers || (n._boundHandlers = {}), n._boundHandlers[r] = i;
1223
1223
  });
1224
1224
  }), Array.from(this.shadowRoot.children).forEach((t) => {
1225
1225
  t instanceof HTMLElement && typeof t.rebindEventListeners == "function" && t.rebindEventListeners();
@@ -1235,15 +1235,15 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1235
1235
  try {
1236
1236
  let t = function(n) {
1237
1237
  const r = /* @__PURE__ */ new WeakSet();
1238
- function i(s) {
1238
+ function o(s) {
1239
1239
  if (s === null || typeof s != "object" || r.has(s)) return s;
1240
- if (r.add(s), Array.isArray(s)) return s.map(i);
1241
- const o = {};
1240
+ if (r.add(s), Array.isArray(s)) return s.map(o);
1241
+ const i = {};
1242
1242
  for (const a in s)
1243
- Object.prototype.hasOwnProperty.call(s, a) && (o[a] = i(s[a]));
1244
- return o;
1243
+ Object.prototype.hasOwnProperty.call(s, a) && (i[a] = o(s[a]));
1244
+ return i;
1245
1245
  }
1246
- return i(n);
1246
+ return o(n);
1247
1247
  };
1248
1248
  if (typeof e == "string") {
1249
1249
  let n = function(c) {
@@ -1254,14 +1254,14 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1254
1254
  }, r = function(c) {
1255
1255
  c.children.forEach(r);
1256
1256
  };
1257
- const i = n(e), s = J(i);
1257
+ const o = n(e), s = J(o);
1258
1258
  r(s);
1259
- const o = this.shadowRoot;
1260
- if (!o)
1259
+ const i = this.shadowRoot;
1260
+ if (!i)
1261
1261
  return;
1262
- let a = o.querySelector("style");
1263
- if (a || (a = document.createElement("style"), o.appendChild(a)), this.config.style ? a.textContent = typeof this.config.style == "function" ? this.config.style(this.stateObj) : this.config.style : a.textContent = "", s.type === "#fragment") {
1264
- const c = Array.from(o.childNodes).find(
1262
+ let a = i.querySelector("style");
1263
+ if (a || (a = document.createElement("style"), i.appendChild(a)), this.config.style ? a.textContent = typeof this.config.style == "function" ? this.config.style(this.stateObj) : this.config.style : a.textContent = "", s.type === "#fragment") {
1264
+ const c = Array.from(i.childNodes).find(
1265
1265
  (l) => l.nodeType === 1 && l !== a
1266
1266
  );
1267
1267
  if (c) {
@@ -1279,7 +1279,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1279
1279
  } else
1280
1280
  s.children.forEach((l) => {
1281
1281
  const d = g(l);
1282
- d && o.appendChild(d), l.dom = d ?? void 0;
1282
+ d && i.appendChild(d), l.dom = d ?? void 0;
1283
1283
  });
1284
1284
  } else {
1285
1285
  let c = Array.from(this.shadowRoot.childNodes).find(
@@ -1299,19 +1299,19 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1299
1299
  } else {
1300
1300
  const n = !this.shadowRoot.firstElementChild, r = this.lastCompiledTemplate?.id === e.id;
1301
1301
  if (n) {
1302
- const i = j(e, this.stateObj, this.api);
1303
- this.shadowRoot.appendChild(i);
1302
+ const o = j(e, this.stateObj, this.api);
1303
+ this.shadowRoot.appendChild(o);
1304
1304
  } else if (r && this.shadowRoot.firstElementChild) {
1305
- const i = this.lastState;
1306
- V(e, this.shadowRoot.firstElementChild, this.stateObj, this.api, i || void 0);
1305
+ const o = this.lastState;
1306
+ V(e, this.shadowRoot.firstElementChild, this.stateObj, this.api, o || void 0);
1307
1307
  } else {
1308
- const i = j(e, this.stateObj, this.api);
1308
+ const o = j(e, this.stateObj, this.api);
1309
1309
  let s = this.shadowRoot.querySelector("style");
1310
1310
  s || (s = document.createElement("style"), this.shadowRoot.insertBefore(s, this.shadowRoot.firstChild)), this.config.style ? s.textContent = typeof this.config.style == "function" ? this.config.style(this.stateObj) : this.config.style : s.textContent = "";
1311
- let o = this.shadowRoot.querySelector("[data-root]");
1312
- for (o || (o = document.createElement("div"), o.setAttribute("data-root", ""), this.shadowRoot.appendChild(o)); o.firstChild; )
1313
- o.removeChild(o.firstChild);
1314
- o.appendChild(i);
1311
+ let i = this.shadowRoot.querySelector("[data-root]");
1312
+ for (i || (i = document.createElement("div"), i.setAttribute("data-root", ""), this.shadowRoot.appendChild(i)); i.firstChild; )
1313
+ i.removeChild(i.firstChild);
1314
+ i.appendChild(o);
1315
1315
  }
1316
1316
  this.lastCompiledTemplate = e;
1317
1317
  }
@@ -1361,15 +1361,15 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1361
1361
  const r = this.shadowRoot.querySelector(`[data-ref="${t}"]`);
1362
1362
  if (r) {
1363
1363
  e.has(r) || e.set(r, /* @__PURE__ */ new Set());
1364
- const i = e.get(r), s = r.addEventListener;
1365
- r.addEventListener = function(o, a, c) {
1366
- const l = `${o}`;
1367
- i.has(l) || (i.add(l), s.call(r, o, a, c));
1364
+ const o = e.get(r), s = r.addEventListener;
1365
+ r.addEventListener = function(i, a, c) {
1366
+ const l = `${i}`;
1367
+ o.has(l) || (o.add(l), s.call(r, i, a, c));
1368
1368
  }, r.setAttribute("data-refs-processed", "true");
1369
1369
  try {
1370
1370
  n(r, this.api.state, this.api);
1371
- } catch (o) {
1372
- this._handleRenderError(o);
1371
+ } catch (i) {
1372
+ this._handleRenderError(i);
1373
1373
  }
1374
1374
  }
1375
1375
  });
@@ -1386,15 +1386,15 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1386
1386
  const n = t;
1387
1387
  Array.from(n.attributes).forEach((r) => {
1388
1388
  if (r.name.startsWith("data-on-")) {
1389
- const i = r.name.slice(8), s = r.value, o = this.config[s];
1390
- if (typeof o == "function") {
1391
- n._boundHandlers && n._boundHandlers[i] && n.removeEventListener(i, n._boundHandlers[i]);
1389
+ const o = r.name.slice(8), s = r.value, i = this.config[s];
1390
+ if (typeof i == "function") {
1391
+ n._boundHandlers && n._boundHandlers[o] && n.removeEventListener(o, n._boundHandlers[o]);
1392
1392
  const a = (c) => {
1393
- o.call(this.config, c, this.api.state, this.api), this.syncControlledInputsAndEvents();
1393
+ i.call(this.config, c, this.api.state, this.api), this.syncControlledInputsAndEvents();
1394
1394
  };
1395
- n.addEventListener(i, a), n._boundHandlers || (n._boundHandlers = {}), n._boundHandlers[i] = a;
1395
+ n.addEventListener(o, a), n._boundHandlers || (n._boundHandlers = {}), n._boundHandlers[o] = a;
1396
1396
  } else
1397
- this.config.debug && console.warn(`[runtime] Handler '${s}' not found on config for event '${i}'`, n);
1397
+ this.config.debug && console.warn(`[runtime] Handler '${s}' not found on config for event '${o}'`, n);
1398
1398
  }
1399
1399
  }), t = e.nextNode();
1400
1400
  }
@@ -1415,9 +1415,9 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
1415
1415
  }
1416
1416
  });
1417
1417
  function lt(e, t) {
1418
- if (t = _(t), t.debug && console.log(`[runtime] Debugging component: ${e}`, t), !e || !t.template || !t.state) {
1419
- t && typeof t.onError == "function" && t.onError(new Error("Component requires tag, template, and state"), t.state, {
1420
- state: t.state,
1418
+ if (t = _(t), t.debug && console.log(`[runtime] Debugging component: ${e}`, t), !e || !t.template) {
1419
+ t && typeof t.onError == "function" && t.onError(new Error("Component requires tag and template"), t.state ?? {}, {
1420
+ state: t.state ?? {},
1421
1421
  emit: () => {
1422
1422
  },
1423
1423
  onGlobal: () => () => {
@@ -1429,11 +1429,11 @@ function lt(e, t) {
1429
1429
  }), t && t.debug && console.error("[runtime] Malformed config:", { tag: e, config: t });
1430
1430
  return;
1431
1431
  }
1432
- if (v.forEach((l) => {
1432
+ if (v.forEach((d) => {
1433
1433
  try {
1434
- l.onInit?.(t);
1435
- } catch (d) {
1436
- t && typeof t.onError == "function" && t.onError(d instanceof Error ? d : new Error(String(d)), t.state, {
1434
+ d.onInit?.(t);
1435
+ } catch (f) {
1436
+ t && typeof t.onError == "function" && t.onError(f instanceof Error ? f : new Error(String(f)), t.state, {
1437
1437
  state: t.state,
1438
1438
  emit: () => {
1439
1439
  },
@@ -1443,32 +1443,32 @@ function lt(e, t) {
1443
1443
  },
1444
1444
  emitGlobal: () => {
1445
1445
  }
1446
- }), t && t.debug && console.error("[runtime] Plugin onInit error:", d);
1446
+ }), t && t.debug && console.error("[runtime] Plugin onInit error:", f);
1447
1447
  }
1448
1448
  }), (typeof window < "u" && window.VITE_DEV_HMR || typeof import.meta < "u" && void 0) && customElements.get(e))
1449
1449
  try {
1450
- document.querySelectorAll(e).forEach((l) => l.remove()), window.customElements._definitions && delete window.customElements._definitions[e];
1450
+ document.querySelectorAll(e).forEach((d) => d.remove()), window.customElements._definitions && delete window.customElements._definitions[e];
1451
1451
  } catch {
1452
1452
  }
1453
1453
  if (customElements.get(e)) {
1454
1454
  t.debug && console.warn(`[runtime] Component "${e}" already registered`);
1455
1455
  return;
1456
1456
  }
1457
- const s = M(t.state, t.computed);
1457
+ const s = M(t.state ?? {}, t.computed);
1458
1458
  t.state = s, t._subscribe = s.subscribe;
1459
- const o = Object.keys(t.state).filter(
1460
- (l) => ["string", "number", "boolean"].includes(typeof t.state[l])
1459
+ const i = t.state ?? {}, a = Object.keys(i).filter(
1460
+ (d) => ["string", "number", "boolean"].includes(typeof i[d])
1461
1461
  );
1462
- class a extends P {
1462
+ class c extends P {
1463
1463
  static get observedAttributes() {
1464
- return o;
1464
+ return a;
1465
1465
  }
1466
1466
  constructor() {
1467
1467
  super();
1468
1468
  }
1469
1469
  }
1470
- const c = a;
1471
- typeof customElements < "u" && !customElements.get(e) && (window.__componentRegistry = window.__componentRegistry || {}, window.__componentRegistry[e] = t, customElements.define(e, c));
1470
+ const l = c;
1471
+ typeof customElements < "u" && !customElements.get(e) && (window.__componentRegistry = window.__componentRegistry || {}, window.__componentRegistry[e] = t, customElements.define(e, l));
1472
1472
  }
1473
1473
  export {
1474
1474
  Q as Store,