@dialecte/core 0.6.4 → 0.7.0

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 (46) hide show
  1. package/dist/diagnostics/diagnostics.d.ts +26 -0
  2. package/dist/diagnostics/diagnostics.d.ts.map +1 -0
  3. package/dist/diagnostics/index.d.ts +3 -0
  4. package/dist/diagnostics/index.d.ts.map +1 -0
  5. package/dist/diagnostics/types.d.ts +72 -0
  6. package/dist/diagnostics/types.d.ts.map +1 -0
  7. package/dist/errors/codes.d.ts +4 -0
  8. package/dist/errors/codes.d.ts.map +1 -1
  9. package/dist/helpers.js +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +22 -3
  13. package/dist/project/index.d.ts +2 -1
  14. package/dist/project/index.d.ts.map +1 -1
  15. package/dist/project/io/import-document.d.ts.map +1 -1
  16. package/dist/project/io/init-empty-document.d.ts.map +1 -1
  17. package/dist/project/io/resolve-config.d.ts +4 -0
  18. package/dist/project/io/resolve-config.d.ts.map +1 -0
  19. package/dist/project/project.d.ts +39 -9
  20. package/dist/project/project.d.ts.map +1 -1
  21. package/dist/project/state/document-lifecycle.d.ts +18 -0
  22. package/dist/project/state/document-lifecycle.d.ts.map +1 -0
  23. package/dist/project/types.d.ts +44 -0
  24. package/dist/project/types.d.ts.map +1 -1
  25. package/dist/{project-DGQAe9G9.js → project-DIKdMMHx.js} +573 -433
  26. package/dist/store/in-memory/in-memory-store.d.ts +1 -1
  27. package/dist/store/in-memory/in-memory-store.d.ts.map +1 -1
  28. package/dist/store/local/dexie-store.d.ts +1 -1
  29. package/dist/store/local/dexie-store.d.ts.map +1 -1
  30. package/dist/store/local/types.d.ts +3 -0
  31. package/dist/store/local/types.d.ts.map +1 -1
  32. package/dist/store/store.types.d.ts +2 -2
  33. package/dist/store/store.types.d.ts.map +1 -1
  34. package/dist/test.js +11 -11
  35. package/dist/types/io.d.ts +30 -27
  36. package/dist/types/io.d.ts.map +1 -1
  37. package/dist/{utils-CTBHUFs9.js → utils-DJN0Md0v.js} +4 -0
  38. package/dist/utils.js +1 -1
  39. package/dist/xml/parse/parse-xml-document.d.ts.map +1 -1
  40. package/dist/xml/parse/parse-xml-document.types.d.ts +5 -0
  41. package/dist/xml/parse/parse-xml-document.types.d.ts.map +1 -1
  42. package/dist/xml/parse/parser.d.ts +4 -2
  43. package/dist/xml/parse/parser.d.ts.map +1 -1
  44. package/dist/xml/parse/types.d.ts +2 -0
  45. package/dist/xml/parse/types.d.ts.map +1 -1
  46. package/package.json +1 -1
