@hintergrund/ui 0.1.14 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3333 +0,0 @@
1
- typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
2
- return Promise.resolve().then(e);
3
- } });
4
- const Jn = "5";
5
- typeof window < "u" && ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add(Jn);
6
- const $s = 1, Es = 2, Ts = 4, Ss = 8, ks = 16, As = 1, Ns = 2, xs = 4, Rs = 8, Os = 16, Ms = 1, Cs = 2, Is = 4, Xn = 1, Zn = 2, Wt = "[", Kt = "[!", Pt = "[?", Jt = "]", Se = {}, T = /* @__PURE__ */ Symbol(), Xt = "http://www.w3.org/1999/xhtml", Ps = "http://www.w3.org/2000/svg", Ls = "http://www.w3.org/1998/Math/MathML", Qn = !1;
7
- var er = Array.isArray, tr = Array.prototype.indexOf, ke = Array.prototype.includes, nr = Array.from, Ke = Object.keys, Le = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, Zt = Object.getOwnPropertyDescriptors, rr = Object.prototype, sr = Array.prototype, Tt = Object.getPrototypeOf, Lt = Object.isExtensible;
8
- function Ds(e) {
9
- return typeof e == "function";
10
- }
11
- const _e = () => {
12
- };
13
- function Fs(e) {
14
- return e();
15
- }
16
- function ir(e) {
17
- for (var t = 0; t < e.length; t++)
18
- e[t]();
19
- }
20
- function Qt() {
21
- var e, t, n = new Promise((r, s) => {
22
- e = r, t = s;
23
- });
24
- return { promise: n, resolve: e, reject: t };
25
- }
26
- function js(e, t) {
27
- if (Array.isArray(e))
28
- return e;
29
- if (!(Symbol.iterator in e))
30
- return Array.from(e);
31
- const n = [];
32
- for (const r of e)
33
- if (n.push(r), n.length === t) break;
34
- return n;
35
- }
36
- const A = 2, Ae = 4, je = 8, en = 1 << 24, z = 16, J = 32, ee = 64, ct = 128, I = 512, E = 1024, S = 2048, V = 4096, P = 8192, B = 16384, oe = 32768, Dt = 1 << 25, Ne = 65536, ht = 1 << 17, ar = 1 << 18, me = 1 << 19, tn = 1 << 20, Hs = 1 << 25, ge = 65536, Je = 1 << 21, De = 1 << 22, fe = 1 << 23, ve = /* @__PURE__ */ Symbol("$state"), fr = /* @__PURE__ */ Symbol("legacy props"), lr = /* @__PURE__ */ Symbol(""), Q = new class extends Error {
37
- name = "StaleReactionError";
38
- message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
39
- }(), nn = (
40
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
41
- !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml")
42
- ), He = 3, Qe = 8;
43
- function or(e) {
44
- throw new Error("https://svelte.dev/e/lifecycle_outside_component");
45
- }
46
- function ur() {
47
- throw new Error("https://svelte.dev/e/async_derived_orphan");
48
- }
49
- function Bs(e, t, n) {
50
- throw new Error("https://svelte.dev/e/each_key_duplicate");
51
- }
52
- function cr(e) {
53
- throw new Error("https://svelte.dev/e/effect_in_teardown");
54
- }
55
- function hr() {
56
- throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
57
- }
58
- function dr(e) {
59
- throw new Error("https://svelte.dev/e/effect_orphan");
60
- }
61
- function _r() {
62
- throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
63
- }
64
- function vr() {
65
- throw new Error("https://svelte.dev/e/hydration_failed");
66
- }
67
- function Vs(e) {
68
- throw new Error("https://svelte.dev/e/props_invalid_value");
69
- }
70
- function pr() {
71
- throw new Error("https://svelte.dev/e/state_descriptors_fixed");
72
- }
73
- function br() {
74
- throw new Error("https://svelte.dev/e/state_prototype_fixed");
75
- }
76
- function gr() {
77
- throw new Error("https://svelte.dev/e/state_unsafe_mutation");
78
- }
79
- function yr() {
80
- throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
81
- }
82
- function mr() {
83
- console.warn("https://svelte.dev/e/derived_inert");
84
- }
85
- function et(e) {
86
- console.warn("https://svelte.dev/e/hydration_mismatch");
87
- }
88
- function Us() {
89
- console.warn("https://svelte.dev/e/select_multiple_invalid_value");
90
- }
91
- function wr() {
92
- console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
93
- }
94
- let g = !1;
95
- function ie(e) {
96
- g = e;
97
- }
98
- let y;
99
- function D(e) {
100
- if (e === null)
101
- throw et(), Se;
102
- return y = e;
103
- }
104
- function St() {
105
- return D(/* @__PURE__ */ re(y));
106
- }
107
- function Ys(e) {
108
- if (g) {
109
- if (/* @__PURE__ */ re(y) !== null)
110
- throw et(), Se;
111
- y = e;
112
- }
113
- }
114
- function $r(e = 1) {
115
- if (g) {
116
- for (var t = e, n = y; t--; )
117
- n = /** @type {TemplateNode} */
118
- /* @__PURE__ */ re(n);
119
- y = n;
120
- }
121
- }
122
- function rn(e = !0) {
123
- for (var t = 0, n = y; ; ) {
124
- if (n.nodeType === Qe) {
125
- var r = (
126
- /** @type {Comment} */
127
- n.data
128
- );
129
- if (r === Jt) {
130
- if (t === 0) return n;
131
- t -= 1;
132
- } else (r === Wt || r === Kt || // "[1", "[2", etc. for if blocks
133
- r[0] === "[" && !isNaN(Number(r.slice(1)))) && (t += 1);
134
- }
135
- var s = (
136
- /** @type {TemplateNode} */
137
- /* @__PURE__ */ re(n)
138
- );
139
- e && n.remove(), n = s;
140
- }
141
- }
142
- function Er(e) {
143
- if (!e || e.nodeType !== Qe)
144
- throw et(), Se;
145
- return (
146
- /** @type {Comment} */
147
- e.data
148
- );
149
- }
150
- function sn(e) {
151
- return e === this.v;
152
- }
153
- function an(e, t) {
154
- return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
155
- }
156
- function fn(e) {
157
- return !an(e, this.v);
158
- }
159
- let tt = !1, Tr = !1;
160
- function Gs() {
161
- tt = !0;
162
- }
163
- let $ = null;
164
- function xe(e) {
165
- $ = e;
166
- }
167
- function zs(e) {
168
- return (
169
- /** @type {T} */
170
- ln().get(e)
171
- );
172
- }
173
- function Ws(e, t) {
174
- return ln().set(e, t), t;
175
- }
176
- function Sr(e, t = !1, n) {
177
- $ = {
178
- p: $,
179
- i: !1,
180
- c: null,
181
- e: null,
182
- s: e,
183
- x: null,
184
- r: (
185
- /** @type {Effect} */
186
- _
187
- ),
188
- l: tt && !t ? { s: null, u: null, $: [] } : null
189
- };
190
- }
191
- function kr(e) {
192
- var t = (
193
- /** @type {ComponentContext} */
194
- $
195
- ), n = t.e;
196
- if (n !== null) {
197
- t.e = null;
198
- for (var r of n)
199
- Rn(r);
200
- }
201
- return e !== void 0 && (t.x = e), t.i = !0, $ = t.p, e ?? /** @type {T} */
202
- {};
203
- }
204
- function qe() {
205
- return !tt || $ !== null && $.l === null;
206
- }
207
- function ln(e) {
208
- return $ === null && or(), $.c ??= new Map(Ar($) || void 0);
209
- }
210
- function Ar(e) {
211
- let t = e.p;
212
- for (; t !== null; ) {
213
- const n = t.c;
214
- if (n !== null)
215
- return n;
216
- t = t.p;
217
- }
218
- return null;
219
- }
220
- let he = [];
221
- function on() {
222
- var e = he;
223
- he = [], ir(e);
224
- }
225
- function W(e) {
226
- if (he.length === 0 && !Ce) {
227
- var t = he;
228
- queueMicrotask(() => {
229
- t === he && on();
230
- });
231
- }
232
- he.push(e);
233
- }
234
- function Nr() {
235
- for (; he.length > 0; )
236
- on();
237
- }
238
- function un(e) {
239
- var t = _;
240
- if (t === null)
241
- return b.f |= fe, e;
242
- if ((t.f & oe) === 0 && (t.f & Ae) === 0)
243
- throw e;
244
- ae(e, t);
245
- }
246
- function ae(e, t) {
247
- for (; t !== null; ) {
248
- if ((t.f & ct) !== 0) {
249
- if ((t.f & oe) === 0)
250
- throw e;
251
- try {
252
- t.b.error(e);
253
- return;
254
- } catch (n) {
255
- e = n;
256
- }
257
- }
258
- t = t.parent;
259
- }
260
- throw e;
261
- }
262
- const xr = -7169;
263
- function w(e, t) {
264
- e.f = e.f & xr | t;
265
- }
266
- function kt(e) {
267
- (e.f & I) !== 0 || e.deps === null ? w(e, E) : w(e, V);
268
- }
269
- function cn(e) {
270
- if (e !== null)
271
- for (const t of e)
272
- (t.f & A) === 0 || (t.f & ge) === 0 || (t.f ^= ge, cn(
273
- /** @type {Derived} */
274
- t.deps
275
- ));
276
- }
277
- function hn(e, t, n) {
278
- (e.f & S) !== 0 ? t.add(e) : (e.f & V) !== 0 && n.add(e), cn(e.deps), w(e, E);
279
- }
280
- function dn(e, t, n) {
281
- if (e == null)
282
- return t(void 0), _e;
283
- const r = Ve(
284
- () => e.subscribe(
285
- t,
286
- // @ts-expect-error
287
- n
288
- )
289
- );
290
- return r.unsubscribe ? () => r.unsubscribe() : r;
291
- }
292
- const $e = [];
293
- function Ks(e, t) {
294
- return {
295
- subscribe: Rr(e, t).subscribe
296
- };
297
- }
298
- function Rr(e, t = _e) {
299
- let n = null;
300
- const r = /* @__PURE__ */ new Set();
301
- function s(a) {
302
- if (an(e, a) && (e = a, n)) {
303
- const l = !$e.length;
304
- for (const o of r)
305
- o[1](), $e.push(o, e);
306
- if (l) {
307
- for (let o = 0; o < $e.length; o += 2)
308
- $e[o][0]($e[o + 1]);
309
- $e.length = 0;
310
- }
311
- }
312
- }
313
- function i(a) {
314
- s(a(
315
- /** @type {T} */
316
- e
317
- ));
318
- }
319
- function f(a, l = _e) {
320
- const o = [a, l];
321
- return r.add(o), r.size === 1 && (n = t(s, i) || _e), a(
322
- /** @type {T} */
323
- e
324
- ), () => {
325
- r.delete(o), r.size === 0 && n && (n(), n = null);
326
- };
327
- }
328
- return { set: s, update: i, subscribe: f };
329
- }
330
- function Or(e) {
331
- let t;
332
- return dn(e, (n) => t = n)(), t;
333
- }
334
- let dt = !1, Ue = !1, _t = /* @__PURE__ */ Symbol();
335
- function Js(e, t, n) {
336
- const r = n[t] ??= {
337
- store: null,
338
- source: /* @__PURE__ */ $n(void 0),
339
- unsubscribe: _e
340
- };
341
- if (r.store !== e && !(_t in n))
342
- if (r.unsubscribe(), r.store = e ?? null, e == null)
343
- r.source.v = void 0, r.unsubscribe = _e;
344
- else {
345
- var s = !0;
346
- r.unsubscribe = dn(e, (i) => {
347
- s ? r.source.v = i : G(r.source, i);
348
- }), s = !1;
349
- }
350
- return e && _t in n ? Or(e) : q(r.source);
351
- }
352
- function Xs(e, t) {
353
- return Mr(e, t), t;
354
- }
355
- function Zs() {
356
- const e = {};
357
- function t() {
358
- it(() => {
359
- for (var n in e)
360
- e[n].unsubscribe();
361
- Le(e, _t, {
362
- enumerable: !1,
363
- value: !0
364
- });
365
- });
366
- }
367
- return [e, t];
368
- }
369
- function Mr(e, t) {
370
- dt = !0;
371
- try {
372
- e.set(t);
373
- } finally {
374
- dt = !1;
375
- }
376
- }
377
- function Qs(e) {
378
- var t = Ue;
379
- try {
380
- return Ue = !1, [e(), Ue];
381
- } finally {
382
- Ue = t;
383
- }
384
- }
385
- const ce = /* @__PURE__ */ new Set();
386
- let p = null, j = null, vt = null, Ce = !1, ft = !1, Ee = null, Ge = null;
387
- var Ft = 0;
388
- let Cr = 1;
389
- class te {
390
- id = Cr++;
391
- /**
392
- * The current values of any signals that are updated in this batch.
393
- * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
394
- * They keys of this map are identical to `this.#previous`
395
- * @type {Map<Value, [any, boolean]>}
396
- */
397
- current = /* @__PURE__ */ new Map();
398
- /**
399
- * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
400
- * They keys of this map are identical to `this.#current`
401
- * @type {Map<Value, any>}
402
- */
403
- previous = /* @__PURE__ */ new Map();
404
- /**
405
- * When the batch is committed (and the DOM is updated), we need to remove old branches
406
- * and append new ones by calling the functions added inside (if/each/key/etc) blocks
407
- * @type {Set<(batch: Batch) => void>}
408
- */
409
- #e = /* @__PURE__ */ new Set();
410
- /**
411
- * If a fork is discarded, we need to destroy any effects that are no longer needed
412
- * @type {Set<(batch: Batch) => void>}
413
- */
414
- #r = /* @__PURE__ */ new Set();
415
- /**
416
- * Callbacks that should run only when a fork is committed.
417
- * @type {Set<(batch: Batch) => void>}
418
- */
419
- #t = /* @__PURE__ */ new Set();
420
- /**
421
- * Async effects that are currently in flight
422
- * @type {Map<Effect, number>}
423
- */
424
- #i = /* @__PURE__ */ new Map();
425
- /**
426
- * Async effects that are currently in flight, _not_ inside a pending boundary
427
- * @type {Map<Effect, number>}
428
- */
429
- #s = /* @__PURE__ */ new Map();
430
- /**
431
- * A deferred that resolves when the batch is committed, used with `settled()`
432
- * TODO replace with Promise.withResolvers once supported widely enough
433
- * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
434
- */
435
- #a = null;
436
- /**
437
- * The root effects that need to be flushed
438
- * @type {Effect[]}
439
- */
440
- #n = [];
441
- /**
442
- * Effects created while this batch was active.
443
- * @type {Effect[]}
444
- */
445
- #f = [];
446
- /**
447
- * Deferred effects (which run after async work has completed) that are DIRTY
448
- * @type {Set<Effect>}
449
- */
450
- #o = /* @__PURE__ */ new Set();
451
- /**
452
- * Deferred effects that are MAYBE_DIRTY
453
- * @type {Set<Effect>}
454
- */
455
- #u = /* @__PURE__ */ new Set();
456
- /**
457
- * A map of branches that still exist, but will be destroyed when this batch
458
- * is committed — we skip over these during `process`.
459
- * The value contains child effects that were dirty/maybe_dirty before being reset,
460
- * so they can be rescheduled if the branch survives.
461
- * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
462
- */
463
- #l = /* @__PURE__ */ new Map();
464
- /**
465
- * Inverse of #skipped_branches which we need to tell prior batches to unskip them when committing
466
- * @type {Set<Effect>}
467
- */
468
- #h = /* @__PURE__ */ new Set();
469
- is_fork = !1;
470
- #_ = !1;
471
- /** @type {Set<Batch>} */
472
- #d = /* @__PURE__ */ new Set();
473
- #c() {
474
- return this.is_fork || this.#s.size > 0;
475
- }
476
- #g() {
477
- for (const r of this.#d)
478
- for (const s of r.#s.keys()) {
479
- for (var t = !1, n = s; n.parent !== null; ) {
480
- if (this.#l.has(n)) {
481
- t = !0;
482
- break;
483
- }
484
- n = n.parent;
485
- }
486
- if (!t)
487
- return !0;
488
- }
489
- return !1;
490
- }
491
- /**
492
- * Add an effect to the #skipped_branches map and reset its children
493
- * @param {Effect} effect
494
- */
495
- skip_effect(t) {
496
- this.#l.has(t) || this.#l.set(t, { d: [], m: [] }), this.#h.delete(t);
497
- }
498
- /**
499
- * Remove an effect from the #skipped_branches map and reschedule
500
- * any tracked dirty/maybe_dirty child effects
501
- * @param {Effect} effect
502
- * @param {(e: Effect) => void} callback
503
- */
504
- unskip_effect(t, n = (r) => this.schedule(r)) {
505
- var r = this.#l.get(t);
506
- if (r) {
507
- this.#l.delete(t);
508
- for (var s of r.d)
509
- w(s, S), n(s);
510
- for (s of r.m)
511
- w(s, V), n(s);
512
- }
513
- this.#h.add(t);
514
- }
515
- #v() {
516
- if (Ft++ > 1e3 && (ce.delete(this), Ir()), !this.#c()) {
517
- for (const a of this.#o)
518
- this.#u.delete(a), w(a, S), this.schedule(a);
519
- for (const a of this.#u)
520
- w(a, V), this.schedule(a);
521
- }
522
- const t = this.#n;
523
- this.#n = [], this.apply();
524
- var n = Ee = [], r = [], s = Ge = [];
525
- for (const a of t)
526
- try {
527
- this.#b(a, n, r);
528
- } catch (l) {
529
- throw bn(a), l;
530
- }
531
- if (p = null, s.length > 0) {
532
- var i = te.ensure();
533
- for (const a of s)
534
- i.schedule(a);
535
- }
536
- if (Ee = null, Ge = null, this.#c() || this.#g()) {
537
- this.#p(r), this.#p(n);
538
- for (const [a, l] of this.#l)
539
- pn(a, l);
540
- } else {
541
- this.#i.size === 0 && ce.delete(this), this.#o.clear(), this.#u.clear();
542
- for (const a of this.#e) a(this);
543
- this.#e.clear(), jt(r), jt(n), this.#a?.resolve();
544
- }
545
- var f = (
546
- /** @type {Batch | null} */
547
- /** @type {unknown} */
548
- p
549
- );
550
- if (this.#n.length > 0) {
551
- const a = f ??= this;
552
- a.#n.push(...this.#n.filter((l) => !a.#n.includes(l)));
553
- }
554
- f !== null && (ce.add(f), f.#v());
555
- }
556
- /**
557
- * Traverse the effect tree, executing effects or stashing
558
- * them for later execution as appropriate
559
- * @param {Effect} root
560
- * @param {Effect[]} effects
561
- * @param {Effect[]} render_effects
562
- */
563
- #b(t, n, r) {
564
- t.f ^= E;
565
- for (var s = t.first; s !== null; ) {
566
- var i = s.f, f = (i & (J | ee)) !== 0, a = f && (i & E) !== 0, l = a || (i & P) !== 0 || this.#l.has(s);
567
- if (!l && s.fn !== null) {
568
- f ? s.f ^= E : (i & Ae) !== 0 ? n.push(s) : Re(s) && ((i & z) !== 0 && this.#u.add(s), ye(s));
569
- var o = s.first;
570
- if (o !== null) {
571
- s = o;
572
- continue;
573
- }
574
- }
575
- for (; s !== null; ) {
576
- var u = s.next;
577
- if (u !== null) {
578
- s = u;
579
- break;
580
- }
581
- s = s.parent;
582
- }
583
- }
584
- }
585
- /**
586
- * @param {Effect[]} effects
587
- */
588
- #p(t) {
589
- for (var n = 0; n < t.length; n += 1)
590
- hn(t[n], this.#o, this.#u);
591
- }
592
- /**
593
- * Associate a change to a given source with the current
594
- * batch, noting its previous and current values
595
- * @param {Value} source
596
- * @param {any} value
597
- * @param {boolean} [is_derived]
598
- */
599
- capture(t, n, r = !1) {
600
- t.v !== T && !this.previous.has(t) && this.previous.set(t, t.v), (t.f & fe) === 0 && (this.current.set(t, [n, r]), j?.set(t, n)), this.is_fork || (t.v = n);
601
- }
602
- activate() {
603
- p = this;
604
- }
605
- deactivate() {
606
- p = null, j = null;
607
- }
608
- flush() {
609
- try {
610
- ft = !0, p = this, this.#v();
611
- } finally {
612
- Ft = 0, vt = null, Ee = null, Ge = null, ft = !1, p = null, j = null, pe.clear();
613
- }
614
- }
615
- discard() {
616
- for (const t of this.#r) t(this);
617
- this.#r.clear(), this.#t.clear(), ce.delete(this);
618
- }
619
- /**
620
- * @param {Effect} effect
621
- */
622
- register_created_effect(t) {
623
- this.#f.push(t);
624
- }
625
- #y() {
626
- for (const u of ce) {
627
- var t = u.id < this.id, n = [];
628
- for (const [c, [h, v]] of this.current) {
629
- if (u.current.has(c)) {
630
- var r = (
631
- /** @type {[any, boolean]} */
632
- u.current.get(c)[0]
633
- );
634
- if (t && h !== r)
635
- u.current.set(c, [h, v]);
636
- else
637
- continue;
638
- }
639
- n.push(c);
640
- }
641
- var s = [...u.current.keys()].filter((c) => !this.current.has(c));
642
- if (s.length === 0)
643
- t && u.discard();
644
- else if (n.length > 0) {
645
- if (t)
646
- for (const c of this.#h)
647
- u.unskip_effect(c, (h) => {
648
- (h.f & (z | De)) !== 0 ? u.schedule(h) : u.#p([h]);
649
- });
650
- u.activate();
651
- var i = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map();
652
- for (var a of n)
653
- vn(a, s, i, f);
654
- f = /* @__PURE__ */ new Map();
655
- var l = [...u.current.keys()].filter(
656
- (c) => this.current.has(c) ? (
657
- /** @type {[any, boolean]} */
658
- this.current.get(c)[0] !== c
659
- ) : !0
660
- );
661
- for (const c of this.#f)
662
- (c.f & (B | P | ht)) === 0 && At(c, l, f) && ((c.f & (De | z)) !== 0 ? (w(c, S), u.schedule(c)) : u.#o.add(c));
663
- if (u.#n.length > 0) {
664
- u.apply();
665
- for (var o of u.#n)
666
- u.#b(o, [], []);
667
- u.#n = [];
668
- }
669
- u.deactivate();
670
- }
671
- }
672
- for (const u of ce)
673
- u.#d.has(this) && (u.#d.delete(this), u.#d.size === 0 && !u.#c() && (u.activate(), u.#v()));
674
- }
675
- /**
676
- * @param {boolean} blocking
677
- * @param {Effect} effect
678
- */
679
- increment(t, n) {
680
- let r = this.#i.get(n) ?? 0;
681
- if (this.#i.set(n, r + 1), t) {
682
- let s = this.#s.get(n) ?? 0;
683
- this.#s.set(n, s + 1);
684
- }
685
- }
686
- /**
687
- * @param {boolean} blocking
688
- * @param {Effect} effect
689
- * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
690
- */
691
- decrement(t, n, r) {
692
- let s = this.#i.get(n) ?? 0;
693
- if (s === 1 ? this.#i.delete(n) : this.#i.set(n, s - 1), t) {
694
- let i = this.#s.get(n) ?? 0;
695
- i === 1 ? this.#s.delete(n) : this.#s.set(n, i - 1);
696
- }
697
- this.#_ || r || (this.#_ = !0, W(() => {
698
- this.#_ = !1, this.flush();
699
- }));
700
- }
701
- /**
702
- * @param {Set<Effect>} dirty_effects
703
- * @param {Set<Effect>} maybe_dirty_effects
704
- */
705
- transfer_effects(t, n) {
706
- for (const r of t)
707
- this.#o.add(r);
708
- for (const r of n)
709
- this.#u.add(r);
710
- t.clear(), n.clear();
711
- }
712
- /** @param {(batch: Batch) => void} fn */
713
- oncommit(t) {
714
- this.#e.add(t);
715
- }
716
- /** @param {(batch: Batch) => void} fn */
717
- ondiscard(t) {
718
- this.#r.add(t);
719
- }
720
- /** @param {(batch: Batch) => void} fn */
721
- on_fork_commit(t) {
722
- this.#t.add(t);
723
- }
724
- run_fork_commit_callbacks() {
725
- for (const t of this.#t) t(this);
726
- this.#t.clear();
727
- }
728
- settled() {
729
- return (this.#a ??= Qt()).promise;
730
- }
731
- static ensure() {
732
- if (p === null) {
733
- const t = p = new te();
734
- ft || (ce.add(p), Ce || W(() => {
735
- p === t && t.flush();
736
- }));
737
- }
738
- return p;
739
- }
740
- apply() {
741
- {
742
- j = null;
743
- return;
744
- }
745
- }
746
- /**
747
- *
748
- * @param {Effect} effect
749
- */
750
- schedule(t) {
751
- if (vt = t, t.b?.is_pending && (t.f & (Ae | je | en)) !== 0 && (t.f & oe) === 0) {
752
- t.b.defer_effect(t);
753
- return;
754
- }
755
- for (var n = t; n.parent !== null; ) {
756
- n = n.parent;
757
- var r = n.f;
758
- if (Ee !== null && n === _ && (b === null || (b.f & A) === 0) && !dt)
759
- return;
760
- if ((r & (ee | J)) !== 0) {
761
- if ((r & E) === 0)
762
- return;
763
- n.f ^= E;
764
- }
765
- }
766
- this.#n.push(n);
767
- }
768
- }
769
- function _n(e) {
770
- var t = Ce;
771
- Ce = !0;
772
- try {
773
- for (var n; ; ) {
774
- if (Nr(), p === null)
775
- return (
776
- /** @type {T} */
777
- n
778
- );
779
- p.flush();
780
- }
781
- } finally {
782
- Ce = t;
783
- }
784
- }
785
- function Ir() {
786
- try {
787
- _r();
788
- } catch (e) {
789
- ae(e, vt);
790
- }
791
- }
792
- let X = null;
793
- function jt(e) {
794
- var t = e.length;
795
- if (t !== 0) {
796
- for (var n = 0; n < t; ) {
797
- var r = e[n++];
798
- if ((r.f & (B | P)) === 0 && Re(r) && (X = /* @__PURE__ */ new Set(), ye(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Cn(r), X?.size > 0)) {
799
- pe.clear();
800
- for (const s of X) {
801
- if ((s.f & (B | P)) !== 0) continue;
802
- const i = [s];
803
- let f = s.parent;
804
- for (; f !== null; )
805
- X.has(f) && (X.delete(f), i.push(f)), f = f.parent;
806
- for (let a = i.length - 1; a >= 0; a--) {
807
- const l = i[a];
808
- (l.f & (B | P)) === 0 && ye(l);
809
- }
810
- }
811
- X.clear();
812
- }
813
- }
814
- X = null;
815
- }
816
- }
817
- function vn(e, t, n, r) {
818
- if (!n.has(e) && (n.add(e), e.reactions !== null))
819
- for (const s of e.reactions) {
820
- const i = s.f;
821
- (i & A) !== 0 ? vn(
822
- /** @type {Derived} */
823
- s,
824
- t,
825
- n,
826
- r
827
- ) : (i & (De | z)) !== 0 && (i & S) === 0 && At(s, t, r) && (w(s, S), Nt(
828
- /** @type {Effect} */
829
- s
830
- ));
831
- }
832
- }
833
- function At(e, t, n) {
834
- const r = n.get(e);
835
- if (r !== void 0) return r;
836
- if (e.deps !== null)
837
- for (const s of e.deps) {
838
- if (ke.call(t, s))
839
- return !0;
840
- if ((s.f & A) !== 0 && At(
841
- /** @type {Derived} */
842
- s,
843
- t,
844
- n
845
- ))
846
- return n.set(
847
- /** @type {Derived} */
848
- s,
849
- !0
850
- ), !0;
851
- }
852
- return n.set(e, !1), !1;
853
- }
854
- function Nt(e) {
855
- p.schedule(e);
856
- }
857
- function pn(e, t) {
858
- if (!((e.f & J) !== 0 && (e.f & E) !== 0)) {
859
- (e.f & S) !== 0 ? t.d.push(e) : (e.f & V) !== 0 && t.m.push(e), w(e, E);
860
- for (var n = e.first; n !== null; )
861
- pn(n, t), n = n.next;
862
- }
863
- }
864
- function bn(e) {
865
- w(e, E);
866
- for (var t = e.first; t !== null; )
867
- bn(t), t = t.next;
868
- }
869
- function Pr(e) {
870
- let t = 0, n = Be(0), r;
871
- return () => {
872
- Mt() && (q(n), ue(() => (t === 0 && (r = Ve(() => e(() => Ie(n)))), t += 1, () => {
873
- W(() => {
874
- t -= 1, t === 0 && (r?.(), r = void 0, Ie(n));
875
- });
876
- })));
877
- };
878
- }
879
- var Lr = Ne | me;
880
- function Dr(e, t, n, r) {
881
- new Fr(e, t, n, r);
882
- }
883
- class Fr {
884
- /** @type {Boundary | null} */
885
- parent;
886
- is_pending = !1;
887
- /**
888
- * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
889
- * Inherited from parent boundary, or defaults to identity.
890
- * @type {(error: unknown) => unknown}
891
- */
892
- transform_error;
893
- /** @type {TemplateNode} */
894
- #e;
895
- /** @type {TemplateNode | null} */
896
- #r = g ? y : null;
897
- /** @type {BoundaryProps} */
898
- #t;
899
- /** @type {((anchor: Node) => void)} */
900
- #i;
901
- /** @type {Effect} */
902
- #s;
903
- /** @type {Effect | null} */
904
- #a = null;
905
- /** @type {Effect | null} */
906
- #n = null;
907
- /** @type {Effect | null} */
908
- #f = null;
909
- /** @type {DocumentFragment | null} */
910
- #o = null;
911
- #u = 0;
912
- #l = 0;
913
- #h = !1;
914
- /** @type {Set<Effect>} */
915
- #_ = /* @__PURE__ */ new Set();
916
- /** @type {Set<Effect>} */
917
- #d = /* @__PURE__ */ new Set();
918
- /**
919
- * A source containing the number of pending async deriveds/expressions.
920
- * Only created if `$effect.pending()` is used inside the boundary,
921
- * otherwise updating the source results in needless `Batch.ensure()`
922
- * calls followed by no-op flushes
923
- * @type {Source<number> | null}
924
- */
925
- #c = null;
926
- #g = Pr(() => (this.#c = Be(this.#u), () => {
927
- this.#c = null;
928
- }));
929
- /**
930
- * @param {TemplateNode} node
931
- * @param {BoundaryProps} props
932
- * @param {((anchor: Node) => void)} children
933
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
934
- */
935
- constructor(t, n, r, s) {
936
- this.#e = t, this.#t = n, this.#i = (i) => {
937
- var f = (
938
- /** @type {Effect} */
939
- _
940
- );
941
- f.b = this, f.f |= ct, r(i);
942
- }, this.parent = /** @type {Effect} */
943
- _.b, this.transform_error = s ?? this.parent?.transform_error ?? ((i) => i), this.#s = On(() => {
944
- if (g) {
945
- const i = (
946
- /** @type {Comment} */
947
- this.#r
948
- );
949
- St();
950
- const f = i.data === Kt;
951
- if (i.data.startsWith(Pt)) {
952
- const l = JSON.parse(i.data.slice(Pt.length));
953
- this.#b(l);
954
- } else f ? this.#p() : this.#v();
955
- } else
956
- this.#y();
957
- }, Lr), g && (this.#e = y);
958
- }
959
- #v() {
960
- try {
961
- this.#a = Z(() => this.#i(this.#e));
962
- } catch (t) {
963
- this.error(t);
964
- }
965
- }
966
- /**
967
- * @param {unknown} error The deserialized error from the server's hydration comment
968
- */
969
- #b(t) {
970
- const n = this.#t.failed;
971
- n && (this.#f = Z(() => {
972
- n(
973
- this.#e,
974
- () => t,
975
- () => () => {
976
- }
977
- );
978
- }));
979
- }
980
- #p() {
981
- const t = this.#t.pending;
982
- t && (this.is_pending = !0, this.#n = Z(() => t(this.#e)), W(() => {
983
- var n = this.#o = document.createDocumentFragment(), r = U();
984
- n.append(r), this.#a = this.#w(() => Z(() => this.#i(r))), this.#l === 0 && (this.#e.before(n), this.#o = null, Pe(
985
- /** @type {Effect} */
986
- this.#n,
987
- () => {
988
- this.#n = null;
989
- }
990
- ), this.#m(
991
- /** @type {Batch} */
992
- p
993
- ));
994
- }));
995
- }
996
- #y() {
997
- try {
998
- if (this.is_pending = this.has_pending_snippet(), this.#l = 0, this.#u = 0, this.#a = Z(() => {
999
- this.#i(this.#e);
1000
- }), this.#l > 0) {
1001
- var t = this.#o = document.createDocumentFragment();
1002
- Ln(this.#a, t);
1003
- const n = (
1004
- /** @type {(anchor: Node) => void} */
1005
- this.#t.pending
1006
- );
1007
- this.#n = Z(() => n(this.#e));
1008
- } else
1009
- this.#m(
1010
- /** @type {Batch} */
1011
- p
1012
- );
1013
- } catch (n) {
1014
- this.error(n);
1015
- }
1016
- }
1017
- /**
1018
- * @param {Batch} batch
1019
- */
1020
- #m(t) {
1021
- this.is_pending = !1, t.transfer_effects(this.#_, this.#d);
1022
- }
1023
- /**
1024
- * Defer an effect inside a pending boundary until the boundary resolves
1025
- * @param {Effect} effect
1026
- */
1027
- defer_effect(t) {
1028
- hn(t, this.#_, this.#d);
1029
- }
1030
- /**
1031
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1032
- * @returns {boolean}
1033
- */
1034
- is_rendered() {
1035
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
1036
- }
1037
- has_pending_snippet() {
1038
- return !!this.#t.pending;
1039
- }
1040
- /**
1041
- * @template T
1042
- * @param {() => T} fn
1043
- */
1044
- #w(t) {
1045
- var n = _, r = b, s = $;
1046
- O(this.#s), R(this.#s), xe(this.#s.ctx);
1047
- try {
1048
- return te.ensure(), t();
1049
- } catch (i) {
1050
- return un(i), null;
1051
- } finally {
1052
- O(n), R(r), xe(s);
1053
- }
1054
- }
1055
- /**
1056
- * Updates the pending count associated with the currently visible pending snippet,
1057
- * if any, such that we can replace the snippet with content once work is done
1058
- * @param {1 | -1} d
1059
- * @param {Batch} batch
1060
- */
1061
- #$(t, n) {
1062
- if (!this.has_pending_snippet()) {
1063
- this.parent && this.parent.#$(t, n);
1064
- return;
1065
- }
1066
- this.#l += t, this.#l === 0 && (this.#m(n), this.#n && Pe(this.#n, () => {
1067
- this.#n = null;
1068
- }), this.#o && (this.#e.before(this.#o), this.#o = null));
1069
- }
1070
- /**
1071
- * Update the source that powers `$effect.pending()` inside this boundary,
1072
- * and controls when the current `pending` snippet (if any) is removed.
1073
- * Do not call from inside the class
1074
- * @param {1 | -1} d
1075
- * @param {Batch} batch
1076
- */
1077
- update_pending_count(t, n) {
1078
- this.#$(t, n), this.#u += t, !(!this.#c || this.#h) && (this.#h = !0, W(() => {
1079
- this.#h = !1, this.#c && Ze(this.#c, this.#u);
1080
- }));
1081
- }
1082
- get_effect_pending() {
1083
- return this.#g(), q(
1084
- /** @type {Source<number>} */
1085
- this.#c
1086
- );
1087
- }
1088
- /** @param {unknown} error */
1089
- error(t) {
1090
- if (!this.#t.onerror && !this.#t.failed)
1091
- throw t;
1092
- p?.is_fork ? (this.#a && p.skip_effect(this.#a), this.#n && p.skip_effect(this.#n), this.#f && p.skip_effect(this.#f), p.on_fork_commit(() => {
1093
- this.#E(t);
1094
- })) : this.#E(t);
1095
- }
1096
- /**
1097
- * @param {unknown} error
1098
- */
1099
- #E(t) {
1100
- this.#a && (x(this.#a), this.#a = null), this.#n && (x(this.#n), this.#n = null), this.#f && (x(this.#f), this.#f = null), g && (D(
1101
- /** @type {TemplateNode} */
1102
- this.#r
1103
- ), $r(), D(rn()));
1104
- var n = this.#t.onerror;
1105
- let r = this.#t.failed;
1106
- var s = !1, i = !1;
1107
- const f = () => {
1108
- if (s) {
1109
- wr();
1110
- return;
1111
- }
1112
- s = !0, i && yr(), this.#f !== null && Pe(this.#f, () => {
1113
- this.#f = null;
1114
- }), this.#w(() => {
1115
- this.#y();
1116
- });
1117
- }, a = (l) => {
1118
- try {
1119
- i = !0, n?.(l, f), i = !1;
1120
- } catch (o) {
1121
- ae(o, this.#s && this.#s.parent);
1122
- }
1123
- r && (this.#f = this.#w(() => {
1124
- try {
1125
- return Z(() => {
1126
- var o = (
1127
- /** @type {Effect} */
1128
- _
1129
- );
1130
- o.b = this, o.f |= ct, r(
1131
- this.#e,
1132
- () => l,
1133
- () => f
1134
- );
1135
- });
1136
- } catch (o) {
1137
- return ae(
1138
- o,
1139
- /** @type {Effect} */
1140
- this.#s.parent
1141
- ), null;
1142
- }
1143
- }));
1144
- };
1145
- W(() => {
1146
- var l;
1147
- try {
1148
- l = this.transform_error(t);
1149
- } catch (o) {
1150
- ae(o, this.#s && this.#s.parent);
1151
- return;
1152
- }
1153
- l !== null && typeof l == "object" && typeof /** @type {any} */
1154
- l.then == "function" ? l.then(
1155
- a,
1156
- /** @param {unknown} e */
1157
- (o) => ae(o, this.#s && this.#s.parent)
1158
- ) : a(l);
1159
- });
1160
- }
1161
- }
1162
- function jr(e, t, n, r) {
1163
- const s = qe() ? xt : Br;
1164
- var i = e.filter((h) => !h.settled);
1165
- if (n.length === 0 && i.length === 0) {
1166
- r(t.map(s));
1167
- return;
1168
- }
1169
- var f = (
1170
- /** @type {Effect} */
1171
- _
1172
- ), a = Hr(), l = i.length === 1 ? i[0].promise : i.length > 1 ? Promise.all(i.map((h) => h.promise)) : null;
1173
- function o(h) {
1174
- a();
1175
- try {
1176
- r(h);
1177
- } catch (v) {
1178
- (f.f & B) === 0 && ae(v, f);
1179
- }
1180
- Xe();
1181
- }
1182
- if (n.length === 0) {
1183
- l.then(() => o(t.map(s)));
1184
- return;
1185
- }
1186
- var u = gn();
1187
- function c() {
1188
- Promise.all(n.map((h) => /* @__PURE__ */ qr(h))).then((h) => o([...t.map(s), ...h])).catch((h) => ae(h, f)).finally(() => u());
1189
- }
1190
- l ? l.then(() => {
1191
- a(), c(), Xe();
1192
- }) : c();
1193
- }
1194
- function Hr() {
1195
- var e = (
1196
- /** @type {Effect} */
1197
- _
1198
- ), t = b, n = $, r = (
1199
- /** @type {Batch} */
1200
- p
1201
- );
1202
- return function(i = !0) {
1203
- O(e), R(t), xe(n), i && (e.f & B) === 0 && (r?.activate(), r?.apply());
1204
- };
1205
- }
1206
- function Xe(e = !0) {
1207
- O(null), R(null), xe(null), e && p?.deactivate();
1208
- }
1209
- function gn() {
1210
- var e = (
1211
- /** @type {Effect} */
1212
- _
1213
- ), t = (
1214
- /** @type {Boundary} */
1215
- e.b
1216
- ), n = (
1217
- /** @type {Batch} */
1218
- p
1219
- ), r = t.is_rendered();
1220
- return t.update_pending_count(1, n), n.increment(r, e), (s = !1) => {
1221
- t.update_pending_count(-1, n), n.decrement(r, e, s);
1222
- };
1223
- }
1224
- // @__NO_SIDE_EFFECTS__
1225
- function xt(e) {
1226
- var t = A | S;
1227
- return _ !== null && (_.f |= me), {
1228
- ctx: $,
1229
- deps: null,
1230
- effects: null,
1231
- equals: sn,
1232
- f: t,
1233
- fn: e,
1234
- reactions: null,
1235
- rv: 0,
1236
- v: (
1237
- /** @type {V} */
1238
- T
1239
- ),
1240
- wv: 0,
1241
- parent: _,
1242
- ac: null
1243
- };
1244
- }
1245
- // @__NO_SIDE_EFFECTS__
1246
- function qr(e, t, n) {
1247
- let r = (
1248
- /** @type {Effect | null} */
1249
- _
1250
- );
1251
- r === null && ur();
1252
- var s = (
1253
- /** @type {Promise<V>} */
1254
- /** @type {unknown} */
1255
- void 0
1256
- ), i = Be(
1257
- /** @type {V} */
1258
- T
1259
- ), f = !b, a = /* @__PURE__ */ new Map();
1260
- return Zr(() => {
1261
- var l = (
1262
- /** @type {Effect} */
1263
- _
1264
- ), o = Qt();
1265
- s = o.promise;
1266
- try {
1267
- Promise.resolve(e()).then(o.resolve, o.reject).finally(Xe);
1268
- } catch (v) {
1269
- o.reject(v), Xe();
1270
- }
1271
- var u = (
1272
- /** @type {Batch} */
1273
- p
1274
- );
1275
- if (f) {
1276
- if ((l.f & oe) !== 0)
1277
- var c = gn();
1278
- if (
1279
- /** @type {Boundary} */
1280
- r.b.is_rendered()
1281
- )
1282
- a.get(u)?.reject(Q), a.delete(u);
1283
- else {
1284
- for (const v of a.values())
1285
- v.reject(Q);
1286
- a.clear();
1287
- }
1288
- a.set(u, o);
1289
- }
1290
- const h = (v, d = void 0) => {
1291
- if (c) {
1292
- var m = d === Q;
1293
- c(m);
1294
- }
1295
- if (!(d === Q || (l.f & B) !== 0)) {
1296
- if (u.activate(), d)
1297
- i.f |= fe, Ze(i, d);
1298
- else {
1299
- (i.f & fe) !== 0 && (i.f ^= fe), Ze(i, v);
1300
- for (const [k, F] of a) {
1301
- if (a.delete(k), k === u) break;
1302
- F.reject(Q);
1303
- }
1304
- }
1305
- u.deactivate();
1306
- }
1307
- };
1308
- o.promise.then(h, (v) => h(null, v || "unknown"));
1309
- }), it(() => {
1310
- for (const l of a.values())
1311
- l.reject(Q);
1312
- }), new Promise((l) => {
1313
- function o(u) {
1314
- function c() {
1315
- u === s ? l(i) : o(s);
1316
- }
1317
- u.then(c, c);
1318
- }
1319
- o(s);
1320
- });
1321
- }
1322
- // @__NO_SIDE_EFFECTS__
1323
- function ei(e) {
1324
- const t = /* @__PURE__ */ xt(e);
1325
- return Dn(t), t;
1326
- }
1327
- // @__NO_SIDE_EFFECTS__
1328
- function Br(e) {
1329
- const t = /* @__PURE__ */ xt(e);
1330
- return t.equals = fn, t;
1331
- }
1332
- function Vr(e) {
1333
- var t = e.effects;
1334
- if (t !== null) {
1335
- e.effects = null;
1336
- for (var n = 0; n < t.length; n += 1)
1337
- x(
1338
- /** @type {Effect} */
1339
- t[n]
1340
- );
1341
- }
1342
- }
1343
- function Rt(e) {
1344
- var t, n = _, r = e.parent;
1345
- if (!le && r !== null && (r.f & (B | P)) !== 0)
1346
- return mr(), e.v;
1347
- O(r);
1348
- try {
1349
- e.f &= ~ge, Vr(e), t = qn(e);
1350
- } finally {
1351
- O(n);
1352
- }
1353
- return t;
1354
- }
1355
- function yn(e) {
1356
- var t = Rt(e);
1357
- if (!e.equals(t) && (e.wv = jn(), (!p?.is_fork || e.deps === null) && (p !== null ? p.capture(e, t, !0) : e.v = t, e.deps === null))) {
1358
- w(e, E);
1359
- return;
1360
- }
1361
- le || (j !== null ? (Mt() || p?.is_fork) && j.set(e, t) : kt(e));
1362
- }
1363
- function Ur(e) {
1364
- if (e.effects !== null)
1365
- for (const t of e.effects)
1366
- (t.teardown || t.ac) && (t.teardown?.(), t.ac?.abort(Q), t.teardown = _e, t.ac = null, Fe(t, 0), Ct(t));
1367
- }
1368
- function mn(e) {
1369
- if (e.effects !== null)
1370
- for (const t of e.effects)
1371
- t.teardown && ye(t);
1372
- }
1373
- let pt = /* @__PURE__ */ new Set();
1374
- const pe = /* @__PURE__ */ new Map();
1375
- let wn = !1;
1376
- function Be(e, t) {
1377
- var n = {
1378
- f: 0,
1379
- // TODO ideally we could skip this altogether, but it causes type errors
1380
- v: e,
1381
- reactions: null,
1382
- equals: sn,
1383
- rv: 0,
1384
- wv: 0
1385
- };
1386
- return n;
1387
- }
1388
- // @__NO_SIDE_EFFECTS__
1389
- function se(e, t) {
1390
- const n = Be(e);
1391
- return Dn(n), n;
1392
- }
1393
- // @__NO_SIDE_EFFECTS__
1394
- function $n(e, t = !1, n = !0) {
1395
- const r = Be(e);
1396
- return t || (r.equals = fn), tt && n && $ !== null && $.l !== null && ($.l.s ??= []).push(r), r;
1397
- }
1398
- function G(e, t, n = !1) {
1399
- b !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1400
- // to ensure we error if state is set inside an inspect effect
1401
- (!H || (b.f & ht) !== 0) && qe() && (b.f & (A | z | De | ht)) !== 0 && (L === null || !ke.call(L, e)) && gr();
1402
- let r = n ? Oe(t) : t;
1403
- return Ze(e, r, Ge);
1404
- }
1405
- function Ze(e, t, n = null) {
1406
- if (!e.equals(t)) {
1407
- pe.set(e, le ? t : e.v);
1408
- var r = te.ensure();
1409
- if (r.capture(e, t), (e.f & A) !== 0) {
1410
- const s = (
1411
- /** @type {Derived} */
1412
- e
1413
- );
1414
- (e.f & S) !== 0 && Rt(s), j === null && kt(s);
1415
- }
1416
- e.wv = jn(), En(e, S, n), qe() && _ !== null && (_.f & E) !== 0 && (_.f & (J | ee)) === 0 && (C === null ? ns([e]) : C.push(e)), !r.is_fork && pt.size > 0 && !wn && Yr();
1417
- }
1418
- return t;
1419
- }
1420
- function Yr() {
1421
- wn = !1;
1422
- for (const e of pt)
1423
- (e.f & E) !== 0 && w(e, V), Re(e) && ye(e);
1424
- pt.clear();
1425
- }
1426
- function ti(e, t = 1) {
1427
- var n = q(e), r = t === 1 ? n++ : n--;
1428
- return G(e, n), r;
1429
- }
1430
- function Ie(e) {
1431
- G(e, e.v + 1);
1432
- }
1433
- function En(e, t, n) {
1434
- var r = e.reactions;
1435
- if (r !== null)
1436
- for (var s = qe(), i = r.length, f = 0; f < i; f++) {
1437
- var a = r[f], l = a.f;
1438
- if (!(!s && a === _)) {
1439
- var o = (l & S) === 0;
1440
- if (o && w(a, t), (l & A) !== 0) {
1441
- var u = (
1442
- /** @type {Derived} */
1443
- a
1444
- );
1445
- j?.delete(u), (l & ge) === 0 && (l & I && (_ === null || (_.f & Je) === 0) && (a.f |= ge), En(u, V, n));
1446
- } else if (o) {
1447
- var c = (
1448
- /** @type {Effect} */
1449
- a
1450
- );
1451
- (l & z) !== 0 && X !== null && X.add(c), n !== null ? n.push(c) : Nt(c);
1452
- }
1453
- }
1454
- }
1455
- }
1456
- function Oe(e) {
1457
- if (typeof e != "object" || e === null || ve in e)
1458
- return e;
1459
- const t = Tt(e);
1460
- if (t !== rr && t !== sr)
1461
- return e;
1462
- var n = /* @__PURE__ */ new Map(), r = er(e), s = /* @__PURE__ */ se(0), i = be, f = (a) => {
1463
- if (be === i)
1464
- return a();
1465
- var l = b, o = be;
1466
- R(null), Ut(i);
1467
- var u = a();
1468
- return R(l), Ut(o), u;
1469
- };
1470
- return r && n.set("length", /* @__PURE__ */ se(
1471
- /** @type {any[]} */
1472
- e.length
1473
- )), new Proxy(
1474
- /** @type {any} */
1475
- e,
1476
- {
1477
- defineProperty(a, l, o) {
1478
- (!("value" in o) || o.configurable === !1 || o.enumerable === !1 || o.writable === !1) && pr();
1479
- var u = n.get(l);
1480
- return u === void 0 ? f(() => {
1481
- var c = /* @__PURE__ */ se(o.value);
1482
- return n.set(l, c), c;
1483
- }) : G(u, o.value, !0), !0;
1484
- },
1485
- deleteProperty(a, l) {
1486
- var o = n.get(l);
1487
- if (o === void 0) {
1488
- if (l in a) {
1489
- const u = f(() => /* @__PURE__ */ se(T));
1490
- n.set(l, u), Ie(s);
1491
- }
1492
- } else
1493
- G(o, T), Ie(s);
1494
- return !0;
1495
- },
1496
- get(a, l, o) {
1497
- if (l === ve)
1498
- return e;
1499
- var u = n.get(l), c = l in a;
1500
- if (u === void 0 && (!c || Te(a, l)?.writable) && (u = f(() => {
1501
- var v = Oe(c ? a[l] : T), d = /* @__PURE__ */ se(v);
1502
- return d;
1503
- }), n.set(l, u)), u !== void 0) {
1504
- var h = q(u);
1505
- return h === T ? void 0 : h;
1506
- }
1507
- return Reflect.get(a, l, o);
1508
- },
1509
- getOwnPropertyDescriptor(a, l) {
1510
- var o = Reflect.getOwnPropertyDescriptor(a, l);
1511
- if (o && "value" in o) {
1512
- var u = n.get(l);
1513
- u && (o.value = q(u));
1514
- } else if (o === void 0) {
1515
- var c = n.get(l), h = c?.v;
1516
- if (c !== void 0 && h !== T)
1517
- return {
1518
- enumerable: !0,
1519
- configurable: !0,
1520
- value: h,
1521
- writable: !0
1522
- };
1523
- }
1524
- return o;
1525
- },
1526
- has(a, l) {
1527
- if (l === ve)
1528
- return !0;
1529
- var o = n.get(l), u = o !== void 0 && o.v !== T || Reflect.has(a, l);
1530
- if (o !== void 0 || _ !== null && (!u || Te(a, l)?.writable)) {
1531
- o === void 0 && (o = f(() => {
1532
- var h = u ? Oe(a[l]) : T, v = /* @__PURE__ */ se(h);
1533
- return v;
1534
- }), n.set(l, o));
1535
- var c = q(o);
1536
- if (c === T)
1537
- return !1;
1538
- }
1539
- return u;
1540
- },
1541
- set(a, l, o, u) {
1542
- var c = n.get(l), h = l in a;
1543
- if (r && l === "length")
1544
- for (var v = o; v < /** @type {Source<number>} */
1545
- c.v; v += 1) {
1546
- var d = n.get(v + "");
1547
- d !== void 0 ? G(d, T) : v in a && (d = f(() => /* @__PURE__ */ se(T)), n.set(v + "", d));
1548
- }
1549
- if (c === void 0)
1550
- (!h || Te(a, l)?.writable) && (c = f(() => /* @__PURE__ */ se(void 0)), G(c, Oe(o)), n.set(l, c));
1551
- else {
1552
- h = c.v !== T;
1553
- var m = f(() => Oe(o));
1554
- G(c, m);
1555
- }
1556
- var k = Reflect.getOwnPropertyDescriptor(a, l);
1557
- if (k?.set && k.set.call(u, o), !h) {
1558
- if (r && typeof l == "string") {
1559
- var F = (
1560
- /** @type {Source<number>} */
1561
- n.get("length")
1562
- ), we = Number(l);
1563
- Number.isInteger(we) && we >= F.v && G(F, we + 1);
1564
- }
1565
- Ie(s);
1566
- }
1567
- return !0;
1568
- },
1569
- ownKeys(a) {
1570
- q(s);
1571
- var l = Reflect.ownKeys(a).filter((c) => {
1572
- var h = n.get(c);
1573
- return h === void 0 || h.v !== T;
1574
- });
1575
- for (var [o, u] of n)
1576
- u.v !== T && !(o in a) && l.push(o);
1577
- return l;
1578
- },
1579
- setPrototypeOf() {
1580
- br();
1581
- }
1582
- }
1583
- );
1584
- }
1585
- function Ht(e) {
1586
- try {
1587
- if (e !== null && typeof e == "object" && ve in e)
1588
- return e[ve];
1589
- } catch {
1590
- }
1591
- return e;
1592
- }
1593
- function Gr(e, t) {
1594
- return Object.is(Ht(e), Ht(t));
1595
- }
1596
- var qt, Tn, Sn, kn;
1597
- function bt() {
1598
- if (qt === void 0) {
1599
- qt = window, Tn = /Firefox/.test(navigator.userAgent);
1600
- var e = Element.prototype, t = Node.prototype, n = Text.prototype;
1601
- Sn = Te(t, "firstChild").get, kn = Te(t, "nextSibling").get, Lt(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), Lt(n) && (n.__t = void 0);
1602
- }
1603
- }
1604
- function U(e = "") {
1605
- return document.createTextNode(e);
1606
- }
1607
- // @__NO_SIDE_EFFECTS__
1608
- function ne(e) {
1609
- return (
1610
- /** @type {TemplateNode | null} */
1611
- Sn.call(e)
1612
- );
1613
- }
1614
- // @__NO_SIDE_EFFECTS__
1615
- function re(e) {
1616
- return (
1617
- /** @type {TemplateNode | null} */
1618
- kn.call(e)
1619
- );
1620
- }
1621
- function ni(e, t) {
1622
- if (!g)
1623
- return /* @__PURE__ */ ne(e);
1624
- var n = /* @__PURE__ */ ne(y);
1625
- if (n === null)
1626
- n = y.appendChild(U());
1627
- else if (t && n.nodeType !== He) {
1628
- var r = U();
1629
- return n?.before(r), D(r), r;
1630
- }
1631
- return t && nt(
1632
- /** @type {Text} */
1633
- n
1634
- ), D(n), n;
1635
- }
1636
- function ri(e, t = !1) {
1637
- if (!g) {
1638
- var n = /* @__PURE__ */ ne(e);
1639
- return n instanceof Comment && n.data === "" ? /* @__PURE__ */ re(n) : n;
1640
- }
1641
- if (t) {
1642
- if (y?.nodeType !== He) {
1643
- var r = U();
1644
- return y?.before(r), D(r), r;
1645
- }
1646
- nt(
1647
- /** @type {Text} */
1648
- y
1649
- );
1650
- }
1651
- return y;
1652
- }
1653
- function si(e, t = 1, n = !1) {
1654
- let r = g ? y : e;
1655
- for (var s; t--; )
1656
- s = r, r = /** @type {TemplateNode} */
1657
- /* @__PURE__ */ re(r);
1658
- if (!g)
1659
- return r;
1660
- if (n) {
1661
- if (r?.nodeType !== He) {
1662
- var i = U();
1663
- return r === null ? s?.after(i) : r.before(i), D(i), i;
1664
- }
1665
- nt(
1666
- /** @type {Text} */
1667
- r
1668
- );
1669
- }
1670
- return D(r), r;
1671
- }
1672
- function An(e) {
1673
- e.textContent = "";
1674
- }
1675
- function zr() {
1676
- return !1;
1677
- }
1678
- function Ot(e, t, n) {
1679
- return (
1680
- /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
1681
- document.createElementNS(t ?? Xt, e, void 0)
1682
- );
1683
- }
1684
- function nt(e) {
1685
- if (
1686
- /** @type {string} */
1687
- e.nodeValue.length < 65536
1688
- )
1689
- return;
1690
- let t = e.nextSibling;
1691
- for (; t !== null && t.nodeType === He; )
1692
- t.remove(), e.nodeValue += /** @type {string} */
1693
- t.nodeValue, t = e.nextSibling;
1694
- }
1695
- function ii(e) {
1696
- g && /* @__PURE__ */ ne(e) !== null && An(e);
1697
- }
1698
- let Bt = !1;
1699
- function Nn() {
1700
- Bt || (Bt = !0, document.addEventListener(
1701
- "reset",
1702
- (e) => {
1703
- Promise.resolve().then(() => {
1704
- if (!e.defaultPrevented)
1705
- for (
1706
- const t of
1707
- /**@type {HTMLFormElement} */
1708
- e.target.elements
1709
- )
1710
- t.__on_r?.();
1711
- });
1712
- },
1713
- // In the capture phase to guarantee we get noticed of it (no possibility of stopPropagation)
1714
- { capture: !0 }
1715
- ));
1716
- }
1717
- function rt(e) {
1718
- var t = b, n = _;
1719
- R(null), O(null);
1720
- try {
1721
- return e();
1722
- } finally {
1723
- R(t), O(n);
1724
- }
1725
- }
1726
- function st(e, t, n, r = n) {
1727
- e.addEventListener(t, () => rt(n));
1728
- const s = e.__on_r;
1729
- s ? e.__on_r = () => {
1730
- s(), r(!0);
1731
- } : e.__on_r = () => r(!0), Nn();
1732
- }
1733
- function xn(e) {
1734
- _ === null && (b === null && dr(), hr()), le && cr();
1735
- }
1736
- function Wr(e, t) {
1737
- var n = t.last;
1738
- n === null ? t.last = t.first = e : (n.next = e, e.prev = n, t.last = e);
1739
- }
1740
- function Y(e, t) {
1741
- var n = _;
1742
- n !== null && (n.f & P) !== 0 && (e |= P);
1743
- var r = {
1744
- ctx: $,
1745
- deps: null,
1746
- nodes: null,
1747
- f: e | S | I,
1748
- first: null,
1749
- fn: t,
1750
- last: null,
1751
- next: null,
1752
- parent: n,
1753
- b: n && n.b,
1754
- prev: null,
1755
- teardown: null,
1756
- wv: 0,
1757
- ac: null
1758
- };
1759
- p?.register_created_effect(r);
1760
- var s = r;
1761
- if ((e & Ae) !== 0)
1762
- Ee !== null ? Ee.push(r) : te.ensure().schedule(r);
1763
- else if (t !== null) {
1764
- try {
1765
- ye(r);
1766
- } catch (f) {
1767
- throw x(r), f;
1768
- }
1769
- s.deps === null && s.teardown === null && s.nodes === null && s.first === s.last && // either `null`, or a singular child
1770
- (s.f & me) === 0 && (s = s.first, (e & z) !== 0 && (e & Ne) !== 0 && s !== null && (s.f |= Ne));
1771
- }
1772
- if (s !== null && (s.parent = n, n !== null && Wr(s, n), b !== null && (b.f & A) !== 0 && (e & ee) === 0)) {
1773
- var i = (
1774
- /** @type {Derived} */
1775
- b
1776
- );
1777
- (i.effects ??= []).push(s);
1778
- }
1779
- return r;
1780
- }
1781
- function Mt() {
1782
- return b !== null && !H;
1783
- }
1784
- function it(e) {
1785
- const t = Y(je, null);
1786
- return w(t, E), t.teardown = e, t;
1787
- }
1788
- function ai(e) {
1789
- xn();
1790
- var t = (
1791
- /** @type {Effect} */
1792
- _.f
1793
- ), n = !b && (t & J) !== 0 && (t & oe) === 0;
1794
- if (n) {
1795
- var r = (
1796
- /** @type {ComponentContext} */
1797
- $
1798
- );
1799
- (r.e ??= []).push(e);
1800
- } else
1801
- return Rn(e);
1802
- }
1803
- function Rn(e) {
1804
- return Y(Ae | tn, e);
1805
- }
1806
- function fi(e) {
1807
- return xn(), Y(je | tn, e);
1808
- }
1809
- function Kr(e) {
1810
- te.ensure();
1811
- const t = Y(ee | me, e);
1812
- return () => {
1813
- x(t);
1814
- };
1815
- }
1816
- function Jr(e) {
1817
- te.ensure();
1818
- const t = Y(ee | me, e);
1819
- return (n = {}) => new Promise((r) => {
1820
- n.outro ? Pe(t, () => {
1821
- x(t), r(void 0);
1822
- }) : (x(t), r(void 0));
1823
- });
1824
- }
1825
- function Xr(e) {
1826
- return Y(Ae, e);
1827
- }
1828
- function li(e, t) {
1829
- var n = (
1830
- /** @type {ComponentContextLegacy} */
1831
- $
1832
- ), r = { effect: null, ran: !1, deps: e };
1833
- n.l.$.push(r), r.effect = ue(() => {
1834
- if (e(), !r.ran) {
1835
- r.ran = !0;
1836
- var s = (
1837
- /** @type {Effect} */
1838
- _
1839
- );
1840
- try {
1841
- O(s.parent), Ve(t);
1842
- } finally {
1843
- O(s);
1844
- }
1845
- }
1846
- });
1847
- }
1848
- function oi() {
1849
- var e = (
1850
- /** @type {ComponentContextLegacy} */
1851
- $
1852
- );
1853
- ue(() => {
1854
- for (var t of e.l.$) {
1855
- t.deps();
1856
- var n = t.effect;
1857
- (n.f & E) !== 0 && n.deps !== null && w(n, V), Re(n) && ye(n), t.ran = !1;
1858
- }
1859
- });
1860
- }
1861
- function Zr(e) {
1862
- return Y(De | me, e);
1863
- }
1864
- function ue(e, t = 0) {
1865
- return Y(je | t, e);
1866
- }
1867
- function ui(e, t = [], n = [], r = []) {
1868
- jr(r, t, n, (s) => {
1869
- Y(je, () => e(...s.map(q)));
1870
- });
1871
- }
1872
- function On(e, t = 0) {
1873
- var n = Y(z | t, e);
1874
- return n;
1875
- }
1876
- function Z(e) {
1877
- return Y(J | me, e);
1878
- }
1879
- function Mn(e) {
1880
- var t = e.teardown;
1881
- if (t !== null) {
1882
- const n = le, r = b;
1883
- Vt(!0), R(null);
1884
- try {
1885
- t.call(null);
1886
- } finally {
1887
- Vt(n), R(r);
1888
- }
1889
- }
1890
- }
1891
- function Ct(e, t = !1) {
1892
- var n = e.first;
1893
- for (e.first = e.last = null; n !== null; ) {
1894
- const s = n.ac;
1895
- s !== null && rt(() => {
1896
- s.abort(Q);
1897
- });
1898
- var r = n.next;
1899
- (n.f & ee) !== 0 ? n.parent = null : x(n, t), n = r;
1900
- }
1901
- }
1902
- function Qr(e) {
1903
- for (var t = e.first; t !== null; ) {
1904
- var n = t.next;
1905
- (t.f & J) === 0 && x(t), t = n;
1906
- }
1907
- }
1908
- function x(e, t = !0) {
1909
- var n = !1;
1910
- (t || (e.f & ar) !== 0) && e.nodes !== null && e.nodes.end !== null && (es(
1911
- e.nodes.start,
1912
- /** @type {TemplateNode} */
1913
- e.nodes.end
1914
- ), n = !0), w(e, Dt), Ct(e, t && !n), Fe(e, 0);
1915
- var r = e.nodes && e.nodes.t;
1916
- if (r !== null)
1917
- for (const i of r)
1918
- i.stop();
1919
- Mn(e), e.f ^= Dt, e.f |= B;
1920
- var s = e.parent;
1921
- s !== null && s.first !== null && Cn(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = e.b = null;
1922
- }
1923
- function es(e, t) {
1924
- for (; e !== null; ) {
1925
- var n = e === t ? null : /* @__PURE__ */ re(e);
1926
- e.remove(), e = n;
1927
- }
1928
- }
1929
- function Cn(e) {
1930
- var t = e.parent, n = e.prev, r = e.next;
1931
- n !== null && (n.next = r), r !== null && (r.prev = n), t !== null && (t.first === e && (t.first = r), t.last === e && (t.last = n));
1932
- }
1933
- function Pe(e, t, n = !0) {
1934
- var r = [];
1935
- In(e, r, !0);
1936
- var s = () => {
1937
- n && x(e), t && t();
1938
- }, i = r.length;
1939
- if (i > 0) {
1940
- var f = () => --i || s();
1941
- for (var a of r)
1942
- a.out(f);
1943
- } else
1944
- s();
1945
- }
1946
- function In(e, t, n) {
1947
- if ((e.f & P) === 0) {
1948
- e.f ^= P;
1949
- var r = e.nodes && e.nodes.t;
1950
- if (r !== null)
1951
- for (const a of r)
1952
- (a.is_global || n) && t.push(a);
1953
- for (var s = e.first; s !== null; ) {
1954
- var i = s.next;
1955
- if ((s.f & ee) === 0) {
1956
- var f = (s.f & Ne) !== 0 || // If this is a branch effect without a block effect parent,
1957
- // it means the parent block effect was pruned. In that case,
1958
- // transparency information was transferred to the branch effect.
1959
- (s.f & J) !== 0 && (e.f & z) !== 0;
1960
- In(s, t, f ? n : !1);
1961
- }
1962
- s = i;
1963
- }
1964
- }
1965
- }
1966
- function ts(e) {
1967
- Pn(e, !0);
1968
- }
1969
- function Pn(e, t) {
1970
- if ((e.f & P) !== 0) {
1971
- e.f ^= P, (e.f & E) === 0 && (w(e, S), te.ensure().schedule(e));
1972
- for (var n = e.first; n !== null; ) {
1973
- var r = n.next, s = (n.f & Ne) !== 0 || (n.f & J) !== 0;
1974
- Pn(n, s ? t : !1), n = r;
1975
- }
1976
- var i = e.nodes && e.nodes.t;
1977
- if (i !== null)
1978
- for (const f of i)
1979
- (f.is_global || t) && f.in();
1980
- }
1981
- }
1982
- function Ln(e, t) {
1983
- if (e.nodes)
1984
- for (var n = e.nodes.start, r = e.nodes.end; n !== null; ) {
1985
- var s = n === r ? null : /* @__PURE__ */ re(n);
1986
- t.append(n), n = s;
1987
- }
1988
- }
1989
- let ze = !1, le = !1;
1990
- function Vt(e) {
1991
- le = e;
1992
- }
1993
- let b = null, H = !1;
1994
- function R(e) {
1995
- b = e;
1996
- }
1997
- let _ = null;
1998
- function O(e) {
1999
- _ = e;
2000
- }
2001
- let L = null;
2002
- function Dn(e) {
2003
- b !== null && (L === null ? L = [e] : L.push(e));
2004
- }
2005
- let N = null, M = 0, C = null;
2006
- function ns(e) {
2007
- C = e;
2008
- }
2009
- let Fn = 1, de = 0, be = de;
2010
- function Ut(e) {
2011
- be = e;
2012
- }
2013
- function jn() {
2014
- return ++Fn;
2015
- }
2016
- function Re(e) {
2017
- var t = e.f;
2018
- if ((t & S) !== 0)
2019
- return !0;
2020
- if (t & A && (e.f &= ~ge), (t & V) !== 0) {
2021
- for (var n = (
2022
- /** @type {Value[]} */
2023
- e.deps
2024
- ), r = n.length, s = 0; s < r; s++) {
2025
- var i = n[s];
2026
- if (Re(
2027
- /** @type {Derived} */
2028
- i
2029
- ) && yn(
2030
- /** @type {Derived} */
2031
- i
2032
- ), i.wv > e.wv)
2033
- return !0;
2034
- }
2035
- (t & I) !== 0 && // During time traveling we don't want to reset the status so that
2036
- // traversal of the graph in the other batches still happens
2037
- j === null && w(e, E);
2038
- }
2039
- return !1;
2040
- }
2041
- function Hn(e, t, n = !0) {
2042
- var r = e.reactions;
2043
- if (r !== null && !(L !== null && ke.call(L, e)))
2044
- for (var s = 0; s < r.length; s++) {
2045
- var i = r[s];
2046
- (i.f & A) !== 0 ? Hn(
2047
- /** @type {Derived} */
2048
- i,
2049
- t,
2050
- !1
2051
- ) : t === i && (n ? w(i, S) : (i.f & E) !== 0 && w(i, V), Nt(
2052
- /** @type {Effect} */
2053
- i
2054
- ));
2055
- }
2056
- }
2057
- function qn(e) {
2058
- var t = N, n = M, r = C, s = b, i = L, f = $, a = H, l = be, o = e.f;
2059
- N = /** @type {null | Value[]} */
2060
- null, M = 0, C = null, b = (o & (J | ee)) === 0 ? e : null, L = null, xe(e.ctx), H = !1, be = ++de, e.ac !== null && (rt(() => {
2061
- e.ac.abort(Q);
2062
- }), e.ac = null);
2063
- try {
2064
- e.f |= Je;
2065
- var u = (
2066
- /** @type {Function} */
2067
- e.fn
2068
- ), c = u();
2069
- e.f |= oe;
2070
- var h = e.deps, v = p?.is_fork;
2071
- if (N !== null) {
2072
- var d;
2073
- if (v || Fe(e, M), h !== null && M > 0)
2074
- for (h.length = M + N.length, d = 0; d < N.length; d++)
2075
- h[M + d] = N[d];
2076
- else
2077
- e.deps = h = N;
2078
- if (Mt() && (e.f & I) !== 0)
2079
- for (d = M; d < h.length; d++)
2080
- (h[d].reactions ??= []).push(e);
2081
- } else !v && h !== null && M < h.length && (Fe(e, M), h.length = M);
2082
- if (qe() && C !== null && !H && h !== null && (e.f & (A | V | S)) === 0)
2083
- for (d = 0; d < /** @type {Source[]} */
2084
- C.length; d++)
2085
- Hn(
2086
- C[d],
2087
- /** @type {Effect} */
2088
- e
2089
- );
2090
- if (s !== null && s !== e) {
2091
- if (de++, s.deps !== null)
2092
- for (let m = 0; m < n; m += 1)
2093
- s.deps[m].rv = de;
2094
- if (t !== null)
2095
- for (const m of t)
2096
- m.rv = de;
2097
- C !== null && (r === null ? r = C : r.push(.../** @type {Source[]} */
2098
- C));
2099
- }
2100
- return (e.f & fe) !== 0 && (e.f ^= fe), c;
2101
- } catch (m) {
2102
- return un(m);
2103
- } finally {
2104
- e.f ^= Je, N = t, M = n, C = r, b = s, L = i, xe(f), H = a, be = l;
2105
- }
2106
- }
2107
- function rs(e, t) {
2108
- let n = t.reactions;
2109
- if (n !== null) {
2110
- var r = tr.call(n, e);
2111
- if (r !== -1) {
2112
- var s = n.length - 1;
2113
- s === 0 ? n = t.reactions = null : (n[r] = n[s], n.pop());
2114
- }
2115
- }
2116
- if (n === null && (t.f & A) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
2117
- // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
2118
- // allows us to skip the expensive work of disconnecting and immediately reconnecting it
2119
- (N === null || !ke.call(N, t))) {
2120
- var i = (
2121
- /** @type {Derived} */
2122
- t
2123
- );
2124
- (i.f & I) !== 0 && (i.f ^= I, i.f &= ~ge), i.v !== T && kt(i), Ur(i), Fe(i, 0);
2125
- }
2126
- }
2127
- function Fe(e, t) {
2128
- var n = e.deps;
2129
- if (n !== null)
2130
- for (var r = t; r < n.length; r++)
2131
- rs(e, n[r]);
2132
- }
2133
- function ye(e) {
2134
- var t = e.f;
2135
- if ((t & B) === 0) {
2136
- w(e, E);
2137
- var n = _, r = ze;
2138
- _ = e, ze = !0;
2139
- try {
2140
- (t & (z | en)) !== 0 ? Qr(e) : Ct(e), Mn(e);
2141
- var s = qn(e);
2142
- e.teardown = typeof s == "function" ? s : null, e.wv = Fn;
2143
- var i;
2144
- Qn && Tr && (e.f & S) !== 0 && e.deps;
2145
- } finally {
2146
- ze = r, _ = n;
2147
- }
2148
- }
2149
- }
2150
- async function ss() {
2151
- await Promise.resolve(), _n();
2152
- }
2153
- function q(e) {
2154
- var t = e.f, n = (t & A) !== 0;
2155
- if (b !== null && !H) {
2156
- var r = _ !== null && (_.f & B) !== 0;
2157
- if (!r && (L === null || !ke.call(L, e))) {
2158
- var s = b.deps;
2159
- if ((b.f & Je) !== 0)
2160
- e.rv < de && (e.rv = de, N === null && s !== null && s[M] === e ? M++ : N === null ? N = [e] : N.push(e));
2161
- else {
2162
- (b.deps ??= []).push(e);
2163
- var i = e.reactions;
2164
- i === null ? e.reactions = [b] : ke.call(i, b) || i.push(b);
2165
- }
2166
- }
2167
- }
2168
- if (le && pe.has(e))
2169
- return pe.get(e);
2170
- if (n) {
2171
- var f = (
2172
- /** @type {Derived} */
2173
- e
2174
- );
2175
- if (le) {
2176
- var a = f.v;
2177
- return ((f.f & E) === 0 && f.reactions !== null || Vn(f)) && (a = Rt(f)), pe.set(f, a), a;
2178
- }
2179
- var l = (f.f & I) === 0 && !H && b !== null && (ze || (b.f & I) !== 0), o = (f.f & oe) === 0;
2180
- Re(f) && (l && (f.f |= I), yn(f)), l && !o && (mn(f), Bn(f));
2181
- }
2182
- if (j?.has(e))
2183
- return j.get(e);
2184
- if ((e.f & fe) !== 0)
2185
- throw e.v;
2186
- return e.v;
2187
- }
2188
- function Bn(e) {
2189
- if (e.f |= I, e.deps !== null)
2190
- for (const t of e.deps)
2191
- (t.reactions ??= []).push(e), (t.f & A) !== 0 && (t.f & I) === 0 && (mn(
2192
- /** @type {Derived} */
2193
- t
2194
- ), Bn(
2195
- /** @type {Derived} */
2196
- t
2197
- ));
2198
- }
2199
- function Vn(e) {
2200
- if (e.v === T) return !0;
2201
- if (e.deps === null) return !1;
2202
- for (const t of e.deps)
2203
- if (pe.has(t) || (t.f & A) !== 0 && Vn(
2204
- /** @type {Derived} */
2205
- t
2206
- ))
2207
- return !0;
2208
- return !1;
2209
- }
2210
- function Ve(e) {
2211
- var t = H;
2212
- try {
2213
- return H = !0, e();
2214
- } finally {
2215
- H = t;
2216
- }
2217
- }
2218
- function ci(e) {
2219
- if (!(typeof e != "object" || !e || e instanceof EventTarget)) {
2220
- if (ve in e)
2221
- gt(e);
2222
- else if (!Array.isArray(e))
2223
- for (let t in e) {
2224
- const n = e[t];
2225
- typeof n == "object" && n && ve in n && gt(n);
2226
- }
2227
- }
2228
- }
2229
- function gt(e, t = /* @__PURE__ */ new Set()) {
2230
- if (typeof e == "object" && e !== null && // We don't want to traverse DOM elements
2231
- !(e instanceof EventTarget) && !t.has(e)) {
2232
- t.add(e), e instanceof Date && e.getTime();
2233
- for (let r in e)
2234
- try {
2235
- gt(e[r], t);
2236
- } catch {
2237
- }
2238
- const n = Tt(e);
2239
- if (n !== Object.prototype && n !== Array.prototype && n !== Map.prototype && n !== Set.prototype && n !== Date.prototype) {
2240
- const r = Zt(n);
2241
- for (let s in r) {
2242
- const i = r[s].get;
2243
- if (i)
2244
- try {
2245
- i.call(e);
2246
- } catch {
2247
- }
2248
- }
2249
- }
2250
- }
2251
- }
2252
- const Me = /* @__PURE__ */ Symbol("events"), Un = /* @__PURE__ */ new Set(), yt = /* @__PURE__ */ new Set();
2253
- function hi(e) {
2254
- if (!g) return;
2255
- e.removeAttribute("onload"), e.removeAttribute("onerror");
2256
- const t = e.__e;
2257
- t !== void 0 && (e.__e = void 0, queueMicrotask(() => {
2258
- e.isConnected && e.dispatchEvent(t);
2259
- }));
2260
- }
2261
- function is(e, t, n, r = {}) {
2262
- function s(i) {
2263
- if (r.capture || mt.call(t, i), !i.cancelBubble)
2264
- return rt(() => n?.call(this, i));
2265
- }
2266
- return e.startsWith("pointer") || e.startsWith("touch") || e === "wheel" ? W(() => {
2267
- t.addEventListener(e, s, r);
2268
- }) : t.addEventListener(e, s, r), s;
2269
- }
2270
- function di(e, t, n, r, s) {
2271
- var i = { capture: r, passive: s }, f = is(e, t, n, i);
2272
- (t === document.body || // @ts-ignore
2273
- t === window || // @ts-ignore
2274
- t === document || // Firefox has quirky behavior, it can happen that we still get "canplay" events when the element is already removed
2275
- t instanceof HTMLMediaElement) && it(() => {
2276
- t.removeEventListener(e, f, i);
2277
- });
2278
- }
2279
- function _i(e, t, n) {
2280
- (t[Me] ??= {})[e] = n;
2281
- }
2282
- function vi(e) {
2283
- for (var t = 0; t < e.length; t++)
2284
- Un.add(e[t]);
2285
- for (var n of yt)
2286
- n(e);
2287
- }
2288
- let Yt = null;
2289
- function mt(e) {
2290
- var t = this, n = (
2291
- /** @type {Node} */
2292
- t.ownerDocument
2293
- ), r = e.type, s = e.composedPath?.() || [], i = (
2294
- /** @type {null | Element} */
2295
- s[0] || e.target
2296
- );
2297
- Yt = e;
2298
- var f = 0, a = Yt === e && e[Me];
2299
- if (a) {
2300
- var l = s.indexOf(a);
2301
- if (l !== -1 && (t === document || t === /** @type {any} */
2302
- window)) {
2303
- e[Me] = t;
2304
- return;
2305
- }
2306
- var o = s.indexOf(t);
2307
- if (o === -1)
2308
- return;
2309
- l <= o && (f = l);
2310
- }
2311
- if (i = /** @type {Element} */
2312
- s[f] || e.target, i !== t) {
2313
- Le(e, "currentTarget", {
2314
- configurable: !0,
2315
- get() {
2316
- return i || n;
2317
- }
2318
- });
2319
- var u = b, c = _;
2320
- R(null), O(null);
2321
- try {
2322
- for (var h, v = []; i !== null; ) {
2323
- var d = i.assignedSlot || i.parentNode || /** @type {any} */
2324
- i.host || null;
2325
- try {
2326
- var m = i[Me]?.[r];
2327
- m != null && (!/** @type {any} */
2328
- i.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2329
- // -> the target could not have been disabled because it emits the event in the first place
2330
- e.target === i) && m.call(i, e);
2331
- } catch (k) {
2332
- h ? v.push(k) : h = k;
2333
- }
2334
- if (e.cancelBubble || d === t || d === null)
2335
- break;
2336
- i = d;
2337
- }
2338
- if (h) {
2339
- for (let k of v)
2340
- queueMicrotask(() => {
2341
- throw k;
2342
- });
2343
- throw h;
2344
- }
2345
- } finally {
2346
- e[Me] = t, delete e.currentTarget, R(u), O(c);
2347
- }
2348
- }
2349
- }
2350
- const as = (
2351
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
2352
- globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
2353
- /** @param {string} html */
2354
- createHTML: (e) => e
2355
- })
2356
- );
2357
- function fs(e) {
2358
- return (
2359
- /** @type {string} */
2360
- as?.createHTML(e) ?? e
2361
- );
2362
- }
2363
- function Yn(e) {
2364
- var t = Ot("template");
2365
- return t.innerHTML = fs(e.replaceAll("<!>", "<!---->")), t.content;
2366
- }
2367
- function K(e, t) {
2368
- var n = (
2369
- /** @type {Effect} */
2370
- _
2371
- );
2372
- n.nodes === null && (n.nodes = { start: e, end: t, a: null, t: null });
2373
- }
2374
- // @__NO_SIDE_EFFECTS__
2375
- function pi(e, t) {
2376
- var n = (t & Xn) !== 0, r = (t & Zn) !== 0, s, i = !e.startsWith("<!>");
2377
- return () => {
2378
- if (g)
2379
- return K(y, null), y;
2380
- s === void 0 && (s = Yn(i ? e : "<!>" + e), n || (s = /** @type {TemplateNode} */
2381
- /* @__PURE__ */ ne(s)));
2382
- var f = (
2383
- /** @type {TemplateNode} */
2384
- r || Tn ? document.importNode(s, !0) : s.cloneNode(!0)
2385
- );
2386
- if (n) {
2387
- var a = (
2388
- /** @type {TemplateNode} */
2389
- /* @__PURE__ */ ne(f)
2390
- ), l = (
2391
- /** @type {TemplateNode} */
2392
- f.lastChild
2393
- );
2394
- K(a, l);
2395
- } else
2396
- K(f, f);
2397
- return f;
2398
- };
2399
- }
2400
- // @__NO_SIDE_EFFECTS__
2401
- function ls(e, t, n = "svg") {
2402
- var r = !e.startsWith("<!>"), s = `<${n}>${r ? e : "<!>" + e}</${n}>`, i;
2403
- return () => {
2404
- if (g)
2405
- return K(y, null), y;
2406
- if (!i) {
2407
- var f = (
2408
- /** @type {DocumentFragment} */
2409
- Yn(s)
2410
- ), a = (
2411
- /** @type {Element} */
2412
- /* @__PURE__ */ ne(f)
2413
- );
2414
- i = /** @type {Element} */
2415
- /* @__PURE__ */ ne(a);
2416
- }
2417
- var l = (
2418
- /** @type {TemplateNode} */
2419
- i.cloneNode(!0)
2420
- );
2421
- return K(l, l), l;
2422
- };
2423
- }
2424
- // @__NO_SIDE_EFFECTS__
2425
- function bi(e, t) {
2426
- return /* @__PURE__ */ ls(e, t, "svg");
2427
- }
2428
- function gi(e = "") {
2429
- if (!g) {
2430
- var t = U(e + "");
2431
- return K(t, t), t;
2432
- }
2433
- var n = y;
2434
- return n.nodeType !== He ? (n.before(n = U()), D(n)) : nt(
2435
- /** @type {Text} */
2436
- n
2437
- ), K(n, n), n;
2438
- }
2439
- function yi() {
2440
- if (g)
2441
- return K(y, null), y;
2442
- var e = document.createDocumentFragment(), t = document.createComment(""), n = U();
2443
- return e.append(t, n), K(t, n), e;
2444
- }
2445
- function os(e, t) {
2446
- if (g) {
2447
- var n = (
2448
- /** @type {Effect & { nodes: EffectNodes }} */
2449
- _
2450
- );
2451
- ((n.f & oe) === 0 || n.nodes.end === null) && (n.nodes.end = y), St();
2452
- return;
2453
- }
2454
- e !== null && e.before(
2455
- /** @type {Node} */
2456
- t
2457
- );
2458
- }
2459
- const us = ["touchstart", "touchmove"];
2460
- function cs(e) {
2461
- return us.includes(e);
2462
- }
2463
- let Gt = !0;
2464
- function mi(e, t) {
2465
- var n = t == null ? "" : typeof t == "object" ? `${t}` : t;
2466
- n !== (e.__t ??= e.nodeValue) && (e.__t = n, e.nodeValue = `${n}`);
2467
- }
2468
- function Gn(e, t) {
2469
- return zn(e, t);
2470
- }
2471
- function hs(e, t) {
2472
- bt(), t.intro = t.intro ?? !1;
2473
- const n = t.target, r = g, s = y;
2474
- try {
2475
- for (var i = /* @__PURE__ */ ne(n); i && (i.nodeType !== Qe || /** @type {Comment} */
2476
- i.data !== Wt); )
2477
- i = /* @__PURE__ */ re(i);
2478
- if (!i)
2479
- throw Se;
2480
- ie(!0), D(
2481
- /** @type {Comment} */
2482
- i
2483
- );
2484
- const f = zn(e, { ...t, anchor: i });
2485
- return ie(!1), /** @type {Exports} */
2486
- f;
2487
- } catch (f) {
2488
- if (f instanceof Error && f.message.split(`
2489
- `).some((a) => a.startsWith("https://svelte.dev/e/")))
2490
- throw f;
2491
- return f !== Se && console.warn("Failed to hydrate: ", f), t.recover === !1 && vr(), bt(), An(n), ie(!1), Gn(e, t);
2492
- } finally {
2493
- ie(r), D(s);
2494
- }
2495
- }
2496
- const Ye = /* @__PURE__ */ new Map();
2497
- function zn(e, { target: t, anchor: n, props: r = {}, events: s, context: i, intro: f = !0, transformError: a }) {
2498
- bt();
2499
- var l = void 0, o = Jr(() => {
2500
- var u = n ?? t.appendChild(U());
2501
- Dr(
2502
- /** @type {TemplateNode} */
2503
- u,
2504
- {
2505
- pending: () => {
2506
- }
2507
- },
2508
- (v) => {
2509
- Sr({});
2510
- var d = (
2511
- /** @type {ComponentContext} */
2512
- $
2513
- );
2514
- if (i && (d.c = i), s && (r.$$events = s), g && K(
2515
- /** @type {TemplateNode} */
2516
- v,
2517
- null
2518
- ), Gt = f, l = e(v, r) || {}, Gt = !0, g && (_.nodes.end = y, y === null || y.nodeType !== Qe || /** @type {Comment} */
2519
- y.data !== Jt))
2520
- throw et(), Se;
2521
- kr();
2522
- },
2523
- a
2524
- );
2525
- var c = /* @__PURE__ */ new Set(), h = (v) => {
2526
- for (var d = 0; d < v.length; d++) {
2527
- var m = v[d];
2528
- if (!c.has(m)) {
2529
- c.add(m);
2530
- var k = cs(m);
2531
- for (const at of [t, document]) {
2532
- var F = Ye.get(at);
2533
- F === void 0 && (F = /* @__PURE__ */ new Map(), Ye.set(at, F));
2534
- var we = F.get(m);
2535
- we === void 0 ? (at.addEventListener(m, mt, { passive: k }), F.set(m, 1)) : F.set(m, we + 1);
2536
- }
2537
- }
2538
- }
2539
- };
2540
- return h(nr(Un)), yt.add(h), () => {
2541
- for (var v of c)
2542
- for (const k of [t, document]) {
2543
- var d = (
2544
- /** @type {Map<string, number>} */
2545
- Ye.get(k)
2546
- ), m = (
2547
- /** @type {number} */
2548
- d.get(v)
2549
- );
2550
- --m == 0 ? (k.removeEventListener(v, mt), d.delete(v), d.size === 0 && Ye.delete(k)) : d.set(v, m);
2551
- }
2552
- yt.delete(h), u !== n && u.parentNode?.removeChild(u);
2553
- };
2554
- });
2555
- return wt.set(l, o), l;
2556
- }
2557
- let wt = /* @__PURE__ */ new WeakMap();
2558
- function ds(e, t) {
2559
- const n = wt.get(e);
2560
- return n ? (wt.delete(e), n(t)) : Promise.resolve();
2561
- }
2562
- class _s {
2563
- /** @type {TemplateNode} */
2564
- anchor;
2565
- /** @type {Map<Batch, Key>} */
2566
- #e = /* @__PURE__ */ new Map();
2567
- /**
2568
- * Map of keys to effects that are currently rendered in the DOM.
2569
- * These effects are visible and actively part of the document tree.
2570
- * Example:
2571
- * ```
2572
- * {#if condition}
2573
- * foo
2574
- * {:else}
2575
- * bar
2576
- * {/if}
2577
- * ```
2578
- * Can result in the entries `true->Effect` and `false->Effect`
2579
- * @type {Map<Key, Effect>}
2580
- */
2581
- #r = /* @__PURE__ */ new Map();
2582
- /**
2583
- * Similar to #onscreen with respect to the keys, but contains branches that are not yet
2584
- * in the DOM, because their insertion is deferred.
2585
- * @type {Map<Key, Branch>}
2586
- */
2587
- #t = /* @__PURE__ */ new Map();
2588
- /**
2589
- * Keys of effects that are currently outroing
2590
- * @type {Set<Key>}
2591
- */
2592
- #i = /* @__PURE__ */ new Set();
2593
- /**
2594
- * Whether to pause (i.e. outro) on change, or destroy immediately.
2595
- * This is necessary for `<svelte:element>`
2596
- */
2597
- #s = !0;
2598
- /**
2599
- * @param {TemplateNode} anchor
2600
- * @param {boolean} transition
2601
- */
2602
- constructor(t, n = !0) {
2603
- this.anchor = t, this.#s = n;
2604
- }
2605
- /**
2606
- * @param {Batch} batch
2607
- */
2608
- #a = (t) => {
2609
- if (this.#e.has(t)) {
2610
- var n = (
2611
- /** @type {Key} */
2612
- this.#e.get(t)
2613
- ), r = this.#r.get(n);
2614
- if (r)
2615
- ts(r), this.#i.delete(n);
2616
- else {
2617
- var s = this.#t.get(n);
2618
- s && (this.#r.set(n, s.effect), this.#t.delete(n), s.fragment.lastChild.remove(), this.anchor.before(s.fragment), r = s.effect);
2619
- }
2620
- for (const [i, f] of this.#e) {
2621
- if (this.#e.delete(i), i === t)
2622
- break;
2623
- const a = this.#t.get(f);
2624
- a && (x(a.effect), this.#t.delete(f));
2625
- }
2626
- for (const [i, f] of this.#r) {
2627
- if (i === n || this.#i.has(i)) continue;
2628
- const a = () => {
2629
- if (Array.from(this.#e.values()).includes(i)) {
2630
- var o = document.createDocumentFragment();
2631
- Ln(f, o), o.append(U()), this.#t.set(i, { effect: f, fragment: o });
2632
- } else
2633
- x(f);
2634
- this.#i.delete(i), this.#r.delete(i);
2635
- };
2636
- this.#s || !r ? (this.#i.add(i), Pe(f, a, !1)) : a();
2637
- }
2638
- }
2639
- };
2640
- /**
2641
- * @param {Batch} batch
2642
- */
2643
- #n = (t) => {
2644
- this.#e.delete(t);
2645
- const n = Array.from(this.#e.values());
2646
- for (const [r, s] of this.#t)
2647
- n.includes(r) || (x(s.effect), this.#t.delete(r));
2648
- };
2649
- /**
2650
- *
2651
- * @param {any} key
2652
- * @param {null | ((target: TemplateNode) => void)} fn
2653
- */
2654
- ensure(t, n) {
2655
- var r = (
2656
- /** @type {Batch} */
2657
- p
2658
- ), s = zr();
2659
- if (n && !this.#r.has(t) && !this.#t.has(t))
2660
- if (s) {
2661
- var i = document.createDocumentFragment(), f = U();
2662
- i.append(f), this.#t.set(t, {
2663
- effect: Z(() => n(f)),
2664
- fragment: i
2665
- });
2666
- } else
2667
- this.#r.set(
2668
- t,
2669
- Z(() => n(this.anchor))
2670
- );
2671
- if (this.#e.set(r, t), s) {
2672
- for (const [a, l] of this.#r)
2673
- a === t ? r.unskip_effect(l) : r.skip_effect(l);
2674
- for (const [a, l] of this.#t)
2675
- a === t ? r.unskip_effect(l.effect) : r.skip_effect(l.effect);
2676
- r.oncommit(this.#a), r.ondiscard(this.#n);
2677
- } else
2678
- g && (this.anchor = y), this.#a(r);
2679
- }
2680
- }
2681
- function wi(e, t, n = !1) {
2682
- var r;
2683
- g && (r = y, St());
2684
- var s = new _s(e), i = n ? Ne : 0;
2685
- function f(a, l) {
2686
- if (g) {
2687
- var o = Er(
2688
- /** @type {TemplateNode} */
2689
- r
2690
- );
2691
- if (a !== parseInt(o.substring(1))) {
2692
- var u = rn();
2693
- D(u), s.anchor = u, ie(!1), s.ensure(a, l), ie(!0);
2694
- return;
2695
- }
2696
- }
2697
- s.ensure(a, l);
2698
- }
2699
- On(() => {
2700
- var a = !1;
2701
- t((l, o = 0) => {
2702
- a = !0, f(o, l);
2703
- }), a || f(-1, null);
2704
- }, i);
2705
- }
2706
- function $i(e, t) {
2707
- Xr(() => {
2708
- var n = e.getRootNode(), r = (
2709
- /** @type {ShadowRoot} */
2710
- n.host ? (
2711
- /** @type {ShadowRoot} */
2712
- n
2713
- ) : (
2714
- /** @type {Document} */
2715
- n.head ?? /** @type {Document} */
2716
- n.ownerDocument.head
2717
- )
2718
- );
2719
- if (!r.querySelector("#" + t.hash)) {
2720
- const s = Ot("style");
2721
- s.id = t.hash, s.textContent = t.code, r.appendChild(s);
2722
- }
2723
- });
2724
- }
2725
- const vs = /* @__PURE__ */ Symbol("is custom element"), ps = /* @__PURE__ */ Symbol("is html"), bs = nn ? "link" : "LINK", gs = nn ? "progress" : "PROGRESS";
2726
- function Ei(e) {
2727
- if (g) {
2728
- var t = !1, n = () => {
2729
- if (!t) {
2730
- if (t = !0, e.hasAttribute("value")) {
2731
- var r = e.value;
2732
- $t(e, "value", null), e.value = r;
2733
- }
2734
- if (e.hasAttribute("checked")) {
2735
- var s = e.checked;
2736
- $t(e, "checked", null), e.checked = s;
2737
- }
2738
- }
2739
- };
2740
- e.__on_r = n, W(n), Nn();
2741
- }
2742
- }
2743
- function Ti(e, t) {
2744
- var n = It(e);
2745
- n.value === (n.value = // treat null and undefined the same for the initial value
2746
- t ?? void 0) || // @ts-expect-error
2747
- // `progress` elements always need their value set when it's `0`
2748
- e.value === t && (t !== 0 || e.nodeName !== gs) || (e.value = t ?? "");
2749
- }
2750
- function Si(e, t) {
2751
- var n = It(e);
2752
- n.checked !== (n.checked = // treat null and undefined the same for the initial value
2753
- t ?? void 0) && (e.checked = t);
2754
- }
2755
- function $t(e, t, n, r) {
2756
- var s = It(e);
2757
- g && (s[t] = e.getAttribute(t), t === "src" || t === "srcset" || t === "href" && e.nodeName === bs) || s[t] !== (s[t] = n) && (t === "loading" && (e[lr] = n), n == null ? e.removeAttribute(t) : typeof n != "string" && Wn(e).includes(t) ? e[t] = n : e.setAttribute(t, n));
2758
- }
2759
- function ki(e, t, n) {
2760
- var r = b, s = _;
2761
- let i = g;
2762
- g && ie(!1), R(null), O(null);
2763
- try {
2764
- // `style` should use `set_attribute` rather than the setter
2765
- t !== "style" && // Don't compute setters for custom elements while they aren't registered yet,
2766
- // because during their upgrade/instantiation they might add more setters.
2767
- // Instead, fall back to a simple "an object, then set as property" heuristic.
2768
- (Et.has(e.getAttribute("is") || e.nodeName) || // customElements may not be available in browser extension contexts
2769
- !customElements || customElements.get(e.getAttribute("is") || e.nodeName.toLowerCase()) ? Wn(e).includes(t) : n && typeof n == "object") ? e[t] = n : $t(e, t, n == null ? n : String(n));
2770
- } finally {
2771
- R(r), O(s), i && ie(!0);
2772
- }
2773
- }
2774
- function It(e) {
2775
- return (
2776
- /** @type {Record<string | symbol, unknown>} **/
2777
- // @ts-expect-error
2778
- e.__attributes ??= {
2779
- [vs]: e.nodeName.includes("-"),
2780
- [ps]: e.namespaceURI === Xt
2781
- }
2782
- );
2783
- }
2784
- var Et = /* @__PURE__ */ new Map();
2785
- function Wn(e) {
2786
- var t = e.getAttribute("is") || e.nodeName, n = Et.get(t);
2787
- if (n) return n;
2788
- Et.set(t, n = []);
2789
- for (var r, s = e, i = Element.prototype; i !== s; ) {
2790
- r = Zt(s);
2791
- for (var f in r)
2792
- r[f].set && n.push(f);
2793
- s = Tt(s);
2794
- }
2795
- return n;
2796
- }
2797
- function Ai(e, t, n = t) {
2798
- var r = /* @__PURE__ */ new WeakSet();
2799
- st(e, "input", async (s) => {
2800
- var i = s ? e.defaultValue : e.value;
2801
- if (i = ot(e) ? ut(i) : i, n(i), p !== null && r.add(p), await ss(), i !== (i = t())) {
2802
- var f = e.selectionStart, a = e.selectionEnd, l = e.value.length;
2803
- if (e.value = i ?? "", a !== null) {
2804
- var o = e.value.length;
2805
- f === a && a === l && o > l ? (e.selectionStart = o, e.selectionEnd = o) : (e.selectionStart = f, e.selectionEnd = Math.min(a, o));
2806
- }
2807
- }
2808
- }), // If we are hydrating and the value has since changed,
2809
- // then use the updated value from the input instead.
2810
- (g && e.defaultValue !== e.value || // If defaultValue is set, then value == defaultValue
2811
- // TODO Svelte 6: remove input.value check and set to empty string?
2812
- Ve(t) == null && e.value) && (n(ot(e) ? ut(e.value) : e.value), p !== null && r.add(p)), ue(() => {
2813
- var s = t();
2814
- if (e === document.activeElement) {
2815
- var i = (
2816
- /** @type {Batch} */
2817
- p
2818
- );
2819
- if (r.has(i))
2820
- return;
2821
- }
2822
- ot(e) && s === ut(e.value) || e.type === "date" && !s && !e.value || s !== e.value && (e.value = s ?? "");
2823
- });
2824
- }
2825
- const lt = /* @__PURE__ */ new Set();
2826
- function Ni(e, t, n, r, s = r) {
2827
- var i = n.getAttribute("type") === "checkbox", f = e;
2828
- let a = !1;
2829
- if (t !== null)
2830
- for (var l of t)
2831
- f = f[l] ??= [];
2832
- f.push(n), st(
2833
- n,
2834
- "change",
2835
- () => {
2836
- var o = n.__value;
2837
- i && (o = zt(f, o, n.checked)), s(o);
2838
- },
2839
- // TODO better default value handling
2840
- () => s(i ? [] : null)
2841
- ), ue(() => {
2842
- var o = r();
2843
- if (g && n.defaultChecked !== n.checked) {
2844
- a = !0;
2845
- return;
2846
- }
2847
- i ? (o = o || [], n.checked = o.includes(n.__value)) : n.checked = Gr(n.__value, o);
2848
- }), it(() => {
2849
- var o = f.indexOf(n);
2850
- o !== -1 && f.splice(o, 1);
2851
- }), lt.has(f) || (lt.add(f), W(() => {
2852
- f.sort((o, u) => o.compareDocumentPosition(u) === 4 ? -1 : 1), lt.delete(f);
2853
- })), W(() => {
2854
- if (a) {
2855
- var o;
2856
- if (i)
2857
- o = zt(f, o, n.checked);
2858
- else {
2859
- var u = f.find((c) => c.checked);
2860
- o = u?.__value;
2861
- }
2862
- s(o);
2863
- }
2864
- });
2865
- }
2866
- function xi(e, t, n = t) {
2867
- st(e, "change", (r) => {
2868
- var s = r ? e.defaultChecked : e.checked;
2869
- n(s);
2870
- }), // If we are hydrating and the value has since changed,
2871
- // then use the update value from the input instead.
2872
- (g && e.defaultChecked !== e.checked || // If defaultChecked is set, then checked == defaultChecked
2873
- Ve(t) == null) && n(e.checked), ue(() => {
2874
- var r = t();
2875
- e.checked = !!r;
2876
- });
2877
- }
2878
- function zt(e, t, n) {
2879
- for (var r = /* @__PURE__ */ new Set(), s = 0; s < e.length; s += 1)
2880
- e[s].checked && r.add(e[s].__value);
2881
- return n || r.delete(t), Array.from(r);
2882
- }
2883
- function ot(e) {
2884
- var t = e.type;
2885
- return t === "number" || t === "range";
2886
- }
2887
- function ut(e) {
2888
- return e === "" ? null : +e;
2889
- }
2890
- function Ri(e, t, n = t) {
2891
- st(e, "change", () => {
2892
- n(e.files);
2893
- }), // If we are hydrating and the value has since changed,
2894
- // then use the updated value from the input instead.
2895
- g && e.files && n(e.files), ue(() => {
2896
- e.files = t();
2897
- });
2898
- }
2899
- function ys(e) {
2900
- return new ms(e);
2901
- }
2902
- class ms {
2903
- /** @type {any} */
2904
- #e;
2905
- /** @type {Record<string, any>} */
2906
- #r;
2907
- /**
2908
- * @param {ComponentConstructorOptions & {
2909
- * component: any;
2910
- * }} options
2911
- */
2912
- constructor(t) {
2913
- var n = /* @__PURE__ */ new Map(), r = (i, f) => {
2914
- var a = /* @__PURE__ */ $n(f, !1, !1);
2915
- return n.set(i, a), a;
2916
- };
2917
- const s = new Proxy(
2918
- { ...t.props || {}, $$events: {} },
2919
- {
2920
- get(i, f) {
2921
- return q(n.get(f) ?? r(f, Reflect.get(i, f)));
2922
- },
2923
- has(i, f) {
2924
- return f === fr ? !0 : (q(n.get(f) ?? r(f, Reflect.get(i, f))), Reflect.has(i, f));
2925
- },
2926
- set(i, f, a) {
2927
- return G(n.get(f) ?? r(f, a), a), Reflect.set(i, f, a);
2928
- }
2929
- }
2930
- );
2931
- this.#r = (t.hydrate ? hs : Gn)(t.component, {
2932
- target: t.target,
2933
- anchor: t.anchor,
2934
- props: s,
2935
- context: t.context,
2936
- intro: t.intro ?? !1,
2937
- recover: t.recover,
2938
- transformError: t.transformError
2939
- }), (!t?.props?.$$host || t.sync === !1) && _n(), this.#e = s.$$events;
2940
- for (const i of Object.keys(this.#r))
2941
- i === "$set" || i === "$destroy" || i === "$on" || Le(this, i, {
2942
- get() {
2943
- return this.#r[i];
2944
- },
2945
- /** @param {any} value */
2946
- set(f) {
2947
- this.#r[i] = f;
2948
- },
2949
- enumerable: !0
2950
- });
2951
- this.#r.$set = /** @param {Record<string, any>} next */
2952
- (i) => {
2953
- Object.assign(s, i);
2954
- }, this.#r.$destroy = () => {
2955
- ds(this.#r);
2956
- };
2957
- }
2958
- /** @param {Record<string, any>} props */
2959
- $set(t) {
2960
- this.#r.$set(t);
2961
- }
2962
- /**
2963
- * @param {string} event
2964
- * @param {(...args: any[]) => any} callback
2965
- * @returns {any}
2966
- */
2967
- $on(t, n) {
2968
- this.#e[t] = this.#e[t] || [];
2969
- const r = (...s) => n.call(this, ...s);
2970
- return this.#e[t].push(r), () => {
2971
- this.#e[t] = this.#e[t].filter(
2972
- /** @param {any} fn */
2973
- (s) => s !== r
2974
- );
2975
- };
2976
- }
2977
- $destroy() {
2978
- this.#r.$destroy();
2979
- }
2980
- }
2981
- let Kn;
2982
- typeof HTMLElement == "function" && (Kn = class extends HTMLElement {
2983
- /** The Svelte component constructor */
2984
- $$ctor;
2985
- /** Slots */
2986
- $$s;
2987
- /** @type {any} The Svelte component instance */
2988
- $$c;
2989
- /** Whether or not the custom element is connected */
2990
- $$cn = !1;
2991
- /** @type {Record<string, any>} Component props data */
2992
- $$d = {};
2993
- /** `true` if currently in the process of reflecting component props back to attributes */
2994
- $$r = !1;
2995
- /** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
2996
- $$p_d = {};
2997
- /** @type {Record<string, EventListenerOrEventListenerObject[]>} Event listeners */
2998
- $$l = {};
2999
- /** @type {Map<EventListenerOrEventListenerObject, Function>} Event listener unsubscribe functions */
3000
- $$l_u = /* @__PURE__ */ new Map();
3001
- /** @type {any} The managed render effect for reflecting attributes */
3002
- $$me;
3003
- /** @type {ShadowRoot | null} The ShadowRoot of the custom element */
3004
- $$shadowRoot = null;
3005
- /**
3006
- * @param {*} $$componentCtor
3007
- * @param {*} $$slots
3008
- * @param {ShadowRootInit | undefined} shadow_root_init
3009
- */
3010
- constructor(e, t, n) {
3011
- super(), this.$$ctor = e, this.$$s = t, n && (this.$$shadowRoot = this.attachShadow(n));
3012
- }
3013
- /**
3014
- * @param {string} type
3015
- * @param {EventListenerOrEventListenerObject} listener
3016
- * @param {boolean | AddEventListenerOptions} [options]
3017
- */
3018
- addEventListener(e, t, n) {
3019
- if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) {
3020
- const r = this.$$c.$on(e, t);
3021
- this.$$l_u.set(t, r);
3022
- }
3023
- super.addEventListener(e, t, n);
3024
- }
3025
- /**
3026
- * @param {string} type
3027
- * @param {EventListenerOrEventListenerObject} listener
3028
- * @param {boolean | AddEventListenerOptions} [options]
3029
- */
3030
- removeEventListener(e, t, n) {
3031
- if (super.removeEventListener(e, t, n), this.$$c) {
3032
- const r = this.$$l_u.get(t);
3033
- r && (r(), this.$$l_u.delete(t));
3034
- }
3035
- }
3036
- async connectedCallback() {
3037
- if (this.$$cn = !0, !this.$$c) {
3038
- let e = function(r) {
3039
- return (s) => {
3040
- const i = Ot("slot");
3041
- r !== "default" && (i.name = r), os(s, i);
3042
- };
3043
- };
3044
- if (await Promise.resolve(), !this.$$cn || this.$$c)
3045
- return;
3046
- const t = {}, n = ws(this);
3047
- for (const r of this.$$s)
3048
- r in n && (r === "default" && !this.$$d.children ? (this.$$d.children = e(r), t.default = !0) : t[r] = e(r));
3049
- for (const r of this.attributes) {
3050
- const s = this.$$g_p(r.name);
3051
- s in this.$$d || (this.$$d[s] = We(s, r.value, this.$$p_d, "toProp"));
3052
- }
3053
- for (const r in this.$$p_d)
3054
- !(r in this.$$d) && this[r] !== void 0 && (this.$$d[r] = this[r], delete this[r]);
3055
- this.$$c = ys({
3056
- component: this.$$ctor,
3057
- target: this.$$shadowRoot || this,
3058
- props: {
3059
- ...this.$$d,
3060
- $$slots: t,
3061
- $$host: this
3062
- }
3063
- }), this.$$me = Kr(() => {
3064
- ue(() => {
3065
- this.$$r = !0;
3066
- for (const r of Ke(this.$$c)) {
3067
- if (!this.$$p_d[r]?.reflect) continue;
3068
- this.$$d[r] = this.$$c[r];
3069
- const s = We(
3070
- r,
3071
- this.$$d[r],
3072
- this.$$p_d,
3073
- "toAttribute"
3074
- );
3075
- s == null ? this.removeAttribute(this.$$p_d[r].attribute || r) : this.setAttribute(this.$$p_d[r].attribute || r, s);
3076
- }
3077
- this.$$r = !1;
3078
- });
3079
- });
3080
- for (const r in this.$$l)
3081
- for (const s of this.$$l[r]) {
3082
- const i = this.$$c.$on(r, s);
3083
- this.$$l_u.set(s, i);
3084
- }
3085
- this.$$l = {};
3086
- }
3087
- }
3088
- // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
3089
- // and setting attributes through setAttribute etc, this is helpful
3090
- /**
3091
- * @param {string} attr
3092
- * @param {string} _oldValue
3093
- * @param {string} newValue
3094
- */
3095
- attributeChangedCallback(e, t, n) {
3096
- this.$$r || (e = this.$$g_p(e), this.$$d[e] = We(e, n, this.$$p_d, "toProp"), this.$$c?.$set({ [e]: this.$$d[e] }));
3097
- }
3098
- disconnectedCallback() {
3099
- this.$$cn = !1, Promise.resolve().then(() => {
3100
- !this.$$cn && this.$$c && (this.$$c.$destroy(), this.$$me(), this.$$c = void 0);
3101
- });
3102
- }
3103
- /**
3104
- * @param {string} attribute_name
3105
- */
3106
- $$g_p(e) {
3107
- return Ke(this.$$p_d).find(
3108
- (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e
3109
- ) || e;
3110
- }
3111
- });
3112
- function We(e, t, n, r) {
3113
- const s = n[e]?.type;
3114
- if (t = s === "Boolean" && typeof t != "boolean" ? t != null : t, !r || !n[e])
3115
- return t;
3116
- if (r === "toAttribute")
3117
- switch (s) {
3118
- case "Object":
3119
- case "Array":
3120
- return t == null ? null : JSON.stringify(t);
3121
- case "Boolean":
3122
- return t ? "" : null;
3123
- case "Number":
3124
- return t ?? null;
3125
- default:
3126
- return t;
3127
- }
3128
- else
3129
- switch (s) {
3130
- case "Object":
3131
- case "Array":
3132
- return t && JSON.parse(t);
3133
- case "Boolean":
3134
- return t;
3135
- // conversion already handled above
3136
- case "Number":
3137
- return t != null ? +t : t;
3138
- default:
3139
- return t;
3140
- }
3141
- }
3142
- function ws(e) {
3143
- const t = {};
3144
- return e.childNodes.forEach((n) => {
3145
- t[
3146
- /** @type {Element} node */
3147
- n.slot || "default"
3148
- ] = !0;
3149
- }), t;
3150
- }
3151
- function Oi(e, t, n, r, s, i) {
3152
- let f = class extends Kn {
3153
- constructor() {
3154
- super(e, n, s), this.$$p_d = t;
3155
- }
3156
- static get observedAttributes() {
3157
- return Ke(t).map(
3158
- (a) => (t[a].attribute || a).toLowerCase()
3159
- );
3160
- }
3161
- };
3162
- return Ke(t).forEach((a) => {
3163
- Le(f.prototype, a, {
3164
- get() {
3165
- return this.$$c && a in this.$$c ? this.$$c[a] : this.$$d[a];
3166
- },
3167
- set(l) {
3168
- l = We(a, l, t), this.$$d[a] = l;
3169
- var o = this.$$c;
3170
- if (o) {
3171
- var u = Te(o, a)?.get;
3172
- u ? o[a] = l : o.$set({ [a]: l });
3173
- }
3174
- }
3175
- });
3176
- }), r.forEach((a) => {
3177
- Le(f.prototype, a, {
3178
- get() {
3179
- return this.$$c?.[a];
3180
- }
3181
- });
3182
- }), e.element = /** @type {any} */
3183
- f, f;
3184
- }
3185
- export {
3186
- wi as $,
3187
- re as A,
3188
- _s as B,
3189
- Qe as C,
3190
- ne as D,
3191
- Ne as E,
3192
- ue as F,
3193
- ci as G,
3194
- Wt as H,
3195
- an as I,
3196
- st as J,
3197
- p as K,
3198
- it as L,
3199
- Us as M,
3200
- Gr as N,
3201
- $ as O,
3202
- fi as P,
3203
- ai as Q,
3204
- oe as R,
3205
- Fs as S,
3206
- Is as T,
3207
- ir as U,
3208
- q as V,
3209
- xt as W,
3210
- vi as X,
3211
- Oi as Y,
3212
- $i as Z,
3213
- ri as _,
3214
- qe as a,
3215
- ts as a$,
3216
- ui as a0,
3217
- _i as a1,
3218
- di as a2,
3219
- os as a3,
3220
- kr as a4,
3221
- pi as a5,
3222
- Sr as a6,
3223
- si as a7,
3224
- se as a8,
3225
- ei as a9,
3226
- Qt as aA,
3227
- Gs as aB,
3228
- Zs as aC,
3229
- Js as aD,
3230
- Xs as aE,
3231
- Rr as aF,
3232
- li as aG,
3233
- oi as aH,
3234
- $n as aI,
3235
- Br as aJ,
3236
- Ks as aK,
3237
- Qn as aL,
3238
- Ni as aM,
3239
- or as aN,
3240
- tt as aO,
3241
- Ze as aP,
3242
- Z as aQ,
3243
- Bs as aR,
3244
- zr as aS,
3245
- nr as aT,
3246
- Es as aU,
3247
- Be as aV,
3248
- $s as aW,
3249
- ks as aX,
3250
- Hs as aY,
3251
- Ts as aZ,
3252
- B as a_,
3253
- ni as aa,
3254
- _n as ab,
3255
- Ys as ac,
3256
- G as ad,
3257
- $t as ae,
3258
- mi as af,
3259
- Ei as ag,
3260
- Si as ah,
3261
- Ti as ai,
3262
- Ai as aj,
3263
- gi as ak,
3264
- $r as al,
3265
- yi as am,
3266
- ki as an,
3267
- Oe as ao,
3268
- zs as ap,
3269
- Ws as aq,
3270
- ii as ar,
3271
- qt as as,
3272
- hi as at,
3273
- Ri as au,
3274
- bi as av,
3275
- ss as aw,
3276
- ti as ax,
3277
- js as ay,
3278
- xi as az,
3279
- On as b,
3280
- Pe as b0,
3281
- P as b1,
3282
- J as b2,
3283
- Ss as b3,
3284
- An as b4,
3285
- Ln as b5,
3286
- x as b6,
3287
- Kt as b7,
3288
- Jt as b8,
3289
- K as b9,
3290
- es as ba,
3291
- et as bb,
3292
- Se as bc,
3293
- Ot as bd,
3294
- Ps as be,
3295
- Ls as bf,
3296
- Dt as bg,
3297
- ve as bh,
3298
- Kr as bi,
3299
- le as bj,
3300
- fr as bk,
3301
- Te as bl,
3302
- Qs as bm,
3303
- Vs as bn,
3304
- xs as bo,
3305
- As as bp,
3306
- Rs as bq,
3307
- Ns as br,
3308
- Os as bs,
3309
- St as c,
3310
- D as d,
3311
- ie as e,
3312
- y as f,
3313
- Tt as g,
3314
- g as h,
3315
- er as i,
3316
- _ as j,
3317
- z as k,
3318
- Xr as l,
3319
- Ds as m,
3320
- _e as n,
3321
- rr as o,
3322
- Gt as p,
3323
- W as q,
3324
- Er as r,
3325
- rn as s,
3326
- Ms as t,
3327
- Ve as u,
3328
- Cs as v,
3329
- rt as w,
3330
- U as x,
3331
- ar as y,
3332
- me as z
3333
- };