@instantdb/react 0.22.89-experimental.split-store.20276199573.1 → 0.22.89-experimental.uuidfix.20281951052.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 = {};
@@ -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,7 +112,7 @@ 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) {
@@ -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,7 +446,7 @@ 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() {
@@ -457,7 +457,7 @@ const jt = (t, e, n = !1) => {
457
457
  },
458
458
  set(t, e) {
459
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;
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))
@@ -483,7 +483,7 @@ const jt = (t, e, n = !1) => {
483
483
  get(t) {
484
484
  var e, n;
485
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))
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,
@@ -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 = te(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;
@@ -704,8 +704,8 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
704
704
  const s = yr(te(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(te(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
711
  return e in te(t);
@@ -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;
@@ -1427,21 +1427,21 @@ function Z(t, e, n) {
1427
1427
  const i = e.length - 1;
1428
1428
  for (let s = 0; s < i; s++) {
1429
1429
  const o = e[s];
1430
- let a = r.get(o);
1431
- a === void 0 && (a = /* @__PURE__ */ new Map(), r.set(o, a)), r = a;
1430
+ let u = r.get(o);
1431
+ u === void 0 && (u = /* @__PURE__ */ new Map(), r.set(o, u)), r = u;
1432
1432
  }
1433
1433
  i > -1 && r.set(e[i], n);
1434
1434
  }
1435
1435
  function gi(t, e, n) {
1436
1436
  const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1437
1437
  for (const o of e) {
1438
- let [a, u, c] = o;
1439
- const d = t.getAttr(u);
1438
+ let [u, a, c] = o;
1439
+ const d = t.getAttr(a);
1440
1440
  if (!d) {
1441
- console.warn("no such attr", u, a);
1441
+ console.warn("no such attr", a, u);
1442
1442
  continue;
1443
1443
  }
1444
- 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) && Z(s, [c, a, u], o), Z(r, [u, a, c], o), Z(i, [a, u, c], o);
1445
1445
  }
1446
1446
  return { eav: r, aev: i, vae: s };
1447
1447
  }
@@ -1473,65 +1473,65 @@ function ct(t, e) {
1473
1473
  var n, r;
1474
1474
  let i;
1475
1475
  if (Array.isArray(e[0])) {
1476
- const [o, a] = e[0], u = t.aev.get(o);
1477
- if (!u)
1476
+ const [o, u] = e[0], a = t.aev.get(o);
1477
+ if (!a)
1478
1478
  return null;
1479
- i = (n = X(u, 2).find((d) => d[2] === a)) === null || n === void 0 ? void 0 : n[0];
1479
+ i = (n = X(a, 2).find((d) => d[2] === u)) === null || n === void 0 ? void 0 : n[0];
1480
1480
  } else
1481
1481
  i = e[0];
1482
1482
  if (!i)
1483
1483
  return null;
1484
1484
  const s = e[2];
1485
1485
  if (Array.isArray(s) && s.length === 2 && t.aev.get(s[0])) {
1486
- const [o, a] = s, u = t.aev.get(o);
1487
- if (!u)
1486
+ const [o, u] = s, a = t.aev.get(o);
1487
+ if (!a)
1488
1488
  return null;
1489
- const d = (r = X(u, 2).find((b) => b[2] === a)) === null || r === void 0 ? void 0 : r[0];
1489
+ const d = (r = X(a, 2).find((b) => b[2] === u)) === null || r === void 0 ? void 0 : r[0];
1490
1490
  if (!d)
1491
1491
  return null;
1492
1492
  const [f, l, p, ...y] = e;
1493
1493
  return [i, l, d, ...y];
1494
1494
  } else {
1495
- const [o, ...a] = e;
1496
- return [i, ...a];
1495
+ const [o, ...u] = e;
1496
+ return [i, ...u];
1497
1497
  }
1498
1498
  }
1499
1499
  function vi(t, e, n) {
1500
1500
  const r = ct(t, n);
1501
1501
  if (!r)
1502
1502
  return;
1503
- const [i, s, o] = r, a = e.getAttr(s);
1504
- 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]));
1505
1505
  }
1506
1506
  let so = 0;
1507
1507
  function Si(t, e, n) {
1508
1508
  const [r, i, s] = n;
1509
1509
  let o;
1510
- const a = We(t.eav, [r, i, s]);
1511
- 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++;
1512
1512
  }
1513
1513
  function Oi(t, e, n) {
1514
1514
  var r;
1515
1515
  const i = ct(t, n);
1516
1516
  if (!i)
1517
1517
  return;
1518
- let [s, o, a] = i;
1519
- const u = e.getAttr(o);
1520
- if (!u)
1518
+ let [s, o, u] = i;
1519
+ const a = e.getAttr(o);
1520
+ if (!a)
1521
1521
  return;
1522
- u["checked-data-type"] === "date" && t.useDateObjects && (a = xt(a));
1523
- 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];
1524
- 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) ? (Z(t.eav, [s, o], /* @__PURE__ */ new Map([[u, f]])), Z(t.aev, [o, s], /* @__PURE__ */ new Map([[u, f]]))) : (Z(t.eav, [s, o, u], f), Z(t.aev, [o, s, u], f)), Ln(a) && Z(t.vae, [u, o, s], f);
1525
1525
  }
1526
1526
  function oo(t, e, n) {
1527
1527
  var r;
1528
1528
  const i = ct(t, n);
1529
1529
  if (!i)
1530
1530
  return;
1531
- const [s, o, a] = i, u = e.getAttr(o);
1532
- if (!u)
1531
+ const [s, o, u] = i, a = e.getAttr(o);
1532
+ if (!a)
1533
1533
  return;
1534
- if (!Fn(u))
1534
+ if (!Fn(a))
1535
1535
  throw new Error("merge operation is not supported for links");
1536
1536
  const c = We(t.eav, [s, o]);
1537
1537
  if (!c)
@@ -1539,20 +1539,20 @@ function oo(t, e, n) {
1539
1539
  const d = (r = c.values().next()) === null || r === void 0 ? void 0 : r.value;
1540
1540
  if (!d)
1541
1541
  return;
1542
- const f = d[2], l = bi(f, a), p = [
1542
+ const f = d[2], l = bi(f, u), p = [
1543
1543
  s,
1544
1544
  o,
1545
1545
  l,
1546
- Si(t, u, d)
1546
+ Si(t, a, d)
1547
1547
  ];
1548
1548
  Z(t.eav, [s, o], /* @__PURE__ */ new Map([[l, p]])), Z(t.aev, [o, s], /* @__PURE__ */ new Map([[l, p]]));
1549
1549
  }
1550
1550
  function cn(t, e, n) {
1551
1551
  var r, i;
1552
- const [s, o] = n, a = ct(t, [s]);
1553
- if (!a)
1552
+ const [s, o] = n, u = ct(t, [s]);
1553
+ if (!u)
1554
1554
  return;
1555
- const [u] = a, c = t.eav.get(u);
1555
+ const [a] = u, c = t.eav.get(a);
1556
1556
  if (c) {
1557
1557
  for (const f of c.keys()) {
1558
1558
  const l = e.getAttr(f);
@@ -1563,16 +1563,16 @@ function cn(t, e, n) {
1563
1563
  // the store that didn't set `etype` in deleteEntity
1564
1564
  (!o || // If we don't know about the attr, let's just get rid of it
1565
1565
  !l || // Make sure it matches the etype
1566
- ((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]));
1567
1567
  }
1568
- c.size === 0 && oe(t.eav, [u]);
1568
+ c.size === 0 && oe(t.eav, [a]);
1569
1569
  }
1570
- const d = t.vae.get(u) && X(t.vae.get(u), 2);
1570
+ const d = t.vae.get(a) && X(t.vae.get(a), 2);
1571
1571
  d && d.forEach((f) => {
1572
1572
  var l, p, y;
1573
1573
  const [b, _, T] = f, g = e.getAttr(_);
1574
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]]);
1575
- }), ((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]);
1576
1576
  }
1577
1577
  function Ei(t, e, n) {
1578
1578
  const r = gi(e, n, t.useDateObjects);
@@ -1580,13 +1580,13 @@ function Ei(t, e, n) {
1580
1580
  t[i] = r[i];
1581
1581
  });
1582
1582
  }
