@solidjs/signals 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -1,2264 +1,2016 @@
1
- 'use strict';
2
-
3
- // src/core/error.ts
4
- var NotReadyError = class extends Error {
5
- constructor(cause) {
1
+ "use strict";
2
+ class NotReadyError extends Error {
3
+ cause;
4
+ constructor(e) {
6
5
  super();
7
- this.cause = cause;
6
+ this.cause = e;
8
7
  }
9
- };
10
- var NoOwnerError = class extends Error {
8
+ }
9
+ class NoOwnerError extends Error {
11
10
  constructor() {
12
11
  super("");
13
12
  }
14
- };
15
- var ContextNotFoundError = class extends Error {
16
- constructor() {
17
- super(
18
- ""
19
- );
20
- }
21
- };
22
-
23
- // src/core/constants.ts
24
- var NOT_PENDING = {};
25
- var SUPPORTS_PROXY = typeof Proxy === "function";
26
-
27
- // src/core/heap.ts
28
- function actualInsertIntoHeap(n, heap) {
29
- var _a, _b, _c;
30
- const parentHeight = (((_a = n.w) == null ? void 0 : _a.$) ? (_b = n.w.aa) == null ? void 0 : _b.c : (_c = n.w) == null ? void 0 : _c.c) ?? -1;
31
- if (parentHeight >= n.c)
32
- n.c = parentHeight + 1;
33
- const height = n.c;
34
- const heapAtHeight = heap.s[height];
35
- if (heapAtHeight === void 0) {
36
- heap.s[height] = n;
37
- } else {
38
- const tail = heapAtHeight.z;
39
- tail.Q = n;
40
- n.z = tail;
41
- heapAtHeight.z = n;
42
- }
43
- if (height > heap.L) {
44
- heap.L = height;
45
- }
46
13
  }
47
- function insertIntoHeap(n, heap) {
48
- let flags = n.b;
49
- if (flags & (8 /* InHeap */ | 4 /* RecomputingDeps */))
50
- return;
51
- if (flags & 1 /* Check */) {
52
- n.b = flags & ~(1 /* Check */ | 2 /* Dirty */) | 2 /* Dirty */ | 8 /* InHeap */;
53
- } else
54
- n.b = flags | 8 /* InHeap */;
55
- if (!(flags & 16 /* InHeapHeight */)) {
56
- actualInsertIntoHeap(n, heap);
57
- }
58
- }
59
- function insertIntoHeapHeight(n, heap) {
60
- let flags = n.b;
61
- if (flags & (8 /* InHeap */ | 4 /* RecomputingDeps */ | 16 /* InHeapHeight */))
62
- return;
63
- n.b = flags | 16 /* InHeapHeight */;
64
- actualInsertIntoHeap(n, heap);
65
- }
66
- function deleteFromHeap(n, heap) {
67
- const flags = n.b;
68
- if (!(flags & (8 /* InHeap */ | 16 /* InHeapHeight */)))
69
- return;
70
- n.b = flags & ~(8 /* InHeap */ | 16 /* InHeapHeight */);
71
- const height = n.c;
72
- if (n.z === n) {
73
- heap.s[height] = void 0;
74
- } else {
75
- const next = n.Q;
76
- const dhh = heap.s[height];
77
- const end = next ?? dhh;
78
- if (n === dhh) {
79
- heap.s[height] = next;
80
- } else {
81
- n.z.Q = next;
82
- }
83
- end.z = n.z;
84
- }
85
- n.z = n;
86
- n.Q = void 0;
87
- }
88
- function markHeap(heap) {
89
- if (heap.ba)
90
- return;
91
- heap.ba = true;
92
- for (let i = 0; i <= heap.L; i++) {
93
- for (let el = heap.s[i]; el !== void 0; el = el.Q) {
94
- if (el.b & 8 /* InHeap */)
95
- markNode(el);
96
- }
14
+ class ContextNotFoundError extends Error {
15
+ constructor() {
16
+ super("");
97
17
  }
98
18
  }
99
- function markNode(el, newState = 2 /* Dirty */) {
100
- const flags = el.b;
101
- if ((flags & (1 /* Check */ | 2 /* Dirty */)) >= newState)
102
- return;
103
- el.b = flags & ~(1 /* Check */ | 2 /* Dirty */) | newState;
104
- for (let link2 = el.x; link2 !== null; link2 = link2.A) {
105
- markNode(link2.j, 1 /* Check */);
106
- }
107
- if (el.ca !== null) {
108
- for (let child = el.ca; child !== null; child = child.sa) {
109
- for (let link2 = child.x; link2 !== null; link2 = link2.A) {
110
- markNode(link2.j, 1 /* Check */);
19
+ const e = 0;
20
+ const t = 1 << 0;
21
+ const n = 1 << 1;
22
+ const r = 1 << 2;
23
+ const i = 1 << 3;
24
+ const s = 1 << 4;
25
+ const o = 1 << 5;
26
+ const u = 1 << 6;
27
+ const l = 0;
28
+ const f = 1 << 0;
29
+ const c = 1 << 1;
30
+ const a = 1 << 2;
31
+ const d = 1;
32
+ const h = 2;
33
+ const p = {};
34
+ const y = typeof Proxy === "function";
35
+ const g = {};
36
+ function actualInsertIntoHeap(e, t) {
37
+ const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1;
38
+ if (n >= e.o) e.o = n + 1;
39
+ const r = e.o;
40
+ const i = t.l[r];
41
+ if (i === undefined) t.l[r] = e;
42
+ else {
43
+ const t = i.h;
44
+ t.p = e;
45
+ e.h = t;
46
+ i.h = e;
47
+ }
48
+ if (r > t._) t._ = r;
49
+ }
50
+ function insertIntoHeap(e, o) {
51
+ let u = e.S;
52
+ if (u & (i | r)) return;
53
+ if (u & t) {
54
+ e.S = (u & -4) | n | i;
55
+ } else e.S = u | i;
56
+ if (!(u & s)) actualInsertIntoHeap(e, o);
57
+ }
58
+ function insertIntoHeapHeight(e, t) {
59
+ let n = e.S;
60
+ if (n & (i | r | s)) return;
61
+ e.S = n | s;
62
+ actualInsertIntoHeap(e, t);
63
+ }
64
+ function deleteFromHeap(e, t) {
65
+ const n = e.S;
66
+ if (!(n & (i | s))) return;
67
+ e.S = n & -25;
68
+ const r = e.o;
69
+ if (e.h === e) t.l[r] = undefined;
70
+ else {
71
+ const n = e.p;
72
+ const i = t.l[r];
73
+ const s = n ?? i;
74
+ if (e === i) t.l[r] = n;
75
+ else e.h.p = n;
76
+ s.h = e.h;
77
+ }
78
+ e.h = e;
79
+ e.p = undefined;
80
+ }
81
+ function markHeap(e) {
82
+ if (e.m) return;
83
+ e.m = true;
84
+ for (let t = 0; t <= e._; t++) {
85
+ for (let n = e.l[t]; n !== undefined; n = n.p) {
86
+ if (n.S & i) markNode(n);
87
+ }
88
+ }
89
+ }
90
+ function markNode(e, r = n) {
91
+ const i = e.S;
92
+ if ((i & (t | n)) >= r) return;
93
+ e.S = (i & -4) | r;
94
+ for (let n = e.O; n !== null; n = n.C) {
95
+ markNode(n.N, t);
96
+ }
97
+ if (e.k !== null) {
98
+ for (let n = e.k; n !== null; n = n.j) {
99
+ for (let e = n.O; e !== null; e = e.C) {
100
+ markNode(e.N, t);
111
101
  }
112
102
  }
113
103
  }
114
104
  }
115
- function runHeap(heap, recompute2) {
116
- heap.ba = false;
117
- for (heap.q = 0; heap.q <= heap.L; heap.q++) {
118
- let el = heap.s[heap.q];
119
- while (el !== void 0) {
120
- if (el.b & 8 /* InHeap */)
121
- recompute2(el);
122
- else {
123
- adjustHeight(el, heap);
124
- }
125
- el = heap.s[heap.q];
105
+ function runHeap(e, t) {
106
+ e.m = false;
107
+ for (e.A = 0; e.A <= e._; e.A++) {
108
+ let n = e.l[e.A];
109
+ while (n !== undefined) {
110
+ if (n.S & i) t(n);
111
+ else adjustHeight(n, e);
112
+ n = e.l[e.A];
126
113
  }
127
114
  }
128
- heap.L = 0;
115
+ e._ = 0;
129
116
  }
130
- function adjustHeight(el, heap) {
131
- deleteFromHeap(el, heap);
132
- let newHeight = el.c;
133
- for (let d = el.l; d; d = d.E) {
134
- const dep1 = d.R;
135
- const dep = dep1.ia || dep1;
136
- if (dep.H) {
137
- if (dep.c >= newHeight) {
138
- newHeight = dep.c + 1;
139
- }
140
- }
117
+ function adjustHeight(e, t) {
118
+ deleteFromHeap(e, t);
119
+ let n = e.o;
120
+ for (let t = e.W; t; t = t.P) {
121
+ const e = t.H;
122
+ const r = e.I || e;
123
+ if (r.F && r.o >= n) n = r.o + 1;
141
124
  }
142
- if (el.c !== newHeight) {
143
- el.c = newHeight;
144
- for (let s = el.x; s !== null; s = s.A) {
145
- insertIntoHeapHeight(s.j, heap);
125
+ if (e.o !== n) {
126
+ e.o = n;
127
+ for (let n = e.O; n !== null; n = n.C) {
128
+ insertIntoHeapHeight(n.N, t);
146
129
  }
147
130
  }
148
131
  }
149
-
150
- // src/core/scheduler.ts
151
- var clock = 0;
152
- var activeTransition = null;
153
- var transitions = /* @__PURE__ */ new Set();
154
- var scheduled = false;
132
+ const w = new Set();
133
+ const _ = { l: new Array(2e3).fill(undefined), m: false, A: 0, _: 0 };
134
+ const S = { l: new Array(2e3).fill(undefined), m: false, A: 0, _: 0 };
135
+ let b = 0;
136
+ let m = null;
137
+ let x = false;
155
138
  function schedule() {
156
- if (scheduled)
157
- return;
158
- scheduled = true;
159
- if (!globalQueue.da)
160
- queueMicrotask(flush);
161
- }
162
- var dirtyQueue = {
163
- s: new Array(2e3).fill(void 0),
164
- ba: false,
165
- q: 0,
166
- L: 0
167
- };
168
- var zombieQueue = {
169
- s: new Array(2e3).fill(void 0),
170
- ba: false,
171
- q: 0,
172
- L: 0
173
- };
174
- var Queue = class {
175
- w = null;
176
- k = [[], []];
177
- m = [];
178
- created = clock;
179
- addChild(child) {
180
- this.m.push(child);
181
- child.w = this;
182
- }
183
- removeChild(child) {
184
- const index = this.m.indexOf(child);
185
- if (index >= 0) {
186
- this.m.splice(index, 1);
187
- child.w = null;
188
- }
189
- }
190
- notify(node, mask, flags) {
191
- if (this.w)
192
- return this.w.notify(node, mask, flags);
139
+ if (x) return;
140
+ x = true;
141
+ if (!O.R) queueMicrotask(flush);
142
+ }
143
+ class Queue {
144
+ i = null;
145
+ V = [[], []];
146
+ q = [];
147
+ created = b;
148
+ addChild(e) {
149
+ this.q.push(e);
150
+ e.i = this;
151
+ }
152
+ removeChild(e) {
153
+ const t = this.q.indexOf(e);
154
+ if (t >= 0) {
155
+ this.q.splice(t, 1);
156
+ e.i = null;
157
+ }
158
+ }
159
+ notify(e, t, n) {
160
+ if (this.i) return this.i.notify(e, t, n);
193
161
  return false;
194
162
  }
195
- run(type) {
196
- if (this.k[type - 1].length) {
197
- const effects = this.k[type - 1];
198
- this.k[type - 1] = [];
199
- runQueue(effects, type);
163
+ run(e) {
164
+ if (this.V[e - 1].length) {
165
+ const t = this.V[e - 1];
166
+ this.V[e - 1] = [];
167
+ runQueue(t, e);
200
168
  }
201
- for (let i = 0; i < this.m.length; i++) {
202
- this.m[i].run(type);
169
+ for (let t = 0; t < this.q.length; t++) {
170
+ this.q[t].run(e);
203
171
  }
204
172
  }
205
- enqueue(type, fn) {
206
- if (type)
207
- this.k[type - 1].push(fn);
173
+ enqueue(e, t) {
174
+ if (e) this.V[e - 1].push(t);
208
175
  schedule();
209
176
  }
210
- stashQueues(stub) {
211
- stub.k[0].push(...this.k[0]);
212
- stub.k[1].push(...this.k[1]);
213
- this.k = [[], []];
214
- for (let i = 0; i < this.m.length; i++) {
215
- let child = this.m[i];
216
- let childStub = stub.m[i];
217
- if (!childStub) {
218
- childStub = { k: [[], []], m: [] };
219
- stub.m[i] = childStub;
177
+ stashQueues(e) {
178
+ e.V[0].push(...this.V[0]);
179
+ e.V[1].push(...this.V[1]);
180
+ this.V = [[], []];
181
+ for (let t = 0; t < this.q.length; t++) {
182
+ let n = this.q[t];
183
+ let r = e.q[t];
184
+ if (!r) {
185
+ r = { V: [[], []], q: [] };
186
+ e.q[t] = r;
220
187
  }
221
- child.stashQueues(childStub);
188
+ n.stashQueues(r);
222
189
  }
223
190
  }
224
- restoreQueues(stub) {
225
- this.k[0].push(...stub.k[0]);
226
- this.k[1].push(...stub.k[1]);
227
- for (let i = 0; i < stub.m.length; i++) {
228
- const childStub = stub.m[i];
229
- let child = this.m[i];
230
- if (child)
231
- child.restoreQueues(childStub);
191
+ restoreQueues(e) {
192
+ this.V[0].push(...e.V[0]);
193
+ this.V[1].push(...e.V[1]);
194
+ for (let t = 0; t < e.q.length; t++) {
195
+ const n = e.q[t];
196
+ let r = this.q[t];
197
+ if (r) r.restoreQueues(n);
232
198
  }
233
199
  }
234
- };
235
- var GlobalQueue = class _GlobalQueue extends Queue {
236
- da = false;
237
- h = [];
238
- static S;
239
- static la;
200
+ }
201
+ class GlobalQueue extends Queue {
202
+ R = false;
203
+ M = [];
204
+ static D;
205
+ static B;
240
206
  flush() {
241
- if (this.da)
242
- return;
243
- this.da = true;
207
+ if (this.R) return;
208
+ this.R = true;
244
209
  try {
245
- runHeap(dirtyQueue, _GlobalQueue.S);
246
- if (activeTransition) {
247
- if (!transitionComplete(activeTransition)) {
248
- runHeap(zombieQueue, _GlobalQueue.S);
249
- globalQueue.h = [];
250
- globalQueue.stashQueues(activeTransition.queueStash);
251
- clock++;
252
- scheduled = false;
253
- runPending(activeTransition.pendingNodes, true);
254
- activeTransition = null;
210
+ runHeap(_, GlobalQueue.D);
211
+ if (m) {
212
+ if (!transitionComplete(m)) {
213
+ runHeap(S, GlobalQueue.D);
214
+ this.M = [];
215
+ this.stashQueues(m.queueStash);
216
+ b++;
217
+ x = false;
218
+ runPending(m.pendingNodes, true);
219
+ m = null;
255
220
  return;
256
221
  }
257
- globalQueue.h.push(...activeTransition.pendingNodes);
258
- globalQueue.restoreQueues(activeTransition.queueStash);
259
- transitions.delete(activeTransition);
260
- activeTransition = null;
261
- if (runPending(globalQueue.h, false))
262
- runHeap(dirtyQueue, _GlobalQueue.S);
263
- } else if (transitions.size)
264
- runHeap(zombieQueue, _GlobalQueue.S);
265
- for (let i = 0; i < globalQueue.h.length; i++) {
266
- const n = globalQueue.h[i];
267
- if (n.e !== NOT_PENDING) {
268
- n.g = n.e;
269
- n.e = NOT_PENDING;
222
+ this.M.push(...m.pendingNodes);
223
+ this.restoreQueues(m.queueStash);
224
+ w.delete(m);
225
+ m = null;
226
+ if (runPending(this.M, false)) runHeap(_, GlobalQueue.D);
227
+ } else if (w.size) runHeap(S, GlobalQueue.D);
228
+ for (let e = 0; e < this.M.length; e++) {
229
+ const t = this.M[e];
230
+ if (t.K !== p) {
231
+ t.G = t.K;
232
+ t.K = p;
233
+ if (t.T) t.U = true;
270
234
  }
271
- if (n.H)
272
- _GlobalQueue.la(n, false, true);
235
+ if (t.F) GlobalQueue.B(t, false, true);
273
236
  }
274
- globalQueue.h.length = 0;
275
- clock++;
276
- scheduled = false;
277
- this.run(1 /* Render */);
278
- this.run(2 /* User */);
237
+ this.M.length = 0;
238
+ b++;
239
+ x = false;
240
+ this.run(d);
241
+ this.run(h);
279
242
  } finally {
280
- this.da = false;
243
+ this.R = false;
281
244
  }
282
245
  }
283
- notify(node, mask, flags) {
284
- if (mask & 1 /* Pending */) {
285
- if (flags & 1 /* Pending */) {
286
- if (activeTransition && !activeTransition.asyncNodes.includes(node.B.cause))
287
- activeTransition.asyncNodes.push(node.B.cause);
246
+ notify(e, t, n) {
247
+ if (t & f) {
248
+ if (n & f) {
249
+ if (m && !m.asyncNodes.includes(e.L.cause)) m.asyncNodes.push(e.L.cause);
288
250
  }
289
251
  return true;
290
252
  }
291
253
  return false;
292
254
  }
293
- initTransition(node) {
294
- if (activeTransition && activeTransition.time === clock)
295
- return;
296
- if (!activeTransition) {
297
- activeTransition = node.T ?? {
298
- time: clock,
299
- pendingNodes: [],
300
- asyncNodes: [],
301
- queueStash: { k: [[], []], m: [] }
302
- };
255
+ initTransition(e) {
256
+ if (m && m.time === b) return;
257
+ if (!m) {
258
+ m = e.J ?? { time: b, pendingNodes: [], asyncNodes: [], queueStash: { V: [[], []], q: [] } };
303
259
  }
304
- transitions.add(activeTransition);
305
- activeTransition.time = clock;
306
- for (let i = 0; i < globalQueue.h.length; i++) {
307
- const n = globalQueue.h[i];
308
- n.T = activeTransition;
309
- activeTransition.pendingNodes.push(n);
260
+ w.add(m);
261
+ m.time = b;
262
+ for (let e = 0; e < this.M.length; e++) {
263
+ const t = this.M[e];
264
+ t.J = m;
265
+ m.pendingNodes.push(t);
310
266
  }
311
- globalQueue.h = activeTransition.pendingNodes;
267
+ this.M = m.pendingNodes;
312
268
  }
313
- };
314
- function runPending(pendingNodes, value) {
315
- let needsReset = false;
316
- const p = pendingNodes.slice();
317
- for (let i = 0; i < p.length; i++) {
318
- const n = p[i];
319
- n.T = activeTransition;
320
- if (n.I) {
321
- n.I.ea(value);
322
- needsReset = true;
269
+ }
270
+ function runPending(e, t) {
271
+ let n = false;
272
+ const r = e.slice();
273
+ for (let e = 0; e < r.length; e++) {
274
+ const i = r[e];
275
+ i.J = m;
276
+ if (i.X) {
277
+ i.X.Y(t);
278
+ n = true;
279
+ }
280
+ if (i.Z && i.Z.K !== p) {
281
+ i.Z.Y(i.Z.K);
282
+ i.Z.K = p;
283
+ n = true;
323
284
  }
324
285
  }
325
- return needsReset;
286
+ return n;
326
287
  }
327
- var globalQueue = new GlobalQueue();
288
+ const O = new GlobalQueue();
328
289
  function flush() {
329
- while (scheduled) {
330
- globalQueue.flush();
290
+ while (x) {
291
+ O.flush();
331
292
  }
332
293
  }
333
- function runQueue(queue, type) {
334
- for (let i = 0; i < queue.length; i++)
335
- queue[i](type);
294
+ function runQueue(e, t) {
295
+ for (let n = 0; n < e.length; n++) e[n](t);
336
296
  }
337
- function transitionComplete(transition) {
338
- let done = true;
339
- for (let i = 0; i < transition.asyncNodes.length; i++) {
340
- if (transition.asyncNodes[i].f & 1 /* Pending */) {
341
- done = false;
297
+ function transitionComplete(e) {
298
+ let t = true;
299
+ for (let n = 0; n < e.asyncNodes.length; n++) {
300
+ if (e.asyncNodes[n].$ & f) {
301
+ t = false;
342
302
  break;
343
303
  }
344
304
  }
345
- return done;
346
- }
347
-
348
- // src/core/core.ts
349
- GlobalQueue.S = recompute;
350
- GlobalQueue.la = disposeChildren;
351
- var tracking = false;
352
- var stale = false;
353
- var pendingValueCheck = false;
354
- var pendingCheck = null;
355
- var context = null;
356
- var defaultContext = {};
357
- function notifySubs(node) {
358
- for (let s = node.x; s !== null; s = s.A) {
359
- const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
360
- if (queue.q > s.j.c)
361
- queue.q = s.j.c;
362
- insertIntoHeap(s.j, queue);
363
- }
364
- }
365
- function recompute(el, create = false) {
366
- var _a;
367
- deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
368
- if (el.e !== NOT_PENDING || el.U || el.V)
369
- disposeChildren(el);
305
+ return t;
306
+ }
307
+ function runInTransition(e, t) {
308
+ const n = m;
309
+ m = e.J;
310
+ t(e);
311
+ m = n;
312
+ }
313
+ GlobalQueue.D = recompute;
314
+ GlobalQueue.B = disposeChildren;
315
+ let C = false;
316
+ let v = false;
317
+ let N = false;
318
+ let k = null;
319
+ let E = null;
320
+ function notifySubs(e) {
321
+ for (let t = e.O; t !== null; t = t.C) {
322
+ const e = t.N.S & o ? S : _;
323
+ if (e.A > t.N.o) e.A = t.N.o;
324
+ insertIntoHeap(t.N, e);
325
+ }
326
+ }
327
+ function recompute(t, n = false) {
328
+ deleteFromHeap(t, t.S & o ? S : _);
329
+ if (t.K !== p || t.ee || t.te) disposeChildren(t);
370
330
  else {
371
- markDisposal(el);
372
- globalQueue.h.push(el);
373
- el.V = el.t;
374
- el.U = el.r;
375
- el.t = null;
376
- el.r = null;
377
- }
378
- const oldcontext = context;
379
- context = el;
380
- el.F = null;
381
- el.b = 4 /* RecomputingDeps */;
382
- el.J = clock;
383
- let value = el.e === NOT_PENDING ? el.g : el.e;
384
- let oldHeight = el.c;
385
- let prevStatusFlags = el.f;
386
- let prevError = el.B;
387
- let prevTracking = tracking;
388
- clearStatusFlags(el);
389
- tracking = true;
331
+ markDisposal(t);
332
+ O.M.push(t);
333
+ t.te = t.ne;
334
+ t.ee = t.re;
335
+ t.ne = null;
336
+ t.re = null;
337
+ }
338
+ const i = E;
339
+ E = t;
340
+ t.ie = null;
341
+ t.S = r;
342
+ t.se = b;
343
+ let s = t.K === p ? t.G : t.K;
344
+ let u = t.o;
345
+ let d = t.$;
346
+ let h = t.L;
347
+ let y = C;
348
+ setStatusFlags(t, l | (d & a));
349
+ C = true;
390
350
  try {
391
- value = el.H(value);
351
+ s = t.F(s);
352
+ t.$ &= ~a;
392
353
  } catch (e) {
393
354
  if (e instanceof NotReadyError) {
394
- if (e.cause !== el)
395
- link(e.cause, el);
396
- setStatusFlags(el, prevStatusFlags & ~2 /* Error */ | 1 /* Pending */, e);
397
- } else {
398
- setError(el, e);
399
- }
355
+ if (e.cause !== t) link(e.cause, t);
356
+ setStatusFlags(t, (d & ~c) | f, e);
357
+ } else setStatusFlags(t, c, e);
400
358
  } finally {
401
- tracking = prevTracking;
359
+ C = y;
402
360
  }
403
- el.b = 0 /* None */;
404
- context = oldcontext;
405
- const depsTail = el.F;
406
- let toRemove = depsTail !== null ? depsTail.E : el.l;
407
- if (toRemove !== null) {
361
+ t.S = e;
362
+ E = i;
363
+ const g = t.ie;
364
+ let w = g !== null ? g.P : t.W;
365
+ if (w !== null) {
408
366
  do {
409
- toRemove = unlinkSubs(toRemove);
410
- } while (toRemove !== null);
411
- if (depsTail !== null) {
412
- depsTail.E = null;
413
- } else {
414
- el.l = null;
415
- }
416
- }
417
- const valueChanged = !el.fa || !el.fa(el.e === NOT_PENDING ? el.g : el.e, value);
418
- const statusFlagsChanged = el.f !== prevStatusFlags || el.B !== prevError;
419
- (_a = el.ma) == null ? void 0 : _a.call(el, statusFlagsChanged, prevStatusFlags);
420
- if (valueChanged || statusFlagsChanged) {
421
- if (valueChanged) {
422
- if (create || el.ja || el.K)
423
- el.g = value;
367
+ w = unlinkSubs(w);
368
+ } while (w !== null);
369
+ if (g !== null) g.P = null;
370
+ else t.W = null;
371
+ }
372
+ const x = !t.oe || !t.oe(t.K === p || t.ue ? t.G : t.K, s);
373
+ const v = t.$ !== d || t.L !== h;
374
+ t.le?.(v, d);
375
+ if (x || v) {
376
+ if (x) {
377
+ if (n || t.ue || (t.T && t.J != m)) t.G = s;
424
378
  else {
425
- if (el.e === NOT_PENDING)
426
- globalQueue.h.push(el);
427
- el.e = value;
379
+ if (t.K === p) O.M.push(t);
380
+ t.K = s;
428
381
  }
429
- if (el.C)
430
- el.C.ea(value);
382
+ if (t.Z) t.Z.Y(s);
431
383
  }
432
- for (let s = el.x; s !== null; s = s.A) {
433
- const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
434
- if (s.j.c < el.c && queue.q > s.j.c)
435
- queue.q = s.j.c;
436
- insertIntoHeap(s.j, queue);
384
+ for (let e = t.O; e !== null; e = e.C) {
385
+ const n = e.N.S & o ? S : _;
386
+ if (e.N.o < t.o && n.A > e.N.o) n.A = e.N.o;
387
+ insertIntoHeap(e.N, n);
437
388
  }
438
- } else if (el.c != oldHeight) {
439
- for (let s = el.x; s !== null; s = s.A) {
440
- insertIntoHeapHeight(s.j, s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
389
+ } else if (t.o != u) {
390
+ for (let e = t.O; e !== null; e = e.C) {
391
+ insertIntoHeapHeight(e.N, e.N.S & o ? S : _);
441
392
  }
442
393
  }
394
+ if (t.T && t.J && m !== t.J) runInTransition(t, recompute);
443
395
  }
444
- function updateIfNecessary(el) {
445
- if (el.b & 1 /* Check */) {
446
- for (let d = el.l; d; d = d.E) {
447
- const dep1 = d.R;
448
- const dep = dep1.ia || dep1;
449
- if (dep.H) {
450
- updateIfNecessary(dep);
396
+ function updateIfNecessary(r) {
397
+ if (r.S & t) {
398
+ for (let e = r.W; e; e = e.P) {
399
+ const t = e.H;
400
+ const i = t.I || t;
401
+ if (i.F) {
402
+ updateIfNecessary(i);
451
403
  }
452
- if (el.b & 2 /* Dirty */) {
404
+ if (r.S & n) {
453
405
  break;
454
406
  }
455
407
  }
456
408
  }
457
- if (el.b & 2 /* Dirty */) {
458
- recompute(el);
459
- }
460
- el.b = 0 /* None */;
461
- }
462
- function unlinkSubs(link2) {
463
- var _a;
464
- const dep = link2.R;
465
- const nextDep = link2.E;
466
- const nextSub = link2.A;
467
- const prevSub = link2.na;
468
- if (nextSub !== null) {
469
- nextSub.na = prevSub;
470
- } else {
471
- dep.W = prevSub;
472
- }
473
- if (prevSub !== null) {
474
- prevSub.A = nextSub;
475
- } else {
476
- dep.x = nextSub;
477
- if (nextSub === null) {
478
- (_a = dep.ta) == null ? void 0 : _a.call(dep);
479
- dep.H && unobserved(dep);
480
- }
409
+ if (r.S & n) {
410
+ recompute(r);
481
411
  }
482
- return nextDep;
412
+ r.S = e;
483
413
  }
484
- function unobserved(el) {
485
- deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
486
- let dep = el.l;
487
- while (dep !== null) {
488
- dep = unlinkSubs(dep);
489
- }
490
- el.l = null;
491
- runDisposal(el);
492
- }
493
- function link(dep, sub) {
494
- const prevDep = sub.F;
495
- if (prevDep !== null && prevDep.R === dep) {
496
- return;
497
- }
498
- let nextDep = null;
499
- const isRecomputing = sub.b & 4 /* RecomputingDeps */;
500
- if (isRecomputing) {
501
- nextDep = prevDep !== null ? prevDep.E : sub.l;
502
- if (nextDep !== null && nextDep.R === dep) {
503
- sub.F = nextDep;
414
+ function unlinkSubs(e) {
415
+ const t = e.H;
416
+ const n = e.P;
417
+ const r = e.C;
418
+ const i = e.fe;
419
+ if (r !== null) r.fe = i;
420
+ else t.ce = i;
421
+ if (i !== null) i.C = r;
422
+ else {
423
+ t.O = r;
424
+ if (r === null) {
425
+ t.ae?.();
426
+ t.F && unobserved(t);
427
+ }
428
+ }
429
+ return n;
430
+ }
431
+ function unobserved(e) {
432
+ deleteFromHeap(e, e.S & o ? S : _);
433
+ let t = e.W;
434
+ while (t !== null) {
435
+ t = unlinkSubs(t);
436
+ }
437
+ e.W = null;
438
+ runDisposal(e);
439
+ }
440
+ function link(e, t) {
441
+ const n = t.ie;
442
+ if (n !== null && n.H === e) return;
443
+ let i = null;
444
+ const s = t.S & r;
445
+ if (s) {
446
+ i = n !== null ? n.P : t.W;
447
+ if (i !== null && i.H === e) {
448
+ t.ie = i;
504
449
  return;
505
450
  }
506
451
  }
507
- const prevSub = dep.W;
508
- if (prevSub !== null && prevSub.j === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
509
- return;
510
- }
511
- const newLink = sub.F = dep.W = {
512
- R: dep,
513
- j: sub,
514
- E: nextDep,
515
- na: prevSub,
516
- A: null
517
- };
518
- if (prevDep !== null) {
519
- prevDep.E = newLink;
520
- } else {
521
- sub.l = newLink;
522
- }
523
- if (prevSub !== null) {
524
- prevSub.A = newLink;
525
- } else {
526
- dep.x = newLink;
527
- }
452
+ const o = e.ce;
453
+ if (o !== null && o.N === t && (!s || isValidLink(o, t))) return;
454
+ const u = (t.ie = e.ce = { H: e, N: t, P: i, fe: o, C: null });
455
+ if (n !== null) n.P = u;
456
+ else t.W = u;
457
+ if (o !== null) o.C = u;
458
+ else e.O = u;
528
459
  }
529
- function isValidLink(checkLink, sub) {
530
- const depsTail = sub.F;
531
- if (depsTail !== null) {
532
- let link2 = sub.l;
460
+ function isValidLink(e, t) {
461
+ const n = t.ie;
462
+ if (n !== null) {
463
+ let r = t.W;
533
464
  do {
534
- if (link2 === checkLink) {
535
- return true;
536
- }
537
- if (link2 === depsTail) {
538
- break;
539
- }
540
- link2 = link2.E;
541
- } while (link2 !== null);
465
+ if (r === e) return true;
466
+ if (r === n) break;
467
+ r = r.P;
468
+ } while (r !== null);
542
469
  }
543
470
  return false;
544
471
  }
545
- function setStatusFlags(signal2, flags, error = null) {
546
- signal2.f = flags;
547
- signal2.B = error;
548
- }
549
- function setError(signal2, error) {
550
- setStatusFlags(signal2, 2 /* Error */, error);
472
+ function setStatusFlags(e, t, n = null) {
473
+ e.$ = t;
474
+ e.L = n;
551
475
  }
552
- function clearStatusFlags(signal2) {
553
- setStatusFlags(signal2, 0 /* None */);
554
- }
555
- function markDisposal(el) {
556
- let child = el.r;
557
- while (child) {
558
- child.b |= 32 /* Zombie */;
559
- const inHeap = child.b & 8 /* InHeap */;
560
- if (inHeap) {
561
- deleteFromHeap(child, dirtyQueue);
562
- insertIntoHeap(child, zombieQueue);
476
+ function markDisposal(e) {
477
+ let t = e.re;
478
+ while (t) {
479
+ t.S |= o;
480
+ if (t.S & i) {
481
+ deleteFromHeap(t, _);
482
+ insertIntoHeap(t, S);
563
483
  }
564
- markDisposal(child);
565
- child = child.M;
484
+ markDisposal(t);
485
+ t = t.de;
566
486
  }
567
487
  }
568
- function dispose(node) {
569
- let toRemove = node.l || null;
488
+ function dispose(e) {
489
+ let t = e.W || null;
570
490
  do {
571
- toRemove = unlinkSubs(toRemove);
572
- } while (toRemove !== null);
573
- node.l = null;
574
- node.F = null;
575
- disposeChildren(node, true);
576
- }
577
- function disposeChildren(node, self = false, zombie) {
578
- if (node.b & 64 /* Disposed */)
579
- return;
580
- if (self)
581
- node.b = 64 /* Disposed */;
582
- let child = zombie ? node.U : node.r;
583
- while (child) {
584
- const nextChild = child.M;
585
- if (child.l) {
586
- const n = child;
587
- deleteFromHeap(n, n.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
588
- let toRemove = n.l;
491
+ t = unlinkSubs(t);
492
+ } while (t !== null);
493
+ e.W = null;
494
+ e.ie = null;
495
+ disposeChildren(e, true);
496
+ }
497
+ function disposeChildren(e, t = false, n) {
498
+ if (e.S & u) return;
499
+ if (t) e.S = u;
500
+ let r = n ? e.ee : e.re;
501
+ while (r) {
502
+ const e = r.de;
503
+ if (r.W) {
504
+ const e = r;
505
+ deleteFromHeap(e, e.S & o ? S : _);
506
+ let t = e.W;
589
507
  do {
590
- toRemove = unlinkSubs(toRemove);
591
- } while (toRemove !== null);
592
- n.l = null;
593
- n.F = null;
508
+ t = unlinkSubs(t);
509
+ } while (t !== null);
510
+ e.W = null;
511
+ e.ie = null;
594
512
  }
595
- disposeChildren(child, true);
596
- child = nextChild;
513
+ disposeChildren(r, true);
514
+ r = e;
597
515
  }
598
- if (zombie) {
599
- node.U = null;
516
+ if (n) {
517
+ e.ee = null;
600
518
  } else {
601
- node.r = null;
602
- node.M = null;
519
+ e.re = null;
520
+ e.de = null;
603
521
  }
604
- runDisposal(node, zombie);
522
+ runDisposal(e, n);
605
523
  }
606
- function runDisposal(node, zombie) {
607
- let disposal = zombie ? node.V : node.t;
608
- if (!disposal)
609
- return;
610
- if (Array.isArray(disposal)) {
611
- for (let i = 0; i < disposal.length; i++) {
612
- const callable = disposal[i];
613
- callable.call(callable);
524
+ function runDisposal(e, t) {
525
+ let n = t ? e.te : e.ne;
526
+ if (!n) return;
527
+ if (Array.isArray(n)) {
528
+ for (let e = 0; e < n.length; e++) {
529
+ const t = n[e];
530
+ t.call(t);
614
531
  }
615
532
  } else {
616
- disposal.call(disposal);
617
- }
618
- zombie ? node.V = null : node.t = null;
619
- }
620
- function withOptions(obj, options) {
621
- obj.id = (options == null ? void 0 : options.id) ?? ((context == null ? void 0 : context.id) != null ? getNextChildId(context) : void 0);
622
- obj.fa = (options == null ? void 0 : options.equals) != null ? options.equals : isEqual;
623
- obj.za = !!(options == null ? void 0 : options.pureWrite);
624
- obj.ta = options == null ? void 0 : options.unobserved;
625
- if (options == null ? void 0 : options.ka)
626
- Object.assign(obj, options.ka);
627
- return obj;
628
- }
629
- function getNextChildId(owner) {
630
- if (owner.id != null)
631
- return formatId(owner.id, owner.oa++);
632
- throw new Error("Cannot get child id from owner without an id");
533
+ n.call(n);
534
+ }
535
+ t ? (e.te = null) : (e.ne = null);
633
536
  }
634
- function formatId(prefix, id) {
635
- const num = id.toString(36), len = num.length - 1;
636
- return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
537
+ function getNextChildId(e) {
538
+ if (e.id != null) return formatId(e.id, e.he++);
539
+ throw new Error("Cannot get child id from owner without an id");
637
540
  }
638
- function computed(fn, initialValue, options) {
639
- const self = withOptions(
640
- {
641
- t: null,
642
- i: globalQueue,
643
- D: defaultContext,
644
- oa: 0,
645
- H: fn,
646
- g: initialValue,
647
- c: 0,
648
- ca: null,
649
- Q: void 0,
650
- z: null,
651
- l: null,
652
- F: null,
653
- x: null,
654
- W: null,
655
- w: context,
656
- M: null,
657
- r: null,
658
- b: 0 /* None */,
659
- f: 4 /* Uninitialized */,
660
- J: clock,
661
- e: NOT_PENDING,
662
- V: null,
663
- U: null
664
- },
665
- options
666
- );
667
- self.z = self;
668
- const parent = (context == null ? void 0 : context.$) ? context.aa : context;
669
- if (context) {
670
- context.i && (self.i = context.i);
671
- context.D && (self.D = context.D);
672
- const lastChild = context.r;
673
- if (lastChild === null) {
674
- context.r = self;
541
+ function formatId(e, t) {
542
+ const n = t.toString(36),
543
+ r = n.length - 1;
544
+ return e + (r ? String.fromCharCode(64 + r) : "") + n;
545
+ }
546
+ function computed(t, n, r) {
547
+ const i = {
548
+ id: r?.id ?? (E?.id != null ? getNextChildId(E) : undefined),
549
+ oe: r?.equals != null ? r.equals : isEqual,
550
+ pe: !!r?.pureWrite,
551
+ ae: r?.unobserved,
552
+ ne: null,
553
+ ye: E?.ye ?? O,
554
+ ge: E?.ge ?? g,
555
+ he: 0,
556
+ F: t,
557
+ G: n,
558
+ o: 0,
559
+ k: null,
560
+ p: undefined,
561
+ h: null,
562
+ W: null,
563
+ ie: null,
564
+ O: null,
565
+ ce: null,
566
+ i: E,
567
+ de: null,
568
+ re: null,
569
+ S: e,
570
+ $: a,
571
+ se: b,
572
+ K: p,
573
+ te: null,
574
+ ee: null
575
+ };
576
+ if (r?.we) Object.assign(i, r.we);
577
+ i.h = i;
578
+ const s = E?.t ? E.u : E;
579
+ if (E) {
580
+ const e = E.re;
581
+ if (e === null) {
582
+ E.re = i;
675
583
  } else {
676
- self.M = lastChild;
677
- context.r = self;
678
- }
679
- }
680
- if (parent)
681
- self.c = parent.c + 1;
682
- recompute(self, true);
683
- return self;
684
- }
685
- function asyncComputed(asyncFn, initialValue, options) {
686
- let lastResult = void 0;
687
- let refreshing = false;
688
- const fn = (prev) => {
689
- const result = asyncFn(prev, refreshing);
690
- refreshing = false;
691
- lastResult = result;
692
- const isPromise = result instanceof Promise;
693
- const iterator = result[Symbol.asyncIterator];
694
- if (!isPromise && !iterator) {
695
- return result;
696
- }
697
- if (isPromise) {
698
- result.then((v) => {
699
- if (lastResult !== result)
700
- return;
701
- globalQueue.initTransition(self);
702
- setSignal(self, () => v);
584
+ i.de = e;
585
+ E.re = i;
586
+ }
587
+ }
588
+ if (s) i.o = s.o + 1;
589
+ recompute(i, true);
590
+ return i;
591
+ }
592
+ function asyncComputed(e, t, n) {
593
+ let r = undefined;
594
+ let i = false;
595
+ const fn = t => {
596
+ const n = e(t, i);
597
+ i = false;
598
+ r = n;
599
+ const o = n instanceof Promise;
600
+ const u = n[Symbol.asyncIterator];
601
+ if (!o && !u) {
602
+ return n;
603
+ }
604
+ if (o) {
605
+ n.then(e => {
606
+ if (r !== n) return;
607
+ O.initTransition(s);
608
+ setSignal(s, () => e);
703
609
  flush();
704
- }).catch((e) => {
705
- if (lastResult !== result)
706
- return;
707
- globalQueue.initTransition(self);
708
- setError(self, e);
709
- self.J = clock;
710
- notifySubs(self);
610
+ }).catch(e => {
611
+ if (r !== n) return;
612
+ O.initTransition(s);
613
+ setStatusFlags(s, c, e);
614
+ s.se = b;
615
+ notifySubs(s);
711
616
  schedule();
712
617
  flush();
713
618
  });
714
619
  } else {
715
620
  (async () => {
716
621
  try {
717
- for await (let value of result) {
718
- if (lastResult !== result)
719
- return;
720
- globalQueue.initTransition(self);
721
- setSignal(self, () => value);
622
+ for await (let e of n) {
623
+ if (r !== n) return;
624
+ O.initTransition(s);
625
+ setSignal(s, () => e);
722
626
  flush();
723
627
  }
724
- } catch (error) {
725
- if (lastResult !== result)
726
- return;
727
- globalQueue.initTransition(self);
728
- setError(self, error);
729
- self.J = clock;
730
- notifySubs(self);
628
+ } catch (e) {
629
+ if (r !== n) return;
630
+ O.initTransition(s);
631
+ setStatusFlags(s, c, e);
632
+ s.se = b;
633
+ notifySubs(s);
731
634
  schedule();
732
635
  flush();
733
636
  }
734
637
  })();
735
638
  }
736
- globalQueue.initTransition(context);
737
- throw new NotReadyError(context);
639
+ O.initTransition(E);
640
+ throw new NotReadyError(E);
738
641
  };
739
- const self = computed(fn, initialValue, options);
740
- self.ua = () => {
741
- refreshing = true;
742
- recompute(self);
642
+ const s = computed(fn, t, n);
643
+ s._e = () => {
644
+ i = true;
645
+ recompute(s);
646
+ schedule();
743
647
  flush();
744
648
  };
745
- return self;
746
- }
747
- function signal(v, options, firewall = null) {
748
- if (firewall !== null) {
749
- return firewall.ca = withOptions(
750
- {
751
- g: v,
752
- x: null,
753
- W: null,
754
- ia: firewall,
755
- sa: firewall.ca,
756
- f: 0 /* None */,
757
- J: clock,
758
- e: NOT_PENDING
759
- },
760
- options
761
- );
762
- } else {
763
- return withOptions(
764
- {
765
- g: v,
766
- x: null,
767
- W: null,
768
- f: 0 /* None */,
769
- J: clock,
770
- e: NOT_PENDING
771
- },
772
- options
773
- );
774
- }
649
+ return s;
650
+ }
651
+ function signal(e, t, n = null) {
652
+ const r = {
653
+ id: t?.id ?? (E?.id != null ? getNextChildId(E) : undefined),
654
+ oe: t?.equals != null ? t.equals : isEqual,
655
+ pe: !!t?.pureWrite,
656
+ ae: t?.unobserved,
657
+ G: e,
658
+ O: null,
659
+ ce: null,
660
+ $: l,
661
+ se: b,
662
+ I: n,
663
+ j: n?.k || null,
664
+ K: p
665
+ };
666
+ n && (n.k = r);
667
+ return r;
775
668
  }
776
- function isEqual(a, b) {
777
- return a === b;
669
+ function isEqual(e, t) {
670
+ return e === t;
778
671
  }
779
- function untrack(fn) {
780
- if (!tracking)
781
- return fn();
782
- tracking = false;
672
+ function untrack(e) {
673
+ if (!C) return e();
674
+ C = false;
783
675
  try {
784
- return fn();
676
+ return e();
785
677
  } finally {
786
- tracking = true;
787
- }
788
- }
789
- function read(el) {
790
- let c = context;
791
- if (c == null ? void 0 : c.$)
792
- c = c.aa;
793
- if (c && tracking) {
794
- link(el, c);
795
- const owner = el.ia || el;
796
- if (owner.H) {
797
- const isZombie = el.b & 32 /* Zombie */;
798
- if (owner.c >= (isZombie ? zombieQueue.q : dirtyQueue.q)) {
799
- markNode(c);
800
- markHeap(isZombie ? zombieQueue : dirtyQueue);
801
- updateIfNecessary(owner);
678
+ C = true;
679
+ }
680
+ }
681
+ function read(e) {
682
+ let t = E;
683
+ if (t?.t) t = t.u;
684
+ if (t && C && !k && !N) {
685
+ link(e, t);
686
+ const n = e.I || e;
687
+ if (n.F) {
688
+ const r = e.S & o;
689
+ if (n.o >= (r ? S.A : _.A)) {
690
+ markNode(t);
691
+ markHeap(r ? S : _);
692
+ updateIfNecessary(n);
802
693
  }
803
- const height = owner.c;
804
- if (height >= c.c && el.w !== c) {
805
- c.c = height + 1;
694
+ const i = n.o;
695
+ if (i >= t.o && e.i !== t) {
696
+ t.o = i + 1;
806
697
  }
807
698
  }
808
699
  }
809
- if (pendingCheck) {
810
- const pendingResult = (el.f & 1 /* Pending */) !== 0 || !!el.T || false;
811
- if (!el.I) {
812
- el.I = signal(pendingResult);
813
- el.I.ja = true;
814
- el.I.ea = (v) => setSignal(el.I, v);
700
+ if (k) {
701
+ if (!e.X) {
702
+ e.X = signal(false);
703
+ e.X.ue = true;
704
+ e.X.Y = t => setSignal(e.X, t);
815
705
  }
816
- const prev = pendingCheck;
817
- pendingCheck = null;
818
- read(el.I);
819
- pendingCheck = prev;
820
- prev.g = pendingResult || prev.g;
706
+ const t = k;
707
+ k = null;
708
+ t.G = read(e.X) || t.G;
709
+ k = t;
821
710
  }
822
- if (pendingValueCheck) {
823
- if (!el.C) {
824
- el.C = signal(
825
- el.e === NOT_PENDING ? el.g : el.e
826
- );
827
- el.C.ja = true;
828
- el.C.ea = (v) => queueMicrotask(() => queueMicrotask(() => setSignal(el.C, v)));
711
+ if (N) {
712
+ if (!e.Z) {
713
+ e.Z = signal(e.G);
714
+ e.Z.ue = true;
715
+ e.Z.Y = t => setSignal(e.Z, t);
829
716
  }
830
- pendingValueCheck = false;
717
+ N = false;
831
718
  try {
832
- return read(el.C);
719
+ return read(e.Z);
833
720
  } finally {
834
- pendingValueCheck = true;
721
+ N = true;
835
722
  }
836
723
  }
837
- if (el.f & 1 /* Pending */) {
838
- if (c && !stale || el.f & 4 /* Uninitialized */)
839
- throw el.B;
840
- else if (c && stale && !pendingCheck) {
841
- setStatusFlags(
842
- c,
843
- c.f | 1,
844
- el.B
845
- );
724
+ if (e.$ & f) {
725
+ if ((t && !v) || e.$ & a) throw e.L;
726
+ else if (t && v && !k) {
727
+ setStatusFlags(t, t.$ | 1, e.L);
846
728
  }
847
729
  }
848
- if (el.f & 2 /* Error */) {
849
- if (el.J < clock) {
850
- recompute(el, true);
851
- return read(el);
730
+ if (e.$ & c) {
731
+ if (e.se < b) {
732
+ recompute(e, true);
733
+ return read(e);
852
734
  } else {
853
- throw el.B;
735
+ throw e.L;
854
736
  }
855
737
  }
856
- return !c || el.e === NOT_PENDING || stale && !pendingCheck && el.T && activeTransition !== el.T ? el.g : el.e;
738
+ return !t || e.ue || e.K === p || (v && !k && e.J && m !== e.J) ? e.G : e.K;
857
739
  }
858
- function setSignal(el, v) {
859
- if (typeof v === "function") {
860
- v = v(
861
- el.e === NOT_PENDING ? el.g : el.e
862
- );
740
+ function setSignal(e, t) {
741
+ if (typeof t === "function") {
742
+ t = t(e.K === p ? e.G : e.K);
863
743
  }
864
- const valueChanged = !el.fa || !el.fa(el.e === NOT_PENDING ? el.g : el.e, v);
865
- if (!valueChanged && !el.f)
866
- return v;
867
- if (valueChanged) {
868
- if (el.ja)
869
- el.g = v;
744
+ const n = !e.oe || !e.oe(e.K === p || e.ue ? e.G : e.K, t);
745
+ if (!n && !e.$) return t;
746
+ if (n) {
747
+ if (e.ue) e.G = t;
870
748
  else {
871
- if (el.e === NOT_PENDING)
872
- globalQueue.h.push(el);
873
- el.e = v;
749
+ if (e.K === p) O.M.push(e);
750
+ e.K = t;
874
751
  }
875
- if (el.C)
876
- el.C.ea(v);
752
+ if (e.Z) e.Z.K = t;
877
753
  }
878
- clearStatusFlags(el);
879
- el.J = clock;
880
- notifySubs(el);
754
+ setStatusFlags(e, l);
755
+ e.se = b;
756
+ notifySubs(e);
881
757
  schedule();
882
- return v;
758
+ return t;
883
759
  }
884
760
  function getObserver() {
885
- return tracking ? context : null;
761
+ return C ? E : null;
886
762
  }
887
763
  function getOwner() {
888
- return context;
889
- }
890
- function onCleanup(fn) {
891
- if (!context)
892
- return fn;
893
- const node = context;
894
- if (!node.t) {
895
- node.t = fn;
896
- } else if (Array.isArray(node.t)) {
897
- node.t.push(fn);
764
+ return E;
765
+ }
766
+ function onCleanup(e) {
767
+ if (!E) return e;
768
+ const t = E;
769
+ if (!t.ne) {
770
+ t.ne = e;
771
+ } else if (Array.isArray(t.ne)) {
772
+ t.ne.push(e);
898
773
  } else {
899
- node.t = [node.t, fn];
900
- }
901
- return fn;
902
- }
903
- function createOwner(options) {
904
- const parent = context;
905
- const owner = {
906
- $: true,
907
- aa: (parent == null ? void 0 : parent.$) ? parent.aa : parent,
908
- r: null,
909
- M: null,
910
- t: null,
911
- id: (options == null ? void 0 : options.id) ?? ((parent == null ? void 0 : parent.id) != null ? getNextChildId(parent) : void 0),
912
- i: (parent == null ? void 0 : parent.i) ?? globalQueue,
913
- D: (parent == null ? void 0 : parent.D) || defaultContext,
914
- oa: 0,
915
- V: null,
916
- U: null,
917
- w: parent,
918
- dispose(self = true) {
919
- disposeChildren(owner, self);
774
+ t.ne = [t.ne, e];
775
+ }
776
+ return e;
777
+ }
778
+ function createOwner(e) {
779
+ const t = E;
780
+ const n = {
781
+ t: true,
782
+ u: t?.t ? t.u : t,
783
+ re: null,
784
+ de: null,
785
+ ne: null,
786
+ id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
787
+ ye: t?.ye ?? O,
788
+ ge: t?.ge || g,
789
+ he: 0,
790
+ te: null,
791
+ ee: null,
792
+ i: t,
793
+ dispose(e = true) {
794
+ disposeChildren(n, e);
920
795
  }
921
796
  };
922
- if (parent) {
923
- const lastChild = parent.r;
924
- if (lastChild === null) {
925
- parent.r = owner;
797
+ if (t) {
798
+ const e = t.re;
799
+ if (e === null) {
800
+ t.re = n;
926
801
  } else {
927
- owner.M = lastChild;
928
- parent.r = owner;
802
+ n.de = e;
803
+ t.re = n;
929
804
  }
930
805
  }
931
- return owner;
806
+ return n;
932
807
  }
933
- function createRoot(init, options) {
934
- const owner = createOwner(options);
935
- return runWithOwner(owner, () => init(owner.dispose));
808
+ function createRoot(e, t) {
809
+ const n = createOwner(t);
810
+ return runWithOwner(n, () => e(n.dispose));
936
811
  }
937
- function runWithOwner(owner, fn) {
938
- const oldContext = context;
939
- context = owner;
812
+ function runWithOwner(e, t) {
813
+ const n = E;
814
+ E = e;
940
815
  try {
941
- return fn();
816
+ return t();
942
817
  } finally {
943
- context = oldContext;
818
+ E = n;
944
819
  }
945
820
  }
946
- function staleValues(fn, set = true) {
947
- const prevStale = stale;
948
- stale = set;
821
+ function staleValues(e, t = true) {
822
+ const n = v;
823
+ v = t;
949
824
  try {
950
- return fn();
825
+ return e();
951
826
  } finally {
952
- stale = prevStale;
827
+ v = n;
953
828
  }
954
829
  }
955
- function pending(fn) {
956
- const prevLatest = pendingValueCheck;
957
- pendingValueCheck = true;
830
+ function pending(e) {
831
+ const t = N;
832
+ N = true;
958
833
  try {
959
- return staleValues(fn, false);
834
+ return staleValues(e, false);
960
835
  } finally {
961
- pendingValueCheck = prevLatest;
836
+ N = t;
962
837
  }
963
838
  }
964
- function isPending(fn, loadingValue) {
965
- const current = pendingCheck;
966
- pendingCheck = { g: false };
839
+ function isPending(e, t) {
840
+ const n = k;
841
+ k = { G: false };
967
842
  try {
968
- staleValues(fn);
969
- return pendingCheck.g;
970
- } catch (err) {
971
- if (!(err instanceof NotReadyError))
972
- return false;
973
- if (loadingValue !== void 0)
974
- return loadingValue;
975
- throw err;
843
+ staleValues(e);
844
+ return k.G;
845
+ } catch (e) {
846
+ if (!(e instanceof NotReadyError)) return false;
847
+ if (t !== undefined) return t;
848
+ throw e;
976
849
  } finally {
977
- pendingCheck = current;
850
+ k = n;
978
851
  }
979
852
  }
980
-
981
- // src/core/context.ts
982
- function createContext(defaultValue, description) {
983
- return { id: Symbol(description), defaultValue };
853
+ function createContext(e, t) {
854
+ return { id: Symbol(t), defaultValue: e };
984
855
  }
985
- function getContext(context2, owner = getOwner()) {
986
- if (!owner) {
856
+ function getContext(e, t = getOwner()) {
857
+ if (!t) {
987
858
  throw new NoOwnerError();
988
859
  }
989
- const value = hasContext(context2, owner) ? owner.D[context2.id] : context2.defaultValue;
990
- if (isUndefined(value)) {
860
+ const n = hasContext(e, t) ? t.ge[e.id] : e.defaultValue;
861
+ if (isUndefined(n)) {
991
862
  throw new ContextNotFoundError();
992
863
  }
993
- return value;
864
+ return n;
994
865
  }
995
- function setContext(context2, value, owner = getOwner()) {
996
- if (!owner) {
866
+ function setContext(e, t, n = getOwner()) {
867
+ if (!n) {
997
868
  throw new NoOwnerError();
998
869
  }
999
- owner.D = {
1000
- ...owner.D,
1001
- [context2.id]: isUndefined(value) ? context2.defaultValue : value
1002
- };
1003
- }
1004
- function hasContext(context2, owner) {
1005
- return !isUndefined(owner == null ? void 0 : owner.D[context2.id]);
1006
- }
1007
- function isUndefined(value) {
1008
- return typeof value === "undefined";
1009
- }
1010
-
1011
- // src/core/effect.ts
1012
- function effect(compute, effect2, error, initialValue, options) {
1013
- var _a;
1014
- let initialized = false;
1015
- const node = computed(compute, initialValue, {
1016
- ...options,
1017
- ka: {
1018
- ga: true,
1019
- pa: initialValue,
1020
- va: effect2,
1021
- qa: error,
1022
- N: void 0,
1023
- i: ((_a = getOwner()) == null ? void 0 : _a.i) ?? globalQueue,
1024
- K: (options == null ? void 0 : options.render) ? 1 /* Render */ : 2 /* User */,
1025
- ma(statusFlagsChanged, prevStatusFlags) {
1026
- if (initialized) {
1027
- const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
1028
- this.ga = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
1029
- if (this.ga)
1030
- this.i.enqueue(this.K, runEffect.bind(this));
870
+ n.ge = { ...n.ge, [e.id]: isUndefined(t) ? e.defaultValue : t };
871
+ }
872
+ function hasContext(e, t) {
873
+ return !isUndefined(t?.ge[e.id]);
874
+ }
875
+ function isUndefined(e) {
876
+ return typeof e === "undefined";
877
+ }
878
+ function effect(e, t, n, r, i) {
879
+ let s = false;
880
+ const o = computed(e, r, {
881
+ ...i,
882
+ we: {
883
+ U: true,
884
+ Se: r,
885
+ be: t,
886
+ me: n,
887
+ xe: undefined,
888
+ T: i?.render ? d : h,
889
+ le(e, t) {
890
+ if (s) {
891
+ const n = this.$ && this.$ === t && e;
892
+ this.U = !(this.$ & c) && !(this.$ & f & ~t) && !n;
893
+ if (this.U) this.ye.enqueue(this.T, runEffect.bind(this));
1031
894
  }
1032
- if (this.f & 2 /* Error */) {
1033
- let error2 = this.B;
1034
- this.i.notify(this, 1 /* Pending */, 0);
1035
- if (this.K === 2 /* User */) {
895
+ if (this.$ & c) {
896
+ let e = this.L;
897
+ this.ye.notify(this, f, 0);
898
+ if (this.T === h) {
1036
899
  try {
1037
- return this.qa ? this.qa(error2, () => {
1038
- var _a2;
1039
- (_a2 = this.N) == null ? void 0 : _a2.call(this);
1040
- this.N = void 0;
1041
- }) : console.error(error2);
1042
- } catch (e) {
1043
- error2 = e;
900
+ return this.me
901
+ ? this.me(e, () => {
902
+ this.xe?.();
903
+ this.xe = undefined;
904
+ })
905
+ : console.error(e);
906
+ } catch (t) {
907
+ e = t;
1044
908
  }
1045
909
  }
1046
- if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
1047
- throw error2;
1048
- } else if (this.K === 1 /* Render */) {
1049
- this.i.notify(
1050
- this,
1051
- 1 /* Pending */ | 2 /* Error */,
1052
- this.f
1053
- );
910
+ if (!this.ye.notify(this, c, c)) throw e;
911
+ } else if (this.T === d) {
912
+ this.ye.notify(this, f | c, this.$);
1054
913
  }
1055
914
  }
1056
915
  }
1057
916
  });
1058
- initialized = true;
1059
- if (node.K === 1 /* Render */)
1060
- node.H = (p) => staleValues(() => compute(p));
1061
- !(options == null ? void 0 : options.defer) && !(node.f & (2 /* Error */ | 1 /* Pending */)) && (node.K === 2 /* User */ ? node.i.enqueue(node.K, runEffect.bind(node)) : runEffect.call(node));
1062
- onCleanup(() => {
1063
- var _a2;
1064
- return (_a2 = node.N) == null ? void 0 : _a2.call(node);
1065
- });
917
+ s = true;
918
+ if (o.T === d) o.F = t => staleValues(() => e(t));
919
+ !i?.defer &&
920
+ !(o.$ & (c | f)) &&
921
+ (o.T === h ? o.ye.enqueue(o.T, runEffect.bind(o)) : runEffect.call(o));
922
+ onCleanup(() => o.xe?.());
1066
923
  }
1067
924
  function runEffect() {
1068
- var _a;
1069
- if (!this.ga || this.b & 64 /* Disposed */)
1070
- return;
1071
- (_a = this.N) == null ? void 0 : _a.call(this);
1072
- this.N = void 0;
925
+ if (!this.U || this.S & u) return;
926
+ this.xe?.();
927
+ this.xe = undefined;
1073
928
  try {
1074
- this.N = this.va(this.g, this.pa);
1075
- } catch (error) {
1076
- if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
1077
- throw error;
929
+ this.xe = this.be(this.G, this.Se);
930
+ } catch (e) {
931
+ if (!this.ye.notify(this, c, c)) throw e;
1078
932
  } finally {
1079
- this.pa = this.g;
1080
- this.ga = false;
1081
- }
1082
- }
1083
-
1084
- // src/signals.ts
1085
- function createSignal(first, second, third) {
1086
- if (typeof first === "function") {
1087
- const node2 = computed(first, second, third);
1088
- return [
1089
- read.bind(null, node2),
1090
- setSignal.bind(null, node2)
1091
- ];
1092
- }
1093
- const o = getOwner();
1094
- const needsId = (o == null ? void 0 : o.id) != null;
1095
- const node = signal(
1096
- first,
1097
- needsId ? { id: getNextChildId(o), ...second } : second
1098
- );
1099
- return [
1100
- read.bind(null, node),
1101
- setSignal.bind(null, node)
1102
- ];
1103
- }
1104
- function createMemo(compute, value, options) {
1105
- let node = computed(compute, value, options);
1106
- return read.bind(null, node);
1107
- }
1108
- function createAsync(compute, value, options) {
1109
- const node = asyncComputed(compute, value, options);
1110
- const ret = read.bind(null, node);
1111
- ret.refresh = node.ua;
1112
- return ret;
1113
- }
1114
- function createEffect(compute, effectFn, value, options) {
1115
- void effect(
1116
- compute,
1117
- effectFn.effect || effectFn,
1118
- effectFn.error,
1119
- value,
1120
- options
1121
- );
1122
- }
1123
- function createRenderEffect(compute, effectFn, value, options) {
1124
- void effect(compute, effectFn, void 0, value, {
1125
- render: true,
1126
- ...options
1127
- });
1128
- }
1129
- function createTrackedEffect(compute, options) {
1130
- }
1131
- function createReaction(effectFn, options) {
1132
- let cleanup = void 0;
1133
- onCleanup(() => cleanup == null ? void 0 : cleanup());
1134
- return (tracking2) => {
1135
- effect(
1136
- () => (tracking2(), getOwner()),
1137
- (node) => {
1138
- var _a;
1139
- cleanup == null ? void 0 : cleanup();
1140
- cleanup = (_a = effectFn.effect || effectFn) == null ? void 0 : _a();
1141
- dispose(node);
1142
- },
1143
- effectFn.error,
1144
- void 0,
1145
- {
1146
- defer: true,
1147
- ...options
1148
- }
1149
- );
933
+ this.Se = this.G;
934
+ this.U = false;
935
+ }
936
+ }
937
+ function createSignal(e, t, n) {
938
+ if (typeof e === "function") {
939
+ const r = computed(e, t, n);
940
+ return [read.bind(null, r), setSignal.bind(null, r)];
941
+ }
942
+ const r = getOwner();
943
+ const i = r?.id != null;
944
+ const s = signal(e, i ? { id: getNextChildId(r), ...t } : t);
945
+ return [read.bind(null, s), setSignal.bind(null, s)];
946
+ }
947
+ function createMemo(e, t, n) {
948
+ let r = computed(e, t, n);
949
+ return read.bind(null, r);
950
+ }
951
+ function createAsync(e, t, n) {
952
+ const r = asyncComputed(e, t, n);
953
+ const i = read.bind(null, r);
954
+ i.refresh = r._e;
955
+ return i;
956
+ }
957
+ function createEffect(e, t, n, r) {
958
+ void effect(e, t.effect || t, t.error, n, r);
959
+ }
960
+ function createRenderEffect(e, t, n, r) {
961
+ void effect(e, t, undefined, n, { render: true, ...r });
962
+ }
963
+ function createTrackedEffect(e, t) {}
964
+ function createReaction(e, t) {
965
+ let n = undefined;
966
+ onCleanup(() => n?.());
967
+ const r = getOwner();
968
+ return i => {
969
+ runWithOwner(r, () => {
970
+ effect(
971
+ () => (i(), getOwner()),
972
+ t => {
973
+ n?.();
974
+ n = (e.effect || e)?.();
975
+ dispose(t);
976
+ },
977
+ e.error,
978
+ undefined,
979
+ { defer: true, ...(false ? { ...t, name: t?.name ?? "effect" } : t) }
980
+ );
981
+ });
1150
982
  };
1151
983
  }
1152
- function resolve(fn) {
1153
- return new Promise((res, rej) => {
1154
- createRoot((dispose2) => {
984
+ function resolve(e) {
985
+ return new Promise((t, n) => {
986
+ createRoot(r => {
1155
987
  computed(() => {
1156
988
  try {
1157
- res(fn());
1158
- } catch (err) {
1159
- if (err instanceof NotReadyError)
1160
- throw err;
1161
- rej(err);
989
+ t(e());
990
+ } catch (e) {
991
+ if (e instanceof NotReadyError) throw e;
992
+ n(e);
1162
993
  }
1163
- dispose2();
994
+ r();
1164
995
  });
1165
996
  });
1166
997
  });
1167
998
  }
1168
- function createOptimistic(first, second, third) {
999
+ function createOptimistic(e, t, n) {
1169
1000
  return {};
1170
1001
  }
1171
- function onSettled(callback) {
1172
- let cleanup;
1173
- const o = getOwner();
1174
- if (o)
1175
- onCleanup(() => cleanup == null ? void 0 : cleanup());
1176
- globalQueue.enqueue(2 /* User */, () => {
1177
- cleanup = callback();
1178
- !o && (cleanup == null ? void 0 : cleanup());
1002
+ function onSettled(e) {
1003
+ let t;
1004
+ const n = getOwner();
1005
+ if (n) onCleanup(() => t?.());
1006
+ O.enqueue(h, () => {
1007
+ t = e();
1008
+ !n && t?.();
1179
1009
  });
1180
1010
  }
1181
-
1182
- // src/store/reconcile.ts
1183
- function unwrap(value) {
1184
- var _a;
1185
- return ((_a = value == null ? void 0 : value[$TARGET]) == null ? void 0 : _a[STORE_NODE]) ?? value;
1186
- }
1187
- function getOverrideValue(value, override, nodes, key) {
1188
- return nodes && key in nodes ? read(nodes[key]) : override && key in override ? override[key] : value[key];
1189
- }
1190
- function getAllKeys(value, override, next) {
1191
- const keys = getKeys(value, override);
1192
- const nextKeys = Object.keys(next);
1193
- return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
1194
- }
1195
- function applyState(next, state, keyFn, all) {
1196
- const target = state == null ? void 0 : state[$TARGET];
1197
- if (!target)
1198
- return;
1199
- const previous = target[STORE_VALUE];
1200
- const override = target[STORE_OVERRIDE];
1201
- let nodes = target[STORE_NODE];
1202
- if (next === previous && !override)
1203
- return;
1204
- (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
1205
- target[STORE_VALUE] = next;
1206
- target[STORE_OVERRIDE] = void 0;
1207
- if (Array.isArray(previous)) {
1208
- let changed = false;
1209
- const prevLength = getOverrideValue(previous, override, nodes, "length");
1210
- if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
1211
- let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
1212
- for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, nodes, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
1213
- applyState(next[start], wrap(item, target), keyFn, all);
1011
+ function unwrap(e) {
1012
+ return e?.[W]?.[R] ?? e;
1013
+ }
1014
+ function getOverrideValue(e, t, n, r) {
1015
+ return n && r in n ? read(n[r]) : t && r in t ? t[r] : e[r];
1016
+ }
1017
+ function getAllKeys(e, t, n) {
1018
+ const r = getKeys(e, t);
1019
+ const i = Object.keys(n);
1020
+ return Array.from(new Set([...r, ...i]));
1021
+ }
1022
+ function applyState(e, t, n, r) {
1023
+ const i = t?.[W];
1024
+ if (!i) return;
1025
+ const s = i[F];
1026
+ const o = i[Q];
1027
+ let u = i[R];
1028
+ if (e === s && !o) return;
1029
+ (i[M] || B).set(e, i[P]);
1030
+ i[F] = e;
1031
+ i[Q] = undefined;
1032
+ if (Array.isArray(s)) {
1033
+ let t = false;
1034
+ const l = getOverrideValue(s, o, u, "length");
1035
+ if (e.length && l && e[0] && n(e[0]) != null) {
1036
+ let f, c, a, d, h, p, y, g;
1037
+ for (
1038
+ a = 0, d = Math.min(l, e.length);
1039
+ a < d && ((p = getOverrideValue(s, o, u, a)) === e[a] || (p && e[a] && n(p) === n(e[a])));
1040
+ a++
1041
+ ) {
1042
+ applyState(e[a], wrap(p, i), n, r);
1214
1043
  }
1215
- const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
1216
- for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, nodes, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
1217
- temp[newEnd] = item;
1044
+ const w = new Array(e.length),
1045
+ _ = new Map();
1046
+ for (
1047
+ d = l - 1, h = e.length - 1;
1048
+ d >= a &&
1049
+ h >= a &&
1050
+ ((p = getOverrideValue(s, o, u, d)) === e[h] || (p && e[h] && n(p) === n(e[h])));
1051
+ d--, h--
1052
+ ) {
1053
+ w[h] = p;
1218
1054
  }
1219
- if (start > newEnd || start > end) {
1220
- for (j = start; j <= newEnd; j++) {
1221
- changed = true;
1222
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
1055
+ if (a > h || a > d) {
1056
+ for (c = a; c <= h; c++) {
1057
+ t = true;
1058
+ i[R][c] && setSignal(i[R][c], wrap(e[c], i));
1223
1059
  }
1224
- for (; j < next.length; j++) {
1225
- changed = true;
1226
- const wrapped = wrap(temp[j], target);
1227
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
1228
- applyState(next[j], wrapped, keyFn, all);
1060
+ for (; c < e.length; c++) {
1061
+ t = true;
1062
+ const s = wrap(w[c], i);
1063
+ i[R][c] && setSignal(i[R][c], s);
1064
+ applyState(e[c], s, n, r);
1229
1065
  }
1230
- changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
1231
- prevLength !== next.length && target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
1066
+ t && i[R][j] && setSignal(i[R][j], void 0);
1067
+ l !== e.length && i[R].length && setSignal(i[R].length, e.length);
1232
1068
  return;
1233
1069
  }
1234
- newIndicesNext = new Array(newEnd + 1);
1235
- for (j = newEnd; j >= start; j--) {
1236
- item = next[j];
1237
- keyVal = item ? keyFn(item) : item;
1238
- i = newIndices.get(keyVal);
1239
- newIndicesNext[j] = i === void 0 ? -1 : i;
1240
- newIndices.set(keyVal, j);
1070
+ y = new Array(h + 1);
1071
+ for (c = h; c >= a; c--) {
1072
+ p = e[c];
1073
+ g = p ? n(p) : p;
1074
+ f = _.get(g);
1075
+ y[c] = f === undefined ? -1 : f;
1076
+ _.set(g, c);
1241
1077
  }
1242
- for (i = start; i <= end; i++) {
1243
- item = getOverrideValue(previous, override, nodes, i);
1244
- keyVal = item ? keyFn(item) : item;
1245
- j = newIndices.get(keyVal);
1246
- if (j !== void 0 && j !== -1) {
1247
- temp[j] = item;
1248
- j = newIndicesNext[j];
1249
- newIndices.set(keyVal, j);
1078
+ for (f = a; f <= d; f++) {
1079
+ p = getOverrideValue(s, o, u, f);
1080
+ g = p ? n(p) : p;
1081
+ c = _.get(g);
1082
+ if (c !== undefined && c !== -1) {
1083
+ w[c] = p;
1084
+ c = y[c];
1085
+ _.set(g, c);
1250
1086
  }
1251
1087
  }
1252
- for (j = start; j < next.length; j++) {
1253
- if (j in temp) {
1254
- const wrapped = wrap(temp[j], target);
1255
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
1256
- applyState(next[j], wrapped, keyFn, all);
1257
- } else
1258
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
1088
+ for (c = a; c < e.length; c++) {
1089
+ if (c in w) {
1090
+ const t = wrap(w[c], i);
1091
+ i[R][c] && setSignal(i[R][c], t);
1092
+ applyState(e[c], t, n, r);
1093
+ } else i[R][c] && setSignal(i[R][c], wrap(e[c], i));
1259
1094
  }
1260
- if (start < next.length)
1261
- changed = true;
1262
- } else if (prevLength && next.length) {
1263
- for (let i = 0, len = next.length; i < len; i++) {
1264
- const item = getOverrideValue(previous, override, nodes, i);
1265
- isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
1095
+ if (a < e.length) t = true;
1096
+ } else if (l && e.length) {
1097
+ for (let t = 0, l = e.length; t < l; t++) {
1098
+ const l = getOverrideValue(s, o, u, t);
1099
+ isWrappable(l) && applyState(e[t], wrap(l, i), n, r);
1266
1100
  }
1267
1101
  }
1268
- if (prevLength !== next.length) {
1269
- changed = true;
1270
- target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
1102
+ if (l !== e.length) {
1103
+ t = true;
1104
+ i[R].length && setSignal(i[R].length, e.length);
1271
1105
  }
1272
- changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
1106
+ t && i[R][j] && setSignal(i[R][j], void 0);
1273
1107
  return;
1274
1108
  }
1275
- if (nodes) {
1276
- const tracked = nodes[$TRACK];
1277
- const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
1278
- for (let i = 0, len = keys.length; i < len; i++) {
1279
- const key = keys[i];
1280
- const node = nodes[key];
1281
- const previousValue = unwrap(getOverrideValue(previous, override, nodes, key));
1282
- let nextValue = unwrap(next[key]);
1283
- if (previousValue === nextValue)
1284
- continue;
1285
- if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
1286
- tracked && setSignal(tracked, void 0);
1287
- node && setSignal(node, isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
1288
- } else
1289
- applyState(nextValue, wrap(previousValue, target), keyFn, all);
1290
- }
1291
- }
1292
- if (nodes = target[STORE_HAS]) {
1293
- const keys = Object.keys(nodes);
1294
- for (let i = 0, len = keys.length; i < len; i++) {
1295
- const key = keys[i];
1296
- setSignal(nodes[key], key in next);
1297
- }
1298
- }
1299
- }
1300
- function reconcile(value, key, all = false) {
1301
- return (state) => {
1302
- if (state == null)
1303
- throw new Error("Cannot reconcile null or undefined state");
1304
- const keyFn = typeof key === "string" ? (item) => item[key] : key;
1305
- const eq = keyFn(state);
1306
- if (eq !== void 0 && keyFn(value) !== keyFn(state))
1109
+ if (u) {
1110
+ const t = u[j];
1111
+ const l = t || r ? getAllKeys(s, o, e) : Object.keys(u);
1112
+ for (let f = 0, c = l.length; f < c; f++) {
1113
+ const c = l[f];
1114
+ const a = u[c];
1115
+ const d = unwrap(getOverrideValue(s, o, u, c));
1116
+ let h = unwrap(e[c]);
1117
+ if (d === h) continue;
1118
+ if (!d || !isWrappable(d) || (n(d) != null && n(d) !== n(h))) {
1119
+ t && setSignal(t, void 0);
1120
+ a && setSignal(a, isWrappable(h) ? wrap(h, i) : h);
1121
+ } else applyState(h, wrap(d, i), n, r);
1122
+ }
1123
+ }
1124
+ if ((u = i[V])) {
1125
+ const t = Object.keys(u);
1126
+ for (let n = 0, r = t.length; n < r; n++) {
1127
+ const r = t[n];
1128
+ setSignal(u[r], r in e);
1129
+ }
1130
+ }
1131
+ }
1132
+ function reconcile(e, t, n = false) {
1133
+ return r => {
1134
+ if (r == null) throw new Error("Cannot reconcile null or undefined state");
1135
+ const i = typeof t === "string" ? e => e[t] : t;
1136
+ const s = i(r);
1137
+ if (s !== undefined && i(e) !== i(r))
1307
1138
  throw new Error("Cannot reconcile states with different identity");
1308
- applyState(value, state, keyFn, all);
1139
+ applyState(e, r, i, n);
1309
1140
  };
1310
1141
  }
1311
-
1312
- // src/store/projection.ts
1313
- function createProjectionInternal(fn, initialValue = {}, options) {
1314
- let node;
1315
- const wrappedMap = /* @__PURE__ */ new WeakMap();
1316
- const wrapProjection = (source) => {
1317
- var _a;
1318
- if (wrappedMap.has(source))
1319
- return wrappedMap.get(source);
1320
- if (((_a = source[$TARGET]) == null ? void 0 : _a[STORE_WRAP]) === wrapProjection)
1321
- return source;
1322
- const wrapped = createStoreProxy(source, storeTraps, {
1323
- [STORE_WRAP]: wrapProjection,
1324
- [STORE_LOOKUP]: wrappedMap,
1325
- [STORE_FIREWALL]() {
1326
- return node;
1142
+ function createProjectionInternal(e, t = {}, n) {
1143
+ let r;
1144
+ const i = new WeakMap();
1145
+ const wrapProjection = e => {
1146
+ if (i.has(e)) return i.get(e);
1147
+ if (e[W]?.[q] === wrapProjection) return e;
1148
+ const t = createStoreProxy(e, G, {
1149
+ [q]: wrapProjection,
1150
+ [M]: i,
1151
+ [D]() {
1152
+ return r;
1327
1153
  }
1328
1154
  });
1329
- wrappedMap.set(source, wrapped);
1330
- return wrapped;
1155
+ i.set(e, t);
1156
+ return t;
1331
1157
  };
1332
- const wrappedStore = wrapProjection(initialValue);
1333
- node = computed(() => {
1334
- storeSetter(wrappedStore, (s) => {
1335
- const value = fn(s);
1336
- if (value !== s && value !== void 0) {
1337
- reconcile(value, (options == null ? void 0 : options.key) || "id", options == null ? void 0 : options.all)(s);
1158
+ const s = wrapProjection(t);
1159
+ r = computed(() => {
1160
+ storeSetter(s, t => {
1161
+ const r = e(t);
1162
+ if (r !== t && r !== undefined) {
1163
+ reconcile(r, n?.key || "id", n?.all)(t);
1338
1164
  }
1339
1165
  });
1340
1166
  });
1341
- return { store: wrappedStore, node };
1342
- }
1343
- function createProjection(fn, initialValue = {}, options) {
1344
- return createProjectionInternal(fn, initialValue, options).store;
1345
- }
1346
-
1347
- // src/store/store.ts
1348
- var $TRACK = Symbol(0);
1349
- var $DEEP = Symbol(0);
1350
- var $TARGET = Symbol(0);
1351
- var $PROXY = Symbol(0);
1352
- var $DELETED = Symbol(0);
1353
- var PARENTS = /* @__PURE__ */ new WeakMap();
1354
- var STORE_VALUE = "v";
1355
- var STORE_OVERRIDE = "o";
1356
- var STORE_NODE = "n";
1357
- var STORE_HAS = "h";
1358
- var STORE_WRAP = "w";
1359
- var STORE_LOOKUP = "l";
1360
- var STORE_FIREWALL = "f";
1361
- function createStoreProxy(value, traps = storeTraps, extend) {
1362
- let newTarget;
1363
- if (Array.isArray(value)) {
1364
- newTarget = [];
1365
- newTarget.v = value;
1366
- } else
1367
- newTarget = { v: value };
1368
- extend && Object.assign(newTarget, extend);
1369
- return newTarget[$PROXY] = new Proxy(newTarget, traps);
1370
- }
1371
- var storeLookup = /* @__PURE__ */ new WeakMap();
1372
- function wrap(value, target) {
1373
- if (target == null ? void 0 : target[STORE_WRAP])
1374
- return target[STORE_WRAP](value, target);
1375
- let p = value[$PROXY] || storeLookup.get(value);
1376
- if (!p)
1377
- storeLookup.set(value, p = createStoreProxy(value));
1378
- return p;
1379
- }
1380
- function isWrappable(obj) {
1381
- return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
1382
- }
1383
- function getNodes(target, type) {
1384
- let nodes = target[type];
1385
- if (!nodes)
1386
- target[type] = nodes = /* @__PURE__ */ Object.create(null);
1387
- return nodes;
1388
- }
1389
- function getNode(nodes, property, value, firewall, equals = isEqual) {
1390
- if (nodes[property])
1391
- return nodes[property];
1392
- return nodes[property] = signal(
1393
- value,
1167
+ return { store: s, node: r };
1168
+ }
1169
+ function createProjection(e, t = {}, n) {
1170
+ return createProjectionInternal(e, t, n).store;
1171
+ }
1172
+ const j = Symbol(0),
1173
+ A = Symbol(0),
1174
+ W = Symbol(0),
1175
+ P = Symbol(0),
1176
+ H = Symbol(0);
1177
+ const I = new WeakMap();
1178
+ const F = "v",
1179
+ Q = "o",
1180
+ R = "n",
1181
+ V = "h",
1182
+ q = "w",
1183
+ M = "l",
1184
+ D = "f";
1185
+ function createStoreProxy(e, t = G, n) {
1186
+ let r;
1187
+ if (Array.isArray(e)) {
1188
+ r = [];
1189
+ r.v = e;
1190
+ } else r = { v: e };
1191
+ n && Object.assign(r, n);
1192
+ return (r[P] = new Proxy(r, t));
1193
+ }
1194
+ const B = new WeakMap();
1195
+ function wrap(e, t) {
1196
+ if (t?.[q]) return t[q](e, t);
1197
+ let n = e[P] || B.get(e);
1198
+ if (!n) B.set(e, (n = createStoreProxy(e)));
1199
+ return n;
1200
+ }
1201
+ function isWrappable(e) {
1202
+ return e != null && typeof e === "object" && !Object.isFrozen(e);
1203
+ }
1204
+ function getNodes(e, t) {
1205
+ let n = e[t];
1206
+ if (!n) e[t] = n = Object.create(null);
1207
+ return n;
1208
+ }
1209
+ function getNode(e, t, n, r, i = isEqual) {
1210
+ if (e[t]) return e[t];
1211
+ return (e[t] = signal(
1212
+ n,
1394
1213
  {
1395
- equals,
1214
+ equals: i,
1396
1215
  unobserved() {
1397
- delete nodes[property];
1216
+ delete e[t];
1398
1217
  }
1399
1218
  },
1400
- firewall
1401
- );
1402
- }
1403
- function trackSelf(target, symbol = $TRACK) {
1404
- var _a;
1405
- getObserver() && read(
1406
- getNode(getNodes(target, STORE_NODE), symbol, void 0, (_a = target[STORE_FIREWALL]) == null ? void 0 : _a.call(target), false)
1407
- );
1408
- }
1409
- function getKeys(source, override, enumerable = true) {
1410
- const baseKeys = untrack(() => enumerable ? Object.keys(source) : Reflect.ownKeys(source));
1411
- if (!override)
1412
- return baseKeys;
1413
- const keys = new Set(baseKeys);
1414
- const overrides = Reflect.ownKeys(override);
1415
- for (const key of overrides) {
1416
- if (override[key] !== $DELETED)
1417
- keys.add(key);
1418
- else
1419
- keys.delete(key);
1420
- }
1421
- return Array.from(keys);
1422
- }
1423
- function getPropertyDescriptor(source, override, property) {
1424
- let value = source;
1425
- if (override && property in override) {
1426
- if (value[property] === $DELETED)
1427
- return void 0;
1428
- if (!(property in value))
1429
- value = override;
1430
- }
1431
- return Reflect.getOwnPropertyDescriptor(value, property);
1432
- }
1433
- var Writing = null;
1434
- var storeTraps = {
1435
- get(target, property, receiver) {
1436
- var _a;
1437
- if (property === $TARGET)
1438
- return target;
1439
- if (property === $PROXY)
1440
- return receiver;
1441
- if (property === $TRACK || property === $DEEP) {
1442
- trackSelf(target, property);
1443
- return receiver;
1444
- }
1445
- const nodes = getNodes(target, STORE_NODE);
1446
- const tracked = nodes[property];
1447
- const overridden = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE];
1448
- const proxySource = !!target[STORE_VALUE][$TARGET];
1449
- const storeValue = overridden ? target[STORE_OVERRIDE] : target[STORE_VALUE];
1450
- if (!tracked) {
1451
- const desc = Object.getOwnPropertyDescriptor(storeValue, property);
1452
- if (desc && desc.get)
1453
- return desc.get.call(receiver);
1454
- }
1455
- if (Writing == null ? void 0 : Writing.has(receiver)) {
1456
- let value2 = tracked && (overridden || !proxySource) ? tracked.e !== NOT_PENDING ? tracked.e : tracked.g : storeValue[property];
1457
- value2 === $DELETED && (value2 = void 0);
1458
- if (!isWrappable(value2))
1459
- return value2;
1460
- const wrapped = wrap(value2, target);
1461
- Writing.add(wrapped);
1462
- return wrapped;
1463
- }
1464
- let value = tracked ? overridden || !proxySource ? read(nodes[property]) : (read(nodes[property]), storeValue[property]) : storeValue[property];
1465
- value === $DELETED && (value = void 0);
1466
- if (!tracked) {
1467
- if (!overridden && typeof value === "function" && !storeValue.hasOwnProperty(property)) {
1468
- let proto;
1469
- return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value;
1219
+ r
1220
+ ));
1221
+ }
1222
+ function trackSelf(e, t = j) {
1223
+ getObserver() && read(getNode(getNodes(e, R), t, undefined, e[D]?.(), false));
1224
+ }
1225
+ function getKeys(e, t, n = true) {
1226
+ const r = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
1227
+ if (!t) return r;
1228
+ const i = new Set(r);
1229
+ const s = Reflect.ownKeys(t);
1230
+ for (const e of s) {
1231
+ if (t[e] !== H) i.add(e);
1232
+ else i.delete(e);
1233
+ }
1234
+ return Array.from(i);
1235
+ }
1236
+ function getPropertyDescriptor(e, t, n) {
1237
+ let r = e;
1238
+ if (t && n in t) {
1239
+ if (r[n] === H) return void 0;
1240
+ if (!(n in r)) r = t;
1241
+ }
1242
+ return Reflect.getOwnPropertyDescriptor(r, n);
1243
+ }
1244
+ let K = null;
1245
+ const G = {
1246
+ get(e, t, n) {
1247
+ if (t === W) return e;
1248
+ if (t === P) return n;
1249
+ if (t === j || t === A) {
1250
+ trackSelf(e, t);
1251
+ return n;
1252
+ }
1253
+ const r = getNodes(e, R);
1254
+ const i = r[t];
1255
+ const s = e[Q] && t in e[Q];
1256
+ const o = !!e[F][W];
1257
+ const u = s ? e[Q] : e[F];
1258
+ if (!i) {
1259
+ const e = Object.getOwnPropertyDescriptor(u, t);
1260
+ if (e && e.get) return e.get.call(n);
1261
+ }
1262
+ if (K?.has(n)) {
1263
+ let n = i && (s || !o) ? (i.K !== p ? i.K : i.G) : u[t];
1264
+ n === H && (n = undefined);
1265
+ if (!isWrappable(n)) return n;
1266
+ const r = wrap(n, e);
1267
+ K.add(r);
1268
+ return r;
1269
+ }
1270
+ let l = i ? (s || !o ? read(r[t]) : (read(r[t]), u[t])) : u[t];
1271
+ l === H && (l = undefined);
1272
+ if (!i) {
1273
+ if (!s && typeof l === "function" && !u.hasOwnProperty(t)) {
1274
+ let t;
1275
+ return !Array.isArray(e[F]) && (t = Object.getPrototypeOf(e[F])) && t !== Object.prototype
1276
+ ? l.bind(u)
1277
+ : l;
1470
1278
  } else if (getObserver()) {
1471
- return read(
1472
- getNode(
1473
- nodes,
1474
- property,
1475
- isWrappable(value) ? wrap(value, target) : value,
1476
- (_a = target[STORE_FIREWALL]) == null ? void 0 : _a.call(target)
1477
- )
1478
- );
1279
+ return read(getNode(r, t, isWrappable(l) ? wrap(l, e) : l, e[D]?.()));
1479
1280
  }
1480
1281
  }
1481
- return isWrappable(value) ? wrap(value, target) : value;
1282
+ return isWrappable(l) ? wrap(l, e) : l;
1482
1283
  },
1483
- has(target, property) {
1484
- var _a;
1485
- if (property === $PROXY || property === $TRACK || property === "__proto__")
1486
- return true;
1487
- const has = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] !== $DELETED : property in target[STORE_VALUE];
1488
- getObserver() && read(getNode(getNodes(target, STORE_HAS), property, has, (_a = target[STORE_FIREWALL]) == null ? void 0 : _a.call(target)));
1489
- return has;
1284
+ has(e, t) {
1285
+ if (t === P || t === j || t === "__proto__") return true;
1286
+ const n = e[Q] && t in e[Q] ? e[Q][t] !== H : t in e[F];
1287
+ getObserver() && read(getNode(getNodes(e, V), t, n, e[D]?.()));
1288
+ return n;
1490
1289
  },
1491
- set(target, property, rawValue) {
1492
- const store = target[$PROXY];
1493
- if (Writing == null ? void 0 : Writing.has(target[$PROXY])) {
1290
+ set(e, t, n) {
1291
+ const r = e[P];
1292
+ if (K?.has(e[P])) {
1494
1293
  untrack(() => {
1495
- var _a, _b, _c;
1496
- const state = target[STORE_VALUE];
1497
- const base = state[property];
1498
- const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : base;
1499
- const value = ((_a = rawValue == null ? void 0 : rawValue[$TARGET]) == null ? void 0 : _a[STORE_VALUE]) ?? rawValue;
1500
- if (prev === value)
1501
- return true;
1502
- const len = ((_b = target[STORE_OVERRIDE]) == null ? void 0 : _b.length) || state.length;
1503
- if (value !== void 0 && value === base)
1504
- delete target[STORE_OVERRIDE][property];
1505
- else
1506
- (target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = value;
1507
- const wrappable = isWrappable(value);
1508
- if (isWrappable(prev)) {
1509
- const parents = PARENTS.get(prev);
1510
- parents && (parents instanceof Set ? parents.delete(store) : PARENTS.delete(prev));
1294
+ const i = e[F];
1295
+ const s = i[t];
1296
+ const o = e[Q] && t in e[Q] ? e[Q][t] : s;
1297
+ const u = n?.[W]?.[F] ?? n;
1298
+ if (o === u) return true;
1299
+ const l = e[Q]?.length || i.length;
1300
+ if (u !== undefined && u === s) delete e[Q][t];
1301
+ else (e[Q] || (e[Q] = Object.create(null)))[t] = u;
1302
+ const f = isWrappable(u);
1303
+ if (isWrappable(o)) {
1304
+ const e = I.get(o);
1305
+ e && (e instanceof Set ? e.delete(r) : I.delete(o));
1511
1306
  }
1512
- if (recursivelyNotify(store, storeLookup) && wrappable)
1513
- recursivelyAddParent(value, store);
1514
- ((_c = target[STORE_HAS]) == null ? void 0 : _c[property]) && setSignal(target[STORE_HAS][property], true);
1515
- const nodes = getNodes(target, STORE_NODE);
1516
- nodes[property] && setSignal(nodes[property], () => wrappable ? wrap(value, target) : value);
1517
- if (Array.isArray(state)) {
1518
- const index = parseInt(property) + 1;
1519
- if (index > len)
1520
- nodes.length && setSignal(nodes.length, index);
1307
+ if (recursivelyNotify(r, B) && f) recursivelyAddParent(u, r);
1308
+ e[V]?.[t] && setSignal(e[V][t], true);
1309
+ const c = getNodes(e, R);
1310
+ c[t] && setSignal(c[t], () => (f ? wrap(u, e) : u));
1311
+ if (Array.isArray(i)) {
1312
+ const e = parseInt(t) + 1;
1313
+ if (e > l) c.length && setSignal(c.length, e);
1521
1314
  }
1522
- nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
1315
+ c[j] && setSignal(c[j], undefined);
1523
1316
  });
1524
1317
  }
1525
1318
  return true;
1526
1319
  },
1527
- deleteProperty(target, property) {
1528
- var _a;
1529
- if ((Writing == null ? void 0 : Writing.has(target[$PROXY])) && ((_a = target[STORE_OVERRIDE]) == null ? void 0 : _a[property]) !== $DELETED) {
1320
+ deleteProperty(e, t) {
1321
+ if (K?.has(e[P]) && e[Q]?.[t] !== H) {
1530
1322
  untrack(() => {
1531
- var _a2;
1532
- const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : target[STORE_VALUE][property];
1533
- if (property in target[STORE_VALUE]) {
1534
- (target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = $DELETED;
1535
- } else if (target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]) {
1536
- delete target[STORE_OVERRIDE][property];
1537
- } else
1538
- return true;
1539
- if (isWrappable(prev)) {
1540
- const parents = PARENTS.get(prev);
1541
- parents && (parents instanceof Set ? parents.delete(target) : PARENTS.delete(prev));
1323
+ const n = e[Q] && t in e[Q] ? e[Q][t] : e[F][t];
1324
+ if (t in e[F]) {
1325
+ (e[Q] || (e[Q] = Object.create(null)))[t] = H;
1326
+ } else if (e[Q] && t in e[Q]) {
1327
+ delete e[Q][t];
1328
+ } else return true;
1329
+ if (isWrappable(n)) {
1330
+ const t = I.get(n);
1331
+ t && (t instanceof Set ? t.delete(e) : I.delete(n));
1542
1332
  }
1543
- if ((_a2 = target[STORE_HAS]) == null ? void 0 : _a2[property])
1544
- setSignal(target[STORE_HAS][property], false);
1545
- const nodes = getNodes(target, STORE_NODE);
1546
- nodes[property] && setSignal(nodes[property], void 0);
1547
- nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
1333
+ if (e[V]?.[t]) setSignal(e[V][t], false);
1334
+ const r = getNodes(e, R);
1335
+ r[t] && setSignal(r[t], undefined);
1336
+ r[j] && setSignal(r[j], undefined);
1548
1337
  });
1549
1338
  }
1550
1339
  return true;
1551
1340
  },
1552
- ownKeys(target) {
1553
- trackSelf(target);
1554
- return getKeys(target[STORE_VALUE], target[STORE_OVERRIDE], false);
1341
+ ownKeys(e) {
1342
+ trackSelf(e);
1343
+ return getKeys(e[F], e[Q], false);
1555
1344
  },
1556
- getOwnPropertyDescriptor(target, property) {
1557
- if (property === $PROXY)
1558
- return { value: target[$PROXY], writable: true, configurable: true };
1559
- return getPropertyDescriptor(target[STORE_VALUE], target[STORE_OVERRIDE], property);
1345
+ getOwnPropertyDescriptor(e, t) {
1346
+ if (t === P) return { value: e[P], writable: true, configurable: true };
1347
+ return getPropertyDescriptor(e[F], e[Q], t);
1560
1348
  },
1561
- getPrototypeOf(target) {
1562
- return Object.getPrototypeOf(target[STORE_VALUE]);
1349
+ getPrototypeOf(e) {
1350
+ return Object.getPrototypeOf(e[F]);
1563
1351
  }
1564
1352
  };
1565
- function storeSetter(store, fn) {
1566
- const prevWriting = Writing;
1567
- Writing = /* @__PURE__ */ new Set();
1568
- Writing.add(store);
1353
+ function storeSetter(e, t) {
1354
+ const n = K;
1355
+ K = new Set();
1356
+ K.add(e);
1569
1357
  try {
1570
- const value = fn(store);
1571
- if (value !== store && value !== void 0) {
1572
- if (Array.isArray(value)) {
1573
- for (let i = 0, len = value.length; i < len; i++)
1574
- store[i] = value[i];
1575
- store.length = value.length;
1358
+ const n = t(e);
1359
+ if (n !== e && n !== undefined) {
1360
+ if (Array.isArray(n)) {
1361
+ for (let t = 0, r = n.length; t < r; t++) e[t] = n[t];
1362
+ e.length = n.length;
1576
1363
  } else {
1577
- const keys = /* @__PURE__ */ new Set([...Object.keys(store), ...Object.keys(value)]);
1578
- keys.forEach((key) => {
1579
- if (key in value)
1580
- store[key] = value[key];
1581
- else
1582
- delete store[key];
1364
+ const t = new Set([...Object.keys(e), ...Object.keys(n)]);
1365
+ t.forEach(t => {
1366
+ if (t in n) e[t] = n[t];
1367
+ else delete e[t];
1583
1368
  });
1584
1369
  }
1585
1370
  }
1586
1371
  } finally {
1587
- Writing.clear();
1588
- Writing = prevWriting;
1589
- }
1590
- }
1591
- function createStore(first, second, options) {
1592
- const derived = typeof first === "function", wrappedStore = derived ? createProjectionInternal(first, second, options).store : wrap(first);
1593
- return [wrappedStore, (fn) => storeSetter(wrappedStore, fn)];
1594
- }
1595
- function recursivelyNotify(state, lookup) {
1596
- var _a;
1597
- let target = state[$TARGET] || ((_a = lookup == null ? void 0 : lookup.get(state)) == null ? void 0 : _a[$TARGET]);
1598
- let notified = false;
1599
- if (target) {
1600
- const deep2 = getNodes(target, STORE_NODE)[$DEEP];
1601
- if (deep2) {
1602
- setSignal(deep2, void 0);
1603
- notified = true;
1604
- }
1605
- lookup = target[STORE_LOOKUP] || lookup;
1606
- }
1607
- const parents = PARENTS.get((target == null ? void 0 : target[STORE_VALUE]) || state);
1608
- if (!parents)
1609
- return notified;
1610
- if (parents instanceof Set) {
1611
- for (let parent of parents)
1612
- notified = recursivelyNotify(parent, lookup) || notified;
1613
- } else
1614
- notified = recursivelyNotify(parents, lookup) || notified;
1615
- return notified;
1616
- }
1617
- function recursivelyAddParent(state, parent) {
1618
- let override;
1619
- const target = state[$TARGET];
1620
- if (target) {
1621
- override = target[STORE_OVERRIDE];
1622
- state = target[STORE_VALUE];
1623
- }
1624
- if (parent) {
1625
- let parents = PARENTS.get(state);
1626
- if (!parents)
1627
- PARENTS.set(state, parent);
1628
- else if (parents !== parent) {
1629
- if (!(parents instanceof Set))
1630
- PARENTS.set(state, parents = /* @__PURE__ */ new Set([parents]));
1631
- else if (parents.has(parent))
1632
- return;
1633
- parents.add(parent);
1634
- } else
1635
- return;
1636
- }
1637
- if (Array.isArray(state)) {
1638
- const len = (override == null ? void 0 : override.length) || state.length;
1639
- for (let i = 0; i < len; i++) {
1640
- const item = override && i in override ? override[i] : state[i];
1641
- isWrappable(item) && recursivelyAddParent(item, state);
1372
+ K.clear();
1373
+ K = n;
1374
+ }
1375
+ }
1376
+ function createStore(e, t, n) {
1377
+ const r = typeof e === "function",
1378
+ i = r ? createProjectionInternal(e, t, n).store : wrap(e);
1379
+ return [i, e => storeSetter(i, e)];
1380
+ }
1381
+ function recursivelyNotify(e, t) {
1382
+ let n = e[W] || t?.get(e)?.[W];
1383
+ let r = false;
1384
+ if (n) {
1385
+ const e = getNodes(n, R)[A];
1386
+ if (e) {
1387
+ setSignal(e, undefined);
1388
+ r = true;
1389
+ }
1390
+ t = n[M] || t;
1391
+ }
1392
+ const i = I.get(n?.[F] || e);
1393
+ if (!i) return r;
1394
+ if (i instanceof Set) {
1395
+ for (let e of i) r = recursivelyNotify(e, t) || r;
1396
+ } else r = recursivelyNotify(i, t) || r;
1397
+ return r;
1398
+ }
1399
+ function recursivelyAddParent(e, t) {
1400
+ let n;
1401
+ const r = e[W];
1402
+ if (r) {
1403
+ n = r[Q];
1404
+ e = r[F];
1405
+ }
1406
+ if (t) {
1407
+ let n = I.get(e);
1408
+ if (!n) I.set(e, t);
1409
+ else if (n !== t) {
1410
+ if (!(n instanceof Set)) I.set(e, (n = new Set([n])));
1411
+ else if (n.has(t)) return;
1412
+ n.add(t);
1413
+ } else return;
1414
+ }
1415
+ if (Array.isArray(e)) {
1416
+ const t = n?.length || e.length;
1417
+ for (let r = 0; r < t; r++) {
1418
+ const t = n && r in n ? n[r] : e[r];
1419
+ isWrappable(t) && recursivelyAddParent(t, e);
1642
1420
  }
1643
1421
  } else {
1644
- const keys = getKeys(state, override);
1645
- for (let i = 0; i < keys.length; i++) {
1646
- const key = keys[i];
1647
- const item = override && key in override ? override[key] : state[key];
1648
- isWrappable(item) && recursivelyAddParent(item, state);
1422
+ const t = getKeys(e, n);
1423
+ for (let r = 0; r < t.length; r++) {
1424
+ const i = t[r];
1425
+ const s = n && i in n ? n[i] : e[i];
1426
+ isWrappable(s) && recursivelyAddParent(s, e);
1649
1427
  }
1650
1428
  }
1651
1429
  }
1652
- function deep(store) {
1653
- recursivelyAddParent(store);
1654
- return store[$DEEP];
1430
+ function deep(e) {
1431
+ recursivelyAddParent(e);
1432
+ return e[A];
1655
1433
  }
1656
-
1657
- // src/store/optimistic.ts
1658
- function createOptimisticStore(first, second, options) {
1434
+ function createOptimisticStore(e, t, n) {
1659
1435
  return [];
1660
1436
  }
1661
-
1662
- // src/store/utils.ts
1663
- function snapshot(item, map, lookup) {
1664
- var _a;
1665
- let target, isArray, override, result, unwrapped, v;
1666
- if (!isWrappable(item))
1667
- return item;
1668
- if (map && map.has(item))
1669
- return map.get(item);
1670
- if (!map)
1671
- map = /* @__PURE__ */ new Map();
1672
- if (target = item[$TARGET] || ((_a = lookup == null ? void 0 : lookup.get(item)) == null ? void 0 : _a[$TARGET])) {
1673
- override = target[STORE_OVERRIDE];
1674
- isArray = Array.isArray(target[STORE_VALUE]);
1675
- map.set(
1676
- item,
1677
- override ? result = isArray ? [] : Object.create(Object.getPrototypeOf(target[STORE_VALUE])) : target[STORE_VALUE]
1678
- );
1679
- item = target[STORE_VALUE];
1680
- lookup = storeLookup;
1437
+ function snapshot(e, t, n) {
1438
+ let r, i, s, o, u, l;
1439
+ if (!isWrappable(e)) return e;
1440
+ if (t && t.has(e)) return t.get(e);
1441
+ if (!t) t = new Map();
1442
+ if ((r = e[W] || n?.get(e)?.[W])) {
1443
+ s = r[Q];
1444
+ i = Array.isArray(r[F]);
1445
+ t.set(e, s ? (o = i ? [] : Object.create(Object.getPrototypeOf(r[F]))) : r[F]);
1446
+ e = r[F];
1447
+ n = B;
1681
1448
  } else {
1682
- isArray = Array.isArray(item);
1683
- map.set(item, item);
1684
- }
1685
- if (isArray) {
1686
- const len = (override == null ? void 0 : override.length) || item.length;
1687
- for (let i = 0; i < len; i++) {
1688
- v = override && i in override ? override[i] : item[i];
1689
- if (v === $DELETED)
1690
- continue;
1691
- if ((unwrapped = snapshot(v, map, lookup)) !== v || result) {
1692
- if (!result)
1693
- map.set(item, result = [...item]);
1694
- result[i] = unwrapped;
1449
+ i = Array.isArray(e);
1450
+ t.set(e, e);
1451
+ }
1452
+ if (i) {
1453
+ const r = s?.length || e.length;
1454
+ for (let i = 0; i < r; i++) {
1455
+ l = s && i in s ? s[i] : e[i];
1456
+ if (l === H) continue;
1457
+ if ((u = snapshot(l, t, n)) !== l || o) {
1458
+ if (!o) t.set(e, (o = [...e]));
1459
+ o[i] = u;
1695
1460
  }
1696
1461
  }
1697
1462
  } else {
1698
- const keys = getKeys(item, override);
1699
- for (let i = 0, l = keys.length; i < l; i++) {
1700
- let prop = keys[i];
1701
- const desc = getPropertyDescriptor(item, override, prop);
1702
- if (desc.get)
1703
- continue;
1704
- v = override && prop in override ? override[prop] : item[prop];
1705
- if ((unwrapped = snapshot(v, map, lookup)) !== item[prop] || result) {
1706
- if (!result) {
1707
- result = Object.create(Object.getPrototypeOf(item));
1708
- Object.assign(result, item);
1463
+ const r = getKeys(e, s);
1464
+ for (let i = 0, f = r.length; i < f; i++) {
1465
+ let f = r[i];
1466
+ const c = getPropertyDescriptor(e, s, f);
1467
+ if (c.get) continue;
1468
+ l = s && f in s ? s[f] : e[f];
1469
+ if ((u = snapshot(l, t, n)) !== e[f] || o) {
1470
+ if (!o) {
1471
+ o = Object.create(Object.getPrototypeOf(e));
1472
+ Object.assign(o, e);
1709
1473
  }
1710
- result[prop] = unwrapped;
1474
+ o[f] = u;
1711
1475
  }
1712
1476
  }
1713
1477
  }
1714
- return result || item;
1478
+ return o || e;
1715
1479
  }
1716
1480
  function trueFn() {
1717
1481
  return true;
1718
1482
  }
1719
- var propTraps = {
1720
- get(_, property, receiver) {
1721
- if (property === $PROXY)
1722
- return receiver;
1723
- return _.get(property);
1483
+ const T = {
1484
+ get(e, t, n) {
1485
+ if (t === P) return n;
1486
+ return e.get(t);
1724
1487
  },
1725
- has(_, property) {
1726
- if (property === $PROXY)
1727
- return true;
1728
- return _.has(property);
1488
+ has(e, t) {
1489
+ if (t === P) return true;
1490
+ return e.has(t);
1729
1491
  },
1730
1492
  set: trueFn,
1731
1493
  deleteProperty: trueFn,
1732
- getOwnPropertyDescriptor(_, property) {
1494
+ getOwnPropertyDescriptor(e, t) {
1733
1495
  return {
1734
1496
  configurable: true,
1735
1497
  enumerable: true,
1736
1498
  get() {
1737
- return _.get(property);
1499
+ return e.get(t);
1738
1500
  },
1739
1501
  set: trueFn,
1740
1502
  deleteProperty: trueFn
1741
1503
  };
1742
1504
  },
1743
- ownKeys(_) {
1744
- return _.keys();
1505
+ ownKeys(e) {
1506
+ return e.keys();
1745
1507
  }
1746
1508
  };
1747
- function resolveSource(s) {
1748
- return !(s = typeof s === "function" ? s() : s) ? {} : s;
1749
- }
1750
- var $SOURCES = Symbol(0);
1751
- function merge(...sources) {
1752
- if (sources.length === 1 && typeof sources[0] !== "function")
1753
- return sources[0];
1754
- let proxy = false;
1755
- const flattened = [];
1756
- for (let i = 0; i < sources.length; i++) {
1757
- const s = sources[i];
1758
- proxy = proxy || !!s && $PROXY in s;
1759
- const childSources = !!s && s[$SOURCES];
1760
- if (childSources)
1761
- flattened.push(...childSources);
1762
- else
1763
- flattened.push(
1764
- typeof s === "function" ? (proxy = true, createMemo(s)) : s
1765
- );
1766
- }
1767
- if (SUPPORTS_PROXY && proxy) {
1509
+ function resolveSource(e) {
1510
+ return !(e = typeof e === "function" ? e() : e) ? {} : e;
1511
+ }
1512
+ const U = Symbol(0);
1513
+ function merge(...e) {
1514
+ if (e.length === 1 && typeof e[0] !== "function") return e[0];
1515
+ let t = false;
1516
+ const n = [];
1517
+ for (let r = 0; r < e.length; r++) {
1518
+ const i = e[r];
1519
+ t = t || (!!i && P in i);
1520
+ const s = !!i && i[U];
1521
+ if (s) n.push(...s);
1522
+ else n.push(typeof i === "function" ? ((t = true), createMemo(i)) : i);
1523
+ }
1524
+ if (y && t) {
1768
1525
  return new Proxy(
1769
1526
  {
1770
- get(property) {
1771
- if (property === $SOURCES)
1772
- return flattened;
1773
- for (let i = flattened.length - 1; i >= 0; i--) {
1774
- const s = resolveSource(flattened[i]);
1775
- if (property in s)
1776
- return s[property];
1527
+ get(e) {
1528
+ if (e === U) return n;
1529
+ for (let t = n.length - 1; t >= 0; t--) {
1530
+ const r = resolveSource(n[t]);
1531
+ if (e in r) return r[e];
1777
1532
  }
1778
1533
  },
1779
- has(property) {
1780
- for (let i = flattened.length - 1; i >= 0; i--) {
1781
- if (property in resolveSource(flattened[i]))
1782
- return true;
1534
+ has(e) {
1535
+ for (let t = n.length - 1; t >= 0; t--) {
1536
+ if (e in resolveSource(n[t])) return true;
1783
1537
  }
1784
1538
  return false;
1785
1539
  },
1786
1540
  keys() {
1787
- const keys = [];
1788
- for (let i = 0; i < flattened.length; i++)
1789
- keys.push(...Object.keys(resolveSource(flattened[i])));
1790
- return [...new Set(keys)];
1541
+ const e = [];
1542
+ for (let t = 0; t < n.length; t++) e.push(...Object.keys(resolveSource(n[t])));
1543
+ return [...new Set(e)];
1791
1544
  }
1792
1545
  },
1793
- propTraps
1546
+ T
1794
1547
  );
1795
1548
  }
1796
- const defined = /* @__PURE__ */ Object.create(null);
1797
- let nonTargetKey = false;
1798
- let lastIndex = flattened.length - 1;
1799
- for (let i = lastIndex; i >= 0; i--) {
1800
- const source = flattened[i];
1801
- if (!source) {
1802
- i === lastIndex && lastIndex--;
1549
+ const r = Object.create(null);
1550
+ let i = false;
1551
+ let s = n.length - 1;
1552
+ for (let e = s; e >= 0; e--) {
1553
+ const t = n[e];
1554
+ if (!t) {
1555
+ e === s && s--;
1803
1556
  continue;
1804
1557
  }
1805
- const sourceKeys = Object.getOwnPropertyNames(source);
1806
- for (let j = sourceKeys.length - 1; j >= 0; j--) {
1807
- const key = sourceKeys[j];
1808
- if (key === "__proto__" || key === "constructor")
1809
- continue;
1810
- if (!defined[key]) {
1811
- nonTargetKey = nonTargetKey || i !== lastIndex;
1812
- const desc = Object.getOwnPropertyDescriptor(source, key);
1813
- defined[key] = desc.get ? {
1814
- enumerable: true,
1815
- configurable: true,
1816
- get: desc.get.bind(source)
1817
- } : desc;
1558
+ const o = Object.getOwnPropertyNames(t);
1559
+ for (let n = o.length - 1; n >= 0; n--) {
1560
+ const u = o[n];
1561
+ if (u === "__proto__" || u === "constructor") continue;
1562
+ if (!r[u]) {
1563
+ i = i || e !== s;
1564
+ const n = Object.getOwnPropertyDescriptor(t, u);
1565
+ r[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
1818
1566
  }
1819
1567
  }
1820
1568
  }
1821
- if (!nonTargetKey)
1822
- return flattened[lastIndex];
1823
- const target = {};
1824
- const definedKeys = Object.keys(defined);
1825
- for (let i = definedKeys.length - 1; i >= 0; i--) {
1826
- const key = definedKeys[i], desc = defined[key];
1827
- if (desc.get)
1828
- Object.defineProperty(target, key, desc);
1829
- else
1830
- target[key] = desc.value;
1569
+ if (!i) return n[s];
1570
+ const o = {};
1571
+ const u = Object.keys(r);
1572
+ for (let e = u.length - 1; e >= 0; e--) {
1573
+ const t = u[e],
1574
+ n = r[t];
1575
+ if (n.get) Object.defineProperty(o, t, n);
1576
+ else o[t] = n.value;
1831
1577
  }
1832
- target[$SOURCES] = flattened;
1833
- return target;
1578
+ o[U] = n;
1579
+ return o;
1834
1580
  }
1835
- function omit(props, ...keys) {
1836
- const blocked = new Set(keys);
1837
- if (SUPPORTS_PROXY && $PROXY in props) {
1581
+ function omit(e, ...t) {
1582
+ const n = new Set(t);
1583
+ if (y && P in e) {
1838
1584
  return new Proxy(
1839
1585
  {
1840
- get(property) {
1841
- return blocked.has(property) ? void 0 : props[property];
1586
+ get(t) {
1587
+ return n.has(t) ? undefined : e[t];
1842
1588
  },
1843
- has(property) {
1844
- return !blocked.has(property) && property in props;
1589
+ has(t) {
1590
+ return !n.has(t) && t in e;
1845
1591
  },
1846
1592
  keys() {
1847
- return Object.keys(props).filter((k) => !blocked.has(k));
1593
+ return Object.keys(e).filter(e => !n.has(e));
1848
1594
  }
1849
1595
  },
1850
- propTraps
1596
+ T
1851
1597
  );
1852
1598
  }
1853
- const result = {};
1854
- for (const propName of Object.getOwnPropertyNames(props)) {
1855
- if (!blocked.has(propName)) {
1856
- const desc = Object.getOwnPropertyDescriptor(props, propName);
1857
- !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable ? result[propName] = desc.value : Object.defineProperty(result, propName, desc);
1599
+ const r = {};
1600
+ for (const t of Object.getOwnPropertyNames(e)) {
1601
+ if (!n.has(t)) {
1602
+ const n = Object.getOwnPropertyDescriptor(e, t);
1603
+ !n.get && !n.set && n.enumerable && n.writable && n.configurable
1604
+ ? (r[t] = n.value)
1605
+ : Object.defineProperty(r, t, n);
1858
1606
  }
1859
1607
  }
1860
- return result;
1608
+ return r;
1861
1609
  }
1862
-
1863
- // src/map.ts
1864
- function mapArray(list, map, options) {
1865
- const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
1610
+ function mapArray(e, t, n) {
1611
+ const r = typeof n?.keyed === "function" ? n.keyed : undefined;
1866
1612
  return createMemo(
1867
1613
  updateKeyedMap.bind({
1868
- X: createOwner(),
1869
- n: 0,
1870
- wa: list,
1871
- G: [],
1872
- O: map,
1873
- d: [],
1874
- a: [],
1875
- P: keyFn,
1876
- o: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
1877
- p: map.length > 1 ? [] : void 0,
1878
- Y: options == null ? void 0 : options.fallback
1614
+ Oe: createOwner(),
1615
+ Ce: 0,
1616
+ ve: e,
1617
+ Ne: [],
1618
+ ke: t,
1619
+ Ee: [],
1620
+ je: [],
1621
+ Ae: r,
1622
+ We: r || n?.keyed === false ? [] : undefined,
1623
+ Pe: t.length > 1 ? [] : undefined,
1624
+ He: n?.fallback
1879
1625
  })
1880
1626
  );
1881
1627
  }
1882
- var pureOptions = { pureWrite: true };
1628
+ const L = { pureWrite: true };
1883
1629
  function updateKeyedMap() {
1884
- const newItems = this.wa() || [], newLen = newItems.length;
1885
- newItems[$TRACK];
1886
- runWithOwner(this.X, () => {
1887
- let i, j, mapper = this.o ? () => {
1888
- this.o[j] = signal(newItems[j], pureOptions);
1889
- this.p && (this.p[j] = signal(j, pureOptions));
1890
- return this.O(
1891
- read.bind(null, this.o[j]),
1892
- this.p ? read.bind(null, this.p[j]) : void 0
1893
- );
1894
- } : this.p ? () => {
1895
- const item = newItems[j];
1896
- this.p[j] = signal(j, pureOptions);
1897
- return this.O(
1898
- () => item,
1899
- read.bind(null, this.p[j])
1900
- );
1901
- } : () => {
1902
- const item = newItems[j];
1903
- return this.O(() => item);
1904
- };
1905
- if (newLen === 0) {
1906
- if (this.n !== 0) {
1907
- this.X.dispose(false);
1908
- this.a = [];
1909
- this.G = [];
1910
- this.d = [];
1911
- this.n = 0;
1912
- this.o && (this.o = []);
1913
- this.p && (this.p = []);
1630
+ const e = this.ve() || [],
1631
+ t = e.length;
1632
+ e[j];
1633
+ runWithOwner(this.Oe, () => {
1634
+ let n,
1635
+ r,
1636
+ i = this.We
1637
+ ? () => {
1638
+ this.We[r] = signal(e[r], L);
1639
+ this.Pe && (this.Pe[r] = signal(r, L));
1640
+ return this.ke(
1641
+ read.bind(null, this.We[r]),
1642
+ this.Pe ? read.bind(null, this.Pe[r]) : undefined
1643
+ );
1644
+ }
1645
+ : this.Pe
1646
+ ? () => {
1647
+ const t = e[r];
1648
+ this.Pe[r] = signal(r, L);
1649
+ return this.ke(() => t, read.bind(null, this.Pe[r]));
1650
+ }
1651
+ : () => {
1652
+ const t = e[r];
1653
+ return this.ke(() => t);
1654
+ };
1655
+ if (t === 0) {
1656
+ if (this.Ce !== 0) {
1657
+ this.Oe.dispose(false);
1658
+ this.je = [];
1659
+ this.Ne = [];
1660
+ this.Ee = [];
1661
+ this.Ce = 0;
1662
+ this.We && (this.We = []);
1663
+ this.Pe && (this.Pe = []);
1914
1664
  }
1915
- if (this.Y && !this.d[0]) {
1916
- this.d[0] = runWithOwner(
1917
- this.a[0] = createOwner(),
1918
- this.Y
1919
- );
1665
+ if (this.He && !this.Ee[0]) {
1666
+ this.Ee[0] = runWithOwner((this.je[0] = createOwner()), this.He);
1920
1667
  }
1921
- } else if (this.n === 0) {
1922
- if (this.a[0])
1923
- this.a[0].dispose();
1924
- this.d = new Array(newLen);
1925
- for (j = 0; j < newLen; j++) {
1926
- this.G[j] = newItems[j];
1927
- this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
1668
+ } else if (this.Ce === 0) {
1669
+ if (this.je[0]) this.je[0].dispose();
1670
+ this.Ee = new Array(t);
1671
+ for (r = 0; r < t; r++) {
1672
+ this.Ne[r] = e[r];
1673
+ this.Ee[r] = runWithOwner((this.je[r] = createOwner()), i);
1928
1674
  }
1929
- this.n = newLen;
1675
+ this.Ce = t;
1930
1676
  } else {
1931
- let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.o ? new Array(newLen) : void 0, tempIndexes = this.p ? new Array(newLen) : void 0;
1932
- for (start = 0, end = Math.min(this.n, newLen); start < end && (this.G[start] === newItems[start] || this.o && compare(this.P, this.G[start], newItems[start])); start++) {
1933
- if (this.o)
1934
- setSignal(this.o[start], newItems[start]);
1677
+ let s,
1678
+ o,
1679
+ u,
1680
+ l,
1681
+ f,
1682
+ c,
1683
+ a,
1684
+ d = new Array(t),
1685
+ h = new Array(t),
1686
+ p = this.We ? new Array(t) : undefined,
1687
+ y = this.Pe ? new Array(t) : undefined;
1688
+ for (
1689
+ s = 0, o = Math.min(this.Ce, t);
1690
+ s < o && (this.Ne[s] === e[s] || (this.We && compare(this.Ae, this.Ne[s], e[s])));
1691
+ s++
1692
+ ) {
1693
+ if (this.We) setSignal(this.We[s], e[s]);
1935
1694
  }
1936
- for (end = this.n - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.o && compare(this.P, this.G[end], newItems[newEnd])); end--, newEnd--) {
1937
- temp[newEnd] = this.d[end];
1938
- tempNodes[newEnd] = this.a[end];
1939
- tempRows && (tempRows[newEnd] = this.o[end]);
1940
- tempIndexes && (tempIndexes[newEnd] = this.p[end]);
1695
+ for (
1696
+ o = this.Ce - 1, u = t - 1;
1697
+ o >= s &&
1698
+ u >= s &&
1699
+ (this.Ne[o] === e[u] || (this.We && compare(this.Ae, this.Ne[o], e[u])));
1700
+ o--, u--
1701
+ ) {
1702
+ d[u] = this.Ee[o];
1703
+ h[u] = this.je[o];
1704
+ p && (p[u] = this.We[o]);
1705
+ y && (y[u] = this.Pe[o]);
1941
1706
  }
1942
- newIndices = /* @__PURE__ */ new Map();
1943
- newIndicesNext = new Array(newEnd + 1);
1944
- for (j = newEnd; j >= start; j--) {
1945
- item = newItems[j];
1946
- key = this.P ? this.P(item) : item;
1947
- i = newIndices.get(key);
1948
- newIndicesNext[j] = i === void 0 ? -1 : i;
1949
- newIndices.set(key, j);
1707
+ c = new Map();
1708
+ a = new Array(u + 1);
1709
+ for (r = u; r >= s; r--) {
1710
+ l = e[r];
1711
+ f = this.Ae ? this.Ae(l) : l;
1712
+ n = c.get(f);
1713
+ a[r] = n === undefined ? -1 : n;
1714
+ c.set(f, r);
1950
1715
  }
1951
- for (i = start; i <= end; i++) {
1952
- item = this.G[i];
1953
- key = this.P ? this.P(item) : item;
1954
- j = newIndices.get(key);
1955
- if (j !== void 0 && j !== -1) {
1956
- temp[j] = this.d[i];
1957
- tempNodes[j] = this.a[i];
1958
- tempRows && (tempRows[j] = this.o[i]);
1959
- tempIndexes && (tempIndexes[j] = this.p[i]);
1960
- j = newIndicesNext[j];
1961
- newIndices.set(key, j);
1962
- } else
1963
- this.a[i].dispose();
1716
+ for (n = s; n <= o; n++) {
1717
+ l = this.Ne[n];
1718
+ f = this.Ae ? this.Ae(l) : l;
1719
+ r = c.get(f);
1720
+ if (r !== undefined && r !== -1) {
1721
+ d[r] = this.Ee[n];
1722
+ h[r] = this.je[n];
1723
+ p && (p[r] = this.We[n]);
1724
+ y && (y[r] = this.Pe[n]);
1725
+ r = a[r];
1726
+ c.set(f, r);
1727
+ } else this.je[n].dispose();
1964
1728
  }
1965
- for (j = start; j < newLen; j++) {
1966
- if (j in temp) {
1967
- this.d[j] = temp[j];
1968
- this.a[j] = tempNodes[j];
1969
- if (tempRows) {
1970
- this.o[j] = tempRows[j];
1971
- setSignal(this.o[j], newItems[j]);
1729
+ for (r = s; r < t; r++) {
1730
+ if (r in d) {
1731
+ this.Ee[r] = d[r];
1732
+ this.je[r] = h[r];
1733
+ if (p) {
1734
+ this.We[r] = p[r];
1735
+ setSignal(this.We[r], e[r]);
1972
1736
  }
1973
- if (tempIndexes) {
1974
- this.p[j] = tempIndexes[j];
1975
- setSignal(this.p[j], j);
1737
+ if (y) {
1738
+ this.Pe[r] = y[r];
1739
+ setSignal(this.Pe[r], r);
1976
1740
  }
1977
1741
  } else {
1978
- this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
1742
+ this.Ee[r] = runWithOwner((this.je[r] = createOwner()), i);
1979
1743
  }
1980
1744
  }
1981
- this.d = this.d.slice(0, this.n = newLen);
1982
- this.G = newItems.slice(0);
1745
+ this.Ee = this.Ee.slice(0, (this.Ce = t));
1746
+ this.Ne = e.slice(0);
1983
1747
  }
1984
1748
  });
1985
- return this.d;
1749
+ return this.Ee;
1986
1750
  }
1987
- function repeat(count, map, options) {
1751
+ function repeat(e, t, n) {
1988
1752
  return updateRepeat.bind({
1989
- X: createOwner(),
1990
- n: 0,
1991
- y: 0,
1992
- xa: count,
1993
- O: map,
1994
- a: [],
1995
- d: [],
1996
- ya: options == null ? void 0 : options.from,
1997
- Y: options == null ? void 0 : options.fallback
1753
+ Oe: createOwner(),
1754
+ Ce: 0,
1755
+ Ie: 0,
1756
+ Fe: e,
1757
+ ke: t,
1758
+ je: [],
1759
+ Ee: [],
1760
+ Qe: n?.from,
1761
+ He: n?.fallback
1998
1762
  });
1999
1763
  }
2000
1764
  function updateRepeat() {
2001
- var _a;
2002
- const newLen = this.xa();
2003
- const from = ((_a = this.ya) == null ? void 0 : _a.call(this)) || 0;
2004
- runWithOwner(this.X, () => {
2005
- if (newLen === 0) {
2006
- if (this.n !== 0) {
2007
- this.X.dispose(false);
2008
- this.a = [];
2009
- this.d = [];
2010
- this.n = 0;
1765
+ const e = this.Fe();
1766
+ const t = this.Qe?.() || 0;
1767
+ runWithOwner(this.Oe, () => {
1768
+ if (e === 0) {
1769
+ if (this.Ce !== 0) {
1770
+ this.Oe.dispose(false);
1771
+ this.je = [];
1772
+ this.Ee = [];
1773
+ this.Ce = 0;
2011
1774
  }
2012
- if (this.Y && !this.d[0]) {
2013
- this.d[0] = runWithOwner(
2014
- this.a[0] = createOwner(),
2015
- this.Y
2016
- );
1775
+ if (this.He && !this.Ee[0]) {
1776
+ this.Ee[0] = runWithOwner((this.je[0] = createOwner()), this.He);
2017
1777
  }
2018
1778
  return;
2019
1779
  }
2020
- const to = from + newLen;
2021
- const prevTo = this.y + this.n;
2022
- if (this.n === 0 && this.a[0])
2023
- this.a[0].dispose();
2024
- for (let i = to; i < prevTo; i++)
2025
- this.a[i - this.y].dispose();
2026
- if (this.y < from) {
2027
- let i = this.y;
2028
- while (i < from && i < this.n)
2029
- this.a[i++].dispose();
2030
- this.a.splice(0, from - this.y);
2031
- this.d.splice(0, from - this.y);
2032
- } else if (this.y > from) {
2033
- let i = prevTo - this.y - 1;
2034
- let difference = this.y - from;
2035
- this.a.length = this.d.length = newLen;
2036
- while (i >= difference) {
2037
- this.a[i] = this.a[i - difference];
2038
- this.d[i] = this.d[i - difference];
2039
- i--;
1780
+ const n = t + e;
1781
+ const r = this.Ie + this.Ce;
1782
+ if (this.Ce === 0 && this.je[0]) this.je[0].dispose();
1783
+ for (let e = n; e < r; e++) this.je[e - this.Ie].dispose();
1784
+ if (this.Ie < t) {
1785
+ let e = this.Ie;
1786
+ while (e < t && e < this.Ce) this.je[e++].dispose();
1787
+ this.je.splice(0, t - this.Ie);
1788
+ this.Ee.splice(0, t - this.Ie);
1789
+ } else if (this.Ie > t) {
1790
+ let n = r - this.Ie - 1;
1791
+ let i = this.Ie - t;
1792
+ this.je.length = this.Ee.length = e;
1793
+ while (n >= i) {
1794
+ this.je[n] = this.je[n - i];
1795
+ this.Ee[n] = this.Ee[n - i];
1796
+ n--;
2040
1797
  }
2041
- for (let i2 = 0; i2 < difference; i2++) {
2042
- this.d[i2] = runWithOwner(
2043
- this.a[i2] = createOwner(),
2044
- () => this.O(i2 + from)
2045
- );
1798
+ for (let e = 0; e < i; e++) {
1799
+ this.Ee[e] = runWithOwner((this.je[e] = createOwner()), () => this.ke(e + t));
2046
1800
  }
2047
1801
  }
2048
- for (let i = prevTo; i < to; i++) {
2049
- this.d[i - from] = runWithOwner(
2050
- this.a[i - from] = createOwner(),
2051
- () => this.O(i)
2052
- );
1802
+ for (let e = r; e < n; e++) {
1803
+ this.Ee[e - t] = runWithOwner((this.je[e - t] = createOwner()), () => this.ke(e));
2053
1804
  }
2054
- this.d = this.d.slice(0, newLen);
2055
- this.y = from;
2056
- this.n = newLen;
1805
+ this.Ee = this.Ee.slice(0, e);
1806
+ this.Ie = t;
1807
+ this.Ce = e;
2057
1808
  });
2058
- return this.d;
2059
- }
2060
- function compare(key, a, b) {
2061
- return key ? key(a) === key(b) : true;
2062
- }
2063
-
2064
- // src/boundaries.ts
2065
- function boundaryComputed(fn, propagationMask) {
2066
- const node = computed(fn, void 0, {
2067
- ka: {
2068
- ma() {
2069
- let flags = this.f;
2070
- this.f &= ~this.Z;
2071
- if (this.Z & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
2072
- flags &= ~1 /* Pending */;
1809
+ return this.Ee;
1810
+ }
1811
+ function compare(e, t, n) {
1812
+ return e ? e(t) === e(n) : true;
1813
+ }
1814
+ function boundaryComputed(e, t) {
1815
+ const n = computed(e, undefined, {
1816
+ we: {
1817
+ le() {
1818
+ let e = this.$;
1819
+ this.$ &= ~this.Re;
1820
+ if (this.Re & f && !(this.$ & a)) {
1821
+ e &= ~f;
2073
1822
  }
2074
- this.i.notify(this, this.Z, flags);
1823
+ this.ye.notify(this, this.Re, e);
2075
1824
  },
2076
- Z: propagationMask
1825
+ Re: t
2077
1826
  }
2078
1827
  });
2079
- node.Z = propagationMask;
2080
- return node;
2081
- }
2082
- function createBoundChildren(owner, fn, queue, mask) {
2083
- const parentQueue = owner.i;
2084
- parentQueue.addChild(owner.i = queue);
2085
- onCleanup(() => parentQueue.removeChild(owner.i));
2086
- return runWithOwner(owner, () => {
2087
- const c = computed(fn);
2088
- return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
1828
+ n.Re = t;
1829
+ return n;
1830
+ }
1831
+ function createBoundChildren(e, t, n, r) {
1832
+ const i = e.ye;
1833
+ i.addChild((e.ye = n));
1834
+ onCleanup(() => i.removeChild(e.ye));
1835
+ return runWithOwner(e, () => {
1836
+ const e = computed(t);
1837
+ return boundaryComputed(() => staleValues(() => flatten(read(e))), r);
2089
1838
  });
2090
1839
  }
2091
- var ConditionalQueue = class extends Queue {
2092
- u;
2093
- ha = /* @__PURE__ */ new Set();
2094
- h = /* @__PURE__ */ new Set();
2095
- constructor(disabled) {
1840
+ class ConditionalQueue extends Queue {
1841
+ Ve;
1842
+ qe = new Set();
1843
+ M = new Set();
1844
+ constructor(e) {
2096
1845
  super();
2097
- this.u = disabled;
2098
- }
2099
- run(type) {
2100
- if (!type || read(this.u))
2101
- return;
2102
- return super.run(type);
2103
- }
2104
- notify(node, type, flags) {
2105
- if (read(this.u)) {
2106
- if (type & 1 /* Pending */) {
2107
- if (flags & 1 /* Pending */) {
2108
- this.h.add(node);
2109
- type &= ~1 /* Pending */;
2110
- } else if (this.h.delete(node))
2111
- type &= ~1 /* Pending */;
1846
+ this.Ve = e;
1847
+ }
1848
+ run(e) {
1849
+ if (!e || read(this.Ve)) return;
1850
+ return super.run(e);
1851
+ }
1852
+ notify(e, t, n) {
1853
+ if (read(this.Ve)) {
1854
+ if (t & f) {
1855
+ if (n & f) {
1856
+ this.M.add(e);
1857
+ t &= ~f;
1858
+ } else if (this.M.delete(e)) t &= ~f;
2112
1859
  }
2113
- if (type & 2 /* Error */) {
2114
- if (flags & 2 /* Error */) {
2115
- this.ha.add(node);
2116
- type &= ~2 /* Error */;
2117
- } else if (this.ha.delete(node))
2118
- type &= ~2 /* Error */;
1860
+ if (t & c) {
1861
+ if (n & c) {
1862
+ this.qe.add(e);
1863
+ t &= ~c;
1864
+ } else if (this.qe.delete(e)) t &= ~c;
2119
1865
  }
2120
1866
  }
2121
- return type ? super.notify(node, type, flags) : true;
1867
+ return t ? super.notify(e, t, n) : true;
2122
1868
  }
2123
- };
2124
- var CollectionQueue = class extends Queue {
2125
- _;
2126
- a = /* @__PURE__ */ new Set();
2127
- u = signal(false, { pureWrite: true });
2128
- ra = false;
2129
- constructor(type) {
1869
+ }
1870
+ class CollectionQueue extends Queue {
1871
+ Me;
1872
+ je = new Set();
1873
+ Ve = signal(false, { pureWrite: true });
1874
+ De = false;
1875
+ constructor(e) {
2130
1876
  super();
2131
- this._ = type;
2132
- }
2133
- run(type) {
2134
- if (!type || read(this.u))
2135
- return;
2136
- return super.run(type);
2137
- }
2138
- notify(node, type, flags) {
2139
- if (!(type & this._) || this._ & 1 /* Pending */ && this.ra)
2140
- return super.notify(node, type, flags);
2141
- if (flags & this._) {
2142
- this.a.add(node);
2143
- if (this.a.size === 1)
2144
- setSignal(this.u, true);
2145
- } else if (this.a.size > 0) {
2146
- this.a.delete(node);
2147
- if (this.a.size === 0)
2148
- setSignal(this.u, false);
2149
- }
2150
- type &= ~this._;
2151
- return type ? super.notify(node, type, flags) : true;
2152
- }
2153
- };
2154
- function createBoundary(fn, condition) {
2155
- const owner = createOwner();
2156
- const queue = new ConditionalQueue(computed(() => condition() === "hidden" /* HIDDEN */));
2157
- const tree = createBoundChildren(owner, fn, queue, 0);
1877
+ this.Me = e;
1878
+ }
1879
+ run(e) {
1880
+ if (!e || read(this.Ve)) return;
1881
+ return super.run(e);
1882
+ }
1883
+ notify(e, t, n) {
1884
+ if (!(t & this.Me) || (this.Me & f && this.De)) return super.notify(e, t, n);
1885
+ if (n & this.Me) {
1886
+ this.je.add(e);
1887
+ if (this.je.size === 1) setSignal(this.Ve, true);
1888
+ } else if (this.je.size > 0) {
1889
+ this.je.delete(e);
1890
+ if (this.je.size === 0) setSignal(this.Ve, false);
1891
+ }
1892
+ t &= ~this.Me;
1893
+ return t ? super.notify(e, t, n) : true;
1894
+ }
1895
+ }
1896
+ var z;
1897
+ (function (e) {
1898
+ e["VISIBLE"] = "visible";
1899
+ e["HIDDEN"] = "hidden";
1900
+ })(z || (z = {}));
1901
+ function createBoundary(e, t) {
1902
+ const n = createOwner();
1903
+ const r = new ConditionalQueue(computed(() => t() === z.HIDDEN));
1904
+ const i = createBoundChildren(n, e, r, 0);
2158
1905
  computed(() => {
2159
- const disabled = read(queue.u);
2160
- tree.Z = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
2161
- if (!disabled) {
2162
- queue.h.forEach(
2163
- (node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
2164
- );
2165
- queue.ha.forEach((node) => queue.notify(node, 2 /* Error */, 2 /* Error */));
2166
- queue.h.clear();
2167
- queue.ha.clear();
1906
+ const e = read(r.Ve);
1907
+ i.Re = e ? c | f : 0;
1908
+ if (!e) {
1909
+ r.M.forEach(e => r.notify(e, f, f));
1910
+ r.qe.forEach(e => r.notify(e, c, c));
1911
+ r.M.clear();
1912
+ r.qe.clear();
2168
1913
  }
2169
1914
  });
2170
- return () => read(queue.u) ? void 0 : read(tree);
2171
- }
2172
- function createCollectionBoundary(type, fn, fallback) {
2173
- const owner = createOwner();
2174
- const queue = new CollectionQueue(type);
2175
- const tree = createBoundChildren(owner, fn, queue, type);
2176
- const decision = computed(() => {
2177
- if (!read(queue.u)) {
2178
- const resolved = read(tree);
2179
- if (!untrack(() => read(queue.u)))
2180
- queue.ra = true;
2181
- return resolved;
2182
- }
2183
- return fallback(queue);
1915
+ return () => (read(r.Ve) ? undefined : read(i));
1916
+ }
1917
+ function createCollectionBoundary(e, t, n) {
1918
+ const r = createOwner();
1919
+ const i = new CollectionQueue(e);
1920
+ const s = createBoundChildren(r, t, i, e);
1921
+ const o = computed(() => {
1922
+ if (!read(i.Ve)) {
1923
+ const e = read(s);
1924
+ if (!untrack(() => read(i.Ve))) i.De = true;
1925
+ return e;
1926
+ }
1927
+ return n(i);
2184
1928
  });
2185
- return read.bind(null, decision);
2186
- }
2187
- function createLoadBoundary(fn, fallback) {
2188
- return createCollectionBoundary(1 /* Pending */, fn, () => fallback());
2189
- }
2190
- function createErrorBoundary(fn, fallback) {
2191
- return createCollectionBoundary(2 /* Error */, fn, (queue) => {
2192
- let node = queue.a.values().next().value;
2193
- return fallback(node.B, () => {
2194
- for (let node2 of queue.a) {
2195
- recompute(node2, true);
2196
- }
1929
+ return read.bind(null, o);
1930
+ }
1931
+ function createLoadBoundary(e, t) {
1932
+ return createCollectionBoundary(f, e, () => t());
1933
+ }
1934
+ function collectErrorSources(e, t) {
1935
+ let n = true;
1936
+ let r = e.W;
1937
+ while (r !== null) {
1938
+ const e = r.H;
1939
+ if (e.W && e.$ & c) {
1940
+ n = false;
1941
+ collectErrorSources(e, t);
1942
+ }
1943
+ r = r.P;
1944
+ }
1945
+ n && t.push(e);
1946
+ }
1947
+ function createErrorBoundary(e, t) {
1948
+ return createCollectionBoundary(c, e, e => {
1949
+ let n = e.je.values().next().value;
1950
+ return t(n.L, () => {
1951
+ const t = [];
1952
+ for (const n of e.je) collectErrorSources(n, t);
1953
+ for (const e of t) recompute(e);
1954
+ schedule();
2197
1955
  });
2198
1956
  });
2199
1957
  }
2200
- function flatten(children, options) {
2201
- if (typeof children === "function" && !children.length) {
2202
- if (options == null ? void 0 : options.doNotUnwrap)
2203
- return children;
1958
+ function flatten(e, t) {
1959
+ if (typeof e === "function" && !e.length) {
1960
+ if (t?.doNotUnwrap) return e;
2204
1961
  do {
2205
- children = children();
2206
- } while (typeof children === "function" && !children.length);
1962
+ e = e();
1963
+ } while (typeof e === "function" && !e.length);
2207
1964
  }
2208
- if ((options == null ? void 0 : options.skipNonRendered) && (children == null || children === true || children === false || children === ""))
2209
- return;
2210
- if (Array.isArray(children)) {
2211
- let results = [];
2212
- if (flattenArray(children, results, options)) {
1965
+ if (t?.skipNonRendered && (e == null || e === true || e === false || e === "")) return;
1966
+ if (Array.isArray(e)) {
1967
+ let n = [];
1968
+ if (flattenArray(e, n, t)) {
2213
1969
  return () => {
2214
- let nested = [];
2215
- flattenArray(results, nested, { ...options, doNotUnwrap: false });
2216
- return nested;
1970
+ let e = [];
1971
+ flattenArray(n, e, { ...t, doNotUnwrap: false });
1972
+ return e;
2217
1973
  };
2218
1974
  }
2219
- return results;
1975
+ return n;
2220
1976
  }
2221
- return children;
1977
+ return e;
2222
1978
  }
2223
- function flattenArray(children, results = [], options) {
2224
- let notReady = null;
2225
- let needsUnwrap = false;
2226
- for (let i = 0; i < children.length; i++) {
1979
+ function flattenArray(e, t = [], n) {
1980
+ let r = null;
1981
+ let i = false;
1982
+ for (let s = 0; s < e.length; s++) {
2227
1983
  try {
2228
- let child = children[i];
2229
- if (typeof child === "function" && !child.length) {
2230
- if (options == null ? void 0 : options.doNotUnwrap) {
2231
- results.push(child);
2232
- needsUnwrap = true;
1984
+ let r = e[s];
1985
+ if (typeof r === "function" && !r.length) {
1986
+ if (n?.doNotUnwrap) {
1987
+ t.push(r);
1988
+ i = true;
2233
1989
  continue;
2234
1990
  }
2235
1991
  do {
2236
- child = child();
2237
- } while (typeof child === "function" && !child.length);
1992
+ r = r();
1993
+ } while (typeof r === "function" && !r.length);
2238
1994
  }
2239
- if (Array.isArray(child)) {
2240
- needsUnwrap = flattenArray(child, results, options);
2241
- } else if ((options == null ? void 0 : options.skipNonRendered) && (child == null || child === true || child === false || child === "")) {
2242
- } else
2243
- results.push(child);
1995
+ if (Array.isArray(r)) {
1996
+ i = flattenArray(r, t, n);
1997
+ } else if (n?.skipNonRendered && (r == null || r === true || r === false || r === "")) {
1998
+ } else t.push(r);
2244
1999
  } catch (e) {
2245
- if (!(e instanceof NotReadyError))
2246
- throw e;
2247
- notReady = e;
2000
+ if (!(e instanceof NotReadyError)) throw e;
2001
+ r = e;
2248
2002
  }
2249
2003
  }
2250
- if (notReady)
2251
- throw notReady;
2252
- return needsUnwrap;
2004
+ if (r) throw r;
2005
+ return i;
2253
2006
  }
2254
-
2255
- exports.$PROXY = $PROXY;
2256
- exports.$TARGET = $TARGET;
2257
- exports.$TRACK = $TRACK;
2007
+ exports.$PROXY = P;
2008
+ exports.$TARGET = W;
2009
+ exports.$TRACK = j;
2258
2010
  exports.ContextNotFoundError = ContextNotFoundError;
2259
2011
  exports.NoOwnerError = NoOwnerError;
2260
2012
  exports.NotReadyError = NotReadyError;
2261
- exports.SUPPORTS_PROXY = SUPPORTS_PROXY;
2013
+ exports.SUPPORTS_PROXY = y;
2262
2014
  exports.createAsync = createAsync;
2263
2015
  exports.createBoundary = createBoundary;
2264
2016
  exports.createContext = createContext;