@instantdb/core 0.22.86-experimental.split-store.20178922132.1 → 0.22.86-experimental.split-store.20183617880.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/__tests__/src/Reactor.test.js +18 -11
  2. package/__tests__/src/{datalog.test.js → datalog.test.ts} +17 -5
  3. package/__tests__/src/{instaml.test.js → instaml.test.ts} +183 -119
  4. package/__tests__/src/instaql.bench.ts +34 -0
  5. package/__tests__/src/{instaql.test.js → instaql.test.ts} +342 -455
  6. package/__tests__/src/instaqlInference.test.js +13 -9
  7. package/__tests__/src/{store.test.js → store.test.ts} +188 -210
  8. package/dist/commonjs/Reactor.d.ts +4 -1
  9. package/dist/commonjs/Reactor.d.ts.map +1 -1
  10. package/dist/commonjs/Reactor.js +22 -12
  11. package/dist/commonjs/Reactor.js.map +1 -1
  12. package/dist/commonjs/instaml.d.ts +3 -3
  13. package/dist/commonjs/instaml.d.ts.map +1 -1
  14. package/dist/commonjs/instaml.js +2 -2
  15. package/dist/commonjs/instaml.js.map +1 -1
  16. package/dist/commonjs/instaql.d.ts +2 -2
  17. package/dist/commonjs/instaql.d.ts.map +1 -1
  18. package/dist/commonjs/instaql.js.map +1 -1
  19. package/dist/commonjs/store.d.ts +28 -9
  20. package/dist/commonjs/store.d.ts.map +1 -1
  21. package/dist/commonjs/store.js +13 -8
  22. package/dist/commonjs/store.js.map +1 -1
  23. package/dist/esm/Reactor.d.ts +4 -1
  24. package/dist/esm/Reactor.d.ts.map +1 -1
  25. package/dist/esm/Reactor.js +22 -12
  26. package/dist/esm/Reactor.js.map +1 -1
  27. package/dist/esm/instaml.d.ts +3 -3
  28. package/dist/esm/instaml.d.ts.map +1 -1
  29. package/dist/esm/instaml.js +3 -3
  30. package/dist/esm/instaml.js.map +1 -1
  31. package/dist/esm/instaql.d.ts +2 -2
  32. package/dist/esm/instaql.d.ts.map +1 -1
  33. package/dist/esm/instaql.js.map +1 -1
  34. package/dist/esm/store.d.ts +28 -9
  35. package/dist/esm/store.d.ts.map +1 -1
  36. package/dist/esm/store.js +11 -6
  37. package/dist/esm/store.js.map +1 -1
  38. package/dist/standalone/index.js +549 -533
  39. package/dist/standalone/index.umd.cjs +2 -2
  40. package/package.json +2 -2
  41. package/src/Reactor.js +44 -35
  42. package/src/instaml.ts +8 -7
  43. package/src/instaql.ts +2 -2
  44. package/src/store.ts +47 -19
  45. package/__tests__/src/instaql.bench.js +0 -29
@@ -1,6 +1,6 @@
1
- var Vn = Object.defineProperty;
2
- var Wn = (t, e, n) => e in t ? Vn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var w = (t, e, n) => Wn(t, typeof e != "symbol" ? e + "" : e, n);
1
+ var Qn = Object.defineProperty;
2
+ var Gn = (t, e, n) => e in t ? Qn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var w = (t, e, n) => Gn(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  function P(t) {
5
5
  if (typeof t == "number")
6
6
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -40,7 +40,7 @@ const k = {
40
40
  Remove: "remove",
41
41
  Replace: "replace",
42
42
  Add: "add"
43
- }, Xt = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Qn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), we = Symbol.iterator, L = {
43
+ }, Xt = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Bn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), we = Symbol.iterator, F = {
44
44
  mutable: "mutable",
45
45
  immutable: "immutable"
46
46
  }, rt = {};
@@ -64,11 +64,11 @@ function st(t) {
64
64
  function it(t) {
65
65
  return Object.getPrototypeOf(t) === Map.prototype;
66
66
  }
67
- function U(t) {
67
+ function L(t) {
68
68
  var e;
69
69
  return (e = t.copy) !== null && e !== void 0 ? e : t.original;
70
70
  }
71
- function H(t) {
71
+ function J(t) {
72
72
  return !!S(t);
73
73
  }
74
74
  function S(t) {
@@ -79,11 +79,11 @@ function ot(t) {
79
79
  const n = S(t);
80
80
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
81
81
  }
82
- function K(t, e) {
82
+ function q(t, e) {
83
83
  if (!t || typeof t != "object")
84
84
  return !1;
85
85
  let n;
86
- return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, L)) === L.immutable || typeof n == "function");
86
+ return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, F)) === F.immutable || typeof n == "function");
87
87
  }
