@pie-element/venn-classification 0.1.1-next.3 → 0.1.1-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,16 @@
1
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/disclose-version.js
1
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/disclose-version.js
2
2
  if (typeof window !== "undefined") {
3
3
  var _window$__svelte, _window;
4
4
  ((_window$__svelte = (_window = window).__svelte ?? (_window.__svelte = {})).v ?? (_window$__svelte.v = /* @__PURE__ */ new Set())).add("5");
5
5
  }
6
6
  //#endregion
7
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/constants.js
7
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/constants.js
8
8
  var HYDRATION_ERROR = {};
9
9
  var UNINITIALIZED = Symbol("uninitialized");
10
10
  var NAMESPACE_SVG = "http://www.w3.org/2000/svg";
11
11
  var NAMESPACE_MATHML = "http://www.w3.org/1998/Math/MathML";
12
12
  //#endregion
13
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/shared/utils.js
13
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/shared/utils.js
14
14
  var is_array = Array.isArray;
15
15
  var index_of = Array.prototype.indexOf;
16
16
  var includes = Array.prototype.includes;
@@ -67,7 +67,7 @@ function to_array(value, n) {
67
67
  return array;
68
68
  }
69
69
  //#endregion
70
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
70
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
71
71
  function _typeof(o) {
72
72
  "@babel/helpers - typeof";
73
73
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -77,7 +77,7 @@ function _typeof(o) {
77
77
  }, _typeof(o);
78
78
  }
79
79
  //#endregion
80
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
80
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
81
81
  function toPrimitive(t, r) {
82
82
  if ("object" != _typeof(t) || !t) return t;
83
83
  var e = t[Symbol.toPrimitive];
@@ -89,13 +89,13 @@ function toPrimitive(t, r) {
89
89
  return ("string" === r ? String : Number)(t);
90
90
  }
91
91
  //#endregion
92
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
92
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
93
93
  function toPropertyKey(t) {
94
94
  var i = toPrimitive(t, "string");
95
95
  return "symbol" == _typeof(i) ? i : i + "";
96
96
  }
97
97
  //#endregion
98
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
98
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
99
99
  function _defineProperty(e, r, t) {
100
100
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
101
101
  value: t,
@@ -156,7 +156,7 @@ function lifecycle_outside_component(name) {
156
156
  throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
157
157
  }
158
158
  //#endregion
159
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/errors.js
159
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/errors.js
160
160
  /**
161
161
  * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
162
162
  * @returns {never}
@@ -267,7 +267,7 @@ function svelte_boundary_reset_noop() {
267
267
  console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
268
268
  }
269
269
  //#endregion
270
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/hydration.js
270
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/hydration.js
271
271
  /** @import { TemplateNode } from '#client' */
272
272
  /**
273
273
  * Use this variable to guard everything related to hydration code so it can be treeshaken out
@@ -346,7 +346,7 @@ function read_hydration_instruction(node) {
346
346
  return node.data;
347
347
  }
348
348
  //#endregion
349
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/equality.js
349
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/equality.js
350
350
  /** @import { Equals } from '#client' */
351
351
  /** @type {Equals} */
352
352
  function equals(value) {
@@ -365,13 +365,13 @@ function safe_equals(value) {
365
365
  return !safe_not_equal(value, this.v);
366
366
  }
367
367
  //#endregion
368
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/flags/index.js
368
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/flags/index.js
369
369
  /** True if experimental.async=true */
370
370
  var async_mode_flag = false;
371
371
  /** True if we're not certain that we only have Svelte 5 code in the compilation */
372
372
  var legacy_mode_flag = false;
373
373
  //#endregion
374
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/context.js
374
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/context.js
375
375
  /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
376
376
  /** @type {ComponentContext | null} */
377
377
  var component_context = null;
@@ -423,7 +423,7 @@ function is_runes() {
423
423
  return !legacy_mode_flag || component_context !== null && component_context.l === null;
424
424
  }
425
425
  //#endregion
426
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/task.js
426
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/task.js
427
427
  /** @type {Array<() => void>} */
428
428
  var micro_tasks = [];
429
429
  function run_micro_tasks() {
@@ -466,6 +466,7 @@ function handle_error(error) {
466
466
  * @param {Effect | null} effect
467
467
  */
468
468
  function invoke_error_boundary(error, effect) {
469
+ if (effect !== null && (effect.f & 16384) !== 0) return;
469
470
  while (effect !== null) {
470
471
  if ((effect.f & 128) !== 0) {
471
472
  if ((effect.f & 32768) === 0) throw error;
@@ -481,7 +482,7 @@ function invoke_error_boundary(error, effect) {
481
482
  throw error;
482
483
  }
483
484
  //#endregion
484
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/status.js
485
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/status.js
485
486
  /** @import { Derived, Signal } from '#client' */
486
487
  var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
487
488
  /**
@@ -500,7 +501,7 @@ function update_derived_status(derived) {
500
501
  else set_signal_status(derived, MAYBE_DIRTY);
501
502
  }
502
503
  //#endregion
503
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/utils.js
504
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/utils.js
504
505
  /** @import { Derived, Effect, Value } from '#client' */
505
506
  /**
506
507
  * @param {Value[] | null} deps
@@ -528,7 +529,7 @@ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
528
529
  set_signal_status(effect, CLEAN);
529
530
  }
530
531
  //#endregion
531
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/store.js
532
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/store.js
532
533
  /**
533
534
  * We set this to `true` when updating a store so that we correctly
534
535
  * schedule effects if the update takes place inside a `$:` effect
@@ -558,1460 +559,1501 @@ function capture_store_binding(fn) {
558
559
  }
559
560
  }
560
561
  //#endregion
561
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/checkPrivateRedeclaration.js
562
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
563
+ /**
564
+ * @template T
565
+ * @param {() => T} fn
566
+ */
567
+ function without_reactive_context(fn) {
568
+ var previous_reaction = active_reaction;
569
+ var previous_effect = active_effect;
570
+ set_active_reaction(null);
571
+ set_active_effect(null);
572
+ try {
573
+ return fn();
574
+ } finally {
575
+ set_active_reaction(previous_reaction);
576
+ set_active_effect(previous_effect);
577
+ }
578
+ }
579
+ //#endregion
580
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/reactivity/create-subscriber.js
581
+ /**
582
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
583
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
584
+ *
585
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
586
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
587
+ *
588
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
589
+ *
590
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
591
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
592
+ *
593
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
594
+ *
595
+ * ```js
596
+ * import { createSubscriber } from 'svelte/reactivity';
597
+ * import { on } from 'svelte/events';
598
+ *
599
+ * export class MediaQuery {
600
+ * #query;
601
+ * #subscribe;
602
+ *
603
+ * constructor(query) {
604
+ * this.#query = window.matchMedia(`(${query})`);
605
+ *
606
+ * this.#subscribe = createSubscriber((update) => {
607
+ * // when the `change` event occurs, re-run any effects that read `this.current`
608
+ * const off = on(this.#query, 'change', update);
609
+ *
610
+ * // stop listening when all the effects are destroyed
611
+ * return () => off();
612
+ * });
613
+ * }
614
+ *
615
+ * get current() {
616
+ * // This makes the getter reactive, if read in an effect
617
+ * this.#subscribe();
618
+ *
619
+ * // Return the current state of the query, whether or not we're in an effect
620
+ * return this.#query.matches;
621
+ * }
622
+ * }
623
+ * ```
624
+ * @param {(update: () => void) => (() => void) | void} start
625
+ * @since 5.7.0
626
+ */
627
+ function createSubscriber(start) {
628
+ let subscribers = 0;
629
+ let version = source(0);
630
+ /** @type {(() => void) | void} */
631
+ let stop;
632
+ return () => {
633
+ if (effect_tracking()) {
634
+ get(version);
635
+ render_effect(() => {
636
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
637
+ subscribers += 1;
638
+ return () => {
639
+ queue_micro_task(() => {
640
+ subscribers -= 1;
641
+ if (subscribers === 0) {
642
+ stop?.();
643
+ stop = void 0;
644
+ increment(version);
645
+ }
646
+ });
647
+ };
648
+ });
649
+ }
650
+ };
651
+ }
652
+ //#endregion
653
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/checkPrivateRedeclaration.js
562
654
  function _checkPrivateRedeclaration(e, t) {
563
655
  if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
564
656
  }
565
657
  //#endregion
566
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateMethodInitSpec.js
658
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateMethodInitSpec.js
567
659
  function _classPrivateMethodInitSpec(e, a) {
568
660
  _checkPrivateRedeclaration(e, a), a.add(e);
569
661
  }
570
662
  //#endregion
571
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateFieldInitSpec.js
663
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldInitSpec.js
572
664
  function _classPrivateFieldInitSpec(e, t, a) {
573
665
  _checkPrivateRedeclaration(e, t), t.set(e, a);
574
666
  }
575
667
  //#endregion
576
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/assertClassBrand.js
668
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/assertClassBrand.js
577
669
  function _assertClassBrand(e, t, n) {
578
670
  if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
579
671
  throw new TypeError("Private element is not present on this object");
580
672
  }
581
673
  //#endregion
582
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateFieldSet2.js
674
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldSet2.js
583
675
  function _classPrivateFieldSet2(s, a, r) {
584
676
  return s.set(_assertClassBrand(s, a), r), r;
585
677
  }
586
678
  //#endregion
587
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateFieldGet2.js
679
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldGet2.js
588
680
  function _classPrivateFieldGet2(s, a) {
589
681
  return s.get(_assertClassBrand(s, a));
590
682
  }
591
683
  //#endregion
592
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/batch.js
593
- /** @import { Fork } from 'svelte' */
594
- /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
595
- var _Batch;
596
- /** @type {Batch | null} */
597
- var first_batch = null;
598
- /** @type {Batch | null} */
599
- var last_batch = null;
600
- /** @type {Batch | null} */
601
- var current_batch = null;
602
- /**
603
- * This is needed to avoid overwriting inputs
604
- * @type {Batch | null}
605
- */
606
- var previous_batch = null;
607
- /**
608
- * When time travelling (i.e. working in one batch, while other batches
609
- * still have ongoing work), we ignore the real values of affected
610
- * signals in favour of their values within the batch
611
- * @type {Map<Value, any> | null}
612
- */
613
- var batch_values = null;
614
- /** @type {Effect | null} */
615
- var last_scheduled_effect = null;
616
- var is_flushing_sync = false;
617
- var is_processing = false;
684
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
685
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
618
686
  /**
619
- * During traversal, this is an array. Newly created effects are (if not immediately
620
- * executed) pushed to this array, rather than going through the scheduling
621
- * rigamarole that would cause another turn of the flush loop.
622
- * @type {Effect[] | null}
687
+ * @typedef {{
688
+ * onerror?: ((error: unknown, reset: () => void) => void) | null;
689
+ * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
690
+ * pending?: ((anchor: Node) => void) | null;
691
+ * }} BoundaryProps
623
692
  */
624
- var collected_effects = null;
693
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
625
694
  /**
626
- * An array of effects that are marked during traversal as a result of a `set`
627
- * (not `internal_set`) call. These will be added to the next batch and
628
- * trigger another `batch.process()`
629
- * @type {Effect[] | null}
630
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
695
+ * @param {TemplateNode} node
696
+ * @param {BoundaryProps} props
697
+ * @param {((anchor: Node) => void)} children
698
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
699
+ * @returns {void}
631
700
  */
632
- var legacy_updates = null;
633
- var flush_count = 0;
634
- var uid = 1;
635
- var _started = /* @__PURE__ */ new WeakMap();
636
- var _prev = /* @__PURE__ */ new WeakMap();
637
- var _next = /* @__PURE__ */ new WeakMap();
638
- var _commit_callbacks = /* @__PURE__ */ new WeakMap();
639
- var _discard_callbacks = /* @__PURE__ */ new WeakMap();
640
- var _pending = /* @__PURE__ */ new WeakMap();
641
- var _blocking_pending = /* @__PURE__ */ new WeakMap();
642
- var _deferred = /* @__PURE__ */ new WeakMap();
643
- var _roots = /* @__PURE__ */ new WeakMap();
644
- var _new_effects = /* @__PURE__ */ new WeakMap();
701
+ function boundary(node, props, children, transform_error) {
702
+ new Boundary(node, props, children, transform_error);
703
+ }
704
+ var _anchor = /* @__PURE__ */ new WeakMap();
705
+ var _hydrate_open = /* @__PURE__ */ new WeakMap();
706
+ var _props = /* @__PURE__ */ new WeakMap();
707
+ var _children = /* @__PURE__ */ new WeakMap();
708
+ var _effect = /* @__PURE__ */ new WeakMap();
709
+ var _main_effect = /* @__PURE__ */ new WeakMap();
710
+ var _pending_effect = /* @__PURE__ */ new WeakMap();
711
+ var _failed_effect = /* @__PURE__ */ new WeakMap();
712
+ var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
713
+ var _local_pending_count = /* @__PURE__ */ new WeakMap();
714
+ var _pending_count = /* @__PURE__ */ new WeakMap();
715
+ var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
645
716
  var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
646
717
  var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
647
- var _skipped_branches = /* @__PURE__ */ new WeakMap();
648
- var _unskipped_branches = /* @__PURE__ */ new WeakMap();
649
- var _decrement_queued = /* @__PURE__ */ new WeakMap();
650
- var _Batch_brand = /* @__PURE__ */ new WeakSet();
651
- var Batch = class Batch {
652
- constructor() {
653
- _classPrivateMethodInitSpec(this, _Batch_brand);
654
- _defineProperty(this, "id", uid++);
655
- _classPrivateFieldInitSpec(this, _started, false);
656
- _defineProperty(this, "linked", true);
657
- _classPrivateFieldInitSpec(this, _prev, null);
658
- _classPrivateFieldInitSpec(this, _next, null);
659
- _defineProperty(
660
- this,
661
- /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
662
- "async_deriveds",
663
- /* @__PURE__ */ new Map()
664
- );
718
+ var _effect_pending = /* @__PURE__ */ new WeakMap();
719
+ var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
720
+ var _Boundary_brand = /* @__PURE__ */ new WeakSet();
721
+ var Boundary = class {
722
+ /**
723
+ * @param {TemplateNode} node
724
+ * @param {BoundaryProps} props
725
+ * @param {((anchor: Node) => void)} children
726
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
727
+ */
728
+ constructor(node, props, children, transform_error) {
729
+ _classPrivateMethodInitSpec(this, _Boundary_brand);
665
730
  _defineProperty(
666
731
  this,
667
- /**
668
- * The current values of any signals that are updated in this batch.
669
- * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
670
- * They keys of this map are identical to `this.#previous`
671
- * @type {Map<Value, [any, boolean]>}
672
- */
673
- "current",
674
- /* @__PURE__ */ new Map()
732
+ /** @type {Boundary | null} */
733
+ "parent",
734
+ void 0
675
735
  );
736
+ _defineProperty(this, "is_pending", false);
676
737
  _defineProperty(
677
738
  this,
678
739
  /**
679
- * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
680
- * They keys of this map are identical to `this.#current`
681
- * @type {Map<Value, any>}
740
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
741
+ * Inherited from parent boundary, or defaults to identity.
742
+ * @type {(error: unknown) => unknown}
682
743
  */
683
- "previous",
684
- /* @__PURE__ */ new Map()
744
+ "transform_error",
745
+ void 0
685
746
  );
686
- _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
687
- _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
688
- _classPrivateFieldInitSpec(this, _pending, 0);
689
- _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
690
- _classPrivateFieldInitSpec(this, _deferred, null);
691
- _classPrivateFieldInitSpec(this, _roots, []);
692
- _classPrivateFieldInitSpec(this, _new_effects, []);
747
+ _classPrivateFieldInitSpec(this, _anchor, void 0);
748
+ _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
749
+ _classPrivateFieldInitSpec(this, _props, void 0);
750
+ _classPrivateFieldInitSpec(this, _children, void 0);
751
+ _classPrivateFieldInitSpec(this, _effect, void 0);
752
+ _classPrivateFieldInitSpec(this, _main_effect, null);
753
+ _classPrivateFieldInitSpec(this, _pending_effect, null);
754
+ _classPrivateFieldInitSpec(this, _failed_effect, null);
755
+ _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
756
+ _classPrivateFieldInitSpec(this, _local_pending_count, 0);
757
+ _classPrivateFieldInitSpec(this, _pending_count, 0);
758
+ _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
693
759
  _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
694
760
  _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
695
- _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
696
- _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
697
- _defineProperty(this, "is_fork", false);
698
- _classPrivateFieldInitSpec(this, _decrement_queued, false);
699
- if (last_batch === null) first_batch = last_batch = this;
700
- else {
701
- _classPrivateFieldSet2(_next, last_batch, this);
702
- _classPrivateFieldSet2(_prev, this, last_batch);
703
- }
704
- last_batch = this;
705
- }
706
- /**
707
- * Add an effect to the #skipped_branches map and reset its children
708
- * @param {Effect} effect
709
- */
710
- skip_effect(effect) {
711
- if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
712
- d: [],
713
- m: []
714
- });
715
- _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
761
+ _classPrivateFieldInitSpec(this, _effect_pending, null);
762
+ _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
763
+ _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
764
+ return () => {
765
+ _classPrivateFieldSet2(_effect_pending, this, null);
766
+ };
767
+ }));
768
+ _classPrivateFieldSet2(_anchor, this, node);
769
+ _classPrivateFieldSet2(_props, this, props);
770
+ _classPrivateFieldSet2(_children, this, (anchor) => {
771
+ var effect = active_effect;
772
+ effect.b = this;
773
+ effect.f |= 128;
774
+ children(anchor);
775
+ });
776
+ this.parent = active_effect.b;
777
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
778
+ _classPrivateFieldSet2(_effect, this, block(() => {
779
+ if (hydrating) {
780
+ const comment = _classPrivateFieldGet2(_hydrate_open, this);
781
+ hydrate_next();
782
+ const server_rendered_pending = comment.data === "[!";
783
+ if (comment.data.startsWith("[?")) {
784
+ const serialized_error = JSON.parse(comment.data.slice(2));
785
+ _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
786
+ } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
787
+ else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
788
+ } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
789
+ }, flags));
790
+ if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
716
791
  }
717
792
  /**
718
- * Remove an effect from the #skipped_branches map and reschedule
719
- * any tracked dirty/maybe_dirty child effects
793
+ * Defer an effect inside a pending boundary until the boundary resolves
720
794
  * @param {Effect} effect
721
- * @param {(e: Effect) => void} callback
722
- */
723
- unskip_effect(effect, callback = (e) => this.schedule(e)) {
724
- var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
725
- if (tracked) {
726
- _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
727
- for (var e of tracked.d) {
728
- set_signal_status(e, DIRTY);
729
- callback(e);
730
- }
731
- for (e of tracked.m) {
732
- set_signal_status(e, MAYBE_DIRTY);
733
- callback(e);
734
- }
735
- }
736
- _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
737
- }
738
- /**
739
- * Associate a change to a given source with the current
740
- * batch, noting its previous and current values
741
- * @param {Value} source
742
- * @param {any} value
743
- * @param {boolean} [is_derived]
744
795
  */
745
- capture(source, value, is_derived = false) {
746
- if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
747
- if ((source.f & 8388608) === 0) {
748
- this.current.set(source, [value, is_derived]);
749
- batch_values?.set(source, value);
750
- }
751
- if (!this.is_fork) source.v = value;
752
- }
753
- activate() {
754
- current_batch = this;
755
- }
756
- deactivate() {
757
- current_batch = null;
758
- batch_values = null;
759
- }
760
- flush() {
761
- try {
762
- is_processing = true;
763
- current_batch = this;
764
- _assertClassBrand(_Batch_brand, this, _process).call(this);
765
- } finally {
766
- flush_count = 0;
767
- last_scheduled_effect = null;
768
- collected_effects = null;
769
- legacy_updates = null;
770
- is_processing = false;
771
- current_batch = null;
772
- batch_values = null;
773
- old_values.clear();
774
- }
775
- }
776
- discard() {
777
- for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
778
- _classPrivateFieldGet2(_discard_callbacks, this).clear();
779
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
780
- _classPrivateFieldGet2(_deferred, this)?.resolve();
796
+ defer_effect(effect) {
797
+ defer_effect(effect, _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
781
798
  }
782
799
  /**
783
- * @param {Effect} effect
800
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
801
+ * @returns {boolean}
784
802
  */
785
- register_created_effect(effect) {
786
- _classPrivateFieldGet2(_new_effects, this).push(effect);
803
+ is_rendered() {
804
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
787
805
  }
788
- /**
789
- * @param {boolean} blocking
790
- * @param {Effect} effect
791
- */
792
- increment(blocking, effect) {
793
- _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
794
- if (blocking) {
795
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
796
- _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
797
- }
806
+ has_pending_snippet() {
807
+ return !!_classPrivateFieldGet2(_props, this).pending;
798
808
  }
799
809
  /**
800
- * @param {boolean} blocking
801
- * @param {Effect} effect
810
+ * Update the source that powers `$effect.pending()` inside this boundary,
811
+ * and controls when the current `pending` snippet (if any) is removed.
812
+ * Do not call from inside the class
813
+ * @param {1 | -1} d
814
+ * @param {Batch} batch
802
815
  */
803
- decrement(blocking, effect) {
804
- _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
805
- if (blocking) {
806
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
807
- if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
808
- else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
809
- }
810
- if (_classPrivateFieldGet2(_decrement_queued, this)) return;
811
- _classPrivateFieldSet2(_decrement_queued, this, true);
816
+ update_pending_count(d, batch) {
817
+ _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
818
+ _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
819
+ if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
820
+ _classPrivateFieldSet2(_pending_count_update_queued, this, true);
812
821
  queue_micro_task(() => {
813
- _classPrivateFieldSet2(_decrement_queued, this, false);
814
- if (this.linked) this.flush();
822
+ _classPrivateFieldSet2(_pending_count_update_queued, this, false);
823
+ if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
815
824
  });
816
825
  }
817
- /**
818
- * @param {Set<Effect>} dirty_effects
819
- * @param {Set<Effect>} maybe_dirty_effects
820
- */
821
- transfer_effects(dirty_effects, maybe_dirty_effects) {
822
- for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
823
- for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
824
- dirty_effects.clear();
825
- maybe_dirty_effects.clear();
826
- }
827
- /** @param {(batch: Batch) => void} fn */
828
- oncommit(fn) {
829
- _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
830
- }
831
- /** @param {(batch: Batch) => void} fn */
832
- ondiscard(fn) {
833
- _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
834
- }
835
- settled() {
836
- return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
826
+ get_effect_pending() {
827
+ _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
828
+ return get(_classPrivateFieldGet2(_effect_pending, this));
837
829
  }
838
- static ensure() {
839
- if (current_batch === null) {
840
- const batch = current_batch = new Batch();
841
- if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
842
- if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
830
+ /** @param {unknown} error */
831
+ error(error) {
832
+ if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
833
+ if (current_batch?.is_fork) {
834
+ if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
835
+ if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
836
+ if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
837
+ current_batch.oncommit(() => {
838
+ _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
843
839
  });
844
- }
845
- return current_batch;
840
+ } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
846
841
  }
847
- apply() {
848
- if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
849
- batch_values = null;
850
- return;
851
- }
852
- batch_values = /* @__PURE__ */ new Map();
853
- for (const [source, [value]] of this.current) batch_values.set(source, value);
854
- for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
855
- if (batch === this || batch.is_fork) continue;
856
- var intersects = false;
857
- if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
858
- if (is_derived) continue;
859
- if (this.current.has(source)) {
860
- intersects = true;
861
- break;
862
- }
863
- }
864
- if (!intersects) {
865
- for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
866
- }
867
- }
842
+ };
843
+ function _hydrate_resolved_content() {
844
+ try {
845
+ _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
846
+ } catch (error) {
847
+ this.error(error);
868
848
  }
869
- /**
870
- *
871
- * @param {Effect} effect
872
- */
873
- schedule(effect) {
874
- last_scheduled_effect = effect;
875
- if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
876
- effect.b.defer_effect(effect);
849
+ }
850
+ /**
851
+ * @param {unknown} error The deserialized error from the server's hydration comment
852
+ */
853
+ function _hydrate_failed_content(error) {
854
+ const failed = _classPrivateFieldGet2(_props, this).failed;
855
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, error);
856
+ queue_micro_task(invoke_onerror);
857
+ if (!failed) return;
858
+ _classPrivateFieldSet2(_failed_effect, this, branch(() => {
859
+ failed(_classPrivateFieldGet2(_anchor, this), () => error, () => reset);
860
+ }));
861
+ }
862
+ /**
863
+ * Creates the `reset` function for a failed boundary, along with a function
864
+ * that invokes `onerror` with it (if provided)
865
+ * @param {unknown} error
866
+ * @returns {{ reset: () => void, invoke_onerror: () => void }}
867
+ */
868
+ function _create_reset(error) {
869
+ var did_reset = false;
870
+ var calling_on_error = false;
871
+ const reset = () => {
872
+ if (did_reset) {
873
+ svelte_boundary_reset_noop();
877
874
  return;
878
875
  }
879
- var e = effect;
880
- while (e.parent !== null) {
881
- e = e.parent;
882
- var flags = e.f;
883
- if (collected_effects !== null && e === active_effect) {
884
- if (async_mode_flag) return;
885
- if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
886
- }
887
- if ((flags & 96) !== 0) {
888
- if ((flags & 1024) === 0) return;
889
- e.f ^= CLEAN;
890
- }
876
+ did_reset = true;
877
+ if (calling_on_error) svelte_boundary_reset_onerror();
878
+ if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
879
+ _classPrivateFieldSet2(_failed_effect, this, null);
880
+ });
881
+ _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
882
+ _assertClassBrand(_Boundary_brand, this, _render).call(this);
883
+ });
884
+ };
885
+ const invoke_onerror = () => {
886
+ try {
887
+ calling_on_error = true;
888
+ _classPrivateFieldGet2(_props, this).onerror?.(error, reset);
889
+ calling_on_error = false;
890
+ } catch (err) {
891
+ invoke_error_boundary(err, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
891
892
  }
892
- _classPrivateFieldGet2(_roots, this).push(e);
893
- }
894
- };
895
- _Batch = Batch;
896
- function _is_deferred() {
897
- if (this.is_fork) return true;
898
- for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
899
- var e = effect;
900
- var skipped = false;
901
- while (e.parent !== null) {
902
- if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
903
- skipped = true;
904
- break;
905
- }
906
- e = e.parent;
893
+ };
894
+ return {
895
+ reset,
896
+ invoke_onerror
897
+ };
898
+ }
899
+ function _hydrate_pending_content() {
900
+ const pending = _classPrivateFieldGet2(_props, this).pending;
901
+ if (!pending) return;
902
+ this.is_pending = true;
903
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
904
+ queue_micro_task(() => {
905
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
906
+ var anchor = create_text();
907
+ fragment.append(anchor);
908
+ _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
909
+ return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
910
+ }));
911
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
912
+ _classPrivateFieldGet2(_anchor, this).before(fragment);
913
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
914
+ pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
915
+ _classPrivateFieldSet2(_pending_effect, this, null);
916
+ });
917
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
907
918
  }
908
- if (!skipped) return true;
909
- }
910
- return false;
919
+ });
911
920
  }
