@instantdb/react 0.22.47-experimental.sync-table.19184737115.1 → 0.22.47-experimental.sync-table.19185753694.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.
@@ -1,4 +1,4 @@
1
- import si, { useRef as vt, useCallback as be, useSyncExternalStore as Xt, useEffect as Oe, useMemo as en, useState as oi, createElement as vs } from "react";
1
+ import si, { useRef as Ot, useCallback as be, useSyncExternalStore as Xt, useEffect as Ee, useMemo as en, useState as oi, createElement as vs } from "react";
2
2
  function z(t) {
3
3
  if (typeof t == "number")
4
4
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -41,7 +41,7 @@ const D = {
41
41
  Remove: "remove",
42
42
  Replace: "replace",
43
43
  Add: "add"
44
- }, ui = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Os = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), _t = Symbol.iterator, ne = {
44
+ }, ai = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Os = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), gt = Symbol.iterator, ne = {
45
45
  mutable: "mutable",
46
46
  immutable: "immutable"
47
47
  }, Pn = {};
@@ -69,24 +69,24 @@ function te(t) {
69
69
  var e;
70
70
  return (e = t.copy) !== null && e !== void 0 ? e : t.original;
71
71
  }
72
- function Ee(t) {
72
+ function Ae(t) {
73
73
  return !!C(t);
74
74
  }
75
75
  function C(t) {
76
- return typeof t != "object" ? null : t == null ? void 0 : t[ui];
76
+ return typeof t != "object" ? null : t == null ? void 0 : t[ai];
77
77
  }
78
78
  function $n(t) {
79
79
  var e;
80
80
  const n = C(t);
81
81
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
82
82
  }
83
- function ue(t, e) {
83
+ function ae(t, e) {
84
84
  if (!t || typeof t != "object")
85
85
  return !1;
86
86
  let n;
87
87
  return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, ne)) === ne.immutable || typeof n == "function");
88
88
  }
