@tempots/dom 24.0.0-next.9 → 25.1.0

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