@instantdb/react 0.22.86-experimental.split-store.20183617880.1 → 0.22.86-experimental.split-store.20247643606.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.
@@ -1,4 +1,4 @@
1
- import oi, { useRef as ot, useCallback as we, useSyncExternalStore as en, useEffect as ke, useMemo as tn, useState as ai, createElement as Os } from "react";
1
+ import oi, { useRef as ot, useCallback as we, useSyncExternalStore as en, useEffect as ke, useMemo as tn, useState as ui, createElement as Os } from "react";
2
2
  function B(t) {
3
3
  if (typeof t == "number")
4
4
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -41,7 +41,7 @@ const L = {
41
41
  Remove: "remove",
42
42
  Replace: "replace",
43
43
  Add: "add"
44
- }, ui = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Es = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), vt = Symbol.iterator, ne = {
44
+ }, ai = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Es = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), vt = Symbol.iterator, ne = {
45
45
  mutable: "mutable",
46
46
  immutable: "immutable"
47
47
  }, In = {};
@@ -65,7 +65,7 @@ function Pn(t) {
65
65
  function Mn(t) {
66
66
  return Object.getPrototypeOf(t) === Map.prototype;
67
67
  }
68
- function te(t) {
68
+ function ee(t) {
69
69
  var e;
70
70
  return (e = t.copy) !== null && e !== void 0 ? e : t.original;
71
71
  }
@@ -73,14 +73,14 @@ function je(t) {
73
73
  return !!j(t);
74
74
  }
75
75
  function j(t) {
76
- return typeof t != "object" ? null : t == null ? void 0 : t[ui];
76
+ return typeof t != "object" ? null : t == null ? void 0 : t[ai];
77
77
  }
78
78
  function Rn(t) {
79
79
  var e;
80
80
  const n = j(t);
81
81
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
82
82
  }
83
- function ae(t, e) {
83
+ function ue(t, e) {
84
84
  if (!t || typeof t != "object")
85
85
  return !1;
86
86
  let n;
@@ -112,12 +112,12 @@ function Ce(t) {
112
112
  function _e(t, e) {
113
113
  return Ce(t) === 2 ? t.get(e) : t[e];
114
114
  }
115
- function ut(t, e, n) {
115
+ function at(t, e, n) {
116
116
  Ce(t) === 2 ? t.set(e, n) : t[e] = n;
117
117
  }
118
118
  function Qt(t, e) {
119
119
  const n = j(t);
120
- return (n ? te(n) : t)[e];
120
+ return (n ? ee(n) : t)[e];
121
121
  }
122
122
  function be(t, e) {
123
123
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
@@ -197,7 +197,7 @@ function Q(t) {
197
197
  t.copy || (t.copy = di(t.original, t.options));
198
198
  }
199
199
  function Ye(t) {
200
- if (!ae(t))
200
+ if (!ue(t))
201
201
  return Rn(t);
202
202
  if (Array.isArray(t))
203
203
  return t.map(Ye);
@@ -240,13 +240,13 @@ function Re(t, e, n, r, i) {
240
240
  n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], i = i ?? [];
241
241
  const o = n.has(t) ? n.get(t) : t;
242
242
  if (r.length > 0) {
243
- const a = r.indexOf(o);
244
- if (o && typeof o == "object" && a !== -1)
245
- throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, a).map((u, c) => {
246
- if (typeof u == "symbol")
247
- return `[${u.toString()}]`;
243
+ const u = r.indexOf(o);
244
+ if (o && typeof o == "object" && u !== -1)
245
+ throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, u).map((a, c) => {
246
+ if (typeof a == "symbol")
247
+ return `[${a.toString()}]`;
248
248
  const d = r[c];
249
- return typeof u == "object" && (d instanceof Map || d instanceof Set) ? Array.from(d.keys()).indexOf(u) : u;
249
+ return typeof a == "object" && (d instanceof Map || d instanceof Set) ? Array.from(d.keys()).indexOf(a) : a;
250
250
  }).join("/")}`);
251
251
  r.push(o), i.push(e);
252
252
  } else
@@ -258,25 +258,25 @@ function Re(t, e, n, r, i) {
258
258
  }
259
259
  switch (Ce(t)) {
260
260
  case 2:
261
- for (const [a, u] of t)
262
- Re(a, a, n, r, i), Re(u, a, n, r, i);
261
+ for (const [u, a] of t)
262
+ Re(u, u, n, r, i), Re(a, u, n, r, i);
263
263
  t.set = t.clear = t.delete = br;
264
264
  break;
265
265
  case 3:
266
- for (const a of t)
267
- Re(a, a, n, r, i);
266
+ for (const u of t)
267
+ Re(u, u, n, r, i);
268
268
  t.add = t.clear = t.delete = br;
269
269
  break;
270
270
  case 1:
271
271
  Object.freeze(t);
272
272
  let o = 0;
273
- for (const a of t)
274
- Re(a, o, n, r, i), o += 1;
273
+ for (const u of t)
274
+ Re(u, o, n, r, i), o += 1;
275
275
  break;
276
276
  default:
277
- Object.freeze(t), Object.keys(t).forEach((a) => {
278
- const u = t[a];
279
- Re(u, a, n, r, i);
277
+ Object.freeze(t), Object.keys(t).forEach((u) => {
278
+ const a = t[u];
279
+ Re(a, u, n, r, i);
280
280
  });
281
281
  }
282
282
  r.pop(), i.pop();
@@ -295,22 +295,22 @@ function xn(t, e) {
295
295
  t.forEach((r, i) => e(i, r, t));
296
296
  }
297
297
  function fi(t, e, n) {
298
- if (je(t) || !ae(t, n) || e.has(t) || Object.isFrozen(t))
298
+ if (je(t) || !ue(t, n) || e.has(t) || Object.isFrozen(t))
299
299
  return;
300
300
  const r = t instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
301
301
  if (e.add(t), xn(t, (s, o) => {
302
- var a;
302
+ var u;
303
303
  if (je(o)) {
304
- const u = j(o);
305
- Q(u);
306
- const c = !((a = u.assignedMap) === null || a === void 0) && a.size || u.operated ? u.copy : u.original;
307
- ut(r ? i : t, s, c);
304
+ const a = j(o);
305
+ Q(a);
306
+ const c = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
307
+ at(r ? i : t, s, c);
308
308
  } else
309
309
  fi(o, e, n);
310
310
  }), i) {
311
311
  const s = t, o = Array.from(s);
312
- s.clear(), o.forEach((a) => {
313
- s.add(i.has(a) ? i.get(a) : a);
312
+ s.clear(), o.forEach((u) => {
313
+ s.add(i.has(u) ? i.get(u) : u);
314
314
  });
315
315
  }
316
316
  }
@@ -335,28 +335,28 @@ function sn(t, e, n, r) {
335
335
  function $n(t, e, n, r) {
336
336
  const i = j(n);
337
337
  i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
338
- var a;
339
- const u = t.type === 3 ? t.setMap : t.copy;
340
- if (be(_e(u, e), n)) {
338
+ var u;
339
+ const a = t.type === 3 ? t.setMap : t.copy;
340
+ if (be(_e(a, e), n)) {
341
341
  let c = i.original;
342
- i.copy && (c = i.copy), rn(t), sn(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(c, i.original)), ut(u, e, c);
342
+ i.copy && (c = i.copy), rn(t), sn(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(c, i.original)), at(a, e, c);
343
343
  }
344
- }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ae(n, t.options) && t.finalities.draft.push(() => {
344
+ }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ue(n, t.options) && t.finalities.draft.push(() => {
345
345
  const s = t.type === 3 ? t.setMap : t.copy;
346
346
  be(_e(s, e), n) && Cs(t, e);
347
347
  });
348
348
  }
349
349
  function Is(t, e, n, r, i) {
350
- let { original: s, assignedMap: o, options: a } = t, u = t.copy;
351
- u.length < s.length && ([s, u] = [u, s], [n, r] = [r, n]);
350
+ let { original: s, assignedMap: o, options: u } = t, a = t.copy;
351
+ a.length < s.length && ([s, a] = [a, s], [n, r] = [r, n]);
352
352
  for (let c = 0; c < s.length; c += 1)
353
- if (o.get(c.toString()) && u[c] !== s[c]) {
353
+ if (o.get(c.toString()) && a[c] !== s[c]) {
354
354
  const d = e.concat([c]), f = Ee(d, i);
355
355
  n.push({
356
356
  op: L.Replace,
357
357
  path: f,
358
358
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
359
- value: St(u[c])
359
+ value: St(a[c])
360
360
  }), r.push({
361
361
  op: L.Replace,
362
362
  path: f,
@@ -364,17 +364,17 @@ function Is(t, e, n, r, i) {
364
364
  value: St(s[c])
365
365
  });
366
366
  }
367
- for (let c = s.length; c < u.length; c += 1) {
367
+ for (let c = s.length; c < a.length; c += 1) {
368
368
  const d = e.concat([c]), f = Ee(d, i);
369
369
  n.push({
370
370
  op: L.Add,
371
371
  path: f,
372
372
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
373
- value: St(u[c])
373
+ value: St(a[c])
374
374
  });
375
375
  }
376
- if (s.length < u.length) {
377
- const { arrayLengthAssignment: c = !0 } = a.enablePatches;
376
+ if (s.length < a.length) {
377
+ const { arrayLengthAssignment: c = !0 } = u.enablePatches;
378
378
  if (c) {
379
379
  const d = e.concat(["length"]), f = Ee(d, i);
380
380
  r.push({
@@ -383,7 +383,7 @@ function Is(t, e, n, r, i) {
383
383
  value: s.length
384
384
  });
385
385
  } else
386
- for (let d = u.length; s.length < d; d -= 1) {
386
+ for (let d = a.length; s.length < d; d -= 1) {
387
387
  const f = e.concat([d - 1]), l = Ee(f, i);
388
388
  r.push({
389
389
  op: L.Remove,
@@ -393,47 +393,47 @@ function Is(t, e, n, r, i) {
393
393
  }
394
394
  }
395
395
  function Ps({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
396
- n.forEach((a, u) => {
397
- const c = _e(t, u), d = St(_e(e, u)), f = a ? tt(t, u) ? L.Replace : L.Add : L.Remove;
396
+ n.forEach((u, a) => {
397
+ const c = _e(t, a), d = St(_e(e, a)), f = u ? tt(t, a) ? L.Replace : L.Add : L.Remove;
398
398
  if (be(c, d) && f === L.Replace)
399
399
  return;
400
- const l = r.concat(u), p = Ee(l, o);
400
+ const l = r.concat(a), p = Ee(l, o);
401
401
  i.push(f === L.Remove ? { op: f, path: p } : { op: f, path: p, value: d }), s.push(f === L.Add ? { op: L.Remove, path: p } : f === L.Remove ? { op: L.Add, path: p, value: c } : { op: L.Replace, path: p, value: c });
402
402
  });
403
403
  }
404
404
  function Ms({ original: t, copy: e }, n, r, i, s) {
405
405
  let o = 0;
406
- t.forEach((a) => {
407
- if (!e.has(a)) {
408
- const u = n.concat([o]), c = Ee(u, s);
406
+ t.forEach((u) => {
407
+ if (!e.has(u)) {
408
+ const a = n.concat([o]), c = Ee(a, s);
409
409
  r.push({
410
410
  op: L.Remove,
411
411
  path: c,
412
- value: a
412
+ value: u
413
413
  }), i.unshift({
414
414
  op: L.Add,
415
415
  path: c,
416
- value: a
416
+ value: u
417
417
  });
418
418
  }
419
419
  o += 1;
420
- }), o = 0, e.forEach((a) => {
421
- if (!t.has(a)) {
422
- const u = n.concat([o]), c = Ee(u, s);
420
+ }), o = 0, e.forEach((u) => {
421
+ if (!t.has(u)) {
422
+ const a = n.concat([o]), c = Ee(a, s);
423
423
  r.push({
424
424
  op: L.Add,
425
425
  path: c,
426
- value: a
426
+ value: u
427
427
  }), i.unshift({
428
428
  op: L.Remove,
429
429
  path: c,
430
- value: a
430
+ value: u
431
431
  });
432
432
  }
433
433
  o += 1;
434
434
  });
435
435
  }
436
- function at(t, e, n, r) {
436
+ function ut(t, e, n, r) {
437
437
  const { pathAsArray: i = !0 } = t.options.enablePatches;
438
438
  switch (t.type) {
439
439
  case 0:
@@ -446,18 +446,18 @@ function at(t, e, n, r) {
446
446
  }
447
447
  }
448
448
  const jt = (t, e, n = !1) => {
449
- if (typeof t == "object" && t !== null && (!ae(t, e) || n))
449
+ if (typeof t == "object" && t !== null && (!ue(t, e) || n))
450
450
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
451
451
  }, on = {
452
452
  get size() {
453
- return te(j(this)).size;
453
+ return ee(j(this)).size;
454
454
  },
455
455
  has(t) {
456
- return te(j(this)).has(t);
456
+ return ee(j(this)).has(t);
457
457
  },
458
458
  set(t, e) {
459
- const n = j(this), r = te(n);
460
- return (!r.has(t) || !be(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), $n(n, t, e, at)), this;
459
+ const n = j(this), r = ee(n);
460
+ return (!r.has(t) || !be(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), $n(n, t, e, ut)), this;
461
461
  },
462
462
  delete(t) {
463
463
  if (!this.has(t))
@@ -476,14 +476,14 @@ const jt = (t, e, n = !1) => {
476
476
  },
477
477
  forEach(t, e) {
478
478
  const n = j(this);
479
- te(n).forEach((r, i) => {
479
+ ee(n).forEach((r, i) => {
480
480
  t.call(e, this.get(i), i, this);
481
481
  });
482
482
  },
483
483
  get(t) {
484
484
  var e, n;
485
- const r = j(this), i = te(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, ne)) === ne.mutable;
486
- if (r.options.strict && jt(i, r.options, s), s || r.finalized || !ae(i, r.options) || i !== r.original.get(t))
485
+ const r = j(this), i = ee(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, ne)) === ne.mutable;
486
+ if (r.options.strict && jt(i, r.options, s), s || r.finalized || !ue(i, r.options) || i !== r.original.get(t))
487
487
  return i;
488
488
  const o = In.createDraft({
489
489
  original: i,
@@ -495,7 +495,7 @@ const jt = (t, e, n = !1) => {
495
495
  return Q(r), r.copy.set(t, o), o;
496
496
  },
497
497
  keys() {
498
- return te(j(this)).keys();
498
+ return ee(j(this)).keys();
499
499
  },
500
500
  values() {
501
501
  const t = this.keys();
@@ -535,9 +535,9 @@ const jt = (t, e, n = !1) => {
535
535
  if (s.done)
536
536
  return s;
537
537
  const o = s.value;
538
- let a = t.setMap.get(o);
539
- const u = j(a), c = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, a, ne)) === ne.mutable;
540
- if (t.options.strict && jt(o, t.options, c), !c && !u && ae(o, t.options) && !t.finalized && t.original.has(o)) {
538
+ let u = t.setMap.get(o);
539
+ const a = j(u), c = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, u, ne)) === ne.mutable;
540
+ if (t.options.strict && jt(o, t.options, c), !c && !a && ue(o, t.options) && !t.finalized && t.original.has(o)) {
541
541
  const d = In.createDraft({
542
542
  original: o,
543
543
  parentDraft: t,
@@ -545,11 +545,11 @@ const jt = (t, e, n = !1) => {
545
545
  finalities: t.finalities,
546
546
  options: t.options
547
547
  });
548
- t.setMap.set(o, d), a = d;
549
- } else u && (a = u.proxy);
548
+ t.setMap.set(o, d), u = d;
549
+ } else a && (u = a.proxy);
550
550
  return {
551
551
  done: !1,
552
- value: n ? a : [a, a]
552
+ value: n ? u : [u, u]
553
553
  };
554
554
  }, Ct = {
555
555
  get size() {
@@ -565,7 +565,7 @@ const jt = (t, e, n = !1) => {
565
565
  },
566
566
  add(t) {
567
567
  const e = j(this);
568
- return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), $n(e, t, t, at)), this;
568
+ return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), $n(e, t, t, ut)), this;
569
569
  },
570
570
  delete(t) {
571
571
  if (!this.has(t))
@@ -646,7 +646,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
646
646
  const s = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
647
647
  if (s && li.has(s))
648
648
  return s;
649
- if (e === ui)
649
+ if (e === ai)
650
650
  return t;
651
651
  let o;
652
652
  if (t.options.mark) {
@@ -654,32 +654,32 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
654
654
  if (o = t.options.mark(c, ne), o === ne.mutable)
655
655
  return t.options.strict && jt(c, t.options, !0), c;
656
656
  }
657
- const a = te(t);
658
- if (a instanceof Map && Rs.includes(e)) {
657
+ const u = ee(t);
658
+ if (u instanceof Map && Rs.includes(e)) {
659
659
  if (e === "size")
660
660
  return Object.getOwnPropertyDescriptor(on, "size").get.call(t.proxy);
661
661
  const c = on[e];
662
662
  if (c)
663
663
  return c.bind(t.proxy);
664
664
  }
665
- if (a instanceof Set && xs.includes(e)) {
665
+ if (u instanceof Set && xs.includes(e)) {
666
666
  if (e === "size")
667
667
  return Object.getOwnPropertyDescriptor(Ct, "size").get.call(t.proxy);
668
668
  const c = Ct[e];
669
669
  if (c)
670
670
  return c.bind(t.proxy);
671
671
  }
672
- if (!tt(a, e)) {
673
- const c = yr(a, e);
672
+ if (!tt(u, e)) {
673
+ const c = yr(u, e);
674
674
  return c ? "value" in c ? c.value : (
675
675
  // !case: support for getter
676
676
  (i = c.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
677
677
  ) : void 0;
678
678
  }
679
- const u = a[e];
680
- if (t.options.strict && jt(u, t.options), t.finalized || !ae(u, t.options))
681
- return u;
682
- if (u === Qt(t.original, e)) {
679
+ const a = u[e];
680
+ if (t.options.strict && jt(a, t.options), t.finalized || !ue(a, t.options))
681
+ return a;
682
+ if (a === Qt(t.original, e)) {
683
683
  if (Q(t), t.copy[e] = Dn({
684
684
  original: t.original[e],
685
685
  parentDraft: t,
@@ -692,7 +692,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
692
692
  }
693
693
  return t.copy[e];
694
694
  }
695
- return u;
695
+ return a;
696
696
  },
697
697
  set(t, e, n) {
698
698
  var r;
@@ -701,20 +701,20 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
701
701
  let i;
702
702
  if (t.type === 1 && e !== "length" && !(Number.isInteger(i = Number(e)) && i >= 0 && (e === 0 || i === 0 || String(i) === String(e))))
703
703
  throw new Error("Only supports setting array indices and the 'length' property.");
704
- const s = yr(te(t), e);
704
+ const s = yr(ee(t), e);
705
705
  if (s != null && s.set)
706
706
  return s.set.call(t.proxy, n), !0;
707
- const o = Qt(te(t), e), a = j(o);
708
- return a && be(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) : (be(n, o) && (n !== void 0 || tt(t.original, e)) || (Q(t), fe(t), tt(t.original, e) && be(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, $n(t, e, n, at)), !0);
707
+ const o = Qt(ee(t), e), u = j(o);
708
+ return u && be(u.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) : (be(n, o) && (n !== void 0 || tt(t.original, e)) || (Q(t), fe(t), tt(t.original, e) && be(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, $n(t, e, n, ut)), !0);
709
709
  },
710
710
  has(t, e) {
711
- return e in te(t);
711
+ return e in ee(t);
712
712
  },
713
713
  ownKeys(t) {
714
- return Reflect.ownKeys(te(t));
714
+ return Reflect.ownKeys(ee(t));
715
715
  },
716
716
  getOwnPropertyDescriptor(t, e) {
717
- const n = te(t), r = Reflect.getOwnPropertyDescriptor(n, e);
717
+ const n = ee(t), r = Reflect.getOwnPropertyDescriptor(n, e);
718
718
  return r && {
719
719
  writable: !0,
720
720
  configurable: t.type !== 1 || e !== "length",
@@ -737,7 +737,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
737
737
  }
738
738
  };
739
739
  function Dn(t) {
740
- const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ce(e), a = {
740
+ const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ce(e), u = {
741
741
  type: o,
742
742
  finalized: !1,
743
743
  parent: n,
@@ -749,43 +749,43 @@ function Dn(t) {
749
749
  // Mapping of draft Set items to their corresponding draft values.
750
750
  setMap: o === 3 ? new Map(e.entries()) : void 0
751
751
  };
752
- (r || "key" in t) && (a.key = r);
753
- const { proxy: u, revoke: c } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, hi);
754
- if (i.revoke.push(c), li.add(u), a.proxy = u, n) {
752
+ (r || "key" in t) && (u.key = r);
753
+ const { proxy: a, revoke: c } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, hi);
754
+ if (i.revoke.push(c), li.add(a), u.proxy = a, n) {
755
755
  const d = n;
756
756
  d.finalities.draft.push((f, l) => {
757
757
  var p, y;
758
- const b = j(u);
758
+ const b = j(a);
759
759
  let _ = d.type === 3 ? d.setMap : d.copy;
760
760
  const T = _e(_, r), g = j(T);
761
761
  if (g) {
762
762
  let m = g.original;
763
- g.operated && (m = Rn(T)), rn(g), sn(g, at, f, l), d.options.enableAutoFreeze && (d.options.updatedValues = (p = d.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), d.options.updatedValues.set(m, g.original)), ut(_, r, m);
763
+ g.operated && (m = Rn(T)), rn(g), sn(g, ut, f, l), d.options.enableAutoFreeze && (d.options.updatedValues = (p = d.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), d.options.updatedValues.set(m, g.original)), at(_, r, m);
764
764
  }
765
765
  (y = b.callbacks) === null || y === void 0 || y.forEach((m) => {
766
766
  m(f, l);
767
767
  });
768
768
  });
769
769
  } else {
770
- const d = j(u);
770
+ const d = j(a);
771
771
  d.finalities.draft.push((f, l) => {
772
- rn(d), sn(d, at, f, l);
772
+ rn(d), sn(d, ut, f, l);
773
773
  });
774
774
  }
775
- return u;
775
+ return a;
776
776
  }
777
777
  In.createDraft = Dn;
778
778
  function $s(t, e, n, r, i) {
779
779
  var s;
780
- const o = j(t), a = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, u = !!e.length;
780
+ const o = j(t), u = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, a = !!e.length;
781
781
  if (o != null && o.operated)
782
782
  for (; o.finalities.draft.length > 0; )
783
783
  o.finalities.draft.pop()(n, r);
784
- const c = u ? e[0] : o ? o.operated ? o.copy : o.original : t;
784
+ const c = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
785
785
  return o && nn(o), i && Re(c, c, o == null ? void 0 : o.options.updatedValues), [
786
786
  c,
787
- n && u ? [{ op: L.Replace, path: [], value: e[0] }] : n,
788
- r && u ? [{ op: L.Replace, path: [], value: a }] : r
787
+ n && a ? [{ op: L.Replace, path: [], value: e[0] }] : n,
788
+ r && a ? [{ op: L.Replace, path: [], value: u }] : r
789
789
  ];
790
790
  }
791
791
  function Ds(t, e) {
@@ -797,39 +797,39 @@ function Ds(t, e) {
797
797
  };
798
798
  let i, s;
799
799
  e.enablePatches && (i = [], s = []);
800
- const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ae(t, e) ? t : Dn({
800
+ const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ue(t, e) ? t : Dn({
801
801
  original: t,
802
802
  parentDraft: null,
803
803
  finalities: r,
804
804
  options: e
805
805
  });
806
806
  return [
807
- a,
808
- (u = []) => {
809
- const [c, d, f] = $s(a, u, i, s, e.enableAutoFreeze);
807
+ u,
808
+ (a = []) => {
809
+ const [c, d, f] = $s(u, a, i, s, e.enableAutoFreeze);
810
810
  return e.enablePatches ? [c, d, f] : c;
811
811
  }
812
812
  ];
813
813
  }
814
- function an(t) {
814
+ function un(t) {
815
815
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: i = !0 } = t;
816
- xn(n, (s, o, a) => {
817
- const u = j(o);
818
- if (u && e && u.finalities === e.finalities) {
816
+ xn(n, (s, o, u) => {
817
+ const a = j(o);
818
+ if (a && e && a.finalities === e.finalities) {
819
819
  t.isContainDraft = !0;
820
- const c = u.original;
821
- if (a instanceof Set) {
822
- const d = Array.from(a);
823
- a.clear(), d.forEach((f) => a.add(s === f ? c : f));
820
+ const c = a.original;
821
+ if (u instanceof Set) {
822
+ const d = Array.from(u);
823
+ u.clear(), d.forEach((f) => u.add(s === f ? c : f));
824
824
  } else
825
- ut(a, s, c);
826
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, an(t));
825
+ at(u, s, c);
826
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, un(t));
827
827
  }), i && (t.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
828
828
  }
829
829
  function pi(t) {
830
830
  var e;
831
831
  const n = j(t);
832
- if (!ae(t, n == null ? void 0 : n.options))
832
+ if (!ue(t, n == null ? void 0 : n.options))
833
833
  return t;
834
834
  const r = Ce(t);
835
835
  if (n && !n.operated)
@@ -847,11 +847,11 @@ function pi(t) {
847
847
  }
848
848
  } else
849
849
  i = t;
850
- if (xn(i, (o, a) => {
851
- if (n && be(_e(n.original, o), a))
850
+ if (xn(i, (o, u) => {
851
+ if (n && be(_e(n.original, o), u))
852
852
  return;
853
- const u = pi(a);
854
- u !== a && (i === t && s(), ut(i, o, u));
853
+ const a = pi(u);
854
+ a !== u && (i === t && s(), at(i, o, a));
855
855
  }), r === 3) {
856
856
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : i;
857
857
  return Pn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
@@ -864,17 +864,17 @@ function gr(t) {
864
864
  return pi(t);
865
865
  }
866
866
  const Us = (t) => function e(n, r, i) {
867
- var s, o, a;
867
+ var s, o, u;
868
868
  if (typeof n == "function" && typeof r != "function")
869
869
  return function(S, ...C) {
870
870
  return e(S, ($) => n.call(this, $, ...C), r);
871
871
  };
872
- const u = n, c = r;
872
+ const a = n, c = r;
873
873
  let d = i;
874
874
  if (typeof r != "function" && (d = r), d !== void 0 && Object.prototype.toString.call(d) !== "[object Object]")
875
875
  throw new Error(`Invalid options: ${d}, 'options' should be an object.`);
876
876
  d = Object.assign(Object.assign({}, t), d);
877
- const f = je(u) ? gr(u) : u, l = Array.isArray(d.mark) ? (S, C) => {
877
+ const f = je(a) ? gr(a) : a, l = Array.isArray(d.mark) ? (S, C) => {
878
878
  for (const $ of d.mark) {
879
879
  if (typeof $ != "function")
880
880
  throw new Error(`Invalid mark: ${$}, 'mark' should be a function.`);
@@ -883,16 +883,16 @@ const Us = (t) => function e(n, r, i) {
883
883
  return D;
884
884
  }
885
885
  } : d.mark, p = (s = d.enablePatches) !== null && s !== void 0 ? s : !1, y = (o = d.strict) !== null && o !== void 0 ? o : !1, _ = {
886
- enableAutoFreeze: (a = d.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
886
+ enableAutoFreeze: (u = d.enableAutoFreeze) !== null && u !== void 0 ? u : !1,
887
887
  mark: l,
888
888
  strict: y,
889
889
  enablePatches: p
890
890
  };
891
- if (!ae(f, _) && typeof f == "object" && f !== null)
891
+ if (!ue(f, _) && typeof f == "object" && f !== null)
892
892
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
893
893
  const [T, g] = Ds(f, _);
894
894
  if (typeof r != "function") {
895
- if (!ae(f, _))
895
+ if (!ue(f, _))
896
896
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
897
897
  return [T, g];
898
898
  }
@@ -910,14 +910,14 @@ const Us = (t) => function e(n, r, i) {
910
910
  const D = S == null ? void 0 : S[Es];
911
911
  if (D) {
912
912
  const Ve = D[0];
913
- return _.strict && typeof S == "object" && S !== null && an({
913
+ return _.strict && typeof S == "object" && S !== null && un({
914
914
  rootDraft: C,
915
915
  value: S,
916
916
  useRawReturn: !0
917
917
  }), g([Ve]);
918
918
  }
919
919
  if (S !== void 0)
920
- return typeof S == "object" && S !== null && an({ rootDraft: C, value: S }), g([S]);
920
+ return typeof S == "object" && S !== null && un({ rootDraft: C, value: S }), g([S]);
921
921
  }
922
922
  if (S === T || S === void 0)
923
923
  return g([]);
@@ -1246,7 +1246,7 @@ function Hs(t) {
1246
1246
  function Ys(t) {
1247
1247
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
1248
1248
  if (n) {
1249
- const [, r, i, s, o, a] = n, u = i.padStart(2, "0"), c = s.padStart(2, "0"), d = `${r}-${u}-${c}T${a}`;
1249
+ const [, r, i, s, o, u] = n, a = i.padStart(2, "0"), c = s.padStart(2, "0"), d = `${r}-${a}-${c}T${u}`;
1250
1250
  return new Date(d);
1251
1251
  }
1252
1252
  return null;
@@ -1255,8 +1255,8 @@ function Js(t) {
1255
1255
  const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1256
1256
  if (!o)
1257
1257
  throw new Error(`Unable to parse time from: ${t}`);
1258
- let [, a, u, c, d] = o;
1259
- return a = Number(a), u = Number(u), c = Number(c), d === "PM" && a !== 12 ? a += 12 : d === "AM" && a === 12 && (a = 0), new Date(Date.UTC(s, r - 1, i, a, u, c));
1258
+ let [, u, a, c, d] = o;
1259
+ return u = Number(u), a = Number(a), c = Number(c), d === "PM" && u !== 12 ? u += 12 : d === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, c));
1260
1260
  }
1261
1261
  function Zs(t) {
1262
1262
  switch (t) {
@@ -1299,7 +1299,7 @@ function to(t, e) {
1299
1299
  return null;
1300
1300
  }
1301
1301
  }
1302
- function un(t) {
1302
+ function an(t) {
1303
1303
  for (const e of eo) {
1304
1304
  const n = to(e, t);
1305
1305
  if (n)
@@ -1310,7 +1310,7 @@ function un(t) {
1310
1310
  function no(t) {
1311
1311
  try {
1312
1312
  const e = JSON.parse(t);
1313
- return typeof e == "string" ? un(e) : null;
1313
+ return typeof e == "string" ? an(e) : null;
1314
1314
  } catch {
1315
1315
  return null;
1316
1316
  }
@@ -1322,7 +1322,7 @@ function xt(t) {
1322
1322
  if (t instanceof Date)
1323
1323
  return t;
1324
1324
  if (typeof t == "string") {
1325
- const e = un(t) || no(t) || un(t.trim());
1325
+ const e = an(t) || no(t) || an(t.trim());
1326
1326
  if (!e)
1327
1327
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1328
1328
  return e;
@@ -1351,49 +1351,47 @@ class Ae {
1351
1351
  getAttr(e) {
1352
1352
  return this.attrs[e];
1353
1353
  }
1354
- // XXX: Might be better to create all of the indexes at once as soon as someone
1355
- // requests one index
1356
1354
  get blobAttrs() {
1357
1355
  if (this._blobAttrs)
1358
1356
  return this._blobAttrs;
1359
- console.log("blobAttrs"), this._blobAttrs = /* @__PURE__ */ new Map();
1357
+ this._blobAttrs = /* @__PURE__ */ new Map();
1360
1358
  for (const e of Object.values(this.attrs))
1361
1359
  if (Fn(e)) {
1362
1360
  const [n, r, i] = e["forward-identity"];
1363
- Z(this.blobAttrs, [r, i], e);
1361
+ te(this.blobAttrs, [r, i], e);
1364
1362
  }
1365
1363
  return this._blobAttrs;
1366
1364
  }
1367
1365
  get primaryKeys() {
1368
1366
  if (this._primaryKeys)
1369
1367
  return this._primaryKeys;
1370
- console.log("primayKeys"), this._primaryKeys = /* @__PURE__ */ new Map();
1368
+ this._primaryKeys = /* @__PURE__ */ new Map();
1371
1369
  for (const e of Object.values(this.attrs))
1372
1370
  if (e["primary?"]) {
1373
1371
  const [n, r] = e["forward-identity"];
1374
- Z(this._primaryKeys, [r], e);
1372
+ te(this._primaryKeys, [r], e);
1375
1373
  }
1376
1374
  return this._primaryKeys;
1377
1375
  }
1378
1376
  get forwardIdents() {
1379
1377
  if (this._forwardIdents)
1380
1378
  return this._forwardIdents;
1381
- console.log("fwdIdents"), this._forwardIdents = /* @__PURE__ */ new Map();
1379
+ this._forwardIdents = /* @__PURE__ */ new Map();
1382
1380
  for (const e of Object.values(this.attrs)) {
1383
1381
  const n = e["forward-identity"], [r, i, s] = n;
1384
- Z(this._forwardIdents, [i, s], e);
1382
+ te(this._forwardIdents, [i, s], e);
1385
1383
  }
1386
1384
  return this._forwardIdents;
1387
1385
  }
1388
1386
  get revIdents() {
1389
1387
  if (this._revIdents)
1390
1388
  return this._revIdents;
1391
- console.log("revIdents"), this._revIdents = /* @__PURE__ */ new Map();
1389
+ this._revIdents = /* @__PURE__ */ new Map();
1392
1390
  for (const e of Object.values(this.attrs)) {
1393
1391
  const n = e["reverse-identity"];
1394
1392
  if (n) {
1395
1393
  const [r, i, s] = n;
1396
- Z(this._revIdents, [i, s], e);
1394
+ te(this._revIdents, [i, s], e);
1397
1395
  }
1398
1396
  }
1399
1397
  return this._revIdents;
@@ -1424,33 +1422,32 @@ function oe(t, e) {
1424
1422
  const [n, ...r] = e;
1425
1423
  t.has(n) && oe(t.get(n), r);
1426
1424
  }
1427
- function Z(t, e, n) {
1428
- if (e.length === 0)
1429
- throw new Error("path must have at least one element");
1430
- if (e.length === 1) {
1431
- t.set(e[0], n);
1432
- return;
1425
+ function te(t, e, n) {
1426
+ let r = t;
1427
+ const i = e.length - 1;
1428
+ for (let s = 0; s < i; s++) {
1429
+ const o = e[s];
1430
+ let u = r.get(o);
1431
+ u === void 0 && (u = /* @__PURE__ */ new Map(), r.set(o, u)), r = u;
1433
1432
  }
1434
- const [r, ...i] = e;
1435
- let s = t.get(r);
1436
- s || (s = /* @__PURE__ */ new Map(), t.set(r, s)), Z(s, i, n);
1433
+ i > -1 && r.set(e[i], n);
1437
1434
  }
1438
1435
  function gi(t, e, n) {
1439
1436
  const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1440
1437
  for (const o of e) {
1441
- let [a, u, c] = o;
1442
- const d = t.getAttr(u);
1438
+ let [u, a, c] = o;
1439
+ const d = t.getAttr(a);
1443
1440
  if (!d) {
1444
- console.warn("no such attr", u, a);
1441
+ console.warn("no such attr", a, u);
1445
1442
  continue;
1446
1443
  }
1447
- d["checked-data-type"] === "date" && n && (c = xt(c), o[2] = c), Ln(d) && Z(s, [c, u, a], o), Z(r, [a, u, c], o), Z(i, [u, a, c], o);
1444
+ d["checked-data-type"] === "date" && n && (c = xt(c), o[2] = c), Ln(d) && te(s, [c, a, u], o), te(r, [u, a, c], o), te(i, [a, u, c], o);
1448
1445
  }
1449
1446
  return { eav: r, aev: i, vae: s };
1450
1447
  }
1451
1448
  function wi(t) {
1452
1449
  return {
1453
- triples: X(t.eav, 3),
1450
+ triples: Z(t.eav, 3),
1454
1451
  cardinalityInference: t.cardinalityInference,
1455
1452
  useDateObjects: t.useDateObjects,
1456
1453
  version: 1
@@ -1476,65 +1473,65 @@ function ct(t, e) {
1476
1473
  var n, r;
1477
1474
  let i;
1478
1475
  if (Array.isArray(e[0])) {
1479
- const [o, a] = e[0], u = t.aev.get(o);
1480
- if (!u)
1476
+ const [o, u] = e[0], a = t.aev.get(o);
1477
+ if (!a)
1481
1478
  return null;
1482
- i = (n = X(u, 2).find((d) => d[2] === a)) === null || n === void 0 ? void 0 : n[0];
1479
+ i = (n = Z(a, 2).find((d) => d[2] === u)) === null || n === void 0 ? void 0 : n[0];
1483
1480
  } else
1484
1481
  i = e[0];
1485
1482
  if (!i)
1486
1483
  return null;
1487
1484
  const s = e[2];
1488
1485
  if (Array.isArray(s) && s.length === 2 && t.aev.get(s[0])) {
1489
- const [o, a] = s, u = t.aev.get(o);
1490
- if (!u)
1486
+ const [o, u] = s, a = t.aev.get(o);
1487
+ if (!a)
1491
1488
  return null;
1492
- const d = (r = X(u, 2).find((b) => b[2] === a)) === null || r === void 0 ? void 0 : r[0];
1489
+ const d = (r = Z(a, 2).find((b) => b[2] === u)) === null || r === void 0 ? void 0 : r[0];
1493
1490
  if (!d)
1494
1491
  return null;
1495
1492
  const [f, l, p, ...y] = e;
1496
1493
  return [i, l, d, ...y];
1497
1494
  } else {
1498
- const [o, ...a] = e;
1499
- return [i, ...a];
1495
+ const [o, ...u] = e;
1496
+ return [i, ...u];
1500
1497
  }
1501
1498
  }
1502
1499
  function vi(t, e, n) {
1503
1500
  const r = ct(t, n);
1504
1501
  if (!r)
1505
1502
  return;
1506
- const [i, s, o] = r, a = e.getAttr(s);
1507
- a && (oe(t.eav, [i, s, o]), oe(t.aev, [s, i, o]), Ln(a) && oe(t.vae, [o, s, i]));
1503
+ const [i, s, o] = r, u = e.getAttr(s);
1504
+ u && (oe(t.eav, [i, s, o]), oe(t.aev, [s, i, o]), Ln(u) && oe(t.vae, [o, s, i]));
1508
1505
  }
1509
1506
  let so = 0;
1510
1507
  function Si(t, e, n) {
1511
1508
  const [r, i, s] = n;
1512
1509
  let o;
1513
- const a = We(t.eav, [r, i, s]);
1514
- return a && (o = a[3]), o || Date.now() * 10 + so++;
1510
+ const u = We(t.eav, [r, i, s]);
1511
+ return u && (o = u[3]), o || Date.now() * 10 + so++;
1515
1512
  }
1516
1513
  function Oi(t, e, n) {
1517
1514
  var r;
1518
1515
  const i = ct(t, n);
1519
1516
  if (!i)
1520
1517
  return;
1521
- let [s, o, a] = i;
1522
- const u = e.getAttr(o);
1523
- if (!u)
1518
+ let [s, o, u] = i;
1519
+ const a = e.getAttr(o);
1520
+ if (!a)
1524
1521
  return;
1525
- u["checked-data-type"] === "date" && t.useDateObjects && (a = xt(a));
1526
- const c = We(t.eav, [s, o, a]), d = (r = c == null ? void 0 : c[3]) !== null && r !== void 0 ? r : Si(t, u, i), f = [s, o, a, d];
1527
- ro(u) ? (Z(t.eav, [s, o], /* @__PURE__ */ new Map([[a, f]])), Z(t.aev, [o, s], /* @__PURE__ */ new Map([[a, f]]))) : (Z(t.eav, [s, o, a], f), Z(t.aev, [o, s, a], f)), Ln(u) && Z(t.vae, [a, o, s], f);
1522
+ a["checked-data-type"] === "date" && t.useDateObjects && (u = xt(u));
1523
+ const c = We(t.eav, [s, o, u]), d = (r = c == null ? void 0 : c[3]) !== null && r !== void 0 ? r : Si(t, a, i), f = [s, o, u, d];
1524
+ ro(a) ? (te(t.eav, [s, o], /* @__PURE__ */ new Map([[u, f]])), te(t.aev, [o, s], /* @__PURE__ */ new Map([[u, f]]))) : (te(t.eav, [s, o, u], f), te(t.aev, [o, s, u], f)), Ln(a) && te(t.vae, [u, o, s], f);
1528
1525
  }
1529
1526
  function oo(t, e, n) {
1530
1527
  var r;
1531
1528
  const i = ct(t, n);
1532
1529
  if (!i)
1533
1530
  return;
1534
- const [s, o, a] = i, u = e.getAttr(o);
1535
- if (!u)
1531
+ const [s, o, u] = i, a = e.getAttr(o);
1532
+ if (!a)
1536
1533
  return;
1537
- if (!Fn(u))
1534
+ if (!Fn(a))
1538
1535
  throw new Error("merge operation is not supported for links");
1539
1536
  const c = We(t.eav, [s, o]);
1540
1537
  if (!c)
@@ -1542,40 +1539,40 @@ function oo(t, e, n) {
1542
1539
  const d = (r = c.values().next()) === null || r === void 0 ? void 0 : r.value;
1543
1540
  if (!d)
1544
1541
  return;
1545
- const f = d[2], l = bi(f, a), p = [
1542
+ const f = d[2], l = bi(f, u), p = [
1546
1543
  s,
1547
1544
  o,
1548
1545
  l,
1549
- Si(t, u, d)
1546
+ Si(t, a, d)
1550
1547
  ];
1551
- Z(t.eav, [s, o], /* @__PURE__ */ new Map([[l, p]]));
1548
+ te(t.eav, [s, o], /* @__PURE__ */ new Map([[l, p]]));
1552
1549
  }
1553
1550
  function cn(t, e, n) {
1554
1551
  var r, i;
1555
- const [s, o] = n, a = ct(t, [s]);
1556
- if (!a)
1552
+ const [s, o] = n, u = ct(t, [s]);
1553
+ if (!u)
1557
1554
  return;
1558
- const [u] = a, c = t.eav.get(u);
1555
+ const [a] = u, c = t.eav.get(a);
1559
1556
  if (c) {
1560
1557
  for (const f of c.keys()) {
1561
1558
  const l = e.getAttr(f);
1562
- l && l["on-delete-reverse"] === "cascade" && X(c.get(f), 1).forEach(([p, y, b]) => {
1559
+ l && l["on-delete-reverse"] === "cascade" && Z(c.get(f), 1).forEach(([p, y, b]) => {
1563
1560
  var _;
1564
1561
  return cn(t, e, [b, (_ = l["reverse-identity"]) === null || _ === void 0 ? void 0 : _[1]]);
1565
1562
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
1566
1563
  // the store that didn't set `etype` in deleteEntity
1567
1564
  (!o || // If we don't know about the attr, let's just get rid of it
1568
1565
  !l || // Make sure it matches the etype
1569
- ((r = l["forward-identity"]) === null || r === void 0 ? void 0 : r[1]) === o) && (oe(t.aev, [f, u]), oe(t.eav, [u, f]));
1566
+ ((r = l["forward-identity"]) === null || r === void 0 ? void 0 : r[1]) === o) && (oe(t.aev, [f, a]), oe(t.eav, [a, f]));
1570
1567
  }
1571
- c.size === 0 && oe(t.eav, [u]);
1568
+ c.size === 0 && oe(t.eav, [a]);
1572
1569
  }
1573
- const d = t.vae.get(u) && X(t.vae.get(u), 2);
1570
+ const d = t.vae.get(a) && Z(t.vae.get(a), 2);
1574
1571
  d && d.forEach((f) => {
1575
1572
  var l, p, y;
1576
1573
  const [b, _, T] = f, g = e.getAttr(_);
1577
1574
  (!o || !g || ((l = g["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === o) && (oe(t.eav, [b, _, T]), oe(t.aev, [_, b, T]), oe(t.vae, [T, _, b])), g && g["on-delete"] === "cascade" && ((p = g["reverse-identity"]) === null || p === void 0 ? void 0 : p[1]) === o && cn(t, e, [b, (y = g["forward-identity"]) === null || y === void 0 ? void 0 : y[1]]);
1578
- }), ((i = t.vae.get(u)) === null || i === void 0 ? void 0 : i.size) === 0 && oe(t.vae, [u]);
1575
+ }), ((i = t.vae.get(a)) === null || i === void 0 ? void 0 : i.size) === 0 && oe(t.vae, [a]);
1579
1576
  }
1580
1577
  function Ei(t, e, n) {
1581
1578
  const r = gi(e, n, t.useDateObjects);
@@ -1583,13 +1580,13 @@ function Ei(t, e, n) {
1583
1580
  t[i] = r[i];
1584
1581
  });
1585
1582
  }
1586
- function ao(t, [e]) {
1583
+ function uo(t, [e]) {
1587
1584
  t.addAttr(e);
1588
1585
  }
1589
1586
  function Ai(t) {
1590
- return X(t.eav, 3);
1587
+ return Z(t.eav, 3);
1591
1588
  }
1592
- function uo(t, e, [n]) {
1589
+ function ao(t, e, [n]) {
1593
1590
  if (!e.getAttr(n))
1594
1591
  return;
1595
1592
  const r = Ai(t).filter(([i, s]) => s !== n);
@@ -1614,10 +1611,10 @@ function fo(t, e, n) {
1614
1611
  cn(t, e, i);
1615
1612
  break;
1616
1613
  case "add-attr":
1617
- ao(e, i);
1614
+ uo(e, i);
1618
1615
  break;
1619
1616
  case "delete-attr":
1620
- uo(t, e, i);
1617
+ ao(t, e, i);
1621
1618
  break;
1622
1619
  case "update-attr":
1623
1620
  co(t, e, i);
@@ -1630,7 +1627,7 @@ function fo(t, e, n) {
1630
1627
  throw new Error(`unhandled transaction action: ${r}`);
1631
1628
  }
1632
1629
  }
1633
- function X(t, e, n = []) {
1630
+ function Z(t, e, n = []) {
1634
1631
  if (!t || e === 0)
1635
1632
  return n;
1636
1633
  if (e === 1) {
@@ -1639,7 +1636,7 @@ function X(t, e, n = []) {
1639
1636
  return n;
1640
1637
  }
1641
1638
  for (const r of t.values())
1642
- X(r, e - 1, n);
1639
+ Z(r, e - 1, n);
1643
1640
  return n;
1644
1641
  }
1645
1642
  function gt(t, e, n) {
@@ -1651,27 +1648,27 @@ function gt(t, e, n) {
1651
1648
  return i;
1652
1649
  }
1653
1650
  if (n != null && n.hasOwnProperty("$isNull")) {
1654
- const { attrId: o, isNull: a, reverse: u } = n.$isNull;
1655
- if (u)
1651
+ const { attrId: o, isNull: u, reverse: a } = n.$isNull;
1652
+ if (a)
1656
1653
  for (const c of e.keys()) {
1657
1654
  const d = t.vae.get(c), f = !d || !d.get(o);
1658
- (a ? f : !f) && i.push(e.get(c));
1655
+ (u ? f : !f) && i.push(e.get(c));
1659
1656
  }
1660
1657
  else {
1661
1658
  const c = t.aev.get(o);
1662
1659
  for (const d of e.keys()) {
1663
1660
  const f = !c || ((r = c.get(d)) === null || r === void 0 ? void 0 : r.get(null)) || !c.get(d);
1664
- (a ? f : !f) && i.push(e.get(d));
1661
+ (u ? f : !f) && i.push(e.get(d));
1665
1662
  }
1666
1663
  }
1667
1664
  return i;
1668
1665
  }
1669
1666
  if (n != null && n.$comparator)
1670
- return X(e, 1).filter(n.$op);
1667
+ return Z(e, 1).filter(n.$op);
1671
1668
  const s = n.in || n.$in || [n];
1672
1669
  for (const o of s) {
1673
- const a = e.get(o);
1674
- a && i.push(a);
1670
+ const u = e.get(o);
1671
+ u && i.push(u);
1675
1672
  }
1676
1673
  return i;
1677
1674
  }
@@ -1683,48 +1680,48 @@ function ho(t, [e, n, r]) {
1683
1680
  var i, s;
1684
1681
  switch (lo(e, n, r)) {
1685
1682
  case "e": {
1686
- const a = t.eav.get(e);
1687
- return X(a, 2);
1683
+ const u = t.eav.get(e);
1684
+ return Z(u, 2);
1688
1685
  }
1689
1686
  case "ea": {
1690
- const a = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
1691
- return X(a, 1);
1687
+ const u = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
1688
+ return Z(u, 1);
1692
1689
  }
1693
1690
  case "eav": {
1694
- const a = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
1695
- return a ? gt(t, a, r) : [];
1691
+ const u = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
1692
+ return u ? gt(t, u, r) : [];
1696
1693
  }
1697
1694
  case "ev": {
1698
- const a = t.eav.get(e);
1699
- if (!a)
1695
+ const u = t.eav.get(e);
1696
+ if (!u)
1700
1697
  return [];
1701
- const u = [];
1702
- for (const c of a.values())
1703
- u.push(...gt(t, c, r));
1704
- return u;
1698
+ const a = [];
1699
+ for (const c of u.values())
1700
+ a.push(...gt(t, c, r));
1701
+ return a;
1705
1702
  }
1706
1703
  case "a": {
1707
- const a = t.aev.get(n);
1708
- return X(a, 2);
1704
+ const u = t.aev.get(n);
1705
+ return Z(u, 2);
1709
1706
  }
1710
1707
  case "av": {
1711
- const a = t.aev.get(n);
1712
- if (!a)
1708
+ const u = t.aev.get(n);
1709
+ if (!u)
1713
1710
  return [];
1714
- const u = [];
1715
- for (const c of a.values())
1716
- u.push(...gt(t, c, r));
1717
- return u;
1718
- }
1719
- case "v": {
1720
1711
  const a = [];
1721
- for (const u of t.eav.values())
1722
- for (const c of u.values())
1723
- a.push(...gt(t, c, r));
1712
+ for (const c of u.values())
1713
+ a.push(...gt(t, c, r));
1724
1714
  return a;
1725
1715
  }
1716
+ case "v": {
1717
+ const u = [];
1718
+ for (const a of t.eav.values())
1719
+ for (const c of a.values())
1720
+ u.push(...gt(t, c, r));
1721
+ return u;
1722
+ }
1726
1723
  default:
1727
- return X(t.eav, 3);
1724
+ return Z(t.eav, 3);
1728
1725
  }
1729
1726
  }
1730
1727
  function po(t, e, n) {
@@ -1733,8 +1730,8 @@ function po(t, e, n) {
1733
1730
  if (!e)
1734
1731
  return i;
1735
1732
  for (const [s, o] of e.entries()) {
1736
- const a = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), u = X(a, 1);
1737
- for (const c of u)
1733
+ const u = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), a = Z(u, 1);
1734
+ for (const c of a)
1738
1735
  i[s] = c[2];
1739
1736
  }
1740
1737
  return i;
@@ -1764,10 +1761,10 @@ function bo(t, e, n) {
1764
1761
  return We(t.eav, [i, s]);
1765
1762
  }
1766
1763
  function _o(t, e, n) {
1767
- const r = n.filter(([i, s, o, a, u]) => {
1764
+ const r = n.filter(([i, s, o, u, a]) => {
1768
1765
  if (i !== "add-triple" && i !== "deep-merge-triple")
1769
1766
  return !0;
1770
- const c = u == null ? void 0 : u.mode;
1767
+ const c = a == null ? void 0 : a.mode;
1771
1768
  if (c !== "create" && c !== "update")
1772
1769
  return !0;
1773
1770
  let d = !1;
@@ -1953,23 +1950,23 @@ function qo(t, e, n) {
1953
1950
  return t.map((r) => r === e ? n : r);
1954
1951
  }
1955
1952
  function Ci(t, e, n, r, i) {
1956
- const s = K(e, n, i), o = Ie(e, n, i), a = s || o;
1957
- if (!a)
1953
+ const s = K(e, n, i), o = Ie(e, n, i), u = s || o;
1954
+ if (!u)
1958
1955
  throw new Ke(`Could not find attr for ${[n, i]}`);
1959
- if (a["value-type"] !== "ref")
1960
- throw new Error(`Attr ${a.id} is not a ref`);
1961
- const [u, c] = a["forward-identity"], [d, f] = a["reverse-identity"], l = r + 1, p = s ? [
1956
+ if (u["value-type"] !== "ref")
1957
+ throw new Error(`Attr ${u.id} is not a ref`);
1958
+ const [a, c] = u["forward-identity"], [d, f] = u["reverse-identity"], l = r + 1, p = s ? [
1962
1959
  t(c, r),
1963
- a.id,
1960
+ u.id,
1964
1961
  t(f, l),
1965
1962
  nt("time")
1966
1963
  ] : [
1967
1964
  t(c, l),
1968
- a.id,
1965
+ u.id,
1969
1966
  t(f, r),
1970
1967
  nt("time")
1971
1968
  ];
1972
- return [s ? f : c, l, p, a, !!s];
1969
+ return [s ? f : c, l, p, u, !!s];
1973
1970
  }
1974
1971
  function Ar(t, e) {
1975
1972
  if (typeof e != "string")
@@ -2042,8 +2039,8 @@ function Wo(t, e) {
2042
2039
  return e;
2043
2040
  }
2044
2041
  function zo(t, e, n, r, i, s) {
2045
- const o = K(e, n, i), a = Ie(e, n, i), u = o || a;
2046
- if (!u)
2042
+ const o = K(e, n, i), u = Ie(e, n, i), a = o || u;
2043
+ if (!a)
2047
2044
  throw new Ke(`No attr for etype = ${n} label = ${i}`);
2048
2045
  if (s != null && s.hasOwnProperty("$isNull")) {
2049
2046
  const c = K(e, n, "id");
@@ -2052,26 +2049,26 @@ function zo(t, e, n, r, i, s) {
2052
2049
  return [
2053
2050
  t(n, r),
2054
2051
  c.id,
2055
- { $isNull: { attrId: u.id, isNull: s.$isNull, reverse: !o } },
2052
+ { $isNull: { attrId: a.id, isNull: s.$isNull, reverse: !o } },
2056
2053
  nt("time")
2057
2054
  ];
2058
2055
  }
2059
2056
  return o ? [
2060
2057
  t(n, r),
2061
- u.id,
2062
- Wo(u, s),
2058
+ a.id,
2059
+ Wo(a, s),
2063
2060
  nt("time")
2064
- ] : [s, u.id, t(n, r), nt("time")];
2061
+ ] : [s, a.id, t(n, r), nt("time")];
2065
2062
  }
2066
2063
  function Vo(t, e, n, r, i) {
2067
- const [s, o, a] = i.reduce((u, c) => {
2068
- const [d, f, l] = u, [p, y, b] = Ci(t, e, d, f, c);
2064
+ const [s, o, u] = i.reduce((a, c) => {
2065
+ const [d, f, l] = a, [p, y, b] = Ci(t, e, d, f, c);
2069
2066
  return [p, y, [...l, b]];
2070
2067
  }, [n, r, []]);
2071
- return [s, o, a];
2068
+ return [s, o, u];
2072
2069
  }
2073
2070
  function fn(t, e, n, r, i, s) {
2074
- const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, c, d] = Vo(t, e, n, r, o), f = zo(t, e, u, c, a, s);
2071
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = Vo(t, e, n, r, o), f = zo(t, e, a, c, u, s);
2075
2072
  return d.concat([f]);
2076
2073
  }
2077
2074
  function Bo(t, e) {
@@ -2090,11 +2087,11 @@ function Ho(t, e, n) {
2090
2087
  };
2091
2088
  }
2092
2089
  function kr(t, e, n, r, i, s) {
2093
- const o = t(r, i), a = s.map((u, c) => {
2090
+ const o = t(r, i), u = s.map((a, c) => {
2094
2091
  const d = Ho(t, o, c);
2095
- return Ii(d, n, r, i, u);
2092
+ return Ii(d, n, r, i, a);
2096
2093
  });
2097
- return { [e]: { patterns: a, joinSym: o } };
2094
+ return { [e]: { patterns: u, joinSym: o } };
2098
2095
  }
2099
2096
  function Yo(t) {
2100
2097
  const e = [];
@@ -2115,26 +2112,26 @@ function Ii(t, e, n, r, i) {
2115
2112
  return kr(t, "and", e, n, r, o);
2116
2113
  if (s === "$entityIdStartsWith")
2117
2114
  return [];
2118
- const a = s.split(".");
2115
+ const u = s.split(".");
2119
2116
  if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2120
- const u = fn(t, e, n, r, a, o), c = jr(t, e, n, r, a);
2117
+ const a = fn(t, e, n, r, u, o), c = jr(t, e, n, r, u);
2121
2118
  return [
2122
2119
  {
2123
2120
  or: {
2124
- patterns: [u, ...c],
2121
+ patterns: [a, ...c],
2125
2122
  joinSym: t(n, r)
2126
2123
  }
2127
2124
  }
2128
2125
  ];
2129
2126
  }
2130
- return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2127
+ return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && u.length > 1 ? [
2131
2128
  {
2132
2129
  or: {
2133
- patterns: jr(t, e, n, r, a),
2130
+ patterns: jr(t, e, n, r, u),
2134
2131
  joinSym: t(n, r)
2135
2132
  }
2136
2133
  }
2137
- ] : fn(t, e, n, r, a, o);
2134
+ ] : fn(t, e, n, r, u, o);
2138
2135
  });
2139
2136
  }
2140
2137
  function Jo(t, e, n, r) {
@@ -2145,13 +2142,13 @@ function Zo(t, e, n) {
2145
2142
  return [t(e, n), t("time", n)];
2146
2143
  }
2147
2144
  function Xo(t, e, n, r, i, s) {
2148
- const [o, a, u, c, d] = Ci(t, e, n, r, i), f = qo(u, t(n, r), s);
2149
- return [o, a, f, c, d];
2145
+ const [o, u, a, c, d] = Ci(t, e, n, r, i), f = qo(a, t(n, r), s);
2146
+ return [o, u, f, c, d];
2150
2147
  }
2151
- function ea(t, e, n, { etype: r, level: i, form: s }, o) {
2152
- const a = Object.keys(s).filter((u) => u !== "$");
2153
- return a.length ? Object.entries(o).map(function([c, d]) {
2154
- return a.map(function(p) {
2148
+ function eu(t, e, n, { etype: r, level: i, form: s }, o) {
2149
+ const u = Object.keys(s).filter((a) => a !== "$");
2150
+ return u.length ? Object.entries(o).map(function([c, d]) {
2151
+ return u.map(function(p) {
2155
2152
  var y, b, _;
2156
2153
  const T = !!(e.cardinalityInference && (!((_ = (b = (y = n.linkIndex) === null || y === void 0 ? void 0 : y[r]) === null || b === void 0 ? void 0 : b[p]) === null || _ === void 0) && _.isSingular));
2157
2154
  try {
@@ -2172,11 +2169,11 @@ function ea(t, e, n, { etype: r, level: i, form: s }, o) {
2172
2169
  }, d);
2173
2170
  }) : Object.values(o);
2174
2171
  }
2175
- function ta(t, e, n) {
2172
+ function tu(t, e, n) {
2176
2173
  return n === "string" ? Lo(t, e) : t > e ? 1 : -1;
2177
2174
  }
2178
2175
  function Ze(t, e, n, r, i) {
2179
- return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 : ta(e, r, i);
2176
+ return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 : tu(e, r, i);
2180
2177
  }
2181
2178
  function Pt([t, e], [n, r], i) {
2182
2179
  return Ze(t, e, n, r, i);
@@ -2184,49 +2181,49 @@ function Pt([t, e], [n, r], i) {
2184
2181
  function ln(t) {
2185
2182
  return t == null ? t : new Date(t).getTime();
2186
2183
  }
2187
- function na(t, e, n, r) {
2184
+ function nu(t, e, n, r) {
2188
2185
  var i;
2189
- const [s, o, a, u] = t, c = n === "desc" ? 1 : -1;
2186
+ const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
2190
2187
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2191
- return Pt(r, [s, u], null) === c;
2192
- const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(a) : a;
2188
+ return Pt(r, [s, a], null) === c;
2189
+ const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(u) : u;
2193
2190
  return Pt([d, p], [s, y], l) === c;
2194
2191
  }
2195
- function ra(t, e) {
2192
+ function ru(t, e) {
2196
2193
  const n = e[1];
2197
2194
  return t.getAttr(n);
2198
2195
  }
2199
- function ia(t, e, n) {
2196
+ function iu(t, e, n) {
2200
2197
  const r = Object.keys(n)[0];
2201
2198
  return K(t, e, r);
2202
2199
  }
2203
- function sa(t, e, n, r) {
2200
+ function su(t, e, n, r) {
2204
2201
  if (n)
2205
- return ra(t, n);
2202
+ return ru(t, n);
2206
2203
  if (r)
2207
- return ia(t, e, r);
2204
+ return iu(t, e, r);
2208
2205
  }
2209
- function oa(t, e, n) {
2206
+ function ou(t, e, n) {
2210
2207
  var r, i;
2211
2208
  if (!Array.isArray(n.fields))
2212
2209
  return yo(t, e);
2213
2210
  const s = /* @__PURE__ */ new Map();
2214
2211
  for (const o of n.fields) {
2215
- const a = K(t, e, o), u = (r = a == null ? void 0 : a["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2216
- u && Fn(a) && s.set(u, a);
2212
+ const u = K(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2213
+ a && Fn(u) && s.set(a, u);
2217
2214
  }
2218
2215
  if (!s.has("id")) {
2219
- const o = K(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
2220
- a && s.set(a, o);
2216
+ const o = K(t, e, "id"), u = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
2217
+ u && s.set(u, o);
2221
2218
  }
2222
2219
  return s;
2223
2220
  }
2224
- function aa(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2225
- var o, a;
2226
- const u = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = ua(s);
2221
+ function uu(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2222
+ var o, u;
2223
+ const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = au(s);
2227
2224
  let f = Ao(t, i);
2228
- const l = r == null ? void 0 : r["start-cursor"], p = sa(e, n, l, u);
2229
- if (p && ((a = p == null ? void 0 : p["forward-identity"]) === null || a === void 0 ? void 0 : a[2]) !== "id") {
2225
+ const l = r == null ? void 0 : r["start-cursor"], p = su(e, n, l, a);
2226
+ if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
2230
2227
  const _ = p["checked-data-type"] === "date", T = p.id;
2231
2228
  f = f.map(([g]) => {
2232
2229
  var m, O, S, C, $;
@@ -2240,17 +2237,17 @@ function aa(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2240
2237
  return Pt(g, T, p == null ? void 0 : p["checked-data-type"]);
2241
2238
  });
2242
2239
  let y = {};
2243
- const b = oa(e, n, i);
2240
+ const b = ou(e, n, i);
2244
2241
  for (const _ of f) {
2245
2242
  const [T] = _;
2246
- if (y[T] || !c && l && p && na(l, p, d, _))
2243
+ if (y[T] || !c && l && p && nu(l, p, d, _))
2247
2244
  continue;
2248
2245
  const g = po(t, b, T);
2249
2246
  g && (y[T] = g);
2250
2247
  }
2251
2248
  return y;
2252
2249
  }
2253
- function ua(t) {
2250
+ function au(t) {
2254
2251
  var e;
2255
2252
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2256
2253
  return n && n[Object.keys(n)[0]] || "asc";
@@ -2260,11 +2257,11 @@ function Pi(t) {
2260
2257
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2261
2258
  return !i && !s && !o;
2262
2259
  }
2263
- function ca(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2264
- var a, u, c, d, f;
2260
+ function cu(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2261
+ var u, a, c, d, f;
2265
2262
  if (!Pi(i) && (!o || !o["start-cursor"]))
2266
2263
  return [];
2267
- const l = Bo(Jo(e, n, r, (a = i.$) === null || a === void 0 ? void 0 : a.where), s), p = Zo($t, n, r), y = (u = i.$) === null || u === void 0 ? void 0 : u.fields, b = aa(t, e, {
2264
+ const l = Bo(Jo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = Zo($t, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = uu(t, e, {
2268
2265
  etype: n,
2269
2266
  pageInfo: o,
2270
2267
  form: i,
@@ -2277,9 +2274,9 @@ function ca(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2277
2274
  }
2278
2275
  return b;
2279
2276
  }
2280
- function da(t, e, n) {
2277
+ function du(t, e, n) {
2281
2278
  try {
2282
- return ca(t, e, n);
2279
+ return cu(t, e, n);
2283
2280
  } catch (r) {
2284
2281
  if (r instanceof Ke)
2285
2282
  return {};
@@ -2287,10 +2284,10 @@ function da(t, e, n) {
2287
2284
  }
2288
2285
  }
2289
2286
  function Mi(t, e, n) {
2290
- const r = da(t, e, n);
2291
- return ea($t, t, e, n, r);
2287
+ const r = du(t, e, n);
2288
+ return eu($t, t, e, n, r);
2292
2289
  }
2293
- function fa(t) {
2290
+ function fu(t) {
2294
2291
  const e = {};
2295
2292
  for (const [n, r] of Object.entries(t))
2296
2293
  e[n] = {
@@ -2302,17 +2299,17 @@ function fa(t) {
2302
2299
  return e;
2303
2300
  }
2304
2301
  function Ri({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
2305
- const o = { data: Object.keys(i).reduce(function(u, c) {
2306
- return r != null && r[c] || c === "$$ruleParams" || (u[c] = Mi(t, e, {
2302
+ const o = { data: Object.keys(i).reduce(function(a, c) {
2303
+ return r != null && r[c] || c === "$$ruleParams" || (a[c] = Mi(t, e, {
2307
2304
  etype: c,
2308
2305
  form: i[c],
2309
2306
  level: 0,
2310
2307
  pageInfo: n == null ? void 0 : n[c]
2311
- })), u;
2308
+ })), a;
2312
2309
  }, {}) };
2313
- return n && (o.pageInfo = fa(n)), r && (o.aggregate = r), o;
2310
+ return n && (o.pageInfo = fu(n)), r && (o.aggregate = r), o;
2314
2311
  }
2315
- function la() {
2312
+ function lu() {
2316
2313
  const e = {
2317
2314
  __etype: 1,
2318
2315
  __ops: 1,
@@ -2326,7 +2323,7 @@ function la() {
2326
2323
  };
2327
2324
  return new Set(Object.keys(e));
2328
2325
  }
2329
- const ha = la();
2326
+ const hu = lu();
2330
2327
  function hn(t, e, n) {
2331
2328
  const r = {
2332
2329
  __etype: t,
@@ -2338,10 +2335,10 @@ function hn(t, e, n) {
2338
2335
  return n;
2339
2336
  if (s === "__etype")
2340
2337
  return t;
2341
- if (ha.has(s))
2342
- return (o, a) => hn(t, e, [
2338
+ if (hu.has(s))
2339
+ return (o, u) => hn(t, e, [
2343
2340
  ...n,
2344
- a ? [s, t, e, o, a] : [s, t, e, o]
2341
+ u ? [s, t, e, o, u] : [s, t, e, o]
2345
2342
  ]);
2346
2343
  }
2347
2344
  });
@@ -2356,7 +2353,7 @@ function xi(t) {
2356
2353
  const [e, n, ...r] = t.split("__");
2357
2354
  return [n, JSON.parse(r.join("__"))];
2358
2355
  }
2359
- function pa(t) {
2356
+ function pu(t) {
2360
2357
  return new Proxy({
2361
2358
  __etype: t
2362
2359
  }, {
@@ -2371,23 +2368,23 @@ function pa(t) {
2371
2368
  function Kn() {
2372
2369
  return new Proxy({}, {
2373
2370
  get(t, e) {
2374
- return pa(e);
2371
+ return pu(e);
2375
2372
  }
2376
2373
  });
2377
2374
  }
2378
2375
  const Lc = Kn();
2379
- function ya(t) {
2376
+ function yu(t) {
2380
2377
  return t.__ops;
2381
2378
  }
2382
- function ba(t, e) {
2379
+ function bu(t, e) {
2383
2380
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2384
2381
  for (const o of e) {
2385
- const a = n[o];
2386
- if (a)
2387
- i.push(a);
2382
+ const u = n[o];
2383
+ if (u)
2384
+ i.push(u);
2388
2385
  else if (Array.isArray(o) && o.length == 2 && n[o[0]]) {
2389
- const [u, c] = o;
2390
- i.push([n[u], c]);
2386
+ const [a, c] = o;
2387
+ i.push([n[a], c]);
2391
2388
  } else
2392
2389
  i.push(o);
2393
2390
  }
@@ -2398,7 +2395,7 @@ function ba(t, e) {
2398
2395
  }
2399
2396
  return i;
2400
2397
  }
2401
- function _a(t) {
2398
+ function _u(t) {
2402
2399
  if (Array.isArray(t))
2403
2400
  return t;
2404
2401
  const e = Object.entries(t);
@@ -2406,7 +2403,7 @@ function _a(t) {
2406
2403
  throw new Error("lookup must be an object with a single unique attr and value.");
2407
2404
  return e[0];
2408
2405
  }
2409
- function ga(t, e, n) {
2406
+ function gu(t, e, n) {
2410
2407
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2411
2408
  // before assuming it's a ref lookup.
2412
2409
  !K(t, e, n);
@@ -2417,8 +2414,8 @@ function pn(t) {
2417
2414
  throw new Error(`${t} is not a valid lookup attribute.`);
2418
2415
  return e;
2419
2416
  }
2420
- function wa(t, e, n) {
2421
- if (!ga(t, e, n))
2417
+ function wu(t, e, n) {
2418
+ if (!gu(t, e, n))
2422
2419
  return K(t, e, n);
2423
2420
  const r = pn(n), i = K(t, e, r) || Ie(t, e, r);
2424
2421
  if (i && i["value-type"] !== "ref")
@@ -2426,20 +2423,20 @@ function wa(t, e, n) {
2426
2423
  return i;
2427
2424
  }
2428
2425
  function yn(t) {
2429
- return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : _a(t);
2426
+ return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : _u(t);
2430
2427
  }
2431
- function ee(t, e, n) {
2428
+ function X(t, e, n) {
2432
2429
  const r = yn(n);
2433
2430
  if (r === null)
2434
2431
  return n;
2435
- const [i, s] = r, o = wa(t, e, i);
2432
+ const [i, s] = r, o = wu(t, e, i);
2436
2433
  if (!o || !o["unique?"])
2437
2434
  throw new Error(`${i} is not a unique attribute.`);
2438
2435
  return [o.id, s];
2439
2436
  }
2440
2437
  function $i(t, e, n, r) {
2441
2438
  var i;
2442
- const s = ee(t, e, n);
2439
+ const s = X(t, e, n);
2443
2440
  return Array.isArray(s) ? [[
2444
2441
  "add-triple",
2445
2442
  s,
@@ -2447,52 +2444,56 @@ function $i(t, e, n, r) {
2447
2444
  s
2448
2445
  ]].concat(r) : r;
2449
2446
  }
2450
- function Ta({ attrsStore: t }, [e, n, r]) {
2447
+ function Tu({ attrsStore: t }, [e, n, r]) {
2451
2448
  const i = Object.entries(r).flatMap(([s, o]) => {
2452
- const a = Array.isArray(o) ? o : [o], u = K(t, e, s), c = Ie(t, e, s);
2453
- return a.map((d) => u ? [
2449
+ const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2450
+ return u.map((d) => a ? [
2454
2451
  "add-triple",
2455
- ee(t, e, n),
2456
- u.id,
2457
- // XXX: Better error here
2458
- ee(t, u["reverse-identity"][1], d)
2452
+ X(t, e, n),
2453
+ a.id,
2454
+ // Uses `!` because if we get here, we should have created the attr if it doesn't
2455
+ // already exist
2456
+ X(t, a["reverse-identity"][1], d)
2459
2457
  ] : [
2460
2458
  "add-triple",
2461
- // XXX: Better error here
2462
- ee(t, c["forward-identity"][1], d),
2459
+ // Uses `!` because if we get here, we should have created the attr if it doesn't
2460
+ // already exist
2461
+ X(t, c["forward-identity"][1], d),
2463
2462
  c == null ? void 0 : c.id,
2464
- ee(t, e, n)
2463
+ X(t, e, n)
2465
2464
  ]);
2466
2465
  });
2467
2466
  return $i(t, e, n, i);
2468
2467
  }
2469
- function ma({ attrsStore: t }, [e, n, r]) {
2468
+ function mu({ attrsStore: t }, [e, n, r]) {
2470
2469
  const i = Object.entries(r).flatMap(([s, o]) => {
2471
- const a = Array.isArray(o) ? o : [o], u = K(t, e, s), c = Ie(t, e, s);
2472
- return a.map((d) => u ? [
2470
+ const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2471
+ return u.map((d) => a ? [
2473
2472
  "retract-triple",
2474
- ee(t, e, n),
2475
- u.id,
2476
- // XXX: Better error here
2477
- ee(t, u["reverse-identity"][1], d)
2473
+ X(t, e, n),
2474
+ a.id,
2475
+ // Uses `!` because if we get here, we should have created the attr if it doesn't
2476
+ // already exist
2477
+ X(t, a["reverse-identity"][1], d)
2478
2478
  ] : [
2479
2479
  "retract-triple",
2480
- // XXX: Better error here
2481
- ee(t, c["forward-identity"][1], d),
2480
+ // Uses `!` because if we get here, we should have created the attr if it doesn't
2481
+ // already exist
2482
+ X(t, c["forward-identity"][1], d),
2482
2483
  c.id,
2483
- ee(t, e, n)
2484
+ X(t, e, n)
2484
2485
  ]);
2485
2486
  });
2486
2487
  return $i(t, e, n, i);
2487
2488
  }
2488
- function va(t, e, n, r) {
2489
+ function vu(t, e, n, r) {
2489
2490
  var i;
2490
2491
  if (Array.isArray(r)) {
2491
2492
  const [s, o] = r;
2492
- for (const a of t || []) {
2493
- const u = a == null ? void 0 : a.aev.get(s);
2494
- if (u) {
2495
- for (const [c, d, f] of X(u, 2))
2493
+ for (const u of t || []) {
2494
+ const a = u == null ? void 0 : u.aev.get(s);
2495
+ if (a) {
2496
+ for (const [c, d, f] of Z(a, 2))
2496
2497
  if (f === o)
2497
2498
  return !0;
2498
2499
  }
@@ -2501,45 +2502,45 @@ function va(t, e, n, r) {
2501
2502
  for (const s of t || []) {
2502
2503
  const o = s == null ? void 0 : s.eav.get(r);
2503
2504
  if (o) {
2504
- for (const a of o.keys())
2505
- if (((i = e.getAttr(a)) === null || i === void 0 ? void 0 : i["forward-identity"][1]) == n)
2505
+ for (const u of o.keys())
2506
+ if (((i = e.getAttr(u)) === null || i === void 0 ? void 0 : i["forward-identity"][1]) == n)
2506
2507
  return !0;
2507
2508
  }
2508
2509
  }
2509
2510
  return !1;
2510
2511
  }
2511
2512
  function Di({ stores: t, attrsStore: e }, [n, r, i, s]) {
2512
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : va(t, e, n, r) ? { mode: "update" } : null;
2513
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : vu(t, e, n, r) ? { mode: "update" } : null;
2513
2514
  }
2514
- function Sa(t, e) {
2515
- const { attrsStore: n } = t, [r, i, s, o] = e, a = Un(s), u = ee(n, r, i);
2516
- return [["id", u]].concat(Object.entries(a)).map(([d, f]) => {
2515
+ function Su(t, e) {
2516
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = X(n, r, i);
2517
+ return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
2517
2518
  const l = K(n, r, d);
2518
- return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", u, l.id, f, { mode: "create" }];
2519
+ return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
2519
2520
  });
2520
2521
  }
2521
- function Oa(t, e) {
2522
- const { attrsStore: n } = t, [r, i, s, o] = e, a = Un(s), u = ee(n, r, i), c = Di(t, [r, u, s, o]);
2523
- return [["id", u]].concat(Object.entries(a)).map(([f, l]) => {
2522
+ function Ou(t, e) {
2523
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = X(n, r, i), c = Di(t, [r, a, s, o]);
2524
+ return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
2524
2525
  const p = K(n, r, f);
2525
2526
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), [
2526
2527
  "add-triple",
2527
- u,
2528
+ a,
2528
2529
  p.id,
2529
2530
  l,
2530
2531
  ...c ? [c] : []
2531
2532
  ];
2532
2533
  });
2533
2534
  }
2534
- function Ea({ attrsStore: t }, [e, n]) {
2535
- return [["delete-entity", ee(t, e, n), e]];
2535
+ function Eu({ attrsStore: t }, [e, n]) {
2536
+ return [["delete-entity", X(t, e, n), e]];
2536
2537
  }
2537
- function Aa(t, e) {
2538
- const { attrsStore: n } = t, [r, i, s, o] = e, a = Un(s), u = ee(n, r, i), c = Di(t, [r, u, s, o]), d = Object.entries(a).map(([l, p]) => {
2538
+ function Au(t, e) {
2539
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = X(n, r, i), c = Di(t, [r, a, s, o]), d = Object.entries(u).map(([l, p]) => {
2539
2540
  const y = K(n, r, l);
2540
2541
  return [
2541
2542
  "deep-merge-triple",
2542
- u,
2543
+ a,
2543
2544
  y.id,
2544
2545
  p,
2545
2546
  ...c ? [c] : []
@@ -2547,44 +2548,44 @@ function Aa(t, e) {
2547
2548
  });
2548
2549
  return [[
2549
2550
  "add-triple",
2550
- u,
2551
+ a,
2551
2552
  K(n, r, "id").id,
2552
- u,
2553
+ a,
2553
2554
  ...c ? [c] : []
2554
2555
  ]].concat(d);
2555
2556
  }
2556
- function ka({ attrsStore: t }, [e, n, r]) {
2557
- return [["rule-params", ee(t, e, n), e, r]];
2557
+ function ku({ attrsStore: t }, [e, n, r]) {
2558
+ return [["rule-params", X(t, e, n), e, r]];
2558
2559
  }
2559
- function ja(t) {
2560
+ function ju(t) {
2560
2561
  const [e, n, r, i, s] = t;
2561
2562
  if (!i)
2562
2563
  return t;
2563
2564
  const o = Object.assign({}, i);
2564
2565
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
2565
2566
  }
2566
- function Ca(t, e) {
2567
- const [n, ...r] = ja(e);
2567
+ function Cu(t, e) {
2568
+ const [n, ...r] = ju(e);
2568
2569
  switch (n) {
2569
2570
  case "merge":
2570
- return Aa(t, r);
2571
+ return Au(t, r);
2571
2572
  case "create":
2572
- return Sa(t, r);
2573
+ return Su(t, r);
2573
2574
  case "update":
2574
- return Oa(t, r);
2575
+ return Ou(t, r);
2575
2576
  case "link":
2576
- return Ta(t, r);
2577
+ return Tu(t, r);
2577
2578
  case "unlink":
2578
- return ma(t, r);
2579
+ return mu(t, r);
2579
2580
  case "delete":
2580
- return Ea(t, r);
2581
+ return Eu(t, r);
2581
2582
  case "ruleParams":
2582
- return ka(t, r);
2583
+ return ku(t, r);
2583
2584
  default:
2584
2585
  throw new Error(`unsupported action ${n}`);
2585
2586
  }
2586
2587
  }
2587
- function Ia(t) {
2588
+ function Iu(t) {
2588
2589
  switch (t) {
2589
2590
  case "string":
2590
2591
  case "date":
@@ -2595,29 +2596,29 @@ function Ia(t) {
2595
2596
  return;
2596
2597
  }
2597
2598
  }
2598
- function Pa(t, e, n) {
2599
+ function Pu(t, e, n) {
2599
2600
  var r, i;
2600
2601
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
2601
2602
  if (n === "id")
2602
2603
  return null;
2603
2604
  if (!s)
2604
2605
  throw new Error(`${e}.${n} does not exist in your schema`);
2605
- const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ia(s == null ? void 0 : s.valueType);
2606
+ const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Iu(s == null ? void 0 : s.valueType);
2606
2607
  return {
2607
- "index?": a,
2608
+ "index?": u,
2608
2609
  "unique?": o,
2609
- "checked-data-type": u
2610
+ "checked-data-type": a
2610
2611
  };
2611
2612
  }
2612
2613
  function wt(t, e, n, r) {
2613
- const i = t ? Pa(t, e, n) : null, s = W(), a = [W(), e, n];
2614
- return Object.assign(Object.assign({ id: s, "forward-identity": a, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2614
+ const i = t ? Pu(t, e, n) : null, s = W(), u = [W(), e, n];
2615
+ return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2615
2616
  }
2616
- function Ma(t, e, n) {
2617
+ function Mu(t, e, n) {
2617
2618
  return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
2618
2619
  }
2619
- function Ra(t, e, n) {
2620
- const r = Ma(t, e, n);
2620
+ function Ru(t, e, n) {
2621
+ const r = Mu(t, e, n);
2621
2622
  if (!r)
2622
2623
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2623
2624
  const { forward: i, reverse: s } = r;
@@ -2631,13 +2632,13 @@ function Ra(t, e, n) {
2631
2632
  };
2632
2633
  }
2633
2634
  function Cr(t, e, n, r) {
2634
- const i = t ? Ra(t, e, n) : null, s = W(), o = [W(), e, n], a = [W(), n, e];
2635
+ const i = t ? Ru(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
2635
2636
  return Object.assign(Object.assign({
2636
2637
  id: s,
2637
2638
  // @ts-ignore: ts thinks it's any[]
2638
2639
  "forward-identity": o,
2639
2640
  // @ts-ignore: ts thinks it's any[]
2640
- "reverse-identity": a,
2641
+ "reverse-identity": u,
2641
2642
  "value-type": "ref",
2642
2643
  // @ts-ignore: ts thinks it's type string
2643
2644
  cardinality: "many",
@@ -2646,7 +2647,7 @@ function Cr(t, e, n, r) {
2646
2647
  isUnsynced: !0
2647
2648
  }, i || {}), r || {});
2648
2649
  }
2649
- const xa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), $a = /* @__PURE__ */ new Set(["link", "unlink"]), Da = /* @__PURE__ */ new Set(["create", "update", "merge"]), Ua = /* @__PURE__ */ new Set([
2650
+ const xu = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), $u = /* @__PURE__ */ new Set(["link", "unlink"]), Du = /* @__PURE__ */ new Set(["create", "update", "merge"]), Uu = /* @__PURE__ */ new Set([
2650
2651
  "link",
2651
2652
  "unlink",
2652
2653
  "create",
@@ -2654,30 +2655,30 @@ const xa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2654
2655
  "merge",
2655
2656
  "delete",
2656
2657
  "ruleParams"
2657
- ]), bn = { "unique?": !0, "index?": !0 }, La = Object.assign(Object.assign({}, bn), { cardinality: "one" });
2658
- function Fa(t) {
2658
+ ]), bn = { "unique?": !0, "index?": !0 }, Lu = Object.assign(Object.assign({}, bn), { cardinality: "one" });
2659
+ function Fu(t) {
2659
2660
  const e = [], [n, r, i, s] = t;
2660
- if (!Ua.has(n))
2661
+ if (!Uu.has(n))
2661
2662
  return e;
2662
2663
  const o = yn(i);
2663
2664
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2664
- for (const [a, u] of Object.entries(s)) {
2665
- const c = Array.isArray(u) ? u : [u];
2665
+ for (const [u, a] of Object.entries(s)) {
2666
+ const c = Array.isArray(a) ? a : [a];
2666
2667
  for (const d of c) {
2667
2668
  const f = yn(d);
2668
2669
  f && e.push({
2669
2670
  etype: r,
2670
2671
  lookupPair: f,
2671
- linkLabel: a
2672
+ linkLabel: u
2672
2673
  });
2673
2674
  }
2674
2675
  }
2675
2676
  return e;
2676
2677
  }
2677
- function Na({ attrsStore: t, schema: e }, n) {
2678
+ function Nu({ attrsStore: t, schema: e }, n) {
2678
2679
  var r, i;
2679
- const s = /* @__PURE__ */ new Set(), o = [], a = [];
2680
- function u(y, b) {
2680
+ const s = /* @__PURE__ */ new Set(), o = [], u = [];
2681
+ function a(y, b) {
2681
2682
  return K(t, y, b) || o.find((_) => _["forward-identity"][1] === y && _["forward-identity"][2] === b);
2682
2683
  }
2683
2684
  function c(y, b) {
@@ -2687,49 +2688,49 @@ function Na({ attrsStore: t, schema: e }, n) {
2687
2688
  });
2688
2689
  }
2689
2690
  function d(y) {
2690
- o.push(y), a.push(["add-attr", y]), s.add(y.id);
2691
+ o.push(y), u.push(["add-attr", y]), s.add(y.id);
2691
2692
  }
2692
2693
  function f(y) {
2693
- y && "isUnsynced" in y && y.isUnsynced && !s.has(y.id) && (o.push(y), a.push(["add-attr", y]), s.add(y.id));
2694
+ y && "isUnsynced" in y && y.isUnsynced && !s.has(y.id) && (o.push(y), u.push(["add-attr", y]), s.add(y.id));
2694
2695
  }
2695
2696
  function l(y, b) {
2696
2697
  return b.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2697
2698
  // before assuming it's a ref lookup.
2698
- !u(y, b);
2699
+ !a(y, b);
2699
2700
  }
2700
2701
  function p(y, b) {
2701
- const _ = u(y, b), T = c(y, b);
2702
- f(_), f(T), !_ && !T && d(Cr(e, y, b, La));
2702
+ const _ = a(y, b), T = c(y, b);
2703
+ f(_), f(T), !_ && !T && d(Cr(e, y, b, Lu));
2703
2704
  }
2704
2705
  for (const y of n)
2705
- for (const { etype: b, lookupPair: _, linkLabel: T } of Fa(y)) {
2706
+ for (const { etype: b, lookupPair: _, linkLabel: T } of Fu(y)) {
2706
2707
  const g = _[0];
2707
2708
  if (T) {
2708
2709
  p(b, T);
2709
- const m = u(b, T), O = c(b, T);
2710
+ const m = a(b, T), O = c(b, T);
2710
2711
  f(m), f(O);
2711
2712
  const S = ((r = m == null ? void 0 : m["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = O == null ? void 0 : O["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || T;
2712
2713
  if (l(S, g))
2713
2714
  p(S, pn(g));
2714
2715
  else {
2715
- const C = u(S, g);
2716
+ const C = a(S, g);
2716
2717
  C || d(wt(e, S, g, bn)), f(C);
2717
2718
  }
2718
2719
  } else if (l(b, g))
2719
2720
  p(b, pn(g));
2720
2721
  else {
2721
- const m = u(b, g);
2722
+ const m = a(b, g);
2722
2723
  m || d(wt(e, b, g, bn)), f(m);
2723
2724
  }
2724
2725
  }
2725
2726
  for (const y of n) {
2726
2727
  const [b, _, T, g] = y;
2727
- if (xa.has(b)) {
2728
- const m = u(_, "id");
2728
+ if (xu.has(b)) {
2729
+ const m = a(_, "id");
2729
2730
  f(m), m || d(wt(e, _, "id", { "unique?": !0 }));
2730
2731
  for (const O of Object.keys(g)) {
2731
- const S = u(_, O);
2732
- if (f(S), Da.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), $a.has(b)) {
2732
+ const S = a(_, O);
2733
+ if (f(S), Du.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), $u.has(b)) {
2733
2734
  const C = c(_, O);
2734
2735
  !S && !C && d(Cr(e, _, O)), f(C);
2735
2736
  }
@@ -2740,13 +2741,13 @@ function Na({ attrsStore: t, schema: e }, n) {
2740
2741
  const y = Object.assign({}, t.attrs);
2741
2742
  for (const b of o)
2742
2743
  y[b.id] = b;
2743
- return [new Ae(y, t.linkIndex), a];
2744
+ return [new Ae(y, t.linkIndex), u];
2744
2745
  }
2745
- return [t, a];
2746
+ return [t, u];
2746
2747
  }
2747
- function Ka(t, e) {
2748
- const r = (Array.isArray(e) ? e : [e]).flatMap((u) => ya(u)), [i, s] = Na(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), a = r.flatMap((u) => Ca(o, u));
2749
- return [...s, ...a];
2748
+ function Ku(t, e) {
2749
+ const r = (Array.isArray(e) ? e : [e]).flatMap((a) => yu(a)), [i, s] = Nu(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Cu(o, a));
2750
+ return [...s, ...u];
2750
2751
  }
2751
2752
  var de = function(t, e, n, r) {
2752
2753
  function i(s) {
@@ -2755,14 +2756,14 @@ var de = function(t, e, n, r) {
2755
2756
  });
2756
2757
  }
2757
2758
  return new (n || (n = Promise))(function(s, o) {
2758
- function a(d) {
2759
+ function u(d) {
2759
2760
  try {
2760
2761
  c(r.next(d));
2761
2762
  } catch (f) {
2762
2763
  o(f);
2763
2764
  }
2764
2765
  }
2765
- function u(d) {
2766
+ function a(d) {
2766
2767
  try {
2767
2768
  c(r.throw(d));
2768
2769
  } catch (f) {
@@ -2770,7 +2771,7 @@ var de = function(t, e, n, r) {
2770
2771
  }
2771
2772
  }
2772
2773
  function c(d) {
2773
- d.done ? s(d.value) : i(d.value).then(a, u);
2774
+ d.done ? s(d.value) : i(d.value).then(u, a);
2774
2775
  }
2775
2776
  c((r = r.apply(t, e || [])).next());
2776
2777
  });
@@ -2779,7 +2780,7 @@ function Ir(t, e) {
2779
2780
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2780
2781
  }
2781
2782
  const rt = "__meta";
2782
- class qa {
2783
+ class qu {
2783
2784
  constructor(e, n) {
2784
2785
  }
2785
2786
  }
@@ -2803,8 +2804,8 @@ class _n {
2803
2804
  this._meta.loadingPromise = i;
2804
2805
  const s = yield i;
2805
2806
  this._meta.isLoading = !1, this._meta.error = null, this._meta.loadingPromise = null, this._meta.attempts = 0;
2806
- const o = (n = (e = this._meta.value) === null || e === void 0 ? void 0 : e.objects) !== null && n !== void 0 ? n : {}, a = s ?? {}, u = (r = a.objects) !== null && r !== void 0 ? r : {};
2807
- this._meta.value = Object.assign(Object.assign({}, a), { objects: Object.assign(Object.assign({}, o), u) });
2807
+ const o = (n = (e = this._meta.value) === null || e === void 0 ? void 0 : e.objects) !== null && n !== void 0 ? n : {}, u = s ?? {}, a = (r = u.objects) !== null && r !== void 0 ? r : {};
2808
+ this._meta.value = Object.assign(Object.assign({}, u), { objects: Object.assign(Object.assign({}, o), a) });
2808
2809
  } catch (i) {
2809
2810
  this._meta.error = i, this._meta.attempts++, this._meta.loadingPromise = null;
2810
2811
  }
@@ -2826,7 +2827,7 @@ class _n {
2826
2827
  if (!n)
2827
2828
  return;
2828
2829
  const r = Object.entries(n.objects);
2829
- r.sort(([i, s], [o, a]) => a.updatedAt - s.updatedAt);
2830
+ r.sort(([i, s], [o, u]) => u.updatedAt - s.updatedAt);
2830
2831
  for (const [i] of r.slice(0, e))
2831
2832
  this._loadKey(i);
2832
2833
  });
@@ -2888,16 +2889,16 @@ class _n {
2888
2889
  const o = this._meta.value;
2889
2890
  if (!o)
2890
2891
  return Promise.resolve(0);
2891
- const a = [], u = [];
2892
+ const u = [], a = [];
2892
2893
  for (const p of this._pendingSaveKeys)
2893
- p in this.currentValue ? u.push(p) : (a.push(p), delete o.objects[p]);
2894
- for (const p of a) {
2894
+ p in this.currentValue ? a.push(p) : (u.push(p), delete o.objects[p]);
2895
+ for (const p of u) {
2895
2896
  const y = this._persister.removeItem(p);
2896
2897
  i.push(y.then(() => 1)), this._loadedKeys.delete(p), this._pendingSaveKeys.delete(p);
2897
2898
  }
2898
2899
  const c = [], d = [[rt, o]], f = (n = o.objects) !== null && n !== void 0 ? n : {};
2899
2900
  o.objects = f;
2900
- for (const p of u)
2901
+ for (const p of a)
2901
2902
  if (this._loadedKeys.has(p)) {
2902
2903
  const y = this.serialize(p, this.currentValue[p]);
2903
2904
  d.push([p, y]);
@@ -2954,11 +2955,11 @@ class _n {
2954
2955
  const o = Date.now();
2955
2956
  for (const [l, p] of Object.entries(r.objects))
2956
2957
  !n.has(l) && p.updatedAt < o - this._gcOpts.maxAgeMs && (i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedOldCount++);
2957
- const a = Object.entries(r.objects);
2958
- a.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
2959
- const u = a.filter(([l]) => !n.has(l));
2960
- if (a.length > this._gcOpts.maxEntries)
2961
- for (const [l] of u.slice(0, a.length - this._gcOpts.maxEntries))
2958
+ const u = Object.entries(r.objects);
2959
+ u.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
2960
+ const a = u.filter(([l]) => !n.has(l));
2961
+ if (u.length > this._gcOpts.maxEntries)
2962
+ for (const [l] of a.slice(0, u.length - this._gcOpts.maxEntries))
2962
2963
  i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedThresholdCount++;
2963
2964
  const c = Object.entries(r.objects);
2964
2965
  c.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
@@ -3031,14 +3032,14 @@ var ye = function(t, e, n, r) {
3031
3032
  });
3032
3033
  }
3033
3034
  return new (n || (n = Promise))(function(s, o) {
3034
- function a(d) {
3035
+ function u(d) {
3035
3036
  try {
3036
3037
  c(r.next(d));
3037
3038
  } catch (f) {
3038
3039
  o(f);
3039
3040
  }
3040
3041
  }
3041
- function u(d) {
3042
+ function a(d) {
3042
3043
  try {
3043
3044
  c(r.throw(d));
3044
3045
  } catch (f) {
@@ -3046,18 +3047,18 @@ var ye = function(t, e, n, r) {
3046
3047
  }
3047
3048
  }
3048
3049
  function c(d) {
3049
- d.done ? s(d.value) : i(d.value).then(a, u);
3050
+ d.done ? s(d.value) : i(d.value).then(u, a);
3050
3051
  }
3051
3052
  c((r = r.apply(t, e || [])).next());
3052
3053
  });
3053
3054
  };
3054
- const Wa = 6, za = ["kv", "querySubs", "syncSubs"];
3055
- function Va(t) {
3055
+ const Wu = 6, zu = ["kv", "querySubs", "syncSubs"];
3056
+ function Vu(t) {
3056
3057
  return function(n) {
3057
3058
  console.error("Error in IndexedDB event", { source: t, event: n });
3058
3059
  };
3059
3060
  }
3060
- function Ba(t) {
3061
+ function Bu(t) {
3061
3062
  return ye(this, void 0, void 0, function* () {
3062
3063
  return new Promise((e) => {
3063
3064
  const n = indexedDB.open(t);
@@ -3073,7 +3074,7 @@ function Ba(t) {
3073
3074
  });
3074
3075
  });
3075
3076
  }
3076
- function Ga(t, e, n) {
3077
+ function Gu(t, e, n) {
3077
3078
  return ye(this, void 0, void 0, function* () {
3078
3079
  const r = (
3079
3080
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3083,7 +3084,7 @@ function Ga(t, e, n) {
3083
3084
  return;
3084
3085
  const i = /* @__PURE__ */ new Set();
3085
3086
  return new Promise((s, o) => {
3086
- var a, u, c, d;
3087
+ var u, a, c, d;
3087
3088
  const f = {};
3088
3089
  for (const [y, b] of Object.entries(r)) {
3089
3090
  const _ = typeof b == "string" ? JSON.parse(b) : b;
@@ -3091,7 +3092,7 @@ function Ga(t, e, n) {
3091
3092
  const g = {
3092
3093
  createdAt: _.lastAccessed,
3093
3094
  updatedAt: _.lastAccessed,
3094
- size: (d = (c = (u = (a = _.result) === null || a === void 0 ? void 0 : a.store) === null || u === void 0 ? void 0 : u.triples) === null || c === void 0 ? void 0 : c.length) !== null && d !== void 0 ? d : 0
3095
+ size: (d = (c = (a = (u = _.result) === null || u === void 0 ? void 0 : u.store) === null || a === void 0 ? void 0 : a.triples) === null || c === void 0 ? void 0 : c.length) !== null && d !== void 0 ? d : 0
3095
3096
  };
3096
3097
  f[y] = g;
3097
3098
  }
@@ -3117,9 +3118,9 @@ function Pr(t, e, n) {
3117
3118
  });
3118
3119
  });
3119
3120
  }
3120
- function Qa(t, e) {
3121
+ function Qu(t, e) {
3121
3122
  return ye(this, void 0, void 0, function* () {
3122
- const n = yield Ba(`instant_${t}_5`);
3123
+ const n = yield Bu(`instant_${t}_5`);
3123
3124
  if (!n)
3124
3125
  return;
3125
3126
  const r = yield new Promise((d, f) => {
@@ -3138,36 +3139,36 @@ function Qa(t, e) {
3138
3139
  }, y.onerror = (_) => {
3139
3140
  f(_);
3140
3141
  };
3141
- }), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), a = [], u = { objects: {} };
3142
+ }), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), u = [], a = { objects: {} };
3142
3143
  for (const [d, f] of r)
3143
3144
  switch (d) {
3144
3145
  case "querySubs": {
3145
- const l = Ga(d, f, o);
3146
- a.push(l);
3146
+ const l = Gu(d, f, o);
3147
+ u.push(l);
3147
3148
  break;
3148
3149
  }
3149
3150
  default: {
3150
3151
  const l = Pr(d, f, s);
3151
- a.push(l);
3152
+ u.push(l);
3152
3153
  const p = {
3153
3154
  createdAt: Date.now(),
3154
3155
  updatedAt: Date.now(),
3155
3156
  size: 0
3156
3157
  };
3157
- u.objects[d] = p;
3158
+ a.objects[d] = p;
3158
3159
  break;
3159
3160
  }
3160
3161
  }
3161
- const c = Pr(rt, u, s);
3162
- a.push(c), yield Promise.all(a), yield new Promise((d, f) => {
3162
+ const c = Pr(rt, a, s);
3163
+ u.push(c), yield Promise.all(u), yield new Promise((d, f) => {
3163
3164
  i.oncomplete = (l) => d(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3164
3165
  });
3165
3166
  });
3166
3167
  }
3167
3168
  const Mr = /* @__PURE__ */ new Map();
3168
- class Ui extends qa {
3169
+ class Ui extends qu {
3169
3170
  constructor(e, n) {
3170
- super(e, n), this.dbName = `instant_${e}_${Wa}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3171
+ super(e, n), this.dbName = `instant_${e}_${Wu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3171
3172
  }
3172
3173
  _init() {
3173
3174
  return new Promise((e, n) => {
@@ -3176,15 +3177,15 @@ class Ui extends qa {
3176
3177
  i.onerror = (s) => {
3177
3178
  n(s);
3178
3179
  }, i.onsuccess = (s) => {
3179
- const a = s.target.result;
3180
+ const u = s.target.result;
3180
3181
  if (r) {
3181
- const u = Qa(this._appId, a).catch((c) => {
3182
- Va("Error upgrading store from version 5 to 6.")(c);
3182
+ const a = Qu(this._appId, u).catch((c) => {
3183
+ Vu("Error upgrading store from version 5 to 6.")(c);
3183
3184
  });
3184
- Mr.set(this.dbName, u), u.then(() => e(a)).catch(() => e(a));
3185
+ Mr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3185
3186
  } else {
3186
- const u = Mr.get(this.dbName);
3187
- u ? u.then(() => e(a)).catch(() => e(a)) : e(a);
3187
+ const a = Mr.get(this.dbName);
3188
+ a ? a.then(() => e(u)).catch(() => e(u)) : e(u);
3188
3189
  }
3189
3190
  }, i.onupgradeneeded = (s) => {
3190
3191
  r = !0, this._upgradeStore(s);
@@ -3193,18 +3194,18 @@ class Ui extends qa {
3193
3194
  }
3194
3195
  _upgradeStore(e) {
3195
3196
  const r = e.target.result;
3196
- for (const i of za)
3197
+ for (const i of zu)
3197
3198
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3198
3199
  }
3199
3200
  getItem(e) {
3200
3201
  return ye(this, void 0, void 0, function* () {
3201
3202
  const n = yield this._dbPromise;
3202
3203
  return new Promise((r, i) => {
3203
- const a = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
3204
- a.onerror = (u) => {
3205
- i(u);
3206
- }, a.onsuccess = (u) => {
3207
- a.result ? r(a.result) : r(null);
3204
+ const u = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
3205
+ u.onerror = (a) => {
3206
+ i(a);
3207
+ }, u.onsuccess = (a) => {
3208
+ u.result ? r(u.result) : r(null);
3208
3209
  };
3209
3210
  });
3210
3211
  });
@@ -3213,10 +3214,10 @@ class Ui extends qa {
3213
3214
  return ye(this, void 0, void 0, function* () {
3214
3215
  const r = yield this._dbPromise;
3215
3216
  return new Promise((i, s) => {
3216
- const u = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
3217
- u.onerror = (c) => {
3217
+ const a = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
3218
+ a.onerror = (c) => {
3218
3219
  s(c);
3219
- }, u.onsuccess = (c) => {
3220
+ }, a.onsuccess = (c) => {
3220
3221
  i();
3221
3222
  };
3222
3223
  });
@@ -3227,16 +3228,16 @@ class Ui extends qa {
3227
3228
  return ye(this, void 0, void 0, function* () {
3228
3229
  const n = yield this._dbPromise;
3229
3230
  return new Promise((r, i) => {
3230
- const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), a = /* @__PURE__ */ new Set();
3231
- for (const [u, c] of e) {
3232
- const d = o.put(c, u);
3233
- a.add(d);
3231
+ const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), u = /* @__PURE__ */ new Set();
3232
+ for (const [a, c] of e) {
3233
+ const d = o.put(c, a);
3234
+ u.add(d);
3234
3235
  }
3235
- for (const u of a)
3236
- u.onerror = (c) => {
3236
+ for (const a of u)
3237
+ a.onerror = (c) => {
3237
3238
  s.abort(), i(c);
3238
- }, u.onsuccess = (c) => {
3239
- a.delete(u), a.size === 0 && r();
3239
+ }, a.onsuccess = (c) => {
3240
+ u.delete(a), u.size === 0 && r();
3240
3241
  };
3241
3242
  });
3242
3243
  });
@@ -3245,10 +3246,10 @@ class Ui extends qa {
3245
3246
  return ye(this, void 0, void 0, function* () {
3246
3247
  const n = yield this._dbPromise;
3247
3248
  return new Promise((r, i) => {
3248
- const a = n.transaction([this._storeName], "readwrite").objectStore(this._storeName).delete(e);
3249
- a.onerror = (u) => {
3250
- i(u);
3251
- }, a.onsuccess = (u) => {
3249
+ const u = n.transaction([this._storeName], "readwrite").objectStore(this._storeName).delete(e);
3250
+ u.onerror = (a) => {
3251
+ i(a);
3252
+ }, u.onsuccess = (a) => {
3252
3253
  r();
3253
3254
  };
3254
3255
  });
@@ -3259,30 +3260,30 @@ class Ui extends qa {
3259
3260
  const e = yield this._dbPromise;
3260
3261
  return new Promise((n, r) => {
3261
3262
  const o = e.transaction([this._storeName], "readonly").objectStore(this._storeName).getAllKeys();
3262
- o.onerror = (a) => {
3263
- r(a);
3264
- }, o.onsuccess = (a) => {
3265
- n(o.result.filter((u) => typeof u == "string"));
3263
+ o.onerror = (u) => {
3264
+ r(u);
3265
+ }, o.onsuccess = (u) => {
3266
+ n(o.result.filter((a) => typeof a == "string"));
3266
3267
  };
3267
3268
  });
3268
3269
  });
3269
3270
  }
3270
3271
  }
3271
- var Ha = function(t, e, n, r) {
3272
+ var Hu = function(t, e, n, r) {
3272
3273
  function i(s) {
3273
3274
  return s instanceof n ? s : new n(function(o) {
3274
3275
  o(s);
3275
3276
  });
3276
3277
  }
3277
3278
  return new (n || (n = Promise))(function(s, o) {
3278
- function a(d) {
3279
+ function u(d) {
3279
3280
  try {
3280
3281
  c(r.next(d));
3281
3282
  } catch (f) {
3282
3283
  o(f);
3283
3284
  }
3284
3285
  }
3285
- function u(d) {
3286
+ function a(d) {
3286
3287
  try {
3287
3288
  c(r.throw(d));
3288
3289
  } catch (f) {
@@ -3290,14 +3291,14 @@ var Ha = function(t, e, n, r) {
3290
3291
  }
3291
3292
  }
3292
3293
  function c(d) {
3293
- d.done ? s(d.value) : i(d.value).then(a, u);
3294
+ d.done ? s(d.value) : i(d.value).then(u, a);
3294
3295
  }
3295
3296
  c((r = r.apply(t, e || [])).next());
3296
3297
  });
3297
3298
  };
3298
3299
  class Li {
3299
3300
  static getIsOnline() {
3300
- return Ha(this, void 0, void 0, function* () {
3301
+ return Hu(this, void 0, void 0, function* () {
3301
3302
  return navigator.onLine;
3302
3303
  });
3303
3304
  }
@@ -3322,21 +3323,21 @@ class qe extends Error {
3322
3323
  return "InstantError";
3323
3324
  }
3324
3325
  }
3325
- var Ya = function(t, e, n, r) {
3326
+ var Yu = function(t, e, n, r) {
3326
3327
  function i(s) {
3327
3328
  return s instanceof n ? s : new n(function(o) {
3328
3329
  o(s);
3329
3330
  });
3330
3331
  }
3331
3332
  return new (n || (n = Promise))(function(s, o) {
3332
- function a(d) {
3333
+ function u(d) {
3333
3334
  try {
3334
3335
  c(r.next(d));
3335
3336
  } catch (f) {
3336
3337
  o(f);
3337
3338
  }
3338
3339
  }
3339
- function u(d) {
3340
+ function a(d) {
3340
3341
  try {
3341
3342
  c(r.throw(d));
3342
3343
  } catch (f) {
@@ -3344,7 +3345,7 @@ var Ya = function(t, e, n, r) {
3344
3345
  }
3345
3346
  }
3346
3347
  function c(d) {
3347
- d.done ? s(d.value) : i(d.value).then(a, u);
3348
+ d.done ? s(d.value) : i(d.value).then(u, a);
3348
3349
  }
3349
3350
  c((r = r.apply(t, e || [])).next());
3350
3351
  });
@@ -3361,8 +3362,8 @@ class Dt extends qe {
3361
3362
  return "InstantAPIError";
3362
3363
  }
3363
3364
  }
3364
- function ue(t, e) {
3365
- return Ya(this, void 0, void 0, function* () {
3365
+ function ae(t, e) {
3366
+ return Yu(this, void 0, void 0, function* () {
3366
3367
  const n = yield fetch(t, e), r = yield n.json();
3367
3368
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Dt({ status: n.status, body: r }));
3368
3369
  });
@@ -3374,14 +3375,14 @@ var ze = function(t, e, n, r) {
3374
3375
  });
3375
3376
  }
3376
3377
  return new (n || (n = Promise))(function(s, o) {
3377
- function a(d) {
3378
+ function u(d) {
3378
3379
  try {
3379
3380
  c(r.next(d));
3380
3381
  } catch (f) {
3381
3382
  o(f);
3382
3383
  }
3383
3384
  }
3384
- function u(d) {
3385
+ function a(d) {
3385
3386
  try {
3386
3387
  c(r.throw(d));
3387
3388
  } catch (f) {
@@ -3389,21 +3390,21 @@ var ze = function(t, e, n, r) {
3389
3390
  }
3390
3391
  }
3391
3392
  function c(d) {
3392
- d.done ? s(d.value) : i(d.value).then(a, u);
3393
+ d.done ? s(d.value) : i(d.value).then(u, a);
3393
3394
  }
3394
3395
  c((r = r.apply(t, e || [])).next());
3395
3396
  });
3396
3397
  };
3397
- function Ja({ apiURI: t, appId: e, email: n }) {
3398
- return ue(`${t}/runtime/auth/send_magic_code`, {
3398
+ function Ju({ apiURI: t, appId: e, email: n }) {
3399
+ return ae(`${t}/runtime/auth/send_magic_code`, {
3399
3400
  method: "POST",
3400
3401
  headers: { "content-type": "application/json" },
3401
3402
  body: JSON.stringify({ "app-id": e, email: n })
3402
3403
  });
3403
3404
  }
3404
- function Za(t) {
3405
+ function Zu(t) {
3405
3406
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3406
- return yield ue(`${e}/runtime/auth/verify_magic_code`, {
3407
+ return yield ae(`${e}/runtime/auth/verify_magic_code`, {
3407
3408
  method: "POST",
3408
3409
  headers: { "content-type": "application/json" },
3409
3410
  body: JSON.stringify(Object.assign({
@@ -3414,9 +3415,9 @@ function Za(t) {
3414
3415
  });
3415
3416
  });
3416
3417
  }
3417
- function Xa(t) {
3418
+ function Xu(t) {
3418
3419
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3419
- return yield ue(`${e}/runtime/auth/verify_refresh_token`, {
3420
+ return yield ae(`${e}/runtime/auth/verify_refresh_token`, {
3420
3421
  method: "POST",
3421
3422
  headers: { "content-type": "application/json" },
3422
3423
  body: JSON.stringify({
@@ -3426,9 +3427,9 @@ function Xa(t) {
3426
3427
  });
3427
3428
  });
3428
3429
  }
3429
- function eu(t) {
3430
+ function ea(t) {
3430
3431
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3431
- return yield ue(`${e}/runtime/auth/sign_in_guest`, {
3432
+ return yield ae(`${e}/runtime/auth/sign_in_guest`, {
3432
3433
  method: "POST",
3433
3434
  headers: { "content-type": "application/json" },
3434
3435
  body: JSON.stringify({
@@ -3439,7 +3440,7 @@ function eu(t) {
3439
3440
  }
3440
3441
  function Rr(t) {
3441
3442
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
3442
- return yield ue(`${e}/runtime/oauth/token`, {
3443
+ return yield ae(`${e}/runtime/oauth/token`, {
3443
3444
  method: "POST",
3444
3445
  headers: { "content-type": "application/json" },
3445
3446
  body: JSON.stringify({
@@ -3451,9 +3452,9 @@ function Rr(t) {
3451
3452
  });
3452
3453
  });
3453
3454
  }
3454
- function tu(t) {
3455
+ function ta(t) {
3455
3456
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3456
- return yield ue(`${e}/runtime/oauth/id_token`, {
3457
+ return yield ae(`${e}/runtime/oauth/id_token`, {
3457
3458
  method: "POST",
3458
3459
  headers: { "content-type": "application/json" },
3459
3460
  body: JSON.stringify({
@@ -3466,9 +3467,9 @@ function tu(t) {
3466
3467
  });
3467
3468
  });
3468
3469
  }
3469
- function nu(t) {
3470
+ function na(t) {
3470
3471
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3471
- return yield ue(`${e}/runtime/signout`, {
3472
+ return yield ae(`${e}/runtime/signout`, {
3472
3473
  method: "POST",
3473
3474
  headers: {
3474
3475
  "content-type": "application/json"
@@ -3487,14 +3488,14 @@ var dt = function(t, e, n, r) {
3487
3488
  });
3488
3489
  }
3489
3490
  return new (n || (n = Promise))(function(s, o) {
3490
- function a(d) {
3491
+ function u(d) {
3491
3492
  try {
3492
3493
  c(r.next(d));
3493
3494
  } catch (f) {
3494
3495
  o(f);
3495
3496
  }
3496
3497
  }
3497
- function u(d) {
3498
+ function a(d) {
3498
3499
  try {
3499
3500
  c(r.throw(d));
3500
3501
  } catch (f) {
@@ -3502,29 +3503,29 @@ var dt = function(t, e, n, r) {
3502
3503
  }
3503
3504
  }
3504
3505
  function c(d) {
3505
- d.done ? s(d.value) : i(d.value).then(a, u);
3506
+ d.done ? s(d.value) : i(d.value).then(u, a);
3506
3507
  }
3507
3508
  c((r = r.apply(t, e || [])).next());
3508
3509
  });
3509
3510
  };
3510
- function ru(t) {
3511
- return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: a }) {
3512
- const u = {
3511
+ function ra(t) {
3512
+ return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
3513
+ const a = {
3513
3514
  app_id: n,
3514
3515
  path: r,
3515
3516
  authorization: `Bearer ${s}`,
3516
3517
  "content-type": o || i.type
3517
3518
  };
3518
- return a && (u["content-disposition"] = a), yield ue(`${e}/storage/upload`, {
3519
+ return u && (a["content-disposition"] = u), yield ae(`${e}/storage/upload`, {
3519
3520
  method: "PUT",
3520
- headers: u,
3521
+ headers: a,
3521
3522
  body: i
3522
3523
  });
3523
3524
  });
3524
3525
  }
3525
- function iu(t) {
3526
+ function ia(t) {
3526
3527
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3527
- const { data: s } = yield ue(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3528
+ const { data: s } = yield ae(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3528
3529
  method: "DELETE",
3529
3530
  headers: {
3530
3531
  "content-type": "application/json",
@@ -3534,9 +3535,9 @@ function iu(t) {
3534
3535
  return s;
3535
3536
  });
3536
3537
  }
3537
- function su(t) {
3538
+ function sa(t) {
3538
3539
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3539
- const { data: o } = yield ue(`${e}/storage/signed-upload-url`, {
3540
+ const { data: o } = yield ae(`${e}/storage/signed-upload-url`, {
3540
3541
  method: "POST",
3541
3542
  headers: {
3542
3543
  "content-type": "application/json",
@@ -3550,7 +3551,7 @@ function su(t) {
3550
3551
  return o;
3551
3552
  });
3552
3553
  }
3553
- function ou(t, e) {
3554
+ function oa(t, e) {
3554
3555
  return dt(this, void 0, void 0, function* () {
3555
3556
  return (yield fetch(t, {
3556
3557
  method: "PUT",
@@ -3561,9 +3562,9 @@ function ou(t, e) {
3561
3562
  })).ok;
3562
3563
  });
3563
3564
  }
3564
- function au(t) {
3565
+ function ua(t) {
3565
3566
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3566
- const { data: s } = yield ue(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3567
+ const { data: s } = yield ae(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3567
3568
  method: "GET",
3568
3569
  headers: {
3569
3570
  "content-type": "application/json",
@@ -3583,25 +3584,25 @@ function xr(t, e) {
3583
3584
  n[r] = t[r];
3584
3585
  }), n;
3585
3586
  }
3586
- function uu(t, e, n) {
3587
+ function aa(t, e, n) {
3587
3588
  var r, i;
3588
3589
  const s = {
3589
3590
  peers: {}
3590
3591
  };
3591
3592
  if (e && "user" in e ? e.user : !0) {
3592
- const a = xr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3593
- s.user = Object.assign(Object.assign({}, a), { peerId: n });
3593
+ const u = xr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3594
+ s.user = Object.assign(Object.assign({}, u), { peerId: n });
3594
3595
  }
3595
- for (const a of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3596
- const u = (e == null ? void 0 : e.peers) === void 0, c = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(a));
3597
- if (u || c) {
3598
- const d = xr(t.peers[a], e == null ? void 0 : e.keys);
3599
- s.peers[a] = Object.assign(Object.assign({}, d), { peerId: a });
3596
+ for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3597
+ const a = (e == null ? void 0 : e.peers) === void 0, c = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
3598
+ if (a || c) {
3599
+ const d = xr(t.peers[u], e == null ? void 0 : e.keys);
3600
+ s.peers[u] = Object.assign(Object.assign({}, d), { peerId: u });
3600
3601
  }
3601
3602
  }
3602
3603
  return s;
3603
3604
  }
3604
- function cu(t, e) {
3605
+ function ca(t, e) {
3605
3606
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !wr(t.user, e.user)) || !yi(t.peers, e.peers))
3606
3607
  return !0;
3607
3608
  for (const r of Object.keys(t.peers))
@@ -3626,8 +3627,8 @@ function Ki(t, e = []) {
3626
3627
  t.forEach((n) => {
3627
3628
  const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
3628
3629
  for (const o of s)
3629
- for (const a of o)
3630
- e.push(a);
3630
+ for (const u of o)
3631
+ e.push(u);
3631
3632
  Ki(n["child-nodes"], e);
3632
3633
  });
3633
3634
  }
@@ -3649,8 +3650,8 @@ function Ur(t) {
3649
3650
  }, e;
3650
3651
  }, {});
3651
3652
  }
3652
- const Wn = "v0.22.86-experimental.split-store.20183617880.1";
3653
- function du(t, e) {
3653
+ const Wn = "v0.22.86-experimental.split-store.20247643606.1";
3654
+ function da(t, e) {
3654
3655
  return {
3655
3656
  info: t ? (...n) => console.info(...n, e()) : () => {
3656
3657
  },
@@ -3734,7 +3735,7 @@ const Lr = [
3734
3735
  "before",
3735
3736
  "fields",
3736
3737
  "aggregate"
3737
- ], fu = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
3738
+ ], fa = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
3738
3739
  if (n || t == null)
3739
3740
  return !0;
3740
3741
  switch (e) {
@@ -3749,9 +3750,9 @@ const Lr = [
3749
3750
  default:
3750
3751
  return !0;
3751
3752
  }
3752
- }, lu = (t, e, n, r, i, s, o) => {
3753
- const a = s.valueType === "json", u = (c, d, f) => {
3754
- if (!qi(f, d, a))
3753
+ }, la = (t, e, n, r, i, s, o) => {
3754
+ const u = s.valueType === "json", a = (c, d, f) => {
3755
+ if (!qi(f, d, u))
3755
3756
  throw new R(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
3756
3757
  };
3757
3758
  switch (t) {
@@ -3760,7 +3761,7 @@ const Lr = [
3760
3761
  if (!Array.isArray(e))
3761
3762
  throw new R(`Operator '${t}' for attribute '${r}' in entity '${i}' must be an array, but received: ${typeof e}`, o);
3762
3763
  for (const c of e)
3763
- u(t, n, c);
3764
+ a(t, n, c);
3764
3765
  break;
3765
3766
  case "$not":
3766
3767
  case "$ne":
@@ -3768,30 +3769,30 @@ const Lr = [
3768
3769
  case "$lt":
3769
3770
  case "$gte":
3770
3771
  case "$lte":
3771
- u(t, n, e);
3772
+ a(t, n, e);
3772
3773
  break;
3773
3774
  case "$like":
3774
3775
  case "$ilike":
3775
- if (u(t, "string", e), t === "$ilike" && !s.isIndexed)
3776
+ if (a(t, "string", e), t === "$ilike" && !s.isIndexed)
3776
3777
  throw new R(`Operator '${t}' can only be used with indexed attributes, but '${r}' in entity '${i}' is not indexed`, o);
3777
3778
  break;
3778
3779
  case "$isNull":
3779
- u(t, "boolean", e);
3780
+ a(t, "boolean", e);
3780
3781
  break;
3781
3782
  default:
3782
3783
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
3783
3784
  }
3784
3785
  }, Le = (t, e, n, r, i) => {
3785
- const s = fu(n), o = n.valueType === "json";
3786
+ const s = fa(n), o = n.valueType === "json";
3786
3787
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3787
3788
  if (o)
3788
3789
  return;
3789
- const u = t;
3790
- for (const [c, d] of Object.entries(u))
3791
- lu(c, d, s, e, r, n, `${i}.${c}`);
3790
+ const a = t;
3791
+ for (const [c, d] of Object.entries(a))
3792
+ la(c, d, s, e, r, n, `${i}.${c}`);
3792
3793
  } else if (!qi(t, s, o))
3793
3794
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3794
- }, hu = (t, e, n, r, i) => {
3795
+ }, ha = (t, e, n, r, i) => {
3795
3796
  const s = t.split(".");
3796
3797
  if (s.length < 2)
3797
3798
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -3807,25 +3808,25 @@ const Lr = [
3807
3808
  }
3808
3809
  o = p.entityName;
3809
3810
  }
3810
- const a = s[s.length - 1], u = r.entities[o];
3811
- if (!u)
3811
+ const u = s[s.length - 1], a = r.entities[o];
3812
+ if (!a)
3812
3813
  throw new R(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, i);
3813
- if (a === "id") {
3814
+ if (u === "id") {
3814
3815
  if (typeof e == "string" && !Ne(e))
3815
3816
  throw new R(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3816
3817
  Le(e, t, new H("string", !1, !0), n, i);
3817
3818
  return;
3818
3819
  }
3819
- const c = u.attrs[a];
3820
- if (Object.keys(u.links).includes(a)) {
3820
+ const c = a.attrs[u];
3821
+ if (Object.keys(a.links).includes(u)) {
3821
3822
  if (typeof e == "string" && !Ne(e))
3822
- throw new R(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3823
+ throw new R(`Invalid value for link '${u}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3823
3824
  Le(e, t, new H("string", !1, !0), n, i);
3824
3825
  return;
3825
3826
  }
3826
3827
  if (!c) {
3827
- const d = Object.keys(u.attrs);
3828
- throw new R(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${d.length > 0 ? d.join(", ") + ", id" : "id"}`, i);
3828
+ const d = Object.keys(a.attrs);
3829
+ throw new R(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${d.length > 0 ? d.join(", ") + ", id" : "id"}`, i);
3829
3830
  }
3830
3831
  Le(e, t, c, n, i);
3831
3832
  }, Wi = (t, e, n, r) => {
@@ -3841,27 +3842,27 @@ const Lr = [
3841
3842
  continue;
3842
3843
  }
3843
3844
  if (i.includes(".")) {
3844
- hu(i, s, e, n, `${r}.${i}`);
3845
+ ha(i, s, e, n, `${r}.${i}`);
3845
3846
  continue;
3846
3847
  }
3847
3848
  const o = n.entities[e];
3848
3849
  if (!o)
3849
3850
  continue;
3850
- const a = o.attrs[i], u = o.links[i];
3851
- if (!a && !u) {
3851
+ const u = o.attrs[i], a = o.links[i];
3852
+ if (!u && !a) {
3852
3853
  const c = Object.keys(o.attrs), d = Object.keys(o.links);
3853
3854
  throw new R(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${c.length > 0 ? c.join(", ") : "none"}. Available links: ${d.length > 0 ? d.join(", ") : "none"}`, `${r}.${i}`);
3854
3855
  }
3855
- if (a)
3856
- Le(s, i, a, e, `${r}.${i}`);
3857
- else if (u) {
3856
+ if (u)
3857
+ Le(s, i, u, e, `${r}.${i}`);
3858
+ else if (a) {
3858
3859
  if (typeof s == "string" && !Ne(s))
3859
3860
  throw new R(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${s}`, `${r}.${i}`);
3860
3861
  const c = new H("string", !1, !0);
3861
3862
  Le(s, i, c, e, `${r}.${i}`);
3862
3863
  }
3863
3864
  }
3864
- }, pu = (t, e, n, r, i = 0) => {
3865
+ }, pa = (t, e, n, r, i = 0) => {
3865
3866
  for (const o of Object.keys(t))
3866
3867
  if (!Lr.includes(o))
3867
3868
  throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Lr.join(", ")}. Found: ${o}`, r);
@@ -3888,19 +3889,19 @@ const Lr = [
3888
3889
  for (const o of Object.keys(t))
3889
3890
  if (o !== "$") {
3890
3891
  if (n && !(o in n.entities[e].links)) {
3891
- const u = Object.keys(n.entities[e].links);
3892
- throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${u.length > 0 ? u.join(", ") : "none"}`, `${r}.${o}`);
3892
+ const a = Object.keys(n.entities[e].links);
3893
+ throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${a.length > 0 ? a.join(", ") : "none"}`, `${r}.${o}`);
3893
3894
  }
3894
- const a = t[o];
3895
- if (typeof a == "object" && a !== null) {
3896
- const u = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3897
- u && zi(a, u, n, `${r}.${o}`, i + 1);
3895
+ const u = t[o];
3896
+ if (typeof u == "object" && u !== null) {
3897
+ const a = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3898
+ a && zi(u, a, n, `${r}.${o}`, i + 1);
3898
3899
  }
3899
3900
  } else {
3900
- const a = t[o];
3901
- if (typeof a != "object" || a === null)
3902
- throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3903
- pu(a, e, n, `${r}.$`, i);
3901
+ const u = t[o];
3902
+ if (typeof u != "object" || u === null)
3903
+ throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
3904
+ pa(u, e, n, `${r}.$`, i);
3904
3905
  }
3905
3906
  }, Fr = (t, e) => {
3906
3907
  if (typeof t != "object" || t === null)
@@ -3927,19 +3928,19 @@ class ie extends Error {
3927
3928
  super(e), this.name = "TransactionValidationError";
3928
3929
  }
3929
3930
  }
3930
- const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Vi(e)}`), Kr = {
3931
+ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ya = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Vi(e)}`), Kr = {
3931
3932
  string: (t) => typeof t == "string",
3932
3933
  number: (t) => typeof t == "number" && !isNaN(t),
3933
3934
  boolean: (t) => typeof t == "boolean",
3934
3935
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3935
3936
  json: () => !0
3936
- }, bu = (t, e) => {
3937
+ }, ba = (t, e) => {
3937
3938
  var n, r;
3938
3939
  return t == null ? !0 : (r = (n = Kr[e.valueType]) === null || n === void 0 ? void 0 : n.call(Kr, t)) !== null && r !== void 0 ? r : !1;
3939
3940
  }, Bi = (t, e) => {
3940
3941
  const n = e.entities[t];
3941
3942
  if (!n)
3942
- throw yu(t, Object.keys(e.entities));
3943
+ throw ya(t, Object.keys(e.entities));
3943
3944
  return n;
3944
3945
  }, Yt = (t, e, n) => {
3945
3946
  const r = Bi(t, n);
@@ -3949,7 +3950,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3949
3950
  if (i === "id")
3950
3951
  continue;
3951
3952
  const o = r.attrs[i];
3952
- if (o && !bu(s, o))
3953
+ if (o && !ba(s, o))
3953
3954
  throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
3954
3955
  }
3955
3956
  }, qr = (t, e, n) => {
@@ -3958,19 +3959,19 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3958
3959
  throw new ie(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
3959
3960
  for (const [i, s] of Object.entries(e)) {
3960
3961
  if (!r.links[i]) {
3961
- const a = Object.keys(r.links);
3962
- throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Vi(a)}`);
3962
+ const u = Object.keys(r.links);
3963
+ throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Vi(u)}`);
3963
3964
  }
3964
3965
  if (s != null) {
3965
3966
  if (Array.isArray(s)) {
3966
- for (const a of s)
3967
- if (!Nr(a))
3968
- throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
3967
+ for (const u of s)
3968
+ if (!Nr(u))
3969
+ throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${u}`);
3969
3970
  } else if (!Nr(s))
