@tempots/dom 24.0.0-next.2 → 24.0.0-next.21

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.
package/index.js CHANGED
@@ -1,24 +1,24 @@
1
- var De = Object.defineProperty;
2
- var X = (s) => {
1
+ var $e = Object.defineProperty;
2
+ var te = (s) => {
3
3
  throw TypeError(s);
4
4
  };
5
- var Oe = (s, e, t) => e in s ? De(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
6
- var i = (s, e, t) => Oe(s, typeof e != "symbol" ? e + "" : e, t), Y = (s, e, t) => e.has(s) || X("Cannot " + t);
7
- var A = (s, e, t) => (Y(s, e, "read from private field"), t ? t.call(s) : e.get(s)), Z = (s, e, t) => e.has(s) ? X("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), F = (s, e, t, r) => (Y(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
8
- const Ae = (s, e, t) => s + (e - s) * t;
9
- const Me = (s, e, t) => {
5
+ var ke = (s, e, t) => e in s ? $e(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
6
+ var o = (s, e, t) => ke(s, typeof e != "symbol" ? e + "" : e, t), se = (s, e, t) => e.has(s) || te("Cannot " + t);
7
+ var X = (s, e, t) => (se(s, e, "read from private field"), t ? t.call(s) : e.get(s)), re = (s, e, t) => e.has(s) ? te("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), ne = (s, e, t, r) => (se(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
8
+ const Ie = (s, e, t) => s + (e - s) * t;
9
+ const Ne = (s, e, t) => {
10
10
  const r = Math.max(s.length, e.length);
11
11
  let n = "";
12
- for (let o = 0; o < r; o++) {
13
- let l = s.charCodeAt(o);
12
+ for (let i = 0; i < r; i++) {
13
+ let l = s.charCodeAt(i);
14
14
  isNaN(l) && (l = 97);
15
- let c = e.charCodeAt(o);
16
- isNaN(c) && (c = 97), n += String.fromCharCode(l + (c - l) * t);
15
+ let a = e.charCodeAt(i);
16
+ isNaN(a) && (a = 97), n += String.fromCharCode(l + (a - l) * t);
17
17
  }
18
18
  return n;
19
- }, ke = (s, e, t) => new Date(s.getTime() + (e.getTime() - s.getTime()) * t), Le = (s, e) => e, $e = (s) => typeof s == "number" ? Ae : typeof s == "string" ? Me : s instanceof Date ? ke : Le;
20
- var w;
21
- class M {
19
+ }, Re = (s, e, t) => new Date(s.getTime() + (e.getTime() - s.getTime()) * t), Ve = (s, e) => e, je = (s) => typeof s == "number" ? Ie : typeof s == "string" ? Ne : s instanceof Date ? Re : Ve;
20
+ var D;
21
+ class N {
22
22
  /**
23
23
  * Creates a new instance of `ElementPosition`.
24
24
  * @param index - The index of the element.
@@ -28,25 +28,25 @@ class M {
28
28
  /**
29
29
  * The counter of the element starting from 1.
30
30
  */
31
- i(this, "counter");
31
+ o(this, "counter");
32
32
  /**
33
33
  * Checks if the element is the first element in the collection.
34
34
  * @returns `true` if the element is the first element, `false` otherwise.
35
35
  */
36
- i(this, "isFirst");
36
+ o(this, "isFirst");
37
37
  /**
38
38
  * Checks if the counter of the element is even.
39
39
  * @returns `true` if the counter is even, `false` otherwise.
40
40
  */
41
- i(this, "isEven");
41
+ o(this, "isEven");
42
42
  /**
43
43
  * Checks if the counter of the element is odd.
44
44
  * @returns `true` if the counter is odd, `false` otherwise.
45
45
  */
46
- i(this, "isOdd");
47
- Z(this, w);
48
- i(this, "dispose", () => {
49
- A(this, w) != null && (A(this, w).dispose(), F(this, w, void 0));
46
+ o(this, "isOdd");
47
+ re(this, D);
48
+ o(this, "dispose", () => {
49
+ this.total.dispose();
50
50
  });
51
51
  this.index = e, this.total = t, this.counter = e + 1, this.isFirst = e === 0, this.isEven = e % 2 === 1, this.isOdd = e % 2 === 0;
52
52
  }
@@ -55,11 +55,11 @@ class M {
55
55
  * @returns `true` if the element is the last element, `false` otherwise.
56
56
  */
57
57
  get isLast() {
58
- return A(this, w) == null && F(this, w, this.total.map((e) => this.counter === e)), A(this, w);
58
+ return X(this, D) == null && ne(this, D, this.total.map((e) => this.counter === e)), X(this, D);
59
59
  }
60
60
  }
61
- w = new WeakMap();
62
- const k = class k {
61
+ D = new WeakMap();
62
+ const H = class H {
63
63
  /**
64
64
  * Represents a signal with a value of type T.
65
65
  *
@@ -71,71 +71,83 @@ const k = class k {
71
71
  /**
72
72
  * @internal
73
73
  */
74
- i(this, "$__signal__", !0);
74
+ o(this, "$__signal__", !0);
75
75
  /**
76
76
  * @internal
77
77
  */
78
- i(this, "_value");
78
+ o(this, "_value");
79
79
  /**
80
80
  * @internal
81
81
  */
82
- i(this, "_derivatives", []);
82
+ o(this, "_derivatives", []);
83
83
  /**
84
84
  * @internal
85
85
  */
86
- i(this, "_onValueListeners", []);
86
+ o(this, "_onValueListeners", []);
87
87
  /**
88
88
  * @internal
89
89
  */
90
- i(this, "_onDisposeListeners", []);
90
+ o(this, "_onDisposeListeners", []);
91
91
  /**
92
92
  * Gets the current value of the signal.
93
93
  * @returns The current value of the signal.
94
94
  */
95
- i(this, "get", () => this._value);
95
+ o(this, "get", () => this._value);
96
96
  /**
97
97
  * Checks if the signal has any registered listeners.
98
98
  * @returns `true` if the signal has listeners, `false` otherwise.
99
99
  */
100
- i(this, "hasListeners", () => this._onValueListeners.length > 0);
100
+ o(this, "hasListeners", () => this._onValueListeners.length > 0);
101
101
  /**
102
102
  * Registers a listener function to be called whenever the value of the signal changes.
103
103
  * The listener function will be immediately called with the current value of the signal.
104
104
  * Returns a function that can be called to unregister the listener.
105
105
  *
106
106
  * @param listener - The listener function to be called when the value of the signal changes.
107
- */
108
- i(this, "on", (e) => (e(this.get()), this._onValueListeners.push(e), () => {
109
- this._onValueListeners.splice(this._onValueListeners.indexOf(e), 1);
110
- }));
107
+ * @param options - Options for the listener.
108
+ */
109
+ o(this, "on", (e, t = {}) => {
110
+ t.skipInitial || e(this.get(), void 0);
111
+ const r = t.once ? (i, l) => {
112
+ n(), e(i, l);
113
+ } : e;
114
+ this._onValueListeners.push(r);
115
+ const n = () => {
116
+ this._onValueListeners.splice(
117
+ this._onValueListeners.indexOf(r),
118
+ 1
119
+ ), t.abortSignal != null && t.abortSignal.removeEventListener("abort", n);
120
+ };
121
+ return t.abortSignal != null && t.abortSignal.addEventListener("abort", n), n;
122
+ });
111
123
  /**
112
124
  * @internal
113
125
  */
114
- i(this, "_setAndNotify", (e, t) => {
115
- const r = this.equals(this._value, e);
116
- r || (this._value = e), (t || !r) && this._onValueListeners.forEach((n) => n(e));
126
+ o(this, "_setAndNotify", (e, t) => {
127
+ const r = this._value, n = this.equals(r, e);
128
+ n || (this._value = e), (t || !n) && this._onValueListeners.forEach((i) => i(e, r));
117
129
  });
118
130
  /**
119
131
  * @internal
120
132
  */
121
- i(this, "_disposed", !1);
133
+ o(this, "_disposed", !1);
122
134
  /**
123
135
  * Checks whether the signal is disposed.
124
136
  * @returns True if the signal is disposed, false otherwise.
125
137
  */
126
- i(this, "isDisposed", () => this._disposed);
138
+ o(this, "isDisposed", () => this._disposed);
127
139
  /**
128
140
  * Adds a listener function to be called when the object is disposed.
129
141
  * @param listener - The listener function to be called when the object is disposed.
130
142
  * @returns A function that can be called to remove the listener.
131
143
  */
132
- i(this, "onDispose", (e) => {
144
+ o(this, "onDispose", (e) => {
133
145
  this._onDisposeListeners.push(e);
134
146
  });
135
147
  /**
136
148
  * Disposes the signal, releasing any resources associated with it.
137
149
  */
138
- i(this, "dispose", () => {
150
+ o(this, "dispose", () => {
139
151
  this._disposed || (this._disposed = !0, this._onDisposeListeners.forEach((e) => e()), this._onDisposeListeners.length = 0, this._derivatives.length = 0);
140
152
  });
141
153
  /**
@@ -147,8 +159,8 @@ const k = class k {
147
159
  * @param equals - Optional equality function to determine if two mapped values are equal.
148
160
  * @returns - A new Computed instance with the mapped value.
149
161
  */
150
- i(this, "map", (e, t = (r, n) => r === n) => {
151
- const r = new T(() => {
162
+ o(this, "map", (e, t = (r, n) => r === n) => {
163
+ const r = new x(() => {
152
164
  try {
153
165
  return e(this.get());
154
166
  } catch (n) {
@@ -167,8 +179,8 @@ const k = class k {
167
179
  * Defaults to a strict equality check (===).
168
180
  * @returns A new Signal that emits the values of the resulting Signal.
169
181
  */
170
- i(this, "flatMap", (e, t = (r, n) => r === n) => {
171
- const r = new T(() => {
182
+ o(this, "flatMap", (e, t = (r, n) => r === n) => {
183
+ const r = new x(() => {
172
184
  try {
173
185
  return e(this.get()).get();
174
186
  } catch (n) {
@@ -183,26 +195,26 @@ const k = class k {
183
195
  * @param fn - The callback function to be invoked with the current value of the signal.
184
196
  * @returns A new signal that emits the same value as the original signal and invokes the callback function.
185
197
  */
186
- i(this, "tap", (e) => this.map((t) => (e(t), t)));
198
+ o(this, "tap", (e) => this.map((t) => (e(t), t)));
187
199
  /**
188
200
  * Returns a new Signal that emits the value at the specified key of the current value.
189
201
  *
190
202
  * @param key - The key of the value to retrieve.
191
203
  * @returns A new Signal that emits the value at the specified key.
192
204
  */
193
- i(this, "at", (e) => this.map((t) => t[e]));
205
+ o(this, "at", (e) => this.map((t) => t[e]));
194
206
  /**
195
207
  * @internal
196
208
  */
197
- i(this, "_$");
198
- i(this, "filter", (e, t) => {
209
+ o(this, "_$");
210
+ o(this, "filter", (e, t) => {
199
211
  let r = t ?? this.get();
200
- const n = new T(() => {
212
+ const n = new x(() => {
201
213
  try {
202
- const o = this.get();
203
- return r = e(o) ? o : r;
204
- } catch (o) {
205
- throw console.error("Error in Signal.filter:", o), o;
214
+ const i = this.get();
215
+ return r = e(i) ? i : r;
216
+ } catch (i) {
217
+ throw console.error("Error in Signal.filter:", i), i;
206
218
  }
207
219
  }, this.equals);
208
220
  return this.setDerivative(n), n;
@@ -217,17 +229,17 @@ const k = class k {
217
229
  * @param equals - Optional equality function to determine if two values are equal.
218
230
  * @returns - A new Computed object with the mapped and filtered values.
219
231
  */
220
- i(this, "filterMap", (e, t, r = (n, o) => n === o) => {
232
+ o(this, "filterMap", (e, t, r = (n, i) => n === i) => {
221
233
  let n = t;
222
- const o = new T(() => {
234
+ const i = new x(() => {
223
235
  try {
224
- const l = this.get(), c = e(l);
225
- return n = c ?? n;
236
+ const l = this.get(), a = e(l);
237
+ return n = a ?? n;
226
238
  } catch (l) {
227
239
  throw console.error("Error in Signal.filterMap:", l), l;
228
240
  }
229
241
  }, r);
230
- return this.setDerivative(o), o;
242
+ return this.setDerivative(i), i;
231
243
  });
232
244
  /**
233
245
  * Maps the values emitted by the signal to a new value asynchronously using the provided function.
@@ -242,25 +254,25 @@ const k = class k {
242
254
  * @param equals - The equality function to compare the mapped values for equality.
243
255
  * @returns A property that holds the mapped value and can be observed for changes.
244
256
  */
245
- i(this, "mapAsync", (e, t, r, n = (o, l) => o === l) => {
246
- const o = I(t, n);
247
- let l = 0, c = new AbortController();
248
- return o.onDispose(
249
- this.on(async (a) => {
250
- const f = ++l;
251
- c.abort(), c = new AbortController();
257
+ o(this, "mapAsync", (e, t, r, n = (i, l) => i === l) => {
258
+ const i = E(t, n);
259
+ let l = 0, a = new AbortController();
260
+ return i.onDispose(
261
+ this.on(async (c) => {
262
+ const u = ++l;
263
+ a.abort(), a = new AbortController();
252
264
  try {
253
- const h = await e(a, { abortSignal: c.signal });
254
- f === l && o.set(h);
265
+ const h = await e(c, { abortSignal: a.signal });
266
+ u === l && i.set(h);
255
267
  } catch (h) {
256
- if (f === l)
268
+ if (u === l)
257
269
  if (r != null)
258
- o.set(r(h));
270
+ i.set(r(h));
259
271
  else
260
272
  throw h;
261
273
  }
262
274
  })
263
- ), o;
275
+ ), i;
264
276
  });
265
277
  /**
266
278
  * Maps the values of the signal using the provided function `fn`, and returns a new signal
@@ -272,28 +284,38 @@ const k = class k {
272
284
  * @param alt - The alternative value to use when the mapped value is `undefined` or `null`.
273
285
  * @returns A new signal containing the mapped values.
274
286
  */
275
- i(this, "mapMaybe", (e, t) => this.map((r) => e(r) ?? t));
287
+ o(this, "mapMaybe", (e, t) => this.map((r) => e(r) ?? t));
276
288
  /**
277
289
  * Feeds a property into the signal and sets up disposal behavior.
278
290
  * @param prop - The property to feed into the signal.
279
291
  * @param autoDisposeProp - Determines whether the property should be automatically disposed when the signal is disposed.
280
292
  * @returns The input property.
281
293
  */
282
- i(this, "feedProp", (e, t = !1) => {
294
+ o(this, "feedProp", (e, t = !1) => {
283
295
  const r = this.on(e.set);
284
296
  return e.onDispose(r), t ? this.onDispose(e.dispose) : this.onDispose(r), e;
285
297
  });
286
298
  /**
287
299
  * Derives a new property from the current signal.
288
- * @param autoDisposeProp - Determines whether the derived property should be automatically disposed.
300
+ * @param options - The options for the derived property.
301
+ * @param options.autoDisposeProp - Determines whether the derived property should be automatically disposed.
302
+ * @param options.equals - A function that determines if two values are equal.
289
303
  * @returns The derived property.
290
304
  */
291
- i(this, "deriveProp", (e = !0) => this.feedProp(I(this.get()), e));
305
+ o(this, "deriveProp", ({
306
+ autoDisposeProp: e = !0,
307
+ equals: t
308
+ } = {}) => this.feedProp(E(this.get(), t), e));
309
+ /**
310
+ * Derives a new signal from the current signal. Useful to create a new signal that emits the same values as the current signal but can be disposed independently.
311
+ * @returns A new signal that emits the same values as the current signal.
312
+ */
313
+ o(this, "derive", () => this.map((e) => e));
292
314
  /**
293
315
  * Returns a signal that emits the count of values received so far.
294
316
  * @returns A signal that emits the count of values received so far.
295
317
  */
296
- i(this, "count", () => {
318
+ o(this, "count", () => {
297
319
  let e = 0;
298
320
  return this.map(() => ++e);
299
321
  });
@@ -303,7 +325,7 @@ const k = class k {
303
325
  * Additionally, when the computed value is disposed, it sets the signal as dirty.
304
326
  * @param computed - The computed value to add as a derivative.
305
327
  */
306
- i(this, "setDerivative", (e) => {
328
+ o(this, "setDerivative", (e) => {
307
329
  this._derivatives.push(e), e.onDispose(() => {
308
330
  this._derivatives.splice(
309
331
  this._derivatives.indexOf(e),
@@ -340,27 +362,27 @@ const k = class k {
340
362
  * @param equals - A function to compare two values of type O for equality. Defaults to strict equality (===).
341
363
  * @returns - A Signal that represents the result of the Promise.
342
364
  */
343
- i(k, "ofPromise", (e, t, r, n = (o, l) => o === l) => {
344
- const o = new k(t, n);
345
- return e.then((l) => o._setAndNotify(l, !1)).catch((l) => {
346
- r != null ? o._setAndNotify(r(l), !1) : console.error(
365
+ o(H, "ofPromise", (e, t, r, n = (i, l) => i === l) => {
366
+ const i = new H(t, n);
367
+ return e.then((l) => i._setAndNotify(l, !1)).catch((l) => {
368
+ r != null ? i._setAndNotify(r(l), !1) : console.error(
347
369
  "Unhandled promise rejection in Signal.ofPromise:",
348
370
  l
349
371
  );
350
- }), o;
372
+ }), i;
351
373
  }), /**
352
374
  * Checks if a value is a Signal.
353
375
  *
354
376
  * @param value - The value to check.
355
377
  * @returns `true` if the value is a Signal, `false` otherwise.
356
378
  */
357
- i(k, "is", (e) => (
379
+ o(H, "is", (e) => (
358
380
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
359
381
  e != null && e.$__signal__ === !0
360
382
  ));
361
- let d = k;
362
- const Ne = typeof queueMicrotask == "function" ? queueMicrotask : (s) => Promise.resolve().then(s);
363
- class T extends d {
383
+ let d = H;
384
+ const qe = typeof queueMicrotask == "function" ? queueMicrotask : (s) => Promise.resolve().then(s);
385
+ class x extends d {
364
386
  /**
365
387
  * Represents a Signal object.
366
388
  * @param _fn - The function that returns the value of the signal.
@@ -371,36 +393,36 @@ class T extends d {
371
393
  /**
372
394
  * @internal
373
395
  */
374
- i(this, "$__computed__", !0);
396
+ o(this, "$__computed__", !0);
375
397
  /**
376
398
  * @internal
377
399
  */
378
- i(this, "_isDirty", !1);
400
+ o(this, "_isDirty", !1);
379
401
  /**
380
402
  * Marks the signal as dirty, indicating that its value has changed and needs to be recalculated.
381
403
  * If the signal is already dirty or disposed, this method does nothing.
382
404
  * It also marks all dependent signals as dirty and schedules a notification to update their values.
383
405
  */
384
- i(this, "setDirty", () => {
406
+ o(this, "setDirty", () => {
385
407
  this._isDirty || this._disposed || (this._isDirty = !0, this._derivatives.forEach((t) => t.setDirty()), this._scheduleNotify());
386
408
  });
387
409
  /**
388
410
  * @internal
389
411
  */
390
- i(this, "_scheduleCount", 0);
412
+ o(this, "_scheduleCount", 0);
391
413
  /**
392
414
  * Schedules a notification to be executed asynchronously.
393
415
  * If the signal is dirty, it will be updated and notified.
394
416
  * @internal
395
417
  */
396
- i(this, "_scheduleNotify", () => {
418
+ o(this, "_scheduleNotify", () => {
397
419
  const t = ++this._scheduleCount;
398
- Ne(() => {
420
+ qe(() => {
399
421
  this._scheduleCount !== t || this._disposed !== !1 || this._isDirty && (this._isDirty = !1, this._setAndNotify(this._fn(), !1));
400
422
  });
401
423
  });
402
424
  /** {@inheritDoc Signal.get} */
403
- i(this, "get", () => (this._isDirty && (this._isDirty = !1, this._value = this._fn(), this._setAndNotify(this._value, !0)), this._value));
425
+ o(this, "get", () => (this._isDirty && (this._isDirty = !1, this._setAndNotify(this._fn(), !0)), this._value));
404
426
  this._fn = t, this.setDirty();
405
427
  }
406
428
  /**
@@ -417,26 +439,26 @@ class T extends d {
417
439
  return this.get();
418
440
  }
419
441
  }
420
- const V = class V extends d {
442
+ const W = class W extends d {
421
443
  constructor() {
422
444
  super(...arguments);
423
445
  /**
424
446
  * @internal
425
447
  */
426
- i(this, "$__prop__", !0);
448
+ o(this, "$__prop__", !0);
427
449
  /**
428
450
  * Changes the value of the property and notifies its listeners.
429
451
  *
430
452
  * @param value - The new value of the property.
431
453
  */
432
- i(this, "set", (t) => {
454
+ o(this, "set", (t) => {
433
455
  this._setAndNotify(t, !1);
434
456
  });
435
457
  /**
436
458
  * Updates the value of the signal by applying the provided function to the current value.
437
459
  * @param fn - The function to apply to the current value.
438
460
  */
439
- i(this, "update", (t) => {
461
+ o(this, "update", (t) => {
440
462
  this._setAndNotify(t(this.get()), !1);
441
463
  });
442
464
  /**
@@ -445,16 +467,16 @@ const V = class V extends d {
445
467
  * @param effects - An array of effects to be executed after the state is updated.
446
468
  * @returns A dispatch function that can be used to update the state and trigger the effects.
447
469
  */
448
- i(this, "reducer", (t, ...r) => {
470
+ o(this, "reducer", (t, ...r) => {
449
471
  const n = this;
450
- return function o(l) {
451
- const c = n.value;
452
- n.update((a) => t(a, l)), !n.equals(c, n.value) && r.forEach(
453
- (a) => a({
454
- previousState: c,
472
+ return function i(l) {
473
+ const a = n.value;
474
+ n.update((c) => t(c, l)), !n.equals(a, n.value) && r.forEach(
475
+ (c) => c({
476
+ previousState: a,
455
477
  state: n.value,
456
478
  action: l,
457
- dispatch: o
479
+ dispatch: i
458
480
  })
459
481
  );
460
482
  };
@@ -470,9 +492,9 @@ const V = class V extends d {
470
492
  * Defaults to a strict equality check (===).
471
493
  * @returns A Prop object representing the isomorphism.
472
494
  */
473
- i(this, "iso", (t, r, n = (o, l) => o === l) => {
474
- const o = new V(t(this.get()), n);
475
- return o.onDispose(this.on((l) => o.set(t(l)))), o.on((l) => this._setAndNotify(r(l), !1)), o;
495
+ o(this, "iso", (t, r, n = (i, l) => i === l) => {
496
+ const i = new W(t(this.get()), n);
497
+ return i.onDispose(this.on((l) => i.set(t(l)))), i.on((l) => this._setAndNotify(r(l), !1)), i;
476
498
  });
477
499
  /**
478
500
  * Returns a `Prop` that represents the value at the specified key of the current value.
@@ -480,7 +502,7 @@ const V = class V extends d {
480
502
  * @param key - The key of the value to access.
481
503
  * @returns A `Prop` that represents the value at the specified key.
482
504
  */
483
- i(this, "atProp", (t) => this.iso(
505
+ o(this, "atProp", (t) => this.iso(
484
506
  (r) => r[t],
485
507
  (r) => ({ ...this.value, [t]: r })
486
508
  ));
@@ -500,15 +522,30 @@ const V = class V extends d {
500
522
  * @param value - The value to check.
501
523
  * @returns `true` if the value is a Prop, `false` otherwise.
502
524
  */
503
- i(V, "is", (t) => (
525
+ o(W, "is", (t) => (
504
526
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
505
527
  t != null && t.$__prop__ === !0
506
528
  ));
507
- let H = V;
508
- const G = (s, e, t = (r, n) => r === n) => {
509
- const r = new T(s, t);
529
+ let R = W;
530
+ const Y = (s, e, t = (r, n) => r === n) => {
531
+ const r = new x(s, t);
510
532
  return e.forEach((n) => n.setDerivative(r)), r;
511
- }, He = (s, e) => G(s, e).dispose, I = (s, e = (t, r) => t === r) => new H(s, e), R = (s, e = (t, r) => t === r) => new d(s, e), ee = () => typeof window < "u" ? window : void 0, p = {
533
+ }, Fe = (s, e, t = {}) => {
534
+ let r = t.once ? () => {
535
+ i(), s();
536
+ } : s;
537
+ if (t.skipInitial) {
538
+ let l = !1;
539
+ const a = r;
540
+ r = () => {
541
+ l ? a() : l = !0;
542
+ };
543
+ }
544
+ const n = Y(r, e), i = () => {
545
+ n.dispose(), t.abortSignal != null && t.abortSignal.removeEventListener("abort", i);
546
+ };
547
+ return t.abortSignal != null && t.abortSignal.addEventListener("abort", i), i;
548
+ }, E = (s, e = (t, r) => t === r) => new R(s, e), J = (s, e = (t, r) => t === r) => new d(s, e), oe = () => typeof window < "u" ? window : void 0, y = {
512
549
  /**
513
550
  * Maps a value or a Signal to a new value.
514
551
  * If the value is a Signal, it returns a new Signal with the mapped value.
@@ -531,7 +568,7 @@ const G = (s, e, t = (r, n) => r === n) => {
531
568
  * @param equals - A function that determines if two values are equal. Defaults to strict equality (===).
532
569
  * @returns A Signal instance.
533
570
  */
534
- toSignal: (s, e) => d.is(s) ? s : R(s, e),
571
+ toSignal: (s, e) => d.is(s) ? s : J(s, e),
535
572
  /**
536
573
  * Wraps a value in a `Signal` if it is not already a `Signal`.
537
574
  * If the value is `null` or `undefined`, it returns `null` or `undefined` respectively.
@@ -540,7 +577,7 @@ const G = (s, e, t = (r, n) => r === n) => {
540
577
  */
541
578
  maybeToSignal: (s, e) => {
542
579
  if (s != null)
543
- return p.toSignal(s, e);
580
+ return y.toSignal(s, e);
544
581
  },
545
582
  /**
546
583
  * Gets the value from a `Signal` or the value itself if it is not a `Signal`.
@@ -564,107 +601,125 @@ const G = (s, e, t = (r, n) => r === n) => {
564
601
  */
565
602
  dispose: (s) => {
566
603
  d.is(s) && s.dispose();
567
- }
568
- }, yt = (...s) => (e, t) => {
604
+ },
605
+ /**
606
+ * Derives a Prop from a Signal.
607
+ * If the value is a Signal, it returns a new Prop with the derived value.
608
+ * If the value is not a Signal, it returns a new Prop with the value.
609
+ * @param value - The value or Signal instance to derive the Prop from.
610
+ * @param options - The options for the derived Prop.
611
+ * @param options.autoDisposeProp - Determines whether the derived Prop should be automatically disposed.
612
+ * @param options.equals - A function that determines if two values are equal.
613
+ * @returns A Prop instance.
614
+ */
615
+ deriveProp: (s, {
616
+ autoDisposeProp: e = !0,
617
+ equals: t
618
+ } = {}) => d.is(s) ? s.deriveProp({ autoDisposeProp: e, equals: t }) : E(s, t)
619
+ }, $t = (...s) => (e, t) => {
620
+ const r = s.filter((n) => d.is(n));
621
+ return Y(
622
+ () => e(...s.map((n) => y.get(n))),
623
+ r,
624
+ t
625
+ );
626
+ }, kt = (...s) => (e, t = {}) => {
569
627
  const r = s.filter((n) => d.is(n));
570
- return G(
571
- () => e(...s.map((n) => p.get(n))),
628
+ return Fe(
629
+ () => e(...s.map(y.get)),
572
630
  r,
573
631
  t
574
632
  );
575
- }, wt = (...s) => (e) => {
576
- const t = s.filter((r) => d.is(r));
577
- He(() => e(...s.map(p.get)), t);
578
633
  };
579
- class te {
634
+ class le {
580
635
  constructor() {
581
- i(this, "_store", /* @__PURE__ */ new Map());
636
+ o(this, "_store", /* @__PURE__ */ new Map());
582
637
  /**
583
638
  * Retrieves the value associated with the specified key from the memory store.
584
639
  * @param key - The key to retrieve the value for.
585
640
  * @returns The value associated with the key, or `null` if the key is not found.
586
641
  */
587
- i(this, "getItem", (e) => this._store.get(e) ?? null);
642
+ o(this, "getItem", (e) => this._store.get(e) ?? null);
588
643
  /**
589
644
  * Sets the value associated with the specified key in the memory store.
590
645
  * @param key - The key to set the value for.
591
646
  * @param value - The value to set.
592
647
  */
593
- i(this, "setItem", (e, t) => {
648
+ o(this, "setItem", (e, t) => {
594
649
  this._store.set(e, t);
595
650
  });
596
651
  }
597
652
  }
598
- const se = ({
653
+ const ce = ({
599
654
  key: s,
600
655
  defaultValue: e,
601
656
  store: t,
602
657
  serialize: r = JSON.stringify,
603
658
  deserialize: n = JSON.parse,
604
- equals: o = (c, a) => c === a,
605
- onLoad: l = (c) => c
659
+ equals: i = (a, c) => a === c,
660
+ onLoad: l = (a) => a
606
661
  }) => {
607
- const c = t.getItem(s), a = new H(
608
- c != null ? l(n(c)) : typeof e == "function" ? e() : e,
609
- o
662
+ const a = t.getItem(s), c = new R(
663
+ a != null ? l(n(a)) : typeof e == "function" ? e() : e,
664
+ i
610
665
  );
611
- return a.on((f) => {
612
- t.setItem(s, r(f));
613
- }), a;
614
- }, _t = (s) => {
666
+ return c.on((u) => {
667
+ t.setItem(s, r(u));
668
+ }), c;
669
+ }, It = (s) => {
615
670
  var e;
616
- return se({
671
+ return ce({
617
672
  ...s,
618
- store: ((e = ee()) == null ? void 0 : e.localStorage) ?? new te()
673
+ store: ((e = oe()) == null ? void 0 : e.localStorage) ?? new le()
619
674
  });
620
- }, vt = (s) => {
675
+ }, Nt = (s) => {
621
676
  var e;
622
- return se({
677
+ return ce({
623
678
  ...s,
624
- store: ((e = ee()) == null ? void 0 : e.sessionStorage) ?? new te()
679
+ store: ((e = oe()) == null ? void 0 : e.sessionStorage) ?? new le()
625
680
  });
626
681
  };
627
- function K(s) {
682
+ function ie(s) {
628
683
  return typeof requestAnimationFrame == "function" ? requestAnimationFrame(s) : setTimeout(s, 0);
629
684
  }
630
- const Ie = (s, e, t, r) => {
631
- const n = (r == null ? void 0 : r.duration) ?? 300, o = (r == null ? void 0 : r.easing) ?? ((y) => y), l = (r == null ? void 0 : r.equals) ?? ((y, N) => y === N);
632
- let c = r == null ? void 0 : r.interpolate, a = s, f = e(), h = performance.now(), P = null, O = !0;
633
- const B = new T(e, l), x = I(s, l);
634
- x.onDispose(() => {
635
- P !== null && cancelAnimationFrame(P);
636
- }), x.onDispose(B.dispose), t.forEach((y) => {
637
- y.setDerivative(B), y.onDispose(x.dispose);
685
+ const Be = (s, e, t, r) => {
686
+ const n = (r == null ? void 0 : r.duration) ?? 300, i = (r == null ? void 0 : r.easing) ?? ((A) => A), l = (r == null ? void 0 : r.equals) ?? ((A, I) => A === I);
687
+ let a = r == null ? void 0 : r.interpolate, c = s, u = e(), h = performance.now(), m = null, b = !0;
688
+ const p = new x(e, l), g = E(s, l);
689
+ g.onDispose(() => {
690
+ m !== null && cancelAnimationFrame(m);
691
+ }), g.onDispose(p.dispose), t.forEach((A) => {
692
+ A.setDerivative(p), A.onDispose(g.dispose);
638
693
  });
639
- const be = (y) => {
640
- f = y, h = performance.now(), a = x.value, O && (O = !1, P = K(J));
641
- }, J = () => {
642
- const N = (performance.now() - h) / p.get(n), Ee = o(N);
643
- c == null && (c = $e(a));
644
- let Q = c(a, f, Ee);
645
- N >= 1 ? (O = !0, Q = f) : P = K(J), x.set(Q);
694
+ const w = (A) => {
695
+ u = A, h = performance.now(), c = g.value, b && (b = !1, m = ie(K));
696
+ }, K = () => {
697
+ const I = (performance.now() - h) / y.get(n), He = i(I);
698
+ a == null && (a = je(c));
699
+ let ee = a(c, u, He);
700
+ I >= 1 ? (b = !0, ee = u) : m = ie(K), g.set(ee);
646
701
  };
647
- return B.on(be), x;
648
- }, St = (s, e) => {
702
+ return p.on(w), g;
703
+ }, Rt = (s, e) => {
649
704
  const { initialValue: t, ...r } = e ?? {};
650
- return Ie(
705
+ return Be(
651
706
  t ?? s.get(),
652
707
  s.get,
653
708
  [s],
654
709
  r
655
710
  );
656
- }, Pt = (s, e) => {
711
+ }, Vt = (s, e) => {
657
712
  const { signals: t, literals: r } = Object.entries(s).reduce(
658
- ({ signals: o, literals: l }, [c, a]) => (d.is(a) ? o.push([c, a]) : l[c] = a, { signals: o, literals: l }),
713
+ ({ signals: i, literals: l }, [a, c]) => (d.is(c) ? i.push([a, c]) : l[a] = c, { signals: i, literals: l }),
659
714
  { signals: [], literals: {} }
660
- ), n = t.map(([, o]) => o);
661
- return G(() => (t.forEach(([o, l]) => r[o] = l.value), e(r)), n);
662
- }, re = /* @__PURE__ */ new Set(["checked", "disabled", "hidden", "selected"]), ne = /* @__PURE__ */ new Set([
715
+ ), n = t.map(([, i]) => i);
716
+ return Y(() => (t.forEach(([i, l]) => r[i] = l.value), e(r)), n);
717
+ }, ae = /* @__PURE__ */ new Set(["checked", "disabled", "hidden", "selected"]), ue = /* @__PURE__ */ new Set([
663
718
  "rowSpan",
664
719
  "colSpan",
665
720
  "tabIndex",
666
721
  "valueAsNumber"
667
- ]), ie = /* @__PURE__ */ new Set(["valueAsDate"]), oe = /* @__PURE__ */ new Set([
722
+ ]), he = /* @__PURE__ */ new Set(["valueAsDate"]), fe = /* @__PURE__ */ new Set([
668
723
  "value",
669
724
  "textContent",
670
725
  "innerText",
@@ -672,26 +727,26 @@ const Ie = (s, e, t, r) => {
672
727
  "outerHTML",
673
728
  "className",
674
729
  "classList"
675
- ]), Ve = (s, e) => re.has(s) ? (t) => {
730
+ ]), Ue = (s, e) => ae.has(s) ? (t) => {
676
731
  t == null ? e[s] = null : e[s] = !!t;
677
- } : ne.has(s) ? (t) => {
732
+ } : ue.has(s) ? (t) => {
678
733
  t == null ? e[s] = null : e[s] = Number(t);
679
- } : ie.has(s) ? (t) => {
734
+ } : he.has(s) ? (t) => {
680
735
  t == null ? e[s] = null : e[s] = t;
681
- } : oe.has(s) ? (t) => {
736
+ } : fe.has(s) ? (t) => {
682
737
  t == null ? e[s] = null : e[s] = String(t);
683
738
  } : (t) => {
684
739
  t == null ? e.removeAttribute(s) : e.setAttribute(s, t);
685
- }, Re = (s, e) => re.has(s) ? () => !!e[s] : ne.has(s) ? () => Number(e[s]) : ie.has(s) ? () => e[s] : oe.has(s) ? () => String(e[s]) : () => e.getAttribute(s), U = (s) => {
740
+ }, We = (s, e) => ae.has(s) ? () => !!e[s] : ue.has(s) ? () => Number(e[s]) : he.has(s) ? () => e[s] : fe.has(s) ? () => String(e[s]) : () => e.getAttribute(s), V = (s) => {
686
741
  const e = s;
687
742
  e && e.onblur && (e.onblur = null), !(!s || s.ownerDocument === void 0) && s.parentElement && s.parentElement.removeChild(s);
688
- }, je = (s) => le(s) ? s : s.parentElement, le = (s) => s.nodeType === 1;
689
- class ce extends Error {
743
+ }, Je = (s) => de(s) ? s : s.parentElement, de = (s) => s.nodeType === 1;
744
+ class pe extends Error {
690
745
  constructor(e) {
691
746
  super(`Provider not found: ${e.description}`);
692
747
  }
693
748
  }
694
- class b {
749
+ class L {
695
750
  /**
696
751
  * Constructs a new `DOMContext` instance.
697
752
  *
@@ -709,7 +764,7 @@ class b {
709
764
  * @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
710
765
  * @returns The newly created element.
711
766
  */
712
- i(this, "createElement", (e, t) => t !== void 0 ? this.document.createElementNS(t, e) : this.document.createElement(e));
767
+ o(this, "createElement", (e, t) => t !== void 0 ? this.document.createElementNS(t, e) : this.document.createElement(e));
713
768
  /**
714
769
  * Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace and appends it to the current element.
715
770
  *
@@ -717,7 +772,7 @@ class b {
717
772
  * @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
718
773
  * @returns The newly created element.
719
774
  */
720
- i(this, "makeChildElement", (e, t) => {
775
+ o(this, "makeChildElement", (e, t) => {
721
776
  const r = this.createElement(e, t);
722
777
  return this.appendOrInsert(r), this.withElement(r);
723
778
  });
@@ -726,13 +781,13 @@ class b {
726
781
  * @param text - The text content for the new text node.
727
782
  * @returns A new `Text` node with the specified text content.
728
783
  */
729
- i(this, "createText", (e) => this.document.createTextNode(e));
784
+ o(this, "createText", (e) => this.document.createTextNode(e));
730
785
  /**
731
786
  * Creates a new text node with the specified text content and appends it to the current element.
732
787
  * @param text - The text content for the new text node.
733
788
  * @returns A new `DOMContext` with a reference to the new text node.
734
789
  */
735
- i(this, "makeChildText", (e) => {
790
+ o(this, "makeChildText", (e) => {
736
791
  const t = this.createText(e);
737
792
  return this.appendOrInsert(t), this.withReference(t);
738
793
  });
@@ -740,14 +795,14 @@ class b {
740
795
  * Sets the text content of the current element.
741
796
  * @param text - The text content to set.
742
797
  */
743
- i(this, "setText", (e) => {
798
+ o(this, "setText", (e) => {
744
799
  this.reference.nodeValue = e;
745
800
  });
746
801
  /**
747
802
  * Gets the text content of the current element or text node.
748
803
  * @returns The text content of the current element or text node.
749
804
  */
750
- i(this, "getText", () => {
805
+ o(this, "getText", () => {
751
806
  var e;
752
807
  return ((e = this.reference) == null ? void 0 : e.nodeValue) ?? this.element.textContent ?? "";
753
808
  });
@@ -756,7 +811,7 @@ class b {
756
811
  * The text node is appended or inserted to the current `DOMContext`.
757
812
  * The new `DOMContext` with the reference is returned.
758
813
  */
759
- i(this, "makeRef", () => {
814
+ o(this, "makeRef", () => {
760
815
  const e = this.createText("");
761
816
  return this.appendOrInsert(e), this.withReference(e);
762
817
  });
@@ -765,7 +820,7 @@ class b {
765
820
  *
766
821
  * @param child - The child node to append or insert.
767
822
  */
768
- i(this, "appendOrInsert", (e) => {
823
+ o(this, "appendOrInsert", (e) => {
769
824
  this.reference === void 0 ? this.element.appendChild(e) : this.element.insertBefore(e, this.reference);
770
825
  });
771
826
  /**
@@ -773,13 +828,13 @@ class b {
773
828
  * @param element - The DOM element to use in the new `DOMContext` instance.
774
829
  * @returns A new `DOMContext` instance with the provided `element`.
775
830
  */
776
- i(this, "withElement", (e) => new b(this.document, e, void 0, this.providers));
831
+ o(this, "withElement", (e) => new L(this.document, e, void 0, this.providers));
777
832
  /**
778
833
  * Creates a new `DOMContext` instance with a reference to a DOM element selected by the provided `selector`.
779
834
  * @param selector - The CSS selector for the target DOM element.
780
835
  * @returns A new `DOMContext` instance with a reference to the selected DOM element.
781
836
  */
782
- i(this, "makePortal", (e) => {
837
+ o(this, "makePortal", (e) => {
783
838
  const t = this.document.querySelector(e);
784
839
  if (t == null)
785
840
  throw new Error(`Cannot find element by selector for portal: ${e}`);
@@ -791,7 +846,7 @@ class b {
791
846
  * @param reference - The optional `Text` node to use as the reference for the new `DOMContext`.
792
847
  * @returns A new `DOMContext` instance with the specified reference.
793
848
  */
794
- i(this, "withReference", (e) => new b(this.document, this.element, e, this.providers));
849
+ o(this, "withReference", (e) => new L(this.document, this.element, e, this.providers));
795
850
  /**
796
851
  * Returns a new HTMLDOMContext instance with the specified providers merged into
797
852
  * the existing providers.
@@ -799,7 +854,7 @@ class b {
799
854
  * @param providers - An object containing the providers to be merged into the existing providers.
800
855
  * @returns A new HTMLDOMContext instance with the merged providers.
801
856
  */
802
- i(this, "withProviders", (e) => new b(this.document, this.element, this.reference, {
857
+ o(this, "withProviders", (e) => new L(this.document, this.element, this.reference, {
803
858
  ...this.providers,
804
859
  ...e
805
860
  }));
@@ -810,69 +865,74 @@ class b {
810
865
  * @returns The provider for the given mark.
811
866
  * @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
812
867
  */
813
- i(this, "getProvider", (e) => {
868
+ o(this, "getProvider", (e) => {
814
869
  if (this.providers[e] === void 0)
815
- throw new ce(e);
870
+ throw new pe(e);
816
871
  return this.providers[e];
817
872
  });
818
- i(this, "clear", (e) => {
819
- e && (this.reference !== void 0 ? U(this.reference) : U(this.element));
873
+ o(this, "clear", (e) => {
874
+ e && (this.reference !== void 0 ? V(this.reference) : V(this.element));
820
875
  });
821
876
  /**
822
877
  * Adds classes to the element.
823
878
  * @param tokens - The class names to add.
824
879
  */
825
- i(this, "addClasses", (e) => {
880
+ o(this, "addClasses", (e) => {
826
881
  this.element.classList.add(...e);
827
882
  });
828
883
  /**
829
884
  * Removes classes from the element.
830
885
  * @param tokens - The class names to remove.
831
886
  */
832
- i(this, "removeClasses", (e) => {
887
+ o(this, "removeClasses", (e) => {
833
888
  this.element.classList.remove(...e);
834
889
  });
835
890
  /**
836
891
  * Gets the classes of the element.
837
892
  * @returns The classes of the element.
838
893
  */
839
- i(this, "getClasses", () => Array.from(this.element.classList));
894
+ o(this, "getClasses", () => Array.from(this.element.classList));
840
895
  /**
841
896
  * Adds an event listener to the element.
842
897
  * @param event - The event to listen for.
843
898
  * @param listener - The listener to call when the event occurs.
899
+ * @param options - The options for the event listener.
844
900
  * @returns A function to remove the event listener.
845
901
  */
846
- i(this, "on", (e, t) => (this.element.addEventListener(e, t), (r) => {
847
- r && this.element.removeEventListener(e, t);
902
+ o(this, "on", (e, t, r) => (this.element.addEventListener(e, t, r), (n) => {
903
+ n && this.element.removeEventListener(
904
+ e,
905
+ t,
906
+ r
907
+ );
848
908
  }));
849
909
  /**
850
910
  * Returns `true` if the context is a browser DOM context.
851
911
  * @returns `true` if the context is a browser DOM context.
852
912
  */
853
- i(this, "isBrowserDOM", () => !0);
913
+ o(this, "isBrowserDOM", () => !0);
854
914
  /**
855
915
  * Returns `true` if the context is a headless DOM context.
856
916
  * @returns `true` if the context is a headless DOM context.
857
917
  */
858
- i(this, "isHeadlessDOM", () => !1);
918
+ o(this, "isHeadlessDOM", () => !1);
859
919
  /**
860
920
  * Sets the style of the element.
861
921
  * @param name - The name of the style to set.
862
922
  * @param value - The value of the style to set.
863
923
  */
864
- i(this, "setStyle", (e, t) => {
865
- this.element.style.setProperty(e, t);
924
+ o(this, "setStyle", (e, t) => {
925
+ this.element.style[e] = t;
866
926
  });
867
927
  /**
868
928
  * Gets the style of the element.
869
929
  * @param name - The name of the style to get.
870
930
  * @returns The value of the style.
871
931
  */
872
- i(this, "getStyle", (e) => this.element.style.getPropertyValue(e));
873
- i(this, "makeAccessors", (e) => ({
874
- get: Re(e, this.element),
875
- set: Ve(e, this.element)
932
+ o(this, "getStyle", (e) => this.element.style[e]);
933
+ o(this, "makeAccessors", (e) => ({
934
+ get: We(e, this.element),
935
+ set: Ue(e, this.element)
876
936
  }));
877
937
  this.document = e, this.element = t, this.reference = r, this.providers = n;
878
938
  }
@@ -884,44 +944,270 @@ class b {
884
944
  * @returns A new `DOMContext` instance.
885
945
  */
886
946
  static of(e, t) {
887
- return new b(e.ownerDocument, e, t, {});
947
+ return new L(e.ownerDocument, e, t, {});
948
+ }
949
+ }
950
+ const Q = (s, e) => {
951
+ const t = s(e);
952
+ return () => t(!0);
953
+ }, jt = (s, e, { doc: t, clear: r } = {}) => {
954
+ const n = typeof e == "string" ? (t ?? document).querySelector(e) : e;
955
+ if (n === null)
956
+ throw new Ge(
957
+ `Cannot find element by selector for render: ${e}`
958
+ );
959
+ r !== !1 && (t ?? n.ownerDocument) != null && n.nodeType === 1 && (n.innerHTML = "");
960
+ const i = Je(n), l = de(n) ? void 0 : n, a = L.of(i, l);
961
+ return Q(s, a);
962
+ }, qt = (s, {
963
+ startUrl: e = "https://example.com",
964
+ selector: t = ":root"
965
+ } = {}) => {
966
+ const r = y.toSignal(e).deriveProp(), n = new Se(t, void 0), i = new O(n, void 0, { currentURL: r }, {});
967
+ return {
968
+ clear: Q(s(), i),
969
+ root: n,
970
+ currentURL: r
971
+ };
972
+ };
973
+ class Ge extends Error {
974
+ constructor(e) {
975
+ super(e);
976
+ }
977
+ }
978
+ const ge = "data-tts-node", j = "data-tts-class", q = "data-tts-style", F = "data-tts-html", B = "data-tts-text", U = "data-tts-attrs";
979
+ class Ft {
980
+ constructor({
981
+ select: e,
982
+ getAttribute: t,
983
+ setAttribute: r,
984
+ getClass: n,
985
+ setClass: i,
986
+ getStyles: l,
987
+ setStyles: a,
988
+ appendHTML: c,
989
+ getInnerHTML: u,
990
+ setInnerHTML: h,
991
+ getInnerText: m,
992
+ setInnerText: b
993
+ }) {
994
+ /**
995
+ * Selects elements from the headless environment.
996
+ * @param selector - The selector to select elements from. The supported selectors are CSS selectors whose complexity depends on the adapter implementation.
997
+ * @returns An array of elements.
998
+ */
999
+ o(this, "select");
1000
+ /**
1001
+ * Gets the value of an attribute from an element.
1002
+ * @param el - The element to get the attribute from.
1003
+ * @param attr - The attribute to get the value from.
1004
+ * @returns The value of the attribute or null if the attribute is not set.
1005
+ */
1006
+ o(this, "getAttribute");
1007
+ /**
1008
+ * Sets the value of an attribute on an element.
1009
+ * @param el - The element to set the attribute on.
1010
+ * @param attr - The attribute to set the value of.
1011
+ * @param value - The value to set the attribute to.
1012
+ */
1013
+ o(this, "setAttribute");
1014
+ /**
1015
+ * Gets the class of an element.
1016
+ * @param el - The element to get the class from.
1017
+ * @returns The class of the element or an empty string if the class is not set.
1018
+ */
1019
+ o(this, "getClass");
1020
+ /**
1021
+ * Sets the class of an element.
1022
+ * @param el - The element to set the class on.
1023
+ * @param cls - The class to set.
1024
+ */
1025
+ o(this, "setClass");
1026
+ /**
1027
+ * Gets the styles of an element.
1028
+ * @param el - The element to get the styles from.
1029
+ * @returns The styles of the element.
1030
+ */
1031
+ o(this, "getStyles");
1032
+ /**
1033
+ * Sets the styles of an element.
1034
+ * @param el - The element to set the styles on.
1035
+ */
1036
+ o(this, "setStyles");
1037
+ /**
1038
+ * Appends HTML to an element.
1039
+ * @param el - The element to append the HTML to.
1040
+ * @param html - The HTML to append.
1041
+ */
1042
+ o(this, "appendHTML");
1043
+ /**
1044
+ * Gets the inner HTML of an element.
1045
+ * @param el - The element to get the inner HTML from.
1046
+ * @returns The inner HTML of the element or an empty string if the inner HTML is not set.
1047
+ */
1048
+ o(this, "getInnerHTML");
1049
+ /**
1050
+ * Sets the inner HTML of an element.
1051
+ * @param el - The element to set the inner HTML on.
1052
+ * @param html - The inner HTML to set.
1053
+ */
1054
+ o(this, "setInnerHTML");
1055
+ /**
1056
+ * Gets the inner text of an element.
1057
+ * @param el - The element to get the inner text from.
1058
+ * @returns The inner text of the element or an empty string if the inner text is not set.
1059
+ */
1060
+ o(this, "getInnerText");
1061
+ /**
1062
+ * Sets the inner text of an element.
1063
+ * @param el - The element to set the inner text on.
1064
+ * @param text - The inner text to set.
1065
+ */
1066
+ o(this, "setInnerText");
1067
+ /**
1068
+ * Sets the content of the root element from a HeadlessPortal. Generally this will be the same instance that is
1069
+ * returned by `runHeadless`.
1070
+ *
1071
+ * @param root - The HeadlessPortal containing the content to set.
1072
+ * @param setPlaceholders - Whether to set placeholders for the content. This allows you to restore the original content
1073
+ * when you render on the server and then hydrate on the client.
1074
+ */
1075
+ o(this, "setFromRoot", (e, t) => {
1076
+ e.getPortals().forEach((n) => {
1077
+ for (const i of this.select(n.selector)) {
1078
+ if (i == null)
1079
+ throw new Error(
1080
+ `Cannot find element by selector for render: ${n.selector}`
1081
+ );
1082
+ if (n.hasChildren() && this.appendHTML(i, n.contentToHTML(t)), n.hasInnerHTML()) {
1083
+ if (t) {
1084
+ const l = this.getInnerHTML(i);
1085
+ l != null && this.setAttribute(i, F, l);
1086
+ }
1087
+ this.setInnerHTML(i, n.getInnerHTML());
1088
+ }
1089
+ if (n.hasInnerText()) {
1090
+ if (t) {
1091
+ const l = this.getInnerText(i);
1092
+ l != null && this.setAttribute(i, B, l);
1093
+ }
1094
+ this.setInnerText(i, n.getInnerText());
1095
+ }
1096
+ if (n.hasClasses()) {
1097
+ if (t) {
1098
+ const l = this.getClass(i);
1099
+ l != null && this.setAttribute(i, j, l);
1100
+ }
1101
+ this.setClass(i, n.getClasses().join(" "));
1102
+ }
1103
+ if (n.hasStyles()) {
1104
+ if (t) {
1105
+ const l = this.getStyles(i);
1106
+ Object.keys(l).length > 0 && this.setAttribute(
1107
+ i,
1108
+ q,
1109
+ JSON.stringify(l)
1110
+ );
1111
+ }
1112
+ this.setStyles(i, n.getStyles());
1113
+ }
1114
+ if (n.hasAttributes()) {
1115
+ const l = n.getAttributes();
1116
+ if (t) {
1117
+ const a = [];
1118
+ l.forEach(([c]) => {
1119
+ const u = this.getAttribute(i, c);
1120
+ u != null && a.push([c, u]);
1121
+ }), a.length > 0 && this.setAttribute(
1122
+ i,
1123
+ U,
1124
+ JSON.stringify(Object.fromEntries(a))
1125
+ );
1126
+ }
1127
+ l.forEach(([a, c]) => {
1128
+ this.setAttribute(i, a, c);
1129
+ });
1130
+ }
1131
+ }
1132
+ });
1133
+ });
1134
+ this.select = e, this.getAttribute = t, this.setAttribute = r, this.getClass = n, this.setClass = i, this.getStyles = l, this.setStyles = a, this.appendHTML = c, this.getInnerHTML = u, this.setInnerHTML = h, this.getInnerText = m, this.setInnerText = b;
888
1135
  }
889
1136
  }
890
- const g = Symbol("class"), _ = Symbol("style"), C = Symbol("handler"), ae = () => Math.random().toString(36).substring(2, 15), qe = (s) => s.replace(/<[^>]*>?/g, "");
891
- class ue {
1137
+ const ze = () => {
1138
+ document.querySelectorAll(`[${ge}]`).forEach(V);
1139
+ }, Xe = (s) => {
1140
+ const e = s.getAttribute(j);
1141
+ s.removeAttribute(j), e != null && s.setAttribute("class", e);
1142
+ }, Ye = () => {
1143
+ document.querySelectorAll(`[${j}]`).forEach((e) => Xe(e));
1144
+ }, Qe = (s) => {
1145
+ const e = s.getAttribute(F);
1146
+ s.removeAttribute(F), e != null && (s.innerHTML = e);
1147
+ }, Ze = () => {
1148
+ document.querySelectorAll(`[${F}]`).forEach((e) => Qe(e));
1149
+ }, Ke = (s) => {
1150
+ const e = s.getAttribute(B);
1151
+ s.removeAttribute(B), e != null && (s.innerText = e);
1152
+ }, et = () => {
1153
+ document.querySelectorAll(`[${B}]`).forEach((e) => Ke(e));
1154
+ }, me = (s) => JSON.parse(s.replace(/&quot;/g, '"')), tt = (s) => {
1155
+ const e = s.getAttribute(q);
1156
+ if (s.removeAttribute(q), e != null) {
1157
+ const t = me(e);
1158
+ Object.entries(t).forEach(([r, n]) => {
1159
+ s.style.setProperty(r, n);
1160
+ });
1161
+ }
1162
+ }, st = () => {
1163
+ document.querySelectorAll(`[${q}]`).forEach((e) => tt(e));
1164
+ }, rt = (s) => {
1165
+ const e = s.getAttribute(U);
1166
+ if (s.removeAttribute(U), e != null) {
1167
+ const t = me(e);
1168
+ Object.entries(t).forEach(([r, n]) => {
1169
+ n == null ? s.removeAttribute(r) : s.setAttribute(r, n);
1170
+ });
1171
+ }
1172
+ }, nt = () => {
1173
+ document.querySelectorAll(`[${U}]`).forEach((e) => rt(e));
1174
+ }, Bt = () => {
1175
+ ze(), Ye(), et(), Ze(), st(), nt();
1176
+ }, T = Symbol("class"), v = Symbol("style"), C = Symbol("handler"), ye = () => Math.random().toString(36).substring(2, 15), it = (s) => s.replace(/<[^>]*>?/g, "");
1177
+ class Te {
892
1178
  constructor(e) {
893
- i(this, "id", ae());
894
- i(this, "properties", {});
895
- i(this, "children", []);
896
- i(this, "isElement", () => !0);
897
- i(this, "isText", () => !1);
898
- i(this, "getText", () => this.properties.innerText != null ? this.properties.innerText : this.properties.innerHTML != null ? qe(this.properties.innerHTML) : this.children.map((e) => e.getText()).join(""));
899
- i(this, "removeChild", (e) => {
1179
+ o(this, "id", ye());
1180
+ o(this, "properties", {});
1181
+ o(this, "children", []);
1182
+ o(this, "isElement", () => !0);
1183
+ o(this, "isText", () => !1);
1184
+ o(this, "getText", () => this.properties.innerText != null ? this.properties.innerText : this.properties.innerHTML != null ? it(this.properties.innerHTML) : this.children.map((e) => e.getText()).join(""));
1185
+ o(this, "removeChild", (e) => {
900
1186
  const t = this.children.indexOf(e);
901
1187
  t !== -1 && this.children.splice(t, 1);
902
1188
  });
903
- i(this, "remove", () => {
1189
+ o(this, "remove", () => {
904
1190
  if (this.parent != null)
905
1191
  this.parent.removeChild(this);
906
1192
  else
907
1193
  throw new Error("Parent is undefined");
908
1194
  });
909
- i(this, "getPortals", () => {
1195
+ o(this, "getPortals", () => {
910
1196
  const e = this.elements().flatMap((t) => t.isPortal() ? [t, ...t.getPortals()] : t.getPortals());
911
1197
  return this.isPortal() && e.unshift(this), e;
912
1198
  });
913
- i(this, "elements", () => this.children.filter((e) => e.isElement()));
914
- i(this, "hasInnerHTML", () => this.properties.innerHTML != null);
915
- i(this, "getInnerHTML", () => this.properties.innerHTML ?? "");
916
- i(this, "getInnerText", () => this.properties.innerText ?? "");
917
- i(this, "hasInnerText", () => this.properties.innerText != null);
918
- i(this, "hasChildren", () => this.children.length > 0);
919
- i(this, "hasClasses", () => this.properties[g] != null);
920
- i(this, "hasStyles", () => this.properties[_] != null);
921
- i(this, "hasAttributes", () => Object.keys(this.properties).length > 0);
922
- i(this, "hasHandlers", () => this.properties[C] != null);
923
- i(this, "hasRenderableProperties", () => this.hasClasses() || this.hasAttributes() || this.hasStyles());
924
- i(this, "getById", (e) => {
1199
+ o(this, "elements", () => this.children.filter((e) => e.isElement()));
1200
+ o(this, "hasInnerHTML", () => this.properties.innerHTML != null);
1201
+ o(this, "getInnerHTML", () => this.properties.innerHTML ?? "");
1202
+ o(this, "getInnerText", () => this.properties.innerText ?? "");
1203
+ o(this, "hasInnerText", () => this.properties.innerText != null);
1204
+ o(this, "hasChildren", () => this.children.length > 0);
1205
+ o(this, "hasClasses", () => this.properties[T] != null);
1206
+ o(this, "hasStyles", () => this.properties[v] != null);
1207
+ o(this, "hasAttributes", () => Object.keys(this.properties).length > 0);
1208
+ o(this, "hasHandlers", () => this.properties[C] != null);
1209
+ o(this, "hasRenderableProperties", () => this.hasClasses() || this.hasAttributes() || this.hasStyles());
1210
+ o(this, "getById", (e) => {
925
1211
  if (this.properties.id === e)
926
1212
  return this;
927
1213
  for (const t of this.elements()) {
@@ -930,57 +1216,61 @@ class ue {
930
1216
  return r;
931
1217
  }
932
1218
  });
933
- i(this, "trigger", (e, t) => {
1219
+ o(this, "trigger", (e, t) => {
934
1220
  ((this.properties[C] ?? {})[e] ?? []).forEach((n) => n(t));
935
1221
  });
936
- i(this, "click", () => {
1222
+ o(this, "click", () => {
937
1223
  this.trigger("click", {});
938
1224
  });
939
- i(this, "on", (e, t) => {
940
- var o;
941
- const r = (o = this.properties)[C] ?? (o[C] = {}), n = t;
942
- return r[e] = [...r[e] ?? [], n], () => {
943
- const l = r[e] ?? [], c = l.indexOf(n);
944
- c !== -1 && (l.splice(c, 1), l.length === 0 ? (delete r[e], Object.keys(r).length === 0 && delete this.properties[C]) : r[e] = l);
1225
+ o(this, "on", (e, t, r) => {
1226
+ var a;
1227
+ const n = (a = this.properties)[C] ?? (a[C] = {}), i = r != null && r.once ? (c) => {
1228
+ l(), t(c);
1229
+ } : (c) => t(c);
1230
+ n[e] = [...n[e] ?? [], i];
1231
+ const l = () => {
1232
+ const c = n[e] ?? [], u = c.indexOf(i);
1233
+ u !== -1 && (c.splice(u, 1), c.length === 0 ? (delete n[e], Object.keys(n).length === 0 && delete this.properties[C]) : n[e] = c, (r == null ? void 0 : r.signal) != null && r.signal.removeEventListener("abort", l));
945
1234
  };
1235
+ return (r == null ? void 0 : r.signal) != null && r.signal.addEventListener("abort", l), l;
946
1236
  });
947
- i(this, "addClasses", (e) => {
1237
+ o(this, "addClasses", (e) => {
948
1238
  var r;
949
1239
  if (e.length === 0)
950
1240
  return;
951
- const t = (r = this.properties)[g] ?? (r[g] = []);
1241
+ const t = (r = this.properties)[T] ?? (r[T] = []);
952
1242
  e.forEach((n) => {
953
1243
  t.includes(n) || t.push(n);
954
1244
  });
955
1245
  });
956
- i(this, "removeClasses", (e) => {
1246
+ o(this, "removeClasses", (e) => {
957
1247
  var r;
958
1248
  if (e.length === 0)
959
1249
  return;
960
- const t = (r = this.properties)[g] ?? (r[g] = []);
1250
+ const t = (r = this.properties)[T] ?? (r[T] = []);
961
1251
  e.forEach((n) => {
962
- const o = t.indexOf(n);
963
- o !== -1 && t.splice(o, 1);
964
- }), t.length === 0 && delete this.properties[g];
1252
+ const i = t.indexOf(n);
1253
+ i !== -1 && t.splice(i, 1);
1254
+ }), t.length === 0 && delete this.properties[T];
965
1255
  });
966
- i(this, "getClasses", () => this.properties[g] ?? []);
967
- i(this, "getAttributes", () => Object.entries(this.properties).filter(
1256
+ o(this, "getClasses", () => this.properties[T] ?? []);
1257
+ o(this, "getAttributes", () => Object.entries(this.properties).filter(
968
1258
  ([e]) => !["innerText", "innerHTML"].includes(e)
969
1259
  ));
970
- i(this, "getVisibleAttributes", () => Reflect.ownKeys(this.properties).flatMap(
971
- (e) => e === g ? [["class", this.getClasses()]] : e === _ ? [["style", this.getStyles()]] : typeof e == "string" ? [[e, String(this.properties[e])]] : []
1260
+ o(this, "getVisibleAttributes", () => Reflect.ownKeys(this.properties).flatMap(
1261
+ (e) => e === T ? [["class", this.getClasses()]] : e === v ? [["style", this.getStyles()]] : typeof e == "string" ? [[e, String(this.properties[e])]] : []
972
1262
  ));
973
- i(this, "setStyle", (e, t) => {
1263
+ o(this, "setStyle", (e, t) => {
974
1264
  var n;
975
- const r = (n = this.properties)[_] ?? (n[_] = {});
976
- r[e] = t, t === "" && (delete r[e], Object.keys(r).length === 0 && delete this.properties[_]);
1265
+ const r = (n = this.properties)[v] ?? (n[v] = {});
1266
+ r[e] = t, t === "" && (delete r[e], Object.keys(r).length === 0 && delete this.properties[v]);
977
1267
  });
978
- i(this, "getStyle", (e) => {
1268
+ o(this, "getStyle", (e) => {
979
1269
  var t;
980
- return ((t = this.properties[_]) == null ? void 0 : t[e]) ?? "";
1270
+ return ((t = this.properties[v]) == null ? void 0 : t[e]) ?? "";
981
1271
  });
982
- i(this, "getStyles", () => this.properties[_] ?? {});
983
- i(this, "makeAccessors", (e) => {
1272
+ o(this, "getStyles", () => this.properties[v] ?? {});
1273
+ o(this, "makeAccessors", (e) => {
984
1274
  const t = this.properties;
985
1275
  return {
986
1276
  get: () => t[e],
@@ -990,149 +1280,149 @@ class ue {
990
1280
  this.parent = e;
991
1281
  }
992
1282
  }
993
- const Be = (s) => s.replace(/"/g, "&quot;"), Fe = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
994
- class Ue extends ue {
1283
+ const ot = (s) => s.replace(/"/g, "&quot;"), lt = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1284
+ class ct extends Te {
995
1285
  constructor(t, r, n) {
996
1286
  super(n);
997
- i(this, "isPortal", () => !1);
998
- i(this, "toHTML", () => {
999
- const t = this.children.map((l) => l.toHTML()).join(""), r = this.namespace ? ` xmlns="${this.namespace}"` : "";
1000
- let n = null;
1001
- const o = this.getVisibleAttributes().map(([l, c]) => l === "class" ? ` class="${c.join(" ")}"` : l === "style" ? typeof c == "string" ? ` style="${c}"` : ` style="${Object.entries(c).map(([a, f]) => `${a}: ${f};`).join(" ")}"` : Ge.has(l) ? ` ${l}` : l === "innerHTML" ? (n = c, "") : l === "innerText" ? (n = Fe(c), "") : ` ${l}="${Be(c)}"`).join("");
1002
- return ze.has(this.tagName) && t === "" ? `<${this.tagName}${r}${o} />` : `<${this.tagName}${r}${o}>${n ?? t}</${this.tagName}>`;
1287
+ o(this, "isPortal", () => !1);
1288
+ o(this, "toHTML", (t = !1) => {
1289
+ const r = this.children.map((c) => c.toHTML()).join(""), n = this.namespace ? ` xmlns="${this.namespace}"` : "";
1290
+ let i = null;
1291
+ const l = this.getVisibleAttributes().map(([c, u]) => c === "class" ? ` class="${u.join(" ")}"` : c === "style" ? typeof u == "string" ? ` style="${u}"` : ` style="${Object.entries(u).map(([h, m]) => `${h}: ${m};`).join(" ")}"` : ut.has(c) ? ` ${c}` : c === "innerHTML" ? (i = u, "") : c === "innerText" ? (i = lt(u), "") : ` ${c}="${ot(u)}"`).join(""), a = t ? ` ${ge}` : "";
1292
+ return ht.has(this.tagName) && r === "" ? `<${this.tagName}${n}${l}${a} />` : `<${this.tagName}${n}${l}${a}>${i ?? r}</${this.tagName}>`;
1003
1293
  });
1004
1294
  this.tagName = t, this.namespace = r;
1005
1295
  }
1006
1296
  }
1007
- class he extends ue {
1297
+ class Se extends Te {
1008
1298
  constructor(t, r) {
1009
1299
  super(r);
1010
- i(this, "isPortal", () => !0);
1011
- i(this, "toHTML", () => "");
1012
- i(this, "contentToHTML", () => this.children.map((t) => t.toHTML()).join(""));
1300
+ o(this, "isPortal", () => !0);
1301
+ o(this, "toHTML", () => "");
1302
+ o(this, "contentToHTML", (t = !1) => this.children.map((r) => r.toHTML(t)).join(""));
1013
1303
  this.selector = t;
1014
1304
  }
1015
1305
  }
1016
- class We {
1306
+ class at {
1017
1307
  constructor(e) {
1018
- i(this, "id", ae());
1019
- i(this, "isElement", () => !1);
1020
- i(this, "isText", () => !0);
1021
- i(this, "getText", () => this.text);
1022
- i(this, "toHTML", () => this.text);
1308
+ o(this, "id", ye());
1309
+ o(this, "isElement", () => !1);
1310
+ o(this, "isText", () => !0);
1311
+ o(this, "getText", () => this.text);
1312
+ o(this, "toHTML", () => this.text);
1023
1313
  this.text = e;
1024
1314
  }
1025
1315
  }
1026
- class E {
1316
+ class O {
1027
1317
  constructor(e, t, r, n) {
1028
- i(this, "appendOrInsert", (e) => {
1318
+ o(this, "appendOrInsert", (e) => {
1029
1319
  if (this.reference != null) {
1030
1320
  const t = this.element.children.indexOf(this.reference);
1031
1321
  this.element.children.splice(t, 0, e);
1032
1322
  } else
1033
1323
  this.element.children.push(e);
1034
1324
  });
1035
- i(this, "makeChildElement", (e, t) => {
1036
- const r = new Ue(e, t, this.element);
1037
- return this.appendOrInsert(r), new E(
1325
+ o(this, "makeChildElement", (e, t) => {
1326
+ const r = new ct(e, t, this.element);
1327
+ return this.appendOrInsert(r), new O(
1038
1328
  r,
1039
1329
  void 0,
1040
1330
  this.container,
1041
1331
  this.providers
1042
1332
  );
1043
1333
  });
1044
- i(this, "makeChildText", (e) => {
1045
- const t = new We(e);
1046
- return this.appendOrInsert(t), new E(
1334
+ o(this, "makeChildText", (e) => {
1335
+ const t = new at(e);
1336
+ return this.appendOrInsert(t), new O(
1047
1337
  this.element,
1048
1338
  t,
1049
1339
  this.container,
1050
1340
  this.providers
1051
1341
  );
1052
1342
  });
1053
- i(this, "setText", (e) => {
1343
+ o(this, "setText", (e) => {
1054
1344
  this.reference && this.reference.isText() && (this.reference.text = e);
1055
1345
  });
1056
- i(this, "getText", () => {
1346
+ o(this, "getText", () => {
1057
1347
  var e;
1058
1348
  return ((e = this.reference) == null ? void 0 : e.getText()) ?? this.element.getText();
1059
1349
  });
1060
- i(this, "makeRef", () => this.makeChildText(""));
1061
- i(this, "makePortal", (e) => {
1062
- const t = new he(e, this.element);
1063
- return this.appendOrInsert(t), new E(
1350
+ o(this, "makeRef", () => this.makeChildText(""));
1351
+ o(this, "makePortal", (e) => {
1352
+ const t = new Se(e, this.element);
1353
+ return this.appendOrInsert(t), new O(
1064
1354
  t,
1065
1355
  void 0,
1066
1356
  this.container,
1067
1357
  this.providers
1068
1358
  );
1069
1359
  });
1070
- i(this, "withProviders", (e) => new E(this.element, this.reference, this.container, {
1360
+ o(this, "withProviders", (e) => new O(this.element, this.reference, this.container, {
1071
1361
  ...this.providers,
1072
1362
  ...e
1073
1363
  }));
1074
- i(this, "getProvider", (e) => {
1364
+ o(this, "getProvider", (e) => {
1075
1365
  if (this.providers[e] === void 0)
1076
- throw new ce(e);
1366
+ throw new pe(e);
1077
1367
  return this.providers[e];
1078
1368
  });
1079
- i(this, "clear", (e) => {
1369
+ o(this, "clear", (e) => {
1080
1370
  e && (this.reference !== void 0 ? this.element.removeChild(this.reference) : this.element.remove());
1081
1371
  });
1082
- i(this, "on", (e, t) => this.element.on(e, t));
1083
- i(this, "addClasses", (e) => this.element.addClasses(e));
1084
- i(this, "removeClasses", (e) => this.element.removeClasses(e));
1085
- i(this, "getClasses", () => this.element.getClasses());
1086
- i(this, "isBrowserDOM", () => !1);
1087
- i(this, "isHeadlessDOM", () => !0);
1088
- i(this, "setStyle", (e, t) => this.element.setStyle(e, t));
1089
- i(this, "getStyle", (e) => this.element.getStyle(e));
1090
- i(this, "makeAccessors", (e) => this.element.makeAccessors(e));
1372
+ o(this, "on", (e, t) => this.element.on(e, t));
1373
+ o(this, "addClasses", (e) => this.element.addClasses(e));
1374
+ o(this, "removeClasses", (e) => this.element.removeClasses(e));
1375
+ o(this, "getClasses", () => this.element.getClasses());
1376
+ o(this, "isBrowserDOM", () => !1);
1377
+ o(this, "isHeadlessDOM", () => !0);
1378
+ o(this, "setStyle", (e, t) => this.element.setStyle(e, t));
1379
+ o(this, "getStyle", (e) => this.element.getStyle(e));
1380
+ o(this, "makeAccessors", (e) => this.element.makeAccessors(e));
1091
1381
  this.element = e, this.reference = t, this.container = r, this.providers = n;
1092
1382
  }
1093
1383
  }
1094
- const Ge = /* @__PURE__ */ new Set([
1384
+ const ut = /* @__PURE__ */ new Set([
1095
1385
  "checked",
1096
1386
  "disabled",
1097
1387
  "multiple",
1098
1388
  "readonly",
1099
1389
  "required",
1100
1390
  "selected"
1101
- ]), ze = /* @__PURE__ */ new Set(["img", "br", "hr", "input", "link", "meta"]), fe = (s) => (e) => {
1391
+ ]), ht = /* @__PURE__ */ new Set(["img", "br", "hr", "input", "link", "meta"]), be = (s) => (e) => {
1102
1392
  const t = e.makeChildText(s);
1103
1393
  return (r) => t.clear(r);
1104
- }, de = (s) => (e) => {
1394
+ }, Ae = (s) => (e) => {
1105
1395
  const t = e.makeChildText(s.value), r = s.on((n) => t.setText(n));
1106
1396
  return (n) => {
1107
1397
  r(), t.clear(n);
1108
1398
  };
1109
- }, xt = (s) => d.is(s) ? de(s) : fe(s), m = (...s) => (e) => {
1110
- const t = s.map((r) => u(r)(e));
1399
+ }, Ut = (s) => d.is(s) ? Ae(s) : be(s), S = (...s) => (e) => {
1400
+ const t = s.map((r) => f(r)(e));
1111
1401
  return (r) => {
1112
1402
  t.forEach((n) => n(r));
1113
1403
  };
1114
- }, v = () => () => {
1115
- }, Je = (s) => (e) => (e.addClasses(s), (t) => {
1404
+ }, _ = () => () => {
1405
+ }, ft = (s) => (e) => (e.addClasses(s), (t) => {
1116
1406
  t && e.removeClasses(s);
1117
- }), Qe = (s) => (e) => {
1407
+ }), dt = (s) => (e) => {
1118
1408
  let t = [];
1119
1409
  const r = s.on((n) => {
1120
- e.removeClasses(t), t = (n ?? "").split(" ").filter((o) => o.length > 0), e.addClasses(t);
1410
+ e.removeClasses(t), t = (n ?? "").split(" ").filter((i) => i.length > 0), e.addClasses(t);
1121
1411
  });
1122
1412
  return (n) => {
1123
1413
  r(), n && e.removeClasses(t), t.length = 0;
1124
1414
  };
1125
- }, L = (s, e) => (t) => {
1126
- const { get: r, set: n } = t.makeAccessors(s), o = r();
1415
+ }, $ = (s, e) => (t) => {
1416
+ const { get: r, set: n } = t.makeAccessors(s), i = r();
1127
1417
  return n(e), (l) => {
1128
- l && n(o);
1418
+ l && n(i);
1129
1419
  };
1130
- }, $ = (s, e) => (t) => {
1131
- const { get: r, set: n } = t.makeAccessors(s), o = r(), l = e.on(n);
1132
- return (c) => {
1133
- l(), c && n(o);
1420
+ }, k = (s, e) => (t) => {
1421
+ const { get: r, set: n } = t.makeAccessors(s), i = r(), l = e.on(n);
1422
+ return (a) => {
1423
+ l(), a && n(i);
1134
1424
  };
1135
- }, D = new Proxy(
1425
+ }, M = new Proxy(
1136
1426
  {},
1137
1427
  {
1138
1428
  /**
@@ -1146,17 +1436,17 @@ const Ge = /* @__PURE__ */ new Set([
1146
1436
  * @returns The renderable component for the specified attribute.
1147
1437
  *
1148
1438
  */
1149
- get: (s, e) => e === "class" ? (t) => d.is(t) ? Qe(t) : Je(
1439
+ get: (s, e) => e === "class" ? (t) => d.is(t) ? dt(t) : ft(
1150
1440
  (t ?? "").split(" ").filter((r) => r.length > 0)
1151
- ) : (t) => d.is(t) ? $(
1441
+ ) : (t) => d.is(t) ? k(
1152
1442
  e,
1153
1443
  t
1154
- ) : L(
1444
+ ) : $(
1155
1445
  e,
1156
1446
  t
1157
1447
  )
1158
1448
  }
1159
- ), Ct = new Proxy(
1449
+ ), Wt = new Proxy(
1160
1450
  {},
1161
1451
  {
1162
1452
  /**
@@ -1167,12 +1457,12 @@ const Ge = /* @__PURE__ */ new Set([
1167
1457
  * @returns The renderable component for the specified attribute.
1168
1458
  *
1169
1459
  */
1170
- get: (s, e) => (t) => d.is(t) ? $(
1460
+ get: (s, e) => (t) => d.is(t) ? k(
1171
1461
  `data-${e}`,
1172
1462
  t
1173
- ) : L(`data-${e}`, t)
1463
+ ) : $(`data-${e}`, t)
1174
1464
  }
1175
- ), Tt = new Proxy(
1465
+ ), Jt = new Proxy(
1176
1466
  {},
1177
1467
  {
1178
1468
  /**
@@ -1183,15 +1473,15 @@ const Ge = /* @__PURE__ */ new Set([
1183
1473
  * @returns The renderable component for the specified attribute.
1184
1474
  *
1185
1475
  */
1186
- get: (s, e) => (t) => d.is(t) ? $(
1476
+ get: (s, e) => (t) => d.is(t) ? k(
1187
1477
  `aria-${e}`,
1188
1478
  t
1189
- ) : L(
1479
+ ) : $(
1190
1480
  `aria-${e}`,
1191
1481
  t
1192
1482
  )
1193
1483
  }
1194
- ), bt = new Proxy(
1484
+ ), Gt = new Proxy(
1195
1485
  {},
1196
1486
  {
1197
1487
  /**
@@ -1202,15 +1492,15 @@ const Ge = /* @__PURE__ */ new Set([
1202
1492
  * @returns The renderable component for the specified attribute.
1203
1493
  *
1204
1494
  */
1205
- get: (s, e) => (t) => d.is(t) ? $(
1495
+ get: (s, e) => (t) => d.is(t) ? k(
1206
1496
  e,
1207
1497
  t
1208
- ) : L(
1498
+ ) : $(
1209
1499
  e,
1210
1500
  t
1211
1501
  )
1212
1502
  }
1213
- ), Et = new Proxy(
1503
+ ), zt = new Proxy(
1214
1504
  {},
1215
1505
  {
1216
1506
  /**
@@ -1220,37 +1510,37 @@ const Ge = /* @__PURE__ */ new Set([
1220
1510
  * @returns The renderable component for the specified attribute.
1221
1511
  *
1222
1512
  */
1223
- get: (s, e) => (t) => d.is(t) ? $(
1513
+ get: (s, e) => (t) => d.is(t) ? k(
1224
1514
  e,
1225
1515
  t
1226
- ) : L(
1516
+ ) : $(
1227
1517
  e,
1228
1518
  t
1229
1519
  )
1230
1520
  }
1231
- ), u = (s) => {
1521
+ ), f = (s) => {
1232
1522
  if (s == null)
1233
- return v;
1523
+ return _;
1234
1524
  if (Array.isArray(s))
1235
- return m(...s.map(u));
1525
+ return S(...s.map(f));
1236
1526
  if (typeof s == "string")
1237
- return fe(s);
1527
+ return be(s);
1238
1528
  if (d.is(s))
1239
- return de(s);
1529
+ return Ae(s);
1240
1530
  if (typeof s == "function")
1241
1531
  return s;
1242
1532
  throw new Error(`Unknown type: '${typeof s}' for child: ${s}`);
1243
- }, pe = (s, ...e) => (t) => {
1244
- const r = t.makeChildElement(s, void 0), n = e.map((o) => u(o)(r));
1245
- return (o) => {
1246
- n.forEach((l) => l(!1)), r.clear(o);
1533
+ }, _e = (s, ...e) => (t) => {
1534
+ const r = t.makeChildElement(s, void 0), n = e.map((i) => f(i)(r));
1535
+ return (i) => {
1536
+ n.forEach((l) => l(!1)), r.clear(i);
1247
1537
  };
1248
- }, ge = (s, e, ...t) => (r) => {
1249
- const n = r.makeChildElement(s, e), o = t.map((l) => u(l)(n));
1538
+ }, ve = (s, e, ...t) => (r) => {
1539
+ const n = r.makeChildElement(s, e), i = t.map((l) => f(l)(n));
1250
1540
  return (l) => {
1251
- o.forEach((c) => c(!1)), n.clear(l);
1541
+ i.forEach((a) => a(!1)), n.clear(l);
1252
1542
  };
1253
- }, Dt = new Proxy(
1543
+ }, Xt = new Proxy(
1254
1544
  {},
1255
1545
  {
1256
1546
  /**
@@ -1258,9 +1548,9 @@ const Ge = /* @__PURE__ */ new Set([
1258
1548
  * @param tagName - The HTML tag name.
1259
1549
  * @returns A renderable function that creates and appends the HTML element to the DOM.
1260
1550
  */
1261
- get: (s, e) => (...t) => pe(e, t.flatMap(u))
1551
+ get: (s, e) => (...t) => _e(e, t.flatMap(f))
1262
1552
  }
1263
- ), Ot = new Proxy(
1553
+ ), Yt = new Proxy(
1264
1554
  {},
1265
1555
  {
1266
1556
  /**
@@ -1268,9 +1558,9 @@ const Ge = /* @__PURE__ */ new Set([
1268
1558
  * @param type - The input type name.
1269
1559
  * @returns A renderable function that creates and appends the HTMLInput element to the DOM.
1270
1560
  */
1271
- get: (s, e) => (...t) => pe("input", D.type(e), ...t)
1561
+ get: (s, e) => (...t) => _e("input", M.type(e), ...t)
1272
1562
  }
1273
- ), Xe = "http://www.w3.org/2000/svg", At = new Proxy(
1563
+ ), pt = "http://www.w3.org/2000/svg", Qt = new Proxy(
1274
1564
  {},
1275
1565
  {
1276
1566
  /**
@@ -1278,9 +1568,9 @@ const Ge = /* @__PURE__ */ new Set([
1278
1568
  * @param tagName - The SVG tag name.
1279
1569
  * @returns A renderable function that creates and appends the SVG element to the DOM.
1280
1570
  */
1281
- get: (s, e) => (...t) => ge(e, Xe, t.flatMap(u))
1571
+ get: (s, e) => (...t) => ve(e, pt, t.flatMap(f))
1282
1572
  }
1283
- ), Ye = "http://www.w3.org/1998/Math/MathML", Mt = new Proxy(
1573
+ ), gt = "http://www.w3.org/1998/Math/MathML", Zt = new Proxy(
1284
1574
  {},
1285
1575
  {
1286
1576
  /**
@@ -1288,35 +1578,35 @@ const Ge = /* @__PURE__ */ new Set([
1288
1578
  * @param tagName - The Math tag name.
1289
1579
  * @returns A renderable function that creates and appends the Math element to the DOM.
1290
1580
  */
1291
- get: (s, e) => (...t) => ge(e, Ye, t.flatMap(u))
1581
+ get: (s, e) => (...t) => ve(e, gt, t.flatMap(f))
1292
1582
  }
1293
- ), me = (s, e) => {
1583
+ ), Ee = (s, e) => {
1294
1584
  if (typeof e == "function")
1295
- return me(s, { then: e });
1296
- const t = e.pending != null ? u(e.pending) : v, r = e.then, n = e.error != null ? (o) => u(e.error(o)) : () => v;
1297
- return (o) => {
1585
+ return Ee(s, { then: e });
1586
+ const t = e.pending != null ? f(e.pending) : _, r = e.then, n = e.error != null ? (i) => f(e.error(i)) : () => _;
1587
+ return (i) => {
1298
1588
  let l = !0;
1299
- const c = s(), a = o.makeRef();
1300
- let f = u(t)(a);
1301
- return c.then(
1589
+ const a = s(), c = i.makeRef();
1590
+ let u = f(t)(c);
1591
+ return a.then(
1302
1592
  (h) => {
1303
- l && (f(!0), f = u(r(h))(a));
1593
+ l && (u(!0), u = f(r(h))(c));
1304
1594
  },
1305
1595
  (h) => {
1306
- l && (f(!0), f = u(n(h))(a));
1596
+ l && (u(!0), u = f(n(h))(c));
1307
1597
  }
1308
1598
  ), (h) => {
1309
- l = !1, f(h), a.clear(h);
1599
+ l = !1, u(h), c.clear(h);
1310
1600
  };
1311
1601
  };
1312
- }, kt = (s, e) => me(() => s, e), ye = (s, e) => (t) => t.on(s, e), Ze = (s) => ye("click", (e) => {
1602
+ }, Kt = (s, e) => Ee(() => s, e), we = (s, e, t) => (r) => r.on(s, e, t), mt = (s) => we("click", (e) => {
1313
1603
  e.preventDefault();
1314
1604
  const t = e.target;
1315
1605
  setTimeout(() => {
1316
1606
  const r = t.ownerDocument != null ? t == null ? void 0 : t.checked : void 0;
1317
1607
  r != null && s(!r);
1318
1608
  }, 0);
1319
- }), j = new Proxy(
1609
+ }), G = new Proxy(
1320
1610
  {},
1321
1611
  {
1322
1612
  /**
@@ -1324,15 +1614,15 @@ const Ge = /* @__PURE__ */ new Set([
1324
1614
  * @param fn - The function to call when the event is triggered.
1325
1615
  * @returns A `Renderable` function that adds the event listener to the element.
1326
1616
  */
1327
- get: (s, e) => (t) => ye(e, t)
1617
+ get: (s, e) => (t) => we(e, t)
1328
1618
  }
1329
- ), Ke = (s) => (e) => {
1619
+ ), yt = (s) => (e) => {
1330
1620
  const t = e.target;
1331
1621
  s(t.value);
1332
- }, et = (s) => (e) => {
1622
+ }, Tt = (s) => (e) => {
1333
1623
  const t = e.target;
1334
1624
  s(t.valueAsNumber);
1335
- }, tt = (s) => (e) => {
1625
+ }, St = (s) => (e) => {
1336
1626
  const t = e.target;
1337
1627
  if (t.value === "")
1338
1628
  return;
@@ -1342,212 +1632,245 @@ const Ge = /* @__PURE__ */ new Set([
1342
1632
  Number(r[2].substring(0, 2))
1343
1633
  );
1344
1634
  s(n);
1345
- }, st = (s) => (e) => {
1635
+ }, bt = (s) => (e) => {
1346
1636
  const t = e.target;
1347
1637
  if (t.value === "")
1348
1638
  return;
1349
- const r = t.value.split("T"), n = r[0].split("-"), o = new Date(
1639
+ const r = t.value.split("T"), n = r[0].split("-"), i = new Date(
1350
1640
  Number(n[0]),
1351
1641
  Number(n[1]) - 1,
1352
1642
  Number(n[2])
1353
1643
  ), l = r[1].split(":");
1354
- o.setHours(Number(l[0])), o.setMinutes(Number(l[1])), o.setSeconds(Number(l[2])), s(o);
1355
- }, Lt = (s) => (e) => {
1644
+ i.setHours(Number(l[0])), i.setMinutes(Number(l[1])), i.setSeconds(Number(l[2])), s(i);
1645
+ }, es = (s) => (e) => {
1356
1646
  const t = e.target;
1357
1647
  s(t.checked);
1358
- }, $t = (s) => (e) => {
1648
+ }, ts = (s) => (e) => {
1359
1649
  e.preventDefault(), s();
1360
- }, Nt = (s) => (e) => {
1650
+ }, ss = (s) => (e) => {
1361
1651
  e.stopPropagation(), s();
1362
- }, Ht = (s) => (e) => {
1652
+ }, rs = (s) => (e) => {
1363
1653
  e.stopImmediatePropagation(), s();
1364
- }, It = (s, e = "input") => m(
1365
- D.valueAsDate(s),
1366
- j[e](tt(s.set))
1367
- ), Vt = (s, e = "input") => m(
1368
- D.valueAsDate(s),
1369
- j[e](st(s.set))
1370
- ), Rt = (s, e = "input") => m(
1371
- D.valueAsNumber(s),
1372
- j[e](et(s.set))
1373
- ), jt = (s, e = "input") => m(D.value(s), j[e](Ke(s.set))), qt = (s) => m(D.checked(s), Ze(s.set)), q = (s, e) => {
1654
+ }, ns = (s, e = "input") => S(
1655
+ M.valueAsDate(s),
1656
+ G[e](St(s.set))
1657
+ ), is = (s, e = "input") => S(
1658
+ M.valueAsDate(s),
1659
+ G[e](bt(s.set))
1660
+ ), os = (s, e = "input") => S(
1661
+ M.valueAsNumber(s),
1662
+ G[e](Tt(s.set))
1663
+ ), ls = (s, e = "input") => S(M.value(s), G[e](yt(s.set))), cs = (s) => S(M.checked(s), mt(s.set)), z = (s, e) => {
1374
1664
  if (d.is(s))
1375
1665
  return (r) => {
1376
1666
  const n = r.makeRef();
1377
- let o, l;
1378
- const c = s.map((h) => Object.keys(h)[0]);
1379
- let a;
1380
- const f = c.on((h) => {
1381
- if (h !== a) {
1382
- l == null || l.dispose(), o == null || o(!0), l = s.map((O) => O[h]);
1383
- const P = e[h](l);
1384
- o = u(P)(n), a = h;
1667
+ let i, l;
1668
+ const a = s.map((h) => Object.keys(h)[0]);
1669
+ let c;
1670
+ const u = a.on((h) => {
1671
+ if (h !== c) {
1672
+ l == null || l.dispose(), i == null || i(!0), l = s.map((b) => b[h]);
1673
+ const m = e[h](l);
1674
+ i = f(m)(n), c = h;
1385
1675
  }
1386
1676
  });
1387
1677
  return (h) => {
1388
- f(), n.clear(h), o == null || o(h);
1678
+ l == null || l.dispose(), u(), n.clear(h), i == null || i(h);
1389
1679
  };
1390
1680
  };
1391
1681
  const t = Object.keys(s)[0];
1392
- return u(e[t](R(s[t])));
1393
- }, we = (s, e, t) => q(
1394
- p.map(s, (r) => ({ [r[e]]: r })),
1682
+ return f(e[t](J(s[t])));
1683
+ }, Ce = (s, e, t) => z(
1684
+ y.map(s, (r) => ({ [r[e]]: r })),
1395
1685
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1396
1686
  t
1397
- ), Bt = (s, e) => we(s, "kind", e), Ft = (s, e) => {
1398
- const t = p.map(s, ([r, n]) => ({ [r]: n }));
1399
- return q(t, e);
1400
- }, Ut = (s, e) => we(s, "type", e), rt = (s, e) => q(
1401
- p.map(s, (t) => ({ [t]: !0 })),
1687
+ ), as = (s, e) => Ce(s, "kind", e), us = (s, e) => {
1688
+ const t = y.map(s, ([r, n]) => ({ [r]: n }));
1689
+ return z(t, e);
1690
+ }, hs = (s, e) => Ce(s, "type", e), At = (s, e) => z(
1691
+ y.map(s, (t) => ({ [t]: !0 })),
1402
1692
  e
1403
- ), Wt = (s, e = {}) => (t) => {
1693
+ ), fs = (s, e = {}) => (t) => {
1404
1694
  const r = (e == null ? void 0 : e.firstSeparator) ?? s, n = (e == null ? void 0 : e.lastSeparator) ?? s;
1405
- return rt(
1406
- t.map((o) => o.isFirst ? "first" : o.isLast ? "last" : "other"),
1695
+ return At(
1696
+ t.map((i) => i.isFirst ? "first" : i.isLast ? "last" : "other"),
1407
1697
  {
1408
1698
  first: () => r,
1409
1699
  last: () => n,
1410
1700
  other: () => s
1411
1701
  }
1412
1702
  );
1413
- }, _e = (s, e) => (t) => {
1414
- const r = Object.values(s).reduce((n, o) => {
1415
- const l = t.getProvider(o);
1416
- return n[o] = l, n;
1417
- }, {});
1418
- return u(e(r))(t);
1419
- }, Gt = (s, e) => (t) => {
1703
+ }, Pe = (s, e) => (t) => {
1704
+ const r = Object.values(s).reduce(
1705
+ (n, i) => {
1706
+ const l = t.getProvider(i);
1707
+ return Reflect.set(n, i, l), n;
1708
+ },
1709
+ {}
1710
+ );
1711
+ return f(e(r))(t);
1712
+ }, ds = (s, e) => (t) => {
1420
1713
  const r = [], n = Object.entries(s).reduce(
1421
- (o, [l, c]) => (r.push(
1422
- c((a) => (Reflect.set(o, l, a), null))(t)
1423
- ), o),
1714
+ (i, [l, a]) => (r.push(
1715
+ a((c) => (Reflect.set(i, l, c), null))(t)
1716
+ ), i),
1424
1717
  {}
1425
1718
  );
1426
- return r.push(e(n)(t)), (o) => {
1427
- r.forEach((l) => l(o));
1719
+ return r.push(e(n)(t)), (i) => {
1720
+ r.forEach((l) => l(i));
1428
1721
  };
1429
- }, nt = (s, e) => _e([s], (t) => u(e(t[s]))), zt = (s, e) => _e(s, (t) => u(e(t))), Jt = (s) => (e) => s(e) ?? (() => {
1430
- }), Qt = (s) => (e) => (e.appendOrInsert(s), (t) => {
1431
- t && U(s);
1432
- }), it = (s, e, t) => {
1722
+ }, _t = (s, e) => Pe([s], (t) => f(e(t[s]))), ps = (s, e) => Pe(s, (t) => f(e(t))), gs = (s) => (e) => s(e) ?? (() => {
1723
+ }), ms = (s) => (e) => (e.appendOrInsert(s), (t) => {
1724
+ t && V(s);
1725
+ }), vt = (s, e, t) => {
1433
1726
  if (d.is(s)) {
1434
1727
  const r = s;
1435
1728
  return (n) => {
1436
- const o = n.makeRef();
1437
- let l = null, c = !1;
1438
- const a = I(null), f = r.on((h) => {
1439
- h == null ? (l == null || l(!0), l = u((t == null ? void 0 : t()) ?? v)(o), c = !1) : (a.value = h, c || (l == null || l(!0), l = u(e(a))(
1440
- o
1441
- ), c = !0));
1729
+ const i = n.makeRef();
1730
+ let l = () => {
1731
+ }, a = !1, c = null;
1732
+ const u = r.on((h) => {
1733
+ h == null ? (l(!0), l = f((t == null ? void 0 : t()) ?? _)(i), a = !1, c == null || c.dispose(), c = null) : (c == null ? c = E(h) : c.value = h, a || (l(!0), l = f(e(c))(
1734
+ i
1735
+ ), a = !0));
1442
1736
  });
1443
1737
  return (h) => {
1444
- f(), l == null || l(h), o.clear(h);
1738
+ c == null || c.dispose(), u(), l == null || l(h), i.clear(h);
1445
1739
  };
1446
1740
  };
1447
1741
  } else {
1448
1742
  const r = s;
1449
1743
  if (r == null) {
1450
1744
  const n = t == null ? void 0 : t();
1451
- return n != null ? u(n) : v;
1745
+ return n != null ? f(n) : _;
1452
1746
  }
1453
- return u(e(R(r)));
1747
+ return f(e(J(r)));
1454
1748
  }
1455
- }, W = (s) => (e) => (t) => s(t, e), ve = (s, e, t) => Se(
1749
+ }, ys = (...s) => (e, t) => (r) => {
1750
+ const n = r.makeRef();
1751
+ if (s.some(
1752
+ (p) => !d.is(p) && p == null
1753
+ ))
1754
+ return (t != null ? f(t == null ? void 0 : t()) : _)(
1755
+ n
1756
+ );
1757
+ const l = s.map(() => null), a = s.map(
1758
+ (p) => d.is(p) ? p.value != null : p != null
1759
+ );
1760
+ let c = null;
1761
+ const u = E(a.every((p) => p)), h = (p, g) => {
1762
+ if (p.value != null) {
1763
+ if (l[g] == null) {
1764
+ const w = E(p.value);
1765
+ l[g] = w;
1766
+ } else
1767
+ l[g].value = p.value;
1768
+ a[g] = !0;
1769
+ } else
1770
+ a[g] = !1;
1771
+ };
1772
+ let m = s.length - 1;
1773
+ const b = s.map((p, g) => {
1774
+ if (!d.is(p)) {
1775
+ const w = E(p);
1776
+ return l[g] = w, () => {
1777
+ };
1778
+ }
1779
+ return p.on(() => {
1780
+ h(p, g), m === 0 ? u.value = a.every((w) => w) : m--;
1781
+ });
1782
+ });
1783
+ return u.on((p) => {
1784
+ c == null || c(!0), c = null, p ? c = f(e(...l))(n) : c = f((t == null ? void 0 : t()) ?? _)(n);
1785
+ }), (p) => {
1786
+ l.forEach((g) => g == null ? void 0 : g.dispose()), u.dispose(), b.forEach((g) => g()), c == null || c(p), n.clear(p);
1787
+ };
1788
+ }, Z = (...s) => (e) => (t) => s.forEach((r) => r(t, e)), Et = (s, e, t) => xe(
1456
1789
  s,
1457
1790
  () => e,
1458
1791
  () => t
1459
- ), Se = (s, e, t) => it(
1460
- p.map(s, (r) => r ? !0 : null),
1792
+ ), xe = (s, e, t) => vt(
1793
+ y.map(s, (r) => r ? !0 : null),
1461
1794
  e,
1462
1795
  t ?? void 0
1463
- ), Xt = (s, e, t) => ot(
1796
+ ), Ts = (s, e, t) => wt(
1464
1797
  s,
1465
1798
  () => e,
1466
1799
  () => t
1467
- ), ot = (s, e, t) => Se(
1468
- p.map(s, (r) => !r),
1800
+ ), wt = (s, e, t) => xe(
1801
+ y.map(s, (r) => !r),
1469
1802
  e,
1470
1803
  t
1471
- ), Pe = (s, e, t) => t != null ? Pe(s, (r) => {
1472
- const n = new M(
1804
+ ), Le = (s, e, t) => t != null ? Le(s, (r) => {
1805
+ const n = new N(
1473
1806
  r.index,
1474
- r.total.map((o) => o - 1)
1807
+ r.total.map((i) => i - 1)
1475
1808
  );
1476
- return m(
1477
- W(n.dispose),
1478
- u(e(r)),
1479
- ve(r.isLast, v, t(n))
1809
+ return S(
1810
+ Z(n.dispose),
1811
+ f(e(r)),
1812
+ Et(r.isLast, _, t(n))
1480
1813
  );
1481
1814
  }) : d.is(s) ? (r) => {
1482
- const n = r.makeRef(), o = Array.from(
1815
+ const n = r.makeRef(), i = Array.from(
1483
1816
  { length: s.value },
1484
- (a, f) => f
1485
- ).map((a) => new M(a, s)), l = o.map(
1486
- (a) => u(e(a))(n)
1487
- ), c = s.on((a) => {
1488
- for (; a < l.length; )
1489
- o.pop().dispose(), l.pop()(!0);
1490
- for (let f = 0; f < a; f++)
1491
- if (o[f] == null) {
1492
- o[f] = new M(f, s);
1493
- const h = u(e(o[f]));
1494
- l[f] = h(n);
1817
+ (c, u) => u
1818
+ ).map((c) => new N(c, s.derive())), l = i.map(
1819
+ (c) => f(e(c))(n)
1820
+ ), a = s.on((c) => {
1821
+ for (; c < l.length; )
1822
+ i.pop().dispose(), l.pop()(!0);
1823
+ for (let u = 0; u < c; u++)
1824
+ if (i[u] == null) {
1825
+ i[u] = new N(u, s.derive());
1826
+ const h = f(e(i[u]));
1827
+ l[u] = h(n);
1495
1828
  }
1496
1829
  });
1497
- return (a) => {
1498
- c(), n.clear(a);
1830
+ return (c) => {
1831
+ a(), n.clear(c);
1499
1832
  };
1500
- } : m(
1833
+ } : S(
1501
1834
  ...Array.from({ length: s }, (r, n) => n).map(
1502
- (r) => u(e(new M(r, R(s))))
1835
+ (r) => f(e(new N(r, J(s))))
1503
1836
  )
1504
- ), lt = (s, e, t) => {
1505
- if (t != null)
1506
- return lt(s, (r, n) => {
1507
- const o = new M(
1508
- n.index,
1509
- n.total.map((l) => l - 1)
1510
- );
1511
- return m([
1512
- W(o.dispose),
1513
- u(e(r, n)),
1514
- ve(n.isLast, v, t(o))
1515
- ]);
1516
- });
1517
- {
1518
- const r = p.map(s, (o) => o.length), n = p.toSignal(s);
1519
- return Pe(r, (o) => {
1520
- const l = n.map((c) => c[o.index]);
1521
- return m(
1522
- W(l.dispose),
1523
- u(e(l, o))
1837
+ ), Ss = (s, e, t) => {
1838
+ const r = y.map(s, (i) => i.length), n = y.toSignal(s);
1839
+ return Le(
1840
+ r,
1841
+ (i) => {
1842
+ const l = n.map((a) => a[i.index]);
1843
+ return S(
1844
+ Z(l.dispose),
1845
+ f(e(l, i))
1524
1846
  );
1525
- });
1526
- }
1527
- }, ct = (s) => (e) => e.isBrowserDOM() ? s(e) ?? (() => {
1847
+ },
1848
+ t
1849
+ );
1850
+ }, Ct = (s) => (e) => e.isBrowserDOM() ? s(e) ?? (() => {
1528
1851
  }) : () => {
1529
- }, Yt = (s) => (e) => e.isHeadlessDOM() ? s(e) ?? (() => {
1852
+ }, bs = (s) => (e) => e.isHeadlessDOM() ? s(e) ?? (() => {
1530
1853
  }) : () => {
1531
- }, Zt = (s) => ct((e) => s(e.element) ?? (() => {
1532
- })), Kt = (s, e) => {
1854
+ }, As = (s) => Ct((e) => s(e.element) ?? (() => {
1855
+ })), _s = (s, e) => {
1533
1856
  if (d.is(s)) {
1534
1857
  const t = s;
1535
1858
  return (r) => {
1536
1859
  r = r.makeRef();
1537
- const n = t.map((c) => u(e(c)));
1538
- let o = () => {
1860
+ const n = t.map((a) => f(e(a)));
1861
+ let i = () => {
1539
1862
  };
1540
- const l = n.on((c) => {
1541
- o(!0), o = c(r);
1863
+ const l = n.on((a) => {
1864
+ i(!0), i = a(r);
1542
1865
  });
1543
- return (c) => {
1544
- l(), o(c);
1866
+ return (a) => {
1867
+ l(), i(a);
1545
1868
  };
1546
1869
  };
1547
1870
  }
1548
- return u(e(s));
1549
- }, es = (s, e, t = () => v) => q(
1550
- p.map(
1871
+ return f(e(s));
1872
+ }, vs = (s, e, t = () => _) => z(
1873
+ y.map(
1551
1874
  s,
1552
1875
  (r) => r.length > 0 ? { notEmpty: r } : { whenEmpty: null }
1553
1876
  ),
@@ -1555,62 +1878,52 @@ const Ge = /* @__PURE__ */ new Set([
1555
1878
  notEmpty: (r) => e(r),
1556
1879
  whenEmpty: () => t()
1557
1880
  }
1558
- ), z = (s, e) => {
1559
- const t = s(e);
1560
- return () => t(!0);
1561
- }, ts = (s, e, { doc: t, clear: r } = {}) => {
1562
- const n = typeof e == "string" ? (t ?? document).querySelector(e) : e;
1563
- if (n === null)
1564
- throw new at(
1565
- `Cannot find element by selector for render: ${e}`
1566
- );
1567
- r !== !1 && (t ?? n.ownerDocument) != null && n.nodeType === 1 && (n.innerHTML = "");
1568
- const o = je(n), l = le(n) ? void 0 : n, c = b.of(o, l);
1569
- return z(s, c);
1570
- }, ss = (s, {
1571
- startUrl: e = "https://example.com",
1572
- selector: t = ":root"
1573
- } = {}) => {
1574
- const r = p.toSignal(e).deriveProp(), n = new he(t, void 0), o = new E(n, void 0, { currentURL: r }, {});
1575
- return {
1576
- clear: z(s(), o),
1577
- root: n,
1578
- currentURL: r
1579
- };
1580
- };
1581
- class at extends Error {
1582
- constructor(e) {
1583
- super(e);
1584
- }
1585
- }
1586
- const rs = (s, e) => (t) => {
1881
+ ), Es = (s, e) => (t) => {
1587
1882
  const r = t.makePortal(s);
1588
- return z(u(e), r);
1589
- }, ut = (s) => Symbol(s), xe = (s, e) => (t) => u(e)(t.withProviders(s)), ns = (...s) => s.length > 0 ? s.reduceRight((e, t) => (r) => e(t(r))) : u, ht = (s, e, t) => xe({ [s]: e }, u(t)), is = (s, e) => xe(s, u(e)), Ce = ut("Probe"), S = /* @__PURE__ */ new Map(), ft = (s, e, t) => {
1590
- if (S.has(s))
1883
+ return Q(f(e), r);
1884
+ }, Pt = (s) => Symbol(s), Oe = (s, e) => (t) => f(e)(t.withProviders(s)), ws = (...s) => s.length > 0 ? s.reduceRight((e, t) => (r) => e(t(r))) : f, xt = (s, e, t) => Oe({ [s]: e }, f(t)), Cs = (s, e) => Oe(s, f(e)), De = Pt("Probe"), P = /* @__PURE__ */ new Map(), Lt = ({
1885
+ identifier: s,
1886
+ callback: e = () => {
1887
+ },
1888
+ child: t,
1889
+ timeout: r = 10
1890
+ }) => {
1891
+ if (P.has(s))
1591
1892
  throw new Error(`Probe already exists: ${s.description}`);
1592
- return S.set(s, 0), ht(Ce, (n) => {
1593
- let o = S.get(n);
1594
- if (o == null)
1595
- throw new Error(`Probe not found: ${n.description}`);
1596
- --o === 0 ? (e(), S.delete(n)) : S.set(n, o);
1597
- }, t);
1598
- }, dt = (s, e) => nt(Ce, (t) => {
1599
- const r = S.get(s);
1600
- if (r == null)
1601
- throw new Error(`Probe not found: ${s.description}`);
1602
- return S.set(s, r + 1), e(() => t(s));
1603
- }), Te = Symbol("globalProbe"), os = (s, e) => ft(Te, s, e), ls = (s) => dt(Te, s), pt = (s, e) => (t) => {
1893
+ const n = setTimeout(() => e("timeout"), r);
1894
+ P.set(s, {
1895
+ counter: 0,
1896
+ timeoutId: n
1897
+ });
1898
+ const i = (l) => {
1899
+ clearTimeout(n);
1900
+ const a = P.get(l);
1901
+ if (a == null)
1902
+ throw new Error(`Probe not found: ${l.description}`);
1903
+ --a.counter === 0 ? (e("resolved"), P.delete(l)) : P.set(l, a);
1904
+ };
1905
+ return S(
1906
+ Z(() => clearTimeout(n)),
1907
+ xt(De, i, t)
1908
+ );
1909
+ }, Ot = (s, e) => _t(De, (t) => {
1910
+ const r = P.get(s);
1911
+ return r == null ? e(() => {
1912
+ }) : (clearTimeout(r.timeoutId), r.counter++, e(() => t(s)));
1913
+ }), Me = Symbol("globalProbe"), Ps = ({
1914
+ callback: s,
1915
+ timeout: e
1916
+ }, t) => Lt({ identifier: Me, callback: s, child: t, timeout: e }), xs = (s) => Ot(Me, s), Dt = (s, e) => (t) => {
1604
1917
  const r = t.getStyle(s);
1605
1918
  return t.setStyle(s, e), (n) => {
1606
1919
  n && t.setStyle(s, r);
1607
1920
  };
1608
- }, gt = (s, e) => (t) => {
1921
+ }, Mt = (s, e) => (t) => {
1609
1922
  const r = t.getStyle(s);
1610
1923
  return e.on((n) => t.setStyle(s, n)), (n) => {
1611
1924
  n && t.setStyle(s, r);
1612
1925
  };
1613
- }, cs = new Proxy(
1926
+ }, Ls = new Proxy(
1614
1927
  {},
1615
1928
  {
1616
1929
  /**
@@ -1621,117 +1934,122 @@ const rs = (s, e) => (t) => {
1621
1934
  * @returns The renderable component for the specified attribute.
1622
1935
  *
1623
1936
  */
1624
- get: (s, e) => (t) => d.is(t) ? gt(e, t) : pt(e, t)
1937
+ get: (s, e) => (t) => d.is(t) ? Mt(e, t) : Dt(e, t)
1625
1938
  }
1626
1939
  );
1627
1940
  export {
1628
- kt as Async,
1629
- qt as BindChecked,
1630
- It as BindDate,
1631
- Vt as BindDateTime,
1632
- Rt as BindNumber,
1633
- jt as BindText,
1634
- b as BrowserContext,
1635
- T as Computed,
1636
- Wt as Conjunction,
1637
- Qt as DOMNode,
1638
- pe as El,
1639
- ge as ElNS,
1640
- M as ElementPosition,
1641
- v as Empty,
1642
- it as Ensure,
1643
- lt as ForEach,
1644
- m as Fragment,
1645
- E as HeadlessContext,
1646
- Ue as HeadlessElement,
1647
- he as HeadlessPortal,
1648
- We as HeadlessText,
1649
- ot as LazyUnless,
1650
- Se as LazyWhen,
1651
- Kt as MapSignal,
1652
- te as MemoryStore,
1653
- es as NotEmpty,
1654
- ct as OnBrowserCtx,
1655
- Ze as OnChecked,
1656
- Jt as OnCtx,
1657
- W as OnDispose,
1658
- Zt as OnElement,
1659
- Yt as OnHeadlessCtx,
1660
- q as OneOf,
1661
- we as OneOfField,
1662
- Bt as OneOfKind,
1663
- Ft as OneOfTuple,
1664
- Ut as OneOfType,
1665
- rt as OneOfValue,
1666
- rs as Portal,
1667
- H as Prop,
1668
- ns as Provide,
1669
- os as ProvideGlobalProbe,
1670
- ft as ProvideProbe,
1671
- ce as ProviderNotFoundError,
1672
- at as RenderingError,
1673
- Pe as Repeat,
1941
+ Kt as Async,
1942
+ cs as BindChecked,
1943
+ ns as BindDate,
1944
+ is as BindDateTime,
1945
+ os as BindNumber,
1946
+ ls as BindText,
1947
+ L as BrowserContext,
1948
+ j as CLASS_PLACEHOLDER_ATTR,
1949
+ x as Computed,
1950
+ fs as Conjunction,
1951
+ ms as DOMNode,
1952
+ _e as El,
1953
+ ve as ElNS,
1954
+ N as ElementPosition,
1955
+ _ as Empty,
1956
+ vt as Ensure,
1957
+ ys as EnsureAll,
1958
+ Ss as ForEach,
1959
+ S as Fragment,
1960
+ Ft as HeadlessAdapter,
1961
+ O as HeadlessContext,
1962
+ ct as HeadlessElement,
1963
+ Se as HeadlessPortal,
1964
+ at as HeadlessText,
1965
+ wt as LazyUnless,
1966
+ xe as LazyWhen,
1967
+ _s as MapSignal,
1968
+ le as MemoryStore,
1969
+ vs as NotEmpty,
1970
+ Ct as OnBrowserCtx,
1971
+ mt as OnChecked,
1972
+ gs as OnCtx,
1973
+ Z as OnDispose,
1974
+ As as OnElement,
1975
+ bs as OnHeadlessCtx,
1976
+ z as OneOf,
1977
+ Ce as OneOfField,
1978
+ as as OneOfKind,
1979
+ us as OneOfTuple,
1980
+ hs as OneOfType,
1981
+ At as OneOfValue,
1982
+ Es as Portal,
1983
+ R as Prop,
1984
+ ws as Provide,
1985
+ Ps as ProvideGlobalProbe,
1986
+ Lt as ProvideProbe,
1987
+ pe as ProviderNotFoundError,
1988
+ Ge as RenderingError,
1989
+ Le as Repeat,
1674
1990
  d as Signal,
1675
- me as Task,
1676
- xt as TextNode,
1677
- Xt as Unless,
1678
- Gt as Use,
1679
- ls as UseGlobalProbe,
1680
- dt as UseProbe,
1681
- nt as UseProvider,
1682
- zt as UseProviders,
1683
- p as Value,
1684
- ve as When,
1685
- ht as WithProvider,
1686
- is as WithProviders,
1687
- je as _getSelfOrParentElement,
1688
- le as _isElement,
1689
- Re as _makeGetter,
1690
- Ve as _makeSetter,
1691
- U as _removeDOMNode,
1692
- de as _signalText,
1693
- fe as _staticText,
1694
- St as animateSignal,
1695
- Ie as animateSignals,
1696
- Tt as aria,
1697
- D as attr,
1698
- Ct as dataAttr,
1699
- Lt as emitChecked,
1700
- $t as emitPreventDefault,
1701
- Ht as emitStopImmediatePropagation,
1702
- Nt as emitStopPropagation,
1703
- Ke as emitValue,
1704
- tt as emitValueAsDate,
1705
- st as emitValueAsDateTime,
1706
- et as emitValueAsNumber,
1707
- Le as endInterpolate,
1708
- ee as getWindow,
1709
- $e as guessInterpolate,
1710
- Dt as html,
1711
- Ot as input,
1712
- ke as interpolateDate,
1713
- Ae as interpolateNumber,
1714
- Me as interpolateString,
1715
- _t as localStorageProp,
1716
- G as makeComputed,
1717
- yt as makeComputedOf,
1718
- Pt as makeComputedRecord,
1719
- He as makeEffect,
1720
- wt as makeEffectOf,
1721
- I as makeProp,
1722
- ut as makeProviderMark,
1723
- R as makeSignal,
1724
- Mt as math,
1725
- Et as mathAttr,
1726
- j as on,
1727
- Ce as probeMarker,
1728
- ts as render,
1729
- z as renderWithContext,
1730
- u as renderableOfTNode,
1731
- ss as runHeadless,
1732
- vt as sessionStorageProp,
1733
- se as storedProp,
1734
- cs as style,
1735
- At as svg,
1736
- bt as svgAttr
1991
+ Ee as Task,
1992
+ Ut as TextNode,
1993
+ Ts as Unless,
1994
+ ds as Use,
1995
+ xs as UseGlobalProbe,
1996
+ Ot as UseProbe,
1997
+ _t as UseProvider,
1998
+ ps as UseProviders,
1999
+ y as Value,
2000
+ Et as When,
2001
+ xt as WithProvider,
2002
+ Cs as WithProviders,
2003
+ ge as _NODE_PLACEHOLDER_ATTR,
2004
+ Je as _getSelfOrParentElement,
2005
+ de as _isElement,
2006
+ We as _makeGetter,
2007
+ Ue as _makeSetter,
2008
+ V as _removeDOMNode,
2009
+ Ae as _signalText,
2010
+ be as _staticText,
2011
+ Rt as animateSignal,
2012
+ Be as animateSignals,
2013
+ Jt as aria,
2014
+ M as attr,
2015
+ Wt as dataAttr,
2016
+ es as emitChecked,
2017
+ ts as emitPreventDefault,
2018
+ rs as emitStopImmediatePropagation,
2019
+ ss as emitStopPropagation,
2020
+ yt as emitValue,
2021
+ St as emitValueAsDate,
2022
+ bt as emitValueAsDateTime,
2023
+ Tt as emitValueAsNumber,
2024
+ Ve as endInterpolate,
2025
+ oe as getWindow,
2026
+ je as guessInterpolate,
2027
+ Xt as html,
2028
+ Yt as input,
2029
+ Re as interpolateDate,
2030
+ Ie as interpolateNumber,
2031
+ Ne as interpolateString,
2032
+ It as localStorageProp,
2033
+ Y as makeComputed,
2034
+ $t as makeComputedOf,
2035
+ Vt as makeComputedRecord,
2036
+ Fe as makeEffect,
2037
+ kt as makeEffectOf,
2038
+ E as makeProp,
2039
+ Pt as makeProviderMark,
2040
+ J as makeSignal,
2041
+ Zt as math,
2042
+ zt as mathAttr,
2043
+ G as on,
2044
+ De as probeMarker,
2045
+ jt as render,
2046
+ Q as renderWithContext,
2047
+ f as renderableOfTNode,
2048
+ Bt as restoreTempoPlaceholders,
2049
+ qt as runHeadless,
2050
+ Nt as sessionStorageProp,
2051
+ ce as storedProp,
2052
+ Ls as style,
2053
+ Qt as svg,
2054
+ Gt as svgAttr
1737
2055
  };