@@ -1,13 +1,13 @@
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";
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-DJN0Md0v.js";
2
+ import { assertNoFixedViolation as _, assertXsiTypeAdmitted as v, assertXsiTypeChangeLeavesNothing as y, isRecordOf as b, mergeExtensions as x, readAttribute as ee, readAttributes as S, standardizeRecord as te, toFullAttributeArray as C, toRawRecord as ne, toRef as w, toTreeRecord as re } from "./helpers.js";
3
3
  //#region \0rolldown/runtime.js
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, {
4
+ var ie = Object.create, ae = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, T = Object.getOwnPropertyNames, E = 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 = T(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !se.call(e, s) && s !== n && ae(e, s, {
6
6
  get: ((e) => t[e]).bind(null, s),
7
- enumerable: !(r = ae(t, s)) || r.enumerable
7
+ enumerable: !(r = oe(t, s)) || r.enumerable
8
8
  });
9
9
  return e;
10
- }, O = (e, t, n) => (n = e == null ? {} : re(oe(e)), ce(t || !e || !e.__esModule ? ie(n, "default", {
10
+ }, O = (e, t, n) => (n = e == null ? {} : ie(E(e)), ce(t || !e || !e.__esModule ? ae(n, "default", {
11
11
  value: e,
12
12
  enumerable: !0
13
13
  }) : n, e));
@@ -668,7 +668,7 @@ function F(e) {
668
668
  s = c;
669
669
  break;
670
670
  }
671
- let l = await t.get(T(e));
671
+ let l = await t.get(w(e));
672
672
  if (!l || Ae({
673
673
  record: l,
674
674
  omitSpec: r
@@ -740,7 +740,7 @@ async function Re(e) {
740
740
  let { source: t, record: n, omitSpec: r } = e;
741
741
  if (!n.children?.length) return [];
742
742
  let i = n.children.filter((e) => !r.unconditional.has(e.tagName));
743
- return i.length ? (await t.getMany(i.map((e) => T(e)))).filter((e) => e !== void 0 && !Ae({
743
+ return i.length ? (await t.getMany(i.map((e) => w(e)))).filter((e) => e !== void 0 && !Ae({
744
744
  record: e,
745
745
  omitSpec: r
746
746
  })) : [];
@@ -759,7 +759,7 @@ async function ze(e) {
759
759
  });
760
760
  if (!o) return "";
761
761
  let { dialecteConfig: s } = t;
762
- return S({
762
+ return ee({
763
763
  record: o,
764
764
  dialecteConfig: s,
765
765
  name: r,
@@ -774,7 +774,7 @@ async function Be(e) {
774
774
  });
775
775
  if (!o) return;
776
776
  let { dialecteConfig: s } = t;
777
- return S({
777
+ return ee({
778
778
  record: o,
779
779
  dialecteConfig: s,
780
780
  name: r,
@@ -792,7 +792,7 @@ async function Ve(e) {
792
792
  });
793
793
  if (!a) return {};
794
794
  let { dialecteConfig: o } = t;
795
- return C({
795
+ return S({
796
796
  record: a,
797
797
  dialecteConfig: o,
798
798
  namespace: r,
@@ -806,7 +806,7 @@ async function He(e) {
806
806
  });
807
807
  if (!i) return [];
808
808
  let { dialecteConfig: a } = t;
809
- return C({
809
+ return S({
810
810
  record: i,
811
811
  dialecteConfig: a,
812
812
  defaults: r,
@@ -951,7 +951,7 @@ async function L(e) {
951
951
  transparentElements: p,
952
952
  remainingDepth: c ?? Infinity
953
953
  });
954
- if (!m) return ne({ record: d });
954
+ if (!m) return re({ record: d });
955
955
  let h = s ?? (p?.length ? p : void 0);
956
956
  return Ye({
957
957
  tree: h ? We({
@@ -997,7 +997,7 @@ function Ze(e) {
997
997
  return e.remainingDepth <= 0 || qe({
998
998
  record: n,
999
999
  compiledOmit: i
1000
- }) ? ne({ record: n }) : ne({
1000
+ }) ? re({ record: n }) : re({
1001
1001
  record: n,
1002
1002
  tree: Qe({
1003
1003
  recordsById: t,
@@ -1163,7 +1163,7 @@ async function ot(e) {
1163
1163
  if (d.set(e.id, e), m(e.id), !(i !== void 0 && n >= i)) for (let r of e.children) {
1164
1164
  let e = await M({
1165
1165
  context: t,
1166
- ref: T(r)
1166
+ ref: w(r)
1167
1167
  });
1168
1168
  e && await h(e, n + 1);
1169
1169
  }
@@ -1197,7 +1197,7 @@ async function ot(e) {
1197
1197
  if (e.id === r.id) continue;
1198
1198
  let n = await M({
1199
1199
  context: t,
1200
- ref: T(e)
1200
+ ref: w(e)
1201
1201
  });
1202
1202
  n && (c ? await h(n, 0) : d.set(n.id, n));
1203
1203
  }
@@ -1260,7 +1260,7 @@ function lt(e) {
1260
1260
  });
1261
1261
  function c(e, t) {
1262
1262
  let n = t === "live" ? i : a, r = e.children.filter((e) => n.has(e.id)).map((e) => c(n.get(e.id), t)), s = t === "live" ? (o.get(e.id) ?? []).map((e) => c(e, "deleted")) : [];
1263
- return ne({
1263
+ return re({
1264
1264
  record: e,
1265
1265
  tree: [...r, ...s]
1266
1266
  });
@@ -1840,7 +1840,7 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
1840
1840
  function n(t, r) {
1841
1841
  if (!(this instanceof n)) return new n(t, r);
1842
1842
  var a = this;
1843
- i(a), a.q = a.c = "", a.bufferCheckPosition = e.MAX_BUFFER_LENGTH, a.encoding = null, a.opt = r || {}, a.opt.lowercase = a.opt.lowercase || a.opt.lowercasetags, a.looseCase = a.opt.lowercase ? "toLowerCase" : "toUpperCase", a.opt.maxEntityCount = a.opt.maxEntityCount || 512, a.opt.maxEntityDepth = a.opt.maxEntityDepth || 4, a.entityCount = a.entityDepth = 0, a.tags = [], a.closed = a.closedRoot = a.sawRoot = !1, a.tag = a.error = null, a.strict = !!t, a.noscript = !!(t || a.opt.noscript), a.state = w.BEGIN, a.strictEntities = a.opt.strictEntities, a.ENTITIES = a.strictEntities ? Object.create(e.XML_ENTITIES) : Object.create(e.ENTITIES), a.attribList = [], a.opt.xmlns && (a.ns = Object.create(h)), a.opt.unquotedAttributeValues === void 0 && (a.opt.unquotedAttributeValues = !t), a.trackPosition = a.opt.position !== !1, a.trackPosition && (a.position = a.line = a.column = 0), T(a, "onready");
1843
+ i(a), a.q = a.c = "", a.bufferCheckPosition = e.MAX_BUFFER_LENGTH, a.encoding = null, a.opt = r || {}, a.opt.lowercase = a.opt.lowercase || a.opt.lowercasetags, a.looseCase = a.opt.lowercase ? "toLowerCase" : "toUpperCase", a.opt.maxEntityCount = a.opt.maxEntityCount || 512, a.opt.maxEntityDepth = a.opt.maxEntityDepth || 4, a.entityCount = a.entityDepth = 0, a.tags = [], a.closed = a.closedRoot = a.sawRoot = !1, a.tag = a.error = null, a.strict = !!t, a.noscript = !!(t || a.opt.noscript), a.state = C.BEGIN, a.strictEntities = a.opt.strictEntities, a.ENTITIES = a.strictEntities ? Object.create(e.XML_ENTITIES) : Object.create(e.ENTITIES), a.attribList = [], a.opt.xmlns && (a.ns = Object.create(h)), a.opt.unquotedAttributeValues === void 0 && (a.opt.unquotedAttributeValues = !t), a.trackPosition = a.opt.position !== !1, a.trackPosition && (a.position = a.line = a.column = 0), w(a, "onready");
1844
1844
  }
1845
1845
  Object.create || (Object.create = function(e) {
1846
1846
  function t() {}
@@ -1855,13 +1855,13 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
1855
1855
  var s = n[t[a]].length;
1856
1856
  if (s > r) switch (t[a]) {
1857
1857
  case "textNode":
1858
- oe(n);
1858
+ E(n);
1859
1859
  break;
1860
1860
  case "cdata":
1861
- E(n, "oncdata", n.cdata), n.cdata = "";
1861
+ T(n, "oncdata", n.cdata), n.cdata = "";
1862
1862
  break;
1863
1863
  case "script":
1864
- E(n, "onscript", n.script), n.script = "";
1864
+ T(n, "onscript", n.script), n.script = "";
1865
1865
  break;
1866
1866
  default: D(n, "Max buffer length exceeded: " + t[a]);
1867
1867
  }
@@ -1873,7 +1873,7 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
1873
1873
  for (var n = 0, r = t.length; n < r; n++) e[t[n]] = "";
1874
1874
  }
1875
1875
  function a(e) {
1876
- oe(e), e.cdata !== "" && (E(e, "oncdata", e.cdata), e.cdata = ""), e.script !== "" && (E(e, "onscript", e.script), e.script = "");
1876
+ E(e), e.cdata !== "" && (T(e, "oncdata", e.cdata), e.cdata = ""), e.script !== "" && (T(e, "onscript", e.script), e.script = "");
1877
1877
  }
1878
1878
  n.prototype = {
1879
1879
  end: function() {
@@ -1972,53 +1972,53 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
1972
1972
  function x(e) {
1973
1973
  return e === "\"" || e === "'";
1974
1974
  }
1975
- function S(e) {
1975
+ function ee(e) {
1976
1976
  return e === ">" || b(e);
1977
1977
  }
1978
- function C(e, t) {
1978
+ function S(e, t) {
1979
1979
  return e.test(t);
1980
1980
  }
1981
- function ee(e, t) {
1982
- return !C(e, t);
1983
- }
1984
- var w = 0;
1985
- for (var te in e.STATE = {
1986
- BEGIN: w++,
1987
- BEGIN_WHITESPACE: w++,
1988
- TEXT: w++,
1989
- TEXT_ENTITY: w++,
1990
- OPEN_WAKA: w++,
1991
- SGML_DECL: w++,
1992
- SGML_DECL_QUOTED: w++,
1993
- DOCTYPE: w++,
1994
- DOCTYPE_QUOTED: w++,
1995
- DOCTYPE_DTD: w++,
1996
- DOCTYPE_DTD_QUOTED: w++,
1997
- COMMENT_STARTING: w++,
1998
- COMMENT: w++,
1999
- COMMENT_ENDING: w++,
2000
- COMMENT_ENDED: w++,
2001
- CDATA: w++,
2002
- CDATA_ENDING: w++,
2003
- CDATA_ENDING_2: w++,
2004
- PROC_INST: w++,
2005
- PROC_INST_BODY: w++,
2006
- PROC_INST_ENDING: w++,
2007
- OPEN_TAG: w++,
2008
- OPEN_TAG_SLASH: w++,
2009
- ATTRIB: w++,
2010
- ATTRIB_NAME: w++,
2011
- ATTRIB_NAME_SAW_WHITE: w++,
2012
- ATTRIB_VALUE: w++,
2013
- ATTRIB_VALUE_QUOTED: w++,
2014
- ATTRIB_VALUE_CLOSED: w++,
2015
- ATTRIB_VALUE_UNQUOTED: w++,
2016
- ATTRIB_VALUE_ENTITY_Q: w++,
2017
- ATTRIB_VALUE_ENTITY_U: w++,
2018
- CLOSE_TAG: w++,
2019
- CLOSE_TAG_SAW_WHITE: w++,
2020
- SCRIPT: w++,
2021
- SCRIPT_ENDING: w++
1981
+ function te(e, t) {
1982
+ return !S(e, t);
1983
+ }
1984
+ var C = 0;
1985
+ for (var ne in e.STATE = {
1986
+ BEGIN: C++,
1987
+ BEGIN_WHITESPACE: C++,
1988
+ TEXT: C++,
1989
+ TEXT_ENTITY: C++,
1990
+ OPEN_WAKA: C++,
1991
+ SGML_DECL: C++,
1992
+ SGML_DECL_QUOTED: C++,
1993
+ DOCTYPE: C++,
1994
+ DOCTYPE_QUOTED: C++,
1995
+ DOCTYPE_DTD: C++,
1996
+ DOCTYPE_DTD_QUOTED: C++,
1997
+ COMMENT_STARTING: C++,
1998
+ COMMENT: C++,
1999
+ COMMENT_ENDING: C++,
2000
+ COMMENT_ENDED: C++,
2001
+ CDATA: C++,
2002
+ CDATA_ENDING: C++,
2003
+ CDATA_ENDING_2: C++,
2004
+ PROC_INST: C++,
2005
+ PROC_INST_BODY: C++,
2006
+ PROC_INST_ENDING: C++,
2007
+ OPEN_TAG: C++,
2008
+ OPEN_TAG_SLASH: C++,
2009
+ ATTRIB: C++,
2010
+ ATTRIB_NAME: C++,
2011
+ ATTRIB_NAME_SAW_WHITE: C++,
2012
+ ATTRIB_VALUE: C++,
2013
+ ATTRIB_VALUE_QUOTED: C++,
2014
+ ATTRIB_VALUE_CLOSED: C++,
2015
+ ATTRIB_VALUE_UNQUOTED: C++,
2016
+ ATTRIB_VALUE_ENTITY_Q: C++,
2017
+ ATTRIB_VALUE_ENTITY_U: C++,
2018
+ CLOSE_TAG: C++,
2019
+ CLOSE_TAG_SAW_WHITE: C++,
2020
+ SCRIPT: C++,
2021
+ SCRIPT_ENDING: C++
2022
2022
  }, e.XML_ENTITIES = {
2023
2023
  amp: "&",
2024
2024
  gt: ">",
@@ -2282,42 +2282,42 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
2282
2282
  }, Object.keys(e.ENTITIES).forEach(function(t) {
2283
2283
  var n = e.ENTITIES[t], r = typeof n == "number" ? String.fromCharCode(n) : n;
2284
2284
  e.ENTITIES[t] = r;
2285
- }), e.STATE) e.STATE[e.STATE[te]] = te;
2286
- w = e.STATE;
2287
- function T(e, t, n) {
2285
+ }), e.STATE) e.STATE[e.STATE[ne]] = ne;
2286
+ C = e.STATE;
2287
+ function w(e, t, n) {
2288
2288
  e[t] && e[t](n);
2289
2289
  }
2290
- function ne(e) {
2290
+ function re(e) {
2291
2291
  var t = e && e.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);
2292
2292
  return t ? t[2] : null;
2293
2293
  }
2294
- function re(e) {
2294
+ function ie(e) {
2295
2295
  return e ? e.toLowerCase().replace(/[^a-z0-9]/g, "") : null;
2296
2296
  }
2297
- function ie(e, t) {
2298
- let n = re(e), r = re(t);
2297
+ function ae(e, t) {
2298
+ let n = ie(e), r = ie(t);
2299
2299
  return !n || !r ? !0 : r === "utf16" ? n === "utf16le" || n === "utf16be" : n === r;
2300
2300
  }
2301
- function ae(e, t) {
2301
+ function oe(e, t) {
2302
2302
  if (!(!e.strict || !e.encoding || !t || t.name !== "xml")) {
2303
- var n = ne(t.body);
2304
- n && !ie(e.encoding, n) && O(e, "XML declaration encoding " + n + " does not match detected stream encoding " + e.encoding.toUpperCase());
2303
+ var n = re(t.body);
2304
+ n && !ae(e.encoding, n) && O(e, "XML declaration encoding " + n + " does not match detected stream encoding " + e.encoding.toUpperCase());
2305
2305
  }
2306
2306
  }
2307
- function E(e, t, n) {
2308
- e.textNode && oe(e), T(e, t, n);
2307
+ function T(e, t, n) {
2308
+ e.textNode && E(e), w(e, t, n);
2309
2309
  }
2310
- function oe(e) {
2311
- e.textNode = se(e.opt, e.textNode), e.textNode && T(e, "ontext", e.textNode), e.textNode = "";
2310
+ function E(e) {
2311
+ e.textNode = se(e.opt, e.textNode), e.textNode && w(e, "ontext", e.textNode), e.textNode = "";
2312
2312
  }
2313
2313
  function se(e, t) {
2314
2314
  return e.trim && (t = t.trim()), e.normalize && (t = t.replace(/\s+/g, " ")), t;
2315
2315
  }
2316
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;
2317
+ return E(e), e.trackPosition && (t += "\nLine: " + e.line + "\nColumn: " + e.column + "\nChar: " + e.c), t = Error(t), e.error = t, w(e, "onerror", t), e;
2318
2318
  }
2319
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;
2320
+ return e.sawRoot && !e.closedRoot && O(e, "Unclosed root tag"), e.state !== C.BEGIN && e.state !== C.BEGIN_WHITESPACE && e.state !== C.TEXT && D(e, "Unexpected end"), E(e), e.c = "", e.closed = !0, w(e, "onend"), n.call(e, e.strict, e.opt), e;
2321
2321
  }
2322
2322
  function O(e, t) {
2323
2323
  if (typeof e != "object" || !(e instanceof n)) throw Error("bad call to strictFail");
@@ -2329,7 +2329,7 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
2329
2329
  name: e.tagName,
2330
2330
  attributes: {}
2331
2331
  };
2332
- e.opt.xmlns && (n.ns = t.ns), e.attribList.length = 0, E(e, "onopentagstart", n);
2332
+ e.opt.xmlns && (n.ns = t.ns), e.attribList.length = 0, T(e, "onopentagstart", n);
2333
2333
  }
2334
2334
  function ue(e, t) {
2335
2335
  var n = e.indexOf(":") < 0 ? ["", e] : e.split(":"), r = n[0], i = n[1];
@@ -2352,7 +2352,7 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
2352
2352
  i.ns === a.ns && (i.ns = Object.create(a.ns)), i.ns[r] = e.attribValue;
2353
2353
  }
2354
2354
  e.attribList.push([e.attribName, e.attribValue]);
2355
- } else e.tag.attributes[e.attribName] = e.attribValue, E(e, "onattribute", {
2355
+ } else e.tag.attributes[e.attribName] = e.attribValue, T(e, "onattribute", {
2356
2356
  name: e.attribName,
2357
2357
  value: e.attribValue
2358
2358
  });
@@ -2364,7 +2364,7 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
2364
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);
2365
2365
  var i = e.tags[e.tags.length - 1] || e;
2366
2366
  n.ns && i.ns !== n.ns && Object.keys(n.ns).forEach(function(t) {
2367
- E(e, "onopennamespace", {
2367
+ T(e, "onopennamespace", {
2368
2368
  prefix: t,
2369
2369
  uri: n.ns[t]
2370
2370
  });
@@ -2377,54 +2377,54 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
2377
2377
  local: f,
2378
2378
  uri: p
2379
2379
  };
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);
2380
+ d && d !== "xmlns" && !p && (O(e, "Unbound namespace prefix: " + JSON.stringify(d)), m.uri = d), e.tag.attributes[c] = m, T(e, "onattribute", m);
2381
2381
  }
2382
2382
  e.attribList.length = 0;
2383
2383
  }
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;
2384
+ e.tag.isSelfClosing = !!t, e.sawRoot = !0, e.tags.push(e.tag), T(e, "onopentag", e.tag), t || (!e.noscript && e.tagName.toLowerCase() === "script" ? e.state = C.SCRIPT : e.state = C.TEXT, e.tag = null, e.tagName = ""), e.attribName = e.attribValue = "", e.attribList.length = 0;
2385
2385
  }
2386
2386
  function k(e) {
2387
2387
  if (!e.tagName) {
2388
- O(e, "Weird empty close tag."), e.textNode += "</>", e.state = w.TEXT;
2388
+ O(e, "Weird empty close tag."), e.textNode += "</>", e.state = C.TEXT;
2389
2389
  return;
2390
2390
  }
2391
2391
  if (e.script) {
2392
2392
  if (e.tagName !== "script") {
2393
- e.script += "</" + e.tagName + ">", e.tagName = "", e.state = w.SCRIPT;
2393
+ e.script += "</" + e.tagName + ">", e.tagName = "", e.state = C.SCRIPT;
2394
2394
  return;
2395
2395
  }
2396
- E(e, "onscript", e.script), e.script = "";
2396
+ T(e, "onscript", e.script), e.script = "";
2397
2397
  }
2398
2398
  var t = e.tags.length, n = e.tagName;
2399
2399
  e.strict || (n = n[e.looseCase]());
2400
2400
  for (var r = n; t-- && e.tags[t].name !== r;) O(e, "Unexpected close tag");
2401
2401
  if (t < 0) {
2402
- O(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 = C.TEXT;
2403
2403
  return;
2404
2404
  }
2405
2405
  e.tagName = n;
2406
2406
  for (var i = e.tags.length; i-- > t;) {
2407
2407
  var a = e.tag = e.tags.pop();
2408
- e.tagName = e.tag.name, E(e, "onclosetag", e.tagName);
2408
+ e.tagName = e.tag.name, T(e, "onclosetag", e.tagName);
2409
2409
  var o = {};
2410
2410
  for (var s in a.ns) o[s] = a.ns[s];
2411
2411
  var c = e.tags[e.tags.length - 1] || e;
2412
2412
  e.opt.xmlns && a.ns !== c.ns && Object.keys(a.ns).forEach(function(t) {
2413
2413
  var n = a.ns[t];
2414
- E(e, "onclosenamespace", {
2414
+ T(e, "onclosenamespace", {
2415
2415
  prefix: t,
2416
2416
  uri: n
2417
2417
  });
2418
2418
  });
2419
2419
  }
2420
- t === 0 && (e.closedRoot = !0), e.tagName = e.attribValue = e.attribName = "", e.attribList.length = 0, e.state = w.TEXT;
2420
+ t === 0 && (e.closedRoot = !0), e.tagName = e.attribValue = e.attribName = "", e.attribList.length = 0, e.state = C.TEXT;
2421
2421
  }
2422
2422
  function pe(e) {
2423
2423
  var t = e.entity, n = t.toLowerCase(), r, i = "";
2424
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));
2425
2425
  }
2426
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);
2427
+ t === "<" ? (e.state = C.OPEN_WAKA, e.startTagPosition = e.position) : b(t) || (O(e, "Non-whitespace before first tag."), e.textNode = t, e.state = C.TEXT);
2428
2428
  }
2429
2429
  function A(e, t) {
2430
2430
  var n = "";
@@ -2437,168 +2437,168 @@ var Dt = /* @__PURE__ */ D(((e, t) => {
2437
2437
  if (t === null) return ce(n);
2438
2438
  typeof t == "object" && (t = t.toString());
2439
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) {
2440
- case w.BEGIN:
2441
- if (n.state = w.BEGIN_WHITESPACE, a === "") continue;
2440
+ case C.BEGIN:
2441
+ if (n.state = C.BEGIN_WHITESPACE, a === "") continue;
2442
2442
  me(n, a);
2443
2443
  continue;
2444
- case w.BEGIN_WHITESPACE:
2444
+ case C.BEGIN_WHITESPACE:
2445
2445
  me(n, a);
2446
2446
  continue;
2447
- case w.TEXT:
2447
+ case C.TEXT:
2448
2448
  if (n.sawRoot && !n.closedRoot) {
2449
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++);
2450
2450
  n.textNode += t.substring(o, i - 1);
2451
2451
  }
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);
2452
+ a === "<" && !(n.sawRoot && n.closedRoot && !n.strict) ? (n.state = C.OPEN_WAKA, n.startTagPosition = n.position) : (!b(a) && (!n.sawRoot || n.closedRoot) && O(n, "Text data outside of root node."), a === "&" ? n.state = C.TEXT_ENTITY : n.textNode += a);
2453
2453
  continue;
2454
- case w.SCRIPT:
2455
- a === "<" ? n.state = w.SCRIPT_ENDING : n.script += a;
2454
+ case C.SCRIPT:
2455
+ a === "<" ? n.state = C.SCRIPT_ENDING : n.script += a;
2456
2456
  continue;
2457
- case w.SCRIPT_ENDING:
2458
- a === "/" ? n.state = w.CLOSE_TAG : (n.script += "<" + a, n.state = w.SCRIPT);
2457
+ case C.SCRIPT_ENDING:
2458
+ a === "/" ? n.state = C.CLOSE_TAG : (n.script += "<" + a, n.state = C.SCRIPT);
2459
2459
  continue;
2460
- case w.OPEN_WAKA:
2461
- if (a === "!") n.state = w.SGML_DECL, n.sgmlDecl = "";
2462
- else if (!b(a)) if (C(g, a)) n.state = w.OPEN_TAG, n.tagName = a;
2463
- else if (a === "/") n.state = w.CLOSE_TAG, n.tagName = "";
2464
- else if (a === "?") n.state = w.PROC_INST, n.procInstName = n.procInstBody = "";
2460
+ case C.OPEN_WAKA:
2461
+ if (a === "!") n.state = C.SGML_DECL, n.sgmlDecl = "";
2462
+ else if (!b(a)) if (S(g, a)) n.state = C.OPEN_TAG, n.tagName = a;
2463
+ else if (a === "/") n.state = C.CLOSE_TAG, n.tagName = "";
2464
+ else if (a === "?") n.state = C.PROC_INST, n.procInstName = n.procInstBody = "";
2465
2465
  else {
2466
2466
  if (O(n, "Unencoded <"), n.startTagPosition + 1 < n.position) {
2467
2467
  var s = n.position - n.startTagPosition;
2468
2468
  a = Array(s).join(" ") + a;
2469
2469
  }
2470
- n.textNode += "<" + a, n.state = w.TEXT;
2470
+ n.textNode += "<" + a, n.state = C.TEXT;
2471
2471
  }
2472
2472
  continue;
2473
- case w.SGML_DECL:
2473
+ case C.SGML_DECL:
2474
2474
  if (n.sgmlDecl + a === "--") {
2475
- n.state = w.COMMENT, n.comment = "", n.sgmlDecl = "";
2475
+ n.state = C.COMMENT, n.comment = "", n.sgmlDecl = "";
2476
2476
  continue;
2477
2477
  }
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);
2478
+ n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = C.DOCTYPE_DTD, n.doctype += "<!" + n.sgmlDecl + a, n.sgmlDecl = "") : (n.sgmlDecl + a).toUpperCase() === d ? (T(n, "onopencdata"), n.state = C.CDATA, n.sgmlDecl = "", n.cdata = "") : (n.sgmlDecl + a).toUpperCase() === f ? (n.state = C.DOCTYPE, (n.doctype || n.sawRoot) && O(n, "Inappropriately located doctype declaration"), n.doctype = "", n.sgmlDecl = "") : a === ">" ? (T(n, "onsgmldeclaration", n.sgmlDecl), n.sgmlDecl = "", n.state = C.TEXT) : (x(a) && (n.state = C.SGML_DECL_QUOTED), n.sgmlDecl += a);
2479
2479
  continue;
2480
- case w.SGML_DECL_QUOTED:
2481
- a === n.q && (n.state = w.SGML_DECL, n.q = ""), n.sgmlDecl += a;
2480
+ case C.SGML_DECL_QUOTED:
2481
+ a === n.q && (n.state = C.SGML_DECL, n.q = ""), n.sgmlDecl += a;
2482
2482
  continue;
2483
- case w.DOCTYPE:
2484
- a === ">" ? (n.state = w.TEXT, E(n, "ondoctype", n.doctype), n.doctype = !0) : (n.doctype += a, a === "[" ? n.state = w.DOCTYPE_DTD : x(a) && (n.state = w.DOCTYPE_QUOTED, n.q = a));
2483
+ case C.DOCTYPE:
2484
+ a === ">" ? (n.state = C.TEXT, T(n, "ondoctype", n.doctype), n.doctype = !0) : (n.doctype += a, a === "[" ? n.state = C.DOCTYPE_DTD : x(a) && (n.state = C.DOCTYPE_QUOTED, n.q = a));
2485
2485
  continue;
2486
- case w.DOCTYPE_QUOTED:
2487
- n.doctype += a, a === n.q && (n.q = "", n.state = w.DOCTYPE);
2486
+ case C.DOCTYPE_QUOTED:
2487
+ n.doctype += a, a === n.q && (n.q = "", n.state = C.DOCTYPE);
2488
2488
  continue;
2489
- case w.DOCTYPE_DTD:
2490
- a === "]" ? (n.doctype += a, n.state = w.DOCTYPE) : a === "<" ? (n.state = w.OPEN_WAKA, n.startTagPosition = n.position) : x(a) ? (n.doctype += a, n.state = w.DOCTYPE_DTD_QUOTED, n.q = a) : n.doctype += a;
2489
+ case C.DOCTYPE_DTD:
2490
+ a === "]" ? (n.doctype += a, n.state = C.DOCTYPE) : a === "<" ? (n.state = C.OPEN_WAKA, n.startTagPosition = n.position) : x(a) ? (n.doctype += a, n.state = C.DOCTYPE_DTD_QUOTED, n.q = a) : n.doctype += a;
2491
2491
  continue;
2492
- case w.DOCTYPE_DTD_QUOTED:
2493
- n.doctype += a, a === n.q && (n.state = w.DOCTYPE_DTD, n.q = "");
2492
+ case C.DOCTYPE_DTD_QUOTED:
2493
+ n.doctype += a, a === n.q && (n.state = C.DOCTYPE_DTD, n.q = "");
2494
2494
  continue;
2495
- case w.COMMENT:
2496
- a === "-" ? n.state = w.COMMENT_ENDING : n.comment += a;
2495
+ case C.COMMENT:
2496
+ a === "-" ? n.state = C.COMMENT_ENDING : n.comment += a;
2497
2497
  continue;
2498
- case w.COMMENT_ENDING:
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);
2498
+ case C.COMMENT_ENDING:
2499
+ a === "-" ? (n.state = C.COMMENT_ENDED, n.comment = se(n.opt, n.comment), n.comment && T(n, "oncomment", n.comment), n.comment = "") : (n.comment += "-" + a, n.state = C.COMMENT);
2500
2500
  continue;
2501
- case w.COMMENT_ENDED:
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);
2501
+ case C.COMMENT_ENDED:
2502
+ a === ">" ? n.doctype && n.doctype !== !0 ? n.state = C.DOCTYPE_DTD : n.state = C.TEXT : (O(n, "Malformed comment"), n.comment += "--" + a, n.state = C.COMMENT);
2503
2503
  continue;
2504
- case w.CDATA:
2504
+ case C.CDATA:
2505
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++);
2506
- n.cdata += t.substring(o, i - 1), a === "]" && (n.state = w.CDATA_ENDING);
2506
+ n.cdata += t.substring(o, i - 1), a === "]" && (n.state = C.CDATA_ENDING);
2507
2507
  continue;
2508
- case w.CDATA_ENDING:
2509
- a === "]" ? n.state = w.CDATA_ENDING_2 : (n.cdata += "]" + a, n.state = w.CDATA);
2508
+ case C.CDATA_ENDING:
2509
+ a === "]" ? n.state = C.CDATA_ENDING_2 : (n.cdata += "]" + a, n.state = C.CDATA);
2510
2510
  continue;
2511
- case w.CDATA_ENDING_2:
2512
- a === ">" ? (n.cdata && E(n, "oncdata", n.cdata), E(n, "onclosecdata"), n.cdata = "", n.state = w.TEXT) : a === "]" ? n.cdata += "]" : (n.cdata += "]]" + a, n.state = w.CDATA);
2511
+ case C.CDATA_ENDING_2:
2512
+ a === ">" ? (n.cdata && T(n, "oncdata", n.cdata), T(n, "onclosecdata"), n.cdata = "", n.state = C.TEXT) : a === "]" ? n.cdata += "]" : (n.cdata += "]]" + a, n.state = C.CDATA);
2513
2513
  continue;
2514
- case w.PROC_INST:
2515
- a === "?" ? n.state = w.PROC_INST_ENDING : b(a) ? n.state = w.PROC_INST_BODY : n.procInstName += a;
2514
+ case C.PROC_INST:
2515
+ a === "?" ? n.state = C.PROC_INST_ENDING : b(a) ? n.state = C.PROC_INST_BODY : n.procInstName += a;
2516
2516
  continue;
2517
- case w.PROC_INST_BODY:
2517
+ case C.PROC_INST_BODY:
2518
2518
  if (!n.procInstBody && b(a)) continue;
2519
- a === "?" ? n.state = w.PROC_INST_ENDING : n.procInstBody += a;
2519
+ a === "?" ? n.state = C.PROC_INST_ENDING : n.procInstBody += a;
2520
2520
  continue;
2521
- case w.PROC_INST_ENDING:
2521
+ case C.PROC_INST_ENDING:
2522
2522
  if (a === ">") {
2523
2523
  let e = {
2524
2524
  name: n.procInstName,
2525
2525
  body: n.procInstBody
2526
2526
  };
2527
- ae(n, e), E(n, "onprocessinginstruction", e), n.procInstName = n.procInstBody = "", n.state = w.TEXT;
2528
- } else n.procInstBody += "?" + a, n.state = w.PROC_INST_BODY;
2527
+ oe(n, e), T(n, "onprocessinginstruction", e), n.procInstName = n.procInstBody = "", n.state = C.TEXT;
2528
+ } else n.procInstBody += "?" + a, n.state = C.PROC_INST_BODY;
2529
2529
  continue;
2530
- case w.OPEN_TAG:
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));
2530
+ case C.OPEN_TAG:
2531
+ S(_, a) ? n.tagName += a : (le(n), a === ">" ? fe(n) : a === "/" ? n.state = C.OPEN_TAG_SLASH : (b(a) || O(n, "Invalid character in tag name"), n.state = C.ATTRIB));
2532
2532
  continue;
2533
- case w.OPEN_TAG_SLASH:
2534
- a === ">" ? (fe(n, !0), k(n)) : (O(n, "Forward-slash in opening tag not followed by >"), n.state = w.ATTRIB);
2533
+ case C.OPEN_TAG_SLASH:
2534
+ a === ">" ? (fe(n, !0), k(n)) : (O(n, "Forward-slash in opening tag not followed by >"), n.state = C.ATTRIB);
2535
2535
  continue;
2536
- case w.ATTRIB:
2536
+ case C.ATTRIB:
2537
2537
  if (b(a)) continue;
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");
2538
+ a === ">" ? fe(n) : a === "/" ? n.state = C.OPEN_TAG_SLASH : S(g, a) ? (n.attribName = a, n.attribValue = "", n.state = C.ATTRIB_NAME) : O(n, "Invalid attribute name");
2539
2539
  continue;
2540
- case w.ATTRIB_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");
2540
+ case C.ATTRIB_NAME:
2541
+ a === "=" ? n.state = C.ATTRIB_VALUE : a === ">" ? (O(n, "Attribute without value"), n.attribValue = n.attribName, de(n), fe(n)) : b(a) ? n.state = C.ATTRIB_NAME_SAW_WHITE : S(_, a) ? n.attribName += a : O(n, "Invalid attribute name");
2542
2542
  continue;
2543
- case w.ATTRIB_NAME_SAW_WHITE:
2544
- if (a === "=") n.state = w.ATTRIB_VALUE;
2543
+ case C.ATTRIB_NAME_SAW_WHITE:
2544
+ if (a === "=") n.state = C.ATTRIB_VALUE;
2545
2545
  else if (b(a)) continue;
2546
- else O(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 = "", T(n, "onattribute", {
2547
2547
  name: n.attribName,
2548
2548
  value: ""
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);
2549
+ }), n.attribName = "", a === ">" ? fe(n) : S(g, a) ? (n.attribName = a, n.state = C.ATTRIB_NAME) : (O(n, "Invalid attribute name"), n.state = C.ATTRIB);
2550
2550
  continue;
2551
- case w.ATTRIB_VALUE:
2551
+ case C.ATTRIB_VALUE:
2552
2552
  if (b(a)) continue;
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);
2553
+ x(a) ? (n.q = a, n.state = C.ATTRIB_VALUE_QUOTED) : (n.opt.unquotedAttributeValues || D(n, "Unquoted attribute value"), n.state = C.ATTRIB_VALUE_UNQUOTED, n.attribValue = a);
2554
2554
  continue;
2555
- case w.ATTRIB_VALUE_QUOTED:
2555
+ case C.ATTRIB_VALUE_QUOTED:
2556
2556
  if (a !== n.q) {
2557
- a === "&" ? n.state = w.ATTRIB_VALUE_ENTITY_Q : n.attribValue += a;
2557
+ a === "&" ? n.state = C.ATTRIB_VALUE_ENTITY_Q : n.attribValue += a;
2558
2558
  continue;
2559
2559
  }
2560
- de(n), n.q = "", n.state = w.ATTRIB_VALUE_CLOSED;
2560
+ de(n), n.q = "", n.state = C.ATTRIB_VALUE_CLOSED;
2561
2561
  continue;
2562
- case w.ATTRIB_VALUE_CLOSED:
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");
2562
+ case C.ATTRIB_VALUE_CLOSED:
2563
+ b(a) ? n.state = C.ATTRIB : a === ">" ? fe(n) : a === "/" ? n.state = C.OPEN_TAG_SLASH : S(g, a) ? (O(n, "No whitespace between attributes"), n.attribName = a, n.attribValue = "", n.state = C.ATTRIB_NAME) : O(n, "Invalid attribute name");
2564
2564
  continue;
2565
- case w.ATTRIB_VALUE_UNQUOTED:
2566
- if (!S(a)) {
2567
- a === "&" ? n.state = w.ATTRIB_VALUE_ENTITY_U : n.attribValue += a;
2565
+ case C.ATTRIB_VALUE_UNQUOTED:
2566
+ if (!ee(a)) {
2567
+ a === "&" ? n.state = C.ATTRIB_VALUE_ENTITY_U : n.attribValue += a;
2568
2568
  continue;
2569
2569
  }
2570
- de(n), a === ">" ? fe(n) : n.state = w.ATTRIB;
2570
+ de(n), a === ">" ? fe(n) : n.state = C.ATTRIB;
2571
2571
  continue;
2572
- case w.CLOSE_TAG:
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);
2572
+ case C.CLOSE_TAG:
2573
+ if (n.tagName) a === ">" ? k(n) : S(_, a) ? n.tagName += a : n.script ? (n.script += "</" + n.tagName + a, n.tagName = "", n.state = C.SCRIPT) : (b(a) || O(n, "Invalid tagname in closing tag"), n.state = C.CLOSE_TAG_SAW_WHITE);
2574
2574
  else {
2575
2575
  if (b(a)) continue;
2576
- ee(g, a) ? n.script ? (n.script += "</" + a, n.state = w.SCRIPT) : O(n, "Invalid tagname in closing tag.") : n.tagName = a;
2576
+ te(g, a) ? n.script ? (n.script += "</" + a, n.state = C.SCRIPT) : O(n, "Invalid tagname in closing tag.") : n.tagName = a;
2577
2577
  }
2578
2578
  continue;
2579
- case w.CLOSE_TAG_SAW_WHITE:
2579
+ case C.CLOSE_TAG_SAW_WHITE:
2580
2580
  if (b(a)) continue;
2581
2581
  a === ">" ? k(n) : O(n, "Invalid characters in closing tag");
2582
2582
  continue;
2583
- case w.TEXT_ENTITY:
2584
- case w.ATTRIB_VALUE_ENTITY_Q:
2585
- case w.ATTRIB_VALUE_ENTITY_U:
2583
+ case C.TEXT_ENTITY:
2584
+ case C.ATTRIB_VALUE_ENTITY_Q:
2585
+ case C.ATTRIB_VALUE_ENTITY_U:
2586
2586
  var c, l;
2587
2587
  switch (n.state) {
2588
- case w.TEXT_ENTITY:
2589
- c = w.TEXT, l = "textNode";
2588
+ case C.TEXT_ENTITY:
2589
+ c = C.TEXT, l = "textNode";
2590
2590
  break;
2591
- case w.ATTRIB_VALUE_ENTITY_Q:
2592
- c = w.ATTRIB_VALUE_QUOTED, l = "attribValue";
2591
+ case C.ATTRIB_VALUE_ENTITY_Q:
2592
+ c = C.ATTRIB_VALUE_QUOTED, l = "attribValue";
2593
2593
  break;
2594
- case w.ATTRIB_VALUE_ENTITY_U:
2595
- c = w.ATTRIB_VALUE_UNQUOTED, l = "attribValue";
2594
+ case C.ATTRIB_VALUE_ENTITY_U:
2595
+ c = C.ATTRIB_VALUE_UNQUOTED, l = "attribValue";
2596
2596
  break;
2597
2597
  }
2598
2598
  if (a === ";") {
2599
2599
  var u = pe(n);
2600
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);
2601
+ } else S(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);
2602
2602
  continue;
2603
2603
  default: throw Error(n, "Unknown state: " + n.state);
2604
2604
  }
@@ -2774,75 +2774,83 @@ function Pt({ enabled: e }) {
2774
2774
  //#endregion
2775
2775
  //#region src/xml/parse/parser.ts
2776
2776
  function Ft(e) {
2777
- let { dialecteConfig: t, useCustomRecordsIds: n, session: r, hooks: i, perf: a = Mt } = e, o = {
2777
+ let { dialecteConfig: t, useCustomRecordsIds: n, session: r, hooks: i, importSession: a, perf: o = Mt } = e, s = {
2778
2778
  defaultNamespace: null,
2779
2779
  stack: [],
2780
- recordsBatch: []
2781
- }, s = V.parser(!0, {
2780
+ recordsBatch: [],
2781
+ sawRoot: !1
2782
+ }, c = V.parser(!0, {
2782
2783
  lowercase: !1,
2783
2784
  trim: !0,
2784
2785
  normalize: !0,
2785
2786
  position: !1,
2786
2787
  xmlns: !0
2787
2788
  });
2788
- s.onopentag = (e) => {
2789
- a.time("core::import::onOpenTag", () => It({
2789
+ c.onopentag = (e) => {
2790
+ o.time("core::import::onOpenTag", () => It({
2790
2791
  node: e,
2791
- state: o,
2792
+ state: s,
2792
2793
  dialecteConfig: t,
2793
2794
  useCustomRecordsIds: n
2794
2795
  }));
2795
- }, s.ontext = (e) => {
2796
- a.time("core::import::onText", () => Lt({
2796
+ }, c.ontext = (e) => {
2797
+ o.time("core::import::onText", () => Lt({
2797
2798
  text: e,
2798
- state: o
2799
+ state: s
2799
2800
  }));
2800
- }, s.oncdata = (e) => {
2801
- a.time("core::import::onText", () => Lt({
2801
+ }, c.oncdata = (e) => {
2802
+ o.time("core::import::onText", () => Lt({
2802
2803
  text: e,
2803
- state: o
2804
+ state: s
2804
2805
  }));
2805
- }, s.onclosetag = () => {
2806
- a.time("core::import::onCloseTag", () => H({
2807
- state: o,
2806
+ }, c.onclosetag = () => {
2807
+ o.time("core::import::onCloseTag", () => H({
2808
+ state: s,
2808
2809
  hooks: i,
2810
+ importSession: a,
2809
2811
  session: r,
2810
2812
  dialecteConfig: t,
2811
- perf: a
2813
+ perf: o
2812
2814
  }));
2813
- }, s.onerror = Rt;
2814
- function c() {
2815
- let e = o.recordsBatch;
2816
- return o.recordsBatch = [], e;
2817
- }
2815
+ }, c.onerror = Rt;
2818
2816
  function l() {
2819
- return o.recordsBatch.length;
2817
+ let e = s.recordsBatch;
2818
+ return s.recordsBatch = [], e;
2819
+ }
2820
+ function u() {
2821
+ return s.recordsBatch.length;
2820
2822
  }
2821
2823
  return {
2822
- parser: s,
2823
- drainBatch: c,
2824
- getSize: l
2824
+ parser: c,
2825
+ drainBatch: l,
2826
+ getSize: u
2825
2827
  };
2826
2828
  }
2827
2829
  function It(e) {
2828
- let { node: t, state: n, dialecteConfig: r, useCustomRecordsIds: i } = e, a = zt(t);
2829
- n.defaultNamespace ||= Bt({
2830
+ let { node: t, state: n, dialecteConfig: i, useCustomRecordsIds: a } = e, o = zt(t);
2831
+ n.stack.length === 0 && (n.sawRoot && r("PARSE_ERROR", {
2832
+ detail: `XML parsing error: a second root element <${t.name}> after the root was closed`,
2833
+ meta: {
2834
+ reason: "second-root",
2835
+ tagName: t.name
2836
+ }
2837
+ }), n.sawRoot = !0), n.defaultNamespace ||= Bt({
2830
2838
  element: t,
2831
- defaultNamespace: r.namespaces.default,
2832
- rootElementName: r.rootElementName
2839
+ defaultNamespace: i.namespaces.default,
2840
+ rootElementName: i.rootElementName
2833
2841
  });
2834
- let o = U(t, n.defaultNamespace), s = {
2842
+ let s = U(t, n.defaultNamespace), c = {
2835
2843
  id: Ut({
2836
2844
  attributes: t.attributes,
2837
- useCustomRecordsIds: i
2845
+ useCustomRecordsIds: a
2838
2846
  }),
2839
- tagName: a,
2840
- namespace: o,
2847
+ tagName: o,
2848
+ namespace: s,
2841
2849
  attributes: m({
2842
- dialecteConfig: r,
2850
+ dialecteConfig: i,
2843
2851
  attributes: Vt(Wt({
2844
2852
  attributes: t.attributes,
2845
- useCustomRecordsIds: i
2853
+ useCustomRecordsIds: a
2846
2854
  })),
2847
2855
  namespaceOf: (e) => t.ns[e]
2848
2856
  }),
@@ -2850,36 +2858,42 @@ function It(e) {
2850
2858
  parent: Ht(n.stack),
2851
2859
  children: []
2852
2860
  };
2853
- n.stack.push(s);
2861
+ n.stack.push(c);
2854
2862
  }
2855
2863
  function Lt(e) {
2856
2864
  let { text: t, state: n } = e;
2857
2865
  t && n.stack.length > 0 && (n.stack[n.stack.length - 1].value += t);
2858
2866
  }
2859
2867
  function H(e) {
2860
- let { state: t, hooks: n, session: r, dialecteConfig: i, perf: a = Mt } = e, o = t.stack.pop();
2861
- if (!o) return;
2862
- let s = a.time("core::import::onCloseTag::standardize", () => ee({
2863
- dialecteConfig: i,
2868
+ let { state: t, hooks: n, importSession: r, session: i, dialecteConfig: a, perf: o = Mt } = e, s = t.stack.pop();
2869
+ if (!s) return;
2870
+ let c = o.time("core::import::onCloseTag::standardize", () => te({
2871
+ dialecteConfig: a,
2864
2872
  hooks: n,
2865
- record: o
2866
- }));
2867
- n?.beforeImportRecord && a.time("core::import::onCloseTag::beforeHook", () => n.beforeImportRecord({
2868
- record: s,
2873
+ record: s
2874
+ })), l = r?.beforeImportRecord;
2875
+ l && o.time("core::import::onCloseTag::beforeHook", () => l({
2876
+ record: c,
2869
2877
  ancestry: t.stack
2870
- })), a.time("core::import::onCloseTag::reconcileChildren", () => {
2878
+ })), o.time("core::import::onCloseTag::reconcileChildren", () => {
2871
2879
  let e = t.stack[t.stack.length - 1];
2872
2880
  e ? e.children.push({
2873
- id: s.id,
2874
- tagName: s.tagName
2875
- }) : s.parent && r.registerPendingChild(s.parent.id, {
2876
- id: s.id,
2877
- tagName: s.tagName
2881
+ id: c.id,
2882
+ tagName: c.tagName
2883
+ }) : c.parent && i.registerPendingChild(c.parent.id, {
2884
+ id: c.id,
2885
+ tagName: c.tagName
2878
2886
  });
2879
- }), t.recordsBatch.push(s);
2887
+ }), t.recordsBatch.push(c);
2880
2888
  }
2881
2889
  function Rt(e) {
2882
- return /* @__PURE__ */ Error(`XML parsing error: ${e}`);
2890
+ r("PARSE_ERROR", {
2891
+ detail: `XML parsing error: ${e.message}`,
2892
+ meta: {
2893
+ reason: "malformed-xml",
2894
+ parser: e.message
2895
+ }
2896
+ });
2883
2897
  }
2884
2898
  function zt(e) {
2885
2899
  return e.local;
@@ -2930,44 +2944,56 @@ function Wt(e) {
2930
2944
  //#region src/xml/parse/parse-xml-document.ts
2931
2945
  var Gt = 32 * 1024, W = 2e3;
2932
2946
  async function G(e) {
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;
2934
- if (u(l.some((e) => c.name.toLowerCase().endsWith(e)), {
2947
+ let { documentId: t, configKey: n, store: r, config: i, useCustomRecordsIds: a = !1, chunkOptions: o, hooks: s, perf: c = Mt } = e, { file: l } = e, { supportedFileExtensions: d } = i.io;
2948
+ if (u(d.some((e) => l.name.toLowerCase().endsWith(e)), {
2935
2949
  key: "ASSERTION_FAILED",
2936
- detail: `Unsupported file type: ${c.name}`
2937
- }), c.size === 0) return {
2950
+ detail: `Unsupported file type: ${l.name}`
2951
+ }), l.size === 0) return {
2938
2952
  documentId: t,
2939
- recordCount: 0
2953
+ recordCount: 0,
2954
+ diagnostics: []
2940
2955
  };
2941
- let d = o?.beforeImport;
2942
- if (d) {
2943
- let e = d(await c.text());
2944
- c = new File([e], c.name, { type: c.type });
2945
- }
2946
- let f = a?.chunkSize ?? Gt, p = a?.batchSize ?? W, m = new At(), h = Ft({
2947
- dialecteConfig: r,
2948
- useCustomRecordsIds: i,
2949
- session: m,
2950
- hooks: o,
2951
- perf: s
2952
- });
2953
- s.start("core::import");
2954
- let g = await Kt({
2955
- file: c,
2956
- sax: h,
2957
- session: m,
2958
- store: n,
2956
+ let f = s?.beforeImport;
2957
+ if (f) {
2958
+ let e = f(await l.text());
2959
+ l = new File([e], l.name, { type: l.type });
2960
+ }
2961
+ let p = o?.chunkSize ?? Gt, m = o?.batchSize ?? W, h = new At(), g = s?.createImportSession?.({
2959
2962
  documentId: t,
2960
- chunkSize: f,
2961
- batchSize: p,
2962
- perf: s
2963
+ configKey: n
2964
+ }), _ = Ft({
2965
+ dialecteConfig: i,
2966
+ useCustomRecordsIds: a,
2967
+ session: h,
2968
+ hooks: s,
2969
+ importSession: g,
2970
+ perf: c
2963
2971
  });
2964
- return s.stop("core::import"), {
2972
+ c.start("core::import");
2973
+ let v;
2974
+ try {
2975
+ v = await Kt({
2976
+ file: l,
2977
+ sax: _,
2978
+ session: h,
2979
+ store: r,
2980
+ documentId: t,
2981
+ chunkSize: p,
2982
+ batchSize: m,
2983
+ perf: c
2984
+ });
2985
+ } finally {
2986
+ c.stop("core::import");
2987
+ }
2988
+ let { recordDelta: y, diagnostics: b } = await qt({
2989
+ importSession: g,
2990
+ store: r,
2991
+ documentId: t
2992
+ });
2993
+ return {
2965
2994
  documentId: t,
2966
- recordCount: g + await qt({
2967
- hooks: o,
2968
- store: n,
2969
- documentId: t
2970
- })
2995
+ recordCount: v + y,
2996
+ diagnostics: b
2971
2997
  };
2972
2998
  }
2973
2999
  async function Kt(e) {
@@ -2983,7 +3009,7 @@ async function Kt(e) {
2983
3009
  for (; u + o <= t.length;) {
2984
3010
  c.start("core::import::decode");
2985
3011
  let e = d.decode(t.subarray(u, u + o), { stream: !0 });
2986
- c.stop("core::import::decode"), u += o, c.start("core::import::sax"), n.parser.write(e), c.stop("core::import::sax"), l += await Yt({
3012
+ c.stop("core::import::decode"), u += o, c.time("core::import::sax", () => n.parser.write(e)), l += await Yt({
2987
3013
  sax: n,
2988
3014
  session: r,
2989
3015
  store: i,
@@ -2998,7 +3024,7 @@ async function Kt(e) {
2998
3024
  if (f.length > 0) {
2999
3025
  c.start("core::import::decode");
3000
3026
  let e = d.decode(f);
3001
- c.stop("core::import::decode"), c.start("core::import::sax"), n.parser.write(e), c.stop("core::import::sax");
3027
+ c.stop("core::import::decode"), c.time("core::import::sax", () => n.parser.write(e));
3002
3028
  }
3003
3029
  n.parser.close(), l += await Yt({
3004
3030
  sax: n,
@@ -3013,14 +3039,20 @@ async function Kt(e) {
3013
3039
  return l;
3014
3040
  }
3015
3041
  async function qt(e) {
3016
- let { hooks: t, store: n, documentId: r } = e;
3017
- if (!t?.afterImport) return 0;
3018
- let { creates: i, updates: a, deletes: o } = await t.afterImport();
3019
- return i?.length || a?.length || o?.length ? (await n.bulkWrite(r, {
3042
+ let { importSession: t, store: n, documentId: r } = e;
3043
+ if (!t?.afterImport) return {
3044
+ recordDelta: 0,
3045
+ diagnostics: []
3046
+ };
3047
+ let { creates: i, updates: a, deletes: o, diagnostics: s = [] } = await t.afterImport();
3048
+ return (i?.length || a?.length || o?.length) && await n.bulkWrite(r, {
3020
3049
  creates: i,
3021
3050
  updates: a,
3022
3051
  deletes: o
3023
- }), (i?.length ?? 0) - (o?.length ?? 0)) : 0;
3052
+ }), {
3053
+ recordDelta: (i?.length ?? 0) - (o?.length ?? 0),
3054
+ diagnostics: s
3055
+ };
3024
3056
  }
3025
3057
  function Jt(e, t) {
3026
3058
  let n = new Uint8Array(e.length + t.length);
@@ -3039,7 +3071,7 @@ async function Yt(e) {
3039
3071
  async function Xt(e) {
3040
3072
  let { context: t, options: n = {} } = e, { ref: r, ancestors: i, siblings: a, depth: o, includeDeleted: s, omit: c, unwrap: l, as: u = "tree" } = n, d = await ot({
3041
3073
  context: t,
3042
- ref: r ? T(r) : void 0,
3074
+ ref: r ? w(r) : void 0,
3043
3075
  ancestors: i,
3044
3076
  siblings: a,
3045
3077
  depth: o,
@@ -3094,7 +3126,7 @@ var $t = class {
3094
3126
  async getDefinition(e) {
3095
3127
  return Ue({
3096
3128
  context: this.getContext(),
3097
- ref: T(e)
3129
+ ref: w(e)
3098
3130
  });
3099
3131
  }
3100
3132
  async getRecords(e) {
@@ -3106,14 +3138,14 @@ var $t = class {
3106
3138
  async getChild(e, t) {
3107
3139
  return be({
3108
3140
  context: this.getContext(),
3109
- ref: T(e),
3141
+ ref: w(e),
3110
3142
  tagName: t
3111
3143
  });
3112
3144
  }
3113
3145
  async getChildren(e, t) {
3114
3146
  return xe({
3115
3147
  context: this.getContext(),
3116
- ref: T(e),
3148
+ ref: w(e),
3117
3149
  tagName: t
3118
3150
  });
3119
3151
  }
@@ -3150,7 +3182,7 @@ var $t = class {
3150
3182
  async getTree(e, t) {
3151
3183
  return L({
3152
3184
  context: this.getContext(),
3153
- ref: T(e),
3185
+ ref: w(e),
3154
3186
  options: t,
3155
3187
  dialecteConfig: this.dialecteConfig
3156
3188
  });
@@ -3162,7 +3194,7 @@ var $t = class {
3162
3194
  });
3163
3195
  }
3164
3196
  async findDescendants(e) {
3165
- let t = T(e), n = this.dialecteConfig.descendants[t.tagName] ?? [];
3197
+ let t = w(e), n = this.dialecteConfig.descendants[t.tagName] ?? [];
3166
3198
  return De({
3167
3199
  context: this.getContext(),
3168
3200
  ref: t,
@@ -3172,7 +3204,7 @@ var $t = class {
3172
3204
  async findAncestors(e) {
3173
3205
  return e ? N({
3174
3206
  context: this.getContext(),
3175
- ref: T(e)
3207
+ ref: w(e)
3176
3208
  }) : [];
3177
3209
  }
3178
3210
  async findByAttributes(e) {
@@ -3226,17 +3258,17 @@ var $t = class {
3226
3258
  async getRecord(e) {
3227
3259
  return M({
3228
3260
  context: this.context,
3229
- ref: T(e)
3261
+ ref: w(e)
3230
3262
  });
3231
3263
  }
3232
3264
  async getDefinition(e) {
3233
3265
  return Ue({
3234
3266
  context: this.context,
3235
- ref: T(e)
3267
+ ref: w(e)
3236
3268
  });
3237
3269
  }
3238
3270
  async getRecords(e) {
3239
- let t = e.map((e) => T(e));
3271
+ let t = e.map((e) => w(e));
3240
3272
  return ve({
3241
3273
  context: this.context,
3242
3274
  refs: t
@@ -3245,14 +3277,14 @@ var $t = class {
3245
3277
  async getChild(e, t) {
3246
3278
  if (e) return be({
3247
3279
  context: this.context,
3248
- ref: T(e),
3280
+ ref: w(e),
3249
3281
  tagName: t
3250
3282
  });
3251
3283
  }
3252
3284
  async getChildren(e, t) {
3253
3285
  return e ? xe({
3254
3286
  context: this.context,
3255
- ref: T(e),
3287
+ ref: w(e),
3256
3288
  tagName: t
3257
3289
  }) : [];
3258
3290
  }
@@ -3263,7 +3295,7 @@ var $t = class {
3263
3295
  });
3264
3296
  }
3265
3297
  async findDescendants(e, t) {
3266
- let n = T(e);
3298
+ let n = w(e);
3267
3299
  if (!t) {
3268
3300
  let e = this.dialecteConfig.descendants[n.tagName] ?? [];
3269
3301
  return De({
@@ -3281,14 +3313,14 @@ var $t = class {
3281
3313
  async findAncestors(e, t) {
3282
3314
  return e ? N({
3283
3315
  context: this.context,
3284
- ref: T(e),
3316
+ ref: w(e),
3285
3317
  options: t
3286
3318
  }) : [];
3287
3319
  }
3288
3320
  async getTree(e, t) {
3289
3321
  return L({
3290
3322
  context: this.context,
3291
- ref: T(e),
3323
+ ref: w(e),
3292
3324
  options: t,
3293
3325
  dialecteConfig: this.dialecteConfig
3294
3326
  });
@@ -3334,7 +3366,7 @@ var $t = class {
3334
3366
  //#region src/document/transaction/stage-operations.ts
3335
3367
  function K(e) {
3336
3368
  let { context: t, status: n, record: r, oldRecord: i, newRecord: a } = e, o, s, c;
3337
- if (r && (o = te(r)), i && (s = te(i)), a && (c = te(a)), n === "created") {
3369
+ if (r && (o = ne(r)), i && (s = ne(i)), a && (c = ne(a)), n === "created") {
3338
3370
  u(o, {
3339
3371
  detail: "Record is required for created",
3340
3372
  key: "ELEMENT_NOT_FOUND"
@@ -3413,7 +3445,7 @@ async function nn(e) {
3413
3445
  key: "ELEMENT_NOT_FOUND",
3414
3446
  ref: a
3415
3447
  });
3416
- let m = ee({
3448
+ let m = te({
3417
3449
  dialecteConfig: t,
3418
3450
  hooks: n,
3419
3451
  record: {
@@ -3517,17 +3549,17 @@ async function sn(e) {
3517
3549
  attributes: l.attributes,
3518
3550
  value: l.value
3519
3551
  }
3520
- }), d = T(o);
3552
+ }), d = w(o);
3521
3553
  s.push({
3522
3554
  source: Object.assign(d, { attributes: [...o.attributes] }),
3523
- target: T(u)
3555
+ target: w(u)
3524
3556
  }), r.progress.nextStep();
3525
3557
  for (let e of l.tree) await sn({
3526
3558
  dialecteConfig: t,
3527
3559
  hooks: n,
3528
3560
  context: r,
3529
3561
  query: i,
3530
- parentRef: T(u),
3562
+ parentRef: w(u),
3531
3563
  record: e,
3532
3564
  mappings: s
3533
3565
  });
@@ -3563,7 +3595,7 @@ async function cn(e) {
3563
3595
  });
3564
3596
  let o = await M({
3565
3597
  context: n,
3566
- ref: T(a.parent)
3598
+ ref: w(a.parent)
3567
3599
  });
3568
3600
  u(o, {
3569
3601
  detail: `Parent record not found (tagName=${a.parent.tagName}, id=${a.parent.id})`,
@@ -3592,7 +3624,7 @@ async function ln(e) {
3592
3624
  for (let e of n.children) {
3593
3625
  let n = await M({
3594
3626
  context: t,
3595
- ref: T(e)
3627
+ ref: w(e)
3596
3628
  });
3597
3629
  n && (n.children.length > 0 && await ln({
3598
3630
  context: t,
@@ -3642,7 +3674,7 @@ async function fn(e) {
3642
3674
  key: "ELEMENT_NOT_FOUND",
3643
3675
  ref: a
3644
3676
  });
3645
- let d = s ? w({
3677
+ let d = s ? C({
3646
3678
  dialecteConfig: t,
3647
3679
  tagName: l.tagName,
3648
3680
  attributes: s,
@@ -3656,7 +3688,7 @@ async function fn(e) {
3656
3688
  },
3657
3689
  attributes: d
3658
3690
  }));
3659
- let p = d.some(h), m = ee({
3691
+ let p = d.some(h), m = te({
3660
3692
  dialecteConfig: t,
3661
3693
  hooks: n,
3662
3694
  record: {
@@ -3701,7 +3733,7 @@ var hn = class extends $t {
3701
3733
  async addChild(e, t) {
3702
3734
  return nn({
3703
3735
  context: this.getContext(),
3704
- parentRef: T(e),
3736
+ parentRef: w(e),
3705
3737
  params: {
3706
3738
  id: t.id,
3707
3739
  tagName: t.tagName,
@@ -3717,7 +3749,7 @@ var hn = class extends $t {
3717
3749
  async ensureChild(e, t) {
3718
3750
  return un({
3719
3751
  context: this.getContext(),
3720
- parentRef: T(e),
3752
+ parentRef: w(e),
3721
3753
  params: {
3722
3754
  id: t.id,
3723
3755
  tagName: t.tagName,
@@ -3733,7 +3765,7 @@ var hn = class extends $t {
3733
3765
  async update(e, t) {
3734
3766
  return fn({
3735
3767
  context: this.getContext(),
3736
- ref: T(e),
3768
+ ref: w(e),
3737
3769
  params: {
3738
3770
  attributes: t.attributes,
3739
3771
  value: t.value
@@ -3746,7 +3778,7 @@ var hn = class extends $t {
3746
3778
  async delete(e) {
3747
3779
  return cn({
3748
3780
  context: this.getContext(),
3749
- ref: T(e),
3781
+ ref: w(e),
3750
3782
  hooks: this.hooks,
3751
3783
  query: this.query
3752
3784
  });
@@ -3757,7 +3789,7 @@ var hn = class extends $t {
3757
3789
  hooks: this.hooks,
3758
3790
  context: this.getContext(),
3759
3791
  query: this.query,
3760
- parentRef: T(e),
3792
+ parentRef: w(e),
3761
3793
  record: t
3762
3794
  });
3763
3795
  }
@@ -3862,7 +3894,7 @@ var yn = class extends en {
3862
3894
  async addChild(e, t) {
3863
3895
  return nn({
3864
3896
  context: this.context,
3865
- parentRef: T(e),
3897
+ parentRef: w(e),
3866
3898
  params: t,
3867
3899
  dialecteConfig: this.dialecteConfig,
3868
3900
  hooks: this.hooks,
@@ -3872,7 +3904,7 @@ var yn = class extends en {
3872
3904
  async ensureChild(e, t) {
3873
3905
  return un({
3874
3906
  context: this.context,
3875
- parentRef: T(e),
3907
+ parentRef: w(e),
3876
3908
  params: t,
3877
3909
  dialecteConfig: this.dialecteConfig,
3878
3910
  hooks: this.hooks,
@@ -3882,7 +3914,7 @@ var yn = class extends en {
3882
3914
  async update(e, t) {
3883
3915
  return fn({
3884
3916
  context: this.context,
3885
- ref: T(e),
3917
+ ref: w(e),
3886
3918
  params: t,
3887
3919
  dialecteConfig: this.dialecteConfig,
3888
3920
  hooks: this.hooks,
@@ -3892,7 +3924,7 @@ var yn = class extends en {
3892
3924
  async delete(e) {
3893
3925
  return cn({
3894
3926
  context: this.context,
3895
- ref: T(e),
3927
+ ref: w(e),
3896
3928
  hooks: this.hooks,
3897
3929
  query: this
3898
3930
  });
@@ -3902,7 +3934,7 @@ var yn = class extends en {
3902
3934
  dialecteConfig: this.dialecteConfig,
3903
3935
  hooks: this.hooks,
3904
3936
  context: this.context,
3905
- parentRef: T(e),
3937
+ parentRef: w(e),
3906
3938
  record: t,
3907
3939
  query: this
3908
3940
  });
@@ -4181,16 +4213,16 @@ var Tn = {
4181
4213
  } else n === void 0 ? a(e) && !isNaN(parseInt(t)) ? e.splice(t, 1) : delete e[t] : e[t] = n;
4182
4214
  }
4183
4215
  }
4184
- function S(e) {
4216
+ function ee(e) {
4185
4217
  var t, n = {};
4186
4218
  for (t in e) l(e, t) && (n[t] = e[t]);
4187
4219
  return n;
4188
4220
  }
4189
- var C = [].concat;
4190
- function ee(e) {
4191
- return C.apply([], e);
4221
+ var S = [].concat;
4222
+ function te(e) {
4223
+ return S.apply([], e);
4192
4224
  }
4193
- var w = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(ee([
4225
+ var C = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(te([
4194
4226
  8,
4195
4227
  16,
4196
4228
  32,
@@ -4205,36 +4237,36 @@ var Tn = {
4205
4237
  });
4206
4238
  }))).filter(function(e) {
4207
4239
  return r[e];
4208
- }), te = new Set(w.map(function(e) {
4240
+ }), ne = new Set(C.map(function(e) {
4209
4241
  return r[e];
4210
- })), T = null;
4211
- function ne(e) {
4212
- return T = /* @__PURE__ */ new WeakMap(), e = function e(t) {
4242
+ })), w = null;
4243
+ function re(e) {
4244
+ return w = /* @__PURE__ */ new WeakMap(), e = function e(t) {
4213
4245
  if (!t || typeof t != "object") return t;
4214
- var n = T.get(t);
4246
+ var n = w.get(t);
4215
4247
  if (n) return n;
4216
4248
  if (a(t)) {
4217
- n = [], T.set(t, n);
4249
+ n = [], w.set(t, n);
4218
4250
  for (var r = 0, i = t.length; r < i; ++r) n.push(e(t[r]));
4219
- } else if (te.has(t.constructor)) n = t;
4251
+ } else if (ne.has(t.constructor)) n = t;
4220
4252
  else {
4221
4253
  var o, c = s(t);
4222
- for (o in n = c === Object.prototype ? {} : Object.create(c), T.set(t, n), t) l(t, o) && (n[o] = e(t[o]));
4254
+ for (o in n = c === Object.prototype ? {} : Object.create(c), w.set(t, n), t) l(t, o) && (n[o] = e(t[o]));
4223
4255
  }
4224
4256
  return n;
4225
- }(e), T = null, e;
4257
+ }(e), w = null, e;
4226
4258
  }
4227
- var re = {}.toString;
4228
- function ie(e) {
4229
- return re.call(e).slice(8, -1);
4259
+ var ie = {}.toString;
4260
+ function ae(e) {
4261
+ return ie.call(e).slice(8, -1);
4230
4262
  }
4231
- var ae = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", E = typeof ae == "symbol" ? function(e) {
4263
+ var oe = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", T = typeof oe == "symbol" ? function(e) {
4232
4264
  var t;
4233
- return e != null && (t = e[ae]) && t.apply(e);
4265
+ return e != null && (t = e[oe]) && t.apply(e);
4234
4266
  } : function() {
4235
4267
  return null;
4236
4268
  };
4237
- function oe(e, t) {
4269
+ function E(e, t) {
4238
4270
  t = e.indexOf(t), 0 <= t && e.splice(t, 1);
4239
4271
  }
4240
4272
  var se = {};
@@ -4243,7 +4275,7 @@ var Tn = {
4243
4275
  if (arguments.length === 1) {
4244
4276
  if (a(e)) return e.slice();
4245
4277
  if (this === se && typeof e == "string") return [e];
4246
- if (i = E(e)) for (n = []; !(r = i.next()).done;) n.push(r.value);
4278
+ if (i = T(e)) for (n = []; !(r = i.next()).done;) n.push(r.value);
4247
4279
  else {
4248
4280
  if (e == null || typeof (t = e.length) != "number") return [e];
4249
4281
  for (n = Array(t); t--;) n[t] = e[t];
@@ -4255,7 +4287,7 @@ var Tn = {
4255
4287
  return e[Symbol.toStringTag] === "AsyncFunction";
4256
4288
  } : function() {
4257
4289
  return !1;
4258
- }, w = [
4290
+ }, C = [
4259
4291
  "Unknown",
4260
4292
  "Constraint",
4261
4293
  "Data",
@@ -4287,7 +4319,7 @@ var Tn = {
4287
4319
  "DatabaseClosed",
4288
4320
  "PrematureCommit",
4289
4321
  "ForeignAwait"
4290
- ].concat(w), le = {
4322
+ ].concat(C), le = {
4291
4323
  VersionChanged: "Database version changed by other database connection",
4292
4324
  DatabaseClosed: "Database has been closed",
4293
4325
  Abort: "Transaction aborted",
@@ -4323,10 +4355,10 @@ var Tn = {
4323
4355
  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);
4324
4356
  }
4325
4357
  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) {
4358
+ }, {}), he = (A.Syntax = SyntaxError, A.Type = TypeError, A.Range = RangeError, C.reduce(function(e, t) {
4327
4359
  return e[t + "Error"] = A[t], e;
4328
4360
  }, {}));
4329
- w = O.reduce(function(e, t) {
4361
+ C = O.reduce(function(e, t) {
4330
4362
  return [
4331
4363
  "Syntax",
4332
4364
  "Type",
@@ -4383,7 +4415,7 @@ var Tn = {
4383
4415
  return t.apply(this, arguments);
4384
4416
  };
4385
4417
  }
4386
- w.ModifyError = fe, w.DexieError = ue, w.BulkError = k;
4418
+ C.ModifyError = fe, C.DexieError = ue, C.BulkError = k;
4387
4419
  var N = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
4388
4420
  function Ce(e) {
4389
4421
  N = e;
@@ -4776,7 +4808,7 @@ var Tn = {
4776
4808
  return typeof e != "string" || /\./.test(e) ? function(e) {
4777
4809
  return e;
4778
4810
  } : function(t) {
4779
- return t[e] === void 0 && e in t && delete (t = ne(t))[e], t;
4811
+ return t[e] === void 0 && e in t && delete (t = re(t))[e], t;
4780
4812
  };
4781
4813
  }
4782
4814
  function bt() {
@@ -4805,7 +4837,7 @@ var Tn = {
4805
4837
  }
4806
4838
  function xt(e) {
4807
4839
  var t = typeof e;
4808
- return t == "object" && (ArrayBuffer.isView(e) || (t = ie(e)) === "ArrayBuffer") ? "binary" : t;
4840
+ return t == "object" && (ArrayBuffer.isView(e) || (t = ae(e)) === "ArrayBuffer") ? "binary" : t;
4809
4841
  }
4810
4842
  function St(e) {
4811
4843
  return e instanceof Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e);
@@ -5512,11 +5544,11 @@ var Tn = {
5512
5544
  })).then(function(g) {
5513
5545
  var _ = [], v = [], y = l ? [] : null, b = h ? m : [];
5514
5546
  if (!h) for (var x = 0; x < p; ++x) {
5515
- var S = g[x], C = {
5516
- value: ne(S),
5547
+ var ee = g[x], S = {
5548
+ value: re(ee),
5517
5549
  primKey: t[f + x]
5518
5550
  };
5519
- !1 !== o.call(C, C.value, C) && (C.value == null ? b.push(t[f + x]) : l || B(u(S), u(C.value)) === 0 ? (v.push(C.value), l && y.push(t[f + x])) : (b.push(t[f + x]), _.push(C.value)));
5551
+ !1 !== o.call(S, S.value, S) && (S.value == null ? b.push(t[f + x]) : l || B(u(ee), u(S.value)) === 0 ? (v.push(S.value), l && y.push(t[f + x])) : (b.push(t[f + x]), _.push(S.value)));
5520
5552
  }
5521
5553
  return Promise.resolve(0 < _.length && s.mutate({
5522
5554
  trans: r,
@@ -6248,7 +6280,7 @@ var Tn = {
6248
6280
  return t.deleteIndex(e);
6249
6281
  });
6250
6282
  }), e._cfg.contentUpgrade);
6251
- if (p && e._cfg.version > a) return cn(r, c), s._memoizedTables = {}, t = S(d), f.del.forEach(function(e) {
6283
+ if (p && e._cfg.version > a) return cn(r, c), s._memoizedTables = {}, t = ee(d), f.del.forEach(function(e) {
6252
6284
  t[e] = l[e];
6253
6285
  }), un(r, [r.Transaction.prototype]), ln(r, [r.Transaction.prototype], i(t), t), s.schema = t, (n = ce(p)) && nt(), d = I.follow(function() {
6254
6286
  var e;
@@ -6556,7 +6588,7 @@ var Tn = {
6556
6588
  return i(t).forEach(function(n) {
6557
6589
  e[n] ? Tn(e[n], t[n]) : e[n] = function e(t) {
6558
6590
  var n, r, i = {};
6559
- for (n in t) l(t, n) && (r = t[n], i[n] = !r || typeof r != "object" || te.has(r.constructor) ? r : e(r));
6591
+ for (n in t) l(t, n) && (r = t[n], i[n] = !r || typeof r != "object" || ne.has(r.constructor) ? r : e(r));
6560
6592
  return i;
6561
6593
  }(t[n]);
6562
6594
  }), e;
@@ -6583,7 +6615,7 @@ var Tn = {
6583
6615
  var t = Dn(this).next(e).value;
6584
6616
  return t && B(t.from, e) <= 0 && 0 <= B(t.to, e);
6585
6617
  }
6586
- })[ae] = function() {
6618
+ })[oe] = function() {
6587
6619
  return Dn(this);
6588
6620
  }, O));
6589
6621
  var Q = {}, Mn = {}, Nn = !1;
@@ -6808,7 +6840,7 @@ var Tn = {
6808
6840
  function Vn(e, t, n, r) {
6809
6841
  return n ||= {}, r ||= "", i(e).forEach(function(i) {
6810
6842
  var a, o, s;
6811
- l(t, i) ? (a = e[i], o = t[i], typeof a == "object" && typeof o == "object" && a && o ? (s = ie(a)) === ie(o) ? s === "Object" ? Vn(a, o, n, r + i + ".") : a !== o && (n[r + i] = t[i]) : n[r + i] = t[i] : a !== o && (n[r + i] = t[i])) : n[r + i] = void 0;
6843
+ l(t, i) ? (a = e[i], o = t[i], typeof a == "object" && typeof o == "object" && a && o ? (s = ae(a)) === ae(o) ? s === "Object" ? Vn(a, o, n, r + i + ".") : a !== o && (n[r + i] = t[i]) : n[r + i] = t[i] : a !== o && (n[r + i] = t[i])) : n[r + i] = void 0;
6812
6844
  }), i(t).forEach(function(i) {
6813
6845
  l(e, i) || (n[r + i] = t[i]);
6814
6846
  }), n;
@@ -6916,7 +6948,7 @@ var Tn = {
6916
6948
  function Wn(e, t, n) {
6917
6949
  try {
6918
6950
  if (!t || t.keys.length < e.length) return null;
6919
- for (var r = [], i = 0, a = 0; i < t.keys.length && a < e.length; ++i) B(t.keys[i], e[a]) === 0 && (r.push(n ? ne(t.values[i]) : t.values[i]), ++a);
6951
+ for (var r = [], i = 0, a = 0; i < t.keys.length && a < e.length; ++i) B(t.keys[i], e[a]) === 0 && (r.push(n ? re(t.values[i]) : t.values[i]), ++a);
6920
6952
  return r.length === e.length ? r : null;
6921
6953
  } catch {
6922
6954
  return null;
@@ -6934,7 +6966,7 @@ var Tn = {
6934
6966
  return e.cache ? (t = Wn(e.keys, e.trans._cache, e.cache === "clone")) ? I.resolve(t) : r.getMany(e).then(function(t) {
6935
6967
  return e.trans._cache = {
6936
6968
  keys: e.keys,
6937
- values: e.cache === "clone" ? ne(t) : t
6969
+ values: e.cache === "clone" ? re(t) : t
6938
6970
  }, t;
6939
6971
  }) : r.getMany(e);
6940
6972
  },
@@ -7155,7 +7187,7 @@ var Tn = {
7155
7187
  e.subscribers.add(n), r.addEventListener("abort", function() {
7156
7188
  var r, i;
7157
7189
  e.subscribers.delete(n), e.subscribers.size === 0 && (r = e, i = t, setTimeout(function() {
7158
- r.subscribers.size === 0 && oe(i, r);
7190
+ r.subscribers.size === 0 && E(i, r);
7159
7191
  }, 3e3));
7160
7192
  });
7161
7193
  }
@@ -7177,16 +7209,16 @@ var Tn = {
7177
7209
  var f = e.table(u), p = d.optimisticOps.filter(function(e) {
7178
7210
  return e.trans === s;
7179
7211
  });
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) {
7212
+ 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) && (E(b, x), x.subscribers.forEach(function(e) {
7181
7213
  return o.add(e);
7182
7214
  }));
7183
7215
  else if (0 < p.length) {
7184
7216
  d.optimisticOps = d.optimisticOps.filter(function(e) {
7185
7217
  return e.trans !== s;
7186
7218
  });
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) {
7219
+ for (var v = 0, y = Object.values(d.queries.query); v < y.length; v++) for (var b, x, ee, S = 0, te = (b = y[v]).slice(); S < te.length; S++) (x = te[S]).res != null && s.mutatedParts && (i && !x.dirty ? (ee = Object.isFrozen(x.res), ee = Zn(x.res, x.req, p, f, x, ee), x.dirty ? (E(b, x), x.subscribers.forEach(function(e) {
7188
7220
  return o.add(e);
7189
- })) : S !== x.res && (x.res = S, x.promise = I.resolve({ result: S }))) : (x.dirty && oe(b, x), x.subscribers.forEach(function(e) {
7221
+ })) : ee !== x.res && (x.res = ee, x.promise = I.resolve({ result: ee }))) : (x.dirty && E(b, x), x.subscribers.forEach(function(e) {
7190
7222
  return o.add(e);
7191
7223
  })));
7192
7224
  }
@@ -7207,13 +7239,13 @@ var Tn = {
7207
7239
  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) {
7208
7240
  return e == null;
7209
7241
  })) ? (o.optimisticOps.push(e), e.mutatedParts && Pn(e.mutatedParts), s.then(function(t) {
7210
- 0 < t.numFailures && (oe(o.optimisticOps, e), (t = Yn(0, e, t)) && o.optimisticOps.push(t), e.mutatedParts) && Pn(e.mutatedParts);
7242
+ 0 < t.numFailures && (E(o.optimisticOps, e), (t = Yn(0, e, t)) && o.optimisticOps.push(t), e.mutatedParts) && Pn(e.mutatedParts);
7211
7243
  }), s.catch(function() {
7212
- oe(o.optimisticOps, e), e.mutatedParts && Pn(e.mutatedParts);
7244
+ E(o.optimisticOps, e), e.mutatedParts && Pn(e.mutatedParts);
7213
7245
  })) : s.then(function(n) {
7214
7246
  var r = Yn(0, t(t({}, e), { values: e.values.map(function(e, r) {
7215
7247
  var i;
7216
- return n.failures[r] ? e : (x(i = (i = a.keyPath) != null && i.includes(".") ? ne(e) : t({}, e), a.keyPath, n.results[r]), i);
7248
+ return n.failures[r] ? e : (x(i = (i = a.keyPath) != null && i.includes(".") ? re(e) : t({}, e), a.keyPath, n.results[r]), i);
7217
7249
  }) }), n);
7218
7250
  o.optimisticOps.push(r), queueMicrotask(function() {
7219
7251
  return e.mutatedParts && Pn(e.mutatedParts);
@@ -7273,7 +7305,7 @@ var Tn = {
7273
7305
  }
7274
7306
  return e;
7275
7307
  }).catch(function(e) {
7276
- return c && u && oe(c, u), Promise.reject(e);
7308
+ return c && u && E(c, u), Promise.reject(e);
7277
7309
  }), u = {
7278
7310
  obsSet: e.obsSet,
7279
7311
  promise: l,
@@ -7290,7 +7322,7 @@ var Tn = {
7290
7322
  optimisticOps: [],
7291
7323
  unsignaledParts: {}
7292
7324
  }).queries.query[e.query.index.name || ""] = c)), er(u, c, a, o), u.promise.then(function(n) {
7293
- return n = Zn(n.result, e, s?.optimisticOps, i, u, t), { result: t ? n : ne(n) };
7325
+ return n = Zn(n.result, e, s?.optimisticOps, i, u, t), { result: t ? n : re(n) };
7294
7326
  })) : i.query(e);
7295
7327
  }
7296
7328
  });
@@ -7402,7 +7434,7 @@ var Tn = {
7402
7434
  for (var i = Array(r - 1); --r;) i[r - 1] = arguments[r];
7403
7435
  return n = i.pop(), [
7404
7436
  e,
7405
- ee(i),
7437
+ te(i),
7406
7438
  n
7407
7439
  ];
7408
7440
  }.apply(this, arguments);
@@ -7696,7 +7728,7 @@ var Tn = {
7696
7728
  dr = t;
7697
7729
  }
7698
7730
  }
7699
- u(cr, t(t({}, w), {
7731
+ u(cr, t(t({}, C), {
7700
7732
  delete: function(e) {
7701
7733
  return new cr(e, { addons: [] }).delete();
7702
7734
  },
@@ -7778,8 +7810,8 @@ var Tn = {
7778
7810
  x(e, t, void 0);
7779
7811
  });
7780
7812
  },
7781
- shallowClone: S,
7782
- deepClone: ne,
7813
+ shallowClone: ee,
7814
+ deepClone: re,
7783
7815
  getObjectDiff: Vn,
7784
7816
  cmp: B,
7785
7817
  asap: y,
@@ -7885,10 +7917,12 @@ var Wn = {
7885
7917
  });
7886
7918
  }
7887
7919
  async getDocument(e) {
7888
- return await this.ensureCurrentSchema(), this.db.table(q).get(e);
7920
+ await this.ensureCurrentSchema();
7921
+ let t = await this.db.table(q).get(e);
7922
+ return t && Jn(t);
7889
7923
  }
7890
7924
  async getDocuments() {
7891
- return await this.ensureCurrentSchema(), this.db.table(q).toArray();
7925
+ return await this.ensureCurrentSchema(), (await this.db.table(q).toArray()).map(Jn);
7892
7926
  }
7893
7927
  async updateDocument(e, t) {
7894
7928
  await this.ensureCurrentSchema(), await this.db.table(q).update(e, t);
@@ -8176,7 +8210,7 @@ var Wn = {
8176
8210
  });
8177
8211
  try {
8178
8212
  await e.open();
8179
- let t = await e.table(q).toArray(), n = await e.table(Y).get("schemaVersion");
8213
+ let t = (await e.table(q).toArray()).map(Jn), n = await e.table(Y).get("schemaVersion");
8180
8214
  e.close(), this.knownDocuments = new Map(t.map((e) => [e.id, e])), this.schemaVersion = n?.value ?? 1;
8181
8215
  } catch {
8182
8216
  e.close();
@@ -8206,9 +8240,15 @@ function Kn() {
8206
8240
  function qn(e, t) {
8207
8241
  e.has(t) || r("DOCUMENT_NOT_REGISTERED", { detail: `Cannot add blob: owner document "${t}" is not registered` });
8208
8242
  }
8243
+ function Jn(e) {
8244
+ return e.status ? e : {
8245
+ ...e,
8246
+ status: "ready"
8247
+ };
8248
+ }
8209
8249
  //#endregion
8210
8250
  //#region src/store/in-memory/in-memory-store.ts
8211
- var Jn = class e {
8251
+ var Yn = class e {
8212
8252
  static {
8213
8253
  this.reconcileWarned = !1;
8214
8254
  }
@@ -8415,15 +8455,15 @@ var Jn = class e {
8415
8455
  };
8416
8456
  //#endregion
8417
8457
  //#region src/store/resolve-store.ts
8418
- function Yn(e, t, n, r) {
8458
+ function Xn(e, t, n, r) {
8419
8459
  return t.type === "local" ? new Gn(e, {
8420
8460
  recordSchema: n.database.recordSchema,
8421
8461
  perf: r
8422
- }) : t.type === "inMemory" ? new Jn(e, { writable: t.writable ?? !0 }) : t.store;
8462
+ }) : t.type === "inMemory" ? new Yn(e, { writable: t.writable ?? !0 }) : t.store;
8423
8463
  }
8424
8464
  //#endregion
8425
8465
  //#region src/project/io/export-document.ts
8426
- async function Xn(e) {
8466
+ async function Zn(e) {
8427
8467
  let { documentId: t, state: n, configs: r, store: i, projectName: a, options: o } = e, s = n.documents.get(t);
8428
8468
  u(s, {
8429
8469
  key: "DOCUMENT_NOT_REGISTERED",
@@ -8445,7 +8485,7 @@ async function Xn(e) {
8445
8485
  }
8446
8486
  //#endregion
8447
8487
  //#region src/project/io/export-blob.ts
8448
- async function Zn(e) {
8488
+ async function Qn(e) {
8449
8489
  let { blobId: t, store: n, options: r } = e, i = await n.getBlob(t);
8450
8490
  u(i, {
8451
8491
  key: "BLOB_NOT_FOUND",
@@ -8462,8 +8502,20 @@ async function Zn(e) {
8462
8502
  };
8463
8503
  }
8464
8504
  //#endregion
8505
+ //#region src/project/state/document-lifecycle.ts
8506
+ var $n = 2e3, er = 5 * 6e4;
8507
+ function tr(e) {
8508
+ return e.status === "importing";
8509
+ }
8510
+ function nr(e, t = Date.now()) {
8511
+ return tr(e) && t - (e.importingAt ?? 0) > 3e5;
8512
+ }
8513
+ function rr(e) {
8514
+ return e.filter((e) => !tr(e));
8515
+ }
8516
+ //#endregion
8465
8517
  //#region src/project/state/document-state.ts
8466
- function Qn(e) {
8518
+ function $(e) {
8467
8519
  return {
8468
8520
  record: e,
8469
8521
  loading: !1,
@@ -8475,46 +8527,74 @@ function Qn(e) {
8475
8527
  canRedo: !1
8476
8528
  };
8477
8529
  }
8478
- function $n(e, t) {
8530
+ function ir(e, t) {
8479
8531
  let n = new Set(t.map((e) => e.id));
8480
- for (let n of t) e.has(n.id) || e.set(n.id, Qn(n));
8532
+ for (let n of t) e.has(n.id) || e.set(n.id, $(n));
8481
8533
  for (let t of e.keys()) n.has(t) || e.delete(t);
8482
8534
  return e;
8483
8535
  }
8484
8536
  //#endregion
8485
- //#region src/project/io/import-document.ts
8486
- async function er(e) {
8487
- let { file: t, store: n, configs: r, defaultConfigKey: i, options: a, hooks: o, perf: s } = e, c = a?.configKey ?? i, l = r[c];
8488
- u(l, {
8537
+ //#region src/project/io/resolve-config.ts
8538
+ function ar(e) {
8539
+ let { configs: t, defaultConfigKey: n, configKey: r = n } = e, i = t[r];
8540
+ return u(i, {
8489
8541
  key: "UNKNOWN_CONFIG_KEY",
8490
- detail: `Unknown configKey: "${c}". Available: ${Object.keys(r).join(", ")}`
8491
- });
8492
- let d = crypto.randomUUID(), f = t.name.includes(".") ? `.${t.name.split(".").pop()}` : l.io.supportedFileExtensions[0], p = {
8493
- id: d,
8542
+ detail: `Unknown configKey: "${r}". Available: ${Object.keys(t).join(", ")}`
8543
+ }), {
8544
+ configKey: r,
8545
+ config: i
8546
+ };
8547
+ }
8548
+ //#endregion
8549
+ //#region src/project/io/import-document.ts
8550
+ async function or(e) {
8551
+ let { file: t, store: n, configs: r, defaultConfigKey: i, options: a, hooks: o, perf: s } = e, { configKey: c, config: l } = ar({
8552
+ configs: r,
8553
+ defaultConfigKey: i,
8554
+ configKey: a?.configKey
8555
+ }), u = crypto.randomUUID(), d = t.name.includes(".") ? `.${t.name.split(".").pop()}` : l.io.supportedFileExtensions[0], f = {
8556
+ id: u,
8494
8557
  name: t.name.replace(/\.[^.]+$/, "") || "untitled",
8495
- extension: f,
8558
+ extension: d,
8496
8559
  configKey: c,
8497
8560
  createdAt: Date.now(),
8498
- metadata: a?.metadata
8561
+ metadata: a?.metadata,
8562
+ status: "importing",
8563
+ importingAt: Date.now()
8564
+ };
8565
+ await g(n, f);
8566
+ let p = sr(n, u), m;
8567
+ try {
8568
+ m = await G({
8569
+ file: t,
8570
+ documentId: u,
8571
+ configKey: c,
8572
+ store: n,
8573
+ config: l,
8574
+ useCustomRecordsIds: a?.useCustomRecordsIds,
8575
+ chunkOptions: a?.chunkOptions,
8576
+ hooks: o,
8577
+ perf: s
8578
+ }), clearInterval(p), await n.updateDocument(u, { status: "ready" });
8579
+ } catch (e) {
8580
+ clearInterval(p);
8581
+ try {
8582
+ await n.removeDocument(u);
8583
+ } catch {}
8584
+ throw e;
8585
+ }
8586
+ let h = {
8587
+ ...f,
8588
+ status: "ready"
8499
8589
  };
8500
- await h(n, p);
8501
- let { recordCount: m } = await G({
8502
- file: t,
8503
- documentId: d,
8504
- store: n,
8505
- config: l,
8506
- useCustomRecordsIds: a?.useCustomRecordsIds,
8507
- chunkOptions: a?.chunkOptions,
8508
- hooks: o,
8509
- perf: s
8510
- });
8511
8590
  return {
8512
- documentId: d,
8513
- record: p,
8514
- documentState: Qn(p),
8515
- recordCount: m
8591
+ documentId: u,
8592
+ record: h,
8593
+ documentState: $(h),
8594
+ recordCount: m.recordCount,
8595
+ diagnostics: m.diagnostics
8516
8596
  };
8517
- async function h(e, t) {
8597
+ async function g(e, t) {
8518
8598
  s?.start("core::import::registerDocument");
8519
8599
  try {
8520
8600
  await e.registerDocument(t);
@@ -8523,24 +8603,31 @@ async function er(e) {
8523
8603
  }
8524
8604
  }
8525
8605
  }
8606
+ function sr(e, t) {
8607
+ return setInterval(async () => {
8608
+ try {
8609
+ await e.updateDocument(t, { importingAt: Date.now() });
8610
+ } catch {}
8611
+ }, $n);
8612
+ }
8526
8613
  //#endregion
8527
8614
  //#region src/project/io/init-empty-document.ts
8528
- async function tr(e) {
8529
- let { store: t, configs: n, defaultConfigKey: r, options: i, hooks: a } = e, o = i?.configKey ?? r, s = n[o];
8530
- u(s, {
8531
- key: "UNKNOWN_CONFIG_KEY",
8532
- detail: `Unknown configKey: "${o}". Available: ${Object.keys(n).join(", ")}`
8533
- });
8534
- let c = i?.extension ?? s.io.supportedFileExtensions[0], l = i?.name ?? "untitled", d = crypto.randomUUID(), f = {
8535
- id: d,
8615
+ async function cr(e) {
8616
+ let { store: t, configs: n, defaultConfigKey: r, options: i, hooks: a } = e, { configKey: o, config: s } = ar({
8617
+ configs: n,
8618
+ defaultConfigKey: r,
8619
+ configKey: i?.configKey
8620
+ }), c = i?.extension ?? s.io.supportedFileExtensions[0], l = i?.name ?? "untitled", u = crypto.randomUUID(), d = {
8621
+ id: u,
8536
8622
  name: l,
8537
8623
  extension: c,
8538
8624
  configKey: o,
8539
8625
  createdAt: Date.now(),
8626
+ status: "ready",
8540
8627
  metadata: i?.metadata
8541
8628
  };
8542
- await t.registerDocument(f);
8543
- let p = ee({
8629
+ await t.registerDocument(d);
8630
+ let f = te({
8544
8631
  dialecteConfig: s,
8545
8632
  hooks: a,
8546
8633
  record: {
@@ -8551,15 +8638,15 @@ async function tr(e) {
8551
8638
  children: []
8552
8639
  }
8553
8640
  });
8554
- return await t.bulkWrite(d, { creates: [p] }), {
8555
- documentId: d,
8556
- record: f,
8557
- documentState: Qn(f)
8641
+ return await t.bulkWrite(u, { creates: [f] }), {
8642
+ documentId: u,
8643
+ record: d,
8644
+ documentState: $(d)
8558
8645
  };
8559
8646
  }
8560
8647
  //#endregion
8561
8648
  //#region src/project/project.ts
8562
- var nr = class {
8649
+ var lr = class {
8563
8650
  get name() {
8564
8651
  return u(this._name !== void 0, {
8565
8652
  key: "PROJECT_NOT_OPENED",
@@ -8567,11 +8654,19 @@ var nr = class {
8567
8654
  }), this._name;
8568
8655
  }
8569
8656
  get store() {
8570
- return u(this._store !== void 0, {
8657
+ return u(this._store !== void 0 && !this.closing, {
8571
8658
  key: "PROJECT_NOT_OPENED",
8572
- detail: "Call project.open(name) before accessing project properties."
8659
+ detail: this.closing ? "The project is closed: open it again before using it." : "Call project.open(name) before accessing project properties."
8573
8660
  }), this._store;
8574
8661
  }
8662
+ enqueueImport(e) {
8663
+ let t = this.importChain.then(e, e);
8664
+ return this.importChain = t, t;
8665
+ }
8666
+ settledImports() {
8667
+ let e = () => {};
8668
+ return this.importChain.then(e, e);
8669
+ }
8575
8670
  get channel() {
8576
8671
  return u(this._channel !== void 0, {
8577
8672
  key: "PROJECT_NOT_OPENED",
@@ -8596,7 +8691,7 @@ var nr = class {
8596
8691
  if (n) for (let e of n) e(t);
8597
8692
  }
8598
8693
  constructor(e) {
8599
- this.closing = !1, this.pendingBroadcastWork = /* @__PURE__ */ new Set(), this.state = {
8694
+ this.closing = !1, this.pendingBroadcastWork = /* @__PURE__ */ new Set(), this.importChain = Promise.resolve(), this.state = {
8600
8695
  documents: /* @__PURE__ */ new Map(),
8601
8696
  activeTransactions: 0
8602
8697
  }, this.stateSubscribers = /* @__PURE__ */ new Map();
@@ -8610,11 +8705,13 @@ var nr = class {
8610
8705
  this._name = e, this.closing = !1, this._channel = new BroadcastChannel(this.channelName), this._channel.addEventListener("message", (e) => {
8611
8706
  this.onChannelMessage(e.data);
8612
8707
  });
8613
- let t = Yn(e, this.storage, this.configs[this.defaultConfigKey], this.perf);
8708
+ let t = Xn(e, this.storage, this.configs[this.defaultConfigKey], this.perf);
8614
8709
  await t.open(), this._store = t;
8615
- let n = await t.getDocuments();
8616
- for (let e of n) this.state.documents.set(e.id, Qn(e));
8617
- return await Promise.all(n.map((e) => this.refreshHistoryStatus(e.id))), this;
8710
+ let n = await ur(t);
8711
+ for (let e of n) this.state.documents.set(e.id, $(e));
8712
+ return await Promise.all(n.map((e) => this.refreshHistoryStatus(e.id))), this.staleSweep = setInterval(() => {
8713
+ this.trackBroadcastWork(ur(t).then(() => {}));
8714
+ }, er), this;
8618
8715
  }
8619
8716
  onChannelMessage(e) {
8620
8717
  if (!this.closing) switch (e?.type) {
@@ -8643,14 +8740,14 @@ var nr = class {
8643
8740
  let { canUndo: n, canRedo: r } = await this.store.getHistoryStatus(e);
8644
8741
  t.canUndo = n, t.canRedo = r;
8645
8742
  }
8646
- close() {
8647
- this.closing = !0, this._channel?.close(), this.store.close();
8743
+ async close() {
8744
+ this.closing = !0, await this.settledImports(), clearInterval(this.staleSweep), this._channel?.close(), this._store?.close();
8648
8745
  }
8649
8746
  async destroy() {
8650
- this.closing = !0, this._channel?.close(), await Promise.allSettled(this.pendingBroadcastWork), await this.store.destroy(), this.state.documents.clear();
8747
+ this.closing = !0, await this.settledImports(), this._channel?.close(), await Promise.allSettled(this.pendingBroadcastWork), await this._store?.destroy(), this.state.documents.clear();
8651
8748
  }
8652
8749
  async initEmptyDocument(e) {
8653
- let t = await tr({
8750
+ let t = await cr({
8654
8751
  store: this.store,
8655
8752
  configs: this.configs,
8656
8753
  defaultConfigKey: this.defaultConfigKey,
@@ -8670,28 +8767,66 @@ var nr = class {
8670
8767
  timestamp: Date.now()
8671
8768
  });
8672
8769
  }
8770
+ importStore(e) {
8771
+ let t = this.store;
8772
+ return ar({
8773
+ configs: this.configs,
8774
+ defaultConfigKey: this.defaultConfigKey,
8775
+ configKey: e?.configKey
8776
+ }), t;
8777
+ }
8673
8778
  async import(e, t) {
8674
- let n = await Promise.all(e.map((e) => er({
8779
+ this.importStore(t);
8780
+ let n = [];
8781
+ for (let r of e) try {
8782
+ n.push({
8783
+ status: "imported",
8784
+ ...await this.importFile(r, t)
8785
+ });
8786
+ } catch (e) {
8787
+ let t = o(e) ?? o(a("IMPORT_FAILED", {
8788
+ detail: e instanceof Error ? e.message : String(e),
8789
+ cause: e instanceof Error ? e : void 0
8790
+ }));
8791
+ n.push({
8792
+ status: "failed",
8793
+ fileName: r.name,
8794
+ error: t
8795
+ });
8796
+ }
8797
+ return n;
8798
+ }
8799
+ async importFile(e, t) {
8800
+ let n = this.importStore(t);
8801
+ return this.enqueueImport(() => this.importOne({
8675
8802
  file: e,
8676
- store: this.store,
8803
+ options: t,
8804
+ store: n
8805
+ }));
8806
+ }
8807
+ async importOne(e) {
8808
+ let { file: t, options: n, store: r } = e, i = await or({
8809
+ file: t,
8810
+ store: r,
8677
8811
  configs: this.configs,
8678
8812
  defaultConfigKey: this.defaultConfigKey,
8679
- options: t,
8813
+ options: n,
8680
8814
  hooks: this.hooks,
8681
8815
  perf: this.perf
8682
- })));
8683
- for (let e of n) this.state.documents.set(e.documentId, e.documentState), this.broadcast({
8816
+ });
8817
+ return this.state.documents.set(i.documentId, i.documentState), this.broadcast({
8684
8818
  type: "document-imported",
8685
- documentId: e.documentId,
8819
+ documentId: i.documentId,
8686
8820
  timestamp: Date.now()
8687
- });
8688
- return n.map(({ documentId: e, recordCount: t }) => ({
8689
- documentId: e,
8690
- recordCount: t
8691
- }));
8821
+ }), {
8822
+ fileName: t.name,
8823
+ documentId: i.documentId,
8824
+ recordCount: i.recordCount,
8825
+ diagnostics: i.diagnostics
8826
+ };
8692
8827
  }
8693
8828
  async export(e, t) {
8694
- return Xn({
8829
+ return Zn({
8695
8830
  documentId: e,
8696
8831
  state: this.state,
8697
8832
  configs: this.configs,
@@ -8701,10 +8836,11 @@ var nr = class {
8701
8836
  });
8702
8837
  }
8703
8838
  async getDocuments() {
8704
- return this.store.getDocuments();
8839
+ return rr(await this.store.getDocuments());
8705
8840
  }
8706
8841
  async getDocument(e) {
8707
- return this.store.getDocument(e);
8842
+ let t = await this.store.getDocument(e);
8843
+ return t && !tr(t) ? t : void 0;
8708
8844
  }
8709
8845
  openDocument(e) {
8710
8846
  let t = this.state.documents.get(e);
@@ -8782,7 +8918,7 @@ var nr = class {
8782
8918
  return this.store.getBlob(e);
8783
8919
  }
8784
8920
  async exportBlob(e, t) {
8785
- return Zn({
8921
+ return Qn({
8786
8922
  blobId: e,
8787
8923
  store: this.store,
8788
8924
  options: t
@@ -8839,11 +8975,15 @@ var nr = class {
8839
8975
  }
8840
8976
  async refreshState() {
8841
8977
  let e = await this.store.getDocuments();
8842
- $n(this.state.documents, e);
8978
+ ir(this.state.documents, rr(e));
8843
8979
  }
8844
8980
  async reconcileFromBroadcast(e) {
8845
8981
  this.closing || (await this.store.reconcile(e), await this.refreshState());
8846
8982
  }
8847
8983
  };
8984
+ async function ur(e) {
8985
+ let t = await e.getDocuments(), n = Date.now(), r = t.filter((e) => nr(e, n));
8986
+ return await Promise.all(r.map((t) => e.removeDocument(t.id))), rr(t);
8987
+ }
8848
8988
  //#endregion
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 };
8989
+ export { Ue as $, en as A, mt as B, Sn as C, bn as D, xn as E, Mt as F, ot as G, ft as H, At as I, Je as J, L as K, Ot as L, Xt as M, G as N, yn as O, Pt as P, We as Q, gt as R, Y as S, Cn as T, z as U, pt as V, lt as W, Ge as X, Ke as Y, qe as Z, Dn as _, k as _t, ir as a, Ce as at, J as b, O as bt, Qn as c, Se as ct, Yn as d, ye as dt, Ve as et, Gn as f, ve as ft, Tn as g, j as gt, En as h, ge as ht, $ as i, De as it, $t as j, hn as k, Zn as l, xe as lt, kn as m, M as mt, cr as n, ze as nt, $n as o, P as ot, On as p, _e as pt, Ye as q, or as r, Be as rt, er as s, N as st, lr as t, He as tt, Xn as u, be as ut, X as v, de as vt, wn as w, q as x, Z as y, le as yt, ht as z };