88
88
  function en(t, e = []) {
89
89
  if (Object.hasOwnProperty.call(t, "key")) {
@@ -99,24 +99,24 @@ function en(t, e = []) {
99
99
  return en(t.parent, e);
100
100
  e.reverse();
101
101
  try {
102
- Gn(t.copy, e);
102
+ Hn(t.copy, e);
103
103
  } catch {
104
104
  return null;
105
105
  }
106
106
  return e;
107
107
  }
108
- function J(t) {
108
+ function Y(t) {
109
109
  return Array.isArray(t) ? 1 : t instanceof Map ? 2 : t instanceof Set ? 3 : 0;
110
110
  }
111
111
  function G(t, e) {
112
- return J(t) === 2 ? t.get(e) : t[e];
112
+ return Y(t) === 2 ? t.get(e) : t[e];
113
113
  }
114
114
  function he(t, e, n) {
115
- J(t) === 2 ? t.set(e, n) : t[e] = n;
115
+ Y(t) === 2 ? t.set(e, n) : t[e] = n;
116
116
  }
117
117
  function De(t, e) {
118
118
  const n = S(t);
119
- return (n ? U(n) : t)[e];
119
+ return (n ? L(n) : t)[e];
120
120
  }
121
121
  function Q(t, e) {
122
122
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
@@ -132,15 +132,15 @@ function B(t, e) {
132
132
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
133
133
  }).join("/");
134
134
  }
135
- function Gn(t, e) {
135
+ function Hn(t, e) {
136
136
  for (let n = 0; n < e.length - 1; n += 1) {
137
137
  const r = e[n];
138
- if (t = G(J(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
138
+ if (t = G(Y(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
139
139
  throw new Error(`Cannot resolve patch at '${e.join("/")}'.`);
140
140
  }
141
141
  return t;
142
142
  }
143
- function Bn(t) {
143
+ function Jn(t) {
144
144
  const e = Object.create(Object.getPrototypeOf(t));
145
145
  return Reflect.ownKeys(t).forEach((n) => {
146
146
  let r = Reflect.getOwnPropertyDescriptor(t, n);
@@ -156,7 +156,7 @@ function Bn(t) {
156
156
  }), Reflect.defineProperty(e, n, r);
157
157
  }), e;
158
158
  }
159
- const Hn = Object.prototype.propertyIsEnumerable;
159
+ const Yn = Object.prototype.propertyIsEnumerable;
160
160
  function tn(t, e) {
161
161
  let n;
162
162
  if (Array.isArray(t))
@@ -173,9 +173,9 @@ function tn(t, e) {
173
173
  return new r(t);
174
174
  }
175
175
  return new Map(t);
176
- } else if (e != null && e.mark && (n = e.mark(t, L), n !== void 0) && n !== L.mutable) {
177
- if (n === L.immutable)
178
- return Bn(t);
176
+ } else if (e != null && e.mark && (n = e.mark(t, F), n !== void 0) && n !== F.mutable) {
177
+ if (n === F.immutable)
178
+ return Jn(t);
179
179
  if (typeof n == "function") {
180
180
  if (e.enablePatches || e.enableAutoFreeze)
181
181
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -187,7 +187,7 @@ function tn(t, e) {
187
187
  return Object.keys(t).forEach((s) => {
188
188
  r[s] = t[s];
189
189
  }), Object.getOwnPropertySymbols(t).forEach((s) => {
190
- Hn.call(t, s) && (r[s] = t[s]);
190
+ Yn.call(t, s) && (r[s] = t[s]);
191
191
  }), r;
192
192
  } else
193
193
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
@@ -196,7 +196,7 @@ function j(t) {
196
196
  t.copy || (t.copy = tn(t.original, t.options));
197
197
  }
198
198
  function ie(t) {
199
- if (!K(t))
199
+ if (!q(t))
200
200
  return ot(t);
201
201
  if (Array.isArray(t))
202
202
  return t.map(ie);
@@ -225,7 +225,7 @@ function ie(t) {
225
225
  return e;
226
226
  }
227
227
  function Te(t) {
228
- return H(t) ? ie(t) : t;
228
+ return J(t) ? ie(t) : t;
229
229
  }
230
230
  function V(t) {
231
231
  var e;
@@ -234,7 +234,7 @@ function V(t) {
234
234
  function Tt() {
235
235
  throw new Error("Cannot modify frozen object");
236
236
  }
237
- function Z(t, e, n, r, s) {
237
+ function X(t, e, n, r, s) {
238
238
  {
239
239
  n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], s = s ?? [];
240
240
  const o = n.has(t) ? n.get(t) : t;
@@ -251,37 +251,37 @@ function Z(t, e, n, r, s) {
251
251
  } else
252
252
  r.push(o);
253
253
  }
254
- if (Object.isFrozen(t) || H(t)) {
254
+ if (Object.isFrozen(t) || J(t)) {
255
255
  r.pop(), s.pop();
256
256
  return;
257
257
  }
258
- switch (J(t)) {
258
+ switch (Y(t)) {
259
259
  case 2:
260
260
  for (const [a, c] of t)
261
- Z(a, a, n, r, s), Z(c, a, n, r, s);
261
+ X(a, a, n, r, s), X(c, a, n, r, s);
262
262
  t.set = t.clear = t.delete = Tt;
263
263
  break;
264
264
  case 3:
265
265
  for (const a of t)
266
- Z(a, a, n, r, s);
266
+ X(a, a, n, r, s);
267
267
  t.add = t.clear = t.delete = Tt;
268
268
  break;
269
269
  case 1:
270
270
  Object.freeze(t);
271
271
  let o = 0;
272
272
  for (const a of t)
273
- Z(a, o, n, r, s), o += 1;
273
+ X(a, o, n, r, s), o += 1;
274
274
  break;
275
275
  default:
276
276
  Object.freeze(t), Object.keys(t).forEach((a) => {
277
277
  const c = t[a];
278
- Z(c, a, n, r, s);
278
+ X(c, a, n, r, s);
279
279
  });
280
280
  }
281
281
  r.pop(), s.pop();
282
282
  }
283
283
  function at(t, e) {
284
- const n = J(t);
284
+ const n = Y(t);
285
285
  if (n === 0)
286
286
  Reflect.ownKeys(t).forEach((r) => {
287
287
  e(r, t[r], t);
@@ -294,12 +294,12 @@ function at(t, e) {
294
294
  t.forEach((r, s) => e(s, r, t));
295
295
  }
296
296
  function nn(t, e, n) {
297
- if (H(t) || !K(t, n) || e.has(t) || Object.isFrozen(t))
297
+ if (J(t) || !q(t, n) || e.has(t) || Object.isFrozen(t))
298
298
  return;
299
299
  const r = t instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
300
300
  if (e.add(t), at(t, (i, o) => {
301
301
  var a;
302
- if (H(o)) {
302
+ if (J(o)) {
303
303
  const c = S(o);
304
304
  j(c);
305
305
  const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
@@ -313,7 +313,7 @@ function nn(t, e, n) {
313
313
  });
314
314
  }
315
315
  }
316
- function Jn(t, e) {
316
+ function Zn(t, e) {
317
317
  const n = t.type === 3 ? t.setMap : t.copy;
318
318
  t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && nn(G(n, e), t.finalities.handledSet, t.options);
319
319
  }
@@ -340,12 +340,12 @@ function ct(t, e, n, r) {
340
340
  let u = s.original;
341
341
  s.copy && (u = s.copy), Ke(t), qe(t, r, i, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(u, s.original)), he(c, e, u);
342
342
  }
343
- }), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), K(n, t.options) && t.finalities.draft.push(() => {
343
+ }), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), q(n, t.options) && t.finalities.draft.push(() => {
344
344
  const i = t.type === 3 ? t.setMap : t.copy;
345
- Q(G(i, e), n) && Jn(t, e);
345
+ Q(G(i, e), n) && Zn(t, e);
346
346
  });
347
347
  }
348
- function Yn(t, e, n, r, s) {
348
+ function Xn(t, e, n, r, s) {
349
349
  let { original: i, assignedMap: o, options: a } = t, c = t.copy;
350
350
  c.length < i.length && ([i, c] = [c, i], [n, r] = [r, n]);
351
351
  for (let u = 0; u < i.length; u += 1)
@@ -391,7 +391,7 @@ function Yn(t, e, n, r, s) {
391
391
  }
392
392
  }
393
393
  }
394
- function Zn({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
394
+ function er({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
395
395
  n.forEach((a, c) => {
396
396
  const u = G(t, c), l = Te(G(e, c)), f = a ? ce(t, c) ? k.Replace : k.Add : k.Remove;
397
397
  if (Q(u, l) && f === k.Replace)
@@ -400,7 +400,7 @@ function Zn({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
400
400
  s.push(f === k.Remove ? { op: f, path: h } : { op: f, path: h, value: l }), i.push(f === k.Add ? { op: k.Remove, path: h } : f === k.Remove ? { op: k.Add, path: h, value: u } : { op: k.Replace, path: h, value: u });
401
401
  });
402
402
  }
403
- function Xn({ original: t, copy: e }, n, r, s, i) {
403
+ function tr({ original: t, copy: e }, n, r, s, i) {
404
404
  let o = 0;
405
405
  t.forEach((a) => {
406
406
  if (!e.has(a)) {
@@ -437,25 +437,25 @@ function fe(t, e, n, r) {
437
437
  switch (t.type) {
438
438
  case 0:
439
439
  case 2:
440
- return Zn(t, e, n, r, s);
440
+ return er(t, e, n, r, s);
441
441
  case 1:
442
- return Yn(t, e, n, r, s);
443
- case 3:
444
442
  return Xn(t, e, n, r, s);
443
+ case 3:
444
+ return tr(t, e, n, r, s);
445
445
  }
446
446
  }
447
447
  const Ae = (t, e, n = !1) => {
448
- if (typeof t == "object" && t !== null && (!K(t, e) || n))
448
+ if (typeof t == "object" && t !== null && (!q(t, e) || n))
449
449
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
450
450
  }, ze = {
451
451
  get size() {
452
- return U(S(this)).size;
452
+ return L(S(this)).size;
453
453
  },
454
454
  has(t) {
455
- return U(S(this)).has(t);
455
+ return L(S(this)).has(t);
456
456
  },
457
457
  set(t, e) {
458
- const n = S(this), r = U(n);
458
+ const n = S(this), r = L(n);
459
459
  return (!r.has(t) || !Q(r.get(t), e)) && (j(n), V(n), n.assignedMap.set(t, !0), n.copy.set(t, e), ct(n, t, e, fe)), this;
460
460
  },
461
461
  delete(t) {
@@ -475,14 +475,14 @@ const Ae = (t, e, n = !1) => {
475
475
  },
476
476
  forEach(t, e) {
477
477
  const n = S(this);
478
- U(n).forEach((r, s) => {
478
+ L(n).forEach((r, s) => {
479
479
  t.call(e, this.get(s), s, this);
480
480
  });
481
481
  },
482
482
  get(t) {
483
483
  var e, n;
484
- const r = S(this), s = U(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, L)) === L.mutable;
485
- if (r.options.strict && Ae(s, r.options, i), i || r.finalized || !K(s, r.options) || s !== r.original.get(t))
484
+ const r = S(this), s = L(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, F)) === F.mutable;
485
+ if (r.options.strict && Ae(s, r.options, i), i || r.finalized || !q(s, r.options) || s !== r.original.get(t))
486
486
  return s;
487
487
  const o = rt.createDraft({
488
488
  original: s,
@@ -494,7 +494,7 @@ const Ae = (t, e, n = !1) => {
494
494
  return j(r), r.copy.set(t, o), o;
495
495
  },
496
496
  keys() {
497
- return U(S(this)).keys();
497
+ return L(S(this)).keys();
498
498
  },
499
499
  values() {
500
500
  const t = this.keys();
@@ -528,15 +528,15 @@ const Ae = (t, e, n = !1) => {
528
528
  [we]() {
529
529
  return this.entries();
530
530
  }
531
- }, er = Reflect.ownKeys(ze), mt = (t, e, { isValuesIterator: n }) => () => {
531
+ }, nr = Reflect.ownKeys(ze), mt = (t, e, { isValuesIterator: n }) => () => {
532
532
  var r, s;
533
533
  const i = e.next();
534
534
  if (i.done)
535
535
  return i;
536
536
  const o = i.value;
537
537
  let a = t.setMap.get(o);
538
- const c = S(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, L)) === L.mutable;
539
- if (t.options.strict && Ae(o, t.options, u), !u && !c && K(o, t.options) && !t.finalized && t.original.has(o)) {
538
+ const c = S(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, F)) === F.mutable;
539
+ if (t.options.strict && Ae(o, t.options, u), !u && !c && q(o, t.options) && !t.finalized && t.original.has(o)) {
540
540
  const l = rt.createDraft({
541
541
  original: o,
542
542
  parentDraft: t,
@@ -639,7 +639,7 @@ Set.prototype.difference && Object.assign(ve, {
639
639
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
640
640
  }
641
641
  });
642
- const tr = Reflect.ownKeys(ve), rn = /* @__PURE__ */ new WeakSet(), sn = {
642
+ const rr = Reflect.ownKeys(ve), rn = /* @__PURE__ */ new WeakSet(), sn = {
643
643
  get(t, e, n) {
644
644
  var r, s;
645
645
  const i = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
@@ -650,18 +650,18 @@ const tr = Reflect.ownKeys(ve), rn = /* @__PURE__ */ new WeakSet(), sn = {
650
650
  let o;
651
651
  if (t.options.mark) {
652
652
  const u = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
653
- if (o = t.options.mark(u, L), o === L.mutable)
653
+ if (o = t.options.mark(u, F), o === F.mutable)
654
654
  return t.options.strict && Ae(u, t.options, !0), u;
655
655
  }
656
- const a = U(t);
657
- if (a instanceof Map && er.includes(e)) {
656
+ const a = L(t);
657
+ if (a instanceof Map && nr.includes(e)) {
658
658
  if (e === "size")
659
659
  return Object.getOwnPropertyDescriptor(ze, "size").get.call(t.proxy);
660
660
  const u = ze[e];
661
661
  if (u)
662
662
  return u.bind(t.proxy);
663
663
  }
664
- if (a instanceof Set && tr.includes(e)) {
664
+ if (a instanceof Set && rr.includes(e)) {
665
665
  if (e === "size")
666
666
  return Object.getOwnPropertyDescriptor(ve, "size").get.call(t.proxy);
667
667
  const u = ve[e];
@@ -676,7 +676,7 @@ const tr = Reflect.ownKeys(ve), rn = /* @__PURE__ */ new WeakSet(), sn = {
676
676
  ) : void 0;
677
677
  }
678
678
  const c = a[e];
679
- if (t.options.strict && Ae(c, t.options), t.finalized || !K(c, t.options))
679
+ if (t.options.strict && Ae(c, t.options), t.finalized || !q(c, t.options))
680
680
  return c;
681
681
  if (c === De(t.original, e)) {
682
682
  if (j(t), t.copy[e] = ut({
@@ -700,20 +700,20 @@ const tr = Reflect.ownKeys(ve), rn = /* @__PURE__ */ new WeakSet(), sn = {
700
700
  let s;
701
701
  if (t.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
702
702
  throw new Error("Only supports setting array indices and the 'length' property.");
703
- const i = wt(U(t), e);
703
+ const i = wt(L(t), e);
704
704
  if (i != null && i.set)
705
705
  return i.set.call(t.proxy, n), !0;
706
- const o = De(U(t), e), a = S(o);
706
+ const o = De(L(t), e), a = S(o);
707
707
  return a && Q(a.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (Q(n, o) && (n !== void 0 || ce(t.original, e)) || (j(t), V(t), ce(t.original, e) && Q(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, ct(t, e, n, fe)), !0);
708
708
  },
709
709
  has(t, e) {
710
- return e in U(t);
710
+ return e in L(t);
711
711
  },
712
712
  ownKeys(t) {
713
- return Reflect.ownKeys(U(t));
713
+ return Reflect.ownKeys(L(t));
714
714
  },
715
715
  getOwnPropertyDescriptor(t, e) {
716
- const n = U(t), r = Reflect.getOwnPropertyDescriptor(n, e);
716
+ const n = L(t), r = Reflect.getOwnPropertyDescriptor(n, e);
717
717
  return r && {
718
718
  writable: !0,
719
719
  configurable: t.type !== 1 || e !== "length",
@@ -736,7 +736,7 @@ const tr = Reflect.ownKeys(ve), rn = /* @__PURE__ */ new WeakSet(), sn = {
736
736
  }
737
737
  };
738
738
  function ut(t) {
739
- const { original: e, parentDraft: n, key: r, finalities: s, options: i } = t, o = J(e), a = {
739
+ const { original: e, parentDraft: n, key: r, finalities: s, options: i } = t, o = Y(e), a = {
740
740
  type: o,
741
741
  finalized: !1,
742
742
  parent: n,
@@ -774,20 +774,20 @@ function ut(t) {
774
774
  return c;
775
775
  }
776
776
  rt.createDraft = ut;
777
- function nr(t, e, n, r, s) {
777
+ function sr(t, e, n, r, s) {
778
778
  var i;
779
779
  const o = S(t), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : t, c = !!e.length;
780
780
  if (o != null && o.operated)
781
781
  for (; o.finalities.draft.length > 0; )
782
782
  o.finalities.draft.pop()(n, r);
783
783
  const u = c ? e[0] : o ? o.operated ? o.copy : o.original : t;
784
- return o && Ne(o), s && Z(u, u, o == null ? void 0 : o.options.updatedValues), [
784
+ return o && Ne(o), s && X(u, u, o == null ? void 0 : o.options.updatedValues), [
785
785
  u,
786
786
  n && c ? [{ op: k.Replace, path: [], value: e[0] }] : n,
787
787
  r && c ? [{ op: k.Replace, path: [], value: a }] : r
788
788
  ];
789
789
  }
790
- function rr(t, e) {
790
+ function ir(t, e) {
791
791
  var n;
792
792
  const r = {
793
793
  draft: [],
@@ -796,7 +796,7 @@ function rr(t, e) {
796
796
  };
797
797
  let s, i;
798
798
  e.enablePatches && (s = [], i = []);
799
- const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, L)) === L.mutable || !K(t, e) ? t : ut({
799
+ const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, F)) === F.mutable || !q(t, e) ? t : ut({
800
800
  original: t,
801
801
  parentDraft: null,
802
802
  finalities: r,
@@ -805,7 +805,7 @@ function rr(t, e) {
805
805
  return [
806
806
  a,
807
807
  (c = []) => {
808
- const [u, l, f] = nr(a, c, s, i, e.enableAutoFreeze);
808
+ const [u, l, f] = sr(a, c, s, i, e.enableAutoFreeze);
809
809
  return e.enablePatches ? [u, l, f] : u;
810
810
  }
811
811
  ];
@@ -828,9 +828,9 @@ function Ve(t) {
828
828
  function on(t) {
829
829
  var e;
830
830
  const n = S(t);
831
- if (!K(t, n == null ? void 0 : n.options))
831
+ if (!q(t, n == null ? void 0 : n.options))
832
832
  return t;
833
- const r = J(t);
833
+ const r = Y(t);
834
834
  if (n && !n.operated)
835
835
  return n.original;
836
836
  let s;
@@ -858,11 +858,11 @@ function on(t) {
858
858
  return s;
859
859
  }
860
860
  function St(t) {
861
- if (!H(t))
861
+ if (!J(t))
862
862
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
863
863
  return on(t);
864
864
  }
865
- const sr = (t) => function e(n, r, s) {
865
+ const or = (t) => function e(n, r, s) {
866
866
  var i, o, a;
867
867
  if (typeof n == "function" && typeof r != "function")
868
868
  return function(m, ...O) {
@@ -873,13 +873,13 @@ const sr = (t) => function e(n, r, s) {
873
873
  if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
874
874
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
875
875
  l = Object.assign(Object.assign({}, t), l);
876
- const f = H(c) ? St(c) : c, d = Array.isArray(l.mark) ? (m, O) => {
876
+ const f = J(c) ? St(c) : c, d = Array.isArray(l.mark) ? (m, O) => {
877
877
  for (const M of l.mark) {
878
878
  if (typeof M != "function")
879
879
  throw new Error(`Invalid mark: ${M}, 'mark' should be a function.`);
880
- const z = M(m, O);
881
- if (z)
882
- return z;
880
+ const U = M(m, O);
881
+ if (U)
882
+ return U;
883
883
  }
884
884
  } : l.mark, h = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, p = (o = l.strict) !== null && o !== void 0 ? o : !1, b = {
885
885
  enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
@@ -887,11 +887,11 @@ const sr = (t) => function e(n, r, s) {
887
887
  strict: p,
888
888
  enablePatches: h
889
889
  };
890
- if (!K(f, b) && typeof f == "object" && f !== null)
890
+ if (!q(f, b) && typeof f == "object" && f !== null)
891
891
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
892
- const [_, g] = rr(f, b);
892
+ const [_, g] = ir(f, b);
893
893
  if (typeof r != "function") {
894
- if (!K(f, b))
894
+ if (!q(f, b))
895
895
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
896
896
  return [_, g];
897
897
  }
@@ -903,12 +903,12 @@ const sr = (t) => function e(n, r, s) {
903
903
  }
904
904
  const A = (m) => {
905
905
  const O = S(_);
906
- if (!H(m)) {
906
+ if (!J(m)) {
907
907
  if (m !== void 0 && !Q(m, _) && (O != null && O.operated))
908
908
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
909
- const z = m == null ? void 0 : m[Qn];
910
- if (z) {
911
- const $e = z[0];
909
+ const U = m == null ? void 0 : m[Bn];
910
+ if (U) {
911
+ const $e = U[0];
912
912
  return b.strict && typeof m == "object" && m !== null && Ve({
913
913
  rootDraft: O,
914
914
  value: m,
@@ -931,7 +931,7 @@ const sr = (t) => function e(n, r, s) {
931
931
  return T instanceof Promise ? T.then(A, (m) => {
932
932
  throw Ne(S(_)), m;
933
933
  }) : A(T);
934
- }, Oe = sr();
934
+ }, Oe = or();
935
935
  Object.prototype.constructor.toString();
936
936
  function an(t, e) {
937
937
  const n = Object.keys(t), r = Object.keys(e);
@@ -973,7 +973,7 @@ function cn(t, e) {
973
973
  function oe(t) {
974
974
  return typeof t == "object" && t !== null && !Array.isArray(t);
975
975
  }
976
- function ir(t, e, n) {
976
+ function ar(t, e, n) {
977
977
  if (!t || e.length === 0)
978
978
  return;
979
979
  let r = t || {};
@@ -1003,13 +1003,13 @@ function un(t, e) {
1003
1003
  Array.isArray(t) ? t.splice(n, 1) : delete t[n];
1004
1004
  return;
1005
1005
  }
1006
- un(t[n], r), or(t[n]) && delete t[n];
1006
+ un(t[n], r), cr(t[n]) && delete t[n];
1007
1007
  }
1008
1008
  }
1009
- function or(t) {
1009
+ function cr(t) {
1010
1010
  return t && Object.keys(t).length === 0;
1011
1011
  }
1012
- const Ot = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, ar = {
1012
+ const Ot = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, ur = {
1013
1013
  ZULU: 0,
1014
1014
  YEKT: 18e3,
1015
1015
  YEKST: 21600,
@@ -1205,32 +1205,32 @@ const Ot = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1205
1205
  ACSST: 37800,
1206
1206
  ACDT: 37800
1207
1207
  };
1208
- function cr(t) {
1208
+ function lr(t) {
1209
1209
  return new Date(t);
1210
1210
  }
1211
- function ur(t) {
1211
+ function fr(t) {
1212
1212
  return /* @__PURE__ */ new Date(t + "Z");
1213
1213
  }
1214
- const lr = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1215
- function fr(t) {
1216
- const e = t.match(lr);
1214
+ const dr = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1215
+ function hr(t) {
1216
+ const e = t.match(dr);
1217
1217
  if (!e)
1218
1218
  return null;
1219
1219
  const [n, r, s, i] = e;
1220
1220
  return r <= 0 || s <= 0 || i <= 0 ? null : r > 999 ? new Date(Date.UTC(r, s - 1, i, 0, 0, 0, 0)) : new Date(Date.UTC(i, r - 1, s, 0, 0, 0, 0));
1221
1221
  }
1222
- function dr(t) {
1222
+ function pr(t) {
1223
1223
  const [e, n] = t.split(" ");
1224
1224
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1225
1225
  }
1226
- function hr(t) {
1226
+ function yr(t) {
1227
1227
  const [e, n] = t.split(" ");
1228
1228
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1229
1229
  }
1230
- function pr(t) {
1230
+ function br(t) {
1231
1231
  return new Date(t);
1232
1232
  }
1233
- function yr(t) {
1233
+ function _r(t) {
1234
1234
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1235
1235
  if (!t.match(e))
1236
1236
  throw new Error(`Unable to parse \`${t}\` as a date.`);
@@ -1247,7 +1247,7 @@ function yr(t) {
1247
1247
  )
1248
1248
  );
1249
1249
  }
1250
- function br(t) {
1250
+ function gr(t) {
1251
1251
  const e = /^(.+T.+)([+-])(\d{2})$/, n = t.match(e);
1252
1252
  if (n) {
1253
1253
  const [, r, s, i] = n, o = `${r}${s}${i}:00`;
@@ -1255,7 +1255,7 @@ function br(t) {
1255
1255
  }
1256
1256
  return null;
1257
1257
  }
1258
- function _r(t) {
1258
+ function wr(t) {
1259
1259
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
1260
1260
  if (n) {
1261
1261
  const [, r, s, i, o, a] = n, c = s.padStart(2, "0"), u = i.padStart(2, "0"), l = `${r}-${c}-${u}T${a}`;
@@ -1263,14 +1263,14 @@ function _r(t) {
1263
1263
  }
1264
1264
  return null;
1265
1265
  }
1266
- function gr(t) {
1266
+ function Tr(t) {
1267
1267
  const [e, n] = t.split(", "), [r, s, i] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1268
1268
  if (!o)
1269
1269
  throw new Error(`Unable to parse time from: ${t}`);
1270
1270
  let [, a, c, u, l] = o;
1271
1271
  return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
1272
1272
  }
1273
- function wr(t) {
1273
+ function mr(t) {
1274
1274
  switch (t) {
1275
1275
  case "epoch":
1276
1276
  return /* @__PURE__ */ new Date(0);
@@ -1282,28 +1282,28 @@ function wr(t) {
1282
1282
  return null;
1283
1283
  }
1284
1284
  }
1285
- function Tr(t) {
1285
+ function Sr(t) {
1286
1286
  const e = t.match(Ot);
1287
1287
  if (!e)
1288
1288
  return null;
1289
- const [n] = e, r = ar[n], s = new Date(t.replace(Ot, "Z"));
1289
+ const [n] = e, r = ur[n], s = new Date(t.replace(Ot, "Z"));
1290
1290
  return new Date(s.getTime() - r * 1e3);
1291
1291
  }
1292
- const mr = [
1293
- fr,
1292
+ const Ar = [
1294
1293
  hr,
1295
1294
  yr,
1295
+ _r,
1296
+ Tr,
1297
+ br,
1298
+ fr,
1296
1299
  gr,
1297
1300
  pr,
1298
- ur,
1299
- br,
1300
- dr,
1301
- cr,
1302
- wr,
1303
- Tr,
1304
- _r
1301
+ lr,
1302
+ mr,
1303
+ Sr,
1304
+ wr
1305
1305
  ];
1306
- function Sr(t, e) {
1306
+ function vr(t, e) {
1307
1307
  try {
1308
1308
  const n = t(e);
1309
1309
  return n instanceof Date && !isNaN(n.getTime()) ? n : null;
@@ -1312,14 +1312,14 @@ function Sr(t, e) {
1312
1312
  }
1313
1313
  }
1314
1314
  function We(t) {
1315
- for (const e of mr) {
1316
- const n = Sr(e, t);
1315
+ for (const e of Ar) {
1316
+ const n = vr(e, t);
1317
1317
  if (n)
1318
1318
  return n;
1319
1319
  }
1320
1320
  return null;
1321
1321
  }
1322
- function Ar(t) {
1322
+ function Or(t) {
1323
1323
  try {
1324
1324
  const e = JSON.parse(t);
1325
1325
  return typeof e == "string" ? We(e) : null;
@@ -1334,7 +1334,7 @@ function Ie(t) {
1334
1334
  if (t instanceof Date)
1335
1335
  return t;
1336
1336
  if (typeof t == "string") {
1337
- const e = We(t) || Ar(t) || We(t.trim());
1337
+ const e = We(t) || Or(t) || We(t.trim());
1338
1338
  if (!e)
1339
1339
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1340
1340
  return e;
@@ -1345,9 +1345,9 @@ function Ie(t) {
1345
1345
  );
1346
1346
  }
1347
1347
  }
1348
- class X {
1348
+ class H {
1349
1349
  constructor(e, n) {
1350
- this._blobAttrs = null, this._primaryKeys = null, this._forwardIdents = null, this._revIdents = null, console.log("attrs init", new Error("trace")), this.attrs = e, this.linkIndex = n;
1350
+ this._blobAttrs = null, this._primaryKeys = null, this._forwardIdents = null, this._revIdents = null, this.attrs = e, this.linkIndex = n;
1351
1351
  }
1352
1352
  resetAttrIndexes() {
1353
1353
  this._blobAttrs = null, this._primaryKeys = null, this._forwardIdents = null, this._revIdents = null;
@@ -1416,7 +1416,7 @@ class X {
1416
1416
  return { attrs: this.attrs, linkIndex: this.linkIndex };
1417
1417
  }
1418
1418
  }
1419
- function vr(t) {
1419
+ function kr(t) {
1420
1420
  return t.cardinality === "one";
1421
1421
  }
1422
1422
  function ft(t) {
@@ -1428,14 +1428,14 @@ function dt(t) {
1428
1428
  function re(t, e) {
1429
1429
  return e.reduce((n, r) => n && n.get(r), t);
1430
1430
  }
1431
- function N(t, e) {
1431
+ function K(t, e) {
1432
1432
  if (e.length === 0) throw new Error("path must have at least one element");
1433
1433
  if (e.length === 1) {
1434
1434
  t.delete(e[0]);
1435
1435
  return;
1436
1436
  }
1437
1437
  const [n, ...r] = e;
1438
- t.has(n) && N(t.get(n), r);
1438
+ t.has(n) && K(t.get(n), r);
1439
1439
  }
1440
1440
  function D(t, e, n) {
1441
1441
  if (e.length === 0) throw new Error("path must have at least one element");
@@ -1478,11 +1478,11 @@ function dn(t, e) {
1478
1478
  }
1479
1479
  function hn(t, e) {
1480
1480
  if (t)
1481
- return new X(t.attrs, t.linkIndex);
1481
+ return new H(t.attrs, t.linkIndex);
1482
1482
  if (e && "__type" in e)
1483
- return new X(e.attrs, e.linkIndex);
1483
+ return new H(e.attrs, e.linkIndex);
1484
1484
  }
1485
- function Or(t, e) {
1485
+ function Er(t, e) {
1486
1486
  return re(t.eav, [e]) !== void 0;
1487
1487
  }
1488
1488
  function Se(t, e, n, r) {
@@ -1525,14 +1525,14 @@ function pn(t, e, n) {
1525
1525
  if (!r)
1526
1526
  return;
1527
1527
  const [s, i, o] = r, a = e.getAttr(i);
1528
- a && (N(t.eav, [s, i, o]), N(t.aev, [i, s, o]), ft(a) && N(t.vae, [o, i, s]));
1528
+ a && (K(t.eav, [s, i, o]), K(t.aev, [i, s, o]), ft(a) && K(t.vae, [o, i, s]));
1529
1529
  }
1530
- let kr = 0;
1530
+ let Ir = 0;
1531
1531
  function yn(t, e, n) {
1532
1532
  const [r, s, i] = n;
1533
1533
  let o;
1534
1534
  const a = re(t.eav, [r, s, i]);
1535
- return a && (o = a[3]), o || Date.now() * 10 + kr++;
1535
+ return a && (o = a[3]), o || Date.now() * 10 + Ir++;
1536
1536
  }
1537
1537
  function bn(t, e, n) {
1538
1538
  const r = pe(t, n);
@@ -1544,9 +1544,9 @@ function bn(t, e, n) {
1544
1544
  return;
1545
1545
  a["checked-data-type"] === "date" && t.useDateObjects && (o = Ie(o));
1546
1546
  const c = re(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? yn(t, a, r), l = [s, i, o, u];
1547
- vr(a) ? (D(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), D(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (D(t.eav, [s, i, o], l), D(t.aev, [i, s, o], l)), ft(a) && D(t.vae, [o, i, s], l);
1547
+ kr(a) ? (D(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), D(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (D(t.eav, [s, i, o], l), D(t.aev, [i, s, o], l)), ft(a) && D(t.vae, [o, i, s], l);
1548
1548
  }
1549
- function Er(t, e, n) {
1549
+ function Cr(t, e, n) {
1550
1550
  var h;
1551
1551
  const r = pe(t, n);
1552
1552
  if (!r)
@@ -1585,16 +1585,16 @@ function Qe(t, e, n) {
1585
1585
  // the store that didn't set `etype` in deleteEntity
1586
1586
  (!s || // If we don't know about the attr, let's just get rid of it
1587
1587
  !d || // Make sure it matches the etype
1588
- ((u = d["forward-identity"]) == null ? void 0 : u[1]) === s) && (N(t.aev, [f, o]), N(t.eav, [o, f]));
1588
+ ((u = d["forward-identity"]) == null ? void 0 : u[1]) === s) && (K(t.aev, [f, o]), K(t.eav, [o, f]));
1589
1589
  }
1590
- a.size === 0 && N(t.eav, [o]);
1590
+ a.size === 0 && K(t.eav, [o]);
1591
1591
  }
1592
1592
  const c = t.vae.get(o) && R(t.vae.get(o), 2);
1593
1593
  c && c.forEach((f) => {
1594
1594
  var b, _, g;
1595
1595
  const [d, h, p] = f, y = e.getAttr(h);
1596
- (!s || !y || ((b = y["reverse-identity"]) == null ? void 0 : b[1]) === s) && (N(t.eav, [d, h, p]), N(t.aev, [h, d, p]), N(t.vae, [p, h, d])), y && y["on-delete"] === "cascade" && ((_ = y["reverse-identity"]) == null ? void 0 : _[1]) === s && Qe(t, e, [d, (g = y["forward-identity"]) == null ? void 0 : g[1]]);
1597
- }), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && N(t.vae, [o]);
1596
+ (!s || !y || ((b = y["reverse-identity"]) == null ? void 0 : b[1]) === s) && (K(t.eav, [d, h, p]), K(t.aev, [h, d, p]), K(t.vae, [p, h, d])), y && y["on-delete"] === "cascade" && ((_ = y["reverse-identity"]) == null ? void 0 : _[1]) === s && Qe(t, e, [d, (g = y["forward-identity"]) == null ? void 0 : g[1]]);
1597
+ }), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && K(t.vae, [o]);
1598
1598
  }
1599
1599
  function _n(t, e, n) {
1600
1600
  const r = ln(
@@ -1606,28 +1606,28 @@ function _n(t, e, n) {
1606
1606
  t[s] = r[s];
1607
1607
  });
1608
1608
  }
1609
- function Ir(t, [e]) {
1609
+ function Mr(t, [e]) {
1610
1610
  t.addAttr(e);
1611
1611
  }
1612
1612
  function gn(t) {
1613
1613
  return R(t.eav, 3);
1614
1614
  }
1615
- function Cr(t, e, [n]) {
1615
+ function Pr(t, e, [n]) {
1616
1616
  if (!e.getAttr(n)) return;
1617
1617
  const r = gn(t).filter(([s, i]) => i !== n);
1618
1618
  e.deleteAttr(n), _n(t, e, r);
1619
1619
  }
1620
- function Mr(t, e, [n]) {
1620
+ function jr(t, e, [n]) {
1621
1621
  e.getAttr(n.id) && (e.updateAttr(n), _n(t, e, gn(t)));
1622
1622
  }
1623
- function Pr(t, e, n) {
1623
+ function $r(t, e, n) {
1624
1624
  const [r, ...s] = n;
1625
1625
  switch (r) {
1626
1626
  case "add-triple":
1627
1627
  bn(t, e, s);
1628
1628
  break;
1629
1629
  case "deep-merge-triple":
1630
- Er(t, e, s);
1630
+ Cr(t, e, s);
1631
1631
  break;
1632
1632
  case "retract-triple":
1633
1633
  pn(t, e, s);
@@ -1636,13 +1636,13 @@ function Pr(t, e, n) {
1636
1636
  Qe(t, e, s);
1637
1637
  break;
1638
1638
  case "add-attr":
1639
- Ir(e, s);
1639
+ Mr(e, s);
1640
1640
  break;
1641
1641
  case "delete-attr":
1642
- Cr(t, e, s);
1642
+ Pr(t, e, s);
1643
1643
  break;
1644
1644
  case "update-attr":
1645
- Mr(t, e, s);
1645
+ jr(t, e, s);
1646
1646
  break;
1647
1647
  case "restore-attr":
1648
1648
  break;
@@ -1697,13 +1697,13 @@ function ye(t, e, n) {
1697
1697
  }
1698
1698
  return r;
1699
1699
  }
1700
- function jr(t, e, n) {
1700
+ function Dr(t, e, n) {
1701
1701
  let r = "";
1702
1702
  return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
1703
1703
  }
1704
- function $r(t, [e, n, r]) {
1704
+ function Rr(t, [e, n, r]) {
1705
1705
  var i, o;
1706
- switch (jr(e, n, r)) {
1706
+ switch (Dr(e, n, r)) {
1707
1707
  case "e": {
1708
1708
  const a = t.eav.get(e);
1709
1709
  return R(a, 2);
@@ -1749,7 +1749,7 @@ function $r(t, [e, n, r]) {
1749
1749
  return R(t.eav, 3);
1750
1750
  }
1751
1751
  }
1752
- function Dr(t, e, n) {
1752
+ function xr(t, e, n) {
1753
1753
  var s;
1754
1754
  const r = {};
1755
1755
  if (!e)
@@ -1765,11 +1765,11 @@ function E(t, e, n) {
1765
1765
  var r;
1766
1766
  return (r = t.forwardIdents.get(e)) == null ? void 0 : r.get(n);
1767
1767
  }
1768
- function Y(t, e, n) {
1768
+ function Z(t, e, n) {
1769
1769
  var r;
1770
1770
  return (r = t.revIdents.get(e)) == null ? void 0 : r.get(n);
1771
1771
  }
1772
- function Rr(t, e) {
1772
+ function Ur(t, e) {
1773
1773
  return t.blobAttrs.get(e);
1774
1774
  }
1775
1775
  function wn(t, e) {
@@ -1777,7 +1777,7 @@ function wn(t, e) {
1777
1777
  const n = t.primaryKeys.get(e);
1778
1778
  return n || ((r = t.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
1779
1779
  }
1780
- function xr(t, e, n) {
1780
+ function Lr(t, e, n) {
1781
1781
  const r = pe(t, n);
1782
1782
  if (!r)
1783
1783
  return;
@@ -1785,7 +1785,7 @@ function xr(t, e, n) {
1785
1785
  if (e.getAttr(i))
1786
1786
  return re(t.eav, [s, i]);
1787
1787
  }
1788
- function Ur(t, e, n) {
1788
+ function Fr(t, e, n) {
1789
1789
  const r = n.filter(
1790
1790
  ([s, i, o, a, c]) => {
1791
1791
  if (s !== "add-triple" && s !== "deep-merge-triple")
@@ -1800,7 +1800,7 @@ function Ur(t, e, n) {
1800
1800
  e,
1801
1801
  f["forward-identity"][1]
1802
1802
  );
1803
- l = !!xr(t, e, [
1803
+ l = !!Lr(t, e, [
1804
1804
  i,
1805
1805
  d == null ? void 0 : d.id,
1806
1806
  i
@@ -1809,16 +1809,25 @@ function Ur(t, e, n) {
1809
1809
  return !(u === "create" && l || u === "update" && !l);
1810
1810
  }
1811
1811
  );
1812
- return Oe(t, (s) => {
1813
- r.forEach((i) => {
1814
- Pr(s, e, i);
1815
- });
1816
- });
1812
+ return Oe(
1813
+ { store: t, attrsStore: e },
1814
+ (s) => {
1815
+ r.forEach((i) => {
1816
+ $r(s.store, s.attrsStore, i);
1817
+ });
1818
+ },
1819
+ {
1820
+ mark: (s) => {
1821
+ if (s instanceof H)
1822
+ return "immutable";
1823
+ }
1824
+ }
1825
+ );
1817
1826
  }
1818
- function Lr(t) {
1827
+ function Nr(t) {
1819
1828
  return typeof t == "string" && t.startsWith("?");
1820
1829
  }
1821
- function Fr(t, e, n) {
1830
+ function Kr(t, e, n) {
1822
1831
  if (n.hasOwnProperty(t)) {
1823
1832
  const r = n[t];
1824
1833
  return Tn(r, e, n);
@@ -1828,15 +1837,15 @@ function Fr(t, e, n) {
1828
1837
  function kt(t, e, n) {
1829
1838
  return t === e ? n : null;
1830
1839
  }
1831
- function Nr(t) {
1840
+ function qr(t) {
1832
1841
  switch (typeof t) {
1833
1842
  case "string":
1834
- return t.startsWith("?") ? Fr : kt;
1843
+ return t.startsWith("?") ? Kr : kt;
1835
1844
  default:
1836
1845
  return kt;
1837
1846
  }
1838
1847
  }
1839
- const Kr = [
1848
+ const zr = [
1840
1849
  "in",
1841
1850
  "$in",
1842
1851
  "$not",
@@ -1844,69 +1853,69 @@ const Kr = [
1844
1853
  "$comparator"
1845
1854
  // covers all of $gt, $lt, etc.
1846
1855
  ];
1847
- function qr(t) {
1848
- for (const e of Kr)
1856
+ function Vr(t) {
1857
+ for (const e of zr)
1849
1858
  if (t.hasOwnProperty(e))
1850
1859
  return !0;
1851
1860
  return !1;
1852
1861
  }
1853
1862
  function Tn(t, e, n) {
1854
- return n ? typeof t == "object" ? qr(t) ? n : null : Nr(t)(t, e, n) : null;
1863
+ return n ? typeof t == "object" ? Vr(t) ? n : null : qr(t)(t, e, n) : null;
1855
1864
  }
1856
- function zr(t, e, n) {
1865
+ function Wr(t, e, n) {
1857
1866
  return t.reduce((r, s, i) => {
1858
1867
  const o = e[i];
1859
1868
  return Tn(s, o, r);
1860
1869
  }, n);
1861
1870
  }
1862
- function Vr(t, e, n) {
1863
- return Gr(t, e, n).map((r) => zr(e, r, n)).filter((r) => r);
1871
+ function Qr(t, e, n) {
1872
+ return Hr(t, e, n).map((r) => Wr(e, r, n)).filter((r) => r);
1864
1873
  }
1865
- function Wr(t, e, n) {
1866
- return e.or ? e.or.patterns.flatMap((r) => Ge(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => Ge(t, s, r), n) : n.flatMap((r) => Vr(t, e, r));
1874
+ function Gr(t, e, n) {
1875
+ return e.or ? e.or.patterns.flatMap((r) => Ge(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => Ge(t, s, r), n) : n.flatMap((r) => Qr(t, e, r));
1867
1876
  }
1868
1877
  function Ge(t, e, n = [{}]) {
1869
- return e.reduce((r, s) => Wr(t, s, r), n);
1878
+ return e.reduce((r, s) => Gr(t, s, r), n);
1870
1879
  }
1871
1880
  function ht(t, e) {
1872
- return Array.isArray(e) ? e.map((n) => ht(t, n)) : Lr(e) ? t[e] : e;
1881
+ return Array.isArray(e) ? e.map((n) => ht(t, n)) : Nr(e) ? t[e] : e;
1873
1882
  }
1874
- function Qr(t, { find: e, where: n }) {
1883
+ function Br(t, { find: e, where: n }) {
1875
1884
  return Ge(t, n).map((s) => ht(s, e));
1876
1885
  }
1877
- function Gr(t, e, n) {
1878
- return $r(t, ht(n, e));
1886
+ function Hr(t, e, n) {
1887
+ return Rr(t, ht(n, e));
1879
1888
  }
1880
- const Br = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1889
+ const Jr = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1881
1890
  function te(t) {
1882
- return typeof t == "string" && Br.test(t);
1891
+ return typeof t == "string" && Jr.test(t);
1883
1892
  }
1884
1893
  const C = [];
1885
1894
  for (let t = 0; t < 256; ++t)
1886
1895
  C.push((t + 256).toString(16).slice(1));
1887
- function Hr(t, e = 0) {
1896
+ function Yr(t, e = 0) {
1888
1897
  return (C[t[e + 0]] + C[t[e + 1]] + C[t[e + 2]] + C[t[e + 3]] + "-" + C[t[e + 4]] + C[t[e + 5]] + "-" + C[t[e + 6]] + C[t[e + 7]] + "-" + C[t[e + 8]] + C[t[e + 9]] + "-" + C[t[e + 10]] + C[t[e + 11]] + C[t[e + 12]] + C[t[e + 13]] + C[t[e + 14]] + C[t[e + 15]]).toLowerCase();
1889
1898
  }
1890
1899
  let Re;
1891
- const Jr = new Uint8Array(16);
1892
- function Yr() {
1900
+ const Zr = new Uint8Array(16);
1901
+ function Xr() {
1893
1902
  if (!Re) {
1894
1903
  if (typeof crypto > "u" || !crypto.getRandomValues)
1895
1904
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1896
1905
  Re = crypto.getRandomValues.bind(crypto);
1897
1906
  }
1898
- return Re(Jr);
1907
+ return Re(Zr);
1899
1908
  }
1900
- const Zr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Et = { randomUUID: Zr };
1901
- function Xr(t, e, n) {
1909
+ const es = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Et = { randomUUID: es };
1910
+ function ts(t, e, n) {
1902
1911
  var s;
1903
1912
  if (Et.randomUUID && !t)
1904
1913
  return Et.randomUUID();
1905
1914
  t = t || {};
1906
- const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? Yr();
1915
+ const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? Xr();
1907
1916
  if (r.length < 16)
1908
1917
  throw new Error("Random bytes length must be >= 16");
1909
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Hr(r);
1918
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Yr(r);
1910
1919
  }
1911
1920
  function It(t) {
1912
1921
  const e = t.replace(/-/g, ""), n = [];
@@ -1914,24 +1923,24 @@ function It(t) {
1914
1923
  n.push(parseInt(e.substring(r, r + 2), 16));
1915
1924
  return n;
1916
1925
  }
1917
- function es(t, e) {
1926
+ function ns(t, e) {
1918
1927
  for (let n = 0; n < t.length; n++) {
1919
1928
  if (t[n] < e[n]) return -1;
1920
1929
  if (t[n] > e[n]) return 1;
1921
1930
  }
1922
1931
  return 0;
1923
1932
  }
1924
- function ts(t, e) {
1925
- return es(It(t), It(e));
1933
+ function rs(t, e) {
1934
+ return ns(It(t), It(e));
1926
1935
  }
1927
1936
  function I() {
1928
- return Xr();
1937
+ return ts();
1929
1938
  }
1930
- function ns(t, e) {
1939
+ function ss(t, e) {
1931
1940
  return t.localeCompare(e);
1932
1941
  }
1933
- function rs() {
1934
- let t = ns;
1942
+ function is() {
1943
+ let t = ss;
1935
1944
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1936
1945
  try {
1937
1946
  t = Intl.Collator("en-US").compare;
@@ -1939,10 +1948,10 @@ function rs() {
1939
1948
  }
1940
1949
  return t;
1941
1950
  }
1942
- const ss = rs();
1943
- let is = 0;
1951
+ const os = is();
1952
+ let as = 0;
1944
1953
  function ue(t) {
1945
- return Ce(`_${t}`, is++);
1954
+ return Ce(`_${t}`, as++);
1946
1955
  }
1947
1956
  function Ce(t, e) {
1948
1957
  return `?${t}-${e}`;
@@ -1952,28 +1961,28 @@ class ne extends Error {
1952
1961
  super(e), this.name = "AttrNotFoundError";
1953
1962
  }
1954
1963
  }
1955
- function os(t, e) {
1964
+ function cs(t, e) {
1956
1965
  const n = wn(t, e);
1957
1966
  if (!n)
1958
1967
  throw new ne(`Could not find id attr for ${e}`);
1959
1968
  return n;
1960
1969
  }
1961
1970
  function Ct(t, e, n, r) {
1962
- return [as(t, e, n, r)];
1971
+ return [us(t, e, n, r)];
1963
1972
  }
1964
- function as(t, e, n, r) {
1973
+ function us(t, e, n, r) {
1965
1974
  return [
1966
1975
  t(n, r),
1967
- os(e, n).id,
1976
+ cs(e, n).id,
1968
1977
  t(n, r),
1969
1978
  t("time", r)
1970
1979
  ];
1971
1980
  }
1972
- function cs(t, e, n) {
1981
+ function ls(t, e, n) {
1973
1982
  return t.map((r) => r === e ? n : r);
1974
1983
  }
1975
1984
  function mn(t, e, n, r, s) {
1976
- const i = E(e, n, s), o = Y(e, n, s), a = i || o;
1985
+ const i = E(e, n, s), o = Z(e, n, s), a = i || o;
1977
1986
  if (!a)
1978
1987
  throw new ne(`Could not find attr for ${[n, s]}`);
1979
1988
  if (a["value-type"] !== "ref")
@@ -2004,7 +2013,7 @@ function Mt(t, e) {
2004
2013
  return typeof o != "string" ? !1 : s.test(o);
2005
2014
  };
2006
2015
  }
2007
- function us(t, e) {
2016
+ function fs(t, e) {
2008
2017
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2009
2018
  return e;
2010
2019
  const n = t["checked-data-type"] === "date";
@@ -2064,8 +2073,8 @@ function us(t, e) {
2064
2073
  }
2065
2074
  return e;
2066
2075
  }
2067
- function ls(t, e, n, r, s, i) {
2068
- const o = E(e, n, s), a = Y(
2076
+ function ds(t, e, n, r, s, i) {
2077
+ const o = E(e, n, s), a = Z(
2069
2078
  e,
2070
2079
  n,
2071
2080
  s
@@ -2090,11 +2099,11 @@ function ls(t, e, n, r, s, i) {
2090
2099
  return o ? [
2091
2100
  t(n, r),
2092
2101
  c.id,
2093
- us(c, i),
2102
+ fs(c, i),
2094
2103
  ue("time")
2095
2104
  ] : [i, c.id, t(n, r), ue("time")];
2096
2105
  }
2097
- function fs(t, e, n, r, s) {
2106
+ function hs(t, e, n, r, s) {
2098
2107
  const [i, o, a] = s.reduce(
2099
2108
  (c, u) => {
2100
2109
  const [l, f, d] = c, [h, p, y] = mn(
@@ -2111,13 +2120,13 @@ function fs(t, e, n, r, s) {
2111
2120
  return [i, o, a];
2112
2121
  }
2113
2122
  function Be(t, e, n, r, s, i) {
2114
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = fs(
2123
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = hs(
2115
2124
  t,
2116
2125
  e,
2117
2126
  n,
2118
2127
  r,
2119
2128
  o
2120
- ), f = ls(
2129
+ ), f = ds(
2121
2130
  t,
2122
2131
  e,
2123
2132
  c,
@@ -2127,16 +2136,16 @@ function Be(t, e, n, r, s, i) {
2127
2136
  );
2128
2137
  return l.concat([f]);
2129
2138
  }
2130
- function ds(t, e) {
2139
+ function ps(t, e) {
2131
2140
  return e ? [e].concat(t) : t;
2132
2141
  }
2133
- function hs([t, e]) {
2142
+ function ys([t, e]) {
2134
2143
  return t === "or" && Array.isArray(e);
2135
2144
  }
2136
- function ps([t, e]) {
2145
+ function bs([t, e]) {
2137
2146
  return t === "and" && Array.isArray(e);
2138
2147
  }
2139
- function ys(t, e, n) {
2148
+ function _s(t, e, n) {
2140
2149
  return (r, s) => {
2141
2150
  const i = t(r, s);
2142
2151
  return e == i ? i : `${i}-${n}`;
@@ -2144,19 +2153,19 @@ function ys(t, e, n) {
2144
2153
  }
2145
2154
  function Pt(t, e, n, r, s, i) {
2146
2155
  const o = t(r, s), a = i.map((c, u) => {
2147
- const l = ys(t, o, u);
2156
+ const l = _s(t, o, u);
2148
2157
  return Sn(l, n, r, s, c);
2149
2158
  });
2150
2159
  return { [e]: { patterns: a, joinSym: o } };
2151
2160
  }
2152
- function bs(t) {
2161
+ function gs(t) {
2153
2162
  const e = [];
2154
2163
  for (let n = 1; n <= t.length; n++)
2155
2164
  e.push(t.slice(0, n));
2156
2165
  return e;
2157
2166
  }
2158
2167
  function jt(t, e, n, r, s) {
2159
- return bs(s).map(
2168
+ return gs(s).map(
2160
2169
  (i) => Be(t, e, n, r, i, {
2161
2170
  $isNull: !0
2162
2171
  })
@@ -2164,9 +2173,9 @@ function jt(t, e, n, r, s) {
2164
2173
  }
2165
2174
  function Sn(t, e, n, r, s) {
2166
2175
  return Object.entries(s).flatMap(([i, o]) => {
2167
- if (hs([i, o]))
2176
+ if (ys([i, o]))
2168
2177
  return Pt(t, "or", e, n, r, o);
2169
- if (ps([i, o]))
2178
+ if (bs([i, o]))
2170
2179
  return Pt(t, "and", e, n, r, o);
2171
2180
  if (i === "$entityIdStartsWith")
2172
2181
  return [];
@@ -2211,31 +2220,31 @@ function Sn(t, e, n, r, s) {
2211
2220
  ] : Be(t, e, n, r, a, o);
2212
2221
  });
2213
2222
  }
2214
- function _s(t, e, n, r) {
2223
+ function ws(t, e, n, r) {
2215
2224
  const s = Ce;
2216
2225
  return r ? Sn(s, t, e, n, r).concat(Ct(s, t, e, n)) : Ct(s, t, e, n);
2217
2226
  }
2218
- function gs(t, e, n) {
2227
+ function Ts(t, e, n) {
2219
2228
  return [t(e, n), t("time", n)];
2220
2229
  }
2221
- function ws(t, e, n, r, s, i) {
2230
+ function ms(t, e, n, r, s, i) {
2222
2231
  const [o, a, c, u, l] = mn(
2223
2232
  t,
2224
2233
  e,
2225
2234
  n,
2226
2235
  r,
2227
2236
  s
2228
- ), f = cs(c, t(n, r), i);
2237
+ ), f = ls(c, t(n, r), i);
2229
2238
  return [o, a, f, u, l];
2230
2239
  }
2231
- function Ts(t, e, n, { etype: r, level: s, form: i }, o) {
2240
+ function Ss(t, e, n, { etype: r, level: s, form: i }, o) {
2232
2241
  const a = Object.keys(i).filter((c) => c !== "$");
2233
2242
  return a.length ? Object.entries(o).map(function([u, l]) {
2234
2243
  return a.map(function(h) {
2235
2244
  var y, b, _;
2236
2245
  const p = !!(e.cardinalityInference && ((_ = (b = (y = n.linkIndex) == null ? void 0 : y[r]) == null ? void 0 : b[h]) != null && _.isSingular));
2237
2246
  try {
2238
- const [g, T, A] = ws(
2247
+ const [g, T, A] = ms(
2239
2248
  t,
2240
2249
  n,
2241
2250
  r,
@@ -2259,11 +2268,11 @@ function Ts(t, e, n, { etype: r, level: s, form: i }, o) {
2259
2268
  }, l);
2260
2269
  }) : Object.values(o);
2261
2270
  }
2262
- function ms(t, e, n) {
2263
- return n === "string" ? ss(t, e) : t > e ? 1 : -1;
2271
+ function As(t, e, n) {
2272
+ return n === "string" ? os(t, e) : t > e ? 1 : -1;
2264
2273
  }
2265
2274
  function ae(t, e, n, r, s) {
2266
- return e === r || e == null && r == null ? ts(t, n) : r == null ? 1 : e == null ? -1 : ms(e, r, s);
2275
+ return e === r || e == null && r == null ? rs(t, n) : r == null ? 1 : e == null ? -1 : As(e, r, s);
2267
2276
  }
2268
2277
  function ke([t, e], [n, r], s) {
2269
2278
  return ae(t, e, n, r, s);
@@ -2271,7 +2280,7 @@ function ke([t, e], [n, r], s) {
2271
2280
  function He(t) {
2272
2281
  return t == null ? t : new Date(t).getTime();
2273
2282
  }
2274
- function Ss(t, e, n, r) {
2283
+ function vs(t, e, n, r) {
2275
2284
  var p;
2276
2285
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2277
2286
  if (((p = e["forward-identity"]) == null ? void 0 : p[2]) === "id")
@@ -2279,24 +2288,24 @@ function Ss(t, e, n, r) {
2279
2288
  const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? He(l) : l, h = f === "date" ? He(o) : o;
2280
2289
  return ke([u, d], [s, h], f) === c;
2281
2290
  }
2282
- function As(t, e) {
2291
+ function Os(t, e) {
2283
2292
  const n = e[1];
2284
2293
  return t.getAttr(n);
2285
2294
  }
2286
- function vs(t, e, n) {
2295
+ function ks(t, e, n) {
2287
2296
  const r = Object.keys(n)[0];
2288
2297
  return E(t, e, r);
2289
2298
  }
2290
- function Os(t, e, n, r) {
2299
+ function Es(t, e, n, r) {
2291
2300
  if (n)
2292
- return As(t, n);
2301
+ return Os(t, n);
2293
2302
  if (r)
2294
- return vs(t, e, r);
2303
+ return ks(t, e, r);
2295
2304
  }
2296
- function ks(t, e, n) {
2305
+ function Is(t, e, n) {
2297
2306
  var s, i;
2298
2307
  if (!Array.isArray(n.fields))
2299
- return Rr(t, e);
2308
+ return Ur(t, e);
2300
2309
  const r = /* @__PURE__ */ new Map();
2301
2310
  for (const o of n.fields) {
2302
2311
  const a = E(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
@@ -2308,16 +2317,16 @@ function ks(t, e, n) {
2308
2317
  }
2309
2318
  return r;
2310
2319
  }
2311
- function Es(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2320
+ function Cs(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2312
2321
  var p, y;
2313
- const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = An(i), c = Is(i);
2314
- let u = Qr(t, s);
2315
- const l = r == null ? void 0 : r["start-cursor"], f = Os(e, n, l, o);
2322
+ const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = An(i), c = Ms(i);
2323
+ let u = Br(t, s);
2324
+ const l = r == null ? void 0 : r["start-cursor"], f = Es(e, n, l, o);
2316
2325
  if (f && ((y = f == null ? void 0 : f["forward-identity"]) == null ? void 0 : y[2]) !== "id") {
2317
2326
  const b = f["checked-data-type"] === "date", _ = f.id;
2318
2327
  u = u.map(([g]) => {
2319
- var A, m, O, M, z;
2320
- let T = (z = (M = (O = (m = (A = t.eav.get(g)) == null ? void 0 : A.get(_)) == null ? void 0 : m.values()) == null ? void 0 : O.next()) == null ? void 0 : M.value) == null ? void 0 : z[2];
2328
+ var A, m, O, M, U;
2329
+ let T = (U = (M = (O = (m = (A = t.eav.get(g)) == null ? void 0 : A.get(_)) == null ? void 0 : m.values()) == null ? void 0 : O.next()) == null ? void 0 : M.value) == null ? void 0 : U[2];
2321
2330
  return b && (T = He(T)), [g, T];
2322
2331
  });
2323
2332
  }
@@ -2329,17 +2338,17 @@ function Es(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2329
2338
  }
2330
2339
  );
2331
2340
  let d = {};
2332
- const h = ks(e, n, s);
2341
+ const h = Is(e, n, s);
2333
2342
  for (const b of u) {
2334
2343
  const [_] = b;
2335
- if (d[_] || !a && l && f && Ss(l, f, c, b))
2344
+ if (d[_] || !a && l && f && vs(l, f, c, b))
2336
2345
  continue;
2337
- const g = Dr(t, h, _);
2346
+ const g = xr(t, h, _);
2338
2347
  g && (d[_] = g);
2339
2348
  }
2340
2349
  return d;
2341
2350
  }
2342
- function Is(t) {
2351
+ function Ms(t) {
2343
2352
  var n;
2344
2353
  const e = (n = t.$) == null ? void 0 : n.order;
2345
2354
  return e && e[Object.keys(e)[0]] || "asc";
@@ -2349,14 +2358,14 @@ function An(t) {
2349
2358
  const e = (s = t.$) == null ? void 0 : s.offset, n = (i = t.$) == null ? void 0 : i.before, r = (o = t.$) == null ? void 0 : o.after;
2350
2359
  return !e && !n && !r;
2351
2360
  }
2352
- function Cs(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2361
+ function Ps(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2353
2362
  var d, h, p, y, b;
2354
2363
  if (!An(s) && (!o || !o["start-cursor"]))
2355
2364
  return [];
2356
- const a = ds(
2357
- _s(e, n, r, (d = s.$) == null ? void 0 : d.where),
2365
+ const a = ps(
2366
+ ws(e, n, r, (d = s.$) == null ? void 0 : d.where),
2358
2367
  i
2359
- ), c = gs(Ce, n, r), u = (h = s.$) == null ? void 0 : h.fields, l = Es(t, e, {
2368
+ ), c = Ts(Ce, n, r), u = (h = s.$) == null ? void 0 : h.fields, l = Cs(t, e, {
2360
2369
  etype: n,
2361
2370
  pageInfo: o,
2362
2371
  form: s,
@@ -2371,9 +2380,9 @@ function Cs(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2371
2380
  }
2372
2381
  return l;
2373
2382
  }
2374
- function Ms(t, e, n) {
2383
+ function js(t, e, n) {
2375
2384
  try {
2376
- return Cs(t, e, n);
2385
+ return Ps(t, e, n);
2377
2386
  } catch (r) {
2378
2387
  if (r instanceof ne)
2379
2388
  return {};
@@ -2381,10 +2390,10 @@ function Ms(t, e, n) {
2381
2390
  }
2382
2391
  }
2383
2392
  function vn(t, e, n) {
2384
- const r = Ms(t, e, n);
2385
- return Ts(Ce, t, e, n, r);
2393
+ const r = js(t, e, n);
2394
+ return Ss(Ce, t, e, n, r);
2386
2395
  }
2387
- function Ps(t) {
2396
+ function $s(t) {
2388
2397
  const e = {};
2389
2398
  for (const [n, r] of Object.entries(t))
2390
2399
  e[n] = {
@@ -2409,9 +2418,9 @@ function On({
2409
2418
  pageInfo: n == null ? void 0 : n[u]
2410
2419
  })), c;
2411
2420
  }, {}) };
2412
- return n && (o.pageInfo = Ps(n)), r && (o.aggregate = r), o;
2421
+ return n && (o.pageInfo = $s(n)), r && (o.aggregate = r), o;
2413
2422
  }
2414
- function js() {
2423
+ function Ds() {
2415
2424
  const e = {
2416
2425
  __etype: 1,
2417
2426
  __ops: 1,
@@ -2425,7 +2434,7 @@ function js() {
2425
2434
  };
2426
2435
  return new Set(Object.keys(e));
2427
2436
  }
2428
- const $s = js();
2437
+ const Rs = Ds();
2429
2438
  function Je(t, e, n) {
2430
2439
  const r = {
2431
2440
  __etype: t,
@@ -2435,7 +2444,7 @@ function Je(t, e, n) {
2435
2444
  get: (s, i) => {
2436
2445
  if (i === "__ops") return n;
2437
2446
  if (i === "__etype") return t;
2438
- if ($s.has(i))
2447
+ if (Rs.has(i))
2439
2448
  return (o, a) => Je(t, e, [
2440
2449
  ...n,
2441
2450
  a ? [i, t, e, o, a] : [i, t, e, o]
@@ -2443,7 +2452,7 @@ function Je(t, e, n) {
2443
2452
  }
2444
2453
  });
2445
2454
  }
2446
- function jo(t, e) {
2455
+ function Do(t, e) {
2447
2456
  return `lookup__${t}__${JSON.stringify(e)}`;
2448
2457
  }
2449
2458
  function Ee(t) {
@@ -2453,7 +2462,7 @@ function kn(t) {
2453
2462
  const [e, n, ...r] = t.split("__");
2454
2463
  return [n, JSON.parse(r.join("__"))];
2455
2464
  }
2456
- function Ds(t) {
2465
+ function xs(t) {
2457
2466
  return new Proxy(
2458
2467
  {
2459
2468
  __etype: t
@@ -2472,16 +2481,16 @@ function En() {
2472
2481
  {},
2473
2482
  {
2474
2483
  get(t, e) {
2475
- return Ds(e);
2484
+ return xs(e);
2476
2485
  }
2477
2486
  }
2478
2487
  );
2479
2488
  }
2480
- const $o = En();
2481
- function Rs(t) {
2489
+ const Ro = En();
2490
+ function Us(t) {
2482
2491
  return t.__ops;
2483
2492
  }
2484
- function xs(t, e) {
2493
+ function Ls(t, e) {
2485
2494
  const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
2486
2495
  for (const o of e) {
2487
2496
  const a = n[o];
@@ -2500,7 +2509,7 @@ function xs(t, e) {
2500
2509
  }
2501
2510
  return s;
2502
2511
  }
2503
- function Us(t) {
2512
+ function Fs(t) {
2504
2513
  if (Array.isArray(t))
2505
2514
  return t;
2506
2515
  const e = Object.entries(t);
@@ -2510,7 +2519,7 @@ function Us(t) {
2510
2519
  );
2511
2520
  return e[0];
2512
2521
  }
2513
- function Ls(t, e, n) {
2522
+ function Ns(t, e, n) {
2514
2523
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2515
2524
  // before assuming it's a ref lookup.
2516
2525
  !E(t, e, n);
@@ -2521,22 +2530,22 @@ function Ye(t) {
2521
2530
  throw new Error(`${t} is not a valid lookup attribute.`);
2522
2531
  return e;
2523
2532
  }
2524
- function Fs(t, e, n) {
2525
- if (!Ls(t, e, n))
2533
+ function Ks(t, e, n) {
2534
+ if (!Ns(t, e, n))
2526
2535
  return E(t, e, n);
2527
- const r = Ye(n), s = E(t, e, r) || Y(t, e, r);
2536
+ const r = Ye(n), s = E(t, e, r) || Z(t, e, r);
2528
2537
  if (s && s["value-type"] !== "ref")
2529
2538
  throw new Error(`${n} does not reference a valid link attribute.`);
2530
2539
  return s;
2531
2540
  }
2532
2541
  function Ze(t) {
2533
- return typeof t == "string" && !Ee(t) ? null : typeof t == "string" && Ee(t) ? kn(t) : Us(t);
2542
+ return typeof t == "string" && !Ee(t) ? null : typeof t == "string" && Ee(t) ? kn(t) : Fs(t);
2534
2543
  }
2535
2544
  function x(t, e, n) {
2536
2545
  const r = Ze(n);
2537
2546
  if (r === null)
2538
2547
  return n;
2539
- const [s, i] = r, o = Fs(t, e, s);
2548
+ const [s, i] = r, o = Ks(t, e, s);
2540
2549
  if (!o || !o["unique?"])
2541
2550
  throw new Error(`${s} is not a unique attribute.`);
2542
2551
  return [o.id, i];
@@ -2551,9 +2560,9 @@ function In(t, e, n, r) {
2551
2560
  s
2552
2561
  ]].concat(r) : r;
2553
2562
  }
2554
- function Ns({ attrsStore: t }, [e, n, r]) {
2563
+ function qs({ attrsStore: t }, [e, n, r]) {
2555
2564
  const s = Object.entries(r).flatMap(([i, o]) => {
2556
- const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Y(t, e, i);
2565
+ const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Z(t, e, i);
2557
2566
  return a.map((l) => c ? [
2558
2567
  "add-triple",
2559
2568
  x(t, e, n),
@@ -2570,9 +2579,9 @@ function Ns({ attrsStore: t }, [e, n, r]) {
2570
2579
  });
2571
2580
  return In(t, e, n, s);
2572
2581
  }
2573
- function Ks({ attrsStore: t }, [e, n, r]) {
2582
+ function zs({ attrsStore: t }, [e, n, r]) {
2574
2583
  const s = Object.entries(r).flatMap(([i, o]) => {
2575
- const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Y(t, e, i);
2584
+ const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Z(t, e, i);
2576
2585
  return a.map((l) => c ? [
2577
2586
  "retract-triple",
2578
2587
  x(t, e, n),
@@ -2589,7 +2598,7 @@ function Ks({ attrsStore: t }, [e, n, r]) {
2589
2598
  });
2590
2599
  return In(t, e, n, s);
2591
2600
  }
2592
- function qs(t, e, n, r) {
2601
+ function Vs(t, e, n, r) {
2593
2602
  var s;
2594
2603
  if (Array.isArray(r)) {
2595
2604
  const [i, o] = r;
@@ -2613,16 +2622,16 @@ function qs(t, e, n, r) {
2613
2622
  return !1;
2614
2623
  }
2615
2624
  function Cn({ stores: t, attrsStore: e }, [n, r, s, i]) {
2616
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : qs(t, e, n, r) ? { mode: "update" } : null;
2625
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Vs(t, e, n, r) ? { mode: "update" } : null;
2617
2626
  }
2618
- function zs(t, e) {
2627
+ function Ws(t, e) {
2619
2628
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s);
2620
2629
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
2621
2630
  const d = E(n, r, l);
2622
2631
  return d["checked-data-type"] === "date" && t.useDateObjects && (f = Ie(f)), ["add-triple", c, d.id, f, { mode: "create" }];
2623
2632
  });
2624
2633
  }
2625
- function Vs(t, e) {
2634
+ function Qs(t, e) {
2626
2635
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s), u = Cn(t, [r, c, i, o]);
2627
2636
  return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
2628
2637
  const h = E(n, r, f);
@@ -2635,10 +2644,10 @@ function Vs(t, e) {
2635
2644
  ];
2636
2645
  });
2637
2646
  }
2638
- function Ws({ attrsStore: t }, [e, n]) {
2647
+ function Gs({ attrsStore: t }, [e, n]) {
2639
2648
  return [["delete-entity", x(t, e, n), e]];
2640
2649
  }
2641
- function Qs(t, e) {
2650
+ function Bs(t, e) {
2642
2651
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s), u = Cn(t, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
2643
2652
  const p = E(n, r, d);
2644
2653
  return [
@@ -2657,38 +2666,38 @@ function Qs(t, e) {
2657
2666
  ...u ? [u] : []
2658
2667
  ]].concat(l);
2659
2668
  }
2660
- function Gs({ attrsStore: t }, [e, n, r]) {
2669
+ function Hs({ attrsStore: t }, [e, n, r]) {
2661
2670
  return [["rule-params", x(t, e, n), e, r]];
2662
2671
  }
2663
- function Bs(t) {
2672
+ function Js(t) {
2664
2673
  const [e, n, r, s, i] = t;
2665
2674
  if (!s)
2666
2675
  return t;
2667
2676
  const o = { ...s };
2668
2677
  return delete o.id, [e, n, r, o, ...i ? [i] : []];
2669
2678
  }
2670
- function Hs(t, e) {
2671
- const [n, ...r] = Bs(e);
2679
+ function Ys(t, e) {
2680
+ const [n, ...r] = Js(e);
2672
2681
  switch (n) {
2673
2682
  case "merge":
2674
- return Qs(t, r);
2683
+ return Bs(t, r);
2675
2684
  case "create":
2676
- return zs(t, r);
2685
+ return Ws(t, r);
2677
2686
  case "update":
2678
- return Vs(t, r);
2687
+ return Qs(t, r);
2679
2688
  case "link":
2680
- return Ns(t, r);
2689
+ return qs(t, r);
2681
2690
  case "unlink":
2682
- return Ks(t, r);
2691
+ return zs(t, r);
2683
2692
  case "delete":
2684
- return Ws(t, r);
2685
- case "ruleParams":
2686
2693
  return Gs(t, r);
2694
+ case "ruleParams":
2695
+ return Hs(t, r);
2687
2696
  default:
2688
2697
  throw new Error(`unsupported action ${n}`);
2689
2698
  }
2690
2699
  }
2691
- function Js(t) {
2700
+ function Zs(t) {
2692
2701
  switch (t) {
2693
2702
  case "string":
2694
2703
  case "date":
@@ -2699,13 +2708,13 @@ function Js(t) {
2699
2708
  return;
2700
2709
  }
2701
2710
  }
2702
- function Ys(t, e, n) {
2711
+ function Xs(t, e, n) {
2703
2712
  var a, c;
2704
2713
  const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
2705
2714
  if (n === "id") return null;
2706
2715
  if (!r)
2707
2716
  throw new Error(`${e}.${n} does not exist in your schema`);
2708
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Js(r == null ? void 0 : r.valueType);
2717
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Zs(r == null ? void 0 : r.valueType);
2709
2718
  return {
2710
2719
  "index?": i,
2711
2720
  "unique?": s,
@@ -2713,7 +2722,7 @@ function Ys(t, e, n) {
2713
2722
  };
2714
2723
  }
2715
2724
  function be(t, e, n, r) {
2716
- const s = t ? Ys(t, e, n) : null, i = I(), a = [I(), e, n];
2725
+ const s = t ? Xs(t, e, n) : null, i = I(), a = [I(), e, n];
2717
2726
  return {
2718
2727
  id: i,
2719
2728
  "forward-identity": a,
@@ -2726,11 +2735,11 @@ function be(t, e, n, r) {
2726
2735
  ...r || {}
2727
2736
  };
2728
2737
  }
2729
- function Zs(t, e, n) {
2738
+ function ei(t, e, n) {
2730
2739
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2731
2740
  }
2732
- function Xs(t, e, n) {
2733
- const r = Zs(t, e, n);
2741
+ function ti(t, e, n) {
2742
+ const r = ei(t, e, n);
2734
2743
  if (!r)
2735
2744
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2736
2745
  const { forward: s, reverse: i } = r;
@@ -2744,7 +2753,7 @@ function Xs(t, e, n) {
2744
2753
  };
2745
2754
  }
2746
2755
  function $t(t, e, n, r) {
2747
- const s = t ? Xs(t, e, n) : null, i = I(), o = [I(), e, n], a = [I(), n, e];
2756
+ const s = t ? ti(t, e, n) : null, i = I(), o = [I(), e, n], a = [I(), n, e];
2748
2757
  return {
2749
2758
  id: i,
2750
2759
  // @ts-ignore: ts thinks it's any[]
@@ -2761,7 +2770,7 @@ function $t(t, e, n, r) {
2761
2770
  ...r || {}
2762
2771
  };
2763
2772
  }
2764
- const ei = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ti = /* @__PURE__ */ new Set(["link", "unlink"]), ni = /* @__PURE__ */ new Set(["create", "update", "merge"]), ri = /* @__PURE__ */ new Set([
2773
+ const ni = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ri = /* @__PURE__ */ new Set(["link", "unlink"]), si = /* @__PURE__ */ new Set(["create", "update", "merge"]), ii = /* @__PURE__ */ new Set([
2765
2774
  "link",
2766
2775
  "unlink",
2767
2776
  "create",
@@ -2769,13 +2778,13 @@ const ei = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2769
2778
  "merge",
2770
2779
  "delete",
2771
2780
  "ruleParams"
2772
- ]), Xe = { "unique?": !0, "index?": !0 }, si = {
2781
+ ]), Xe = { "unique?": !0, "index?": !0 }, oi = {
2773
2782
  ...Xe,
2774
2783
  cardinality: "one"
2775
2784
  };
2776
- function ii(t) {
2785
+ function ai(t) {
2777
2786
  const e = [], [n, r, s, i] = t;
2778
- if (!ri.has(n))
2787
+ if (!ii.has(n))
2779
2788
  return e;
2780
2789
  const o = Ze(s);
2781
2790
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -2792,7 +2801,7 @@ function ii(t) {
2792
2801
  }
2793
2802
  return e;
2794
2803
  }
2795
- function oi({ attrsStore: t, schema: e }, n) {
2804
+ function ci({ attrsStore: t, schema: e }, n) {
2796
2805
  var d, h;
2797
2806
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2798
2807
  function o(p, y) {
@@ -2801,7 +2810,7 @@ function oi({ attrsStore: t, schema: e }, n) {
2801
2810
  );
2802
2811
  }
2803
2812
  function a(p, y) {
2804
- return Y(t, p, y) || s.find(
2813
+ return Z(t, p, y) || s.find(
2805
2814
  (b) => {
2806
2815
  var _, g;
2807
2816
  return ((_ = b["reverse-identity"]) == null ? void 0 : _[1]) === p && ((g = b["reverse-identity"]) == null ? void 0 : g[2]) === y;
@@ -2817,14 +2826,14 @@ function oi({ attrsStore: t, schema: e }, n) {
2817
2826
  function l(p, y) {
2818
2827
  return y.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2819
2828
  // before assuming it's a ref lookup.
2820
- !a(p, y);
2829
+ !o(p, y);
2821
2830
  }
2822
2831
  function f(p, y) {
2823
2832
  const b = o(p, y), _ = a(p, y);
2824
- u(b), u(_), !b && !_ && c($t(e, p, y, si));
2833
+ u(b), u(_), !b && !_ && c($t(e, p, y, oi));
2825
2834
  }
2826
2835
  for (const p of n)
2827
- for (const { etype: y, lookupPair: b, linkLabel: _ } of ii(p)) {
2836
+ for (const { etype: y, lookupPair: b, linkLabel: _ } of ai(p)) {
2828
2837
  const g = b[0];
2829
2838
  if (_) {
2830
2839
  f(y, _);
@@ -2848,19 +2857,19 @@ function oi({ attrsStore: t, schema: e }, n) {
2848
2857
  }
2849
2858
  for (const p of n) {
2850
2859
  const [y, b, _, g] = p;
2851
- if (ei.has(y)) {
2860
+ if (ni.has(y)) {
2852
2861
  const T = o(b, "id");
2853
2862
  u(T), T || c(be(e, b, "id", { "unique?": !0 }));
2854
2863
  for (const A of Object.keys(g)) {
2855
2864
  const m = o(b, A);
2856
- if (u(m), ni.has(y) && (m || c(
2865
+ if (u(m), si.has(y) && (m || c(
2857
2866
  be(
2858
2867
  e,
2859
2868
  b,
2860
2869
  A,
2861
2870
  A === "id" ? { "unique?": !0 } : null
2862
2871
  )
2863
- )), ti.has(y)) {
2872
+ )), ri.has(y)) {
2864
2873
  const O = a(b, A);
2865
2874
  !m && !O && c($t(e, b, A)), u(O);
2866
2875
  }
@@ -2871,19 +2880,19 @@ function oi({ attrsStore: t, schema: e }, n) {
2871
2880
  const p = { ...t.attrs };
2872
2881
  for (const y of s)
2873
2882
  p[y.id] = y;
2874
- return [new X(p, t.linkIndex), i];
2883
+ return [new H(p, t.linkIndex), i];
2875
2884
  }
2876
2885
  return [t, i];
2877
2886
  }
2878
- function ai(t, e) {
2879
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Rs(c)), [s, i] = oi(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Hs(o, c));
2887
+ function ui(t, e) {
2888
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Us(c)), [s, i] = ci(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Ys(o, c));
2880
2889
  return [...i, ...a];
2881
2890
  }
2882
2891
  function Dt(t, e) {
2883
2892
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2884
2893
  }
2885
2894
  const le = "__meta";
2886
- class ci {
2895
+ class li {
2887
2896
  constructor(e, n) {
2888
2897
  }
2889
2898
  }
@@ -3116,13 +3125,13 @@ class et {
3116
3125
  };
3117
3126
  }
3118
3127
  }
3119
- const ui = 6, li = ["kv", "querySubs", "syncSubs"];
3120
- function fi(t) {
3128
+ const fi = 6, di = ["kv", "querySubs", "syncSubs"];
3129
+ function hi(t) {
3121
3130
  return function(n) {
3122
3131
  console.error("Error in IndexedDB event", { source: t, event: n });
3123
3132
  };
3124
3133
  }
3125
- async function di(t) {
3134
+ async function pi(t) {
3126
3135
  return new Promise((e) => {
3127
3136
  const n = indexedDB.open(t);
3128
3137
  n.onerror = (r) => {
@@ -3136,7 +3145,7 @@ async function di(t) {
3136
3145
  };
3137
3146
  });
3138
3147
  }
3139
- async function hi(t, e, n) {
3148
+ async function yi(t, e, n) {
3140
3149
  const r = (
3141
3150
  // Backwards compatibility for older versions where we JSON.stringified before storing
3142
3151
  typeof e == "string" ? JSON.parse(e) : e
@@ -3176,8 +3185,8 @@ async function Rt(t, e, n) {
3176
3185
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3177
3186
  });
3178
3187
  }
3179
- async function pi(t, e) {
3180
- const n = await di(`instant_${t}_5`);
3188
+ async function bi(t, e) {
3189
+ const n = await pi(`instant_${t}_5`);
3181
3190
  if (!n)
3182
3191
  return;
3183
3192
  const r = await new Promise((l, f) => {
@@ -3200,7 +3209,7 @@ async function pi(t, e) {
3200
3209
  for (const [l, f] of r)
3201
3210
  switch (l) {
3202
3211
  case "querySubs": {
3203
- const d = hi(l, f, o);
3212
+ const d = yi(l, f, o);
3204
3213
  a.push(d);
3205
3214
  break;
3206
3215
  }
@@ -3222,9 +3231,9 @@ async function pi(t, e) {
3222
3231
  });
3223
3232
  }
3224
3233
  const xt = /* @__PURE__ */ new Map();
3225
- class Mn extends ci {
3234
+ class Mn extends li {
3226
3235
  constructor(e, n) {
3227
- super(e, n), this.dbName = `instant_${e}_${ui}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3236
+ super(e, n), this.dbName = `instant_${e}_${fi}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3228
3237
  }
3229
3238
  _init() {
3230
3239
  return new Promise((e, n) => {
@@ -3235,8 +3244,8 @@ class Mn extends ci {
3235
3244
  }, s.onsuccess = (i) => {
3236
3245
  const a = i.target.result;
3237
3246
  if (r) {
3238
- const c = pi(this._appId, a).catch((u) => {
3239
- fi("Error upgrading store from version 5 to 6.")(u);
3247
+ const c = bi(this._appId, a).catch((u) => {
3248
+ hi("Error upgrading store from version 5 to 6.")(u);
3240
3249
  });
3241
3250
  xt.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
3242
3251
  } else {
@@ -3250,7 +3259,7 @@ class Mn extends ci {
3250
3259
  }
3251
3260
  _upgradeStore(e) {
3252
3261
  const r = e.target.result;
3253
- for (const s of li)
3262
+ for (const s of di)
3254
3263
  r.objectStoreNames.contains(s) || r.createObjectStore(s);
3255
3264
  }
3256
3265
  async getItem(e) {
@@ -3352,29 +3361,29 @@ class Me extends de {
3352
3361
  return "InstantAPIError";
3353
3362
  }
3354
3363
  }
3355
- async function q(t, e) {
3364
+ async function z(t, e) {
3356
3365
  const n = await fetch(t, e), r = await n.json();
3357
3366
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Me({ status: n.status, body: r }));
3358
3367
  }
3359
- function yi({
3368
+ function _i({
3360
3369
  apiURI: t,
3361
3370
  appId: e,
3362
3371
  email: n
3363
3372
  }) {
3364
- return q(`${t}/runtime/auth/send_magic_code`, {
3373
+ return z(`${t}/runtime/auth/send_magic_code`, {
3365
3374
  method: "POST",
3366
3375
  headers: { "content-type": "application/json" },
3367
3376
  body: JSON.stringify({ "app-id": e, email: n })
3368
3377
  });
3369
3378
  }
3370
- async function bi({
3379
+ async function gi({
3371
3380
  apiURI: t,
3372
3381
  appId: e,
3373
3382
  email: n,
3374
3383
  code: r,
3375
3384
  refreshToken: s
3376
3385
  }) {
3377
- return await q(`${t}/runtime/auth/verify_magic_code`, {
3386
+ return await z(`${t}/runtime/auth/verify_magic_code`, {
3378
3387
  method: "POST",
3379
3388
  headers: { "content-type": "application/json" },
3380
3389
  body: JSON.stringify({
@@ -3385,12 +3394,12 @@ async function bi({
3385
3394
  })
3386
3395
  });
3387
3396
  }
3388
- async function _i({
3397
+ async function wi({
3389
3398
  apiURI: t,
3390
3399
  appId: e,
3391
3400
  refreshToken: n
3392
3401
  }) {
3393
- return await q(`${t}/runtime/auth/verify_refresh_token`, {
3402
+ return await z(`${t}/runtime/auth/verify_refresh_token`, {
3394
3403
  method: "POST",
3395
3404
  headers: { "content-type": "application/json" },
3396
3405
  body: JSON.stringify({
@@ -3399,11 +3408,11 @@ async function _i({
3399
3408
  })
3400
3409
  });
3401
3410
  }
3402
- async function gi({
3411
+ async function Ti({
3403
3412
  apiURI: t,
3404
3413
  appId: e
3405
3414
  }) {
3406
- return await q(`${t}/runtime/auth/sign_in_guest`, {
3415
+ return await z(`${t}/runtime/auth/sign_in_guest`, {
3407
3416
  method: "POST",
3408
3417
  headers: { "content-type": "application/json" },
3409
3418
  body: JSON.stringify({
@@ -3418,7 +3427,7 @@ async function Ut({
3418
3427
  codeVerifier: r,
3419
3428
  refreshToken: s
3420
3429
  }) {
3421
- return await q(`${t}/runtime/oauth/token`, {
3430
+ return await z(`${t}/runtime/oauth/token`, {
3422
3431
  method: "POST",
3423
3432
  headers: { "content-type": "application/json" },
3424
3433
  body: JSON.stringify({
@@ -3429,7 +3438,7 @@ async function Ut({
3429
3438
  })
3430
3439
  });
3431
3440
  }
3432
- async function wi({
3441
+ async function mi({
3433
3442
  apiURI: t,
3434
3443
  appId: e,
3435
3444
  nonce: n,
@@ -3437,7 +3446,7 @@ async function wi({
3437
3446
  clientName: s,
3438
3447
  refreshToken: i
3439
3448
  }) {
3440
- return await q(`${t}/runtime/oauth/id_token`, {
3449
+ return await z(`${t}/runtime/oauth/id_token`, {
3441
3450
  method: "POST",
3442
3451
  headers: { "content-type": "application/json" },
3443
3452
  body: JSON.stringify({
@@ -3449,12 +3458,12 @@ async function wi({
3449
3458
  })
3450
3459
  });
3451
3460
  }
3452
- async function Ti({
3461
+ async function Si({
3453
3462
  apiURI: t,
3454
3463
  appId: e,
3455
3464
  refreshToken: n
3456
3465
  }) {
3457
- return await q(`${t}/runtime/signout`, {
3466
+ return await z(`${t}/runtime/signout`, {
3458
3467
  method: "POST",
3459
3468
  headers: {
3460
3469
  "content-type": "application/json"
@@ -3465,7 +3474,7 @@ async function Ti({
3465
3474
  })
3466
3475
  });
3467
3476
  }
3468
- async function mi({
3477
+ async function Ai({
3469
3478
  apiURI: t,
3470
3479
  appId: e,
3471
3480
  path: n,
@@ -3480,19 +3489,19 @@ async function mi({
3480
3489
  authorization: `Bearer ${s}`,
3481
3490
  "content-type": i || r.type
3482
3491
  };
3483
- return o && (a["content-disposition"] = o), await q(`${t}/storage/upload`, {
3492
+ return o && (a["content-disposition"] = o), await z(`${t}/storage/upload`, {
3484
3493
  method: "PUT",
3485
3494
  headers: a,
3486
3495
  body: r
3487
3496
  });
3488
3497
  }
3489
- async function Si({
3498
+ async function vi({
3490
3499
  apiURI: t,
3491
3500
  appId: e,
3492
3501
  path: n,
3493
3502
  refreshToken: r
3494
3503
  }) {
3495
- const { data: s } = await q(
3504
+ const { data: s } = await z(
3496
3505
  `${t}/storage/files?app_id=${e}&filename=${encodeURIComponent(n)}`,
3497
3506
  {
3498
3507
  method: "DELETE",
@@ -3504,14 +3513,14 @@ async function Si({
3504
3513
  );
3505
3514
  return s;
3506
3515
  }
3507
- async function Ai({
3516
+ async function Oi({
3508
3517
  apiURI: t,
3509
3518
  appId: e,
3510
3519
  fileName: n,
3511
3520
  refreshToken: r,
3512
3521
  metadata: s = {}
3513
3522
  }) {
3514
- const { data: i } = await q(`${t}/storage/signed-upload-url`, {
3523
+ const { data: i } = await z(`${t}/storage/signed-upload-url`, {
3515
3524
  method: "POST",
3516
3525
  headers: {
3517
3526
  "content-type": "application/json",
@@ -3524,7 +3533,7 @@ async function Ai({
3524
3533
  });
3525
3534
  return i;
3526
3535
  }
3527
- async function vi(t, e) {
3536
+ async function ki(t, e) {
3528
3537
  return (await fetch(t, {
3529
3538
  method: "PUT",
3530
3539
  body: e,
@@ -3533,13 +3542,13 @@ async function vi(t, e) {
3533
3542
  }
3534
3543
  })).ok;
3535
3544
  }
3536
- async function Oi({
3545
+ async function Ei({
3537
3546
  apiURI: t,
3538
3547
  appId: e,
3539
3548
  path: n,
3540
3549
  refreshToken: r
3541
3550
  }) {
3542
- const { data: s } = await q(
3551
+ const { data: s } = await z(
3543
3552
  `${t}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(
3544
3553
  n
3545
3554
  )}`,
@@ -3562,7 +3571,7 @@ function Lt(t, e) {
3562
3571
  n[r] = t[r];
3563
3572
  }), n;
3564
3573
  }
3565
- function ki(t, e, n) {
3574
+ function Ii(t, e, n) {
3566
3575
  const r = {
3567
3576
  peers: {}
3568
3577
  };
@@ -3579,7 +3588,7 @@ function ki(t, e, n) {
3579
3588
  }
3580
3589
  return r;
3581
3590
  }
3582
- function Ei(t, e) {
3591
+ function Ci(t, e) {
3583
3592
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !At(t.user, e.user)) || !an(t.peers, e.peers)) return !0;
3584
3593
  for (const r of Object.keys(t.peers))
3585
3594
  if (!At(t.peers[r], e.peers[r])) return !0;
@@ -3628,8 +3637,8 @@ function Kt(t) {
3628
3637
  }, e;
3629
3638
  }, {});
3630
3639
  }
3631
- const Rn = "v0.22.86-experimental.split-store.20178922132.1";
3632
- function Ii(t, e) {
3640
+ const Rn = "v0.22.86-experimental.split-store.20183617880.1";
3641
+ function Mi(t, e) {
3633
3642
  return {
3634
3643
  info: t ? (...n) => console.info(...n, e()) : () => {
3635
3644
  },
@@ -3749,7 +3758,7 @@ const qt = [
3749
3758
  "before",
3750
3759
  "fields",
3751
3760
  "aggregate"
3752
- ], Ci = (t) => t.valueType || "unknown", xn = (t, e, n = !1) => {
3761
+ ], Pi = (t) => t.valueType || "unknown", xn = (t, e, n = !1) => {
3753
3762
  if (n || t == null) return !0;
3754
3763
  switch (e) {
3755
3764
  case "string":
@@ -3763,7 +3772,7 @@ const qt = [
3763
3772
  default:
3764
3773
  return !0;
3765
3774
  }
3766
- }, Mi = (t, e, n, r, s, i, o) => {
3775
+ }, ji = (t, e, n, r, s, i, o) => {
3767
3776
  const a = i.valueType === "json", c = (u, l, f) => {
3768
3777
  if (!xn(f, l, a))
3769
3778
  throw new v(
@@ -3808,13 +3817,13 @@ const qt = [
3808
3817
  );
3809
3818
  }
3810
3819
  }, ee = (t, e, n, r, s) => {
3811
- const i = Ci(n), o = n.valueType === "json";
3820
+ const i = Pi(n), o = n.valueType === "json";
3812
3821
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3813
3822
  if (o)
3814
3823
  return;
3815
3824
  const c = t;
3816
3825
  for (const [u, l] of Object.entries(c))
3817
- Mi(
3826
+ ji(
3818
3827
  u,
3819
3828
  l,
3820
3829
  i,
@@ -3828,7 +3837,7 @@ const qt = [
3828
3837
  `Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`,
3829
3838
  s
3830
3839
  );
3831
- }, Pi = (t, e, n, r, s) => {
3840
+ }, $i = (t, e, n, r, s) => {
3832
3841
  const i = t.split(".");
3833
3842
  if (i.length < 2)
3834
3843
  throw new v(
@@ -3922,7 +3931,7 @@ const qt = [
3922
3931
  continue;
3923
3932
  }
3924
3933
  if (s.includes(".")) {
3925
- Pi(
3934
+ $i(
3926
3935
  s,
3927
3936
  i,
3928
3937
  e,
@@ -3965,7 +3974,7 @@ const qt = [
3965
3974
  );
3966
3975
  }
3967
3976
  }
3968
- }, ji = (t, e, n, r, s = 0) => {
3977
+ }, Di = (t, e, n, r, s = 0) => {
3969
3978
  for (const o of Object.keys(t))
3970
3979
  if (!qt.includes(o))
3971
3980
  throw new v(
@@ -4033,7 +4042,7 @@ const qt = [
4033
4042
  `Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`,
4034
4043
  `${r}.$`
4035
4044
  );
4036
- ji(
4045
+ Di(
4037
4046
  a,
4038
4047
  e,
4039
4048
  n,
@@ -4081,12 +4090,12 @@ const qt = [
4081
4090
  }
4082
4091
  }
4083
4092
  }, Vt = (t) => typeof t != "string" ? !1 : Ee(t) ? !0 : te(t);
4084
- class F extends Error {
4093
+ class N extends Error {
4085
4094
  constructor(e) {
4086
4095
  super(e), this.name = "TransactionValidationError";
4087
4096
  }
4088
4097
  }
4089
- const Fn = (t) => t.length > 0 ? t.join(", ") : "none", $i = (t, e) => new F(
4098
+ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4090
4099
  `Entity '${t}' does not exist in schema. Available entities: ${Fn(e)}`
4091
4100
  ), xe = {
4092
4101
  string: (t) => typeof t == "string",
@@ -4094,38 +4103,38 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", $i = (t, e) => new F(
4094
4103
  boolean: (t) => typeof t == "boolean",
4095
4104
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4096
4105
  json: () => !0
4097
- }, Di = (t, e) => {
4106
+ }, xi = (t, e) => {
4098
4107
  var n;
4099
4108
  return t == null ? !0 : ((n = xe[e.valueType]) == null ? void 0 : n.call(xe, t)) ?? !1;
4100
4109
  }, Nn = (t, e) => {
4101
4110
  const n = e.entities[t];
4102
4111
  if (!n)
4103
- throw $i(t, Object.keys(e.entities));
4112
+ throw Ri(t, Object.keys(e.entities));
4104
4113
  return n;
4105
4114
  }, Ue = (t, e, n) => {
4106
4115
  const r = Nn(t, n);
4107
4116
  if (typeof e != "object" || e === null)
4108
- throw new F(
4117
+ throw new N(
4109
4118
  `Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`
4110
4119
  );
4111
4120
  for (const [s, i] of Object.entries(e)) {
4112
4121
  if (s === "id") continue;
4113
4122
  const o = r.attrs[s];
4114
- if (o && !Di(i, o))
4115
- throw new F(
4123
+ if (o && !xi(i, o))
4124
+ throw new N(
4116
4125
  `Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`
4117
4126
  );
4118
4127
  }
4119
4128
  }, Wt = (t, e, n) => {
4120
4129
  const r = Nn(t, n);
4121
4130
  if (typeof e != "object" || e === null)
4122
- throw new F(
4131
+ throw new N(
4123
4132
  `Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`
4124
4133
  );
4125
4134
  for (const [s, i] of Object.entries(e)) {
4126
4135
  if (!r.links[s]) {
4127
4136
  const a = Object.keys(r.links);
4128
- throw new F(
4137
+ throw new N(
4129
4138
  `Link '${s}' does not exist on entity '${t}'. Available links: ${Fn(a)}`
4130
4139
  );
4131
4140
  }
@@ -4133,16 +4142,16 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", $i = (t, e) => new F(
4133
4142
  if (Array.isArray(i)) {
4134
4143
  for (const a of i)
4135
4144
  if (!Vt(a))
4136
- throw new F(
4145
+ throw new N(
4137
4146
  `Invalid entity ID in link '${s}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`
4138
4147
  );
4139
4148
  } else if (!Vt(i))
4140
- throw new F(
4149
+ throw new N(
4141
4150
  `Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`
4142
4151
  );
4143
4152
  }
4144
4153
  }
4145
- }, Ri = {
4154
+ }, Ui = {
4146
4155
  create: Ue,
4147
4156
  update: Ue,
4148
4157
  merge: Ue,
@@ -4150,36 +4159,36 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", $i = (t, e) => new F(
4150
4159
  unlink: Wt,
4151
4160
  delete: () => {
4152
4161
  }
4153
- }, xi = (t, e) => {
4162
+ }, Li = (t, e) => {
4154
4163
  if (!e) return;
4155
4164
  const [n, r, s, i] = t;
4156
4165
  if (!Array.isArray(s) && !te(s))
4157
- throw new F(
4166
+ throw new N(
4158
4167
  `Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`
4159
4168
  );
4160
4169
  if (typeof r != "string")
4161
- throw new F(
4170
+ throw new N(
4162
4171
  `Entity name must be a string, but received: ${typeof r}`
4163
4172
  );
4164
- const o = Ri[n];
4173
+ const o = Ui[n];
4165
4174
  o && i !== void 0 && o(r, i, e);
4166
- }, Ui = (t, e) => {
4175
+ }, Fi = (t, e) => {
4167
4176
  const n = Array.isArray(t) ? t : [t];
4168
4177
  for (const r of n) {
4169
4178
  if (!r || typeof r != "object")
4170
- throw new F(
4179
+ throw new N(
4171
4180
  `Transaction chunk must be an object, but received: ${typeof r}`
4172
4181
  );
4173
4182
  if (!Array.isArray(r.__ops))
4174
- throw new F(
4183
+ throw new N(
4175
4184
  `Transaction chunk must have __ops array, but received: ${typeof r.__ops}`
4176
4185
  );
4177
4186
  for (const s of r.__ops) {
4178
4187
  if (!Array.isArray(s))
4179
- throw new F(
4188
+ throw new N(
4180
4189
  `Transaction operation must be an array, but received: ${typeof s}`
4181
4190
  );
4182
- xi(s, e);
4191
+ Li(s, e);
4183
4192
  }
4184
4193
  }
4185
4194
  };
@@ -4212,7 +4221,7 @@ class Qt {
4212
4221
  return this.conn.send(JSON.stringify(e));
4213
4222
  }
4214
4223
  }
4215
- class Li {
4224
+ class Ni {
4216
4225
  constructor(e, n) {
4217
4226
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Kn++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4218
4227
  this.initParams || this.handleError();
@@ -4295,7 +4304,7 @@ class Li {
4295
4304
  this.handleClose();
4296
4305
  }
4297
4306
  }
4298
- function Fi(t, e) {
4307
+ function Ki(t, e) {
4299
4308
  const n = t.values;
4300
4309
  if (n) {
4301
4310
  const r = hn(n.attrsStore, null);
@@ -4307,7 +4316,7 @@ function Fi(t, e) {
4307
4316
  }
4308
4317
  return t;
4309
4318
  }
4310
- function Ni(t, e) {
4319
+ function qi(t, e) {
4311
4320
  var n;
4312
4321
  if (e.values) {
4313
4322
  const r = [];
@@ -4322,7 +4331,7 @@ function Ni(t, e) {
4322
4331
  } else
4323
4332
  return e;
4324
4333
  }
4325
- function Ki(t, e, n) {
4334
+ function zi(t, e, n) {
4326
4335
  var i, o;
4327
4336
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = n == null ? void 0 : n.state) == null ? void 0 : o.txId;
4328
4337
  return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
@@ -4352,7 +4361,7 @@ function Bt(t, e, n) {
4352
4361
  break;
4353
4362
  }
4354
4363
  }
4355
- function qi(t, e, n) {
4364
+ function Vi(t, e, n) {
4356
4365
  var s, i;
4357
4366
  const r = {};
4358
4367
  for (const { action: o, triple: a } of n) {
@@ -4379,14 +4388,14 @@ function qi(t, e, n) {
4379
4388
  function _e(t, e) {
4380
4389
  return { [t.table]: e.map((n) => n.entity) };
4381
4390
  }
4382
- function zi(t, e) {
4391
+ function Wi(t, e) {
4383
4392
  var r;
4384
4393
  if (t.orderFieldType)
4385
4394
  return t.orderFieldType;
4386
4395
  const n = t.orderField === "serverCreatedAt" ? "number" : (r = E(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
4387
4396
  return t.orderFieldType = n, n;
4388
4397
  }
4389
- function Vi(t, e, n) {
4398
+ function Qi(t, e, n) {
4390
4399
  const r = e;
4391
4400
  if (t.orderField === "serverCreatedAt") {
4392
4401
  n.sort(
@@ -4431,14 +4440,14 @@ function Vi(t, e, n) {
4431
4440
  }
4432
4441
  );
4433
4442
  }
4434
- var Wi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Wi || {});
4435
- class Qi {
4443
+ var Gi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Gi || {});
4444
+ class Bi {
4436
4445
  constructor(e, n, r, s, i, o) {
4437
4446
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new et({
4438
4447
  persister: n,
4439
- merge: Ki,
4440
- serialize: Ni,
4441
- parse: (a, c) => Fi(c, this.config.useDateObjects),
4448
+ merge: zi,
4449
+ serialize: qi,
4450
+ parse: (a, c) => Ki(c, this.config.useDateObjects),
4442
4451
  objectSize: (a) => {
4443
4452
  var c;
4444
4453
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4648,9 +4657,9 @@ class Qi {
4648
4657
  e: for (const [b, _] of Object.entries(u))
4649
4658
  for (let g = 0; g < f.length; g++) {
4650
4659
  const T = f[g];
4651
- if (Or(T.store, b)) {
4660
+ if (Er(T.store, b)) {
4652
4661
  Bt(T.store, l.attrsStore, _);
4653
- const A = Le(s, T.store, l.attrsStore), m = qi(
4662
+ const A = Le(s, T.store, l.attrsStore), m = Vi(
4654
4663
  T.store,
4655
4664
  l.attrsStore,
4656
4665
  _
@@ -4690,8 +4699,8 @@ class Qi {
4690
4699
  const p = [];
4691
4700
  for (const b of c.sort().reverse())
4692
4701
  p.push(f[b].entity), f.splice(b, 1);
4693
- const y = zi(s, this.getAttrs);
4694
- Vi(s, y, f), this.notifyCbs(r, {
4702
+ const y = Wi(s, this.getAttrs);
4703
+ Qi(s, y, f), this.notifyCbs(r, {
4695
4704
  type: "SyncTransaction",
4696
4705
  data: _e(s, (o = s.values) == null ? void 0 : o.entities),
4697
4706
  added: h,
@@ -4738,11 +4747,11 @@ const W = {
4738
4747
  AUTHENTICATED: "authenticated",
4739
4748
  CLOSED: "closed",
4740
4749
  ERRORED: "errored"
4741
- }, Gi = 3e4, Bi = 3e4, Hi = 200, Ji = {
4750
+ }, Hi = 3e4, Ji = 3e4, Yi = 200, Zi = {
4742
4751
  apiURI: "https://api.instantdb.com",
4743
4752
  websocketURI: "wss://api.instantdb.com/runtime/session"
4744
4753
  }, Fe = "_instant_oauth_redirect", se = "currentUser";
4745
- function Yi({
4754
+ function Xi({
4746
4755
  transportType: t,
4747
4756
  appId: e,
4748
4757
  apiURI: n,
@@ -4755,7 +4764,7 @@ function Yi({
4755
4764
  case "ws":
4756
4765
  return new Qt(`${r}?app_id=${e}`);
4757
4766
  case "sse":
4758
- return new Li(
4767
+ return new Ni(
4759
4768
  s,
4760
4769
  `${n}/runtime/sse?app_id=${e}`
4761
4770
  );
@@ -4763,7 +4772,7 @@ function Yi({
4763
4772
  throw new Error("Unknown transport type " + t);
4764
4773
  }
4765
4774
  }
4766
- function Zi() {
4775
+ function eo() {
4767
4776
  return typeof window < "u" || typeof chrome < "u";
4768
4777
  }
4769
4778
  const Ht = {
@@ -4772,7 +4781,7 @@ const Ht = {
4772
4781
  "refresh-presence": !0,
4773
4782
  "patch-presence": !0
4774
4783
  };
4775
- function Xi(t, e) {
4784
+ function to(t, e) {
4776
4785
  var r;
4777
4786
  const n = typeof t == "string" ? JSON.parse(t) : t;
4778
4787
  if ((r = n == null ? void 0 : n.result) != null && r.store) {
@@ -4790,7 +4799,7 @@ function Xi(t, e) {
4790
4799
  }
4791
4800
  return n;
4792
4801
  }
4793
- function eo(t, e) {
4802
+ function no(t, e) {
4794
4803
  const { result: n, ...r } = e, s = (
4795
4804
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
4796
4805
  r
@@ -4805,7 +4814,7 @@ function eo(t, e) {
4805
4814
  }
4806
4815
  return s;
4807
4816
  }
4808
- function to(t, e) {
4817
+ function ro(t, e) {
4809
4818
  switch (t) {
4810
4819
  case "pendingMutations":
4811
4820
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4813,7 +4822,7 @@ function to(t, e) {
4813
4822
  return e;
4814
4823
  }
4815
4824
  }
4816
- function no(t, e) {
4825
+ function so(t, e) {
4817
4826
  switch (t) {
4818
4827
  case "pendingMutations":
4819
4828
  return [...e.entries()];
@@ -4821,7 +4830,7 @@ function no(t, e) {
4821
4830
  return e;
4822
4831
  }
4823
4832
  }
4824
- function ro(t, e, n) {
4833
+ function io(t, e, n) {
4825
4834
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
4826
4835
  return r && !s && n && (n.result = r), n || e;
4827
4836
  }
@@ -4831,7 +4840,7 @@ function Jt(t) {
4831
4840
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
4832
4841
  });
4833
4842
  }
4834
- class so {
4843
+ class oo {
4835
4844
  constructor(e, n = Mn, r = Pn, s, i) {
4836
4845
  /** @type {sts.AttrsStore | undefined} */
4837
4846
  w(this, "attrs");
@@ -4926,9 +4935,9 @@ class so {
4926
4935
  });
4927
4936
  /** Applies transactions locally and sends transact message to server */
4928
4937
  w(this, "pushTx", (e) => {
4929
- this.config.disableValidation || Ui(e, this.config.schema);
4938
+ this.config.disableValidation || Fi(e, this.config.schema);
4930
4939
  try {
4931
- const n = ai(
4940
+ const n = ui(
4932
4941
  {
4933
4942
  attrsStore: this.optimisticAttrs(),
4934
4943
  schema: this.config.schema,
@@ -5067,10 +5076,10 @@ class so {
5067
5076
  this._reconnectTimeoutMs
5068
5077
  ), this._scheduleReconnect();
5069
5078
  });
5070
- if (this._EventSource = i, this.config = { ...Ji, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Bi, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Hi, this._log = Ii(
5079
+ if (this._EventSource = i, this.config = { ...Zi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ji, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Yi, this._log = Mi(
5071
5080
  e.verbose || pt || jn,
5072
5081
  () => this._reactorStats()
5073
- ), this.versions = { ...s || {}, "@instantdb/core": Rn }, this.config.schema && (this._linkIndex = Kt(this.config.schema)), !!Zi()) {
5082
+ ), this.versions = { ...s || {}, "@instantdb/core": Rn }, this.config.schema && (this._linkIndex = Kt(this.config.schema)), !!eo()) {
5074
5083
  if (!e.appId)
5075
5084
  throw new Error("Instant must be initialized with an appId.");
5076
5085
  if (!te(e.appId))
@@ -5087,7 +5096,7 @@ class so {
5087
5096
  } catch (c) {
5088
5097
  this._log.error("[error] handle broadcast channel", c);
5089
5098
  }
5090
- })), this._initStorage(n), this._syncTable = new Qi(
5099
+ })), this._initStorage(n), this._syncTable = new Bi(
5091
5100
  this._trySendAuthed.bind(this),
5092
5101
  new n(this.config.appId, "syncSubs"),
5093
5102
  {
@@ -5138,9 +5147,9 @@ class so {
5138
5147
  _initStorage(e) {
5139
5148
  this.querySubs = new et({
5140
5149
  persister: new e(this.config.appId, "querySubs"),
5141
- merge: ro,
5142
- serialize: eo,
5143
- parse: (n, r) => Xi(r, this.config.useDateObjects),
5150
+ merge: io,
5151
+ serialize: no,
5152
+ parse: (n, r) => to(r, this.config.useDateObjects),
5144
5153
  // objectSize
5145
5154
  objectSize: (n) => {
5146
5155
  var r, s, i;
@@ -5159,8 +5168,8 @@ class so {
5159
5168
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new et({
5160
5169
  persister: new e(this.config.appId, "kv"),
5161
5170
  merge: this._onMergeKv,
5162
- serialize: no,
5163
- parse: to,
5171
+ serialize: so,
5172
+ parse: ro,
5164
5173
  objectSize: () => 0,
5165
5174
  logger: this._log,
5166
5175
  saveThrottleMs: 100,
@@ -5289,34 +5298,43 @@ class so {
5289
5298
  });
5290
5299
  const b = Jt(y.entries()), _ = d.map((g) => {
5291
5300
  var yt, bt, _t, gt;
5292
- const T = g["instaql-query"], A = g["instaql-result"], m = P(T), O = Nt(A), M = Se(
5293
- this.ensureAttrs(),
5301
+ const T = g["instaql-query"], A = g["instaql-result"], m = P(T), O = Nt(A), M = this.ensureAttrs(), U = Se(
5302
+ M,
5294
5303
  O,
5295
5304
  r,
5296
5305
  this.config.useDateObjects
5297
- ), z = this._applyOptimisticUpdates(
5306
+ ), { store: $e, attrsStore: zn } = this._applyOptimisticUpdates(
5307
+ U,
5298
5308
  M,
5299
- this.ensureAttrs(),
5300
5309
  b,
5301
5310
  p
5302
- ), $e = (bt = (yt = A == null ? void 0 : A[0]) == null ? void 0 : yt.data) == null ? void 0 : bt["page-info"], zn = (gt = (_t = A == null ? void 0 : A[0]) == null ? void 0 : _t.data) == null ? void 0 : gt.aggregate;
5303
- return { q: T, hash: m, store: z, pageInfo: $e, aggregate: zn };
5311
+ ), Vn = (bt = (yt = A == null ? void 0 : A[0]) == null ? void 0 : yt.data) == null ? void 0 : bt["page-info"], Wn = (gt = (_t = A == null ? void 0 : A[0]) == null ? void 0 : _t.data) == null ? void 0 : gt.aggregate;
5312
+ return {
5313
+ q: T,
5314
+ hash: m,
5315
+ store: $e,
5316
+ attrsStore: zn,
5317
+ pageInfo: Vn,
5318
+ aggregate: Wn
5319
+ };
5304
5320
  });
5305
- _.forEach(({ hash: g, q: T, store: A, pageInfo: m, aggregate: O }) => {
5306
- this.querySubs.updateInPlace((M) => {
5307
- if (!M[g]) {
5308
- this._log.error("Missing value in querySubs", { hash: g, q: T });
5309
- return;
5310
- }
5311
- M[g].result = {
5312
- store: A,
5313
- attrsStore: this.ensureAttrs(),
5314
- pageInfo: m,
5315
- aggregate: O,
5316
- processedTxId: p
5317
- };
5318
- });
5319
- }), this._cleanupPendingMutationsQueries(), _.forEach(({ hash: g }) => {
5321
+ _.forEach(
5322
+ ({ hash: g, q: T, store: A, attrsStore: m, pageInfo: O, aggregate: M }) => {
5323
+ this.querySubs.updateInPlace((U) => {
5324
+ if (!U[g]) {
5325
+ this._log.error("Missing value in querySubs", { hash: g, q: T });
5326
+ return;
5327
+ }
5328
+ U[g].result = {
5329
+ store: A,
5330
+ attrsStore: m,
5331
+ pageInfo: O,
5332
+ aggregate: M,
5333
+ processedTxId: p
5334
+ };
5335
+ });
5336
+ }
5337
+ ), this._cleanupPendingMutationsQueries(), _.forEach(({ hash: g }) => {
5320
5338
  this.notifyOne(g);
5321
5339
  });
5322
5340
  break;
@@ -5462,7 +5480,7 @@ class so {
5462
5480
  i && (i.dfd.reject(s), this._completeQueryOnce(e, n, i.dfd));
5463
5481
  }
5464
5482
  _setAttrs(e) {
5465
- this.attrs = new X(
5483
+ this.attrs = new H(
5466
5484
  e.reduce((n, r) => (n[r.id] = r, n), {}),
5467
5485
  this._linkIndex
5468
5486
  ), this.notifyAttrsSubs();
@@ -5509,7 +5527,7 @@ class so {
5509
5527
  const s = P(e), i = this._startQuerySub(e, s);
5510
5528
  return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
5511
5529
  () => r.reject(new Error("Query timed out")),
5512
- Gi
5530
+ Hi
5513
5531
  ), r.promise;
5514
5532
  }
5515
5533
  _completeQueryOnce(e, n, r) {
@@ -5552,7 +5570,7 @@ class so {
5552
5570
  return E(e, d, h);
5553
5571
  }, i = (l) => {
5554
5572
  const [f, d, h] = l["forward-identity"];
5555
- return Y(e, d, h);
5573
+ return Z(e, d, h);
5556
5574
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
5557
5575
  let a = !1;
5558
5576
  const c = (l, f) => {
@@ -5577,7 +5595,7 @@ class so {
5577
5595
  a = !0;
5578
5596
  continue;
5579
5597
  }
5580
- const y = a ? xs(o, h) : h;
5598
+ const y = a ? Ls(o, h) : h;
5581
5599
  d.push(y);
5582
5600
  }
5583
5601
  return a ? d : l;
@@ -5610,13 +5628,13 @@ class so {
5610
5628
  r.push(u);
5611
5629
  }
5612
5630
  if (!n.size && !r.length)
5613
- return this.attrs || new X({}, this._linkIndex);
5631
+ return this.attrs || new H({}, this._linkIndex);
5614
5632
  const s = { ...((o = this.attrs) == null ? void 0 : o.attrs) || {} };
5615
5633
  for (const a of r)
5616
5634
  s[a.id] = a;
5617
5635
  for (const a of n)
5618
5636
  delete s[a];
5619
- return new X(s, this._linkIndex);
5637
+ return new H(s, this._linkIndex);
5620
5638
  }
5621
5639
  /** Runs instaql on a query and a store */
5622
5640
  dataForQuery(e) {
@@ -5632,21 +5650,19 @@ class so {
5632
5650
  const { store: l, attrsStore: f, pageInfo: d, aggregate: h, processedTxId: p } = c, y = this._rewriteMutationsSorted(
5633
5651
  f,
5634
5652
  o
5635
- ), b = this._applyOptimisticUpdates(
5636
- l,
5637
- f,
5638
- y,
5639
- p
5640
- );
5653
+ ), { store: b, attrsStore: _ } = this._applyOptimisticUpdates(l, f, y, p);
5641
5654
  return { data: On(
5642
- { store: b, attrsStore: f, pageInfo: d, aggregate: h },
5655
+ { store: b, attrsStore: _, pageInfo: d, aggregate: h },
5643
5656
  a
5644
5657
  ), querySubVersion: r, pendingMutationsVersion: i };
5645
5658
  }
5646
5659
  _applyOptimisticUpdates(e, n, r, s) {
5647
5660
  for (const [i, o] of r)
5648
- (!o["tx-id"] || s && o["tx-id"] > s) && (e = Ur(e, n, o["tx-steps"]));
5649
- return e;
5661
+ if (!o["tx-id"] || s && o["tx-id"] > s) {
5662
+ const a = Fr(e, n, o["tx-steps"]);
5663
+ e = a.store, n = a.attrsStore;
5664
+ }
5665
+ return { store: e, attrsStore: n };
5650
5666
  }
5651
5667
  /** Re-compute all subscriptions */
5652
5668
  notifyAll() {
@@ -5768,7 +5784,7 @@ class so {
5768
5784
  return;
5769
5785
  }
5770
5786
  const e = this._transport;
5771
- this._transport = Yi({
5787
+ this._transport = Xi({
5772
5788
  transportType: this._transportType,
5773
5789
  appId: this.config.appId,
5774
5790
  apiURI: this.config.apiURI,
@@ -5962,7 +5978,7 @@ class so {
5962
5978
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5963
5979
  }
5964
5980
  sendMagicCode({ email: e }) {
5965
- return yi({
5981
+ return _i({
5966
5982
  apiURI: this.config.apiURI,
5967
5983
  appId: this.config.appId,
5968
5984
  email: e
@@ -5970,7 +5986,7 @@ class so {
5970
5986
  }
5971
5987
  async signInWithMagicCode({ email: e, code: n }) {
5972
5988
  var o;
5973
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await bi({
5989
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await gi({
5974
5990
  apiURI: this.config.apiURI,
5975
5991
  appId: this.config.appId,
5976
5992
  email: e,
@@ -5980,7 +5996,7 @@ class so {
5980
5996
  return await this.changeCurrentUser(i.user), i;
5981
5997
  }
5982
5998
  async signInWithCustomToken(e) {
5983
- const n = await _i({
5999
+ const n = await wi({
5984
6000
  apiURI: this.config.apiURI,
5985
6001
  appId: this.config.appId,
5986
6002
  refreshToken: e
@@ -5988,7 +6004,7 @@ class so {
5988
6004
  return await this.changeCurrentUser(n.user), n;
5989
6005
  }
5990
6006
  async signInAsGuest() {
5991
- const e = await gi({
6007
+ const e = await Ti({
5992
6008
  apiURI: this.config.apiURI,
5993
6009
  appId: this.config.appId
5994
6010
  });
@@ -6003,7 +6019,7 @@ class so {
6003
6019
  this._log.info("[auth-invalidate] skipped invalidateToken");
6004
6020
  return;
6005
6021
  }
6006
- Ti({
6022
+ Si({
6007
6023
  apiURI: this.config.apiURI,
6008
6024
  appId: this.config.appId,
6009
6025
  refreshToken: r
@@ -6056,7 +6072,7 @@ class so {
6056
6072
  */
6057
6073
  async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
6058
6074
  var a;
6059
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await wi({
6075
+ const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await mi({
6060
6076
  apiURI: this.config.apiURI,
6061
6077
  appId: this.config.appId,
6062
6078
  idToken: e,
@@ -6097,7 +6113,7 @@ class so {
6097
6113
  getPresence(e, n, r = {}) {
6098
6114
  const s = this._rooms[n], i = this._presence[n];
6099
6115
  return !s || !i || !i.result ? null : {
6100
- ...ki(i.result, r, this._sessionId),
6116
+ ...Ii(i.result, r, this._sessionId),
6101
6117
  isLoading: !s.isConnected,
6102
6118
  error: s.error
6103
6119
  };
@@ -6153,7 +6169,7 @@ class so {
6153
6169
  }
6154
6170
  _notifyPresenceSub(e, n) {
6155
6171
  const r = this.getPresence("", e, n);
6156
- r && (n.prev && !Ei(r, n.prev) || (n.prev = r, n.cb(r)));
6172
+ r && (n.prev && !Ci(r, n.prev) || (n.prev = r, n.cb(r)));
6157
6173
  }
6158
6174
  _patchPresencePeers(e, n) {
6159
6175
  var o, a, c;
@@ -6166,7 +6182,7 @@ class so {
6166
6182
  for (let [l, f, d] of n)
6167
6183
  switch (f) {
6168
6184
  case "+":
6169
- ir(u, l, d);
6185
+ ar(u, l, d);
6170
6186
  break;
6171
6187
  case "r":
6172
6188
  vt(u, l, d);
@@ -6229,7 +6245,7 @@ class so {
6229
6245
  async uploadFile(e, n, r) {
6230
6246
  var o;
6231
6247
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
6232
- return mi({
6248
+ return Ai({
6233
6249
  ...r,
6234
6250
  apiURI: this.config.apiURI,
6235
6251
  appId: this.config.appId,
@@ -6241,7 +6257,7 @@ class so {
6241
6257
  async deleteFile(e) {
6242
6258
  var i;
6243
6259
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6244
- return await Si({
6260
+ return await vi({
6245
6261
  apiURI: this.config.apiURI,
6246
6262
  appId: this.config.appId,
6247
6263
  path: e,
@@ -6252,18 +6268,18 @@ class so {
6252
6268
  // ---------------------------------
6253
6269
  async upload(e, n) {
6254
6270
  var c;
6255
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await Ai({
6271
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await Oi({
6256
6272
  apiURI: this.config.apiURI,
6257
6273
  appId: this.config.appId,
6258
6274
  fileName: i,
6259
6275
  refreshToken: s
6260
6276
  });
6261
- return await vi(o, n);
6277
+ return await ki(o, n);
6262
6278
  }
6263
6279
  async getDownloadUrl(e) {
6264
6280
  var i;
6265
6281
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6266
- return await Oi({
6282
+ return await Ei({
6267
6283
  apiURI: this.config.apiURI,
6268
6284
  appId: this.config.appId,
6269
6285
  path: e,
@@ -6271,7 +6287,7 @@ class so {
6271
6287
  });
6272
6288
  }
6273
6289
  }
6274
- function io(t, e) {
6290
+ function ao(t, e) {
6275
6291
  return new je(
6276
6292
  qn(t, e),
6277
6293
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -6283,25 +6299,25 @@ function io(t, e) {
6283
6299
  void 0
6284
6300
  );
6285
6301
  }
6286
- function oo(t) {
6302
+ function co(t) {
6287
6303
  return new Pe(t, {});
6288
6304
  }
6289
- function ao() {
6305
+ function uo() {
6290
6306
  return new $("string", !0, !1);
6291
6307
  }
6292
- function co() {
6308
+ function lo() {
6293
6309
  return new $("number", !0, !1);
6294
6310
  }
6295
- function uo() {
6311
+ function fo() {
6296
6312
  return new $("boolean", !0, !1);
6297
6313
  }
6298
- function lo() {
6314
+ function ho() {
6299
6315
  return new $("date", !0, !1);
6300
6316
  }
6301
- function fo() {
6317
+ function po() {
6302
6318
  return new $("json", !0, !1);
6303
6319
  }
6304
- function ho() {
6320
+ function yo() {
6305
6321
  return new $("json", !0, !1);
6306
6322
  }
6307
6323
  function qn(t, e) {
@@ -6325,7 +6341,7 @@ function qn(t, e) {
6325
6341
  ])
6326
6342
  );
6327
6343
  }
6328
- function po({
6344
+ function bo({
6329
6345
  entities: t,
6330
6346
  links: e,
6331
6347
  rooms: n
@@ -6342,23 +6358,23 @@ function po({
6342
6358
  s
6343
6359
  );
6344
6360
  }
6345
- const Do = {
6361
+ const xo = {
6346
6362
  // constructs
6347
- graph: io,
6348
- schema: po,
6349
- entity: oo,
6363
+ graph: ao,
6364
+ schema: bo,
6365
+ entity: co,
6350
6366
  // value types
6351
- string: ao,
6352
- number: co,
6353
- boolean: uo,
6354
- date: lo,
6355
- json: fo,
6356
- any: ho
6367
+ string: uo,
6368
+ number: lo,
6369
+ boolean: fo,
6370
+ date: ho,
6371
+ json: po,
6372
+ any: yo
6357
6373
  };
6358
6374
  let ge;
6359
- function yo(t, e) {
6375
+ function _o(t, e) {
6360
6376
  ge == null || ge.dispose();
6361
- const n = mo(e), r = go(e, a), s = _o(bo(t));
6377
+ const n = Ao(e), r = To(e, a), s = wo(go(t));
6362
6378
  function i(l) {
6363
6379
  var f;
6364
6380
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
@@ -6380,10 +6396,10 @@ function yo(t, e) {
6380
6396
  }
6381
6397
  return u();
6382
6398
  }
6383
- function bo(t) {
6399
+ function go(t) {
6384
6400
  return `${pt || $n ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6385
6401
  }
6386
- function _o(t) {
6402
+ function wo(t) {
6387
6403
  const e = document.createElement("iframe");
6388
6404
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6389
6405
  width: "100%",
@@ -6392,7 +6408,7 @@ function _o(t) {
6392
6408
  border: "none"
6393
6409
  }), { element: e };
6394
6410
  }
6395
- function go(t, e) {
6411
+ function To(t, e) {
6396
6412
  const n = `
6397
6413
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6398
6414
  <rect width="512" height="512" fill="black"/>
@@ -6402,7 +6418,7 @@ function go(t, e) {
6402
6418
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
6403
6419
  // pos
6404
6420
  position: "fixed",
6405
- ...wo(t.position),
6421
+ ...mo(t.position),
6406
6422
  height: "32px",
6407
6423
  width: "32px",
6408
6424
  // layout
@@ -6417,7 +6433,7 @@ function go(t, e) {
6417
6433
  cursor: "pointer"
6418
6434
  }), r.addEventListener("click", e), { element: r };
6419
6435
  }
6420
- function wo(t) {
6436
+ function mo(t) {
6421
6437
  switch (t) {
6422
6438
  case "bottom-left":
6423
6439
  return { bottom: "24px", left: "24px" };
@@ -6429,7 +6445,7 @@ function wo(t) {
6429
6445
  return { top: "24px", left: "24px" };
6430
6446
  }
6431
6447
  }
6432
- function To(t) {
6448
+ function So(t) {
6433
6449
  switch (t) {
6434
6450
  case "bottom-left":
6435
6451
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6441,11 +6457,11 @@ function To(t) {
6441
6457
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6442
6458
  }
6443
6459
  }
6444
- function mo(t) {
6460
+ function Ao(t) {
6445
6461
  const e = document.createElement("div");
6446
6462
  Object.assign(e.style, {
6447
6463
  position: "fixed",
6448
- ...To(t.position),
6464
+ ...So(t.position),
6449
6465
  display: "block",
6450
6466
  borderRadius: "4px",
6451
6467
  border: "1px #ccc solid",
@@ -6458,37 +6474,37 @@ function mo(t) {
6458
6474
  }
6459
6475
  return { element: e, isVisible: n };
6460
6476
  }
6461
- const So = {
6477
+ const vo = {
6462
6478
  apiURI: "https://api.instantdb.com",
6463
6479
  websocketURI: "wss://api.instantdb.com/runtime/session"
6464
6480
  };
6465
- function Ao() {
6481
+ function Oo() {
6466
6482
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6467
6483
  }
6468
- function vo() {
6484
+ function ko() {
6469
6485
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6470
6486
  }
6471
6487
  function tt(t) {
6472
6488
  const e = t.__adminToken;
6473
6489
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6474
6490
  }
6475
- const nt = vo(), Yt = Ao();
6476
- class Oo {
6491
+ const nt = ko(), Yt = Oo();
6492
+ class Eo {
6477
6493
  constructor(e) {
6478
6494
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
6479
6495
  }
6480
6496
  }
6481
- class ko {
6497
+ class Io {
6482
6498
  constructor(e) {
6483
6499
  this.db = e, this.uploadFile = (n, r, s = {}) => this.db.uploadFile(n, r, s), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
6484
6500
  }
6485
6501
  }
6486
- function Ro(t) {
6502
+ function Uo(t) {
6487
6503
  return JSON.parse(JSON.stringify(t));
6488
6504
  }
6489
- class Eo {
6505
+ class Co {
6490
6506
  constructor(e) {
6491
- this.tx = En(), this._reactor = e, this.auth = new Oo(this._reactor), this.storage = new ko(this._reactor);
6507
+ this.tx = En(), this._reactor = e, this.auth = new Eo(this._reactor), this.storage = new Io(this._reactor);
6492
6508
  }
6493
6509
  /**
6494
6510
  * Use this to write data! You can create, update, delete, and link objects
@@ -6671,19 +6687,19 @@ function Zt(t) {
6671
6687
  const n = P(t);
6672
6688
  return Yt.set(t, n), n;
6673
6689
  }
6674
- function Io(t, e) {
6690
+ function Mo(t, e) {
6675
6691
  return Zt(t._reactor.config.schema) !== Zt(e);
6676
6692
  }
6677
- function Co(t, e, n, r, s) {
6693
+ function Po(t, e, n, r, s) {
6678
6694
  const i = {
6679
6695
  ...t,
6680
6696
  useDateObjects: t.useDateObjects ?? !1
6681
6697
  }, o = nt[tt(i)];
6682
6698
  if (o)
6683
- return Io(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6684
- const a = new so(
6699
+ return Mo(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6700
+ const a = new oo(
6685
6701
  {
6686
- ...So,
6702
+ ...vo,
6687
6703
  ...i,
6688
6704
  cardinalityInference: !!i.schema
6689
6705
  },
@@ -6691,10 +6707,10 @@ function Co(t, e, n, r, s) {
6691
6707
  n || Pn,
6692
6708
  { ...r || {}, "@instantdb/core": Rn },
6693
6709
  s
6694
- ), c = new Eo(a);
6695
- return nt[tt(i)] = c, Mo(i.appId, i.devtool), c;
6710
+ ), c = new Co(a);
6711
+ return nt[tt(i)] = c, jo(i.appId, i.devtool), c;
6696
6712
  }
6697
- function Mo(t, e) {
6713
+ function jo(t, e) {
6698
6714
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6699
6715
  return;
6700
6716
  const n = {
@@ -6702,33 +6718,33 @@ function Mo(t, e) {
6702
6718
  allowedHosts: ["localhost"],
6703
6719
  ...typeof e == "object" ? e : {}
6704
6720
  };
6705
- n.allowedHosts.includes(window.location.hostname) && yo(t, n);
6721
+ n.allowedHosts.includes(window.location.hostname) && _o(t, n);
6706
6722
  }
6707
- const xo = Co;
6723
+ const Lo = Po;
6708
6724
  export {
6709
- Oo as Auth,
6725
+ Eo as Auth,
6710
6726
  Mn as IndexedDBStorage,
6711
6727
  Me as InstantAPIError,
6712
- Eo as InstantCoreDatabase,
6728
+ Co as InstantCoreDatabase,
6713
6729
  de as InstantError,
6714
6730
  v as QueryValidationError,
6715
- ko as Storage,
6716
- ci as StorageInterface,
6717
- Wi as SyncTableCallbackEventType,
6718
- F as TransactionValidationError,
6731
+ Io as Storage,
6732
+ li as StorageInterface,
6733
+ Gi as SyncTableCallbackEventType,
6734
+ N as TransactionValidationError,
6719
6735
  Pn as WindowNetworkListener,
6720
- Ro as coerceQuery,
6736
+ Uo as coerceQuery,
6721
6737
  Ie as coerceToDate,
6722
- Rs as getOps,
6723
- Do as i,
6738
+ Us as getOps,
6739
+ xo as i,
6724
6740
  I as id,
6725
- Co as init,
6726
- xo as init_experimental,
6727
- jo as lookup,
6728
- $o as tx,
6741
+ Po as init,
6742
+ Lo as init_experimental,
6743
+ Do as lookup,
6744
+ Ro as tx,
6729
6745
  En as txInit,
6730
6746
  zt as validateQuery,
6731
- Ui as validateTransactions,
6747
+ Fi as validateTransactions,
6732
6748
  Rn as version,
6733
6749
  P as weakHash
6734
6750
  };