@dialecte/core 0.6.2 → 0.6.4

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.
Files changed (36) hide show
  1. package/dist/document/query/any/any-query.d.ts +1 -0
  2. package/dist/document/query/any/any-query.d.ts.map +1 -1
  3. package/dist/document/query/find/descendant/find-descendant.d.ts +12 -0
  4. package/dist/document/query/find/descendant/find-descendant.d.ts.map +1 -1
  5. package/dist/document/query/find/descendant/record-source.d.ts +42 -0
  6. package/dist/document/query/find/descendant/record-source.d.ts.map +1 -0
  7. package/dist/document/query/get/attribute/get-attribute.d.ts +7 -7
  8. package/dist/document/query/get/attribute/get-attribute.d.ts.map +1 -1
  9. package/dist/document/query/get/attribute/get-attributes.d.ts +5 -3
  10. package/dist/document/query/get/attribute/get-attributes.d.ts.map +1 -1
  11. package/dist/document/query/get/record/index.d.ts +1 -0
  12. package/dist/document/query/get/record/index.d.ts.map +1 -1
  13. package/dist/document/query/get/record/load-live-records.d.ts +9 -0
  14. package/dist/document/query/get/record/load-live-records.d.ts.map +1 -0
  15. package/dist/document/query/main.d.ts +11 -0
  16. package/dist/document/query/main.d.ts.map +1 -1
  17. package/dist/helpers/index.d.ts +2 -0
  18. package/dist/helpers/index.d.ts.map +1 -1
  19. package/dist/helpers/read-attributes.d.ts +56 -0
  20. package/dist/helpers/read-attributes.d.ts.map +1 -0
  21. package/dist/helpers/read-attributes.types.d.ts +10 -0
  22. package/dist/helpers/read-attributes.types.d.ts.map +1 -0
  23. package/dist/helpers.js +167 -43
  24. package/dist/index.js +3 -3
  25. package/dist/{project-DQ6Yf6lO.js → project-DGQAe9G9.js} +854 -793
  26. package/dist/store/in-memory/in-memory-store.d.ts +1 -0
  27. package/dist/store/in-memory/in-memory-store.d.ts.map +1 -1
  28. package/dist/store/local/dexie-store.d.ts +6 -0
  29. package/dist/store/local/dexie-store.d.ts.map +1 -1
  30. package/dist/store/store.types.d.ts +6 -0
  31. package/dist/store/store.types.d.ts.map +1 -1
  32. package/dist/test/run-test-cases.d.ts.map +1 -1
  33. package/dist/test/run-test-cases.type.d.ts +8 -0
  34. package/dist/test/run-test-cases.type.d.ts.map +1 -1
  35. package/dist/test.js +33 -31
  36. package/package.json +1 -1
@@ -1,32 +1,32 @@
1
- import { A as e, C as t, E as n, L as r, N as i, P as a, R as o, T as s, _ as c, b as l, c as u, h as d, l as f, m as p, n as m, t as h, w as g, x as _, y as v } from "./utils-CTBHUFs9.js";
2
- import { assertNoFixedViolation as y, assertXsiTypeAdmitted as b, assertXsiTypeChangeLeavesNothing as x, isRecordOf as S, mergeExtensions as C, standardizeRecord as ee, toFullAttributeArray as w, toRawRecord as te, toRef as T, toTreeRecord as ne } from "./helpers.js";
1
+ import { A as e, C as t, E as n, L as r, N as i, P as a, R as o, T as s, _ as c, b as l, l as u, m as d, n as f, t as p, w as m, x as h, y as g } from "./utils-CTBHUFs9.js";
2
+ import { assertNoFixedViolation as _, assertXsiTypeAdmitted as v, assertXsiTypeChangeLeavesNothing as y, isRecordOf as b, mergeExtensions as x, readAttribute as S, readAttributes as C, standardizeRecord as ee, toFullAttributeArray as w, toRawRecord as te, toRef as T, toTreeRecord as ne } from "./helpers.js";
3
3
  //#region \0rolldown/runtime.js
