ladrillosjs 2.0.0-beta.3.2 → 2.0.0-beta.3.4

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.
@@ -0,0 +1,1250 @@
1
+ var pt = Object.defineProperty, mt = Object.defineProperties;
2
+ var bt = Object.getOwnPropertyDescriptors;
3
+ var Y = Object.getOwnPropertySymbols;
4
+ var gt = Object.prototype.hasOwnProperty, Et = Object.prototype.propertyIsEnumerable;
5
+ var et = (n) => {
6
+ throw TypeError(n);
7
+ };
8
+ var tt = (n, t, e) => t in n ? pt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, B = (n, t) => {
9
+ for (var e in t || (t = {}))
10
+ gt.call(t, e) && tt(n, e, t[e]);
11
+ if (Y)
12
+ for (var e of Y(t))
13
+ Et.call(t, e) && tt(n, e, t[e]);
14
+ return n;
15
+ }, Z = (n, t) => mt(n, bt(t));
16
+ var J = (n, t, e) => t.has(n) || et("Cannot " + e);
17
+ var _ = (n, t, e) => (J(n, t, "read from private field"), e ? e.call(n) : t.get(n)), F = (n, t, e) => t.has(n) ? et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), j = (n, t, e, s) => (J(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), N = (n, t, e) => (J(n, t, "access private method"), e);
18
+ var D = (n, t, e) => new Promise((s, o) => {
19
+ var l = (u) => {
20
+ try {
21
+ r(e.next(u));
22
+ } catch (f) {
23
+ o(f);
24
+ }
25
+ }, c = (u) => {
26
+ try {
27
+ r(e.throw(u));
28
+ } catch (f) {
29
+ o(f);
30
+ }
31
+ }, r = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(l, c);
32
+ r((e = e.apply(n, t)).next());
33
+ });
34
+ import { R as nt, l as wt, a as Q, c as W, b as $t, d as yt, e as vt, f as At, g as xt, h as G, i as _t } from "./index-COl4zCLy.mjs";
35
+ const St = (n, t, e) => {
36
+ if (!t) return;
37
+ const s = document.createElement("style");
38
+ s.textContent = t, e ? n.appendChild(s) : document.head.appendChild(s);
39
+ }, Ct = (n, t) => {
40
+ n.innerHTML = t;
41
+ const e = Tt(n), s = Rt(n), o = Lt(n), l = kt(n);
42
+ return { bindings: e, twoWayBindings: s, conditionals: o, loops: l };
43
+ }, st = (n) => {
44
+ const t = [], e = n.match(/\((.*)\)/);
45
+ if (!e) return t;
46
+ const s = e[1].trim();
47
+ return s && s.split(",").map((l) => l.trim()).forEach((l) => {
48
+ if (/^['"]/.test(l) || /^\d+/.test(l)) return;
49
+ const c = l.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
50
+ c && t.push(c[1]);
51
+ }), t;
52
+ }, Tt = (n) => {
53
+ const t = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, null), e = [];
54
+ let s;
55
+ const o = (c) => {
56
+ let r = c.parentElement;
57
+ for (; r; ) {
58
+ if (r.hasAttribute && r.hasAttribute("$for"))
59
+ return !0;
60
+ r = r.parentElement;
61
+ }
62
+ return !1;
63
+ };
64
+ for (; s = t.nextNode(); ) {
65
+ if (o(s))
66
+ continue;
67
+ const c = [...s.textContent.matchAll(nt.bindings)];
68
+ if (c.length > 0) {
69
+ const r = s.textContent, u = c.map((f) => {
70
+ const i = f[1].trim(), d = i.includes("(") && i.includes(")"), a = /[+*/%<>=!&|]/.test(i) || // Math or logical operators (excluding hyphen)
71
+ /\s-\s/.test(i), m = /^(!|typeof\s|void\s|delete\s)/.test(i), b = a || m || // Expressions starting with operators
72
+ /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(i) || // Method calls like name.toLowerCase()
73
+ /\bnew\s+/.test(i) || // Object instantiation like new Date()
74
+ /\b(typeof|instanceof|void|delete)\b/.test(i), p = d ? [i.split("(")[0].trim()] : i.split(".").map(($) => $.trim()), h = d ? st(i) : [];
75
+ return { raw: i, path: p, isFunction: d, isExpression: b, functionArgs: h };
76
+ });
77
+ e.push({ node: s, bindings: u, original: r });
78
+ }
79
+ }
80
+ return n.querySelectorAll("*").forEach((c) => {
81
+ if (!(c.hasAttribute("$for") || o(c)))
82
+ for (const r of c.attributes) {
83
+ if (r.name === "$if" || r.name === "$else-if" || r.name === "$else" || r.name === "$bind")
84
+ continue;
85
+ const u = [...r.value.matchAll(nt.bindings)];
86
+ if (u.length > 0) {
87
+ const f = r.value, i = u.map((d) => {
88
+ const a = d[1].trim(), m = a.includes("(") && a.includes(")"), b = /[+*/%<>=!&|]/.test(a) || // Math or logical operators (excluding hyphen)
89
+ /\s-\s/.test(a), p = /^(!|typeof\s|void\s|delete\s)/.test(a), h = b || p || // Expressions starting with operators
90
+ /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || // Method calls like name.toLowerCase()
91
+ /\bnew\s+/.test(a) || // Object instantiation like new Date()
92
+ /\b(typeof|instanceof|void|delete)\b/.test(a), $ = m ? [a.split("(")[0].trim()] : a.split(".").map((C) => C.trim()), E = m ? st(a) : [];
93
+ return { raw: a, path: $, isFunction: m, isExpression: h, functionArgs: E };
94
+ });
95
+ e.push({
96
+ node: c,
97
+ bindings: i,
98
+ original: f,
99
+ isAttribute: !0,
100
+ attributeName: r.name
101
+ });
102
+ }
103
+ }
104
+ }), e;
105
+ }, Rt = (n) => {
106
+ const t = [];
107
+ return n.querySelectorAll("[\\$bind]").forEach((s) => {
108
+ var r;
109
+ const o = s.getAttribute("$bind");
110
+ if (!o) return;
111
+ const l = o.trim(), c = l.split(".").map((u) => u.trim());
112
+ s instanceof HTMLInputElement || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement ? (t.push({
113
+ element: s,
114
+ path: c,
115
+ raw: l,
116
+ isContentEditable: !1,
117
+ initialValue: s.value || ""
118
+ }), s.removeAttribute("$bind")) : s instanceof HTMLElement && s.hasAttribute("contenteditable") && (t.push({
119
+ element: s,
120
+ path: c,
121
+ raw: l,
122
+ isContentEditable: !0,
123
+ initialValue: ((r = s.textContent) == null ? void 0 : r.trim()) || ""
124
+ }), s.removeAttribute("$bind"));
125
+ }), t;
126
+ }, Lt = (n) => {
127
+ const t = [], e = /* @__PURE__ */ new Set();
128
+ return n.querySelectorAll("[\\$if]").forEach((o) => {
129
+ if (e.has(o)) return;
130
+ const l = [];
131
+ let c = o;
132
+ for (; c; ) {
133
+ const r = c.hasAttribute("$if"), u = c.hasAttribute("$else-if"), f = c.hasAttribute("$else");
134
+ if (!r && !u && !f) break;
135
+ e.add(c);
136
+ let i, d = "";
137
+ r ? (i = "if", d = c.getAttribute("$if") || "", c.removeAttribute("$if")) : u ? (i = "else-if", d = c.getAttribute("$else-if") || "", c.removeAttribute("$else-if")) : (i = "else", c.removeAttribute("$else"));
138
+ const a = document.createComment(
139
+ `conditional:${i}:${d}`
140
+ ), m = c.parentElement || n, b = c.nextSibling;
141
+ m.insertBefore(a, c);
142
+ const p = {
143
+ element: c,
144
+ condition: d.trim(),
145
+ type: i,
146
+ placeholder: a,
147
+ group: [],
148
+ // Will be set after the group is complete
149
+ originalParent: m,
150
+ nextSibling: b
151
+ };
152
+ l.push(p);
153
+ const h = c.nextElementSibling;
154
+ if (c.remove(), c = h, h && !h.hasAttribute("$else-if") && !h.hasAttribute("$else"))
155
+ break;
156
+ }
157
+ l.forEach((r) => {
158
+ r.group = l;
159
+ }), t.push(l);
160
+ }), t;
161
+ }, Vt = (n) => {
162
+ const t = /* @__PURE__ */ new Set();
163
+ return n.forEach((e) => {
164
+ e.forEach((s) => {
165
+ let o = s.condition;
166
+ o = o.replace(/\{([^}]+)\}/g, "$1");
167
+ const l = /\b([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\b/g, c = /* @__PURE__ */ new Set([
168
+ "true",
169
+ "false",
170
+ "null",
171
+ "undefined",
172
+ "typeof",
173
+ "instanceof",
174
+ "new",
175
+ "return",
176
+ "if",
177
+ "else",
178
+ "for",
179
+ "while",
180
+ "do",
181
+ "switch",
182
+ "case",
183
+ "break",
184
+ "continue"
185
+ ]);
186
+ let r;
187
+ for (; (r = l.exec(o)) !== null; ) {
188
+ const f = r[1].split(".")[0];
189
+ c.has(f) || t.add(f);
190
+ }
191
+ });
192
+ }), t;
193
+ }, kt = (n) => {
194
+ const t = [];
195
+ return n.querySelectorAll("[\\$for]").forEach((s) => {
196
+ var m;
197
+ const o = s.getAttribute("$for");
198
+ if (!o) return;
199
+ const l = s.getAttribute("$key") || void 0, c = o.match(
200
+ /^\s*(?:\(([^,]+),\s*([^)]+)\)|([^\s]+))\s+(?:in|of)\s+(.+)\s*$/
201
+ );
202
+ if (!c) {
203
+ wt(`Invalid $for expression: "${o}"`, {
204
+ expression: o,
205
+ lineHint: "$for attribute parsing"
206
+ });
207
+ return;
208
+ }
209
+ const r = (c[1] || c[3]).trim(), u = (m = c[2]) == null ? void 0 : m.trim(), f = c[4].trim(), i = document.createComment(`loop:${o}`), d = s.parentElement || n;
210
+ d.insertBefore(i, s), s.removeAttribute("$for"), l && s.removeAttribute("$key"), s.remove();
211
+ const a = {
212
+ template: s,
213
+ expression: o,
214
+ itemName: r,
215
+ indexName: u,
216
+ arrayName: f,
217
+ keyAttribute: l,
218
+ placeholder: i,
219
+ renderedElements: [],
220
+ originalParent: d
221
+ };
222
+ t.push(a);
223
+ }), t;
224
+ }, Bt = (n) => {
225
+ const t = /* @__PURE__ */ new Set();
226
+ return n.forEach((e) => {
227
+ const s = e.arrayName.split(".")[0];
228
+ t.add(s);
229
+ }), t;
230
+ }, H = /* @__PURE__ */ new Map(), Ft = 100, U = (n) => {
231
+ const t = H.get(n);
232
+ if (t)
233
+ return H.delete(n), H.set(n, t), t;
234
+ const e = new Function(
235
+ "component",
236
+ `
237
+ const { Date, Array, Math, String, Number, Boolean, Object, JSON, RegExp } = globalThis;
238
+ with(component) {
239
+ return ${n};
240
+ }
241
+ `
242
+ );
243
+ if (H.size >= Ft) {
244
+ const s = H.keys().next().value;
245
+ s && H.delete(s);
246
+ }
247
+ return H.set(n, e), e;
248
+ }, z = (n, t) => t.reduce((e, s) => {
249
+ if (!(e == null || typeof e != "object"))
250
+ return e[s];
251
+ }, n), K = (n, t, e) => {
252
+ if (t.length === 0) return;
253
+ const s = t[t.length - 1], o = t.slice(0, -1);
254
+ let l = n;
255
+ for (const c of o)
256
+ (l[c] === void 0 || l[c] === null) && (l[c] = {}), l = l[c];
257
+ l[s] = e;
258
+ }, ot = (n, t, e) => {
259
+ if (n.length !== 0)
260
+ for (const s of n) {
261
+ let o = s.original, l, c = !1;
262
+ for (const { raw: r, path: u, isFunction: f, isExpression: i } of s.bindings) {
263
+ let d, a = !1;
264
+ if (i || f)
265
+ try {
266
+ d = U(r)(e || t);
267
+ } catch (b) {
268
+ Q(r, b, W(e)), d = void 0, a = !0;
269
+ }
270
+ else
271
+ d = z(t, u), d === void 0 && (a = !0);
272
+ if (a) {
273
+ c = !0;
274
+ continue;
275
+ }
276
+ const m = String(d != null ? d : "");
277
+ l = d, o = o.replace(`{${r}}`, m);
278
+ }
279
+ if (c && s.original, s.node.nodeType === Node.TEXT_NODE) {
280
+ const r = s.node, u = r.parentElement, f = o.trim().startsWith("<") && o.includes(">");
281
+ u && f ? u.innerHTML !== o && (u.innerHTML = o) : r.textContent !== o && (r.textContent = o);
282
+ } else {
283
+ const r = s.node;
284
+ s.isAttribute && s.attributeName && ([
285
+ "disabled",
286
+ "checked",
287
+ "readonly",
288
+ "required",
289
+ "selected",
290
+ "hidden",
291
+ "open",
292
+ "autofocus",
293
+ "autoplay",
294
+ "controls",
295
+ "loop",
296
+ "muted"
297
+ ].includes(s.attributeName.toLowerCase()) ? (typeof l == "boolean" ? l : l === "true" || l === "True") ? r.setAttribute(s.attributeName, "") : r.removeAttribute(s.attributeName) : r.setAttribute(s.attributeName, o));
298
+ }
299
+ }
300
+ }, Ot = (n, t, e) => {
301
+ if (!n) return !0;
302
+ let s = n.trim();
303
+ s = s.replace(/\{([^}]+)\}/g, "$1");
304
+ try {
305
+ return new Function(
306
+ "context",
307
+ "component",
308
+ `
309
+ with (context) {
310
+ try {
311
+ return Boolean(${s});
312
+ } catch (e) {
313
+ return false;
314
+ }
315
+ }
316
+ `
317
+ )(t, e);
318
+ } catch (o) {
319
+ return yt(
320
+ n,
321
+ o,
322
+ W(e)
323
+ ), !1;
324
+ }
325
+ }, at = (n, t) => {
326
+ const e = [
327
+ "click",
328
+ "dblclick",
329
+ "mousedown",
330
+ "mouseup",
331
+ "mouseover",
332
+ "mouseout",
333
+ "mousemove",
334
+ "mouseenter",
335
+ "mouseleave",
336
+ "keydown",
337
+ "keyup",
338
+ "keypress",
339
+ "focus",
340
+ "blur",
341
+ "change",
342
+ "input",
343
+ "submit",
344
+ "reset",
345
+ "scroll",
346
+ "resize",
347
+ "load",
348
+ "unload",
349
+ "touchstart",
350
+ "touchend",
351
+ "touchmove",
352
+ "touchcancel",
353
+ "dragstart",
354
+ "drag",
355
+ "dragend",
356
+ "dragenter",
357
+ "dragover",
358
+ "dragleave",
359
+ "drop"
360
+ ];
361
+ [n, ...n.querySelectorAll("*")].forEach((o) => {
362
+ e.forEach((l) => {
363
+ const c = `on${l}`, r = o.getAttribute(c);
364
+ if (r) {
365
+ const u = `__processed_${c}`;
366
+ if (o[u]) return;
367
+ o.removeAttribute(c), o.addEventListener(
368
+ l,
369
+ function(f) {
370
+ try {
371
+ new Function(
372
+ "event",
373
+ "component",
374
+ `
375
+ with(component) {
376
+ ${r}
377
+ }
378
+ `
379
+ ).call(this, f, t);
380
+ } catch (i) {
381
+ vt(
382
+ l,
383
+ r,
384
+ i,
385
+ W(t, {
386
+ elementTag: o.tagName.toLowerCase()
387
+ })
388
+ );
389
+ }
390
+ }
391
+ ), o[u] = !0;
392
+ }
393
+ });
394
+ });
395
+ }, rt = (n, t, e) => {
396
+ var s;
397
+ for (const o of n) {
398
+ let l = !1;
399
+ for (const c of o) {
400
+ const { element: r, condition: u, type: f, placeholder: i, originalParent: d } = c;
401
+ let a = !1;
402
+ f === "else" ? a = !l : l || (a = Ot(u, t, e), a && (l = !0));
403
+ const m = r.parentNode !== null;
404
+ a && !m ? ((s = i.parentNode) == null || s.insertBefore(r, i.nextSibling), e && at(r, e)) : !a && m && r.remove();
405
+ }
406
+ }
407
+ }, it = (n, t, e) => {
408
+ var s;
409
+ for (const o of n) {
410
+ const {
411
+ template: l,
412
+ itemName: c,
413
+ indexName: r,
414
+ arrayName: u,
415
+ placeholder: f,
416
+ renderedElements: i
417
+ } = o, d = z(t, u.split("."));
418
+ if (d !== void 0 && !Array.isArray(d)) {
419
+ $t(
420
+ `${c} in ${u}`,
421
+ new Error(`"${u}" is not an array, got: ${typeof d}`),
422
+ W(e, {
423
+ lineHint: "$for loop in template"
424
+ })
425
+ ), i.forEach((p) => p.remove()), i.length = 0;
426
+ return;
427
+ }
428
+ if (!d)
429
+ return;
430
+ const a = d.length, m = i.length;
431
+ if (a === m && a > 0) {
432
+ d.forEach((p, h) => {
433
+ const $ = i[h], E = Z(B({}, t), {
434
+ [c]: p
435
+ });
436
+ r && (E[r] = h), ct($, E, e);
437
+ });
438
+ return;
439
+ }
440
+ a < m && i.splice(a).forEach((h) => h.remove());
441
+ const b = Math.min(a, m);
442
+ for (let p = 0; p < b; p++) {
443
+ const h = d[p], $ = i[p], E = Z(B({}, t), {
444
+ [c]: h
445
+ });
446
+ r && (E[r] = p), ct($, E, e);
447
+ }
448
+ if (a > m) {
449
+ const p = document.createDocumentFragment();
450
+ for (let $ = m; $ < a; $++) {
451
+ const E = d[$], C = l.cloneNode(!0), T = Z(B({}, t), {
452
+ [c]: E
453
+ });
454
+ r && (T[r] = $), Wt(C, T, e), p.appendChild(C), i.push(C), e && at(C, e);
455
+ }
456
+ const h = i[m - 1] || f;
457
+ (s = h.parentNode) == null || s.insertBefore(p, h.nextSibling);
458
+ }
459
+ }
460
+ }, ct = (n, t, e) => {
461
+ const s = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, null);
462
+ let o;
463
+ for (; o = s.nextNode(); ) {
464
+ const c = o.__originalText;
465
+ if (c || o.textContent && o.textContent.includes("{")) {
466
+ const u = c || o.textContent;
467
+ c || (o.__originalText = u);
468
+ let f = u;
469
+ [...u.matchAll(/\{([^}]+)\}/g)].forEach((d) => {
470
+ const a = d[1].trim(), m = a.includes("(") && a.includes(")"), p = /[+*/%<>=!&|]/.test(a) || /\s-\s/.test(a) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || /\bnew\s+/.test(a) || /\b(typeof|instanceof|void|delete)\b/.test(a);
471
+ let h;
472
+ if (p || m)
473
+ try {
474
+ const $ = U(a), E = typeof t == "object" && t !== null ? B(B({}, t), e || {}) : e || {};
475
+ h = $(E);
476
+ } catch ($) {
477
+ h = void 0;
478
+ }
479
+ else {
480
+ const $ = a.split(".").map((E) => E.trim());
481
+ h = z(t, $);
482
+ }
483
+ h !== void 0 && (f = f.replace(`{${a}}`, String(h != null ? h : "")));
484
+ }), o.textContent !== f && (o.textContent = f);
485
+ }
486
+ }
487
+ [n, ...n.querySelectorAll("*")].forEach((c) => {
488
+ Array.from(c.attributes).forEach((r) => {
489
+ const u = r.__originalValue;
490
+ if (u || r.value.includes("{")) {
491
+ const i = u || r.value;
492
+ u || (r.__originalValue = i);
493
+ let d = i;
494
+ [...i.matchAll(/\{([^}]+)\}/g)].forEach((m) => {
495
+ const b = m[1].trim(), p = b.includes("(") && b.includes(")"), $ = /[+*/%<>=!&|]/.test(b) || /\s-\s/.test(b) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(b) || /\bnew\s+/.test(b) || /\b(typeof|instanceof|void|delete)\b/.test(b);
496
+ let E;
497
+ if ($ || p)
498
+ try {
499
+ const C = U(b), T = typeof t == "object" && t !== null ? B(B({}, t), e || {}) : e || {};
500
+ E = C(T);
501
+ } catch (C) {
502
+ E = void 0;
503
+ }
504
+ else {
505
+ const C = b.split(".").map((T) => T.trim());
506
+ E = z(t, C);
507
+ }
508
+ E !== void 0 && (d = d.replace(`{${b}}`, String(E != null ? E : "")));
509
+ }), r.value !== d && c.setAttribute(r.name, d);
510
+ }
511
+ });
512
+ });
513
+ }, Wt = (n, t, e) => {
514
+ const s = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, null);
515
+ let o;
516
+ for (; o = s.nextNode(); )
517
+ if (o.textContent && o.textContent.includes("{")) {
518
+ const c = o.textContent;
519
+ o.__originalText = c;
520
+ let r = c;
521
+ [...c.matchAll(/\{([^}]+)\}/g)].forEach((f) => {
522
+ const i = f[1].trim(), d = i.includes("(") && i.includes(")"), m = /[+*/%<>=!&|]/.test(i) || /\s-\s/.test(i) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(i) || // Method calls
523
+ /\bnew\s+/.test(i) || // Object instantiation like new Date()
524
+ /\b(typeof|instanceof|void|delete)\b/.test(i);
525
+ let b;
526
+ if (m || d)
527
+ try {
528
+ const p = U(i), h = typeof t == "object" && t !== null ? B(B({}, t), e || {}) : e || {};
529
+ b = p(h);
530
+ } catch (p) {
531
+ Q(
532
+ i,
533
+ p,
534
+ W(e, {
535
+ lineHint: "$for loop template binding"
536
+ })
537
+ ), b = void 0;
538
+ }
539
+ else {
540
+ const p = i.split(".").map((h) => h.trim());
541
+ b = z(t, p);
542
+ }
543
+ b !== void 0 && (r = r.replace(`{${i}}`, String(b != null ? b : "")));
544
+ }), o.textContent = r;
545
+ }
546
+ [n, ...n.querySelectorAll("*")].forEach((c) => {
547
+ Array.from(c.attributes).forEach((r) => {
548
+ if (r.value.includes("{")) {
549
+ const u = r.value;
550
+ r.__originalValue = u;
551
+ let f = u;
552
+ [...u.matchAll(/\{([^}]+)\}/g)].forEach((d) => {
553
+ const a = d[1].trim(), m = a.includes("(") && a.includes(")"), p = /[+*/%<>=!&|]/.test(a) || /\s-\s/.test(a) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || // Method calls
554
+ /\bnew\s+/.test(a) || // Object instantiation like new Date()
555
+ /\b(typeof|instanceof|void|delete)\b/.test(a);
556
+ let h;
557
+ if (p || m)
558
+ try {
559
+ const $ = U(a), E = typeof t == "object" && t !== null ? B(B({}, t), e || {}) : e || {};
560
+ h = $(E);
561
+ } catch ($) {
562
+ Q(
563
+ a,
564
+ $,
565
+ W(e, {
566
+ attributeName: r.name,
567
+ lineHint: "$for loop attribute binding"
568
+ })
569
+ ), h = void 0;
570
+ }
571
+ else {
572
+ const $ = a.split(".").map((E) => E.trim());
573
+ h = z(t, $);
574
+ }
575
+ h !== void 0 && (f = f.replace(`{${a}}`, String(h != null ? h : "")));
576
+ }), c.setAttribute(r.name, f);
577
+ }
578
+ });
579
+ });
580
+ }, lt = (n) => n instanceof ShadowRoot ? n.host : n, Mt = (n, t) => {
581
+ const e = /* @__PURE__ */ new Set();
582
+ t.forEach(({ path: o }) => {
583
+ const l = o[0];
584
+ e.add(l);
585
+ });
586
+ const s = [];
587
+ return e.forEach((o) => {
588
+ s.push(`
589
+ if (!Object.getOwnPropertyDescriptor(component, '${o}')) {
590
+ Object.defineProperty(component, '${o}', {
591
+ get() { return this.state.${o}; },
592
+ set(val) { this.state.${o} = val; },
593
+ enumerable: true,
594
+ configurable: true
595
+ });
596
+ }
597
+ `);
598
+ }), {
599
+ injectedCode: "",
600
+ // No longer needed in script scope
601
+ componentInjections: s.join(`
602
+ `),
603
+ bindVarNames: e
604
+ };
605
+ }, Nt = (n, t, e = /* @__PURE__ */ new Set()) => {
606
+ const s = [], o = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set();
607
+ t.forEach((u) => {
608
+ u.bindings.forEach((f) => {
609
+ const i = f.path[0];
610
+ l.add(i), f.isFunction && f.functionArgs && f.functionArgs.forEach((d) => {
611
+ l.add(d);
612
+ });
613
+ });
614
+ }), e.forEach((u) => {
615
+ l.add(u);
616
+ });
617
+ const c = /(?:const|let|var)\s+(\w+)\s*=\s*([^;]+);?/g;
618
+ let r;
619
+ for (; (r = c.exec(n)) !== null; ) {
620
+ const u = r[1], f = r[2].trim();
621
+ l.has(u) && (s.push(`component.state.${u} = ${u};`), o.set(u, f));
622
+ }
623
+ return { stateBindings: s, boundVarNames: l, defaultValues: o };
624
+ }, Ht = (n, t) => {
625
+ if (t.size === 0) return n;
626
+ let e = n;
627
+ return t.forEach((s) => {
628
+ const o = new RegExp(
629
+ `\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
630
+ "g"
631
+ );
632
+ e = e.replace(
633
+ o,
634
+ `component.state.${s}$1 $2`
635
+ );
636
+ const l = new RegExp(
637
+ `(?<!component\\.state\\.)\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
638
+ "g"
639
+ );
640
+ e = e.replace(
641
+ l,
642
+ `component.state.${s}$1`
643
+ );
644
+ const c = new RegExp(
645
+ `\\b${s}\\.(\\w+(?:\\.\\w+)*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
646
+ "g"
647
+ );
648
+ e = e.replace(
649
+ c,
650
+ `component.state.${s}.$1 $2`
651
+ );
652
+ const r = new RegExp(
653
+ `(?<!component\\.state\\.)(?<!const\\s${s}\\s*=\\s*{[^}]*)\\b${s}\\.(\\w+(?:\\.\\w+)*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
654
+ "g"
655
+ );
656
+ e = e.replace(
657
+ r,
658
+ `component.state.${s}.$1`
659
+ );
660
+ const u = new RegExp(
661
+ `(?<!\\.)\\b(\\+\\+|\\-\\-)${s}\\b|\\b${s}(\\+\\+|\\-\\-)`,
662
+ "g"
663
+ );
664
+ e = e.replace(u, (d) => {
665
+ if (d.startsWith("++") || d.startsWith("--"))
666
+ return `${d.substring(0, 2)}component.state.${s}`;
667
+ {
668
+ const a = d.substring(d.length - 2);
669
+ return `component.state.${s}${a}`;
670
+ }
671
+ });
672
+ const f = new RegExp(
673
+ `(?<!\\.)\\b${s}\\s*(\\+=|\\-=|\\*=|\\/=|%=|\\*\\*=|<<=|>>=|>>>=|&=|\\|=|\\^=)`,
674
+ "g"
675
+ );
676
+ e = e.replace(
677
+ f,
678
+ `component.state.${s}$1`
679
+ );
680
+ const i = new RegExp(
681
+ `(?<!const\\s)(?<!let\\s)(?<!var\\s)(?<!\\.)\\b${s}\\s*=\\s*([^=])`,
682
+ "g"
683
+ );
684
+ e = e.replace(
685
+ i,
686
+ `component.state.${s} = $1`
687
+ );
688
+ }), e;
689
+ }, ut = (n, t, e, s, o, l = /* @__PURE__ */ new Set()) => {
690
+ try {
691
+ const { injectedCode: c, componentInjections: r, bindVarNames: u } = Mt(n, e), f = /function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[\w\s]*)\s*=>/g, i = [];
692
+ let d;
693
+ for (; (d = f.exec(n)) !== null; ) {
694
+ const R = d[1] || d[2];
695
+ R && i.push(R);
696
+ }
697
+ const a = i.map(
698
+ (R) => `component.${R} = typeof ${R} !== 'undefined' ? ${R}.bind(component) : undefined;`
699
+ ).join(`
700
+ `), { stateBindings: m, boundVarNames: b, defaultValues: p } = Nt(n, t, l), h = /* @__PURE__ */ new Set([...b, ...u]), $ = m.join(`
701
+ `), E = Ht(
702
+ n,
703
+ h
704
+ ), C = `
705
+ (function() {
706
+ // Create component scope with direct access to state
707
+ const component = this;
708
+ const $state = component.state;
709
+
710
+ // Define $bind variables on component object for event handler access
711
+ ${r}
712
+
713
+ // Provide framework utilities with $ prefix to avoid naming conflicts
714
+ const $setState = (updates) => component.setState(updates);
715
+
716
+ // Event bus methods for component communication
717
+ const $emit = (eventName, data) => arguments[2].emit(eventName, data);
718
+ const $listen = (eventName, callback) => {
719
+ const unsubscribe = arguments[2].listen(eventName, callback);
720
+ // Store unsubscribe function for cleanup on disconnect
721
+ if (!component.__eventUnsubscribers) {
722
+ component.__eventUnsubscribers = [];
723
+ }
724
+ component.__eventUnsubscribers.push(unsubscribe);
725
+ return unsubscribe;
726
+ };
727
+
728
+ // Also attach to component for event handler access
729
+ component.$emit = $emit;
730
+ component.$listen = $listen;
731
+
732
+ // Override querySelector/querySelectorAll to query within the component's host
733
+ const host = arguments[1];
734
+ const $querySelector = (selector) => host.querySelector(selector);
735
+ const $querySelectorAll = (selector) => host.querySelectorAll(selector);
736
+
737
+ // Execute script content within component scope so $bind variables are accessible
738
+ with(component) {
739
+ ${E}
740
+
741
+ // Auto-bind variables to component state (e.g., const name = "value" → this.state.name = "value")
742
+ ${$}
743
+
744
+ // Auto-attach all detected functions to component for onclick access
745
+ ${a}
746
+ }
747
+ }).call(arguments[0], arguments[0], arguments[1], arguments[2])
748
+ `;
749
+ return new Function(C)(o, s, At), p;
750
+ } catch (c) {
751
+ return xt(c, W(o)), /* @__PURE__ */ new Map();
752
+ }
753
+ }, dt = (n, t) => {
754
+ [
755
+ "click",
756
+ "dblclick",
757
+ "mousedown",
758
+ "mouseup",
759
+ "mouseover",
760
+ "mouseout",
761
+ "mousemove",
762
+ "mouseenter",
763
+ "mouseleave",
764
+ "keydown",
765
+ "keyup",
766
+ "keypress",
767
+ "focus",
768
+ "blur",
769
+ "change",
770
+ "input",
771
+ "submit",
772
+ "reset",
773
+ "scroll",
774
+ "resize",
775
+ "load",
776
+ "unload",
777
+ "touchstart",
778
+ "touchend",
779
+ "touchmove",
780
+ "touchcancel",
781
+ "dragstart",
782
+ "drag",
783
+ "dragend",
784
+ "dragenter",
785
+ "dragover",
786
+ "dragleave",
787
+ "drop"
788
+ ].forEach((s) => {
789
+ const o = `on${s}`;
790
+ (n instanceof ShadowRoot ? n.querySelectorAll(`[${o}]`) : t.querySelectorAll(`[${o}]`)).forEach((c) => {
791
+ const r = `${o}`;
792
+ if (c[`__processed_${r}`]) return;
793
+ const u = c.getAttribute(o);
794
+ u && (c.removeAttribute(o), c.addEventListener(
795
+ s,
796
+ function(f) {
797
+ new Function(
798
+ "event",
799
+ "component",
800
+ `
801
+ with(component) {
802
+ ${u}
803
+ }
804
+ `
805
+ ).call(this, f, t);
806
+ }
807
+ ), c[`__processed_${r}`] = !0);
808
+ });
809
+ });
810
+ }, jt = (l, c, r, ...u) => D(null, [l, c, r, ...u], function* (n, t, e, s = [], o = /* @__PURE__ */ new Set()) {
811
+ const f = /* @__PURE__ */ new Map();
812
+ if (!(t != null && t.length)) return f;
813
+ const i = lt(n);
814
+ for (const d of t)
815
+ d.content && ut(
816
+ d.content,
817
+ e,
818
+ s,
819
+ n,
820
+ i,
821
+ o
822
+ ).forEach((m, b) => {
823
+ f.has(b) || f.set(b, m);
824
+ });
825
+ return dt(n, i), f;
826
+ }), zt = (n, t) => new Promise((e, s) => {
827
+ const o = document.querySelector(
828
+ `script[src="${n}"]`
829
+ );
830
+ if (o) {
831
+ if (o.dataset.loaded === "true") {
832
+ e();
833
+ return;
834
+ }
835
+ o.addEventListener("load", () => e(), { once: !0 }), o.addEventListener(
836
+ "error",
837
+ () => s(new Error(`Failed to load external script: ${n}`)),
838
+ { once: !0 }
839
+ );
840
+ return;
841
+ }
842
+ const l = document.createElement("script");
843
+ l.src = n, t && (l.type = t), l.onload = () => {
844
+ l.dataset.loaded = "true", e();
845
+ }, l.onerror = () => s(new Error(`Failed to load external script: ${n}`)), document.head.appendChild(l);
846
+ }), It = (n, t, e) => t.size === 0 ? n : function(...s) {
847
+ const o = n.apply(this, s);
848
+ return e.requestUpdate && e.requestUpdate(), o;
849
+ }, Ut = (n, t, e, s) => {
850
+ let o = n;
851
+ const l = /import\s+([^;]*?)\s+from\s+['"]([^'"]+)['"]/g;
852
+ if (o = o.replace(
853
+ l,
854
+ (r, u, f) => {
855
+ if (!f.startsWith(".") && !f.startsWith("/"))
856
+ return r;
857
+ try {
858
+ const i = new URL(f, s).href;
859
+ return `import ${u} from '${i}'`;
860
+ } catch (i) {
861
+ return console.warn(
862
+ `Could not resolve import path: ${f} relative to ${s}`
863
+ ), r;
864
+ }
865
+ }
866
+ ), t.size === 0)
867
+ return o;
868
+ const c = `
869
+ // Auto-generated: Reactive state synchronization for module scope
870
+ const __getComponent = () => window.__ladrilloContexts?.get('${e}')?.element;
871
+ const __syncState = (varName, value) => {
872
+ const component = __getComponent();
873
+ if (component?.setState) {
874
+ component.setState({ [varName]: value });
875
+ }
876
+ };
877
+ `;
878
+ return t.forEach((r) => {
879
+ const u = new RegExp(
880
+ `(let|const|var)\\s+${r}\\s*=\\s*([^;=][^;]*);`,
881
+ "g"
882
+ );
883
+ o = o.replace(u, (i, d, a) => {
884
+ const m = a.trim();
885
+ return `${d} ${r} = ${m}; __syncState('${r}', ${r});`;
886
+ });
887
+ const f = new RegExp(
888
+ `(?<!let\\s|const\\s|var\\s)(?<!\\.)\\b${r}\\s*=\\s*([^;=][^;]*);`,
889
+ "g"
890
+ );
891
+ o = o.replace(f, (i, d) => {
892
+ const a = d.trim();
893
+ return `${r} = ${a}; __syncState('${r}', ${r});`;
894
+ });
895
+ }), c + `
896
+ ` + o;
897
+ }, qt = (c, r, u, ...f) => D(null, [c, r, u, ...f], function* (n, t, e, s = [], o = /* @__PURE__ */ new Set(), l) {
898
+ var d;
899
+ const i = lt(n);
900
+ for (const a of t) {
901
+ let m;
902
+ l ? l.startsWith("http://") || l.startsWith("https://") ? m = l : m = new URL(
903
+ l,
904
+ window.location.href
905
+ ).href : m = window.location.href;
906
+ const b = new URL(a.src, m).href;
907
+ if (a.external)
908
+ yield zt(b, a.type);
909
+ else if (a.type === "module") {
910
+ const p = i.tagName.toLowerCase();
911
+ window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(p, {
912
+ host: n,
913
+ shadowRoot: n instanceof ShadowRoot ? n : null,
914
+ element: i,
915
+ state: i.state,
916
+ setState: (d = i.setState) == null ? void 0 : d.bind(i)
917
+ });
918
+ try {
919
+ const h = /* @__PURE__ */ new Set();
920
+ e.forEach((C) => {
921
+ C.bindings.forEach((T) => {
922
+ if (!T.isFunction) {
923
+ const R = T.path[0];
924
+ h.add(R);
925
+ }
926
+ });
927
+ });
928
+ let $ = b;
929
+ if (h.size > 0)
930
+ try {
931
+ let T = yield (yield fetch(b)).text();
932
+ T = Ut(
933
+ T,
934
+ h,
935
+ p,
936
+ b
937
+ );
938
+ const R = new Blob([T], { type: "application/javascript" });
939
+ $ = URL.createObjectURL(R);
940
+ } catch (C) {
941
+ console.warn(
942
+ `Could not transform module source, using original: ${b}`
943
+ );
944
+ }
945
+ const E = yield import(
946
+ /* webpackIgnore: true */
947
+ $
948
+ );
949
+ Object.entries(E).forEach(([C, T]) => {
950
+ if (C !== "default") {
951
+ const R = typeof T == "function" ? It(
952
+ T,
953
+ h,
954
+ i
955
+ ) : T;
956
+ i[C] = R;
957
+ }
958
+ }), E.default && (i.default = E.default), $ !== b && URL.revokeObjectURL($);
959
+ } catch (h) {
960
+ console.error(
961
+ `Failed to load or process module script: ${b}`,
962
+ h
963
+ );
964
+ }
965
+ } else
966
+ yield fetch(b).then((p) => {
967
+ if (!p.ok)
968
+ throw new Error(`HTTP ${p.status}: ${p.statusText}`);
969
+ const h = p.headers.get("content-type");
970
+ if (h && !h.includes("javascript") && !h.includes("text/plain"))
971
+ throw new Error(`Expected JavaScript but got ${h}`);
972
+ return p.text();
973
+ }).then((p) => {
974
+ ut(
975
+ p,
976
+ e,
977
+ s,
978
+ n,
979
+ i,
980
+ o
981
+ );
982
+ }).catch((p) => {
983
+ console.error(`Failed to load external script: ${a.src}`, p);
984
+ });
985
+ }
986
+ dt(n, i);
987
+ }), Xt = (n, t) => {
988
+ var f, i, d, a, m, b, p, h, I, E, ft, ht;
989
+ const { tagName: e, template: s, scripts: o, externalScripts: l, styles: c, sourcePath: r } = n, R = class R extends HTMLElement {
990
+ constructor() {
991
+ super();
992
+ F(this, h);
993
+ F(this, f, []);
994
+ F(this, i, []);
995
+ F(this, d, []);
996
+ F(this, a, []);
997
+ F(this, m, []);
998
+ F(this, b, r);
999
+ F(this, p, /* @__PURE__ */ new WeakMap());
1000
+ t && this.attachShadow({ mode: "open" });
1001
+ const g = {};
1002
+ let w = !1;
1003
+ const S = () => {
1004
+ w || (w = !0, requestAnimationFrame(() => {
1005
+ w = !1, ot(_(this, f), this.state, this), rt(_(this, d), this.state, this), it(_(this, a), this.state, this), N(this, h, ht).call(this);
1006
+ }));
1007
+ }, A = () => {
1008
+ S();
1009
+ };
1010
+ this.state = new Proxy(g, {
1011
+ get: (y, v) => y[v],
1012
+ set: (y, v, L) => {
1013
+ const M = y[v];
1014
+ return v in y && Object.is(M, L) || (L !== null && typeof L == "object" ? y[v] = N(this, h, I).call(this, L, A) : y[v] = L, Object.getOwnPropertyDescriptor(this, v) || Object.defineProperty(this, v, {
1015
+ get() {
1016
+ return this.state[v];
1017
+ },
1018
+ set(k) {
1019
+ this.state[v] = k;
1020
+ },
1021
+ enumerable: !0,
1022
+ configurable: !0
1023
+ }), A()), !0;
1024
+ }
1025
+ });
1026
+ }
1027
+ /**
1028
+ * Updates component state with one or more key-value pairs
1029
+ * @param updates - Object containing state updates
1030
+ * @example
1031
+ * component.setState({ count: 5, name: 'John' })
1032
+ */
1033
+ setState(g) {
1034
+ Object.assign(this.state, g);
1035
+ }
1036
+ // Invoked when element is added to the DOM
1037
+ connectedCallback() {
1038
+ return D(this, null, function* () {
1039
+ const g = t ? this.shadowRoot : this, { bindings: w, twoWayBindings: S, conditionals: A, loops: y } = Ct(
1040
+ g,
1041
+ s
1042
+ );
1043
+ j(this, f, w), j(this, i, S), j(this, d, A), j(this, a, y);
1044
+ const v = Vt(A), L = Bt(y);
1045
+ St(g, c, t), yield qt(
1046
+ g,
1047
+ l,
1048
+ _(this, f),
1049
+ _(this, i),
1050
+ /* @__PURE__ */ new Set([...v, ...L]),
1051
+ _(this, b)
1052
+ ), (yield jt(
1053
+ g,
1054
+ o,
1055
+ _(this, f),
1056
+ _(this, i),
1057
+ /* @__PURE__ */ new Set([...v, ...L])
1058
+ )).forEach((x, k) => {
1059
+ if (this.state[k] === void 0)
1060
+ try {
1061
+ const V = new Function(`return ${x}`);
1062
+ this.state[k] = V();
1063
+ } catch (V) {
1064
+ this.state[k] = x;
1065
+ }
1066
+ }), this._initializeStateFromAttributes(), this._setupTwoWayBindings(), ot(_(this, f), this.state, this), rt(_(this, d), this.state, this), it(_(this, a), this.state, this), this._setupAttributeObserver();
1067
+ });
1068
+ }
1069
+ // Invoked when element is removed from the DOM
1070
+ disconnectedCallback() {
1071
+ this.__attributeObserver && (this.__attributeObserver.disconnect(), this.__attributeObserver = null), _(this, m).forEach((w) => {
1072
+ try {
1073
+ w();
1074
+ } catch (S) {
1075
+ _t(
1076
+ "cleanup",
1077
+ S,
1078
+ W(this, {
1079
+ lineHint: "disconnectedCallback cleanup"
1080
+ })
1081
+ );
1082
+ }
1083
+ }), j(this, m, []);
1084
+ const g = this.__eventUnsubscribers;
1085
+ g && Array.isArray(g) && (g.forEach((w) => {
1086
+ try {
1087
+ w();
1088
+ } catch (S) {
1089
+ G.error(
1090
+ "⚠️ Event Bus Error: Failed to unsubscribe from event",
1091
+ W(this)
1092
+ ), G.error(` Error details: ${S.message}`);
1093
+ }
1094
+ }), this.__eventUnsubscribers = []);
1095
+ }
1096
+ // Set up observer to watch for attribute changes
1097
+ _setupAttributeObserver() {
1098
+ const g = new MutationObserver((w) => {
1099
+ w.forEach((S) => {
1100
+ if (S.type === "attributes" && S.attributeName) {
1101
+ const A = this.getAttribute(S.attributeName);
1102
+ this._handleAttributeChange(S.attributeName, A);
1103
+ }
1104
+ });
1105
+ });
1106
+ g.observe(this, {
1107
+ attributes: !0,
1108
+ attributeOldValue: !0
1109
+ }), this.__attributeObserver = g;
1110
+ }
1111
+ // initializes the state from the attributes
1112
+ _initializeStateFromAttributes() {
1113
+ this.getAttributeNames().forEach((g) => {
1114
+ const w = this.getAttribute(g);
1115
+ this._handleAttributeChange(g, w);
1116
+ });
1117
+ }
1118
+ // Invoked when attributes are changed.
1119
+ _handleAttributeChange(g, w) {
1120
+ var A;
1121
+ if (g) {
1122
+ const y = "this.state.";
1123
+ g.startsWith(y) && (g = g.slice(y.length));
1124
+ }
1125
+ const S = N(A = R, E, ft).call(A, w);
1126
+ this.state[g] = S;
1127
+ }
1128
+ // Setup two-way data bindings for input elements with $bind
1129
+ _setupTwoWayBindings() {
1130
+ _(this, i).forEach(
1131
+ ({ element: g, path: w, raw: S, isContentEditable: A, initialValue: y }) => {
1132
+ var L, M;
1133
+ if (this._getNestedValue(w) === void 0) {
1134
+ const x = y || "";
1135
+ K(this.state, w, x);
1136
+ }
1137
+ if (A) {
1138
+ const x = g;
1139
+ x.textContent = (L = this._getNestedValue(w)) != null ? L : "";
1140
+ const k = (X) => {
1141
+ const O = X.target.textContent || "";
1142
+ K(this.state, w, O);
1143
+ };
1144
+ x.addEventListener("input", k);
1145
+ const V = () => {
1146
+ x.removeEventListener("input", k);
1147
+ };
1148
+ _(this, m).push(V);
1149
+ } else {
1150
+ const x = g, k = x instanceof HTMLInputElement && x.type === "checkbox";
1151
+ x instanceof HTMLInputElement && x.type, k ? x.checked = !!this._getNestedValue(w) : x.value = (M = this._getNestedValue(w)) != null ? M : "";
1152
+ const V = (q) => {
1153
+ const O = q.target;
1154
+ let P;
1155
+ O instanceof HTMLInputElement && O.type === "checkbox" ? P = O.checked : (O instanceof HTMLInputElement && O.type, P = O.value), K(this.state, w, P);
1156
+ };
1157
+ x.addEventListener("input", V);
1158
+ const X = () => {
1159
+ x.removeEventListener("input", V);
1160
+ };
1161
+ if (_(this, m).push(X), x instanceof HTMLSelectElement || x instanceof HTMLInputElement && ["checkbox", "radio", "file"].includes(x.type)) {
1162
+ x.addEventListener("change", V);
1163
+ const q = () => {
1164
+ x.removeEventListener("change", V);
1165
+ };
1166
+ _(this, m).push(q);
1167
+ }
1168
+ }
1169
+ }
1170
+ );
1171
+ }
1172
+ // Helper to get nested value from state
1173
+ _getNestedValue(g) {
1174
+ return g.reduce((w, S) => w == null ? void 0 : w[S], this.state);
1175
+ }
1176
+ };
1177
+ f = new WeakMap(), i = new WeakMap(), d = new WeakMap(), a = new WeakMap(), m = new WeakMap(), b = new WeakMap(), p = new WeakMap(), h = new WeakSet(), /**
1178
+ * Creates a deep reactive proxy that tracks nested object/array mutations
1179
+ * @param target - The object or array to make reactive
1180
+ * @param callback - Function to call when any nested property changes
1181
+ */
1182
+ I = function(g, w) {
1183
+ if (g === null || typeof g != "object" || g instanceof HTMLElement || g instanceof Node)
1184
+ return g;
1185
+ if (_(this, p).has(g))
1186
+ return _(this, p).get(g);
1187
+ const S = new Proxy(g, {
1188
+ get: (A, y) => {
1189
+ const v = A[y];
1190
+ if (Array.isArray(A) && typeof v == "function" && [
1191
+ "push",
1192
+ "pop",
1193
+ "shift",
1194
+ "unshift",
1195
+ "splice",
1196
+ "sort",
1197
+ "reverse"
1198
+ ].includes(y))
1199
+ return (...M) => {
1200
+ const x = M.map(
1201
+ (V) => V !== null && typeof V == "object" ? N(this, h, I).call(this, V, w) : V
1202
+ ), k = v.apply(A, x);
1203
+ return w(), k;
1204
+ };
1205
+ if (v !== null && typeof v == "object") {
1206
+ if (_(this, p).has(v))
1207
+ return _(this, p).get(v);
1208
+ const L = N(this, h, I).call(this, v, w);
1209
+ return A[y] = L, L;
1210
+ }
1211
+ return v;
1212
+ },
1213
+ set: (A, y, v) => {
1214
+ const L = A[y];
1215
+ return Object.is(L, v) || (v !== null && typeof v == "object" ? A[y] = N(this, h, I).call(this, v, w) : A[y] = v, w()), !0;
1216
+ }
1217
+ });
1218
+ return _(this, p).set(g, S), S;
1219
+ }, E = new WeakSet(), ft = function(g) {
1220
+ if (g === null || g === "") return null;
1221
+ if (g !== "undefined")
1222
+ try {
1223
+ return JSON.parse(g);
1224
+ } catch (w) {
1225
+ return g;
1226
+ }
1227
+ }, // Update two-way bound elements when state changes
1228
+ ht = function() {
1229
+ _(this, i).forEach(({ element: g, path: w, isContentEditable: S }) => {
1230
+ const A = this._getNestedValue(w);
1231
+ if (S) {
1232
+ const y = g;
1233
+ y.textContent !== A && (y.textContent = A != null ? A : "");
1234
+ } else {
1235
+ const y = g;
1236
+ if (y instanceof HTMLInputElement && y.type === "checkbox") {
1237
+ const v = !!A;
1238
+ y.checked !== v && (y.checked = v);
1239
+ } else
1240
+ y.value !== A && (y.value = A != null ? A : "");
1241
+ }
1242
+ });
1243
+ }, F(R, E);
1244
+ let u = R;
1245
+ customElements.get(e) || (customElements.define(e, u), G.log(`Web component defined: <${e}></${e}>`));
1246
+ };
1247
+ export {
1248
+ Xt as defineWebComponent
1249
+ };
1250
+ //# sourceMappingURL=webcomponent-WCW6485Z.mjs.map