@instantdb/react-common 0.22.133 → 0.22.134-experimental.better-error.21950490460.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.
@@ -2554,9 +2554,9 @@ function Bi() {
2554
2554
  return t;
2555
2555
  }
2556
2556
  const Gi = Bi();
2557
- let Hi = 0;
2557
+ let Hi = !0, Ji = 0;
2558
2558
  function Fe(t) {
2559
- return dt(`_${t}`, Hi++);
2559
+ return dt(`_${t}`, Ji++);
2560
2560
  }
2561
2561
  function dt(t, e) {
2562
2562
  return `?${t}-${e}`;
@@ -2566,24 +2566,24 @@ class Ee extends Error {
2566
2566
  super(e), this.name = "AttrNotFoundError";
2567
2567
  }
2568
2568
  }
2569
- function Ji(t, e) {
2569
+ function Yi(t, e) {
2570
2570
  const n = Ur(t, e);
2571
2571
  if (!n)
2572
2572
  throw new Ee(`Could not find id attr for ${e}`);
2573
2573
  return n;
2574
2574
  }
2575
2575
  function Qn(t, e, n, r) {
2576
- return [Yi(t, e, n, r)];
2576
+ return [Zi(t, e, n, r)];
2577
2577
  }
2578
- function Yi(t, e, n, r) {
2578
+ function Zi(t, e, n, r) {
2579
2579
  return [
2580
2580
  t(n, r),
2581
- Ji(e, n).id,
2581
+ Yi(e, n).id,
2582
2582
  t(n, r),
2583
2583
  t("time", r)
2584
2584
  ];
2585
2585
  }
2586
- function Zi(t, e, n) {
2586
+ function Xi(t, e, n) {
2587
2587
  return t.map((r) => r === e ? n : r);
2588
2588
  }
2589
2589
  function Fr(t, e, n, r, s) {
@@ -2615,7 +2615,7 @@ function Bn(t, e) {
2615
2615
  return typeof o != "string" ? !1 : s.test(o);
2616
2616
  };
2617
2617
  }
2618
- function Xi(t, e) {
2618
+ function eo(t, e) {
2619
2619
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2620
2620
  return e;
2621
2621
  const n = t["checked-data-type"] === "date";
@@ -2675,7 +2675,7 @@ function Xi(t, e) {
2675
2675
  }
2676
2676
  return e;
2677
2677
  }
2678
- function eo(t, e, n, r, s, i) {
2678
+ function to(t, e, n, r, s, i) {
2679
2679
  const o = U(e, n, s), a = we(e, n, s), c = o || a;
2680
2680
  if (!c)
2681
2681
  throw new Ee(`No attr for etype = ${n} label = ${s}`);
@@ -2693,11 +2693,11 @@ function eo(t, e, n, r, s, i) {
2693
2693
  return o ? [
2694
2694
  t(n, r),
2695
2695
  c.id,
2696
- Xi(c, i),
2696
+ eo(c, i),
2697
2697
  Fe("time")
2698
2698
  ] : [i, c.id, t(n, r), Fe("time")];
2699
2699
  }
2700
- function to(t, e, n, r, s) {
2700
+ function no(t, e, n, r, s) {
2701
2701
  const [i, o, a] = s.reduce((c, u) => {
2702
2702
  const [l, d, h] = c, [y, b, g] = Fr(t, e, l, d, u);
2703
2703
  return [y, b, [...h, g]];
@@ -2705,19 +2705,19 @@ function to(t, e, n, r, s) {
2705
2705
  return [i, o, a];
2706
2706
  }
2707
2707
  function zt(t, e, n, r, s, i) {
2708
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = to(t, e, n, r, o), d = eo(t, e, c, u, a, i);
2708
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = no(t, e, n, r, o), d = to(t, e, c, u, a, i);
2709
2709
  return l.concat([d]);
2710
2710
  }
2711
- function no(t, e) {
2711
+ function ro(t, e) {
2712
2712
  return e ? [e].concat(t) : t;
2713
2713
  }
2714
- function ro([t, e]) {
2714
+ function so([t, e]) {
2715
2715
  return t === "or" && Array.isArray(e);
2716
2716
  }
2717
- function so([t, e]) {
2717
+ function io([t, e]) {
2718
2718
  return t === "and" && Array.isArray(e);
2719
2719
  }
2720
- function io(t, e, n) {
2720
+ function oo(t, e, n) {
2721
2721
  return (r, s) => {
2722
2722
  const i = t(r, s);
2723
2723
  return e == i ? i : `${i}-${n}`;
@@ -2725,27 +2725,27 @@ function io(t, e, n) {
2725
2725
  }
2726
2726
  function Gn(t, e, n, r, s, i) {
2727
2727
  const o = t(r, s), a = i.map((c, u) => {
2728
- const l = io(t, o, u);
2728
+ const l = oo(t, o, u);
2729
2729
  return Nr(l, n, r, s, c);
2730
2730
  });
2731
2731
  return { [e]: { patterns: a, joinSym: o } };
2732
2732
  }
2733
- function oo(t) {
2733
+ function ao(t) {
2734
2734
  const e = [];
2735
2735
  for (let n = 1; n <= t.length; n++)
2736
2736
  e.push(t.slice(0, n));
2737
2737
  return e;
2738
2738
  }
2739
2739
  function Hn(t, e, n, r, s) {
2740
- return oo(s).map((i) => zt(t, e, n, r, i, {
2740
+ return ao(s).map((i) => zt(t, e, n, r, i, {
2741
2741
  $isNull: !0
2742
2742
  }));
2743
2743
  }
2744
2744
  function Nr(t, e, n, r, s) {
2745
2745
  return Object.entries(s).flatMap(([i, o]) => {
2746
- if (ro([i, o]))
2747
- return Gn(t, "or", e, n, r, o);
2748
2746
  if (so([i, o]))
2747
+ return Gn(t, "or", e, n, r, o);
2748
+ if (io([i, o]))
2749
2749
  return Gn(t, "and", e, n, r, o);
2750
2750
  if (i === "$entityIdStartsWith")
2751
2751
  return [];
@@ -2771,25 +2771,25 @@ function Nr(t, e, n, r, s) {
2771
2771
  ] : zt(t, e, n, r, a, o);
2772
2772
  });
2773
2773
  }
2774
- function ao(t, e, n, r) {
2774
+ function co(t, e, n, r) {
2775
2775
  const s = dt;
2776
2776
  return r ? Nr(s, t, e, n, r).concat(Qn(s, t, e, n)) : Qn(s, t, e, n);
2777
2777
  }
2778
- function co(t, e, n) {
2778
+ function uo(t, e, n) {
2779
2779
  return [t(e, n), t("time", n)];
2780
2780
  }
2781
- function uo(t, e, n, r, s, i) {
2782
- const [o, a, c, u, l] = Fr(t, e, n, r, s), d = Zi(c, t(n, r), i);
2781
+ function lo(t, e, n, r, s, i) {
2782
+ const [o, a, c, u, l] = Fr(t, e, n, r, s), d = Xi(c, t(n, r), i);
2783
2783
  return [o, a, d, u, l];
2784
2784
  }
2785
- function lo(t, e, n, { etype: r, level: s, form: i }, o) {
2785
+ function fo(t, e, n, { etype: r, level: s, form: i }, o) {
2786
2786
  const a = Object.keys(i).filter((c) => c !== "$");
2787
2787
  return a.length ? Object.entries(o).map(function([u, l]) {
2788
2788
  return a.map(function(y) {
2789
2789
  var g, w, m;
2790
2790
  const b = !!(e.cardinalityInference && ((m = (w = (g = n.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : w[y]) != null && m.isSingular));
2791
2791
  try {
2792
- const [T, S, C] = uo(t, n, r, s, y, u), A = qr(e, n, {
2792
+ const [T, S, C] = lo(t, n, r, s, y, u), A = qr(e, n, {
2793
2793
  etype: T,
2794
2794
  level: S,
2795
2795
  form: i[y],
@@ -2806,11 +2806,11 @@ function lo(t, e, n, { etype: r, level: s, form: i }, o) {
2806
2806
  }, l);
2807
2807
  }) : Object.values(o);
2808
2808
  }
2809
- function fo(t, e, n) {
2809
+ function ho(t, e, n) {
2810
2810
  return n === "string" ? Gi(t, e) : t > e ? 1 : -1;
2811
2811
  }
2812
2812
  function Ue(t, e, n, r, s) {
2813
- return e === r || e == null && r == null ? Wi(t, n) : r == null ? 1 : e == null ? -1 : fo(e, r, s);
2813
+ return e === r || e == null && r == null ? Wi(t, n) : r == null ? 1 : e == null ? -1 : ho(e, r, s);
2814
2814
  }
2815
2815
  function ut([t, e], [n, r], s) {
2816
2816
  return Ue(t, e, n, r, s);
@@ -2818,7 +2818,7 @@ function ut([t, e], [n, r], s) {
2818
2818
  function Vt(t) {
2819
2819
  return t == null ? t : new Date(t).getTime();
2820
2820
  }
2821
- function ho(t, e, n, r) {
2821
+ function po(t, e, n, r) {
2822
2822
  var b;
2823
2823
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2824
2824
  if (((b = e["forward-identity"]) == null ? void 0 : b[2]) === "id")
@@ -2826,21 +2826,21 @@ function ho(t, e, n, r) {
2826
2826
  const [u, l] = r, d = e["checked-data-type"], h = d === "date" ? Vt(l) : l, y = d === "date" ? Vt(o) : o;
2827
2827
  return ut([u, h], [s, y], d) === c;
2828
2828
  }
2829
- function po(t, e) {
2829
+ function yo(t, e) {
2830
2830
  const n = e[1];
2831
2831
  return t.getAttr(n);
2832
2832
  }
2833
- function yo(t, e, n) {
2833
+ function bo(t, e, n) {
2834
2834
  const r = Object.keys(n)[0];
2835
2835
  return U(t, e, r);
2836
2836
  }
2837
- function bo(t, e, n, r) {
2837
+ function _o(t, e, n, r) {
2838
2838
  if (n)
2839
- return po(t, n);
2839
+ return yo(t, n);
2840
2840
  if (r)
2841
- return yo(t, e, r);
2841
+ return bo(t, e, r);
2842
2842
  }
2843
- function _o(t, e, n) {
2843
+ function go(t, e, n) {
2844
2844
  var s, i;
2845
2845
  if (!Array.isArray(n.fields))
2846
2846
  return Oi(t, e);
@@ -2855,11 +2855,11 @@ function _o(t, e, n) {
2855
2855
  }
2856
2856
  return r;
2857
2857
  }
2858
- function go(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2858
+ function To(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2859
2859
  var b, g;
2860
- const o = (b = i == null ? void 0 : i.$) == null ? void 0 : b.order, a = Kr(i), c = To(i);
2860
+ const o = (b = i == null ? void 0 : i.$) == null ? void 0 : b.order, a = Kr(i), c = wo(i);
2861
2861
  let u = xi(t, s);
2862
- const l = r == null ? void 0 : r["start-cursor"], d = bo(e, n, l, o);
2862
+ const l = r == null ? void 0 : r["start-cursor"], d = _o(e, n, l, o);
2863
2863
  if (d && ((g = d == null ? void 0 : d["forward-identity"]) == null ? void 0 : g[2]) !== "id") {
2864
2864
  const w = d["checked-data-type"] === "date", m = d.id;
2865
2865
  u = u.map(([T]) => {
@@ -2874,17 +2874,17 @@ function go(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2874
2874
  return ut(T, m, d == null ? void 0 : d["checked-data-type"]);
2875
2875
  });
2876
2876
  let h = {};
2877
- const y = _o(e, n, s);
2877
+ const y = go(e, n, s);
2878
2878
  for (const w of u) {
2879
2879
  const [m] = w;
2880
- if (h[m] || !a && l && d && ho(l, d, c, w))
2880
+ if (h[m] || !a && l && d && po(l, d, c, w))
2881
2881
  continue;
2882
2882
  const T = Ai(t, y, m);
2883
2883
  T && (h[m] = T);
2884
2884
  }
2885
2885
  return h;
2886
2886
  }
2887
- function To(t) {
2887
+ function wo(t) {
2888
2888
  var n;
2889
2889
  const e = (n = t.$) == null ? void 0 : n.order;
2890
2890
  return e && e[Object.keys(e)[0]] || "asc";
@@ -2894,26 +2894,26 @@ function Kr(t) {
2894
2894
  const e = (s = t.$) == null ? void 0 : s.offset, n = (i = t.$) == null ? void 0 : i.before, r = (o = t.$) == null ? void 0 : o.after;
2895
2895
  return !e && !n && !r;
2896
2896
  }
2897
- function wo(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2897
+ function mo(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2898
2898
  var h, y, b, g, w;
2899
2899
  if (!Kr(s) && (!o || !o["start-cursor"]))
2900
2900
  return [];
2901
- const a = no(ao(e, n, r, (h = s.$) == null ? void 0 : h.where), i), c = co(dt, n, r), u = (y = s.$) == null ? void 0 : y.fields, l = go(t, e, {
2901
+ const a = ro(co(e, n, r, (h = s.$) == null ? void 0 : h.where), i), c = uo(dt, n, r), u = (y = s.$) == null ? void 0 : y.fields, l = To(t, e, {
2902
2902
  etype: n,
2903
2903
  pageInfo: o,
2904
2904
  form: s,
2905
2905
  dq: { where: a, find: c, fields: u }
2906
2906
  }), d = ((b = s.$) == null ? void 0 : b.limit) || ((g = s.$) == null ? void 0 : g.first) || ((w = s.$) == null ? void 0 : w.last);
2907
2907
  if (d != null) {
2908
- r > 0 && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2908
+ r > 0 && Hi && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2909
2909
  const m = Object.entries(l);
2910
2910
  return m.length <= d ? l : Object.fromEntries(m.slice(0, d));
2911
2911
  }
2912
2912
  return l;
2913
2913
  }
2914
- function mo(t, e, n) {
2914
+ function So(t, e, n) {
2915
2915
  try {
2916
- return wo(t, e, n);
2916
+ return mo(t, e, n);
2917
2917
  } catch (r) {
2918
2918
  if (r instanceof Ee)
2919
2919
  return {};
@@ -2921,10 +2921,10 @@ function mo(t, e, n) {
2921
2921
  }
2922
2922
  }
2923
2923
  function qr(t, e, n) {
2924
- const r = mo(t, e, n);
2925
- return lo(dt, t, e, n, r);
2924
+ const r = So(t, e, n);
2925
+ return fo(dt, t, e, n, r);
2926
2926
  }
2927
- function So(t) {
2927
+ function vo(t) {
2928
2928
  const e = {};
2929
2929
  for (const [n, r] of Object.entries(t))
2930
2930
  e[n] = {
@@ -2944,9 +2944,9 @@ function zr({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, s) {
2944
2944
  pageInfo: n == null ? void 0 : n[u]
2945
2945
  })), c;
2946
2946
  }, {}) };
2947
- return n && (o.pageInfo = So(n)), r && (o.aggregate = r), o;
2947
+ return n && (o.pageInfo = vo(n)), r && (o.aggregate = r), o;
2948
2948
  }
2949
- function vo() {
2949
+ function Ao() {
2950
2950
  const e = {
2951
2951
  __etype: 1,
2952
2952
  __ops: 1,
@@ -2960,7 +2960,7 @@ function vo() {
2960
2960
  };
2961
2961
  return new Set(Object.keys(e));
2962
2962
  }
2963
- const Ao = vo();
2963
+ const Oo = Ao();
2964
2964
  function it(t, e, n) {
2965
2965
  const r = {
2966
2966
  __etype: t,
@@ -2972,7 +2972,7 @@ function it(t, e, n) {
2972
2972
  return n;
2973
2973
  if (i === "__etype")
2974
2974
  return t;
2975
- if (Ao.has(i))
2975
+ if (Oo.has(i))
2976
2976
  return (o, a) => it(t, e, [
2977
2977
  ...n,
2978
2978
  a ? [i, t, e, o, a] : [i, t, e, o]
@@ -2980,7 +2980,7 @@ function it(t, e, n) {
2980
2980
  }
2981
2981
  });
2982
2982
  }
2983
- function Oo(t, e) {
2983
+ function Eo(t, e) {
2984
2984
  return `lookup__${t}__${JSON.stringify(e)}`;
2985
2985
  }
2986
2986
  function lt(t) {
@@ -2990,13 +2990,13 @@ function Wt(t) {
2990
2990
  const [e, n, ...r] = t.split("__");
2991
2991
  return [n, JSON.parse(r.join("__"))];
2992
2992
  }
2993
- function Eo(t) {
2993
+ function ko(t) {
2994
2994
  return new Proxy({
2995
2995
  __etype: t
2996
2996
  }, {
2997
2997
  get(e, n) {
2998
2998
  if (n === "lookup")
2999
- return (s, i) => it(t, Wt(Oo(s, i)), []);
2999
+ return (s, i) => it(t, Wt(Eo(s, i)), []);
3000
3000
  if (n === "__etype")
3001
3001
  return t;
3002
3002
  const r = n;
@@ -3007,15 +3007,15 @@ function Eo(t) {
3007
3007
  function ln() {
3008
3008
  return new Proxy({}, {
3009
3009
  get(t, e) {
3010
- return Eo(e);
3010
+ return ko(e);
3011
3011
  }
3012
3012
  });
3013
3013
  }
3014
3014
  ln();
3015
- function ko(t) {
3015
+ function Po(t) {
3016
3016
  return t.__ops;
3017
3017
  }
3018
- function Po(t, e) {
3018
+ function Co(t, e) {
3019
3019
  const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
3020
3020
  for (const o of e) {
3021
3021
  const a = n[o];
@@ -3034,7 +3034,7 @@ function Po(t, e) {
3034
3034
  }
3035
3035
  return s;
3036
3036
  }
3037
- function Co(t) {
3037
+ function Io(t) {
3038
3038
  if (Array.isArray(t))
3039
3039
  return t;
3040
3040
  const e = Object.entries(t);
@@ -3042,7 +3042,7 @@ function Co(t) {
3042
3042
  throw new Error("lookup must be an object with a single unique attr and value.");
3043
3043
  return e[0];
3044
3044
  }
3045
- function Io(t, e, n) {
3045
+ function Mo(t, e, n) {
3046
3046
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
3047
3047
  // before assuming it's a ref lookup.
3048
3048
  !U(t, e, n);
@@ -3053,8 +3053,8 @@ function Qt(t) {
3053
3053
  throw new Error(`${t} is not a valid lookup attribute.`);
3054
3054
  return e;
3055
3055
  }
3056
- function Mo(t, e, n) {
3057
- if (!Io(t, e, n))
3056
+ function jo(t, e, n) {
3057
+ if (!Mo(t, e, n))
3058
3058
  return U(t, e, n);
3059
3059
  const r = Qt(n), s = U(t, e, r) || we(t, e, r);
3060
3060
  if (s && s["value-type"] !== "ref")
@@ -3062,13 +3062,13 @@ function Mo(t, e, n) {
3062
3062
  return s;
3063
3063
  }
3064
3064
  function Bt(t) {
3065
- return typeof t == "string" && !lt(t) ? null : typeof t == "string" && lt(t) ? Wt(t) : Co(t);
3065
+ return typeof t == "string" && !lt(t) ? null : typeof t == "string" && lt(t) ? Wt(t) : Io(t);
3066
3066
  }
3067
3067
  function G(t, e, n) {
3068
3068
  const r = Bt(n);
3069
3069
  if (r === null)
3070
3070
  return n;
3071
- const [s, i] = r, o = Mo(t, e, s);
3071
+ const [s, i] = r, o = jo(t, e, s);
3072
3072
  if (!o || !o["unique?"])
3073
3073
  throw new Error(`${s} is not a unique attribute.`);
3074
3074
  return [o.id, i];
@@ -3083,7 +3083,7 @@ function Vr(t, e, n, r) {
3083
3083
  s
3084
3084
  ]].concat(r) : r;
3085
3085
  }
3086
- function jo({ attrsStore: t }, [e, n, r]) {
3086
+ function Ro({ attrsStore: t }, [e, n, r]) {
3087
3087
  const s = Object.entries(r).flatMap(([i, o]) => {
3088
3088
  const a = Array.isArray(o) ? o : [o], c = U(t, e, i), u = we(t, e, i);
3089
3089
  return a.map((l) => c ? [
@@ -3104,7 +3104,7 @@ function jo({ attrsStore: t }, [e, n, r]) {
3104
3104
  });
3105
3105
  return Vr(t, e, n, s);
3106
3106
  }
3107
- function Ro({ attrsStore: t }, [e, n, r]) {
3107
+ function $o({ attrsStore: t }, [e, n, r]) {
3108
3108
  const s = Object.entries(r).flatMap(([i, o]) => {
3109
3109
  const a = Array.isArray(o) ? o : [o], c = U(t, e, i), u = we(t, e, i);
3110
3110
  return a.map((l) => c ? [
@@ -3125,7 +3125,7 @@ function Ro({ attrsStore: t }, [e, n, r]) {
3125
3125
  });
3126
3126
  return Vr(t, e, n, s);
3127
3127
  }
3128
- function $o(t, e, n, r) {
3128
+ function Do(t, e, n, r) {
3129
3129
  var s;
3130
3130
  if (Array.isArray(r)) {
3131
3131
  const [i, o] = r;
@@ -3149,16 +3149,16 @@ function $o(t, e, n, r) {
3149
3149
  return !1;
3150
3150
  }
3151
3151
  function Wr({ stores: t, attrsStore: e }, [n, r, s, i]) {
3152
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : $o(t, e, n, r) ? { mode: "update" } : null;
3152
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Do(t, e, n, r) ? { mode: "update" } : null;
3153
3153
  }
3154
- function Do(t, e) {
3154
+ function xo(t, e) {
3155
3155
  const { attrsStore: n } = t, [r, s, i, o] = e, a = on(i), c = G(n, r, s);
3156
3156
  return [["id", c]].concat(Object.entries(a)).map(([l, d]) => {
3157
3157
  const h = U(n, r, l);
3158
3158
  return h["checked-data-type"] === "date" && t.useDateObjects && (d = ft(d)), ["add-triple", c, h.id, d, { mode: "create" }];
3159
3159
  });
3160
3160
  }
3161
- function xo(t, e) {
3161
+ function Uo(t, e) {
3162
3162
  const { attrsStore: n } = t, [r, s, i, o] = e, a = on(i), c = G(n, r, s), u = Wr(t, [r, c, i, o]);
3163
3163
  return [["id", c]].concat(Object.entries(a)).map(([d, h]) => {
3164
3164
  const y = U(n, r, d);
@@ -3171,10 +3171,10 @@ function xo(t, e) {
3171
3171
  ];
3172
3172
  });
3173
3173
  }
3174
- function Uo({ attrsStore: t }, [e, n]) {
3174
+ function Lo({ attrsStore: t }, [e, n]) {
3175
3175
  return [["delete-entity", G(t, e, n), e]];
3176
3176
  }
3177
- function Lo(t, e) {
3177
+ function Fo(t, e) {
3178
3178
  const { attrsStore: n } = t, [r, s, i, o] = e, a = on(i), c = G(n, r, s), u = Wr(t, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
3179
3179
  const b = U(n, r, h);
3180
3180
  return [
@@ -3193,38 +3193,38 @@ function Lo(t, e) {
3193
3193
  ...u ? [u] : []
3194
3194
  ]].concat(l);
3195
3195
  }
3196
- function Fo({ attrsStore: t }, [e, n, r]) {
3196
+ function No({ attrsStore: t }, [e, n, r]) {
3197
3197
  return [["rule-params", G(t, e, n), e, r]];
3198
3198
  }
3199
- function No(t) {
3199
+ function Ko(t) {
3200
3200
  const [e, n, r, s, i] = t;
3201
3201
  if (!s)
3202
3202
  return t;
3203
3203
  const o = { ...s };
3204
3204
  return delete o.id, [e, n, r, o, ...i ? [i] : []];
3205
3205
  }
3206
- function Ko(t, e) {
3207
- const [n, ...r] = No(e);
3206
+ function qo(t, e) {
3207
+ const [n, ...r] = Ko(e);
3208
3208
  switch (n) {
3209
3209
  case "merge":
3210
- return Lo(t, r);
3210
+ return Fo(t, r);
3211
3211
  case "create":
3212
- return Do(t, r);
3213
- case "update":
3214
3212
  return xo(t, r);
3213
+ case "update":
3214
+ return Uo(t, r);
3215
3215
  case "link":
3216
- return jo(t, r);
3217
- case "unlink":
3218
3216
  return Ro(t, r);
3217
+ case "unlink":
3218
+ return $o(t, r);
3219
3219
  case "delete":
3220
- return Uo(t, r);
3220
+ return Lo(t, r);
3221
3221
  case "ruleParams":
3222
- return Fo(t, r);
3222
+ return No(t, r);
3223
3223
  default:
3224
3224
  throw new Error(`unsupported action ${n}`);
3225
3225
  }
3226
3226
  }
3227
- function qo(t) {
3227
+ function zo(t) {
3228
3228
  switch (t) {
3229
3229
  case "string":
3230
3230
  case "date":
@@ -3235,14 +3235,14 @@ function qo(t) {
3235
3235
  return;
3236
3236
  }
3237
3237
  }
3238
- function zo(t, e, n) {
3238
+ function Vo(t, e, n) {
3239
3239
  var a, c;
3240
3240
  const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
3241
3241
  if (n === "id")
3242
3242
  return null;
3243
3243
  if (!r)
3244
3244
  throw new Error(`${e}.${n} does not exist in your schema`);
3245
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = qo(r == null ? void 0 : r.valueType);
3245
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = zo(r == null ? void 0 : r.valueType);
3246
3246
  return {
3247
3247
  "index?": i,
3248
3248
  "unique?": s,
@@ -3250,7 +3250,7 @@ function zo(t, e, n) {
3250
3250
  };
3251
3251
  }
3252
3252
  function Xe(t, e, n, r) {
3253
- const s = t ? zo(t, e, n) : null, i = F(), a = [F(), e, n];
3253
+ const s = t ? Vo(t, e, n) : null, i = F(), a = [F(), e, n];
3254
3254
  return {
3255
3255
  id: i,
3256
3256
  "forward-identity": a,
@@ -3263,11 +3263,11 @@ function Xe(t, e, n, r) {
3263
3263
  ...r || {}
3264
3264
  };
3265
3265
  }
3266
- function Vo(t, e, n) {
3266
+ function Wo(t, e, n) {
3267
3267
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
3268
3268
  }
3269
- function Wo(t, e, n) {
3270
- const r = Vo(t, e, n);
3269
+ function Qo(t, e, n) {
3270
+ const r = Wo(t, e, n);
3271
3271
  if (!r)
3272
3272
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
3273
3273
  const { forward: s, reverse: i } = r;
@@ -3281,7 +3281,7 @@ function Wo(t, e, n) {
3281
3281
  };
3282
3282
  }
3283
3283
  function Jn(t, e, n, r) {
3284
- const s = t ? Wo(t, e, n) : null, i = F(), o = [F(), e, n], a = [F(), n, e];
3284
+ const s = t ? Qo(t, e, n) : null, i = F(), o = [F(), e, n], a = [F(), n, e];
3285
3285
  return {
3286
3286
  id: i,
3287
3287
  // @ts-ignore: ts thinks it's any[]
@@ -3298,7 +3298,7 @@ function Jn(t, e, n, r) {
3298
3298
  ...r || {}
3299
3299
  };
3300
3300
  }
3301
- const Qo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Bo = /* @__PURE__ */ new Set(["link", "unlink"]), Go = /* @__PURE__ */ new Set(["create", "update", "merge"]), Ho = /* @__PURE__ */ new Set([
3301
+ const Bo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Go = /* @__PURE__ */ new Set(["link", "unlink"]), Ho = /* @__PURE__ */ new Set(["create", "update", "merge"]), Jo = /* @__PURE__ */ new Set([
3302
3302
  "link",
3303
3303
  "unlink",
3304
3304
  "create",
@@ -3306,13 +3306,13 @@ const Qo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
3306
3306
  "merge",
3307
3307
  "delete",
3308
3308
  "ruleParams"
3309
- ]), Gt = { "unique?": !0, "index?": !0 }, Jo = {
3309
+ ]), Gt = { "unique?": !0, "index?": !0 }, Yo = {
3310
3310
  ...Gt,
3311
3311
  cardinality: "one"
3312
3312
  };
3313
- function Yo(t) {
3313
+ function Zo(t) {
3314
3314
  const e = [], [n, r, s, i] = t;
3315
- if (!Ho.has(n))
3315
+ if (!Jo.has(n))
3316
3316
  return e;
3317
3317
  const o = Bt(s);
3318
3318
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -3329,7 +3329,7 @@ function Yo(t) {
3329
3329
  }
3330
3330
  return e;
3331
3331
  }
3332
- function Zo({ attrsStore: t, schema: e }, n) {
3332
+ function Xo({ attrsStore: t, schema: e }, n) {
3333
3333
  var h, y;
3334
3334
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
3335
3335
  function o(b, g) {
@@ -3354,10 +3354,10 @@ function Zo({ attrsStore: t, schema: e }, n) {
3354
3354
  }
3355
3355
  function d(b, g) {
3356
3356
  const w = o(b, g), m = a(b, g);
3357
- u(w), u(m), !w && !m && c(Jn(e, b, g, Jo));
3357
+ u(w), u(m), !w && !m && c(Jn(e, b, g, Yo));
3358
3358
  }
3359
3359
  for (const b of n)
3360
- for (const { etype: g, lookupPair: w, linkLabel: m } of Yo(b)) {
3360
+ for (const { etype: g, lookupPair: w, linkLabel: m } of Zo(b)) {
3361
3361
  const T = w[0];
3362
3362
  if (m) {
3363
3363
  d(g, m);
@@ -3379,12 +3379,12 @@ function Zo({ attrsStore: t, schema: e }, n) {
3379
3379
  }
3380
3380
  for (const b of n) {
3381
3381
  const [g, w, m, T] = b;
3382
- if (Qo.has(g)) {
3382
+ if (Bo.has(g)) {
3383
3383
  const S = o(w, "id");
3384
3384
  u(S), S || c(Xe(e, w, "id", { "unique?": !0 }));
3385
3385
  for (const C of Object.keys(T)) {
3386
3386
  const A = o(w, C);
3387
- if (u(A), Go.has(g) && (A || c(Xe(e, w, C, C === "id" ? { "unique?": !0 } : null))), Bo.has(g)) {
3387
+ if (u(A), Ho.has(g) && (A || c(Xe(e, w, C, C === "id" ? { "unique?": !0 } : null))), Go.has(g)) {
3388
3388
  const j = a(w, C);
3389
3389
  !A && !j && c(Jn(e, w, C)), u(j);
3390
3390
  }
@@ -3399,15 +3399,15 @@ function Zo({ attrsStore: t, schema: e }, n) {
3399
3399
  }
3400
3400
  return [t, i];
3401
3401
  }
3402
- function Xo(t, e) {
3403
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => ko(c)), [s, i] = Zo(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Ko(o, c));
3402
+ function ea(t, e) {
3403
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Po(c)), [s, i] = Xo(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => qo(o, c));
3404
3404
  return [...i, ...a];
3405
3405
  }
3406
3406
  function Yn(t, e) {
3407
3407
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
3408
3408
  }
3409
3409
  const Ne = "__meta";
3410
- class ea {
3410
+ class ta {
3411
3411
  constructor(e, n) {
3412
3412
  }
3413
3413
  }
@@ -3651,13 +3651,13 @@ class Ht {
3651
3651
  };
3652
3652
  }
3653
3653
  }
3654
- const ta = 6, na = ["kv", "querySubs", "syncSubs"];
3655
- function ra(t) {
3654
+ const na = 6, ra = ["kv", "querySubs", "syncSubs"];
3655
+ function sa(t) {
3656
3656
  return function(n) {
3657
3657
  console.error("Error in IndexedDB event", { source: t, event: n });
3658
3658
  };
3659
3659
  }
3660
- async function sa(t) {
3660
+ async function ia(t) {
3661
3661
  return new Promise((e) => {
3662
3662
  const n = indexedDB.open(t);
3663
3663
  n.onerror = (r) => {
@@ -3671,7 +3671,7 @@ async function sa(t) {
3671
3671
  };
3672
3672
  });
3673
3673
  }
3674
- async function ia(t, e, n) {
3674
+ async function oa(t, e, n) {
3675
3675
  const r = (
3676
3676
  // Backwards compatibility for older versions where we JSON.stringified before storing
3677
3677
  typeof e == "string" ? JSON.parse(e) : e
@@ -3711,8 +3711,8 @@ async function Zn(t, e, n) {
3711
3711
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3712
3712
  });
3713
3713
  }
3714
- async function oa(t, e) {
3715
- const n = await sa(`instant_${t}_5`);
3714
+ async function aa(t, e) {
3715
+ const n = await ia(`instant_${t}_5`);
3716
3716
  if (!n)
3717
3717
  return;
3718
3718
  const r = await new Promise((l, d) => {
@@ -3735,7 +3735,7 @@ async function oa(t, e) {
3735
3735
  for (const [l, d] of r)
3736
3736
  switch (l) {
3737
3737
  case "querySubs": {
3738
- const h = ia(l, d, o);
3738
+ const h = oa(l, d, o);
3739
3739
  a.push(h);
3740
3740
  break;
3741
3741
  }
@@ -3757,7 +3757,7 @@ async function oa(t, e) {
3757
3757
  });
3758
3758
  }
3759
3759
  const Xn = /* @__PURE__ */ new Map();
3760
- class Qr extends ea {
3760
+ class Qr extends ta {
3761
3761
  constructor(n, r) {
3762
3762
  super(n, r);
3763
3763
  p(this, "dbName");
@@ -3765,7 +3765,7 @@ class Qr extends ea {
3765
3765
  p(this, "_appId");
3766
3766
  p(this, "_prefix");
3767
3767
  p(this, "_dbPromise");
3768
- this.dbName = `instant_${n}_${ta}`, this._storeName = r, this._appId = n, this._dbPromise = this._init();
3768
+ this.dbName = `instant_${n}_${na}`, this._storeName = r, this._appId = n, this._dbPromise = this._init();
3769
3769
  }
3770
3770
  _init() {
3771
3771
  return new Promise((n, r) => {
@@ -3776,8 +3776,8 @@ class Qr extends ea {
3776
3776
  }, i.onsuccess = (o) => {
3777
3777
  const c = o.target.result;
3778
3778
  if (s) {
3779
- const u = oa(this._appId, c).catch((l) => {
3780
- ra("Error upgrading store from version 5 to 6.")(l);
3779
+ const u = aa(this._appId, c).catch((l) => {
3780
+ sa("Error upgrading store from version 5 to 6.")(l);
3781
3781
  });
3782
3782
  Xn.set(this.dbName, u), u.then(() => n(c)).catch(() => n(c));
3783
3783
  } else {
@@ -3791,7 +3791,7 @@ class Qr extends ea {
3791
3791
  }
3792
3792
  _upgradeStore(n) {
3793
3793
  const s = n.target.result;
3794
- for (const i of na)
3794
+ for (const i of ra)
3795
3795
  s.objectStoreNames.contains(i) || s.createObjectStore(i);
3796
3796
  }
3797
3797
  async getItem(n) {
@@ -3901,14 +3901,14 @@ async function ne(t, e) {
3901
3901
  const n = await fetch(t, e), r = await n.json();
3902
3902
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new ht({ status: n.status, body: r }));
3903
3903
  }
3904
- function aa({ apiURI: t, appId: e, email: n }) {
3904
+ function ca({ apiURI: t, appId: e, email: n }) {
3905
3905
  return ne(`${t}/runtime/auth/send_magic_code`, {
3906
3906
  method: "POST",
3907
3907
  headers: { "content-type": "application/json" },
3908
3908
  body: JSON.stringify({ "app-id": e, email: n })
3909
3909
  });
3910
3910
  }
3911
- async function ca({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
3911
+ async function ua({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
3912
3912
  return await ne(`${t}/runtime/auth/verify_magic_code`, {
3913
3913
  method: "POST",
3914
3914
  headers: { "content-type": "application/json" },
@@ -3920,7 +3920,7 @@ async function ca({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
3920
3920
  })
3921
3921
  });
3922
3922
  }
3923
- async function ua({ apiURI: t, appId: e, refreshToken: n }) {
3923
+ async function la({ apiURI: t, appId: e, refreshToken: n }) {
3924
3924
  return await ne(`${t}/runtime/auth/verify_refresh_token`, {
3925
3925
  method: "POST",
3926
3926
  headers: { "content-type": "application/json" },
@@ -3930,7 +3930,7 @@ async function ua({ apiURI: t, appId: e, refreshToken: n }) {
3930
3930
  })
3931
3931
  });
3932
3932
  }
3933
- async function la({ apiURI: t, appId: e }) {
3933
+ async function fa({ apiURI: t, appId: e }) {
3934
3934
  return await ne(`${t}/runtime/auth/sign_in_guest`, {
3935
3935
  method: "POST",
3936
3936
  headers: { "content-type": "application/json" },
@@ -3951,7 +3951,7 @@ async function er({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken:
3951
3951
  })
3952
3952
  });
3953
3953
  }
3954
- async function fa({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, refreshToken: i }) {
3954
+ async function da({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, refreshToken: i }) {
3955
3955
  return await ne(`${t}/runtime/oauth/id_token`, {
3956
3956
  method: "POST",
3957
3957
  headers: { "content-type": "application/json" },
@@ -3964,7 +3964,7 @@ async function fa({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, re
3964
3964
  })
3965
3965
  });
3966
3966
  }
3967
- async function da({ apiURI: t, appId: e, refreshToken: n }) {
3967
+ async function ha({ apiURI: t, appId: e, refreshToken: n }) {
3968
3968
  return await ne(`${t}/runtime/signout`, {
3969
3969
  method: "POST",
3970
3970
  headers: {
@@ -3976,7 +3976,7 @@ async function da({ apiURI: t, appId: e, refreshToken: n }) {
3976
3976
  })
3977
3977
  });
3978
3978
  }
3979
- async function ha({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
3979
+ async function pa({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
3980
3980
  const a = {
3981
3981
  app_id: e,
3982
3982
  path: n,
@@ -3989,7 +3989,7 @@ async function ha({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, cont
3989
3989
  body: r
3990
3990
  });
3991
3991
  }
3992
- async function pa({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3992
+ async function ya({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3993
3993
  const { data: s } = await ne(`${t}/storage/files?app_id=${e}&filename=${encodeURIComponent(n)}`, {
3994
3994
  method: "DELETE",
3995
3995
  headers: {
@@ -3999,7 +3999,7 @@ async function pa({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3999
3999
  });
4000
4000
  return s;
4001
4001
  }
4002
- async function ya({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata: s = {} }) {
4002
+ async function ba({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata: s = {} }) {
4003
4003
  const { data: i } = await ne(`${t}/storage/signed-upload-url`, {
4004
4004
  method: "POST",
4005
4005
  headers: {
@@ -4013,7 +4013,7 @@ async function ya({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata:
4013
4013
  });
4014
4014
  return i;
4015
4015
  }
4016
- async function ba(t, e) {
4016
+ async function _a(t, e) {
4017
4017
  return (await fetch(t, {
4018
4018
  method: "PUT",
4019
4019
  body: e,
@@ -4022,7 +4022,7 @@ async function ba(t, e) {
4022
4022
  }
4023
4023
  })).ok;
4024
4024
  }
4025
- async function _a({ apiURI: t, appId: e, path: n, refreshToken: r }) {
4025
+ async function ga({ apiURI: t, appId: e, path: n, refreshToken: r }) {
4026
4026
  const { data: s } = await ne(`${t}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(n)}`, {
4027
4027
  method: "GET",
4028
4028
  headers: {
@@ -4042,7 +4042,7 @@ function tr(t, e) {
4042
4042
  n[r] = t[r];
4043
4043
  }), n;
4044
4044
  }
4045
- function ga(t, e, n) {
4045
+ function Ta(t, e, n) {
4046
4046
  const r = {
4047
4047
  peers: {}
4048
4048
  };
@@ -4059,7 +4059,7 @@ function ga(t, e, n) {
4059
4059
  }
4060
4060
  return r;
4061
4061
  }
4062
- function Ta(t, e) {
4062
+ function wa(t, e) {
4063
4063
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Nn(t.user, e.user)) || !Or(t.peers, e.peers))
4064
4064
  return !0;
4065
4065
  for (const r of Object.keys(t.peers))
@@ -4110,8 +4110,8 @@ function sr(t) {
4110
4110
  }, e;
4111
4111
  }, {});
4112
4112
  }
4113
- const Yr = "v0.22.133";
4114
- function wa(t, e) {
4113
+ const Yr = "v0.22.134-experimental.better-error.21950490460.1";
4114
+ function ma(t, e) {
4115
4115
  return {
4116
4116
  info: t ? (...n) => console.info(...n, e()) : () => {
4117
4117
  },
@@ -4171,7 +4171,7 @@ const ir = [
4171
4171
  "before",
4172
4172
  "fields",
4173
4173
  "aggregate"
4174
- ], ma = (t) => t.valueType || "unknown", Zr = (t, e, n = !1) => {
4174
+ ], Sa = (t) => t.valueType || "unknown", Zr = (t, e, n = !1) => {
4175
4175
  if (n || t == null)
4176
4176
  return !0;
4177
4177
  switch (e) {
@@ -4186,7 +4186,7 @@ const ir = [
4186
4186
  default:
4187
4187
  return !0;
4188
4188
  }
4189
- }, Sa = (t, e, n, r, s, i, o) => {
4189
+ }, va = (t, e, n, r, s, i, o) => {
4190
4190
  const a = i.valueType === "json", c = (u, l, d) => {
4191
4191
  if (!Zr(d, l, a))
4192
4192
  throw new R(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof d}`, o);
@@ -4219,16 +4219,16 @@ const ir = [
4219
4219
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${s}'`, o);
4220
4220
  }
4221
4221
  }, Ae = (t, e, n, r, s) => {
4222
- const i = ma(n), o = n.valueType === "json";
4222
+ const i = Sa(n), o = n.valueType === "json";
4223
4223
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
4224
4224
  if (o)
4225
4225
  return;
4226
4226
  const c = t;
4227
4227
  for (const [u, l] of Object.entries(c))
4228
- Sa(u, l, i, e, r, n, `${s}.${u}`);
4228
+ va(u, l, i, e, r, n, `${s}.${u}`);
4229
4229
  } else if (!Zr(t, i, o))
4230
4230
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`, s);
4231
- }, va = (t, e, n, r, s) => {
4231
+ }, Aa = (t, e, n, r, s) => {
4232
4232
  const i = t.split(".");
4233
4233
  if (i.length < 2)
4234
4234
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, s);
@@ -4278,7 +4278,7 @@ const ir = [
4278
4278
  continue;
4279
4279
  }
4280
4280
  if (s.includes(".")) {
4281
- va(s, i, e, n, `${r}.${s}`);
4281
+ Aa(s, i, e, n, `${r}.${s}`);
4282
4282
  continue;
4283
4283
  }
4284
4284
  const o = n.entities[e];
@@ -4298,7 +4298,7 @@ const ir = [
4298
4298
  Ae(i, s, u, e, `${r}.${s}`);
4299
4299
  }
4300
4300
  }
4301
- }, Aa = (t, e, n, r, s = 0) => {
4301
+ }, Oa = (t, e, n, r, s = 0) => {
4302
4302
  for (const o of Object.keys(t))
4303
4303
  if (!ir.includes(o))
4304
4304
  throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${ir.join(", ")}. Found: ${o}`, r);
@@ -4337,7 +4337,7 @@ const ir = [
4337
4337
  const a = t[o];
4338
4338
  if (typeof a != "object" || a === null)
4339
4339
  throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
4340
- Aa(a, e, n, `${r}.$`, s);
4340
+ Oa(a, e, n, `${r}.$`, s);
4341
4341
  }
4342
4342
  }, or = (t, e) => {
4343
4343
  if (typeof t != "object" || t === null)
@@ -4364,19 +4364,19 @@ class Z extends Error {
4364
4364
  super(e), this.name = "TransactionValidationError";
4365
4365
  }
4366
4366
  }
4367
- const ts = (t) => t.length > 0 ? t.join(", ") : "none", Oa = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${ts(e)}`), Et = {
4367
+ const ts = (t) => t.length > 0 ? t.join(", ") : "none", Ea = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${ts(e)}`), Et = {
4368
4368
  string: (t) => typeof t == "string",
4369
4369
  number: (t) => typeof t == "number" && !isNaN(t),
4370
4370
  boolean: (t) => typeof t == "boolean",
4371
4371
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4372
4372
  json: () => !0
4373
- }, Ea = (t, e) => {
4373
+ }, ka = (t, e) => {
4374
4374
  var n;
4375
4375
  return t == null ? !0 : ((n = Et[e.valueType]) == null ? void 0 : n.call(Et, t)) ?? !1;
4376
4376
  }, ns = (t, e) => {
4377
4377
  const n = e.entities[t];
4378
4378
  if (!n)
4379
- throw Oa(t, Object.keys(e.entities));
4379
+ throw Ea(t, Object.keys(e.entities));
4380
4380
  return n;
4381
4381
  }, kt = (t, e, n) => {
4382
4382
  const r = ns(t, n);
@@ -4386,7 +4386,7 @@ const ts = (t) => t.length > 0 ? t.join(", ") : "none", Oa = (t, e) => new Z(`En
4386
4386
  if (s === "id")
4387
4387
  continue;
4388
4388
  const o = r.attrs[s];
4389
- if (o && !Ea(i, o))
4389
+ if (o && !ka(i, o))
4390
4390
  throw new Z(`Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`);
4391
4391
  }
4392
4392
  }, cr = (t, e, n) => {
@@ -4407,7 +4407,7 @@ const ts = (t) => t.length > 0 ? t.join(", ") : "none", Oa = (t, e) => new Z(`En
4407
4407
  throw new Z(`Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`);
4408
4408
  }
4409
4409
  }
4410
- }, ka = {
4410
+ }, Pa = {
4411
4411
  create: kt,
4412
4412
  update: kt,
4413
4413
  merge: kt,
@@ -4415,7 +4415,7 @@ const ts = (t) => t.length > 0 ? t.join(", ") : "none", Oa = (t, e) => new Z(`En
4415
4415
  unlink: cr,
4416
4416
  delete: () => {
4417
4417
  }
4418
- }, Pa = (t, e) => {
4418
+ }, Ca = (t, e) => {
4419
4419
  if (!e)
4420
4420
  return;
4421
4421
  const [n, r, s, i] = t;
@@ -4423,9 +4423,9 @@ const ts = (t) => t.length > 0 ? t.join(", ") : "none", Oa = (t, e) => new Z(`En
4423
4423
  throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
4424
4424
  if (typeof r != "string")
4425
4425
  throw new Z(`Entity name must be a string, but received: ${typeof r}`);
4426
- const o = ka[n];
4426
+ const o = Pa[n];
4427
4427
  o && i !== void 0 && o(r, i, e);
4428
- }, Ca = (t, e) => {
4428
+ }, Ia = (t, e) => {
4429
4429
  const n = Array.isArray(t) ? t : [t];
4430
4430
  for (const r of n) {
4431
4431
  if (!r || typeof r != "object")
@@ -4435,7 +4435,7 @@ const ts = (t) => t.length > 0 ? t.join(", ") : "none", Oa = (t, e) => new Z(`En
4435
4435
  for (const s of r.__ops) {
4436
4436
  if (!Array.isArray(s))
4437
4437
  throw new Z(`Transaction operation must be an array, but received: ${typeof s}`);
4438
- Pa(s, e);
4438
+ Ca(s, e);
4439
4439
  }
4440
4440
  }
4441
4441
  };
@@ -4475,7 +4475,7 @@ class ur {
4475
4475
  return this.conn.send(JSON.stringify(e));
4476
4476
  }
4477
4477
  }
4478
- class Ia {
4478
+ class Ma {
4479
4479
  constructor(e, n) {
4480
4480
  p(this, "type", "sse");
4481
4481
  p(this, "initParams", null);
@@ -4571,7 +4571,7 @@ class Ia {
4571
4571
  this.handleClose();
4572
4572
  }
4573
4573
  }
4574
- function Ma(t, e) {
4574
+ function ja(t, e) {
4575
4575
  const n = t.values;
4576
4576
  if (n) {
4577
4577
  const r = Mr(n.attrsStore, null);
@@ -4583,7 +4583,7 @@ function Ma(t, e) {
4583
4583
  }
4584
4584
  return t;
4585
4585
  }
4586
- function ja(t, e) {
4586
+ function Ra(t, e) {
4587
4587
  var n;
4588
4588
  if (e.values) {
4589
4589
  const r = [];
@@ -4598,7 +4598,7 @@ function ja(t, e) {
4598
4598
  } else
4599
4599
  return e;
4600
4600
  }
4601
- function Ra(t, e, n) {
4601
+ function $a(t, e, n) {
4602
4602
  var i, o;
4603
4603
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = n == null ? void 0 : n.state) == null ? void 0 : o.txId;
4604
4604
  return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
@@ -4625,7 +4625,7 @@ function fr(t, e, n) {
4625
4625
  break;
4626
4626
  }
4627
4627
  }
4628
- function $a(t, e, n) {
4628
+ function Da(t, e, n) {
4629
4629
  var s, i;
4630
4630
  const r = {};
4631
4631
  for (const { action: o, triple: a } of n) {
@@ -4653,14 +4653,14 @@ function $a(t, e, n) {
4653
4653
  function et(t, e) {
4654
4654
  return { [t.table]: e.map((n) => n.entity) };
4655
4655
  }
4656
- function Da(t, e) {
4656
+ function xa(t, e) {
4657
4657
  var r;
4658
4658
  if (t.orderFieldType)
4659
4659
  return t.orderFieldType;
4660
4660
  const n = t.orderField === "serverCreatedAt" ? "number" : (r = U(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
4661
4661
  return t.orderFieldType = n, n;
4662
4662
  }
4663
- function xa(t, e, n) {
4663
+ function Ua(t, e, n) {
4664
4664
  const r = e;
4665
4665
  if (t.orderField === "serverCreatedAt") {
4666
4666
  n.sort(t.orderDirection === "asc" ? function(o, a) {
@@ -4681,7 +4681,7 @@ var he;
4681
4681
  (function(t) {
4682
4682
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4683
4683
  })(he || (he = {}));
4684
- class Ua {
4684
+ class La {
4685
4685
  constructor(e, n, r, s, i, o) {
4686
4686
  p(this, "trySend");
4687
4687
  p(this, "subs");
@@ -4694,9 +4694,9 @@ class Ua {
4694
4694
  p(this, "getAttrs");
4695
4695
  this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new Ht({
4696
4696
  persister: n,
4697
- merge: Ra,
4698
- serialize: ja,
4699
- parse: (a, c) => Ma(c, this.config.useDateObjects),
4697
+ merge: $a,
4698
+ serialize: Ra,
4699
+ parse: (a, c) => ja(c, this.config.useDateObjects),
4700
4700
  objectSize: (a) => {
4701
4701
  var c;
4702
4702
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4893,7 +4893,7 @@ class Ua {
4893
4893
  const S = d[T];
4894
4894
  if (yi(S.store, w)) {
4895
4895
  fr(S.store, l.attrsStore, m);
4896
- const C = Pt(s, S.store, l.attrsStore), A = $a(S.store, l.attrsStore, m)[w];
4896
+ const C = Pt(s, S.store, l.attrsStore), A = Da(S.store, l.attrsStore, m)[w];
4897
4897
  C ? (h.push({
4898
4898
  oldEntity: S.entity,
4899
4899
  newEntity: C,
@@ -4924,8 +4924,8 @@ class Ua {
4924
4924
  const b = [];
4925
4925
  for (const w of c.sort().reverse())
4926
4926
  b.push(d[w].entity), d.splice(w, 1);
4927
- const g = Da(s, this.getAttrs);
4928
- xa(s, g, d), this.notifyCbs(r, {
4927
+ const g = xa(s, this.getAttrs);
4928
+ Ua(s, g, d), this.notifyCbs(r, {
4929
4929
  type: he.SyncTransaction,
4930
4930
  data: et(s, (o = s.values) == null ? void 0 : o.entities),
4931
4931
  added: y,
@@ -4972,23 +4972,23 @@ const ie = {
4972
4972
  AUTHENTICATED: "authenticated",
4973
4973
  CLOSED: "closed",
4974
4974
  ERRORED: "errored"
4975
- }, La = 3e4, Fa = 3e4, Na = 200, Ka = 1e3 * 60, qa = {
4975
+ }, Fa = 3e4, Na = 3e4, Ka = 200, qa = 1e3 * 60, za = {
4976
4976
  apiURI: "https://api.instantdb.com",
4977
4977
  websocketURI: "wss://api.instantdb.com/runtime/session"
4978
4978
  }, Ct = "_instant_oauth_redirect", Re = "currentUser";
4979
- function za({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
4979
+ function Va({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
4980
4980
  if (!s)
4981
4981
  return new ur(`${r}?app_id=${e}`);
4982
4982
  switch (t) {
4983
4983
  case "ws":
4984
4984
  return new ur(`${r}?app_id=${e}`);
4985
4985
  case "sse":
4986
- return new Ia(s, `${n}/runtime/sse?app_id=${e}`);
4986
+ return new Ma(s, `${n}/runtime/sse?app_id=${e}`);
4987
4987
  default:
4988
4988
  throw new Error("Unknown transport type " + t);
4989
4989
  }
4990
4990
  }
4991
- function Va() {
4991
+ function Wa() {
4992
4992
  return typeof window < "u" || typeof chrome < "u";
4993
4993
  }
4994
4994
  const dr = {
@@ -4997,7 +4997,7 @@ const dr = {
4997
4997
  "refresh-presence": !0,
4998
4998
  "patch-presence": !0
4999
4999
  };
5000
- function Wa(t, e) {
5000
+ function Qa(t, e) {
5001
5001
  var r;
5002
5002
  const n = typeof t == "string" ? JSON.parse(t) : t;
5003
5003
  if ((r = n == null ? void 0 : n.result) != null && r.store) {
@@ -5012,7 +5012,7 @@ function Wa(t, e) {
5012
5012
  }
5013
5013
  return n;
5014
5014
  }
5015
- function Qa(t, e) {
5015
+ function Ba(t, e) {
5016
5016
  const { result: n, ...r } = e, s = (
5017
5017
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
5018
5018
  r
@@ -5027,7 +5027,7 @@ function Qa(t, e) {
5027
5027
  }
5028
5028
  return s;
5029
5029
  }
5030
- function Ba(t, e) {
5030
+ function Ga(t, e) {
5031
5031
  switch (t) {
5032
5032
  case "pendingMutations":
5033
5033
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -5035,7 +5035,7 @@ function Ba(t, e) {
5035
5035
  return e;
5036
5036
  }
5037
5037
  }
5038
- function Ga(t, e) {
5038
+ function Ha(t, e) {
5039
5039
  switch (t) {
5040
5040
  case "pendingMutations":
5041
5041
  return [...e.entries()];
@@ -5043,7 +5043,7 @@ function Ga(t, e) {
5043
5043
  return e;
5044
5044
  }
5045
5045
  }
5046
- function Ha(t, e, n) {
5046
+ function Ja(t, e, n) {
5047
5047
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
5048
5048
  return r && !s && n && (n.result = r), n || e;
5049
5049
  }
@@ -5053,7 +5053,7 @@ function It(t) {
5053
5053
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
5054
5054
  });
5055
5055
  }
5056
- class Ja {
5056
+ class Ya {
5057
5057
  constructor(e, n = Qr, r = Br, s, i) {
5058
5058
  /** @type {s.AttrsStore | undefined} */
5059
5059
  p(this, "attrs");
@@ -5148,9 +5148,9 @@ class Ja {
5148
5148
  });
5149
5149
  /** Applies transactions locally and sends transact message to server */
5150
5150
  p(this, "pushTx", (e) => {
5151
- this.config.disableValidation || Ca(e, this.config.schema);
5151
+ this.config.disableValidation || Ia(e, this.config.schema);
5152
5152
  try {
5153
- const n = Xo({
5153
+ const n = ea({
5154
5154
  attrsStore: this.optimisticAttrs(),
5155
5155
  schema: this.config.schema,
5156
5156
  stores: Object.values(this.querySubs.currentValue).map((r) => {
@@ -5251,7 +5251,7 @@ class Ja {
5251
5251
  }
5252
5252
  this._log.info("[socket][close]", n.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
5253
5253
  });
5254
- if (this._EventSource = i, this.config = { ...qa, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Fa, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Na, this._log = wa(e.verbose || fn || Gr, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": Yr }, this.config.schema && (this._linkIndex = sr(this.config.schema)), !!Va()) {
5254
+ if (this._EventSource = i, this.config = { ...za, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Na, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Ka, this._log = ma(e.verbose || fn || Gr, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": Yr }, this.config.schema && (this._linkIndex = sr(this.config.schema)), !!Wa()) {
5255
5255
  if (!e.appId)
5256
5256
  throw new Error("Instant must be initialized with an appId.");
5257
5257
  if (!Oe(e.appId))
@@ -5268,14 +5268,14 @@ class Ja {
5268
5268
  } catch (c) {
5269
5269
  this._log.error("[error] handle broadcast channel", c);
5270
5270
  }
5271
- })), this._initStorage(n), this._syncTable = new Ua(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5271
+ })), this._initStorage(n), this._syncTable = new La(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5272
5272
  useDateObjects: this.config.useDateObjects
5273
5273
  }, this._log, (o) => xe(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser().then((o) => {
5274
5274
  this.syncUserToEndpoint(o.user);
5275
5275
  }), setInterval(async () => {
5276
5276
  const o = await this.getCurrentUser();
5277
5277
  this.syncUserToEndpoint(o.user);
5278
- }, Ka), r.getIsOnline().then((o) => {
5278
+ }, qa), r.getIsOnline().then((o) => {
5279
5279
  this._isOnline = o, this._startSocket(), r.listen((a) => {
5280
5280
  a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", ie.CLOSED), this._setStatus(ie.CLOSED)));
5281
5281
  });
@@ -5307,9 +5307,9 @@ class Ja {
5307
5307
  _initStorage(e) {
5308
5308
  this.querySubs = new Ht({
5309
5309
  persister: new e(this.config.appId, "querySubs"),
5310
- merge: Ha,
5311
- serialize: Qa,
5312
- parse: (n, r) => Wa(r, this.config.useDateObjects),
5310
+ merge: Ja,
5311
+ serialize: Ba,
5312
+ parse: (n, r) => Qa(r, this.config.useDateObjects),
5313
5313
  // objectSize
5314
5314
  objectSize: (n) => {
5315
5315
  var r, s, i;
@@ -5328,8 +5328,8 @@ class Ja {
5328
5328
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Ht({
5329
5329
  persister: new e(this.config.appId, "kv"),
5330
5330
  merge: this._onMergeKv,
5331
- serialize: Ga,
5332
- parse: Ba,
5331
+ serialize: Ha,
5332
+ parse: Ga,
5333
5333
  objectSize: () => 0,
5334
5334
  logger: this._log,
5335
5335
  saveThrottleMs: 100,
@@ -5666,7 +5666,7 @@ class Ja {
5666
5666
  if (!this.querySubs)
5667
5667
  return r.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), r.promise;
5668
5668
  const s = L(e), i = this._startQuerySub(e, s);
5669
- return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), La), r.promise;
5669
+ return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), Fa), r.promise;
5670
5670
  }
5671
5671
  _completeQueryOnce(e, n, r) {
5672
5672
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((s) => s.dfd !== r), this._cleanupQuery(e, n));
@@ -5733,7 +5733,7 @@ class Ja {
5733
5733
  a = !0;
5734
5734
  continue;
5735
5735
  }
5736
- const g = a ? Po(o, y) : y;
5736
+ const g = a ? Co(o, y) : y;
5737
5737
  h.push(g);
5738
5738
  }
5739
5739
  return a ? h : l;
@@ -5911,7 +5911,7 @@ class Ja {
5911
5911
  return;
5912
5912
  }
5913
5913
  const e = this._transport;
5914
- this._transport = za({
5914
+ this._transport = Va({
5915
5915
  transportType: this._transportType,
5916
5916
  appId: this.config.appId,
5917
5917
  apiURI: this.config.apiURI,
@@ -6122,7 +6122,7 @@ class Ja {
6122
6122
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
6123
6123
  }
6124
6124
  sendMagicCode({ email: e }) {
6125
- return aa({
6125
+ return ca({
6126
6126
  apiURI: this.config.apiURI,
6127
6127
  appId: this.config.appId,
6128
6128
  email: e
@@ -6130,7 +6130,7 @@ class Ja {
6130
6130
  }
6131
6131
  async signInWithMagicCode({ email: e, code: n }) {
6132
6132
  var o;
6133
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await ca({
6133
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await ua({
6134
6134
  apiURI: this.config.apiURI,
6135
6135
  appId: this.config.appId,
6136
6136
  email: e,
@@ -6140,7 +6140,7 @@ class Ja {
6140
6140
  return await this.changeCurrentUser(i.user), i;
6141
6141
  }
6142
6142
  async signInWithCustomToken(e) {
6143
- const n = await ua({
6143
+ const n = await la({
6144
6144
  apiURI: this.config.apiURI,
6145
6145
  appId: this.config.appId,
6146
6146
  refreshToken: e
@@ -6148,7 +6148,7 @@ class Ja {
6148
6148
  return await this.changeCurrentUser(n.user), n;
6149
6149
  }
6150
6150
  async signInAsGuest() {
6151
- const e = await la({
6151
+ const e = await fa({
6152
6152
  apiURI: this.config.apiURI,
6153
6153
  appId: this.config.appId
6154
6154
  });
@@ -6163,7 +6163,7 @@ class Ja {
6163
6163
  this._log.info("[auth-invalidate] skipped invalidateToken");
6164
6164
  return;
6165
6165
  }
6166
- da({
6166
+ ha({
6167
6167
  apiURI: this.config.apiURI,
6168
6168
  appId: this.config.appId,
6169
6169
  refreshToken: r
@@ -6216,7 +6216,7 @@ class Ja {
6216
6216
  */
6217
6217
  async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
6218
6218
  var a;
6219
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await fa({
6219
+ const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await da({
6220
6220
  apiURI: this.config.apiURI,
6221
6221
  appId: this.config.appId,
6222
6222
  idToken: e,
@@ -6259,7 +6259,7 @@ class Ja {
6259
6259
  getPresence(e, n, r = {}) {
6260
6260
  const s = this._rooms[n], i = this._presence[n];
6261
6261
  return !s || !i || !i.result ? null : {
6262
- ...ga(i.result, r, this._sessionId),
6262
+ ...Ta(i.result, r, this._sessionId),
6263
6263
  isLoading: !s.isConnected,
6264
6264
  error: s.error
6265
6265
  };
@@ -6321,7 +6321,7 @@ class Ja {
6321
6321
  }
6322
6322
  _notifyPresenceSub(e, n) {
6323
6323
  const r = this.getPresence("", e, n);
6324
- r && (n.prev && !Ta(r, n.prev) || (n.prev = r, n.cb(r)));
6324
+ r && (n.prev && !wa(r, n.prev) || (n.prev = r, n.cb(r)));
6325
6325
  }
6326
6326
  _patchPresencePeers(e, n) {
6327
6327
  var o, a, c;
@@ -6393,7 +6393,7 @@ class Ja {
6393
6393
  async uploadFile(e, n, r) {
6394
6394
  var o;
6395
6395
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
6396
- return ha({
6396
+ return pa({
6397
6397
  ...r,
6398
6398
  apiURI: this.config.apiURI,
6399
6399
  appId: this.config.appId,
@@ -6405,7 +6405,7 @@ class Ja {
6405
6405
  async deleteFile(e) {
6406
6406
  var i;
6407
6407
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6408
- return await pa({
6408
+ return await ya({
6409
6409
  apiURI: this.config.apiURI,
6410
6410
  appId: this.config.appId,
6411
6411
  path: e,
@@ -6416,18 +6416,18 @@ class Ja {
6416
6416
  // ---------------------------------
6417
6417
  async upload(e, n) {
6418
6418
  var c;
6419
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await ya({
6419
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await ba({
6420
6420
  apiURI: this.config.apiURI,
6421
6421
  appId: this.config.appId,
6422
6422
  fileName: i,
6423
6423
  refreshToken: s
6424
6424
  });
6425
- return await ba(o, n);
6425
+ return await _a(o, n);
6426
6426
  }
6427
6427
  async getDownloadUrl(e) {
6428
6428
  var i;
6429
6429
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6430
- return await _a({
6430
+ return await ga({
6431
6431
  apiURI: this.config.apiURI,
6432
6432
  appId: this.config.appId,
6433
6433
  path: e,
@@ -6436,9 +6436,9 @@ class Ja {
6436
6436
  }
6437
6437
  }
6438
6438
  let tt;
6439
- function Ya(t, e) {
6439
+ function Za(t, e) {
6440
6440
  tt == null || tt.dispose();
6441
- const n = rc(e), r = ec(e, a), s = Xa(Za(t));
6441
+ const n = sc(e), r = tc(e, a), s = ec(Xa(t));
6442
6442
  function i(l) {
6443
6443
  var d;
6444
6444
  l.source === s.element.contentWindow && ((d = l.data) == null ? void 0 : d.type) === "close" && n.isVisible() && a();
@@ -6460,10 +6460,10 @@ function Ya(t, e) {
6460
6460
  }
6461
6461
  return u();
6462
6462
  }
6463
- function Za(t) {
6463
+ function Xa(t) {
6464
6464
  return `${fn || Hr ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6465
6465
  }
6466
- function Xa(t) {
6466
+ function ec(t) {
6467
6467
  const e = document.createElement("iframe");
6468
6468
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6469
6469
  width: "100%",
@@ -6472,7 +6472,7 @@ function Xa(t) {
6472
6472
  border: "none"
6473
6473
  }), { element: e };
6474
6474
  }
6475
- function ec(t, e) {
6475
+ function tc(t, e) {
6476
6476
  const n = `
6477
6477
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6478
6478
  <rect width="512" height="512" fill="black"/>
@@ -6482,7 +6482,7 @@ function ec(t, e) {
6482
6482
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
6483
6483
  // pos
6484
6484
  position: "fixed",
6485
- ...tc(t.position),
6485
+ ...nc(t.position),
6486
6486
  height: "32px",
6487
6487
  width: "32px",
6488
6488
  // layout
@@ -6497,7 +6497,7 @@ function ec(t, e) {
6497
6497
  cursor: "pointer"
6498
6498
  }), r.addEventListener("click", e), { element: r };
6499
6499
  }
6500
- function tc(t) {
6500
+ function nc(t) {
6501
6501
  switch (t) {
6502
6502
  case "bottom-left":
6503
6503
  return { bottom: "24px", left: "24px" };
@@ -6509,7 +6509,7 @@ function tc(t) {
6509
6509
  return { top: "24px", left: "24px" };
6510
6510
  }
6511
6511
  }
6512
- function nc(t) {
6512
+ function rc(t) {
6513
6513
  switch (t) {
6514
6514
  case "bottom-left":
6515
6515
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6521,11 +6521,11 @@ function nc(t) {
6521
6521
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6522
6522
  }
6523
6523
  }
6524
- function rc(t) {
6524
+ function sc(t) {
6525
6525
  const e = document.createElement("div");
6526
6526
  Object.assign(e.style, {
6527
6527
  position: "fixed",
6528
- ...nc(t.position),
6528
+ ...rc(t.position),
6529
6529
  display: "block",
6530
6530
  borderRadius: "4px",
6531
6531
  border: "1px #ccc solid",
@@ -6538,22 +6538,22 @@ function rc(t) {
6538
6538
  }
6539
6539
  return { element: e, isVisible: n };
6540
6540
  }
6541
- const sc = {
6541
+ const ic = {
6542
6542
  apiURI: "https://api.instantdb.com",
6543
6543
  websocketURI: "wss://api.instantdb.com/runtime/session"
6544
6544
  };
6545
- function ic() {
6545
+ function oc() {
6546
6546
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6547
6547
  }
6548
- function oc() {
6548
+ function ac() {
6549
6549
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6550
6550
  }
6551
6551
  function Jt(t) {
6552
6552
  const e = t.__adminToken;
6553
6553
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6554
6554
  }
6555
- const Yt = oc(), hr = ic();
6556
- class ac {
6555
+ const Yt = ac(), hr = oc();
6556
+ class cc {
6557
6557
  constructor(e) {
6558
6558
  p(this, "db");
6559
6559
  /**
@@ -6670,7 +6670,7 @@ class ac {
6670
6670
  this.db = e;
6671
6671
  }
6672
6672
  }
6673
- class cc {
6673
+ class uc {
6674
6674
  constructor(e) {
6675
6675
  p(this, "db");
6676
6676
  /**
@@ -6719,16 +6719,16 @@ class cc {
6719
6719
  this.db = e;
6720
6720
  }
6721
6721
  }
6722
- function uc(t) {
6722
+ function lc(t) {
6723
6723
  return JSON.parse(JSON.stringify(t));
6724
6724
  }
6725
- class lc {
6725
+ class fc {
6726
6726
  constructor(e) {
6727
6727
  p(this, "_reactor");
6728
6728
  p(this, "auth");
6729
6729
  p(this, "storage");
6730
6730
  p(this, "tx", ln());
6731
- this._reactor = e, this.auth = new ac(this._reactor), this.storage = new cc(this._reactor);
6731
+ this._reactor = e, this.auth = new cc(this._reactor), this.storage = new uc(this._reactor);
6732
6732
  }
6733
6733
  /**
6734
6734
  * Use this to write data! You can create, update, delete, and link objects
@@ -6911,10 +6911,10 @@ function pr(t) {
6911
6911
  const n = L(t);
6912
6912
  return hr.set(t, n), n;
6913
6913
  }
6914
- function fc(t, e) {
6914
+ function dc(t, e) {
6915
6915
  return pr(t._reactor.config.schema) !== pr(e);
6916
6916
  }
6917
- function dc(t, e, n, r, s) {
6917
+ function hc(t, e, n, r, s) {
6918
6918
  var u;
6919
6919
  const i = {
6920
6920
  ...t,
@@ -6922,15 +6922,15 @@ function dc(t, e, n, r, s) {
6922
6922
  useDateObjects: t.useDateObjects ?? !1
6923
6923
  }, o = Yt[Jt(i)];
6924
6924
  if (o)
6925
- return fc(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6926
- const a = new Ja({
6927
- ...sc,
6925
+ return dc(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6926
+ const a = new Ya({
6927
+ ...ic,
6928
6928
  ...i,
6929
6929
  cardinalityInference: !!i.schema
6930
- }, e || Qr, n || Br, { ...r || {}, "@instantdb/core": Yr }, s), c = new lc(a);
6931
- return Yt[Jt(i)] = c, hc(i.appId, i.devtool), c;
6930
+ }, e || Qr, n || Br, { ...r || {}, "@instantdb/core": Yr }, s), c = new fc(a);
6931
+ return Yt[Jt(i)] = c, pc(i.appId, i.devtool), c;
6932
6932
  }
6933
- function hc(t, e) {
6933
+ function pc(t, e) {
6934
6934
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6935
6935
  return;
6936
6936
  const n = {
@@ -6938,9 +6938,9 @@ function hc(t, e) {
6938
6938
  allowedHosts: ["localhost"],
6939
6939
  ...typeof e == "object" ? e : {}
6940
6940
  };
6941
- n.allowedHosts.includes(window.location.hostname) && Ya(t, n);
6941
+ n.allowedHosts.includes(window.location.hostname) && Za(t, n);
6942
6942
  }
6943
- const pc = {
6943
+ const yc = {
6944
6944
  isLoading: !0,
6945
6945
  data: void 0,
6946
6946
  pageInfo: void 0,
@@ -6955,9 +6955,9 @@ function yr(t) {
6955
6955
  ...t || {}
6956
6956
  };
6957
6957
  }
6958
- function yc(t, e, n) {
6958
+ function bc(t, e, n) {
6959
6959
  e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
6960
- const r = e ? uc(e) : null, s = L(r), i = Ke(
6960
+ const r = e ? lc(e) : null, s = L(r), i = Ke(
6961
6961
  yr(t._reactor.getPreviousResult(r))
6962
6962
  ), o = fe(
6963
6963
  (c) => (i.current = yr(
@@ -6981,10 +6981,10 @@ function yc(t, e, n) {
6981
6981
  return { state: jt(
6982
6982
  o,
6983
6983
  () => i.current,
6984
- () => pc
6984
+ () => yc
6985
6985
  ), query: r };
6986
6986
  }
6987
- function bc() {
6987
+ function _c() {
6988
6988
  const t = Ke(null);
6989
6989
  _e(() => {
6990
6990
  n();
@@ -6997,8 +6997,8 @@ function bc() {
6997
6997
  }
6998
6998
  return { set: e, clear: n };
6999
6999
  }
7000
- const _c = 1e3;
7001
- function gc(t, e, n) {
7000
+ const gc = 1e3;
7001
+ function Tc(t, e, n) {
7002
7002
  const r = Ke(n);
7003
7003
  r.current = n, _e(() => t.core._reactor.subscribeTopic(
7004
7004
  t.type,
@@ -7009,7 +7009,7 @@ function gc(t, e, n) {
7009
7009
  }
7010
7010
  ), [t.id, e]);
7011
7011
  }
7012
- function Tc(t, e) {
7012
+ function wc(t, e) {
7013
7013
  return _e(() => t.core._reactor.joinRoom(t.type, t.id), [t.id]), fe(
7014
7014
  (r) => {
7015
7015
  t.core._reactor.publishTopic({
@@ -7022,7 +7022,7 @@ function Tc(t, e) {
7022
7022
  [t.id, e]
7023
7023
  );
7024
7024
  }
7025
- function wc(t, e = {}) {
7025
+ function mc(t, e = {}) {
7026
7026
  var o, a;
7027
7027
  const [n, r] = _r(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
7028
7028
  peers: {},
@@ -7047,14 +7047,14 @@ function wc(t, e = {}) {
7047
7047
  publishPresence: s
7048
7048
  }), [n, s]);
7049
7049
  }
7050
- function mc(t, e, n) {
7050
+ function Sc(t, e, n) {
7051
7051
  _e(
7052
7052
  () => t.core._reactor.joinRoom(t.type, t.id, e),
7053
7053
  [t.id]
7054
7054
  ), _e(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
7055
7055
  }
7056
- function Sc(t, e, n = {}) {
7057
- const r = bc(), s = pe.usePresence(t, {
7056
+ function vc(t, e, n = {}) {
7057
+ const r = _c(), s = pe.usePresence(t, {
7058
7058
  keys: [e]
7059
7059
  }), i = Rt(() => {
7060
7060
  const l = t._core._reactor.getPresence(
@@ -7068,7 +7068,7 @@ function Sc(t, e, n = {}) {
7068
7068
  (l) => {
7069
7069
  t.core._reactor.publishPresence(t.type, t.id, {
7070
7070
  [e]: l
7071
- }), l && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? _c, () => {
7071
+ }), l && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? gc, () => {
7072
7072
  t.core._reactor.publishPresence(t.type, t.id, {
7073
7073
  [e]: null
7074
7074
  });
@@ -7091,13 +7091,13 @@ function Sc(t, e, n = {}) {
7091
7091
  };
7092
7092
  }
7093
7093
  const pe = {
7094
- useTopicEffect: gc,
7095
- usePublishTopic: Tc,
7096
- usePresence: wc,
7097
- useSyncPresence: mc,
7098
- useTypingIndicator: Sc
7094
+ useTopicEffect: Tc,
7095
+ usePublishTopic: wc,
7096
+ usePresence: mc,
7097
+ useSyncPresence: Sc,
7098
+ useTypingIndicator: vc
7099
7099
  };
7100
- class vc {
7100
+ class Ac {
7101
7101
  constructor(e, n, r) {
7102
7102
  p(this, "core");
7103
7103
  /** @deprecated use `core` instead */
@@ -7184,7 +7184,7 @@ class vc {
7184
7184
  this.core = e, this._core = this.core, this.type = n, this.id = r;
7185
7185
  }
7186
7186
  }
7187
- const Ac = {
7187
+ const Oc = {
7188
7188
  isLoading: !0,
7189
7189
  user: void 0,
7190
7190
  error: void 0
@@ -7287,7 +7287,7 @@ class Mt {
7287
7287
  * auth.user ? { goals: {} } : null,
7288
7288
  * );
7289
7289
  */
7290
- p(this, "useQuery", (e, n) => yc(this.core, e, n).state);
7290
+ p(this, "useQuery", (e, n) => bc(this.core, e, n).state);
7291
7291
  /**
7292
7292
  * Listen for the logged in state. This is useful
7293
7293
  * for deciding when to show a login screen.
@@ -7416,7 +7416,7 @@ class Mt {
7416
7416
  const n = this.useAuth();
7417
7417
  return n.isLoading || n.error || n.user ? null : /* @__PURE__ */ Ye.jsx(Ye.Fragment, { children: e });
7418
7418
  });
7419
- this.core = dc(
7419
+ this.core = hc(
7420
7420
  e,
7421
7421
  // @ts-expect-error because TS can't resolve subclass statics
7422
7422
  e.Store || this.constructor.Storage,
@@ -7440,7 +7440,7 @@ class Mt {
7440
7440
  * const { peers } = db.rooms.usePresence(room);
7441
7441
  */
7442
7442
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7443
- return new vc(this.core, e, n);
7443
+ return new Ac(this.core, e, n);
7444
7444
  }
7445
7445
  _useAuth() {
7446
7446
  const e = Ke(
@@ -7451,7 +7451,7 @@ class Mt {
7451
7451
  return jt(
7452
7452
  n,
7453
7453
  () => e.current,
7454
- () => Ac
7454
+ () => Oc
7455
7455
  );
7456
7456
  }
7457
7457
  /**