@instantdb/react 0.22.93 → 0.22.94-experimental.drewh-ssr.20384771877.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/commonjs/next-ssr/HydrationStreamProvider.d.ts +66 -0
  2. package/dist/commonjs/next-ssr/HydrationStreamProvider.d.ts.map +1 -0
  3. package/dist/commonjs/next-ssr/HydrationStreamProvider.js +140 -0
  4. package/dist/commonjs/next-ssr/HydrationStreamProvider.js.map +1 -0
  5. package/dist/commonjs/next-ssr/InstantNextDatabase.d.ts +12 -0
  6. package/dist/commonjs/next-ssr/InstantNextDatabase.d.ts.map +1 -0
  7. package/dist/commonjs/next-ssr/InstantNextDatabase.js +42 -0
  8. package/dist/commonjs/next-ssr/InstantNextDatabase.js.map +1 -0
  9. package/dist/commonjs/next-ssr/InstantSuspenseProvider.d.ts +28 -0
  10. package/dist/commonjs/next-ssr/InstantSuspenseProvider.d.ts.map +1 -0
  11. package/dist/commonjs/next-ssr/InstantSuspenseProvider.js +99 -0
  12. package/dist/commonjs/next-ssr/InstantSuspenseProvider.js.map +1 -0
  13. package/dist/commonjs/next-ssr/getUserFromInstantCookie.d.ts +3 -0
  14. package/dist/commonjs/next-ssr/getUserFromInstantCookie.d.ts.map +1 -0
  15. package/dist/commonjs/next-ssr/getUserFromInstantCookie.js +21 -0
  16. package/dist/commonjs/next-ssr/getUserFromInstantCookie.js.map +1 -0
  17. package/dist/commonjs/next-ssr/htmlescape.d.ts +3 -0
  18. package/dist/commonjs/next-ssr/htmlescape.d.ts.map +1 -0
  19. package/dist/commonjs/next-ssr/htmlescape.js +25 -0
  20. package/dist/commonjs/next-ssr/htmlescape.js.map +1 -0
  21. package/dist/commonjs/next-ssr/index.d.ts +28 -0
  22. package/dist/commonjs/next-ssr/index.d.ts.map +1 -0
  23. package/dist/commonjs/next-ssr/index.js +43 -0
  24. package/dist/commonjs/next-ssr/index.js.map +1 -0
  25. package/dist/esm/next-ssr/HydrationStreamProvider.d.ts +66 -0
  26. package/dist/esm/next-ssr/HydrationStreamProvider.d.ts.map +1 -0
  27. package/dist/esm/next-ssr/HydrationStreamProvider.js +103 -0
  28. package/dist/esm/next-ssr/HydrationStreamProvider.js.map +1 -0
  29. package/dist/esm/next-ssr/InstantNextDatabase.d.ts +12 -0
  30. package/dist/esm/next-ssr/InstantNextDatabase.d.ts.map +1 -0
  31. package/dist/esm/next-ssr/InstantNextDatabase.js +35 -0
  32. package/dist/esm/next-ssr/InstantNextDatabase.js.map +1 -0
  33. package/dist/esm/next-ssr/InstantSuspenseProvider.d.ts +28 -0
  34. package/dist/esm/next-ssr/InstantSuspenseProvider.d.ts.map +1 -0
  35. package/dist/esm/next-ssr/InstantSuspenseProvider.js +94 -0
  36. package/dist/esm/next-ssr/InstantSuspenseProvider.js.map +1 -0
  37. package/dist/esm/next-ssr/getUserFromInstantCookie.d.ts +3 -0
  38. package/dist/esm/next-ssr/getUserFromInstantCookie.d.ts.map +1 -0
  39. package/dist/esm/next-ssr/getUserFromInstantCookie.js +17 -0
  40. package/dist/esm/next-ssr/getUserFromInstantCookie.js.map +1 -0
  41. package/dist/esm/next-ssr/htmlescape.d.ts +3 -0
  42. package/dist/esm/next-ssr/htmlescape.d.ts.map +1 -0
  43. package/dist/esm/next-ssr/htmlescape.js +21 -0
  44. package/dist/esm/next-ssr/htmlescape.js.map +1 -0
  45. package/dist/esm/next-ssr/index.d.ts +28 -0
  46. package/dist/esm/next-ssr/index.d.ts.map +1 -0
  47. package/dist/esm/next-ssr/index.js +32 -0
  48. package/dist/esm/next-ssr/index.js.map +1 -0
  49. package/dist/standalone/index.js +1033 -977
  50. package/dist/standalone/index.umd.cjs +14 -14
  51. package/package.json +18 -6
  52. package/src/next-ssr/HydrationStreamProvider.tsx +200 -0
  53. package/src/next-ssr/InstantNextDatabase.tsx +56 -0
  54. package/src/next-ssr/InstantSuspenseProvider.tsx +189 -0
  55. package/src/next-ssr/getUserFromInstantCookie.ts +11 -0
  56. package/src/next-ssr/htmlescape.ts +24 -0
  57. package/src/next-ssr/index.tsx +47 -0
  58. package/tsconfig.json +1 -0
