@instantdb/react-common 0.22.89-experimental.split-store.20276199573.1 → 0.22.89-experimental.uuidfix.20281951052.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2504,21 +2504,22 @@ function Ws() {
2504
2504
  const Bs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Vn = { randomUUID: Bs };
2505
2505
  function Gs(t, e, n) {
2506
2506
  var i;
2507
- if (Vn.randomUUID && !t)
2508
- return Vn.randomUUID();
2509
2507
  t = t || {};
2510
2508
  const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Ws();
2511
2509
  if (r.length < 16)
2512
2510
  throw new Error("Random bytes length must be >= 16");
2513
2511
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, zs(r);
2514
2512
  }
2513
+ function Qs(t, e, n) {
2514
+ return Vn.randomUUID ? Vn.randomUUID() : Gs(t);
2515
+ }
2515
2516
  function Wn(t) {
2516
2517
  const e = t.replace(/-/g, ""), n = [];
2517
2518
  for (let r = 0; r < e.length; r += 2)
2518
2519
  n.push(parseInt(e.substring(r, r + 2), 16));
2519
2520
  return n;
2520
2521
  }
2521
- function Qs(t, e) {
2522
+ function Hs(t, e) {
2522
2523
  for (let n = 0; n < t.length; n++) {
2523
2524
  if (t[n] < e[n])
2524
2525
  return -1;
@@ -2527,17 +2528,17 @@ function Qs(t, e) {
2527
2528
  }
2528
2529
  return 0;
2529
2530
  }
2530
- function Hs(t, e) {
2531
- return Qs(Wn(t), Wn(e));
2531
+ function Ys(t, e) {
2532
+ return Hs(Wn(t), Wn(e));
2532
2533
  }
2533
2534
  function N() {
2534
- return Gs();
2535
+ return Qs();
2535
2536
  }
2536
- function Ys(t, e) {
2537
+ function Js(t, e) {
2537
2538
  return t.localeCompare(e);
2538
2539
  }
2539
- function Js() {
2540
- let t = Ys;
2540
+ function Zs() {
2541
+ let t = Js;
2541
2542
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
2542
2543
  try {
2543
2544
  t = Intl.Collator("en-US").compare;
@@ -2545,10 +2546,10 @@ function Js() {
2545
2546
  }
2546
2547
  return t;
2547
2548
  }
2548
- const Zs = Js();
2549
- let Xs = 0;
2549
+ const Xs = Zs();
2550
+ let eo = 0;
2550
2551
  function Ne(t) {
2551
- return yt(`_${t}`, Xs++);
2552
+ return yt(`_${t}`, eo++);
2552
2553
  }
2553
2554
  function yt(t, e) {
2554
2555
  return `?${t}-${e}`;
@@ -2558,24 +2559,24 @@ class ke extends Error {
2558
2559
  super(e), this.name = "AttrNotFoundError";
2559
2560
  }
2560
2561
  }
2561
- function eo(t, e) {
2562
+ function to(t, e) {
2562
2563
  const n = Kr(t, e);
2563
2564
  if (!n)
2564
2565
  throw new ke(`Could not find id attr for ${e}`);
2565
2566
  return n;
2566
2567
  }
2567
2568
  function Bn(t, e, n, r) {
2568
- return [to(t, e, n, r)];
2569
+ return [no(t, e, n, r)];
2569
2570
  }
2570
- function to(t, e, n, r) {
2571
+ function no(t, e, n, r) {
2571
2572
  return [
2572
2573
  t(n, r),
2573
- eo(e, n).id,
2574
+ to(e, n).id,
2574
2575
  t(n, r),
2575
2576
  t("time", r)
2576
2577
  ];
2577
2578
  }
2578
- function no(t, e, n) {
2579
+ function ro(t, e, n) {
2579
2580
  return t.map((r) => r === e ? n : r);
2580
2581
  }
2581
2582
  function zr(t, e, n, r, i) {
@@ -2607,7 +2608,7 @@ function Gn(t, e) {
2607
2608
  return typeof o != "string" ? !1 : i.test(o);
2608
2609
  };
2609
2610
  }
2610
- function ro(t, e) {
2611
+ function io(t, e) {
2611
2612
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2612
2613
  return e;
2613
2614
  const n = t["checked-data-type"] === "date";
@@ -2667,7 +2668,7 @@ function ro(t, e) {
2667
2668
  }
2668
2669
  return e;
2669
2670
  }
2670
- function io(t, e, n, r, i, s) {
2671
+ function so(t, e, n, r, i, s) {
2671
2672
  const o = F(e, n, i), u = me(e, n, i), a = o || u;
2672
2673
  if (!a)
2673
2674
  throw new ke(`No attr for etype = ${n} label = ${i}`);
@@ -2685,11 +2686,11 @@ function io(t, e, n, r, i, s) {
2685
2686
  return o ? [
2686
2687
  t(n, r),
2687
2688
  a.id,
2688
- ro(a, s),
2689
+ io(a, s),
2689
2690
  Ne("time")
2690
2691
  ] : [s, a.id, t(n, r), Ne("time")];
2691
2692
  }
2692
- function so(t, e, n, r, i) {
2693
+ function oo(t, e, n, r, i) {
2693
2694
  const [s, o, u] = i.reduce((a, c) => {
2694
2695
  const [d, f, l] = a, [p, y, b] = zr(t, e, d, f, c);
2695
2696
  return [p, y, [...l, b]];
@@ -2697,19 +2698,19 @@ function so(t, e, n, r, i) {
2697
2698
  return [s, o, u];
2698
2699
  }
2699
2700
  function qt(t, e, n, r, i, s) {
2700
- const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = so(t, e, n, r, o), f = io(t, e, a, c, u, s);
2701
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = oo(t, e, n, r, o), f = so(t, e, a, c, u, s);
2701
2702
  return d.concat([f]);
2702
2703
  }
2703
- function oo(t, e) {
2704
+ function uo(t, e) {
2704
2705
  return e ? [e].concat(t) : t;
2705
2706
  }
2706
- function uo([t, e]) {
2707
+ function ao([t, e]) {
2707
2708
  return t === "or" && Array.isArray(e);
2708
2709
  }
2709
- function ao([t, e]) {
2710
+ function co([t, e]) {
2710
2711
  return t === "and" && Array.isArray(e);
2711
2712
  }
2712
- function co(t, e, n) {
2713
+ function fo(t, e, n) {
2713
2714
  return (r, i) => {
2714
2715
  const s = t(r, i);
2715
2716
  return e == s ? s : `${s}-${n}`;
@@ -2717,27 +2718,27 @@ function co(t, e, n) {
2717
2718
  }
2718
2719
  function Qn(t, e, n, r, i, s) {
2719
2720
  const o = t(r, i), u = s.map((a, c) => {
2720
- const d = co(t, o, c);
2721
+ const d = fo(t, o, c);
2721
2722
  return Vr(d, n, r, i, a);
2722
2723
  });
2723
2724
  return { [e]: { patterns: u, joinSym: o } };
2724
2725
  }
2725
- function fo(t) {
2726
+ function lo(t) {
2726
2727
  const e = [];
2727
2728
  for (let n = 1; n <= t.length; n++)
2728
2729
  e.push(t.slice(0, n));
2729
2730
  return e;
2730
2731
  }
2731
2732
  function Hn(t, e, n, r, i) {
2732
- return fo(i).map((s) => qt(t, e, n, r, s, {
2733
+ return lo(i).map((s) => qt(t, e, n, r, s, {
2733
2734
  $isNull: !0
2734
2735
  }));
2735
2736
  }
2736
2737
  function Vr(t, e, n, r, i) {
2737
2738
  return Object.entries(i).flatMap(([s, o]) => {
2738
- if (uo([s, o]))
2739
- return Qn(t, "or", e, n, r, o);
2740
2739
  if (ao([s, o]))
2740
+ return Qn(t, "or", e, n, r, o);
2741
+ if (co([s, o]))
2741
2742
  return Qn(t, "and", e, n, r, o);
2742
2743
  if (s === "$entityIdStartsWith")
2743
2744
  return [];
@@ -2763,25 +2764,25 @@ function Vr(t, e, n, r, i) {
2763
2764
  ] : qt(t, e, n, r, u, o);
2764
2765
  });
2765
2766
  }
2766
- function lo(t, e, n, r) {
2767
+ function ho(t, e, n, r) {
2767
2768
  const i = yt;
2768
2769
  return r ? Vr(i, t, e, n, r).concat(Bn(i, t, e, n)) : Bn(i, t, e, n);
2769
2770
  }
2770
- function ho(t, e, n) {
2771
+ function po(t, e, n) {
2771
2772
  return [t(e, n), t("time", n)];
2772
2773
  }
2773
- function po(t, e, n, r, i, s) {
2774
- const [o, u, a, c, d] = zr(t, e, n, r, i), f = no(a, t(n, r), s);
2774
+ function yo(t, e, n, r, i, s) {
2775
+ const [o, u, a, c, d] = zr(t, e, n, r, i), f = ro(a, t(n, r), s);
2775
2776
  return [o, u, f, c, d];
2776
2777
  }
2777
- function yo(t, e, n, { etype: r, level: i, form: s }, o) {
2778
+ function bo(t, e, n, { etype: r, level: i, form: s }, o) {
2778
2779
  const u = Object.keys(s).filter((a) => a !== "$");
2779
2780
  return u.length ? Object.entries(o).map(function([c, d]) {
2780
2781
  return u.map(function(p) {
2781
2782
  var y, b, _;
2782
2783
  const w = !!(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));
2783
2784
  try {
2784
- const [g, v, A] = po(t, n, r, i, p, c), S = Br(e, n, {
2785
+ const [g, v, A] = yo(t, n, r, i, p, c), S = Br(e, n, {
2785
2786
  etype: g,
2786
2787
  level: v,
2787
2788
  form: s[p],
@@ -2798,11 +2799,11 @@ function yo(t, e, n, { etype: r, level: i, form: s }, o) {
2798
2799
  }, d);
2799
2800
  }) : Object.values(o);
2800
2801
  }
2801
- function bo(t, e, n) {
2802
- return n === "string" ? Zs(t, e) : t > e ? 1 : -1;
2802
+ function _o(t, e, n) {
2803
+ return n === "string" ? Xs(t, e) : t > e ? 1 : -1;
2803
2804
  }
2804
2805
  function Le(t, e, n, r, i) {
2805
- return e === r || e == null && r == null ? Hs(t, n) : r == null ? 1 : e == null ? -1 : bo(e, r, i);
2806
+ return e === r || e == null && r == null ? Ys(t, n) : r == null ? 1 : e == null ? -1 : _o(e, r, i);
2806
2807
  }
2807
2808
  function lt([t, e], [n, r], i) {
2808
2809
  return Le(t, e, n, r, i);
@@ -2810,7 +2811,7 @@ function lt([t, e], [n, r], i) {
2810
2811
  function zt(t) {
2811
2812
  return t == null ? t : new Date(t).getTime();
2812
2813
  }
2813
- function _o(t, e, n, r) {
2814
+ function go(t, e, n, r) {
2814
2815
  var i;
2815
2816
  const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
2816
2817
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
@@ -2818,21 +2819,21 @@ function _o(t, e, n, r) {
2818
2819
  const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? zt(f) : f, y = l === "date" ? zt(u) : u;
2819
2820
  return lt([d, p], [s, y], l) === c;
2820
2821
  }
2821
- function go(t, e) {
2822
+ function To(t, e) {
2822
2823
  const n = e[1];
2823
2824
  return t.getAttr(n);
2824
2825
  }
2825
- function To(t, e, n) {
2826
+ function wo(t, e, n) {
2826
2827
  const r = Object.keys(n)[0];
2827
2828
  return F(t, e, r);
2828
2829
  }
2829
- function wo(t, e, n, r) {
2830
+ function mo(t, e, n, r) {
2830
2831
  if (n)
2831
- return go(t, n);
2832
+ return To(t, n);
2832
2833
  if (r)
2833
- return To(t, e, r);
2834
+ return wo(t, e, r);
2834
2835
  }
2835
- function mo(t, e, n) {
2836
+ function vo(t, e, n) {
2836
2837
  var r, i;
2837
2838
  if (!Array.isArray(n.fields))
2838
2839
  return Cs(t, e);
@@ -2847,11 +2848,11 @@ function mo(t, e, n) {
2847
2848
  }
2848
2849
  return s;
2849
2850
  }
2850
- function vo(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2851
+ function So(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2851
2852
  var o, u;
2852
- const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Wr(s), d = So(s);
2853
+ const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Wr(s), d = Oo(s);
2853
2854
  let f = Ns(t, i);
2854
- const l = r == null ? void 0 : r["start-cursor"], p = wo(e, n, l, a);
2855
+ const l = r == null ? void 0 : r["start-cursor"], p = mo(e, n, l, a);
2855
2856
  if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
2856
2857
  const _ = p["checked-data-type"] === "date", w = p.id;
2857
2858
  f = f.map(([g]) => {
@@ -2866,17 +2867,17 @@ function vo(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2866
2867
  return lt(g, w, p == null ? void 0 : p["checked-data-type"]);
2867
2868
  });
2868
2869
  let y = {};
2869
- const b = mo(e, n, i);
2870
+ const b = vo(e, n, i);
2870
2871
  for (const _ of f) {
2871
2872
  const [w] = _;
2872
- if (y[w] || !c && l && p && _o(l, p, d, _))
2873
+ if (y[w] || !c && l && p && go(l, p, d, _))
2873
2874
  continue;
2874
2875
  const g = js(t, b, w);
2875
2876
  g && (y[w] = g);
2876
2877
  }
2877
2878
  return y;
2878
2879
  }
2879
- function So(t) {
2880
+ function Oo(t) {
2880
2881
  var e;
2881
2882
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2882
2883
  return n && n[Object.keys(n)[0]] || "asc";
@@ -2886,11 +2887,11 @@ function Wr(t) {
2886
2887
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2887
2888
  return !i && !s && !o;
2888
2889
  }
2889
- function Oo(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2890
+ function Ao(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2890
2891
  var u, a, c, d, f;
2891
2892
  if (!Wr(i) && (!o || !o["start-cursor"]))
2892
2893
  return [];
2893
- const l = oo(lo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = ho(yt, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = vo(t, e, {
2894
+ const l = uo(ho(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = po(yt, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = So(t, e, {
2894
2895
  etype: n,
2895
2896
  pageInfo: o,
2896
2897
  form: i,
@@ -2903,9 +2904,9 @@ function Oo(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2903
2904
  }
2904
2905
  return b;
2905
2906
  }
2906
- function Ao(t, e, n) {
2907
+ function Eo(t, e, n) {
2907
2908
  try {
2908
- return Oo(t, e, n);
2909
+ return Ao(t, e, n);
2909
2910
  } catch (r) {
2910
2911
  if (r instanceof ke)
2911
2912
  return {};
@@ -2913,10 +2914,10 @@ function Ao(t, e, n) {
2913
2914
  }
2914
2915
  }
2915
2916
  function Br(t, e, n) {
2916
- const r = Ao(t, e, n);
2917
- return yo(yt, t, e, n, r);
2917
+ const r = Eo(t, e, n);
2918
+ return bo(yt, t, e, n, r);
2918
2919
  }
2919
- function Eo(t) {
2920
+ function ko(t) {
2920
2921
  const e = {};
2921
2922
  for (const [n, r] of Object.entries(t))
2922
2923
  e[n] = {
@@ -2936,9 +2937,9 @@ function Gr({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
2936
2937
  pageInfo: n == null ? void 0 : n[c]
2937
2938
  })), a;
2938
2939
  }, {}) };
2939
- return n && (o.pageInfo = Eo(n)), r && (o.aggregate = r), o;
2940
+ return n && (o.pageInfo = ko(n)), r && (o.aggregate = r), o;
2940
2941
  }
2941
- function ko() {
2942
+ function jo() {
2942
2943
  const e = {
2943
2944
  __etype: 1,
2944
2945
  __ops: 1,
@@ -2952,7 +2953,7 @@ function ko() {
2952
2953
  };
2953
2954
  return new Set(Object.keys(e));
2954
2955
  }
2955
- const jo = ko();
2956
+ const Co = jo();
2956
2957
  function Vt(t, e, n) {
2957
2958
  const r = {
2958
2959
  __etype: t,
@@ -2964,7 +2965,7 @@ function Vt(t, e, n) {
2964
2965
  return n;
2965
2966
  if (s === "__etype")
2966
2967
  return t;
2967
- if (jo.has(s))
2968
+ if (Co.has(s))
2968
2969
  return (o, u) => Vt(t, e, [
2969
2970
  ...n,
2970
2971
  u ? [s, t, e, o, u] : [s, t, e, o]
@@ -2979,7 +2980,7 @@ function Qr(t) {
2979
2980
  const [e, n, ...r] = t.split("__");
2980
2981
  return [n, JSON.parse(r.join("__"))];
2981
2982
  }
2982
- function Co(t) {
2983
+ function Io(t) {
2983
2984
  return new Proxy({
2984
2985
  __etype: t
2985
2986
  }, {
@@ -2994,15 +2995,15 @@ function Co(t) {
2994
2995
  function cn() {
2995
2996
  return new Proxy({}, {
2996
2997
  get(t, e) {
2997
- return Co(e);
2998
+ return Io(e);
2998
2999
  }
2999
3000
  });
3000
3001
  }
3001
3002
  cn();
3002
- function Io(t) {
3003
+ function Po(t) {
3003
3004
  return t.__ops;
3004
3005
  }
3005
- function Po(t, e) {
3006
+ function Mo(t, e) {
3006
3007
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
3007
3008
  for (const o of e) {
3008
3009
  const u = n[o];
@@ -3021,7 +3022,7 @@ function Po(t, e) {
3021
3022
  }
3022
3023
  return i;
3023
3024
  }
3024
- function Mo(t) {
3025
+ function Ro(t) {
3025
3026
  if (Array.isArray(t))
3026
3027
  return t;
3027
3028
  const e = Object.entries(t);
@@ -3029,7 +3030,7 @@ function Mo(t) {
3029
3030
  throw new Error("lookup must be an object with a single unique attr and value.");
3030
3031
  return e[0];
3031
3032
  }
3032
- function Ro(t, e, n) {
3033
+ function $o(t, e, n) {
3033
3034
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
3034
3035
  // before assuming it's a ref lookup.
3035
3036
  !F(t, e, n);
@@ -3040,8 +3041,8 @@ function Wt(t) {
3040
3041
  throw new Error(`${t} is not a valid lookup attribute.`);
3041
3042
  return e;
3042
3043
  }
3043
- function $o(t, e, n) {
3044
- if (!Ro(t, e, n))
3044
+ function Do(t, e, n) {
3045
+ if (!$o(t, e, n))
3045
3046
  return F(t, e, n);
3046
3047
  const r = Wt(n), i = F(t, e, r) || me(t, e, r);
3047
3048
  if (i && i["value-type"] !== "ref")
@@ -3049,13 +3050,13 @@ function $o(t, e, n) {
3049
3050
  return i;
3050
3051
  }
3051
3052
  function Bt(t) {
3052
- return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Qr(t) : Mo(t);
3053
+ return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Qr(t) : Ro(t);
3053
3054
  }
3054
3055
  function Q(t, e, n) {
3055
3056
  const r = Bt(n);
3056
3057
  if (r === null)
3057
3058
  return n;
3058
- const [i, s] = r, o = $o(t, e, i);
3059
+ const [i, s] = r, o = Do(t, e, i);
3059
3060
  if (!o || !o["unique?"])
3060
3061
  throw new Error(`${i} is not a unique attribute.`);
3061
3062
  return [o.id, s];
@@ -3070,7 +3071,7 @@ function Hr(t, e, n, r) {
3070
3071
  s
3071
3072
  ]].concat(r) : r;
3072
3073
  }
3073
- function Do({ attrsStore: t }, [e, n, r]) {
3074
+ function xo({ attrsStore: t }, [e, n, r]) {
3074
3075
  const i = Object.entries(r).flatMap(([s, o]) => {
3075
3076
  const u = Array.isArray(o) ? o : [o], a = F(t, e, s), c = me(t, e, s);
3076
3077
  return u.map((d) => a ? [
@@ -3091,7 +3092,7 @@ function Do({ attrsStore: t }, [e, n, r]) {
3091
3092
  });
3092
3093
  return Hr(t, e, n, i);
3093
3094
  }
3094
- function xo({ attrsStore: t }, [e, n, r]) {
3095
+ function Uo({ attrsStore: t }, [e, n, r]) {
3095
3096
  const i = Object.entries(r).flatMap(([s, o]) => {
3096
3097
  const u = Array.isArray(o) ? o : [o], a = F(t, e, s), c = me(t, e, s);
3097
3098
  return u.map((d) => a ? [
@@ -3112,7 +3113,7 @@ function xo({ attrsStore: t }, [e, n, r]) {
3112
3113
  });
3113
3114
  return Hr(t, e, n, i);
3114
3115
  }
3115
- function Uo(t, e, n, r) {
3116
+ function Lo(t, e, n, r) {
3116
3117
  var i;
3117
3118
  if (Array.isArray(r)) {
3118
3119
  const [s, o] = r;
@@ -3136,16 +3137,16 @@ function Uo(t, e, n, r) {
3136
3137
  return !1;
3137
3138
  }
3138
3139
  function Yr({ stores: t, attrsStore: e }, [n, r, i, s]) {
3139
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Uo(t, e, n, r) ? { mode: "update" } : null;
3140
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Lo(t, e, n, r) ? { mode: "update" } : null;
3140
3141
  }
3141
- function Lo(t, e) {
3142
+ function Fo(t, e) {
3142
3143
  const { attrsStore: n } = t, [r, i, s, o] = e, u = sn(s), a = Q(n, r, i);
3143
3144
  return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
3144
3145
  const l = F(n, r, d);
3145
3146
  return l["checked-data-type"] === "date" && t.useDateObjects && (f = pt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
3146
3147
  });
3147
3148
  }
3148
- function Fo(t, e) {
3149
+ function No(t, e) {
3149
3150
  const { attrsStore: n } = t, [r, i, s, o] = e, u = sn(s), a = Q(n, r, i), c = Yr(t, [r, a, s, o]);
3150
3151
  return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
3151
3152
  const p = F(n, r, f);
@@ -3158,10 +3159,10 @@ function Fo(t, e) {
3158
3159
  ];
3159
3160
  });
3160
3161
  }
3161
- function No({ attrsStore: t }, [e, n]) {
3162
+ function Ko({ attrsStore: t }, [e, n]) {
3162
3163
  return [["delete-entity", Q(t, e, n), e]];
3163
3164
  }
3164
- function Ko(t, e) {
3165
+ function qo(t, e) {
3165
3166
  const { attrsStore: n } = t, [r, i, s, o] = e, u = sn(s), a = Q(n, r, i), c = Yr(t, [r, a, s, o]), d = Object.entries(u).map(([l, p]) => {
3166
3167
  const y = F(n, r, l);
3167
3168
  return [
@@ -3180,38 +3181,38 @@ function Ko(t, e) {
3180
3181
  ...c ? [c] : []
3181
3182
  ]].concat(d);
3182
3183
  }
3183
- function qo({ attrsStore: t }, [e, n, r]) {
3184
+ function zo({ attrsStore: t }, [e, n, r]) {
3184
3185
  return [["rule-params", Q(t, e, n), e, r]];
3185
3186
  }
3186
- function zo(t) {
3187
+ function Vo(t) {
3187
3188
  const [e, n, r, i, s] = t;
3188
3189
  if (!i)
3189
3190
  return t;
3190
3191
  const o = Object.assign({}, i);
3191
3192
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
3192
3193
  }
3193
- function Vo(t, e) {
3194
- const [n, ...r] = zo(e);
3194
+ function Wo(t, e) {
3195
+ const [n, ...r] = Vo(e);
3195
3196
  switch (n) {
3196
3197
  case "merge":
3197
- return Ko(t, r);
3198
+ return qo(t, r);
3198
3199
  case "create":
3199
- return Lo(t, r);
3200
- case "update":
3201
3200
  return Fo(t, r);
3201
+ case "update":
3202
+ return No(t, r);
3202
3203
  case "link":
3203
- return Do(t, r);
3204
- case "unlink":
3205
3204
  return xo(t, r);
3205
+ case "unlink":
3206
+ return Uo(t, r);
3206
3207
  case "delete":
3207
- return No(t, r);
3208
+ return Ko(t, r);
3208
3209
  case "ruleParams":
3209
- return qo(t, r);
3210
+ return zo(t, r);
3210
3211
  default:
3211
3212
  throw new Error(`unsupported action ${n}`);
3212
3213
  }
3213
3214
  }
3214
- function Wo(t) {
3215
+ function Bo(t) {
3215
3216
  switch (t) {
3216
3217
  case "string":
3217
3218
  case "date":
@@ -3222,14 +3223,14 @@ function Wo(t) {
3222
3223
  return;
3223
3224
  }
3224
3225
  }
3225
- function Bo(t, e, n) {
3226
+ function Go(t, e, n) {
3226
3227
  var r, i;
3227
3228
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
3228
3229
  if (n === "id")
3229
3230
  return null;
3230
3231
  if (!s)
3231
3232
  throw new Error(`${e}.${n} does not exist in your schema`);
3232
- const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Wo(s == null ? void 0 : s.valueType);
3233
+ const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Bo(s == null ? void 0 : s.valueType);
3233
3234
  return {
3234
3235
  "index?": u,
3235
3236
  "unique?": o,
@@ -3237,14 +3238,14 @@ function Bo(t, e, n) {
3237
3238
  };
3238
3239
  }
3239
3240
  function nt(t, e, n, r) {
3240
- const i = t ? Bo(t, e, n) : null, s = N(), u = [N(), e, n];
3241
+ const i = t ? Go(t, e, n) : null, s = N(), u = [N(), e, n];
3241
3242
  return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
3242
3243
  }
3243
- function Go(t, e, n) {
3244
+ function Qo(t, e, n) {
3244
3245
  return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
3245
3246
  }
3246
- function Qo(t, e, n) {
3247
- const r = Go(t, e, n);
3247
+ function Ho(t, e, n) {
3248
+ const r = Qo(t, e, n);
3248
3249
  if (!r)
3249
3250
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
3250
3251
  const { forward: i, reverse: s } = r;
@@ -3258,7 +3259,7 @@ function Qo(t, e, n) {
3258
3259
  };
3259
3260
  }
3260
3261
  function Yn(t, e, n, r) {
3261
- const i = t ? Qo(t, e, n) : null, s = N(), o = [N(), e, n], u = [N(), n, e];
3262
+ const i = t ? Ho(t, e, n) : null, s = N(), o = [N(), e, n], u = [N(), n, e];
3262
3263
  return Object.assign(Object.assign({
3263
3264
  id: s,
3264
3265
  // @ts-ignore: ts thinks it's any[]
@@ -3273,7 +3274,7 @@ function Yn(t, e, n, r) {
3273
3274
  isUnsynced: !0
3274
3275
  }, i || {}), r || {});
3275
3276
  }
3276
- const Ho = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Yo = /* @__PURE__ */ new Set(["link", "unlink"]), Jo = /* @__PURE__ */ new Set(["create", "update", "merge"]), Zo = /* @__PURE__ */ new Set([
3277
+ const Yo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Jo = /* @__PURE__ */ new Set(["link", "unlink"]), Zo = /* @__PURE__ */ new Set(["create", "update", "merge"]), Xo = /* @__PURE__ */ new Set([
3277
3278
  "link",
3278
3279
  "unlink",
3279
3280
  "create",
@@ -3281,10 +3282,10 @@ const Ho = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
3281
3282
  "merge",
3282
3283
  "delete",
3283
3284
  "ruleParams"
3284
- ]), Gt = { "unique?": !0, "index?": !0 }, Xo = Object.assign(Object.assign({}, Gt), { cardinality: "one" });
3285
- function eu(t) {
3285
+ ]), Gt = { "unique?": !0, "index?": !0 }, eu = Object.assign(Object.assign({}, Gt), { cardinality: "one" });
3286
+ function tu(t) {
3286
3287
  const e = [], [n, r, i, s] = t;
3287
- if (!Zo.has(n))
3288
+ if (!Xo.has(n))
3288
3289
  return e;
3289
3290
  const o = Bt(i);
3290
3291
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -3301,7 +3302,7 @@ function eu(t) {
3301
3302
  }
3302
3303
  return e;
3303
3304
  }
3304
- function tu({ attrsStore: t, schema: e }, n) {
3305
+ function nu({ attrsStore: t, schema: e }, n) {
3305
3306
  var r, i;
3306
3307
  const s = /* @__PURE__ */ new Set(), o = [], u = [];
3307
3308
  function a(y, b) {
@@ -3326,10 +3327,10 @@ function tu({ attrsStore: t, schema: e }, n) {
3326
3327
  }
3327
3328
  function p(y, b) {
3328
3329
  const _ = a(y, b), w = c(y, b);
3329
- f(_), f(w), !_ && !w && d(Yn(e, y, b, Xo));
3330
+ f(_), f(w), !_ && !w && d(Yn(e, y, b, eu));
3330
3331
  }
3331
3332
  for (const y of n)
3332
- for (const { etype: b, lookupPair: _, linkLabel: w } of eu(y)) {
3333
+ for (const { etype: b, lookupPair: _, linkLabel: w } of tu(y)) {
3333
3334
  const g = _[0];
3334
3335
  if (w) {
3335
3336
  p(b, w);
@@ -3351,12 +3352,12 @@ function tu({ attrsStore: t, schema: e }, n) {
3351
3352
  }
3352
3353
  for (const y of n) {
3353
3354
  const [b, _, w, g] = y;
3354
- if (Ho.has(b)) {
3355
+ if (Yo.has(b)) {
3355
3356
  const v = a(_, "id");
3356
3357
  f(v), v || d(nt(e, _, "id", { "unique?": !0 }));
3357
3358
  for (const A of Object.keys(g)) {
3358
3359
  const S = a(_, A);
3359
- if (f(S), Jo.has(b) && (S || d(nt(e, _, A, A === "id" ? { "unique?": !0 } : null))), Yo.has(b)) {
3360
+ if (f(S), Zo.has(b) && (S || d(nt(e, _, A, A === "id" ? { "unique?": !0 } : null))), Jo.has(b)) {
3360
3361
  const C = c(_, A);
3361
3362
  !S && !C && d(Yn(e, _, A)), f(C);
3362
3363
  }
@@ -3371,8 +3372,8 @@ function tu({ attrsStore: t, schema: e }, n) {
3371
3372
  }
3372
3373
  return [t, u];
3373
3374
  }
3374
- function nu(t, e) {
3375
- const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Io(a)), [i, s] = tu(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Vo(o, a));
3375
+ function ru(t, e) {
3376
+ const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Po(a)), [i, s] = nu(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Wo(o, a));
3376
3377
  return [...s, ...u];
3377
3378
  }
3378
3379
  var re = function(t, e, n, r) {
@@ -3406,7 +3407,7 @@ function Jn(t, e) {
3406
3407
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
3407
3408
  }
3408
3409
  const Ke = "__meta";
3409
- class ru {
3410
+ class iu {
3410
3411
  constructor(e, n) {
3411
3412
  }
3412
3413
  }
@@ -3678,13 +3679,13 @@ var ue = function(t, e, n, r) {
3678
3679
  c((r = r.apply(t, e || [])).next());
3679
3680
  });
3680
3681
  };
3681
- const iu = 6, su = ["kv", "querySubs", "syncSubs"];
3682
- function ou(t) {
3682
+ const su = 6, ou = ["kv", "querySubs", "syncSubs"];
3683
+ function uu(t) {
3683
3684
  return function(n) {
3684
3685
  console.error("Error in IndexedDB event", { source: t, event: n });
3685
3686
  };
3686
3687
  }
3687
- function uu(t) {
3688
+ function au(t) {
3688
3689
  return ue(this, void 0, void 0, function* () {
3689
3690
  return new Promise((e) => {
3690
3691
  const n = indexedDB.open(t);
@@ -3700,7 +3701,7 @@ function uu(t) {
3700
3701
  });
3701
3702
  });
3702
3703
  }
3703
- function au(t, e, n) {
3704
+ function cu(t, e, n) {
3704
3705
  return ue(this, void 0, void 0, function* () {
3705
3706
  const r = (
3706
3707
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3744,9 +3745,9 @@ function Zn(t, e, n) {
3744
3745
  });
3745
3746
  });
3746
3747
  }
3747
- function cu(t, e) {
3748
+ function du(t, e) {
3748
3749
  return ue(this, void 0, void 0, function* () {
3749
- const n = yield uu(`instant_${t}_5`);
3750
+ const n = yield au(`instant_${t}_5`);
3750
3751
  if (!n)
3751
3752
  return;
3752
3753
  const r = yield new Promise((d, f) => {
@@ -3769,7 +3770,7 @@ function cu(t, e) {
3769
3770
  for (const [d, f] of r)
3770
3771
  switch (d) {
3771
3772
  case "querySubs": {
3772
- const l = au(d, f, o);
3773
+ const l = cu(d, f, o);
3773
3774
  u.push(l);
3774
3775
  break;
3775
3776
  }
@@ -3792,9 +3793,9 @@ function cu(t, e) {
3792
3793
  });
3793
3794
  }
3794
3795
  const Xn = /* @__PURE__ */ new Map();
3795
- class Jr extends ru {
3796
+ class Jr extends iu {
3796
3797
  constructor(e, n) {
3797
- super(e, n), this.dbName = `instant_${e}_${iu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3798
+ super(e, n), this.dbName = `instant_${e}_${su}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3798
3799
  }
3799
3800
  _init() {
3800
3801
  return new Promise((e, n) => {
@@ -3805,8 +3806,8 @@ class Jr extends ru {
3805
3806
  }, i.onsuccess = (s) => {
3806
3807
  const u = s.target.result;
3807
3808
  if (r) {
3808
- const a = cu(this._appId, u).catch((c) => {
3809
- ou("Error upgrading store from version 5 to 6.")(c);
3809
+ const a = du(this._appId, u).catch((c) => {
3810
+ uu("Error upgrading store from version 5 to 6.")(c);
3810
3811
  });
3811
3812
  Xn.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3812
3813
  } else {
@@ -3820,7 +3821,7 @@ class Jr extends ru {
3820
3821
  }
3821
3822
  _upgradeStore(e) {
3822
3823
  const r = e.target.result;
3823
- for (const i of su)
3824
+ for (const i of ou)
3824
3825
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3825
3826
  }
3826
3827
  getItem(e) {
@@ -3895,7 +3896,7 @@ class Jr extends ru {
3895
3896
  });
3896
3897
  }
3897
3898
  }
3898
- var du = function(t, e, n, r) {
3899
+ var fu = function(t, e, n, r) {
3899
3900
  function i(s) {
3900
3901
  return s instanceof n ? s : new n(function(o) {
3901
3902
  o(s);
@@ -3924,7 +3925,7 @@ var du = function(t, e, n, r) {
3924
3925
  };
3925
3926
  class Zr {
3926
3927
  static getIsOnline() {
3927
- return du(this, void 0, void 0, function* () {
3928
+ return fu(this, void 0, void 0, function* () {
3928
3929
  return navigator.onLine;
3929
3930
  });
3930
3931
  }
@@ -3949,7 +3950,7 @@ class je extends Error {
3949
3950
  return "InstantError";
3950
3951
  }
3951
3952
  }
3952
- var fu = function(t, e, n, r) {
3953
+ var lu = function(t, e, n, r) {
3953
3954
  function i(s) {
3954
3955
  return s instanceof n ? s : new n(function(o) {
3955
3956
  o(s);
@@ -3989,7 +3990,7 @@ class bt extends je {
3989
3990
  }
3990
3991
  }
3991
3992
  function te(t, e) {
3992
- return fu(this, void 0, void 0, function* () {
3993
+ return lu(this, void 0, void 0, function* () {
3993
3994
  const n = yield fetch(t, e), r = yield n.json();
3994
3995
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new bt({ status: n.status, body: r }));
3995
3996
  });
@@ -4021,14 +4022,14 @@ var Ie = function(t, e, n, r) {
4021
4022
  c((r = r.apply(t, e || [])).next());
4022
4023
  });
4023
4024
  };
4024
- function lu({ apiURI: t, appId: e, email: n }) {
4025
+ function hu({ apiURI: t, appId: e, email: n }) {
4025
4026
  return te(`${t}/runtime/auth/send_magic_code`, {
4026
4027
  method: "POST",
4027
4028
  headers: { "content-type": "application/json" },
4028
4029
  body: JSON.stringify({ "app-id": e, email: n })
4029
4030
  });
4030
4031
  }
4031
- function hu(t) {
4032
+ function pu(t) {
4032
4033
  return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
4033
4034
  return yield te(`${e}/runtime/auth/verify_magic_code`, {
4034
4035
  method: "POST",
@@ -4041,7 +4042,7 @@ function hu(t) {
4041
4042
  });
4042
4043
  });
4043
4044
  }
4044
- function pu(t) {
4045
+ function yu(t) {
4045
4046
  return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
4046
4047
  return yield te(`${e}/runtime/auth/verify_refresh_token`, {
4047
4048
  method: "POST",
@@ -4053,7 +4054,7 @@ function pu(t) {
4053
4054
  });
4054
4055
  });
4055
4056
  }
4056
- function yu(t) {
4057
+ function bu(t) {
4057
4058
  return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
4058
4059
  return yield te(`${e}/runtime/auth/sign_in_guest`, {
4059
4060
  method: "POST",
@@ -4078,7 +4079,7 @@ function er(t) {
4078
4079
  });
4079
4080
  });
4080
4081
  }
4081
- function bu(t) {
4082
+ function _u(t) {
4082
4083
  return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
4083
4084
  return yield te(`${e}/runtime/oauth/id_token`, {
4084
4085
  method: "POST",
@@ -4093,7 +4094,7 @@ function bu(t) {
4093
4094
  });
4094
4095
  });
4095
4096
  }
4096
- function _u(t) {
4097
+ function gu(t) {
4097
4098
  return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
4098
4099
  return yield te(`${e}/runtime/signout`, {
4099
4100
  method: "POST",
@@ -4134,7 +4135,7 @@ var Be = function(t, e, n, r) {
4134
4135
  c((r = r.apply(t, e || [])).next());
4135
4136
  });
4136
4137
  };
4137
- function gu(t) {
4138
+ function Tu(t) {
4138
4139
  return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
4139
4140
  const a = {
4140
4141
  app_id: n,
@@ -4149,7 +4150,7 @@ function gu(t) {
4149
4150
  });
4150
4151
  });
4151
4152
  }
4152
- function Tu(t) {
4153
+ function wu(t) {
4153
4154
  return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
4154
4155
  const { data: s } = yield te(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
4155
4156
  method: "DELETE",
@@ -4161,7 +4162,7 @@ function Tu(t) {
4161
4162
  return s;
4162
4163
  });
4163
4164
  }
4164
- function wu(t) {
4165
+ function mu(t) {
4165
4166
  return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
4166
4167
  const { data: o } = yield te(`${e}/storage/signed-upload-url`, {
4167
4168
  method: "POST",
@@ -4177,7 +4178,7 @@ function wu(t) {
4177
4178
  return o;
4178
4179
  });
4179
4180
  }
4180
- function mu(t, e) {
4181
+ function vu(t, e) {
4181
4182
  return Be(this, void 0, void 0, function* () {
4182
4183
  return (yield fetch(t, {
4183
4184
  method: "PUT",
@@ -4188,7 +4189,7 @@ function mu(t, e) {
4188
4189
  })).ok;
4189
4190
  });
4190
4191
  }
4191
- function vu(t) {
4192
+ function Su(t) {
4192
4193
  return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
4193
4194
  const { data: s } = yield te(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
4194
4195
  method: "GET",
@@ -4210,7 +4211,7 @@ function tr(t, e) {
4210
4211
  n[r] = t[r];
4211
4212
  }), n;
4212
4213
  }
4213
- function Su(t, e, n) {
4214
+ function Ou(t, e, n) {
4214
4215
  var r, i;
4215
4216
  const s = {
4216
4217
  peers: {}
@@ -4228,7 +4229,7 @@ function Su(t, e, n) {
4228
4229
  }
4229
4230
  return s;
4230
4231
  }
4231
- function Ou(t, e) {
4232
+ function Au(t, e) {
4232
4233
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Nn(t.user, e.user)) || !Cr(t.peers, e.peers))
4233
4234
  return !0;
4234
4235
  for (const r of Object.keys(t.peers))
@@ -4276,8 +4277,8 @@ function ir(t) {
4276
4277
  }, e;
4277
4278
  }, {});
4278
4279
  }
4279
- const ni = "v0.22.89-experimental.split-store.20276199573.1";
4280
- function Au(t, e) {
4280
+ const ni = "v0.22.89-experimental.uuidfix.20281951052.1";
4281
+ function Eu(t, e) {
4281
4282
  return {
4282
4283
  info: t ? (...n) => console.info(...n, e()) : () => {
4283
4284
  },
@@ -4326,7 +4327,7 @@ const sr = [
4326
4327
  "before",
4327
4328
  "fields",
4328
4329
  "aggregate"
4329
- ], Eu = (t) => t.valueType || "unknown", ri = (t, e, n = !1) => {
4330
+ ], ku = (t) => t.valueType || "unknown", ri = (t, e, n = !1) => {
4330
4331
  if (n || t == null)
4331
4332
  return !0;
4332
4333
  switch (e) {
@@ -4341,7 +4342,7 @@ const sr = [
4341
4342
  default:
4342
4343
  return !0;
4343
4344
  }
4344
- }, ku = (t, e, n, r, i, s, o) => {
4345
+ }, ju = (t, e, n, r, i, s, o) => {
4345
4346
  const u = s.valueType === "json", a = (c, d, f) => {
4346
4347
  if (!ri(f, d, u))
4347
4348
  throw new M(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
@@ -4374,16 +4375,16 @@ const sr = [
4374
4375
  throw new M(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
4375
4376
  }
4376
4377
  }, Ae = (t, e, n, r, i) => {
4377
- const s = Eu(n), o = n.valueType === "json";
4378
+ const s = ku(n), o = n.valueType === "json";
4378
4379
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
4379
4380
  if (o)
4380
4381
  return;
4381
4382
  const a = t;
4382
4383
  for (const [c, d] of Object.entries(a))
4383
- ku(c, d, s, e, r, n, `${i}.${c}`);
4384
+ ju(c, d, s, e, r, n, `${i}.${c}`);
4384
4385
  } else if (!ri(t, s, o))
4385
4386
  throw new M(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
4386
- }, ju = (t, e, n, r, i) => {
4387
+ }, Cu = (t, e, n, r, i) => {
4387
4388
  const s = t.split(".");
4388
4389
  if (s.length < 2)
4389
4390
  throw new M(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -4433,7 +4434,7 @@ const sr = [
4433
4434
  continue;
4434
4435
  }
4435
4436
  if (i.includes(".")) {
4436
- ju(i, s, e, n, `${r}.${i}`);
4437
+ Cu(i, s, e, n, `${r}.${i}`);
4437
4438
  continue;
4438
4439
  }
4439
4440
  const o = n.entities[e];
@@ -4453,7 +4454,7 @@ const sr = [
4453
4454
  Ae(s, i, c, e, `${r}.${i}`);
4454
4455
  }
4455
4456
  }
4456
- }, Cu = (t, e, n, r, i = 0) => {
4457
+ }, Iu = (t, e, n, r, i = 0) => {
4457
4458
  for (const o of Object.keys(t))
4458
4459
  if (!sr.includes(o))
4459
4460
  throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${sr.join(", ")}. Found: ${o}`, r);
@@ -4492,7 +4493,7 @@ const sr = [
4492
4493
  const u = t[o];
4493
4494
  if (typeof u != "object" || u === null)
4494
4495
  throw new M(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
4495
- Cu(u, e, n, `${r}.$`, i);
4496
+ Iu(u, e, n, `${r}.$`, i);
4496
4497
  }
4497
4498
  }, or = (t, e) => {
4498
4499
  if (typeof t != "object" || t === null)
@@ -4519,19 +4520,19 @@ class Z extends Error {
4519
4520
  super(e), this.name = "TransactionValidationError";
4520
4521
  }
4521
4522
  }
4522
- const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${oi(e)}`), ar = {
4523
+ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Pu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${oi(e)}`), ar = {
4523
4524
  string: (t) => typeof t == "string",
4524
4525
  number: (t) => typeof t == "number" && !isNaN(t),
4525
4526
  boolean: (t) => typeof t == "boolean",
4526
4527
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4527
4528
  json: () => !0
4528
- }, Pu = (t, e) => {
4529
+ }, Mu = (t, e) => {
4529
4530
  var n, r;
4530
4531
  return t == null ? !0 : (r = (n = ar[e.valueType]) === null || n === void 0 ? void 0 : n.call(ar, t)) !== null && r !== void 0 ? r : !1;
4531
4532
  }, ui = (t, e) => {
4532
4533
  const n = e.entities[t];
4533
4534
  if (!n)
4534
- throw Iu(t, Object.keys(e.entities));
4535
+ throw Pu(t, Object.keys(e.entities));
4535
4536
  return n;
4536
4537
  }, jt = (t, e, n) => {
4537
4538
  const r = ui(t, n);
@@ -4541,7 +4542,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
4541
4542
  if (i === "id")
4542
4543
  continue;
4543
4544
  const o = r.attrs[i];
4544
- if (o && !Pu(s, o))
4545
+ if (o && !Mu(s, o))
4545
4546
  throw new Z(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
4546
4547
  }
4547
4548
  }, cr = (t, e, n) => {
@@ -4562,7 +4563,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
4562
4563
  throw new Z(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
4563
4564
  }
4564
4565
  }
4565
- }, Mu = {
4566
+ }, Ru = {
4566
4567
  create: jt,
4567
4568
  update: jt,
4568
4569
  merge: jt,
@@ -4570,7 +4571,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
4570
4571
  unlink: cr,
4571
4572
  delete: () => {
4572
4573
  }
4573
- }, Ru = (t, e) => {
4574
+ }, $u = (t, e) => {
4574
4575
  if (!e)
4575
4576
  return;
4576
4577
  const [n, r, i, s] = t;
@@ -4578,9 +4579,9 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
4578
4579
  throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
4579
4580
  if (typeof r != "string")
4580
4581
  throw new Z(`Entity name must be a string, but received: ${typeof r}`);
4581
- const o = Mu[n];
4582
+ const o = Ru[n];
4582
4583
  o && s !== void 0 && o(r, s, e);
4583
- }, $u = (t, e) => {
4584
+ }, Du = (t, e) => {
4584
4585
  const n = Array.isArray(t) ? t : [t];
4585
4586
  for (const r of n) {
4586
4587
  if (!r || typeof r != "object")
@@ -4590,7 +4591,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
4590
4591
  for (const i of r.__ops) {
4591
4592
  if (!Array.isArray(i))
4592
4593
  throw new Z(`Transaction operation must be an array, but received: ${typeof i}`);
4593
- Ru(i, e);
4594
+ $u(i, e);
4594
4595
  }
4595
4596
  }
4596
4597
  };
@@ -4652,7 +4653,7 @@ class fr {
4652
4653
  return this.conn.send(JSON.stringify(e));
4653
4654
  }
4654
4655
  }
4655
- class Du {
4656
+ class xu {
4656
4657
  constructor(e, n) {
4657
4658
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${ai++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4658
4659
  this.initParams || this.handleError();
@@ -4765,7 +4766,7 @@ var lr = function(t, e, n, r) {
4765
4766
  c((r = r.apply(t, e || [])).next());
4766
4767
  });
4767
4768
  };
4768
- function xu(t, e) {
4769
+ function Uu(t, e) {
4769
4770
  const n = t.values;
4770
4771
  if (n) {
4771
4772
  const r = Dr(n.attrsStore, null);
@@ -4777,7 +4778,7 @@ function xu(t, e) {
4777
4778
  }
4778
4779
  return t;
4779
4780
  }
4780
- function Uu(t, e) {
4781
+ function Lu(t, e) {
4781
4782
  var n;
4782
4783
  if (e.values) {
4783
4784
  const r = [];
@@ -4789,7 +4790,7 @@ function Uu(t, e) {
4789
4790
  } else
4790
4791
  return e;
4791
4792
  }
4792
- function Lu(t, e, n) {
4793
+ function Fu(t, e, n) {
4793
4794
  var r, i;
4794
4795
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4795
4796
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
@@ -4816,7 +4817,7 @@ function pr(t, e, n) {
4816
4817
  break;
4817
4818
  }
4818
4819
  }
4819
- function Fu(t, e, n) {
4820
+ function Nu(t, e, n) {
4820
4821
  var r, i, s, o;
4821
4822
  const u = {};
4822
4823
  for (const { action: a, triple: c } of n) {
@@ -4844,14 +4845,14 @@ function Fu(t, e, n) {
4844
4845
  function rt(t, e) {
4845
4846
  return { [t.table]: e.map((n) => n.entity) };
4846
4847
  }
4847
- function Nu(t, e) {
4848
+ function Ku(t, e) {
4848
4849
  var n;
4849
4850
  if (t.orderFieldType)
4850
4851
  return t.orderFieldType;
4851
4852
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = F(e(), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4852
4853
  return t.orderFieldType = r, r;
4853
4854
  }
4854
- function Ku(t, e, n) {
4855
+ function qu(t, e, n) {
4855
4856
  const r = e;
4856
4857
  if (t.orderField === "serverCreatedAt") {
4857
4858
  n.sort(t.orderDirection === "asc" ? function(o, u) {
@@ -4872,13 +4873,13 @@ var pe;
4872
4873
  (function(t) {
4873
4874
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4874
4875
  })(pe || (pe = {}));
4875
- class qu {
4876
+ class zu {
4876
4877
  constructor(e, n, r, i, s, o) {
4877
4878
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.getAttrs = o, this.subs = new Qt({
4878
4879
  persister: n,
4879
- merge: Lu,
4880
- serialize: Uu,
4881
- parse: (u, a) => xu(a, this.config.useDateObjects),
4880
+ merge: Fu,
4881
+ serialize: Lu,
4882
+ parse: (u, a) => Uu(a, this.config.useDateObjects),
4882
4883
  objectSize: (u) => {
4883
4884
  var a;
4884
4885
  return ((a = u.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
@@ -5080,7 +5081,7 @@ class qu {
5080
5081
  const S = p[A];
5081
5082
  if (Ts(S.store, g)) {
5082
5083
  pr(S.store, l.attrsStore, v);
5083
- const C = Ct(u, S.store, l.attrsStore), $ = Fu(S.store, l.attrsStore, v)[g];
5084
+ const C = Ct(u, S.store, l.attrsStore), $ = Nu(S.store, l.attrsStore, v)[g];
5084
5085
  C ? (y.push({
5085
5086
  oldEntity: S.entity,
5086
5087
  newEntity: C,
@@ -5111,8 +5112,8 @@ class qu {
5111
5112
  const _ = [];
5112
5113
  for (const g of d.sort().reverse())
5113
5114
  _.push(p[g].entity), p.splice(g, 1);
5114
- const w = Nu(u, this.getAttrs);
5115
- Ku(u, w, p), this.notifyCbs(o, {
5115
+ const w = Ku(u, this.getAttrs);
5116
+ qu(u, w, p), this.notifyCbs(o, {
5116
5117
  type: pe.SyncTransaction,
5117
5118
  data: rt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
5118
5119
  added: b,
@@ -5193,23 +5194,23 @@ const oe = {
5193
5194
  AUTHENTICATED: "authenticated",
5194
5195
  CLOSED: "closed",
5195
5196
  ERRORED: "errored"
5196
- }, zu = 3e4, Vu = 3e4, Wu = 200, Bu = {
5197
+ }, Vu = 3e4, Wu = 3e4, Bu = 200, Gu = {
5197
5198
  apiURI: "https://api.instantdb.com",
5198
5199
  websocketURI: "wss://api.instantdb.com/runtime/session"
5199
5200
  }, It = "_instant_oauth_redirect", De = "currentUser";
5200
- function Gu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
5201
+ function Qu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
5201
5202
  if (!i)
5202
5203
  return new fr(`${r}?app_id=${e}`);
5203
5204
  switch (t) {
5204
5205
  case "ws":
5205
5206
  return new fr(`${r}?app_id=${e}`);
5206
5207
  case "sse":
5207
- return new Du(i, `${n}/runtime/sse?app_id=${e}`);
5208
+ return new xu(i, `${n}/runtime/sse?app_id=${e}`);
5208
5209
  default:
5209
5210
  throw new Error("Unknown transport type " + t);
5210
5211
  }
5211
5212
  }
5212
- function Qu() {
5213
+ function Hu() {
5213
5214
  return typeof window < "u" || typeof chrome < "u";
5214
5215
  }
5215
5216
  const yr = {
@@ -5218,7 +5219,7 @@ const yr = {
5218
5219
  "refresh-presence": !0,
5219
5220
  "patch-presence": !0
5220
5221
  };
5221
- function Hu(t, e) {
5222
+ function Yu(t, e) {
5222
5223
  var n;
5223
5224
  const r = typeof t == "string" ? JSON.parse(t) : t;
5224
5225
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
@@ -5230,7 +5231,7 @@ function Hu(t, e) {
5230
5231
  }
5231
5232
  return r;
5232
5233
  }
5233
- function Yu(t, e) {
5234
+ function Ju(t, e) {
5234
5235
  const { result: n } = e, i = ci(e, ["result"]);
5235
5236
  if (n) {
5236
5237
  const s = Object.assign(Object.assign({}, n), { store: Rr(n.store), attrsStore: n.attrsStore.toJSON() });
@@ -5238,7 +5239,7 @@ function Yu(t, e) {
5238
5239
  }
5239
5240
  return i;
5240
5241
  }
5241
- function Ju(t, e) {
5242
+ function Zu(t, e) {
5242
5243
  switch (t) {
5243
5244
  case "pendingMutations":
5244
5245
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -5246,7 +5247,7 @@ function Ju(t, e) {
5246
5247
  return e;
5247
5248
  }
5248
5249
  }
5249
- function Zu(t, e) {
5250
+ function Xu(t, e) {
5250
5251
  switch (t) {
5251
5252
  case "pendingMutations":
5252
5253
  return [...e.entries()];
@@ -5254,7 +5255,7 @@ function Zu(t, e) {
5254
5255
  return e;
5255
5256
  }
5256
5257
  }
5257
- function Xu(t, e, n) {
5258
+ function ea(t, e, n) {
5258
5259
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
5259
5260
  return r && !i && n && (n.result = r), n || e;
5260
5261
  }
@@ -5264,7 +5265,7 @@ function br(t) {
5264
5265
  return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
5265
5266
  });
5266
5267
  }
5267
- class ea {
5268
+ class ta {
5268
5269
  constructor(e, n = Jr, r = Zr, i, s) {
5269
5270
  var o, u, a;
5270
5271
  if (this._isOnline = !0, this._isShutdown = !1, this.status = oe.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) => {
@@ -5297,9 +5298,9 @@ class ea {
5297
5298
  }, this.notifyQueryError = (c, d) => {
5298
5299
  (this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
5299
5300
  }, this.pushTx = (c) => {
5300
- this.config.disableValidation || $u(c, this.config.schema);
5301
+ this.config.disableValidation || Du(c, this.config.schema);
5301
5302
  try {
5302
- const d = nu({
5303
+ const d = ru({
5303
5304
  attrsStore: this.optimisticAttrs(),
5304
5305
  schema: this.config.schema,
5305
5306
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -5388,7 +5389,7 @@ class ea {
5388
5389
  return;
5389
5390
  }
5390
5391
  this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
5391
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Bu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Vu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Wu, this._log = Au(e.verbose || dn || Xr, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": ni }), this.config.schema && (this._linkIndex = ir(this.config.schema)), !!Qu()) {
5392
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Gu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Wu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Bu, this._log = Eu(e.verbose || dn || Xr, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": ni }), this.config.schema && (this._linkIndex = ir(this.config.schema)), !!Hu()) {
5392
5393
  if (!e.appId)
5393
5394
  throw new Error("Instant must be initialized with an appId.");
5394
5395
  if (!Ee(e.appId))
@@ -5403,7 +5404,7 @@ class ea {
5403
5404
  } catch (f) {
5404
5405
  this._log.error("[error] handle broadcast channel", f);
5405
5406
  }
5406
- }))), this._initStorage(n), this._syncTable = new qu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5407
+ }))), this._initStorage(n), this._syncTable = new zu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5407
5408
  useDateObjects: this.config.useDateObjects
5408
5409
  }, this._log, (c) => at(this.ensureAttrs(), c, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((c) => {
5409
5410
  this._isOnline = c, this._startSocket(), r.listen((d) => {
@@ -5433,9 +5434,9 @@ class ea {
5433
5434
  _initStorage(e) {
5434
5435
  this.querySubs = new Qt({
5435
5436
  persister: new e(this.config.appId, "querySubs"),
5436
- merge: Xu,
5437
- serialize: Yu,
5438
- parse: (n, r) => Hu(r, this.config.useDateObjects),
5437
+ merge: ea,
5438
+ serialize: Ju,
5439
+ parse: (n, r) => Yu(r, this.config.useDateObjects),
5439
5440
  // objectSize
5440
5441
  objectSize: (n) => {
5441
5442
  var r, i, s, o;
@@ -5454,8 +5455,8 @@ class ea {
5454
5455
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Qt({
5455
5456
  persister: new e(this.config.appId, "kv"),
5456
5457
  merge: this._onMergeKv,
5457
- serialize: Zu,
5458
- parse: Ju,
5458
+ serialize: Xu,
5459
+ parse: Zu,
5459
5460
  objectSize: () => 0,
5460
5461
  logger: this._log,
5461
5462
  saveThrottleMs: 100,
@@ -5768,7 +5769,7 @@ class ea {
5768
5769
  if (!this.querySubs)
5769
5770
  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;
5770
5771
  const s = q(e), o = this._startQuerySub(e, s);
5771
- 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")), zu), i.promise;
5772
+ 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")), Vu), i.promise;
5772
5773
  }
5773
5774
  _completeQueryOnce(e, n, r) {
5774
5775
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5835,7 +5836,7 @@ class ea {
5835
5836
  u = !0;
5836
5837
  continue;
5837
5838
  }
5838
- const b = u ? Po(o, p) : p;
5839
+ const b = u ? Mo(o, p) : p;
5839
5840
  l.push(b);
5840
5841
  }
5841
5842
  return u ? l : d;
@@ -6001,7 +6002,7 @@ class ea {
6001
6002
  return;
6002
6003
  }
6003
6004
  const e = this._transport;
6004
- this._transport = Gu({
6005
+ this._transport = Qu({
6005
6006
  transportType: this._transportType,
6006
6007
  appId: this.config.appId,
6007
6008
  apiURI: this.config.apiURI,
@@ -6204,7 +6205,7 @@ class ea {
6204
6205
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
6205
6206
  }
6206
6207
  sendMagicCode({ email: e }) {
6207
- return lu({
6208
+ return hu({
6208
6209
  apiURI: this.config.apiURI,
6209
6210
  appId: this.config.appId,
6210
6211
  email: e
@@ -6213,7 +6214,7 @@ class ea {
6213
6214
  signInWithMagicCode(e) {
6214
6215
  return L(this, arguments, void 0, function* ({ email: n, code: r }) {
6215
6216
  var i;
6216
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield hu({
6217
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield pu({
6217
6218
  apiURI: this.config.apiURI,
6218
6219
  appId: this.config.appId,
6219
6220
  email: n,
@@ -6225,7 +6226,7 @@ class ea {
6225
6226
  }
6226
6227
  signInWithCustomToken(e) {
6227
6228
  return L(this, void 0, void 0, function* () {
6228
- const n = yield pu({
6229
+ const n = yield yu({
6229
6230
  apiURI: this.config.apiURI,
6230
6231
  appId: this.config.appId,
6231
6232
  refreshToken: e
@@ -6235,7 +6236,7 @@ class ea {
6235
6236
  }
6236
6237
  signInAsGuest() {
6237
6238
  return L(this, void 0, void 0, function* () {
6238
- const e = yield yu({
6239
+ const e = yield bu({
6239
6240
  apiURI: this.config.apiURI,
6240
6241
  appId: this.config.appId
6241
6242
  });
@@ -6251,7 +6252,7 @@ class ea {
6251
6252
  this._log.info("[auth-invalidate] skipped invalidateToken");
6252
6253
  return;
6253
6254
  }
6254
- _u({
6255
+ gu({
6255
6256
  apiURI: this.config.apiURI,
6256
6257
  appId: this.config.appId,
6257
6258
  refreshToken: i
@@ -6309,7 +6310,7 @@ class ea {
6309
6310
  signInWithIdToken(e) {
6310
6311
  return L(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
6311
6312
  var s;
6312
- const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield bu({
6313
+ const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield _u({
6313
6314
  apiURI: this.config.apiURI,
6314
6315
  appId: this.config.appId,
6315
6316
  idToken: n,
@@ -6350,7 +6351,7 @@ class ea {
6350
6351
  // TODO: look into typing again
6351
6352
  getPresence(e, n, r = {}) {
6352
6353
  const i = this._rooms[n], s = this._presence[n];
6353
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Su(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
6354
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Ou(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
6354
6355
  }
6355
6356
  // TODO: look into typing again
6356
6357
  publishPresence(e, n, r) {
@@ -6400,7 +6401,7 @@ class ea {
6400
6401
  }
6401
6402
  _notifyPresenceSub(e, n) {
6402
6403
  const r = this.getPresence("", e, n);
6403
- r && (n.prev && !Ou(r, n.prev) || (n.prev = r, n.cb(r)));
6404
+ r && (n.prev && !Au(r, n.prev) || (n.prev = r, n.cb(r)));
6404
6405
  }
6405
6406
  _patchPresencePeers(e, n) {
6406
6407
  var r, i, s;
@@ -6474,14 +6475,14 @@ class ea {
6474
6475
  return L(this, void 0, void 0, function* () {
6475
6476
  var i;
6476
6477
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
6477
- return gu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
6478
+ return Tu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
6478
6479
  });
6479
6480
  }
6480
6481
  deleteFile(e) {
6481
6482
  return L(this, void 0, void 0, function* () {
6482
6483
  var n;
6483
6484
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
6484
- return yield Tu({
6485
+ return yield wu({
6485
6486
  apiURI: this.config.apiURI,
6486
6487
  appId: this.config.appId,
6487
6488
  path: e,
@@ -6494,20 +6495,20 @@ class ea {
6494
6495
  upload(e, n) {
6495
6496
  return L(this, void 0, void 0, function* () {
6496
6497
  var r;
6497
- 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 wu({
6498
+ 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 mu({
6498
6499
  apiURI: this.config.apiURI,
6499
6500
  appId: this.config.appId,
6500
6501
  fileName: o,
6501
6502
  refreshToken: s
6502
6503
  });
6503
- return yield mu(u, n);
6504
+ return yield vu(u, n);
6504
6505
  });
6505
6506
  }
6506
6507
  getDownloadUrl(e) {
6507
6508
  return L(this, void 0, void 0, function* () {
6508
6509
  var n;
6509
6510
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
6510
- return yield vu({
6511
+ return yield Su({
6511
6512
  apiURI: this.config.apiURI,
6512
6513
  appId: this.config.appId,
6513
6514
  path: e,
@@ -6517,9 +6518,9 @@ class ea {
6517
6518
  }
6518
6519
  }
6519
6520
  let it;
6520
- function ta(t, e) {
6521
+ function na(t, e) {
6521
6522
  it == null || it.dispose();
6522
- const n = ua(e), r = ia(e, u), i = ra(na(t));
6523
+ const n = aa(e), r = sa(e, u), i = ia(ra(t));
6523
6524
  function s(d) {
6524
6525
  var f;
6525
6526
  d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
@@ -6541,10 +6542,10 @@ function ta(t, e) {
6541
6542
  }
6542
6543
  return c();
6543
6544
  }
6544
- function na(t) {
6545
+ function ra(t) {
6545
6546
  return `${dn || ei ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6546
6547
  }
6547
- function ra(t) {
6548
+ function ia(t) {
6548
6549
  const e = document.createElement("iframe");
6549
6550
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6550
6551
  width: "100%",
@@ -6553,7 +6554,7 @@ function ra(t) {
6553
6554
  border: "none"
6554
6555
  }), { element: e };
6555
6556
  }
6556
- function ia(t, e) {
6557
+ function sa(t, e) {
6557
6558
  const n = `
6558
6559
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6559
6560
  <rect width="512" height="512" fill="black"/>
@@ -6563,7 +6564,7 @@ function ia(t, e) {
6563
6564
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6564
6565
  // pos
6565
6566
  position: "fixed"
6566
- }, sa(t.position)), {
6567
+ }, oa(t.position)), {
6567
6568
  height: "32px",
6568
6569
  width: "32px",
6569
6570
  // layout
@@ -6578,7 +6579,7 @@ function ia(t, e) {
6578
6579
  cursor: "pointer"
6579
6580
  })), r.addEventListener("click", e), { element: r };
6580
6581
  }
6581
- function sa(t) {
6582
+ function oa(t) {
6582
6583
  switch (t) {
6583
6584
  case "bottom-left":
6584
6585
  return { bottom: "24px", left: "24px" };
@@ -6590,7 +6591,7 @@ function sa(t) {
6590
6591
  return { top: "24px", left: "24px" };
6591
6592
  }
6592
6593
  }
6593
- function oa(t) {
6594
+ function ua(t) {
6594
6595
  switch (t) {
6595
6596
  case "bottom-left":
6596
6597
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6602,23 +6603,23 @@ function oa(t) {
6602
6603
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6603
6604
  }
6604
6605
  }
6605
- function ua(t) {
6606
+ function aa(t) {
6606
6607
  const e = document.createElement("div");
6607
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, oa(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";
6608
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, ua(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";
6608
6609
  function n() {
6609
6610
  return e.style.display !== "none";
6610
6611
  }
6611
6612
  return { element: e, isVisible: n };
6612
6613
  }
6613
- const aa = {
6614
+ const ca = {
6614
6615
  apiURI: "https://api.instantdb.com",
6615
6616
  websocketURI: "wss://api.instantdb.com/runtime/session"
6616
6617
  };
6617
- function ca() {
6618
+ function da() {
6618
6619
  var t;
6619
6620
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6620
6621
  }
6621
- function da() {
6622
+ function fa() {
6622
6623
  var t;
6623
6624
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
6624
6625
  }
@@ -6626,23 +6627,23 @@ function Ht(t) {
6626
6627
  const e = t.__adminToken;
6627
6628
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6628
6629
  }
6629
- const Yt = da(), _r = ca();
6630
- class fa {
6630
+ const Yt = fa(), _r = da();
6631
+ class la {
6631
6632
  constructor(e) {
6632
6633
  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);
6633
6634
  }
6634
6635
  }
6635
- class la {
6636
+ class ha {
6636
6637
  constructor(e) {
6637
6638
  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);
6638
6639
  }
6639
6640
  }
6640
- function ha(t) {
6641
+ function pa(t) {
6641
6642
  return JSON.parse(JSON.stringify(t));
6642
6643
  }
6643
- class pa {
6644
+ class ya {
6644
6645
  constructor(e) {
6645
- this.tx = cn(), this._reactor = e, this.auth = new fa(this._reactor), this.storage = new la(this._reactor);
6646
+ this.tx = cn(), this._reactor = e, this.auth = new la(this._reactor), this.storage = new ha(this._reactor);
6646
6647
  }
6647
6648
  /**
6648
6649
  * Use this to write data! You can create, update, delete, and link objects
@@ -6825,24 +6826,24 @@ function gr(t) {
6825
6826
  const n = q(t);
6826
6827
  return _r.set(t, n), n;
6827
6828
  }
6828
- function ya(t, e) {
6829
+ function ba(t, e) {
6829
6830
  return gr(t._reactor.config.schema) !== gr(e);
6830
6831
  }
6831
- function ba(t, e, n, r, i) {
6832
+ function _a(t, e, n, r, i) {
6832
6833
  var s;
6833
6834
  const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = Yt[Ht(o)];
6834
6835
  if (u)
6835
- return ya(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6836
- const a = new ea(Object.assign(Object.assign(Object.assign({}, aa), o), { cardinalityInference: !!o.schema }), e || Jr, n || Zr, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": ni }), i), c = new pa(a);
6837
- return Yt[Ht(o)] = c, _a(o.appId, o.devtool), c;
6836
+ return ba(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6837
+ const a = new ta(Object.assign(Object.assign(Object.assign({}, ca), o), { cardinalityInference: !!o.schema }), e || Jr, n || Zr, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": ni }), i), c = new ya(a);
6838
+ return Yt[Ht(o)] = c, ga(o.appId, o.devtool), c;
6838
6839
  }
6839
- function _a(t, e) {
6840
+ function ga(t, e) {
6840
6841
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6841
6842
  return;
6842
6843
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6843
- n.allowedHosts.includes(window.location.hostname) && ta(t, n);
6844
+ n.allowedHosts.includes(window.location.hostname) && na(t, n);
6844
6845
  }
6845
- const ga = {
6846
+ const Ta = {
6846
6847
  isLoading: !0,
6847
6848
  data: void 0,
6848
6849
  pageInfo: void 0,
@@ -6857,9 +6858,9 @@ function Tr(t) {
6857
6858
  ...t || {}
6858
6859
  };
6859
6860
  }
6860
- function Ta(t, e, n) {
6861
+ function wa(t, e, n) {
6861
6862
  e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
6862
- const r = e ? ha(e) : null, i = q(r), s = qe(
6863
+ const r = e ? pa(e) : null, i = q(r), s = qe(
6863
6864
  Tr(t._reactor.getPreviousResult(r))
6864
6865
  ), o = fe(
6865
6866
  (a) => (s.current = Tr(
@@ -6883,10 +6884,10 @@ function Ta(t, e, n) {
6883
6884
  return { state: Pt(
6884
6885
  o,
6885
6886
  () => s.current,
6886
- () => ga
6887
+ () => Ta
6887
6888
  ), query: r };
6888
6889
  }
6889
- function wa() {
6890
+ function ma() {
6890
6891
  const t = qe(null);
6891
6892
  ge(() => {
6892
6893
  n();
@@ -6899,8 +6900,8 @@ function wa() {
6899
6900
  }
6900
6901
  return { set: e, clear: n };
6901
6902
  }
6902
- const ma = 1e3;
6903
- function va(t, e, n) {
6903
+ const va = 1e3;
6904
+ function Sa(t, e, n) {
6904
6905
  const r = qe(n);
6905
6906
  r.current = n, ge(() => t.core._reactor.subscribeTopic(
6906
6907
  t.id,
@@ -6910,7 +6911,7 @@ function va(t, e, n) {
6910
6911
  }
6911
6912
  ), [t.id, e]);
6912
6913
  }
6913
- function Sa(t, e) {
6914
+ function Oa(t, e) {
6914
6915
  return ge(() => t.core._reactor.joinRoom(t.id), [t.id]), fe(
6915
6916
  (r) => {
6916
6917
  t.core._reactor.publishTopic({
@@ -6923,7 +6924,7 @@ function Sa(t, e) {
6923
6924
  [t.id, e]
6924
6925
  );
6925
6926
  }
6926
- function Oa(t, e = {}) {
6927
+ function Aa(t, e = {}) {
6927
6928
  var o, u;
6928
6929
  const [n, r] = mr(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
6929
6930
  peers: {},
@@ -6948,11 +6949,11 @@ function Oa(t, e = {}) {
6948
6949
  publishPresence: i
6949
6950
  }), [n, i]);
6950
6951
  }
6951
- function Aa(t, e, n) {
6952
+ function Ea(t, e, n) {
6952
6953
  ge(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ge(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6953
6954
  }
6954
- function Ea(t, e, n = {}) {
6955
- const r = wa(), i = ye.usePresence(t, {
6955
+ function ka(t, e, n = {}) {
6956
+ const r = ma(), i = ye.usePresence(t, {
6956
6957
  keys: [e]
6957
6958
  }), s = Mt(() => {
6958
6959
  const d = t._core._reactor.getPresence(
@@ -6966,7 +6967,7 @@ function Ea(t, e, n = {}) {
6966
6967
  (d) => {
6967
6968
  t.core._reactor.publishPresence(t.type, t.id, {
6968
6969
  [e]: d
6969
- }), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? ma, () => {
6970
+ }), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? va, () => {
6970
6971
  t.core._reactor.publishPresence(t.type, t.id, {
6971
6972
  [e]: null
6972
6973
  });
@@ -6989,25 +6990,25 @@ function Ea(t, e, n = {}) {
6989
6990
  };
6990
6991
  }
6991
6992
  const ye = {
6992
- useTopicEffect: va,
6993
- usePublishTopic: Sa,
6994
- usePresence: Oa,
6995
- useSyncPresence: Aa,
6996
- useTypingIndicator: Ea
6993
+ useTopicEffect: Sa,
6994
+ usePublishTopic: Oa,
6995
+ usePresence: Aa,
6996
+ useSyncPresence: Ea,
6997
+ useTypingIndicator: ka
6997
6998
  };
6998
- class ka {
6999
+ class ja {
6999
7000
  constructor(e, n, r) {
7000
7001
  this.useTopicEffect = (i, s) => {
7001
7002
  ye.useTopicEffect(this, i, s);
7002
7003
  }, this.usePublishTopic = (i) => ye.usePublishTopic(this, i), this.usePresence = (i = {}) => ye.usePresence(this, i), this.useSyncPresence = (i, s) => ye.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => ye.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
7003
7004
  }
7004
7005
  }
7005
- const ja = {
7006
+ const Ca = {
7006
7007
  isLoading: !0,
7007
7008
  user: void 0,
7008
7009
  error: void 0
7009
7010
  };
7010
- class Ia {
7011
+ class Pa {
7011
7012
  constructor(e, n) {
7012
7013
  this.tx = cn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
7013
7014
  const [i, s] = mr(null);
@@ -7017,7 +7018,7 @@ class Ia {
7017
7018
  s(u);
7018
7019
  })();
7019
7020
  }, [r]), i;
7020
- }, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => Ta(this.core, r, i).state, this.useAuth = () => {
7021
+ }, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => wa(this.core, r, i).state, this.useAuth = () => {
7021
7022
  const r = qe(
7022
7023
  this.core._reactor._currentUserCached
7023
7024
  ), i = fe((o) => this.core.subscribeAuth((a) => {
@@ -7026,7 +7027,7 @@ class Ia {
7026
7027
  return Pt(
7027
7028
  i,
7028
7029
  () => r.current,
7029
- () => ja
7030
+ () => Ca
7030
7031
  );
7031
7032
  }, this.useUser = () => {
7032
7033
  const { user: r } = this.useAuth();
@@ -7053,7 +7054,7 @@ class Ia {
7053
7054
  }, this.SignedOut = ({ children: r }) => {
7054
7055
  const i = this.useAuth();
7055
7056
  return i.isLoading || i.error || i.user ? null : /* @__PURE__ */ et.jsx(et.Fragment, { children: r });
7056
- }, this.core = ba(
7057
+ }, this.core = _a(
7057
7058
  e,
7058
7059
  // @ts-expect-error because TS can't resolve subclass statics
7059
7060
  this.constructor.Storage,
@@ -7077,7 +7078,7 @@ class Ia {
7077
7078
  * const { peers } = db.rooms.usePresence(room);
7078
7079
  */
7079
7080
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7080
- return new ka(this.core, e, n);
7081
+ return new ja(this.core, e, n);
7081
7082
  }
7082
7083
  /**
7083
7084
  * One time query for the logged in state. This is useful
@@ -7094,5 +7095,5 @@ class Ia {
7094
7095
  }
7095
7096
  }
7096
7097
  export {
7097
- Ia as InstantReactAbstractDatabase
7098
+ Pa as InstantReactAbstractDatabase
7098
7099
  };