cruzo 0.9.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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +268 -0
  3. package/assets/cruzo.png +0 -0
  4. package/dist/component-CH-TJ5VF.js +1850 -0
  5. package/dist/component-CH-TJ5VF.js.map +1 -0
  6. package/dist/component.d.ts +62 -0
  7. package/dist/component.d.ts.map +1 -0
  8. package/dist/components-registry.service.d.ts +21 -0
  9. package/dist/components-registry.service.d.ts.map +1 -0
  10. package/dist/http.d.ts +54 -0
  11. package/dist/http.d.ts.map +1 -0
  12. package/dist/index.d.ts +14 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +355 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/interfaces.d.ts +39 -0
  17. package/dist/interfaces.d.ts.map +1 -0
  18. package/dist/lib/component.d.ts +62 -0
  19. package/dist/lib/component.d.ts.map +1 -0
  20. package/dist/lib/components-registry.service.d.ts +21 -0
  21. package/dist/lib/components-registry.service.d.ts.map +1 -0
  22. package/dist/lib/http.d.ts +54 -0
  23. package/dist/lib/http.d.ts.map +1 -0
  24. package/dist/lib/index.d.ts +14 -0
  25. package/dist/lib/index.d.ts.map +1 -0
  26. package/dist/lib/interfaces.d.ts +39 -0
  27. package/dist/lib/interfaces.d.ts.map +1 -0
  28. package/dist/lib/router.service.d.ts +84 -0
  29. package/dist/lib/router.service.d.ts.map +1 -0
  30. package/dist/lib/rx-scope.d.ts +76 -0
  31. package/dist/lib/rx-scope.d.ts.map +1 -0
  32. package/dist/lib/rx.d.ts +21 -0
  33. package/dist/lib/rx.d.ts.map +1 -0
  34. package/dist/lib/service.d.ts +10 -0
  35. package/dist/lib/service.d.ts.map +1 -0
  36. package/dist/lib/template.d.ts +141 -0
  37. package/dist/lib/template.d.ts.map +1 -0
  38. package/dist/lib/utils.d.ts +4 -0
  39. package/dist/lib/utils.d.ts.map +1 -0
  40. package/dist/lib/vm.d.ts +118 -0
  41. package/dist/lib/vm.d.ts.map +1 -0
  42. package/dist/router.service-CYzZn3L6.js +231 -0
  43. package/dist/router.service-CYzZn3L6.js.map +1 -0
  44. package/dist/router.service.d.ts +84 -0
  45. package/dist/router.service.d.ts.map +1 -0
  46. package/dist/rx-scope.d.ts +76 -0
  47. package/dist/rx-scope.d.ts.map +1 -0
  48. package/dist/rx.d.ts +21 -0
  49. package/dist/rx.d.ts.map +1 -0
  50. package/dist/service.d.ts +10 -0
  51. package/dist/service.d.ts.map +1 -0
  52. package/dist/template.d.ts +141 -0
  53. package/dist/template.d.ts.map +1 -0
  54. package/dist/ui-components/button-group/button-group.component.d.ts +17 -0
  55. package/dist/ui-components/button-group/button-group.component.d.ts.map +1 -0
  56. package/dist/ui-components/button-group.css +38 -0
  57. package/dist/ui-components/button-group.js +35 -0
  58. package/dist/ui-components/button-group.js.map +1 -0
  59. package/dist/ui-components/input/input.component.d.ts +41 -0
  60. package/dist/ui-components/input/input.component.d.ts.map +1 -0
  61. package/dist/ui-components/input.css +13 -0
  62. package/dist/ui-components/input.js +104 -0
  63. package/dist/ui-components/input.js.map +1 -0
  64. package/dist/ui-components/modal/modal.component.d.ts +32 -0
  65. package/dist/ui-components/modal/modal.component.d.ts.map +1 -0
  66. package/dist/ui-components/modal.css +35 -0
  67. package/dist/ui-components/modal.js +45 -0
  68. package/dist/ui-components/modal.js.map +1 -0
  69. package/dist/ui-components/router-link/router-link.d.ts +29 -0
  70. package/dist/ui-components/router-link/router-link.d.ts.map +1 -0
  71. package/dist/ui-components/router-link.js +46 -0
  72. package/dist/ui-components/router-link.js.map +1 -0
  73. package/dist/ui-components/select/select.component.d.ts +30 -0
  74. package/dist/ui-components/select/select.component.d.ts.map +1 -0
  75. package/dist/ui-components/select.css +111 -0
  76. package/dist/ui-components/select.js +77 -0
  77. package/dist/ui-components/select.js.map +1 -0
  78. package/dist/ui-components/spinner/spinner.component.d.ts +30 -0
  79. package/dist/ui-components/spinner/spinner.component.d.ts.map +1 -0
  80. package/dist/ui-components/spinner.css +106 -0
  81. package/dist/ui-components/spinner.js +83 -0
  82. package/dist/ui-components/spinner.js.map +1 -0
  83. package/dist/ui-components/upload/upload.component.d.ts +17 -0
  84. package/dist/ui-components/upload/upload.component.d.ts.map +1 -0
  85. package/dist/ui-components/upload.css +31 -0
  86. package/dist/ui-components/upload.js +34 -0
  87. package/dist/ui-components/upload.js.map +1 -0
  88. package/dist/utils.d.ts +4 -0
  89. package/dist/utils.d.ts.map +1 -0
  90. package/dist/utils.js +26 -0
  91. package/dist/utils.js.map +1 -0
  92. package/dist/vm.d.ts +118 -0
  93. package/dist/vm.d.ts.map +1 -0
  94. package/package.json +74 -0