4
- var re = Object.create, ie = Object.defineProperty, ae = Object.getOwnPropertyDescriptor, E = Object.getOwnPropertyNames, D = Object.getPrototypeOf, oe = Object.prototype.hasOwnProperty, O = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), se = (e, t, n, r) => {
5
- if (t && typeof t == "object" || typeof t == "function") for (var i = E(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !oe.call(e, s) && s !== n && ie(e, s, {
4
+ var re = Object.create, ie = Object.defineProperty, ae = Object.getOwnPropertyDescriptor, E = Object.getOwnPropertyNames, oe = Object.getPrototypeOf, se = Object.prototype.hasOwnProperty, D = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), ce = (e, t, n, r) => {
5
+ if (t && typeof t == "object" || typeof t == "function") for (var i = E(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !se.call(e, s) && s !== n && ie(e, s, {
6
6
  get: ((e) => t[e]).bind(null, s),
7
7
  enumerable: !(r = ae(t, s)) || r.enumerable
8
8
  });
9
9
  return e;
10
- }, k = (e, t, n) => (n = e == null ? {} : re(D(e)), se(t || !e || !e.__esModule ? ie(n, "default", {
10
+ }, O = (e, t, n) => (n = e == null ? {} : re(oe(e)), ce(t || !e || !e.__esModule ? ie(n, "default", {
11
11
  value: e,
12
12
  enumerable: !0
13
13
  }) : n, e));
14
14
  //#endregion
15
15
  //#region src/document/bind-extensions.ts
16
- function ce(e, t) {
17
- return e ? le(e, t) : {};
18
- }
19
16
  function le(e, t) {
17
+ return e ? ue(e, t) : {};
18
+ }
19
+ function ue(e, t) {
20
20
  let n = {};
21
21
  for (let r of Object.keys(e)) {
22
22
  let i = e[r];
23
- n[r] = typeof i == "function" ? (...e) => i(t, ...e) : le(i, t);
23
+ n[r] = typeof i == "function" ? (...e) => i(t, ...e) : ue(i, t);
24
24
  }
25
25
  return n;
26
26
  }
27
27
  //#endregion
28
28
  //#region src/document/progress/create-progress-reporter.ts
29
- function ue(e, t = () => {}) {
29
+ function de(e, t = () => {}) {
30
30
  let n = [];
31
31
  function r() {
32
32
  if (n.length === 0) {
@@ -70,7 +70,7 @@ function ue(e, t = () => {}) {
70
70
  }
71
71
  //#endregion
72
72
  //#region src/document/progress/noop-progress-reporter.ts
73
- var de = Object.freeze({
73
+ var fe = Object.freeze({
74
74
  plan() {},
75
75
  nextStep() {},
76
76
  endPlan() {},
@@ -78,7 +78,7 @@ var de = Object.freeze({
78
78
  });
79
79
  //#endregion
80
80
  //#region src/document/staged-operations.ts
81
- function A() {
81
+ function k() {
82
82
  return {
83
83
  log: [],
84
84
  byId: /* @__PURE__ */ new Map()
@@ -86,11 +86,11 @@ function A() {
86
86
  }
87
87
  //#endregion
88
88
  //#region src/document/query/get/record/staged-lookup.ts
89
- function fe(e) {
89
+ function pe(e) {
90
90
  let { stagedOperations: t, tagName: n, id: r } = e, { log: i, byId: a } = t;
91
91
  if (r !== void 0) {
92
92
  let e = a.get(r);
93
- return e ? pe({
93
+ return e ? me({
94
94
  operation: e,
95
95
  tagName: n,
96
96
  id: r
@@ -98,28 +98,28 @@ function fe(e) {
98
98
  }
99
99
  for (let e = i.length - 1; e >= 0; e--) {
100
100
  let t = i[e];
101
- if ((t.status === "created" || t.status === "updated") && S(t.newRecord, n)) return {
101
+ if ((t.status === "created" || t.status === "updated") && b(t.newRecord, n)) return {
102
102
  ...t.newRecord,
103
103
  status: t.status
104
104
  };
105
- if (t.status === "deleted" && S(t.oldRecord, n)) return {
105
+ if (t.status === "deleted" && b(t.oldRecord, n)) return {
106
106
  ...t.oldRecord,
107
107
  status: "deleted"
108
108
  };
109
109
  }
110
110
  }
111
- function pe(e) {
111
+ function me(e) {
112
112
  let { operation: t, tagName: n, id: r } = e;
113
- if ((t.status === "created" || t.status === "updated") && t.newRecord.id === r) return j(t.newRecord.tagName, n, r), {
113
+ if ((t.status === "created" || t.status === "updated") && t.newRecord.id === r) return A(t.newRecord.tagName, n, r), {
114
114
  ...t.newRecord,
115
115
  status: t.status
116
116
  };
117
- if (t.status === "deleted" && t.oldRecord.id === r) return j(t.oldRecord.tagName, n, r), {
117
+ if (t.status === "deleted" && t.oldRecord.id === r) return A(t.oldRecord.tagName, n, r), {
118
118
  ...t.oldRecord,
119
119
  status: "deleted"
120
120
  };
121
121
  }
122
- function j(e, t, n) {
122
+ function A(e, t, n) {
123
123
  e !== t && r("ELEMENT_TAGNAME_MISMATCH", {
124
124
  detail: `Expected tagName '${t}', got '${e}' for id '${n}'`,
125
125
  ref: {
@@ -128,14 +128,14 @@ function j(e, t, n) {
128
128
  }
129
129
  });
130
130
  }
131
- function me(e) {
131
+ function he(e) {
132
132
  let { rawRecords: t, stagedOperations: n, tagName: r } = e, i = new Map(t.map((e) => [e.id, {
133
133
  ...e,
134
134
  status: "unchanged"
135
135
  }]));
136
136
  for (let e of n) {
137
137
  if (e.status === "created" || e.status === "updated") {
138
- if (!S(e.newRecord, r)) continue;
138
+ if (!b(e.newRecord, r)) continue;
139
139
  i.set(e.newRecord.id, {
140
140
  ...e.newRecord,
141
141
  status: e.status
@@ -145,7 +145,7 @@ function me(e) {
145
145
  }
146
146
  return Array.from(i.values());
147
147
  }
148
- function M(e) {
148
+ function j(e) {
149
149
  let { rawRecords: t, stagedOperations: n, includeDeleted: r = !1 } = e, { log: i, byId: a } = n, o = new Map(t.map((e) => [e.id, {
150
150
  ...e,
151
151
  status: "unchanged"
@@ -176,7 +176,7 @@ function M(e) {
176
176
  deleted: c
177
177
  };
178
178
  }
179
- function he(e) {
179
+ function ge(e) {
180
180
  let t = /* @__PURE__ */ new Set();
181
181
  for (let n of e) n.status === "created" && t.add(n.newRecord.id);
182
182
  let n = /* @__PURE__ */ new Map();
@@ -196,10 +196,10 @@ function he(e) {
196
196
  }
197
197
  //#endregion
198
198
  //#region src/document/query/get/record/get-record.ts
199
- async function N(e) {
199
+ async function M(e) {
200
200
  let { context: t, ref: n } = e;
201
201
  if (t.stagedOperations.log.length > 0) {
202
- let e = fe({
202
+ let e = pe({
203
203
  stagedOperations: t.stagedOperations,
204
204
  tagName: n.tagName,
205
205
  id: n.id
@@ -225,14 +225,14 @@ async function N(e) {
225
225
  }
226
226
  //#endregion
227
227
  //#region src/document/query/get/record/resolve-record.ts
228
- async function ge(e) {
228
+ async function _e(e) {
229
229
  let { context: t, ref: n } = e;
230
- if (f(n, { detail: "The record or ref is undefined" }), !("attributes" in n) || !Array.isArray(n.attributes)) return N({
230
+ if (u(n, { detail: "The record or ref is undefined" }), !("attributes" in n) || !Array.isArray(n.attributes)) return M({
231
231
  context: t,
232
232
  ref: n
233
233
  });
234
234
  if (t.stagedOperations.log.length > 0) {
235
- let e = fe({
235
+ let e = pe({
236
236
  stagedOperations: t.stagedOperations,
237
237
  tagName: n.tagName,
238
238
  id: n.id
@@ -247,21 +247,21 @@ async function ge(e) {
247
247
  }
248
248
  //#endregion
249
249
  //#region src/document/query/get/record/get-records.ts
250
- async function _e(e) {
250
+ async function ve(e) {
251
251
  let { context: t, refs: n } = e;
252
- return Promise.all(n.map((e) => N({
252
+ return Promise.all(n.map((e) => M({
253
253
  context: t,
254
254
  ref: e
255
255
  })));
256
256
  }
257
257
  //#endregion
258
258
  //#region src/document/query/get/record/get-records-by-tagname.ts
259
- async function ve(e) {
259
+ async function ye(e) {
260
260
  let { context: t, tagName: n } = e;
261
261
  t.perf.count("core::store::getByTagName");
262
262
  let r = await t.store.getByTagNameInDocument(n, t.documentId);
263
263
  for (let e of r) bn(t) && t.recordCache.set(e.id, e);
264
- return me({
264
+ return he({
265
265
  rawRecords: r,
266
266
  stagedOperations: t.stagedOperations.log,
267
267
  tagName: n
@@ -269,14 +269,14 @@ async function ve(e) {
269
269
  }
270
270
  //#endregion
271
271
  //#region src/document/query/get/record/get-child.ts
272
- async function ye(e) {
273
- let { context: t, ref: n, tagName: r } = e, i = await N({
272
+ async function be(e) {
273
+ let { context: t, ref: n, tagName: r } = e, i = await M({
274
274
  context: t,
275
275
  ref: n
276
276
  });
277
277
  if (!i) return;
278
278
  let a = i.children.find((e) => e.tagName === r);
279
- if (a) return N({
279
+ if (a) return M({
280
280
  context: t,
281
281
  ref: a
282
282
  });
@@ -284,13 +284,13 @@ async function ye(e) {
284
284
  if (!o?.length) return;
285
285
  let s = i.children.filter((e) => o.includes(e.tagName));
286
286
  for (let e of s) {
287
- let n = await N({
287
+ let n = await M({
288
288
  context: t,
289
289
  ref: e
290
290
  });
291
291
  if (!n) continue;
292
292
  let i = n.children.find((e) => e.tagName === r);
293
- if (i) return N({
293
+ if (i) return M({
294
294
  context: t,
295
295
  ref: i
296
296
  });
@@ -298,8 +298,8 @@ async function ye(e) {
298
298
  }
299
299
  //#endregion
300
300
  //#region src/document/query/get/record/get-children.ts
301
- async function be(e) {
302
- let { context: t, ref: n, tagName: r } = e, i = await N({
301
+ async function xe(e) {
302
+ let { context: t, ref: n, tagName: r } = e, i = await M({
303
303
  context: t,
304
304
  ref: n
305
305
  });
@@ -308,7 +308,7 @@ async function be(e) {
308
308
  tagName: r,
309
309
  id: e.id
310
310
  }));
311
- if (a.length) return (await _e({
311
+ if (a.length) return (await ve({
312
312
  context: t,
313
313
  refs: a
314
314
  })).filter((e) => e !== void 0);
@@ -316,27 +316,37 @@ async function be(e) {
316
316
  if (!o?.length) return [];
317
317
  let s = i.children.filter((e) => o.includes(e.tagName));
318
318
  if (!s.length) return [];
319
- let c = (await _e({
319
+ let c = (await ve({
320
320
  context: t,
321
321
  refs: s
322
322
  })).filter((e) => e !== void 0).flatMap((e) => e.children.filter((e) => e.tagName === r)).map((e) => ({
323
323
  tagName: r,
324
324
  id: e.id
325
325
  }));
326
- return c.length ? (await _e({
326
+ return c.length ? (await ve({
327
327
  context: t,
328
328
  refs: c
329
329
  })).filter((e) => e !== void 0) : [];
330
330
  }
331
331
  //#endregion
332
+ //#region src/document/query/get/record/load-live-records.ts
333
+ async function Se(e) {
334
+ e.perf.count("core::store::getByDocumentId");
335
+ let { live: t } = j({
336
+ rawRecords: await e.store.getByDocumentId(e.documentId),
337
+ stagedOperations: e.stagedOperations
338
+ });
339
+ return t;
340
+ }
341
+ //#endregion
332
342
  //#region src/document/query/find/ancestor/find-ancestor.ts
333
- async function xe(e) {
334
- let { context: t, ref: n, options: r } = e, i = r?.depth ?? Infinity, a = r?.stopAtTagName, o = r?.order ?? "bottom-up", s = [], c = await N({
343
+ async function N(e) {
344
+ let { context: t, ref: n, options: r } = e, i = r?.depth ?? Infinity, a = r?.stopAtTagName, o = r?.order ?? "bottom-up", s = [], c = await M({
335
345
  context: t,
336
346
  ref: n
337
347
  });
338
348
  for (; c?.parent && s.length < i;) {
339
- let e = c.parent, n = await N({
349
+ let e = c.parent, n = await M({
340
350
  context: t,
341
351
  ref: e
342
352
  });
@@ -347,25 +357,25 @@ async function xe(e) {
347
357
  }
348
358
  //#endregion
349
359
  //#region src/document/query/find/by-attribute/find-by-attributes.ts
350
- async function P(e) {
351
- let { context: t, tagName: n, attributes: r } = e, i = await ve({
360
+ async function Ce(e) {
361
+ let { context: t, tagName: n, attributes: r } = e, i = await ye({
352
362
  context: t,
353
363
  tagName: n
354
364
  }), a = [];
355
- for (let e of i) Se({
365
+ for (let e of i) P({
356
366
  dialecteConfig: t.dialecteConfig,
357
367
  record: e,
358
368
  attributeFilter: r
359
369
  }) && a.push(e);
360
370
  return a;
361
371
  }
362
- function Se(e) {
372
+ function P(e) {
363
373
  let { dialecteConfig: t, record: n, attributeFilter: r } = e;
364
374
  if (!r || Object.keys(r).length === 0) return !0;
365
375
  for (let [e, i] of Object.entries(r)) {
366
376
  if (i === void 0) continue;
367
377
  if (e === "xsi:type") {
368
- if (!Ce({
378
+ if (!we({
369
379
  dialecteConfig: t,
370
380
  record: n,
371
381
  expected: i
@@ -380,8 +390,8 @@ function Se(e) {
380
390
  }
381
391
  return !0;
382
392
  }
383
- function Ce(e) {
384
- let { dialecteConfig: n, record: r, expected: i } = e, a = r.attributes.find(_);
393
+ function we(e) {
394
+ let { dialecteConfig: n, record: r, expected: i } = e, a = r.attributes.find(h);
385
395
  if (a === void 0 || a.value === "") return !1;
386
396
  let o = l({
387
397
  dialecteConfig: n,
@@ -400,33 +410,111 @@ function Ce(e) {
400
410
  namespaceOf: s
401
411
  }) === o);
402
412
  }
413
+ var Te = 1 / 17;
414
+ function Ee(e) {
415
+ let { context: t } = e, n = /* @__PURE__ */ new Map(), i, a, o = 0, s;
416
+ function c(e) {
417
+ return t.stagedOperations.byId.has(e) ? !1 : !(bn(t) && t.recordCache.has(e));
418
+ }
419
+ async function l(e) {
420
+ if (i) return i;
421
+ if (!(e === 0 || o + e <= 128)) {
422
+ if (s === void 0) {
423
+ t.perf.count("core::store::count");
424
+ let e = await t.store.count(t.documentId);
425
+ s = Math.max(128, Math.ceil(e * Te));
426
+ }
427
+ if (!(o + e <= s)) return i = await Se(t), i;
428
+ }
429
+ }
430
+ function u(e, t) {
431
+ return t && t.tagName !== e.tagName && r("ELEMENT_TAGNAME_MISMATCH", {
432
+ detail: `Expected tagName '${e.tagName}', got '${t.tagName}' for id '${e.id}'`,
433
+ ref: e
434
+ }), t;
435
+ }
436
+ async function d(e) {
437
+ if (e.id === void 0) return M({
438
+ context: t,
439
+ ref: e
440
+ });
441
+ let r = e;
442
+ if (i) return u(r, i.get(r.id));
443
+ if (n.has(r.id)) return u(r, n.get(r.id));
444
+ let a = c(r.id), s = a ? await l(1) : void 0;
445
+ if (s) return u(r, s.get(r.id));
446
+ a && o++;
447
+ let d = await M({
448
+ context: t,
449
+ ref: r
450
+ });
451
+ return n.set(r.id, d), d;
452
+ }
453
+ async function f(e) {
454
+ if (!i) {
455
+ let r = /* @__PURE__ */ new Map();
456
+ for (let t of e) t.id === void 0 || n.has(t.id) || r.has(t.id) || r.set(t.id, t);
457
+ let i = [...r.keys()].filter(c).length;
458
+ if (!await l(i)) {
459
+ o += i;
460
+ let e = [...r.values()], a = await Promise.all(e.map((e) => M({
461
+ context: t,
462
+ ref: e
463
+ })));
464
+ e.forEach((e, t) => n.set(e.id, a[t]));
465
+ }
466
+ }
467
+ return Promise.all(e.map((e) => d(e)));
468
+ }
469
+ function p(e, t) {
470
+ if (!a) {
471
+ a = /* @__PURE__ */ new Map();
472
+ for (let t of e.values()) {
473
+ let e = a.get(t.tagName);
474
+ e ? e.push(t) : a.set(t.tagName, [t]);
475
+ }
476
+ }
477
+ return a.get(t) ?? [];
478
+ }
479
+ async function m(e) {
480
+ let n = i ?? await l(1);
481
+ return n ? p(n, e) : (o++, ye({
482
+ context: t,
483
+ tagName: e
484
+ }));
485
+ }
486
+ return {
487
+ get: d,
488
+ getMany: f,
489
+ byTag: m
490
+ };
491
+ }
403
492
  //#endregion
404
493
  //#region src/document/query/find/descendant/find-descendant.ts
405
- async function we(e) {
406
- let { context: t, ref: n, options: r } = e, { collect: i, omit: a } = r, o = Te({
494
+ async function De(e) {
495
+ let { context: t, ref: n, options: r } = e, { collect: i, omit: a } = r, o = Oe({
407
496
  omit: a,
408
497
  dialecteConfig: t.dialecteConfig
409
- }), s = De(i), c = /* @__PURE__ */ new Map();
498
+ }), s = je(i), c = /* @__PURE__ */ new Map();
410
499
  for (let e of s.allTags) c.set(e, /* @__PURE__ */ new Map());
411
- let l = await N({
412
- context: t,
413
- ref: n
414
- });
415
- return l && (s.mode === "flat" ? await Ae({
500
+ let l = Ee({ context: t }), u = await l.get(n);
501
+ return u && (s.mode === "flat" ? await Pe({
416
502
  context: t,
417
- rootId: l.id,
503
+ source: l,
504
+ root: u,
418
505
  collectSpec: s,
419
506
  omitSpec: o,
420
507
  collected: c
421
- }) : await Ne({
508
+ }) : await Ie({
422
509
  context: t,
423
- record: l,
510
+ source: l,
511
+ record: u,
424
512
  pathNodes: s.paths,
425
513
  omitSpec: o,
426
514
  collected: c
427
- })), F(c);
515
+ })), I(c);
428
516
  }
429
- function Te(e) {
517
+ function Oe(e) {
430
518
  let { omit: t, dialecteConfig: n } = e, r = /* @__PURE__ */ new Set(), i = [];
431
519
  if (!t) return {
432
520
  dialecteConfig: n,
@@ -447,17 +535,20 @@ function Te(e) {
447
535
  conditional: i
448
536
  };
449
537
  }
450
- function Ee(e) {
538
+ function ke(e) {
539
+ return e.unconditional.size > 0 || e.conditional.length > 0;
540
+ }
541
+ function Ae(e) {
451
542
  let { record: t, omitSpec: n } = e;
452
543
  if (n.unconditional.has(t.tagName)) return !0;
453
- for (let e of n.conditional) if (e.tagName === t.tagName && Se({
544
+ for (let e of n.conditional) if (e.tagName === t.tagName && P({
454
545
  dialecteConfig: n.dialecteConfig,
455
546
  record: t,
456
547
  attributeFilter: e.where
457
548
  })) return !0;
458
549
  return !1;
459
550
  }
460
- function De(e) {
551
+ function je(e) {
461
552
  if (typeof e == "string") return {
462
553
  mode: "flat",
463
554
  targets: [{ tagName: e }],
@@ -479,16 +570,16 @@ function De(e) {
479
570
  let t = /* @__PURE__ */ new Set();
480
571
  return {
481
572
  mode: "path",
482
- paths: Oe(e, t),
573
+ paths: Me(e, t),
483
574
  allTags: t
484
575
  };
485
576
  }
486
- function Oe(e, t) {
577
+ function Me(e, t) {
487
578
  let n = [];
488
579
  for (let [r, i] of Object.entries(e)) {
489
580
  if (r === "where") continue;
490
581
  t.add(r);
491
- let e = ke({
582
+ let e = Ne({
492
583
  tagName: r,
493
584
  value: i,
494
585
  allTags: t
@@ -497,7 +588,7 @@ function Oe(e, t) {
497
588
  }
498
589
  return n;
499
590
  }
500
- function ke(e) {
591
+ function Ne(e) {
501
592
  let { tagName: t, value: n, allTags: r } = e;
502
593
  if (n === !0) return {
503
594
  tagName: t,
@@ -518,277 +609,225 @@ function ke(e) {
518
609
  return {
519
610
  tagName: t,
520
611
  where: a,
521
- children: Oe(s, r),
612
+ children: Me(s, r),
522
613
  isLeaf: !1
523
614
  };
524
615
  }
525
- async function Ae(e) {
526
- let { context: t, rootId: n, collectSpec: r, omitSpec: i, collected: a } = e;
527
- for (let e of r.targets) {
528
- if (i.unconditional.has(e.tagName)) continue;
529
- let r = await ve({
530
- context: t,
531
- tagName: e.tagName
532
- });
533
- for (let o of r) je({
616
+ async function Pe(e) {
617
+ let { context: t, source: n, root: r, collectSpec: i, omitSpec: a, collected: o } = e, s = !r.parent && !ke(a), c = F({
618
+ source: n,
619
+ rootId: r.id,
620
+ omitSpec: a
621
+ });
622
+ for (let e of i.targets) {
623
+ if (a.unconditional.has(e.tagName)) continue;
624
+ let r = await n.byTag(e.tagName);
625
+ for (let n of r) Fe({
534
626
  dialecteConfig: t.dialecteConfig,
535
- record: o,
627
+ record: n,
536
628
  where: e.where
537
- }) && (Ee({
538
- record: o,
539
- omitSpec: i
540
- }) || await Me({
541
- context: t,
542
- record: o,
543
- rootId: n,
544
- omitSpec: i
545
- }) && a.get(e.tagName).set(o.id, o));
629
+ }) && (s ? !Ae({
630
+ record: n,
631
+ omitSpec: a
632
+ }) : await c.isUnderRoot(n)) && o.get(e.tagName).set(n.id, n);
546
633
  }
547
634
  }
548
- function je(e) {
635
+ function Fe(e) {
549
636
  let { dialecteConfig: t, record: n, where: r } = e;
550
- return r ? Se({
637
+ return r ? P({
551
638
  dialecteConfig: t,
552
639
  record: n,
553
640
  attributeFilter: r
554
641
  }) : !0;
555
642
  }
556
- async function Me(e) {
557
- let { context: t, record: n, rootId: r, omitSpec: i } = e;
558
- if (n.id === r) return !0;
559
- let a = n;
560
- for (; a;) {
561
- if (!a.parent || i.unconditional.has(a.parent.tagName)) return !1;
562
- if (a.parent.id === r) return !0;
563
- let e = await N({
564
- context: t,
565
- ref: T(a.parent)
566
- });
567
- if (!e || Ee({
643
+ function F(e) {
644
+ let { source: t, rootId: n, omitSpec: r } = e, i = /* @__PURE__ */ new Map();
645
+ async function a(e) {
646
+ if (Ae({
568
647
  record: e,
569
- omitSpec: i
648
+ omitSpec: r
570
649
  })) return !1;
571
- a = e;
650
+ if (e.id === n) return !0;
651
+ let a = [e.id], o = e, s;
652
+ for (;;) {
653
+ let e = o.parent;
654
+ if (!e) {
655
+ s = !1;
656
+ break;
657
+ }
658
+ if (r.unconditional.has(e.tagName)) {
659
+ s = !1;
660
+ break;
661
+ }
662
+ if (e.id === n) {
663
+ s = !0;
664
+ break;
665
+ }
666
+ let c = i.get(e.id);
667
+ if (c !== void 0) {
668
+ s = c;
669
+ break;
670
+ }
671
+ let l = await t.get(T(e));
672
+ if (!l || Ae({
673
+ record: l,
674
+ omitSpec: r
675
+ })) {
676
+ i.set(e.id, !1), s = !1;
677
+ break;
678
+ }
679
+ a.push(l.id), o = l;
680
+ }
681
+ for (let e of a) i.set(e, s);
682
+ return s;
572
683
  }
573
- return !1;
684
+ return { isUnderRoot: a };
574
685
  }
575
- async function Ne(e) {
576
- let { context: t, record: n, pathNodes: r, omitSpec: i, collected: a } = e;
577
- if (!n.children?.length) return;
578
- let o = new Set(r.map((e) => e.tagName));
579
- for (let e of r) {
580
- let r = await Pe({
686
+ async function Ie(e) {
687
+ let { context: t, source: n, record: r, pathNodes: i, omitSpec: a, collected: o } = e;
688
+ if (!r.children?.length) return;
689
+ let s = new Set(i.map((e) => e.tagName));
690
+ for (let e of i) {
691
+ let i = await Le({
581
692
  context: t,
582
- record: n,
693
+ source: n,
694
+ record: r,
583
695
  tagName: e.tagName,
584
696
  where: e.where,
585
- omitSpec: i,
586
- stopAtTagNames: o
697
+ omitSpec: a,
698
+ stopAtTagNames: s
587
699
  });
588
- for (let n of r) a.get(e.tagName).set(n.id, n), !e.isLeaf && e.children.length > 0 && await Ne({
700
+ for (let r of i) o.get(e.tagName).set(r.id, r), !e.isLeaf && e.children.length > 0 && await Ie({
589
701
  context: t,
590
- record: n,
702
+ source: n,
703
+ record: r,
591
704
  pathNodes: e.children,
592
- omitSpec: i,
593
- collected: a
705
+ omitSpec: a,
706
+ collected: o
594
707
  });
595
708
  }
596
709
  }
597
- async function Pe(e) {
598
- let { context: t, record: n, tagName: r, where: i, omitSpec: a, stopAtTagNames: o } = e, s = [];
599
- if (!n.children?.length) return s;
600
- let c = [], l = await Fe({
601
- context: t,
602
- record: n,
603
- omitSpec: a
710
+ async function Le(e) {
711
+ let { context: t, source: n, record: r, tagName: i, where: a, omitSpec: o, stopAtTagNames: s } = e, c = [];
712
+ if (!r.children?.length) return c;
713
+ let l = [], u = await Re({
714
+ source: n,
715
+ record: r,
716
+ omitSpec: o
604
717
  });
605
- for (c.push(...l); c.length > 0;) {
606
- let e = c.shift();
607
- if (e.tagName === r) {
608
- je({
718
+ for (l.push(...u); l.length > 0;) {
719
+ let e = l.shift();
720
+ if (e.tagName === i) {
721
+ Fe({
609
722
  dialecteConfig: t.dialecteConfig,
610
723
  record: e,
611
- where: i
612
- }) && s.push(e);
724
+ where: a
725
+ }) && c.push(e);
613
726
  continue;
614
727
  }
615
- if (!(o.has(e.tagName) && e.tagName !== r) && e.children?.length) {
616
- let n = await Fe({
617
- context: t,
728
+ if (!(s.has(e.tagName) && e.tagName !== i) && e.children?.length) {
729
+ let t = await Re({
730
+ source: n,
618
731
  record: e,
619
- omitSpec: a
732
+ omitSpec: o
620
733
  });
621
- c.push(...n);
734
+ l.push(...t);
622
735
  }
623
736
  }
624
- return s;
737
+ return c;
625
738
  }
626
- async function Fe(e) {
627
- let { context: t, record: n, omitSpec: r } = e;
739
+ async function Re(e) {
740
+ let { source: t, record: n, omitSpec: r } = e;
628
741
  if (!n.children?.length) return [];
629
742
  let i = n.children.filter((e) => !r.unconditional.has(e.tagName));
630
- return i.length ? (await Promise.all(i.map((e) => N({
631
- context: t,
632
- ref: T(e)
633
- })))).filter((e) => e !== void 0 && !Ee({
743
+ return i.length ? (await t.getMany(i.map((e) => T(e)))).filter((e) => e !== void 0 && !Ae({
634
744
  record: e,
635
745
  omitSpec: r
636
746
  })) : [];
637
747
  }
638
- function F(e) {
748
+ function I(e) {
639
749
  let t = {};
640
750
  for (let [n, r] of e.entries()) t[n] = Array.from(r.values());
641
751
  return t;
642
752
  }
643
753
  //#endregion
644
754
  //#region src/document/query/get/attribute/get-attribute.ts
645
- async function Ie(e) {
646
- let { context: t, ref: n, name: r, namespace: i, defaults: a = "optional" } = e, o = await ge({
755
+ async function ze(e) {
756
+ let { context: t, ref: n, name: r, namespace: i, defaults: a } = e, o = await _e({
647
757
  context: t,
648
758
  ref: n
649
- }), s = o?.attributes ?? [], l = Re(t.dialecteConfig, r, i), u = s.find((e) => e.name === l);
650
- return u ? u.value : (o ? c({
651
- dialecteConfig: t.dialecteConfig,
759
+ });
760
+ if (!o) return "";
761
+ let { dialecteConfig: s } = t;
762
+ return S({
652
763
  record: o,
653
- attributeName: l,
764
+ dialecteConfig: s,
765
+ name: r,
766
+ namespace: i,
654
767
  defaults: a
655
- }) : void 0) ?? "";
768
+ });
656
769
  }
657
- async function Le(e) {
658
- let { context: t, ref: n, name: r, namespace: i, defaults: a = "optional" } = e, { dialecteConfig: o } = t, s = await ge({
770
+ async function Be(e) {
771
+ let { context: t, ref: n, name: r, namespace: i, defaults: a } = e, o = await _e({
659
772
  context: t,
660
773
  ref: n
661
- }), l = s?.attributes ?? [], u = Re(o, r, i), f = l.find((e) => e.name === u);
662
- if (f) return f;
663
- if (!s || a === "none") return;
664
- let p = c({
665
- dialecteConfig: o,
666
- record: s,
667
- attributeName: u,
668
- defaults: a
669
774
  });
670
- if (p === void 0) return;
671
- let { namespace: m } = d({
672
- dialecteConfig: o,
673
- record: s,
674
- attributeName: u
775
+ if (!o) return;
776
+ let { dialecteConfig: s } = t;
777
+ return S({
778
+ record: o,
779
+ dialecteConfig: s,
780
+ name: r,
781
+ namespace: i,
782
+ defaults: a,
783
+ fullObject: !0
675
784
  });
676
- return {
677
- name: u,
678
- value: p,
679
- namespace: m
680
- };
681
- }
682
- function Re(e, t, n) {
683
- if (n === void 0) return t;
684
- let r = u(e, n);
685
- return r ? `${r}:${t}` : t;
686
785
  }
687
786
  //#endregion
688
787
  //#region src/document/query/get/attribute/get-attributes.ts
689
- async function I(e) {
690
- let { context: t, ref: n, namespace: r, defaults: i = "optional" } = e, { dialecteConfig: a } = t, o = await ge({
788
+ async function Ve(e) {
789
+ let { context: t, ref: n, namespace: r, defaults: i } = e, a = await _e({
691
790
  context: t,
692
791
  ref: n
693
- }), s = o?.attributes ?? [], l = r === void 0 ? void 0 : u(a, r), d = s.reduce((e, t) => {
694
- let n = ze({
695
- name: t.name,
696
- namespace: t.namespace,
697
- targetPrefix: l
698
- });
699
- return n !== void 0 && (e[n] = t.value ?? ""), e;
700
- }, {});
701
- if (o && i !== "none") {
702
- let e = v({
703
- dialecteConfig: a,
704
- record: o
705
- })?.attributes.sequence ?? [];
706
- for (let t of e) {
707
- let e = ze({
708
- name: t,
709
- targetPrefix: l
710
- });
711
- if (e === void 0 || e in d) continue;
712
- let n = c({
713
- dialecteConfig: a,
714
- record: o,
715
- attributeName: t,
716
- defaults: i
717
- });
718
- n !== void 0 && (d[e] = n);
719
- }
720
- }
721
- return d;
722
- }
723
- function ze(e) {
724
- let { name: t, namespace: n, targetPrefix: r } = e, { prefix: i, local: a, isXmlns: o } = Ve(t);
725
- if (!(o || n?.uri === "http://www.w3.org/2000/xmlns/")) return r === void 0 ? t : i === r ? a : void 0;
792
+ });
793
+ if (!a) return {};
794
+ let { dialecteConfig: o } = t;
795
+ return C({
796
+ record: a,
797
+ dialecteConfig: o,
798
+ namespace: r,
799
+ defaults: i
800
+ });
726
801
  }
727
- async function Be(e) {
728
- let { context: t, ref: n, defaults: r = "optional" } = e, { dialecteConfig: i } = t, a = await ge({
802
+ async function He(e) {
803
+ let { context: t, ref: n, defaults: r } = e, i = await _e({
729
804
  context: t,
730
805
  ref: n
731
- }), o = [...a?.attributes ?? []];
732
- if (a && r !== "none") {
733
- let e = new Set(o.map((e) => e.name)), t = v({
734
- dialecteConfig: i,
735
- record: a
736
- })?.attributes.sequence ?? [];
737
- for (let n of t) {
738
- if (e.has(n)) continue;
739
- let t = c({
740
- dialecteConfig: i,
741
- record: a,
742
- attributeName: n,
743
- defaults: r
744
- });
745
- if (t === void 0) continue;
746
- let { namespace: s } = d({
747
- dialecteConfig: i,
748
- record: a,
749
- attributeName: n
750
- });
751
- o.push({
752
- name: n,
753
- value: t,
754
- namespace: s
755
- });
756
- }
757
- }
758
- return o;
759
- }
760
- function Ve(e) {
761
- if (e === "xmlns" || e.startsWith("xmlns:")) return {
762
- prefix: "",
763
- local: e,
764
- isXmlns: !0
765
- };
766
- let t = e.indexOf(":");
767
- return t === -1 ? {
768
- prefix: "",
769
- local: e,
770
- isXmlns: !1
771
- } : {
772
- prefix: e.slice(0, t),
773
- local: e.slice(t + 1),
774
- isXmlns: !1
775
- };
806
+ });
807
+ if (!i) return [];
808
+ let { dialecteConfig: a } = t;
809
+ return C({
810
+ record: i,
811
+ dialecteConfig: a,
812
+ defaults: r,
813
+ fullObject: !0
814
+ });
776
815
  }
777
816
  //#endregion
778
817
  //#region src/document/query/get/definition/get-definition.ts
779
- async function He(e) {
780
- let { context: t, ref: n } = e, r = await N({
818
+ async function Ue(e) {
819
+ let { context: t, ref: n } = e, r = await M({
781
820
  context: t,
782
821
  ref: n
783
822
  });
784
- if (r) return v({
823
+ if (r) return g({
785
824
  dialecteConfig: t.dialecteConfig,
786
825
  record: r
787
826
  });
788
827
  }
789
828
  //#endregion
790
829
  //#region src/document/query/tree-filter/unwrap.ts
791
- function Ue(e) {
830
+ function We(e) {
792
831
  let { tree: t, unwrapTagNames: n } = e;
793
832
  function r(e) {
794
833
  return e.flatMap((e) => n.includes(e.tagName) ? r(e.tree) : [{
@@ -803,7 +842,7 @@ function Ue(e) {
803
842
  }
804
843
  //#endregion
805
844
  //#region src/document/query/tree-filter/omit.ts
806
- function We(e) {
845
+ function Ge(e) {
807
846
  let { omit: t, dialecteConfig: n } = e, r = /* @__PURE__ */ new Set(), i = [];
808
847
  if (!t) return {
809
848
  dialecteConfig: n,
@@ -832,38 +871,38 @@ function We(e) {
832
871
  conditional: i
833
872
  };
834
873
  }
835
- function Ge(e) {
874
+ function Ke(e) {
836
875
  let { record: t, compiledOmit: n } = e;
837
- return n.unconditional.has(t.tagName) ? !0 : n.conditional.some((e) => e.scope === "self" && e.tagName === t.tagName && Se({
876
+ return n.unconditional.has(t.tagName) ? !0 : n.conditional.some((e) => e.scope === "self" && e.tagName === t.tagName && P({
838
877
  dialecteConfig: n.dialecteConfig,
839
878
  record: t,
840
879
  attributeFilter: e.where
841
880
  }));
842
881
  }
843
- function Ke(e) {
882
+ function qe(e) {
844
883
  let { record: t, compiledOmit: n } = e;
845
- return n.conditional.some((e) => e.scope === "children" && e.tagName === t.tagName && Se({
884
+ return n.conditional.some((e) => e.scope === "children" && e.tagName === t.tagName && P({
846
885
  dialecteConfig: n.dialecteConfig,
847
886
  record: t,
848
887
  attributeFilter: e.where
849
888
  }));
850
889
  }
851
- function qe(e) {
890
+ function Je(e) {
852
891
  let { tree: t, omit: n, dialecteConfig: r } = e;
853
892
  if (!n?.length) return t;
854
- let i = We({
893
+ let i = Ge({
855
894
  omit: n,
856
895
  dialecteConfig: r
857
896
  });
858
897
  function a(e) {
859
- if (Ke({
898
+ if (qe({
860
899
  record: e,
861
900
  compiledOmit: i
862
901
  })) return {
863
902
  ...e,
864
903
  tree: []
865
904
  };
866
- let t = e.tree.filter((e) => !Ge({
905
+ let t = e.tree.filter((e) => !Ke({
867
906
  record: e,
868
907
  compiledOmit: i
869
908
  })).map((e) => a(e));
@@ -876,11 +915,11 @@ function qe(e) {
876
915
  }
877
916
  //#endregion
878
917
  //#region src/document/query/tree-filter/order.ts
879
- function Je(e) {
918
+ function Ye(e) {
880
919
  let { tree: t, childrenConfig: n } = e;
881
920
  function r(e) {
882
921
  if (e.tree.length === 0) return e;
883
- let t = m({
922
+ let t = f({
884
923
  parentTagName: e.tagName,
885
924
  children: e.tree.map(r),
886
925
  childrenConfig: n
@@ -894,42 +933,34 @@ function Je(e) {
894
933
  }
895
934
  //#endregion
896
935
  //#region src/document/query/get/tree/get-tree.ts
897
- async function Ye(e) {
898
- let { context: t, ref: n, options: r = {}, dialecteConfig: i } = e, { select: a, omit: o, unwrap: s, depth: c } = r, l = c !== void 0 && n.id !== void 0 && t.stagedOperations.log.length === 0 ? await R(t, n, c) : await L(t), u = Xe(l, n);
899
- f(u, {
936
+ async function L(e) {
937
+ let { context: t, ref: n, options: r = {}, dialecteConfig: i } = e, { select: a, omit: o, unwrap: s, depth: c } = r, l = c !== void 0 && n.id !== void 0 && t.stagedOperations.log.length === 0 ? await R(t, n, c) : await Se(t), d = Xe(l, n);
938
+ u(d, {
900
939
  detail: "No record found for provided ref",
901
940
  key: "ELEMENT_NOT_FOUND"
902
941
  });
903
- let d = We({
942
+ let f = Ge({
904
943
  omit: o,
905
944
  dialecteConfig: t.dialecteConfig
906
945
  }), p = t.dialecteConfig.transparentElements, m = Ze({
907
946
  recordsById: l,
908
- record: u,
947
+ record: d,
909
948
  select: a,
910
- compiledOmit: d,
949
+ compiledOmit: f,
911
950
  dialecteConfig: i,
912
951
  transparentElements: p,
913
952
  remainingDepth: c ?? Infinity
914
953
  });
915
- if (!m) return ne({ record: u });
954
+ if (!m) return ne({ record: d });
916
955
  let h = s ?? (p?.length ? p : void 0);
917
- return Je({
918
- tree: h ? Ue({
956
+ return Ye({
957
+ tree: h ? We({
919
958
  tree: m,
920
959
  unwrapTagNames: h
921
960
  }) : m,
922
961
  childrenConfig: t.dialecteConfig.children
923
962
  });
924
963
  }
925
- async function L(e) {
926
- e.perf.count("core::store::getByDocumentId");
927
- let { live: t } = M({
928
- rawRecords: await e.store.getByDocumentId(e.documentId),
929
- stagedOperations: e.stagedOperations
930
- });
931
- return t;
932
- }
933
964
  async function R(e, t, n) {
934
965
  let r = /* @__PURE__ */ new Map();
935
966
  if (t.id === void 0) return r;
@@ -963,7 +994,7 @@ function Xe(e, t) {
963
994
  }
964
995
  function Ze(e) {
965
996
  let { recordsById: t, record: n, select: r, compiledOmit: i, dialecteConfig: a, transparentElements: o } = e;
966
- return e.remainingDepth <= 0 || Ke({
997
+ return e.remainingDepth <= 0 || qe({
967
998
  record: n,
968
999
  compiledOmit: i
969
1000
  }) ? ne({ record: n }) : ne({
@@ -1001,7 +1032,7 @@ function Qe(e) {
1001
1032
  transparentElements: o
1002
1033
  }));
1003
1034
  if (!c.length) return [];
1004
- let l = c.map((e) => t.get(e.id)).filter((e) => e !== void 0).filter((e) => !Ge({
1035
+ let l = c.map((e) => t.get(e.id)).filter((e) => e !== void 0).filter((e) => !Ke({
1005
1036
  record: e,
1006
1037
  compiledOmit: i
1007
1038
  }));
@@ -1072,7 +1103,7 @@ function nt(e) {
1072
1103
  }
1073
1104
  function rt(e) {
1074
1105
  let { child: t, select: n, dialecteConfig: r, filterConfig: i } = e;
1075
- if (!(!r || n.recursive === !1) && r.children[t.tagName]?.includes(t.tagName) && !(n.where && !Se({
1106
+ if (!(!r || n.recursive === !1) && r.children[t.tagName]?.includes(t.tagName) && !(n.where && !P({
1076
1107
  dialecteConfig: i,
1077
1108
  record: t,
1078
1109
  attributeFilter: n.where
@@ -1083,7 +1114,7 @@ function rt(e) {
1083
1114
  }
1084
1115
  function it(e) {
1085
1116
  let { child: t, entry: n, parentRecord: r, filterConfig: i } = e, a = n;
1086
- if (!(a.where && !Se({
1117
+ if (!(a.where && !P({
1087
1118
  dialecteConfig: i,
1088
1119
  record: t,
1089
1120
  attributeFilter: a.where
@@ -1124,24 +1155,24 @@ async function ot(e) {
1124
1155
  context: t,
1125
1156
  includeDeleted: a
1126
1157
  });
1127
- let o = e.siblings ?? !1, s = o === !0 || typeof o == "object" && !!o, c = typeof o == "object" && !!o && o.expand === !0, l = n ?? { tagName: t.dialecteConfig.rootElementName }, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), p = a ? he(t.stagedOperations.log) : void 0;
1158
+ let o = e.siblings ?? !1, s = o === !0 || typeof o == "object" && !!o, c = typeof o == "object" && !!o && o.expand === !0, l = n ?? { tagName: t.dialecteConfig.rootElementName }, d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a ? ge(t.stagedOperations.log) : void 0;
1128
1159
  function m(e) {
1129
- if (p) for (let t of p.get(e) ?? []) d.has(t.id) || (d.set(t.id, t), m(t.id));
1160
+ if (p) for (let t of p.get(e) ?? []) f.has(t.id) || (f.set(t.id, t), m(t.id));
1130
1161
  }
1131
1162
  async function h(e, n) {
1132
- if (u.set(e.id, e), m(e.id), !(i !== void 0 && n >= i)) for (let r of e.children) {
1133
- let e = await N({
1163
+ if (d.set(e.id, e), m(e.id), !(i !== void 0 && n >= i)) for (let r of e.children) {
1164
+ let e = await M({
1134
1165
  context: t,
1135
1166
  ref: T(r)
1136
1167
  });
1137
1168
  e && await h(e, n + 1);
1138
1169
  }
1139
1170
  }
1140
- let g = await N({
1171
+ let g = await M({
1141
1172
  context: t,
1142
1173
  ref: l
1143
1174
  });
1144
- f(g, {
1175
+ u(g, {
1145
1176
  key: "ELEMENT_NOT_FOUND",
1146
1177
  detail: "No record found for the provided ref"
1147
1178
  });
@@ -1149,7 +1180,7 @@ async function ot(e) {
1149
1180
  await h(g, 0);
1150
1181
  let v = Math.max(r, +!!s);
1151
1182
  if (v > 0) {
1152
- let e = await xe({
1183
+ let e = await N({
1153
1184
  context: t,
1154
1185
  ref: l,
1155
1186
  options: {
@@ -1157,30 +1188,30 @@ async function ot(e) {
1157
1188
  order: "bottom-up"
1158
1189
  }
1159
1190
  });
1160
- for (let t of e) u.set(t.id, t), _ = t.id;
1191
+ for (let t of e) d.set(t.id, t), _ = t.id;
1161
1192
  if (s) {
1162
1193
  let n = [g, ...e];
1163
1194
  for (let e = 0; e < n.length - 1; e++) {
1164
1195
  let r = n[e], i = n[e + 1];
1165
1196
  for (let e of i.children) {
1166
1197
  if (e.id === r.id) continue;
1167
- let n = await N({
1198
+ let n = await M({
1168
1199
  context: t,
1169
1200
  ref: T(e)
1170
1201
  });
1171
- n && (c ? await h(n, 0) : u.set(n.id, n));
1202
+ n && (c ? await h(n, 0) : d.set(n.id, n));
1172
1203
  }
1173
1204
  }
1174
1205
  }
1175
1206
  }
1176
1207
  return ct({
1177
- live: u,
1178
- deletedById: d,
1208
+ live: d,
1209
+ deletedById: f,
1179
1210
  rootId: _
1180
1211
  });
1181
1212
  }
1182
1213
  async function st(e) {
1183
- let { context: t, includeDeleted: n = !1 } = e, { live: r, deleted: i } = M({
1214
+ let { context: t, includeDeleted: n = !1 } = e, { live: r, deleted: i } = j({
1184
1215
  rawRecords: await t.store.getByDocumentId(t.documentId),
1185
1216
  stagedOperations: t.stagedOperations,
1186
1217
  includeDeleted: n
@@ -1189,7 +1220,7 @@ async function st(e) {
1189
1220
  a = e.id;
1190
1221
  break;
1191
1222
  }
1192
- return f(a, {
1223
+ return u(a, {
1193
1224
  key: "ROOT_NOT_FOUND",
1194
1225
  detail: `No ${t.dialecteConfig.rootElementName} root element found in document`
1195
1226
  }), ct({
@@ -1223,7 +1254,7 @@ function lt(e) {
1223
1254
  n.push(e), o.set(t, n);
1224
1255
  }
1225
1256
  let s = i.get(r);
1226
- f(s, {
1257
+ u(s, {
1227
1258
  key: "ROOT_NOT_FOUND",
1228
1259
  detail: `No record found for rootId "${r}"`
1229
1260
  });
@@ -1238,7 +1269,7 @@ function lt(e) {
1238
1269
  }
1239
1270
  //#endregion
1240
1271
  //#region node_modules/xml-parser-xo/dist/cjs/index.js
1241
- var ut = /* @__PURE__ */ O(((e, t) => {
1272
+ var ut = /* @__PURE__ */ D(((e, t) => {
1242
1273
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ParsingError = void 0;
1243
1274
  var n = class extends Error {
1244
1275
  constructor(e, t) {
@@ -1402,7 +1433,7 @@ var ut = /* @__PURE__ */ O(((e, t) => {
1402
1433
  }, o();
1403
1434
  }
1404
1435
  t !== void 0 && typeof e == "object" && (t.exports = v), e.default = v;
1405
- })), z = /* @__PURE__ */ O(((e, t) => {
1436
+ })), z = /* @__PURE__ */ D(((e, t) => {
1406
1437
  var n = e && e.__importDefault || function(e) {
1407
1438
  return e && e.__esModule ? e : { default: e };
1408
1439
  };
@@ -1496,7 +1527,7 @@ var ut = /* @__PURE__ */ O(((e, t) => {
1496
1527
  indentation: "",
1497
1528
  lineSeparator: ""
1498
1529
  })), t !== void 0 && typeof e == "object" && (t.exports = p), e.default = p;
1499
- })), dt = /* @__PURE__ */ k(z(), 1);
1530
+ })), dt = /* @__PURE__ */ O(z(), 1);
1500
1531
  function ft(e) {
1501
1532
  return (0, dt.default)(e);
1502
1533
  }
@@ -1513,7 +1544,7 @@ function mt(e, t = {}) {
1513
1544
  //#region src/xml/build/download-file.ts
1514
1545
  async function ht(e) {
1515
1546
  let { extension: t, xmlDocument: n, filename: r } = e, i = mt(n);
1516
- await h({
1547
+ await p({
1517
1548
  data: new Blob([i], { type: "application/xml" }),
1518
1549
  filename: r,
1519
1550
  pickerType: {
@@ -1528,19 +1559,19 @@ function gt(e) {
1528
1559
  let { records: t, config: n, withDatabaseIds: r = !1, rootId: i, declareNamespaces: a = !0 } = e, o = /* @__PURE__ */ new Map(), s;
1529
1560
  for (let e of t) o.set(e.id, e), e.tagName === n.rootElementName && (s = e);
1530
1561
  let c = i ? o.get(i) : s;
1531
- f(c, {
1562
+ u(c, {
1532
1563
  detail: i ? `No record found for rootId "${i}"` : `No ${n.rootElementName} root element found in records`,
1533
1564
  key: "EXPORT_ROOT_NOT_FOUND"
1534
1565
  });
1535
- let l = c.tagName === n.rootElementName ? c : void 0, u = n.namespaces.default, d = document.implementation.createDocument(u.uri, null, null), p = vt({
1536
- document: d,
1566
+ let l = c.tagName === n.rootElementName ? c : void 0, d = n.namespaces.default, f = document.implementation.createDocument(d.uri, null, null), p = vt({
1567
+ document: f,
1537
1568
  record: c,
1538
- defaultNamespace: u,
1569
+ defaultNamespace: d,
1539
1570
  declareNamespaces: a
1540
1571
  });
1541
1572
  return a && p.setAttribute("xmlns", c.namespace.uri), c.attributes && bt({
1542
1573
  config: n,
1543
- document: d,
1574
+ document: f,
1544
1575
  element: p,
1545
1576
  attributes: c.attributes,
1546
1577
  isRoot: !0,
@@ -1551,7 +1582,7 @@ function gt(e) {
1551
1582
  rootElement: p,
1552
1583
  namespace: c.namespace,
1553
1584
  rootRecord: l
1554
- }), c.value && (p.textContent = c.value.trim()), r && p.setAttribute(pt, c.id), d.appendChild(p), a && B({
1585
+ }), c.value && (p.textContent = c.value.trim()), r && p.setAttribute(pt, c.id), f.appendChild(p), a && B({
1555
1586
  config: n,
1556
1587
  element: p,
1557
1588
  record: c,
@@ -1560,12 +1591,12 @@ function gt(e) {
1560
1591
  index: o,
1561
1592
  config: n,
1562
1593
  withDatabaseIds: r,
1563
- xmlDocument: d,
1594
+ xmlDocument: f,
1564
1595
  parentRecord: c,
1565
1596
  parentElement: p,
1566
1597
  documentRoot: l,
1567
1598
  declareNamespaces: a
1568
- }), d;
1599
+ }), f;
1569
1600
  }
1570
1601
  function _t(e) {
1571
1602
  let { index: t, config: n, withDatabaseIds: r, xmlDocument: i, parentRecord: a, parentElement: o, documentRoot: s, declareNamespaces: c } = e;
@@ -1573,7 +1604,7 @@ function _t(e) {
1573
1604
  let l = [];
1574
1605
  for (let e of a.children) {
1575
1606
  let n = t.get(e.id);
1576
- f(n, {
1607
+ u(n, {
1577
1608
  detail: `Parent '${a.tagName}' references non-existent child '${e.tagName}' (id: ${e.id})`,
1578
1609
  key: "EXPORT_ORPHAN_CHILD_REF",
1579
1610
  ref: {
@@ -1582,12 +1613,12 @@ function _t(e) {
1582
1613
  }
1583
1614
  }), l.push(n);
1584
1615
  }
1585
- let u = m({
1616
+ let d = f({
1586
1617
  parentTagName: a.tagName,
1587
1618
  children: l,
1588
1619
  childrenConfig: n.children
1589
1620
  });
1590
- for (let e of u) {
1621
+ for (let e of d) {
1591
1622
  let a = yt({
1592
1623
  config: n,
1593
1624
  document: i,
@@ -1655,7 +1686,7 @@ function bt(e) {
1655
1686
  r.setAttribute(e.name, String(e.value));
1656
1687
  continue;
1657
1688
  }
1658
- let i = p(e.name);
1689
+ let i = d(e.name);
1659
1690
  if (!s) {
1660
1691
  r.setAttribute(`${e.namespace.prefix}:${i}`, String(e.value));
1661
1692
  continue;
@@ -1711,7 +1742,7 @@ function St(t) {
1711
1742
  }));
1712
1743
  }
1713
1744
  function Ct(e) {
1714
- let { config: t, rootElement: n, namespace: r, rootRecord: i } = e, a = v({
1745
+ let { config: t, rootElement: n, namespace: r, rootRecord: i } = e, a = g({
1715
1746
  dialecteConfig: t,
1716
1747
  record: i
1717
1748
  })?.attributes.details ?? {}, o = Object.entries(a).filter(([e, n]) => c({
@@ -1721,7 +1752,7 @@ function Ct(e) {
1721
1752
  defaults: "required"
1722
1753
  }) === void 0 ? !1 : r.uri === t.namespaces.default.uri ? !n.namespace : n.namespace?.prefix === r.prefix && n.namespace?.uri === r.uri);
1723
1754
  if (o.length > 0) for (let [e, r] of o) {
1724
- let a = p(e), o = c({
1755
+ let a = d(e), o = c({
1725
1756
  dialecteConfig: t,
1726
1757
  record: i,
1727
1758
  attributeName: e,
@@ -1736,7 +1767,7 @@ function Ct(e) {
1736
1767
  function wt(e) {
1737
1768
  let { config: t, document: n, element: r, record: i, documentRoot: a, declareNamespaces: o } = e;
1738
1769
  if (!o) return;
1739
- let s = v({
1770
+ let s = g({
1740
1771
  dialecteConfig: t,
1741
1772
  record: i
1742
1773
  })?.attributes.details;
@@ -1748,7 +1779,7 @@ function wt(e) {
1748
1779
  defaults: "required"
1749
1780
  });
1750
1781
  if (s === void 0) continue;
1751
- let u = p(e);
1782
+ let u = d(e);
1752
1783
  (l.namespace ? r.hasAttributeNS(l.namespace.uri, u) : r.hasAttribute(u)) || (l.namespace && l.namespace.prefix && l.namespace.prefix !== "xmlns" ? (o && St({
1753
1784
  config: t,
1754
1785
  document: n,
@@ -1765,9 +1796,9 @@ function Et(e) {
1765
1796
  }
1766
1797
  //#endregion
1767
1798
  //#region __vite-browser-external
1768
- var Dt = /* @__PURE__ */ O(((e, t) => {
1799
+ var Dt = /* @__PURE__ */ D(((e, t) => {
1769
1800
  t.exports = {};
1770
- })), V = /* @__PURE__ */ k((/* @__PURE__ */ O(((e) => {
1801
+ })), V = /* @__PURE__ */ O((/* @__PURE__ */ D(((e) => {
1771
1802
  (function(e) {
1772
1803
  e.parser = function(e, t) {
1773
1804
  return new n(e, t);
@@ -1824,7 +1855,7 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
1824
1855
  var s = n[t[a]].length;
1825
1856
  if (s > r) switch (t[a]) {
1826
1857
  case "textNode":
1827
- D(n);
1858
+ oe(n);
1828
1859
  break;
1829
1860
  case "cdata":
1830
1861
  E(n, "oncdata", n.cdata), n.cdata = "";
@@ -1832,7 +1863,7 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
1832
1863
  case "script":
1833
1864
  E(n, "onscript", n.script), n.script = "";
1834
1865
  break;
1835
- default: O(n, "Max buffer length exceeded: " + t[a]);
1866
+ default: D(n, "Max buffer length exceeded: " + t[a]);
1836
1867
  }
1837
1868
  i = Math.max(i, s);
1838
1869
  }
@@ -1842,13 +1873,13 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
1842
1873
  for (var n = 0, r = t.length; n < r; n++) e[t[n]] = "";
1843
1874
  }
1844
1875
  function a(e) {
1845
- D(e), e.cdata !== "" && (E(e, "oncdata", e.cdata), e.cdata = ""), e.script !== "" && (E(e, "onscript", e.script), e.script = "");
1876
+ oe(e), e.cdata !== "" && (E(e, "oncdata", e.cdata), e.cdata = ""), e.script !== "" && (E(e, "onscript", e.script), e.script = "");
1846
1877
  }
1847
1878
  n.prototype = {
1848
1879
  end: function() {
1849
- se(this);
1880
+ ce(this);
1850
1881
  },
1851
- write: me,
1882
+ write: he,
1852
1883
  resume: function() {
1853
1884
  return this.error = null, this;
1854
1885
  },
@@ -2270,29 +2301,29 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2270
2301
  function ae(e, t) {
2271
2302
  if (!(!e.strict || !e.encoding || !t || t.name !== "xml")) {
2272
2303
  var n = ne(t.body);
2273
- n && !ie(e.encoding, n) && k(e, "XML declaration encoding " + n + " does not match detected stream encoding " + e.encoding.toUpperCase());
2304
+ n && !ie(e.encoding, n) && O(e, "XML declaration encoding " + n + " does not match detected stream encoding " + e.encoding.toUpperCase());
2274
2305
  }
2275
2306
  }
2276
2307
  function E(e, t, n) {
2277
- e.textNode && D(e), T(e, t, n);
2308
+ e.textNode && oe(e), T(e, t, n);
2278
2309
  }
2279
- function D(e) {
2280
- e.textNode = oe(e.opt, e.textNode), e.textNode && T(e, "ontext", e.textNode), e.textNode = "";
2310
+ function oe(e) {
2311
+ e.textNode = se(e.opt, e.textNode), e.textNode && T(e, "ontext", e.textNode), e.textNode = "";
2281
2312
  }
2282
- function oe(e, t) {
2313
+ function se(e, t) {
2283
2314
  return e.trim && (t = t.trim()), e.normalize && (t = t.replace(/\s+/g, " ")), t;
2284
2315
  }
2285
- function O(e, t) {
2286
- return D(e), e.trackPosition && (t += "\nLine: " + e.line + "\nColumn: " + e.column + "\nChar: " + e.c), t = Error(t), e.error = t, T(e, "onerror", t), e;
2316
+ function D(e, t) {
2317
+ return oe(e), e.trackPosition && (t += "\nLine: " + e.line + "\nColumn: " + e.column + "\nChar: " + e.c), t = Error(t), e.error = t, T(e, "onerror", t), e;
2287
2318
  }
2288
- function se(e) {
2289
- return e.sawRoot && !e.closedRoot && k(e, "Unclosed root tag"), e.state !== w.BEGIN && e.state !== w.BEGIN_WHITESPACE && e.state !== w.TEXT && O(e, "Unexpected end"), D(e), e.c = "", e.closed = !0, T(e, "onend"), n.call(e, e.strict, e.opt), e;
2319
+ function ce(e) {
2320
+ return e.sawRoot && !e.closedRoot && O(e, "Unclosed root tag"), e.state !== w.BEGIN && e.state !== w.BEGIN_WHITESPACE && e.state !== w.TEXT && D(e, "Unexpected end"), oe(e), e.c = "", e.closed = !0, T(e, "onend"), n.call(e, e.strict, e.opt), e;
2290
2321
  }
2291
- function k(e, t) {
2322
+ function O(e, t) {
2292
2323
  if (typeof e != "object" || !(e instanceof n)) throw Error("bad call to strictFail");
2293
- e.strict && O(e, t);
2324
+ e.strict && D(e, t);
2294
2325
  }
2295
- function ce(e) {
2326
+ function le(e) {
2296
2327
  e.strict || (e.tagName = e.tagName[e.looseCase]());
2297
2328
  var t = e.tags[e.tags.length - 1] || e, n = e.tag = {
2298
2329
  name: e.tagName,
@@ -2300,22 +2331,22 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2300
2331
  };
2301
2332
  e.opt.xmlns && (n.ns = t.ns), e.attribList.length = 0, E(e, "onopentagstart", n);
2302
2333
  }
2303
- function le(e, t) {
2334
+ function ue(e, t) {
2304
2335
  var n = e.indexOf(":") < 0 ? ["", e] : e.split(":"), r = n[0], i = n[1];
2305
2336
  return t && e === "xmlns" && (r = "xmlns", i = ""), {
2306
2337
  prefix: r,
2307
2338
  local: i
2308
2339
  };
2309
2340
  }
2310
- function ue(e) {
2341
+ function de(e) {
2311
2342
  if (e.strict || (e.attribName = e.attribName[e.looseCase]()), e.attribList.indexOf(e.attribName) !== -1 || e.tag.attributes.hasOwnProperty(e.attribName)) {
2312
2343
  e.attribName = e.attribValue = "";
2313
2344
  return;
2314
2345
  }
2315
2346
  if (e.opt.xmlns) {
2316
- var t = le(e.attribName, !0), n = t.prefix, r = t.local;
2317
- if (n === "xmlns") if (r === "xml" && e.attribValue !== p) k(e, "xml: prefix must be bound to " + p + "\nActual: " + e.attribValue);
2318
- else if (r === "xmlns" && e.attribValue !== m) k(e, "xmlns: prefix must be bound to " + m + "\nActual: " + e.attribValue);
2347
+ var t = ue(e.attribName, !0), n = t.prefix, r = t.local;
2348
+ if (n === "xmlns") if (r === "xml" && e.attribValue !== p) O(e, "xml: prefix must be bound to " + p + "\nActual: " + e.attribValue);
2349
+ else if (r === "xmlns" && e.attribValue !== m) O(e, "xmlns: prefix must be bound to " + m + "\nActual: " + e.attribValue);
2319
2350
  else {
2320
2351
  var i = e.tag, a = e.tags[e.tags.length - 1] || e;
2321
2352
  i.ns === a.ns && (i.ns = Object.create(a.ns)), i.ns[r] = e.attribValue;
@@ -2327,10 +2358,10 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2327
2358
  });
2328
2359
  e.attribName = e.attribValue = "";
2329
2360
  }
2330
- function de(e, t) {
2361
+ function fe(e, t) {
2331
2362
  if (e.opt.xmlns) {
2332
- var n = e.tag, r = le(e.tagName);
2333
- n.prefix = r.prefix, n.local = r.local, n.uri = n.ns[r.prefix] || "", n.prefix && !n.uri && (k(e, "Unbound namespace prefix: " + JSON.stringify(e.tagName)), n.uri = r.prefix);
2363
+ var n = e.tag, r = ue(e.tagName);
2364
+ n.prefix = r.prefix, n.local = r.local, n.uri = n.ns[r.prefix] || "", n.prefix && !n.uri && (O(e, "Unbound namespace prefix: " + JSON.stringify(e.tagName)), n.uri = r.prefix);
2334
2365
  var i = e.tags[e.tags.length - 1] || e;
2335
2366
  n.ns && i.ns !== n.ns && Object.keys(n.ns).forEach(function(t) {
2336
2367
  E(e, "onopennamespace", {
@@ -2339,22 +2370,22 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2339
2370
  });
2340
2371
  });
2341
2372
  for (var a = 0, o = e.attribList.length; a < o; a++) {
2342
- var s = e.attribList[a], c = s[0], l = s[1], u = le(c, !0), d = u.prefix, f = u.local, p = d === "" ? "" : n.ns[d] || "", m = {
2373
+ var s = e.attribList[a], c = s[0], l = s[1], u = ue(c, !0), d = u.prefix, f = u.local, p = d === "" ? "" : n.ns[d] || "", m = {
2343
2374
  name: c,
2344
2375
  value: l,
2345
2376
  prefix: d,
2346
2377
  local: f,
2347
2378
  uri: p
2348
2379
  };
2349
- d && d !== "xmlns" && !p && (k(e, "Unbound namespace prefix: " + JSON.stringify(d)), m.uri = d), e.tag.attributes[c] = m, E(e, "onattribute", m);
2380
+ d && d !== "xmlns" && !p && (O(e, "Unbound namespace prefix: " + JSON.stringify(d)), m.uri = d), e.tag.attributes[c] = m, E(e, "onattribute", m);
2350
2381
  }
2351
2382
  e.attribList.length = 0;
2352
2383
  }
2353
2384
  e.tag.isSelfClosing = !!t, e.sawRoot = !0, e.tags.push(e.tag), E(e, "onopentag", e.tag), t || (!e.noscript && e.tagName.toLowerCase() === "script" ? e.state = w.SCRIPT : e.state = w.TEXT, e.tag = null, e.tagName = ""), e.attribName = e.attribValue = "", e.attribList.length = 0;
2354
2385
  }
2355
- function A(e) {
2386
+ function k(e) {
2356
2387
  if (!e.tagName) {
2357
- k(e, "Weird empty close tag."), e.textNode += "</>", e.state = w.TEXT;
2388
+ O(e, "Weird empty close tag."), e.textNode += "</>", e.state = w.TEXT;
2358
2389
  return;
2359
2390
  }
2360
2391
  if (e.script) {
@@ -2366,9 +2397,9 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2366
2397
  }
2367
2398
  var t = e.tags.length, n = e.tagName;
2368
2399
  e.strict || (n = n[e.looseCase]());
2369
- for (var r = n; t-- && e.tags[t].name !== r;) k(e, "Unexpected close tag");
2400
+ for (var r = n; t-- && e.tags[t].name !== r;) O(e, "Unexpected close tag");
2370
2401
  if (t < 0) {
2371
- k(e, "Unmatched closing tag: " + e.tagName), e.textNode += "</" + e.tagName + ">", e.state = w.TEXT;
2402
+ O(e, "Unmatched closing tag: " + e.tagName), e.textNode += "</" + e.tagName + ">", e.state = w.TEXT;
2372
2403
  return;
2373
2404
  }
2374
2405
  e.tagName = n;
@@ -2388,37 +2419,37 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2388
2419
  }
2389
2420
  t === 0 && (e.closedRoot = !0), e.tagName = e.attribValue = e.attribName = "", e.attribList.length = 0, e.state = w.TEXT;
2390
2421
  }
2391
- function fe(e) {
2422
+ function pe(e) {
2392
2423
  var t = e.entity, n = t.toLowerCase(), r, i = "";
2393
- return e.ENTITIES[t] ? e.ENTITIES[t] : e.ENTITIES[n] ? e.ENTITIES[n] : (t = n, t.charAt(0) === "#" && (t.charAt(1) === "x" ? (t = t.slice(2), r = parseInt(t, 16), i = r.toString(16)) : (t = t.slice(1), r = parseInt(t, 10), i = r.toString(10))), t = t.replace(/^0+/, ""), isNaN(r) || i.toLowerCase() !== t || r < 0 || r > 1114111 ? (k(e, "Invalid character entity"), "&" + e.entity + ";") : String.fromCodePoint(r));
2424
+ return e.ENTITIES[t] ? e.ENTITIES[t] : e.ENTITIES[n] ? e.ENTITIES[n] : (t = n, t.charAt(0) === "#" && (t.charAt(1) === "x" ? (t = t.slice(2), r = parseInt(t, 16), i = r.toString(16)) : (t = t.slice(1), r = parseInt(t, 10), i = r.toString(10))), t = t.replace(/^0+/, ""), isNaN(r) || i.toLowerCase() !== t || r < 0 || r > 1114111 ? (O(e, "Invalid character entity"), "&" + e.entity + ";") : String.fromCodePoint(r));
2394
2425
  }
2395
- function pe(e, t) {
2396
- t === "<" ? (e.state = w.OPEN_WAKA, e.startTagPosition = e.position) : b(t) || (k(e, "Non-whitespace before first tag."), e.textNode = t, e.state = w.TEXT);
2426
+ function me(e, t) {
2427
+ t === "<" ? (e.state = w.OPEN_WAKA, e.startTagPosition = e.position) : b(t) || (O(e, "Non-whitespace before first tag."), e.textNode = t, e.state = w.TEXT);
2397
2428
  }
2398
- function j(e, t) {
2429
+ function A(e, t) {
2399
2430
  var n = "";
2400
2431
  return t < e.length && (n = e.charAt(t)), n;
2401
2432
  }
2402
- function me(t) {
2433
+ function he(t) {
2403
2434
  var n = this;
2404
2435
  if (this.error) throw this.error;
2405
- if (n.closed) return O(n, "Cannot write after close. Assign an onready handler.");
2406
- if (t === null) return se(n);
2436
+ if (n.closed) return D(n, "Cannot write after close. Assign an onready handler.");
2437
+ if (t === null) return ce(n);
2407
2438
  typeof t == "object" && (t = t.toString());
2408
- for (var i = 0, a = ""; a = j(t, i++), n.c = a, a;) switch (n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++), n.state) {
2439
+ for (var i = 0, a = ""; a = A(t, i++), n.c = a, a;) switch (n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++), n.state) {
2409
2440
  case w.BEGIN:
2410
2441
  if (n.state = w.BEGIN_WHITESPACE, a === "") continue;
2411
- pe(n, a);
2442
+ me(n, a);
2412
2443
  continue;
2413
2444
  case w.BEGIN_WHITESPACE:
2414
- pe(n, a);
2445
+ me(n, a);
2415
2446
  continue;
2416
2447
  case w.TEXT:
2417
2448
  if (n.sawRoot && !n.closedRoot) {
2418
- for (var o = i - 1; a && a !== "<" && a !== "&";) a = j(t, i++), a && n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++);
2449
+ for (var o = i - 1; a && a !== "<" && a !== "&";) a = A(t, i++), a && n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++);
2419
2450
  n.textNode += t.substring(o, i - 1);
2420
2451
  }
2421
- a === "<" && !(n.sawRoot && n.closedRoot && !n.strict) ? (n.state = w.OPEN_WAKA, n.startTagPosition = n.position) : (!b(a) && (!n.sawRoot || n.closedRoot) && k(n, "Text data outside of root node."), a === "&" ? n.state = w.TEXT_ENTITY : n.textNode += a);
2452
+ a === "<" && !(n.sawRoot && n.closedRoot && !n.strict) ? (n.state = w.OPEN_WAKA, n.startTagPosition = n.position) : (!b(a) && (!n.sawRoot || n.closedRoot) && O(n, "Text data outside of root node."), a === "&" ? n.state = w.TEXT_ENTITY : n.textNode += a);
2422
2453
  continue;
2423
2454
  case w.SCRIPT:
2424
2455
  a === "<" ? n.state = w.SCRIPT_ENDING : n.script += a;
@@ -2432,7 +2463,7 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2432
2463
  else if (a === "/") n.state = w.CLOSE_TAG, n.tagName = "";
2433
2464
  else if (a === "?") n.state = w.PROC_INST, n.procInstName = n.procInstBody = "";
2434
2465
  else {
2435
- if (k(n, "Unencoded <"), n.startTagPosition + 1 < n.position) {
2466
+ if (O(n, "Unencoded <"), n.startTagPosition + 1 < n.position) {
2436
2467
  var s = n.position - n.startTagPosition;
2437
2468
  a = Array(s).join(" ") + a;
2438
2469
  }
@@ -2444,7 +2475,7 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2444
2475
  n.state = w.COMMENT, n.comment = "", n.sgmlDecl = "";
2445
2476
  continue;
2446
2477
  }
2447
- n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = w.DOCTYPE_DTD, n.doctype += "<!" + n.sgmlDecl + a, n.sgmlDecl = "") : (n.sgmlDecl + a).toUpperCase() === d ? (E(n, "onopencdata"), n.state = w.CDATA, n.sgmlDecl = "", n.cdata = "") : (n.sgmlDecl + a).toUpperCase() === f ? (n.state = w.DOCTYPE, (n.doctype || n.sawRoot) && k(n, "Inappropriately located doctype declaration"), n.doctype = "", n.sgmlDecl = "") : a === ">" ? (E(n, "onsgmldeclaration", n.sgmlDecl), n.sgmlDecl = "", n.state = w.TEXT) : (x(a) && (n.state = w.SGML_DECL_QUOTED), n.sgmlDecl += a);
2478
+ n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = w.DOCTYPE_DTD, n.doctype += "<!" + n.sgmlDecl + a, n.sgmlDecl = "") : (n.sgmlDecl + a).toUpperCase() === d ? (E(n, "onopencdata"), n.state = w.CDATA, n.sgmlDecl = "", n.cdata = "") : (n.sgmlDecl + a).toUpperCase() === f ? (n.state = w.DOCTYPE, (n.doctype || n.sawRoot) && O(n, "Inappropriately located doctype declaration"), n.doctype = "", n.sgmlDecl = "") : a === ">" ? (E(n, "onsgmldeclaration", n.sgmlDecl), n.sgmlDecl = "", n.state = w.TEXT) : (x(a) && (n.state = w.SGML_DECL_QUOTED), n.sgmlDecl += a);
2448
2479
  continue;
2449
2480
  case w.SGML_DECL_QUOTED:
2450
2481
  a === n.q && (n.state = w.SGML_DECL, n.q = ""), n.sgmlDecl += a;
@@ -2465,13 +2496,13 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2465
2496
  a === "-" ? n.state = w.COMMENT_ENDING : n.comment += a;
2466
2497
  continue;
2467
2498
  case w.COMMENT_ENDING:
2468
- a === "-" ? (n.state = w.COMMENT_ENDED, n.comment = oe(n.opt, n.comment), n.comment && E(n, "oncomment", n.comment), n.comment = "") : (n.comment += "-" + a, n.state = w.COMMENT);
2499
+ a === "-" ? (n.state = w.COMMENT_ENDED, n.comment = se(n.opt, n.comment), n.comment && E(n, "oncomment", n.comment), n.comment = "") : (n.comment += "-" + a, n.state = w.COMMENT);
2469
2500
  continue;
2470
2501
  case w.COMMENT_ENDED:
2471
- a === ">" ? n.doctype && n.doctype !== !0 ? n.state = w.DOCTYPE_DTD : n.state = w.TEXT : (k(n, "Malformed comment"), n.comment += "--" + a, n.state = w.COMMENT);
2502
+ a === ">" ? n.doctype && n.doctype !== !0 ? n.state = w.DOCTYPE_DTD : n.state = w.TEXT : (O(n, "Malformed comment"), n.comment += "--" + a, n.state = w.COMMENT);
2472
2503
  continue;
2473
2504
  case w.CDATA:
2474
- for (var o = i - 1; a && a !== "]";) a = j(t, i++), a && n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++);
2505
+ for (var o = i - 1; a && a !== "]";) a = A(t, i++), a && n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++);
2475
2506
  n.cdata += t.substring(o, i - 1), a === "]" && (n.state = w.CDATA_ENDING);
2476
2507
  continue;
2477
2508
  case w.CDATA_ENDING:
@@ -2497,57 +2528,57 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2497
2528
  } else n.procInstBody += "?" + a, n.state = w.PROC_INST_BODY;
2498
2529
  continue;
2499
2530
  case w.OPEN_TAG:
2500
- C(_, a) ? n.tagName += a : (ce(n), a === ">" ? de(n) : a === "/" ? n.state = w.OPEN_TAG_SLASH : (b(a) || k(n, "Invalid character in tag name"), n.state = w.ATTRIB));
2531
+ C(_, a) ? n.tagName += a : (le(n), a === ">" ? fe(n) : a === "/" ? n.state = w.OPEN_TAG_SLASH : (b(a) || O(n, "Invalid character in tag name"), n.state = w.ATTRIB));
2501
2532
  continue;
2502
2533
  case w.OPEN_TAG_SLASH:
2503
- a === ">" ? (de(n, !0), A(n)) : (k(n, "Forward-slash in opening tag not followed by >"), n.state = w.ATTRIB);
2534
+ a === ">" ? (fe(n, !0), k(n)) : (O(n, "Forward-slash in opening tag not followed by >"), n.state = w.ATTRIB);
2504
2535
  continue;
2505
2536
  case w.ATTRIB:
2506
2537
  if (b(a)) continue;
2507
- a === ">" ? de(n) : a === "/" ? n.state = w.OPEN_TAG_SLASH : C(g, a) ? (n.attribName = a, n.attribValue = "", n.state = w.ATTRIB_NAME) : k(n, "Invalid attribute name");
2538
+ a === ">" ? fe(n) : a === "/" ? n.state = w.OPEN_TAG_SLASH : C(g, a) ? (n.attribName = a, n.attribValue = "", n.state = w.ATTRIB_NAME) : O(n, "Invalid attribute name");
2508
2539
  continue;
2509
2540
  case w.ATTRIB_NAME:
2510
- a === "=" ? n.state = w.ATTRIB_VALUE : a === ">" ? (k(n, "Attribute without value"), n.attribValue = n.attribName, ue(n), de(n)) : b(a) ? n.state = w.ATTRIB_NAME_SAW_WHITE : C(_, a) ? n.attribName += a : k(n, "Invalid attribute name");
2541
+ a === "=" ? n.state = w.ATTRIB_VALUE : a === ">" ? (O(n, "Attribute without value"), n.attribValue = n.attribName, de(n), fe(n)) : b(a) ? n.state = w.ATTRIB_NAME_SAW_WHITE : C(_, a) ? n.attribName += a : O(n, "Invalid attribute name");
2511
2542
  continue;
2512
2543
  case w.ATTRIB_NAME_SAW_WHITE:
2513
2544
  if (a === "=") n.state = w.ATTRIB_VALUE;
2514
2545
  else if (b(a)) continue;
2515
- else k(n, "Attribute without value"), n.tag.attributes[n.attribName] = "", n.attribValue = "", E(n, "onattribute", {
2546
+ else O(n, "Attribute without value"), n.tag.attributes[n.attribName] = "", n.attribValue = "", E(n, "onattribute", {
2516
2547
  name: n.attribName,
2517
2548
  value: ""
2518
- }), n.attribName = "", a === ">" ? de(n) : C(g, a) ? (n.attribName = a, n.state = w.ATTRIB_NAME) : (k(n, "Invalid attribute name"), n.state = w.ATTRIB);
2549
+ }), n.attribName = "", a === ">" ? fe(n) : C(g, a) ? (n.attribName = a, n.state = w.ATTRIB_NAME) : (O(n, "Invalid attribute name"), n.state = w.ATTRIB);
2519
2550
  continue;
2520
2551
  case w.ATTRIB_VALUE:
2521
2552
  if (b(a)) continue;
2522
- x(a) ? (n.q = a, n.state = w.ATTRIB_VALUE_QUOTED) : (n.opt.unquotedAttributeValues || O(n, "Unquoted attribute value"), n.state = w.ATTRIB_VALUE_UNQUOTED, n.attribValue = a);
2553
+ x(a) ? (n.q = a, n.state = w.ATTRIB_VALUE_QUOTED) : (n.opt.unquotedAttributeValues || D(n, "Unquoted attribute value"), n.state = w.ATTRIB_VALUE_UNQUOTED, n.attribValue = a);
2523
2554
  continue;
2524
2555
  case w.ATTRIB_VALUE_QUOTED:
2525
2556
  if (a !== n.q) {
2526
2557
  a === "&" ? n.state = w.ATTRIB_VALUE_ENTITY_Q : n.attribValue += a;
2527
2558
  continue;
2528
2559
  }
2529
- ue(n), n.q = "", n.state = w.ATTRIB_VALUE_CLOSED;
2560
+ de(n), n.q = "", n.state = w.ATTRIB_VALUE_CLOSED;
2530
2561
  continue;
2531
2562
  case w.ATTRIB_VALUE_CLOSED:
2532
- b(a) ? n.state = w.ATTRIB : a === ">" ? de(n) : a === "/" ? n.state = w.OPEN_TAG_SLASH : C(g, a) ? (k(n, "No whitespace between attributes"), n.attribName = a, n.attribValue = "", n.state = w.ATTRIB_NAME) : k(n, "Invalid attribute name");
2563
+ b(a) ? n.state = w.ATTRIB : a === ">" ? fe(n) : a === "/" ? n.state = w.OPEN_TAG_SLASH : C(g, a) ? (O(n, "No whitespace between attributes"), n.attribName = a, n.attribValue = "", n.state = w.ATTRIB_NAME) : O(n, "Invalid attribute name");
2533
2564
  continue;
2534
2565
  case w.ATTRIB_VALUE_UNQUOTED:
2535
2566
  if (!S(a)) {
2536
2567
  a === "&" ? n.state = w.ATTRIB_VALUE_ENTITY_U : n.attribValue += a;
2537
2568
  continue;
2538
2569
  }
2539
- ue(n), a === ">" ? de(n) : n.state = w.ATTRIB;
2570
+ de(n), a === ">" ? fe(n) : n.state = w.ATTRIB;
2540
2571
  continue;
2541
2572
  case w.CLOSE_TAG:
2542
- if (n.tagName) a === ">" ? A(n) : C(_, a) ? n.tagName += a : n.script ? (n.script += "</" + n.tagName + a, n.tagName = "", n.state = w.SCRIPT) : (b(a) || k(n, "Invalid tagname in closing tag"), n.state = w.CLOSE_TAG_SAW_WHITE);
2573
+ if (n.tagName) a === ">" ? k(n) : C(_, a) ? n.tagName += a : n.script ? (n.script += "</" + n.tagName + a, n.tagName = "", n.state = w.SCRIPT) : (b(a) || O(n, "Invalid tagname in closing tag"), n.state = w.CLOSE_TAG_SAW_WHITE);
2543
2574
  else {
2544
2575
  if (b(a)) continue;
2545
- ee(g, a) ? n.script ? (n.script += "</" + a, n.state = w.SCRIPT) : k(n, "Invalid tagname in closing tag.") : n.tagName = a;
2576
+ ee(g, a) ? n.script ? (n.script += "</" + a, n.state = w.SCRIPT) : O(n, "Invalid tagname in closing tag.") : n.tagName = a;
2546
2577
  }
2547
2578
  continue;
2548
2579
  case w.CLOSE_TAG_SAW_WHITE:
2549
2580
  if (b(a)) continue;
2550
- a === ">" ? A(n) : k(n, "Invalid characters in closing tag");
2581
+ a === ">" ? k(n) : O(n, "Invalid characters in closing tag");
2551
2582
  continue;
2552
2583
  case w.TEXT_ENTITY:
2553
2584
  case w.ATTRIB_VALUE_ENTITY_Q:
@@ -2565,9 +2596,9 @@ var Dt = /* @__PURE__ */ O(((e, t) => {
2565
2596
  break;
2566
2597
  }
2567
2598
  if (a === ";") {
2568
- var u = fe(n);
2569
- n.opt.unparsedEntities && !Object.values(e.XML_ENTITIES).includes(u) ? ((n.entityCount += 1) > n.opt.maxEntityCount && O(n, "Parsed entity count exceeds max entity count"), (n.entityDepth += 1) > n.opt.maxEntityDepth && O(n, "Parsed entity depth exceeds max entity depth"), n.entity = "", n.state = c, n.write(u), --n.entityDepth) : (n[l] += u, n.entity = "", n.state = c);
2570
- } else C(n.entity.length ? y : v, a) ? n.entity += a : (k(n, "Invalid character in entity name"), n[l] += "&" + n.entity + a, n.entity = "", n.state = c);
2599
+ var u = pe(n);
2600
+ n.opt.unparsedEntities && !Object.values(e.XML_ENTITIES).includes(u) ? ((n.entityCount += 1) > n.opt.maxEntityCount && D(n, "Parsed entity count exceeds max entity count"), (n.entityDepth += 1) > n.opt.maxEntityDepth && D(n, "Parsed entity depth exceeds max entity depth"), n.entity = "", n.state = c, n.write(u), --n.entityDepth) : (n[l] += u, n.entity = "", n.state = c);
2601
+ } else C(n.entity.length ? y : v, a) ? n.entity += a : (O(n, "Invalid character in entity name"), n[l] += "&" + n.entity + a, n.entity = "", n.state = c);
2571
2602
  continue;
2572
2603
  default: throw Error(n, "Unknown state: " + n.state);
2573
2604
  }
@@ -2807,7 +2838,7 @@ function It(e) {
2807
2838
  }),
2808
2839
  tagName: a,
2809
2840
  namespace: o,
2810
- attributes: g({
2841
+ attributes: m({
2811
2842
  dialecteConfig: r,
2812
2843
  attributes: Vt(Wt({
2813
2844
  attributes: t.attributes,
@@ -2855,7 +2886,7 @@ function zt(e) {
2855
2886
  }
2856
2887
  function Bt(e) {
2857
2888
  let { element: t, defaultNamespace: n, rootElementName: r } = e;
2858
- return f(t.name === r, { detail: `Expected root element <${r}>, got <${t.name}>` }), t.attributes?.xmlns?.value ? {
2889
+ return u(t.name === r, { detail: `Expected root element <${r}>, got <${t.name}>` }), t.attributes?.xmlns?.value ? {
2859
2890
  prefix: "",
2860
2891
  uri: t.attributes.xmlns.value
2861
2892
  } : n;
@@ -2900,19 +2931,19 @@ function Wt(e) {
2900
2931
  var Gt = 32 * 1024, W = 2e3;
2901
2932
  async function G(e) {
2902
2933
  let { documentId: t, store: n, config: r, useCustomRecordsIds: i = !1, chunkOptions: a, hooks: o, perf: s = Mt } = e, { file: c } = e, { supportedFileExtensions: l } = r.io;
2903
- if (f(l.some((e) => c.name.toLowerCase().endsWith(e)), {
2934
+ if (u(l.some((e) => c.name.toLowerCase().endsWith(e)), {
2904
2935
  key: "ASSERTION_FAILED",
2905
2936
  detail: `Unsupported file type: ${c.name}`
2906
2937
  }), c.size === 0) return {
2907
2938
  documentId: t,
2908
2939
  recordCount: 0
2909
2940
  };
2910
- let u = o?.beforeImport;
2911
- if (u) {
2912
- let e = u(await c.text());
2941
+ let d = o?.beforeImport;
2942
+ if (d) {
2943
+ let e = d(await c.text());
2913
2944
  c = new File([e], c.name, { type: c.type });
2914
2945
  }
2915
- let d = a?.chunkSize ?? Gt, p = a?.batchSize ?? W, m = new At(), h = Ft({
2946
+ let f = a?.chunkSize ?? Gt, p = a?.batchSize ?? W, m = new At(), h = Ft({
2916
2947
  dialecteConfig: r,
2917
2948
  useCustomRecordsIds: i,
2918
2949
  session: m,
@@ -2926,7 +2957,7 @@ async function G(e) {
2926
2957
  session: m,
2927
2958
  store: n,
2928
2959
  documentId: t,
2929
- chunkSize: d,
2960
+ chunkSize: f,
2930
2961
  batchSize: p,
2931
2962
  perf: s
2932
2963
  });
@@ -3026,16 +3057,16 @@ async function Xt(e) {
3026
3057
  }
3027
3058
  function Zt(e, t, n) {
3028
3059
  let r = lt(t);
3029
- r = qe({
3060
+ r = Je({
3030
3061
  tree: r,
3031
3062
  omit: n.omit,
3032
3063
  dialecteConfig: e.dialecteConfig
3033
3064
  });
3034
3065
  let i = e.dialecteConfig.transparentElements, a = n.unwrap ?? (i?.length ? [...i] : void 0);
3035
- return a?.length && (r = Ue({
3066
+ return a?.length && (r = We({
3036
3067
  tree: r,
3037
3068
  unwrapTagNames: a
3038
- })), r = Je({
3069
+ })), r = Ye({
3039
3070
  tree: r,
3040
3071
  childrenConfig: e.dialecteConfig.children
3041
3072
  }), r;
@@ -3055,50 +3086,50 @@ var $t = class {
3055
3086
  this.getContext = e, this.dialecteConfig = t;
3056
3087
  }
3057
3088
  async getRecord(e) {
3058
- return N({
3089
+ return M({
3059
3090
  context: this.getContext(),
3060
3091
  ref: e
3061
3092
  });
3062
3093
  }
3063
3094
  async getDefinition(e) {
3064
- return He({
3095
+ return Ue({
3065
3096
  context: this.getContext(),
3066
3097
  ref: T(e)
3067
3098
  });
3068
3099
  }
3069
3100
  async getRecords(e) {
3070
- return _e({
3101
+ return ve({
3071
3102
  context: this.getContext(),
3072
3103
  refs: e
3073
3104
  });
3074
3105
  }
3075
3106
  async getChild(e, t) {
3076
- return ye({
3107
+ return be({
3077
3108
  context: this.getContext(),
3078
3109
  ref: T(e),
3079
3110
  tagName: t
3080
3111
  });
3081
3112
  }
3082
3113
  async getChildren(e, t) {
3083
- return be({
3114
+ return xe({
3084
3115
  context: this.getContext(),
3085
3116
  ref: T(e),
3086
3117
  tagName: t
3087
3118
  });
3088
3119
  }
3089
3120
  async getRecordsByTagName(e) {
3090
- return ve({
3121
+ return ye({
3091
3122
  context: this.getContext(),
3092
3123
  tagName: e
3093
3124
  });
3094
3125
  }
3095
3126
  async getAttribute(e, t) {
3096
3127
  let n = e, { fullObject: r } = t;
3097
- return r ? Le({
3128
+ return r ? Be({
3098
3129
  context: this.getContext(),
3099
3130
  ref: n,
3100
3131
  ...t
3101
- }) : Ie({
3132
+ }) : ze({
3102
3133
  context: this.getContext(),
3103
3134
  ref: n,
3104
3135
  ...t
@@ -3106,18 +3137,18 @@ var $t = class {
3106
3137
  }
3107
3138
  async getAttributes(e, t) {
3108
3139
  let n = e, { fullObject: r } = t || {};
3109
- return r ? Be({
3140
+ return r ? He({
3110
3141
  context: this.getContext(),
3111
3142
  ref: n,
3112
3143
  ...t
3113
- }) : I({
3144
+ }) : Ve({
3114
3145
  context: this.getContext(),
3115
3146
  ref: n,
3116
3147
  ...t
3117
3148
  });
3118
3149
  }
3119
3150
  async getTree(e, t) {
3120
- return Ye({
3151
+ return L({
3121
3152
  context: this.getContext(),
3122
3153
  ref: T(e),
3123
3154
  options: t,
@@ -3132,20 +3163,20 @@ var $t = class {
3132
3163
  }
3133
3164
  async findDescendants(e) {
3134
3165
  let t = T(e), n = this.dialecteConfig.descendants[t.tagName] ?? [];
3135
- return we({
3166
+ return De({
3136
3167
  context: this.getContext(),
3137
3168
  ref: t,
3138
3169
  options: { collect: n }
3139
3170
  });
3140
3171
  }
3141
3172
  async findAncestors(e) {
3142
- return e ? xe({
3173
+ return e ? N({
3143
3174
  context: this.getContext(),
3144
3175
  ref: T(e)
3145
3176
  }) : [];
3146
3177
  }
3147
3178
  async findByAttributes(e) {
3148
- return P({
3179
+ return Ce({
3149
3180
  context: this.getContext(),
3150
3181
  tagName: e.tagName,
3151
3182
  attributes: e.attributes
@@ -3162,7 +3193,7 @@ var $t = class {
3162
3193
  return this._any ??= new $t(() => this.context, this.dialecteConfig);
3163
3194
  }
3164
3195
  getOperations() {
3165
- return A();
3196
+ return k();
3166
3197
  }
3167
3198
  get context() {
3168
3199
  return {
@@ -3171,62 +3202,62 @@ var $t = class {
3171
3202
  documentId: this.documentId,
3172
3203
  recordCache: void 0,
3173
3204
  stagedOperations: this.getOperations(),
3174
- progress: de,
3205
+ progress: fe,
3175
3206
  perf: this.perf
3176
3207
  };
3177
3208
  }
3178
3209
  async getDocumentInfo() {
3179
3210
  let e = await this.store.getDocument(this.documentId);
3180
- return f(e, {
3211
+ return u(e, {
3181
3212
  key: "DOCUMENT_NOT_REGISTERED",
3182
3213
  detail: `Expected document id: ${this.documentId}`
3183
3214
  }), e;
3184
3215
  }
3185
3216
  async getRoot() {
3186
- let e = await N({
3217
+ let e = await M({
3187
3218
  context: this.context,
3188
3219
  ref: { tagName: this.dialecteConfig.rootElementName }
3189
3220
  });
3190
- return f(e, {
3221
+ return u(e, {
3191
3222
  key: "ROOT_NOT_FOUND",
3192
3223
  detail: `Expected tag name: ${this.dialecteConfig.rootElementName}`
3193
3224
  }), e;
3194
3225
  }
3195
3226
  async getRecord(e) {
3196
- return N({
3227
+ return M({
3197
3228
  context: this.context,
3198
3229
  ref: T(e)
3199
3230
  });
3200
3231
  }
3201
3232
  async getDefinition(e) {
3202
- return He({
3233
+ return Ue({
3203
3234
  context: this.context,
3204
3235
  ref: T(e)
3205
3236
  });
3206
3237
  }
3207
3238
  async getRecords(e) {
3208
3239
  let t = e.map((e) => T(e));
3209
- return _e({
3240
+ return ve({
3210
3241
  context: this.context,
3211
3242
  refs: t
3212
3243
  });
3213
3244
  }
3214
3245
  async getChild(e, t) {
3215
- if (e) return ye({
3246
+ if (e) return be({
3216
3247
  context: this.context,
3217
3248
  ref: T(e),
3218
3249
  tagName: t
3219
3250
  });
3220
3251
  }
3221
3252
  async getChildren(e, t) {
3222
- return e ? be({
3253
+ return e ? xe({
3223
3254
  context: this.context,
3224
3255
  ref: T(e),
3225
3256
  tagName: t
3226
3257
  }) : [];
3227
3258
  }
3228
3259
  async getRecordsByTagName(e) {
3229
- return ve({
3260
+ return ye({
3230
3261
  context: this.context,
3231
3262
  tagName: e
3232
3263
  });
@@ -3235,27 +3266,27 @@ var $t = class {
3235
3266
  let n = T(e);
3236
3267
  if (!t) {
3237
3268
  let e = this.dialecteConfig.descendants[n.tagName] ?? [];
3238
- return we({
3269
+ return De({
3239
3270
  context: this.context,
3240
3271
  ref: n,
3241
3272
  options: { collect: e }
3242
3273
  });
3243
3274
  }
3244
- return we({
3275
+ return De({
3245
3276
  context: this.context,
3246
3277
  ref: n,
3247
3278
  options: t
3248
3279
  });
3249
3280
  }
3250
3281
  async findAncestors(e, t) {
3251
- return e ? xe({
3282
+ return e ? N({
3252
3283
  context: this.context,
3253
3284
  ref: T(e),
3254
3285
  options: t
3255
3286
  }) : [];
3256
3287
  }
3257
3288
  async getTree(e, t) {
3258
- return Ye({
3289
+ return L({
3259
3290
  context: this.context,
3260
3291
  ref: T(e),
3261
3292
  options: t,
@@ -3270,11 +3301,11 @@ var $t = class {
3270
3301
  }
3271
3302
  async getAttribute(e, t) {
3272
3303
  let { fullObject: n } = t;
3273
- return n ? Le({
3304
+ return n ? Be({
3274
3305
  context: this.context,
3275
3306
  ref: e,
3276
3307
  ...t
3277
- }) : Ie({
3308
+ }) : ze({
3278
3309
  context: this.context,
3279
3310
  ref: e,
3280
3311
  ...t
@@ -3282,18 +3313,18 @@ var $t = class {
3282
3313
  }
3283
3314
  async getAttributes(e, t) {
3284
3315
  let { fullObject: n } = t || {};
3285
- return n ? Be({
3316
+ return n ? He({
3286
3317
  context: this.context,
3287
3318
  ref: e,
3288
3319
  ...t
3289
- }) : I({
3320
+ }) : Ve({
3290
3321
  context: this.context,
3291
3322
  ref: e,
3292
3323
  ...t
3293
3324
  });
3294
3325
  }
3295
3326
  async findByAttributes(e) {
3296
- return P({
3327
+ return Ce({
3297
3328
  context: this.context,
3298
3329
  ...e
3299
3330
  });
@@ -3304,7 +3335,7 @@ var $t = class {
3304
3335
  function K(e) {
3305
3336
  let { context: t, status: n, record: r, oldRecord: i, newRecord: a } = e, o, s, c;
3306
3337
  if (r && (o = te(r)), i && (s = te(i)), a && (c = te(a)), n === "created") {
3307
- f(o, {
3338
+ u(o, {
3308
3339
  detail: "Record is required for created",
3309
3340
  key: "ELEMENT_NOT_FOUND"
3310
3341
  });
@@ -3315,7 +3346,7 @@ function K(e) {
3315
3346
  };
3316
3347
  t.stagedOperations.log.push(e), t.stagedOperations.byId.set(o.id, e);
3317
3348
  } else if (n === "updated") {
3318
- f(s && c, {
3349
+ u(s && c, {
3319
3350
  detail: "Old record and new record are required for updated",
3320
3351
  key: "ELEMENT_NOT_FOUND"
3321
3352
  });
@@ -3326,7 +3357,7 @@ function K(e) {
3326
3357
  };
3327
3358
  t.stagedOperations.log.push(e), t.stagedOperations.byId.set(c.id, e);
3328
3359
  } else if (n === "deleted" && o) {
3329
- f(o, {
3360
+ u(o, {
3330
3361
  detail: "Record is required for deleted",
3331
3362
  key: "ELEMENT_NOT_FOUND"
3332
3363
  });
@@ -3368,16 +3399,16 @@ function tn(e) {
3368
3399
  //#endregion
3369
3400
  //#region src/document/transaction/create/create.ts
3370
3401
  async function nn(e) {
3371
- let { dialecteConfig: t, hooks: n, context: r, query: i, parentRef: a, params: o } = e, { id: s, tagName: c, attributes: l, namespace: u, value: d } = o;
3402
+ let { dialecteConfig: t, hooks: n, context: r, query: i, parentRef: a, params: o } = e, { id: s, tagName: c, attributes: l, namespace: d, value: f } = o;
3372
3403
  rn({
3373
3404
  attributes: l,
3374
3405
  tagName: c
3375
3406
  });
3376
- let p = await N({
3407
+ let p = await M({
3377
3408
  context: r,
3378
3409
  ref: a
3379
3410
  });
3380
- f(p, {
3411
+ u(p, {
3381
3412
  detail: "Parent record not found",
3382
3413
  key: "ELEMENT_NOT_FOUND",
3383
3414
  ref: a
@@ -3389,8 +3420,8 @@ async function nn(e) {
3389
3420
  id: s ?? crypto.randomUUID(),
3390
3421
  tagName: c,
3391
3422
  attributes: l,
3392
- namespace: u,
3393
- value: d,
3423
+ namespace: d,
3424
+ value: f,
3394
3425
  parent: {
3395
3426
  id: p.id,
3396
3427
  tagName: p.tagName
@@ -3398,11 +3429,11 @@ async function nn(e) {
3398
3429
  children: []
3399
3430
  }
3400
3431
  });
3401
- y({
3432
+ _({
3402
3433
  dialecteConfig: t,
3403
3434
  record: m,
3404
3435
  attributes: m.attributes
3405
- }), b({
3436
+ }), v({
3406
3437
  dialecteConfig: t,
3407
3438
  record: m
3408
3439
  }), K({
@@ -3436,7 +3467,7 @@ function rn(e) {
3436
3467
  if (!(!t || !Array.isArray(t))) for (let e of t) {
3437
3468
  let { name: t, namespace: i } = e;
3438
3469
  t === "xmlns" || t.startsWith("xmlns:") || !t.includes(":") || typeof i == "object" && i?.prefix === t.slice(0, t.indexOf(":")) || r("PREFIXED_ATTRIBUTE_NAME", {
3439
- detail: `Attribute '${t}' on '${n}' is prefixed — pass a local name plus its namespace instead: { name: '${p(t)}', namespace }.`,
3470
+ detail: `Attribute '${t}' on '${n}' is prefixed — pass a local name plus its namespace instead: { name: '${d(t)}', namespace }.`,
3440
3471
  ref: { tagName: n }
3441
3472
  });
3442
3473
  }
@@ -3505,15 +3536,15 @@ async function sn(e) {
3505
3536
  //#endregion
3506
3537
  //#region src/document/transaction/delete/delete.ts
3507
3538
  async function cn(e) {
3508
- let { hooks: t, context: n, query: r, ref: i } = e, a = await N({
3539
+ let { hooks: t, context: n, query: r, ref: i } = e, a = await M({
3509
3540
  context: n,
3510
3541
  ref: i
3511
3542
  });
3512
- f(a, {
3543
+ u(a, {
3513
3544
  detail: `Record not found (tagName=${i.tagName}, id=${i.id})`,
3514
3545
  key: "ELEMENT_NOT_FOUND",
3515
3546
  ref: i
3516
- }), f(a.parent, {
3547
+ }), u(a.parent, {
3517
3548
  detail: "Cannot delete root element",
3518
3549
  key: "PROTECTED_ROOT"
3519
3550
  }), t?.beforeDelete && tn({
@@ -3530,11 +3561,11 @@ async function cn(e) {
3530
3561
  status: "deleted",
3531
3562
  record: a
3532
3563
  });
3533
- let o = await N({
3564
+ let o = await M({
3534
3565
  context: n,
3535
3566
  ref: T(a.parent)
3536
3567
  });
3537
- f(o, {
3568
+ u(o, {
3538
3569
  detail: `Parent record not found (tagName=${a.parent.tagName}, id=${a.parent.id})`,
3539
3570
  key: "ELEMENT_NOT_FOUND"
3540
3571
  });
@@ -3559,7 +3590,7 @@ async function cn(e) {
3559
3590
  async function ln(e) {
3560
3591
  let { context: t, record: n } = e;
3561
3592
  for (let e of n.children) {
3562
- let n = await N({
3593
+ let n = await M({
3563
3594
  context: t,
3564
3595
  ref: T(e)
3565
3596
  });
@@ -3576,12 +3607,12 @@ async function ln(e) {
3576
3607
  //#endregion
3577
3608
  //#region src/document/transaction/ensure/ensure.ts
3578
3609
  async function un(e) {
3579
- let { dialecteConfig: t, hooks: n, context: r, query: i, parentRef: a, params: o } = e, s = dn(o.attributes), c = await be({
3610
+ let { dialecteConfig: t, hooks: n, context: r, query: i, parentRef: a, params: o } = e, s = dn(o.attributes), c = await xe({
3580
3611
  context: r,
3581
3612
  ref: a,
3582
3613
  tagName: o.tagName
3583
3614
  });
3584
- return (s ? c.find((e) => Se({
3615
+ return (s ? c.find((e) => P({
3585
3616
  dialecteConfig: t,
3586
3617
  record: e,
3587
3618
  attributeFilter: s
@@ -3602,44 +3633,44 @@ function dn(e) {
3602
3633
  //#endregion
3603
3634
  //#region src/document/transaction/update/update.ts
3604
3635
  async function fn(e) {
3605
- let { dialecteConfig: t, hooks: n, context: r, query: i, ref: a, params: o } = e, { attributes: s, value: c } = o, l = await N({
3636
+ let { dialecteConfig: t, hooks: n, context: r, query: i, ref: a, params: o } = e, { attributes: s, value: c } = o, l = await M({
3606
3637
  context: r,
3607
3638
  ref: a
3608
3639
  });
3609
- f(l, {
3640
+ u(l, {
3610
3641
  detail: `Record not found (tagName=${a.tagName}, id=${a.id})`,
3611
3642
  key: "ELEMENT_NOT_FOUND",
3612
3643
  ref: a
3613
3644
  });
3614
- let u = s ? w({
3645
+ let d = s ? w({
3615
3646
  dialecteConfig: t,
3616
3647
  tagName: l.tagName,
3617
3648
  attributes: s,
3618
3649
  stored: l.attributes
3619
- }) : [], d = l.attributes;
3620
- s && (d = [...l.attributes.filter((e) => !u.some((t) => t.name === e.name)), ...u].filter((e) => e.value !== void 0 && e.value !== null), y({
3650
+ }) : [], f = l.attributes;
3651
+ s && (f = [...l.attributes.filter((e) => !d.some((t) => t.name === e.name)), ...d].filter((e) => e.value !== void 0 && e.value !== null), _({
3621
3652
  dialecteConfig: t,
3622
3653
  record: {
3623
3654
  ...l,
3624
- attributes: d
3655
+ attributes: f
3625
3656
  },
3626
- attributes: u
3657
+ attributes: d
3627
3658
  }));
3628
- let p = u.some(_), m = ee({
3659
+ let p = d.some(h), m = ee({
3629
3660
  dialecteConfig: t,
3630
3661
  hooks: n,
3631
3662
  record: {
3632
3663
  ...l,
3633
- attributes: d,
3664
+ attributes: f,
3634
3665
  value: c === void 0 ? l.value : c
3635
3666
  }
3636
3667
  });
3637
- return p && (b({
3668
+ return p && (v({
3638
3669
  dialecteConfig: t,
3639
3670
  record: m
3640
- }), x({
3671
+ }), y({
3641
3672
  dialecteConfig: t,
3642
- merged: d,
3673
+ merged: f,
3643
3674
  record: m
3644
3675
  })), pn(l, m) ? m : (K({
3645
3676
  context: r,
@@ -3806,7 +3837,7 @@ async function vn(e) {
3806
3837
  //#region src/document/transaction/main.ts
3807
3838
  var yn = class extends en {
3808
3839
  constructor(e, t, n, r, i, a = Mt, o = () => {}) {
3809
- super(e, t, n, a), this.stagedOperations = A(), this.recordCache = /* @__PURE__ */ new Map(), this.stagingFinished = !1, this.documentActivity = r, this.hooks = i, this.progressReporter = ue(r, o);
3840
+ super(e, t, n, a), this.stagedOperations = k(), this.recordCache = /* @__PURE__ */ new Map(), this.stagingFinished = !1, this.documentActivity = r, this.hooks = i, this.progressReporter = de(r, o);
3810
3841
  }
3811
3842
  get progress() {
3812
3843
  return this.progressReporter;
@@ -3887,7 +3918,7 @@ var yn = class extends en {
3887
3918
  return this.stagedOperations.log;
3888
3919
  }
3889
3920
  clearStagedOperations() {
3890
- this.stagedOperations = A();
3921
+ this.stagedOperations = k();
3891
3922
  }
3892
3923
  clearRecordCache() {
3893
3924
  this.recordCache.clear();
@@ -3915,11 +3946,11 @@ var xn = class {
3915
3946
  this.activeTransactions = 0, this.store = e, this.config = t, this.documentId = n, this.hooks = i, this.extensionsRegistry = r, this.state = a.state, this.channelName = a.channelName, this.broadcast = a.broadcast, this.refreshHistoryStatus = a.refreshHistoryStatus, this.perf = a.perf, this.subscribe = a.subscribeState, this.signalStateChange = a.signalStateChange;
3916
3947
  }
3917
3948
  withQueryExtensions(e) {
3918
- let t = ce(this.extensionsRegistry?.query, e);
3949
+ let t = le(this.extensionsRegistry?.query, e);
3919
3950
  return Object.assign(e, t);
3920
3951
  }
3921
3952
  withAllExtensions(e) {
3922
- let t = ce(this.extensionsRegistry?.query, e), n = ce(this.extensionsRegistry?.transaction, e), r = {};
3953
+ let t = le(this.extensionsRegistry?.query, e), n = le(this.extensionsRegistry?.transaction, e), r = {};
3923
3954
  for (let [e, n] of Object.entries(t)) r[e] = {
3924
3955
  ...r[e],
3925
3956
  ...n
@@ -4051,7 +4082,7 @@ var Tn = {
4051
4082
  indexes: [],
4052
4083
  compoundIndexes: [],
4053
4084
  arrayIndexes: []
4054
- }, An = /* @__PURE__ */ k((/* @__PURE__ */ O(((e, t) => {
4085
+ }, An = /* @__PURE__ */ O((/* @__PURE__ */ D(((e, t) => {
4055
4086
  ((n, r) => {
4056
4087
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).Dexie = r();
4057
4088
  })(e, function() {
@@ -4203,15 +4234,15 @@ var Tn = {
4203
4234
  } : function() {
4204
4235
  return null;
4205
4236
  };
4206
- function D(e, t) {
4237
+ function oe(e, t) {
4207
4238
  t = e.indexOf(t), 0 <= t && e.splice(t, 1);
4208
4239
  }
4209
- var oe = {};
4210
- function O(e) {
4240
+ var se = {};
4241
+ function D(e) {
4211
4242
  var t, n, r, i;
4212
4243
  if (arguments.length === 1) {
4213
4244
  if (a(e)) return e.slice();
4214
- if (this === oe && typeof e == "string") return [e];
4245
+ if (this === se && typeof e == "string") return [e];
4215
4246
  if (i = E(e)) for (n = []; !(r = i.next()).done;) n.push(r.value);
4216
4247
  else {
4217
4248
  if (e == null || typeof (t = e.length) != "number") return [e];
@@ -4220,7 +4251,7 @@ var Tn = {
4220
4251
  } else for (t = arguments.length, n = Array(t); t--;) n[t] = arguments[t];
4221
4252
  return n;
4222
4253
  }
4223
- var se = typeof Symbol < "u" ? function(e) {
4254
+ var ce = typeof Symbol < "u" ? function(e) {
4224
4255
  return e[Symbol.toStringTag] === "AsyncFunction";
4225
4256
  } : function() {
4226
4257
  return !1;
@@ -4239,7 +4270,7 @@ var Tn = {
4239
4270
  "QuotaExceeded",
4240
4271
  "Syntax",
4241
4272
  "DataClone"
4242
- ], k = [
4273
+ ], O = [
4243
4274
  "Modify",
4244
4275
  "Bulk",
4245
4276
  "OpenFailed",
@@ -4256,92 +4287,92 @@ var Tn = {
4256
4287
  "DatabaseClosed",
4257
4288
  "PrematureCommit",
4258
4289
  "ForeignAwait"
4259
- ].concat(w), ce = {
4290
+ ].concat(w), le = {
4260
4291
  VersionChanged: "Database version changed by other database connection",
4261
4292
  DatabaseClosed: "Database has been closed",
4262
4293
  Abort: "Transaction aborted",
4263
4294
  TransactionInactive: "Transaction has already completed or failed",
4264
4295
  MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"
4265
4296
  };
4266
- function le(e, t) {
4297
+ function ue(e, t) {
4267
4298
  this.name = e, this.message = t;
4268
4299
  }
4269
- function ue(e, t) {
4300
+ function de(e, t) {
4270
4301
  return e + ". Errors: " + Object.keys(t).map(function(e) {
4271
4302
  return t[e].toString();
4272
4303
  }).filter(function(e, t, n) {
4273
4304
  return n.indexOf(e) === t;
4274
4305
  }).join("\n");
4275
4306
  }
4276
- function de(e, t, n, r) {
4277
- this.failures = t, this.failedKeys = r, this.successCount = n, this.message = ue(e, t);
4307
+ function fe(e, t, n, r) {
4308
+ this.failures = t, this.failedKeys = r, this.successCount = n, this.message = de(e, t);
4278
4309
  }
4279
- function A(e, t) {
4310
+ function k(e, t) {
4280
4311
  this.name = "BulkError", this.failures = Object.keys(t).map(function(e) {
4281
4312
  return t[e];
4282
- }), this.failuresByPos = t, this.message = ue(e, this.failures);
4313
+ }), this.failuresByPos = t, this.message = de(e, this.failures);
4283
4314
  }
4284
- p(le).from(Error).extend({ toString: function() {
4315
+ p(ue).from(Error).extend({ toString: function() {
4285
4316
  return this.name + ": " + this.message;
4286
- } }), p(de).from(le), p(A).from(le);
4287
- var fe = k.reduce(function(e, t) {
4317
+ } }), p(fe).from(ue), p(k).from(ue);
4318
+ var pe = O.reduce(function(e, t) {
4288
4319
  return e[t] = t + "Error", e;
4289
- }, {}), pe = le, j = k.reduce(function(e, t) {
4320
+ }, {}), me = ue, A = O.reduce(function(e, t) {
4290
4321
  var n = t + "Error";
4291
4322
  function r(e, r) {
4292
- this.name = n, e ? typeof e == "string" ? (this.message = `${e}${r ? "\n " + r : ""}`, this.inner = r || null) : typeof e == "object" && (this.message = `${e.name} ${e.message}`, this.inner = e) : (this.message = ce[t] || n, this.inner = null);
4323
+ this.name = n, e ? typeof e == "string" ? (this.message = `${e}${r ? "\n " + r : ""}`, this.inner = r || null) : typeof e == "object" && (this.message = `${e.name} ${e.message}`, this.inner = e) : (this.message = le[t] || n, this.inner = null);
4293
4324
  }
4294
- return p(r).from(pe), e[t] = r, e;
4295
- }, {}), me = (j.Syntax = SyntaxError, j.Type = TypeError, j.Range = RangeError, w.reduce(function(e, t) {
4296
- return e[t + "Error"] = j[t], e;
4325
+ return p(r).from(me), e[t] = r, e;
4326
+ }, {}), he = (A.Syntax = SyntaxError, A.Type = TypeError, A.Range = RangeError, w.reduce(function(e, t) {
4327
+ return e[t + "Error"] = A[t], e;
4297
4328
  }, {}));
4298
- w = k.reduce(function(e, t) {
4329
+ w = O.reduce(function(e, t) {
4299
4330
  return [
4300
4331
  "Syntax",
4301
4332
  "Type",
4302
4333
  "Range"
4303
- ].indexOf(t) === -1 && (e[t + "Error"] = j[t]), e;
4334
+ ].indexOf(t) === -1 && (e[t + "Error"] = A[t]), e;
4304
4335
  }, {});
4305
- function M() {}
4306
- function he(e) {
4336
+ function j() {}
4337
+ function ge(e) {
4307
4338
  return e;
4308
4339
  }
4309
- function N(e, t) {
4310
- return e == null || e === he ? t : function(n) {
4340
+ function M(e, t) {
4341
+ return e == null || e === ge ? t : function(n) {
4311
4342
  return t(e(n));
4312
4343
  };
4313
4344
  }
4314
- function ge(e, t) {
4345
+ function _e(e, t) {
4315
4346
  return function() {
4316
4347
  e.apply(this, arguments), t.apply(this, arguments);
4317
4348
  };
4318
4349
  }
4319
- function _e(e, t) {
4320
- return e === M ? t : function() {
4350
+ function ve(e, t) {
4351
+ return e === j ? t : function() {
4321
4352
  var n = e.apply(this, arguments), r = (n !== void 0 && (arguments[0] = n), this.onsuccess), i = this.onerror, a = (this.onsuccess = null, this.onerror = null, t.apply(this, arguments));
4322
- return r && (this.onsuccess = this.onsuccess ? ge(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? ge(i, this.onerror) : i), a === void 0 ? n : a;
4353
+ return r && (this.onsuccess = this.onsuccess ? _e(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? _e(i, this.onerror) : i), a === void 0 ? n : a;
4323
4354
  };
4324
4355
  }
4325
- function ve(e, t) {
4326
- return e === M ? t : function() {
4356
+ function ye(e, t) {
4357
+ return e === j ? t : function() {
4327
4358
  e.apply(this, arguments);
4328
4359
  var n = this.onsuccess, r = this.onerror;
4329
- this.onsuccess = this.onerror = null, t.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? ge(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? ge(r, this.onerror) : r);
4360
+ this.onsuccess = this.onerror = null, t.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? _e(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? _e(r, this.onerror) : r);
4330
4361
  };
4331
4362
  }
4332
- function ye(e, t) {
4333
- return e === M ? t : function() {
4363
+ function be(e, t) {
4364
+ return e === j ? t : function() {
4334
4365
  var n = e.apply(this, arguments), r = (o(arguments[0], n), this.onsuccess), i = this.onerror, a = (this.onsuccess = null, this.onerror = null, t.apply(this, arguments));
4335
- return r && (this.onsuccess = this.onsuccess ? ge(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? ge(i, this.onerror) : i), n === void 0 ? a === void 0 ? void 0 : a : o(n, a);
4366
+ return r && (this.onsuccess = this.onsuccess ? _e(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? _e(i, this.onerror) : i), n === void 0 ? a === void 0 ? void 0 : a : o(n, a);
4336
4367
  };
4337
4368
  }
4338
- function be(e, t) {
4339
- return e === M ? t : function() {
4369
+ function xe(e, t) {
4370
+ return e === j ? t : function() {
4340
4371
  return !1 !== t.apply(this, arguments) && e.apply(this, arguments);
4341
4372
  };
4342
4373
  }
4343
- function xe(e, t) {
4344
- return e === M ? t : function() {
4374
+ function Se(e, t) {
4375
+ return e === j ? t : function() {
4345
4376
  var n = e.apply(this, arguments);
4346
4377
  if (n && typeof n.then == "function") {
4347
4378
  for (var r = this, i = arguments.length, a = Array(i); i--;) a[i] = arguments[i];
@@ -4352,37 +4383,37 @@ var Tn = {
4352
4383
  return t.apply(this, arguments);
4353
4384
  };
4354
4385
  }
4355
- w.ModifyError = de, w.DexieError = le, w.BulkError = A;
4356
- var P = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
4357
- function Se(e) {
4358
- P = e;
4386
+ w.ModifyError = fe, w.DexieError = ue, w.BulkError = k;
4387
+ var N = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
4388
+ function Ce(e) {
4389
+ N = e;
4359
4390
  }
4360
- var Ce = {}, we = 100, Te = typeof Promise > "u" ? [] : (k = Promise.resolve(), typeof crypto < "u" && crypto.subtle ? [
4391
+ var P = {}, we = 100, Te = typeof Promise > "u" ? [] : (O = Promise.resolve(), typeof crypto < "u" && crypto.subtle ? [
4361
4392
  Te = crypto.subtle.digest("SHA-512", new Uint8Array([0])),
4362
4393
  s(Te),
4363
- k
4394
+ O
4364
4395
  ] : [
4365
- k,
4366
- s(k),
4367
- k
4368
- ]), k = Te[0], Ee = Te[1], Ee = Ee && Ee.then, De = k && k.constructor, Oe = !!Te[2], ke = function(e, t) {
4396
+ O,
4397
+ s(O),
4398
+ O
4399
+ ]), O = Te[0], Ee = Te[1], Ee = Ee && Ee.then, De = O && O.constructor, Oe = !!Te[2], ke = function(e, t) {
4369
4400
  Ie.push([e, t]), je &&= (queueMicrotask(Ge), !1);
4370
- }, Ae = !0, je = !0, Me = [], Ne = [], Pe = he, Fe = {
4401
+ }, Ae = !0, je = !0, Me = [], Ne = [], Pe = ge, Fe = {
4371
4402
  id: "global",
4372
4403
  global: !0,
4373
4404
  ref: 0,
4374
4405
  unhandleds: [],
4375
- onunhandled: M,
4406
+ onunhandled: j,
4376
4407
  pgp: !1,
4377
4408
  env: {},
4378
- finalize: M
4409
+ finalize: j
4379
4410
  }, F = Fe, Ie = [], Le = 0, Re = [];
4380
4411
  function I(e) {
4381
4412
  if (typeof this != "object") throw TypeError("Promises must be constructed via new");
4382
4413
  this._listeners = [], this._lib = !1;
4383
4414
  var t = this._PSD = F;
4384
4415
  if (typeof e != "function") {
4385
- if (e !== Ce) throw TypeError("Not a function");
4416
+ if (e !== P) throw TypeError("Not a function");
4386
4417
  this._state = arguments[1], this._value = arguments[2], !1 === this._state && Ve(this, this._value);
4387
4418
  } else this._state = null, this._value = null, ++t.ref, function e(t, n) {
4388
4419
  try {
@@ -4409,10 +4440,10 @@ var Tn = {
4409
4440
  });
4410
4441
  return this._consoleTask && (s._consoleTask = this._consoleTask), s;
4411
4442
  }
4412
- return n.prototype = Ce, n;
4443
+ return n.prototype = P, n;
4413
4444
  },
4414
4445
  set: function(e) {
4415
- f(this, "then", e && e.prototype === Ce ? ze : {
4446
+ f(this, "then", e && e.prototype === P ? ze : {
4416
4447
  get: function() {
4417
4448
  return e;
4418
4449
  },
@@ -4453,7 +4484,7 @@ var Tn = {
4453
4484
  function We(e, t, n) {
4454
4485
  try {
4455
4486
  var r, i = t._value;
4456
- !t._state && Ne.length && (Ne = []), r = P && t._consoleTask ? t._consoleTask.run(function() {
4487
+ !t._state && Ne.length && (Ne = []), r = N && t._consoleTask ? t._consoleTask.run(function() {
4457
4488
  return e(i);
4458
4489
  }) : e(i), t._state || Ne.indexOf(i) !== -1 || ((e) => {
4459
4490
  for (var t = Me.length; t;) if (Me[--t]._value === e._value) return Me.splice(t, 1);
@@ -4489,7 +4520,7 @@ var Tn = {
4489
4520
  }), Re.slice(0)), n = t.length; n;) t[--n]();
4490
4521
  }
4491
4522
  function Ye(e) {
4492
- return new I(Ce, !1, e);
4523
+ return new I(P, !1, e);
4493
4524
  }
4494
4525
  function L(e, t) {
4495
4526
  var n = F;
@@ -4532,14 +4563,14 @@ var Tn = {
4532
4563
  var n = this;
4533
4564
  return e < Infinity ? new I(function(r, i) {
4534
4565
  var a = setTimeout(function() {
4535
- return i(new j.Timeout(t));
4566
+ return i(new A.Timeout(t));
4536
4567
  }, e);
4537
4568
  n.then(r, i).finally(clearTimeout.bind(null, a));
4538
4569
  }) : this;
4539
4570
  }
4540
4571
  }), typeof Symbol < "u" && Symbol.toStringTag && f(I.prototype, Symbol.toStringTag, "Dexie.Promise"), Fe.env = st(), u(I, {
4541
4572
  all: function() {
4542
- var e = O.apply(null, arguments).map(it);
4573
+ var e = D.apply(null, arguments).map(it);
4543
4574
  return new I(function(t, n) {
4544
4575
  e.length === 0 && t([]);
4545
4576
  var r = e.length;
@@ -4553,11 +4584,11 @@ var Tn = {
4553
4584
  resolve: function(e) {
4554
4585
  return e instanceof I ? e : e && typeof e.then == "function" ? new I(function(t, n) {
4555
4586
  e.then(t, n);
4556
- }) : new I(Ce, !0, e);
4587
+ }) : new I(P, !0, e);
4557
4588
  },
4558
4589
  reject: Ye,
4559
4590
  race: function() {
4560
- var e = O.apply(null, arguments).map(it);
4591
+ var e = D.apply(null, arguments).map(it);
4561
4592
  return new I(function(t, n) {
4562
4593
  e.map(function(e) {
4563
4594
  return I.resolve(e).then(t, n);
@@ -4597,7 +4628,7 @@ var Tn = {
4597
4628
  return new I(function(n, r) {
4598
4629
  return tt(function(t, n) {
4599
4630
  var r = F;
4600
- r.unhandleds = [], r.onunhandled = n, r.finalize = ge(function() {
4631
+ r.unhandleds = [], r.onunhandled = n, r.finalize = _e(function() {
4601
4632
  var e, r = this;
4602
4633
  e = function() {
4603
4634
  r.unhandleds.length === 0 ? t() : n(r.unhandleds[0]);
@@ -4611,7 +4642,7 @@ var Tn = {
4611
4642
  });
4612
4643
  }
4613
4644
  }), De && (De.allSettled && f(I, "allSettled", function() {
4614
- var e = O.apply(null, arguments).map(it);
4645
+ var e = D.apply(null, arguments).map(it);
4615
4646
  return new I(function(t) {
4616
4647
  e.length === 0 && t([]);
4617
4648
  var n = e.length, r = Array(n);
@@ -4632,7 +4663,7 @@ var Tn = {
4632
4663
  });
4633
4664
  });
4634
4665
  }), De.any && typeof AggregateError < "u" && f(I, "any", function() {
4635
- var e = O.apply(null, arguments).map(it);
4666
+ var e = D.apply(null, arguments).map(it);
4636
4667
  return new I(function(t, n) {
4637
4668
  e.length === 0 && n(/* @__PURE__ */ AggregateError([]));
4638
4669
  var r = e.length, i = Array(r);
@@ -4727,7 +4758,7 @@ var Tn = {
4727
4758
  function ut(e) {
4728
4759
  Promise === De && R.echoes === 0 ? Qe === 0 ? e() : enqueueNativeMicroTask(e) : setTimeout(e, 0);
4729
4760
  }
4730
- ("" + Ee).indexOf("[native code]") === -1 && (nt = rt = M);
4761
+ ("" + Ee).indexOf("[native code]") === -1 && (nt = rt = j);
4731
4762
  var z = I.reject, dt = "￿", ft = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", pt = "String expected.", mt = "__dbnames", ht = "readonly", gt = "readwrite";
4732
4763
  function _t(e, t) {
4733
4764
  return e ? t ? function() {
@@ -4749,7 +4780,7 @@ var Tn = {
4749
4780
  };
4750
4781
  }
4751
4782
  function bt() {
4752
- throw j.Type("Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.");
4783
+ throw A.Type("Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.");
4753
4784
  }
4754
4785
  function B(e, t) {
4755
4786
  try {
@@ -4829,10 +4860,10 @@ var Tn = {
4829
4860
  return a;
4830
4861
  }
4831
4862
  V.prototype._trans = function(e, t, n) {
4832
- var r = this._tx || F.trans, i = this.name, a = P && typeof console < "u" && console.createTask && console.createTask(`Dexie: ${e === "readonly" ? "read" : "write"} ${this.name}`);
4863
+ var r = this._tx || F.trans, i = this.name, a = N && typeof console < "u" && console.createTask && console.createTask(`Dexie: ${e === "readonly" ? "read" : "write"} ${this.name}`);
4833
4864
  function o(e, n, r) {
4834
4865
  if (r.schema[i]) return t(r.idbtrans, r);
4835
- throw new j.NotFound("Table " + i + " not part of transaction");
4866
+ throw new A.NotFound("Table " + i + " not part of transaction");
4836
4867
  }
4837
4868
  var s = Ke();
4838
4869
  try {
@@ -4847,7 +4878,7 @@ var Tn = {
4847
4878
  try {
4848
4879
  a.create(), t._state.PR1398_maxLoop = 3;
4849
4880
  } catch (a) {
4850
- return a.name === fe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
4881
+ return a.name === pe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
4851
4882
  return e(t, n, r, i);
4852
4883
  })) : z(a);
4853
4884
  }
@@ -4864,10 +4895,10 @@ var Tn = {
4864
4895
  });
4865
4896
  });
4866
4897
  }
4867
- if (t._state.openComplete) return z(new j.DatabaseClosed(t._state.dbOpenError));
4898
+ if (t._state.openComplete) return z(new A.DatabaseClosed(t._state.dbOpenError));
4868
4899
  if (!t._state.isBeingOpened) {
4869
- if (!t._state.autoOpen) return z(new j.DatabaseClosed());
4870
- t.open().catch(M);
4900
+ if (!t._state.autoOpen) return z(new A.DatabaseClosed());
4901
+ t.open().catch(j);
4871
4902
  }
4872
4903
  return t._state.dbReadyPromise.then(function() {
4873
4904
  return e(t, n, r, i);
@@ -4881,7 +4912,7 @@ var Tn = {
4881
4912
  }
4882
4913
  }, V.prototype.get = function(e, t) {
4883
4914
  var n = this;
4884
- return e && e.constructor === Object ? this.where(e).first(t) : e == null ? z(new j.Type("Invalid argument to Table.get()")) : this._trans("readonly", function(t) {
4915
+ return e && e.constructor === Object ? this.where(e).first(t) : e == null ? z(new A.Type("Invalid argument to Table.get()")) : this._trans("readonly", function(t) {
4885
4916
  return n.core.get({
4886
4917
  trans: t,
4887
4918
  key: e
@@ -4908,7 +4939,7 @@ var Tn = {
4908
4939
  if (n && this.db._maxKey !== dt) return s = n.keyPath.slice(0, t.length), this.where(s).equals(s.map(function(t) {
4909
4940
  return e[t];
4910
4941
  }));
4911
- !n && P && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit from a compound index [${t.join("+")}]`);
4942
+ !n && N && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit from a compound index [${t.join("+")}]`);
4912
4943
  var r = this.schema.idxByName;
4913
4944
  function o(e, t) {
4914
4945
  return B(e, t) === 0;
@@ -5018,7 +5049,7 @@ var Tn = {
5018
5049
  });
5019
5050
  });
5020
5051
  }, V.prototype.update = function(e, t) {
5021
- return typeof e != "object" || a(e) ? this.where(":id").equals(e).modify(t) : (e = b(e, this.schema.primKey.keyPath)) === void 0 ? z(new j.InvalidArgument("Given object does not contain its primary key")) : this.where(":id").equals(e).modify(t);
5052
+ return typeof e != "object" || a(e) ? this.where(":id").equals(e).modify(t) : (e = b(e, this.schema.primKey.keyPath)) === void 0 ? z(new A.InvalidArgument("Given object does not contain its primary key")) : this.where(":id").equals(e).modify(t);
5022
5053
  }, V.prototype.put = function(e, t) {
5023
5054
  var n = this, r = this.schema.primKey, i = r.auto, a = r.keyPath, o = e;
5024
5055
  return a && i && (o = yt(a)(e)), this._trans("readwrite", function(e) {
@@ -5078,8 +5109,8 @@ var Tn = {
5078
5109
  var r = this, i = Array.isArray(t) ? t : void 0, a = (n ||= i ? void 0 : t) ? n.allKeys : void 0;
5079
5110
  return this._trans("readwrite", function(t) {
5080
5111
  var n = r.schema.primKey, o = n.auto, n = n.keyPath;
5081
- if (n && i) throw new j.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
5082
- if (i && i.length !== e.length) throw new j.InvalidArgument("Arguments objects and keys must have the same length");
5112
+ if (n && i) throw new A.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
5113
+ if (i && i.length !== e.length) throw new A.InvalidArgument("Arguments objects and keys must have the same length");
5083
5114
  var s = e.length, o = n && o ? e.map(yt(n)) : e;
5084
5115
  return r.core.mutate({
5085
5116
  trans: t,
@@ -5090,15 +5121,15 @@ var Tn = {
5090
5121
  }).then(function(e) {
5091
5122
  var t = e.numFailures, n = e.failures;
5092
5123
  if (t === 0) return a ? e.results : e.lastResult;
5093
- throw new A(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`, n);
5124
+ throw new k(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`, n);
5094
5125
  });
5095
5126
  });
5096
5127
  }, V.prototype.bulkPut = function(e, t, n) {
5097
5128
  var r = this, i = Array.isArray(t) ? t : void 0, a = (n ||= i ? void 0 : t) ? n.allKeys : void 0;
5098
5129
  return this._trans("readwrite", function(t) {
5099
5130
  var n = r.schema.primKey, o = n.auto, n = n.keyPath;
5100
- if (n && i) throw new j.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
5101
- if (i && i.length !== e.length) throw new j.InvalidArgument("Arguments objects and keys must have the same length");
5131
+ if (n && i) throw new A.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
5132
+ if (i && i.length !== e.length) throw new A.InvalidArgument("Arguments objects and keys must have the same length");
5102
5133
  var s = e.length, o = n && o ? e.map(yt(n)) : e;
5103
5134
  return r.core.mutate({
5104
5135
  trans: t,
@@ -5109,7 +5140,7 @@ var Tn = {
5109
5140
  }).then(function(e) {
5110
5141
  var t = e.numFailures, n = e.failures;
5111
5142
  if (t === 0) return a ? e.results : e.lastResult;
5112
- throw new A(`${r.name}.bulkPut(): ${t} of ${s} operations failed`, n);
5143
+ throw new k(`${r.name}.bulkPut(): ${t} of ${s} operations failed`, n);
5113
5144
  });
5114
5145
  });
5115
5146
  }, V.prototype.bulkUpdate = function(e) {
@@ -5130,7 +5161,7 @@ var Tn = {
5130
5161
  for (var u = 0, d = Object.keys(i); u < d.length; u++) {
5131
5162
  var f = d[u], p = i[f];
5132
5163
  if (f === t.schema.primKey.keyPath) {
5133
- if (B(p, r) !== 0) throw new j.Constraint("Cannot update primary key in bulkUpdate()");
5164
+ if (B(p, r) !== 0) throw new A.Constraint("Cannot update primary key in bulkUpdate()");
5134
5165
  } else x(o, f, p);
5135
5166
  }
5136
5167
  a.push(n), c.push(r), l.push(o);
@@ -5152,7 +5183,7 @@ var Tn = {
5152
5183
  var s, c = o[i], l = a[Number(c)];
5153
5184
  l != null && (s = r[c], delete r[c], r[l] = s);
5154
5185
  }
5155
- throw new A(`${t.name}.bulkUpdate(): ${n} of ${u} operations failed`, r);
5186
+ throw new k(`${t.name}.bulkUpdate(): ${n} of ${u} operations failed`, r);
5156
5187
  });
5157
5188
  });
5158
5189
  });
@@ -5169,7 +5200,7 @@ var Tn = {
5169
5200
  }).then(function(e) {
5170
5201
  var r = e.numFailures, i = e.failures;
5171
5202
  if (r === 0) return e.lastResult;
5172
- throw new A(`${t.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
5203
+ throw new k(`${t.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
5173
5204
  });
5174
5205
  };
5175
5206
  var Dt = V;
@@ -5188,9 +5219,9 @@ var Tn = {
5188
5219
  return t;
5189
5220
  function s(e, r, o) {
5190
5221
  var c, l;
5191
- if (typeof e != "object") return r ||= be, l = {
5222
+ if (typeof e != "object") return r ||= xe, l = {
5192
5223
  subscribers: [],
5193
- fire: o ||= M,
5224
+ fire: o ||= j,
5194
5225
  subscribe: function(e) {
5195
5226
  l.subscribers.indexOf(e) === -1 && (l.subscribers.push(e), l.fire = r(l.fire, e));
5196
5227
  },
@@ -5204,8 +5235,8 @@ var Tn = {
5204
5235
  var t = c[e];
5205
5236
  if (a(t)) s(e, c[e][0], c[e][1]);
5206
5237
  else {
5207
- if (t !== "asap") throw new j.InvalidArgument("Invalid event config");
5208
- var n = s(e, he, function() {
5238
+ if (t !== "asap") throw new A.InvalidArgument("Invalid event config");
5239
+ var n = s(e, ge, function() {
5209
5240
  for (var e = arguments.length, t = Array(e); e--;) t[e] = arguments[e];
5210
5241
  n.subscribers.forEach(function(e) {
5211
5242
  y(function() {
@@ -5236,7 +5267,7 @@ var Tn = {
5236
5267
  if (e.isPrimKey) return t.primaryKey;
5237
5268
  var n = t.getIndexByKeyPath(e.index);
5238
5269
  if (n) return n;
5239
- throw new j.Schema("KeyPath " + e.index + " on object store " + t.name + " is not indexed");
5270
+ throw new A.Schema("KeyPath " + e.index + " on object store " + t.name + " is not indexed");
5240
5271
  }
5241
5272
  function Pt(e, t, n) {
5242
5273
  var r = Nt(e, t.schema);
@@ -5274,9 +5305,9 @@ var Tn = {
5274
5305
  t && !t(e, function(e) {
5275
5306
  return n = e;
5276
5307
  }, function(t) {
5277
- e.stop(t), n = M;
5308
+ e.stop(t), n = j;
5278
5309
  }, function(t) {
5279
- e.fail(t), n = M;
5310
+ e.fail(t), n = j;
5280
5311
  }) || i(e.value, e, function(e) {
5281
5312
  return n = e;
5282
5313
  }), n();
@@ -5528,7 +5559,7 @@ var Tn = {
5528
5559
  range: n.range
5529
5560
  };
5530
5561
  return i(0).then(function() {
5531
- if (0 < f.length) throw new de("Error modifying one or more objects", f, p, m);
5562
+ if (0 < f.length) throw new fe("Error modifying one or more objects", f, p, m);
5532
5563
  return t.length;
5533
5564
  });
5534
5565
  });
@@ -5550,7 +5581,7 @@ var Tn = {
5550
5581
  range: i
5551
5582
  }).then(function(e) {
5552
5583
  var n = e.failures, e = e.numFailures;
5553
- if (e) throw new de("Could not delete some values", Object.keys(n).map(function(e) {
5584
+ if (e) throw new fe("Could not delete some values", Object.keys(n).map(function(e) {
5554
5585
  return n[e];
5555
5586
  }), t - e);
5556
5587
  return t - e;
@@ -5697,19 +5728,19 @@ var Tn = {
5697
5728
  return e === t[0];
5698
5729
  }, [e], "");
5699
5730
  }, W.prototype.anyOfIgnoreCase = function() {
5700
- var e = O.apply(oe, arguments);
5731
+ var e = D.apply(se, arguments);
5701
5732
  return e.length === 0 ? Vt(this) : Ht(this, function(e, t) {
5702
5733
  return t.indexOf(e) !== -1;
5703
5734
  }, e, "");
5704
5735
  }, W.prototype.startsWithAnyOfIgnoreCase = function() {
5705
- var e = O.apply(oe, arguments);
5736
+ var e = D.apply(se, arguments);
5706
5737
  return e.length === 0 ? Vt(this) : Ht(this, function(e, t) {
5707
5738
  return t.some(function(t) {
5708
5739
  return e.indexOf(t) === 0;
5709
5740
  });
5710
5741
  }, e, dt);
5711
5742
  }, W.prototype.anyOf = function() {
5712
- var e, t, n = this, r = O.apply(oe, arguments), i = this._cmp;
5743
+ var e, t, n = this, r = D.apply(se, arguments), i = this._cmp;
5713
5744
  try {
5714
5745
  r.sort(i);
5715
5746
  } catch {
@@ -5731,7 +5762,7 @@ var Tn = {
5731
5762
  includeUppers: !1
5732
5763
  });
5733
5764
  }, W.prototype.noneOf = function() {
5734
- var e = O.apply(oe, arguments);
5765
+ var e = D.apply(se, arguments);
5735
5766
  if (e.length === 0) return new this.Collection(this);
5736
5767
  try {
5737
5768
  e.sort(this._ascending);
@@ -5750,7 +5781,7 @@ var Tn = {
5750
5781
  if (e.length === 0) return Vt(this);
5751
5782
  if (!e.every(function(e) {
5752
5783
  return e[0] !== void 0 && e[1] !== void 0 && i(e[0], e[1]) <= 0;
5753
- })) return U(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", j.InvalidArgument);
5784
+ })) return U(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", A.InvalidArgument);
5754
5785
  var c = !t || !1 !== t.includeLowers, l = t && !0 === t.includeUppers, u, d = i;
5755
5786
  function f(e, t) {
5756
5787
  return d(e[0], t[0]);
@@ -5789,7 +5820,7 @@ var Tn = {
5789
5820
  }), !1);
5790
5821
  }), t;
5791
5822
  }, W.prototype.startsWithAnyOf = function() {
5792
- var e = O.apply(oe, arguments);
5823
+ var e = D.apply(se, arguments);
5793
5824
  return e.every(function(e) {
5794
5825
  return typeof e == "string";
5795
5826
  }) ? e.length === 0 ? Vt(this) : this.inAnyRange(e.map(function(e) {
@@ -5823,15 +5854,15 @@ var Tn = {
5823
5854
  if (this.mode) {
5824
5855
  var n = this.db.idbdb, r = this.db._state.dbOpenError;
5825
5856
  if (v(!this.idbtrans), !e && !n) switch (r && r.name) {
5826
- case "DatabaseClosedError": throw new j.DatabaseClosed(r);
5827
- case "MissingAPIError": throw new j.MissingAPI(r.message, r);
5828
- default: throw new j.OpenFailed(r);
5857
+ case "DatabaseClosedError": throw new A.DatabaseClosed(r);
5858
+ case "MissingAPIError": throw new A.MissingAPI(r.message, r);
5859
+ default: throw new A.OpenFailed(r);
5829
5860
  }
5830
- if (!this.active) throw new j.TransactionInactive();
5861
+ if (!this.active) throw new A.TransactionInactive();
5831
5862
  v(this._completion._state === null), (e = this.idbtrans = e || (this.db.core || n).transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })).onerror = L(function(n) {
5832
5863
  Kt(n), t._reject(e.error);
5833
5864
  }), e.onabort = L(function(n) {
5834
- Kt(n), t.active && t._reject(new j.Abort(e.error)), t.active = !1, t.on("abort").fire(n);
5865
+ Kt(n), t.active && t._reject(new A.Abort(e.error)), t.active = !1, t.on("abort").fire(n);
5835
5866
  }), e.oncomplete = L(function() {
5836
5867
  t.active = !1, t._resolve(), "mutatedParts" in e && Yt.storagemutated.fire(e.mutatedParts);
5837
5868
  });
@@ -5839,7 +5870,7 @@ var Tn = {
5839
5870
  return this;
5840
5871
  }, Zt.prototype._promise = function(e, t, n) {
5841
5872
  var r, i = this;
5842
- return e === "readwrite" && this.mode !== "readwrite" ? z(new j.ReadOnly("Transaction is readonly")) : this.active ? this._locked() ? new I(function(r, a) {
5873
+ return e === "readwrite" && this.mode !== "readwrite" ? z(new A.ReadOnly("Transaction is readonly")) : this.active ? this._locked() ? new I(function(r, a) {
5843
5874
  i._blockedFuncs.push([function() {
5844
5875
  i._promise(e, t, n).then(r, a);
5845
5876
  }, F]);
@@ -5855,7 +5886,7 @@ var Tn = {
5855
5886
  }) : ((r = new I(function(e, n) {
5856
5887
  var r = t(e, n, i);
5857
5888
  r && r.then && r.then(e, n);
5858
- }))._lib = !0, r) : z(new j.TransactionInactive());
5889
+ }))._lib = !0, r) : z(new A.TransactionInactive());
5859
5890
  }, Zt.prototype._root = function() {
5860
5891
  return this.parent ? this.parent._root() : this;
5861
5892
  }, Zt.prototype.waitFor = function(e) {
@@ -5875,13 +5906,13 @@ var Tn = {
5875
5906
  });
5876
5907
  });
5877
5908
  }, Zt.prototype.abort = function() {
5878
- this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new j.Abort()));
5909
+ this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new A.Abort()));
5879
5910
  }, Zt.prototype.table = function(e) {
5880
5911
  var t = this._memoizedTables ||= {};
5881
5912
  if (l(t, e)) return t[e];
5882
5913
  var n = this.schema[e];
5883
5914
  if (n) return (n = new this.db.Table(e, n, this)).core = this.db.core.table(e), t[e] = n;
5884
- throw new j.NotFound("Table " + e + " not part of transaction");
5915
+ throw new A.NotFound("Table " + e + " not part of transaction");
5885
5916
  }, Zt);
5886
5917
  function Zt() {}
5887
5918
  function Qt(e, t, n, r, i, a, o, s) {
@@ -6207,7 +6238,7 @@ var Tn = {
6207
6238
  var t, n, o, l = u, d = e._cfg.dbschema, f = (yn(r, l, c), yn(r, d, c), u = r._dbSchema = d, mn(l, d)), p = (f.add.forEach(function(e) {
6208
6239
  hn(c, e[0], e[1].primKey, e[1].indexes);
6209
6240
  }), f.change.forEach(function(e) {
6210
- if (e.recreate) throw new j.Upgrade("Not yet support for changing primary key");
6241
+ if (e.recreate) throw new A.Upgrade("Not yet support for changing primary key");
6211
6242
  var t = c.objectStore(e.name);
6212
6243
  e.add.forEach(function(e) {
6213
6244
  return _n(t, e);
@@ -6219,7 +6250,7 @@ var Tn = {
6219
6250
  }), e._cfg.contentUpgrade);
6220
6251
  if (p && e._cfg.version > a) return cn(r, c), s._memoizedTables = {}, t = S(d), f.del.forEach(function(e) {
6221
6252
  t[e] = l[e];
6222
- }), un(r, [r.Transaction.prototype]), ln(r, [r.Transaction.prototype], i(t), t), s.schema = t, (n = se(p)) && nt(), d = I.follow(function() {
6253
+ }), un(r, [r.Transaction.prototype]), ln(r, [r.Transaction.prototype], i(t), t), s.schema = t, (n = ce(p)) && nt(), d = I.follow(function() {
6223
6254
  var e;
6224
6255
  (o = p(s)) && n && (e = rt.bind(null, null), o.then(e, e));
6225
6256
  }), o && typeof o.then == "function" ? I.resolve(o) : d.then(function() {
@@ -6258,7 +6289,7 @@ var Tn = {
6258
6289
  if (e.change.length || e.recreate) return console.warn(`Unable to patch indexes of table ${e.name} because it has changes on the type of index or primary key.`), { value: void 0 };
6259
6290
  var n = t.objectStore(e.name);
6260
6291
  e.add.forEach(function(t) {
6261
- P && console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`), _n(n, t);
6292
+ N && console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`), _n(n, t);
6262
6293
  });
6263
6294
  })(i[r]);
6264
6295
  if (typeof a == "object") return a.value;
@@ -6307,7 +6338,7 @@ var Tn = {
6307
6338
  }
6308
6339
  function gn(e, t) {
6309
6340
  i(e).forEach(function(n) {
6310
- t.db.objectStoreNames.contains(n) || (P && console.debug("Dexie: Creating missing table", n), hn(t, n, e[n].primKey, e[n].indexes));
6341
+ t.db.objectStoreNames.contains(n) || (N && console.debug("Dexie: Creating missing table", n), hn(t, n, e[n].primKey, e[n].indexes));
6311
6342
  });
6312
6343
  }
6313
6344
  function _n(e, t) {
@@ -6348,11 +6379,11 @@ var Tn = {
6348
6379
  i(e).forEach(function(r) {
6349
6380
  if (e[r] !== null) {
6350
6381
  var i = n._parseIndexSyntax(e[r]), a = i.shift();
6351
- if (!a) throw new j.Schema("Invalid schema for table " + r + ": " + e[r]);
6352
- if (a.unique = !0, a.multi) throw new j.Schema("Primary key cannot be multiEntry*");
6382
+ if (!a) throw new A.Schema("Invalid schema for table " + r + ": " + e[r]);
6383
+ if (a.unique = !0, a.multi) throw new A.Schema("Primary key cannot be multiEntry*");
6353
6384
  i.forEach(function(e) {
6354
- if (e.auto) throw new j.Schema("Only primary key can be marked as autoIncrement (++)");
6355
- if (!e.keyPath) throw new j.Schema("Index must have a name and cannot be an empty string");
6385
+ if (e.auto) throw new A.Schema("Only primary key can be marked as autoIncrement (++)");
6386
+ if (!e.keyPath) throw new A.Schema("Index must have a name and cannot be an empty string");
6356
6387
  }), a = n._createTableSchema(r, a, i), t[r] = a;
6357
6388
  }
6358
6389
  });
@@ -6371,7 +6402,7 @@ var Tn = {
6371
6402
  this._cfg.tables
6372
6403
  ], i(r), r), t._storeNames = i(r), this;
6373
6404
  }, q.prototype.upgrade = function(e) {
6374
- return this._cfg.contentUpgrade = xe(this._cfg.contentUpgrade || M, e), this;
6405
+ return this._cfg.contentUpgrade = Se(this._cfg.contentUpgrade || j, e), this;
6375
6406
  };
6376
6407
  var xn = q;
6377
6408
  function q() {}
@@ -6535,7 +6566,7 @@ var Tn = {
6535
6566
  return t[n] && En(t[n], e[n]);
6536
6567
  });
6537
6568
  }
6538
- u(Z.prototype, ((k = {
6569
+ u(Z.prototype, ((O = {
6539
6570
  add: function(e) {
6540
6571
  return Tn(this, e), this;
6541
6572
  },
@@ -6554,7 +6585,7 @@ var Tn = {
6554
6585
  }
6555
6586
  })[ae] = function() {
6556
6587
  return Dn(this);
6557
- }, k));
6588
+ }, O));
6558
6589
  var Q = {}, Mn = {}, Nn = !1;
6559
6590
  function Pn(e) {
6560
6591
  An(Mn, e), Nn || (Nn = !0, setTimeout(function() {
@@ -6596,17 +6627,17 @@ var Tn = {
6596
6627
  t.isBeingOpened = !0, t.dbOpenError = null, t.openComplete = !1;
6597
6628
  var r = t.openCanceller, a = Math.round(10 * e.verno), o = !1;
6598
6629
  function s() {
6599
- if (t.openCanceller !== r) throw new j.DatabaseClosed("db.open() was cancelled");
6630
+ if (t.openCanceller !== r) throw new A.DatabaseClosed("db.open() was cancelled");
6600
6631
  }
6601
6632
  function c() {
6602
6633
  return new I(function(r, l) {
6603
- if (s(), !n) throw new j.MissingAPI();
6634
+ if (s(), !n) throw new A.MissingAPI();
6604
6635
  var u = e.name, p = t.autoSchema || !a ? n.open(u) : n.open(u, a);
6605
- if (!p) throw new j.MissingAPI();
6636
+ if (!p) throw new A.MissingAPI();
6606
6637
  p.onerror = G(l), p.onblocked = L(e._fireOnBlocked), p.onupgradeneeded = L(function(r) {
6607
6638
  var i;
6608
6639
  d = p.transaction, t.autoSchema && !e._options.allowEmptyDB ? (p.onerror = Kt, d.abort(), p.result.close(), (i = n.deleteDatabase(u)).onsuccess = i.onerror = L(function() {
6609
- l(new j.NoSuchDatabase(`Database ${u} doesnt exist`));
6640
+ l(new A.NoSuchDatabase(`Database ${u} doesnt exist`));
6610
6641
  })) : (d.onerror = G(l), i = r.oldVersion > 2 ** 62 ? 0 : r.oldVersion, f = i < 1, e.idbdb = p.result, o && pn(e, d), fn(e, i / 10, d, l));
6611
6642
  }, l), p.onsuccess = L(function() {
6612
6643
  d = null;
@@ -6623,7 +6654,7 @@ var Tn = {
6623
6654
  t.vcFired = !0, e.on("versionchange").fire(n);
6624
6655
  }), v.onclose = L(function() {
6625
6656
  e.close({ disableAutoOpen: !1 });
6626
- }), f && (y = e._deps, h = u, Sn(_ = y.indexedDB) || h === mt || Y(_, y.IDBKeyRange).put({ name: h }).catch(M)), r();
6657
+ }), f && (y = e._deps, h = u, Sn(_ = y.indexedDB) || h === mt || Y(_, y.IDBKeyRange).put({ name: h }).catch(j)), r();
6627
6658
  }, l);
6628
6659
  }).catch(function(e) {
6629
6660
  switch (e?.name) {
@@ -6648,7 +6679,7 @@ var Tn = {
6648
6679
  return e.on.ready.fire(e.vip);
6649
6680
  })).then(function n() {
6650
6681
  var r;
6651
- if (0 < t.onReadyBeingFired.length) return r = t.onReadyBeingFired.reduce(xe, M), t.onReadyBeingFired = [], I.resolve(Cn(function() {
6682
+ if (0 < t.onReadyBeingFired.length) return r = t.onReadyBeingFired.reduce(Se, j), t.onReadyBeingFired = [], I.resolve(Cn(function() {
6652
6683
  return r(e.vip);
6653
6684
  })).then(n);
6654
6685
  });
@@ -6796,22 +6827,22 @@ var Tn = {
6796
6827
  var o = F.trans, s = o.table(r).hook, c = s.deleting, u = s.creating, d = s.updating;
6797
6828
  switch (e.type) {
6798
6829
  case "add":
6799
- if (u.fire === M) break;
6830
+ if (u.fire === j) break;
6800
6831
  return o._promise("readwrite", function() {
6801
6832
  return f(e);
6802
6833
  }, !0);
6803
6834
  case "put":
6804
- if (u.fire === M && d.fire === M) break;
6835
+ if (u.fire === j && d.fire === j) break;
6805
6836
  return o._promise("readwrite", function() {
6806
6837
  return f(e);
6807
6838
  }, !0);
6808
6839
  case "delete":
6809
- if (c.fire === M) break;
6840
+ if (c.fire === j) break;
6810
6841
  return o._promise("readwrite", function() {
6811
6842
  return f(e);
6812
6843
  }, !0);
6813
6844
  case "deleteRange":
6814
- if (c.fire === M) break;
6845
+ if (c.fire === j) break;
6815
6846
  return o._promise("readwrite", function() {
6816
6847
  return function e(n, r, o) {
6817
6848
  return i.query({
@@ -6934,7 +6965,7 @@ var Tn = {
6934
6965
  var n = e.schema.name, r = new Z(e.MIN_KEY, e.MAX_KEY);
6935
6966
  return t(t({}, e), {
6936
6967
  transaction: function(t, n, r) {
6937
- if (F.subscr && n !== "readonly") throw new j.ReadOnly(`Readwrite transaction in liveQuery context. Querier source: ${F.querier}`);
6968
+ if (F.subscr && n !== "readonly") throw new A.ReadOnly(`Readwrite transaction in liveQuery context. Querier source: ${F.querier}`);
6938
6969
  return e.transaction(t, n, r);
6939
6970
  },
6940
6971
  table: function(o) {
@@ -7124,7 +7155,7 @@ var Tn = {
7124
7155
  e.subscribers.add(n), r.addEventListener("abort", function() {
7125
7156
  var r, i;
7126
7157
  e.subscribers.delete(n), e.subscribers.size === 0 && (r = e, i = t, setTimeout(function() {
7127
- r.subscribers.size === 0 && D(i, r);
7158
+ r.subscribers.size === 0 && oe(i, r);
7128
7159
  }, 3e3));
7129
7160
  });
7130
7161
  }
@@ -7146,16 +7177,16 @@ var Tn = {
7146
7177
  var f = e.table(u), p = d.optimisticOps.filter(function(e) {
7147
7178
  return e.trans === s;
7148
7179
  });
7149
- if (s._explicit && i && s.mutatedParts) for (var m = 0, h = Object.values(d.queries.query); m < h.length; m++) for (var g = 0, _ = (b = h[m]).slice(); g < _.length; g++) jn((x = _[g]).obsSet, s.mutatedParts) && (D(b, x), x.subscribers.forEach(function(e) {
7180
+ if (s._explicit && i && s.mutatedParts) for (var m = 0, h = Object.values(d.queries.query); m < h.length; m++) for (var g = 0, _ = (b = h[m]).slice(); g < _.length; g++) jn((x = _[g]).obsSet, s.mutatedParts) && (oe(b, x), x.subscribers.forEach(function(e) {
7150
7181
  return o.add(e);
7151
7182
  }));
7152
7183
  else if (0 < p.length) {
7153
7184
  d.optimisticOps = d.optimisticOps.filter(function(e) {
7154
7185
  return e.trans !== s;
7155
7186
  });
7156
- for (var v = 0, y = Object.values(d.queries.query); v < y.length; v++) for (var b, x, S, C = 0, ee = (b = y[v]).slice(); C < ee.length; C++) (x = ee[C]).res != null && s.mutatedParts && (i && !x.dirty ? (S = Object.isFrozen(x.res), S = Zn(x.res, x.req, p, f, x, S), x.dirty ? (D(b, x), x.subscribers.forEach(function(e) {
7187
+ for (var v = 0, y = Object.values(d.queries.query); v < y.length; v++) for (var b, x, S, C = 0, ee = (b = y[v]).slice(); C < ee.length; C++) (x = ee[C]).res != null && s.mutatedParts && (i && !x.dirty ? (S = Object.isFrozen(x.res), S = Zn(x.res, x.req, p, f, x, S), x.dirty ? (oe(b, x), x.subscribers.forEach(function(e) {
7157
7188
  return o.add(e);
7158
- })) : S !== x.res && (x.res = S, x.promise = I.resolve({ result: S }))) : (x.dirty && D(b, x), x.subscribers.forEach(function(e) {
7189
+ })) : S !== x.res && (x.res = S, x.promise = I.resolve({ result: S }))) : (x.dirty && oe(b, x), x.subscribers.forEach(function(e) {
7159
7190
  return o.add(e);
7160
7191
  })));
7161
7192
  }
@@ -7176,9 +7207,9 @@ var Tn = {
7176
7207
  return !a.outbound && s.db._options.cache !== "disabled" && !s.explicit && s.idbtrans.mode === "readwrite" && (o = Q[`idb://${n}/${r}`]) ? (s = i.mutate(e), e.type !== "add" && e.type !== "put" || !(50 <= e.values.length || Hn(a, e).some(function(e) {
7177
7208
  return e == null;
7178
7209
  })) ? (o.optimisticOps.push(e), e.mutatedParts && Pn(e.mutatedParts), s.then(function(t) {
7179
- 0 < t.numFailures && (D(o.optimisticOps, e), (t = Yn(0, e, t)) && o.optimisticOps.push(t), e.mutatedParts) && Pn(e.mutatedParts);
7210
+ 0 < t.numFailures && (oe(o.optimisticOps, e), (t = Yn(0, e, t)) && o.optimisticOps.push(t), e.mutatedParts) && Pn(e.mutatedParts);
7180
7211
  }), s.catch(function() {
7181
- D(o.optimisticOps, e), e.mutatedParts && Pn(e.mutatedParts);
7212
+ oe(o.optimisticOps, e), e.mutatedParts && Pn(e.mutatedParts);
7182
7213
  })) : s.then(function(n) {
7183
7214
  var r = Yn(0, t(t({}, e), { values: e.values.map(function(e, r) {
7184
7215
  var i;
@@ -7242,7 +7273,7 @@ var Tn = {
7242
7273
  }
7243
7274
  return e;
7244
7275
  }).catch(function(e) {
7245
- return c && u && D(c, u), Promise.reject(e);
7276
+ return c && u && oe(c, u), Promise.reject(e);
7246
7277
  }), u = {
7247
7278
  obsSet: e.obsSet,
7248
7279
  promise: l,
@@ -7273,8 +7304,8 @@ var Tn = {
7273
7304
  } });
7274
7305
  }
7275
7306
  $.prototype.version = function(e) {
7276
- if (isNaN(e) || e < .1) throw new j.Type("Given version is not a positive number");
7277
- if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened) throw new j.Schema("Cannot add version when database is open");
7307
+ if (isNaN(e) || e < .1) throw new A.Type("Given version is not a positive number");
7308
+ if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened) throw new A.Schema("Cannot add version when database is open");
7278
7309
  this.verno = Math.max(this.verno, e);
7279
7310
  var t = this._versions, n = t.filter(function(t) {
7280
7311
  return t._cfg.version === e;
@@ -7283,10 +7314,10 @@ var Tn = {
7283
7314
  }, $.prototype._whenReady = function(e) {
7284
7315
  var t = this;
7285
7316
  return this.idbdb && (this._state.openComplete || F.letThrough || this._vip) ? e() : new I(function(e, n) {
7286
- if (t._state.openComplete) return n(new j.DatabaseClosed(t._state.dbOpenError));
7317
+ if (t._state.openComplete) return n(new A.DatabaseClosed(t._state.dbOpenError));
7287
7318
  if (!t._state.isBeingOpened) {
7288
- if (!t._state.autoOpen) return void n(new j.DatabaseClosed());
7289
- t.open().catch(M);
7319
+ if (!t._state.autoOpen) return void n(new A.DatabaseClosed());
7320
+ t.open().catch(j);
7290
7321
  }
7291
7322
  t._state.dbReadyPromise.then(e, n);
7292
7323
  }).then(e);
@@ -7329,7 +7360,7 @@ var Tn = {
7329
7360
  }));
7330
7361
  }, $.prototype.close = function(e) {
7331
7362
  var e = (e === void 0 ? { disableAutoOpen: !0 } : e).disableAutoOpen, t = this._state;
7332
- e ? (t.isBeingOpened && t.cancelOpen(new j.DatabaseClosed()), this._close(), t.autoOpen = !1, t.dbOpenError = new j.DatabaseClosed()) : (this._close(), t.autoOpen = this._options.autoOpen || t.isBeingOpened, t.openComplete = !1, t.dbOpenError = null);
7363
+ e ? (t.isBeingOpened && t.cancelOpen(new A.DatabaseClosed()), this._close(), t.autoOpen = !1, t.dbOpenError = new A.DatabaseClosed()) : (this._close(), t.autoOpen = this._options.autoOpen || t.isBeingOpened, t.openComplete = !1, t.dbOpenError = null);
7333
7364
  }, $.prototype.delete = function(e) {
7334
7365
  var t = this, n = (e === void 0 && (e = { disableAutoOpen: !0 }), 0 < arguments.length && typeof arguments[0] != "object"), r = this._state;
7335
7366
  return new I(function(i, a) {
@@ -7338,10 +7369,10 @@ var Tn = {
7338
7369
  var n = t._deps.indexedDB.deleteDatabase(t.name);
7339
7370
  n.onsuccess = L(function() {
7340
7371
  var e = t._deps, n = t.name, r;
7341
- Sn(r = e.indexedDB) || n === mt || Y(r, e.IDBKeyRange).delete(n).catch(M), i();
7372
+ Sn(r = e.indexedDB) || n === mt || Y(r, e.IDBKeyRange).delete(n).catch(j), i();
7342
7373
  }), n.onerror = G(a), n.onblocked = t._fireOnBlocked;
7343
7374
  }
7344
- if (n) throw new j.InvalidArgument("Invalid closeOptions argument to db.delete()");
7375
+ if (n) throw new A.InvalidArgument("Invalid closeOptions argument to db.delete()");
7345
7376
  r.isBeingOpened ? r.dbReadyPromise.then(o) : o();
7346
7377
  });
7347
7378
  }, $.prototype.backendDB = function() {
@@ -7367,7 +7398,7 @@ var Tn = {
7367
7398
  }), $.prototype.transaction = function() {
7368
7399
  var e = function(e, t, n) {
7369
7400
  var r = arguments.length;
7370
- if (r < 2) throw new j.InvalidArgument("Too few arguments");
7401
+ if (r < 2) throw new A.InvalidArgument("Too few arguments");
7371
7402
  for (var i = Array(r - 1); --r;) i[r - 1] = arguments[r];
7372
7403
  return n = i.pop(), [
7373
7404
  e,
@@ -7385,17 +7416,17 @@ var Tn = {
7385
7416
  return e;
7386
7417
  }), e == "r" || e === ht) r = ht;
7387
7418
  else {
7388
- if (e != "rw" && e != gt) throw new j.InvalidArgument("Invalid transaction mode: " + e);
7419
+ if (e != "rw" && e != gt) throw new A.InvalidArgument("Invalid transaction mode: " + e);
7389
7420
  r = gt;
7390
7421
  }
7391
7422
  if (o) {
7392
7423
  if (o.mode === ht && r === gt) {
7393
- if (!s) throw new j.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
7424
+ if (!s) throw new A.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
7394
7425
  o = null;
7395
7426
  }
7396
7427
  o && i.forEach(function(e) {
7397
7428
  if (o && o.storeNames.indexOf(e) === -1) {
7398
- if (!s) throw new j.SubTransaction("Table " + e + " not included in parent transaction.");
7429
+ if (!s) throw new A.SubTransaction("Table " + e + " not included in parent transaction.");
7399
7430
  o = null;
7400
7431
  }
7401
7432
  }), s && o && !o.active && (o = null);
@@ -7415,16 +7446,16 @@ var Tn = {
7415
7446
  else try {
7416
7447
  s.create(), s.idbtrans._explicit = !0, t._state.PR1398_maxLoop = 3;
7417
7448
  } catch (i) {
7418
- return i.name === fe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
7449
+ return i.name === pe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
7419
7450
  return e(t, n, r, null, a);
7420
7451
  })) : z(i);
7421
7452
  }
7422
- var c, l = se(a), o = (l && nt(), I.follow(function() {
7453
+ var c, l = ce(a), o = (l && nt(), I.follow(function() {
7423
7454
  var e;
7424
7455
  (c = a.call(s, s)) && (l ? (e = rt.bind(null, null), c.then(e, e)) : typeof c.next == "function" && typeof c.throw == "function" && (c = Rn(c)));
7425
7456
  }, o));
7426
7457
  return (c && typeof c.then == "function" ? I.resolve(c).then(function(e) {
7427
- return s.active ? e : z(new j.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"));
7458
+ return s.active ? e : z(new A.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"));
7428
7459
  }) : o.then(function() {
7429
7460
  return c;
7430
7461
  })).then(function(e) {
@@ -7441,7 +7472,7 @@ var Tn = {
7441
7472
  }) : this._whenReady(c);
7442
7473
  }, $.prototype.table = function(e) {
7443
7474
  if (l(this._allTables, e)) return this._allTables[e];
7444
- throw new j.InvalidTable(`Table ${e} does not exist`);
7475
+ throw new A.InvalidTable(`Table ${e} does not exist`);
7445
7476
  };
7446
7477
  var rr = $;
7447
7478
  function $(e, n) {
@@ -7460,9 +7491,9 @@ var Tn = {
7460
7491
  isBeingOpened: !1,
7461
7492
  onReadyBeingFired: null,
7462
7493
  openComplete: !1,
7463
- dbReadyResolve: M,
7494
+ dbReadyResolve: j,
7464
7495
  dbReadyPromise: null,
7465
- cancelOpen: M,
7496
+ cancelOpen: j,
7466
7497
  openCanceller: null,
7467
7498
  autoSchema: !0,
7468
7499
  PR1398_maxLoop: 3,
@@ -7471,7 +7502,7 @@ var Tn = {
7471
7502
  u.dbReadyResolve = e;
7472
7503
  }), u.openCanceller = new I(function(e, t) {
7473
7504
  u.cancelOpen = t;
7474
- }), this._state = u, this.name = e, this.on = Ot(this, "populate", "blocked", "versionchange", "close", { ready: [xe, M] }), this.once = function(e, t) {
7505
+ }), this._state = u, this.name = e, this.on = Ot(this, "populate", "blocked", "versionchange", "close", { ready: [Se, j] }), this.once = function(e, t) {
7475
7506
  var n = function() {
7476
7507
  var r = [...arguments];
7477
7508
  c.on(e).unsubscribe(n), t.apply(c, r);
@@ -7512,14 +7543,14 @@ var Tn = {
7512
7543
  limit: Infinity,
7513
7544
  error: i,
7514
7545
  or: t.or,
7515
- valueMapper: a === he ? null : a
7546
+ valueMapper: a === ge ? null : a
7516
7547
  };
7517
7548
  })), this.Table = (i = this, kt(Dt.prototype, function(e, t, n) {
7518
7549
  this.db = i, this._tx = n, this.name = e, this.schema = t, this.hook = i._allTables[e] ? i._allTables[e].hook : Ot(null, {
7519
- creating: [_e, M],
7520
- reading: [N, he],
7521
- updating: [ye, M],
7522
- deleting: [ve, M]
7550
+ creating: [ve, j],
7551
+ reading: [M, ge],
7552
+ updating: [be, j],
7553
+ deleting: [ye, j]
7523
7554
  });
7524
7555
  })), this.Transaction = (a = this, kt(Xt.prototype, function(e, t, n, r, i) {
7525
7556
  var o = this;
@@ -7554,7 +7585,7 @@ var Tn = {
7554
7585
  return 0 < B(e, t) ? e : t;
7555
7586
  }, this._min = function(e, t) {
7556
7587
  return B(e, t) < 0 ? e : t;
7557
- }, this._IDBKeyRange = s._deps.IDBKeyRange, !this._IDBKeyRange) throw new j.MissingAPI();
7588
+ }, this._IDBKeyRange = s._deps.IDBKeyRange, !this._IDBKeyRange) throw new A.MissingAPI();
7558
7589
  })), this.on("versionchange", function(e) {
7559
7590
  0 < e.newVersion ? console.warn(`Another connection wants to upgrade database '${c.name}'. Closing db now to resume the upgrade.`) : console.warn(`Another connection wants to delete database '${c.name}'. Closing db now to resume the delete request.`), c.close({ disableAutoOpen: !1 });
7560
7591
  }), this.on("blocked", function(e) {
@@ -7606,7 +7637,7 @@ var Tn = {
7606
7637
  }
7607
7638
  function sr(e) {
7608
7639
  var t, n = !1, r = new ar(function(r) {
7609
- var i = se(e), a, o = !1, s = {}, c = {}, l = {
7640
+ var i = ce(e), a, o = !1, s = {}, c = {}, l = {
7610
7641
  get closed() {
7611
7642
  return o;
7612
7643
  },
@@ -7686,7 +7717,7 @@ var Tn = {
7686
7717
  });
7687
7718
  }) : Y(n, t).toCollection().primaryKeys()).then(e);
7688
7719
  } catch {
7689
- return z(new j.MissingAPI());
7720
+ return z(new A.MissingAPI());
7690
7721
  }
7691
7722
  var t, n;
7692
7723
  },
@@ -7726,10 +7757,10 @@ var Tn = {
7726
7757
  Promise: I,
7727
7758
  debug: {
7728
7759
  get: function() {
7729
- return P;
7760
+ return N;
7730
7761
  },
7731
7762
  set: function(e) {
7732
- Se(e);
7763
+ Ce(e);
7733
7764
  }
7734
7765
  },
7735
7766
  derive: p,
@@ -7755,7 +7786,7 @@ var Tn = {
7755
7786
  minKey: -Infinity,
7756
7787
  addons: [],
7757
7788
  connections: { get: J.toArray },
7758
- errnames: fe,
7789
+ errnames: pe,
7759
7790
  dependencies: ir,
7760
7791
  cache: Q,
7761
7792
  semVer: "4.4.6",
@@ -7778,16 +7809,16 @@ var Tn = {
7778
7809
  dr || ur.postMessage(e);
7779
7810
  })), typeof addEventListener < "u" && (addEventListener("pagehide", function(e) {
7780
7811
  if (!rr.disableBfCache && e.persisted) {
7781
- P && console.debug("Dexie: handling persisted pagehide"), ur?.close();
7812
+ N && console.debug("Dexie: handling persisted pagehide"), ur?.close();
7782
7813
  for (var t = 0, n = J.toArray(); t < n.length; t++) n[t].close({ disableAutoOpen: !1 });
7783
7814
  }
7784
7815
  }), addEventListener("pageshow", function(e) {
7785
- !rr.disableBfCache && e.persisted && (P && console.debug("Dexie: handling persisted pageshow"), fr(), lr({ all: new Z(-Infinity, [[]]) }));
7816
+ !rr.disableBfCache && e.persisted && (N && console.debug("Dexie: handling persisted pageshow"), fr(), lr({ all: new Z(-Infinity, [[]]) }));
7786
7817
  })), I.rejectionMapper = function(e, t) {
7787
- return !e || e instanceof le || e instanceof TypeError || e instanceof SyntaxError || !e.name || !me[e.name] ? e : (t = new me[e.name](t || e.message, e), "stack" in e && f(t, "stack", { get: function() {
7818
+ return !e || e instanceof ue || e instanceof TypeError || e instanceof SyntaxError || !e.name || !he[e.name] ? e : (t = new he[e.name](t || e.message, e), "stack" in e && f(t, "stack", { get: function() {
7788
7819
  return this.inner.stack;
7789
7820
  } }), t);
7790
- }, Se(P), t(rr, Object.freeze({
7821
+ }, Ce(N), t(rr, Object.freeze({
7791
7822
  __proto__: null,
7792
7823
  DEFAULT_MAX_CONNECTIONS: 1e3,
7793
7824
  Dexie: rr,
@@ -7829,7 +7860,7 @@ var Wn = {
7829
7860
  arrayIndexes: []
7830
7861
  }, Gn = class {
7831
7862
  constructor(e, t) {
7832
- this.schemaVersion = 1, this.knownDocuments = /* @__PURE__ */ new Map(), this.schemaLock = Promise.resolve(), this.stale = !1, this.name = e, this.dexieRecordSchema = Un(t?.recordSchema ?? Wn), this.perf = t?.perf ?? Mt, this.db = new Q(e);
7863
+ this.schemaVersion = 1, this.knownDocuments = /* @__PURE__ */ new Map(), this.schemaLock = Promise.resolve(), this.stale = !1, this.recordCounts = /* @__PURE__ */ new Map(), this.name = e, this.dexieRecordSchema = Un(t?.recordSchema ?? Wn), this.perf = t?.perf ?? Mt, this.db = new Q(e);
7833
7864
  }
7834
7865
  async open() {
7835
7866
  await this.reloadFromPersisted();
@@ -7838,7 +7869,7 @@ var Wn = {
7838
7869
  this.db.close();
7839
7870
  }
7840
7871
  async destroy() {
7841
- this.db.isOpen() && (this.db.close(), await Kn()), await Q.delete(this.name), this.knownDocuments.clear();
7872
+ this.db.isOpen() && (this.db.close(), await Kn()), await Q.delete(this.name), this.knownDocuments.clear(), this.recordCounts.clear();
7842
7873
  }
7843
7874
  async reconcile() {
7844
7875
  await this.ensureCurrentSchema();
@@ -7868,13 +7899,17 @@ var Wn = {
7868
7899
  });
7869
7900
  }
7870
7901
  async removeDocument(e) {
7871
- await this.withSchemaLock(async () => {
7872
- this.stale && await this.reloadFromPersisted();
7873
- let t = this.resolveTableName(e);
7874
- this.db.tables.some((e) => e.name === t) && await this.db.table(t).clear();
7875
- let n = wn(e);
7876
- this.db.tables.some((e) => e.name === n) && await this.db.table(n).clear(), await this.db.table(X).where({ documentId: e }).delete(), await this.db.table(J).where({ documentId: e }).delete(), await this.db.table(Y).delete(`head:${e}`), await this.db.table(q).delete(e), this.knownDocuments.delete(e), await this.reopenWithNewSchema({ drop: e });
7877
- });
7902
+ try {
7903
+ await this.withSchemaLock(async () => {
7904
+ this.stale && await this.reloadFromPersisted();
7905
+ let t = this.resolveTableName(e);
7906
+ this.db.tables.some((e) => e.name === t) && await this.db.table(t).clear();
7907
+ let n = wn(e);
7908
+ this.db.tables.some((e) => e.name === n) && await this.db.table(n).clear(), await this.db.table(X).where({ documentId: e }).delete(), await this.db.table(J).where({ documentId: e }).delete(), await this.db.table(Y).delete(`head:${e}`), await this.db.table(q).delete(e), this.knownDocuments.delete(e), await this.reopenWithNewSchema({ drop: e });
7909
+ });
7910
+ } finally {
7911
+ this.recordCounts.delete(e);
7912
+ }
7878
7913
  }
7879
7914
  async get(e, t) {
7880
7915
  if (await this.ensureCurrentSchema(), t) return this.db.table(this.resolveTableName(t)).get(e);
@@ -7886,6 +7921,13 @@ var Wn = {
7886
7921
  async getByDocumentId(e) {
7887
7922
  return await this.ensureCurrentSchema(), this.db.table(this.resolveTableName(e)).toArray();
7888
7923
  }
7924
+ async count(e) {
7925
+ let t = this.recordCounts.get(e);
7926
+ if (t !== void 0) return t;
7927
+ await this.ensureCurrentSchema();
7928
+ let n = await this.db.table(this.resolveTableName(e)).count();
7929
+ return this.recordCounts.set(e, n), n;
7930
+ }
7889
7931
  async getByTagNameInDocument(e, t) {
7890
7932
  return await this.ensureCurrentSchema(), this.db.table(this.resolveTableName(t)).where({ tagName: e }).toArray();
7891
7933
  }
@@ -7893,120 +7935,136 @@ var Wn = {
7893
7935
  return await this.ensureCurrentSchema(), this.db.table(this.resolveTableName(t)).bulkGet(e);
7894
7936
  }
7895
7937
  async bulkWrite(e, t) {
7896
- await this.ensureCurrentSchema();
7897
- let { creates: n, updates: r, deletes: i } = t, a = this.db.table(this.resolveTableName(e));
7898
- await this.db.transaction("rw", a, async () => {
7899
- if (n?.length && (this.perf.start("core::store::bulkWrite::add"), await a.bulkAdd(n), this.perf.stop("core::store::bulkWrite::add")), r?.length) {
7900
- this.perf.start("core::store::bulkWrite::update");
7901
- for (let { recordId: e, removeAttributes: t, ...n } of r) {
7902
- let r = await a.get(e);
7903
- if (!r) continue;
7904
- let i = { ...n };
7905
- if (n.attributes) {
7906
- let e = [...r.attributes];
7907
- for (let t of n.attributes) {
7908
- let n = e.findIndex((e) => e.name === t.name);
7909
- n >= 0 ? e[n] = t : e.push(t);
7938
+ try {
7939
+ await this.ensureCurrentSchema();
7940
+ let { creates: n, updates: r, deletes: i } = t, a = this.db.table(this.resolveTableName(e));
7941
+ await this.db.transaction("rw", a, async () => {
7942
+ if (n?.length && (this.perf.start("core::store::bulkWrite::add"), await a.bulkAdd(n), this.perf.stop("core::store::bulkWrite::add")), r?.length) {
7943
+ this.perf.start("core::store::bulkWrite::update");
7944
+ for (let { recordId: e, removeAttributes: t, ...n } of r) {
7945
+ let r = await a.get(e);
7946
+ if (!r) continue;
7947
+ let i = { ...n };
7948
+ if (n.attributes) {
7949
+ let e = [...r.attributes];
7950
+ for (let t of n.attributes) {
7951
+ let n = e.findIndex((e) => e.name === t.name);
7952
+ n >= 0 ? e[n] = t : e.push(t);
7953
+ }
7954
+ i.attributes = e;
7910
7955
  }
7911
- i.attributes = e;
7912
- }
7913
- if (t?.length && (i.attributes = (i.attributes ?? r.attributes).filter((e) => !t.includes(e.name))), n.children) {
7914
- let e = [...r.children];
7915
- for (let t of n.children) {
7916
- let n = e.findIndex((e) => e.id === t.id);
7917
- n >= 0 ? e[n] = t : e.push(t);
7956
+ if (t?.length && (i.attributes = (i.attributes ?? r.attributes).filter((e) => !t.includes(e.name))), n.children) {
7957
+ let e = [...r.children];
7958
+ for (let t of n.children) {
7959
+ let n = e.findIndex((e) => e.id === t.id);
7960
+ n >= 0 ? e[n] = t : e.push(t);
7961
+ }
7962
+ i.children = e;
7918
7963
  }
7919
- i.children = e;
7964
+ await a.update(e, i);
7920
7965
  }
7921
- await a.update(e, i);
7966
+ this.perf.stop("core::store::bulkWrite::update");
7922
7967
  }
7923
- this.perf.stop("core::store::bulkWrite::update");
7924
- }
7925
- i?.length && (this.perf.start("core::store::bulkWrite::delete"), await a.bulkDelete(i), this.perf.stop("core::store::bulkWrite::delete"));
7926
- });
7968
+ i?.length && (this.perf.start("core::store::bulkWrite::delete"), await a.bulkDelete(i), this.perf.stop("core::store::bulkWrite::delete"));
7969
+ });
7970
+ } finally {
7971
+ this.recordCounts.delete(e);
7972
+ }
7927
7973
  }
7928
7974
  async commit(e) {
7929
- await this.ensureCurrentSchema();
7930
- let { documentId: t, creates: n, updates: i, deletes: a, onProgress: o } = e, s = this.db.table(this.resolveTableName(t)), c = n.length + i.length + a.length, l = 0;
7931
7975
  try {
7932
- await this.db.transaction("rw", s, this.db.table(J), this.db.table(Y), async () => {
7933
- let e = i.length > 0 ? await s.bulkGet(i.map((e) => e.id)) : [], u = a.length > 0 ? await s.bulkGet(a) : [];
7934
- if (n.length > 0) try {
7935
- await s.bulkAdd(n), l += n.length, o(l, c);
7936
- } catch (e) {
7937
- r("STORE_BULK_ADD_FAILED", {
7938
- detail: e instanceof Error ? e.message : String(e),
7939
- cause: e instanceof Error ? e : void 0
7940
- });
7941
- }
7942
- if (i.length > 0) try {
7943
- await s.bulkPut(i), l += i.length, o(l, c);
7944
- } catch (e) {
7945
- r("STORE_BULK_UPDATE_FAILED", {
7946
- detail: e instanceof Error ? e.message : String(e),
7947
- cause: e instanceof Error ? e : void 0
7948
- });
7949
- }
7950
- if (a.length > 0) try {
7951
- await s.bulkDelete(a), l += a.length, o(l, c);
7952
- } catch (e) {
7953
- r("STORE_DELETE_FAILED", {
7954
- detail: e instanceof Error ? e.message : String(e),
7955
- cause: e instanceof Error ? e : void 0
7956
- });
7957
- }
7958
- let d = await this.getHead(t), f = await this.db.table(J).where({ documentId: t }).filter((e) => e.sequenceNumber > d).toArray();
7959
- f.length > 0 && await this.db.table(J).bulkDelete(f.map((e) => e.id));
7960
- let p = d + 1, m = {
7961
- documentId: t,
7962
- sequenceNumber: p,
7963
- timestamp: Date.now(),
7964
- operations: {
7965
- creates: n,
7966
- updates: i.map((t, n) => ({
7967
- before: e[n],
7968
- after: t
7969
- })),
7970
- deletes: u.filter(Boolean)
7976
+ await this.ensureCurrentSchema();
7977
+ let { documentId: t, creates: n, updates: i, deletes: a, onProgress: o } = e, s = this.db.table(this.resolveTableName(t)), c = n.length + i.length + a.length, l = 0;
7978
+ try {
7979
+ await this.db.transaction("rw", s, this.db.table(J), this.db.table(Y), async () => {
7980
+ let e = i.length > 0 ? await s.bulkGet(i.map((e) => e.id)) : [], u = a.length > 0 ? await s.bulkGet(a) : [];
7981
+ if (n.length > 0) try {
7982
+ await s.bulkAdd(n), l += n.length, o(l, c);
7983
+ } catch (e) {
7984
+ r("STORE_BULK_ADD_FAILED", {
7985
+ detail: e instanceof Error ? e.message : String(e),
7986
+ cause: e instanceof Error ? e : void 0
7987
+ });
7971
7988
  }
7972
- };
7973
- await this.db.table(J).add(m), await this.setHead(t, p);
7974
- });
7975
- } catch (e) {
7976
- if (e instanceof Error && e.message.includes("dialecte")) throw e;
7977
- r("STORE_COMMIT_FAILED", {
7978
- detail: e instanceof Error ? e.message : String(e),
7979
- cause: e instanceof Error ? e : void 0
7980
- });
7989
+ if (i.length > 0) try {
7990
+ await s.bulkPut(i), l += i.length, o(l, c);
7991
+ } catch (e) {
7992
+ r("STORE_BULK_UPDATE_FAILED", {
7993
+ detail: e instanceof Error ? e.message : String(e),
7994
+ cause: e instanceof Error ? e : void 0
7995
+ });
7996
+ }
7997
+ if (a.length > 0) try {
7998
+ await s.bulkDelete(a), l += a.length, o(l, c);
7999
+ } catch (e) {
8000
+ r("STORE_DELETE_FAILED", {
8001
+ detail: e instanceof Error ? e.message : String(e),
8002
+ cause: e instanceof Error ? e : void 0
8003
+ });
8004
+ }
8005
+ let d = await this.getHead(t), f = await this.db.table(J).where({ documentId: t }).filter((e) => e.sequenceNumber > d).toArray();
8006
+ f.length > 0 && await this.db.table(J).bulkDelete(f.map((e) => e.id));
8007
+ let p = d + 1, m = {
8008
+ documentId: t,
8009
+ sequenceNumber: p,
8010
+ timestamp: Date.now(),
8011
+ operations: {
8012
+ creates: n,
8013
+ updates: i.map((t, n) => ({
8014
+ before: e[n],
8015
+ after: t
8016
+ })),
8017
+ deletes: u.filter(Boolean)
8018
+ }
8019
+ };
8020
+ await this.db.table(J).add(m), await this.setHead(t, p);
8021
+ });
8022
+ } catch (e) {
8023
+ if (e instanceof Error && e.message.includes("dialecte")) throw e;
8024
+ r("STORE_COMMIT_FAILED", {
8025
+ detail: e instanceof Error ? e.message : String(e),
8026
+ cause: e instanceof Error ? e : void 0
8027
+ });
8028
+ }
8029
+ } finally {
8030
+ this.recordCounts.delete(e.documentId);
7981
8031
  }
7982
8032
  }
7983
8033
  async undo(e) {
7984
- await this.ensureCurrentSchema();
7985
- let t = await this.getHead(e);
7986
- if (t === 0) return;
7987
- let n = await this.db.table(J).where({
7988
- documentId: e,
7989
- sequenceNumber: t
7990
- }).first();
7991
- if (!n) return;
7992
- let r = this.db.table(this.resolveTableName(e));
7993
- await this.db.transaction("rw", r, this.db.table(Y), async () => {
7994
- let { creates: i, updates: a, deletes: o } = n.operations;
7995
- i.length > 0 && await r.bulkDelete(i.map((e) => e.id)), a.length > 0 && await r.bulkPut(a.map((e) => e.before)), o.length > 0 && await r.bulkAdd(o), await this.setHead(e, t - 1);
7996
- });
8034
+ try {
8035
+ await this.ensureCurrentSchema();
8036
+ let t = await this.getHead(e);
8037
+ if (t === 0) return;
8038
+ let n = await this.db.table(J).where({
8039
+ documentId: e,
8040
+ sequenceNumber: t
8041
+ }).first();
8042
+ if (!n) return;
8043
+ let r = this.db.table(this.resolveTableName(e));
8044
+ await this.db.transaction("rw", r, this.db.table(Y), async () => {
8045
+ let { creates: i, updates: a, deletes: o } = n.operations;
8046
+ i.length > 0 && await r.bulkDelete(i.map((e) => e.id)), a.length > 0 && await r.bulkPut(a.map((e) => e.before)), o.length > 0 && await r.bulkAdd(o), await this.setHead(e, t - 1);
8047
+ });
8048
+ } finally {
8049
+ this.recordCounts.delete(e);
8050
+ }
7997
8051
  }
7998
8052
  async redo(e) {
7999
- await this.ensureCurrentSchema();
8000
- let t = await this.getHead(e) + 1, n = await this.db.table(J).where({
8001
- documentId: e,
8002
- sequenceNumber: t
8003
- }).first();
8004
- if (!n) return;
8005
- let r = this.db.table(this.resolveTableName(e));
8006
- await this.db.transaction("rw", r, this.db.table(Y), async () => {
8007
- let { creates: i, updates: a, deletes: o } = n.operations;
8008
- i.length > 0 && await r.bulkAdd(i), a.length > 0 && await r.bulkPut(a.map((e) => e.after)), o.length > 0 && await r.bulkDelete(o.map((e) => e.id)), await this.setHead(e, t);
8009
- });
8053
+ try {
8054
+ await this.ensureCurrentSchema();
8055
+ let t = await this.getHead(e) + 1, n = await this.db.table(J).where({
8056
+ documentId: e,
8057
+ sequenceNumber: t
8058
+ }).first();
8059
+ if (!n) return;
8060
+ let r = this.db.table(this.resolveTableName(e));
8061
+ await this.db.transaction("rw", r, this.db.table(Y), async () => {
8062
+ let { creates: i, updates: a, deletes: o } = n.operations;
8063
+ i.length > 0 && await r.bulkAdd(i), a.length > 0 && await r.bulkPut(a.map((e) => e.after)), o.length > 0 && await r.bulkDelete(o.map((e) => e.id)), await this.setHead(e, t);
8064
+ });
8065
+ } finally {
8066
+ this.recordCounts.delete(e);
8067
+ }
8010
8068
  }
8011
8069
  async getHistoryStatus(e) {
8012
8070
  await this.ensureCurrentSchema();
@@ -8199,6 +8257,9 @@ var Jn = class e {
8199
8257
  async getByDocumentId(e) {
8200
8258
  return [...this.getTable(e).values()];
8201
8259
  }
8260
+ async count(e) {
8261
+ return this.getTable(e).size;
8262
+ }
8202
8263
  async getByTagNameInDocument(e, t) {
8203
8264
  let n = [];
8204
8265
  for (let r of this.getTable(t).values()) r.tagName === e && n.push(r);
@@ -8364,7 +8425,7 @@ function Yn(e, t, n, r) {
8364
8425
  //#region src/project/io/export-document.ts
8365
8426
  async function Xn(e) {
8366
8427
  let { documentId: t, state: n, configs: r, store: i, projectName: a, options: o } = e, s = n.documents.get(t);
8367
- f(s, {
8428
+ u(s, {
8368
8429
  key: "DOCUMENT_NOT_REGISTERED",
8369
8430
  detail: `Document "${t}" not registered in project "${a}"`
8370
8431
  });
@@ -8372,26 +8433,26 @@ async function Xn(e) {
8372
8433
  records: await i.getByDocumentId(t),
8373
8434
  config: c,
8374
8435
  withDatabaseIds: o?.withDatabaseIds
8375
- }), u = `${s.record.name}${s.record.extension}`;
8436
+ }), d = `${s.record.name}${s.record.extension}`;
8376
8437
  return o?.withDownload && await ht({
8377
8438
  extension: s.record.extension,
8378
8439
  xmlDocument: l,
8379
- filename: u
8440
+ filename: d
8380
8441
  }), {
8381
8442
  xmlDocument: l,
8382
- filename: u
8443
+ filename: d
8383
8444
  };
8384
8445
  }
8385
8446
  //#endregion
8386
8447
  //#region src/project/io/export-blob.ts
8387
8448
  async function Zn(e) {
8388
8449
  let { blobId: t, store: n, options: r } = e, i = await n.getBlob(t);
8389
- f(i, {
8450
+ u(i, {
8390
8451
  key: "BLOB_NOT_FOUND",
8391
8452
  detail: `Blob "${t}" not found in store`
8392
8453
  });
8393
8454
  let a = i.entry.name;
8394
- return r?.withDownload && await h({
8455
+ return r?.withDownload && await p({
8395
8456
  data: i.data,
8396
8457
  filename: a
8397
8458
  }), {
@@ -8424,14 +8485,14 @@ function $n(e, t) {
8424
8485
  //#region src/project/io/import-document.ts
8425
8486
  async function er(e) {
8426
8487
  let { file: t, store: n, configs: r, defaultConfigKey: i, options: a, hooks: o, perf: s } = e, c = a?.configKey ?? i, l = r[c];
8427
- f(l, {
8488
+ u(l, {
8428
8489
  key: "UNKNOWN_CONFIG_KEY",
8429
8490
  detail: `Unknown configKey: "${c}". Available: ${Object.keys(r).join(", ")}`
8430
8491
  });
8431
- let u = crypto.randomUUID(), d = t.name.includes(".") ? `.${t.name.split(".").pop()}` : l.io.supportedFileExtensions[0], p = {
8432
- id: u,
8492
+ let d = crypto.randomUUID(), f = t.name.includes(".") ? `.${t.name.split(".").pop()}` : l.io.supportedFileExtensions[0], p = {
8493
+ id: d,
8433
8494
  name: t.name.replace(/\.[^.]+$/, "") || "untitled",
8434
- extension: d,
8495
+ extension: f,
8435
8496
  configKey: c,
8436
8497
  createdAt: Date.now(),
8437
8498
  metadata: a?.metadata
@@ -8439,7 +8500,7 @@ async function er(e) {
8439
8500
  await h(n, p);
8440
8501
  let { recordCount: m } = await G({
8441
8502
  file: t,
8442
- documentId: u,
8503
+ documentId: d,
8443
8504
  store: n,
8444
8505
  config: l,
8445
8506
  useCustomRecordsIds: a?.useCustomRecordsIds,
@@ -8448,7 +8509,7 @@ async function er(e) {
8448
8509
  perf: s
8449
8510
  });
8450
8511
  return {
8451
- documentId: u,
8512
+ documentId: d,
8452
8513
  record: p,
8453
8514
  documentState: Qn(p),
8454
8515
  recordCount: m
@@ -8466,19 +8527,19 @@ async function er(e) {
8466
8527
  //#region src/project/io/init-empty-document.ts
8467
8528
  async function tr(e) {
8468
8529
  let { store: t, configs: n, defaultConfigKey: r, options: i, hooks: a } = e, o = i?.configKey ?? r, s = n[o];
8469
- f(s, {
8530
+ u(s, {
8470
8531
  key: "UNKNOWN_CONFIG_KEY",
8471
8532
  detail: `Unknown configKey: "${o}". Available: ${Object.keys(n).join(", ")}`
8472
8533
  });
8473
- let c = i?.extension ?? s.io.supportedFileExtensions[0], l = i?.name ?? "untitled", u = crypto.randomUUID(), d = {
8474
- id: u,
8534
+ let c = i?.extension ?? s.io.supportedFileExtensions[0], l = i?.name ?? "untitled", d = crypto.randomUUID(), f = {
8535
+ id: d,
8475
8536
  name: l,
8476
8537
  extension: c,
8477
8538
  configKey: o,
8478
8539
  createdAt: Date.now(),
8479
8540
  metadata: i?.metadata
8480
8541
  };
8481
- await t.registerDocument(d);
8542
+ await t.registerDocument(f);
8482
8543
  let p = ee({
8483
8544
  dialecteConfig: s,
8484
8545
  hooks: a,
@@ -8490,29 +8551,29 @@ async function tr(e) {
8490
8551
  children: []
8491
8552
  }
8492
8553
  });
8493
- return await t.bulkWrite(u, { creates: [p] }), {
8494
- documentId: u,
8495
- record: d,
8496
- documentState: Qn(d)
8554
+ return await t.bulkWrite(d, { creates: [p] }), {
8555
+ documentId: d,
8556
+ record: f,
8557
+ documentState: Qn(f)
8497
8558
  };
8498
8559
  }
8499
8560
  //#endregion
8500
8561
  //#region src/project/project.ts
8501
8562
  var nr = class {
8502
8563
  get name() {
8503
- return f(this._name !== void 0, {
8564
+ return u(this._name !== void 0, {
8504
8565
  key: "PROJECT_NOT_OPENED",
8505
8566
  detail: "Call project.open(name) before accessing project properties."
8506
8567
  }), this._name;
8507
8568
  }
8508
8569
  get store() {
8509
- return f(this._store !== void 0, {
8570
+ return u(this._store !== void 0, {
8510
8571
  key: "PROJECT_NOT_OPENED",
8511
8572
  detail: "Call project.open(name) before accessing project properties."
8512
8573
  }), this._store;
8513
8574
  }
8514
8575
  get channel() {
8515
- return f(this._channel !== void 0, {
8576
+ return u(this._channel !== void 0, {
8516
8577
  key: "PROJECT_NOT_OPENED",
8517
8578
  detail: "Call project.open(name) before accessing project properties."
8518
8579
  }), this._channel;
@@ -8540,7 +8601,7 @@ var nr = class {
8540
8601
  activeTransactions: 0
8541
8602
  }, this.stateSubscribers = /* @__PURE__ */ new Map();
8542
8603
  let t = Object.keys(e.configs);
8543
- this.storage = e.storage, this.configs = e.configs, this.defaultConfigKey = e.defaultConfigKey ?? t[0], this.hooks = e.hooks, this.perf = Pt({ enabled: e.dev?.perf ?? !1 }), this.mergedExtensions = e.extensions ? C({
8604
+ this.storage = e.storage, this.configs = e.configs, this.defaultConfigKey = e.defaultConfigKey ?? t[0], this.hooks = e.hooks, this.perf = Pt({ enabled: e.dev?.perf ?? !1 }), this.mergedExtensions = e.extensions ? x({
8544
8605
  base: e.extensions.base,
8545
8606
  custom: e.extensions.custom
8546
8607
  }) : void 0;
@@ -8647,7 +8708,7 @@ var nr = class {
8647
8708
  }
8648
8709
  openDocument(e) {
8649
8710
  let t = this.state.documents.get(e);
8650
- f(t, {
8711
+ u(t, {
8651
8712
  key: "DOCUMENT_NOT_REGISTERED",
8652
8713
  detail: `Document "${e}" not registered in project "${this.name}"`
8653
8714
  });
@@ -8676,7 +8737,7 @@ var nr = class {
8676
8737
  }
8677
8738
  async undo(e) {
8678
8739
  let t = this.state.documents.get(e);
8679
- f(t, {
8740
+ u(t, {
8680
8741
  key: "DOCUMENT_NOT_REGISTERED",
8681
8742
  detail: `Document "${e}" not registered in project "${this.name}"`
8682
8743
  }), await this.store.undo(e);
@@ -8689,7 +8750,7 @@ var nr = class {
8689
8750
  }
8690
8751
  async redo(e) {
8691
8752
  let t = this.state.documents.get(e);
8692
- f(t, {
8753
+ u(t, {
8693
8754
  key: "DOCUMENT_NOT_REGISTERED",
8694
8755
  detail: `Document "${e}" not registered in project "${this.name}"`
8695
8756
  }), await this.store.redo(e);
@@ -8785,4 +8846,4 @@ var nr = class {
8785
8846
  }
8786
8847
  };
8787
8848
  //#endregion
8788
- export { Be as $, Xt as A, ft as B, Cn as C, hn as D, yn as E, Ot as F, Je as G, lt as H, gt as I, We as J, qe as K, ht as L, Pt as M, Mt as N, en as O, At as P, I as Q, mt as R, wn as S, bn as T, ot as U, z as V, Ye as W, Ue as X, Ke as Y, He as Z, Z as _, k as _t, $n as a, xe as at, Y as b, Yn as c, ve as ct, On as d, N as dt, Ie as et, kn as f, he as ft, X as g, ce as gt, Dn as h, ue as ht, Qn as i, Se as it, G as j, $t as k, Jn as l, _e as lt, Tn as m, A as mt, tr as n, we as nt, Zn as o, be as ot, En as p, M as pt, Ge as q, er as r, P as rt, Xn as s, ye as st, nr as t, Le as tt, Gn as u, ge as ut, J as v, xn as w, Sn as x, q as y, pt as z };
8849
+ export { He as $, Xt as A, ft as B, Cn as C, hn as D, yn as E, Ot as F, Ye as G, lt as H, gt as I, Ge as J, Je as K, ht as L, Pt as M, Mt as N, en as O, At as P, Ve as Q, mt as R, wn as S, bn as T, ot as U, z as V, L as W, We as X, qe as Y, Ue as Z, Z as _, le as _t, $n as a, N as at, Y as b, Yn as c, be as ct, On as d, _e as dt, ze as et, kn as f, M as ft, X as g, de as gt, Dn as h, k as ht, Qn as i, P as it, G as j, $t as k, Jn as l, ye as lt, Tn as m, j as mt, tr as n, De as nt, Zn as o, Se as ot, En as p, ge as pt, Ke as q, er as r, Ce as rt, Xn as s, xe as st, nr as t, Be as tt, Gn as u, ve as ut, J as v, O as vt, xn as w, Sn as x, q as y, pt as z };