@solidjs/signals 0.9.5 → 0.9.7

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