@@ -0,0 +1,1850 @@
1
+ var W = Object.defineProperty;
2
+ var P = (n, t, e) => t in n ? W(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var a = (n, t, e) => P(n, typeof t != "symbol" ? t + "" : t, e);
4
+ const Z = (n) => n === " " || n === `
5
+ ` || n === " " || n === "\r", _ = (n) => n >= "0" && n <= "9", X = /[A-Za-z_$]/, O = /[A-Za-z0-9_$]/, Y = (n) => X.test(n), tt = (n) => O.test(n), et = [
6
+ "===",
7
+ "!==",
8
+ "==",
9
+ "!=",
10
+ "<=",
11
+ ">=",
12
+ "&&",
13
+ "||",
14
+ "??",
15
+ "?.",
16
+ "::",
17
+ "+",
18
+ "-",
19
+ "*",
20
+ "/",
21
+ "%",
22
+ "<",
23
+ ">",
24
+ "!",
25
+ "?",
26
+ ":",
27
+ ".",
28
+ ",",
29
+ "(",
30
+ ")",
31
+ "[",
32
+ "]",
33
+ "{",
34
+ "}"
35
+ ];
36
+ function st(n, t) {
37
+ for (const e of et) if (n.startsWith(e, t)) return e;
38
+ return null;
39
+ }
40
+ function nt(n) {
41
+ n = n.trim();
42
+ const t = [];
43
+ let e = 0;
44
+ for (; e < n.length; ) {
45
+ const s = n[e];
46
+ if (Z(s)) {
47
+ e++;
48
+ continue;
49
+ }
50
+ if (s === "'" || s === '"') {
51
+ const o = s, c = e;
52
+ e++;
53
+ let d = "", u = !1;
54
+ for (; e < n.length; ) {
55
+ const m = n[e++];
56
+ if (m === "\\") {
57
+ if (e >= n.length)
58
+ throw new Error(`Unterminated escape sequence in string at ${c}`);
59
+ const f = n[e++];
60
+ d += f === "n" ? `
61
+ ` : f === "t" ? " " : f;
62
+ continue;
63
+ }
64
+ if (m === o) {
65
+ u = !0;
66
+ break;
67
+ }
68
+ d += m;
69
+ }
70
+ if (!u)
71
+ throw new Error(`Unterminated string literal at ${c}`);
72
+ t.push({ t: "str", v: d });
73
+ continue;
74
+ }
75
+ if (_(s) || s === "." && _(n[e + 1] || "")) {
76
+ let o = "";
77
+ for (; e < n.length && (_(n[e]) || n[e] === "."); ) o += n[e++];
78
+ t.push({ t: "num", v: Number(o) });
79
+ continue;
80
+ }
81
+ if (Y(s)) {
82
+ let o = "";
83
+ for (; e < n.length && tt(n[e]); ) o += n[e++];
84
+ t.push({ t: "id", v: o });
85
+ continue;
86
+ }
87
+ const i = st(n, e);
88
+ if (i) {
89
+ e += i.length, "()[]{},".includes(i) ? t.push({ t: "punc", v: i }) : t.push({ t: "op", v: i });
90
+ continue;
91
+ }
92
+ throw new Error(`Unexpected char "${s}" at ${e}`);
93
+ }
94
+ return t.push({ t: "eof" }), t;
95
+ }
96
+ const A = {
97
+ ip: "color:#777",
98
+ hex: "color:#999",
99
+ op: "color:#4fc1ff;font-weight:600",
100
+ jump: "color:#ff5370;font-weight:600",
101
+ arg: "color:#000",
102
+ com: "color:#777;font-style:italic"
103
+ }, D = (n) => "0x" + (n >>> 0).toString(16).padStart(8, "0"), F = (n) => {
104
+ if (typeof n == "string") return JSON.stringify(n);
105
+ if (n == null || typeof n == "number" || typeof n == "boolean") return String(n);
106
+ try {
107
+ const t = JSON.stringify(n);
108
+ return t && t.length > 60 ? t.slice(0, 57) + "…" : t;
109
+ } catch {
110
+ return Object.prototype.toString.call(n);
111
+ }
112
+ }, B = {}, j = 255, J = 8;
113
+ var G = /* @__PURE__ */ ((n) => (n[n.PUSH_CONST = 1] = "PUSH_CONST", n[n.LOAD_ID = 2] = "LOAD_ID", n[n.LOAD_THIS = 3] = "LOAD_THIS", n[n.GET_PROP = 4] = "GET_PROP", n[n.GET_PROP_KEEP = 5] = "GET_PROP_KEEP", n[n.GET_INDEX = 6] = "GET_INDEX", n[n.GET_INDEX_KEEP = 7] = "GET_INDEX_KEEP", n[n.POP = 8] = "POP", n[n.POP_BELOW = 9] = "POP_BELOW", n[n.UNARY_NOT = 10] = "UNARY_NOT", n[n.UNARY_POS = 11] = "UNARY_POS", n[n.UNARY_NEG = 12] = "UNARY_NEG", n[n.BIN_ADD = 13] = "BIN_ADD", n[n.BIN_SUB = 14] = "BIN_SUB", n[n.BIN_MUL = 15] = "BIN_MUL", n[n.BIN_DIV = 16] = "BIN_DIV", n[n.BIN_MOD = 17] = "BIN_MOD", n[n.BIN_EQ = 18] = "BIN_EQ", n[n.BIN_NEQ = 19] = "BIN_NEQ", n[n.BIN_SEQ = 20] = "BIN_SEQ", n[n.BIN_SNEQ = 21] = "BIN_SNEQ", n[n.BIN_LT = 22] = "BIN_LT", n[n.BIN_LTE = 23] = "BIN_LTE", n[n.BIN_GT = 24] = "BIN_GT", n[n.BIN_GTE = 25] = "BIN_GTE", n[n.CALL_FN = 26] = "CALL_FN", n[n.CALL_METHOD = 27] = "CALL_METHOD", n[n.RX_UI = 28] = "RX_UI", n[n.JMP = 29] = "JMP", n[n.JMP_IF_FALSE = 30] = "JMP_IF_FALSE", n[n.JMP_IF_FALSE_KEEP = 31] = "JMP_IF_FALSE_KEEP", n[n.JMP_IF_TRUE_KEEP = 32] = "JMP_IF_TRUE_KEEP", n[n.JMP_IF_NULLISH = 33] = "JMP_IF_NULLISH", n[n.MAKE_ARRAY = 34] = "MAKE_ARRAY", n[n.MAKE_OBJECT = 35] = "MAKE_OBJECT", n[n.ONCE_ENTER = 36] = "ONCE_ENTER", n[n.ONCE_STORE = 37] = "ONCE_STORE", n))(G || {});
114
+ function it(n) {
115
+ return n === 29 || n === 30 || n === 31 || n === 32 || n === 33 || n === 36;
116
+ }
117
+ function M(n, t = 0) {
118
+ return t << J | n & j;
119
+ }
120
+ function R(n) {
121
+ return n & j;
122
+ }
123
+ function $(n) {
124
+ return n >>> J;
125
+ }
126
+ class K {
127
+ constructor(t, e, s, i, o, c) {
128
+ this.code = t, this.consts = e, this.idNames = s, this.exprCount = i, this.onceCount = o, this.expr = c;
129
+ }
130
+ onlyOnce() {
131
+ return this.exprCount === 1 && this.onceCount === 1;
132
+ }
133
+ fmtArg(t, e, s) {
134
+ switch (t) {
135
+ case 1:
136
+ return [`const[${e}]`, F(this.consts[e])];
137
+ case 2:
138
+ return [this.idNames[e] ?? `<bad id[${e}]>`, ""];
139
+ case 4:
140
+ case 5:
141
+ return [F(this.consts[e]), ""];
142
+ case 29:
143
+ case 30:
144
+ case 31:
145
+ case 32:
146
+ case 33:
147
+ return [`-> ${e}`, ""];
148
+ case 26:
149
+ case 27:
150
+ return [`args.length -> ${e}`, ""];
151
+ case 34:
152
+ return [`count=${e}`, ""];
153
+ case 35:
154
+ return [`pairs=${e}`, ""];
155
+ case 36:
156
+ return [`slot=${e} -> ${s ?? "?"}`, ""];
157
+ case 37:
158
+ return [`slot=${e}`, ""];
159
+ default:
160
+ return e ? [`a=${e}`, ""] : ["", ""];
161
+ }
162
+ }
163
+ log() {
164
+ for (let t = 0; t < this.code.length; t++) {
165
+ const e = this.code[t] >>> 0, s = R(e), i = $(e);
166
+ let o;
167
+ s === 36 && (o = (this.code[t + 1] ?? 0) >>> 0);
168
+ const c = G[s] ?? `OP_${s}`, [d, u] = this.fmtArg(s, i, o), m = `%c${String(t).padStart(4)} %c${D(e)} %c${c.padEnd(18)} %c${d}` + (u ? ` %c; ${u}` : ""), f = [
169
+ A.ip,
170
+ A.hex,
171
+ it(s) ? A.jump : A.op,
172
+ A.arg,
173
+ ...u ? [A.com] : []
174
+ ];
175
+ if (console.log(m, ...f), s === 36) {
176
+ t++;
177
+ const p = (this.code[t] ?? 0) >>> 0, r = `%c${String(t).padStart(4)} %c${D(p)} %c${"WIDE".padEnd(18)} %c${`-> ${p}`}`;
178
+ console.log(r, A.ip, A.hex, A.jump, A.arg);
179
+ }
180
+ }
181
+ }
182
+ noRunNeeded(t) {
183
+ var e;
184
+ return this.onlyOnce() && ((e = t.onceMap) == null ? void 0 : e.has(this));
185
+ }
186
+ setOnceSlotValue(t, e, s) {
187
+ if (t.onceMap ?? (t.onceMap = /* @__PURE__ */ new Map()), this.onlyOnce()) {
188
+ t.onceMap.set(this, s);
189
+ return;
190
+ }
191
+ let i = t.onceMap.get(this);
192
+ for (i || (i = [], t.onceMap.set(this, i)); i.length <= e; ) i.push(B);
193
+ i[e] = s;
194
+ }
195
+ getOnceSlotValue(t, e) {
196
+ if (t.onceMap ?? (t.onceMap = /* @__PURE__ */ new Map()), this.onlyOnce())
197
+ return t.onceMap.has(this) ? t.onceMap.get(this) : (t.onceMap.set(this, B), B);
198
+ let s = t.onceMap.get(this);
199
+ for (s || (s = [], t.onceMap.set(this, s)); s.length <= e; ) s.push(B);
200
+ return s[e];
201
+ }
202
+ getSafeErrorMsg(t, e) {
203
+ return `TemplateTypeError: Cannot read properties of ${t === null ? "null" : "undefined"} (reading '${e}')`;
204
+ }
205
+ run(t, e, s, i, o, c) {
206
+ const d = this.code, u = this.consts, m = this.idNames;
207
+ let f, p;
208
+ const r = [];
209
+ let h = 0, v = 0, E = 0;
210
+ const C = (N, w, y) => {
211
+ const l = r[N];
212
+ if (typeof l != "function")
213
+ throw new Error(`Cannot call undefined or non-function value: ${l}`);
214
+ if (!y) return l.call(w);
215
+ const x = r.slice(h - y, h);
216
+ return l.apply(w, x);
217
+ };
218
+ for (; v < d.length; ) {
219
+ const N = d[v++], w = R(N), y = $(N);
220
+ switch (w) {
221
+ case 1:
222
+ r[h++] = u[y];
223
+ break;
224
+ case 2: {
225
+ const l = m[y];
226
+ switch (l) {
227
+ case "root":
228
+ f ?? (f = t.root.self()), r[h++] = f;
229
+ break;
230
+ case "app":
231
+ r[h++] = i;
232
+ break;
233
+ case "index":
234
+ r[h++] = t.cloneIndex;
235
+ break;
236
+ case "$element":
237
+ r[h++] = t.node;
238
+ break;
239
+ case "event":
240
+ r[h++] = c;
241
+ break;
242
+ default:
243
+ r[h++] = t.getVarFromLexicalEnv(l);
244
+ break;
245
+ }
246
+ break;
247
+ }
248
+ case 3:
249
+ p ?? (p = t.getThisArg(o)), r[h++] = p;
250
+ break;
251
+ case 4: {
252
+ const l = u[y], x = r[--h];
253
+ x == null ? (t.handleSafeError(this.getSafeErrorMsg(x, l), this.expr), r[h++] = void 0) : r[h++] = x[l];
254
+ break;
255
+ }
256
+ case 5: {
257
+ const l = u[y], x = r[--h];
258
+ let g;
259
+ x == null ? (t.handleSafeError(this.getSafeErrorMsg(x, l), this.expr), g = void 0) : g = x[l], r[h++] = x, r[h++] = g;
260
+ break;
261
+ }
262
+ case 6: {
263
+ const l = r[--h], x = r[--h];
264
+ x == null ? (t.handleSafeError(this.getSafeErrorMsg(x, l + ""), this.expr), r[h++] = void 0) : r[h++] = x[l];
265
+ break;
266
+ }
267
+ case 7: {
268
+ const l = r[--h], x = r[--h];
269
+ let g;
270
+ x == null ? (t.handleSafeError(this.getSafeErrorMsg(x, l + ""), this.expr), g = void 0) : g = x[l], r[h++] = x, r[h++] = g;
271
+ break;
272
+ }
273
+ case 8:
274
+ h--;
275
+ break;
276
+ case 9: {
277
+ const l = r[--h];
278
+ h--, r[h++] = l;
279
+ break;
280
+ }
281
+ case 10:
282
+ r[h - 1] = !r[h - 1];
283
+ break;
284
+ case 11:
285
+ r[h - 1] = +r[h - 1];
286
+ break;
287
+ case 12:
288
+ r[h - 1] = -r[h - 1];
289
+ break;
290
+ case 13: {
291
+ const l = r[--h];
292
+ r[h - 1] = r[h - 1] + l;
293
+ break;
294
+ }
295
+ case 14: {
296
+ const l = r[--h];
297
+ r[h - 1] = r[h - 1] - l;
298
+ break;
299
+ }
300
+ case 15: {
301
+ const l = r[--h];
302
+ r[h - 1] = r[h - 1] * l;
303
+ break;
304
+ }
305
+ case 16: {
306
+ const l = r[--h];
307
+ r[h - 1] = r[h - 1] / l;
308
+ break;
309
+ }
310
+ case 17: {
311
+ const l = r[--h];
312
+ r[h - 1] = r[h - 1] % l;
313
+ break;
314
+ }
315
+ case 18: {
316
+ const l = r[--h];
317
+ r[h - 1] = r[h - 1] == l;
318
+ break;
319
+ }
320
+ case 19: {
321
+ const l = r[--h];
322
+ r[h - 1] = r[h - 1] != l;
323
+ break;
324
+ }
325
+ case 20: {
326
+ const l = r[--h];
327
+ r[h - 1] = r[h - 1] === l;
328
+ break;
329
+ }
330
+ case 21: {
331
+ const l = r[--h];
332
+ r[h - 1] = r[h - 1] !== l;
333
+ break;
334
+ }
335
+ case 22: {
336
+ const l = r[--h];
337
+ r[h - 1] = r[h - 1] < l;
338
+ break;
339
+ }
340
+ case 23: {
341
+ const l = r[--h];
342
+ r[h - 1] = r[h - 1] <= l;
343
+ break;
344
+ }
345
+ case 24: {
346
+ const l = r[--h];
347
+ r[h - 1] = r[h - 1] > l;
348
+ break;
349
+ }
350
+ case 25: {
351
+ const l = r[--h];
352
+ r[h - 1] = r[h - 1] >= l;
353
+ break;
354
+ }
355
+ case 26: {
356
+ const l = y, x = h - l - 1;
357
+ p ?? (p = t.getThisArg(o));
358
+ const g = C(x, p, l);
359
+ h = x, r[h++] = g;
360
+ break;
361
+ }
362
+ case 27: {
363
+ const l = y, x = h - l - 1, g = h - l - 2, k = r[g], T = C(x, k, l);
364
+ h = g, r[h++] = T;
365
+ break;
366
+ }
367
+ case 28: {
368
+ const l = r[--h];
369
+ if (l == null) throw new Error(`::rx is invalid on ${l}`);
370
+ r[h++] = t.getRxValue(
371
+ e,
372
+ l,
373
+ s,
374
+ o,
375
+ E > 0
376
+ );
377
+ break;
378
+ }
379
+ case 36: {
380
+ const l = y, x = d[v++] >>> 0, g = this.getOnceSlotValue(t, l);
381
+ g !== B ? (r[h++] = g, v = x) : E++;
382
+ break;
383
+ }
384
+ case 37: {
385
+ const l = y;
386
+ this.setOnceSlotValue(t, l, r[h - 1]), E--;
387
+ break;
388
+ }
389
+ case 29:
390
+ v = y;
391
+ break;
392
+ case 30: {
393
+ r[--h] || (v = y);
394
+ break;
395
+ }
396
+ case 31: {
397
+ r[h - 1] ? h-- : v = y;
398
+ break;
399
+ }
400
+ case 32: {
401
+ r[h - 1] ? v = y : h--;
402
+ break;
403
+ }
404
+ case 33: {
405
+ r[h - 1] == null && (v = y);
406
+ break;
407
+ }
408
+ case 34: {
409
+ const l = y, x = new Array(l);
410
+ for (let g = l - 1; g >= 0; g--) x[g] = r[--h];
411
+ r[h++] = x;
412
+ break;
413
+ }
414
+ case 35: {
415
+ const l = y, x = {};
416
+ for (let g = 0; g < l; g++) {
417
+ const k = r[--h], T = r[--h];
418
+ x[T] = k;
419
+ }
420
+ r[h++] = x;
421
+ break;
422
+ }
423
+ default:
424
+ throw new Error(`Unknown op ${w} at ip=${v - 1}`);
425
+ }
426
+ }
427
+ return h ? r[h - 1] : void 0;
428
+ }
429
+ }
430
+ class rt {
431
+ constructor(t) {
432
+ a(this, "pos", 0);
433
+ a(this, "code", []);
434
+ a(this, "consts", null);
435
+ a(this, "constMap");
436
+ a(this, "idNames", null);
437
+ a(this, "idMap");
438
+ a(this, "onceSlot", 0);
439
+ a(this, "exprDepth", 0);
440
+ a(this, "exprCount", 0);
441
+ this.tokens = t;
442
+ }
443
+ withNestedExpr(t) {
444
+ this.exprDepth++;
445
+ try {
446
+ return t();
447
+ } finally {
448
+ this.exprDepth--;
449
+ }
450
+ }
451
+ allocOnceSlot() {
452
+ return this.onceSlot++;
453
+ }
454
+ peek() {
455
+ return this.tokens[this.pos];
456
+ }
457
+ next() {
458
+ return this.tokens[this.pos++];
459
+ }
460
+ expectPunc(t) {
461
+ const e = this.next();
462
+ if (e.t !== "punc" || e.v !== t) throw new Error(`Expected "${t}"`);
463
+ }
464
+ expectOp(t) {
465
+ const e = this.next();
466
+ if (e.t !== "op" || e.v !== t) throw new Error(`Expected "${t}"`);
467
+ }
468
+ c(t) {
469
+ if (this.consts ?? (this.consts = []), typeof t == "string") {
470
+ const s = "s:" + t;
471
+ this.constMap ?? (this.constMap = /* @__PURE__ */ new Map());
472
+ const i = this.constMap.get(s);
473
+ if (i != null) return i;
474
+ const o = this.consts.length;
475
+ return this.consts.push(t), this.constMap.set(s, o), o;
476
+ }
477
+ const e = this.consts.length;
478
+ return this.consts.push(t), e;
479
+ }
480
+ id(t) {
481
+ this.idMap ?? (this.idMap = /* @__PURE__ */ new Map());
482
+ const e = this.idMap.get(t);
483
+ if (e != null) return e;
484
+ this.idNames ?? (this.idNames = []);
485
+ const s = this.idNames.length;
486
+ return this.idNames.push(t), this.idMap.set(t, s), s;
487
+ }
488
+ emit(t, e = 0) {
489
+ this.code.push(M(t, e));
490
+ }
491
+ emitJump(t) {
492
+ const e = this.code.length;
493
+ return this.code.push(M(t, 0)), e;
494
+ }
495
+ patch(t, e) {
496
+ const s = this.code[t];
497
+ this.code[t] = M(R(s), e);
498
+ }
499
+ canCount() {
500
+ return this.exprDepth === 0 && this.exprCount === 0;
501
+ }
502
+ parseBinaryCounted(t, e, s) {
503
+ t();
504
+ let i = this.peek();
505
+ if (this.canCount() && i.t === "op" && e.includes(i.v)) {
506
+ let o = 1;
507
+ for (; i.t === "op" && e.includes(i.v); ) {
508
+ const c = this.next().v;
509
+ t(), s(c), o++, i = this.peek();
510
+ }
511
+ this.exprCount = o;
512
+ return;
513
+ }
514
+ for (; i.t === "op" && e.includes(i.v); ) {
515
+ const o = this.next().v;
516
+ t(), s(o), i = this.peek();
517
+ }
518
+ }
519
+ parseShortCircuit(t, e, s) {
520
+ t();
521
+ let i = this.peek();
522
+ const o = this.canCount() && i.t === "op" && i.v === e;
523
+ let c = 1;
524
+ for (; i.t === "op" && i.v === e; ) {
525
+ this.next();
526
+ const d = this.emitJump(s);
527
+ t(), this.patch(d, this.code.length), o && c++, i = this.peek();
528
+ }
529
+ o && (this.exprCount = c);
530
+ }
531
+ parseNullishChain(t) {
532
+ t();
533
+ let e = this.peek();
534
+ const s = this.canCount() && e.t === "op" && e.v === "??";
535
+ let i = 1;
536
+ for (; e.t === "op" && e.v === "??"; ) {
537
+ this.next();
538
+ const o = this.emitJump(
539
+ 33
540
+ /* JMP_IF_NULLISH */
541
+ ), c = this.emitJump(
542
+ 29
543
+ /* JMP */
544
+ );
545
+ this.patch(o, this.code.length), this.emit(
546
+ 8
547
+ /* POP */
548
+ ), t(), this.patch(c, this.code.length), s && i++, e = this.peek();
549
+ }
550
+ s && (this.exprCount = i);
551
+ }
552
+ getBytecode(t) {
553
+ if (this.peek().t === "eof") throw new Error("Empty template expression is not allowed");
554
+ if (this.parseExpression(), this.peek().t !== "eof") throw new Error("Unexpected token after expression");
555
+ return new K(
556
+ new Uint32Array(this.code),
557
+ this.consts,
558
+ this.idNames,
559
+ this.exprCount || 1,
560
+ this.onceSlot,
561
+ t
562
+ );
563
+ }
564
+ parseExpression() {
565
+ this.parseTernary();
566
+ }
567
+ parseTernary() {
568
+ this.parseNullish();
569
+ const t = this.peek();
570
+ if (t.t === "op" && t.v === "?") {
571
+ this.canCount() && (this.exprCount = 3), this.next();
572
+ const e = this.emitJump(
573
+ 30
574
+ /* JMP_IF_FALSE */
575
+ );
576
+ this.withNestedExpr(() => this.parseExpression());
577
+ const s = this.emitJump(
578
+ 29
579
+ /* JMP */
580
+ );
581
+ this.expectOp(":"), this.patch(e, this.code.length), this.withNestedExpr(() => this.parseExpression()), this.patch(s, this.code.length);
582
+ }
583
+ }
584
+ parseNullish() {
585
+ this.parseNullishChain(() => this.parseOr());
586
+ }
587
+ parseOr() {
588
+ this.parseShortCircuit(
589
+ () => this.parseAnd(),
590
+ "||",
591
+ 32
592
+ /* JMP_IF_TRUE_KEEP */
593
+ );
594
+ }
595
+ parseAnd() {
596
+ this.parseShortCircuit(
597
+ () => this.parseEq(),
598
+ "&&",
599
+ 31
600
+ /* JMP_IF_FALSE_KEEP */
601
+ );
602
+ }
603
+ parseEq() {
604
+ this.parseBinaryCounted(
605
+ () => this.parseRel(),
606
+ ["===", "!==", "==", "!="],
607
+ (t) => {
608
+ switch (t) {
609
+ case "===":
610
+ this.emit(
611
+ 20
612
+ /* BIN_SEQ */
613
+ );
614
+ break;
615
+ case "!==":
616
+ this.emit(
617
+ 21
618
+ /* BIN_SNEQ */
619
+ );
620
+ break;
621
+ case "==":
622
+ this.emit(
623
+ 18
624
+ /* BIN_EQ */
625
+ );
626
+ break;
627
+ case "!=":
628
+ this.emit(
629
+ 19
630
+ /* BIN_NEQ */
631
+ );
632
+ break;
633
+ }
634
+ }
635
+ );
636
+ }
637
+ parseRel() {
638
+ this.parseBinaryCounted(
639
+ () => this.parseAdd(),
640
+ ["<", "<=", ">", ">="],
641
+ (t) => {
642
+ switch (t) {
643
+ case "<":
644
+ this.emit(
645
+ 22
646
+ /* BIN_LT */
647
+ );
648
+ break;
649
+ case "<=":
650
+ this.emit(
651
+ 23
652
+ /* BIN_LTE */
653
+ );
654
+ break;
655
+ case ">":
656
+ this.emit(
657
+ 24
658
+ /* BIN_GT */
659
+ );
660
+ break;
661
+ case ">=":
662
+ this.emit(
663
+ 25
664
+ /* BIN_GTE */
665
+ );
666
+ break;
667
+ }
668
+ }
669
+ );
670
+ }
671
+ parseAdd() {
672
+ this.parseBinaryCounted(
673
+ () => this.parseMul(),
674
+ ["+", "-"],
675
+ (t) => this.emit(
676
+ t === "+" ? 13 : 14
677
+ /* BIN_SUB */
678
+ )
679
+ );
680
+ }
681
+ parseMul() {
682
+ this.parseBinaryCounted(
683
+ () => this.parseUnary(),
684
+ ["*", "/", "%"],
685
+ (t) => this.emit(
686
+ t === "*" ? 15 : t === "/" ? 16 : 17
687
+ /* BIN_MOD */
688
+ )
689
+ );
690
+ }
691
+ parseUnary() {
692
+ const t = this.peek();
693
+ if (t.t === "id" && t.v === "once") {
694
+ const e = this.tokens[this.pos + 1];
695
+ if ((e == null ? void 0 : e.t) === "op" && e.v === "::") {
696
+ this.next(), this.next();
697
+ const s = this.allocOnceSlot();
698
+ this.emit(36, s);
699
+ const i = this.code.length;
700
+ this.code.push(0), this.parsePostfix(), this.emit(37, s), this.code[i] = this.code.length;
701
+ return;
702
+ }
703
+ }
704
+ if (t.t === "op" && ["!", "+", "-"].includes(t.v)) {
705
+ this.next(), this.parseUnary(), this.emit(
706
+ t.v === "!" ? 10 : t.v === "+" ? 11 : 12
707
+ /* UNARY_NEG */
708
+ );
709
+ return;
710
+ }
711
+ this.parsePostfix();
712
+ }
713
+ parsePostfix() {
714
+ this.parsePrimary();
715
+ let t = !1;
716
+ const e = [], s = () => {
717
+ t && (this.emit(
718
+ 9
719
+ /* POP_BELOW */
720
+ ), t = !1);
721
+ }, i = () => {
722
+ e.push(this.emitJump(
723
+ 33
724
+ /* JMP_IF_NULLISH */
725
+ ));
726
+ }, o = (d) => {
727
+ const u = this.c(d), m = this.peek(), f = m.t === "punc" && m.v === "(";
728
+ this.emit(f ? 5 : 4, u), t = f;
729
+ }, c = () => {
730
+ const d = this.peek(), u = d.t === "punc" && d.v === "(";
731
+ this.emit(
732
+ u ? 7 : 6
733
+ /* GET_INDEX */
734
+ ), t = u;
735
+ };
736
+ for (; ; ) {
737
+ const d = this.peek();
738
+ if (d.t === "op" && d.v === ".") {
739
+ s(), this.next();
740
+ const u = this.next();
741
+ if (u.t !== "id") throw new Error('Expected identifier after "."');
742
+ o(u.v);
743
+ continue;
744
+ }
745
+ if (d.t === "op" && d.v === "?.") {
746
+ const u = this.tokens[this.pos + 1];
747
+ if ((u == null ? void 0 : u.t) === "punc" && u.v === "(") {
748
+ s(), this.next(), i();
749
+ continue;
750
+ }
751
+ if ((u == null ? void 0 : u.t) === "punc" && u.v === "[") {
752
+ s(), this.next(), this.next(), i(), this.withNestedExpr(() => this.parseExpression()), this.expectPunc("]"), c();
753
+ continue;
754
+ }
755
+ s(), this.next(), i();
756
+ const m = this.next();
757
+ if (m.t !== "id") throw new Error('Expected identifier after "?."');
758
+ o(m.v);
759
+ continue;
760
+ }
761
+ if (d.t === "punc" && d.v === "[") {
762
+ s(), this.next(), this.withNestedExpr(() => this.parseExpression()), this.expectPunc("]"), c();
763
+ continue;
764
+ }
765
+ if (d.t === "punc" && d.v === "(") {
766
+ this.next();
767
+ const u = this.parseArgsAndCount();
768
+ this.expectPunc(")"), t ? (this.emit(27, u), t = !1) : this.emit(26, u);
769
+ continue;
770
+ }
771
+ if (d.t === "op" && d.v === "::") {
772
+ this.next();
773
+ const u = this.next();
774
+ if (u.t !== "id") throw new Error('Expected modifier after "::"');
775
+ if (u.v === "rx") {
776
+ s(), this.emit(
777
+ 28
778
+ /* RX_UI */
779
+ );
780
+ continue;
781
+ }
782
+ throw new Error(`Unknown modifier: ${u.v}`);
783
+ }
784
+ break;
785
+ }
786
+ if (s(), e.length) {
787
+ const d = this.code.length;
788
+ for (const u of e) this.patch(u, d);
789
+ }
790
+ }
791
+ parseArgsAndCount() {
792
+ let t = 0, e = this.peek();
793
+ if (e.t === "punc" && e.v === ")") return 0;
794
+ for (; ; ) {
795
+ if (this.withNestedExpr(() => this.parseExpression()), t++, e = this.peek(), e.t === "punc" && e.v === ",") {
796
+ this.next();
797
+ continue;
798
+ }
799
+ break;
800
+ }
801
+ return t;
802
+ }
803
+ parsePrimary() {
804
+ const t = this.next();
805
+ if (t.t === "num") {
806
+ this.emit(1, this.c(t.v));
807
+ return;
808
+ }
809
+ if (t.t === "str") {
810
+ this.emit(1, this.c(t.v));
811
+ return;
812
+ }
813
+ if (t.t === "id") {
814
+ if (t.v === "this") {
815
+ this.emit(
816
+ 3
817
+ /* LOAD_THIS */
818
+ );
819
+ return;
820
+ }
821
+ if (t.v === "true") {
822
+ this.emit(1, this.c(!0));
823
+ return;
824
+ }
825
+ if (t.v === "false") {
826
+ this.emit(1, this.c(!1));
827
+ return;
828
+ }
829
+ if (t.v === "null") {
830
+ this.emit(1, this.c(null));
831
+ return;
832
+ }
833
+ if (t.v === "undefined") {
834
+ this.emit(1, this.c(void 0));
835
+ return;
836
+ }
837
+ this.emit(2, this.id(t.v));
838
+ return;
839
+ }
840
+ if (t.t === "punc" && t.v === "(") {
841
+ this.withNestedExpr(() => this.parseExpression()), this.expectPunc(")");
842
+ return;
843
+ }
844
+ if (t.t === "punc" && t.v === "[") {
845
+ let e = 0, s = this.peek();
846
+ if (s.t === "punc" && s.v === "]") {
847
+ this.next(), this.emit(34, 0);
848
+ return;
849
+ }
850
+ for (; ; ) {
851
+ if (this.withNestedExpr(() => this.parseExpression()), e++, s = this.peek(), s.t === "punc" && s.v === ",") {
852
+ this.next();
853
+ continue;
854
+ }
855
+ break;
856
+ }
857
+ this.expectPunc("]"), this.emit(34, e);
858
+ return;
859
+ }
860
+ if (t.t === "punc" && t.v === "{") {
861
+ let e = 0, s = this.peek();
862
+ if (s.t === "punc" && s.v === "}") {
863
+ this.next(), this.emit(35, 0);
864
+ return;
865
+ }
866
+ for (; ; ) {
867
+ const i = this.next();
868
+ if (i.t !== "id" && i.t !== "str")
869
+ throw new Error("Expected object key");
870
+ const o = this.peek();
871
+ if (o.t === "op" && o.v === ":")
872
+ this.emit(1, this.c(i.v)), this.next(), this.withNestedExpr(() => this.parseExpression());
873
+ else {
874
+ if (i.t !== "id")
875
+ throw new Error("Shorthand requires identifier");
876
+ this.emit(1, this.c(i.v)), this.emit(2, this.id(i.v));
877
+ }
878
+ if (e++, s = this.peek(), s.t === "punc" && s.v === ",") {
879
+ this.next();
880
+ continue;
881
+ }
882
+ break;
883
+ }
884
+ this.expectPunc("}"), this.emit(35, e);
885
+ return;
886
+ }
887
+ throw new Error(`Unexpected token in expression: ${JSON.stringify(t, null, 2)}`);
888
+ }
889
+ }
890
+ const L = "{{", ot = "}}";
891
+ var q = /* @__PURE__ */ ((n) => (n[n.REPEAT = 1] = "REPEAT", n[n.EVENT = 2] = "EVENT", n[n.TEXT_NODE = 3] = "TEXT_NODE", n[n.ATTRIBUTE = 4] = "ATTRIBUTE", n[n.ATTACHED = 5] = "ATTACHED", n[n.LEXICAL_ENV = 6] = "LEXICAL_ENV", n[n.INNER_HTML = 7] = "INNER_HTML", n))(q || {});
892
+ class z {
893
+ constructor(t = 5e3) {
894
+ a(this, "map", /* @__PURE__ */ new Map());
895
+ this.limit = t;
896
+ }
897
+ get(t) {
898
+ return this.map.get(t);
899
+ }
900
+ set(t, e) {
901
+ if (!this.map.has(t) && (this.map.set(t, e), this.map.size > this.limit)) {
902
+ const s = this.map.keys().next().value;
903
+ this.map.delete(s);
904
+ }
905
+ }
906
+ }
907
+ const V = new z(5e3), H = new z(5e3), ht = {
908
+ checked: "checked",
909
+ selected: "selected",
910
+ disabled: "disabled",
911
+ hidden: "hidden",
912
+ readonly: "readOnly",
913
+ required: "required",
914
+ open: "open"
915
+ }, at = /* @__PURE__ */ new Set(["component-id", "scope-id"]);
916
+ let I = null;
917
+ const ct = { bubbles: !1 }, b = class b {
918
+ constructor(t) {
919
+ a(this, "root", null);
920
+ a(this, "debug", null);
921
+ a(this, "area", null);
922
+ a(this, "areas", null);
923
+ a(this, "parent", null);
924
+ a(this, "self", null);
925
+ a(this, "lexicalEnv", null);
926
+ a(this, "selector", "");
927
+ a(this, "children", null);
928
+ a(this, "clones", null);
929
+ a(this, "rxAcc", null);
930
+ a(this, "pointer", null);
931
+ a(this, "cloneIndex", null);
932
+ a(this, "parentNode", null);
933
+ a(this, "attached", !0);
934
+ a(this, "detecting", !1);
935
+ a(this, "repeatBC", null);
936
+ a(this, "attachedBC", null);
937
+ a(this, "nodeByIndex", null);
938
+ a(this, "nodeValueByIndex", null);
939
+ a(this, "attrValueByIndex", null);
940
+ a(this, "innerHTMLValue", "");
941
+ a(this, "events", null);
942
+ a(this, "onRxUpdate", null);
943
+ a(this, "rxUpdated", null);
944
+ a(this, "rxUpdatedScheduled", !1);
945
+ a(this, "domStructureChanged", null);
946
+ a(this, "domChangedScheduled", !1);
947
+ a(this, "onceMap", null);
948
+ a(this, "node", null);
949
+ if (Object.assign(this, t), typeof this.self != "function")
950
+ throw new Error("Invalid self param");
951
+ this.root || (this.root = this, this.areas = [], this.debug = {
952
+ selector: t.selector,
953
+ __tplFile: t.__tplFile
954
+ }, this.createAreas(this.node), this.onRxUpdate = this.getRxUpdate());
955
+ const e = +this.node.getAttribute("area-index");
956
+ this.area = this.root.areas[e];
957
+ const s = this.node.getAttribute("repeat");
958
+ s && (this.setPointer(), this.repeatBC = this.getTemplateBytecode(s, !0, "repeat"), this.area.filled || (this.area.templateNodeForClone = this.node.cloneNode(
959
+ !0
960
+ ), this.area.templateNodeForClone.removeAttribute("repeat")), this.node.remove(), this.clones = []), this.area.filled ? this.handleAttributesFilledArea() : this.handleAttributes(), this.area.innerHtmlTemplateBC || this.handleChildrens(this.node), this.setEvents(), this.area.attrNameByIndex && (this.attrValueByIndex = []), this.area.varNameByIndex && (this.lexicalEnv = /* @__PURE__ */ Object.create(null)), this.area.filled = !0;
961
+ }
962
+ static getChangeAttrEvent(t, e, s) {
963
+ return new CustomEvent(
964
+ "onchangeattr",
965
+ Object.assign({ detail: { name: t, prev: e, next: s } }, ct)
966
+ );
967
+ }
968
+ static allowAttributeEvent(t, e) {
969
+ I ?? (I = /* @__PURE__ */ new WeakMap()), I.set(t, e);
970
+ }
971
+ static stringToNode(t) {
972
+ const e = document.createElement("template");
973
+ e.innerHTML = t.trim();
974
+ const s = e.content.firstElementChild;
975
+ if (!s)
976
+ throw new Error("Template.stringToNode(): empty template HTML");
977
+ return s;
978
+ }
979
+ static setAppVariables(t) {
980
+ b.appVariables = t;
981
+ }
982
+ detectChanges() {
983
+ this.root.completelyClearRxAcc(), this.root.rxAcc = /* @__PURE__ */ new Map(), this.root.internalDetectChanges(!0);
984
+ }
985
+ internalDetectChanges(t) {
986
+ if (this.detecting) {
987
+ const e = ["Template error: detectChanges() called during detectChanges()"];
988
+ throw this.root.selector && e.push(this.root.selector), new Error(
989
+ e.join(" at ")
990
+ );
991
+ }
992
+ if (this.detecting = !0, this.updateVars(t), this.attachedBC && this.handleAttachedAttr(t), !this.attached) {
993
+ this.detecting = !1;
994
+ return;
995
+ }
996
+ this.repeatBC ? this.updateRepeat(t) : (this.updateAllTextNodes(t), this.updateAllChildren(t), this.updateAttributes(t), this.updateInnerHtml(t)), this.detecting = !1;
997
+ }
998
+ completelyClearRxAcc() {
999
+ if (this.root.rxAcc) {
1000
+ for (const t of this.root.rxAcc) {
1001
+ const e = t[0], s = t[1];
1002
+ for (const i of s) {
1003
+ const o = i[0];
1004
+ e.postUpdateFns.delete(o.root.onRxUpdate);
1005
+ }
1006
+ }
1007
+ this.root.rxAcc = null, this.root.rxUpdated = null;
1008
+ }
1009
+ }
1010
+ clearRxAccLocally() {
1011
+ if (this.root.rxAcc)
1012
+ for (const t of this.root.rxAcc) {
1013
+ const e = t[0], s = t[1];
1014
+ s.delete(this), s.size === 0 && e.postUpdateFns.delete(this.root.onRxUpdate);
1015
+ }
1016
+ }
1017
+ fullDestroy() {
1018
+ this.completelyClearRxAcc(), this.removeEvents(), this.node && (this.node.innerHTML = ""), this.removePointer();
1019
+ }
1020
+ destroyAllClones() {
1021
+ if (this.clones) {
1022
+ for (; this.clones.length; )
1023
+ this.destroyLastClone();
1024
+ this.markDomStructureChanged();
1025
+ }
1026
+ }
1027
+ locallyDestroyAllChildren() {
1028
+ if (this.children)
1029
+ for (let t = 0; t < this.children.length; t++)
1030
+ this.children[t].locallyDestroy();
1031
+ }
1032
+ setEventsRec() {
1033
+ if (this.setEvents(), !!this.children)
1034
+ for (let t = 0; t < this.children.length; t++)
1035
+ this.children[t].setEventsRec();
1036
+ }
1037
+ destroyLastClone() {
1038
+ const t = this.clones.pop();
1039
+ t.node && t.node.remove(), t.locallyDestroy(), t.removePointer();
1040
+ }
1041
+ locallyDestroy() {
1042
+ this.clearRxAccLocally(), this.removeEvents(), this.locallyDestroyAllChildren(), this.repeatBC && this.destroyAllClones();
1043
+ }
1044
+ attach() {
1045
+ const e = this.getPointer().nextSibling;
1046
+ e ? this.parentNode.insertBefore(this.node, e) : this.parentNode.appendChild(this.node), this.attached = !0, this.setEventsRec(), this.parentNode = null, this.markDomStructureChanged();
1047
+ }
1048
+ linkRxWhenDetach() {
1049
+ this.updateVars(!0), this.attachedBC && this.runVMProgramForContext(
1050
+ 5,
1051
+ this.attachedBC,
1052
+ 0,
1053
+ !0
1054
+ );
1055
+ }
1056
+ detach() {
1057
+ this.locallyDestroy(), this.linkRxWhenDetach(), this.parentNode = this.node.parentNode, this.node.remove(), this.attached = !1, this.markDomStructureChanged();
1058
+ }
1059
+ static kebabToCamel(t) {
1060
+ return t.replace(/-([a-z])/g, (e, s) => s.toUpperCase());
1061
+ }
1062
+ execRepeatExpr(t) {
1063
+ const e = this.runVMProgramForContext(1, this.repeatBC, 0, t) ?? [], s = typeof e;
1064
+ if (s === "number")
1065
+ try {
1066
+ const i = new Array(e);
1067
+ for (let o = 0; o < e; o++) i[o] = o;
1068
+ return i;
1069
+ } catch (i) {
1070
+ this.handleError(
1071
+ i,
1072
+ "vm run",
1073
+ this.repeatBC,
1074
+ this.repeatBC.expr,
1075
+ null,
1076
+ 1
1077
+ /* REPEAT */
1078
+ );
1079
+ }
1080
+ else Array.isArray(e) || this.handleError(
1081
+ new Error(
1082
+ `Repeat expression must return array or number, got ${s}`
1083
+ ),
1084
+ "vm run",
1085
+ this.repeatBC,
1086
+ this.repeatBC.expr,
1087
+ null,
1088
+ 1
1089
+ /* REPEAT */
1090
+ );
1091
+ return e;
1092
+ }
1093
+ rebuildClones(t = !1) {
1094
+ const e = this.execRepeatExpr(t), s = e.length - this.clones.length;
1095
+ if (s !== 0)
1096
+ if (s > 0) {
1097
+ const i = this.clones.length, o = i === 0 ? this.getPointer() : this.clones[i - 1].node, c = document.createDocumentFragment(), d = (u) => this.execRepeatExpr(u);
1098
+ for (let u = 0; u < s; u++) {
1099
+ const m = this.area.templateNodeForClone.cloneNode(!0);
1100
+ c.appendChild(m), this.addClone(m, d, i + u);
1101
+ }
1102
+ this.insertFragmentAfter(o, c), this.markDomStructureChanged();
1103
+ } else {
1104
+ for (; this.clones.length > e.length; )
1105
+ this.destroyLastClone();
1106
+ this.markDomStructureChanged();
1107
+ }
1108
+ }
1109
+ updateAttributes(t) {
1110
+ if (this.area.contentAttributes)
1111
+ for (let e = 0; e < this.area.contentAttributes.length; e++)
1112
+ this.updateAttr(this.area.contentAttributes[e], t);
1113
+ }
1114
+ updateVars(t) {
1115
+ if (this.area.varAttributes)
1116
+ for (let e = 0; e < this.area.varAttributes.length; e++) {
1117
+ const s = this.area.varAttributes[e];
1118
+ this.updateVar(s, t);
1119
+ }
1120
+ }
1121
+ removeEvents() {
1122
+ if (this.events) {
1123
+ for (const t in this.area.events) this.node.removeEventListener(t, this.events[t]);
1124
+ this.events = null;
1125
+ }
1126
+ }
1127
+ setEvents() {
1128
+ this.events ?? (this.events = /* @__PURE__ */ Object.create(null));
1129
+ for (const t in this.area.events) {
1130
+ const e = (s) => {
1131
+ this.runVMProgramForContext(
1132
+ 2,
1133
+ this.area.events[t],
1134
+ 0,
1135
+ !1,
1136
+ s
1137
+ );
1138
+ };
1139
+ this.events[t] = e, this.node.addEventListener(t, e);
1140
+ }
1141
+ }
1142
+ handleAttachedAttr(t) {
1143
+ const e = this.runVMProgramForContext(
1144
+ 5,
1145
+ this.attachedBC,
1146
+ 0,
1147
+ t
1148
+ );
1149
+ e && !this.attached ? this.attach() : !e && this.attached && this.detach();
1150
+ }
1151
+ updateRepeat(t = !1) {
1152
+ this.rebuildClones(t), this.updateAllClones(t);
1153
+ }
1154
+ reactiveUpdateAttachedAttr() {
1155
+ this.internalDetectChanges(!0);
1156
+ }
1157
+ reactiveUpdateLexicalEnv() {
1158
+ this.internalDetectChanges(!0);
1159
+ }
1160
+ reactiveUpdateRepeat() {
1161
+ this.attached && this.updateRepeat(!0);
1162
+ }
1163
+ reactiveUpdateNode(t) {
1164
+ this.attached && this.updateTextNode(t, !1);
1165
+ }
1166
+ reactiveUpdateAttr(t) {
1167
+ this.attached && this.updateAttr(t, !1);
1168
+ }
1169
+ reactiveUpdateInnerHtml() {
1170
+ this.attached && this.updateInnerHtml(!1);
1171
+ }
1172
+ updateTextNode(t, e) {
1173
+ const s = this.nodeByIndex[t], i = this.area.nodeTemplateByIndex[t], o = this.execBytecode(
1174
+ 3,
1175
+ i,
1176
+ t,
1177
+ e
1178
+ );
1179
+ this.nodeValueByIndex[t] === o && t in this.nodeValueByIndex || (s.textContent = o, this.nodeValueByIndex[t] = o);
1180
+ }
1181
+ updateAttr(t, e) {
1182
+ var u;
1183
+ const s = this.execBytecode(
1184
+ 4,
1185
+ this.area.attrTemplateByIndex[t],
1186
+ t,
1187
+ e
1188
+ );
1189
+ let i = this.area.attrNameByIndex[t];
1190
+ i === "data-src" && (i = "src");
1191
+ const o = this.attrValueByIndex[t];
1192
+ if (o === s && t in this.attrValueByIndex) return;
1193
+ const c = s === b.REMOVE_ATTR;
1194
+ c ? this.node.removeAttribute(i) : this.node.setAttribute(i, s);
1195
+ const d = ht[i];
1196
+ d && (this.node[d] = c ? !1 : !!s), this.attrValueByIndex[t] = s, (u = I == null ? void 0 : I.get(this.node)) != null && u.has(i) && this.node.dispatchEvent(b.getChangeAttrEvent(i, o, s));
1197
+ }
1198
+ updateInnerHtml(t) {
1199
+ if (!this.area.innerHtmlTemplateBC) return;
1200
+ const e = this.runVMProgramForContext(
1201
+ 7,
1202
+ this.area.innerHtmlTemplateBC,
1203
+ 0,
1204
+ t
1205
+ );
1206
+ this.innerHTMLValue !== e && (this.node.innerHTML = e, this.innerHTMLValue = e);
1207
+ }
1208
+ updateVar(t, e) {
1209
+ this.lexicalEnv[this.area.varNameByIndex[t]] = this.runVMProgramForContext(
1210
+ 6,
1211
+ this.area.varBytecodeByIndex[t],
1212
+ t,
1213
+ e
1214
+ );
1215
+ }
1216
+ updateAllTextNodes(t) {
1217
+ if (this.area.textNodes)
1218
+ for (let e = 0; e < this.area.textNodes.length; e++)
1219
+ this.updateTextNode(this.area.textNodes[e], t);
1220
+ }
1221
+ updateAllClones(t) {
1222
+ if (this.clones)
1223
+ for (let e = 0; e < this.clones.length; e++)
1224
+ this.clones[e].internalDetectChanges(t);
1225
+ }
1226
+ updateAllChildren(t) {
1227
+ if (this.children)
1228
+ for (let e = 0; e < this.children.length; e++)
1229
+ this.children[e].internalDetectChanges(t);
1230
+ }
1231
+ isTemplate(t) {
1232
+ if (!t) return !1;
1233
+ const e = t.indexOf(L);
1234
+ return e === -1 ? !1 : t.indexOf(ot, e + 2) !== -1;
1235
+ }
1236
+ handleTemplateParseError(t, e, s, i) {
1237
+ const o = t.slice(e, Math.min(e + 40, s)) + (s > e + 40 ? "..." : "");
1238
+ this.handleError(new Error(i), "template parse", null, t, o);
1239
+ }
1240
+ getNodeForError() {
1241
+ return this.node.outerHTML.split(">")[0] + ">";
1242
+ }
1243
+ getTemplateBytecode(t, e, s) {
1244
+ const i = H.get(t);
1245
+ if (i) return i;
1246
+ const o = [], c = t.length;
1247
+ let d = 0;
1248
+ for (; d < c; ) {
1249
+ const m = t.indexOf(L, d);
1250
+ if (m === -1) {
1251
+ d < c && o.push(t.slice(d));
1252
+ break;
1253
+ }
1254
+ m > d && o.push(t.slice(d, m));
1255
+ const f = m + 2, p = [];
1256
+ let r = f, h = null, v = -1;
1257
+ for (; r < c; ) {
1258
+ const E = t[r];
1259
+ if (h !== null) {
1260
+ if (E === "\\") {
1261
+ r += 2;
1262
+ continue;
1263
+ }
1264
+ if (E === h) {
1265
+ h = null, r++;
1266
+ continue;
1267
+ }
1268
+ r++;
1269
+ continue;
1270
+ }
1271
+ if (E === "'" || E === '"' || E === "`") {
1272
+ h = E, r++;
1273
+ continue;
1274
+ }
1275
+ if (E === "(" || E === "[" || E === "{") {
1276
+ p.push(E), r++;
1277
+ continue;
1278
+ }
1279
+ if (E === ")") {
1280
+ (!p.length || p[p.length - 1] !== "(") && this.handleTemplateParseError(t, f, c, `Unmatched ")" at position ${r}`), p.pop(), r++;
1281
+ continue;
1282
+ }
1283
+ if (E === "]") {
1284
+ (!p.length || p[p.length - 1] !== "[") && this.handleTemplateParseError(t, f, c, `Unmatched "]" at position ${r}`), p.pop(), r++;
1285
+ continue;
1286
+ }
1287
+ if (E === "}") {
1288
+ if (p.length && p[p.length - 1] === "{") {
1289
+ p.pop(), r++;
1290
+ continue;
1291
+ }
1292
+ if (p.length === 0 && t[r + 1] === "}") {
1293
+ v = r;
1294
+ break;
1295
+ }
1296
+ if (p.length > 0) {
1297
+ const C = p[p.length - 1] === "(" ? ")" : "]";
1298
+ this.handleTemplateParseError(t, f, c, `Expected "${C}" but got "}" at position ${r}`);
1299
+ }
1300
+ this.handleTemplateParseError(t, f, c, `Unexpected "}" at position ${r}`);
1301
+ }
1302
+ r++;
1303
+ }
1304
+ if (v === -1) {
1305
+ if (p.length > 0) {
1306
+ const E = p[p.length - 1], C = E === "(" ? ")" : E === "[" ? "]" : "}";
1307
+ this.handleTemplateParseError(t, f, c, `Unclosed "${E}": expected "${C}" before end of expression`);
1308
+ }
1309
+ o.push(this.getSingleBytecode(t.slice(f).trim(), t));
1310
+ break;
1311
+ }
1312
+ o.push(this.getSingleBytecode(t.slice(f, v).trim(), t)), d = v + 2;
1313
+ }
1314
+ e && o.length > 1 ? this.handleError(new Error("Template has multi expressions, only single expression is allowed here"), "vm compile", null, t) : o.filter((m) => m instanceof K).length || this.handleError(new Error(`Expression not found, ${this.getNodeForError()} in ${s} attr`), "vm compile", null, t);
1315
+ const u = o.length === 1 ? o[0] : o;
1316
+ return H.set(t, u), u;
1317
+ }
1318
+ getItem(t, e, s, i) {
1319
+ return typeof t == "string" ? t : this.runVMProgramForContext(e, t, s, i);
1320
+ }
1321
+ execBytecode(t, e, s, i) {
1322
+ if (!Array.isArray(e))
1323
+ return this.getItem(e, t, s, i);
1324
+ let o = new Array(e.length);
1325
+ for (let c = 0; c < e.length; c++) o[c] = this.getItem(e[c], t, s, i);
1326
+ return o.join("");
1327
+ }
1328
+ childNodeIsDynamic(t) {
1329
+ return t.hasAttribute("repeat") || t.hasAttribute("attached") ? !0 : this.root.areas[+t.getAttribute("area-index")].hasBindings;
1330
+ }
1331
+ addClone(t, e, s) {
1332
+ const i = new b({
1333
+ parent: this.parent,
1334
+ node: t,
1335
+ self: e,
1336
+ root: this.root,
1337
+ cloneIndex: s
1338
+ });
1339
+ return this.clones.push(i), i;
1340
+ }
1341
+ addChildren(t) {
1342
+ return new b({
1343
+ node: t,
1344
+ self: this.self,
1345
+ root: this.root,
1346
+ cloneIndex: this.cloneIndex
1347
+ });
1348
+ }
1349
+ areaFactory() {
1350
+ return {
1351
+ hasBindings: !1,
1352
+ nodeTemplateByIndex: null,
1353
+ attrNameByIndex: null,
1354
+ attrTemplateByIndex: null,
1355
+ varNameByIndex: null,
1356
+ varBytecodeByIndex: null,
1357
+ textNodes: null,
1358
+ contentAttributes: null,
1359
+ varAttributes: null,
1360
+ eventAttributes: null,
1361
+ events: null,
1362
+ templateNodeForClone: null,
1363
+ filled: !1,
1364
+ innerHtmlTemplateBC: null
1365
+ };
1366
+ }
1367
+ createAreas(t) {
1368
+ t.setAttribute("area-index", String(this.root.areas.length));
1369
+ const e = this.areaFactory();
1370
+ this.root.areas.push(e);
1371
+ const s = t.hasAttribute("inner-html");
1372
+ if (e.hasBindings = this.hasBindingAttributes(t) || this.hasTemplateTextChild(t), !s)
1373
+ for (let i = t.firstElementChild; i; i = i.nextElementSibling) this.createAreas(i);
1374
+ }
1375
+ hasBindingAttributes(t) {
1376
+ for (const e of Array.from(t.attributes)) if (this.isTemplate(e.value)) return !0;
1377
+ return !1;
1378
+ }
1379
+ hasTemplateTextChild(t) {
1380
+ for (let e = t.firstChild; e; e = e.nextSibling) if (e.nodeType === Node.TEXT_NODE && this.isTemplate(e.textContent)) return !0;
1381
+ return !1;
1382
+ }
1383
+ handleChildrens(t) {
1384
+ var s, i;
1385
+ let e = t.firstChild;
1386
+ for (; e; ) {
1387
+ const o = e.nextSibling;
1388
+ if (e.nodeType === 1) {
1389
+ const c = e;
1390
+ if (this.childNodeIsDynamic(c)) {
1391
+ const d = this.addChildren(c);
1392
+ d.parent = this, this.children ?? (this.children = []), this.children.push(d);
1393
+ } else
1394
+ this.handleChildrens(c);
1395
+ } else if (e.nodeType === 3) {
1396
+ const c = e.textContent;
1397
+ if (this.isTemplate(c)) {
1398
+ this.nodeByIndex ?? (this.nodeByIndex = []), this.nodeValueByIndex ?? (this.nodeValueByIndex = []);
1399
+ const d = this.nodeByIndex.push(e) - 1;
1400
+ this.area.filled || ((s = this.area).nodeTemplateByIndex ?? (s.nodeTemplateByIndex = []), this.area.nodeTemplateByIndex.push(this.getTemplateBytecode(c)), (i = this.area).textNodes ?? (i.textNodes = []), this.area.textNodes.push(d));
1401
+ }
1402
+ }
1403
+ e = o;
1404
+ }
1405
+ }
1406
+ resetDetectingUpTree() {
1407
+ let t = this;
1408
+ for (; t; )
1409
+ t.detecting = !1, t = t.parent;
1410
+ }
1411
+ handleError(t, e, s = null, i = "", o = "", c = null) {
1412
+ const d = o ? [o] : [];
1413
+ i && d.push(i), this.root.selector && d.push(this.root.selector);
1414
+ let u = d.join(" at ");
1415
+ this.root.debug.__tplFile && (u += ` (${this.root.debug.__tplFile})`);
1416
+ let m = c ? ", " + q[c] : "";
1417
+ throw t.message = `${e}${m}: ${t.message} in ${u}`, s && (console.log(u), s.log()), t;
1418
+ }
1419
+ handleSafeError(t, e = "") {
1420
+ const s = e ? [e] : [];
1421
+ this.root.selector && s.push(this.root.selector);
1422
+ let i = s.join(" at ");
1423
+ this.root.debug.__tplFile && (i += ` (${this.root.debug.__tplFile})`), console.error(`${t} in ${i}`);
1424
+ }
1425
+ getSingleBytecode(t, e) {
1426
+ t = t.trim();
1427
+ let s = V.get(t);
1428
+ if (!s)
1429
+ try {
1430
+ const i = nt(t);
1431
+ s = new rt(i).getBytecode(t), V.set(t, s);
1432
+ } catch (i) {
1433
+ this.handleError(i, "vm compile", s, e, t);
1434
+ }
1435
+ return s;
1436
+ }
1437
+ linkRxToTemplate(t, e, s) {
1438
+ if (t === 4) {
1439
+ const c = this.area.attrNameByIndex[s];
1440
+ if (c && at.has(c))
1441
+ throw new Error(
1442
+ `::rx is not allowed in "${c}".`
1443
+ );
1444
+ }
1445
+ let i = this.root.rxAcc.get(e);
1446
+ i || (i = /* @__PURE__ */ new Map(), this.root.rxAcc.set(e, i));
1447
+ let o = i.get(this);
1448
+ o || (o = [null, null, 0, 0, 0, 0], i.set(this, o)), t === 3 ? (o[0] ?? (o[0] = /* @__PURE__ */ new Set()), o[0].add(s)) : t === 4 ? (o[1] ?? (o[1] = /* @__PURE__ */ new Set()), o[1].add(s)) : t === 5 ? o[2] = 1 : t === 1 ? o[3] = 1 : t === 6 ? o[4] = 1 : t === 7 && (o[5] = 1), e.setPostUpdate(this.root.onRxUpdate);
1449
+ }
1450
+ getRxValue(t, e, s, i, o) {
1451
+ return t === 2 || o || i && this.linkRxToTemplate(t, e, s), e.actual;
1452
+ }
1453
+ getVarFromLexicalEnv(t) {
1454
+ return this.lexicalEnv && t in this.lexicalEnv ? this.lexicalEnv[t] : this.parent ? this.parent.getVarFromLexicalEnv(t) : void 0;
1455
+ }
1456
+ getThisArg(t) {
1457
+ return typeof this.cloneIndex == "number" ? this.self(t)[this.cloneIndex] : this.self();
1458
+ }
1459
+ runVMProgramForContext(t, e, s, i, o = null) {
1460
+ try {
1461
+ return this.repeatBC && t !== 1 ? void 0 : e.noRunNeeded(this) ? this.onceMap.get(e) : e.run(
1462
+ this,
1463
+ t,
1464
+ s,
1465
+ b.appVariables,
1466
+ i,
1467
+ o
1468
+ );
1469
+ } catch (c) {
1470
+ this.resetDetectingUpTree(), this.handleError(c, "vm run", e, e.expr, null, t);
1471
+ }
1472
+ }
1473
+ handleAttributesFilledArea() {
1474
+ const t = Array.from(this.node.attributes);
1475
+ for (let e = 0; e < t.length; e++) {
1476
+ const s = t[e];
1477
+ s.name === "attached" && !this.repeatBC && (this.setPointer(), this.attachedBC = this.getTemplateBytecode(s.value, !0, s.name)), s.name === "inner-html" && this.node.removeAttribute("inner-html");
1478
+ }
1479
+ if (this.area.eventAttributes)
1480
+ for (let e = 0; e < this.area.eventAttributes.length; e++)
1481
+ this.node.removeAttribute(this.area.eventAttributes[e]);
1482
+ }
1483
+ handleAttributes() {
1484
+ var e, s, i, o, c, d, u, m;
1485
+ const t = Array.from(this.node.attributes);
1486
+ for (let f = 0; f < t.length; f++) {
1487
+ const p = t[f];
1488
+ if (!(p.name === "repeat" || !this.isTemplate(p.value)))
1489
+ if (p.name.indexOf("on") === 0)
1490
+ (e = this.area).eventAttributes ?? (e.eventAttributes = []), this.area.eventAttributes.push(p.name), (s = this.area).events ?? (s.events = /* @__PURE__ */ Object.create(null)), this.area.events[p.name.slice(2)] = this.getTemplateBytecode(p.value, !0, p.name);
1491
+ else if (p.name === "attached" && !this.repeatBC)
1492
+ this.setPointer(), this.attachedBC = this.getTemplateBytecode(p.value, !0, p.name);
1493
+ else if (p.name === "inner-html")
1494
+ this.area.innerHtmlTemplateBC = this.getTemplateBytecode(p.value, !0, p.name), this.node.removeAttribute("inner-html");
1495
+ else if (p.name.indexOf("let-") === 0) {
1496
+ (i = this.area).varNameByIndex ?? (i.varNameByIndex = []);
1497
+ const r = this.area.varNameByIndex.push(b.kebabToCamel(p.name.slice(4))) - 1;
1498
+ (o = this.area).varBytecodeByIndex ?? (o.varBytecodeByIndex = []), this.area.varBytecodeByIndex.push(this.getTemplateBytecode(p.value, !0, p.name)), (c = this.area).varAttributes ?? (c.varAttributes = []), this.area.varAttributes.push(r);
1499
+ } else {
1500
+ (d = this.area).attrNameByIndex ?? (d.attrNameByIndex = []);
1501
+ const r = this.area.attrNameByIndex.push(p.name) - 1;
1502
+ (u = this.area).attrTemplateByIndex ?? (u.attrTemplateByIndex = []), this.area.attrTemplateByIndex.push(this.getTemplateBytecode(p.value)), (m = this.area).contentAttributes ?? (m.contentAttributes = []), this.area.contentAttributes.push(r);
1503
+ }
1504
+ }
1505
+ if (this.area.eventAttributes)
1506
+ for (let f = 0; f < this.area.eventAttributes.length; f++)
1507
+ this.node.removeAttribute(this.area.eventAttributes[f]);
1508
+ }
1509
+ markDomStructureChanged() {
1510
+ typeof this.root.domStructureChanged == "function" && (this.root.domChangedScheduled || (this.root.domChangedScheduled = !0, queueMicrotask(() => {
1511
+ this.root.domChangedScheduled = !1, this.root.domStructureChanged();
1512
+ })));
1513
+ }
1514
+ getRxUpdate() {
1515
+ return (t) => {
1516
+ var e;
1517
+ (e = this.root).rxUpdated ?? (e.rxUpdated = /* @__PURE__ */ new Set()), this.root.rxUpdated.add(t), !this.root.rxUpdatedScheduled && (this.root.rxUpdatedScheduled = !0, queueMicrotask(() => {
1518
+ if (this.root.rxUpdatedScheduled = !1, !this.root.rxUpdated || !this.root.rxAcc) {
1519
+ this.root.rxUpdated = null;
1520
+ return;
1521
+ }
1522
+ for (const s of this.root.rxUpdated) {
1523
+ const i = this.root.rxAcc.get(s);
1524
+ if (i)
1525
+ for (const o of i) {
1526
+ const c = o[0], d = o[1];
1527
+ if (d[2]) {
1528
+ c.reactiveUpdateAttachedAttr();
1529
+ continue;
1530
+ }
1531
+ if (d[4]) {
1532
+ c.reactiveUpdateLexicalEnv();
1533
+ continue;
1534
+ }
1535
+ if (d[0])
1536
+ for (const u of d[0])
1537
+ c.reactiveUpdateNode(u);
1538
+ if (d[1])
1539
+ for (const u of d[1])
1540
+ c.reactiveUpdateAttr(u);
1541
+ d[3] && c.reactiveUpdateRepeat(), d[5] && c.reactiveUpdateInnerHtml();
1542
+ }
1543
+ }
1544
+ this.root.rxUpdated = null;
1545
+ }));
1546
+ };
1547
+ }
1548
+ insertFragmentAfter(t, e) {
1549
+ const s = t.parentNode, i = t.nextSibling;
1550
+ i ? s.insertBefore(e, i) : s.appendChild(e);
1551
+ }
1552
+ removePointer() {
1553
+ this.pointer && this.pointer.remove();
1554
+ }
1555
+ getPointer() {
1556
+ if (!this.pointer)
1557
+ throw new Error(
1558
+ [
1559
+ 'Template initialization error: "pointer" is missing.',
1560
+ "This usually means the Template was created when its node was not in the DOM.",
1561
+ "You need to call setPointer() after inserting the node into the DOM.",
1562
+ `Node: ${this.node.tagName || this.node}`
1563
+ ].join(`
1564
+ `)
1565
+ );
1566
+ return this.pointer;
1567
+ }
1568
+ setPointer() {
1569
+ this.node.parentNode && (this.pointer = this.node.parentNode.insertBefore(
1570
+ document.createComment("p"),
1571
+ this.node
1572
+ ));
1573
+ }
1574
+ };
1575
+ a(b, "REMOVE_ATTR", {}), a(b, "appVariables", {});
1576
+ let U = b;
1577
+ class lt {
1578
+ constructor() {
1579
+ a(this, "instancesBySelector", {});
1580
+ a(this, "componentsRoot", []);
1581
+ a(this, "scopes", {});
1582
+ a(this, "listBySelector", /* @__PURE__ */ new Map());
1583
+ }
1584
+ removeComponents(t, e = !1) {
1585
+ for (; t.length; ) {
1586
+ const s = t.pop();
1587
+ s.disconnectedCallback(e), S.instancesBySelector[s.selector].delete(
1588
+ s.node
1589
+ );
1590
+ }
1591
+ }
1592
+ define(t) {
1593
+ this.listBySelector.set(t.selector, t);
1594
+ }
1595
+ connectBySelector(t, e, s = document, i = null) {
1596
+ const o = s.querySelectorAll(t), c = Array.from(o), d = [];
1597
+ if (c.length) {
1598
+ const u = this.listBySelector.get(t);
1599
+ if (!u)
1600
+ throw new Error(
1601
+ `${t} component is not defined. Call componentsRegistryService.define(...)`
1602
+ );
1603
+ for (const m of c) {
1604
+ this.instancesBySelector[t] = this.instancesBySelector[t] || /* @__PURE__ */ new Map();
1605
+ let f = this.instancesBySelector[t].get(m);
1606
+ if (!f) {
1607
+ f = new u(), f.selector = t, f.node = m;
1608
+ let p = null;
1609
+ i != null && i.httpFactory && (p ?? (p = {}), p.httpFactory = i.httpFactory), i != null && i.params$ && (p ?? (p = {}), p.routeParams$ = i.params$);
1610
+ try {
1611
+ f.connectedCallback(p), e.push(f), this.instancesBySelector[t].set(m, f), d.push(f);
1612
+ } catch (r) {
1613
+ throw r;
1614
+ }
1615
+ }
1616
+ }
1617
+ }
1618
+ return d;
1619
+ }
1620
+ initApp() {
1621
+ for (const t of this.listBySelector.keys())
1622
+ this.connectBySelector(t, this.componentsRoot);
1623
+ }
1624
+ connectScope(t) {
1625
+ this.scopes[t.id] = t;
1626
+ }
1627
+ disconnectScope(t) {
1628
+ delete this.scopes[t.id];
1629
+ }
1630
+ }
1631
+ const S = new lt();
1632
+ class Q {
1633
+ constructor(t, e = null) {
1634
+ a(this, "actual", null);
1635
+ a(this, "groupIndex", null);
1636
+ a(this, "postUpdateFns", null);
1637
+ this.group = t, this.fn = e, this.groupIndex = this.group.length, this.group.push(this);
1638
+ }
1639
+ update(...t) {
1640
+ if (this.actual = typeof this.fn == "function" ? this.fn(...t) : null, !!this.postUpdateFns)
1641
+ for (const e of this.postUpdateFns) e(this);
1642
+ }
1643
+ setPostUpdate(t) {
1644
+ this.postUpdateFns ?? (this.postUpdateFns = /* @__PURE__ */ new Set()), this.postUpdateFns.add(t);
1645
+ }
1646
+ unsubscribe() {
1647
+ const t = this.groupIndex, e = this.group.pop();
1648
+ t < this.group.length && (this.group[t] = e, e.groupIndex = t);
1649
+ }
1650
+ }
1651
+ class dt extends Q {
1652
+ constructor(e, s, i, ...o) {
1653
+ super(e, s);
1654
+ a(this, "deps");
1655
+ a(this, "updateScheduled", !1);
1656
+ a(this, "update", () => {
1657
+ this.updateScheduled || (this.updateScheduled = !0, queueMicrotask(() => {
1658
+ super.update(...this.deps.map((e) => e.actual)), this.updateScheduled = !1;
1659
+ }));
1660
+ });
1661
+ this.deps = o;
1662
+ for (const c of o) c.setPostUpdate(this.update);
1663
+ i != null && i.immediate && this.update();
1664
+ }
1665
+ unsubscribe() {
1666
+ var e, s;
1667
+ for (const i of this.deps)
1668
+ (e = i.postUpdateFns) == null || e.delete(this.update), ((s = i.postUpdateFns) == null ? void 0 : s.size) === 0 && (i.postUpdateFns = null);
1669
+ super.unsubscribe();
1670
+ }
1671
+ }
1672
+ class pt {
1673
+ constructor() {
1674
+ a(this, "id", "");
1675
+ a(this, "index", "");
1676
+ a(this, "selector", "");
1677
+ a(this, "node", null);
1678
+ a(this, "http", null);
1679
+ a(this, "config", null);
1680
+ a(this, "outerScope", null);
1681
+ a(this, "innerScope", null);
1682
+ a(this, "destroyed", !1);
1683
+ a(this, "ac", null);
1684
+ a(this, "dependencies", null);
1685
+ a(this, "connectedDependencies", null);
1686
+ a(this, "hasOuterScope", !1);
1687
+ a(this, "hasConfig", !1);
1688
+ a(this, "isDirective", !1);
1689
+ a(this, "template", null);
1690
+ a(this, "rxList", null);
1691
+ a(this, "value$", this.newRx());
1692
+ a(this, "value", null);
1693
+ a(this, "state$", this.newRx());
1694
+ a(this, "state", null);
1695
+ a(this, "__tplFile", "");
1696
+ a(this, "onUpdateValue", (t, e, s) => {
1697
+ this.index !== e || this.value === t || this.setValue(s);
1698
+ });
1699
+ a(this, "onUpdateState", (t, e, s) => {
1700
+ this.index !== e || this.state === t || this.setState(s);
1701
+ });
1702
+ }
1703
+ disconnectedCallback(t = !1) {
1704
+ if (this.destroyed = !0, this.ac && this.ac.abort(), this.template && this.template.fullDestroy(), t && this.node && !this.isDirective && this.node.remove(), this.value$ && this.value$.unsubscribe(), this.state$ && this.state$.unsubscribe(), this.connectedDependencies && S.removeComponents(this.connectedDependencies), this.rxList) for (; this.rxList.length; ) this.rxList.pop().unsubscribe();
1705
+ this.innerScope && S.disconnectScope(this.innerScope);
1706
+ }
1707
+ getScope() {
1708
+ const t = this.getScopeId(), e = S.scopes[t];
1709
+ if (t && !e)
1710
+ throw new Error(
1711
+ `Scope "${t}" not found for selector "${this.selector}" (component-id="${this.getId()}")`
1712
+ );
1713
+ return e;
1714
+ }
1715
+ connectedCallback(t = null) {
1716
+ if (this.syncId(), this.setIndex(), this.outerScope = this.getScope(), this.outerScope) {
1717
+ const e = this.outerScope.descriptors[this.id];
1718
+ if (this.hasConfig) {
1719
+ if (!e)
1720
+ throw new Error(
1721
+ `Descriptor not found for selector "${this.selector}" id "${this.id}" in scope "${this.getScopeId()}"`
1722
+ );
1723
+ this.config = e.config, this.config || (this.config = {});
1724
+ }
1725
+ this.hasOuterScope && (this.rxList ?? (this.rxList = []), this.setValue(), this.outerScope.newRxValue(
1726
+ this.id,
1727
+ this.onUpdateValue,
1728
+ this.rxList
1729
+ ), this.setState(), this.outerScope.newRxState(
1730
+ this.id,
1731
+ this.onUpdateState,
1732
+ this.rxList
1733
+ ));
1734
+ }
1735
+ if (this.innerScope && S.connectScope(this.innerScope), !this.isDirective && !(t != null && t.disableTemplate) && this.initTemplate(), t != null && t.httpFactory) {
1736
+ this.ac = new AbortController();
1737
+ const e = Object.keys(t.httpFactory);
1738
+ this.http = /* @__PURE__ */ Object.create(null);
1739
+ for (const s of e)
1740
+ this.http[s] = t.httpFactory[s](this.ac.signal);
1741
+ }
1742
+ }
1743
+ setScopeId(t) {
1744
+ return this.node.setAttribute("scope-id", t);
1745
+ }
1746
+ getScopeId() {
1747
+ return this.node.getAttribute("scope-id");
1748
+ }
1749
+ setId(t) {
1750
+ this.node.setAttribute("component-id", t), this.syncId();
1751
+ }
1752
+ getId() {
1753
+ return this.node.getAttribute("component-id");
1754
+ }
1755
+ getIndex() {
1756
+ return this.node.getAttribute("component-index");
1757
+ }
1758
+ syncId() {
1759
+ this.id = this.getId();
1760
+ }
1761
+ setIndex() {
1762
+ this.index = this.getIndex() || "0";
1763
+ }
1764
+ getHTML() {
1765
+ return "";
1766
+ }
1767
+ setValue(t = !1) {
1768
+ this.value = this.outerScope.getValue(this.id, this.index), this.value$.update(this.value);
1769
+ }
1770
+ setState(t = !1) {
1771
+ this.state = this.outerScope.getState(this.id, this.index), this.state$.update(this.state);
1772
+ }
1773
+ updateDependencies() {
1774
+ if (!(!this.dependencies || !this.dependencies.size)) {
1775
+ if (this.connectedDependencies) {
1776
+ let t = null, e = null;
1777
+ for (const s of this.connectedDependencies)
1778
+ document.contains(s.node) ? (e ?? (e = []), e.push(s)) : (t ?? (t = []), t.push(s));
1779
+ this.connectedDependencies = e, t && S.removeComponents(t);
1780
+ }
1781
+ for (const t of this.dependencies) this.connectDependency(t);
1782
+ }
1783
+ }
1784
+ connectDependency(t) {
1785
+ return this.connectedDependencies ?? (this.connectedDependencies = []), S.connectBySelector(
1786
+ t,
1787
+ this.connectedDependencies,
1788
+ this.node
1789
+ );
1790
+ }
1791
+ addDependencies(t) {
1792
+ this.dependencies ?? (this.dependencies = /* @__PURE__ */ new Set());
1793
+ for (const e of t) this.dependencies.add(e);
1794
+ }
1795
+ initTemplate() {
1796
+ const t = this.getHTML();
1797
+ t && (this.node.innerHTML = t, this.template = new U({
1798
+ node: this.node,
1799
+ self: () => this,
1800
+ selector: this.selector,
1801
+ __tplFile: this.__tplFile,
1802
+ domStructureChanged: () => {
1803
+ this.domStructureChanged();
1804
+ }
1805
+ }), this.template.detectChanges(), this.updateDependencies());
1806
+ }
1807
+ domStructureChanged() {
1808
+ this.updateDependencies();
1809
+ }
1810
+ newRx(t = null) {
1811
+ this.rxList ?? (this.rxList = []);
1812
+ const e = new Q(this.rxList, (s) => s);
1813
+ return e.update(t), e;
1814
+ }
1815
+ newRxFunc(t, ...e) {
1816
+ return this.rxList ?? (this.rxList = []), new dt(this.rxList, t, { immediate: !0 }, ...e);
1817
+ }
1818
+ newRxValueFromScope(t, e) {
1819
+ return this.rxList ?? (this.rxList = []), t.newRxValue(e, (s) => s, this.rxList);
1820
+ }
1821
+ newRxStateFromScope(t, e) {
1822
+ return this.rxList ?? (this.rxList = []), t.newRxState(e, (s) => s, this.rxList);
1823
+ }
1824
+ newRxEventFromScope(t, e, s) {
1825
+ return this.rxList ?? (this.rxList = []), t.newRxEvent(e, s, (i) => i, this.rxList);
1826
+ }
1827
+ newRxValueFromScopeByIndex(t, e) {
1828
+ this.rxList ?? (this.rxList = []);
1829
+ const s = {};
1830
+ return t.newRxValue(e, (i, o) => (s[o] = i, s), this.rxList);
1831
+ }
1832
+ newRxStateFromScopeByIndex(t, e) {
1833
+ this.rxList ?? (this.rxList = []);
1834
+ const s = {};
1835
+ return t.newRxState(e, (i, o) => (s[o] = i, s), this.rxList);
1836
+ }
1837
+ newRxEventFromScopeByIndex(t, e, s) {
1838
+ this.rxList ?? (this.rxList = []);
1839
+ const i = {};
1840
+ return t.newRxEvent(e, s, (o, c) => (i[c] = o, i), this.rxList);
1841
+ }
1842
+ }
1843
+ export {
1844
+ pt as A,
1845
+ Q as R,
1846
+ U as T,
1847
+ dt as a,
1848
+ S as c
1849
+ };
1850
+ //# sourceMappingURL=component-CH-TJ5VF.js.map