@reactive-web-components/rwc 2.61.7 → 2.63.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.
@@ -1,1097 +0,0 @@
1
- var at = Object.defineProperty;
2
- var dt = (e, t, s) => t in e ? at(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var f = (e, t, s) => dt(e, typeof t != "symbol" ? t + "" : t, s);
4
- const F = (e) => e && typeof e == "object" && ("classList" in e || "attributes" in e || "customAttributes" in e || "reactiveClassList" in e || "listeners" in e || "customListeners" in e || "children" in e || "effects" in e || "style" in e || Object.keys(e).some(
5
- (t) => t.startsWith(".") || t.startsWith("@") || t.startsWith("$")
6
- )) && !("hostElement" in e), ht = (e) => e && typeof e == "object" && "hostElement" in e && "append" in e && "set" in e && "addStyle" in e && "setAttribute" in e && "addClass" in e && "addEffect" in e && "addReactiveContent" in e && "setReactiveContent" in e && "clear" in e, K = (e, t, ...s) => {
7
- t && t.apply(e, s);
8
- };
9
- let D = !0;
10
- const S = (...e) => {
11
- D && console.debug(
12
- ["[rwc]", ...e].join(" | "),
13
- ...Array.from(e.join("").matchAll(/%c/gm)).map((t, s) => s % 2 === 0 ? "color:red" : "color:inherit")
14
- );
15
- }, V = (e) => e.replace(/([A-Z])/gm, (t) => `-${t.toLowerCase()}`), ft = (e) => e.replace(/-(\w)/gm, (t, s) => s.toUpperCase()), B = (e, ...t) => {
16
- if (!D) return;
17
- const s = {
18
- r: "color: #ff0000",
19
- // red
20
- g: "color: #00ff00",
21
- // green
22
- b: "color: #0000ff",
23
- // blue
24
- y: "color: #ffff00",
25
- // yellow
26
- p: "color: #800080",
27
- // purple
28
- c: "color: #00ffff",
29
- // cyan
30
- o: "color: #ffa500",
31
- // orange
32
- w: "color: #808080"
33
- // gray (w for white/gray)
34
- }, n = e.match(/@[rgbpycow]/g) || [], o = n.map((c) => {
35
- const i = c.slice(1);
36
- return s[i] || "color: inherit";
37
- });
38
- let r = e;
39
- n.forEach((c) => {
40
- const i = new RegExp(`\\${c}([^\\s,]+)`, "g");
41
- r = r.replace(i, "%c$1");
42
- }), console.log(r, ...o, ...t);
43
- }, kt = () => {
44
- D = !0;
45
- }, ut = () => {
46
- D = !1;
47
- };
48
- ut();
49
- const Ft = (e, t) => {
50
- e.every(Boolean) && t(e);
51
- }, P = /* @__PURE__ */ new Set();
52
- let z = !1;
53
- const st = () => {
54
- if (z = !1, P.size === 0)
55
- return;
56
- const e = Array.from(P);
57
- P.clear(), e.forEach((t) => {
58
- t.status === "active" && (Y(t), O.push(t), t(), O.pop());
59
- }), P.size > 0 && (z = !0, Promise.resolve().then(st));
60
- }, pt = (e) => {
61
- P.add(e), z || (z = !0, Promise.resolve().then(st));
62
- }, O = [], Y = (e) => {
63
- var t, s, n, o;
64
- (t = e.children) == null || t.forEach((r) => {
65
- var c;
66
- return (c = r.destroy) == null ? void 0 : c.call(r);
67
- }), (s = e.children) == null || s.clear(), (n = e.cleanupSet) == null || n.forEach((r) => r()), (o = e.cleanupSet) == null || o.clear();
68
- };
69
- function M(e, t) {
70
- let s = (t == null ? void 0 : t.signalCompareFn) || (() => !0);
71
- const n = /* @__PURE__ */ new Set();
72
- function o() {
73
- var c;
74
- const r = O[O.length - 1];
75
- return r && !r.fake && !n.has(r) && r.status === "active" && (n.add(r), (c = r.cleanupSet) == null || c.add(() => n.delete(r))), !(t != null && t.name) && (r != null && r.effectId) && o.setName(r.effectId), e;
76
- }
77
- return o.signalId = `${(t == null ? void 0 : t.name) || ""}_${Math.random().toString(36).substring(2, 15)}`, o.setName = function(r) {
78
- return o.signalId = `${r}_${Math.random().toString(36).substring(2, 15)}`, o;
79
- }, o.setCompareFn = function(r) {
80
- return s = r, o;
81
- }, o.clearSubscribers = function() {
82
- n.clear();
83
- }, o.getSubscribers = function() {
84
- return n;
85
- }, o.peek = function() {
86
- return Object.freeze(e);
87
- }, o.initValue = Object.freeze(e), o.forceSet = function(r) {
88
- e = r, n.forEach((c) => {
89
- pt(c);
90
- });
91
- }, o.set = function(r, c = s) {
92
- e !== r && c(e, r) && o.forceSet(r);
93
- }, o.update = function(r) {
94
- o.set(r(e));
95
- }, o.pipe = (r, c) => {
96
- c != null && c.name && o.setName(c.name);
97
- const i = M(null);
98
- return w(
99
- () => {
100
- const a = o();
101
- w(
102
- () => {
103
- const h = r(a);
104
- h instanceof Promise ? h.then((m) => i.set(m)) : g(h) ? w(() => i.set(h()), {
105
- name: "pipe_effect_inner"
106
- }) : i.set(h);
107
- },
108
- { name: "pipe_effect" }
109
- );
110
- },
111
- { name: (c == null ? void 0 : c.name) || `pipe_${o.signalId}` }
112
- ), i;
113
- }, o;
114
- }
115
- function w(e, t) {
116
- var r;
117
- const s = `${(t == null ? void 0 : t.name) || ""}_${Math.random().toString(36).substring(2, 15)}`;
118
- S("current effect", `%c${s}%c`);
119
- const n = e;
120
- n.status = "active", n.children = /* @__PURE__ */ new Set(), n.effectId = s;
121
- const o = O[O.length - 1];
122
- o && ((r = o.children) == null || r.add(n), n.parent = new WeakRef(o), n.destroy = () => {
123
- var c;
124
- Y(n), (c = o.children) == null || c.delete(n), n.destroy = void 0, n.status = "inactive";
125
- }), n.cleanupSet = /* @__PURE__ */ new Set(), O.push(n), n(), O.pop();
126
- }
127
- const g = (e) => !!e && ["object", "function"].includes(typeof e) && "set" in e && "update" in e && "forceSet" in e && "signalId" in e;
128
- function Nt(e, ...t) {
129
- const s = M("");
130
- return w(() => {
131
- const n = t.map(
132
- (r) => g(r) ? String(r()) : String(r)
133
- ), o = [e[0]];
134
- n.forEach((r, c) => {
135
- o.push(r, e[c + 1]);
136
- }), s.set(o.join(""));
137
- }), s;
138
- }
139
- function Bt(e, t) {
140
- const s = M(t ?? null), n = (o) => s.set(o);
141
- return e instanceof Promise ? e.then(n) : typeof e == "function" && w(() => {
142
- const o = e();
143
- o instanceof Promise ? o.then(n) : g(o) ? w(() => n(o())) : n(o);
144
- }), s;
145
- }
146
- function Vt(e, t) {
147
- let s = e(), n = t();
148
- w(() => {
149
- const o = e(), r = t();
150
- o !== r && (o !== s ? t.set(o) : r !== n && e.set(r)), s = o, n = r;
151
- });
152
- }
153
- function Jt(...e) {
154
- let t = e.map((n) => n());
155
- const s = M(t);
156
- return e.forEach((n, o) => {
157
- w(() => {
158
- const r = () => t.filter((c) => c !== void 0).length;
159
- r() === e.length && (t = Array.from(t).fill(void 0)), t[o] = n(), r() === e.length && s.set([...t]);
160
- });
161
- }), s;
162
- }
163
- const qt = (...e) => {
164
- const t = M([]);
165
- return w(() => {
166
- t.set(e.map((s) => s()));
167
- }), t;
168
- }, J = "eventProps", q = "EVENT_CONFIG", k = "observedAttributes", zt = () => (e, t) => {
169
- Reflect.get(e, k) || Reflect.defineProperty(e, k, {
170
- value: []
171
- }), Reflect.get(e, k).push(
172
- V(t)
173
- );
174
- }, Dt = (e) => (t, s) => {
175
- Reflect.get(t, J) || Reflect.defineProperty(t, J, {
176
- value: []
177
- }), Reflect.get(t, q) || Reflect.defineProperty(t, q, {
178
- value: {}
179
- }), Reflect.get(t, q)[s] = {
180
- bubbles: (e == null ? void 0 : e.bubbles) ?? !1,
181
- composed: (e == null ? void 0 : e.composed) ?? !1
182
- }, Reflect.get(t, J).push(s);
183
- }, nt = (e, t = !1) => (s) => {
184
- S(
185
- e,
186
- "start register static attr",
187
- s.prototype[k]
188
- );
189
- const n = [];
190
- if (s.styles) {
191
- const r = s.styles, c = [];
192
- Array.isArray(r) ? c.push(...r) : c.push(r), c.forEach((i) => {
193
- const a = new CSSStyleSheet();
194
- a.replaceSync(i), n.push(a);
195
- const C = new CSSStyleSheet();
196
- C.replaceSync(i.slice(i.indexOf("@property"))), document.adoptedStyleSheets.push(C);
197
- });
198
- }
199
- class o extends s {
200
- constructor(...c) {
201
- S("constructor", `%c${e}%c`), super(t, ...c), n.length > 0 && this.shadow.adoptedStyleSheets.push(...n);
202
- }
203
- render() {
204
- return S("rwc: render from new class"), s.prototype.render.call(this);
205
- }
206
- attributeChangedCallback(c, i, a) {
207
- S(
208
- "%cAttribute has changed.%c",
209
- `%c${c}%c`,
210
- `oldValue: ${i}, newValue: ${a}`,
211
- `%c${e}%c`
212
- );
213
- try {
214
- a = JSON.parse(a);
215
- } catch {
216
- }
217
- const C = ft(c);
218
- if (C in this && g(this[C])) {
219
- const h = this[C];
220
- h.setName(c), a === null ? (h.set(h.initValue), this.removeAttribute(c)) : h.set(a);
221
- }
222
- K(
223
- this,
224
- s.prototype.attributeChangedCallback,
225
- c,
226
- i,
227
- a
228
- );
229
- }
230
- connectedCallback() {
231
- const c = () => {
232
- var a, C;
233
- S("rwc: connectedCallback"), S("connectedCallback", `%c${e}%c`, this), (a = this.init) == null || a.call(this), this.providers && Object.keys(this.providers).length > 0 && (S("WRAPPER for providers", e), Object.entries(this.providers).forEach(
234
- ([h, d]) => {
235
- S("register provider", h, d()), this.addEventListener(h, (m) => {
236
- var u;
237
- S("send provider", h, d());
238
- const p = m;
239
- ((u = p.detail) == null ? void 0 : u.context) === h && (p.stopPropagation(), p.detail.callback(d));
240
- });
241
- }
242
- )), this.checkInjects(), (C = s.prototype[J]) == null || C.forEach(
243
- (h) => {
244
- this[h] = (d) => {
245
- const m = s.prototype[q][h], { bubbles: p, composed: u } = m;
246
- g(d) ? w(() => {
247
- B("@oemit reactive value", d()), this.dispatchEvent(
248
- new CustomEvent(h, {
249
- detail: d(),
250
- bubbles: p,
251
- composed: u
252
- })
253
- );
254
- }) : (B("@oemit value", d), this.dispatchEvent(
255
- new CustomEvent(h, {
256
- detail: d,
257
- bubbles: p,
258
- composed: u
259
- })
260
- ));
261
- };
262
- }
263
- ), S("start render", `%c${e}%c`, e);
264
- const i = () => {
265
- S("rwc: insertRenderTemplate");
266
- const d = this.render().hostElement;
267
- d && this.shadow.appendChild(d), K(this, s.prototype.connectedCallback), this.appendSlotContent();
268
- };
269
- if (this.rootStyle && !s.styles) {
270
- const h = (p) => p instanceof Promise || Array.isArray(p) && p.every((u) => u instanceof Promise), d = this.rootStyle, m = (p) => {
271
- const u = new CSSStyleSheet();
272
- u.replaceSync(p), this.shadow.adoptedStyleSheets.push(u);
273
- const y = new CSSStyleSheet();
274
- y.replaceSync(p.slice(p.indexOf("@property"))), document.adoptedStyleSheets.push(y);
275
- };
276
- if (h(d)) {
277
- const p = [];
278
- Array.isArray(d) ? p.push(...d) : p.push(d), Promise.all(p).then((u) => u.forEach((y) => m(y.default))).then(() => i());
279
- } else {
280
- const p = [];
281
- Array.isArray(d) ? p.push(...d) : p.push(d), p.forEach((u) => m(u)), i();
282
- }
283
- } else
284
- i();
285
- this.slotContext && Object.keys(this.slotContext).length > 0 && this.shadow.querySelectorAll("slot").forEach((h) => {
286
- S(
287
- this.slotContext,
288
- this.slotContext && this.slotContext[h.name]
289
- ), B(
290
- "@bslot element",
291
- h,
292
- `name:${h.name};`,
293
- h.assignedElements()
294
- ), h.assignedElements().forEach((d) => {
295
- const m = this.slotContext[h.name];
296
- this.slotContext && g(m) && (B(
297
- "@oslot element",
298
- h,
299
- `name:${h.name};`,
300
- h.assignedElements()
301
- ), w(() => {
302
- d.dispatchEvent(
303
- new CustomEvent("handleSlotContext", {
304
- detail: m()
305
- })
306
- );
307
- }));
308
- });
309
- });
310
- };
311
- c.fake = !0, c.component = new WeakRef(this), this.effectSet.add(new WeakRef(c)), w(c, { name: "FAKE_wrapperEffect" });
312
- }
313
- disconnectedCallback() {
314
- this.allSlotContent = [], this.slotContent = {}, this.htmlSlotContent = {}, this.effectSet.forEach((c) => {
315
- var i, a;
316
- return (a = (i = c.deref()) == null ? void 0 : i.destroy) == null ? void 0 : a.call(i);
317
- }), this.effectSet.clear(), this.shadow.replaceChildren(), this.replaceChildren(), K(this, s.prototype.disconnectedCallback);
318
- }
319
- }
320
- return f(o, "observedAttributes", s.prototype[k] ?? []), f(o, "renderTagName", e), o.toString = () => e, customElements.get(e) ? console.error(
321
- `название тега ${e} повторяется, компонент ${s.name} не зарегистрирован`
322
- ) : customElements.define(e, o), s.renderTagName = e, s;
323
- };
324
- class _ extends HTMLElement {
325
- constructor(s = !1) {
326
- super();
327
- f(this, "init");
328
- f(this, "isSlotLazyLoading", !1);
329
- f(this, "slotTemplate");
330
- f(this, "slotContext");
331
- f(this, "rootStyle");
332
- f(this, "modelValue");
333
- f(this, "providers");
334
- f(this, "effectSet", /* @__PURE__ */ new Set());
335
- f(this, "appendAllSlotContent");
336
- f(this, "allSlotContent", []);
337
- f(this, "slotContent", {});
338
- f(this, "htmlSlotContent", {});
339
- f(this, "shadow");
340
- f(this, "injects", {});
341
- this.shadow = this.attachShadow({ mode: s ? "closed" : "open" });
342
- }
343
- // @ts-expect-error - appendChild is not defined in the HTMLElement interface
344
- appendChild(s, n = !0) {
345
- var o;
346
- if (this.isSlotLazyLoading && n) {
347
- if (s instanceof HTMLElement) {
348
- const r = s.slot || "default";
349
- this.htmlSlotContent[r] || (this.htmlSlotContent[r] = []), (o = this.htmlSlotContent[r]) == null || o.push(s);
350
- }
351
- } else return super.appendChild(s);
352
- }
353
- appendSlotContent() {
354
- var s;
355
- (s = this.appendAllSlotContent) == null || s.call(this);
356
- }
357
- inject(s) {
358
- return S("%cinject%c", s), this.injects[s] || (this.injects[s] = M(null)), this.injects[s];
359
- }
360
- checkInjects() {
361
- Object.entries(this.injects).forEach(([s, n]) => {
362
- S(
363
- "%cinject%c",
364
- `%c${s}%c`,
365
- "from BaseElement (dispatch event)"
366
- ), this.shadow.dispatchEvent(
367
- new CustomEvent(s, {
368
- detail: {
369
- context: s,
370
- callback: (o) => w(() => {
371
- n.set(o());
372
- }, { name: s })
373
- },
374
- bubbles: !0,
375
- composed: !0
376
- })
377
- );
378
- });
379
- }
380
- setReactiveValue(s) {
381
- this.modelValue = s;
382
- }
383
- }
384
- f(_, "observedAttributes", []), f(_, "renderTagName", ""), f(_, "styles");
385
- const Gt = (e) => "render" in e && "setReactiveValue" in e, mt = "handleSlotContext", X = "onConnected", ot = (e) => typeof e == "string" ? e : JSON.stringify(e), Et = (e) => {
386
- const t = document.createElement("span");
387
- return t.textContent = ot(e), t;
388
- }, rt = (e, t) => (e.appendChild(Et(t)), e), Ct = (e, t) => (e.replaceChildren(), rt(e, t)), Q = (e) => {
389
- const t = document.createElement("span");
390
- return w(() => {
391
- const s = e();
392
- t.textContent = ot(s);
393
- }), t;
394
- };
395
- class ct {
396
- constructor(t) {
397
- f(this, "wrapper");
398
- f(this, "keyedEffects", /* @__PURE__ */ new Map());
399
- f(this, "append", (...t) => (t.forEach((s) => {
400
- var o;
401
- const n = s.hostElement;
402
- n && ((o = this.hostElement) == null || o.appendChild(n), X in n && setTimeout(() => {
403
- var r;
404
- (r = n.onConnected) == null || r.call(
405
- n,
406
- s,
407
- n
408
- );
409
- }));
410
- }), this));
411
- f(this, "set", (...t) => {
412
- var n;
413
- this.clear();
414
- const s = document.createDocumentFragment();
415
- return t.forEach((o) => {
416
- const r = o.hostElement;
417
- r && s.appendChild(r);
418
- }), (n = this.hostElement) == null || n.appendChild(s), this;
419
- });
420
- f(this, "removeChild", (...t) => (t.forEach((s) => {
421
- var n, o;
422
- if (Array.from(((n = this.hostElement) == null ? void 0 : n.childNodes.values()) || []).some(
423
- (r) => r === s.hostElement
424
- )) {
425
- const r = s.hostElement;
426
- r && ((o = this.hostElement) == null || o.removeChild(r));
427
- }
428
- }), this));
429
- f(this, "addHtmlContent", (t) => {
430
- const s = this.hostElement;
431
- return s ? (rt(s, t), this) : this;
432
- });
433
- f(this, "setHtmlContent", (t) => {
434
- const s = this.hostElement;
435
- return s ? (Ct(s, t), this) : this;
436
- });
437
- f(this, "setAttribute", (t, s) => {
438
- var r;
439
- const n = this.hostElement;
440
- if (!n) return this;
441
- let o;
442
- if (typeof s == "boolean" && !(n instanceof _))
443
- if (s)
444
- o = "";
445
- else {
446
- this.removeAttribute(t);
447
- const c = t.toLowerCase();
448
- return c in n && (n[c] = null), this;
449
- }
450
- else typeof s != "string" ? o = JSON.stringify(s) : o = s;
451
- if ((r = this.hostElement) == null || r.setAttribute(V(t), o), !(n instanceof _)) {
452
- const c = t.toLowerCase();
453
- c in n && (n[c] = s);
454
- }
455
- return this;
456
- });
457
- f(this, "setCustomAttribute", (t, s) => {
458
- var o;
459
- let n;
460
- return typeof s != "string" ? n = JSON.stringify(s) : n = s, (o = this.hostElement) == null || o.setAttribute(V(t), n), this;
461
- });
462
- f(this, "setReactiveAttribute", (t, s) => (this.addEffect((n) => {
463
- n.setAttribute(t, s());
464
- }, t), this));
465
- f(this, "setReactiveCustomAttribute", (t, s) => (this.addEffect((n) => {
466
- n.setCustomAttribute(t, s());
467
- }), this));
468
- f(this, "removeAttribute", (t) => {
469
- var s;
470
- return (s = this.hostElement) == null || s.removeAttribute(V(t)), this;
471
- });
472
- f(this, "addStyle", (t) => {
473
- const s = this.hostElement;
474
- return s ? (Object.entries(t).forEach(([n, o]) => {
475
- const r = n.startsWith("--");
476
- typeof o == "function" ? this.addEffect(() => {
477
- if (r) {
478
- const c = String(o() || "");
479
- s.style.setProperty(n, c);
480
- } else
481
- s.style[n] = o();
482
- }) : typeof o == "string" && (r ? s.style.setProperty(n, o) : s.style[n] = o);
483
- }), this) : this;
484
- });
485
- f(this, "onConnected", (t) => this.hostElement ? (Reflect.defineProperty(this.hostElement, X, {
486
- get() {
487
- return t;
488
- }
489
- }), this) : this);
490
- f(this, "addClass", (...t) => (t.forEach((s) => {
491
- var n;
492
- typeof s == "string" ? (n = this.hostElement) == null || n.classList.add(
493
- ...s.split(" ").flatMap((o) => o.split(`
494
- `)).map((o) => o.trim()).filter(Boolean)
495
- ) : (() => {
496
- let o = null;
497
- this.addEffect(() => {
498
- const r = s();
499
- r.length > 0 && (o ? this.replaceClass(o, r) : this.addClass(r), o = r);
500
- });
501
- })();
502
- }), this));
503
- f(this, "setClass", (...t) => {
504
- var s, n, o;
505
- return (n = this.hostElement) == null || n.classList.remove(...((s = this.hostElement) == null ? void 0 : s.classList) || []), (o = this.hostElement) == null || o.classList.add(...t), this;
506
- });
507
- f(this, "addReactiveClass", (t) => (Object.keys(t).forEach((s) => {
508
- this.addEffect((n) => {
509
- t[s]() ? n.addClass(s) : n.removeClass(s);
510
- });
511
- }), this));
512
- f(this, "removeClass", (...t) => {
513
- var s;
514
- return (s = this.hostElement) == null || s.classList.remove(...t), this;
515
- });
516
- f(this, "replaceClass", (t, s) => {
517
- var n;
518
- return (n = this.hostElement) == null || n.classList.replace(t, s), this;
519
- });
520
- f(this, "addEffect", (t, s) => {
521
- var r, c;
522
- const n = this.hostElement;
523
- if (!n) return this;
524
- const o = () => t(this, n);
525
- if (s) {
526
- const i = (r = this.keyedEffects.get(s)) == null ? void 0 : r.deref();
527
- i && Y(i);
528
- }
529
- return (c = n.effectSet) == null || c.add(new WeakRef(o)), o.component = this.wrapper, w(o, { name: (s == null ? void 0 : s.toString()) || n.tagName }), this;
530
- });
531
- f(this, "addReactiveContent", (t) => {
532
- var s;
533
- return (s = this.hostElement) == null || s.appendChild(Q(t)), this;
534
- });
535
- f(this, "setReactiveContent", (t) => {
536
- var s;
537
- return this.clear(), (s = this.hostElement) == null || s.appendChild(Q(t)), this;
538
- });
539
- f(this, "clear", () => {
540
- var t;
541
- return (t = this.hostElement) == null || t.replaceChildren(), this;
542
- });
543
- this.wrapper = t;
544
- const s = t.deref();
545
- s && (s.effectSet = /* @__PURE__ */ new Set());
546
- }
547
- get hostElement() {
548
- return this.wrapper.deref();
549
- }
550
- addEventlistener(t, s, n = !1) {
551
- var o;
552
- return (o = this.hostElement) == null || o.addEventListener(t, (r) => s(r, this, this.hostElement), n), this;
553
- }
554
- }
555
- class bt extends ct {
556
- constructor() {
557
- super(...arguments);
558
- f(this, "setReactiveValue", (s) => (this.hostElement instanceof _ && this.hostElement.setReactiveValue(s), this));
559
- f(this, "setSlotTemplate", (s) => {
560
- var o;
561
- const n = (o = this.hostElement) == null ? void 0 : o.slotTemplate;
562
- return n && Object.entries(s).forEach(([r, c]) => {
563
- n[r] = c;
564
- }), this;
565
- });
566
- }
567
- }
568
- const Kt = () => () => {
569
- }, St = (e) => new bt(new WeakRef(e)), yt = (e) => new ct(new WeakRef(e)), wt = (e, ...t) => ({
570
- classList: [...e.map((s) => s.trim()).filter(Boolean), ...t]
571
- }), Yt = (e, ...t) => wt(e, ...t), it = (e, t) => {
572
- if (!t || !e.deref()) return;
573
- const s = Object.keys(t || {}).filter(
574
- (o) => o.startsWith(".") || o.startsWith("@") || o.startsWith("$")
575
- );
576
- s.filter((o) => o.startsWith(".")).forEach((o) => {
577
- t != null && t.attributes || (t.attributes = {}), t.attributes[o.slice(1)] = t[o];
578
- }), s.filter((o) => o.startsWith("@")).forEach((o) => {
579
- t != null && t.listeners || (t.listeners = {});
580
- const r = o.slice(1);
581
- t.listeners[r] = t[o];
582
- }), s.filter((o) => o.startsWith("$")).forEach((o) => {
583
- t != null && t.effects || (t.effects = []), t.effects.push(t[o]);
584
- });
585
- const n = e.deref();
586
- if (n)
587
- return gt(n, t.classList), It(n, t.style), Ot(n, t.attributes), Lt(n, t.reactiveClassList), Rt(n, t.customAttributes), At(n, t.children), vt(n, t.effects), tt(n, t.listeners), tt(n, t.customListeners), n;
588
- }, tt = (e, t) => {
589
- t && Object.entries(t).forEach(([s, n]) => {
590
- typeof n == "function" && e.addEventlistener(s, n);
591
- });
592
- }, vt = (e, t) => t == null ? void 0 : t.forEach((s) => e.addEffect(s)), At = (e, t) => G(new WeakRef(e), ...t || []) ?? e, Rt = (e, t) => {
593
- const s = t;
594
- s && Object.keys(s).forEach((n) => {
595
- g(s[n]) ? e.setReactiveCustomAttribute(n, s[n]) : typeof s[n] == "function" ? e.addEffect(() => {
596
- e.setCustomAttribute(n, s[n]());
597
- }) : e.setCustomAttribute(n, s[n]);
598
- });
599
- }, gt = (e, t) => e.addClass(...t || []), Lt = (e, t) => e.addReactiveClass(t || {}), It = (e, t) => e.addStyle(t || {}), Ot = (e, t) => {
600
- const s = t, n = (o, r) => {
601
- r && (g(r) ? e.setReactiveAttribute(o, r) : typeof r == "function" ? e.addEffect(() => {
602
- e.setAttribute(o, r());
603
- }) : e.setAttribute(o, r));
604
- };
605
- s && Object.keys(s).forEach((o) => {
606
- n(o, s[o]);
607
- });
608
- }, G = (e, ...t) => {
609
- const s = e.deref();
610
- if (s)
611
- return t.forEach((n) => {
612
- typeof n == "string" ? n.trim().length > 0 && s.addHtmlContent(n) : g(n) ? s.addReactiveContent(n) : s.append(n);
613
- }), s;
614
- }, W = (e, t) => {
615
- const s = document.createElement(e), n = yt(s);
616
- return it(new WeakRef(n), t) ?? n;
617
- }, Z = (e, t) => {
618
- const [s, ...n] = e.split(" ").map((r) => r.trim()), o = W(s, t);
619
- return n.length > 0 && o.addClass(...n), (...r) => G(
620
- new WeakRef(o),
621
- ...r.filter(Boolean).flat().flatMap(
622
- (c) => typeof c == "function" && !g(c) ? j(() => c(o)) : c
623
- )
624
- ) ?? o;
625
- }, j = (e) => {
626
- const t = `getSignalContent_${Math.random().toString(36).substring(2, 15)}`;
627
- return W("div").addStyle({ display: "contents" }).addEffect((s) => {
628
- s.clear(), G(new WeakRef(s), ...[e()].flat());
629
- }, t);
630
- }, Zt = (e, t, s) => {
631
- const n = W("div").addStyle({ display: "contents" }), o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
632
- let a = [];
633
- const C = /* @__PURE__ */ new Set();
634
- let h = e.peek();
635
- const d = (u) => {
636
- C.delete(u), o.delete(u), r.delete(u), c.delete(u), i.delete(u);
637
- }, m = (u) => {
638
- if (!i.has(u)) {
639
- const y = a.indexOf(u);
640
- return i.set(u, y), y;
641
- }
642
- return i.get(u);
643
- }, p = (u, y, x) => Array.from(x.children).indexOf(u) !== y;
644
- return w(() => {
645
- const u = e(), y = u.map(t).map((E) => typeof E == "string" ? E : E.toString()), x = new Set(y);
646
- i.clear(), y.forEach((E, b) => {
647
- i.set(E, b);
648
- }), a = y;
649
- const L = n.hostElement;
650
- if (!L) return;
651
- S(
652
- "containerChildren",
653
- Array.from(L.children),
654
- a
655
- );
656
- const H = [];
657
- Array.from(L.children).forEach((E) => {
658
- const b = E.dataset.key;
659
- b && !x.has(b) && H.push(E);
660
- }), H.forEach((E) => {
661
- const b = E.dataset.key;
662
- S("remove element", b, E), E.remove(), d(b);
663
- }), y.forEach((E, b) => {
664
- var v;
665
- const A = u[b], $ = h[b];
666
- if (!o.has(E))
667
- S("create new element", E, A), o.set(
668
- E,
669
- M(Math.random().toString(36).substring(2, 15))
670
- ), r.set(
671
- E,
672
- () => s(A, b, u).setCustomAttribute("data-key", E)
673
- );
674
- else if ($ && JSON.stringify(A) !== JSON.stringify($)) {
675
- const R = c.get(E);
676
- (v = o.get(E)) == null || v.set(Math.random().toString(36).substring(2, 15)), r.set(
677
- E,
678
- () => s(A, b, u).setCustomAttribute("data-key", E)
679
- ), R && R.parentNode && S("mark element for update", E);
680
- }
681
- }), h = [...u.map((E) => ({ ...E }))];
682
- const N = () => {
683
- o.forEach((E, b) => {
684
- S("key from setTimeout foreach currItemSignalMap", b), C.has(b) || (C.add(b), w(() => {
685
- var U;
686
- E();
687
- const A = m(b), $ = (U = r.get(b)) == null ? void 0 : U();
688
- if (!$ || !$.hostElement) return;
689
- const v = n.hostElement, R = $.hostElement;
690
- if (!v) return;
691
- S("call effect from setTimeout", b, R);
692
- const I = c.get(b);
693
- if (I && I.parentNode === v) {
694
- if (p(I, A, v)) {
695
- const T = v.children[A];
696
- T && T !== I ? v.insertBefore(I, T) : T || v.appendChild(I);
697
- }
698
- R !== I && (I.replaceWith(R), c.set(b, R));
699
- } else if (c.set(b, R), A < v.children.length) {
700
- const T = v.children[A];
701
- T ? v.insertBefore(R, T) : v.appendChild(R);
702
- } else
703
- v.appendChild(R);
704
- }));
705
- });
706
- };
707
- Promise.resolve().then(() => N());
708
- }), n;
709
- }, Ut = (e) => {
710
- let t = [W("div")], s = !1;
711
- return w(() => {
712
- var r, c;
713
- const n = e();
714
- s = Array.isArray(n);
715
- const o = [];
716
- o.push(...[n].flat()), o.length === 0 && o.push(
717
- W("div").addStyle({ display: "none" }).setAttribute("id", "empty_template")
718
- );
719
- try {
720
- S(
721
- "newReactiveComponent.map",
722
- o.map((i) => {
723
- var a;
724
- return S("newReactiveComponent hostElement", i.hostElement), (a = i.hostElement) == null ? void 0 : a.id;
725
- })
726
- ), S(
727
- "currComponent[0].hostElement?.id",
728
- (r = t[0].hostElement) == null ? void 0 : r.id,
729
- t
730
- ), (c = t[0].hostElement) == null || c.replaceWith(
731
- ...o.map((i) => i.hostElement).filter(Boolean)
732
- ), t.slice(1).forEach((i) => {
733
- var a;
734
- return (a = i.hostElement) == null ? void 0 : a.remove();
735
- }), t = o;
736
- } catch (i) {
737
- console.error(i);
738
- }
739
- }), s ? t : t[0];
740
- }, Xt = (e) => mt in e, Qt = (e) => {
741
- const t = Z("div")().addStyle({ display: "contents" }), s = (n) => {
742
- const o = t.hostElement;
743
- return o && (o.innerHTML = n), t;
744
- };
745
- return typeof e == "string" ? s(e) : t.addEffect(() => {
746
- s(e());
747
- }), t;
748
- }, lt = (e, t, s) => e ? j(t) : s ? j(s) : Z("div")().setAttribute("id", "empty_div_renderIf").addStyle({ display: "none" }), jt = (e, t, s) => j(() => lt(!!e(), t, s)), te = (e, t, s) => typeof e == "boolean" ? lt(e, t, s) : jt(e, t, s), et = (e, t) => j(t).addEffect((s, n) => {
749
- if (typeof e == "boolean")
750
- n.style.display = e ? "block" : "none";
751
- else {
752
- const o = e() ? "block" : "none";
753
- n.style.display = o;
754
- }
755
- }), ee = (e, t, s) => {
756
- const n = [
757
- et(e, t)
758
- ].flat();
759
- return s && n.push(
760
- ...[
761
- et(
762
- () => typeof e == "boolean" ? !e : !e(),
763
- s
764
- )
765
- ].flat()
766
- ), j(() => n);
767
- }, Mt = (e, t) => {
768
- S("createCustomElement", e);
769
- const s = document.createElement(e), n = St(s);
770
- return s.init = () => {
771
- it(new WeakRef(n), t);
772
- }, n;
773
- }, Tt = (e, t) => {
774
- const s = e.split(" ").slice(1).map((o) => o.trim()), n = Mt(e.split(" ")[0], t);
775
- return Array.isArray(s) && s.length > 0 && n.addClass(...s), (...o) => {
776
- const r = o.filter(Boolean).flat().flatMap(
777
- (i) => typeof i == "function" && !g(i) ? j(() => i(n)) : i
778
- ), c = n.hostElement;
779
- return c && (c.allSlotContent = r, c.slotContent = r.filter(ht).reduce(
780
- (i, a) => {
781
- var h;
782
- const C = ((h = a.hostElement) == null ? void 0 : h.getAttribute("slot")) || "default";
783
- return i[C] || (i[C] = []), i[C].push(a), i;
784
- },
785
- {}
786
- ), c.appendAllSlotContent = () => {
787
- G(new WeakRef(n), ...r);
788
- }), n;
789
- };
790
- }, $t = (e, t, s) => Tt(
791
- `${e.renderTagName}${t && typeof t == "string" ? " " + t : ""}`,
792
- F(t) ? t : t && typeof t == "string" ? s : void 0
793
- ), se = () => {
794
- const e = () => {
795
- };
796
- return e.oldValue = null, e;
797
- }, ne = () => ({}), _t = (e, t, s) => {
798
- const n = t ? nt(t, s)(e) : e;
799
- return (o, ...r) => {
800
- const c = [...r];
801
- return o && !F(o) && c.unshift(o), $t(n, F(o) ? o : {})(...c);
802
- };
803
- }, oe = (e) => [
804
- _t(e),
805
- (t, s) => {
806
- nt(t, s)(e);
807
- }
808
- ], l = {}, Wt = [
809
- "div",
810
- "span",
811
- "section",
812
- "input",
813
- "button",
814
- "table",
815
- "tr",
816
- "td",
817
- "th",
818
- "ul",
819
- "li",
820
- "ol",
821
- "form",
822
- "label",
823
- "select",
824
- "option",
825
- "textarea",
826
- "img",
827
- "a",
828
- "p",
829
- "h1",
830
- "h2",
831
- "h3",
832
- "h4",
833
- "h5",
834
- "h6",
835
- "br",
836
- "hr",
837
- "pre",
838
- "code",
839
- "nav",
840
- "header",
841
- "footer",
842
- "main",
843
- "aside",
844
- "article",
845
- "figure",
846
- "figcaption",
847
- "blockquote",
848
- "cite",
849
- "small",
850
- "strong",
851
- "em",
852
- "b",
853
- "i",
854
- "u",
855
- "s",
856
- "sub",
857
- "sup",
858
- "mark",
859
- "del",
860
- "ins",
861
- "details",
862
- "summary",
863
- "progress",
864
- "meter",
865
- "audio",
866
- "video",
867
- "canvas",
868
- "slot"
869
- ];
870
- Wt.forEach((e) => {
871
- l[e] = (t, ...s) => {
872
- let n = [...s];
873
- return t && !F(t) && (n = [t].concat(n)), Z(e, F(t) ? t : {})(...n);
874
- };
875
- });
876
- const xt = l.div, re = l.span, ce = l.section, ie = l.input, le = l.button, ae = l.table, de = l.tr, he = l.td, fe = l.th, ue = l.ul, pe = l.li, me = l.ol, Ee = l.form, Ce = l.label, be = l.select, Se = l.option, ye = l.textarea, we = l.img, ve = l.a, Ae = l.p, Re = l.h1, ge = l.h2, Le = l.h3, Ie = l.h4, Oe = l.h5, je = l.h6, Me = l.br, Te = l.hr, $e = l.pre, _e = l.code, We = l.nav, xe = l.header, He = l.footer, Pe = l.main, ke = l.aside, Fe = l.article, Ne = l.figure, Be = l.figcaption, Ve = l.blockquote, Je = l.cite, qe = l.small, ze = l.strong, De = l.em, Ge = l.b, Ke = l.i, Ye = l.u, Ze = l.s, Ue = l.sub, Xe = l.sup, Qe = l.mark, ts = l.del, es = l.ins, ss = l.details, ns = l.summary, os = l.progress, rs = l.meter, cs = l.audio, is = l.video, ls = l.canvas, as = l.slot, ds = (e) => (t) => e(t).addClass(...t.classList ?? []).addReactiveClass(t.reactiveClassList ?? {});
877
- function Ht(e, t) {
878
- let s = 0;
879
- return (...n) => {
880
- const o = Date.now();
881
- o - s >= t && (e(...n), s = o);
882
- };
883
- }
884
- const hs = (e, t) => j(() => {
885
- const s = e();
886
- let n = null;
887
- return s.map(
888
- (o, r) => xt(
889
- {
890
- "@dragstart": (c, i, a) => {
891
- n = a;
892
- },
893
- "@dragend": (c, i, a) => {
894
- a.style.transform = "", a.removeAttribute("draggable");
895
- },
896
- "@mousedown": (c, i, a) => {
897
- a.style.transform = "translateZ(0)", a.setAttribute("draggable", "true");
898
- },
899
- "@dragover": (c) => {
900
- c.preventDefault();
901
- },
902
- "@dragenter": Ht((c, i, a) => {
903
- var C, h, d;
904
- if (c.preventDefault(), n) {
905
- let m = n, p = a;
906
- const u = ((C = n.getClientRects().item(0)) == null ? void 0 : C.y) ?? 0, y = ((h = a.getClientRects().item(0)) == null ? void 0 : h.y) ?? 0;
907
- u < y && ([m, p] = [a, n]), (d = a.parentElement) == null || d.insertBefore(m, p);
908
- }
909
- }, 200)
910
- },
911
- t(o, r, [...e.peek()])
912
- )
913
- );
914
- }), fs = (e, t, s) => {
915
- let n = [], o = [];
916
- const r = W("div").addStyle({ display: "contents" }), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
917
- return w(() => {
918
- const a = e(), C = a.map(t);
919
- o.filter((d) => !C.includes(d)).forEach((d) => {
920
- var m, p;
921
- c.delete(d), (p = (m = r.hostElement) == null ? void 0 : m.querySelector(`[data-key="${d}"]`)) == null || p.remove();
922
- }), C.forEach((d, m) => {
923
- o.includes(d) || c.set(
924
- d,
925
- () => s(a[m], m, a).setCustomAttribute(
926
- "data-key",
927
- d
928
- )
929
- );
930
- }), C.forEach((d, m) => {
931
- var p;
932
- if (o.includes(d)) {
933
- JSON.stringify(n[o.indexOf(d)]) !== JSON.stringify(a[m]) && ((p = i.get(d)) == null || p.set({
934
- templateFunc: () => s(a[m], m, a),
935
- items: a,
936
- itemsKey: C,
937
- index: m
938
- }));
939
- return;
940
- }
941
- i.set(
942
- d,
943
- M({
944
- templateFunc: () => s(a[m], m, a),
945
- items: a,
946
- itemsKey: C,
947
- index: m
948
- })
949
- ), queueMicrotask(() => {
950
- w(() => {
951
- var H, N, E;
952
- const { templateFunc: u, index: y } = ((H = i.get(d)) == null ? void 0 : H()) ?? {}, x = (N = r.hostElement) == null ? void 0 : N.querySelector(
953
- `[data-key="${d}"]`
954
- ), L = (u == null ? void 0 : u().setCustomAttribute("data-key", d).hostElement) ?? document.createElement("div");
955
- x ? (E = r.hostElement) == null || E.childNodes.forEach((b, A) => {
956
- b instanceof HTMLElement && b.getAttribute("data-key") === d && (y === A ? (h(
957
- y ?? 0,
958
- r.hostElement,
959
- L
960
- ), b.remove()) : h(
961
- y ?? 0,
962
- r.hostElement,
963
- L
964
- ));
965
- }) : h(y ?? 0, r.hostElement, L);
966
- });
967
- });
968
- });
969
- const h = (d, m, p) => {
970
- p && m && (d < m.children.length ? m.insertBefore(p, m.children[d]) : m.appendChild(p));
971
- };
972
- o = C, n = [...a];
973
- }), r;
974
- };
975
- export {
976
- _ as BaseElement,
977
- ve as a,
978
- Ot as addAttributeList,
979
- gt as addClassList,
980
- Rt as addCustomAttributes,
981
- Lt as addReactiveClassList,
982
- It as addStyleList,
983
- G as appendContentItem,
984
- Fe as article,
985
- ke as aside,
986
- cs as audio,
987
- Ge as b,
988
- Vt as bindReactiveSignals,
989
- Ve as blockquote,
990
- Me as br,
991
- le as button,
992
- V as camelToKebab,
993
- ls as canvas,
994
- K as checkCall,
995
- Ft as checkRef,
996
- Je as cite,
997
- wt as classList,
998
- Yt as cls,
999
- _e as code,
1000
- B as colorLog,
1001
- qt as combineLatest,
1002
- nt as component,
1003
- oe as configCustomComponent,
1004
- ds as createComponent,
1005
- $t as createCustom,
1006
- Tt as createCustomEl,
1007
- Mt as createCustomElement,
1008
- Z as createEl,
1009
- W as createElement,
1010
- Bt as createSignal,
1011
- St as customElementHelpers,
1012
- hs as ddList,
1013
- ne as defineSlotTemplate,
1014
- ts as del,
1015
- ss as details,
1016
- ut as disableLogs,
1017
- xt as div,
1018
- w as effect,
1019
- yt as elementHelpers,
1020
- De as em,
1021
- kt as enableLogs,
1022
- Dt as event,
1023
- Kt as eventEmitter,
1024
- Be as figcaption,
1025
- Ne as figure,
1026
- He as footer,
1027
- Jt as forkJoin,
1028
- Ee as form,
1029
- fs as getList,
1030
- j as getSignalContent,
1031
- Re as h1,
1032
- ge as h2,
1033
- Le as h3,
1034
- Ie as h4,
1035
- Oe as h5,
1036
- je as h6,
1037
- xe as header,
1038
- Te as hr,
1039
- Ke as i,
1040
- we as img,
1041
- it as initComponent,
1042
- ie as input,
1043
- es as ins,
1044
- Gt as isBaseElement,
1045
- ht as isComponentConfig,
1046
- F as isComponentInitConfig,
1047
- g as isReactiveSignal,
1048
- Xt as isSlotTemplate,
1049
- ft as kebabToCamel,
1050
- Ce as label,
1051
- pe as li,
1052
- Pe as main,
1053
- Qe as mark,
1054
- rs as meter,
1055
- We as nav,
1056
- se as newEventEmitter,
1057
- me as ol,
1058
- Zt as oldGetList,
1059
- Se as option,
1060
- Ae as p,
1061
- $e as pre,
1062
- os as progress,
1063
- S as projectLog,
1064
- zt as property,
1065
- Y as removeEffect,
1066
- lt as renderIf,
1067
- Nt as rs,
1068
- jt as rxRenderIf,
1069
- Ze as s,
1070
- ce as section,
1071
- be as select,
1072
- At as setChildren,
1073
- vt as setEffects,
1074
- tt as setListeners,
1075
- ee as show,
1076
- et as showIf,
1077
- M as signal,
1078
- Ut as signalComponent,
1079
- as as slot,
1080
- qe as small,
1081
- re as span,
1082
- ze as strong,
1083
- Ue as sub,
1084
- ns as summary,
1085
- Xe as sup,
1086
- ae as table,
1087
- he as td,
1088
- ye as textarea,
1089
- fe as th,
1090
- de as tr,
1091
- Ye as u,
1092
- ue as ul,
1093
- Qt as unsafeHtml,
1094
- _t as useCustomComponent,
1095
- is as video,
1096
- te as when
1097
- };