3970
3971
  throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
3971
3972
  }
3972
3973
  }
3973
- }, _u = {
3974
+ }, _a = {
3974
3975
  create: Yt,
3975
3976
  update: Yt,
3976
3977
  merge: Yt,
@@ -3978,7 +3979,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3978
3979
  unlink: qr,
3979
3980
  delete: () => {
3980
3981
  }
3981
- }, gu = (t, e) => {
3982
+ }, ga = (t, e) => {
3982
3983
  if (!e)
3983
3984
  return;
3984
3985
  const [n, r, i, s] = t;
@@ -3986,9 +3987,9 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3986
3987
  throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
3987
3988
  if (typeof r != "string")
3988
3989
  throw new ie(`Entity name must be a string, but received: ${typeof r}`);
3989
- const o = _u[n];
3990
+ const o = _a[n];
3990
3991
  o && s !== void 0 && o(r, s, e);
3991
- }, wu = (t, e) => {
3992
+ }, wa = (t, e) => {
3992
3993
  const n = Array.isArray(t) ? t : [t];
3993
3994
  for (const r of n) {
3994
3995
  if (!r || typeof r != "object")
@@ -3998,7 +3999,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3998
3999
  for (const i of r.__ops) {
3999
4000
  if (!Array.isArray(i))
4000
4001
  throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
4001
- gu(i, e);
4002
+ ga(i, e);
4002
4003
  }
4003
4004
  }
4004
4005
  };