@@ -1,5 +1,5 @@
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
- function B(t) {
1
+ import oi, { useRef as ut, useCallback as we, useSyncExternalStore as en, useEffect as ke, useMemo as tn, useState as ui, createElement as Os } from "react";
2
+ function W(t) {
3
3
  if (typeof t == "number")
4
4
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
5
5
  if (typeof t == "boolean")
@@ -18,7 +18,7 @@ function B(t) {
18
18
  let e = 2166136261;
19
19
  for (let n = 0; n < t.length; n++) {
20
20
  e ^= (n + 1) * 2654435761;
21
- const r = B(t[n]);
21
+ const r = W(t[n]);
22
22
  for (let i = 0; i < r.length; i++)
23
23
  e ^= r.charCodeAt(i), e *= 16777619, e = e >>> 0;
24
24
  }
@@ -28,24 +28,24 @@ function B(t) {
28
28
  let e = 2166136261;
29
29
  const n = Object.keys(t).sort();
30
30
  for (let r = 0; r < n.length; r++) {
31
- const i = n[r], s = B(i);
31
+ const i = n[r], s = W(i);
32
32
  e ^= parseInt(s, 16), e *= 16777619, e = e >>> 0;
33
- const o = B(t[i]);
33
+ const o = W(t[i]);
34
34
  e ^= parseInt(o, 16), e *= 16777619, e = e >>> 0;
35
35
  }
36
36
  return e.toString(16);
37
37
  }
38
- return B(String(t));
38
+ return W(String(t));
39
39
  }
40
- const L = {
40
+ const F = {
41
41
  Remove: "remove",
42
42
  Replace: "replace",
43
43
  Add: "add"
44
- }, ai = 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__"), St = Symbol.iterator, ne = {
45
45
  mutable: "mutable",
46
46
  immutable: "immutable"
47
47
  }, In = {};
48
- function tt(t, e) {
48
+ function nt(t, e) {
49
49
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
50
50
  }
51
51
  function yr(t, e) {
@@ -92,7 +92,7 @@ function ci(t, e = []) {
92
92
  if (r !== null && (r == null ? void 0 : r.original) !== t.original)
93
93
  return null;
94
94
  const i = t.parent.type === 3, s = i ? Array.from(t.parent.setMap.keys()).indexOf(t.key) : t.key;
95
- if (!(i && n.size > s || tt(n, s)))
95
+ if (!(i && n.size > s || nt(n, s)))
96
96
  return null;
97
97
  e.push(s);
98
98
  }
@@ -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 at(t, e, n) {
115
+ function ct(t, e, n) {
116
116
  Ce(t) === 2 ? t.set(e, n) : t[e] = n;
117
117
  }
118
118
  function Qt(t, e) {
@@ -225,7 +225,7 @@ function Ye(t) {
225
225
  e[n] = Ye(t[n]);
226
226
  return e;
227
227
  }
228
- function St(t) {
228
+ function Ot(t) {
229
229
  return je(t) ? Ye(t) : t;
230
230
  }
231
231
  function fe(t) {
@@ -242,11 +242,11 @@ function Re(t, e, n, r, i) {
242
242
  if (r.length > 0) {
243
243
  const u = r.indexOf(o);
244
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, d) => {
245
+ throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, u).map((a, c) => {
246
246
  if (typeof a == "symbol")
247
247
  return `[${a.toString()}]`;
248
- const c = r[d];
249
- return typeof a == "object" && (c instanceof Map || c instanceof Set) ? Array.from(c.keys()).indexOf(a) : a;
248
+ const d = r[c];
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
@@ -303,8 +303,8 @@ function fi(t, e, n) {
303
303
  if (je(o)) {
304
304
  const a = j(o);
305
305
  Q(a);
306
- const d = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
307
- at(r ? i : t, s, d);
306
+ const c = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
307
+ ct(r ? i : t, s, c);
308
308
  } else
309
309
  fi(o, e, n);
310
310
  }), i) {
@@ -338,8 +338,8 @@ function $n(t, e, n, r) {
338
338
  var u;
339
339
  const a = t.type === 3 ? t.setMap : t.copy;
340
340
  if (be(_e(a, e), n)) {
341
- let d = i.original;
342
- i.copy && (d = 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(d, i.original)), at(a, e, d);
341
+ let c = i.original;
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)), ct(a, e, c);
343
343
  }
344
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;
@@ -349,44 +349,44 @@ function $n(t, e, n, r) {
349
349
  function Is(t, e, n, r, i) {
350
350
  let { original: s, assignedMap: o, options: u } = t, a = t.copy;
351
351
  a.length < s.length && ([s, a] = [a, s], [n, r] = [r, n]);
352
- for (let d = 0; d < s.length; d += 1)
353
- if (o.get(d.toString()) && a[d] !== s[d]) {
354
- const c = e.concat([d]), f = Ee(c, i);
352
+ for (let c = 0; c < s.length; c += 1)
353
+ if (o.get(c.toString()) && a[c] !== s[c]) {
354
+ const d = e.concat([c]), f = Ee(d, i);
355
355
  n.push({
356
- op: L.Replace,
356
+ op: F.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(a[d])
359
+ value: Ot(a[c])
360
360
  }), r.push({
361
- op: L.Replace,
361
+ op: F.Replace,
362
362
  path: f,
363
363
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
364
- value: St(s[d])
364
+ value: Ot(s[c])
365
365
  });
366
366
  }
367
- for (let d = s.length; d < a.length; d += 1) {
368
- const c = e.concat([d]), f = Ee(c, i);
367
+ for (let c = s.length; c < a.length; c += 1) {
368
+ const d = e.concat([c]), f = Ee(d, i);
369
369
  n.push({
370
- op: L.Add,
370
+ op: F.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(a[d])
373
+ value: Ot(a[c])
374
374
  });
375
375
  }
376
376
  if (s.length < a.length) {
377
- const { arrayLengthAssignment: d = !0 } = u.enablePatches;
378
- if (d) {
379
- const c = e.concat(["length"]), f = Ee(c, i);
377
+ const { arrayLengthAssignment: c = !0 } = u.enablePatches;
378
+ if (c) {
379
+ const d = e.concat(["length"]), f = Ee(d, i);
380
380
  r.push({
381
- op: L.Replace,
381
+ op: F.Replace,
382
382
  path: f,
383
383
  value: s.length
384
384
  });
385
385
  } else
386
- for (let c = a.length; s.length < c; c -= 1) {
387
- const f = e.concat([c - 1]), l = Ee(f, i);
386
+ for (let d = a.length; s.length < d; d -= 1) {
387
+ const f = e.concat([d - 1]), l = Ee(f, i);
388
388
  r.push({
389
- op: L.Remove,
389
+ op: F.Remove,
390
390
  path: l
391
391
  });
392
392
  }
@@ -394,46 +394,46 @@ function Is(t, e, n, r, i) {
394
394
  }
395
395
  function Ps({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
396
396
  n.forEach((u, a) => {
397
- const d = _e(t, a), c = St(_e(e, a)), f = u ? tt(t, a) ? L.Replace : L.Add : L.Remove;
398
- if (be(d, c) && f === L.Replace)
397
+ const c = _e(t, a), d = Ot(_e(e, a)), f = u ? nt(t, a) ? F.Replace : F.Add : F.Remove;
398
+ if (be(c, d) && f === F.Replace)
399
399
  return;
400
400
  const l = r.concat(a), p = Ee(l, o);
401
- i.push(f === L.Remove ? { op: f, path: p } : { op: f, path: p, value: c }), s.push(f === L.Add ? { op: L.Remove, path: p } : f === L.Remove ? { op: L.Add, path: p, value: d } : { op: L.Replace, path: p, value: d });
401
+ i.push(f === F.Remove ? { op: f, path: p } : { op: f, path: p, value: d }), s.push(f === F.Add ? { op: F.Remove, path: p } : f === F.Remove ? { op: F.Add, path: p, value: c } : { op: F.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
406
  t.forEach((u) => {
407
407
  if (!e.has(u)) {
408
- const a = n.concat([o]), d = Ee(a, s);
408
+ const a = n.concat([o]), c = Ee(a, s);
409
409
  r.push({
410
- op: L.Remove,
411
- path: d,
410
+ op: F.Remove,
411
+ path: c,
412
412
  value: u
413
413
  }), i.unshift({
414
- op: L.Add,
415
- path: d,
414
+ op: F.Add,
415
+ path: c,
416
416
  value: u
417
417
  });
418
418
  }
419
419
  o += 1;
420
420
  }), o = 0, e.forEach((u) => {
421
421
  if (!t.has(u)) {
422
- const a = n.concat([o]), d = Ee(a, s);
422
+ const a = n.concat([o]), c = Ee(a, s);
423
423
  r.push({
424
- op: L.Add,
425
- path: d,
424
+ op: F.Add,
425
+ path: c,
426
426
  value: u
427
427
  }), i.unshift({
428
- op: L.Remove,
429
- path: d,
428
+ op: F.Remove,
429
+ path: c,
430
430
  value: u
431
431
  });
432
432
  }
433
433
  o += 1;
434
434
  });
435
435
  }
436
- function ut(t, e, n, r) {
436
+ function at(t, e, n, r) {
437
437
  const { pathAsArray: i = !0 } = t.options.enablePatches;
438
438
  switch (t.type) {
439
439
  case 0:
@@ -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, ut)), 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, at)), this;
461
461
  },
462
462
  delete(t) {
463
463
  if (!this.has(t))
@@ -500,7 +500,7 @@ const jt = (t, e, n = !1) => {
500
500
  values() {
501
501
  const t = this.keys();
502
502
  return {
503
- [vt]: () => this.values(),
503
+ [St]: () => this.values(),
504
504
  next: () => {
505
505
  const e = t.next();
506
506
  return e.done ? e : {
@@ -513,7 +513,7 @@ const jt = (t, e, n = !1) => {
513
513
  entries() {
514
514
  const t = this.keys();
515
515
  return {
516
- [vt]: () => this.entries(),
516
+ [St]: () => this.entries(),
517
517
  next: () => {
518
518
  const e = t.next();
519
519
  if (e.done)
@@ -526,7 +526,7 @@ const jt = (t, e, n = !1) => {
526
526
  }
527
527
  };
528
528
  },
529
- [vt]() {
529
+ [St]() {
530
530
  return this.entries();
531
531
  }
532
532
  }, Rs = Reflect.ownKeys(on), _r = (t, e, { isValuesIterator: n }) => () => {
@@ -536,16 +536,16 @@ const jt = (t, e, n = !1) => {
536
536
  return s;
537
537
  const o = s.value;
538
538
  let u = t.setMap.get(o);
539
- const a = j(u), d = ((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, d), !d && !a && ue(o, t.options) && !t.finalized && t.original.has(o)) {
541
- const c = In.createDraft({
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
+ const d = In.createDraft({
542
542
  original: o,
543
543
  parentDraft: t,
544
544
  key: o,
545
545
  finalities: t.finalities,
546
546
  options: t.options
547
547
  });
548
- t.setMap.set(o, c), u = c;
548
+ t.setMap.set(o, d), u = d;
549
549
  } else a && (u = a.proxy);
550
550
  return {
551
551
  done: !1,
@@ -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, ut)), 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;
569
569
  },
570
570
  delete(t) {
571
571
  if (!this.has(t))
@@ -607,7 +607,7 @@ const jt = (t, e, n = !1) => {
607
607
  keys() {
608
608
  return this.values();
609
609
  },
610
- [vt]() {
610
+ [St]() {
611
611
  return this.values();
612
612
  },
613
613
  forEach(t, e) {
@@ -650,30 +650,30 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
650
650
  return t;
651
651
  let o;
652
652
  if (t.options.mark) {
653
- const d = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
654
- if (o = t.options.mark(d, ne), o === ne.mutable)
655
- return t.options.strict && jt(d, t.options, !0), d;
653
+ const c = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
654
+ if (o = t.options.mark(c, ne), o === ne.mutable)
655
+ return t.options.strict && jt(c, t.options, !0), c;
656
656
  }
657
657
  const u = te(t);
658
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
- const d = on[e];
662
- if (d)
663
- return d.bind(t.proxy);
661
+ const c = on[e];
662
+ if (c)
663
+ return c.bind(t.proxy);
664
664
  }
665
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
- const d = Ct[e];
669
- if (d)
670
- return d.bind(t.proxy);
668
+ const c = Ct[e];
669
+ if (c)
670
+ return c.bind(t.proxy);
671
671
  }
672
- if (!tt(u, e)) {
673
- const d = yr(u, e);
674
- return d ? "value" in d ? d.value : (
672
+ if (!nt(u, e)) {
673
+ const c = yr(u, e);
674
+ return c ? "value" in c ? c.value : (
675
675
  // !case: support for getter
676
- (i = d.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
676
+ (i = c.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
677
677
  ) : void 0;
678
678
  }
679
679
  const a = u[e];
@@ -687,8 +687,8 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
687
687
  finalities: t.finalities,
688
688
  options: t.options
689
689
  }), typeof o == "function") {
690
- const d = j(t.copy[e]);
691
- return Q(d), fe(d), d.copy;
690
+ const c = j(t.copy[e]);
691
+ return Q(c), fe(c), c.copy;
692
692
  }
693
693
  return t.copy[e];
694
694
  }
@@ -705,7 +705,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
705
705
  if (s != null && s.set)
706
706
  return s.set.call(t.proxy, n), !0;
707
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);
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 || nt(t.original, e)) || (Q(t), fe(t), nt(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);
709
709
  },
710
710
  has(t, e) {
711
711
  return e in te(t);
@@ -750,26 +750,26 @@ function Dn(t) {
750
750
  setMap: o === 3 ? new Map(e.entries()) : void 0
751
751
  };
752
752
  (r || "key" in t) && (u.key = r);
753
- const { proxy: a, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, hi);
754
- if (i.revoke.push(d), li.add(a), u.proxy = a, n) {
755
- const c = n;
756
- c.finalities.draft.push((f, l) => {
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
+ const d = n;
756
+ d.finalities.draft.push((f, l) => {
757
757
  var p, y;
758
758
  const b = j(a);
759
- let _ = c.type === 3 ? c.setMap : c.copy;
760
- const T = _e(_, r), g = j(T);
761
- if (g) {
762
- let m = g.original;
763
- g.operated && (m = Rn(T)), rn(g), sn(g, ut, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(m, g.original)), at(_, r, m);
759
+ let g = d.type === 3 ? d.setMap : d.copy;
760
+ const T = _e(g, r), _ = j(T);
761
+ if (_) {
762
+ let m = _.original;
763
+ _.operated && (m = Rn(T)), rn(_), sn(_, 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, _.original)), ct(g, 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 c = j(a);
771
- c.finalities.draft.push((f, l) => {
772
- rn(c), sn(c, ut, f, l);
770
+ const d = j(a);
771
+ d.finalities.draft.push((f, l) => {
772
+ rn(d), sn(d, at, f, l);
773
773
  });
774
774
  }
775
775
  return a;
@@ -781,11 +781,11 @@ function $s(t, e, n, r, i) {
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 d = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
785
- return o && nn(o), i && Re(d, d, o == null ? void 0 : o.options.updatedValues), [
786
- d,
787
- n && a ? [{ op: L.Replace, path: [], value: e[0] }] : n,
788
- r && a ? [{ op: L.Replace, path: [], value: u }] : r
784
+ const c = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
785
+ return o && nn(o), i && Re(c, c, o == null ? void 0 : o.options.updatedValues), [
786
+ c,
787
+ n && a ? [{ op: F.Replace, path: [], value: e[0] }] : n,
788
+ r && a ? [{ op: F.Replace, path: [], value: u }] : r
789
789
  ];
790
790
  }
791
791
  function Ds(t, e) {
@@ -806,8 +806,8 @@ function Ds(t, e) {
806
806
  return [
807
807
  u,
808
808
  (a = []) => {
809
- const [d, c, f] = $s(u, a, i, s, e.enableAutoFreeze);
810
- return e.enablePatches ? [d, c, f] : d;
809
+ const [c, d, f] = $s(u, a, i, s, e.enableAutoFreeze);
810
+ return e.enablePatches ? [c, d, f] : c;
811
811
  }
812
812
  ];
813
813
  }
@@ -817,12 +817,12 @@ function un(t) {
817
817
  const a = j(o);
818
818
  if (a && e && a.finalities === e.finalities) {
819
819
  t.isContainDraft = !0;
820
- const d = a.original;
820
+ const c = a.original;
821
821
  if (u instanceof Set) {
822
- const c = Array.from(u);
823
- u.clear(), c.forEach((f) => u.add(s === f ? d : f));
822
+ const d = Array.from(u);
823
+ u.clear(), d.forEach((f) => u.add(s === f ? c : f));
824
824
  } else
825
- at(u, s, d);
825
+ ct(u, s, c);
826
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
  }
@@ -851,7 +851,7 @@ function pi(t) {
851
851
  if (n && be(_e(n.original, o), u))
852
852
  return;
853
853
  const a = pi(u);
854
- a !== u && (i === t && s(), at(i, o, a));
854
+ a !== u && (i === t && s(), ct(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);
@@ -869,36 +869,36 @@ const Us = (t) => function e(n, r, i) {
869
869
  return function(S, ...C) {
870
870
  return e(S, ($) => n.call(this, $, ...C), r);
871
871
  };
872
- const a = n, d = r;
873
- let c = i;
874
- if (typeof r != "function" && (c = r), c !== void 0 && Object.prototype.toString.call(c) !== "[object Object]")
875
- throw new Error(`Invalid options: ${c}, 'options' should be an object.`);
876
- c = Object.assign(Object.assign({}, t), c);
877
- const f = je(a) ? gr(a) : a, l = Array.isArray(c.mark) ? (S, C) => {
878
- for (const $ of c.mark) {
872
+ const a = n, c = r;
873
+ let d = i;
874
+ if (typeof r != "function" && (d = r), d !== void 0 && Object.prototype.toString.call(d) !== "[object Object]")
875
+ throw new Error(`Invalid options: ${d}, 'options' should be an object.`);
876
+ d = Object.assign(Object.assign({}, t), d);
877
+ const f = je(a) ? gr(a) : a, l = Array.isArray(d.mark) ? (S, C) => {
878
+ for (const $ of d.mark) {
879
879
  if (typeof $ != "function")
880
880
  throw new Error(`Invalid mark: ${$}, 'mark' should be a function.`);
881
881
  const D = $(S, C);
882
882
  if (D)
883
883
  return D;
884
884
  }
885
- } : c.mark, p = (s = c.enablePatches) !== null && s !== void 0 ? s : !1, y = (o = c.strict) !== null && o !== void 0 ? o : !1, _ = {
886
- enableAutoFreeze: (u = c.enableAutoFreeze) !== null && u !== void 0 ? u : !1,
885
+ } : d.mark, p = (s = d.enablePatches) !== null && s !== void 0 ? s : !1, y = (o = d.strict) !== null && o !== void 0 ? o : !1, g = {
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 (!ue(f, _) && typeof f == "object" && f !== null)
891
+ if (!ue(f, g) && 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
- const [T, g] = Ds(f, _);
893
+ const [T, _] = Ds(f, g);
894
894
  if (typeof r != "function") {
895
- if (!ue(f, _))
895
+ if (!ue(f, g))
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
- return [T, g];
897
+ return [T, _];
898
898
  }
899
899
  let m;
900
900
  try {
901
- m = d(T);
901
+ m = c(T);
902
902
  } catch (S) {
903
903
  throw nn(j(T)), S;
904
904
  }
@@ -910,24 +910,24 @@ 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 && un({
913
+ return g.strict && typeof S == "object" && S !== null && un({
914
914
  rootDraft: C,
915
915
  value: S,
916
916
  useRawReturn: !0
917
- }), g([Ve]);
917
+ }), _([Ve]);
918
918
  }
919
919
  if (S !== void 0)
920
- return typeof S == "object" && S !== null && un({ rootDraft: C, value: S }), g([S]);
920
+ return typeof S == "object" && S !== null && un({ rootDraft: C, value: S }), _([S]);
921
921
  }
922
922
  if (S === T || S === void 0)
923
- return g([]);
923
+ return _([]);
924
924
  const $ = j(S);
925
- if (_ === $.options) {
925
+ if (g === $.options) {
926
926
  if ($.operated)
927
927
  throw new Error("Cannot return a modified child draft.");
928
- return g([gr(S)]);
928
+ return _([gr(S)]);
929
929
  }
930
- return g([S]);
930
+ return _([S]);
931
931
  };
932
932
  return m instanceof Promise ? m.then(O, (S) => {
933
933
  throw nn(j(T)), S;
@@ -941,8 +941,8 @@ function yi(t, e) {
941
941
  function wr(t, e) {
942
942
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every((n) => e.hasOwnProperty(n) && t[n] === e[n]);
943
943
  }
944
- function Ot(t, e) {
945
- return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : yi(t, e) ? Object.keys(t).every((n) => Ot(t[n], e[n])) : !1;
944
+ function Et(t, e) {
945
+ return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : yi(t, e) ? Object.keys(t).every((n) => Et(t[n], e[n])) : !1;
946
946
  }
947
947
  function Un(t) {
948
948
  if (!Je(t))
@@ -1246,8 +1246,8 @@ 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, u] = n, a = i.padStart(2, "0"), d = s.padStart(2, "0"), c = `${r}-${a}-${d}T${u}`;
1250
- return new Date(c);
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
+ return new Date(d);
1251
1251
  }
1252
1252
  return null;
1253
1253
  }
@@ -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 [, u, a, d, c] = o;
1259
- return u = Number(u), a = Number(a), d = Number(d), c === "PM" && u !== 12 ? u += 12 : c === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, d));
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) {
@@ -1435,13 +1435,13 @@ function Z(t, e, n) {
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 [u, a, d] = o;
1439
- const c = t.getAttr(a);
1440
- if (!c) {
1438
+ let [u, a, c] = o;
1439
+ const d = t.getAttr(a);
1440
+ if (!d) {
1441
1441
  console.warn("no such attr", a, u);
1442
1442
  continue;
1443
1443
  }
1444
- c["checked-data-type"] === "date" && n && (d = xt(d), o[2] = d), Ln(c) && Z(s, [d, a, u], o), Z(r, [u, a, d], o), Z(i, [a, u, d], 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
  }
@@ -1454,7 +1454,7 @@ function wi(t) {
1454
1454
  };
1455
1455
  }
1456
1456
  function Ti(t, e) {
1457
- return Et(t, e.triples, e.cardinalityInference, e.useDateObjects);
1457
+ return Ze(t, e.triples, e.cardinalityInference, e.useDateObjects);
1458
1458
  }
1459
1459
  function mi(t, e) {
1460
1460
  if (t)
@@ -1465,18 +1465,18 @@ function mi(t, e) {
1465
1465
  function io(t, e) {
1466
1466
  return We(t.eav, [e]) !== void 0;
1467
1467
  }
1468
- function Et(t, e, n, r) {
1468
+ function Ze(t, e, n, r) {
1469
1469
  const i = gi(t, e, r);
1470
1470
  return i.cardinalityInference = n, i.useDateObjects = r, i;
1471
1471
  }
1472
- function ct(t, e) {
1472
+ function dt(t, e) {
1473
1473
  var n, r;
1474
1474
  let i;
1475
1475
  if (Array.isArray(e[0])) {
1476
1476
  const [o, u] = e[0], a = t.aev.get(o);
1477
1477
  if (!a)
1478
1478
  return null;
1479
- i = (n = X(a, 2).find((c) => c[2] === u)) === 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)
@@ -1486,18 +1486,18 @@ function ct(t, e) {
1486
1486
  const [o, u] = s, a = t.aev.get(o);
1487
1487
  if (!a)
1488
1488
  return null;
1489
- const c = (r = X(a, 2).find((b) => b[2] === u)) === null || r === void 0 ? void 0 : r[0];
1490
- if (!c)
1489
+ const d = (r = X(a, 2).find((b) => b[2] === u)) === null || r === void 0 ? void 0 : r[0];
1490
+ if (!d)
1491
1491
  return null;
1492
1492
  const [f, l, p, ...y] = e;
1493
- return [i, l, c, ...y];
1493
+ return [i, l, d, ...y];
1494
1494
  } else {
1495
1495
  const [o, ...u] = e;
1496
1496
  return [i, ...u];
1497
1497
  }
1498
1498
  }
1499
1499
  function vi(t, e, n) {
1500
- const r = ct(t, n);
1500
+ const r = dt(t, n);
1501
1501
  if (!r)
1502
1502
  return;
1503
1503
  const [i, s, o] = r, u = e.getAttr(s);
@@ -1512,7 +1512,7 @@ function Si(t, e, n) {
1512
1512
  }
1513
1513
  function Oi(t, e, n) {
1514
1514
  var r;
1515
- const i = ct(t, n);
1515
+ const i = dt(t, n);
1516
1516
  if (!i)
1517
1517
  return;
1518
1518
  let [s, o, u] = i;
@@ -1520,12 +1520,12 @@ function Oi(t, e, n) {
1520
1520
  if (!a)
1521
1521
  return;
1522
1522
  a["checked-data-type"] === "date" && t.useDateObjects && (u = xt(u));
1523
- const d = We(t.eav, [s, o, u]), c = (r = d == null ? void 0 : d[3]) !== null && r !== void 0 ? r : Si(t, a, i), f = [s, o, u, c];
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
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
- const i = ct(t, n);
1528
+ const i = dt(t, n);
1529
1529
  if (!i)
1530
1530
  return;
1531
1531
  const [s, o, u] = i, a = e.getAttr(o);
@@ -1533,45 +1533,45 @@ function oo(t, e, n) {
1533
1533
  return;
1534
1534
  if (!Fn(a))
1535
1535
  throw new Error("merge operation is not supported for links");
1536
- const d = We(t.eav, [s, o]);
1537
- if (!d)
1538
- return;
1539
- const c = (r = d.values().next()) === null || r === void 0 ? void 0 : r.value;
1536
+ const c = We(t.eav, [s, o]);
1540
1537
  if (!c)
1541
1538
  return;
1542
- const f = c[2], l = bi(f, u), p = [
1539
+ const d = (r = c.values().next()) === null || r === void 0 ? void 0 : r.value;
1540
+ if (!d)
1541
+ return;
1542
+ const f = d[2], l = bi(f, u), p = [
1543
1543
  s,
1544
1544
  o,
1545
1545
  l,
1546
- Si(t, a, c)
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, u = ct(t, [s]);
1552
+ const [s, o] = n, u = dt(t, [s]);
1553
1553
  if (!u)
1554
1554
  return;
1555
- const [a] = u, d = t.eav.get(a);
1556
- if (d) {
1557
- for (const f of d.keys()) {
1555
+ const [a] = u, c = t.eav.get(a);
1556
+ if (c) {
1557
+ for (const f of c.keys()) {
1558
1558
  const l = e.getAttr(f);
1559
- l && l["on-delete-reverse"] === "cascade" && X(d.get(f), 1).forEach(([p, y, b]) => {
1560
- var _;
1561
- return cn(t, e, [b, (_ = l["reverse-identity"]) === null || _ === void 0 ? void 0 : _[1]]);
1559
+ l && l["on-delete-reverse"] === "cascade" && X(c.get(f), 1).forEach(([p, y, b]) => {
1560
+ var g;
1561
+ return cn(t, e, [b, (g = l["reverse-identity"]) === null || g === void 0 ? void 0 : g[1]]);
1562
1562
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
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
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
- d.size === 0 && oe(t.eav, [a]);
1568
+ c.size === 0 && oe(t.eav, [a]);
1569
1569
  }
1570
- const c = t.vae.get(a) && X(t.vae.get(a), 2);
1571
- c && c.forEach((f) => {
1570
+ const d = t.vae.get(a) && X(t.vae.get(a), 2);
1571
+ d && d.forEach((f) => {
1572
1572
  var l, p, y;
1573
- const [b, _, T] = f, g = e.getAttr(_);
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]]);
1573
+ const [b, g, T] = f, _ = e.getAttr(g);
1574
+ (!o || !_ || ((l = _["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === o) && (oe(t.eav, [b, g, T]), oe(t.aev, [g, b, T]), oe(t.vae, [T, g, b])), _ && _["on-delete"] === "cascade" && ((p = _["reverse-identity"]) === null || p === void 0 ? void 0 : p[1]) === o && cn(t, e, [b, (y = _["forward-identity"]) === null || y === void 0 ? void 0 : y[1]]);
1575
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) {
@@ -1639,7 +1639,7 @@ function X(t, e, n = []) {
1639
1639
  X(r, e - 1, n);
1640
1640
  return n;
1641
1641
  }
1642
- function gt(t, e, n) {
1642
+ function wt(t, e, n) {
1643
1643
  var r;
1644
1644
  const i = [];
1645
1645
  if (n != null && n.hasOwnProperty("$not")) {
@@ -1650,16 +1650,16 @@ function gt(t, e, n) {
1650
1650
  if (n != null && n.hasOwnProperty("$isNull")) {
1651
1651
  const { attrId: o, isNull: u, reverse: a } = n.$isNull;
1652
1652
  if (a)
1653
- for (const d of e.keys()) {
1654
- const c = t.vae.get(d), f = !c || !c.get(o);
1655
- (u ? f : !f) && i.push(e.get(d));
1656
- }
1657
- else {
1658
- const d = t.aev.get(o);
1659
1653
  for (const c of e.keys()) {
1660
- const f = !d || ((r = d.get(c)) === null || r === void 0 ? void 0 : r.get(null)) || !d.get(c);
1654
+ const d = t.vae.get(c), f = !d || !d.get(o);
1661
1655
  (u ? f : !f) && i.push(e.get(c));
1662
1656
  }
1657
+ else {
1658
+ const c = t.aev.get(o);
1659
+ for (const d of e.keys()) {
1660
+ const f = !c || ((r = c.get(d)) === null || r === void 0 ? void 0 : r.get(null)) || !c.get(d);
1661
+ (u ? f : !f) && i.push(e.get(d));
1662
+ }
1663
1663
  }
1664
1664
  return i;
1665
1665
  }
@@ -1689,15 +1689,15 @@ function ho(t, [e, n, r]) {
1689
1689
  }
1690
1690
  case "eav": {
1691
1691
  const u = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
1692
- return u ? gt(t, u, r) : [];
1692
+ return u ? wt(t, u, r) : [];
1693
1693
  }
1694
1694
  case "ev": {
1695
1695
  const u = t.eav.get(e);
1696
1696
  if (!u)
1697
1697
  return [];
1698
1698
  const a = [];
1699
- for (const d of u.values())
1700
- a.push(...gt(t, d, r));
1699
+ for (const c of u.values())
1700
+ a.push(...wt(t, c, r));
1701
1701
  return a;
1702
1702
  }
1703
1703
  case "a": {
@@ -1709,15 +1709,15 @@ function ho(t, [e, n, r]) {
1709
1709
  if (!u)
1710
1710
  return [];
1711
1711
  const a = [];
1712
- for (const d of u.values())
1713
- a.push(...gt(t, d, r));
1712
+ for (const c of u.values())
1713
+ a.push(...wt(t, c, r));
1714
1714
  return a;
1715
1715
  }
1716
1716
  case "v": {
1717
1717
  const u = [];
1718
1718
  for (const a of t.eav.values())
1719
- for (const d of a.values())
1720
- u.push(...gt(t, d, r));
1719
+ for (const c of a.values())
1720
+ u.push(...wt(t, c, r));
1721
1721
  return u;
1722
1722
  }
1723
1723
  default:
@@ -1731,8 +1731,8 @@ function po(t, e, n) {
1731
1731
  return i;
1732
1732
  for (const [s, o] of e.entries()) {
1733
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 d of a)
1735
- i[s] = d[2];
1734
+ for (const c of a)
1735
+ i[s] = c[2];
1736
1736
  }
1737
1737
  return i;
1738
1738
  }
@@ -1753,7 +1753,7 @@ function ki(t, e) {
1753
1753
  return r || ((n = t.forwardIdents.get(e)) === null || n === void 0 ? void 0 : n.get("id"));
1754
1754
  }
1755
1755
  function bo(t, e, n) {
1756
- const r = ct(t, n);
1756
+ const r = dt(t, n);
1757
1757
  if (!r)
1758
1758
  return;
1759
1759
  const [i, s, o] = r;
@@ -1764,20 +1764,20 @@ function _o(t, e, n) {
1764
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 d = a == null ? void 0 : a.mode;
1768
- if (d !== "create" && d !== "update")
1767
+ const c = a == null ? void 0 : a.mode;
1768
+ if (c !== "create" && c !== "update")
1769
1769
  return !0;
1770
- let c = !1;
1770
+ let d = !1;
1771
1771
  const f = e.getAttr(o);
1772
1772
  if (f) {
1773
1773
  const l = ki(e, f["forward-identity"][1]);
1774
- c = !!bo(t, e, [
1774
+ d = !!bo(t, e, [
1775
1775
  s,
1776
1776
  l == null ? void 0 : l.id,
1777
1777
  s
1778
1778
  ]);
1779
1779
  }
1780
- return !(d === "create" && c || d === "update" && !c);
1780
+ return !(c === "create" && d || c === "update" && !d);
1781
1781
  });
1782
1782
  return It({ store: t, attrsStore: e }, (i) => {
1783
1783
  r.forEach((s) => {
@@ -1856,11 +1856,11 @@ const jo = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a
1856
1856
  function Ne(t) {
1857
1857
  return typeof t == "string" && jo.test(t);
1858
1858
  }
1859
- const z = [];
1859
+ const V = [];
1860
1860
  for (let t = 0; t < 256; ++t)
1861
- z.push((t + 256).toString(16).slice(1));
1861
+ V.push((t + 256).toString(16).slice(1));
1862
1862
  function Co(t, e = 0) {
1863
- return (z[t[e + 0]] + z[t[e + 1]] + z[t[e + 2]] + z[t[e + 3]] + "-" + z[t[e + 4]] + z[t[e + 5]] + "-" + z[t[e + 6]] + z[t[e + 7]] + "-" + z[t[e + 8]] + z[t[e + 9]] + "-" + z[t[e + 10]] + z[t[e + 11]] + z[t[e + 12]] + z[t[e + 13]] + z[t[e + 14]] + z[t[e + 15]]).toLowerCase();
1863
+ return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
1864
1864
  }
1865
1865
  let Ht;
1866
1866
  const Io = new Uint8Array(16);
@@ -1901,7 +1901,7 @@ function xo(t, e) {
1901
1901
  function $o(t, e) {
1902
1902
  return xo(Or(t), Or(e));
1903
1903
  }
1904
- function W() {
1904
+ function z() {
1905
1905
  return Ro();
1906
1906
  }
1907
1907
  function Do(t, e) {
@@ -1918,7 +1918,7 @@ function Uo() {
1918
1918
  }
1919
1919
  const Lo = Uo();
1920
1920
  let Fo = 0;
1921
- function nt(t) {
1921
+ function rt(t) {
1922
1922
  return $t(`_${t}`, Fo++);
1923
1923
  }
1924
1924
  function $t(t, e) {
@@ -1955,18 +1955,18 @@ function Ci(t, e, n, r, i) {
1955
1955
  throw new Ke(`Could not find attr for ${[n, i]}`);
1956
1956
  if (u["value-type"] !== "ref")
1957
1957
  throw new Error(`Attr ${u.id} is not a ref`);
1958
- const [a, d] = u["forward-identity"], [c, f] = u["reverse-identity"], l = r + 1, p = s ? [
1959
- t(d, r),
1958
+ const [a, c] = u["forward-identity"], [d, f] = u["reverse-identity"], l = r + 1, p = s ? [
1959
+ t(c, r),
1960
1960
  u.id,
1961
1961
  t(f, l),
1962
- nt("time")
1962
+ rt("time")
1963
1963
  ] : [
1964
- t(d, l),
1964
+ t(c, l),
1965
1965
  u.id,
1966
1966
  t(f, r),
1967
- nt("time")
1967
+ rt("time")
1968
1968
  ];
1969
- return [s ? f : d, l, p, u, !!s];
1969
+ return [s ? f : c, l, p, u, !!s];
1970
1970
  }
1971
1971
  function Ar(t, e) {
1972
1972
  if (typeof e != "string")
@@ -2043,33 +2043,33 @@ function zo(t, e, n, r, i, s) {
2043
2043
  if (!a)
2044
2044
  throw new Ke(`No attr for etype = ${n} label = ${i}`);
2045
2045
  if (s != null && s.hasOwnProperty("$isNull")) {
2046
- const d = K(e, n, "id");
2047
- if (!d)
2046
+ const c = K(e, n, "id");
2047
+ if (!c)
2048
2048
  throw new Ke(`No attr for etype = ${n} label = id`);
2049
2049
  return [
2050
2050
  t(n, r),
2051
- d.id,
2051
+ c.id,
2052
2052
  { $isNull: { attrId: a.id, isNull: s.$isNull, reverse: !o } },
2053
- nt("time")
2053
+ rt("time")
2054
2054
  ];
2055
2055
  }
2056
2056
  return o ? [
2057
2057
  t(n, r),
2058
2058
  a.id,
2059
2059
  Wo(a, s),
2060
- nt("time")
2061
- ] : [s, a.id, t(n, r), nt("time")];
2060
+ rt("time")
2061
+ ] : [s, a.id, t(n, r), rt("time")];
2062
2062
  }
2063
2063
  function Vo(t, e, n, r, i) {
2064
- const [s, o, u] = i.reduce((a, d) => {
2065
- const [c, f, l] = a, [p, y, b] = Ci(t, e, c, f, d);
2064
+ const [s, o, u] = i.reduce((a, c) => {
2065
+ const [d, f, l] = a, [p, y, b] = Ci(t, e, d, f, c);
2066
2066
  return [p, y, [...l, b]];
2067
2067
  }, [n, r, []]);
2068
2068
  return [s, o, u];
2069
2069
  }
2070
2070
  function fn(t, e, n, r, i, s) {
2071
- const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = Vo(t, e, n, r, o), f = zo(t, e, a, d, u, s);
2072
- return c.concat([f]);
2071
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = Vo(t, e, n, r, o), f = zo(t, e, a, c, u, s);
2072
+ return d.concat([f]);
2073
2073
  }
2074
2074
  function Bo(t, e) {
2075
2075
  return e ? [e].concat(t) : t;
@@ -2087,9 +2087,9 @@ function Ho(t, e, n) {
2087
2087
  };
2088
2088
  }
2089
2089
  function kr(t, e, n, r, i, s) {
2090
- const o = t(r, i), u = s.map((a, d) => {
2091
- const c = Ho(t, o, d);
2092
- return Ii(c, n, r, i, a);
2090
+ const o = t(r, i), u = s.map((a, c) => {
2091
+ const d = Ho(t, o, c);
2092
+ return Ii(d, n, r, i, a);
2093
2093
  });
2094
2094
  return { [e]: { patterns: u, joinSym: o } };
2095
2095
  }
@@ -2114,11 +2114,11 @@ function Ii(t, e, n, r, i) {
2114
2114
  return [];
2115
2115
  const u = s.split(".");
2116
2116
  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 a = fn(t, e, n, r, u, o), d = jr(t, e, n, r, u);
2117
+ const a = fn(t, e, n, r, u, o), c = jr(t, e, n, r, u);
2118
2118
  return [
2119
2119
  {
2120
2120
  or: {
2121
- patterns: [a, ...d],
2121
+ patterns: [a, ...c],
2122
2122
  joinSym: t(n, r)
2123
2123
  }
2124
2124
  }
@@ -2142,52 +2142,52 @@ function Zo(t, e, n) {
2142
2142
  return [t(e, n), t("time", n)];
2143
2143
  }
2144
2144
  function Xo(t, e, n, r, i, s) {
2145
- const [o, u, a, d, c] = Ci(t, e, n, r, i), f = qo(a, t(n, r), s);
2146
- return [o, u, f, d, c];
2145
+ const [o, u, a, c, d] = Ci(t, e, n, r, i), f = qo(a, t(n, r), s);
2146
+ return [o, u, f, c, d];
2147
2147
  }
2148
2148
  function eu(t, e, n, { etype: r, level: i, form: s }, o) {
2149
2149
  const u = Object.keys(s).filter((a) => a !== "$");
2150
- return u.length ? Object.entries(o).map(function([d, c]) {
2150
+ return u.length ? Object.entries(o).map(function([c, d]) {
2151
2151
  return u.map(function(p) {
2152
- var y, b, _;
2153
- const T = !!(e.cardinalityInference && (!((_ = (b = (y = n.linkIndex) === null || y === void 0 ? void 0 : y[r]) === null || b === void 0 ? void 0 : b[p]) === null || _ === void 0) && _.isSingular));
2152
+ var y, b, g;
2153
+ const T = !!(e.cardinalityInference && (!((g = (b = (y = n.linkIndex) === null || y === void 0 ? void 0 : y[r]) === null || b === void 0 ? void 0 : b[p]) === null || g === void 0) && g.isSingular));
2154
2154
  try {
2155
- const [g, m, O] = Xo(t, n, r, i, p, d), S = Mi(e, n, {
2156
- etype: g,
2155
+ const [_, m, O] = Xo(t, n, r, i, p, c), S = Mi(e, n, {
2156
+ etype: _,
2157
2157
  level: m,
2158
2158
  form: s[p],
2159
2159
  join: O
2160
2160
  }), C = T ? S[0] : S;
2161
2161
  return { [p]: C };
2162
- } catch (g) {
2163
- if (g instanceof Ke)
2162
+ } catch (_) {
2163
+ if (_ instanceof Ke)
2164
2164
  return { [p]: T ? void 0 : [] };
2165
- throw g;
2165
+ throw _;
2166
2166
  }
2167
2167
  }).reduce(function(p, y) {
2168
2168
  return Object.assign(Object.assign({}, p), y);
2169
- }, c);
2169
+ }, d);
2170
2170
  }) : Object.values(o);
2171
2171
  }
2172
2172
  function tu(t, e, n) {
2173
2173
  return n === "string" ? Lo(t, e) : t > e ? 1 : -1;
2174
2174
  }
2175
- function Ze(t, e, n, r, i) {
2175
+ function Xe(t, e, n, r, i) {
2176
2176
  return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 : tu(e, r, i);
2177
2177
  }
2178
2178
  function Pt([t, e], [n, r], i) {
2179
- return Ze(t, e, n, r, i);
2179
+ return Xe(t, e, n, r, i);
2180
2180
  }
2181
2181
  function ln(t) {
2182
2182
  return t == null ? t : new Date(t).getTime();
2183
2183
  }
2184
2184
  function nu(t, e, n, r) {
2185
2185
  var i;
2186
- const [s, o, u, a] = t, d = n === "desc" ? 1 : -1;
2186
+ const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
2187
2187
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2188
- return Pt(r, [s, a], null) === d;
2189
- const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(u) : u;
2190
- return Pt([c, p], [s, y], l) === d;
2188
+ return Pt(r, [s, a], null) === c;
2189
+ const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(u) : u;
2190
+ return Pt([d, p], [s, y], l) === c;
2191
2191
  }
2192
2192
  function ru(t, e) {
2193
2193
  const n = e[1];
@@ -2220,30 +2220,30 @@ function ou(t, e, n) {
2220
2220
  }
2221
2221
  function uu(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2222
2222
  var o, u;
2223
- const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, d = Pi(s), c = au(s);
2223
+ const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = au(s);
2224
2224
  let f = Ao(t, i);
2225
2225
  const l = r == null ? void 0 : r["start-cursor"], p = su(e, n, l, a);
2226
2226
  if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
2227
- const _ = p["checked-data-type"] === "date", T = p.id;
2228
- f = f.map(([g]) => {
2227
+ const g = p["checked-data-type"] === "date", T = p.id;
2228
+ f = f.map(([_]) => {
2229
2229
  var m, O, S, C, $;
2230
- let D = ($ = (C = (S = (O = (m = t.eav.get(g)) === null || m === void 0 ? void 0 : m.get(T)) === null || O === void 0 ? void 0 : O.values()) === null || S === void 0 ? void 0 : S.next()) === null || C === void 0 ? void 0 : C.value) === null || $ === void 0 ? void 0 : $[2];
2231
- return _ && (D = ln(D)), [g, D];
2230
+ let D = ($ = (C = (S = (O = (m = t.eav.get(_)) === null || m === void 0 ? void 0 : m.get(T)) === null || O === void 0 ? void 0 : O.values()) === null || S === void 0 ? void 0 : S.next()) === null || C === void 0 ? void 0 : C.value) === null || $ === void 0 ? void 0 : $[2];
2231
+ return g && (D = ln(D)), [_, D];
2232
2232
  });
2233
2233
  }
2234
- f.sort(c === "asc" ? function(T, g) {
2235
- return Pt(T, g, p == null ? void 0 : p["checked-data-type"]);
2236
- } : function(T, g) {
2237
- return Pt(g, T, p == null ? void 0 : p["checked-data-type"]);
2234
+ f.sort(d === "asc" ? function(T, _) {
2235
+ return Pt(T, _, p == null ? void 0 : p["checked-data-type"]);
2236
+ } : function(T, _) {
2237
+ return Pt(_, T, p == null ? void 0 : p["checked-data-type"]);
2238
2238
  });
2239
2239
  let y = {};
2240
2240
  const b = ou(e, n, i);
2241
- for (const _ of f) {
2242
- const [T] = _;
2243
- if (y[T] || !d && l && p && nu(l, p, c, _))
2241
+ for (const g of f) {
2242
+ const [T] = g;
2243
+ if (y[T] || !c && l && p && nu(l, p, d, g))
2244
2244
  continue;
2245
- const g = po(t, b, T);
2246
- g && (y[T] = g);
2245
+ const _ = po(t, b, T);
2246
+ _ && (y[T] = _);
2247
2247
  }
2248
2248
  return y;
2249
2249
  }
@@ -2258,7 +2258,7 @@ function Pi(t) {
2258
2258
  return !i && !s && !o;
2259
2259
  }
2260
2260
  function cu(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2261
- var u, a, d, c, f;
2261
+ var u, a, c, d, f;
2262
2262
  if (!Pi(i) && (!o || !o["start-cursor"]))
2263
2263
  return [];
2264
2264
  const l = Bo(Jo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = Zo($t, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = uu(t, e, {
@@ -2266,11 +2266,11 @@ function cu(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2266
2266
  pageInfo: o,
2267
2267
  form: i,
2268
2268
  dq: { where: l, find: p, fields: y }
2269
- }), _ = ((d = i.$) === null || d === void 0 ? void 0 : d.limit) || ((c = i.$) === null || c === void 0 ? void 0 : c.first) || ((f = i.$) === null || f === void 0 ? void 0 : f.last);
2270
- if (_ != null) {
2269
+ }), g = ((c = i.$) === null || c === void 0 ? void 0 : c.limit) || ((d = i.$) === null || d === void 0 ? void 0 : d.first) || ((f = i.$) === null || f === void 0 ? void 0 : f.last);
2270
+ if (g != null) {
2271
2271
  r > 0 && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2272
2272
  const T = Object.entries(b);
2273
- return T.length <= _ ? b : Object.fromEntries(T.slice(0, _));
2273
+ return T.length <= g ? b : Object.fromEntries(T.slice(0, g));
2274
2274
  }
2275
2275
  return b;
2276
2276
  }
@@ -2299,12 +2299,12 @@ function fu(t) {
2299
2299
  return e;
2300
2300
  }
2301
2301
  function Ri({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
2302
- const o = { data: Object.keys(i).reduce(function(a, d) {
2303
- return r != null && r[d] || d === "$$ruleParams" || (a[d] = Mi(t, e, {
2304
- etype: d,
2305
- form: i[d],
2302
+ const o = { data: Object.keys(i).reduce(function(a, c) {
2303
+ return r != null && r[c] || c === "$$ruleParams" || (a[c] = Mi(t, e, {
2304
+ etype: c,
2305
+ form: i[c],
2306
2306
  level: 0,
2307
- pageInfo: n == null ? void 0 : n[d]
2307
+ pageInfo: n == null ? void 0 : n[c]
2308
2308
  })), a;
2309
2309
  }, {}) };
2310
2310
  return n && (o.pageInfo = fu(n)), r && (o.aggregate = r), o;
@@ -2343,7 +2343,7 @@ function hn(t, e, n) {
2343
2343
  }
2344
2344
  });
2345
2345
  }
2346
- function Uc(t, e) {
2346
+ function Lc(t, e) {
2347
2347
  return `lookup__${t}__${JSON.stringify(e)}`;
2348
2348
  }
2349
2349
  function Mt(t) {
@@ -2372,7 +2372,7 @@ function Kn() {
2372
2372
  }
2373
2373
  });
2374
2374
  }
2375
- const Lc = Kn();
2375
+ const Fc = Kn();
2376
2376
  function yu(t) {
2377
2377
  return t.__ops;
2378
2378
  }
@@ -2383,8 +2383,8 @@ function bu(t, e) {
2383
2383
  if (u)
2384
2384
  i.push(u);
2385
2385
  else if (Array.isArray(o) && o.length == 2 && n[o[0]]) {
2386
- const [a, d] = o;
2387
- i.push([n[a], d]);
2386
+ const [a, c] = o;
2387
+ i.push([n[a], c]);
2388
2388
  } else
2389
2389
  i.push(o);
2390
2390
  }
@@ -2446,20 +2446,20 @@ function $i(t, e, n, r) {
2446
2446
  }
2447
2447
  function Tu({ attrsStore: t }, [e, n, r]) {
2448
2448
  const i = Object.entries(r).flatMap(([s, o]) => {
2449
- const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = Ie(t, e, s);
2450
- return u.map((c) => a ? [
2449
+ const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2450
+ return u.map((d) => a ? [
2451
2451
  "add-triple",
2452
2452
  ee(t, e, n),
2453
2453
  a.id,
2454
2454
  // Uses `!` because if we get here, we should have created the attr if it doesn't
2455
2455
  // already exist
2456
- ee(t, a["reverse-identity"][1], c)
2456
+ ee(t, a["reverse-identity"][1], d)
2457
2457
  ] : [
2458
2458
  "add-triple",
2459
2459
  // Uses `!` because if we get here, we should have created the attr if it doesn't
2460
2460
  // already exist
2461
- ee(t, d["forward-identity"][1], c),
2462
- d == null ? void 0 : d.id,
2461
+ ee(t, c["forward-identity"][1], d),
2462
+ c == null ? void 0 : c.id,
2463
2463
  ee(t, e, n)
2464
2464
  ]);
2465
2465
  });
@@ -2467,20 +2467,20 @@ function Tu({ attrsStore: t }, [e, n, r]) {
2467
2467
  }
2468
2468
  function mu({ attrsStore: t }, [e, n, r]) {
2469
2469
  const i = Object.entries(r).flatMap(([s, o]) => {
2470
- const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = Ie(t, e, s);
2471
- return u.map((c) => a ? [
2470
+ const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2471
+ return u.map((d) => a ? [
2472
2472
  "retract-triple",
2473
2473
  ee(t, e, n),
2474
2474
  a.id,
2475
2475
  // Uses `!` because if we get here, we should have created the attr if it doesn't
2476
2476
  // already exist
2477
- ee(t, a["reverse-identity"][1], c)
2477
+ ee(t, a["reverse-identity"][1], d)
2478
2478
  ] : [
2479
2479
  "retract-triple",
2480
2480
  // Uses `!` because if we get here, we should have created the attr if it doesn't
2481
2481
  // already exist
2482
- ee(t, d["forward-identity"][1], c),
2483
- d.id,
2482
+ ee(t, c["forward-identity"][1], d),
2483
+ c.id,
2484
2484
  ee(t, e, n)
2485
2485
  ]);
2486
2486
  });
@@ -2493,7 +2493,7 @@ function vu(t, e, n, r) {
2493
2493
  for (const u of t || []) {
2494
2494
  const a = u == null ? void 0 : u.aev.get(s);
2495
2495
  if (a) {
2496
- for (const [d, c, f] of X(a, 2))
2496
+ for (const [c, d, f] of X(a, 2))
2497
2497
  if (f === o)
2498
2498
  return !0;
2499
2499
  }
@@ -2514,13 +2514,13 @@ function Di({ stores: t, attrsStore: e }, [n, r, i, s]) {
2514
2514
  }
2515
2515
  function Su(t, e) {
2516
2516
  const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i);
2517
- return [["id", a]].concat(Object.entries(u)).map(([c, f]) => {
2518
- const l = K(n, r, c);
2517
+ return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
2518
+ const l = K(n, r, d);
2519
2519
  return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
2520
2520
  });
2521
2521
  }
2522
2522
  function Ou(t, e) {
2523
- const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), d = Di(t, [r, a, s, o]);
2523
+ const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), c = Di(t, [r, a, s, o]);
2524
2524
  return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
2525
2525
  const p = K(n, r, f);
2526
2526
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), [
@@ -2528,7 +2528,7 @@ function Ou(t, e) {
2528
2528
  a,
2529
2529
  p.id,
2530
2530
  l,
2531
- ...d ? [d] : []
2531
+ ...c ? [c] : []
2532
2532
  ];
2533
2533
  });
2534
2534
  }
@@ -2536,14 +2536,14 @@ function Eu({ attrsStore: t }, [e, n]) {
2536
2536
  return [["delete-entity", ee(t, e, n), e]];
2537
2537
  }
2538
2538
  function Au(t, e) {
2539
- const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), d = Di(t, [r, a, s, o]), c = Object.entries(u).map(([l, p]) => {
2539
+ 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
2540
  const y = K(n, r, l);
2541
2541
  return [
2542
2542
  "deep-merge-triple",
2543
2543
  a,
2544
2544
  y.id,
2545
2545
  p,
2546
- ...d ? [d] : []
2546
+ ...c ? [c] : []
2547
2547
  ];
2548
2548
  });
2549
2549
  return [[
@@ -2551,8 +2551,8 @@ function Au(t, e) {
2551
2551
  a,
2552
2552
  K(n, r, "id").id,
2553
2553
  a,
2554
- ...d ? [d] : []
2555
- ]].concat(c);
2554
+ ...c ? [c] : []
2555
+ ]].concat(d);
2556
2556
  }
2557
2557
  function ku({ attrsStore: t }, [e, n, r]) {
2558
2558
  return [["rule-params", ee(t, e, n), e, r]];
@@ -2610,8 +2610,8 @@ function Pu(t, e, n) {
2610
2610
  "checked-data-type": a
2611
2611
  };
2612
2612
  }
2613
- function wt(t, e, n, r) {
2614
- const i = t ? Pu(t, e, n) : null, s = W(), u = [W(), e, n];
2613
+ function Tt(t, e, n, r) {
2614
+ const i = t ? Pu(t, e, n) : null, s = z(), u = [z(), e, n];
2615
2615
  return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2616
2616
  }
2617
2617
  function Mu(t, e, n) {
@@ -2623,8 +2623,8 @@ function Ru(t, e, n) {
2623
2623
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2624
2624
  const { forward: i, reverse: s } = r;
2625
2625
  return {
2626
- "forward-identity": [W(), i.on, i.label],
2627
- "reverse-identity": [W(), s.on, s.label],
2626
+ "forward-identity": [z(), i.on, i.label],
2627
+ "reverse-identity": [z(), s.on, s.label],
2628
2628
  cardinality: i.has === "one" ? "one" : "many",
2629
2629
  "unique?": s.has === "one",
2630
2630
  "on-delete": i.onDelete,
@@ -2632,7 +2632,7 @@ function Ru(t, e, n) {
2632
2632
  };
2633
2633
  }
2634
2634
  function Cr(t, e, n, r) {
2635
- const i = t ? Ru(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
2635
+ const i = t ? Ru(t, e, n) : null, s = z(), o = [z(), e, n], u = [z(), n, e];
2636
2636
  return Object.assign(Object.assign({
2637
2637
  id: s,
2638
2638
  // @ts-ignore: ts thinks it's any[]
@@ -2663,9 +2663,9 @@ function Fu(t) {
2663
2663
  const o = yn(i);
2664
2664
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2665
2665
  for (const [u, a] of Object.entries(s)) {
2666
- const d = Array.isArray(a) ? a : [a];
2667
- for (const c of d) {
2668
- const f = yn(c);
2666
+ const c = Array.isArray(a) ? a : [a];
2667
+ for (const d of c) {
2668
+ const f = yn(d);
2669
2669
  f && e.push({
2670
2670
  etype: r,
2671
2671
  lookupPair: f,
@@ -2679,15 +2679,15 @@ function Nu({ attrsStore: t, schema: e }, n) {
2679
2679
  var r, i;
2680
2680
  const s = /* @__PURE__ */ new Set(), o = [], u = [];
2681
2681
  function a(y, b) {
2682
- return K(t, y, b) || o.find((_) => _["forward-identity"][1] === y && _["forward-identity"][2] === b);
2682
+ return K(t, y, b) || o.find((g) => g["forward-identity"][1] === y && g["forward-identity"][2] === b);
2683
2683
  }
2684
- function d(y, b) {
2685
- return Ie(t, y, b) || o.find((_) => {
2686
- var T, g;
2687
- return ((T = _["reverse-identity"]) === null || T === void 0 ? void 0 : T[1]) === y && ((g = _["reverse-identity"]) === null || g === void 0 ? void 0 : g[2]) === b;
2684
+ function c(y, b) {
2685
+ return Ie(t, y, b) || o.find((g) => {
2686
+ var T, _;
2687
+ return ((T = g["reverse-identity"]) === null || T === void 0 ? void 0 : T[1]) === y && ((_ = g["reverse-identity"]) === null || _ === void 0 ? void 0 : _[2]) === b;
2688
2688
  });
2689
2689
  }
2690
- function c(y) {
2690
+ function d(y) {
2691
2691
  o.push(y), u.push(["add-attr", y]), s.add(y.id);
2692
2692
  }
2693
2693
  function f(y) {
@@ -2699,40 +2699,40 @@ function Nu({ attrsStore: t, schema: e }, n) {
2699
2699
  !a(y, b);
2700
2700
  }
2701
2701
  function p(y, b) {
2702
- const _ = a(y, b), T = d(y, b);
2703
- f(_), f(T), !_ && !T && c(Cr(e, y, b, Lu));
2702
+ const g = a(y, b), T = c(y, b);
2703
+ f(g), f(T), !g && !T && d(Cr(e, y, b, Lu));
2704
2704
  }
2705
2705
  for (const y of n)
2706
- for (const { etype: b, lookupPair: _, linkLabel: T } of Fu(y)) {
2707
- const g = _[0];
2706
+ for (const { etype: b, lookupPair: g, linkLabel: T } of Fu(y)) {
2707
+ const _ = g[0];
2708
2708
  if (T) {
2709
2709
  p(b, T);
2710
- const m = a(b, T), O = d(b, T);
2710
+ const m = a(b, T), O = c(b, T);
2711
2711
  f(m), f(O);
2712
2712
  const S = ((r = m == null ? void 0 : m["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = O == null ? void 0 : O["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || T;
2713
- if (l(S, g))
2714
- p(S, pn(g));
2713
+ if (l(S, _))
2714
+ p(S, pn(_));
2715
2715
  else {
2716
- const C = a(S, g);
2717
- C || c(wt(e, S, g, bn)), f(C);
2716
+ const C = a(S, _);
2717
+ C || d(Tt(e, S, _, bn)), f(C);
2718
2718
  }
2719
- } else if (l(b, g))
2720
- p(b, pn(g));
2719
+ } else if (l(b, _))
2720
+ p(b, pn(_));
2721
2721
  else {
2722
- const m = a(b, g);
2723
- m || c(wt(e, b, g, bn)), f(m);
2722
+ const m = a(b, _);
2723
+ m || d(Tt(e, b, _, bn)), f(m);
2724
2724
  }
2725
2725
  }
2726
2726
  for (const y of n) {
2727
- const [b, _, T, g] = y;
2727
+ const [b, g, T, _] = y;
2728
2728
  if (xu.has(b)) {
2729
- const m = a(_, "id");
2730
- f(m), m || c(wt(e, _, "id", { "unique?": !0 }));
2731
- for (const O of Object.keys(g)) {
2732
- const S = a(_, O);
2733
- if (f(S), Du.has(b) && (S || c(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), $u.has(b)) {
2734
- const C = d(_, O);
2735
- !S && !C && c(Cr(e, _, O)), f(C);
2729
+ const m = a(g, "id");
2730
+ f(m), m || d(Tt(e, g, "id", { "unique?": !0 }));
2731
+ for (const O of Object.keys(_)) {
2732
+ const S = a(g, O);
2733
+ if (f(S), Du.has(b) && (S || d(Tt(e, g, O, O === "id" ? { "unique?": !0 } : null))), $u.has(b)) {
2734
+ const C = c(g, O);
2735
+ !S && !C && d(Cr(e, g, O)), f(C);
2736
2736
  }
2737
2737
  }
2738
2738
  }
@@ -2756,30 +2756,30 @@ var de = function(t, e, n, r) {
2756
2756
  });
2757
2757
  }
2758
2758
  return new (n || (n = Promise))(function(s, o) {
2759
- function u(c) {
2759
+ function u(d) {
2760
2760
  try {
2761
- d(r.next(c));
2761
+ c(r.next(d));
2762
2762
  } catch (f) {
2763
2763
  o(f);
2764
2764
  }
2765
2765
  }
2766
- function a(c) {
2766
+ function a(d) {
2767
2767
  try {
2768
- d(r.throw(c));
2768
+ c(r.throw(d));
2769
2769
  } catch (f) {
2770
2770
  o(f);
2771
2771
  }
2772
2772
  }
2773
- function d(c) {
2774
- c.done ? s(c.value) : i(c.value).then(u, a);
2773
+ function c(d) {
2774
+ d.done ? s(d.value) : i(d.value).then(u, a);
2775
2775
  }
2776
- d((r = r.apply(t, e || [])).next());
2776
+ c((r = r.apply(t, e || [])).next());
2777
2777
  });
2778
2778
  };
2779
2779
  function Ir(t, e) {
2780
2780
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2781
2781
  }
2782
- const rt = "__meta";
2782
+ const it = "__meta";
2783
2783
  class qu {
2784
2784
  constructor(e, n) {
2785
2785
  }
@@ -2800,7 +2800,7 @@ class _n {
2800
2800
  var e, n, r;
2801
2801
  this._meta.loadingPromise && (yield this._meta.loadingPromise);
2802
2802
  try {
2803
- const i = this._persister.getItem(rt);
2803
+ const i = this._persister.getItem(it);
2804
2804
  this._meta.loadingPromise = i;
2805
2805
  const s = yield i;
2806
2806
  this._meta.isLoading = !1, this._meta.error = null, this._meta.loadingPromise = null, this._meta.attempts = 0;
@@ -2881,10 +2881,10 @@ class _n {
2881
2881
  const i = [], s = e == null ? void 0 : e.skipGc;
2882
2882
  if (this._meta.isLoading) {
2883
2883
  const p = new Promise((y, b) => {
2884
- var _;
2885
- setTimeout(() => this._enqueuePersist(e ? Object.assign(Object.assign({}, e), { attempts: (e.attempts || 0) + 1 }) : { attempts: 1 }).then(y).catch(b), 10 + ((_ = e == null ? void 0 : e.attempts) !== null && _ !== void 0 ? _ : 0) * 1e3);
2884
+ var g;
2885
+ setTimeout(() => this._enqueuePersist(e ? Object.assign(Object.assign({}, e), { attempts: (e.attempts || 0) + 1 }) : { attempts: 1 }).then(y).catch(b), 10 + ((g = e == null ? void 0 : e.attempts) !== null && g !== void 0 ? g : 0) * 1e3);
2886
2886
  });
2887
- return i.push(p), Promise.all(i).then((y) => y.reduce((b, _) => b + _, 0));
2887
+ return i.push(p), Promise.all(i).then((y) => y.reduce((b, g) => b + g, 0));
2888
2888
  }
2889
2889
  const o = this._meta.value;
2890
2890
  if (!o)
@@ -2896,23 +2896,23 @@ class _n {
2896
2896
  const y = this._persister.removeItem(p);
2897
2897
  i.push(y.then(() => 1)), this._loadedKeys.delete(p), this._pendingSaveKeys.delete(p);
2898
2898
  }
2899
- const d = [], c = [[rt, o]], f = (n = o.objects) !== null && n !== void 0 ? n : {};
2899
+ const c = [], d = [[it, o]], f = (n = o.objects) !== null && n !== void 0 ? n : {};
2900
2900
  o.objects = f;
2901
2901
  for (const p of a)
2902
2902
  if (this._loadedKeys.has(p)) {
2903
2903
  const y = this.serialize(p, this.currentValue[p]);
2904
- c.push([p, y]);
2905
- const b = this._objectSize(y), _ = (r = f[p]) !== null && r !== void 0 ? r : {
2904
+ d.push([p, y]);
2905
+ const b = this._objectSize(y), g = (r = f[p]) !== null && r !== void 0 ? r : {
2906
2906
  createdAt: Date.now(),
2907
2907
  updatedAt: Date.now(),
2908
2908
  size: b
2909
2909
  };
2910
- _.updatedAt = Date.now(), _.size = b, f[p] = _, this._pendingSaveKeys.delete(p);
2910
+ g.updatedAt = Date.now(), g.size = b, f[p] = g, this._pendingSaveKeys.delete(p);
2911
2911
  } else
2912
- d.push(p);
2913
- const l = this._persister.multiSet(c);
2912
+ c.push(p);
2913
+ const l = this._persister.multiSet(d);
2914
2914
  i.push(l.then(() => 1));
2915
- for (const p of d) {
2915
+ for (const p of c) {
2916
2916
  const y = this._loadKey(p).then(() => this._enqueuePersist(e));
2917
2917
  i.push(y);
2918
2918
  }
@@ -2928,7 +2928,7 @@ class _n {
2928
2928
  if (!this._gcOpts)
2929
2929
  return;
2930
2930
  const e = new Set(yield this._persister.getAllKeys());
2931
- e.delete(rt);
2931
+ e.delete(it);
2932
2932
  const n = new Set(Object.keys(this.currentValue));
2933
2933
  for (const l of Object.keys(this._loadingKeys))
2934
2934
  n.add(l);
@@ -2961,12 +2961,12 @@ class _n {
2961
2961
  if (u.length > this._gcOpts.maxEntries)
2962
2962
  for (const [l] of a.slice(0, u.length - this._gcOpts.maxEntries))
2963
2963
  i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedThresholdCount++;
2964
- const d = Object.entries(r.objects);
2965
- d.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
2966
- const c = d.filter(([l]) => !n.has(l));
2967
- let f = d.reduce((l, [p, y]) => l + y.size, 0);
2968
- for (; f > 0 && f > this._gcOpts.maxSize && c.length; ) {
2969
- const [[l, p]] = c.splice(0, 1);
2964
+ const c = Object.entries(r.objects);
2965
+ c.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
2966
+ const d = c.filter(([l]) => !n.has(l));
2967
+ let f = c.reduce((l, [p, y]) => l + y.size, 0);
2968
+ for (; f > 0 && f > this._gcOpts.maxSize && d.length; ) {
2969
+ const [[l, p]] = d.splice(0, 1);
2970
2970
  f -= p.size, i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedSizeCount++;
2971
2971
  }
2972
2972
  for (const l of Object.keys(r.objects))
@@ -3032,24 +3032,24 @@ var ye = function(t, e, n, r) {
3032
3032
  });
3033
3033
  }
3034
3034
  return new (n || (n = Promise))(function(s, o) {
3035
- function u(c) {
3035
+ function u(d) {
3036
3036
  try {
3037
- d(r.next(c));
3037
+ c(r.next(d));
3038
3038
  } catch (f) {
3039
3039
  o(f);
3040
3040
  }
3041
3041
  }
3042
- function a(c) {
3042
+ function a(d) {
3043
3043
  try {
3044
- d(r.throw(c));
3044
+ c(r.throw(d));
3045
3045
  } catch (f) {
3046
3046
  o(f);
3047
3047
  }
3048
3048
  }
3049
- function d(c) {
3050
- c.done ? s(c.value) : i(c.value).then(u, a);
3049
+ function c(d) {
3050
+ d.done ? s(d.value) : i(d.value).then(u, a);
3051
3051
  }
3052
- d((r = r.apply(t, e || [])).next());
3052
+ c((r = r.apply(t, e || [])).next());
3053
3053
  });
3054
3054
  };
3055
3055
  const Wu = 6, zu = ["kv", "querySubs", "syncSubs"];
@@ -3084,22 +3084,22 @@ function Gu(t, e, n) {
3084
3084
  return;
3085
3085
  const i = /* @__PURE__ */ new Set();
3086
3086
  return new Promise((s, o) => {
3087
- var u, a, d, c;
3087
+ var u, a, c, d;
3088
3088
  const f = {};
3089
3089
  for (const [y, b] of Object.entries(r)) {
3090
- const _ = typeof b == "string" ? JSON.parse(b) : b;
3091
- if (_.lastAccessed) {
3092
- const g = {
3093
- createdAt: _.lastAccessed,
3094
- updatedAt: _.lastAccessed,
3095
- size: (c = (d = (a = (u = _.result) === null || u === void 0 ? void 0 : u.store) === null || a === void 0 ? void 0 : a.triples) === null || d === void 0 ? void 0 : d.length) !== null && c !== void 0 ? c : 0
3090
+ const g = typeof b == "string" ? JSON.parse(b) : b;
3091
+ if (g.lastAccessed) {
3092
+ const _ = {
3093
+ createdAt: g.lastAccessed,
3094
+ updatedAt: g.lastAccessed,
3095
+ size: (d = (c = (a = (u = g.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
3096
  };
3097
- f[y] = g;
3097
+ f[y] = _;
3098
3098
  }
3099
- const T = n.put(_, y);
3099
+ const T = n.put(g, y);
3100
3100
  i.add(T);
3101
3101
  }
3102
- const l = { objects: f }, p = n.put(l, rt);
3102
+ const l = { objects: f }, p = n.put(l, it);
3103
3103
  i.add(p);
3104
3104
  for (const y of i)
3105
3105
  y.onsuccess = () => {
@@ -3123,45 +3123,45 @@ function Qu(t, e) {
3123
3123
  const n = yield Bu(`instant_${t}_5`);
3124
3124
  if (!n)
3125
3125
  return;
3126
- const r = yield new Promise((c, f) => {
3126
+ const r = yield new Promise((d, f) => {
3127
3127
  const y = n.transaction(["kv"], "readonly").objectStore("kv").openCursor();
3128
- y.onerror = (_) => {
3129
- f(_);
3128
+ y.onerror = (g) => {
3129
+ f(g);
3130
3130
  };
3131
3131
  const b = [];
3132
3132
  y.onsuccess = () => {
3133
- const _ = y.result;
3134
- if (_) {
3135
- const T = _.key, g = _.value;
3136
- b.push([T, g]), _.continue();
3133
+ const g = y.result;
3134
+ if (g) {
3135
+ const T = g.key, _ = g.value;
3136
+ b.push([T, _]), g.continue();
3137
3137
  } else
3138
- c(b);
3139
- }, y.onerror = (_) => {
3140
- f(_);
3138
+ d(b);
3139
+ }, y.onerror = (g) => {
3140
+ f(g);
3141
3141
  };
3142
3142
  }), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), u = [], a = { objects: {} };
3143
- for (const [c, f] of r)
3144
- switch (c) {
3143
+ for (const [d, f] of r)
3144
+ switch (d) {
3145
3145
  case "querySubs": {
3146
- const l = Gu(c, f, o);
3146
+ const l = Gu(d, f, o);
3147
3147
  u.push(l);
3148
3148
  break;
3149
3149
  }
3150
3150
  default: {
3151
- const l = Pr(c, f, s);
3151
+ const l = Pr(d, f, s);
3152
3152
  u.push(l);
3153
3153
  const p = {
3154
3154
  createdAt: Date.now(),
3155
3155
  updatedAt: Date.now(),
3156
3156
  size: 0
3157
3157
  };
3158
- a.objects[c] = p;
3158
+ a.objects[d] = p;
3159
3159
  break;
3160
3160
  }
3161
3161
  }
3162
- const d = Pr(rt, a, s);
3163
- u.push(d), yield Promise.all(u), yield new Promise((c, f) => {
3164
- i.oncomplete = (l) => c(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3162
+ const c = Pr(it, a, s);
3163
+ u.push(c), yield Promise.all(u), yield new Promise((d, f) => {
3164
+ i.oncomplete = (l) => d(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3165
3165
  });
3166
3166
  });
3167
3167
  }
@@ -3179,8 +3179,8 @@ class Ui extends qu {
3179
3179
  }, i.onsuccess = (s) => {
3180
3180
  const u = s.target.result;
3181
3181
  if (r) {
3182
- const a = Qu(this._appId, u).catch((d) => {
3183
- Vu("Error upgrading store from version 5 to 6.")(d);
3182
+ const a = Qu(this._appId, u).catch((c) => {
3183
+ Vu("Error upgrading store from version 5 to 6.")(c);
3184
3184
  });
3185
3185
  Mr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3186
3186
  } else {
@@ -3215,9 +3215,9 @@ class Ui extends qu {
3215
3215
  const r = yield this._dbPromise;
3216
3216
  return new Promise((i, s) => {
3217
3217
  const a = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
3218
- a.onerror = (d) => {
3219
- s(d);
3220
- }, a.onsuccess = (d) => {
3218
+ a.onerror = (c) => {
3219
+ s(c);
3220
+ }, a.onsuccess = (c) => {
3221
3221
  i();
3222
3222
  };
3223
3223
  });
@@ -3229,14 +3229,14 @@ class Ui extends qu {
3229
3229
  const n = yield this._dbPromise;
3230
3230
  return new Promise((r, i) => {
3231
3231
  const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), u = /* @__PURE__ */ new Set();
3232
- for (const [a, d] of e) {
3233
- const c = o.put(d, a);
3234
- u.add(c);
3232
+ for (const [a, c] of e) {
3233
+ const d = o.put(c, a);
3234
+ u.add(d);
3235
3235
  }
3236
3236
  for (const a of u)
3237
- a.onerror = (d) => {
3238
- s.abort(), i(d);
3239
- }, a.onsuccess = (d) => {
3237
+ a.onerror = (c) => {
3238
+ s.abort(), i(c);
3239
+ }, a.onsuccess = (c) => {
3240
3240
  u.delete(a), u.size === 0 && r();
3241
3241
  };
3242
3242
  });
@@ -3276,24 +3276,24 @@ var Hu = function(t, e, n, r) {
3276
3276
  });
3277
3277
  }
3278
3278
  return new (n || (n = Promise))(function(s, o) {
3279
- function u(c) {
3279
+ function u(d) {
3280
3280
  try {
3281
- d(r.next(c));
3281
+ c(r.next(d));
3282
3282
  } catch (f) {
3283
3283
  o(f);
3284
3284
  }
3285
3285
  }
3286
- function a(c) {
3286
+ function a(d) {
3287
3287
  try {
3288
- d(r.throw(c));
3288
+ c(r.throw(d));
3289
3289
  } catch (f) {
3290
3290
  o(f);
3291
3291
  }
3292
3292
  }
3293
- function d(c) {
3294
- c.done ? s(c.value) : i(c.value).then(u, a);
3293
+ function c(d) {
3294
+ d.done ? s(d.value) : i(d.value).then(u, a);
3295
3295
  }
3296
- d((r = r.apply(t, e || [])).next());
3296
+ c((r = r.apply(t, e || [])).next());
3297
3297
  });
3298
3298
  };
3299
3299
  class Li {
@@ -3330,24 +3330,24 @@ var Yu = function(t, e, n, r) {
3330
3330
  });
3331
3331
  }
3332
3332
  return new (n || (n = Promise))(function(s, o) {
3333
- function u(c) {
3333
+ function u(d) {
3334
3334
  try {
3335
- d(r.next(c));
3335
+ c(r.next(d));
3336
3336
  } catch (f) {
3337
3337
  o(f);
3338
3338
  }
3339
3339
  }
3340
- function a(c) {
3340
+ function a(d) {
3341
3341
  try {
3342
- d(r.throw(c));
3342
+ c(r.throw(d));
3343
3343
  } catch (f) {
3344
3344
  o(f);
3345
3345
  }
3346
3346
  }
3347
- function d(c) {
3348
- c.done ? s(c.value) : i(c.value).then(u, a);
3347
+ function c(d) {
3348
+ d.done ? s(d.value) : i(d.value).then(u, a);
3349
3349
  }
3350
- d((r = r.apply(t, e || [])).next());
3350
+ c((r = r.apply(t, e || [])).next());
3351
3351
  });
3352
3352
  };
3353
3353
  class Dt extends qe {
@@ -3375,24 +3375,24 @@ var ze = function(t, e, n, r) {
3375
3375
  });
3376
3376
  }
3377
3377
  return new (n || (n = Promise))(function(s, o) {
3378
- function u(c) {
3378
+ function u(d) {
3379
3379
  try {
3380
- d(r.next(c));
3380
+ c(r.next(d));
3381
3381
  } catch (f) {
3382
3382
  o(f);
3383
3383
  }
3384
3384
  }
3385
- function a(c) {
3385
+ function a(d) {
3386
3386
  try {
3387
- d(r.throw(c));
3387
+ c(r.throw(d));
3388
3388
  } catch (f) {
3389
3389
  o(f);
3390
3390
  }
3391
3391
  }
3392
- function d(c) {
3393
- c.done ? s(c.value) : i(c.value).then(u, a);
3392
+ function c(d) {
3393
+ d.done ? s(d.value) : i(d.value).then(u, a);
3394
3394
  }
3395
- d((r = r.apply(t, e || [])).next());
3395
+ c((r = r.apply(t, e || [])).next());
3396
3396
  });
3397
3397
  };
3398
3398
  function Ju({ apiURI: t, appId: e, email: n }) {
@@ -3481,35 +3481,35 @@ function na(t) {
3481
3481
  });
3482
3482
  });
3483
3483
  }
3484
- var dt = function(t, e, n, r) {
3484
+ var ft = function(t, e, n, r) {
3485
3485
  function i(s) {
3486
3486
  return s instanceof n ? s : new n(function(o) {
3487
3487
  o(s);
3488
3488
  });
3489
3489
  }
3490
3490
  return new (n || (n = Promise))(function(s, o) {
3491
- function u(c) {
3491
+ function u(d) {
3492
3492
  try {
3493
- d(r.next(c));
3493
+ c(r.next(d));
3494
3494
  } catch (f) {
3495
3495
  o(f);
3496
3496
  }
3497
3497
  }
3498
- function a(c) {
3498
+ function a(d) {
3499
3499
  try {
3500
- d(r.throw(c));
3500
+ c(r.throw(d));
3501
3501
  } catch (f) {
3502
3502
  o(f);
3503
3503
  }
3504
3504
  }
3505
- function d(c) {
3506
- c.done ? s(c.value) : i(c.value).then(u, a);
3505
+ function c(d) {
3506
+ d.done ? s(d.value) : i(d.value).then(u, a);
3507
3507
  }
3508
- d((r = r.apply(t, e || [])).next());
3508
+ c((r = r.apply(t, e || [])).next());
3509
3509
  });
3510
3510
  };
3511
3511
  function ra(t) {
3512
- return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
3512
+ return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
3513
3513
  const a = {
3514
3514
  app_id: n,
3515
3515
  path: r,
@@ -3524,7 +3524,7 @@ function ra(t) {
3524
3524
  });
3525
3525
  }
3526
3526
  function ia(t) {
3527
- return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3527
+ return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3528
3528
  const { data: s } = yield ae(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3529
3529
  method: "DELETE",
3530
3530
  headers: {
@@ -3536,7 +3536,7 @@ function ia(t) {
3536
3536
  });
3537
3537
  }
3538
3538
  function sa(t) {
3539
- return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3539
+ return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3540
3540
  const { data: o } = yield ae(`${e}/storage/signed-upload-url`, {
3541
3541
  method: "POST",
3542
3542
  headers: {
@@ -3552,7 +3552,7 @@ function sa(t) {
3552
3552
  });
3553
3553
  }
3554
3554
  function oa(t, e) {
3555
- return dt(this, void 0, void 0, function* () {
3555
+ return ft(this, void 0, void 0, function* () {
3556
3556
  return (yield fetch(t, {
3557
3557
  method: "PUT",
3558
3558
  body: e,
@@ -3563,7 +3563,7 @@ function oa(t, e) {
3563
3563
  });
3564
3564
  }
3565
3565
  function ua(t) {
3566
- return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3566
+ return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3567
3567
  const { data: s } = yield ae(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3568
3568
  method: "GET",
3569
3569
  headers: {
@@ -3594,10 +3594,10 @@ function aa(t, e, n) {
3594
3594
  s.user = Object.assign(Object.assign({}, u), { peerId: n });
3595
3595
  }
3596
3596
  for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3597
- const a = (e == null ? void 0 : e.peers) === void 0, d = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
3598
- if (a || d) {
3599
- const c = xr(t.peers[u], e == null ? void 0 : e.keys);
3600
- s.peers[u] = Object.assign(Object.assign({}, c), { peerId: u });
3597
+ const a = (e == null ? void 0 : e.peers) === void 0, c = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
3598
+ if (a || c) {
3599
+ const d = xr(t.peers[u], e == null ? void 0 : e.keys);
3600
+ s.peers[u] = Object.assign(Object.assign({}, d), { peerId: u });
3601
3601
  }
3602
3602
  }
3603
3603
  return s;
@@ -3650,7 +3650,7 @@ function Ur(t) {
3650
3650
  }, e;
3651
3651
  }, {});
3652
3652
  }
3653
- const Wn = "v0.22.93";
3653
+ const Wn = "v0.22.94-experimental.drewh-ssr.20384771877.1";
3654
3654
  function da(t, e) {
3655
3655
  return {
3656
3656
  info: t ? (...n) => console.info(...n, e()) : () => {
@@ -3751,17 +3751,17 @@ const Lr = [
3751
3751
  return !0;
3752
3752
  }
3753
3753
  }, la = (t, e, n, r, i, s, o) => {
3754
- const u = s.valueType === "json", a = (d, c, f) => {
3755
- if (!qi(f, c, u))
3756
- throw new R(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
3754
+ const u = s.valueType === "json", a = (c, d, f) => {
3755
+ if (!qi(f, d, u))
3756
+ throw new R(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
3757
3757
  };
3758
3758
  switch (t) {
3759
3759
  case "in":
3760
3760
  case "$in":
3761
3761
  if (!Array.isArray(e))
3762
3762
  throw new R(`Operator '${t}' for attribute '${r}' in entity '${i}' must be an array, but received: ${typeof e}`, o);
3763
- for (const d of e)
3764
- a(t, n, d);
3763
+ for (const c of e)
3764
+ a(t, n, c);
3765
3765
  break;
3766
3766
  case "$not":
3767
3767
  case "$ne":
@@ -3788,8 +3788,8 @@ const Lr = [
3788
3788
  if (o)
3789
3789
  return;
3790
3790
  const a = t;
3791
- for (const [d, c] of Object.entries(a))
3792
- la(d, c, s, e, r, n, `${i}.${d}`);
3791
+ for (const [c, d] of Object.entries(a))
3792
+ la(c, d, s, e, r, n, `${i}.${c}`);
3793
3793
  } else if (!qi(t, s, o))
3794
3794
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3795
3795
  }, ha = (t, e, n, r, i) => {
@@ -3797,8 +3797,8 @@ const Lr = [
3797
3797
  if (s.length < 2)
3798
3798
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
3799
3799
  let o = n;
3800
- for (let c = 0; c < s.length - 1; c++) {
3801
- const f = s[c], l = r.entities[o];
3800
+ for (let d = 0; d < s.length - 1; d++) {
3801
+ const f = s[d], l = r.entities[o];
3802
3802
  if (!l)
3803
3803
  throw new R(`Entity '${o}' does not exist in schema while traversing dot notation path '${t}'.`, i);
3804
3804
  const p = l.links[f];
@@ -3817,24 +3817,24 @@ const Lr = [
3817
3817
  Le(e, t, new H("string", !1, !0), n, i);
3818
3818
  return;
3819
3819
  }
3820
- const d = a.attrs[u];
3820
+ const c = a.attrs[u];
3821
3821
  if (Object.keys(a.links).includes(u)) {
3822
3822
  if (typeof e == "string" && !Ne(e))
3823
3823
  throw new R(`Invalid value for link '${u}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3824
3824
  Le(e, t, new H("string", !1, !0), n, i);
3825
3825
  return;
3826
3826
  }
3827
- if (!d) {
3828
- const c = Object.keys(a.attrs);
3829
- throw new R(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") + ", id" : "id"}`, i);
3827
+ if (!c) {
3828
+ const d = Object.keys(a.attrs);
3829
+ throw new R(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${d.length > 0 ? d.join(", ") + ", id" : "id"}`, i);
3830
3830
  }
3831
- Le(e, t, d, n, i);
3831
+ Le(e, t, c, n, i);
3832
3832
  }, Wi = (t, e, n, r) => {
3833
3833
  for (const [i, s] of Object.entries(t)) {
3834
3834
  if (i === "or" || i === "and") {
3835
3835
  if (Array.isArray(s))
3836
- for (const d of s)
3837
- typeof d == "object" && d !== null && Wi(d, e, n, `${r}.${i}[${d}]`);
3836
+ for (const c of s)
3837
+ typeof c == "object" && c !== null && Wi(c, e, n, `${r}.${i}[${c}]`);
3838
3838
  continue;
3839
3839
  }
3840
3840
  if (i === "id") {
@@ -3850,16 +3850,16 @@ const Lr = [
3850
3850
  continue;
3851
3851
  const u = o.attrs[i], a = o.links[i];
3852
3852
  if (!u && !a) {
3853
- const d = Object.keys(o.attrs), c = Object.keys(o.links);
3854
- throw new R(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${d.length > 0 ? d.join(", ") : "none"}. Available links: ${c.length > 0 ? c.join(", ") : "none"}`, `${r}.${i}`);
3853
+ const c = Object.keys(o.attrs), d = Object.keys(o.links);
3854
+ throw new R(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${c.length > 0 ? c.join(", ") : "none"}. Available links: ${d.length > 0 ? d.join(", ") : "none"}`, `${r}.${i}`);
3855
3855
  }
3856
3856
  if (u)
3857
3857
  Le(s, i, u, e, `${r}.${i}`);
3858
3858
  else if (a) {
3859
3859
  if (typeof s == "string" && !Ne(s))
3860
3860
  throw new R(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${s}`, `${r}.${i}`);
3861
- const d = new H("string", !1, !0);
3862
- Le(s, i, d, e, `${r}.${i}`);
3861
+ const c = new H("string", !1, !0);
3862
+ Le(s, i, c, e, `${r}.${i}`);
3863
3863
  }
3864
3864
  }
3865
3865
  }, pa = (t, e, n, r, i = 0) => {
@@ -4010,24 +4010,24 @@ var Wr = function(t, e, n, r) {
4010
4010
  });
4011
4011
  }
4012
4012
  return new (n || (n = Promise))(function(s, o) {
4013
- function u(c) {
4013
+ function u(d) {
4014
4014
  try {
4015
- d(r.next(c));
4015
+ c(r.next(d));
4016
4016
  } catch (f) {
4017
4017
  o(f);
4018
4018
  }
4019
4019
  }
4020
- function a(c) {
4020
+ function a(d) {
4021
4021
  try {
4022
- d(r.throw(c));
4022
+ c(r.throw(d));
4023
4023
  } catch (f) {
4024
4024
  o(f);
4025
4025
  }
4026
4026
  }
4027
- function d(c) {
4028
- c.done ? s(c.value) : i(c.value).then(u, a);
4027
+ function c(d) {
4028
+ d.done ? s(d.value) : i(d.value).then(u, a);
4029
4029
  }
4030
- d((r = r.apply(t, e || [])).next());
4030
+ c((r = r.apply(t, e || [])).next());
4031
4031
  });
4032
4032
  };
4033
4033
  let Gi = 0;
@@ -4154,24 +4154,24 @@ var Vr = function(t, e, n, r) {
4154
4154
  });
4155
4155
  }
4156
4156
  return new (n || (n = Promise))(function(s, o) {
4157
- function u(c) {
4157
+ function u(d) {
4158
4158
  try {
4159
- d(r.next(c));
4159
+ c(r.next(d));
4160
4160
  } catch (f) {
4161
4161
  o(f);
4162
4162
  }
4163
4163
  }
4164
- function a(c) {
4164
+ function a(d) {
4165
4165
  try {
4166
- d(r.throw(c));
4166
+ c(r.throw(d));
4167
4167
  } catch (f) {
4168
4168
  o(f);
4169
4169
  }
4170
4170
  }
4171
- function d(c) {
4172
- c.done ? s(c.value) : i(c.value).then(u, a);
4171
+ function c(d) {
4172
+ d.done ? s(d.value) : i(d.value).then(u, a);
4173
4173
  }
4174
- d((r = r.apply(t, e || [])).next());
4174
+ c((r = r.apply(t, e || [])).next());
4175
4175
  });
4176
4176
  };
4177
4177
  function ma(t, e) {
@@ -4228,12 +4228,12 @@ function Gr(t, e, n) {
4228
4228
  function Oa(t, e, n) {
4229
4229
  var r, i, s, o;
4230
4230
  const u = {};
4231
- for (const { action: a, triple: d } of n) {
4232
- const [c, f, l] = d, p = (i = (r = e.getAttr(f)) === null || r === void 0 ? void 0 : r["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
4231
+ for (const { action: a, triple: c } of n) {
4232
+ const [d, f, l] = c, p = (i = (r = e.getAttr(f)) === null || r === void 0 ? void 0 : r["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
4233
4233
  if (!p)
4234
4234
  continue;
4235
- const y = (s = u[c]) !== null && s !== void 0 ? s : {};
4236
- u[c] = y;
4235
+ const y = (s = u[d]) !== null && s !== void 0 ? s : {};
4236
+ u[d] = y;
4237
4237
  const b = (o = y[p]) !== null && o !== void 0 ? o : {};
4238
4238
  switch (a) {
4239
4239
  case "added":
@@ -4245,12 +4245,12 @@ function Oa(t, e, n) {
4245
4245
  }
4246
4246
  y[p] = b;
4247
4247
  }
4248
- for (const [a, d] of Object.entries(u))
4249
- for (const [c, { oldValue: f, newValue: l }] of Object.entries(d))
4250
- f === l && delete d[c];
4248
+ for (const [a, c] of Object.entries(u))
4249
+ for (const [d, { oldValue: f, newValue: l }] of Object.entries(c))
4250
+ f === l && delete c[d];
4251
4251
  return u;
4252
4252
  }
4253
- function Tt(t, e) {
4253
+ function mt(t, e) {
4254
4254
  return { [t.table]: e.map((n) => n.entity) };
4255
4255
  }
4256
4256
  function Ea(t, e) {
@@ -4264,17 +4264,17 @@ function Aa(t, e, n) {
4264
4264
  const r = e;
4265
4265
  if (t.orderField === "serverCreatedAt") {
4266
4266
  n.sort(t.orderDirection === "asc" ? function(o, u) {
4267
- return Ze(o.entity.id, o.serverCreatedAt, u.entity.id, u.serverCreatedAt, r);
4267
+ return Xe(o.entity.id, o.serverCreatedAt, u.entity.id, u.serverCreatedAt, r);
4268
4268
  } : function(o, u) {
4269
- return Ze(u.entity.id, u.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
4269
+ return Xe(u.entity.id, u.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
4270
4270
  });
4271
4271
  return;
4272
4272
  }
4273
4273
  const i = t.orderField;
4274
4274
  n.sort(t.orderDirection === "asc" ? function(o, u) {
4275
- return Ze(o.entity.id, o.entity[i], u.entity.id, u.entity[i], r);
4275
+ return Xe(o.entity.id, o.entity[i], u.entity.id, u.entity[i], r);
4276
4276
  } : function(o, u) {
4277
- return Ze(u.entity.id, u.entity[i], o.entity.id, o.entity[i], r);
4277
+ return Xe(u.entity.id, u.entity[i], o.entity.id, o.entity[i], r);
4278
4278
  });
4279
4279
  }
4280
4280
  var ve;
@@ -4307,7 +4307,7 @@ class ka {
4307
4307
  this.subs.flush();
4308
4308
  }
4309
4309
  subscribe(e, n) {
4310
- const r = B(e);
4310
+ const r = W(e);
4311
4311
  return this.callbacks[r] = this.callbacks[r] || [], this.callbacks[r].push(n), this.initSubscription(e, r, n), (i) => {
4312
4312
  this.unsubscribe(r, n, i == null ? void 0 : i.keepSubscription);
4313
4313
  };
@@ -4323,7 +4323,7 @@ class ka {
4323
4323
  }
4324
4324
  }
4325
4325
  sendStart(e) {
4326
- this.trySend(W(), {
4326
+ this.trySend(z(), {
4327
4327
  op: "start-sync",
4328
4328
  q: e
4329
4329
  });
@@ -4337,7 +4337,7 @@ class ka {
4337
4337
  });
4338
4338
  }
4339
4339
  sendRemove(e, n) {
4340
- this.trySend(W(), {
4340
+ this.trySend(z(), {
4341
4341
  op: "remove-sync",
4342
4342
  "subscription-id": e.subscriptionId,
4343
4343
  "keep-subscription": n
@@ -4351,16 +4351,16 @@ class ka {
4351
4351
  if (a && a.state && a.state.txId) {
4352
4352
  this.sendResync(a, a.state, a.state.txId), !((i = a.values) === null || i === void 0) && i.entities && r && r({
4353
4353
  type: ve.LoadFromStorage,
4354
- data: Tt(a, (s = a.values) === null || s === void 0 ? void 0 : s.entities)
4354
+ data: mt(a, (s = a.values) === null || s === void 0 ? void 0 : s.entities)
4355
4355
  });
4356
4356
  return;
4357
4357
  }
4358
- const d = Object.keys(e)[0], c = ((u = (o = e[d]) === null || o === void 0 ? void 0 : o.$) === null || u === void 0 ? void 0 : u.order) || { serverCreatedAt: "asc" }, [f, l] = Object.entries(c)[0];
4358
+ const c = Object.keys(e)[0], d = ((u = (o = e[c]) === null || o === void 0 ? void 0 : o.$) === null || u === void 0 ? void 0 : u.order) || { serverCreatedAt: "asc" }, [f, l] = Object.entries(d)[0];
4359
4359
  this.subs.updateInPlace((p) => {
4360
4360
  p[n] = {
4361
4361
  query: e,
4362
4362
  hash: n,
4363
- table: d,
4363
+ table: c,
4364
4364
  orderDirection: l,
4365
4365
  orderField: f,
4366
4366
  createdAt: Date.now(),
@@ -4379,7 +4379,7 @@ class ka {
4379
4379
  });
4380
4380
  }
4381
4381
  onStartSyncOk(e) {
4382
- const n = e["subscription-id"], r = e.q, i = B(r);
4382
+ const n = e["subscription-id"], r = e.q, i = W(r);
4383
4383
  this.idToHash[n] = i, this.subs.updateInPlace((s) => {
4384
4384
  const o = s[i];
4385
4385
  if (!o)
@@ -4411,20 +4411,20 @@ class ka {
4411
4411
  attrsStore: this.getAttrs()
4412
4412
  };
4413
4413
  u.values = a;
4414
- const d = a.entities;
4415
- for (const c of i) {
4416
- const f = this.createStore(c), l = Jt(u, f, a.attrsStore);
4417
- d.push({
4414
+ const c = a.entities;
4415
+ for (const d of i) {
4416
+ const f = this.createStore(d), l = Jt(u, f, a.attrsStore);
4417
+ c.push({
4418
4418
  store: f,
4419
4419
  entity: l,
4420
4420
  serverCreatedAt: Br(u, f, a.attrsStore, l.id)
4421
4421
  }), o.push(l);
4422
4422
  }
4423
- this.subs.updateInPlace((c) => {
4424
- c[s] = u, c[s].updatedAt = Date.now();
4423
+ this.subs.updateInPlace((d) => {
4424
+ d[s] = u, d[s].updatedAt = Date.now();
4425
4425
  }), u.values && this.notifyCbs(s, {
4426
4426
  type: ve.InitialSyncBatch,
4427
- data: Tt(u, u.values.entities),
4427
+ data: mt(u, u.values.entities),
4428
4428
  batch: o
4429
4429
  });
4430
4430
  }
@@ -4449,7 +4449,7 @@ class ka {
4449
4449
  const s = this.subs.currentValue[i];
4450
4450
  s && this.notifyCbs(i, {
4451
4451
  type: ve.InitialSyncComplete,
4452
- data: Tt(s, ((n = s.values) === null || n === void 0 ? void 0 : n.entities) || [])
4452
+ data: mt(s, ((n = s.values) === null || n === void 0 ? void 0 : n.entities) || [])
4453
4453
  });
4454
4454
  }
4455
4455
  onSyncUpdateTriples(e) {
@@ -4469,14 +4469,14 @@ class ka {
4469
4469
  this.log.error("Missing state for sub", u, e);
4470
4470
  return;
4471
4471
  }
4472
- for (const d of e.txes) {
4473
- if (a.txId && a.txId >= d["tx-id"])
4472
+ for (const c of e.txes) {
4473
+ if (a.txId && a.txId >= c["tx-id"])
4474
4474
  continue;
4475
- a.txId = d["tx-id"];
4476
- const c = [], f = {};
4477
- for (const g of d.changes) {
4478
- const m = (n = f[g.triple[0]]) !== null && n !== void 0 ? n : [];
4479
- f[g.triple[0]] = m, m.push(g);
4475
+ a.txId = c["tx-id"];
4476
+ const d = [], f = {};
4477
+ for (const _ of c.changes) {
4478
+ const m = (n = f[_.triple[0]]) !== null && n !== void 0 ? n : [];
4479
+ f[_.triple[0]] = m, m.push(_);
4480
4480
  }
4481
4481
  const l = (r = u.values) !== null && r !== void 0 ? r : {
4482
4482
  entities: [],
@@ -4484,22 +4484,22 @@ class ka {
4484
4484
  }, p = l.entities;
4485
4485
  u.values = l;
4486
4486
  const y = [];
4487
- e: for (const [g, m] of Object.entries(f))
4487
+ e: for (const [_, m] of Object.entries(f))
4488
4488
  for (let O = 0; O < p.length; O++) {
4489
4489
  const S = p[O];
4490
- if (io(S.store, g)) {
4490
+ if (io(S.store, _)) {
4491
4491
  Gr(S.store, l.attrsStore, m);
4492
- const C = Jt(u, S.store, l.attrsStore), $ = Oa(S.store, l.attrsStore, m)[g];
4492
+ const C = Jt(u, S.store, l.attrsStore), $ = Oa(S.store, l.attrsStore, m)[_];
4493
4493
  C ? (y.push({
4494
4494
  oldEntity: S.entity,
4495
4495
  newEntity: C,
4496
4496
  changedFields: $ || {}
4497
- }), S.entity = C) : c.push(O), delete f[g];
4497
+ }), S.entity = C) : d.push(O), delete f[_];
4498
4498
  continue e;
4499
4499
  }
4500
4500
  }
4501
4501
  const b = [];
4502
- for (const [g, m] of Object.entries(f)) {
4502
+ for (const [_, m] of Object.entries(f)) {
4503
4503
  const O = this.createStore([]);
4504
4504
  Gr(O, l.attrsStore, m);
4505
4505
  const S = Jt(u, O, l.attrsStore);
@@ -4517,20 +4517,20 @@ class ka {
4517
4517
  serverCreatedAt: Br(u, O, l.attrsStore, S.id)
4518
4518
  }), b.push(S);
4519
4519
  }
4520
- const _ = [];
4521
- for (const g of c.sort().reverse())
4522
- _.push(p[g].entity), p.splice(g, 1);
4520
+ const g = [];
4521
+ for (const _ of d.sort().reverse())
4522
+ g.push(p[_].entity), p.splice(_, 1);
4523
4523
  const T = Ea(u, this.getAttrs);
4524
4524
  Aa(u, T, p), this.notifyCbs(o, {
4525
4525
  type: ve.SyncTransaction,
4526
- data: Tt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
4526
+ data: mt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
4527
4527
  added: b,
4528
- removed: _,
4528
+ removed: g,
4529
4529
  updated: y
4530
4530
  });
4531
4531
  }
4532
- this.subs.updateInPlace((d) => {
4533
- d[o] = u, d[o].updatedAt = Date.now();
4532
+ this.subs.updateInPlace((c) => {
4533
+ c[o] = u, c[o].updatedAt = Date.now();
4534
4534
  });
4535
4535
  }
4536
4536
  clearSubscriptionData(e, n) {
@@ -4545,7 +4545,7 @@ class ka {
4545
4545
  }
4546
4546
  }
4547
4547
  onStartSyncError(e) {
4548
- const n = B(e["original-event"].q), r = {
4548
+ const n = W(e["original-event"].q), r = {
4549
4549
  message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa.",
4550
4550
  status: e.status,
4551
4551
  type: e.type,
@@ -4562,31 +4562,31 @@ class ka {
4562
4562
  r && this.initSubscription(r.query, r.hash);
4563
4563
  }
4564
4564
  }
4565
- var N = function(t, e, n, r) {
4565
+ var U = function(t, e, n, r) {
4566
4566
  function i(s) {
4567
4567
  return s instanceof n ? s : new n(function(o) {
4568
4568
  o(s);
4569
4569
  });
4570
4570
  }
4571
4571
  return new (n || (n = Promise))(function(s, o) {
4572
- function u(c) {
4572
+ function u(d) {
4573
4573
  try {
4574
- d(r.next(c));
4574
+ c(r.next(d));
4575
4575
  } catch (f) {
4576
4576
  o(f);
4577
4577
  }
4578
4578
  }
4579
- function a(c) {
4579
+ function a(d) {
4580
4580
  try {
4581
- d(r.throw(c));
4581
+ c(r.throw(d));
4582
4582
  } catch (f) {
4583
4583
  o(f);
4584
4584
  }
4585
4585
  }
4586
- function d(c) {
4587
- c.done ? s(c.value) : i(c.value).then(u, a);
4586
+ function c(d) {
4587
+ d.done ? s(d.value) : i(d.value).then(u, a);
4588
4588
  }
4589
- d((r = r.apply(t, e || [])).next());
4589
+ c((r = r.apply(t, e || [])).next());
4590
4590
  });
4591
4591
  }, Qi = function(t, e) {
4592
4592
  var n = {};
@@ -4602,11 +4602,11 @@ const he = {
4602
4602
  AUTHENTICATED: "authenticated",
4603
4603
  CLOSED: "closed",
4604
4604
  ERRORED: "errored"
4605
- }, ja = 3e4, Ca = 3e4, Ia = 200, Pa = {
4605
+ }, ja = 3e4, Ca = 3e4, Ia = 200, Pa = 1e3 * 60, Ma = {
4606
4606
  apiURI: "https://api.instantdb.com",
4607
4607
  websocketURI: "wss://api.instantdb.com/runtime/session"
4608
4608
  }, Zt = "_instant_oauth_redirect", Ge = "currentUser";
4609
- function Ma({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4609
+ function Ra({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4610
4610
  if (!i)
4611
4611
  return new zr(`${r}?app_id=${e}`);
4612
4612
  switch (t) {
@@ -4618,7 +4618,7 @@ function Ma({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl:
4618
4618
  throw new Error("Unknown transport type " + t);
4619
4619
  }
4620
4620
  }
4621
- function Ra() {
4621
+ function xa() {
4622
4622
  return typeof window < "u" || typeof chrome < "u";
4623
4623
  }
4624
4624
  const Qr = {
@@ -4627,7 +4627,7 @@ const Qr = {
4627
4627
  "refresh-presence": !0,
4628
4628
  "patch-presence": !0
4629
4629
  };
4630
- function xa(t, e) {
4630
+ function $a(t, e) {
4631
4631
  var n;
4632
4632
  const r = typeof t == "string" ? JSON.parse(t) : t;
4633
4633
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
@@ -4639,7 +4639,7 @@ function xa(t, e) {
4639
4639
  }
4640
4640
  return r;
4641
4641
  }
4642
- function $a(t, e) {
4642
+ function Da(t, e) {
4643
4643
  const { result: n } = e, i = Qi(e, ["result"]);
4644
4644
  if (n) {
4645
4645
  const s = Object.assign(Object.assign({}, n), { store: wi(n.store), attrsStore: n.attrsStore.toJSON() });
@@ -4647,7 +4647,7 @@ function $a(t, e) {
4647
4647
  }
4648
4648
  return i;
4649
4649
  }
4650
- function Da(t, e) {
4650
+ function Ua(t, e) {
4651
4651
  switch (t) {
4652
4652
  case "pendingMutations":
4653
4653
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4655,7 +4655,7 @@ function Da(t, e) {
4655
4655
  return e;
4656
4656
  }
4657
4657
  }
4658
- function Ua(t, e) {
4658
+ function La(t, e) {
4659
4659
  switch (t) {
4660
4660
  case "pendingMutations":
4661
4661
  return [...e.entries()];
@@ -4663,7 +4663,7 @@ function Ua(t, e) {
4663
4663
  return e;
4664
4664
  }
4665
4665
  }
4666
- function La(t, e, n) {
4666
+ function Fa(t, e, n) {
4667
4667
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
4668
4668
  return r && !i && n && (n.result = r), n || e;
4669
4669
  }
@@ -4673,42 +4673,42 @@ function Hr(t) {
4673
4673
  return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
4674
4674
  });
4675
4675
  }
4676
- class Fa {
4676
+ class Na {
4677
4677
  constructor(e, n = Ui, r = Li, i, s) {
4678
4678
  var o, u, a;
4679
- if (this._isOnline = !0, this._isShutdown = !1, this.status = he.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (d, c, f) => {
4679
+ if (this._isOnline = !0, this._isShutdown = !1, this.status = he.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (c, d, f) => {
4680
4680
  var l, p;
4681
- switch (d) {
4681
+ switch (c) {
4682
4682
  case "pendingMutations": {
4683
- const y = (l = c == null ? void 0 : c.entries()) !== null && l !== void 0 ? l : [], b = (p = f == null ? void 0 : f.entries()) !== null && p !== void 0 ? p : [], _ = new Map([...y, ...b]);
4684
- return (c ? this._rewriteMutationsSorted(this.attrs, c) : []).forEach(([g, m]) => {
4683
+ const y = (l = d == null ? void 0 : d.entries()) !== null && l !== void 0 ? l : [], b = (p = f == null ? void 0 : f.entries()) !== null && p !== void 0 ? p : [], g = new Map([...y, ...b]);
4684
+ return (d ? this._rewriteMutationsSorted(this.attrs, d) : []).forEach(([_, m]) => {
4685
4685
  var O;
4686
- !(!((O = f == null ? void 0 : f.pendingMutations) === null || O === void 0) && O.has(g)) && !m["tx-id"] && this._sendMutation(g, m);
4687
- }), _;
4686
+ !(!((O = f == null ? void 0 : f.pendingMutations) === null || O === void 0) && O.has(_)) && !m["tx-id"] && this._sendMutation(_, m);
4687
+ }), g;
4688
4688
  }
4689
4689
  default:
4690
- return f || c;
4691
- }
4692
- }, this.getPreviousResult = (d) => {
4693
- var c;
4694
- const f = B(d);
4695
- return (c = this.dataForQuery(f)) === null || c === void 0 ? void 0 : c.data;
4696
- }, this.notifyOne = (d) => {
4697
- var c, f;
4698
- const l = (c = this.queryCbs[d]) !== null && c !== void 0 ? c : [], p = (f = this._dataForQueryCache[d]) === null || f === void 0 ? void 0 : f.data, y = this.dataForQuery(d);
4699
- y != null && y.data && (this._dataForQueryCache[d] = y, !Ot(y.data, p) && l.forEach((b) => b.cb(y.data)));
4700
- }, this.notifyOneQueryOnce = (d) => {
4701
- var c, f;
4702
- const l = (c = this.queryOnceDfds[d]) !== null && c !== void 0 ? c : [], p = (f = this.dataForQuery(d)) === null || f === void 0 ? void 0 : f.data;
4690
+ return f || d;
4691
+ }
4692
+ }, this.getPreviousResult = (c) => {
4693
+ var d;
4694
+ const f = W(c);
4695
+ return (d = this.dataForQuery(f)) === null || d === void 0 ? void 0 : d.data;
4696
+ }, this.notifyOne = (c) => {
4697
+ var d, f;
4698
+ const l = (d = this.queryCbs[c]) !== null && d !== void 0 ? d : [], p = (f = this._dataForQueryCache[c]) === null || f === void 0 ? void 0 : f.data, y = this.dataForQuery(c);
4699
+ y != null && y.data && (this._dataForQueryCache[c] = y, !Et(y.data, p) && l.forEach((b) => b.cb(y.data)));
4700
+ }, this.notifyOneQueryOnce = (c) => {
4701
+ var d, f;
4702
+ const l = (d = this.queryOnceDfds[c]) !== null && d !== void 0 ? d : [], p = (f = this.dataForQuery(c)) === null || f === void 0 ? void 0 : f.data;
4703
4703
  l.forEach((y) => {
4704
- this._completeQueryOnce(y.q, d, y.dfd), y.dfd.resolve(p);
4704
+ this._completeQueryOnce(y.q, c, y.dfd), y.dfd.resolve(p);
4705
4705
  });
4706
- }, this.notifyQueryError = (d, c) => {
4707
- (this.queryCbs[d] || []).forEach((l) => l.cb({ error: c }));
4708
- }, this.pushTx = (d) => {
4709
- this.config.disableValidation || wa(d, this.config.schema);
4706
+ }, this.notifyQueryError = (c, d) => {
4707
+ (this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
4708
+ }, this.pushTx = (c) => {
4709
+ this.config.disableValidation || wa(c, this.config.schema);
4710
4710
  try {
4711
- const c = Ku({
4711
+ const d = Ku({
4712
4712
  attrsStore: this.optimisticAttrs(),
4713
4713
  schema: this.config.schema,
4714
4714
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4716,33 +4716,33 @@ class Fa {
4716
4716
  return (l = f == null ? void 0 : f.result) === null || l === void 0 ? void 0 : l.store;
4717
4717
  }),
4718
4718
  useDateObjects: this.config.useDateObjects
4719
- }, d);
4720
- return this.pushOps(c);
4721
- } catch (c) {
4722
- return this.pushOps([], c);
4719
+ }, c);
4720
+ return this.pushOps(d);
4721
+ } catch (d) {
4722
+ return this.pushOps([], d);
4723
4723
  }
4724
- }, this.pushOps = (d, c) => {
4725
- const f = W(), l = [...this._pendingMutations().values()], p = Math.max(0, ...l.map((_) => _.order || 0)) + 1, y = {
4724
+ }, this.pushOps = (c, d) => {
4725
+ const f = z(), l = [...this._pendingMutations().values()], p = Math.max(0, ...l.map((g) => g.order || 0)) + 1, y = {
4726
4726
  op: "transact",
4727
- "tx-steps": d,
4727
+ "tx-steps": c,
4728
4728
  created: Date.now(),
4729
- error: c,
4729
+ error: d,
4730
4730
  order: p
4731
4731
  };
4732
- this._updatePendingMutations((_) => {
4733
- _.set(f, y);
4732
+ this._updatePendingMutations((g) => {
4733
+ g.set(f, y);
4734
4734
  });
4735
4735
  const b = new $r();
4736
4736
  return this.mutationDeferredStore.set(f, b), this._sendMutation(f, y), this.notifyAll(), b.promise;
4737
- }, this._transportOnOpen = (d) => {
4738
- const c = d.target;
4739
- if (this._transport !== c) {
4740
- this._log.info("[socket][open]", c.id, "skip; this is no longer the current transport");
4737
+ }, this._transportOnOpen = (c) => {
4738
+ const d = c.target;
4739
+ if (this._transport !== d) {
4740
+ this._log.info("[socket][open]", d.id, "skip; this is no longer the current transport");
4741
4741
  return;
4742
4742
  }
4743
4743
  this._log.info("[socket][open]", this._transport.id), this._setStatus(he.OPENED), this.getCurrentUser().then((f) => {
4744
4744
  var l;
4745
- this._trySend(W(), {
4745
+ this._trySend(z(), {
4746
4746
  op: "init",
4747
4747
  "app-id": this.config.appId,
4748
4748
  "refresh-token": (l = f.user) === null || l === void 0 ? void 0 : l.refresh_token,
@@ -4755,26 +4755,26 @@ class Fa {
4755
4755
  "__admin-token": this.config.__adminToken
4756
4756
  });
4757
4757
  }).catch((f) => {
4758
- this._log.error("[socket][error]", c.id, f);
4758
+ this._log.error("[socket][error]", d.id, f);
4759
4759
  });
4760
- }, this._transportOnMessage = (d) => {
4761
- const c = d.target, f = d.message;
4762
- if (this._transport !== c) {
4763
- this._log.info("[socket][message]", c.id, f, "skip; this is no longer the current transport");
4760
+ }, this._transportOnMessage = (c) => {
4761
+ const d = c.target, f = c.message;
4762
+ if (this._transport !== d) {
4763
+ this._log.info("[socket][message]", d.id, f, "skip; this is no longer the current transport");
4764
4764
  return;
4765
4765
  }
4766
- if (!this._wsOk && c.type === "ws" && (this._wsOk = !0), this._transportType = "ws", Array.isArray(d.message))
4767
- for (const l of d.message)
4768
- this._handleReceive(c.id, l);
4766
+ if (!this._wsOk && d.type === "ws" && (this._wsOk = !0), this._transportType = "ws", Array.isArray(c.message))
4767
+ for (const l of c.message)
4768
+ this._handleReceive(d.id, l);
4769
4769
  else
4770
- this._handleReceive(c.id, d.message);
4771
- }, this._transportOnError = (d) => {
4772
- const c = d.target;
4773
- if (this._transport !== c) {
4774
- this._log.info("[socket][error]", c.id, "skip; this is no longer the current transport");
4770
+ this._handleReceive(d.id, c.message);
4771
+ }, this._transportOnError = (c) => {
4772
+ const d = c.target;
4773
+ if (this._transport !== d) {
4774
+ this._log.info("[socket][error]", d.id, "skip; this is no longer the current transport");
4775
4775
  return;
4776
4776
  }
4777
- this._log.error("[socket][error]", c.id, d);
4777
+ this._log.error("[socket][error]", d.id, c);
4778
4778
  }, this._scheduleReconnect = () => {
4779
4779
  !this._wsOk && this._transportType !== "sse" && (this._transportType = "sse", this._reconnectTimeoutMs = 0), setTimeout(() => {
4780
4780
  if (this._reconnectTimeoutMs = Math.min(this._reconnectTimeoutMs + 1e3, 1e4), !this._isOnline) {
@@ -4783,29 +4783,29 @@ class Fa {
4783
4783
  }
4784
4784
  this._startSocket();
4785
4785
  }, this._reconnectTimeoutMs);
4786
- }, this._transportOnClose = (d) => {
4787
- const c = d.target;
4788
- if (this._transport !== c) {
4789
- this._log.info("[socket][close]", c.id, "skip; this is no longer the current transport");
4786
+ }, this._transportOnClose = (c) => {
4787
+ const d = c.target;
4788
+ if (this._transport !== d) {
4789
+ this._log.info("[socket][close]", d.id, "skip; this is no longer the current transport");
4790
4790
  return;
4791
4791
  }
4792
4792
  this._setStatus(he.CLOSED);
4793
4793
  for (const f of Object.values(this._rooms))
4794
4794
  f.isConnected = !1;
4795
4795
  if (this._isShutdown) {
4796
- this._log.info("[socket][close]", c.id, "Reactor has been shut down and will not reconnect");
4796
+ this._log.info("[socket][close]", d.id, "Reactor has been shut down and will not reconnect");
4797
4797
  return;
4798
4798
  }
4799
- this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4800
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Pa), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Ca, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Ia, this._log = da(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Ra()) {
4799
+ this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4800
+ }, 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 : Ca, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Ia, this._log = da(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!xa()) {
4801
4801
  if (!e.appId)
4802
4802
  throw new Error("Instant must be initialized with an appId.");
4803
4803
  if (!Ne(e.appId))
4804
4804
  throw new Error(`Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`);
4805
- typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", (d) => N(this, void 0, void 0, function* () {
4806
- var c;
4805
+ typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", (c) => U(this, void 0, void 0, function* () {
4806
+ var d;
4807
4807
  try {
4808
- if (((c = d.data) === null || c === void 0 ? void 0 : c.type) === "auth") {
4808
+ if (((d = c.data) === null || d === void 0 ? void 0 : d.type) === "auth") {
4809
4809
  const f = yield this.getCurrentUser();
4810
4810
  this.updateUser(f.user);
4811
4811
  }
@@ -4814,9 +4814,14 @@ class Fa {
4814
4814
  }
4815
4815
  }))), this._initStorage(n), this._syncTable = new ka(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4816
4816
  useDateObjects: this.config.useDateObjects
4817
- }, this._log, (d) => Et(this.ensureAttrs(), d, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
4818
- this._isOnline = d, this._startSocket(), r.listen((c) => {
4819
- c !== this._isOnline && (this._log.info("[network] online =", c), this._isOnline = c, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", he.CLOSED), this._setStatus(he.CLOSED)));
4817
+ }, this._log, (c) => Ze(this.ensureAttrs(), c, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser().then((c) => {
4818
+ this.syncUserToEndpoint(c.user);
4819
+ }), setInterval(() => U(this, void 0, void 0, function* () {
4820
+ const c = yield this.getCurrentUser();
4821
+ this.syncUserToEndpoint(c.user);
4822
+ }), Pa), r.getIsOnline().then((c) => {
4823
+ this._isOnline = c, this._startSocket(), r.listen((d) => {
4824
+ d !== this._isOnline && (this._log.info("[network] online =", d), this._isOnline = d, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", he.CLOSED), this._setStatus(he.CLOSED)));
4820
4825
  });
4821
4826
  }), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
4822
4827
  }
@@ -4842,9 +4847,9 @@ class Fa {
4842
4847
  _initStorage(e) {
4843
4848
  this.querySubs = new _n({
4844
4849
  persister: new e(this.config.appId, "querySubs"),
4845
- merge: La,
4846
- serialize: $a,
4847
- parse: (n, r) => xa(r, this.config.useDateObjects),
4850
+ merge: Fa,
4851
+ serialize: Da,
4852
+ parse: (n, r) => $a(r, this.config.useDateObjects),
4848
4853
  // objectSize
4849
4854
  objectSize: (n) => {
4850
4855
  var r, i, s, o;
@@ -4863,8 +4868,8 @@ class Fa {
4863
4868
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new _n({
4864
4869
  persister: new e(this.config.appId, "kv"),
4865
4870
  merge: this._onMergeKv,
4866
- serialize: Ua,
4867
- parse: Da,
4871
+ serialize: La,
4872
+ parse: Ua,
4868
4873
  objectSize: () => 0,
4869
4874
  logger: this._log,
4870
4875
  saveThrottleMs: 100,
@@ -4912,13 +4917,37 @@ class Fa {
4912
4917
  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
4918
  if (this._broadcastQueue[e] = [], i && this._trySetPresence(e, i), s)
4914
4919
  for (const o of s) {
4915
- const { topic: u, roomType: a, data: d } = o;
4916
- this._tryBroadcast(e, a, u, d);
4920
+ const { topic: u, roomType: a, data: c } = o;
4921
+ this._tryBroadcast(e, a, u, c);
4917
4922
  }
4918
4923
  }
4924
+ /**
4925
+ * Does the same thing as add-query-ok
4926
+ * but called as a result of receiving query info from ssr
4927
+ * @param {any} q
4928
+ * @param {{ triples: any; pageInfo: any; }} result
4929
+ * @param {boolean} enableCardinalityInference
4930
+ */
4931
+ _addQueryData(e, n, r) {
4932
+ if (!this.attrs)
4933
+ throw new Error("Attrs in reactor have not been set");
4934
+ const i = W(e), s = this.ensureAttrs(), o = Ze(this.attrs, n.triples, r, this.config.useDateObjects);
4935
+ this.querySubs.updateInPlace((u) => {
4936
+ u[i] = {
4937
+ result: {
4938
+ store: o,
4939
+ attrsStore: s,
4940
+ pageInfo: n.pageInfo,
4941
+ processedTxId: void 0,
4942
+ isExternal: !0
4943
+ },
4944
+ q: e
4945
+ };
4946
+ }), this._cleanupPendingMutationsQueries(), this.notifyOne(i), this.notifyOneQueryOnce(i), this._cleanupPendingMutationsTimeout();
4947
+ }
4919
4948
  _handleReceive(e, n) {
4920
4949
  var r, i, s, o, u, a;
4921
- const d = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4950
+ const c = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4922
4951
  switch (Qr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4923
4952
  case "init-ok": {
4924
4953
  this._setStatus(he.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
@@ -4929,14 +4958,14 @@ class Fa {
4929
4958
  break;
4930
4959
  }
4931
4960
  case "add-query-exists": {
4932
- this.notifyOneQueryOnce(B(n.q));
4961
+ this.notifyOneQueryOnce(W(n.q));
4933
4962
  break;
4934
4963
  }
4935
4964
  case "add-query-ok": {
4936
- const { q: l, result: p } = n, y = B(l);
4965
+ const { q: l, result: p } = n, y = W(l);
4937
4966
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
4938
4967
  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"], _ = (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, d, this.config.useDateObjects);
4968
+ 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"], g = (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), _ = this.ensureAttrs(), m = Ze(_, T, c, this.config.useDateObjects);
4940
4969
  this.querySubs.updateInPlace((O) => {
4941
4970
  if (!O[y]) {
4942
4971
  this._log.info("Missing value in querySubs", { hash: y, q: l });
@@ -4944,9 +4973,9 @@ class Fa {
4944
4973
  }
4945
4974
  O[y].result = {
4946
4975
  store: m,
4947
- attrsStore: g,
4976
+ attrsStore: _,
4948
4977
  pageInfo: b,
4949
- aggregate: _,
4978
+ aggregate: g,
4950
4979
  processedTxId: n["processed-tx-id"]
4951
4980
  };
4952
4981
  }), this._cleanupPendingMutationsQueries(), this.notifyOne(y), this.notifyOneQueryOnce(y), this._cleanupPendingMutationsTimeout();
@@ -4972,28 +5001,28 @@ class Fa {
4972
5001
  const { computations: l, attrs: p } = n, y = n["processed-tx-id"];
4973
5002
  p && this._setAttrs(p), this._cleanupPendingMutationsTimeout();
4974
5003
  const b = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), y);
4975
- b !== this._pendingMutations() && this.kv.updateInPlace((g) => {
4976
- g.pendingMutations = b;
5004
+ b !== this._pendingMutations() && this.kv.updateInPlace((_) => {
5005
+ _.pendingMutations = b;
4977
5006
  });
4978
- const _ = Hr(b.entries()), T = l.map((g) => {
5007
+ const g = Hr(b.entries()), T = l.map((_) => {
4979
5008
  var m, O, S, C;
4980
- const $ = g["instaql-query"], D = g["instaql-result"], Ve = B($), ft = Dr(D), lt = this.ensureAttrs(), Ft = Et(lt, ft, d, this.config.useDateObjects), { store: ht, attrsStore: ce } = this._applyOptimisticUpdates(Ft, lt, _, y), le = (O = (m = D == null ? void 0 : D[0]) === null || m === void 0 ? void 0 : m.data) === null || O === void 0 ? void 0 : O["page-info"], Te = (C = (S = D == null ? void 0 : D[0]) === null || S === void 0 ? void 0 : S.data) === null || C === void 0 ? void 0 : C.aggregate;
5009
+ const $ = _["instaql-query"], D = _["instaql-result"], Ve = W($), lt = Dr(D), ht = this.ensureAttrs(), Ft = Ze(ht, lt, c, this.config.useDateObjects), { store: pt, attrsStore: ce } = this._applyOptimisticUpdates(Ft, ht, g, y), le = (O = (m = D == null ? void 0 : D[0]) === null || m === void 0 ? void 0 : m.data) === null || O === void 0 ? void 0 : O["page-info"], Te = (C = (S = D == null ? void 0 : D[0]) === null || S === void 0 ? void 0 : S.data) === null || C === void 0 ? void 0 : C.aggregate;
4981
5010
  return {
4982
5011
  q: $,
4983
5012
  hash: Ve,
4984
- store: ht,
5013
+ store: pt,
4985
5014
  attrsStore: ce,
4986
5015
  pageInfo: le,
4987
5016
  aggregate: Te
4988
5017
  };
4989
5018
  });
4990
- T.forEach(({ hash: g, q: m, store: O, attrsStore: S, pageInfo: C, aggregate: $ }) => {
5019
+ T.forEach(({ hash: _, q: m, store: O, attrsStore: S, pageInfo: C, aggregate: $ }) => {
4991
5020
  this.querySubs.updateInPlace((D) => {
4992
- if (!D[g]) {
4993
- this._log.error("Missing value in querySubs", { hash: g, q: m });
5021
+ if (!D[_]) {
5022
+ this._log.error("Missing value in querySubs", { hash: _, q: m });
4994
5023
  return;
4995
5024
  }
4996
- D[g].result = {
5025
+ D[_].result = {
4997
5026
  store: O,
4998
5027
  attrsStore: S,
4999
5028
  pageInfo: C,
@@ -5001,8 +5030,8 @@ class Fa {
5001
5030
  processedTxId: y
5002
5031
  };
5003
5032
  });
5004
- }), this._cleanupPendingMutationsQueries(), T.forEach(({ hash: g }) => {
5005
- this.notifyOne(g);
5033
+ }), this._cleanupPendingMutationsQueries(), T.forEach(({ hash: _ }) => {
5034
+ this.notifyOne(_);
5006
5035
  });
5007
5036
  break;
5008
5037
  }
@@ -5015,15 +5044,15 @@ class Fa {
5015
5044
  this._updatePendingMutations((T) => {
5016
5045
  T.set(l, Object.assign(Object.assign({}, T.get(l)), { "tx-id": p, confirmed: Date.now() }));
5017
5046
  });
5018
- const _ = [];
5047
+ const g = [];
5019
5048
  for (const T of b["tx-steps"])
5020
5049
  if (T[0] === "add-attr") {
5021
- const g = T[1];
5022
- _.push(g);
5050
+ const _ = T[1];
5051
+ g.push(_);
5023
5052
  }
5024
- if (_.length) {
5053
+ if (g.length) {
5025
5054
  const T = Object.values(this.ensureAttrs().attrs);
5026
- this._setAttrs([...T, ..._]);
5055
+ this._setAttrs([...T, ...g]);
5027
5056
  }
5028
5057
  this._finishTransaction("synced", l), this._cleanupPendingMutationsTimeout();
5029
5058
  break;
@@ -5058,8 +5087,8 @@ class Fa {
5058
5087
  break;
5059
5088
  }
5060
5089
  case "join-room-error":
5061
- const c = n["room-id"], f = this._rooms[c];
5062
- f && (f.error = n.error), this._notifyPresenceSubs(c);
5090
+ const d = n["room-id"], f = this._rooms[d];
5091
+ f && (f.error = n.error), this._notifyPresenceSubs(d);
5063
5092
  break;
5064
5093
  case "error":
5065
5094
  this._handleReceiveError(n);
@@ -5099,18 +5128,18 @@ class Fa {
5099
5128
  _handleReceiveError(e) {
5100
5129
  var n, r, i, s, o, u, a;
5101
5130
  console.log("error", e);
5102
- const d = e["client-event-id"];
5103
- this._inFlightMutationEventIds.delete(d);
5104
- const c = this._pendingMutations().get(d), f = {
5131
+ const c = e["client-event-id"];
5132
+ this._inFlightMutationEventIds.delete(c);
5133
+ const d = this._pendingMutations().get(c), f = {
5105
5134
  message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa."
5106
5135
  };
5107
- if (e.hint && (f.hint = e.hint), c) {
5108
- this._handleMutationError("error", d, e);
5136
+ if (e.hint && (f.hint = e.hint), d) {
5137
+ this._handleMutationError("error", c, e);
5109
5138
  return;
5110
5139
  }
5111
5140
  if (!((n = e["original-event"]) === null || n === void 0) && n.hasOwnProperty("q") && ((r = e["original-event"]) === null || r === void 0 ? void 0 : r.op) === "add-query") {
5112
- const y = (i = e["original-event"]) === null || i === void 0 ? void 0 : i.q, b = B(y);
5113
- this.notifyQueryError(B(y), f), this.notifyQueryOnceError(y, b, d, f);
5141
+ const y = (i = e["original-event"]) === null || i === void 0 ? void 0 : i.q, b = W(y);
5142
+ this.notifyQueryError(W(y), f), this.notifyQueryOnceError(y, b, c, f);
5114
5143
  return;
5115
5144
  }
5116
5145
  if (((s = e["original-event"]) === null || s === void 0 ? void 0 : s.op) === "init") {
@@ -5142,7 +5171,7 @@ class Fa {
5142
5171
  this.attrs = new Ae(e.reduce((n, r) => (n[r.id] = r, n), {}), this._linkIndex), this.notifyAttrsSubs();
5143
5172
  }
5144
5173
  _startQuerySub(e, n) {
5145
- const r = W();
5174
+ const r = z();
5146
5175
  return this.querySubs.updateInPlace((i) => {
5147
5176
  i[n] = i[n] || { q: e, result: null, eventId: r }, i[n].lastAccessed = Date.now();
5148
5177
  }), this._trySendAuthed(r, { op: "add-query", q: e }), r;
@@ -5163,7 +5192,7 @@ class Fa {
5163
5192
  subscribeQuery(e, n, r) {
5164
5193
  var i;
5165
5194
  this.config.disableValidation || Fr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5166
- const s = B(e), o = this.getPreviousResult(e);
5195
+ const s = W(e), o = this.getPreviousResult(e);
5167
5196
  return o && n(o), this.queryCbs[s] = (i = this.queryCbs[s]) !== null && i !== void 0 ? i : [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5168
5197
  this._unsubQuery(e, s, n);
5169
5198
  };
@@ -5176,7 +5205,7 @@ class Fa {
5176
5205
  return i.reject(new Error("We can't run `queryOnce`, because the device is offline.")), i.promise;
5177
5206
  if (!this.querySubs)
5178
5207
  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
- const s = B(e), o = this._startQuerySub(e, s);
5208
+ const s = W(e), o = this._startQuerySub(e, s);
5180
5209
  return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), ja), i.promise;
5181
5210
  }
5182
5211
  _completeQueryOnce(e, n, r) {
@@ -5190,7 +5219,7 @@ class Fa {
5190
5219
  return !!(!((n = this.queryCbs[e]) === null || n === void 0) && n.length || !((r = this.queryOnceDfds[e]) === null || r === void 0) && r.length);
5191
5220
  }
5192
5221
  _cleanupQuery(e, n) {
5193
- this._hasQueryListeners(n) || (delete this.queryCbs[n], delete this.queryOnceDfds[n], delete this._dataForQueryCache[n], this.querySubs.unloadKey(n), this._trySendAuthed(W(), { op: "remove-query", q: e }));
5222
+ this._hasQueryListeners(n) || (delete this.queryCbs[n], delete this.queryOnceDfds[n], delete this._dataForQueryCache[n], this.querySubs.unloadKey(n), this._trySendAuthed(z(), { op: "remove-query", q: e }));
5194
5223
  }
5195
5224
  // When we `pushTx`, it's possible that we don't yet have `this.attrs`
5196
5225
  // This means that `tx-steps` in `pendingMutations` will include `add-attr`
@@ -5214,22 +5243,22 @@ class Fa {
5214
5243
  return n;
5215
5244
  if (!n)
5216
5245
  return /* @__PURE__ */ new Map();
5217
- const i = (c) => {
5218
- const [f, l, p] = c["forward-identity"];
5246
+ const i = (d) => {
5247
+ const [f, l, p] = d["forward-identity"];
5219
5248
  return K(e, l, p);
5220
- }, s = (c) => {
5221
- const [f, l, p] = c["forward-identity"];
5249
+ }, s = (d) => {
5250
+ const [f, l, p] = d["forward-identity"];
5222
5251
  return Ie(e, l, p);
5223
5252
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
5224
5253
  let u = !1;
5225
- const a = (c, f) => {
5254
+ const a = (d, f) => {
5226
5255
  const l = [];
5227
- for (const p of c) {
5256
+ for (const p of d) {
5228
5257
  const [y] = p;
5229
5258
  if (y === "add-attr") {
5230
- const [_, T] = p, g = i(T);
5231
- if (g && T.id !== g.id) {
5232
- o.attrIdMap[T.id] = g.id, u = !0;
5259
+ const [g, T] = p, _ = i(T);
5260
+ if (_ && T.id !== _.id) {
5261
+ o.attrIdMap[T.id] = _.id, u = !0;
5233
5262
  continue;
5234
5263
  }
5235
5264
  if (T["value-type"] === "ref") {
@@ -5247,11 +5276,11 @@ class Fa {
5247
5276
  const b = u ? bu(o, p) : p;
5248
5277
  l.push(b);
5249
5278
  }
5250
- return u ? l : c;
5251
- }, d = /* @__PURE__ */ new Map();
5252
- for (const [c, f] of n.entries())
5253
- d.set(c, Object.assign(Object.assign({}, f), { "tx-steps": a(f["tx-steps"], f["tx-id"]) }));
5254
- return u ? d : n;
5279
+ return u ? l : d;
5280
+ }, c = /* @__PURE__ */ new Map();
5281
+ for (const [d, f] of n.entries())
5282
+ c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": a(f["tx-steps"], f["tx-id"]) }));
5283
+ return u ? c : n;
5255
5284
  }
5256
5285
  _rewriteMutationsSorted(e, n) {
5257
5286
  return Hr(this._rewriteMutations(e, n).entries());
@@ -5268,8 +5297,8 @@ class Fa {
5268
5297
  if (u === "add-attr")
5269
5298
  s.push(a);
5270
5299
  else if (u === "update-attr" && a.id && (!((e = this.attrs) === null || e === void 0) && e.getAttr(a.id))) {
5271
- const d = Object.assign(Object.assign({}, this.attrs.getAttr(a.id)), a);
5272
- s.push(d);
5300
+ const c = Object.assign(Object.assign({}, this.attrs.getAttr(a.id)), a);
5301
+ s.push(c);
5273
5302
  }
5274
5303
  if (!i.size && !s.length)
5275
5304
  return this.attrs || new Ae({}, this._linkIndex);
@@ -5281,20 +5310,25 @@ class Fa {
5281
5310
  return new Ae(o, this._linkIndex);
5282
5311
  }
5283
5312
  /** Runs instaql on a query and a store */
5284
- dataForQuery(e) {
5285
- const n = this._errorMessage;
5286
- if (n)
5287
- return { error: n };
5313
+ dataForQuery(e, n = !0) {
5314
+ const r = this._errorMessage;
5315
+ if (r)
5316
+ return { error: r };
5288
5317
  if (!this.querySubs || !this.kv.currentValue.pendingMutations)
5289
5318
  return;
5290
- const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: u, result: a } = i[e] || {};
5291
- if (!a)
5319
+ const i = this.querySubs.version(), s = this.querySubs.currentValue, o = this.kv.version(), u = this._pendingMutations(), { q: a, result: c } = s[e] || {};
5320
+ if (!c)
5292
5321
  return;
5293
5322
  const d = this._dataForQueryCache[e];
5294
- if (d && r === d.querySubVersion && s === d.pendingMutationsVersion)
5323
+ if (d && i === d.querySubVersion && o === d.pendingMutationsVersion)
5295
5324
  return d;
5296
- const { store: c, attrsStore: f, pageInfo: l, aggregate: p, processedTxId: y } = a, b = this._rewriteMutationsSorted(f, o), { store: _, attrsStore: T } = this._applyOptimisticUpdates(c, f, b, y);
5297
- return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p }, u), querySubVersion: r, pendingMutationsVersion: s };
5325
+ let f = c.store, l = c.attrsStore;
5326
+ const { pageInfo: p, aggregate: y, processedTxId: b } = c, g = this._rewriteMutationsSorted(l, u);
5327
+ if (n) {
5328
+ const _ = this._applyOptimisticUpdates(f, l, g, b);
5329
+ f = _.store, l = _.attrsStore;
5330
+ }
5331
+ return { data: Ri({ store: f, attrsStore: l, pageInfo: p, aggregate: y }, a), querySubVersion: i, pendingMutationsVersion: o };
5298
5332
  }
5299
5333
  _applyOptimisticUpdates(e, n, r, i) {
5300
5334
  for (const [s, o] of r)
@@ -5410,7 +5444,7 @@ class Fa {
5410
5444
  return;
5411
5445
  }
5412
5446
  const e = this._transport;
5413
- this._transport = Ma({
5447
+ this._transport = Ra({
5414
5448
  transportType: this._transportType,
5415
5449
  appId: this.config.appId,
5416
5450
  apiURI: this.config.apiURI,
@@ -5427,14 +5461,14 @@ class Fa {
5427
5461
  *
5428
5462
  */
5429
5463
  getLocalId(e) {
5430
- return N(this, void 0, void 0, function* () {
5464
+ return U(this, void 0, void 0, function* () {
5431
5465
  const n = `localToken_${e}`;
5432
5466
  if (this.kv.currentValue[n])
5433
5467
  return this.kv.currentValue[n];
5434
5468
  const r = yield this.kv.waitForKeyToLoad(n);
5435
5469
  if (r)
5436
5470
  return r;
5437
- const i = W();
5471
+ const i = z();
5438
5472
  return this.kv.updateInPlace((s) => {
5439
5473
  s[n] || (s[n] = i);
5440
5474
  }), yield this.kv.waitForKeyToLoad(n);
@@ -5468,7 +5502,7 @@ class Fa {
5468
5502
  * @returns Promise<null | {error: {message: string}}>
5469
5503
  */
5470
5504
  _oauthLoginInit() {
5471
- return N(this, void 0, void 0, function* () {
5505
+ return U(this, void 0, void 0, function* () {
5472
5506
  var e, n, r, i;
5473
5507
  if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
5474
5508
  return null;
@@ -5483,20 +5517,20 @@ class Fa {
5483
5517
  return null;
5484
5518
  this._replaceUrlAfterOAuth();
5485
5519
  try {
5486
- const a = yield this._getCurrentUser(), d = (a == null ? void 0 : a.type) === "guest", { user: c } = yield Rr({
5520
+ const a = yield this._getCurrentUser(), c = (a == null ? void 0 : a.type) === "guest", { user: d } = yield Rr({
5487
5521
  apiURI: this.config.apiURI,
5488
5522
  appId: this.config.appId,
5489
5523
  code: u,
5490
- refreshToken: d ? a.refresh_token : void 0
5524
+ refreshToken: c ? a.refresh_token : void 0
5491
5525
  });
5492
- return this.setCurrentUser(c), null;
5526
+ return this.setCurrentUser(d), null;
5493
5527
  } catch (a) {
5494
5528
  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
5529
  }
5496
5530
  });
5497
5531
  }
5498
5532
  _waitForOAuthCallbackResponse() {
5499
- return N(this, void 0, void 0, function* () {
5533
+ return U(this, void 0, void 0, function* () {
5500
5534
  return yield this._oauthCallbackResponse;
5501
5535
  });
5502
5536
  }
@@ -5511,13 +5545,13 @@ class Fa {
5511
5545
  n.isLoading || e(this._currentUserCached);
5512
5546
  let r = !1;
5513
5547
  return this.getCurrentUser().then((i) => {
5514
- r || Ot(i, n) || e(i);
5548
+ r || Et(i, n) || e(i);
5515
5549
  }), () => {
5516
5550
  r = !0, this.authCbs = this.authCbs.filter((i) => i !== e);
5517
5551
  };
5518
5552
  }
5519
5553
  getAuth() {
5520
- return N(this, void 0, void 0, function* () {
5554
+ return U(this, void 0, void 0, function* () {
5521
5555
  const { user: e, error: n } = yield this.getCurrentUser();
5522
5556
  if (n)
5523
5557
  throw new qe("Could not get current user: " + n.message);
@@ -5550,7 +5584,7 @@ class Fa {
5550
5584
  this.connectionStatusCbs.forEach((n) => n(e));
5551
5585
  }
5552
5586
  setCurrentUser(e) {
5553
- return N(this, void 0, void 0, function* () {
5587
+ return U(this, void 0, void 0, function* () {
5554
5588
  this.kv.updateInPlace((n) => {
5555
5589
  n[Ge] = e;
5556
5590
  }), yield this.kv.waitForKeyToLoad(Ge);
@@ -5560,13 +5594,13 @@ class Fa {
5560
5594
  return this._currentUserCached;
5561
5595
  }
5562
5596
  _getCurrentUser() {
5563
- return N(this, void 0, void 0, function* () {
5597
+ return U(this, void 0, void 0, function* () {
5564
5598
  const e = yield this.kv.waitForKeyToLoad(Ge);
5565
5599
  return typeof e == "string" ? JSON.parse(e) : e;
5566
5600
  });
5567
5601
  }
5568
5602
  getCurrentUser() {
5569
- return N(this, void 0, void 0, function* () {
5603
+ return U(this, void 0, void 0, function* () {
5570
5604
  const e = yield this._waitForOAuthCallbackResponse();
5571
5605
  if (e != null && e.error) {
5572
5606
  const n = { error: e.error, user: void 0 };
@@ -5585,16 +5619,16 @@ class Fa {
5585
5619
  });
5586
5620
  }
5587
5621
  _hasCurrentUser() {
5588
- return N(this, void 0, void 0, function* () {
5622
+ return U(this, void 0, void 0, function* () {
5589
5623
  const e = yield this.kv.waitForKeyToLoad(Ge);
5590
5624
  return typeof e == "string" ? JSON.parse(e) != null : e != null;
5591
5625
  });
5592
5626
  }
5593
5627
  changeCurrentUser(e) {
5594
- return N(this, void 0, void 0, function* () {
5628
+ return U(this, void 0, void 0, function* () {
5595
5629
  var n;
5596
5630
  const { user: r } = yield this.getCurrentUser();
5597
- if (!Ot(r, e)) {
5631
+ if (!Et(r, e)) {
5598
5632
  yield this.setCurrentUser(e), this.updateUser(e);
5599
5633
  try {
5600
5634
  (n = this._broadcastChannel) === null || n === void 0 || n.postMessage({ type: "auth" });
@@ -5604,7 +5638,28 @@ class Fa {
5604
5638
  }
5605
5639
  });
5606
5640
  }
5641
+ syncUserToEndpoint(e) {
5642
+ return U(this, void 0, void 0, function* () {
5643
+ if (this.config.firstPartyPath)
5644
+ try {
5645
+ fetch(this.config.firstPartyPath + "/", {
5646
+ method: "POST",
5647
+ body: JSON.stringify({
5648
+ type: "sync-user",
5649
+ appId: this.config.appId,
5650
+ user: e
5651
+ }),
5652
+ headers: {
5653
+ "Content-Type": "application/json"
5654
+ }
5655
+ });
5656
+ } catch (n) {
5657
+ this._log.error("Error syncing user with external endpoint", n);
5658
+ }
5659
+ });
5660
+ }
5607
5661
  updateUser(e) {
5662
+ this.syncUserToEndpoint(e);
5608
5663
  const n = { error: void 0, user: e };
5609
5664
  this._currentUserCached = Object.assign({ isLoading: !1 }, n), this._dataForQueryCache = {}, this.querySubs.updateInPlace((r) => {
5610
5665
  Object.keys(r).forEach((i) => {
@@ -5620,7 +5675,7 @@ class Fa {
5620
5675
  });
5621
5676
  }
5622
5677
  signInWithMagicCode(e) {
5623
- return N(this, arguments, void 0, function* ({ email: n, code: r }) {
5678
+ return U(this, arguments, void 0, function* ({ email: n, code: r }) {
5624
5679
  var i;
5625
5680
  const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Zu({
5626
5681
  apiURI: this.config.apiURI,
@@ -5633,7 +5688,7 @@ class Fa {
5633
5688
  });
5634
5689
  }
5635
5690
  signInWithCustomToken(e) {
5636
- return N(this, void 0, void 0, function* () {
5691
+ return U(this, void 0, void 0, function* () {
5637
5692
  const n = yield Xu({
5638
5693
  apiURI: this.config.apiURI,
5639
5694
  appId: this.config.appId,
@@ -5643,7 +5698,7 @@ class Fa {
5643
5698
  });
5644
5699
  }
5645
5700
  signInAsGuest() {
5646
- return N(this, void 0, void 0, function* () {
5701
+ return U(this, void 0, void 0, function* () {
5647
5702
  const e = yield ea({
5648
5703
  apiURI: this.config.apiURI,
5649
5704
  appId: this.config.appId
@@ -5670,7 +5725,7 @@ class Fa {
5670
5725
  });
5671
5726
  }
5672
5727
  signOut(e) {
5673
- return N(this, void 0, void 0, function* () {
5728
+ return U(this, void 0, void 0, function* () {
5674
5729
  const n = yield this.getCurrentUser();
5675
5730
  this.potentiallyInvalidateToken(n, e), yield this.changeCurrentUser(null);
5676
5731
  });
@@ -5693,7 +5748,7 @@ class Fa {
5693
5748
  * @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
5694
5749
  */
5695
5750
  exchangeCodeForToken(e) {
5696
- return N(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
5751
+ return U(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
5697
5752
  var i;
5698
5753
  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
5754
  apiURI: this.config.apiURI,
@@ -5716,7 +5771,7 @@ class Fa {
5716
5771
  * @param {string | null | undefined} [params.nonce] - The nonce used when requesting the id_token from the external service
5717
5772
  */
5718
5773
  signInWithIdToken(e) {
5719
- return N(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5774
+ return U(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5720
5775
  var s;
5721
5776
  const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield ta({
5722
5777
  apiURI: this.config.apiURI,
@@ -5771,17 +5826,17 @@ class Fa {
5771
5826
  s.result.user = o, i.isConnected && (this._trySetPresence(n, o), this._notifyPresenceSubs(n));
5772
5827
  }
5773
5828
  _trySetPresence(e, n) {
5774
- this._trySendAuthed(W(), {
5829
+ this._trySendAuthed(z(), {
5775
5830
  op: "set-presence",
5776
5831
  "room-id": e,
5777
5832
  data: n
5778
5833
  });
5779
5834
  }
5780
5835
  _tryJoinRoom(e, n) {
5781
- this._trySendAuthed(W(), { op: "join-room", "room-id": e, data: n }), delete this._roomsPendingLeave[e];
5836
+ this._trySendAuthed(z(), { op: "join-room", "room-id": e, data: n }), delete this._roomsPendingLeave[e];
5782
5837
  }
5783
5838
  _tryLeaveRoom(e) {
5784
- this._trySendAuthed(W(), { op: "leave-room", "room-id": e });
5839
+ this._trySendAuthed(z(), { op: "leave-room", "room-id": e });
5785
5840
  }
5786
5841
  _trySetRoomConnected(e, n) {
5787
5842
  const r = this._rooms[e];
@@ -5797,8 +5852,8 @@ class Fa {
5797
5852
  r.initialPresence || r.initialData
5798
5853
  ), o = Object.assign(Object.assign({}, r), { roomId: n, cb: i, prev: null });
5799
5854
  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 u, a, d;
5801
- this._presence[n].handlers = (d = (a = (u = this._presence[n]) === null || u === void 0 ? void 0 : u.handlers) === null || a === void 0 ? void 0 : a.filter((c) => c !== o)) !== null && d !== void 0 ? d : [], s();
5855
+ var u, a, c;
5856
+ 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
5857
  };
5803
5858
  }
5804
5859
  _notifyPresenceSubs(e) {
@@ -5814,22 +5869,22 @@ class Fa {
5814
5869
  _patchPresencePeers(e, n) {
5815
5870
  var r, i, s;
5816
5871
  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 u = Object.fromEntries(Object.entries(o).map(([d, c]) => [d, { data: c }]));
5872
+ let u = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
5818
5873
  (s = this._presence[e]) === null || s === void 0 || s.result;
5819
- const a = It(u, (d) => {
5820
- for (let [c, f, l] of n)
5874
+ const a = It(u, (c) => {
5875
+ for (let [d, f, l] of n)
5821
5876
  switch (f) {
5822
5877
  case "+":
5823
- Ls(d, c, l);
5878
+ Ls(c, d, l);
5824
5879
  break;
5825
5880
  case "r":
5826
- Tr(d, c, l);
5881
+ Tr(c, d, l);
5827
5882
  break;
5828
5883
  case "-":
5829
- _i(d, c);
5884
+ _i(c, d);
5830
5885
  break;
5831
5886
  }
5832
- delete d[this._sessionId];
5887
+ delete c[this._sessionId];
5833
5888
  });
5834
5889
  this._setPresencePeers(e, a);
5835
5890
  }
@@ -5855,7 +5910,7 @@ class Fa {
5855
5910
  }
5856
5911
  }
5857
5912
  _tryBroadcast(e, n, r, i) {
5858
- this._trySendAuthed(W(), {
5913
+ this._trySendAuthed(z(), {
5859
5914
  op: "client-broadcast",
5860
5915
  "room-id": e,
5861
5916
  roomType: n,
@@ -5872,22 +5927,22 @@ class Fa {
5872
5927
  _notifyBroadcastSubs(e, n, r) {
5873
5928
  var i, s, o;
5874
5929
  (o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((u) => {
5875
- var a, d, c, f, l, p;
5876
- const y = (a = r.data) === null || a === void 0 ? void 0 : a.data, b = r.data["peer-id"] === this._sessionId ? (c = (d = this._presence[e]) === null || d === void 0 ? void 0 : d.result) === null || c === void 0 ? void 0 : c.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"]];
5930
+ var a, c, d, f, l, p;
5931
+ const y = (a = r.data) === null || a === void 0 ? void 0 : a.data, b = r.data["peer-id"] === this._sessionId ? (d = (c = this._presence[e]) === null || c === void 0 ? void 0 : c.result) === null || d === void 0 ? void 0 : d.user : (p = (l = (f = this._presence[e]) === null || f === void 0 ? void 0 : f.result) === null || l === void 0 ? void 0 : l.peers) === null || p === void 0 ? void 0 : p[r.data["peer-id"]];
5877
5932
  return u(y, b);
5878
5933
  });
5879
5934
  }
5880
5935
  // --------
5881
5936
  // Storage
5882
5937
  uploadFile(e, n, r) {
5883
- return N(this, void 0, void 0, function* () {
5938
+ return U(this, void 0, void 0, function* () {
5884
5939
  var i;
5885
5940
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5886
5941
  return ra(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5887
5942
  });
5888
5943
  }
5889
5944
  deleteFile(e) {
5890
- return N(this, void 0, void 0, function* () {
5945
+ return U(this, void 0, void 0, function* () {
5891
5946
  var n;
5892
5947
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5893
5948
  return yield ia({
@@ -5901,7 +5956,7 @@ class Fa {
5901
5956
  // Deprecated Storage API (Jan 2025)
5902
5957
  // ---------------------------------
5903
5958
  upload(e, n) {
5904
- return N(this, void 0, void 0, function* () {
5959
+ return U(this, void 0, void 0, function* () {
5905
5960
  var r;
5906
5961
  const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield sa({
5907
5962
  apiURI: this.config.apiURI,
@@ -5913,7 +5968,7 @@ class Fa {
5913
5968
  });
5914
5969
  }
5915
5970
  getDownloadUrl(e) {
5916
- return N(this, void 0, void 0, function* () {
5971
+ return U(this, void 0, void 0, function* () {
5917
5972
  var n;
5918
5973
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5919
5974
  return yield ua({
@@ -5925,7 +5980,7 @@ class Fa {
5925
5980
  });
5926
5981
  }
5927
5982
  }
5928
- function Na(t, e) {
5983
+ function Ka(t, e) {
5929
5984
  return new Lt(
5930
5985
  Hi(t, e),
5931
5986
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -5937,25 +5992,25 @@ function Na(t, e) {
5937
5992
  void 0
5938
5993
  );
5939
5994
  }
5940
- function Ka(t) {
5995
+ function qa(t) {
5941
5996
  return new Ut(t, {});
5942
5997
  }
5943
- function qa() {
5998
+ function Wa() {
5944
5999
  return new H("string", !0, !1);
5945
6000
  }
5946
- function Wa() {
6001
+ function za() {
5947
6002
  return new H("number", !0, !1);
5948
6003
  }
5949
- function za() {
6004
+ function Va() {
5950
6005
  return new H("boolean", !0, !1);
5951
6006
  }
5952
- function Va() {
6007
+ function Ba() {
5953
6008
  return new H("date", !0, !1);
5954
6009
  }
5955
- function Ba() {
6010
+ function Ga() {
5956
6011
  return new H("json", !0, !1);
5957
6012
  }
5958
- function Ga() {
6013
+ function Qa() {
5959
6014
  return new H("json", !0, !1);
5960
6015
  }
5961
6016
  function Hi(t, e) {
@@ -5969,12 +6024,12 @@ function Hi(t, e) {
5969
6024
  entityName: a.forward.on,
5970
6025
  cardinality: a.reverse.has
5971
6026
  };
5972
- return Object.fromEntries(Object.entries(t).map(([a, d]) => [
6027
+ return Object.fromEntries(Object.entries(t).map(([a, c]) => [
5973
6028
  a,
5974
- new Ut(d.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
6029
+ new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
5975
6030
  ]));
5976
6031
  }
5977
- function Qa({ entities: t, links: e, rooms: n }) {
6032
+ function Ha({ entities: t, links: e, rooms: n }) {
5978
6033
  const r = e ?? {}, i = n ?? {};
5979
6034
  return new Lt(
5980
6035
  Hi(t, r),
@@ -5987,29 +6042,29 @@ function Qa({ entities: t, links: e, rooms: n }) {
5987
6042
  i
5988
6043
  );
5989
6044
  }
5990
- const Fc = {
6045
+ const Nc = {
5991
6046
  // constructs
5992
- graph: Na,
5993
- schema: Qa,
5994
- entity: Ka,
6047
+ graph: Ka,
6048
+ schema: Ha,
6049
+ entity: qa,
5995
6050
  // value types
5996
- string: qa,
5997
- number: Wa,
5998
- boolean: za,
5999
- date: Va,
6000
- json: Ba,
6001
- any: Ga
6051
+ string: Wa,
6052
+ number: za,
6053
+ boolean: Va,
6054
+ date: Ba,
6055
+ json: Ga,
6056
+ any: Qa
6002
6057
  };
6003
- let mt;
6004
- function Ha(t, e) {
6005
- mt == null || mt.dispose();
6006
- const n = tc(e), r = Za(e, u), i = Ja(Ya(t));
6007
- function s(c) {
6058
+ let vt;
6059
+ function Ya(t, e) {
6060
+ vt == null || vt.dispose();
6061
+ const n = nc(e), r = Xa(e, u), i = Za(Ja(t));
6062
+ function s(d) {
6008
6063
  var f;
6009
- c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
6064
+ d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
6010
6065
  }
6011
- function o(c) {
6012
- const f = c.shiftKey && c.ctrlKey && c.key === "0", l = c.key === "Escape" || c.key === "Esc";
6066
+ function o(d) {
6067
+ const f = d.shiftKey && d.ctrlKey && d.key === "0", l = d.key === "Escape" || d.key === "Esc";
6013
6068
  (f || l && n.isVisible()) && u();
6014
6069
  }
6015
6070
  function u() {
@@ -6018,17 +6073,17 @@ function Ha(t, e) {
6018
6073
  function a() {
6019
6074
  n.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", s);
6020
6075
  }
6021
- function d() {
6022
- document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), mt = {
6076
+ function c() {
6077
+ document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), vt = {
6023
6078
  dispose: a
6024
6079
  };
6025
6080
  }
6026
- return d();
6081
+ return c();
6027
6082
  }
6028
- function Ya(t) {
6083
+ function Ja(t) {
6029
6084
  return `${qn || Ni ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6030
6085
  }
6031
- function Ja(t) {
6086
+ function Za(t) {
6032
6087
  const e = document.createElement("iframe");
6033
6088
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6034
6089
  width: "100%",
@@ -6037,7 +6092,7 @@ function Ja(t) {
6037
6092
  border: "none"
6038
6093
  }), { element: e };
6039
6094
  }
6040
- function Za(t, e) {
6095
+ function Xa(t, e) {
6041
6096
  const n = `
6042
6097
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6043
6098
  <rect width="512" height="512" fill="black"/>
@@ -6047,7 +6102,7 @@ function Za(t, e) {
6047
6102
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6048
6103
  // pos
6049
6104
  position: "fixed"
6050
- }, Xa(t.position)), {
6105
+ }, ec(t.position)), {
6051
6106
  height: "32px",
6052
6107
  width: "32px",
6053
6108
  // layout
@@ -6062,7 +6117,7 @@ function Za(t, e) {
6062
6117
  cursor: "pointer"
6063
6118
  })), r.addEventListener("click", e), { element: r };
6064
6119
  }
6065
- function Xa(t) {
6120
+ function ec(t) {
6066
6121
  switch (t) {
6067
6122
  case "bottom-left":
6068
6123
  return { bottom: "24px", left: "24px" };
@@ -6074,7 +6129,7 @@ function Xa(t) {
6074
6129
  return { top: "24px", left: "24px" };
6075
6130
  }
6076
6131
  }
6077
- function ec(t) {
6132
+ function tc(t) {
6078
6133
  switch (t) {
6079
6134
  case "bottom-left":
6080
6135
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6086,23 +6141,23 @@ function ec(t) {
6086
6141
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6087
6142
  }
6088
6143
  }
6089
- function tc(t) {
6144
+ function nc(t) {
6090
6145
  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";
6146
+ 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
6147
  function n() {
6093
6148
  return e.style.display !== "none";
6094
6149
  }
6095
6150
  return { element: e, isVisible: n };
6096
6151
  }
6097
- const nc = {
6152
+ const rc = {
6098
6153
  apiURI: "https://api.instantdb.com",
6099
6154
  websocketURI: "wss://api.instantdb.com/runtime/session"
6100
6155
  };
6101
- function rc() {
6156
+ function ic() {
6102
6157
  var t;
6103
6158
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6104
6159
  }
6105
- function ic() {
6160
+ function sc() {
6106
6161
  var t;
6107
6162
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
6108
6163
  }
@@ -6110,23 +6165,23 @@ function gn(t) {
6110
6165
  const e = t.__adminToken;
6111
6166
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6112
6167
  }
6113
- const wn = ic(), Yr = rc();
6114
- class sc {
6168
+ const wn = sc(), Yr = ic();
6169
+ class oc {
6115
6170
  constructor(e) {
6116
6171
  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
6172
  }
6118
6173
  }
6119
- class oc {
6174
+ class uc {
6120
6175
  constructor(e) {
6121
6176
  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
6177
  }
6123
6178
  }
6124
- function uc(t) {
6179
+ function ac(t) {
6125
6180
  return JSON.parse(JSON.stringify(t));
6126
6181
  }
6127
- class ac {
6182
+ class cc {
6128
6183
  constructor(e) {
6129
- this.tx = Kn(), this._reactor = e, this.auth = new sc(this._reactor), this.storage = new oc(this._reactor);
6184
+ this.tx = Kn(), this._reactor = e, this.auth = new oc(this._reactor), this.storage = new uc(this._reactor);
6130
6185
  }
6131
6186
  /**
6132
6187
  * Use this to write data! You can create, update, delete, and link objects
@@ -6306,25 +6361,25 @@ function Jr(t) {
6306
6361
  const e = Yr.get(t);
6307
6362
  if (e)
6308
6363
  return e;
6309
- const n = B(t);
6364
+ const n = W(t);
6310
6365
  return Yr.set(t, n), n;
6311
6366
  }
6312
- function cc(t, e) {
6367
+ function dc(t, e) {
6313
6368
  return Jr(t._reactor.config.schema) !== Jr(e);
6314
6369
  }
6315
- function dc(t, e, n, r, i) {
6370
+ function fc(t, e, n, r, i) {
6316
6371
  var s, o;
6317
6372
  const u = Object.assign(Object.assign({}, t), { appId: (s = t.appId) === null || s === void 0 ? void 0 : s.trim(), useDateObjects: (o = t.useDateObjects) !== null && o !== void 0 ? o : !1 }), a = wn[gn(u)];
6318
6373
  if (a)
6319
- return cc(a, u.schema) && a._reactor.updateSchema(u.schema), a;
6320
- const d = new Fa(Object.assign(Object.assign(Object.assign({}, nc), u), { cardinalityInference: !!u.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new ac(d);
6321
- return wn[gn(u)] = c, fc(u.appId, u.devtool), c;
6374
+ return dc(a, u.schema) && a._reactor.updateSchema(u.schema), a;
6375
+ const c = new Na(Object.assign(Object.assign(Object.assign({}, rc), u), { cardinalityInference: !!u.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), d = new cc(c);
6376
+ return wn[gn(u)] = d, lc(u.appId, u.devtool), d;
6322
6377
  }
6323
- function fc(t, e) {
6378
+ function lc(t, e) {
6324
6379
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6325
6380
  return;
6326
6381
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6327
- n.allowedHosts.includes(window.location.hostname) && Ha(t, n);
6382
+ n.allowedHosts.includes(window.location.hostname) && Ya(t, n);
6328
6383
  }
6329
6384
  var Tn = { exports: {} }, Qe = {};
6330
6385
  /**
@@ -6337,21 +6392,21 @@ var Tn = { exports: {} }, Qe = {};
6337
6392
  * LICENSE file in the root directory of this source tree.
6338
6393
  */
6339
6394
  var Zr;
6340
- function lc() {
6395
+ function hc() {
6341
6396
  if (Zr) return Qe;
6342
6397
  Zr = 1;
6343
6398
  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(u, a, d) {
6345
- var c, f = {}, l = null, p = null;
6346
- d !== void 0 && (l = "" + d), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
6347
- for (c in a) r.call(a, c) && !s.hasOwnProperty(c) && (f[c] = a[c]);
6348
- if (u && u.defaultProps) for (c in a = u.defaultProps, a) f[c] === void 0 && (f[c] = a[c]);
6399
+ function o(u, a, c) {
6400
+ var d, f = {}, l = null, p = null;
6401
+ c !== void 0 && (l = "" + c), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
6402
+ for (d in a) r.call(a, d) && !s.hasOwnProperty(d) && (f[d] = a[d]);
6403
+ if (u && u.defaultProps) for (d in a = u.defaultProps, a) f[d] === void 0 && (f[d] = a[d]);
6349
6404
  return { $$typeof: e, type: u, key: l, ref: p, props: f, _owner: i.current };
6350
6405
  }
6351
6406
  return Qe.Fragment = n, Qe.jsx = o, Qe.jsxs = o, Qe;
6352
6407
  }
6353
6408
  var He = {}, Xr;
6354
- function hc() {
6409
+ function pc() {
6355
6410
  if (Xr) return He;
6356
6411
  Xr = 1;
6357
6412
  var t = {};
@@ -6365,14 +6420,14 @@ function hc() {
6365
6420
  * LICENSE file in the root directory of this source tree.
6366
6421
  */
6367
6422
  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"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = 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";
6423
+ 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, g = "@@iterator";
6369
6424
  function T(h) {
6370
6425
  if (h === null || typeof h != "object")
6371
6426
  return null;
6372
- var w = b && h[b] || h[_];
6427
+ var w = b && h[b] || h[g];
6373
6428
  return typeof w == "function" ? w : null;
6374
6429
  }
6375
- var g = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
6430
+ var _ = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
6376
6431
  function m(h) {
6377
6432
  {
6378
6433
  for (var w = arguments.length, v = new Array(w > 1 ? w - 1 : 0), E = 1; E < w; E++)
@@ -6382,7 +6437,7 @@ function hc() {
6382
6437
  }
6383
6438
  function O(h, w, v) {
6384
6439
  {
6385
- var E = g.ReactDebugCurrentFrame, P = E.getStackAddendum();
6440
+ var E = _.ReactDebugCurrentFrame, P = E.getStackAddendum();
6386
6441
  P !== "" && (w += "%s", v = v.concat([P]));
6387
6442
  var M = v.map(function(I) {
6388
6443
  return String(I);
@@ -6390,14 +6445,14 @@ function hc() {
6390
6445
  M.unshift("Warning: " + w), Function.prototype.apply.call(console[h], console, M);
6391
6446
  }
6392
6447
  }
6393
- var S = !1, C = !1, $ = !1, D = !1, Ve = !1, ft;
6394
- ft = Symbol.for("react.module.reference");
6395
- function lt(h) {
6396
- return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h === c || 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 === d || // This needs to include all possible module reference object
6448
+ var S = !1, C = !1, $ = !1, D = !1, Ve = !1, lt;
6449
+ lt = Symbol.for("react.module.reference");
6450
+ function ht(h) {
6451
+ 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
6452
  // types supported by any Flight configuration anywhere since
6398
6453
  // we don't know which Flight build this will end up being used
6399
6454
  // with.
6400
- h.$$typeof === ft || h.getModuleId !== void 0));
6455
+ h.$$typeof === lt || h.getModuleId !== void 0));
6401
6456
  }
6402
6457
  function Ft(h, w, v) {
6403
6458
  var E = h.displayName;
@@ -6406,7 +6461,7 @@ function hc() {
6406
6461
  var P = w.displayName || w.name || "";
6407
6462
  return P !== "" ? v + "(" + P + ")" : v;
6408
6463
  }
6409
- function ht(h) {
6464
+ function pt(h) {
6410
6465
  return h.displayName || "Context";
6411
6466
  }
6412
6467
  function ce(h) {
@@ -6425,7 +6480,7 @@ function hc() {
6425
6480
  return "Profiler";
6426
6481
  case s:
6427
6482
  return "StrictMode";
6428
- case c:
6483
+ case d:
6429
6484
  return "Suspense";
6430
6485
  case f:
6431
6486
  return "SuspenseList";
@@ -6434,11 +6489,11 @@ function hc() {
6434
6489
  switch (h.$$typeof) {
6435
6490
  case a:
6436
6491
  var w = h;
6437
- return ht(w) + ".Consumer";
6492
+ return pt(w) + ".Consumer";
6438
6493
  case u:
6439
6494
  var v = h;
6440
- return ht(v._context) + ".Provider";
6441
- case d:
6495
+ return pt(v._context) + ".Provider";
6496
+ case c:
6442
6497
  return Ft(h, h.render, "ForwardRef");
6443
6498
  case l:
6444
6499
  var E = h.displayName || null;
@@ -6516,8 +6571,8 @@ function hc() {
6516
6571
  Te < 0 && m("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
6517
6572
  }
6518
6573
  }
6519
- var Nt = g.ReactCurrentDispatcher, Kt;
6520
- function pt(h, w, v) {
6574
+ var Nt = _.ReactCurrentDispatcher, Kt;
6575
+ function yt(h, w, v) {
6521
6576
  {
6522
6577
  if (Kt === void 0)
6523
6578
  try {
@@ -6530,16 +6585,16 @@ function hc() {
6530
6585
  ` + Kt + h;
6531
6586
  }
6532
6587
  }
6533
- var qt = !1, yt;
6588
+ var qt = !1, bt;
6534
6589
  {
6535
6590
  var Xi = typeof WeakMap == "function" ? WeakMap : Map;
6536
- yt = new Xi();
6591
+ bt = new Xi();
6537
6592
  }
6538
6593
  function er(h, w) {
6539
6594
  if (!h || qt)
6540
6595
  return "";
6541
6596
  {
6542
- var v = yt.get(h);
6597
+ var v = bt.get(h);
6543
6598
  if (v !== void 0)
6544
6599
  return v;
6545
6600
  }
@@ -6585,26 +6640,26 @@ function hc() {
6585
6640
  if (Y && E && typeof Y.stack == "string") {
6586
6641
  for (var k = Y.stack.split(`
6587
6642
  `), G = E.stack.split(`
6588
- `), U = k.length - 1, F = G.length - 1; U >= 1 && F >= 0 && k[U] !== G[F]; )
6589
- F--;
6590
- for (; U >= 1 && F >= 0; U--, F--)
6591
- if (k[U] !== G[F]) {
6592
- if (U !== 1 || F !== 1)
6643
+ `), L = k.length - 1, N = G.length - 1; L >= 1 && N >= 0 && k[L] !== G[N]; )
6644
+ N--;
6645
+ for (; L >= 1 && N >= 0; L--, N--)
6646
+ if (k[L] !== G[N]) {
6647
+ if (L !== 1 || N !== 1)
6593
6648
  do
6594
- if (U--, F--, F < 0 || k[U] !== G[F]) {
6649
+ if (L--, N--, N < 0 || k[L] !== G[N]) {
6595
6650
  var re = `
6596
- ` + k[U].replace(" at new ", " at ");
6597
- return h.displayName && re.includes("<anonymous>") && (re = re.replace("<anonymous>", h.displayName)), typeof h == "function" && yt.set(h, re), re;
6651
+ ` + k[L].replace(" at new ", " at ");
6652
+ return h.displayName && re.includes("<anonymous>") && (re = re.replace("<anonymous>", h.displayName)), typeof h == "function" && bt.set(h, re), re;
6598
6653
  }
6599
- while (U >= 1 && F >= 0);
6654
+ while (L >= 1 && N >= 0);
6600
6655
  break;
6601
6656
  }
6602
6657
  }
6603
6658
  } finally {
6604
6659
  qt = !1, Nt.current = M, Zi(), Error.prepareStackTrace = P;
6605
6660
  }
6606
- var Me = h ? h.displayName || h.name : "", me = Me ? pt(Me) : "";
6607
- return typeof h == "function" && yt.set(h, me), me;
6661
+ var Me = h ? h.displayName || h.name : "", me = Me ? yt(Me) : "";
6662
+ return typeof h == "function" && bt.set(h, me), me;
6608
6663
  }
6609
6664
  function es(h, w, v) {
6610
6665
  return er(h, !1);
@@ -6613,39 +6668,39 @@ function hc() {
6613
6668
  var w = h.prototype;
6614
6669
  return !!(w && w.isReactComponent);
6615
6670
  }
6616
- function bt(h, w, v) {
6671
+ function _t(h, w, v) {
6617
6672
  if (h == null)
6618
6673
  return "";
6619
6674
  if (typeof h == "function")
6620
6675
  return er(h, ts(h));
6621
6676
  if (typeof h == "string")
6622
- return pt(h);
6677
+ return yt(h);
6623
6678
  switch (h) {
6624
- case c:
6625
- return pt("Suspense");
6679
+ case d:
6680
+ return yt("Suspense");
6626
6681
  case f:
6627
- return pt("SuspenseList");
6682
+ return yt("SuspenseList");
6628
6683
  }
6629
6684
  if (typeof h == "object")
6630
6685
  switch (h.$$typeof) {
6631
- case d:
6686
+ case c:
6632
6687
  return es(h.render);
6633
6688
  case l:
6634
- return bt(h.type, w, v);
6689
+ return _t(h.type, w, v);
6635
6690
  case p: {
6636
6691
  var E = h, P = E._payload, M = E._init;
6637
6692
  try {
6638
- return bt(M(P), w, v);
6693
+ return _t(M(P), w, v);
6639
6694
  } catch {
6640
6695
  }
6641
6696
  }
6642
6697
  }
6643
6698
  return "";
6644
6699
  }
6645
- var Be = Object.prototype.hasOwnProperty, tr = {}, nr = g.ReactDebugCurrentFrame;
6646
- function _t(h) {
6700
+ var Be = Object.prototype.hasOwnProperty, tr = {}, nr = _.ReactDebugCurrentFrame;
6701
+ function gt(h) {
6647
6702
  if (h) {
6648
- var w = h._owner, v = bt(h.type, h._source, w ? w.type : null);
6703
+ var w = h._owner, v = _t(h.type, h._source, w ? w.type : null);
6649
6704
  nr.setExtraStackFrame(v);
6650
6705
  } else
6651
6706
  nr.setExtraStackFrame(null);
@@ -6662,10 +6717,10 @@ function hc() {
6662
6717
  throw G.name = "Invariant Violation", G;
6663
6718
  }
6664
6719
  k = h[I](w, I, E, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
6665
- } catch (U) {
6666
- k = U;
6720
+ } catch (L) {
6721
+ k = L;
6667
6722
  }
6668
- k && !(k instanceof Error) && (_t(P), m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", E || "React class", v, I, typeof k), _t(null)), k instanceof Error && !(k.message in tr) && (tr[k.message] = !0, _t(P), m("Failed %s type: %s", v, k.message), _t(null));
6723
+ k && !(k instanceof Error) && (gt(P), m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", E || "React class", v, I, typeof k), gt(null)), k instanceof Error && !(k.message in tr) && (tr[k.message] = !0, gt(P), m("Failed %s type: %s", v, k.message), gt(null));
6669
6724
  }
6670
6725
  }
6671
6726
  }
@@ -6693,7 +6748,7 @@ function hc() {
6693
6748
  if (ss(h))
6694
6749
  return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", is(h)), rr(h);
6695
6750
  }
6696
- var sr = g.ReactCurrentOwner, os = {
6751
+ var sr = _.ReactCurrentOwner, os = {
6697
6752
  key: !0,
6698
6753
  ref: !0,
6699
6754
  __self: !0,
@@ -6776,21 +6831,21 @@ function hc() {
6776
6831
  for (M in w)
6777
6832
  Be.call(w, M) && !os.hasOwnProperty(M) && (I[M] = w[M]);
6778
6833
  if (h && h.defaultProps) {
6779
- var U = h.defaultProps;
6780
- for (M in U)
6781
- I[M] === void 0 && (I[M] = U[M]);
6834
+ var L = h.defaultProps;
6835
+ for (M in L)
6836
+ I[M] === void 0 && (I[M] = L[M]);
6782
6837
  }
6783
6838
  if (k || G) {
6784
- var F = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
6785
- k && ds(I, F), G && fs(I, F);
6839
+ var N = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
6840
+ k && ds(I, N), G && fs(I, N);
6786
6841
  }
6787
6842
  return ls(h, k, G, P, E, sr.current, I);
6788
6843
  }
6789
6844
  }
6790
- var zt = g.ReactCurrentOwner, ar = g.ReactDebugCurrentFrame;
6845
+ var zt = _.ReactCurrentOwner, ar = _.ReactDebugCurrentFrame;
6791
6846
  function Pe(h) {
6792
6847
  if (h) {
6793
- var w = h._owner, v = bt(h.type, h._source, w ? w.type : null);
6848
+ var w = h._owner, v = _t(h.type, h._source, w ? w.type : null);
6794
6849
  ar.setExtraStackFrame(v);
6795
6850
  } else
6796
6851
  ar.setExtraStackFrame(null);
@@ -6868,7 +6923,7 @@ Check the top-level render call using <` + v + ">.");
6868
6923
  var v;
6869
6924
  if (typeof w == "function")
6870
6925
  v = w.propTypes;
6871
- else if (typeof w == "object" && (w.$$typeof === d || // Note: Memo only checks outer props here.
6926
+ else if (typeof w == "object" && (w.$$typeof === c || // Note: Memo only checks outer props here.
6872
6927
  // Inner props are checked in the reconciler.
6873
6928
  w.$$typeof === l))
6874
6929
  v = w.propTypes;
@@ -6900,18 +6955,18 @@ Check the top-level render call using <` + v + ">.");
6900
6955
  var hr = {};
6901
6956
  function pr(h, w, v, E, P, M) {
6902
6957
  {
6903
- var I = lt(h);
6958
+ var I = ht(h);
6904
6959
  if (!I) {
6905
6960
  var k = "";
6906
6961
  (h === void 0 || typeof h == "object" && h !== null && Object.keys(h).length === 0) && (k += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
6907
6962
  var G = ps();
6908
6963
  G ? k += G : k += cr();
6909
- var U;
6910
- h === null ? U = "null" : Wt(h) ? U = "array" : h !== void 0 && h.$$typeof === n ? (U = "<" + (ce(h.type) || "Unknown") + " />", k = " Did you accidentally export a JSX literal instead of a component?") : U = typeof h, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", U, k);
6964
+ var L;
6965
+ h === null ? L = "null" : Wt(h) ? L = "array" : h !== void 0 && h.$$typeof === n ? (L = "<" + (ce(h.type) || "Unknown") + " />", k = " Did you accidentally export a JSX literal instead of a component?") : L = typeof h, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", L, k);
6911
6966
  }
6912
- var F = hs(h, w, v, P, M);
6913
- if (F == null)
6914
- return F;
6967
+ var N = hs(h, w, v, P, M);
6968
+ if (N == null)
6969
+ return N;
6915
6970
  if (I) {
6916
6971
  var re = w.children;
6917
6972
  if (re !== void 0)
@@ -6939,7 +6994,7 @@ React keys must be passed directly to JSX without using spread:
6939
6994
  <%s key={someKey} {...props} />`, Gt, me, vs, me), hr[me + Gt] = !0;
6940
6995
  }
6941
6996
  }
6942
- return h === i ? _s(F) : bs(F), F;
6997
+ return h === i ? _s(N) : bs(N), N;
6943
6998
  }
6944
6999
  }
6945
7000
  function gs(h, w, v) {
@@ -6952,10 +7007,10 @@ React keys must be passed directly to JSX without using spread:
6952
7007
  He.Fragment = i, He.jsx = Ts, He.jsxs = ms;
6953
7008
  }(), He;
6954
7009
  }
6955
- var pc = {};
6956
- pc.NODE_ENV === "production" ? Tn.exports = lc() : Tn.exports = hc();
6957
- var V = Tn.exports;
6958
- const yc = {
7010
+ var yc = {};
7011
+ yc.NODE_ENV === "production" ? Tn.exports = hc() : Tn.exports = pc();
7012
+ var B = Tn.exports;
7013
+ const bc = {
6959
7014
  isLoading: !0,
6960
7015
  data: void 0,
6961
7016
  pageInfo: void 0,
@@ -6964,28 +7019,28 @@ const yc = {
6964
7019
  function ei(t) {
6965
7020
  return Object.assign({ isLoading: !t, data: void 0, pageInfo: void 0, error: void 0 }, t || {});
6966
7021
  }
6967
- function bc(t, e, n) {
7022
+ function _c(t, e, n) {
6968
7023
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6969
- const r = e ? uc(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
6970
- (a) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
7024
+ const r = e ? ac(e) : null, i = W(r), s = ut(ei(t._reactor.getPreviousResult(r))), o = we(
7025
+ (a) => (s.current = ei(t._reactor.getPreviousResult(r)), a(), r ? t.subscribeQuery(r, (d) => {
6971
7026
  s.current = Object.assign({
6972
- isLoading: !c,
7027
+ isLoading: !d,
6973
7028
  // @ts-expect-error: ts thinks this will always be overwritten
6974
7029
  data: void 0,
6975
7030
  // @ts-expect-error: ts thinks this will always be overwritten
6976
7031
  pageInfo: void 0,
6977
7032
  // @ts-expect-error: ts thinks this will always be overwritten
6978
7033
  error: void 0
6979
- }, c), a();
7034
+ }, d), a();
6980
7035
  }) : () => {
6981
7036
  }),
6982
7037
  // Build a new subscribe function if the query changes
6983
7038
  [i]
6984
7039
  );
6985
- return { state: en(o, () => s.current, () => yc), query: r };
7040
+ return { state: en(o, () => s.current, () => bc), query: r };
6986
7041
  }
6987
- function _c() {
6988
- const t = ot(null);
7042
+ function gc() {
7043
+ const t = ut(null);
6989
7044
  ke(() => {
6990
7045
  n();
6991
7046
  }, []);
@@ -6997,14 +7052,14 @@ function _c() {
6997
7052
  }
6998
7053
  return { set: e, clear: n };
6999
7054
  }
7000
- const gc = 1e3;
7001
- function wc(t, e, n) {
7002
- const r = ot(n);
7055
+ const wc = 1e3;
7056
+ function Tc(t, e, n) {
7057
+ const r = ut(n);
7003
7058
  r.current = n, ke(() => t.core._reactor.subscribeTopic(t.id, e, (s, o) => {
7004
7059
  r.current(s, o);
7005
7060
  }), [t.id, e]);
7006
7061
  }
7007
- function Tc(t, e) {
7062
+ function mc(t, e) {
7008
7063
  return ke(() => t.core._reactor.joinRoom(t.id), [t.id]), we((r) => {
7009
7064
  t.core._reactor.publishTopic({
7010
7065
  roomType: t.type,
@@ -7014,7 +7069,7 @@ function Tc(t, e) {
7014
7069
  });
7015
7070
  }, [t.id, e]);
7016
7071
  }
7017
- function mc(t, e = {}) {
7072
+ function vc(t, e = {}) {
7018
7073
  var n, r;
7019
7074
  const [i, s] = ui(() => {
7020
7075
  var a;
@@ -7023,113 +7078,108 @@ function mc(t, e = {}) {
7023
7078
  isLoading: !0
7024
7079
  };
7025
7080
  });
7026
- ke(() => t.core._reactor.subscribePresence(t.type, t.id, e, (d) => {
7027
- s(d);
7081
+ ke(() => t.core._reactor.subscribePresence(t.type, t.id, e, (c) => {
7082
+ s(c);
7028
7083
  }), [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
7084
  const o = we((a) => {
7030
7085
  t.core._reactor.publishPresence(t.type, t.id, a);
7031
7086
  }, [t.type, t.id]);
7032
7087
  return tn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
7033
7088
  }
7034
- function vc(t, e, n) {
7089
+ function Sc(t, e, n) {
7035
7090
  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
7091
  }
7037
- function Sc(t, e, n = {}) {
7038
- const r = _c(), i = Se.usePresence(t, {
7092
+ function Oc(t, e, n = {}) {
7093
+ const r = gc(), i = Se.usePresence(t, {
7039
7094
  keys: [e]
7040
7095
  }), s = tn(() => {
7041
- var c;
7096
+ var d;
7042
7097
  const f = t._core._reactor.getPresence(t.type, t.id);
7043
- return n != null && n.writeOnly ? [] : Object.values((c = f == null ? void 0 : f.peers) !== null && c !== void 0 ? c : {}).filter((l) => l[e] === !0);
7044
- }, [n == null ? void 0 : n.writeOnly, i]), o = we((c) => {
7098
+ return n != null && n.writeOnly ? [] : Object.values((d = f == null ? void 0 : f.peers) !== null && d !== void 0 ? d : {}).filter((l) => l[e] === !0);
7099
+ }, [n == null ? void 0 : n.writeOnly, i]), o = we((d) => {
7045
7100
  var f;
7046
7101
  t.core._reactor.publishPresence(t.type, t.id, {
7047
- [e]: c
7048
- }), c && ((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, () => {
7102
+ [e]: d
7103
+ }), 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
7104
  t.core._reactor.publishPresence(t.type, t.id, {
7050
7105
  [e]: null
7051
7106
  });
7052
7107
  }));
7053
- }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), u = we((c) => {
7054
- const l = !((n == null ? void 0 : n.stopOnEnter) && c.key === "Enter");
7108
+ }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), u = we((d) => {
7109
+ const l = !((n == null ? void 0 : n.stopOnEnter) && d.key === "Enter");
7055
7110
  o(l);
7056
7111
  }, [n.stopOnEnter, o]), a = we(() => {
7057
7112
  o(!1);
7058
- }, [o]), d = tn(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
7113
+ }, [o]), c = tn(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
7059
7114
  return {
7060
7115
  active: s,
7061
7116
  setActive: o,
7062
- inputProps: d
7117
+ inputProps: c
7063
7118
  };
7064
7119
  }
7065
7120
  const Se = {
7066
- useTopicEffect: wc,
7067
- usePublishTopic: Tc,
7068
- usePresence: mc,
7069
- useSyncPresence: vc,
7070
- useTypingIndicator: Sc
7121
+ useTopicEffect: Tc,
7122
+ usePublishTopic: mc,
7123
+ usePresence: vc,
7124
+ useSyncPresence: Sc,
7125
+ useTypingIndicator: Oc
7071
7126
  };
7072
- class Oc {
7127
+ class Ec {
7073
7128
  constructor(e, n, r) {
7074
7129
  this.useTopicEffect = (i, s) => {
7075
7130
  Se.useTopicEffect(this, i, s);
7076
7131
  }, 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
7132
  }
7078
7133
  }
7079
- var Ec = function(t, e, n, r) {
7134
+ var Ac = function(t, e, n, r) {
7080
7135
  function i(s) {
7081
7136
  return s instanceof n ? s : new n(function(o) {
7082
7137
  o(s);
7083
7138
  });
7084
7139
  }
7085
7140
  return new (n || (n = Promise))(function(s, o) {
7086
- function u(c) {
7141
+ function u(d) {
7087
7142
  try {
7088
- d(r.next(c));
7143
+ c(r.next(d));
7089
7144
  } catch (f) {
7090
7145
  o(f);
7091
7146
  }
7092
7147
  }
7093
- function a(c) {
7148
+ function a(d) {
7094
7149
  try {
7095
- d(r.throw(c));
7150
+ c(r.throw(d));
7096
7151
  } catch (f) {
7097
7152
  o(f);
7098
7153
  }
7099
7154
  }
7100
- function d(c) {
7101
- c.done ? s(c.value) : i(c.value).then(u, a);
7155
+ function c(d) {
7156
+ d.done ? s(d.value) : i(d.value).then(u, a);
7102
7157
  }
7103
- d((r = r.apply(t, e || [])).next());
7158
+ c((r = r.apply(t, e || [])).next());
7104
7159
  });
7105
7160
  };
7106
- const Ac = {
7161
+ const kc = {
7107
7162
  isLoading: !0,
7108
7163
  user: void 0,
7109
7164
  error: void 0
7110
7165
  };
7111
- class kc {
7166
+ class jc {
7112
7167
  constructor(e, n) {
7113
7168
  this.tx = Kn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
7114
7169
  const [i, s] = ui(null);
7115
7170
  return ke(() => {
7116
- Ec(this, void 0, void 0, function* () {
7171
+ Ac(this, void 0, void 0, function* () {
7117
7172
  const u = yield this.getLocalId(r);
7118
7173
  s(u);
7119
7174
  });
7120
7175
  }, [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((a) => {
7123
- r.current = Object.assign({ isLoading: !1 }, a), o();
7124
- }), []);
7125
- return en(i, () => r.current, () => Ac);
7126
- }, this.useUser = () => {
7176
+ }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => _c(this.core, r, i).state, this.useAuth = () => this._useAuth(), this.useUser = () => {
7127
7177
  const { user: r } = this.useAuth();
7128
7178
  if (!r)
7129
7179
  throw new qe("useUser must be used within an auth-protected route");
7130
7180
  return r;
7131
7181
  }, this.useConnectionStatus = () => {
7132
- const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((a) => {
7182
+ const r = ut(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((a) => {
7133
7183
  a !== r.current && (r.current = a, o());
7134
7184
  }), []);
7135
7185
  return en(
@@ -7140,11 +7190,11 @@ class kc {
7140
7190
  );
7141
7191
  }, this.queryOnce = (r, i) => this.core.queryOnce(r, i), this.SignedIn = ({ children: r }) => {
7142
7192
  const i = this.useAuth();
7143
- return i.isLoading || i.error || !i.user ? null : V.jsx(V.Fragment, { children: r });
7193
+ return i.isLoading || i.error || !i.user ? null : B.jsx(B.Fragment, { children: r });
7144
7194
  }, this.SignedOut = ({ children: r }) => {
7145
7195
  const i = this.useAuth();
7146
- return i.isLoading || i.error || i.user ? null : V.jsx(V.Fragment, { children: r });
7147
- }, this.core = dc(
7196
+ return i.isLoading || i.error || i.user ? null : B.jsx(B.Fragment, { children: r });
7197
+ }, this.core = fc(
7148
7198
  e,
7149
7199
  // @ts-expect-error because TS can't resolve subclass statics
7150
7200
  this.constructor.Storage,
@@ -7168,7 +7218,13 @@ class kc {
7168
7218
  * const { peers } = db.rooms.usePresence(room);
7169
7219
  */
7170
7220
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7171
- return new Oc(this.core, e, n);
7221
+ return new Ec(this.core, e, n);
7222
+ }
7223
+ _useAuth() {
7224
+ const e = ut(this.core._reactor._currentUserCached), n = we((i) => this.core.subscribeAuth((o) => {
7225
+ e.current = Object.assign({ isLoading: !1 }, o), i();
7226
+ }), []);
7227
+ return en(n, () => e.current, () => kc);
7172
7228
  }
7173
7229
  /**
7174
7230
  * One time query for the logged in state. This is useful
@@ -7191,18 +7247,18 @@ class ti extends Error {
7191
7247
  }
7192
7248
  function Xt(t) {
7193
7249
  }
7194
- function jc(t) {
7250
+ function Cc(t) {
7195
7251
  if (typeof t == "function")
7196
7252
  throw new TypeError(
7197
7253
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
7198
7254
  );
7199
7255
  const { onEvent: e = Xt, onError: n = Xt, onRetry: r = Xt, onComment: i } = t;
7200
- let s = "", o = !0, u, a = "", d = "";
7201
- function c(b) {
7202
- const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Cc(`${s}${_}`);
7256
+ let s = "", o = !0, u, a = "", c = "";
7257
+ function d(b) {
7258
+ const g = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, _] = Ic(`${s}${g}`);
7203
7259
  for (const m of T)
7204
7260
  f(m);
7205
- s = g, o = !1;
7261
+ s = _, o = !1;
7206
7262
  }
7207
7263
  function f(b) {
7208
7264
  if (b === "") {
@@ -7213,31 +7269,31 @@ function jc(t) {
7213
7269
  i && i(b.slice(b.startsWith(": ") ? 2 : 1));
7214
7270
  return;
7215
7271
  }
7216
- const _ = b.indexOf(":");
7217
- if (_ !== -1) {
7218
- const T = b.slice(0, _), g = b[_ + 1] === " " ? 2 : 1, m = b.slice(_ + g);
7272
+ const g = b.indexOf(":");
7273
+ if (g !== -1) {
7274
+ const T = b.slice(0, g), _ = b[g + 1] === " " ? 2 : 1, m = b.slice(g + _);
7219
7275
  l(T, m, b);
7220
7276
  return;
7221
7277
  }
7222
7278
  l(b, "", b);
7223
7279
  }
7224
- function l(b, _, T) {
7280
+ function l(b, g, T) {
7225
7281
  switch (b) {
7226
7282
  case "event":
7227
- d = _;
7283
+ c = g;
7228
7284
  break;
7229
7285
  case "data":
7230
- a = `${a}${_}
7286
+ a = `${a}${g}
7231
7287
  `;
7232
7288
  break;
7233
7289
  case "id":
7234
- u = _.includes("\0") ? void 0 : _;
7290
+ u = g.includes("\0") ? void 0 : g;
7235
7291
  break;
7236
7292
  case "retry":
7237
- /^\d+$/.test(_) ? r(parseInt(_, 10)) : n(
7238
- new ti(`Invalid \`retry\` value: "${_}"`, {
7293
+ /^\d+$/.test(g) ? r(parseInt(g, 10)) : n(
7294
+ new ti(`Invalid \`retry\` value: "${g}"`, {
7239
7295
  type: "invalid-retry",
7240
- value: _,
7296
+ value: g,
7241
7297
  line: T
7242
7298
  })
7243
7299
  );
@@ -7246,7 +7302,7 @@ function jc(t) {
7246
7302
  n(
7247
7303
  new ti(
7248
7304
  `Unknown field "${b.length > 20 ? `${b.slice(0, 20)}…` : b}"`,
7249
- { type: "unknown-field", field: b, value: _, line: T }
7305
+ { type: "unknown-field", field: b, value: g, line: T }
7250
7306
  )
7251
7307
  );
7252
7308
  break;
@@ -7255,19 +7311,19 @@ function jc(t) {
7255
7311
  function p() {
7256
7312
  a.length > 0 && e({
7257
7313
  id: u,
7258
- event: d || void 0,
7314
+ event: c || void 0,
7259
7315
  // If the data buffer's last character is a U+000A LINE FEED (LF) character,
7260
7316
  // then remove the last character from the data buffer.
7261
7317
  data: a.endsWith(`
7262
7318
  `) ? a.slice(0, -1) : a
7263
- }), u = void 0, a = "", d = "";
7319
+ }), u = void 0, a = "", c = "";
7264
7320
  }
7265
7321
  function y(b = {}) {
7266
- s && b.consume && f(s), o = !0, u = void 0, a = "", d = "", s = "";
7322
+ s && b.consume && f(s), o = !0, u = void 0, a = "", c = "", s = "";
7267
7323
  }
7268
- return { feed: c, reset: y };
7324
+ return { feed: d, reset: y };
7269
7325
  }
7270
- function Cc(t) {
7326
+ function Ic(t) {
7271
7327
  const e = [];
7272
7328
  let n = "", r = 0;
7273
7329
  for (; r < t.length; ) {
@@ -7327,7 +7383,7 @@ class ni extends Event {
7327
7383
  return e(ri(this), n);
7328
7384
  }
7329
7385
  }
7330
- function Ic(t) {
7386
+ function Pc(t) {
7331
7387
  const e = globalThis.DOMException;
7332
7388
  return typeof e == "function" ? new e(t, "SyntaxError") : new SyntaxError(t);
7333
7389
  }
@@ -7346,44 +7402,44 @@ function ri(t) {
7346
7402
  }
7347
7403
  var Yi = (t) => {
7348
7404
  throw TypeError(t);
7349
- }, zn = (t, e, n) => e.has(t) || Yi("Cannot " + n), A = (t, e, n) => (zn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), q = (t, e, n) => e.has(t) ? Yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), x = (t, e, n, r) => (zn(t, e, "write to private field"), e.set(t, n), n), pe = (t, e, n) => (zn(t, e, "access private method"), n), J, Oe, xe, At, Rt, it, Ue, st, ge, $e, Fe, De, Xe, se, vn, Sn, On, ii, En, An, et, kn, jn;
7405
+ }, zn = (t, e, n) => e.has(t) || Yi("Cannot " + n), A = (t, e, n) => (zn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), q = (t, e, n) => e.has(t) ? Yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), x = (t, e, n, r) => (zn(t, e, "write to private field"), e.set(t, n), n), pe = (t, e, n) => (zn(t, e, "access private method"), n), J, Oe, xe, At, Rt, st, Ue, ot, ge, $e, Fe, De, et, se, vn, Sn, On, ii, En, An, tt, kn, jn;
7350
7406
  class kt extends EventTarget {
7351
7407
  constructor(e, n) {
7352
7408
  var r, i;
7353
- super(), q(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, q(this, J), q(this, Oe), q(this, xe), q(this, At), q(this, Rt), q(this, it), q(this, Ue), q(this, st, null), q(this, ge), q(this, $e), q(this, Fe, null), q(this, De, null), q(this, Xe, null), q(this, Sn, async (s) => {
7409
+ 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, st), q(this, Ue), q(this, ot, null), q(this, ge), q(this, $e), q(this, Fe, null), q(this, De, null), q(this, et, null), q(this, Sn, async (s) => {
7354
7410
  var o;
7355
7411
  A(this, $e).reset();
7356
- const { body: u, redirected: a, status: d, headers: c } = s;
7357
- if (d === 204) {
7358
- pe(this, se, et).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
7412
+ const { body: u, redirected: a, status: c, headers: d } = s;
7413
+ if (c === 204) {
7414
+ pe(this, se, tt).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
7359
7415
  return;
7360
7416
  }
7361
- if (a ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), d !== 200) {
7362
- pe(this, se, et).call(this, `Non-200 status code (${d})`, d);
7417
+ if (a ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), c !== 200) {
7418
+ pe(this, se, tt).call(this, `Non-200 status code (${c})`, c);
7363
7419
  return;
7364
7420
  }
7365
- if (!(c.get("content-type") || "").startsWith("text/event-stream")) {
7366
- pe(this, se, et).call(this, 'Invalid content type, expected "text/event-stream"', d);
7421
+ if (!(d.get("content-type") || "").startsWith("text/event-stream")) {
7422
+ pe(this, se, tt).call(this, 'Invalid content type, expected "text/event-stream"', c);
7367
7423
  return;
7368
7424
  }
7369
7425
  if (A(this, J) === this.CLOSED)
7370
7426
  return;
7371
7427
  x(this, J, this.OPEN);
7372
7428
  const f = new Event("open");
7373
- if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof u != "object" || !u || !("getReader" in u)) {
7374
- pe(this, se, et).call(this, "Invalid response body, expected a web ReadableStream", d), this.close();
7429
+ if ((o = A(this, et)) == null || o.call(this, f), this.dispatchEvent(f), typeof u != "object" || !u || !("getReader" in u)) {
7430
+ pe(this, se, tt).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
7375
7431
  return;
7376
7432
  }
7377
7433
  const l = new TextDecoder(), p = u.getReader();
7378
7434
  let y = !0;
7379
7435
  do {
7380
- const { done: b, value: _ } = await p.read();
7381
- _ && A(this, $e).feed(l.decode(_, { stream: !b })), b && (y = !1, A(this, $e).reset(), pe(this, se, kn).call(this));
7436
+ const { done: b, value: g } = await p.read();
7437
+ g && A(this, $e).feed(l.decode(g, { stream: !b })), b && (y = !1, A(this, $e).reset(), pe(this, se, kn).call(this));
7382
7438
  } while (y);
7383
7439
  }), q(this, On, (s) => {
7384
7440
  x(this, ge, void 0), !(s.name === "AbortError" || s.type === "aborted") && pe(this, se, kn).call(this, mn(s));
7385
7441
  }), q(this, En, (s) => {
7386
- typeof s.id == "string" && x(this, st, s.id);
7442
+ typeof s.id == "string" && x(this, ot, s.id);
7387
7443
  const o = new MessageEvent(s.event || "message", {
7388
7444
  data: s.data,
7389
7445
  origin: A(this, xe) ? A(this, xe).origin : A(this, Oe).origin,
@@ -7391,7 +7447,7 @@ class kt extends EventTarget {
7391
7447
  });
7392
7448
  A(this, De) && (!s.event || s.event === "message") && A(this, De).call(this, o), this.dispatchEvent(o);
7393
7449
  }), q(this, An, (s) => {
7394
- x(this, it, s);
7450
+ x(this, st, s);
7395
7451
  }), q(this, jn, () => {
7396
7452
  x(this, Ue, void 0), A(this, J) === this.CONNECTING && pe(this, se, vn).call(this);
7397
7453
  });
@@ -7399,16 +7455,16 @@ class kt extends EventTarget {
7399
7455
  if (e instanceof URL)
7400
7456
  x(this, Oe, e);
7401
7457
  else if (typeof e == "string")
7402
- x(this, Oe, new URL(e, Pc()));
7458
+ x(this, Oe, new URL(e, Mc()));
7403
7459
  else
7404
7460
  throw new Error("Invalid URL");
7405
7461
  } catch {
7406
- throw Ic("An invalid or illegal string was specified");
7462
+ throw Pc("An invalid or illegal string was specified");
7407
7463
  }
7408
- x(this, $e, jc({
7464
+ x(this, $e, Cc({
7409
7465
  onEvent: A(this, En),
7410
7466
  onRetry: A(this, An)
7411
- })), 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);
7467
+ })), x(this, J, this.CONNECTING), x(this, st, 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);
7412
7468
  }
7413
7469
  /**
7414
7470
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -7457,10 +7513,10 @@ class kt extends EventTarget {
7457
7513
  }
7458
7514
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
7459
7515
  get onopen() {
7460
- return A(this, Xe);
7516
+ return A(this, et);
7461
7517
  }
7462
7518
  set onopen(e) {
7463
- x(this, Xe, e);
7519
+ x(this, et, e);
7464
7520
  }
7465
7521
  addEventListener(e, n, r) {
7466
7522
  const i = n;
@@ -7481,7 +7537,7 @@ class kt extends EventTarget {
7481
7537
  A(this, Ue) && clearTimeout(A(this, Ue)), A(this, J) !== this.CLOSED && (A(this, ge) && A(this, ge).abort(), x(this, J, this.CLOSED), x(this, ge, void 0));
7482
7538
  }
7483
7539
  }
7484
- J = /* @__PURE__ */ new WeakMap(), Oe = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(), Rt = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakSet(), /**
7540
+ J = /* @__PURE__ */ new WeakMap(), Oe = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(), Rt = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), et = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakSet(), /**
7485
7541
  * Connect to the given URL and start receiving events
7486
7542
  *
7487
7543
  * @internal
@@ -7501,7 +7557,7 @@ ii = function() {
7501
7557
  // [spec] …will have their mode set to "cors"…
7502
7558
  mode: "cors",
7503
7559
  redirect: "follow",
7504
- headers: { Accept: "text/event-stream", ...A(this, st) ? { "Last-Event-ID": A(this, st) } : void 0 },
7560
+ headers: { Accept: "text/event-stream", ...A(this, ot) ? { "Last-Event-ID": A(this, ot) } : void 0 },
7505
7561
  cache: "no-store",
7506
7562
  signal: (t = A(this, ge)) == null ? void 0 : t.signal
7507
7563
  };
@@ -7513,7 +7569,7 @@ ii = function() {
7513
7569
  * @param code - The HTTP status code, if available
7514
7570
  * @internal
7515
7571
  */
7516
- et = function(t, e) {
7572
+ tt = function(t, e) {
7517
7573
  var n;
7518
7574
  A(this, J) !== this.CLOSED && x(this, J, this.CLOSED);
7519
7575
  const r = new ni("error", { code: e, message: t });
@@ -7531,7 +7587,7 @@ kn = function(t, e) {
7531
7587
  return;
7532
7588
  x(this, J, this.CONNECTING);
7533
7589
  const r = new ni("error", { code: e, message: t });
7534
- (n = A(this, Fe)) == null || n.call(this, r), this.dispatchEvent(r), x(this, Ue, setTimeout(A(this, jn), A(this, it)));
7590
+ (n = A(this, Fe)) == null || n.call(this, r), this.dispatchEvent(r), x(this, Ue, setTimeout(A(this, jn), A(this, st)));
7535
7591
  }, jn = /* @__PURE__ */ new WeakMap(), /**
7536
7592
  * ReadyState representing an EventSource currently trying to connect
7537
7593
  *
@@ -7548,15 +7604,15 @@ kt.OPEN = 1, /**
7548
7604
  * @public
7549
7605
  */
7550
7606
  kt.CLOSED = 2;
7551
- function Pc() {
7607
+ function Mc() {
7552
7608
  const t = "document" in globalThis ? globalThis.document : void 0;
7553
7609
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
7554
7610
  }
7555
- const Vn = class Vn extends kc {
7611
+ const Vn = class Vn extends jc {
7556
7612
  };
7557
7613
  Vn.EventSourceImpl = kt;
7558
7614
  let Cn = Vn;
7559
- function Mc(t) {
7615
+ function Rc(t) {
7560
7616
  const e = {
7561
7617
  ...t,
7562
7618
  useDateObjects: t.useDateObjects ?? !1
@@ -7565,8 +7621,8 @@ function Mc(t) {
7565
7621
  "@instantdb/react": Wn
7566
7622
  });
7567
7623
  }
7568
- const Nc = Mc;
7569
- function Kc({
7624
+ const Kc = Rc;
7625
+ function qc({
7570
7626
  as: t = "div",
7571
7627
  spaceId: e,
7572
7628
  room: n,
@@ -7576,15 +7632,15 @@ function Kc({
7576
7632
  children: o,
7577
7633
  renderCursor: u,
7578
7634
  propagate: a,
7579
- zIndex: d
7635
+ zIndex: c
7580
7636
  }) {
7581
- const c = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
7582
- keys: [c]
7637
+ const d = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
7638
+ keys: [d]
7583
7639
  }), l = n._core._reactor.getPresence(n.type, n.id);
7584
- function p(g, m) {
7585
- const O = m.clientX, S = m.clientY, C = (O - g.left) / g.width * 100, $ = (S - g.top) / g.height * 100;
7640
+ function p(_, m) {
7641
+ const O = m.clientX, S = m.clientY, C = (O - _.left) / _.width * 100, $ = (S - _.top) / _.height * 100;
7586
7642
  f.publishPresence({
7587
- [c]: {
7643
+ [d]: {
7588
7644
  x: O,
7589
7645
  y: S,
7590
7646
  xPercent: C,
@@ -7593,29 +7649,29 @@ function Kc({
7593
7649
  }
7594
7650
  });
7595
7651
  }
7596
- function y(g) {
7597
- a || g.stopPropagation();
7598
- const m = g.currentTarget.getBoundingClientRect();
7599
- p(m, g);
7652
+ function y(_) {
7653
+ a || _.stopPropagation();
7654
+ const m = _.currentTarget.getBoundingClientRect();
7655
+ p(m, _);
7600
7656
  }
7601
- function b(g) {
7657
+ function b(_) {
7602
7658
  f.publishPresence({
7603
- [c]: void 0
7659
+ [d]: void 0
7604
7660
  });
7605
7661
  }
7606
- function _(g) {
7607
- if (g.touches.length !== 1)
7662
+ function g(_) {
7663
+ if (_.touches.length !== 1)
7608
7664
  return;
7609
- const m = g.touches[0];
7665
+ const m = _.touches[0];
7610
7666
  if (m.target instanceof Element) {
7611
- a || g.stopPropagation();
7667
+ a || _.stopPropagation();
7612
7668
  const O = m.target.getBoundingClientRect();
7613
7669
  p(O, m);
7614
7670
  }
7615
7671
  }
7616
- function T(g) {
7672
+ function T(_) {
7617
7673
  f.publishPresence({
7618
- [c]: void 0
7674
+ [d]: void 0
7619
7675
  });
7620
7676
  }
7621
7677
  return Os(
@@ -7623,7 +7679,7 @@ function Kc({
7623
7679
  {
7624
7680
  onMouseMove: y,
7625
7681
  onMouseOut: b,
7626
- onTouchMove: _,
7682
+ onTouchMove: g,
7627
7683
  onTouchEnd: T,
7628
7684
  className: r,
7629
7685
  style: {
@@ -7633,17 +7689,17 @@ function Kc({
7633
7689
  },
7634
7690
  [
7635
7691
  o,
7636
- /* @__PURE__ */ V.jsx(
7692
+ /* @__PURE__ */ B.jsx(
7637
7693
  "div",
7638
7694
  {
7639
7695
  style: {
7640
7696
  ...si,
7641
- ...xc,
7642
- zIndex: d !== void 0 ? d : $c
7697
+ ...$c,
7698
+ zIndex: c !== void 0 ? c : Dc
7643
7699
  },
7644
- children: Object.entries(f.peers).map(([g, m]) => {
7645
- const O = m[c];
7646
- return O ? /* @__PURE__ */ V.jsx(
7700
+ children: Object.entries(f.peers).map(([_, m]) => {
7701
+ const O = m[d];
7702
+ return O ? /* @__PURE__ */ B.jsx(
7647
7703
  "div",
7648
7704
  {
7649
7705
  style: {
@@ -7654,21 +7710,21 @@ function Kc({
7654
7710
  },
7655
7711
  children: u ? u({
7656
7712
  color: O.color,
7657
- presence: l == null ? void 0 : l.peers[g]
7658
- }) : /* @__PURE__ */ V.jsx(Rc, { ...O })
7713
+ presence: l == null ? void 0 : l.peers[_]
7714
+ }) : /* @__PURE__ */ B.jsx(xc, { ...O })
7659
7715
  },
7660
- g
7716
+ _
7661
7717
  ) : null;
7662
7718
  })
7663
7719
  },
7664
- c
7720
+ d
7665
7721
  )
7666
7722
  ]
7667
7723
  );
7668
7724
  }
7669
- function Rc({ color: t }) {
7725
+ function xc({ color: t }) {
7670
7726
  const n = t || "black";
7671
- return /* @__PURE__ */ V.jsxs(
7727
+ return /* @__PURE__ */ B.jsxs(
7672
7728
  "svg",
7673
7729
  {
7674
7730
  style: { height: 35, width: 35 },
@@ -7676,36 +7732,36 @@ function Rc({ color: t }) {
7676
7732
  fill: "none",
7677
7733
  xmlns: "http://www.w3.org/2000/svg",
7678
7734
  children: [
7679
- /* @__PURE__ */ V.jsxs(
7735
+ /* @__PURE__ */ B.jsxs(
7680
7736
  "g",
7681
7737
  {
7682
7738
  fill: "rgba(0,0,0,.2)",
7683
7739
  transform: "matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)",
7684
7740
  children: [
7685
- /* @__PURE__ */ V.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
7686
- /* @__PURE__ */ V.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
7741
+ /* @__PURE__ */ B.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
7742
+ /* @__PURE__ */ B.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
7687
7743
  ]
7688
7744
  }
7689
7745
  ),
7690
- /* @__PURE__ */ V.jsxs(
7746
+ /* @__PURE__ */ B.jsxs(
7691
7747
  "g",
7692
7748
  {
7693
7749
  fill: "white",
7694
7750
  transform: "matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)",
7695
7751
  children: [
7696
- /* @__PURE__ */ V.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
7697
- /* @__PURE__ */ V.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
7752
+ /* @__PURE__ */ B.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
7753
+ /* @__PURE__ */ B.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
7698
7754
  ]
7699
7755
  }
7700
7756
  ),
7701
- /* @__PURE__ */ V.jsxs(
7757
+ /* @__PURE__ */ B.jsxs(
7702
7758
  "g",
7703
7759
  {
7704
7760
  fill: n,
7705
7761
  transform: "matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)",
7706
7762
  children: [
7707
- /* @__PURE__ */ V.jsx("path", { d: "m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z" }),
7708
- /* @__PURE__ */ V.jsx("path", { d: "m13 10.814v11.188l2.969-2.866.428-.139h4.768z" })
7763
+ /* @__PURE__ */ B.jsx("path", { d: "m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z" }),
7764
+ /* @__PURE__ */ B.jsx("path", { d: "m13 10.814v11.188l2.969-2.866.428-.139h4.768z" })
7709
7765
  ]
7710
7766
  }
7711
7767
  )
@@ -7719,21 +7775,21 @@ const si = {
7719
7775
  left: 0,
7720
7776
  bottom: 0,
7721
7777
  right: 0
7722
- }, xc = {
7778
+ }, $c = {
7723
7779
  overflow: "hidden",
7724
7780
  pointerEvents: "none",
7725
7781
  userSelect: "none"
7726
- }, $c = 99999;
7782
+ }, Dc = 99999;
7727
7783
  export {
7728
- Kc as Cursors,
7784
+ qc as Cursors,
7729
7785
  Dt as InstantAPIError,
7730
- kc as InstantReactAbstractDatabase,
7786
+ jc as InstantReactAbstractDatabase,
7731
7787
  Cn as InstantReactWebDatabase,
7732
7788
  ve as SyncTableCallbackEventType,
7733
- Fc as i,
7734
- W as id,
7735
- Mc as init,
7736
- Nc as init_experimental,
7737
- Uc as lookup,
7738
- Lc as tx
7789
+ Nc as i,
7790
+ z as id,
7791
+ Rc as init,
7792
+ Kc as init_experimental,
7793
+ Lc as lookup,
7794
+ Fc as tx
7739
7795
  };