@but212/atom-effect 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- var y = {
1
+ var A = {
2
2
  IDLE: "idle",
3
3
  PENDING: "pending",
4
4
  RESOLVED: "resolved",
5
5
  REJECTED: "rejected"
6
- }, c = {
6
+ }, I = {
7
7
  DISPOSED: 1,
8
8
  EXECUTING: 8
9
- }, B = {
9
+ }, H = {
10
10
  DISPOSED: 1,
11
11
  IS_COMPUTED: 2,
12
12
  DIRTY: 8,
@@ -21,50 +21,56 @@ var y = {
21
21
  DISPOSED: 1,
22
22
  SYNC: 8,
23
23
  NOTIFICATION_SCHEDULED: 16
24
- }, I = {
24
+ }, C = {
25
25
  MAX_EXECUTIONS_PER_SECOND: 1e3,
26
26
  MAX_EXECUTIONS_PER_EFFECT: 100,
27
27
  MAX_EXECUTIONS_PER_FLUSH: 1e4,
28
28
  MAX_FLUSH_ITERATIONS: 1e3,
29
29
  MIN_FLUSH_ITERATIONS: 10,
30
30
  BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
31
- }, tt = {
31
+ }, st = {
32
32
  WARN_INFINITE_LOOP: !0,
33
33
  EFFECT_FREQUENCY_WINDOW: 1e3
34
- }, $ = {
34
+ }, j = {
35
35
  MAX_ASYNC_RETRIES: 3,
36
36
  MAX_PROMISE_ID: Number.MAX_SAFE_INTEGER - 1
37
- }, p = {
37
+ }, T = {
38
38
  UNINITIALIZED: -1,
39
39
  MIN: 1
40
- }, st = 1073741823, j = { VERSION_BITS: 16 }, Ct = (typeof process < "u" && process.env, !1), q = Object.freeze([]), x = class {
40
+ }, w = 1073741823, _t = { VERSION_BITS: 16 }, mt = (typeof process < "u" && process.env, !1), W = Object.freeze([]), z = class {
41
41
  constructor(t, s, e = void 0) {
42
42
  this.node = t, this.version = s, this.unsub = e;
43
43
  }
44
- }, ut = class {
44
+ }, ft = class {
45
45
  constructor(t, s) {
46
46
  this.fn = t, this.sub = s;
47
47
  }
48
48
  notify(t, s) {
49
- this.fn ? this.fn(t, s) : this.sub && this.sub.execute();
49
+ const e = this.fn;
50
+ if (e !== void 0) {
51
+ e(t, s);
52
+ return;
53
+ }
54
+ const i = this.sub;
55
+ i !== void 0 && i.execute();
50
56
  }
51
- }, T = class extends Error {
57
+ }, N = class extends Error {
52
58
  constructor(t, s = null, e = !0) {
53
59
  super(t), this.cause = s, this.recoverable = e, this.name = "AtomError";
54
60
  }
55
- }, v = class extends T {
61
+ }, S = class extends N {
56
62
  constructor(t, s = null) {
57
63
  super(t, s, !0), this.name = "ComputedError";
58
64
  }
59
- }, D = class extends T {
65
+ }, v = class extends N {
60
66
  constructor(t, s = null) {
61
67
  super(t, s, !1), this.name = "EffectError";
62
68
  }
63
- }, R = class extends T {
69
+ }, L = class extends N {
64
70
  constructor(t, s = null) {
65
71
  super(t, s, !1), this.name = "SchedulerError";
66
72
  }
67
- }, h = {
73
+ }, c = {
68
74
  COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
69
75
  COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
70
76
  COMPUTED_COMPUTATION_FAILED: "Computation execution failed",
@@ -91,7 +97,7 @@ var y = {
91
97
  return this._count;
92
98
  }
93
99
  getAt(t) {
94
- switch (t) {
100
+ if (t < 4) switch (t) {
95
101
  case 0:
96
102
  return this._s0;
97
103
  case 1:
@@ -100,15 +106,13 @@ var y = {
100
106
  return this._s2;
101
107
  case 3:
102
108
  return this._s3;
103
- default: {
104
- const s = this._overflow;
105
- if (s !== null && t >= 4) {
106
- const e = t - 4;
107
- if (e < s.length) return s[e] ?? null;
108
- }
109
- return null;
110
- }
111
109
  }
110
+ const s = this._overflow;
111
+ if (s !== null) {
112
+ const e = s[t - 4];
113
+ return e === void 0 ? null : e;
114
+ }
115
+ return null;
112
116
  }
113
117
  setAt(t, s) {
114
118
  switch (t) {
@@ -124,41 +128,38 @@ var y = {
124
128
  case 3:
125
129
  this._s3 = s;
126
130
  break;
127
- default: {
128
- this._overflow ??= [];
129
- const e = this._overflow;
130
- e[t - 4] = s;
131
- }
131
+ default:
132
+ this._overflow ??= [], this._overflow[t - 4] = s;
132
133
  }
133
134
  t >= this._count && (this._count = t + 1);
134
135
  }
135
136
  truncateFrom(t) {
136
137
  const s = this._count;
137
138
  if (t >= s) return;
138
- if (t <= 3) switch (t) {
139
- case 0: {
139
+ if (t <= 3) {
140
+ if (t <= 0) {
140
141
  const i = this._s0;
141
142
  i != null && (this._onItemRemoved(i), this._s0 = null);
142
143
  }
143
- case 1: {
144
+ if (t <= 1) {
144
145
  const i = this._s1;
145
146
  i != null && (this._onItemRemoved(i), this._s1 = null);
146
147
  }
147
- case 2: {
148
+ if (t <= 2) {
148
149
  const i = this._s2;
149
150
  i != null && (this._onItemRemoved(i), this._s2 = null);
150
151
  }
151
- case 3: {
152
+ if (t <= 3) {
152
153
  const i = this._s3;
153
154
  i != null && (this._onItemRemoved(i), this._s3 = null);
154
155
  }
155
156
  }
156
157
  const e = this._overflow;
157
158
  if (e !== null && s > 4) {
158
- const i = t > 4 ? t - 4 : 0, n = e.length;
159
- for (let o = i; o < n; o++) {
160
- const r = e[o];
161
- r != null && (this._onItemRemoved(r), e[o] = null);
159
+ const i = t > 4 ? t - 4 : 0, r = e.length;
160
+ for (let n = i; n < r; n++) {
161
+ const o = e[n];
162
+ o != null && (this._onItemRemoved(o), e[n] = null);
162
163
  }
163
164
  t <= 4 ? (e.length = 0, this._overflow = null) : e.length = t - 4;
164
165
  }
@@ -186,10 +187,11 @@ var y = {
186
187
  this._addToOverflow(t);
187
188
  }
188
189
  _addToOverflow(t) {
189
- if (this._overflow === null) this._overflow = [t];
190
+ const s = this._overflow;
191
+ if (s === null) this._overflow = [t];
190
192
  else {
191
- const s = this._freeIndices;
192
- s !== null && s.length > 0 ? this._overflow[s.pop()] = t : this._overflow.push(t);
193
+ const e = this._freeIndices;
194
+ e !== null && e.length > 0 ? s[e.pop()] = t : s.push(t);
193
195
  }
194
196
  this._count++;
195
197
  }
@@ -204,8 +206,11 @@ var y = {
204
206
  return this._s3 = null, this._count--, !0;
205
207
  const s = this._overflow;
206
208
  if (s == null) return !1;
207
- for (let e = 0, i = s.length; e < i; e++) if (s[e] === t)
208
- return s[e] = null, this._count--, this._freeIndices === null && (this._freeIndices = []), this._freeIndices.push(e), !0;
209
+ for (let e = 0, i = s.length; e < i; e++) if (s[e] === t) {
210
+ s[e] = null, this._count--;
211
+ let r = this._freeIndices;
212
+ return r === null && (r = this._freeIndices = []), r.push(e), !0;
213
+ }
209
214
  return !1;
210
215
  }
211
216
  has(t) {
@@ -218,19 +223,26 @@ var y = {
218
223
  return !1;
219
224
  }
220
225
  forEach(t) {
221
- if (this._count === 0) return;
222
- const s = this._s0;
223
- s != null && t(s);
224
- const e = this._s1;
225
- e != null && t(e);
226
- const i = this._s2;
227
- i != null && t(i);
228
- const n = this._s3;
229
- n != null && t(n);
230
- const o = this._overflow;
231
- if (o != null) for (let r = 0, u = o.length; r < u; r++) {
232
- const l = o[r];
233
- l != null && t(l);
226
+ const s = this._count;
227
+ if (s === 0) return;
228
+ let e = 0;
229
+ const i = this._s0;
230
+ if (i != null && (t(i), ++e === s))
231
+ return;
232
+ const r = this._s1;
233
+ if (r != null && (t(r), ++e === s))
234
+ return;
235
+ const n = this._s2;
236
+ if (n != null && (t(n), ++e === s))
237
+ return;
238
+ const o = this._s3;
239
+ if (o != null && (t(o), ++e === s))
240
+ return;
241
+ const u = this._overflow;
242
+ if (u != null) for (let h = 0, l = u.length; h < l; h++) {
243
+ const f = u[h];
244
+ if (f != null && (t(f), ++e === s))
245
+ return;
234
246
  }
235
247
  }
236
248
  forEachIndexed(t) {
@@ -238,29 +250,37 @@ var y = {
238
250
  if (s === 0) return 0;
239
251
  let e = 0;
240
252
  const i = this._s0;
241
- i != null && (t(i), e++);
242
- const n = this._s1;
243
- n != null && (t(n), e++);
244
- const o = this._s2;
245
- o != null && (t(o), e++);
246
- const r = this._s3;
247
- if (r != null && (t(r), e++), e === s) return e;
253
+ if (i != null && (t(i), ++e === s))
254
+ return e;
255
+ const r = this._s1;
256
+ if (r != null && (t(r), ++e === s))
257
+ return e;
258
+ const n = this._s2;
259
+ if (n != null && (t(n), ++e === s))
260
+ return e;
261
+ const o = this._s3;
262
+ if (o != null && (t(o), ++e === s))
263
+ return e;
248
264
  const u = this._overflow;
249
- if (u != null) for (let l = 0, O = u.length; l < O; l++) {
250
- const Y = u[l];
251
- Y != null && (t(Y), e++);
265
+ if (u != null) for (let h = 0, l = u.length; h < l; h++) {
266
+ const f = u[h];
267
+ if (f != null && (t(f), ++e === s))
268
+ return e;
252
269
  }
253
270
  return e;
254
271
  }
255
272
  compact() {
256
273
  const t = this._overflow;
257
- if (t === null || t.length === 0) return;
258
- let s = 0;
259
- for (; s < t.length; ) if (t[s] === null) {
260
- for (; t.length > s && t[t.length - 1] === null; ) t.pop();
261
- t.length > s && (t[s] = t.pop(), s++);
262
- } else s++;
263
- this._freeIndices = null, t.length === 0 && (this._overflow = null);
274
+ if (t === null) return;
275
+ let s = t.length;
276
+ if (s === 0) return;
277
+ let e = 0;
278
+ for (; e < s; ) if (t[e] === null) {
279
+ for (; s > e && t[s - 1] === null; )
280
+ t.pop(), s--;
281
+ s > e && (t[e] = t.pop(), s--, e++);
282
+ } else e++;
283
+ this._freeIndices = null, s === 0 && (this._overflow = null);
264
284
  }
265
285
  clear() {
266
286
  this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null), this._freeIndices = null;
@@ -268,111 +288,170 @@ var y = {
268
288
  dispose() {
269
289
  this.clear();
270
290
  }
271
- }, W = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), lt = /* @__PURE__ */ Symbol("AtomEffect.Id"), K = /* @__PURE__ */ Symbol("AtomEffect.Type"), b = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), G = {
272
- enabled: !1,
273
- warnInfiniteLoop: tt.WARN_INFINITE_LOOP,
291
+ }, K = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), at = /* @__PURE__ */ Symbol("AtomEffect.Id"), Z = /* @__PURE__ */ Symbol("AtomEffect.Type"), P = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Et = class {
292
+ constructor() {
293
+ this.enabled = !1, this.warnInfiniteLoop = st.WARN_INFINITE_LOOP;
294
+ }
274
295
  warn(t, s) {
275
- },
296
+ }
276
297
  attachDebugInfo(t, s, e) {
277
- },
278
- getDebugName: (t) => t?.[W],
279
- getDebugType: (t) => t?.[K]
280
- }, _t = 1, ct = () => _t++;
281
- function g(t, s, e) {
282
- if (t instanceof T) return t;
283
- const i = t instanceof Error, n = i ? t.message : String(t), o = i ? t : void 0;
284
- return new s(`${i ? t.constructor.name : "Unexpected error"} (${e}): ${n}`, o);
298
+ }
299
+ getDebugName(t) {
300
+ if (t != null)
301
+ return t[K];
302
+ }
303
+ getDebugType(t) {
304
+ if (t != null)
305
+ return t[Z];
306
+ }
307
+ }, G = new Et(), dt = 1, pt = () => dt++ | 0;
308
+ function m(t, s, e) {
309
+ return t instanceof N ? t : t instanceof Error ? new s(`${t.name || t.constructor.name || "Error"} (${e}): ${t.message}`, t) : new s(`Unexpected error (${e}): ${String(t)}`);
285
310
  }
286
- var X = class {
311
+ var Q = class {
287
312
  constructor() {
288
- this.flags = 0, this.version = 0, this._lastSeenEpoch = p.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = ct() & st;
313
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = T.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = pt() & w;
314
+ }
315
+ get isDisposed() {
316
+ return (this.flags & H.DISPOSED) !== 0;
317
+ }
318
+ get isComputed() {
319
+ return (this.flags & H.IS_COMPUTED) !== 0;
320
+ }
321
+ get hasError() {
322
+ return !1;
289
323
  }
290
324
  subscribe(t) {
291
325
  const s = typeof t == "function";
292
- if (!s && (!t || typeof t.execute != "function")) throw g(/* @__PURE__ */ new TypeError("Invalid subscriber"), T, h.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
326
+ if (!s && (!t || typeof t.execute != "function")) throw m(/* @__PURE__ */ new TypeError("Invalid subscriber"), N, c.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
293
327
  let e = this._slots;
294
328
  e || (e = new et(), this._slots = e);
295
329
  let i = !1;
296
- if (e.forEach((o) => {
297
- (s ? o.fn === t : o.sub === t) && (i = !0);
298
- }), i)
330
+ if (e._s0 != null && (s ? e._s0.fn === t : e._s0.sub === t)) i = !0;
331
+ else if (e._s1 != null && (s ? e._s1.fn === t : e._s1.sub === t)) i = !0;
332
+ else if (e._s2 != null && (s ? e._s2.fn === t : e._s2.sub === t)) i = !0;
333
+ else if (e._s3 != null && (s ? e._s3.fn === t : e._s3.sub === t)) i = !0;
334
+ else {
335
+ const n = e._overflow;
336
+ if (n != null) for (let o = 0, u = n.length; o < u; o++) {
337
+ const h = n[o];
338
+ if (h != null && (s ? h.fn === t : h.sub === t)) {
339
+ i = !0;
340
+ break;
341
+ }
342
+ }
343
+ }
344
+ if (i)
299
345
  return () => {
300
346
  };
301
- const n = new ut(s ? t : void 0, s ? void 0 : t);
302
- return e.add(n), () => this._unsubscribe(n);
347
+ const r = new ft(s ? t : void 0, s ? void 0 : t);
348
+ return e.add(r), () => this._unsubscribe(r);
303
349
  }
304
350
  _unsubscribe(t) {
305
- if (this._slots) {
306
- if (this._notifying > 0) {
307
- this._slots.remove(t);
308
- return;
309
- }
310
- this._slots.remove(t), this._slots.compact();
311
- }
351
+ const s = this._slots;
352
+ s && (s.remove(t), this._notifying === 0 && s.compact());
312
353
  }
313
354
  subscriberCount() {
314
- return this._slots ? this._slots.size : 0;
355
+ const t = this._slots;
356
+ return t === null ? 0 : t.size;
315
357
  }
316
358
  _notifySubscribers(t, s) {
317
359
  const e = this._slots;
318
- if (!(!e || e.size === 0)) {
360
+ if (!(e === null || e.size === 0)) {
319
361
  this._notifying++;
320
362
  try {
321
- e.forEach((i) => {
322
- try {
323
- i.notify(t, s);
324
- } catch (n) {
325
- console.error(g(n, T, h.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
363
+ let i = e._s0;
364
+ if (i != null) try {
365
+ i.notify(t, s);
366
+ } catch (n) {
367
+ this._logNotifyError(n);
368
+ }
369
+ if (i = e._s1, i != null) try {
370
+ i.notify(t, s);
371
+ } catch (n) {
372
+ this._logNotifyError(n);
373
+ }
374
+ if (i = e._s2, i != null) try {
375
+ i.notify(t, s);
376
+ } catch (n) {
377
+ this._logNotifyError(n);
378
+ }
379
+ if (i = e._s3, i != null) try {
380
+ i.notify(t, s);
381
+ } catch (n) {
382
+ this._logNotifyError(n);
383
+ }
384
+ const r = e._overflow;
385
+ if (r != null) for (let n = 0, o = r.length; n < o; n++) {
386
+ const u = r[n];
387
+ if (u != null) try {
388
+ u.notify(t, s);
389
+ } catch (h) {
390
+ this._logNotifyError(h);
326
391
  }
327
- });
392
+ }
328
393
  } finally {
329
- this._notifying--, this._notifying === 0 && e.compact();
394
+ --this._notifying === 0 && e.compact();
330
395
  }
331
396
  }
332
397
  }
398
+ _logNotifyError(t) {
399
+ console.error(m(t, N, c.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
400
+ }
333
401
  _isDirty() {
334
402
  const t = this._deps;
335
- if (!t || t.size === 0) return !1;
336
- if (this._hotIndex !== -1) {
337
- const s = t.getAt(this._hotIndex);
338
- if (s != null && s.node.version !== s.version) return !0;
403
+ if (t === null || t.size === 0) return !1;
404
+ const s = this._hotIndex;
405
+ if (s !== -1) {
406
+ const e = t.getAt(s);
407
+ if (e != null && e.node.version !== e.version) return !0;
339
408
  }
340
409
  return !t.hasComputeds && !t.isDirtyFast() ? !1 : this._deepDirtyCheck();
341
410
  }
342
- }, U = 0, k = () => (U = U + 1 & 1073741823 || 1, U), H = (t) => t + 1 & 1073741823 || 1, V = 0, F = !1, it = 0, nt = () => it;
343
- function Z() {
344
- return F ? !1 : (F = !0, it = k(), V = 0, !0);
411
+ }, M = 0;
412
+ function Y() {
413
+ const t = M + 1 & w;
414
+ return M = t === 0 ? 1 : t, M;
415
+ }
416
+ function X(t) {
417
+ const s = t + 1 & w;
418
+ return s === 0 ? 1 : s;
345
419
  }
346
- var J = () => {
347
- F = !1;
348
- }, ft = () => {
349
- if (!F) return 0;
350
- const t = ++V;
351
- if (t > I.MAX_EXECUTIONS_PER_FLUSH) throw new Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${I.MAX_EXECUTIONS_PER_FLUSH}`);
352
- return t;
353
- }, w = /* @__PURE__ */ (function(t) {
354
- return t[t.IDLE = 0] = "IDLE", t[t.BATCHING = 1] = "BATCHING", t[t.FLUSHING = 2] = "FLUSHING", t;
355
- })({}), at = class {
420
+ var k = 0, R = !1, it = 0;
421
+ function nt() {
422
+ return it;
423
+ }
424
+ function J() {
425
+ return R ? !1 : (R = !0, it = Y(), k = 0, !0);
426
+ }
427
+ function tt() {
428
+ R = !1;
429
+ }
430
+ function Ct() {
431
+ if (!R) return 0;
432
+ const t = ++k;
433
+ if (t <= C.MAX_EXECUTIONS_PER_FLUSH) return t;
434
+ throw new Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${C.MAX_EXECUTIONS_PER_FLUSH}`);
435
+ }
436
+ var It = class {
356
437
  constructor() {
357
- this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = I.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
358
- }
359
- get phase() {
360
- return this._isProcessing || this._isFlushingSync ? w.FLUSHING : this._isBatching ? w.BATCHING : w.IDLE;
438
+ this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = C.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
361
439
  }
362
440
  get queueSize() {
363
441
  return this._size;
364
442
  }
365
443
  get isBatching() {
366
- return this._isBatching;
444
+ return this._batchDepth > 0;
367
445
  }
368
446
  schedule(t) {
369
- if (t._nextEpoch !== this._epoch) {
370
- if (t._nextEpoch = this._epoch, this._isBatching || this._isFlushingSync) {
371
- this._batchQueue[this._batchQueueSize++] = t;
372
- return;
373
- }
374
- this._queueBuffer[this._bufferIndex][this._size++] = t, this._isProcessing || this._flush();
447
+ const s = this._epoch;
448
+ if (t._nextEpoch === s) return;
449
+ if (t._nextEpoch = s, this._batchDepth > 0 || this._isFlushingSync) {
450
+ this._batchQueue[this._batchQueueSize++] = t;
451
+ return;
375
452
  }
453
+ const e = this._bufferIndex, i = this._queueBuffer[e];
454
+ i[this._size++] = t, this._isProcessing || this._flush();
376
455
  }
377
456
  _flush() {
378
457
  this._isProcessing || this._size === 0 || (this._isProcessing = !0, queueMicrotask(this._boundRunLoop));
@@ -380,30 +459,31 @@ var J = () => {
380
459
  _runLoop() {
381
460
  try {
382
461
  if (this._size === 0) return;
383
- const t = Z();
384
- this._drainQueue(), t && J();
462
+ const t = J();
463
+ this._drainQueue(), t && tt();
385
464
  } finally {
386
- this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
465
+ this._isProcessing = !1, this._size > 0 && this._batchDepth === 0 && this._flush();
387
466
  }
388
467
  }
389
468
  _flushSync() {
390
469
  this._isFlushingSync = !0;
391
- const t = Z();
470
+ const t = J();
392
471
  try {
393
472
  this._mergeBatchQueue(), this._drainQueue();
394
473
  } finally {
395
- this._isFlushingSync = !1, t && J();
474
+ this._isFlushingSync = !1, t && tt();
396
475
  }
397
476
  }
398
477
  _mergeBatchQueue() {
399
- if (this._batchQueueSize === 0) return;
400
- const t = ++this._epoch, s = this._batchQueue, e = this._queueBuffer[this._bufferIndex];
401
- let i = this._size;
402
- for (let n = 0; n < this._batchQueueSize; n++) {
403
- const o = s[n];
404
- o._nextEpoch !== t && (o._nextEpoch = t, e[i++] = o);
478
+ const t = this._batchQueueSize;
479
+ if (t === 0) return;
480
+ const s = ++this._epoch, e = this._batchQueue, i = this._bufferIndex, r = this._queueBuffer[i];
481
+ let n = this._size;
482
+ for (let o = 0; o < t; o++) {
483
+ const u = e[o];
484
+ u._nextEpoch !== s && (u._nextEpoch = s, r[n++] = u);
405
485
  }
406
- this._size = i, this._batchQueueSize = 0, s.length = 0;
486
+ this._size = n, this._batchQueueSize = 0, e.length = 0;
407
487
  }
408
488
  _drainQueue() {
409
489
  let t = 0;
@@ -417,34 +497,42 @@ var J = () => {
417
497
  }
418
498
  _processQueue() {
419
499
  const t = this._bufferIndex, s = this._queueBuffer[t], e = this._size;
420
- this._bufferIndex = t ^ 1, this._size = 0, this._epoch++;
421
- for (let i = 0; i < e; i++) try {
422
- const n = s[i];
423
- typeof n == "function" ? n() : n.execute();
424
- } catch (n) {
425
- console.error(new R("Error occurred during scheduler execution", n));
500
+ this._bufferIndex = t ^ 1, this._size = 0, this._epoch = this._epoch + 1 | 0;
501
+ for (let i = 0; i < e; i++) {
502
+ const r = s[i];
503
+ try {
504
+ typeof r == "function" ? r() : r.execute();
505
+ } catch (n) {
506
+ console.error(new L("Error occurred during scheduler execution", n));
507
+ }
426
508
  }
427
509
  s.length = 0;
428
510
  }
429
511
  _handleFlushOverflow() {
430
- const t = this._size + this._batchQueueSize;
431
- if (console.error(new R(h.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t))), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow) try {
432
- this.onOverflow(t);
512
+ const t = this._size + this._batchQueueSize, s = this._maxFlushIterations;
513
+ console.error(new L(c.SCHEDULER_FLUSH_OVERFLOW(s, t))), this._size = 0;
514
+ const e = this._bufferIndex;
515
+ this._queueBuffer[e].length = 0, this._batchQueueSize = 0;
516
+ const i = this.onOverflow;
517
+ if (i) try {
518
+ i(t);
433
519
  } catch {
434
520
  }
435
521
  }
436
522
  startBatch() {
437
- this._batchDepth++, this._isBatching = !0;
523
+ this._batchDepth++;
438
524
  }
439
525
  endBatch() {
440
- this._batchDepth !== 0 && --this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
526
+ this._batchDepth !== 0 && --this._batchDepth === 0 && this._flushSync();
441
527
  }
442
528
  setMaxFlushIterations(t) {
443
- if (t < I.MIN_FLUSH_ITERATIONS) throw new R(`Max flush iterations must be at least ${I.MIN_FLUSH_ITERATIONS}`);
529
+ if (t < C.MIN_FLUSH_ITERATIONS) throw new L(`Max flush iterations must be at least ${C.MIN_FLUSH_ITERATIONS}`);
444
530
  this._maxFlushIterations = t;
445
531
  }
446
- }, A = new at(), Q = /* @__PURE__ */ Symbol.for("atom-effect/atom"), rt = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ot = /* @__PURE__ */ Symbol.for("atom-effect/effect"), Et = /* @__PURE__ */ Symbol.for("atom-effect/writable"), _ = {
447
- current: null,
532
+ }, F = new It(), V = /* @__PURE__ */ Symbol.for("atom-effect/atom"), rt = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ot = /* @__PURE__ */ Symbol.for("atom-effect/effect"), Dt = /* @__PURE__ */ Symbol.for("atom-effect/writable"), vt = class {
533
+ constructor() {
534
+ this.current = null;
535
+ }
448
536
  run(t, s) {
449
537
  const e = this.current;
450
538
  this.current = t;
@@ -454,20 +542,26 @@ var J = () => {
454
542
  this.current = e;
455
543
  }
456
544
  }
457
- };
458
- function Dt(t) {
459
- const s = _.current;
460
- if (s === null) return t();
461
- _.current = null;
545
+ }, _ = new vt();
546
+ function Nt(t) {
547
+ const s = _, e = s.current;
548
+ if (e === null) return t();
549
+ s.current = null;
462
550
  try {
463
551
  return t();
464
552
  } finally {
465
- _.current = s;
553
+ s.current = e;
466
554
  }
467
555
  }
468
- var dt = class extends X {
556
+ var St = class extends Q {
469
557
  constructor(t, s) {
470
- super(), this[Q] = !0, this[Et] = !0, this._value = t, this._pendingOldValue = void 0, s && (this.flags |= a.SYNC), G.attachDebugInfo(this, "atom", this.id);
558
+ super(), this[V] = !0, this[Dt] = !0, this._value = t, s && (this.flags |= a.SYNC), G.attachDebugInfo(this, "atom", this.id);
559
+ }
560
+ get isNotificationScheduled() {
561
+ return (this.flags & a.NOTIFICATION_SCHEDULED) !== 0;
562
+ }
563
+ get isSync() {
564
+ return (this.flags & a.SYNC) !== 0;
471
565
  }
472
566
  get value() {
473
567
  const t = _.current;
@@ -476,31 +570,27 @@ var dt = class extends X {
476
570
  set value(t) {
477
571
  const s = this._value;
478
572
  if (Object.is(s, t)) return;
479
- this._value = t, this.version = H(this.version);
480
- const e = this._slots, i = this.flags;
481
- if (e == null || e.size === 0 || i & a.NOTIFICATION_SCHEDULED) return;
482
- this._pendingOldValue = s;
483
- const n = i | a.NOTIFICATION_SCHEDULED;
484
- if (this.flags = n, (n & a.SYNC) !== 0 && !A.isBatching) {
485
- this._flushNotifications();
486
- return;
487
- }
488
- A.schedule(this);
573
+ this._value = t, this.version = X(this.version);
574
+ const e = this.flags;
575
+ if ((e & a.NOTIFICATION_SCHEDULED) !== 0) return;
576
+ const i = this._slots;
577
+ i == null || i.size === 0 || (this._pendingOldValue = s, this.flags = e | a.NOTIFICATION_SCHEDULED, (e & a.SYNC) !== 0 && !F.isBatching ? this._flushNotifications() : F.schedule(this));
489
578
  }
490
579
  execute() {
491
580
  this._flushNotifications();
492
581
  }
493
582
  _flushNotifications() {
494
583
  const t = this.flags;
495
- if (!(t & a.NOTIFICATION_SCHEDULED) || t & a.DISPOSED) return;
584
+ if ((t & (a.NOTIFICATION_SCHEDULED | a.DISPOSED)) !== a.NOTIFICATION_SCHEDULED) return;
496
585
  const s = this._pendingOldValue;
497
- this._pendingOldValue = void 0, this.flags &= ~a.NOTIFICATION_SCHEDULED, this._notifySubscribers(this._value, s);
586
+ this._pendingOldValue = void 0, this.flags = t & ~a.NOTIFICATION_SCHEDULED, this._notifySubscribers(this._value, s);
498
587
  }
499
588
  peek() {
500
589
  return this._value;
501
590
  }
502
591
  dispose() {
503
- this.flags & a.DISPOSED || (this._slots?.clear(), this.flags |= a.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
592
+ const t = this.flags;
593
+ (t & a.DISPOSED) === 0 && (this._slots?.clear(), this.flags = t | a.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
504
594
  }
505
595
  _deepDirtyCheck() {
506
596
  return !1;
@@ -509,12 +599,12 @@ var dt = class extends X {
509
599
  this.dispose();
510
600
  }
511
601
  };
512
- function vt(t, s = {}) {
513
- return new dt(t, s.sync ?? !1);
602
+ function yt(t, s = {}) {
603
+ return new St(t, s.sync ?? !1);
514
604
  }
515
- var z = class extends et {
516
- constructor() {
517
- super(), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0, this._map = null, this.hasComputeds = !1, this._depsHash = 0;
605
+ var ut = class extends et {
606
+ constructor(...t) {
607
+ super(...t), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0;
518
608
  }
519
609
  prepareTracking() {
520
610
  this.hasComputeds = !1;
@@ -530,88 +620,101 @@ var z = class extends et {
530
620
  if (this._map !== null || i > this._SCAN_THRESHOLD) return this._claimViaMap(t, s);
531
621
  if (s < 4) switch (s) {
532
622
  case 0: {
533
- const r = this._s0;
534
- if (r && r.node === t && r.unsub)
535
- return r.version = t.version, !0;
623
+ const n = this._s0;
624
+ if (n && n.node === t && n.unsub)
625
+ return n.version = t.version, !0;
536
626
  }
537
627
  case 1:
538
628
  if (e > 1) {
539
- const r = this._s1;
540
- if (r && r.node === t && r.unsub)
541
- return r.version = t.version, s !== 1 && (this._s1 = this._s0, this._s0 = r), !0;
629
+ const n = this._s1;
630
+ if (n && n.node === t && n.unsub)
631
+ return n.version = t.version, s !== 1 && (this._s1 = this._s0, this._s0 = n), !0;
542
632
  }
543
633
  case 2:
544
634
  if (e > 2) {
545
- const r = this._s2;
546
- if (r && r.node === t && r.unsub) {
547
- if (r.version = t.version, s !== 2) {
548
- const u = s === 0 ? this._s0 : this._s1;
549
- s === 0 ? this._s0 = r : this._s1 = r, this._s2 = u;
635
+ const n = this._s2;
636
+ if (n && n.node === t && n.unsub) {
637
+ if (n.version = t.version, s !== 2) {
638
+ const o = s === 0 ? this._s0 : this._s1;
639
+ s === 0 ? this._s0 = n : this._s1 = n, this._s2 = o;
550
640
  }
551
641
  return !0;
552
642
  }
553
643
  }
554
644
  case 3:
555
645
  if (e > 3) {
556
- const r = this._s3;
557
- if (r && r.node === t && r.unsub) {
558
- if (r.version = t.version, s !== 3) {
559
- let u;
560
- s === 0 ? (u = this._s0, this._s0 = r) : s === 1 ? (u = this._s1, this._s1 = r) : (u = this._s2, this._s2 = r), this._s3 = u;
646
+ const n = this._s3;
647
+ if (n && n.node === t && n.unsub) {
648
+ if (n.version = t.version, s !== 3) {
649
+ let o;
650
+ s === 0 ? (o = this._s0, this._s0 = n) : s === 1 ? (o = this._s1, this._s1 = n) : (o = this._s2, this._s2 = n), this._s3 = o;
561
651
  }
562
652
  return !0;
563
653
  }
564
654
  }
565
655
  }
566
- const n = s > 4 ? s : 4, o = this._overflow;
567
- if (o) for (let r = n - 4, u = o.length; r < u; r++) {
568
- const l = o[r];
569
- if (l && l.node === t && l.unsub)
570
- return l.version = t.version, this._swapGeneral(r + 4, s, l), !0;
656
+ const r = this._overflow;
657
+ if (r) {
658
+ const n = t.version, o = s > 4 ? s : 4, u = r.length;
659
+ for (let h = o - 4; h < u; h++) {
660
+ const l = r[h];
661
+ if (l && l.node === t && l.unsub)
662
+ return l.version = n, this._swapGeneral(h + 4, s, l), !0;
663
+ }
571
664
  }
572
665
  return !1;
573
666
  }
574
667
  _claimViaMap(t, s) {
575
- if (this._map === null) {
576
- this._map = /* @__PURE__ */ new Map();
668
+ let e = this._map;
669
+ if (e === null) {
670
+ e = this._map = /* @__PURE__ */ new Map();
577
671
  const n = this._count;
578
- s < 4 && (s <= 0 && this._s0?.unsub && this._map.set(this._s0.node, 0), s <= 1 && this._s1?.unsub && this._map.set(this._s1.node, 1), s <= 2 && this._s2?.unsub && this._map.set(this._s2.node, 2), s <= 3 && this._s3?.unsub && this._map.set(this._s3.node, 3));
672
+ if (s < 4) {
673
+ const u = this._s0;
674
+ s <= 0 && u?.unsub && e.set(u.node, 0);
675
+ const h = this._s1;
676
+ s <= 1 && h?.unsub && e.set(h.node, 1);
677
+ const l = this._s2;
678
+ s <= 2 && l?.unsub && e.set(l.node, 2);
679
+ const f = this._s3;
680
+ s <= 3 && f?.unsub && e.set(f.node, 3);
681
+ }
579
682
  const o = this._overflow;
580
683
  if (o && n > 4) {
581
- const r = s > 4 ? s : 4;
582
- for (let u = r - 4, l = o.length; u < l; u++) {
583
- const O = o[u];
584
- O?.unsub && this._map.set(O.node, u + 4);
684
+ const u = s > 4 ? s : 4, h = o.length;
685
+ for (let l = u - 4; l < h; l++) {
686
+ const f = o[l];
687
+ f?.unsub && e.set(f.node, l + 4);
585
688
  }
586
689
  }
587
690
  }
588
- const e = this._map.get(t);
589
- if (e === void 0 || e < s) return !1;
590
- const i = this.getAt(e);
591
- if (i == null || !i.unsub) return !1;
592
- if (i.version = t.version, e !== s) {
593
- const n = this.getAt(s);
594
- this.setAt(s, i), this.setAt(e, n), n?.unsub && this._map.set(n.node, e), this._map.set(t, s);
691
+ const i = e.get(t);
692
+ if (i === void 0 || i < s) return !1;
693
+ const r = this.getAt(i);
694
+ if (r == null || !r.unsub) return !1;
695
+ if (r.version = t.version, i !== s) {
696
+ let n;
697
+ s === 0 ? n = this._s0 : s === 1 ? n = this._s1 : s === 2 ? n = this._s2 : s === 3 ? n = this._s3 : n = this._overflow[s - 4] ?? null, this.setAt(s, r), this.setAt(i, n), n?.unsub && e.set(n.node, i), e.set(t, s);
595
698
  }
596
699
  return !0;
597
700
  }
598
701
  _swapGeneral(t, s, e) {
599
702
  if (t === s) return;
600
- const i = this.getAt(s);
601
- if (this.setAt(s, e), t === 0) this._s0 = i;
703
+ let i;
704
+ if (s === 0 ? i = this._s0 : s === 1 ? i = this._s1 : s === 2 ? i = this._s2 : s === 3 ? i = this._s3 : i = this._overflow[s - 4] ?? null, this.setAt(s, e), t === 0) this._s0 = i;
602
705
  else if (t === 1) this._s1 = i;
603
706
  else if (t === 2) this._s2 = i;
604
707
  else if (t === 3) this._s3 = i;
605
708
  else {
606
- const n = this._overflow;
607
- n[t - 4] = i;
709
+ const r = this._overflow;
710
+ r[t - 4] = i;
608
711
  }
609
712
  }
610
713
  insertNew(t, s) {
611
714
  const e = this._count;
612
715
  if (t < e) {
613
- const i = this.getAt(t);
614
- i != null && (this._addToOverflow(i), this._map !== null && i.unsub && this._map.set(i.node, this._count - 1));
716
+ let i;
717
+ t === 0 ? i = this._s0 : t === 1 ? i = this._s1 : t === 2 ? i = this._s2 : t === 3 ? i = this._s3 : i = this._overflow[t - 4] ?? null, i != null && (this._addToOverflow(i), this._map !== null && i.unsub && this._map.set(i.node, this._count - 1));
615
718
  }
616
719
  if (t === 0) this._s0 = s;
617
720
  else if (t === 1) this._s1 = s;
@@ -627,70 +730,47 @@ var z = class extends et {
627
730
  t >= this._count || (super.truncateFrom(t), this._map !== null && (this._map.clear(), this._map = null));
628
731
  }
629
732
  seal() {
630
- const t = this._count;
631
- if (t === 0) {
632
- this._depsHash = 0;
633
- return;
634
- }
635
- const s = j.VERSION_BITS;
636
- let e = 0;
637
- if (t >= 1) {
638
- const i = this._s0;
639
- e = e + (i.version << s) + i.node.id | 0;
640
- }
641
- if (t >= 2) {
642
- const i = this._s1;
643
- e = e + (i.version << s) + i.node.id | 0;
644
- }
645
- if (t >= 3) {
646
- const i = this._s2;
647
- e = e + (i.version << s) + i.node.id | 0;
648
- }
649
- if (t >= 4) {
650
- const i = this._s3;
651
- e = e + (i.version << s) + i.node.id | 0;
652
- }
653
- if (t > 4) {
654
- const i = this._overflow;
655
- for (let n = 0, o = i.length; n < o; n++) {
656
- const r = i[n];
657
- e = e + (r.version << s) + r.node.id | 0;
658
- }
659
- }
660
- this._depsHash = e;
733
+ this._depsHash = this._calculateHash(!1);
661
734
  }
662
735
  isDirtyFast() {
663
- const t = this._count;
664
- if (t === 0) return !1;
665
- const s = j.VERSION_BITS;
666
- let e = 0;
667
- if (t >= 1) {
668
- const i = this._s0.node;
669
- e = e + (i.version << s) + i.id | 0;
670
- }
671
- if (t >= 2) {
672
- const i = this._s1.node;
673
- e = e + (i.version << s) + i.id | 0;
674
- }
675
- if (t >= 3) {
676
- const i = this._s2.node;
677
- e = e + (i.version << s) + i.id | 0;
678
- }
679
- if (t >= 4) {
680
- const i = this._s3.node;
681
- e = e + (i.version << s) + i.id | 0;
736
+ return this._calculateHash(!0) !== this._depsHash;
737
+ }
738
+ _calculateHash(t) {
739
+ const s = this._count;
740
+ if (s === 0) return 0;
741
+ const e = _t.VERSION_BITS;
742
+ let i = 0;
743
+ const r = this._s0;
744
+ if (r != null) {
745
+ const n = r.node, o = t ? n.version : r.version;
746
+ i = i + (o << e) + n.id | 0;
747
+ const u = this._s1;
748
+ if (s > 1 && u != null) {
749
+ const h = u.node, l = t ? h.version : u.version;
750
+ i = i + (l << e) + h.id | 0;
751
+ const f = this._s2;
752
+ if (s > 2 && f != null) {
753
+ const $ = f.node, lt = t ? $.version : f.version;
754
+ i = i + (lt << e) + $.id | 0;
755
+ const U = this._s3;
756
+ if (s > 3 && U != null) {
757
+ const q = U.node, ct = t ? q.version : U.version;
758
+ i = i + (ct << e) + q.id | 0;
759
+ }
760
+ }
761
+ }
682
762
  }
683
- if (t > 4) {
684
- const i = this._overflow;
685
- for (let n = 0, o = i.length; n < o; n++) {
686
- const r = i[n].node;
687
- e = e + (r.version << s) + r.id | 0;
763
+ if (s > 4) {
764
+ const n = this._overflow;
765
+ for (let o = 0, u = n.length; o < u; o++) {
766
+ const h = n[o], l = h.node, f = t ? l.version : h.version;
767
+ i = i + (f << e) + l.id | 0;
688
768
  }
689
769
  }
690
- return e !== this._depsHash;
770
+ return i;
691
771
  }
692
772
  disposeAll() {
693
- this._count > 0 && this.truncateFrom(0), this.hasComputeds = !1, this._map !== null && (this._map.clear(), this._map = null);
773
+ this._count > 0 && this.truncateFrom(0), this.hasComputeds = !1;
694
774
  }
695
775
  remove(t) {
696
776
  throw new Error("remove() is strictly prohibited in DepSlotBuffer to preserve sequential cache paths.");
@@ -698,47 +778,63 @@ var z = class extends et {
698
778
  compact() {
699
779
  }
700
780
  };
701
- function St(t) {
702
- return t !== null && typeof t == "object" && Q in t;
781
+ function At(t) {
782
+ return typeof t == "object" && t !== null && V in t;
703
783
  }
704
- function gt(t) {
705
- return t !== null && typeof t == "object" && rt in t;
784
+ function Ot(t) {
785
+ return typeof t == "object" && t !== null && rt in t;
706
786
  }
707
- function Tt(t) {
708
- return t !== null && typeof t == "object" && ot in t;
787
+ function bt(t) {
788
+ return typeof t == "object" && t !== null && ot in t;
709
789
  }
710
790
  function ht(t) {
711
- return t !== null && typeof t == "object" && typeof t.then == "function";
791
+ return typeof t == "object" && t !== null && typeof t.then == "function";
712
792
  }
713
- var { IDLE: d, DIRTY: f, PENDING: S, RESOLVED: E, REJECTED: C, HAS_ERROR: m, RECOMPUTING: N, DISPOSED: L, IS_COMPUTED: M, FORCE_COMPUTE: P } = B, pt = class extends X {
793
+ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, RECOMPUTING: y, DISPOSED: x, IS_COMPUTED: b, FORCE_COMPUTE: B } = H, gt = class extends Q {
714
794
  constructor(t, s = {}) {
715
- if (typeof t != "function") throw new v(h.COMPUTED_MUST_BE_FUNCTION);
716
- if (super(), this[Q] = !0, this[rt] = !0, this._error = null, this._promiseId = 0, this._deps = new z(), this._asyncRetryCount = 0, this._lastDriftEpoch = p.UNINITIALIZED, this._trackEpoch = p.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = M | f | d, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : b, this._onError = s.onError ?? null, this._maxAsyncRetries = (s.maxAsyncRetries ?? $.MAX_ASYNC_RETRIES) & st, G.attachDebugInfo(this, "computed", this.id), s.lazy === !1) try {
795
+ if (typeof t != "function") throw new S(c.COMPUTED_MUST_BE_FUNCTION);
796
+ if (super(), this[V] = !0, this[rt] = !0, this._error = null, this._promiseId = 0, this._deps = new ut(), this._asyncRetryCount = 0, this._lastDriftEpoch = T.UNINITIALIZED, this._trackEpoch = T.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = b | E | p, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : P, this._onError = s.onError ?? null, this._maxAsyncRetries = (s.maxAsyncRetries ?? j.MAX_ASYNC_RETRIES) & w, G.attachDebugInfo(this, "computed", this.id), s.lazy === !1) try {
717
797
  this._recompute();
718
798
  } catch {
719
799
  }
720
800
  }
801
+ get isDirty() {
802
+ return (this.flags & E) !== 0;
803
+ }
804
+ get isRejected() {
805
+ return (this.flags & D) !== 0;
806
+ }
807
+ get isRecomputing() {
808
+ return (this.flags & y) !== 0;
809
+ }
810
+ get _hasErrorInternal() {
811
+ return (this.flags & O) !== 0;
812
+ }
721
813
  _track() {
722
814
  _.current?.addDependency(this);
723
815
  }
724
816
  get value() {
725
- this._track();
726
- const t = this.flags;
727
- if ((t & (E | f | d)) === E) return this._value;
728
- if (t & L) throw new v(h.COMPUTED_DISPOSED);
729
- if (t & N) {
730
- if (this._defaultValue !== b) return this._defaultValue;
731
- throw new v(h.COMPUTED_CIRCULAR_DEPENDENCY);
817
+ const t = _.current;
818
+ t?.addDependency(this);
819
+ let s = this.flags;
820
+ if ((s & (d | E | p)) === d) return this._value;
821
+ if ((s & x) !== 0) throw new S(c.COMPUTED_DISPOSED);
822
+ if ((s & y) !== 0) {
823
+ const r = this._defaultValue;
824
+ if (r !== P) return r;
825
+ throw new S(c.COMPUTED_CIRCULAR_DEPENDENCY);
826
+ }
827
+ if ((s & (E | p)) !== 0) {
828
+ const r = this._deps;
829
+ if ((s & p) === 0 && (s & B) === 0 && r.size > 0 && !this._isDirty() ? s = this.flags &= ~E : (this._recompute(), s = this.flags), (s & d) !== 0) return this._value;
732
830
  }
733
- if (t & (f | d) && ((t & d) === 0 && (t & P) === 0 && this._deps.size > 0 && !this._isDirty() ? this.flags &= ~f : this._recompute(), this.flags & E))
734
- return this._value;
735
- const s = this._defaultValue, e = s !== b;
736
- if (this.flags & S) {
737
- if (e) return s;
738
- throw new v(h.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
831
+ const e = this._defaultValue, i = e !== P;
832
+ if ((s & g) !== 0) {
833
+ if (i) return e;
834
+ throw new S(c.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
739
835
  }
740
- if (this.flags & C) {
741
- if (e) return s;
836
+ if ((s & D) !== 0) {
837
+ if (i) return e;
742
838
  throw this._error;
743
839
  }
744
840
  return this._value;
@@ -747,78 +843,83 @@ var { IDLE: d, DIRTY: f, PENDING: S, RESOLVED: E, REJECTED: C, HAS_ERROR: m, REC
747
843
  return this._value;
748
844
  }
749
845
  get state() {
750
- this._track();
751
- const t = this.flags;
752
- return t & E ? y.RESOLVED : t & S ? y.PENDING : t & C ? y.REJECTED : y.IDLE;
846
+ const t = _.current;
847
+ t?.addDependency(this);
848
+ const s = this.flags;
849
+ return (s & d) !== 0 ? A.RESOLVED : (s & g) !== 0 ? A.PENDING : (s & D) !== 0 ? A.REJECTED : A.IDLE;
753
850
  }
754
851
  get hasError() {
755
- if (this._track(), this.flags & (C | m)) return !0;
756
- const t = this._deps;
757
- if (!t.hasComputeds) return !1;
758
- const s = t.size;
759
- for (let e = 0; e < s; e++) {
760
- const i = t.getAt(e);
761
- if (i != null && i.node.flags & m) return !0;
762
- }
852
+ const t = _.current;
853
+ if (t?.addDependency(this), (this.flags & (D | O)) !== 0) return !0;
854
+ const s = this._deps;
855
+ if (!s.hasComputeds) return !1;
856
+ const e = s.size;
857
+ for (let i = 0; i < e; i++) if (s.getAt(i)?.node.hasError) return !0;
763
858
  return !1;
764
859
  }
765
860
  get isValid() {
766
861
  return !this.hasError;
767
862
  }
768
863
  get errors() {
769
- this._track();
770
- const t = [];
771
- this._error && t.push(this._error);
772
- const s = this._deps;
773
- if (!s.hasComputeds) return t.length === 0 ? q : Object.freeze(t);
774
- const e = s.size;
775
- for (let i = 0; i < e; i++) {
776
- const n = s.getAt(i);
777
- if (n == null) continue;
778
- const o = n.node;
779
- o.flags & m && this._collectErrorsFromDep(o, t);
864
+ const t = _.current;
865
+ t?.addDependency(this);
866
+ const s = this._error, e = this._deps;
867
+ if (!e.hasComputeds)
868
+ return s == null ? W : Object.freeze([s]);
869
+ const i = [];
870
+ s != null && i.push(s);
871
+ const r = e.size;
872
+ for (let n = 0; n < r; n++) {
873
+ const o = e.getAt(n);
874
+ if (o == null) continue;
875
+ const u = o.node;
876
+ (u.flags & b) !== 0 && u.hasError && this._collectErrorsFromDep(u, i);
780
877
  }
781
- return t.length === 0 ? q : Object.freeze(t);
878
+ return i.length === 0 ? W : Object.freeze(i);
782
879
  }
783
880
  _collectErrorsFromDep(t, s) {
784
881
  const e = t.errors, i = e.length;
785
- for (let n = 0; n < i; n++) {
786
- const o = e[n];
787
- o != null && !s.includes(o) && s.push(o);
882
+ for (let r = 0; r < i; r++) {
883
+ const n = e[r];
884
+ n != null && !s.includes(n) && s.push(n);
788
885
  }
789
886
  }
790
887
  get lastError() {
791
- return this._track(), this._error;
888
+ const t = _.current;
889
+ return t?.addDependency(this), this._error;
792
890
  }
793
891
  get isPending() {
794
- return this._track(), (this.flags & S) !== 0;
892
+ const t = _.current;
893
+ return t?.addDependency(this), (this.flags & g) !== 0;
795
894
  }
796
895
  get isResolved() {
797
- return this._track(), (this.flags & E) !== 0;
896
+ const t = _.current;
897
+ return t?.addDependency(this), (this.flags & d) !== 0;
798
898
  }
799
899
  invalidate() {
800
- this.flags |= P, this._markDirty();
900
+ this.flags |= B, this._markDirty();
801
901
  }
802
902
  dispose() {
803
- this.flags & L || (this._deps.disposeAll(), this._slots?.clear(), this.flags = L | f | d, this._error = null, this._value = void 0, this._hotIndex = -1);
903
+ (this.flags & x) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = x | E | p, this._error = null, this._value = void 0, this._hotIndex = -1);
804
904
  }
805
905
  [Symbol.dispose]() {
806
906
  this.dispose();
807
907
  }
808
908
  addDependency(t) {
809
- if (t._lastSeenEpoch === this._trackEpoch) return;
810
- t._lastSeenEpoch = this._trackEpoch;
811
- const s = this._trackCount, e = this._deps.getAt(s);
812
- if (e != null && e.node === t) e.version = t.version;
813
- else if (!this._deps.claimExisting(t, s)) {
814
- const i = new x(t, t.version, t.subscribe(this));
815
- this._deps.insertNew(s, i);
909
+ const s = this._trackEpoch;
910
+ if (t._lastSeenEpoch === s) return;
911
+ t._lastSeenEpoch = s;
912
+ const e = this._trackCount++, i = this._deps, r = i.getAt(e);
913
+ if (r != null && r.node === t) r.version = t.version;
914
+ else if (!i.claimExisting(t, e)) {
915
+ const n = new z(t, t.version, t.subscribe(this));
916
+ i.insertNew(e, n);
816
917
  }
817
- t.flags & M && (this._deps.hasComputeds = !0), this._trackCount = s + 1;
918
+ (t.flags & b) !== 0 && (i.hasComputeds = !0);
818
919
  }
819
920
  _recompute() {
820
- if (this.flags & N) return;
821
- this.flags = (this.flags | N) & ~P, this._trackEpoch = k(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
921
+ if (this.isRecomputing) return;
922
+ this.flags = (this.flags | y) & ~B, this._trackEpoch = Y(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
822
923
  let t = !1;
823
924
  try {
824
925
  const s = _.run(this, this._fn);
@@ -828,42 +929,44 @@ var { IDLE: d, DIRTY: f, PENDING: S, RESOLVED: E, REJECTED: C, HAS_ERROR: m, REC
828
929
  this._deps.truncateFrom(this._trackCount);
829
930
  } catch {
830
931
  }
831
- this._handleError(s, h.COMPUTED_COMPUTATION_FAILED, !0);
932
+ this._handleError(s, c.COMPUTED_COMPUTATION_FAILED, !0);
832
933
  } finally {
833
- this._trackEpoch = p.UNINITIALIZED, this._trackCount = 0, this.flags &= ~N;
934
+ this._trackEpoch = T.UNINITIALIZED, this._trackCount = 0, this.flags &= ~y;
834
935
  }
835
936
  }
836
937
  _handleAsyncComputation(t) {
837
- this.flags = (this.flags | S) & ~(d | f | E | C), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % $.MAX_PROMISE_ID;
938
+ this.flags = (this.flags | g) & ~(p | E | d | D), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % j.MAX_PROMISE_ID;
838
939
  const s = this._promiseId;
839
940
  t.then((e) => {
840
941
  if (s === this._promiseId) {
841
942
  if (this._isDirty()) {
842
943
  const i = nt();
843
- return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new v(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), h.COMPUTED_ASYNC_COMPUTATION_FAILED);
944
+ return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new S(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), c.COMPUTED_ASYNC_COMPUTATION_FAILED);
844
945
  }
845
946
  this._finalizeResolution(e), this._notifySubscribers(e, void 0);
846
947
  }
847
- }, (e) => s === this._promiseId && this._handleError(e, h.COMPUTED_ASYNC_COMPUTATION_FAILED));
948
+ }, (e) => s === this._promiseId && this._handleError(e, c.COMPUTED_ASYNC_COMPUTATION_FAILED));
848
949
  }
849
950
  _handleError(t, s, e = !1) {
850
- const i = g(t, v, s);
851
- if (!e && !(this.flags & C) && (this.version = H(this.version)), this._error = i, this.flags = this.flags & ~(d | f | S | E) | C | m, this._onError) try {
951
+ const i = m(t, S, s);
952
+ if (!e && !this.isRejected && (this.version = X(this.version)), this._error = i, this.flags = this.flags & ~(p | E | g | d) | D | O, this._onError) try {
852
953
  this._onError(i);
853
- } catch (n) {
854
- console.error(h.CALLBACK_ERROR_IN_ERROR_HANDLER, n);
954
+ } catch (r) {
955
+ console.error(c.CALLBACK_ERROR_IN_ERROR_HANDLER, r);
855
956
  }
856
957
  if (e) throw i;
857
958
  this._notifySubscribers(void 0, void 0);
858
959
  }
859
960
  _finalizeResolution(t) {
860
- (!(this.flags & E) || !this._equal(this._value, t)) && (this.version = H(this.version)), this._value = t, this._error = null, this.flags = (this.flags | E) & ~(d | f | S | C | m);
961
+ const s = this.flags;
962
+ ((s & d) === 0 || !this._equal(this._value, t)) && (this.version = X(this.version)), this._value = t, this._error = null, this.flags = (s | d) & ~(p | E | g | D | O);
861
963
  }
862
964
  execute() {
863
965
  this._markDirty();
864
966
  }
865
967
  _markDirty() {
866
- this.flags & (N | f) || (this.flags |= f, this._notifySubscribers(void 0, void 0));
968
+ const t = this.flags;
969
+ (t & (y | E)) === 0 && (this.flags = t | E, this._notifySubscribers(void 0, void 0));
867
970
  }
868
971
  _isDirty() {
869
972
  const t = this._deps;
@@ -875,14 +978,14 @@ var { IDLE: d, DIRTY: f, PENDING: S, RESOLVED: E, REJECTED: C, HAS_ERROR: m, REC
875
978
  try {
876
979
  const e = t.size;
877
980
  for (let i = 0; i < e; i++) {
878
- const n = t.getAt(i);
879
- if (n == null) continue;
880
- const o = n.node;
881
- if (o.flags & M) try {
882
- o.value;
981
+ const r = t.getAt(i);
982
+ if (r == null) continue;
983
+ const n = r.node;
984
+ if ((n.flags & b) !== 0) try {
985
+ n.value;
883
986
  } catch {
884
987
  }
885
- if (o.version !== n.version)
988
+ if (n.version !== r.version)
886
989
  return this._hotIndex = i, !0;
887
990
  }
888
991
  return this._hotIndex = -1, !1;
@@ -891,64 +994,81 @@ var { IDLE: d, DIRTY: f, PENDING: S, RESOLVED: E, REJECTED: C, HAS_ERROR: m, REC
891
994
  }
892
995
  }
893
996
  };
894
- function mt(t, s = {}) {
895
- return new pt(t, s);
997
+ function Rt(t, s = {}) {
998
+ return new gt(t, s);
896
999
  }
897
- var It = class extends X {
1000
+ var Tt = class extends Q {
898
1001
  constructor(t, s = {}) {
899
- super(), this[ot] = !0, this._cleanup = null, this._deps = new z(), this._currentEpoch = p.UNINITIALIZED, this._lastFlushEpoch = p.UNINITIALIZED, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? I.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? I.MAX_EXECUTIONS_PER_EFFECT, this._cleanup = null, this._deps = new z(), this._currentEpoch = p.UNINITIALIZED, this._lastFlushEpoch = p.UNINITIALIZED, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => A.schedule(this), G.attachDebugInfo(this, "effect", this.id);
1002
+ super(), this[ot] = !0, this._cleanup = null, this._deps = new ut(), this._currentEpoch = T.UNINITIALIZED, this._lastFlushEpoch = T.UNINITIALIZED, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? C.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? C.MAX_EXECUTIONS_PER_EFFECT, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => F.schedule(this), G.attachDebugInfo(this, "effect", this.id);
900
1003
  }
901
1004
  run() {
902
- if (this.flags & c.DISPOSED) throw new D(h.EFFECT_DISPOSED);
1005
+ if (this.isDisposed) throw new v(c.EFFECT_DISPOSED);
903
1006
  this.execute(!0);
904
1007
  }
905
1008
  dispose() {
906
- this.flags & c.DISPOSED || (this.flags |= c.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
1009
+ this.isDisposed || (this.flags |= I.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
907
1010
  }
908
1011
  [Symbol.dispose]() {
909
1012
  this.dispose();
910
1013
  }
911
1014
  addDependency(t) {
912
- if (!(this.flags & c.EXECUTING)) return;
1015
+ if ((this.flags & I.EXECUTING) === 0) return;
913
1016
  const s = this._currentEpoch;
914
1017
  if (t._lastSeenEpoch === s) return;
915
1018
  t._lastSeenEpoch = s;
916
- const e = this._trackCount, i = this._deps;
917
- let n;
918
- e === 0 ? n = i._s0 : e === 1 ? n = i._s1 : e === 2 ? n = i._s2 : e === 3 ? n = i._s3 : n = i.getAt(e), n != null && n.node === t ? n.version = t.version : i.claimExisting(t, e) || this._insertNewDependency(t, e), t.flags & B.IS_COMPUTED && (i.hasComputeds = !0), this._trackCount = e + 1;
1019
+ const e = this._trackCount++, i = this._deps;
1020
+ let r;
1021
+ switch (e) {
1022
+ case 0:
1023
+ r = i._s0;
1024
+ break;
1025
+ case 1:
1026
+ r = i._s1;
1027
+ break;
1028
+ case 2:
1029
+ r = i._s2;
1030
+ break;
1031
+ case 3:
1032
+ r = i._s3;
1033
+ break;
1034
+ default:
1035
+ r = i.getAt(e);
1036
+ }
1037
+ r != null && r.node === t ? r.version = t.version : i.claimExisting(t, e) || this._insertNewDependency(t, e), t.isComputed && (i.hasComputeds = !0);
919
1038
  }
920
1039
  _insertNewDependency(t, s) {
921
1040
  let e;
922
1041
  try {
923
1042
  const i = t.subscribe(this._notifyCallback);
924
- e = new x(t, t.version, i);
1043
+ e = new z(t, t.version, i);
925
1044
  } catch (i) {
926
- const n = g(i, D, h.EFFECT_EXECUTION_FAILED);
927
- if (console.error(n), this._onError) try {
928
- this._onError(n);
1045
+ const r = m(i, v, c.EFFECT_EXECUTION_FAILED);
1046
+ if (console.error(r), this._onError) try {
1047
+ this._onError(r);
929
1048
  } catch {
930
1049
  }
931
- e = new x(t, t.version, void 0);
1050
+ e = new z(t, t.version, void 0);
932
1051
  }
933
1052
  this._deps.insertNew(s, e);
934
1053
  }
935
1054
  execute(t = !1) {
936
- if (this.flags & (c.DISPOSED | c.EXECUTING)) return;
937
- const s = this._deps;
938
- if (!t && s.size > 0 && !this._isDirty()) return;
939
- this._checkInfiniteLoops(), this.flags |= c.EXECUTING, this._execCleanup(), this._currentEpoch = k(), this._trackCount = 0, s.prepareTracking(), this._hotIndex = -1;
940
- let e = !1;
1055
+ const s = this.flags;
1056
+ if ((s & (I.DISPOSED | I.EXECUTING)) !== 0) return;
1057
+ const e = this._deps;
1058
+ if (!t && e.size > 0 && !this._isDirty()) return;
1059
+ this._checkInfiniteLoops(), this.flags = s | I.EXECUTING, this._execCleanup(), this._currentEpoch = Y(), this._trackCount = 0, e.prepareTracking(), this._hotIndex = -1;
1060
+ let i = !1;
941
1061
  try {
942
- const i = _.run(this, this._fn);
943
- s.truncateFrom(this._trackCount), s.seal(), e = !0, ht(i) ? this._handleAsyncResult(i) : this._cleanup = typeof i == "function" ? i : null;
944
- } catch (i) {
945
- if (!e) try {
946
- s.truncateFrom(this._trackCount);
1062
+ const r = _.run(this, this._fn);
1063
+ e.truncateFrom(this._trackCount), e.seal(), i = !0, ht(r) ? this._handleAsyncResult(r) : this._cleanup = typeof r == "function" ? r : null;
1064
+ } catch (r) {
1065
+ if (!i) try {
1066
+ e.truncateFrom(this._trackCount);
947
1067
  } catch {
948
1068
  }
949
- this._handleExecutionError(i), this._cleanup = null;
1069
+ this._handleExecutionError(r), this._cleanup = null;
950
1070
  } finally {
951
- this.flags &= ~c.EXECUTING;
1071
+ this.flags &= ~I.EXECUTING;
952
1072
  }
953
1073
  }
954
1074
  _isDirty() {
@@ -958,11 +1078,11 @@ var It = class extends X {
958
1078
  _handleAsyncResult(t) {
959
1079
  const s = ++this._execId;
960
1080
  t.then((e) => {
961
- if (s !== this._execId || this.flags & c.DISPOSED) {
1081
+ if (s !== this._execId || this.isDisposed) {
962
1082
  if (typeof e == "function") try {
963
1083
  e();
964
1084
  } catch (i) {
965
- this._handleExecutionError(i, h.EFFECT_CLEANUP_FAILED);
1085
+ this._handleExecutionError(i, c.EFFECT_CLEANUP_FAILED);
966
1086
  }
967
1087
  return;
968
1088
  }
@@ -976,10 +1096,10 @@ var It = class extends X {
976
1096
  try {
977
1097
  const e = s.size;
978
1098
  for (let i = 0; i < e; i++) {
979
- const n = s.getAt(i);
980
- if (n == null) continue;
981
- const o = n.node;
982
- if (o.flags & B.IS_COMPUTED && this._tryPullComputed(o), o.version !== n.version)
1099
+ const r = s.getAt(i);
1100
+ if (r == null) continue;
1101
+ const n = r.node;
1102
+ if (n.isComputed && this._tryPullComputed(n), n.version !== r.version)
983
1103
  return this._hotIndex = i, !0;
984
1104
  }
985
1105
  return !1;
@@ -994,85 +1114,84 @@ var It = class extends X {
994
1114
  }
995
1115
  }
996
1116
  _execCleanup() {
997
- if (this._cleanup) {
1117
+ const t = this._cleanup;
1118
+ if (t != null) {
1119
+ this._cleanup = null;
998
1120
  try {
999
- this._cleanup();
1000
- } catch (t) {
1001
- this._handleExecutionError(t, h.EFFECT_CLEANUP_FAILED);
1121
+ t();
1122
+ } catch (s) {
1123
+ this._handleExecutionError(s, c.EFFECT_CLEANUP_FAILED);
1002
1124
  }
1003
- this._cleanup = null;
1004
1125
  }
1005
1126
  }
1006
1127
  _checkInfiniteLoops() {
1007
1128
  const t = nt();
1008
- this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ft() > I.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
1129
+ this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Ct() > C.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
1009
1130
  }
1010
1131
  _checkFrequencyLimit() {
1011
1132
  if (!Number.isFinite(this._maxExecutions)) return;
1012
1133
  const t = Date.now();
1013
- if (t - this._windowStart >= tt.EFFECT_FREQUENCY_WINDOW) {
1134
+ if (t - this._windowStart >= st.EFFECT_FREQUENCY_WINDOW) {
1014
1135
  this._windowStart = t, this._windowCount = 1;
1015
1136
  return;
1016
1137
  }
1017
1138
  if (++this._windowCount > this._maxExecutions) {
1018
- const s = new D(h.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
1139
+ const s = new v(c.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
1019
1140
  throw this.dispose(), this._handleExecutionError(s), s;
1020
1141
  }
1021
1142
  }
1022
- get isDisposed() {
1023
- return (this.flags & c.DISPOSED) !== 0;
1024
- }
1025
1143
  get executionCount() {
1026
1144
  return this._executionCount;
1027
1145
  }
1028
1146
  get isExecuting() {
1029
- return (this.flags & c.EXECUTING) !== 0;
1147
+ return (this.flags & I.EXECUTING) !== 0;
1030
1148
  }
1031
1149
  _throwInfiniteLoopError(t) {
1032
- const s = new D(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${V}`);
1150
+ const s = new v(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${k}`);
1033
1151
  throw this.dispose(), console.error(s), s;
1034
1152
  }
1035
- _handleExecutionError(t, s = h.EFFECT_EXECUTION_FAILED) {
1036
- const e = g(t, D, s);
1153
+ _handleExecutionError(t, s = c.EFFECT_EXECUTION_FAILED) {
1154
+ const e = m(t, v, s);
1037
1155
  if (console.error(e), this._onError) try {
1038
1156
  this._onError(e);
1039
1157
  } catch (i) {
1040
- console.error(g(i, D, h.CALLBACK_ERROR_IN_ERROR_HANDLER));
1158
+ console.error(m(i, v, c.CALLBACK_ERROR_IN_ERROR_HANDLER));
1041
1159
  }
1042
1160
  }
1043
1161
  };
1044
- function Nt(t, s = {}) {
1045
- if (typeof t != "function") throw new D(h.EFFECT_MUST_BE_FUNCTION);
1046
- const e = new It(t, s);
1162
+ function Ft(t, s = {}) {
1163
+ if (typeof t != "function") throw new v(c.EFFECT_MUST_BE_FUNCTION);
1164
+ const e = new Tt(t, s);
1047
1165
  return e.execute(), e;
1048
1166
  }
1049
- function At(t) {
1050
- if (typeof t != "function") throw new TypeError(h.BATCH_CALLBACK_MUST_BE_FUNCTION);
1051
- A.startBatch();
1167
+ function wt(t) {
1168
+ if (typeof t != "function") throw new TypeError(c.BATCH_CALLBACK_MUST_BE_FUNCTION);
1169
+ const s = F;
1170
+ s.startBatch();
1052
1171
  try {
1053
1172
  return t();
1054
1173
  } finally {
1055
- A.endBatch();
1174
+ s.endBatch();
1056
1175
  }
1057
1176
  }
1058
1177
  export {
1059
- y as AsyncState,
1060
- T as AtomError,
1061
- v as ComputedError,
1062
- tt as DEBUG_CONFIG,
1178
+ A as AsyncState,
1179
+ N as AtomError,
1180
+ S as ComputedError,
1181
+ st as DEBUG_CONFIG,
1063
1182
  G as DEBUG_RUNTIME,
1064
- D as EffectError,
1065
- I as SCHEDULER_CONFIG,
1066
- R as SchedulerError,
1067
- vt as atom,
1068
- At as batch,
1069
- mt as computed,
1070
- Nt as effect,
1071
- St as isAtom,
1072
- gt as isComputed,
1073
- Tt as isEffect,
1074
- A as scheduler,
1075
- Dt as untracked
1183
+ v as EffectError,
1184
+ C as SCHEDULER_CONFIG,
1185
+ L as SchedulerError,
1186
+ yt as atom,
1187
+ wt as batch,
1188
+ Rt as computed,
1189
+ Ft as effect,
1190
+ At as isAtom,
1191
+ Ot as isComputed,
1192
+ bt as isEffect,
1193
+ F as scheduler,
1194
+ Nt as untracked
1076
1195
  };
1077
1196
 
1078
1197
  //# sourceMappingURL=index.mjs.map