@pie-players/pie-section-player 0.3.17 → 0.3.20

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.
Files changed (29) hide show
  1. package/README.md +76 -2
  2. package/dist/components/shared/player-action.d.ts +0 -2
  3. package/dist/components/shared/player-action.d.ts.map +1 -1
  4. package/dist/components/shared/player-preload.d.ts.map +1 -1
  5. package/dist/components/shared/section-player-runtime.d.ts +38 -7
  6. package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
  7. package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
  8. package/dist/contracts/layout-contract.d.ts +1 -1
  9. package/dist/contracts/layout-contract.d.ts.map +1 -1
  10. package/dist/contracts/layout-parity-metadata.d.ts.map +1 -1
  11. package/dist/controllers/SectionController.d.ts.map +1 -1
  12. package/dist/defineProperty-CyepwRr5-eHUSgEtz.js +33 -0
  13. package/dist/defineProperty-CyepwRr5.js +33 -0
  14. package/dist/dist-BCuSaTvi.js +393 -0
  15. package/dist/dist-BIgX-aC4-C5B4fLQK.js +389 -0
  16. package/dist/dist-DwP27yIs-gkxodgFn.js +201 -0
  17. package/dist/dist-S3IAfazl.js +201 -0
  18. package/dist/{index-BZq66Ke6-D8dZwpj4.js → module-COIydQYl-2o-TlgiW.js} +38152 -30086
  19. package/dist/pie-section-player.js +7438 -8680
  20. package/dist/player-preload-C_CjM5hv.js +6317 -0
  21. package/dist/tool-annotation-toolbar-BS_MjvXd.js +3974 -0
  22. package/dist/utils/player-preload.js +5 -5
  23. package/package.json +14 -14
  24. package/dist/index-CGqExkh0-DYpgzOOU.js +0 -338
  25. package/dist/index-CGqExkh0.js +0 -354
  26. package/dist/index-DF-Dk87f-lxErM8bo.js +0 -178
  27. package/dist/index-DF-Dk87f.js +0 -192
  28. package/dist/player-preload-Dxvgw3gW.js +0 -7023
  29. package/dist/tool-annotation-toolbar-BOoJpOXj.js +0 -4845