912
- function _process() {
913
- _classPrivateFieldSet2(_started, this, true);
914
- if (flush_count++ > 1e3) {
915
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
916
- infinite_loop_guard();
917
- }
918
- for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
919
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
920
- set_signal_status(e, DIRTY);
921
- this.schedule(e);
922
- }
923
- for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
924
- set_signal_status(e, MAYBE_DIRTY);
925
- this.schedule(e);
921
+ function _render() {
922
+ try {
923
+ this.is_pending = this.has_pending_snippet();
924
+ _classPrivateFieldSet2(_pending_count, this, 0);
925
+ _classPrivateFieldSet2(_local_pending_count, this, 0);
926
+ _classPrivateFieldSet2(_main_effect, this, branch(() => {
927
+ _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
928
+ }));
929
+ if (_classPrivateFieldGet2(_pending_count, this) > 0) {
930
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
931
+ move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
932
+ const pending = _classPrivateFieldGet2(_props, this).pending;
933
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
934
+ } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
935
+ } catch (error) {
936
+ this.error(error);
926
937
  }
927
- const roots = _classPrivateFieldGet2(_roots, this);
928
- _classPrivateFieldSet2(_roots, this, []);
929
- this.apply();
930
- /** @type {Effect[]} */
931
- var effects = collected_effects = [];
932
- /** @type {Effect[]} */
933
- var render_effects = [];
934
- /**
935
- * @type {Effect[]}
936
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
937
- */
938
- var updates = legacy_updates = [];
939
- for (const root of roots) try {
940
- _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
938
+ }
939
+ /**
940
+ * @param {Batch} batch
941
+ */
942
+ function _resolve(batch) {
943
+ this.is_pending = false;
944
+ batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
945
+ }
946
+ /**
947
+ * @template T
948
+ * @param {() => T} fn
949
+ */
950
+ function _run(fn) {
951
+ var previous_effect = active_effect;
952
+ var previous_reaction = active_reaction;
953
+ var previous_ctx = component_context;
954
+ set_active_effect(_classPrivateFieldGet2(_effect, this));
955
+ set_active_reaction(_classPrivateFieldGet2(_effect, this));
956
+ set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
957
+ try {
958
+ Batch.ensure();
959
+ return fn();
941
960
  } catch (e) {
942
- reset_all(root);
943
- if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
944
- throw e;
945
- }
946
- current_batch = null;
947
- if (updates.length > 0) {
948
- var batch = _Batch.ensure();
949
- for (const e of updates) batch.schedule(e);
950
- }
951
- collected_effects = null;
952
- legacy_updates = null;
953
- if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
954
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
955
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
956
- for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
957
- if (updates.length > 0)
958
- /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
959
- return;
961
+ handle_error(e);
962
+ return null;
963
+ } finally {
964
+ set_active_effect(previous_effect);
965
+ set_active_reaction(previous_reaction);
966
+ set_component_context(previous_ctx);
960
967
  }
961
- const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
962
- if (earlier_batch) {
963
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
964
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
965
- _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
968
+ }
969
+ /**
970
+ * Updates the pending count associated with the currently visible pending snippet,
971
+ * if any, such that we can replace the snippet with content once work is done
972
+ * @param {1 | -1} d
973
+ * @param {Batch} batch
974
+ */
975
+ function _update_pending_count(d, batch) {
976
+ if (!this.has_pending_snippet()) {
977
+ if (this.parent) {
978
+ var _this$parent;
979
+ _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
980
+ }
966
981
  return;
967
982
  }
968
- _classPrivateFieldGet2(_dirty_effects$1, this).clear();
969
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
970
- for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
971
- _classPrivateFieldGet2(_commit_callbacks, this).clear();
972
- previous_batch = this;
973
- flush_queued_effects(render_effects);
974
- flush_queued_effects(effects);
975
- previous_batch = null;
976
- _classPrivateFieldGet2(_deferred, this)?.resolve();
977
- var next_batch = current_batch;
978
- if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
979
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
980
- if (async_mode_flag) {
981
- _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
982
- current_batch = next_batch;
983
+ _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
984
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
985
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
986
+ if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
987
+ _classPrivateFieldSet2(_pending_effect, this, null);
988
+ });
989
+ if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
990
+ _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
991
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
983
992
  }
984
993
  }
985
- if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
986
- const batch = next_batch;
987
- _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
988
- } else next_batch = this;
989
- if (next_batch !== null) _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
990
994
  }
991
995
  /**
992
- * Traverse the effect tree, executing effects or stashing
993
- * them for later execution as appropriate
994
- * @param {Effect} root
995
- * @param {Effect[]} effects
996
- * @param {Effect[]} render_effects
996
+ * @param {unknown} error
997
997
  */
998
- function _traverse(root, effects, render_effects) {
999
- root.f ^= CLEAN;
1000
- var effect = root.first;
1001
- while (effect !== null) {
1002
- var flags = effect.f;
1003
- var is_branch = (flags & 96) !== 0;
1004
- if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1005
- if (is_branch) effect.f ^= CLEAN;
1006
- else if ((flags & 4) !== 0) effects.push(effect);
1007
- else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1008
- else if (is_dirty(effect)) {
1009
- if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
1010
- update_effect(effect);
1011
- }
1012
- var child = effect.first;
1013
- if (child !== null) {
1014
- effect = child;
1015
- continue;
1016
- }
1017
- }
1018
- while (effect !== null) {
1019
- var next = effect.next;
1020
- if (next !== null) {
1021
- effect = next;
1022
- break;
1023
- }
1024
- effect = effect.parent;
1025
- }
998
+ function _handle_error(error) {
999
+ if (_classPrivateFieldGet2(_main_effect, this)) {
1000
+ destroy_effect(_classPrivateFieldGet2(_main_effect, this));
1001
+ _classPrivateFieldSet2(_main_effect, this, null);
1026
1002
  }
1027
- }
1028
- function _find_earlier_batch() {
1029
- var batch = _classPrivateFieldGet2(_prev, this);
1030
- while (batch !== null) {
1031
- if (!batch.is_fork) {
1032
- for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
1033
- }
1034
- batch = _classPrivateFieldGet2(_prev, batch);
1003
+ if (_classPrivateFieldGet2(_pending_effect, this)) {
1004
+ destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
1005
+ _classPrivateFieldSet2(_pending_effect, this, null);
1035
1006
  }
1036
- return null;
1007
+ if (_classPrivateFieldGet2(_failed_effect, this)) {
1008
+ destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
1009
+ _classPrivateFieldSet2(_failed_effect, this, null);
1010
+ }
1011
+ if (hydrating) {
1012
+ set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
1013
+ next();
1014
+ set_hydrate_node(skip_nodes());
1015
+ }
1016
+ let failed = _classPrivateFieldGet2(_props, this).failed;
1017
+ /** @param {unknown} transformed_error */
1018
+ const handle_error_result = (transformed_error) => {
1019
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, transformed_error);
1020
+ invoke_onerror();
1021
+ if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1022
+ try {
1023
+ return branch(() => {
1024
+ var effect = active_effect;
1025
+ effect.b = this;
1026
+ effect.f |= 128;
1027
+ failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
1028
+ });
1029
+ } catch (error) {
1030
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
1031
+ return null;
1032
+ }
1033
+ }));
1034
+ };
1035
+ queue_micro_task(() => {
1036
+ /** @type {unknown} */
1037
+ var result;
1038
+ try {
1039
+ result = this.transform_error(error);
1040
+ } catch (e) {
1041
+ invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1042
+ return;
1043
+ }
1044
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
1045
+ /** @type {any} */ result.then(
1046
+ handle_error_result,
1047
+ /** @param {unknown} e */
1048
+ (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
1049
+ );
1050
+ else handle_error_result(result);
1051
+ });
1037
1052
  }
