@mindflight/mindbrain-personal-studio 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/.env.example +50 -0
  2. package/README.md +134 -0
  3. package/bin/mindbrain-studio.mjs +20 -0
  4. package/build/client/_app/immutable/assets/2.BXRKVU9n.css +1 -0
  5. package/build/client/_app/immutable/assets/2.BXRKVU9n.css.br +0 -0
  6. package/build/client/_app/immutable/assets/2.BXRKVU9n.css.gz +0 -0
  7. package/build/client/_app/immutable/chunks/-OSExkSk.js +2 -0
  8. package/build/client/_app/immutable/chunks/-OSExkSk.js.br +0 -0
  9. package/build/client/_app/immutable/chunks/-OSExkSk.js.gz +0 -0
  10. package/build/client/_app/immutable/chunks/BIHI7g3E.js +1 -0
  11. package/build/client/_app/immutable/chunks/BIHI7g3E.js.br +2 -0
  12. package/build/client/_app/immutable/chunks/BIHI7g3E.js.gz +0 -0
  13. package/build/client/_app/immutable/chunks/BJB7pSge.js +1 -0
  14. package/build/client/_app/immutable/chunks/BJB7pSge.js.br +0 -0
  15. package/build/client/_app/immutable/chunks/BJB7pSge.js.gz +0 -0
  16. package/build/client/_app/immutable/chunks/BNUkRZqg.js +1 -0
  17. package/build/client/_app/immutable/chunks/BNUkRZqg.js.br +0 -0
  18. package/build/client/_app/immutable/chunks/BNUkRZqg.js.gz +0 -0
  19. package/build/client/_app/immutable/chunks/BP2JbIUZ.js +1 -0
  20. package/build/client/_app/immutable/chunks/BP2JbIUZ.js.br +0 -0
  21. package/build/client/_app/immutable/chunks/BP2JbIUZ.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/BVrgUHq-.js +1 -0
  23. package/build/client/_app/immutable/chunks/BVrgUHq-.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/BVrgUHq-.js.gz +0 -0
  25. package/build/client/_app/immutable/chunks/BmeSanva.js +1 -0
  26. package/build/client/_app/immutable/chunks/BmeSanva.js.br +0 -0
  27. package/build/client/_app/immutable/chunks/BmeSanva.js.gz +0 -0
  28. package/build/client/_app/immutable/chunks/BnkCgNCx.js +1 -0
  29. package/build/client/_app/immutable/chunks/BnkCgNCx.js.br +0 -0
  30. package/build/client/_app/immutable/chunks/BnkCgNCx.js.gz +0 -0
  31. package/build/client/_app/immutable/chunks/C5KYKPa8.js +311 -0
  32. package/build/client/_app/immutable/chunks/C5KYKPa8.js.br +0 -0
  33. package/build/client/_app/immutable/chunks/C5KYKPa8.js.gz +0 -0
  34. package/build/client/_app/immutable/chunks/CBDzfqXr.js +1 -0
  35. package/build/client/_app/immutable/chunks/CBDzfqXr.js.br +0 -0
  36. package/build/client/_app/immutable/chunks/CBDzfqXr.js.gz +0 -0
  37. package/build/client/_app/immutable/chunks/Cp9dXlPT.js +1 -0
  38. package/build/client/_app/immutable/chunks/Cp9dXlPT.js.br +0 -0
  39. package/build/client/_app/immutable/chunks/Cp9dXlPT.js.gz +0 -0
  40. package/build/client/_app/immutable/chunks/D0daF8Eh.js +2 -0
  41. package/build/client/_app/immutable/chunks/D0daF8Eh.js.br +0 -0
  42. package/build/client/_app/immutable/chunks/D0daF8Eh.js.gz +0 -0
  43. package/build/client/_app/immutable/chunks/D4SoBmS0.js +1 -0
  44. package/build/client/_app/immutable/chunks/D4SoBmS0.js.br +0 -0
  45. package/build/client/_app/immutable/chunks/D4SoBmS0.js.gz +0 -0
  46. package/build/client/_app/immutable/chunks/DpVrWha3.js +1 -0
  47. package/build/client/_app/immutable/chunks/DpVrWha3.js.br +0 -0
  48. package/build/client/_app/immutable/chunks/DpVrWha3.js.gz +0 -0
  49. package/build/client/_app/immutable/chunks/DyXQogav.js +1 -0
  50. package/build/client/_app/immutable/chunks/DyXQogav.js.br +0 -0
  51. package/build/client/_app/immutable/chunks/DyXQogav.js.gz +0 -0
  52. package/build/client/_app/immutable/chunks/Gs0cNFYG.js +1 -0
  53. package/build/client/_app/immutable/chunks/Gs0cNFYG.js.br +0 -0
  54. package/build/client/_app/immutable/chunks/Gs0cNFYG.js.gz +0 -0
  55. package/build/client/_app/immutable/chunks/NXeHtWpC.js +1 -0
  56. package/build/client/_app/immutable/chunks/NXeHtWpC.js.br +0 -0
  57. package/build/client/_app/immutable/chunks/NXeHtWpC.js.gz +0 -0
  58. package/build/client/_app/immutable/chunks/i0D5dc1Y.js +1 -0
  59. package/build/client/_app/immutable/chunks/i0D5dc1Y.js.br +0 -0
  60. package/build/client/_app/immutable/chunks/i0D5dc1Y.js.gz +0 -0
  61. package/build/client/_app/immutable/chunks/nnWk1BBo.js +1 -0
  62. package/build/client/_app/immutable/chunks/nnWk1BBo.js.br +0 -0
  63. package/build/client/_app/immutable/chunks/nnWk1BBo.js.gz +0 -0
  64. package/build/client/_app/immutable/entry/app.CVz6aYsT.js +2 -0
  65. package/build/client/_app/immutable/entry/app.CVz6aYsT.js.br +0 -0
  66. package/build/client/_app/immutable/entry/app.CVz6aYsT.js.gz +0 -0
  67. package/build/client/_app/immutable/entry/start.Bt5tVOz8.js +1 -0
  68. package/build/client/_app/immutable/entry/start.Bt5tVOz8.js.br +2 -0
  69. package/build/client/_app/immutable/entry/start.Bt5tVOz8.js.gz +0 -0
  70. package/build/client/_app/immutable/nodes/0.C2sXq0eH.js +1 -0
  71. package/build/client/_app/immutable/nodes/0.C2sXq0eH.js.br +0 -0
  72. package/build/client/_app/immutable/nodes/0.C2sXq0eH.js.gz +0 -0
  73. package/build/client/_app/immutable/nodes/1.BBtxY46Q.js +1 -0
  74. package/build/client/_app/immutable/nodes/1.BBtxY46Q.js.br +0 -0
  75. package/build/client/_app/immutable/nodes/1.BBtxY46Q.js.gz +0 -0
  76. package/build/client/_app/immutable/nodes/2.D0pSa9ko.js +9 -0
  77. package/build/client/_app/immutable/nodes/2.D0pSa9ko.js.br +0 -0
  78. package/build/client/_app/immutable/nodes/2.D0pSa9ko.js.gz +0 -0
  79. package/build/client/_app/version.json +1 -0
  80. package/build/client/_app/version.json.br +0 -0
  81. package/build/client/_app/version.json.gz +0 -0
  82. package/build/client/robots.txt +3 -0
  83. package/build/client/robots.txt.br +0 -0
  84. package/build/client/robots.txt.gz +0 -0
  85. package/build/env.js +70 -0
  86. package/build/env.js.map +1 -0
  87. package/build/handler.js +26 -0
  88. package/build/handler.js.map +1 -0
  89. package/build/index.js +149 -0
  90. package/build/index.js.map +1 -0
  91. package/build/server/chunks/chunks/edgeLinkModes.js-CfRqrZtd.js +50 -0
  92. package/build/server/chunks/chunks/edgeLinkModes.js-CfRqrZtd.js.map +1 -0
  93. package/build/server/chunks/chunks/environment.js-Bf8x1V_n.js +16 -0
  94. package/build/server/chunks/chunks/environment.js-Bf8x1V_n.js.map +1 -0
  95. package/build/server/chunks/chunks/exports.js-DFR3riS9.js +217 -0
  96. package/build/server/chunks/chunks/exports.js-DFR3riS9.js.map +1 -0
  97. package/build/server/chunks/chunks/false.js-CRHihH2U.js +4 -0
  98. package/build/server/chunks/chunks/false.js-CRHihH2U.js.map +1 -0
  99. package/build/server/chunks/chunks/graphRepository.js-D2DARfVY.js +280 -0
  100. package/build/server/chunks/chunks/graphRepository.js-D2DARfVY.js.map +1 -0
  101. package/build/server/chunks/chunks/internal.js-D8EA_he2.js +119 -0
  102. package/build/server/chunks/chunks/internal.js-D8EA_he2.js.map +1 -0
  103. package/build/server/chunks/chunks/mindbrainClient.js-BFAJqRSL.js +108 -0
  104. package/build/server/chunks/chunks/mindbrainClient.js-BFAJqRSL.js.map +1 -0
  105. package/build/server/chunks/chunks/ontologyInspect.js-Dm3l7KgF.js +13 -0
  106. package/build/server/chunks/chunks/ontologyInspect.js-Dm3l7KgF.js.map +1 -0
  107. package/build/server/chunks/chunks/render-context.js-CTu5Wkzp.js +475 -0
  108. package/build/server/chunks/chunks/render-context.js-CTu5Wkzp.js.map +1 -0
  109. package/build/server/chunks/chunks/renderer.js-DsOhU1UZ.js +1243 -0
  110. package/build/server/chunks/chunks/renderer.js-DsOhU1UZ.js.map +1 -0
  111. package/build/server/chunks/chunks/root.js-DCnlE3XY.js +2815 -0
  112. package/build/server/chunks/chunks/root.js-DCnlE3XY.js.map +1 -0
  113. package/build/server/chunks/chunks/shared-server.js-DaWdgxVh.js +11 -0
  114. package/build/server/chunks/chunks/shared-server.js-DaWdgxVh.js.map +1 -0
  115. package/build/server/chunks/chunks/shared.js-DuDDTJVi.js +1338 -0
  116. package/build/server/chunks/chunks/shared.js-DuDDTJVi.js.map +1 -0
  117. package/build/server/chunks/chunks/utils.js-DGYJFmnf.js +39 -0
  118. package/build/server/chunks/chunks/utils.js-DGYJFmnf.js.map +1 -0
  119. package/build/server/chunks/entries/endpoints/api/brain/_...path_/_server.ts.js-MgPpKBks.js +82 -0
  120. package/build/server/chunks/entries/endpoints/api/brain/_...path_/_server.ts.js-MgPpKBks.js.map +1 -0
  121. package/build/server/chunks/entries/endpoints/api/brain/health/_server.ts.js-DnJQNmWV.js +19 -0
  122. package/build/server/chunks/entries/endpoints/api/brain/health/_server.ts.js-DnJQNmWV.js.map +1 -0
  123. package/build/server/chunks/entries/endpoints/api/graph/_server.ts.js-Bxo7qHVz.js +37 -0
  124. package/build/server/chunks/entries/endpoints/api/graph/_server.ts.js-Bxo7qHVz.js.map +1 -0
  125. package/build/server/chunks/entries/endpoints/api/graph/count/_server.ts.js-BajaLnqp.js +37 -0
  126. package/build/server/chunks/entries/endpoints/api/graph/count/_server.ts.js-BajaLnqp.js.map +1 -0
  127. package/build/server/chunks/entries/endpoints/api/graph/ontologies/_server.ts.js-BFq2mbbX.js +146 -0
  128. package/build/server/chunks/entries/endpoints/api/graph/ontologies/_server.ts.js-BFq2mbbX.js.map +1 -0
  129. package/build/server/chunks/entries/endpoints/api/graph/schema-registry/_server.ts.js-Dyfsc-VA.js +154 -0
  130. package/build/server/chunks/entries/endpoints/api/graph/schema-registry/_server.ts.js-Dyfsc-VA.js.map +1 -0
  131. package/build/server/chunks/entries/endpoints/api/projections/catalog/_server.ts.js-Ds1RymA0.js +351 -0
  132. package/build/server/chunks/entries/endpoints/api/projections/catalog/_server.ts.js-Ds1RymA0.js.map +1 -0
  133. package/build/server/chunks/entries/fallbacks/error.svelte.js-B7V4yZjo.js +51 -0
  134. package/build/server/chunks/entries/fallbacks/error.svelte.js-B7V4yZjo.js.map +1 -0
  135. package/build/server/chunks/entries/pages/_layout.svelte.js-CoC9BAeH.js +15 -0
  136. package/build/server/chunks/entries/pages/_layout.svelte.js-CoC9BAeH.js.map +1 -0
  137. package/build/server/chunks/entries/pages/_page.svelte.js-DMEbD3K6.js +891 -0
  138. package/build/server/chunks/entries/pages/_page.svelte.js-DMEbD3K6.js.map +1 -0
  139. package/build/server/chunks/handler-BjXBCd1c.js +1698 -0
  140. package/build/server/chunks/handler-BjXBCd1c.js.map +1 -0
  141. package/build/server/chunks/index.js-BJYcV8V7.js +4183 -0
  142. package/build/server/chunks/index.js-BJYcV8V7.js.map +1 -0
  143. package/build/server/chunks/manifest.js-Ddaot0P4.js +91 -0
  144. package/build/server/chunks/manifest.js-Ddaot0P4.js.map +1 -0
  145. package/build/server/chunks/nodes/0.js-87v83UX9.js +9 -0
  146. package/build/server/chunks/nodes/0.js-87v83UX9.js.map +1 -0
  147. package/build/server/chunks/nodes/1.js-BRigw_9J.js +9 -0
  148. package/build/server/chunks/nodes/1.js-BRigw_9J.js.map +1 -0
  149. package/build/server/chunks/nodes/2.js-D9-B_qyX.js +9 -0
  150. package/build/server/chunks/nodes/2.js-D9-B_qyX.js.map +1 -0
  151. package/build/shims.js +33 -0
  152. package/build/shims.js.map +1 -0
  153. package/fixtures/minimal-graph.sqlite +0 -0
  154. package/package.json +81 -0
  155. package/scripts/backend-sqlite.mjs +190 -0
  156. package/scripts/build-serenity-v6-concept-review-pack.mjs +493 -0
  157. package/scripts/build-serenity-v6-review-pack.mjs +479 -0
  158. package/scripts/create-serenity-production-v6.mjs +627 -0
  159. package/scripts/dev-sqlite.mjs +86 -0
  160. package/scripts/export-serenity-v6-backup.mjs +178 -0
  161. package/scripts/import-serenity-v6-user-decisions.mjs +543 -0
  162. package/scripts/lib/sqlite-runtime.mjs +197 -0
  163. package/scripts/materialize-serenity-v6-snapshots.mjs +675 -0
  164. package/scripts/publish-npm.mjs +134 -0
  165. package/scripts/seed-immeuble-projections.mjs +169 -0
  166. package/scripts/studio-sqlite.mjs +74 -0