89
- function ai(t, e = []) {
89
+ function ui(t, e = []) {
90
90
  if (Object.hasOwnProperty.call(t, "key")) {
91
91
  const n = t.parent.copy, r = C(pe(n, t.key));
92
92
  if (r !== null && (r == null ? void 0 : r.original) !== t.original)
@@ -97,7 +97,7 @@ function ai(t, e = []) {
97
97
  e.push(s);
98
98
  }
99
99
  if (t.parent)
100
- return ai(t.parent, e);
100
+ return ui(t.parent, e);
101
101
  e.reverse();
102
102
  try {
103
103
  Es(t.copy, e);
@@ -106,16 +106,16 @@ function ai(t, e = []) {
106
106
  }
107
107
  return e;
108
108
  }
109
- function Ae(t) {
109
+ function Ce(t) {
110
110
  return Array.isArray(t) ? 1 : t instanceof Map ? 2 : t instanceof Set ? 3 : 0;
111
111
  }
112
112
  function pe(t, e) {
113
- return Ae(t) === 2 ? t.get(e) : t[e];
113
+ return Ce(t) === 2 ? t.get(e) : t[e];
114
114
  }
115
115
  function st(t, e, n) {
116
- Ae(t) === 2 ? t.set(e, n) : t[e] = n;
116
+ Ce(t) === 2 ? t.set(e, n) : t[e] = n;
117
117
  }
118
- function zt(t, e) {
118
+ function Kt(t, e) {
119
119
  const n = C(t);
120
120
  return (n ? te(n) : t)[e];
121
121
  }
@@ -127,7 +127,7 @@ function tn(t) {
127
127
  for (; t.finalities.revoke.length > 0; )
128
128
  t.finalities.revoke.pop()();
129
129
  }
130
- function Se(t, e) {
130
+ function ve(t, e) {
131
131
  return e ? t : [""].concat(t).map((n) => {
132
132
  const r = `${n}`;
133
133
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
@@ -136,7 +136,7 @@ function Se(t, e) {
136
136
  function Es(t, e) {
137
137
  for (let n = 0; n < e.length - 1; n += 1) {
138
138
  const r = e[n];
139
- if (t = pe(Ae(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
139
+ if (t = pe(Ce(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
140
140
  throw new Error(`Cannot resolve patch at '${e.join("/")}'.`);
141
141
  }
142
142
  return t;
@@ -197,7 +197,7 @@ function Q(t) {
197
197
  t.copy || (t.copy = ci(t.original, t.options));
198
198
  }
199
199
  function He(t) {
200
- if (!ue(t))
200
+ if (!ae(t))
201
201
  return $n(t);
202
202
  if (Array.isArray(t))
203
203
  return t.map(He);
@@ -225,8 +225,8 @@ function He(t) {
225
225
  e[n] = He(t[n]);
226
226
  return e;
227
227
  }
228
- function gt(t) {
229
- return Ee(t) ? He(t) : t;
228
+ function Tt(t) {
229
+ return Ae(t) ? He(t) : t;
230
230
  }
231
231
  function de(t) {
232
232
  var e;
@@ -235,54 +235,54 @@ function de(t) {
235
235
  function gr() {
236
236
  throw new Error("Cannot modify frozen object");
237
237
  }
238
- function je(t, e, n, r, i) {
238
+ function Ie(t, e, n, r, i) {
239
239
  {
240
240
  n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], i = i ?? [];
241
241
  const o = n.has(t) ? n.get(t) : t;
242
242
  if (r.length > 0) {
243
- const u = r.indexOf(o);
244
- if (o && typeof o == "object" && u !== -1)
245
- throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, u).map((a, d) => {
246
- if (typeof a == "symbol")
247
- return `[${a.toString()}]`;
243
+ const a = r.indexOf(o);
244
+ if (o && typeof o == "object" && a !== -1)
245
+ throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, a).map((u, d) => {
246
+ if (typeof u == "symbol")
247
+ return `[${u.toString()}]`;
248
248
  const c = r[d];
249
- return typeof a == "object" && (c instanceof Map || c instanceof Set) ? Array.from(c.keys()).indexOf(a) : a;
249
+ return typeof u == "object" && (c instanceof Map || c instanceof Set) ? Array.from(c.keys()).indexOf(u) : u;
250
250
  }).join("/")}`);
251
251
  r.push(o), i.push(e);
252
252
  } else
253
253
  r.push(o);
254
254
  }
255
- if (Object.isFrozen(t) || Ee(t)) {
255
+ if (Object.isFrozen(t) || Ae(t)) {
256
256
  r.pop(), i.pop();
257
257
  return;
258
258
  }
259
- switch (Ae(t)) {
259
+ switch (Ce(t)) {
260
260
  case 2:
261
- for (const [u, a] of t)
262
- je(u, u, n, r, i), je(a, u, n, r, i);
261
+ for (const [a, u] of t)
262
+ Ie(a, a, n, r, i), Ie(u, a, n, r, i);
263
263
  t.set = t.clear = t.delete = gr;
264
264
  break;
265
265
  case 3:
266
- for (const u of t)
267
- je(u, u, n, r, i);
266
+ for (const a of t)
267
+ Ie(a, a, n, r, i);
268
268
  t.add = t.clear = t.delete = gr;
269
269
  break;
270
270
  case 1:
271
271
  Object.freeze(t);
272
272
  let o = 0;
273
- for (const u of t)
274
- je(u, o, n, r, i), o += 1;
273
+ for (const a of t)
274
+ Ie(a, o, n, r, i), o += 1;
275
275
  break;
276
276
  default:
277
- Object.freeze(t), Object.keys(t).forEach((u) => {
278
- const a = t[u];
279
- je(a, u, n, r, i);
277
+ Object.freeze(t), Object.keys(t).forEach((a) => {
278
+ const u = t[a];
279
+ Ie(u, a, n, r, i);
280
280
  });
281
281
  }
282
282
  r.pop(), i.pop();
283
283
  }
284
284
  function xn(t, e) {
285
- const n = Ae(t);
285
+ const n = Ce(t);
286
286
  if (n === 0)
287
287
  Reflect.ownKeys(t).forEach((r) => {
288
288
  e(r, t[r], t);
@@ -295,22 +295,22 @@ function xn(t, e) {
295
295
  t.forEach((r, i) => e(i, r, t));
296
296
  }
297
297
  function di(t, e, n) {
298
- if (Ee(t) || !ue(t, n) || e.has(t) || Object.isFrozen(t))
298
+ if (Ae(t) || !ae(t, n) || e.has(t) || Object.isFrozen(t))
299
299
  return;
300
300
  const r = t instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
301
301
  if (e.add(t), xn(t, (s, o) => {
302
- var u;
303
- if (Ee(o)) {
304
- const a = C(o);
305
- Q(a);
306
- const d = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
302
+ var a;
303
+ if (Ae(o)) {
304
+ const u = C(o);
305
+ Q(u);
306
+ const d = !((a = u.assignedMap) === null || a === void 0) && a.size || u.operated ? u.copy : u.original;
307
307
  st(r ? i : t, s, d);
308
308
  } else
309
309
  di(o, e, n);
310
310
  }), i) {
311
311
  const s = t, o = Array.from(s);
312
- s.clear(), o.forEach((u) => {
313
- s.add(i.has(u) ? i.get(u) : u);
312
+ s.clear(), o.forEach((a) => {
313
+ s.add(i.has(a) ? i.get(a) : a);
314
314
  });
315
315
  }
316
316
  }
@@ -326,7 +326,7 @@ function nn(t) {
326
326
  function rn(t, e, n, r) {
327
327
  if (t.operated && t.assignedMap && t.assignedMap.size > 0 && !t.finalized) {
328
328
  if (n && r) {
329
- const s = ai(t);
329
+ const s = ui(t);
330
330
  s && e(t, s, n, r);
331
331
  }
332
332
  t.finalized = !0;
@@ -335,56 +335,56 @@ function rn(t, e, n, r) {
335
335
  function Dn(t, e, n, r) {
336
336
  const i = C(n);
337
337
  i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
338
- var u;
339
- const a = t.type === 3 ? t.setMap : t.copy;
340
- if (he(pe(a, e), n)) {
338
+ var a;
339
+ const u = t.type === 3 ? t.setMap : t.copy;
340
+ if (he(pe(u, e), n)) {
341
341
  let d = i.original;
342
- i.copy && (d = i.copy), nn(t), rn(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), st(a, e, d);
342
+ i.copy && (d = i.copy), nn(t), rn(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), st(u, e, d);
343
343
  }
344
- }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ue(n, t.options) && t.finalities.draft.push(() => {
344
+ }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ae(n, t.options) && t.finalities.draft.push(() => {
345
345
  const s = t.type === 3 ? t.setMap : t.copy;
346
346
  he(pe(s, e), n) && ks(t, e);
347
347
  });
348
348
  }
349
349
  function js(t, e, n, r, i) {
350
- let { original: s, assignedMap: o, options: u } = t, a = t.copy;
351
- a.length < s.length && ([s, a] = [a, s], [n, r] = [r, n]);
350
+ let { original: s, assignedMap: o, options: a } = t, u = t.copy;
351
+ u.length < s.length && ([s, u] = [u, s], [n, r] = [r, n]);
352
352
  for (let d = 0; d < s.length; d += 1)
353
- if (o.get(d.toString()) && a[d] !== s[d]) {
354
- const c = e.concat([d]), f = Se(c, i);
353
+ if (o.get(d.toString()) && u[d] !== s[d]) {
354
+ const c = e.concat([d]), f = ve(c, i);
355
355
  n.push({
356
356
  op: D.Replace,
357
357
  path: f,
358
358
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
359
- value: gt(a[d])
359
+ value: Tt(u[d])
360
360
  }), r.push({
361
361
  op: D.Replace,
362
362
  path: f,
363
363
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
364
- value: gt(s[d])
364
+ value: Tt(s[d])
365
365
  });
366
366
  }
367
- for (let d = s.length; d < a.length; d += 1) {
368
- const c = e.concat([d]), f = Se(c, i);
367
+ for (let d = s.length; d < u.length; d += 1) {
368
+ const c = e.concat([d]), f = ve(c, i);
369
369
  n.push({
370
370
  op: D.Add,
371
371
  path: f,
372
372
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
373
- value: gt(a[d])
373
+ value: Tt(u[d])
374
374
  });
375
375
  }
376
- if (s.length < a.length) {
377
- const { arrayLengthAssignment: d = !0 } = u.enablePatches;
376
+ if (s.length < u.length) {
377
+ const { arrayLengthAssignment: d = !0 } = a.enablePatches;
378
378
  if (d) {
379
- const c = e.concat(["length"]), f = Se(c, i);
379
+ const c = e.concat(["length"]), f = ve(c, i);
380
380
  r.push({
381
381
  op: D.Replace,
382
382
  path: f,
383
383
  value: s.length
384
384
  });
385
385
  } else
386
- for (let c = a.length; s.length < c; c -= 1) {
387
- const f = e.concat([c - 1]), h = Se(f, i);
386
+ for (let c = u.length; s.length < c; c -= 1) {
387
+ const f = e.concat([c - 1]), h = ve(f, i);
388
388
  r.push({
389
389
  op: D.Remove,
390
390
  path: h
@@ -393,41 +393,41 @@ function js(t, e, n, r, i) {
393
393
  }
394
394
  }
395
395
  function Is({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
396
- n.forEach((u, a) => {
397
- const d = pe(t, a), c = gt(pe(e, a)), f = u ? et(t, a) ? D.Replace : D.Add : D.Remove;
396
+ n.forEach((a, u) => {
397
+ const d = pe(t, u), c = Tt(pe(e, u)), f = a ? et(t, u) ? D.Replace : D.Add : D.Remove;
398
398
  if (he(d, c) && f === D.Replace)
399
399
  return;
400
- const h = r.concat(a), p = Se(h, o);
400
+ const h = r.concat(u), p = ve(h, o);
401
401
  i.push(f === D.Remove ? { op: f, path: p } : { op: f, path: p, value: c }), s.push(f === D.Add ? { op: D.Remove, path: p } : f === D.Remove ? { op: D.Add, path: p, value: d } : { op: D.Replace, path: p, value: d });
402
402
  });
403
403
  }
404
404
  function Ps({ original: t, copy: e }, n, r, i, s) {
405
405
  let o = 0;
406
- t.forEach((u) => {
407
- if (!e.has(u)) {
408
- const a = n.concat([o]), d = Se(a, s);
406
+ t.forEach((a) => {
407
+ if (!e.has(a)) {
408
+ const u = n.concat([o]), d = ve(u, s);
409
409
  r.push({
410
410
  op: D.Remove,
411
411
  path: d,
412
- value: u
412
+ value: a
413
413
  }), i.unshift({
414
414
  op: D.Add,
415
415
  path: d,
416
- value: u
416
+ value: a
417
417
  });
418
418
  }
419
419
  o += 1;
420
- }), o = 0, e.forEach((u) => {
421
- if (!t.has(u)) {
422
- const a = n.concat([o]), d = Se(a, s);
420
+ }), o = 0, e.forEach((a) => {
421
+ if (!t.has(a)) {
422
+ const u = n.concat([o]), d = ve(u, s);
423
423
  r.push({
424
424
  op: D.Add,
425
425
  path: d,
426
- value: u
426
+ value: a
427
427
  }), i.unshift({
428
428
  op: D.Remove,
429
429
  path: d,
430
- value: u
430
+ value: a
431
431
  });
432
432
  }
433
433
  o += 1;
@@ -445,8 +445,8 @@ function it(t, e, n, r) {
445
445
  return Ps(t, e, n, r, i);
446
446
  }
447
447
  }
448
- const Ot = (t, e, n = !1) => {
449
- if (typeof t == "object" && t !== null && (!ue(t, e) || n))
448
+ const Et = (t, e, n = !1) => {
449
+ if (typeof t == "object" && t !== null && (!ae(t, e) || n))
450
450
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
451
451
  }, sn = {
452
452
  get size() {
@@ -483,7 +483,7 @@ const Ot = (t, e, n = !1) => {
483
483
  get(t) {
484
484
  var e, n;
485
485
  const r = C(this), i = te(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, ne)) === ne.mutable;
486
- if (r.options.strict && Ot(i, r.options, s), s || r.finalized || !ue(i, r.options) || i !== r.original.get(t))
486
+ if (r.options.strict && Et(i, r.options, s), s || r.finalized || !ae(i, r.options) || i !== r.original.get(t))
487
487
  return i;
488
488
  const o = Pn.createDraft({
489
489
  original: i,
@@ -500,7 +500,7 @@ const Ot = (t, e, n = !1) => {
500
500
  values() {
501
501
  const t = this.keys();
502
502
  return {
503
- [_t]: () => this.values(),
503
+ [gt]: () => this.values(),
504
504
  next: () => {
505
505
  const e = t.next();
506
506
  return e.done ? e : {
@@ -513,7 +513,7 @@ const Ot = (t, e, n = !1) => {
513
513
  entries() {
514
514
  const t = this.keys();
515
515
  return {
516
- [_t]: () => this.entries(),
516
+ [gt]: () => this.entries(),
517
517
  next: () => {
518
518
  const e = t.next();
519
519
  if (e.done)
@@ -526,7 +526,7 @@ const Ot = (t, e, n = !1) => {
526
526
  }
527
527
  };
528
528
  },
529
- [_t]() {
529
+ [gt]() {
530
530
  return this.entries();
531
531
  }
532
532
  }, Ms = Reflect.ownKeys(sn), Tr = (t, e, { isValuesIterator: n }) => () => {
@@ -535,9 +535,9 @@ const Ot = (t, e, n = !1) => {
535
535
  if (s.done)
536
536
  return s;
537
537
  const o = s.value;
538
- let u = t.setMap.get(o);
539
- const a = C(u), d = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, u, ne)) === ne.mutable;
540
- if (t.options.strict && Ot(o, t.options, d), !d && !a && ue(o, t.options) && !t.finalized && t.original.has(o)) {
538
+ let a = t.setMap.get(o);
539
+ const u = C(a), d = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, a, ne)) === ne.mutable;
540
+ if (t.options.strict && Et(o, t.options, d), !d && !u && ae(o, t.options) && !t.finalized && t.original.has(o)) {
541
541
  const c = Pn.createDraft({
542
542
  original: o,
543
543
  parentDraft: t,
@@ -545,13 +545,13 @@ const Ot = (t, e, n = !1) => {
545
545
  finalities: t.finalities,
546
546
  options: t.options
547
547
  });
548
- t.setMap.set(o, c), u = c;
549
- } else a && (u = a.proxy);
548
+ t.setMap.set(o, c), a = c;
549
+ } else u && (a = u.proxy);
550
550
  return {
551
551
  done: !1,
552
- value: n ? u : [u, u]
552
+ value: n ? a : [a, a]
553
553
  };
554
- }, Et = {
554
+ }, At = {
555
555
  get size() {
556
556
  return C(this).setMap.size;
557
557
  },
@@ -607,7 +607,7 @@ const Ot = (t, e, n = !1) => {
607
607
  keys() {
608
608
  return this.values();
609
609
  },
610
- [_t]() {
610
+ [gt]() {
611
611
  return this.values();
612
612
  },
613
613
  forEach(t, e) {
@@ -617,7 +617,7 @@ const Ot = (t, e, n = !1) => {
617
617
  t.call(e, r.value, r.value, this), r = n.next();
618
618
  }
619
619
  };
620
- Set.prototype.difference && Object.assign(Et, {
620
+ Set.prototype.difference && Object.assign(At, {
621
621
  intersection(t) {
622
622
  return Set.prototype.intersection.call(new Set(this.values()), t);
623
623
  },
@@ -640,46 +640,46 @@ Set.prototype.difference && Object.assign(Et, {
640
640
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
641
641
  }
642
642
  });
643
- const Rs = Reflect.ownKeys(Et), fi = /* @__PURE__ */ new WeakSet(), li = {
643
+ const Rs = Reflect.ownKeys(At), fi = /* @__PURE__ */ new WeakSet(), li = {
644
644
  get(t, e, n) {
645
645
  var r, i;
646
646
  const s = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
647
647
  if (s && fi.has(s))
648
648
  return s;
649
- if (e === ui)
649
+ if (e === ai)
650
650
  return t;
651
651
  let o;
652
652
  if (t.options.mark) {
653
653
  const d = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
654
654
  if (o = t.options.mark(d, ne), o === ne.mutable)
655
- return t.options.strict && Ot(d, t.options, !0), d;
655
+ return t.options.strict && Et(d, t.options, !0), d;
656
656
  }
657
- const u = te(t);
658
- if (u instanceof Map && Ms.includes(e)) {
657
+ const a = te(t);
658
+ if (a instanceof Map && Ms.includes(e)) {
659
659
  if (e === "size")
660
660
  return Object.getOwnPropertyDescriptor(sn, "size").get.call(t.proxy);
661
661
  const d = sn[e];
662
662
  if (d)
663
663
  return d.bind(t.proxy);
664
664
  }
665
- if (u instanceof Set && Rs.includes(e)) {
665
+ if (a instanceof Set && Rs.includes(e)) {
666
666
  if (e === "size")
667
- return Object.getOwnPropertyDescriptor(Et, "size").get.call(t.proxy);
668
- const d = Et[e];
667
+ return Object.getOwnPropertyDescriptor(At, "size").get.call(t.proxy);
668
+ const d = At[e];
669
669
  if (d)
670
670
  return d.bind(t.proxy);
671
671
  }
672
- if (!et(u, e)) {
673
- const d = _r(u, e);
672
+ if (!et(a, e)) {
673
+ const d = _r(a, e);
674
674
  return d ? "value" in d ? d.value : (
675
675
  // !case: support for getter
676
676
  (i = d.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
677
677
  ) : void 0;
678
678
  }
679
- const a = u[e];
680
- if (t.options.strict && Ot(a, t.options), t.finalized || !ue(a, t.options))
681
- return a;
682
- if (a === zt(t.original, e)) {
679
+ const u = a[e];
680
+ if (t.options.strict && Et(u, t.options), t.finalized || !ae(u, t.options))
681
+ return u;
682
+ if (u === Kt(t.original, e)) {
683
683
  if (Q(t), t.copy[e] = Un({
684
684
  original: t.original[e],
685
685
  parentDraft: t,
@@ -692,7 +692,7 @@ const Rs = Reflect.ownKeys(Et), fi = /* @__PURE__ */ new WeakSet(), li = {
692
692
  }
693
693
  return t.copy[e];
694
694
  }
695
- return a;
695
+ return u;
696
696
  },
697
697
  set(t, e, n) {
698
698
  var r;
@@ -704,8 +704,8 @@ const Rs = Reflect.ownKeys(Et), fi = /* @__PURE__ */ new WeakSet(), li = {
704
704
  const s = _r(te(t), e);
705
705
  if (s != null && s.set)
706
706
  return s.set.call(t.proxy, n), !0;
707
- const o = zt(te(t), e), u = C(o);
708
- return u && he(u.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (he(n, o) && (n !== void 0 || et(t.original, e)) || (Q(t), de(t), et(t.original, e) && he(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Dn(t, e, n, it)), !0);
707
+ const o = Kt(te(t), e), a = C(o);
708
+ return a && he(a.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (he(n, o) && (n !== void 0 || et(t.original, e)) || (Q(t), de(t), et(t.original, e) && he(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Dn(t, e, n, it)), !0);
709
709
  },
710
710
  has(t, e) {
711
711
  return e in te(t);
@@ -733,11 +733,11 @@ const Rs = Reflect.ownKeys(Et), fi = /* @__PURE__ */ new WeakSet(), li = {
733
733
  },
734
734
  deleteProperty(t, e) {
735
735
  var n;
736
- return t.type === 1 ? li.set.call(this, t, e, void 0, t.proxy) : (zt(t.original, e) !== void 0 || e in t.original ? (Q(t), de(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
736
+ return t.type === 1 ? li.set.call(this, t, e, void 0, t.proxy) : (Kt(t.original, e) !== void 0 || e in t.original ? (Q(t), de(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
737
737
  }
738
738
  };
739
739
  function Un(t) {
740
- const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ae(e), u = {
740
+ const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ce(e), a = {
741
741
  type: o,
742
742
  finalized: !1,
743
743
  parent: n,
@@ -749,13 +749,13 @@ function Un(t) {
749
749
  // Mapping of draft Set items to their corresponding draft values.
750
750
  setMap: o === 3 ? new Map(e.entries()) : void 0
751
751
  };
752
- (r || "key" in t) && (u.key = r);
753
- const { proxy: a, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, li);
754
- if (i.revoke.push(d), fi.add(a), u.proxy = a, n) {
752
+ (r || "key" in t) && (a.key = r);
753
+ const { proxy: u, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, li);
754
+ if (i.revoke.push(d), fi.add(u), a.proxy = u, n) {
755
755
  const c = n;
756
756
  c.finalities.draft.push((f, h) => {
757
757
  var p, y;
758
- const b = C(a);
758
+ const b = C(u);
759
759
  let _ = c.type === 3 ? c.setMap : c.copy;
760
760
  const T = pe(_, r), w = C(T);
761
761
  if (w) {
@@ -767,25 +767,25 @@ function Un(t) {
767
767
  });
768
768
  });
769
769
  } else {
770
- const c = C(a);
770
+ const c = C(u);
771
771
  c.finalities.draft.push((f, h) => {
772
772
  nn(c), rn(c, it, f, h);
773
773
  });
774
774
  }
775
- return a;
775
+ return u;
776
776
  }
777
777
  Pn.createDraft = Un;
778
778
  function $s(t, e, n, r, i) {
779
779
  var s;
780
- const o = C(t), u = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, a = !!e.length;
780
+ const o = C(t), a = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, u = !!e.length;
781
781
  if (o != null && o.operated)
782
782
  for (; o.finalities.draft.length > 0; )
783
783
  o.finalities.draft.pop()(n, r);
784
- const d = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
785
- return o && tn(o), i && je(d, d, o == null ? void 0 : o.options.updatedValues), [
784
+ const d = u ? e[0] : o ? o.operated ? o.copy : o.original : t;
785
+ return o && tn(o), i && Ie(d, d, o == null ? void 0 : o.options.updatedValues), [
786
786
  d,
787
- n && a ? [{ op: D.Replace, path: [], value: e[0] }] : n,
788
- r && a ? [{ op: D.Replace, path: [], value: u }] : r
787
+ n && u ? [{ op: D.Replace, path: [], value: e[0] }] : n,
788
+ r && u ? [{ op: D.Replace, path: [], value: a }] : r
789
789
  ];
790
790
  }
791
791
  function xs(t, e) {
@@ -797,41 +797,41 @@ function xs(t, e) {
797
797
  };
798
798
  let i, s;
799
799
  e.enablePatches && (i = [], s = []);
800
- const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ue(t, e) ? t : Un({
800
+ const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ae(t, e) ? t : Un({
801
801
  original: t,
802
802
  parentDraft: null,
803
803
  finalities: r,
804
804
  options: e
805
805
  });
806
806
  return [
807
- u,
808
- (a = []) => {
809
- const [d, c, f] = $s(u, a, i, s, e.enableAutoFreeze);
807
+ a,
808
+ (u = []) => {
809
+ const [d, c, f] = $s(a, u, i, s, e.enableAutoFreeze);
810
810
  return e.enablePatches ? [d, c, f] : d;
811
811
  }
812
812
  ];
813
813
  }
814
814
  function on(t) {
815
815
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: i = !0 } = t;
816
- xn(n, (s, o, u) => {
817
- const a = C(o);
818
- if (a && e && a.finalities === e.finalities) {
816
+ xn(n, (s, o, a) => {
817
+ const u = C(o);
818
+ if (u && e && u.finalities === e.finalities) {
819
819
  t.isContainDraft = !0;
820
- const d = a.original;
821
- if (u instanceof Set) {
822
- const c = Array.from(u);
823
- u.clear(), c.forEach((f) => u.add(s === f ? d : f));
820
+ const d = u.original;
821
+ if (a instanceof Set) {
822
+ const c = Array.from(a);
823
+ a.clear(), c.forEach((f) => a.add(s === f ? d : f));
824
824
  } else
825
- st(u, s, d);
825
+ st(a, s, d);
826
826
  } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, on(t));
827
827
  }), i && (t.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
828
828
  }
829
829
  function hi(t) {
830
830
  var e;
831
831
  const n = C(t);
832
- if (!ue(t, n == null ? void 0 : n.options))
832
+ if (!ae(t, n == null ? void 0 : n.options))
833
833
  return t;
834
- const r = Ae(t);
834
+ const r = Ce(t);
835
835
  if (n && !n.operated)
836
836
  return n.original;
837
837
  let i;
@@ -847,11 +847,11 @@ function hi(t) {
847
847
  }
848
848
  } else
849
849
  i = t;
850
- if (xn(i, (o, u) => {
851
- if (n && he(pe(n.original, o), u))
850
+ if (xn(i, (o, a) => {
851
+ if (n && he(pe(n.original, o), a))
852
852
  return;
853
- const a = hi(u);
854
- a !== u && (i === t && s(), st(i, o, a));
853
+ const u = hi(a);
854
+ u !== a && (i === t && s(), st(i, o, u));
855
855
  }), r === 3) {
856
856
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : i;
857
857
  return Mn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
@@ -859,22 +859,22 @@ function hi(t) {
859
859
  return i;
860
860
  }
861
861
  function wr(t) {
862
- if (!Ee(t))
862
+ if (!Ae(t))
863
863
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
864
864
  return hi(t);
865
865
  }
866
866
  const Ds = (t) => function e(n, r, i) {
867
- var s, o, u;
867
+ var s, o, a;
868
868
  if (typeof n == "function" && typeof r != "function")
869
869
  return function(v, ...M) {
870
870
  return e(v, (U) => n.call(this, U, ...M), r);
871
871
  };
872
- const a = n, d = r;
872
+ const u = n, d = r;
873
873
  let c = i;
874
874
  if (typeof r != "function" && (c = r), c !== void 0 && Object.prototype.toString.call(c) !== "[object Object]")
875
875
  throw new Error(`Invalid options: ${c}, 'options' should be an object.`);
876
876
  c = Object.assign(Object.assign({}, t), c);
877
- const f = Ee(a) ? wr(a) : a, h = Array.isArray(c.mark) ? (v, M) => {
877
+ const f = Ae(u) ? wr(u) : u, h = Array.isArray(c.mark) ? (v, M) => {
878
878
  for (const U of c.mark) {
879
879
  if (typeof U != "function")
880
880
  throw new Error(`Invalid mark: ${U}, 'mark' should be a function.`);
@@ -883,16 +883,16 @@ const Ds = (t) => function e(n, r, i) {
883
883
  return B;
884
884
  }
885
885
  } : c.mark, p = (s = c.enablePatches) !== null && s !== void 0 ? s : !1, y = (o = c.strict) !== null && o !== void 0 ? o : !1, _ = {
886
- enableAutoFreeze: (u = c.enableAutoFreeze) !== null && u !== void 0 ? u : !1,
886
+ enableAutoFreeze: (a = c.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
887
887
  mark: h,
888
888
  strict: y,
889
889
  enablePatches: p
890
890
  };
891
- if (!ue(f, _) && typeof f == "object" && f !== null)
891
+ if (!ae(f, _) && typeof f == "object" && f !== null)
892
892
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
893
893
  const [T, w] = xs(f, _);
894
894
  if (typeof r != "function") {
895
- if (!ue(f, _))
895
+ if (!ae(f, _))
896
896
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
897
897
  return [T, w];
898
898
  }
@@ -904,7 +904,7 @@ const Ds = (t) => function e(n, r, i) {
904
904
  }
905
905
  const j = (v) => {
906
906
  const M = C(T);
907
- if (!Ee(v)) {
907
+ if (!Ae(v)) {
908
908
  if (v !== void 0 && !he(v, T) && (M != null && M.operated))
909
909
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
910
910
  const B = v == null ? void 0 : v[Os];
@@ -932,7 +932,7 @@ const Ds = (t) => function e(n, r, i) {
932
932
  return m instanceof Promise ? m.then(j, (v) => {
933
933
  throw tn(C(T)), v;
934
934
  }) : j(m);
935
- }, un = Ds();
935
+ }, an = Ds();
936
936
  Object.prototype.constructor.toString();
937
937
  function pi(t, e) {
938
938
  const n = Object.keys(t), r = Object.keys(e);
@@ -941,8 +941,8 @@ function pi(t, e) {
941
941
  function mr(t, e) {
942
942
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every((n) => e.hasOwnProperty(n) && t[n] === e[n]);
943
943
  }
944
- function Tt(t, e) {
945
- return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : pi(t, e) ? Object.keys(t).every((n) => Tt(t[n], e[n])) : !1;
944
+ function wt(t, e) {
945
+ return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : pi(t, e) ? Object.keys(t).every((n) => wt(t[n], e[n])) : !1;
946
946
  }
947
947
  function Ln(t) {
948
948
  if (!Ye(t))
@@ -1247,8 +1247,8 @@ function Hs(t) {
1247
1247
  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
1248
  if (!o)
1249
1249
  throw new Error(`Unable to parse time from: ${t}`);
1250
- let [, u, a, d, c] = o;
1251
- return u = Number(u), a = Number(a), d = Number(d), c === "PM" && u !== 12 ? u += 12 : c === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, d));
1250
+ let [, a, u, d, c] = o;
1251
+ 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
1252
  }
1253
1253
  function Ys(t) {
1254
1254
  switch (t) {
@@ -1290,7 +1290,7 @@ function Xs(t, e) {
1290
1290
  return null;
1291
1291
  }
1292
1292
  }
1293
- function an(t) {
1293
+ function un(t) {
1294
1294
  for (const e of Zs) {
1295
1295
  const n = Xs(e, t);
1296
1296
  if (n)
@@ -1301,19 +1301,19 @@ function an(t) {
1301
1301
  function eo(t) {
1302
1302
  try {
1303
1303
  const e = JSON.parse(t);
1304
- return typeof e == "string" ? an(e) : null;
1304
+ return typeof e == "string" ? un(e) : null;
1305
1305
  } catch {
1306
1306
  return null;
1307
1307
  }
1308
1308
  }
1309
- function jt(t) {
1309
+ function It(t) {
1310
1310
  if (t !== void 0) {
1311
1311
  if (t === null)
1312
1312
  return null;
1313
1313
  if (t instanceof Date)
1314
1314
  return t;
1315
1315
  if (typeof t == "string") {
1316
- const e = an(t) || eo(t) || an(t.trim());
1316
+ const e = un(t) || eo(t) || un(t.trim());
1317
1317
  if (!e)
1318
1318
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1319
1319
  return e;
@@ -1361,21 +1361,21 @@ function Z(t, e, n) {
1361
1361
  function _i(t, e, n) {
1362
1362
  const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1363
1363
  for (const o of e) {
1364
- let [u, a, d, c] = o;
1365
- const f = Ne(t, a);
1364
+ let [a, u, d, c] = o;
1365
+ const f = Ne(t, u);
1366
1366
  if (!f) {
1367
- console.warn("no such attr", u, t);
1367
+ console.warn("no such attr", a, t);
1368
1368
  continue;
1369
1369
  }
1370
- f["checked-data-type"] === "date" && n && (d = jt(d), o[2] = d), Fn(f) && Z(s, [d, a, u], o), Z(r, [u, a, d], o), Z(i, [a, u, d], o);
1370
+ f["checked-data-type"] === "date" && n && (d = It(d), o[2] = d), Fn(f) && Z(s, [d, u, a], o), Z(r, [a, u, d], o), Z(i, [u, a, d], o);
1371
1371
  }
1372
1372
  return { eav: r, aev: i, vae: s };
1373
1373
  }
1374
1374
  function gi(t) {
1375
1375
  const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1376
1376
  for (const s of Object.values(t)) {
1377
- const o = s["forward-identity"], [u, a, d] = o, c = s["reverse-identity"];
1378
- if (Z(r, [a, d], s), Nn(s) && Z(e, [a, d], s), s["primary?"] && Z(n, [a], s), c) {
1377
+ const o = s["forward-identity"], [a, u, d] = o, c = s["reverse-identity"];
1378
+ if (Z(r, [u, d], s), Nn(s) && Z(e, [u, d], s), s["primary?"] && Z(n, [u], s), c) {
1379
1379
  const [f, h, p] = c;
1380
1380
  Z(i, [h, p], s);
1381
1381
  }
@@ -1393,7 +1393,7 @@ function Ti(t) {
1393
1393
  };
1394
1394
  }
1395
1395
  function wi(t) {
1396
- return wt(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
1396
+ return mt(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
1397
1397
  }
1398
1398
  function no(t, e) {
1399
1399
  return We(t.eav, [e]) !== void 0;
@@ -1401,7 +1401,7 @@ function no(t, e) {
1401
1401
  function Wn(t) {
1402
1402
  t.attrIndexes = gi(t.attrs);
1403
1403
  }
1404
- function wt(t, e, n, r, i) {
1404
+ function mt(t, e, n, r, i) {
1405
1405
  const s = _i(t, e, i);
1406
1406
  return s.useDateObjects = i, s.attrs = t, s.attrIndexes = gi(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
1407
1407
  }
@@ -1409,27 +1409,27 @@ function ot(t, e) {
1409
1409
  var n, r;
1410
1410
  let i;
1411
1411
  if (Array.isArray(e[0])) {
1412
- const [o, u] = e[0], a = t.aev.get(o);
1413
- if (!a)
1412
+ const [o, a] = e[0], u = t.aev.get(o);
1413
+ if (!u)
1414
1414
  return null;
1415
- i = (n = X(a, 2).find((c) => c[2] === u)) === null || n === void 0 ? void 0 : n[0];
1415
+ i = (n = X(u, 2).find((c) => c[2] === a)) === null || n === void 0 ? void 0 : n[0];
1416
1416
  } else
1417
1417
  i = e[0];
1418
1418
  if (!i)
1419
1419
  return null;
1420
1420
  const s = e[2];
1421
1421
  if (Array.isArray(s) && s.length === 2 && t.aev.get(s[0])) {
1422
- const [o, u] = s, a = t.aev.get(o);
1423
- if (!a)
1422
+ const [o, a] = s, u = t.aev.get(o);
1423
+ if (!u)
1424
1424
  return null;
1425
- const c = (r = X(a, 2).find((b) => b[2] === u)) === null || r === void 0 ? void 0 : r[0];
1425
+ const c = (r = X(u, 2).find((b) => b[2] === a)) === null || r === void 0 ? void 0 : r[0];
1426
1426
  if (!c)
1427
1427
  return null;
1428
1428
  const [f, h, p, ...y] = e;
1429
1429
  return [i, h, c, ...y];
1430
1430
  } else {
1431
- const [o, ...u] = e;
1432
- return [i, ...u];
1431
+ const [o, ...a] = e;
1432
+ return [i, ...a];
1433
1433
  }
1434
1434
  }
1435
1435
  function mi(t, e) {
@@ -1443,8 +1443,8 @@ let ro = 0;
1443
1443
  function Si(t, e, n) {
1444
1444
  const [r, i, s] = n;
1445
1445
  let o;
1446
- const u = We(t.ea, [r, i, s]);
1447
- return u && (o = u[3]), o || Date.now() * 10 + ro++;
1446
+ const a = We(t.ea, [r, i, s]);
1447
+ return a && (o = a[3]), o || Date.now() * 10 + ro++;
1448
1448
  }
1449
1449
  function vi(t, e) {
1450
1450
  var n;
@@ -1452,34 +1452,34 @@ function vi(t, e) {
1452
1452
  if (!r)
1453
1453
  return;
1454
1454
  let [i, s, o] = r;
1455
- const u = Ne(t.attrs, s);
1456
- if (!u)
1455
+ const a = Ne(t.attrs, s);
1456
+ if (!a)
1457
1457
  return;
1458
- u["checked-data-type"] === "date" && t.useDateObjects && (o = jt(o));
1459
- const a = We(t.eav, [i, s, o]), d = (n = a == null ? void 0 : a[3]) !== null && n !== void 0 ? n : Si(t, u, r), c = [i, s, o, d];
1460
- to(u) ? (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)), Fn(u) && Z(t.vae, [o, s, i], c);
1458
+ a["checked-data-type"] === "date" && t.useDateObjects && (o = It(o));
1459
+ const u = We(t.eav, [i, s, o]), d = (n = u == null ? void 0 : u[3]) !== null && n !== void 0 ? n : Si(t, a, r), c = [i, s, o, d];
1460
+ to(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)), Fn(a) && Z(t.vae, [o, s, i], c);
1461
1461
  }
1462
1462
  function io(t, e) {
1463
1463
  var n;
1464
1464
  const r = ot(t, e);
1465
1465
  if (!r)
1466
1466
  return;
1467
- const [i, s, o] = r, u = Ne(t.attrs, s);
1468
- if (!u)
1467
+ const [i, s, o] = r, a = Ne(t.attrs, s);
1468
+ if (!a)
1469
1469
  return;
1470
- if (!Nn(u))
1470
+ if (!Nn(a))
1471
1471
  throw new Error("merge operation is not supported for links");
1472
- const a = We(t.eav, [i, s]);
1473
- if (!a)
1472
+ const u = We(t.eav, [i, s]);
1473
+ if (!u)
1474
1474
  return;
1475
- const d = (n = a.values().next()) === null || n === void 0 ? void 0 : n.value;
1475
+ const d = (n = u.values().next()) === null || n === void 0 ? void 0 : n.value;
1476
1476
  if (!d)
1477
1477
  return;
1478
1478
  const c = d[2], f = yi(c, o), h = [
1479
1479
  i,
1480
1480
  s,
1481
1481
  f,
1482
- Si(t, u, d)
1482
+ Si(t, a, d)
1483
1483
  ];
1484
1484
  Z(t.eav, [i, s], /* @__PURE__ */ new Map([[f, h]]));
1485
1485
  }
@@ -1488,27 +1488,27 @@ function cn(t, e) {
1488
1488
  const [i, s] = e, o = ot(t, [i]);
1489
1489
  if (!o)
1490
1490
  return;
1491
- const [u] = o, a = t.eav.get(u);
1492
- if (a) {
1493
- for (const c of a.keys()) {
1491
+ const [a] = o, u = t.eav.get(a);
1492
+ if (u) {
1493
+ for (const c of u.keys()) {
1494
1494
  const f = t.attrs[c];
1495
- f && f["on-delete-reverse"] === "cascade" && X(a.get(c), 1).forEach(([h, p, y]) => {
1495
+ f && f["on-delete-reverse"] === "cascade" && X(u.get(c), 1).forEach(([h, p, y]) => {
1496
1496
  var b;
1497
1497
  return cn(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
1498
1498
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
1499
1499
  // the store that didn't set `etype` in deleteEntity
1500
1500
  (!s || // If we don't know about the attr, let's just get rid of it
1501
1501
  !f || // Make sure it matches the etype
1502
- ((n = f["forward-identity"]) === null || n === void 0 ? void 0 : n[1]) === s) && (oe(t.aev, [c, u]), oe(t.eav, [u, c]));
1502
+ ((n = f["forward-identity"]) === null || n === void 0 ? void 0 : n[1]) === s) && (oe(t.aev, [c, a]), oe(t.eav, [a, c]));
1503
1503
  }
1504
- a.size === 0 && oe(t.eav, [u]);
1504
+ u.size === 0 && oe(t.eav, [a]);
1505
1505
  }
1506
- const d = t.vae.get(u) && X(t.vae.get(u), 2);
1506
+ const d = t.vae.get(a) && X(t.vae.get(a), 2);
1507
1507
  d && d.forEach((c) => {
1508
1508
  var f, h, p;
1509
1509
  const [y, b, _] = c, T = t.attrs[b];
1510
1510
  (!s || !T || ((f = T["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (oe(t.eav, [y, b, _]), oe(t.aev, [b, y, _]), oe(t.vae, [_, b, y])), T && T["on-delete"] === "cascade" && ((h = T["reverse-identity"]) === null || h === void 0 ? void 0 : h[1]) === s && cn(t, [y, (p = T["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
1511
- }), ((r = t.vae.get(u)) === null || r === void 0 ? void 0 : r.size) === 0 && oe(t.vae, [u]);
1511
+ }), ((r = t.vae.get(a)) === null || r === void 0 ? void 0 : r.size) === 0 && oe(t.vae, [a]);
1512
1512
  }
1513
1513
  function Oi(t, e) {
1514
1514
  const n = _i(t.attrs, e, t.useDateObjects);
@@ -1528,11 +1528,11 @@ function oo(t, [e]) {
1528
1528
  const n = Ei(t).filter(([r, i]) => i !== e);
1529
1529
  delete t.attrs[e], Wn(t), Oi(t, n);
1530
1530
  }
1531
- function uo(t, [e]) {
1531
+ function ao(t, [e]) {
1532
1532
  const n = t.attrs[e.id];
1533
1533
  n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), Wn(t), Oi(t, Ei(t)));
1534
1534
  }
1535
- function ao(t, e) {
1535
+ function uo(t, e) {
1536
1536
  const [n, ...r] = e;
1537
1537
  switch (n) {
1538
1538
  case "add-triple":
@@ -1554,7 +1554,7 @@ function ao(t, e) {
1554
1554
  oo(t, r);
1555
1555
  break;
1556
1556
  case "update-attr":
1557
- uo(t, r);
1557
+ ao(t, r);
1558
1558
  break;
1559
1559
  case "restore-attr":
1560
1560
  break;
@@ -1580,22 +1580,22 @@ function pt(t, e, n) {
1580
1580
  var r, i;
1581
1581
  const s = [];
1582
1582
  if (n != null && n.hasOwnProperty("$not")) {
1583
- for (const u of e.keys())
1584
- n.$not !== u && s.push(e.get(u));
1583
+ for (const a of e.keys())
1584
+ n.$not !== a && s.push(e.get(a));
1585
1585
  return s;
1586
1586
  }
1587
1587
  if (n != null && n.hasOwnProperty("$isNull")) {
1588
- const { attrId: u, isNull: a, reverse: d } = n.$isNull;
1588
+ const { attrId: a, isNull: u, reverse: d } = n.$isNull;
1589
1589
  if (d)
1590
1590
  for (const c of e.keys()) {
1591
- const f = t.vae.get(c), h = !f || ((r = f.get(u)) === null || r === void 0 ? void 0 : r.get(null)) || !f.get(u);
1592
- (a ? h : !h) && s.push(e.get(c));
1591
+ const f = t.vae.get(c), h = !f || ((r = f.get(a)) === null || r === void 0 ? void 0 : r.get(null)) || !f.get(a);
1592
+ (u ? h : !h) && s.push(e.get(c));
1593
1593
  }
1594
1594
  else {
1595
- const c = t.aev.get(u);
1595
+ const c = t.aev.get(a);
1596
1596
  for (const f of e.keys()) {
1597
1597
  const h = !c || ((i = c.get(f)) === null || i === void 0 ? void 0 : i.get(null)) || !c.get(f);
1598
- (a ? h : !h) && s.push(e.get(f));
1598
+ (u ? h : !h) && s.push(e.get(f));
1599
1599
  }
1600
1600
  }
1601
1601
  return s;
@@ -1603,9 +1603,9 @@ function pt(t, e, n) {
1603
1603
  if (n != null && n.$comparator)
1604
1604
  return X(e, 1).filter(n.$op);
1605
1605
  const o = n.in || n.$in || [n];
1606
- for (const u of o) {
1607
- const a = e.get(u);
1608
- a && s.push(a);
1606
+ for (const a of o) {
1607
+ const u = e.get(a);
1608
+ u && s.push(u);
1609
1609
  }
1610
1610
  return s;
1611
1611
  }
@@ -1617,46 +1617,46 @@ function fo(t, [e, n, r]) {
1617
1617
  var i, s;
1618
1618
  switch (co(e, n, r)) {
1619
1619
  case "e": {
1620
- const u = t.eav.get(e);
1621
- return X(u, 2);
1620
+ const a = t.eav.get(e);
1621
+ return X(a, 2);
1622
1622
  }
1623
1623
  case "ea": {
1624
- const u = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
1625
- return X(u, 1);
1624
+ const a = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
1625
+ return X(a, 1);
1626
1626
  }
1627
1627
  case "eav": {
1628
- const u = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
1629
- return u ? pt(t, u, r) : [];
1628
+ const a = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
1629
+ return a ? pt(t, a, r) : [];
1630
1630
  }
1631
1631
  case "ev": {
1632
- const u = t.eav.get(e);
1633
- if (!u)
1632
+ const a = t.eav.get(e);
1633
+ if (!a)
1634
1634
  return [];
1635
- const a = [];
1636
- for (const d of u.values())
1637
- a.push(...pt(t, d, r));
1638
- return a;
1635
+ const u = [];
1636
+ for (const d of a.values())
1637
+ u.push(...pt(t, d, r));
1638
+ return u;
1639
1639
  }
1640
1640
  case "a": {
1641
- const u = t.aev.get(n);
1642
- return X(u, 2);
1641
+ const a = t.aev.get(n);
1642
+ return X(a, 2);
1643
1643
  }
1644
1644
  case "av": {
1645
- const u = t.aev.get(n);
1646
- if (!u)
1645
+ const a = t.aev.get(n);
1646
+ if (!a)
1647
1647
  return [];
1648
- const a = [];
1649
- for (const d of u.values())
1650
- a.push(...pt(t, d, r));
1651
- return a;
1652
- }
1653
- case "v": {
1654
1648
  const u = [];
1655
- for (const a of t.eav.values())
1656
- for (const d of a.values())
1657
- u.push(...pt(t, d, r));
1649
+ for (const d of a.values())
1650
+ u.push(...pt(t, d, r));
1658
1651
  return u;
1659
1652
  }
1653
+ case "v": {
1654
+ const a = [];
1655
+ for (const u of t.eav.values())
1656
+ for (const d of u.values())
1657
+ a.push(...pt(t, d, r));
1658
+ return a;
1659
+ }
1660
1660
  default:
1661
1661
  return X(t.eav, 3);
1662
1662
  }
@@ -1665,8 +1665,8 @@ function lo(t, e, n) {
1665
1665
  var r;
1666
1666
  const i = {};
1667
1667
  for (const [s, o] of e.entries()) {
1668
- const u = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), a = X(u, 1);
1669
- for (const d of a)
1668
+ const a = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), u = X(a, 1);
1669
+ for (const d of u)
1670
1670
  i[s] = d[2];
1671
1671
  }
1672
1672
  return i;
@@ -1696,11 +1696,11 @@ function po(t, e) {
1696
1696
  return We(t.eav, [r, i]);
1697
1697
  }
1698
1698
  function yo(t, e) {
1699
- const n = e.filter(([r, i, s, o, u]) => {
1699
+ const n = e.filter(([r, i, s, o, a]) => {
1700
1700
  if (r !== "add-triple" && r !== "deep-merge-triple")
1701
1701
  return !0;
1702
- const a = u == null ? void 0 : u.mode;
1703
- if (a !== "create" && a !== "update")
1702
+ const u = a == null ? void 0 : a.mode;
1703
+ if (u !== "create" && u !== "update")
1704
1704
  return !0;
1705
1705
  let d = !1;
1706
1706
  const c = Ne(t.attrs, s);
@@ -1708,11 +1708,11 @@ function yo(t, e) {
1708
1708
  const f = Ci(t, c["forward-identity"][1]);
1709
1709
  d = !!po(t, [i, f.id, i]);
1710
1710
  }
1711
- return !(a === "create" && d || a === "update" && !d);
1711
+ return !(u === "create" && d || u === "update" && !d);
1712
1712
  });
1713
- return un(t, (r) => {
1713
+ return an(t, (r) => {
1714
1714
  n.forEach((i) => {
1715
- ao(r, i);
1715
+ uo(r, i);
1716
1716
  });
1717
1717
  });
1718
1718
  }
@@ -1788,15 +1788,15 @@ for (let t = 0; t < 256; ++t)
1788
1788
  function Co(t, e = 0) {
1789
1789
  return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
1790
1790
  }
1791
- let Kt;
1791
+ let Bt;
1792
1792
  const ko = new Uint8Array(16);
1793
1793
  function jo() {
1794
- if (!Kt) {
1794
+ if (!Bt) {
1795
1795
  if (typeof crypto > "u" || !crypto.getRandomValues)
1796
1796
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1797
- Kt = crypto.getRandomValues.bind(crypto);
1797
+ Bt = crypto.getRandomValues.bind(crypto);
1798
1798
  }
1799
- return Kt(ko);
1799
+ return Bt(ko);
1800
1800
  }
1801
1801
  const Io = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Er = { randomUUID: Io };
1802
1802
  function Po(t, e, n) {
@@ -1845,9 +1845,9 @@ function xo() {
1845
1845
  const Do = xo();
1846
1846
  let Uo = 0;
1847
1847
  function tt(t) {
1848
- return It(`_${t}`, Uo++);
1848
+ return Pt(`_${t}`, Uo++);
1849
1849
  }
1850
- function It(t, e) {
1850
+ function Pt(t, e) {
1851
1851
  return `?${t}-${e}`;
1852
1852
  }
1853
1853
  class Le extends Error {
@@ -1876,23 +1876,23 @@ function No(t, e, n) {
1876
1876
  return t.map((r) => r === e ? n : r);
1877
1877
  }
1878
1878
  function ji(t, e, n, r, i) {
1879
- const s = _e(e, n, i), o = Ai(e, n, i), u = s || o;
1880
- if (!u)
1879
+ const s = _e(e, n, i), o = Ai(e, n, i), a = s || o;
1880
+ if (!a)
1881
1881
  throw new Le(`Could not find attr for ${[n, i]}`);
1882
- if (u["value-type"] !== "ref")
1883
- throw new Error(`Attr ${u.id} is not a ref`);
1884
- const [a, d] = u["forward-identity"], [c, f] = u["reverse-identity"], h = r + 1, p = s ? [
1882
+ if (a["value-type"] !== "ref")
1883
+ throw new Error(`Attr ${a.id} is not a ref`);
1884
+ const [u, d] = a["forward-identity"], [c, f] = a["reverse-identity"], h = r + 1, p = s ? [
1885
1885
  t(d, r),
1886
- u.id,
1886
+ a.id,
1887
1887
  t(f, h),
1888
1888
  tt("time")
1889
1889
  ] : [
1890
1890
  t(d, h),
1891
- u.id,
1891
+ a.id,
1892
1892
  t(f, r),
1893
1893
  tt("time")
1894
1894
  ];
1895
- return [s ? f : d, h, p, u, !!s];
1895
+ return [s ? f : d, h, p, a, !!s];
1896
1896
  }
1897
1897
  function kr(t, e) {
1898
1898
  if (typeof e != "string")
@@ -1965,8 +1965,8 @@ function Wo(t, e) {
1965
1965
  return e;
1966
1966
  }
1967
1967
  function Vo(t, e, n, r, i, s) {
1968
- const o = _e(e, n, i), u = Ai(e, n, i), a = o || u;
1969
- if (!a)
1968
+ const o = _e(e, n, i), a = Ai(e, n, i), u = o || a;
1969
+ if (!u)
1970
1970
  throw new Le(`No attr for etype = ${n} label = ${i}`);
1971
1971
  if (s != null && s.hasOwnProperty("$isNull")) {
1972
1972
  const d = _e(e, n, "id");
@@ -1975,26 +1975,26 @@ function Vo(t, e, n, r, i, s) {
1975
1975
  return [
1976
1976
  t(n, r),
1977
1977
  d.id,
1978
- { $isNull: { attrId: a.id, isNull: s.$isNull, reverse: !o } },
1978
+ { $isNull: { attrId: u.id, isNull: s.$isNull, reverse: !o } },
1979
1979
  tt("time")
1980
1980
  ];
1981
1981
  }
1982
1982
  return o ? [
1983
1983
  t(n, r),
1984
- a.id,
1985
- Wo(a, s),
1984
+ u.id,
1985
+ Wo(u, s),
1986
1986
  tt("time")
1987
- ] : [s, a.id, t(n, r), tt("time")];
1987
+ ] : [s, u.id, t(n, r), tt("time")];
1988
1988
  }
1989
1989
  function qo(t, e, n, r, i) {
1990
- const [s, o, u] = i.reduce((a, d) => {
1991
- const [c, f, h] = a, [p, y, b] = ji(t, e, c, f, d);
1990
+ const [s, o, a] = i.reduce((u, d) => {
1991
+ const [c, f, h] = u, [p, y, b] = ji(t, e, c, f, d);
1992
1992
  return [p, y, [...h, b]];
1993
1993
  }, [n, r, []]);
1994
- return [s, o, u];
1994
+ return [s, o, a];
1995
1995
  }
1996
1996
  function fn(t, e, n, r, i, s) {
1997
- const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = qo(t, e, n, r, o), f = Vo(t, e, a, d, u, s);
1997
+ const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, d, c] = qo(t, e, n, r, o), f = Vo(t, e, u, d, a, s);
1998
1998
  return c.concat([f]);
1999
1999
  }
2000
2000
  function zo(t, e) {
@@ -2013,11 +2013,11 @@ function Go(t, e, n) {
2013
2013
  };
2014
2014
  }
2015
2015
  function jr(t, e, n, r, i, s) {
2016
- const o = t(r, i), u = s.map((a, d) => {
2016
+ const o = t(r, i), a = s.map((u, d) => {
2017
2017
  const c = Go(t, o, d);
2018
- return Ii(c, n, r, i, a);
2018
+ return Ii(c, n, r, i, u);
2019
2019
  });
2020
- return { [e]: { patterns: u, joinSym: o } };
2020
+ return { [e]: { patterns: a, joinSym: o } };
2021
2021
  }
2022
2022
  function Qo(t) {
2023
2023
  const e = [];
@@ -2036,47 +2036,47 @@ function Ii(t, e, n, r, i) {
2036
2036
  return jr(t, "and", e, n, r, o);
2037
2037
  if (s === "$entityIdStartsWith")
2038
2038
  return [];
2039
- const u = s.split(".");
2039
+ const a = s.split(".");
2040
2040
  if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2041
- const a = fn(t, e, n, r, u, o), d = Ir(t, e, n, r, u);
2041
+ const u = fn(t, e, n, r, a, o), d = Ir(t, e, n, r, a);
2042
2042
  return [
2043
2043
  {
2044
2044
  or: {
2045
- patterns: [a, ...d],
2045
+ patterns: [u, ...d],
2046
2046
  joinSym: t(n, r)
2047
2047
  }
2048
2048
  }
2049
2049
  ];
2050
2050
  }
2051
- return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && u.length > 1 ? [
2051
+ return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2052
2052
  {
2053
2053
  or: {
2054
- patterns: Ir(t, e, n, r, u),
2054
+ patterns: Ir(t, e, n, r, a),
2055
2055
  joinSym: t(n, r)
2056
2056
  }
2057
2057
  }
2058
- ] : fn(t, e, n, r, u, o);
2058
+ ] : fn(t, e, n, r, a, o);
2059
2059
  });
2060
2060
  }
2061
2061
  function Ho(t, e, n, r) {
2062
- const i = It;
2062
+ const i = Pt;
2063
2063
  return r ? Ii(i, t, e, n, r).concat(Cr(i, t, e, n)) : Cr(i, t, e, n);
2064
2064
  }
2065
2065
  function Yo(t, e, n) {
2066
2066
  return [t(e, n), t("time", n)];
2067
2067
  }
2068
2068
  function Jo(t, e, n, r, i, s) {
2069
- const [o, u, a, d, c] = ji(t, e, n, r, i), f = No(a, t(n, r), s);
2070
- return [o, u, f, d, c];
2069
+ const [o, a, u, d, c] = ji(t, e, n, r, i), f = No(u, t(n, r), s);
2070
+ return [o, a, f, d, c];
2071
2071
  }
2072
2072
  function Zo(t, e, { etype: n, level: r, form: i }, s) {
2073
- const o = Object.keys(i).filter((u) => u !== "$");
2074
- return o.length ? Object.entries(s).map(function([a, d]) {
2073
+ const o = Object.keys(i).filter((a) => a !== "$");
2074
+ return o.length ? Object.entries(s).map(function([u, d]) {
2075
2075
  return o.map(function(h) {
2076
2076
  var p, y, b;
2077
2077
  const _ = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[h]) === null || b === void 0) && b.isSingular));
2078
2078
  try {
2079
- const [T, w, m] = Jo(t, e, n, r, h, a), j = Mi(e, {
2079
+ const [T, w, m] = Jo(t, e, n, r, h, u), j = Mi(e, {
2080
2080
  etype: T,
2081
2081
  level: w,
2082
2082
  form: i[h],
@@ -2099,54 +2099,54 @@ function Xo(t, e, n) {
2099
2099
  function Je(t, e, n, r, i) {
2100
2100
  return e === r || e == null && r == null ? Ro(t, n) : r == null ? 1 : e == null ? -1 : Xo(e, r, i);
2101
2101
  }
2102
- function At([t, e], [n, r], i) {
2102
+ function Ct([t, e], [n, r], i) {
2103
2103
  return Je(t, e, n, r, i);
2104
2104
  }
2105
2105
  function ln(t) {
2106
2106
  return t == null ? t : new Date(t).getTime();
2107
2107
  }
2108
- function eu(t, e, n, r) {
2108
+ function ea(t, e, n, r) {
2109
2109
  var i;
2110
- const [s, o, u, a] = t, d = n === "desc" ? 1 : -1;
2110
+ const [s, o, a, u] = t, d = n === "desc" ? 1 : -1;
2111
2111
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2112
- return At(r, [s, a], null) === d;
2113
- const [c, f] = r, h = e["checked-data-type"], p = h === "date" ? ln(f) : f, y = h === "date" ? ln(u) : u;
2114
- return At([c, p], [s, y], h) === d;
2112
+ return Ct(r, [s, u], null) === d;
2113
+ const [c, f] = r, h = e["checked-data-type"], p = h === "date" ? ln(f) : f, y = h === "date" ? ln(a) : a;
2114
+ return Ct([c, p], [s, y], h) === d;
2115
2115
  }
2116
- function tu(t, e) {
2116
+ function ta(t, e) {
2117
2117
  const n = e[1];
2118
2118
  return t.attrs[n];
2119
2119
  }
2120
- function nu(t, e, n) {
2120
+ function na(t, e, n) {
2121
2121
  const r = Object.keys(n)[0];
2122
2122
  return _e(t, e, r);
2123
2123
  }
2124
- function ru(t, e, n, r) {
2124
+ function ra(t, e, n, r) {
2125
2125
  if (n)
2126
- return tu(t, n);
2126
+ return ta(t, n);
2127
2127
  if (r)
2128
- return nu(t, e, r);
2128
+ return na(t, e, r);
2129
2129
  }
2130
- function iu(t, e, n) {
2130
+ function ia(t, e, n) {
2131
2131
  var r, i;
2132
2132
  if (!Array.isArray(n.fields))
2133
2133
  return ho(t, e);
2134
2134
  const s = /* @__PURE__ */ new Map();
2135
2135
  for (const o of n.fields) {
2136
- const u = _e(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2137
- a && Nn(u) && s.set(a, u);
2136
+ const a = _e(t, e, o), u = (r = a == null ? void 0 : a["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2137
+ u && Nn(a) && s.set(u, a);
2138
2138
  }
2139
2139
  if (!s.has("id")) {
2140
- const o = _e(t, e, "id"), u = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
2141
- u && s.set(u, o);
2140
+ const o = _e(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
2141
+ a && s.set(a, o);
2142
2142
  }
2143
2143
  return s;
2144
2144
  }
2145
- function su(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2145
+ function sa(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2146
2146
  var s, o;
2147
- const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Pi(i), d = ou(i);
2147
+ const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = Pi(i), d = oa(i);
2148
2148
  let c = Oo(t, r);
2149
- const f = n == null ? void 0 : n["start-cursor"], h = ru(t, e, f, u);
2149
+ const f = n == null ? void 0 : n["start-cursor"], h = ra(t, e, f, a);
2150
2150
  if (h && ((o = h == null ? void 0 : h["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
2151
2151
  const b = h["checked-data-type"] === "date", _ = h.id;
2152
2152
  c = c.map(([T]) => {
@@ -2156,22 +2156,22 @@ function su(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2156
2156
  });
2157
2157
  }
2158
2158
  c.sort(d === "asc" ? function(_, T) {
2159
- return At(_, T, h == null ? void 0 : h["checked-data-type"]);
2159
+ return Ct(_, T, h == null ? void 0 : h["checked-data-type"]);
2160
2160
  } : function(_, T) {
2161
- return At(T, _, h == null ? void 0 : h["checked-data-type"]);
2161
+ return Ct(T, _, h == null ? void 0 : h["checked-data-type"]);
2162
2162
  });
2163
2163
  let p = {};
2164
- const y = iu(t, e, r);
2164
+ const y = ia(t, e, r);
2165
2165
  for (const b of c) {
2166
2166
  const [_] = b;
2167
- if (p[_] || !a && f && h && eu(f, h, d, b))
2167
+ if (p[_] || !u && f && h && ea(f, h, d, b))
2168
2168
  continue;
2169
2169
  const T = lo(t, y, _);
2170
2170
  T && (p[_] = T);
2171
2171
  }
2172
2172
  return p;
2173
2173
  }
2174
- function ou(t) {
2174
+ function oa(t) {
2175
2175
  var e;
2176
2176
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2177
2177
  return n && n[Object.keys(n)[0]] || "asc";
@@ -2181,16 +2181,16 @@ function Pi(t) {
2181
2181
  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
2182
  return !i && !s && !o;
2183
2183
  }
2184
- function uu(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2185
- var o, u, a, d, c;
2184
+ function aa(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2185
+ var o, a, u, d, c;
2186
2186
  if (!Pi(r) && (!s || !s["start-cursor"]))
2187
2187
  return [];
2188
- const f = zo(Ho(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), h = Yo(It, e, n), p = (u = r.$) === null || u === void 0 ? void 0 : u.fields, y = su(t, {
2188
+ const f = zo(Ho(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), h = Yo(Pt, e, n), p = (a = r.$) === null || a === void 0 ? void 0 : a.fields, y = sa(t, {
2189
2189
  etype: e,
2190
2190
  pageInfo: s,
2191
2191
  form: r,
2192
2192
  dq: { where: f, find: h, fields: p }
2193
- }), b = ((a = r.$) === null || a === void 0 ? void 0 : a.limit) || ((d = r.$) === null || d === void 0 ? void 0 : d.first) || ((c = r.$) === null || c === void 0 ? void 0 : c.last);
2193
+ }), b = ((u = r.$) === null || u === void 0 ? void 0 : u.limit) || ((d = r.$) === null || d === void 0 ? void 0 : d.first) || ((c = r.$) === null || c === void 0 ? void 0 : c.last);
2194
2194
  if (b != null) {
2195
2195
  n > 0 && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2196
2196
  const _ = Object.entries(y);
@@ -2198,9 +2198,9 @@ function uu(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2198
2198
  }
2199
2199
  return y;
2200
2200
  }
2201
- function au(t, e) {
2201
+ function ua(t, e) {
2202
2202
  try {
2203
- return uu(t, e);
2203
+ return aa(t, e);
2204
2204
  } catch (n) {
2205
2205
  if (n instanceof Le)
2206
2206
  return {};
@@ -2208,10 +2208,10 @@ function au(t, e) {
2208
2208
  }
2209
2209
  }
2210
2210
  function Mi(t, e) {
2211
- const n = au(t, e);
2212
- return Zo(It, t, e, n);
2211
+ const n = ua(t, e);
2212
+ return Zo(Pt, t, e, n);
2213
2213
  }
2214
- function cu(t) {
2214
+ function ca(t) {
2215
2215
  const e = {};
2216
2216
  for (const [n, r] of Object.entries(t))
2217
2217
  e[n] = {
@@ -2223,17 +2223,17 @@ function cu(t) {
2223
2223
  return e;
2224
2224
  }
2225
2225
  function Ri({ store: t, pageInfo: e, aggregate: n }, r) {
2226
- const s = { data: Object.keys(r).reduce(function(u, a) {
2227
- return n != null && n[a] || a === "$$ruleParams" || (u[a] = Mi(t, {
2228
- etype: a,
2229
- form: r[a],
2226
+ const s = { data: Object.keys(r).reduce(function(a, u) {
2227
+ return n != null && n[u] || u === "$$ruleParams" || (a[u] = Mi(t, {
2228
+ etype: u,
2229
+ form: r[u],
2230
2230
  level: 0,
2231
- pageInfo: e == null ? void 0 : e[a]
2232
- })), u;
2231
+ pageInfo: e == null ? void 0 : e[u]
2232
+ })), a;
2233
2233
  }, {}) };
2234
- return e && (s.pageInfo = cu(e)), n && (s.aggregate = n), s;
2234
+ return e && (s.pageInfo = ca(e)), n && (s.aggregate = n), s;
2235
2235
  }
2236
- function du() {
2236
+ function da() {
2237
2237
  const e = {
2238
2238
  __etype: 1,
2239
2239
  __ops: 1,
@@ -2247,7 +2247,7 @@ function du() {
2247
2247
  };
2248
2248
  return new Set(Object.keys(e));
2249
2249
  }
2250
- const fu = du();
2250
+ const fa = da();
2251
2251
  function hn(t, e, n) {
2252
2252
  const r = {
2253
2253
  __etype: t,
@@ -2259,10 +2259,10 @@ function hn(t, e, n) {
2259
2259
  return n;
2260
2260
  if (s === "__etype")
2261
2261
  return t;
2262
- if (fu.has(s))
2263
- return (o, u) => hn(t, e, [
2262
+ if (fa.has(s))
2263
+ return (o, a) => hn(t, e, [
2264
2264
  ...n,
2265
- u ? [s, t, e, o, u] : [s, t, e, o]
2265
+ a ? [s, t, e, o, a] : [s, t, e, o]
2266
2266
  ]);
2267
2267
  }
2268
2268
  });
@@ -2270,14 +2270,14 @@ function hn(t, e, n) {
2270
2270
  function Ec(t, e) {
2271
2271
  return `lookup__${t}__${JSON.stringify(e)}`;
2272
2272
  }
2273
- function Ct(t) {
2273
+ function kt(t) {
2274
2274
  return t.startsWith("lookup__");
2275
2275
  }
2276
2276
  function $i(t) {
2277
2277
  const [e, n, ...r] = t.split("__");
2278
2278
  return [n, JSON.parse(r.join("__"))];
2279
2279
  }
2280
- function lu(t) {
2280
+ function la(t) {
2281
2281
  return new Proxy({
2282
2282
  __etype: t
2283
2283
  }, {
@@ -2285,30 +2285,30 @@ function lu(t) {
2285
2285
  if (n === "__etype")
2286
2286
  return t;
2287
2287
  const r = n;
2288
- return Ct(r) ? hn(t, $i(r), []) : hn(t, r, []);
2288
+ return kt(r) ? hn(t, $i(r), []) : hn(t, r, []);
2289
2289
  }
2290
2290
  });
2291
2291
  }
2292
2292
  function qn() {
2293
2293
  return new Proxy({}, {
2294
2294
  get(t, e) {
2295
- return lu(e);
2295
+ return la(e);
2296
2296
  }
2297
2297
  });
2298
2298
  }
2299
2299
  const Ac = qn();
2300
- function hu(t) {
2300
+ function ha(t) {
2301
2301
  return t.__ops;
2302
2302
  }
2303
- function pu(t, e) {
2303
+ function pa(t, e) {
2304
2304
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2305
2305
  for (const o of e) {
2306
- const u = n[o];
2307
- if (u)
2308
- i.push(u);
2306
+ const a = n[o];
2307
+ if (a)
2308
+ i.push(a);
2309
2309
  else if (Array.isArray(o) && o.length == 2 && n[o[0]]) {
2310
- const [a, d] = o;
2311
- i.push([n[a], d]);
2310
+ const [u, d] = o;
2311
+ i.push([n[u], d]);
2312
2312
  } else
2313
2313
  i.push(o);
2314
2314
  }
@@ -2325,16 +2325,16 @@ function K(t, e, n) {
2325
2325
  return s === e && o === n;
2326
2326
  });
2327
2327
  }
2328
- function ve(t, e, n) {
2328
+ function Oe(t, e, n) {
2329
2329
  return Object.values(t).find((r) => {
2330
2330
  const i = r["reverse-identity"];
2331
2331
  if (!i)
2332
2332
  return !1;
2333
- const [s, o, u] = i;
2334
- return o === e && u === n;
2333
+ const [s, o, a] = i;
2334
+ return o === e && a === n;
2335
2335
  });
2336
2336
  }
2337
- function yu(t) {
2337
+ function ya(t) {
2338
2338
  if (Array.isArray(t))
2339
2339
  return t;
2340
2340
  const e = Object.entries(t);
@@ -2353,22 +2353,22 @@ function yn(t) {
2353
2353
  throw new Error(`${t} is not a valid lookup attribute.`);
2354
2354
  return e;
2355
2355
  }
2356
- function bu(t, e, n) {
2356
+ function ba(t, e, n) {
2357
2357
  if (!pn(t, e, n))
2358
2358
  return K(t, e, n);
2359
- const r = yn(n), i = K(t, e, r) || ve(t, e, r);
2359
+ const r = yn(n), i = K(t, e, r) || Oe(t, e, r);
2360
2360
  if (i && i["value-type"] !== "ref")
2361
2361
  throw new Error(`${n} does not reference a valid link attribute.`);
2362
2362
  return i;
2363
2363
  }
2364
2364
  function bn(t) {
2365
- return typeof t == "string" && !Ct(t) ? null : typeof t == "string" && Ct(t) ? $i(t) : yu(t);
2365
+ return typeof t == "string" && !kt(t) ? null : typeof t == "string" && kt(t) ? $i(t) : ya(t);
2366
2366
  }
2367
2367
  function ee(t, e, n) {
2368
2368
  const r = bn(n);
2369
2369
  if (r === null)
2370
2370
  return n;
2371
- const [i, s] = r, o = bu(t, e, i);
2371
+ const [i, s] = r, o = ba(t, e, i);
2372
2372
  if (!o || !o["unique?"])
2373
2373
  throw new Error(`${i} is not a unique attribute.`);
2374
2374
  return [o.id, s];
@@ -2382,14 +2382,14 @@ function xi(t, e, n, r) {
2382
2382
  i
2383
2383
  ]].concat(r) : r;
2384
2384
  }
2385
- function _u({ attrs: t }, [e, n, r]) {
2385
+ function _a({ attrs: t }, [e, n, r]) {
2386
2386
  const i = Object.entries(r).flatMap(([s, o]) => {
2387
- const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = ve(t, e, s);
2388
- return u.map((c) => a ? [
2387
+ const a = Array.isArray(o) ? o : [o], u = K(t, e, s), d = Oe(t, e, s);
2388
+ return a.map((c) => u ? [
2389
2389
  "add-triple",
2390
2390
  ee(t, e, n),
2391
- a.id,
2392
- ee(t, a["reverse-identity"][1], c)
2391
+ u.id,
2392
+ ee(t, u["reverse-identity"][1], c)
2393
2393
  ] : [
2394
2394
  "add-triple",
2395
2395
  ee(t, d["forward-identity"][1], c),
@@ -2399,14 +2399,14 @@ function _u({ attrs: t }, [e, n, r]) {
2399
2399
  });
2400
2400
  return xi(t, e, n, i);
2401
2401
  }
2402
- function gu({ attrs: t }, [e, n, r]) {
2402
+ function ga({ attrs: t }, [e, n, r]) {
2403
2403
  const i = Object.entries(r).flatMap(([s, o]) => {
2404
- const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = ve(t, e, s);
2405
- return u.map((c) => a ? [
2404
+ const a = Array.isArray(o) ? o : [o], u = K(t, e, s), d = Oe(t, e, s);
2405
+ return a.map((c) => u ? [
2406
2406
  "retract-triple",
2407
2407
  ee(t, e, n),
2408
- a.id,
2409
- ee(t, a["reverse-identity"][1], c)
2408
+ u.id,
2409
+ ee(t, u["reverse-identity"][1], c)
2410
2410
  ] : [
2411
2411
  "retract-triple",
2412
2412
  ee(t, d["forward-identity"][1], c),
@@ -2416,13 +2416,13 @@ function gu({ attrs: t }, [e, n, r]) {
2416
2416
  });
2417
2417
  return xi(t, e, n, i);
2418
2418
  }
2419
- function Tu(t, e, n) {
2419
+ function Ta(t, e, n) {
2420
2420
  if (Array.isArray(n)) {
2421
2421
  const [r, i] = n;
2422
2422
  for (const s of t || []) {
2423
2423
  const o = s == null ? void 0 : s.aev.get(r);
2424
2424
  if (o) {
2425
- for (const [u, a, d] of X(o, 2))
2425
+ for (const [a, u, d] of X(o, 2))
2426
2426
  if (d === i)
2427
2427
  return !0;
2428
2428
  }
@@ -2439,20 +2439,20 @@ function Tu(t, e, n) {
2439
2439
  return !1;
2440
2440
  }
2441
2441
  function Di({ 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 : Tu(t, n, r) ? { mode: "update" } : null;
2442
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Ta(t, n, r) ? { mode: "update" } : null;
2443
2443
  }
2444
- function wu(t, e) {
2445
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = Ln(o), d = ee(r, i, s);
2446
- return [["id", d]].concat(Object.entries(a)).map(([f, h]) => {
2444
+ function wa(t, e) {
2445
+ const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Ln(o), d = ee(r, i, s);
2446
+ return [["id", d]].concat(Object.entries(u)).map(([f, h]) => {
2447
2447
  const p = K(r, i, f);
2448
- return p["checked-data-type"] === "date" && t.useDateObjects && (h = jt(h)), ["add-triple", d, p.id, h, { mode: "create" }];
2448
+ return p["checked-data-type"] === "date" && t.useDateObjects && (h = It(h)), ["add-triple", d, p.id, h, { mode: "create" }];
2449
2449
  });
2450
2450
  }
2451
- function mu(t, e) {
2452
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = Ln(o), d = ee(r, i, s), c = Di(t, [i, d, o, u]);
2453
- return [["id", d]].concat(Object.entries(a)).map(([h, p]) => {
2451
+ function ma(t, e) {
2452
+ const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Ln(o), d = ee(r, i, s), c = Di(t, [i, d, o, a]);
2453
+ return [["id", d]].concat(Object.entries(u)).map(([h, p]) => {
2454
2454
  const y = K(r, i, h);
2455
- return y["checked-data-type"] === "date" && t.useDateObjects && (p = jt(p)), [
2455
+ return y["checked-data-type"] === "date" && t.useDateObjects && (p = It(p)), [
2456
2456
  "add-triple",
2457
2457
  d,
2458
2458
  y.id,
@@ -2461,11 +2461,11 @@ function mu(t, e) {
2461
2461
  ];
2462
2462
  });
2463
2463
  }
2464
- function Su({ attrs: t }, [e, n]) {
2464
+ function Sa({ attrs: t }, [e, n]) {
2465
2465
  return [["delete-entity", ee(t, e, n), e]];
2466
2466
  }
2467
- function vu(t, e) {
2468
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = Ln(o), d = ee(r, i, s), c = Di(t, [i, d, o, u]), f = Object.entries(a).map(([p, y]) => {
2467
+ function va(t, e) {
2468
+ const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Ln(o), d = ee(r, i, s), c = Di(t, [i, d, o, a]), f = Object.entries(u).map(([p, y]) => {
2469
2469
  const b = K(r, i, p);
2470
2470
  return [
2471
2471
  "deep-merge-triple",
@@ -2483,38 +2483,38 @@ function vu(t, e) {
2483
2483
  ...c ? [c] : []
2484
2484
  ]].concat(f);
2485
2485
  }
2486
- function Ou({ attrs: t }, [e, n, r]) {
2486
+ function Oa({ attrs: t }, [e, n, r]) {
2487
2487
  return [["rule-params", ee(t, e, n), e, r]];
2488
2488
  }
2489
- function Eu(t) {
2489
+ function Ea(t) {
2490
2490
  const [e, n, r, i, s] = t;
2491
2491
  if (!i)
2492
2492
  return t;
2493
2493
  const o = Object.assign({}, i);
2494
2494
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
2495
2495
  }
2496
- function Au(t, e) {
2497
- const [n, ...r] = Eu(e);
2496
+ function Aa(t, e) {
2497
+ const [n, ...r] = Ea(e);
2498
2498
  switch (n) {
2499
2499
  case "merge":
2500
- return vu(t, r);
2500
+ return va(t, r);
2501
2501
  case "create":
2502
- return wu(t, r);
2502
+ return wa(t, r);
2503
2503
  case "update":
2504
- return mu(t, r);
2504
+ return ma(t, r);
2505
2505
  case "link":
2506
- return _u(t, r);
2506
+ return _a(t, r);
2507
2507
  case "unlink":
2508
- return gu(t, r);
2508
+ return ga(t, r);
2509
2509
  case "delete":
2510
- return Su(t, r);
2510
+ return Sa(t, r);
2511
2511
  case "ruleParams":
2512
- return Ou(t, r);
2512
+ return Oa(t, r);
2513
2513
  default:
2514
2514
  throw new Error(`unsupported action ${n}`);
2515
2515
  }
2516
2516
  }
2517
- function Cu(t) {
2517
+ function Ca(t) {
2518
2518
  switch (t) {
2519
2519
  case "string":
2520
2520
  case "date":
@@ -2525,29 +2525,29 @@ function Cu(t) {
2525
2525
  return;
2526
2526
  }
2527
2527
  }
2528
- function ku(t, e, n) {
2528
+ function ka(t, e, n) {
2529
2529
  var r, i;
2530
2530
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
2531
2531
  if (n === "id")
2532
2532
  return null;
2533
2533
  if (!s)
2534
2534
  throw new Error(`${e}.${n} does not exist in your schema`);
2535
- const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Cu(s == null ? void 0 : s.valueType);
2535
+ const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ca(s == null ? void 0 : s.valueType);
2536
2536
  return {
2537
- "index?": u,
2537
+ "index?": a,
2538
2538
  "unique?": o,
2539
- "checked-data-type": a
2539
+ "checked-data-type": u
2540
2540
  };
2541
2541
  }
2542
2542
  function yt(t, e, n, r) {
2543
- const i = t ? ku(t, e, n) : null, s = W(), u = [W(), e, n];
2544
- return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2543
+ const i = t ? ka(t, e, n) : null, s = W(), a = [W(), e, n];
2544
+ return Object.assign(Object.assign({ id: s, "forward-identity": a, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2545
2545
  }
2546
- function ju(t, e, n) {
2546
+ function ja(t, e, n) {
2547
2547
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2548
2548
  }
2549
- function Iu(t, e, n) {
2550
- const r = ju(t, e, n);
2549
+ function Ia(t, e, n) {
2550
+ const r = ja(t, e, n);
2551
2551
  if (!r)
2552
2552
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2553
2553
  const { forward: i, reverse: s } = r;
@@ -2561,10 +2561,10 @@ function Iu(t, e, n) {
2561
2561
  };
2562
2562
  }
2563
2563
  function Pr(t, e, n, r) {
2564
- const i = t ? Iu(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
2565
- return Object.assign(Object.assign({ id: s, "forward-identity": o, "reverse-identity": u, "value-type": "ref", cardinality: "many", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2564
+ const i = t ? Ia(t, e, n) : null, s = W(), o = [W(), e, n], a = [W(), n, e];
2565
+ 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
2566
  }
2567
- const Pu = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Mu = /* @__PURE__ */ new Set(["link", "unlink"]), Ru = /* @__PURE__ */ new Set(["create", "update", "merge"]), $u = /* @__PURE__ */ new Set([
2567
+ const Pa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Ma = /* @__PURE__ */ new Set(["link", "unlink"]), Ra = /* @__PURE__ */ new Set(["create", "update", "merge"]), $a = /* @__PURE__ */ new Set([
2568
2568
  "link",
2569
2569
  "unlink",
2570
2570
  "create",
@@ -2572,79 +2572,79 @@ const Pu = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2572
2572
  "merge",
2573
2573
  "delete",
2574
2574
  "ruleParams"
2575
- ]), _n = { "unique?": !0, "index?": !0 }, xu = Object.assign(Object.assign({}, _n), { cardinality: "one" });
2576
- function Du(t) {
2575
+ ]), _n = { "unique?": !0, "index?": !0 }, xa = Object.assign(Object.assign({}, _n), { cardinality: "one" });
2576
+ function Da(t) {
2577
2577
  const e = [], [n, r, i, s] = t;
2578
- if (!$u.has(n))
2578
+ if (!$a.has(n))
2579
2579
  return e;
2580
2580
  const o = bn(i);
2581
2581
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2582
- for (const [u, a] of Object.entries(s)) {
2583
- const d = Array.isArray(a) ? a : [a];
2582
+ for (const [a, u] of Object.entries(s)) {
2583
+ const d = Array.isArray(u) ? u : [u];
2584
2584
  for (const c of d) {
2585
2585
  const f = bn(c);
2586
2586
  f && e.push({
2587
2587
  etype: r,
2588
2588
  lookupPair: f,
2589
- linkLabel: u
2589
+ linkLabel: a
2590
2590
  });
2591
2591
  }
2592
2592
  }
2593
2593
  return e;
2594
2594
  }
2595
- function Uu({ attrs: t, schema: e }, n) {
2595
+ function Ua({ attrs: t, schema: e }, n) {
2596
2596
  var r, i;
2597
- const [s, o, u] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
2598
- function a(f) {
2599
- o[f.id] = f, u.push(["add-attr", f]), s.add(f.id);
2597
+ const [s, o, a] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
2598
+ function u(f) {
2599
+ o[f.id] = f, a.push(["add-attr", f]), s.add(f.id);
2600
2600
  }
2601
2601
  function d(f) {
2602
- f != null && f.isUnsynced && !s.has(f.id) && (u.push(["add-attr", f]), s.add(f.id));
2602
+ f != null && f.isUnsynced && !s.has(f.id) && (a.push(["add-attr", f]), s.add(f.id));
2603
2603
  }
2604
2604
  function c(f, h) {
2605
- const p = K(o, f, h), y = ve(o, f, h);
2606
- d(p), d(y), !p && !y && a(Pr(e, f, h, xu));
2605
+ const p = K(o, f, h), y = Oe(o, f, h);
2606
+ d(p), d(y), !p && !y && u(Pr(e, f, h, xa));
2607
2607
  }
2608
2608
  for (const f of n)
2609
- for (const { etype: h, lookupPair: p, linkLabel: y } of Du(f)) {
2609
+ for (const { etype: h, lookupPair: p, linkLabel: y } of Da(f)) {
2610
2610
  const b = p[0];
2611
2611
  if (y) {
2612
2612
  c(h, y);
2613
- const _ = K(o, h, y), T = ve(o, h, y);
2613
+ const _ = K(o, h, y), T = Oe(o, h, y);
2614
2614
  d(_), d(T);
2615
2615
  const w = ((r = _ == null ? void 0 : _["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = T == null ? void 0 : T["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || y;
2616
2616
  if (pn(o, w, b))
2617
2617
  c(w, yn(b));
2618
2618
  else {
2619
2619
  const m = K(o, w, b);
2620
- m || a(yt(e, w, b, _n)), d(m);
2620
+ m || u(yt(e, w, b, _n)), d(m);
2621
2621
  }
2622
2622
  } else if (pn(o, h, b))
2623
2623
  c(h, yn(b));
2624
2624
  else {
2625
2625
  const _ = K(o, h, b);
2626
- _ || a(yt(e, h, b, _n)), d(_);
2626
+ _ || u(yt(e, h, b, _n)), d(_);
2627
2627
  }
2628
2628
  }
2629
2629
  for (const f of n) {
2630
2630
  const [h, p, y, b] = f;
2631
- if (Pu.has(h)) {
2631
+ if (Pa.has(h)) {
2632
2632
  const _ = K(o, p, "id");
2633
- d(_), _ || a(yt(e, p, "id", { "unique?": !0 }));
2633
+ d(_), _ || u(yt(e, p, "id", { "unique?": !0 }));
2634
2634
  for (const T of Object.keys(b)) {
2635
2635
  const w = K(o, p, T);
2636
- if (d(w), Ru.has(h) && (w || a(yt(e, p, T, T === "id" ? { "unique?": !0 } : null))), Mu.has(h)) {
2637
- const m = ve(o, p, T);
2638
- !w && !m && a(Pr(e, p, T)), d(m);
2636
+ if (d(w), Ra.has(h) && (w || u(yt(e, p, T, T === "id" ? { "unique?": !0 } : null))), Ma.has(h)) {
2637
+ const m = Oe(o, p, T);
2638
+ !w && !m && u(Pr(e, p, T)), d(m);
2639
2639
  }
2640
2640
  }
2641
2641
  }
2642
2642
  }
2643
- return [o, u];
2643
+ return [o, a];
2644
2644
  }
2645
- function Lu(t, e) {
2646
- const r = (Array.isArray(e) ? e : [e]).flatMap((a) => hu(a)), [i, s] = Uu(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), u = r.flatMap((a) => Au(o, a));
2647
- return [...s, ...u];
2645
+ function La(t, e) {
2646
+ const r = (Array.isArray(e) ? e : [e]).flatMap((u) => ha(u)), [i, s] = Ua(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), a = r.flatMap((u) => Aa(o, u));
2647
+ return [...s, ...a];
2648
2648
  }
2649
2649
  var Mr = function(t, e, n, r) {
2650
2650
  function i(s) {
@@ -2653,14 +2653,14 @@ var Mr = function(t, e, n, r) {
2653
2653
  });
2654
2654
  }
2655
2655
  return new (n || (n = Promise))(function(s, o) {
2656
- function u(c) {
2656
+ function a(c) {
2657
2657
  try {
2658
2658
  d(r.next(c));
2659
2659
  } catch (f) {
2660
2660
  o(f);
2661
2661
  }
2662
2662
  }
2663
- function a(c) {
2663
+ function u(c) {
2664
2664
  try {
2665
2665
  d(r.throw(c));
2666
2666
  } catch (f) {
@@ -2668,7 +2668,7 @@ var Mr = function(t, e, n, r) {
2668
2668
  }
2669
2669
  }
2670
2670
  function d(c) {
2671
- c.done ? s(c.value) : i(c.value).then(u, a);
2671
+ c.done ? s(c.value) : i(c.value).then(a, u);
2672
2672
  }
2673
2673
  d((r = r.apply(t, e || [])).next());
2674
2674
  });
@@ -2694,11 +2694,11 @@ class Ui {
2694
2694
  return Mr(this, void 0, void 0, function* () {
2695
2695
  const n = yield this._dbPromise;
2696
2696
  return new Promise((r, i) => {
2697
- const u = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
2698
- u.onerror = (a) => {
2699
- i(a);
2700
- }, u.onsuccess = (a) => {
2701
- u.result ? r(u.result) : r(null);
2697
+ const a = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
2698
+ a.onerror = (u) => {
2699
+ i(u);
2700
+ }, a.onsuccess = (u) => {
2701
+ a.result ? r(a.result) : r(null);
2702
2702
  };
2703
2703
  });
2704
2704
  });
@@ -2707,31 +2707,31 @@ class Ui {
2707
2707
  return Mr(this, void 0, void 0, function* () {
2708
2708
  const r = yield this._dbPromise;
2709
2709
  return new Promise((i, s) => {
2710
- const a = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
2711
- a.onerror = (d) => {
2710
+ const u = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
2711
+ u.onerror = (d) => {
2712
2712
  s(d);
2713
- }, a.onsuccess = (d) => {
2713
+ }, u.onsuccess = (d) => {
2714
2714
  i();
2715
2715
  };
2716
2716
  });
2717
2717
  });
2718
2718
  }
2719
2719
  }
2720
- var Fu = function(t, e, n, r) {
2720
+ var Fa = function(t, e, n, r) {
2721
2721
  function i(s) {
2722
2722
  return s instanceof n ? s : new n(function(o) {
2723
2723
  o(s);
2724
2724
  });
2725
2725
  }
2726
2726
  return new (n || (n = Promise))(function(s, o) {
2727
- function u(c) {
2727
+ function a(c) {
2728
2728
  try {
2729
2729
  d(r.next(c));
2730
2730
  } catch (f) {
2731
2731
  o(f);
2732
2732
  }
2733
2733
  }
2734
- function a(c) {
2734
+ function u(c) {
2735
2735
  try {
2736
2736
  d(r.throw(c));
2737
2737
  } catch (f) {
@@ -2739,14 +2739,14 @@ var Fu = function(t, e, n, r) {
2739
2739
  }
2740
2740
  }
2741
2741
  function d(c) {
2742
- c.done ? s(c.value) : i(c.value).then(u, a);
2742
+ c.done ? s(c.value) : i(c.value).then(a, u);
2743
2743
  }
2744
2744
  d((r = r.apply(t, e || [])).next());
2745
2745
  });
2746
2746
  };
2747
2747
  class Li {
2748
2748
  static getIsOnline() {
2749
- return Fu(this, void 0, void 0, function* () {
2749
+ return Fa(this, void 0, void 0, function* () {
2750
2750
  return navigator.onLine;
2751
2751
  });
2752
2752
  }
@@ -2771,21 +2771,21 @@ class Fe extends Error {
2771
2771
  return "InstantError";
2772
2772
  }
2773
2773
  }
2774
- var Nu = function(t, e, n, r) {
2774
+ var Na = function(t, e, n, r) {
2775
2775
  function i(s) {
2776
2776
  return s instanceof n ? s : new n(function(o) {
2777
2777
  o(s);
2778
2778
  });
2779
2779
  }
2780
2780
  return new (n || (n = Promise))(function(s, o) {
2781
- function u(c) {
2781
+ function a(c) {
2782
2782
  try {
2783
2783
  d(r.next(c));
2784
2784
  } catch (f) {
2785
2785
  o(f);
2786
2786
  }
2787
2787
  }
2788
- function a(c) {
2788
+ function u(c) {
2789
2789
  try {
2790
2790
  d(r.throw(c));
2791
2791
  } catch (f) {
@@ -2793,27 +2793,27 @@ var Nu = function(t, e, n, r) {
2793
2793
  }
2794
2794
  }
2795
2795
  function d(c) {
2796
- c.done ? s(c.value) : i(c.value).then(u, a);
2796
+ c.done ? s(c.value) : i(c.value).then(a, u);
2797
2797
  }
2798
2798
  d((r = r.apply(t, e || [])).next());
2799
2799
  });
2800
2800
  };
2801
- class Pt extends Fe {
2801
+ class Mt extends Fe {
2802
2802
  constructor(e) {
2803
2803
  var n;
2804
2804
  const r = ((n = e.body) === null || n === void 0 ? void 0 : n.message) || `API Error (${e.status})`;
2805
2805
  super(r, e.body.hint);
2806
2806
  const i = new.target.prototype;
2807
- Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, Pt), this.name = "InstantAPIError", this.status = e.status, this.body = e.body;
2807
+ Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, Mt), this.name = "InstantAPIError", this.status = e.status, this.body = e.body;
2808
2808
  }
2809
2809
  get [Symbol.toStringTag]() {
2810
2810
  return "InstantAPIError";
2811
2811
  }
2812
2812
  }
2813
- function ae(t, e) {
2814
- return Nu(this, void 0, void 0, function* () {
2813
+ function ue(t, e) {
2814
+ return Na(this, void 0, void 0, function* () {
2815
2815
  const n = yield fetch(t, e), r = yield n.json();
2816
- return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Pt({ status: n.status, body: r }));
2816
+ return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Mt({ status: n.status, body: r }));
2817
2817
  });
2818
2818
  }
2819
2819
  var Ve = function(t, e, n, r) {
@@ -2823,14 +2823,14 @@ var Ve = function(t, e, n, r) {
2823
2823
  });
2824
2824
  }
2825
2825
  return new (n || (n = Promise))(function(s, o) {
2826
- function u(c) {
2826
+ function a(c) {
2827
2827
  try {
2828
2828
  d(r.next(c));
2829
2829
  } catch (f) {
2830
2830
  o(f);
2831
2831
  }
2832
2832
  }
2833
- function a(c) {
2833
+ function u(c) {
2834
2834
  try {
2835
2835
  d(r.throw(c));
2836
2836
  } catch (f) {
@@ -2838,21 +2838,21 @@ var Ve = function(t, e, n, r) {
2838
2838
  }
2839
2839
  }
2840
2840
  function d(c) {
2841
- c.done ? s(c.value) : i(c.value).then(u, a);
2841
+ c.done ? s(c.value) : i(c.value).then(a, u);
2842
2842
  }
2843
2843
  d((r = r.apply(t, e || [])).next());
2844
2844
  });
2845
2845
  };
2846
- function Wu({ apiURI: t, appId: e, email: n }) {
2847
- return ae(`${t}/runtime/auth/send_magic_code`, {
2846
+ function Wa({ apiURI: t, appId: e, email: n }) {
2847
+ return ue(`${t}/runtime/auth/send_magic_code`, {
2848
2848
  method: "POST",
2849
2849
  headers: { "content-type": "application/json" },
2850
2850
  body: JSON.stringify({ "app-id": e, email: n })
2851
2851
  });
2852
2852
  }
2853
- function Vu(t) {
2853
+ function Va(t) {
2854
2854
  return Ve(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
2855
- return yield ae(`${e}/runtime/auth/verify_magic_code`, {
2855
+ return yield ue(`${e}/runtime/auth/verify_magic_code`, {
2856
2856
  method: "POST",
2857
2857
  headers: { "content-type": "application/json" },
2858
2858
  body: JSON.stringify(Object.assign({
@@ -2863,9 +2863,9 @@ function Vu(t) {
2863
2863
  });
2864
2864
  });
2865
2865
  }
2866
- function qu(t) {
2866
+ function qa(t) {
2867
2867
  return Ve(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
2868
- return yield ae(`${e}/runtime/auth/verify_refresh_token`, {
2868
+ return yield ue(`${e}/runtime/auth/verify_refresh_token`, {
2869
2869
  method: "POST",
2870
2870
  headers: { "content-type": "application/json" },
2871
2871
  body: JSON.stringify({
@@ -2875,9 +2875,9 @@ function qu(t) {
2875
2875
  });
2876
2876
  });
2877
2877
  }
2878
- function zu(t) {
2878
+ function za(t) {
2879
2879
  return Ve(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
2880
- return yield ae(`${e}/runtime/auth/sign_in_guest`, {
2880
+ return yield ue(`${e}/runtime/auth/sign_in_guest`, {
2881
2881
  method: "POST",
2882
2882
  headers: { "content-type": "application/json" },
2883
2883
  body: JSON.stringify({
@@ -2888,7 +2888,7 @@ function zu(t) {
2888
2888
  }
2889
2889
  function Rr(t) {
2890
2890
  return Ve(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
2891
- return yield ae(`${e}/runtime/oauth/token`, {
2891
+ return yield ue(`${e}/runtime/oauth/token`, {
2892
2892
  method: "POST",
2893
2893
  headers: { "content-type": "application/json" },
2894
2894
  body: JSON.stringify({
@@ -2900,9 +2900,9 @@ function Rr(t) {
2900
2900
  });
2901
2901
  });
2902
2902
  }
2903
- function Ku(t) {
2903
+ function Ka(t) {
2904
2904
  return Ve(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
2905
- return yield ae(`${e}/runtime/oauth/id_token`, {
2905
+ return yield ue(`${e}/runtime/oauth/id_token`, {
2906
2906
  method: "POST",
2907
2907
  headers: { "content-type": "application/json" },
2908
2908
  body: JSON.stringify({
@@ -2915,9 +2915,9 @@ function Ku(t) {
2915
2915
  });
2916
2916
  });
2917
2917
  }
2918
- function Bu(t) {
2918
+ function Ba(t) {
2919
2919
  return Ve(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
2920
- return yield ae(`${e}/runtime/signout`, {
2920
+ return yield ue(`${e}/runtime/signout`, {
2921
2921
  method: "POST",
2922
2922
  headers: {
2923
2923
  "content-type": "application/json"
@@ -2929,21 +2929,21 @@ function Bu(t) {
2929
2929
  });
2930
2930
  });
2931
2931
  }
2932
- var ut = function(t, e, n, r) {
2932
+ var at = function(t, e, n, r) {
2933
2933
  function i(s) {
2934
2934
  return s instanceof n ? s : new n(function(o) {
2935
2935
  o(s);
2936
2936
  });
2937
2937
  }
2938
2938
  return new (n || (n = Promise))(function(s, o) {
2939
- function u(c) {
2939
+ function a(c) {
2940
2940
  try {
2941
2941
  d(r.next(c));
2942
2942
  } catch (f) {
2943
2943
  o(f);
2944
2944
  }
2945
2945
  }
2946
- function a(c) {
2946
+ function u(c) {
2947
2947
  try {
2948
2948
  d(r.throw(c));
2949
2949
  } catch (f) {
@@ -2951,29 +2951,29 @@ var ut = function(t, e, n, r) {
2951
2951
  }
2952
2952
  }
2953
2953
  function d(c) {
2954
- c.done ? s(c.value) : i(c.value).then(u, a);
2954
+ c.done ? s(c.value) : i(c.value).then(a, u);
2955
2955
  }
2956
2956
  d((r = r.apply(t, e || [])).next());
2957
2957
  });
2958
2958
  };
2959
- function Gu(t) {
2960
- return ut(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
2961
- const a = {
2959
+ function Ga(t) {
2960
+ return at(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: a }) {
2961
+ const u = {
2962
2962
  app_id: n,
2963
2963
  path: r,
2964
2964
  authorization: `Bearer ${s}`,
2965
2965
  "content-type": o || i.type
2966
2966
  };
2967
- return u && (a["content-disposition"] = u), yield ae(`${e}/storage/upload`, {
2967
+ return a && (u["content-disposition"] = a), yield ue(`${e}/storage/upload`, {
2968
2968
  method: "PUT",
2969
- headers: a,
2969
+ headers: u,
2970
2970
  body: i
2971
2971
  });
2972
2972
  });
2973
2973
  }
2974
- function Qu(t) {
2975
- return ut(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
2976
- const { data: s } = yield ae(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
2974
+ function Qa(t) {
2975
+ return at(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
2976
+ const { data: s } = yield ue(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
2977
2977
  method: "DELETE",
2978
2978
  headers: {
2979
2979
  "content-type": "application/json",
@@ -2983,9 +2983,9 @@ function Qu(t) {
2983
2983
  return s;
2984
2984
  });
2985
2985
  }
2986
- function Hu(t) {
2987
- return ut(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
2988
- const { data: o } = yield ae(`${e}/storage/signed-upload-url`, {
2986
+ function Ha(t) {
2987
+ return at(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
2988
+ const { data: o } = yield ue(`${e}/storage/signed-upload-url`, {
2989
2989
  method: "POST",
2990
2990
  headers: {
2991
2991
  "content-type": "application/json",
@@ -2999,8 +2999,8 @@ function Hu(t) {
2999
2999
  return o;
3000
3000
  });
3001
3001
  }
3002
- function Yu(t, e) {
3003
- return ut(this, void 0, void 0, function* () {
3002
+ function Ya(t, e) {
3003
+ return at(this, void 0, void 0, function* () {
3004
3004
  return (yield fetch(t, {
3005
3005
  method: "PUT",
3006
3006
  body: e,
@@ -3010,9 +3010,9 @@ function Yu(t, e) {
3010
3010
  })).ok;
3011
3011
  });
3012
3012
  }
3013
- function Ju(t) {
3014
- return ut(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3015
- const { data: s } = yield ae(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3013
+ function Ja(t) {
3014
+ return at(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3015
+ const { data: s } = yield ue(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3016
3016
  method: "GET",
3017
3017
  headers: {
3018
3018
  "content-type": "application/json",
@@ -3032,25 +3032,25 @@ function $r(t, e) {
3032
3032
  n[r] = t[r];
3033
3033
  }), n;
3034
3034
  }
3035
- function Zu(t, e, n) {
3035
+ function Za(t, e, n) {
3036
3036
  var r, i;
3037
3037
  const s = {
3038
3038
  peers: {}
3039
3039
  };
3040
3040
  if (e && "user" in e ? e.user : !0) {
3041
- const u = $r((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3042
- s.user = Object.assign(Object.assign({}, u), { peerId: n });
3041
+ const a = $r((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3042
+ s.user = Object.assign(Object.assign({}, a), { peerId: n });
3043
3043
  }
3044
- for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3045
- const a = (e == null ? void 0 : e.peers) === void 0, d = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
3046
- if (a || d) {
3047
- const c = $r(t.peers[u], e == null ? void 0 : e.keys);
3048
- s.peers[u] = Object.assign(Object.assign({}, c), { peerId: u });
3044
+ for (const a of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3045
+ const u = (e == null ? void 0 : e.peers) === void 0, d = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(a));
3046
+ if (u || d) {
3047
+ const c = $r(t.peers[a], e == null ? void 0 : e.keys);
3048
+ s.peers[a] = Object.assign(Object.assign({}, c), { peerId: a });
3049
3049
  }
3050
3050
  }
3051
3051
  return s;
3052
3052
  }
3053
- function Xu(t, e) {
3053
+ function Xa(t, e) {
3054
3054
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !mr(t.user, e.user)) || !pi(t.peers, e.peers))
3055
3055
  return !0;
3056
3056
  for (const r of Object.keys(t.peers))
@@ -3078,14 +3078,14 @@ var Be = function(t, e, n, r) {
3078
3078
  });
3079
3079
  }
3080
3080
  return new (n || (n = Promise))(function(s, o) {
3081
- function u(c) {
3081
+ function a(c) {
3082
3082
  try {
3083
3083
  d(r.next(c));
3084
3084
  } catch (f) {
3085
3085
  o(f);
3086
3086
  }
3087
3087
  }
3088
- function a(c) {
3088
+ function u(c) {
3089
3089
  try {
3090
3090
  d(r.throw(c));
3091
3091
  } catch (f) {
@@ -3093,17 +3093,17 @@ var Be = function(t, e, n, r) {
3093
3093
  }
3094
3094
  }
3095
3095
  function d(c) {
3096
- c.done ? s(c.value) : i(c.value).then(u, a);
3096
+ c.done ? s(c.value) : i(c.value).then(a, u);
3097
3097
  }
3098
3098
  d((r = r.apply(t, e || [])).next());
3099
3099
  });
3100
3100
  };
3101
- function ea(t, e) {
3101
+ function eu(t, e) {
3102
3102
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
3103
3103
  }
3104
3104
  class gn {
3105
- constructor(e, n, r, i, s = (d) => d, o = (d) => d, u = 100, a = 1e3) {
3106
- this._subs = [], this._nextSave = null, this._persister = e, this._key = n, this._onMerge = i, this._loadedCbs = [], this._isLoading = !0, this.currentValue = r, this.serialize = s, this.parse = o, this._saveThrottleMs = u, this._pendingSaveCbs = [], this._version = 0, this._idleCallbackMaxWaitMs = a, this._load();
3105
+ constructor(e, n, r, i, s = (d) => d, o = (d) => d, a = 100, u = 1e3) {
3106
+ this._subs = [], this._nextSave = null, this._persister = e, this._key = n, this._onMerge = i, this._loadedCbs = [], this._isLoading = !0, this.currentValue = r, this.serialize = s, this.parse = o, this._saveThrottleMs = a, this._pendingSaveCbs = [], this._version = 0, this._idleCallbackMaxWaitMs = u, this._load();
3107
3107
  }
3108
3108
  _getFromStorage() {
3109
3109
  return Be(this, void 0, void 0, function* () {
@@ -3165,7 +3165,7 @@ class gn {
3165
3165
  return;
3166
3166
  }
3167
3167
  this._nextSave = setTimeout(() => {
3168
- ea(() => {
3168
+ eu(() => {
3169
3169
  this._nextSave = null, this._writeToStorage();
3170
3170
  }, this._idleCallbackMaxWaitMs);
3171
3171
  }, this._saveThrottleMs);
@@ -3186,8 +3186,8 @@ function Wi(t, e = []) {
3186
3186
  t.forEach((n) => {
3187
3187
  const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
3188
3188
  for (const o of s)
3189
- for (const u of o)
3190
- e.push(u);
3189
+ for (const a of o)
3190
+ e.push(a);
3191
3191
  Wi(n["child-nodes"], e);
3192
3192
  });
3193
3193
  }
@@ -3209,8 +3209,8 @@ function Ur(t) {
3209
3209
  }, e;
3210
3210
  }, {});
3211
3211
  }
3212
- const Kn = "v0.22.47-experimental.sync-table.19184737115.1";
3213
- function ta(t, e) {
3212
+ const Kn = "v0.22.47-experimental.sync-table.19185753694.1";
3213
+ function tu(t, e) {
3214
3214
  return {
3215
3215
  info: t ? (...n) => console.info(...n, e()) : () => {
3216
3216
  },
@@ -3242,15 +3242,15 @@ class H {
3242
3242
  return new H(this.valueType, this.required, !0, Object.assign(Object.assign({}, this.config), { indexed: !0 }));
3243
3243
  }
3244
3244
  }
3245
- class Mt {
3245
+ class Rt {
3246
3246
  constructor(e, n) {
3247
3247
  this.attrs = e, this.links = n;
3248
3248
  }
3249
3249
  asType() {
3250
- return new Mt(this.attrs, this.links);
3250
+ return new Rt(this.attrs, this.links);
3251
3251
  }
3252
3252
  }
3253
- class Rt {
3253
+ class $t {
3254
3254
  constructor(e, n, r) {
3255
3255
  this.entities = e, this.links = n, this.rooms = r;
3256
3256
  }
@@ -3274,7 +3274,7 @@ class Rt {
3274
3274
  * @see https://instantdb.com/docs/presence-and-topics#typesafety
3275
3275
  */
3276
3276
  withRoomSchema() {
3277
- return new Rt(this.entities, this.links, {});
3277
+ return new $t(this.entities, this.links, {});
3278
3278
  }
3279
3279
  }
3280
3280
  class R extends Error {
@@ -3294,7 +3294,7 @@ const Lr = [
3294
3294
  "before",
3295
3295
  "fields",
3296
3296
  "aggregate"
3297
- ], na = (t) => t.valueType || "unknown", Vi = (t, e, n = !1) => {
3297
+ ], nu = (t) => t.valueType || "unknown", Vi = (t, e, n = !1) => {
3298
3298
  if (n || t == null)
3299
3299
  return !0;
3300
3300
  switch (e) {
@@ -3309,9 +3309,9 @@ const Lr = [
3309
3309
  default:
3310
3310
  return !0;
3311
3311
  }
3312
- }, ra = (t, e, n, r, i, s, o) => {
3313
- const u = s.valueType === "json", a = (d, c, f) => {
3314
- if (!Vi(f, c, u))
3312
+ }, ru = (t, e, n, r, i, s, o) => {
3313
+ const a = s.valueType === "json", u = (d, c, f) => {
3314
+ if (!Vi(f, c, a))
3315
3315
  throw new R(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
3316
3316
  };
3317
3317
  switch (t) {
@@ -3320,7 +3320,7 @@ const Lr = [
3320
3320
  if (!Array.isArray(e))
3321
3321
  throw new R(`Operator '${t}' for attribute '${r}' in entity '${i}' must be an array, but received: ${typeof e}`, o);
3322
3322
  for (const d of e)
3323
- a(t, n, d);
3323
+ u(t, n, d);
3324
3324
  break;
3325
3325
  case "$not":
3326
3326
  case "$ne":
@@ -3328,30 +3328,30 @@ const Lr = [
3328
3328
  case "$lt":
3329
3329
  case "$gte":
3330
3330
  case "$lte":
3331
- a(t, n, e);
3331
+ u(t, n, e);
3332
3332
  break;
3333
3333
  case "$like":
3334
3334
  case "$ilike":
3335
- if (a(t, "string", e), t === "$ilike" && !s.isIndexed)
3335
+ if (u(t, "string", e), t === "$ilike" && !s.isIndexed)
3336
3336
  throw new R(`Operator '${t}' can only be used with indexed attributes, but '${r}' in entity '${i}' is not indexed`, o);
3337
3337
  break;
3338
3338
  case "$isNull":
3339
- a(t, "boolean", e);
3339
+ u(t, "boolean", e);
3340
3340
  break;
3341
3341
  default:
3342
3342
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
3343
3343
  }
3344
3344
  }, xe = (t, e, n, r, i) => {
3345
- const s = na(n), o = n.valueType === "json";
3345
+ const s = nu(n), o = n.valueType === "json";
3346
3346
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3347
3347
  if (o)
3348
3348
  return;
3349
- const a = t;
3350
- for (const [d, c] of Object.entries(a))
3351
- ra(d, c, s, e, r, n, `${i}.${d}`);
3349
+ const u = t;
3350
+ for (const [d, c] of Object.entries(u))
3351
+ ru(d, c, s, e, r, n, `${i}.${d}`);
3352
3352
  } else if (!Vi(t, s, o))
3353
3353
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3354
- }, ia = (t, e, n, r, i) => {
3354
+ }, iu = (t, e, n, r, i) => {
3355
3355
  const s = t.split(".");
3356
3356
  if (s.length < 2)
3357
3357
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -3367,25 +3367,25 @@ const Lr = [
3367
3367
  }
3368
3368
  o = p.entityName;
3369
3369
  }
3370
- const u = s[s.length - 1], a = r.entities[o];
3371
- if (!a)
3370
+ const a = s[s.length - 1], u = r.entities[o];
3371
+ if (!u)
3372
3372
  throw new R(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, i);
3373
- if (u === "id") {
3373
+ if (a === "id") {
3374
3374
  if (typeof e == "string" && !Ue(e))
3375
3375
  throw new R(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3376
3376
  xe(e, t, new H("string", !1, !0), n, i);
3377
3377
  return;
3378
3378
  }
3379
- const d = a.attrs[u];
3380
- if (Object.keys(a.links).includes(u)) {
3379
+ const d = u.attrs[a];
3380
+ if (Object.keys(u.links).includes(a)) {
3381
3381
  if (typeof e == "string" && !Ue(e))
3382
- throw new R(`Invalid value for link '${u}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3382
+ throw new R(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
3383
3383
  xe(e, t, new H("string", !1, !0), n, i);
3384
3384
  return;
3385
3385
  }
3386
3386
  if (!d) {
3387
- const c = Object.keys(a.attrs);
3388
- throw new R(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") + ", id" : "id"}`, i);
3387
+ const c = Object.keys(u.attrs);
3388
+ throw new R(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") + ", id" : "id"}`, i);
3389
3389
  }
3390
3390
  xe(e, t, d, n, i);
3391
3391
  }, qi = (t, e, n, r) => {
@@ -3401,27 +3401,27 @@ const Lr = [
3401
3401
  continue;
3402
3402
  }
3403
3403
  if (i.includes(".")) {
3404
- ia(i, s, e, n, `${r}.${i}`);
3404
+ iu(i, s, e, n, `${r}.${i}`);
3405
3405
  continue;
3406
3406
  }
3407
3407
  const o = n.entities[e];
3408
3408
  if (!o)
3409
3409
  continue;
3410
- const u = o.attrs[i], a = o.links[i];
3411
- if (!u && !a) {
3410
+ const a = o.attrs[i], u = o.links[i];
3411
+ if (!a && !u) {
3412
3412
  const d = Object.keys(o.attrs), c = Object.keys(o.links);
3413
3413
  throw new R(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${d.length > 0 ? d.join(", ") : "none"}. Available links: ${c.length > 0 ? c.join(", ") : "none"}`, `${r}.${i}`);
3414
3414
  }
3415
- if (u)
3416
- xe(s, i, u, e, `${r}.${i}`);
3417
- else if (a) {
3415
+ if (a)
3416
+ xe(s, i, a, e, `${r}.${i}`);
3417
+ else if (u) {
3418
3418
  if (typeof s == "string" && !Ue(s))
3419
3419
  throw new R(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${s}`, `${r}.${i}`);
3420
3420
  const d = new H("string", !1, !0);
3421
3421
  xe(s, i, d, e, `${r}.${i}`);
3422
3422
  }
3423
3423
  }
3424
- }, sa = (t, e, n, r, i = 0) => {
3424
+ }, su = (t, e, n, r, i = 0) => {
3425
3425
  for (const o of Object.keys(t))
3426
3426
  if (!Lr.includes(o))
3427
3427
  throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Lr.join(", ")}. Found: ${o}`, r);
@@ -3448,19 +3448,19 @@ const Lr = [
3448
3448
  for (const o of Object.keys(t))
3449
3449
  if (o !== "$") {
3450
3450
  if (n && !(o in n.entities[e].links)) {
3451
- const a = Object.keys(n.entities[e].links);
3452
- throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${a.length > 0 ? a.join(", ") : "none"}`, `${r}.${o}`);
3451
+ const u = Object.keys(n.entities[e].links);
3452
+ throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${u.length > 0 ? u.join(", ") : "none"}`, `${r}.${o}`);
3453
3453
  }
3454
- const u = t[o];
3455
- if (typeof u == "object" && u !== null) {
3456
- const a = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3457
- a && zi(u, a, n, `${r}.${o}`, i + 1);
3454
+ const a = t[o];
3455
+ if (typeof a == "object" && a !== null) {
3456
+ const u = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3457
+ u && zi(a, u, n, `${r}.${o}`, i + 1);
3458
3458
  }
3459
3459
  } else {
3460
- const u = t[o];
3461
- if (typeof u != "object" || u === null)
3462
- throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
3463
- sa(u, e, n, `${r}.$`, i);
3460
+ const a = t[o];
3461
+ if (typeof a != "object" || a === null)
3462
+ throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3463
+ su(a, e, n, `${r}.$`, i);
3464
3464
  }
3465
3465
  }, Fr = (t, e) => {
3466
3466
  if (typeof t != "object" || t === null)
@@ -3481,27 +3481,27 @@ const Lr = [
3481
3481
  zi(n[r], r, e, r, 0);
3482
3482
  }
3483
3483
  }
3484
- }, Nr = (t) => typeof t != "string" ? !1 : Ct(t) ? !0 : Ue(t);
3484
+ }, Nr = (t) => typeof t != "string" ? !1 : kt(t) ? !0 : Ue(t);
3485
3485
  class ie extends Error {
3486
3486
  constructor(e) {
3487
3487
  super(e), this.name = "TransactionValidationError";
3488
3488
  }
3489
3489
  }
3490
- const Ki = (t) => t.length > 0 ? t.join(", ") : "none", oa = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Ki(e)}`), Wr = {
3490
+ const Ki = (t) => t.length > 0 ? t.join(", ") : "none", ou = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Ki(e)}`), Wr = {
3491
3491
  string: (t) => typeof t == "string",
3492
3492
  number: (t) => typeof t == "number" && !isNaN(t),
3493
3493
  boolean: (t) => typeof t == "boolean",
3494
3494
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3495
3495
  json: () => !0
3496
- }, ua = (t, e) => {
3496
+ }, au = (t, e) => {
3497
3497
  var n, r;
3498
3498
  return t == null ? !0 : (r = (n = Wr[e.valueType]) === null || n === void 0 ? void 0 : n.call(Wr, t)) !== null && r !== void 0 ? r : !1;
3499
3499
  }, Bi = (t, e) => {
3500
3500
  const n = e.entities[t];
3501
3501
  if (!n)
3502
- throw oa(t, Object.keys(e.entities));
3502
+ throw ou(t, Object.keys(e.entities));
3503
3503
  return n;
3504
- }, Bt = (t, e, n) => {
3504
+ }, Gt = (t, e, n) => {
3505
3505
  const r = Bi(t, n);
3506
3506
  if (typeof e != "object" || e === null)
3507
3507
  throw new ie(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
@@ -3509,7 +3509,7 @@ const Ki = (t) => t.length > 0 ? t.join(", ") : "none", oa = (t, e) => new ie(`E
3509
3509
  if (i === "id")
3510
3510
  continue;
3511
3511
  const o = r.attrs[i];
3512
- if (o && !ua(s, o))
3512
+ if (o && !au(s, o))
3513
3513
  throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
3514
3514
  }
3515
3515
  }, Vr = (t, e, n) => {
@@ -3518,27 +3518,27 @@ const Ki = (t) => t.length > 0 ? t.join(", ") : "none", oa = (t, e) => new ie(`E
3518
3518
  throw new ie(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
3519
3519
  for (const [i, s] of Object.entries(e)) {
3520
3520
  if (!r.links[i]) {
3521
- const u = Object.keys(r.links);
3522
- throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Ki(u)}`);
3521
+ const a = Object.keys(r.links);
3522
+ throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Ki(a)}`);
3523
3523
  }
3524
3524
  if (s != null) {
3525
3525
  if (Array.isArray(s)) {
3526
- for (const u of s)
3527
- if (!Nr(u))
3528
- throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${u}`);
3526
+ for (const a of s)
3527
+ if (!Nr(a))
3528
+ throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
3529
3529
  } else if (!Nr(s))
3530
3530
  throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
3531
3531
  }
3532
3532
  }
3533
- }, aa = {
3534
- create: Bt,
3535
- update: Bt,
3536
- merge: Bt,
3533
+ }, uu = {
3534
+ create: Gt,
3535
+ update: Gt,
3536
+ merge: Gt,
3537
3537
  link: Vr,
3538
3538
  unlink: Vr,
3539
3539
  delete: () => {
3540
3540
  }
3541
- }, ca = (t, e) => {
3541
+ }, cu = (t, e) => {
3542
3542
  if (!e)
3543
3543
  return;
3544
3544
  const [n, r, i, s] = t;
@@ -3546,9 +3546,9 @@ const Ki = (t) => t.length > 0 ? t.join(", ") : "none", oa = (t, e) => new ie(`E
3546
3546
  throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
3547
3547
  if (typeof r != "string")
3548
3548
  throw new ie(`Entity name must be a string, but received: ${typeof r}`);
3549
- const o = aa[n];
3549
+ const o = uu[n];
3550
3550
  o && s !== void 0 && o(r, s, e);
3551
- }, da = (t, e) => {
3551
+ }, du = (t, e) => {
3552
3552
  const n = Array.isArray(t) ? t : [t];
3553
3553
  for (const r of n) {
3554
3554
  if (!r || typeof r != "object")
@@ -3558,7 +3558,7 @@ const Ki = (t) => t.length > 0 ? t.join(", ") : "none", oa = (t, e) => new ie(`E
3558
3558
  for (const i of r.__ops) {
3559
3559
  if (!Array.isArray(i))
3560
3560
  throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
3561
- ca(i, e);
3561
+ cu(i, e);
3562
3562
  }
3563
3563
  }
3564
3564
  };
@@ -3569,14 +3569,14 @@ var qr = function(t, e, n, r) {
3569
3569
  });
3570
3570
  }
3571
3571
  return new (n || (n = Promise))(function(s, o) {
3572
- function u(c) {
3572
+ function a(c) {
3573
3573
  try {
3574
3574
  d(r.next(c));
3575
3575
  } catch (f) {
3576
3576
  o(f);
3577
3577
  }
3578
3578
  }
3579
- function a(c) {
3579
+ function u(c) {
3580
3580
  try {
3581
3581
  d(r.throw(c));
3582
3582
  } catch (f) {
@@ -3584,7 +3584,7 @@ var qr = function(t, e, n, r) {
3584
3584
  }
3585
3585
  }
3586
3586
  function d(c) {
3587
- c.done ? s(c.value) : i(c.value).then(u, a);
3587
+ c.done ? s(c.value) : i(c.value).then(a, u);
3588
3588
  }
3589
3589
  d((r = r.apply(t, e || [])).next());
3590
3590
  });
@@ -3618,7 +3618,7 @@ class zr {
3618
3618
  return this.conn.send(JSON.stringify(e));
3619
3619
  }
3620
3620
  }
3621
- class fa {
3621
+ class fu {
3622
3622
  constructor(e, n) {
3623
3623
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = null, this.id = `${this.type}_${Gi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
3624
3624
  this.initParams || this.handleError();
@@ -3703,14 +3703,14 @@ var Kr = function(t, e, n, r) {
3703
3703
  });
3704
3704
  }
3705
3705
  return new (n || (n = Promise))(function(s, o) {
3706
- function u(c) {
3706
+ function a(c) {
3707
3707
  try {
3708
3708
  d(r.next(c));
3709
3709
  } catch (f) {
3710
3710
  o(f);
3711
3711
  }
3712
3712
  }
3713
- function a(c) {
3713
+ function u(c) {
3714
3714
  try {
3715
3715
  d(r.throw(c));
3716
3716
  } catch (f) {
@@ -3718,12 +3718,12 @@ var Kr = function(t, e, n, r) {
3718
3718
  }
3719
3719
  }
3720
3720
  function d(c) {
3721
- c.done ? s(c.value) : i(c.value).then(u, a);
3721
+ c.done ? s(c.value) : i(c.value).then(a, u);
3722
3722
  }
3723
3723
  d((r = r.apply(t, e || [])).next());
3724
3724
  });
3725
3725
  };
3726
- function la(t, e) {
3726
+ function lu(t, e) {
3727
3727
  for (const n in t) {
3728
3728
  const r = t[n];
3729
3729
  for (const i of r.entities || [])
@@ -3731,7 +3731,7 @@ function la(t, e) {
3731
3731
  }
3732
3732
  return t;
3733
3733
  }
3734
- function ha(t) {
3734
+ function hu(t) {
3735
3735
  const e = {};
3736
3736
  for (const n in t) {
3737
3737
  const r = t[n];
@@ -3745,7 +3745,7 @@ function ha(t) {
3745
3745
  }
3746
3746
  return e;
3747
3747
  }
3748
- function pa(t, e) {
3748
+ function pu(t, e) {
3749
3749
  const n = {};
3750
3750
  for (const [r, i] of Object.entries(e))
3751
3751
  n[r] = i;
@@ -3754,7 +3754,7 @@ function pa(t, e) {
3754
3754
  n[r] = i;
3755
3755
  return n;
3756
3756
  }
3757
- function Gt(t, e) {
3757
+ function Qt(t, e) {
3758
3758
  return Ri({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
3759
3759
  }
3760
3760
  function Br(t, e, n) {
@@ -3776,17 +3776,17 @@ function Gr(t, e) {
3776
3776
  break;
3777
3777
  }
3778
3778
  }
3779
- function ya(t, e) {
3779
+ function yu(t, e) {
3780
3780
  var n, r, i, s;
3781
3781
  const o = {};
3782
- for (const { action: u, triple: a } of e) {
3783
- const [d, c, f] = a, h = (r = (n = t.attrs[c]) === null || n === void 0 ? void 0 : n["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
3782
+ for (const { action: a, triple: u } of e) {
3783
+ const [d, c, f] = u, h = (r = (n = t.attrs[c]) === null || n === void 0 ? void 0 : n["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
3784
3784
  if (!h)
3785
3785
  continue;
3786
3786
  const p = (i = o[d]) !== null && i !== void 0 ? i : {};
3787
3787
  o[d] = p;
3788
3788
  const y = (s = p[h]) !== null && s !== void 0 ? s : {};
3789
- switch (p[h] = y, u) {
3789
+ switch (p[h] = y, a) {
3790
3790
  case "added":
3791
3791
  y.newValue = f;
3792
3792
  break;
@@ -3797,10 +3797,10 @@ function ya(t, e) {
3797
3797
  }
3798
3798
  return o;
3799
3799
  }
3800
- function Qt(t, e) {
3800
+ function bt(t, e) {
3801
3801
  return { [t.table]: e.map((n) => n.entity) };
3802
3802
  }
3803
- function ba(t, e) {
3803
+ function bu(t, e) {
3804
3804
  const n = t.orderFieldType;
3805
3805
  if (t.orderField === "serverCreatedAt") {
3806
3806
  e.sort(t.orderDirection === "asc" ? function(s, o) {
@@ -3817,13 +3817,13 @@ function ba(t, e) {
3817
3817
  return Je(o.entity.id, o.entity[r], s.entity.id, s.entity[r], n);
3818
3818
  });
3819
3819
  }
3820
- var Re;
3820
+ var we;
3821
3821
  (function(t) {
3822
3822
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
3823
- })(Re || (Re = {}));
3824
- class _a {
3823
+ })(we || (we = {}));
3824
+ class _u {
3825
3825
  constructor(e, n, r, i, s) {
3826
- this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new gn(n, "subs", {}, pa, ha, (o) => la(o, this.config.useDateObjects));
3826
+ this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new gn(n, "subs", {}, pu, hu, (o) => lu(o, this.config.useDateObjects));
3827
3827
  }
3828
3828
  beforeUnload() {
3829
3829
  this.subs.flush();
@@ -3868,19 +3868,19 @@ class _a {
3868
3868
  return Kr(this, void 0, void 0, function* () {
3869
3869
  var i, s, o;
3870
3870
  yield this.subs.waitForLoaded();
3871
- const u = this.subs.currentValue[n];
3872
- if (u && u.state && u.state.txId) {
3873
- this.sendResync(u, u.state), u.entities && r && (Object.keys(e)[0], r({
3874
- type: Re.LoadFromStorage,
3875
- data: Qt(u, u.entities)
3871
+ const a = this.subs.currentValue[n];
3872
+ if (a && a.state && a.state.txId) {
3873
+ this.sendResync(a, a.state), a.entities && r && (Object.keys(e)[0], r({
3874
+ type: we.LoadFromStorage,
3875
+ data: bt(a, a.entities)
3876
3876
  }));
3877
3877
  return;
3878
3878
  }
3879
- const a = Object.keys(e)[0], d = ((s = (i = e[a]) === null || i === void 0 ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order) || { serverCreatedAt: "asc" }, [c, f] = Object.entries(d)[0], h = c === "serverCreatedAt" ? "number" : (o = _e(this.createStore([]), a, c)) === null || o === void 0 ? void 0 : o["checked-data-type"];
3879
+ const u = Object.keys(e)[0], d = ((s = (i = e[u]) === null || i === void 0 ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order) || { serverCreatedAt: "asc" }, [c, f] = Object.entries(d)[0], h = c === "serverCreatedAt" ? "number" : (o = _e(this.createStore([]), u, c)) === null || o === void 0 ? void 0 : o["checked-data-type"];
3880
3880
  this.subs.set((p) => (p[n] = {
3881
3881
  query: e,
3882
3882
  hash: n,
3883
- table: a,
3883
+ table: u,
3884
3884
  orderDirection: f,
3885
3885
  orderField: c,
3886
3886
  orderFieldType: h
@@ -3916,28 +3916,28 @@ class _a {
3916
3916
  this.log.error("Missing hash for subscription", e);
3917
3917
  return;
3918
3918
  }
3919
- const s = [], u = this.subs.set((a) => {
3919
+ const s = [], a = this.subs.set((u) => {
3920
3920
  var d;
3921
- const c = a[i];
3921
+ const c = u[i];
3922
3922
  if (!c)
3923
- return this.log.error("Missing sub for hash", i, e), a;
3923
+ return this.log.error("Missing sub for hash", i, e), u;
3924
3924
  const f = (d = c.entities) !== null && d !== void 0 ? d : [];
3925
3925
  c.entities = f;
3926
3926
  for (const h of r) {
3927
- const p = this.createStore(h), y = Gt(c, p);
3927
+ const p = this.createStore(h), y = Qt(c, p);
3928
3928
  f.push({
3929
3929
  store: p,
3930
3930
  entity: y,
3931
3931
  serverCreatedAt: Br(c, p, y.id)
3932
3932
  }), s.push(y);
3933
3933
  }
3934
- return a;
3934
+ return u;
3935
3935
  })[i];
3936
- u.entities && (Object.keys(u.query)[0], this.notifyCbs(i, {
3937
- type: Re.InitialSyncBatch,
3938
- data: Qt(u, u.entities),
3936
+ a.entities && this.notifyCbs(i, {
3937
+ type: we.InitialSyncBatch,
3938
+ data: bt(a, a.entities),
3939
3939
  batch: s
3940
- }));
3940
+ });
3941
3941
  }
3942
3942
  onSyncInitFinish(e) {
3943
3943
  const n = e["subscription-id"], r = this.idToHash[n];
@@ -3945,12 +3945,17 @@ class _a {
3945
3945
  this.log.error("Missing hash for subscription", e);
3946
3946
  return;
3947
3947
  }
3948
- this.subs.set((i) => {
3949
- const s = i[r];
3950
- if (!s)
3951
- return this.log.error("Missing sub for hash", r, e), i;
3952
- const o = s.state;
3953
- return o ? (o.txId = e["tx-id"], i) : (this.log.error("Sub never set init, missing result", s, e), i);
3948
+ this.subs.set((s) => {
3949
+ const o = s[r];
3950
+ if (!o)
3951
+ return this.log.error("Missing sub for hash", r, e), s;
3952
+ const a = o.state;
3953
+ return a ? (a.txId = e["tx-id"], s) : (this.log.error("Sub never set init, missing result", o, e), s);
3954
+ });
3955
+ const i = this.subs.currentValue[r];
3956
+ i && this.notifyCbs(r, {
3957
+ type: we.InitialSyncComplete,
3958
+ data: bt(i, i.entities || [])
3954
3959
  });
3955
3960
  }
3956
3961
  onSyncUpdateTriples(e) {
@@ -3964,15 +3969,15 @@ class _a {
3964
3969
  const o = i[r];
3965
3970
  if (!o)
3966
3971
  return this.log.error("Missing sub for hash", r, e), i;
3967
- const u = o.state;
3968
- if (!u)
3972
+ const a = o.state;
3973
+ if (!a)
3969
3974
  return this.log.error("Missing state for sub", o, e), i;
3970
- for (const a of e.txes) {
3971
- if (u.txId >= a["tx-id"])
3975
+ for (const u of e.txes) {
3976
+ if (a.txId >= u["tx-id"])
3972
3977
  continue;
3973
- u.txId = a["tx-id"];
3978
+ a.txId = u["tx-id"];
3974
3979
  const d = [], c = {};
3975
- for (const b of a.changes) {
3980
+ for (const b of u.changes) {
3976
3981
  const _ = (s = c[b.triple[0]]) !== null && s !== void 0 ? s : [];
3977
3982
  c[b.triple[0]] = _, _.push(b);
3978
3983
  }
@@ -3983,7 +3988,7 @@ class _a {
3983
3988
  for (const [T, w] of Object.entries(f))
3984
3989
  if (no(w.store, b)) {
3985
3990
  Gr(w.store, _);
3986
- const m = Gt(o, w.store), j = ya(w.store, _)[b];
3991
+ const m = Qt(o, w.store), j = yu(w.store, _)[b];
3987
3992
  for (const [v, { oldValue: M, newValue: U }] of Object.entries(j || {}))
3988
3993
  M === U && delete j[v];
3989
3994
  m ? (h.push({
@@ -3997,7 +4002,7 @@ class _a {
3997
4002
  for (const [b, _] of Object.entries(c)) {
3998
4003
  const T = this.createStore([]);
3999
4004
  Gr(T, _);
4000
- const w = Gt(o, T);
4005
+ const w = Qt(o, T);
4001
4006
  if (!w) {
4002
4007
  this.log.error("No entity found after applying change", {
4003
4008
  sub: o,
@@ -4015,9 +4020,9 @@ class _a {
4015
4020
  const y = [];
4016
4021
  for (const b of d.sort().reverse())
4017
4022
  y.push(f[b].entity), f.splice(b, 1);
4018
- ba(o, f), this.notifyCbs(r, {
4019
- type: Re.SyncTransaction,
4020
- data: Qt(o, o.entities),
4023
+ bu(o, f), this.notifyCbs(r, {
4024
+ type: we.SyncTransaction,
4025
+ data: bt(o, o.entities),
4021
4026
  added: p,
4022
4027
  removed: y,
4023
4028
  updated: h
@@ -4043,7 +4048,7 @@ class _a {
4043
4048
  hint: e.hint
4044
4049
  }, i = Object.keys(e["original-event"].q)[0];
4045
4050
  this.notifyCbs(n, {
4046
- type: Re.Error,
4051
+ type: we.Error,
4047
4052
  data: { [i]: [] },
4048
4053
  error: r
4049
4054
  });
@@ -4060,14 +4065,14 @@ var F = function(t, e, n, r) {
4060
4065
  });
4061
4066
  }
4062
4067
  return new (n || (n = Promise))(function(s, o) {
4063
- function u(c) {
4068
+ function a(c) {
4064
4069
  try {
4065
4070
  d(r.next(c));
4066
4071
  } catch (f) {
4067
4072
  o(f);
4068
4073
  }
4069
4074
  }
4070
- function a(c) {
4075
+ function u(c) {
4071
4076
  try {
4072
4077
  d(r.throw(c));
4073
4078
  } catch (f) {
@@ -4075,11 +4080,11 @@ var F = function(t, e, n, r) {
4075
4080
  }
4076
4081
  }
4077
4082
  function d(c) {
4078
- c.done ? s(c.value) : i(c.value).then(u, a);
4083
+ c.done ? s(c.value) : i(c.value).then(a, u);
4079
4084
  }
4080
4085
  d((r = r.apply(t, e || [])).next());
4081
4086
  });
4082
- }, ga = function(t, e) {
4087
+ }, gu = function(t, e) {
4083
4088
  var n = {};
4084
4089
  for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
4085
4090
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
@@ -4093,23 +4098,23 @@ const fe = {
4093
4098
  AUTHENTICATED: "authenticated",
4094
4099
  CLOSED: "closed",
4095
4100
  ERRORED: "errored"
4096
- }, Ta = 3e4, wa = 3e4, ma = 200, Sa = {
4101
+ }, Tu = 3e4, wu = 3e4, mu = 200, Su = {
4097
4102
  apiURI: "https://api.instantdb.com",
4098
4103
  websocketURI: "wss://api.instantdb.com/runtime/session"
4099
4104
  }, Ht = "_instant_oauth_redirect", Yt = "currentUser";
4100
- function va({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4105
+ function vu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4101
4106
  if (!i)
4102
4107
  return new zr(`${r}?app_id=${e}`);
4103
4108
  switch (t) {
4104
4109
  case "ws":
4105
4110
  return new zr(`${r}?app_id=${e}`);
4106
4111
  case "sse":
4107
- return new fa(i, `${n}/runtime/sse?app_id=${e}`);
4112
+ return new fu(i, `${n}/runtime/sse?app_id=${e}`);
4108
4113
  default:
4109
4114
  throw new Error("Unknown transport type " + t);
4110
4115
  }
4111
4116
  }
4112
- function Oa() {
4117
+ function Ou() {
4113
4118
  return typeof window < "u" || typeof chrome < "u";
4114
4119
  }
4115
4120
  const Qr = {
@@ -4118,7 +4123,7 @@ const Qr = {
4118
4123
  "refresh-presence": !0,
4119
4124
  "patch-presence": !0
4120
4125
  };
4121
- function Ea(t, e) {
4126
+ function Eu(t, e) {
4122
4127
  var n;
4123
4128
  const r = typeof t == "string" ? JSON.parse(t) : t;
4124
4129
  for (const i in r) {
@@ -4130,7 +4135,7 @@ function Ea(t, e) {
4130
4135
  }
4131
4136
  return r;
4132
4137
  }
4133
- function Aa(t) {
4138
+ function Au(t) {
4134
4139
  var e;
4135
4140
  const n = {};
4136
4141
  for (const r in t) {
@@ -4141,13 +4146,13 @@ function Aa(t) {
4141
4146
  }
4142
4147
  function Hr(t) {
4143
4148
  return [...t].sort((e, n) => {
4144
- const [r, i] = e, [s, o] = n, u = i.order || 0, a = o.order || 0;
4145
- return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
4149
+ const [r, i] = e, [s, o] = n, a = i.order || 0, u = o.order || 0;
4150
+ return a == u ? r < s ? -1 : r > s ? 1 : 0 : a - u;
4146
4151
  });
4147
4152
  }
4148
- class Ca {
4153
+ class Cu {
4149
4154
  constructor(e, n = Ui, r = Li, i, s) {
4150
- var o, u, a;
4155
+ var o, a, u;
4151
4156
  if (this._isOnline = !0, this._isShutdown = !1, this.status = fe.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._onMergeQuerySubs = (d, c) => {
4152
4157
  const f = d || {}, h = Object.assign({}, c);
4153
4158
  Object.entries(c).forEach(([y, b]) => {
@@ -4172,7 +4177,7 @@ class Ca {
4172
4177
  }, this.notifyOne = (d) => {
4173
4178
  var c, f;
4174
4179
  const h = (c = this.queryCbs[d]) !== null && c !== void 0 ? c : [], p = (f = this._dataForQueryCache[d]) === null || f === void 0 ? void 0 : f.data, y = this.dataForQuery(d);
4175
- y && (Tt(y, p) || h.forEach((b) => b.cb(y)));
4180
+ y && (wt(y, p) || h.forEach((b) => b.cb(y)));
4176
4181
  }, this.notifyOneQueryOnce = (d) => {
4177
4182
  var c;
4178
4183
  const f = (c = this.queryOnceDfds[d]) !== null && c !== void 0 ? c : [], h = this.dataForQuery(d);
@@ -4182,9 +4187,9 @@ class Ca {
4182
4187
  }, this.notifyQueryError = (d, c) => {
4183
4188
  (this.queryCbs[d] || []).forEach((h) => h.cb({ error: c }));
4184
4189
  }, this.pushTx = (d) => {
4185
- this.config.disableValidation || da(d, this.config.schema);
4190
+ this.config.disableValidation || du(d, this.config.schema);
4186
4191
  try {
4187
- const c = Lu({
4192
+ const c = La({
4188
4193
  attrs: this.optimisticAttrs(),
4189
4194
  schema: this.config.schema,
4190
4195
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4267,7 +4272,7 @@ class Ca {
4267
4272
  return;
4268
4273
  }
4269
4274
  this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4270
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Sa), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : wa, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : ma, this._log = ta(e.verbose || zn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Kn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Oa()) {
4275
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Su), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : wu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : mu, this._log = tu(e.verbose || zn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Kn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Ou()) {
4271
4276
  if (!e.appId)
4272
4277
  throw new Error("Instant must be initialized with an appId.");
4273
4278
  if (!Ue(e.appId))
@@ -4282,9 +4287,9 @@ class Ca {
4282
4287
  } catch (f) {
4283
4288
  this._log.error("[error] handle broadcast channel", f);
4284
4289
  }
4285
- }))), this._initStorage(n), this._syncTable = new _a(this._trySendAuthed.bind(this), this._persister, {
4290
+ }))), this._initStorage(n), this._syncTable = new _u(this._trySendAuthed.bind(this), this._persister, {
4286
4291
  useDateObjects: this.config.useDateObjects
4287
- }, this._log, (d) => wt(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
4292
+ }, this._log, (d) => mt(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
4288
4293
  this._isOnline = d, this._startSocket(), r.listen((c) => {
4289
4294
  c !== this._isOnline && (this._log.info("[network] online =", c), this._isOnline = c, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", fe.CLOSED), this._setStatus(fe.CLOSED)));
4290
4295
  });
@@ -4302,7 +4307,7 @@ class Ca {
4302
4307
  };
4303
4308
  }
4304
4309
  _initStorage(e) {
4305
- this._persister = new e(`instant_${this.config.appId}_5`), this.querySubs = new gn(this._persister, "querySubs", {}, this._onMergeQuerySubs, Aa, (n) => Ea(n, this.config.useDateObjects)), this.pendingMutations = new gn(
4310
+ this._persister = new e(`instant_${this.config.appId}_5`), this.querySubs = new gn(this._persister, "querySubs", {}, this._onMergeQuerySubs, Au, (n) => Eu(n, this.config.useDateObjects)), this.pendingMutations = new gn(
4306
4311
  this._persister,
4307
4312
  "pendingMutations",
4308
4313
  /* @__PURE__ */ new Map(),
@@ -4334,10 +4339,10 @@ class Ca {
4334
4339
  if (s)
4335
4340
  i.resolve({ status: e, eventId: n });
4336
4341
  else if (r.type) {
4337
- const { status: o } = r, u = ga(r, ["status"]);
4338
- i.reject(new Pt({
4342
+ const { status: o } = r, a = gu(r, ["status"]);
4343
+ i.reject(new Mt({
4339
4344
  // @ts-expect-error body.type is not constant typed
4340
- body: u,
4345
+ body: a,
4341
4346
  status: o
4342
4347
  }));
4343
4348
  } else
@@ -4351,12 +4356,12 @@ class Ca {
4351
4356
  const i = (r = (n = this._presence[e]) === null || n === void 0 ? void 0 : n.result) === null || r === void 0 ? void 0 : r.user, s = this._broadcastQueue[e];
4352
4357
  if (this._broadcastQueue[e] = [], i && this._trySetPresence(e, i), s)
4353
4358
  for (const o of s) {
4354
- const { topic: u, roomType: a, data: d } = o;
4355
- this._tryBroadcast(e, a, u, d);
4359
+ const { topic: a, roomType: u, data: d } = o;
4360
+ this._tryBroadcast(e, u, a, d);
4356
4361
  }
4357
4362
  }
4358
4363
  _handleReceive(e, n) {
4359
- var r, i, s, o, u, a;
4364
+ var r, i, s, o, a, u;
4360
4365
  const d = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4361
4366
  switch (Qr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4362
4367
  case "init-ok": {
@@ -4372,7 +4377,7 @@ class Ca {
4372
4377
  break;
4373
4378
  }
4374
4379
  case "add-query-ok": {
4375
- const { q: h, result: p } = n, y = z(h), b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, T = Dr(p), w = wt(this.attrs, T, d, this._linkIndex, this.config.useDateObjects);
4380
+ const { q: h, result: p } = n, y = z(h), b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (u = (a = p == null ? void 0 : p[0]) === null || a === void 0 ? void 0 : a.data) === null || u === void 0 ? void 0 : u.aggregate, T = Dr(p), w = mt(this.attrs, T, d, this._linkIndex, this.config.useDateObjects);
4376
4381
  this.querySubs.set((m) => (m[y].result = {
4377
4382
  store: w,
4378
4383
  pageInfo: b,
@@ -4404,8 +4409,8 @@ class Ca {
4404
4409
  b !== this.pendingMutations.currentValue && this.pendingMutations.set(() => b);
4405
4410
  const _ = Hr(b.entries()), T = h.map((w) => {
4406
4411
  var m, j, v, M;
4407
- const U = w["instaql-query"], B = w["instaql-result"], qe = z(U), at = Dr(B), $t = wt(this.attrs, at, d, this._linkIndex, this.config.useDateObjects), xt = this._applyOptimisticUpdates($t, _, y), ct = (j = (m = B == null ? void 0 : B[0]) === null || m === void 0 ? void 0 : m.data) === null || j === void 0 ? void 0 : j["page-info"], ce = (M = (v = B == null ? void 0 : B[0]) === null || v === void 0 ? void 0 : v.data) === null || M === void 0 ? void 0 : M.aggregate;
4408
- return { hash: qe, store: xt, pageInfo: ct, aggregate: ce };
4412
+ const U = w["instaql-query"], B = w["instaql-result"], qe = z(U), ut = Dr(B), xt = mt(this.attrs, ut, d, this._linkIndex, this.config.useDateObjects), Dt = this._applyOptimisticUpdates(xt, _, y), ct = (j = (m = B == null ? void 0 : B[0]) === null || m === void 0 ? void 0 : m.data) === null || j === void 0 ? void 0 : j["page-info"], ce = (M = (v = B == null ? void 0 : B[0]) === null || v === void 0 ? void 0 : v.data) === null || M === void 0 ? void 0 : M.aggregate;
4413
+ return { hash: qe, store: Dt, pageInfo: ct, aggregate: ce };
4409
4414
  });
4410
4415
  T.forEach(({ hash: w, store: m, pageInfo: j, aggregate: v }) => {
4411
4416
  this.querySubs.set((M) => (M[w].result = { store: m, pageInfo: j, aggregate: v, processedTxId: y }, M));
@@ -4483,7 +4488,7 @@ class Ca {
4483
4488
  }
4484
4489
  }
4485
4490
  _handleReceiveError(e) {
4486
- var n, r, i, s, o, u, a;
4491
+ var n, r, i, s, o, a, u;
4487
4492
  console.log("error", e);
4488
4493
  const d = e["client-event-id"];
4489
4494
  this._inFlightMutationEventIds.delete(d);
@@ -4507,11 +4512,11 @@ class Ca {
4507
4512
  this._setStatus(fe.ERRORED, f), this.notifyAll();
4508
4513
  return;
4509
4514
  }
4510
- if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "resync-table") {
4515
+ if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "resync-table") {
4511
4516
  this._syncTable.onResyncError(e);
4512
4517
  return;
4513
4518
  }
4514
- if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "start-sync") {
4519
+ if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "start-sync") {
4515
4520
  this._syncTable.onStartSyncError(e);
4516
4521
  return;
4517
4522
  }
@@ -4521,7 +4526,7 @@ class Ca {
4521
4526
  }
4522
4527
  notifyQueryOnceError(e, n, r, i) {
4523
4528
  var s;
4524
- const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((u) => u.eventId === r);
4529
+ const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((a) => a.eventId === r);
4525
4530
  o && (o.dfd.reject(i), this._completeQueryOnce(e, n, o.dfd));
4526
4531
  }
4527
4532
  _setAttrs(e) {
@@ -4561,7 +4566,7 @@ class Ca {
4561
4566
  if (!this.querySubs)
4562
4567
  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;
4563
4568
  const s = z(e), o = this._startQuerySub(e, s);
4564
- 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")), Ta), i.promise;
4569
+ 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")), Tu), i.promise;
4565
4570
  }
4566
4571
  _completeQueryOnce(e, n, r) {
4567
4572
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -4592,39 +4597,39 @@ class Ca {
4592
4597
  return K(e, h, p);
4593
4598
  }, s = (c) => {
4594
4599
  const [f, h, p] = c["forward-identity"];
4595
- return ve(e, h, p);
4600
+ return Oe(e, h, p);
4596
4601
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
4597
- let u = !1;
4598
- const a = (c, f) => {
4602
+ let a = !1;
4603
+ const u = (c, f) => {
4599
4604
  const h = [];
4600
4605
  for (const p of c) {
4601
4606
  const [y] = p;
4602
4607
  if (y === "add-attr") {
4603
4608
  const [_, T] = p, w = i(T);
4604
4609
  if (w && T.id !== w.id) {
4605
- o.attrIdMap[T.id] = w.id, u = !0;
4610
+ o.attrIdMap[T.id] = w.id, a = !0;
4606
4611
  continue;
4607
4612
  }
4608
4613
  if (T["value-type"] === "ref") {
4609
4614
  const m = s(T);
4610
4615
  if (m) {
4611
- o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), u = !0;
4616
+ o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), a = !0;
4612
4617
  continue;
4613
4618
  }
4614
4619
  }
4615
4620
  }
4616
4621
  if (r && f && r >= f && y === "add-attr" || y === "update-attr" || y === "delete-attr") {
4617
- u = !0;
4622
+ a = !0;
4618
4623
  continue;
4619
4624
  }
4620
- const b = u ? pu(o, p) : p;
4625
+ const b = a ? pa(o, p) : p;
4621
4626
  h.push(b);
4622
4627
  }
4623
- return u ? h : c;
4628
+ return a ? h : c;
4624
4629
  }, d = /* @__PURE__ */ new Map();
4625
4630
  for (const [c, f] of n.entries())
4626
- d.set(c, Object.assign(Object.assign({}, f), { "tx-steps": a(f["tx-steps"], f["tx-id"]) }));
4627
- return u ? d : n;
4631
+ d.set(c, Object.assign(Object.assign({}, f), { "tx-steps": u(f["tx-steps"], f["tx-id"]) }));
4632
+ return a ? d : n;
4628
4633
  }
4629
4634
  _rewriteMutationsSorted(e, n) {
4630
4635
  return Hr(this._rewriteMutations(e, n).entries());
@@ -4635,19 +4640,19 @@ class Ca {
4635
4640
  var e;
4636
4641
  const n = [
4637
4642
  ...this.pendingMutations.currentValue.values()
4638
- ].flatMap((u) => u["tx-steps"]), r = new Set(n.filter(([u, a]) => u === "delete-attr").map(([u, a]) => a)), i = [];
4639
- for (const [u, a] of n)
4640
- if (u === "add-attr")
4641
- i.push(a);
4642
- else if (u === "update-attr" && a.id && (!((e = this.attrs) === null || e === void 0) && e[a.id])) {
4643
- const d = Object.assign(Object.assign({}, this.attrs[a.id]), a);
4643
+ ].flatMap((a) => a["tx-steps"]), r = new Set(n.filter(([a, u]) => a === "delete-attr").map(([a, u]) => u)), i = [];
4644
+ for (const [a, u] of n)
4645
+ if (a === "add-attr")
4646
+ i.push(u);
4647
+ else if (a === "update-attr" && u.id && (!((e = this.attrs) === null || e === void 0) && e[u.id])) {
4648
+ const d = Object.assign(Object.assign({}, this.attrs[u.id]), u);
4644
4649
  i.push(d);
4645
4650
  }
4646
4651
  const s = [
4647
4652
  ...Object.values(this.attrs || {}),
4648
4653
  ...i
4649
- ].filter((u) => !r.has(u.id));
4650
- return Object.fromEntries(s.map((u) => [u.id, u]));
4654
+ ].filter((a) => !r.has(a.id));
4655
+ return Object.fromEntries(s.map((a) => [a.id, a]));
4651
4656
  }
4652
4657
  /** Runs instaql on a query and a store */
4653
4658
  dataForQuery(e) {
@@ -4656,13 +4661,13 @@ class Ca {
4656
4661
  return { error: n };
4657
4662
  if (!this.querySubs || !this.pendingMutations)
4658
4663
  return;
4659
- const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.pendingMutations.version(), o = this.pendingMutations.currentValue, { q: u, result: a } = i[e] || {};
4660
- if (!a)
4664
+ const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.pendingMutations.version(), o = this.pendingMutations.currentValue, { q: a, result: u } = i[e] || {};
4665
+ if (!u)
4661
4666
  return;
4662
4667
  const d = this._dataForQueryCache[e];
4663
4668
  if (d && r === d.querySubVersion && s === d.pendingMutationsVersion)
4664
4669
  return d.data;
4665
- const { store: c, pageInfo: f, aggregate: h, processedTxId: p } = a, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p), _ = Ri({ store: b, pageInfo: f, aggregate: h }, u);
4670
+ const { store: c, pageInfo: f, aggregate: h, processedTxId: p } = u, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p), _ = Ri({ store: b, pageInfo: f, aggregate: h }, a);
4666
4671
  return this._dataForQueryCache[e] = {
4667
4672
  querySubVersion: r,
4668
4673
  pendingMutationsVersion: s,
@@ -4782,7 +4787,7 @@ class Ca {
4782
4787
  return;
4783
4788
  }
4784
4789
  const e = this._transport;
4785
- this._transport = va({
4790
+ this._transport = vu({
4786
4791
  transportType: this._transportType,
4787
4792
  appId: this.config.appId,
4788
4793
  apiURI: this.config.apiURI,
@@ -4827,8 +4832,8 @@ class Ca {
4827
4832
  typeof navigation.removeEventListener == "function") {
4828
4833
  let i = !1;
4829
4834
  const s = (o) => {
4830
- var u;
4831
- i || (i = !0, navigation.removeEventListener("navigate", s), !o.userInitiated && o.navigationType === "replace" && ((u = o.destination) === null || u === void 0 ? void 0 : u.url) === n && history.replaceState(history.state, "", r));
4835
+ var a;
4836
+ i || (i = !0, navigation.removeEventListener("navigate", s), !o.userInitiated && o.navigationType === "replace" && ((a = o.destination) === null || a === void 0 ? void 0 : a.url) === n && history.replaceState(history.state, "", r));
4832
4837
  };
4833
4838
  navigation.addEventListener("navigate", s);
4834
4839
  }
@@ -4849,20 +4854,20 @@ class Ca {
4849
4854
  const o = s.get("error");
4850
4855
  if (o)
4851
4856
  return this._replaceUrlAfterOAuth(), { error: { message: o } };
4852
- const u = s.get("code");
4853
- if (!u)
4857
+ const a = s.get("code");
4858
+ if (!a)
4854
4859
  return null;
4855
4860
  this._replaceUrlAfterOAuth();
4856
4861
  try {
4857
- const a = yield this._getCurrentUser(), d = (a == null ? void 0 : a.type) === "guest", { user: c } = yield Rr({
4862
+ const u = yield this._getCurrentUser(), d = (u == null ? void 0 : u.type) === "guest", { user: c } = yield Rr({
4858
4863
  apiURI: this.config.apiURI,
4859
4864
  appId: this.config.appId,
4860
- code: u,
4861
- refreshToken: d ? a.refresh_token : void 0
4865
+ code: a,
4866
+ refreshToken: d ? u.refresh_token : void 0
4862
4867
  });
4863
4868
  return this.setCurrentUser(c), null;
4864
- } catch (a) {
4865
- return ((e = a == null ? void 0 : a.body) === null || e === void 0 ? void 0 : e.type) === "record-not-found" && ((r = (n = a == null ? void 0 : a.body) === null || n === void 0 ? void 0 : n.hint) === null || r === void 0 ? void 0 : r["record-type"]) === "app-oauth-code" && (yield this._hasCurrentUser()) ? null : { error: { message: ((i = a == null ? void 0 : a.body) === null || i === void 0 ? void 0 : i.message) || "Error logging in." } };
4869
+ } catch (u) {
4870
+ return ((e = u == null ? void 0 : u.body) === null || e === void 0 ? void 0 : e.type) === "record-not-found" && ((r = (n = u == null ? void 0 : u.body) === null || n === void 0 ? void 0 : n.hint) === null || r === void 0 ? void 0 : r["record-type"]) === "app-oauth-code" && (yield this._hasCurrentUser()) ? null : { error: { message: ((i = u == null ? void 0 : u.body) === null || i === void 0 ? void 0 : i.message) || "Error logging in." } };
4866
4871
  }
4867
4872
  });
4868
4873
  }
@@ -4882,7 +4887,7 @@ class Ca {
4882
4887
  n.isLoading || e(this._currentUserCached);
4883
4888
  let r = !1;
4884
4889
  return this.getCurrentUser().then((i) => {
4885
- r || Tt(i, n) || e(i);
4890
+ r || wt(i, n) || e(i);
4886
4891
  }), () => {
4887
4892
  r = !0, this.authCbs = this.authCbs.filter((i) => i !== e);
4888
4893
  };
@@ -4955,7 +4960,7 @@ class Ca {
4955
4960
  return F(this, void 0, void 0, function* () {
4956
4961
  var n;
4957
4962
  const { user: r } = yield this.getCurrentUser();
4958
- if (!Tt(r, e)) {
4963
+ if (!wt(r, e)) {
4959
4964
  yield this.setCurrentUser(e), this.updateUser(e);
4960
4965
  try {
4961
4966
  (n = this._broadcastChannel) === null || n === void 0 || n.postMessage({ type: "auth" });
@@ -4972,7 +4977,7 @@ class Ca {
4972
4977
  }), r)), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
4973
4978
  }
4974
4979
  sendMagicCode({ email: e }) {
4975
- return Wu({
4980
+ return Wa({
4976
4981
  apiURI: this.config.apiURI,
4977
4982
  appId: this.config.appId,
4978
4983
  email: e
@@ -4981,19 +4986,19 @@ class Ca {
4981
4986
  signInWithMagicCode(e) {
4982
4987
  return F(this, arguments, void 0, function* ({ email: n, code: r }) {
4983
4988
  var i;
4984
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Vu({
4989
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Va({
4985
4990
  apiURI: this.config.apiURI,
4986
4991
  appId: this.config.appId,
4987
4992
  email: n,
4988
4993
  code: r,
4989
4994
  refreshToken: o ? s.user.refresh_token : void 0
4990
4995
  });
4991
- return yield this.changeCurrentUser(u.user), u;
4996
+ return yield this.changeCurrentUser(a.user), a;
4992
4997
  });
4993
4998
  }
4994
4999
  signInWithCustomToken(e) {
4995
5000
  return F(this, void 0, void 0, function* () {
4996
- const n = yield qu({
5001
+ const n = yield qa({
4997
5002
  apiURI: this.config.apiURI,
4998
5003
  appId: this.config.appId,
4999
5004
  refreshToken: e
@@ -5003,7 +5008,7 @@ class Ca {
5003
5008
  }
5004
5009
  signInAsGuest() {
5005
5010
  return F(this, void 0, void 0, function* () {
5006
- const e = yield zu({
5011
+ const e = yield za({
5007
5012
  apiURI: this.config.apiURI,
5008
5013
  appId: this.config.appId
5009
5014
  });
@@ -5019,7 +5024,7 @@ class Ca {
5019
5024
  this._log.info("[auth-invalidate] skipped invalidateToken");
5020
5025
  return;
5021
5026
  }
5022
- Bu({
5027
+ Ba({
5023
5028
  apiURI: this.config.apiURI,
5024
5029
  appId: this.config.appId,
5025
5030
  refreshToken: i
@@ -5054,14 +5059,14 @@ class Ca {
5054
5059
  exchangeCodeForToken(e) {
5055
5060
  return F(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
5056
5061
  var i;
5057
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Rr({
5062
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Rr({
5058
5063
  apiURI: this.config.apiURI,
5059
5064
  appId: this.config.appId,
5060
5065
  code: n,
5061
5066
  codeVerifier: r,
5062
5067
  refreshToken: o ? s.user.refresh_token : void 0
5063
5068
  });
5064
- return yield this.changeCurrentUser(u.user), u;
5069
+ return yield this.changeCurrentUser(a.user), a;
5065
5070
  });
5066
5071
  }
5067
5072
  issuerURI() {
@@ -5077,15 +5082,15 @@ class Ca {
5077
5082
  signInWithIdToken(e) {
5078
5083
  return F(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5079
5084
  var s;
5080
- const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield Ku({
5085
+ const o = yield this.getCurrentUser(), a = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, u = yield Ka({
5081
5086
  apiURI: this.config.apiURI,
5082
5087
  appId: this.config.appId,
5083
5088
  idToken: n,
5084
5089
  clientName: r,
5085
5090
  nonce: i,
5086
- refreshToken: u
5091
+ refreshToken: a
5087
5092
  });
5088
- return yield this.changeCurrentUser(a.user), a;
5093
+ return yield this.changeCurrentUser(u.user), u;
5089
5094
  });
5090
5095
  }
5091
5096
  // --------
@@ -5118,7 +5123,7 @@ class Ca {
5118
5123
  // TODO: look into typing again
5119
5124
  getPresence(e, n, r = {}) {
5120
5125
  const i = this._rooms[n], s = this._presence[n];
5121
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Zu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5126
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Za(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5122
5127
  }
5123
5128
  // TODO: look into typing again
5124
5129
  publishPresence(e, n, r) {
@@ -5156,8 +5161,8 @@ class Ca {
5156
5161
  r.initialPresence || r.initialData
5157
5162
  ), o = Object.assign(Object.assign({}, r), { roomId: n, cb: i, prev: null });
5158
5163
  return this._presence[n] = this._presence[n] || {}, this._presence[n].handlers = this._presence[n].handlers || [], this._presence[n].handlers.push(o), this._notifyPresenceSub(n, o), () => {
5159
- var u, a, d;
5160
- this._presence[n].handlers = (d = (a = (u = this._presence[n]) === null || u === void 0 ? void 0 : u.handlers) === null || a === void 0 ? void 0 : a.filter((c) => c !== o)) !== null && d !== void 0 ? d : [], s();
5164
+ var a, u, d;
5165
+ this._presence[n].handlers = (d = (u = (a = this._presence[n]) === null || a === void 0 ? void 0 : a.handlers) === null || u === void 0 ? void 0 : u.filter((c) => c !== o)) !== null && d !== void 0 ? d : [], s();
5161
5166
  };
5162
5167
  }
5163
5168
  _notifyPresenceSubs(e) {
@@ -5168,14 +5173,14 @@ class Ca {
5168
5173
  }
5169
5174
  _notifyPresenceSub(e, n) {
5170
5175
  const r = this.getPresence("", e, n);
5171
- r && (n.prev && !Xu(r, n.prev) || (n.prev = r, n.cb(r)));
5176
+ r && (n.prev && !Xa(r, n.prev) || (n.prev = r, n.cb(r)));
5172
5177
  }
5173
5178
  _patchPresencePeers(e, n) {
5174
5179
  var r, i, s;
5175
5180
  const o = ((i = (r = this._presence[e]) === null || r === void 0 ? void 0 : r.result) === null || i === void 0 ? void 0 : i.peers) || {};
5176
- let u = Object.fromEntries(Object.entries(o).map(([d, c]) => [d, { data: c }]));
5181
+ let a = Object.fromEntries(Object.entries(o).map(([d, c]) => [d, { data: c }]));
5177
5182
  (s = this._presence[e]) === null || s === void 0 || s.result;
5178
- const a = un(u, (d) => {
5183
+ const u = an(a, (d) => {
5179
5184
  for (let [c, f, h] of n)
5180
5185
  switch (f) {
5181
5186
  case "+":
@@ -5190,13 +5195,13 @@ class Ca {
5190
5195
  }
5191
5196
  delete d[this._sessionId];
5192
5197
  });
5193
- this._setPresencePeers(e, a);
5198
+ this._setPresencePeers(e, u);
5194
5199
  }
5195
5200
  _setPresencePeers(e, n) {
5196
5201
  const r = Object.assign({}, n);
5197
5202
  delete r[this._sessionId];
5198
5203
  const i = Object.fromEntries(Object.entries(r).map(([s, o]) => [s, o.data]));
5199
- this._presence = un(this._presence, (s) => {
5204
+ this._presence = an(this._presence, (s) => {
5200
5205
  Sr(s, [e, "result", "peers"], i);
5201
5206
  });
5202
5207
  }
@@ -5230,10 +5235,10 @@ class Ca {
5230
5235
  }
5231
5236
  _notifyBroadcastSubs(e, n, r) {
5232
5237
  var i, s, o;
5233
- (o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((u) => {
5234
- var a, d, c, f, h, p;
5235
- const y = (a = r.data) === null || a === void 0 ? void 0 : a.data, b = r.data["peer-id"] === this._sessionId ? (c = (d = this._presence[e]) === null || d === void 0 ? void 0 : d.result) === null || c === void 0 ? void 0 : c.user : (p = (h = (f = this._presence[e]) === null || f === void 0 ? void 0 : f.result) === null || h === void 0 ? void 0 : h.peers) === null || p === void 0 ? void 0 : p[r.data["peer-id"]];
5236
- return u(y, b);
5238
+ (o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((a) => {
5239
+ var u, d, c, f, h, p;
5240
+ const y = (u = r.data) === null || u === void 0 ? void 0 : u.data, b = r.data["peer-id"] === this._sessionId ? (c = (d = this._presence[e]) === null || d === void 0 ? void 0 : d.result) === null || c === void 0 ? void 0 : c.user : (p = (h = (f = this._presence[e]) === null || f === void 0 ? void 0 : f.result) === null || h === void 0 ? void 0 : h.peers) === null || p === void 0 ? void 0 : p[r.data["peer-id"]];
5241
+ return a(y, b);
5237
5242
  });
5238
5243
  }
5239
5244
  // --------
@@ -5242,14 +5247,14 @@ class Ca {
5242
5247
  return F(this, void 0, void 0, function* () {
5243
5248
  var i;
5244
5249
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5245
- return Gu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5250
+ return Ga(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5246
5251
  });
5247
5252
  }
5248
5253
  deleteFile(e) {
5249
5254
  return F(this, void 0, void 0, function* () {
5250
5255
  var n;
5251
5256
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5252
- return yield Qu({
5257
+ return yield Qa({
5253
5258
  apiURI: this.config.apiURI,
5254
5259
  appId: this.config.appId,
5255
5260
  path: e,
@@ -5262,20 +5267,20 @@ class Ca {
5262
5267
  upload(e, n) {
5263
5268
  return F(this, void 0, void 0, function* () {
5264
5269
  var r;
5265
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield Hu({
5270
+ 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 Ha({
5266
5271
  apiURI: this.config.apiURI,
5267
5272
  appId: this.config.appId,
5268
5273
  fileName: o,
5269
5274
  refreshToken: s
5270
5275
  });
5271
- return yield Yu(u, n);
5276
+ return yield Ya(a, n);
5272
5277
  });
5273
5278
  }
5274
5279
  getDownloadUrl(e) {
5275
5280
  return F(this, void 0, void 0, function* () {
5276
5281
  var n;
5277
5282
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5278
- return yield Ju({
5283
+ return yield Ja({
5279
5284
  apiURI: this.config.apiURI,
5280
5285
  appId: this.config.appId,
5281
5286
  path: e,
@@ -5284,8 +5289,8 @@ class Ca {
5284
5289
  });
5285
5290
  }
5286
5291
  }
5287
- function ka(t, e) {
5288
- return new Rt(
5292
+ function ku(t, e) {
5293
+ return new $t(
5289
5294
  Qi(t, e),
5290
5295
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
5291
5296
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
@@ -5296,46 +5301,46 @@ function ka(t, e) {
5296
5301
  void 0
5297
5302
  );
5298
5303
  }
5299
- function ja(t) {
5300
- return new Mt(t, {});
5304
+ function ju(t) {
5305
+ return new Rt(t, {});
5301
5306
  }
5302
- function Ia() {
5307
+ function Iu() {
5303
5308
  return new H("string", !0, !1);
5304
5309
  }
5305
- function Pa() {
5310
+ function Pu() {
5306
5311
  return new H("number", !0, !1);
5307
5312
  }
5308
- function Ma() {
5313
+ function Mu() {
5309
5314
  return new H("boolean", !0, !1);
5310
5315
  }
5311
- function Ra() {
5316
+ function Ru() {
5312
5317
  return new H("date", !0, !1);
5313
5318
  }
5314
- function $a() {
5319
+ function $u() {
5315
5320
  return new H("json", !0, !1);
5316
5321
  }
5317
- function xa() {
5322
+ function xu() {
5318
5323
  return new H("json", !0, !1);
5319
5324
  }
5320
5325
  function Qi(t, e) {
5321
5326
  var n, r, i, s;
5322
5327
  const o = { fwd: {}, rev: {} };
5323
- for (const a of Object.values(e))
5324
- (n = o.fwd)[r = a.forward.on] || (n[r] = {}), (i = o.rev)[s = a.reverse.on] || (i[s] = {}), o.fwd[a.forward.on][a.forward.label] = {
5325
- entityName: a.reverse.on,
5326
- cardinality: a.forward.has
5327
- }, o.rev[a.reverse.on][a.reverse.label] = {
5328
- entityName: a.forward.on,
5329
- cardinality: a.reverse.has
5328
+ for (const u of Object.values(e))
5329
+ (n = o.fwd)[r = u.forward.on] || (n[r] = {}), (i = o.rev)[s = u.reverse.on] || (i[s] = {}), o.fwd[u.forward.on][u.forward.label] = {
5330
+ entityName: u.reverse.on,
5331
+ cardinality: u.forward.has
5332
+ }, o.rev[u.reverse.on][u.reverse.label] = {
5333
+ entityName: u.forward.on,
5334
+ cardinality: u.reverse.has
5330
5335
  };
5331
- return Object.fromEntries(Object.entries(t).map(([a, d]) => [
5332
- a,
5333
- new Mt(d.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
5336
+ return Object.fromEntries(Object.entries(t).map(([u, d]) => [
5337
+ u,
5338
+ new Rt(d.attrs, Object.assign(Object.assign({}, o.fwd[u]), o.rev[u]))
5334
5339
  ]));
5335
5340
  }
5336
- function Da({ entities: t, links: e, rooms: n }) {
5341
+ function Du({ entities: t, links: e, rooms: n }) {
5337
5342
  const r = e ?? {}, i = n ?? {};
5338
- return new Rt(
5343
+ return new $t(
5339
5344
  Qi(t, r),
5340
5345
  // (XXX): LinksDef<any> stems from TypeScript's inability to reconcile the
5341
5346
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
@@ -5348,46 +5353,46 @@ function Da({ entities: t, links: e, rooms: n }) {
5348
5353
  }
5349
5354
  const Cc = {
5350
5355
  // constructs
5351
- graph: ka,
5352
- schema: Da,
5353
- entity: ja,
5356
+ graph: ku,
5357
+ schema: Du,
5358
+ entity: ju,
5354
5359
  // value types
5355
- string: Ia,
5356
- number: Pa,
5357
- boolean: Ma,
5358
- date: Ra,
5359
- json: $a,
5360
- any: xa
5360
+ string: Iu,
5361
+ number: Pu,
5362
+ boolean: Mu,
5363
+ date: Ru,
5364
+ json: $u,
5365
+ any: xu
5361
5366
  };
5362
- let bt;
5363
- function Ua(t, e) {
5364
- bt == null || bt.dispose();
5365
- const n = qa(e), r = Na(e, u), i = Fa(La(t));
5367
+ let _t;
5368
+ function Uu(t, e) {
5369
+ _t == null || _t.dispose();
5370
+ const n = qu(e), r = Nu(e, a), i = Fu(Lu(t));
5366
5371
  function s(c) {
5367
5372
  var f;
5368
- c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
5373
+ c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && a();
5369
5374
  }
5370
5375
  function o(c) {
5371
5376
  const f = c.shiftKey && c.ctrlKey && c.key === "0", h = c.key === "Escape" || c.key === "Esc";
5372
- (f || h && n.isVisible()) && u();
5377
+ (f || h && n.isVisible()) && a();
5373
5378
  }
5374
- function u() {
5379
+ function a() {
5375
5380
  n.isVisible() ? n.element.style.display = "none" : (n.element.style.display = "block", n.element.contains(i.element) || n.element.appendChild(i.element));
5376
5381
  }
5377
- function a() {
5382
+ function u() {
5378
5383
  n.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", s);
5379
5384
  }
5380
5385
  function d() {
5381
- document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), bt = {
5382
- dispose: a
5386
+ document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), _t = {
5387
+ dispose: u
5383
5388
  };
5384
5389
  }
5385
5390
  return d();
5386
5391
  }
5387
- function La(t) {
5392
+ function Lu(t) {
5388
5393
  return `${zn || Ni ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
5389
5394
  }
5390
- function Fa(t) {
5395
+ function Fu(t) {
5391
5396
  const e = document.createElement("iframe");
5392
5397
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
5393
5398
  width: "100%",
@@ -5396,7 +5401,7 @@ function Fa(t) {
5396
5401
  border: "none"
5397
5402
  }), { element: e };
5398
5403
  }
5399
- function Na(t, e) {
5404
+ function Nu(t, e) {
5400
5405
  const n = `
5401
5406
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
5402
5407
  <rect width="512" height="512" fill="black"/>
@@ -5406,7 +5411,7 @@ function Na(t, e) {
5406
5411
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
5407
5412
  // pos
5408
5413
  position: "fixed"
5409
- }, Wa(t.position)), {
5414
+ }, Wu(t.position)), {
5410
5415
  height: "32px",
5411
5416
  width: "32px",
5412
5417
  // layout
@@ -5421,7 +5426,7 @@ function Na(t, e) {
5421
5426
  cursor: "pointer"
5422
5427
  })), r.addEventListener("click", e), { element: r };
5423
5428
  }
5424
- function Wa(t) {
5429
+ function Wu(t) {
5425
5430
  switch (t) {
5426
5431
  case "bottom-left":
5427
5432
  return { bottom: "24px", left: "24px" };
@@ -5433,7 +5438,7 @@ function Wa(t) {
5433
5438
  return { top: "24px", left: "24px" };
5434
5439
  }
5435
5440
  }
5436
- function Va(t) {
5441
+ function Vu(t) {
5437
5442
  switch (t) {
5438
5443
  case "bottom-left":
5439
5444
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -5445,23 +5450,23 @@ function Va(t) {
5445
5450
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
5446
5451
  }
5447
5452
  }
5448
- function qa(t) {
5453
+ function qu(t) {
5449
5454
  const e = document.createElement("div");
5450
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, Va(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";
5455
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, Vu(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";
5451
5456
  function n() {
5452
5457
  return e.style.display !== "none";
5453
5458
  }
5454
5459
  return { element: e, isVisible: n };
5455
5460
  }
5456
- const za = {
5461
+ const zu = {
5457
5462
  apiURI: "https://api.instantdb.com",
5458
5463
  websocketURI: "wss://api.instantdb.com/runtime/session"
5459
5464
  };
5460
- function Ka() {
5465
+ function Ku() {
5461
5466
  var t;
5462
5467
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
5463
5468
  }
5464
- function Ba() {
5469
+ function Bu() {
5465
5470
  var t;
5466
5471
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
5467
5472
  }
@@ -5469,23 +5474,23 @@ function Tn(t) {
5469
5474
  const e = t.__adminToken;
5470
5475
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
5471
5476
  }
5472
- const wn = Ba(), Jt = Ka();
5473
- class Ga {
5477
+ const wn = Bu(), Jt = Ku();
5478
+ class Gu {
5474
5479
  constructor(e) {
5475
5480
  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);
5476
5481
  }
5477
5482
  }
5478
- class Qa {
5483
+ class Qu {
5479
5484
  constructor(e) {
5480
5485
  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);
5481
5486
  }
5482
5487
  }
5483
- function Ha(t) {
5488
+ function Hu(t) {
5484
5489
  return JSON.parse(JSON.stringify(t));
5485
5490
  }
5486
- class Ya {
5491
+ class Yu {
5487
5492
  constructor(e) {
5488
- this.tx = qn(), this._reactor = e, this.auth = new Ga(this._reactor), this.storage = new Qa(this._reactor);
5493
+ this.tx = qn(), this._reactor = e, this.auth = new Gu(this._reactor), this.storage = new Qu(this._reactor);
5489
5494
  }
5490
5495
  /**
5491
5496
  * Use this to write data! You can create, update, delete, and link objects
@@ -5656,21 +5661,21 @@ function Yr(t) {
5656
5661
  const e = z(t);
5657
5662
  return Jt.set(t, e), e;
5658
5663
  }
5659
- function Ja(t, e) {
5664
+ function Ju(t, e) {
5660
5665
  return Yr(t._reactor.config.schema) !== Yr(e);
5661
5666
  }
5662
- function Za(t, e, n, r, i) {
5667
+ function Zu(t, e, n, r, i) {
5663
5668
  const s = wn[Tn(t)];
5664
5669
  if (s)
5665
- return Ja(s, t.schema) && s._reactor.updateSchema(t.schema), s;
5666
- const o = new Ca(Object.assign(Object.assign(Object.assign({}, za), t), { cardinalityInference: !!t.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Kn }), i), u = new Ya(o);
5667
- return wn[Tn(t)] = u, Xa(t.appId, t.devtool), u;
5670
+ return Ju(s, t.schema) && s._reactor.updateSchema(t.schema), s;
5671
+ const o = new Cu(Object.assign(Object.assign(Object.assign({}, zu), t), { cardinalityInference: !!t.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Kn }), i), a = new Yu(o);
5672
+ return wn[Tn(t)] = a, Xu(t.appId, t.devtool), a;
5668
5673
  }
5669
- function Xa(t, e) {
5674
+ function Xu(t, e) {
5670
5675
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
5671
5676
  return;
5672
5677
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
5673
- n.allowedHosts.includes(window.location.hostname) && Ua(t, n);
5678
+ n.allowedHosts.includes(window.location.hostname) && Uu(t, n);
5674
5679
  }
5675
5680
  var mn = { exports: {} }, Ge = {};
5676
5681
  /**
@@ -5687,12 +5692,12 @@ function ec() {
5687
5692
  if (Jr) return Ge;
5688
5693
  Jr = 1;
5689
5694
  var t = si, 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 };
5690
- function o(u, a, d) {
5695
+ function o(a, u, d) {
5691
5696
  var c, f = {}, h = null, p = null;
5692
- d !== void 0 && (h = "" + d), a.key !== void 0 && (h = "" + a.key), a.ref !== void 0 && (p = a.ref);
5693
- for (c in a) r.call(a, c) && !s.hasOwnProperty(c) && (f[c] = a[c]);
5694
- if (u && u.defaultProps) for (c in a = u.defaultProps, a) f[c] === void 0 && (f[c] = a[c]);
5695
- return { $$typeof: e, type: u, key: h, ref: p, props: f, _owner: i.current };
5697
+ d !== void 0 && (h = "" + d), u.key !== void 0 && (h = "" + u.key), u.ref !== void 0 && (p = u.ref);
5698
+ for (c in u) r.call(u, c) && !s.hasOwnProperty(c) && (f[c] = u[c]);
5699
+ if (a && a.defaultProps) for (c in u = a.defaultProps, u) f[c] === void 0 && (f[c] = u[c]);
5700
+ return { $$typeof: e, type: a, key: h, ref: p, props: f, _owner: i.current };
5696
5701
  }
5697
5702
  return Ge.Fragment = n, Ge.jsx = o, Ge.jsxs = o, Ge;
5698
5703
  }
@@ -5711,7 +5716,7 @@ function tc() {
5711
5716
  * LICENSE file in the root directory of this source tree.
5712
5717
  */
5713
5718
  return t.NODE_ENV !== "production" && function() {
5714
- var e = si, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
5719
+ var e = si, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
5715
5720
  function T(l) {
5716
5721
  if (l === null || typeof l != "object")
5717
5722
  return null;
@@ -5736,16 +5741,16 @@ function tc() {
5736
5741
  P.unshift("Warning: " + g), Function.prototype.apply.call(console[l], console, P);
5737
5742
  }
5738
5743
  }
5739
- var v = !1, M = !1, U = !1, B = !1, qe = !1, at;
5740
- at = Symbol.for("react.module.reference");
5741
- function $t(l) {
5742
- return !!(typeof l == "string" || typeof l == "function" || l === i || l === o || qe || l === s || l === c || l === f || B || l === y || v || M || U || typeof l == "object" && l !== null && (l.$$typeof === p || l.$$typeof === h || l.$$typeof === u || l.$$typeof === a || l.$$typeof === d || // This needs to include all possible module reference object
5744
+ var v = !1, M = !1, U = !1, B = !1, qe = !1, ut;
5745
+ ut = Symbol.for("react.module.reference");
5746
+ function xt(l) {
5747
+ return !!(typeof l == "string" || typeof l == "function" || l === i || l === o || qe || l === s || l === c || l === f || B || l === y || v || M || U || typeof l == "object" && l !== null && (l.$$typeof === p || l.$$typeof === h || l.$$typeof === a || l.$$typeof === u || l.$$typeof === d || // This needs to include all possible module reference object
5743
5748
  // types supported by any Flight configuration anywhere since
5744
5749
  // we don't know which Flight build this will end up being used
5745
5750
  // with.
5746
- l.$$typeof === at || l.getModuleId !== void 0));
5751
+ l.$$typeof === ut || l.getModuleId !== void 0));
5747
5752
  }
5748
- function xt(l, g, S) {
5753
+ function Dt(l, g, S) {
5749
5754
  var O = l.displayName;
5750
5755
  if (O)
5751
5756
  return O;
@@ -5778,14 +5783,14 @@ function tc() {
5778
5783
  }
5779
5784
  if (typeof l == "object")
5780
5785
  switch (l.$$typeof) {
5781
- case a:
5786
+ case u:
5782
5787
  var g = l;
5783
5788
  return ct(g) + ".Consumer";
5784
- case u:
5789
+ case a:
5785
5790
  var S = l;
5786
5791
  return ct(S._context) + ".Provider";
5787
5792
  case d:
5788
- return xt(l, l.render, "ForwardRef");
5793
+ return Dt(l, l.render, "ForwardRef");
5789
5794
  case h:
5790
5795
  var O = l.displayName || null;
5791
5796
  return O !== null ? O : ce(l.type) || "Memo";
@@ -5862,27 +5867,27 @@ function tc() {
5862
5867
  ze < 0 && m("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
5863
5868
  }
5864
5869
  }
5865
- var Dt = w.ReactCurrentDispatcher, Ut;
5870
+ var Ut = w.ReactCurrentDispatcher, Lt;
5866
5871
  function dt(l, g, S) {
5867
5872
  {
5868
- if (Ut === void 0)
5873
+ if (Lt === void 0)
5869
5874
  try {
5870
5875
  throw Error();
5871
5876
  } catch (I) {
5872
5877
  var O = I.stack.trim().match(/\n( *(at )?)/);
5873
- Ut = O && O[1] || "";
5878
+ Lt = O && O[1] || "";
5874
5879
  }
5875
5880
  return `
5876
- ` + Ut + l;
5881
+ ` + Lt + l;
5877
5882
  }
5878
5883
  }
5879
- var Lt = !1, ft;
5884
+ var Ft = !1, ft;
5880
5885
  {
5881
5886
  var Zi = typeof WeakMap == "function" ? WeakMap : Map;
5882
5887
  ft = new Zi();
5883
5888
  }
5884
5889
  function nr(l, g) {
5885
- if (!l || Lt)
5890
+ if (!l || Ft)
5886
5891
  return "";
5887
5892
  {
5888
5893
  var S = ft.get(l);
@@ -5890,11 +5895,11 @@ function tc() {
5890
5895
  return S;
5891
5896
  }
5892
5897
  var O;
5893
- Lt = !0;
5898
+ Ft = !0;
5894
5899
  var I = Error.prepareStackTrace;
5895
5900
  Error.prepareStackTrace = void 0;
5896
5901
  var P;
5897
- P = Dt.current, Dt.current = null, Yi();
5902
+ P = Ut.current, Ut.current = null, Yi();
5898
5903
  try {
5899
5904
  if (g) {
5900
5905
  var k = function() {
@@ -5947,9 +5952,9 @@ function tc() {
5947
5952
  }
5948
5953
  }
5949
5954
  } finally {
5950
- Lt = !1, Dt.current = P, Ji(), Error.prepareStackTrace = I;
5955
+ Ft = !1, Ut.current = P, Ji(), Error.prepareStackTrace = I;
5951
5956
  }
5952
- var ke = l ? l.displayName || l.name : "", Te = ke ? dt(ke) : "";
5957
+ var je = l ? l.displayName || l.name : "", Te = je ? dt(je) : "";
5953
5958
  return typeof l == "function" && ft.set(l, Te), Te;
5954
5959
  }
5955
5960
  function Xi(l, g, S) {
@@ -6016,7 +6021,7 @@ function tc() {
6016
6021
  }
6017
6022
  }
6018
6023
  var ns = Array.isArray;
6019
- function Ft(l) {
6024
+ function Nt(l) {
6020
6025
  return ns(l);
6021
6026
  }
6022
6027
  function rs(l) {
@@ -6039,12 +6044,12 @@ function tc() {
6039
6044
  if (is(l))
6040
6045
  return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", rs(l)), sr(l);
6041
6046
  }
6042
- var ur = w.ReactCurrentOwner, ss = {
6047
+ var ar = w.ReactCurrentOwner, ss = {
6043
6048
  key: !0,
6044
6049
  ref: !0,
6045
6050
  __self: !0,
6046
6051
  __source: !0
6047
- }, ar, cr;
6052
+ }, ur, cr;
6048
6053
  function os(l) {
6049
6054
  if (Ke.call(l, "ref")) {
6050
6055
  var g = Object.getOwnPropertyDescriptor(l, "ref").get;
@@ -6053,7 +6058,7 @@ function tc() {
6053
6058
  }
6054
6059
  return l.ref !== void 0;
6055
6060
  }
6056
- function us(l) {
6061
+ function as(l) {
6057
6062
  if (Ke.call(l, "key")) {
6058
6063
  var g = Object.getOwnPropertyDescriptor(l, "key").get;
6059
6064
  if (g && g.isReactWarning)
@@ -6061,13 +6066,13 @@ function tc() {
6061
6066
  }
6062
6067
  return l.key !== void 0;
6063
6068
  }
6064
- function as(l, g) {
6065
- typeof l.ref == "string" && ur.current;
6069
+ function us(l, g) {
6070
+ typeof l.ref == "string" && ar.current;
6066
6071
  }
6067
6072
  function cs(l, g) {
6068
6073
  {
6069
6074
  var S = function() {
6070
- ar || (ar = !0, m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", g));
6075
+ ur || (ur = !0, m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", g));
6071
6076
  };
6072
6077
  S.isReactWarning = !0, Object.defineProperty(l, "key", {
6073
6078
  get: S,
@@ -6118,7 +6123,7 @@ function tc() {
6118
6123
  function ls(l, g, S, O, I) {
6119
6124
  {
6120
6125
  var P, k = {}, A = null, G = null;
6121
- S !== void 0 && (or(S), A = "" + S), us(g) && (or(g.key), A = "" + g.key), os(g) && (G = g.ref, as(g, I));
6126
+ S !== void 0 && (or(S), A = "" + S), as(g) && (or(g.key), A = "" + g.key), os(g) && (G = g.ref, us(g, I));
6122
6127
  for (P in g)
6123
6128
  Ke.call(g, P) && !ss.hasOwnProperty(P) && (k[P] = g[P]);
6124
6129
  if (l && l.defaultProps) {
@@ -6130,26 +6135,26 @@ function tc() {
6130
6135
  var L = typeof l == "function" ? l.displayName || l.name || "Unknown" : l;
6131
6136
  A && cs(k, L), G && ds(k, L);
6132
6137
  }
6133
- return fs(l, A, G, I, O, ur.current, k);
6138
+ return fs(l, A, G, I, O, ar.current, k);
6134
6139
  }
6135
6140
  }
6136
- var Nt = w.ReactCurrentOwner, dr = w.ReactDebugCurrentFrame;
6137
- function Ce(l) {
6141
+ var Wt = w.ReactCurrentOwner, dr = w.ReactDebugCurrentFrame;
6142
+ function ke(l) {
6138
6143
  if (l) {
6139
6144
  var g = l._owner, S = lt(l.type, l._source, g ? g.type : null);
6140
6145
  dr.setExtraStackFrame(S);
6141
6146
  } else
6142
6147
  dr.setExtraStackFrame(null);
6143
6148
  }
6144
- var Wt;
6145
- Wt = !1;
6146
- function Vt(l) {
6149
+ var Vt;
6150
+ Vt = !1;
6151
+ function qt(l) {
6147
6152
  return typeof l == "object" && l !== null && l.$$typeof === n;
6148
6153
  }
6149
6154
  function fr() {
6150
6155
  {
6151
- if (Nt.current) {
6152
- var l = ce(Nt.current.type);
6156
+ if (Wt.current) {
6157
+ var l = ce(Wt.current.type);
6153
6158
  if (l)
6154
6159
  return `
6155
6160
 
@@ -6184,25 +6189,25 @@ Check the top-level render call using <` + S + ">.");
6184
6189
  return;
6185
6190
  lr[S] = !0;
6186
6191
  var O = "";
6187
- l && l._owner && l._owner !== Nt.current && (O = " It was passed a child from " + ce(l._owner.type) + "."), Ce(l), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', S, O), Ce(null);
6192
+ l && l._owner && l._owner !== Wt.current && (O = " It was passed a child from " + ce(l._owner.type) + "."), ke(l), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', S, O), ke(null);
6188
6193
  }
6189
6194
  }
6190
6195
  function pr(l, g) {
6191
6196
  {
6192
6197
  if (typeof l != "object")
6193
6198
  return;
6194
- if (Ft(l))
6199
+ if (Nt(l))
6195
6200
  for (var S = 0; S < l.length; S++) {
6196
6201
  var O = l[S];
6197
- Vt(O) && hr(O, g);
6202
+ qt(O) && hr(O, g);
6198
6203
  }
6199
- else if (Vt(l))
6204
+ else if (qt(l))
6200
6205
  l._store && (l._store.validated = !0);
6201
6206
  else if (l) {
6202
6207
  var I = T(l);
6203
6208
  if (typeof I == "function" && I !== l.entries)
6204
6209
  for (var P = I.call(l), k; !(k = P.next()).done; )
6205
- Vt(k.value) && hr(k.value, g);
6210
+ qt(k.value) && hr(k.value, g);
6206
6211
  }
6207
6212
  }
6208
6213
  }
@@ -6223,8 +6228,8 @@ Check the top-level render call using <` + S + ">.");
6223
6228
  if (S) {
6224
6229
  var O = ce(g);
6225
6230
  ts(S, l.props, "prop", O, l);
6226
- } else if (g.PropTypes !== void 0 && !Wt) {
6227
- Wt = !0;
6231
+ } else if (g.PropTypes !== void 0 && !Vt) {
6232
+ Vt = !0;
6228
6233
  var I = ce(g);
6229
6234
  m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", I || "Unknown");
6230
6235
  }
@@ -6236,24 +6241,24 @@ Check the top-level render call using <` + S + ">.");
6236
6241
  for (var g = Object.keys(l.props), S = 0; S < g.length; S++) {
6237
6242
  var O = g[S];
6238
6243
  if (O !== "children" && O !== "key") {
6239
- Ce(l), m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", O), Ce(null);
6244
+ ke(l), m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", O), ke(null);
6240
6245
  break;
6241
6246
  }
6242
6247
  }
6243
- l.ref !== null && (Ce(l), m("Invalid attribute `ref` supplied to `React.Fragment`."), Ce(null));
6248
+ l.ref !== null && (ke(l), m("Invalid attribute `ref` supplied to `React.Fragment`."), ke(null));
6244
6249
  }
6245
6250
  }
6246
6251
  var yr = {};
6247
6252
  function br(l, g, S, O, I, P) {
6248
6253
  {
6249
- var k = $t(l);
6254
+ var k = xt(l);
6250
6255
  if (!k) {
6251
6256
  var A = "";
6252
6257
  (l === void 0 || typeof l == "object" && l !== null && Object.keys(l).length === 0) && (A += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
6253
6258
  var G = hs();
6254
6259
  G ? A += G : A += fr();
6255
6260
  var x;
6256
- l === null ? x = "null" : Ft(l) ? x = "array" : l !== void 0 && l.$$typeof === n ? (x = "<" + (ce(l.type) || "Unknown") + " />", A = " Did you accidentally export a JSX literal instead of a component?") : x = typeof l, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", x, A);
6261
+ l === null ? x = "null" : Nt(l) ? x = "array" : l !== void 0 && l.$$typeof === n ? (x = "<" + (ce(l.type) || "Unknown") + " />", A = " Did you accidentally export a JSX literal instead of a component?") : x = typeof l, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", x, A);
6257
6262
  }
6258
6263
  var L = ls(l, g, S, I, P);
6259
6264
  if (L == null)
@@ -6262,9 +6267,9 @@ Check the top-level render call using <` + S + ">.");
6262
6267
  var re = g.children;
6263
6268
  if (re !== void 0)
6264
6269
  if (O)
6265
- if (Ft(re)) {
6266
- for (var ke = 0; ke < re.length; ke++)
6267
- pr(re[ke], l);
6270
+ if (Nt(re)) {
6271
+ for (var je = 0; je < re.length; je++)
6272
+ pr(re[je], l);
6268
6273
  Object.freeze && Object.freeze(re);
6269
6274
  } else
6270
6275
  m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
@@ -6274,15 +6279,15 @@ Check the top-level render call using <` + S + ">.");
6274
6279
  if (Ke.call(g, "key")) {
6275
6280
  var Te = ce(l), Y = Object.keys(g).filter(function(Ss) {
6276
6281
  return Ss !== "key";
6277
- }), qt = Y.length > 0 ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}";
6278
- if (!yr[Te + qt]) {
6282
+ }), zt = Y.length > 0 ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}";
6283
+ if (!yr[Te + zt]) {
6279
6284
  var ms = Y.length > 0 ? "{" + Y.join(": ..., ") + ": ...}" : "{}";
6280
6285
  m(`A props object containing a "key" prop is being spread into JSX:
6281
6286
  let props = %s;
6282
6287
  <%s {...props} />
6283
6288
  React keys must be passed directly to JSX without using spread:
6284
6289
  let props = %s;
6285
- <%s key={someKey} {...props} />`, qt, Te, ms, Te), yr[Te + qt] = !0;
6290
+ <%s key={someKey} {...props} />`, zt, Te, ms, Te), yr[Te + zt] = !0;
6286
6291
  }
6287
6292
  }
6288
6293
  return l === i ? bs(L) : ys(L), L;
@@ -6312,9 +6317,9 @@ function Xr(t) {
6312
6317
  }
6313
6318
  function ic(t, e, n) {
6314
6319
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6315
- const r = e ? Ha(e) : null, i = z(r), s = vt(Xr(t._reactor.getPreviousResult(r))), o = be(
6316
- (a) => (s.current = Xr(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
6317
- s.current = Object.assign({ isLoading: !c, data: void 0, pageInfo: void 0, error: void 0 }, c), a();
6320
+ const r = e ? Hu(e) : null, i = z(r), s = Ot(Xr(t._reactor.getPreviousResult(r))), o = be(
6321
+ (u) => (s.current = Xr(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
6322
+ s.current = Object.assign({ isLoading: !c, data: void 0, pageInfo: void 0, error: void 0 }, c), u();
6318
6323
  }) : () => {
6319
6324
  }),
6320
6325
  // Build a new subscribe function if the query changes
@@ -6323,8 +6328,8 @@ function ic(t, e, n) {
6323
6328
  return { state: Xt(o, () => s.current, () => rc), query: r };
6324
6329
  }
6325
6330
  function sc() {
6326
- const t = vt(null);
6327
- Oe(() => {
6331
+ const t = Ot(null);
6332
+ Ee(() => {
6328
6333
  n();
6329
6334
  }, []);
6330
6335
  function e(r, i) {
@@ -6336,13 +6341,13 @@ function sc() {
6336
6341
  return { set: e, clear: n };
6337
6342
  }
6338
6343
  const oc = 1e3;
6339
- function uc(t, e, n) {
6340
- Oe(() => t.core._reactor.subscribeTopic(t.id, e, (i, s) => {
6344
+ function ac(t, e, n) {
6345
+ Ee(() => t.core._reactor.subscribeTopic(t.id, e, (i, s) => {
6341
6346
  n(i, s);
6342
6347
  }), [t.id, e]);
6343
6348
  }
6344
- function ac(t, e) {
6345
- return Oe(() => t.core._reactor.joinRoom(t.id), [t.id]), be((r) => {
6349
+ function uc(t, e) {
6350
+ return Ee(() => t.core._reactor.joinRoom(t.id), [t.id]), be((r) => {
6346
6351
  t.core._reactor.publishTopic({
6347
6352
  roomType: t.type,
6348
6353
  roomId: t.id,
@@ -6354,25 +6359,25 @@ function ac(t, e) {
6354
6359
  function cc(t, e = {}) {
6355
6360
  var n, r;
6356
6361
  const [i, s] = oi(() => {
6357
- var a;
6358
- return (a = t.core._reactor.getPresence(t.type, t.id, e)) !== null && a !== void 0 ? a : {
6362
+ var u;
6363
+ return (u = t.core._reactor.getPresence(t.type, t.id, e)) !== null && u !== void 0 ? u : {
6359
6364
  peers: {},
6360
6365
  isLoading: !0
6361
6366
  };
6362
6367
  });
6363
- Oe(() => t.core._reactor.subscribePresence(t.type, t.id, e, (d) => {
6368
+ Ee(() => t.core._reactor.subscribePresence(t.type, t.id, e, (d) => {
6364
6369
  s(d);
6365
6370
  }), [t.id, e.user, (n = e.peers) === null || n === void 0 ? void 0 : n.join(), (r = e.keys) === null || r === void 0 ? void 0 : r.join()]);
6366
- const o = be((a) => {
6367
- t.core._reactor.publishPresence(t.type, t.id, a);
6371
+ const o = be((u) => {
6372
+ t.core._reactor.publishPresence(t.type, t.id, u);
6368
6373
  }, [t.type, t.id]);
6369
6374
  return en(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
6370
6375
  }
6371
6376
  function dc(t, e, n) {
6372
- Oe(() => t.core._reactor.joinRoom(t.id, e), [t.id]), Oe(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6377
+ Ee(() => t.core._reactor.joinRoom(t.id, e), [t.id]), Ee(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6373
6378
  }
6374
6379
  function fc(t, e, n = {}) {
6375
- const r = sc(), i = we.usePresence(t, {
6380
+ const r = sc(), i = me.usePresence(t, {
6376
6381
  keys: [e]
6377
6382
  }), s = en(() => {
6378
6383
  var c;
@@ -6387,21 +6392,21 @@ function fc(t, e, n = {}) {
6387
6392
  [e]: null
6388
6393
  });
6389
6394
  }));
6390
- }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), u = be((c) => {
6395
+ }, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), a = be((c) => {
6391
6396
  const h = !((n == null ? void 0 : n.stopOnEnter) && c.key === "Enter");
6392
6397
  o(h);
6393
- }, [n.stopOnEnter, o]), a = be(() => {
6398
+ }, [n.stopOnEnter, o]), u = be(() => {
6394
6399
  o(!1);
6395
- }, [o]), d = en(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
6400
+ }, [o]), d = en(() => ({ onKeyDown: a, onBlur: u }), [a, u]);
6396
6401
  return {
6397
6402
  active: s,
6398
6403
  setActive: o,
6399
6404
  inputProps: d
6400
6405
  };
6401
6406
  }
6402
- const we = {
6403
- useTopicEffect: uc,
6404
- usePublishTopic: ac,
6407
+ const me = {
6408
+ useTopicEffect: ac,
6409
+ usePublishTopic: uc,
6405
6410
  usePresence: cc,
6406
6411
  useSyncPresence: dc,
6407
6412
  useTypingIndicator: fc
@@ -6409,8 +6414,8 @@ const we = {
6409
6414
  class lc {
6410
6415
  constructor(e, n, r) {
6411
6416
  this.useTopicEffect = (i, s) => {
6412
- we.useTopicEffect(this, i, s);
6413
- }, this.usePublishTopic = (i) => we.usePublishTopic(this, i), this.usePresence = (i = {}) => we.usePresence(this, i), this.useSyncPresence = (i, s) => we.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => we.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
6417
+ me.useTopicEffect(this, i, s);
6418
+ }, this.usePublishTopic = (i) => me.usePublishTopic(this, i), this.usePresence = (i = {}) => me.usePresence(this, i), this.useSyncPresence = (i, s) => me.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => me.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
6414
6419
  }
6415
6420
  }
6416
6421
  var hc = function(t, e, n, r) {
@@ -6420,14 +6425,14 @@ var hc = function(t, e, n, r) {
6420
6425
  });
6421
6426
  }
6422
6427
  return new (n || (n = Promise))(function(s, o) {
6423
- function u(c) {
6428
+ function a(c) {
6424
6429
  try {
6425
6430
  d(r.next(c));
6426
6431
  } catch (f) {
6427
6432
  o(f);
6428
6433
  }
6429
6434
  }
6430
- function a(c) {
6435
+ function u(c) {
6431
6436
  try {
6432
6437
  d(r.throw(c));
6433
6438
  } catch (f) {
@@ -6435,7 +6440,7 @@ var hc = function(t, e, n, r) {
6435
6440
  }
6436
6441
  }
6437
6442
  function d(c) {
6438
- c.done ? s(c.value) : i(c.value).then(u, a);
6443
+ c.done ? s(c.value) : i(c.value).then(a, u);
6439
6444
  }
6440
6445
  d((r = r.apply(t, e || [])).next());
6441
6446
  });
@@ -6449,15 +6454,15 @@ class yc {
6449
6454
  constructor(e, n) {
6450
6455
  this.tx = qn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6451
6456
  const [i, s] = oi(null);
6452
- return Oe(() => {
6457
+ return Ee(() => {
6453
6458
  hc(this, void 0, void 0, function* () {
6454
- const u = yield this.getLocalId(r);
6455
- s(u);
6459
+ const a = yield this.getLocalId(r);
6460
+ s(a);
6456
6461
  });
6457
6462
  }, [r]), i;
6458
- }, this.rooms = we, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => ic(this.core, r, i).state, this.useAuth = () => {
6459
- const r = vt(this.core._reactor._currentUserCached), i = be((o) => this.core.subscribeAuth((a) => {
6460
- r.current = Object.assign({ isLoading: !1 }, a), o();
6463
+ }, this.rooms = me, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => ic(this.core, r, i).state, this.useAuth = () => {
6464
+ const r = Ot(this.core._reactor._currentUserCached), i = be((o) => this.core.subscribeAuth((u) => {
6465
+ r.current = Object.assign({ isLoading: !1 }, u), o();
6461
6466
  }), []);
6462
6467
  return Xt(i, () => r.current, () => pc);
6463
6468
  }, this.useUser = () => {
@@ -6466,8 +6471,8 @@ class yc {
6466
6471
  throw new Fe("useUser must be used within an auth-protected route");
6467
6472
  return r;
6468
6473
  }, this.useConnectionStatus = () => {
6469
- const r = vt(this.core._reactor.status), i = be((o) => this.core.subscribeConnectionStatus((a) => {
6470
- a !== r.current && (r.current = a, o());
6474
+ const r = Ot(this.core._reactor.status), i = be((o) => this.core.subscribeConnectionStatus((u) => {
6475
+ u !== r.current && (r.current = u, o());
6471
6476
  }), []);
6472
6477
  return Xt(
6473
6478
  i,
@@ -6481,7 +6486,7 @@ class yc {
6481
6486
  }, this.SignedOut = ({ children: r }) => {
6482
6487
  const i = this.useAuth();
6483
6488
  return i.isLoading || i.error || i.user ? null : q.jsx(q.Fragment, { children: r });
6484
- }, this.core = Za(
6489
+ }, this.core = Zu(
6485
6490
  e,
6486
6491
  // @ts-expect-error because TS can't resolve subclass statics
6487
6492
  this.constructor.Storage,
@@ -6534,7 +6539,7 @@ function bc(t) {
6534
6539
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
6535
6540
  );
6536
6541
  const { onEvent: e = Zt, onError: n = Zt, onRetry: r = Zt, onComment: i } = t;
6537
- let s = "", o = !0, u, a = "", d = "";
6542
+ let s = "", o = !0, a, u = "", d = "";
6538
6543
  function c(b) {
6539
6544
  const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, w] = _c(`${s}${_}`);
6540
6545
  for (const m of T)
@@ -6564,11 +6569,11 @@ function bc(t) {
6564
6569
  d = _;
6565
6570
  break;
6566
6571
  case "data":
6567
- a = `${a}${_}
6572
+ u = `${u}${_}
6568
6573
  `;
6569
6574
  break;
6570
6575
  case "id":
6571
- u = _.includes("\0") ? void 0 : _;
6576
+ a = _.includes("\0") ? void 0 : _;
6572
6577
  break;
6573
6578
  case "retry":
6574
6579
  /^\d+$/.test(_) ? r(parseInt(_, 10)) : n(
@@ -6590,17 +6595,17 @@ function bc(t) {
6590
6595
  }
6591
6596
  }
6592
6597
  function p() {
6593
- a.length > 0 && e({
6594
- id: u,
6598
+ u.length > 0 && e({
6599
+ id: a,
6595
6600
  event: d || void 0,
6596
6601
  // If the data buffer's last character is a U+000A LINE FEED (LF) character,
6597
6602
  // then remove the last character from the data buffer.
6598
- data: a.endsWith(`
6599
- `) ? a.slice(0, -1) : a
6600
- }), u = void 0, a = "", d = "";
6603
+ data: u.endsWith(`
6604
+ `) ? u.slice(0, -1) : u
6605
+ }), a = void 0, u = "", d = "";
6601
6606
  }
6602
6607
  function y(b = {}) {
6603
- s && b.consume && f(s), o = !0, u = void 0, a = "", d = "", s = "";
6608
+ s && b.consume && f(s), o = !0, a = void 0, u = "", d = "", s = "";
6604
6609
  }
6605
6610
  return { feed: c, reset: y };
6606
6611
  }
@@ -6615,8 +6620,8 @@ function _c(t) {
6615
6620
  n = t.slice(r);
6616
6621
  break;
6617
6622
  } else {
6618
- const u = t.slice(r, o);
6619
- e.push(u), r = o + 1, t[r - 1] === "\r" && t[r] === `
6623
+ const a = t.slice(r, o);
6624
+ e.push(a), r = o + 1, t[r - 1] === "\r" && t[r] === `
6620
6625
  ` && r++;
6621
6626
  }
6622
6627
  }
@@ -6683,19 +6688,19 @@ function ni(t) {
6683
6688
  }
6684
6689
  var Hi = (t) => {
6685
6690
  throw TypeError(t);
6686
- }, Bn = (t, e, n) => e.has(t) || Hi("Cannot " + n), E = (t, e, n) => (Bn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), N = (t, e, n) => e.has(t) ? Hi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), $ = (t, e, n, r) => (Bn(t, e, "write to private field"), e.set(t, n), n), le = (t, e, n) => (Bn(t, e, "access private method"), n), J, me, Ie, mt, kt, nt, $e, rt, ye, Pe, De, Me, Ze, se, vn, On, En, ri, An, Cn, Xe, kn, jn;
6687
- class St extends EventTarget {
6691
+ }, Bn = (t, e, n) => e.has(t) || Hi("Cannot " + n), E = (t, e, n) => (Bn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), N = (t, e, n) => e.has(t) ? Hi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), $ = (t, e, n, r) => (Bn(t, e, "write to private field"), e.set(t, n), n), le = (t, e, n) => (Bn(t, e, "access private method"), n), J, Se, Pe, St, jt, nt, $e, rt, ye, Me, De, Re, Ze, se, vn, On, En, ri, An, Cn, Xe, kn, jn;
6692
+ class vt extends EventTarget {
6688
6693
  constructor(e, n) {
6689
6694
  var r, i;
6690
- super(), N(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, N(this, J), N(this, me), N(this, Ie), N(this, mt), N(this, kt), N(this, nt), N(this, $e), N(this, rt, null), N(this, ye), N(this, Pe), N(this, De, null), N(this, Me, null), N(this, Ze, null), N(this, On, async (s) => {
6695
+ super(), N(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, N(this, J), N(this, Se), N(this, Pe), N(this, St), N(this, jt), N(this, nt), N(this, $e), N(this, rt, null), N(this, ye), N(this, Me), N(this, De, null), N(this, Re, null), N(this, Ze, null), N(this, On, async (s) => {
6691
6696
  var o;
6692
- E(this, Pe).reset();
6693
- const { body: u, redirected: a, status: d, headers: c } = s;
6697
+ E(this, Me).reset();
6698
+ const { body: a, redirected: u, status: d, headers: c } = s;
6694
6699
  if (d === 204) {
6695
6700
  le(this, se, Xe).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
6696
6701
  return;
6697
6702
  }
6698
- if (a ? $(this, Ie, new URL(s.url)) : $(this, Ie, void 0), d !== 200) {
6703
+ if (u ? $(this, Pe, new URL(s.url)) : $(this, Pe, void 0), d !== 200) {
6699
6704
  le(this, se, Xe).call(this, `Non-200 status code (${d})`, d);
6700
6705
  return;
6701
6706
  }
@@ -6707,15 +6712,15 @@ class St extends EventTarget {
6707
6712
  return;
6708
6713
  $(this, J, this.OPEN);
6709
6714
  const f = new Event("open");
6710
- if ((o = E(this, Ze)) == null || o.call(this, f), this.dispatchEvent(f), typeof u != "object" || !u || !("getReader" in u)) {
6715
+ if ((o = E(this, Ze)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
6711
6716
  le(this, se, Xe).call(this, "Invalid response body, expected a web ReadableStream", d), this.close();
6712
6717
  return;
6713
6718
  }
6714
- const h = new TextDecoder(), p = u.getReader();
6719
+ const h = new TextDecoder(), p = a.getReader();
6715
6720
  let y = !0;
6716
6721
  do {
6717
6722
  const { done: b, value: _ } = await p.read();
6718
- _ && E(this, Pe).feed(h.decode(_, { stream: !b })), b && (y = !1, E(this, Pe).reset(), le(this, se, kn).call(this));
6723
+ _ && E(this, Me).feed(h.decode(_, { stream: !b })), b && (y = !1, E(this, Me).reset(), le(this, se, kn).call(this));
6719
6724
  } while (y);
6720
6725
  }), N(this, En, (s) => {
6721
6726
  $(this, ye, void 0), !(s.name === "AbortError" || s.type === "aborted") && le(this, se, kn).call(this, Sn(s));
@@ -6723,10 +6728,10 @@ class St extends EventTarget {
6723
6728
  typeof s.id == "string" && $(this, rt, s.id);
6724
6729
  const o = new MessageEvent(s.event || "message", {
6725
6730
  data: s.data,
6726
- origin: E(this, Ie) ? E(this, Ie).origin : E(this, me).origin,
6731
+ origin: E(this, Pe) ? E(this, Pe).origin : E(this, Se).origin,
6727
6732
  lastEventId: s.id || ""
6728
6733
  });
6729
- E(this, Me) && (!s.event || s.event === "message") && E(this, Me).call(this, o), this.dispatchEvent(o);
6734
+ E(this, Re) && (!s.event || s.event === "message") && E(this, Re).call(this, o), this.dispatchEvent(o);
6730
6735
  }), N(this, Cn, (s) => {
6731
6736
  $(this, nt, s);
6732
6737
  }), N(this, jn, () => {
@@ -6734,18 +6739,18 @@ class St extends EventTarget {
6734
6739
  });
6735
6740
  try {
6736
6741
  if (e instanceof URL)
6737
- $(this, me, e);
6742
+ $(this, Se, e);
6738
6743
  else if (typeof e == "string")
6739
- $(this, me, new URL(e, Tc()));
6744
+ $(this, Se, new URL(e, Tc()));
6740
6745
  else
6741
6746
  throw new Error("Invalid URL");
6742
6747
  } catch {
6743
6748
  throw gc("An invalid or illegal string was specified");
6744
6749
  }
6745
- $(this, Pe, bc({
6750
+ $(this, Me, bc({
6746
6751
  onEvent: E(this, An),
6747
6752
  onRetry: E(this, Cn)
6748
- })), $(this, J, this.CONNECTING), $(this, nt, 3e3), $(this, kt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, mt, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), le(this, se, vn).call(this);
6753
+ })), $(this, J, this.CONNECTING), $(this, nt, 3e3), $(this, jt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, St, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), le(this, se, vn).call(this);
6749
6754
  }
6750
6755
  /**
6751
6756
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -6768,7 +6773,7 @@ class St extends EventTarget {
6768
6773
  * @public
6769
6774
  */
6770
6775
  get url() {
6771
- return E(this, me).href;
6776
+ return E(this, Se).href;
6772
6777
  }
6773
6778
  /**
6774
6779
  * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
@@ -6776,7 +6781,7 @@ class St extends EventTarget {
6776
6781
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
6777
6782
  */
6778
6783
  get withCredentials() {
6779
- return E(this, mt);
6784
+ return E(this, St);
6780
6785
  }
6781
6786
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
6782
6787
  get onerror() {
@@ -6787,10 +6792,10 @@ class St extends EventTarget {
6787
6792
  }
6788
6793
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
6789
6794
  get onmessage() {
6790
- return E(this, Me);
6795
+ return E(this, Re);
6791
6796
  }
6792
6797
  set onmessage(e) {
6793
- $(this, Me, e);
6798
+ $(this, Re, e);
6794
6799
  }
6795
6800
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
6796
6801
  get onopen() {
@@ -6818,13 +6823,13 @@ class St extends EventTarget {
6818
6823
  E(this, $e) && clearTimeout(E(this, $e)), E(this, J) !== this.CLOSED && (E(this, ye) && E(this, ye).abort(), $(this, J, this.CLOSED), $(this, ye, void 0));
6819
6824
  }
6820
6825
  }
6821
- J = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), Ie = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Me = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakSet(), /**
6826
+ J = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakMap(), jt = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Me = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Re = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakSet(), /**
6822
6827
  * Connect to the given URL and start receiving events
6823
6828
  *
6824
6829
  * @internal
6825
6830
  */
6826
6831
  vn = function() {
6827
- $(this, J, this.CONNECTING), $(this, ye, new AbortController()), E(this, kt)(E(this, me), le(this, se, ri).call(this)).then(E(this, On)).catch(E(this, En));
6832
+ $(this, J, this.CONNECTING), $(this, ye, new AbortController()), E(this, jt)(E(this, Se), le(this, se, ri).call(this)).then(E(this, On)).catch(E(this, En));
6828
6833
  }, On = /* @__PURE__ */ new WeakMap(), En = /* @__PURE__ */ new WeakMap(), /**
6829
6834
  * Get request options for the `fetch()` request
6830
6835
  *
@@ -6874,24 +6879,24 @@ kn = function(t, e) {
6874
6879
  *
6875
6880
  * @public
6876
6881
  */
6877
- St.CONNECTING = 0, /**
6882
+ vt.CONNECTING = 0, /**
6878
6883
  * ReadyState representing an EventSource connection that is open (eg connected)
6879
6884
  *
6880
6885
  * @public
6881
6886
  */
6882
- St.OPEN = 1, /**
6887
+ vt.OPEN = 1, /**
6883
6888
  * ReadyState representing an EventSource connection that is closed (eg disconnected)
6884
6889
  *
6885
6890
  * @public
6886
6891
  */
6887
- St.CLOSED = 2;
6892
+ vt.CLOSED = 2;
6888
6893
  function Tc() {
6889
6894
  const t = "document" in globalThis ? globalThis.document : void 0;
6890
6895
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
6891
6896
  }
6892
6897
  const Gn = class Gn extends yc {
6893
6898
  };
6894
- Gn.EventSourceImpl = St;
6899
+ Gn.EventSourceImpl = vt;
6895
6900
  let In = Gn;
6896
6901
  function wc(t) {
6897
6902
  return new In(
@@ -6910,8 +6915,8 @@ function jc({
6910
6915
  style: i,
6911
6916
  userCursorColor: s,
6912
6917
  children: o,
6913
- renderCursor: u,
6914
- propagate: a,
6918
+ renderCursor: a,
6919
+ propagate: u,
6915
6920
  zIndex: d
6916
6921
  }) {
6917
6922
  const c = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
@@ -6930,7 +6935,7 @@ function jc({
6930
6935
  });
6931
6936
  }
6932
6937
  function y(w) {
6933
- a || w.stopPropagation();
6938
+ u || w.stopPropagation();
6934
6939
  const m = w.currentTarget.getBoundingClientRect();
6935
6940
  p(m, w);
6936
6941
  }
@@ -6944,7 +6949,7 @@ function jc({
6944
6949
  return;
6945
6950
  const m = w.touches[0];
6946
6951
  if (m.target instanceof Element) {
6947
- a || w.stopPropagation();
6952
+ u || w.stopPropagation();
6948
6953
  const j = m.target.getBoundingClientRect();
6949
6954
  p(j, m);
6950
6955
  }
@@ -6988,7 +6993,7 @@ function jc({
6988
6993
  transformOrigin: "0 0",
6989
6994
  transition: "transform 100ms"
6990
6995
  },
6991
- children: u ? u({
6996
+ children: a ? a({
6992
6997
  color: j.color,
6993
6998
  presence: h.peers[w]
6994
6999
  }) : /* @__PURE__ */ q.jsx(mc, { ...j })
@@ -7062,9 +7067,10 @@ const ii = {
7062
7067
  }, vc = 99999;
7063
7068
  export {
7064
7069
  jc as Cursors,
7065
- Pt as InstantAPIError,
7070
+ Mt as InstantAPIError,
7066
7071
  yc as InstantReactAbstractDatabase,
7067
7072
  In as InstantReactWebDatabase,
7073
+ we as SyncTableCallbackEventType,
7068
7074
  Cc as i,
7069
7075
  W as id,
7070
7076
  wc as init,