1053
+ //#endregion
1054
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/async.js
1055
+ /** @import { Blocker, Effect, Source, Value } from '#client' */
1038
1056
  /**
1039
- * @param {Batch} batch
1057
+ * @param {Blocker[]} blockers
1058
+ * @param {Array<() => any>} sync
1059
+ * @param {Array<() => Promise<any>>} async
1060
+ * @param {(values: Value[]) => any} fn
1040
1061
  */
1041
- function _merge(batch) {
1042
- for (const [source, value] of batch.current) {
1043
- if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1044
- this.current.set(source, value);
1045
- }
1046
- for (const [effect, deferred] of batch.async_deriveds) {
1047
- const d = this.async_deriveds.get(effect);
1048
- if (d) deferred.promise.then(d.resolve).catch(d.reject);
1062
+ function flatten(blockers, sync, async, fn) {
1063
+ const d = is_runes() ? derived : derived_safe_equal;
1064
+ var pending = blockers.filter((b) => !b.settled);
1065
+ var deriveds = sync.map(d);
1066
+ if (async.length === 0 && pending.length === 0) {
1067
+ fn(deriveds);
1068
+ return;
1049
1069
  }
1050
- this.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, batch), _classPrivateFieldGet2(_maybe_dirty_effects$1, batch));
1070
+ var parent = active_effect;
1071
+ var restore = capture();
1072
+ var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
1051
1073
  /**
1052
- * mark all effects that depend on `batch.current`, except the
1053
- * async effects that we just resolved (TODO unless they depend
1054
- * on values in this batch that are NOT in the later batch?).
1055
- * Through this we also will populate the correct #skipped_branches,
1056
- * oncommit callbacks etc, so we don't need to merge them separately.
1057
- * @param {Value} value
1074
+ * @param {Source[]} async
1058
1075
  */
1059
- const mark = (value) => {
1060
- var reactions = value.reactions;
1061
- if (reactions === null) return;
1062
- for (const reaction of reactions) {
1063
- var flags = reaction.f;
1064
- if ((flags & 2) !== 0) mark(reaction);
1065
- else {
1066
- var effect = reaction;
1067
- if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1068
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(effect);
1069
- set_signal_status(effect, DIRTY);
1070
- this.schedule(effect);
1071
- }
1072
- }
1076
+ function finish(async) {
1077
+ if ((parent.f & 16384) !== 0) return;
1078
+ restore();
1079
+ try {
1080
+ fn([...deriveds, ...async]);
1081
+ } catch (error) {
1082
+ invoke_error_boundary(error, parent);
1083
+ }
1084
+ unset_context();
1085
+ }
1086
+ var decrement_pending = increment_pending();
1087
+ if (async.length === 0) {
1088
+ /** @type {Promise<any>} */ blocker_promise.then(() => finish([])).finally(decrement_pending);
1089
+ return;
1090
+ }
1091
+ function run() {
1092
+ Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then(finish).catch((error) => invoke_error_boundary(error, parent)).finally(decrement_pending);
1093
+ }
1094
+ if (blocker_promise) blocker_promise.then(() => {
1095
+ restore();
1096
+ run();
1097
+ unset_context();
1098
+ });
1099
+ else run();
1100
+ }
1101
+ /**
1102
+ * Captures the current effect context so that we can restore it after
1103
+ * some asynchronous work has happened (so that e.g. `await a + b`
1104
+ * causes `b` to be registered as a dependency).
1105
+ */
1106
+ function capture() {
1107
+ var previous_effect = active_effect;
1108
+ var previous_reaction = active_reaction;
1109
+ var previous_component_context = component_context;
1110
+ var previous_batch = current_batch;
1111
+ return function restore(activate_batch = true) {
1112
+ set_active_effect(previous_effect);
1113
+ set_active_reaction(previous_reaction);
1114
+ set_component_context(previous_component_context);
1115
+ if (activate_batch && (previous_effect.f & 16384) === 0) {
1116
+ previous_batch?.activate();
1117
+ previous_batch?.apply();
1073
1118
  }
1074
1119
  };
1075
- for (const source of this.current.keys()) mark(source);
1076
- this.oncommit(() => batch.discard());
1077
- _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1078
- current_batch = this;
1079
- _assertClassBrand(_Batch_brand, this, _process).call(this);
1080
1120
  }
1121
+ function unset_context(deactivate_batch = true) {
1122
+ set_active_effect(null);
1123
+ set_active_reaction(null);
1124
+ set_component_context(null);
1125
+ if (deactivate_batch) current_batch?.deactivate();
1126
+ }
1127
+ /**
1128
+ * @returns {(skip?: boolean) => void}
1129
+ */
1130
+ function increment_pending() {
1131
+ var effect = active_effect;
1132
+ var boundary = effect.b;
1133
+ var batch = current_batch;
1134
+ var blocking = !!boundary?.is_rendered();
1135
+ boundary?.update_pending_count(1, batch);
1136
+ batch.increment(blocking, effect);
1137
+ return () => {
1138
+ boundary?.update_pending_count(-1, batch);
1139
+ batch.decrement(blocking, effect);
1140
+ };
1141
+ }
1142
+ /**
1143
+ * @template V
1144
+ * @param {() => V} fn
1145
+ * @returns {Derived<V>}
1146
+ */
1147
+ /*#__NO_SIDE_EFFECTS__*/
1148
+ function derived(fn) {
1149
+ var flags = 2 | DIRTY;
1150
+ if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
1151
+ return {
1152
+ ctx: component_context,
1153
+ deps: null,
1154
+ effects: null,
1155
+ equals,
1156
+ f: flags,
1157
+ fn,
1158
+ reactions: null,
1159
+ rv: 0,
1160
+ v: UNINITIALIZED,
1161
+ wv: 0,
1162
+ parent: active_effect,
1163
+ ac: null
1164
+ };
1165
+ }
1166
+ var OBSOLETE = Symbol("obsolete");
1081
1167
  /**
1082
- * @param {Effect[]} effects
1168
+ * @template V
1169
+ * @param {() => V | Promise<V>} fn
1170
+ * @param {string} [label]
1171
+ * @param {string} [location] If provided, print a warning if the value is not read immediately after update
1172
+ * @returns {Promise<Source<V>>}
1083
1173
  */
1084
- function _defer_effects(effects) {
1085
- for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
1086
- }
1087
- function _commit$1() {
1088
- for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1089
- var is_earlier = batch.id < this.id;
1090
- /** @type {Source[]} */
1091
- var sources = [];
1092
- for (const [source, [value, is_derived]] of this.current) {
1093
- if (batch.current.has(source)) {
1094
- var batch_value = batch.current.get(source)[0];
1095
- if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1096
- else continue;
1097
- }
1098
- sources.push(source);
1174
+ /*#__NO_SIDE_EFFECTS__*/
1175
+ function async_derived(fn, label, location) {
1176
+ let parent = active_effect;
1177
+ if (parent === null) async_derived_orphan();
1178
+ var promise = void 0;
1179
+ var signal = source(UNINITIALIZED);
1180
+ var should_suspend = !active_reaction;
1181
+ /** @type {Set<ReturnType<typeof deferred<V>>>} */
1182
+ var deferreds = /* @__PURE__ */ new Set();
1183
+ async_effect(() => {
1184
+ var effect = active_effect;
1185
+ /** @type {ReturnType<typeof deferred<V>>} */
1186
+ var d = deferred();
1187
+ promise = d.promise;
1188
+ try {
1189
+ Promise.resolve(fn()).then(d.resolve, (e) => {
1190
+ if (e !== STALE_REACTION) d.reject(e);
1191
+ }).finally(unset_context);
1192
+ } catch (error) {
1193
+ d.reject(error);
1194
+ unset_context();
1099
1195
  }
1100
- if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1101
- const d = batch.async_deriveds.get(effect);
1102
- if (d) deferred.promise.then(d.resolve).catch(d.reject);
1196
+ var batch = current_batch;
1197
+ if (should_suspend) {
1198
+ if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
1199
+ if (parent.b?.is_rendered()) batch.async_deriveds.get(effect)?.reject(OBSOLETE);
1200
+ else for (const d of deferreds.values()) d.reject(OBSOLETE);
1201
+ deferreds.add(d);
1202
+ batch.async_deriveds.set(effect, d);
1103
1203
  }
1104
- if (!_classPrivateFieldGet2(_started, batch)) continue;
1105
- var others = [...batch.current.keys()].filter((s) => !batch.current.get(s)[1] && !this.current.has(s));
1106
- if (others.length === 0) {
1107
- if (is_earlier) batch.discard();
1108
- } else if (sources.length > 0) {
1109
- if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1110
- if ((e.f & 4194320) !== 0) batch.schedule(e);
1111
- else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1112
- });
1204
+ /**
1205
+ * @param {any} value
1206
+ * @param {unknown} error
1207
+ */
1208
+ const handler = (value, error = void 0) => {
1209
+ decrement_pending?.();
1210
+ deferreds.delete(d);
1211
+ if (error === OBSOLETE) return;
1113
1212
  batch.activate();
1114
- /** @type {Set<Value>} */
1115
- var marked = /* @__PURE__ */ new Set();
1116
- /** @type {Map<Reaction, boolean>} */
1117
- var checked = /* @__PURE__ */ new Map();
1118
- for (var source of sources) mark_effects(source, others, marked, checked);
1119
- checked = /* @__PURE__ */ new Map();
1120
- var current_unequal = [...batch.current].filter(([c, v1]) => {
1121
- const v2 = this.current.get(c);
1122
- if (!v2) return true;
1123
- return v2[0] !== v1[0] || v2[1] !== v1[1];
1124
- }).map(([c]) => c);
1125
- if (current_unequal.length > 0) {
1126
- for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1127
- set_signal_status(effect, DIRTY);
1128
- batch.schedule(effect);
1129
- } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1130
- }
1131
- if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1132
- batch.apply();
1133
- for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1134
- _classPrivateFieldSet2(_roots, batch, []);
1213
+ if (error) {
1214
+ signal.f |= ERROR_VALUE;
1215
+ internal_set(signal, error);
1216
+ } else {
1217
+ if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
1218
+ internal_set(signal, value);
1135
1219
  }
1136
1220
  batch.deactivate();
1221
+ };
1222
+ d.promise.then(handler, (e) => handler(null, e || "unknown"));
1223
+ });
1224
+ teardown(() => {
1225
+ for (const d of deferreds) d.reject(OBSOLETE);
1226
+ });
1227
+ return new Promise((fulfil) => {
1228
+ /** @param {Promise<V>} p */
1229
+ function next(p) {
1230
+ function go() {
1231
+ if (p === promise) fulfil(signal);
1232
+ else next(promise);
1233
+ }
1234
+ p.then(go, go);
1137
1235
  }
1138
- }
1139
- }
1140
- function _unlink() {
1141
- if (!this.linked) return;
1142
- var prev = _classPrivateFieldGet2(_prev, this);
1143
- var next = _classPrivateFieldGet2(_next, this);
1144
- if (prev === null) first_batch = next;
1145
- else _classPrivateFieldSet2(_next, prev, next);
1146
- if (next === null) last_batch = prev;
1147
- else _classPrivateFieldSet2(_prev, next, prev);
1148
- this.linked = false;
1236
+ next(promise);
1237
+ });
1149
1238
  }
1150
1239
  /**
1151
- * Synchronously flush any pending updates.
1152
- * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1153
- * @template [T=void]
1154
- * @param {(() => T) | undefined} [fn]
1155
- * @returns {T}
1240
+ * @template V
1241
+ * @param {() => V} fn
1242
+ * @returns {Derived<V>}
1156
1243
  */
