@pie-element/simple-cloze 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,4524 @@
1
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/disclose-version.js
2
+ if (typeof window !== "undefined") {
3
+ var _window$__svelte, _window;
4
+ ((_window$__svelte = (_window = window).__svelte ?? (_window.__svelte = {})).v ?? (_window$__svelte.v = /* @__PURE__ */ new Set())).add("5");
5
+ }
6
+ //#endregion
7
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/constants.js
8
+ var HYDRATION_ERROR = {};
9
+ var UNINITIALIZED = Symbol();
10
+ var NAMESPACE_SVG = "http://www.w3.org/2000/svg";
11
+ var NAMESPACE_MATHML = "http://www.w3.org/1998/Math/MathML";
12
+ //#endregion
13
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/shared/utils.js
14
+ var is_array = Array.isArray;
15
+ var index_of = Array.prototype.indexOf;
16
+ var includes = Array.prototype.includes;
17
+ var array_from = Array.from;
18
+ var object_keys = Object.keys;
19
+ var define_property = Object.defineProperty;
20
+ var get_descriptor = Object.getOwnPropertyDescriptor;
21
+ var get_descriptors = Object.getOwnPropertyDescriptors;
22
+ var object_prototype = Object.prototype;
23
+ var array_prototype = Array.prototype;
24
+ var get_prototype_of = Object.getPrototypeOf;
25
+ var is_extensible = Object.isExtensible;
26
+ var noop = () => {};
27
+ /** @param {Array<() => void>} arr */
28
+ function run_all(arr) {
29
+ for (var i = 0; i < arr.length; i++) arr[i]();
30
+ }
31
+ /**
32
+ * TODO replace with Promise.withResolvers once supported widely enough
33
+ * @template [T=void]
34
+ */
35
+ function deferred() {
36
+ /** @type {(value: T) => void} */
37
+ var resolve;
38
+ /** @type {(reason: any) => void} */
39
+ var reject;
40
+ return {
41
+ promise: new Promise((res, rej) => {
42
+ resolve = res;
43
+ reject = rej;
44
+ }),
45
+ resolve,
46
+ reject
47
+ };
48
+ }
49
+ //#endregion
50
+ //#region \0@oxc-project+runtime@0.120.0/helpers/typeof.js
51
+ function _typeof(o) {
52
+ "@babel/helpers - typeof";
53
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
54
+ return typeof o;
55
+ } : function(o) {
56
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
57
+ }, _typeof(o);
58
+ }
59
+ //#endregion
60
+ //#region \0@oxc-project+runtime@0.120.0/helpers/toPrimitive.js
61
+ function toPrimitive(t, r) {
62
+ if ("object" != _typeof(t) || !t) return t;
63
+ var e = t[Symbol.toPrimitive];
64
+ if (void 0 !== e) {
65
+ var i = e.call(t, r || "default");
66
+ if ("object" != _typeof(i)) return i;
67
+ throw new TypeError("@@toPrimitive must return a primitive value.");
68
+ }
69
+ return ("string" === r ? String : Number)(t);
70
+ }
71
+ //#endregion
72
+ //#region \0@oxc-project+runtime@0.120.0/helpers/toPropertyKey.js
73
+ function toPropertyKey(t) {
74
+ var i = toPrimitive(t, "string");
75
+ return "symbol" == _typeof(i) ? i : i + "";
76
+ }
77
+ //#endregion
78
+ //#region \0@oxc-project+runtime@0.120.0/helpers/defineProperty.js
79
+ function _defineProperty(e, r, t) {
80
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
81
+ value: t,
82
+ enumerable: !0,
83
+ configurable: !0,
84
+ writable: !0
85
+ }) : e[r] = t, e;
86
+ }
87
+ var CLEAN = 1024;
88
+ var DIRTY = 2048;
89
+ var MAYBE_DIRTY = 4096;
90
+ var INERT = 8192;
91
+ var DESTROYED = 16384;
92
+ /** Set once a reaction has run for the first time */
93
+ var REACTION_RAN = 32768;
94
+ /** Effect is in the process of getting destroyed. Can be observed in child teardown functions */
95
+ var DESTROYING = 1 << 25;
96
+ /**
97
+ * 'Transparent' effects do not create a transition boundary.
98
+ * This is on a block effect 99% of the time but may also be on a branch effect if its parent block effect was pruned
99
+ */
100
+ var EFFECT_TRANSPARENT = 65536;
101
+ var EFFECT_PRESERVED = 1 << 19;
102
+ var USER_EFFECT = 1 << 20;
103
+ /**
104
+ * Tells that we marked this derived and its reactions as visited during the "mark as (maybe) dirty"-phase.
105
+ * Will be lifted during execution of the derived and during checking its dirty state (both are necessary
106
+ * because a derived might be checked but not executed).
107
+ */
108
+ var WAS_MARKED = 65536;
109
+ var REACTION_IS_UPDATING = 1 << 21;
110
+ var ASYNC = 1 << 22;
111
+ var ERROR_VALUE = 1 << 23;
112
+ var STATE_SYMBOL = Symbol("$state");
113
+ var LEGACY_PROPS = Symbol("legacy props");
114
+ var LOADING_ATTR_SYMBOL = Symbol("");
115
+ /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */
116
+ var STALE_REACTION = new class StaleReactionError extends Error {
117
+ constructor(..._args) {
118
+ super(..._args);
119
+ _defineProperty(this, "name", "StaleReactionError");
120
+ _defineProperty(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed");
121
+ }
122
+ }();
123
+ var IS_XHTML = !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml");
124
+ /**
125
+ * `%name%(...)` can only be used during component initialisation
126
+ * @param {string} name
127
+ * @returns {never}
128
+ */
129
+ function lifecycle_outside_component(name) {
130
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
131
+ }
132
+ //#endregion
133
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/errors.js
134
+ /**
135
+ * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
136
+ * @returns {never}
137
+ */
138
+ function async_derived_orphan() {
139
+ throw new Error(`https://svelte.dev/e/async_derived_orphan`);
140
+ }
141
+ /**
142
+ * `%rune%` cannot be used inside an effect cleanup function
143
+ * @param {string} rune
144
+ * @returns {never}
145
+ */
146
+ function effect_in_teardown(rune) {
147
+ throw new Error(`https://svelte.dev/e/effect_in_teardown`);
148
+ }
149
+ /**
150
+ * Effect cannot be created inside a `$derived` value that was not itself created inside an effect
151
+ * @returns {never}
152
+ */
153
+ function effect_in_unowned_derived() {
154
+ throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
155
+ }
156
+ /**
157
+ * `%rune%` can only be used inside an effect (e.g. during component initialisation)
158
+ * @param {string} rune
159
+ * @returns {never}
160
+ */
161
+ function effect_orphan(rune) {
162
+ throw new Error(`https://svelte.dev/e/effect_orphan`);
163
+ }
164
+ /**
165
+ * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
166
+ * @returns {never}
167
+ */
168
+ function effect_update_depth_exceeded() {
169
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
170
+ }
171
+ /**
172
+ * Failed to hydrate the application
173
+ * @returns {never}
174
+ */
175
+ function hydration_failed() {
176
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
177
+ }
178
+ /**
179
+ * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
180
+ * @returns {never}
181
+ */
182
+ function state_descriptors_fixed() {
183
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
184
+ }
185
+ /**
186
+ * Cannot set prototype of `$state` object
187
+ * @returns {never}
188
+ */
189
+ function state_prototype_fixed() {
190
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
191
+ }
192
+ /**
193
+ * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
194
+ * @returns {never}
195
+ */
196
+ function state_unsafe_mutation() {
197
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
198
+ }
199
+ /**
200
+ * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
201
+ * @returns {never}
202
+ */
203
+ function svelte_boundary_reset_onerror() {
204
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
205
+ }
206
+ /**
207
+ * Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location%
208
+ * @param {string | undefined | null} [location]
209
+ */
210
+ function hydration_mismatch(location) {
211
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
212
+ }
213
+ /**
214
+ * A `<svelte:boundary>` `reset` function only resets the boundary the first time it is called
215
+ */
216
+ function svelte_boundary_reset_noop() {
217
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
218
+ }
219
+ //#endregion
220
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/hydration.js
221
+ /** @import { TemplateNode } from '#client' */
222
+ /**
223
+ * Use this variable to guard everything related to hydration code so it can be treeshaken out
224
+ * if the user doesn't use the `hydrate` method and these code paths are therefore not needed.
225
+ */
226
+ var hydrating = false;
227
+ /** @param {boolean} value */
228
+ function set_hydrating(value) {
229
+ hydrating = value;
230
+ }
231
+ /**
232
+ * The node that is currently being hydrated. This starts out as the first node inside the opening
233
+ * <!--[--> comment, and updates each time a component calls `$.child(...)` or `$.sibling(...)`.
234
+ * When entering a block (e.g. `{#if ...}`), `hydrate_node` is the block opening comment; by the
235
+ * time we leave the block it is the closing comment, which serves as the block's anchor.
236
+ * @type {TemplateNode}
237
+ */
238
+ var hydrate_node;
239
+ /** @param {TemplateNode | null} node */
240
+ function set_hydrate_node(node) {
241
+ if (node === null) {
242
+ hydration_mismatch();
243
+ throw HYDRATION_ERROR;
244
+ }
245
+ return hydrate_node = node;
246
+ }
247
+ function hydrate_next() {
248
+ return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
249
+ }
250
+ /** @param {TemplateNode} node */
251
+ function reset(node) {
252
+ if (!hydrating) return;
253
+ if (/* @__PURE__ */ get_next_sibling(hydrate_node) !== null) {
254
+ hydration_mismatch();
255
+ throw HYDRATION_ERROR;
256
+ }
257
+ hydrate_node = node;
258
+ }
259
+ function next(count = 1) {
260
+ if (hydrating) {
261
+ var i = count;
262
+ var node = hydrate_node;
263
+ while (i--) node = /* @__PURE__ */ get_next_sibling(node);
264
+ hydrate_node = node;
265
+ }
266
+ }
267
+ /**
268
+ * Skips or removes (depending on {@link remove}) all nodes starting at `hydrate_node` up until the next hydration end comment
269
+ * @param {boolean} remove
270
+ */
271
+ function skip_nodes(remove = true) {
272
+ var depth = 0;
273
+ var node = hydrate_node;
274
+ while (true) {
275
+ if (node.nodeType === 8) {
276
+ var data = node.data;
277
+ if (data === "]") {
278
+ if (depth === 0) return node;
279
+ depth -= 1;
280
+ } else if (data === "[" || data === "[!" || data[0] === "[" && !isNaN(Number(data.slice(1)))) depth += 1;
281
+ }
282
+ var next = /* @__PURE__ */ get_next_sibling(node);
283
+ if (remove) node.remove();
284
+ node = next;
285
+ }
286
+ }
287
+ /**
288
+ *
289
+ * @param {TemplateNode} node
290
+ */
291
+ function read_hydration_instruction(node) {
292
+ if (!node || node.nodeType !== 8) {
293
+ hydration_mismatch();
294
+ throw HYDRATION_ERROR;
295
+ }
296
+ return node.data;
297
+ }
298
+ //#endregion
299
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/equality.js
300
+ /** @import { Equals } from '#client' */
301
+ /** @type {Equals} */
302
+ function equals(value) {
303
+ return value === this.v;
304
+ }
305
+ /**
306
+ * @param {unknown} a
307
+ * @param {unknown} b
308
+ * @returns {boolean}
309
+ */
310
+ function safe_not_equal(a, b) {
311
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
312
+ }
313
+ /** @type {Equals} */
314
+ function safe_equals(value) {
315
+ return !safe_not_equal(value, this.v);
316
+ }
317
+ //#endregion
318
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/flags/index.js
319
+ /** True if experimental.async=true */
320
+ var async_mode_flag = false;
321
+ /** True if we're not certain that we only have Svelte 5 code in the compilation */
322
+ var legacy_mode_flag = false;
323
+ //#endregion
324
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/context.js
325
+ /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
326
+ /** @type {ComponentContext | null} */
327
+ var component_context = null;
328
+ /** @param {ComponentContext | null} context */
329
+ function set_component_context(context) {
330
+ component_context = context;
331
+ }
332
+ /**
333
+ * @param {Record<string, unknown>} props
334
+ * @param {any} runes
335
+ * @param {Function} [fn]
336
+ * @returns {void}
337
+ */
338
+ function push(props, runes = false, fn) {
339
+ component_context = {
340
+ p: component_context,
341
+ i: false,
342
+ c: null,
343
+ e: null,
344
+ s: props,
345
+ x: null,
346
+ r: active_effect,
347
+ l: legacy_mode_flag && !runes ? {
348
+ s: null,
349
+ u: null,
350
+ $: []
351
+ } : null
352
+ };
353
+ }
354
+ /**
355
+ * @template {Record<string, any>} T
356
+ * @param {T} [component]
357
+ * @returns {T}
358
+ */
359
+ function pop(component) {
360
+ var context = component_context;
361
+ var effects = context.e;
362
+ if (effects !== null) {
363
+ context.e = null;
364
+ for (var fn of effects) create_user_effect(fn);
365
+ }
366
+ if (component !== void 0) context.x = component;
367
+ context.i = true;
368
+ component_context = context.p;
369
+ return component ?? {};
370
+ }
371
+ /** @returns {boolean} */
372
+ function is_runes() {
373
+ return !legacy_mode_flag || component_context !== null && component_context.l === null;
374
+ }
375
+ //#endregion
376
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/task.js
377
+ /** @type {Array<() => void>} */
378
+ var micro_tasks = [];
379
+ function run_micro_tasks() {
380
+ var tasks = micro_tasks;
381
+ micro_tasks = [];
382
+ run_all(tasks);
383
+ }
384
+ /**
385
+ * @param {() => void} fn
386
+ */
387
+ function queue_micro_task(fn) {
388
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
389
+ var tasks = micro_tasks;
390
+ queueMicrotask(() => {
391
+ if (tasks === micro_tasks) run_micro_tasks();
392
+ });
393
+ }
394
+ micro_tasks.push(fn);
395
+ }
396
+ /**
397
+ * Synchronously run any queued tasks.
398
+ */
399
+ function flush_tasks() {
400
+ while (micro_tasks.length > 0) run_micro_tasks();
401
+ }
402
+ /**
403
+ * @param {unknown} error
404
+ */
405
+ function handle_error(error) {
406
+ var effect = active_effect;
407
+ if (effect === null) {
408
+ /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
409
+ return error;
410
+ }
411
+ if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
412
+ invoke_error_boundary(error, effect);
413
+ }
414
+ /**
415
+ * @param {unknown} error
416
+ * @param {Effect | null} effect
417
+ */
418
+ function invoke_error_boundary(error, effect) {
419
+ while (effect !== null) {
420
+ if ((effect.f & 128) !== 0) {
421
+ if ((effect.f & 32768) === 0) throw error;
422
+ try {
423
+ /** @type {Boundary} */ effect.b.error(error);
424
+ return;
425
+ } catch (e) {
426
+ error = e;
427
+ }
428
+ }
429
+ effect = effect.parent;
430
+ }
431
+ throw error;
432
+ }
433
+ //#endregion
434
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/status.js
435
+ /** @import { Derived, Signal } from '#client' */
436
+ var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
437
+ /**
438
+ * @param {Signal} signal
439
+ * @param {number} status
440
+ */
441
+ function set_signal_status(signal, status) {
442
+ signal.f = signal.f & STATUS_MASK | status;
443
+ }
444
+ /**
445
+ * Set a derived's status to CLEAN or MAYBE_DIRTY based on its connection state.
446
+ * @param {Derived} derived
447
+ */
448
+ function update_derived_status(derived) {
449
+ if ((derived.f & 512) !== 0 || derived.deps === null) set_signal_status(derived, CLEAN);
450
+ else set_signal_status(derived, MAYBE_DIRTY);
451
+ }
452
+ //#endregion
453
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/utils.js
454
+ /** @import { Derived, Effect, Value } from '#client' */
455
+ /**
456
+ * @param {Value[] | null} deps
457
+ */
458
+ function clear_marked(deps) {
459
+ if (deps === null) return;
460
+ for (const dep of deps) {
461
+ if ((dep.f & 2) === 0 || (dep.f & 65536) === 0) continue;
462
+ dep.f ^= WAS_MARKED;
463
+ clear_marked(
464
+ /** @type {Derived} */
465
+ dep.deps
466
+ );
467
+ }
468
+ }
469
+ /**
470
+ * @param {Effect} effect
471
+ * @param {Set<Effect>} dirty_effects
472
+ * @param {Set<Effect>} maybe_dirty_effects
473
+ */
474
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
475
+ if ((effect.f & 2048) !== 0) dirty_effects.add(effect);
476
+ else if ((effect.f & 4096) !== 0) maybe_dirty_effects.add(effect);
477
+ clear_marked(effect.deps);
478
+ set_signal_status(effect, CLEAN);
479
+ }
480
+ //#endregion
481
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/store.js
482
+ /**
483
+ * We set this to `true` when updating a store so that we correctly
484
+ * schedule effects if the update takes place inside a `$:` effect
485
+ */
486
+ var legacy_is_updating_store = false;
487
+ //#endregion
488
+ //#region \0@oxc-project+runtime@0.120.0/helpers/checkPrivateRedeclaration.js
489
+ function _checkPrivateRedeclaration(e, t) {
490
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
491
+ }
492
+ //#endregion
493
+ //#region \0@oxc-project+runtime@0.120.0/helpers/classPrivateMethodInitSpec.js
494
+ function _classPrivateMethodInitSpec(e, a) {
495
+ _checkPrivateRedeclaration(e, a), a.add(e);
496
+ }
497
+ //#endregion
498
+ //#region \0@oxc-project+runtime@0.120.0/helpers/classPrivateFieldInitSpec.js
499
+ function _classPrivateFieldInitSpec(e, t, a) {
500
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
501
+ }
502
+ //#endregion
503
+ //#region \0@oxc-project+runtime@0.120.0/helpers/assertClassBrand.js
504
+ function _assertClassBrand(e, t, n) {
505
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
506
+ throw new TypeError("Private element is not present on this object");
507
+ }
508
+ //#endregion
509
+ //#region \0@oxc-project+runtime@0.120.0/helpers/classPrivateFieldGet2.js
510
+ function _classPrivateFieldGet2(s, a) {
511
+ return s.get(_assertClassBrand(s, a));
512
+ }
513
+ //#endregion
514
+ //#region \0@oxc-project+runtime@0.120.0/helpers/classPrivateFieldSet2.js
515
+ function _classPrivateFieldSet2(s, a, r) {
516
+ return s.set(_assertClassBrand(s, a), r), r;
517
+ }
518
+ //#endregion
519
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/batch.js
520
+ /** @import { Fork } from 'svelte' */
521
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
522
+ var _Batch;
523
+ /** @type {Set<Batch>} */
524
+ var batches = /* @__PURE__ */ new Set();
525
+ /** @type {Batch | null} */
526
+ var current_batch = null;
527
+ /**
528
+ * When time travelling (i.e. working in one batch, while other batches
529
+ * still have ongoing work), we ignore the real values of affected
530
+ * signals in favour of their values within the batch
531
+ * @type {Map<Value, any> | null}
532
+ */
533
+ var batch_values = null;
534
+ /** @type {Effect | null} */
535
+ var last_scheduled_effect = null;
536
+ var is_flushing_sync = false;
537
+ var is_processing = false;
538
+ /**
539
+ * During traversal, this is an array. Newly created effects are (if not immediately
540
+ * executed) pushed to this array, rather than going through the scheduling
541
+ * rigamarole that would cause another turn of the flush loop.
542
+ * @type {Effect[] | null}
543
+ */
544
+ var collected_effects = null;
545
+ /**
546
+ * An array of effects that are marked during traversal as a result of a `set`
547
+ * (not `internal_set`) call. These will be added to the next batch and
548
+ * trigger another `batch.process()`
549
+ * @type {Effect[] | null}
550
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
551
+ */
552
+ var legacy_updates = null;
553
+ var flush_count = 0;
554
+ var uid = 1;
555
+ var _commit_callbacks = /* @__PURE__ */ new WeakMap();
556
+ var _discard_callbacks = /* @__PURE__ */ new WeakMap();
557
+ var _pending = /* @__PURE__ */ new WeakMap();
558
+ var _blocking_pending = /* @__PURE__ */ new WeakMap();
559
+ var _deferred = /* @__PURE__ */ new WeakMap();
560
+ var _roots = /* @__PURE__ */ new WeakMap();
561
+ var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
562
+ var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
563
+ var _skipped_branches = /* @__PURE__ */ new WeakMap();
564
+ var _decrement_queued = /* @__PURE__ */ new WeakMap();
565
+ var _Batch_brand = /* @__PURE__ */ new WeakSet();
566
+ var Batch = class Batch {
567
+ constructor() {
568
+ _classPrivateMethodInitSpec(this, _Batch_brand);
569
+ _defineProperty(this, "id", uid++);
570
+ _defineProperty(
571
+ this,
572
+ /**
573
+ * The current values of any sources that are updated in this batch
574
+ * They keys of this map are identical to `this.#previous`
575
+ * @type {Map<Source, any>}
576
+ */
577
+ "current",
578
+ /* @__PURE__ */ new Map()
579
+ );
580
+ _defineProperty(
581
+ this,
582
+ /**
583
+ * The values of any sources that are updated in this batch _before_ those updates took place.
584
+ * They keys of this map are identical to `this.#current`
585
+ * @type {Map<Source, any>}
586
+ */
587
+ "previous",
588
+ /* @__PURE__ */ new Map()
589
+ );
590
+ _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
591
+ _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
592
+ _classPrivateFieldInitSpec(this, _pending, 0);
593
+ _classPrivateFieldInitSpec(this, _blocking_pending, 0);
594
+ _classPrivateFieldInitSpec(this, _deferred, null);
595
+ _classPrivateFieldInitSpec(this, _roots, []);
596
+ _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
597
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
598
+ _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
599
+ _defineProperty(this, "is_fork", false);
600
+ _classPrivateFieldInitSpec(this, _decrement_queued, false);
601
+ }
602
+ /**
603
+ * Add an effect to the #skipped_branches map and reset its children
604
+ * @param {Effect} effect
605
+ */
606
+ skip_effect(effect) {
607
+ if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
608
+ d: [],
609
+ m: []
610
+ });
611
+ }
612
+ /**
613
+ * Remove an effect from the #skipped_branches map and reschedule
614
+ * any tracked dirty/maybe_dirty child effects
615
+ * @param {Effect} effect
616
+ */
617
+ unskip_effect(effect) {
618
+ var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
619
+ if (tracked) {
620
+ _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
621
+ for (var e of tracked.d) {
622
+ set_signal_status(e, DIRTY);
623
+ this.schedule(e);
624
+ }
625
+ for (e of tracked.m) {
626
+ set_signal_status(e, MAYBE_DIRTY);
627
+ this.schedule(e);
628
+ }
629
+ }
630
+ }
631
+ /**
632
+ * Associate a change to a given source with the current
633
+ * batch, noting its previous and current values
634
+ * @param {Source} source
635
+ * @param {any} old_value
636
+ */
637
+ capture(source, old_value) {
638
+ if (old_value !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, old_value);
639
+ if ((source.f & 8388608) === 0) {
640
+ this.current.set(source, source.v);
641
+ batch_values?.set(source, source.v);
642
+ }
643
+ }
644
+ activate() {
645
+ current_batch = this;
646
+ }
647
+ deactivate() {
648
+ current_batch = null;
649
+ batch_values = null;
650
+ }
651
+ flush() {
652
+ try {
653
+ is_processing = true;
654
+ current_batch = this;
655
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
656
+ } finally {
657
+ flush_count = 0;
658
+ last_scheduled_effect = null;
659
+ collected_effects = null;
660
+ legacy_updates = null;
661
+ is_processing = false;
662
+ current_batch = null;
663
+ batch_values = null;
664
+ old_values.clear();
665
+ }
666
+ }
667
+ discard() {
668
+ for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
669
+ _classPrivateFieldGet2(_discard_callbacks, this).clear();
670
+ batches.delete(this);
671
+ }
672
+ /**
673
+ *
674
+ * @param {boolean} blocking
675
+ */
676
+ increment(blocking) {
677
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
678
+ if (blocking) _classPrivateFieldSet2(_blocking_pending, this, _classPrivateFieldGet2(_blocking_pending, this) + 1);
679
+ }
680
+ /**
681
+ * @param {boolean} blocking
682
+ * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
683
+ */
684
+ decrement(blocking, skip) {
685
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
686
+ if (blocking) _classPrivateFieldSet2(_blocking_pending, this, _classPrivateFieldGet2(_blocking_pending, this) - 1);
687
+ if (_classPrivateFieldGet2(_decrement_queued, this) || skip) return;
688
+ _classPrivateFieldSet2(_decrement_queued, this, true);
689
+ queue_micro_task(() => {
690
+ _classPrivateFieldSet2(_decrement_queued, this, false);
691
+ this.flush();
692
+ });
693
+ }
694
+ /**
695
+ * @param {Set<Effect>} dirty_effects
696
+ * @param {Set<Effect>} maybe_dirty_effects
697
+ */
698
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
699
+ for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
700
+ for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
701
+ dirty_effects.clear();
702
+ maybe_dirty_effects.clear();
703
+ }
704
+ /** @param {(batch: Batch) => void} fn */
705
+ oncommit(fn) {
706
+ _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
707
+ }
708
+ /** @param {(batch: Batch) => void} fn */
709
+ ondiscard(fn) {
710
+ _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
711
+ }
712
+ settled() {
713
+ return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
714
+ }
715
+ static ensure() {
716
+ if (current_batch === null) {
717
+ const batch = current_batch = new Batch();
718
+ if (!is_processing) {
719
+ batches.add(current_batch);
720
+ if (!is_flushing_sync) queue_micro_task(() => {
721
+ if (current_batch !== batch) return;
722
+ batch.flush();
723
+ });
724
+ }
725
+ }
726
+ return current_batch;
727
+ }
728
+ apply() {
729
+ if (!async_mode_flag || !this.is_fork && batches.size === 1) {
730
+ batch_values = null;
731
+ return;
732
+ }
733
+ batch_values = new Map(this.current);
734
+ for (const batch of batches) {
735
+ if (batch === this || batch.is_fork) continue;
736
+ for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
737
+ }
738
+ }
739
+ /**
740
+ *
741
+ * @param {Effect} effect
742
+ */
743
+ schedule(effect) {
744
+ last_scheduled_effect = effect;
745
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
746
+ effect.b.defer_effect(effect);
747
+ return;
748
+ }
749
+ var e = effect;
750
+ while (e.parent !== null) {
751
+ e = e.parent;
752
+ var flags = e.f;
753
+ if (collected_effects !== null && e === active_effect) {
754
+ if (async_mode_flag) return;
755
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
756
+ }
757
+ if ((flags & 96) !== 0) {
758
+ if ((flags & 1024) === 0) return;
759
+ e.f ^= CLEAN;
760
+ }
761
+ }
762
+ _classPrivateFieldGet2(_roots, this).push(e);
763
+ }
764
+ };
765
+ _Batch = Batch;
766
+ function _is_deferred() {
767
+ return this.is_fork || _classPrivateFieldGet2(_blocking_pending, this) > 0;
768
+ }
769
+ function _process() {
770
+ if (flush_count++ > 1e3) {
771
+ batches.delete(this);
772
+ infinite_loop_guard();
773
+ }
774
+ if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
775
+ for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
776
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
777
+ set_signal_status(e, DIRTY);
778
+ this.schedule(e);
779
+ }
780
+ for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
781
+ set_signal_status(e, MAYBE_DIRTY);
782
+ this.schedule(e);
783
+ }
784
+ }
785
+ const roots = _classPrivateFieldGet2(_roots, this);
786
+ _classPrivateFieldSet2(_roots, this, []);
787
+ this.apply();
788
+ /** @type {Effect[]} */
789
+ var effects = collected_effects = [];
790
+ /** @type {Effect[]} */
791
+ var render_effects = [];
792
+ /**
793
+ * @type {Effect[]}
794
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
795
+ */
796
+ var updates = legacy_updates = [];
797
+ for (const root of roots) try {
798
+ _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
799
+ } catch (e) {
800
+ reset_all(root);
801
+ throw e;
802
+ }
803
+ current_batch = null;
804
+ if (updates.length > 0) {
805
+ var batch = _Batch.ensure();
806
+ for (const e of updates) batch.schedule(e);
807
+ }
808
+ collected_effects = null;
809
+ legacy_updates = null;
810
+ if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
811
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
812
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
813
+ for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
814
+ } else {
815
+ if (_classPrivateFieldGet2(_pending, this) === 0) batches.delete(this);
816
+ _classPrivateFieldGet2(_dirty_effects$1, this).clear();
817
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
818
+ for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
819
+ _classPrivateFieldGet2(_commit_callbacks, this).clear();
820
+ flush_queued_effects(render_effects);
821
+ flush_queued_effects(effects);
822
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
823
+ }
824
+ var next_batch = current_batch;
825
+ if (_classPrivateFieldGet2(_roots, this).length > 0) {
826
+ const batch = next_batch ?? (next_batch = this);
827
+ _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
828
+ }
829
+ if (next_batch !== null) {
830
+ batches.add(next_batch);
831
+ _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
832
+ }
833
+ if (!batches.has(this)) _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
834
+ }
835
+ /**
836
+ * Traverse the effect tree, executing effects or stashing
837
+ * them for later execution as appropriate
838
+ * @param {Effect} root
839
+ * @param {Effect[]} effects
840
+ * @param {Effect[]} render_effects
841
+ */
842
+ function _traverse(root, effects, render_effects) {
843
+ root.f ^= CLEAN;
844
+ var effect = root.first;
845
+ while (effect !== null) {
846
+ var flags = effect.f;
847
+ var is_branch = (flags & 96) !== 0;
848
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
849
+ if (is_branch) effect.f ^= CLEAN;
850
+ else if ((flags & 4) !== 0) effects.push(effect);
851
+ else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
852
+ else if (is_dirty(effect)) {
853
+ if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
854
+ update_effect(effect);
855
+ }
856
+ var child = effect.first;
857
+ if (child !== null) {
858
+ effect = child;
859
+ continue;
860
+ }
861
+ }
862
+ while (effect !== null) {
863
+ var next = effect.next;
864
+ if (next !== null) {
865
+ effect = next;
866
+ break;
867
+ }
868
+ effect = effect.parent;
869
+ }
870
+ }
871
+ }
872
+ /**
873
+ * @param {Effect[]} effects
874
+ */
875
+ function _defer_effects(effects) {
876
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
877
+ }
878
+ function _commit$1() {
879
+ for (const batch of batches) {
880
+ var is_earlier = batch.id < this.id;
881
+ /** @type {Source[]} */
882
+ var sources = [];
883
+ for (const [source, value] of this.current) {
884
+ if (batch.current.has(source)) if (is_earlier && value !== batch.current.get(source)) batch.current.set(source, value);
885
+ else continue;
886
+ sources.push(source);
887
+ }
888
+ var others = [...batch.current.keys()].filter((s) => !this.current.has(s));
889
+ if (others.length === 0) {
890
+ if (is_earlier) batch.discard();
891
+ } else if (sources.length > 0) {
892
+ batch.activate();
893
+ /** @type {Set<Value>} */
894
+ var marked = /* @__PURE__ */ new Set();
895
+ /** @type {Map<Reaction, boolean>} */
896
+ var checked = /* @__PURE__ */ new Map();
897
+ for (var source of sources) mark_effects(source, others, marked, checked);
898
+ if (_classPrivateFieldGet2(_roots, batch).length > 0) {
899
+ batch.apply();
900
+ for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
901
+ _classPrivateFieldSet2(_roots, batch, []);
902
+ }
903
+ batch.deactivate();
904
+ }
905
+ }
906
+ }
907
+ /**
908
+ * Synchronously flush any pending updates.
909
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
910
+ * @template [T=void]
911
+ * @param {(() => T) | undefined} [fn]
912
+ * @returns {T}
913
+ */
914
+ function flushSync(fn) {
915
+ var was_flushing_sync = is_flushing_sync;
916
+ is_flushing_sync = true;
917
+ try {
918
+ var result;
919
+ if (fn) {
920
+ if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
921
+ result = fn();
922
+ }
923
+ while (true) {
924
+ flush_tasks();
925
+ if (current_batch === null) return result;
926
+ current_batch.flush();
927
+ }
928
+ } finally {
929
+ is_flushing_sync = was_flushing_sync;
930
+ }
931
+ }
932
+ function infinite_loop_guard() {
933
+ try {
934
+ effect_update_depth_exceeded();
935
+ } catch (error) {
936
+ invoke_error_boundary(error, last_scheduled_effect);
937
+ }
938
+ }
939
+ /** @type {Set<Effect> | null} */
940
+ var eager_block_effects = null;
941
+ /**
942
+ * @param {Array<Effect>} effects
943
+ * @returns {void}
944
+ */
945
+ function flush_queued_effects(effects) {
946
+ var length = effects.length;
947
+ if (length === 0) return;
948
+ var i = 0;
949
+ while (i < length) {
950
+ var effect = effects[i++];
951
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
952
+ eager_block_effects = /* @__PURE__ */ new Set();
953
+ update_effect(effect);
954
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
955
+ if (eager_block_effects?.size > 0) {
956
+ old_values.clear();
957
+ for (const e of eager_block_effects) {
958
+ if ((e.f & 24576) !== 0) continue;
959
+ /** @type {Effect[]} */
960
+ const ordered_effects = [e];
961
+ let ancestor = e.parent;
962
+ while (ancestor !== null) {
963
+ if (eager_block_effects.has(ancestor)) {
964
+ eager_block_effects.delete(ancestor);
965
+ ordered_effects.push(ancestor);
966
+ }
967
+ ancestor = ancestor.parent;
968
+ }
969
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
970
+ const e = ordered_effects[j];
971
+ if ((e.f & 24576) !== 0) continue;
972
+ update_effect(e);
973
+ }
974
+ }
975
+ eager_block_effects.clear();
976
+ }
977
+ }
978
+ }
979
+ eager_block_effects = null;
980
+ }
981
+ /**
982
+ * This is similar to `mark_reactions`, but it only marks async/block effects
983
+ * depending on `value` and at least one of the other `sources`, so that
984
+ * these effects can re-run after another batch has been committed
985
+ * @param {Value} value
986
+ * @param {Source[]} sources
987
+ * @param {Set<Value>} marked
988
+ * @param {Map<Reaction, boolean>} checked
989
+ */
990
+ function mark_effects(value, sources, marked, checked) {
991
+ if (marked.has(value)) return;
992
+ marked.add(value);
993
+ if (value.reactions !== null) for (const reaction of value.reactions) {
994
+ const flags = reaction.f;
995
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
996
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
997
+ set_signal_status(reaction, DIRTY);
998
+ schedule_effect(reaction);
999
+ }
1000
+ }
1001
+ }
1002
+ /**
1003
+ * @param {Reaction} reaction
1004
+ * @param {Source[]} sources
1005
+ * @param {Map<Reaction, boolean>} checked
1006
+ */
1007
+ function depends_on(reaction, sources, checked) {
1008
+ const depends = checked.get(reaction);
1009
+ if (depends !== void 0) return depends;
1010
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
1011
+ if (includes.call(sources, dep)) return true;
1012
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1013
+ checked.set(dep, true);
1014
+ return true;
1015
+ }
1016
+ }
1017
+ checked.set(reaction, false);
1018
+ return false;
1019
+ }
1020
+ /**
1021
+ * @param {Effect} effect
1022
+ * @returns {void}
1023
+ */
1024
+ function schedule_effect(effect) {
1025
+ /** @type {Batch} */ current_batch.schedule(effect);
1026
+ }
1027
+ /**
1028
+ * Mark all the effects inside a skipped branch CLEAN, so that
1029
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1030
+ * effects so they can be rescheduled if the branch survives.
1031
+ * @param {Effect} effect
1032
+ * @param {{ d: Effect[], m: Effect[] }} tracked
1033
+ */
1034
+ function reset_branch(effect, tracked) {
1035
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1036
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1037
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1038
+ set_signal_status(effect, CLEAN);
1039
+ var e = effect.first;
1040
+ while (e !== null) {
1041
+ reset_branch(e, tracked);
1042
+ e = e.next;
1043
+ }
1044
+ }
1045
+ /**
1046
+ * Mark an entire effect tree clean following an error
1047
+ * @param {Effect} effect
1048
+ */
1049
+ function reset_all(effect) {
1050
+ set_signal_status(effect, CLEAN);
1051
+ var e = effect.first;
1052
+ while (e !== null) {
1053
+ reset_all(e);
1054
+ e = e.next;
1055
+ }
1056
+ }
1057
+ //#endregion
1058
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/reactivity/create-subscriber.js
1059
+ /**
1060
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
1061
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
1062
+ *
1063
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
1064
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
1065
+ *
1066
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
1067
+ *
1068
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
1069
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
1070
+ *
1071
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
1072
+ *
1073
+ * ```js
1074
+ * import { createSubscriber } from 'svelte/reactivity';
1075
+ * import { on } from 'svelte/events';
1076
+ *
1077
+ * export class MediaQuery {
1078
+ * #query;
1079
+ * #subscribe;
1080
+ *
1081
+ * constructor(query) {
1082
+ * this.#query = window.matchMedia(`(${query})`);
1083
+ *
1084
+ * this.#subscribe = createSubscriber((update) => {
1085
+ * // when the `change` event occurs, re-run any effects that read `this.current`
1086
+ * const off = on(this.#query, 'change', update);
1087
+ *
1088
+ * // stop listening when all the effects are destroyed
1089
+ * return () => off();
1090
+ * });
1091
+ * }
1092
+ *
1093
+ * get current() {
1094
+ * // This makes the getter reactive, if read in an effect
1095
+ * this.#subscribe();
1096
+ *
1097
+ * // Return the current state of the query, whether or not we're in an effect
1098
+ * return this.#query.matches;
1099
+ * }
1100
+ * }
1101
+ * ```
1102
+ * @param {(update: () => void) => (() => void) | void} start
1103
+ * @since 5.7.0
1104
+ */
1105
+ function createSubscriber(start) {
1106
+ let subscribers = 0;
1107
+ let version = source(0);
1108
+ /** @type {(() => void) | void} */
1109
+ let stop;
1110
+ return () => {
1111
+ if (effect_tracking()) {
1112
+ get(version);
1113
+ render_effect(() => {
1114
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
1115
+ subscribers += 1;
1116
+ return () => {
1117
+ queue_micro_task(() => {
1118
+ subscribers -= 1;
1119
+ if (subscribers === 0) {
1120
+ stop?.();
1121
+ stop = void 0;
1122
+ increment(version);
1123
+ }
1124
+ });
1125
+ };
1126
+ });
1127
+ }
1128
+ };
1129
+ }
1130
+ //#endregion
1131
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
1132
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
1133
+ /**
1134
+ * @typedef {{
1135
+ * onerror?: (error: unknown, reset: () => void) => void;
1136
+ * failed?: (anchor: Node, error: () => unknown, reset: () => () => void) => void;
1137
+ * pending?: (anchor: Node) => void;
1138
+ * }} BoundaryProps
1139
+ */
1140
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
1141
+ /**
1142
+ * @param {TemplateNode} node
1143
+ * @param {BoundaryProps} props
1144
+ * @param {((anchor: Node) => void)} children
1145
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
1146
+ * @returns {void}
1147
+ */
1148
+ function boundary(node, props, children, transform_error) {
1149
+ new Boundary(node, props, children, transform_error);
1150
+ }
1151
+ var _anchor = /* @__PURE__ */ new WeakMap();
1152
+ var _hydrate_open = /* @__PURE__ */ new WeakMap();
1153
+ var _props = /* @__PURE__ */ new WeakMap();
1154
+ var _children = /* @__PURE__ */ new WeakMap();
1155
+ var _effect = /* @__PURE__ */ new WeakMap();
1156
+ var _main_effect = /* @__PURE__ */ new WeakMap();
1157
+ var _pending_effect = /* @__PURE__ */ new WeakMap();
1158
+ var _failed_effect = /* @__PURE__ */ new WeakMap();
1159
+ var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
1160
+ var _local_pending_count = /* @__PURE__ */ new WeakMap();
1161
+ var _pending_count = /* @__PURE__ */ new WeakMap();
1162
+ var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
1163
+ var _dirty_effects = /* @__PURE__ */ new WeakMap();
1164
+ var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
1165
+ var _effect_pending = /* @__PURE__ */ new WeakMap();
1166
+ var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
1167
+ var _Boundary_brand = /* @__PURE__ */ new WeakSet();
1168
+ var Boundary = class {
1169
+ /**
1170
+ * @param {TemplateNode} node
1171
+ * @param {BoundaryProps} props
1172
+ * @param {((anchor: Node) => void)} children
1173
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
1174
+ */
1175
+ constructor(node, props, children, transform_error) {
1176
+ _classPrivateMethodInitSpec(this, _Boundary_brand);
1177
+ _defineProperty(
1178
+ this,
1179
+ /** @type {Boundary | null} */
1180
+ "parent",
1181
+ void 0
1182
+ );
1183
+ _defineProperty(this, "is_pending", false);
1184
+ _defineProperty(
1185
+ this,
1186
+ /**
1187
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
1188
+ * Inherited from parent boundary, or defaults to identity.
1189
+ * @type {(error: unknown) => unknown}
1190
+ */
1191
+ "transform_error",
1192
+ void 0
1193
+ );
1194
+ _classPrivateFieldInitSpec(this, _anchor, void 0);
1195
+ _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
1196
+ _classPrivateFieldInitSpec(this, _props, void 0);
1197
+ _classPrivateFieldInitSpec(this, _children, void 0);
1198
+ _classPrivateFieldInitSpec(this, _effect, void 0);
1199
+ _classPrivateFieldInitSpec(this, _main_effect, null);
1200
+ _classPrivateFieldInitSpec(this, _pending_effect, null);
1201
+ _classPrivateFieldInitSpec(this, _failed_effect, null);
1202
+ _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
1203
+ _classPrivateFieldInitSpec(this, _local_pending_count, 0);
1204
+ _classPrivateFieldInitSpec(this, _pending_count, 0);
1205
+ _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
1206
+ _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
1207
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
1208
+ _classPrivateFieldInitSpec(this, _effect_pending, null);
1209
+ _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
1210
+ _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
1211
+ return () => {
1212
+ _classPrivateFieldSet2(_effect_pending, this, null);
1213
+ };
1214
+ }));
1215
+ _classPrivateFieldSet2(_anchor, this, node);
1216
+ _classPrivateFieldSet2(_props, this, props);
1217
+ _classPrivateFieldSet2(_children, this, (anchor) => {
1218
+ var effect = active_effect;
1219
+ effect.b = this;
1220
+ effect.f |= 128;
1221
+ children(anchor);
1222
+ });
1223
+ this.parent = active_effect.b;
1224
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
1225
+ _classPrivateFieldSet2(_effect, this, block(() => {
1226
+ if (hydrating) {
1227
+ const comment = _classPrivateFieldGet2(_hydrate_open, this);
1228
+ hydrate_next();
1229
+ const server_rendered_pending = comment.data === "[!";
1230
+ if (comment.data.startsWith("[?")) {
1231
+ const serialized_error = JSON.parse(comment.data.slice(2));
1232
+ _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
1233
+ } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
1234
+ else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
1235
+ } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
1236
+ }, flags));
1237
+ if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
1238
+ }
1239
+ /**
1240
+ * Defer an effect inside a pending boundary until the boundary resolves
1241
+ * @param {Effect} effect
1242
+ */
1243
+ defer_effect(effect) {
1244
+ defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1245
+ }
1246
+ /**
1247
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1248
+ * @returns {boolean}
1249
+ */
1250
+ is_rendered() {
1251
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
1252
+ }
1253
+ has_pending_snippet() {
1254
+ return !!_classPrivateFieldGet2(_props, this).pending;
1255
+ }
1256
+ /**
1257
+ * Update the source that powers `$effect.pending()` inside this boundary,
1258
+ * and controls when the current `pending` snippet (if any) is removed.
1259
+ * Do not call from inside the class
1260
+ * @param {1 | -1} d
1261
+ * @param {Batch} batch
1262
+ */
1263
+ update_pending_count(d, batch) {
1264
+ _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
1265
+ _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
1266
+ if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
1267
+ _classPrivateFieldSet2(_pending_count_update_queued, this, true);
1268
+ queue_micro_task(() => {
1269
+ _classPrivateFieldSet2(_pending_count_update_queued, this, false);
1270
+ if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
1271
+ });
1272
+ }
1273
+ get_effect_pending() {
1274
+ _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
1275
+ return get(_classPrivateFieldGet2(_effect_pending, this));
1276
+ }
1277
+ /** @param {unknown} error */
1278
+ error(error) {
1279
+ var onerror = _classPrivateFieldGet2(_props, this).onerror;
1280
+ let failed = _classPrivateFieldGet2(_props, this).failed;
1281
+ if (!onerror && !failed) throw error;
1282
+ if (_classPrivateFieldGet2(_main_effect, this)) {
1283
+ destroy_effect(_classPrivateFieldGet2(_main_effect, this));
1284
+ _classPrivateFieldSet2(_main_effect, this, null);
1285
+ }
1286
+ if (_classPrivateFieldGet2(_pending_effect, this)) {
1287
+ destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
1288
+ _classPrivateFieldSet2(_pending_effect, this, null);
1289
+ }
1290
+ if (_classPrivateFieldGet2(_failed_effect, this)) {
1291
+ destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
1292
+ _classPrivateFieldSet2(_failed_effect, this, null);
1293
+ }
1294
+ if (hydrating) {
1295
+ set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
1296
+ next();
1297
+ set_hydrate_node(skip_nodes());
1298
+ }
1299
+ var did_reset = false;
1300
+ var calling_on_error = false;
1301
+ const reset = () => {
1302
+ if (did_reset) {
1303
+ svelte_boundary_reset_noop();
1304
+ return;
1305
+ }
1306
+ did_reset = true;
1307
+ if (calling_on_error) svelte_boundary_reset_onerror();
1308
+ if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
1309
+ _classPrivateFieldSet2(_failed_effect, this, null);
1310
+ });
1311
+ _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1312
+ _assertClassBrand(_Boundary_brand, this, _render).call(this);
1313
+ });
1314
+ };
1315
+ /** @param {unknown} transformed_error */
1316
+ const handle_error_result = (transformed_error) => {
1317
+ try {
1318
+ calling_on_error = true;
1319
+ onerror?.(transformed_error, reset);
1320
+ calling_on_error = false;
1321
+ } catch (error) {
1322
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1323
+ }
1324
+ if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1325
+ try {
1326
+ return branch(() => {
1327
+ var effect = active_effect;
1328
+ effect.b = this;
1329
+ effect.f |= 128;
1330
+ failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
1331
+ });
1332
+ } catch (error) {
1333
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
1334
+ return null;
1335
+ }
1336
+ }));
1337
+ };
1338
+ queue_micro_task(() => {
1339
+ /** @type {unknown} */
1340
+ var result;
1341
+ try {
1342
+ result = this.transform_error(error);
1343
+ } catch (e) {
1344
+ invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1345
+ return;
1346
+ }
1347
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
1348
+ /** @type {any} */ result.then(
1349
+ handle_error_result,
1350
+ /** @param {unknown} e */
1351
+ (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
1352
+ );
1353
+ else handle_error_result(result);
1354
+ });
1355
+ }
1356
+ };
1357
+ function _hydrate_resolved_content() {
1358
+ try {
1359
+ _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
1360
+ } catch (error) {
1361
+ this.error(error);
1362
+ }
1363
+ }
1364
+ /**
1365
+ * @param {unknown} error The deserialized error from the server's hydration comment
1366
+ */
1367
+ function _hydrate_failed_content(error) {
1368
+ const failed = _classPrivateFieldGet2(_props, this).failed;
1369
+ if (!failed) return;
1370
+ _classPrivateFieldSet2(_failed_effect, this, branch(() => {
1371
+ failed(_classPrivateFieldGet2(_anchor, this), () => error, () => () => {});
1372
+ }));
1373
+ }
1374
+ function _hydrate_pending_content() {
1375
+ const pending = _classPrivateFieldGet2(_props, this).pending;
1376
+ if (!pending) return;
1377
+ this.is_pending = true;
1378
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1379
+ queue_micro_task(() => {
1380
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1381
+ var anchor = create_text();
1382
+ fragment.append(anchor);
1383
+ _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1384
+ return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
1385
+ }));
1386
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1387
+ _classPrivateFieldGet2(_anchor, this).before(fragment);
1388
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
1389
+ pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1390
+ _classPrivateFieldSet2(_pending_effect, this, null);
1391
+ });
1392
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1393
+ }
1394
+ });
1395
+ }
1396
+ function _render() {
1397
+ try {
1398
+ this.is_pending = this.has_pending_snippet();
1399
+ _classPrivateFieldSet2(_pending_count, this, 0);
1400
+ _classPrivateFieldSet2(_local_pending_count, this, 0);
1401
+ _classPrivateFieldSet2(_main_effect, this, branch(() => {
1402
+ _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
1403
+ }));
1404
+ if (_classPrivateFieldGet2(_pending_count, this) > 0) {
1405
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1406
+ move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
1407
+ const pending = _classPrivateFieldGet2(_props, this).pending;
1408
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1409
+ } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1410
+ } catch (error) {
1411
+ this.error(error);
1412
+ }
1413
+ }
1414
+ /**
1415
+ * @param {Batch} batch
1416
+ */
1417
+ function _resolve(batch) {
1418
+ this.is_pending = false;
1419
+ batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1420
+ }
1421
+ /**
1422
+ * @template T
1423
+ * @param {() => T} fn
1424
+ */
1425
+ function _run(fn) {
1426
+ var previous_effect = active_effect;
1427
+ var previous_reaction = active_reaction;
1428
+ var previous_ctx = component_context;
1429
+ set_active_effect(_classPrivateFieldGet2(_effect, this));
1430
+ set_active_reaction(_classPrivateFieldGet2(_effect, this));
1431
+ set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
1432
+ try {
1433
+ Batch.ensure();
1434
+ return fn();
1435
+ } catch (e) {
1436
+ handle_error(e);
1437
+ return null;
1438
+ } finally {
1439
+ set_active_effect(previous_effect);
1440
+ set_active_reaction(previous_reaction);
1441
+ set_component_context(previous_ctx);
1442
+ }
1443
+ }
1444
+ /**
1445
+ * Updates the pending count associated with the currently visible pending snippet,
1446
+ * if any, such that we can replace the snippet with content once work is done
1447
+ * @param {1 | -1} d
1448
+ * @param {Batch} batch
1449
+ */
1450
+ function _update_pending_count(d, batch) {
1451
+ if (!this.has_pending_snippet()) {
1452
+ if (this.parent) {
1453
+ var _this$parent;
1454
+ _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
1455
+ }
1456
+ return;
1457
+ }
1458
+ _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
1459
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1460
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
1461
+ if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1462
+ _classPrivateFieldSet2(_pending_effect, this, null);
1463
+ });
1464
+ if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
1465
+ _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
1466
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
1467
+ }
1468
+ }
1469
+ }
1470
+ //#endregion
1471
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/async.js
1472
+ /** @import { Blocker, Effect, Value } from '#client' */
1473
+ /**
1474
+ * @param {Blocker[]} blockers
1475
+ * @param {Array<() => any>} sync
1476
+ * @param {Array<() => Promise<any>>} async
1477
+ * @param {(values: Value[]) => any} fn
1478
+ */
1479
+ function flatten(blockers, sync, async, fn) {
1480
+ const d = is_runes() ? derived : derived_safe_equal;
1481
+ var pending = blockers.filter((b) => !b.settled);
1482
+ if (async.length === 0 && pending.length === 0) {
1483
+ fn(sync.map(d));
1484
+ return;
1485
+ }
1486
+ var parent = active_effect;
1487
+ var restore = capture();
1488
+ var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
1489
+ /** @param {Value[]} values */
1490
+ function finish(values) {
1491
+ restore();
1492
+ try {
1493
+ fn(values);
1494
+ } catch (error) {
1495
+ if ((parent.f & 16384) === 0) invoke_error_boundary(error, parent);
1496
+ }
1497
+ unset_context();
1498
+ }
1499
+ if (async.length === 0) {
1500
+ /** @type {Promise<any>} */ blocker_promise.then(() => finish(sync.map(d)));
1501
+ return;
1502
+ }
1503
+ var decrement_pending = increment_pending();
1504
+ function run() {
1505
+ Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then((result) => finish([...sync.map(d), ...result])).catch((error) => invoke_error_boundary(error, parent)).finally(() => decrement_pending());
1506
+ }
1507
+ if (blocker_promise) blocker_promise.then(() => {
1508
+ restore();
1509
+ run();
1510
+ unset_context();
1511
+ });
1512
+ else run();
1513
+ }
1514
+ /**
1515
+ * Captures the current effect context so that we can restore it after
1516
+ * some asynchronous work has happened (so that e.g. `await a + b`
1517
+ * causes `b` to be registered as a dependency).
1518
+ */
1519
+ function capture() {
1520
+ var previous_effect = active_effect;
1521
+ var previous_reaction = active_reaction;
1522
+ var previous_component_context = component_context;
1523
+ var previous_batch = current_batch;
1524
+ return function restore(activate_batch = true) {
1525
+ set_active_effect(previous_effect);
1526
+ set_active_reaction(previous_reaction);
1527
+ set_component_context(previous_component_context);
1528
+ if (activate_batch && (previous_effect.f & 16384) === 0) {
1529
+ previous_batch?.activate();
1530
+ previous_batch?.apply();
1531
+ }
1532
+ };
1533
+ }
1534
+ function unset_context(deactivate_batch = true) {
1535
+ set_active_effect(null);
1536
+ set_active_reaction(null);
1537
+ set_component_context(null);
1538
+ if (deactivate_batch) current_batch?.deactivate();
1539
+ }
1540
+ /**
1541
+ * @returns {(skip?: boolean) => void}
1542
+ */
1543
+ function increment_pending() {
1544
+ var boundary = active_effect.b;
1545
+ var batch = current_batch;
1546
+ var blocking = boundary.is_rendered();
1547
+ boundary.update_pending_count(1, batch);
1548
+ batch.increment(blocking);
1549
+ return (skip = false) => {
1550
+ boundary.update_pending_count(-1, batch);
1551
+ batch.decrement(blocking, skip);
1552
+ };
1553
+ }
1554
+ /**
1555
+ * @template V
1556
+ * @param {() => V} fn
1557
+ * @returns {Derived<V>}
1558
+ */
1559
+ /* @__NO_SIDE_EFFECTS__ */
1560
+ function derived(fn) {
1561
+ var flags = 2 | DIRTY;
1562
+ var parent_derived = active_reaction !== null && (active_reaction.f & 2) !== 0 ? active_reaction : null;
1563
+ if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
1564
+ return {
1565
+ ctx: component_context,
1566
+ deps: null,
1567
+ effects: null,
1568
+ equals,
1569
+ f: flags,
1570
+ fn,
1571
+ reactions: null,
1572
+ rv: 0,
1573
+ v: UNINITIALIZED,
1574
+ wv: 0,
1575
+ parent: parent_derived ?? active_effect,
1576
+ ac: null
1577
+ };
1578
+ }
1579
+ /**
1580
+ * @template V
1581
+ * @param {() => V | Promise<V>} fn
1582
+ * @param {string} [label]
1583
+ * @param {string} [location] If provided, print a warning if the value is not read immediately after update
1584
+ * @returns {Promise<Source<V>>}
1585
+ */
1586
+ /* @__NO_SIDE_EFFECTS__ */
1587
+ function async_derived(fn, label, location) {
1588
+ let parent = active_effect;
1589
+ if (parent === null) async_derived_orphan();
1590
+ var promise = void 0;
1591
+ var signal = source(UNINITIALIZED);
1592
+ var should_suspend = !active_reaction;
1593
+ /** @type {Map<Batch, ReturnType<typeof deferred<V>>>} */
1594
+ var deferreds = /* @__PURE__ */ new Map();
1595
+ async_effect(() => {
1596
+ var effect = active_effect;
1597
+ /** @type {ReturnType<typeof deferred<V>>} */
1598
+ var d = deferred();
1599
+ promise = d.promise;
1600
+ try {
1601
+ Promise.resolve(fn()).then(d.resolve, d.reject).finally(unset_context);
1602
+ } catch (error) {
1603
+ d.reject(error);
1604
+ unset_context();
1605
+ }
1606
+ var batch = current_batch;
1607
+ if (should_suspend) {
1608
+ if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
1609
+ if (parent.b.is_rendered()) {
1610
+ deferreds.get(batch)?.reject(STALE_REACTION);
1611
+ deferreds.delete(batch);
1612
+ } else {
1613
+ for (const d of deferreds.values()) d.reject(STALE_REACTION);
1614
+ deferreds.clear();
1615
+ }
1616
+ deferreds.set(batch, d);
1617
+ }
1618
+ /**
1619
+ * @param {any} value
1620
+ * @param {unknown} error
1621
+ */
1622
+ const handler = (value, error = void 0) => {
1623
+ if (decrement_pending) decrement_pending(error === STALE_REACTION);
1624
+ if (error === STALE_REACTION || (effect.f & 16384) !== 0) return;
1625
+ batch.activate();
1626
+ if (error) {
1627
+ signal.f |= ERROR_VALUE;
1628
+ internal_set(signal, error);
1629
+ } else {
1630
+ if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
1631
+ internal_set(signal, value);
1632
+ for (const [b, d] of deferreds) {
1633
+ deferreds.delete(b);
1634
+ if (b === batch) break;
1635
+ d.reject(STALE_REACTION);
1636
+ }
1637
+ }
1638
+ batch.deactivate();
1639
+ };
1640
+ d.promise.then(handler, (e) => handler(null, e || "unknown"));
1641
+ });
1642
+ teardown(() => {
1643
+ for (const d of deferreds.values()) d.reject(STALE_REACTION);
1644
+ });
1645
+ return new Promise((fulfil) => {
1646
+ /** @param {Promise<V>} p */
1647
+ function next(p) {
1648
+ function go() {
1649
+ if (p === promise) fulfil(signal);
1650
+ else next(promise);
1651
+ }
1652
+ p.then(go, go);
1653
+ }
1654
+ next(promise);
1655
+ });
1656
+ }
1657
+ /**
1658
+ * @template V
1659
+ * @param {() => V} fn
1660
+ * @returns {Derived<V>}
1661
+ */
1662
+ /* @__NO_SIDE_EFFECTS__ */
1663
+ function user_derived(fn) {
1664
+ const d = /* @__PURE__ */ derived(fn);
1665
+ if (!async_mode_flag) push_reaction_value(d);
1666
+ return d;
1667
+ }
1668
+ /**
1669
+ * @template V
1670
+ * @param {() => V} fn
1671
+ * @returns {Derived<V>}
1672
+ */
1673
+ /* @__NO_SIDE_EFFECTS__ */
1674
+ function derived_safe_equal(fn) {
1675
+ const signal = /* @__PURE__ */ derived(fn);
1676
+ signal.equals = safe_equals;
1677
+ return signal;
1678
+ }
1679
+ /**
1680
+ * @param {Derived} derived
1681
+ * @returns {void}
1682
+ */
1683
+ function destroy_derived_effects(derived) {
1684
+ var effects = derived.effects;
1685
+ if (effects !== null) {
1686
+ derived.effects = null;
1687
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1688
+ }
1689
+ }
1690
+ /**
1691
+ * @param {Derived} derived
1692
+ * @returns {Effect | null}
1693
+ */
1694
+ function get_derived_parent_effect(derived) {
1695
+ var parent = derived.parent;
1696
+ while (parent !== null) {
1697
+ if ((parent.f & 2) === 0) return (parent.f & 16384) === 0 ? parent : null;
1698
+ parent = parent.parent;
1699
+ }
1700
+ return null;
1701
+ }
1702
+ /**
1703
+ * @template T
1704
+ * @param {Derived} derived
1705
+ * @returns {T}
1706
+ */
1707
+ function execute_derived(derived) {
1708
+ var value;
1709
+ var prev_active_effect = active_effect;
1710
+ set_active_effect(get_derived_parent_effect(derived));
1711
+ try {
1712
+ derived.f &= ~WAS_MARKED;
1713
+ destroy_derived_effects(derived);
1714
+ value = update_reaction(derived);
1715
+ } finally {
1716
+ set_active_effect(prev_active_effect);
1717
+ }
1718
+ return value;
1719
+ }
1720
+ /**
1721
+ * @param {Derived} derived
1722
+ * @returns {void}
1723
+ */
1724
+ function update_derived(derived) {
1725
+ var old_value = derived.v;
1726
+ var value = execute_derived(derived);
1727
+ if (!derived.equals(value)) {
1728
+ derived.wv = increment_write_version();
1729
+ if (!current_batch?.is_fork || derived.deps === null) {
1730
+ derived.v = value;
1731
+ current_batch?.capture(derived, old_value);
1732
+ if (derived.deps === null) {
1733
+ set_signal_status(derived, CLEAN);
1734
+ return;
1735
+ }
1736
+ }
1737
+ }
1738
+ if (is_destroying_effect) return;
1739
+ if (batch_values !== null) {
1740
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1741
+ } else update_derived_status(derived);
1742
+ }
1743
+ /**
1744
+ * @param {Derived} derived
1745
+ */
1746
+ function freeze_derived_effects(derived) {
1747
+ if (derived.effects === null) return;
1748
+ for (const e of derived.effects) if (e.teardown || e.ac) {
1749
+ e.teardown?.();
1750
+ e.ac?.abort(STALE_REACTION);
1751
+ e.teardown = noop;
1752
+ e.ac = null;
1753
+ remove_reactions(e, 0);
1754
+ destroy_effect_children(e);
1755
+ }
1756
+ }
1757
+ /**
1758
+ * @param {Derived} derived
1759
+ */
1760
+ function unfreeze_derived_effects(derived) {
1761
+ if (derived.effects === null) return;
1762
+ for (const e of derived.effects) if (e.teardown) update_effect(e);
1763
+ }
1764
+ //#endregion
1765
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/sources.js
1766
+ /** @import { Derived, Effect, Source, Value } from '#client' */
1767
+ /** @type {Set<any>} */
1768
+ var eager_effects = /* @__PURE__ */ new Set();
1769
+ /** @type {Map<Source, any>} */
1770
+ var old_values = /* @__PURE__ */ new Map();
1771
+ var eager_effects_deferred = false;
1772
+ /**
1773
+ * @template V
1774
+ * @param {V} v
1775
+ * @param {Error | null} [stack]
1776
+ * @returns {Source<V>}
1777
+ */
1778
+ function source(v, stack) {
1779
+ return {
1780
+ f: 0,
1781
+ v,
1782
+ reactions: null,
1783
+ equals,
1784
+ rv: 0,
1785
+ wv: 0
1786
+ };
1787
+ }
1788
+ /**
1789
+ * @template V
1790
+ * @param {V} v
1791
+ * @param {Error | null} [stack]
1792
+ */
1793
+ /* @__NO_SIDE_EFFECTS__ */
1794
+ function state(v, stack) {
1795
+ const s = source(v, stack);
1796
+ push_reaction_value(s);
1797
+ return s;
1798
+ }
1799
+ /**
1800
+ * @template V
1801
+ * @param {V} initial_value
1802
+ * @param {boolean} [immutable]
1803
+ * @returns {Source<V>}
1804
+ */
1805
+ /* @__NO_SIDE_EFFECTS__ */
1806
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1807
+ const s = source(initial_value);
1808
+ if (!immutable) s.equals = safe_equals;
1809
+ if (legacy_mode_flag && trackable && component_context !== null && component_context.l !== null) {
1810
+ var _component_context$l;
1811
+ ((_component_context$l = component_context.l).s ?? (_component_context$l.s = [])).push(s);
1812
+ }
1813
+ return s;
1814
+ }
1815
+ /**
1816
+ * @template V
1817
+ * @param {Source<V>} source
1818
+ * @param {V} value
1819
+ * @param {boolean} [should_proxy]
1820
+ * @returns {V}
1821
+ */
1822
+ function set(source, value, should_proxy = false) {
1823
+ if (active_reaction !== null && (!untracking || (active_reaction.f & 131072) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !includes.call(current_sources, source))) state_unsafe_mutation();
1824
+ return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
1825
+ }
1826
+ /**
1827
+ * @template V
1828
+ * @param {Source<V>} source
1829
+ * @param {V} value
1830
+ * @param {Effect[] | null} [updated_during_traversal]
1831
+ * @returns {V}
1832
+ */
1833
+ function internal_set(source, value, updated_during_traversal = null) {
1834
+ if (!source.equals(value)) {
1835
+ var old_value = source.v;
1836
+ if (is_destroying_effect) old_values.set(source, value);
1837
+ else old_values.set(source, old_value);
1838
+ source.v = value;
1839
+ var batch = Batch.ensure();
1840
+ batch.capture(source, old_value);
1841
+ if ((source.f & 2) !== 0) {
1842
+ const derived = source;
1843
+ if ((source.f & 2048) !== 0) execute_derived(derived);
1844
+ if (batch_values === null) update_derived_status(derived);
1845
+ }
1846
+ source.wv = increment_write_version();
1847
+ mark_reactions(source, DIRTY, updated_during_traversal);
1848
+ if (is_runes() && active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) if (untracked_writes === null) set_untracked_writes([source]);
1849
+ else untracked_writes.push(source);
1850
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
1851
+ }
1852
+ return value;
1853
+ }
1854
+ function flush_eager_effects() {
1855
+ eager_effects_deferred = false;
1856
+ for (const effect of eager_effects) {
1857
+ if ((effect.f & 1024) !== 0) set_signal_status(effect, MAYBE_DIRTY);
1858
+ if (is_dirty(effect)) update_effect(effect);
1859
+ }
1860
+ eager_effects.clear();
1861
+ }
1862
+ /**
1863
+ * Silently (without using `get`) increment a source
1864
+ * @param {Source<number>} source
1865
+ */
1866
+ function increment(source) {
1867
+ set(source, source.v + 1);
1868
+ }
1869
+ /**
1870
+ * @param {Value} signal
1871
+ * @param {number} status should be DIRTY or MAYBE_DIRTY
1872
+ * @param {Effect[] | null} updated_during_traversal
1873
+ * @returns {void}
1874
+ */
1875
+ function mark_reactions(signal, status, updated_during_traversal) {
1876
+ var reactions = signal.reactions;
1877
+ if (reactions === null) return;
1878
+ var runes = is_runes();
1879
+ var length = reactions.length;
1880
+ for (var i = 0; i < length; i++) {
1881
+ var reaction = reactions[i];
1882
+ var flags = reaction.f;
1883
+ if (!runes && reaction === active_effect) continue;
1884
+ var not_dirty = (flags & DIRTY) === 0;
1885
+ if (not_dirty) set_signal_status(reaction, status);
1886
+ if ((flags & 2) !== 0) {
1887
+ var derived = reaction;
1888
+ batch_values?.delete(derived);
1889
+ if ((flags & 65536) === 0) {
1890
+ if (flags & 512) reaction.f |= WAS_MARKED;
1891
+ mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
1892
+ }
1893
+ } else if (not_dirty) {
1894
+ var effect = reaction;
1895
+ if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
1896
+ if (updated_during_traversal !== null) updated_during_traversal.push(effect);
1897
+ else schedule_effect(effect);
1898
+ }
1899
+ }
1900
+ }
1901
+ /**
1902
+ * @template T
1903
+ * @param {T} value
1904
+ * @returns {T}
1905
+ */
1906
+ function proxy(value) {
1907
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
1908
+ const prototype = get_prototype_of(value);
1909
+ if (prototype !== object_prototype && prototype !== array_prototype) return value;
1910
+ /** @type {Map<any, Source<any>>} */
1911
+ var sources = /* @__PURE__ */ new Map();
1912
+ var is_proxied_array = is_array(value);
1913
+ var version = /* @__PURE__ */ state(0);
1914
+ var stack = null;
1915
+ var parent_version = update_version;
1916
+ /**
1917
+ * Executes the proxy in the context of the reaction it was originally created in, if any
1918
+ * @template T
1919
+ * @param {() => T} fn
1920
+ */
1921
+ var with_parent = (fn) => {
1922
+ if (update_version === parent_version) return fn();
1923
+ var reaction = active_reaction;
1924
+ var version = update_version;
1925
+ set_active_reaction(null);
1926
+ set_update_version(parent_version);
1927
+ var result = fn();
1928
+ set_active_reaction(reaction);
1929
+ set_update_version(version);
1930
+ return result;
1931
+ };
1932
+ if (is_proxied_array) sources.set("length", /* @__PURE__ */ state(
1933
+ /** @type {any[]} */
1934
+ value.length,
1935
+ stack
1936
+ ));
1937
+ return new Proxy(value, {
1938
+ defineProperty(_, prop, descriptor) {
1939
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) state_descriptors_fixed();
1940
+ var s = sources.get(prop);
1941
+ if (s === void 0) with_parent(() => {
1942
+ var s = /* @__PURE__ */ state(descriptor.value, stack);
1943
+ sources.set(prop, s);
1944
+ return s;
1945
+ });
1946
+ else set(s, descriptor.value, true);
1947
+ return true;
1948
+ },
1949
+ deleteProperty(target, prop) {
1950
+ var s = sources.get(prop);
1951
+ if (s === void 0) {
1952
+ if (prop in target) {
1953
+ const s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
1954
+ sources.set(prop, s);
1955
+ increment(version);
1956
+ }
1957
+ } else {
1958
+ set(s, UNINITIALIZED);
1959
+ increment(version);
1960
+ }
1961
+ return true;
1962
+ },
1963
+ get(target, prop, receiver) {
1964
+ if (prop === STATE_SYMBOL) return value;
1965
+ var s = sources.get(prop);
1966
+ var exists = prop in target;
1967
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1968
+ s = with_parent(() => {
1969
+ return /* @__PURE__ */ state(proxy(exists ? target[prop] : UNINITIALIZED), stack);
1970
+ });
1971
+ sources.set(prop, s);
1972
+ }
1973
+ if (s !== void 0) {
1974
+ var v = get(s);
1975
+ return v === UNINITIALIZED ? void 0 : v;
1976
+ }
1977
+ return Reflect.get(target, prop, receiver);
1978
+ },
1979
+ getOwnPropertyDescriptor(target, prop) {
1980
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1981
+ if (descriptor && "value" in descriptor) {
1982
+ var s = sources.get(prop);
1983
+ if (s) descriptor.value = get(s);
1984
+ } else if (descriptor === void 0) {
1985
+ var source = sources.get(prop);
1986
+ var value = source?.v;
1987
+ if (source !== void 0 && value !== UNINITIALIZED) return {
1988
+ enumerable: true,
1989
+ configurable: true,
1990
+ value,
1991
+ writable: true
1992
+ };
1993
+ }
1994
+ return descriptor;
1995
+ },
1996
+ has(target, prop) {
1997
+ if (prop === STATE_SYMBOL) return true;
1998
+ var s = sources.get(prop);
1999
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
2000
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
2001
+ if (s === void 0) {
2002
+ s = with_parent(() => {
2003
+ return /* @__PURE__ */ state(has ? proxy(target[prop]) : UNINITIALIZED, stack);
2004
+ });
2005
+ sources.set(prop, s);
2006
+ }
2007
+ if (get(s) === UNINITIALIZED) return false;
2008
+ }
2009
+ return has;
2010
+ },
2011
+ set(target, prop, value, receiver) {
2012
+ var s = sources.get(prop);
2013
+ var has = prop in target;
2014
+ if (is_proxied_array && prop === "length") for (var i = value; i < s.v; i += 1) {
2015
+ var other_s = sources.get(i + "");
2016
+ if (other_s !== void 0) set(other_s, UNINITIALIZED);
2017
+ else if (i in target) {
2018
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
2019
+ sources.set(i + "", other_s);
2020
+ }
2021
+ }
2022
+ if (s === void 0) {
2023
+ if (!has || get_descriptor(target, prop)?.writable) {
2024
+ s = with_parent(() => /* @__PURE__ */ state(void 0, stack));
2025
+ set(s, proxy(value));
2026
+ sources.set(prop, s);
2027
+ }
2028
+ } else {
2029
+ has = s.v !== UNINITIALIZED;
2030
+ var p = with_parent(() => proxy(value));
2031
+ set(s, p);
2032
+ }
2033
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
2034
+ if (descriptor?.set) descriptor.set.call(receiver, value);
2035
+ if (!has) {
2036
+ if (is_proxied_array && typeof prop === "string") {
2037
+ var ls = sources.get("length");
2038
+ var n = Number(prop);
2039
+ if (Number.isInteger(n) && n >= ls.v) set(ls, n + 1);
2040
+ }
2041
+ increment(version);
2042
+ }
2043
+ return true;
2044
+ },
2045
+ ownKeys(target) {
2046
+ get(version);
2047
+ var own_keys = Reflect.ownKeys(target).filter((key) => {
2048
+ var source = sources.get(key);
2049
+ return source === void 0 || source.v !== UNINITIALIZED;
2050
+ });
2051
+ for (var [key, source] of sources) if (source.v !== UNINITIALIZED && !(key in target)) own_keys.push(key);
2052
+ return own_keys;
2053
+ },
2054
+ setPrototypeOf() {
2055
+ state_prototype_fixed();
2056
+ }
2057
+ });
2058
+ }
2059
+ //#endregion
2060
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/operations.js
2061
+ /** @import { Effect, TemplateNode } from '#client' */
2062
+ /** @type {Window} */
2063
+ var $window;
2064
+ /** @type {boolean} */
2065
+ var is_firefox;
2066
+ /** @type {() => Node | null} */
2067
+ var first_child_getter;
2068
+ /** @type {() => Node | null} */
2069
+ var next_sibling_getter;
2070
+ /**
2071
+ * Initialize these lazily to avoid issues when using the runtime in a server context
2072
+ * where these globals are not available while avoiding a separate server entry point
2073
+ */
2074
+ function init_operations() {
2075
+ if ($window !== void 0) return;
2076
+ $window = window;
2077
+ is_firefox = /Firefox/.test(navigator.userAgent);
2078
+ var element_prototype = Element.prototype;
2079
+ var node_prototype = Node.prototype;
2080
+ var text_prototype = Text.prototype;
2081
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
2082
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
2083
+ if (is_extensible(element_prototype)) {
2084
+ element_prototype.__click = void 0;
2085
+ element_prototype.__className = void 0;
2086
+ element_prototype.__attributes = null;
2087
+ element_prototype.__style = void 0;
2088
+ element_prototype.__e = void 0;
2089
+ }
2090
+ if (is_extensible(text_prototype)) text_prototype.__t = void 0;
2091
+ }
2092
+ /**
2093
+ * @param {string} value
2094
+ * @returns {Text}
2095
+ */
2096
+ function create_text(value = "") {
2097
+ return document.createTextNode(value);
2098
+ }
2099
+ /**
2100
+ * @template {Node} N
2101
+ * @param {N} node
2102
+ */
2103
+ /* @__NO_SIDE_EFFECTS__ */
2104
+ function get_first_child(node) {
2105
+ return first_child_getter.call(node);
2106
+ }
2107
+ /**
2108
+ * @template {Node} N
2109
+ * @param {N} node
2110
+ */
2111
+ /* @__NO_SIDE_EFFECTS__ */
2112
+ function get_next_sibling(node) {
2113
+ return next_sibling_getter.call(node);
2114
+ }
2115
+ /**
2116
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
2117
+ * @template {Node} N
2118
+ * @param {N} node
2119
+ * @param {boolean} is_text
2120
+ * @returns {TemplateNode | null}
2121
+ */
2122
+ function child(node, is_text) {
2123
+ if (!hydrating) return /* @__PURE__ */ get_first_child(node);
2124
+ var child = /* @__PURE__ */ get_first_child(hydrate_node);
2125
+ if (child === null) child = hydrate_node.appendChild(create_text());
2126
+ else if (is_text && child.nodeType !== 3) {
2127
+ var text = create_text();
2128
+ child?.before(text);
2129
+ set_hydrate_node(text);
2130
+ return text;
2131
+ }
2132
+ if (is_text) merge_text_nodes(child);
2133
+ set_hydrate_node(child);
2134
+ return child;
2135
+ }
2136
+ /**
2137
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
2138
+ * @param {TemplateNode} node
2139
+ * @param {number} count
2140
+ * @param {boolean} is_text
2141
+ * @returns {TemplateNode | null}
2142
+ */
2143
+ function sibling(node, count = 1, is_text = false) {
2144
+ let next_sibling = hydrating ? hydrate_node : node;
2145
+ var last_sibling;
2146
+ while (count--) {
2147
+ last_sibling = next_sibling;
2148
+ next_sibling = /* @__PURE__ */ get_next_sibling(next_sibling);
2149
+ }
2150
+ if (!hydrating) return next_sibling;
2151
+ if (is_text) {
2152
+ if (next_sibling?.nodeType !== 3) {
2153
+ var text = create_text();
2154
+ if (next_sibling === null) last_sibling?.after(text);
2155
+ else next_sibling.before(text);
2156
+ set_hydrate_node(text);
2157
+ return text;
2158
+ }
2159
+ merge_text_nodes(next_sibling);
2160
+ }
2161
+ set_hydrate_node(next_sibling);
2162
+ return next_sibling;
2163
+ }
2164
+ /**
2165
+ * @template {Node} N
2166
+ * @param {N} node
2167
+ * @returns {void}
2168
+ */
2169
+ function clear_text_content(node) {
2170
+ node.textContent = "";
2171
+ }
2172
+ /**
2173
+ * Returns `true` if we're updating the current block, for example `condition` in
2174
+ * an `{#if condition}` block just changed. In this case, the branch should be
2175
+ * appended (or removed) at the same time as other updates within the
2176
+ * current `<svelte:boundary>`
2177
+ */
2178
+ function should_defer_append() {
2179
+ if (!async_mode_flag) return false;
2180
+ if (eager_block_effects !== null) return false;
2181
+ return (active_effect.f & REACTION_RAN) !== 0;
2182
+ }
2183
+ /**
2184
+ * @template {keyof HTMLElementTagNameMap | string} T
2185
+ * @param {T} tag
2186
+ * @param {string} [namespace]
2187
+ * @param {string} [is]
2188
+ * @returns {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element}
2189
+ */
2190
+ function create_element(tag, namespace, is) {
2191
+ let options = is ? { is } : void 0;
2192
+ return document.createElementNS(namespace ?? "http://www.w3.org/1999/xhtml", tag, options);
2193
+ }
2194
+ /**
2195
+ * Browsers split text nodes larger than 65536 bytes when parsing.
2196
+ * For hydration to succeed, we need to stitch them back together
2197
+ * @param {Text} text
2198
+ */
2199
+ function merge_text_nodes(text) {
2200
+ if (text.nodeValue.length < 65536) return;
2201
+ let next = text.nextSibling;
2202
+ while (next !== null && next.nodeType === 3) {
2203
+ next.remove();
2204
+ /** @type {string} */ text.nodeValue += next.nodeValue;
2205
+ next = text.nextSibling;
2206
+ }
2207
+ }
2208
+ //#endregion
2209
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
2210
+ /**
2211
+ * @template T
2212
+ * @param {() => T} fn
2213
+ */
2214
+ function without_reactive_context(fn) {
2215
+ var previous_reaction = active_reaction;
2216
+ var previous_effect = active_effect;
2217
+ set_active_reaction(null);
2218
+ set_active_effect(null);
2219
+ try {
2220
+ return fn();
2221
+ } finally {
2222
+ set_active_reaction(previous_reaction);
2223
+ set_active_effect(previous_effect);
2224
+ }
2225
+ }
2226
+ //#endregion
2227
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/effects.js
2228
+ /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2229
+ /**
2230
+ * @param {'$effect' | '$effect.pre' | '$inspect'} rune
2231
+ */
2232
+ function validate_effect(rune) {
2233
+ if (active_effect === null) {
2234
+ if (active_reaction === null) effect_orphan(rune);
2235
+ effect_in_unowned_derived();
2236
+ }
2237
+ if (is_destroying_effect) effect_in_teardown(rune);
2238
+ }
2239
+ /**
2240
+ * @param {Effect} effect
2241
+ * @param {Effect} parent_effect
2242
+ */
2243
+ function push_effect(effect, parent_effect) {
2244
+ var parent_last = parent_effect.last;
2245
+ if (parent_last === null) parent_effect.last = parent_effect.first = effect;
2246
+ else {
2247
+ parent_last.next = effect;
2248
+ effect.prev = parent_last;
2249
+ parent_effect.last = effect;
2250
+ }
2251
+ }
2252
+ /**
2253
+ * @param {number} type
2254
+ * @param {null | (() => void | (() => void))} fn
2255
+ * @returns {Effect}
2256
+ */
2257
+ function create_effect(type, fn) {
2258
+ var parent = active_effect;
2259
+ if (parent !== null && (parent.f & 8192) !== 0) type |= INERT;
2260
+ /** @type {Effect} */
2261
+ var effect = {
2262
+ ctx: component_context,
2263
+ deps: null,
2264
+ nodes: null,
2265
+ f: type | DIRTY | 512,
2266
+ first: null,
2267
+ fn,
2268
+ last: null,
2269
+ next: null,
2270
+ parent,
2271
+ b: parent && parent.b,
2272
+ prev: null,
2273
+ teardown: null,
2274
+ wv: 0,
2275
+ ac: null
2276
+ };
2277
+ /** @type {Effect | null} */
2278
+ var e = effect;
2279
+ if ((type & 4) !== 0) if (collected_effects !== null) collected_effects.push(effect);
2280
+ else Batch.ensure().schedule(effect);
2281
+ else if (fn !== null) {
2282
+ try {
2283
+ update_effect(effect);
2284
+ } catch (e) {
2285
+ destroy_effect(effect);
2286
+ throw e;
2287
+ }
2288
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && (e.f & 524288) === 0) {
2289
+ e = e.first;
2290
+ if ((type & 16) !== 0 && (type & 65536) !== 0 && e !== null) e.f |= EFFECT_TRANSPARENT;
2291
+ }
2292
+ }
2293
+ if (e !== null) {
2294
+ e.parent = parent;
2295
+ if (parent !== null) push_effect(e, parent);
2296
+ if (active_reaction !== null && (active_reaction.f & 2) !== 0 && (type & 64) === 0) {
2297
+ var derived = active_reaction;
2298
+ (derived.effects ?? (derived.effects = [])).push(e);
2299
+ }
2300
+ }
2301
+ return effect;
2302
+ }
2303
+ /**
2304
+ * Internal representation of `$effect.tracking()`
2305
+ * @returns {boolean}
2306
+ */
2307
+ function effect_tracking() {
2308
+ return active_reaction !== null && !untracking;
2309
+ }
2310
+ /**
2311
+ * @param {() => void} fn
2312
+ */
2313
+ function teardown(fn) {
2314
+ const effect = create_effect(8, null);
2315
+ set_signal_status(effect, CLEAN);
2316
+ effect.teardown = fn;
2317
+ return effect;
2318
+ }
2319
+ /**
2320
+ * Internal representation of `$effect(...)`
2321
+ * @param {() => void | (() => void)} fn
2322
+ */
2323
+ function user_effect(fn) {
2324
+ validate_effect("$effect");
2325
+ var flags = active_effect.f;
2326
+ if (!active_reaction && (flags & 32) !== 0 && (flags & 32768) === 0) {
2327
+ var context = component_context;
2328
+ (context.e ?? (context.e = [])).push(fn);
2329
+ } else return create_user_effect(fn);
2330
+ }
2331
+ /**
2332
+ * @param {() => void | (() => void)} fn
2333
+ */
2334
+ function create_user_effect(fn) {
2335
+ return create_effect(4 | USER_EFFECT, fn);
2336
+ }
2337
+ /**
2338
+ * Internal representation of `$effect.root(...)`
2339
+ * @param {() => void | (() => void)} fn
2340
+ * @returns {() => void}
2341
+ */
2342
+ function effect_root(fn) {
2343
+ Batch.ensure();
2344
+ const effect = create_effect(64 | EFFECT_PRESERVED, fn);
2345
+ return () => {
2346
+ destroy_effect(effect);
2347
+ };
2348
+ }
2349
+ /**
2350
+ * An effect root whose children can transition out
2351
+ * @param {() => void} fn
2352
+ * @returns {(options?: { outro?: boolean }) => Promise<void>}
2353
+ */
2354
+ function component_root(fn) {
2355
+ Batch.ensure();
2356
+ const effect = create_effect(64 | EFFECT_PRESERVED, fn);
2357
+ return (options = {}) => {
2358
+ return new Promise((fulfil) => {
2359
+ if (options.outro) pause_effect(effect, () => {
2360
+ destroy_effect(effect);
2361
+ fulfil(void 0);
2362
+ });
2363
+ else {
2364
+ destroy_effect(effect);
2365
+ fulfil(void 0);
2366
+ }
2367
+ });
2368
+ };
2369
+ }
2370
+ /**
2371
+ * @param {() => void | (() => void)} fn
2372
+ * @returns {Effect}
2373
+ */
2374
+ function effect(fn) {
2375
+ return create_effect(4, fn);
2376
+ }
2377
+ /**
2378
+ * @param {() => void | (() => void)} fn
2379
+ * @returns {Effect}
2380
+ */
2381
+ function async_effect(fn) {
2382
+ return create_effect(ASYNC | EFFECT_PRESERVED, fn);
2383
+ }
2384
+ /**
2385
+ * @param {() => void | (() => void)} fn
2386
+ * @returns {Effect}
2387
+ */
2388
+ function render_effect(fn, flags = 0) {
2389
+ return create_effect(8 | flags, fn);
2390
+ }
2391
+ /**
2392
+ * @param {(...expressions: any) => void | (() => void)} fn
2393
+ * @param {Array<() => any>} sync
2394
+ * @param {Array<() => Promise<any>>} async
2395
+ * @param {Blocker[]} blockers
2396
+ */
2397
+ function template_effect(fn, sync = [], async = [], blockers = []) {
2398
+ flatten(blockers, sync, async, (values) => {
2399
+ create_effect(8, () => fn(...values.map(get)));
2400
+ });
2401
+ }
2402
+ /**
2403
+ * @param {(() => void)} fn
2404
+ * @param {number} flags
2405
+ */
2406
+ function block(fn, flags = 0) {
2407
+ return create_effect(16 | flags, fn);
2408
+ }
2409
+ /**
2410
+ * @param {(() => void)} fn
2411
+ */
2412
+ function branch(fn) {
2413
+ return create_effect(32 | EFFECT_PRESERVED, fn);
2414
+ }
2415
+ /**
2416
+ * @param {Effect} effect
2417
+ */
2418
+ function execute_effect_teardown(effect) {
2419
+ var teardown = effect.teardown;
2420
+ if (teardown !== null) {
2421
+ const previously_destroying_effect = is_destroying_effect;
2422
+ const previous_reaction = active_reaction;
2423
+ set_is_destroying_effect(true);
2424
+ set_active_reaction(null);
2425
+ try {
2426
+ teardown.call(null);
2427
+ } finally {
2428
+ set_is_destroying_effect(previously_destroying_effect);
2429
+ set_active_reaction(previous_reaction);
2430
+ }
2431
+ }
2432
+ }
2433
+ /**
2434
+ * @param {Effect} signal
2435
+ * @param {boolean} remove_dom
2436
+ * @returns {void}
2437
+ */
2438
+ function destroy_effect_children(signal, remove_dom = false) {
2439
+ var effect = signal.first;
2440
+ signal.first = signal.last = null;
2441
+ while (effect !== null) {
2442
+ const controller = effect.ac;
2443
+ if (controller !== null) without_reactive_context(() => {
2444
+ controller.abort(STALE_REACTION);
2445
+ });
2446
+ var next = effect.next;
2447
+ if ((effect.f & 64) !== 0) effect.parent = null;
2448
+ else destroy_effect(effect, remove_dom);
2449
+ effect = next;
2450
+ }
2451
+ }
2452
+ /**
2453
+ * @param {Effect} signal
2454
+ * @returns {void}
2455
+ */
2456
+ function destroy_block_effect_children(signal) {
2457
+ var effect = signal.first;
2458
+ while (effect !== null) {
2459
+ var next = effect.next;
2460
+ if ((effect.f & 32) === 0) destroy_effect(effect);
2461
+ effect = next;
2462
+ }
2463
+ }
2464
+ /**
2465
+ * @param {Effect} effect
2466
+ * @param {boolean} [remove_dom]
2467
+ * @returns {void}
2468
+ */
2469
+ function destroy_effect(effect, remove_dom = true) {
2470
+ var removed = false;
2471
+ if ((remove_dom || (effect.f & 262144) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
2472
+ remove_effect_dom(effect.nodes.start, effect.nodes.end);
2473
+ removed = true;
2474
+ }
2475
+ set_signal_status(effect, DESTROYING);
2476
+ destroy_effect_children(effect, remove_dom && !removed);
2477
+ remove_reactions(effect, 0);
2478
+ var transitions = effect.nodes && effect.nodes.t;
2479
+ if (transitions !== null) for (const transition of transitions) transition.stop();
2480
+ execute_effect_teardown(effect);
2481
+ effect.f ^= DESTROYING;
2482
+ effect.f |= DESTROYED;
2483
+ var parent = effect.parent;
2484
+ if (parent !== null && parent.first !== null) unlink_effect(effect);
2485
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = null;
2486
+ }
2487
+ /**
2488
+ *
2489
+ * @param {TemplateNode | null} node
2490
+ * @param {TemplateNode} end
2491
+ */
2492
+ function remove_effect_dom(node, end) {
2493
+ while (node !== null) {
2494
+ /** @type {TemplateNode | null} */
2495
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2496
+ node.remove();
2497
+ node = next;
2498
+ }
2499
+ }
2500
+ /**
2501
+ * Detach an effect from the effect tree, freeing up memory and
2502
+ * reducing the amount of work that happens on subsequent traversals
2503
+ * @param {Effect} effect
2504
+ */
2505
+ function unlink_effect(effect) {
2506
+ var parent = effect.parent;
2507
+ var prev = effect.prev;
2508
+ var next = effect.next;
2509
+ if (prev !== null) prev.next = next;
2510
+ if (next !== null) next.prev = prev;
2511
+ if (parent !== null) {
2512
+ if (parent.first === effect) parent.first = next;
2513
+ if (parent.last === effect) parent.last = prev;
2514
+ }
2515
+ }
2516
+ /**
2517
+ * When a block effect is removed, we don't immediately destroy it or yank it
2518
+ * out of the DOM, because it might have transitions. Instead, we 'pause' it.
2519
+ * It stays around (in memory, and in the DOM) until outro transitions have
2520
+ * completed, and if the state change is reversed then we _resume_ it.
2521
+ * A paused effect does not update, and the DOM subtree becomes inert.
2522
+ * @param {Effect} effect
2523
+ * @param {() => void} [callback]
2524
+ * @param {boolean} [destroy]
2525
+ */
2526
+ function pause_effect(effect, callback, destroy = true) {
2527
+ /** @type {TransitionManager[]} */
2528
+ var transitions = [];
2529
+ pause_children(effect, transitions, true);
2530
+ var fn = () => {
2531
+ if (destroy) destroy_effect(effect);
2532
+ if (callback) callback();
2533
+ };
2534
+ var remaining = transitions.length;
2535
+ if (remaining > 0) {
2536
+ var check = () => --remaining || fn();
2537
+ for (var transition of transitions) transition.out(check);
2538
+ } else fn();
2539
+ }
2540
+ /**
2541
+ * @param {Effect} effect
2542
+ * @param {TransitionManager[]} transitions
2543
+ * @param {boolean} local
2544
+ */
2545
+ function pause_children(effect, transitions, local) {
2546
+ if ((effect.f & 8192) !== 0) return;
2547
+ effect.f ^= INERT;
2548
+ var t = effect.nodes && effect.nodes.t;
2549
+ if (t !== null) {
2550
+ for (const transition of t) if (transition.is_global || local) transitions.push(transition);
2551
+ }
2552
+ var child = effect.first;
2553
+ while (child !== null) {
2554
+ var sibling = child.next;
2555
+ var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0 && (effect.f & 16) !== 0;
2556
+ pause_children(child, transitions, transparent ? local : false);
2557
+ child = sibling;
2558
+ }
2559
+ }
2560
+ /**
2561
+ * The opposite of `pause_effect`. We call this if (for example)
2562
+ * `x` becomes falsy then truthy: `{#if x}...{/if}`
2563
+ * @param {Effect} effect
2564
+ */
2565
+ function resume_effect(effect) {
2566
+ resume_children(effect, true);
2567
+ }
2568
+ /**
2569
+ * @param {Effect} effect
2570
+ * @param {boolean} local
2571
+ */
2572
+ function resume_children(effect, local) {
2573
+ if ((effect.f & 8192) === 0) return;
2574
+ effect.f ^= INERT;
2575
+ if ((effect.f & 1024) === 0) {
2576
+ set_signal_status(effect, DIRTY);
2577
+ Batch.ensure().schedule(effect);
2578
+ }
2579
+ var child = effect.first;
2580
+ while (child !== null) {
2581
+ var sibling = child.next;
2582
+ var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0;
2583
+ resume_children(child, transparent ? local : false);
2584
+ child = sibling;
2585
+ }
2586
+ var t = effect.nodes && effect.nodes.t;
2587
+ if (t !== null) {
2588
+ for (const transition of t) if (transition.is_global || local) transition.in();
2589
+ }
2590
+ }
2591
+ /**
2592
+ * @param {Effect} effect
2593
+ * @param {DocumentFragment} fragment
2594
+ */
2595
+ function move_effect(effect, fragment) {
2596
+ if (!effect.nodes) return;
2597
+ /** @type {TemplateNode | null} */
2598
+ var node = effect.nodes.start;
2599
+ var end = effect.nodes.end;
2600
+ while (node !== null) {
2601
+ /** @type {TemplateNode | null} */
2602
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2603
+ fragment.append(node);
2604
+ node = next;
2605
+ }
2606
+ }
2607
+ //#endregion
2608
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/legacy.js
2609
+ /**
2610
+ * @type {Set<Value> | null}
2611
+ * @deprecated
2612
+ */
2613
+ var captured_signals = null;
2614
+ //#endregion
2615
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/runtime.js
2616
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2617
+ var is_updating_effect = false;
2618
+ var is_destroying_effect = false;
2619
+ /** @param {boolean} value */
2620
+ function set_is_destroying_effect(value) {
2621
+ is_destroying_effect = value;
2622
+ }
2623
+ /** @type {null | Reaction} */
2624
+ var active_reaction = null;
2625
+ var untracking = false;
2626
+ /** @param {null | Reaction} reaction */
2627
+ function set_active_reaction(reaction) {
2628
+ active_reaction = reaction;
2629
+ }
2630
+ /** @type {null | Effect} */
2631
+ var active_effect = null;
2632
+ /** @param {null | Effect} effect */
2633
+ function set_active_effect(effect) {
2634
+ active_effect = effect;
2635
+ }
2636
+ /**
2637
+ * When sources are created within a reaction, reading and writing
2638
+ * them within that reaction should not cause a re-run
2639
+ * @type {null | Source[]}
2640
+ */
2641
+ var current_sources = null;
2642
+ /** @param {Value} value */
2643
+ function push_reaction_value(value) {
2644
+ if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) if (current_sources === null) current_sources = [value];
2645
+ else current_sources.push(value);
2646
+ }
2647
+ /**
2648
+ * The dependencies of the reaction that is currently being executed. In many cases,
2649
+ * the dependencies are unchanged between runs, and so this will be `null` unless
2650
+ * and until a new dependency is accessed — we track this via `skipped_deps`
2651
+ * @type {null | Value[]}
2652
+ */
2653
+ var new_deps = null;
2654
+ var skipped_deps = 0;
2655
+ /**
2656
+ * Tracks writes that the effect it's executed in doesn't listen to yet,
2657
+ * so that the dependency can be added to the effect later on if it then reads it
2658
+ * @type {null | Source[]}
2659
+ */
2660
+ var untracked_writes = null;
2661
+ /** @param {null | Source[]} value */
2662
+ function set_untracked_writes(value) {
2663
+ untracked_writes = value;
2664
+ }
2665
+ /**
2666
+ * @type {number} Used by sources and deriveds for handling updates.
2667
+ * Version starts from 1 so that unowned deriveds differentiate between a created effect and a run one for tracing
2668
+ **/
2669
+ var write_version = 1;
2670
+ /** @type {number} Used to version each read of a source of derived to avoid duplicating depedencies inside a reaction */
2671
+ var read_version = 0;
2672
+ var update_version = read_version;
2673
+ /** @param {number} value */
2674
+ function set_update_version(value) {
2675
+ update_version = value;
2676
+ }
2677
+ function increment_write_version() {
2678
+ return ++write_version;
2679
+ }
2680
+ /**
2681
+ * Determines whether a derived or effect is dirty.
2682
+ * If it is MAYBE_DIRTY, will set the status to CLEAN
2683
+ * @param {Reaction} reaction
2684
+ * @returns {boolean}
2685
+ */
2686
+ function is_dirty(reaction) {
2687
+ var flags = reaction.f;
2688
+ if ((flags & 2048) !== 0) return true;
2689
+ if (flags & 2) reaction.f &= ~WAS_MARKED;
2690
+ if ((flags & 4096) !== 0) {
2691
+ var dependencies = reaction.deps;
2692
+ var length = dependencies.length;
2693
+ for (var i = 0; i < length; i++) {
2694
+ var dependency = dependencies[i];
2695
+ if (is_dirty(dependency)) update_derived(dependency);
2696
+ if (dependency.wv > reaction.wv) return true;
2697
+ }
2698
+ if ((flags & 512) !== 0 && batch_values === null) set_signal_status(reaction, CLEAN);
2699
+ }
2700
+ return false;
2701
+ }
2702
+ /**
2703
+ * @param {Value} signal
2704
+ * @param {Effect} effect
2705
+ * @param {boolean} [root]
2706
+ */
2707
+ function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
2708
+ var reactions = signal.reactions;
2709
+ if (reactions === null) return;
2710
+ if (!async_mode_flag && current_sources !== null && includes.call(current_sources, signal)) return;
2711
+ for (var i = 0; i < reactions.length; i++) {
2712
+ var reaction = reactions[i];
2713
+ if ((reaction.f & 2) !== 0) schedule_possible_effect_self_invalidation(reaction, effect, false);
2714
+ else if (effect === reaction) {
2715
+ if (root) set_signal_status(reaction, DIRTY);
2716
+ else if ((reaction.f & 1024) !== 0) set_signal_status(reaction, MAYBE_DIRTY);
2717
+ schedule_effect(reaction);
2718
+ }
2719
+ }
2720
+ }
2721
+ /** @param {Reaction} reaction */
2722
+ function update_reaction(reaction) {
2723
+ var previous_deps = new_deps;
2724
+ var previous_skipped_deps = skipped_deps;
2725
+ var previous_untracked_writes = untracked_writes;
2726
+ var previous_reaction = active_reaction;
2727
+ var previous_sources = current_sources;
2728
+ var previous_component_context = component_context;
2729
+ var previous_untracking = untracking;
2730
+ var previous_update_version = update_version;
2731
+ var flags = reaction.f;
2732
+ new_deps = null;
2733
+ skipped_deps = 0;
2734
+ untracked_writes = null;
2735
+ active_reaction = (flags & 96) === 0 ? reaction : null;
2736
+ current_sources = null;
2737
+ set_component_context(reaction.ctx);
2738
+ untracking = false;
2739
+ update_version = ++read_version;
2740
+ if (reaction.ac !== null) {
2741
+ without_reactive_context(() => {
2742
+ /** @type {AbortController} */ reaction.ac.abort(STALE_REACTION);
2743
+ });
2744
+ reaction.ac = null;
2745
+ }
2746
+ try {
2747
+ reaction.f |= REACTION_IS_UPDATING;
2748
+ var fn = reaction.fn;
2749
+ var result = fn();
2750
+ reaction.f |= REACTION_RAN;
2751
+ var deps = reaction.deps;
2752
+ var is_fork = current_batch?.is_fork;
2753
+ if (new_deps !== null) {
2754
+ var i;
2755
+ if (!is_fork) remove_reactions(reaction, skipped_deps);
2756
+ if (deps !== null && skipped_deps > 0) {
2757
+ deps.length = skipped_deps + new_deps.length;
2758
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2759
+ } else reaction.deps = deps = new_deps;
2760
+ if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
2761
+ var _deps$i;
2762
+ ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
2763
+ }
2764
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2765
+ remove_reactions(reaction, skipped_deps);
2766
+ deps.length = skipped_deps;
2767
+ }
2768
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & 6146) === 0) for (i = 0; i < untracked_writes.length; i++) schedule_possible_effect_self_invalidation(untracked_writes[i], reaction);
2769
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2770
+ read_version++;
2771
+ if (previous_reaction.deps !== null) for (let i = 0; i < previous_skipped_deps; i += 1) previous_reaction.deps[i].rv = read_version;
2772
+ if (previous_deps !== null) for (const dep of previous_deps) dep.rv = read_version;
2773
+ if (untracked_writes !== null) if (previous_untracked_writes === null) previous_untracked_writes = untracked_writes;
2774
+ else previous_untracked_writes.push(...untracked_writes);
2775
+ }
2776
+ if ((reaction.f & 8388608) !== 0) reaction.f ^= ERROR_VALUE;
2777
+ return result;
2778
+ } catch (error) {
2779
+ return handle_error(error);
2780
+ } finally {
2781
+ reaction.f ^= REACTION_IS_UPDATING;
2782
+ new_deps = previous_deps;
2783
+ skipped_deps = previous_skipped_deps;
2784
+ untracked_writes = previous_untracked_writes;
2785
+ active_reaction = previous_reaction;
2786
+ current_sources = previous_sources;
2787
+ set_component_context(previous_component_context);
2788
+ untracking = previous_untracking;
2789
+ update_version = previous_update_version;
2790
+ }
2791
+ }
2792
+ /**
2793
+ * @template V
2794
+ * @param {Reaction} signal
2795
+ * @param {Value<V>} dependency
2796
+ * @returns {void}
2797
+ */
2798
+ function remove_reaction(signal, dependency) {
2799
+ let reactions = dependency.reactions;
2800
+ if (reactions !== null) {
2801
+ var index = index_of.call(reactions, signal);
2802
+ if (index !== -1) {
2803
+ var new_length = reactions.length - 1;
2804
+ if (new_length === 0) reactions = dependency.reactions = null;
2805
+ else {
2806
+ reactions[index] = reactions[new_length];
2807
+ reactions.pop();
2808
+ }
2809
+ }
2810
+ }
2811
+ if (reactions === null && (dependency.f & 2) !== 0 && (new_deps === null || !includes.call(new_deps, dependency))) {
2812
+ var derived = dependency;
2813
+ if ((derived.f & 512) !== 0) {
2814
+ derived.f ^= 512;
2815
+ derived.f &= ~WAS_MARKED;
2816
+ }
2817
+ update_derived_status(derived);
2818
+ freeze_derived_effects(derived);
2819
+ remove_reactions(derived, 0);
2820
+ }
2821
+ }
2822
+ /**
2823
+ * @param {Reaction} signal
2824
+ * @param {number} start_index
2825
+ * @returns {void}
2826
+ */
2827
+ function remove_reactions(signal, start_index) {
2828
+ var dependencies = signal.deps;
2829
+ if (dependencies === null) return;
2830
+ for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
2831
+ }
2832
+ /**
2833
+ * @param {Effect} effect
2834
+ * @returns {void}
2835
+ */
2836
+ function update_effect(effect) {
2837
+ var flags = effect.f;
2838
+ if ((flags & 16384) !== 0) return;
2839
+ set_signal_status(effect, CLEAN);
2840
+ var previous_effect = active_effect;
2841
+ var was_updating_effect = is_updating_effect;
2842
+ active_effect = effect;
2843
+ is_updating_effect = true;
2844
+ try {
2845
+ if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
2846
+ else destroy_effect_children(effect);
2847
+ execute_effect_teardown(effect);
2848
+ var teardown = update_reaction(effect);
2849
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2850
+ effect.wv = write_version;
2851
+ } finally {
2852
+ is_updating_effect = was_updating_effect;
2853
+ active_effect = previous_effect;
2854
+ }
2855
+ }
2856
+ /**
2857
+ * @template V
2858
+ * @param {Value<V>} signal
2859
+ * @returns {V}
2860
+ */
2861
+ function get(signal) {
2862
+ var is_derived = (signal.f & 2) !== 0;
2863
+ captured_signals?.add(signal);
2864
+ if (active_reaction !== null && !untracking) {
2865
+ if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !includes.call(current_sources, signal))) {
2866
+ var deps = active_reaction.deps;
2867
+ if ((active_reaction.f & 2097152) !== 0) {
2868
+ if (signal.rv < read_version) {
2869
+ signal.rv = read_version;
2870
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
2871
+ else if (new_deps === null) new_deps = [signal];
2872
+ else new_deps.push(signal);
2873
+ }
2874
+ } else {
2875
+ var _active_reaction;
2876
+ ((_active_reaction = active_reaction).deps ?? (_active_reaction.deps = [])).push(signal);
2877
+ var reactions = signal.reactions;
2878
+ if (reactions === null) signal.reactions = [active_reaction];
2879
+ else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
2880
+ }
2881
+ }
2882
+ }
2883
+ if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
2884
+ if (is_derived) {
2885
+ var derived = signal;
2886
+ if (is_destroying_effect) {
2887
+ var value = derived.v;
2888
+ if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
2889
+ old_values.set(derived, value);
2890
+ return value;
2891
+ }
2892
+ var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
2893
+ var is_new = (derived.f & REACTION_RAN) === 0;
2894
+ if (is_dirty(derived)) {
2895
+ if (should_connect) derived.f |= 512;
2896
+ update_derived(derived);
2897
+ }
2898
+ if (should_connect && !is_new) {
2899
+ unfreeze_derived_effects(derived);
2900
+ reconnect(derived);
2901
+ }
2902
+ }
2903
+ if (batch_values?.has(signal)) return batch_values.get(signal);
2904
+ if ((signal.f & 8388608) !== 0) throw signal.v;
2905
+ return signal.v;
2906
+ }
2907
+ /**
2908
+ * (Re)connect a disconnected derived, so that it is notified
2909
+ * of changes in `mark_reactions`
2910
+ * @param {Derived} derived
2911
+ */
2912
+ function reconnect(derived) {
2913
+ derived.f |= 512;
2914
+ if (derived.deps === null) return;
2915
+ for (const dep of derived.deps) {
2916
+ (dep.reactions ?? (dep.reactions = [])).push(derived);
2917
+ if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
2918
+ unfreeze_derived_effects(dep);
2919
+ reconnect(dep);
2920
+ }
2921
+ }
2922
+ }
2923
+ /** @param {Derived} derived */
2924
+ function depends_on_old_values(derived) {
2925
+ if (derived.v === UNINITIALIZED) return true;
2926
+ if (derived.deps === null) return false;
2927
+ for (const dep of derived.deps) {
2928
+ if (old_values.has(dep)) return true;
2929
+ if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
2930
+ }
2931
+ return false;
2932
+ }
2933
+ /**
2934
+ * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
2935
+ * any state read inside `fn` will not be treated as a dependency.
2936
+ *
2937
+ * ```ts
2938
+ * $effect(() => {
2939
+ * // this will run when `data` changes, but not when `time` changes
2940
+ * save(data, {
2941
+ * timestamp: untrack(() => time)
2942
+ * });
2943
+ * });
2944
+ * ```
2945
+ * @template T
2946
+ * @param {() => T} fn
2947
+ * @returns {T}
2948
+ */
2949
+ function untrack(fn) {
2950
+ var previous_untracking = untracking;
2951
+ try {
2952
+ untracking = true;
2953
+ return fn();
2954
+ } finally {
2955
+ untracking = previous_untracking;
2956
+ }
2957
+ }
2958
+ //#endregion
2959
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/events.js
2960
+ /**
2961
+ * Used on elements, as a map of event type -> event handler,
2962
+ * and on events themselves to track which element handled an event
2963
+ */
2964
+ var event_symbol = Symbol("events");
2965
+ /** @type {Set<string>} */
2966
+ var all_registered_events = /* @__PURE__ */ new Set();
2967
+ /** @type {Set<(events: Array<string>) => void>} */
2968
+ var root_event_handles = /* @__PURE__ */ new Set();
2969
+ /**
2970
+ * @param {string} event_name
2971
+ * @param {Element} element
2972
+ * @param {EventListener} [handler]
2973
+ * @returns {void}
2974
+ */
2975
+ function delegated(event_name, element, handler) {
2976
+ (element[event_symbol] ?? (element[event_symbol] = {}))[event_name] = handler;
2977
+ }
2978
+ /**
2979
+ * @param {Array<string>} events
2980
+ * @returns {void}
2981
+ */
2982
+ function delegate(events) {
2983
+ for (var i = 0; i < events.length; i++) all_registered_events.add(events[i]);
2984
+ for (var fn of root_event_handles) fn(events);
2985
+ }
2986
+ var last_propagated_event = null;
2987
+ /**
2988
+ * @this {EventTarget}
2989
+ * @param {Event} event
2990
+ * @returns {void}
2991
+ */
2992
+ function handle_event_propagation(event) {
2993
+ var handler_element = this;
2994
+ var owner_document = handler_element.ownerDocument;
2995
+ var event_name = event.type;
2996
+ var path = event.composedPath?.() || [];
2997
+ var current_target = path[0] || event.target;
2998
+ last_propagated_event = event;
2999
+ var path_idx = 0;
3000
+ var handled_at = last_propagated_event === event && event[event_symbol];
3001
+ if (handled_at) {
3002
+ var at_idx = path.indexOf(handled_at);
3003
+ if (at_idx !== -1 && (handler_element === document || handler_element === window)) {
3004
+ event[event_symbol] = handler_element;
3005
+ return;
3006
+ }
3007
+ var handler_idx = path.indexOf(handler_element);
3008
+ if (handler_idx === -1) return;
3009
+ if (at_idx <= handler_idx) path_idx = at_idx;
3010
+ }
3011
+ current_target = path[path_idx] || event.target;
3012
+ if (current_target === handler_element) return;
3013
+ define_property(event, "currentTarget", {
3014
+ configurable: true,
3015
+ get() {
3016
+ return current_target || owner_document;
3017
+ }
3018
+ });
3019
+ var previous_reaction = active_reaction;
3020
+ var previous_effect = active_effect;
3021
+ set_active_reaction(null);
3022
+ set_active_effect(null);
3023
+ try {
3024
+ /**
3025
+ * @type {unknown}
3026
+ */
3027
+ var throw_error;
3028
+ /**
3029
+ * @type {unknown[]}
3030
+ */
3031
+ var other_errors = [];
3032
+ while (current_target !== null) {
3033
+ /** @type {null | Element} */
3034
+ var parent_element = current_target.assignedSlot || current_target.parentNode || current_target.host || null;
3035
+ try {
3036
+ var delegated = current_target[event_symbol]?.[event_name];
3037
+ if (delegated != null && (!current_target.disabled || event.target === current_target)) delegated.call(current_target, event);
3038
+ } catch (error) {
3039
+ if (throw_error) other_errors.push(error);
3040
+ else throw_error = error;
3041
+ }
3042
+ if (event.cancelBubble || parent_element === handler_element || parent_element === null) break;
3043
+ current_target = parent_element;
3044
+ }
3045
+ if (throw_error) {
3046
+ for (let error of other_errors) queueMicrotask(() => {
3047
+ throw error;
3048
+ });
3049
+ throw throw_error;
3050
+ }
3051
+ } finally {
3052
+ event[event_symbol] = handler_element;
3053
+ delete event.currentTarget;
3054
+ set_active_reaction(previous_reaction);
3055
+ set_active_effect(previous_effect);
3056
+ }
3057
+ }
3058
+ //#endregion
3059
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/reconciler.js
3060
+ var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", { createHTML: (html) => {
3061
+ return html;
3062
+ } });
3063
+ /** @param {string} html */
3064
+ function create_trusted_html(html) {
3065
+ return policy?.createHTML(html) ?? html;
3066
+ }
3067
+ /**
3068
+ * @param {string} html
3069
+ */
3070
+ function create_fragment_from_html(html) {
3071
+ var elem = create_element("template");
3072
+ elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
3073
+ return elem.content;
3074
+ }
3075
+ //#endregion
3076
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/template.js
3077
+ /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3078
+ /** @import { TemplateStructure } from './types' */
3079
+ /**
3080
+ * @param {TemplateNode} start
3081
+ * @param {TemplateNode | null} end
3082
+ */
3083
+ function assign_nodes(start, end) {
3084
+ var effect = active_effect;
3085
+ if (effect.nodes === null) effect.nodes = {
3086
+ start,
3087
+ end,
3088
+ a: null,
3089
+ t: null
3090
+ };
3091
+ }
3092
+ /**
3093
+ * @param {string} content
3094
+ * @param {number} flags
3095
+ * @returns {() => Node | Node[]}
3096
+ */
3097
+ /* @__NO_SIDE_EFFECTS__ */
3098
+ function from_html(content, flags) {
3099
+ var is_fragment = (flags & 1) !== 0;
3100
+ var use_import_node = (flags & 2) !== 0;
3101
+ /** @type {Node} */
3102
+ var node;
3103
+ /**
3104
+ * Whether or not the first item is a text/element node. If not, we need to
3105
+ * create an additional comment node to act as `effect.nodes.start`
3106
+ */
3107
+ var has_start = !content.startsWith("<!>");
3108
+ return () => {
3109
+ if (hydrating) {
3110
+ assign_nodes(hydrate_node, null);
3111
+ return hydrate_node;
3112
+ }
3113
+ if (node === void 0) {
3114
+ node = create_fragment_from_html(has_start ? content : "<!>" + content);
3115
+ if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
3116
+ }
3117
+ var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
3118
+ if (is_fragment) {
3119
+ var start = /* @__PURE__ */ get_first_child(clone);
3120
+ var end = clone.lastChild;
3121
+ assign_nodes(start, end);
3122
+ } else assign_nodes(clone, clone);
3123
+ return clone;
3124
+ };
3125
+ }
3126
+ /**
3127
+ * @param {string} content
3128
+ * @param {number} flags
3129
+ * @param {'svg' | 'math'} ns
3130
+ * @returns {() => Node | Node[]}
3131
+ */
3132
+ /* @__NO_SIDE_EFFECTS__ */
3133
+ function from_namespace(content, flags, ns = "svg") {
3134
+ /**
3135
+ * Whether or not the first item is a text/element node. If not, we need to
3136
+ * create an additional comment node to act as `effect.nodes.start`
3137
+ */
3138
+ var has_start = !content.startsWith("<!>");
3139
+ var is_fragment = (flags & 1) !== 0;
3140
+ var wrapped = `<${ns}>${has_start ? content : "<!>" + content}</${ns}>`;
3141
+ /** @type {Element | DocumentFragment} */
3142
+ var node;
3143
+ return () => {
3144
+ if (hydrating) {
3145
+ assign_nodes(hydrate_node, null);
3146
+ return hydrate_node;
3147
+ }
3148
+ if (!node) {
3149
+ var root = /* @__PURE__ */ get_first_child(create_fragment_from_html(wrapped));
3150
+ if (is_fragment) {
3151
+ node = document.createDocumentFragment();
3152
+ while (/* @__PURE__ */ get_first_child(root)) node.appendChild(/* @__PURE__ */ get_first_child(root));
3153
+ } else node = /* @__PURE__ */ get_first_child(root);
3154
+ }
3155
+ var clone = node.cloneNode(true);
3156
+ if (is_fragment) {
3157
+ var start = /* @__PURE__ */ get_first_child(clone);
3158
+ var end = clone.lastChild;
3159
+ assign_nodes(start, end);
3160
+ } else assign_nodes(clone, clone);
3161
+ return clone;
3162
+ };
3163
+ }
3164
+ /**
3165
+ * @param {string} content
3166
+ * @param {number} flags
3167
+ */
3168
+ /* @__NO_SIDE_EFFECTS__ */
3169
+ function from_svg(content, flags) {
3170
+ return /* @__PURE__ */ from_namespace(content, flags, "svg");
3171
+ }
3172
+ /**
3173
+ * Assign the created (or in hydration mode, traversed) dom elements to the current block
3174
+ * and insert the elements into the dom (in client mode).
3175
+ * @param {Text | Comment | Element} anchor
3176
+ * @param {DocumentFragment | Element} dom
3177
+ */
3178
+ function append(anchor, dom) {
3179
+ if (hydrating) {
3180
+ var effect = active_effect;
3181
+ if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
3182
+ hydrate_next();
3183
+ return;
3184
+ }
3185
+ if (anchor === null) return;
3186
+ anchor.before(dom);
3187
+ }
3188
+ /**
3189
+ * Subset of delegated events which should be passive by default.
3190
+ * These two are already passive via browser defaults on window, document and body.
3191
+ * But since
3192
+ * - we're delegating them
3193
+ * - they happen often
3194
+ * - they apply to mobile which is generally less performant
3195
+ * we're marking them as passive by default for other elements, too.
3196
+ */
3197
+ var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3198
+ /**
3199
+ * Returns `true` if `name` is a passive event
3200
+ * @param {string} name
3201
+ */
3202
+ function is_passive_event(name) {
3203
+ return PASSIVE_EVENTS.includes(name);
3204
+ }
3205
+ /**
3206
+ * @param {Element} text
3207
+ * @param {string} value
3208
+ * @returns {void}
3209
+ */
3210
+ function set_text(text, value) {
3211
+ var str = value == null ? "" : typeof value === "object" ? `${value}` : value;
3212
+ if (str !== (text.__t ?? (text.__t = text.nodeValue))) {
3213
+ text.__t = str;
3214
+ text.nodeValue = `${str}`;
3215
+ }
3216
+ }
3217
+ /**
3218
+ * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
3219
+ * Transitions will play during the initial render unless the `intro` option is set to `false`.
3220
+ *
3221
+ * @template {Record<string, any>} Props
3222
+ * @template {Record<string, any>} Exports
3223
+ * @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
3224
+ * @param {MountOptions<Props>} options
3225
+ * @returns {Exports}
3226
+ */
3227
+ function mount(component, options) {
3228
+ return _mount(component, options);
3229
+ }
3230
+ /**
3231
+ * Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component
3232
+ *
3233
+ * @template {Record<string, any>} Props
3234
+ * @template {Record<string, any>} Exports
3235
+ * @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
3236
+ * @param {{} extends Props ? {
3237
+ * target: Document | Element | ShadowRoot;
3238
+ * props?: Props;
3239
+ * events?: Record<string, (e: any) => any>;
3240
+ * context?: Map<any, any>;
3241
+ * intro?: boolean;
3242
+ * recover?: boolean;
3243
+ * transformError?: (error: unknown) => unknown;
3244
+ * } : {
3245
+ * target: Document | Element | ShadowRoot;
3246
+ * props: Props;
3247
+ * events?: Record<string, (e: any) => any>;
3248
+ * context?: Map<any, any>;
3249
+ * intro?: boolean;
3250
+ * recover?: boolean;
3251
+ * transformError?: (error: unknown) => unknown;
3252
+ * }} options
3253
+ * @returns {Exports}
3254
+ */
3255
+ function hydrate(component, options) {
3256
+ init_operations();
3257
+ options.intro = options.intro ?? false;
3258
+ const target = options.target;
3259
+ const was_hydrating = hydrating;
3260
+ const previous_hydrate_node = hydrate_node;
3261
+ try {
3262
+ var anchor = /* @__PURE__ */ get_first_child(target);
3263
+ while (anchor && (anchor.nodeType !== 8 || anchor.data !== "[")) anchor = /* @__PURE__ */ get_next_sibling(anchor);
3264
+ if (!anchor) throw HYDRATION_ERROR;
3265
+ set_hydrating(true);
3266
+ set_hydrate_node(anchor);
3267
+ const instance = _mount(component, {
3268
+ ...options,
3269
+ anchor
3270
+ });
3271
+ set_hydrating(false);
3272
+ return instance;
3273
+ } catch (error) {
3274
+ if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) throw error;
3275
+ if (error !== HYDRATION_ERROR) console.warn("Failed to hydrate: ", error);
3276
+ if (options.recover === false) hydration_failed();
3277
+ init_operations();
3278
+ clear_text_content(target);
3279
+ set_hydrating(false);
3280
+ return mount(component, options);
3281
+ } finally {
3282
+ set_hydrating(was_hydrating);
3283
+ set_hydrate_node(previous_hydrate_node);
3284
+ }
3285
+ }
3286
+ /** @type {Map<EventTarget, Map<string, number>>} */
3287
+ var listeners = /* @__PURE__ */ new Map();
3288
+ /**
3289
+ * @template {Record<string, any>} Exports
3290
+ * @param {ComponentType<SvelteComponent<any>> | Component<any>} Component
3291
+ * @param {MountOptions} options
3292
+ * @returns {Exports}
3293
+ */
3294
+ function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
3295
+ init_operations();
3296
+ /** @type {Exports} */
3297
+ var component = void 0;
3298
+ var unmount = component_root(() => {
3299
+ var anchor_node = anchor ?? target.appendChild(create_text());
3300
+ boundary(anchor_node, { pending: () => {} }, (anchor_node) => {
3301
+ push({});
3302
+ var ctx = component_context;
3303
+ if (context) ctx.c = context;
3304
+ if (events)
3305
+ /** @type {any} */ props.$$events = events;
3306
+ if (hydrating) assign_nodes(anchor_node, null);
3307
+ component = Component(anchor_node, props) || {};
3308
+ if (hydrating) {
3309
+ /** @type {Effect & { nodes: EffectNodes }} */ active_effect.nodes.end = hydrate_node;
3310
+ if (hydrate_node === null || hydrate_node.nodeType !== 8 || hydrate_node.data !== "]") {
3311
+ hydration_mismatch();
3312
+ throw HYDRATION_ERROR;
3313
+ }
3314
+ }
3315
+ pop();
3316
+ }, transformError);
3317
+ /** @type {Set<string>} */
3318
+ var registered_events = /* @__PURE__ */ new Set();
3319
+ /** @param {Array<string>} events */
3320
+ var event_handle = (events) => {
3321
+ for (var i = 0; i < events.length; i++) {
3322
+ var event_name = events[i];
3323
+ if (registered_events.has(event_name)) continue;
3324
+ registered_events.add(event_name);
3325
+ var passive = is_passive_event(event_name);
3326
+ for (const node of [target, document]) {
3327
+ var counts = listeners.get(node);
3328
+ if (counts === void 0) {
3329
+ counts = /* @__PURE__ */ new Map();
3330
+ listeners.set(node, counts);
3331
+ }
3332
+ var count = counts.get(event_name);
3333
+ if (count === void 0) {
3334
+ node.addEventListener(event_name, handle_event_propagation, { passive });
3335
+ counts.set(event_name, 1);
3336
+ } else counts.set(event_name, count + 1);
3337
+ }
3338
+ }
3339
+ };
3340
+ event_handle(array_from(all_registered_events));
3341
+ root_event_handles.add(event_handle);
3342
+ return () => {
3343
+ for (var event_name of registered_events) for (const node of [target, document]) {
3344
+ var counts = listeners.get(node);
3345
+ var count = counts.get(event_name);
3346
+ if (--count == 0) {
3347
+ node.removeEventListener(event_name, handle_event_propagation);
3348
+ counts.delete(event_name);
3349
+ if (counts.size === 0) listeners.delete(node);
3350
+ } else counts.set(event_name, count);
3351
+ }
3352
+ root_event_handles.delete(event_handle);
3353
+ if (anchor_node !== anchor) anchor_node.parentNode?.removeChild(anchor_node);
3354
+ };
3355
+ });
3356
+ mounted_components.set(component, unmount);
3357
+ return component;
3358
+ }
3359
+ /**
3360
+ * References of the components that were mounted or hydrated.
3361
+ * Uses a `WeakMap` to avoid memory leaks.
3362
+ */
3363
+ var mounted_components = /* @__PURE__ */ new WeakMap();
3364
+ /**
3365
+ * Unmounts a component that was previously mounted using `mount` or `hydrate`.
3366
+ *
3367
+ * Since 5.13.0, if `options.outro` is `true`, [transitions](https://svelte.dev/docs/svelte/transition) will play before the component is removed from the DOM.
3368
+ *
3369
+ * Returns a `Promise` that resolves after transitions have completed if `options.outro` is true, or immediately otherwise (prior to 5.13.0, returns `void`).
3370
+ *
3371
+ * ```js
3372
+ * import { mount, unmount } from 'svelte';
3373
+ * import App from './App.svelte';
3374
+ *
3375
+ * const app = mount(App, { target: document.body });
3376
+ *
3377
+ * // later...
3378
+ * unmount(app, { outro: true });
3379
+ * ```
3380
+ * @param {Record<string, any>} component
3381
+ * @param {{ outro?: boolean }} [options]
3382
+ * @returns {Promise<void>}
3383
+ */
3384
+ function unmount(component, options) {
3385
+ const fn = mounted_components.get(component);
3386
+ if (fn) {
3387
+ mounted_components.delete(component);
3388
+ return fn(options);
3389
+ }
3390
+ return Promise.resolve();
3391
+ }
3392
+ //#endregion
3393
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3394
+ /** @import { Effect, TemplateNode } from '#client' */
3395
+ var _batches = /* @__PURE__ */ new WeakMap();
3396
+ var _onscreen = /* @__PURE__ */ new WeakMap();
3397
+ var _offscreen = /* @__PURE__ */ new WeakMap();
3398
+ var _outroing = /* @__PURE__ */ new WeakMap();
3399
+ var _transition = /* @__PURE__ */ new WeakMap();
3400
+ var _commit = /* @__PURE__ */ new WeakMap();
3401
+ var _discard = /* @__PURE__ */ new WeakMap();
3402
+ /**
3403
+ * @typedef {{ effect: Effect, fragment: DocumentFragment }} Branch
3404
+ */
3405
+ /**
3406
+ * @template Key
3407
+ */
3408
+ var BranchManager = class {
3409
+ /**
3410
+ * @param {TemplateNode} anchor
3411
+ * @param {boolean} transition
3412
+ */
3413
+ constructor(anchor, transition = true) {
3414
+ _defineProperty(
3415
+ this,
3416
+ /** @type {TemplateNode} */
3417
+ "anchor",
3418
+ void 0
3419
+ );
3420
+ _classPrivateFieldInitSpec(this, _batches, /* @__PURE__ */ new Map());
3421
+ _classPrivateFieldInitSpec(this, _onscreen, /* @__PURE__ */ new Map());
3422
+ _classPrivateFieldInitSpec(this, _offscreen, /* @__PURE__ */ new Map());
3423
+ _classPrivateFieldInitSpec(this, _outroing, /* @__PURE__ */ new Set());
3424
+ _classPrivateFieldInitSpec(this, _transition, true);
3425
+ _classPrivateFieldInitSpec(this, _commit, (batch) => {
3426
+ if (!_classPrivateFieldGet2(_batches, this).has(batch)) return;
3427
+ var key = _classPrivateFieldGet2(_batches, this).get(batch);
3428
+ var onscreen = _classPrivateFieldGet2(_onscreen, this).get(key);
3429
+ if (onscreen) {
3430
+ resume_effect(onscreen);
3431
+ _classPrivateFieldGet2(_outroing, this).delete(key);
3432
+ } else {
3433
+ var offscreen = _classPrivateFieldGet2(_offscreen, this).get(key);
3434
+ if (offscreen) {
3435
+ _classPrivateFieldGet2(_onscreen, this).set(key, offscreen.effect);
3436
+ _classPrivateFieldGet2(_offscreen, this).delete(key);
3437
+ /** @type {TemplateNode} */ offscreen.fragment.lastChild.remove();
3438
+ this.anchor.before(offscreen.fragment);
3439
+ onscreen = offscreen.effect;
3440
+ }
3441
+ }
3442
+ for (const [b, k] of _classPrivateFieldGet2(_batches, this)) {
3443
+ _classPrivateFieldGet2(_batches, this).delete(b);
3444
+ if (b === batch) break;
3445
+ const offscreen = _classPrivateFieldGet2(_offscreen, this).get(k);
3446
+ if (offscreen) {
3447
+ destroy_effect(offscreen.effect);
3448
+ _classPrivateFieldGet2(_offscreen, this).delete(k);
3449
+ }
3450
+ }
3451
+ for (const [k, effect] of _classPrivateFieldGet2(_onscreen, this)) {
3452
+ if (k === key || _classPrivateFieldGet2(_outroing, this).has(k)) continue;
3453
+ const on_destroy = () => {
3454
+ if (Array.from(_classPrivateFieldGet2(_batches, this).values()).includes(k)) {
3455
+ var fragment = document.createDocumentFragment();
3456
+ move_effect(effect, fragment);
3457
+ fragment.append(create_text());
3458
+ _classPrivateFieldGet2(_offscreen, this).set(k, {
3459
+ effect,
3460
+ fragment
3461
+ });
3462
+ } else destroy_effect(effect);
3463
+ _classPrivateFieldGet2(_outroing, this).delete(k);
3464
+ _classPrivateFieldGet2(_onscreen, this).delete(k);
3465
+ };
3466
+ if (_classPrivateFieldGet2(_transition, this) || !onscreen) {
3467
+ _classPrivateFieldGet2(_outroing, this).add(k);
3468
+ pause_effect(effect, on_destroy, false);
3469
+ } else on_destroy();
3470
+ }
3471
+ });
3472
+ _classPrivateFieldInitSpec(this, _discard, (batch) => {
3473
+ _classPrivateFieldGet2(_batches, this).delete(batch);
3474
+ const keys = Array.from(_classPrivateFieldGet2(_batches, this).values());
3475
+ for (const [k, branch] of _classPrivateFieldGet2(_offscreen, this)) if (!keys.includes(k)) {
3476
+ destroy_effect(branch.effect);
3477
+ _classPrivateFieldGet2(_offscreen, this).delete(k);
3478
+ }
3479
+ });
3480
+ this.anchor = anchor;
3481
+ _classPrivateFieldSet2(_transition, this, transition);
3482
+ }
3483
+ /**
3484
+ *
3485
+ * @param {any} key
3486
+ * @param {null | ((target: TemplateNode) => void)} fn
3487
+ */
3488
+ ensure(key, fn) {
3489
+ var batch = current_batch;
3490
+ var defer = should_defer_append();
3491
+ if (fn && !_classPrivateFieldGet2(_onscreen, this).has(key) && !_classPrivateFieldGet2(_offscreen, this).has(key)) if (defer) {
3492
+ var fragment = document.createDocumentFragment();
3493
+ var target = create_text();
3494
+ fragment.append(target);
3495
+ _classPrivateFieldGet2(_offscreen, this).set(key, {
3496
+ effect: branch(() => fn(target)),
3497
+ fragment
3498
+ });
3499
+ } else _classPrivateFieldGet2(_onscreen, this).set(key, branch(() => fn(this.anchor)));
3500
+ _classPrivateFieldGet2(_batches, this).set(batch, key);
3501
+ if (defer) {
3502
+ for (const [k, effect] of _classPrivateFieldGet2(_onscreen, this)) if (k === key) batch.unskip_effect(effect);
3503
+ else batch.skip_effect(effect);
3504
+ for (const [k, branch] of _classPrivateFieldGet2(_offscreen, this)) if (k === key) batch.unskip_effect(branch.effect);
3505
+ else batch.skip_effect(branch.effect);
3506
+ batch.oncommit(_classPrivateFieldGet2(_commit, this));
3507
+ batch.ondiscard(_classPrivateFieldGet2(_discard, this));
3508
+ } else {
3509
+ if (hydrating) this.anchor = hydrate_node;
3510
+ _classPrivateFieldGet2(_commit, this).call(this, batch);
3511
+ }
3512
+ }
3513
+ };
3514
+ /**
3515
+ * `onMount`, like [`$effect`](https://svelte.dev/docs/svelte/$effect), schedules a function to run as soon as the component has been mounted to the DOM.
3516
+ * Unlike `$effect`, the provided function only runs once.
3517
+ *
3518
+ * It must be called during the component's initialisation (but doesn't need to live _inside_ the component;
3519
+ * it can be called from an external module). If a function is returned _synchronously_ from `onMount`,
3520
+ * it will be called when the component is unmounted.
3521
+ *
3522
+ * `onMount` functions do not run during [server-side rendering](https://svelte.dev/docs/svelte/svelte-server#render).
3523
+ *
3524
+ * @template T
3525
+ * @param {() => NotFunction<T> | Promise<NotFunction<T>> | (() => any)} fn
3526
+ * @returns {void}
3527
+ */
3528
+ function onMount(fn) {
3529
+ if (component_context === null) lifecycle_outside_component("onMount");
3530
+ if (legacy_mode_flag && component_context.l !== null) init_update_callbacks(component_context).m.push(fn);
3531
+ else user_effect(() => {
3532
+ const cleanup = untrack(fn);
3533
+ if (typeof cleanup === "function") return cleanup;
3534
+ });
3535
+ }
3536
+ /**
3537
+ * Legacy-mode: Init callbacks object for onMount/beforeUpdate/afterUpdate
3538
+ * @param {ComponentContext} context
3539
+ */
3540
+ function init_update_callbacks(context) {
3541
+ var l = context.l;
3542
+ return l.u ?? (l.u = {
3543
+ a: [],
3544
+ b: [],
3545
+ m: []
3546
+ });
3547
+ }
3548
+ //#endregion
3549
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/blocks/if.js
3550
+ /** @import { TemplateNode } from '#client' */
3551
+ /**
3552
+ * @param {TemplateNode} node
3553
+ * @param {(branch: (fn: (anchor: Node) => void, key?: number | false) => void) => void} fn
3554
+ * @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local'
3555
+ * @returns {void}
3556
+ */
3557
+ function if_block(node, fn, elseif = false) {
3558
+ /** @type {TemplateNode | undefined} */
3559
+ var marker;
3560
+ if (hydrating) {
3561
+ marker = hydrate_node;
3562
+ hydrate_next();
3563
+ }
3564
+ var branches = new BranchManager(node);
3565
+ var flags = elseif ? EFFECT_TRANSPARENT : 0;
3566
+ /**
3567
+ * @param {number | false} key
3568
+ * @param {null | ((anchor: Node) => void)} fn
3569
+ */
3570
+ function update_branch(key, fn) {
3571
+ if (hydrating) {
3572
+ var data = read_hydration_instruction(marker);
3573
+ if (key !== parseInt(data.substring(1))) {
3574
+ var anchor = skip_nodes();
3575
+ set_hydrate_node(anchor);
3576
+ branches.anchor = anchor;
3577
+ set_hydrating(false);
3578
+ branches.ensure(key, fn);
3579
+ set_hydrating(true);
3580
+ return;
3581
+ }
3582
+ }
3583
+ branches.ensure(key, fn);
3584
+ }
3585
+ block(() => {
3586
+ var has_branch = false;
3587
+ fn((fn, key = 0) => {
3588
+ has_branch = true;
3589
+ update_branch(key, fn);
3590
+ });
3591
+ if (!has_branch) update_branch(-1, null);
3592
+ }, flags);
3593
+ }
3594
+ /**
3595
+ * @param {Element | Text | Comment} node
3596
+ * @param {() => string | TrustedHTML} get_value
3597
+ * @param {boolean} [is_controlled]
3598
+ * @param {boolean} [svg]
3599
+ * @param {boolean} [mathml]
3600
+ * @param {boolean} [skip_warning]
3601
+ * @returns {void}
3602
+ */
3603
+ function html(node, get_value, is_controlled = false, svg = false, mathml = false, skip_warning = false) {
3604
+ var anchor = node;
3605
+ /** @type {string | TrustedHTML} */
3606
+ var value = "";
3607
+ if (is_controlled) {
3608
+ var parent_node = node;
3609
+ if (hydrating) anchor = set_hydrate_node(/* @__PURE__ */ get_first_child(parent_node));
3610
+ }
3611
+ template_effect(() => {
3612
+ var effect = active_effect;
3613
+ if (value === (value = get_value() ?? "")) {
3614
+ if (hydrating) hydrate_next();
3615
+ return;
3616
+ }
3617
+ if (is_controlled && !hydrating) {
3618
+ effect.nodes = null;
3619
+ parent_node.innerHTML = value;
3620
+ if (value !== "") assign_nodes(/* @__PURE__ */ get_first_child(parent_node), parent_node.lastChild);
3621
+ return;
3622
+ }
3623
+ if (effect.nodes !== null) {
3624
+ remove_effect_dom(effect.nodes.start, effect.nodes.end);
3625
+ effect.nodes = null;
3626
+ }
3627
+ if (value === "") return;
3628
+ if (hydrating) {
3629
+ hydrate_node.data;
3630
+ /** @type {TemplateNode | null} */
3631
+ var next = hydrate_next();
3632
+ var last = next;
3633
+ while (next !== null && (next.nodeType !== 8 || next.data !== "")) {
3634
+ last = next;
3635
+ next = /* @__PURE__ */ get_next_sibling(next);
3636
+ }
3637
+ if (next === null) {
3638
+ hydration_mismatch();
3639
+ throw HYDRATION_ERROR;
3640
+ }
3641
+ assign_nodes(hydrate_node, last);
3642
+ anchor = set_hydrate_node(next);
3643
+ return;
3644
+ }
3645
+ var wrapper = create_element(svg ? "svg" : mathml ? "math" : "template", svg ? NAMESPACE_SVG : mathml ? NAMESPACE_MATHML : void 0);
3646
+ wrapper.innerHTML = value;
3647
+ /** @type {DocumentFragment | Element} */
3648
+ var node = svg || mathml ? wrapper : wrapper.content;
3649
+ assign_nodes(/* @__PURE__ */ get_first_child(node), node.lastChild);
3650
+ if (svg || mathml) while (/* @__PURE__ */ get_first_child(node)) anchor.before(/* @__PURE__ */ get_first_child(node));
3651
+ else anchor.before(node);
3652
+ });
3653
+ }
3654
+ //#endregion
3655
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/css.js
3656
+ /**
3657
+ * @param {Node} anchor
3658
+ * @param {{ hash: string, code: string }} css
3659
+ */
3660
+ function append_styles$1(anchor, css) {
3661
+ effect(() => {
3662
+ var root = anchor.getRootNode();
3663
+ var target = root.host ? root : root.head ?? root.ownerDocument.head;
3664
+ if (!target.querySelector("#" + css.hash)) {
3665
+ const style = create_element("style");
3666
+ style.id = css.hash;
3667
+ style.textContent = css.code;
3668
+ target.appendChild(style);
3669
+ }
3670
+ });
3671
+ }
3672
+ /**
3673
+ *
3674
+ * @param {Record<string,any>} styles
3675
+ * @param {boolean} important
3676
+ */
3677
+ function append_styles(styles, important = false) {
3678
+ var separator = important ? " !important;" : ";";
3679
+ var css = "";
3680
+ for (var key of Object.keys(styles)) {
3681
+ var value = styles[key];
3682
+ if (value != null && value !== "") css += " " + key + ": " + value + separator;
3683
+ }
3684
+ return css;
3685
+ }
3686
+ /**
3687
+ * @param {string} name
3688
+ * @returns {string}
3689
+ */
3690
+ function to_css_name(name) {
3691
+ if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
3692
+ return name;
3693
+ }
3694
+ /**
3695
+ * @param {any} value
3696
+ * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]
3697
+ * @returns {string | null}
3698
+ */
3699
+ function to_style(value, styles) {
3700
+ if (styles) {
3701
+ var new_style = "";
3702
+ /** @type {Record<string,any> | undefined} */
3703
+ var normal_styles;
3704
+ /** @type {Record<string,any> | undefined} */
3705
+ var important_styles;
3706
+ if (Array.isArray(styles)) {
3707
+ normal_styles = styles[0];
3708
+ important_styles = styles[1];
3709
+ } else normal_styles = styles;
3710
+ if (value) {
3711
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
3712
+ /** @type {boolean | '"' | "'"} */
3713
+ var in_str = false;
3714
+ var in_apo = 0;
3715
+ var in_comment = false;
3716
+ var reserved_names = [];
3717
+ if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
3718
+ if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
3719
+ var start_index = 0;
3720
+ var name_index = -1;
3721
+ const len = value.length;
3722
+ for (var i = 0; i < len; i++) {
3723
+ var c = value[i];
3724
+ if (in_comment) {
3725
+ if (c === "/" && value[i - 1] === "*") in_comment = false;
3726
+ } else if (in_str) {
3727
+ if (in_str === c) in_str = false;
3728
+ } else if (c === "/" && value[i + 1] === "*") in_comment = true;
3729
+ else if (c === "\"" || c === "'") in_str = c;
3730
+ else if (c === "(") in_apo++;
3731
+ else if (c === ")") in_apo--;
3732
+ if (!in_comment && in_str === false && in_apo === 0) {
3733
+ if (c === ":" && name_index === -1) name_index = i;
3734
+ else if (c === ";" || i === len - 1) {
3735
+ if (name_index !== -1) {
3736
+ var name = to_css_name(value.substring(start_index, name_index).trim());
3737
+ if (!reserved_names.includes(name)) {
3738
+ if (c !== ";") i++;
3739
+ var property = value.substring(start_index, i).trim();
3740
+ new_style += " " + property + ";";
3741
+ }
3742
+ }
3743
+ start_index = i + 1;
3744
+ name_index = -1;
3745
+ }
3746
+ }
3747
+ }
3748
+ }
3749
+ if (normal_styles) new_style += append_styles(normal_styles);
3750
+ if (important_styles) new_style += append_styles(important_styles, true);
3751
+ new_style = new_style.trim();
3752
+ return new_style === "" ? null : new_style;
3753
+ }
3754
+ return value == null ? null : String(value);
3755
+ }
3756
+ //#endregion
3757
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/style.js
3758
+ /**
3759
+ * @param {Element & ElementCSSInlineStyle} dom
3760
+ * @param {Record<string, any>} prev
3761
+ * @param {Record<string, any>} next
3762
+ * @param {string} [priority]
3763
+ */
3764
+ function update_styles(dom, prev = {}, next, priority) {
3765
+ for (var key in next) {
3766
+ var value = next[key];
3767
+ if (prev[key] !== value) if (next[key] == null) dom.style.removeProperty(key);
3768
+ else dom.style.setProperty(key, value, priority);
3769
+ }
3770
+ }
3771
+ /**
3772
+ * @param {Element & ElementCSSInlineStyle} dom
3773
+ * @param {string | null} value
3774
+ * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [prev_styles]
3775
+ * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [next_styles]
3776
+ */
3777
+ function set_style(dom, value, prev_styles, next_styles) {
3778
+ var prev = dom.__style;
3779
+ if (hydrating || prev !== value) {
3780
+ var next_style_attr = to_style(value, next_styles);
3781
+ if (!hydrating || next_style_attr !== dom.getAttribute("style")) if (next_style_attr == null) dom.removeAttribute("style");
3782
+ else dom.style.cssText = next_style_attr;
3783
+ dom.__style = value;
3784
+ } else if (next_styles) if (Array.isArray(next_styles)) {
3785
+ update_styles(dom, prev_styles?.[0], next_styles[0]);
3786
+ update_styles(dom, prev_styles?.[1], next_styles[1], "important");
3787
+ } else update_styles(dom, prev_styles, next_styles);
3788
+ return next_styles;
3789
+ }
3790
+ //#endregion
3791
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/attributes.js
3792
+ /** @import { Blocker, Effect } from '#client' */
3793
+ var IS_CUSTOM_ELEMENT = Symbol("is custom element");
3794
+ var IS_HTML = Symbol("is html");
3795
+ var LINK_TAG = IS_XHTML ? "link" : "LINK";
3796
+ /**
3797
+ * @param {Element} element
3798
+ * @param {string} attribute
3799
+ * @param {string | null} value
3800
+ * @param {boolean} [skip_warning]
3801
+ */
3802
+ function set_attribute(element, attribute, value, skip_warning) {
3803
+ var attributes = get_attributes(element);
3804
+ if (hydrating) {
3805
+ attributes[attribute] = element.getAttribute(attribute);
3806
+ if (attribute === "src" || attribute === "srcset" || attribute === "href" && element.nodeName === LINK_TAG) {
3807
+ if (!skip_warning) check_src_in_dev_hydration(element, attribute, value ?? "");
3808
+ return;
3809
+ }
3810
+ }
3811
+ if (attributes[attribute] === (attributes[attribute] = value)) return;
3812
+ if (attribute === "loading") element[LOADING_ATTR_SYMBOL] = value;
3813
+ if (value == null) element.removeAttribute(attribute);
3814
+ else if (typeof value !== "string" && get_setters(element).includes(attribute)) element[attribute] = value;
3815
+ else element.setAttribute(attribute, value);
3816
+ }
3817
+ /**
3818
+ *
3819
+ * @param {Element} element
3820
+ */
3821
+ function get_attributes(element) {
3822
+ return element.__attributes ?? (element.__attributes = {
3823
+ [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
3824
+ [IS_HTML]: element.namespaceURI === "http://www.w3.org/1999/xhtml"
3825
+ });
3826
+ }
3827
+ /** @type {Map<string, string[]>} */
3828
+ var setters_cache = /* @__PURE__ */ new Map();
3829
+ /** @param {Element} element */
3830
+ function get_setters(element) {
3831
+ var cache_key = element.getAttribute("is") || element.nodeName;
3832
+ var setters = setters_cache.get(cache_key);
3833
+ if (setters) return setters;
3834
+ setters_cache.set(cache_key, setters = []);
3835
+ var descriptors;
3836
+ var proto = element;
3837
+ var element_proto = Element.prototype;
3838
+ while (element_proto !== proto) {
3839
+ descriptors = get_descriptors(proto);
3840
+ for (var key in descriptors) if (descriptors[key].set) setters.push(key);
3841
+ proto = get_prototype_of(proto);
3842
+ }
3843
+ return setters;
3844
+ }
3845
+ /**
3846
+ * @param {any} element
3847
+ * @param {string} attribute
3848
+ * @param {string} value
3849
+ */
3850
+ function check_src_in_dev_hydration(element, attribute, value) {}
3851
+ //#endregion
3852
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
3853
+ var _ResizeObserverSingleton;
3854
+ var _listeners = /* @__PURE__ */ new WeakMap();
3855
+ var _observer = /* @__PURE__ */ new WeakMap();
3856
+ var _options = /* @__PURE__ */ new WeakMap();
3857
+ var _ResizeObserverSingleton_brand = /* @__PURE__ */ new WeakSet();
3858
+ /**
3859
+ * We create one listener for all elements
3860
+ * @see {@link https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ Explanation}
3861
+ */
3862
+ var ResizeObserverSingleton = class {
3863
+ /** @param {ResizeObserverOptions} options */
3864
+ constructor(options) {
3865
+ _classPrivateMethodInitSpec(this, _ResizeObserverSingleton_brand);
3866
+ _classPrivateFieldInitSpec(this, _listeners, /* @__PURE__ */ new WeakMap());
3867
+ _classPrivateFieldInitSpec(this, _observer, void 0);
3868
+ _classPrivateFieldInitSpec(this, _options, void 0);
3869
+ _classPrivateFieldSet2(_options, this, options);
3870
+ }
3871
+ /**
3872
+ * @param {Element} element
3873
+ * @param {(entry: ResizeObserverEntry) => any} listener
3874
+ */
3875
+ observe(element, listener) {
3876
+ var listeners = _classPrivateFieldGet2(_listeners, this).get(element) || /* @__PURE__ */ new Set();
3877
+ listeners.add(listener);
3878
+ _classPrivateFieldGet2(_listeners, this).set(element, listeners);
3879
+ _assertClassBrand(_ResizeObserverSingleton_brand, this, _getObserver).call(this).observe(element, _classPrivateFieldGet2(_options, this));
3880
+ return () => {
3881
+ var listeners = _classPrivateFieldGet2(_listeners, this).get(element);
3882
+ listeners.delete(listener);
3883
+ if (listeners.size === 0) {
3884
+ _classPrivateFieldGet2(_listeners, this).delete(element);
3885
+ /** @type {ResizeObserver} */ _classPrivateFieldGet2(_observer, this).unobserve(element);
3886
+ }
3887
+ };
3888
+ }
3889
+ };
3890
+ _ResizeObserverSingleton = ResizeObserverSingleton;
3891
+ function _getObserver() {
3892
+ return _classPrivateFieldGet2(_observer, this) ?? _classPrivateFieldSet2(_observer, this, new ResizeObserver(
3893
+ /** @param {any} entries */
3894
+ (entries) => {
3895
+ for (var entry of entries) {
3896
+ _ResizeObserverSingleton.entries.set(entry.target, entry);
3897
+ for (var listener of _classPrivateFieldGet2(_listeners, this).get(entry.target) || []) listener(entry);
3898
+ }
3899
+ }
3900
+ ));
3901
+ }
3902
+ _defineProperty(ResizeObserverSingleton, "entries", /* @__PURE__ */ new WeakMap());
3903
+ //#endregion
3904
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
3905
+ /** @import { ComponentContext, Effect } from '#client' */
3906
+ /**
3907
+ * @param {any} bound_value
3908
+ * @param {Element} element_or_component
3909
+ * @returns {boolean}
3910
+ */
3911
+ function is_bound_this(bound_value, element_or_component) {
3912
+ return bound_value === element_or_component || bound_value?.[STATE_SYMBOL] === element_or_component;
3913
+ }
3914
+ /**
3915
+ * @param {any} element_or_component
3916
+ * @param {(value: unknown, ...parts: unknown[]) => void} update
3917
+ * @param {(...parts: unknown[]) => unknown} get_value
3918
+ * @param {() => unknown[]} [get_parts] Set if the this binding is used inside an each block,
3919
+ * returns all the parts of the each block context that are used in the expression
3920
+ * @returns {void}
3921
+ */
3922
+ function bind_this(element_or_component = {}, update, get_value, get_parts) {
3923
+ var component_effect = component_context.r;
3924
+ var parent = active_effect;
3925
+ effect(() => {
3926
+ /** @type {unknown[]} */
3927
+ var old_parts;
3928
+ /** @type {unknown[]} */
3929
+ var parts;
3930
+ render_effect(() => {
3931
+ old_parts = parts;
3932
+ parts = get_parts?.() || [];
3933
+ untrack(() => {
3934
+ if (element_or_component !== get_value(...parts)) {
3935
+ update(element_or_component, ...parts);
3936
+ if (old_parts && is_bound_this(get_value(...old_parts), element_or_component)) update(null, ...old_parts);
3937
+ }
3938
+ });
3939
+ });
3940
+ return () => {
3941
+ let p = parent;
3942
+ while (p !== component_effect && p.parent !== null && p.parent.f & 33554432) p = p.parent;
3943
+ const teardown = () => {
3944
+ if (parts && is_bound_this(get_value(...parts), element_or_component)) update(null, ...parts);
3945
+ };
3946
+ const original_teardown = p.teardown;
3947
+ p.teardown = () => {
3948
+ teardown();
3949
+ original_teardown?.();
3950
+ };
3951
+ };
3952
+ });
3953
+ return element_or_component;
3954
+ }
3955
+ //#endregion
3956
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/legacy/legacy-client.js
3957
+ /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
3958
+ /**
3959
+ * Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
3960
+ *
3961
+ * @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
3962
+ *
3963
+ * @template {Record<string, any>} Props
3964
+ * @template {Record<string, any>} Exports
3965
+ * @template {Record<string, any>} Events
3966
+ * @template {Record<string, any>} Slots
3967
+ *
3968
+ * @param {ComponentConstructorOptions<Props> & {
3969
+ * component: ComponentType<SvelteComponent<Props, Events, Slots>> | Component<Props>;
3970
+ * }} options
3971
+ * @returns {SvelteComponent<Props, Events, Slots> & Exports}
3972
+ */
3973
+ function createClassComponent(options) {
3974
+ return new Svelte4Component(options);
3975
+ }
3976
+ var _events = /* @__PURE__ */ new WeakMap();
3977
+ var _instance = /* @__PURE__ */ new WeakMap();
3978
+ /**
3979
+ * Support using the component as both a class and function during the transition period
3980
+ * @typedef {{new (o: ComponentConstructorOptions): SvelteComponent;(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;}} LegacyComponentType
3981
+ */
3982
+ var Svelte4Component = class {
3983
+ /**
3984
+ * @param {ComponentConstructorOptions & {
3985
+ * component: any;
3986
+ * }} options
3987
+ */
3988
+ constructor(options) {
3989
+ _classPrivateFieldInitSpec(this, _events, void 0);
3990
+ _classPrivateFieldInitSpec(this, _instance, void 0);
3991
+ var sources = /* @__PURE__ */ new Map();
3992
+ /**
3993
+ * @param {string | symbol} key
3994
+ * @param {unknown} value
3995
+ */
3996
+ var add_source = (key, value) => {
3997
+ var s = /* @__PURE__ */ mutable_source(value, false, false);
3998
+ sources.set(key, s);
3999
+ return s;
4000
+ };
4001
+ const props = new Proxy({
4002
+ ...options.props || {},
4003
+ $$events: {}
4004
+ }, {
4005
+ get(target, prop) {
4006
+ return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
4007
+ },
4008
+ has(target, prop) {
4009
+ if (prop === LEGACY_PROPS) return true;
4010
+ get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
4011
+ return Reflect.has(target, prop);
4012
+ },
4013
+ set(target, prop, value) {
4014
+ set(sources.get(prop) ?? add_source(prop, value), value);
4015
+ return Reflect.set(target, prop, value);
4016
+ }
4017
+ });
4018
+ _classPrivateFieldSet2(_instance, this, (options.hydrate ? hydrate : mount)(options.component, {
4019
+ target: options.target,
4020
+ anchor: options.anchor,
4021
+ props,
4022
+ context: options.context,
4023
+ intro: options.intro ?? false,
4024
+ recover: options.recover,
4025
+ transformError: options.transformError
4026
+ }));
4027
+ if (!async_mode_flag && (!options?.props?.$$host || options.sync === false)) flushSync();
4028
+ _classPrivateFieldSet2(_events, this, props.$$events);
4029
+ for (const key of Object.keys(_classPrivateFieldGet2(_instance, this))) {
4030
+ if (key === "$set" || key === "$destroy" || key === "$on") continue;
4031
+ define_property(this, key, {
4032
+ get() {
4033
+ return _classPrivateFieldGet2(_instance, this)[key];
4034
+ },
4035
+ set(value) {
4036
+ _classPrivateFieldGet2(_instance, this)[key] = value;
4037
+ },
4038
+ enumerable: true
4039
+ });
4040
+ }
4041
+ _classPrivateFieldGet2(_instance, this).$set = (next) => {
4042
+ Object.assign(props, next);
4043
+ };
4044
+ _classPrivateFieldGet2(_instance, this).$destroy = () => {
4045
+ unmount(_classPrivateFieldGet2(_instance, this));
4046
+ };
4047
+ }
4048
+ /** @param {Record<string, any>} props */
4049
+ $set(props) {
4050
+ _classPrivateFieldGet2(_instance, this).$set(props);
4051
+ }
4052
+ /**
4053
+ * @param {string} event
4054
+ * @param {(...args: any[]) => any} callback
4055
+ * @returns {any}
4056
+ */
4057
+ $on(event, callback) {
4058
+ _classPrivateFieldGet2(_events, this)[event] = _classPrivateFieldGet2(_events, this)[event] || [];
4059
+ /** @param {any[]} args */
4060
+ const cb = (...args) => callback.call(this, ...args);
4061
+ _classPrivateFieldGet2(_events, this)[event].push(cb);
4062
+ return () => {
4063
+ _classPrivateFieldGet2(_events, this)[event] = _classPrivateFieldGet2(_events, this)[event].filter(
4064
+ /** @param {any} fn */
4065
+ (fn) => fn !== cb
4066
+ );
4067
+ };
4068
+ }
4069
+ $destroy() {
4070
+ _classPrivateFieldGet2(_instance, this).$destroy();
4071
+ }
4072
+ };
4073
+ //#endregion
4074
+ //#region ../../../node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
4075
+ /**
4076
+ * @typedef {Object} CustomElementPropDefinition
4077
+ * @property {string} [attribute]
4078
+ * @property {boolean} [reflect]
4079
+ * @property {'String'|'Boolean'|'Number'|'Array'|'Object'} [type]
4080
+ */
4081
+ /** @type {any} */
4082
+ var SvelteElement;
4083
+ if (typeof HTMLElement === "function") SvelteElement = class extends HTMLElement {
4084
+ /**
4085
+ * @param {*} $$componentCtor
4086
+ * @param {*} $$slots
4087
+ * @param {ShadowRootInit | undefined} shadow_root_init
4088
+ */
4089
+ constructor($$componentCtor, $$slots, shadow_root_init) {
4090
+ super();
4091
+ _defineProperty(
4092
+ this,
4093
+ /** The Svelte component constructor */
4094
+ "$$ctor",
4095
+ void 0
4096
+ );
4097
+ _defineProperty(
4098
+ this,
4099
+ /** Slots */
4100
+ "$$s",
4101
+ void 0
4102
+ );
4103
+ _defineProperty(
4104
+ this,
4105
+ /** @type {any} The Svelte component instance */
4106
+ "$$c",
4107
+ void 0
4108
+ );
4109
+ _defineProperty(
4110
+ this,
4111
+ /** Whether or not the custom element is connected */
4112
+ "$$cn",
4113
+ false
4114
+ );
4115
+ _defineProperty(
4116
+ this,
4117
+ /** @type {Record<string, any>} Component props data */
4118
+ "$$d",
4119
+ {}
4120
+ );
4121
+ _defineProperty(
4122
+ this,
4123
+ /** `true` if currently in the process of reflecting component props back to attributes */
4124
+ "$$r",
4125
+ false
4126
+ );
4127
+ _defineProperty(
4128
+ this,
4129
+ /** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
4130
+ "$$p_d",
4131
+ {}
4132
+ );
4133
+ _defineProperty(
4134
+ this,
4135
+ /** @type {Record<string, EventListenerOrEventListenerObject[]>} Event listeners */
4136
+ "$$l",
4137
+ {}
4138
+ );
4139
+ _defineProperty(
4140
+ this,
4141
+ /** @type {Map<EventListenerOrEventListenerObject, Function>} Event listener unsubscribe functions */
4142
+ "$$l_u",
4143
+ /* @__PURE__ */ new Map()
4144
+ );
4145
+ _defineProperty(
4146
+ this,
4147
+ /** @type {any} The managed render effect for reflecting attributes */
4148
+ "$$me",
4149
+ void 0
4150
+ );
4151
+ _defineProperty(
4152
+ this,
4153
+ /** @type {ShadowRoot | null} The ShadowRoot of the custom element */
4154
+ "$$shadowRoot",
4155
+ null
4156
+ );
4157
+ this.$$ctor = $$componentCtor;
4158
+ this.$$s = $$slots;
4159
+ if (shadow_root_init) this.$$shadowRoot = this.attachShadow(shadow_root_init);
4160
+ }
4161
+ /**
4162
+ * @param {string} type
4163
+ * @param {EventListenerOrEventListenerObject} listener
4164
+ * @param {boolean | AddEventListenerOptions} [options]
4165
+ */
4166
+ addEventListener(type, listener, options) {
4167
+ this.$$l[type] = this.$$l[type] || [];
4168
+ this.$$l[type].push(listener);
4169
+ if (this.$$c) {
4170
+ const unsub = this.$$c.$on(type, listener);
4171
+ this.$$l_u.set(listener, unsub);
4172
+ }
4173
+ super.addEventListener(type, listener, options);
4174
+ }
4175
+ /**
4176
+ * @param {string} type
4177
+ * @param {EventListenerOrEventListenerObject} listener
4178
+ * @param {boolean | AddEventListenerOptions} [options]
4179
+ */
4180
+ removeEventListener(type, listener, options) {
4181
+ super.removeEventListener(type, listener, options);
4182
+ if (this.$$c) {
4183
+ const unsub = this.$$l_u.get(listener);
4184
+ if (unsub) {
4185
+ unsub();
4186
+ this.$$l_u.delete(listener);
4187
+ }
4188
+ }
4189
+ }
4190
+ async connectedCallback() {
4191
+ this.$$cn = true;
4192
+ if (!this.$$c) {
4193
+ await Promise.resolve();
4194
+ if (!this.$$cn || this.$$c) return;
4195
+ /** @param {string} name */
4196
+ function create_slot(name) {
4197
+ /**
4198
+ * @param {Element} anchor
4199
+ */
4200
+ return (anchor) => {
4201
+ const slot = create_element("slot");
4202
+ if (name !== "default") slot.name = name;
4203
+ append(anchor, slot);
4204
+ };
4205
+ }
4206
+ /** @type {Record<string, any>} */
4207
+ const $$slots = {};
4208
+ const existing_slots = get_custom_elements_slots(this);
4209
+ for (const name of this.$$s) if (name in existing_slots) if (name === "default" && !this.$$d.children) {
4210
+ this.$$d.children = create_slot(name);
4211
+ $$slots.default = true;
4212
+ } else $$slots[name] = create_slot(name);
4213
+ for (const attribute of this.attributes) {
4214
+ const name = this.$$g_p(attribute.name);
4215
+ if (!(name in this.$$d)) this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, "toProp");
4216
+ }
4217
+ for (const key in this.$$p_d) if (!(key in this.$$d) && this[key] !== void 0) {
4218
+ this.$$d[key] = this[key];
4219
+ delete this[key];
4220
+ }
4221
+ this.$$c = createClassComponent({
4222
+ component: this.$$ctor,
4223
+ target: this.$$shadowRoot || this,
4224
+ props: {
4225
+ ...this.$$d,
4226
+ $$slots,
4227
+ $$host: this
4228
+ }
4229
+ });
4230
+ this.$$me = effect_root(() => {
4231
+ render_effect(() => {
4232
+ this.$$r = true;
4233
+ for (const key of object_keys(this.$$c)) {
4234
+ if (!this.$$p_d[key]?.reflect) continue;
4235
+ this.$$d[key] = this.$$c[key];
4236
+ const attribute_value = get_custom_element_value(key, this.$$d[key], this.$$p_d, "toAttribute");
4237
+ if (attribute_value == null) this.removeAttribute(this.$$p_d[key].attribute || key);
4238
+ else this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
4239
+ }
4240
+ this.$$r = false;
4241
+ });
4242
+ });
4243
+ for (const type in this.$$l) for (const listener of this.$$l[type]) {
4244
+ const unsub = this.$$c.$on(type, listener);
4245
+ this.$$l_u.set(listener, unsub);
4246
+ }
4247
+ this.$$l = {};
4248
+ }
4249
+ }
4250
+ /**
4251
+ * @param {string} attr
4252
+ * @param {string} _oldValue
4253
+ * @param {string} newValue
4254
+ */
4255
+ attributeChangedCallback(attr, _oldValue, newValue) {
4256
+ if (this.$$r) return;
4257
+ attr = this.$$g_p(attr);
4258
+ this.$$d[attr] = get_custom_element_value(attr, newValue, this.$$p_d, "toProp");
4259
+ this.$$c?.$set({ [attr]: this.$$d[attr] });
4260
+ }
4261
+ disconnectedCallback() {
4262
+ this.$$cn = false;
4263
+ Promise.resolve().then(() => {
4264
+ if (!this.$$cn && this.$$c) {
4265
+ this.$$c.$destroy();
4266
+ this.$$me();
4267
+ this.$$c = void 0;
4268
+ }
4269
+ });
4270
+ }
4271
+ /**
4272
+ * @param {string} attribute_name
4273
+ */
4274
+ $$g_p(attribute_name) {
4275
+ return object_keys(this.$$p_d).find((key) => this.$$p_d[key].attribute === attribute_name || !this.$$p_d[key].attribute && key.toLowerCase() === attribute_name) || attribute_name;
4276
+ }
4277
+ };
4278
+ /**
4279
+ * @param {string} prop
4280
+ * @param {any} value
4281
+ * @param {Record<string, CustomElementPropDefinition>} props_definition
4282
+ * @param {'toAttribute' | 'toProp'} [transform]
4283
+ */
4284
+ function get_custom_element_value(prop, value, props_definition, transform) {
4285
+ const type = props_definition[prop]?.type;
4286
+ value = type === "Boolean" && typeof value !== "boolean" ? value != null : value;
4287
+ if (!transform || !props_definition[prop]) return value;
4288
+ else if (transform === "toAttribute") switch (type) {
4289
+ case "Object":
4290
+ case "Array": return value == null ? null : JSON.stringify(value);
4291
+ case "Boolean": return value ? "" : null;
4292
+ case "Number": return value == null ? null : value;
4293
+ default: return value;
4294
+ }
4295
+ else switch (type) {
4296
+ case "Object":
4297
+ case "Array": return value && JSON.parse(value);
4298
+ case "Boolean": return value;
4299
+ case "Number": return value != null ? +value : value;
4300
+ default: return value;
4301
+ }
4302
+ }
4303
+ /**
4304
+ * @param {HTMLElement} element
4305
+ */
4306
+ function get_custom_elements_slots(element) {
4307
+ /** @type {Record<string, true>} */
4308
+ const result = {};
4309
+ element.childNodes.forEach((node) => {
4310
+ result[node.slot || "default"] = true;
4311
+ });
4312
+ return result;
4313
+ }
4314
+ /**
4315
+ * @internal
4316
+ *
4317
+ * Turn a Svelte component into a custom element.
4318
+ * @param {any} Component A Svelte component function
4319
+ * @param {Record<string, CustomElementPropDefinition>} props_definition The props to observe
4320
+ * @param {string[]} slots The slots to create
4321
+ * @param {string[]} exports Explicitly exported values, other than props
4322
+ * @param {ShadowRootInit | undefined} shadow_root_init Options passed to shadow DOM constructor
4323
+ * @param {(ce: new () => HTMLElement) => new () => HTMLElement} [extend]
4324
+ */
4325
+ function create_custom_element(Component, props_definition, slots, exports, shadow_root_init, extend) {
4326
+ let Class = class extends SvelteElement {
4327
+ constructor() {
4328
+ super(Component, slots, shadow_root_init);
4329
+ this.$$p_d = props_definition;
4330
+ }
4331
+ static get observedAttributes() {
4332
+ return object_keys(props_definition).map((key) => (props_definition[key].attribute || key).toLowerCase());
4333
+ }
4334
+ };
4335
+ object_keys(props_definition).forEach((prop) => {
4336
+ define_property(Class.prototype, prop, {
4337
+ get() {
4338
+ return this.$$c && prop in this.$$c ? this.$$c[prop] : this.$$d[prop];
4339
+ },
4340
+ set(value) {
4341
+ value = get_custom_element_value(prop, value, props_definition);
4342
+ this.$$d[prop] = value;
4343
+ var component = this.$$c;
4344
+ if (component) if (get_descriptor(component, prop)?.get) component[prop] = value;
4345
+ else component.$set({ [prop]: value });
4346
+ }
4347
+ });
4348
+ });
4349
+ exports.forEach((property) => {
4350
+ define_property(Class.prototype, property, { get() {
4351
+ return this.$$c?.[property];
4352
+ } });
4353
+ });
4354
+ if (extend) Class = extend(Class);
4355
+ Component.element = Class;
4356
+ return Class;
4357
+ }
4358
+ //#endregion
4359
+ //#region src/delivery/SimpleCloze.svelte
4360
+ var root_1 = /* @__PURE__ */ from_html(`<div class="mb-4 prose"></div>`);
4361
+ var root_3 = /* @__PURE__ */ from_svg(`<svg style="width: 25px; height: 25px;" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-283 359 34 35"><circle cx="-266" cy="375.9" r="14" fill="#bce2ff"></circle><path d="M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z" fill="#bce2ff"></path><polygon points="-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6" fill="#1a9cff"></polygon></svg>`);
4362
+ var root_4 = /* @__PURE__ */ from_svg(`<svg style="width: 25px; height: 25px;" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-129.5 127 34 35"><path style="fill: #D0CAC5; stroke: #E6E3E0; stroke-width: 0.75; stroke-miterlimit: 10;" d="M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5 C-97.4,153.5-104.3,160.4-112.9,160.4z"></path><path style="fill: #B3ABA4; stroke: #CDC7C2; stroke-width: 0.5; stroke-miterlimit: 10;" d="M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z"></path><circle cx="-114.2" cy="143.5" r="14" fill="white"></circle><path d="M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z" fill="#bce2ff"></path><polygon points="-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2" fill="#1a9cff"></polygon></svg>`);
4363
+ var root_2 = /* @__PURE__ */ from_html(`<button type="button" class="mb-3 flex items-center gap-2 cursor-pointer select-none"><!> <span class="text-sm hover:underline"> </span></button>`);
4364
+ var root_5 = /* @__PURE__ */ from_html(`<span class="correctness-icon svelte-1glps5n" style="background-color: #0EA449;"><svg style="width: 12px; height: 12px; color: white;" fill="currentColor" viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"></path></svg></span>`);
4365
+ var root_6 = /* @__PURE__ */ from_html(`<span class="correctness-icon svelte-1glps5n" style="background-color: #BF0D00;"><svg style="width: 12px; height: 12px; color: white;" fill="currentColor" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg></span>`);
4366
+ var root = /* @__PURE__ */ from_html(`<div class="p-4"><!> <!> <div class="relative inline-block"><!> <!> <input type="text" placeholder="Enter your answer..." class="outline-none px-3 py-2 rounded svelte-1glps5n"/></div></div>`);
4367
+ var $$css = {
4368
+ hash: "svelte-1glps5n",
4369
+ code: "\n /* Custom styles for correct answer display */input[readonly].svelte-1glps5n {font-weight:600;}.correctness-icon.svelte-1glps5n {position:absolute;top:-8px;left:-8px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;padding:2px;}"
4370
+ };
4371
+ function SimpleCloze($$anchor, $$props) {
4372
+ push($$props, true);
4373
+ append_styles$1($$anchor, $$css);
4374
+ let inputElement = null;
4375
+ let showCorrectAnswer = /* @__PURE__ */ state(false);
4376
+ onMount(() => {
4377
+ if (inputElement) {
4378
+ inputElement.value = $$props?.session?.response || "";
4379
+ inputElement.addEventListener("input", handleInput);
4380
+ }
4381
+ return () => {
4382
+ if (inputElement) inputElement.removeEventListener("input", handleInput);
4383
+ };
4384
+ });
4385
+ user_effect(() => {
4386
+ if (inputElement && !get(showCorrectAnswer)) {
4387
+ const sessionValue = $$props?.session?.response || "";
4388
+ if (inputElement.value !== sessionValue) inputElement.value = sessionValue;
4389
+ }
4390
+ });
4391
+ user_effect(() => {
4392
+ if (inputElement) {
4393
+ if (get(showCorrectAnswer) && $$props?.model?.correctAnswer) inputElement.value = $$props.model.correctAnswer;
4394
+ else if (!get(showCorrectAnswer)) inputElement.value = $$props?.session?.response || "";
4395
+ }
4396
+ });
4397
+ function handleInput(event) {
4398
+ const target = event.target;
4399
+ const newValue = target.value;
4400
+ const updatedSession = {
4401
+ ...$$props.session,
4402
+ response: newValue
4403
+ };
4404
+ const hostElement = target.closest("simple-cloze");
4405
+ if (hostElement?._internalSession) hostElement._internalSession = updatedSession;
4406
+ const customEvent = new CustomEvent("session-changed", {
4407
+ bubbles: true,
4408
+ composed: true,
4409
+ detail: {
4410
+ complete: true,
4411
+ component: "simple-cloze"
4412
+ }
4413
+ });
4414
+ hostElement?.dispatchEvent(customEvent);
4415
+ }
4416
+ function toggleCorrectAnswer() {
4417
+ set(showCorrectAnswer, !get(showCorrectAnswer));
4418
+ }
4419
+ const isEvaluateMode = /* @__PURE__ */ user_derived(() => $$props?.model?.env?.mode === "evaluate");
4420
+ const correctness = /* @__PURE__ */ user_derived(() => $$props?.model?.correctness);
4421
+ const isCorrect = /* @__PURE__ */ user_derived(() => get(correctness) === "correct");
4422
+ const isIncorrect = /* @__PURE__ */ user_derived(() => get(correctness) === "incorrect");
4423
+ var div = root();
4424
+ var node = child(div);
4425
+ var consequent = ($$anchor) => {
4426
+ var div_1 = root_1();
4427
+ html(div_1, () => $$props.model.prompt, true);
4428
+ reset(div_1);
4429
+ append($$anchor, div_1);
4430
+ };
4431
+ if_block(node, ($$render) => {
4432
+ if ($$props?.model?.prompt) $$render(consequent);
4433
+ });
4434
+ var node_1 = sibling(node, 2);
4435
+ var consequent_2 = ($$anchor) => {
4436
+ var button = root_2();
4437
+ var node_2 = child(button);
4438
+ var consequent_1 = ($$anchor) => {
4439
+ append($$anchor, root_3());
4440
+ };
4441
+ var alternate = ($$anchor) => {
4442
+ append($$anchor, root_4());
4443
+ };
4444
+ if_block(node_2, ($$render) => {
4445
+ if (get(showCorrectAnswer)) $$render(consequent_1);
4446
+ else $$render(alternate, -1);
4447
+ });
4448
+ var span = sibling(node_2, 2);
4449
+ var text = child(span);
4450
+ reset(span);
4451
+ reset(button);
4452
+ template_effect(() => {
4453
+ set_attribute(button, "aria-pressed", get(showCorrectAnswer));
4454
+ set_text(text, `${get(showCorrectAnswer) ? "Hide" : "Show"} correct answer`);
4455
+ });
4456
+ delegated("click", button, toggleCorrectAnswer);
4457
+ append($$anchor, button);
4458
+ };
4459
+ if_block(node_1, ($$render) => {
4460
+ if (get(isEvaluateMode) && get(isIncorrect)) $$render(consequent_2);
4461
+ });
4462
+ var div_2 = sibling(node_1, 2);
4463
+ var node_3 = child(div_2);
4464
+ var consequent_3 = ($$anchor) => {
4465
+ append($$anchor, root_5());
4466
+ };
4467
+ if_block(node_3, ($$render) => {
4468
+ if (get(isEvaluateMode) && (get(isCorrect) || get(showCorrectAnswer))) $$render(consequent_3);
4469
+ });
4470
+ var node_4 = sibling(node_3, 2);
4471
+ var consequent_4 = ($$anchor) => {
4472
+ append($$anchor, root_6());
4473
+ };
4474
+ if_block(node_4, ($$render) => {
4475
+ if (get(isEvaluateMode) && get(isIncorrect) && !get(showCorrectAnswer)) $$render(consequent_4);
4476
+ });
4477
+ var input = sibling(node_4, 2);
4478
+ let styles;
4479
+ bind_this(input, ($$value) => inputElement = $$value, () => inputElement);
4480
+ reset(div_2);
4481
+ reset(div);
4482
+ template_effect(() => {
4483
+ input.disabled = $$props?.model?.disabled;
4484
+ input.readOnly = get(showCorrectAnswer);
4485
+ styles = set_style(input, "", styles, {
4486
+ border: get(isEvaluateMode) && (get(isCorrect) || get(showCorrectAnswer)) ? "solid 2px #0EA449" : get(isEvaluateMode) && get(isIncorrect) && !get(showCorrectAnswer) ? "solid 2px #BF0D00" : "solid 1px #d1d5db",
4487
+ color: get(isEvaluateMode) && (get(isCorrect) || get(isIncorrect)) ? "black" : ""
4488
+ });
4489
+ });
4490
+ append($$anchor, div);
4491
+ pop();
4492
+ }
4493
+ delegate(["click"]);
4494
+ create_custom_element(SimpleCloze, {
4495
+ model: { type: "Object" },
4496
+ session: { type: "Object" }
4497
+ }, [], []);
4498
+ //#endregion
4499
+ //#region src/delivery/index.ts
4500
+ var SvelteElementClass = SimpleCloze.element;
4501
+ var SimpleClozeElement = class extends SvelteElementClass {
4502
+ constructor(..._args) {
4503
+ super(..._args);
4504
+ _defineProperty(this, "_internalSession", null);
4505
+ _defineProperty(this, "onSessionChange", (updatedSession) => {
4506
+ this._internalSession = updatedSession;
4507
+ });
4508
+ }
4509
+ set session(s) {
4510
+ this._internalSession = s;
4511
+ super.session = s;
4512
+ }
4513
+ get session() {
4514
+ return this._internalSession;
4515
+ }
4516
+ connectedCallback() {
4517
+ super.connectedCallback();
4518
+ this.onSessionChange = this.onSessionChange;
4519
+ }
4520
+ };
4521
+ //#endregion
4522
+ export { SimpleClozeElement as default };
4523
+
4524
+ //# sourceMappingURL=index.js.map