@@ -0,0 +1,2815 @@
1
+ import { r as render, L as LEGACY_PROPS, d as define_property, C as CONNECTED, R as REACTION_RAN, E as ERROR_VALUE, a as COMMENT_NODE, H as HYDRATION_START, b as HYDRATION_ERROR, S as STATE_SYMBOL, o as object_prototype, c as array_prototype, U as UNINITIALIZED, g as get_descriptor, D as DERIVED, e as DIRTY, M as MAYBE_DIRTY, i as is_extensible, f as get_prototype_of, h as is_array, j as CLEAN, I as INERT, k as EFFECT, B as BLOCK_EFFECT, l as DESTROYED, m as EAGER_EFFECT, A as ASYNC, n as deferred, p as RENDER_EFFECT, q as MANAGED_EFFECT, s as ROOT_EFFECT, t as BRANCH_EFFECT, W as WAS_MARKED, u as run_all, v as includes, w as REACTION_IS_UPDATING, x as EFFECT_PRESERVED, y as EFFECT_TRANSPARENT, z as HEAD_EFFECT, F as DESTROYING, G as BOUNDARY_EFFECT, J as index_of, K as STALE_REACTION, N as noop, O as array_from, P as is_passive_event, Q as setContext, T as derived, V as HYDRATION_END, X as HYDRATION_START_ELSE, Y as HYDRATION_START_FAILED, Z as USER_EFFECT } from './renderer.js-DsOhU1UZ.js';
2
+ import { B as BROWSER } from './false.js-CRHihH2U.js';
3
+
4
+ let tracing_mode_flag = false;
5
+ function effect_update_depth_exceeded() {
6
+ {
7
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
8
+ }
9
+ }
10
+ function hydration_failed() {
11
+ {
12
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
13
+ }
14
+ }
15
+ function state_descriptors_fixed() {
16
+ {
17
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
18
+ }
19
+ }
20
+ function state_prototype_fixed() {
21
+ {
22
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
23
+ }
24
+ }
25
+ function state_unsafe_mutation() {
26
+ {
27
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
28
+ }
29
+ }
30
+ function svelte_boundary_reset_onerror() {
31
+ {
32
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
33
+ }
34
+ }
35
+ function hydration_mismatch(location) {
36
+ {
37
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
38
+ }
39
+ }
40
+ function svelte_boundary_reset_noop() {
41
+ {
42
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
43
+ }
44
+ }
45
+ let hydrating = false;
46
+ function set_hydrating(value) {
47
+ hydrating = value;
48
+ }
49
+ let hydrate_node;
50
+ function set_hydrate_node(node) {
51
+ if (node === null) {
52
+ hydration_mismatch();
53
+ throw HYDRATION_ERROR;
54
+ }
55
+ return hydrate_node = node;
56
+ }
57
+ function hydrate_next() {
58
+ return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
59
+ }
60
+ function next(count = 1) {
61
+ if (hydrating) {
62
+ var i = count;
63
+ var node = hydrate_node;
64
+ while (i--) {
65
+ node = /** @type {TemplateNode} */
66
+ /* @__PURE__ */ get_next_sibling(node);
67
+ }
68
+ hydrate_node = node;
69
+ }
70
+ }
71
+ function skip_nodes(remove = true) {
72
+ var depth = 0;
73
+ var node = hydrate_node;
74
+ while (true) {
75
+ if (node.nodeType === COMMENT_NODE) {
76
+ var data = (
77
+ /** @type {Comment} */
78
+ node.data
79
+ );
80
+ if (data === HYDRATION_END) {
81
+ if (depth === 0) return node;
82
+ depth -= 1;
83
+ } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE || // "[1", "[2", etc. for if blocks
84
+ data[0] === "[" && !isNaN(Number(data.slice(1)))) {
85
+ depth += 1;
86
+ }
87
+ }
88
+ var next2 = (
89
+ /** @type {TemplateNode} */
90
+ /* @__PURE__ */ get_next_sibling(node)
91
+ );
92
+ if (remove) node.remove();
93
+ node = next2;
94
+ }
95
+ }
96
+ function equals(value) {
97
+ return value === this.v;
98
+ }
99
+ function safe_not_equal(a, b) {
100
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
101
+ }
102
+ function safe_equals(value) {
103
+ return !safe_not_equal(value, this.v);
104
+ }
105
+ let component_context = null;
106
+ function set_component_context(context) {
107
+ component_context = context;
108
+ }
109
+ function push(props, runes = false, fn) {
110
+ component_context = {
111
+ p: component_context,
112
+ i: false,
113
+ c: null,
114
+ e: null,
115
+ s: props,
116
+ x: null,
117
+ r: (
118
+ /** @type {Effect} */
119
+ active_effect
120
+ ),
121
+ l: null
122
+ };
123
+ }
124
+ function pop(component) {
125
+ var context = (
126
+ /** @type {ComponentContext} */
127
+ component_context
128
+ );
129
+ var effects = context.e;
130
+ if (effects !== null) {
131
+ context.e = null;
132
+ for (var fn of effects) {
133
+ create_user_effect(fn);
134
+ }
135
+ }
136
+ context.i = true;
137
+ component_context = context.p;
138
+ return (
139
+ /** @type {T} */
140
+ {}
141
+ );
142
+ }
143
+ function is_runes() {
144
+ return true;
145
+ }
146
+ let micro_tasks = [];
147
+ function run_micro_tasks() {
148
+ var tasks = micro_tasks;
149
+ micro_tasks = [];
150
+ run_all(tasks);
151
+ }
152
+ function queue_micro_task(fn) {
153
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
154
+ var tasks = micro_tasks;
155
+ queueMicrotask(() => {
156
+ if (tasks === micro_tasks) run_micro_tasks();
157
+ });
158
+ }
159
+ micro_tasks.push(fn);
160
+ }
161
+ function flush_tasks() {
162
+ while (micro_tasks.length > 0) {
163
+ run_micro_tasks();
164
+ }
165
+ }
166
+ function handle_error(error) {
167
+ var effect = active_effect;
168
+ if (effect === null) {
169
+ active_reaction.f |= ERROR_VALUE;
170
+ return error;
171
+ }
172
+ if ((effect.f & REACTION_RAN) === 0 && (effect.f & EFFECT) === 0) {
173
+ throw error;
174
+ }
175
+ invoke_error_boundary(error, effect);
176
+ }
177
+ function invoke_error_boundary(error, effect) {
178
+ while (effect !== null) {
179
+ if ((effect.f & BOUNDARY_EFFECT) !== 0) {
180
+ if ((effect.f & REACTION_RAN) === 0) {
181
+ throw error;
182
+ }
183
+ try {
184
+ effect.b.error(error);
185
+ return;
186
+ } catch (e) {
187
+ error = e;
188
+ }
189
+ }
190
+ effect = effect.parent;
191
+ }
192
+ throw error;
193
+ }
194
+ const STATUS_MASK = -7169;
195
+ function set_signal_status(signal, status) {
196
+ signal.f = signal.f & STATUS_MASK | status;
197
+ }
198
+ function update_derived_status(derived2) {
199
+ if ((derived2.f & CONNECTED) !== 0 || derived2.deps === null) {
200
+ set_signal_status(derived2, CLEAN);
201
+ } else {
202
+ set_signal_status(derived2, MAYBE_DIRTY);
203
+ }
204
+ }
205
+ function clear_marked(deps) {
206
+ if (deps === null) return;
207
+ for (const dep of deps) {
208
+ if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) {
209
+ continue;
210
+ }
211
+ dep.f ^= WAS_MARKED;
212
+ clear_marked(
213
+ /** @type {Derived} */
214
+ dep.deps
215
+ );
216
+ }
217
+ }
218
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
219
+ if ((effect.f & DIRTY) !== 0) {
220
+ dirty_effects.add(effect);
221
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
222
+ maybe_dirty_effects.add(effect);
223
+ }
224
+ clear_marked(effect.deps);
225
+ set_signal_status(effect, CLEAN);
226
+ }
227
+ const batches = /* @__PURE__ */ new Set();
228
+ let current_batch = null;
229
+ let batch_values = null;
230
+ let last_scheduled_effect = null;
231
+ let is_flushing_sync = false;
232
+ let is_processing = false;
233
+ let collected_effects = null;
234
+ let legacy_updates = null;
235
+ var flush_count = 0;
236
+ let uid = 1;
237
+ class Batch {
238
+ id = uid++;
239
+ /**
240
+ * The current values of any signals that are updated in this batch.
241
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
242
+ * They keys of this map are identical to `this.#previous`
243
+ * @type {Map<Value, [any, boolean]>}
244
+ */
245
+ current = /* @__PURE__ */ new Map();
246
+ /**
247
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
248
+ * They keys of this map are identical to `this.#current`
249
+ * @type {Map<Value, any>}
250
+ */
251
+ previous = /* @__PURE__ */ new Map();
252
+ /**
253
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
254
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
255
+ * @type {Set<(batch: Batch) => void>}
256
+ */
257
+ #commit_callbacks = /* @__PURE__ */ new Set();
258
+ /**
259
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
260
+ * @type {Set<(batch: Batch) => void>}
261
+ */
262
+ #discard_callbacks = /* @__PURE__ */ new Set();
263
+ /**
264
+ * Async effects that are currently in flight
265
+ * @type {Map<Effect, number>}
266
+ */
267
+ #pending = /* @__PURE__ */ new Map();
268
+ /**
269
+ * Async effects that are currently in flight, _not_ inside a pending boundary
270
+ * @type {Map<Effect, number>}
271
+ */
272
+ #blocking_pending = /* @__PURE__ */ new Map();
273
+ /**
274
+ * A deferred that resolves when the batch is committed, used with `settled()`
275
+ * TODO replace with Promise.withResolvers once supported widely enough
276
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
277
+ */
278
+ #deferred = null;
279
+ /**
280
+ * The root effects that need to be flushed
281
+ * @type {Effect[]}
282
+ */
283
+ #roots = [];
284
+ /**
285
+ * Effects created while this batch was active.
286
+ * @type {Effect[]}
287
+ */
288
+ #new_effects = [];
289
+ /**
290
+ * Deferred effects (which run after async work has completed) that are DIRTY
291
+ * @type {Set<Effect>}
292
+ */
293
+ #dirty_effects = /* @__PURE__ */ new Set();
294
+ /**
295
+ * Deferred effects that are MAYBE_DIRTY
296
+ * @type {Set<Effect>}
297
+ */
298
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
299
+ /**
300
+ * A map of branches that still exist, but will be destroyed when this batch
301
+ * is committed — we skip over these during `process`.
302
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
303
+ * so they can be rescheduled if the branch survives.
304
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
305
+ */
306
+ #skipped_branches = /* @__PURE__ */ new Map();
307
+ is_fork = false;
308
+ #decrement_queued = false;
309
+ /** @type {Set<Batch>} */
310
+ #blockers = /* @__PURE__ */ new Set();
311
+ #is_deferred() {
312
+ return this.is_fork || this.#blocking_pending.size > 0;
313
+ }
314
+ #is_blocked() {
315
+ for (const batch of this.#blockers) {
316
+ for (const effect of batch.#blocking_pending.keys()) {
317
+ var skipped = false;
318
+ var e = effect;
319
+ while (e.parent !== null) {
320
+ if (this.#skipped_branches.has(e)) {
321
+ skipped = true;
322
+ break;
323
+ }
324
+ e = e.parent;
325
+ }
326
+ if (!skipped) {
327
+ return true;
328
+ }
329
+ }
330
+ }
331
+ return false;
332
+ }
333
+ /**
334
+ * Add an effect to the #skipped_branches map and reset its children
335
+ * @param {Effect} effect
336
+ */
337
+ skip_effect(effect) {
338
+ if (!this.#skipped_branches.has(effect)) {
339
+ this.#skipped_branches.set(effect, { d: [], m: [] });
340
+ }
341
+ }
342
+ /**
343
+ * Remove an effect from the #skipped_branches map and reschedule
344
+ * any tracked dirty/maybe_dirty child effects
345
+ * @param {Effect} effect
346
+ */
347
+ unskip_effect(effect) {
348
+ var tracked = this.#skipped_branches.get(effect);
349
+ if (tracked) {
350
+ this.#skipped_branches.delete(effect);
351
+ for (var e of tracked.d) {
352
+ set_signal_status(e, DIRTY);
353
+ this.schedule(e);
354
+ }
355
+ for (e of tracked.m) {
356
+ set_signal_status(e, MAYBE_DIRTY);
357
+ this.schedule(e);
358
+ }
359
+ }
360
+ }
361
+ #process() {
362
+ if (flush_count++ > 1e3) {
363
+ batches.delete(this);
364
+ infinite_loop_guard();
365
+ }
366
+ if (!this.#is_deferred()) {
367
+ for (const e of this.#dirty_effects) {
368
+ this.#maybe_dirty_effects.delete(e);
369
+ set_signal_status(e, DIRTY);
370
+ this.schedule(e);
371
+ }
372
+ for (const e of this.#maybe_dirty_effects) {
373
+ set_signal_status(e, MAYBE_DIRTY);
374
+ this.schedule(e);
375
+ }
376
+ }
377
+ const roots = this.#roots;
378
+ this.#roots = [];
379
+ this.apply();
380
+ var effects = collected_effects = [];
381
+ var render_effects = [];
382
+ var updates = legacy_updates = [];
383
+ for (const root2 of roots) {
384
+ try {
385
+ this.#traverse(root2, effects, render_effects);
386
+ } catch (e) {
387
+ reset_all(root2);
388
+ throw e;
389
+ }
390
+ }
391
+ current_batch = null;
392
+ if (updates.length > 0) {
393
+ var batch = Batch.ensure();
394
+ for (const e of updates) {
395
+ batch.schedule(e);
396
+ }
397
+ }
398
+ collected_effects = null;
399
+ legacy_updates = null;
400
+ if (this.#is_deferred() || this.#is_blocked()) {
401
+ this.#defer_effects(render_effects);
402
+ this.#defer_effects(effects);
403
+ for (const [e, t] of this.#skipped_branches) {
404
+ reset_branch(e, t);
405
+ }
406
+ } else {
407
+ if (this.#pending.size === 0) {
408
+ batches.delete(this);
409
+ }
410
+ this.#dirty_effects.clear();
411
+ this.#maybe_dirty_effects.clear();
412
+ for (const fn of this.#commit_callbacks) fn(this);
413
+ this.#commit_callbacks.clear();
414
+ flush_queued_effects(render_effects);
415
+ flush_queued_effects(effects);
416
+ this.#deferred?.resolve();
417
+ }
418
+ var next_batch = (
419
+ /** @type {Batch | null} */
420
+ /** @type {unknown} */
421
+ current_batch
422
+ );
423
+ if (this.#roots.length > 0) {
424
+ const batch2 = next_batch ??= this;
425
+ batch2.#roots.push(...this.#roots.filter((r) => !batch2.#roots.includes(r)));
426
+ }
427
+ if (next_batch !== null) {
428
+ batches.add(next_batch);
429
+ next_batch.#process();
430
+ }
431
+ if (!batches.has(this)) {
432
+ this.#commit();
433
+ }
434
+ }
435
+ /**
436
+ * Traverse the effect tree, executing effects or stashing
437
+ * them for later execution as appropriate
438
+ * @param {Effect} root
439
+ * @param {Effect[]} effects
440
+ * @param {Effect[]} render_effects
441
+ */
442
+ #traverse(root2, effects, render_effects) {
443
+ root2.f ^= CLEAN;
444
+ var effect = root2.first;
445
+ while (effect !== null) {
446
+ var flags2 = effect.f;
447
+ var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
448
+ var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0;
449
+ var skip = is_skippable_branch || (flags2 & INERT) !== 0 || this.#skipped_branches.has(effect);
450
+ if (!skip && effect.fn !== null) {
451
+ if (is_branch) {
452
+ effect.f ^= CLEAN;
453
+ } else if ((flags2 & EFFECT) !== 0) {
454
+ effects.push(effect);
455
+ } else if (is_dirty(effect)) {
456
+ if ((flags2 & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
457
+ update_effect(effect);
458
+ }
459
+ var child = effect.first;
460
+ if (child !== null) {
461
+ effect = child;
462
+ continue;
463
+ }
464
+ }
465
+ while (effect !== null) {
466
+ var next2 = effect.next;
467
+ if (next2 !== null) {
468
+ effect = next2;
469
+ break;
470
+ }
471
+ effect = effect.parent;
472
+ }
473
+ }
474
+ }
475
+ /**
476
+ * @param {Effect[]} effects
477
+ */
478
+ #defer_effects(effects) {
479
+ for (var i = 0; i < effects.length; i += 1) {
480
+ defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
481
+ }
482
+ }
483
+ /**
484
+ * Associate a change to a given source with the current
485
+ * batch, noting its previous and current values
486
+ * @param {Value} source
487
+ * @param {any} old_value
488
+ * @param {boolean} [is_derived]
489
+ */
490
+ capture(source2, old_value, is_derived = false) {
491
+ if (old_value !== UNINITIALIZED && !this.previous.has(source2)) {
492
+ this.previous.set(source2, old_value);
493
+ }
494
+ if ((source2.f & ERROR_VALUE) === 0) {
495
+ this.current.set(source2, [source2.v, is_derived]);
496
+ batch_values?.set(source2, source2.v);
497
+ }
498
+ }
499
+ activate() {
500
+ current_batch = this;
501
+ }
502
+ deactivate() {
503
+ current_batch = null;
504
+ batch_values = null;
505
+ }
506
+ flush() {
507
+ try {
508
+ is_processing = true;
509
+ current_batch = this;
510
+ this.#process();
511
+ } finally {
512
+ flush_count = 0;
513
+ last_scheduled_effect = null;
514
+ collected_effects = null;
515
+ legacy_updates = null;
516
+ is_processing = false;
517
+ current_batch = null;
518
+ batch_values = null;
519
+ old_values.clear();
520
+ }
521
+ }
522
+ discard() {
523
+ for (const fn of this.#discard_callbacks) fn(this);
524
+ this.#discard_callbacks.clear();
525
+ batches.delete(this);
526
+ }
527
+ /**
528
+ * @param {Effect} effect
529
+ */
530
+ register_created_effect(effect) {
531
+ this.#new_effects.push(effect);
532
+ }
533
+ #commit() {
534
+ for (const batch of batches) {
535
+ var is_earlier = batch.id < this.id;
536
+ var sources = [];
537
+ for (const [source3, [value, is_derived]] of this.current) {
538
+ if (batch.current.has(source3)) {
539
+ var batch_value = (
540
+ /** @type {[any, boolean]} */
541
+ batch.current.get(source3)[0]
542
+ );
543
+ if (is_earlier && value !== batch_value) {
544
+ batch.current.set(source3, [value, is_derived]);
545
+ } else {
546
+ continue;
547
+ }
548
+ }
549
+ sources.push(source3);
550
+ }
551
+ var others = [...batch.current.keys()].filter((s) => !this.current.has(s));
552
+ if (others.length === 0) {
553
+ if (is_earlier) {
554
+ batch.discard();
555
+ }
556
+ } else if (sources.length > 0) {
557
+ batch.activate();
558
+ var marked = /* @__PURE__ */ new Set();
559
+ var checked = /* @__PURE__ */ new Map();
560
+ for (var source2 of sources) {
561
+ mark_effects(source2, others, marked, checked);
562
+ }
563
+ checked = /* @__PURE__ */ new Map();
564
+ var current_unequal = [...batch.current.keys()].filter(
565
+ (c) => this.current.has(c) ? (
566
+ /** @type {[any, boolean]} */
567
+ this.current.get(c)[0] !== c
568
+ ) : true
569
+ );
570
+ for (const effect of this.#new_effects) {
571
+ if ((effect.f & (DESTROYED | INERT | EAGER_EFFECT)) === 0 && depends_on(effect, current_unequal, checked)) {
572
+ if ((effect.f & (ASYNC | BLOCK_EFFECT)) !== 0) {
573
+ set_signal_status(effect, DIRTY);
574
+ batch.schedule(effect);
575
+ } else {
576
+ batch.#dirty_effects.add(effect);
577
+ }
578
+ }
579
+ }
580
+ if (batch.#roots.length > 0) {
581
+ batch.apply();
582
+ for (var root2 of batch.#roots) {
583
+ batch.#traverse(root2, [], []);
584
+ }
585
+ batch.#roots = [];
586
+ }
587
+ batch.deactivate();
588
+ }
589
+ }
590
+ for (const batch of batches) {
591
+ if (batch.#blockers.has(this)) {
592
+ batch.#blockers.delete(this);
593
+ if (batch.#blockers.size === 0 && !batch.#is_deferred()) {
594
+ batch.activate();
595
+ batch.#process();
596
+ }
597
+ }
598
+ }
599
+ }
600
+ /**
601
+ * @param {boolean} blocking
602
+ * @param {Effect} effect
603
+ */
604
+ increment(blocking, effect) {
605
+ let pending_count = this.#pending.get(effect) ?? 0;
606
+ this.#pending.set(effect, pending_count + 1);
607
+ if (blocking) {
608
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
609
+ this.#blocking_pending.set(effect, blocking_pending_count + 1);
610
+ }
611
+ }
612
+ /**
613
+ * @param {boolean} blocking
614
+ * @param {Effect} effect
615
+ * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
616
+ */
617
+ decrement(blocking, effect, skip) {
618
+ let pending_count = this.#pending.get(effect) ?? 0;
619
+ if (pending_count === 1) {
620
+ this.#pending.delete(effect);
621
+ } else {
622
+ this.#pending.set(effect, pending_count - 1);
623
+ }
624
+ if (blocking) {
625
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
626
+ if (blocking_pending_count === 1) {
627
+ this.#blocking_pending.delete(effect);
628
+ } else {
629
+ this.#blocking_pending.set(effect, blocking_pending_count - 1);
630
+ }
631
+ }
632
+ if (this.#decrement_queued || skip) return;
633
+ this.#decrement_queued = true;
634
+ queue_micro_task(() => {
635
+ this.#decrement_queued = false;
636
+ this.flush();
637
+ });
638
+ }
639
+ /**
640
+ * @param {Set<Effect>} dirty_effects
641
+ * @param {Set<Effect>} maybe_dirty_effects
642
+ */
643
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
644
+ for (const e of dirty_effects) {
645
+ this.#dirty_effects.add(e);
646
+ }
647
+ for (const e of maybe_dirty_effects) {
648
+ this.#maybe_dirty_effects.add(e);
649
+ }
650
+ dirty_effects.clear();
651
+ maybe_dirty_effects.clear();
652
+ }
653
+ /** @param {(batch: Batch) => void} fn */
654
+ oncommit(fn) {
655
+ this.#commit_callbacks.add(fn);
656
+ }
657
+ /** @param {(batch: Batch) => void} fn */
658
+ ondiscard(fn) {
659
+ this.#discard_callbacks.add(fn);
660
+ }
661
+ settled() {
662
+ return (this.#deferred ??= deferred()).promise;
663
+ }
664
+ static ensure() {
665
+ if (current_batch === null) {
666
+ const batch = current_batch = new Batch();
667
+ if (!is_processing) {
668
+ batches.add(current_batch);
669
+ if (!is_flushing_sync) {
670
+ queue_micro_task(() => {
671
+ if (current_batch !== batch) {
672
+ return;
673
+ }
674
+ batch.flush();
675
+ });
676
+ }
677
+ }
678
+ }
679
+ return current_batch;
680
+ }
681
+ apply() {
682
+ {
683
+ batch_values = null;
684
+ return;
685
+ }
686
+ }
687
+ /**
688
+ *
689
+ * @param {Effect} effect
690
+ */
691
+ schedule(effect) {
692
+ last_scheduled_effect = effect;
693
+ if (effect.b?.is_pending && (effect.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && (effect.f & REACTION_RAN) === 0) {
694
+ effect.b.defer_effect(effect);
695
+ return;
696
+ }
697
+ var e = effect;
698
+ while (e.parent !== null) {
699
+ e = e.parent;
700
+ var flags2 = e.f;
701
+ if (collected_effects !== null && e === active_effect) {
702
+ if ((active_reaction === null || (active_reaction.f & DERIVED) === 0) && true) {
703
+ return;
704
+ }
705
+ }
706
+ if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
707
+ if ((flags2 & CLEAN) === 0) {
708
+ return;
709
+ }
710
+ e.f ^= CLEAN;
711
+ }
712
+ }
713
+ this.#roots.push(e);
714
+ }
715
+ }
716
+ function flushSync(fn) {
717
+ var was_flushing_sync = is_flushing_sync;
718
+ is_flushing_sync = true;
719
+ try {
720
+ var result;
721
+ if (fn) ;
722
+ while (true) {
723
+ flush_tasks();
724
+ if (current_batch === null) {
725
+ return (
726
+ /** @type {T} */
727
+ result
728
+ );
729
+ }
730
+ current_batch.flush();
731
+ }
732
+ } finally {
733
+ is_flushing_sync = was_flushing_sync;
734
+ }
735
+ }
736
+ function infinite_loop_guard() {
737
+ try {
738
+ effect_update_depth_exceeded();
739
+ } catch (error) {
740
+ invoke_error_boundary(error, last_scheduled_effect);
741
+ }
742
+ }
743
+ let eager_block_effects = null;
744
+ function flush_queued_effects(effects) {
745
+ var length = effects.length;
746
+ if (length === 0) return;
747
+ var i = 0;
748
+ while (i < length) {
749
+ var effect = effects[i++];
750
+ if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
751
+ eager_block_effects = /* @__PURE__ */ new Set();
752
+ update_effect(effect);
753
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) {
754
+ unlink_effect(effect);
755
+ }
756
+ if (eager_block_effects?.size > 0) {
757
+ old_values.clear();
758
+ for (const e of eager_block_effects) {
759
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
760
+ const ordered_effects = [e];
761
+ let ancestor = e.parent;
762
+ while (ancestor !== null) {
763
+ if (eager_block_effects.has(ancestor)) {
764
+ eager_block_effects.delete(ancestor);
765
+ ordered_effects.push(ancestor);
766
+ }
767
+ ancestor = ancestor.parent;
768
+ }
769
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
770
+ const e2 = ordered_effects[j];
771
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
772
+ update_effect(e2);
773
+ }
774
+ }
775
+ eager_block_effects.clear();
776
+ }
777
+ }
778
+ }
779
+ eager_block_effects = null;
780
+ }
781
+ function mark_effects(value, sources, marked, checked) {
782
+ if (marked.has(value)) return;
783
+ marked.add(value);
784
+ if (value.reactions !== null) {
785
+ for (const reaction of value.reactions) {
786
+ const flags2 = reaction.f;
787
+ if ((flags2 & DERIVED) !== 0) {
788
+ mark_effects(
789
+ /** @type {Derived} */
790
+ reaction,
791
+ sources,
792
+ marked,
793
+ checked
794
+ );
795
+ } else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags2 & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
796
+ set_signal_status(reaction, DIRTY);
797
+ schedule_effect(
798
+ /** @type {Effect} */
799
+ reaction
800
+ );
801
+ }
802
+ }
803
+ }
804
+ }
805
+ function depends_on(reaction, sources, checked) {
806
+ const depends = checked.get(reaction);
807
+ if (depends !== void 0) return depends;
808
+ if (reaction.deps !== null) {
809
+ for (const dep of reaction.deps) {
810
+ if (includes.call(sources, dep)) {
811
+ return true;
812
+ }
813
+ if ((dep.f & DERIVED) !== 0 && depends_on(
814
+ /** @type {Derived} */
815
+ dep,
816
+ sources,
817
+ checked
818
+ )) {
819
+ checked.set(
820
+ /** @type {Derived} */
821
+ dep,
822
+ true
823
+ );
824
+ return true;
825
+ }
826
+ }
827
+ }
828
+ checked.set(reaction, false);
829
+ return false;
830
+ }
831
+ function schedule_effect(effect) {
832
+ current_batch.schedule(effect);
833
+ }
834
+ function reset_branch(effect, tracked) {
835
+ if ((effect.f & BRANCH_EFFECT) !== 0 && (effect.f & CLEAN) !== 0) {
836
+ return;
837
+ }
838
+ if ((effect.f & DIRTY) !== 0) {
839
+ tracked.d.push(effect);
840
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
841
+ tracked.m.push(effect);
842
+ }
843
+ set_signal_status(effect, CLEAN);
844
+ var e = effect.first;
845
+ while (e !== null) {
846
+ reset_branch(e, tracked);
847
+ e = e.next;
848
+ }
849
+ }
850
+ function reset_all(effect) {
851
+ set_signal_status(effect, CLEAN);
852
+ var e = effect.first;
853
+ while (e !== null) {
854
+ reset_all(e);
855
+ e = e.next;
856
+ }
857
+ }
858
+ function createSubscriber(start) {
859
+ let subscribers = 0;
860
+ let version = source(0);
861
+ let stop;
862
+ return () => {
863
+ if (effect_tracking()) {
864
+ get(version);
865
+ render_effect(() => {
866
+ if (subscribers === 0) {
867
+ stop = untrack(() => start(() => increment(version)));
868
+ }
869
+ subscribers += 1;
870
+ return () => {
871
+ queue_micro_task(() => {
872
+ subscribers -= 1;
873
+ if (subscribers === 0) {
874
+ stop?.();
875
+ stop = void 0;
876
+ increment(version);
877
+ }
878
+ });
879
+ };
880
+ });
881
+ }
882
+ };
883
+ }
884
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
885
+ function boundary(node, props, children, transform_error) {
886
+ new Boundary(node, props, children, transform_error);
887
+ }
888
+ class Boundary {
889
+ /** @type {Boundary | null} */
890
+ parent;
891
+ is_pending = false;
892
+ /**
893
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
894
+ * Inherited from parent boundary, or defaults to identity.
895
+ * @type {(error: unknown) => unknown}
896
+ */
897
+ transform_error;
898
+ /** @type {TemplateNode} */
899
+ #anchor;
900
+ /** @type {TemplateNode | null} */
901
+ #hydrate_open = hydrating ? hydrate_node : null;
902
+ /** @type {BoundaryProps} */
903
+ #props;
904
+ /** @type {((anchor: Node) => void)} */
905
+ #children;
906
+ /** @type {Effect} */
907
+ #effect;
908
+ /** @type {Effect | null} */
909
+ #main_effect = null;
910
+ /** @type {Effect | null} */
911
+ #pending_effect = null;
912
+ /** @type {Effect | null} */
913
+ #failed_effect = null;
914
+ /** @type {DocumentFragment | null} */
915
+ #offscreen_fragment = null;
916
+ #local_pending_count = 0;
917
+ #pending_count = 0;
918
+ #pending_count_update_queued = false;
919
+ /** @type {Set<Effect>} */
920
+ #dirty_effects = /* @__PURE__ */ new Set();
921
+ /** @type {Set<Effect>} */
922
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
923
+ /**
924
+ * A source containing the number of pending async deriveds/expressions.
925
+ * Only created if `$effect.pending()` is used inside the boundary,
926
+ * otherwise updating the source results in needless `Batch.ensure()`
927
+ * calls followed by no-op flushes
928
+ * @type {Source<number> | null}
929
+ */
930
+ #effect_pending = null;
931
+ #effect_pending_subscriber = createSubscriber(() => {
932
+ this.#effect_pending = source(this.#local_pending_count);
933
+ return () => {
934
+ this.#effect_pending = null;
935
+ };
936
+ });
937
+ /**
938
+ * @param {TemplateNode} node
939
+ * @param {BoundaryProps} props
940
+ * @param {((anchor: Node) => void)} children
941
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
942
+ */
943
+ constructor(node, props, children, transform_error) {
944
+ this.#anchor = node;
945
+ this.#props = props;
946
+ this.#children = (anchor) => {
947
+ var effect = (
948
+ /** @type {Effect} */
949
+ active_effect
950
+ );
951
+ effect.b = this;
952
+ effect.f |= BOUNDARY_EFFECT;
953
+ children(anchor);
954
+ };
955
+ this.parent = /** @type {Effect} */
956
+ active_effect.b;
957
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
958
+ this.#effect = block(() => {
959
+ if (hydrating) {
960
+ const comment = (
961
+ /** @type {Comment} */
962
+ this.#hydrate_open
963
+ );
964
+ hydrate_next();
965
+ const server_rendered_pending = comment.data === HYDRATION_START_ELSE;
966
+ const server_rendered_failed = comment.data.startsWith(HYDRATION_START_FAILED);
967
+ if (server_rendered_failed) {
968
+ const serialized_error = JSON.parse(comment.data.slice(HYDRATION_START_FAILED.length));
969
+ this.#hydrate_failed_content(serialized_error);
970
+ } else if (server_rendered_pending) {
971
+ this.#hydrate_pending_content();
972
+ } else {
973
+ this.#hydrate_resolved_content();
974
+ }
975
+ } else {
976
+ this.#render();
977
+ }
978
+ }, flags);
979
+ if (hydrating) {
980
+ this.#anchor = hydrate_node;
981
+ }
982
+ }
983
+ #hydrate_resolved_content() {
984
+ try {
985
+ this.#main_effect = branch(() => this.#children(this.#anchor));
986
+ } catch (error) {
987
+ this.error(error);
988
+ }
989
+ }
990
+ /**
991
+ * @param {unknown} error The deserialized error from the server's hydration comment
992
+ */
993
+ #hydrate_failed_content(error) {
994
+ const failed = this.#props.failed;
995
+ if (!failed) return;
996
+ this.#failed_effect = branch(() => {
997
+ failed(
998
+ this.#anchor,
999
+ () => error,
1000
+ () => () => {
1001
+ }
1002
+ );
1003
+ });
1004
+ }
1005
+ #hydrate_pending_content() {
1006
+ const pending = this.#props.pending;
1007
+ if (!pending) return;
1008
+ this.is_pending = true;
1009
+ this.#pending_effect = branch(() => pending(this.#anchor));
1010
+ queue_micro_task(() => {
1011
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
1012
+ var anchor = create_text();
1013
+ fragment.append(anchor);
1014
+ this.#main_effect = this.#run(() => {
1015
+ return branch(() => this.#children(anchor));
1016
+ });
1017
+ if (this.#pending_count === 0) {
1018
+ this.#anchor.before(fragment);
1019
+ this.#offscreen_fragment = null;
1020
+ pause_effect(
1021
+ /** @type {Effect} */
1022
+ this.#pending_effect,
1023
+ () => {
1024
+ this.#pending_effect = null;
1025
+ }
1026
+ );
1027
+ this.#resolve(
1028
+ /** @type {Batch} */
1029
+ current_batch
1030
+ );
1031
+ }
1032
+ });
1033
+ }
1034
+ #render() {
1035
+ try {
1036
+ this.is_pending = this.has_pending_snippet();
1037
+ this.#pending_count = 0;
1038
+ this.#local_pending_count = 0;
1039
+ this.#main_effect = branch(() => {
1040
+ this.#children(this.#anchor);
1041
+ });
1042
+ if (this.#pending_count > 0) {
1043
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
1044
+ move_effect(this.#main_effect, fragment);
1045
+ const pending = (
1046
+ /** @type {(anchor: Node) => void} */
1047
+ this.#props.pending
1048
+ );
1049
+ this.#pending_effect = branch(() => pending(this.#anchor));
1050
+ } else {
1051
+ this.#resolve(
1052
+ /** @type {Batch} */
1053
+ current_batch
1054
+ );
1055
+ }
1056
+ } catch (error) {
1057
+ this.error(error);
1058
+ }
1059
+ }
1060
+ /**
1061
+ * @param {Batch} batch
1062
+ */
1063
+ #resolve(batch) {
1064
+ this.is_pending = false;
1065
+ batch.transfer_effects(this.#dirty_effects, this.#maybe_dirty_effects);
1066
+ }
1067
+ /**
1068
+ * Defer an effect inside a pending boundary until the boundary resolves
1069
+ * @param {Effect} effect
1070
+ */
1071
+ defer_effect(effect) {
1072
+ defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
1073
+ }
1074
+ /**
1075
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1076
+ * @returns {boolean}
1077
+ */
1078
+ is_rendered() {
1079
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
1080
+ }
1081
+ has_pending_snippet() {
1082
+ return !!this.#props.pending;
1083
+ }
1084
+ /**
1085
+ * @template T
1086
+ * @param {() => T} fn
1087
+ */
1088
+ #run(fn) {
1089
+ var previous_effect = active_effect;
1090
+ var previous_reaction = active_reaction;
1091
+ var previous_ctx = component_context;
1092
+ set_active_effect(this.#effect);
1093
+ set_active_reaction(this.#effect);
1094
+ set_component_context(this.#effect.ctx);
1095
+ try {
1096
+ Batch.ensure();
1097
+ return fn();
1098
+ } catch (e) {
1099
+ handle_error(e);
1100
+ return null;
1101
+ } finally {
1102
+ set_active_effect(previous_effect);
1103
+ set_active_reaction(previous_reaction);
1104
+ set_component_context(previous_ctx);
1105
+ }
1106
+ }
1107
+ /**
1108
+ * Updates the pending count associated with the currently visible pending snippet,
1109
+ * if any, such that we can replace the snippet with content once work is done
1110
+ * @param {1 | -1} d
1111
+ * @param {Batch} batch
1112
+ */
1113
+ #update_pending_count(d, batch) {
1114
+ if (!this.has_pending_snippet()) {
1115
+ if (this.parent) {
1116
+ this.parent.#update_pending_count(d, batch);
1117
+ }
1118
+ return;
1119
+ }
1120
+ this.#pending_count += d;
1121
+ if (this.#pending_count === 0) {
1122
+ this.#resolve(batch);
1123
+ if (this.#pending_effect) {
1124
+ pause_effect(this.#pending_effect, () => {
1125
+ this.#pending_effect = null;
1126
+ });
1127
+ }
1128
+ if (this.#offscreen_fragment) {
1129
+ this.#anchor.before(this.#offscreen_fragment);
1130
+ this.#offscreen_fragment = null;
1131
+ }
1132
+ }
1133
+ }
1134
+ /**
1135
+ * Update the source that powers `$effect.pending()` inside this boundary,
1136
+ * and controls when the current `pending` snippet (if any) is removed.
1137
+ * Do not call from inside the class
1138
+ * @param {1 | -1} d
1139
+ * @param {Batch} batch
1140
+ */
1141
+ update_pending_count(d, batch) {
1142
+ this.#update_pending_count(d, batch);
1143
+ this.#local_pending_count += d;
1144
+ if (!this.#effect_pending || this.#pending_count_update_queued) return;
1145
+ this.#pending_count_update_queued = true;
1146
+ queue_micro_task(() => {
1147
+ this.#pending_count_update_queued = false;
1148
+ if (this.#effect_pending) {
1149
+ internal_set(this.#effect_pending, this.#local_pending_count);
1150
+ }
1151
+ });
1152
+ }
1153
+ get_effect_pending() {
1154
+ this.#effect_pending_subscriber();
1155
+ return get(
1156
+ /** @type {Source<number>} */
1157
+ this.#effect_pending
1158
+ );
1159
+ }
1160
+ /** @param {unknown} error */
1161
+ error(error) {
1162
+ var onerror = this.#props.onerror;
1163
+ let failed = this.#props.failed;
1164
+ if (!onerror && !failed) {
1165
+ throw error;
1166
+ }
1167
+ if (this.#main_effect) {
1168
+ destroy_effect(this.#main_effect);
1169
+ this.#main_effect = null;
1170
+ }
1171
+ if (this.#pending_effect) {
1172
+ destroy_effect(this.#pending_effect);
1173
+ this.#pending_effect = null;
1174
+ }
1175
+ if (this.#failed_effect) {
1176
+ destroy_effect(this.#failed_effect);
1177
+ this.#failed_effect = null;
1178
+ }
1179
+ if (hydrating) {
1180
+ set_hydrate_node(
1181
+ /** @type {TemplateNode} */
1182
+ this.#hydrate_open
1183
+ );
1184
+ next();
1185
+ set_hydrate_node(skip_nodes());
1186
+ }
1187
+ var did_reset = false;
1188
+ var calling_on_error = false;
1189
+ const reset = () => {
1190
+ if (did_reset) {
1191
+ svelte_boundary_reset_noop();
1192
+ return;
1193
+ }
1194
+ did_reset = true;
1195
+ if (calling_on_error) {
1196
+ svelte_boundary_reset_onerror();
1197
+ }
1198
+ if (this.#failed_effect !== null) {
1199
+ pause_effect(this.#failed_effect, () => {
1200
+ this.#failed_effect = null;
1201
+ });
1202
+ }
1203
+ this.#run(() => {
1204
+ this.#render();
1205
+ });
1206
+ };
1207
+ const handle_error_result = (transformed_error) => {
1208
+ try {
1209
+ calling_on_error = true;
1210
+ onerror?.(transformed_error, reset);
1211
+ calling_on_error = false;
1212
+ } catch (error2) {
1213
+ invoke_error_boundary(error2, this.#effect && this.#effect.parent);
1214
+ }
1215
+ if (failed) {
1216
+ this.#failed_effect = this.#run(() => {
1217
+ try {
1218
+ return branch(() => {
1219
+ var effect = (
1220
+ /** @type {Effect} */
1221
+ active_effect
1222
+ );
1223
+ effect.b = this;
1224
+ effect.f |= BOUNDARY_EFFECT;
1225
+ failed(
1226
+ this.#anchor,
1227
+ () => transformed_error,
1228
+ () => reset
1229
+ );
1230
+ });
1231
+ } catch (error2) {
1232
+ invoke_error_boundary(
1233
+ error2,
1234
+ /** @type {Effect} */
1235
+ this.#effect.parent
1236
+ );
1237
+ return null;
1238
+ }
1239
+ });
1240
+ }
1241
+ };
1242
+ queue_micro_task(() => {
1243
+ var result;
1244
+ try {
1245
+ result = this.transform_error(error);
1246
+ } catch (e) {
1247
+ invoke_error_boundary(e, this.#effect && this.#effect.parent);
1248
+ return;
1249
+ }
1250
+ if (result !== null && typeof result === "object" && typeof /** @type {any} */
1251
+ result.then === "function") {
1252
+ result.then(
1253
+ handle_error_result,
1254
+ /** @param {unknown} e */
1255
+ (e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
1256
+ );
1257
+ } else {
1258
+ handle_error_result(result);
1259
+ }
1260
+ });
1261
+ }
1262
+ }
1263
+ function destroy_derived_effects(derived2) {
1264
+ var effects = derived2.effects;
1265
+ if (effects !== null) {
1266
+ derived2.effects = null;
1267
+ for (var i = 0; i < effects.length; i += 1) {
1268
+ destroy_effect(
1269
+ /** @type {Effect} */
1270
+ effects[i]
1271
+ );
1272
+ }
1273
+ }
1274
+ }
1275
+ function get_derived_parent_effect(derived2) {
1276
+ var parent = derived2.parent;
1277
+ while (parent !== null) {
1278
+ if ((parent.f & DERIVED) === 0) {
1279
+ return (parent.f & DESTROYED) === 0 ? (
1280
+ /** @type {Effect} */
1281
+ parent
1282
+ ) : null;
1283
+ }
1284
+ parent = parent.parent;
1285
+ }
1286
+ return null;
1287
+ }
1288
+ function execute_derived(derived2) {
1289
+ var value;
1290
+ var prev_active_effect = active_effect;
1291
+ set_active_effect(get_derived_parent_effect(derived2));
1292
+ {
1293
+ try {
1294
+ derived2.f &= ~WAS_MARKED;
1295
+ destroy_derived_effects(derived2);
1296
+ value = update_reaction(derived2);
1297
+ } finally {
1298
+ set_active_effect(prev_active_effect);
1299
+ }
1300
+ }
1301
+ return value;
1302
+ }
1303
+ function update_derived(derived2) {
1304
+ var old_value = derived2.v;
1305
+ var value = execute_derived(derived2);
1306
+ if (!derived2.equals(value)) {
1307
+ derived2.wv = increment_write_version();
1308
+ if (!current_batch?.is_fork || derived2.deps === null) {
1309
+ derived2.v = value;
1310
+ current_batch?.capture(derived2, old_value, true);
1311
+ if (derived2.deps === null) {
1312
+ set_signal_status(derived2, CLEAN);
1313
+ return;
1314
+ }
1315
+ }
1316
+ }
1317
+ if (is_destroying_effect) {
1318
+ return;
1319
+ }
1320
+ if (batch_values !== null) {
1321
+ if (effect_tracking() || current_batch?.is_fork) {
1322
+ batch_values.set(derived2, value);
1323
+ }
1324
+ } else {
1325
+ update_derived_status(derived2);
1326
+ }
1327
+ }
1328
+ function freeze_derived_effects(derived2) {
1329
+ if (derived2.effects === null) return;
1330
+ for (const e of derived2.effects) {
1331
+ if (e.teardown || e.ac) {
1332
+ e.teardown?.();
1333
+ e.ac?.abort(STALE_REACTION);
1334
+ e.teardown = noop;
1335
+ e.ac = null;
1336
+ remove_reactions(e, 0);
1337
+ destroy_effect_children(e);
1338
+ }
1339
+ }
1340
+ }
1341
+ function unfreeze_derived_effects(derived2) {
1342
+ if (derived2.effects === null) return;
1343
+ for (const e of derived2.effects) {
1344
+ if (e.teardown) {
1345
+ update_effect(e);
1346
+ }
1347
+ }
1348
+ }
1349
+ let eager_effects = /* @__PURE__ */ new Set();
1350
+ const old_values = /* @__PURE__ */ new Map();
1351
+ let eager_effects_deferred = false;
1352
+ function source(v, stack) {
1353
+ var signal = {
1354
+ f: 0,
1355
+ // TODO ideally we could skip this altogether, but it causes type errors
1356
+ v,
1357
+ reactions: null,
1358
+ equals,
1359
+ rv: 0,
1360
+ wv: 0
1361
+ };
1362
+ return signal;
1363
+ }
1364
+ // @__NO_SIDE_EFFECTS__
1365
+ function state(v, stack) {
1366
+ const s = source(v);
1367
+ push_reaction_value(s);
1368
+ return s;
1369
+ }
1370
+ // @__NO_SIDE_EFFECTS__
1371
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1372
+ const s = source(initial_value);
1373
+ if (!immutable) {
1374
+ s.equals = safe_equals;
1375
+ }
1376
+ return s;
1377
+ }
1378
+ function set(source2, value, should_proxy = false) {
1379
+ if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1380
+ // to ensure we error if state is set inside an inspect effect
1381
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) {
1382
+ state_unsafe_mutation();
1383
+ }
1384
+ let new_value = should_proxy ? proxy(value) : value;
1385
+ return internal_set(source2, new_value, legacy_updates);
1386
+ }
1387
+ function internal_set(source2, value, updated_during_traversal = null) {
1388
+ if (!source2.equals(value)) {
1389
+ var old_value = source2.v;
1390
+ if (is_destroying_effect) {
1391
+ old_values.set(source2, value);
1392
+ } else {
1393
+ old_values.set(source2, old_value);
1394
+ }
1395
+ source2.v = value;
1396
+ var batch = Batch.ensure();
1397
+ batch.capture(source2, old_value);
1398
+ if ((source2.f & DERIVED) !== 0) {
1399
+ const derived2 = (
1400
+ /** @type {Derived} */
1401
+ source2
1402
+ );
1403
+ if ((source2.f & DIRTY) !== 0) {
1404
+ execute_derived(derived2);
1405
+ }
1406
+ if (batch_values === null) {
1407
+ update_derived_status(derived2);
1408
+ }
1409
+ }
1410
+ source2.wv = increment_write_version();
1411
+ mark_reactions(source2, DIRTY, updated_during_traversal);
1412
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
1413
+ if (untracked_writes === null) {
1414
+ set_untracked_writes([source2]);
1415
+ } else {
1416
+ untracked_writes.push(source2);
1417
+ }
1418
+ }
1419
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
1420
+ flush_eager_effects();
1421
+ }
1422
+ }
1423
+ return value;
1424
+ }
1425
+ function flush_eager_effects() {
1426
+ eager_effects_deferred = false;
1427
+ for (const effect of eager_effects) {
1428
+ if ((effect.f & CLEAN) !== 0) {
1429
+ set_signal_status(effect, MAYBE_DIRTY);
1430
+ }
1431
+ if (is_dirty(effect)) {
1432
+ update_effect(effect);
1433
+ }
1434
+ }
1435
+ eager_effects.clear();
1436
+ }
1437
+ function increment(source2) {
1438
+ set(source2, source2.v + 1);
1439
+ }
1440
+ function mark_reactions(signal, status, updated_during_traversal) {
1441
+ var reactions = signal.reactions;
1442
+ if (reactions === null) return;
1443
+ var length = reactions.length;
1444
+ for (var i = 0; i < length; i++) {
1445
+ var reaction = reactions[i];
1446
+ var flags2 = reaction.f;
1447
+ var not_dirty = (flags2 & DIRTY) === 0;
1448
+ if (not_dirty) {
1449
+ set_signal_status(reaction, status);
1450
+ }
1451
+ if ((flags2 & DERIVED) !== 0) {
1452
+ var derived2 = (
1453
+ /** @type {Derived} */
1454
+ reaction
1455
+ );
1456
+ batch_values?.delete(derived2);
1457
+ if ((flags2 & WAS_MARKED) === 0) {
1458
+ if (flags2 & CONNECTED) {
1459
+ reaction.f |= WAS_MARKED;
1460
+ }
1461
+ mark_reactions(derived2, MAYBE_DIRTY, updated_during_traversal);
1462
+ }
1463
+ } else if (not_dirty) {
1464
+ var effect = (
1465
+ /** @type {Effect} */
1466
+ reaction
1467
+ );
1468
+ if ((flags2 & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
1469
+ eager_block_effects.add(effect);
1470
+ }
1471
+ if (updated_during_traversal !== null) {
1472
+ updated_during_traversal.push(effect);
1473
+ } else {
1474
+ schedule_effect(effect);
1475
+ }
1476
+ }
1477
+ }
1478
+ }
1479
+ function proxy(value) {
1480
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
1481
+ return value;
1482
+ }
1483
+ const prototype = get_prototype_of(value);
1484
+ if (prototype !== object_prototype && prototype !== array_prototype) {
1485
+ return value;
1486
+ }
1487
+ var sources = /* @__PURE__ */ new Map();
1488
+ var is_proxied_array = is_array(value);
1489
+ var version = /* @__PURE__ */ state(0);
1490
+ var parent_version = update_version;
1491
+ var with_parent = (fn) => {
1492
+ if (update_version === parent_version) {
1493
+ return fn();
1494
+ }
1495
+ var reaction = active_reaction;
1496
+ var version2 = update_version;
1497
+ set_active_reaction(null);
1498
+ set_update_version(parent_version);
1499
+ var result = fn();
1500
+ set_active_reaction(reaction);
1501
+ set_update_version(version2);
1502
+ return result;
1503
+ };
1504
+ if (is_proxied_array) {
1505
+ sources.set("length", /* @__PURE__ */ state(
1506
+ /** @type {any[]} */
1507
+ value.length
1508
+ ));
1509
+ }
1510
+ return new Proxy(
1511
+ /** @type {any} */
1512
+ value,
1513
+ {
1514
+ defineProperty(_, prop, descriptor) {
1515
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
1516
+ state_descriptors_fixed();
1517
+ }
1518
+ var s = sources.get(prop);
1519
+ if (s === void 0) {
1520
+ with_parent(() => {
1521
+ var s2 = /* @__PURE__ */ state(descriptor.value);
1522
+ sources.set(prop, s2);
1523
+ return s2;
1524
+ });
1525
+ } else {
1526
+ set(s, descriptor.value, true);
1527
+ }
1528
+ return true;
1529
+ },
1530
+ deleteProperty(target, prop) {
1531
+ var s = sources.get(prop);
1532
+ if (s === void 0) {
1533
+ if (prop in target) {
1534
+ const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1535
+ sources.set(prop, s2);
1536
+ increment(version);
1537
+ }
1538
+ } else {
1539
+ set(s, UNINITIALIZED);
1540
+ increment(version);
1541
+ }
1542
+ return true;
1543
+ },
1544
+ get(target, prop, receiver) {
1545
+ if (prop === STATE_SYMBOL) {
1546
+ return value;
1547
+ }
1548
+ var s = sources.get(prop);
1549
+ var exists = prop in target;
1550
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1551
+ s = with_parent(() => {
1552
+ var p = proxy(exists ? target[prop] : UNINITIALIZED);
1553
+ var s2 = /* @__PURE__ */ state(p);
1554
+ return s2;
1555
+ });
1556
+ sources.set(prop, s);
1557
+ }
1558
+ if (s !== void 0) {
1559
+ var v = get(s);
1560
+ return v === UNINITIALIZED ? void 0 : v;
1561
+ }
1562
+ return Reflect.get(target, prop, receiver);
1563
+ },
1564
+ getOwnPropertyDescriptor(target, prop) {
1565
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1566
+ if (descriptor && "value" in descriptor) {
1567
+ var s = sources.get(prop);
1568
+ if (s) descriptor.value = get(s);
1569
+ } else if (descriptor === void 0) {
1570
+ var source2 = sources.get(prop);
1571
+ var value2 = source2?.v;
1572
+ if (source2 !== void 0 && value2 !== UNINITIALIZED) {
1573
+ return {
1574
+ enumerable: true,
1575
+ configurable: true,
1576
+ value: value2,
1577
+ writable: true
1578
+ };
1579
+ }
1580
+ }
1581
+ return descriptor;
1582
+ },
1583
+ has(target, prop) {
1584
+ if (prop === STATE_SYMBOL) {
1585
+ return true;
1586
+ }
1587
+ var s = sources.get(prop);
1588
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1589
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1590
+ if (s === void 0) {
1591
+ s = with_parent(() => {
1592
+ var p = has ? proxy(target[prop]) : UNINITIALIZED;
1593
+ var s2 = /* @__PURE__ */ state(p);
1594
+ return s2;
1595
+ });
1596
+ sources.set(prop, s);
1597
+ }
1598
+ var value2 = get(s);
1599
+ if (value2 === UNINITIALIZED) {
1600
+ return false;
1601
+ }
1602
+ }
1603
+ return has;
1604
+ },
1605
+ set(target, prop, value2, receiver) {
1606
+ var s = sources.get(prop);
1607
+ var has = prop in target;
1608
+ if (is_proxied_array && prop === "length") {
1609
+ for (var i = value2; i < /** @type {Source<number>} */
1610
+ s.v; i += 1) {
1611
+ var other_s = sources.get(i + "");
1612
+ if (other_s !== void 0) {
1613
+ set(other_s, UNINITIALIZED);
1614
+ } else if (i in target) {
1615
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1616
+ sources.set(i + "", other_s);
1617
+ }
1618
+ }
1619
+ }
1620
+ if (s === void 0) {
1621
+ if (!has || get_descriptor(target, prop)?.writable) {
1622
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
1623
+ set(s, proxy(value2));
1624
+ sources.set(prop, s);
1625
+ }
1626
+ } else {
1627
+ has = s.v !== UNINITIALIZED;
1628
+ var p = with_parent(() => proxy(value2));
1629
+ set(s, p);
1630
+ }
1631
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1632
+ if (descriptor?.set) {
1633
+ descriptor.set.call(receiver, value2);
1634
+ }
1635
+ if (!has) {
1636
+ if (is_proxied_array && typeof prop === "string") {
1637
+ var ls = (
1638
+ /** @type {Source<number>} */
1639
+ sources.get("length")
1640
+ );
1641
+ var n = Number(prop);
1642
+ if (Number.isInteger(n) && n >= ls.v) {
1643
+ set(ls, n + 1);
1644
+ }
1645
+ }
1646
+ increment(version);
1647
+ }
1648
+ return true;
1649
+ },
1650
+ ownKeys(target) {
1651
+ get(version);
1652
+ var own_keys = Reflect.ownKeys(target).filter((key2) => {
1653
+ var source3 = sources.get(key2);
1654
+ return source3 === void 0 || source3.v !== UNINITIALIZED;
1655
+ });
1656
+ for (var [key, source2] of sources) {
1657
+ if (source2.v !== UNINITIALIZED && !(key in target)) {
1658
+ own_keys.push(key);
1659
+ }
1660
+ }
1661
+ return own_keys;
1662
+ },
1663
+ setPrototypeOf() {
1664
+ state_prototype_fixed();
1665
+ }
1666
+ }
1667
+ );
1668
+ }
1669
+ var $window;
1670
+ var first_child_getter;
1671
+ var next_sibling_getter;
1672
+ function init_operations() {
1673
+ if ($window !== void 0) {
1674
+ return;
1675
+ }
1676
+ $window = window;
1677
+ var element_prototype = Element.prototype;
1678
+ var node_prototype = Node.prototype;
1679
+ var text_prototype = Text.prototype;
1680
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
1681
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
1682
+ if (is_extensible(element_prototype)) {
1683
+ element_prototype.__click = void 0;
1684
+ element_prototype.__className = void 0;
1685
+ element_prototype.__attributes = null;
1686
+ element_prototype.__style = void 0;
1687
+ element_prototype.__e = void 0;
1688
+ }
1689
+ if (is_extensible(text_prototype)) {
1690
+ text_prototype.__t = void 0;
1691
+ }
1692
+ }
1693
+ function create_text(value = "") {
1694
+ return document.createTextNode(value);
1695
+ }
1696
+ // @__NO_SIDE_EFFECTS__
1697
+ function get_first_child(node) {
1698
+ return (
1699
+ /** @type {TemplateNode | null} */
1700
+ first_child_getter.call(node)
1701
+ );
1702
+ }
1703
+ // @__NO_SIDE_EFFECTS__
1704
+ function get_next_sibling(node) {
1705
+ return (
1706
+ /** @type {TemplateNode | null} */
1707
+ next_sibling_getter.call(node)
1708
+ );
1709
+ }
1710
+ function clear_text_content(node) {
1711
+ node.textContent = "";
1712
+ }
1713
+ function without_reactive_context(fn) {
1714
+ var previous_reaction = active_reaction;
1715
+ var previous_effect = active_effect;
1716
+ set_active_reaction(null);
1717
+ set_active_effect(null);
1718
+ try {
1719
+ return fn();
1720
+ } finally {
1721
+ set_active_reaction(previous_reaction);
1722
+ set_active_effect(previous_effect);
1723
+ }
1724
+ }
1725
+ function push_effect(effect, parent_effect) {
1726
+ var parent_last = parent_effect.last;
1727
+ if (parent_last === null) {
1728
+ parent_effect.last = parent_effect.first = effect;
1729
+ } else {
1730
+ parent_last.next = effect;
1731
+ effect.prev = parent_last;
1732
+ parent_effect.last = effect;
1733
+ }
1734
+ }
1735
+ function create_effect(type, fn) {
1736
+ var parent = active_effect;
1737
+ if (parent !== null && (parent.f & INERT) !== 0) {
1738
+ type |= INERT;
1739
+ }
1740
+ var effect = {
1741
+ ctx: component_context,
1742
+ deps: null,
1743
+ nodes: null,
1744
+ f: type | DIRTY | CONNECTED,
1745
+ first: null,
1746
+ fn,
1747
+ last: null,
1748
+ next: null,
1749
+ parent,
1750
+ b: parent && parent.b,
1751
+ prev: null,
1752
+ teardown: null,
1753
+ wv: 0,
1754
+ ac: null
1755
+ };
1756
+ current_batch?.register_created_effect(effect);
1757
+ var e = effect;
1758
+ if ((type & EFFECT) !== 0) {
1759
+ if (collected_effects !== null) {
1760
+ collected_effects.push(effect);
1761
+ } else {
1762
+ Batch.ensure().schedule(effect);
1763
+ }
1764
+ } else if (fn !== null) {
1765
+ try {
1766
+ update_effect(effect);
1767
+ } catch (e2) {
1768
+ destroy_effect(effect);
1769
+ throw e2;
1770
+ }
1771
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
1772
+ (e.f & EFFECT_PRESERVED) === 0) {
1773
+ e = e.first;
1774
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
1775
+ e.f |= EFFECT_TRANSPARENT;
1776
+ }
1777
+ }
1778
+ }
1779
+ if (e !== null) {
1780
+ e.parent = parent;
1781
+ if (parent !== null) {
1782
+ push_effect(e, parent);
1783
+ }
1784
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
1785
+ var derived2 = (
1786
+ /** @type {Derived} */
1787
+ active_reaction
1788
+ );
1789
+ (derived2.effects ??= []).push(e);
1790
+ }
1791
+ }
1792
+ return effect;
1793
+ }
1794
+ function effect_tracking() {
1795
+ return active_reaction !== null && !untracking;
1796
+ }
1797
+ function create_user_effect(fn) {
1798
+ return create_effect(EFFECT | USER_EFFECT, fn);
1799
+ }
1800
+ function component_root(fn) {
1801
+ Batch.ensure();
1802
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn);
1803
+ return (options = {}) => {
1804
+ return new Promise((fulfil) => {
1805
+ if (options.outro) {
1806
+ pause_effect(effect, () => {
1807
+ destroy_effect(effect);
1808
+ fulfil(void 0);
1809
+ });
1810
+ } else {
1811
+ destroy_effect(effect);
1812
+ fulfil(void 0);
1813
+ }
1814
+ });
1815
+ };
1816
+ }
1817
+ function render_effect(fn, flags2 = 0) {
1818
+ return create_effect(RENDER_EFFECT | flags2, fn);
1819
+ }
1820
+ function block(fn, flags2 = 0) {
1821
+ var effect = create_effect(BLOCK_EFFECT | flags2, fn);
1822
+ return effect;
1823
+ }
1824
+ function branch(fn) {
1825
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn);
1826
+ }
1827
+ function execute_effect_teardown(effect) {
1828
+ var teardown = effect.teardown;
1829
+ if (teardown !== null) {
1830
+ const previously_destroying_effect = is_destroying_effect;
1831
+ const previous_reaction = active_reaction;
1832
+ set_is_destroying_effect(true);
1833
+ set_active_reaction(null);
1834
+ try {
1835
+ teardown.call(null);
1836
+ } finally {
1837
+ set_is_destroying_effect(previously_destroying_effect);
1838
+ set_active_reaction(previous_reaction);
1839
+ }
1840
+ }
1841
+ }
1842
+ function destroy_effect_children(signal, remove_dom = false) {
1843
+ var effect = signal.first;
1844
+ signal.first = signal.last = null;
1845
+ while (effect !== null) {
1846
+ const controller = effect.ac;
1847
+ if (controller !== null) {
1848
+ without_reactive_context(() => {
1849
+ controller.abort(STALE_REACTION);
1850
+ });
1851
+ }
1852
+ var next2 = effect.next;
1853
+ if ((effect.f & ROOT_EFFECT) !== 0) {
1854
+ effect.parent = null;
1855
+ } else {
1856
+ destroy_effect(effect, remove_dom);
1857
+ }
1858
+ effect = next2;
1859
+ }
1860
+ }
1861
+ function destroy_block_effect_children(signal) {
1862
+ var effect = signal.first;
1863
+ while (effect !== null) {
1864
+ var next2 = effect.next;
1865
+ if ((effect.f & BRANCH_EFFECT) === 0) {
1866
+ destroy_effect(effect);
1867
+ }
1868
+ effect = next2;
1869
+ }
1870
+ }
1871
+ function destroy_effect(effect, remove_dom = true) {
1872
+ var removed = false;
1873
+ if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
1874
+ remove_effect_dom(
1875
+ effect.nodes.start,
1876
+ /** @type {TemplateNode} */
1877
+ effect.nodes.end
1878
+ );
1879
+ removed = true;
1880
+ }
1881
+ set_signal_status(effect, DESTROYING);
1882
+ destroy_effect_children(effect, remove_dom && !removed);
1883
+ remove_reactions(effect, 0);
1884
+ var transitions = effect.nodes && effect.nodes.t;
1885
+ if (transitions !== null) {
1886
+ for (const transition of transitions) {
1887
+ transition.stop();
1888
+ }
1889
+ }
1890
+ execute_effect_teardown(effect);
1891
+ effect.f ^= DESTROYING;
1892
+ effect.f |= DESTROYED;
1893
+ var parent = effect.parent;
1894
+ if (parent !== null && parent.first !== null) {
1895
+ unlink_effect(effect);
1896
+ }
1897
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
1898
+ }
1899
+ function remove_effect_dom(node, end) {
1900
+ while (node !== null) {
1901
+ var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1902
+ node.remove();
1903
+ node = next2;
1904
+ }
1905
+ }
1906
+ function unlink_effect(effect) {
1907
+ var parent = effect.parent;
1908
+ var prev = effect.prev;
1909
+ var next2 = effect.next;
1910
+ if (prev !== null) prev.next = next2;
1911
+ if (next2 !== null) next2.prev = prev;
1912
+ if (parent !== null) {
1913
+ if (parent.first === effect) parent.first = next2;
1914
+ if (parent.last === effect) parent.last = prev;
1915
+ }
1916
+ }
1917
+ function pause_effect(effect, callback, destroy = true) {
1918
+ var transitions = [];
1919
+ pause_children(effect, transitions, true);
1920
+ var fn = () => {
1921
+ if (destroy) destroy_effect(effect);
1922
+ if (callback) callback();
1923
+ };
1924
+ var remaining = transitions.length;
1925
+ if (remaining > 0) {
1926
+ var check = () => --remaining || fn();
1927
+ for (var transition of transitions) {
1928
+ transition.out(check);
1929
+ }
1930
+ } else {
1931
+ fn();
1932
+ }
1933
+ }
1934
+ function pause_children(effect, transitions, local) {
1935
+ if ((effect.f & INERT) !== 0) return;
1936
+ effect.f ^= INERT;
1937
+ var t = effect.nodes && effect.nodes.t;
1938
+ if (t !== null) {
1939
+ for (const transition of t) {
1940
+ if (transition.is_global || local) {
1941
+ transitions.push(transition);
1942
+ }
1943
+ }
1944
+ }
1945
+ var child = effect.first;
1946
+ while (child !== null) {
1947
+ var sibling = child.next;
1948
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
1949
+ // it means the parent block effect was pruned. In that case,
1950
+ // transparency information was transferred to the branch effect.
1951
+ (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
1952
+ pause_children(child, transitions, transparent ? local : false);
1953
+ child = sibling;
1954
+ }
1955
+ }
1956
+ function move_effect(effect, fragment) {
1957
+ if (!effect.nodes) return;
1958
+ var node = effect.nodes.start;
1959
+ var end = effect.nodes.end;
1960
+ while (node !== null) {
1961
+ var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1962
+ fragment.append(node);
1963
+ node = next2;
1964
+ }
1965
+ }
1966
+ let is_updating_effect = false;
1967
+ let is_destroying_effect = false;
1968
+ function set_is_destroying_effect(value) {
1969
+ is_destroying_effect = value;
1970
+ }
1971
+ let active_reaction = null;
1972
+ let untracking = false;
1973
+ function set_active_reaction(reaction) {
1974
+ active_reaction = reaction;
1975
+ }
1976
+ let active_effect = null;
1977
+ function set_active_effect(effect) {
1978
+ active_effect = effect;
1979
+ }
1980
+ let current_sources = null;
1981
+ function push_reaction_value(value) {
1982
+ if (active_reaction !== null && true) {
1983
+ if (current_sources === null) {
1984
+ current_sources = [value];
1985
+ } else {
1986
+ current_sources.push(value);
1987
+ }
1988
+ }
1989
+ }
1990
+ let new_deps = null;
1991
+ let skipped_deps = 0;
1992
+ let untracked_writes = null;
1993
+ function set_untracked_writes(value) {
1994
+ untracked_writes = value;
1995
+ }
1996
+ let write_version = 1;
1997
+ let read_version = 0;
1998
+ let update_version = read_version;
1999
+ function set_update_version(value) {
2000
+ update_version = value;
2001
+ }
2002
+ function increment_write_version() {
2003
+ return ++write_version;
2004
+ }
2005
+ function is_dirty(reaction) {
2006
+ var flags2 = reaction.f;
2007
+ if ((flags2 & DIRTY) !== 0) {
2008
+ return true;
2009
+ }
2010
+ if (flags2 & DERIVED) {
2011
+ reaction.f &= ~WAS_MARKED;
2012
+ }
2013
+ if ((flags2 & MAYBE_DIRTY) !== 0) {
2014
+ var dependencies = (
2015
+ /** @type {Value[]} */
2016
+ reaction.deps
2017
+ );
2018
+ var length = dependencies.length;
2019
+ for (var i = 0; i < length; i++) {
2020
+ var dependency = dependencies[i];
2021
+ if (is_dirty(
2022
+ /** @type {Derived} */
2023
+ dependency
2024
+ )) {
2025
+ update_derived(
2026
+ /** @type {Derived} */
2027
+ dependency
2028
+ );
2029
+ }
2030
+ if (dependency.wv > reaction.wv) {
2031
+ return true;
2032
+ }
2033
+ }
2034
+ if ((flags2 & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that
2035
+ // traversal of the graph in the other batches still happens
2036
+ batch_values === null) {
2037
+ set_signal_status(reaction, CLEAN);
2038
+ }
2039
+ }
2040
+ return false;
2041
+ }
2042
+ function schedule_possible_effect_self_invalidation(signal, effect, root2 = true) {
2043
+ var reactions = signal.reactions;
2044
+ if (reactions === null) return;
2045
+ if (current_sources !== null && includes.call(current_sources, signal)) {
2046
+ return;
2047
+ }
2048
+ for (var i = 0; i < reactions.length; i++) {
2049
+ var reaction = reactions[i];
2050
+ if ((reaction.f & DERIVED) !== 0) {
2051
+ schedule_possible_effect_self_invalidation(
2052
+ /** @type {Derived} */
2053
+ reaction,
2054
+ effect,
2055
+ false
2056
+ );
2057
+ } else if (effect === reaction) {
2058
+ if (root2) {
2059
+ set_signal_status(reaction, DIRTY);
2060
+ } else if ((reaction.f & CLEAN) !== 0) {
2061
+ set_signal_status(reaction, MAYBE_DIRTY);
2062
+ }
2063
+ schedule_effect(
2064
+ /** @type {Effect} */
2065
+ reaction
2066
+ );
2067
+ }
2068
+ }
2069
+ }
2070
+ function update_reaction(reaction) {
2071
+ var previous_deps = new_deps;
2072
+ var previous_skipped_deps = skipped_deps;
2073
+ var previous_untracked_writes = untracked_writes;
2074
+ var previous_reaction = active_reaction;
2075
+ var previous_sources = current_sources;
2076
+ var previous_component_context = component_context;
2077
+ var previous_untracking = untracking;
2078
+ var previous_update_version = update_version;
2079
+ var flags2 = reaction.f;
2080
+ new_deps = /** @type {null | Value[]} */
2081
+ null;
2082
+ skipped_deps = 0;
2083
+ untracked_writes = null;
2084
+ active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2085
+ current_sources = null;
2086
+ set_component_context(reaction.ctx);
2087
+ untracking = false;
2088
+ update_version = ++read_version;
2089
+ if (reaction.ac !== null) {
2090
+ without_reactive_context(() => {
2091
+ reaction.ac.abort(STALE_REACTION);
2092
+ });
2093
+ reaction.ac = null;
2094
+ }
2095
+ try {
2096
+ reaction.f |= REACTION_IS_UPDATING;
2097
+ var fn = (
2098
+ /** @type {Function} */
2099
+ reaction.fn
2100
+ );
2101
+ var result = fn();
2102
+ reaction.f |= REACTION_RAN;
2103
+ var deps = reaction.deps;
2104
+ var is_fork = current_batch?.is_fork;
2105
+ if (new_deps !== null) {
2106
+ var i;
2107
+ if (!is_fork) {
2108
+ remove_reactions(reaction, skipped_deps);
2109
+ }
2110
+ if (deps !== null && skipped_deps > 0) {
2111
+ deps.length = skipped_deps + new_deps.length;
2112
+ for (i = 0; i < new_deps.length; i++) {
2113
+ deps[skipped_deps + i] = new_deps[i];
2114
+ }
2115
+ } else {
2116
+ reaction.deps = deps = new_deps;
2117
+ }
2118
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
2119
+ for (i = skipped_deps; i < deps.length; i++) {
2120
+ (deps[i].reactions ??= []).push(reaction);
2121
+ }
2122
+ }
2123
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2124
+ remove_reactions(reaction, skipped_deps);
2125
+ deps.length = skipped_deps;
2126
+ }
2127
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
2128
+ for (i = 0; i < /** @type {Source[]} */
2129
+ untracked_writes.length; i++) {
2130
+ schedule_possible_effect_self_invalidation(
2131
+ untracked_writes[i],
2132
+ /** @type {Effect} */
2133
+ reaction
2134
+ );
2135
+ }
2136
+ }
2137
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2138
+ read_version++;
2139
+ if (previous_reaction.deps !== null) {
2140
+ for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) {
2141
+ previous_reaction.deps[i2].rv = read_version;
2142
+ }
2143
+ }
2144
+ if (previous_deps !== null) {
2145
+ for (const dep of previous_deps) {
2146
+ dep.rv = read_version;
2147
+ }
2148
+ }
2149
+ if (untracked_writes !== null) {
2150
+ if (previous_untracked_writes === null) {
2151
+ previous_untracked_writes = untracked_writes;
2152
+ } else {
2153
+ previous_untracked_writes.push(.../** @type {Source[]} */
2154
+ untracked_writes);
2155
+ }
2156
+ }
2157
+ }
2158
+ if ((reaction.f & ERROR_VALUE) !== 0) {
2159
+ reaction.f ^= ERROR_VALUE;
2160
+ }
2161
+ return result;
2162
+ } catch (error) {
2163
+ return handle_error(error);
2164
+ } finally {
2165
+ reaction.f ^= REACTION_IS_UPDATING;
2166
+ new_deps = previous_deps;
2167
+ skipped_deps = previous_skipped_deps;
2168
+ untracked_writes = previous_untracked_writes;
2169
+ active_reaction = previous_reaction;
2170
+ current_sources = previous_sources;
2171
+ set_component_context(previous_component_context);
2172
+ untracking = previous_untracking;
2173
+ update_version = previous_update_version;
2174
+ }
2175
+ }
2176
+ function remove_reaction(signal, dependency) {
2177
+ let reactions = dependency.reactions;
2178
+ if (reactions !== null) {
2179
+ var index = index_of.call(reactions, signal);
2180
+ if (index !== -1) {
2181
+ var new_length = reactions.length - 1;
2182
+ if (new_length === 0) {
2183
+ reactions = dependency.reactions = null;
2184
+ } else {
2185
+ reactions[index] = reactions[new_length];
2186
+ reactions.pop();
2187
+ }
2188
+ }
2189
+ }
2190
+ if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
2191
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
2192
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
2193
+ (new_deps === null || !includes.call(new_deps, dependency))) {
2194
+ var derived2 = (
2195
+ /** @type {Derived} */
2196
+ dependency
2197
+ );
2198
+ if ((derived2.f & CONNECTED) !== 0) {
2199
+ derived2.f ^= CONNECTED;
2200
+ derived2.f &= ~WAS_MARKED;
2201
+ }
2202
+ update_derived_status(derived2);
2203
+ freeze_derived_effects(derived2);
2204
+ remove_reactions(derived2, 0);
2205
+ }
2206
+ }
2207
+ function remove_reactions(signal, start_index) {
2208
+ var dependencies = signal.deps;
2209
+ if (dependencies === null) return;
2210
+ for (var i = start_index; i < dependencies.length; i++) {
2211
+ remove_reaction(signal, dependencies[i]);
2212
+ }
2213
+ }
2214
+ function update_effect(effect) {
2215
+ var flags2 = effect.f;
2216
+ if ((flags2 & DESTROYED) !== 0) {
2217
+ return;
2218
+ }
2219
+ set_signal_status(effect, CLEAN);
2220
+ var previous_effect = active_effect;
2221
+ var was_updating_effect = is_updating_effect;
2222
+ active_effect = effect;
2223
+ is_updating_effect = true;
2224
+ try {
2225
+ if ((flags2 & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
2226
+ destroy_block_effect_children(effect);
2227
+ } else {
2228
+ destroy_effect_children(effect);
2229
+ }
2230
+ execute_effect_teardown(effect);
2231
+ var teardown = update_reaction(effect);
2232
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2233
+ effect.wv = write_version;
2234
+ var dep;
2235
+ if (BROWSER && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ;
2236
+ } finally {
2237
+ is_updating_effect = was_updating_effect;
2238
+ active_effect = previous_effect;
2239
+ }
2240
+ }
2241
+ function get(signal) {
2242
+ var flags2 = signal.f;
2243
+ var is_derived = (flags2 & DERIVED) !== 0;
2244
+ if (active_reaction !== null && !untracking) {
2245
+ var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2246
+ if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
2247
+ var deps = active_reaction.deps;
2248
+ if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
2249
+ if (signal.rv < read_version) {
2250
+ signal.rv = read_version;
2251
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
2252
+ skipped_deps++;
2253
+ } else if (new_deps === null) {
2254
+ new_deps = [signal];
2255
+ } else {
2256
+ new_deps.push(signal);
2257
+ }
2258
+ }
2259
+ } else {
2260
+ (active_reaction.deps ??= []).push(signal);
2261
+ var reactions = signal.reactions;
2262
+ if (reactions === null) {
2263
+ signal.reactions = [active_reaction];
2264
+ } else if (!includes.call(reactions, active_reaction)) {
2265
+ reactions.push(active_reaction);
2266
+ }
2267
+ }
2268
+ }
2269
+ }
2270
+ if (is_destroying_effect && old_values.has(signal)) {
2271
+ return old_values.get(signal);
2272
+ }
2273
+ if (is_derived) {
2274
+ var derived2 = (
2275
+ /** @type {Derived} */
2276
+ signal
2277
+ );
2278
+ if (is_destroying_effect) {
2279
+ var value = derived2.v;
2280
+ if ((derived2.f & CLEAN) === 0 && derived2.reactions !== null || depends_on_old_values(derived2)) {
2281
+ value = execute_derived(derived2);
2282
+ }
2283
+ old_values.set(derived2, value);
2284
+ return value;
2285
+ }
2286
+ var should_connect = (derived2.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
2287
+ var is_new = (derived2.f & REACTION_RAN) === 0;
2288
+ if (is_dirty(derived2)) {
2289
+ if (should_connect) {
2290
+ derived2.f |= CONNECTED;
2291
+ }
2292
+ update_derived(derived2);
2293
+ }
2294
+ if (should_connect && !is_new) {
2295
+ unfreeze_derived_effects(derived2);
2296
+ reconnect(derived2);
2297
+ }
2298
+ }
2299
+ if (batch_values?.has(signal)) {
2300
+ return batch_values.get(signal);
2301
+ }
2302
+ if ((signal.f & ERROR_VALUE) !== 0) {
2303
+ throw signal.v;
2304
+ }
2305
+ return signal.v;
2306
+ }
2307
+ function reconnect(derived2) {
2308
+ derived2.f |= CONNECTED;
2309
+ if (derived2.deps === null) return;
2310
+ for (const dep of derived2.deps) {
2311
+ (dep.reactions ??= []).push(derived2);
2312
+ if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) {
2313
+ unfreeze_derived_effects(
2314
+ /** @type {Derived} */
2315
+ dep
2316
+ );
2317
+ reconnect(
2318
+ /** @type {Derived} */
2319
+ dep
2320
+ );
2321
+ }
2322
+ }
2323
+ }
2324
+ function depends_on_old_values(derived2) {
2325
+ if (derived2.v === UNINITIALIZED) return true;
2326
+ if (derived2.deps === null) return false;
2327
+ for (const dep of derived2.deps) {
2328
+ if (old_values.has(dep)) {
2329
+ return true;
2330
+ }
2331
+ if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
2332
+ /** @type {Derived} */
2333
+ dep
2334
+ )) {
2335
+ return true;
2336
+ }
2337
+ }
2338
+ return false;
2339
+ }
2340
+ function untrack(fn) {
2341
+ var previous_untracking = untracking;
2342
+ try {
2343
+ untracking = true;
2344
+ return fn();
2345
+ } finally {
2346
+ untracking = previous_untracking;
2347
+ }
2348
+ }
2349
+ const event_symbol = /* @__PURE__ */ Symbol("events");
2350
+ const all_registered_events = /* @__PURE__ */ new Set();
2351
+ const root_event_handles = /* @__PURE__ */ new Set();
2352
+ let last_propagated_event = null;
2353
+ function handle_event_propagation(event) {
2354
+ var handler_element = this;
2355
+ var owner_document = (
2356
+ /** @type {Node} */
2357
+ handler_element.ownerDocument
2358
+ );
2359
+ var event_name = event.type;
2360
+ var path = event.composedPath?.() || [];
2361
+ var current_target = (
2362
+ /** @type {null | Element} */
2363
+ path[0] || event.target
2364
+ );
2365
+ last_propagated_event = event;
2366
+ var path_idx = 0;
2367
+ var handled_at = last_propagated_event === event && event[event_symbol];
2368
+ if (handled_at) {
2369
+ var at_idx = path.indexOf(handled_at);
2370
+ if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
2371
+ window)) {
2372
+ event[event_symbol] = handler_element;
2373
+ return;
2374
+ }
2375
+ var handler_idx = path.indexOf(handler_element);
2376
+ if (handler_idx === -1) {
2377
+ return;
2378
+ }
2379
+ if (at_idx <= handler_idx) {
2380
+ path_idx = at_idx;
2381
+ }
2382
+ }
2383
+ current_target = /** @type {Element} */
2384
+ path[path_idx] || event.target;
2385
+ if (current_target === handler_element) return;
2386
+ define_property(event, "currentTarget", {
2387
+ configurable: true,
2388
+ get() {
2389
+ return current_target || owner_document;
2390
+ }
2391
+ });
2392
+ var previous_reaction = active_reaction;
2393
+ var previous_effect = active_effect;
2394
+ set_active_reaction(null);
2395
+ set_active_effect(null);
2396
+ try {
2397
+ var throw_error;
2398
+ var other_errors = [];
2399
+ while (current_target !== null) {
2400
+ var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
2401
+ current_target.host || null;
2402
+ try {
2403
+ var delegated = current_target[event_symbol]?.[event_name];
2404
+ if (delegated != null && (!/** @type {any} */
2405
+ current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2406
+ // -> the target could not have been disabled because it emits the event in the first place
2407
+ event.target === current_target)) {
2408
+ delegated.call(current_target, event);
2409
+ }
2410
+ } catch (error) {
2411
+ if (throw_error) {
2412
+ other_errors.push(error);
2413
+ } else {
2414
+ throw_error = error;
2415
+ }
2416
+ }
2417
+ if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
2418
+ break;
2419
+ }
2420
+ current_target = parent_element;
2421
+ }
2422
+ if (throw_error) {
2423
+ for (let error of other_errors) {
2424
+ queueMicrotask(() => {
2425
+ throw error;
2426
+ });
2427
+ }
2428
+ throw throw_error;
2429
+ }
2430
+ } finally {
2431
+ event[event_symbol] = handler_element;
2432
+ delete event.currentTarget;
2433
+ set_active_reaction(previous_reaction);
2434
+ set_active_effect(previous_effect);
2435
+ }
2436
+ }
2437
+ function assign_nodes(start, end) {
2438
+ var effect = (
2439
+ /** @type {Effect} */
2440
+ active_effect
2441
+ );
2442
+ if (effect.nodes === null) {
2443
+ effect.nodes = { start, end, a: null, t: null };
2444
+ }
2445
+ }
2446
+ function mount(component, options) {
2447
+ return _mount(component, options);
2448
+ }
2449
+ function hydrate(component, options) {
2450
+ init_operations();
2451
+ options.intro = options.intro ?? false;
2452
+ const target = options.target;
2453
+ const was_hydrating = hydrating;
2454
+ const previous_hydrate_node = hydrate_node;
2455
+ try {
2456
+ var anchor = /* @__PURE__ */ get_first_child(target);
2457
+ while (anchor && (anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */
2458
+ anchor.data !== HYDRATION_START)) {
2459
+ anchor = /* @__PURE__ */ get_next_sibling(anchor);
2460
+ }
2461
+ if (!anchor) {
2462
+ throw HYDRATION_ERROR;
2463
+ }
2464
+ set_hydrating(true);
2465
+ set_hydrate_node(
2466
+ /** @type {Comment} */
2467
+ anchor
2468
+ );
2469
+ const instance = _mount(component, { ...options, anchor });
2470
+ set_hydrating(false);
2471
+ return (
2472
+ /** @type {Exports} */
2473
+ instance
2474
+ );
2475
+ } catch (error) {
2476
+ if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) {
2477
+ throw error;
2478
+ }
2479
+ if (error !== HYDRATION_ERROR) {
2480
+ console.warn("Failed to hydrate: ", error);
2481
+ }
2482
+ if (options.recover === false) {
2483
+ hydration_failed();
2484
+ }
2485
+ init_operations();
2486
+ clear_text_content(target);
2487
+ set_hydrating(false);
2488
+ return mount(component, options);
2489
+ } finally {
2490
+ set_hydrating(was_hydrating);
2491
+ set_hydrate_node(previous_hydrate_node);
2492
+ }
2493
+ }
2494
+ const listeners = /* @__PURE__ */ new Map();
2495
+ function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
2496
+ init_operations();
2497
+ var component = void 0;
2498
+ var unmount2 = component_root(() => {
2499
+ var anchor_node = anchor ?? target.appendChild(create_text());
2500
+ boundary(
2501
+ /** @type {TemplateNode} */
2502
+ anchor_node,
2503
+ {
2504
+ pending: () => {
2505
+ }
2506
+ },
2507
+ (anchor_node2) => {
2508
+ push({});
2509
+ var ctx = (
2510
+ /** @type {ComponentContext} */
2511
+ component_context
2512
+ );
2513
+ if (context) ctx.c = context;
2514
+ if (events) {
2515
+ props.$$events = events;
2516
+ }
2517
+ if (hydrating) {
2518
+ assign_nodes(
2519
+ /** @type {TemplateNode} */
2520
+ anchor_node2,
2521
+ null
2522
+ );
2523
+ }
2524
+ component = Component(anchor_node2, props) || {};
2525
+ if (hydrating) {
2526
+ active_effect.nodes.end = hydrate_node;
2527
+ if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
2528
+ hydrate_node.data !== HYDRATION_END) {
2529
+ hydration_mismatch();
2530
+ throw HYDRATION_ERROR;
2531
+ }
2532
+ }
2533
+ pop();
2534
+ },
2535
+ transformError
2536
+ );
2537
+ var registered_events = /* @__PURE__ */ new Set();
2538
+ var event_handle = (events2) => {
2539
+ for (var i = 0; i < events2.length; i++) {
2540
+ var event_name = events2[i];
2541
+ if (registered_events.has(event_name)) continue;
2542
+ registered_events.add(event_name);
2543
+ var passive = is_passive_event(event_name);
2544
+ for (const node of [target, document]) {
2545
+ var counts = listeners.get(node);
2546
+ if (counts === void 0) {
2547
+ counts = /* @__PURE__ */ new Map();
2548
+ listeners.set(node, counts);
2549
+ }
2550
+ var count = counts.get(event_name);
2551
+ if (count === void 0) {
2552
+ node.addEventListener(event_name, handle_event_propagation, { passive });
2553
+ counts.set(event_name, 1);
2554
+ } else {
2555
+ counts.set(event_name, count + 1);
2556
+ }
2557
+ }
2558
+ }
2559
+ };
2560
+ event_handle(array_from(all_registered_events));
2561
+ root_event_handles.add(event_handle);
2562
+ return () => {
2563
+ for (var event_name of registered_events) {
2564
+ for (const node of [target, document]) {
2565
+ var counts = (
2566
+ /** @type {Map<string, number>} */
2567
+ listeners.get(node)
2568
+ );
2569
+ var count = (
2570
+ /** @type {number} */
2571
+ counts.get(event_name)
2572
+ );
2573
+ if (--count == 0) {
2574
+ node.removeEventListener(event_name, handle_event_propagation);
2575
+ counts.delete(event_name);
2576
+ if (counts.size === 0) {
2577
+ listeners.delete(node);
2578
+ }
2579
+ } else {
2580
+ counts.set(event_name, count);
2581
+ }
2582
+ }
2583
+ }
2584
+ root_event_handles.delete(event_handle);
2585
+ if (anchor_node !== anchor) {
2586
+ anchor_node.parentNode?.removeChild(anchor_node);
2587
+ }
2588
+ };
2589
+ });
2590
+ mounted_components.set(component, unmount2);
2591
+ return component;
2592
+ }
2593
+ let mounted_components = /* @__PURE__ */ new WeakMap();
2594
+ function unmount(component, options) {
2595
+ const fn = mounted_components.get(component);
2596
+ if (fn) {
2597
+ mounted_components.delete(component);
2598
+ return fn(options);
2599
+ }
2600
+ return Promise.resolve();
2601
+ }
2602
+ function asClassComponent$1(component) {
2603
+ return class extends Svelte4Component {
2604
+ /** @param {any} options */
2605
+ constructor(options) {
2606
+ super({
2607
+ component,
2608
+ ...options
2609
+ });
2610
+ }
2611
+ };
2612
+ }
2613
+ class Svelte4Component {
2614
+ /** @type {any} */
2615
+ #events;
2616
+ /** @type {Record<string, any>} */
2617
+ #instance;
2618
+ /**
2619
+ * @param {ComponentConstructorOptions & {
2620
+ * component: any;
2621
+ * }} options
2622
+ */
2623
+ constructor(options) {
2624
+ var sources = /* @__PURE__ */ new Map();
2625
+ var add_source = (key, value) => {
2626
+ var s = /* @__PURE__ */ mutable_source(value, false, false);
2627
+ sources.set(key, s);
2628
+ return s;
2629
+ };
2630
+ const props = new Proxy(
2631
+ { ...options.props || {}, $$events: {} },
2632
+ {
2633
+ get(target, prop) {
2634
+ return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2635
+ },
2636
+ has(target, prop) {
2637
+ if (prop === LEGACY_PROPS) return true;
2638
+ get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2639
+ return Reflect.has(target, prop);
2640
+ },
2641
+ set(target, prop, value) {
2642
+ set(sources.get(prop) ?? add_source(prop, value), value);
2643
+ return Reflect.set(target, prop, value);
2644
+ }
2645
+ }
2646
+ );
2647
+ this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
2648
+ target: options.target,
2649
+ anchor: options.anchor,
2650
+ props,
2651
+ context: options.context,
2652
+ intro: options.intro ?? false,
2653
+ recover: options.recover,
2654
+ transformError: options.transformError
2655
+ });
2656
+ if (!options?.props?.$$host || options.sync === false) {
2657
+ flushSync();
2658
+ }
2659
+ this.#events = props.$$events;
2660
+ for (const key of Object.keys(this.#instance)) {
2661
+ if (key === "$set" || key === "$destroy" || key === "$on") continue;
2662
+ define_property(this, key, {
2663
+ get() {
2664
+ return this.#instance[key];
2665
+ },
2666
+ /** @param {any} value */
2667
+ set(value) {
2668
+ this.#instance[key] = value;
2669
+ },
2670
+ enumerable: true
2671
+ });
2672
+ }
2673
+ this.#instance.$set = /** @param {Record<string, any>} next */
2674
+ (next2) => {
2675
+ Object.assign(props, next2);
2676
+ };
2677
+ this.#instance.$destroy = () => {
2678
+ unmount(this.#instance);
2679
+ };
2680
+ }
2681
+ /** @param {Record<string, any>} props */
2682
+ $set(props) {
2683
+ this.#instance.$set(props);
2684
+ }
2685
+ /**
2686
+ * @param {string} event
2687
+ * @param {(...args: any[]) => any} callback
2688
+ * @returns {any}
2689
+ */
2690
+ $on(event, callback) {
2691
+ this.#events[event] = this.#events[event] || [];
2692
+ const cb = (...args) => callback.call(this, ...args);
2693
+ this.#events[event].push(cb);
2694
+ return () => {
2695
+ this.#events[event] = this.#events[event].filter(
2696
+ /** @param {any} fn */
2697
+ (fn) => fn !== cb
2698
+ );
2699
+ };
2700
+ }
2701
+ $destroy() {
2702
+ this.#instance.$destroy();
2703
+ }
2704
+ }
2705
+ function asClassComponent(component) {
2706
+ const component_constructor = asClassComponent$1(component);
2707
+ const _render = (props, { context, csp, transformError } = {}) => {
2708
+ const result = render(component, { props, context, csp, transformError });
2709
+ const munged = Object.defineProperties(
2710
+ /** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
2711
+ {},
2712
+ {
2713
+ css: {
2714
+ value: { code: "", map: null }
2715
+ },
2716
+ head: {
2717
+ get: () => result.head
2718
+ },
2719
+ html: {
2720
+ get: () => result.body
2721
+ },
2722
+ then: {
2723
+ /**
2724
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
2725
+ *
2726
+ * @template TResult1
2727
+ * @template [TResult2=never]
2728
+ * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
2729
+ * @param { (reason: unknown) => TResult2 } onrejected
2730
+ */
2731
+ value: (onfulfilled, onrejected) => {
2732
+ {
2733
+ const user_result = onfulfilled({
2734
+ css: munged.css,
2735
+ head: munged.head,
2736
+ html: munged.html
2737
+ });
2738
+ return Promise.resolve(user_result);
2739
+ }
2740
+ }
2741
+ }
2742
+ }
2743
+ );
2744
+ return munged;
2745
+ };
2746
+ component_constructor.render = _render;
2747
+ return component_constructor;
2748
+ }
2749
+ function Root($$renderer, $$props) {
2750
+ $$renderer.component(($$renderer2) => {
2751
+ let {
2752
+ stores,
2753
+ page,
2754
+ constructors,
2755
+ components = [],
2756
+ form,
2757
+ data_0 = null,
2758
+ data_1 = null
2759
+ } = $$props;
2760
+ {
2761
+ setContext("__svelte__", stores);
2762
+ }
2763
+ {
2764
+ stores.page.set(page);
2765
+ }
2766
+ const Pyramid_1 = derived(() => constructors[1]);
2767
+ if (constructors[1]) {
2768
+ $$renderer2.push("<!--[0-->");
2769
+ const Pyramid_0 = constructors[0];
2770
+ if (Pyramid_0) {
2771
+ $$renderer2.push("<!--[-->");
2772
+ Pyramid_0($$renderer2, {
2773
+ data: data_0,
2774
+ form,
2775
+ params: page.params,
2776
+ children: ($$renderer3) => {
2777
+ if (Pyramid_1()) {
2778
+ $$renderer3.push("<!--[-->");
2779
+ Pyramid_1()($$renderer3, { data: data_1, form, params: page.params });
2780
+ $$renderer3.push("<!--]-->");
2781
+ } else {
2782
+ $$renderer3.push("<!--[!-->");
2783
+ $$renderer3.push("<!--]-->");
2784
+ }
2785
+ },
2786
+ $$slots: { default: true }
2787
+ });
2788
+ $$renderer2.push("<!--]-->");
2789
+ } else {
2790
+ $$renderer2.push("<!--[!-->");
2791
+ $$renderer2.push("<!--]-->");
2792
+ }
2793
+ } else {
2794
+ $$renderer2.push("<!--[-1-->");
2795
+ const Pyramid_0 = constructors[0];
2796
+ if (Pyramid_0) {
2797
+ $$renderer2.push("<!--[-->");
2798
+ Pyramid_0($$renderer2, { data: data_0, form, params: page.params });
2799
+ $$renderer2.push("<!--]-->");
2800
+ } else {
2801
+ $$renderer2.push("<!--[!-->");
2802
+ $$renderer2.push("<!--]-->");
2803
+ }
2804
+ }
2805
+ $$renderer2.push(`<!--]--> `);
2806
+ {
2807
+ $$renderer2.push("<!--[-1-->");
2808
+ }
2809
+ $$renderer2.push(`<!--]-->`);
2810
+ });
2811
+ }
2812
+ const root = asClassComponent(Root);
2813
+
2814
+ export { root as r, safe_not_equal as s };
2815
+ //# sourceMappingURL=root.js-DCnlE3XY.js.map