@instantdb/core 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.
@@ -1907,38 +1907,39 @@ function Xr() {
1907
1907
  const es = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Et = { randomUUID: es };
1908
1908
  function ts(t, e, n) {
1909
1909
  var s;
1910
- if (Et.randomUUID && !t)
1911
- return Et.randomUUID();
1912
1910
  t = t || {};
1913
1911
  const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? Xr();
1914
1912
  if (r.length < 16)
1915
1913
  throw new Error("Random bytes length must be >= 16");
1916
1914
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Yr(r);
1917
1915
  }
1916
+ function ns(t, e, n) {
1917
+ return Et.randomUUID ? Et.randomUUID() : ts(t);
1918
+ }
1918
1919
  function It(t) {
1919
1920
  const e = t.replace(/-/g, ""), n = [];
1920
1921
  for (let r = 0; r < e.length; r += 2)
1921
1922
  n.push(parseInt(e.substring(r, r + 2), 16));
1922
1923
  return n;
1923
1924
  }
1924
- function ns(t, e) {
1925
+ function rs(t, e) {
1925
1926
  for (let n = 0; n < t.length; n++) {
1926
1927
  if (t[n] < e[n]) return -1;
1927
1928
  if (t[n] > e[n]) return 1;
1928
1929
  }
1929
1930
  return 0;
1930
1931
  }
1931
- function rs(t, e) {
1932
- return ns(It(t), It(e));
1932
+ function ss(t, e) {
1933
+ return rs(It(t), It(e));
1933
1934
  }
1934
1935
  function I() {
1935
- return ts();
1936
+ return ns();
1936
1937
  }
1937
- function ss(t, e) {
1938
+ function is(t, e) {
1938
1939
  return t.localeCompare(e);
1939
1940
  }
1940
- function is() {
1941
- let t = ss;
1941
+ function os() {
1942
+ let t = is;
1942
1943
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1943
1944
  try {
1944
1945
  t = Intl.Collator("en-US").compare;
@@ -1946,10 +1947,10 @@ function is() {
1946
1947
  }
1947
1948
  return t;
1948
1949
  }
1949
- const os = is();
1950
- let as = 0;
1950
+ const as = os();
1951
+ let cs = 0;
1951
1952
  function ue(t) {
1952
- return Ce(`_${t}`, as++);
1953
+ return Ce(`_${t}`, cs++);
1953
1954
  }
1954
1955
  function Ce(t, e) {
1955
1956
  return `?${t}-${e}`;
@@ -1959,24 +1960,24 @@ class ne extends Error {
1959
1960
  super(e), this.name = "AttrNotFoundError";
1960
1961
  }
1961
1962
  }
1962
- function cs(t, e) {
1963
+ function us(t, e) {
1963
1964
  const n = wn(t, e);
1964
1965
  if (!n)
1965
1966
  throw new ne(`Could not find id attr for ${e}`);
1966
1967
  return n;
1967
1968
  }
1968
1969
  function Ct(t, e, n, r) {
1969
- return [us(t, e, n, r)];
1970
+ return [ls(t, e, n, r)];
1970
1971
  }
1971
- function us(t, e, n, r) {
1972
+ function ls(t, e, n, r) {
1972
1973
  return [
1973
1974
  t(n, r),
1974
- cs(e, n).id,
1975
+ us(e, n).id,
1975
1976
  t(n, r),
1976
1977
  t("time", r)
1977
1978
  ];
1978
1979
  }
1979
- function ls(t, e, n) {
1980
+ function fs(t, e, n) {
1980
1981
  return t.map((r) => r === e ? n : r);
1981
1982
  }
1982
1983
  function mn(t, e, n, r, s) {
@@ -2011,7 +2012,7 @@ function Mt(t, e) {
2011
2012
  return typeof o != "string" ? !1 : s.test(o);
2012
2013
  };
2013
2014
  }
2014
- function fs(t, e) {
2015
+ function ds(t, e) {
2015
2016
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2016
2017
  return e;
2017
2018
  const n = t["checked-data-type"] === "date";
@@ -2071,7 +2072,7 @@ function fs(t, e) {
2071
2072
  }
2072
2073
  return e;
2073
2074
  }
2074
- function ds(t, e, n, r, s, i) {
2075
+ function hs(t, e, n, r, s, i) {
2075
2076
  const o = E(e, n, s), a = Z(
2076
2077
  e,
2077
2078
  n,
@@ -2097,11 +2098,11 @@ function ds(t, e, n, r, s, i) {
2097
2098
  return o ? [
2098
2099
  t(n, r),
2099
2100
  c.id,
2100
- fs(c, i),
2101
+ ds(c, i),
2101
2102
  ue("time")
2102
2103
  ] : [i, c.id, t(n, r), ue("time")];
2103
2104
  }
2104
- function hs(t, e, n, r, s) {
2105
+ function ps(t, e, n, r, s) {
2105
2106
  const [i, o, a] = s.reduce(
2106
2107
  (c, u) => {
2107
2108
  const [l, f, d] = c, [h, p, y] = mn(
@@ -2118,13 +2119,13 @@ function hs(t, e, n, r, s) {
2118
2119
  return [i, o, a];
2119
2120
  }
2120
2121
  function Be(t, e, n, r, s, i) {
2121
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = hs(
2122
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = ps(
2122
2123
  t,
2123
2124
  e,
2124
2125
  n,
2125
2126
  r,
2126
2127
  o
2127
- ), f = ds(
2128
+ ), f = hs(
2128
2129
  t,
2129
2130
  e,
2130
2131
  c,
@@ -2134,16 +2135,16 @@ function Be(t, e, n, r, s, i) {
2134
2135
  );
2135
2136
  return l.concat([f]);
2136
2137
  }
2137
- function ps(t, e) {
2138
+ function ys(t, e) {
2138
2139
  return e ? [e].concat(t) : t;
2139
2140
  }
2140
- function ys([t, e]) {
2141
+ function bs([t, e]) {
2141
2142
  return t === "or" && Array.isArray(e);
2142
2143
  }
2143
- function bs([t, e]) {
2144
+ function _s([t, e]) {
2144
2145
  return t === "and" && Array.isArray(e);
2145
2146
  }
2146
- function _s(t, e, n) {
2147
+ function gs(t, e, n) {
2147
2148
  return (r, s) => {
2148
2149
  const i = t(r, s);
2149
2150
  return e == i ? i : `${i}-${n}`;
@@ -2151,19 +2152,19 @@ function _s(t, e, n) {
2151
2152
  }
2152
2153
  function Pt(t, e, n, r, s, i) {
2153
2154
  const o = t(r, s), a = i.map((c, u) => {
2154
- const l = _s(t, o, u);
2155
+ const l = gs(t, o, u);
2155
2156
  return Sn(l, n, r, s, c);
2156
2157
  });
2157
2158
  return { [e]: { patterns: a, joinSym: o } };
2158
2159
  }
2159
- function gs(t) {
2160
+ function ws(t) {
2160
2161
  const e = [];
2161
2162
  for (let n = 1; n <= t.length; n++)
2162
2163
  e.push(t.slice(0, n));
2163
2164
  return e;
2164
2165
  }
2165
2166
  function jt(t, e, n, r, s) {
2166
- return gs(s).map(
2167
+ return ws(s).map(
2167
2168
  (i) => Be(t, e, n, r, i, {
2168
2169
  $isNull: !0
2169
2170
  })
@@ -2171,9 +2172,9 @@ function jt(t, e, n, r, s) {
2171
2172
  }
2172
2173
  function Sn(t, e, n, r, s) {
2173
2174
  return Object.entries(s).flatMap(([i, o]) => {
2174
- if (ys([i, o]))
2175
- return Pt(t, "or", e, n, r, o);
2176
2175
  if (bs([i, o]))
2176
+ return Pt(t, "or", e, n, r, o);
2177
+ if (_s([i, o]))
2177
2178
  return Pt(t, "and", e, n, r, o);
2178
2179
  if (i === "$entityIdStartsWith")
2179
2180
  return [];
@@ -2218,31 +2219,31 @@ function Sn(t, e, n, r, s) {
2218
2219
  ] : Be(t, e, n, r, a, o);
2219
2220
  });
2220
2221
  }
2221
- function ws(t, e, n, r) {
2222
+ function Ts(t, e, n, r) {
2222
2223
  const s = Ce;
2223
2224
  return r ? Sn(s, t, e, n, r).concat(Ct(s, t, e, n)) : Ct(s, t, e, n);
2224
2225
  }
2225
- function Ts(t, e, n) {
2226
+ function ms(t, e, n) {
2226
2227
  return [t(e, n), t("time", n)];
2227
2228
  }
2228
- function ms(t, e, n, r, s, i) {
2229
+ function Ss(t, e, n, r, s, i) {
2229
2230
  const [o, a, c, u, l] = mn(
2230
2231
  t,
2231
2232
  e,
2232
2233
  n,
2233
2234
  r,
2234
2235
  s
2235
- ), f = ls(c, t(n, r), i);
2236
+ ), f = fs(c, t(n, r), i);
2236
2237
  return [o, a, f, u, l];
2237
2238
  }
2238
- function Ss(t, e, n, { etype: r, level: s, form: i }, o) {
2239
+ function As(t, e, n, { etype: r, level: s, form: i }, o) {
2239
2240
  const a = Object.keys(i).filter((c) => c !== "$");
2240
2241
  return a.length ? Object.entries(o).map(function([u, l]) {
2241
2242
  return a.map(function(h) {
2242
2243
  var y, b, g;
2243
2244
  const p = !!(e.cardinalityInference && ((g = (b = (y = n.linkIndex) == null ? void 0 : y[r]) == null ? void 0 : b[h]) != null && g.isSingular));
2244
2245
  try {
2245
- const [_, T, A] = ms(
2246
+ const [_, T, A] = Ss(
2246
2247
  t,
2247
2248
  n,
2248
2249
  r,
@@ -2266,11 +2267,11 @@ function Ss(t, e, n, { etype: r, level: s, form: i }, o) {
2266
2267
  }, l);
2267
2268
  }) : Object.values(o);
2268
2269
  }
2269
- function As(t, e, n) {
2270
- return n === "string" ? os(t, e) : t > e ? 1 : -1;
2270
+ function vs(t, e, n) {
2271
+ return n === "string" ? as(t, e) : t > e ? 1 : -1;
2271
2272
  }
2272
2273
  function ae(t, e, n, r, s) {
2273
- return e === r || e == null && r == null ? rs(t, n) : r == null ? 1 : e == null ? -1 : As(e, r, s);
2274
+ return e === r || e == null && r == null ? ss(t, n) : r == null ? 1 : e == null ? -1 : vs(e, r, s);
2274
2275
  }
2275
2276
  function ke([t, e], [n, r], s) {
2276
2277
  return ae(t, e, n, r, s);
@@ -2278,7 +2279,7 @@ function ke([t, e], [n, r], s) {
2278
2279
  function He(t) {
2279
2280
  return t == null ? t : new Date(t).getTime();
2280
2281
  }
2281
- function vs(t, e, n, r) {
2282
+ function Os(t, e, n, r) {
2282
2283
  var p;
2283
2284
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2284
2285
  if (((p = e["forward-identity"]) == null ? void 0 : p[2]) === "id")
@@ -2286,21 +2287,21 @@ function vs(t, e, n, r) {
2286
2287
  const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? He(l) : l, h = f === "date" ? He(o) : o;
2287
2288
  return ke([u, d], [s, h], f) === c;
2288
2289
  }
2289
- function Os(t, e) {
2290
+ function ks(t, e) {
2290
2291
  const n = e[1];
2291
2292
  return t.getAttr(n);
2292
2293
  }
2293
- function ks(t, e, n) {
2294
+ function Es(t, e, n) {
2294
2295
  const r = Object.keys(n)[0];
2295
2296
  return E(t, e, r);
2296
2297
  }
2297
- function Es(t, e, n, r) {
2298
+ function Is(t, e, n, r) {
2298
2299
  if (n)
2299
- return Os(t, n);
2300
+ return ks(t, n);
2300
2301
  if (r)
2301
- return ks(t, e, r);
2302
+ return Es(t, e, r);
2302
2303
  }
2303
- function Is(t, e, n) {
2304
+ function Cs(t, e, n) {
2304
2305
  var s, i;
2305
2306
  if (!Array.isArray(n.fields))
2306
2307
  return Ur(t, e);
@@ -2315,11 +2316,11 @@ function Is(t, e, n) {
2315
2316
  }
2316
2317
  return r;
2317
2318
  }
2318
- function Cs(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2319
+ function Ms(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2319
2320
  var p, y;
2320
- const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = An(i), c = Ms(i);
2321
+ const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = An(i), c = Ps(i);
2321
2322
  let u = Br(t, s);
2322
- const l = r == null ? void 0 : r["start-cursor"], f = Es(e, n, l, o);
2323
+ const l = r == null ? void 0 : r["start-cursor"], f = Is(e, n, l, o);
2323
2324
  if (f && ((y = f == null ? void 0 : f["forward-identity"]) == null ? void 0 : y[2]) !== "id") {
2324
2325
  const b = f["checked-data-type"] === "date", g = f.id;
2325
2326
  u = u.map(([_]) => {
@@ -2336,17 +2337,17 @@ function Cs(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2336
2337
  }
2337
2338
  );
2338
2339
  let d = {};
2339
- const h = Is(e, n, s);
2340
+ const h = Cs(e, n, s);
2340
2341
  for (const b of u) {
2341
2342
  const [g] = b;
2342
- if (d[g] || !a && l && f && vs(l, f, c, b))
2343
+ if (d[g] || !a && l && f && Os(l, f, c, b))
2343
2344
  continue;
2344
2345
  const _ = xr(t, h, g);
2345
2346
  _ && (d[g] = _);
2346
2347
  }
2347
2348
  return d;
2348
2349
  }
2349
- function Ms(t) {
2350
+ function Ps(t) {
2350
2351
  var n;
2351
2352
  const e = (n = t.$) == null ? void 0 : n.order;
2352
2353
  return e && e[Object.keys(e)[0]] || "asc";
@@ -2356,14 +2357,14 @@ function An(t) {
2356
2357
  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;
2357
2358
  return !e && !n && !r;
2358
2359
  }
2359
- function Ps(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2360
+ function js(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2360
2361
  var d, h, p, y, b;
2361
2362
  if (!An(s) && (!o || !o["start-cursor"]))
2362
2363
  return [];
2363
- const a = ps(
2364
- ws(e, n, r, (d = s.$) == null ? void 0 : d.where),
2364
+ const a = ys(
2365
+ Ts(e, n, r, (d = s.$) == null ? void 0 : d.where),
2365
2366
  i
2366
- ), c = Ts(Ce, n, r), u = (h = s.$) == null ? void 0 : h.fields, l = Cs(t, e, {
2367
+ ), c = ms(Ce, n, r), u = (h = s.$) == null ? void 0 : h.fields, l = Ms(t, e, {
2367
2368
  etype: n,
2368
2369
  pageInfo: o,
2369
2370
  form: s,
@@ -2378,9 +2379,9 @@ function Ps(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2378
2379
  }
2379
2380
  return l;
2380
2381
  }
2381
- function js(t, e, n) {
2382
+ function $s(t, e, n) {
2382
2383
  try {
2383
- return Ps(t, e, n);
2384
+ return js(t, e, n);
2384
2385
  } catch (r) {
2385
2386
  if (r instanceof ne)
2386
2387
  return {};
@@ -2388,10 +2389,10 @@ function js(t, e, n) {
2388
2389
  }
2389
2390
  }
2390
2391
  function vn(t, e, n) {
2391
- const r = js(t, e, n);
2392
- return Ss(Ce, t, e, n, r);
2392
+ const r = $s(t, e, n);
2393
+ return As(Ce, t, e, n, r);
2393
2394
  }
2394
- function $s(t) {
2395
+ function Ds(t) {
2395
2396
  const e = {};
2396
2397
  for (const [n, r] of Object.entries(t))
2397
2398
  e[n] = {
@@ -2416,9 +2417,9 @@ function On({
2416
2417
  pageInfo: n == null ? void 0 : n[u]
2417
2418
  })), c;
2418
2419
  }, {}) };
2419
- return n && (o.pageInfo = $s(n)), r && (o.aggregate = r), o;
2420
+ return n && (o.pageInfo = Ds(n)), r && (o.aggregate = r), o;
2420
2421
  }
2421
- function Ds() {
2422
+ function Rs() {
2422
2423
  const e = {
2423
2424
  __etype: 1,
2424
2425
  __ops: 1,
@@ -2432,7 +2433,7 @@ function Ds() {
2432
2433
  };
2433
2434
  return new Set(Object.keys(e));
2434
2435
  }
2435
- const Rs = Ds();
2436
+ const xs = Rs();
2436
2437
  function Je(t, e, n) {
2437
2438
  const r = {
2438
2439
  __etype: t,
@@ -2442,7 +2443,7 @@ function Je(t, e, n) {
2442
2443
  get: (s, i) => {
2443
2444
  if (i === "__ops") return n;
2444
2445
  if (i === "__etype") return t;
2445
- if (Rs.has(i))
2446
+ if (xs.has(i))
2446
2447
  return (o, a) => Je(t, e, [
2447
2448
  ...n,
2448
2449
  a ? [i, t, e, o, a] : [i, t, e, o]
@@ -2450,7 +2451,7 @@ function Je(t, e, n) {
2450
2451
  }
2451
2452
  });
2452
2453
  }
2453
- function Do(t, e) {
2454
+ function Ro(t, e) {
2454
2455
  return `lookup__${t}__${JSON.stringify(e)}`;
2455
2456
  }
2456
2457
  function Ee(t) {
@@ -2460,7 +2461,7 @@ function kn(t) {
2460
2461
  const [e, n, ...r] = t.split("__");
2461
2462
  return [n, JSON.parse(r.join("__"))];
2462
2463
  }
2463
- function xs(t) {
2464
+ function Us(t) {
2464
2465
  return new Proxy(
2465
2466
  {
2466
2467
  __etype: t
@@ -2479,16 +2480,16 @@ function En() {
2479
2480
  {},
2480
2481
  {
2481
2482
  get(t, e) {
2482
- return xs(e);
2483
+ return Us(e);
2483
2484
  }
2484
2485
  }
2485
2486
  );
2486
2487
  }
2487
- const Ro = En();
2488
- function Us(t) {
2488
+ const xo = En();
2489
+ function Ls(t) {
2489
2490
  return t.__ops;
2490
2491
  }
2491
- function Ls(t, e) {
2492
+ function Fs(t, e) {
2492
2493
  const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
2493
2494
  for (const o of e) {
2494
2495
  const a = n[o];
@@ -2507,7 +2508,7 @@ function Ls(t, e) {
2507
2508
  }
2508
2509
  return s;
2509
2510
  }
2510
- function Fs(t) {
2511
+ function Ns(t) {
2511
2512
  if (Array.isArray(t))
2512
2513
  return t;
2513
2514
  const e = Object.entries(t);
@@ -2517,7 +2518,7 @@ function Fs(t) {
2517
2518
  );
2518
2519
  return e[0];
2519
2520
  }
2520
- function Ns(t, e, n) {
2521
+ function Ks(t, e, n) {
2521
2522
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2522
2523
  // before assuming it's a ref lookup.
2523
2524
  !E(t, e, n);
@@ -2528,8 +2529,8 @@ function Ye(t) {
2528
2529
  throw new Error(`${t} is not a valid lookup attribute.`);
2529
2530
  return e;
2530
2531
  }
2531
- function Ks(t, e, n) {
2532
- if (!Ns(t, e, n))
2532
+ function qs(t, e, n) {
2533
+ if (!Ks(t, e, n))
2533
2534
  return E(t, e, n);
2534
2535
  const r = Ye(n), s = E(t, e, r) || Z(t, e, r);
2535
2536
  if (s && s["value-type"] !== "ref")
@@ -2537,13 +2538,13 @@ function Ks(t, e, n) {
2537
2538
  return s;
2538
2539
  }
2539
2540
  function Ze(t) {
2540
- return typeof t == "string" && !Ee(t) ? null : typeof t == "string" && Ee(t) ? kn(t) : Fs(t);
2541
+ return typeof t == "string" && !Ee(t) ? null : typeof t == "string" && Ee(t) ? kn(t) : Ns(t);
2541
2542
  }
2542
2543
  function x(t, e, n) {
2543
2544
  const r = Ze(n);
2544
2545
  if (r === null)
2545
2546
  return n;
2546
- const [s, i] = r, o = Ks(t, e, s);
2547
+ const [s, i] = r, o = qs(t, e, s);
2547
2548
  if (!o || !o["unique?"])
2548
2549
  throw new Error(`${s} is not a unique attribute.`);
2549
2550
  return [o.id, i];
@@ -2558,7 +2559,7 @@ function In(t, e, n, r) {
2558
2559
  s
2559
2560
  ]].concat(r) : r;
2560
2561
  }
2561
- function qs({ attrsStore: t }, [e, n, r]) {
2562
+ function zs({ attrsStore: t }, [e, n, r]) {
2562
2563
  const s = Object.entries(r).flatMap(([i, o]) => {
2563
2564
  const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Z(t, e, i);
2564
2565
  return a.map((l) => c ? [
@@ -2579,7 +2580,7 @@ function qs({ attrsStore: t }, [e, n, r]) {
2579
2580
  });
2580
2581
  return In(t, e, n, s);
2581
2582
  }
2582
- function zs({ attrsStore: t }, [e, n, r]) {
2583
+ function Vs({ attrsStore: t }, [e, n, r]) {
2583
2584
  const s = Object.entries(r).flatMap(([i, o]) => {
2584
2585
  const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Z(t, e, i);
2585
2586
  return a.map((l) => c ? [
@@ -2600,7 +2601,7 @@ function zs({ attrsStore: t }, [e, n, r]) {
2600
2601
  });
2601
2602
  return In(t, e, n, s);
2602
2603
  }
2603
- function Vs(t, e, n, r) {
2604
+ function Ws(t, e, n, r) {
2604
2605
  var s;
2605
2606
  if (Array.isArray(r)) {
2606
2607
  const [i, o] = r;
@@ -2624,16 +2625,16 @@ function Vs(t, e, n, r) {
2624
2625
  return !1;
2625
2626
  }
2626
2627
  function Cn({ stores: t, attrsStore: e }, [n, r, s, i]) {
2627
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Vs(t, e, n, r) ? { mode: "update" } : null;
2628
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Ws(t, e, n, r) ? { mode: "update" } : null;
2628
2629
  }
2629
- function Ws(t, e) {
2630
+ function Qs(t, e) {
2630
2631
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s);
2631
2632
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
2632
2633
  const d = E(n, r, l);
2633
2634
  return d["checked-data-type"] === "date" && t.useDateObjects && (f = Ie(f)), ["add-triple", c, d.id, f, { mode: "create" }];
2634
2635
  });
2635
2636
  }
2636
- function Qs(t, e) {
2637
+ function Gs(t, e) {
2637
2638
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s), u = Cn(t, [r, c, i, o]);
2638
2639
  return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
2639
2640
  const h = E(n, r, f);
@@ -2646,10 +2647,10 @@ function Qs(t, e) {
2646
2647
  ];
2647
2648
  });
2648
2649
  }
2649
- function Gs({ attrsStore: t }, [e, n]) {
2650
+ function Bs({ attrsStore: t }, [e, n]) {
2650
2651
  return [["delete-entity", x(t, e, n), e]];
2651
2652
  }
2652
- function Bs(t, e) {
2653
+ function Hs(t, e) {
2653
2654
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s), u = Cn(t, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
2654
2655
  const p = E(n, r, d);
2655
2656
  return [
@@ -2668,38 +2669,38 @@ function Bs(t, e) {
2668
2669
  ...u ? [u] : []
2669
2670
  ]].concat(l);
2670
2671
  }
2671
- function Hs({ attrsStore: t }, [e, n, r]) {
2672
+ function Js({ attrsStore: t }, [e, n, r]) {
2672
2673
  return [["rule-params", x(t, e, n), e, r]];
2673
2674
  }
2674
- function Js(t) {
2675
+ function Ys(t) {
2675
2676
  const [e, n, r, s, i] = t;
2676
2677
  if (!s)
2677
2678
  return t;
2678
2679
  const o = { ...s };
2679
2680
  return delete o.id, [e, n, r, o, ...i ? [i] : []];
2680
2681
  }
2681
- function Ys(t, e) {
2682
- const [n, ...r] = Js(e);
2682
+ function Zs(t, e) {
2683
+ const [n, ...r] = Ys(e);
2683
2684
  switch (n) {
2684
2685
  case "merge":
2685
- return Bs(t, r);
2686
+ return Hs(t, r);
2686
2687
  case "create":
2687
- return Ws(t, r);
2688
- case "update":
2689
2688
  return Qs(t, r);
2689
+ case "update":
2690
+ return Gs(t, r);
2690
2691
  case "link":
2691
- return qs(t, r);
2692
- case "unlink":
2693
2692
  return zs(t, r);
2693
+ case "unlink":
2694
+ return Vs(t, r);
2694
2695
  case "delete":
2695
- return Gs(t, r);
2696
+ return Bs(t, r);
2696
2697
  case "ruleParams":
2697
- return Hs(t, r);
2698
+ return Js(t, r);
2698
2699
  default:
2699
2700
  throw new Error(`unsupported action ${n}`);
2700
2701
  }
2701
2702
  }
2702
- function Zs(t) {
2703
+ function Xs(t) {
2703
2704
  switch (t) {
2704
2705
  case "string":
2705
2706
  case "date":
@@ -2710,13 +2711,13 @@ function Zs(t) {
2710
2711
  return;
2711
2712
  }
2712
2713
  }
2713
- function Xs(t, e, n) {
2714
+ function ei(t, e, n) {
2714
2715
  var a, c;
2715
2716
  const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
2716
2717
  if (n === "id") return null;
2717
2718
  if (!r)
2718
2719
  throw new Error(`${e}.${n} does not exist in your schema`);
2719
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Zs(r == null ? void 0 : r.valueType);
2720
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Xs(r == null ? void 0 : r.valueType);
2720
2721
  return {
2721
2722
  "index?": i,
2722
2723
  "unique?": s,
@@ -2724,7 +2725,7 @@ function Xs(t, e, n) {
2724
2725
  };
2725
2726
  }
2726
2727
  function be(t, e, n, r) {
2727
- const s = t ? Xs(t, e, n) : null, i = I(), a = [I(), e, n];
2728
+ const s = t ? ei(t, e, n) : null, i = I(), a = [I(), e, n];
2728
2729
  return {
2729
2730
  id: i,
2730
2731
  "forward-identity": a,
@@ -2737,11 +2738,11 @@ function be(t, e, n, r) {
2737
2738
  ...r || {}
2738
2739
  };
2739
2740
  }
2740
- function ei(t, e, n) {
2741
+ function ti(t, e, n) {
2741
2742
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2742
2743
  }
2743
- function ti(t, e, n) {
2744
- const r = ei(t, e, n);
2744
+ function ni(t, e, n) {
2745
+ const r = ti(t, e, n);
2745
2746
  if (!r)
2746
2747
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2747
2748
  const { forward: s, reverse: i } = r;
@@ -2755,7 +2756,7 @@ function ti(t, e, n) {
2755
2756
  };
2756
2757
  }
2757
2758
  function $t(t, e, n, r) {
2758
- const s = t ? ti(t, e, n) : null, i = I(), o = [I(), e, n], a = [I(), n, e];
2759
+ const s = t ? ni(t, e, n) : null, i = I(), o = [I(), e, n], a = [I(), n, e];
2759
2760
  return {
2760
2761
  id: i,
2761
2762
  // @ts-ignore: ts thinks it's any[]
@@ -2772,7 +2773,7 @@ function $t(t, e, n, r) {
2772
2773
  ...r || {}
2773
2774
  };
2774
2775
  }
2775
- const ni = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ri = /* @__PURE__ */ new Set(["link", "unlink"]), si = /* @__PURE__ */ new Set(["create", "update", "merge"]), ii = /* @__PURE__ */ new Set([
2776
+ const ri = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), si = /* @__PURE__ */ new Set(["link", "unlink"]), ii = /* @__PURE__ */ new Set(["create", "update", "merge"]), oi = /* @__PURE__ */ new Set([
2776
2777
  "link",
2777
2778
  "unlink",
2778
2779
  "create",
@@ -2780,13 +2781,13 @@ const ni = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2780
2781
  "merge",
2781
2782
  "delete",
2782
2783
  "ruleParams"
2783
- ]), Xe = { "unique?": !0, "index?": !0 }, oi = {
2784
+ ]), Xe = { "unique?": !0, "index?": !0 }, ai = {
2784
2785
  ...Xe,
2785
2786
  cardinality: "one"
2786
2787
  };
2787
- function ai(t) {
2788
+ function ci(t) {
2788
2789
  const e = [], [n, r, s, i] = t;
2789
- if (!ii.has(n))
2790
+ if (!oi.has(n))
2790
2791
  return e;
2791
2792
  const o = Ze(s);
2792
2793
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -2803,7 +2804,7 @@ function ai(t) {
2803
2804
  }
2804
2805
  return e;
2805
2806
  }
2806
- function ci({ attrsStore: t, schema: e }, n) {
2807
+ function ui({ attrsStore: t, schema: e }, n) {
2807
2808
  var d, h;
2808
2809
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2809
2810
  function o(p, y) {
@@ -2832,10 +2833,10 @@ function ci({ attrsStore: t, schema: e }, n) {
2832
2833
  }
2833
2834
  function f(p, y) {
2834
2835
  const b = o(p, y), g = a(p, y);
2835
- u(b), u(g), !b && !g && c($t(e, p, y, oi));
2836
+ u(b), u(g), !b && !g && c($t(e, p, y, ai));
2836
2837
  }
2837
2838
  for (const p of n)
2838
- for (const { etype: y, lookupPair: b, linkLabel: g } of ai(p)) {
2839
+ for (const { etype: y, lookupPair: b, linkLabel: g } of ci(p)) {
2839
2840
  const _ = b[0];
2840
2841
  if (g) {
2841
2842
  f(y, g);
@@ -2859,19 +2860,19 @@ function ci({ attrsStore: t, schema: e }, n) {
2859
2860
  }
2860
2861
  for (const p of n) {
2861
2862
  const [y, b, g, _] = p;
2862
- if (ni.has(y)) {
2863
+ if (ri.has(y)) {
2863
2864
  const T = o(b, "id");
2864
2865
  u(T), T || c(be(e, b, "id", { "unique?": !0 }));
2865
2866
  for (const A of Object.keys(_)) {
2866
2867
  const m = o(b, A);
2867
- if (u(m), si.has(y) && (m || c(
2868
+ if (u(m), ii.has(y) && (m || c(
2868
2869
  be(
2869
2870
  e,
2870
2871
  b,
2871
2872
  A,
2872
2873
  A === "id" ? { "unique?": !0 } : null
2873
2874
  )
2874
- )), ri.has(y)) {
2875
+ )), si.has(y)) {
2875
2876
  const O = a(b, A);
2876
2877
  !m && !O && c($t(e, b, A)), u(O);
2877
2878
  }
@@ -2886,15 +2887,15 @@ function ci({ attrsStore: t, schema: e }, n) {
2886
2887
  }
2887
2888
  return [t, i];
2888
2889
  }
2889
- function ui(t, e) {
2890
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Us(c)), [s, i] = ci(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Ys(o, c));
2890
+ function li(t, e) {
2891
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Ls(c)), [s, i] = ui(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Zs(o, c));
2891
2892
  return [...i, ...a];
2892
2893
  }
2893
2894
  function Dt(t, e) {
2894
2895
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2895
2896
  }
2896
2897
  const le = "__meta";
2897
- class li {
2898
+ class fi {
2898
2899
  constructor(e, n) {
2899
2900
  }
2900
2901
  }
@@ -3127,13 +3128,13 @@ class et {
3127
3128
  };
3128
3129
  }
3129
3130
  }
3130
- const fi = 6, di = ["kv", "querySubs", "syncSubs"];
3131
- function hi(t) {
3131
+ const di = 6, hi = ["kv", "querySubs", "syncSubs"];
3132
+ function pi(t) {
3132
3133
  return function(n) {
3133
3134
  console.error("Error in IndexedDB event", { source: t, event: n });
3134
3135
  };
3135
3136
  }
3136
- async function pi(t) {
3137
+ async function yi(t) {
3137
3138
  return new Promise((e) => {
3138
3139
  const n = indexedDB.open(t);
3139
3140
  n.onerror = (r) => {
@@ -3147,7 +3148,7 @@ async function pi(t) {
3147
3148
  };
3148
3149
  });
3149
3150
  }
3150
- async function yi(t, e, n) {
3151
+ async function bi(t, e, n) {
3151
3152
  const r = (
3152
3153
  // Backwards compatibility for older versions where we JSON.stringified before storing
3153
3154
  typeof e == "string" ? JSON.parse(e) : e
@@ -3187,8 +3188,8 @@ async function Rt(t, e, n) {
3187
3188
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3188
3189
  });
3189
3190
  }
3190
- async function bi(t, e) {
3191
- const n = await pi(`instant_${t}_5`);
3191
+ async function _i(t, e) {
3192
+ const n = await yi(`instant_${t}_5`);
3192
3193
  if (!n)
3193
3194
  return;
3194
3195
  const r = await new Promise((l, f) => {
@@ -3211,7 +3212,7 @@ async function bi(t, e) {
3211
3212
  for (const [l, f] of r)
3212
3213
  switch (l) {
3213
3214
  case "querySubs": {
3214
- const d = yi(l, f, o);
3215
+ const d = bi(l, f, o);
3215
3216
  a.push(d);
3216
3217
  break;
3217
3218
  }
@@ -3233,9 +3234,9 @@ async function bi(t, e) {
3233
3234
  });
3234
3235
  }
3235
3236
  const xt = /* @__PURE__ */ new Map();
3236
- class Mn extends li {
3237
+ class Mn extends fi {
3237
3238
  constructor(e, n) {
3238
- super(e, n), this.dbName = `instant_${e}_${fi}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3239
+ super(e, n), this.dbName = `instant_${e}_${di}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3239
3240
  }
3240
3241
  _init() {
3241
3242
  return new Promise((e, n) => {
@@ -3246,8 +3247,8 @@ class Mn extends li {
3246
3247
  }, s.onsuccess = (i) => {
3247
3248
  const a = i.target.result;
3248
3249
  if (r) {
3249
- const c = bi(this._appId, a).catch((u) => {
3250
- hi("Error upgrading store from version 5 to 6.")(u);
3250
+ const c = _i(this._appId, a).catch((u) => {
3251
+ pi("Error upgrading store from version 5 to 6.")(u);
3251
3252
  });
3252
3253
  xt.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
3253
3254
  } else {
@@ -3261,7 +3262,7 @@ class Mn extends li {
3261
3262
  }
3262
3263
  _upgradeStore(e) {
3263
3264
  const r = e.target.result;
3264
- for (const s of di)
3265
+ for (const s of hi)
3265
3266
  r.objectStoreNames.contains(s) || r.createObjectStore(s);
3266
3267
  }
3267
3268
  async getItem(e) {
@@ -3367,7 +3368,7 @@ async function z(t, e) {
3367
3368
  const n = await fetch(t, e), r = await n.json();
3368
3369
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Me({ status: n.status, body: r }));
3369
3370
  }
3370
- function _i({
3371
+ function gi({
3371
3372
  apiURI: t,
3372
3373
  appId: e,
3373
3374
  email: n
@@ -3378,7 +3379,7 @@ function _i({
3378
3379
  body: JSON.stringify({ "app-id": e, email: n })
3379
3380
  });
3380
3381
  }
3381
- async function gi({
3382
+ async function wi({
3382
3383
  apiURI: t,
3383
3384
  appId: e,
3384
3385
  email: n,
@@ -3396,7 +3397,7 @@ async function gi({
3396
3397
  })
3397
3398
  });
3398
3399
  }
3399
- async function wi({
3400
+ async function Ti({
3400
3401
  apiURI: t,
3401
3402
  appId: e,
3402
3403
  refreshToken: n
@@ -3410,7 +3411,7 @@ async function wi({
3410
3411
  })
3411
3412
  });
3412
3413
  }
3413
- async function Ti({
3414
+ async function mi({
3414
3415
  apiURI: t,
3415
3416
  appId: e
3416
3417
  }) {
@@ -3440,7 +3441,7 @@ async function Ut({
3440
3441
  })
3441
3442
  });
3442
3443
  }
3443
- async function mi({
3444
+ async function Si({
3444
3445
  apiURI: t,
3445
3446
  appId: e,
3446
3447
  nonce: n,
@@ -3460,7 +3461,7 @@ async function mi({
3460
3461
  })
3461
3462
  });
3462
3463
  }
3463
- async function Si({
3464
+ async function Ai({
3464
3465
  apiURI: t,
3465
3466
  appId: e,
3466
3467
  refreshToken: n
@@ -3476,7 +3477,7 @@ async function Si({
3476
3477
  })
3477
3478
  });
3478
3479
  }
3479
- async function Ai({
3480
+ async function vi({
3480
3481
  apiURI: t,
3481
3482
  appId: e,
3482
3483
  path: n,
@@ -3497,7 +3498,7 @@ async function Ai({
3497
3498
  body: r
3498
3499
  });
3499
3500
  }
3500
- async function vi({
3501
+ async function Oi({
3501
3502
  apiURI: t,
3502
3503
  appId: e,
3503
3504
  path: n,
@@ -3515,7 +3516,7 @@ async function vi({
3515
3516
  );
3516
3517
  return s;
3517
3518
  }
3518
- async function Oi({
3519
+ async function ki({
3519
3520
  apiURI: t,
3520
3521
  appId: e,
3521
3522
  fileName: n,
@@ -3535,7 +3536,7 @@ async function Oi({
3535
3536
  });
3536
3537
  return i;
3537
3538
  }
3538
- async function ki(t, e) {
3539
+ async function Ei(t, e) {
3539
3540
  return (await fetch(t, {
3540
3541
  method: "PUT",
3541
3542
  body: e,
@@ -3544,7 +3545,7 @@ async function ki(t, e) {
3544
3545
  }
3545
3546
  })).ok;
3546
3547
  }
3547
- async function Ei({
3548
+ async function Ii({
3548
3549
  apiURI: t,
3549
3550
  appId: e,
3550
3551
  path: n,
@@ -3573,7 +3574,7 @@ function Lt(t, e) {
3573
3574
  n[r] = t[r];
3574
3575
  }), n;
3575
3576
  }
3576
- function Ii(t, e, n) {
3577
+ function Ci(t, e, n) {
3577
3578
  const r = {
3578
3579
  peers: {}
3579
3580
  };
@@ -3590,7 +3591,7 @@ function Ii(t, e, n) {
3590
3591
  }
3591
3592
  return r;
3592
3593
  }
3593
- function Ci(t, e) {
3594
+ function Mi(t, e) {
3594
3595
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !At(t.user, e.user)) || !an(t.peers, e.peers)) return !0;
3595
3596
  for (const r of Object.keys(t.peers))
3596
3597
  if (!At(t.peers[r], e.peers[r])) return !0;
@@ -3639,8 +3640,8 @@ function Kt(t) {
3639
3640
  }, e;
3640
3641
  }, {});
3641
3642
  }
3642
- const Rn = "v0.22.89-experimental.split-store.20276199573.1";
3643
- function Mi(t, e) {
3643
+ const Rn = "v0.22.89-experimental.uuidfix.20281951052.1";
3644
+ function Pi(t, e) {
3644
3645
  return {
3645
3646
  info: t ? (...n) => console.info(...n, e()) : () => {
3646
3647
  },
@@ -3760,7 +3761,7 @@ const qt = [
3760
3761
  "before",
3761
3762
  "fields",
3762
3763
  "aggregate"
3763
- ], Pi = (t) => t.valueType || "unknown", xn = (t, e, n = !1) => {
3764
+ ], ji = (t) => t.valueType || "unknown", xn = (t, e, n = !1) => {
3764
3765
  if (n || t == null) return !0;
3765
3766
  switch (e) {
3766
3767
  case "string":
@@ -3774,7 +3775,7 @@ const qt = [
3774
3775
  default:
3775
3776
  return !0;
3776
3777
  }
3777
- }, ji = (t, e, n, r, s, i, o) => {
3778
+ }, $i = (t, e, n, r, s, i, o) => {
3778
3779
  const a = i.valueType === "json", c = (u, l, f) => {
3779
3780
  if (!xn(f, l, a))
3780
3781
  throw new v(
@@ -3819,13 +3820,13 @@ const qt = [
3819
3820
  );
3820
3821
  }
3821
3822
  }, ee = (t, e, n, r, s) => {
3822
- const i = Pi(n), o = n.valueType === "json";
3823
+ const i = ji(n), o = n.valueType === "json";
3823
3824
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3824
3825
  if (o)
3825
3826
  return;
3826
3827
  const c = t;
3827
3828
  for (const [u, l] of Object.entries(c))
3828
- ji(
3829
+ $i(
3829
3830
  u,
3830
3831
  l,
3831
3832
  i,
@@ -3839,7 +3840,7 @@ const qt = [
3839
3840
  `Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`,
3840
3841
  s
3841
3842
  );
3842
- }, $i = (t, e, n, r, s) => {
3843
+ }, Di = (t, e, n, r, s) => {
3843
3844
  const i = t.split(".");
3844
3845
  if (i.length < 2)
3845
3846
  throw new v(
@@ -3933,7 +3934,7 @@ const qt = [
3933
3934
  continue;
3934
3935
  }
3935
3936
  if (s.includes(".")) {
3936
- $i(
3937
+ Di(
3937
3938
  s,
3938
3939
  i,
3939
3940
  e,
@@ -3976,7 +3977,7 @@ const qt = [
3976
3977
  );
3977
3978
  }
3978
3979
  }
3979
- }, Di = (t, e, n, r, s = 0) => {
3980
+ }, Ri = (t, e, n, r, s = 0) => {
3980
3981
  for (const o of Object.keys(t))
3981
3982
  if (!qt.includes(o))
3982
3983
  throw new v(
@@ -4044,7 +4045,7 @@ const qt = [
4044
4045
  `Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`,
4045
4046
  `${r}.$`
4046
4047
  );
4047
- Di(
4048
+ Ri(
4048
4049
  a,
4049
4050
  e,
4050
4051
  n,
@@ -4097,7 +4098,7 @@ class N extends Error {
4097
4098
  super(e), this.name = "TransactionValidationError";
4098
4099
  }
4099
4100
  }
4100
- const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4101
+ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4101
4102
  `Entity '${t}' does not exist in schema. Available entities: ${Fn(e)}`
4102
4103
  ), xe = {
4103
4104
  string: (t) => typeof t == "string",
@@ -4105,13 +4106,13 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4105
4106
  boolean: (t) => typeof t == "boolean",
4106
4107
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4107
4108
  json: () => !0
4108
- }, xi = (t, e) => {
4109
+ }, Ui = (t, e) => {
4109
4110
  var n;
4110
4111
  return t == null ? !0 : ((n = xe[e.valueType]) == null ? void 0 : n.call(xe, t)) ?? !1;
4111
4112
  }, Nn = (t, e) => {
4112
4113
  const n = e.entities[t];
4113
4114
  if (!n)
4114
- throw Ri(t, Object.keys(e.entities));
4115
+ throw xi(t, Object.keys(e.entities));
4115
4116
  return n;
4116
4117
  }, Ue = (t, e, n) => {
4117
4118
  const r = Nn(t, n);
@@ -4122,7 +4123,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4122
4123
  for (const [s, i] of Object.entries(e)) {
4123
4124
  if (s === "id") continue;
4124
4125
  const o = r.attrs[s];
4125
- if (o && !xi(i, o))
4126
+ if (o && !Ui(i, o))
4126
4127
  throw new N(
4127
4128
  `Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`
4128
4129
  );
@@ -4153,7 +4154,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4153
4154
  );
4154
4155
  }
4155
4156
  }
4156
- }, Ui = {
4157
+ }, Li = {
4157
4158
  create: Ue,
4158
4159
  update: Ue,
4159
4160
  merge: Ue,
@@ -4161,7 +4162,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4161
4162
  unlink: Wt,
4162
4163
  delete: () => {
4163
4164
  }
4164
- }, Li = (t, e) => {
4165
+ }, Fi = (t, e) => {
4165
4166
  if (!e) return;
4166
4167
  const [n, r, s, i] = t;
4167
4168
  if (!Array.isArray(s) && !te(s))
@@ -4172,9 +4173,9 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4172
4173
  throw new N(
4173
4174
  `Entity name must be a string, but received: ${typeof r}`
4174
4175
  );
4175
- const o = Ui[n];
4176
+ const o = Li[n];
4176
4177
  o && i !== void 0 && o(r, i, e);
4177
- }, Fi = (t, e) => {
4178
+ }, Ni = (t, e) => {
4178
4179
  const n = Array.isArray(t) ? t : [t];
4179
4180
  for (const r of n) {
4180
4181
  if (!r || typeof r != "object")
@@ -4190,7 +4191,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4190
4191
  throw new N(
4191
4192
  `Transaction operation must be an array, but received: ${typeof s}`
4192
4193
  );
4193
- Li(s, e);
4194
+ Fi(s, e);
4194
4195
  }
4195
4196
  }
4196
4197
  };
@@ -4223,7 +4224,7 @@ class Qt {
4223
4224
  return this.conn.send(JSON.stringify(e));
4224
4225
  }
4225
4226
  }
4226
- class Ni {
4227
+ class Ki {
4227
4228
  constructor(e, n) {
4228
4229
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Kn++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4229
4230
  this.initParams || this.handleError();
@@ -4306,7 +4307,7 @@ class Ni {
4306
4307
  this.handleClose();
4307
4308
  }
4308
4309
  }
4309
- function Ki(t, e) {
4310
+ function qi(t, e) {
4310
4311
  const n = t.values;
4311
4312
  if (n) {
4312
4313
  const r = hn(n.attrsStore, null);
@@ -4318,7 +4319,7 @@ function Ki(t, e) {
4318
4319
  }
4319
4320
  return t;
4320
4321
  }
4321
- function qi(t, e) {
4322
+ function zi(t, e) {
4322
4323
  var n;
4323
4324
  if (e.values) {
4324
4325
  const r = [];
@@ -4333,7 +4334,7 @@ function qi(t, e) {
4333
4334
  } else
4334
4335
  return e;
4335
4336
  }
4336
- function zi(t, e, n) {
4337
+ function Vi(t, e, n) {
4337
4338
  var i, o;
4338
4339
  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;
4339
4340
  return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
@@ -4363,7 +4364,7 @@ function Bt(t, e, n) {
4363
4364
  break;
4364
4365
  }
4365
4366
  }
4366
- function Vi(t, e, n) {
4367
+ function Wi(t, e, n) {
4367
4368
  var s, i;
4368
4369
  const r = {};
4369
4370
  for (const { action: o, triple: a } of n) {
@@ -4390,14 +4391,14 @@ function Vi(t, e, n) {
4390
4391
  function _e(t, e) {
4391
4392
  return { [t.table]: e.map((n) => n.entity) };
4392
4393
  }
4393
- function Wi(t, e) {
4394
+ function Qi(t, e) {
4394
4395
  var r;
4395
4396
  if (t.orderFieldType)
4396
4397
  return t.orderFieldType;
4397
4398
  const n = t.orderField === "serverCreatedAt" ? "number" : (r = E(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
4398
4399
  return t.orderFieldType = n, n;
4399
4400
  }
4400
- function Qi(t, e, n) {
4401
+ function Gi(t, e, n) {
4401
4402
  const r = e;
4402
4403
  if (t.orderField === "serverCreatedAt") {
4403
4404
  n.sort(
@@ -4442,14 +4443,14 @@ function Qi(t, e, n) {
4442
4443
  }
4443
4444
  );
4444
4445
  }
4445
- var Gi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Gi || {});
4446
- class Bi {
4446
+ var Bi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Bi || {});
4447
+ class Hi {
4447
4448
  constructor(e, n, r, s, i, o) {
4448
4449
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new et({
4449
4450
  persister: n,
4450
- merge: zi,
4451
- serialize: qi,
4452
- parse: (a, c) => Ki(c, this.config.useDateObjects),
4451
+ merge: Vi,
4452
+ serialize: zi,
4453
+ parse: (a, c) => qi(c, this.config.useDateObjects),
4453
4454
  objectSize: (a) => {
4454
4455
  var c;
4455
4456
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4661,7 +4662,7 @@ class Bi {
4661
4662
  const T = f[_];
4662
4663
  if (Er(T.store, b)) {
4663
4664
  Bt(T.store, l.attrsStore, g);
4664
- const A = Le(s, T.store, l.attrsStore), m = Vi(
4665
+ const A = Le(s, T.store, l.attrsStore), m = Wi(
4665
4666
  T.store,
4666
4667
  l.attrsStore,
4667
4668
  g
@@ -4701,8 +4702,8 @@ class Bi {
4701
4702
  const p = [];
4702
4703
  for (const b of c.sort().reverse())
4703
4704
  p.push(f[b].entity), f.splice(b, 1);
4704
- const y = Wi(s, this.getAttrs);
4705
- Qi(s, y, f), this.notifyCbs(r, {
4705
+ const y = Qi(s, this.getAttrs);
4706
+ Gi(s, y, f), this.notifyCbs(r, {
4706
4707
  type: "SyncTransaction",
4707
4708
  data: _e(s, (o = s.values) == null ? void 0 : o.entities),
4708
4709
  added: h,
@@ -4749,11 +4750,11 @@ const W = {
4749
4750
  AUTHENTICATED: "authenticated",
4750
4751
  CLOSED: "closed",
4751
4752
  ERRORED: "errored"
4752
- }, Hi = 3e4, Ji = 3e4, Yi = 200, Zi = {
4753
+ }, Ji = 3e4, Yi = 3e4, Zi = 200, Xi = {
4753
4754
  apiURI: "https://api.instantdb.com",
4754
4755
  websocketURI: "wss://api.instantdb.com/runtime/session"
4755
4756
  }, Fe = "_instant_oauth_redirect", se = "currentUser";
4756
- function Xi({
4757
+ function eo({
4757
4758
  transportType: t,
4758
4759
  appId: e,
4759
4760
  apiURI: n,
@@ -4766,7 +4767,7 @@ function Xi({
4766
4767
  case "ws":
4767
4768
  return new Qt(`${r}?app_id=${e}`);
4768
4769
  case "sse":
4769
- return new Ni(
4770
+ return new Ki(
4770
4771
  s,
4771
4772
  `${n}/runtime/sse?app_id=${e}`
4772
4773
  );
@@ -4774,7 +4775,7 @@ function Xi({
4774
4775
  throw new Error("Unknown transport type " + t);
4775
4776
  }
4776
4777
  }
4777
- function eo() {
4778
+ function to() {
4778
4779
  return typeof window < "u" || typeof chrome < "u";
4779
4780
  }
4780
4781
  const Ht = {
@@ -4783,7 +4784,7 @@ const Ht = {
4783
4784
  "refresh-presence": !0,
4784
4785
  "patch-presence": !0
4785
4786
  };
4786
- function to(t, e) {
4787
+ function no(t, e) {
4787
4788
  var r;
4788
4789
  const n = typeof t == "string" ? JSON.parse(t) : t;
4789
4790
  if ((r = n == null ? void 0 : n.result) != null && r.store) {
@@ -4801,7 +4802,7 @@ function to(t, e) {
4801
4802
  }
4802
4803
  return n;
4803
4804
  }
4804
- function no(t, e) {
4805
+ function ro(t, e) {
4805
4806
  const { result: n, ...r } = e, s = (
4806
4807
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
4807
4808
  r
@@ -4816,7 +4817,7 @@ function no(t, e) {
4816
4817
  }
4817
4818
  return s;
4818
4819
  }
4819
- function ro(t, e) {
4820
+ function so(t, e) {
4820
4821
  switch (t) {
4821
4822
  case "pendingMutations":
4822
4823
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4824,7 +4825,7 @@ function ro(t, e) {
4824
4825
  return e;
4825
4826
  }
4826
4827
  }
4827
- function so(t, e) {
4828
+ function io(t, e) {
4828
4829
  switch (t) {
4829
4830
  case "pendingMutations":
4830
4831
  return [...e.entries()];
@@ -4832,7 +4833,7 @@ function so(t, e) {
4832
4833
  return e;
4833
4834
  }
4834
4835
  }
4835
- function io(t, e, n) {
4836
+ function oo(t, e, n) {
4836
4837
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
4837
4838
  return r && !s && n && (n.result = r), n || e;
4838
4839
  }
@@ -4842,7 +4843,7 @@ function Jt(t) {
4842
4843
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
4843
4844
  });
4844
4845
  }
4845
- class oo {
4846
+ class ao {
4846
4847
  constructor(e, n = Mn, r = Pn, s, i) {
4847
4848
  /** @type {s.AttrsStore | undefined} */
4848
4849
  w(this, "attrs");
@@ -4937,9 +4938,9 @@ class oo {
4937
4938
  });
4938
4939
  /** Applies transactions locally and sends transact message to server */
4939
4940
  w(this, "pushTx", (e) => {
4940
- this.config.disableValidation || Fi(e, this.config.schema);
4941
+ this.config.disableValidation || Ni(e, this.config.schema);
4941
4942
  try {
4942
- const n = ui(
4943
+ const n = li(
4943
4944
  {
4944
4945
  attrsStore: this.optimisticAttrs(),
4945
4946
  schema: this.config.schema,
@@ -5078,10 +5079,10 @@ class oo {
5078
5079
  this._reconnectTimeoutMs
5079
5080
  ), this._scheduleReconnect();
5080
5081
  });
5081
- if (this._EventSource = i, this.config = { ...Zi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ji, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Yi, this._log = Mi(
5082
+ if (this._EventSource = i, this.config = { ...Xi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Yi, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Zi, this._log = Pi(
5082
5083
  e.verbose || pt || jn,
5083
5084
  () => this._reactorStats()
5084
- ), this.versions = { ...s || {}, "@instantdb/core": Rn }, this.config.schema && (this._linkIndex = Kt(this.config.schema)), !!eo()) {
5085
+ ), this.versions = { ...s || {}, "@instantdb/core": Rn }, this.config.schema && (this._linkIndex = Kt(this.config.schema)), !!to()) {
5085
5086
  if (!e.appId)
5086
5087
  throw new Error("Instant must be initialized with an appId.");
5087
5088
  if (!te(e.appId))
@@ -5098,7 +5099,7 @@ class oo {
5098
5099
  } catch (c) {
5099
5100
  this._log.error("[error] handle broadcast channel", c);
5100
5101
  }
5101
- })), this._initStorage(n), this._syncTable = new Bi(
5102
+ })), this._initStorage(n), this._syncTable = new Hi(
5102
5103
  this._trySendAuthed.bind(this),
5103
5104
  new n(this.config.appId, "syncSubs"),
5104
5105
  {
@@ -5149,9 +5150,9 @@ class oo {
5149
5150
  _initStorage(e) {
5150
5151
  this.querySubs = new et({
5151
5152
  persister: new e(this.config.appId, "querySubs"),
5152
- merge: io,
5153
- serialize: no,
5154
- parse: (n, r) => to(r, this.config.useDateObjects),
5153
+ merge: oo,
5154
+ serialize: ro,
5155
+ parse: (n, r) => no(r, this.config.useDateObjects),
5155
5156
  // objectSize
5156
5157
  objectSize: (n) => {
5157
5158
  var r, s, i;
@@ -5170,8 +5171,8 @@ class oo {
5170
5171
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new et({
5171
5172
  persister: new e(this.config.appId, "kv"),
5172
5173
  merge: this._onMergeKv,
5173
- serialize: so,
5174
- parse: ro,
5174
+ serialize: io,
5175
+ parse: so,
5175
5176
  objectSize: () => 0,
5176
5177
  logger: this._log,
5177
5178
  saveThrottleMs: 100,
@@ -5529,7 +5530,7 @@ class oo {
5529
5530
  const s = P(e), i = this._startQuerySub(e, s);
5530
5531
  return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
5531
5532
  () => r.reject(new Error("Query timed out")),
5532
- Hi
5533
+ Ji
5533
5534
  ), r.promise;
5534
5535
  }
5535
5536
  _completeQueryOnce(e, n, r) {
@@ -5597,7 +5598,7 @@ class oo {
5597
5598
  a = !0;
5598
5599
  continue;
5599
5600
  }
5600
- const y = a ? Ls(o, h) : h;
5601
+ const y = a ? Fs(o, h) : h;
5601
5602
  d.push(y);
5602
5603
  }
5603
5604
  return a ? d : l;
@@ -5786,7 +5787,7 @@ class oo {
5786
5787
  return;
5787
5788
  }
5788
5789
  const e = this._transport;
5789
- this._transport = Xi({
5790
+ this._transport = eo({
5790
5791
  transportType: this._transportType,
5791
5792
  appId: this.config.appId,
5792
5793
  apiURI: this.config.apiURI,
@@ -5980,7 +5981,7 @@ class oo {
5980
5981
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5981
5982
  }
5982
5983
  sendMagicCode({ email: e }) {
5983
- return _i({
5984
+ return gi({
5984
5985
  apiURI: this.config.apiURI,
5985
5986
  appId: this.config.appId,
5986
5987
  email: e
@@ -5988,7 +5989,7 @@ class oo {
5988
5989
  }
5989
5990
  async signInWithMagicCode({ email: e, code: n }) {
5990
5991
  var o;
5991
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await gi({
5992
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await wi({
5992
5993
  apiURI: this.config.apiURI,
5993
5994
  appId: this.config.appId,
5994
5995
  email: e,
@@ -5998,7 +5999,7 @@ class oo {
5998
5999
  return await this.changeCurrentUser(i.user), i;
5999
6000
  }
6000
6001
  async signInWithCustomToken(e) {
6001
- const n = await wi({
6002
+ const n = await Ti({
6002
6003
  apiURI: this.config.apiURI,
6003
6004
  appId: this.config.appId,
6004
6005
  refreshToken: e
@@ -6006,7 +6007,7 @@ class oo {
6006
6007
  return await this.changeCurrentUser(n.user), n;
6007
6008
  }
6008
6009
  async signInAsGuest() {
6009
- const e = await Ti({
6010
+ const e = await mi({
6010
6011
  apiURI: this.config.apiURI,
6011
6012
  appId: this.config.appId
6012
6013
  });
@@ -6021,7 +6022,7 @@ class oo {
6021
6022
  this._log.info("[auth-invalidate] skipped invalidateToken");
6022
6023
  return;
6023
6024
  }
6024
- Si({
6025
+ Ai({
6025
6026
  apiURI: this.config.apiURI,
6026
6027
  appId: this.config.appId,
6027
6028
  refreshToken: r
@@ -6074,7 +6075,7 @@ class oo {
6074
6075
  */
6075
6076
  async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
6076
6077
  var a;
6077
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await mi({
6078
+ const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await Si({
6078
6079
  apiURI: this.config.apiURI,
6079
6080
  appId: this.config.appId,
6080
6081
  idToken: e,
@@ -6115,7 +6116,7 @@ class oo {
6115
6116
  getPresence(e, n, r = {}) {
6116
6117
  const s = this._rooms[n], i = this._presence[n];
6117
6118
  return !s || !i || !i.result ? null : {
6118
- ...Ii(i.result, r, this._sessionId),
6119
+ ...Ci(i.result, r, this._sessionId),
6119
6120
  isLoading: !s.isConnected,
6120
6121
  error: s.error
6121
6122
  };
@@ -6171,7 +6172,7 @@ class oo {
6171
6172
  }
6172
6173
  _notifyPresenceSub(e, n) {
6173
6174
  const r = this.getPresence("", e, n);
6174
- r && (n.prev && !Ci(r, n.prev) || (n.prev = r, n.cb(r)));
6175
+ r && (n.prev && !Mi(r, n.prev) || (n.prev = r, n.cb(r)));
6175
6176
  }
6176
6177
  _patchPresencePeers(e, n) {
6177
6178
  var o, a, c;
@@ -6247,7 +6248,7 @@ class oo {
6247
6248
  async uploadFile(e, n, r) {
6248
6249
  var o;
6249
6250
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
6250
- return Ai({
6251
+ return vi({
6251
6252
  ...r,
6252
6253
  apiURI: this.config.apiURI,
6253
6254
  appId: this.config.appId,
@@ -6259,7 +6260,7 @@ class oo {
6259
6260
  async deleteFile(e) {
6260
6261
  var i;
6261
6262
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6262
- return await vi({
6263
+ return await Oi({
6263
6264
  apiURI: this.config.apiURI,
6264
6265
  appId: this.config.appId,
6265
6266
  path: e,
@@ -6270,18 +6271,18 @@ class oo {
6270
6271
  // ---------------------------------
6271
6272
  async upload(e, n) {
6272
6273
  var c;
6273
- 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 Oi({
6274
+ 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 ki({
6274
6275
  apiURI: this.config.apiURI,
6275
6276
  appId: this.config.appId,
6276
6277
  fileName: i,
6277
6278
  refreshToken: s
6278
6279
  });
6279
- return await ki(o, n);
6280
+ return await Ei(o, n);
6280
6281
  }
6281
6282
  async getDownloadUrl(e) {
6282
6283
  var i;
6283
6284
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6284
- return await Ei({
6285
+ return await Ii({
6285
6286
  apiURI: this.config.apiURI,
6286
6287
  appId: this.config.appId,
6287
6288
  path: e,
@@ -6289,7 +6290,7 @@ class oo {
6289
6290
  });
6290
6291
  }
6291
6292
  }
6292
- function ao(t, e) {
6293
+ function co(t, e) {
6293
6294
  return new je(
6294
6295
  qn(t, e),
6295
6296
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -6301,25 +6302,25 @@ function ao(t, e) {
6301
6302
  void 0
6302
6303
  );
6303
6304
  }
6304
- function co(t) {
6305
+ function uo(t) {
6305
6306
  return new Pe(t, {});
6306
6307
  }
6307
- function uo() {
6308
+ function lo() {
6308
6309
  return new $("string", !0, !1);
6309
6310
  }
6310
- function lo() {
6311
+ function fo() {
6311
6312
  return new $("number", !0, !1);
6312
6313
  }
6313
- function fo() {
6314
+ function ho() {
6314
6315
  return new $("boolean", !0, !1);
6315
6316
  }
6316
- function ho() {
6317
+ function po() {
6317
6318
  return new $("date", !0, !1);
6318
6319
  }
6319
- function po() {
6320
+ function yo() {
6320
6321
  return new $("json", !0, !1);
6321
6322
  }
6322
- function yo() {
6323
+ function bo() {
6323
6324
  return new $("json", !0, !1);
6324
6325
  }
6325
6326
  function qn(t, e) {
@@ -6343,7 +6344,7 @@ function qn(t, e) {
6343
6344
  ])
6344
6345
  );
6345
6346
  }
6346
- function bo({
6347
+ function _o({
6347
6348
  entities: t,
6348
6349
  links: e,
6349
6350
  rooms: n
@@ -6360,23 +6361,23 @@ function bo({
6360
6361
  s
6361
6362
  );
6362
6363
  }
6363
- const xo = {
6364
+ const Uo = {
6364
6365
  // constructs
6365
- graph: ao,
6366
- schema: bo,
6367
- entity: co,
6366
+ graph: co,
6367
+ schema: _o,
6368
+ entity: uo,
6368
6369
  // value types
6369
- string: uo,
6370
- number: lo,
6371
- boolean: fo,
6372
- date: ho,
6373
- json: po,
6374
- any: yo
6370
+ string: lo,
6371
+ number: fo,
6372
+ boolean: ho,
6373
+ date: po,
6374
+ json: yo,
6375
+ any: bo
6375
6376
  };
6376
6377
  let ge;
6377
- function _o(t, e) {
6378
+ function go(t, e) {
6378
6379
  ge == null || ge.dispose();
6379
- const n = Ao(e), r = To(e, a), s = wo(go(t));
6380
+ const n = vo(e), r = mo(e, a), s = To(wo(t));
6380
6381
  function i(l) {
6381
6382
  var f;
6382
6383
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
@@ -6398,10 +6399,10 @@ function _o(t, e) {
6398
6399
  }
6399
6400
  return u();
6400
6401
  }
6401
- function go(t) {
6402
+ function wo(t) {
6402
6403
  return `${pt || $n ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6403
6404
  }
6404
- function wo(t) {
6405
+ function To(t) {
6405
6406
  const e = document.createElement("iframe");
6406
6407
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6407
6408
  width: "100%",
@@ -6410,7 +6411,7 @@ function wo(t) {
6410
6411
  border: "none"
6411
6412
  }), { element: e };
6412
6413
  }
6413
- function To(t, e) {
6414
+ function mo(t, e) {
6414
6415
  const n = `
6415
6416
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6416
6417
  <rect width="512" height="512" fill="black"/>
@@ -6420,7 +6421,7 @@ function To(t, e) {
6420
6421
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
6421
6422
  // pos
6422
6423
  position: "fixed",
6423
- ...mo(t.position),
6424
+ ...So(t.position),
6424
6425
  height: "32px",
6425
6426
  width: "32px",
6426
6427
  // layout
@@ -6435,7 +6436,7 @@ function To(t, e) {
6435
6436
  cursor: "pointer"
6436
6437
  }), r.addEventListener("click", e), { element: r };
6437
6438
  }
6438
- function mo(t) {
6439
+ function So(t) {
6439
6440
  switch (t) {
6440
6441
  case "bottom-left":
6441
6442
  return { bottom: "24px", left: "24px" };
@@ -6447,7 +6448,7 @@ function mo(t) {
6447
6448
  return { top: "24px", left: "24px" };
6448
6449
  }
6449
6450
  }
6450
- function So(t) {
6451
+ function Ao(t) {
6451
6452
  switch (t) {
6452
6453
  case "bottom-left":
6453
6454
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6459,11 +6460,11 @@ function So(t) {
6459
6460
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6460
6461
  }
6461
6462
  }
6462
- function Ao(t) {
6463
+ function vo(t) {
6463
6464
  const e = document.createElement("div");
6464
6465
  Object.assign(e.style, {
6465
6466
  position: "fixed",
6466
- ...So(t.position),
6467
+ ...Ao(t.position),
6467
6468
  display: "block",
6468
6469
  borderRadius: "4px",
6469
6470
  border: "1px #ccc solid",
@@ -6476,37 +6477,37 @@ function Ao(t) {
6476
6477
  }
6477
6478
  return { element: e, isVisible: n };
6478
6479
  }
6479
- const vo = {
6480
+ const Oo = {
6480
6481
  apiURI: "https://api.instantdb.com",
6481
6482
  websocketURI: "wss://api.instantdb.com/runtime/session"
6482
6483
  };
6483
- function Oo() {
6484
+ function ko() {
6484
6485
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6485
6486
  }
6486
- function ko() {
6487
+ function Eo() {
6487
6488
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6488
6489
  }
6489
6490
  function tt(t) {
6490
6491
  const e = t.__adminToken;
6491
6492
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6492
6493
  }
6493
- const nt = ko(), Yt = Oo();
6494
- class Eo {
6494
+ const nt = Eo(), Yt = ko();
6495
+ class Io {
6495
6496
  constructor(e) {
6496
6497
  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);
6497
6498
  }
6498
6499
  }
6499
- class Io {
6500
+ class Co {
6500
6501
  constructor(e) {
6501
6502
  this.db = e, this.uploadFile = (n, r, s = {}) => this.db.uploadFile(n, r, s), 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);
6502
6503
  }
6503
6504
  }
6504
- function Uo(t) {
6505
+ function Lo(t) {
6505
6506
  return JSON.parse(JSON.stringify(t));
6506
6507
  }
6507
- class Co {
6508
+ class Mo {
6508
6509
  constructor(e) {
6509
- this.tx = En(), this._reactor = e, this.auth = new Eo(this._reactor), this.storage = new Io(this._reactor);
6510
+ this.tx = En(), this._reactor = e, this.auth = new Io(this._reactor), this.storage = new Co(this._reactor);
6510
6511
  }
6511
6512
  /**
6512
6513
  * Use this to write data! You can create, update, delete, and link objects
@@ -6689,19 +6690,19 @@ function Zt(t) {
6689
6690
  const n = P(t);
6690
6691
  return Yt.set(t, n), n;
6691
6692
  }
6692
- function Mo(t, e) {
6693
+ function Po(t, e) {
6693
6694
  return Zt(t._reactor.config.schema) !== Zt(e);
6694
6695
  }
6695
- function Po(t, e, n, r, s) {
6696
+ function jo(t, e, n, r, s) {
6696
6697
  const i = {
6697
6698
  ...t,
6698
6699
  useDateObjects: t.useDateObjects ?? !1
6699
6700
  }, o = nt[tt(i)];
6700
6701
  if (o)
6701
- return Mo(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6702
- const a = new oo(
6702
+ return Po(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6703
+ const a = new ao(
6703
6704
  {
6704
- ...vo,
6705
+ ...Oo,
6705
6706
  ...i,
6706
6707
  cardinalityInference: !!i.schema
6707
6708
  },
@@ -6709,10 +6710,10 @@ function Po(t, e, n, r, s) {
6709
6710
  n || Pn,
6710
6711
  { ...r || {}, "@instantdb/core": Rn },
6711
6712
  s
6712
- ), c = new Co(a);
6713
- return nt[tt(i)] = c, jo(i.appId, i.devtool), c;
6713
+ ), c = new Mo(a);
6714
+ return nt[tt(i)] = c, $o(i.appId, i.devtool), c;
6714
6715
  }
6715
- function jo(t, e) {
6716
+ function $o(t, e) {
6716
6717
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6717
6718
  return;
6718
6719
  const n = {
@@ -6720,33 +6721,33 @@ function jo(t, e) {
6720
6721
  allowedHosts: ["localhost"],
6721
6722
  ...typeof e == "object" ? e : {}
6722
6723
  };
6723
- n.allowedHosts.includes(window.location.hostname) && _o(t, n);
6724
+ n.allowedHosts.includes(window.location.hostname) && go(t, n);
6724
6725
  }
6725
- const Lo = Po;
6726
+ const Fo = jo;
6726
6727
  export {
6727
- Eo as Auth,
6728
+ Io as Auth,
6728
6729
  Mn as IndexedDBStorage,
6729
6730
  Me as InstantAPIError,
6730
- Co as InstantCoreDatabase,
6731
+ Mo as InstantCoreDatabase,
6731
6732
  de as InstantError,
6732
6733
  v as QueryValidationError,
6733
- Io as Storage,
6734
- li as StorageInterface,
6735
- Gi as SyncTableCallbackEventType,
6734
+ Co as Storage,
6735
+ fi as StorageInterface,
6736
+ Bi as SyncTableCallbackEventType,
6736
6737
  N as TransactionValidationError,
6737
6738
  Pn as WindowNetworkListener,
6738
- Uo as coerceQuery,
6739
+ Lo as coerceQuery,
6739
6740
  Ie as coerceToDate,
6740
- Us as getOps,
6741
- xo as i,
6741
+ Ls as getOps,
6742
+ Uo as i,
6742
6743
  I as id,
6743
- Po as init,
6744
- Lo as init_experimental,
6745
- Do as lookup,
6746
- Ro as tx,
6744
+ jo as init,
6745
+ Fo as init_experimental,
6746
+ Ro as lookup,
6747
+ xo as tx,
6747
6748
  En as txInit,
6748
6749
  zt as validateQuery,
6749
- Fi as validateTransactions,
6750
+ Ni as validateTransactions,
6750
6751
  Rn as version,
6751
6752
  P as weakHash
6752
6753
  };