@@ -1,4845 +0,0 @@
1
- var ci = Object.defineProperty, Kn = (e) => {
2
- throw TypeError(e);
3
- }, ui = (e, t, o) => t in e ? ci(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, m = (e, t, o) => ui(e, typeof t != "symbol" ? t + "" : t, o), tn = (e, t, o) => t.has(e) || Kn("Cannot " + o), u = (e, t, o) => (tn(e, t, "read from private field"), o ? o.call(e) : t.get(e)), x = (e, t, o) => t.has(e) ? Kn("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, o), I = (e, t, o, n) => (tn(e, t, "write to private field"), t.set(e, o), o), M = (e, t, o) => (tn(e, t, "access private method"), o), Sn;
4
- typeof window < "u" && ((Sn = window.__svelte ?? (window.__svelte = {})).v ?? (Sn.v = /* @__PURE__ */ new Set())).add("5");
5
- const di = 1, fi = 2, hi = 16, pi = 1, vi = 2, Yn = "[", on = "[!", kn = "[?", nn = "]", St = {}, N = /* @__PURE__ */ Symbol(), Jn = "http://www.w3.org/1999/xhtml", gi = !1;
6
- var Zn = Array.isArray, mi = Array.prototype.indexOf, kt = Array.prototype.includes, xo = Array.from, wo = Object.keys, To = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, bi = Object.getOwnPropertyDescriptors, yi = Object.prototype, wi = Array.prototype, Xn = Object.getPrototypeOf, An = Object.isExtensible;
7
- const Ti = () => {
8
- };
9
- function Ii(e) {
10
- for (var t = 0; t < e.length; t++)
11
- e[t]();
12
- }
13
- function Qn() {
14
- var e, t, o = new Promise((n, r) => {
15
- e = n, t = r;
16
- });
17
- return { promise: o, resolve: e, reject: t };
18
- }
19
- const j = 2, Ot = 4, At = 8, rn = 1 << 24, Xe = 16, ge = 32, Qe = 64, jo = 128, oe = 512, V = 1024, z = 2048, ve = 4096, D = 8192, Ie = 16384, vt = 32768, _t = 65536, _n = 1 << 17, $i = 1 << 18, gt = 1 << 19, xi = 1 << 20, Le = 1 << 25, ut = 65536, zo = 1 << 21, sn = 1 << 22, Ye = 1 << 23, uo = /* @__PURE__ */ Symbol("$state"), Si = /* @__PURE__ */ Symbol("legacy props"), ki = /* @__PURE__ */ Symbol(""), it = new class extends Error {
20
- constructor() {
21
- super(...arguments), m(this, "name", "StaleReactionError"), m(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed");
22
- }
23
- }(), Ai = (
24
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
25
- !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml")
26
- ), So = 3, Xt = 8;
27
- function _i() {
28
- throw new Error("https://svelte.dev/e/async_derived_orphan");
29
- }
30
- function Ci(e, t, o) {
31
- throw new Error("https://svelte.dev/e/each_key_duplicate");
32
- }
33
- function Ei(e) {
34
- throw new Error("https://svelte.dev/e/effect_in_teardown");
35
- }
36
- function Pi() {
37
- throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
38
- }
39
- function Li(e) {
40
- throw new Error("https://svelte.dev/e/effect_orphan");
41
- }
42
- function Mi() {
43
- throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
44
- }
45
- function Oi() {
46
- throw new Error("https://svelte.dev/e/hydration_failed");
47
- }
48
- function Ri() {
49
- throw new Error("https://svelte.dev/e/state_descriptors_fixed");
50
- }
51
- function Ni() {
52
- throw new Error("https://svelte.dev/e/state_prototype_fixed");
53
- }
54
- function Vi() {
55
- throw new Error("https://svelte.dev/e/state_unsafe_mutation");
56
- }
57
- function ji() {
58
- throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
59
- }
60
- function ko(e) {
61
- console.warn("https://svelte.dev/e/hydration_mismatch");
62
- }
63
- function zi() {
64
- console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
65
- }
66
- let P = !1;
67
- function Me(e) {
68
- P = e;
69
- }
70
- let C;
71
- function J(e) {
72
- if (e === null)
73
- throw ko(), St;
74
- return C = e;
75
- }
76
- function Ao() {
77
- return J(/* @__PURE__ */ xe(C));
78
- }
79
- function ro(e) {
80
- if (P) {
81
- if (/* @__PURE__ */ xe(C) !== null)
82
- throw ko(), St;
83
- C = e;
84
- }
85
- }
86
- function Wi(e = 1) {
87
- if (P) {
88
- for (var t = e, o = C; t--; )
89
- o = /** @type {TemplateNode} */
90
- /* @__PURE__ */ xe(o);
91
- C = o;
92
- }
93
- }
94
- function Io(e = !0) {
95
- for (var t = 0, o = C; ; ) {
96
- if (o.nodeType === Xt) {
97
- var n = (
98
- /** @type {Comment} */
99
- o.data
100
- );
101
- if (n === nn) {
102
- if (t === 0) return o;
103
- t -= 1;
104
- } else (n === Yn || n === on || // "[1", "[2", etc. for if blocks
105
- n[0] === "[" && !isNaN(Number(n.slice(1)))) && (t += 1);
106
- }
107
- var r = (
108
- /** @type {TemplateNode} */
109
- /* @__PURE__ */ xe(o)
110
- );
111
- e && o.remove(), o = r;
112
- }
113
- }
114
- function er(e) {
115
- if (!e || e.nodeType !== Xt)
116
- throw ko(), St;
117
- return (
118
- /** @type {Comment} */
119
- e.data
120
- );
121
- }
122
- function tr(e) {
123
- return e === this.v;
124
- }
125
- function Bi(e, t) {
126
- return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
127
- }
128
- function or(e) {
129
- return !Bi(e, this.v);
130
- }
131
- let qi = !1, re = null;
132
- function Ct(e) {
133
- re = e;
134
- }
135
- function nr(e, t = !1, o) {
136
- re = {
137
- p: re,
138
- i: !1,
139
- c: null,
140
- e: null,
141
- s: e,
142
- x: null,
143
- l: null
144
- };
145
- }
146
- function rr(e) {
147
- var t = (
148
- /** @type {ComponentContext} */
149
- re
150
- ), o = t.e;
151
- if (o !== null) {
152
- t.e = null;
153
- for (var n of o)
154
- Cr(n);
155
- }
156
- return e !== void 0 && (t.x = e), t.i = !0, re = t.p, e ?? /** @type {T} */
157
- {};
158
- }
159
- function ir() {
160
- return !0;
161
- }
162
- let st = [];
163
- function sr() {
164
- var e = st;
165
- st = [], Ii(e);
166
- }
167
- function dt(e) {
168
- if (st.length === 0 && !Gt) {
169
- var t = st;
170
- queueMicrotask(() => {
171
- t === st && sr();
172
- });
173
- }
174
- st.push(e);
175
- }
176
- function Di() {
177
- for (; st.length > 0; )
178
- sr();
179
- }
180
- function lr(e) {
181
- var t = k;
182
- if (t === null)
183
- return S.f |= Ye, e;
184
- if ((t.f & vt) === 0 && (t.f & Ot) === 0)
185
- throw e;
186
- Ke(e, t);
187
- }
188
- function Ke(e, t) {
189
- for (; t !== null; ) {
190
- if ((t.f & jo) !== 0) {
191
- if ((t.f & vt) === 0)
192
- throw e;
193
- try {
194
- t.b.error(e);
195
- return;
196
- } catch (o) {
197
- e = o;
198
- }
199
- }
200
- t = t.parent;
201
- }
202
- throw e;
203
- }
204
- const Hi = -7169;
205
- function O(e, t) {
206
- e.f = e.f & Hi | t;
207
- }
208
- function ln(e) {
209
- (e.f & oe) !== 0 || e.deps === null ? O(e, V) : O(e, ve);
210
- }
211
- function ar(e) {
212
- if (e !== null)
213
- for (const t of e)
214
- (t.f & j) === 0 || (t.f & ut) === 0 || (t.f ^= ut, ar(
215
- /** @type {Derived} */
216
- t.deps
217
- ));
218
- }
219
- function cr(e, t, o) {
220
- (e.f & z) !== 0 ? t.add(e) : (e.f & ve) !== 0 && o.add(e), ar(e.deps), O(e, V);
221
- }
222
- const fo = /* @__PURE__ */ new Set();
223
- let L = null, pe = null, G = [], _o = null, Gt = !1, Et = null, Fi = 1;
224
- var ot, qt, We, nt, yt, Ut, lt, Ce, Dt, ye, Wo, Bo, qo, Do;
225
- const Gi = class ur {
226
- constructor() {
227
- x(this, ye), m(this, "id", Fi++), m(this, "current", /* @__PURE__ */ new Map()), m(this, "previous", /* @__PURE__ */ new Map()), x(this, ot, /* @__PURE__ */ new Set()), x(this, qt, /* @__PURE__ */ new Set()), x(this, We, 0), x(this, nt, 0), x(this, yt, null), x(this, Ut, /* @__PURE__ */ new Set()), x(this, lt, /* @__PURE__ */ new Set()), x(this, Ce, /* @__PURE__ */ new Map()), m(this, "is_fork", !1), x(this, Dt, !1);
228
- }
229
- /**
230
- * Add an effect to the #skipped_branches map and reset its children
231
- * @param {Effect} effect
232
- */
233
- skip_effect(t) {
234
- u(this, Ce).has(t) || u(this, Ce).set(t, { d: [], m: [] });
235
- }
236
- /**
237
- * Remove an effect from the #skipped_branches map and reschedule
238
- * any tracked dirty/maybe_dirty child effects
239
- * @param {Effect} effect
240
- */
241
- unskip_effect(t) {
242
- var o = u(this, Ce).get(t);
243
- if (o) {
244
- u(this, Ce).delete(t);
245
- for (var n of o.d)
246
- O(n, z), Te(n);
247
- for (n of o.m)
248
- O(n, ve), Te(n);
249
- }
250
- }
251
- /**
252
- *
253
- * @param {Effect[]} root_effects
254
- */
255
- process(t) {
256
- G = [], this.apply();
257
- var o = Et = [], n = [];
258
- for (const r of t)
259
- M(this, ye, Bo).call(this, r, o, n);
260
- if (Et = null, M(this, ye, Wo).call(this)) {
261
- M(this, ye, qo).call(this, n), M(this, ye, qo).call(this, o);
262
- for (const [r, i] of u(this, Ce))
263
- pr(r, i);
264
- } else {
265
- L = null;
266
- for (const r of u(this, ot)) r(this);
267
- u(this, ot).clear(), u(this, We) === 0 && M(this, ye, Do).call(this), Cn(n), Cn(o), u(this, Ut).clear(), u(this, lt).clear(), u(this, yt)?.resolve();
268
- }
269
- pe = null;
270
- }
271
- /**
272
- * Associate a change to a given source with the current
273
- * batch, noting its previous and current values
274
- * @param {Source} source
275
- * @param {any} value
276
- */
277
- capture(t, o) {
278
- o !== N && !this.previous.has(t) && this.previous.set(t, o), (t.f & Ye) === 0 && (this.current.set(t, t.v), pe?.set(t, t.v));
279
- }
280
- activate() {
281
- L = this, this.apply();
282
- }
283
- deactivate() {
284
- L === this && (L = null, pe = null);
285
- }
286
- flush() {
287
- if (G.length > 0)
288
- L = this, dr();
289
- else if (u(this, We) === 0 && !this.is_fork) {
290
- for (const t of u(this, ot)) t(this);
291
- u(this, ot).clear(), M(this, ye, Do).call(this), u(this, yt)?.resolve();
292
- }
293
- this.deactivate();
294
- }
295
- discard() {
296
- for (const t of u(this, qt)) t(this);
297
- u(this, qt).clear();
298
- }
299
- /**
300
- *
301
- * @param {boolean} blocking
302
- */
303
- increment(t) {
304
- I(this, We, u(this, We) + 1), t && I(this, nt, u(this, nt) + 1);
305
- }
306
- /**
307
- *
308
- * @param {boolean} blocking
309
- */
310
- decrement(t) {
311
- I(this, We, u(this, We) - 1), t && I(this, nt, u(this, nt) - 1), !u(this, Dt) && (I(this, Dt, !0), dt(() => {
312
- I(this, Dt, !1), M(this, ye, Wo).call(this) ? G.length > 0 && this.flush() : this.revive();
313
- }));
314
- }
315
- revive() {
316
- for (const t of u(this, Ut))
317
- u(this, lt).delete(t), O(t, z), Te(t);
318
- for (const t of u(this, lt))
319
- O(t, ve), Te(t);
320
- this.flush();
321
- }
322
- /** @param {(batch: Batch) => void} fn */
323
- oncommit(t) {
324
- u(this, ot).add(t);
325
- }
326
- /** @param {(batch: Batch) => void} fn */
327
- ondiscard(t) {
328
- u(this, qt).add(t);
329
- }
330
- settled() {
331
- return (u(this, yt) ?? I(this, yt, Qn())).promise;
332
- }
333
- static ensure() {
334
- if (L === null) {
335
- const t = L = new ur();
336
- fo.add(L), Gt || dt(() => {
337
- L === t && t.flush();
338
- });
339
- }
340
- return L;
341
- }
342
- apply() {
343
- }
344
- };
345
- ot = /* @__PURE__ */ new WeakMap(), qt = /* @__PURE__ */ new WeakMap(), We = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), yt = /* @__PURE__ */ new WeakMap(), Ut = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), Ce = /* @__PURE__ */ new WeakMap(), Dt = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakSet(), Wo = function() {
346
- return this.is_fork || u(this, nt) > 0;
347
- }, /**
348
- * Traverse the effect tree, executing effects or stashing
349
- * them for later execution as appropriate
350
- * @param {Effect} root
351
- * @param {Effect[]} effects
352
- * @param {Effect[]} render_effects
353
- */
354
- Bo = function(e, t, o) {
355
- e.f ^= V;
356
- for (var n = e.first; n !== null; ) {
357
- var r = n.f, i = (r & (ge | Qe)) !== 0, s = i && (r & V) !== 0, l = (r & D) !== 0, a = s || u(this, Ce).has(n);
358
- if (!a && n.fn !== null) {
359
- i ? l || (n.f ^= V) : (r & Ot) !== 0 ? t.push(n) : (r & (At | rn)) !== 0 && l ? o.push(n) : Qt(n) && (Mt(n), (r & Xe) !== 0 && (u(this, lt).add(n), l && O(n, z)));
360
- var c = n.first;
361
- if (c !== null) {
362
- n = c;
363
- continue;
364
- }
365
- }
366
- for (; n !== null; ) {
367
- var d = n.next;
368
- if (d !== null) {
369
- n = d;
370
- break;
371
- }
372
- n = n.parent;
373
- }
374
- }
375
- }, /**
376
- * @param {Effect[]} effects
377
- */
378
- qo = function(e) {
379
- for (var t = 0; t < e.length; t += 1)
380
- cr(e[t], u(this, Ut), u(this, lt));
381
- }, Do = function() {
382
- var e;
383
- if (fo.size > 1) {
384
- this.previous.clear();
385
- var t = L, o = pe, n = !0;
386
- for (const i of fo) {
387
- if (i === this) {
388
- n = !1;
389
- continue;
390
- }
391
- const s = [];
392
- for (const [a, c] of this.current) {
393
- if (i.current.has(a))
394
- if (n && c !== i.current.get(a))
395
- i.current.set(a, c);
396
- else
397
- continue;
398
- s.push(a);
399
- }
400
- if (s.length === 0)
401
- continue;
402
- const l = [...i.current.keys()].filter((a) => !this.current.has(a));
403
- if (l.length > 0) {
404
- var r = G;
405
- G = [];
406
- const a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
407
- for (const d of s)
408
- fr(d, l, a, c);
409
- if (G.length > 0) {
410
- L = i, i.apply();
411
- for (const d of G)
412
- M(e = i, ye, Bo).call(e, d, [], []);
413
- i.deactivate();
414
- }
415
- G = r;
416
- }
417
- }
418
- L = t, pe = o;
419
- }
420
- u(this, Ce).clear(), fo.delete(this);
421
- };
422
- let ft = Gi;
423
- function ho(e) {
424
- var t = Gt;
425
- Gt = !0;
426
- try {
427
- for (var o; ; ) {
428
- if (Di(), G.length === 0 && (L?.flush(), G.length === 0))
429
- return _o = null, /** @type {T} */
430
- o;
431
- dr();
432
- }
433
- } finally {
434
- Gt = t;
435
- }
436
- }
437
- function dr() {
438
- try {
439
- for (var e = 0; G.length > 0; ) {
440
- var t = ft.ensure();
441
- if (e++ > 1e3) {
442
- var o, n;
443
- Ui();
444
- }
445
- t.process(G), Je.clear();
446
- }
447
- } finally {
448
- G = [], _o = null, Et = null;
449
- }
450
- }
451
- function Ui() {
452
- try {
453
- Mi();
454
- } catch (e) {
455
- Ke(e, _o);
456
- }
457
- }
458
- let _e = null;
459
- function Cn(e) {
460
- var t = e.length;
461
- if (t !== 0) {
462
- for (var o = 0; o < t; ) {
463
- var n = e[o++];
464
- if ((n.f & (Ie | D)) === 0 && Qt(n) && (_e = /* @__PURE__ */ new Set(), Mt(n), n.deps === null && n.first === null && n.nodes === null && n.teardown === null && n.ac === null && Lr(n), _e?.size > 0)) {
465
- Je.clear();
466
- for (const r of _e) {
467
- if ((r.f & (Ie | D)) !== 0) continue;
468
- const i = [r];
469
- let s = r.parent;
470
- for (; s !== null; )
471
- _e.has(s) && (_e.delete(s), i.push(s)), s = s.parent;
472
- for (let l = i.length - 1; l >= 0; l--) {
473
- const a = i[l];
474
- (a.f & (Ie | D)) === 0 && Mt(a);
475
- }
476
- }
477
- _e.clear();
478
- }
479
- }
480
- _e = null;
481
- }
482
- }
483
- function fr(e, t, o, n) {
484
- if (!o.has(e) && (o.add(e), e.reactions !== null))
485
- for (const r of e.reactions) {
486
- const i = r.f;
487
- (i & j) !== 0 ? fr(
488
- /** @type {Derived} */
489
- r,
490
- t,
491
- o,
492
- n
493
- ) : (i & (sn | Xe)) !== 0 && (i & z) === 0 && hr(r, t, n) && (O(r, z), Te(
494
- /** @type {Effect} */
495
- r
496
- ));
497
- }
498
- }
499
- function hr(e, t, o) {
500
- const n = o.get(e);
501
- if (n !== void 0) return n;
502
- if (e.deps !== null)
503
- for (const r of e.deps) {
504
- if (kt.call(t, r))
505
- return !0;
506
- if ((r.f & j) !== 0 && hr(
507
- /** @type {Derived} */
508
- r,
509
- t,
510
- o
511
- ))
512
- return o.set(
513
- /** @type {Derived} */
514
- r,
515
- !0
516
- ), !0;
517
- }
518
- return o.set(e, !1), !1;
519
- }
520
- function Te(e) {
521
- var t = _o = e, o = t.b;
522
- if (o?.is_pending && (e.f & (Ot | At | rn)) !== 0 && (e.f & vt) === 0) {
523
- o.defer_effect(e);
524
- return;
525
- }
526
- for (; t.parent !== null; ) {
527
- t = t.parent;
528
- var n = t.f;
529
- if (Et !== null && t === k && (e.f & At) === 0)
530
- return;
531
- if ((n & (Qe | ge)) !== 0) {
532
- if ((n & V) === 0)
533
- return;
534
- t.f ^= V;
535
- }
536
- }
537
- G.push(t);
538
- }
539
- function pr(e, t) {
540
- if (!((e.f & ge) !== 0 && (e.f & V) !== 0)) {
541
- (e.f & z) !== 0 ? t.d.push(e) : (e.f & ve) !== 0 && t.m.push(e), O(e, V);
542
- for (var o = e.first; o !== null; )
543
- pr(o, t), o = o.next;
544
- }
545
- }
546
- function Ki(e) {
547
- let t = 0, o = ht(0), n;
548
- return () => {
549
- dn() && (p(o), fn(() => (t === 0 && (n = qr(() => e(() => Jt(o)))), t += 1, () => {
550
- dt(() => {
551
- t -= 1, t === 0 && (n?.(), n = void 0, Jt(o));
552
- });
553
- })));
554
- };
555
- }
556
- var Yi = _t | gt;
557
- function Ji(e, t, o, n) {
558
- new Zi(e, t, o, n);
559
- }
560
- var ee, po, Ee, Tt, Y, Pe, te, we, Be, rt, qe, Ht, Kt, Yt, De, Ho, q, vr, gr, mr, Fo, io, $o, Go;
561
- class Zi {
562
- /**
563
- * @param {TemplateNode} node
564
- * @param {BoundaryProps} props
565
- * @param {((anchor: Node) => void)} children
566
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
567
- */
568
- constructor(t, o, n, r) {
569
- x(this, q), m(this, "parent"), m(this, "is_pending", !1), m(this, "transform_error"), x(this, ee), x(this, po, P ? C : null), x(this, Ee), x(this, Tt), x(this, Y), x(this, Pe, null), x(this, te, null), x(this, we, null), x(this, Be, null), x(this, rt, 0), x(this, qe, 0), x(this, Ht, !1), x(this, Kt, /* @__PURE__ */ new Set()), x(this, Yt, /* @__PURE__ */ new Set()), x(this, De, null), x(this, Ho, Ki(() => (I(this, De, ht(u(this, rt))), () => {
570
- I(this, De, null);
571
- }))), I(this, ee, t), I(this, Ee, o), I(this, Tt, (i) => {
572
- var s = (
573
- /** @type {Effect} */
574
- k
575
- );
576
- s.b = this, s.f |= jo, n(i);
577
- }), this.parent = /** @type {Effect} */
578
- k.b, this.transform_error = r ?? this.parent?.transform_error ?? ((i) => i), I(this, Y, hn(() => {
579
- if (P) {
580
- const i = (
581
- /** @type {Comment} */
582
- u(this, po)
583
- );
584
- Ao();
585
- const s = i.data === on;
586
- if (i.data.startsWith(kn)) {
587
- const l = JSON.parse(i.data.slice(kn.length));
588
- M(this, q, gr).call(this, l);
589
- } else s ? M(this, q, mr).call(this) : M(this, q, vr).call(this);
590
- } else
591
- M(this, q, Fo).call(this);
592
- }, Yi)), P && I(this, ee, C);
593
- }
594
- /**
595
- * Defer an effect inside a pending boundary until the boundary resolves
596
- * @param {Effect} effect
597
- */
598
- defer_effect(t) {
599
- cr(t, u(this, Kt), u(this, Yt));
600
- }
601
- /**
602
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
603
- * @returns {boolean}
604
- */
605
- is_rendered() {
606
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
607
- }
608
- has_pending_snippet() {
609
- return !!u(this, Ee).pending;
610
- }
611
- /**
612
- * Update the source that powers `$effect.pending()` inside this boundary,
613
- * and controls when the current `pending` snippet (if any) is removed.
614
- * Do not call from inside the class
615
- * @param {1 | -1} d
616
- */
617
- update_pending_count(t) {
618
- M(this, q, Go).call(this, t), I(this, rt, u(this, rt) + t), !(!u(this, De) || u(this, Ht)) && (I(this, Ht, !0), dt(() => {
619
- I(this, Ht, !1), u(this, De) && Pt(u(this, De), u(this, rt));
620
- }));
621
- }
622
- get_effect_pending() {
623
- return u(this, Ho).call(this), p(
624
- /** @type {Source<number>} */
625
- u(this, De)
626
- );
627
- }
628
- /** @param {unknown} error */
629
- error(t) {
630
- var o = u(this, Ee).onerror;
631
- let n = u(this, Ee).failed;
632
- if (!o && !n)
633
- throw t;
634
- u(this, Pe) && (H(u(this, Pe)), I(this, Pe, null)), u(this, te) && (H(u(this, te)), I(this, te, null)), u(this, we) && (H(u(this, we)), I(this, we, null)), P && (J(
635
- /** @type {TemplateNode} */
636
- u(this, po)
637
- ), Wi(), J(Io()));
638
- var r = !1, i = !1;
639
- const s = () => {
640
- if (r) {
641
- zi();
642
- return;
643
- }
644
- r = !0, i && ji(), u(this, we) !== null && pt(u(this, we), () => {
645
- I(this, we, null);
646
- }), M(this, q, $o).call(this, () => {
647
- ft.ensure(), M(this, q, Fo).call(this);
648
- });
649
- }, l = (a) => {
650
- try {
651
- i = !0, o?.(a, s), i = !1;
652
- } catch (c) {
653
- Ke(c, u(this, Y) && u(this, Y).parent);
654
- }
655
- n && I(this, we, M(this, q, $o).call(this, () => {
656
- ft.ensure();
657
- try {
658
- return fe(() => {
659
- var c = (
660
- /** @type {Effect} */
661
- k
662
- );
663
- c.b = this, c.f |= jo, n(
664
- u(this, ee),
665
- () => a,
666
- () => s
667
- );
668
- });
669
- } catch (c) {
670
- return Ke(
671
- c,
672
- /** @type {Effect} */
673
- u(this, Y).parent
674
- ), null;
675
- }
676
- }));
677
- };
678
- dt(() => {
679
- var a;
680
- try {
681
- a = this.transform_error(t);
682
- } catch (c) {
683
- Ke(c, u(this, Y) && u(this, Y).parent);
684
- return;
685
- }
686
- a !== null && typeof a == "object" && typeof /** @type {any} */
687
- a.then == "function" ? a.then(
688
- l,
689
- /** @param {unknown} e */
690
- (c) => Ke(c, u(this, Y) && u(this, Y).parent)
691
- ) : l(a);
692
- });
693
- }
694
- }
695
- ee = /* @__PURE__ */ new WeakMap(), po = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakMap(), Tt = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), we = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap(), Ht = /* @__PURE__ */ new WeakMap(), Kt = /* @__PURE__ */ new WeakMap(), Yt = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Ho = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakSet(), vr = function() {
696
- try {
697
- I(this, Pe, fe(() => u(this, Tt).call(this, u(this, ee))));
698
- } catch (e) {
699
- this.error(e);
700
- }
701
- }, /**
702
- * @param {unknown} error The deserialized error from the server's hydration comment
703
- */
704
- gr = function(e) {
705
- const t = u(this, Ee).failed;
706
- t && I(this, we, fe(() => {
707
- t(
708
- u(this, ee),
709
- () => e,
710
- () => () => {
711
- }
712
- );
713
- }));
714
- }, mr = function() {
715
- const e = u(this, Ee).pending;
716
- e && (this.is_pending = !0, I(this, te, fe(() => e(u(this, ee)))), dt(() => {
717
- var t = I(this, Be, document.createDocumentFragment()), o = Oe();
718
- t.append(o), I(this, Pe, M(this, q, $o).call(this, () => (ft.ensure(), fe(() => u(this, Tt).call(this, o))))), u(this, qe) === 0 && (u(this, ee).before(t), I(this, Be, null), pt(
719
- /** @type {Effect} */
720
- u(this, te),
721
- () => {
722
- I(this, te, null);
723
- }
724
- ), M(this, q, io).call(this));
725
- }));
726
- }, Fo = function() {
727
- try {
728
- if (this.is_pending = this.has_pending_snippet(), I(this, qe, 0), I(this, rt, 0), I(this, Pe, fe(() => {
729
- u(this, Tt).call(this, u(this, ee));
730
- })), u(this, qe) > 0) {
731
- var e = I(this, Be, document.createDocumentFragment());
732
- gn(u(this, Pe), e);
733
- const t = (
734
- /** @type {(anchor: Node) => void} */
735
- u(this, Ee).pending
736
- );
737
- I(this, te, fe(() => t(u(this, ee))));
738
- } else
739
- M(this, q, io).call(this);
740
- } catch (t) {
741
- this.error(t);
742
- }
743
- }, io = function() {
744
- this.is_pending = !1;
745
- for (const e of u(this, Kt))
746
- O(e, z), Te(e);
747
- for (const e of u(this, Yt))
748
- O(e, ve), Te(e);
749
- u(this, Kt).clear(), u(this, Yt).clear();
750
- }, /**
751
- * @template T
752
- * @param {() => T} fn
753
- */
754
- $o = function(e) {
755
- var t = k, o = S, n = re;
756
- $e(u(this, Y)), ie(u(this, Y)), Ct(u(this, Y).ctx);
757
- try {
758
- return e();
759
- } catch (r) {
760
- return lr(r), null;
761
- } finally {
762
- $e(t), ie(o), Ct(n);
763
- }
764
- }, /**
765
- * Updates the pending count associated with the currently visible pending snippet,
766
- * if any, such that we can replace the snippet with content once work is done
767
- * @param {1 | -1} d
768
- */
769
- Go = function(e) {
770
- var t;
771
- if (!this.has_pending_snippet()) {
772
- this.parent && M(t = this.parent, q, Go).call(t, e);
773
- return;
774
- }
775
- I(this, qe, u(this, qe) + e), u(this, qe) === 0 && (M(this, q, io).call(this), u(this, te) && pt(u(this, te), () => {
776
- I(this, te, null);
777
- }), u(this, Be) && (u(this, ee).before(u(this, Be)), I(this, Be, null)));
778
- };
779
- function Xi(e, t, o, n) {
780
- const r = Co;
781
- var i = e.filter((f) => !f.settled);
782
- if (o.length === 0 && i.length === 0) {
783
- n(t.map(r));
784
- return;
785
- }
786
- var s = (
787
- /** @type {Effect} */
788
- k
789
- ), l = Qi(), a = i.length === 1 ? i[0].promise : i.length > 1 ? Promise.all(i.map((f) => f.promise)) : null;
790
- function c(f) {
791
- l();
792
- try {
793
- n(f);
794
- } catch (b) {
795
- (s.f & Ie) === 0 && Ke(b, s);
796
- }
797
- Uo();
798
- }
799
- if (o.length === 0) {
800
- a.then(() => c(t.map(r)));
801
- return;
802
- }
803
- function d() {
804
- l(), Promise.all(o.map((f) => /* @__PURE__ */ ts(f))).then((f) => c([...t.map(r), ...f])).catch((f) => Ke(f, s));
805
- }
806
- a ? a.then(d) : d();
807
- }
808
- function Qi() {
809
- var e = k, t = S, o = re, n = L;
810
- return function(r = !0) {
811
- $e(e), ie(t), Ct(o), r && n?.activate();
812
- };
813
- }
814
- function Uo(e = !0) {
815
- $e(null), ie(null), Ct(null), e && L?.deactivate();
816
- }
817
- function es() {
818
- var e = (
819
- /** @type {Boundary} */
820
- /** @type {Effect} */
821
- k.b
822
- ), t = (
823
- /** @type {Batch} */
824
- L
825
- ), o = e.is_rendered();
826
- return e.update_pending_count(1), t.increment(o), () => {
827
- e.update_pending_count(-1), t.decrement(o);
828
- };
829
- }
830
- // @__NO_SIDE_EFFECTS__
831
- function Co(e) {
832
- var t = j | z, o = S !== null && (S.f & j) !== 0 ? (
833
- /** @type {Derived} */
834
- S
835
- ) : null;
836
- return k !== null && (k.f |= gt), {
837
- ctx: re,
838
- deps: null,
839
- effects: null,
840
- equals: tr,
841
- f: t,
842
- fn: e,
843
- reactions: null,
844
- rv: 0,
845
- v: (
846
- /** @type {V} */
847
- N
848
- ),
849
- wv: 0,
850
- parent: o ?? k,
851
- ac: null
852
- };
853
- }
854
- // @__NO_SIDE_EFFECTS__
855
- function ts(e, t, o) {
856
- k === null && _i();
857
- var n = (
858
- /** @type {Promise<V>} */
859
- /** @type {unknown} */
860
- void 0
861
- ), r = ht(
862
- /** @type {V} */
863
- N
864
- ), i = !S, s = /* @__PURE__ */ new Map();
865
- return fs(() => {
866
- var l = Qn();
867
- n = l.promise;
868
- try {
869
- Promise.resolve(e()).then(l.resolve, l.reject).finally(Uo);
870
- } catch (f) {
871
- l.reject(f), Uo();
872
- }
873
- var a = (
874
- /** @type {Batch} */
875
- L
876
- );
877
- if (i) {
878
- var c = es();
879
- s.get(a)?.reject(it), s.delete(a), s.set(a, l);
880
- }
881
- const d = (f, b = void 0) => {
882
- if (a.activate(), b)
883
- b !== it && (r.f |= Ye, Pt(r, b));
884
- else {
885
- (r.f & Ye) !== 0 && (r.f ^= Ye), Pt(r, f);
886
- for (const [g, h] of s) {
887
- if (s.delete(g), g === a) break;
888
- h.reject(it);
889
- }
890
- }
891
- c && c();
892
- };
893
- l.promise.then(d, (f) => d(null, f || "unknown"));
894
- }), cs(() => {
895
- for (const l of s.values())
896
- l.reject(it);
897
- }), new Promise((l) => {
898
- function a(c) {
899
- function d() {
900
- c === n ? l(r) : a(n);
901
- }
902
- c.then(d, d);
903
- }
904
- a(n);
905
- });
906
- }
907
- // @__NO_SIDE_EFFECTS__
908
- function Oo(e) {
909
- const t = /* @__PURE__ */ Co(e);
910
- return Rr(t), t;
911
- }
912
- // @__NO_SIDE_EFFECTS__
913
- function os(e) {
914
- const t = /* @__PURE__ */ Co(e);
915
- return t.equals = or, t;
916
- }
917
- function ns(e) {
918
- var t = e.effects;
919
- if (t !== null) {
920
- e.effects = null;
921
- for (var o = 0; o < t.length; o += 1)
922
- H(
923
- /** @type {Effect} */
924
- t[o]
925
- );
926
- }
927
- }
928
- function rs(e) {
929
- for (var t = e.parent; t !== null; ) {
930
- if ((t.f & j) === 0)
931
- return (t.f & Ie) === 0 ? (
932
- /** @type {Effect} */
933
- t
934
- ) : null;
935
- t = t.parent;
936
- }
937
- return null;
938
- }
939
- function an(e) {
940
- var t, o = k;
941
- $e(rs(e));
942
- try {
943
- e.f &= ~ut, ns(e), t = zr(e);
944
- } finally {
945
- $e(o);
946
- }
947
- return t;
948
- }
949
- function br(e) {
950
- var t = an(e);
951
- if (!e.equals(t) && (e.wv = Vr(), (!L?.is_fork || e.deps === null) && (e.v = t, e.deps === null))) {
952
- O(e, V);
953
- return;
954
- }
955
- Ze || (pe !== null ? (dn() || L?.is_fork) && pe.set(e, t) : ln(e));
956
- }
957
- function is(e) {
958
- if (e.effects !== null)
959
- for (const t of e.effects)
960
- (t.teardown || t.ac) && (t.teardown?.(), t.ac?.abort(it), t.teardown = Ti, t.ac = null, Zt(t, 0), pn(t));
961
- }
962
- function yr(e) {
963
- if (e.effects !== null)
964
- for (const t of e.effects)
965
- t.teardown && Mt(t);
966
- }
967
- let Ko = /* @__PURE__ */ new Set();
968
- const Je = /* @__PURE__ */ new Map();
969
- let wr = !1;
970
- function ht(e, t) {
971
- var o = {
972
- f: 0,
973
- // TODO ideally we could skip this altogether, but it causes type errors
974
- v: e,
975
- reactions: null,
976
- equals: tr,
977
- rv: 0,
978
- wv: 0
979
- };
980
- return o;
981
- }
982
- // @__NO_SIDE_EFFECTS__
983
- function R(e, t) {
984
- const o = ht(e);
985
- return Rr(o), o;
986
- }
987
- // @__NO_SIDE_EFFECTS__
988
- function Tr(e, t = !1, o = !0) {
989
- const n = ht(e);
990
- return t || (n.equals = or), n;
991
- }
992
- function A(e, t, o = !1) {
993
- S !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
994
- // to ensure we error if state is set inside an inspect effect
995
- (!he || (S.f & _n) !== 0) && ir() && (S.f & (j | Xe | sn | _n)) !== 0 && (ne === null || !kt.call(ne, e)) && Vi();
996
- let n = o ? It(t) : t;
997
- return Pt(e, n);
998
- }
999
- function Pt(e, t) {
1000
- if (!e.equals(t)) {
1001
- var o = e.v;
1002
- Ze ? Je.set(e, t) : Je.set(e, o), e.v = t;
1003
- var n = ft.ensure();
1004
- if (n.capture(e, o), (e.f & j) !== 0) {
1005
- const r = (
1006
- /** @type {Derived} */
1007
- e
1008
- );
1009
- (e.f & z) !== 0 && an(r), ln(r);
1010
- }
1011
- e.wv = Vr(), Ir(e, z), k !== null && (k.f & V) !== 0 && (k.f & (ge | Qe)) === 0 && (Q === null ? vs([e]) : Q.push(e)), !n.is_fork && Ko.size > 0 && !wr && ss();
1012
- }
1013
- return t;
1014
- }
1015
- function ss() {
1016
- wr = !1;
1017
- for (const e of Ko)
1018
- (e.f & V) !== 0 && O(e, ve), Qt(e) && Mt(e);
1019
- Ko.clear();
1020
- }
1021
- function Jt(e) {
1022
- A(e, e.v + 1);
1023
- }
1024
- function Ir(e, t) {
1025
- var o = e.reactions;
1026
- if (o !== null)
1027
- for (var n = o.length, r = 0; r < n; r++) {
1028
- var i = o[r], s = i.f, l = (s & z) === 0;
1029
- if (l && O(i, t), (s & j) !== 0) {
1030
- var a = (
1031
- /** @type {Derived} */
1032
- i
1033
- );
1034
- pe?.delete(a), (s & ut) === 0 && (s & oe && (i.f |= ut), Ir(a, ve));
1035
- } else l && ((s & Xe) !== 0 && _e !== null && _e.add(
1036
- /** @type {Effect} */
1037
- i
1038
- ), Te(
1039
- /** @type {Effect} */
1040
- i
1041
- ));
1042
- }
1043
- }
1044
- function It(e) {
1045
- if (typeof e != "object" || e === null || uo in e)
1046
- return e;
1047
- const t = Xn(e);
1048
- if (t !== yi && t !== wi)
1049
- return e;
1050
- var o = /* @__PURE__ */ new Map(), n = Zn(e), r = /* @__PURE__ */ R(0), i = ct, s = (l) => {
1051
- if (ct === i)
1052
- return l();
1053
- var a = S, c = ct;
1054
- ie(null), Mn(i);
1055
- var d = l();
1056
- return ie(a), Mn(c), d;
1057
- };
1058
- return n && o.set("length", /* @__PURE__ */ R(
1059
- /** @type {any[]} */
1060
- e.length
1061
- )), new Proxy(
1062
- /** @type {any} */
1063
- e,
1064
- {
1065
- defineProperty(l, a, c) {
1066
- (!("value" in c) || c.configurable === !1 || c.enumerable === !1 || c.writable === !1) && Ri();
1067
- var d = o.get(a);
1068
- return d === void 0 ? s(() => {
1069
- var f = /* @__PURE__ */ R(c.value);
1070
- return o.set(a, f), f;
1071
- }) : A(d, c.value, !0), !0;
1072
- },
1073
- deleteProperty(l, a) {
1074
- var c = o.get(a);
1075
- if (c === void 0) {
1076
- if (a in l) {
1077
- const d = s(() => /* @__PURE__ */ R(N));
1078
- o.set(a, d), Jt(r);
1079
- }
1080
- } else
1081
- A(c, N), Jt(r);
1082
- return !0;
1083
- },
1084
- get(l, a, c) {
1085
- if (a === uo)
1086
- return e;
1087
- var d = o.get(a), f = a in l;
1088
- if (d === void 0 && (!f || xt(l, a)?.writable) && (d = s(() => {
1089
- var g = It(f ? l[a] : N), h = /* @__PURE__ */ R(g);
1090
- return h;
1091
- }), o.set(a, d)), d !== void 0) {
1092
- var b = p(d);
1093
- return b === N ? void 0 : b;
1094
- }
1095
- return Reflect.get(l, a, c);
1096
- },
1097
- getOwnPropertyDescriptor(l, a) {
1098
- var c = Reflect.getOwnPropertyDescriptor(l, a);
1099
- if (c && "value" in c) {
1100
- var d = o.get(a);
1101
- d && (c.value = p(d));
1102
- } else if (c === void 0) {
1103
- var f = o.get(a), b = f?.v;
1104
- if (f !== void 0 && b !== N)
1105
- return {
1106
- enumerable: !0,
1107
- configurable: !0,
1108
- value: b,
1109
- writable: !0
1110
- };
1111
- }
1112
- return c;
1113
- },
1114
- has(l, a) {
1115
- if (a === uo)
1116
- return !0;
1117
- var c = o.get(a), d = c !== void 0 && c.v !== N || Reflect.has(l, a);
1118
- if (c !== void 0 || k !== null && (!d || xt(l, a)?.writable)) {
1119
- c === void 0 && (c = s(() => {
1120
- var b = d ? It(l[a]) : N, g = /* @__PURE__ */ R(b);
1121
- return g;
1122
- }), o.set(a, c));
1123
- var f = p(c);
1124
- if (f === N)
1125
- return !1;
1126
- }
1127
- return d;
1128
- },
1129
- set(l, a, c, d) {
1130
- var f = o.get(a), b = a in l;
1131
- if (n && a === "length")
1132
- for (var g = c; g < /** @type {Source<number>} */
1133
- f.v; g += 1) {
1134
- var h = o.get(g + "");
1135
- h !== void 0 ? A(h, N) : g in l && (h = s(() => /* @__PURE__ */ R(N)), o.set(g + "", h));
1136
- }
1137
- if (f === void 0)
1138
- (!b || xt(l, a)?.writable) && (f = s(() => /* @__PURE__ */ R(void 0)), A(f, It(c)), o.set(a, f));
1139
- else {
1140
- b = f.v !== N;
1141
- var w = s(() => It(c));
1142
- A(f, w);
1143
- }
1144
- var T = Reflect.getOwnPropertyDescriptor(l, a);
1145
- if (T?.set && T.set.call(d, c), !b) {
1146
- if (n && typeof a == "string") {
1147
- var $ = (
1148
- /** @type {Source<number>} */
1149
- o.get("length")
1150
- ), E = Number(a);
1151
- Number.isInteger(E) && E >= $.v && A($, E + 1);
1152
- }
1153
- Jt(r);
1154
- }
1155
- return !0;
1156
- },
1157
- ownKeys(l) {
1158
- p(r);
1159
- var a = Reflect.ownKeys(l).filter((f) => {
1160
- var b = o.get(f);
1161
- return b === void 0 || b.v !== N;
1162
- });
1163
- for (var [c, d] of o)
1164
- d.v !== N && !(c in l) && a.push(c);
1165
- return a;
1166
- },
1167
- setPrototypeOf() {
1168
- Ni();
1169
- }
1170
- }
1171
- );
1172
- }
1173
- var En, $r, xr, Sr;
1174
- function Yo() {
1175
- if (En === void 0) {
1176
- En = window, $r = /Firefox/.test(navigator.userAgent);
1177
- var e = Element.prototype, t = Node.prototype, o = Text.prototype;
1178
- xr = xt(t, "firstChild").get, Sr = xt(t, "nextSibling").get, An(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), An(o) && (o.__t = void 0);
1179
- }
1180
- }
1181
- function Oe(e = "") {
1182
- return document.createTextNode(e);
1183
- }
1184
- // @__NO_SIDE_EFFECTS__
1185
- function Lt(e) {
1186
- return (
1187
- /** @type {TemplateNode | null} */
1188
- xr.call(e)
1189
- );
1190
- }
1191
- // @__NO_SIDE_EFFECTS__
1192
- function xe(e) {
1193
- return (
1194
- /** @type {TemplateNode | null} */
1195
- Sr.call(e)
1196
- );
1197
- }
1198
- function so(e, t) {
1199
- if (!P)
1200
- return /* @__PURE__ */ Lt(e);
1201
- var o = /* @__PURE__ */ Lt(C);
1202
- if (o === null)
1203
- o = C.appendChild(Oe());
1204
- else if (t && o.nodeType !== So) {
1205
- var n = Oe();
1206
- return o?.before(n), J(n), n;
1207
- }
1208
- return t && un(
1209
- /** @type {Text} */
1210
- o
1211
- ), J(o), o;
1212
- }
1213
- function Ro(e, t = !1) {
1214
- if (!P) {
1215
- var o = /* @__PURE__ */ Lt(e);
1216
- return o instanceof Comment && o.data === "" ? /* @__PURE__ */ xe(o) : o;
1217
- }
1218
- if (t) {
1219
- if (C?.nodeType !== So) {
1220
- var n = Oe();
1221
- return C?.before(n), J(n), n;
1222
- }
1223
- un(
1224
- /** @type {Text} */
1225
- C
1226
- );
1227
- }
1228
- return C;
1229
- }
1230
- function je(e, t = 1, o = !1) {
1231
- let n = P ? C : e;
1232
- for (var r; t--; )
1233
- r = n, n = /** @type {TemplateNode} */
1234
- /* @__PURE__ */ xe(n);
1235
- if (!P)
1236
- return n;
1237
- if (o) {
1238
- if (n?.nodeType !== So) {
1239
- var i = Oe();
1240
- return n === null ? r?.after(i) : n.before(i), J(i), i;
1241
- }
1242
- un(
1243
- /** @type {Text} */
1244
- n
1245
- );
1246
- }
1247
- return J(n), n;
1248
- }
1249
- function kr(e) {
1250
- e.textContent = "";
1251
- }
1252
- function Ar() {
1253
- return !1;
1254
- }
1255
- function cn(e, t, o) {
1256
- return (
1257
- /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
1258
- document.createElementNS(Jn, e, void 0)
1259
- );
1260
- }
1261
- function un(e) {
1262
- if (
1263
- /** @type {string} */
1264
- e.nodeValue.length < 65536
1265
- )
1266
- return;
1267
- let t = e.nextSibling;
1268
- for (; t !== null && t.nodeType === So; )
1269
- t.remove(), e.nodeValue += /** @type {string} */
1270
- t.nodeValue, t = e.nextSibling;
1271
- }
1272
- function _r(e) {
1273
- var t = S, o = k;
1274
- ie(null), $e(null);
1275
- try {
1276
- return e();
1277
- } finally {
1278
- ie(t), $e(o);
1279
- }
1280
- }
1281
- function ls(e) {
1282
- k === null && (S === null && Li(), Pi()), Ze && Ei();
1283
- }
1284
- function as(e, t) {
1285
- var o = t.last;
1286
- o === null ? t.last = t.first = e : (o.next = e, e.prev = o, t.last = e);
1287
- }
1288
- function Se(e, t) {
1289
- var o = k;
1290
- o !== null && (o.f & D) !== 0 && (e |= D);
1291
- var n = {
1292
- ctx: re,
1293
- deps: null,
1294
- nodes: null,
1295
- f: e | z | oe,
1296
- first: null,
1297
- fn: t,
1298
- last: null,
1299
- next: null,
1300
- parent: o,
1301
- b: o && o.b,
1302
- prev: null,
1303
- teardown: null,
1304
- wv: 0,
1305
- ac: null
1306
- }, r = n;
1307
- if ((e & Ot) !== 0)
1308
- Et !== null ? Et.push(n) : Te(n);
1309
- else if (t !== null) {
1310
- try {
1311
- Mt(n);
1312
- } catch (s) {
1313
- throw H(n), s;
1314
- }
1315
- r.deps === null && r.teardown === null && r.nodes === null && r.first === r.last && // either `null`, or a singular child
1316
- (r.f & gt) === 0 && (r = r.first, (e & Xe) !== 0 && (e & _t) !== 0 && r !== null && (r.f |= _t));
1317
- }
1318
- if (r !== null && (r.parent = o, o !== null && as(r, o), S !== null && (S.f & j) !== 0 && (e & Qe) === 0)) {
1319
- var i = (
1320
- /** @type {Derived} */
1321
- S
1322
- );
1323
- (i.effects ?? (i.effects = [])).push(r);
1324
- }
1325
- return n;
1326
- }
1327
- function dn() {
1328
- return S !== null && !he;
1329
- }
1330
- function cs(e) {
1331
- const t = Se(At, null);
1332
- return O(t, V), t.teardown = e, t;
1333
- }
1334
- function Pn(e) {
1335
- ls();
1336
- var t = (
1337
- /** @type {Effect} */
1338
- k.f
1339
- ), o = !S && (t & ge) !== 0 && (t & vt) === 0;
1340
- if (o) {
1341
- var n = (
1342
- /** @type {ComponentContext} */
1343
- re
1344
- );
1345
- (n.e ?? (n.e = [])).push(e);
1346
- } else
1347
- return Cr(e);
1348
- }
1349
- function Cr(e) {
1350
- return Se(Ot | xi, e);
1351
- }
1352
- function us(e) {
1353
- ft.ensure();
1354
- const t = Se(Qe | gt, e);
1355
- return () => {
1356
- H(t);
1357
- };
1358
- }
1359
- function ds(e) {
1360
- ft.ensure();
1361
- const t = Se(Qe | gt, e);
1362
- return (o = {}) => new Promise((n) => {
1363
- o.outro ? pt(t, () => {
1364
- H(t), n(void 0);
1365
- }) : (H(t), n(void 0));
1366
- });
1367
- }
1368
- function Er(e) {
1369
- return Se(Ot, e);
1370
- }
1371
- function fs(e) {
1372
- return Se(sn | gt, e);
1373
- }
1374
- function fn(e, t = 0) {
1375
- return Se(At | t, e);
1376
- }
1377
- function lo(e, t = [], o = [], n = []) {
1378
- Xi(n, t, o, (r) => {
1379
- Se(At, () => e(...r.map(p)));
1380
- });
1381
- }
1382
- function hn(e, t = 0) {
1383
- var o = Se(Xe | t, e);
1384
- return o;
1385
- }
1386
- function fe(e) {
1387
- return Se(ge | gt, e);
1388
- }
1389
- function Pr(e) {
1390
- var t = e.teardown;
1391
- if (t !== null) {
1392
- const o = Ze, n = S;
1393
- Ln(!0), ie(null);
1394
- try {
1395
- t.call(null);
1396
- } finally {
1397
- Ln(o), ie(n);
1398
- }
1399
- }
1400
- }
1401
- function pn(e, t = !1) {
1402
- var o = e.first;
1403
- for (e.first = e.last = null; o !== null; ) {
1404
- const r = o.ac;
1405
- r !== null && _r(() => {
1406
- r.abort(it);
1407
- });
1408
- var n = o.next;
1409
- (o.f & Qe) !== 0 ? o.parent = null : H(o, t), o = n;
1410
- }
1411
- }
1412
- function hs(e) {
1413
- for (var t = e.first; t !== null; ) {
1414
- var o = t.next;
1415
- (t.f & ge) === 0 && H(t), t = o;
1416
- }
1417
- }
1418
- function H(e, t = !0) {
1419
- var o = !1;
1420
- (t || (e.f & $i) !== 0) && e.nodes !== null && e.nodes.end !== null && (ps(
1421
- e.nodes.start,
1422
- /** @type {TemplateNode} */
1423
- e.nodes.end
1424
- ), o = !0), pn(e, t && !o), Zt(e, 0), O(e, Ie);
1425
- var n = e.nodes && e.nodes.t;
1426
- if (n !== null)
1427
- for (const i of n)
1428
- i.stop();
1429
- Pr(e);
1430
- var r = e.parent;
1431
- r !== null && r.first !== null && Lr(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null;
1432
- }
1433
- function ps(e, t) {
1434
- for (; e !== null; ) {
1435
- var o = e === t ? null : /* @__PURE__ */ xe(e);
1436
- e.remove(), e = o;
1437
- }
1438
- }
1439
- function Lr(e) {
1440
- var t = e.parent, o = e.prev, n = e.next;
1441
- o !== null && (o.next = n), n !== null && (n.prev = o), t !== null && (t.first === e && (t.first = n), t.last === e && (t.last = o));
1442
- }
1443
- function pt(e, t, o = !0) {
1444
- var n = [];
1445
- Mr(e, n, !0);
1446
- var r = () => {
1447
- o && H(e), t && t();
1448
- }, i = n.length;
1449
- if (i > 0) {
1450
- var s = () => --i || r();
1451
- for (var l of n)
1452
- l.out(s);
1453
- } else
1454
- r();
1455
- }
1456
- function Mr(e, t, o) {
1457
- if ((e.f & D) === 0) {
1458
- e.f ^= D;
1459
- var n = e.nodes && e.nodes.t;
1460
- if (n !== null)
1461
- for (const l of n)
1462
- (l.is_global || o) && t.push(l);
1463
- for (var r = e.first; r !== null; ) {
1464
- var i = r.next, s = (r.f & _t) !== 0 || // If this is a branch effect without a block effect parent,
1465
- // it means the parent block effect was pruned. In that case,
1466
- // transparency information was transferred to the branch effect.
1467
- (r.f & ge) !== 0 && (e.f & Xe) !== 0;
1468
- Mr(r, t, s ? o : !1), r = i;
1469
- }
1470
- }
1471
- }
1472
- function vn(e) {
1473
- Or(e, !0);
1474
- }
1475
- function Or(e, t) {
1476
- if ((e.f & D) !== 0) {
1477
- e.f ^= D;
1478
- for (var o = e.first; o !== null; ) {
1479
- var n = o.next, r = (o.f & _t) !== 0 || (o.f & ge) !== 0;
1480
- Or(o, r ? t : !1), o = n;
1481
- }
1482
- var i = e.nodes && e.nodes.t;
1483
- if (i !== null)
1484
- for (const s of i)
1485
- (s.is_global || t) && s.in();
1486
- }
1487
- }
1488
- function gn(e, t) {
1489
- if (e.nodes)
1490
- for (var o = e.nodes.start, n = e.nodes.end; o !== null; ) {
1491
- var r = o === n ? null : /* @__PURE__ */ xe(o);
1492
- t.append(o), o = r;
1493
- }
1494
- }
1495
- let vo = !1, Ze = !1;
1496
- function Ln(e) {
1497
- Ze = e;
1498
- }
1499
- let S = null, he = !1;
1500
- function ie(e) {
1501
- S = e;
1502
- }
1503
- let k = null;
1504
- function $e(e) {
1505
- k = e;
1506
- }
1507
- let ne = null;
1508
- function Rr(e) {
1509
- S !== null && (ne === null ? ne = [e] : ne.push(e));
1510
- }
1511
- let F = null, K = 0, Q = null;
1512
- function vs(e) {
1513
- Q = e;
1514
- }
1515
- let Nr = 1, at = 0, ct = at;
1516
- function Mn(e) {
1517
- ct = e;
1518
- }
1519
- function Vr() {
1520
- return ++Nr;
1521
- }
1522
- function Qt(e) {
1523
- var t = e.f;
1524
- if ((t & z) !== 0)
1525
- return !0;
1526
- if (t & j && (e.f &= ~ut), (t & ve) !== 0) {
1527
- for (var o = (
1528
- /** @type {Value[]} */
1529
- e.deps
1530
- ), n = o.length, r = 0; r < n; r++) {
1531
- var i = o[r];
1532
- if (Qt(
1533
- /** @type {Derived} */
1534
- i
1535
- ) && br(
1536
- /** @type {Derived} */
1537
- i
1538
- ), i.wv > e.wv)
1539
- return !0;
1540
- }
1541
- (t & oe) !== 0 && // During time traveling we don't want to reset the status so that
1542
- // traversal of the graph in the other batches still happens
1543
- pe === null && O(e, V);
1544
- }
1545
- return !1;
1546
- }
1547
- function jr(e, t, o = !0) {
1548
- var n = e.reactions;
1549
- if (n !== null && !(ne !== null && kt.call(ne, e)))
1550
- for (var r = 0; r < n.length; r++) {
1551
- var i = n[r];
1552
- (i.f & j) !== 0 ? jr(
1553
- /** @type {Derived} */
1554
- i,
1555
- t,
1556
- !1
1557
- ) : t === i && (o ? O(i, z) : (i.f & V) !== 0 && O(i, ve), Te(
1558
- /** @type {Effect} */
1559
- i
1560
- ));
1561
- }
1562
- }
1563
- function zr(e) {
1564
- var t, o = F, n = K, r = Q, i = S, s = ne, l = re, a = he, c = ct, d = e.f;
1565
- F = /** @type {null | Value[]} */
1566
- null, K = 0, Q = null, S = (d & (ge | Qe)) === 0 ? e : null, ne = null, Ct(e.ctx), he = !1, ct = ++at, e.ac !== null && (_r(() => {
1567
- e.ac.abort(it);
1568
- }), e.ac = null);
1569
- try {
1570
- e.f |= zo;
1571
- var f = (
1572
- /** @type {Function} */
1573
- e.fn
1574
- ), b = f();
1575
- e.f |= vt;
1576
- var g = e.deps, h = L?.is_fork;
1577
- if (F !== null) {
1578
- var w;
1579
- if (h || Zt(e, K), g !== null && K > 0)
1580
- for (g.length = K + F.length, w = 0; w < F.length; w++)
1581
- g[K + w] = F[w];
1582
- else
1583
- e.deps = g = F;
1584
- if (dn() && (e.f & oe) !== 0)
1585
- for (w = K; w < g.length; w++)
1586
- ((t = g[w]).reactions ?? (t.reactions = [])).push(e);
1587
- } else !h && g !== null && K < g.length && (Zt(e, K), g.length = K);
1588
- if (ir() && Q !== null && !he && g !== null && (e.f & (j | ve | z)) === 0)
1589
- for (w = 0; w < /** @type {Source[]} */
1590
- Q.length; w++)
1591
- jr(
1592
- Q[w],
1593
- /** @type {Effect} */
1594
- e
1595
- );
1596
- if (i !== null && i !== e) {
1597
- if (at++, i.deps !== null)
1598
- for (let T = 0; T < n; T += 1)
1599
- i.deps[T].rv = at;
1600
- if (o !== null)
1601
- for (const T of o)
1602
- T.rv = at;
1603
- Q !== null && (r === null ? r = Q : r.push(.../** @type {Source[]} */
1604
- Q));
1605
- }
1606
- return (e.f & Ye) !== 0 && (e.f ^= Ye), b;
1607
- } catch (T) {
1608
- return lr(T);
1609
- } finally {
1610
- e.f ^= zo, F = o, K = n, Q = r, S = i, ne = s, Ct(l), he = a, ct = c;
1611
- }
1612
- }
1613
- function gs(e, t) {
1614
- let o = t.reactions;
1615
- if (o !== null) {
1616
- var n = mi.call(o, e);
1617
- if (n !== -1) {
1618
- var r = o.length - 1;
1619
- r === 0 ? o = t.reactions = null : (o[n] = o[r], o.pop());
1620
- }
1621
- }
1622
- if (o === null && (t.f & j) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1623
- // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1624
- // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1625
- (F === null || !kt.call(F, t))) {
1626
- var i = (
1627
- /** @type {Derived} */
1628
- t
1629
- );
1630
- (i.f & oe) !== 0 && (i.f ^= oe, i.f &= ~ut), ln(i), is(i), Zt(i, 0);
1631
- }
1632
- }
1633
- function Zt(e, t) {
1634
- var o = e.deps;
1635
- if (o !== null)
1636
- for (var n = t; n < o.length; n++)
1637
- gs(e, o[n]);
1638
- }
1639
- function Mt(e) {
1640
- var t = e.f;
1641
- if ((t & Ie) === 0) {
1642
- O(e, V);
1643
- var o = k, n = vo;
1644
- k = e, vo = !0;
1645
- try {
1646
- (t & (Xe | rn)) !== 0 ? hs(e) : pn(e), Pr(e);
1647
- var r = zr(e);
1648
- e.teardown = typeof r == "function" ? r : null, e.wv = Nr;
1649
- var i;
1650
- gi && qi && (e.f & z) !== 0 && e.deps;
1651
- } finally {
1652
- vo = n, k = o;
1653
- }
1654
- }
1655
- }
1656
- function p(e) {
1657
- var t = e.f, o = (t & j) !== 0;
1658
- if (S !== null && !he) {
1659
- var n = k !== null && (k.f & Ie) !== 0;
1660
- if (!n && (ne === null || !kt.call(ne, e))) {
1661
- var r = S.deps;
1662
- if ((S.f & zo) !== 0)
1663
- e.rv < at && (e.rv = at, F === null && r !== null && r[K] === e ? K++ : F === null ? F = [e] : F.push(e));
1664
- else {
1665
- (S.deps ?? (S.deps = [])).push(e);
1666
- var i = e.reactions;
1667
- i === null ? e.reactions = [S] : kt.call(i, S) || i.push(S);
1668
- }
1669
- }
1670
- }
1671
- if (Ze && Je.has(e))
1672
- return Je.get(e);
1673
- if (o) {
1674
- var s = (
1675
- /** @type {Derived} */
1676
- e
1677
- );
1678
- if (Ze) {
1679
- var l = s.v;
1680
- return ((s.f & V) === 0 && s.reactions !== null || Br(s)) && (l = an(s)), Je.set(s, l), l;
1681
- }
1682
- var a = (s.f & oe) === 0 && !he && S !== null && (vo || (S.f & oe) !== 0), c = (s.f & vt) === 0;
1683
- Qt(s) && (a && (s.f |= oe), br(s)), a && !c && (yr(s), Wr(s));
1684
- }
1685
- if (pe?.has(e))
1686
- return pe.get(e);
1687
- if ((e.f & Ye) !== 0)
1688
- throw e.v;
1689
- return e.v;
1690
- }
1691
- function Wr(e) {
1692
- if (e.f |= oe, e.deps !== null)
1693
- for (const t of e.deps)
1694
- (t.reactions ?? (t.reactions = [])).push(e), (t.f & j) !== 0 && (t.f & oe) === 0 && (yr(
1695
- /** @type {Derived} */
1696
- t
1697
- ), Wr(
1698
- /** @type {Derived} */
1699
- t
1700
- ));
1701
- }
1702
- function Br(e) {
1703
- if (e.v === N) return !0;
1704
- if (e.deps === null) return !1;
1705
- for (const t of e.deps)
1706
- if (Je.has(t) || (t.f & j) !== 0 && Br(
1707
- /** @type {Derived} */
1708
- t
1709
- ))
1710
- return !0;
1711
- return !1;
1712
- }
1713
- function qr(e) {
1714
- var t = he;
1715
- try {
1716
- return he = !0, e();
1717
- } finally {
1718
- he = t;
1719
- }
1720
- }
1721
- const $t = /* @__PURE__ */ Symbol("events"), Dr = /* @__PURE__ */ new Set(), Jo = /* @__PURE__ */ new Set();
1722
- function jt(e, t, o) {
1723
- (t[$t] ?? (t[$t] = {}))[e] = o;
1724
- }
1725
- function ms(e) {
1726
- for (var t = 0; t < e.length; t++)
1727
- Dr.add(e[t]);
1728
- for (var o of Jo)
1729
- o(e);
1730
- }
1731
- let On = null;
1732
- function Rn(e) {
1733
- var t = this, o = (
1734
- /** @type {Node} */
1735
- t.ownerDocument
1736
- ), n = e.type, r = e.composedPath?.() || [], i = (
1737
- /** @type {null | Element} */
1738
- r[0] || e.target
1739
- );
1740
- On = e;
1741
- var s = 0, l = On === e && e[$t];
1742
- if (l) {
1743
- var a = r.indexOf(l);
1744
- if (a !== -1 && (t === document || t === /** @type {any} */
1745
- window)) {
1746
- e[$t] = t;
1747
- return;
1748
- }
1749
- var c = r.indexOf(t);
1750
- if (c === -1)
1751
- return;
1752
- a <= c && (s = a);
1753
- }
1754
- if (i = /** @type {Element} */
1755
- r[s] || e.target, i !== t) {
1756
- To(e, "currentTarget", {
1757
- configurable: !0,
1758
- get() {
1759
- return i || o;
1760
- }
1761
- });
1762
- var d = S, f = k;
1763
- ie(null), $e(null);
1764
- try {
1765
- for (var b, g = []; i !== null; ) {
1766
- var h = i.assignedSlot || i.parentNode || /** @type {any} */
1767
- i.host || null;
1768
- try {
1769
- var w = i[$t]?.[n];
1770
- w != null && (!/** @type {any} */
1771
- i.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
1772
- // -> the target could not have been disabled because it emits the event in the first place
1773
- e.target === i) && w.call(i, e);
1774
- } catch (T) {
1775
- b ? g.push(T) : b = T;
1776
- }
1777
- if (e.cancelBubble || h === t || h === null)
1778
- break;
1779
- i = h;
1780
- }
1781
- if (b) {
1782
- for (let T of g)
1783
- queueMicrotask(() => {
1784
- throw T;
1785
- });
1786
- throw b;
1787
- }
1788
- } finally {
1789
- e[$t] = t, delete e.currentTarget, ie(d), $e(f);
1790
- }
1791
- }
1792
- }
1793
- const bs = (
1794
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
1795
- globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
1796
- /** @param {string} html */
1797
- createHTML: (e) => e
1798
- })
1799
- );
1800
- function ys(e) {
1801
- return (
1802
- /** @type {string} */
1803
- bs?.createHTML(e) ?? e
1804
- );
1805
- }
1806
- function ws(e) {
1807
- var t = cn("template");
1808
- return t.innerHTML = ys(e.replaceAll("<!>", "<!---->")), t.content;
1809
- }
1810
- function go(e, t) {
1811
- var o = (
1812
- /** @type {Effect} */
1813
- k
1814
- );
1815
- o.nodes === null && (o.nodes = { start: e, end: t, a: null, t: null });
1816
- }
1817
- // @__NO_SIDE_EFFECTS__
1818
- function mt(e, t) {
1819
- var o = (t & pi) !== 0, n = (t & vi) !== 0, r, i = !e.startsWith("<!>");
1820
- return () => {
1821
- if (P)
1822
- return go(C, null), C;
1823
- r === void 0 && (r = ws(i ? e : "<!>" + e), o || (r = /** @type {TemplateNode} */
1824
- /* @__PURE__ */ Lt(r)));
1825
- var s = (
1826
- /** @type {TemplateNode} */
1827
- n || $r ? document.importNode(r, !0) : r.cloneNode(!0)
1828
- );
1829
- if (o) {
1830
- var l = (
1831
- /** @type {TemplateNode} */
1832
- /* @__PURE__ */ Lt(s)
1833
- ), a = (
1834
- /** @type {TemplateNode} */
1835
- s.lastChild
1836
- );
1837
- go(l, a);
1838
- } else
1839
- go(s, s);
1840
- return s;
1841
- };
1842
- }
1843
- function He(e, t) {
1844
- if (P) {
1845
- var o = (
1846
- /** @type {Effect & { nodes: EffectNodes }} */
1847
- k
1848
- );
1849
- ((o.f & vt) === 0 || o.nodes.end === null) && (o.nodes.end = C), Ao();
1850
- return;
1851
- }
1852
- e !== null && e.before(
1853
- /** @type {Node} */
1854
- t
1855
- );
1856
- }
1857
- const Ts = ["touchstart", "touchmove"];
1858
- function Is(e) {
1859
- return Ts.includes(e);
1860
- }
1861
- function Nn(e, t) {
1862
- var o = t == null ? "" : typeof t == "object" ? `${t}` : t;
1863
- o !== (e.__t ?? (e.__t = e.nodeValue)) && (e.__t = o, e.nodeValue = `${o}`);
1864
- }
1865
- function Hr(e, t) {
1866
- return Fr(e, t);
1867
- }
1868
- function $s(e, t) {
1869
- Yo(), t.intro = t.intro ?? !1;
1870
- const o = t.target, n = P, r = C;
1871
- try {
1872
- for (var i = /* @__PURE__ */ Lt(o); i && (i.nodeType !== Xt || /** @type {Comment} */
1873
- i.data !== Yn); )
1874
- i = /* @__PURE__ */ xe(i);
1875
- if (!i)
1876
- throw St;
1877
- Me(!0), J(
1878
- /** @type {Comment} */
1879
- i
1880
- );
1881
- const s = Fr(e, { ...t, anchor: i });
1882
- return Me(!1), /** @type {Exports} */
1883
- s;
1884
- } catch (s) {
1885
- if (s instanceof Error && s.message.split(`
1886
- `).some((l) => l.startsWith("https://svelte.dev/e/")))
1887
- throw s;
1888
- return s !== St && console.warn("Failed to hydrate: ", s), t.recover === !1 && Oi(), Yo(), kr(o), Me(!1), Hr(e, t);
1889
- } finally {
1890
- Me(n), J(r);
1891
- }
1892
- }
1893
- const ao = /* @__PURE__ */ new Map();
1894
- function Fr(e, { target: t, anchor: o, props: n = {}, events: r, context: i, intro: s = !0, transformError: l }) {
1895
- Yo();
1896
- var a = void 0, c = ds(() => {
1897
- var d = o ?? t.appendChild(Oe());
1898
- Ji(
1899
- /** @type {TemplateNode} */
1900
- d,
1901
- {
1902
- pending: () => {
1903
- }
1904
- },
1905
- (g) => {
1906
- nr({});
1907
- var h = (
1908
- /** @type {ComponentContext} */
1909
- re
1910
- );
1911
- if (i && (h.c = i), r && (n.$$events = r), P && go(
1912
- /** @type {TemplateNode} */
1913
- g,
1914
- null
1915
- ), a = e(g, n) || {}, P && (k.nodes.end = C, C === null || C.nodeType !== Xt || /** @type {Comment} */
1916
- C.data !== nn))
1917
- throw ko(), St;
1918
- rr();
1919
- },
1920
- l
1921
- );
1922
- var f = /* @__PURE__ */ new Set(), b = (g) => {
1923
- for (var h = 0; h < g.length; h++) {
1924
- var w = g[h];
1925
- if (!f.has(w)) {
1926
- f.add(w);
1927
- var T = Is(w);
1928
- for (const se of [t, document]) {
1929
- var $ = ao.get(se);
1930
- $ === void 0 && ($ = /* @__PURE__ */ new Map(), ao.set(se, $));
1931
- var E = $.get(w);
1932
- E === void 0 ? (se.addEventListener(w, Rn, { passive: T }), $.set(w, 1)) : $.set(w, E + 1);
1933
- }
1934
- }
1935
- }
1936
- };
1937
- return b(xo(Dr)), Jo.add(b), () => {
1938
- for (var g of f)
1939
- for (const T of [t, document]) {
1940
- var h = (
1941
- /** @type {Map<string, number>} */
1942
- ao.get(T)
1943
- ), w = (
1944
- /** @type {number} */
1945
- h.get(g)
1946
- );
1947
- --w == 0 ? (T.removeEventListener(g, Rn), h.delete(g), h.size === 0 && ao.delete(T)) : h.set(g, w);
1948
- }
1949
- Jo.delete(b), d !== o && d.parentNode?.removeChild(d);
1950
- };
1951
- });
1952
- return Zo.set(a, c), a;
1953
- }
1954
- let Zo = /* @__PURE__ */ new WeakMap();
1955
- function xs(e, t) {
1956
- const o = Zo.get(e);
1957
- return o ? (Zo.delete(e), o(t)) : Promise.resolve();
1958
- }
1959
- var me, Fe, be, wt, mo, Xo, Gr;
1960
- class Ss {
1961
- /**
1962
- * @param {TemplateNode} anchor
1963
- * @param {boolean} transition
1964
- */
1965
- constructor(t, o = !0) {
1966
- m(this, "anchor"), x(this, me, /* @__PURE__ */ new Map()), x(this, Fe, /* @__PURE__ */ new Map()), x(this, be, /* @__PURE__ */ new Map()), x(this, wt, /* @__PURE__ */ new Set()), x(this, mo, !0), x(this, Xo, (n) => {
1967
- if (u(this, me).has(n)) {
1968
- var r = (
1969
- /** @type {Key} */
1970
- u(this, me).get(n)
1971
- ), i = u(this, Fe).get(r);
1972
- if (i)
1973
- vn(i), u(this, wt).delete(r);
1974
- else {
1975
- var s = u(this, be).get(r);
1976
- s && (s.effect.f & D) === 0 && (u(this, Fe).set(r, s.effect), u(this, be).delete(r), s.fragment.lastChild.remove(), this.anchor.before(s.fragment), i = s.effect);
1977
- }
1978
- for (const [l, a] of u(this, me)) {
1979
- if (u(this, me).delete(l), l === n)
1980
- break;
1981
- const c = u(this, be).get(a);
1982
- c && (H(c.effect), u(this, be).delete(a));
1983
- }
1984
- for (const [l, a] of u(this, Fe)) {
1985
- if (l === r || u(this, wt).has(l) || (a.f & D) !== 0) continue;
1986
- const c = () => {
1987
- if (Array.from(u(this, me).values()).includes(l)) {
1988
- var d = document.createDocumentFragment();
1989
- gn(a, d), d.append(Oe()), u(this, be).set(l, { effect: a, fragment: d });
1990
- } else
1991
- H(a);
1992
- u(this, wt).delete(l), u(this, Fe).delete(l);
1993
- };
1994
- u(this, mo) || !i ? (u(this, wt).add(l), pt(a, c, !1)) : c();
1995
- }
1996
- }
1997
- }), x(this, Gr, (n) => {
1998
- u(this, me).delete(n);
1999
- const r = Array.from(u(this, me).values());
2000
- for (const [i, s] of u(this, be))
2001
- r.includes(i) || (H(s.effect), u(this, be).delete(i));
2002
- }), this.anchor = t, I(this, mo, o);
2003
- }
2004
- /**
2005
- *
2006
- * @param {any} key
2007
- * @param {null | ((target: TemplateNode) => void)} fn
2008
- */
2009
- ensure(t, o) {
2010
- var n = (
2011
- /** @type {Batch} */
2012
- L
2013
- ), r = Ar();
2014
- o && !u(this, Fe).has(t) && !u(this, be).has(t) && u(this, Fe).set(
2015
- t,
2016
- fe(() => o(this.anchor))
2017
- ), u(this, me).set(n, t), r || (P && (this.anchor = C), u(this, Xo).call(this, n));
2018
- }
2019
- }
2020
- me = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap(), wt = /* @__PURE__ */ new WeakMap(), mo = /* @__PURE__ */ new WeakMap(), Xo = /* @__PURE__ */ new WeakMap(), Gr = /* @__PURE__ */ new WeakMap();
2021
- function zt(e, t, o = !1) {
2022
- var n;
2023
- P && (n = C, Ao());
2024
- var r = new Ss(e), i = o ? _t : 0;
2025
- function s(l, a) {
2026
- if (P) {
2027
- var c = er(
2028
- /** @type {TemplateNode} */
2029
- n
2030
- );
2031
- if (l !== parseInt(c.substring(1))) {
2032
- var d = Io();
2033
- J(d), r.anchor = d, Me(!1), r.ensure(l, a), Me(!0);
2034
- return;
2035
- }
2036
- }
2037
- r.ensure(l, a);
2038
- }
2039
- hn(() => {
2040
- var l = !1;
2041
- t((a, c = 0) => {
2042
- l = !0, s(c, a);
2043
- }), l || s(-1, null);
2044
- }, i);
2045
- }
2046
- function ks(e, t) {
2047
- return t;
2048
- }
2049
- function As(e, t, o) {
2050
- for (var n = [], r = t.length, i, s = t.length, l = 0; l < r; l++) {
2051
- let f = t[l];
2052
- pt(
2053
- f,
2054
- () => {
2055
- if (i) {
2056
- if (i.pending.delete(f), i.done.add(f), i.pending.size === 0) {
2057
- var b = (
2058
- /** @type {Set<EachOutroGroup>} */
2059
- e.outrogroups
2060
- );
2061
- Qo(e, xo(i.done)), b.delete(i), b.size === 0 && (e.outrogroups = null);
2062
- }
2063
- } else
2064
- s -= 1;
2065
- },
2066
- !1
2067
- );
2068
- }
2069
- if (s === 0) {
2070
- var a = n.length === 0 && o !== null;
2071
- if (a) {
2072
- var c = (
2073
- /** @type {Element} */
2074
- o
2075
- ), d = (
2076
- /** @type {Element} */
2077
- c.parentNode
2078
- );
2079
- kr(d), d.append(c), e.items.clear();
2080
- }
2081
- Qo(e, t, !a);
2082
- } else
2083
- i = {
2084
- pending: new Set(t),
2085
- done: /* @__PURE__ */ new Set()
2086
- }, (e.outrogroups ?? (e.outrogroups = /* @__PURE__ */ new Set())).add(i);
2087
- }
2088
- function Qo(e, t, o = !0) {
2089
- var n;
2090
- if (e.pending.size > 0) {
2091
- n = /* @__PURE__ */ new Set();
2092
- for (const s of e.pending.values())
2093
- for (const l of s)
2094
- n.add(
2095
- /** @type {EachItem} */
2096
- e.items.get(l).e
2097
- );
2098
- }
2099
- for (var r = 0; r < t.length; r++) {
2100
- var i = t[r];
2101
- if (n?.has(i)) {
2102
- i.f |= Le;
2103
- const s = document.createDocumentFragment();
2104
- gn(i, s);
2105
- } else
2106
- H(t[r], o);
2107
- }
2108
- }
2109
- var co;
2110
- function _s(e, t, o, n, r, i = null) {
2111
- var s = e, l = /* @__PURE__ */ new Map();
2112
- P && Ao();
2113
- var a = null, c = /* @__PURE__ */ os(() => {
2114
- var $ = o();
2115
- return Zn($) ? $ : $ == null ? [] : xo($);
2116
- }), d, f = /* @__PURE__ */ new Map(), b = !0;
2117
- function g($) {
2118
- (T.effect.f & Ie) === 0 && (T.pending.delete($), T.fallback = a, Cs(T, d, s, t, n), a !== null && (d.length === 0 ? (a.f & Le) === 0 ? vn(a) : (a.f ^= Le, Ft(a, null, s)) : pt(a, () => {
2119
- a = null;
2120
- })));
2121
- }
2122
- function h($) {
2123
- T.pending.delete($);
2124
- }
2125
- var w = hn(() => {
2126
- d = /** @type {V[]} */
2127
- p(c);
2128
- var $ = d.length;
2129
- let E = !1;
2130
- if (P) {
2131
- var se = er(s) === on;
2132
- se !== ($ === 0) && (s = Io(), J(s), Me(!1), E = !0);
2133
- }
2134
- for (var le = /* @__PURE__ */ new Set(), W = (
2135
- /** @type {Batch} */
2136
- L
2137
- ), Ve = Ar(), Z = 0; Z < $; Z += 1) {
2138
- P && C.nodeType === Xt && /** @type {Comment} */
2139
- C.data === nn && (s = /** @type {Comment} */
2140
- C, E = !0, Me(!1));
2141
- var X = d[Z], bt = n(X, Z), ae = b ? null : l.get(bt);
2142
- ae ? (ae.v && Pt(ae.v, X), ae.i && Pt(ae.i, Z), Ve && W.unskip_effect(ae.e)) : (ae = Es(
2143
- l,
2144
- b ? s : co ?? (co = Oe()),
2145
- X,
2146
- bt,
2147
- Z,
2148
- r,
2149
- t,
2150
- o
2151
- ), b || (ae.e.f |= Le), l.set(bt, ae)), le.add(bt);
2152
- }
2153
- if ($ === 0 && i && !a && (b ? a = fe(() => i(s)) : (a = fe(() => i(co ?? (co = Oe()))), a.f |= Le)), $ > le.size && Ci(), P && $ > 0 && J(Io()), !b)
2154
- if (f.set(W, le), Ve) {
2155
- for (const [eo, Lo] of l)
2156
- le.has(eo) || W.skip_effect(Lo.e);
2157
- W.oncommit(g), W.ondiscard(h);
2158
- } else
2159
- g(W);
2160
- E && Me(!0), p(c);
2161
- }), T = { effect: w, items: l, pending: f, outrogroups: null, fallback: a };
2162
- b = !1, P && (s = C);
2163
- }
2164
- function Wt(e) {
2165
- for (; e !== null && (e.f & ge) === 0; )
2166
- e = e.next;
2167
- return e;
2168
- }
2169
- function Cs(e, t, o, n, r) {
2170
- var i = t.length, s = e.items, l = Wt(e.effect.first), a, c = null, d = [], f = [], b, g, h, w;
2171
- for (w = 0; w < i; w += 1) {
2172
- if (b = t[w], g = r(b, w), h = /** @type {EachItem} */
2173
- s.get(g).e, e.outrogroups !== null)
2174
- for (const X of e.outrogroups)
2175
- X.pending.delete(h), X.done.delete(h);
2176
- if ((h.f & Le) !== 0)
2177
- if (h.f ^= Le, h === l)
2178
- Ft(h, null, o);
2179
- else {
2180
- var T = c ? c.next : l;
2181
- h === e.effect.last && (e.effect.last = h.prev), h.prev && (h.prev.next = h.next), h.next && (h.next.prev = h.prev), ze(e, c, h), ze(e, h, T), Ft(h, T, o), c = h, d = [], f = [], l = Wt(c.next);
2182
- continue;
2183
- }
2184
- if ((h.f & D) !== 0 && vn(h), h !== l) {
2185
- if (a !== void 0 && a.has(h)) {
2186
- if (d.length < f.length) {
2187
- var $ = f[0], E;
2188
- c = $.prev;
2189
- var se = d[0], le = d[d.length - 1];
2190
- for (E = 0; E < d.length; E += 1)
2191
- Ft(d[E], $, o);
2192
- for (E = 0; E < f.length; E += 1)
2193
- a.delete(f[E]);
2194
- ze(e, se.prev, le.next), ze(e, c, se), ze(e, le, $), l = $, c = le, w -= 1, d = [], f = [];
2195
- } else
2196
- a.delete(h), Ft(h, l, o), ze(e, h.prev, h.next), ze(e, h, c === null ? e.effect.first : c.next), ze(e, c, h), c = h;
2197
- continue;
2198
- }
2199
- for (d = [], f = []; l !== null && l !== h; )
2200
- (a ?? (a = /* @__PURE__ */ new Set())).add(l), f.push(l), l = Wt(l.next);
2201
- if (l === null)
2202
- continue;
2203
- }
2204
- (h.f & Le) === 0 && d.push(h), c = h, l = Wt(h.next);
2205
- }
2206
- if (e.outrogroups !== null) {
2207
- for (const X of e.outrogroups)
2208
- X.pending.size === 0 && (Qo(e, xo(X.done)), e.outrogroups?.delete(X));
2209
- e.outrogroups.size === 0 && (e.outrogroups = null);
2210
- }
2211
- if (l !== null || a !== void 0) {
2212
- var W = [];
2213
- if (a !== void 0)
2214
- for (h of a)
2215
- (h.f & D) === 0 && W.push(h);
2216
- for (; l !== null; )
2217
- (l.f & D) === 0 && l !== e.fallback && W.push(l), l = Wt(l.next);
2218
- var Ve = W.length;
2219
- if (Ve > 0) {
2220
- var Z = null;
2221
- As(e, W, Z);
2222
- }
2223
- }
2224
- }
2225
- function Es(e, t, o, n, r, i, s, l) {
2226
- var a = (s & di) !== 0 ? (s & hi) === 0 ? /* @__PURE__ */ Tr(o, !1, !1) : ht(o) : null, c = (s & fi) !== 0 ? ht(r) : null;
2227
- return {
2228
- v: a,
2229
- i: c,
2230
- e: fe(() => (i(t, a ?? o, c ?? r, l), () => {
2231
- e.delete(n);
2232
- }))
2233
- };
2234
- }
2235
- function Ft(e, t, o) {
2236
- if (e.nodes)
2237
- for (var n = e.nodes.start, r = e.nodes.end, i = t && (t.f & Le) === 0 ? (
2238
- /** @type {EffectNodes} */
2239
- t.nodes.start
2240
- ) : o; n !== null; ) {
2241
- var s = (
2242
- /** @type {TemplateNode} */
2243
- /* @__PURE__ */ xe(n)
2244
- );
2245
- if (i.before(n), n === r)
2246
- return;
2247
- n = s;
2248
- }
2249
- }
2250
- function ze(e, t, o) {
2251
- t === null ? e.effect.first = o : t.next = o, o === null ? e.effect.last = t : o.prev = t;
2252
- }
2253
- function Ps(e, t) {
2254
- Er(() => {
2255
- var o = e.getRootNode(), n = (
2256
- /** @type {ShadowRoot} */
2257
- o.host ? (
2258
- /** @type {ShadowRoot} */
2259
- o
2260
- ) : (
2261
- /** @type {Document} */
2262
- o.head ?? /** @type {Document} */
2263
- o.ownerDocument.head
2264
- )
2265
- );
2266
- if (!n.querySelector("#" + t.hash)) {
2267
- const r = cn("style");
2268
- r.id = t.hash, r.textContent = t.code, n.appendChild(r);
2269
- }
2270
- });
2271
- }
2272
- function Ls(e, t) {
2273
- return e == null ? null : String(e);
2274
- }
2275
- function Vn(e, t, o, n) {
2276
- var r = e.__style;
2277
- if (P || r !== t) {
2278
- var i = Ls(t);
2279
- (!P || i !== e.getAttribute("style")) && (i == null ? e.removeAttribute("style") : e.style.cssText = i), e.__style = t;
2280
- }
2281
- return n;
2282
- }
2283
- const Ms = /* @__PURE__ */ Symbol("is custom element"), Os = /* @__PURE__ */ Symbol("is html"), Rs = Ai ? "link" : "LINK";
2284
- function jn(e, t, o, n) {
2285
- var r = Ns(e);
2286
- P && (r[t] = e.getAttribute(t), t === "src" || t === "srcset" || t === "href" && e.nodeName === Rs) || r[t] !== (r[t] = o) && (t === "loading" && (e[ki] = o), o == null ? e.removeAttribute(t) : typeof o != "string" && Vs(e).includes(t) ? e[t] = o : e.setAttribute(t, o));
2287
- }
2288
- function Ns(e) {
2289
- return (
2290
- /** @type {Record<string | symbol, unknown>} **/
2291
- // @ts-expect-error
2292
- e.__attributes ?? (e.__attributes = {
2293
- [Ms]: e.nodeName.includes("-"),
2294
- [Os]: e.namespaceURI === Jn
2295
- })
2296
- );
2297
- }
2298
- var zn = /* @__PURE__ */ new Map();
2299
- function Vs(e) {
2300
- var t = e.getAttribute("is") || e.nodeName, o = zn.get(t);
2301
- if (o) return o;
2302
- zn.set(t, o = []);
2303
- for (var n, r = e, i = Element.prototype; i !== r; ) {
2304
- n = bi(r);
2305
- for (var s in n)
2306
- n[s].set && o.push(s);
2307
- r = Xn(r);
2308
- }
2309
- return o;
2310
- }
2311
- function Wn(e, t) {
2312
- return e === t || e?.[uo] === t;
2313
- }
2314
- function Bn(e = {}, t, o, n) {
2315
- return Er(() => {
2316
- var r, i;
2317
- return fn(() => {
2318
- r = i, i = [], qr(() => {
2319
- e !== o(...i) && (t(e, ...i), r && Wn(o(...r), e) && t(null, ...r));
2320
- });
2321
- }), () => {
2322
- dt(() => {
2323
- i && Wn(o(...i), e) && t(null, ...i);
2324
- });
2325
- };
2326
- }), e;
2327
- }
2328
- function No(e, t, o, n) {
2329
- var r = (
2330
- /** @type {V} */
2331
- n
2332
- ), i = !0, s = () => (i && (i = !1, r = /** @type {V} */
2333
- n), r), l;
2334
- l = /** @type {V} */
2335
- e[t], l === void 0 && n !== void 0 && (l = s());
2336
- var a;
2337
- a = () => {
2338
- var b = (
2339
- /** @type {V} */
2340
- e[t]
2341
- );
2342
- return b === void 0 ? s() : (i = !0, b);
2343
- };
2344
- var c = !1, d = /* @__PURE__ */ Co(() => (c = !1, a())), f = (
2345
- /** @type {Effect} */
2346
- k
2347
- );
2348
- return (
2349
- /** @type {() => V} */
2350
- (function(b, g) {
2351
- if (arguments.length > 0) {
2352
- const h = g ? p(d) : b;
2353
- return A(d, h), c = !0, r !== void 0 && (r = h), b;
2354
- }
2355
- return Ze && c || (f.f & Ie) !== 0 ? d.v : p(d);
2356
- })
2357
- );
2358
- }
2359
- function js(e) {
2360
- return new zs(e);
2361
- }
2362
- var Ge, de;
2363
- class zs {
2364
- /**
2365
- * @param {ComponentConstructorOptions & {
2366
- * component: any;
2367
- * }} options
2368
- */
2369
- constructor(t) {
2370
- x(this, Ge), x(this, de);
2371
- var o = /* @__PURE__ */ new Map(), n = (i, s) => {
2372
- var l = /* @__PURE__ */ Tr(s, !1, !1);
2373
- return o.set(i, l), l;
2374
- };
2375
- const r = new Proxy(
2376
- { ...t.props || {}, $$events: {} },
2377
- {
2378
- get(i, s) {
2379
- return p(o.get(s) ?? n(s, Reflect.get(i, s)));
2380
- },
2381
- has(i, s) {
2382
- return s === Si ? !0 : (p(o.get(s) ?? n(s, Reflect.get(i, s))), Reflect.has(i, s));
2383
- },
2384
- set(i, s, l) {
2385
- return A(o.get(s) ?? n(s, l), l), Reflect.set(i, s, l);
2386
- }
2387
- }
2388
- );
2389
- I(this, de, (t.hydrate ? $s : Hr)(t.component, {
2390
- target: t.target,
2391
- anchor: t.anchor,
2392
- props: r,
2393
- context: t.context,
2394
- intro: t.intro ?? !1,
2395
- recover: t.recover,
2396
- transformError: t.transformError
2397
- })), (!t?.props?.$$host || t.sync === !1) && ho(), I(this, Ge, r.$$events);
2398
- for (const i of Object.keys(u(this, de)))
2399
- i === "$set" || i === "$destroy" || i === "$on" || To(this, i, {
2400
- get() {
2401
- return u(this, de)[i];
2402
- },
2403
- /** @param {any} value */
2404
- set(s) {
2405
- u(this, de)[i] = s;
2406
- },
2407
- enumerable: !0
2408
- });
2409
- u(this, de).$set = /** @param {Record<string, any>} next */
2410
- (i) => {
2411
- Object.assign(r, i);
2412
- }, u(this, de).$destroy = () => {
2413
- xs(u(this, de));
2414
- };
2415
- }
2416
- /** @param {Record<string, any>} props */
2417
- $set(t) {
2418
- u(this, de).$set(t);
2419
- }
2420
- /**
2421
- * @param {string} event
2422
- * @param {(...args: any[]) => any} callback
2423
- * @returns {any}
2424
- */
2425
- $on(t, o) {
2426
- u(this, Ge)[t] = u(this, Ge)[t] || [];
2427
- const n = (...r) => o.call(this, ...r);
2428
- return u(this, Ge)[t].push(n), () => {
2429
- u(this, Ge)[t] = u(this, Ge)[t].filter(
2430
- /** @param {any} fn */
2431
- (r) => r !== n
2432
- );
2433
- };
2434
- }
2435
- $destroy() {
2436
- u(this, de).$destroy();
2437
- }
2438
- }
2439
- Ge = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap();
2440
- let Ur;
2441
- typeof HTMLElement == "function" && (Ur = class extends HTMLElement {
2442
- /**
2443
- * @param {*} $$componentCtor
2444
- * @param {*} $$slots
2445
- * @param {ShadowRootInit | undefined} shadow_root_init
2446
- */
2447
- constructor(e, t, o) {
2448
- super(), m(this, "$$ctor"), m(this, "$$s"), m(this, "$$c"), m(this, "$$cn", !1), m(this, "$$d", {}), m(this, "$$r", !1), m(this, "$$p_d", {}), m(this, "$$l", {}), m(this, "$$l_u", /* @__PURE__ */ new Map()), m(this, "$$me"), m(this, "$$shadowRoot", null), this.$$ctor = e, this.$$s = t, o && (this.$$shadowRoot = this.attachShadow(o));
2449
- }
2450
- /**
2451
- * @param {string} type
2452
- * @param {EventListenerOrEventListenerObject} listener
2453
- * @param {boolean | AddEventListenerOptions} [options]
2454
- */
2455
- addEventListener(e, t, o) {
2456
- if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) {
2457
- const n = this.$$c.$on(e, t);
2458
- this.$$l_u.set(t, n);
2459
- }
2460
- super.addEventListener(e, t, o);
2461
- }
2462
- /**
2463
- * @param {string} type
2464
- * @param {EventListenerOrEventListenerObject} listener
2465
- * @param {boolean | AddEventListenerOptions} [options]
2466
- */
2467
- removeEventListener(e, t, o) {
2468
- if (super.removeEventListener(e, t, o), this.$$c) {
2469
- const n = this.$$l_u.get(t);
2470
- n && (n(), this.$$l_u.delete(t));
2471
- }
2472
- }
2473
- async connectedCallback() {
2474
- if (this.$$cn = !0, !this.$$c) {
2475
- let e = function(n) {
2476
- return (r) => {
2477
- const i = cn("slot");
2478
- n !== "default" && (i.name = n), He(r, i);
2479
- };
2480
- };
2481
- if (await Promise.resolve(), !this.$$cn || this.$$c)
2482
- return;
2483
- const t = {}, o = Ws(this);
2484
- for (const n of this.$$s)
2485
- n in o && (n === "default" && !this.$$d.children ? (this.$$d.children = e(n), t.default = !0) : t[n] = e(n));
2486
- for (const n of this.attributes) {
2487
- const r = this.$$g_p(n.name);
2488
- r in this.$$d || (this.$$d[r] = bo(r, n.value, this.$$p_d, "toProp"));
2489
- }
2490
- for (const n in this.$$p_d)
2491
- !(n in this.$$d) && this[n] !== void 0 && (this.$$d[n] = this[n], delete this[n]);
2492
- this.$$c = js({
2493
- component: this.$$ctor,
2494
- target: this.$$shadowRoot || this,
2495
- props: {
2496
- ...this.$$d,
2497
- $$slots: t,
2498
- $$host: this
2499
- }
2500
- }), this.$$me = us(() => {
2501
- fn(() => {
2502
- this.$$r = !0;
2503
- for (const n of wo(this.$$c)) {
2504
- if (!this.$$p_d[n]?.reflect) continue;
2505
- this.$$d[n] = this.$$c[n];
2506
- const r = bo(
2507
- n,
2508
- this.$$d[n],
2509
- this.$$p_d,
2510
- "toAttribute"
2511
- );
2512
- r == null ? this.removeAttribute(this.$$p_d[n].attribute || n) : this.setAttribute(this.$$p_d[n].attribute || n, r);
2513
- }
2514
- this.$$r = !1;
2515
- });
2516
- });
2517
- for (const n in this.$$l)
2518
- for (const r of this.$$l[n]) {
2519
- const i = this.$$c.$on(n, r);
2520
- this.$$l_u.set(r, i);
2521
- }
2522
- this.$$l = {};
2523
- }
2524
- }
2525
- // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
2526
- // and setting attributes through setAttribute etc, this is helpful
2527
- /**
2528
- * @param {string} attr
2529
- * @param {string} _oldValue
2530
- * @param {string} newValue
2531
- */
2532
- attributeChangedCallback(e, t, o) {
2533
- this.$$r || (e = this.$$g_p(e), this.$$d[e] = bo(e, o, this.$$p_d, "toProp"), this.$$c?.$set({ [e]: this.$$d[e] }));
2534
- }
2535
- disconnectedCallback() {
2536
- this.$$cn = !1, Promise.resolve().then(() => {
2537
- !this.$$cn && this.$$c && (this.$$c.$destroy(), this.$$me(), this.$$c = void 0);
2538
- });
2539
- }
2540
- /**
2541
- * @param {string} attribute_name
2542
- */
2543
- $$g_p(e) {
2544
- return wo(this.$$p_d).find(
2545
- (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e
2546
- ) || e;
2547
- }
2548
- });
2549
- function bo(e, t, o, n) {
2550
- const r = o[e]?.type;
2551
- if (t = r === "Boolean" && typeof t != "boolean" ? t != null : t, !n || !o[e])
2552
- return t;
2553
- if (n === "toAttribute")
2554
- switch (r) {
2555
- case "Object":
2556
- case "Array":
2557
- return t == null ? null : JSON.stringify(t);
2558
- case "Boolean":
2559
- return t ? "" : null;
2560
- case "Number":
2561
- return t ?? null;
2562
- default:
2563
- return t;
2564
- }
2565
- else
2566
- switch (r) {
2567
- case "Object":
2568
- case "Array":
2569
- return t && JSON.parse(t);
2570
- case "Boolean":
2571
- return t;
2572
- // conversion already handled above
2573
- case "Number":
2574
- return t != null ? +t : t;
2575
- default:
2576
- return t;
2577
- }
2578
- }
2579
- function Ws(e) {
2580
- const t = {};
2581
- return e.childNodes.forEach((o) => {
2582
- t[
2583
- /** @type {Element} node */
2584
- o.slot || "default"
2585
- ] = !0;
2586
- }), t;
2587
- }
2588
- function Bs(e, t, o, n, r, i) {
2589
- let s = class extends Ur {
2590
- constructor() {
2591
- super(e, o, r), this.$$p_d = t;
2592
- }
2593
- static get observedAttributes() {
2594
- return wo(t).map(
2595
- (l) => (t[l].attribute || l).toLowerCase()
2596
- );
2597
- }
2598
- };
2599
- return wo(t).forEach((l) => {
2600
- To(s.prototype, l, {
2601
- get() {
2602
- return this.$$c && l in this.$$c ? this.$$c[l] : this.$$d[l];
2603
- },
2604
- set(a) {
2605
- a = bo(l, a, t), this.$$d[l] = a;
2606
- var c = this.$$c;
2607
- if (c) {
2608
- var d = xt(c, l)?.get;
2609
- d ? c[l] = a : c.$set({ [l]: a });
2610
- }
2611
- }
2612
- });
2613
- }), n.forEach((l) => {
2614
- To(s.prototype, l, {
2615
- get() {
2616
- return this.$$c?.[l];
2617
- }
2618
- });
2619
- }), e.element = /** @type {any} */
2620
- s, s;
2621
- }
2622
- class qs extends Event {
2623
- constructor(t, o, n, r) {
2624
- super("context-request", { bubbles: !0, composed: !0 }), m(this, "context"), m(this, "contextTarget"), m(this, "callback"), m(this, "subscribe"), this.context = t, this.contextTarget = o, this.callback = n, this.subscribe = r ?? !1;
2625
- }
2626
- }
2627
- class Ds {
2628
- constructor(t, o) {
2629
- m(this, "host"), m(this, "context"), m(this, "subscribe"), m(this, "onValue"), m(this, "isConnected", !1), m(this, "unsubscribe"), m(this, "currentValue"), m(this, "handleValue", (n, r) => {
2630
- r !== this.unsubscribe && (this.unsubscribe?.(), this.unsubscribe = r), !this.subscribe && this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.currentValue = n, this.onValue?.(n);
2631
- }), this.host = t, this.context = o.context, this.subscribe = o.subscribe ?? !0, this.onValue = o.onValue;
2632
- }
2633
- connect() {
2634
- this.isConnected || (this.isConnected = !0, this.requestValue());
2635
- }
2636
- disconnect() {
2637
- this.isConnected && (this.isConnected = !1, this.unsubscribe?.(), this.unsubscribe = void 0);
2638
- }
2639
- get value() {
2640
- return this.currentValue;
2641
- }
2642
- requestValue() {
2643
- this.host.dispatchEvent(new qs(this.context, this.host, this.handleValue, this.subscribe));
2644
- }
2645
- }
2646
- const Kr = (e) => e, Hs = Kr(/* @__PURE__ */ Symbol.for("pie.assessmentToolkit.shellContext")), Fs = Kr(/* @__PURE__ */ Symbol.for("pie.assessmentToolkit.regionScopeContext"));
2647
- function Yr(e, t, o) {
2648
- let n = !1;
2649
- const r = new Ds(e, {
2650
- context: t,
2651
- subscribe: !0,
2652
- onValue: (c) => {
2653
- n = !0, o(c);
2654
- }
2655
- });
2656
- r.connect();
2657
- const i = (c) => {
2658
- c.context === t && r.requestValue();
2659
- };
2660
- e.addEventListener("context-provider", i);
2661
- let s = 0;
2662
- const l = 200, a = globalThis.setInterval(() => {
2663
- if (n || s >= l) {
2664
- globalThis.clearInterval(a);
2665
- return;
2666
- }
2667
- s += 1, r.requestValue();
2668
- }, 50);
2669
- return () => {
2670
- globalThis.clearInterval(a), e.removeEventListener("context-provider", i), r.disconnect();
2671
- };
2672
- }
2673
- function Gs(e, t) {
2674
- return Yr(e, Hs, t);
2675
- }
2676
- function Us(e, t) {
2677
- return Yr(e, Fs, t);
2678
- }
2679
- var qn;
2680
- (function(e) {
2681
- e.TTS_WORD = "tts-word", e.TTS_SENTENCE = "tts-sentence", e.ANNOTATION = "annotation";
2682
- })(qn || (qn = {}));
2683
- var Ue;
2684
- (function(e) {
2685
- e.YELLOW = "yellow", e.GREEN = "green", e.BLUE = "blue", e.PINK = "pink", e.ORANGE = "orange", e.UNDERLINE = "underline";
2686
- })(Ue || (Ue = {}));
2687
- const Ks = {
2688
- tts: "textToSpeech",
2689
- colorScheme: "theme"
2690
- };
2691
- function Ys(e) {
2692
- const t = e.trim();
2693
- return t ? Ks[t] || t : "";
2694
- }
2695
- const Js = [
2696
- "assessment",
2697
- "section",
2698
- "item",
2699
- "passage",
2700
- "rubric",
2701
- "element"
2702
- ];
2703
- function yo(e, t) {
2704
- if (typeof e != "string" || e.trim().length === 0)
2705
- throw new Error(`Invalid tool registration: "${t}" must be a non-empty string.`);
2706
- }
2707
- function Dn(e) {
2708
- if (yo(e.toolId, "toolId"), yo(e.name, "name"), yo(e.description, "description"), typeof e.icon != "string" && typeof e.icon != "function")
2709
- throw new Error(`Invalid tool registration "${e.toolId}": "icon" must be a string or function.`);
2710
- if (!Array.isArray(e.supportedLevels) || e.supportedLevels.length === 0)
2711
- throw new Error(`Invalid tool registration "${e.toolId}": "supportedLevels" must be a non-empty array.`);
2712
- const t = e.supportedLevels.find((o) => !Js.includes(o));
2713
- if (t)
2714
- throw new Error(`Invalid tool registration "${e.toolId}": unsupported level "${t}".`);
2715
- if (e.activation !== void 0 && e.activation !== "toolbar-toggle" && e.activation !== "selection-gateway")
2716
- throw new Error(`Invalid tool registration "${e.toolId}": unsupported activation "${String(e.activation)}".`);
2717
- if (e.singletonScope !== void 0 && e.singletonScope !== "section")
2718
- throw new Error(`Invalid tool registration "${e.toolId}": unsupported singletonScope "${String(e.singletonScope)}".`);
2719
- if (e.activation === "selection-gateway" && e.singletonScope !== "section")
2720
- throw new Error(`Invalid tool registration "${e.toolId}": selection-gateway tools must declare singletonScope "section".`);
2721
- if (e.pnpSupportIds !== void 0 && (!Array.isArray(e.pnpSupportIds) || e.pnpSupportIds.some((o) => typeof o != "string" || o.trim().length === 0)))
2722
- throw new Error(`Invalid tool registration "${e.toolId}": "pnpSupportIds" must be an array of non-empty strings.`);
2723
- if (typeof e.isVisibleInContext != "function")
2724
- throw new Error(`Invalid tool registration "${e.toolId}": "isVisibleInContext" must be a function.`);
2725
- if (typeof e.renderToolbar != "function")
2726
- throw new Error(`Invalid tool registration "${e.toolId}": "renderToolbar" must be a function.`);
2727
- }
2728
- class Zs {
2729
- constructor() {
2730
- m(this, "tools", /* @__PURE__ */ new Map()), m(this, "pnpIndex", /* @__PURE__ */ new Map()), m(this, "componentOverrides", {}), m(this, "moduleLoaders", /* @__PURE__ */ new Map()), m(this, "loadedToolModules", /* @__PURE__ */ new Set()), m(this, "moduleLoadPromises", /* @__PURE__ */ new Map());
2731
- }
2732
- /**
2733
- * Normalize a single tool alias to canonical toolId.
2734
- */
2735
- normalizeToolId(t) {
2736
- return Ys(t);
2737
- }
2738
- /**
2739
- * Normalize a list of tool aliases to canonical toolIds.
2740
- */
2741
- normalizeToolIds(t) {
2742
- return t.map((o) => this.normalizeToolId(o));
2743
- }
2744
- /**
2745
- * Register a tool
2746
- *
2747
- * @param registration - Tool registration
2748
- * @throws Error if toolId is already registered
2749
- */
2750
- register(t) {
2751
- if (Dn(t), this.tools.has(t.toolId))
2752
- throw new Error(`Tool '${t.toolId}' is already registered`);
2753
- if (this.tools.set(t.toolId, t), t.pnpSupportIds)
2754
- for (const o of t.pnpSupportIds)
2755
- this.pnpIndex.has(o) || this.pnpIndex.set(o, /* @__PURE__ */ new Set()), this.pnpIndex.get(o).add(t.toolId);
2756
- }
2757
- /**
2758
- * Override an existing tool registration
2759
- *
2760
- * @param registration - New tool registration (must have existing toolId)
2761
- */
2762
- override(t) {
2763
- if (Dn(t), !this.tools.has(t.toolId))
2764
- throw new Error(`Cannot override non-existent tool '${t.toolId}'`);
2765
- const o = this.tools.get(t.toolId);
2766
- if (o.pnpSupportIds)
2767
- for (const n of o.pnpSupportIds)
2768
- this.pnpIndex.get(n)?.delete(t.toolId);
2769
- if (this.tools.set(t.toolId, t), t.pnpSupportIds)
2770
- for (const n of t.pnpSupportIds)
2771
- this.pnpIndex.has(n) || this.pnpIndex.set(n, /* @__PURE__ */ new Set()), this.pnpIndex.get(n).add(t.toolId);
2772
- }
2773
- /**
2774
- * Unregister a tool
2775
- *
2776
- * @param toolId - Tool ID to remove
2777
- */
2778
- unregister(t) {
2779
- const o = this.tools.get(t);
2780
- if (o) {
2781
- if (o.pnpSupportIds)
2782
- for (const n of o.pnpSupportIds)
2783
- this.pnpIndex.get(n)?.delete(t);
2784
- this.tools.delete(t);
2785
- }
2786
- }
2787
- /**
2788
- * Get a tool registration by ID
2789
- *
2790
- * @param toolId - Tool ID
2791
- * @returns Tool registration or undefined
2792
- */
2793
- get(t) {
2794
- return this.tools.get(t);
2795
- }
2796
- /**
2797
- * Check if a tool is registered
2798
- *
2799
- * @param toolId - Tool ID
2800
- * @returns true if registered
2801
- */
2802
- has(t) {
2803
- return this.tools.has(t);
2804
- }
2805
- /**
2806
- * Get all registered tool IDs
2807
- *
2808
- * @returns Array of tool IDs
2809
- */
2810
- getAllToolIds() {
2811
- return Array.from(this.tools.keys());
2812
- }
2813
- /**
2814
- * Get all tool registrations
2815
- *
2816
- * @returns Array of tool registrations
2817
- */
2818
- getAllTools() {
2819
- return Array.from(this.tools.values());
2820
- }
2821
- /**
2822
- * Find tool IDs that support a given PNP support ID
2823
- *
2824
- * @param pnpSupportId - PNP support ID (e.g., 'calculator')
2825
- * @returns Set of tool IDs that support this PNP ID
2826
- */
2827
- getToolsByPNPSupport(t) {
2828
- return this.pnpIndex.get(t) || /* @__PURE__ */ new Set();
2829
- }
2830
- /**
2831
- * Get tools that support a specific level
2832
- *
2833
- * @param level - Tool level (assessment, section, item, passage, element)
2834
- * @returns Array of tool registrations that support this level
2835
- */
2836
- getToolsByLevel(t) {
2837
- return this.getAllTools().filter((o) => o.supportedLevels.includes(t));
2838
- }
2839
- /**
2840
- * Resolve tool activation with backward-compatible defaults.
2841
- */
2842
- getToolActivation(t) {
2843
- return this.get(t)?.activation || "toolbar-toggle";
2844
- }
2845
- /**
2846
- * Resolve singleton scope for a tool when present.
2847
- */
2848
- getToolSingletonScope(t) {
2849
- return this.get(t)?.singletonScope || null;
2850
- }
2851
- /**
2852
- * Filter tool IDs by activation type.
2853
- */
2854
- filterToolIdsByActivation(t, o) {
2855
- return t.filter((n) => this.getToolActivation(n) === o);
2856
- }
2857
- /**
2858
- * Filter tools by visibility in a given context
2859
- *
2860
- * Pass 2 of the two-pass model: Given a list of allowed tool IDs (from Pass 1),
2861
- * ask each tool if it's relevant in this context.
2862
- *
2863
- * @param allowedToolIds - Tool IDs that passed Pass 1 (orchestrator approval)
2864
- * @param context - Context to evaluate
2865
- * @returns Array of visible tool registrations
2866
- */
2867
- filterVisibleInContext(t, o) {
2868
- const n = [];
2869
- for (const r of t) {
2870
- const i = this.get(r);
2871
- if (!i) {
2872
- console.warn(`Tool '${r}' is allowed but not registered`);
2873
- continue;
2874
- }
2875
- if (i.supportedLevels.includes(o.level))
2876
- try {
2877
- i.isVisibleInContext(o) && n.push(i);
2878
- } catch (s) {
2879
- console.error(`Error evaluating visibility for tool '${r}':`, s);
2880
- }
2881
- }
2882
- return n;
2883
- }
2884
- /**
2885
- * Get tool metadata for building UIs
2886
- * Useful for building PNP configuration interfaces
2887
- *
2888
- * @returns Array of tool metadata (id, name, description, pnpSupportIds)
2889
- */
2890
- getToolMetadata() {
2891
- return this.getAllTools().map((t) => ({
2892
- toolId: t.toolId,
2893
- name: t.name,
2894
- description: t.description,
2895
- pnpSupportIds: t.pnpSupportIds || [],
2896
- supportedLevels: t.supportedLevels,
2897
- activation: t.activation || "toolbar-toggle",
2898
- singletonScope: t.singletonScope || null
2899
- }));
2900
- }
2901
- /**
2902
- * Generate PNP support IDs from enabled tools
2903
- * Useful for creating PNP profiles
2904
- *
2905
- * @param enabledToolIds - Tool IDs to enable
2906
- * @returns Array of unique PNP support IDs
2907
- */
2908
- generatePNPSupportsFromTools(t) {
2909
- const o = /* @__PURE__ */ new Set();
2910
- for (const n of t) {
2911
- const r = this.get(n);
2912
- if (r?.pnpSupportIds)
2913
- for (const i of r.pnpSupportIds)
2914
- o.add(i);
2915
- }
2916
- return Array.from(o);
2917
- }
2918
- /**
2919
- * Clear all registrations (useful for testing)
2920
- */
2921
- clear() {
2922
- this.tools.clear(), this.pnpIndex.clear();
2923
- }
2924
- /**
2925
- * Configure global component overrides used by tool instance creation.
2926
- */
2927
- setComponentOverrides(t) {
2928
- this.componentOverrides = t;
2929
- }
2930
- /**
2931
- * Register lazy module loaders by toolId.
2932
- * Toolbars call ensureToolModuleLoaded(toolId) before instance creation.
2933
- */
2934
- setToolModuleLoaders(t) {
2935
- for (const [o, n] of Object.entries(t))
2936
- if (n) {
2937
- if (yo(o, "tool module loader id"), typeof n != "function")
2938
- throw new Error(`Invalid tool module loader for "${o}": expected a function.`);
2939
- this.moduleLoaders.set(o, n);
2940
- }
2941
- }
2942
- /**
2943
- * Ensure tool module side-effects are loaded exactly once.
2944
- * Safe to call repeatedly; concurrent callers share the same promise.
2945
- */
2946
- async ensureToolModuleLoaded(t) {
2947
- if (this.loadedToolModules.has(t))
2948
- return;
2949
- const o = this.moduleLoadPromises.get(t);
2950
- if (o) {
2951
- await o;
2952
- return;
2953
- }
2954
- const n = this.moduleLoaders.get(t);
2955
- if (!n)
2956
- return;
2957
- const r = (async () => {
2958
- await n(), this.loadedToolModules.add(t);
2959
- })();
2960
- this.moduleLoadPromises.set(t, r);
2961
- try {
2962
- await r;
2963
- } finally {
2964
- this.moduleLoadPromises.delete(t);
2965
- }
2966
- }
2967
- /**
2968
- * Ensure a set of tool modules are loaded.
2969
- */
2970
- async ensureToolModulesLoaded(t) {
2971
- await Promise.all(t.map((o) => this.ensureToolModuleLoaded(o)));
2972
- }
2973
- /**
2974
- * Whether a tool module has already been loaded.
2975
- */
2976
- isToolModuleLoaded(t) {
2977
- return this.loadedToolModules.has(t);
2978
- }
2979
- /**
2980
- * Render a tool for toolbar use with component overrides attached.
2981
- */
2982
- renderForToolbar(t, o, n) {
2983
- const r = this.get(t);
2984
- if (!r)
2985
- throw new Error(`Tool '${t}' is not registered`);
2986
- const i = {
2987
- ...n,
2988
- componentOverrides: {
2989
- ...this.componentOverrides || {},
2990
- ...n.componentOverrides || {}
2991
- }
2992
- };
2993
- return r.renderToolbar(o, i);
2994
- }
2995
- }
2996
- function Jr(e) {
2997
- return e.level === "item";
2998
- }
2999
- function Xs(e) {
3000
- return e.level === "passage";
3001
- }
3002
- function Qs(e) {
3003
- return e.level === "rubric";
3004
- }
3005
- function Zr(e) {
3006
- return e.level === "element";
3007
- }
3008
- function mn(e) {
3009
- if (Zr(e)) {
3010
- const t = e.item.config;
3011
- if (!t)
3012
- return "";
3013
- const o = [], n = (l) => l.replace(/<[^>]*>/g, " ").trim(), r = t.elements?.[e.elementId];
3014
- r && typeof r == "string" && o.push(n(r));
3015
- const i = t.models, s = (Array.isArray(i) ? i : i && typeof i == "object" ? Object.values(i) : []).find((l) => l && typeof l == "object" && l.id === e.elementId);
3016
- if (s) {
3017
- for (const l of Object.values(s))
3018
- if (typeof l == "string" && o.push(n(l)), Array.isArray(l)) {
3019
- for (const a of l)
3020
- if (a && typeof a == "object")
3021
- for (const c of Object.values(a))
3022
- typeof c == "string" && o.push(n(c));
3023
- }
3024
- }
3025
- return o.filter(Boolean).join(" ").trim();
3026
- }
3027
- if (Jr(e)) {
3028
- const t = e.item;
3029
- if (!t?.config)
3030
- return "";
3031
- const o = t.config, n = [], r = (a) => a.replace(/<[^>]*>/g, " ").trim();
3032
- typeof o.markup == "string" && n.push(r(o.markup));
3033
- const i = o.elements;
3034
- if (i && typeof i == "object")
3035
- for (const a of Object.values(i))
3036
- typeof a == "string" && n.push(r(a));
3037
- const s = o.models, l = Array.isArray(s) ? s : s && typeof s == "object" ? Object.values(s) : [];
3038
- for (const a of l)
3039
- if (!(!a || typeof a != "object")) {
3040
- for (const c of Object.values(a))
3041
- if (typeof c == "string" && n.push(r(c)), Array.isArray(c)) {
3042
- for (const d of c)
3043
- if (d && typeof d == "object")
3044
- for (const f of Object.values(d))
3045
- typeof f == "string" && n.push(r(f));
3046
- }
3047
- }
3048
- return n.filter(Boolean).join(" ").trim();
3049
- }
3050
- if (Xs(e)) {
3051
- const t = e.passage;
3052
- if (!t?.config)
3053
- return "";
3054
- const o = t.config, n = [], r = (a) => a.replace(/<[^>]*>/g, " ").trim();
3055
- typeof o.markup == "string" && n.push(r(o.markup)), typeof o.content == "string" && n.push(r(o.content)), typeof o.prompt == "string" && n.push(r(o.prompt));
3056
- const i = o.elements;
3057
- if (i && typeof i == "object")
3058
- for (const a of Object.values(i))
3059
- typeof a == "string" && n.push(r(a));
3060
- const s = o.models, l = Array.isArray(s) ? s : s && typeof s == "object" ? Object.values(s) : [];
3061
- for (const a of l)
3062
- if (!(!a || typeof a != "object")) {
3063
- for (const c of Object.values(a))
3064
- if (typeof c == "string" && n.push(r(c)), Array.isArray(c)) {
3065
- for (const d of c)
3066
- if (d && typeof d == "object")
3067
- for (const f of Object.values(d))
3068
- typeof f == "string" && n.push(r(f));
3069
- }
3070
- }
3071
- return n.filter(Boolean).join(" ").trim();
3072
- }
3073
- if (Qs(e)) {
3074
- const t = e.rubricBlock;
3075
- return t.passage?.config ? (t.passage.config.markup || "").replace(/<[^>]*>/g, " ").trim() : (t.content || "").replace(/<[^>]*>/g, " ").trim();
3076
- }
3077
- return "";
3078
- }
3079
- function Eo(e) {
3080
- const t = mn(e);
3081
- return [
3082
- /<math[>\s]/i,
3083
- // MathML
3084
- /\\\[([^\]]+)\\\]/,
3085
- // LaTeX display math
3086
- /\$\$[^$]+\$\$/,
3087
- // LaTeX display math ($$...$$)
3088
- /\\\(/,
3089
- // LaTeX inline math
3090
- /[+\-*/=<>≤≥∑∫√π]/,
3091
- // Math symbols
3092
- /\d+\s*[+\-*/=]\s*\d+/
3093
- // Simple arithmetic
3094
- ].some((o) => o.test(t));
3095
- }
3096
- function el(e) {
3097
- const t = [
3098
- "pie-multiple-choice",
3099
- "pie-inline-choice",
3100
- "pie-select-text",
3101
- "multiple-choice",
3102
- "inline-choice",
3103
- "select-text"
3104
- ];
3105
- if (Zr(e)) {
3106
- const o = e.item.config;
3107
- if (!o?.models)
3108
- return !1;
3109
- const n = (Array.isArray(o.models) ? o.models : Object.values(o.models)).find((i) => i && typeof i == "object" && i.id === e.elementId);
3110
- if (!n)
3111
- return !1;
3112
- const r = n.element || "";
3113
- return t.includes(r);
3114
- }
3115
- if (Jr(e)) {
3116
- const o = e.item.config?.models;
3117
- return (Array.isArray(o) ? o : o && typeof o == "object" ? Object.values(o) : []).some((n) => {
3118
- if (!n || typeof n != "object")
3119
- return !1;
3120
- const r = n.element || "";
3121
- return t.includes(r) ? !0 : Array.isArray(n.choices) && n.choices.length > 0;
3122
- });
3123
- }
3124
- return !1;
3125
- }
3126
- function Po(e) {
3127
- return mn(e).trim().length >= 10;
3128
- }
3129
- function tl(e) {
3130
- const t = mn(e);
3131
- return [
3132
- /chemistry|chemical|element|atom|molecule|compound/i,
3133
- /periodic\s+table/i,
3134
- /H₂O|CO₂|NaCl|O₂|N₂/i,
3135
- // Chemical formulas
3136
- /\b[A-Z][a-z]?\d*\b/,
3137
- // Element symbols (H, He, Li, etc.)
3138
- /biology|organism|cell|DNA|RNA|protein/i,
3139
- /physics|force|energy|velocity|acceleration/i
3140
- ].some((o) => o.test(t));
3141
- }
3142
- const ol = [
3143
- "assessment",
3144
- "section",
3145
- "item",
3146
- "passage",
3147
- "rubric"
3148
- ], nl = new Set(ol);
3149
- function rl(e) {
3150
- return nl.has(e);
3151
- }
3152
- function bn(e, t, o) {
3153
- const n = e.trim(), r = o.trim();
3154
- if (!n || !r)
3155
- throw new Error("Tool instance ids require non-empty tool and scope ids");
3156
- if (!rl(t))
3157
- throw new Error(`Unknown tool scope level '${t}'. Register custom levels with registerToolScopeLevel().`);
3158
- return `${n}:${t}:${r}`;
3159
- }
3160
- class il {
3161
- constructor() {
3162
- m(this, "providerId", "desmos-calculator"), m(this, "providerName", "Desmos Calculator"), m(this, "category", "calculator"), m(this, "version", "1.10"), m(this, "requiresAuth", !0), m(this, "desmosProvider", null), m(this, "config", null);
3163
- }
3164
- /**
3165
- * Initialize Desmos calculator provider
3166
- *
3167
- * Loads the Desmos API library and authenticates with provided credentials.
3168
- *
3169
- * @param config Configuration with API key or proxy endpoint
3170
- * @throws Error if initialization fails
3171
- */
3172
- async initialize(t) {
3173
- if (this.desmosProvider) {
3174
- console.warn("[DesmosToolProvider] Already initialized, skipping reinitialization");
3175
- return;
3176
- }
3177
- this.config = t;
3178
- const o = await import("./index-DF-Dk87f-lxErM8bo.js");
3179
- this.desmosProvider = new o.DesmosCalculatorProvider();
3180
- try {
3181
- await this.desmosProvider.initialize({
3182
- apiKey: t.apiKey,
3183
- proxyEndpoint: t.proxyEndpoint
3184
- }), console.log(`[DesmosToolProvider] Initialized successfully ${t.proxyEndpoint ? "(using proxy)" : t.apiKey ? "(direct API key)" : "(no auth)"}`);
3185
- } catch (n) {
3186
- throw console.error("[DesmosToolProvider] Initialization failed:", n), new Error("Failed to initialize Desmos calculator provider. Check API key or proxy endpoint.");
3187
- }
3188
- }
3189
- /**
3190
- * Create a calculator provider instance
3191
- *
3192
- * Returns the initialized Desmos calculator provider.
3193
- *
3194
- * @param config Optional instance-specific configuration (currently unused)
3195
- * @returns Desmos calculator provider
3196
- * @throws Error if provider not initialized
3197
- */
3198
- async createInstance(t) {
3199
- if (!this.desmosProvider)
3200
- throw new Error("[DesmosToolProvider] Provider not initialized. Call initialize() first.");
3201
- return this.desmosProvider;
3202
- }
3203
- /**
3204
- * Get provider capabilities
3205
- *
3206
- * @returns Desmos calculator capabilities
3207
- */
3208
- getCapabilities() {
3209
- return {
3210
- supportsOffline: !1,
3211
- // Requires Desmos CDN
3212
- requiresAuth: !0,
3213
- maxInstances: null,
3214
- // Unlimited calculator instances
3215
- features: {
3216
- basic: !0,
3217
- scientific: !0,
3218
- graphing: !0,
3219
- fourFunction: !0
3220
- }
3221
- };
3222
- }
3223
- /**
3224
- * Check if provider is ready
3225
- *
3226
- * @returns true if provider is initialized
3227
- */
3228
- isReady() {
3229
- return this.desmosProvider !== null;
3230
- }
3231
- /**
3232
- * Clean up provider resources
3233
- *
3234
- * Destroys the Desmos calculator provider and releases resources.
3235
- */
3236
- destroy() {
3237
- this.desmosProvider && (this.desmosProvider.destroy(), this.desmosProvider = null), this.config = null, console.log("[DesmosToolProvider] Destroyed");
3238
- }
3239
- }
3240
- const sl = (e, t) => {
3241
- const o = t?.useSentenceSegmenter !== !1;
3242
- try {
3243
- if (!o)
3244
- throw new Error("Segmenter disabled by policy");
3245
- const l = globalThis.Intl?.Segmenter;
3246
- if (typeof l == "function") {
3247
- const a = new l(t?.locale, {
3248
- granularity: "sentence"
3249
- }), c = Array.from(a.segment(e)).map((d) => ({
3250
- text: d.segment,
3251
- offset: d.index
3252
- })).filter((d) => d.text.trim().length > 0);
3253
- if (c.length > 0)
3254
- return c;
3255
- }
3256
- } catch {
3257
- }
3258
- const n = /[^.!?]+(?:[.!?]+|$)/g, r = e.match(n) || [e], i = [];
3259
- let s = 0;
3260
- for (const l of r) {
3261
- const a = e.indexOf(l, s);
3262
- a !== -1 && (i.push({ text: l, offset: a }), s = a + l.length);
3263
- }
3264
- return i.length > 0 ? i : [{ text: e, offset: 0 }];
3265
- };
3266
- class ll {
3267
- constructor() {
3268
- m(this, "providerId", "browser"), m(this, "providerName", "Browser Speech Synthesis"), m(this, "version", "1.0.0");
3269
- }
3270
- async initialize(t) {
3271
- if (typeof window > "u")
3272
- throw new Error("BrowserTTSProvider requires browser environment");
3273
- if (!("speechSynthesis" in window))
3274
- throw new Error("Browser does not support Speech Synthesis API");
3275
- return new al(t);
3276
- }
3277
- supportsFeature(t) {
3278
- return !0;
3279
- }
3280
- getCapabilities() {
3281
- return {
3282
- supportsPause: !0,
3283
- supportsResume: !0,
3284
- supportsWordBoundary: !0,
3285
- supportsVoiceSelection: !0,
3286
- supportsRateControl: !0,
3287
- supportsPitchControl: !0
3288
- };
3289
- }
3290
- destroy() {
3291
- }
3292
- }
3293
- class al {
3294
- constructor(t) {
3295
- m(this, "utterance", null), m(this, "config", null), m(this, "_isPlaying", !1), m(this, "_isPaused", !1), m(this, "speakRunId", 0), m(this, "onWordBoundary"), this.config = t;
3296
- }
3297
- async speak(t) {
3298
- if (!this.config)
3299
- throw new Error("TTS not initialized");
3300
- this.stop();
3301
- const o = this.speakRunId, n = this.splitIntoChunks(t);
3302
- for (const r of n)
3303
- if (o !== this.speakRunId || !await this.speakChunk(r.text, r.offset, o))
3304
- break;
3305
- }
3306
- async speakSegments(t) {
3307
- if (!this.config)
3308
- throw new Error("TTS not initialized");
3309
- this.stop();
3310
- const o = this.speakRunId;
3311
- for (const n of t) {
3312
- if (o !== this.speakRunId)
3313
- break;
3314
- const r = this.splitIntoChunks(n.text);
3315
- for (const s of r)
3316
- if (o !== this.speakRunId || !await this.speakChunk(s.text, n.startOffset + s.offset, o))
3317
- break;
3318
- const i = Math.max(0, Number(n.pauseMsAfter || 0));
3319
- if (i > 0 && o === this.speakRunId && !await this.waitForPause(i, o))
3320
- break;
3321
- }
3322
- }
3323
- async waitForPause(t, o) {
3324
- return await new Promise((n) => setTimeout(n, t)), o === this.speakRunId;
3325
- }
3326
- splitIntoChunks(t) {
3327
- if (t.length <= 260)
3328
- return [{ text: t, offset: 0 }];
3329
- const o = this.segmentSentences(t), n = [];
3330
- let r = "", i = 0;
3331
- for (const s of o) {
3332
- const l = s.text.trim();
3333
- if (!l)
3334
- continue;
3335
- const a = s.text.search(/\S/), c = s.offset + (a === -1 ? 0 : a);
3336
- if (!r) {
3337
- r = l, i = c;
3338
- continue;
3339
- }
3340
- const d = `${r} ${l}`;
3341
- d.length <= 260 ? r = d : (n.push({ text: r, offset: i }), r = l, i = c);
3342
- }
3343
- return r && n.push({ text: r, offset: i }), n.length ? n : [{ text: t, offset: 0 }];
3344
- }
3345
- getHighlightMode() {
3346
- return (this.config?.providerOptions || {}).highlightMode === "word" ? "word" : "sentence";
3347
- }
3348
- getSegmentationPolicy() {
3349
- const t = this.config?.providerOptions || {}, o = t.segmenter || {}, n = o.mode !== "regexOnly", r = typeof o.locale == "string" && o.locale.trim().length > 0 ? o.locale : typeof t.locale == "string" && t.locale.trim().length > 0 ? t.locale : void 0;
3350
- return {
3351
- useSentenceSegmenter: n,
3352
- useWordSegmenter: n,
3353
- locale: r
3354
- };
3355
- }
3356
- segmentSentences(t) {
3357
- const o = this.getSegmentationPolicy();
3358
- return sl(t, {
3359
- locale: o.locale,
3360
- useSentenceSegmenter: o.useSentenceSegmenter
3361
- });
3362
- }
3363
- inferWordLength(t, o) {
3364
- const n = Math.max(0, Math.min(o, Math.max(0, t.length - 1)));
3365
- return t.slice(n).match(/^\s*([^\s]+)/)?.[1]?.length || 1;
3366
- }
3367
- async speakChunk(t, o, n) {
3368
- return new Promise((r, i) => {
3369
- if (n !== this.speakRunId) {
3370
- r(!1);
3371
- return;
3372
- }
3373
- if (this.utterance = new SpeechSynthesisUtterance(t), this.config?.voice) {
3374
- const s = speechSynthesis.getVoices().find((l) => l.name === this.config.voice);
3375
- s && (this.utterance.voice = s);
3376
- }
3377
- this.config?.rate && (this.utterance.rate = this.config.rate), this.config?.pitch && (this.utterance.pitch = this.config.pitch), this.utterance.onstart = () => {
3378
- n === this.speakRunId && (this._isPlaying = !0, this._isPaused = !1);
3379
- }, this.utterance.onend = () => {
3380
- if (n !== this.speakRunId) {
3381
- r(!1);
3382
- return;
3383
- }
3384
- this._isPlaying = !1, this._isPaused = !1, r(!0);
3385
- }, this.utterance.onerror = (s) => {
3386
- if (n !== this.speakRunId) {
3387
- r(!1);
3388
- return;
3389
- }
3390
- if (this._isPlaying = !1, this._isPaused = !1, s.error === "interrupted" || s.error === "canceled") {
3391
- r(!1);
3392
- return;
3393
- }
3394
- i(new Error(`Speech synthesis error: ${s.error}`));
3395
- }, this.utterance.onpause = () => {
3396
- n === this.speakRunId && (this._isPaused = !0);
3397
- }, this.utterance.onresume = () => {
3398
- n === this.speakRunId && (this._isPaused = !1);
3399
- }, this.utterance.onboundary = (s) => {
3400
- if (n !== this.speakRunId || (console.log("[BrowserProvider] Boundary event:", s.name, "charIndex:", s.charIndex, "charLength:", s.charLength), s.name !== "word" || !this.onWordBoundary) || this.getHighlightMode() === "sentence")
3401
- return;
3402
- const l = Math.max(0, Math.min(s.charIndex, Math.max(0, t.length - 1))), a = Number(s.charLength || 0), c = this.inferWordLength(t, l), d = Number.isFinite(a) && a > 0 && a <= 80 && l + a <= t.length ? a : c, f = t.substring(l, Math.min(t.length, l + d)).trim(), b = o + l;
3403
- console.log("[BrowserProvider] Calling onWordBoundary with word:", f, "at position:", b), this.onWordBoundary(f, b, d);
3404
- }, speechSynthesis.speak(this.utterance);
3405
- });
3406
- }
3407
- pause() {
3408
- this._isPlaying && !this._isPaused && speechSynthesis.pause();
3409
- }
3410
- resume() {
3411
- this._isPlaying && this._isPaused && speechSynthesis.resume();
3412
- }
3413
- stop() {
3414
- this.speakRunId += 1, this._isPlaying && speechSynthesis.cancel(), this._isPlaying = !1, this._isPaused = !1;
3415
- }
3416
- isPlaying() {
3417
- return this._isPlaying && !this._isPaused;
3418
- }
3419
- isPaused() {
3420
- return this._isPaused;
3421
- }
3422
- /**
3423
- * Update settings dynamically (rate, pitch, voice)
3424
- * Changes take effect on the next speak() call
3425
- */
3426
- updateSettings(t) {
3427
- this.config || (this.config = {}), t.rate !== void 0 && (this.config.rate = t.rate), t.pitch !== void 0 && (this.config.pitch = t.pitch), t.voice !== void 0 && (this.config.voice = t.voice), t.providerOptions !== void 0 && (this.config.providerOptions = {
3428
- ...this.config.providerOptions || {},
3429
- ...t.providerOptions || {}
3430
- });
3431
- }
3432
- }
3433
- class cl {
3434
- /**
3435
- * Create TTS tool provider
3436
- *
3437
- * @param backend TTS backend to use (default: 'browser')
3438
- */
3439
- constructor(t = "browser") {
3440
- m(this, "providerId", "tts-service"), m(this, "providerName", "Text-to-Speech"), m(this, "category", "tts"), m(this, "version", "1.0"), m(this, "requiresAuth"), m(this, "ttsProvider", null), m(this, "config", null), this.requiresAuth = t !== "browser";
3441
- }
3442
- /**
3443
- * Initialize TTS provider
3444
- *
3445
- * Sets up the appropriate TTS backend.
3446
- *
3447
- * @param config Configuration with backend type and credentials
3448
- * @throws Error if initialization fails or required config missing
3449
- */
3450
- async initialize(t) {
3451
- if (this.ttsProvider) {
3452
- console.warn("[TTSToolProvider] Already initialized, skipping reinitialization");
3453
- return;
3454
- }
3455
- switch (this.config = t, t.backend) {
3456
- case "browser":
3457
- await this._initializeBrowserTTS(t);
3458
- break;
3459
- case "polly":
3460
- case "google":
3461
- case "server":
3462
- await this._initializeServerTTS(t);
3463
- break;
3464
- default:
3465
- throw new Error(`[TTSToolProvider] Unknown backend: ${t.backend}`);
3466
- }
3467
- console.log(`[TTSToolProvider] Initialized successfully (backend: ${t.backend})`);
3468
- }
3469
- /**
3470
- * Initialize browser TTS (Web Speech API)
3471
- */
3472
- async _initializeBrowserTTS(t) {
3473
- if (typeof window > "u" || !("speechSynthesis" in window))
3474
- throw new Error("[TTSToolProvider] Browser TTS not supported (Web Speech API not available)");
3475
- this.ttsProvider = new ll(), console.log("[TTSToolProvider] Browser TTS initialized (Web Speech API)");
3476
- }
3477
- /**
3478
- * Initialize server-based TTS (Polly, Google)
3479
- */
3480
- async _initializeServerTTS(t) {
3481
- if (!t.apiEndpoint)
3482
- throw new Error("[TTSToolProvider] apiEndpoint required for server-based TTS backends");
3483
- const o = await import("./index-CGqExkh0-DYpgzOOU.js");
3484
- this.ttsProvider = new o.ServerTTSProvider(), console.log(`[TTSToolProvider] Server TTS initialized (provider: ${t.serverProvider || t.backend})`);
3485
- }
3486
- /**
3487
- * Create a TTS provider instance
3488
- *
3489
- * Returns the initialized TTS provider.
3490
- *
3491
- * @param config Optional instance-specific configuration (currently unused)
3492
- * @returns TTS provider
3493
- * @throws Error if provider not initialized
3494
- */
3495
- async createInstance(t) {
3496
- if (!this.ttsProvider)
3497
- throw new Error("[TTSToolProvider] Provider not initialized. Call initialize() first.");
3498
- return this.ttsProvider;
3499
- }
3500
- /**
3501
- * Get provider capabilities
3502
- *
3503
- * @returns TTS capabilities based on backend
3504
- */
3505
- getCapabilities() {
3506
- const t = this.config?.backend === "browser";
3507
- return {
3508
- supportsOffline: t,
3509
- requiresAuth: !t,
3510
- maxInstances: 1,
3511
- // Single TTS instance (playback is sequential)
3512
- features: {
3513
- wordBoundary: !0,
3514
- // All backends support word highlighting
3515
- pause: !0,
3516
- resume: !0,
3517
- rateControl: !0,
3518
- pitchControl: t,
3519
- // Only browser supports pitch
3520
- voiceSelection: !0
3521
- }
3522
- };
3523
- }
3524
- /**
3525
- * Check if provider is ready
3526
- *
3527
- * @returns true if provider is initialized
3528
- */
3529
- isReady() {
3530
- return this.ttsProvider !== null;
3531
- }
3532
- /**
3533
- * Clean up provider resources
3534
- *
3535
- * Destroys the TTS provider and releases resources.
3536
- */
3537
- destroy() {
3538
- this.ttsProvider && (this.ttsProvider.destroy(), this.ttsProvider = null), this.config = null, console.log("[TTSToolProvider] Destroyed");
3539
- }
3540
- }
3541
- const ul = /* @__PURE__ */ new Set([
3542
- "annotation-xml",
3543
- "color-profile",
3544
- "font-face",
3545
- "font-face-src",
3546
- "font-face-uri",
3547
- "font-face-format",
3548
- "font-face-name",
3549
- "missing-glyph"
3550
- ]), dl = /^[a-z][a-z0-9._-]*-[a-z0-9._-]*$/, fl = (e, t = "custom element tag") => {
3551
- if (!e || typeof e != "string")
3552
- throw new Error(`Invalid ${t}: expected a non-empty string`);
3553
- const o = e.trim();
3554
- if (!o)
3555
- throw new Error(`Invalid ${t}: tag is empty`);
3556
- if (o !== o.toLowerCase())
3557
- throw new Error(`Invalid ${t} "${o}": custom element names must be lowercase`);
3558
- if (!o.includes("-"))
3559
- throw new Error(`Invalid ${t} "${o}": custom element names must include a hyphen`);
3560
- if (ul.has(o))
3561
- throw new Error(`Invalid ${t} "${o}": this name is reserved by the HTML spec`);
3562
- if (!dl.test(o))
3563
- throw new Error(`Invalid ${t} "${o}": allowed characters are lowercase letters, numbers, ".", "_" and "-"`);
3564
- return o;
3565
- }, Xr = {
3566
- calculator: "pie-tool-calculator",
3567
- textToSpeech: "pie-tool-text-to-speech",
3568
- ruler: "pie-tool-ruler",
3569
- protractor: "pie-tool-protractor",
3570
- answerEliminator: "pie-tool-answer-eliminator",
3571
- highlighter: "pie-tool-annotation-toolbar",
3572
- lineReader: "pie-tool-line-reader",
3573
- theme: "pie-tool-theme",
3574
- colorScheme: "pie-tool-theme",
3575
- annotationToolbar: "pie-tool-annotation-toolbar",
3576
- graph: "pie-tool-graph",
3577
- periodicTable: "pie-tool-periodic-table"
3578
- }, hl = (e, t) => {
3579
- const o = t?.toolTagMap?.[e] ?? Xr[e] ?? e;
3580
- return fl(o, `tool component tag for "${e}"`);
3581
- }, pl = (e) => document.createElement(e), ke = (e, t, o, n) => {
3582
- const r = hl(e, n), i = n?.toolComponentFactories?.[e] ?? n?.toolComponentFactory;
3583
- return i ? i({ toolId: e, tagName: r, context: t, toolbarContext: o }) : pl(r);
3584
- }, vl = {
3585
- toolId: "calculator",
3586
- name: "Calculator",
3587
- description: "Multi-type calculator (basic, scientific, graphing)",
3588
- icon: "calculator",
3589
- provider: {
3590
- getProviderId: (e) => typeof e?.provider?.id == "string" && e.provider.id.length > 0 ? e.provider.id : "calculator-desmos",
3591
- createProvider: () => new il(),
3592
- getInitConfig: (e) => e?.provider?.init ?? {},
3593
- getAuthFetcher: (e) => {
3594
- const t = e?.provider?.runtime?.authFetcher;
3595
- return typeof t == "function" ? t : async () => {
3596
- const o = await fetch("/api/tools/desmos/auth", {
3597
- method: "GET",
3598
- credentials: "same-origin"
3599
- });
3600
- if (!o.ok)
3601
- throw new Error(`Failed to fetch Desmos auth config (${o.status})`);
3602
- return await o.json();
3603
- };
3604
- },
3605
- lazy: !0
3606
- },
3607
- // Calculator is item-level in this player architecture.
3608
- supportedLevels: ["item"],
3609
- // PNP support IDs that enable this tool
3610
- // Maps to QTI 3.0 standard features: calculator, graphingCalculator
3611
- pnpSupportIds: [
3612
- "calculator",
3613
- // QTI 3.0 standard (cognitive.calculator)
3614
- "graphingCalculator",
3615
- // QTI 3.0 standard (assessment.graphingCalculator)
3616
- "basicCalculator",
3617
- // Common variant
3618
- "scientificCalculator"
3619
- // Common variant
3620
- ],
3621
- /**
3622
- * Pass 2: Determine if calculator is relevant in this context
3623
- *
3624
- * Calculator is relevant when context contains mathematical content
3625
- * (MathML, LaTeX, arithmetic markers).
3626
- */
3627
- isVisibleInContext(e) {
3628
- return Eo(e);
3629
- },
3630
- renderToolbar(e, t) {
3631
- const o = bn(this.toolId, t.scope.level, t.scope.scopeId), n = t.componentOverrides, r = ke(this.toolId, e, t, n);
3632
- r.setAttribute("tool-id", o), r.toolkitCoordinator = t.toolkitCoordinator;
3633
- const i = {
3634
- toolId: this.toolId,
3635
- label: this.name,
3636
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3637
- disabled: !1,
3638
- ariaLabel: "Open scientific calculator",
3639
- tooltip: "Calculator",
3640
- onClick: () => t.toggleTool(this.toolId),
3641
- active: t.isToolVisible(o)
3642
- };
3643
- let s = i.active;
3644
- return r.visible = i.active, {
3645
- toolId: this.toolId,
3646
- elements: [
3647
- {
3648
- element: r,
3649
- mount: "after-buttons",
3650
- shell: {
3651
- title: this.name,
3652
- draggable: !0,
3653
- resizable: !0,
3654
- closeable: !0,
3655
- initialWidth: 720,
3656
- initialHeight: 620,
3657
- minWidth: 360,
3658
- minHeight: 420
3659
- }
3660
- }
3661
- ],
3662
- button: i,
3663
- sync: () => {
3664
- const l = t.isToolVisible(o);
3665
- i.active = l, i.ariaLabel = l ? "Close scientific calculator" : "Open scientific calculator", i.tooltip = l ? "Close calculator" : "Calculator", s !== l && (r.visible = l, s = l), r.toolkitCoordinator !== t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3666
- },
3667
- subscribeActive: (l) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3668
- l(t.isToolVisible(o));
3669
- }) : () => {
3670
- }
3671
- };
3672
- }
3673
- }, Hn = (e) => e && typeof e == "object" ? e : {}, Vo = (e) => {
3674
- const t = Hn(e), o = Hn(e?.settings);
3675
- return { ...t, ...o };
3676
- }, en = (e) => e.backend || "browser", Qr = (e, t) => e.serverProvider || e.provider || (t === "polly" || t === "google" ? t : void 0), ei = (e, t) => e.transportMode || (t === "custom" ? "custom" : "pie"), gl = (e) => {
3677
- const t = en(e), o = Qr(e, t), n = ei(e, o);
3678
- return {
3679
- voice: e.defaultVoice,
3680
- rate: e.rate,
3681
- pitch: e.pitch,
3682
- providerOptions: {
3683
- ...e.language ? { locale: e.language } : {},
3684
- ...t === "polly" && e.engine ? { engine: e.engine } : {},
3685
- ...t === "polly" && typeof e.sampleRate == "number" ? { sampleRate: e.sampleRate } : {},
3686
- ...t === "polly" && e.format ? { format: e.format } : {},
3687
- ...t === "polly" ? {
3688
- speechMarkTypes: e.speechMarksMode === "word+sentence" ? ["word", "sentence"] : ["word"]
3689
- } : {},
3690
- ...n === "custom" && typeof e.cache == "boolean" ? { cache: e.cache } : {},
3691
- ...n === "custom" && e.speedRate ? { speedRate: e.speedRate } : {},
3692
- ...n === "custom" && e.lang_id ? { lang_id: e.lang_id } : {}
3693
- },
3694
- apiEndpoint: e.apiEndpoint,
3695
- provider: o,
3696
- language: e.language,
3697
- transportMode: n,
3698
- endpointMode: e.endpointMode,
3699
- endpointValidationMode: e.endpointValidationMode,
3700
- includeAuthOnAssetFetch: e.includeAuthOnAssetFetch,
3701
- validateEndpoint: e.validateEndpoint
3702
- };
3703
- }, Bt = /* @__PURE__ */ new Map(), ml = "__pieToolElementUnmount", Fn = Object.freeze([1.5, 2]), bl = (e) => {
3704
- if (!Array.isArray(e))
3705
- return [...Fn];
3706
- const t = /* @__PURE__ */ new Set();
3707
- for (const o of e) {
3708
- if (typeof o != "number" || !Number.isFinite(o) || o <= 0)
3709
- continue;
3710
- const n = Math.round(o * 100) / 100;
3711
- n !== 1 && t.add(n);
3712
- }
3713
- return t.size ? Array.from(t) : [...Fn];
3714
- }, yl = {
3715
- toolId: "textToSpeech",
3716
- name: "Text to Speech",
3717
- description: "Read content aloud",
3718
- icon: "volume-up",
3719
- provider: {
3720
- getProviderId: () => "tts",
3721
- createProvider: (e) => {
3722
- const t = Vo(e);
3723
- return new cl(en(t));
3724
- },
3725
- getInitConfig: (e) => {
3726
- const t = Vo(e), o = en(t), n = Qr(t, o), r = ei(t, n);
3727
- return {
3728
- backend: o,
3729
- serverProvider: n,
3730
- transportMode: r,
3731
- ...gl(t)
3732
- };
3733
- },
3734
- getAuthFetcher: (e) => {
3735
- const t = e?.provider?.runtime?.authFetcher;
3736
- return typeof t == "function" ? t : void 0;
3737
- },
3738
- lazy: !0
3739
- },
3740
- // TTS can appear at all levels except assessment and element.
3741
- supportedLevels: ["section", "item", "passage", "rubric"],
3742
- // PNP support IDs that enable this tool
3743
- // Maps to QTI 3.0 standard features: textToSpeech, readAloud
3744
- pnpSupportIds: [
3745
- "textToSpeech",
3746
- // QTI 3.0 standard (auditory.textToSpeech)
3747
- "readAloud",
3748
- // QTI 3.0 standard (auditory.readAloud)
3749
- "tts",
3750
- // Common abbreviation
3751
- "speechOutput"
3752
- // Common variant
3753
- ],
3754
- /**
3755
- * Pass 2: Determine if TTS is relevant in this context
3756
- *
3757
- * TTS is relevant when:
3758
- * - Context contains readable text (at least 10 characters)
3759
- */
3760
- isVisibleInContext(e) {
3761
- return Po(e);
3762
- },
3763
- renderToolbar(e, t) {
3764
- const o = () => {
3765
- const s = Vo(t.toolkitCoordinator?.getToolConfig(this.toolId) || void 0);
3766
- return bl(s.speedOptions);
3767
- }, n = bn(this.toolId, t.scope.level, t.scope.scopeId), r = () => {
3768
- const s = t.ui?.size;
3769
- return s === "sm" || s === "lg" ? s : "md";
3770
- }, i = () => {
3771
- let s = Bt.get(n);
3772
- return s && typeof s.isConnected == "boolean" && !s.isConnected && (Bt.delete(n), s = void 0), s || (s = document.createElement("pie-tool-tts-inline"), s[ml] = () => {
3773
- Bt.get(n) === s && Bt.delete(n);
3774
- }, Bt.set(n, s)), s.setAttribute("tool-id", n), s.setAttribute("catalog-id", t.catalogId || t.itemId), s.setAttribute("language", t.language || "en-US"), s.setAttribute("size", r()), s.speedOptions = o(), s;
3775
- };
3776
- return {
3777
- toolId: this.toolId,
3778
- button: null,
3779
- elements: [
3780
- {
3781
- element: i(),
3782
- mount: "before-buttons"
3783
- }
3784
- ],
3785
- sync: () => {
3786
- const s = i();
3787
- s.setAttribute("tool-id", n), s.setAttribute("catalog-id", t.catalogId || t.itemId), s.setAttribute("language", t.language || "en-US"), s.setAttribute("size", r()), s.speedOptions = o(), t.ensureTTSReady && t.ensureTTSReady().catch((l) => {
3788
- console.error("[ttsToolRegistration] Failed to initialize TTS service:", l);
3789
- });
3790
- }
3791
- };
3792
- }
3793
- };
3794
- function Re(e, t) {
3795
- const o = bn(e, t.scope.level, t.scope.scopeId);
3796
- return {
3797
- fullToolId: o,
3798
- isActive: () => t.isToolVisible(o),
3799
- subscribeActive: (n) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3800
- n(t.isToolVisible(o));
3801
- }) : () => {
3802
- }
3803
- };
3804
- }
3805
- function Ne(e) {
3806
- const t = e.isActive();
3807
- e.button.active = t, e.overlay.visible = t, e.onActiveChange?.(t);
3808
- }
3809
- const wl = {
3810
- toolId: "ruler",
3811
- name: "Ruler",
3812
- description: "On-screen ruler for measurements",
3813
- icon: "ruler",
3814
- // Ruler typically appears at item/element level
3815
- supportedLevels: ["item", "element"],
3816
- // PNP support IDs
3817
- // Maps to QTI 3.0 standard feature: ruler
3818
- pnpSupportIds: [
3819
- "ruler",
3820
- // QTI 3.0 standard (assessment.ruler)
3821
- "measurement"
3822
- // Common variant
3823
- ],
3824
- /**
3825
- * Pass 2: Ruler is relevant when math content is present
3826
- */
3827
- isVisibleInContext(e) {
3828
- return Eo(e);
3829
- },
3830
- renderToolbar(e, t) {
3831
- const o = Re(this.toolId, t), n = {
3832
- toolId: this.toolId,
3833
- label: this.name,
3834
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3835
- disabled: !1,
3836
- ariaLabel: "Open ruler tool",
3837
- tooltip: "Ruler",
3838
- onClick: () => t.toggleTool(this.toolId),
3839
- active: o.isActive()
3840
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
3841
- return i.setAttribute("tool-id", o.fullToolId), {
3842
- toolId: this.toolId,
3843
- button: n,
3844
- elements: [{ element: i, mount: "after-buttons" }],
3845
- sync: () => {
3846
- Ne({
3847
- button: n,
3848
- overlay: i,
3849
- isActive: o.isActive
3850
- }), t.toolkitCoordinator && (i.toolkitCoordinator = t.toolkitCoordinator);
3851
- },
3852
- subscribeActive: o.subscribeActive
3853
- };
3854
- }
3855
- }, Tl = {
3856
- toolId: "protractor",
3857
- name: "Protractor",
3858
- description: "On-screen protractor for angle measurements",
3859
- icon: "protractor",
3860
- // Protractor typically appears at item/element level
3861
- supportedLevels: ["item", "element"],
3862
- // PNP support IDs
3863
- // Maps to QTI 3.0 standard feature: protractor
3864
- pnpSupportIds: [
3865
- "protractor",
3866
- // QTI 3.0 standard (assessment.protractor)
3867
- "angleMeasurement"
3868
- // Common variant
3869
- ],
3870
- /**
3871
- * Pass 2: Protractor is relevant when math content is present
3872
- */
3873
- isVisibleInContext(e) {
3874
- return Eo(e);
3875
- },
3876
- renderToolbar(e, t) {
3877
- const o = Re(this.toolId, t), n = {
3878
- toolId: this.toolId,
3879
- label: this.name,
3880
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3881
- disabled: !1,
3882
- ariaLabel: "Open protractor tool",
3883
- tooltip: "Protractor",
3884
- onClick: () => t.toggleTool(this.toolId),
3885
- active: o.isActive()
3886
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
3887
- return i.setAttribute("tool-id", o.fullToolId), {
3888
- toolId: this.toolId,
3889
- button: n,
3890
- elements: [{ element: i, mount: "after-buttons" }],
3891
- sync: () => {
3892
- Ne({
3893
- button: n,
3894
- overlay: i,
3895
- isActive: o.isActive
3896
- }), t.toolkitCoordinator && (i.toolkitCoordinator = t.toolkitCoordinator);
3897
- },
3898
- subscribeActive: o.subscribeActive
3899
- };
3900
- }
3901
- }, Il = {
3902
- toolId: "answerEliminator",
3903
- name: "Answer Eliminator",
3904
- description: "Strike through answer choices",
3905
- icon: "strikethrough",
3906
- // Answer eliminator appears at item level only
3907
- supportedLevels: ["item"],
3908
- // PNP support IDs
3909
- // Maps to QTI 3.0 standard feature: answerMasking
3910
- pnpSupportIds: [
3911
- "answerMasking",
3912
- // QTI 3.0 standard (assessment.answerMasking)
3913
- "answerEliminator",
3914
- // QTI 3.0 standard (assessment.answerEliminator)
3915
- "strikethrough",
3916
- // Common variant
3917
- "choiceMasking"
3918
- // Common variant
3919
- ],
3920
- /**
3921
- * Pass 2: Answer eliminator is relevant only for choice-based questions
3922
- */
3923
- isVisibleInContext(e) {
3924
- return el(e);
3925
- },
3926
- renderToolbar(e, t) {
3927
- const o = Re(this.toolId, t), n = t.componentOverrides ?? {}, r = ke(this.toolId, e, t, n);
3928
- r.setAttribute("tool-id", o.fullToolId), r.setAttribute("strategy", "strikethrough"), r.setAttribute("button-alignment", "inline");
3929
- const i = {
3930
- toolId: this.toolId,
3931
- label: this.name,
3932
- icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="currentColor" aria-hidden="true"><path d="M19,3H16.3H7.7H5A2,2 0 0,0 3,5V7.7V16.4V19A2,2 0 0,0 5,21H7.7H16.4H19A2,2 0 0,0 21,19V16.3V7.7V5A2,2 0 0,0 19,3M15.6,17L12,13.4L8.4,17L7,15.6L10.6,12L7,8.4L8.4,7L12,10.6L15.6,7L17,8.4L13.4,12L17,15.6L15.6,17Z"/></svg>',
3933
- disabled: !1,
3934
- ariaLabel: "Answer eliminator - Strike through choices",
3935
- tooltip: "Strike Through",
3936
- onClick: () => t.toggleTool(this.toolId),
3937
- active: o.isActive()
3938
- };
3939
- return {
3940
- toolId: this.toolId,
3941
- button: i,
3942
- elements: [{ element: r, mount: "after-buttons" }],
3943
- sync: () => {
3944
- Ne({
3945
- button: i,
3946
- overlay: r,
3947
- isActive: o.isActive
3948
- }), t.toolCoordinator && (r.coordinator = t.toolCoordinator), r.scopeElement = t.getScopeElement?.() || null, t.elementToolStateStore && (r.elementToolStateStore = t.elementToolStateStore);
3949
- const s = t.getGlobalElementId?.();
3950
- s && (r.globalElementId = s);
3951
- },
3952
- subscribeActive: o.subscribeActive
3953
- };
3954
- }
3955
- }, $l = {
3956
- toolId: "highlighter",
3957
- name: "Highlighter",
3958
- description: "Highlight text",
3959
- icon: "highlighter",
3960
- activation: "toolbar-toggle",
3961
- // Highlighter appears at passage, rubric, item, and element levels
3962
- supportedLevels: ["passage", "rubric", "item", "element"],
3963
- // PNP support IDs
3964
- pnpSupportIds: ["highlighter", "textHighlight", "annotation"],
3965
- /**
3966
- * Pass 2: Highlighter is relevant when readable text is available
3967
- */
3968
- isVisibleInContext(e) {
3969
- return Po(e);
3970
- },
3971
- renderToolbar(e, t) {
3972
- const o = Re(this.toolId, t), n = {
3973
- toolId: this.toolId,
3974
- label: this.name,
3975
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3976
- disabled: !1,
3977
- ariaLabel: "Highlighter - Highlight text",
3978
- tooltip: "Highlight",
3979
- onClick: () => t.toggleTool(this.toolId),
3980
- active: o.isActive()
3981
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
3982
- return i.setAttribute("tool-id", o.fullToolId), {
3983
- toolId: this.toolId,
3984
- button: n,
3985
- elements: [{ element: i, mount: "after-buttons" }],
3986
- sync: () => {
3987
- Ne({
3988
- button: n,
3989
- overlay: i,
3990
- isActive: o.isActive,
3991
- onActiveChange: (s) => {
3992
- i.enabled = s;
3993
- }
3994
- }), t.ttsService && (i.ttsService = t.ttsService);
3995
- },
3996
- subscribeActive: o.subscribeActive
3997
- };
3998
- }
3999
- }, xl = {
4000
- toolId: "lineReader",
4001
- name: "Line Reader",
4002
- description: "Reading guide overlay",
4003
- icon: "bars-3",
4004
- // Line reader appears where there's text to read
4005
- supportedLevels: ["passage", "rubric", "item"],
4006
- // PNP support IDs
4007
- // Maps to QTI 3.0 standard features: readingMask, readingGuide, readingRuler
4008
- pnpSupportIds: [
4009
- "readingMask",
4010
- // QTI 3.0 standard (reading.readingMask)
4011
- "readingGuide",
4012
- // QTI 3.0 standard (reading.readingGuide)
4013
- "readingRuler",
4014
- // QTI 3.0 standard (reading.readingRuler)
4015
- "lineReader",
4016
- // Common variant
4017
- "trackingGuide"
4018
- // Common variant
4019
- ],
4020
- /**
4021
- * Pass 2: Line reader is relevant when readable text is present
4022
- */
4023
- isVisibleInContext(e) {
4024
- return Po(e);
4025
- },
4026
- renderToolbar(e, t) {
4027
- const o = Re(this.toolId, t), n = {
4028
- toolId: this.toolId,
4029
- label: this.name,
4030
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
4031
- disabled: !1,
4032
- ariaLabel: "Line reader - Reading guide",
4033
- tooltip: "Line Reader",
4034
- onClick: () => t.toggleTool(this.toolId),
4035
- active: o.isActive()
4036
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
4037
- return i.setAttribute("tool-id", o.fullToolId), {
4038
- toolId: this.toolId,
4039
- button: n,
4040
- elements: [{ element: i, mount: "after-buttons" }],
4041
- sync: () => {
4042
- Ne({
4043
- button: n,
4044
- overlay: i,
4045
- isActive: o.isActive
4046
- }), t.toolkitCoordinator && (i.toolkitCoordinator = t.toolkitCoordinator);
4047
- },
4048
- subscribeActive: o.subscribeActive
4049
- };
4050
- }
4051
- }, Sl = {
4052
- toolId: "theme",
4053
- name: "Theme",
4054
- description: "Accessible themes and contrast",
4055
- icon: "swatch",
4056
- // Color scheme is assessment-wide
4057
- supportedLevels: ["assessment", "section"],
4058
- // PNP support IDs
4059
- // Maps to QTI 3.0 standard features: highContrastDisplay, colorContrast, invertColors
4060
- pnpSupportIds: [
4061
- "highContrastDisplay",
4062
- // QTI 3.0 standard (visual.highContrastDisplay)
4063
- "colorContrast",
4064
- // QTI 3.0 standard (visual.colorContrast)
4065
- "invertColors",
4066
- // QTI 3.0 standard (visual.invertColors)
4067
- "colorScheme",
4068
- // Legacy alias
4069
- "theme",
4070
- // Canonical id
4071
- "highContrast",
4072
- // Common variant
4073
- "customColors"
4074
- // Common variant
4075
- ],
4076
- /**
4077
- * Pass 2: Color scheme is always relevant when allowed
4078
- */
4079
- isVisibleInContext(e) {
4080
- return !0;
4081
- },
4082
- renderToolbar(e, t) {
4083
- const o = Re(this.toolId, t), n = {
4084
- toolId: this.toolId,
4085
- label: this.name,
4086
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
4087
- disabled: !1,
4088
- ariaLabel: "Theme - Change colors and contrast",
4089
- tooltip: "Theme",
4090
- onClick: () => t.toggleTool(this.toolId),
4091
- active: o.isActive()
4092
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
4093
- return i.setAttribute("tool-id", o.fullToolId), {
4094
- toolId: this.toolId,
4095
- button: n,
4096
- elements: [
4097
- {
4098
- element: i,
4099
- mount: "after-buttons",
4100
- shell: {
4101
- title: this.name,
4102
- draggable: !0,
4103
- resizable: !1,
4104
- closeable: !0,
4105
- initialWidth: 520,
4106
- initialHeight: 380,
4107
- minWidth: 420,
4108
- minHeight: 300
4109
- }
4110
- }
4111
- ],
4112
- sync: () => {
4113
- Ne({
4114
- button: n,
4115
- overlay: i,
4116
- isActive: o.isActive
4117
- }), t.toolkitCoordinator && (i.toolkitCoordinator = t.toolkitCoordinator);
4118
- },
4119
- subscribeActive: o.subscribeActive
4120
- };
4121
- }
4122
- }, kl = Sl, Al = {
4123
- toolId: "annotationToolbar",
4124
- name: "Highlighter",
4125
- description: "Highlight and annotate text",
4126
- icon: "highlighter",
4127
- activation: "selection-gateway",
4128
- singletonScope: "section",
4129
- // Annotation appears where there's text content
4130
- supportedLevels: ["passage", "rubric", "item", "element"],
4131
- // PNP support IDs
4132
- // Maps to QTI 3.0 standard features: highlighting, annotations
4133
- pnpSupportIds: [
4134
- "highlighting",
4135
- // QTI 3.0 standard (cognitive.highlighting / reading.wordHighlighting)
4136
- "annotations",
4137
- // QTI 3.0 standard (cognitive.annotations)
4138
- "highlighter",
4139
- // Common variant
4140
- "textHighlight",
4141
- // Common variant
4142
- "annotation"
4143
- // Common variant
4144
- ],
4145
- /**
4146
- * Pass 2: Annotation is relevant when readable text is present
4147
- */
4148
- isVisibleInContext(e) {
4149
- return Po(e);
4150
- },
4151
- renderToolbar(e, t) {
4152
- const o = Re(this.toolId, t), n = {
4153
- toolId: this.toolId,
4154
- label: this.name,
4155
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
4156
- disabled: !1,
4157
- ariaLabel: "Annotation toolbar - Highlight text",
4158
- tooltip: "Highlight",
4159
- onClick: () => t.toggleTool(this.toolId),
4160
- active: o.isActive()
4161
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
4162
- return i.setAttribute("tool-id", o.fullToolId), {
4163
- toolId: this.toolId,
4164
- button: n,
4165
- elements: [{ element: i, mount: "after-buttons" }],
4166
- sync: () => {
4167
- Ne({
4168
- button: n,
4169
- overlay: i,
4170
- isActive: o.isActive
4171
- }), t.toolkitCoordinator && (i.toolkitCoordinator = t.toolkitCoordinator);
4172
- },
4173
- subscribeActive: o.subscribeActive
4174
- };
4175
- }
4176
- }, _l = {
4177
- toolId: "graph",
4178
- name: "Graph",
4179
- description: "Graphing calculator and coordinate plane",
4180
- icon: "chart-bar",
4181
- // Graph is a section-level floating tool.
4182
- supportedLevels: ["section"],
4183
- // PNP support IDs
4184
- // Maps to QTI 3.0 standard features: graph, graphingCalculator
4185
- pnpSupportIds: [
4186
- "graph",
4187
- // QTI 3.0 standard (assessment.graph)
4188
- "graphingCalculator",
4189
- // QTI 3.0 standard (assessment.graphingCalculator)
4190
- "coordinatePlane",
4191
- // Common variant
4192
- "graphingTool"
4193
- // Common variant
4194
- ],
4195
- /**
4196
- * Pass 2: Graph is relevant when math content is present
4197
- */
4198
- isVisibleInContext(e) {
4199
- return Eo(e);
4200
- },
4201
- renderToolbar(e, t) {
4202
- const o = Re(this.toolId, t), n = {
4203
- toolId: this.toolId,
4204
- label: this.name,
4205
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
4206
- disabled: !1,
4207
- ariaLabel: "Graph - Graphing calculator",
4208
- tooltip: "Graph",
4209
- onClick: () => t.toggleTool(this.toolId),
4210
- active: o.isActive()
4211
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
4212
- return i.setAttribute("tool-id", o.fullToolId), {
4213
- toolId: this.toolId,
4214
- button: n,
4215
- elements: [
4216
- {
4217
- element: i,
4218
- mount: "after-buttons",
4219
- shell: {
4220
- title: this.name,
4221
- draggable: !0,
4222
- resizable: !0,
4223
- closeable: !0,
4224
- initialWidth: 920,
4225
- initialHeight: 680,
4226
- minWidth: 640,
4227
- minHeight: 500
4228
- }
4229
- }
4230
- ],
4231
- sync: () => {
4232
- Ne({
4233
- button: n,
4234
- overlay: i,
4235
- isActive: o.isActive
4236
- });
4237
- },
4238
- subscribeActive: o.subscribeActive
4239
- };
4240
- }
4241
- }, Cl = {
4242
- toolId: "periodicTable",
4243
- name: "Periodic Table",
4244
- description: "Chemistry periodic table reference",
4245
- icon: "beaker",
4246
- // Periodic table is a section-level floating tool.
4247
- supportedLevels: ["section"],
4248
- // PNP support IDs
4249
- // Maps to QTI 3.0 standard feature: periodicTable
4250
- pnpSupportIds: [
4251
- "periodicTable",
4252
- // QTI 3.0 standard (assessment.periodicTable)
4253
- "chemistryReference",
4254
- // Common variant
4255
- "elementReference"
4256
- // Common variant
4257
- ],
4258
- /**
4259
- * Pass 2: Periodic table is relevant when science content is present
4260
- */
4261
- isVisibleInContext(e) {
4262
- return tl(e);
4263
- },
4264
- renderToolbar(e, t) {
4265
- const o = Re(this.toolId, t), n = {
4266
- toolId: this.toolId,
4267
- label: this.name,
4268
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
4269
- disabled: !1,
4270
- ariaLabel: "Periodic table - Chemistry reference",
4271
- tooltip: "Periodic Table",
4272
- onClick: () => t.toggleTool(this.toolId),
4273
- active: o.isActive()
4274
- }, r = t.componentOverrides ?? {}, i = ke(this.toolId, e, t, r);
4275
- return i.setAttribute("tool-id", o.fullToolId), {
4276
- toolId: this.toolId,
4277
- button: n,
4278
- elements: [
4279
- {
4280
- element: i,
4281
- mount: "after-buttons",
4282
- shell: {
4283
- title: this.name,
4284
- draggable: !0,
4285
- resizable: !0,
4286
- closeable: !0,
4287
- initialWidth: 1160,
4288
- initialHeight: 760,
4289
- minWidth: 920,
4290
- minHeight: 620
4291
- }
4292
- }
4293
- ],
4294
- sync: () => {
4295
- Ne({
4296
- button: n,
4297
- overlay: i,
4298
- isActive: o.isActive
4299
- });
4300
- },
4301
- subscribeActive: o.subscribeActive
4302
- };
4303
- }
4304
- }, El = [
4305
- vl,
4306
- yl,
4307
- wl,
4308
- Tl,
4309
- Il,
4310
- $l,
4311
- xl,
4312
- kl,
4313
- Al,
4314
- _l,
4315
- Cl
4316
- ];
4317
- function Pl(e = {}) {
4318
- const t = new Zs(), o = {
4319
- toolTagMap: {
4320
- ...Xr,
4321
- ...e.toolTagMap || {}
4322
- },
4323
- toolComponentFactory: e.toolComponentFactory,
4324
- toolComponentFactories: e.toolComponentFactories
4325
- }, n = (r) => e.overrides?.[r.toolId] || r;
4326
- return e.includePackagedTools && Ll(t, {
4327
- toolIds: e.toolIds,
4328
- applyOverrides: n
4329
- }), e.toolModuleLoaders && Object.keys(e.toolModuleLoaders).length > 0 && t.setToolModuleLoaders(e.toolModuleLoaders), t.setComponentOverrides(o), t;
4330
- }
4331
- function Ll(e, t = {}) {
4332
- const o = t.toolIds && t.toolIds.length > 0 ? new Set(t.toolIds) : null, n = t.applyOverrides || ((r) => r);
4333
- for (const r of El)
4334
- o && !o.has(r.toolId) || e.register(n(r));
4335
- }
4336
- function Ml(e = {}) {
4337
- return Pl({
4338
- ...e,
4339
- includePackagedTools: !0
4340
- });
4341
- }
4342
- function Ol() {
4343
- const e = Ml(), t = /* @__PURE__ */ new Set();
4344
- for (const o of e.getAllTools())
4345
- for (const n of o.pnpSupportIds || [])
4346
- t.add(n);
4347
- return [...t].sort();
4348
- }
4349
- Ol();
4350
- const Rl = {
4351
- /**
4352
- * Visual accessibility features
4353
- * For students with low vision, color blindness, or visual processing needs
4354
- */
4355
- visual: {
4356
- // Magnification and zoom
4357
- magnification: "magnification",
4358
- screenMagnifier: "screenMagnifier",
4359
- zoomable: "zoomable",
4360
- // Color and contrast
4361
- highContrastDisplay: "highContrastDisplay",
4362
- highContrastAudio: "highContrastAudio",
4363
- colorContrast: "colorContrast",
4364
- invertColors: "invertColors",
4365
- // Display customization
4366
- displayTransformability: "displayTransformability",
4367
- largePrint: "largePrint",
4368
- fontEnlargement: "fontEnlargement",
4369
- resizeText: "resizeText",
4370
- // Visual alternatives
4371
- alternativeText: "alternativeText",
4372
- longDescription: "longDescription",
4373
- describedMath: "describedMath",
4374
- tactileGraphic: "tactileGraphic",
4375
- tactileObject: "tactileObject"
4376
- },
4377
- /**
4378
- * Auditory accessibility features
4379
- * For students who are deaf, hard of hearing, or benefit from audio
4380
- */
4381
- auditory: {
4382
- // Audio output
4383
- audioDescription: "audioDescription",
4384
- textToSpeech: "textToSpeech",
4385
- readAloud: "readAloud",
4386
- humanVoice: "humanVoice",
4387
- syntheticVoice: "syntheticVoice",
4388
- // Speech control
4389
- speechRate: "speechRate",
4390
- speechVolume: "speechVolume",
4391
- voicePitch: "voicePitch",
4392
- // Visual alternatives for audio
4393
- captions: "captions",
4394
- closedCaptions: "closedCaptions",
4395
- openCaptions: "openCaptions",
4396
- transcript: "transcript",
4397
- signLanguage: "signLanguage",
4398
- subtitles: "subtitles",
4399
- // Audio adjustments
4400
- audioControl: "audioControl",
4401
- noBackgroundAudio: "noBackgroundAudio"
4402
- },
4403
- /**
4404
- * Motor/physical accessibility features
4405
- * For students with limited mobility or motor control
4406
- */
4407
- motor: {
4408
- // Input alternatives
4409
- keyboardControl: "keyboardControl",
4410
- mouseControl: "mouseControl",
4411
- touchControl: "touchControl",
4412
- voiceControl: "voiceControl",
4413
- switchControl: "switchControl",
4414
- eyeGazeControl: "eyeGazeControl",
4415
- // Keyboard features
4416
- singleSwitchAccess: "singleSwitchAccess",
4417
- stickyKeys: "stickyKeys",
4418
- keyboardShortcuts: "keyboardShortcuts",
4419
- // Timing
4420
- timingControl: "timingControl",
4421
- unlimitedTime: "unlimitedTime",
4422
- extendedTime: "extendedTime",
4423
- pauseControl: "pauseControl"
4424
- },
4425
- /**
4426
- * Cognitive/learning accessibility features
4427
- * For students with learning disabilities, ADHD, autism, etc.
4428
- */
4429
- cognitive: {
4430
- // Content simplification
4431
- simplifiedLanguage: "simplifiedLanguage",
4432
- reducedComplexity: "reducedComplexity",
4433
- structuralNavigation: "structuralNavigation",
4434
- tableOfContents: "tableOfContents",
4435
- // Focus and attention
4436
- reducedDistraction: "reducedDistraction",
4437
- noFlashing: "noFlashing",
4438
- pauseAnimation: "pauseAnimation",
4439
- // Organization and support
4440
- annotations: "annotations",
4441
- bookmarking: "bookmarking",
4442
- highlighting: "highlighting",
4443
- guidedNavigation: "guidedNavigation",
4444
- // Tools
4445
- calculator: "calculator",
4446
- thesaurus: "thesaurus",
4447
- spellingAssistance: "spellingAssistance",
4448
- grammarAssistance: "grammarAssistance"
4449
- },
4450
- /**
4451
- * Reading support features
4452
- * For students with dyslexia or reading challenges
4453
- */
4454
- reading: {
4455
- // Text presentation
4456
- lineSpacing: "lineSpacing",
4457
- wordSpacing: "wordSpacing",
4458
- letterSpacing: "letterSpacing",
4459
- fontFamily: "fontFamily",
4460
- readingMask: "readingMask",
4461
- readingGuide: "readingGuide",
4462
- readingRuler: "readingRuler",
4463
- // Highlighting and emphasis
4464
- wordHighlighting: "wordHighlighting",
4465
- lineHighlighting: "lineHighlighting",
4466
- focusIndicator: "focusIndicator",
4467
- // Content support
4468
- printableResource: "printableResource",
4469
- braille: "braille",
4470
- nemeth: "nemeth",
4471
- refreshableBraille: "refreshableBraille"
4472
- },
4473
- /**
4474
- * Navigation features
4475
- * For efficient content navigation
4476
- */
4477
- navigation: {
4478
- // Structure
4479
- index: "index",
4480
- pageNavigation: "pageNavigation",
4481
- skipContent: "skipContent",
4482
- breadcrumbs: "breadcrumbs",
4483
- // Search
4484
- searchable: "searchable",
4485
- fullTextSearch: "fullTextSearch"
4486
- },
4487
- /**
4488
- * Linguistic features
4489
- * For language support
4490
- */
4491
- linguistic: {
4492
- // Languages
4493
- multilingualText: "multilingualText",
4494
- translatedText: "translatedText",
4495
- glossary: "glossary",
4496
- // Sign language
4497
- signLanguageInterpretation: "signLanguageInterpretation",
4498
- visualLanguage: "visualLanguage"
4499
- },
4500
- /**
4501
- * Assessment-specific features
4502
- * Features specific to test-taking environments
4503
- */
4504
- assessment: {
4505
- // Tools
4506
- protractor: "protractor",
4507
- ruler: "ruler",
4508
- graph: "graph",
4509
- graphingCalculator: "graphingCalculator",
4510
- periodicTable: "periodicTable",
4511
- formulaSheet: "formulaSheet",
4512
- // Answer support
4513
- answerMasking: "answerMasking",
4514
- answerEliminator: "answerEliminator",
4515
- strikethrough: "strikethrough",
4516
- // Item features
4517
- itemGlossary: "itemGlossary",
4518
- tutorialAvailable: "tutorialAvailable"
4519
- }
4520
- };
4521
- Object.values(Rl).flatMap((e) => Object.values(e));
4522
- var Gn;
4523
- (function(e) {
4524
- e[e.BASE = 0] = "BASE", e[e.TOOL = 1e3] = "TOOL", e[e.MODAL = 2e3] = "MODAL", e[e.CONTROL = 3e3] = "CONTROL", e[e.HIGHLIGHT = 4e3] = "HIGHLIGHT";
4525
- })(Gn || (Gn = {}));
4526
- var Un;
4527
- (function(e) {
4528
- e.IDLE = "idle", e.LOADING = "loading", e.PLAYING = "playing", e.PAUSED = "paused", e.ERROR = "error";
4529
- })(Un || (Un = {}));
4530
- var Nl = /* @__PURE__ */ mt('<button class="pie-tool-annotation-toolbar__highlight-swatch svelte-g8qu62"><span class="pie-sr-only svelte-g8qu62"> </span></button>'), Vl = /* @__PURE__ */ mt('<div class="divider divider-horizontal mx-0 w-px svelte-g8qu62"></div> <button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--icon svelte-g8qu62" aria-label="Read selected text aloud" title="Read Aloud"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" class="svelte-g8qu62"><path d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z"></path></svg></button>', 1), jl = /* @__PURE__ */ mt('<button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--warning svelte-g8qu62" aria-label="Remove this annotation" title="Remove"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" class="svelte-g8qu62"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg></button>'), zl = /* @__PURE__ */ mt('<button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--danger svelte-g8qu62" aria-label="Clear all annotations from document" title="Clear All">Clear All</button>'), Wl = /* @__PURE__ */ mt('<div class="divider divider-horizontal mx-0 w-px svelte-g8qu62"></div> <!> <!>', 1), Bl = /* @__PURE__ */ mt('<div class="pie-tool-annotation-toolbar notranslate svelte-g8qu62" role="toolbar" aria-label="Text annotation toolbar" translate="no"><!> <button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--icon svelte-g8qu62" aria-label="Underline selected text" title="Underline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" class="svelte-g8qu62"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z"></path></svg></button> <!> <!></div>'), ql = /* @__PURE__ */ mt('<div style="display: none;" aria-hidden="true"></div> <!> <div role="status" aria-live="polite" aria-atomic="true" class="pie-sr-only svelte-g8qu62"> </div>', 1);
4531
- const Dl = {
4532
- hash: "svelte-g8qu62",
4533
- code: `.pie-tool-annotation-toolbar.svelte-g8qu62 {position:fixed;z-index:4200;display:flex;gap:0.25rem;padding:0.5rem;border-radius:0.5rem;background:var(--pie-background, #fff);color:var(--pie-text, #111827);border:1px solid var(--pie-border, #d1d5db);box-shadow:0 10px 25px -8px rgb(0 0 0 / 0.3);user-select:none;}.pie-tool-annotation-toolbar__highlight-swatch.svelte-g8qu62 {width:2.5rem;height:2rem;border:2px solid color-mix(in srgb, var(--pie-border-dark, #111827) 20%, transparent);border-radius:0.375rem;cursor:pointer;transition:all 0.15s ease;display:flex;align-items:center;justify-content:center;padding:0;}.pie-tool-annotation-toolbar__highlight-swatch.svelte-g8qu62:hover {transform:scale(1.1);border-color:color-mix(in srgb, var(--pie-border-dark, #111827) 45%, transparent);box-shadow:0 2px 8px rgb(0 0 0 / 0.15);}.pie-tool-annotation-toolbar__highlight-swatch.svelte-g8qu62:focus-visible {outline:2px solid var(--pie-button-focus-outline, var(--pie-primary, #3f51b5));outline-offset:2px;}.pie-tool-annotation-toolbar.svelte-g8qu62 .divider-horizontal:where(.svelte-g8qu62) {height:auto;width:1px;background-color:color-mix(in srgb, var(--pie-border, #d1d5db) 70%, transparent);}
4534
-
4535
- /* Screen reader only content */.pie-sr-only.svelte-g8qu62 {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;}
4536
-
4537
- /* Button styling */.pie-tool-annotation-toolbar__button.svelte-g8qu62 {display:inline-flex;align-items:center;justify-content:center;gap:0.35rem;padding:0.4rem 0.55rem;border:1px solid var(--pie-button-border, #d1d5db);border-radius:0.4rem;background:var(--pie-button-bg, #fff);color:var(--pie-button-color, var(--pie-text, #111827));cursor:pointer;}.pie-tool-annotation-toolbar__button--icon.svelte-g8qu62 {min-width:2rem;min-height:2rem;padding:0.45rem;}.pie-tool-annotation-toolbar__button.svelte-g8qu62:hover {background:var(--pie-button-hover-bg, #f9fafb);color:var(--pie-button-hover-color, var(--pie-text, #111827));border-color:var(--pie-button-hover-border, #9ca3af);}.pie-tool-annotation-toolbar__button.svelte-g8qu62:focus-visible {outline:2px solid var(--pie-button-focus-outline, var(--pie-primary, #3f51b5));outline-offset:2px;}.pie-tool-annotation-toolbar__button.svelte-g8qu62:disabled {opacity:0.6;cursor:not-allowed;}.pie-tool-annotation-toolbar__button--warning.svelte-g8qu62 {color:var(--pie-missing-icon, #92400e);}.pie-tool-annotation-toolbar__button--danger.svelte-g8qu62 {color:var(--pie-incorrect-icon, #b91c1c);}.pie-tool-annotation-toolbar__button.svelte-g8qu62 svg:where(.svelte-g8qu62) {width:18px;height:18px;}`
4538
- };
4539
- function Hl(e, t) {
4540
- nr(t, !0), Ps(e, Dl);
4541
- let o = No(t, "enabled", 7, !0), n = No(t, "highlightCoordinator", 7, null), r = No(t, "ttsService", 7, null);
4542
- const i = typeof window < "u", s = "pie-annotations", l = [
4543
- {
4544
- name: Ue.YELLOW,
4545
- hex: "#fde995",
4546
- label: "Yellow highlight"
4547
- },
4548
- {
4549
- name: Ue.PINK,
4550
- hex: "#ff9fae",
4551
- label: "Pink highlight"
4552
- },
4553
- {
4554
- name: Ue.BLUE,
4555
- hex: "#a7e0f6",
4556
- label: "Blue highlight"
4557
- },
4558
- {
4559
- name: Ue.GREEN,
4560
- hex: "#a6e1c5",
4561
- label: "Green highlight"
4562
- }
4563
- ], a = [
4564
- "button",
4565
- "input",
4566
- "select",
4567
- "textarea",
4568
- '[contenteditable="true"]',
4569
- ".pie-tool-annotation-toolbar",
4570
- ".pie-tool-toolbar",
4571
- '[role="button"]',
4572
- '[role="textbox"]'
4573
- ];
4574
- let c = /* @__PURE__ */ R(null), d = /* @__PURE__ */ R(null), f = /* @__PURE__ */ R(null), b = /* @__PURE__ */ R(null), g = /* @__PURE__ */ R(It({
4575
- isVisible: !1,
4576
- selectedText: "",
4577
- selectedRange: null,
4578
- toolbarPosition: { x: 0, y: 0 }
4579
- })), h = /* @__PURE__ */ R(!1), w = /* @__PURE__ */ R(
4580
- !1
4581
- // Flag to prevent immediate hiding after showing
4582
- ), T = /* @__PURE__ */ R(
4583
- ""
4584
- // For screen readers when toolbar is repositioned
4585
- ), $ = /* @__PURE__ */ R(0), E = /* @__PURE__ */ R(null), se = /* @__PURE__ */ Oo(() => p($) > 0), le = /* @__PURE__ */ Oo(() => p(E) !== null), W = /* @__PURE__ */ Oo(() => p(b)?.scopeElement || p(f)?.scopeElement || null);
4586
- function Ve() {
4587
- const v = p(c)?.ownerDocument;
4588
- return p(W) || v?.documentElement || document.documentElement;
4589
- }
4590
- function Z() {
4591
- const v = p(f)?.canonicalItemId || p(f)?.itemId || "global";
4592
- return `${s}:${v}`;
4593
- }
4594
- function X(v) {
4595
- if (!n()) return null;
4596
- const y = n().getAnnotations();
4597
- for (const _ of y) {
4598
- const B = v.compareBoundaryPoints(Range.START_TO_START, _.range), et = v.compareBoundaryPoints(Range.END_TO_END, _.range), Rt = v.compareBoundaryPoints(Range.START_TO_END, _.range), Nt = v.compareBoundaryPoints(Range.END_TO_START, _.range);
4599
- if (B >= 0 && et <= 0 || // selection inside annotation
4600
- B <= 0 && et >= 0 || // annotation inside selection
4601
- Rt > 0 && Nt < 0)
4602
- return _.id;
4603
- }
4604
- return null;
4605
- }
4606
- function bt(v) {
4607
- if (v.nodeType !== Node.ELEMENT_NODE && v.nodeType !== Node.TEXT_NODE)
4608
- return !1;
4609
- const y = v.nodeType === Node.TEXT_NODE ? v.parentElement : v;
4610
- return y ? !a.some((_) => {
4611
- try {
4612
- return y.closest(_) !== null;
4613
- } catch {
4614
- return !1;
4615
- }
4616
- }) : !1;
4617
- }
4618
- function ae(v) {
4619
- if (!p(W)) return !0;
4620
- const y = v.commonAncestorContainer, _ = y.nodeType === Node.TEXT_NODE ? y.parentElement : y;
4621
- return !!_ && p(W).contains(_);
4622
- }
4623
- function eo() {
4624
- if (!(!i || !n()))
4625
- try {
4626
- const v = Ve(), y = n().exportAnnotations(v);
4627
- sessionStorage.setItem(Z(), JSON.stringify(y));
4628
- } catch (v) {
4629
- console.error("[AnnotationToolbar] Failed to save annotations:", v);
4630
- }
4631
- }
4632
- function Lo() {
4633
- if (!(!i || !n()))
4634
- try {
4635
- const v = sessionStorage.getItem(Z());
4636
- if (!v) return;
4637
- const y = JSON.parse(v), _ = Ve(), B = n().importAnnotations(y, _);
4638
- console.log(`[AnnotationToolbar] Restored ${B} annotations`), A($, n().getAnnotations().length, !0);
4639
- } catch (v) {
4640
- console.error("[AnnotationToolbar] Failed to load annotations:", v);
4641
- }
4642
- }
4643
- function to() {
4644
- if (!o() || !i) return;
4645
- const v = window.getSelection();
4646
- if (!v || v.rangeCount === 0) return Ae();
4647
- const y = v.getRangeAt(0), _ = v.toString().trim();
4648
- if (!_ || !ae(y) || !bt(y.commonAncestorContainer))
4649
- return Ae();
4650
- const B = y.getBoundingClientRect(), et = B.left + B.width / 2, Rt = B.top - 8;
4651
- A(E, X(y), !0), p(g).isVisible = !0, p(g).selectedText = _, p(g).selectedRange = y.cloneRange(), p(g).toolbarPosition = { x: et, y: Rt };
4652
- const Nt = _.length > 30 ? _.substring(0, 30) + "..." : _;
4653
- A(T, `Annotation toolbar opened for "${Nt}"`), setTimeout(
4654
- () => {
4655
- A(T, "");
4656
- },
4657
- 2e3
4658
- ), A(w, !0), setTimeout(
4659
- () => {
4660
- A(w, !1);
4661
- },
4662
- 100
4663
- );
4664
- }
4665
- function Ae() {
4666
- p(h) && r() && (r().stop(), A(h, !1)), p(g).isVisible = !1, p(g).selectedText = "", p(g).selectedRange = null;
4667
- }
4668
- function yn(v) {
4669
- if (!p(g).selectedRange || !n()) return;
4670
- const y = p(g).selectedText;
4671
- n().addAnnotation(p(g).selectedRange, v), A($, n().getAnnotations().length, !0), eo();
4672
- const _ = v === Ue.UNDERLINE ? "underlined" : `highlighted in ${v}`, B = y.length > 30 ? y.substring(0, 30) + "..." : y;
4673
- A(T, `"${B}" ${_}`), setTimeout(
4674
- () => {
4675
- A(T, "");
4676
- },
4677
- 3e3
4678
- ), Ae();
4679
- }
4680
- function ti() {
4681
- if (!p(E) || !n()) {
4682
- console.warn("[AnnotationToolbar] No overlapping annotation to remove");
4683
- return;
4684
- }
4685
- console.log("[AnnotationToolbar] Removing annotation:", p(E));
4686
- const v = n().getAnnotation(p(E));
4687
- if (!v) {
4688
- console.warn("[AnnotationToolbar] Annotation not found:", p(E));
4689
- return;
4690
- }
4691
- const y = v.range.toString();
4692
- n().removeAnnotation(p(E));
4693
- const _ = n().getAnnotations().length;
4694
- A($, _, !0), console.log("[AnnotationToolbar] Annotations remaining:", _), eo();
4695
- const B = y.length > 30 ? y.substring(0, 30) + "..." : y;
4696
- A(T, `Removed annotation from "${B}"`), setTimeout(
4697
- () => {
4698
- A(T, "");
4699
- },
4700
- 3e3
4701
- ), Ae();
4702
- }
4703
- function oi() {
4704
- const v = p($);
4705
- n()?.clearAnnotations(), A($, 0), sessionStorage.removeItem(Z()), A(T, `${v} annotation${v === 1 ? "" : "s"} cleared`), setTimeout(
4706
- () => {
4707
- A(T, "");
4708
- },
4709
- 3e3
4710
- ), Ae();
4711
- }
4712
- async function ni() {
4713
- if (!(!p(g).selectedRange || !r())) {
4714
- A(h, !0);
4715
- try {
4716
- console.log("[AnnotationToolbar] Speaking range:", p(g).selectedRange.toString().substring(0, 50)), await r().speakRange(p(g).selectedRange, { contentRoot: Ve() }), console.log("[AnnotationToolbar] TTS completed successfully");
4717
- } catch (v) {
4718
- console.error("[AnnotationToolbar] TTS error:", v), alert(`TTS failed: ${v instanceof Error ? v.message : String(v)}`);
4719
- } finally {
4720
- A(h, !1);
4721
- }
4722
- }
4723
- }
4724
- function wn(v) {
4725
- v.key === "Escape" && p(g).isVisible && (v.preventDefault(), Ae());
4726
- }
4727
- function oo(v) {
4728
- !p(g).isVisible || p(w) || p(d) && !p(d).contains(v.target) && Ae();
4729
- }
4730
- Pn(() => {
4731
- if (!i) return;
4732
- const v = setTimeout(
4733
- () => {
4734
- Lo();
4735
- },
4736
- 2e3
4737
- ), y = p(W) || document;
4738
- return y.addEventListener("mouseup", to), y.addEventListener("click", oo), y.addEventListener("touchend", to), y.addEventListener("touchstart", oo), document.addEventListener("keydown", wn), window.addEventListener("scroll", Ae, !0), () => {
4739
- clearTimeout(v), y.removeEventListener("mouseup", to), y.removeEventListener("click", oo), y.removeEventListener("touchend", to), y.removeEventListener("touchstart", oo), document.removeEventListener("keydown", wn), window.removeEventListener("scroll", Ae, !0);
4740
- };
4741
- }), Pn(() => {
4742
- if (!p(c)) return;
4743
- const v = Gs(p(c), (_) => {
4744
- A(f, _, !0);
4745
- }), y = Us(p(c), (_) => {
4746
- A(b, _, !0);
4747
- });
4748
- return () => {
4749
- y(), v();
4750
- };
4751
- });
4752
- var ri = {
4753
- get enabled() {
4754
- return o();
4755
- },
4756
- set enabled(v = !0) {
4757
- o(v), ho();
4758
- },
4759
- get highlightCoordinator() {
4760
- return n();
4761
- },
4762
- set highlightCoordinator(v = null) {
4763
- n(v), ho();
4764
- },
4765
- get ttsService() {
4766
- return r();
4767
- },
4768
- set ttsService(v = null) {
4769
- r(v), ho();
4770
- }
4771
- }, Tn = ql(), In = Ro(Tn);
4772
- Bn(In, (v) => A(c, v), () => p(c));
4773
- var $n = je(In, 2);
4774
- {
4775
- var ii = (v) => {
4776
- var y = Bl(), _ = so(y);
4777
- _s(_, 17, () => l, ks, (ce, ue) => {
4778
- var U = Nl(), no = so(U), Mo = so(no, !0);
4779
- ro(no), ro(U), lo(() => {
4780
- Vn(U, `background-color: ${p(ue).hex ?? ""};`), jn(U, "aria-label", p(ue).label), jn(U, "title", p(ue).label), Nn(Mo, p(ue).label);
4781
- }), jt("click", U, () => yn(p(ue).name)), He(ce, U);
4782
- });
4783
- var B = je(_, 2), et = je(B, 2);
4784
- {
4785
- var Rt = (ce) => {
4786
- var ue = Vl(), U = je(Ro(ue), 2);
4787
- lo(() => U.disabled = p(h)), jt("click", U, ni), He(ce, ue);
4788
- };
4789
- zt(et, (ce) => {
4790
- r() && ce(Rt);
4791
- });
4792
- }
4793
- var Nt = je(et, 2);
4794
- {
4795
- var li = (ce) => {
4796
- var ue = Wl(), U = je(Ro(ue), 2);
4797
- {
4798
- var no = (tt) => {
4799
- var Vt = jl();
4800
- jt("click", Vt, ti), He(tt, Vt);
4801
- };
4802
- zt(U, (tt) => {
4803
- p(le) && tt(no);
4804
- });
4805
- }
4806
- var Mo = je(U, 2);
4807
- {
4808
- var ai = (tt) => {
4809
- var Vt = zl();
4810
- jt("click", Vt, oi), He(tt, Vt);
4811
- };
4812
- zt(Mo, (tt) => {
4813
- p(se) && tt(ai);
4814
- });
4815
- }
4816
- He(ce, ue);
4817
- };
4818
- zt(Nt, (ce) => {
4819
- (p(le) || p(se)) && ce(li);
4820
- });
4821
- }
4822
- ro(y), Bn(y, (ce) => A(d, ce), () => p(d)), lo(() => Vn(y, `left:${p(g).toolbarPosition.x}px; top:${p(g).toolbarPosition.y}px; transform: translate(-50%, -100%);`)), jt("click", B, () => yn(Ue.UNDERLINE)), He(v, y);
4823
- };
4824
- zt($n, (v) => {
4825
- p(g).isVisible && v(ii);
4826
- });
4827
- }
4828
- var xn = je($n, 2), si = so(xn, !0);
4829
- return ro(xn), lo(() => Nn(si, p(T))), He(e, Tn), rr(ri);
4830
- }
4831
- ms(["click"]);
4832
- customElements.define("pie-tool-annotation-toolbar", Bs(
4833
- Hl,
4834
- {
4835
- enabled: { attribute: "enabled", type: "Boolean" },
4836
- highlightCoordinator: { type: "Object" },
4837
- ttsService: { type: "Object" }
4838
- },
4839
- [],
4840
- [],
4841
- { mode: "open" }
4842
- ));
4843
- export {
4844
- Hl as default
4845
- };