ladrillosjs 2.0.0-beta.2.2 → 2.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,57 +1,57 @@
1
- var lt = Object.defineProperty, ut = Object.defineProperties;
2
- var dt = Object.getOwnPropertyDescriptors;
3
- var X = Object.getOwnPropertySymbols;
4
- var ft = Object.prototype.hasOwnProperty, ht = Object.prototype.propertyIsEnumerable;
5
- var G = (t) => {
6
- throw TypeError(t);
1
+ var ft = Object.defineProperty, ht = Object.defineProperties;
2
+ var pt = Object.getOwnPropertyDescriptors;
3
+ var K = Object.getOwnPropertySymbols;
4
+ var mt = Object.prototype.hasOwnProperty, bt = Object.prototype.propertyIsEnumerable;
5
+ var Y = (e) => {
6
+ throw TypeError(e);
7
7
  };
8
- var J = (t, n, s) => n in t ? lt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[n] = s, O = (t, n) => {
9
- for (var s in n || (n = {}))
10
- ft.call(n, s) && J(t, s, n[s]);
11
- if (X)
12
- for (var s of X(n))
13
- ht.call(n, s) && J(t, s, n[s]);
14
- return t;
15
- }, K = (t, n) => ut(t, dt(n));
16
- var P = (t, n, s) => n.has(t) || G("Cannot " + s);
17
- var x = (t, n, s) => (P(t, n, "read from private field"), s ? s.call(t) : n.get(t)), _ = (t, n, s) => n.has(t) ? G("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(t) : n.set(t, s), F = (t, n, s, e) => (P(t, n, "write to private field"), e ? e.call(t, s) : n.set(t, s), s), M = (t, n, s) => (P(t, n, "access private method"), s);
18
- var I = (t, n, s) => new Promise((e, o) => {
8
+ var Q = (e, n, t) => n in e ? ft(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, O = (e, n) => {
9
+ for (var t in n || (n = {}))
10
+ mt.call(n, t) && Q(e, t, n[t]);
11
+ if (K)
12
+ for (var t of K(n))
13
+ bt.call(n, t) && Q(e, t, n[t]);
14
+ return e;
15
+ }, tt = (e, n) => ht(e, pt(n));
16
+ var U = (e, n, t) => n.has(e) || Y("Cannot " + t);
17
+ var A = (e, n, t) => (U(e, n, "read from private field"), t ? t.call(e) : n.get(e)), _ = (e, n, t) => n.has(e) ? Y("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), M = (e, n, t, s) => (U(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), W = (e, n, t) => (U(e, n, "access private method"), t);
18
+ var j = (e, n, t) => new Promise((s, o) => {
19
19
  var i = (d) => {
20
20
  try {
21
- c(s.next(d));
21
+ c(t.next(d));
22
22
  } catch (a) {
23
23
  o(a);
24
24
  }
25
25
  }, r = (d) => {
26
26
  try {
27
- c(s.throw(d));
27
+ c(t.throw(d));
28
28
  } catch (a) {
29
29
  o(a);
30
30
  }
31
- }, c = (d) => d.done ? e(d.value) : Promise.resolve(d.value).then(i, r);
32
- c((s = s.apply(t, n)).next());
31
+ }, c = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, r);
32
+ c((t = t.apply(e, n)).next());
33
33
  });
34
- import { R as Q, e as pt, l as mt } from "./index-CrzikOU3.mjs";
35
- const bt = (t, n, s) => {
34
+ import { R as et, l as gt, a as X, c as R, b as Et, d as wt, e as $t, f as yt, g as vt, h as D, i as At } from "./index-DymB3-NG.mjs";
35
+ const xt = (e, n, t) => {
36
36
  if (!n) return;
37
- const e = document.createElement("style");
38
- e.textContent = n, s ? t.appendChild(e) : document.head.appendChild(e);
39
- }, gt = (t, n) => {
40
- t.innerHTML = n;
41
- const s = Et(t), e = wt(t), o = $t(t), i = vt(t);
42
- return { bindings: s, twoWayBindings: e, conditionals: o, loops: i };
43
- }, Y = (t) => {
44
- const n = [], s = t.match(/\((.*)\)/);
45
- if (!s) return n;
46
- const e = s[1].trim();
47
- return e && e.split(",").map((i) => i.trim()).forEach((i) => {
37
+ const s = document.createElement("style");
38
+ s.textContent = n, t ? e.appendChild(s) : document.head.appendChild(s);
39
+ }, St = (e, n) => {
40
+ e.innerHTML = n;
41
+ const t = _t(e), s = Ct(e), o = Tt(e), i = Lt(e);
42
+ return { bindings: t, twoWayBindings: s, conditionals: o, loops: i };
43
+ }, nt = (e) => {
44
+ const n = [], t = e.match(/\((.*)\)/);
45
+ if (!t) return n;
46
+ const s = t[1].trim();
47
+ return s && s.split(",").map((i) => i.trim()).forEach((i) => {
48
48
  if (/^['"]/.test(i) || /^\d+/.test(i)) return;
49
49
  const r = i.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
50
50
  r && n.push(r[1]);
51
51
  }), n;
52
- }, Et = (t) => {
53
- const n = document.createTreeWalker(t, NodeFilter.SHOW_TEXT, null), s = [];
54
- let e;
52
+ }, _t = (e) => {
53
+ const n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), t = [];
54
+ let s;
55
55
  const o = (r) => {
56
56
  let c = r.parentElement;
57
57
  for (; c; ) {
@@ -61,38 +61,38 @@ const bt = (t, n, s) => {
61
61
  }
62
62
  return !1;
63
63
  };
64
- for (; e = n.nextNode(); ) {
65
- if (o(e))
64
+ for (; s = n.nextNode(); ) {
65
+ if (o(s))
66
66
  continue;
67
- const r = [...e.textContent.matchAll(Q.bindings)];
67
+ const r = [...s.textContent.matchAll(et.bindings)];
68
68
  if (r.length > 0) {
69
- const c = e.textContent, d = r.map((a) => {
69
+ const c = s.textContent, d = r.map((a) => {
70
70
  const l = a[1].trim(), u = l.includes("(") && l.includes(")"), f = /[+*/%<>=!&|]/.test(l) || // Math or logical operators (excluding hyphen)
71
71
  /\s-\s/.test(l), p = /^(!|typeof\s|void\s|delete\s)/.test(l), E = f || p || // Expressions starting with operators
72
72
  /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(l) || // Method calls like name.toLowerCase()
73
73
  /\bnew\s+/.test(l) || // Object instantiation like new Date()
74
- /\b(typeof|instanceof|void|delete)\b/.test(l), m = u ? [l.split("(")[0].trim()] : l.split(".").map((C) => C.trim()), b = u ? Y(l) : [];
74
+ /\b(typeof|instanceof|void|delete)\b/.test(l), m = u ? [l.split("(")[0].trim()] : l.split(".").map((C) => C.trim()), b = u ? nt(l) : [];
75
75
  return { raw: l, path: m, isFunction: u, isExpression: E, functionArgs: b };
76
76
  });
77
- s.push({ node: e, bindings: d, original: c });
77
+ t.push({ node: s, bindings: d, original: c });
78
78
  }
79
79
  }
80
- return t.querySelectorAll("*").forEach((r) => {
80
+ return e.querySelectorAll("*").forEach((r) => {
81
81
  if (!(r.hasAttribute("$for") || o(r)))
82
82
  for (const c of r.attributes) {
83
83
  if (c.name === "$if" || c.name === "$else-if" || c.name === "$else" || c.name === "$bind")
84
84
  continue;
85
- const d = [...c.value.matchAll(Q.bindings)];
85
+ const d = [...c.value.matchAll(et.bindings)];
86
86
  if (d.length > 0) {
87
87
  const a = c.value, l = d.map((u) => {
88
88
  const f = u[1].trim(), p = f.includes("(") && f.includes(")"), E = /[+*/%<>=!&|]/.test(f) || // Math or logical operators (excluding hyphen)
89
89
  /\s-\s/.test(f), m = /^(!|typeof\s|void\s|delete\s)/.test(f), b = E || m || // Expressions starting with operators
90
90
  /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(f) || // Method calls like name.toLowerCase()
91
91
  /\bnew\s+/.test(f) || // Object instantiation like new Date()
92
- /\b(typeof|instanceof|void|delete)\b/.test(f), C = p ? [f.split("(")[0].trim()] : f.split(".").map((q) => q.trim()), R = p ? Y(f) : [];
93
- return { raw: f, path: C, isFunction: p, isExpression: b, functionArgs: R };
92
+ /\b(typeof|instanceof|void|delete)\b/.test(f), C = p ? [f.split("(")[0].trim()] : f.split(".").map((z) => z.trim()), N = p ? nt(f) : [];
93
+ return { raw: f, path: C, isFunction: p, isExpression: b, functionArgs: N };
94
94
  });
95
- s.push({
95
+ t.push({
96
96
  node: r,
97
97
  bindings: l,
98
98
  original: a,
@@ -101,43 +101,43 @@ const bt = (t, n, s) => {
101
101
  });
102
102
  }
103
103
  }
104
- }), s;
105
- }, wt = (t) => {
104
+ }), t;
105
+ }, Ct = (e) => {
106
106
  const n = [];
107
- return t.querySelectorAll("[\\$bind]").forEach((e) => {
107
+ return e.querySelectorAll("[\\$bind]").forEach((s) => {
108
108
  var c;
109
- const o = e.getAttribute("$bind");
109
+ const o = s.getAttribute("$bind");
110
110
  if (!o) return;
111
111
  const i = o.trim(), r = i.split(".").map((d) => d.trim());
112
- e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (n.push({
113
- element: e,
112
+ s instanceof HTMLInputElement || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement ? (n.push({
113
+ element: s,
114
114
  path: r,
115
115
  raw: i,
116
116
  isContentEditable: !1,
117
- initialValue: e.value || ""
118
- }), e.removeAttribute("$bind")) : e instanceof HTMLElement && e.hasAttribute("contenteditable") && (n.push({
119
- element: e,
117
+ initialValue: s.value || ""
118
+ }), s.removeAttribute("$bind")) : s instanceof HTMLElement && s.hasAttribute("contenteditable") && (n.push({
119
+ element: s,
120
120
  path: r,
121
121
  raw: i,
122
122
  isContentEditable: !0,
123
- initialValue: ((c = e.textContent) == null ? void 0 : c.trim()) || ""
124
- }), e.removeAttribute("$bind"));
123
+ initialValue: ((c = s.textContent) == null ? void 0 : c.trim()) || ""
124
+ }), s.removeAttribute("$bind"));
125
125
  }), n;
126
- }, $t = (t) => {
127
- const n = [], s = /* @__PURE__ */ new Set();
128
- return t.querySelectorAll("[\\$if]").forEach((o) => {
129
- if (s.has(o)) return;
126
+ }, Tt = (e) => {
127
+ const n = [], t = /* @__PURE__ */ new Set();
128
+ return e.querySelectorAll("[\\$if]").forEach((o) => {
129
+ if (t.has(o)) return;
130
130
  const i = [];
131
131
  let r = o;
132
132
  for (; r; ) {
133
133
  const c = r.hasAttribute("$if"), d = r.hasAttribute("$else-if"), a = r.hasAttribute("$else");
134
134
  if (!c && !d && !a) break;
135
- s.add(r);
135
+ t.add(r);
136
136
  let l, u = "";
137
137
  c ? (l = "if", u = r.getAttribute("$if") || "", r.removeAttribute("$if")) : d ? (l = "else-if", u = r.getAttribute("$else-if") || "", r.removeAttribute("$else-if")) : (l = "else", r.removeAttribute("$else"));
138
138
  const f = document.createComment(
139
139
  `conditional:${l}:${u}`
140
- ), p = r.parentElement || t, E = r.nextSibling;
140
+ ), p = r.parentElement || e, E = r.nextSibling;
141
141
  p.insertBefore(f, r);
142
142
  const m = {
143
143
  element: r,
@@ -158,11 +158,11 @@ const bt = (t, n, s) => {
158
158
  c.group = i;
159
159
  }), n.push(i);
160
160
  }), n;
161
- }, yt = (t) => {
161
+ }, kt = (e) => {
162
162
  const n = /* @__PURE__ */ new Set();
163
- return t.forEach((s) => {
164
- s.forEach((e) => {
165
- let o = e.condition;
163
+ return e.forEach((t) => {
164
+ t.forEach((s) => {
165
+ let o = s.condition;
166
166
  o = o.replace(/\{([^}]+)\}/g, "$1");
167
167
  const i = /\b([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\b/g, r = /* @__PURE__ */ new Set([
168
168
  "true",
@@ -190,23 +190,26 @@ const bt = (t, n, s) => {
190
190
  }
191
191
  });
192
192
  }), n;
193
- }, vt = (t) => {
193
+ }, Lt = (e) => {
194
194
  const n = [];
195
- return t.querySelectorAll("[\\$for]").forEach((e) => {
195
+ return e.querySelectorAll("[\\$for]").forEach((s) => {
196
196
  var p;
197
- const o = e.getAttribute("$for");
197
+ const o = s.getAttribute("$for");
198
198
  if (!o) return;
199
- const i = e.getAttribute("$key") || void 0, r = o.match(
199
+ const i = s.getAttribute("$key") || void 0, r = o.match(
200
200
  /^\s*(?:\(([^,]+),\s*([^)]+)\)|([^\s]+))\s+(?:in|of)\s+(.+)\s*$/
201
201
  );
202
202
  if (!r) {
203
- console.error(`Invalid $for expression: "${o}"`);
203
+ gt(`Invalid $for expression: "${o}"`, {
204
+ expression: o,
205
+ lineHint: "$for attribute parsing"
206
+ });
204
207
  return;
205
208
  }
206
- const c = (r[1] || r[3]).trim(), d = (p = r[2]) == null ? void 0 : p.trim(), a = r[4].trim(), l = document.createComment(`loop:${o}`), u = e.parentElement || t;
207
- u.insertBefore(l, e), e.removeAttribute("$for"), i && e.removeAttribute("$key"), e.remove();
209
+ const c = (r[1] || r[3]).trim(), d = (p = r[2]) == null ? void 0 : p.trim(), a = r[4].trim(), l = document.createComment(`loop:${o}`), u = s.parentElement || e;
210
+ u.insertBefore(l, s), s.removeAttribute("$for"), i && s.removeAttribute("$key"), s.remove();
208
211
  const f = {
209
- template: e,
212
+ template: s,
210
213
  expression: o,
211
214
  itemName: c,
212
215
  indexName: d,
@@ -218,53 +221,53 @@ const bt = (t, n, s) => {
218
221
  };
219
222
  n.push(f);
220
223
  }), n;
221
- }, xt = (t) => {
224
+ }, Rt = (e) => {
222
225
  const n = /* @__PURE__ */ new Set();
223
- return t.forEach((s) => {
224
- const e = s.arrayName.split(".")[0];
225
- n.add(e);
226
+ return e.forEach((t) => {
227
+ const s = t.arrayName.split(".")[0];
228
+ n.add(s);
226
229
  }), n;
227
- }, B = /* @__PURE__ */ new Map(), At = 100, D = (t) => {
228
- const n = B.get(t);
230
+ }, F = /* @__PURE__ */ new Map(), Nt = 100, J = (e) => {
231
+ const n = F.get(e);
229
232
  if (n)
230
- return B.delete(t), B.set(t, n), n;
231
- const s = new Function(
233
+ return F.delete(e), F.set(e, n), n;
234
+ const t = new Function(
232
235
  "component",
233
236
  `
234
237
  const { Date, Array, Math, String, Number, Boolean, Object, JSON, RegExp } = globalThis;
235
238
  with(component) {
236
- return ${t};
239
+ return ${e};
237
240
  }
238
241
  `
239
242
  );
240
- if (B.size >= At) {
241
- const e = B.keys().next().value;
242
- e && B.delete(e);
243
+ if (F.size >= Nt) {
244
+ const s = F.keys().next().value;
245
+ s && F.delete(s);
243
246
  }
244
- return B.set(t, s), s;
245
- }, j = (t, n) => n.reduce((s, e) => {
246
- if (!(s == null || typeof s != "object"))
247
- return s[e];
248
- }, t), U = (t, n, s) => {
247
+ return F.set(e, t), t;
248
+ }, q = (e, n) => n.reduce((t, s) => {
249
+ if (!(t == null || typeof t != "object"))
250
+ return t[s];
251
+ }, e), Z = (e, n, t) => {
249
252
  if (n.length === 0) return;
250
- const e = n[n.length - 1], o = n.slice(0, -1);
251
- let i = t;
253
+ const s = n[n.length - 1], o = n.slice(0, -1);
254
+ let i = e;
252
255
  for (const r of o)
253
256
  (i[r] === void 0 || i[r] === null) && (i[r] = {}), i = i[r];
254
- i[e] = s;
255
- }, tt = (t, n, s) => {
256
- for (const e of t) {
257
- let o = e.original, i, r = !1;
258
- for (const { raw: c, path: d, isFunction: a, isExpression: l } of e.bindings) {
257
+ i[s] = t;
258
+ }, st = (e, n, t) => {
259
+ for (const s of e) {
260
+ let o = s.original, i, r = !1;
261
+ for (const { raw: c, path: d, isFunction: a, isExpression: l } of s.bindings) {
259
262
  let u, f = !1;
260
263
  if (l || a)
261
264
  try {
262
- u = D(c)(s || n);
265
+ u = J(c)(t || n);
263
266
  } catch (E) {
264
- console.error(`Error executing expression binding {${c}}:`, E), u = void 0, f = !0;
267
+ X(c, E, R(t)), u = void 0, f = !0;
265
268
  }
266
269
  else
267
- u = j(n, d), u === void 0 && (f = !0);
270
+ u = q(n, d), u === void 0 && (f = !0);
268
271
  if (f) {
269
272
  r = !0;
270
273
  continue;
@@ -272,12 +275,12 @@ const bt = (t, n, s) => {
272
275
  const p = String(u != null ? u : "");
273
276
  i = u, o = o.replace(`{${c}}`, p);
274
277
  }
275
- if (r && e.original, e.node.nodeType === Node.TEXT_NODE) {
276
- const c = e.node, d = c.parentElement, a = o.trim().startsWith("<") && o.includes(">");
278
+ if (r && s.original, s.node.nodeType === Node.TEXT_NODE) {
279
+ const c = s.node, d = c.parentElement, a = o.trim().startsWith("<") && o.includes(">");
277
280
  d && a ? d.innerHTML = o : c.textContent = o;
278
281
  } else {
279
- const c = e.node;
280
- e.isAttribute && e.attributeName && ([
282
+ const c = s.node;
283
+ s.isAttribute && s.attributeName && ([
281
284
  "disabled",
282
285
  "checked",
283
286
  "readonly",
@@ -290,13 +293,13 @@ const bt = (t, n, s) => {
290
293
  "controls",
291
294
  "loop",
292
295
  "muted"
293
- ].includes(e.attributeName.toLowerCase()) ? (typeof i == "boolean" ? i : i === "true" || i === "True") ? c.setAttribute(e.attributeName, "") : c.removeAttribute(e.attributeName) : c.setAttribute(e.attributeName, o));
296
+ ].includes(s.attributeName.toLowerCase()) ? (typeof i == "boolean" ? i : i === "true" || i === "True") ? c.setAttribute(s.attributeName, "") : c.removeAttribute(s.attributeName) : c.setAttribute(s.attributeName, o));
294
297
  }
295
298
  }
296
- }, St = (t, n, s) => {
297
- if (!t) return !0;
298
- let e = t.trim();
299
- e = e.replace(/\{([^}]+)\}/g, "$1");
299
+ }, Vt = (e, n, t) => {
300
+ if (!e) return !0;
301
+ let s = e.trim();
302
+ s = s.replace(/\{([^}]+)\}/g, "$1");
300
303
  try {
301
304
  return new Function(
302
305
  "context",
@@ -304,18 +307,22 @@ const bt = (t, n, s) => {
304
307
  `
305
308
  with (context) {
306
309
  try {
307
- return Boolean(${e});
310
+ return Boolean(${s});
308
311
  } catch (e) {
309
312
  return false;
310
313
  }
311
314
  }
312
315
  `
313
- )(n, s);
316
+ )(n, t);
314
317
  } catch (o) {
315
- return console.error(`Error evaluating condition "${t}":`, o), !1;
318
+ return wt(
319
+ e,
320
+ o,
321
+ R(t)
322
+ ), !1;
316
323
  }
317
- }, st = (t, n) => {
318
- const s = [
324
+ }, it = (e, n) => {
325
+ const t = [
319
326
  "click",
320
327
  "dblclick",
321
328
  "mousedown",
@@ -350,8 +357,8 @@ const bt = (t, n, s) => {
350
357
  "dragleave",
351
358
  "drop"
352
359
  ];
353
- [t, ...t.querySelectorAll("*")].forEach((o) => {
354
- s.forEach((i) => {
360
+ [e, ...e.querySelectorAll("*")].forEach((o) => {
361
+ t.forEach((i) => {
355
362
  const r = `on${i}`, c = o.getAttribute(r);
356
363
  if (c) {
357
364
  const d = `__processed_${r}`;
@@ -370,10 +377,13 @@ const bt = (t, n, s) => {
370
377
  `
371
378
  ).call(this, a, n);
372
379
  } catch (l) {
373
- console.error(
374
- `Error executing ${i} handler:`,
380
+ $t(
381
+ i,
382
+ c,
375
383
  l,
376
- c
384
+ R(n, {
385
+ elementTag: o.tagName.toLowerCase()
386
+ })
377
387
  );
378
388
  }
379
389
  }
@@ -381,20 +391,20 @@ const bt = (t, n, s) => {
381
391
  }
382
392
  });
383
393
  });
384
- }, et = (t, n, s) => {
385
- var e;
386
- for (const o of t) {
394
+ }, ot = (e, n, t) => {
395
+ var s;
396
+ for (const o of e) {
387
397
  let i = !1;
388
398
  for (const r of o) {
389
399
  const { element: c, condition: d, type: a, placeholder: l, originalParent: u } = r;
390
400
  let f = !1;
391
- a === "else" ? f = !i : i || (f = St(d, n, s), f && (i = !0));
401
+ a === "else" ? f = !i : i || (f = Vt(d, n, t), f && (i = !0));
392
402
  const p = c.parentNode !== null;
393
- f && !p ? ((e = l.parentNode) == null || e.insertBefore(c, l.nextSibling), s && st(c, s)) : !f && p && c.remove();
403
+ f && !p ? ((s = l.parentNode) == null || s.insertBefore(c, l.nextSibling), t && it(c, t)) : !f && p && c.remove();
394
404
  }
395
405
  }
396
- }, nt = (t, n, s) => {
397
- for (const e of t) {
406
+ }, rt = (e, n, t) => {
407
+ for (const s of e) {
398
408
  const {
399
409
  template: o,
400
410
  itemName: i,
@@ -402,27 +412,33 @@ const bt = (t, n, s) => {
402
412
  arrayName: c,
403
413
  placeholder: d,
404
414
  renderedElements: a
405
- } = e, l = j(n, c.split("."));
415
+ } = s, l = q(n, c.split("."));
406
416
  if (l !== void 0 && !Array.isArray(l)) {
407
- console.warn(`$for: "${c}" is not an array, got:`, l), a.forEach((u) => u.remove()), a.length = 0;
417
+ Et(
418
+ `${i} in ${c}`,
419
+ new Error(`"${c}" is not an array, got: ${typeof l}`),
420
+ R(t, {
421
+ lineHint: "$for loop in template"
422
+ })
423
+ ), a.forEach((u) => u.remove()), a.length = 0;
408
424
  return;
409
425
  }
410
426
  if (!l)
411
427
  return;
412
428
  a.forEach((u) => u.remove()), a.length = 0, l.forEach((u, f) => {
413
429
  var b;
414
- const p = o.cloneNode(!0), E = K(O({}, n), {
430
+ const p = o.cloneNode(!0), E = tt(O({}, n), {
415
431
  [i]: u
416
432
  });
417
- r && (E[r] = f), _t(p, E, s);
433
+ r && (E[r] = f), Bt(p, E, t);
418
434
  const m = a.length > 0 ? a[a.length - 1] : d;
419
- (b = m.parentNode) == null || b.insertBefore(p, m.nextSibling), a.push(p), s && st(p, s);
435
+ (b = m.parentNode) == null || b.insertBefore(p, m.nextSibling), a.push(p), t && it(p, t);
420
436
  });
421
437
  }
422
- }, _t = (t, n, s) => {
423
- const e = document.createTreeWalker(t, NodeFilter.SHOW_TEXT, null);
438
+ }, Bt = (e, n, t) => {
439
+ const s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null);
424
440
  let o;
425
- for (; o = e.nextNode(); )
441
+ for (; o = s.nextNode(); )
426
442
  if (o.textContent && o.textContent.includes("{")) {
427
443
  let r = o.textContent;
428
444
  [...o.textContent.matchAll(/\{([^}]+)\}/g)].forEach((d) => {
@@ -432,22 +448,25 @@ const bt = (t, n, s) => {
432
448
  let p;
433
449
  if (f || l)
434
450
  try {
435
- const E = D(a), m = typeof n == "object" && n !== null ? O(O({}, n), s || {}) : s || {};
451
+ const E = J(a), m = typeof n == "object" && n !== null ? O(O({}, n), t || {}) : t || {};
436
452
  p = E(m);
437
453
  } catch (E) {
438
- console.error(
439
- `Error executing expression in loop {${a}}:`,
440
- E
454
+ X(
455
+ a,
456
+ E,
457
+ R(t, {
458
+ lineHint: "$for loop template binding"
459
+ })
441
460
  ), p = void 0;
442
461
  }
443
462
  else {
444
463
  const E = a.split(".").map((m) => m.trim());
445
- p = j(n, E);
464
+ p = q(n, E);
446
465
  }
447
466
  p !== void 0 && (r = r.replace(`{${a}}`, String(p != null ? p : "")));
448
467
  }), o.textContent = r;
449
468
  }
450
- [t, ...t.querySelectorAll("*")].forEach((r) => {
469
+ [e, ...e.querySelectorAll("*")].forEach((r) => {
451
470
  Array.from(r.attributes).forEach((c) => {
452
471
  if (c.value.includes("{")) {
453
472
  let d = c.value;
@@ -458,32 +477,36 @@ const bt = (t, n, s) => {
458
477
  let m;
459
478
  if (E || f)
460
479
  try {
461
- const b = D(u), C = typeof n == "object" && n !== null ? O(O({}, n), s || {}) : s || {};
480
+ const b = J(u), C = typeof n == "object" && n !== null ? O(O({}, n), t || {}) : t || {};
462
481
  m = b(C);
463
482
  } catch (b) {
464
- console.error(
465
- `Error executing expression in loop attribute {${u}}:`,
466
- b
483
+ X(
484
+ u,
485
+ b,
486
+ R(t, {
487
+ attributeName: c.name,
488
+ lineHint: "$for loop attribute binding"
489
+ })
467
490
  ), m = void 0;
468
491
  }
469
492
  else {
470
493
  const b = u.split(".").map((C) => C.trim());
471
- m = j(n, b);
494
+ m = q(n, b);
472
495
  }
473
496
  m !== void 0 && (d = d.replace(`{${u}}`, String(m != null ? m : "")));
474
497
  }), r.setAttribute(c.name, d);
475
498
  }
476
499
  });
477
500
  });
478
- }, ot = (t) => t instanceof ShadowRoot ? t.host : t, Ct = (t, n) => {
479
- const s = /* @__PURE__ */ new Set();
501
+ }, ct = (e) => e instanceof ShadowRoot ? e.host : e, Ft = (e, n) => {
502
+ const t = /* @__PURE__ */ new Set();
480
503
  n.forEach(({ path: o }) => {
481
504
  const i = o[0];
482
- s.add(i);
505
+ t.add(i);
483
506
  });
484
- const e = [];
485
- return s.forEach((o) => {
486
- e.push(`
507
+ const s = [];
508
+ return t.forEach((o) => {
509
+ s.push(`
487
510
  if (!Object.getOwnPropertyDescriptor(component, '${o}')) {
488
511
  Object.defineProperty(component, '${o}', {
489
512
  get() { return this.state.${o}; },
@@ -496,12 +519,12 @@ const bt = (t, n, s) => {
496
519
  }), {
497
520
  injectedCode: "",
498
521
  // No longer needed in script scope
499
- componentInjections: e.join(`
522
+ componentInjections: s.join(`
500
523
  `),
501
- bindVarNames: s
524
+ bindVarNames: t
502
525
  };
503
- }, Tt = (t, n, s = /* @__PURE__ */ new Set()) => {
504
- const e = [], o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
526
+ }, Ot = (e, n, t = /* @__PURE__ */ new Set()) => {
527
+ const s = [], o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
505
528
  n.forEach((d) => {
506
529
  d.bindings.forEach((a) => {
507
530
  const l = a.path[0];
@@ -509,97 +532,97 @@ const bt = (t, n, s) => {
509
532
  i.add(u);
510
533
  });
511
534
  });
512
- }), s.forEach((d) => {
535
+ }), t.forEach((d) => {
513
536
  i.add(d);
514
537
  });
515
538
  const r = /(?:const|let|var)\s+(\w+)\s*=\s*([^;]+);?/g;
516
539
  let c;
517
- for (; (c = r.exec(t)) !== null; ) {
540
+ for (; (c = r.exec(e)) !== null; ) {
518
541
  const d = c[1], a = c[2].trim();
519
- i.has(d) && (e.push(`component.state.${d} = ${d};`), o.set(d, a));
542
+ i.has(d) && (s.push(`component.state.${d} = ${d};`), o.set(d, a));
520
543
  }
521
- return { stateBindings: e, boundVarNames: i, defaultValues: o };
522
- }, kt = (t, n) => {
523
- if (n.size === 0) return t;
524
- let s = t;
525
- return n.forEach((e) => {
544
+ return { stateBindings: s, boundVarNames: i, defaultValues: o };
545
+ }, Mt = (e, n) => {
546
+ if (n.size === 0) return e;
547
+ let t = e;
548
+ return n.forEach((s) => {
526
549
  const o = new RegExp(
527
- `\\b${e}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
550
+ `\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
528
551
  "g"
529
552
  );
530
- s = s.replace(
553
+ t = t.replace(
531
554
  o,
532
- `component.state.${e}$1 $2`
555
+ `component.state.${s}$1 $2`
533
556
  );
534
557
  const i = new RegExp(
535
- `(?<!component\\.state\\.)\\b${e}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
558
+ `(?<!component\\.state\\.)\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
536
559
  "g"
537
560
  );
538
- s = s.replace(
561
+ t = t.replace(
539
562
  i,
540
- `component.state.${e}$1`
563
+ `component.state.${s}$1`
541
564
  );
542
565
  const r = new RegExp(
543
- `\\b${e}\\.(\\w+(?:\\.\\w+)*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
566
+ `\\b${s}\\.(\\w+(?:\\.\\w+)*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
544
567
  "g"
545
568
  );
546
- s = s.replace(
569
+ t = t.replace(
547
570
  r,
548
- `component.state.${e}.$1 $2`
571
+ `component.state.${s}.$1 $2`
549
572
  );
550
573
  const c = new RegExp(
551
- `(?<!component\\.state\\.)(?<!const\\s${e}\\s*=\\s*{[^}]*)\\b${e}\\.(\\w+(?:\\.\\w+)*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
574
+ `(?<!component\\.state\\.)(?<!const\\s${s}\\s*=\\s*{[^}]*)\\b${s}\\.(\\w+(?:\\.\\w+)*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
552
575
  "g"
553
576
  );
554
- s = s.replace(
577
+ t = t.replace(
555
578
  c,
556
- `component.state.${e}.$1`
579
+ `component.state.${s}.$1`
557
580
  );
558
581
  const d = new RegExp(
559
- `(?<!\\.)\\b(\\+\\+|\\-\\-)${e}\\b|\\b${e}(\\+\\+|\\-\\-)`,
582
+ `(?<!\\.)\\b(\\+\\+|\\-\\-)${s}\\b|\\b${s}(\\+\\+|\\-\\-)`,
560
583
  "g"
561
584
  );
562
- s = s.replace(d, (u) => {
585
+ t = t.replace(d, (u) => {
563
586
  if (u.startsWith("++") || u.startsWith("--"))
564
- return `${u.substring(0, 2)}component.state.${e}`;
587
+ return `${u.substring(0, 2)}component.state.${s}`;
565
588
  {
566
589
  const f = u.substring(u.length - 2);
567
- return `component.state.${e}${f}`;
590
+ return `component.state.${s}${f}`;
568
591
  }
569
592
  });
570
593
  const a = new RegExp(
571
- `(?<!\\.)\\b${e}\\s*(\\+=|\\-=|\\*=|\\/=|%=|\\*\\*=|<<=|>>=|>>>=|&=|\\|=|\\^=)`,
594
+ `(?<!\\.)\\b${s}\\s*(\\+=|\\-=|\\*=|\\/=|%=|\\*\\*=|<<=|>>=|>>>=|&=|\\|=|\\^=)`,
572
595
  "g"
573
596
  );
574
- s = s.replace(
597
+ t = t.replace(
575
598
  a,
576
- `component.state.${e}$1`
599
+ `component.state.${s}$1`
577
600
  );
578
601
  const l = new RegExp(
579
- `(?<!const\\s)(?<!let\\s)(?<!var\\s)(?<!\\.)\\b${e}\\s*=\\s*([^=])`,
602
+ `(?<!const\\s)(?<!let\\s)(?<!var\\s)(?<!\\.)\\b${s}\\s*=\\s*([^=])`,
580
603
  "g"
581
604
  );
582
- s = s.replace(
605
+ t = t.replace(
583
606
  l,
584
- `component.state.${e} = $1`
607
+ `component.state.${s} = $1`
585
608
  );
586
- }), s;
587
- }, rt = (t, n, s, e, o, i = /* @__PURE__ */ new Set()) => {
609
+ }), t;
610
+ }, at = (e, n, t, s, o, i = /* @__PURE__ */ new Set()) => {
588
611
  try {
589
- const { injectedCode: r, componentInjections: c, bindVarNames: d } = Ct(t, s), a = /function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[\w\s]*)\s*=>/g, l = [];
612
+ const { injectedCode: r, componentInjections: c, bindVarNames: d } = Ft(e, t), a = /function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[\w\s]*)\s*=>/g, l = [];
590
613
  let u;
591
- for (; (u = a.exec(t)) !== null; ) {
614
+ for (; (u = a.exec(e)) !== null; ) {
592
615
  const S = u[1] || u[2];
593
616
  S && l.push(S);
594
617
  }
595
618
  const f = l.map(
596
619
  (S) => `component.${S} = typeof ${S} !== 'undefined' ? ${S}.bind(component) : undefined;`
597
620
  ).join(`
598
- `), { stateBindings: p, boundVarNames: E, defaultValues: m } = Tt(t, n, i), b = /* @__PURE__ */ new Set([...E, ...d]), C = p.join(`
599
- `), R = kt(
600
- t,
621
+ `), { stateBindings: p, boundVarNames: E, defaultValues: m } = Ot(e, n, i), b = /* @__PURE__ */ new Set([...E, ...d]), C = p.join(`
622
+ `), N = Mt(
623
+ e,
601
624
  b
602
- ), q = `
625
+ ), z = `
603
626
  (function() {
604
627
  // Create component scope with direct access to state
605
628
  const component = this;
@@ -634,7 +657,7 @@ const bt = (t, n, s) => {
634
657
 
635
658
  // Execute script content within component scope so $bind variables are accessible
636
659
  with(component) {
637
- ${R}
660
+ ${N}
638
661
 
639
662
  // Auto-bind variables to component state (e.g., const name = "value" → this.state.name = "value")
640
663
  ${C}
@@ -644,11 +667,11 @@ const bt = (t, n, s) => {
644
667
  }
645
668
  }).call(arguments[0], arguments[0], arguments[1], arguments[2])
646
669
  `;
647
- return new Function(q)(o, e, pt), m;
670
+ return new Function(z)(o, s, yt), m;
648
671
  } catch (r) {
649
- return console.error("Script execution failed:", r), /* @__PURE__ */ new Map();
672
+ return vt(r, R(o)), /* @__PURE__ */ new Map();
650
673
  }
651
- }, it = (t, n) => {
674
+ }, lt = (e, n) => {
652
675
  [
653
676
  "click",
654
677
  "dblclick",
@@ -683,14 +706,14 @@ const bt = (t, n, s) => {
683
706
  "dragover",
684
707
  "dragleave",
685
708
  "drop"
686
- ].forEach((e) => {
687
- const o = `on${e}`;
688
- (t instanceof ShadowRoot ? t.querySelectorAll(`[${o}]`) : n.querySelectorAll(`[${o}]`)).forEach((r) => {
709
+ ].forEach((s) => {
710
+ const o = `on${s}`;
711
+ (e instanceof ShadowRoot ? e.querySelectorAll(`[${o}]`) : n.querySelectorAll(`[${o}]`)).forEach((r) => {
689
712
  const c = `${o}`;
690
713
  if (r[`__processed_${c}`]) return;
691
714
  const d = r.getAttribute(o);
692
715
  d && (r.removeAttribute(o), r.addEventListener(
693
- e,
716
+ s,
694
717
  function(a) {
695
718
  new Function(
696
719
  "event",
@@ -705,45 +728,45 @@ const bt = (t, n, s) => {
705
728
  ), r[`__processed_${c}`] = !0);
706
729
  });
707
730
  });
708
- }, Lt = (i, r, c, ...d) => I(null, [i, r, c, ...d], function* (t, n, s, e = [], o = /* @__PURE__ */ new Set()) {
731
+ }, Wt = (i, r, c, ...d) => j(null, [i, r, c, ...d], function* (e, n, t, s = [], o = /* @__PURE__ */ new Set()) {
709
732
  const a = /* @__PURE__ */ new Map();
710
733
  if (!(n != null && n.length)) return a;
711
- const l = ot(t);
734
+ const l = ct(e);
712
735
  for (const u of n)
713
- u.content && rt(
736
+ u.content && at(
714
737
  u.content,
738
+ t,
715
739
  s,
716
740
  e,
717
- t,
718
741
  l,
719
742
  o
720
743
  ).forEach((p, E) => {
721
744
  a.has(E) || a.set(E, p);
722
745
  });
723
- return it(t, l), a;
724
- }), Rt = (t, n) => new Promise((s, e) => {
746
+ return lt(e, l), a;
747
+ }), Ht = (e, n) => new Promise((t, s) => {
725
748
  const o = document.querySelector(
726
- `script[src="${t}"]`
749
+ `script[src="${e}"]`
727
750
  );
728
751
  if (o) {
729
752
  if (o.dataset.loaded === "true") {
730
- s();
753
+ t();
731
754
  return;
732
755
  }
733
- o.addEventListener("load", () => s(), { once: !0 }), o.addEventListener(
756
+ o.addEventListener("load", () => t(), { once: !0 }), o.addEventListener(
734
757
  "error",
735
- () => e(new Error(`Failed to load external script: ${t}`)),
758
+ () => s(new Error(`Failed to load external script: ${e}`)),
736
759
  { once: !0 }
737
760
  );
738
761
  return;
739
762
  }
740
763
  const i = document.createElement("script");
741
- i.src = t, n && (i.type = n), i.onload = () => {
742
- i.dataset.loaded = "true", s();
743
- }, i.onerror = () => e(new Error(`Failed to load external script: ${t}`)), document.head.appendChild(i);
744
- }), Vt = (r, c, d, ...a) => I(null, [r, c, d, ...a], function* (t, n, s, e = [], o = /* @__PURE__ */ new Set(), i) {
764
+ i.src = e, n && (i.type = n), i.onload = () => {
765
+ i.dataset.loaded = "true", t();
766
+ }, i.onerror = () => s(new Error(`Failed to load external script: ${e}`)), document.head.appendChild(i);
767
+ }), It = (r, c, d, ...a) => j(null, [r, c, d, ...a], function* (e, n, t, s = [], o = /* @__PURE__ */ new Set(), i) {
745
768
  var u;
746
- const l = ot(t);
769
+ const l = ct(e);
747
770
  for (const f of n) {
748
771
  let p;
749
772
  i ? i.startsWith("http://") || i.startsWith("https://") ? p = i : p = new URL(
@@ -752,12 +775,12 @@ const bt = (t, n, s) => {
752
775
  ).href : p = window.location.href;
753
776
  const E = new URL(f.src, p).href;
754
777
  if (f.external)
755
- yield Rt(E, f.type);
778
+ yield Ht(E, f.type);
756
779
  else if (f.type === "module") {
757
780
  const m = l.tagName.toLowerCase();
758
781
  window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(m, {
759
- host: t,
760
- shadowRoot: t instanceof ShadowRoot ? t : null,
782
+ host: e,
783
+ shadowRoot: e instanceof ShadowRoot ? e : null,
761
784
  element: l,
762
785
  state: l.state,
763
786
  setState: (u = l.setState) == null ? void 0 : u.bind(l)
@@ -773,11 +796,11 @@ const bt = (t, n, s) => {
773
796
  throw new Error(`Expected JavaScript but got ${b}`);
774
797
  return m.text();
775
798
  }).then((m) => {
776
- rt(
799
+ at(
777
800
  m,
801
+ t,
778
802
  s,
779
803
  e,
780
- t,
781
804
  l,
782
805
  o
783
806
  );
@@ -785,10 +808,10 @@ const bt = (t, n, s) => {
785
808
  console.error(`Failed to load external script: ${f.src}`, m);
786
809
  });
787
810
  }
788
- it(t, l);
789
- }), Mt = (t, n) => {
790
- var a, l, u, f, p, E, m, b, Z, R, ct, at;
791
- const { tagName: s, template: e, scripts: o, externalScripts: i, styles: r, sourcePath: c } = t, S = class S extends HTMLElement {
811
+ lt(e, l);
812
+ }), Ut = (e, n) => {
813
+ var a, l, u, f, p, E, m, b, G, N, ut, dt;
814
+ const { tagName: t, template: s, scripts: o, externalScripts: i, styles: r, sourcePath: c } = e, S = class S extends HTMLElement {
792
815
  constructor() {
793
816
  super();
794
817
  _(this, b);
@@ -801,18 +824,18 @@ const bt = (t, n, s) => {
801
824
  _(this, m, /* @__PURE__ */ new WeakMap());
802
825
  n && this.attachShadow({ mode: "open" });
803
826
  const h = {}, w = () => {
804
- tt(x(this, a), this.state, this), et(x(this, u), this.state, this), nt(x(this, f), this.state, this), M(this, b, at).call(this);
827
+ st(A(this, a), this.state, this), ot(A(this, u), this.state, this), rt(A(this, f), this.state, this), W(this, b, dt).call(this);
805
828
  };
806
829
  this.state = new Proxy(h, {
807
830
  get: (y, g) => y[g],
808
831
  set: (y, g, $) => {
809
- const A = y[g];
810
- return g in y && Object.is(A, $) || ($ !== null && typeof $ == "object" ? y[g] = M(this, b, Z).call(this, $, w) : y[g] = $, Object.getOwnPropertyDescriptor(this, g) || Object.defineProperty(this, g, {
832
+ const x = y[g];
833
+ return g in y && Object.is(x, $) || ($ !== null && typeof $ == "object" ? y[g] = W(this, b, G).call(this, $, w) : y[g] = $, Object.getOwnPropertyDescriptor(this, g) || Object.defineProperty(this, g, {
811
834
  get() {
812
835
  return this.state[g];
813
836
  },
814
- set(N) {
815
- this.state[g] = N;
837
+ set(B) {
838
+ this.state[g] = B;
816
839
  },
817
840
  enumerable: !0,
818
841
  configurable: !0
@@ -831,26 +854,26 @@ const bt = (t, n, s) => {
831
854
  }
832
855
  // Invoked when element is added to the DOM
833
856
  connectedCallback() {
834
- return I(this, null, function* () {
835
- const h = n ? this.shadowRoot : this, { bindings: w, twoWayBindings: y, conditionals: g, loops: $ } = gt(
857
+ return j(this, null, function* () {
858
+ const h = n ? this.shadowRoot : this, { bindings: w, twoWayBindings: y, conditionals: g, loops: $ } = St(
836
859
  h,
837
- e
860
+ s
838
861
  );
839
- F(this, a, w), F(this, l, y), F(this, u, g), F(this, f, $);
840
- const A = yt(g), T = xt($);
841
- bt(h, r, n), yield Vt(
862
+ M(this, a, w), M(this, l, y), M(this, u, g), M(this, f, $);
863
+ const x = kt(g), T = Rt($);
864
+ xt(h, r, n), yield It(
842
865
  h,
843
866
  i,
844
- x(this, a),
845
- x(this, l),
846
- /* @__PURE__ */ new Set([...A, ...T]),
847
- x(this, E)
848
- ), (yield Lt(
867
+ A(this, a),
868
+ A(this, l),
869
+ /* @__PURE__ */ new Set([...x, ...T]),
870
+ A(this, E)
871
+ ), (yield Wt(
849
872
  h,
850
873
  o,
851
- x(this, a),
852
- x(this, l),
853
- /* @__PURE__ */ new Set([...A, ...T])
874
+ A(this, a),
875
+ A(this, l),
876
+ /* @__PURE__ */ new Set([...x, ...T])
854
877
  )).forEach((v, V) => {
855
878
  if (this.state[V] === void 0)
856
879
  try {
@@ -859,24 +882,33 @@ const bt = (t, n, s) => {
859
882
  } catch (k) {
860
883
  this.state[V] = v;
861
884
  }
862
- }), this._initializeStateFromAttributes(), this._setupTwoWayBindings(), tt(x(this, a), this.state, this), et(x(this, u), this.state, this), nt(x(this, f), this.state, this), this._setupAttributeObserver();
885
+ }), this._initializeStateFromAttributes(), this._setupTwoWayBindings(), st(A(this, a), this.state, this), ot(A(this, u), this.state, this), rt(A(this, f), this.state, this), this._setupAttributeObserver();
863
886
  });
864
887
  }
865
888
  // Invoked when element is removed from the DOM
866
889
  disconnectedCallback() {
867
- this.__attributeObserver && (this.__attributeObserver.disconnect(), this.__attributeObserver = null), x(this, p).forEach((w) => {
890
+ this.__attributeObserver && (this.__attributeObserver.disconnect(), this.__attributeObserver = null), A(this, p).forEach((w) => {
868
891
  try {
869
892
  w();
870
893
  } catch (y) {
871
- console.error("Error cleaning up two-way binding:", y);
894
+ At(
895
+ "cleanup",
896
+ y,
897
+ R(this, {
898
+ lineHint: "disconnectedCallback cleanup"
899
+ })
900
+ );
872
901
  }
873
- }), F(this, p, []);
902
+ }), M(this, p, []);
874
903
  const h = this.__eventUnsubscribers;
875
904
  h && Array.isArray(h) && (h.forEach((w) => {
876
905
  try {
877
906
  w();
878
907
  } catch (y) {
879
- console.error("Error unsubscribing from event:", y);
908
+ D.error(
909
+ "⚠️ Event Bus Error: Failed to unsubscribe from event",
910
+ R(this)
911
+ ), D.error(` Error details: ${y.message}`);
880
912
  }
881
913
  }), this.__eventUnsubscribers = []);
882
914
  }
@@ -909,48 +941,48 @@ const bt = (t, n, s) => {
909
941
  const $ = "this.state.";
910
942
  h.startsWith($) && (h = h.slice($.length));
911
943
  }
912
- const y = M(g = S, R, ct).call(g, w);
944
+ const y = W(g = S, N, ut).call(g, w);
913
945
  this.state[h] = y;
914
946
  }
915
947
  // Setup two-way data bindings for input elements with $bind
916
948
  _setupTwoWayBindings() {
917
- x(this, l).forEach(
949
+ A(this, l).forEach(
918
950
  ({ element: h, path: w, raw: y, isContentEditable: g, initialValue: $ }) => {
919
- var T, N;
951
+ var T, B;
920
952
  if (this._getNestedValue(w) === void 0) {
921
953
  const v = $ || "";
922
- U(this.state, w, v);
954
+ Z(this.state, w, v);
923
955
  }
924
956
  if (g) {
925
957
  const v = h;
926
958
  v.textContent = (T = this._getNestedValue(w)) != null ? T : "";
927
- const V = (z) => {
928
- const L = z.target.textContent || "";
929
- U(this.state, w, L);
959
+ const V = (P) => {
960
+ const L = P.target.textContent || "";
961
+ Z(this.state, w, L);
930
962
  };
931
963
  v.addEventListener("input", V);
932
964
  const k = () => {
933
965
  v.removeEventListener("input", V);
934
966
  };
935
- x(this, p).push(k);
967
+ A(this, p).push(k);
936
968
  } else {
937
969
  const v = h, V = v instanceof HTMLInputElement && v.type === "checkbox";
938
- v instanceof HTMLInputElement && v.type, V ? v.checked = !!this._getNestedValue(w) : v.value = (N = this._getNestedValue(w)) != null ? N : "";
939
- const k = (W) => {
940
- const L = W.target;
941
- let H;
942
- L instanceof HTMLInputElement && L.type === "checkbox" ? H = L.checked : (L instanceof HTMLInputElement && L.type, H = L.value), U(this.state, w, H);
970
+ v instanceof HTMLInputElement && v.type, V ? v.checked = !!this._getNestedValue(w) : v.value = (B = this._getNestedValue(w)) != null ? B : "";
971
+ const k = (H) => {
972
+ const L = H.target;
973
+ let I;
974
+ L instanceof HTMLInputElement && L.type === "checkbox" ? I = L.checked : (L instanceof HTMLInputElement && L.type, I = L.value), Z(this.state, w, I);
943
975
  };
944
976
  v.addEventListener("input", k);
945
- const z = () => {
977
+ const P = () => {
946
978
  v.removeEventListener("input", k);
947
979
  };
948
- if (x(this, p).push(z), v instanceof HTMLSelectElement || v instanceof HTMLInputElement && ["checkbox", "radio", "file"].includes(v.type)) {
980
+ if (A(this, p).push(P), v instanceof HTMLSelectElement || v instanceof HTMLInputElement && ["checkbox", "radio", "file"].includes(v.type)) {
949
981
  v.addEventListener("change", k);
950
- const W = () => {
982
+ const H = () => {
951
983
  v.removeEventListener("change", k);
952
984
  };
953
- x(this, p).push(W);
985
+ A(this, p).push(H);
954
986
  }
955
987
  }
956
988
  }
@@ -966,15 +998,15 @@ const bt = (t, n, s) => {
966
998
  * @param target - The object or array to make reactive
967
999
  * @param callback - Function to call when any nested property changes
968
1000
  */
969
- Z = function(h, w) {
1001
+ G = function(h, w) {
970
1002
  if (h === null || typeof h != "object" || h instanceof HTMLElement || h instanceof Node)
971
1003
  return h;
972
- if (x(this, m).has(h))
973
- return x(this, m).get(h);
1004
+ if (A(this, m).has(h))
1005
+ return A(this, m).get(h);
974
1006
  const y = new Proxy(h, {
975
1007
  get: (g, $) => {
976
- const A = g[$];
977
- return Array.isArray(g) && typeof A == "function" && [
1008
+ const x = g[$];
1009
+ return Array.isArray(g) && typeof x == "function" && [
978
1010
  "push",
979
1011
  "pop",
980
1012
  "shift",
@@ -982,18 +1014,18 @@ const bt = (t, n, s) => {
982
1014
  "splice",
983
1015
  "sort",
984
1016
  "reverse"
985
- ].includes($) ? (...N) => {
986
- const v = A.apply(g, N);
1017
+ ].includes($) ? (...B) => {
1018
+ const v = x.apply(g, B);
987
1019
  return w(), v;
988
- } : A !== null && typeof A == "object" ? M(this, b, Z).call(this, A, w) : A;
1020
+ } : x !== null && typeof x == "object" ? W(this, b, G).call(this, x, w) : x;
989
1021
  },
990
- set: (g, $, A) => {
1022
+ set: (g, $, x) => {
991
1023
  const T = g[$];
992
- return Object.is(T, A) || (g[$] = A, w()), !0;
1024
+ return Object.is(T, x) || (g[$] = x, w()), !0;
993
1025
  }
994
1026
  });
995
- return x(this, m).set(h, y), y;
996
- }, R = new WeakSet(), ct = function(h) {
1027
+ return A(this, m).set(h, y), y;
1028
+ }, N = new WeakSet(), ut = function(h) {
997
1029
  if (h === null || h === "") return null;
998
1030
  if (h !== "undefined")
999
1031
  try {
@@ -1002,8 +1034,8 @@ const bt = (t, n, s) => {
1002
1034
  return h;
1003
1035
  }
1004
1036
  }, // Update two-way bound elements when state changes
1005
- at = function() {
1006
- x(this, l).forEach(({ element: h, path: w, isContentEditable: y }) => {
1037
+ dt = function() {
1038
+ A(this, l).forEach(({ element: h, path: w, isContentEditable: y }) => {
1007
1039
  const g = this._getNestedValue(w);
1008
1040
  if (y) {
1009
1041
  const $ = h;
@@ -1011,17 +1043,17 @@ const bt = (t, n, s) => {
1011
1043
  } else {
1012
1044
  const $ = h;
1013
1045
  if ($ instanceof HTMLInputElement && $.type === "checkbox") {
1014
- const A = !!g;
1015
- $.checked !== A && ($.checked = A);
1046
+ const x = !!g;
1047
+ $.checked !== x && ($.checked = x);
1016
1048
  } else
1017
1049
  $.value !== g && ($.value = g != null ? g : "");
1018
1050
  }
1019
1051
  });
1020
- }, _(S, R);
1052
+ }, _(S, N);
1021
1053
  let d = S;
1022
- customElements.define(s, d), mt.log(`Web component defined: <${s}></${s}>`);
1054
+ customElements.get(t) || (customElements.define(t, d), D.log(`Web component defined: <${t}></${t}>`));
1023
1055
  };
1024
1056
  export {
1025
- Mt as defineWebComponent
1057
+ Ut as defineWebComponent
1026
1058
  };
1027
- //# sourceMappingURL=webcomponent-UsabEy9d.mjs.map
1059
+ //# sourceMappingURL=webcomponent-DrCSyWrI.mjs.map