@pie-players/pie-section-player-tools-shared 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.
package/dist/index.js ADDED
@@ -0,0 +1,1562 @@
1
+ var Je = Object.defineProperty;
2
+ var ce = (t) => {
3
+ throw TypeError(t);
4
+ };
5
+ var Qe = (t, e, n) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
+ var z = (t, e, n) => Qe(t, typeof e != "symbol" ? e + "" : e, n), qt = (t, e, n) => e.has(t) || ce("Cannot " + n);
7
+ var o = (t, e, n) => (qt(t, e, "read from private field"), n ? n.call(t) : e.get(t)), w = (t, e, n) => e.has(t) ? ce("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), X = (t, e, n, s) => (qt(t, e, "write to private field"), s ? s.call(t, n) : e.set(t, n), n), j = (t, e, n) => (qt(t, e, "access private method"), n);
8
+ var ge;
9
+ typeof window < "u" && ((ge = window.__svelte ?? (window.__svelte = {})).v ?? (ge.v = /* @__PURE__ */ new Set())).add("5");
10
+ const $e = 1, tn = 2, Ot = /* @__PURE__ */ Symbol(), be = "http://www.w3.org/1999/xhtml", Gt = !1;
11
+ var en = Array.prototype.indexOf, gt = Array.prototype.includes, nn = Object.getOwnPropertyDescriptors, rn = Object.getPrototypeOf;
12
+ const sn = () => {
13
+ };
14
+ function ln(t) {
15
+ for (var e = 0; e < t.length; e++)
16
+ t[e]();
17
+ }
18
+ function Ee() {
19
+ var t, e, n = new Promise((s, r) => {
20
+ t = s, e = r;
21
+ });
22
+ return { promise: n, resolve: t, reject: e };
23
+ }
24
+ const E = 2, Xt = 4, bt = 8, ie = 1 << 24, st = 16, W = 32, wt = 64, on = 128, D = 512, g = 1024, b = 2048, Y = 4096, F = 8192, Z = 16384, Mt = 32768, Et = 65536, fn = 1 << 18, jt = 1 << 19, rt = 65536, Kt = 1 << 21, xe = 1 << 22, G = 1 << 23, Q = new class extends Error {
25
+ constructor() {
26
+ super(...arguments);
27
+ z(this, "name", "StaleReactionError");
28
+ z(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed");
29
+ }
30
+ }();
31
+ function an() {
32
+ throw new Error("https://svelte.dev/e/async_derived_orphan");
33
+ }
34
+ function un() {
35
+ throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
36
+ }
37
+ function ye(t) {
38
+ return t === this.v;
39
+ }
40
+ let cn = !1, St = null;
41
+ function Dt(t) {
42
+ St = t;
43
+ }
44
+ function hn() {
45
+ return !0;
46
+ }
47
+ let it = [];
48
+ function vn() {
49
+ var t = it;
50
+ it = [], ln(t);
51
+ }
52
+ function he(t) {
53
+ if (it.length === 0) {
54
+ var e = it;
55
+ queueMicrotask(() => {
56
+ e === it && vn();
57
+ });
58
+ }
59
+ it.push(t);
60
+ }
61
+ function dn(t) {
62
+ var e = _;
63
+ if (e === null)
64
+ return v.f |= G, t;
65
+ if ((e.f & Mt) === 0 && (e.f & Xt) === 0)
66
+ throw t;
67
+ Ft(t, e);
68
+ }
69
+ function Ft(t, e) {
70
+ for (; e !== null; ) {
71
+ if ((e.f & on) !== 0) {
72
+ if ((e.f & Mt) === 0)
73
+ throw t;
74
+ try {
75
+ e.b.error(t);
76
+ return;
77
+ } catch (n) {
78
+ t = n;
79
+ }
80
+ }
81
+ e = e.parent;
82
+ }
83
+ throw t;
84
+ }
85
+ const _n = -7169;
86
+ function m(t, e) {
87
+ t.f = t.f & _n | e;
88
+ }
89
+ function le(t) {
90
+ (t.f & D) !== 0 || t.deps === null ? m(t, g) : m(t, Y);
91
+ }
92
+ function ke(t) {
93
+ if (t !== null)
94
+ for (const e of t)
95
+ (e.f & E) === 0 || (e.f & rt) === 0 || (e.f ^= rt, ke(
96
+ /** @type {Derived} */
97
+ e.deps
98
+ ));
99
+ }
100
+ function pn(t, e, n) {
101
+ (t.f & b) !== 0 ? e.add(t) : (t.f & Y) !== 0 && n.add(t), ke(t.deps), m(t, g);
102
+ }
103
+ const At = /* @__PURE__ */ new Set();
104
+ let p = null, I = null, N = [], oe = null, ht = null, mn = 1;
105
+ var B, ot, tt, ft, at, ut, U, L, ct, k, Jt, Qt, $t, te;
106
+ const ue = class ue {
107
+ constructor() {
108
+ w(this, k);
109
+ // for debugging. TODO remove once async is stable
110
+ z(this, "id", mn++);
111
+ /**
112
+ * The current values of any sources that are updated in this batch
113
+ * They keys of this map are identical to `this.#previous`
114
+ * @type {Map<Source, any>}
115
+ */
116
+ z(this, "current", /* @__PURE__ */ new Map());
117
+ /**
118
+ * The values of any sources that are updated in this batch _before_ those updates took place.
119
+ * They keys of this map are identical to `this.#current`
120
+ * @type {Map<Source, any>}
121
+ */
122
+ z(this, "previous", /* @__PURE__ */ new Map());
123
+ /**
124
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
125
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
126
+ * @type {Set<(batch: Batch) => void>}
127
+ */
128
+ w(this, B, /* @__PURE__ */ new Set());
129
+ /**
130
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
131
+ * @type {Set<(batch: Batch) => void>}
132
+ */
133
+ w(this, ot, /* @__PURE__ */ new Set());
134
+ /**
135
+ * The number of async effects that are currently in flight
136
+ */
137
+ w(this, tt, 0);
138
+ /**
139
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
140
+ */
141
+ w(this, ft, 0);
142
+ /**
143
+ * A deferred that resolves when the batch is committed, used with `settled()`
144
+ * TODO replace with Promise.withResolvers once supported widely enough
145
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
146
+ */
147
+ w(this, at, null);
148
+ /**
149
+ * Deferred effects (which run after async work has completed) that are DIRTY
150
+ * @type {Set<Effect>}
151
+ */
152
+ w(this, ut, /* @__PURE__ */ new Set());
153
+ /**
154
+ * Deferred effects that are MAYBE_DIRTY
155
+ * @type {Set<Effect>}
156
+ */
157
+ w(this, U, /* @__PURE__ */ new Set());
158
+ /**
159
+ * A map of branches that still exist, but will be destroyed when this batch
160
+ * is committed — we skip over these during `process`.
161
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
162
+ * so they can be rescheduled if the branch survives.
163
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
164
+ */
165
+ w(this, L, /* @__PURE__ */ new Map());
166
+ z(this, "is_fork", !1);
167
+ w(this, ct, !1);
168
+ }
169
+ /**
170
+ * Add an effect to the #skipped_branches map and reset its children
171
+ * @param {Effect} effect
172
+ */
173
+ skip_effect(e) {
174
+ o(this, L).has(e) || o(this, L).set(e, { d: [], m: [] });
175
+ }
176
+ /**
177
+ * Remove an effect from the #skipped_branches map and reschedule
178
+ * any tracked dirty/maybe_dirty child effects
179
+ * @param {Effect} effect
180
+ */
181
+ unskip_effect(e) {
182
+ var n = o(this, L).get(e);
183
+ if (n) {
184
+ o(this, L).delete(e);
185
+ for (var s of n.d)
186
+ m(s, b), q(s);
187
+ for (s of n.m)
188
+ m(s, Y), q(s);
189
+ }
190
+ }
191
+ /**
192
+ *
193
+ * @param {Effect[]} root_effects
194
+ */
195
+ process(e) {
196
+ N = [], this.apply();
197
+ var n = ht = [], s = [];
198
+ for (const r of e)
199
+ j(this, k, Qt).call(this, r, n, s);
200
+ if (ht = null, j(this, k, Jt).call(this)) {
201
+ j(this, k, $t).call(this, s), j(this, k, $t).call(this, n);
202
+ for (const [r, i] of o(this, L))
203
+ Te(r, i);
204
+ } else {
205
+ p = null;
206
+ for (const r of o(this, B)) r(this);
207
+ o(this, B).clear(), o(this, tt) === 0 && j(this, k, te).call(this), ve(s), ve(n), o(this, ut).clear(), o(this, U).clear(), o(this, at)?.resolve();
208
+ }
209
+ I = null;
210
+ }
211
+ /**
212
+ * Associate a change to a given source with the current
213
+ * batch, noting its previous and current values
214
+ * @param {Source} source
215
+ * @param {any} value
216
+ */
217
+ capture(e, n) {
218
+ n !== Ot && !this.previous.has(e) && this.previous.set(e, n), (e.f & G) === 0 && (this.current.set(e, e.v), I?.set(e, e.v));
219
+ }
220
+ activate() {
221
+ p = this, this.apply();
222
+ }
223
+ deactivate() {
224
+ p === this && (p = null, I = null);
225
+ }
226
+ flush() {
227
+ if (N.length > 0)
228
+ p = this, wn();
229
+ else if (o(this, tt) === 0 && !this.is_fork) {
230
+ for (const e of o(this, B)) e(this);
231
+ o(this, B).clear(), j(this, k, te).call(this), o(this, at)?.resolve();
232
+ }
233
+ this.deactivate();
234
+ }
235
+ discard() {
236
+ for (const e of o(this, ot)) e(this);
237
+ o(this, ot).clear();
238
+ }
239
+ /**
240
+ *
241
+ * @param {boolean} blocking
242
+ */
243
+ increment(e) {
244
+ X(this, tt, o(this, tt) + 1), e && X(this, ft, o(this, ft) + 1);
245
+ }
246
+ /**
247
+ *
248
+ * @param {boolean} blocking
249
+ */
250
+ decrement(e) {
251
+ X(this, tt, o(this, tt) - 1), e && X(this, ft, o(this, ft) - 1), !o(this, ct) && (X(this, ct, !0), he(() => {
252
+ X(this, ct, !1), j(this, k, Jt).call(this) ? N.length > 0 && this.flush() : this.revive();
253
+ }));
254
+ }
255
+ revive() {
256
+ for (const e of o(this, ut))
257
+ o(this, U).delete(e), m(e, b), q(e);
258
+ for (const e of o(this, U))
259
+ m(e, Y), q(e);
260
+ this.flush();
261
+ }
262
+ /** @param {(batch: Batch) => void} fn */
263
+ oncommit(e) {
264
+ o(this, B).add(e);
265
+ }
266
+ /** @param {(batch: Batch) => void} fn */
267
+ ondiscard(e) {
268
+ o(this, ot).add(e);
269
+ }
270
+ settled() {
271
+ return (o(this, at) ?? X(this, at, Ee())).promise;
272
+ }
273
+ static ensure() {
274
+ if (p === null) {
275
+ const e = p = new ue();
276
+ At.add(p), he(() => {
277
+ p === e && e.flush();
278
+ });
279
+ }
280
+ return p;
281
+ }
282
+ apply() {
283
+ }
284
+ };
285
+ B = new WeakMap(), ot = new WeakMap(), tt = new WeakMap(), ft = new WeakMap(), at = new WeakMap(), ut = new WeakMap(), U = new WeakMap(), L = new WeakMap(), ct = new WeakMap(), k = new WeakSet(), Jt = function() {
286
+ return this.is_fork || o(this, ft) > 0;
287
+ }, /**
288
+ * Traverse the effect tree, executing effects or stashing
289
+ * them for later execution as appropriate
290
+ * @param {Effect} root
291
+ * @param {Effect[]} effects
292
+ * @param {Effect[]} render_effects
293
+ */
294
+ Qt = function(e, n, s) {
295
+ e.f ^= g;
296
+ for (var r = e.first; r !== null; ) {
297
+ var i = r.f, l = (i & (W | wt)) !== 0, f = l && (i & g) !== 0, a = (i & F) !== 0, c = f || o(this, L).has(r);
298
+ if (!c && r.fn !== null) {
299
+ l ? a || (r.f ^= g) : (i & Xt) !== 0 ? n.push(r) : (i & (bt | ie)) !== 0 && a ? s.push(r) : Ct(r) && (mt(r), (i & st) !== 0 && (o(this, U).add(r), a && m(r, b)));
300
+ var h = r.first;
301
+ if (h !== null) {
302
+ r = h;
303
+ continue;
304
+ }
305
+ }
306
+ for (; r !== null; ) {
307
+ var u = r.next;
308
+ if (u !== null) {
309
+ r = u;
310
+ break;
311
+ }
312
+ r = r.parent;
313
+ }
314
+ }
315
+ }, /**
316
+ * @param {Effect[]} effects
317
+ */
318
+ $t = function(e) {
319
+ for (var n = 0; n < e.length; n += 1)
320
+ pn(e[n], o(this, ut), o(this, U));
321
+ }, te = function() {
322
+ var i;
323
+ if (At.size > 1) {
324
+ this.previous.clear();
325
+ var e = p, n = I, s = !0;
326
+ for (const l of At) {
327
+ if (l === this) {
328
+ s = !1;
329
+ continue;
330
+ }
331
+ const f = [];
332
+ for (const [c, h] of this.current) {
333
+ if (l.current.has(c))
334
+ if (s && h !== l.current.get(c))
335
+ l.current.set(c, h);
336
+ else
337
+ continue;
338
+ f.push(c);
339
+ }
340
+ if (f.length === 0)
341
+ continue;
342
+ const a = [...l.current.keys()].filter((c) => !this.current.has(c));
343
+ if (a.length > 0) {
344
+ var r = N;
345
+ N = [];
346
+ const c = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
347
+ for (const u of f)
348
+ Me(u, a, c, h);
349
+ if (N.length > 0) {
350
+ p = l, l.apply();
351
+ for (const u of N)
352
+ j(i = l, k, Qt).call(i, u, [], []);
353
+ l.deactivate();
354
+ }
355
+ N = r;
356
+ }
357
+ }
358
+ p = e, I = n;
359
+ }
360
+ o(this, L).clear(), At.delete(this);
361
+ };
362
+ let Pt = ue;
363
+ function wn() {
364
+ var t = null;
365
+ try {
366
+ for (var e = 0; N.length > 0; ) {
367
+ var n = Pt.ensure();
368
+ if (e++ > 1e3) {
369
+ var s, r;
370
+ gn();
371
+ }
372
+ n.process(N), K.clear();
373
+ }
374
+ } finally {
375
+ N = [], oe = null, ht = null;
376
+ }
377
+ }
378
+ function gn() {
379
+ try {
380
+ un();
381
+ } catch (t) {
382
+ Ft(t, oe);
383
+ }
384
+ }
385
+ let V = null;
386
+ function ve(t) {
387
+ var e = t.length;
388
+ if (e !== 0) {
389
+ for (var n = 0; n < e; ) {
390
+ var s = t[n++];
391
+ if ((s.f & (Z | F)) === 0 && Ct(s) && (V = /* @__PURE__ */ new Set(), mt(s), s.deps === null && s.first === null && s.nodes === null && s.teardown === null && s.ac === null && He(s), V?.size > 0)) {
392
+ K.clear();
393
+ for (const r of V) {
394
+ if ((r.f & (Z | F)) !== 0) continue;
395
+ const i = [r];
396
+ let l = r.parent;
397
+ for (; l !== null; )
398
+ V.has(l) && (V.delete(l), i.push(l)), l = l.parent;
399
+ for (let f = i.length - 1; f >= 0; f--) {
400
+ const a = i[f];
401
+ (a.f & (Z | F)) === 0 && mt(a);
402
+ }
403
+ }
404
+ V.clear();
405
+ }
406
+ }
407
+ V = null;
408
+ }
409
+ }
410
+ function Me(t, e, n, s) {
411
+ if (!n.has(t) && (n.add(t), t.reactions !== null))
412
+ for (const r of t.reactions) {
413
+ const i = r.f;
414
+ (i & E) !== 0 ? Me(
415
+ /** @type {Derived} */
416
+ r,
417
+ e,
418
+ n,
419
+ s
420
+ ) : (i & (xe | st)) !== 0 && (i & b) === 0 && Se(r, e, s) && (m(r, b), q(
421
+ /** @type {Effect} */
422
+ r
423
+ ));
424
+ }
425
+ }
426
+ function Se(t, e, n) {
427
+ const s = n.get(t);
428
+ if (s !== void 0) return s;
429
+ if (t.deps !== null)
430
+ for (const r of t.deps) {
431
+ if (gt.call(e, r))
432
+ return !0;
433
+ if ((r.f & E) !== 0 && Se(
434
+ /** @type {Derived} */
435
+ r,
436
+ e,
437
+ n
438
+ ))
439
+ return n.set(
440
+ /** @type {Derived} */
441
+ r,
442
+ !0
443
+ ), !0;
444
+ }
445
+ return n.set(t, !1), !1;
446
+ }
447
+ function q(t) {
448
+ var e = oe = t, n = e.b;
449
+ if (n?.is_pending && (t.f & (Xt | bt | ie)) !== 0 && (t.f & Mt) === 0) {
450
+ n.defer_effect(t);
451
+ return;
452
+ }
453
+ for (; e.parent !== null; ) {
454
+ e = e.parent;
455
+ var s = e.f;
456
+ if (ht !== null && e === _ && (t.f & bt) === 0)
457
+ return;
458
+ if ((s & (wt | W)) !== 0) {
459
+ if ((s & g) === 0)
460
+ return;
461
+ e.f ^= g;
462
+ }
463
+ }
464
+ N.push(e);
465
+ }
466
+ function Te(t, e) {
467
+ if (!((t.f & W) !== 0 && (t.f & g) !== 0)) {
468
+ (t.f & b) !== 0 ? e.d.push(t) : (t.f & Y) !== 0 && e.m.push(t), m(t, g);
469
+ for (var n = t.first; n !== null; )
470
+ Te(n, e), n = n.next;
471
+ }
472
+ }
473
+ function bn(t, e, n, s) {
474
+ const r = yn;
475
+ var i = t.filter((u) => !u.settled);
476
+ if (n.length === 0 && i.length === 0) {
477
+ s(e.map(r));
478
+ return;
479
+ }
480
+ var l = (
481
+ /** @type {Effect} */
482
+ _
483
+ ), f = En(), a = i.length === 1 ? i[0].promise : i.length > 1 ? Promise.all(i.map((u) => u.promise)) : null;
484
+ function c(u) {
485
+ f();
486
+ try {
487
+ s(u);
488
+ } catch (x) {
489
+ (l.f & Z) === 0 && Ft(x, l);
490
+ }
491
+ ee();
492
+ }
493
+ if (n.length === 0) {
494
+ a.then(() => c(e.map(r)));
495
+ return;
496
+ }
497
+ function h() {
498
+ f(), Promise.all(n.map((u) => /* @__PURE__ */ kn(u))).then((u) => c([...e.map(r), ...u])).catch((u) => Ft(u, l));
499
+ }
500
+ a ? a.then(h) : h();
501
+ }
502
+ function En() {
503
+ var t = _, e = v, n = St, s = p;
504
+ return function(i = !0) {
505
+ pt(t), _t(e), Dt(n), i && s?.activate();
506
+ };
507
+ }
508
+ function ee(t = !0) {
509
+ pt(null), _t(null), Dt(null), t && p?.deactivate();
510
+ }
511
+ function xn() {
512
+ var t = (
513
+ /** @type {Boundary} */
514
+ /** @type {Effect} */
515
+ _.b
516
+ ), e = (
517
+ /** @type {Batch} */
518
+ p
519
+ ), n = t.is_rendered();
520
+ return t.update_pending_count(1), e.increment(n), () => {
521
+ t.update_pending_count(-1), e.decrement(n);
522
+ };
523
+ }
524
+ // @__NO_SIDE_EFFECTS__
525
+ function yn(t) {
526
+ var e = E | b, n = v !== null && (v.f & E) !== 0 ? (
527
+ /** @type {Derived} */
528
+ v
529
+ ) : null;
530
+ return _ !== null && (_.f |= jt), {
531
+ ctx: St,
532
+ deps: null,
533
+ effects: null,
534
+ equals: ye,
535
+ f: e,
536
+ fn: t,
537
+ reactions: null,
538
+ rv: 0,
539
+ v: (
540
+ /** @type {V} */
541
+ Ot
542
+ ),
543
+ wv: 0,
544
+ parent: n ?? _,
545
+ ac: null
546
+ };
547
+ }
548
+ // @__NO_SIDE_EFFECTS__
549
+ function kn(t, e, n) {
550
+ /** @type {Effect | null} */
551
+ _ === null && an();
552
+ var r = (
553
+ /** @type {Promise<V>} */
554
+ /** @type {unknown} */
555
+ void 0
556
+ ), i = Cn(
557
+ /** @type {V} */
558
+ Ot
559
+ ), l = !v, f = /* @__PURE__ */ new Map();
560
+ return On(() => {
561
+ var a = Ee();
562
+ r = a.promise;
563
+ try {
564
+ Promise.resolve(t()).then(a.resolve, a.reject).finally(ee);
565
+ } catch (x) {
566
+ a.reject(x), ee();
567
+ }
568
+ var c = (
569
+ /** @type {Batch} */
570
+ p
571
+ );
572
+ if (l) {
573
+ var h = xn();
574
+ f.get(c)?.reject(Q), f.delete(c), f.set(c, a);
575
+ }
576
+ const u = (x, d = void 0) => {
577
+ if (c.activate(), d)
578
+ d !== Q && (i.f |= G, de(i, d));
579
+ else {
580
+ (i.f & G) !== 0 && (i.f ^= G), de(i, x);
581
+ for (const [O, M] of f) {
582
+ if (f.delete(O), O === c) break;
583
+ M.reject(Q);
584
+ }
585
+ }
586
+ h && h();
587
+ };
588
+ a.promise.then(u, (x) => u(null, x || "unknown"));
589
+ }), Yn(() => {
590
+ for (const a of f.values())
591
+ a.reject(Q);
592
+ }), new Promise((a) => {
593
+ function c(h) {
594
+ function u() {
595
+ h === r ? a(i) : c(r);
596
+ }
597
+ h.then(u, u);
598
+ }
599
+ c(r);
600
+ });
601
+ }
602
+ function Mn(t) {
603
+ var e = t.effects;
604
+ if (e !== null) {
605
+ t.effects = null;
606
+ for (var n = 0; n < e.length; n += 1)
607
+ J(
608
+ /** @type {Effect} */
609
+ e[n]
610
+ );
611
+ }
612
+ }
613
+ function Sn(t) {
614
+ for (var e = t.parent; e !== null; ) {
615
+ if ((e.f & E) === 0)
616
+ return (e.f & Z) === 0 ? (
617
+ /** @type {Effect} */
618
+ e
619
+ ) : null;
620
+ e = e.parent;
621
+ }
622
+ return null;
623
+ }
624
+ function fe(t) {
625
+ var e, n = _;
626
+ pt(Sn(t));
627
+ try {
628
+ t.f &= ~rt, Mn(t), e = We(t);
629
+ } finally {
630
+ pt(n);
631
+ }
632
+ return e;
633
+ }
634
+ function Ce(t) {
635
+ var e = fe(t);
636
+ if (!t.equals(e) && (t.wv = je(), (!p?.is_fork || t.deps === null) && (t.v = e, t.deps === null))) {
637
+ m(t, g);
638
+ return;
639
+ }
640
+ dt || (I !== null ? (Pe() || p?.is_fork) && I.set(t, e) : le(t));
641
+ }
642
+ function Tn(t) {
643
+ if (t.effects !== null)
644
+ for (const e of t.effects)
645
+ (e.teardown || e.ac) && (e.teardown?.(), e.ac?.abort(Q), e.teardown = sn, e.ac = null, xt(e, 0), ae(e));
646
+ }
647
+ function Ae(t) {
648
+ if (t.effects !== null)
649
+ for (const e of t.effects)
650
+ e.teardown && mt(e);
651
+ }
652
+ let ne = /* @__PURE__ */ new Set();
653
+ const K = /* @__PURE__ */ new Map();
654
+ let Re = !1;
655
+ function Cn(t, e) {
656
+ var n = {
657
+ f: 0,
658
+ // TODO ideally we could skip this altogether, but it causes type errors
659
+ v: t,
660
+ reactions: null,
661
+ equals: ye,
662
+ rv: 0,
663
+ wv: 0
664
+ };
665
+ return n;
666
+ }
667
+ function de(t, e) {
668
+ if (!t.equals(e)) {
669
+ var n = t.v;
670
+ dt ? K.set(t, e) : K.set(t, n), t.v = e;
671
+ var s = Pt.ensure();
672
+ if (s.capture(t, n), (t.f & E) !== 0) {
673
+ const r = (
674
+ /** @type {Derived} */
675
+ t
676
+ );
677
+ (t.f & b) !== 0 && fe(r), le(r);
678
+ }
679
+ t.wv = je(), Ne(t, b), _ !== null && (_.f & g) !== 0 && (_.f & (W | wt)) === 0 && (R === null ? Un([t]) : R.push(t)), !s.is_fork && ne.size > 0 && !Re && An();
680
+ }
681
+ return e;
682
+ }
683
+ function An() {
684
+ Re = !1;
685
+ for (const t of ne)
686
+ (t.f & g) !== 0 && m(t, Y), Ct(t) && mt(t);
687
+ ne.clear();
688
+ }
689
+ function Ne(t, e) {
690
+ var n = t.reactions;
691
+ if (n !== null)
692
+ for (var s = n.length, r = 0; r < s; r++) {
693
+ var i = n[r], l = i.f, f = (l & b) === 0;
694
+ if (f && m(i, e), (l & E) !== 0) {
695
+ var a = (
696
+ /** @type {Derived} */
697
+ i
698
+ );
699
+ I?.delete(a), (l & rt) === 0 && (l & D && (i.f |= rt), Ne(a, Y));
700
+ } else f && ((l & st) !== 0 && V !== null && V.add(
701
+ /** @type {Effect} */
702
+ i
703
+ ), q(
704
+ /** @type {Effect} */
705
+ i
706
+ ));
707
+ }
708
+ }
709
+ var Rn, Nn, Dn;
710
+ function _e(t = "") {
711
+ return document.createTextNode(t);
712
+ }
713
+ // @__NO_SIDE_EFFECTS__
714
+ function vt(t) {
715
+ return (
716
+ /** @type {TemplateNode | null} */
717
+ Nn.call(t)
718
+ );
719
+ }
720
+ // @__NO_SIDE_EFFECTS__
721
+ function Vt(t) {
722
+ return (
723
+ /** @type {TemplateNode | null} */
724
+ Dn.call(t)
725
+ );
726
+ }
727
+ function De(t, e) {
728
+ return /* @__PURE__ */ vt(t);
729
+ }
730
+ function Fn(t, e = !1) {
731
+ {
732
+ var n = /* @__PURE__ */ vt(t);
733
+ return n instanceof Comment && n.data === "" ? /* @__PURE__ */ Vt(n) : n;
734
+ }
735
+ }
736
+ function Pn(t, e = 1, n = !1) {
737
+ let s = t;
738
+ for (; e--; )
739
+ s = /** @type {TemplateNode} */
740
+ /* @__PURE__ */ Vt(s);
741
+ return s;
742
+ }
743
+ function In() {
744
+ return !1;
745
+ }
746
+ function Ln(t, e, n) {
747
+ return (
748
+ /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
749
+ document.createElementNS(be, t, void 0)
750
+ );
751
+ }
752
+ function Fe(t) {
753
+ var e = v, n = _;
754
+ _t(null), pt(null);
755
+ try {
756
+ return t();
757
+ } finally {
758
+ _t(e), pt(n);
759
+ }
760
+ }
761
+ function Hn(t, e) {
762
+ var n = e.last;
763
+ n === null ? e.last = e.first = t : (n.next = t, t.prev = n, e.last = t);
764
+ }
765
+ function Tt(t, e) {
766
+ var n = _;
767
+ n !== null && (n.f & F) !== 0 && (t |= F);
768
+ var s = {
769
+ ctx: St,
770
+ deps: null,
771
+ nodes: null,
772
+ f: t | b | D,
773
+ first: null,
774
+ fn: e,
775
+ last: null,
776
+ next: null,
777
+ parent: n,
778
+ b: n && n.b,
779
+ prev: null,
780
+ teardown: null,
781
+ wv: 0,
782
+ ac: null
783
+ }, r = s;
784
+ if ((t & Xt) !== 0)
785
+ ht !== null ? ht.push(s) : q(s);
786
+ else if (e !== null) {
787
+ try {
788
+ mt(s);
789
+ } catch (l) {
790
+ throw J(s), l;
791
+ }
792
+ r.deps === null && r.teardown === null && r.nodes === null && r.first === r.last && // either `null`, or a singular child
793
+ (r.f & jt) === 0 && (r = r.first, (t & st) !== 0 && (t & Et) !== 0 && r !== null && (r.f |= Et));
794
+ }
795
+ if (r !== null && (r.parent = n, n !== null && Hn(r, n), v !== null && (v.f & E) !== 0 && (t & wt) === 0)) {
796
+ var i = (
797
+ /** @type {Derived} */
798
+ v
799
+ );
800
+ (i.effects ?? (i.effects = [])).push(r);
801
+ }
802
+ return s;
803
+ }
804
+ function Pe() {
805
+ return v !== null && !$;
806
+ }
807
+ function Yn(t) {
808
+ const e = Tt(bt, null);
809
+ return m(e, g), e.teardown = t, e;
810
+ }
811
+ function On(t) {
812
+ return Tt(xe | jt, t);
813
+ }
814
+ function Ie(t, e = [], n = [], s = []) {
815
+ bn(s, e, n, (r) => {
816
+ Tt(bt, () => t(...r.map(Zn)));
817
+ });
818
+ }
819
+ function Xn(t, e = 0) {
820
+ var n = Tt(st | e, t);
821
+ return n;
822
+ }
823
+ function pe(t) {
824
+ return Tt(W | jt, t);
825
+ }
826
+ function Le(t) {
827
+ var e = t.teardown;
828
+ if (e !== null) {
829
+ const n = dt, s = v;
830
+ me(!0), _t(null);
831
+ try {
832
+ e.call(null);
833
+ } finally {
834
+ me(n), _t(s);
835
+ }
836
+ }
837
+ }
838
+ function ae(t, e = !1) {
839
+ var n = t.first;
840
+ for (t.first = t.last = null; n !== null; ) {
841
+ const r = n.ac;
842
+ r !== null && Fe(() => {
843
+ r.abort(Q);
844
+ });
845
+ var s = n.next;
846
+ (n.f & wt) !== 0 ? n.parent = null : J(n, e), n = s;
847
+ }
848
+ }
849
+ function jn(t) {
850
+ for (var e = t.first; e !== null; ) {
851
+ var n = e.next;
852
+ (e.f & W) === 0 && J(e), e = n;
853
+ }
854
+ }
855
+ function J(t, e = !0) {
856
+ var n = !1;
857
+ (e || (t.f & fn) !== 0) && t.nodes !== null && t.nodes.end !== null && (Vn(
858
+ t.nodes.start,
859
+ /** @type {TemplateNode} */
860
+ t.nodes.end
861
+ ), n = !0), ae(t, e && !n), xt(t, 0), m(t, Z);
862
+ var s = t.nodes && t.nodes.t;
863
+ if (s !== null)
864
+ for (const i of s)
865
+ i.stop();
866
+ Le(t);
867
+ var r = t.parent;
868
+ r !== null && r.first !== null && He(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes = t.ac = null;
869
+ }
870
+ function Vn(t, e) {
871
+ for (; t !== null; ) {
872
+ var n = t === e ? null : /* @__PURE__ */ Vt(t);
873
+ t.remove(), t = n;
874
+ }
875
+ }
876
+ function He(t) {
877
+ var e = t.parent, n = t.prev, s = t.next;
878
+ n !== null && (n.next = s), s !== null && (s.prev = n), e !== null && (e.first === t && (e.first = s), e.last === t && (e.last = n));
879
+ }
880
+ function Wn(t, e, n = !0) {
881
+ var s = [];
882
+ Ye(t, s, !0);
883
+ var r = () => {
884
+ n && J(t), e && e();
885
+ }, i = s.length;
886
+ if (i > 0) {
887
+ var l = () => --i || r();
888
+ for (var f of s)
889
+ f.out(l);
890
+ } else
891
+ r();
892
+ }
893
+ function Ye(t, e, n) {
894
+ if ((t.f & F) === 0) {
895
+ t.f ^= F;
896
+ var s = t.nodes && t.nodes.t;
897
+ if (s !== null)
898
+ for (const f of s)
899
+ (f.is_global || n) && e.push(f);
900
+ for (var r = t.first; r !== null; ) {
901
+ var i = r.next, l = (r.f & Et) !== 0 || // If this is a branch effect without a block effect parent,
902
+ // it means the parent block effect was pruned. In that case,
903
+ // transparency information was transferred to the branch effect.
904
+ (r.f & W) !== 0 && (t.f & st) !== 0;
905
+ Ye(r, e, l ? n : !1), r = i;
906
+ }
907
+ }
908
+ }
909
+ function zn(t) {
910
+ Oe(t, !0);
911
+ }
912
+ function Oe(t, e) {
913
+ if ((t.f & F) !== 0) {
914
+ t.f ^= F;
915
+ for (var n = t.first; n !== null; ) {
916
+ var s = n.next, r = (n.f & Et) !== 0 || (n.f & W) !== 0;
917
+ Oe(n, r ? e : !1), n = s;
918
+ }
919
+ var i = t.nodes && t.nodes.t;
920
+ if (i !== null)
921
+ for (const l of i)
922
+ (l.is_global || e) && l.in();
923
+ }
924
+ }
925
+ function Bn(t, e) {
926
+ if (t.nodes)
927
+ for (var n = t.nodes.start, s = t.nodes.end; n !== null; ) {
928
+ var r = n === s ? null : /* @__PURE__ */ Vt(n);
929
+ e.append(n), n = r;
930
+ }
931
+ }
932
+ let Rt = !1, dt = !1;
933
+ function me(t) {
934
+ dt = t;
935
+ }
936
+ let v = null, $ = !1;
937
+ function _t(t) {
938
+ v = t;
939
+ }
940
+ let _ = null;
941
+ function pt(t) {
942
+ _ = t;
943
+ }
944
+ let nt = null, y = null, T = 0, R = null;
945
+ function Un(t) {
946
+ R = t;
947
+ }
948
+ let Xe = 1, lt = 0;
949
+ function je() {
950
+ return ++Xe;
951
+ }
952
+ function Ct(t) {
953
+ var e = t.f;
954
+ if ((e & b) !== 0)
955
+ return !0;
956
+ if (e & E && (t.f &= ~rt), (e & Y) !== 0) {
957
+ for (var n = (
958
+ /** @type {Value[]} */
959
+ t.deps
960
+ ), s = n.length, r = 0; r < s; r++) {
961
+ var i = n[r];
962
+ if (Ct(
963
+ /** @type {Derived} */
964
+ i
965
+ ) && Ce(
966
+ /** @type {Derived} */
967
+ i
968
+ ), i.wv > t.wv)
969
+ return !0;
970
+ }
971
+ (e & D) !== 0 && // During time traveling we don't want to reset the status so that
972
+ // traversal of the graph in the other batches still happens
973
+ I === null && m(t, g);
974
+ }
975
+ return !1;
976
+ }
977
+ function Ve(t, e, n = !0) {
978
+ var s = t.reactions;
979
+ if (s !== null && !(nt !== null && gt.call(nt, t)))
980
+ for (var r = 0; r < s.length; r++) {
981
+ var i = s[r];
982
+ (i.f & E) !== 0 ? Ve(
983
+ /** @type {Derived} */
984
+ i,
985
+ e,
986
+ !1
987
+ ) : e === i && (n ? m(i, b) : (i.f & g) !== 0 && m(i, Y), q(
988
+ /** @type {Effect} */
989
+ i
990
+ ));
991
+ }
992
+ }
993
+ function We(t) {
994
+ var O;
995
+ var e = y, n = T, s = R, r = v, i = nt, l = St, f = $, a = t.f;
996
+ y = /** @type {null | Value[]} */
997
+ null, T = 0, R = null, v = (a & (W | wt)) === 0 ? t : null, nt = null, Dt(t.ctx), $ = !1, ++lt, t.ac !== null && (Fe(() => {
998
+ t.ac.abort(Q);
999
+ }), t.ac = null);
1000
+ try {
1001
+ t.f |= Kt;
1002
+ var c = (
1003
+ /** @type {Function} */
1004
+ t.fn
1005
+ ), h = c();
1006
+ t.f |= Mt;
1007
+ var u = t.deps, x = p?.is_fork;
1008
+ if (y !== null) {
1009
+ var d;
1010
+ if (x || xt(t, T), u !== null && T > 0)
1011
+ for (u.length = T + y.length, d = 0; d < y.length; d++)
1012
+ u[T + d] = y[d];
1013
+ else
1014
+ t.deps = u = y;
1015
+ if (Pe() && (t.f & D) !== 0)
1016
+ for (d = T; d < u.length; d++)
1017
+ ((O = u[d]).reactions ?? (O.reactions = [])).push(t);
1018
+ } else !x && u !== null && T < u.length && (xt(t, T), u.length = T);
1019
+ if (hn() && R !== null && !$ && u !== null && (t.f & (E | Y | b)) === 0)
1020
+ for (d = 0; d < /** @type {Source[]} */
1021
+ R.length; d++)
1022
+ Ve(
1023
+ R[d],
1024
+ /** @type {Effect} */
1025
+ t
1026
+ );
1027
+ if (r !== null && r !== t) {
1028
+ if (lt++, r.deps !== null)
1029
+ for (let M = 0; M < n; M += 1)
1030
+ r.deps[M].rv = lt;
1031
+ if (e !== null)
1032
+ for (const M of e)
1033
+ M.rv = lt;
1034
+ R !== null && (s === null ? s = R : s.push(.../** @type {Source[]} */
1035
+ R));
1036
+ }
1037
+ return (t.f & G) !== 0 && (t.f ^= G), h;
1038
+ } catch (M) {
1039
+ return dn(M);
1040
+ } finally {
1041
+ t.f ^= Kt, y = e, T = n, R = s, v = r, nt = i, Dt(l), $ = f;
1042
+ }
1043
+ }
1044
+ function qn(t, e) {
1045
+ let n = e.reactions;
1046
+ if (n !== null) {
1047
+ var s = en.call(n, t);
1048
+ if (s !== -1) {
1049
+ var r = n.length - 1;
1050
+ r === 0 ? n = e.reactions = null : (n[s] = n[r], n.pop());
1051
+ }
1052
+ }
1053
+ if (n === null && (e.f & E) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1054
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1055
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1056
+ (y === null || !gt.call(y, e))) {
1057
+ var i = (
1058
+ /** @type {Derived} */
1059
+ e
1060
+ );
1061
+ (i.f & D) !== 0 && (i.f ^= D, i.f &= ~rt), le(i), Tn(i), xt(i, 0);
1062
+ }
1063
+ }
1064
+ function xt(t, e) {
1065
+ var n = t.deps;
1066
+ if (n !== null)
1067
+ for (var s = e; s < n.length; s++)
1068
+ qn(t, n[s]);
1069
+ }
1070
+ function mt(t) {
1071
+ var e = t.f;
1072
+ if ((e & Z) === 0) {
1073
+ m(t, g);
1074
+ var n = _, s = Rt;
1075
+ _ = t, Rt = !0;
1076
+ try {
1077
+ (e & (st | ie)) !== 0 ? jn(t) : ae(t), Le(t);
1078
+ var r = We(t);
1079
+ t.teardown = typeof r == "function" ? r : null, t.wv = Xe;
1080
+ var i;
1081
+ Gt && cn && (t.f & b) !== 0 && t.deps;
1082
+ } finally {
1083
+ Rt = s, _ = n;
1084
+ }
1085
+ }
1086
+ }
1087
+ function Zn(t) {
1088
+ var e = t.f, n = (e & E) !== 0;
1089
+ if (v !== null && !$) {
1090
+ var s = _ !== null && (_.f & Z) !== 0;
1091
+ if (!s && (nt === null || !gt.call(nt, t))) {
1092
+ var r = v.deps;
1093
+ if ((v.f & Kt) !== 0)
1094
+ t.rv < lt && (t.rv = lt, y === null && r !== null && r[T] === t ? T++ : y === null ? y = [t] : y.push(t));
1095
+ else {
1096
+ (v.deps ?? (v.deps = [])).push(t);
1097
+ var i = t.reactions;
1098
+ i === null ? t.reactions = [v] : gt.call(i, v) || i.push(v);
1099
+ }
1100
+ }
1101
+ }
1102
+ if (dt && K.has(t))
1103
+ return K.get(t);
1104
+ if (n) {
1105
+ var l = (
1106
+ /** @type {Derived} */
1107
+ t
1108
+ );
1109
+ if (dt) {
1110
+ var f = l.v;
1111
+ return ((l.f & g) === 0 && l.reactions !== null || Be(l)) && (f = fe(l)), K.set(l, f), f;
1112
+ }
1113
+ var a = (l.f & D) === 0 && !$ && v !== null && (Rt || (v.f & D) !== 0), c = (l.f & Mt) === 0;
1114
+ Ct(l) && (a && (l.f |= D), Ce(l)), a && !c && (Ae(l), ze(l));
1115
+ }
1116
+ if (I?.has(t))
1117
+ return I.get(t);
1118
+ if ((t.f & G) !== 0)
1119
+ throw t.v;
1120
+ return t.v;
1121
+ }
1122
+ function ze(t) {
1123
+ if (t.f |= D, t.deps !== null)
1124
+ for (const e of t.deps)
1125
+ (e.reactions ?? (e.reactions = [])).push(t), (e.f & E) !== 0 && (e.f & D) === 0 && (Ae(
1126
+ /** @type {Derived} */
1127
+ e
1128
+ ), ze(
1129
+ /** @type {Derived} */
1130
+ e
1131
+ ));
1132
+ }
1133
+ function Be(t) {
1134
+ if (t.v === Ot) return !0;
1135
+ if (t.deps === null) return !1;
1136
+ for (const e of t.deps)
1137
+ if (K.has(e) || (e.f & E) !== 0 && Be(
1138
+ /** @type {Derived} */
1139
+ e
1140
+ ))
1141
+ return !0;
1142
+ return !1;
1143
+ }
1144
+ const Zt = /* @__PURE__ */ Symbol("events"), Gn = /* @__PURE__ */ new Set(), Kn = /* @__PURE__ */ new Set();
1145
+ function re(t, e, n) {
1146
+ (e[Zt] ?? (e[Zt] = {}))[t] = n;
1147
+ }
1148
+ function Ue(t) {
1149
+ for (var e = 0; e < t.length; e++)
1150
+ Gn.add(t[e]);
1151
+ for (var n of Kn)
1152
+ n(t);
1153
+ }
1154
+ const Jn = (
1155
+ // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
1156
+ globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
1157
+ /** @param {string} html */
1158
+ createHTML: (t) => t
1159
+ })
1160
+ );
1161
+ function Qn(t) {
1162
+ return (
1163
+ /** @type {string} */
1164
+ Jn?.createHTML(t) ?? t
1165
+ );
1166
+ }
1167
+ function qe(t) {
1168
+ var e = Ln("template");
1169
+ return e.innerHTML = Qn(t.replaceAll("<!>", "<!---->")), e.content;
1170
+ }
1171
+ function se(t, e) {
1172
+ var n = (
1173
+ /** @type {Effect} */
1174
+ _
1175
+ );
1176
+ n.nodes === null && (n.nodes = { start: t, end: e, a: null, t: null });
1177
+ }
1178
+ // @__NO_SIDE_EFFECTS__
1179
+ function Ze(t, e) {
1180
+ var n = (e & $e) !== 0, s = (e & tn) !== 0, r, i = !t.startsWith("<!>");
1181
+ return () => {
1182
+ r === void 0 && (r = qe(i ? t : "<!>" + t), n || (r = /** @type {TemplateNode} */
1183
+ /* @__PURE__ */ vt(r)));
1184
+ var l = (
1185
+ /** @type {TemplateNode} */
1186
+ s || Rn ? document.importNode(r, !0) : r.cloneNode(!0)
1187
+ );
1188
+ if (n) {
1189
+ var f = (
1190
+ /** @type {TemplateNode} */
1191
+ /* @__PURE__ */ vt(l)
1192
+ ), a = (
1193
+ /** @type {TemplateNode} */
1194
+ l.lastChild
1195
+ );
1196
+ se(f, a);
1197
+ } else
1198
+ se(l, l);
1199
+ return l;
1200
+ };
1201
+ }
1202
+ // @__NO_SIDE_EFFECTS__
1203
+ function $n(t, e, n = "svg") {
1204
+ var s = !t.startsWith("<!>"), r = `<${n}>${s ? t : "<!>" + t}</${n}>`, i;
1205
+ return () => {
1206
+ if (!i) {
1207
+ var l = (
1208
+ /** @type {DocumentFragment} */
1209
+ qe(r)
1210
+ ), f = (
1211
+ /** @type {Element} */
1212
+ /* @__PURE__ */ vt(l)
1213
+ );
1214
+ i = /** @type {Element} */
1215
+ /* @__PURE__ */ vt(f);
1216
+ }
1217
+ var a = (
1218
+ /** @type {TemplateNode} */
1219
+ i.cloneNode(!0)
1220
+ );
1221
+ return se(a, a), a;
1222
+ };
1223
+ }
1224
+ // @__NO_SIDE_EFFECTS__
1225
+ function Ge(t, e) {
1226
+ return /* @__PURE__ */ $n(t, e, "svg");
1227
+ }
1228
+ function Nt(t, e) {
1229
+ t !== null && t.before(
1230
+ /** @type {Node} */
1231
+ e
1232
+ );
1233
+ }
1234
+ var P, H, C, et, yt, kt, Yt;
1235
+ class tr {
1236
+ /**
1237
+ * @param {TemplateNode} anchor
1238
+ * @param {boolean} transition
1239
+ */
1240
+ constructor(e, n = !0) {
1241
+ /** @type {TemplateNode} */
1242
+ z(this, "anchor");
1243
+ /** @type {Map<Batch, Key>} */
1244
+ w(this, P, /* @__PURE__ */ new Map());
1245
+ /**
1246
+ * Map of keys to effects that are currently rendered in the DOM.
1247
+ * These effects are visible and actively part of the document tree.
1248
+ * Example:
1249
+ * ```
1250
+ * {#if condition}
1251
+ * foo
1252
+ * {:else}
1253
+ * bar
1254
+ * {/if}
1255
+ * ```
1256
+ * Can result in the entries `true->Effect` and `false->Effect`
1257
+ * @type {Map<Key, Effect>}
1258
+ */
1259
+ w(this, H, /* @__PURE__ */ new Map());
1260
+ /**
1261
+ * Similar to #onscreen with respect to the keys, but contains branches that are not yet
1262
+ * in the DOM, because their insertion is deferred.
1263
+ * @type {Map<Key, Branch>}
1264
+ */
1265
+ w(this, C, /* @__PURE__ */ new Map());
1266
+ /**
1267
+ * Keys of effects that are currently outroing
1268
+ * @type {Set<Key>}
1269
+ */
1270
+ w(this, et, /* @__PURE__ */ new Set());
1271
+ /**
1272
+ * Whether to pause (i.e. outro) on change, or destroy immediately.
1273
+ * This is necessary for `<svelte:element>`
1274
+ */
1275
+ w(this, yt, !0);
1276
+ /**
1277
+ * @param {Batch} batch
1278
+ */
1279
+ w(this, kt, (e) => {
1280
+ if (o(this, P).has(e)) {
1281
+ var n = (
1282
+ /** @type {Key} */
1283
+ o(this, P).get(e)
1284
+ ), s = o(this, H).get(n);
1285
+ if (s)
1286
+ zn(s), o(this, et).delete(n);
1287
+ else {
1288
+ var r = o(this, C).get(n);
1289
+ r && (r.effect.f & F) === 0 && (o(this, H).set(n, r.effect), o(this, C).delete(n), r.fragment.lastChild.remove(), this.anchor.before(r.fragment), s = r.effect);
1290
+ }
1291
+ for (const [i, l] of o(this, P)) {
1292
+ if (o(this, P).delete(i), i === e)
1293
+ break;
1294
+ const f = o(this, C).get(l);
1295
+ f && (J(f.effect), o(this, C).delete(l));
1296
+ }
1297
+ for (const [i, l] of o(this, H)) {
1298
+ if (i === n || o(this, et).has(i) || (l.f & F) !== 0) continue;
1299
+ const f = () => {
1300
+ if (Array.from(o(this, P).values()).includes(i)) {
1301
+ var c = document.createDocumentFragment();
1302
+ Bn(l, c), c.append(_e()), o(this, C).set(i, { effect: l, fragment: c });
1303
+ } else
1304
+ J(l);
1305
+ o(this, et).delete(i), o(this, H).delete(i);
1306
+ };
1307
+ o(this, yt) || !s ? (o(this, et).add(i), Wn(l, f, !1)) : f();
1308
+ }
1309
+ }
1310
+ });
1311
+ /**
1312
+ * @param {Batch} batch
1313
+ */
1314
+ w(this, Yt, (e) => {
1315
+ o(this, P).delete(e);
1316
+ const n = Array.from(o(this, P).values());
1317
+ for (const [s, r] of o(this, C))
1318
+ n.includes(s) || (J(r.effect), o(this, C).delete(s));
1319
+ });
1320
+ this.anchor = e, X(this, yt, n);
1321
+ }
1322
+ /**
1323
+ *
1324
+ * @param {any} key
1325
+ * @param {null | ((target: TemplateNode) => void)} fn
1326
+ */
1327
+ ensure(e, n) {
1328
+ var s = (
1329
+ /** @type {Batch} */
1330
+ p
1331
+ ), r = In();
1332
+ if (n && !o(this, H).has(e) && !o(this, C).has(e))
1333
+ if (r) {
1334
+ var i = document.createDocumentFragment(), l = _e();
1335
+ i.append(l), o(this, C).set(e, {
1336
+ effect: pe(() => n(l)),
1337
+ fragment: i
1338
+ });
1339
+ } else
1340
+ o(this, H).set(
1341
+ e,
1342
+ pe(() => n(this.anchor))
1343
+ );
1344
+ if (o(this, P).set(s, e), r) {
1345
+ for (const [f, a] of o(this, H))
1346
+ f === e ? s.unskip_effect(a) : s.skip_effect(a);
1347
+ for (const [f, a] of o(this, C))
1348
+ f === e ? s.unskip_effect(a.effect) : s.skip_effect(a.effect);
1349
+ s.oncommit(o(this, kt)), s.ondiscard(o(this, Yt));
1350
+ } else
1351
+ o(this, kt).call(this, s);
1352
+ }
1353
+ }
1354
+ P = new WeakMap(), H = new WeakMap(), C = new WeakMap(), et = new WeakMap(), yt = new WeakMap(), kt = new WeakMap(), Yt = new WeakMap();
1355
+ function er(t, e, n = !1) {
1356
+ var s = new tr(t), r = n ? Et : 0;
1357
+ function i(l, f) {
1358
+ s.ensure(l, f);
1359
+ }
1360
+ Xn(() => {
1361
+ var l = !1;
1362
+ e((f, a = 0) => {
1363
+ l = !0, i(a, f);
1364
+ }), l || i(-1, null);
1365
+ }, r);
1366
+ }
1367
+ function Ke(t) {
1368
+ var e, n, s = "";
1369
+ if (typeof t == "string" || typeof t == "number") s += t;
1370
+ else if (typeof t == "object") if (Array.isArray(t)) {
1371
+ var r = t.length;
1372
+ for (e = 0; e < r; e++) t[e] && (n = Ke(t[e])) && (s && (s += " "), s += n);
1373
+ } else for (n in t) t[n] && (s && (s += " "), s += n);
1374
+ return s;
1375
+ }
1376
+ function nr() {
1377
+ for (var t, e, n = 0, s = "", r = arguments.length; n < r; n++) (t = arguments[n]) && (e = Ke(t)) && (s && (s += " "), s += e);
1378
+ return s;
1379
+ }
1380
+ function It(t) {
1381
+ return typeof t == "object" ? nr(t) : t ?? "";
1382
+ }
1383
+ function rr(t, e, n) {
1384
+ var s = t == null ? "" : "" + t;
1385
+ return s === "" ? null : s;
1386
+ }
1387
+ function Lt(t, e, n, s, r, i) {
1388
+ var l = t.__className;
1389
+ if (l !== n || l === void 0) {
1390
+ var f = rr(n);
1391
+ f == null ? t.removeAttribute("class") : e ? t.className = f : t.setAttribute("class", f), t.__className = n;
1392
+ }
1393
+ return i;
1394
+ }
1395
+ const sr = /* @__PURE__ */ Symbol("is custom element"), ir = /* @__PURE__ */ Symbol("is html");
1396
+ function lr(t, e, n, s) {
1397
+ var r = or(t);
1398
+ r[e] !== (r[e] = n) && (n == null ? t.removeAttribute(e) : typeof n != "string" && fr(t).includes(e) ? t[e] = n : t.setAttribute(e, n));
1399
+ }
1400
+ function or(t) {
1401
+ return (
1402
+ /** @type {Record<string | symbol, unknown>} **/
1403
+ // @ts-expect-error
1404
+ t.__attributes ?? (t.__attributes = {
1405
+ [sr]: t.nodeName.includes("-"),
1406
+ [ir]: t.namespaceURI === be
1407
+ })
1408
+ );
1409
+ }
1410
+ var we = /* @__PURE__ */ new Map();
1411
+ function fr(t) {
1412
+ var e = t.getAttribute("is") || t.nodeName, n = we.get(e);
1413
+ if (n) return n;
1414
+ we.set(e, n = []);
1415
+ for (var s, r = t, i = Element.prototype; i !== r; ) {
1416
+ s = nn(r);
1417
+ for (var l in s)
1418
+ s[l].set && n.push(l);
1419
+ r = rn(r);
1420
+ }
1421
+ return n;
1422
+ }
1423
+ function Ht(t, e, n, s) {
1424
+ var r = (
1425
+ /** @type {V} */
1426
+ s
1427
+ ), i = !0, l = () => (i && (i = !1, r = /** @type {V} */
1428
+ s), r), f;
1429
+ f = /** @type {V} */
1430
+ t[e], f === void 0 && s !== void 0 && (f = l());
1431
+ var a;
1432
+ return a = () => {
1433
+ var c = (
1434
+ /** @type {V} */
1435
+ t[e]
1436
+ );
1437
+ return c === void 0 ? l() : (i = !0, c);
1438
+ }, a;
1439
+ }
1440
+ var ar = /* @__PURE__ */ Ge('<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path></svg>'), ur = /* @__PURE__ */ Ge('<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>'), cr = /* @__PURE__ */ Ze('<button><!></button> <button title="Close"><svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></button>', 1);
1441
+ function pr(t, e) {
1442
+ let n = Ht(e, "minimized", 3, !1), s = Ht(e, "buttonClass", 3, "btn btn-xs btn-ghost btn-circle");
1443
+ var r = cr(), i = Fn(r), l = De(i);
1444
+ {
1445
+ var f = (h) => {
1446
+ var u = ar();
1447
+ Nt(h, u);
1448
+ }, a = (h) => {
1449
+ var u = ur();
1450
+ Nt(h, u);
1451
+ };
1452
+ er(l, (h) => {
1453
+ n() ? h(f) : h(a, -1);
1454
+ });
1455
+ }
1456
+ var c = Pn(i, 2);
1457
+ Ie(() => {
1458
+ Lt(i, 1, It(s())), lr(i, "title", n() ? "Maximize" : "Minimize"), Lt(c, 1, It(s()));
1459
+ }), re("click", i, function(...h) {
1460
+ e.onToggle?.apply(this, h);
1461
+ }), re("click", c, function(...h) {
1462
+ e.onClose?.apply(this, h);
1463
+ }), Nt(t, r);
1464
+ }
1465
+ Ue(["click"]);
1466
+ var hr = /* @__PURE__ */ Ze('<div role="button" tabindex="0" title="Resize window"><svg viewBox="0 0 16 16" fill="currentColor"><path d="M16 16V14H14V16H16Z"></path><path d="M16 11V9H14V11H16Z"></path><path d="M13 16V14H11V16H13Z"></path></svg></div>');
1467
+ function mr(t, e) {
1468
+ let n = Ht(e, "handleClass", 3, "absolute bottom-0 right-0 w-4 h-4 cursor-se-resize"), s = Ht(e, "iconClass", 3, "w-full h-full text-base-content/30");
1469
+ var r = hr(), i = De(r);
1470
+ Ie(() => {
1471
+ Lt(r, 1, It(n())), Lt(i, 0, It(s()));
1472
+ }), re("mousedown", r, function(...l) {
1473
+ e.onPointerDown?.apply(this, l);
1474
+ }), Nt(t, r);
1475
+ }
1476
+ Ue(["mousedown"]);
1477
+ function wr(t, e) {
1478
+ const n = (u, x, d) => Math.max(x, Math.min(u, d)), s = n(
1479
+ Math.round(t.width * e.widthRatio),
1480
+ e.minWidth,
1481
+ e.maxWidth
1482
+ ), r = n(
1483
+ Math.round(t.height * e.heightRatio),
1484
+ e.minHeight,
1485
+ e.maxHeight
1486
+ ), i = e.paddingX ?? 16, l = e.paddingY ?? 16, f = Math.max(i, t.width - s - i), a = Math.max(l, t.height - r - l), c = e.alignX === "left" ? i : e.alignX === "right" ? f : Math.max(i, Math.round((t.width - s) / 2)), h = e.alignY === "top" ? l : e.alignY === "bottom" ? a : Math.max(l, Math.round((t.height - r) / 2));
1487
+ return { x: c, y: h, width: s, height: r };
1488
+ }
1489
+ function gr(t) {
1490
+ const e = t.padding ?? 0;
1491
+ let n = !1, s = !1, r = 0, i = 0, l = 0, f = 0, a = 0, c = 0, h = 0, u = 0;
1492
+ const x = (S) => {
1493
+ if (!n) return;
1494
+ const A = t.getState(), Wt = S.clientX - r, zt = S.clientY - i, Bt = Math.max(e, window.innerWidth - A.width - e), Ut = Math.max(e, window.innerHeight - 100 - e);
1495
+ t.setState({
1496
+ ...A,
1497
+ x: Math.max(e, Math.min(l + Wt, Bt)),
1498
+ y: Math.max(e, Math.min(f + zt, Ut))
1499
+ });
1500
+ }, d = (S) => {
1501
+ if (!s) return;
1502
+ const A = t.getState(), Wt = S.clientX - a, zt = S.clientY - c, Bt = Math.max(
1503
+ t.minWidth,
1504
+ window.innerWidth - A.x - e
1505
+ ), Ut = Math.max(
1506
+ t.minHeight,
1507
+ window.innerHeight - A.y - e
1508
+ );
1509
+ t.setState({
1510
+ ...A,
1511
+ width: Math.max(
1512
+ t.minWidth,
1513
+ Math.min(h + Wt, Bt)
1514
+ ),
1515
+ height: Math.max(
1516
+ t.minHeight,
1517
+ Math.min(u + zt, Ut)
1518
+ )
1519
+ });
1520
+ }, O = () => {
1521
+ n = !1, document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", O);
1522
+ }, M = () => {
1523
+ s = !1, document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", M);
1524
+ };
1525
+ return {
1526
+ startDrag(S) {
1527
+ n = !0, r = S.clientX, i = S.clientY;
1528
+ const A = t.getState();
1529
+ l = A.x, f = A.y, document.addEventListener("mousemove", x), document.addEventListener("mouseup", O);
1530
+ },
1531
+ startResize(S) {
1532
+ s = !0, a = S.clientX, c = S.clientY;
1533
+ const A = t.getState();
1534
+ h = A.width, u = A.height, document.addEventListener("mousemove", d), document.addEventListener("mouseup", M), S.preventDefault(), S.stopPropagation();
1535
+ },
1536
+ stop() {
1537
+ O(), M();
1538
+ }
1539
+ };
1540
+ }
1541
+ function vr(t, e) {
1542
+ return (t || void 0) === (e || void 0);
1543
+ }
1544
+ function br(t, e, n) {
1545
+ const s = t?.key?.sectionId || "", r = t?.key?.attemptId || void 0;
1546
+ return s !== e ? !1 : vr(r, n);
1547
+ }
1548
+ function Er(t, e, n) {
1549
+ return !t?.getSectionController || !e ? null : t.getSectionController({
1550
+ sectionId: e,
1551
+ attemptId: n
1552
+ }) || null;
1553
+ }
1554
+ export {
1555
+ mr as PanelResizeHandle,
1556
+ pr as PanelWindowControls,
1557
+ wr as computePanelSizeFromViewport,
1558
+ gr as createFloatingPanelPointerController,
1559
+ Er as getSectionControllerFromCoordinator,
1560
+ br as isMatchingSectionControllerLifecycleEvent,
1561
+ vr as optionalIdsEqual
1562
+ };