@pie-players/pie-section-player 0.3.3 → 0.3.4

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