1583
- function ao(t, [e]) {
1583
+ function uo(t, [e]) {
1584
1584
  t.addAttr(e);
1585
1585
  }
1586
1586
  function Ai(t) {
1587
1587
  return X(t.eav, 3);
1588
1588
  }
1589
- function uo(t, e, [n]) {
1589
+ function ao(t, e, [n]) {
1590
1590
  if (!e.getAttr(n))
1591
1591
  return;
1592
1592
  const r = Ai(t).filter(([i, s]) => s !== n);
@@ -1611,10 +1611,10 @@ function fo(t, e, n) {
1611
1611
  cn(t, e, i);
1612
1612
  break;
1613
1613
  case "add-attr":
1614
- ao(e, i);
1614
+ uo(e, i);
1615
1615
  break;
1616
1616
  case "delete-attr":
1617
- uo(t, e, i);
1617
+ ao(t, e, i);
1618
1618
  break;
1619
1619
  case "update-attr":
1620
1620
  co(t, e, i);
@@ -1648,17 +1648,17 @@ function gt(t, e, n) {
1648
1648
  return i;
1649
1649
  }
1650
1650
  if (n != null && n.hasOwnProperty("$isNull")) {
1651
- const { attrId: o, isNull: a, reverse: u } = n.$isNull;
1652
- if (u)
1651
+ const { attrId: o, isNull: u, reverse: a } = n.$isNull;
1652
+ if (a)
1653
1653
  for (const c of e.keys()) {
1654
1654
  const d = t.vae.get(c), f = !d || !d.get(o);
1655
- (a ? f : !f) && i.push(e.get(c));
1655
+ (u ? f : !f) && i.push(e.get(c));
1656
1656
  }
1657
1657
  else {
1658
1658
  const c = t.aev.get(o);
1659
1659
  for (const d of e.keys()) {
1660
1660
  const f = !c || ((r = c.get(d)) === null || r === void 0 ? void 0 : r.get(null)) || !c.get(d);
1661
- (a ? f : !f) && i.push(e.get(d));
1661
+ (u ? f : !f) && i.push(e.get(d));
1662
1662
  }
1663
1663
  }
1664
1664
  return i;
@@ -1667,8 +1667,8 @@ function gt(t, e, n) {
1667
1667
  return X(e, 1).filter(n.$op);
1668
1668
  const s = n.in || n.$in || [n];
1669
1669
  for (const o of s) {
1670
- const a = e.get(o);
1671
- a && i.push(a);
1670
+ const u = e.get(o);
1671
+ u && i.push(u);
1672
1672
  }
1673
1673
  return i;
1674
1674
  }
@@ -1680,46 +1680,46 @@ function ho(t, [e, n, r]) {
1680
1680
  var i, s;
1681
1681
  switch (lo(e, n, r)) {
1682
1682
  case "e": {
1683
- const a = t.eav.get(e);
1684
- return X(a, 2);
1683
+ const u = t.eav.get(e);
1684
+ return X(u, 2);
1685
1685
  }
1686
1686
  case "ea": {
1687
- const a = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
1688
- return X(a, 1);
1687
+ const u = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
1688
+ return X(u, 1);
1689
1689
  }
1690
1690
  case "eav": {
1691
- const a = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
1692
- 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) : [];
1693
1693
  }
1694
1694
  case "ev": {
1695
- const a = t.eav.get(e);
1696
- if (!a)
1695
+ const u = t.eav.get(e);
1696
+ if (!u)
1697
1697
  return [];
1698
- const u = [];
1699
- for (const c of a.values())
1700
- u.push(...gt(t, c, r));
1701
- return u;
1698
+ const a = [];
1699
+ for (const c of u.values())
1700
+ a.push(...gt(t, c, r));
1701
+ return a;
1702
1702
  }
1703
1703
  case "a": {
1704
- const a = t.aev.get(n);
1705
- return X(a, 2);
1704
+ const u = t.aev.get(n);
1705
+ return X(u, 2);
1706
1706
  }
1707
1707
  case "av": {
1708
- const a = t.aev.get(n);
1709
- if (!a)
1708
+ const u = t.aev.get(n);
1709
+ if (!u)
1710
1710
  return [];
1711
- const u = [];
1712
- for (const c of a.values())
1713
- u.push(...gt(t, c, r));
1714
- return u;
1715
- }
1716
- case "v": {
1717
1711
  const a = [];
1718
- for (const u of t.eav.values())
1719
- for (const c of u.values())
1720
- a.push(...gt(t, c, r));
1712
+ for (const c of u.values())
1713
+ a.push(...gt(t, c, r));
1721
1714
  return a;
1722
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
+ }
1723
1723
  default:
1724
1724
  return X(t.eav, 3);
1725
1725
  }
@@ -1730,8 +1730,8 @@ function po(t, e, n) {
1730
1730
  if (!e)
1731
1731
  return i;
1732
1732
  for (const [s, o] of e.entries()) {
1733
- const a = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), u = X(a, 1);
1734
- for (const c of u)
1733
+ const u = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), a = X(u, 1);
1734
+ for (const c of a)
1735
1735
  i[s] = c[2];
1736
1736
  }
1737
1737
  return i;
@@ -1761,10 +1761,10 @@ function bo(t, e, n) {
1761
1761
  return We(t.eav, [i, s]);
1762
1762
  }
1763
1763
  function _o(t, e, n) {
1764
- const r = n.filter(([i, s, o, a, u]) => {
1764
+ const r = n.filter(([i, s, o, u, a]) => {
1765
1765
  if (i !== "add-triple" && i !== "deep-merge-triple")
1766
1766
  return !0;
1767
- const c = u == null ? void 0 : u.mode;
1767
+ const c = a == null ? void 0 : a.mode;
1768
1768
  if (c !== "create" && c !== "update")
1769
1769
  return !0;
1770
1770
  let d = !1;
@@ -1875,21 +1875,22 @@ function Po() {
1875
1875
  const Mo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Sr = { randomUUID: Mo };
1876
1876
  function Ro(t, e, n) {
1877
1877
  var i;
1878
- if (Sr.randomUUID && !t)
1879
- return Sr.randomUUID();
1880
1878
  t = t || {};
1881
1879
  const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Po();
1882
1880
  if (r.length < 16)
1883
1881
  throw new Error("Random bytes length must be >= 16");
1884
1882
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Co(r);
1885
1883
  }
1884
+ function xo(t, e, n) {
1885
+ return Sr.randomUUID ? Sr.randomUUID() : Ro(t);
1886
+ }
1886
1887
  function Or(t) {
1887
1888
  const e = t.replace(/-/g, ""), n = [];
1888
1889
  for (let r = 0; r < e.length; r += 2)
1889
1890
  n.push(parseInt(e.substring(r, r + 2), 16));
1890
1891
  return n;
1891
1892
  }
1892
- function xo(t, e) {
1893
+ function $o(t, e) {
1893
1894
  for (let n = 0; n < t.length; n++) {
1894
1895
  if (t[n] < e[n])
1895
1896
  return -1;
@@ -1898,17 +1899,17 @@ function xo(t, e) {
1898
1899
  }
1899
1900
  return 0;
1900
1901
  }
1901
- function $o(t, e) {
1902
- return xo(Or(t), Or(e));
1902
+ function Do(t, e) {
1903
+ return $o(Or(t), Or(e));
1903
1904
  }
1904
1905
  function W() {
1905
- return Ro();
1906
+ return xo();
1906
1907
  }
1907
- function Do(t, e) {
1908
+ function Uo(t, e) {
1908
1909
  return t.localeCompare(e);
1909
1910
  }
1910
- function Uo() {
1911
- let t = Do;
1911
+ function Lo() {
1912
+ let t = Uo;
1912
1913
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1913
1914
  try {
1914
1915
  t = Intl.Collator("en-US").compare;
@@ -1916,10 +1917,10 @@ function Uo() {
1916
1917
  }
1917
1918
  return t;
1918
1919
  }
1919
- const Lo = Uo();
1920
- let Fo = 0;
1920
+ const Fo = Lo();
1921
+ let No = 0;
1921
1922
  function nt(t) {
1922
- return $t(`_${t}`, Fo++);
1923
+ return $t(`_${t}`, No++);
1923
1924
  }
1924
1925
  function $t(t, e) {
1925
1926
  return `?${t}-${e}`;
@@ -1929,44 +1930,44 @@ class Ke extends Error {
1929
1930
  super(e), this.name = "AttrNotFoundError";
1930
1931
  }
1931
1932
  }
1932
- function No(t, e) {
1933
+ function Ko(t, e) {
1933
1934
  const n = ki(t, e);
1934
1935
  if (!n)
1935
1936
  throw new Ke(`Could not find id attr for ${e}`);
1936
1937
  return n;
1937
1938
  }
1938
1939
  function Er(t, e, n, r) {
1939
- return [Ko(t, e, n, r)];
1940
+ return [qo(t, e, n, r)];
1940
1941
  }
1941
- function Ko(t, e, n, r) {
1942
+ function qo(t, e, n, r) {
1942
1943
  return [
1943
1944
  t(n, r),
1944
- No(e, n).id,
1945
+ Ko(e, n).id,
1945
1946
  t(n, r),
1946
1947
  t("time", r)
1947
1948
  ];
1948
1949
  }
1949
- function qo(t, e, n) {
1950
+ function Wo(t, e, n) {
1950
1951
  return t.map((r) => r === e ? n : r);
1951
1952
  }
1952
1953
  function Ci(t, e, n, r, i) {
1953
- const s = K(e, n, i), o = Ie(e, n, i), a = s || o;
1954
- if (!a)
1954
+ const s = K(e, n, i), o = Ie(e, n, i), u = s || o;
1955
+ if (!u)
1955
1956
  throw new Ke(`Could not find attr for ${[n, i]}`);
1956
- if (a["value-type"] !== "ref")
1957
- throw new Error(`Attr ${a.id} is not a ref`);
1958
- const [u, c] = a["forward-identity"], [d, f] = a["reverse-identity"], l = r + 1, p = s ? [
1957
+ if (u["value-type"] !== "ref")
1958
+ throw new Error(`Attr ${u.id} is not a ref`);
1959
+ const [a, c] = u["forward-identity"], [d, f] = u["reverse-identity"], l = r + 1, p = s ? [
1959
1960
  t(c, r),
1960
- a.id,
1961
+ u.id,
1961
1962
  t(f, l),
1962
1963
  nt("time")
1963
1964
  ] : [
1964
1965
  t(c, l),
1965
- a.id,
1966
+ u.id,
1966
1967
  t(f, r),
1967
1968
  nt("time")
1968
1969
  ];
1969
- return [s ? f : c, l, p, a, !!s];
1970
+ return [s ? f : c, l, p, u, !!s];
1970
1971
  }
1971
1972
  function Ar(t, e) {
1972
1973
  if (typeof e != "string")
@@ -1978,7 +1979,7 @@ function Ar(t, e) {
1978
1979
  return typeof o != "string" ? !1 : i.test(o);
1979
1980
  };
1980
1981
  }
1981
- function Wo(t, e) {
1982
+ function zo(t, e) {
1982
1983
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
1983
1984
  return e;
1984
1985
  const n = t["checked-data-type"] === "date";
@@ -2038,9 +2039,9 @@ function Wo(t, e) {
2038
2039
  }
2039
2040
  return e;
2040
2041
  }
2041
- function zo(t, e, n, r, i, s) {
2042
- const o = K(e, n, i), a = Ie(e, n, i), u = o || a;
2043
- if (!u)
2042
+ function Vo(t, e, n, r, i, s) {
2043
+ const o = K(e, n, i), u = Ie(e, n, i), a = o || u;
2044
+ if (!a)
2044
2045
  throw new Ke(`No attr for etype = ${n} label = ${i}`);
2045
2046
  if (s != null && s.hasOwnProperty("$isNull")) {
2046
2047
  const c = K(e, n, "id");
@@ -2049,110 +2050,110 @@ function zo(t, e, n, r, i, s) {
2049
2050
  return [
2050
2051
  t(n, r),
2051
2052
  c.id,
2052
- { $isNull: { attrId: u.id, isNull: s.$isNull, reverse: !o } },
2053
+ { $isNull: { attrId: a.id, isNull: s.$isNull, reverse: !o } },
2053
2054
  nt("time")
2054
2055
  ];
2055
2056
  }
2056
2057
  return o ? [
2057
2058
  t(n, r),
2058
- u.id,
2059
- Wo(u, s),
2059
+ a.id,
2060
+ zo(a, s),
2060
2061
  nt("time")
2061
- ] : [s, u.id, t(n, r), nt("time")];
2062
+ ] : [s, a.id, t(n, r), nt("time")];
2062
2063
  }
2063
- function Vo(t, e, n, r, i) {
2064
- const [s, o, a] = i.reduce((u, c) => {
2065
- const [d, f, l] = u, [p, y, b] = Ci(t, e, d, f, c);
2064
+ function Bo(t, e, n, r, i) {
2065
+ const [s, o, u] = i.reduce((a, c) => {
2066
+ const [d, f, l] = a, [p, y, b] = Ci(t, e, d, f, c);
2066
2067
  return [p, y, [...l, b]];
2067
2068
  }, [n, r, []]);
2068
- return [s, o, a];
2069
+ return [s, o, u];
2069
2070
  }
2070
2071
  function fn(t, e, n, r, i, s) {
2071
- 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);
2072
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = Bo(t, e, n, r, o), f = Vo(t, e, a, c, u, s);
2072
2073
  return d.concat([f]);
2073
2074
  }
2074
- function Bo(t, e) {
2075
+ function Go(t, e) {
2075
2076
  return e ? [e].concat(t) : t;
2076
2077
  }
2077
- function Go([t, e]) {
2078
+ function Qo([t, e]) {
2078
2079
  return t === "or" && Array.isArray(e);
2079
2080
  }
2080
- function Qo([t, e]) {
2081
+ function Ho([t, e]) {
2081
2082
  return t === "and" && Array.isArray(e);
2082
2083
  }
2083
- function Ho(t, e, n) {
2084
+ function Yo(t, e, n) {
2084
2085
  return (r, i) => {
2085
2086
  const s = t(r, i);
2086
2087
  return e == s ? s : `${s}-${n}`;
2087
2088
  };
2088
2089
  }
2089
2090
  function kr(t, e, n, r, i, s) {
2090
- const o = t(r, i), a = s.map((u, c) => {
2091
- const d = Ho(t, o, c);
2092
- return Ii(d, n, r, i, u);
2091
+ const o = t(r, i), u = s.map((a, c) => {
2092
+ const d = Yo(t, o, c);
2093
+ return Ii(d, n, r, i, a);
2093
2094
  });
2094
- return { [e]: { patterns: a, joinSym: o } };
2095
+ return { [e]: { patterns: u, joinSym: o } };
2095
2096
  }
2096
- function Yo(t) {
2097
+ function Jo(t) {
2097
2098
  const e = [];
2098
2099
  for (let n = 1; n <= t.length; n++)
2099
2100
  e.push(t.slice(0, n));
2100
2101
  return e;
2101
2102
  }
2102
2103
  function jr(t, e, n, r, i) {
2103
- return Yo(i).map((s) => fn(t, e, n, r, s, {
2104
+ return Jo(i).map((s) => fn(t, e, n, r, s, {
2104
2105
  $isNull: !0
2105
2106
  }));
2106
2107
  }
2107
2108
  function Ii(t, e, n, r, i) {
2108
2109
  return Object.entries(i).flatMap(([s, o]) => {
2109
- if (Go([s, o]))
2110
- return kr(t, "or", e, n, r, o);
2111
2110
  if (Qo([s, o]))
2111
+ return kr(t, "or", e, n, r, o);
2112
+ if (Ho([s, o]))
2112
2113
  return kr(t, "and", e, n, r, o);
2113
2114
  if (s === "$entityIdStartsWith")
2114
2115
  return [];
2115
- const a = s.split(".");
2116
+ const u = s.split(".");
2116
2117
  if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2117
- const u = fn(t, e, n, r, a, o), c = jr(t, e, n, r, a);
2118
+ const a = fn(t, e, n, r, u, o), c = jr(t, e, n, r, u);
2118
2119
  return [
2119
2120
  {
2120
2121
  or: {
2121
- patterns: [u, ...c],
2122
+ patterns: [a, ...c],
2122
2123
  joinSym: t(n, r)
2123
2124
  }
2124
2125
  }
2125
2126
  ];
2126
2127
  }
2127
- return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2128
+ return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && u.length > 1 ? [
2128
2129
  {
2129
2130
  or: {
2130
- patterns: jr(t, e, n, r, a),
2131
+ patterns: jr(t, e, n, r, u),
2131
2132
  joinSym: t(n, r)
2132
2133
  }
2133
2134
  }
2134
- ] : fn(t, e, n, r, a, o);
2135
+ ] : fn(t, e, n, r, u, o);
2135
2136
  });
2136
2137
  }
2137
- function Jo(t, e, n, r) {
2138
+ function Zo(t, e, n, r) {
2138
2139
  const i = $t;
2139
2140
  return r ? Ii(i, t, e, n, r).concat(Er(i, t, e, n)) : Er(i, t, e, n);
2140
2141
  }
2141
- function Zo(t, e, n) {
2142
+ function Xo(t, e, n) {
2142
2143
  return [t(e, n), t("time", n)];
2143
2144
  }
2144
- function Xo(t, e, n, r, i, s) {
2145
- const [o, a, u, c, d] = Ci(t, e, n, r, i), f = qo(u, t(n, r), s);
2146
- return [o, a, f, c, d];
2145
+ function eu(t, e, n, r, i, s) {
2146
+ const [o, u, a, c, d] = Ci(t, e, n, r, i), f = Wo(a, t(n, r), s);
2147
+ return [o, u, f, c, d];
2147
2148
  }
2148
- function ea(t, e, n, { etype: r, level: i, form: s }, o) {
2149
- const a = Object.keys(s).filter((u) => u !== "$");
2150
- return a.length ? Object.entries(o).map(function([c, d]) {
2151
- return a.map(function(p) {
2149
+ function tu(t, e, n, { etype: r, level: i, form: s }, o) {
2150
+ const u = Object.keys(s).filter((a) => a !== "$");
2151
+ return u.length ? Object.entries(o).map(function([c, d]) {
2152
+ return u.map(function(p) {
2152
2153
  var y, b, _;
2153
2154
  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));
2154
2155
  try {
2155
- const [g, m, O] = Xo(t, n, r, i, p, c), S = Mi(e, n, {
2156
+ const [g, m, O] = eu(t, n, r, i, p, c), S = Mi(e, n, {
2156
2157
  etype: g,
2157
2158
  level: m,
2158
2159
  form: s[p],
@@ -2169,11 +2170,11 @@ function ea(t, e, n, { etype: r, level: i, form: s }, o) {
2169
2170
  }, d);
2170
2171
  }) : Object.values(o);
2171
2172
  }
2172
- function ta(t, e, n) {
2173
- return n === "string" ? Lo(t, e) : t > e ? 1 : -1;
2173
+ function nu(t, e, n) {
2174
+ return n === "string" ? Fo(t, e) : t > e ? 1 : -1;
2174
2175
  }
2175
2176
  function Ze(t, e, n, r, i) {
2176
- return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 : ta(e, r, i);
2177
+ return e === r || e == null && r == null ? Do(t, n) : r == null ? 1 : e == null ? -1 : nu(e, r, i);
2177
2178
  }
2178
2179
  function Pt([t, e], [n, r], i) {
2179
2180
  return Ze(t, e, n, r, i);
@@ -2181,49 +2182,49 @@ function Pt([t, e], [n, r], i) {
2181
2182
  function ln(t) {
2182
2183
  return t == null ? t : new Date(t).getTime();
2183
2184
  }
2184
- function na(t, e, n, r) {
2185
+ function ru(t, e, n, r) {
2185
2186
  var i;
2186
- const [s, o, a, u] = t, c = n === "desc" ? 1 : -1;
2187
+ const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
2187
2188
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2188
- return Pt(r, [s, u], null) === c;
2189
- const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(a) : a;
2189
+ return Pt(r, [s, a], null) === c;
2190
+ const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(u) : u;
2190
2191
  return Pt([d, p], [s, y], l) === c;
2191
2192
  }
2192
- function ra(t, e) {
2193
+ function iu(t, e) {
2193
2194
  const n = e[1];
2194
2195
  return t.getAttr(n);
2195
2196
  }
2196
- function ia(t, e, n) {
2197
+ function su(t, e, n) {
2197
2198
  const r = Object.keys(n)[0];
2198
2199
  return K(t, e, r);
2199
2200
  }
2200
- function sa(t, e, n, r) {
2201
+ function ou(t, e, n, r) {
2201
2202
  if (n)
2202
- return ra(t, n);
2203
+ return iu(t, n);
2203
2204
  if (r)
2204
- return ia(t, e, r);
2205
+ return su(t, e, r);
2205
2206
  }
2206
- function oa(t, e, n) {
2207
+ function uu(t, e, n) {
2207
2208
  var r, i;
2208
2209
  if (!Array.isArray(n.fields))
2209
2210
  return yo(t, e);
2210
2211
  const s = /* @__PURE__ */ new Map();
2211
2212
  for (const o of n.fields) {
2212
- const a = K(t, e, o), u = (r = a == null ? void 0 : a["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2213
- u && Fn(a) && s.set(u, a);
2213
+ const u = K(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2214
+ a && Fn(u) && s.set(a, u);
2214
2215
  }
2215
2216
  if (!s.has("id")) {
2216
- const o = K(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
2217
- a && s.set(a, o);
2217
+ const o = K(t, e, "id"), u = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
2218
+ u && s.set(u, o);
2218
2219
  }
2219
2220
  return s;
2220
2221
  }
2221
- function aa(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2222
- var o, a;
2223
- const u = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = ua(s);
2222
+ function au(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2223
+ var o, u;
2224
+ const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = cu(s);
2224
2225
  let f = Ao(t, i);
2225
- const l = r == null ? void 0 : r["start-cursor"], p = sa(e, n, l, u);
2226
- if (p && ((a = p == null ? void 0 : p["forward-identity"]) === null || a === void 0 ? void 0 : a[2]) !== "id") {
2226
+ const l = r == null ? void 0 : r["start-cursor"], p = ou(e, n, l, a);
2227
+ if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
2227
2228
  const _ = p["checked-data-type"] === "date", T = p.id;
2228
2229
  f = f.map(([g]) => {
2229
2230
  var m, O, S, C, $;
@@ -2237,17 +2238,17 @@ function aa(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2237
2238
  return Pt(g, T, p == null ? void 0 : p["checked-data-type"]);
2238
2239
  });
2239
2240
  let y = {};
2240
- const b = oa(e, n, i);
2241
+ const b = uu(e, n, i);
2241
2242
  for (const _ of f) {
2242
2243
  const [T] = _;
2243
- if (y[T] || !c && l && p && na(l, p, d, _))
2244
+ if (y[T] || !c && l && p && ru(l, p, d, _))
2244
2245
  continue;
2245
2246
  const g = po(t, b, T);
2246
2247
  g && (y[T] = g);
2247
2248
  }
2248
2249
  return y;
2249
2250
  }
2250
- function ua(t) {
2251
+ function cu(t) {
2251
2252
  var e;
2252
2253
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2253
2254
  return n && n[Object.keys(n)[0]] || "asc";
@@ -2257,11 +2258,11 @@ function Pi(t) {
2257
2258
  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;
2258
2259
  return !i && !s && !o;
2259
2260
  }
2260
- function ca(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2261
- var a, u, c, d, f;
2261
+ function du(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2262
+ var u, a, c, d, f;
2262
2263
  if (!Pi(i) && (!o || !o["start-cursor"]))
2263
2264
  return [];
2264
- 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, {
2265
+ const l = Go(Zo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = Xo($t, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = au(t, e, {
2265
2266
  etype: n,
2266
2267
  pageInfo: o,
2267
2268
  form: i,
@@ -2274,9 +2275,9 @@ function ca(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2274
2275
  }
2275
2276
  return b;
2276
2277
  }
2277
- function da(t, e, n) {
2278
+ function fu(t, e, n) {
2278
2279
  try {
2279
- return ca(t, e, n);
2280
+ return du(t, e, n);
2280
2281
  } catch (r) {
2281
2282
  if (r instanceof Ke)
2282
2283
  return {};
@@ -2284,10 +2285,10 @@ function da(t, e, n) {
2284
2285
  }
2285
2286
  }
2286
2287
  function Mi(t, e, n) {
2287
- const r = da(t, e, n);
2288
- return ea($t, t, e, n, r);
2288
+ const r = fu(t, e, n);
2289
+ return tu($t, t, e, n, r);
2289
2290
  }
2290
- function fa(t) {
2291
+ function lu(t) {
2291
2292
  const e = {};
2292
2293
  for (const [n, r] of Object.entries(t))
2293
2294
  e[n] = {
@@ -2299,17 +2300,17 @@ function fa(t) {
2299
2300
  return e;
2300
2301
  }
2301
2302
  function Ri({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
2302
- const o = { data: Object.keys(i).reduce(function(u, c) {
2303
- return r != null && r[c] || c === "$$ruleParams" || (u[c] = Mi(t, e, {
2303
+ const o = { data: Object.keys(i).reduce(function(a, c) {
2304
+ return r != null && r[c] || c === "$$ruleParams" || (a[c] = Mi(t, e, {
2304
2305
  etype: c,
2305
2306
  form: i[c],
2306
2307
  level: 0,
2307
2308
  pageInfo: n == null ? void 0 : n[c]
2308
- })), u;
2309
+ })), a;
2309
2310
  }, {}) };
2310
- return n && (o.pageInfo = fa(n)), r && (o.aggregate = r), o;
2311
+ return n && (o.pageInfo = lu(n)), r && (o.aggregate = r), o;
2311
2312
  }
2312
- function la() {
2313
+ function hu() {
2313
2314
  const e = {
2314
2315
  __etype: 1,
2315
2316
  __ops: 1,
@@ -2323,7 +2324,7 @@ function la() {
2323
2324
  };
2324
2325
  return new Set(Object.keys(e));
2325
2326
  }
2326
- const ha = la();
2327
+ const pu = hu();
2327
2328
  function hn(t, e, n) {
2328
2329
  const r = {
2329
2330
  __etype: t,
@@ -2335,15 +2336,15 @@ function hn(t, e, n) {
2335
2336
  return n;
2336
2337
  if (s === "__etype")
2337
2338
  return t;
2338
- if (ha.has(s))
2339
- return (o, a) => hn(t, e, [
2339
+ if (pu.has(s))
2340
+ return (o, u) => hn(t, e, [
2340
2341
  ...n,
2341
- a ? [s, t, e, o, a] : [s, t, e, o]
2342
+ u ? [s, t, e, o, u] : [s, t, e, o]
2342
2343
  ]);
2343
2344
  }
2344
2345
  });
2345
2346
  }
2346
- function Uc(t, e) {
2347
+ function Lc(t, e) {
2347
2348
  return `lookup__${t}__${JSON.stringify(e)}`;
2348
2349
  }
2349
2350
  function Mt(t) {
@@ -2353,7 +2354,7 @@ function xi(t) {
2353
2354
  const [e, n, ...r] = t.split("__");
2354
2355
  return [n, JSON.parse(r.join("__"))];
2355
2356
  }
2356
- function pa(t) {
2357
+ function yu(t) {
2357
2358
  return new Proxy({
2358
2359
  __etype: t
2359
2360
  }, {
@@ -2368,23 +2369,23 @@ function pa(t) {
2368
2369
  function Kn() {
2369
2370
  return new Proxy({}, {
2370
2371
  get(t, e) {
2371
- return pa(e);
2372
+ return yu(e);
2372
2373
  }
2373
2374
  });
2374
2375
  }
2375
- const Lc = Kn();
2376
- function ya(t) {
2376
+ const Fc = Kn();
2377
+ function bu(t) {
2377
2378
  return t.__ops;
2378
2379
  }
2379
- function ba(t, e) {
2380
+ function _u(t, e) {
2380
2381
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2381
2382
  for (const o of e) {
2382
- const a = n[o];
2383
- if (a)
2384
- i.push(a);
2383
+ const u = n[o];
2384
+ if (u)
2385
+ i.push(u);
2385
2386
  else if (Array.isArray(o) && o.length == 2 && n[o[0]]) {
2386
- const [u, c] = o;
2387
- i.push([n[u], c]);
2387
+ const [a, c] = o;
2388
+ i.push([n[a], c]);
2388
2389
  } else
2389
2390
  i.push(o);
2390
2391
  }
@@ -2395,7 +2396,7 @@ function ba(t, e) {
2395
2396
  }
2396
2397
  return i;
2397
2398
  }
2398
- function _a(t) {
2399
+ function gu(t) {
2399
2400
  if (Array.isArray(t))
2400
2401
  return t;
2401
2402
  const e = Object.entries(t);
@@ -2403,7 +2404,7 @@ function _a(t) {
2403
2404
  throw new Error("lookup must be an object with a single unique attr and value.");
2404
2405
  return e[0];
2405
2406
  }
2406
- function ga(t, e, n) {
2407
+ function wu(t, e, n) {
2407
2408
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2408
2409
  // before assuming it's a ref lookup.
2409
2410
  !K(t, e, n);
@@ -2414,8 +2415,8 @@ function pn(t) {
2414
2415
  throw new Error(`${t} is not a valid lookup attribute.`);
2415
2416
  return e;
2416
2417
  }
2417
- function wa(t, e, n) {
2418
- if (!ga(t, e, n))
2418
+ function Tu(t, e, n) {
2419
+ if (!wu(t, e, n))
2419
2420
  return K(t, e, n);
2420
2421
  const r = pn(n), i = K(t, e, r) || Ie(t, e, r);
2421
2422
  if (i && i["value-type"] !== "ref")
@@ -2423,13 +2424,13 @@ function wa(t, e, n) {
2423
2424
  return i;
2424
2425
  }
2425
2426
  function yn(t) {
2426
- return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : _a(t);
2427
+ return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : gu(t);
2427
2428
  }
2428
2429
  function ee(t, e, n) {
2429
2430
  const r = yn(n);
2430
2431
  if (r === null)
2431
2432
  return n;
2432
- const [i, s] = r, o = wa(t, e, i);
2433
+ const [i, s] = r, o = Tu(t, e, i);
2433
2434
  if (!o || !o["unique?"])
2434
2435
  throw new Error(`${i} is not a unique attribute.`);
2435
2436
  return [o.id, s];
@@ -2444,16 +2445,16 @@ function $i(t, e, n, r) {
2444
2445
  s
2445
2446
  ]].concat(r) : r;
2446
2447
  }
2447
- function Ta({ attrsStore: t }, [e, n, r]) {
2448
+ function mu({ attrsStore: t }, [e, n, r]) {
2448
2449
  const i = Object.entries(r).flatMap(([s, o]) => {
2449
- const a = Array.isArray(o) ? o : [o], u = K(t, e, s), c = Ie(t, e, s);
2450
- return a.map((d) => u ? [
2450
+ const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2451
+ return u.map((d) => a ? [
2451
2452
  "add-triple",
2452
2453
  ee(t, e, n),
2453
- u.id,
2454
+ a.id,
2454
2455
  // Uses `!` because if we get here, we should have created the attr if it doesn't
2455
2456
  // already exist
2456
- ee(t, u["reverse-identity"][1], d)
2457
+ ee(t, a["reverse-identity"][1], d)
2457
2458
  ] : [
2458
2459
  "add-triple",
2459
2460
  // Uses `!` because if we get here, we should have created the attr if it doesn't
@@ -2465,16 +2466,16 @@ function Ta({ attrsStore: t }, [e, n, r]) {
2465
2466
  });
2466
2467
  return $i(t, e, n, i);
2467
2468
  }
2468
- function ma({ attrsStore: t }, [e, n, r]) {
2469
+ function vu({ attrsStore: t }, [e, n, r]) {
2469
2470
  const i = Object.entries(r).flatMap(([s, o]) => {
2470
- const a = Array.isArray(o) ? o : [o], u = K(t, e, s), c = Ie(t, e, s);
2471
- return a.map((d) => u ? [
2471
+ const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2472
+ return u.map((d) => a ? [
2472
2473
  "retract-triple",
2473
2474
  ee(t, e, n),
2474
- u.id,
2475
+ a.id,
2475
2476
  // Uses `!` because if we get here, we should have created the attr if it doesn't
2476
2477
  // already exist
2477
- ee(t, u["reverse-identity"][1], d)
2478
+ ee(t, a["reverse-identity"][1], d)
2478
2479
  ] : [
2479
2480
  "retract-triple",
2480
2481
  // Uses `!` because if we get here, we should have created the attr if it doesn't
@@ -2486,14 +2487,14 @@ function ma({ attrsStore: t }, [e, n, r]) {
2486
2487
  });
2487
2488
  return $i(t, e, n, i);
2488
2489
  }
2489
- function va(t, e, n, r) {
2490
+ function Su(t, e, n, r) {
2490
2491
  var i;
2491
2492
  if (Array.isArray(r)) {
2492
2493
  const [s, o] = r;
2493
- for (const a of t || []) {
2494
- const u = a == null ? void 0 : a.aev.get(s);
2495
- if (u) {
2496
- for (const [c, d, f] of X(u, 2))
2494
+ for (const u of t || []) {
2495
+ const a = u == null ? void 0 : u.aev.get(s);
2496
+ if (a) {
2497
+ for (const [c, d, f] of X(a, 2))
2497
2498
  if (f === o)
2498
2499
  return !0;
2499
2500
  }
@@ -2502,45 +2503,45 @@ function va(t, e, n, r) {
2502
2503
  for (const s of t || []) {
2503
2504
  const o = s == null ? void 0 : s.eav.get(r);
2504
2505
  if (o) {
2505
- for (const a of o.keys())
2506
- if (((i = e.getAttr(a)) === null || i === void 0 ? void 0 : i["forward-identity"][1]) == n)
2506
+ for (const u of o.keys())
2507
+ if (((i = e.getAttr(u)) === null || i === void 0 ? void 0 : i["forward-identity"][1]) == n)
2507
2508
  return !0;
2508
2509
  }
2509
2510
  }
2510
2511
  return !1;
2511
2512
  }
2512
2513
  function Di({ stores: t, attrsStore: e }, [n, r, i, s]) {
2513
- 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;
2514
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Su(t, e, n, r) ? { mode: "update" } : null;
2514
2515
  }
2515
- function Sa(t, e) {
2516
- const { attrsStore: n } = t, [r, i, s, o] = e, a = Un(s), u = ee(n, r, i);
2517
- return [["id", u]].concat(Object.entries(a)).map(([d, f]) => {
2516
+ function Ou(t, e) {
2517
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i);
2518
+ return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
2518
2519
  const l = K(n, r, d);
2519
- return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", u, l.id, f, { mode: "create" }];
2520
+ return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
2520
2521
  });
2521
2522
  }
2522
- function Oa(t, e) {
2523
- const { attrsStore: n } = t, [r, i, s, o] = e, a = Un(s), u = ee(n, r, i), c = Di(t, [r, u, s, o]);
2524
- return [["id", u]].concat(Object.entries(a)).map(([f, l]) => {
2523
+ function Eu(t, e) {
2524
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), c = Di(t, [r, a, s, o]);
2525
+ return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
2525
2526
  const p = K(n, r, f);
2526
2527
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), [
2527
2528
  "add-triple",
2528
- u,
2529
+ a,
2529
2530
  p.id,
2530
2531
  l,
2531
2532
  ...c ? [c] : []
2532
2533
  ];
2533
2534
  });
2534
2535
  }
2535
- function Ea({ attrsStore: t }, [e, n]) {
2536
+ function Au({ attrsStore: t }, [e, n]) {
2536
2537
  return [["delete-entity", ee(t, e, n), e]];
2537
2538
  }
2538
- function Aa(t, e) {
2539
- 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]) => {
2539
+ function ku(t, e) {
2540
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), c = Di(t, [r, a, s, o]), d = Object.entries(u).map(([l, p]) => {
2540
2541
  const y = K(n, r, l);
2541
2542
  return [
2542
2543
  "deep-merge-triple",
2543
- u,
2544
+ a,
2544
2545
  y.id,
2545
2546
  p,
2546
2547
  ...c ? [c] : []
@@ -2548,44 +2549,44 @@ function Aa(t, e) {
2548
2549
  });
2549
2550
  return [[
2550
2551
  "add-triple",
2551
- u,
2552
+ a,
2552
2553
  K(n, r, "id").id,
2553
- u,
2554
+ a,
2554
2555
  ...c ? [c] : []
2555
2556
  ]].concat(d);
2556
2557
  }
2557
- function ka({ attrsStore: t }, [e, n, r]) {
2558
+ function ju({ attrsStore: t }, [e, n, r]) {
2558
2559
  return [["rule-params", ee(t, e, n), e, r]];
2559
2560
  }
2560
- function ja(t) {
2561
+ function Cu(t) {
2561
2562
  const [e, n, r, i, s] = t;
2562
2563
  if (!i)
2563
2564
  return t;
2564
2565
  const o = Object.assign({}, i);
2565
2566
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
2566
2567
  }
2567
- function Ca(t, e) {
2568
- const [n, ...r] = ja(e);
2568
+ function Iu(t, e) {
2569
+ const [n, ...r] = Cu(e);
2569
2570
  switch (n) {
2570
2571
  case "merge":
2571
- return Aa(t, r);
2572
+ return ku(t, r);
2572
2573
  case "create":
2573
- return Sa(t, r);
2574
+ return Ou(t, r);
2574
2575
  case "update":
2575
- return Oa(t, r);
2576
+ return Eu(t, r);
2576
2577
  case "link":
2577
- return Ta(t, r);
2578
+ return mu(t, r);
2578
2579
  case "unlink":
2579
- return ma(t, r);
2580
+ return vu(t, r);
2580
2581
  case "delete":
2581
- return Ea(t, r);
2582
+ return Au(t, r);
2582
2583
  case "ruleParams":
2583
- return ka(t, r);
2584
+ return ju(t, r);
2584
2585
  default:
2585
2586
  throw new Error(`unsupported action ${n}`);
2586
2587
  }
2587
2588
  }
2588
- function Ia(t) {
2589
+ function Pu(t) {
2589
2590
  switch (t) {
2590
2591
  case "string":
2591
2592
  case "date":
@@ -2596,29 +2597,29 @@ function Ia(t) {
2596
2597
  return;
2597
2598
  }
2598
2599
  }
2599
- function Pa(t, e, n) {
2600
+ function Mu(t, e, n) {
2600
2601
  var r, i;
2601
2602
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
2602
2603
  if (n === "id")
2603
2604
  return null;
2604
2605
  if (!s)
2605
2606
  throw new Error(`${e}.${n} does not exist in your schema`);
2606
- const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ia(s == null ? void 0 : s.valueType);
2607
+ const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Pu(s == null ? void 0 : s.valueType);
2607
2608
  return {
2608
- "index?": a,
2609
+ "index?": u,
2609
2610
  "unique?": o,
2610
- "checked-data-type": u
2611
+ "checked-data-type": a
2611
2612
  };
2612
2613
  }
2613
2614
  function wt(t, e, n, r) {
2614
- const i = t ? Pa(t, e, n) : null, s = W(), a = [W(), e, n];
2615
- return Object.assign(Object.assign({ id: s, "forward-identity": a, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2615
+ const i = t ? Mu(t, e, n) : null, s = W(), u = [W(), e, n];
2616
+ return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2616
2617
  }
2617
- function Ma(t, e, n) {
2618
+ function Ru(t, e, n) {
2618
2619
  return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
2619
2620
  }
2620
- function Ra(t, e, n) {
2621
- const r = Ma(t, e, n);
2621
+ function xu(t, e, n) {
2622
+ const r = Ru(t, e, n);
2622
2623
  if (!r)
2623
2624
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2624
2625
  const { forward: i, reverse: s } = r;
@@ -2632,13 +2633,13 @@ function Ra(t, e, n) {
2632
2633
  };
2633
2634
  }
2634
2635
  function Cr(t, e, n, r) {
2635
- const i = t ? Ra(t, e, n) : null, s = W(), o = [W(), e, n], a = [W(), n, e];
2636
+ const i = t ? xu(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
2636
2637
  return Object.assign(Object.assign({
2637
2638
  id: s,
2638
2639
  // @ts-ignore: ts thinks it's any[]
2639
2640
  "forward-identity": o,
2640
2641
  // @ts-ignore: ts thinks it's any[]
2641
- "reverse-identity": a,
2642
+ "reverse-identity": u,
2642
2643
  "value-type": "ref",
2643
2644
  // @ts-ignore: ts thinks it's type string
2644
2645
  cardinality: "many",
@@ -2647,7 +2648,7 @@ function Cr(t, e, n, r) {
2647
2648
  isUnsynced: !0
2648
2649
  }, i || {}), r || {});
2649
2650
  }
2650
- 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([
2651
+ const $u = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Du = /* @__PURE__ */ new Set(["link", "unlink"]), Uu = /* @__PURE__ */ new Set(["create", "update", "merge"]), Lu = /* @__PURE__ */ new Set([
2651
2652
  "link",
2652
2653
  "unlink",
2653
2654
  "create",
@@ -2655,30 +2656,30 @@ const xa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2655
2656
  "merge",
2656
2657
  "delete",
2657
2658
  "ruleParams"
2658
- ]), bn = { "unique?": !0, "index?": !0 }, La = Object.assign(Object.assign({}, bn), { cardinality: "one" });
2659
- function Fa(t) {
2659
+ ]), bn = { "unique?": !0, "index?": !0 }, Fu = Object.assign(Object.assign({}, bn), { cardinality: "one" });
2660
+ function Nu(t) {
2660
2661
  const e = [], [n, r, i, s] = t;
2661
- if (!Ua.has(n))
2662
+ if (!Lu.has(n))
2662
2663
  return e;
2663
2664
  const o = yn(i);
2664
2665
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2665
- for (const [a, u] of Object.entries(s)) {
2666
- const c = Array.isArray(u) ? u : [u];
2666
+ for (const [u, a] of Object.entries(s)) {
2667
+ const c = Array.isArray(a) ? a : [a];
2667
2668
  for (const d of c) {
2668
2669
  const f = yn(d);
2669
2670
  f && e.push({
2670
2671
  etype: r,
2671
2672
  lookupPair: f,
2672
- linkLabel: a
2673
+ linkLabel: u
2673
2674
  });
2674
2675
  }
2675
2676
  }
2676
2677
  return e;
2677
2678
  }
2678
- function Na({ attrsStore: t, schema: e }, n) {
2679
+ function Ku({ attrsStore: t, schema: e }, n) {
2679
2680
  var r, i;
2680
- const s = /* @__PURE__ */ new Set(), o = [], a = [];
2681
- function u(y, b) {
2681
+ const s = /* @__PURE__ */ new Set(), o = [], u = [];
2682
+ function a(y, b) {
2682
2683
  return K(t, y, b) || o.find((_) => _["forward-identity"][1] === y && _["forward-identity"][2] === b);
2683
2684
  }
2684
2685
  function c(y, b) {
@@ -2688,49 +2689,49 @@ function Na({ attrsStore: t, schema: e }, n) {
2688
2689
  });
2689
2690
  }
2690
2691
  function d(y) {
2691
- o.push(y), a.push(["add-attr", y]), s.add(y.id);
2692
+ o.push(y), u.push(["add-attr", y]), s.add(y.id);
2692
2693
  }
2693
2694
  function f(y) {
2694
- y && "isUnsynced" in y && y.isUnsynced && !s.has(y.id) && (o.push(y), a.push(["add-attr", y]), s.add(y.id));
2695
+ y && "isUnsynced" in y && y.isUnsynced && !s.has(y.id) && (o.push(y), u.push(["add-attr", y]), s.add(y.id));
2695
2696
  }
2696
2697
  function l(y, b) {
2697
2698
  return b.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2698
2699
  // before assuming it's a ref lookup.
2699
- !u(y, b);
2700
+ !a(y, b);
2700
2701
  }
2701
2702
  function p(y, b) {
2702
- const _ = u(y, b), T = c(y, b);
2703
- f(_), f(T), !_ && !T && d(Cr(e, y, b, La));
2703
+ const _ = a(y, b), T = c(y, b);
2704
+ f(_), f(T), !_ && !T && d(Cr(e, y, b, Fu));
2704
2705
  }
2705
2706
  for (const y of n)
2706
- for (const { etype: b, lookupPair: _, linkLabel: T } of Fa(y)) {
2707
+ for (const { etype: b, lookupPair: _, linkLabel: T } of Nu(y)) {
2707
2708
  const g = _[0];
2708
2709
  if (T) {
2709
2710
  p(b, T);
2710
- const m = u(b, T), O = c(b, T);
2711
+ const m = a(b, T), O = c(b, T);
2711
2712
  f(m), f(O);
2712
2713
  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;
2713
2714
  if (l(S, g))
2714
2715
  p(S, pn(g));
2715
2716
  else {
2716
- const C = u(S, g);
2717
+ const C = a(S, g);
2717
2718
  C || d(wt(e, S, g, bn)), f(C);
2718
2719
  }
2719
2720
  } else if (l(b, g))
2720
2721
  p(b, pn(g));
2721
2722
  else {
2722
- const m = u(b, g);
2723
+ const m = a(b, g);
2723
2724
  m || d(wt(e, b, g, bn)), f(m);
2724
2725
  }
2725
2726
  }
2726
2727
  for (const y of n) {
2727
2728
  const [b, _, T, g] = y;
2728
- if (xa.has(b)) {
2729
- const m = u(_, "id");
2729
+ if ($u.has(b)) {
2730
+ const m = a(_, "id");
2730
2731
  f(m), m || d(wt(e, _, "id", { "unique?": !0 }));
2731
2732
  for (const O of Object.keys(g)) {
2732
- const S = u(_, O);
2733
- if (f(S), Da.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), $a.has(b)) {
2733
+ const S = a(_, O);
2734
+ if (f(S), Uu.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), Du.has(b)) {
2734
2735
  const C = c(_, O);
2735
2736
  !S && !C && d(Cr(e, _, O)), f(C);
2736
2737
  }
@@ -2741,13 +2742,13 @@ function Na({ attrsStore: t, schema: e }, n) {
2741
2742
  const y = Object.assign({}, t.attrs);
2742
2743
  for (const b of o)
2743
2744
  y[b.id] = b;
2744
- return [new Ae(y, t.linkIndex), a];
2745
+ return [new Ae(y, t.linkIndex), u];
2745
2746
  }
2746
- return [t, a];
2747
+ return [t, u];
2747
2748
  }
2748
- function Ka(t, e) {
2749
- 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));
2750
- return [...s, ...a];
2749
+ function qu(t, e) {
2750
+ const r = (Array.isArray(e) ? e : [e]).flatMap((a) => bu(a)), [i, s] = Ku(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Iu(o, a));
2751
+ return [...s, ...u];
2751
2752
  }
2752
2753
  var de = function(t, e, n, r) {
2753
2754
  function i(s) {
@@ -2756,14 +2757,14 @@ var de = function(t, e, n, r) {
2756
2757
  });
2757
2758
  }
2758
2759
  return new (n || (n = Promise))(function(s, o) {
2759
- function a(d) {
2760
+ function u(d) {
2760
2761
  try {
2761
2762
  c(r.next(d));
2762
2763
  } catch (f) {
2763
2764
  o(f);
2764
2765
  }
2765
2766
  }
2766
- function u(d) {
2767
+ function a(d) {
2767
2768
  try {
2768
2769
  c(r.throw(d));
2769
2770
  } catch (f) {
@@ -2771,7 +2772,7 @@ var de = function(t, e, n, r) {
2771
2772
  }
2772
2773
  }
2773
2774
  function c(d) {
2774
- d.done ? s(d.value) : i(d.value).then(a, u);
2775
+ d.done ? s(d.value) : i(d.value).then(u, a);
2775
2776
  }
2776
2777
  c((r = r.apply(t, e || [])).next());
2777
2778
  });
@@ -2780,7 +2781,7 @@ function Ir(t, e) {
2780
2781
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2781
2782
  }
2782
2783
  const rt = "__meta";
2783
- class qa {
2784
+ class Wu {
2784
2785
  constructor(e, n) {
2785
2786
  }
2786
2787
  }
@@ -2804,8 +2805,8 @@ class _n {
2804
2805
  this._meta.loadingPromise = i;
2805
2806
  const s = yield i;
2806
2807
  this._meta.isLoading = !1, this._meta.error = null, this._meta.loadingPromise = null, this._meta.attempts = 0;
2807
- 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 : {};
2808
- this._meta.value = Object.assign(Object.assign({}, a), { objects: Object.assign(Object.assign({}, o), u) });
2808
+ 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 : {};
2809
+ this._meta.value = Object.assign(Object.assign({}, u), { objects: Object.assign(Object.assign({}, o), a) });
2809
2810
  } catch (i) {
2810
2811
  this._meta.error = i, this._meta.attempts++, this._meta.loadingPromise = null;
2811
2812
  }
@@ -2827,7 +2828,7 @@ class _n {
2827
2828
  if (!n)
2828
2829
  return;
2829
2830
  const r = Object.entries(n.objects);
2830
- r.sort(([i, s], [o, a]) => a.updatedAt - s.updatedAt);
2831
+ r.sort(([i, s], [o, u]) => u.updatedAt - s.updatedAt);
2831
2832
  for (const [i] of r.slice(0, e))
2832
2833
  this._loadKey(i);
2833
2834
  });
@@ -2889,16 +2890,16 @@ class _n {
2889
2890
  const o = this._meta.value;
2890
2891
  if (!o)
2891
2892
  return Promise.resolve(0);
2892
- const a = [], u = [];
2893
+ const u = [], a = [];
2893
2894
  for (const p of this._pendingSaveKeys)
2894
- p in this.currentValue ? u.push(p) : (a.push(p), delete o.objects[p]);
2895
- for (const p of a) {
2895
+ p in this.currentValue ? a.push(p) : (u.push(p), delete o.objects[p]);
2896
+ for (const p of u) {
2896
2897
  const y = this._persister.removeItem(p);
2897
2898
  i.push(y.then(() => 1)), this._loadedKeys.delete(p), this._pendingSaveKeys.delete(p);
2898
2899
  }
2899
2900
  const c = [], d = [[rt, o]], f = (n = o.objects) !== null && n !== void 0 ? n : {};
2900
2901
  o.objects = f;
2901
- for (const p of u)
2902
+ for (const p of a)
2902
2903
  if (this._loadedKeys.has(p)) {
2903
2904
  const y = this.serialize(p, this.currentValue[p]);
2904
2905
  d.push([p, y]);
@@ -2955,11 +2956,11 @@ class _n {
2955
2956
  const o = Date.now();
2956
2957
  for (const [l, p] of Object.entries(r.objects))
2957
2958
  !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++);
2958
- const a = Object.entries(r.objects);
2959
- a.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
2960
- const u = a.filter(([l]) => !n.has(l));
2961
- if (a.length > this._gcOpts.maxEntries)
2962
- for (const [l] of u.slice(0, a.length - this._gcOpts.maxEntries))
2959
+ const u = Object.entries(r.objects);
2960
+ u.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
2961
+ const a = u.filter(([l]) => !n.has(l));
2962
+ if (u.length > this._gcOpts.maxEntries)
2963
+ for (const [l] of a.slice(0, u.length - this._gcOpts.maxEntries))
2963
2964
  i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedThresholdCount++;
2964
2965
  const c = Object.entries(r.objects);
2965
2966
  c.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
@@ -3032,14 +3033,14 @@ var ye = function(t, e, n, r) {
3032
3033
  });
3033
3034
  }
3034
3035
  return new (n || (n = Promise))(function(s, o) {
3035
- function a(d) {
3036
+ function u(d) {
3036
3037
  try {
3037
3038
  c(r.next(d));
3038
3039
  } catch (f) {
3039
3040
  o(f);
3040
3041
  }
3041
3042
  }
3042
- function u(d) {
3043
+ function a(d) {
3043
3044
  try {
3044
3045
  c(r.throw(d));
3045
3046
  } catch (f) {
@@ -3047,18 +3048,18 @@ var ye = function(t, e, n, r) {
3047
3048
  }
3048
3049
  }
3049
3050
  function c(d) {
3050
- d.done ? s(d.value) : i(d.value).then(a, u);
3051
+ d.done ? s(d.value) : i(d.value).then(u, a);
3051
3052
  }
3052
3053
  c((r = r.apply(t, e || [])).next());
3053
3054
  });
3054
3055
  };
3055
- const Wa = 6, za = ["kv", "querySubs", "syncSubs"];
3056
- function Va(t) {
3056
+ const zu = 6, Vu = ["kv", "querySubs", "syncSubs"];
3057
+ function Bu(t) {
3057
3058
  return function(n) {
3058
3059
  console.error("Error in IndexedDB event", { source: t, event: n });
3059
3060
  };
3060
3061
  }
3061
- function Ba(t) {
3062
+ function Gu(t) {
3062
3063
  return ye(this, void 0, void 0, function* () {
3063
3064
  return new Promise((e) => {
3064
3065
  const n = indexedDB.open(t);
@@ -3074,7 +3075,7 @@ function Ba(t) {
3074
3075
  });
3075
3076
  });
3076
3077
  }
3077
- function Ga(t, e, n) {
3078
+ function Qu(t, e, n) {
3078
3079
  return ye(this, void 0, void 0, function* () {
3079
3080
  const r = (
3080
3081
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3084,7 +3085,7 @@ function Ga(t, e, n) {
3084
3085
  return;
3085
3086
  const i = /* @__PURE__ */ new Set();
3086
3087
  return new Promise((s, o) => {
3087
- var a, u, c, d;
3088
+ var u, a, c, d;
3088
3089
  const f = {};
3089
3090
  for (const [y, b] of Object.entries(r)) {
3090
3091
  const _ = typeof b == "string" ? JSON.parse(b) : b;
@@ -3092,7 +3093,7 @@ function Ga(t, e, n) {
3092
3093
  const g = {
3093
3094
  createdAt: _.lastAccessed,
3094
3095
  updatedAt: _.lastAccessed,
3095
- 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
3096
+ 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
3096
3097
  };
3097
3098
  f[y] = g;
3098
3099
  }
@@ -3118,9 +3119,9 @@ function Pr(t, e, n) {
3118
3119
  });
3119
3120
  });
3120
3121
  }
3121
- function Qa(t, e) {
3122
+ function Hu(t, e) {
3122
3123
  return ye(this, void 0, void 0, function* () {
3123
- const n = yield Ba(`instant_${t}_5`);
3124
+ const n = yield Gu(`instant_${t}_5`);
3124
3125
  if (!n)
3125
3126
  return;
3126
3127
  const r = yield new Promise((d, f) => {
@@ -3139,36 +3140,36 @@ function Qa(t, e) {
3139
3140
  }, y.onerror = (_) => {
3140
3141
  f(_);
3141
3142
  };
3142
- }), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), a = [], u = { objects: {} };
3143
+ }), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), u = [], a = { objects: {} };
3143
3144
  for (const [d, f] of r)
3144
3145
  switch (d) {
3145
3146
  case "querySubs": {
3146
- const l = Ga(d, f, o);
3147
- a.push(l);
3147
+ const l = Qu(d, f, o);
3148
+ u.push(l);
3148
3149
  break;
3149
3150
  }
3150
3151
  default: {
3151
3152
  const l = Pr(d, f, s);
3152
- a.push(l);
3153
+ u.push(l);
3153
3154
  const p = {
3154
3155
  createdAt: Date.now(),
3155
3156
  updatedAt: Date.now(),
3156
3157
  size: 0
3157
3158
  };
3158
- u.objects[d] = p;
3159
+ a.objects[d] = p;
3159
3160
  break;
3160
3161
  }
3161
3162
  }
3162
- const c = Pr(rt, u, s);
3163
- a.push(c), yield Promise.all(a), yield new Promise((d, f) => {
3163
+ const c = Pr(rt, a, s);
3164
+ u.push(c), yield Promise.all(u), yield new Promise((d, f) => {
3164
3165
  i.oncomplete = (l) => d(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3165
3166
  });
3166
3167
  });
3167
3168
  }
3168
3169
  const Mr = /* @__PURE__ */ new Map();
3169
- class Ui extends qa {
3170
+ class Ui extends Wu {
3170
3171
  constructor(e, n) {
3171
- super(e, n), this.dbName = `instant_${e}_${Wa}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3172
+ super(e, n), this.dbName = `instant_${e}_${zu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3172
3173
  }
3173
3174
  _init() {
3174
3175
  return new Promise((e, n) => {
@@ -3177,15 +3178,15 @@ class Ui extends qa {
3177
3178
  i.onerror = (s) => {
3178
3179
  n(s);
3179
3180
  }, i.onsuccess = (s) => {
3180
- const a = s.target.result;
3181
+ const u = s.target.result;
3181
3182
  if (r) {
3182
- const u = Qa(this._appId, a).catch((c) => {
3183
- Va("Error upgrading store from version 5 to 6.")(c);
3183
+ const a = Hu(this._appId, u).catch((c) => {
3184
+ Bu("Error upgrading store from version 5 to 6.")(c);
3184
3185
  });
3185
- Mr.set(this.dbName, u), u.then(() => e(a)).catch(() => e(a));
3186
+ Mr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3186
3187
  } else {
3187
- const u = Mr.get(this.dbName);
3188
- u ? u.then(() => e(a)).catch(() => e(a)) : e(a);
3188
+ const a = Mr.get(this.dbName);
3189
+ a ? a.then(() => e(u)).catch(() => e(u)) : e(u);
3189
3190
  }
3190
3191
  }, i.onupgradeneeded = (s) => {
3191
3192
  r = !0, this._upgradeStore(s);
@@ -3194,18 +3195,18 @@ class Ui extends qa {
3194
3195
  }
3195
3196
  _upgradeStore(e) {
3196
3197
  const r = e.target.result;
3197
- for (const i of za)
3198
+ for (const i of Vu)
3198
3199
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3199
3200
  }
3200
3201
  getItem(e) {
3201
3202
  return ye(this, void 0, void 0, function* () {
3202
3203
  const n = yield this._dbPromise;
3203
3204
  return new Promise((r, i) => {
3204
- const a = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
3205
- a.onerror = (u) => {
3206
- i(u);
3207
- }, a.onsuccess = (u) => {
3208
- a.result ? r(a.result) : r(null);
3205
+ const u = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
3206
+ u.onerror = (a) => {
3207
+ i(a);
3208
+ }, u.onsuccess = (a) => {
3209
+ u.result ? r(u.result) : r(null);
3209
3210
  };
3210
3211
  });
3211
3212
  });
@@ -3214,10 +3215,10 @@ class Ui extends qa {
3214
3215
  return ye(this, void 0, void 0, function* () {
3215
3216
  const r = yield this._dbPromise;
3216
3217
  return new Promise((i, s) => {
3217
- const u = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
3218
- u.onerror = (c) => {
3218
+ const a = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
3219
+ a.onerror = (c) => {
3219
3220
  s(c);
3220
- }, u.onsuccess = (c) => {
3221
+ }, a.onsuccess = (c) => {
3221
3222
  i();
3222
3223
  };
3223
3224
  });
@@ -3228,16 +3229,16 @@ class Ui extends qa {
3228
3229
  return ye(this, void 0, void 0, function* () {
3229
3230
  const n = yield this._dbPromise;
3230
3231
  return new Promise((r, i) => {
3231
- const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), a = /* @__PURE__ */ new Set();
3232
- for (const [u, c] of e) {
3233
- const d = o.put(c, u);
3234
- a.add(d);
3232
+ const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), u = /* @__PURE__ */ new Set();
3233
+ for (const [a, c] of e) {
3234
+ const d = o.put(c, a);
3235
+ u.add(d);
3235
3236
  }
3236
- for (const u of a)
3237
- u.onerror = (c) => {
3237
+ for (const a of u)
3238
+ a.onerror = (c) => {
3238
3239
  s.abort(), i(c);
3239
- }, u.onsuccess = (c) => {
3240
- a.delete(u), a.size === 0 && r();
3240
+ }, a.onsuccess = (c) => {
3241
+ u.delete(a), u.size === 0 && r();
3241
3242
  };
3242
3243
  });
3243
3244
  });
@@ -3246,10 +3247,10 @@ class Ui extends qa {
3246
3247
  return ye(this, void 0, void 0, function* () {
3247
3248
  const n = yield this._dbPromise;
3248
3249
  return new Promise((r, i) => {
3249
- const a = n.transaction([this._storeName], "readwrite").objectStore(this._storeName).delete(e);
3250
- a.onerror = (u) => {
3251
- i(u);
3252
- }, a.onsuccess = (u) => {
3250
+ const u = n.transaction([this._storeName], "readwrite").objectStore(this._storeName).delete(e);
3251
+ u.onerror = (a) => {
3252
+ i(a);
3253
+ }, u.onsuccess = (a) => {
3253
3254
  r();
3254
3255
  };
3255
3256
  });
@@ -3260,30 +3261,30 @@ class Ui extends qa {
3260
3261
  const e = yield this._dbPromise;
3261
3262
  return new Promise((n, r) => {
3262
3263
  const o = e.transaction([this._storeName], "readonly").objectStore(this._storeName).getAllKeys();
3263
- o.onerror = (a) => {
3264
- r(a);
3265
- }, o.onsuccess = (a) => {
3266
- n(o.result.filter((u) => typeof u == "string"));
3264
+ o.onerror = (u) => {
3265
+ r(u);
3266
+ }, o.onsuccess = (u) => {
3267
+ n(o.result.filter((a) => typeof a == "string"));
3267
3268
  };
3268
3269
  });
3269
3270
  });
3270
3271
  }
3271
3272
  }
3272
- var Ha = function(t, e, n, r) {
3273
+ var Yu = function(t, e, n, r) {
3273
3274
  function i(s) {
3274
3275
  return s instanceof n ? s : new n(function(o) {
3275
3276
  o(s);
3276
3277
  });
3277
3278
  }
3278
3279
  return new (n || (n = Promise))(function(s, o) {
3279
- function a(d) {
3280
+ function u(d) {
3280
3281
  try {
3281
3282
  c(r.next(d));
3282
3283
  } catch (f) {
3283
3284
  o(f);
3284
3285
  }
3285
3286
  }
3286
- function u(d) {
3287
+ function a(d) {
3287
3288
  try {
3288
3289
  c(r.throw(d));
3289
3290
  } catch (f) {
@@ -3291,14 +3292,14 @@ var Ha = function(t, e, n, r) {
3291
3292
  }
3292
3293
  }
3293
3294
  function c(d) {
3294
- d.done ? s(d.value) : i(d.value).then(a, u);
3295
+ d.done ? s(d.value) : i(d.value).then(u, a);
3295
3296
  }
3296
3297
  c((r = r.apply(t, e || [])).next());
3297
3298
  });
3298
3299
  };
3299
3300
  class Li {
3300
3301
  static getIsOnline() {
3301
- return Ha(this, void 0, void 0, function* () {
3302
+ return Yu(this, void 0, void 0, function* () {
3302
3303
  return navigator.onLine;
3303
3304
  });
3304
3305
  }
@@ -3323,21 +3324,21 @@ class qe extends Error {
3323
3324
  return "InstantError";
3324
3325
  }
3325
3326
  }
3326
- var Ya = function(t, e, n, r) {
3327
+ var Ju = function(t, e, n, r) {
3327
3328
  function i(s) {
3328
3329
  return s instanceof n ? s : new n(function(o) {
3329
3330
  o(s);
3330
3331
  });
3331
3332
  }
3332
3333
  return new (n || (n = Promise))(function(s, o) {
3333
- function a(d) {
3334
+ function u(d) {
3334
3335
  try {
3335
3336
  c(r.next(d));
3336
3337
  } catch (f) {
3337
3338
  o(f);
3338
3339
  }
3339
3340
  }
3340
- function u(d) {
3341
+ function a(d) {
3341
3342
  try {
3342
3343
  c(r.throw(d));
3343
3344
  } catch (f) {
@@ -3345,7 +3346,7 @@ var Ya = function(t, e, n, r) {
3345
3346
  }
3346
3347
  }
3347
3348
  function c(d) {
3348
- d.done ? s(d.value) : i(d.value).then(a, u);
3349
+ d.done ? s(d.value) : i(d.value).then(u, a);
3349
3350
  }
3350
3351
  c((r = r.apply(t, e || [])).next());
3351
3352
  });
@@ -3362,8 +3363,8 @@ class Dt extends qe {
3362
3363
  return "InstantAPIError";
3363
3364
  }
3364
3365
  }
3365
- function ue(t, e) {
3366
- return Ya(this, void 0, void 0, function* () {
3366
+ function ae(t, e) {
3367
+ return Ju(this, void 0, void 0, function* () {
3367
3368
  const n = yield fetch(t, e), r = yield n.json();
3368
3369
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Dt({ status: n.status, body: r }));
3369
3370
  });
@@ -3375,14 +3376,14 @@ var ze = function(t, e, n, r) {
3375
3376
  });
3376
3377
  }
3377
3378
  return new (n || (n = Promise))(function(s, o) {
3378
- function a(d) {
3379
+ function u(d) {
3379
3380
  try {
3380
3381
  c(r.next(d));
3381
3382
  } catch (f) {
3382
3383
  o(f);
3383
3384
  }
3384
3385
  }
3385
- function u(d) {
3386
+ function a(d) {
3386
3387
  try {
3387
3388
  c(r.throw(d));
3388
3389
  } catch (f) {
@@ -3390,21 +3391,21 @@ var ze = function(t, e, n, r) {
3390
3391
  }
3391
3392
  }
3392
3393
  function c(d) {
3393
- d.done ? s(d.value) : i(d.value).then(a, u);
3394
+ d.done ? s(d.value) : i(d.value).then(u, a);
3394
3395
  }
3395
3396
  c((r = r.apply(t, e || [])).next());
3396
3397
  });
3397
3398
  };
3398
- function Ja({ apiURI: t, appId: e, email: n }) {
3399
- return ue(`${t}/runtime/auth/send_magic_code`, {
3399
+ function Zu({ apiURI: t, appId: e, email: n }) {
3400
+ return ae(`${t}/runtime/auth/send_magic_code`, {
3400
3401
  method: "POST",
3401
3402
  headers: { "content-type": "application/json" },
3402
3403
  body: JSON.stringify({ "app-id": e, email: n })
3403
3404
  });
3404
3405
  }
3405
- function Za(t) {
3406
+ function Xu(t) {
3406
3407
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3407
- return yield ue(`${e}/runtime/auth/verify_magic_code`, {
3408
+ return yield ae(`${e}/runtime/auth/verify_magic_code`, {
3408
3409
  method: "POST",
3409
3410
  headers: { "content-type": "application/json" },
3410
3411
  body: JSON.stringify(Object.assign({
@@ -3415,9 +3416,9 @@ function Za(t) {
3415
3416
  });
3416
3417
  });
3417
3418
  }
3418
- function Xa(t) {
3419
+ function ea(t) {
3419
3420
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3420
- return yield ue(`${e}/runtime/auth/verify_refresh_token`, {
3421
+ return yield ae(`${e}/runtime/auth/verify_refresh_token`, {
3421
3422
  method: "POST",
3422
3423
  headers: { "content-type": "application/json" },
3423
3424
  body: JSON.stringify({
@@ -3427,9 +3428,9 @@ function Xa(t) {
3427
3428
  });
3428
3429
  });
3429
3430
  }
3430
- function eu(t) {
3431
+ function ta(t) {
3431
3432
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3432
- return yield ue(`${e}/runtime/auth/sign_in_guest`, {
3433
+ return yield ae(`${e}/runtime/auth/sign_in_guest`, {
3433
3434
  method: "POST",
3434
3435
  headers: { "content-type": "application/json" },
3435
3436
  body: JSON.stringify({
@@ -3440,7 +3441,7 @@ function eu(t) {
3440
3441
  }
3441
3442
  function Rr(t) {
3442
3443
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
3443
- return yield ue(`${e}/runtime/oauth/token`, {
3444
+ return yield ae(`${e}/runtime/oauth/token`, {
3444
3445
  method: "POST",
3445
3446
  headers: { "content-type": "application/json" },
3446
3447
  body: JSON.stringify({
@@ -3452,9 +3453,9 @@ function Rr(t) {
3452
3453
  });
3453
3454
  });
3454
3455
  }
3455
- function tu(t) {
3456
+ function na(t) {
3456
3457
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3457
- return yield ue(`${e}/runtime/oauth/id_token`, {
3458
+ return yield ae(`${e}/runtime/oauth/id_token`, {
3458
3459
  method: "POST",
3459
3460
  headers: { "content-type": "application/json" },
3460
3461
  body: JSON.stringify({
@@ -3467,9 +3468,9 @@ function tu(t) {
3467
3468
  });
3468
3469
  });
3469
3470
  }
3470
- function nu(t) {
3471
+ function ra(t) {
3471
3472
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3472
- return yield ue(`${e}/runtime/signout`, {
3473
+ return yield ae(`${e}/runtime/signout`, {
3473
3474
  method: "POST",
3474
3475
  headers: {
3475
3476
  "content-type": "application/json"
@@ -3488,14 +3489,14 @@ var dt = function(t, e, n, r) {
3488
3489
  });
3489
3490
  }
3490
3491
  return new (n || (n = Promise))(function(s, o) {
3491
- function a(d) {
3492
+ function u(d) {
3492
3493
  try {
3493
3494
  c(r.next(d));
3494
3495
  } catch (f) {
3495
3496
  o(f);
3496
3497
  }
3497
3498
  }
3498
- function u(d) {
3499
+ function a(d) {
3499
3500
  try {
3500
3501
  c(r.throw(d));
3501
3502
  } catch (f) {
@@ -3503,29 +3504,29 @@ var dt = function(t, e, n, r) {
3503
3504
  }
3504
3505
  }
3505
3506
  function c(d) {
3506
- d.done ? s(d.value) : i(d.value).then(a, u);
3507
+ d.done ? s(d.value) : i(d.value).then(u, a);
3507
3508
  }
3508
3509
  c((r = r.apply(t, e || [])).next());
3509
3510
  });
3510
3511
  };
3511
- function ru(t) {
3512
- return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: a }) {
3513
- const u = {
3512
+ function ia(t) {
3513
+ return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
3514
+ const a = {
3514
3515
  app_id: n,
3515
3516
  path: r,
3516
3517
  authorization: `Bearer ${s}`,
3517
3518
  "content-type": o || i.type
3518
3519
  };
3519
- return a && (u["content-disposition"] = a), yield ue(`${e}/storage/upload`, {
3520
+ return u && (a["content-disposition"] = u), yield ae(`${e}/storage/upload`, {
3520
3521
  method: "PUT",
3521
- headers: u,
3522
+ headers: a,
3522
3523
  body: i
3523
3524
  });
3524
3525
  });
3525
3526
  }
3526
- function iu(t) {
3527
+ function sa(t) {
3527
3528
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3528
- const { data: s } = yield ue(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3529
+ const { data: s } = yield ae(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3529
3530
  method: "DELETE",
3530
3531
  headers: {
3531
3532
  "content-type": "application/json",
@@ -3535,9 +3536,9 @@ function iu(t) {
3535
3536
  return s;
3536
3537
  });
3537
3538
  }
3538
- function su(t) {
3539
+ function oa(t) {
3539
3540
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3540
- const { data: o } = yield ue(`${e}/storage/signed-upload-url`, {
3541
+ const { data: o } = yield ae(`${e}/storage/signed-upload-url`, {
3541
3542
  method: "POST",
3542
3543
  headers: {
3543
3544
  "content-type": "application/json",
@@ -3551,7 +3552,7 @@ function su(t) {
3551
3552
  return o;
3552
3553
  });
3553
3554
  }
3554
- function ou(t, e) {
3555
+ function ua(t, e) {
3555
3556
  return dt(this, void 0, void 0, function* () {
3556
3557
  return (yield fetch(t, {
3557
3558
  method: "PUT",
@@ -3562,9 +3563,9 @@ function ou(t, e) {
3562
3563
  })).ok;
3563
3564
  });
3564
3565
  }
3565
- function au(t) {
3566
+ function aa(t) {
3566
3567
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3567
- const { data: s } = yield ue(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3568
+ const { data: s } = yield ae(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3568
3569
  method: "GET",
3569
3570
  headers: {
3570
3571
  "content-type": "application/json",
@@ -3584,25 +3585,25 @@ function xr(t, e) {
3584
3585
  n[r] = t[r];
3585
3586
  }), n;
3586
3587
  }
3587
- function uu(t, e, n) {
3588
+ function ca(t, e, n) {
3588
3589
  var r, i;
3589
3590
  const s = {
3590
3591
  peers: {}
3591
3592
  };
3592
3593
  if (e && "user" in e ? e.user : !0) {
3593
- const a = xr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3594
- s.user = Object.assign(Object.assign({}, a), { peerId: n });
3594
+ const u = xr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3595
+ s.user = Object.assign(Object.assign({}, u), { peerId: n });
3595
3596
  }
3596
- for (const a of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3597
- 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));
3598
- if (u || c) {
3599
- const d = xr(t.peers[a], e == null ? void 0 : e.keys);
3600
- s.peers[a] = Object.assign(Object.assign({}, d), { peerId: a });
3597
+ for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3598
+ 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));
3599
+ if (a || c) {
3600
+ const d = xr(t.peers[u], e == null ? void 0 : e.keys);
3601
+ s.peers[u] = Object.assign(Object.assign({}, d), { peerId: u });
3601
3602
  }
3602
3603
  }
3603
3604
  return s;
3604
3605
  }
3605
- function cu(t, e) {
3606
+ function da(t, e) {
3606
3607
  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))
3607
3608
  return !0;
3608
3609
  for (const r of Object.keys(t.peers))
@@ -3627,8 +3628,8 @@ function Ki(t, e = []) {
3627
3628
  t.forEach((n) => {
3628
3629
  const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
3629
3630
  for (const o of s)
3630
- for (const a of o)
3631
- e.push(a);
3631
+ for (const u of o)
3632
+ e.push(u);
3632
3633
  Ki(n["child-nodes"], e);
3633
3634
  });
3634
3635
  }
@@ -3650,8 +3651,8 @@ function Ur(t) {
3650
3651
  }, e;
3651
3652
  }, {});
3652
3653
  }
3653
- const Wn = "v0.22.89-experimental.split-store.20276199573.1";
3654
- function du(t, e) {
3654
+ const Wn = "v0.22.89-experimental.uuidfix.20281951052.1";
3655
+ function fa(t, e) {
3655
3656
  return {
3656
3657
  info: t ? (...n) => console.info(...n, e()) : () => {
3657
3658
  },
@@ -3735,7 +3736,7 @@ const Lr = [
3735
3736
  "before",
3736
3737
  "fields",
3737
3738
  "aggregate"
3738
- ], fu = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
3739
+ ], la = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
3739
3740
  if (n || t == null)
3740
3741
  return !0;
3741
3742
  switch (e) {
@@ -3750,9 +3751,9 @@ const Lr = [
3750
3751
  default:
3751
3752
  return !0;
3752
3753
  }
3753
- }, lu = (t, e, n, r, i, s, o) => {
3754
- const a = s.valueType === "json", u = (c, d, f) => {
3755
- if (!qi(f, d, a))
3754
+ }, ha = (t, e, n, r, i, s, o) => {
3755
+ const u = s.valueType === "json", a = (c, d, f) => {
3756
+ if (!qi(f, d, u))
3756
3757
  throw new R(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
3757
3758
  };
3758
3759
  switch (t) {
@@ -3761,7 +3762,7 @@ const Lr = [
3761
3762
  if (!Array.isArray(e))
3762
3763
  throw new R(`Operator '${t}' for attribute '${r}' in entity '${i}' must be an array, but received: ${typeof e}`, o);
3763
3764
  for (const c of e)
3764
- u(t, n, c);
3765
+ a(t, n, c);
3765
3766
  break;
3766
3767
  case "$not":
3767
3768
  case "$ne":
@@ -3769,30 +3770,30 @@ const Lr = [
3769
3770
  case "$lt":
3770
3771
  case "$gte":
3771
3772
  case "$lte":
3772
- u(t, n, e);
3773
+ a(t, n, e);
3773
3774
  break;
3774
3775
  case "$like":
3775
3776
  case "$ilike":
3776
- if (u(t, "string", e), t === "$ilike" && !s.isIndexed)
3777
+ if (a(t, "string", e), t === "$ilike" && !s.isIndexed)
3777
3778
  throw new R(`Operator '${t}' can only be used with indexed attributes, but '${r}' in entity '${i}' is not indexed`, o);
3778
3779
  break;
3779
3780
  case "$isNull":
3780
- u(t, "boolean", e);
3781
+ a(t, "boolean", e);
3781
3782
  break;
3782
3783
  default:
3783
3784
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
3784
3785
  }
3785
3786
  }, Le = (t, e, n, r, i) => {
3786
- const s = fu(n), o = n.valueType === "json";
3787
+ const s = la(n), o = n.valueType === "json";
3787
3788
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3788
3789
  if (o)
3789
3790
  return;
3790
- const u = t;
3791
- for (const [c, d] of Object.entries(u))
3792
- lu(c, d, s, e, r, n, `${i}.${c}`);
3791
+ const a = t;
3792
+ for (const [c, d] of Object.entries(a))
3793
+ ha(c, d, s, e, r, n, `${i}.${c}`);
3793
3794
  } else if (!qi(t, s, o))
3794
3795
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3795
- }, hu = (t, e, n, r, i) => {
3796
+ }, pa = (t, e, n, r, i) => {
3796
3797
  const s = t.split(".");
3797
3798
  if (s.length < 2)
3798
3799
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -3808,25 +3809,25 @@ const Lr = [
3808
3809
  }
3809
3810
  o = p.entityName;
3810
3811
  }
3811
- const a = s[s.length - 1], u = r.entities[o];
3812
- if (!u)
3812
+ const u = s[s.length - 1], a = r.entities[o];
3813
+ if (!a)
3813
3814
  throw new R(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, i);
3814
- if (a === "id") {
3815
+ if (u === "id") {
3815
3816
  if (typeof e == "string" && !Ne(e))
3816
3817
  throw new R(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3817
3818
  Le(e, t, new H("string", !1, !0), n, i);
3818
3819
  return;
3819
3820
  }
3820
- const c = u.attrs[a];
3821
- if (Object.keys(u.links).includes(a)) {
3821
+ const c = a.attrs[u];
3822
+ if (Object.keys(a.links).includes(u)) {
3822
3823
  if (typeof e == "string" && !Ne(e))
3823
- throw new R(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3824
+ throw new R(`Invalid value for link '${u}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3824
3825
  Le(e, t, new H("string", !1, !0), n, i);
3825
3826
  return;
3826
3827
  }
3827
3828
  if (!c) {
3828
- const d = Object.keys(u.attrs);
3829
- 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);
3829
+ const d = Object.keys(a.attrs);
3830
+ 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);
3830
3831
  }
3831
3832
  Le(e, t, c, n, i);
3832
3833
  }, Wi = (t, e, n, r) => {
@@ -3842,27 +3843,27 @@ const Lr = [
3842
3843
  continue;
3843
3844
  }
3844
3845
  if (i.includes(".")) {
3845
- hu(i, s, e, n, `${r}.${i}`);
3846
+ pa(i, s, e, n, `${r}.${i}`);
3846
3847
  continue;
3847
3848
  }
3848
3849
  const o = n.entities[e];
3849
3850
  if (!o)
3850
3851
  continue;
3851
- const a = o.attrs[i], u = o.links[i];
3852
- if (!a && !u) {
3852
+ const u = o.attrs[i], a = o.links[i];
3853
+ if (!u && !a) {
3853
3854
  const c = Object.keys(o.attrs), d = Object.keys(o.links);
3854
3855
  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}`);
3855
3856
  }
3856
- if (a)
3857
- Le(s, i, a, e, `${r}.${i}`);
3858
- else if (u) {
3857
+ if (u)
3858
+ Le(s, i, u, e, `${r}.${i}`);
3859
+ else if (a) {
3859
3860
  if (typeof s == "string" && !Ne(s))
3860
3861
  throw new R(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${s}`, `${r}.${i}`);
3861
3862
  const c = new H("string", !1, !0);
3862
3863
  Le(s, i, c, e, `${r}.${i}`);
3863
3864
  }
3864
3865
  }
3865
- }, pu = (t, e, n, r, i = 0) => {
3866
+ }, ya = (t, e, n, r, i = 0) => {
3866
3867
  for (const o of Object.keys(t))
3867
3868
  if (!Lr.includes(o))
3868
3869
  throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Lr.join(", ")}. Found: ${o}`, r);
@@ -3889,19 +3890,19 @@ const Lr = [
3889
3890
  for (const o of Object.keys(t))
3890
3891
  if (o !== "$") {
3891
3892
  if (n && !(o in n.entities[e].links)) {
3892
- const u = Object.keys(n.entities[e].links);
3893
- throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${u.length > 0 ? u.join(", ") : "none"}`, `${r}.${o}`);
3893
+ const a = Object.keys(n.entities[e].links);
3894
+ throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${a.length > 0 ? a.join(", ") : "none"}`, `${r}.${o}`);
3894
3895
  }
3895
- const a = t[o];
3896
- if (typeof a == "object" && a !== null) {
3897
- const u = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3898
- u && zi(a, u, n, `${r}.${o}`, i + 1);
3896
+ const u = t[o];
3897
+ if (typeof u == "object" && u !== null) {
3898
+ const a = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3899
+ a && zi(u, a, n, `${r}.${o}`, i + 1);
3899
3900
  }
3900
3901
  } else {
3901
- const a = t[o];
3902
- if (typeof a != "object" || a === null)
3903
- throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3904
- pu(a, e, n, `${r}.$`, i);
3902
+ const u = t[o];
3903
+ if (typeof u != "object" || u === null)
3904
+ throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
3905
+ ya(u, e, n, `${r}.$`, i);
3905
3906
  }
3906
3907
  }, Fr = (t, e) => {
3907
3908
  if (typeof t != "object" || t === null)
@@ -3928,19 +3929,19 @@ class ie extends Error {
3928
3929
  super(e), this.name = "TransactionValidationError";
3929
3930
  }
3930
3931
  }
3931
- 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 = {
3932
+ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Vi(e)}`), Kr = {
3932
3933
  string: (t) => typeof t == "string",
3933
3934
  number: (t) => typeof t == "number" && !isNaN(t),
3934
3935
  boolean: (t) => typeof t == "boolean",
3935
3936
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3936
3937
  json: () => !0
3937
- }, bu = (t, e) => {
3938
+ }, _a = (t, e) => {
3938
3939
  var n, r;
3939
3940
  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;
3940
3941
  }, Bi = (t, e) => {
3941
3942
  const n = e.entities[t];
3942
3943
  if (!n)
3943
- throw yu(t, Object.keys(e.entities));
3944
+ throw ba(t, Object.keys(e.entities));
3944
3945
  return n;
3945
3946
  }, Yt = (t, e, n) => {
3946
3947
  const r = Bi(t, n);
@@ -3950,7 +3951,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3950
3951
  if (i === "id")
3951
3952
  continue;
3952
3953
  const o = r.attrs[i];
3953
- if (o && !bu(s, o))
3954
+ if (o && !_a(s, o))
3954
3955
  throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
3955
3956
  }
3956
3957
  }, qr = (t, e, n) => {
@@ -3959,19 +3960,19 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3959
3960
  throw new ie(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
3960
3961
  for (const [i, s] of Object.entries(e)) {
3961
3962
  if (!r.links[i]) {
3962
- const a = Object.keys(r.links);
3963
- throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Vi(a)}`);
3963
+ const u = Object.keys(r.links);
3964
+ throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Vi(u)}`);
3964
3965
  }
3965
3966
  if (s != null) {
3966
3967
  if (Array.isArray(s)) {
3967
- for (const a of s)
3968
- if (!Nr(a))
3969
- throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
3968
+ for (const u of s)
3969
+ if (!Nr(u))
3970
+ throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${u}`);
3970
3971
  } else if (!Nr(s))
3971
3972
  throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
3972
3973
  }
3973
3974
  }
3974
- }, _u = {
3975
+ }, ga = {
3975
3976
  create: Yt,
3976
3977
  update: Yt,
3977
3978
  merge: Yt,
@@ -3979,7 +3980,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3979
3980
  unlink: qr,
3980
3981
  delete: () => {
3981
3982
  }
3982
- }, gu = (t, e) => {
3983
+ }, wa = (t, e) => {
3983
3984
  if (!e)
3984
3985
  return;
3985
3986
  const [n, r, i, s] = t;
@@ -3987,9 +3988,9 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3987
3988
  throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
3988
3989
  if (typeof r != "string")
3989
3990
  throw new ie(`Entity name must be a string, but received: ${typeof r}`);
3990
- const o = _u[n];
3991
+ const o = ga[n];
3991
3992
  o && s !== void 0 && o(r, s, e);
3992
- }, wu = (t, e) => {
3993
+ }, Ta = (t, e) => {
3993
3994
  const n = Array.isArray(t) ? t : [t];
3994
3995
  for (const r of n) {
3995
3996
  if (!r || typeof r != "object")
@@ -3999,7 +4000,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
3999
4000
  for (const i of r.__ops) {
4000
4001
  if (!Array.isArray(i))
4001
4002
  throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
4002
- gu(i, e);
4003
+ wa(i, e);
4003
4004
  }
4004
4005
  }
4005
4006
  };
@@ -4010,14 +4011,14 @@ var Wr = function(t, e, n, r) {
4010
4011
  });
4011
4012
  }
4012
4013
  return new (n || (n = Promise))(function(s, o) {
4013
- function a(d) {
4014
+ function u(d) {
4014
4015
  try {
4015
4016
  c(r.next(d));
4016
4017
  } catch (f) {
4017
4018
  o(f);
4018
4019
  }
4019
4020
  }
4020
- function u(d) {
4021
+ function a(d) {
4021
4022
  try {
4022
4023
  c(r.throw(d));
4023
4024
  } catch (f) {
@@ -4025,7 +4026,7 @@ var Wr = function(t, e, n, r) {
4025
4026
  }
4026
4027
  }
4027
4028
  function c(d) {
4028
- d.done ? s(d.value) : i(d.value).then(a, u);
4029
+ d.done ? s(d.value) : i(d.value).then(u, a);
4029
4030
  }
4030
4031
  c((r = r.apply(t, e || [])).next());
4031
4032
  });
@@ -4061,7 +4062,7 @@ class zr {
4061
4062
  return this.conn.send(JSON.stringify(e));
4062
4063
  }
4063
4064
  }
4064
- class Tu {
4065
+ class ma {
4065
4066
  constructor(e, n) {
4066
4067
  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(() => {
4067
4068
  this.initParams || this.handleError();
@@ -4154,14 +4155,14 @@ var Vr = function(t, e, n, r) {
4154
4155
  });
4155
4156
  }
4156
4157
  return new (n || (n = Promise))(function(s, o) {
4157
- function a(d) {
4158
+ function u(d) {
4158
4159
  try {
4159
4160
  c(r.next(d));
4160
4161
  } catch (f) {
4161
4162
  o(f);
4162
4163
  }
4163
4164
  }
4164
- function u(d) {
4165
+ function a(d) {
4165
4166
  try {
4166
4167
  c(r.throw(d));
4167
4168
  } catch (f) {
@@ -4169,12 +4170,12 @@ var Vr = function(t, e, n, r) {
4169
4170
  }
4170
4171
  }
4171
4172
  function c(d) {
4172
- d.done ? s(d.value) : i(d.value).then(a, u);
4173
+ d.done ? s(d.value) : i(d.value).then(u, a);
4173
4174
  }
4174
4175
  c((r = r.apply(t, e || [])).next());
4175
4176
  });
4176
4177
  };
4177
- function mu(t, e) {
4178
+ function va(t, e) {
4178
4179
  const n = t.values;
4179
4180
  if (n) {
4180
4181
  const r = mi(n.attrsStore, null);
@@ -4186,7 +4187,7 @@ function mu(t, e) {
4186
4187
  }
4187
4188
  return t;
4188
4189
  }
4189
- function vu(t, e) {
4190
+ function Sa(t, e) {
4190
4191
  var n;
4191
4192
  if (e.values) {
4192
4193
  const r = [];
@@ -4198,7 +4199,7 @@ function vu(t, e) {
4198
4199
  } else
4199
4200
  return e;
4200
4201
  }
4201
- function Su(t, e, n) {
4202
+ function Oa(t, e, n) {
4202
4203
  var r, i;
4203
4204
  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;
4204
4205
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
@@ -4225,17 +4226,17 @@ function Gr(t, e, n) {
4225
4226
  break;
4226
4227
  }
4227
4228
  }
4228
- function Ou(t, e, n) {
4229
+ function Ea(t, e, n) {
4229
4230
  var r, i, s, o;
4230
- const a = {};
4231
- for (const { action: u, triple: c } of n) {
4231
+ const u = {};
4232
+ for (const { action: a, triple: c } of n) {
4232
4233
  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];
4233
4234
  if (!p)
4234
4235
  continue;
4235
- const y = (s = a[d]) !== null && s !== void 0 ? s : {};
4236
- a[d] = y;
4236
+ const y = (s = u[d]) !== null && s !== void 0 ? s : {};
4237
+ u[d] = y;
4237
4238
  const b = (o = y[p]) !== null && o !== void 0 ? o : {};
4238
- switch (y[p] = b, u) {
4239
+ switch (y[p] = b, a) {
4239
4240
  case "added":
4240
4241
  b.newValue = l;
4241
4242
  break;
@@ -4244,53 +4245,53 @@ function Ou(t, e, n) {
4244
4245
  break;
4245
4246
  }
4246
4247
  }
4247
- for (const u of Object.keys(a)) {
4248
- const { oldValue: c, newValue: d } = a[u];
4249
- c === d && delete a[u];
4248
+ for (const a of Object.keys(u)) {
4249
+ const { oldValue: c, newValue: d } = u[a];
4250
+ c === d && delete u[a];
4250
4251
  }
4251
- return a;
4252
+ return u;
4252
4253
  }
4253
4254
  function Tt(t, e) {
4254
4255
  return { [t.table]: e.map((n) => n.entity) };
4255
4256
  }
4256
- function Eu(t, e) {
4257
+ function Aa(t, e) {
4257
4258
  var n;
4258
4259
  if (t.orderFieldType)
4259
4260
  return t.orderFieldType;
4260
4261
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = K(e(), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4261
4262
  return t.orderFieldType = r, r;
4262
4263
  }
4263
- function Au(t, e, n) {
4264
+ function ka(t, e, n) {
4264
4265
  const r = e;
4265
4266
  if (t.orderField === "serverCreatedAt") {
4266
- n.sort(t.orderDirection === "asc" ? function(o, a) {
4267
- return Ze(o.entity.id, o.serverCreatedAt, a.entity.id, a.serverCreatedAt, r);
4268
- } : function(o, a) {
4269
- return Ze(a.entity.id, a.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
4267
+ n.sort(t.orderDirection === "asc" ? function(o, u) {
4268
+ return Ze(o.entity.id, o.serverCreatedAt, u.entity.id, u.serverCreatedAt, r);
4269
+ } : function(o, u) {
4270
+ return Ze(u.entity.id, u.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
4270
4271
  });
4271
4272
  return;
4272
4273
  }
4273
4274
  const i = t.orderField;
4274
- n.sort(t.orderDirection === "asc" ? function(o, a) {
4275
- return Ze(o.entity.id, o.entity[i], a.entity.id, a.entity[i], r);
4276
- } : function(o, a) {
4277
- return Ze(a.entity.id, a.entity[i], o.entity.id, o.entity[i], r);
4275
+ n.sort(t.orderDirection === "asc" ? function(o, u) {
4276
+ return Ze(o.entity.id, o.entity[i], u.entity.id, u.entity[i], r);
4277
+ } : function(o, u) {
4278
+ return Ze(u.entity.id, u.entity[i], o.entity.id, o.entity[i], r);
4278
4279
  });
4279
4280
  }
4280
4281
  var ve;
4281
4282
  (function(t) {
4282
4283
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4283
4284
  })(ve || (ve = {}));
4284
- class ku {
4285
+ class ja {
4285
4286
  constructor(e, n, r, i, s, o) {
4286
4287
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.getAttrs = o, this.subs = new _n({
4287
4288
  persister: n,
4288
- merge: Su,
4289
- serialize: vu,
4290
- parse: (a, u) => mu(u, this.config.useDateObjects),
4291
- objectSize: (a) => {
4292
- var u;
4293
- return ((u = a.values) === null || u === void 0 ? void 0 : u.entities.length) || 0;
4289
+ merge: Oa,
4290
+ serialize: Sa,
4291
+ parse: (u, a) => va(a, this.config.useDateObjects),
4292
+ objectSize: (u) => {
4293
+ var a;
4294
+ return ((a = u.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
4294
4295
  },
4295
4296
  logger: i,
4296
4297
  gc: {
@@ -4345,17 +4346,17 @@ class ku {
4345
4346
  }
4346
4347
  initSubscription(e, n, r) {
4347
4348
  return Vr(this, void 0, void 0, function* () {
4348
- var i, s, o, a;
4349
+ var i, s, o, u;
4349
4350
  yield this.subs.waitForKeyToLoad(n);
4350
- const u = this.subs.currentValue[n];
4351
- if (u && u.state && u.state.txId) {
4352
- this.sendResync(u, u.state, u.state.txId), !((i = u.values) === null || i === void 0) && i.entities && r && r({
4351
+ const a = this.subs.currentValue[n];
4352
+ if (a && a.state && a.state.txId) {
4353
+ this.sendResync(a, a.state, a.state.txId), !((i = a.values) === null || i === void 0) && i.entities && r && r({
4353
4354
  type: ve.LoadFromStorage,
4354
- data: Tt(u, (s = u.values) === null || s === void 0 ? void 0 : s.entities)
4355
+ data: Tt(a, (s = a.values) === null || s === void 0 ? void 0 : s.entities)
4355
4356
  });
4356
4357
  return;
4357
4358
  }
4358
- 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];
4359
+ 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];
4359
4360
  this.subs.updateInPlace((p) => {
4360
4361
  p[n] = {
4361
4362
  query: e,
@@ -4401,30 +4402,30 @@ class ku {
4401
4402
  this.log.error("Missing hash for subscription", e);
4402
4403
  return;
4403
4404
  }
4404
- const o = [], a = this.subs.currentValue[s];
4405
- if (!a) {
4405
+ const o = [], u = this.subs.currentValue[s];
4406
+ if (!u) {
4406
4407
  this.log.error("Missing sub for hash", s, e);
4407
4408
  return;
4408
4409
  }
4409
- const u = (n = a.values) !== null && n !== void 0 ? n : {
4410
+ const a = (n = u.values) !== null && n !== void 0 ? n : {
4410
4411
  entities: [],
4411
4412
  attrsStore: this.getAttrs()
4412
4413
  };
4413
- a.values = u;
4414
- const c = u.entities;
4414
+ u.values = a;
4415
+ const c = a.entities;
4415
4416
  for (const d of i) {
4416
- const f = this.createStore(d), l = Jt(a, f, u.attrsStore);
4417
+ const f = this.createStore(d), l = Jt(u, f, a.attrsStore);
4417
4418
  c.push({
4418
4419
  store: f,
4419
4420
  entity: l,
4420
- serverCreatedAt: Br(a, f, u.attrsStore, l.id)
4421
+ serverCreatedAt: Br(u, f, a.attrsStore, l.id)
4421
4422
  }), o.push(l);
4422
4423
  }
4423
4424
  this.subs.updateInPlace((d) => {
4424
- d[s] = a, d[s].updatedAt = Date.now();
4425
- }), a.values && this.notifyCbs(s, {
4425
+ d[s] = u, d[s].updatedAt = Date.now();
4426
+ }), u.values && this.notifyCbs(s, {
4426
4427
  type: ve.InitialSyncBatch,
4427
- data: Tt(a, a.values.entities),
4428
+ data: Tt(u, u.values.entities),
4428
4429
  batch: o
4429
4430
  });
4430
4431
  }
@@ -4436,15 +4437,15 @@ class ku {
4436
4437
  return;
4437
4438
  }
4438
4439
  this.subs.updateInPlace((o) => {
4439
- const a = o[i];
4440
- if (!a) {
4440
+ const u = o[i];
4441
+ if (!u) {
4441
4442
  this.log.error("Missing sub for hash", i, e);
4442
4443
  return;
4443
4444
  }
4444
- const u = a.state;
4445
- if (!u)
4446
- return this.log.error("Sub never set init, missing result", a, e), o;
4447
- u.txId = e["tx-id"], a.updatedAt = Date.now();
4445
+ const a = u.state;
4446
+ if (!a)
4447
+ return this.log.error("Sub never set init, missing result", u, e), o;
4448
+ a.txId = e["tx-id"], u.updatedAt = Date.now();
4448
4449
  });
4449
4450
  const s = this.subs.currentValue[i];
4450
4451
  s && this.notifyCbs(i, {
@@ -4459,37 +4460,37 @@ class ku {
4459
4460
  this.log.error("Missing hash for subscription", e);
4460
4461
  return;
4461
4462
  }
4462
- const a = this.subs.currentValue[o];
4463
- if (!a) {
4463
+ const u = this.subs.currentValue[o];
4464
+ if (!u) {
4464
4465
  this.log.error("Missing sub for hash", o, e);
4465
4466
  return;
4466
4467
  }
4467
- const u = a.state;
4468
- if (!u) {
4469
- this.log.error("Missing state for sub", a, e);
4468
+ const a = u.state;
4469
+ if (!a) {
4470
+ this.log.error("Missing state for sub", u, e);
4470
4471
  return;
4471
4472
  }
4472
4473
  for (const c of e.txes) {
4473
- if (u.txId && u.txId >= c["tx-id"])
4474
+ if (a.txId && a.txId >= c["tx-id"])
4474
4475
  continue;
4475
- u.txId = c["tx-id"];
4476
+ a.txId = c["tx-id"];
4476
4477
  const d = [], f = {};
4477
4478
  for (const g of c.changes) {
4478
4479
  const m = (n = f[g.triple[0]]) !== null && n !== void 0 ? n : [];
4479
4480
  f[g.triple[0]] = m, m.push(g);
4480
4481
  }
4481
- const l = (r = a.values) !== null && r !== void 0 ? r : {
4482
+ const l = (r = u.values) !== null && r !== void 0 ? r : {
4482
4483
  entities: [],
4483
4484
  attrsStore: this.getAttrs()
4484
4485
  }, p = l.entities;
4485
- a.values = l;
4486
+ u.values = l;
4486
4487
  const y = [];
4487
4488
  e: for (const [g, m] of Object.entries(f))
4488
4489
  for (let O = 0; O < p.length; O++) {
4489
4490
  const S = p[O];
4490
4491
  if (io(S.store, g)) {
4491
4492
  Gr(S.store, l.attrsStore, m);
4492
- const C = Jt(a, S.store, l.attrsStore), $ = Ou(S.store, l.attrsStore, m)[g];
4493
+ const C = Jt(u, S.store, l.attrsStore), $ = Ea(S.store, l.attrsStore, m)[g];
4493
4494
  C ? (y.push({
4494
4495
  oldEntity: S.entity,
4495
4496
  newEntity: C,
@@ -4502,10 +4503,10 @@ class ku {
4502
4503
  for (const [g, m] of Object.entries(f)) {
4503
4504
  const O = this.createStore([]);
4504
4505
  Gr(O, l.attrsStore, m);
4505
- const S = Jt(a, O, l.attrsStore);
4506
+ const S = Jt(u, O, l.attrsStore);
4506
4507
  if (!S) {
4507
4508
  this.log.error("No entity found after applying change", {
4508
- sub: a,
4509
+ sub: u,
4509
4510
  changes: m,
4510
4511
  store: O
4511
4512
  });
@@ -4514,23 +4515,23 @@ class ku {
4514
4515
  p.push({
4515
4516
  store: O,
4516
4517
  entity: S,
4517
- serverCreatedAt: Br(a, O, l.attrsStore, S.id)
4518
+ serverCreatedAt: Br(u, O, l.attrsStore, S.id)
4518
4519
  }), b.push(S);
4519
4520
  }
4520
4521
  const _ = [];
4521
4522
  for (const g of d.sort().reverse())
4522
4523
  _.push(p[g].entity), p.splice(g, 1);
4523
- const T = Eu(a, this.getAttrs);
4524
- Au(a, T, p), this.notifyCbs(o, {
4524
+ const T = Aa(u, this.getAttrs);
4525
+ ka(u, T, p), this.notifyCbs(o, {
4525
4526
  type: ve.SyncTransaction,
4526
- data: Tt(a, (i = a.values) === null || i === void 0 ? void 0 : i.entities),
4527
+ data: Tt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
4527
4528
  added: b,
4528
4529
  removed: _,
4529
4530
  updated: y
4530
4531
  });
4531
4532
  }
4532
4533
  this.subs.updateInPlace((c) => {
4533
- c[o] = a, c[o].updatedAt = Date.now();
4534
+ c[o] = u, c[o].updatedAt = Date.now();
4534
4535
  });
4535
4536
  }
4536
4537
  clearSubscriptionData(e, n) {
@@ -4569,14 +4570,14 @@ var N = function(t, e, n, r) {
4569
4570
  });
4570
4571
  }
4571
4572
  return new (n || (n = Promise))(function(s, o) {
4572
- function a(d) {
4573
+ function u(d) {
4573
4574
  try {
4574
4575
  c(r.next(d));
4575
4576
  } catch (f) {
4576
4577
  o(f);
4577
4578
  }
4578
4579
  }
4579
- function u(d) {
4580
+ function a(d) {
4580
4581
  try {
4581
4582
  c(r.throw(d));
4582
4583
  } catch (f) {
@@ -4584,7 +4585,7 @@ var N = function(t, e, n, r) {
4584
4585
  }
4585
4586
  }
4586
4587
  function c(d) {
4587
- d.done ? s(d.value) : i(d.value).then(a, u);
4588
+ d.done ? s(d.value) : i(d.value).then(u, a);
4588
4589
  }
4589
4590
  c((r = r.apply(t, e || [])).next());
4590
4591
  });
@@ -4602,23 +4603,23 @@ const he = {
4602
4603
  AUTHENTICATED: "authenticated",
4603
4604
  CLOSED: "closed",
4604
4605
  ERRORED: "errored"
4605
- }, ju = 3e4, Cu = 3e4, Iu = 200, Pu = {
4606
+ }, Ca = 3e4, Ia = 3e4, Pa = 200, Ma = {
4606
4607
  apiURI: "https://api.instantdb.com",
4607
4608
  websocketURI: "wss://api.instantdb.com/runtime/session"
4608
4609
  }, Zt = "_instant_oauth_redirect", Ge = "currentUser";
4609
- function Mu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4610
+ function Ra({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4610
4611
  if (!i)
4611
4612
  return new zr(`${r}?app_id=${e}`);
4612
4613
  switch (t) {
4613
4614
  case "ws":
4614
4615
  return new zr(`${r}?app_id=${e}`);
4615
4616
  case "sse":
4616
- return new Tu(i, `${n}/runtime/sse?app_id=${e}`);
4617
+ return new ma(i, `${n}/runtime/sse?app_id=${e}`);
4617
4618
  default:
4618
4619
  throw new Error("Unknown transport type " + t);
4619
4620
  }
4620
4621
  }
4621
- function Ru() {
4622
+ function xa() {
4622
4623
  return typeof window < "u" || typeof chrome < "u";
4623
4624
  }
4624
4625
  const Qr = {
@@ -4627,7 +4628,7 @@ const Qr = {
4627
4628
  "refresh-presence": !0,
4628
4629
  "patch-presence": !0
4629
4630
  };
4630
- function xu(t, e) {
4631
+ function $a(t, e) {
4631
4632
  var n;
4632
4633
  const r = typeof t == "string" ? JSON.parse(t) : t;
4633
4634
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
@@ -4639,7 +4640,7 @@ function xu(t, e) {
4639
4640
  }
4640
4641
  return r;
4641
4642
  }
4642
- function $u(t, e) {
4643
+ function Da(t, e) {
4643
4644
  const { result: n } = e, i = Qi(e, ["result"]);
4644
4645
  if (n) {
4645
4646
  const s = Object.assign(Object.assign({}, n), { store: wi(n.store), attrsStore: n.attrsStore.toJSON() });
@@ -4647,7 +4648,7 @@ function $u(t, e) {
4647
4648
  }
4648
4649
  return i;
4649
4650
  }
4650
- function Du(t, e) {
4651
+ function Ua(t, e) {
4651
4652
  switch (t) {
4652
4653
  case "pendingMutations":
4653
4654
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4655,7 +4656,7 @@ function Du(t, e) {
4655
4656
  return e;
4656
4657
  }
4657
4658
  }
4658
- function Uu(t, e) {
4659
+ function La(t, e) {
4659
4660
  switch (t) {
4660
4661
  case "pendingMutations":
4661
4662
  return [...e.entries()];
@@ -4663,19 +4664,19 @@ function Uu(t, e) {
4663
4664
  return e;
4664
4665
  }
4665
4666
  }
4666
- function Lu(t, e, n) {
4667
+ function Fa(t, e, n) {
4667
4668
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
4668
4669
  return r && !i && n && (n.result = r), n || e;
4669
4670
  }
4670
4671
  function Hr(t) {
4671
4672
  return [...t].sort((e, n) => {
4672
- const [r, i] = e, [s, o] = n, a = i.order || 0, u = o.order || 0;
4673
- return a == u ? r < s ? -1 : r > s ? 1 : 0 : a - u;
4673
+ const [r, i] = e, [s, o] = n, u = i.order || 0, a = o.order || 0;
4674
+ return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
4674
4675
  });
4675
4676
  }
4676
- class Fu {
4677
+ class Na {
4677
4678
  constructor(e, n = Ui, r = Li, i, s) {
4678
- var o, a, u;
4679
+ var o, u, a;
4679
4680
  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) => {
4680
4681
  var l, p;
4681
4682
  switch (c) {
@@ -4706,9 +4707,9 @@ class Fu {
4706
4707
  }, this.notifyQueryError = (c, d) => {
4707
4708
  (this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
4708
4709
  }, this.pushTx = (c) => {
4709
- this.config.disableValidation || wu(c, this.config.schema);
4710
+ this.config.disableValidation || Ta(c, this.config.schema);
4710
4711
  try {
4711
- const d = Ka({
4712
+ const d = qu({
4712
4713
  attrsStore: this.optimisticAttrs(),
4713
4714
  schema: this.config.schema,
4714
4715
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4797,7 +4798,7 @@ class Fu {
4797
4798
  return;
4798
4799
  }
4799
4800
  this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4800
- }, 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()) {
4801
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Ma), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Ia, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Pa, this._log = fa(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)), !!xa()) {
4801
4802
  if (!e.appId)
4802
4803
  throw new Error("Instant must be initialized with an appId.");
4803
4804
  if (!Ne(e.appId))
@@ -4812,7 +4813,7 @@ class Fu {
4812
4813
  } catch (f) {
4813
4814
  this._log.error("[error] handle broadcast channel", f);
4814
4815
  }
4815
- }))), this._initStorage(n), this._syncTable = new ku(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4816
+ }))), this._initStorage(n), this._syncTable = new ja(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4816
4817
  useDateObjects: this.config.useDateObjects
4817
4818
  }, 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) => {
4818
4819
  this._isOnline = c, this._startSocket(), r.listen((d) => {
@@ -4842,9 +4843,9 @@ class Fu {
4842
4843
  _initStorage(e) {
4843
4844
  this.querySubs = new _n({
4844
4845
  persister: new e(this.config.appId, "querySubs"),
4845
- merge: Lu,
4846
- serialize: $u,
4847
- parse: (n, r) => xu(r, this.config.useDateObjects),
4846
+ merge: Fa,
4847
+ serialize: Da,
4848
+ parse: (n, r) => $a(r, this.config.useDateObjects),
4848
4849
  // objectSize
4849
4850
  objectSize: (n) => {
4850
4851
  var r, i, s, o;
@@ -4863,8 +4864,8 @@ class Fu {
4863
4864
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new _n({
4864
4865
  persister: new e(this.config.appId, "kv"),
4865
4866
  merge: this._onMergeKv,
4866
- serialize: Uu,
4867
- parse: Du,
4867
+ serialize: La,
4868
+ parse: Ua,
4868
4869
  objectSize: () => 0,
4869
4870
  logger: this._log,
4870
4871
  saveThrottleMs: 100,
@@ -4895,10 +4896,10 @@ class Fu {
4895
4896
  if (s)
4896
4897
  i.resolve({ status: e, eventId: n });
4897
4898
  else if (r != null && r.type) {
4898
- const { status: o } = r, a = Qi(r, ["status"]);
4899
+ const { status: o } = r, u = Qi(r, ["status"]);
4899
4900
  i.reject(new Dt({
4900
4901
  // @ts-expect-error body.type is not constant typed
4901
- body: a,
4902
+ body: u,
4902
4903
  status: o ?? 0
4903
4904
  }));
4904
4905
  } else
@@ -4912,12 +4913,12 @@ class Fu {
4912
4913
  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];
4913
4914
  if (this._broadcastQueue[e] = [], i && this._trySetPresence(e, i), s)
4914
4915
  for (const o of s) {
4915
- const { topic: a, roomType: u, data: c } = o;
4916
- this._tryBroadcast(e, u, a, c);
4916
+ const { topic: u, roomType: a, data: c } = o;
4917
+ this._tryBroadcast(e, a, u, c);
4917
4918
  }
4918
4919
  }
4919
4920
  _handleReceive(e, n) {
4920
- var r, i, s, o, a, u;
4921
+ var r, i, s, o, u, a;
4921
4922
  const c = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4922
4923
  switch (Qr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4923
4924
  case "init-ok": {
@@ -4936,7 +4937,7 @@ class Fu {
4936
4937
  const { q: l, result: p } = n, y = B(l);
4937
4938
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
4938
4939
  break;
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"], _ = (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 = this.ensureAttrs(), m = Et(g, T, c, this.config.useDateObjects);
4940
+ 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
4941
  this.querySubs.updateInPlace((O) => {
4941
4942
  if (!O[y]) {
4942
4943
  this._log.info("Missing value in querySubs", { hash: y, q: l });
@@ -5097,7 +5098,7 @@ class Fu {
5097
5098
  }
5098
5099
  }
5099
5100
  _handleReceiveError(e) {
5100
- var n, r, i, s, o, a, u;
5101
+ var n, r, i, s, o, u, a;
5101
5102
  console.log("error", e);
5102
5103
  const c = e["client-event-id"];
5103
5104
  this._inFlightMutationEventIds.delete(c);
@@ -5121,11 +5122,11 @@ class Fu {
5121
5122
  this._setStatus(he.ERRORED, f), this.notifyAll();
5122
5123
  return;
5123
5124
  }
5124
- if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "resync-table") {
5125
+ if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "resync-table") {
5125
5126
  this._syncTable.onResyncError(e);
5126
5127
  return;
5127
5128
  }
5128
- if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "start-sync") {
5129
+ if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "start-sync") {
5129
5130
  this._syncTable.onStartSyncError(e);
5130
5131
  return;
5131
5132
  }
@@ -5135,7 +5136,7 @@ class Fu {
5135
5136
  }
5136
5137
  notifyQueryOnceError(e, n, r, i) {
5137
5138
  var s;
5138
- const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((a) => a.eventId === r);
5139
+ const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((u) => u.eventId === r);
5139
5140
  o && (o.dfd.reject(i), this._completeQueryOnce(e, n, o.dfd));
5140
5141
  }
5141
5142
  _setAttrs(e) {
@@ -5177,7 +5178,7 @@ class Fu {
5177
5178
  if (!this.querySubs)
5178
5179
  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;
5179
5180
  const s = B(e), o = this._startQuerySub(e, s);
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")), ju), i.promise;
5181
+ 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")), Ca), i.promise;
5181
5182
  }
5182
5183
  _completeQueryOnce(e, n, r) {
5183
5184
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5221,37 +5222,37 @@ class Fu {
5221
5222
  const [f, l, p] = d["forward-identity"];
5222
5223
  return Ie(e, l, p);
5223
5224
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
5224
- let a = !1;
5225
- const u = (d, f) => {
5225
+ let u = !1;
5226
+ const a = (d, f) => {
5226
5227
  const l = [];
5227
5228
  for (const p of d) {
5228
5229
  const [y] = p;
5229
5230
  if (y === "add-attr") {
5230
5231
  const [_, T] = p, g = i(T);
5231
5232
  if (g && T.id !== g.id) {
5232
- o.attrIdMap[T.id] = g.id, a = !0;
5233
+ o.attrIdMap[T.id] = g.id, u = !0;
5233
5234
  continue;
5234
5235
  }
5235
5236
  if (T["value-type"] === "ref") {
5236
5237
  const m = s(T);
5237
5238
  if (m) {
5238
- o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), a = !0;
5239
+ o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), u = !0;
5239
5240
  continue;
5240
5241
  }
5241
5242
  }
5242
5243
  }
5243
5244
  if (r && f && r >= f && y === "add-attr" || y === "update-attr" || y === "delete-attr") {
5244
- a = !0;
5245
+ u = !0;
5245
5246
  continue;
5246
5247
  }
5247
- const b = a ? ba(o, p) : p;
5248
+ const b = u ? _u(o, p) : p;
5248
5249
  l.push(b);
5249
5250
  }
5250
- return a ? l : d;
5251
+ return u ? l : d;
5251
5252
  }, c = /* @__PURE__ */ new Map();
5252
5253
  for (const [d, f] of n.entries())
5253
- c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": u(f["tx-steps"], f["tx-id"]) }));
5254
- return a ? c : n;
5254
+ c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": a(f["tx-steps"], f["tx-id"]) }));
5255
+ return u ? c : n;
5255
5256
  }
5256
5257
  _rewriteMutationsSorted(e, n) {
5257
5258
  return Hr(this._rewriteMutations(e, n).entries());
@@ -5263,21 +5264,21 @@ class Fu {
5263
5264
  */
5264
5265
  optimisticAttrs() {
5265
5266
  var e, n;
5266
- 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 = [];
5267
- for (const [a, u] of r)
5268
- if (a === "add-attr")
5269
- s.push(u);
5270
- else if (a === "update-attr" && u.id && (!((e = this.attrs) === null || e === void 0) && e.getAttr(u.id))) {
5271
- const c = Object.assign(Object.assign({}, this.attrs.getAttr(u.id)), u);
5267
+ 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 = [];
5268
+ for (const [u, a] of r)
5269
+ if (u === "add-attr")
5270
+ s.push(a);
5271
+ else if (u === "update-attr" && a.id && (!((e = this.attrs) === null || e === void 0) && e.getAttr(a.id))) {
5272
+ const c = Object.assign(Object.assign({}, this.attrs.getAttr(a.id)), a);
5272
5273
  s.push(c);
5273
5274
  }
5274
5275
  if (!i.size && !s.length)
5275
5276
  return this.attrs || new Ae({}, this._linkIndex);
5276
5277
  const o = Object.assign({}, ((n = this.attrs) === null || n === void 0 ? void 0 : n.attrs) || {});
5277
- for (const a of s)
5278
- o[a.id] = a;
5279
- for (const a of i)
5280
- delete o[a];
5278
+ for (const u of s)
5279
+ o[u.id] = u;
5280
+ for (const u of i)
5281
+ delete o[u];
5281
5282
  return new Ae(o, this._linkIndex);
5282
5283
  }
5283
5284
  /** Runs instaql on a query and a store */
@@ -5287,20 +5288,20 @@ class Fu {
5287
5288
  return { error: n };
5288
5289
  if (!this.querySubs || !this.kv.currentValue.pendingMutations)
5289
5290
  return;
5290
- const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: a, result: u } = i[e] || {};
5291
- if (!u)
5291
+ const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: u, result: a } = i[e] || {};
5292
+ if (!a)
5292
5293
  return;
5293
5294
  const c = this._dataForQueryCache[e];
5294
5295
  if (c && r === c.querySubVersion && s === c.pendingMutationsVersion)
5295
5296
  return c;
5296
- 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);
5297
- return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p }, a), querySubVersion: r, pendingMutationsVersion: s };
5297
+ 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);
5298
+ return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p }, u), querySubVersion: r, pendingMutationsVersion: s };
5298
5299
  }
5299
5300
  _applyOptimisticUpdates(e, n, r, i) {
5300
5301
  for (const [s, o] of r)
5301
5302
  if (!o["tx-id"] || i && o["tx-id"] > i) {
5302
- const a = _o(e, n, o["tx-steps"]);
5303
- e = a.store, n = a.attrsStore;
5303
+ const u = _o(e, n, o["tx-steps"]);
5304
+ e = u.store, n = u.attrsStore;
5304
5305
  }
5305
5306
  return { store: e, attrsStore: n };
5306
5307
  }
@@ -5410,7 +5411,7 @@ class Fu {
5410
5411
  return;
5411
5412
  }
5412
5413
  const e = this._transport;
5413
- this._transport = Mu({
5414
+ this._transport = Ra({
5414
5415
  transportType: this._transportType,
5415
5416
  appId: this.config.appId,
5416
5417
  apiURI: this.config.apiURI,
@@ -5456,8 +5457,8 @@ class Fu {
5456
5457
  typeof navigation.removeEventListener == "function") {
5457
5458
  let i = !1;
5458
5459
  const s = (o) => {
5459
- var a;
5460
- 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));
5460
+ var u;
5461
+ 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));
5461
5462
  };
5462
5463
  navigation.addEventListener("navigate", s);
5463
5464
  }
@@ -5478,20 +5479,20 @@ class Fu {
5478
5479
  const o = s.get("error");
5479
5480
  if (o)
5480
5481
  return this._replaceUrlAfterOAuth(), { error: { message: o } };
5481
- const a = s.get("code");
5482
- if (!a)
5482
+ const u = s.get("code");
5483
+ if (!u)
5483
5484
  return null;
5484
5485
  this._replaceUrlAfterOAuth();
5485
5486
  try {
5486
- const u = yield this._getCurrentUser(), c = (u == null ? void 0 : u.type) === "guest", { user: d } = yield Rr({
5487
+ const a = yield this._getCurrentUser(), c = (a == null ? void 0 : a.type) === "guest", { user: d } = yield Rr({
5487
5488
  apiURI: this.config.apiURI,
5488
5489
  appId: this.config.appId,
5489
- code: a,
5490
- refreshToken: c ? u.refresh_token : void 0
5490
+ code: u,
5491
+ refreshToken: c ? a.refresh_token : void 0
5491
5492
  });
5492
5493
  return this.setCurrentUser(d), null;
5493
- } catch (u) {
5494
- 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." } };
5494
+ } catch (a) {
5495
+ 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." } };
5495
5496
  }
5496
5497
  });
5497
5498
  }
@@ -5613,7 +5614,7 @@ class Fu {
5613
5614
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5614
5615
  }
5615
5616
  sendMagicCode({ email: e }) {
5616
- return Ja({
5617
+ return Zu({
5617
5618
  apiURI: this.config.apiURI,
5618
5619
  appId: this.config.appId,
5619
5620
  email: e
@@ -5622,19 +5623,19 @@ class Fu {
5622
5623
  signInWithMagicCode(e) {
5623
5624
  return N(this, arguments, void 0, function* ({ email: n, code: r }) {
5624
5625
  var i;
5625
- 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({
5626
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Xu({
5626
5627
  apiURI: this.config.apiURI,
5627
5628
  appId: this.config.appId,
5628
5629
  email: n,
5629
5630
  code: r,
5630
5631
  refreshToken: o ? s.user.refresh_token : void 0
5631
5632
  });
5632
- return yield this.changeCurrentUser(a.user), a;
5633
+ return yield this.changeCurrentUser(u.user), u;
5633
5634
  });
5634
5635
  }
5635
5636
  signInWithCustomToken(e) {
5636
5637
  return N(this, void 0, void 0, function* () {
5637
- const n = yield Xa({
5638
+ const n = yield ea({
5638
5639
  apiURI: this.config.apiURI,
5639
5640
  appId: this.config.appId,
5640
5641
  refreshToken: e
@@ -5644,7 +5645,7 @@ class Fu {
5644
5645
  }
5645
5646
  signInAsGuest() {
5646
5647
  return N(this, void 0, void 0, function* () {
5647
- const e = yield eu({
5648
+ const e = yield ta({
5648
5649
  apiURI: this.config.apiURI,
5649
5650
  appId: this.config.appId
5650
5651
  });
@@ -5660,7 +5661,7 @@ class Fu {
5660
5661
  this._log.info("[auth-invalidate] skipped invalidateToken");
5661
5662
  return;
5662
5663
  }
5663
- nu({
5664
+ ra({
5664
5665
  apiURI: this.config.apiURI,
5665
5666
  appId: this.config.appId,
5666
5667
  refreshToken: i
@@ -5695,14 +5696,14 @@ class Fu {
5695
5696
  exchangeCodeForToken(e) {
5696
5697
  return N(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
5697
5698
  var i;
5698
- 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({
5699
+ 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({
5699
5700
  apiURI: this.config.apiURI,
5700
5701
  appId: this.config.appId,
5701
5702
  code: n,
5702
5703
  codeVerifier: r,
5703
5704
  refreshToken: o ? s.user.refresh_token : void 0
5704
5705
  });
5705
- return yield this.changeCurrentUser(a.user), a;
5706
+ return yield this.changeCurrentUser(u.user), u;
5706
5707
  });
5707
5708
  }
5708
5709
  issuerURI() {
@@ -5718,15 +5719,15 @@ class Fu {
5718
5719
  signInWithIdToken(e) {
5719
5720
  return N(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5720
5721
  var s;
5721
- 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({
5722
+ const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield na({
5722
5723
  apiURI: this.config.apiURI,
5723
5724
  appId: this.config.appId,
5724
5725
  idToken: n,
5725
5726
  clientName: r,
5726
5727
  nonce: i,
5727
- refreshToken: a
5728
+ refreshToken: u
5728
5729
  });
5729
- return yield this.changeCurrentUser(u.user), u;
5730
+ return yield this.changeCurrentUser(a.user), a;
5730
5731
  });
5731
5732
  }
5732
5733
  // --------
@@ -5759,7 +5760,7 @@ class Fu {
5759
5760
  // TODO: look into typing again
5760
5761
  getPresence(e, n, r = {}) {
5761
5762
  const i = this._rooms[n], s = this._presence[n];
5762
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, uu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5763
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, ca(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5763
5764
  }
5764
5765
  // TODO: look into typing again
5765
5766
  publishPresence(e, n, r) {
@@ -5797,8 +5798,8 @@ class Fu {
5797
5798
  r.initialPresence || r.initialData
5798
5799
  ), o = Object.assign(Object.assign({}, r), { roomId: n, cb: i, prev: null });
5799
5800
  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), () => {
5800
- var a, u, c;
5801
- 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();
5801
+ var u, a, c;
5802
+ 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();
5802
5803
  };
5803
5804
  }
5804
5805
  _notifyPresenceSubs(e) {
@@ -5809,14 +5810,14 @@ class Fu {
5809
5810
  }
5810
5811
  _notifyPresenceSub(e, n) {
5811
5812
  const r = this.getPresence("", e, n);
5812
- r && (n.prev && !cu(r, n.prev) || (n.prev = r, n.cb(r)));
5813
+ r && (n.prev && !da(r, n.prev) || (n.prev = r, n.cb(r)));
5813
5814
  }
5814
5815
  _patchPresencePeers(e, n) {
5815
5816
  var r, i, s;
5816
5817
  const o = ((i = (r = this._presence[e]) === null || r === void 0 ? void 0 : r.result) === null || i === void 0 ? void 0 : i.peers) || {};
5817
- let a = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
5818
+ let u = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
5818
5819
  (s = this._presence[e]) === null || s === void 0 || s.result;
5819
- const u = It(a, (c) => {
5820
+ const a = It(u, (c) => {
5820
5821
  for (let [d, f, l] of n)
5821
5822
  switch (f) {
5822
5823
  case "+":
@@ -5831,7 +5832,7 @@ class Fu {
5831
5832
  }
5832
5833
  delete c[this._sessionId];
5833
5834
  });
5834
- this._setPresencePeers(e, u);
5835
+ this._setPresencePeers(e, a);
5835
5836
  }
5836
5837
  _setPresencePeers(e, n) {
5837
5838
  const r = Object.assign({}, n);
@@ -5871,10 +5872,10 @@ class Fu {
5871
5872
  }
5872
5873
  _notifyBroadcastSubs(e, n, r) {
5873
5874
  var i, s, o;
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((a) => {
5875
- var u, c, d, f, l, p;
5876
- 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"]];
5877
- return a(y, b);
5875
+ (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) => {
5876
+ var a, c, d, f, l, p;
5877
+ 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"]];
5878
+ return u(y, b);
5878
5879
  });
5879
5880
  }
5880
5881
  // --------
@@ -5883,14 +5884,14 @@ class Fu {
5883
5884
  return N(this, void 0, void 0, function* () {
5884
5885
  var i;
5885
5886
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5886
- return ru(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5887
+ return ia(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5887
5888
  });
5888
5889
  }
5889
5890
  deleteFile(e) {
5890
5891
  return N(this, void 0, void 0, function* () {
5891
5892
  var n;
5892
5893
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5893
- return yield iu({
5894
+ return yield sa({
5894
5895
  apiURI: this.config.apiURI,
5895
5896
  appId: this.config.appId,
5896
5897
  path: e,
@@ -5903,20 +5904,20 @@ class Fu {
5903
5904
  upload(e, n) {
5904
5905
  return N(this, void 0, void 0, function* () {
5905
5906
  var r;
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, a = yield su({
5907
+ 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 oa({
5907
5908
  apiURI: this.config.apiURI,
5908
5909
  appId: this.config.appId,
5909
5910
  fileName: o,
5910
5911
  refreshToken: s
5911
5912
  });
5912
- return yield ou(a, n);
5913
+ return yield ua(u, n);
5913
5914
  });
5914
5915
  }
5915
5916
  getDownloadUrl(e) {
5916
5917
  return N(this, void 0, void 0, function* () {
5917
5918
  var n;
5918
5919
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5919
- return yield au({
5920
+ return yield aa({
5920
5921
  apiURI: this.config.apiURI,
5921
5922
  appId: this.config.appId,
5922
5923
  path: e,
@@ -5925,7 +5926,7 @@ class Fu {
5925
5926
  });
5926
5927
  }
5927
5928
  }
5928
- function Nu(t, e) {
5929
+ function Ka(t, e) {
5929
5930
  return new Lt(
5930
5931
  Hi(t, e),
5931
5932
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -5937,44 +5938,44 @@ function Nu(t, e) {
5937
5938
  void 0
5938
5939
  );
5939
5940
  }
5940
- function Ku(t) {
5941
+ function qa(t) {
5941
5942
  return new Ut(t, {});
5942
5943
  }
5943
- function qu() {
5944
+ function Wa() {
5944
5945
  return new H("string", !0, !1);
5945
5946
  }
5946
- function Wu() {
5947
+ function za() {
5947
5948
  return new H("number", !0, !1);
5948
5949
  }
5949
- function zu() {
5950
+ function Va() {
5950
5951
  return new H("boolean", !0, !1);
5951
5952
  }
5952
- function Vu() {
5953
+ function Ba() {
5953
5954
  return new H("date", !0, !1);
5954
5955
  }
5955
- function Bu() {
5956
+ function Ga() {
5956
5957
  return new H("json", !0, !1);
5957
5958
  }
5958
- function Gu() {
5959
+ function Qa() {
5959
5960
  return new H("json", !0, !1);
5960
5961
  }
5961
5962
  function Hi(t, e) {
5962
5963
  var n, r, i, s;
5963
5964
  const o = { fwd: {}, rev: {} };
5964
- for (const u of Object.values(e))
5965
- (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] = {
5966
- entityName: u.reverse.on,
5967
- cardinality: u.forward.has
5968
- }, o.rev[u.reverse.on][u.reverse.label] = {
5969
- entityName: u.forward.on,
5970
- cardinality: u.reverse.has
5965
+ for (const a of Object.values(e))
5966
+ (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] = {
5967
+ entityName: a.reverse.on,
5968
+ cardinality: a.forward.has
5969
+ }, o.rev[a.reverse.on][a.reverse.label] = {
5970
+ entityName: a.forward.on,
5971
+ cardinality: a.reverse.has
5971
5972
  };
5972
- return Object.fromEntries(Object.entries(t).map(([u, c]) => [
5973
- u,
5974
- new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[u]), o.rev[u]))
5973
+ return Object.fromEntries(Object.entries(t).map(([a, c]) => [
5974
+ a,
5975
+ new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
5975
5976
  ]));
5976
5977
  }
5977
- function Qu({ entities: t, links: e, rooms: n }) {
5978
+ function Ha({ entities: t, links: e, rooms: n }) {
5978
5979
  const r = e ?? {}, i = n ?? {};
5979
5980
  return new Lt(
5980
5981
  Hi(t, r),
@@ -5987,48 +5988,48 @@ function Qu({ entities: t, links: e, rooms: n }) {
5987
5988
  i
5988
5989
  );
5989
5990
  }
5990
- const Fc = {
5991
+ const Nc = {
5991
5992
  // constructs
5992
- graph: Nu,
5993
- schema: Qu,
5994
- entity: Ku,
5993
+ graph: Ka,
5994
+ schema: Ha,
5995
+ entity: qa,
5995
5996
  // value types
5996
- string: qu,
5997
- number: Wu,
5998
- boolean: zu,
5999
- date: Vu,
6000
- json: Bu,
6001
- any: Gu
5997
+ string: Wa,
5998
+ number: za,
5999
+ boolean: Va,
6000
+ date: Ba,
6001
+ json: Ga,
6002
+ any: Qa
6002
6003
  };
6003
6004
  let mt;
6004
- function Hu(t, e) {
6005
+ function Ya(t, e) {
6005
6006
  mt == null || mt.dispose();
6006
- const n = tc(e), r = Zu(e, a), i = Ju(Yu(t));
6007
+ const n = nc(e), r = Xa(e, u), i = Za(Ja(t));
6007
6008
  function s(d) {
6008
6009
  var f;
6009
- d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && a();
6010
+ d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
6010
6011
  }
6011
6012
  function o(d) {
6012
6013
  const f = d.shiftKey && d.ctrlKey && d.key === "0", l = d.key === "Escape" || d.key === "Esc";
6013
- (f || l && n.isVisible()) && a();
6014
+ (f || l && n.isVisible()) && u();
6014
6015
  }
6015
- function a() {
6016
+ function u() {
6016
6017
  n.isVisible() ? n.element.style.display = "none" : (n.element.style.display = "block", n.element.contains(i.element) || n.element.appendChild(i.element));
6017
6018
  }
6018
- function u() {
6019
+ function a() {
6019
6020
  n.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", s);
6020
6021
  }
6021
6022
  function c() {
6022
6023
  document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), mt = {
6023
- dispose: u
6024
+ dispose: a
6024
6025
  };
6025
6026
  }
6026
6027
  return c();
6027
6028
  }
6028
- function Yu(t) {
6029
+ function Ja(t) {
6029
6030
  return `${qn || Ni ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6030
6031
  }
6031
- function Ju(t) {
6032
+ function Za(t) {
6032
6033
  const e = document.createElement("iframe");
6033
6034
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6034
6035
  width: "100%",
@@ -6037,7 +6038,7 @@ function Ju(t) {
6037
6038
  border: "none"
6038
6039
  }), { element: e };
6039
6040
  }
6040
- function Zu(t, e) {
6041
+ function Xa(t, e) {
6041
6042
  const n = `
6042
6043
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6043
6044
  <rect width="512" height="512" fill="black"/>
@@ -6047,7 +6048,7 @@ function Zu(t, e) {
6047
6048
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6048
6049
  // pos
6049
6050
  position: "fixed"
6050
- }, Xu(t.position)), {
6051
+ }, ec(t.position)), {
6051
6052
  height: "32px",
6052
6053
  width: "32px",
6053
6054
  // layout
@@ -6062,7 +6063,7 @@ function Zu(t, e) {
6062
6063
  cursor: "pointer"
6063
6064
  })), r.addEventListener("click", e), { element: r };
6064
6065
  }
6065
- function Xu(t) {
6066
+ function ec(t) {
6066
6067
  switch (t) {
6067
6068
  case "bottom-left":
6068
6069
  return { bottom: "24px", left: "24px" };
@@ -6074,7 +6075,7 @@ function Xu(t) {
6074
6075
  return { top: "24px", left: "24px" };
6075
6076
  }
6076
6077
  }
6077
- function ec(t) {
6078
+ function tc(t) {
6078
6079
  switch (t) {
6079
6080
  case "bottom-left":
6080
6081
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6086,23 +6087,23 @@ function ec(t) {
6086
6087
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6087
6088
  }
6088
6089
  }
6089
- function tc(t) {
6090
+ function nc(t) {
6090
6091
  const e = document.createElement("div");
6091
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, ec(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6092
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, tc(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6092
6093
  function n() {
6093
6094
  return e.style.display !== "none";
6094
6095
  }
6095
6096
  return { element: e, isVisible: n };
6096
6097
  }
6097
- const nc = {
6098
+ const rc = {
6098
6099
  apiURI: "https://api.instantdb.com",
6099
6100
  websocketURI: "wss://api.instantdb.com/runtime/session"
6100
6101
  };
6101
- function rc() {
6102
+ function ic() {
6102
6103
  var t;
6103
6104
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6104
6105
  }
6105
- function ic() {
6106
+ function sc() {
6106
6107
  var t;
6107
6108
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
6108
6109
  }
@@ -6110,13 +6111,13 @@ function gn(t) {
6110
6111
  const e = t.__adminToken;
6111
6112
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6112
6113
  }
6113
- const wn = ic(), Yr = rc();
6114
- class sc {
6114
+ const wn = sc(), Yr = ic();
6115
+ class oc {
6115
6116
  constructor(e) {
6116
6117
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
6117
6118
  }
6118
6119
  }
6119
- class oc {
6120
+ class uc {
6120
6121
  constructor(e) {
6121
6122
  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);
6122
6123
  }
@@ -6124,9 +6125,9 @@ class oc {
6124
6125
  function ac(t) {
6125
6126
  return JSON.parse(JSON.stringify(t));
6126
6127
  }
6127
- class uc {
6128
+ class cc {
6128
6129
  constructor(e) {
6129
- this.tx = Kn(), this._reactor = e, this.auth = new sc(this._reactor), this.storage = new oc(this._reactor);
6130
+ this.tx = Kn(), this._reactor = e, this.auth = new oc(this._reactor), this.storage = new uc(this._reactor);
6130
6131
  }
6131
6132
  /**
6132
6133
  * Use this to write data! You can create, update, delete, and link objects
@@ -6309,22 +6310,22 @@ function Jr(t) {
6309
6310
  const n = B(t);
6310
6311
  return Yr.set(t, n), n;
6311
6312
  }
6312
- function cc(t, e) {
6313
+ function dc(t, e) {
6313
6314
  return Jr(t._reactor.config.schema) !== Jr(e);
6314
6315
  }
6315
- function dc(t, e, n, r, i) {
6316
+ function fc(t, e, n, r, i) {
6316
6317
  var s;
6317
- const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), a = wn[gn(o)];
6318
- if (a)
6319
- return cc(a, o.schema) && a._reactor.updateSchema(o.schema), a;
6320
- 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);
6321
- return wn[gn(o)] = c, fc(o.appId, o.devtool), c;
6318
+ const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = wn[gn(o)];
6319
+ if (u)
6320
+ return dc(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6321
+ const a = new Na(Object.assign(Object.assign(Object.assign({}, rc), o), { cardinalityInference: !!o.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new cc(a);
6322
+ return wn[gn(o)] = c, lc(o.appId, o.devtool), c;
6322
6323
  }
6323
- function fc(t, e) {
6324
+ function lc(t, e) {
6324
6325
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6325
6326
  return;
6326
6327
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6327
- n.allowedHosts.includes(window.location.hostname) && Hu(t, n);
6328
+ n.allowedHosts.includes(window.location.hostname) && Ya(t, n);
6328
6329
  }
6329
6330
  var Tn = { exports: {} }, Qe = {};
6330
6331
  /**
@@ -6337,21 +6338,21 @@ var Tn = { exports: {} }, Qe = {};
6337
6338
  * LICENSE file in the root directory of this source tree.
6338
6339
  */
6339
6340
  var Zr;
6340
- function lc() {
6341
+ function hc() {
6341
6342
  if (Zr) return Qe;
6342
6343
  Zr = 1;
6343
6344
  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 };
6344
- function o(a, u, c) {
6345
+ function o(u, a, c) {
6345
6346
  var d, f = {}, l = null, p = null;
6346
- c !== void 0 && (l = "" + c), u.key !== void 0 && (l = "" + u.key), u.ref !== void 0 && (p = u.ref);
6347
- for (d in u) r.call(u, d) && !s.hasOwnProperty(d) && (f[d] = u[d]);
6348
- if (a && a.defaultProps) for (d in u = a.defaultProps, u) f[d] === void 0 && (f[d] = u[d]);
6349
- return { $$typeof: e, type: a, key: l, ref: p, props: f, _owner: i.current };
6347
+ c !== void 0 && (l = "" + c), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
6348
+ for (d in a) r.call(a, d) && !s.hasOwnProperty(d) && (f[d] = a[d]);
6349
+ if (u && u.defaultProps) for (d in a = u.defaultProps, a) f[d] === void 0 && (f[d] = a[d]);
6350
+ return { $$typeof: e, type: u, key: l, ref: p, props: f, _owner: i.current };
6350
6351
  }
6351
6352
  return Qe.Fragment = n, Qe.jsx = o, Qe.jsxs = o, Qe;
6352
6353
  }
6353
6354
  var He = {}, Xr;
6354
- function hc() {
6355
+ function pc() {
6355
6356
  if (Xr) return He;
6356
6357
  Xr = 1;
6357
6358
  var t = {};
@@ -6365,7 +6366,7 @@ function hc() {
6365
6366
  * LICENSE file in the root directory of this source tree.
6366
6367
  */
6367
6368
  return t.NODE_ENV !== "production" && function() {
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"), 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";
6369
+ 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";
6369
6370
  function T(h) {
6370
6371
  if (h === null || typeof h != "object")
6371
6372
  return null;
@@ -6393,7 +6394,7 @@ function hc() {
6393
6394
  var S = !1, C = !1, $ = !1, D = !1, Ve = !1, ft;
6394
6395
  ft = Symbol.for("react.module.reference");
6395
6396
  function lt(h) {
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 === a || h.$$typeof === u || h.$$typeof === c || // This needs to include all possible module reference object
6397
+ 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
6397
6398
  // types supported by any Flight configuration anywhere since
6398
6399
  // we don't know which Flight build this will end up being used
6399
6400
  // with.
@@ -6432,10 +6433,10 @@ function hc() {
6432
6433
  }
6433
6434
  if (typeof h == "object")
6434
6435
  switch (h.$$typeof) {
6435
- case u:
6436
+ case a:
6436
6437
  var w = h;
6437
6438
  return ht(w) + ".Consumer";
6438
- case a:
6439
+ case u:
6439
6440
  var v = h;
6440
6441
  return ht(v._context) + ".Provider";
6441
6442
  case c:
@@ -6698,8 +6699,8 @@ function hc() {
6698
6699
  ref: !0,
6699
6700
  __self: !0,
6700
6701
  __source: !0
6701
- }, or, ar;
6702
- function as(h) {
6702
+ }, or, ur;
6703
+ function us(h) {
6703
6704
  if (Be.call(h, "ref")) {
6704
6705
  var w = Object.getOwnPropertyDescriptor(h, "ref").get;
6705
6706
  if (w && w.isReactWarning)
@@ -6707,7 +6708,7 @@ function hc() {
6707
6708
  }
6708
6709
  return h.ref !== void 0;
6709
6710
  }
6710
- function us(h) {
6711
+ function as(h) {
6711
6712
  if (Be.call(h, "key")) {
6712
6713
  var w = Object.getOwnPropertyDescriptor(h, "key").get;
6713
6714
  if (w && w.isReactWarning)
@@ -6732,7 +6733,7 @@ function hc() {
6732
6733
  function fs(h, w) {
6733
6734
  {
6734
6735
  var v = function() {
6735
- 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));
6736
+ 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));
6736
6737
  };
6737
6738
  v.isReactWarning = !0, Object.defineProperty(h, "ref", {
6738
6739
  get: v,
@@ -6772,7 +6773,7 @@ function hc() {
6772
6773
  function hs(h, w, v, E, P) {
6773
6774
  {
6774
6775
  var M, I = {}, k = null, G = null;
6775
- v !== void 0 && (ir(v), k = "" + v), us(w) && (ir(w.key), k = "" + w.key), as(w) && (G = w.ref, cs(w, P));
6776
+ v !== void 0 && (ir(v), k = "" + v), as(w) && (ir(w.key), k = "" + w.key), us(w) && (G = w.ref, cs(w, P));
6776
6777
  for (M in w)
6777
6778
  Be.call(w, M) && !os.hasOwnProperty(M) && (I[M] = w[M]);
6778
6779
  if (h && h.defaultProps) {
@@ -6787,13 +6788,13 @@ function hc() {
6787
6788
  return ls(h, k, G, P, E, sr.current, I);
6788
6789
  }
6789
6790
  }
6790
- var zt = g.ReactCurrentOwner, ur = g.ReactDebugCurrentFrame;
6791
+ var zt = g.ReactCurrentOwner, ar = g.ReactDebugCurrentFrame;
6791
6792
  function Pe(h) {
6792
6793
  if (h) {
6793
6794
  var w = h._owner, v = bt(h.type, h._source, w ? w.type : null);
6794
- ur.setExtraStackFrame(v);
6795
+ ar.setExtraStackFrame(v);
6795
6796
  } else
6796
- ur.setExtraStackFrame(null);
6797
+ ar.setExtraStackFrame(null);
6797
6798
  }
6798
6799
  var Vt;
6799
6800
  Vt = !1;
@@ -6952,10 +6953,10 @@ React keys must be passed directly to JSX without using spread:
6952
6953
  He.Fragment = i, He.jsx = Ts, He.jsxs = ms;
6953
6954
  }(), He;
6954
6955
  }
6955
- var pc = {};
6956
- pc.NODE_ENV === "production" ? Tn.exports = lc() : Tn.exports = hc();
6956
+ var yc = {};
6957
+ yc.NODE_ENV === "production" ? Tn.exports = hc() : Tn.exports = pc();
6957
6958
  var V = Tn.exports;
6958
- const yc = {
6959
+ const bc = {
6959
6960
  isLoading: !0,
6960
6961
  data: void 0,
6961
6962
  pageInfo: void 0,
@@ -6964,10 +6965,10 @@ const yc = {
6964
6965
  function ei(t) {
6965
6966
  return Object.assign({ isLoading: !t, data: void 0, pageInfo: void 0, error: void 0 }, t || {});
6966
6967
  }
6967
- function bc(t, e, n) {
6968
+ function _c(t, e, n) {
6968
6969
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6969
6970
  const r = e ? ac(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
6970
- (u) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
6971
+ (a) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
6971
6972
  s.current = Object.assign({
6972
6973
  isLoading: !d,
6973
6974
  // @ts-expect-error: ts thinks this will always be overwritten
@@ -6976,15 +6977,15 @@ function bc(t, e, n) {
6976
6977
  pageInfo: void 0,
6977
6978
  // @ts-expect-error: ts thinks this will always be overwritten
6978
6979
  error: void 0
6979
- }, d), u();
6980
+ }, d), a();
6980
6981
  }) : () => {
6981
6982
  }),
6982
6983
  // Build a new subscribe function if the query changes
6983
6984
  [i]
6984
6985
  );
6985
- return { state: en(o, () => s.current, () => yc), query: r };
6986
+ return { state: en(o, () => s.current, () => bc), query: r };
6986
6987
  }
6987
- function _c() {
6988
+ function gc() {
6988
6989
  const t = ot(null);
6989
6990
  ke(() => {
6990
6991
  n();
@@ -6997,14 +6998,14 @@ function _c() {
6997
6998
  }
6998
6999
  return { set: e, clear: n };
6999
7000
  }
7000
- const gc = 1e3;
7001
- function wc(t, e, n) {
7001
+ const wc = 1e3;
7002
+ function Tc(t, e, n) {
7002
7003
  const r = ot(n);
7003
7004
  r.current = n, ke(() => t.core._reactor.subscribeTopic(t.id, e, (s, o) => {
7004
7005
  r.current(s, o);
7005
7006
  }), [t.id, e]);
7006
7007
  }
7007
- function Tc(t, e) {
7008
+ function mc(t, e) {
7008
7009
  return ke(() => t.core._reactor.joinRoom(t.id), [t.id]), we((r) => {
7009
7010
  t.core._reactor.publishTopic({
7010
7011
  roomType: t.type,
@@ -7014,11 +7015,11 @@ function Tc(t, e) {
7014
7015
  });
7015
7016
  }, [t.id, e]);
7016
7017
  }
7017
- function mc(t, e = {}) {
7018
+ function vc(t, e = {}) {
7018
7019
  var n, r;
7019
- const [i, s] = ai(() => {
7020
- var u;
7021
- return (u = t.core._reactor.getPresence(t.type, t.id, e)) !== null && u !== void 0 ? u : {
7020
+ const [i, s] = ui(() => {
7021
+ var a;
7022
+ return (a = t.core._reactor.getPresence(t.type, t.id, e)) !== null && a !== void 0 ? a : {
7022
7023
  peers: {},
7023
7024
  isLoading: !0
7024
7025
  };
@@ -7026,16 +7027,16 @@ function mc(t, e = {}) {
7026
7027
  ke(() => t.core._reactor.subscribePresence(t.type, t.id, e, (c) => {
7027
7028
  s(c);
7028
7029
  }), [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()]);
7029
- const o = we((u) => {
7030
- t.core._reactor.publishPresence(t.type, t.id, u);
7030
+ const o = we((a) => {
7031
+ t.core._reactor.publishPresence(t.type, t.id, a);
7031
7032
  }, [t.type, t.id]);
7032
7033
  return tn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
7033
7034
  }
7034
- function vc(t, e, n) {
7035
+ function Sc(t, e, n) {
7035
7036
  ke(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ke(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
7036
7037
  }
7037
- function Sc(t, e, n = {}) {
7038
- const r = _c(), i = Se.usePresence(t, {
7038
+ function Oc(t, e, n = {}) {
7039
+ const r = gc(), i = Se.usePresence(t, {
7039
7040
  keys: [e]
7040
7041
  }), s = tn(() => {
7041
7042
  var d;
@@ -7045,17 +7046,17 @@ function Sc(t, e, n = {}) {
7045
7046
  var f;
7046
7047
  t.core._reactor.publishPresence(t.type, t.id, {
7047
7048
  [e]: d
7048
- }), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : gc, () => {
7049
+ }), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : wc, () => {
7049
7050
  t.core._reactor.publishPresence(t.type, t.id, {
7050
7051
  [e]: null
7051
7052
  });
7052
7053
  }));
7053
- }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), a = we((d) => {
7054
+ }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), u = we((d) => {
7054
7055
  const l = !((n == null ? void 0 : n.stopOnEnter) && d.key === "Enter");
7055
7056
  o(l);
7056
- }, [n.stopOnEnter, o]), u = we(() => {
7057
+ }, [n.stopOnEnter, o]), a = we(() => {
7057
7058
  o(!1);
7058
- }, [o]), c = tn(() => ({ onKeyDown: a, onBlur: u }), [a, u]);
7059
+ }, [o]), c = tn(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
7059
7060
  return {
7060
7061
  active: s,
7061
7062
  setActive: o,
@@ -7063,34 +7064,34 @@ function Sc(t, e, n = {}) {
7063
7064
  };
7064
7065
  }
7065
7066
  const Se = {
7066
- useTopicEffect: wc,
7067
- usePublishTopic: Tc,
7068
- usePresence: mc,
7069
- useSyncPresence: vc,
7070
- useTypingIndicator: Sc
7067
+ useTopicEffect: Tc,
7068
+ usePublishTopic: mc,
7069
+ usePresence: vc,
7070
+ useSyncPresence: Sc,
7071
+ useTypingIndicator: Oc
7071
7072
  };
7072
- class Oc {
7073
+ class Ec {
7073
7074
  constructor(e, n, r) {
7074
7075
  this.useTopicEffect = (i, s) => {
7075
7076
  Se.useTopicEffect(this, i, s);
7076
7077
  }, this.usePublishTopic = (i) => Se.usePublishTopic(this, i), this.usePresence = (i = {}) => Se.usePresence(this, i), this.useSyncPresence = (i, s) => Se.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => Se.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
7077
7078
  }
7078
7079
  }
7079
- var Ec = function(t, e, n, r) {
7080
+ var Ac = function(t, e, n, r) {
7080
7081
  function i(s) {
7081
7082
  return s instanceof n ? s : new n(function(o) {
7082
7083
  o(s);
7083
7084
  });
7084
7085
  }
7085
7086
  return new (n || (n = Promise))(function(s, o) {
7086
- function a(d) {
7087
+ function u(d) {
7087
7088
  try {
7088
7089
  c(r.next(d));
7089
7090
  } catch (f) {
7090
7091
  o(f);
7091
7092
  }
7092
7093
  }
7093
- function u(d) {
7094
+ function a(d) {
7094
7095
  try {
7095
7096
  c(r.throw(d));
7096
7097
  } catch (f) {
@@ -7098,39 +7099,39 @@ var Ec = function(t, e, n, r) {
7098
7099
  }
7099
7100
  }
7100
7101
  function c(d) {
7101
- d.done ? s(d.value) : i(d.value).then(a, u);
7102
+ d.done ? s(d.value) : i(d.value).then(u, a);
7102
7103
  }
7103
7104
  c((r = r.apply(t, e || [])).next());
7104
7105
  });
7105
7106
  };
7106
- const Ac = {
7107
+ const kc = {
7107
7108
  isLoading: !0,
7108
7109
  user: void 0,
7109
7110
  error: void 0
7110
7111
  };
7111
- class kc {
7112
+ class jc {
7112
7113
  constructor(e, n) {
7113
7114
  this.tx = Kn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
7114
- const [i, s] = ai(null);
7115
+ const [i, s] = ui(null);
7115
7116
  return ke(() => {
7116
- Ec(this, void 0, void 0, function* () {
7117
- const a = yield this.getLocalId(r);
7118
- s(a);
7117
+ Ac(this, void 0, void 0, function* () {
7118
+ const u = yield this.getLocalId(r);
7119
+ s(u);
7119
7120
  });
7120
7121
  }, [r]), i;
7121
- }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => bc(this.core, r, i).state, this.useAuth = () => {
7122
- const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((u) => {
7123
- r.current = Object.assign({ isLoading: !1 }, u), o();
7122
+ }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => _c(this.core, r, i).state, this.useAuth = () => {
7123
+ const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((a) => {
7124
+ r.current = Object.assign({ isLoading: !1 }, a), o();
7124
7125
  }), []);
7125
- return en(i, () => r.current, () => Ac);
7126
+ return en(i, () => r.current, () => kc);
7126
7127
  }, this.useUser = () => {
7127
7128
  const { user: r } = this.useAuth();
7128
7129
  if (!r)
7129
7130
  throw new qe("useUser must be used within an auth-protected route");
7130
7131
  return r;
7131
7132
  }, this.useConnectionStatus = () => {
7132
- const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((u) => {
7133
- u !== r.current && (r.current = u, o());
7133
+ const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((a) => {
7134
+ a !== r.current && (r.current = a, o());
7134
7135
  }), []);
7135
7136
  return en(
7136
7137
  i,
@@ -7144,7 +7145,7 @@ class kc {
7144
7145
  }, this.SignedOut = ({ children: r }) => {
7145
7146
  const i = this.useAuth();
7146
7147
  return i.isLoading || i.error || i.user ? null : V.jsx(V.Fragment, { children: r });
7147
- }, this.core = dc(
7148
+ }, this.core = fc(
7148
7149
  e,
7149
7150
  // @ts-expect-error because TS can't resolve subclass statics
7150
7151
  this.constructor.Storage,
@@ -7168,7 +7169,7 @@ class kc {
7168
7169
  * const { peers } = db.rooms.usePresence(room);
7169
7170
  */
7170
7171
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7171
- return new Oc(this.core, e, n);
7172
+ return new Ec(this.core, e, n);
7172
7173
  }
7173
7174
  /**
7174
7175
  * One time query for the logged in state. This is useful
@@ -7191,15 +7192,15 @@ class ti extends Error {
7191
7192
  }
7192
7193
  function Xt(t) {
7193
7194
  }
7194
- function jc(t) {
7195
+ function Cc(t) {
7195
7196
  if (typeof t == "function")
7196
7197
  throw new TypeError(
7197
7198
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
7198
7199
  );
7199
7200
  const { onEvent: e = Xt, onError: n = Xt, onRetry: r = Xt, onComment: i } = t;
7200
- let s = "", o = !0, a, u = "", c = "";
7201
+ let s = "", o = !0, u, a = "", c = "";
7201
7202
  function d(b) {
7202
- const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Cc(`${s}${_}`);
7203
+ const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Ic(`${s}${_}`);
7203
7204
  for (const m of T)
7204
7205
  f(m);
7205
7206
  s = g, o = !1;
@@ -7227,11 +7228,11 @@ function jc(t) {
7227
7228
  c = _;
7228
7229
  break;
7229
7230
  case "data":
7230
- u = `${u}${_}
7231
+ a = `${a}${_}
7231
7232
  `;
7232
7233
  break;
7233
7234
  case "id":
7234
- a = _.includes("\0") ? void 0 : _;
7235
+ u = _.includes("\0") ? void 0 : _;
7235
7236
  break;
7236
7237
  case "retry":
7237
7238
  /^\d+$/.test(_) ? r(parseInt(_, 10)) : n(
@@ -7253,21 +7254,21 @@ function jc(t) {
7253
7254
  }
7254
7255
  }
7255
7256
  function p() {
7256
- u.length > 0 && e({
7257
- id: a,
7257
+ a.length > 0 && e({
7258
+ id: u,
7258
7259
  event: c || void 0,
7259
7260
  // If the data buffer's last character is a U+000A LINE FEED (LF) character,
7260
7261
  // then remove the last character from the data buffer.
7261
- data: u.endsWith(`
7262
- `) ? u.slice(0, -1) : u
7263
- }), a = void 0, u = "", c = "";
7262
+ data: a.endsWith(`
7263
+ `) ? a.slice(0, -1) : a
7264
+ }), u = void 0, a = "", c = "";
7264
7265
  }
7265
7266
  function y(b = {}) {
7266
- s && b.consume && f(s), o = !0, a = void 0, u = "", c = "", s = "";
7267
+ s && b.consume && f(s), o = !0, u = void 0, a = "", c = "", s = "";
7267
7268
  }
7268
7269
  return { feed: d, reset: y };
7269
7270
  }
7270
- function Cc(t) {
7271
+ function Ic(t) {
7271
7272
  const e = [];
7272
7273
  let n = "", r = 0;
7273
7274
  for (; r < t.length; ) {
@@ -7278,8 +7279,8 @@ function Cc(t) {
7278
7279
  n = t.slice(r);
7279
7280
  break;
7280
7281
  } else {
7281
- const a = t.slice(r, o);
7282
- e.push(a), r = o + 1, t[r - 1] === "\r" && t[r] === `
7282
+ const u = t.slice(r, o);
7283
+ e.push(u), r = o + 1, t[r - 1] === "\r" && t[r] === `
7283
7284
  ` && r++;
7284
7285
  }
7285
7286
  }
@@ -7327,7 +7328,7 @@ class ni extends Event {
7327
7328
  return e(ri(this), n);
7328
7329
  }
7329
7330
  }
7330
- function Ic(t) {
7331
+ function Pc(t) {
7331
7332
  const e = globalThis.DOMException;
7332
7333
  return typeof e == "function" ? new e(t, "SyntaxError") : new SyntaxError(t);
7333
7334
  }
@@ -7353,12 +7354,12 @@ class kt extends EventTarget {
7353
7354
  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) => {
7354
7355
  var o;
7355
7356
  A(this, $e).reset();
7356
- const { body: a, redirected: u, status: c, headers: d } = s;
7357
+ const { body: u, redirected: a, status: c, headers: d } = s;
7357
7358
  if (c === 204) {
7358
7359
  pe(this, se, et).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
7359
7360
  return;
7360
7361
  }
7361
- if (u ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), c !== 200) {
7362
+ if (a ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), c !== 200) {
7362
7363
  pe(this, se, et).call(this, `Non-200 status code (${c})`, c);
7363
7364
  return;
7364
7365
  }
@@ -7370,11 +7371,11 @@ class kt extends EventTarget {
7370
7371
  return;
7371
7372
  x(this, J, this.OPEN);
7372
7373
  const f = new Event("open");
7373
- if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
7374
+ if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof u != "object" || !u || !("getReader" in u)) {
7374
7375
  pe(this, se, et).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
7375
7376
  return;
7376
7377
  }
7377
- const l = new TextDecoder(), p = a.getReader();
7378
+ const l = new TextDecoder(), p = u.getReader();
7378
7379
  let y = !0;
7379
7380
  do {
7380
7381
  const { done: b, value: _ } = await p.read();
@@ -7399,13 +7400,13 @@ class kt extends EventTarget {
7399
7400
  if (e instanceof URL)
7400
7401
  x(this, Oe, e);
7401
7402
  else if (typeof e == "string")
7402
- x(this, Oe, new URL(e, Pc()));
7403
+ x(this, Oe, new URL(e, Mc()));
7403
7404
  else
7404
7405
  throw new Error("Invalid URL");
7405
7406
  } catch {
7406
- throw Ic("An invalid or illegal string was specified");
7407
+ throw Pc("An invalid or illegal string was specified");
7407
7408
  }
7408
- x(this, $e, jc({
7409
+ x(this, $e, Cc({
7409
7410
  onEvent: A(this, En),
7410
7411
  onRetry: A(this, An)
7411
7412
  })), x(this, J, this.CONNECTING), x(this, it, 3e3), x(this, Rt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), x(this, At, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), pe(this, se, vn).call(this);
@@ -7548,15 +7549,15 @@ kt.OPEN = 1, /**
7548
7549
  * @public
7549
7550
  */
7550
7551
  kt.CLOSED = 2;
7551
- function Pc() {
7552
+ function Mc() {
7552
7553
  const t = "document" in globalThis ? globalThis.document : void 0;
7553
7554
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
7554
7555
  }
7555
- const Vn = class Vn extends kc {
7556
+ const Vn = class Vn extends jc {
7556
7557
  };
7557
7558
  Vn.EventSourceImpl = kt;
7558
7559
  let Cn = Vn;
7559
- function Mc(t) {
7560
+ function Rc(t) {
7560
7561
  const e = {
7561
7562
  ...t,
7562
7563
  useDateObjects: t.useDateObjects ?? !1
@@ -7565,8 +7566,8 @@ function Mc(t) {
7565
7566
  "@instantdb/react": Wn
7566
7567
  });
7567
7568
  }
7568
- const Nc = Mc;
7569
- function Kc({
7569
+ const Kc = Rc;
7570
+ function qc({
7570
7571
  as: t = "div",
7571
7572
  spaceId: e,
7572
7573
  room: n,
@@ -7574,8 +7575,8 @@ function Kc({
7574
7575
  style: i,
7575
7576
  userCursorColor: s,
7576
7577
  children: o,
7577
- renderCursor: a,
7578
- propagate: u,
7578
+ renderCursor: u,
7579
+ propagate: a,
7579
7580
  zIndex: c
7580
7581
  }) {
7581
7582
  const d = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
@@ -7594,7 +7595,7 @@ function Kc({
7594
7595
  });
7595
7596
  }
7596
7597
  function y(g) {
7597
- u || g.stopPropagation();
7598
+ a || g.stopPropagation();
7598
7599
  const m = g.currentTarget.getBoundingClientRect();
7599
7600
  p(m, g);
7600
7601
  }
@@ -7608,7 +7609,7 @@ function Kc({
7608
7609
  return;
7609
7610
  const m = g.touches[0];
7610
7611
  if (m.target instanceof Element) {
7611
- u || g.stopPropagation();
7612
+ a || g.stopPropagation();
7612
7613
  const O = m.target.getBoundingClientRect();
7613
7614
  p(O, m);
7614
7615
  }
@@ -7638,8 +7639,8 @@ function Kc({
7638
7639
  {
7639
7640
  style: {
7640
7641
  ...si,
7641
- ...xc,
7642
- zIndex: c !== void 0 ? c : $c
7642
+ ...$c,
7643
+ zIndex: c !== void 0 ? c : Dc
7643
7644
  },
7644
7645
  children: Object.entries(f.peers).map(([g, m]) => {
7645
7646
  const O = m[d];
@@ -7652,10 +7653,10 @@ function Kc({
7652
7653
  transformOrigin: "0 0",
7653
7654
  transition: "transform 100ms"
7654
7655
  },
7655
- children: a ? a({
7656
+ children: u ? u({
7656
7657
  color: O.color,
7657
7658
  presence: l == null ? void 0 : l.peers[g]
7658
- }) : /* @__PURE__ */ V.jsx(Rc, { ...O })
7659
+ }) : /* @__PURE__ */ V.jsx(xc, { ...O })
7659
7660
  },
7660
7661
  g
7661
7662
  ) : null;
@@ -7666,7 +7667,7 @@ function Kc({
7666
7667
  ]
7667
7668
  );
7668
7669
  }
7669
- function Rc({ color: t }) {
7670
+ function xc({ color: t }) {
7670
7671
  const n = t || "black";
7671
7672
  return /* @__PURE__ */ V.jsxs(
7672
7673
  "svg",
@@ -7719,21 +7720,21 @@ const si = {
7719
7720
  left: 0,
7720
7721
  bottom: 0,
7721
7722
  right: 0
7722
- }, xc = {
7723
+ }, $c = {
7723
7724
  overflow: "hidden",
7724
7725
  pointerEvents: "none",
7725
7726
  userSelect: "none"
7726
- }, $c = 99999;
7727
+ }, Dc = 99999;
7727
7728
  export {
7728
- Kc as Cursors,
7729
+ qc as Cursors,
7729
7730
  Dt as InstantAPIError,
7730
- kc as InstantReactAbstractDatabase,
7731
+ jc as InstantReactAbstractDatabase,
7731
7732
  Cn as InstantReactWebDatabase,
7732
7733
  ve as SyncTableCallbackEventType,
7733
- Fc as i,
7734
+ Nc as i,
7734
7735
  W as id,
7735
- Mc as init,
7736
- Nc as init_experimental,
7737
- Uc as lookup,
7738
- Lc as tx
7736
+ Rc as init,
7737
+ Kc as init_experimental,
7738
+ Lc as lookup,
7739
+ Fc as tx
7739
7740
  };