@instantdb/react 0.22.76 → 0.22.77-experimental.drewh-entity-caching.19941365378.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.
@@ -1244,13 +1244,21 @@ function Zs(t) {
1244
1244
  return null;
1245
1245
  }
1246
1246
  function Xs(t) {
1247
+ const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
1248
+ if (n) {
1249
+ const [, r, i, s, o, a] = n, u = i.padStart(2, "0"), d = s.padStart(2, "0"), c = `${r}-${u}-${d}T${a}`;
1250
+ return new Date(c);
1251
+ }
1252
+ return null;
1253
+ }
1254
+ function eo(t) {
1247
1255
  const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1248
1256
  if (!o)
1249
1257
  throw new Error(`Unable to parse time from: ${t}`);
1250
1258
  let [, a, u, d, c] = o;
1251
1259
  return a = Number(a), u = Number(u), d = Number(d), c === "PM" && a !== 12 ? a += 12 : c === "AM" && a === 12 && (a = 0), new Date(Date.UTC(s, r - 1, i, a, u, d));
1252
1260
  }
1253
- function eo(t) {
1261
+ function to(t) {
1254
1262
  switch (t) {
1255
1263
  case "epoch":
1256
1264
  return /* @__PURE__ */ new Date(0);
@@ -1262,27 +1270,28 @@ function eo(t) {
1262
1270
  return null;
1263
1271
  }
1264
1272
  }
1265
- function to(t) {
1273
+ function no(t) {
1266
1274
  const e = t.match(Or);
1267
1275
  if (!e)
1268
1276
  return null;
1269
1277
  const [n] = e, r = Ws[n], i = new Date(t.replace(Or, "Z"));
1270
1278
  return new Date(i.getTime() - r * 1e3);
1271
1279
  }
1272
- const no = [
1280
+ const ro = [
1273
1281
  Gs,
1274
1282
  Hs,
1275
1283
  Js,
1276
- Xs,
1284
+ eo,
1277
1285
  Ys,
1278
1286
  Vs,
1279
1287
  Zs,
1280
1288
  Qs,
1281
1289
  zs,
1282
- eo,
1283
- to
1290
+ to,
1291
+ no,
1292
+ Xs
1284
1293
  ];
1285
- function ro(t, e) {
1294
+ function io(t, e) {
1286
1295
  try {
1287
1296
  const n = t(e);
1288
1297
  return n instanceof Date && !isNaN(n.getTime()) ? n : null;
@@ -1291,14 +1300,14 @@ function ro(t, e) {
1291
1300
  }
1292
1301
  }
1293
1302
  function cn(t) {
1294
- for (const e of no) {
1295
- const n = ro(e, t);
1303
+ for (const e of ro) {
1304
+ const n = io(e, t);
1296
1305
  if (n)
1297
1306
  return n;
1298
1307
  }
1299
1308
  return null;
1300
1309
  }
1301
- function io(t) {
1310
+ function so(t) {
1302
1311
  try {
1303
1312
  const e = JSON.parse(t);
1304
1313
  return typeof e == "string" ? cn(e) : null;
@@ -1313,7 +1322,7 @@ function xt(t) {
1313
1322
  if (t instanceof Date)
1314
1323
  return t;
1315
1324
  if (typeof t == "string") {
1316
- const e = cn(t) || io(t) || cn(t.trim());
1325
+ const e = cn(t) || so(t) || cn(t.trim());
1317
1326
  if (!e)
1318
1327
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1319
1328
  return e;
@@ -1322,7 +1331,7 @@ function xt(t) {
1322
1331
  throw new Error(`Invalid date value \`${t}\`. Expected a date, number, or string, got type ${typeof t}.`);
1323
1332
  }
1324
1333
  }
1325
- function so(t) {
1334
+ function oo(t) {
1326
1335
  return t.cardinality === "one";
1327
1336
  }
1328
1337
  function Nn(t) {
@@ -1395,7 +1404,7 @@ function Si(t) {
1395
1404
  function Oi(t) {
1396
1405
  return Et(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
1397
1406
  }
1398
- function oo(t, e) {
1407
+ function ao(t, e) {
1399
1408
  return We(t.eav, [e]) !== void 0;
1400
1409
  }
1401
1410
  function qn(t) {
@@ -1403,7 +1412,7 @@ function qn(t) {
1403
1412
  }
1404
1413
  function Et(t, e, n, r, i) {
1405
1414
  const s = mi(t, e, i);
1406
- return s.useDateObjects = i, s.attrs = t, s.attrIndexes = vi(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
1415
+ return s.useDateObjects = i, s.attrs = t, s.attrIndexes = vi(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s.entityCache = /* @__PURE__ */ new Map(), s;
1407
1416
  }
1408
1417
  function dt(t, e) {
1409
1418
  var n, r;
@@ -1439,12 +1448,12 @@ function Ei(t, e) {
1439
1448
  const [r, i, s] = n, o = qe(t.attrs, i);
1440
1449
  o && (oe(t.eav, [r, i, s]), oe(t.aev, [i, r, s]), Nn(o) && oe(t.vae, [s, i, r]));
1441
1450
  }
1442
- let ao = 0;
1451
+ let uo = 0;
1443
1452
  function Ai(t, e, n) {
1444
1453
  const [r, i, s] = n;
1445
1454
  let o;
1446
1455
  const a = We(t.ea, [r, i, s]);
1447
- return a && (o = a[3]), o || Date.now() * 10 + ao++;
1456
+ return a && (o = a[3]), o || Date.now() * 10 + uo++;
1448
1457
  }
1449
1458
  function ki(t, e) {
1450
1459
  var n;
@@ -1457,9 +1466,9 @@ function ki(t, e) {
1457
1466
  return;
1458
1467
  a["checked-data-type"] === "date" && t.useDateObjects && (o = xt(o));
1459
1468
  const u = We(t.eav, [i, s, o]), d = (n = u == null ? void 0 : u[3]) !== null && n !== void 0 ? n : Ai(t, a, r), c = [i, s, o, d];
1460
- so(a) ? (Z(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), Z(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (Z(t.eav, [i, s, o], c), Z(t.aev, [s, i, o], c)), Nn(a) && Z(t.vae, [o, s, i], c);
1469
+ oo(a) ? (Z(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), Z(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (Z(t.eav, [i, s, o], c), Z(t.aev, [s, i, o], c)), Nn(a) && Z(t.vae, [o, s, i], c);
1461
1470
  }
1462
- function uo(t, e) {
1471
+ function co(t, e) {
1463
1472
  var n;
1464
1473
  const r = dt(t, e);
1465
1474
  if (!r)
@@ -1516,30 +1525,30 @@ function ji(t, e) {
1516
1525
  t[r] = n[r];
1517
1526
  });
1518
1527
  }
1519
- function co(t, [e]) {
1528
+ function fo(t, [e]) {
1520
1529
  t.attrs[e.id] = e, qn(t);
1521
1530
  }
1522
1531
  function Ci(t) {
1523
1532
  return X(t.eav, 3);
1524
1533
  }
1525
- function fo(t, [e]) {
1534
+ function lo(t, [e]) {
1526
1535
  if (!t.attrs[e])
1527
1536
  return;
1528
1537
  const n = Ci(t).filter(([r, i]) => i !== e);
1529
1538
  delete t.attrs[e], qn(t), ji(t, n);
1530
1539
  }
1531
- function lo(t, [e]) {
1540
+ function ho(t, [e]) {
1532
1541
  const n = t.attrs[e.id];
1533
1542
  n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), qn(t), ji(t, Ci(t)));
1534
1543
  }
1535
- function ho(t, e) {
1544
+ function po(t, e) {
1536
1545
  const [n, ...r] = e;
1537
1546
  switch (n) {
1538
1547
  case "add-triple":
1539
1548
  ki(t, r);
1540
1549
  break;
1541
1550
  case "deep-merge-triple":
1542
- uo(t, r);
1551
+ co(t, r);
1543
1552
  break;
1544
1553
  case "retract-triple":
1545
1554
  Ei(t, r);
@@ -1548,13 +1557,13 @@ function ho(t, e) {
1548
1557
  dn(t, r);
1549
1558
  break;
1550
1559
  case "add-attr":
1551
- co(t, r);
1560
+ fo(t, r);
1552
1561
  break;
1553
1562
  case "delete-attr":
1554
- fo(t, r);
1563
+ lo(t, r);
1555
1564
  break;
1556
1565
  case "update-attr":
1557
- lo(t, r);
1566
+ ho(t, r);
1558
1567
  break;
1559
1568
  case "restore-attr":
1560
1569
  break;
@@ -1609,13 +1618,13 @@ function gt(t, e, n) {
1609
1618
  }
1610
1619
  return s;
1611
1620
  }
1612
- function po(t, e, n) {
1621
+ function yo(t, e, n) {
1613
1622
  let r = "";
1614
1623
  return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
1615
1624
  }
1616
- function yo(t, [e, n, r]) {
1625
+ function bo(t, [e, n, r]) {
1617
1626
  var i, s;
1618
- switch (po(e, n, r)) {
1627
+ switch (yo(e, n, r)) {
1619
1628
  case "e": {
1620
1629
  const a = t.eav.get(e);
1621
1630
  return X(a, 2);
@@ -1661,15 +1670,17 @@ function yo(t, [e, n, r]) {
1661
1670
  return X(t.eav, 3);
1662
1671
  }
1663
1672
  }
1664
- function bo(t, e, n) {
1673
+ function _o(t, e, n) {
1665
1674
  var r;
1675
+ if (t.entityCache.has(n))
1676
+ return t.entityCache.get(n);
1666
1677
  const i = {};
1667
1678
  for (const [s, o] of e.entries()) {
1668
1679
  const a = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), u = X(a, 1);
1669
1680
  for (const d of u)
1670
1681
  i[s] = d[2];
1671
1682
  }
1672
- return i;
1683
+ return t.entityCache.set(n, i), i;
1673
1684
  }
1674
1685
  function Te(t, e, n) {
1675
1686
  var r;
@@ -1679,7 +1690,7 @@ function Pi(t, e, n) {
1679
1690
  var r;
1680
1691
  return (r = t.attrIndexes.revIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
1681
1692
  }
1682
- function _o(t, e) {
1693
+ function go(t, e) {
1683
1694
  return t.attrIndexes.blobAttrs.get(e);
1684
1695
  }
1685
1696
  function Ii(t, e) {
@@ -1687,7 +1698,7 @@ function Ii(t, e) {
1687
1698
  const r = t.attrIndexes.primaryKeys.get(e);
1688
1699
  return r || ((n = t.attrIndexes.forwardIdents.get(e)) === null || n === void 0 ? void 0 : n.get("id"));
1689
1700
  }
1690
- function go(t, e) {
1701
+ function To(t, e) {
1691
1702
  const n = dt(t, e);
1692
1703
  if (!n)
1693
1704
  return;
@@ -1695,7 +1706,7 @@ function go(t, e) {
1695
1706
  if (qe(t.attrs, i))
1696
1707
  return We(t.eav, [r, i]);
1697
1708
  }
1698
- function To(t, e) {
1709
+ function wo(t, e) {
1699
1710
  const n = e.filter(([r, i, s, o, a]) => {
1700
1711
  if (r !== "add-triple" && r !== "deep-merge-triple")
1701
1712
  return !0;
@@ -1706,20 +1717,20 @@ function To(t, e) {
1706
1717
  const c = qe(t.attrs, s);
1707
1718
  if (c) {
1708
1719
  const f = Ii(t, c["forward-identity"][1]);
1709
- d = !!go(t, [i, f.id, i]);
1720
+ d = !!To(t, [i, f.id, i]);
1710
1721
  }
1711
1722
  return !(u === "create" && d || u === "update" && !d);
1712
1723
  });
1713
1724
  return Pt(t, (r) => {
1714
1725
  n.forEach((i) => {
1715
- ho(r, i);
1726
+ po(r, i);
1716
1727
  });
1717
1728
  });
1718
1729
  }
1719
- function wo(t) {
1730
+ function mo(t) {
1720
1731
  return typeof t == "string" && t.startsWith("?");
1721
1732
  }
1722
- function mo(t, e, n) {
1733
+ function vo(t, e, n) {
1723
1734
  if (n.hasOwnProperty(t)) {
1724
1735
  const r = n[t];
1725
1736
  return Mi(r, e, n);
@@ -1729,15 +1740,15 @@ function mo(t, e, n) {
1729
1740
  function Er(t, e, n) {
1730
1741
  return t === e ? n : null;
1731
1742
  }
1732
- function vo(t) {
1743
+ function So(t) {
1733
1744
  switch (typeof t) {
1734
1745
  case "string":
1735
- return t.startsWith("?") ? mo : Er;
1746
+ return t.startsWith("?") ? vo : Er;
1736
1747
  default:
1737
1748
  return Er;
1738
1749
  }
1739
1750
  }
1740
- const So = [
1751
+ const Oo = [
1741
1752
  "in",
1742
1753
  "$in",
1743
1754
  "$not",
@@ -1745,69 +1756,69 @@ const So = [
1745
1756
  "$comparator"
1746
1757
  // covers all of $gt, $lt, etc.
1747
1758
  ];
1748
- function Oo(t) {
1749
- for (const e of So)
1759
+ function Eo(t) {
1760
+ for (const e of Oo)
1750
1761
  if (t.hasOwnProperty(e))
1751
1762
  return !0;
1752
1763
  return !1;
1753
1764
  }
1754
1765
  function Mi(t, e, n) {
1755
- return n ? typeof t == "object" ? Oo(t) ? n : null : vo(t)(t, e, n) : null;
1766
+ return n ? typeof t == "object" ? Eo(t) ? n : null : So(t)(t, e, n) : null;
1756
1767
  }
1757
- function Eo(t, e, n) {
1768
+ function Ao(t, e, n) {
1758
1769
  return t.reduce((r, i, s) => {
1759
1770
  const o = e[s];
1760
1771
  return Mi(i, o, r);
1761
1772
  }, n);
1762
1773
  }
1763
- function Ao(t, e, n) {
1764
- return Co(t, e, n).map((r) => Eo(e, r, n)).filter((r) => r);
1765
- }
1766
1774
  function ko(t, e, n) {
1767
- return e.or ? e.or.patterns.flatMap((r) => fn(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => fn(t, i, r), n) : n.flatMap((r) => Ao(t, e, r));
1775
+ return Po(t, e, n).map((r) => Ao(e, r, n)).filter((r) => r);
1776
+ }
1777
+ function jo(t, e, n) {
1778
+ return e.or ? e.or.patterns.flatMap((r) => fn(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => fn(t, i, r), n) : n.flatMap((r) => ko(t, e, r));
1768
1779
  }
1769
1780
  function fn(t, e, n = [{}]) {
1770
- return e.reduce((r, i) => ko(t, i, r), n);
1781
+ return e.reduce((r, i) => jo(t, i, r), n);
1771
1782
  }
1772
1783
  function Wn(t, e) {
1773
- return Array.isArray(e) ? e.map((n) => Wn(t, n)) : wo(e) ? t[e] : e;
1784
+ return Array.isArray(e) ? e.map((n) => Wn(t, n)) : mo(e) ? t[e] : e;
1774
1785
  }
1775
- function jo(t, { find: e, where: n }) {
1786
+ function Co(t, { find: e, where: n }) {
1776
1787
  return fn(t, n).map((i) => Wn(i, e));
1777
1788
  }
1778
- function Co(t, e, n) {
1779
- return yo(t, Wn(n, e));
1789
+ function Po(t, e, n) {
1790
+ return bo(t, Wn(n, e));
1780
1791
  }
1781
- const Po = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1792
+ const Io = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1782
1793
  function Fe(t) {
1783
- return typeof t == "string" && Po.test(t);
1794
+ return typeof t == "string" && Io.test(t);
1784
1795
  }
1785
1796
  const q = [];
1786
1797
  for (let t = 0; t < 256; ++t)
1787
1798
  q.push((t + 256).toString(16).slice(1));
1788
- function Io(t, e = 0) {
1799
+ function Mo(t, e = 0) {
1789
1800
  return (q[t[e + 0]] + q[t[e + 1]] + q[t[e + 2]] + q[t[e + 3]] + "-" + q[t[e + 4]] + q[t[e + 5]] + "-" + q[t[e + 6]] + q[t[e + 7]] + "-" + q[t[e + 8]] + q[t[e + 9]] + "-" + q[t[e + 10]] + q[t[e + 11]] + q[t[e + 12]] + q[t[e + 13]] + q[t[e + 14]] + q[t[e + 15]]).toLowerCase();
1790
1801
  }
1791
1802
  let Yt;
1792
- const Mo = new Uint8Array(16);
1793
- function Ro() {
1803
+ const Ro = new Uint8Array(16);
1804
+ function xo() {
1794
1805
  if (!Yt) {
1795
1806
  if (typeof crypto > "u" || !crypto.getRandomValues)
1796
1807
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1797
1808
  Yt = crypto.getRandomValues.bind(crypto);
1798
1809
  }
1799
- return Yt(Mo);
1810
+ return Yt(Ro);
1800
1811
  }
1801
- const xo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ar = { randomUUID: xo };
1802
- function $o(t, e, n) {
1812
+ const $o = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ar = { randomUUID: $o };
1813
+ function Do(t, e, n) {
1803
1814
  var i;
1804
1815
  if (Ar.randomUUID && !t)
1805
1816
  return Ar.randomUUID();
1806
1817
  t = t || {};
1807
- const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Ro();
1818
+ const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? xo();
1808
1819
  if (r.length < 16)
1809
1820
  throw new Error("Random bytes length must be >= 16");
1810
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Io(r);
1821
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Mo(r);
1811
1822
  }
1812
1823
  function kr(t) {
1813
1824
  const e = t.replace(/-/g, ""), n = [];
@@ -1815,7 +1826,7 @@ function kr(t) {
1815
1826
  n.push(parseInt(e.substring(r, r + 2), 16));
1816
1827
  return n;
1817
1828
  }
1818
- function Do(t, e) {
1829
+ function Uo(t, e) {
1819
1830
  for (let n = 0; n < t.length; n++) {
1820
1831
  if (t[n] < e[n])
1821
1832
  return -1;
@@ -1824,17 +1835,17 @@ function Do(t, e) {
1824
1835
  }
1825
1836
  return 0;
1826
1837
  }
1827
- function Uo(t, e) {
1828
- return Do(kr(t), kr(e));
1838
+ function Lo(t, e) {
1839
+ return Uo(kr(t), kr(e));
1829
1840
  }
1830
1841
  function K() {
1831
- return $o();
1842
+ return Do();
1832
1843
  }
1833
- function Lo(t, e) {
1844
+ function Fo(t, e) {
1834
1845
  return t.localeCompare(e);
1835
1846
  }
1836
- function Fo() {
1837
- let t = Lo;
1847
+ function No() {
1848
+ let t = Fo;
1838
1849
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1839
1850
  try {
1840
1851
  t = Intl.Collator("en-US").compare;
@@ -1842,10 +1853,10 @@ function Fo() {
1842
1853
  }
1843
1854
  return t;
1844
1855
  }
1845
- const No = Fo();
1846
- let Ko = 0;
1856
+ const Ko = No();
1857
+ let qo = 0;
1847
1858
  function rt(t) {
1848
- return $t(`_${t}`, Ko++);
1859
+ return $t(`_${t}`, qo++);
1849
1860
  }
1850
1861
  function $t(t, e) {
1851
1862
  return `?${t}-${e}`;
@@ -1855,24 +1866,24 @@ class Ne extends Error {
1855
1866
  super(e), this.name = "AttrNotFoundError";
1856
1867
  }
1857
1868
  }
1858
- function qo(t, e) {
1869
+ function Wo(t, e) {
1859
1870
  const n = Ii(t, e);
1860
1871
  if (!n)
1861
1872
  throw new Ne(`Could not find id attr for ${e}`);
1862
1873
  return n;
1863
1874
  }
1864
1875
  function jr(t, e, n, r) {
1865
- return [Wo(t, e, n, r)];
1876
+ return [zo(t, e, n, r)];
1866
1877
  }
1867
- function Wo(t, e, n, r) {
1878
+ function zo(t, e, n, r) {
1868
1879
  return [
1869
1880
  t(n, r),
1870
- qo(e, n).id,
1881
+ Wo(e, n).id,
1871
1882
  t(n, r),
1872
1883
  t("time", r)
1873
1884
  ];
1874
1885
  }
1875
- function zo(t, e, n) {
1886
+ function Vo(t, e, n) {
1876
1887
  return t.map((r) => r === e ? n : r);
1877
1888
  }
1878
1889
  function Ri(t, e, n, r, i) {
@@ -1904,7 +1915,7 @@ function Cr(t, e) {
1904
1915
  return typeof o != "string" ? !1 : i.test(o);
1905
1916
  };
1906
1917
  }
1907
- function Vo(t, e) {
1918
+ function Bo(t, e) {
1908
1919
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
1909
1920
  return e;
1910
1921
  const n = t["checked-data-type"] === "date";
@@ -1964,7 +1975,7 @@ function Vo(t, e) {
1964
1975
  }
1965
1976
  return e;
1966
1977
  }
1967
- function Bo(t, e, n, r, i, s) {
1978
+ function Go(t, e, n, r, i, s) {
1968
1979
  const o = Te(e, n, i), a = Pi(e, n, i), u = o || a;
1969
1980
  if (!u)
1970
1981
  throw new Ne(`No attr for etype = ${n} label = ${i}`);
@@ -1982,11 +1993,11 @@ function Bo(t, e, n, r, i, s) {
1982
1993
  return o ? [
1983
1994
  t(n, r),
1984
1995
  u.id,
1985
- Vo(u, s),
1996
+ Bo(u, s),
1986
1997
  rt("time")
1987
1998
  ] : [s, u.id, t(n, r), rt("time")];
1988
1999
  }
1989
- function Go(t, e, n, r, i) {
2000
+ function Qo(t, e, n, r, i) {
1990
2001
  const [s, o, a] = i.reduce((u, d) => {
1991
2002
  const [c, f, l] = u, [p, y, b] = Ri(t, e, c, f, d);
1992
2003
  return [p, y, [...l, b]];
@@ -1994,19 +2005,19 @@ function Go(t, e, n, r, i) {
1994
2005
  return [s, o, a];
1995
2006
  }
1996
2007
  function ln(t, e, n, r, i, s) {
1997
- const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, d, c] = Go(t, e, n, r, o), f = Bo(t, e, u, d, a, s);
2008
+ const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, d, c] = Qo(t, e, n, r, o), f = Go(t, e, u, d, a, s);
1998
2009
  return c.concat([f]);
1999
2010
  }
2000
- function Qo(t, e) {
2011
+ function Ho(t, e) {
2001
2012
  return e ? [e].concat(t) : t;
2002
2013
  }
2003
- function Ho([t, e]) {
2014
+ function Yo([t, e]) {
2004
2015
  return t === "or" && Array.isArray(e);
2005
2016
  }
2006
- function Yo([t, e]) {
2017
+ function Jo([t, e]) {
2007
2018
  return t === "and" && Array.isArray(e);
2008
2019
  }
2009
- function Jo(t, e, n) {
2020
+ function Zo(t, e, n) {
2010
2021
  return (r, i) => {
2011
2022
  const s = t(r, i);
2012
2023
  return e == s ? s : `${s}-${n}`;
@@ -2014,25 +2025,25 @@ function Jo(t, e, n) {
2014
2025
  }
2015
2026
  function Pr(t, e, n, r, i, s) {
2016
2027
  const o = t(r, i), a = s.map((u, d) => {
2017
- const c = Jo(t, o, d);
2028
+ const c = Zo(t, o, d);
2018
2029
  return xi(c, n, r, i, u);
2019
2030
  });
2020
2031
  return { [e]: { patterns: a, joinSym: o } };
2021
2032
  }
2022
- function Zo(t) {
2033
+ function Xo(t) {
2023
2034
  const e = [];
2024
2035
  for (let n = 1; n <= t.length; n++)
2025
2036
  e.push(t.slice(0, n));
2026
2037
  return e;
2027
2038
  }
2028
2039
  function Ir(t, e, n, r, i) {
2029
- return Zo(i).map((s) => ln(t, e, n, r, s, { $isNull: !0 }));
2040
+ return Xo(i).map((s) => ln(t, e, n, r, s, { $isNull: !0 }));
2030
2041
  }
2031
2042
  function xi(t, e, n, r, i) {
2032
2043
  return Object.entries(i).flatMap(([s, o]) => {
2033
- if (Ho([s, o]))
2034
- return Pr(t, "or", e, n, r, o);
2035
2044
  if (Yo([s, o]))
2045
+ return Pr(t, "or", e, n, r, o);
2046
+ if (Jo([s, o]))
2036
2047
  return Pr(t, "and", e, n, r, o);
2037
2048
  if (s === "$entityIdStartsWith")
2038
2049
  return [];
@@ -2058,25 +2069,25 @@ function xi(t, e, n, r, i) {
2058
2069
  ] : ln(t, e, n, r, a, o);
2059
2070
  });
2060
2071
  }
2061
- function Xo(t, e, n, r) {
2072
+ function ea(t, e, n, r) {
2062
2073
  const i = $t;
2063
2074
  return r ? xi(i, t, e, n, r).concat(jr(i, t, e, n)) : jr(i, t, e, n);
2064
2075
  }
2065
- function ea(t, e, n) {
2076
+ function ta(t, e, n) {
2066
2077
  return [t(e, n), t("time", n)];
2067
2078
  }
2068
- function ta(t, e, n, r, i, s) {
2069
- const [o, a, u, d, c] = Ri(t, e, n, r, i), f = zo(u, t(n, r), s);
2079
+ function na(t, e, n, r, i, s) {
2080
+ const [o, a, u, d, c] = Ri(t, e, n, r, i), f = Vo(u, t(n, r), s);
2070
2081
  return [o, a, f, d, c];
2071
2082
  }
2072
- function na(t, e, { etype: n, level: r, form: i }, s) {
2083
+ function ra(t, e, { etype: n, level: r, form: i }, s) {
2073
2084
  const o = Object.keys(i).filter((a) => a !== "$");
2074
2085
  return o.length ? Object.entries(s).map(function([u, d]) {
2075
2086
  return o.map(function(l) {
2076
2087
  var p, y, b;
2077
2088
  const _ = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[l]) === null || b === void 0) && b.isSingular));
2078
2089
  try {
2079
- const [w, g, m] = ta(t, e, n, r, l, u), E = Di(e, {
2090
+ const [w, g, m] = na(t, e, n, r, l, u), E = Di(e, {
2080
2091
  etype: w,
2081
2092
  level: g,
2082
2093
  form: i[l],
@@ -2093,11 +2104,11 @@ function na(t, e, { etype: n, level: r, form: i }, s) {
2093
2104
  }, d);
2094
2105
  }) : Object.values(s);
2095
2106
  }
2096
- function ra(t, e, n) {
2097
- return n === "string" ? No(t, e) : t > e ? 1 : -1;
2107
+ function ia(t, e, n) {
2108
+ return n === "string" ? Ko(t, e) : t > e ? 1 : -1;
2098
2109
  }
2099
2110
  function Xe(t, e, n, r, i) {
2100
- return e === r || e == null && r == null ? Uo(t, n) : r == null ? 1 : e == null ? -1 : ra(e, r, i);
2111
+ return e === r || e == null && r == null ? Lo(t, n) : r == null ? 1 : e == null ? -1 : ia(e, r, i);
2101
2112
  }
2102
2113
  function It([t, e], [n, r], i) {
2103
2114
  return Xe(t, e, n, r, i);
@@ -2105,7 +2116,7 @@ function It([t, e], [n, r], i) {
2105
2116
  function hn(t) {
2106
2117
  return t == null ? t : new Date(t).getTime();
2107
2118
  }
2108
- function ia(t, e, n, r) {
2119
+ function sa(t, e, n, r) {
2109
2120
  var i;
2110
2121
  const [s, o, a, u] = t, d = n === "desc" ? 1 : -1;
2111
2122
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
@@ -2113,24 +2124,24 @@ function ia(t, e, n, r) {
2113
2124
  const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? hn(f) : f, y = l === "date" ? hn(a) : a;
2114
2125
  return It([c, p], [s, y], l) === d;
2115
2126
  }
2116
- function sa(t, e) {
2127
+ function oa(t, e) {
2117
2128
  const n = e[1];
2118
2129
  return t.attrs[n];
2119
2130
  }
2120
- function oa(t, e, n) {
2131
+ function aa(t, e, n) {
2121
2132
  const r = Object.keys(n)[0];
2122
2133
  return Te(t, e, r);
2123
2134
  }
2124
- function aa(t, e, n, r) {
2135
+ function ua(t, e, n, r) {
2125
2136
  if (n)
2126
- return sa(t, n);
2137
+ return oa(t, n);
2127
2138
  if (r)
2128
- return oa(t, e, r);
2139
+ return aa(t, e, r);
2129
2140
  }
2130
- function ua(t, e, n) {
2141
+ function ca(t, e, n) {
2131
2142
  var r, i;
2132
2143
  if (!Array.isArray(n.fields))
2133
- return _o(t, e);
2144
+ return go(t, e);
2134
2145
  const s = /* @__PURE__ */ new Map();
2135
2146
  for (const o of n.fields) {
2136
2147
  const a = Te(t, e, o), u = (r = a == null ? void 0 : a["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
@@ -2142,11 +2153,11 @@ function ua(t, e, n) {
2142
2153
  }
2143
2154
  return s;
2144
2155
  }
2145
- function ca(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2156
+ function da(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2146
2157
  var s, o;
2147
- const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = $i(i), d = da(i);
2148
- let c = jo(t, r);
2149
- const f = n == null ? void 0 : n["start-cursor"], l = aa(t, e, f, a);
2158
+ const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = $i(i), d = fa(i);
2159
+ let c = Co(t, r);
2160
+ const f = n == null ? void 0 : n["start-cursor"], l = ua(t, e, f, a);
2150
2161
  if (l && ((o = l == null ? void 0 : l["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
2151
2162
  const b = l["checked-data-type"] === "date", _ = l.id;
2152
2163
  c = c.map(([w]) => {
@@ -2161,17 +2172,17 @@ function ca(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2161
2172
  return It(w, _, l == null ? void 0 : l["checked-data-type"]);
2162
2173
  });
2163
2174
  let p = {};
2164
- const y = ua(t, e, r);
2175
+ const y = ca(t, e, r);
2165
2176
  for (const b of c) {
2166
2177
  const [_] = b;
2167
- if (p[_] || !u && f && l && ia(f, l, d, b))
2178
+ if (p[_] || !u && f && l && sa(f, l, d, b))
2168
2179
  continue;
2169
- const w = bo(t, y, _);
2180
+ const w = _o(t, y, _);
2170
2181
  w && (p[_] = w);
2171
2182
  }
2172
2183
  return p;
2173
2184
  }
2174
- function da(t) {
2185
+ function fa(t) {
2175
2186
  var e;
2176
2187
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2177
2188
  return n && n[Object.keys(n)[0]] || "asc";
@@ -2181,11 +2192,11 @@ function $i(t) {
2181
2192
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2182
2193
  return !i && !s && !o;
2183
2194
  }
2184
- function fa(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2195
+ function la(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2185
2196
  var o, a, u, d, c;
2186
2197
  if (!$i(r) && (!s || !s["start-cursor"]))
2187
2198
  return [];
2188
- const f = Qo(Xo(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = ea($t, e, n), p = (a = r.$) === null || a === void 0 ? void 0 : a.fields, y = ca(t, {
2199
+ const f = Ho(ea(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = ta($t, e, n), p = (a = r.$) === null || a === void 0 ? void 0 : a.fields, y = da(t, {
2189
2200
  etype: e,
2190
2201
  pageInfo: s,
2191
2202
  form: r,
@@ -2198,9 +2209,9 @@ function fa(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2198
2209
  }
2199
2210
  return y;
2200
2211
  }
2201
- function la(t, e) {
2212
+ function ha(t, e) {
2202
2213
  try {
2203
- return fa(t, e);
2214
+ return la(t, e);
2204
2215
  } catch (n) {
2205
2216
  if (n instanceof Ne)
2206
2217
  return {};
@@ -2208,10 +2219,10 @@ function la(t, e) {
2208
2219
  }
2209
2220
  }
2210
2221
  function Di(t, e) {
2211
- const n = la(t, e);
2212
- return na($t, t, e, n);
2222
+ const n = ha(t, e);
2223
+ return ra($t, t, e, n);
2213
2224
  }
2214
- function ha(t) {
2225
+ function pa(t) {
2215
2226
  const e = {};
2216
2227
  for (const [n, r] of Object.entries(t))
2217
2228
  e[n] = {
@@ -2231,9 +2242,9 @@ function Ui({ store: t, pageInfo: e, aggregate: n }, r) {
2231
2242
  pageInfo: e == null ? void 0 : e[u]
2232
2243
  })), a;
2233
2244
  }, {}) };
2234
- return e && (s.pageInfo = ha(e)), n && (s.aggregate = n), s;
2245
+ return e && (s.pageInfo = pa(e)), n && (s.aggregate = n), s;
2235
2246
  }
2236
- function pa() {
2247
+ function ya() {
2237
2248
  const e = {
2238
2249
  __etype: 1,
2239
2250
  __ops: 1,
@@ -2247,7 +2258,7 @@ function pa() {
2247
2258
  };
2248
2259
  return new Set(Object.keys(e));
2249
2260
  }
2250
- const ya = pa();
2261
+ const ba = ya();
2251
2262
  function pn(t, e, n) {
2252
2263
  const r = {
2253
2264
  __etype: t,
@@ -2259,7 +2270,7 @@ function pn(t, e, n) {
2259
2270
  return n;
2260
2271
  if (s === "__etype")
2261
2272
  return t;
2262
- if (ya.has(s))
2273
+ if (ba.has(s))
2263
2274
  return (o, a) => pn(t, e, [
2264
2275
  ...n,
2265
2276
  a ? [s, t, e, o, a] : [s, t, e, o]
@@ -2267,7 +2278,7 @@ function pn(t, e, n) {
2267
2278
  }
2268
2279
  });
2269
2280
  }
2270
- function Fc(t, e) {
2281
+ function Nc(t, e) {
2271
2282
  return `lookup__${t}__${JSON.stringify(e)}`;
2272
2283
  }
2273
2284
  function Mt(t) {
@@ -2277,7 +2288,7 @@ function Li(t) {
2277
2288
  const [e, n, ...r] = t.split("__");
2278
2289
  return [n, JSON.parse(r.join("__"))];
2279
2290
  }
2280
- function ba(t) {
2291
+ function _a(t) {
2281
2292
  return new Proxy({
2282
2293
  __etype: t
2283
2294
  }, {
@@ -2292,15 +2303,15 @@ function ba(t) {
2292
2303
  function zn() {
2293
2304
  return new Proxy({}, {
2294
2305
  get(t, e) {
2295
- return ba(e);
2306
+ return _a(e);
2296
2307
  }
2297
2308
  });
2298
2309
  }
2299
- const Nc = zn();
2300
- function _a(t) {
2310
+ const Kc = zn();
2311
+ function ga(t) {
2301
2312
  return t.__ops;
2302
2313
  }
2303
- function ga(t, e) {
2314
+ function Ta(t, e) {
2304
2315
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2305
2316
  for (const o of e) {
2306
2317
  const a = n[o];
@@ -2334,7 +2345,7 @@ function Ae(t, e, n) {
2334
2345
  return o === e && a === n;
2335
2346
  });
2336
2347
  }
2337
- function Ta(t) {
2348
+ function wa(t) {
2338
2349
  if (Array.isArray(t))
2339
2350
  return t;
2340
2351
  const e = Object.entries(t);
@@ -2353,7 +2364,7 @@ function bn(t) {
2353
2364
  throw new Error(`${t} is not a valid lookup attribute.`);
2354
2365
  return e;
2355
2366
  }
2356
- function wa(t, e, n) {
2367
+ function ma(t, e, n) {
2357
2368
  if (!yn(t, e, n))
2358
2369
  return V(t, e, n);
2359
2370
  const r = bn(n), i = V(t, e, r) || Ae(t, e, r);
@@ -2362,13 +2373,13 @@ function wa(t, e, n) {
2362
2373
  return i;
2363
2374
  }
2364
2375
  function _n(t) {
2365
- return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? Li(t) : Ta(t);
2376
+ return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? Li(t) : wa(t);
2366
2377
  }
2367
2378
  function ee(t, e, n) {
2368
2379
  const r = _n(n);
2369
2380
  if (r === null)
2370
2381
  return n;
2371
- const [i, s] = r, o = wa(t, e, i);
2382
+ const [i, s] = r, o = ma(t, e, i);
2372
2383
  if (!o || !o["unique?"])
2373
2384
  throw new Error(`${i} is not a unique attribute.`);
2374
2385
  return [o.id, s];
@@ -2382,7 +2393,7 @@ function Fi(t, e, n, r) {
2382
2393
  i
2383
2394
  ]].concat(r) : r;
2384
2395
  }
2385
- function ma({ attrs: t }, [e, n, r]) {
2396
+ function va({ attrs: t }, [e, n, r]) {
2386
2397
  const i = Object.entries(r).flatMap(([s, o]) => {
2387
2398
  const a = Array.isArray(o) ? o : [o], u = V(t, e, s), d = Ae(t, e, s);
2388
2399
  return a.map((c) => u ? [
@@ -2399,7 +2410,7 @@ function ma({ attrs: t }, [e, n, r]) {
2399
2410
  });
2400
2411
  return Fi(t, e, n, i);
2401
2412
  }
2402
- function va({ attrs: t }, [e, n, r]) {
2413
+ function Sa({ attrs: t }, [e, n, r]) {
2403
2414
  const i = Object.entries(r).flatMap(([s, o]) => {
2404
2415
  const a = Array.isArray(o) ? o : [o], u = V(t, e, s), d = Ae(t, e, s);
2405
2416
  return a.map((c) => u ? [
@@ -2416,7 +2427,7 @@ function va({ attrs: t }, [e, n, r]) {
2416
2427
  });
2417
2428
  return Fi(t, e, n, i);
2418
2429
  }
2419
- function Sa(t, e, n) {
2430
+ function Oa(t, e, n) {
2420
2431
  if (Array.isArray(n)) {
2421
2432
  const [r, i] = n;
2422
2433
  for (const s of t || []) {
@@ -2439,16 +2450,16 @@ function Sa(t, e, n) {
2439
2450
  return !1;
2440
2451
  }
2441
2452
  function Ni({ stores: t, attrs: e }, [n, r, i, s]) {
2442
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Sa(t, n, r) ? { mode: "update" } : null;
2453
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Oa(t, n, r) ? { mode: "update" } : null;
2443
2454
  }
2444
- function Oa(t, e) {
2455
+ function Ea(t, e) {
2445
2456
  const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o), d = ee(r, i, s);
2446
2457
  return [["id", d]].concat(Object.entries(u)).map(([f, l]) => {
2447
2458
  const p = V(r, i, f);
2448
2459
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), ["add-triple", d, p.id, l, { mode: "create" }];
2449
2460
  });
2450
2461
  }
2451
- function Ea(t, e) {
2462
+ function Aa(t, e) {
2452
2463
  const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o), d = ee(r, i, s), c = Ni(t, [i, d, o, a]);
2453
2464
  return [["id", d]].concat(Object.entries(u)).map(([l, p]) => {
2454
2465
  const y = V(r, i, l);
@@ -2461,10 +2472,10 @@ function Ea(t, e) {
2461
2472
  ];
2462
2473
  });
2463
2474
  }
2464
- function Aa({ attrs: t }, [e, n]) {
2475
+ function ka({ attrs: t }, [e, n]) {
2465
2476
  return [["delete-entity", ee(t, e, n), e]];
2466
2477
  }
2467
- function ka(t, e) {
2478
+ function ja(t, e) {
2468
2479
  const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o), d = ee(r, i, s), c = Ni(t, [i, d, o, a]), f = Object.entries(u).map(([p, y]) => {
2469
2480
  const b = V(r, i, p);
2470
2481
  return [
@@ -2483,38 +2494,38 @@ function ka(t, e) {
2483
2494
  ...c ? [c] : []
2484
2495
  ]].concat(f);
2485
2496
  }
2486
- function ja({ attrs: t }, [e, n, r]) {
2497
+ function Ca({ attrs: t }, [e, n, r]) {
2487
2498
  return [["rule-params", ee(t, e, n), e, r]];
2488
2499
  }
2489
- function Ca(t) {
2500
+ function Pa(t) {
2490
2501
  const [e, n, r, i, s] = t;
2491
2502
  if (!i)
2492
2503
  return t;
2493
2504
  const o = Object.assign({}, i);
2494
2505
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
2495
2506
  }
2496
- function Pa(t, e) {
2497
- const [n, ...r] = Ca(e);
2507
+ function Ia(t, e) {
2508
+ const [n, ...r] = Pa(e);
2498
2509
  switch (n) {
2499
2510
  case "merge":
2500
- return ka(t, r);
2511
+ return ja(t, r);
2501
2512
  case "create":
2502
- return Oa(t, r);
2503
- case "update":
2504
2513
  return Ea(t, r);
2514
+ case "update":
2515
+ return Aa(t, r);
2505
2516
  case "link":
2506
- return ma(t, r);
2507
- case "unlink":
2508
2517
  return va(t, r);
2518
+ case "unlink":
2519
+ return Sa(t, r);
2509
2520
  case "delete":
2510
- return Aa(t, r);
2521
+ return ka(t, r);
2511
2522
  case "ruleParams":
2512
- return ja(t, r);
2523
+ return Ca(t, r);
2513
2524
  default:
2514
2525
  throw new Error(`unsupported action ${n}`);
2515
2526
  }
2516
2527
  }
2517
- function Ia(t) {
2528
+ function Ma(t) {
2518
2529
  switch (t) {
2519
2530
  case "string":
2520
2531
  case "date":
@@ -2525,14 +2536,14 @@ function Ia(t) {
2525
2536
  return;
2526
2537
  }
2527
2538
  }
2528
- function Ma(t, e, n) {
2539
+ function Ra(t, e, n) {
2529
2540
  var r, i;
2530
2541
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
2531
2542
  if (n === "id")
2532
2543
  return null;
2533
2544
  if (!s)
2534
2545
  throw new Error(`${e}.${n} does not exist in your schema`);
2535
- const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ia(s == null ? void 0 : s.valueType);
2546
+ const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ma(s == null ? void 0 : s.valueType);
2536
2547
  return {
2537
2548
  "index?": a,
2538
2549
  "unique?": o,
@@ -2540,14 +2551,14 @@ function Ma(t, e, n) {
2540
2551
  };
2541
2552
  }
2542
2553
  function Tt(t, e, n, r) {
2543
- const i = t ? Ma(t, e, n) : null, s = K(), a = [K(), e, n];
2554
+ const i = t ? Ra(t, e, n) : null, s = K(), a = [K(), e, n];
2544
2555
  return Object.assign(Object.assign({ id: s, "forward-identity": a, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2545
2556
  }
2546
- function Ra(t, e, n) {
2557
+ function xa(t, e, n) {
2547
2558
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2548
2559
  }
2549
- function xa(t, e, n) {
2550
- const r = Ra(t, e, n);
2560
+ function $a(t, e, n) {
2561
+ const r = xa(t, e, n);
2551
2562
  if (!r)
2552
2563
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2553
2564
  const { forward: i, reverse: s } = r;
@@ -2561,10 +2572,10 @@ function xa(t, e, n) {
2561
2572
  };
2562
2573
  }
2563
2574
  function Mr(t, e, n, r) {
2564
- const i = t ? xa(t, e, n) : null, s = K(), o = [K(), e, n], a = [K(), n, e];
2575
+ const i = t ? $a(t, e, n) : null, s = K(), o = [K(), e, n], a = [K(), n, e];
2565
2576
  return Object.assign(Object.assign({ id: s, "forward-identity": o, "reverse-identity": a, "value-type": "ref", cardinality: "many", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2566
2577
  }
2567
- const $a = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Da = /* @__PURE__ */ new Set(["link", "unlink"]), Ua = /* @__PURE__ */ new Set(["create", "update", "merge"]), La = /* @__PURE__ */ new Set([
2578
+ const Da = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Ua = /* @__PURE__ */ new Set(["link", "unlink"]), La = /* @__PURE__ */ new Set(["create", "update", "merge"]), Fa = /* @__PURE__ */ new Set([
2568
2579
  "link",
2569
2580
  "unlink",
2570
2581
  "create",
@@ -2572,10 +2583,10 @@ const $a = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2572
2583
  "merge",
2573
2584
  "delete",
2574
2585
  "ruleParams"
2575
- ]), gn = { "unique?": !0, "index?": !0 }, Fa = Object.assign(Object.assign({}, gn), { cardinality: "one" });
2576
- function Na(t) {
2586
+ ]), gn = { "unique?": !0, "index?": !0 }, Na = Object.assign(Object.assign({}, gn), { cardinality: "one" });
2587
+ function Ka(t) {
2577
2588
  const e = [], [n, r, i, s] = t;
2578
- if (!La.has(n))
2589
+ if (!Fa.has(n))
2579
2590
  return e;
2580
2591
  const o = _n(i);
2581
2592
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -2592,7 +2603,7 @@ function Na(t) {
2592
2603
  }
2593
2604
  return e;
2594
2605
  }
2595
- function Ka({ attrs: t, schema: e }, n) {
2606
+ function qa({ attrs: t, schema: e }, n) {
2596
2607
  var r, i;
2597
2608
  const [s, o, a] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
2598
2609
  function u(f) {
@@ -2603,10 +2614,10 @@ function Ka({ attrs: t, schema: e }, n) {
2603
2614
  }
2604
2615
  function c(f, l) {
2605
2616
  const p = V(o, f, l), y = Ae(o, f, l);
2606
- d(p), d(y), !p && !y && u(Mr(e, f, l, Fa));
2617
+ d(p), d(y), !p && !y && u(Mr(e, f, l, Na));
2607
2618
  }
2608
2619
  for (const f of n)
2609
- for (const { etype: l, lookupPair: p, linkLabel: y } of Na(f)) {
2620
+ for (const { etype: l, lookupPair: p, linkLabel: y } of Ka(f)) {
2610
2621
  const b = p[0];
2611
2622
  if (y) {
2612
2623
  c(l, y);
@@ -2628,12 +2639,12 @@ function Ka({ attrs: t, schema: e }, n) {
2628
2639
  }
2629
2640
  for (const f of n) {
2630
2641
  const [l, p, y, b] = f;
2631
- if ($a.has(l)) {
2642
+ if (Da.has(l)) {
2632
2643
  const _ = V(o, p, "id");
2633
2644
  d(_), _ || u(Tt(e, p, "id", { "unique?": !0 }));
2634
2645
  for (const w of Object.keys(b)) {
2635
2646
  const g = V(o, p, w);
2636
- if (d(g), Ua.has(l) && (g || u(Tt(e, p, w, w === "id" ? { "unique?": !0 } : null))), Da.has(l)) {
2647
+ if (d(g), La.has(l) && (g || u(Tt(e, p, w, w === "id" ? { "unique?": !0 } : null))), Ua.has(l)) {
2637
2648
  const m = Ae(o, p, w);
2638
2649
  !g && !m && u(Mr(e, p, w)), d(m);
2639
2650
  }
@@ -2642,8 +2653,8 @@ function Ka({ attrs: t, schema: e }, n) {
2642
2653
  }
2643
2654
  return [o, a];
2644
2655
  }
2645
- function qa(t, e) {
2646
- const r = (Array.isArray(e) ? e : [e]).flatMap((u) => _a(u)), [i, s] = Ka(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), a = r.flatMap((u) => Pa(o, u));
2656
+ function Wa(t, e) {
2657
+ const r = (Array.isArray(e) ? e : [e]).flatMap((u) => ga(u)), [i, s] = qa(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), a = r.flatMap((u) => Ia(o, u));
2647
2658
  return [...s, ...a];
2648
2659
  }
2649
2660
  var de = function(t, e, n, r) {
@@ -2677,7 +2688,7 @@ function Rr(t, e) {
2677
2688
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2678
2689
  }
2679
2690
  const it = "__meta";
2680
- class Wa {
2691
+ class za {
2681
2692
  constructor(e, n) {
2682
2693
  }
2683
2694
  }
@@ -2952,13 +2963,13 @@ var pe = function(t, e, n, r) {
2952
2963
  d((r = r.apply(t, e || [])).next());
2953
2964
  });
2954
2965
  };
2955
- const za = 6, Va = ["kv", "querySubs", "syncSubs"];
2956
- function Ba(t) {
2966
+ const Va = 6, Ba = ["kv", "querySubs", "syncSubs"];
2967
+ function Ga(t) {
2957
2968
  return function(n) {
2958
2969
  console.error("Error in IndexedDB event", { source: t, event: n });
2959
2970
  };
2960
2971
  }
2961
- function Ga(t) {
2972
+ function Qa(t) {
2962
2973
  return pe(this, void 0, void 0, function* () {
2963
2974
  return new Promise((e) => {
2964
2975
  const n = indexedDB.open(t);
@@ -2974,7 +2985,7 @@ function Ga(t) {
2974
2985
  });
2975
2986
  });
2976
2987
  }
2977
- function Qa(t, e, n) {
2988
+ function Ha(t, e, n) {
2978
2989
  return pe(this, void 0, void 0, function* () {
2979
2990
  const r = (
2980
2991
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3018,9 +3029,9 @@ function xr(t, e, n) {
3018
3029
  });
3019
3030
  });
3020
3031
  }
3021
- function Ha(t, e) {
3032
+ function Ya(t, e) {
3022
3033
  return pe(this, void 0, void 0, function* () {
3023
- const n = yield Ga(`instant_${t}_5`);
3034
+ const n = yield Qa(`instant_${t}_5`);
3024
3035
  if (!n)
3025
3036
  return;
3026
3037
  const r = yield new Promise((c, f) => {
@@ -3043,7 +3054,7 @@ function Ha(t, e) {
3043
3054
  for (const [c, f] of r)
3044
3055
  switch (c) {
3045
3056
  case "querySubs": {
3046
- const l = Qa(c, f, o);
3057
+ const l = Ha(c, f, o);
3047
3058
  a.push(l);
3048
3059
  break;
3049
3060
  }
@@ -3066,9 +3077,9 @@ function Ha(t, e) {
3066
3077
  });
3067
3078
  }
3068
3079
  const $r = /* @__PURE__ */ new Map();
3069
- class Ki extends Wa {
3080
+ class Ki extends za {
3070
3081
  constructor(e, n) {
3071
- super(e, n), this.dbName = `instant_${e}_${za}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3082
+ super(e, n), this.dbName = `instant_${e}_${Va}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3072
3083
  }
3073
3084
  _init() {
3074
3085
  return new Promise((e, n) => {
@@ -3079,8 +3090,8 @@ class Ki extends Wa {
3079
3090
  }, i.onsuccess = (s) => {
3080
3091
  const a = s.target.result;
3081
3092
  if (r) {
3082
- const u = Ha(this._appId, a).catch((d) => {
3083
- Ba("Error upgrading store from version 5 to 6.")(d);
3093
+ const u = Ya(this._appId, a).catch((d) => {
3094
+ Ga("Error upgrading store from version 5 to 6.")(d);
3084
3095
  });
3085
3096
  $r.set(this.dbName, u), u.then(() => e(a)).catch(() => e(a));
3086
3097
  } else {
@@ -3094,7 +3105,7 @@ class Ki extends Wa {
3094
3105
  }
3095
3106
  _upgradeStore(e) {
3096
3107
  const r = e.target.result;
3097
- for (const i of Va)
3108
+ for (const i of Ba)
3098
3109
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3099
3110
  }
3100
3111
  getItem(e) {
@@ -3169,7 +3180,7 @@ class Ki extends Wa {
3169
3180
  });
3170
3181
  }
3171
3182
  }
3172
- var Ya = function(t, e, n, r) {
3183
+ var Ja = function(t, e, n, r) {
3173
3184
  function i(s) {
3174
3185
  return s instanceof n ? s : new n(function(o) {
3175
3186
  o(s);
@@ -3198,7 +3209,7 @@ var Ya = function(t, e, n, r) {
3198
3209
  };
3199
3210
  class qi {
3200
3211
  static getIsOnline() {
3201
- return Ya(this, void 0, void 0, function* () {
3212
+ return Ja(this, void 0, void 0, function* () {
3202
3213
  return navigator.onLine;
3203
3214
  });
3204
3215
  }
@@ -3223,7 +3234,7 @@ class Ke extends Error {
3223
3234
  return "InstantError";
3224
3235
  }
3225
3236
  }
3226
- var Ja = function(t, e, n, r) {
3237
+ var Za = function(t, e, n, r) {
3227
3238
  function i(s) {
3228
3239
  return s instanceof n ? s : new n(function(o) {
3229
3240
  o(s);
@@ -3263,7 +3274,7 @@ class Dt extends Ke {
3263
3274
  }
3264
3275
  }
3265
3276
  function ue(t, e) {
3266
- return Ja(this, void 0, void 0, function* () {
3277
+ return Za(this, void 0, void 0, function* () {
3267
3278
  const n = yield fetch(t, e), r = yield n.json();
3268
3279
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Dt({ status: n.status, body: r }));
3269
3280
  });
@@ -3295,14 +3306,14 @@ var ze = function(t, e, n, r) {
3295
3306
  d((r = r.apply(t, e || [])).next());
3296
3307
  });
3297
3308
  };
3298
- function Za({ apiURI: t, appId: e, email: n }) {
3309
+ function Xa({ apiURI: t, appId: e, email: n }) {
3299
3310
  return ue(`${t}/runtime/auth/send_magic_code`, {
3300
3311
  method: "POST",
3301
3312
  headers: { "content-type": "application/json" },
3302
3313
  body: JSON.stringify({ "app-id": e, email: n })
3303
3314
  });
3304
3315
  }
3305
- function Xa(t) {
3316
+ function eu(t) {
3306
3317
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3307
3318
  return yield ue(`${e}/runtime/auth/verify_magic_code`, {
3308
3319
  method: "POST",
@@ -3315,7 +3326,7 @@ function Xa(t) {
3315
3326
  });
3316
3327
  });
3317
3328
  }
3318
- function eu(t) {
3329
+ function tu(t) {
3319
3330
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3320
3331
  return yield ue(`${e}/runtime/auth/verify_refresh_token`, {
3321
3332
  method: "POST",
@@ -3327,7 +3338,7 @@ function eu(t) {
3327
3338
  });
3328
3339
  });
3329
3340
  }
3330
- function tu(t) {
3341
+ function nu(t) {
3331
3342
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3332
3343
  return yield ue(`${e}/runtime/auth/sign_in_guest`, {
3333
3344
  method: "POST",
@@ -3352,7 +3363,7 @@ function Dr(t) {
3352
3363
  });
3353
3364
  });
3354
3365
  }
3355
- function nu(t) {
3366
+ function ru(t) {
3356
3367
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3357
3368
  return yield ue(`${e}/runtime/oauth/id_token`, {
3358
3369
  method: "POST",
@@ -3367,7 +3378,7 @@ function nu(t) {
3367
3378
  });
3368
3379
  });
3369
3380
  }
3370
- function ru(t) {
3381
+ function iu(t) {
3371
3382
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3372
3383
  return yield ue(`${e}/runtime/signout`, {
3373
3384
  method: "POST",
@@ -3408,7 +3419,7 @@ var ft = function(t, e, n, r) {
3408
3419
  d((r = r.apply(t, e || [])).next());
3409
3420
  });
3410
3421
  };
3411
- function iu(t) {
3422
+ function su(t) {
3412
3423
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: a }) {
3413
3424
  const u = {
3414
3425
  app_id: n,
@@ -3423,7 +3434,7 @@ function iu(t) {
3423
3434
  });
3424
3435
  });
3425
3436
  }
3426
- function su(t) {
3437
+ function ou(t) {
3427
3438
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3428
3439
  const { data: s } = yield ue(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3429
3440
  method: "DELETE",
@@ -3435,7 +3446,7 @@ function su(t) {
3435
3446
  return s;
3436
3447
  });
3437
3448
  }
3438
- function ou(t) {
3449
+ function au(t) {
3439
3450
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3440
3451
  const { data: o } = yield ue(`${e}/storage/signed-upload-url`, {
3441
3452
  method: "POST",
@@ -3451,7 +3462,7 @@ function ou(t) {
3451
3462
  return o;
3452
3463
  });
3453
3464
  }
3454
- function au(t, e) {
3465
+ function uu(t, e) {
3455
3466
  return ft(this, void 0, void 0, function* () {
3456
3467
  return (yield fetch(t, {
3457
3468
  method: "PUT",
@@ -3462,7 +3473,7 @@ function au(t, e) {
3462
3473
  })).ok;
3463
3474
  });
3464
3475
  }
3465
- function uu(t) {
3476
+ function cu(t) {
3466
3477
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3467
3478
  const { data: s } = yield ue(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3468
3479
  method: "GET",
@@ -3484,7 +3495,7 @@ function Ur(t, e) {
3484
3495
  n[r] = t[r];
3485
3496
  }), n;
3486
3497
  }
3487
- function cu(t, e, n) {
3498
+ function du(t, e, n) {
3488
3499
  var r, i;
3489
3500
  const s = {
3490
3501
  peers: {}
@@ -3502,7 +3513,7 @@ function cu(t, e, n) {
3502
3513
  }
3503
3514
  return s;
3504
3515
  }
3505
- function du(t, e) {
3516
+ function fu(t, e) {
3506
3517
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !vr(t.user, e.user)) || !gi(t.peers, e.peers))
3507
3518
  return !0;
3508
3519
  for (const r of Object.keys(t.peers))
@@ -3550,8 +3561,8 @@ function Nr(t) {
3550
3561
  }, e;
3551
3562
  }, {});
3552
3563
  }
3553
- const Bn = "v0.22.76";
3554
- function fu(t, e) {
3564
+ const Bn = "v0.22.77-experimental.drewh-entity-caching.19941365378.1";
3565
+ function lu(t, e) {
3555
3566
  return {
3556
3567
  info: t ? (...n) => console.info(...n, e()) : () => {
3557
3568
  },
@@ -3635,7 +3646,7 @@ const Kr = [
3635
3646
  "before",
3636
3647
  "fields",
3637
3648
  "aggregate"
3638
- ], lu = (t) => t.valueType || "unknown", Bi = (t, e, n = !1) => {
3649
+ ], hu = (t) => t.valueType || "unknown", Bi = (t, e, n = !1) => {
3639
3650
  if (n || t == null)
3640
3651
  return !0;
3641
3652
  switch (e) {
@@ -3650,7 +3661,7 @@ const Kr = [
3650
3661
  default:
3651
3662
  return !0;
3652
3663
  }
3653
- }, hu = (t, e, n, r, i, s, o) => {
3664
+ }, pu = (t, e, n, r, i, s, o) => {
3654
3665
  const a = s.valueType === "json", u = (d, c, f) => {
3655
3666
  if (!Bi(f, c, a))
3656
3667
  throw new R(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
@@ -3683,16 +3694,16 @@ const Kr = [
3683
3694
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
3684
3695
  }
3685
3696
  }, Ue = (t, e, n, r, i) => {
3686
- const s = lu(n), o = n.valueType === "json";
3697
+ const s = hu(n), o = n.valueType === "json";
3687
3698
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3688
3699
  if (o)
3689
3700
  return;
3690
3701
  const u = t;
3691
3702
  for (const [d, c] of Object.entries(u))
3692
- hu(d, c, s, e, r, n, `${i}.${d}`);
3703
+ pu(d, c, s, e, r, n, `${i}.${d}`);
3693
3704
  } else if (!Bi(t, s, o))
3694
3705
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3695
- }, pu = (t, e, n, r, i) => {
3706
+ }, yu = (t, e, n, r, i) => {
3696
3707
  const s = t.split(".");
3697
3708
  if (s.length < 2)
3698
3709
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -3742,7 +3753,7 @@ const Kr = [
3742
3753
  continue;
3743
3754
  }
3744
3755
  if (i.includes(".")) {
3745
- pu(i, s, e, n, `${r}.${i}`);
3756
+ yu(i, s, e, n, `${r}.${i}`);
3746
3757
  continue;
3747
3758
  }
3748
3759
  const o = n.entities[e];
@@ -3762,7 +3773,7 @@ const Kr = [
3762
3773
  Ue(s, i, d, e, `${r}.${i}`);
3763
3774
  }
3764
3775
  }
3765
- }, yu = (t, e, n, r, i = 0) => {
3776
+ }, bu = (t, e, n, r, i = 0) => {
3766
3777
  for (const o of Object.keys(t))
3767
3778
  if (!Kr.includes(o))
3768
3779
  throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Kr.join(", ")}. Found: ${o}`, r);
@@ -3801,7 +3812,7 @@ const Kr = [
3801
3812
  const a = t[o];
3802
3813
  if (typeof a != "object" || a === null)
3803
3814
  throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3804
- yu(a, e, n, `${r}.$`, i);
3815
+ bu(a, e, n, `${r}.$`, i);
3805
3816
  }
3806
3817
  }, qr = (t, e) => {
3807
3818
  if (typeof t != "object" || t === null)
@@ -3828,19 +3839,19 @@ class ie extends Error {
3828
3839
  super(e), this.name = "TransactionValidationError";
3829
3840
  }
3830
3841
  }
3831
- const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Hi(e)}`), zr = {
3842
+ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", _u = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Hi(e)}`), zr = {
3832
3843
  string: (t) => typeof t == "string",
3833
3844
  number: (t) => typeof t == "number" && !isNaN(t),
3834
3845
  boolean: (t) => typeof t == "boolean",
3835
3846
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3836
3847
  json: () => !0
3837
- }, _u = (t, e) => {
3848
+ }, gu = (t, e) => {
3838
3849
  var n, r;
3839
3850
  return t == null ? !0 : (r = (n = zr[e.valueType]) === null || n === void 0 ? void 0 : n.call(zr, t)) !== null && r !== void 0 ? r : !1;
3840
3851
  }, Yi = (t, e) => {
3841
3852
  const n = e.entities[t];
3842
3853
  if (!n)
3843
- throw bu(t, Object.keys(e.entities));
3854
+ throw _u(t, Object.keys(e.entities));
3844
3855
  return n;
3845
3856
  }, Jt = (t, e, n) => {
3846
3857
  const r = Yi(t, n);
@@ -3850,7 +3861,7 @@ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`E
3850
3861
  if (i === "id")
3851
3862
  continue;
3852
3863
  const o = r.attrs[i];
3853
- if (o && !_u(s, o))
3864
+ if (o && !gu(s, o))
3854
3865
  throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
3855
3866
  }
3856
3867
  }, Vr = (t, e, n) => {
@@ -3871,7 +3882,7 @@ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`E
3871
3882
  throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
3872
3883
  }
3873
3884
  }
3874
- }, gu = {
3885
+ }, Tu = {
3875
3886
  create: Jt,
3876
3887
  update: Jt,
3877
3888
  merge: Jt,
@@ -3879,7 +3890,7 @@ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`E
3879
3890
  unlink: Vr,
3880
3891
  delete: () => {
3881
3892
  }
3882
- }, Tu = (t, e) => {
3893
+ }, wu = (t, e) => {
3883
3894
  if (!e)
3884
3895
  return;
3885
3896
  const [n, r, i, s] = t;
@@ -3887,9 +3898,9 @@ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`E
3887
3898
  throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
3888
3899
  if (typeof r != "string")
3889
3900
  throw new ie(`Entity name must be a string, but received: ${typeof r}`);
3890
- const o = gu[n];
3901
+ const o = Tu[n];
3891
3902
  o && s !== void 0 && o(r, s, e);
3892
- }, wu = (t, e) => {
3903
+ }, mu = (t, e) => {
3893
3904
  const n = Array.isArray(t) ? t : [t];
3894
3905
  for (const r of n) {
3895
3906
  if (!r || typeof r != "object")
@@ -3899,7 +3910,7 @@ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`E
3899
3910
  for (const i of r.__ops) {
3900
3911
  if (!Array.isArray(i))
3901
3912
  throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
3902
- Tu(i, e);
3913
+ wu(i, e);
3903
3914
  }
3904
3915
  }
3905
3916
  };
@@ -3961,7 +3972,7 @@ class Gr {
3961
3972
  return this.conn.send(JSON.stringify(e));
3962
3973
  }
3963
3974
  }
3964
- class mu {
3975
+ class vu {
3965
3976
  constructor(e, n) {
3966
3977
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Ji++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
3967
3978
  this.initParams || this.handleError();
@@ -4074,14 +4085,14 @@ var Qr = function(t, e, n, r) {
4074
4085
  d((r = r.apply(t, e || [])).next());
4075
4086
  });
4076
4087
  };
4077
- function vu(t, e) {
4088
+ function Su(t, e) {
4078
4089
  const n = t.values;
4079
4090
  if (n)
4080
4091
  for (const r of n.entities || [])
4081
4092
  r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Oi(r.store);
4082
4093
  return t;
4083
4094
  }
4084
- function Su(t, e) {
4095
+ function Ou(t, e) {
4085
4096
  var n, r;
4086
4097
  if (!((n = e.values) === null || n === void 0) && n.entities) {
4087
4098
  const i = [];
@@ -4093,7 +4104,7 @@ function Su(t, e) {
4093
4104
  } else
4094
4105
  return e;
4095
4106
  }
4096
- function Ou(t, e, n) {
4107
+ function Eu(t, e, n) {
4097
4108
  var r, i;
4098
4109
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4099
4110
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
@@ -4120,7 +4131,7 @@ function Yr(t, e) {
4120
4131
  break;
4121
4132
  }
4122
4133
  }
4123
- function Eu(t, e) {
4134
+ function Au(t, e) {
4124
4135
  var n, r, i, s;
4125
4136
  const o = {};
4126
4137
  for (const { action: a, triple: u } of e) {
@@ -4148,14 +4159,14 @@ function Eu(t, e) {
4148
4159
  function wt(t, e) {
4149
4160
  return { [t.table]: e.map((n) => n.entity) };
4150
4161
  }
4151
- function Au(t, e) {
4162
+ function ku(t, e) {
4152
4163
  var n;
4153
4164
  if (t.orderFieldType)
4154
4165
  return t.orderFieldType;
4155
4166
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = Te(e([]), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4156
4167
  return t.orderFieldType = r, r;
4157
4168
  }
4158
- function ku(t, e, n) {
4169
+ function ju(t, e, n) {
4159
4170
  const r = e;
4160
4171
  if (t.orderField === "serverCreatedAt") {
4161
4172
  n.sort(t.orderDirection === "asc" ? function(o, a) {
@@ -4176,13 +4187,13 @@ var ve;
4176
4187
  (function(t) {
4177
4188
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4178
4189
  })(ve || (ve = {}));
4179
- class ju {
4190
+ class Cu {
4180
4191
  constructor(e, n, r, i, s) {
4181
4192
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new Tn({
4182
4193
  persister: n,
4183
- merge: Ou,
4184
- serialize: Su,
4185
- parse: (o, a) => vu(a, this.config.useDateObjects),
4194
+ merge: Eu,
4195
+ serialize: Ou,
4196
+ parse: (o, a) => Su(a, this.config.useDateObjects),
4186
4197
  objectSize: (o) => {
4187
4198
  var a;
4188
4199
  return ((a = o.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
@@ -4384,9 +4395,9 @@ class ju {
4384
4395
  e: for (const [g, m] of Object.entries(f))
4385
4396
  for (let E = 0; E < p.length; E++) {
4386
4397
  const S = p[E];
4387
- if (oo(S.store, g)) {
4398
+ if (ao(S.store, g)) {
4388
4399
  Yr(S.store, m);
4389
- const I = Zt(a, S.store), x = Eu(S.store, m)[g];
4400
+ const I = Zt(a, S.store), x = Au(S.store, m)[g];
4390
4401
  I ? (y.push({
4391
4402
  oldEntity: S.entity,
4392
4403
  newEntity: I,
@@ -4417,8 +4428,8 @@ class ju {
4417
4428
  const _ = [];
4418
4429
  for (const g of c.sort().reverse())
4419
4430
  _.push(p[g].entity), p.splice(g, 1);
4420
- const w = Au(a, this.createStore);
4421
- ku(a, w, p), this.notifyCbs(o, {
4431
+ const w = ku(a, this.createStore);
4432
+ ju(a, w, p), this.notifyCbs(o, {
4422
4433
  type: ve.SyncTransaction,
4423
4434
  data: wt(a, (i = a.values) === null || i === void 0 ? void 0 : i.entities),
4424
4435
  added: b,
@@ -4485,7 +4496,7 @@ var F = function(t, e, n, r) {
4485
4496
  }
4486
4497
  d((r = r.apply(t, e || [])).next());
4487
4498
  });
4488
- }, Cu = function(t, e) {
4499
+ }, Pu = function(t, e) {
4489
4500
  var n = {};
4490
4501
  for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
4491
4502
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
@@ -4499,23 +4510,23 @@ const le = {
4499
4510
  AUTHENTICATED: "authenticated",
4500
4511
  CLOSED: "closed",
4501
4512
  ERRORED: "errored"
4502
- }, Pu = 3e4, Iu = 3e4, Mu = 200, Ru = {
4513
+ }, Iu = 3e4, Mu = 3e4, Ru = 200, xu = {
4503
4514
  apiURI: "https://api.instantdb.com",
4504
4515
  websocketURI: "wss://api.instantdb.com/runtime/session"
4505
4516
  }, Xt = "_instant_oauth_redirect", Qe = "currentUser";
4506
- function xu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4517
+ function $u({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4507
4518
  if (!i)
4508
4519
  return new Gr(`${r}?app_id=${e}`);
4509
4520
  switch (t) {
4510
4521
  case "ws":
4511
4522
  return new Gr(`${r}?app_id=${e}`);
4512
4523
  case "sse":
4513
- return new mu(i, `${n}/runtime/sse?app_id=${e}`);
4524
+ return new vu(i, `${n}/runtime/sse?app_id=${e}`);
4514
4525
  default:
4515
4526
  throw new Error("Unknown transport type " + t);
4516
4527
  }
4517
4528
  }
4518
- function $u() {
4529
+ function Du() {
4519
4530
  return typeof window < "u" || typeof chrome < "u";
4520
4531
  }
4521
4532
  const Jr = {
@@ -4524,7 +4535,7 @@ const Jr = {
4524
4535
  "refresh-presence": !0,
4525
4536
  "patch-presence": !0
4526
4537
  };
4527
- function Du(t, e) {
4538
+ function Uu(t, e) {
4528
4539
  var n;
4529
4540
  const r = typeof t == "string" ? JSON.parse(t) : t;
4530
4541
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
@@ -4533,12 +4544,12 @@ function Du(t, e) {
4533
4544
  }
4534
4545
  return r;
4535
4546
  }
4536
- function Uu(t, e) {
4547
+ function Lu(t, e) {
4537
4548
  var n;
4538
4549
  const r = Object.assign({}, e);
4539
4550
  return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Si(e.result.store) })), r;
4540
4551
  }
4541
- function Lu(t, e) {
4552
+ function Fu(t, e) {
4542
4553
  switch (t) {
4543
4554
  case "pendingMutations":
4544
4555
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4546,7 +4557,7 @@ function Lu(t, e) {
4546
4557
  return e;
4547
4558
  }
4548
4559
  }
4549
- function Fu(t, e) {
4560
+ function Nu(t, e) {
4550
4561
  switch (t) {
4551
4562
  case "pendingMutations":
4552
4563
  return [...e.entries()];
@@ -4554,7 +4565,7 @@ function Fu(t, e) {
4554
4565
  return e;
4555
4566
  }
4556
4567
  }
4557
- function Nu(t, e, n) {
4568
+ function Ku(t, e, n) {
4558
4569
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
4559
4570
  return r && !i && n && (n.result = r), n || e;
4560
4571
  }
@@ -4564,7 +4575,7 @@ function Zr(t) {
4564
4575
  return a == u ? r < s ? -1 : r > s ? 1 : 0 : a - u;
4565
4576
  });
4566
4577
  }
4567
- class Ku {
4578
+ class qu {
4568
4579
  constructor(e, n = Ki, r = qi, i, s) {
4569
4580
  var o, a, u;
4570
4581
  if (this._isOnline = !0, this._isShutdown = !1, this.status = le.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (d, c, f) => {
@@ -4597,9 +4608,9 @@ class Ku {
4597
4608
  }, this.notifyQueryError = (d, c) => {
4598
4609
  (this.queryCbs[d] || []).forEach((l) => l.cb({ error: c }));
4599
4610
  }, this.pushTx = (d) => {
4600
- this.config.disableValidation || wu(d, this.config.schema);
4611
+ this.config.disableValidation || mu(d, this.config.schema);
4601
4612
  try {
4602
- const c = qa({
4613
+ const c = Wa({
4603
4614
  attrs: this.optimisticAttrs(),
4604
4615
  schema: this.config.schema,
4605
4616
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4688,7 +4699,7 @@ class Ku {
4688
4699
  return;
4689
4700
  }
4690
4701
  this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4691
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Ru), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : Iu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : Mu, this._log = fu(e.verbose || Vn || Wi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Bn }), this.config.schema && (this._linkIndex = Nr(this.config.schema)), !!$u()) {
4702
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, xu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : Mu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : Ru, this._log = lu(e.verbose || Vn || Wi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Bn }), this.config.schema && (this._linkIndex = Nr(this.config.schema)), !!Du()) {
4692
4703
  if (!e.appId)
4693
4704
  throw new Error("Instant must be initialized with an appId.");
4694
4705
  if (!Fe(e.appId))
@@ -4703,7 +4714,7 @@ class Ku {
4703
4714
  } catch (f) {
4704
4715
  this._log.error("[error] handle broadcast channel", f);
4705
4716
  }
4706
- }))), this._initStorage(n), this._syncTable = new ju(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4717
+ }))), this._initStorage(n), this._syncTable = new Cu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4707
4718
  useDateObjects: this.config.useDateObjects
4708
4719
  }, this._log, (d) => Et(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
4709
4720
  this._isOnline = d, this._startSocket(), r.listen((c) => {
@@ -4728,9 +4739,9 @@ class Ku {
4728
4739
  _initStorage(e) {
4729
4740
  this.querySubs = new Tn({
4730
4741
  persister: new e(this.config.appId, "querySubs"),
4731
- merge: Nu,
4732
- serialize: Uu,
4733
- parse: (n, r) => Du(r, this.config.useDateObjects),
4742
+ merge: Ku,
4743
+ serialize: Lu,
4744
+ parse: (n, r) => Uu(r, this.config.useDateObjects),
4734
4745
  // objectSize
4735
4746
  objectSize: (n) => {
4736
4747
  var r, i, s, o;
@@ -4749,8 +4760,8 @@ class Ku {
4749
4760
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Tn({
4750
4761
  persister: new e(this.config.appId, "kv"),
4751
4762
  merge: this._onMergeKv,
4752
- serialize: Fu,
4753
- parse: Lu,
4763
+ serialize: Nu,
4764
+ parse: Fu,
4754
4765
  objectSize: () => 0,
4755
4766
  logger: this._log,
4756
4767
  saveThrottleMs: 100,
@@ -4781,7 +4792,7 @@ class Ku {
4781
4792
  if (s)
4782
4793
  i.resolve({ status: e, eventId: n });
4783
4794
  else if (r != null && r.type) {
4784
- const { status: o } = r, a = Cu(r, ["status"]);
4795
+ const { status: o } = r, a = Pu(r, ["status"]);
4785
4796
  i.reject(new Dt({
4786
4797
  // @ts-expect-error body.type is not constant typed
4787
4798
  body: a,
@@ -5040,7 +5051,7 @@ class Ku {
5040
5051
  if (!this.querySubs)
5041
5052
  return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
5042
5053
  const s = z(e), o = this._startQuerySub(e, s);
5043
- return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Pu), i.promise;
5054
+ return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Iu), i.promise;
5044
5055
  }
5045
5056
  _completeQueryOnce(e, n, r) {
5046
5057
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5101,7 +5112,7 @@ class Ku {
5101
5112
  a = !0;
5102
5113
  continue;
5103
5114
  }
5104
- const b = a ? ga(o, p) : p;
5115
+ const b = a ? Ta(o, p) : p;
5105
5116
  l.push(b);
5106
5117
  }
5107
5118
  return a ? l : c;
@@ -5149,7 +5160,7 @@ class Ku {
5149
5160
  }
5150
5161
  _applyOptimisticUpdates(e, n, r) {
5151
5162
  for (const [i, s] of n)
5152
- (!s["tx-id"] || r && s["tx-id"] > r) && (e = To(e, s["tx-steps"]));
5163
+ (!s["tx-id"] || r && s["tx-id"] > r) && (e = wo(e, s["tx-steps"]));
5153
5164
  return e;
5154
5165
  }
5155
5166
  /** Re-compute all subscriptions */
@@ -5258,7 +5269,7 @@ class Ku {
5258
5269
  return;
5259
5270
  }
5260
5271
  const e = this._transport;
5261
- this._transport = xu({
5272
+ this._transport = $u({
5262
5273
  transportType: this._transportType,
5263
5274
  appId: this.config.appId,
5264
5275
  apiURI: this.config.apiURI,
@@ -5461,7 +5472,7 @@ class Ku {
5461
5472
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5462
5473
  }
5463
5474
  sendMagicCode({ email: e }) {
5464
- return Za({
5475
+ return Xa({
5465
5476
  apiURI: this.config.apiURI,
5466
5477
  appId: this.config.appId,
5467
5478
  email: e
@@ -5470,7 +5481,7 @@ class Ku {
5470
5481
  signInWithMagicCode(e) {
5471
5482
  return F(this, arguments, void 0, function* ({ email: n, code: r }) {
5472
5483
  var i;
5473
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Xa({
5484
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield eu({
5474
5485
  apiURI: this.config.apiURI,
5475
5486
  appId: this.config.appId,
5476
5487
  email: n,
@@ -5482,7 +5493,7 @@ class Ku {
5482
5493
  }
5483
5494
  signInWithCustomToken(e) {
5484
5495
  return F(this, void 0, void 0, function* () {
5485
- const n = yield eu({
5496
+ const n = yield tu({
5486
5497
  apiURI: this.config.apiURI,
5487
5498
  appId: this.config.appId,
5488
5499
  refreshToken: e
@@ -5492,7 +5503,7 @@ class Ku {
5492
5503
  }
5493
5504
  signInAsGuest() {
5494
5505
  return F(this, void 0, void 0, function* () {
5495
- const e = yield tu({
5506
+ const e = yield nu({
5496
5507
  apiURI: this.config.apiURI,
5497
5508
  appId: this.config.appId
5498
5509
  });
@@ -5508,7 +5519,7 @@ class Ku {
5508
5519
  this._log.info("[auth-invalidate] skipped invalidateToken");
5509
5520
  return;
5510
5521
  }
5511
- ru({
5522
+ iu({
5512
5523
  apiURI: this.config.apiURI,
5513
5524
  appId: this.config.appId,
5514
5525
  refreshToken: i
@@ -5566,7 +5577,7 @@ class Ku {
5566
5577
  signInWithIdToken(e) {
5567
5578
  return F(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5568
5579
  var s;
5569
- const o = yield this.getCurrentUser(), a = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, u = yield nu({
5580
+ const o = yield this.getCurrentUser(), a = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, u = yield ru({
5570
5581
  apiURI: this.config.apiURI,
5571
5582
  appId: this.config.appId,
5572
5583
  idToken: n,
@@ -5607,7 +5618,7 @@ class Ku {
5607
5618
  // TODO: look into typing again
5608
5619
  getPresence(e, n, r = {}) {
5609
5620
  const i = this._rooms[n], s = this._presence[n];
5610
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, cu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5621
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, du(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5611
5622
  }
5612
5623
  // TODO: look into typing again
5613
5624
  publishPresence(e, n, r) {
@@ -5657,7 +5668,7 @@ class Ku {
5657
5668
  }
5658
5669
  _notifyPresenceSub(e, n) {
5659
5670
  const r = this.getPresence("", e, n);
5660
- r && (n.prev && !du(r, n.prev) || (n.prev = r, n.cb(r)));
5671
+ r && (n.prev && !fu(r, n.prev) || (n.prev = r, n.cb(r)));
5661
5672
  }
5662
5673
  _patchPresencePeers(e, n) {
5663
5674
  var r, i, s;
@@ -5731,14 +5742,14 @@ class Ku {
5731
5742
  return F(this, void 0, void 0, function* () {
5732
5743
  var i;
5733
5744
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5734
- return iu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5745
+ return su(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5735
5746
  });
5736
5747
  }
5737
5748
  deleteFile(e) {
5738
5749
  return F(this, void 0, void 0, function* () {
5739
5750
  var n;
5740
5751
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5741
- return yield su({
5752
+ return yield ou({
5742
5753
  apiURI: this.config.apiURI,
5743
5754
  appId: this.config.appId,
5744
5755
  path: e,
@@ -5751,20 +5762,20 @@ class Ku {
5751
5762
  upload(e, n) {
5752
5763
  return F(this, void 0, void 0, function* () {
5753
5764
  var r;
5754
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, a = yield ou({
5765
+ const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, a = yield au({
5755
5766
  apiURI: this.config.apiURI,
5756
5767
  appId: this.config.appId,
5757
5768
  fileName: o,
5758
5769
  refreshToken: s
5759
5770
  });
5760
- return yield au(a, n);
5771
+ return yield uu(a, n);
5761
5772
  });
5762
5773
  }
5763
5774
  getDownloadUrl(e) {
5764
5775
  return F(this, void 0, void 0, function* () {
5765
5776
  var n;
5766
5777
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5767
- return yield uu({
5778
+ return yield cu({
5768
5779
  apiURI: this.config.apiURI,
5769
5780
  appId: this.config.appId,
5770
5781
  path: e,
@@ -5773,7 +5784,7 @@ class Ku {
5773
5784
  });
5774
5785
  }
5775
5786
  }
5776
- function qu(t, e) {
5787
+ function Wu(t, e) {
5777
5788
  return new Lt(
5778
5789
  Zi(t, e),
5779
5790
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -5785,25 +5796,25 @@ function qu(t, e) {
5785
5796
  void 0
5786
5797
  );
5787
5798
  }
5788
- function Wu(t) {
5799
+ function zu(t) {
5789
5800
  return new Ut(t, {});
5790
5801
  }
5791
- function zu() {
5802
+ function Vu() {
5792
5803
  return new H("string", !0, !1);
5793
5804
  }
5794
- function Vu() {
5805
+ function Bu() {
5795
5806
  return new H("number", !0, !1);
5796
5807
  }
5797
- function Bu() {
5808
+ function Gu() {
5798
5809
  return new H("boolean", !0, !1);
5799
5810
  }
5800
- function Gu() {
5811
+ function Qu() {
5801
5812
  return new H("date", !0, !1);
5802
5813
  }
5803
- function Qu() {
5814
+ function Hu() {
5804
5815
  return new H("json", !0, !1);
5805
5816
  }
5806
- function Hu() {
5817
+ function Yu() {
5807
5818
  return new H("json", !0, !1);
5808
5819
  }
5809
5820
  function Zi(t, e) {
@@ -5822,7 +5833,7 @@ function Zi(t, e) {
5822
5833
  new Ut(d.attrs, Object.assign(Object.assign({}, o.fwd[u]), o.rev[u]))
5823
5834
  ]));
5824
5835
  }
5825
- function Yu({ entities: t, links: e, rooms: n }) {
5836
+ function Ju({ entities: t, links: e, rooms: n }) {
5826
5837
  const r = e ?? {}, i = n ?? {};
5827
5838
  return new Lt(
5828
5839
  Zi(t, r),
@@ -5835,23 +5846,23 @@ function Yu({ entities: t, links: e, rooms: n }) {
5835
5846
  i
5836
5847
  );
5837
5848
  }
5838
- const Kc = {
5849
+ const qc = {
5839
5850
  // constructs
5840
- graph: qu,
5841
- schema: Yu,
5842
- entity: Wu,
5851
+ graph: Wu,
5852
+ schema: Ju,
5853
+ entity: zu,
5843
5854
  // value types
5844
- string: zu,
5845
- number: Vu,
5846
- boolean: Bu,
5847
- date: Gu,
5848
- json: Qu,
5849
- any: Hu
5855
+ string: Vu,
5856
+ number: Bu,
5857
+ boolean: Gu,
5858
+ date: Qu,
5859
+ json: Hu,
5860
+ any: Yu
5850
5861
  };
5851
5862
  let mt;
5852
- function Ju(t, e) {
5863
+ function Zu(t, e) {
5853
5864
  mt == null || mt.dispose();
5854
- const n = rc(e), r = ec(e, a), i = Xu(Zu(t));
5865
+ const n = ic(e), r = tc(e, a), i = ec(Xu(t));
5855
5866
  function s(c) {
5856
5867
  var f;
5857
5868
  c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && a();
@@ -5873,10 +5884,10 @@ function Ju(t, e) {
5873
5884
  }
5874
5885
  return d();
5875
5886
  }
5876
- function Zu(t) {
5887
+ function Xu(t) {
5877
5888
  return `${Vn || zi ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
5878
5889
  }
5879
- function Xu(t) {
5890
+ function ec(t) {
5880
5891
  const e = document.createElement("iframe");
5881
5892
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
5882
5893
  width: "100%",
@@ -5885,7 +5896,7 @@ function Xu(t) {
5885
5896
  border: "none"
5886
5897
  }), { element: e };
5887
5898
  }
5888
- function ec(t, e) {
5899
+ function tc(t, e) {
5889
5900
  const n = `
5890
5901
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
5891
5902
  <rect width="512" height="512" fill="black"/>
@@ -5895,7 +5906,7 @@ function ec(t, e) {
5895
5906
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
5896
5907
  // pos
5897
5908
  position: "fixed"
5898
- }, tc(t.position)), {
5909
+ }, nc(t.position)), {
5899
5910
  height: "32px",
5900
5911
  width: "32px",
5901
5912
  // layout
@@ -5910,7 +5921,7 @@ function ec(t, e) {
5910
5921
  cursor: "pointer"
5911
5922
  })), r.addEventListener("click", e), { element: r };
5912
5923
  }
5913
- function tc(t) {
5924
+ function nc(t) {
5914
5925
  switch (t) {
5915
5926
  case "bottom-left":
5916
5927
  return { bottom: "24px", left: "24px" };
@@ -5922,7 +5933,7 @@ function tc(t) {
5922
5933
  return { top: "24px", left: "24px" };
5923
5934
  }
5924
5935
  }
5925
- function nc(t) {
5936
+ function rc(t) {
5926
5937
  switch (t) {
5927
5938
  case "bottom-left":
5928
5939
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -5934,23 +5945,23 @@ function nc(t) {
5934
5945
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
5935
5946
  }
5936
5947
  }
5937
- function rc(t) {
5948
+ function ic(t) {
5938
5949
  const e = document.createElement("div");
5939
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, nc(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
5950
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, rc(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
5940
5951
  function n() {
5941
5952
  return e.style.display !== "none";
5942
5953
  }
5943
5954
  return { element: e, isVisible: n };
5944
5955
  }
5945
- const ic = {
5956
+ const sc = {
5946
5957
  apiURI: "https://api.instantdb.com",
5947
5958
  websocketURI: "wss://api.instantdb.com/runtime/session"
5948
5959
  };
5949
- function sc() {
5960
+ function oc() {
5950
5961
  var t;
5951
5962
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
5952
5963
  }
5953
- function oc() {
5964
+ function ac() {
5954
5965
  var t;
5955
5966
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
5956
5967
  }
@@ -5958,23 +5969,23 @@ function wn(t) {
5958
5969
  const e = t.__adminToken;
5959
5970
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
5960
5971
  }
5961
- const mn = oc(), Xr = sc();
5962
- class ac {
5972
+ const mn = ac(), Xr = oc();
5973
+ class uc {
5963
5974
  constructor(e) {
5964
5975
  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);
5965
5976
  }
5966
5977
  }
5967
- class uc {
5978
+ class cc {
5968
5979
  constructor(e) {
5969
5980
  this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
5970
5981
  }
5971
5982
  }
5972
- function cc(t) {
5983
+ function dc(t) {
5973
5984
  return JSON.parse(JSON.stringify(t));
5974
5985
  }
5975
- class dc {
5986
+ class fc {
5976
5987
  constructor(e) {
5977
- this.tx = zn(), this._reactor = e, this.auth = new ac(this._reactor), this.storage = new uc(this._reactor);
5988
+ this.tx = zn(), this._reactor = e, this.auth = new uc(this._reactor), this.storage = new cc(this._reactor);
5978
5989
  }
5979
5990
  /**
5980
5991
  * Use this to write data! You can create, update, delete, and link objects
@@ -6157,22 +6168,22 @@ function ei(t) {
6157
6168
  const n = z(t);
6158
6169
  return Xr.set(t, n), n;
6159
6170
  }
6160
- function fc(t, e) {
6171
+ function lc(t, e) {
6161
6172
  return ei(t._reactor.config.schema) !== ei(e);
6162
6173
  }
6163
- function lc(t, e, n, r, i) {
6174
+ function hc(t, e, n, r, i) {
6164
6175
  var s;
6165
6176
  const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), a = mn[wn(o)];
6166
6177
  if (a)
6167
- return fc(a, o.schema) && a._reactor.updateSchema(o.schema), a;
6168
- const u = new Ku(Object.assign(Object.assign(Object.assign({}, ic), o), { cardinalityInference: !!o.schema }), e || Ki, n || qi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Bn }), i), d = new dc(u);
6169
- return mn[wn(o)] = d, hc(o.appId, o.devtool), d;
6178
+ return lc(a, o.schema) && a._reactor.updateSchema(o.schema), a;
6179
+ const u = new qu(Object.assign(Object.assign(Object.assign({}, sc), o), { cardinalityInference: !!o.schema }), e || Ki, n || qi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Bn }), i), d = new fc(u);
6180
+ return mn[wn(o)] = d, pc(o.appId, o.devtool), d;
6170
6181
  }
6171
- function hc(t, e) {
6182
+ function pc(t, e) {
6172
6183
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6173
6184
  return;
6174
6185
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6175
- n.allowedHosts.includes(window.location.hostname) && Ju(t, n);
6186
+ n.allowedHosts.includes(window.location.hostname) && Zu(t, n);
6176
6187
  }
6177
6188
  var vn = { exports: {} }, He = {};
6178
6189
  /**
@@ -6185,7 +6196,7 @@ var vn = { exports: {} }, He = {};
6185
6196
  * LICENSE file in the root directory of this source tree.
6186
6197
  */
6187
6198
  var ti;
6188
- function pc() {
6199
+ function yc() {
6189
6200
  if (ti) return He;
6190
6201
  ti = 1;
6191
6202
  var t = ci, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
@@ -6199,7 +6210,7 @@ function pc() {
6199
6210
  return He.Fragment = n, He.jsx = o, He.jsxs = o, He;
6200
6211
  }
6201
6212
  var Ye = {}, ni;
6202
- function yc() {
6213
+ function bc() {
6203
6214
  if (ni) return Ye;
6204
6215
  ni = 1;
6205
6216
  var t = {};
@@ -6800,10 +6811,10 @@ React keys must be passed directly to JSX without using spread:
6800
6811
  Ye.Fragment = i, Ye.jsx = Ss, Ye.jsxs = Os;
6801
6812
  }(), Ye;
6802
6813
  }
6803
- var bc = {};
6804
- bc.NODE_ENV === "production" ? vn.exports = pc() : vn.exports = yc();
6814
+ var _c = {};
6815
+ _c.NODE_ENV === "production" ? vn.exports = yc() : vn.exports = bc();
6805
6816
  var W = vn.exports;
6806
- const _c = {
6817
+ const gc = {
6807
6818
  isLoading: !0,
6808
6819
  data: void 0,
6809
6820
  pageInfo: void 0,
@@ -6812,9 +6823,9 @@ const _c = {
6812
6823
  function ri(t) {
6813
6824
  return Object.assign({ isLoading: !t, data: void 0, pageInfo: void 0, error: void 0 }, t || {});
6814
6825
  }
6815
- function gc(t, e, n) {
6826
+ function Tc(t, e, n) {
6816
6827
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6817
- const r = e ? cc(e) : null, i = z(r), s = at(ri(t._reactor.getPreviousResult(r))), o = ge(
6828
+ const r = e ? dc(e) : null, i = z(r), s = at(ri(t._reactor.getPreviousResult(r))), o = ge(
6818
6829
  (u) => (s.current = ri(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
6819
6830
  s.current = Object.assign({
6820
6831
  isLoading: !c,
@@ -6830,9 +6841,9 @@ function gc(t, e, n) {
6830
6841
  // Build a new subscribe function if the query changes
6831
6842
  [i]
6832
6843
  );
6833
- return { state: tn(o, () => s.current, () => _c), query: r };
6844
+ return { state: tn(o, () => s.current, () => gc), query: r };
6834
6845
  }
6835
- function Tc() {
6846
+ function wc() {
6836
6847
  const t = at(null);
6837
6848
  ke(() => {
6838
6849
  n();
@@ -6845,14 +6856,14 @@ function Tc() {
6845
6856
  }
6846
6857
  return { set: e, clear: n };
6847
6858
  }
6848
- const wc = 1e3;
6849
- function mc(t, e, n) {
6859
+ const mc = 1e3;
6860
+ function vc(t, e, n) {
6850
6861
  const r = at(n);
6851
6862
  r.current = n, ke(() => t.core._reactor.subscribeTopic(t.id, e, (s, o) => {
6852
6863
  r.current(s, o);
6853
6864
  }), [t.id, e]);
6854
6865
  }
6855
- function vc(t, e) {
6866
+ function Sc(t, e) {
6856
6867
  return ke(() => t.core._reactor.joinRoom(t.id), [t.id]), ge((r) => {
6857
6868
  t.core._reactor.publishTopic({
6858
6869
  roomType: t.type,
@@ -6862,7 +6873,7 @@ function vc(t, e) {
6862
6873
  });
6863
6874
  }, [t.id, e]);
6864
6875
  }
6865
- function Sc(t, e = {}) {
6876
+ function Oc(t, e = {}) {
6866
6877
  var n, r;
6867
6878
  const [i, s] = di(() => {
6868
6879
  var u;
@@ -6879,11 +6890,11 @@ function Sc(t, e = {}) {
6879
6890
  }, [t.type, t.id]);
6880
6891
  return nn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
6881
6892
  }
6882
- function Oc(t, e, n) {
6893
+ function Ec(t, e, n) {
6883
6894
  ke(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ke(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6884
6895
  }
6885
- function Ec(t, e, n = {}) {
6886
- const r = Tc(), i = Se.usePresence(t, {
6896
+ function Ac(t, e, n = {}) {
6897
+ const r = wc(), i = Se.usePresence(t, {
6887
6898
  keys: [e]
6888
6899
  }), s = nn(() => {
6889
6900
  var c;
@@ -6893,7 +6904,7 @@ function Ec(t, e, n = {}) {
6893
6904
  var f;
6894
6905
  t.core._reactor.publishPresence(t.type, t.id, {
6895
6906
  [e]: c
6896
- }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : wc, () => {
6907
+ }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : mc, () => {
6897
6908
  t.core._reactor.publishPresence(t.type, t.id, {
6898
6909
  [e]: null
6899
6910
  });
@@ -6911,20 +6922,20 @@ function Ec(t, e, n = {}) {
6911
6922
  };
6912
6923
  }
6913
6924
  const Se = {
6914
- useTopicEffect: mc,
6915
- usePublishTopic: vc,
6916
- usePresence: Sc,
6917
- useSyncPresence: Oc,
6918
- useTypingIndicator: Ec
6925
+ useTopicEffect: vc,
6926
+ usePublishTopic: Sc,
6927
+ usePresence: Oc,
6928
+ useSyncPresence: Ec,
6929
+ useTypingIndicator: Ac
6919
6930
  };
6920
- class Ac {
6931
+ class kc {
6921
6932
  constructor(e, n, r) {
6922
6933
  this.useTopicEffect = (i, s) => {
6923
6934
  Se.useTopicEffect(this, i, s);
6924
6935
  }, this.usePublishTopic = (i) => Se.usePublishTopic(this, i), this.usePresence = (i = {}) => Se.usePresence(this, i), this.useSyncPresence = (i, s) => Se.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => Se.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
6925
6936
  }
6926
6937
  }
6927
- var kc = function(t, e, n, r) {
6938
+ var jc = function(t, e, n, r) {
6928
6939
  function i(s) {
6929
6940
  return s instanceof n ? s : new n(function(o) {
6930
6941
  o(s);
@@ -6951,26 +6962,26 @@ var kc = function(t, e, n, r) {
6951
6962
  d((r = r.apply(t, e || [])).next());
6952
6963
  });
6953
6964
  };
6954
- const jc = {
6965
+ const Cc = {
6955
6966
  isLoading: !0,
6956
6967
  user: void 0,
6957
6968
  error: void 0
6958
6969
  };
6959
- class Cc {
6970
+ class Pc {
6960
6971
  constructor(e, n) {
6961
6972
  this.tx = zn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6962
6973
  const [i, s] = di(null);
6963
6974
  return ke(() => {
6964
- kc(this, void 0, void 0, function* () {
6975
+ jc(this, void 0, void 0, function* () {
6965
6976
  const a = yield this.getLocalId(r);
6966
6977
  s(a);
6967
6978
  });
6968
6979
  }, [r]), i;
6969
- }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => gc(this.core, r, i).state, this.useAuth = () => {
6980
+ }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => Tc(this.core, r, i).state, this.useAuth = () => {
6970
6981
  const r = at(this.core._reactor._currentUserCached), i = ge((o) => this.core.subscribeAuth((u) => {
6971
6982
  r.current = Object.assign({ isLoading: !1 }, u), o();
6972
6983
  }), []);
6973
- return tn(i, () => r.current, () => jc);
6984
+ return tn(i, () => r.current, () => Cc);
6974
6985
  }, this.useUser = () => {
6975
6986
  const { user: r } = this.useAuth();
6976
6987
  if (!r)
@@ -6992,7 +7003,7 @@ class Cc {
6992
7003
  }, this.SignedOut = ({ children: r }) => {
6993
7004
  const i = this.useAuth();
6994
7005
  return i.isLoading || i.error || i.user ? null : W.jsx(W.Fragment, { children: r });
6995
- }, this.core = lc(
7006
+ }, this.core = hc(
6996
7007
  e,
6997
7008
  // @ts-expect-error because TS can't resolve subclass statics
6998
7009
  this.constructor.Storage,
@@ -7016,7 +7027,7 @@ class Cc {
7016
7027
  * const { peers } = db.rooms.usePresence(room);
7017
7028
  */
7018
7029
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7019
- return new Ac(this.core, e, n);
7030
+ return new kc(this.core, e, n);
7020
7031
  }
7021
7032
  /**
7022
7033
  * One time query for the logged in state. This is useful
@@ -7039,7 +7050,7 @@ class ii extends Error {
7039
7050
  }
7040
7051
  function en(t) {
7041
7052
  }
7042
- function Pc(t) {
7053
+ function Ic(t) {
7043
7054
  if (typeof t == "function")
7044
7055
  throw new TypeError(
7045
7056
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
@@ -7047,7 +7058,7 @@ function Pc(t) {
7047
7058
  const { onEvent: e = en, onError: n = en, onRetry: r = en, onComment: i } = t;
7048
7059
  let s = "", o = !0, a, u = "", d = "";
7049
7060
  function c(b) {
7050
- const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [w, g] = Ic(`${s}${_}`);
7061
+ const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [w, g] = Mc(`${s}${_}`);
7051
7062
  for (const m of w)
7052
7063
  f(m);
7053
7064
  s = g, o = !1;
@@ -7115,7 +7126,7 @@ function Pc(t) {
7115
7126
  }
7116
7127
  return { feed: c, reset: y };
7117
7128
  }
7118
- function Ic(t) {
7129
+ function Mc(t) {
7119
7130
  const e = [];
7120
7131
  let n = "", r = 0;
7121
7132
  for (; r < t.length; ) {
@@ -7175,7 +7186,7 @@ class si extends Event {
7175
7186
  return e(oi(this), n);
7176
7187
  }
7177
7188
  }
7178
- function Mc(t) {
7189
+ function Rc(t) {
7179
7190
  const e = globalThis.DOMException;
7180
7191
  return typeof e == "function" ? new e(t, "SyntaxError") : new SyntaxError(t);
7181
7192
  }
@@ -7247,13 +7258,13 @@ class kt extends EventTarget {
7247
7258
  if (e instanceof URL)
7248
7259
  $(this, Oe, e);
7249
7260
  else if (typeof e == "string")
7250
- $(this, Oe, new URL(e, Rc()));
7261
+ $(this, Oe, new URL(e, xc()));
7251
7262
  else
7252
7263
  throw new Error("Invalid URL");
7253
7264
  } catch {
7254
- throw Mc("An invalid or illegal string was specified");
7265
+ throw Rc("An invalid or illegal string was specified");
7255
7266
  }
7256
- $(this, xe, Pc({
7267
+ $(this, xe, Ic({
7257
7268
  onEvent: A(this, kn),
7258
7269
  onRetry: A(this, jn)
7259
7270
  })), $(this, J, this.CONNECTING), $(this, st, 3e3), $(this, Rt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, At, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), he(this, se, On).call(this);
@@ -7396,15 +7407,15 @@ kt.OPEN = 1, /**
7396
7407
  * @public
7397
7408
  */
7398
7409
  kt.CLOSED = 2;
7399
- function Rc() {
7410
+ function xc() {
7400
7411
  const t = "document" in globalThis ? globalThis.document : void 0;
7401
7412
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
7402
7413
  }
7403
- const Qn = class Qn extends Cc {
7414
+ const Qn = class Qn extends Pc {
7404
7415
  };
7405
7416
  Qn.EventSourceImpl = kt;
7406
7417
  let In = Qn;
7407
- function xc(t) {
7418
+ function $c(t) {
7408
7419
  const e = {
7409
7420
  ...t,
7410
7421
  useDateObjects: t.useDateObjects ?? !1
@@ -7413,8 +7424,8 @@ function xc(t) {
7413
7424
  "@instantdb/react": Bn
7414
7425
  });
7415
7426
  }
7416
- const qc = xc;
7417
- function Wc({
7427
+ const Wc = $c;
7428
+ function zc({
7418
7429
  as: t = "div",
7419
7430
  spaceId: e,
7420
7431
  room: n,
@@ -7486,8 +7497,8 @@ function Wc({
7486
7497
  {
7487
7498
  style: {
7488
7499
  ...ui,
7489
- ...Dc,
7490
- zIndex: d !== void 0 ? d : Uc
7500
+ ...Uc,
7501
+ zIndex: d !== void 0 ? d : Lc
7491
7502
  },
7492
7503
  children: Object.entries(f.peers).map(([g, m]) => {
7493
7504
  const E = m[c];
@@ -7503,7 +7514,7 @@ function Wc({
7503
7514
  children: a ? a({
7504
7515
  color: E.color,
7505
7516
  presence: l == null ? void 0 : l.peers[g]
7506
- }) : /* @__PURE__ */ W.jsx($c, { ...E })
7517
+ }) : /* @__PURE__ */ W.jsx(Dc, { ...E })
7507
7518
  },
7508
7519
  g
7509
7520
  ) : null;
@@ -7514,7 +7525,7 @@ function Wc({
7514
7525
  ]
7515
7526
  );
7516
7527
  }
7517
- function $c({ color: t }) {
7528
+ function Dc({ color: t }) {
7518
7529
  const n = t || "black";
7519
7530
  return /* @__PURE__ */ W.jsxs(
7520
7531
  "svg",
@@ -7567,21 +7578,21 @@ const ui = {
7567
7578
  left: 0,
7568
7579
  bottom: 0,
7569
7580
  right: 0
7570
- }, Dc = {
7581
+ }, Uc = {
7571
7582
  overflow: "hidden",
7572
7583
  pointerEvents: "none",
7573
7584
  userSelect: "none"
7574
- }, Uc = 99999;
7585
+ }, Lc = 99999;
7575
7586
  export {
7576
- Wc as Cursors,
7587
+ zc as Cursors,
7577
7588
  Dt as InstantAPIError,
7578
- Cc as InstantReactAbstractDatabase,
7589
+ Pc as InstantReactAbstractDatabase,
7579
7590
  In as InstantReactWebDatabase,
7580
7591
  ve as SyncTableCallbackEventType,
7581
- Kc as i,
7592
+ qc as i,
7582
7593
  K as id,
7583
- xc as init,
7584
- qc as init_experimental,
7585
- Fc as lookup,
7586
- Nc as tx
7594
+ $c as init,
7595
+ Wc as init_experimental,
7596
+ Nc as lookup,
7597
+ Kc as tx
7587
7598
  };