@pie-players/pie-tool-calculator-desmos 0.3.3

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