@@ -4009,14 +4010,14 @@ var Wr = function(t, e, n, r) {
4009
4010
  });
4010
4011
  }
4011
4012
  return new (n || (n = Promise))(function(s, o) {
4012
- function a(d) {
4013
+ function u(d) {
4013
4014
  try {
4014
4015
  c(r.next(d));
4015
4016
  } catch (f) {
4016
4017
  o(f);
4017
4018
  }
4018
4019
  }
4019
- function u(d) {
4020
+ function a(d) {
4020
4021
  try {
4021
4022
  c(r.throw(d));
4022
4023
  } catch (f) {
@@ -4024,7 +4025,7 @@ var Wr = function(t, e, n, r) {
4024
4025
  }
4025
4026
  }
4026
4027
  function c(d) {
4027
- d.done ? s(d.value) : i(d.value).then(a, u);
4028
+ d.done ? s(d.value) : i(d.value).then(u, a);
4028
4029
  }
4029
4030
  c((r = r.apply(t, e || [])).next());
4030
4031
  });
@@ -4060,7 +4061,7 @@ class zr {
4060
4061
  return this.conn.send(JSON.stringify(e));
4061
4062
  }
4062
4063
  }
4063
- class Tu {
4064
+ class Ta {
4064
4065
  constructor(e, n) {
4065
4066
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Gi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4066
4067
  this.initParams || this.handleError();
@@ -4153,14 +4154,14 @@ var Vr = function(t, e, n, r) {
4153
4154
  });
4154
4155
  }
4155
4156
  return new (n || (n = Promise))(function(s, o) {
4156
- function a(d) {
4157
+ function u(d) {
4157
4158
  try {
4158
4159
  c(r.next(d));
4159
4160
  } catch (f) {
4160
4161
  o(f);
4161
4162
  }
4162
4163
  }
4163
- function u(d) {
4164
+ function a(d) {
4164
4165
  try {
4165
4166
  c(r.throw(d));
4166
4167
  } catch (f) {
@@ -4168,12 +4169,12 @@ var Vr = function(t, e, n, r) {
4168
4169
  }
4169
4170
  }
4170
4171
  function c(d) {
4171
- d.done ? s(d.value) : i(d.value).then(a, u);
4172
+ d.done ? s(d.value) : i(d.value).then(u, a);
4172
4173
  }
4173
4174
  c((r = r.apply(t, e || [])).next());
4174
4175
  });
4175
4176
  };
4176
- function mu(t, e) {
4177
+ function ma(t, e) {
4177
4178
  const n = t.values;
4178
4179
  if (n) {
4179
4180
  const r = mi(n.attrsStore, null);
@@ -4185,7 +4186,7 @@ function mu(t, e) {
4185
4186
  }
4186
4187
  return t;
4187
4188
  }
4188
- function vu(t, e) {
4189
+ function va(t, e) {
4189
4190
  var n;
4190
4191
  if (e.values) {
4191
4192
  const r = [];
@@ -4197,7 +4198,7 @@ function vu(t, e) {
4197
4198
  } else
4198
4199
  return e;
4199
4200
  }
4200
- function Su(t, e, n) {
4201
+ function Sa(t, e, n) {
4201
4202
  var r, i;
4202
4203
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4203
4204
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
@@ -4224,17 +4225,17 @@ function Gr(t, e, n) {
4224
4225
  break;
4225
4226
  }
4226
4227
  }
4227
- function Ou(t, e, n) {
4228
+ function Oa(t, e, n) {
4228
4229
  var r, i, s, o;
4229
- const a = {};
4230
- for (const { action: u, triple: c } of n) {
4230
+ const u = {};
4231
+ for (const { action: a, triple: c } of n) {
4231
4232
  const [d, f, l] = c, p = (i = (r = e.getAttr(f)) === null || r === void 0 ? void 0 : r["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
4232
4233
  if (!p)
4233
4234
  continue;
4234
- const y = (s = a[d]) !== null && s !== void 0 ? s : {};
4235
- a[d] = y;
4235
+ const y = (s = u[d]) !== null && s !== void 0 ? s : {};
4236
+ u[d] = y;
4236
4237
  const b = (o = y[p]) !== null && o !== void 0 ? o : {};
4237
- switch (y[p] = b, u) {
4238
+ switch (y[p] = b, a) {
4238
4239
  case "added":
4239
4240
  b.newValue = l;
4240
4241
  break;
@@ -4243,53 +4244,53 @@ function Ou(t, e, n) {
4243
4244
  break;
4244
4245
  }
4245
4246
  }
4246
- for (const u of Object.keys(a)) {
4247
- const { oldValue: c, newValue: d } = a[u];
4248
- c === d && delete a[u];
4247
+ for (const a of Object.keys(u)) {
4248
+ const { oldValue: c, newValue: d } = u[a];
4249
+ c === d && delete u[a];
4249
4250
  }
4250
- return a;
4251
+ return u;
4251
4252
  }
4252
4253
  function Tt(t, e) {
4253
4254
  return { [t.table]: e.map((n) => n.entity) };
4254
4255
  }
4255
- function Eu(t, e) {
4256
+ function Ea(t, e) {
4256
4257
  var n;
4257
4258
  if (t.orderFieldType)
4258
4259
  return t.orderFieldType;
4259
4260
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = K(e(), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4260
4261
  return t.orderFieldType = r, r;
4261
4262
  }
4262
- function Au(t, e, n) {
4263
+ function Aa(t, e, n) {
4263
4264
  const r = e;
4264
4265
  if (t.orderField === "serverCreatedAt") {
4265
- n.sort(t.orderDirection === "asc" ? function(o, a) {
4266
- return Ze(o.entity.id, o.serverCreatedAt, a.entity.id, a.serverCreatedAt, r);
4267
- } : function(o, a) {
4268
- return Ze(a.entity.id, a.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
4266
+ n.sort(t.orderDirection === "asc" ? function(o, u) {
4267
+ return Ze(o.entity.id, o.serverCreatedAt, u.entity.id, u.serverCreatedAt, r);
4268
+ } : function(o, u) {
4269
+ return Ze(u.entity.id, u.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
4269
4270
  });
4270
4271
  return;
4271
4272
  }
4272
4273
  const i = t.orderField;
4273
- n.sort(t.orderDirection === "asc" ? function(o, a) {
4274
- return Ze(o.entity.id, o.entity[i], a.entity.id, a.entity[i], r);
4275
- } : function(o, a) {
4276
- return Ze(a.entity.id, a.entity[i], o.entity.id, o.entity[i], r);
4274
+ n.sort(t.orderDirection === "asc" ? function(o, u) {
4275
+ return Ze(o.entity.id, o.entity[i], u.entity.id, u.entity[i], r);
4276
+ } : function(o, u) {
4277
+ return Ze(u.entity.id, u.entity[i], o.entity.id, o.entity[i], r);
4277
4278
  });
4278
4279
  }
4279
4280
  var ve;
4280
4281
  (function(t) {
4281
4282
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4282
4283
  })(ve || (ve = {}));
4283
- class ku {
4284
+ class ka {
4284
4285
  constructor(e, n, r, i, s, o) {
4285
4286
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.getAttrs = o, this.subs = new _n({
4286
4287
  persister: n,
4287
- merge: Su,
4288
- serialize: vu,
4289
- parse: (a, u) => mu(u, this.config.useDateObjects),
4290
- objectSize: (a) => {
4291
- var u;
4292
- return ((u = a.values) === null || u === void 0 ? void 0 : u.entities.length) || 0;
4288
+ merge: Sa,
4289
+ serialize: va,
4290
+ parse: (u, a) => ma(a, this.config.useDateObjects),
4291
+ objectSize: (u) => {
4292
+ var a;
4293
+ return ((a = u.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
4293
4294
  },
4294
4295
  logger: i,
4295
4296
  gc: {
@@ -4344,17 +4345,17 @@ class ku {
4344
4345
  }
4345
4346
  initSubscription(e, n, r) {
4346
4347
  return Vr(this, void 0, void 0, function* () {
4347
- var i, s, o, a;
4348
+ var i, s, o, u;
4348
4349
  yield this.subs.waitForKeyToLoad(n);
4349
- const u = this.subs.currentValue[n];
4350
- if (u && u.state && u.state.txId) {
4351
- this.sendResync(u, u.state, u.state.txId), !((i = u.values) === null || i === void 0) && i.entities && r && r({
4350
+ const a = this.subs.currentValue[n];
4351
+ if (a && a.state && a.state.txId) {
4352
+ this.sendResync(a, a.state, a.state.txId), !((i = a.values) === null || i === void 0) && i.entities && r && r({
4352
4353
  type: ve.LoadFromStorage,
4353
- data: Tt(u, (s = u.values) === null || s === void 0 ? void 0 : s.entities)
4354
+ data: Tt(a, (s = a.values) === null || s === void 0 ? void 0 : s.entities)
4354
4355
  });
4355
4356
  return;
4356
4357
  }
4357
- const c = Object.keys(e)[0], d = ((a = (o = e[c]) === null || o === void 0 ? void 0 : o.$) === null || a === void 0 ? void 0 : a.order) || { serverCreatedAt: "asc" }, [f, l] = Object.entries(d)[0];
4358
+ const c = Object.keys(e)[0], d = ((u = (o = e[c]) === null || o === void 0 ? void 0 : o.$) === null || u === void 0 ? void 0 : u.order) || { serverCreatedAt: "asc" }, [f, l] = Object.entries(d)[0];
4358
4359
  this.subs.updateInPlace((p) => {
4359
4360
  p[n] = {
4360
4361
  query: e,
@@ -4400,30 +4401,30 @@ class ku {
4400
4401
  this.log.error("Missing hash for subscription", e);
4401
4402
  return;
4402
4403
  }
4403
- const o = [], a = this.subs.currentValue[s];
4404
- if (!a) {
4404
+ const o = [], u = this.subs.currentValue[s];
4405
+ if (!u) {
4405
4406
  this.log.error("Missing sub for hash", s, e);
4406
4407
  return;
4407
4408
  }
4408
- const u = (n = a.values) !== null && n !== void 0 ? n : {
4409
+ const a = (n = u.values) !== null && n !== void 0 ? n : {
4409
4410
  entities: [],
4410
4411
  attrsStore: this.getAttrs()
4411
4412
  };
4412
- a.values = u;
4413
- const c = u.entities;
4413
+ u.values = a;
4414
+ const c = a.entities;
4414
4415
  for (const d of i) {
4415
- const f = this.createStore(d), l = Jt(a, f, u.attrsStore);
4416
+ const f = this.createStore(d), l = Jt(u, f, a.attrsStore);
4416
4417
  c.push({
4417
4418
  store: f,
4418
4419
  entity: l,
4419
- serverCreatedAt: Br(a, f, u.attrsStore, l.id)
4420
+ serverCreatedAt: Br(u, f, a.attrsStore, l.id)
4420
4421
  }), o.push(l);
4421
4422
  }
4422
4423
  this.subs.updateInPlace((d) => {
4423
- d[s] = a, d[s].updatedAt = Date.now();
4424
- }), a.values && this.notifyCbs(s, {
4424
+ d[s] = u, d[s].updatedAt = Date.now();
4425
+ }), u.values && this.notifyCbs(s, {
4425
4426
  type: ve.InitialSyncBatch,
4426
- data: Tt(a, a.values.entities),
4427
+ data: Tt(u, u.values.entities),
4427
4428
  batch: o
4428
4429
  });
4429
4430
  }
@@ -4435,15 +4436,15 @@ class ku {
4435
4436
  return;
4436
4437
  }
4437
4438
  this.subs.updateInPlace((o) => {
4438
- const a = o[i];
4439
- if (!a) {
4439
+ const u = o[i];
4440
+ if (!u) {
4440
4441
  this.log.error("Missing sub for hash", i, e);
4441
4442
  return;
4442
4443
  }
4443
- const u = a.state;
4444
- if (!u)
4445
- return this.log.error("Sub never set init, missing result", a, e), o;
4446
- u.txId = e["tx-id"], a.updatedAt = Date.now();
4444
+ const a = u.state;
4445
+ if (!a)
4446
+ return this.log.error("Sub never set init, missing result", u, e), o;
4447
+ a.txId = e["tx-id"], u.updatedAt = Date.now();
4447
4448
  });
4448
4449
  const s = this.subs.currentValue[i];
4449
4450
  s && this.notifyCbs(i, {
@@ -4458,37 +4459,37 @@ class ku {
4458
4459
  this.log.error("Missing hash for subscription", e);
4459
4460
  return;
4460
4461
  }
4461
- const a = this.subs.currentValue[o];
4462
- if (!a) {
4462
+ const u = this.subs.currentValue[o];
4463
+ if (!u) {
4463
4464
  this.log.error("Missing sub for hash", o, e);
4464
4465
  return;
4465
4466
  }
4466
- const u = a.state;
4467
- if (!u) {
4468
- this.log.error("Missing state for sub", a, e);
4467
+ const a = u.state;
4468
+ if (!a) {
4469
+ this.log.error("Missing state for sub", u, e);
4469
4470
  return;
4470
4471
  }
4471
4472
  for (const c of e.txes) {
4472
- if (u.txId && u.txId >= c["tx-id"])
4473
+ if (a.txId && a.txId >= c["tx-id"])
4473
4474
  continue;
4474
- u.txId = c["tx-id"];
4475
+ a.txId = c["tx-id"];
4475
4476
  const d = [], f = {};
4476
4477
  for (const g of c.changes) {
4477
4478
  const m = (n = f[g.triple[0]]) !== null && n !== void 0 ? n : [];
4478
4479
  f[g.triple[0]] = m, m.push(g);
4479
4480
  }
4480
- const l = (r = a.values) !== null && r !== void 0 ? r : {
4481
+ const l = (r = u.values) !== null && r !== void 0 ? r : {
4481
4482
  entities: [],
4482
4483
  attrsStore: this.getAttrs()
4483
4484
  }, p = l.entities;
4484
- a.values = l;
4485
+ u.values = l;
4485
4486
  const y = [];
4486
4487
  e: for (const [g, m] of Object.entries(f))
4487
4488
  for (let O = 0; O < p.length; O++) {
4488
4489
  const S = p[O];
4489
4490
  if (io(S.store, g)) {
4490
4491
  Gr(S.store, l.attrsStore, m);
4491
- const C = Jt(a, S.store, l.attrsStore), $ = Ou(S.store, l.attrsStore, m)[g];
4492
+ const C = Jt(u, S.store, l.attrsStore), $ = Oa(S.store, l.attrsStore, m)[g];
4492
4493
  C ? (y.push({
4493
4494
  oldEntity: S.entity,
4494
4495
  newEntity: C,
@@ -4501,10 +4502,10 @@ class ku {
4501
4502
  for (const [g, m] of Object.entries(f)) {
4502
4503
  const O = this.createStore([]);
4503
4504
  Gr(O, l.attrsStore, m);
4504
- const S = Jt(a, O, l.attrsStore);
4505
+ const S = Jt(u, O, l.attrsStore);
4505
4506
  if (!S) {
4506
4507
  this.log.error("No entity found after applying change", {
4507
- sub: a,
4508
+ sub: u,
4508
4509
  changes: m,
4509
4510
  store: O
4510
4511
  });
@@ -4513,23 +4514,23 @@ class ku {
4513
4514
  p.push({
4514
4515
  store: O,
4515
4516
  entity: S,
4516
- serverCreatedAt: Br(a, O, l.attrsStore, S.id)
4517
+ serverCreatedAt: Br(u, O, l.attrsStore, S.id)
4517
4518
  }), b.push(S);
4518
4519
  }
4519
4520
  const _ = [];
4520
4521
  for (const g of d.sort().reverse())
4521
4522
  _.push(p[g].entity), p.splice(g, 1);
4522
- const T = Eu(a, this.getAttrs);
4523
- Au(a, T, p), this.notifyCbs(o, {
4523
+ const T = Ea(u, this.getAttrs);
4524
+ Aa(u, T, p), this.notifyCbs(o, {
4524
4525
  type: ve.SyncTransaction,
4525
- data: Tt(a, (i = a.values) === null || i === void 0 ? void 0 : i.entities),
4526
+ data: Tt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
4526
4527
  added: b,
4527
4528
  removed: _,
4528
4529
  updated: y
4529
4530
  });
4530
4531
  }
4531
4532
  this.subs.updateInPlace((c) => {
4532
- c[o] = a, c[o].updatedAt = Date.now();
4533
+ c[o] = u, c[o].updatedAt = Date.now();
4533
4534
  });
4534
4535
  }
4535
4536
  clearSubscriptionData(e, n) {
@@ -4568,14 +4569,14 @@ var N = function(t, e, n, r) {
4568
4569
  });
4569
4570
  }
4570
4571
  return new (n || (n = Promise))(function(s, o) {
4571
- function a(d) {
4572
+ function u(d) {
4572
4573
  try {
4573
4574
  c(r.next(d));
4574
4575
  } catch (f) {
4575
4576
  o(f);
4576
4577
  }
4577
4578
  }
4578
- function u(d) {
4579
+ function a(d) {
4579
4580
  try {
4580
4581
  c(r.throw(d));
4581
4582
  } catch (f) {
@@ -4583,7 +4584,7 @@ var N = function(t, e, n, r) {
4583
4584
  }
4584
4585
  }
4585
4586
  function c(d) {
4586
- d.done ? s(d.value) : i(d.value).then(a, u);
4587
+ d.done ? s(d.value) : i(d.value).then(u, a);
4587
4588
  }
4588
4589
  c((r = r.apply(t, e || [])).next());
4589
4590
  });
@@ -4601,23 +4602,23 @@ const he = {
4601
4602
  AUTHENTICATED: "authenticated",
4602
4603
  CLOSED: "closed",
4603
4604
  ERRORED: "errored"
4604
- }, ju = 3e4, Cu = 3e4, Iu = 200, Pu = {
4605
+ }, ja = 3e4, Ca = 3e4, Ia = 200, Pa = {
4605
4606
  apiURI: "https://api.instantdb.com",
4606
4607
  websocketURI: "wss://api.instantdb.com/runtime/session"
4607
4608
  }, Zt = "_instant_oauth_redirect", Ge = "currentUser";
4608
- function Mu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4609
+ function Ma({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4609
4610
  if (!i)
4610
4611
  return new zr(`${r}?app_id=${e}`);
4611
4612
  switch (t) {
4612
4613
  case "ws":
4613
4614
  return new zr(`${r}?app_id=${e}`);
4614
4615
  case "sse":
4615
- return new Tu(i, `${n}/runtime/sse?app_id=${e}`);
4616
+ return new Ta(i, `${n}/runtime/sse?app_id=${e}`);
4616
4617
  default:
4617
4618
  throw new Error("Unknown transport type " + t);
4618
4619
  }
4619
4620
  }
4620
- function Ru() {
4621
+ function Ra() {
4621
4622
  return typeof window < "u" || typeof chrome < "u";
4622
4623
  }
4623
4624
  const Qr = {
@@ -4626,7 +4627,7 @@ const Qr = {
4626
4627
  "refresh-presence": !0,
4627
4628
  "patch-presence": !0
4628
4629
  };
4629
- function xu(t, e) {
4630
+ function xa(t, e) {
4630
4631
  var n;
4631
4632
  const r = typeof t == "string" ? JSON.parse(t) : t;
4632
4633
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
@@ -4638,7 +4639,7 @@ function xu(t, e) {
4638
4639
  }
4639
4640
  return r;
4640
4641
  }
4641
- function $u(t, e) {
4642
+ function $a(t, e) {
4642
4643
  const { result: n } = e, i = Qi(e, ["result"]);
4643
4644
  if (n) {
4644
4645
  const s = Object.assign(Object.assign({}, n), { store: wi(n.store), attrsStore: n.attrsStore.toJSON() });
@@ -4646,7 +4647,7 @@ function $u(t, e) {
4646
4647
  }
4647
4648
  return i;
4648
4649
  }
4649
- function Du(t, e) {
4650
+ function Da(t, e) {
4650
4651
  switch (t) {
4651
4652
  case "pendingMutations":
4652
4653
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4654,7 +4655,7 @@ function Du(t, e) {
4654
4655
  return e;
4655
4656
  }
4656
4657
  }
4657
- function Uu(t, e) {
4658
+ function Ua(t, e) {
4658
4659
  switch (t) {
4659
4660
  case "pendingMutations":
4660
4661
  return [...e.entries()];
@@ -4662,19 +4663,19 @@ function Uu(t, e) {
4662
4663
  return e;
4663
4664
  }
4664
4665
  }
4665
- function Lu(t, e, n) {
4666
+ function La(t, e, n) {
4666
4667
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
4667
4668
  return r && !i && n && (n.result = r), n || e;
4668
4669
  }
4669
4670
  function Hr(t) {
4670
4671
  return [...t].sort((e, n) => {
4671
- const [r, i] = e, [s, o] = n, a = i.order || 0, u = o.order || 0;
4672
- return a == u ? r < s ? -1 : r > s ? 1 : 0 : a - u;
4672
+ const [r, i] = e, [s, o] = n, u = i.order || 0, a = o.order || 0;
4673
+ return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
4673
4674
  });
4674
4675
  }
4675
- class Fu {
4676
+ class Fa {
4676
4677
  constructor(e, n = Ui, r = Li, i, s) {
4677
- var o, a, u;
4678
+ var o, u, a;
4678
4679
  if (this._isOnline = !0, this._isShutdown = !1, this.status = he.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (c, d, f) => {
4679
4680
  var l, p;
4680
4681
  switch (c) {
@@ -4705,9 +4706,9 @@ class Fu {
4705
4706
  }, this.notifyQueryError = (c, d) => {
4706
4707
  (this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
4707
4708
  }, this.pushTx = (c) => {
4708
- this.config.disableValidation || wu(c, this.config.schema);
4709
+ this.config.disableValidation || wa(c, this.config.schema);
4709
4710
  try {
4710
- const d = Ka({
4711
+ const d = Ku({
4711
4712
  attrsStore: this.optimisticAttrs(),
4712
4713
  schema: this.config.schema,
4713
4714
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4796,7 +4797,7 @@ class Fu {
4796
4797
  return;
4797
4798
  }
4798
4799
  this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4799
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Pu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : Cu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : Iu, this._log = du(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Ru()) {
4800
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Pa), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Ca, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Ia, this._log = da(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Ra()) {
4800
4801
  if (!e.appId)
4801
4802
  throw new Error("Instant must be initialized with an appId.");
4802
4803
  if (!Ne(e.appId))
@@ -4811,7 +4812,7 @@ class Fu {
4811
4812
  } catch (f) {
4812
4813
  this._log.error("[error] handle broadcast channel", f);
4813
4814
  }
4814
- }))), this._initStorage(n), this._syncTable = new ku(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4815
+ }))), this._initStorage(n), this._syncTable = new ka(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4815
4816
  useDateObjects: this.config.useDateObjects
4816
4817
  }, this._log, (c) => Et(this.ensureAttrs(), c, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((c) => {
4817
4818
  this._isOnline = c, this._startSocket(), r.listen((d) => {
@@ -4841,9 +4842,9 @@ class Fu {
4841
4842
  _initStorage(e) {
4842
4843
  this.querySubs = new _n({
4843
4844
  persister: new e(this.config.appId, "querySubs"),
4844
- merge: Lu,
4845
- serialize: $u,
4846
- parse: (n, r) => xu(r, this.config.useDateObjects),
4845
+ merge: La,
4846
+ serialize: $a,
4847
+ parse: (n, r) => xa(r, this.config.useDateObjects),
4847
4848
  // objectSize
4848
4849
  objectSize: (n) => {
4849
4850
  var r, i, s, o;
@@ -4862,8 +4863,8 @@ class Fu {
4862
4863
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new _n({
4863
4864
  persister: new e(this.config.appId, "kv"),
4864
4865
  merge: this._onMergeKv,
4865
- serialize: Uu,
4866
- parse: Du,
4866
+ serialize: Ua,
4867
+ parse: Da,
4867
4868
  objectSize: () => 0,
4868
4869
  logger: this._log,
4869
4870
  saveThrottleMs: 100,
@@ -4894,10 +4895,10 @@ class Fu {
4894
4895
  if (s)
4895
4896
  i.resolve({ status: e, eventId: n });
4896
4897
  else if (r != null && r.type) {
4897
- const { status: o } = r, a = Qi(r, ["status"]);
4898
+ const { status: o } = r, u = Qi(r, ["status"]);
4898
4899
  i.reject(new Dt({
4899
4900
  // @ts-expect-error body.type is not constant typed
4900
- body: a,
4901
+ body: u,
4901
4902
  status: o ?? 0
4902
4903
  }));
4903
4904
  } else
@@ -4911,12 +4912,12 @@ class Fu {
4911
4912
  const i = (r = (n = this._presence[e]) === null || n === void 0 ? void 0 : n.result) === null || r === void 0 ? void 0 : r.user, s = this._broadcastQueue[e];
4912
4913
  if (this._broadcastQueue[e] = [], i && this._trySetPresence(e, i), s)
4913
4914
  for (const o of s) {
4914
- const { topic: a, roomType: u, data: c } = o;
4915
- this._tryBroadcast(e, u, a, c);
4915
+ const { topic: u, roomType: a, data: c } = o;
4916
+ this._tryBroadcast(e, a, u, c);
4916
4917
  }
4917
4918
  }
4918
4919
  _handleReceive(e, n) {
4919
- var r, i, s, o, a, u;
4920
+ var r, i, s, o, u, a;
4920
4921
  const c = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4921
4922
  switch (Qr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4922
4923
  case "init-ok": {
@@ -4935,15 +4936,15 @@ class Fu {
4935
4936
  const { q: l, result: p } = n, y = B(l);
4936
4937
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
4937
4938
  break;
4938
- const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (u = (a = p == null ? void 0 : p[0]) === null || a === void 0 ? void 0 : a.data) === null || u === void 0 ? void 0 : u.aggregate, T = Dr(p), g = Et(this.ensureAttrs(), T, c, this.config.useDateObjects);
4939
- this.querySubs.updateInPlace((m) => {
4940
- if (!m[y]) {
4939
+ const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, T = Dr(p), g = this.ensureAttrs(), m = Et(g, T, c, this.config.useDateObjects);
4940
+ this.querySubs.updateInPlace((O) => {
4941
+ if (!O[y]) {
4941
4942
  this._log.info("Missing value in querySubs", { hash: y, q: l });
4942
4943
  return;
4943
4944
  }
4944
- m[y].result = {
4945
- store: g,
4946
- attrsStore: this.ensureAttrs(),
4945
+ O[y].result = {
4946
+ store: m,
4947
+ attrsStore: g,
4947
4948
  pageInfo: b,
4948
4949
  aggregate: _,
4949
4950
  processedTxId: n["processed-tx-id"]
@@ -5096,7 +5097,7 @@ class Fu {
5096
5097
  }
5097
5098
  }
5098
5099
  _handleReceiveError(e) {
5099
- var n, r, i, s, o, a, u;
5100
+ var n, r, i, s, o, u, a;
5100
5101
  console.log("error", e);
5101
5102
  const c = e["client-event-id"];
5102
5103
  this._inFlightMutationEventIds.delete(c);
@@ -5120,11 +5121,11 @@ class Fu {
5120
5121
  this._setStatus(he.ERRORED, f), this.notifyAll();
5121
5122
  return;
5122
5123
  }
5123
- if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "resync-table") {
5124
+ if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "resync-table") {
5124
5125
  this._syncTable.onResyncError(e);
5125
5126
  return;
5126
5127
  }
5127
- if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "start-sync") {
5128
+ if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "start-sync") {
5128
5129
  this._syncTable.onStartSyncError(e);
5129
5130
  return;
5130
5131
  }
@@ -5134,7 +5135,7 @@ class Fu {
5134
5135
  }
5135
5136
  notifyQueryOnceError(e, n, r, i) {
5136
5137
  var s;
5137
- const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((a) => a.eventId === r);
5138
+ const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((u) => u.eventId === r);
5138
5139
  o && (o.dfd.reject(i), this._completeQueryOnce(e, n, o.dfd));
5139
5140
  }
5140
5141
  _setAttrs(e) {
@@ -5176,7 +5177,7 @@ class Fu {
5176
5177
  if (!this.querySubs)
5177
5178
  return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
5178
5179
  const s = B(e), o = this._startQuerySub(e, s);
5179
- return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), ju), i.promise;
5180
+ return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), ja), i.promise;
5180
5181
  }
5181
5182
  _completeQueryOnce(e, n, r) {
5182
5183
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5220,37 +5221,37 @@ class Fu {
5220
5221
  const [f, l, p] = d["forward-identity"];
5221
5222
  return Ie(e, l, p);
5222
5223
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
5223
- let a = !1;
5224
- const u = (d, f) => {
5224
+ let u = !1;
5225
+ const a = (d, f) => {
5225
5226
  const l = [];
5226
5227
  for (const p of d) {
5227
5228
  const [y] = p;
5228
5229
  if (y === "add-attr") {
5229
5230
  const [_, T] = p, g = i(T);
5230
5231
  if (g && T.id !== g.id) {
5231
- o.attrIdMap[T.id] = g.id, a = !0;
5232
+ o.attrIdMap[T.id] = g.id, u = !0;
5232
5233
  continue;
5233
5234
  }
5234
5235
  if (T["value-type"] === "ref") {
5235
5236
  const m = s(T);
5236
5237
  if (m) {
5237
- o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), a = !0;
5238
+ o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), u = !0;
5238
5239
  continue;
5239
5240
  }
5240
5241
  }
5241
5242
  }
5242
5243
  if (r && f && r >= f && y === "add-attr" || y === "update-attr" || y === "delete-attr") {
5243
- a = !0;
5244
+ u = !0;
5244
5245
  continue;
5245
5246
  }
5246
- const b = a ? ba(o, p) : p;
5247
+ const b = u ? bu(o, p) : p;
5247
5248
  l.push(b);
5248
5249
  }
5249
- return a ? l : d;
5250
+ return u ? l : d;
5250
5251
  }, c = /* @__PURE__ */ new Map();
5251
5252
  for (const [d, f] of n.entries())
5252
- c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": u(f["tx-steps"], f["tx-id"]) }));
5253
- return a ? c : n;
5253
+ c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": a(f["tx-steps"], f["tx-id"]) }));
5254
+ return u ? c : n;
5254
5255
  }
5255
5256
  _rewriteMutationsSorted(e, n) {
5256
5257
  return Hr(this._rewriteMutations(e, n).entries());
@@ -5262,21 +5263,21 @@ class Fu {
5262
5263
  */
5263
5264
  optimisticAttrs() {
5264
5265
  var e, n;
5265
- const r = [...this._pendingMutations().values()].flatMap((a) => a["tx-steps"]), i = new Set(r.filter(([a, u]) => a === "delete-attr").map(([a, u]) => u)), s = [];
5266
- for (const [a, u] of r)
5267
- if (a === "add-attr")
5268
- s.push(u);
5269
- else if (a === "update-attr" && u.id && (!((e = this.attrs) === null || e === void 0) && e.getAttr(u.id))) {
5270
- const c = Object.assign(Object.assign({}, this.attrs.getAttr(u.id)), u);
5266
+ const r = [...this._pendingMutations().values()].flatMap((u) => u["tx-steps"]), i = new Set(r.filter(([u, a]) => u === "delete-attr").map(([u, a]) => a)), s = [];
5267
+ for (const [u, a] of r)
5268
+ if (u === "add-attr")
5269
+ s.push(a);
5270
+ else if (u === "update-attr" && a.id && (!((e = this.attrs) === null || e === void 0) && e.getAttr(a.id))) {
5271
+ const c = Object.assign(Object.assign({}, this.attrs.getAttr(a.id)), a);
5271
5272
  s.push(c);
5272
5273
  }
5273
5274
  if (!i.size && !s.length)
5274
5275
  return this.attrs || new Ae({}, this._linkIndex);
5275
5276
  const o = Object.assign({}, ((n = this.attrs) === null || n === void 0 ? void 0 : n.attrs) || {});
5276
- for (const a of s)
5277
- o[a.id] = a;
5278
- for (const a of i)
5279
- delete o[a];
5277
+ for (const u of s)
5278
+ o[u.id] = u;
5279
+ for (const u of i)
5280
+ delete o[u];
5280
5281
  return new Ae(o, this._linkIndex);
5281
5282
  }
5282
5283
  /** Runs instaql on a query and a store */
@@ -5286,20 +5287,20 @@ class Fu {
5286
5287
  return { error: n };
5287
5288
  if (!this.querySubs || !this.kv.currentValue.pendingMutations)
5288
5289
  return;
5289
- const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: a, result: u } = i[e] || {};
5290
- if (!u)
5290
+ const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: u, result: a } = i[e] || {};
5291
+ if (!a)
5291
5292
  return;
5292
5293
  const c = this._dataForQueryCache[e];
5293
5294
  if (c && r === c.querySubVersion && s === c.pendingMutationsVersion)
5294
5295
  return c;
5295
- const { store: d, attrsStore: f, pageInfo: l, aggregate: p, processedTxId: y } = u, b = this._rewriteMutationsSorted(f, o), { store: _, attrsStore: T } = this._applyOptimisticUpdates(d, f, b, y);
5296
- return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p }, a), querySubVersion: r, pendingMutationsVersion: s };
5296
+ const { store: d, attrsStore: f, pageInfo: l, aggregate: p, processedTxId: y } = a, b = this._rewriteMutationsSorted(f, o), { store: _, attrsStore: T } = this._applyOptimisticUpdates(d, f, b, y);
5297
+ return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p }, u), querySubVersion: r, pendingMutationsVersion: s };
5297
5298
  }
5298
5299
  _applyOptimisticUpdates(e, n, r, i) {
5299
5300
  for (const [s, o] of r)
5300
5301
  if (!o["tx-id"] || i && o["tx-id"] > i) {
5301
- const a = _o(e, n, o["tx-steps"]);
5302
- e = a.store, n = a.attrsStore;
5302
+ const u = _o(e, n, o["tx-steps"]);
5303
+ e = u.store, n = u.attrsStore;
5303
5304
  }
5304
5305
  return { store: e, attrsStore: n };
5305
5306
  }
@@ -5409,7 +5410,7 @@ class Fu {
5409
5410
  return;
5410
5411
  }
5411
5412
  const e = this._transport;
5412
- this._transport = Mu({
5413
+ this._transport = Ma({
5413
5414
  transportType: this._transportType,
5414
5415
  appId: this.config.appId,
5415
5416
  apiURI: this.config.apiURI,
@@ -5455,8 +5456,8 @@ class Fu {
5455
5456
  typeof navigation.removeEventListener == "function") {
5456
5457
  let i = !1;
5457
5458
  const s = (o) => {
5458
- var a;
5459
- i || (i = !0, navigation.removeEventListener("navigate", s), !o.userInitiated && o.navigationType === "replace" && ((a = o.destination) === null || a === void 0 ? void 0 : a.url) === n && history.replaceState(history.state, "", r));
5459
+ var u;
5460
+ i || (i = !0, navigation.removeEventListener("navigate", s), !o.userInitiated && o.navigationType === "replace" && ((u = o.destination) === null || u === void 0 ? void 0 : u.url) === n && history.replaceState(history.state, "", r));
5460
5461
  };
5461
5462
  navigation.addEventListener("navigate", s);
5462
5463
  }
@@ -5477,20 +5478,20 @@ class Fu {
5477
5478
  const o = s.get("error");
5478
5479
  if (o)
5479
5480
  return this._replaceUrlAfterOAuth(), { error: { message: o } };
5480
- const a = s.get("code");
5481
- if (!a)
5481
+ const u = s.get("code");
5482
+ if (!u)
5482
5483
  return null;
5483
5484
  this._replaceUrlAfterOAuth();
5484
5485
  try {
5485
- const u = yield this._getCurrentUser(), c = (u == null ? void 0 : u.type) === "guest", { user: d } = yield Rr({
5486
+ const a = yield this._getCurrentUser(), c = (a == null ? void 0 : a.type) === "guest", { user: d } = yield Rr({
5486
5487
  apiURI: this.config.apiURI,
5487
5488
  appId: this.config.appId,
5488
- code: a,
5489
- refreshToken: c ? u.refresh_token : void 0
5489
+ code: u,
5490
+ refreshToken: c ? a.refresh_token : void 0
5490
5491
  });
5491
5492
  return this.setCurrentUser(d), null;
5492
- } catch (u) {
5493
- return ((e = u == null ? void 0 : u.body) === null || e === void 0 ? void 0 : e.type) === "record-not-found" && ((r = (n = u == null ? void 0 : u.body) === null || n === void 0 ? void 0 : n.hint) === null || r === void 0 ? void 0 : r["record-type"]) === "app-oauth-code" && (yield this._hasCurrentUser()) ? null : { error: { message: ((i = u == null ? void 0 : u.body) === null || i === void 0 ? void 0 : i.message) || "Error logging in." } };
5493
+ } catch (a) {
5494
+ return ((e = a == null ? void 0 : a.body) === null || e === void 0 ? void 0 : e.type) === "record-not-found" && ((r = (n = a == null ? void 0 : a.body) === null || n === void 0 ? void 0 : n.hint) === null || r === void 0 ? void 0 : r["record-type"]) === "app-oauth-code" && (yield this._hasCurrentUser()) ? null : { error: { message: ((i = a == null ? void 0 : a.body) === null || i === void 0 ? void 0 : i.message) || "Error logging in." } };
5494
5495
  }
5495
5496
  });
5496
5497
  }
@@ -5612,7 +5613,7 @@ class Fu {
5612
5613
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5613
5614
  }
5614
5615
  sendMagicCode({ email: e }) {
5615
- return Ja({
5616
+ return Ju({
5616
5617
  apiURI: this.config.apiURI,
5617
5618
  appId: this.config.appId,
5618
5619
  email: e
@@ -5621,19 +5622,19 @@ class Fu {
5621
5622
  signInWithMagicCode(e) {
5622
5623
  return N(this, arguments, void 0, function* ({ email: n, code: r }) {
5623
5624
  var i;
5624
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Za({
5625
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Zu({
5625
5626
  apiURI: this.config.apiURI,
5626
5627
  appId: this.config.appId,
5627
5628
  email: n,
5628
5629
  code: r,
5629
5630
  refreshToken: o ? s.user.refresh_token : void 0
5630
5631
  });
5631
- return yield this.changeCurrentUser(a.user), a;
5632
+ return yield this.changeCurrentUser(u.user), u;
5632
5633
  });
5633
5634
  }
5634
5635
  signInWithCustomToken(e) {
5635
5636
  return N(this, void 0, void 0, function* () {
5636
- const n = yield Xa({
5637
+ const n = yield Xu({
5637
5638
  apiURI: this.config.apiURI,
5638
5639
  appId: this.config.appId,
5639
5640
  refreshToken: e
@@ -5643,7 +5644,7 @@ class Fu {
5643
5644
  }
5644
5645
  signInAsGuest() {
5645
5646
  return N(this, void 0, void 0, function* () {
5646
- const e = yield eu({
5647
+ const e = yield ea({
5647
5648
  apiURI: this.config.apiURI,
5648
5649
  appId: this.config.appId
5649
5650
  });
@@ -5659,7 +5660,7 @@ class Fu {
5659
5660
  this._log.info("[auth-invalidate] skipped invalidateToken");
5660
5661
  return;
5661
5662
  }
5662
- nu({
5663
+ na({
5663
5664
  apiURI: this.config.apiURI,
5664
5665
  appId: this.config.appId,
5665
5666
  refreshToken: i
@@ -5694,14 +5695,14 @@ class Fu {
5694
5695
  exchangeCodeForToken(e) {
5695
5696
  return N(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
5696
5697
  var i;
5697
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Rr({
5698
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Rr({
5698
5699
  apiURI: this.config.apiURI,
5699
5700
  appId: this.config.appId,
5700
5701
  code: n,
5701
5702
  codeVerifier: r,
5702
5703
  refreshToken: o ? s.user.refresh_token : void 0
5703
5704
  });
5704
- return yield this.changeCurrentUser(a.user), a;
5705
+ return yield this.changeCurrentUser(u.user), u;
5705
5706
  });
5706
5707
  }
5707
5708
  issuerURI() {
@@ -5717,15 +5718,15 @@ class Fu {
5717
5718
  signInWithIdToken(e) {
5718
5719
  return N(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5719
5720
  var s;
5720
- const o = yield this.getCurrentUser(), a = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, u = yield tu({
5721
+ const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield ta({
5721
5722
  apiURI: this.config.apiURI,
5722
5723
  appId: this.config.appId,
5723
5724
  idToken: n,
5724
5725
  clientName: r,
5725
5726
  nonce: i,
5726
- refreshToken: a
5727
+ refreshToken: u
5727
5728
  });
5728
- return yield this.changeCurrentUser(u.user), u;
5729
+ return yield this.changeCurrentUser(a.user), a;
5729
5730
  });
5730
5731
  }
5731
5732
  // --------
@@ -5758,7 +5759,7 @@ class Fu {
5758
5759
  // TODO: look into typing again
5759
5760
  getPresence(e, n, r = {}) {
5760
5761
  const i = this._rooms[n], s = this._presence[n];
5761
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, uu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5762
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, aa(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5762
5763
  }
5763
5764
  // TODO: look into typing again
5764
5765
  publishPresence(e, n, r) {
@@ -5796,8 +5797,8 @@ class Fu {
5796
5797
  r.initialPresence || r.initialData
5797
5798
  ), o = Object.assign(Object.assign({}, r), { roomId: n, cb: i, prev: null });
5798
5799
  return this._presence[n] = this._presence[n] || {}, this._presence[n].handlers = this._presence[n].handlers || [], this._presence[n].handlers.push(o), this._notifyPresenceSub(n, o), () => {
5799
- var a, u, c;
5800
- this._presence[n].handlers = (c = (u = (a = this._presence[n]) === null || a === void 0 ? void 0 : a.handlers) === null || u === void 0 ? void 0 : u.filter((d) => d !== o)) !== null && c !== void 0 ? c : [], s();
5800
+ var u, a, c;
5801
+ this._presence[n].handlers = (c = (a = (u = this._presence[n]) === null || u === void 0 ? void 0 : u.handlers) === null || a === void 0 ? void 0 : a.filter((d) => d !== o)) !== null && c !== void 0 ? c : [], s();
5801
5802
  };
5802
5803
  }
5803
5804
  _notifyPresenceSubs(e) {
@@ -5808,14 +5809,14 @@ class Fu {
5808
5809
  }
5809
5810
  _notifyPresenceSub(e, n) {
5810
5811
  const r = this.getPresence("", e, n);
5811
- r && (n.prev && !cu(r, n.prev) || (n.prev = r, n.cb(r)));
5812
+ r && (n.prev && !ca(r, n.prev) || (n.prev = r, n.cb(r)));
5812
5813
  }
5813
5814
  _patchPresencePeers(e, n) {
5814
5815
  var r, i, s;
5815
5816
  const o = ((i = (r = this._presence[e]) === null || r === void 0 ? void 0 : r.result) === null || i === void 0 ? void 0 : i.peers) || {};
5816
- let a = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
5817
+ let u = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
5817
5818
  (s = this._presence[e]) === null || s === void 0 || s.result;
5818
- const u = It(a, (c) => {
5819
+ const a = It(u, (c) => {
5819
5820
  for (let [d, f, l] of n)
5820
5821
  switch (f) {
5821
5822
  case "+":
@@ -5830,7 +5831,7 @@ class Fu {
5830
5831
  }
5831
5832
  delete c[this._sessionId];
5832
5833
  });
5833
- this._setPresencePeers(e, u);
5834
+ this._setPresencePeers(e, a);
5834
5835
  }
5835
5836
  _setPresencePeers(e, n) {
5836
5837
  const r = Object.assign({}, n);
@@ -5870,10 +5871,10 @@ class Fu {
5870
5871
  }
5871
5872
  _notifyBroadcastSubs(e, n, r) {
5872
5873
  var i, s, o;
5873
- (o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((a) => {
5874
- var u, c, d, f, l, p;
5875
- const y = (u = r.data) === null || u === void 0 ? void 0 : u.data, b = r.data["peer-id"] === this._sessionId ? (d = (c = this._presence[e]) === null || c === void 0 ? void 0 : c.result) === null || d === void 0 ? void 0 : d.user : (p = (l = (f = this._presence[e]) === null || f === void 0 ? void 0 : f.result) === null || l === void 0 ? void 0 : l.peers) === null || p === void 0 ? void 0 : p[r.data["peer-id"]];
5876
- return a(y, b);
5874
+ (o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((u) => {
5875
+ var a, c, d, f, l, p;
5876
+ const y = (a = r.data) === null || a === void 0 ? void 0 : a.data, b = r.data["peer-id"] === this._sessionId ? (d = (c = this._presence[e]) === null || c === void 0 ? void 0 : c.result) === null || d === void 0 ? void 0 : d.user : (p = (l = (f = this._presence[e]) === null || f === void 0 ? void 0 : f.result) === null || l === void 0 ? void 0 : l.peers) === null || p === void 0 ? void 0 : p[r.data["peer-id"]];
5877
+ return u(y, b);
5877
5878
  });
5878
5879
  }
5879
5880
  // --------
@@ -5882,14 +5883,14 @@ class Fu {
5882
5883
  return N(this, void 0, void 0, function* () {
5883
5884
  var i;
5884
5885
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5885
- return ru(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5886
+ return ra(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5886
5887
  });
5887
5888
  }
5888
5889
  deleteFile(e) {
5889
5890
  return N(this, void 0, void 0, function* () {
5890
5891
  var n;
5891
5892
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5892
- return yield iu({
5893
+ return yield ia({
5893
5894
  apiURI: this.config.apiURI,
5894
5895
  appId: this.config.appId,
5895
5896
  path: e,
@@ -5902,20 +5903,20 @@ class Fu {
5902
5903
  upload(e, n) {
5903
5904
  return N(this, void 0, void 0, function* () {
5904
5905
  var r;
5905
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, a = yield su({
5906
+ const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield sa({
5906
5907
  apiURI: this.config.apiURI,
5907
5908
  appId: this.config.appId,
5908
5909
  fileName: o,
5909
5910
  refreshToken: s
5910
5911
  });
5911
- return yield ou(a, n);
5912
+ return yield oa(u, n);
5912
5913
  });
5913
5914
  }
5914
5915
  getDownloadUrl(e) {
5915
5916
  return N(this, void 0, void 0, function* () {
5916
5917
  var n;
5917
5918
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5918
- return yield au({
5919
+ return yield ua({
5919
5920
  apiURI: this.config.apiURI,
5920
5921
  appId: this.config.appId,
5921
5922
  path: e,
@@ -5924,7 +5925,7 @@ class Fu {
5924
5925
  });
5925
5926
  }
5926
5927
  }
5927
- function Nu(t, e) {
5928
+ function Na(t, e) {
5928
5929
  return new Lt(
5929
5930
  Hi(t, e),
5930
5931
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -5936,44 +5937,44 @@ function Nu(t, e) {
5936
5937
  void 0
5937
5938
  );
5938
5939
  }
5939
- function Ku(t) {
5940
+ function Ka(t) {
5940
5941
  return new Ut(t, {});
5941
5942
  }
5942
- function qu() {
5943
+ function qa() {
5943
5944
  return new H("string", !0, !1);
5944
5945
  }
5945
- function Wu() {
5946
+ function Wa() {
5946
5947
  return new H("number", !0, !1);
5947
5948
  }
5948
- function zu() {
5949
+ function za() {
5949
5950
  return new H("boolean", !0, !1);
5950
5951
  }
5951
- function Vu() {
5952
+ function Va() {
5952
5953
  return new H("date", !0, !1);
5953
5954
  }
5954
- function Bu() {
5955
+ function Ba() {
5955
5956
  return new H("json", !0, !1);
5956
5957
  }
5957
- function Gu() {
5958
+ function Ga() {
5958
5959
  return new H("json", !0, !1);
5959
5960
  }
5960
5961
  function Hi(t, e) {
5961
5962
  var n, r, i, s;
5962
5963
  const o = { fwd: {}, rev: {} };
5963
- for (const u of Object.values(e))
5964
- (n = o.fwd)[r = u.forward.on] || (n[r] = {}), (i = o.rev)[s = u.reverse.on] || (i[s] = {}), o.fwd[u.forward.on][u.forward.label] = {
5965
- entityName: u.reverse.on,
5966
- cardinality: u.forward.has
5967
- }, o.rev[u.reverse.on][u.reverse.label] = {
5968
- entityName: u.forward.on,
5969
- cardinality: u.reverse.has
5964
+ for (const a of Object.values(e))
5965
+ (n = o.fwd)[r = a.forward.on] || (n[r] = {}), (i = o.rev)[s = a.reverse.on] || (i[s] = {}), o.fwd[a.forward.on][a.forward.label] = {
5966
+ entityName: a.reverse.on,
5967
+ cardinality: a.forward.has
5968
+ }, o.rev[a.reverse.on][a.reverse.label] = {
5969
+ entityName: a.forward.on,
5970
+ cardinality: a.reverse.has
5970
5971
  };
5971
- return Object.fromEntries(Object.entries(t).map(([u, c]) => [
5972
- u,
5973
- new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[u]), o.rev[u]))
5972
+ return Object.fromEntries(Object.entries(t).map(([a, c]) => [
5973
+ a,
5974
+ new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
5974
5975
  ]));
5975
5976
  }
5976
- function Qu({ entities: t, links: e, rooms: n }) {
5977
+ function Qa({ entities: t, links: e, rooms: n }) {
5977
5978
  const r = e ?? {}, i = n ?? {};
5978
5979
  return new Lt(
5979
5980
  Hi(t, r),
@@ -5988,46 +5989,46 @@ function Qu({ entities: t, links: e, rooms: n }) {
5988
5989
  }
5989
5990
  const Fc = {
5990
5991
  // constructs
5991
- graph: Nu,
5992
- schema: Qu,
5993
- entity: Ku,
5992
+ graph: Na,
5993
+ schema: Qa,
5994
+ entity: Ka,
5994
5995
  // value types
5995
- string: qu,
5996
- number: Wu,
5997
- boolean: zu,
5998
- date: Vu,
5999
- json: Bu,
6000
- any: Gu
5996
+ string: qa,
5997
+ number: Wa,
5998
+ boolean: za,
5999
+ date: Va,
6000
+ json: Ba,
6001
+ any: Ga
6001
6002
  };
6002
6003
  let mt;
6003
- function Hu(t, e) {
6004
+ function Ha(t, e) {
6004
6005
  mt == null || mt.dispose();
6005
- const n = tc(e), r = Zu(e, a), i = Ju(Yu(t));
6006
+ const n = tc(e), r = Za(e, u), i = Ja(Ya(t));
6006
6007
  function s(d) {
6007
6008
  var f;
6008
- d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && a();
6009
+ d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
6009
6010
  }
6010
6011
  function o(d) {
6011
6012
  const f = d.shiftKey && d.ctrlKey && d.key === "0", l = d.key === "Escape" || d.key === "Esc";
6012
- (f || l && n.isVisible()) && a();
6013
+ (f || l && n.isVisible()) && u();
6013
6014
  }
6014
- function a() {
6015
+ function u() {
6015
6016
  n.isVisible() ? n.element.style.display = "none" : (n.element.style.display = "block", n.element.contains(i.element) || n.element.appendChild(i.element));
6016
6017
  }
6017
- function u() {
6018
+ function a() {
6018
6019
  n.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", s);
6019
6020
  }
6020
6021
  function c() {
6021
6022
  document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), mt = {
6022
- dispose: u
6023
+ dispose: a
6023
6024
  };
6024
6025
  }
6025
6026
  return c();
6026
6027
  }
6027
- function Yu(t) {
6028
+ function Ya(t) {
6028
6029
  return `${qn || Ni ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6029
6030
  }
6030
- function Ju(t) {
6031
+ function Ja(t) {
6031
6032
  const e = document.createElement("iframe");
6032
6033
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6033
6034
  width: "100%",
@@ -6036,7 +6037,7 @@ function Ju(t) {
6036
6037
  border: "none"
6037
6038
  }), { element: e };
6038
6039
  }
6039
- function Zu(t, e) {
6040
+ function Za(t, e) {
6040
6041
  const n = `
6041
6042
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6042
6043
  <rect width="512" height="512" fill="black"/>
@@ -6046,7 +6047,7 @@ function Zu(t, e) {
6046
6047
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6047
6048
  // pos
6048
6049
  position: "fixed"
6049
- }, Xu(t.position)), {
6050
+ }, Xa(t.position)), {
6050
6051
  height: "32px",
6051
6052
  width: "32px",
6052
6053
  // layout
@@ -6061,7 +6062,7 @@ function Zu(t, e) {
6061
6062
  cursor: "pointer"
6062
6063
  })), r.addEventListener("click", e), { element: r };
6063
6064
  }
6064
- function Xu(t) {
6065
+ function Xa(t) {
6065
6066
  switch (t) {
6066
6067
  case "bottom-left":
6067
6068
  return { bottom: "24px", left: "24px" };
@@ -6120,10 +6121,10 @@ class oc {
6120
6121
  this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), 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);
6121
6122
  }
6122
6123
  }
6123
- function ac(t) {
6124
+ function uc(t) {
6124
6125
  return JSON.parse(JSON.stringify(t));
6125
6126
  }
6126
- class uc {
6127
+ class ac {
6127
6128
  constructor(e) {
6128
6129
  this.tx = Kn(), this._reactor = e, this.auth = new sc(this._reactor), this.storage = new oc(this._reactor);
6129
6130
  }
@@ -6313,17 +6314,17 @@ function cc(t, e) {
6313
6314
  }
6314
6315
  function dc(t, e, n, r, i) {
6315
6316
  var s;
6316
- const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), a = wn[gn(o)];
6317
- if (a)
6318
- return cc(a, o.schema) && a._reactor.updateSchema(o.schema), a;
6319
- const u = new Fu(Object.assign(Object.assign(Object.assign({}, nc), o), { cardinalityInference: !!o.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new uc(u);
6317
+ const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = wn[gn(o)];
6318
+ if (u)
6319
+ return cc(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6320
+ const a = new Fa(Object.assign(Object.assign(Object.assign({}, nc), o), { cardinalityInference: !!o.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new ac(a);
6320
6321
  return wn[gn(o)] = c, fc(o.appId, o.devtool), c;
6321
6322
  }
6322
6323
  function fc(t, e) {
6323
6324
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6324
6325
  return;
6325
6326
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6326
- n.allowedHosts.includes(window.location.hostname) && Hu(t, n);
6327
+ n.allowedHosts.includes(window.location.hostname) && Ha(t, n);
6327
6328
  }
6328
6329
  var Tn = { exports: {} }, Qe = {};
6329
6330
  /**
@@ -6340,12 +6341,12 @@ function lc() {
6340
6341
  if (Zr) return Qe;
6341
6342
  Zr = 1;
6342
6343
  var t = oi, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
6343
- function o(a, u, c) {
6344
+ function o(u, a, c) {
6344
6345
  var d, f = {}, l = null, p = null;
6345
- c !== void 0 && (l = "" + c), u.key !== void 0 && (l = "" + u.key), u.ref !== void 0 && (p = u.ref);
6346
- for (d in u) r.call(u, d) && !s.hasOwnProperty(d) && (f[d] = u[d]);
6347
- if (a && a.defaultProps) for (d in u = a.defaultProps, u) f[d] === void 0 && (f[d] = u[d]);
6348
- return { $$typeof: e, type: a, key: l, ref: p, props: f, _owner: i.current };
6346
+ c !== void 0 && (l = "" + c), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
6347
+ for (d in a) r.call(a, d) && !s.hasOwnProperty(d) && (f[d] = a[d]);
6348
+ if (u && u.defaultProps) for (d in a = u.defaultProps, a) f[d] === void 0 && (f[d] = a[d]);
6349
+ return { $$typeof: e, type: u, key: l, ref: p, props: f, _owner: i.current };
6349
6350
  }
6350
6351
  return Qe.Fragment = n, Qe.jsx = o, Qe.jsxs = o, Qe;
6351
6352
  }
@@ -6364,7 +6365,7 @@ function hc() {
6364
6365
  * LICENSE file in the root directory of this source tree.
6365
6366
  */
6366
6367
  return t.NODE_ENV !== "production" && function() {
6367
- var e = oi, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
6368
+ var e = oi, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
6368
6369
  function T(h) {
6369
6370
  if (h === null || typeof h != "object")
6370
6371
  return null;
@@ -6392,7 +6393,7 @@ function hc() {
6392
6393
  var S = !1, C = !1, $ = !1, D = !1, Ve = !1, ft;
6393
6394
  ft = Symbol.for("react.module.reference");
6394
6395
  function lt(h) {
6395
- return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h === d || h === f || D || h === y || S || C || $ || typeof h == "object" && h !== null && (h.$$typeof === p || h.$$typeof === l || h.$$typeof === a || h.$$typeof === u || h.$$typeof === c || // This needs to include all possible module reference object
6396
+ return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h === d || h === f || D || h === y || S || C || $ || typeof h == "object" && h !== null && (h.$$typeof === p || h.$$typeof === l || h.$$typeof === u || h.$$typeof === a || h.$$typeof === c || // This needs to include all possible module reference object
6396
6397
  // types supported by any Flight configuration anywhere since
6397
6398
  // we don't know which Flight build this will end up being used
6398
6399
  // with.
@@ -6431,10 +6432,10 @@ function hc() {
6431
6432
  }
6432
6433
  if (typeof h == "object")
6433
6434
  switch (h.$$typeof) {
6434
- case u:
6435
+ case a:
6435
6436
  var w = h;
6436
6437
  return ht(w) + ".Consumer";
6437
- case a:
6438
+ case u:
6438
6439
  var v = h;
6439
6440
  return ht(v._context) + ".Provider";
6440
6441
  case c:
@@ -6697,8 +6698,8 @@ function hc() {
6697
6698
  ref: !0,
6698
6699
  __self: !0,
6699
6700
  __source: !0
6700
- }, or, ar;
6701
- function as(h) {
6701
+ }, or, ur;
6702
+ function us(h) {
6702
6703
  if (Be.call(h, "ref")) {
6703
6704
  var w = Object.getOwnPropertyDescriptor(h, "ref").get;
6704
6705
  if (w && w.isReactWarning)
@@ -6706,7 +6707,7 @@ function hc() {
6706
6707
  }
6707
6708
  return h.ref !== void 0;
6708
6709
  }
6709
- function us(h) {
6710
+ function as(h) {
6710
6711
  if (Be.call(h, "key")) {
6711
6712
  var w = Object.getOwnPropertyDescriptor(h, "key").get;
6712
6713
  if (w && w.isReactWarning)
@@ -6731,7 +6732,7 @@ function hc() {
6731
6732
  function fs(h, w) {
6732
6733
  {
6733
6734
  var v = function() {
6734
- ar || (ar = !0, m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", w));
6735
+ ur || (ur = !0, m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", w));
6735
6736
  };
6736
6737
  v.isReactWarning = !0, Object.defineProperty(h, "ref", {
6737
6738
  get: v,
@@ -6771,7 +6772,7 @@ function hc() {
6771
6772
  function hs(h, w, v, E, P) {
6772
6773
  {
6773
6774
  var M, I = {}, k = null, G = null;
6774
- v !== void 0 && (ir(v), k = "" + v), us(w) && (ir(w.key), k = "" + w.key), as(w) && (G = w.ref, cs(w, P));
6775
+ v !== void 0 && (ir(v), k = "" + v), as(w) && (ir(w.key), k = "" + w.key), us(w) && (G = w.ref, cs(w, P));
6775
6776
  for (M in w)
6776
6777
  Be.call(w, M) && !os.hasOwnProperty(M) && (I[M] = w[M]);
6777
6778
  if (h && h.defaultProps) {
@@ -6786,13 +6787,13 @@ function hc() {
6786
6787
  return ls(h, k, G, P, E, sr.current, I);
6787
6788
  }
6788
6789
  }
6789
- var zt = g.ReactCurrentOwner, ur = g.ReactDebugCurrentFrame;
6790
+ var zt = g.ReactCurrentOwner, ar = g.ReactDebugCurrentFrame;
6790
6791
  function Pe(h) {
6791
6792
  if (h) {
6792
6793
  var w = h._owner, v = bt(h.type, h._source, w ? w.type : null);
6793
- ur.setExtraStackFrame(v);
6794
+ ar.setExtraStackFrame(v);
6794
6795
  } else
6795
- ur.setExtraStackFrame(null);
6796
+ ar.setExtraStackFrame(null);
6796
6797
  }
6797
6798
  var Vt;
6798
6799
  Vt = !1;
@@ -6965,8 +6966,8 @@ function ei(t) {
6965
6966
  }
6966
6967
  function bc(t, e, n) {
6967
6968
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6968
- const r = e ? ac(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
6969
- (u) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
6969
+ const r = e ? uc(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
6970
+ (a) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
6970
6971
  s.current = Object.assign({
6971
6972
  isLoading: !d,
6972
6973
  // @ts-expect-error: ts thinks this will always be overwritten
@@ -6975,7 +6976,7 @@ function bc(t, e, n) {
6975
6976
  pageInfo: void 0,
6976
6977
  // @ts-expect-error: ts thinks this will always be overwritten
6977
6978
  error: void 0
6978
- }, d), u();
6979
+ }, d), a();
6979
6980
  }) : () => {
6980
6981
  }),
6981
6982
  // Build a new subscribe function if the query changes
@@ -7015,9 +7016,9 @@ function Tc(t, e) {
7015
7016
  }
7016
7017
  function mc(t, e = {}) {
7017
7018
  var n, r;
7018
- const [i, s] = ai(() => {
7019
- var u;
7020
- return (u = t.core._reactor.getPresence(t.type, t.id, e)) !== null && u !== void 0 ? u : {
7019
+ const [i, s] = ui(() => {
7020
+ var a;
7021
+ return (a = t.core._reactor.getPresence(t.type, t.id, e)) !== null && a !== void 0 ? a : {
7021
7022
  peers: {},
7022
7023
  isLoading: !0
7023
7024
  };
@@ -7025,8 +7026,8 @@ function mc(t, e = {}) {
7025
7026
  ke(() => t.core._reactor.subscribePresence(t.type, t.id, e, (c) => {
7026
7027
  s(c);
7027
7028
  }), [t.id, e.user, (n = e.peers) === null || n === void 0 ? void 0 : n.join(), (r = e.keys) === null || r === void 0 ? void 0 : r.join()]);
7028
- const o = we((u) => {
7029
- t.core._reactor.publishPresence(t.type, t.id, u);
7029
+ const o = we((a) => {
7030
+ t.core._reactor.publishPresence(t.type, t.id, a);
7030
7031
  }, [t.type, t.id]);
7031
7032
  return tn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
7032
7033
  }
@@ -7049,12 +7050,12 @@ function Sc(t, e, n = {}) {
7049
7050
  [e]: null
7050
7051
  });
7051
7052
  }));
7052
- }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), a = we((d) => {
7053
+ }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), u = we((d) => {
7053
7054
  const l = !((n == null ? void 0 : n.stopOnEnter) && d.key === "Enter");
7054
7055
  o(l);
7055
- }, [n.stopOnEnter, o]), u = we(() => {
7056
+ }, [n.stopOnEnter, o]), a = we(() => {
7056
7057
  o(!1);
7057
- }, [o]), c = tn(() => ({ onKeyDown: a, onBlur: u }), [a, u]);
7058
+ }, [o]), c = tn(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
7058
7059
  return {
7059
7060
  active: s,
7060
7061
  setActive: o,
@@ -7082,14 +7083,14 @@ var Ec = function(t, e, n, r) {
7082
7083
  });
7083
7084
  }
7084
7085
  return new (n || (n = Promise))(function(s, o) {
7085
- function a(d) {
7086
+ function u(d) {
7086
7087
  try {
7087
7088
  c(r.next(d));
7088
7089
  } catch (f) {
7089
7090
  o(f);
7090
7091
  }
7091
7092
  }
7092
- function u(d) {
7093
+ function a(d) {
7093
7094
  try {
7094
7095
  c(r.throw(d));
7095
7096
  } catch (f) {
@@ -7097,7 +7098,7 @@ var Ec = function(t, e, n, r) {
7097
7098
  }
7098
7099
  }
7099
7100
  function c(d) {
7100
- d.done ? s(d.value) : i(d.value).then(a, u);
7101
+ d.done ? s(d.value) : i(d.value).then(u, a);
7101
7102
  }
7102
7103
  c((r = r.apply(t, e || [])).next());
7103
7104
  });
@@ -7110,16 +7111,16 @@ const Ac = {
7110
7111
  class kc {
7111
7112
  constructor(e, n) {
7112
7113
  this.tx = Kn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
7113
- const [i, s] = ai(null);
7114
+ const [i, s] = ui(null);
7114
7115
  return ke(() => {
7115
7116
  Ec(this, void 0, void 0, function* () {
7116
- const a = yield this.getLocalId(r);
7117
- s(a);
7117
+ const u = yield this.getLocalId(r);
7118
+ s(u);
7118
7119
  });
7119
7120
  }, [r]), i;
7120
7121
  }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => bc(this.core, r, i).state, this.useAuth = () => {
7121
- const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((u) => {
7122
- r.current = Object.assign({ isLoading: !1 }, u), o();
7122
+ const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((a) => {
7123
+ r.current = Object.assign({ isLoading: !1 }, a), o();
7123
7124
  }), []);
7124
7125
  return en(i, () => r.current, () => Ac);
7125
7126
  }, this.useUser = () => {
@@ -7128,8 +7129,8 @@ class kc {
7128
7129
  throw new qe("useUser must be used within an auth-protected route");
7129
7130
  return r;
7130
7131
  }, this.useConnectionStatus = () => {
7131
- const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((u) => {
7132
- u !== r.current && (r.current = u, o());
7132
+ const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((a) => {
7133
+ a !== r.current && (r.current = a, o());
7133
7134
  }), []);
7134
7135
  return en(
7135
7136
  i,
@@ -7196,7 +7197,7 @@ function jc(t) {
7196
7197
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
7197
7198
  );
7198
7199
  const { onEvent: e = Xt, onError: n = Xt, onRetry: r = Xt, onComment: i } = t;
7199
- let s = "", o = !0, a, u = "", c = "";
7200
+ let s = "", o = !0, u, a = "", c = "";
7200
7201
  function d(b) {
7201
7202
  const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Cc(`${s}${_}`);
7202
7203
  for (const m of T)
@@ -7226,11 +7227,11 @@ function jc(t) {
7226
7227
  c = _;
7227
7228
  break;
7228
7229
  case "data":
7229
- u = `${u}${_}
7230
+ a = `${a}${_}
7230
7231
  `;
7231
7232
  break;
7232
7233
  case "id":
7233
- a = _.includes("\0") ? void 0 : _;
7234
+ u = _.includes("\0") ? void 0 : _;
7234
7235
  break;
7235
7236
  case "retry":
7236
7237
  /^\d+$/.test(_) ? r(parseInt(_, 10)) : n(
@@ -7252,17 +7253,17 @@ function jc(t) {
7252
7253
  }
7253
7254
  }
7254
7255
  function p() {
7255
- u.length > 0 && e({
7256
- id: a,
7256
+ a.length > 0 && e({
7257
+ id: u,
7257
7258
  event: c || void 0,
7258
7259
  // If the data buffer's last character is a U+000A LINE FEED (LF) character,
7259
7260
  // then remove the last character from the data buffer.
7260
- data: u.endsWith(`
7261
- `) ? u.slice(0, -1) : u
7262
- }), a = void 0, u = "", c = "";
7261
+ data: a.endsWith(`
7262
+ `) ? a.slice(0, -1) : a
7263
+ }), u = void 0, a = "", c = "";
7263
7264
  }
7264
7265
  function y(b = {}) {
7265
- s && b.consume && f(s), o = !0, a = void 0, u = "", c = "", s = "";
7266
+ s && b.consume && f(s), o = !0, u = void 0, a = "", c = "", s = "";
7266
7267
  }
7267
7268
  return { feed: d, reset: y };
7268
7269
  }
@@ -7277,8 +7278,8 @@ function Cc(t) {
7277
7278
  n = t.slice(r);
7278
7279
  break;
7279
7280
  } else {
7280
- const a = t.slice(r, o);
7281
- e.push(a), r = o + 1, t[r - 1] === "\r" && t[r] === `
7281
+ const u = t.slice(r, o);
7282
+ e.push(u), r = o + 1, t[r - 1] === "\r" && t[r] === `
7282
7283
  ` && r++;
7283
7284
  }
7284
7285
  }
@@ -7352,12 +7353,12 @@ class kt extends EventTarget {
7352
7353
  super(), q(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, q(this, J), q(this, Oe), q(this, xe), q(this, At), q(this, Rt), q(this, it), q(this, Ue), q(this, st, null), q(this, ge), q(this, $e), q(this, Fe, null), q(this, De, null), q(this, Xe, null), q(this, Sn, async (s) => {
7353
7354
  var o;
7354
7355
  A(this, $e).reset();
7355
- const { body: a, redirected: u, status: c, headers: d } = s;
7356
+ const { body: u, redirected: a, status: c, headers: d } = s;
7356
7357
  if (c === 204) {
7357
7358
  pe(this, se, et).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
7358
7359
  return;
7359
7360
  }
7360
- if (u ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), c !== 200) {
7361
+ if (a ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), c !== 200) {
7361
7362
  pe(this, se, et).call(this, `Non-200 status code (${c})`, c);
7362
7363
  return;
7363
7364
  }
@@ -7369,11 +7370,11 @@ class kt extends EventTarget {
7369
7370
  return;
7370
7371
  x(this, J, this.OPEN);
7371
7372
  const f = new Event("open");
7372
- if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
7373
+ if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof u != "object" || !u || !("getReader" in u)) {
7373
7374
  pe(this, se, et).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
7374
7375
  return;
7375
7376
  }
7376
- const l = new TextDecoder(), p = a.getReader();
7377
+ const l = new TextDecoder(), p = u.getReader();
7377
7378
  let y = !0;
7378
7379
  do {
7379
7380
  const { done: b, value: _ } = await p.read();
@@ -7573,8 +7574,8 @@ function Kc({
7573
7574
  style: i,
7574
7575
  userCursorColor: s,
7575
7576
  children: o,
7576
- renderCursor: a,
7577
- propagate: u,
7577
+ renderCursor: u,
7578
+ propagate: a,
7578
7579
  zIndex: c
7579
7580
  }) {
7580
7581
  const d = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
@@ -7593,7 +7594,7 @@ function Kc({
7593
7594
  });
7594
7595
  }
7595
7596
  function y(g) {
7596
- u || g.stopPropagation();
7597
+ a || g.stopPropagation();
7597
7598
  const m = g.currentTarget.getBoundingClientRect();
7598
7599
  p(m, g);
7599
7600
  }
@@ -7607,7 +7608,7 @@ function Kc({
7607
7608
  return;
7608
7609
  const m = g.touches[0];
7609
7610
  if (m.target instanceof Element) {
7610
- u || g.stopPropagation();
7611
+ a || g.stopPropagation();
7611
7612
  const O = m.target.getBoundingClientRect();
7612
7613
  p(O, m);
7613
7614
  }
@@ -7651,7 +7652,7 @@ function Kc({
7651
7652
  transformOrigin: "0 0",
7652
7653
  transition: "transform 100ms"
7653
7654
  },
7654
- children: a ? a({
7655
+ children: u ? u({
7655
7656
  color: O.color,
7656
7657
  presence: l == null ? void 0 : l.peers[g]
7657
7658
  }) : /* @__PURE__ */ V.jsx(Rc, { ...O })