@signaldb/oby 1.0.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 ADDED
@@ -0,0 +1,1100 @@
1
+ import { createReactivityAdapter as Et } from "@signaldb/core";
2
+ const xe = Symbol("Cached"), ce = Symbol("Observable"), Ge = Symbol("Observable.Boolean"), $e = Symbol("Observable.Frozen"), Te = Symbol("Observable.Readable"), Be = Symbol("Observable.Writable"), ne = Symbol("Store"), je = Symbol("Store.Keys"), We = Symbol("Store.Observable"), de = Symbol("Store.Target"), Pe = Symbol("Store.Values"), Ie = Symbol("Store.Untracked"), H = Symbol("Suspense"), Xe = Symbol("Uncached"), Ne = Symbol("Untracked"), Ze = Symbol("Untracked.Unwrapped"), wt = (e) => Q(e) ? e : [e], Ot = (e) => e instanceof Error ? e : typeof e == "string" ? new Error(e) : new Error("Unknown error"), { is: G } = Object, { isArray: Q } = Array, yt = (e, t) => {
3
+ if (e.length !== t.length)
4
+ return !1;
5
+ for (let s = 0, n = e.length; s < n; s++) {
6
+ const r = e[s], i = t[s];
7
+ if (!G(r, i))
8
+ return !1;
9
+ }
10
+ return !0;
11
+ }, _ = (e) => typeof e == "function", Le = (e) => e !== null && typeof e == "object", _t = (e) => typeof e == "symbol", Ce = () => {
12
+ }, ke = () => !1;
13
+ function Rt() {
14
+ if (arguments.length)
15
+ throw new Error("A readonly Observable can not be updated");
16
+ return this;
17
+ }
18
+ function mt() {
19
+ if (arguments.length)
20
+ throw new Error("A readonly Observable can not be updated");
21
+ return this.get();
22
+ }
23
+ function Mt(e) {
24
+ return arguments.length ? _(e) ? this.C(e) : this.set(e) : this.get();
25
+ }
26
+ const C = (e) => {
27
+ const t = Rt.bind(e);
28
+ return t[ce] = !0, t[$e] = !0, t;
29
+ }, F = (e) => {
30
+ const t = mt.bind(e);
31
+ return t[ce] = !0, t[Te] = e, t;
32
+ }, et = (e) => {
33
+ const t = Mt.bind(e);
34
+ return t[ce] = !0, t[Be] = e, t;
35
+ }, Je = 0, Ae = 1, be = 2, ge = 3, tt = C(!1), xt = C(!0), Ke = new Proxy({}, new Proxy({}, { get() {
36
+ throw new Error("Unavailable value");
37
+ } })), st = function() {
38
+ }, Re = (e, t) => {
39
+ if (e instanceof Array)
40
+ for (let s = 0, n = e.length; s < n; s++)
41
+ t(e[s]);
42
+ else e && t(e);
43
+ }, fe = (e, t) => {
44
+ if (e instanceof Array)
45
+ for (let s = e.length - 1; s >= 0; s--)
46
+ t(e[s]);
47
+ else e && t(e);
48
+ }, ue = (e, t, s) => {
49
+ const n = e[t];
50
+ n instanceof Array ? n.push(s) : n ? e[t] = [n, s] : e[t] = s;
51
+ }, q = (e, t, s) => {
52
+ const n = e[t];
53
+ if (n instanceof Set)
54
+ n.add(s);
55
+ else if (n) {
56
+ if (s !== n) {
57
+ const r = /* @__PURE__ */ new Set();
58
+ r.add(n), r.add(s), e[t] = r;
59
+ }
60
+ } else
61
+ e[t] = s;
62
+ }, J = (e, t, s) => {
63
+ const n = e[t];
64
+ n instanceof Set ? n.delete(s) : n === s && (e[t] = void 0);
65
+ }, re = (e, t) => {
66
+ if (e instanceof Set)
67
+ for (const s of e)
68
+ t(s);
69
+ else e && t(e);
70
+ }, Tt = (e) => e.call(e), me = (e) => e.Q(!0);
71
+ class le {
72
+ constructor() {
73
+ this.disposed = !1, this.B = void 0, this.S = void 0, this.D = void 0, this.K = void 0, this.T = void 0, this.U = void 0;
74
+ }
75
+ /* API */
76
+ catch(t, s) {
77
+ var r;
78
+ const { S: n } = this;
79
+ if (n)
80
+ return n(t), !0;
81
+ if ((r = this.parent) != null && r.catch(t, !0))
82
+ return !0;
83
+ if (s)
84
+ return !1;
85
+ throw t;
86
+ }
87
+ Q(t) {
88
+ fe(this.D, me), fe(this.K, me), fe(this.U, me), fe(this.B, Tt), this.B = void 0, this.disposed = t, this.S = void 0, this.K = void 0, this.U = void 0;
89
+ }
90
+ get(t) {
91
+ var s;
92
+ return (s = this.context) == null ? void 0 : s[t];
93
+ }
94
+ E(t, s, n) {
95
+ const r = g, i = Y;
96
+ Fe(s), Se(n);
97
+ try {
98
+ return t();
99
+ } catch (o) {
100
+ return this.catch(Ot(o), !1), Ke;
101
+ } finally {
102
+ Fe(r), Se(i);
103
+ }
104
+ }
105
+ }
106
+ class nt extends le {
107
+ constructor() {
108
+ super(...arguments), this.context = {};
109
+ }
110
+ }
111
+ let W, rt = new nt(), Y, g = rt;
112
+ const Ye = (e) => W = e, Se = (e) => Y = e, Fe = (e) => g = e;
113
+ let ae = 0, Ve = Ce;
114
+ const Bt = async (e) => {
115
+ ae || Ye(new Promise((t) => Ve = t));
116
+ try {
117
+ return ae += 1, await e();
118
+ } finally {
119
+ ae -= 1, ae || (Ye(void 0), Ve());
120
+ }
121
+ }, it = (e) => _(e) && Ge in e, ie = (e) => {
122
+ var t, s;
123
+ return _(e) && ($e in e || !!((s = (t = e[Te]) == null ? void 0 : t.parent) != null && s.disposed));
124
+ }, Ue = (e) => _(e) && (Ne in e || Ze in e);
125
+ let Pt = class {
126
+ constructor() {
127
+ this.A1 = [], this.M = 0, this.A2 = !1, this.N = () => {
128
+ if (!this.A2 && !this.M && this.A1.length)
129
+ try {
130
+ for (this.A2 = !0; ; ) {
131
+ const t = this.A1;
132
+ if (!t.length)
133
+ break;
134
+ this.A1 = [];
135
+ for (let s = 0, n = t.length; s < n; s++)
136
+ t[s].C();
137
+ }
138
+ } finally {
139
+ this.A2 = !1;
140
+ }
141
+ }, this.E = (t) => {
142
+ this.M += 1, t(), this.M -= 1, this.N();
143
+ }, this.F = (t) => {
144
+ this.A1.push(t);
145
+ };
146
+ }
147
+ };
148
+ const te = new Pt();
149
+ class N {
150
+ /* CONSTRUCTOR */
151
+ constructor(t, s, n) {
152
+ this.K = /* @__PURE__ */ new Set(), this.value = t, n && (this.parent = n), (s == null ? void 0 : s.equals) !== void 0 && (this.equals = s.equals || ke);
153
+ }
154
+ /* API */
155
+ get() {
156
+ var t, s;
157
+ return (t = this.parent) != null && t.disposed || ((s = this.parent) == null || s.C(), Y == null || Y.A.L(this)), this.value;
158
+ }
159
+ set(t) {
160
+ const s = this.equals || G;
161
+ return (this.value === st || !s(t, this.value)) && (this.value = t, te.M += 1, this.I(ge), te.M -= 1, te.N()), t;
162
+ }
163
+ I(t) {
164
+ for (const s of this.K)
165
+ (s.J !== Ae || s.A.has(this)) && (s.sync ? (s.J = Math.max(s.J, t), te.F(s)) : s.I(t));
166
+ }
167
+ C(t) {
168
+ const s = t(this.value);
169
+ return this.set(s);
170
+ }
171
+ }
172
+ class It {
173
+ /* CONSTRUCTOR */
174
+ constructor(t) {
175
+ this.observer = t, this.A = [], this.P = 0;
176
+ }
177
+ /* API */
178
+ Q(t) {
179
+ if (t) {
180
+ const { observer: s, A: n } = this;
181
+ for (let r = 0; r < n.length; r++)
182
+ n[r].K.delete(s);
183
+ }
184
+ this.P = 0;
185
+ }
186
+ R() {
187
+ const { observer: t, A: s, P: n } = this, r = s.length;
188
+ if (n < r) {
189
+ for (let i = n; i < r; i++)
190
+ s[i].K.delete(t);
191
+ s.length = n;
192
+ }
193
+ }
194
+ empty() {
195
+ return !this.A.length;
196
+ }
197
+ has(t) {
198
+ const s = this.A.indexOf(t);
199
+ return s >= 0 && s < this.P;
200
+ }
201
+ L(t) {
202
+ const { observer: s, A: n, P: r } = this, i = n.length;
203
+ if (i > 0) {
204
+ if (n[r] === t) {
205
+ this.P += 1;
206
+ return;
207
+ }
208
+ const o = n.indexOf(t);
209
+ if (o >= 0 && o < r)
210
+ return;
211
+ r < i - 1 ? this.R() : r === i - 1 && n[r].K.delete(s);
212
+ }
213
+ t.K.add(s), n[this.P++] = t, r === 128 && (s.A = new Nt(s, n));
214
+ }
215
+ C() {
216
+ var s;
217
+ const { A: t } = this;
218
+ for (let n = 0, r = t.length; n < r; n++)
219
+ (s = t[n].parent) == null || s.C();
220
+ }
221
+ }
222
+ class Nt {
223
+ /* CONSTRUCTOR */
224
+ constructor(t, s) {
225
+ this.observer = t, this.A = new Set(s);
226
+ }
227
+ /* API */
228
+ Q(t) {
229
+ for (const s of this.A)
230
+ s.K.delete(this.observer);
231
+ }
232
+ R() {
233
+ }
234
+ empty() {
235
+ return !this.A.size;
236
+ }
237
+ has(t) {
238
+ return this.A.has(t);
239
+ }
240
+ L(t) {
241
+ const { observer: s, A: n } = this, r = n.size;
242
+ t.K.add(s);
243
+ const i = n.size;
244
+ r !== i && n.add(t);
245
+ }
246
+ C() {
247
+ var t;
248
+ for (const s of this.A)
249
+ (t = s.parent) == null || t.C();
250
+ }
251
+ }
252
+ class ve extends le {
253
+ /* CONSTRUCTOR */
254
+ constructor() {
255
+ super(), this.parent = g, this.context = g.context, this.J = ge, this.A = new It(this), g !== rt && ue(this.parent, "K", this);
256
+ }
257
+ /* API */
258
+ Q(t) {
259
+ this.A.Q(t), super.Q(t);
260
+ }
261
+ H(t) {
262
+ this.Q(!1), this.J = Ae;
263
+ try {
264
+ return this.E(t, this, this);
265
+ } finally {
266
+ this.A.R();
267
+ }
268
+ }
269
+ run() {
270
+ throw new Error("Abstract method");
271
+ }
272
+ I(t) {
273
+ throw new Error("Abstract method");
274
+ }
275
+ C() {
276
+ this.disposed || (this.J === be && this.A.C(), this.J === ge ? (this.J = Ae, this.run(), this.J === Ae ? this.J = Je : this.C()) : this.J = Je);
277
+ }
278
+ }
279
+ class Lt extends ve {
280
+ /* CONSTRUCTOR */
281
+ constructor(t, s) {
282
+ super(), this.fn = t, this.observable = new N(st, s, this), (s == null ? void 0 : s.sync) === !0 && (this.sync = !0, this.C());
283
+ }
284
+ /* API */
285
+ run() {
286
+ const t = super.H(this.fn);
287
+ !this.disposed && this.A.empty() && (this.disposed = !0), t !== Ke && this.observable.set(t);
288
+ }
289
+ I(t) {
290
+ const s = this.J;
291
+ s >= t || (this.J = t, s !== be && this.observable.I(be));
292
+ }
293
+ }
294
+ const L = (e, t) => {
295
+ if (ie(e))
296
+ return e;
297
+ if (Ue(e))
298
+ return C(e());
299
+ {
300
+ const s = new Lt(e, t);
301
+ return F(s.observable);
302
+ }
303
+ }, De = (e) => {
304
+ if (_(e)) {
305
+ if (ie(e) || Ue(e))
306
+ return !!e();
307
+ if (it(e))
308
+ return e;
309
+ {
310
+ const t = L(() => !!e());
311
+ return t[Ge] = !0, t;
312
+ }
313
+ } else
314
+ return !!e;
315
+ }, D = (e) => {
316
+ ue(g, "B", e);
317
+ };
318
+ class Ct extends le {
319
+ /* CONSTRUCTOR */
320
+ constructor(t) {
321
+ super(), this.parent = g, this.context = { ...g.context, ...t }, ue(this.parent, "D", this);
322
+ }
323
+ /* API */
324
+ E(t) {
325
+ return super.E(t, this, void 0);
326
+ }
327
+ }
328
+ function Kt(e, t) {
329
+ return _t(e) ? g.context[e] : new Ct(e).E(t || Ce);
330
+ }
331
+ const Ut = () => {
332
+ const e = new N(!1);
333
+ return D(() => e.set(!0)), F(e);
334
+ };
335
+ class vt {
336
+ constructor() {
337
+ this.A1 = [], this.A2 = !1, this.A3 = !1, this.N = () => {
338
+ if (!this.A2 && this.A1.length)
339
+ try {
340
+ for (this.A2 = !0; ; ) {
341
+ const t = this.A1;
342
+ if (!t.length)
343
+ break;
344
+ this.A1 = [];
345
+ for (let s = 0, n = t.length; s < n; s++)
346
+ t[s].C();
347
+ }
348
+ } finally {
349
+ this.A2 = !1;
350
+ }
351
+ }, this.queue = () => {
352
+ this.A3 || (this.A3 = !0, this.resolve());
353
+ }, this.resolve = () => {
354
+ queueMicrotask(() => {
355
+ queueMicrotask(() => {
356
+ W ? W.finally(this.resolve) : (this.A3 = !1, this.N());
357
+ });
358
+ });
359
+ }, this.F = (t) => {
360
+ this.A1.push(t), this.queue();
361
+ };
362
+ }
363
+ }
364
+ const pe = new vt();
365
+ class ot extends ve {
366
+ /* CONSTRUCTOR */
367
+ constructor(t, s) {
368
+ if (super(), this.fn = t, (s == null ? void 0 : s.suspense) !== !1) {
369
+ const n = this.get(H);
370
+ n && (this.suspense = n);
371
+ }
372
+ (s == null ? void 0 : s.sync) === !0 && (this.sync = !0), (s == null ? void 0 : s.sync) === "init" ? (this.init = !0, this.C()) : this.F();
373
+ }
374
+ /* API */
375
+ run() {
376
+ const t = super.H(this.fn);
377
+ _(t) && ue(this, "B", t);
378
+ }
379
+ F() {
380
+ var t;
381
+ (t = this.suspense) != null && t.suspended || (this.sync ? this.C() : pe.F(this));
382
+ }
383
+ I(t) {
384
+ const s = this.J;
385
+ s >= t || (this.J = t, (!this.sync || s !== 2 && s !== 3) && this.F());
386
+ }
387
+ C() {
388
+ var t;
389
+ (t = this.suspense) != null && t.suspended || super.C();
390
+ }
391
+ }
392
+ const we = (e, t) => {
393
+ const s = new ot(e, t);
394
+ return () => s.Q(!0);
395
+ };
396
+ function O(e) {
397
+ if (_(e))
398
+ return Ze in e ? O(e()) : Ne in e ? C(O(e())) : ce in e ? e : L(() => O(e()));
399
+ if (e instanceof Array) {
400
+ const t = new Array(e.length);
401
+ for (let s = 0, n = t.length; s < n; s++)
402
+ t[s] = O(e[s]);
403
+ return t;
404
+ } else
405
+ return e;
406
+ }
407
+ class Oe extends le {
408
+ /* CONSTRUCTOR */
409
+ constructor(t) {
410
+ super(), this.parent = g, this.context = g.context, t && this.get(H) && (this.A0 = !0, q(this.parent, "T", this));
411
+ }
412
+ /* API */
413
+ Q(t) {
414
+ this.A0 && J(this.parent, "T", this), super.Q(t);
415
+ }
416
+ E(t) {
417
+ const s = () => this.Q(!0), n = () => t(s);
418
+ return super.E(n, this, void 0);
419
+ }
420
+ }
421
+ const Dt = C(-1);
422
+ let Qt = class extends Oe {
423
+ };
424
+ class qt {
425
+ /* CONSTRUCTOR */
426
+ constructor(t) {
427
+ this.parent = g, this.suspense = g.get(H), this.A5 = /* @__PURE__ */ new Map(), this.A6 = !1, this.A7 = 0, this.A8 = 0, this.A9 = 0, this.cleanup = () => {
428
+ if (!this.A7 || this.A7 === this.A8)
429
+ return;
430
+ const { A5: s, A6: n } = this;
431
+ s.size && (this.A9 ? s.forEach((r, i) => {
432
+ r.A6 !== n && (r.Q(!0), s.delete(i));
433
+ }) : (this.A5.forEach((r) => {
434
+ r.Q(!0);
435
+ }), this.A5 = /* @__PURE__ */ new Map()));
436
+ }, this.Q = () => {
437
+ this.suspense && J(this.parent, "T", this.T), this.A7 = this.A5.size, this.A8 = 0, this.A9 = 0, this.cleanup();
438
+ }, this.AA = () => {
439
+ this.A6 = !this.A6, this.A8 = 0, this.A9 = 0;
440
+ }, this.O = (s) => {
441
+ this.A9 = s.length, this.cleanup(), this.A7 = this.A9, this.A8 = 0;
442
+ }, this.map = (s) => {
443
+ var A;
444
+ this.AA();
445
+ const { A5: n, A6: r, fn: i, AB: o } = this, u = new Array(s.length);
446
+ let c = !0, h = !0, l = 0;
447
+ for (let f = 0, S = s.length; f < S; f++) {
448
+ const d = s[f], b = n.get(d);
449
+ if (b && b.A6 !== r)
450
+ h = !1, l += 1, b.A6 = r, (A = b.index) == null || A.set(f), u[f] = b.G;
451
+ else {
452
+ c = !1;
453
+ const p = new Qt(!1);
454
+ b && D(() => p.Q(!0)), p.E(() => {
455
+ let y = Dt;
456
+ o && (p.index = new N(f), y = F(p.index));
457
+ const j = u[f] = O(i(d, y));
458
+ p.A6 = r, p.G = j, b || n.set(d, p);
459
+ });
460
+ }
461
+ }
462
+ return this.A8 = l, this.O(s), c && (u[xe] = !0), h && (u[Xe] = !0), u;
463
+ }, this.T = () => Array.from(this.A5.values()), this.fn = t, this.AB = t.length > 1, this.suspense && q(this.parent, "T", this.T);
464
+ }
465
+ }
466
+ const Qe = (e) => _(e) && ce in e;
467
+ function X(e, t = !0) {
468
+ return (t ? _ : Qe)(e) ? e() : e;
469
+ }
470
+ class ct extends le {
471
+ /* CONSTRUCTOR */
472
+ constructor() {
473
+ var t;
474
+ super(), this.parent = g, this.context = { ...g.context, [H]: this }, ue(this.parent, "U", this), this.suspended = ((t = g.get(H)) == null ? void 0 : t.suspended) || 0;
475
+ }
476
+ /* API */
477
+ A4(t) {
478
+ var c;
479
+ if (!this.suspended && !t)
480
+ return;
481
+ const s = this.suspended, n = s + (t ? 1 : -1);
482
+ if (this.suspended = n, !!s == !!n)
483
+ return;
484
+ (c = this.observable) == null || c.set(!!n);
485
+ const r = (h) => {
486
+ Re(h.D, r), Re(h.K, i), Re(h.U, u), re(h.T, o);
487
+ }, i = (h) => {
488
+ h instanceof ot && (h.J === be || h.J === ge) && (h.init ? h.C() : h.F()), r(h);
489
+ }, o = (h) => {
490
+ _(h) ? h().forEach(r) : r(h);
491
+ }, u = (h) => {
492
+ h.A4(t);
493
+ };
494
+ r(this);
495
+ }
496
+ E(t) {
497
+ return super.E(t, this, void 0);
498
+ }
499
+ }
500
+ const ut = (e, t) => {
501
+ const s = new ct(), n = De(e);
502
+ return we(() => s.A4(X(n)), { sync: !0 }), s.E(t);
503
+ }, Jt = C(-1);
504
+ class Yt extends Oe {
505
+ }
506
+ class Ft {
507
+ /* CONSTRUCTOR */
508
+ constructor(t, s) {
509
+ this.parent = g, this.suspense = g.get(H), this.A5 = /* @__PURE__ */ new Map(), this.AC = [], this.AD = 0, this.cleanup = () => {
510
+ let n = 0, r = Math.max(0, this.pooled ? this.AD - this.AC.length : 0);
511
+ this.A5.forEach((i) => {
512
+ var o;
513
+ r > 0 && n++ < r ? ((o = i.suspended) == null || o.set(!0), this.AC.push(i)) : i.Q(!0);
514
+ });
515
+ }, this.Q = () => {
516
+ this.suspense && J(this.parent, "T", this.T), this.A5.forEach((n) => {
517
+ n.Q(!0);
518
+ }), this.AC.forEach((n) => {
519
+ n.Q(!0);
520
+ });
521
+ }, this.map = (n) => {
522
+ var d, b, p, y, j, he;
523
+ const { A5: r, fn: i, AB: o } = this, u = /* @__PURE__ */ new Map(), c = new Array(n.length), h = this.AC, l = this.pooled;
524
+ let A = !0, f = !0, S = [];
525
+ if (r.size)
526
+ for (let M = 0, E = n.length; M < E; M++) {
527
+ const x = n[M], T = r.get(x);
528
+ T ? (f = !1, r.delete(x), u.set(x, T), (d = T.index) == null || d.set(M), c[M] = T.G) : S.push(M);
529
+ }
530
+ else
531
+ S = new Array(c.length);
532
+ e: for (let M = 0, E = S.length; M < E; M++) {
533
+ const x = S[M] || M, T = n[x], V = u.has(T);
534
+ if (!V)
535
+ for (const [k, z] of r.entries()) {
536
+ r.delete(k), u.set(T, z), (b = z.index) == null || b.set(x), (p = z.value) == null || p.set(T), c[x] = z.G;
537
+ continue e;
538
+ }
539
+ A = !1;
540
+ let R;
541
+ l && h.length ? (R = h.pop(), (y = R.index) == null || y.set(x), (j = R.value) == null || j.set(T), (he = R.suspended) == null || he.set(!1), c[x] = R.G) : (R = new Yt(!1), R.E(() => {
542
+ let k = Jt;
543
+ o && (R.index = new N(x), k = F(R.index));
544
+ const z = R.value = new N(T), _e = l ? new N(!1) : void 0, qe = L(() => X(z.get())), pt = c[x] = _e ? ut(() => _e.get(), () => O(i(qe, k))) : O(i(qe, k));
545
+ R.value = z, R.G = pt, R.suspended = _e;
546
+ })), V ? D(() => R.Q(!0)) : u.set(T, R);
547
+ }
548
+ return this.AD = Math.max(this.AD, c.length), this.cleanup(), this.A5 = u, A && (c[xe] = !0), f && (c[Xe] = !0), c;
549
+ }, this.T = () => [...this.A5.values(), ...this.AC.values()], this.fn = t, this.AB = t.length > 1, this.pooled = s, this.suspense && q(this.parent, "T", this.T);
550
+ }
551
+ }
552
+ const B = (e) => Le(e) && ne in e;
553
+ function K(e) {
554
+ if (_(e)) {
555
+ const t = Y;
556
+ if (t)
557
+ try {
558
+ return Se(void 0), e();
559
+ } finally {
560
+ Se(t);
561
+ }
562
+ else
563
+ return e();
564
+ } else
565
+ return e;
566
+ }
567
+ function Vt(e, t, s = [], n) {
568
+ if (Q(e) && !B(e)) {
569
+ const r = !!(n != null && n.unkeyed);
570
+ return C(K(() => e.length ? e.map((i, o) => O(t(r && !Qe(i) ? C(i) : i, o))) : O(s)));
571
+ } else {
572
+ const { Q: r, map: i } = n != null && n.unkeyed ? new Ft(t, !!n.pooled) : new qt(t);
573
+ D(r);
574
+ const o = L(() => X(e) ?? [], {
575
+ equals: (u, c) => !!u && !!c && !u.length && !c.length && !B(u) && !B(c)
576
+ });
577
+ return L(() => {
578
+ const u = o();
579
+ return B(u) && u[Pe], K(() => {
580
+ const c = i(u);
581
+ return c != null && c.length ? c : O(s);
582
+ });
583
+ }, {
584
+ equals: (u, c) => Q(u) && !!u[xe] && Q(c) && yt(u, c)
585
+ });
586
+ }
587
+ }
588
+ const lt = (e) => (K(e), e), Me = (e, t, s) => {
589
+ for (let n = 0, r = t.length; n < r; n++) {
590
+ const i = t[n];
591
+ if (i.length === 1)
592
+ return i[0];
593
+ if (G(i[0], e))
594
+ return i[1];
595
+ }
596
+ return s;
597
+ };
598
+ function ht(e, t, s) {
599
+ if (_(e) && !ie(e) && !Ue(e)) {
600
+ if (it(e))
601
+ return L(() => O(Me(e(), t, s)));
602
+ const r = lt(L(() => Me(e(), t, s)));
603
+ return ie(r) ? C(O(r())) : L(() => O(X(r)));
604
+ } else {
605
+ const r = Me(X(e), t, s);
606
+ return C(O(r));
607
+ }
608
+ }
609
+ const ft = (e, t, s) => {
610
+ const n = De(e);
611
+ return ht(n, [[!0, t], [s]]);
612
+ };
613
+ function zt(e, t, s) {
614
+ return ft(e, t, s);
615
+ }
616
+ const at = () => !!W || pe.A3 || pe.A2 || te.A2;
617
+ function At(e, t) {
618
+ return et(new N(e, t));
619
+ }
620
+ const dt = () => {
621
+ const e = g instanceof nt, t = g instanceof Oe, s = g instanceof ct, n = g instanceof ve;
622
+ return { isSuperRoot: e, isRoot: t, isSuspense: s, isComputation: n };
623
+ }, Ht = (e) => _(e) && Be in e, Gt = (e) => _(e) ? e[Te] || e[Be] || Ke : e, $t = (e) => Ht(e) ? F(Gt(e)) : e, jt = (e) => new Oe(!0).E(e);
624
+ class Wt extends Map {
625
+ constructor() {
626
+ super(...arguments), this.disposed = !1;
627
+ }
628
+ }
629
+ class Xt extends N {
630
+ constructor() {
631
+ super(...arguments), this.AE = 1;
632
+ }
633
+ /* API */
634
+ call() {
635
+ this.AF.disposed || (this.AE -= 1, !this.AE && this.AF.delete(this.AG));
636
+ }
637
+ }
638
+ const Zt = (e) => {
639
+ if (e = lt(L(e)), ie(e)) {
640
+ const r = K(e);
641
+ return (i) => i === r ? xt : tt;
642
+ }
643
+ let t = new Wt(), s = K(e);
644
+ return we(() => {
645
+ var o, u;
646
+ const r = s, i = e();
647
+ G(r, i) || (s = i, (o = t.get(r)) == null || o.set(!1), (u = t.get(i)) == null || u.set(!0));
648
+ }, { suspense: !1, sync: !0 }), D(() => {
649
+ t.disposed = !0;
650
+ }), (r) => {
651
+ let i = t.get(r);
652
+ return i ? i.AE += 1 : (i = new Xt(r === s), i.AF = t, i.AG = r, t.set(r, i)), D(i), F(i);
653
+ };
654
+ };
655
+ class U extends Map {
656
+ AH(t, s) {
657
+ return super.set(t, s), s;
658
+ }
659
+ }
660
+ class ye {
661
+ constructor() {
662
+ this.AE = 0;
663
+ }
664
+ listen() {
665
+ this.AE += 1, D(this);
666
+ }
667
+ call() {
668
+ this.AE -= 1, !this.AE && this.Q();
669
+ }
670
+ Q() {
671
+ }
672
+ }
673
+ class kt extends ye {
674
+ constructor(t, s) {
675
+ super(), this.parent = t, this.observable = s;
676
+ }
677
+ Q() {
678
+ this.parent.keys = void 0;
679
+ }
680
+ }
681
+ class es extends ye {
682
+ constructor(t, s) {
683
+ super(), this.parent = t, this.observable = s;
684
+ }
685
+ Q() {
686
+ this.parent.values = void 0;
687
+ }
688
+ }
689
+ class ts extends ye {
690
+ constructor(t, s, n) {
691
+ super(), this.parent = t, this.key = s, this.observable = n;
692
+ }
693
+ Q() {
694
+ var t;
695
+ (t = this.parent.has) == null || t.delete(this.key);
696
+ }
697
+ }
698
+ class ss extends ye {
699
+ constructor(t, s, n, r) {
700
+ super(), this.parent = t, this.key = s, this.observable = n, this.AI = r;
701
+ }
702
+ Q() {
703
+ var t;
704
+ (t = this.parent.AJ) == null || t.delete(this.key);
705
+ }
706
+ }
707
+ const m = {
708
+ /* VARIABLES */
709
+ AK: 0,
710
+ AL: /* @__PURE__ */ new Set(),
711
+ AM: /* @__PURE__ */ new Set(),
712
+ /* API */
713
+ AN: () => {
714
+ const { AL: e, AM: t } = m, s = /* @__PURE__ */ new Set(), n = (r) => {
715
+ s.has(r) || (s.add(r), re(r.AO, n), re(r.AP, (i) => {
716
+ e.add(i);
717
+ }));
718
+ };
719
+ return t.forEach(n), () => {
720
+ e.forEach((r) => {
721
+ r();
722
+ });
723
+ };
724
+ },
725
+ V: (e) => {
726
+ m.AM.add(e), I.F();
727
+ },
728
+ reset: () => {
729
+ m.AL = /* @__PURE__ */ new Set(), m.AM = /* @__PURE__ */ new Set();
730
+ }
731
+ }, w = {
732
+ /* VARIABLES */
733
+ AK: 0,
734
+ AM: /* @__PURE__ */ new Map(),
735
+ /* API */
736
+ AN: () => {
737
+ const { AM: e } = w;
738
+ return () => {
739
+ e.forEach((t, s) => {
740
+ const n = Array.from(t);
741
+ re(s.AQ, (r) => {
742
+ r(n);
743
+ });
744
+ });
745
+ };
746
+ },
747
+ V: (e, t) => {
748
+ const s = w.AM.get(e) || /* @__PURE__ */ new Set();
749
+ s.add(t), w.AM.set(e, s), I.F();
750
+ },
751
+ AR: (e, t, s) => {
752
+ if (t.AO) {
753
+ const n = /* @__PURE__ */ new Set(), r = (i) => {
754
+ n.has(i) || (n.add(i), re(i.AO, (o) => {
755
+ o.AO || w.V(o, i.store), r(o);
756
+ }));
757
+ };
758
+ r(e || t);
759
+ } else {
760
+ const n = (e == null ? void 0 : e.store) || K(() => t.store[s]);
761
+ w.V(t, n);
762
+ }
763
+ },
764
+ reset: () => {
765
+ w.AM = /* @__PURE__ */ new Map();
766
+ }
767
+ }, I = {
768
+ /* VARIABLES */
769
+ AK: !1,
770
+ /* API */
771
+ N: () => {
772
+ const e = m.AN(), t = w.AN();
773
+ I.reset(), e(), t();
774
+ },
775
+ AS: () => {
776
+ at() ? W ? W.finally(I.AS) : setTimeout(I.AS, 0) : I.N();
777
+ },
778
+ reset: () => {
779
+ I.AK = !1, m.reset(), w.reset();
780
+ },
781
+ F: () => {
782
+ I.AK || (I.AK = !0, queueMicrotask(I.AS));
783
+ }
784
+ }, Z = /* @__PURE__ */ new WeakMap(), ns = /* @__PURE__ */ new Set([ne, je, We, de, Pe]), rs = /* @__PURE__ */ new Set(["__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__", "prototype", "constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString", "toSource", "toString", "valueOf"]), bt = {
785
+ /* API */
786
+ get: (e, t) => {
787
+ var c, h;
788
+ if (ns.has(t)) {
789
+ if (t === ne)
790
+ return !0;
791
+ if (t === de)
792
+ return e;
793
+ if (t === je) {
794
+ if (ee()) {
795
+ const l = P(e);
796
+ l.keys || (l.keys = ze(l)), l.keys.listen(), l.keys.observable.get();
797
+ }
798
+ return;
799
+ }
800
+ if (t === Pe) {
801
+ if (ee()) {
802
+ const l = P(e);
803
+ l.values || (l.values = os(l)), l.values.listen(), l.values.observable.get();
804
+ }
805
+ return;
806
+ }
807
+ if (t === We)
808
+ return (l) => {
809
+ var y;
810
+ l = typeof l == "number" ? String(l) : l;
811
+ const A = P(e), f = (y = A.AT) == null ? void 0 : y.get(l);
812
+ if (f)
813
+ return f.bind(A.store);
814
+ A.AJ || (A.AJ = new U());
815
+ const S = e[l], d = A.AJ.get(l) || A.AJ.AH(l, He(A, l, S)), b = A.equals ? { equals: A.equals } : void 0;
816
+ return d.observable || (d.observable = oe(A, S, b)), F(d.observable);
817
+ };
818
+ }
819
+ if (rs.has(t))
820
+ return e[t];
821
+ const s = P(e), n = (c = s.AT) == null ? void 0 : c.get(t), r = n || e[t];
822
+ s.AJ || (s.AJ = new U());
823
+ const i = ee(), o = se(r), u = i || o ? s.AJ.get(t) || s.AJ.AH(t, He(s, t, r)) : void 0;
824
+ if (u != null && u.AI && q(u.AI, "AO", s), u && i) {
825
+ const l = s.equals ? { equals: s.equals } : void 0;
826
+ u.listen(), u.observable || (u.observable = oe(s, r, l)), u.observable.get();
827
+ }
828
+ return n ? n.call(s.store) : typeof r == "function" && r === Array.prototype[t] ? function() {
829
+ return r.apply(s.store, arguments);
830
+ } : ((h = u == null ? void 0 : u.AI) == null ? void 0 : h.store) || r;
831
+ },
832
+ set: (e, t, s) => {
833
+ var i, o, u, c, h, l, A, f, S, d;
834
+ s = v(s);
835
+ const n = P(e), r = (i = n.AU) == null ? void 0 : i.get(t);
836
+ if (r)
837
+ r.call(n.store, s);
838
+ else {
839
+ const b = Q(e), p = e[t], y = !!p || t in e, j = n.equals || G;
840
+ if (y && j(s, p) && (t !== "length" || !b))
841
+ return !0;
842
+ const he = b && e.length;
843
+ e[t] = s;
844
+ const M = b && e.length;
845
+ b && t !== "length" && he !== M && ((c = (u = (o = n.AJ) == null ? void 0 : o.get("length")) == null ? void 0 : u.observable) == null || c.set(M)), (h = n.values) == null || h.observable.set(0), y || ((l = n.keys) == null || l.observable.set(0), (f = (A = n.has) == null ? void 0 : A.get(t)) == null || f.observable.set(!0));
846
+ const E = (S = n.AJ) == null ? void 0 : S.get(t);
847
+ if (E != null && E.AI && J(E.AI, "AO", n), E && ((d = E.observable) == null || d.set(s), E.AI = se(s) ? Z.get(s) || Ee(s, t, n) : void 0), E != null && E.AI && q(E.AI, "AO", n), w.AK && w.AR(E == null ? void 0 : E.AI, n, t), m.AK && m.V(n), b && t === "length") {
848
+ const x = Number(p), T = Number(s);
849
+ for (let V = T; V < x; V++)
850
+ V in e || bt.deleteProperty(e, `${V}`, !0);
851
+ }
852
+ }
853
+ return !0;
854
+ },
855
+ deleteProperty: (e, t, s) => {
856
+ var u, c, h, l, A, f, S, d;
857
+ const n = t in e;
858
+ if (!s && !n)
859
+ return !0;
860
+ if (!Reflect.deleteProperty(e, t))
861
+ return !1;
862
+ const i = P(e);
863
+ (u = i.AT) == null || u.delete(t), (c = i.AU) == null || c.delete(t), (h = i.keys) == null || h.observable.set(0), (l = i.values) == null || l.observable.set(0), (f = (A = i.has) == null ? void 0 : A.get(t)) == null || f.observable.set(!1);
864
+ const o = (S = i.AJ) == null ? void 0 : S.get(t);
865
+ return w.AK && w.AR(o == null ? void 0 : o.AI, i, t), o != null && o.AI && J(o.AI, "AO", i), o && ((d = o.observable) == null || d.set(void 0), o.AI = void 0), m.AK && m.V(i), !0;
866
+ },
867
+ defineProperty: (e, t, s) => {
868
+ var h, l, A, f, S, d, b, p;
869
+ const n = P(e), r = n.equals || G, i = t in e, o = Reflect.getOwnPropertyDescriptor(e, t);
870
+ if ("value" in s && B(s.value) && (s = { ...s, value: v(s.value) }), o && fs(o, s, r))
871
+ return !0;
872
+ if (!Reflect.defineProperty(e, t, s))
873
+ return !1;
874
+ s.get ? s.get && (n.AT || (n.AT = new U()), n.AT.set(t, s.get)) : (h = n.AT) == null || h.delete(t), s.set ? s.set && (n.AU || (n.AU = new U()), n.AU.set(t, s.set)) : (l = n.AU) == null || l.delete(t), i !== !!s.enumerable && ((A = n.keys) == null || A.observable.set(0)), (S = (f = n.has) == null ? void 0 : f.get(t)) == null || S.observable.set(!0);
875
+ const c = (d = n.AJ) == null ? void 0 : d.get(t);
876
+ if (w.AK && w.AR(c == null ? void 0 : c.AI, n, t), c != null && c.AI && J(c.AI, "AO", n), c)
877
+ if ("get" in s)
878
+ (b = c.observable) == null || b.set(s.get), c.AI = void 0;
879
+ else {
880
+ const y = s.value;
881
+ (p = c.observable) == null || p.set(y), c.AI = se(y) ? Z.get(y) || Ee(y, t, n) : void 0;
882
+ }
883
+ return c != null && c.AI && q(c.AI, "AO", n), w.AK && w.AR(c == null ? void 0 : c.AI, n, t), m.AK && m.V(n), !0;
884
+ },
885
+ has: (e, t) => {
886
+ if (t === ne || t === de)
887
+ return !0;
888
+ const s = t in e;
889
+ if (ee()) {
890
+ const n = P(e);
891
+ n.has || (n.has = new U());
892
+ const r = n.has.get(t) || n.has.AH(t, cs(n, t, s));
893
+ r.listen(), r.observable.get();
894
+ }
895
+ return s;
896
+ },
897
+ ownKeys: (e) => {
898
+ const t = Reflect.ownKeys(e);
899
+ if (ee()) {
900
+ const s = P(e);
901
+ s.keys || (s.keys = ze(s)), s.keys.listen(), s.keys.observable.get();
902
+ }
903
+ return t;
904
+ }
905
+ }, is = {
906
+ /* API */
907
+ has: (e, t) => t === Ie ? !0 : t in e
908
+ }, Ee = (e, t, s, n) => {
909
+ if (B(e))
910
+ return P(v(e));
911
+ const r = as(e, t, s) ? e : new Proxy(e, bt), i = us(e), o = { AO: s, store: r };
912
+ if (i) {
913
+ const { AT: u, AU: c } = i;
914
+ u && (o.AT = u), c && (o.AU = c);
915
+ }
916
+ return n === !1 ? o.equals = ke : n ? o.equals = n : s != null && s.equals && (o.equals = s.equals), Z.set(e, o), o;
917
+ }, P = (e) => {
918
+ const t = Z.get(e);
919
+ if (!t)
920
+ throw new Error("Impossible");
921
+ return t;
922
+ }, gt = (e) => P(v(e)), ze = (e) => {
923
+ const t = oe(e, 0, { equals: !1 });
924
+ return new kt(e, t);
925
+ }, os = (e) => {
926
+ const t = oe(e, 0, { equals: !1 });
927
+ return new es(e, t);
928
+ }, cs = (e, t, s) => {
929
+ const n = oe(e, s);
930
+ return new ts(e, t, n);
931
+ }, oe = (e, t, s) => new N(t, s), He = (e, t, s) => {
932
+ const r = se(s) ? Z.get(s) || Ee(s, t, e) : void 0, i = new ss(e, t, void 0, r);
933
+ return e.AJ || (e.AJ = new U()), e.AJ.set(t, i), i;
934
+ }, us = (e) => {
935
+ if (Q(e))
936
+ return;
937
+ let t, s;
938
+ const n = Object.keys(e);
939
+ for (let r = 0, i = n.length; r < i; r++) {
940
+ const o = n[r], u = Object.getOwnPropertyDescriptor(e, o);
941
+ if (!u)
942
+ continue;
943
+ const { get: c, set: h } = u;
944
+ c && (t || (t = new U()), t.set(o, c)), h && (s || (s = new U()), s.set(o, h)), c && !h && (s || (s = new U()), s.set(o, As));
945
+ }
946
+ if (!(!t && !s))
947
+ return { AT: t, AU: s };
948
+ }, ls = (e, t) => B(e) ? e : (Z.get(e) || Ee(e, void 0, void 0, t == null ? void 0 : t.equals)).store, v = (e) => B(e) ? e[de] : e, hs = (e) => !Le(e) || St(e) ? e : new Proxy(e, is), fs = (e, t, s) => !!e.configurable == !!t.configurable && !!e.enumerable == !!t.enumerable && !!e.writable == !!t.writable && s(e.value, t.value) && e.get === t.get && e.set === t.set, as = (e, t, s) => {
949
+ if (Object.isFrozen(e))
950
+ return !0;
951
+ if (!s || t === void 0)
952
+ return !1;
953
+ const n = $.unwrap(s.store), r = Reflect.getOwnPropertyDescriptor(n, t);
954
+ return !(r != null && r.configurable || r != null && r.writable);
955
+ }, ee = () => !!Y, se = (e) => {
956
+ if (e === null || typeof e != "object")
957
+ return !1;
958
+ if (ne in e)
959
+ return !0;
960
+ if (Ie in e)
961
+ return !1;
962
+ if (Q(e))
963
+ return !0;
964
+ const t = Object.getPrototypeOf(e);
965
+ return t === null ? !0 : Object.getPrototypeOf(t) === null;
966
+ }, St = (e) => e === null || typeof e != "object" ? !1 : Ie in e, As = () => {
967
+ throw new TypeError("Cannot set property value of #<Object> which has only a getter");
968
+ }, $ = (e, t) => !Le(e) || St(e) ? e : ls(e, t);
969
+ $.on = (e, t) => {
970
+ const s = B(e) ? [e] : wt(e), n = s.filter(_), r = s.filter(B).map(gt);
971
+ m.AK += 1;
972
+ const i = n.map((o) => {
973
+ let u = !1;
974
+ return we(() => {
975
+ u && (m.AL.add(t), I.F()), u = !0, o();
976
+ }, { suspense: !1, sync: !0 });
977
+ });
978
+ return r.forEach((o) => {
979
+ q(o, "AP", t);
980
+ }), () => {
981
+ m.AK -= 1, i.forEach((o) => {
982
+ o();
983
+ }), r.forEach((o) => {
984
+ J(o, "AP", t);
985
+ });
986
+ };
987
+ };
988
+ $._onRoots = (e, t) => {
989
+ if (!B(e))
990
+ return Ce;
991
+ const s = gt(e);
992
+ if (s.AO)
993
+ throw new Error("Only top-level stores are supported");
994
+ return w.AK += 1, q(s, "AQ", t), () => {
995
+ w.AK -= 1, J(s, "AQ", t);
996
+ };
997
+ };
998
+ $.reconcile = /* @__PURE__ */ (() => {
999
+ const e = (r) => Q(r) ? 1 : se(r) ? 2 : 0, t = (r, i) => {
1000
+ const o = v(r), u = v(i);
1001
+ s(r, i);
1002
+ const c = e(o), h = e(u);
1003
+ return (c === 1 || h === 1) && (r.length = i.length), r;
1004
+ }, s = (r, i) => {
1005
+ const o = v(r), u = v(i), c = Object.keys(o), h = Object.keys(u);
1006
+ for (let l = 0, A = h.length; l < A; l++) {
1007
+ const f = h[l], S = o[f], d = u[f];
1008
+ if (G(S, d))
1009
+ S === void 0 && !(f in o) && (r[f] = void 0);
1010
+ else {
1011
+ const b = e(S), p = e(d);
1012
+ b && b === p ? (s(r[f], d), b === 1 && (r[f].length = d.length)) : r[f] = d;
1013
+ }
1014
+ }
1015
+ for (let l = 0, A = c.length; l < A; l++) {
1016
+ const f = c[l];
1017
+ f in u || delete r[f];
1018
+ }
1019
+ return r;
1020
+ };
1021
+ return (r, i) => K(() => t(r, i));
1022
+ })();
1023
+ $.untrack = (e) => hs(e);
1024
+ $.unwrap = (e) => v(e);
1025
+ const ds = () => {
1026
+ const e = g.get(H);
1027
+ if (!e)
1028
+ return tt;
1029
+ const t = e.observable || (e.observable = new N(!!e.suspended));
1030
+ return F(t);
1031
+ }, bs = () => {
1032
+ pe.N();
1033
+ }, gs = (e, t) => {
1034
+ const s = At();
1035
+ return L(() => {
1036
+ const n = s();
1037
+ return n ? O(t({ error: n, reset: () => s(void 0) })) : (g.S = s, O(e));
1038
+ });
1039
+ };
1040
+ function Ss(e) {
1041
+ const t = _(e) ? (...s) => K(() => e(...s)) : () => e;
1042
+ return t[Ne] = !0, t;
1043
+ }
1044
+ const ps = () => {
1045
+ const e = g, t = Y;
1046
+ return (s) => e.E(() => s(), e, t);
1047
+ };
1048
+ function a(e, t) {
1049
+ return et(new N(e, t));
1050
+ }
1051
+ a.batch = Bt;
1052
+ a.boolean = De;
1053
+ a.cleanup = D;
1054
+ a.context = Kt;
1055
+ a.disposed = Ut;
1056
+ a.effect = we;
1057
+ a.for = Vt;
1058
+ a.get = X;
1059
+ a.if = zt;
1060
+ a.isBatching = at;
1061
+ a.isObservable = Qe;
1062
+ a.isStore = B;
1063
+ a.memo = L;
1064
+ a.observable = At;
1065
+ a.owner = dt;
1066
+ a.readonly = $t;
1067
+ a.resolve = O;
1068
+ a.root = jt;
1069
+ a.selector = Zt;
1070
+ a.store = $;
1071
+ a.suspended = ds;
1072
+ a.suspense = ut;
1073
+ a.switch = ht;
1074
+ a.ternary = ft;
1075
+ a.tick = bs;
1076
+ a.tryCatch = gs;
1077
+ a.untrack = K;
1078
+ a.untracked = Ss;
1079
+ a.with = ps;
1080
+ const ys = Et({
1081
+ create: () => {
1082
+ const e = a(0);
1083
+ return {
1084
+ depend: () => {
1085
+ e();
1086
+ },
1087
+ notify: () => {
1088
+ e(K(() => e() + 1));
1089
+ }
1090
+ };
1091
+ },
1092
+ isInScope: () => !!dt(),
1093
+ onDispose: (e) => {
1094
+ D(e);
1095
+ }
1096
+ });
1097
+ export {
1098
+ ys as default
1099
+ };
1100
+ //# sourceMappingURL=index.mjs.map