1157
- function flushSync(fn) {
1158
- var was_flushing_sync = is_flushing_sync;
1159
- is_flushing_sync = true;
1160
- try {
1161
- var result;
1162
- if (fn) {
1163
- if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1164
- result = fn();
1165
- }
1166
- while (true) {
1167
- flush_tasks();
1168
- if (current_batch === null) return result;
1169
- current_batch.flush();
1170
- }
1171
- } finally {
1172
- is_flushing_sync = was_flushing_sync;
1173
- }
1174
- }
1175
- function infinite_loop_guard() {
1176
- try {
1177
- effect_update_depth_exceeded();
1178
- } catch (error) {
1179
- invoke_error_boundary(error, last_scheduled_effect);
1180
- }
1244
+ /*#__NO_SIDE_EFFECTS__*/
1245
+ function user_derived(fn) {
1246
+ const d = /* @__PURE__ */ derived(fn);
1247
+ if (!async_mode_flag) push_reaction_value(d);
1248
+ return d;
1181
1249
  }
1182
- /** @type {Set<Effect> | null} */
1183
- var eager_block_effects = null;
1184
1250
  /**
1185
- * @param {Array<Effect>} effects
1186
- * @returns {void}
1251
+ * @template V
1252
+ * @param {() => V} fn
1253
+ * @returns {Derived<V>}
1187
1254
  */
1188
- function flush_queued_effects(effects) {
1189
- var length = effects.length;
1190
- if (length === 0) return;
1191
- var i = 0;
1192
- while (i < length) {
1193
- var effect = effects[i++];
1194
- if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1195
- eager_block_effects = /* @__PURE__ */ new Set();
1196
- update_effect(effect);
1197
- if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1198
- if (eager_block_effects?.size > 0) {
1199
- old_values.clear();
1200
- for (const e of eager_block_effects) {
1201
- if ((e.f & 24576) !== 0) continue;
1202
- /** @type {Effect[]} */
1203
- const ordered_effects = [e];
1204
- let ancestor = e.parent;
1205
- while (ancestor !== null) {
1206
- if (eager_block_effects.has(ancestor)) {
1207
- eager_block_effects.delete(ancestor);
1208
- ordered_effects.push(ancestor);
1209
- }
1210
- ancestor = ancestor.parent;
1211
- }
1212
- for (let j = ordered_effects.length - 1; j >= 0; j--) {
1213
- const e = ordered_effects[j];
1214
- if ((e.f & 24576) !== 0) continue;
1215
- update_effect(e);
1216
- }
1217
- }
1218
- eager_block_effects.clear();
1219
- }
1220
- }
1221
- }
1222
- eager_block_effects = null;
1255
+ /*#__NO_SIDE_EFFECTS__*/
1256
+ function derived_safe_equal(fn) {
1257
+ const signal = /* @__PURE__ */ derived(fn);
1258
+ signal.equals = safe_equals;
1259
+ return signal;
1223
1260
  }
1224
1261
  /**
1225
- * This is similar to `mark_reactions`, but it only marks async/block effects
1226
- * depending on `value` and at least one of the other `sources`, so that
1227
- * these effects can re-run after another batch has been committed
1228
- * @param {Value} value
1229
- * @param {Source[]} sources
1230
- * @param {Set<Value>} marked
1231
- * @param {Map<Reaction, boolean>} checked
1262
+ * @param {Derived} derived
1263
+ * @returns {void}
1232
1264
  */
1233
- function mark_effects(value, sources, marked, checked) {
1234
- if (marked.has(value)) return;
1235
- marked.add(value);
1236
- if (value.reactions !== null) for (const reaction of value.reactions) {
1237
- const flags = reaction.f;
1238
- if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1239
- else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1240
- set_signal_status(reaction, DIRTY);
1241
- schedule_effect(reaction);
1242
- }
1265
+ function destroy_derived_effects(derived) {
1266
+ var effects = derived.effects;
1267
+ if (effects !== null) {
1268
+ derived.effects = null;
1269
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1243
1270
  }
1244
1271
  }
1245
1272
  /**
1246
- * @param {Reaction} reaction
1247
- * @param {Source[]} sources
1248
- * @param {Map<Reaction, boolean>} checked
1273
+ * @template T
1274
+ * @param {Derived} derived
1275
+ * @returns {T}
1249
1276
  */
1250
- function depends_on(reaction, sources, checked) {
1251
- const depends = checked.get(reaction);
1252
- if (depends !== void 0) return depends;
1253
- if (reaction.deps !== null) for (const dep of reaction.deps) {
1254
- if (includes.call(sources, dep)) return true;
1255
- if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1256
- checked.set(dep, true);
1257
- return true;
1258
- }
1277
+ function execute_derived(derived) {
1278
+ var value;
1279
+ var prev_active_effect = active_effect;
1280
+ var parent = derived.parent;
1281
+ if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
1282
+ derived_inert();
1283
+ return derived.v;
1284
+ }
1285
+ set_active_effect(parent);
1286
+ try {
1287
+ derived.f &= ~WAS_MARKED;
1288
+ destroy_derived_effects(derived);
1289
+ value = update_reaction(derived);
1290
+ } finally {
1291
+ set_active_effect(prev_active_effect);
1259
1292
  }
1260
- checked.set(reaction, false);
1261
- return false;
1293
+ return value;
1262
1294
  }
1263
1295
  /**
1264
- * @param {Effect} effect
1296
+ * @param {Derived} derived
1265
1297
  * @returns {void}
1266
1298
  */
1267
- function schedule_effect(effect) {
1268
- /** @type {Batch} */ current_batch.schedule(effect);
1299
+ function update_derived(derived) {
1300
+ var value = execute_derived(derived);
1301
+ if (!derived.equals(value)) {
1302
+ derived.wv = increment_write_version();
1303
+ if (!current_batch?.is_fork || derived.deps === null) {
1304
+ if (current_batch !== null) {
1305
+ current_batch.capture(derived, value, true);
1306
+ previous_batch?.capture(derived, value, true);
1307
+ } else derived.v = value;
1308
+ if (derived.deps === null) {
1309
+ set_signal_status(derived, CLEAN);
1310
+ return;
1311
+ }
1312
+ }
1313
+ }
1314
+ if (is_destroying_effect) return;
1315
+ if (batch_values !== null) {
1316
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1317
+ } else update_derived_status(derived);
1269
1318
  }
1270
1319
  /**
1271
- * Mark all the effects inside a skipped branch CLEAN, so that
1272
- * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1273
- * effects so they can be rescheduled if the branch survives.
1274
- * @param {Effect} effect
1275
- * @param {{ d: Effect[], m: Effect[] }} tracked
1320
+ * @param {Derived} derived
1276
1321
  */
1277
- function reset_branch(effect, tracked) {
1278
- if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1279
- if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1280
- else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1281
- set_signal_status(effect, CLEAN);
1282
- var e = effect.first;
1283
- while (e !== null) {
1284
- reset_branch(e, tracked);
1285
- e = e.next;
1322
+ function freeze_derived_effects(derived) {
1323
+ if (derived.effects === null) return;
1324
+ for (const e of derived.effects) if (e.teardown || e.ac) {
1325
+ e.teardown?.();
1326
+ if (e.ac !== null) without_reactive_context(() => {
1327
+ /** @type {AbortController} */ e.ac.abort(STALE_REACTION);
1328
+ e.ac = null;
1329
+ });
1330
+ if (e.fn !== null) e.teardown = noop;
1331
+ remove_reactions(e, 0);
1332
+ destroy_effect_children(e);
1286
1333
  }
1287
1334
  }
1288
1335
  /**
1289
- * Mark an entire effect tree clean following an error
1290
- * @param {Effect} effect
1336
+ * @param {Derived} derived
1291
1337
  */
1292
- function reset_all(effect) {
1293
- set_signal_status(effect, CLEAN);
1294
- var e = effect.first;
1295
- while (e !== null) {
1296
- reset_all(e);
1297
- e = e.next;
1298
- }
1338
+ function unfreeze_derived_effects(derived) {
1339
+ if (derived.effects === null) return;
1340
+ for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
1299
1341
  }
1300
1342
  //#endregion
1301
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/reactivity/create-subscriber.js
1343
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/batch.js
1344
+ /** @import { Fork } from 'svelte' */
1345
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
1346
+ var _Batch;
1347
+ /** @type {Batch | null} */
1348
+ var first_batch = null;
1349
+ /** @type {Batch | null} */
1350
+ var last_batch = null;
1351
+ /** @type {Batch | null} */
1352
+ var current_batch = null;
1302
1353
  /**
1303
- * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
1304
- * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
1305
- *
1306
- * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
1307
- * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
1308
- *
1309
- * If `start` returns a cleanup function, it will be called when the effect is destroyed.
1310
- *
1311
- * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
1312
- * are active, and the returned teardown function will only be called when all effects are destroyed.
1313
- *
1314
- * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
1315
- *
1316
- * ```js
1317
- * import { createSubscriber } from 'svelte/reactivity';
1318
- * import { on } from 'svelte/events';
1319
- *
1320
- * export class MediaQuery {
1321
- * #query;
1322
- * #subscribe;
1323
- *
1324
- * constructor(query) {
1325
- * this.#query = window.matchMedia(`(${query})`);
1326
- *
1327
- * this.#subscribe = createSubscriber((update) => {
1328
- * // when the `change` event occurs, re-run any effects that read `this.current`
1329
- * const off = on(this.#query, 'change', update);
1330
- *
1331
- * // stop listening when all the effects are destroyed
1332
- * return () => off();
1333
- * });
1334
- * }
1335
- *
1336
- * get current() {
1337
- * // This makes the getter reactive, if read in an effect
1338
- * this.#subscribe();
1339
- *
1340
- * // Return the current state of the query, whether or not we're in an effect
1341
- * return this.#query.matches;
1342
- * }
1343
- * }
1344
- * ```
1345
- * @param {(update: () => void) => (() => void) | void} start
1346
- * @since 5.7.0
1354
+ * This is needed to avoid overwriting inputs
1355
+ * @type {Batch | null}
1347
1356
  */
1348
- function createSubscriber(start) {
1349
- let subscribers = 0;
1350
- let version = source(0);
1351
- /** @type {(() => void) | void} */
1352
- let stop;
1353
- return () => {
1354
- if (effect_tracking()) {
1355
- get(version);
1356
- render_effect(() => {
1357
- if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
1358
- subscribers += 1;
1359
- return () => {
1360
- queue_micro_task(() => {
1361
- subscribers -= 1;
1362
- if (subscribers === 0) {
1363
- stop?.();
1364
- stop = void 0;
1365
- increment(version);
1366
- }
1367
- });
1368
- };
1369
- });
1370
- }
1371
- };
1372
- }
1373
- //#endregion
1374
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
1375
- /** @import { Effect, Source, TemplateNode, } from '#client' */
1357
+ var previous_batch = null;
1376
1358
  /**
1377
- * @typedef {{
1378
- * onerror?: ((error: unknown, reset: () => void) => void) | null;
1379
- * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
1380
- * pending?: ((anchor: Node) => void) | null;
1381
- * }} BoundaryProps
1359
+ * When time travelling (i.e. working in one batch, while other batches
1360
+ * still have ongoing work), we ignore the real values of affected
1361
+ * signals in favour of their values within the batch
1362
+ * @type {Map<Value, any> | null}
1382
1363
  */
1383
- var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
1364
+ var batch_values = null;
1365
+ /** @type {Effect | null} */
1366
+ var last_scheduled_effect = null;
1367
+ var is_flushing_sync = false;
1368
+ var is_processing = false;
1384
1369
  /**
1385
- * @param {TemplateNode} node
1386
- * @param {BoundaryProps} props
1387
- * @param {((anchor: Node) => void)} children
1388
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
1389
- * @returns {void}
1370
+ * During traversal, this is an array. Newly created effects are (if not immediately
1371
+ * executed) pushed to this array, rather than going through the scheduling
1372
+ * rigamarole that would cause another turn of the flush loop.
1373
+ * @type {Effect[] | null}
1390
1374
  */
1391
- function boundary(node, props, children, transform_error) {
1392
- new Boundary(node, props, children, transform_error);
1393
- }
1394
- var _anchor = /* @__PURE__ */ new WeakMap();
1395
- var _hydrate_open = /* @__PURE__ */ new WeakMap();
1396
- var _props = /* @__PURE__ */ new WeakMap();
1397
- var _children = /* @__PURE__ */ new WeakMap();
1398
- var _effect = /* @__PURE__ */ new WeakMap();
1399
- var _main_effect = /* @__PURE__ */ new WeakMap();
1400
- var _pending_effect = /* @__PURE__ */ new WeakMap();
1401
- var _failed_effect = /* @__PURE__ */ new WeakMap();
1402
- var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
1403
- var _local_pending_count = /* @__PURE__ */ new WeakMap();
1404
- var _pending_count = /* @__PURE__ */ new WeakMap();
1405
- var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
1375
+ var collected_effects = null;
1376
+ /**
1377
+ * An array of effects that are marked during traversal as a result of a `set`
1378
+ * (not `internal_set`) call. These will be added to the next batch and
1379
+ * trigger another `batch.process()`
1380
+ * @type {Effect[] | null}
1381
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1382
+ */
1383
+ var legacy_updates = null;
1384
+ var flush_count = 0;
1385
+ var uid = 1;
1386
+ var _started = /* @__PURE__ */ new WeakMap();
1387
+ var _prev = /* @__PURE__ */ new WeakMap();
1388
+ var _next = /* @__PURE__ */ new WeakMap();
1389
+ var _commit_callbacks = /* @__PURE__ */ new WeakMap();
1390
+ var _discard_callbacks = /* @__PURE__ */ new WeakMap();
1391
+ var _pending = /* @__PURE__ */ new WeakMap();
1392
+ var _blocking_pending = /* @__PURE__ */ new WeakMap();
1393
+ var _deferred = /* @__PURE__ */ new WeakMap();
1394
+ var _roots = /* @__PURE__ */ new WeakMap();
1395
+ var _new_effects = /* @__PURE__ */ new WeakMap();
1406
1396
  var _dirty_effects = /* @__PURE__ */ new WeakMap();
1407
1397
  var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
1408
- var _effect_pending = /* @__PURE__ */ new WeakMap();
1409
- var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
1410
- var _Boundary_brand = /* @__PURE__ */ new WeakSet();
1411
- var Boundary = class {
1412
- /**
1413
- * @param {TemplateNode} node
1414
- * @param {BoundaryProps} props
1415
- * @param {((anchor: Node) => void)} children
1416
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
1417
- */
1418
- constructor(node, props, children, transform_error) {
1419
- _classPrivateMethodInitSpec(this, _Boundary_brand);
1398
+ var _skipped_branches = /* @__PURE__ */ new WeakMap();
1399
+ var _unskipped_branches = /* @__PURE__ */ new WeakMap();
1400
+ var _decrement_queued = /* @__PURE__ */ new WeakMap();
1401
+ var _Batch_brand = /* @__PURE__ */ new WeakSet();
1402
+ var Batch = class Batch {
1403
+ constructor() {
1404
+ _classPrivateMethodInitSpec(this, _Batch_brand);
1405
+ _defineProperty(this, "id", uid++);
1406
+ _classPrivateFieldInitSpec(this, _started, false);
1407
+ _defineProperty(this, "linked", true);
1408
+ _classPrivateFieldInitSpec(this, _prev, null);
1409
+ _classPrivateFieldInitSpec(this, _next, null);
1420
1410
  _defineProperty(
1421
1411
  this,
1422
- /** @type {Boundary | null} */
1423
- "parent",
1424
- void 0
1412
+ /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
1413
+ "async_deriveds",
1414
+ /* @__PURE__ */ new Map()
1425
1415
  );
1426
- _defineProperty(this, "is_pending", false);
1427
1416
  _defineProperty(
1428
1417
  this,
1429
1418
  /**
1430
- * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
1431
- * Inherited from parent boundary, or defaults to identity.
1432
- * @type {(error: unknown) => unknown}
1419
+ * The current values of any signals that are updated in this batch.
1420
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
1421
+ * They keys of this map are identical to `this.#previous`
1422
+ * @type {Map<Value, [any, boolean]>}
1433
1423
  */
1434
- "transform_error",
1435
- void 0
1424
+ "current",
1425
+ /* @__PURE__ */ new Map()
1426
+ );
1427
+ _defineProperty(
1428
+ this,
1429
+ /**
1430
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
1431
+ * They keys of this map are identical to `this.#current`
1432
+ * @type {Map<Value, any>}
1433
+ */
1434
+ "previous",
1435
+ /* @__PURE__ */ new Map()
1436
1436
  );
1437
- _classPrivateFieldInitSpec(this, _anchor, void 0);
1438
- _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
1439
- _classPrivateFieldInitSpec(this, _props, void 0);
1440
- _classPrivateFieldInitSpec(this, _children, void 0);
1441
- _classPrivateFieldInitSpec(this, _effect, void 0);
1442
- _classPrivateFieldInitSpec(this, _main_effect, null);
1443
- _classPrivateFieldInitSpec(this, _pending_effect, null);
1444
- _classPrivateFieldInitSpec(this, _failed_effect, null);
1445
- _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
1446
- _classPrivateFieldInitSpec(this, _local_pending_count, 0);
1447
- _classPrivateFieldInitSpec(this, _pending_count, 0);
1448
- _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
1437
+ _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
1438
+ _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
1439
+ _classPrivateFieldInitSpec(this, _pending, 0);
1440
+ _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
1441
+ _classPrivateFieldInitSpec(this, _deferred, null);
1442
+ _classPrivateFieldInitSpec(this, _roots, []);
1443
+ _classPrivateFieldInitSpec(this, _new_effects, []);
1449
1444
  _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
1450
1445
  _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
1451
- _classPrivateFieldInitSpec(this, _effect_pending, null);
1452
- _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
1453
- _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
1454
- return () => {
1455
- _classPrivateFieldSet2(_effect_pending, this, null);
1456
- };
1457
- }));
1458
- _classPrivateFieldSet2(_anchor, this, node);
1459
- _classPrivateFieldSet2(_props, this, props);
1460
- _classPrivateFieldSet2(_children, this, (anchor) => {
1461
- var effect = active_effect;
1462
- effect.b = this;
1463
- effect.f |= 128;
1464
- children(anchor);
1465
- });
1466
- this.parent = active_effect.b;
1467
- this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
1468
- _classPrivateFieldSet2(_effect, this, block(() => {
1469
- if (hydrating) {
1470
- const comment = _classPrivateFieldGet2(_hydrate_open, this);
1471
- hydrate_next();
1472
- const server_rendered_pending = comment.data === "[!";
1473
- if (comment.data.startsWith("[?")) {
1474
- const serialized_error = JSON.parse(comment.data.slice(2));
1475
- _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
1476
- } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
1477
- else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
1478
- } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
1479
- }, flags));
1480
- if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
1446
+ _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
1447
+ _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
1448
+ _defineProperty(this, "is_fork", false);
1449
+ _classPrivateFieldInitSpec(this, _decrement_queued, false);
1450
+ if (last_batch === null) first_batch = last_batch = this;
1451
+ else {
1452
+ _classPrivateFieldSet2(_next, last_batch, this);
1453
+ _classPrivateFieldSet2(_prev, this, last_batch);
1454
+ }
1455
+ last_batch = this;
1481
1456
  }
1482
1457
  /**
1483
- * Defer an effect inside a pending boundary until the boundary resolves
1458
+ * Add an effect to the #skipped_branches map and reset its children
1484
1459
  * @param {Effect} effect
1485
1460
  */
1486
- defer_effect(effect) {
1487
- defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1461
+ skip_effect(effect) {
1462
+ if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
1463
+ d: [],
1464
+ m: []
1465
+ });
1466
+ _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
1488
1467
  }
1489
1468
  /**
1490
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1491
- * @returns {boolean}
1469
+ * Remove an effect from the #skipped_branches map and reschedule
1470
+ * any tracked dirty/maybe_dirty child effects
1471
+ * @param {Effect} effect
1472
+ * @param {(e: Effect) => void} callback
1492
1473
  */
1493
- is_rendered() {
1494
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
1495
- }
1496
- has_pending_snippet() {
1497
- return !!_classPrivateFieldGet2(_props, this).pending;
1474
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
1475
+ var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
1476
+ if (tracked) {
1477
+ _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
1478
+ for (var e of tracked.d) {
1479
+ set_signal_status(e, DIRTY);
1480
+ callback(e);
1481
+ }
1482
+ for (e of tracked.m) {
1483
+ set_signal_status(e, MAYBE_DIRTY);
1484
+ callback(e);
1485
+ }
1486
+ }
1487
+ _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
1498
1488
  }
1499
1489
  /**
1500
- * Update the source that powers `$effect.pending()` inside this boundary,
1501
- * and controls when the current `pending` snippet (if any) is removed.
1502
- * Do not call from inside the class
1503
- * @param {1 | -1} d
1504
- * @param {Batch} batch
1490
+ * Associate a change to a given source with the current
1491
+ * batch, noting its previous and current values
1492
+ * @param {Value} source
1493
+ * @param {any} value
1494
+ * @param {boolean} [is_derived]
1505
1495
  */
1506
- update_pending_count(d, batch) {
1507
- _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
1508
- _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
1509
- if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
1510
- _classPrivateFieldSet2(_pending_count_update_queued, this, true);
1511
- queue_micro_task(() => {
1512
- _classPrivateFieldSet2(_pending_count_update_queued, this, false);
1513
- if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
1514
- });
1515
- }
1516
- get_effect_pending() {
1517
- _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
1518
- return get(_classPrivateFieldGet2(_effect_pending, this));
1496
+ capture(source, value, is_derived = false) {
1497
+ if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
1498
+ if ((source.f & 8388608) === 0) {
1499
+ this.current.set(source, [value, is_derived]);
1500
+ batch_values?.set(source, value);
1501
+ }
1502
+ if (!this.is_fork) source.v = value;
1519
1503
  }
1520
- /** @param {unknown} error */
1521
- error(error) {
1522
- if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
1523
- if (current_batch?.is_fork) {
1524
- if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
1525
- if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
1526
- if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
1527
- current_batch.oncommit(() => {
1528
- _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
1529
- });
1530
- } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
1504
+ activate() {
1505
+ current_batch = this;
1531
1506
  }
1532
- };
1533
- function _hydrate_resolved_content() {
1534
- try {
1535
- _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
1536
- } catch (error) {
1537
- this.error(error);
1507
+ deactivate() {
1508
+ current_batch = null;
1509
+ batch_values = null;
1538
1510
  }
1539
- }
1540
- /**
1541
- * @param {unknown} error The deserialized error from the server's hydration comment
1542
- */
1543
- function _hydrate_failed_content(error) {
1544
- const failed = _classPrivateFieldGet2(_props, this).failed;
1545
- if (!failed) return;
1546
- _classPrivateFieldSet2(_failed_effect, this, branch(() => {
1547
- failed(_classPrivateFieldGet2(_anchor, this), () => error, () => () => {});
1548
- }));
1549
- }
1550
- function _hydrate_pending_content() {
1551
- const pending = _classPrivateFieldGet2(_props, this).pending;
1552
- if (!pending) return;
1553
- this.is_pending = true;
1554
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1555
- queue_micro_task(() => {
1556
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1557
- var anchor = create_text();
1558
- fragment.append(anchor);
1559
- _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1560
- return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
1561
- }));
1562
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1563
- _classPrivateFieldGet2(_anchor, this).before(fragment);
1564
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1565
- pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1566
- _classPrivateFieldSet2(_pending_effect, this, null);
1567
- });
1568
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1511
+ flush() {
1512
+ try {
1513
+ is_processing = true;
1514
+ current_batch = this;
1515
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
1516
+ } finally {
1517
+ flush_count = 0;
1518
+ last_scheduled_effect = null;
1519
+ collected_effects = null;
1520
+ legacy_updates = null;
1521
+ is_processing = false;
1522
+ current_batch = null;
1523
+ batch_values = null;
1524
+ old_values.clear();
1569
1525
  }
1570
- });
1571
- }
1572
- function _render() {
1573
- try {
1574
- this.is_pending = this.has_pending_snippet();
1575
- _classPrivateFieldSet2(_pending_count, this, 0);
1576
- _classPrivateFieldSet2(_local_pending_count, this, 0);
1577
- _classPrivateFieldSet2(_main_effect, this, branch(() => {
1578
- _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
1579
- }));
1580
- if (_classPrivateFieldGet2(_pending_count, this) > 0) {
1581
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1582
- move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
1583
- const pending = _classPrivateFieldGet2(_props, this).pending;
1584
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1585
- } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1586
- } catch (error) {
1587
- this.error(error);
1588
1526
  }
1589
- }
1590
- /**
1591
- * @param {Batch} batch
1592
- */
1593
- function _resolve(batch) {
1594
- this.is_pending = false;
1595
- batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1596
- }
1597
- /**
1598
- * @template T
1599
- * @param {() => T} fn
1600
- */
1601
- function _run(fn) {
1602
- var previous_effect = active_effect;
1603
- var previous_reaction = active_reaction;
1604
- var previous_ctx = component_context;
1605
- set_active_effect(_classPrivateFieldGet2(_effect, this));
1606
- set_active_reaction(_classPrivateFieldGet2(_effect, this));
1607
- set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
1608
- try {
1609
- Batch.ensure();
1610
- return fn();
1611
- } catch (e) {
1612
- handle_error(e);
1613
- return null;
1614
- } finally {
1615
- set_active_effect(previous_effect);
1616
- set_active_reaction(previous_reaction);
1617
- set_component_context(previous_ctx);
1527
+ discard() {
1528
+ for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
1529
+ _classPrivateFieldGet2(_discard_callbacks, this).clear();
1530
+ for (const deferred of this.async_deriveds.values()) deferred.reject(OBSOLETE);
1531
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1532
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
1618
1533
  }
1619
- }
1620
- /**
1621
- * Updates the pending count associated with the currently visible pending snippet,
1622
- * if any, such that we can replace the snippet with content once work is done
1623
- * @param {1 | -1} d
1624
- * @param {Batch} batch
1625
- */
1626
- function _update_pending_count(d, batch) {
1627
- if (!this.has_pending_snippet()) {
1628
- if (this.parent) {
1629
- var _this$parent;
1630
- _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
1534
+ /**
1535
+ * @param {Effect} effect
1536
+ */
1537
+ register_created_effect(effect) {
1538
+ _classPrivateFieldGet2(_new_effects, this).push(effect);
1539
+ }
1540
+ /**
1541
+ * @param {boolean} blocking
1542
+ * @param {Effect} effect
1543
+ */
1544
+ increment(blocking, effect) {
1545
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
1546
+ if (blocking) {
1547
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1548
+ _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
1631
1549
  }
1632
- return;
1633
1550
  }
1634
- _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
1635
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1636
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
1637
- if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1638
- _classPrivateFieldSet2(_pending_effect, this, null);
1639
- });
1640
- if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
1641
- _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
1642
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1551
+ /**
1552
+ * @param {boolean} blocking
1553
+ * @param {Effect} effect
1554
+ */
1555
+ decrement(blocking, effect) {
1556
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
1557
+ if (blocking) {
1558
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1559
+ if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
1560
+ else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
1643
1561
  }
1562
+ if (_classPrivateFieldGet2(_decrement_queued, this)) return;
1563
+ _classPrivateFieldSet2(_decrement_queued, this, true);
1564
+ queue_micro_task(() => {
1565
+ _classPrivateFieldSet2(_decrement_queued, this, false);
1566
+ if (this.linked) this.flush();
1567
+ });
1644
1568
  }
1645
- }
1646
- /**
1647
- * @param {unknown} error
1648
- */
1649
- function _handle_error(error) {
1650
- if (_classPrivateFieldGet2(_main_effect, this)) {
1651
- destroy_effect(_classPrivateFieldGet2(_main_effect, this));
1652
- _classPrivateFieldSet2(_main_effect, this, null);
1569
+ /**
1570
+ * @param {Set<Effect>} dirty_effects
1571
+ * @param {Set<Effect>} maybe_dirty_effects
1572
+ */
1573
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
1574
+ for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects, this).add(e);
1575
+ for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects, this).add(e);
1576
+ dirty_effects.clear();
1577
+ maybe_dirty_effects.clear();
1653
1578
  }
1654
- if (_classPrivateFieldGet2(_pending_effect, this)) {
1655
- destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
1656
- _classPrivateFieldSet2(_pending_effect, this, null);
1579
+ /** @param {(batch: Batch) => void} fn */
1580
+ oncommit(fn) {
1581
+ _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
1657
1582
  }
1658
- if (_classPrivateFieldGet2(_failed_effect, this)) {
1659
- destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
1660
- _classPrivateFieldSet2(_failed_effect, this, null);
1583
+ /** @param {(batch: Batch) => void} fn */
1584
+ ondiscard(fn) {
1585
+ _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
1661
1586
  }
1662
- if (hydrating) {
1663
- set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
1664
- next();
1665
- set_hydrate_node(skip_nodes());
1587
+ settled() {
1588
+ return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
1666
1589
  }
1667
- var onerror = _classPrivateFieldGet2(_props, this).onerror;
1668
- let failed = _classPrivateFieldGet2(_props, this).failed;
1669
- var did_reset = false;
1670
- var calling_on_error = false;
1671
- const reset = () => {
1672
- if (did_reset) {
1673
- svelte_boundary_reset_noop();
1674
- return;
1590
+ static ensure() {
1591
+ if (current_batch === null) {
1592
+ const batch = current_batch = new Batch();
1593
+ if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
1594
+ if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
1595
+ });
1675
1596
  }
1676
- did_reset = true;
1677
- if (calling_on_error) svelte_boundary_reset_onerror();
1678
- if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
1679
- _classPrivateFieldSet2(_failed_effect, this, null);
1680
- });
1681
- _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1682
- _assertClassBrand(_Boundary_brand, this, _render).call(this);
1683
- });
1684
- };
1685
- /** @param {unknown} transformed_error */
1686
- const handle_error_result = (transformed_error) => {
1687
- try {
1688
- calling_on_error = true;
1689
- onerror?.(transformed_error, reset);
1690
- calling_on_error = false;
1691
- } catch (error) {
1692
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1597
+ return current_batch;
1598
+ }
1599
+ apply() {
1600
+ if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
1601
+ batch_values = null;
1602
+ return;
1693
1603
  }
1694
- if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1695
- try {
1696
- return branch(() => {
1697
- var effect = active_effect;
1698
- effect.b = this;
1699
- effect.f |= 128;
1700
- failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
1701
- });
1702
- } catch (error) {
1703
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
1704
- return null;
1604
+ batch_values = /* @__PURE__ */ new Map();
1605
+ for (const [source, [value]] of this.current) batch_values.set(source, value);
1606
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1607
+ if (batch === this || batch.is_fork) continue;
1608
+ var intersects = false;
1609
+ if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
1610
+ if (is_derived) continue;
1611
+ if (this.current.has(source)) {
1612
+ intersects = true;
1613
+ break;
1614
+ }
1705
1615
  }
1706
- }));
1707
- };
1708
- queue_micro_task(() => {
1709
- /** @type {unknown} */
1710
- var result;
1711
- try {
1712
- result = this.transform_error(error);
1713
- } catch (e) {
1714
- invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1616
+ if (!intersects) {
1617
+ for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
1618
+ }
1619
+ }
1620
+ }
1621
+ /**
1622
+ *
1623
+ * @param {Effect} effect
1624
+ */
1625
+ schedule(effect) {
1626
+ last_scheduled_effect = effect;
1627
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
1628
+ effect.b.defer_effect(effect);
1715
1629
  return;
1716
1630
  }
1717
- if (result !== null && typeof result === "object" && typeof result.then === "function")
1718
- /** @type {any} */ result.then(
1719
- handle_error_result,
1720
- /** @param {unknown} e */
1721
- (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
1722
- );
1723
- else handle_error_result(result);
1724
- });
1631
+ var e = effect;
1632
+ while (e.parent !== null) {
1633
+ e = e.parent;
1634
+ var flags = e.f;
1635
+ if (collected_effects !== null && e === active_effect) {
1636
+ if (async_mode_flag) return;
1637
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
1638
+ }
1639
+ if ((flags & 96) !== 0) {
1640
+ if ((flags & 1024) === 0) return;
1641
+ e.f ^= CLEAN;
1642
+ }
1643
+ }
1644
+ _classPrivateFieldGet2(_roots, this).push(e);
1645
+ }
1646
+ };
1647
+ _Batch = Batch;
1648
+ function _is_deferred() {
1649
+ if (this.is_fork) return true;
1650
+ for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
1651
+ var e = effect;
1652
+ var skipped = false;
1653
+ while (e.parent !== null) {
1654
+ if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
1655
+ skipped = true;
1656
+ break;
1657
+ }
1658
+ e = e.parent;
1659
+ }
1660
+ if (!skipped) return true;
1661
+ }
1662
+ return false;
1725
1663
  }
1726
- //#endregion
1727
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/async.js
1728
- /** @import { Blocker, Effect, Source, Value } from '#client' */
1729
- /**
1730
- * @param {Blocker[]} blockers
1731
- * @param {Array<() => any>} sync
1732
- * @param {Array<() => Promise<any>>} async
1733
- * @param {(values: Value[]) => any} fn
1734
- */
1735
- function flatten(blockers, sync, async, fn) {
1736
- const d = is_runes() ? derived : derived_safe_equal;
1737
- var pending = blockers.filter((b) => !b.settled);
1738
- var deriveds = sync.map(d);
1739
- if (async.length === 0 && pending.length === 0) {
1740
- fn(deriveds);
1741
- return;
1664
+ function _process() {
1665
+ _classPrivateFieldSet2(_started, this, true);
1666
+ if (flush_count++ > 1e3) {
1667
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1668
+ infinite_loop_guard();
1742
1669
  }
1743
- var parent = active_effect;
1744
- var restore = capture();
1745
- var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
1670
+ for (const e of _classPrivateFieldGet2(_dirty_effects, this)) {
1671
+ _classPrivateFieldGet2(_maybe_dirty_effects, this).delete(e);
1672
+ set_signal_status(e, DIRTY);
1673
+ this.schedule(e);
1674
+ }
1675
+ for (const e of _classPrivateFieldGet2(_maybe_dirty_effects, this)) {
1676
+ set_signal_status(e, MAYBE_DIRTY);
1677
+ this.schedule(e);
1678
+ }
1679
+ const roots = _classPrivateFieldGet2(_roots, this);
1680
+ _classPrivateFieldSet2(_roots, this, []);
1681
+ this.apply();
1682
+ /** @type {Effect[]} */
1683
+ var effects = collected_effects = [];
1684
+ /** @type {Effect[]} */
1685
+ var render_effects = [];
1746
1686
  /**
1747
- * @param {Source[]} async
1687
+ * @type {Effect[]}
1688
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1748
1689
  */
1749
- function finish(async) {
1750
- if ((parent.f & 16384) !== 0) return;
1751
- restore();
1752
- try {
1753
- fn([...deriveds, ...async]);
1754
- } catch (error) {
1755
- invoke_error_boundary(error, parent);
1756
- }
1757
- unset_context();
1690
+ var updates = legacy_updates = [];
1691
+ for (const root of roots) try {
1692
+ _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
1693
+ } catch (e) {
1694
+ reset_all(root);
1695
+ if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
1696
+ throw e;
1697
+ }
1698
+ current_batch = null;
1699
+ if (updates.length > 0) {
1700
+ var batch = _Batch.ensure();
1701
+ for (const e of updates) batch.schedule(e);
1702
+ }
1703
+ collected_effects = null;
1704
+ legacy_updates = null;
1705
+ if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
1706
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1707
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1708
+ for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
1709
+ if (updates.length > 0)
1710
+ /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
1711
+ return;
1758
1712
  }
1759
- var decrement_pending = increment_pending();
1760
- if (async.length === 0) {
1761
- /** @type {Promise<any>} */ blocker_promise.then(() => finish([])).finally(decrement_pending);
1713
+ const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
1714
+ if (earlier_batch) {
1715
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1716
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1717
+ _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
1762
1718
  return;
1763
1719
  }
1764
- function run() {
1765
- Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then(finish).catch((error) => invoke_error_boundary(error, parent)).finally(decrement_pending);
1720
+ _classPrivateFieldGet2(_dirty_effects, this).clear();
1721
+ _classPrivateFieldGet2(_maybe_dirty_effects, this).clear();
1722
+ for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
1723
+ _classPrivateFieldGet2(_commit_callbacks, this).clear();
1724
+ previous_batch = this;
1725
+ flush_queued_effects(render_effects);
1726
+ flush_queued_effects(effects);
1727
+ previous_batch = null;
1728
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
1729
+ var next_batch = current_batch;
1730
+ if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
1731
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1732
+ if (async_mode_flag) {
1733
+ _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
1734
+ current_batch = next_batch;
1735
+ }
1766
1736
  }
1767
- if (blocker_promise) blocker_promise.then(() => {
1768
- restore();
1769
- run();
1770
- unset_context();
1771
- });
1772
- else run();
1737
+ if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
1738
+ const batch = next_batch;
1739
+ _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
1740
+ } else next_batch = this;
1741
+ if (next_batch !== null) _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
1773
1742
  }
1774
1743
  /**
1775
- * Captures the current effect context so that we can restore it after
1776
- * some asynchronous work has happened (so that e.g. `await a + b`
1777
- * causes `b` to be registered as a dependency).
1744
+ * Traverse the effect tree, executing effects or stashing
1745
+ * them for later execution as appropriate
1746
+ * @param {Effect} root
1747
+ * @param {Effect[]} effects
1748
+ * @param {Effect[]} render_effects
1778
1749
  */
1779
- function capture() {
1780
- var previous_effect = active_effect;
1781
- var previous_reaction = active_reaction;
1782
- var previous_component_context = component_context;
1783
- var previous_batch = current_batch;
1784
- return function restore(activate_batch = true) {
1785
- set_active_effect(previous_effect);
1786
- set_active_reaction(previous_reaction);
1787
- set_component_context(previous_component_context);
1788
- if (activate_batch && (previous_effect.f & 16384) === 0) {
1789
- previous_batch?.activate();
1790
- previous_batch?.apply();
1750
+ function _traverse(root, effects, render_effects) {
1751
+ root.f ^= CLEAN;
1752
+ var effect = root.first;
1753
+ while (effect !== null) {
1754
+ var flags = effect.f;
1755
+ var is_branch = (flags & 96) !== 0;
1756
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1757
+ if (is_branch) effect.f ^= CLEAN;
1758
+ else if ((flags & 4) !== 0) effects.push(effect);
1759
+ else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1760
+ else if (is_dirty(effect)) {
1761
+ if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects, this).add(effect);
1762
+ update_effect(effect);
1763
+ }
1764
+ var child = effect.first;
1765
+ if (child !== null) {
1766
+ effect = child;
1767
+ continue;
1768
+ }
1791
1769
  }
1792
- };
1770
+ while (effect !== null) {
1771
+ var next = effect.next;
1772
+ if (next !== null) {
1773
+ effect = next;
1774
+ break;
1775
+ }
1776
+ effect = effect.parent;
1777
+ }
1778
+ }
1793
1779
  }
1794
- function unset_context(deactivate_batch = true) {
1795
- set_active_effect(null);
1796
- set_active_reaction(null);
1797
- set_component_context(null);
1798
- if (deactivate_batch) current_batch?.deactivate();
1780
+ function _find_earlier_batch() {
1781
+ var batch = _classPrivateFieldGet2(_prev, this);
1782
+ while (batch !== null) {
1783
+ if (!batch.is_fork) {
1784
+ for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
1785
+ }
1786
+ batch = _classPrivateFieldGet2(_prev, batch);
1787
+ }
1788
+ return null;
1799
1789
  }
1800
1790
  /**
1801
- * @returns {(skip?: boolean) => void}
1791
+ * @param {Batch} batch
1802
1792
  */
1803
- function increment_pending() {
1804
- var effect = active_effect;
1805
- var boundary = effect.b;
1806
- var batch = current_batch;
1807
- var blocking = !!boundary?.is_rendered();
1808
- boundary?.update_pending_count(1, batch);
1809
- batch.increment(blocking, effect);
1810
- return () => {
1811
- boundary?.update_pending_count(-1, batch);
1812
- batch.decrement(blocking, effect);
1793
+ function _merge(batch) {
1794
+ for (const [source, value] of batch.current) {
1795
+ if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1796
+ this.current.set(source, value);
1797
+ }
1798
+ for (const [effect, deferred] of batch.async_deriveds) {
1799
+ const d = this.async_deriveds.get(effect);
1800
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1801
+ }
1802
+ batch.async_deriveds.clear();
1803
+ this.transfer_effects(_classPrivateFieldGet2(_dirty_effects, batch), _classPrivateFieldGet2(_maybe_dirty_effects, batch));
1804
+ /**
1805
+ * mark all effects that depend on `batch.current`, except the
1806
+ * async effects that we just resolved (TODO unless they depend
1807
+ * on values in this batch that are NOT in the later batch?).
1808
+ * Through this we also will populate the correct #skipped_branches,
1809
+ * oncommit callbacks etc, so we don't need to merge them separately.
1810
+ * @param {Value} value
1811
+ */
1812
+ const mark = (value) => {
1813
+ var reactions = value.reactions;
1814
+ if (reactions === null) return;
1815
+ if ((value.f & 2) !== 0 && (value.f & 6144) === 0) return;
1816
+ for (const reaction of reactions) {
1817
+ var flags = reaction.f;
1818
+ if ((flags & 2) !== 0) mark(reaction);
1819
+ else {
1820
+ var effect = reaction;
1821
+ if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1822
+ _classPrivateFieldGet2(_maybe_dirty_effects, this).delete(effect);
1823
+ set_signal_status(effect, DIRTY);
1824
+ this.schedule(effect);
1825
+ }
1826
+ }
1827
+ }
1813
1828
  };
1829
+ for (const source of this.current.keys()) mark(source);
1830
+ this.oncommit(() => batch.discard());
1831
+ _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1832
+ current_batch = this;
1833
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
1814
1834
  }
1815
1835
  /**
1816
- * @template V
1817
- * @param {() => V} fn
1818
- * @returns {Derived<V>}
1836
+ * @param {Effect[]} effects
1819
1837
  */
1820
- /*#__NO_SIDE_EFFECTS__*/
1821
- function derived(fn) {
1822
- var flags = 2 | DIRTY;
1823
- if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
1824
- return {
1825
- ctx: component_context,
1826
- deps: null,
1827
- effects: null,
1828
- equals,
1829
- f: flags,
1830
- fn,
1831
- reactions: null,
1832
- rv: 0,
1833
- v: UNINITIALIZED,
1834
- wv: 0,
1835
- parent: active_effect,
1836
- ac: null
1837
- };
1838
+ function _defer_effects(effects) {
1839
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1838
1840
  }
1839
- var OBSOLETE = Symbol("obsolete");
1840
- /**
1841
- * @template V
1842
- * @param {() => V | Promise<V>} fn
1843
- * @param {string} [label]
1844
- * @param {string} [location] If provided, print a warning if the value is not read immediately after update
1845
- * @returns {Promise<Source<V>>}
1846
- */
1847
- /*#__NO_SIDE_EFFECTS__*/
1848
- function async_derived(fn, label, location) {
1849
- let parent = active_effect;
1850
- if (parent === null) async_derived_orphan();
1851
- var promise = void 0;
1852
- var signal = source(UNINITIALIZED);
1853
- var should_suspend = !active_reaction;
1854
- /** @type {Set<ReturnType<typeof deferred<V>>>} */
1855
- var deferreds = /* @__PURE__ */ new Set();
1856
- async_effect(() => {
1857
- var effect = active_effect;
1858
- /** @type {ReturnType<typeof deferred<V>>} */
1859
- var d = deferred();
1860
- promise = d.promise;
1861
- try {
1862
- Promise.resolve(fn()).then(d.resolve, (e) => {
1863
- if (e !== STALE_REACTION) d.reject(e);
1864
- }).finally(unset_context);
1865
- } catch (error) {
1866
- d.reject(error);
1867
- unset_context();
1841
+ function _commit$1() {
1842
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1843
+ var is_earlier = batch.id < this.id;
1844
+ /** @type {Source[]} */
1845
+ var sources = [];
1846
+ for (const [source, [value, is_derived]] of this.current) {
1847
+ if (batch.current.has(source)) {
1848
+ var batch_value = batch.current.get(source)[0];
1849
+ if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1850
+ else continue;
1851
+ }
1852
+ sources.push(source);
1868
1853
  }
1869
- var batch = current_batch;
1870
- if (should_suspend) {
1871
- if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
1872
- if (parent.b?.is_rendered()) batch.async_deriveds.get(effect)?.reject(OBSOLETE);
1873
- else for (const d of deferreds.values()) d.reject(OBSOLETE);
1874
- deferreds.add(d);
1875
- batch.async_deriveds.set(effect, d);
1854
+ if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1855
+ const d = batch.async_deriveds.get(effect);
1856
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1876
1857
  }
1877
- /**
1878
- * @param {any} value
1879
- * @param {unknown} error
1880
- */
1881
- const handler = (value, error = void 0) => {
1882
- decrement_pending?.();
1883
- deferreds.delete(d);
1884
- if (error === OBSOLETE) return;
1858
+ var current = [...batch.current.keys()].filter((source) => !batch.current.get(source)[1]);
1859
+ if (!_classPrivateFieldGet2(_started, batch) || current.length === 0) continue;
1860
+ var others = current.filter((source) => !this.current.has(source));
1861
+ if (others.length === 0) {
1862
+ if (is_earlier) batch.discard();
1863
+ } else if (sources.length > 0) {
1864
+ if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1865
+ if ((e.f & 4194320) !== 0) batch.schedule(e);
1866
+ else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1867
+ });
1885
1868
  batch.activate();
1886
- if (error) {
1887
- signal.f |= ERROR_VALUE;
1888
- internal_set(signal, error);
1889
- } else {
1890
- if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
1891
- internal_set(signal, value);
1869
+ /** @type {Set<Value>} */
1870
+ var marked = /* @__PURE__ */ new Set();
1871
+ /** @type {Map<Reaction, boolean>} */
1872
+ var checked = /* @__PURE__ */ new Map();
1873
+ for (var source of sources) mark_effects(source, others, marked, checked);
1874
+ checked = /* @__PURE__ */ new Map();
1875
+ var current_unequal = [...batch.current].filter(([c, v1]) => {
1876
+ const v2 = this.current.get(c);
1877
+ if (!v2) return true;
1878
+ return v2[0] !== v1[0] || v2[1] !== v1[1];
1879
+ }).map(([c]) => c);
1880
+ if (current_unequal.length > 0) {
1881
+ for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1882
+ set_signal_status(effect, DIRTY);
1883
+ batch.schedule(effect);
1884
+ } else _classPrivateFieldGet2(_dirty_effects, batch).add(effect);
1892
1885
  }
1893
- batch.deactivate();
1894
- };
1895
- d.promise.then(handler, (e) => handler(null, e || "unknown"));
1896
- });
1897
- teardown(() => {
1898
- for (const d of deferreds) d.reject(OBSOLETE);
1899
- });
1900
- return new Promise((fulfil) => {
1901
- /** @param {Promise<V>} p */
1902
- function next(p) {
1903
- function go() {
1904
- if (p === promise) fulfil(signal);
1905
- else next(promise);
1886
+ if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1887
+ batch.apply();
1888
+ for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1889
+ _classPrivateFieldSet2(_roots, batch, []);
1906
1890
  }
1907
- p.then(go, go);
1891
+ batch.deactivate();
1908
1892
  }
1909
- next(promise);
1910
- });
1893
+ }
1911
1894
  }
1912
- /**
1913
- * @template V
1914
- * @param {() => V} fn
1915
- * @returns {Derived<V>}
1916
- */
1917
- /*#__NO_SIDE_EFFECTS__*/
1918
- function user_derived(fn) {
1919
- const d = /* @__PURE__ */ derived(fn);
1920
- if (!async_mode_flag) push_reaction_value(d);
1921
- return d;
1895
+ function _unlink() {
1896
+ if (!this.linked) return;
1897
+ var prev = _classPrivateFieldGet2(_prev, this);
1898
+ var next = _classPrivateFieldGet2(_next, this);
1899
+ if (prev === null) first_batch = next;
1900
+ else _classPrivateFieldSet2(_next, prev, next);
1901
+ if (next === null) last_batch = prev;
1902
+ else _classPrivateFieldSet2(_prev, next, prev);
1903
+ this.linked = false;
1922
1904
  }
1923
1905
  /**
1924
- * @template V
1925
- * @param {() => V} fn
1926
- * @returns {Derived<V>}
1906
+ * Synchronously flush any pending updates.
1907
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1908
+ * @template [T=void]
1909
+ * @param {(() => T) | undefined} [fn]
1910
+ * @returns {T}
1927
1911
  */
1928
- /*#__NO_SIDE_EFFECTS__*/
1929
- function derived_safe_equal(fn) {
1930
- const signal = /* @__PURE__ */ derived(fn);
1931
- signal.equals = safe_equals;
1932
- return signal;
1912
+ function flushSync(fn) {
1913
+ var was_flushing_sync = is_flushing_sync;
1914
+ is_flushing_sync = true;
1915
+ try {
1916
+ var result;
1917
+ if (fn) {
1918
+ if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1919
+ result = fn();
1920
+ }
1921
+ while (true) {
1922
+ flush_tasks();
1923
+ if (current_batch === null) return result;
1924
+ current_batch.flush();
1925
+ }
1926
+ } finally {
1927
+ is_flushing_sync = was_flushing_sync;
1928
+ }
1929
+ }
1930
+ function infinite_loop_guard() {
1931
+ try {
1932
+ effect_update_depth_exceeded();
1933
+ } catch (error) {
1934
+ invoke_error_boundary(error, last_scheduled_effect);
1935
+ }
1933
1936
  }
1937
+ /** @type {Set<Effect> | null} */
1938
+ var eager_block_effects = null;
1934
1939
  /**
1935
- * @param {Derived} derived
1940
+ * @param {Array<Effect>} effects
1936
1941
  * @returns {void}
1937
1942
  */
1938
- function destroy_derived_effects(derived) {
1939
- var effects = derived.effects;
1940
- if (effects !== null) {
1941
- derived.effects = null;
1942
- for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1943
+ function flush_queued_effects(effects) {
1944
+ var length = effects.length;
1945
+ if (length === 0) return;
1946
+ var i = 0;
1947
+ while (i < length) {
1948
+ var effect = effects[i++];
1949
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1950
+ eager_block_effects = /* @__PURE__ */ new Set();
1951
+ update_effect(effect);
1952
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1953
+ if (eager_block_effects?.size > 0) {
1954
+ old_values.clear();
1955
+ for (const e of eager_block_effects) {
1956
+ if ((e.f & 24576) !== 0) continue;
1957
+ /** @type {Effect[]} */
1958
+ const ordered_effects = [e];
1959
+ let ancestor = e.parent;
1960
+ while (ancestor !== null) {
1961
+ if (eager_block_effects.has(ancestor)) {
1962
+ eager_block_effects.delete(ancestor);
1963
+ ordered_effects.push(ancestor);
1964
+ }
1965
+ ancestor = ancestor.parent;
1966
+ }
1967
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1968
+ const e = ordered_effects[j];
1969
+ if ((e.f & 24576) !== 0) continue;
1970
+ update_effect(e);
1971
+ }
1972
+ }
1973
+ eager_block_effects.clear();
1974
+ }
1975
+ }
1943
1976
  }
1977
+ eager_block_effects = null;
1944
1978
  }
1945
1979
  /**
1946
- * @template T
1947
- * @param {Derived} derived
1948
- * @returns {T}
1980
+ * This is similar to `mark_reactions`, but it only marks async/block effects
1981
+ * depending on `value` and at least one of the other `sources`, so that
1982
+ * these effects can re-run after another batch has been committed
1983
+ * @param {Value} value
1984
+ * @param {Source[]} sources
1985
+ * @param {Set<Value>} marked
1986
+ * @param {Map<Reaction, boolean>} checked
1949
1987
  */
1950
- function execute_derived(derived) {
1951
- var value;
1952
- var prev_active_effect = active_effect;
1953
- var parent = derived.parent;
1954
- if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
1955
- derived_inert();
1956
- return derived.v;
1957
- }
1958
- set_active_effect(parent);
1959
- try {
1960
- derived.f &= ~WAS_MARKED;
1961
- destroy_derived_effects(derived);
1962
- value = update_reaction(derived);
1963
- } finally {
1964
- set_active_effect(prev_active_effect);
1988
+ function mark_effects(value, sources, marked, checked) {
1989
+ if (marked.has(value)) return;
1990
+ marked.add(value);
1991
+ if (value.reactions !== null) for (const reaction of value.reactions) {
1992
+ const flags = reaction.f;
1993
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1994
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1995
+ set_signal_status(reaction, DIRTY);
1996
+ schedule_effect(reaction);
1997
+ }
1965
1998
  }
1966
- return value;
1967
1999
  }
1968
2000
  /**
1969
- * @param {Derived} derived
1970
- * @returns {void}
2001
+ * @param {Reaction} reaction
2002
+ * @param {Source[]} sources
2003
+ * @param {Map<Reaction, boolean>} checked
1971
2004
  */
1972
- function update_derived(derived) {
1973
- var value = execute_derived(derived);
1974
- if (!derived.equals(value)) {
1975
- derived.wv = increment_write_version();
1976
- if (!current_batch?.is_fork || derived.deps === null) {
1977
- if (current_batch !== null) {
1978
- current_batch.capture(derived, value, true);
1979
- previous_batch?.capture(derived, value, true);
1980
- } else derived.v = value;
1981
- if (derived.deps === null) {
1982
- set_signal_status(derived, CLEAN);
1983
- return;
1984
- }
2005
+ function depends_on(reaction, sources, checked) {
2006
+ const depends = checked.get(reaction);
2007
+ if (depends !== void 0) return depends;
2008
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
2009
+ if (includes.call(sources, dep)) return true;
2010
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
2011
+ checked.set(dep, true);
2012
+ return true;
1985
2013
  }
1986
2014
  }
1987
- if (is_destroying_effect) return;
1988
- if (batch_values !== null) {
1989
- if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1990
- } else update_derived_status(derived);
2015
+ checked.set(reaction, false);
2016
+ return false;
1991
2017
  }
1992
2018
  /**
1993
- * @param {Derived} derived
2019
+ * @param {Effect} effect
2020
+ * @returns {void}
1994
2021
  */
1995
- function freeze_derived_effects(derived) {
1996
- if (derived.effects === null) return;
1997
- for (const e of derived.effects) if (e.teardown || e.ac) {
1998
- e.teardown?.();
1999
- e.ac?.abort(STALE_REACTION);
2000
- if (e.fn !== null) e.teardown = noop;
2001
- e.ac = null;
2002
- remove_reactions(e, 0);
2003
- destroy_effect_children(e);
2022
+ function schedule_effect(effect) {
2023
+ /** @type {Batch} */ current_batch.schedule(effect);
2024
+ }
2025
+ /**
2026
+ * Mark all the effects inside a skipped branch CLEAN, so that
2027
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
2028
+ * effects so they can be rescheduled if the branch survives.
2029
+ * @param {Effect} effect
2030
+ * @param {{ d: Effect[], m: Effect[] }} tracked
2031
+ */
2032
+ function reset_branch(effect, tracked) {
2033
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
2034
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
2035
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
2036
+ set_signal_status(effect, CLEAN);
2037
+ var e = effect.first;
2038
+ while (e !== null) {
2039
+ reset_branch(e, tracked);
2040
+ e = e.next;
2004
2041
  }
2005
2042
  }
2006
2043
  /**
2007
- * @param {Derived} derived
2044
+ * Mark an entire effect tree clean following an error
2045
+ * @param {Effect} effect
2008
2046
  */
2009
- function unfreeze_derived_effects(derived) {
2010
- if (derived.effects === null) return;
2011
- for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
2047
+ function reset_all(effect) {
2048
+ set_signal_status(effect, CLEAN);
2049
+ var e = effect.first;
2050
+ while (e !== null) {
2051
+ reset_all(e);
2052
+ e = e.next;
2053
+ }
2012
2054
  }
2013
2055
  //#endregion
2014
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/sources.js
2056
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/sources.js
2015
2057
  /** @import { Derived, Effect, Source, Value } from '#client' */
2016
2058
  /** @type {Set<Effect>} */
2017
2059
  var eager_effects = /* @__PURE__ */ new Set();
@@ -2309,19 +2351,8 @@ function proxy(value) {
2309
2351
  }
2310
2352
  });
2311
2353
  }
2312
- new Set([
2313
- "copyWithin",
2314
- "fill",
2315
- "pop",
2316
- "push",
2317
- "reverse",
2318
- "shift",
2319
- "sort",
2320
- "splice",
2321
- "unshift"
2322
- ]);
2323
2354
  //#endregion
2324
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/operations.js
2355
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/operations.js
2325
2356
  /** @import { Effect, TemplateNode } from '#client' */
2326
2357
  /** @type {Window} */
2327
2358
  var $window;
@@ -2499,25 +2530,7 @@ function merge_text_nodes(text) {
2499
2530
  }
2500
2531
  }
2501
2532
  //#endregion
2502
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
2503
- /**
2504
- * @template T
2505
- * @param {() => T} fn
2506
- */
2507
- function without_reactive_context(fn) {
2508
- var previous_reaction = active_reaction;
2509
- var previous_effect = active_effect;
2510
- set_active_reaction(null);
2511
- set_active_effect(null);
2512
- try {
2513
- return fn();
2514
- } finally {
2515
- set_active_reaction(previous_reaction);
2516
- set_active_effect(previous_effect);
2517
- }
2518
- }
2519
- //#endregion
2520
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/effects.js
2533
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/effects.js
2521
2534
  /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2522
2535
  /**
2523
2536
  * @param {'$effect' | '$effect.pre' | '$inspect'} rune
@@ -2903,15 +2916,18 @@ function move_effect(effect, fragment) {
2903
2916
  }
2904
2917
  }
2905
2918
  //#endregion
2906
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/legacy.js
2919
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/legacy.js
2907
2920
  /**
2908
2921
  * @type {Set<Value> | null}
2909
2922
  * @deprecated
2910
2923
  */
2911
2924
  var captured_signals = null;
2912
2925
  //#endregion
2913
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/runtime.js
2926
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/runtime.js
2914
2927
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2928
+ /**
2929
+ * True if updating in an effect context that is reactive (i.e. not branch/root effects)
2930
+ */
2915
2931
  var is_updating_effect = false;
2916
2932
  var is_destroying_effect = false;
2917
2933
  /** @param {boolean} value */
@@ -3112,6 +3128,11 @@ function remove_reaction(signal, dependency) {
3112
3128
  derived.f &= ~WAS_MARKED;
3113
3129
  }
3114
3130
  if (derived.v !== UNINITIALIZED) update_derived_status(derived);
3131
+ if (derived.ac !== null) without_reactive_context(() => {
3132
+ /** @type {AbortController} */ derived.ac.abort(STALE_REACTION);
3133
+ derived.ac = null;
3134
+ set_signal_status(derived, DIRTY);
3135
+ });
3115
3136
  freeze_derived_effects(derived);
3116
3137
  remove_reactions(derived, 0);
3117
3138
  }
@@ -3137,7 +3158,7 @@ function update_effect(effect) {
3137
3158
  var previous_effect = active_effect;
3138
3159
  var was_updating_effect = is_updating_effect;
3139
3160
  active_effect = effect;
3140
- is_updating_effect = true;
3161
+ is_updating_effect = (flags & 96) === 0;
3141
3162
  try {
3142
3163
  if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
3143
3164
  else destroy_effect_children(effect);
@@ -3266,7 +3287,7 @@ function untrack(fn) {
3266
3287
  }
3267
3288
  }
3268
3289
  //#endregion
3269
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/events.js
3290
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/events.js
3270
3291
  /**
3271
3292
  * Used on elements, as a map of event type -> event handler,
3272
3293
  * and on events themselves to track which element handled an event
@@ -3406,7 +3427,7 @@ function handle_event_propagation(event) {
3406
3427
  }
3407
3428
  }
3408
3429
  //#endregion
3409
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/reconciler.js
3430
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/reconciler.js
3410
3431
  var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
3411
3432
  /** @param {string} html */
3412
3433
  createHTML: (html) => {
@@ -3425,7 +3446,7 @@ function create_fragment_from_html(html) {
3425
3446
  return elem.content;
3426
3447
  }
3427
3448
  //#endregion
3428
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/template.js
3449
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/template.js
3429
3450
  /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3430
3451
  /** @import { TemplateStructure } from './types' */
3431
3452
  /**
@@ -3575,9 +3596,8 @@ function is_passive_event(name) {
3575
3596
  * @returns {void}
3576
3597
  */
3577
3598
  function set_text(text, value) {
3578
- var _text;
3579
3599
  var str = value == null ? "" : typeof value === "object" ? `${value}` : value;
3580
- if (str !== ((_text = text)[TEXT_CACHE] ?? (_text[TEXT_CACHE] = text.nodeValue))) {
3600
+ if (str !== (text[TEXT_CACHE] ?? (text[TEXT_CACHE] = text.nodeValue))) {
3581
3601
  /** @type {any} */ text[TEXT_CACHE] = str;
3582
3602
  text.nodeValue = `${str}`;
3583
3603
  }
@@ -3758,7 +3778,7 @@ function unmount(component, options) {
3758
3778
  return Promise.resolve();
3759
3779
  }
3760
3780
  //#endregion
3761
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3781
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3762
3782
  /** @import { Effect, TemplateNode } from '#client' */
3763
3783
  var _batches = /* @__PURE__ */ new WeakMap();
3764
3784
  var _onscreen = /* @__PURE__ */ new WeakMap();
@@ -3881,7 +3901,7 @@ var BranchManager = class {
3881
3901
  }
3882
3902
  };
3883
3903
  //#endregion
3884
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/snippet.js
3904
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/blocks/snippet.js
3885
3905
  /** @import { Snippet } from 'svelte' */
3886
3906
  /** @import { TemplateNode } from '#client' */
3887
3907
  /** @import { Getters } from '#shared' */
@@ -3934,7 +3954,7 @@ function init_update_callbacks(context) {
3934
3954
  });
3935
3955
  }
3936
3956
  //#endregion
3937
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/if.js
3957
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/blocks/if.js
3938
3958
  /** @import { TemplateNode } from '#client' */
3939
3959
  /**
3940
3960
  * @param {TemplateNode} node
@@ -3980,7 +4000,7 @@ function if_block(node, fn, elseif = false) {
3980
4000
  }, flags);
3981
4001
  }
3982
4002
  //#endregion
3983
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/each.js
4003
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/blocks/each.js
3984
4004
  /** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
3985
4005
  /** @import { Batch } from '../../reactivity/batch.js'; */
3986
4006
  /**
@@ -4452,7 +4472,7 @@ function html(node, get_value, is_controlled = false, svg = false, mathml = fals
4452
4472
  });
4453
4473
  }
4454
4474
  //#endregion
4455
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/css.js
4475
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/css.js
4456
4476
  /**
4457
4477
  * @param {Node} anchor
4458
4478
  * @param {{ hash: string, code: string }} css
@@ -4470,7 +4490,7 @@ function append_styles$1(anchor, css) {
4470
4490
  });
4471
4491
  }
4472
4492
  //#endregion
4473
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/shared/attributes.js
4493
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/shared/attributes.js
4474
4494
  var whitespace = [..." \n\r\f\xA0\v"];
4475
4495
  /**
4476
4496
  * @param {any} value
@@ -4580,7 +4600,7 @@ function to_style(value, styles) {
4580
4600
  return value == null ? null : String(value);
4581
4601
  }
4582
4602
  //#endregion
4583
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/class.js
4603
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/class.js
4584
4604
  /**
4585
4605
  * @param {Element} dom
4586
4606
  * @param {boolean | number} is_html
@@ -4605,7 +4625,7 @@ function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
4605
4625
  return next_classes;
4606
4626
  }
4607
4627
  //#endregion
4608
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/style.js
4628
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/style.js
4609
4629
  /**
4610
4630
  * @param {Element & ElementCSSInlineStyle} dom
4611
4631
  * @param {Record<string, any>} prev
@@ -4639,7 +4659,7 @@ function set_style(dom, value, prev_styles, next_styles) {
4639
4659
  return next_styles;
4640
4660
  }
4641
4661
  //#endregion
4642
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4662
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4643
4663
  /** @import { Blocker, Effect } from '#client' */
4644
4664
  var IS_CUSTOM_ELEMENT = Symbol("is custom element");
4645
4665
  var IS_HTML = Symbol("is html");
@@ -4670,8 +4690,7 @@ function set_attribute(element, attribute, value, skip_warning) {
4670
4690
  * @param {Element} element
4671
4691
  */
4672
4692
  function get_attributes(element) {
4673
- var _element;
4674
- return (_element = element)[ATTRIBUTES_CACHE] ?? (_element[ATTRIBUTES_CACHE] = {
4693
+ return element[ATTRIBUTES_CACHE] ?? (element[ATTRIBUTES_CACHE] = {
4675
4694
  [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
4676
4695
  [IS_HTML]: element.namespaceURI === "http://www.w3.org/1999/xhtml"
4677
4696
  });
@@ -4695,7 +4714,7 @@ function get_setters(element) {
4695
4714
  return setters;
4696
4715
  }
4697
4716
  //#endregion
4698
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4717
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4699
4718
  var _ResizeObserverSingleton;
4700
4719
  var _listeners = /* @__PURE__ */ new WeakMap();
4701
4720
  var _observer = /* @__PURE__ */ new WeakMap();
@@ -4747,7 +4766,7 @@ function _getObserver() {
4747
4766
  }
4748
4767
  _defineProperty(ResizeObserverSingleton, "entries", /* @__PURE__ */ new WeakMap());
4749
4768
  //#endregion
4750
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
4769
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
4751
4770
  /** @import { ComponentContext, Effect } from '#client' */
4752
4771
  /**
4753
4772
  * @param {any} bound_value
@@ -4889,7 +4908,7 @@ function prop(props, key, flags, fallback) {
4889
4908
  });
4890
4909
  }
4891
4910
  //#endregion
4892
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/legacy/legacy-client.js
4911
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/legacy/legacy-client.js
4893
4912
  /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
4894
4913
  /**
4895
4914
  * Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
@@ -5008,7 +5027,7 @@ var Svelte4Component = class {
5008
5027
  }
5009
5028
  };
5010
5029
  //#endregion
5011
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
5030
+ //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
5012
5031
  /**
5013
5032
  * @typedef {Object} CustomElementPropDefinition
5014
5033
  * @property {string} [attribute]
@@ -5294,7 +5313,8 @@ function create_custom_element(Component, props_definition, slots, exports, shad
5294
5313
  }
5295
5314
  //#endregion
5296
5315
  //#region ../../lib-svelte/delivery-events/dist/index2.js
5297
- var _e, _e2;
5316
+ var _e;
5317
+ var _e2;
5298
5318
  var e$1 = (_e = class e extends CustomEvent {
5299
5319
  constructor(t, n, r) {
5300
5320
  super(e.TYPE, {
@@ -5307,7 +5327,8 @@ var e$1 = (_e = class e extends CustomEvent {
5307
5327
  }
5308
5328
  }), this.component = t, this.complete = n;
5309
5329
  }
5310
- }, _e.TYPE = "model-set", _e), t$2 = (_e2 = class e extends CustomEvent {
5330
+ }, _e.TYPE = "model-set", _e);
5331
+ var t$2 = (_e2 = class e extends CustomEvent {
5311
5332
  constructor(t, n) {
5312
5333
  super(e.TYPE, {
5313
5334
  bubbles: !0,
@@ -5343,11 +5364,11 @@ function r$1({ sourceEl: t, fallbackSelector: r, component: i, complete: a, sess
5343
5364
  }
5344
5365
  //#endregion
5345
5366
  //#region ../../shared/math-rendering-mathjax/dist/index.js
5346
- var e = "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", t = null;
5347
- function n(n) {
5348
- return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : t || (t = new Promise((t, r) => {
5349
- let { useSingleDollar: i = !1, accessibility: a = !0, loadFonts: o = !0, srcUrl: s } = n, c = {
5350
- loader: { load: a ? ["a11y/assistive-mml"] : [] },
5367
+ var e = null;
5368
+ function t(t) {
5369
+ return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : e || (e = new Promise((e, n) => {
5370
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = t, s = {
5371
+ loader: { load: i ? ["a11y/assistive-mml"] : [] },
5351
5372
  tex: {
5352
5373
  packages: [
5353
5374
  "base",
@@ -5362,27 +5383,27 @@ function n(n) {
5362
5383
  }
5363
5384
  },
5364
5385
  options: {
5365
- enableMenu: a,
5366
- enableExplorer: a,
5367
- enableAssistiveMml: a
5386
+ enableMenu: i,
5387
+ enableExplorer: i,
5388
+ enableAssistiveMml: i
5368
5389
  },
5369
5390
  startup: {
5370
5391
  ready: () => {
5371
- window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), t());
5392
+ window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), e());
5372
5393
  },
5373
5394
  defaultReady: () => {}
5374
5395
  }
5375
5396
  };
5376
- i && c.tex && (c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), o || (c.chtml = { fontURL: "" }), window.MathJax = c;
5377
- let l = document.createElement("script");
5378
- l.src = s || e, l.async = !0, l.onload = () => {
5379
- setTimeout(t, 100);
5380
- }, l.onerror = () => {
5381
- r(/* @__PURE__ */ Error("Failed to load MathJax"));
5382
- }, document.head.appendChild(l);
5383
- }), t);
5384
- }
5385
- function r() {
5397
+ r && s.tex && (s.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], s.tex.processEscapes = !0), a || (s.chtml = { fontURL: "" }), window.MathJax = s;
5398
+ let c = document.createElement("script");
5399
+ c.src = o || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", c.async = !0, c.onload = () => {
5400
+ setTimeout(e, 100);
5401
+ }, c.onerror = () => {
5402
+ n(/* @__PURE__ */ Error("Failed to load MathJax"));
5403
+ }, document.head.appendChild(c);
5404
+ }), e);
5405
+ }
5406
+ function n() {
5386
5407
  let e = window.MathJax?.startup?.document;
5387
5408
  if (typeof e?.assistiveMml == "function") try {
5388
5409
  e.assistiveMml().updateDocument?.();
@@ -5390,33 +5411,33 @@ function r() {
5390
5411
  console.warn("[mathjax-renderer] Failed to attach assistive MathML:", e);
5391
5412
  }
5392
5413
  }
5393
- function i(e = {}) {
5394
- return async (t) => {
5395
- if (await n(e), !window.MathJax?.typesetPromise) {
5414
+ function r(e = {}) {
5415
+ return async (r) => {
5416
+ if (await t(e), !window.MathJax?.typesetPromise) {
5396
5417
  console.warn("[mathjax-renderer] MathJax not loaded or missing typesetPromise.");
5397
5418
  return;
5398
5419
  }
5399
- await window.MathJax.typesetPromise([t]), r();
5420
+ await window.MathJax.typesetPromise([r]), n();
5400
5421
  };
5401
5422
  }
5402
- var o = "@pie-lib/math-rendering", s = null;
5403
- function c() {
5404
- return s || (s = i({
5423
+ var a = null;
5424
+ function o() {
5425
+ return a || (a = r({
5405
5426
  accessibility: !0,
5406
5427
  useSingleDollar: !0
5407
- })), s;
5428
+ })), a;
5408
5429
  }
5409
- function l() {
5430
+ function s() {
5410
5431
  if (typeof window > "u") return null;
5411
- let e = window[o];
5432
+ let e = window["@pie-lib/math-rendering"];
5412
5433
  return typeof e?.renderMath == "function" ? e : null;
5413
5434
  }
5414
- var u = async (e) => {
5435
+ var c = async (e) => {
5415
5436
  if (typeof window > "u") return;
5416
5437
  let t = typeof e == "string", n;
5417
5438
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
5418
- let r = l();
5419
- return r ? await r.renderMath?.(n) : await c()(n), t ? n.innerHTML : void 0;
5439
+ let r = s();
5440
+ return r ? await r.renderMath?.(n) : await o()(n), t ? n.innerHTML : void 0;
5420
5441
  };
5421
5442
  //#endregion
5422
5443
  //#region src/delivery/tile-accessible-name.ts
@@ -5438,7 +5459,7 @@ var root_3$1 = /* @__PURE__ */ from_html(`<span class="badge badge-incorrect sve
5438
5459
  var root_4$1 = /* @__PURE__ */ from_html(`<button type="button"><span><!> <!></span> <!></button>`);
5439
5460
  var $$css$2 = {
5440
5461
  hash: "svelte-1hgaksk",
5441
- code: ".venn-tile.svelte-1hgaksk {position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:64px;min-height:44px;padding:8px 14px;border:1.5px solid #334155;border-radius:10px;background:#ffffff;color:#0f172a;font-size:14px;font-weight:500;box-shadow:0 1px 2px rgba(15, 23, 42, 0.06);cursor:grab;touch-action:none;user-select:none;transition:box-shadow 120ms ease, transform 120ms ease, background 120ms ease;}.venn-tile.svelte-1hgaksk:focus-visible,\n .venn-tile.focused.svelte-1hgaksk {outline:2px solid #2563eb;outline-offset:2px;}.venn-tile.svelte-1hgaksk:hover:not(:disabled) {background:#f8fafc;}.venn-tile.held.svelte-1hgaksk {cursor:grabbing;box-shadow:0 6px 18px rgba(15, 23, 42, 0.18);transform:translateY(-1px);background:#eef2ff;}.venn-tile.invisible.svelte-1hgaksk {visibility:hidden;}.venn-tile.ghost.svelte-1hgaksk {pointer-events:none;cursor:grabbing;box-shadow:0 10px 24px rgba(15, 23, 42, 0.22);transform:rotate(-1.5deg);background:#ffffff;opacity:0.96;}.venn-tile.correct.svelte-1hgaksk {border-color:#0ea449;}.venn-tile.incorrect.svelte-1hgaksk {border-color:#bf0d00;}.venn-tile.svelte-1hgaksk:disabled {cursor:default;}.tile-body.svelte-1hgaksk {display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:8px;pointer-events:none;max-width:220px;}.tile-body-image.svelte-1hgaksk {flex-direction:column;gap:4px;}.tile-img.svelte-1hgaksk {width:40px;height:40px;object-fit:contain;flex-shrink:0;}.tile-label.svelte-1hgaksk {pointer-events:none;text-align:center;line-height:1.25;word-break:break-word;}.tile-label-below.svelte-1hgaksk {font-size:12px;font-weight:600;}.badge.svelte-1hgaksk {position:absolute;top:-8px;right:-8px;width:20px;height:20px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#ffffff;}.badge-correct.svelte-1hgaksk {background:#0ea449;}.badge-incorrect.svelte-1hgaksk {background:#bf0d00;}\n @media (prefers-reduced-motion: reduce) {.venn-tile.svelte-1hgaksk {transition:none;}\n }"
5462
+ code: ".venn-tile.svelte-1hgaksk {position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:64px;min-height:44px;padding:8px 14px;border:1.5px solid #334155;border-radius:10px;background:#ffffff;color:#0f172a;font-size:14px;font-weight:500;box-shadow:0 1px 2px rgba(15, 23, 42, 0.06);cursor:grab;touch-action:none;user-select:none;transition:box-shadow 120ms ease, transform 120ms ease, background 120ms ease;}.venn-tile.svelte-1hgaksk:focus-visible,\n .venn-tile.focused.svelte-1hgaksk {outline:2px solid var(--vc-focus-ring, #1565c0);outline-offset:2px;}.venn-tile.svelte-1hgaksk:hover:not(:disabled) {background:#f8fafc;}.venn-tile.held.svelte-1hgaksk {cursor:grabbing;box-shadow:0 6px 18px rgba(15, 23, 42, 0.18);transform:translateY(-1px);background:#eef2ff;}.venn-tile.invisible.svelte-1hgaksk {visibility:hidden;}.venn-tile.ghost.svelte-1hgaksk {pointer-events:none;cursor:grabbing;box-shadow:0 10px 24px rgba(15, 23, 42, 0.22);transform:rotate(-1.5deg);background:#ffffff;opacity:0.96;}.venn-tile.correct.svelte-1hgaksk {border-color:#0ea449;}.venn-tile.incorrect.svelte-1hgaksk {border-color:#bf0d00;}.venn-tile.svelte-1hgaksk:disabled {cursor:default;}.tile-body.svelte-1hgaksk {display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:8px;pointer-events:none;max-width:220px;}.tile-body-image.svelte-1hgaksk {flex-direction:column;gap:4px;}.tile-img.svelte-1hgaksk {width:40px;height:40px;object-fit:contain;flex-shrink:0;}.tile-label.svelte-1hgaksk {pointer-events:none;text-align:center;line-height:1.25;word-break:break-word;}.tile-label-below.svelte-1hgaksk {font-size:12px;font-weight:600;}.badge.svelte-1hgaksk {position:absolute;top:-8px;right:-8px;width:20px;height:20px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#ffffff;}.badge-correct.svelte-1hgaksk {background:#0ea449;}.badge-incorrect.svelte-1hgaksk {background:#bf0d00;}\n @media (prefers-reduced-motion: reduce) {.venn-tile.svelte-1hgaksk {transition:none;}\n }"
5442
5463
  };
5443
5464
  function Tile($$anchor, $$props) {
5444
5465
  push($$props, true);
@@ -5649,7 +5670,7 @@ create_custom_element(Tile, {
5649
5670
  var root$1 = /* @__PURE__ */ from_html(`<div role="region" data-region-key="tray"><div class="tray-label svelte-1ogsh8s"> </div> <div class="tray-items svelte-1ogsh8s"><!></div></div>`);
5650
5671
  var $$css$1 = {
5651
5672
  hash: "svelte-1ogsh8s",
5652
- code: ".venn-tray.svelte-1ogsh8s {border:1.5px dashed #94a3b8;border-radius:12px;padding:14px 16px;background:#f8fafc;min-height:120px;transition:background 120ms ease, border-color 120ms ease;}.venn-tray.drop-target.svelte-1ogsh8s {background:#e0f2fe;border-color:#0ea5e9;}.venn-tray.focused.svelte-1ogsh8s {outline:2px solid #2563eb;outline-offset:2px;}.tray-label.svelte-1ogsh8s {font-size:12px;font-weight:600;color:#475569;text-transform:uppercase;letter-spacing:0.05em;margin-bottom:8px;}.tray-items.svelte-1ogsh8s {display:flex;flex-wrap:wrap;gap:10px;}\n @media (prefers-reduced-motion: reduce) {.venn-tray.svelte-1ogsh8s {transition:none;}\n }"
5673
+ code: ".venn-tray.svelte-1ogsh8s {border:1.5px dashed #94a3b8;border-radius:12px;padding:14px 16px;background:#f8fafc;min-height:120px;transition:background 120ms ease, border-color 120ms ease;}.venn-tray.drop-target.svelte-1ogsh8s {background:#e0f2fe;border-color:#0ea5e9;}.venn-tray.focused.svelte-1ogsh8s {outline:2px solid var(--vc-focus-ring, #1565c0);outline-offset:2px;}.tray-label.svelte-1ogsh8s {font-size:12px;font-weight:600;color:#475569;text-transform:uppercase;letter-spacing:0.05em;margin-bottom:8px;}.tray-items.svelte-1ogsh8s {display:flex;flex-wrap:wrap;gap:10px;}\n @media (prefers-reduced-motion: reduce) {.venn-tray.svelte-1ogsh8s {transition:none;}\n }"
5653
5674
  };
5654
5675
  function Tray($$anchor, $$props) {
5655
5676
  push($$props, true);
@@ -5856,7 +5877,7 @@ function makeGridSlot(center, slotsPerRow) {
5856
5877
  * compose accessible names, and `model.regionLabels` for overrides).
5857
5878
  */
5858
5879
  function buildLayout2Set(model, geometry = defaultGeometry2Set()) {
5859
- if (!model.circles || model.circles.length !== 2) throw new Error(`buildLayout2Set requires exactly 2 circles (got ${model.circles?.length ?? 0})`);
5880
+ if (model.circles?.length !== 2) throw new Error(`buildLayout2Set requires exactly 2 circles (got ${model.circles?.length ?? 0})`);
5860
5881
  const [c0, c1] = geometry.circles;
5861
5882
  const regions = enumerateRegions(2);
5862
5883
  const circleBottom = Math.max(c0.cy + c0.r, c1.cy + c1.r);
@@ -6051,12 +6072,6 @@ function groupTilesByRegion(model, session) {
6051
6072
  }
6052
6073
  return groups;
6053
6074
  }
6054
- new Set([
6055
- "$$slots",
6056
- "$$events",
6057
- "$$legacy",
6058
- "$$host"
6059
- ]);
6060
6075
  var root = /* @__PURE__ */ from_html(`<div class="venn-prompt prose svelte-gkcqor"></div>`);
6061
6076
  var root_1 = /* @__PURE__ */ from_svg(`<svg class="toggle-icon svelte-gkcqor" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-283 359 34 35" aria-hidden="true"><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>`);
6062
6077
  var root_2 = /* @__PURE__ */ from_svg(`<svg class="toggle-icon svelte-gkcqor" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-129.5 127 34 35" aria-hidden="true"><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>`);
@@ -6074,7 +6089,7 @@ var root_13 = /* @__PURE__ */ from_html(`<div class="drag-ghost svelte-gkcqor"><
6074
6089
  var root_14 = /* @__PURE__ */ from_html(`<div class="venn-root svelte-gkcqor"><!> <!> <div class="venn-diagram svelte-gkcqor"><svg preserveAspectRatio="xMidYMid meet" aria-hidden="true" class="svelte-gkcqor"><defs><mask id="venn-mask-left-only" maskUnits="userSpaceOnUse" x="0" y="0"><rect x="0" y="0" fill="black"></rect><circle fill="white"></circle><circle fill="black"></circle></mask><mask id="venn-mask-right-only" maskUnits="userSpaceOnUse" x="0" y="0"><rect x="0" y="0" fill="black"></rect><circle fill="white"></circle><circle fill="black"></circle></mask><clipPath id="venn-clip-left" clipPathUnits="userSpaceOnUse"><circle></circle></clipPath><mask id="venn-mask-outside" maskUnits="userSpaceOnUse" x="0" y="0"><rect x="0" y="0" fill="white"></rect><circle fill="black"></circle><circle fill="black"></circle></mask></defs><rect x="1" y="1" fill="#ffffff" stroke="#cbd5e1" stroke-width="1.5" rx="12"></rect><!><!><!><!><!><!><!><line x1="16" stroke="#cbd5e1" stroke-width="1" stroke-dasharray="4 6"></line></svg> <div class="region-labels svelte-gkcqor" aria-hidden="false"></div> <div class="placed-tiles svelte-gkcqor"></div></div> <!> <!> <div class="sr-only svelte-gkcqor" aria-live="polite" aria-atomic="true"></div></div>`);
6075
6090
  var $$css = {
6076
6091
  hash: "svelte-gkcqor",
6077
- code: ".venn-root.svelte-gkcqor {display:flex;flex-direction:column;gap:16px;padding:16px;color:#0f172a;font-family:system-ui, -apple-system, Segoe UI, Roboto, sans-serif;}.venn-prompt.svelte-gkcqor {font-size:16px;line-height:1.5;}.venn-prompt.svelte-gkcqor p {margin:0 0 8px 0;}.toggle-correct.svelte-gkcqor {align-self:center;display:inline-flex;align-items:center;gap:8px;margin:0 0 4px 0;padding:0;background:transparent;border:0;color:inherit;font:inherit;font-size:14px;cursor:pointer;user-select:none;}.toggle-correct.svelte-gkcqor:focus-visible {outline:2px solid #2563eb;outline-offset:2px;border-radius:2px;}.toggle-icon.svelte-gkcqor {width:25px;height:25px;flex-shrink:0;}.toggle-label.svelte-gkcqor {line-height:1.2;}.toggle-correct.svelte-gkcqor:hover .toggle-label:where(.svelte-gkcqor),\n .toggle-correct.svelte-gkcqor:focus-visible .toggle-label:where(.svelte-gkcqor) {text-decoration:underline;}.venn-diagram.svelte-gkcqor {position:relative;width:100%;\n /*\n * Keep the diagram \"smart\" about vertical space: it should not monopolise\n * the viewport and force the tray below the fold.\n * - aspect-ratio preserves the 3:2 geometry the SVG is tuned for\n * - max-width keeps the diagram from dominating wide layouts\n * - max-height (viewport-relative) shrinks it further in short windows\n * so the prompt, toggle, and tray remain in view without scrolling\n * whenever possible. The SVG uses preserveAspectRatio=\"xMidYMid meet\",\n * so when max-height wins the width reduces in lockstep.\n */max-width:720px;aspect-ratio:900 / 540;max-height:min(60vh, 430px);margin:0 auto;}.venn-diagram.svelte-gkcqor svg:where(.svelte-gkcqor) {width:100%;height:100%;display:block;}.placed-tiles.svelte-gkcqor,\n .region-labels.svelte-gkcqor {position:absolute;inset:0;pointer-events:none;}.tile-wrapper.svelte-gkcqor {position:absolute;transform:translate(-50%, -50%);pointer-events:auto;}.region-aria.svelte-gkcqor {position:absolute;width:1px;height:1px;transform:translate(-50%, -50%);opacity:0;pointer-events:none;}.sr-only.svelte-gkcqor {position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}.drag-ghost.svelte-gkcqor {position:fixed;top:0;left:0;transform:translate(-50%, -50%);pointer-events:none;z-index:1000;}"
6092
+ code: ".venn-root.svelte-gkcqor {display:flex;flex-direction:column;gap:16px;padding:16px;color:#0f172a;font-family:system-ui, -apple-system, Segoe UI, Roboto, sans-serif;--vc-focus-ring: var(\n --pie-focus-outline,\n var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565c0))\n );}.venn-prompt.svelte-gkcqor {font-size:16px;line-height:1.5;}.venn-prompt.svelte-gkcqor p {margin:0 0 8px 0;}.toggle-correct.svelte-gkcqor {align-self:center;display:inline-flex;align-items:center;gap:8px;margin:0 0 4px 0;padding:0;background:transparent;border:0;color:inherit;font:inherit;font-size:14px;cursor:pointer;user-select:none;}.toggle-correct.svelte-gkcqor:focus-visible {outline:2px solid var(--vc-focus-ring, #1565c0);outline-offset:2px;border-radius:2px;}.toggle-icon.svelte-gkcqor {width:25px;height:25px;flex-shrink:0;}.toggle-label.svelte-gkcqor {line-height:1.2;}.toggle-correct.svelte-gkcqor:hover .toggle-label:where(.svelte-gkcqor),\n .toggle-correct.svelte-gkcqor:focus-visible .toggle-label:where(.svelte-gkcqor) {text-decoration:underline;}.venn-diagram.svelte-gkcqor {position:relative;width:100%;\n /*\n * Keep the diagram \"smart\" about vertical space: it should not monopolise\n * the viewport and force the tray below the fold.\n * - aspect-ratio preserves the 3:2 geometry the SVG is tuned for\n * - max-width keeps the diagram from dominating wide layouts\n * - max-height (viewport-relative) shrinks it further in short windows\n * so the prompt, toggle, and tray remain in view without scrolling\n * whenever possible. The SVG uses preserveAspectRatio=\"xMidYMid meet\",\n * so when max-height wins the width reduces in lockstep.\n */max-width:720px;aspect-ratio:900 / 540;max-height:min(60vh, 430px);margin:0 auto;}.venn-diagram.svelte-gkcqor svg:where(.svelte-gkcqor) {width:100%;height:100%;display:block;}.placed-tiles.svelte-gkcqor,\n .region-labels.svelte-gkcqor {position:absolute;inset:0;pointer-events:none;}.tile-wrapper.svelte-gkcqor {position:absolute;transform:translate(-50%, -50%);pointer-events:auto;}.region-aria.svelte-gkcqor {position:absolute;width:1px;height:1px;transform:translate(-50%, -50%);opacity:0;pointer-events:none;}.sr-only.svelte-gkcqor {position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}.drag-ghost.svelte-gkcqor {position:fixed;top:0;left:0;transform:translate(-50%, -50%);pointer-events:none;z-index:1000;}"
6078
6093
  };
6079
6094
  function VennClassification($$anchor, $$props) {
6080
6095
  push($$props, true);
@@ -6282,7 +6297,7 @@ function VennClassification($$anchor, $$props) {
6282
6297
  function typeset() {
6283
6298
  if (!containerEl) return;
6284
6299
  try {
6285
- u(containerEl);
6300
+ c(containerEl);
6286
6301
  } catch (err) {
6287
6302
  console.warn("venn-classification: MathJax render failed", err);
6288
6303
  }