@sheetxl/io-xlsx 0.8.0-beta.1 → 0.8.0-beta.10

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 (126) hide show
  1. package/browser/esm/{Ctqql4O-3xj2K8vv.mjs → 2EOdn2WRK5y1L58S.mjs} +193 -143
  2. package/browser/esm/{BkNXyG6NC-w5Xo92.mjs → B-jb5SuiVh5NnBG_.mjs} +28 -13
  3. package/browser/esm/BKT8OBj-bhQwdg49.mjs +67 -0
  4. package/browser/esm/BLXcoiDAaOMjFuhw.mjs +8056 -0
  5. package/browser/esm/BPmehfSqdvgsLBsB.mjs +5153 -0
  6. package/browser/esm/CI_CZI5m5-KkiAK5.mjs +3559 -0
  7. package/browser/esm/{Dz1Dp8DDJvhd09RR.mjs → DXopGe8PrLWmwGaV.mjs} +1 -1
  8. package/browser/esm/NQIuOQIleHC4NUW6.mjs +2446 -0
  9. package/browser/esm/index.mjs +2 -3
  10. package/browser/esm/{CLWzJJyoSrykkVLX.mjs → xc_LzCPgHn-acgFZ.mjs} +2 -2
  11. package/licenses/dependencies.txt +2 -2
  12. package/node/esm/{fOnuUjpPCAzmuIXN.mjs → BmdmvgO5Zdgx-RWo.mjs} +2 -2
  13. package/node/esm/BpxxiZ2oKPkUSfdB.mjs +2486 -0
  14. package/node/esm/{CEV7nKotMpeRRnQC.mjs → CHqRP_NjPpPd7m9L.mjs} +1 -1
  15. package/node/esm/CtAF486aZqYzMeLM.mjs +3651 -0
  16. package/node/esm/{CEAmv36xpTNgFwl_.mjs → O5mti2R9drFOlXc7.mjs} +49 -35
  17. package/node/esm/QS_theNoeqNGLStj.mjs +5298 -0
  18. package/node/esm/index.mjs +40 -25
  19. package/node/esm/nNQ7MG89sGKwkjMA.mjs +4649 -0
  20. package/package.json +7 -8
  21. package/types/src/AutoFilterRules.d.ts +86 -10
  22. package/types/src/ConditionalFormatRules.d.ts +5 -5
  23. package/types/src/DataValidationRules.d.ts +18 -2
  24. package/types/src/ExcelCalcStamp.d.ts +39 -0
  25. package/types/src/ExcelCompat.d.ts +197 -42
  26. package/types/src/ExcelReservedNames.d.ts +3 -4
  27. package/types/src/LegacyFormula.d.ts +28 -7
  28. package/types/src/OOXMLExtensions.d.ts +14 -2
  29. package/types/src/Plugin.d.ts +16 -5
  30. package/types/src/ProtectionAttributes.d.ts +38 -0
  31. package/types/src/SourcePackage.d.ts +31 -12
  32. package/types/src/Types.d.ts +17 -0
  33. package/types/src/reader/HiddenFormulas.d.ts +16 -0
  34. package/types/src/reader/SlicerJoin.d.ts +24 -0
  35. package/types/src/reader/Warning.d.ts +29 -0
  36. package/types/src/reader/ZipReader.d.ts +1 -1
  37. package/types/src/reader/_SlicerRecord.d.ts +37 -0
  38. package/types/src/reader/dom/CustGeomUtils.d.ts +7 -0
  39. package/types/src/reader/dom/DOMTransformer.d.ts +2 -2
  40. package/types/src/reader/dom/ExecutionContext.d.ts +16 -3
  41. package/types/src/reader/dom/Types.d.ts +19 -3
  42. package/types/src/reader/domVisitors/AutoFilterVisitor.d.ts +13 -0
  43. package/types/src/reader/domVisitors/ColorContainerVisitor.d.ts +15 -2
  44. package/types/src/reader/domVisitors/CommentVisitor.d.ts +24 -2
  45. package/types/src/reader/domVisitors/CommentsVisitor.d.ts +2 -2
  46. package/types/src/reader/domVisitors/DrawingCxnSpVisitor.d.ts +1 -0
  47. package/types/src/reader/domVisitors/DrawingElementVisitor.d.ts +32 -1
  48. package/types/src/reader/domVisitors/DrawingGraphicFrameVisitor.d.ts +9 -0
  49. package/types/src/reader/domVisitors/DrawingGrpSpVisitor.d.ts +14 -2
  50. package/types/src/reader/domVisitors/DrawingPicVisitor.d.ts +13 -0
  51. package/types/src/reader/domVisitors/DrawingSpVisitor.d.ts +20 -1
  52. package/types/src/reader/domVisitors/DrawingVisitor.d.ts +10 -0
  53. package/types/src/reader/domVisitors/ExternalLinkVisitor.d.ts +21 -3
  54. package/types/src/reader/domVisitors/FmtSchemeVisitor.d.ts +4 -4
  55. package/types/src/reader/domVisitors/FormControlPrVisitor.d.ts +9 -0
  56. package/types/src/reader/domVisitors/ShapeTextVisitor.d.ts +44 -0
  57. package/types/src/reader/domVisitors/SheetColorContainerVisitor.d.ts +2 -2
  58. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +19 -6
  59. package/types/src/reader/domVisitors/SlicerCacheDefinitionVisitor.d.ts +7 -2
  60. package/types/src/reader/domVisitors/SlicersVisitor.d.ts +7 -3
  61. package/types/src/reader/domVisitors/TextPropertiesVisitor.d.ts +13 -1
  62. package/types/src/reader/domVisitors/ThreadedCommentVisitor.d.ts +18 -1
  63. package/types/src/reader/domVisitors/ThreadedCommentsVisitor.d.ts +2 -2
  64. package/types/src/reader/domVisitors/WorkbookVisitor.d.ts +11 -1
  65. package/types/src/reader/domVisitors/index.d.ts +4 -2
  66. package/types/src/reader/sax/LeanSaxParser.d.ts +58 -0
  67. package/types/src/reader/sax/SaxParser.d.ts +11 -1
  68. package/types/src/reader/sax/SaxVisitor.d.ts +3 -2
  69. package/types/src/reader/saxVisitors/ContentTypesVisitor.d.ts +9 -0
  70. package/types/src/reader/saxVisitors/WorksheetVisitor.d.ts +11 -4
  71. package/types/src/utils/DrawingMLText.d.ts +39 -0
  72. package/types/src/utils/FormControls.d.ts +170 -0
  73. package/types/src/utils/VmlNoteShapes.d.ts +135 -0
  74. package/types/src/vba/VBAProject.d.ts +52 -4
  75. package/types/src/writer/builder/ContentTypes.d.ts +13 -0
  76. package/types/src/writer/builder/Emitter.d.ts +11 -6
  77. package/types/src/writer/builder/OpcXmlUtils.d.ts +2 -0
  78. package/types/src/writer/builder/PackageBuilder.d.ts +72 -22
  79. package/types/src/writer/builder/PartWriter.d.ts +5 -0
  80. package/types/src/writer/builder/RelationshipSet.d.ts +3 -0
  81. package/types/src/writer/builder/Types.d.ts +117 -38
  82. package/types/src/writer/builder/_Types.d.ts +17 -0
  83. package/types/src/writer/emitters/CommentsEmitter.d.ts +58 -0
  84. package/types/src/writer/emitters/EmbeddedPartEmitter.d.ts +60 -0
  85. package/types/src/writer/emitters/ExternalLinkEmitter.d.ts +19 -0
  86. package/types/src/writer/emitters/LegacyDrawingEmitter.d.ts +18 -0
  87. package/types/src/writer/emitters/PersonsEmitter.d.ts +17 -0
  88. package/types/src/writer/emitters/PivotTableEmitter.d.ts +45 -0
  89. package/types/src/writer/emitters/SlicerEmitter.d.ts +66 -0
  90. package/types/src/writer/emitters/StylesEmitter.d.ts +2 -2
  91. package/types/src/writer/emitters/TableEmitter.d.ts +14 -0
  92. package/types/src/writer/emitters/ThreadedCommentsEmitter.d.ts +27 -0
  93. package/types/src/writer/emitters/WorkbookEmitter.d.ts +16 -3
  94. package/types/src/writer/utils/AutoFilter.d.ts +2 -2
  95. package/types/src/writer/utils/CustGeomUtils.d.ts +5 -0
  96. package/types/src/writer/utils/DrawMLUtils.d.ts +57 -3
  97. package/types/src/writer/utils/DummyFunction.d.ts +0 -2
  98. package/types/src/writer/utils/DxfCollector.d.ts +3 -3
  99. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +28 -0
  100. package/types/src/writer/utils/PrstGeomUtils.d.ts +6 -0
  101. package/types/src/writer/utils/TextUtils.d.ts +21 -2
  102. package/browser/cjs/B6sirGz6w-Bm7Ofo.cjs +0 -1
  103. package/browser/cjs/B7_pDFYCVzt-3hUs.cjs +0 -1
  104. package/browser/cjs/BAtEL-5TLyoaPFDP.cjs +0 -2
  105. package/browser/cjs/Bg0e53JZa8vhmm5a.cjs +0 -1
  106. package/browser/cjs/CIpMN7SDVREKQUQE.cjs +0 -6
  107. package/browser/cjs/CK5FFUvet6FnIYO_.cjs +0 -5
  108. package/browser/cjs/D5Y4KQhKdukOkjvA.cjs +0 -2
  109. package/browser/cjs/DV6LeTEiiFUrZoxj.cjs +0 -1
  110. package/browser/cjs/DWkuoJSgvcXJTdN1.cjs +0 -1
  111. package/browser/cjs/Db8YjGM6TG34c8aT.cjs +0 -1
  112. package/browser/cjs/index.cjs +0 -1
  113. package/browser/cjs/xQ6-wbTw5UzZUM1Y.cjs +0 -1
  114. package/browser/esm/4BWLu134ABlCQEtM.mjs +0 -3655
  115. package/browser/esm/BzQ_lPzc8C4OTIGZ.mjs +0 -99
  116. package/browser/esm/CJknI8BYGSZr-4zS.mjs +0 -52
  117. package/browser/esm/Cok_fBIUCHDSrKw0.mjs +0 -2211
  118. package/browser/esm/D-m_kQLaewdwuXaF.mjs +0 -2685
  119. package/browser/esm/Dj7D2nVdAZ3TiUks.mjs +0 -4743
  120. package/browser/esm/ijQzHH-bvDfUHIi1.mjs +0 -24
  121. package/node/esm/CF1R5ovFsRNu--Rw.mjs +0 -3744
  122. package/node/esm/Ctcl4jN52INWpKWC.mjs +0 -2255
  123. package/node/esm/CvnRSooxEQdlJgMn.mjs +0 -2766
  124. package/node/esm/DQd0vxzTaPt2qSL-.mjs +0 -108
  125. package/node/esm/ssSlRCbCqxvZ9IX8.mjs +0 -2481
  126. package/types/src/reader/domVisitors/HyperlinkVisitor.d.ts +0 -6
@@ -0,0 +1,3559 @@
1
+ /**
2
+ * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.10
3
+ *
4
+ * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
+ * License: The license can be found at https://www.sheetxl.com/license.
6
+ */
7
+ import { $t as e, At as t, Bt as n, Ct as r, Dt as i, Et as a, Jt as o, Kt as s, Lt as c, Nt as l, Q as u, Qt as d, Rt as f, S as p, St as m, Ut as ee, Vt as h, Wt as g, Xt as _, Y as v, Yt as y, Z as te, en as ne, gt as b, ht as re, in as x, kt as ie, l as ae, lt as oe, m as S, on as C, ot as w, pt as se, q as T, rn as E, rt as D, sn as ce, st as O, t as le, u as ue, wt as de, x as k, xt as A, y as j, zt as M } from "./BLXcoiDAaOMjFuhw.mjs";
8
+ import { BufferUtils as fe, CommonUtils as pe, ExpectedError as me } from "@sheetxl/utils";
9
+ import { AddressUtils as N, CommonUtils as P, CoordUtils as he, FormulaError as F, FormulaText as ge, ICellStyle as _e, IColor as ve, ICondition as I, IConditionalFormat as L, IRange as ye, OutOfBoundsError as R, PersonCollection as be, ResourceCollection as xe, Theme as Se, Tuple as Ce, Workbook as we } from "@sheetxl/sdk";
10
+ var Te = {
11
+ ascending: "ascending",
12
+ descending: "descending",
13
+ natural: "dataSource"
14
+ };
15
+ function Ee(e, t) {
16
+ if (!t) return null;
17
+ for (let n = 0; n < e.length; n++) if (e[n].id !== void 0 && String(e[n].id) === t) return e[n];
18
+ let n = Number(t);
19
+ return Number.isInteger(n) && n >= 1 && n <= e.length ? e[n - 1] : null;
20
+ }
21
+ function De(e, t, n) {
22
+ let r = {
23
+ ...t,
24
+ source: n
25
+ };
26
+ if (e.caption !== void 0 && e.caption !== e.sourceName && (r.caption = e.caption), !1 === e.showCaption && (r.hiddenCaption = !0), e.columnCount !== void 0 && e.columnCount > 1 && (r.columnCount = e.columnCount), e.rowHeight !== void 0) {
27
+ let t = Math.round(e.rowHeight / 9525);
28
+ t > 0 && t !== 27 && (r.rowHeight = t);
29
+ }
30
+ e.style && e.style !== "SlicerStyleLight1" && (r.style = e.style);
31
+ let i = e.sortOrder ? Te[e.sortOrder] : void 0;
32
+ return i && i !== "ascending" && (r.sortOrder = i), e.crossFilter && e.crossFilter !== "showItemsWithDataAtTop" && (r.crossFilter = e.crossFilter), e.lockedPosition && (r.lockedPosition = !0), !1 === e.customListSort && (r.disabledCustomListSort = !0), e.cacheName && (r.cacheName = e.cacheName), e.startItem && (r.startItem = e.startItem), e.level !== void 0 && (r.level = e.level), e.uid && (r.uid = e.uid), r;
33
+ }
34
+ var z = (e, t, n) => {
35
+ let r = `Unable to read '${e}': ${t?.message ?? t}`;
36
+ n?.onWarning ? n.onWarning(r, e) : console.warn(r);
37
+ }, Oe = (e, t, n, r, i = null) => {
38
+ if (!e) return null;
39
+ let a = e;
40
+ a.startsWith("/") && (a = a.substring(1));
41
+ let o = i?.parsedRefs?.get(e);
42
+ if (o !== void 0) return o;
43
+ let s = t(a);
44
+ if (!s) return null;
45
+ let c = s.content;
46
+ try {
47
+ let t = new TextDecoder().decode(c), a = n.parseFromString(t, "text/xml"), o = r.transform(a, e, i ?? pe.EmptyObject);
48
+ return i?.parsedRefs?.set(e, o), o;
49
+ } catch (t) {
50
+ z(e, t, i);
51
+ }
52
+ return null;
53
+ }, B = (e, t, n, r, i = null) => {
54
+ if (!e) return null;
55
+ let a = Oe(e, t, n, r, i);
56
+ if (!a) return null;
57
+ let o = /* @__PURE__ */ new Map(), s = Object.keys(a), c = s.length;
58
+ for (let e = 0; e < c; e++) {
59
+ let t = s[e], n = a[t];
60
+ o.set(t, n);
61
+ }
62
+ return o;
63
+ }, V = (e, t, n, r, i, a = null) => {
64
+ let o = /* @__PURE__ */ new Map(), s = t[e], c = s ? s.length : 0;
65
+ for (let e = 0; e < c; e++) {
66
+ let t = s[e];
67
+ if (!t) continue;
68
+ let c = t;
69
+ c.startsWith("/") && (c = c.substring(1));
70
+ let l = Oe(c, n, r, i, a);
71
+ o.set(c, l);
72
+ }
73
+ return o;
74
+ }, ke = (e) => {
75
+ let t = e.split(/\/+/);
76
+ return t.reduce((e, t, n) => (t === "." ? e.splice(n, 1) : t === ".." && e.splice(n - 1, 2), e), t).join("/");
77
+ }, H = Object.freeze([
78
+ "lt1",
79
+ "dk1",
80
+ "lt2",
81
+ "dk2",
82
+ "accent1",
83
+ "accent2",
84
+ "accent3",
85
+ "accent4",
86
+ "accent5",
87
+ "accent6",
88
+ "hlink",
89
+ "folHlink"
90
+ ]), Ae = (e, t = "auto") => {
91
+ let n, r = e("auto");
92
+ r === void 0 || r !== "1" && r !== "true" || (n = t);
93
+ let i = e("indexed");
94
+ i && (n = i === "64" ? "auto" : `index${i}`);
95
+ let a = e("rgb");
96
+ a && (n = a.toLowerCase(), a.length !== 8 || a.startsWith("FF") || (n = "FF" + a.substring(2, a.length)));
97
+ let o = e("theme");
98
+ o && (n = H[Number(o)]);
99
+ let s = e("tint");
100
+ if (s && (n += ` ${ve.AdjustmentType.ETint} ${parseFloat(s)}`), n) return n;
101
+ }, je = (e) => e && e.replace(/^\{([\s\S]+)\}$/, "$1"), U = /* @__PURE__ */ new Uint8Array(), W = class t {
102
+ constructor(e, t, n) {
103
+ this.buffers = /* @__PURE__ */ new Map(), this.zip = e, this.entries = t, this.rawBuffer = n;
104
+ }
105
+ static normalize(e) {
106
+ return e.startsWith("/") ? e.slice(1) : e;
107
+ }
108
+ static async create(n) {
109
+ let r = n instanceof Blob ? U : n instanceof Uint8Array ? n : new Uint8Array(n), i = n instanceof Blob ? new ne(n) : new E(r), a = new e(i), o = /* @__PURE__ */ new Map();
110
+ for (let e of await a.getEntries()) e.directory || o.set(e.filename, e);
111
+ return new t(a, o, r);
112
+ }
113
+ getNames() {
114
+ return [...this.entries.keys()];
115
+ }
116
+ has(e) {
117
+ return this.entries.has(t.normalize(e));
118
+ }
119
+ uncompressedSize(e) {
120
+ return this.entries.get(t.normalize(e))?.uncompressedSize ?? 0;
121
+ }
122
+ async getBuffer(e) {
123
+ let n = t.normalize(e), r = this.buffers.get(n);
124
+ if (r) return r;
125
+ let i = this.entries.get(n);
126
+ if (!i) return null;
127
+ let a = await i.getData(new x());
128
+ return this.buffers.set(n, a), a;
129
+ }
130
+ async prefetch(e) {
131
+ let t = [];
132
+ for (let [n, r] of this.entries) !this.buffers.has(n) && e(n, r) && t.push(r.getData(new x()).then((e) => {
133
+ this.buffers.set(n, e);
134
+ }));
135
+ await Promise.all(t);
136
+ }
137
+ getEntry(e) {
138
+ return this.buffers.get(t.normalize(e)) ?? null;
139
+ }
140
+ async getTextStream(e, n) {
141
+ let r = this.entries.get(t.normalize(e));
142
+ if (!r) return null;
143
+ let i = new TransformStream();
144
+ r.getData(i.writable).catch(() => {});
145
+ let a = i.readable.getReader(), o = new TextDecoder("utf-8");
146
+ return new ReadableStream({ async pull(e) {
147
+ let { value: t, done: r } = await a.read();
148
+ if (r) {
149
+ let t = o.decode();
150
+ t && e.enqueue(t), e.close();
151
+ return;
152
+ }
153
+ n?.(t.byteLength);
154
+ let i = o.decode(t, { stream: !0 });
155
+ i && e.enqueue(i);
156
+ } }).getReader();
157
+ }
158
+ getRawEntry(e) {
159
+ let n = this.entries.get(t.normalize(e));
160
+ if (!n || n.encrypted || n.crc32 === void 0) return null;
161
+ let r = n.offset;
162
+ if (r + 30 > this.rawBuffer.byteLength) return null;
163
+ let i = new DataView(this.rawBuffer.buffer, this.rawBuffer.byteOffset + r, 30);
164
+ if (i.getUint32(0, !0) !== 67324752) return null;
165
+ let a = r + 30 + i.getUint16(26, !0) + i.getUint16(28, !0), o = a + n.compressedSize;
166
+ return o > this.rawBuffer.byteLength ? null : {
167
+ data: this.rawBuffer.subarray(a, o),
168
+ compressionMethod: n.compressionMethod,
169
+ signature: n.crc32
170
+ };
171
+ }
172
+ async close() {
173
+ await this.zip.close();
174
+ }
175
+ }, Me = class {
176
+ constructor(e) {
177
+ this._sink = e, this._samples = [], this._t0 = Ne(), this._tPrev = this._t0, this._heapPrev = Pe();
178
+ }
179
+ mark(e) {
180
+ let t = Ne(), n = Pe(), r = {
181
+ label: e,
182
+ tMs: t - this._t0,
183
+ dtMs: t - this._tPrev,
184
+ heapBytes: n,
185
+ dHeapBytes: n !== void 0 && this._heapPrev !== void 0 ? n - this._heapPrev : void 0,
186
+ rssBytes: Fe()
187
+ };
188
+ this._tPrev = t, this._heapPrev = n, this._samples.push(r), this._sink?.(r);
189
+ }
190
+ samples() {
191
+ return this._samples;
192
+ }
193
+ toTable() {
194
+ return this._samples.map((e) => ({
195
+ phase: e.label,
196
+ tMs: Math.round(e.tMs),
197
+ dtMs: Math.round(e.dtMs),
198
+ heapMB: e.heapBytes === void 0 ? "—" : Ie(e.heapBytes / 1048576),
199
+ dHeapMB: e.dHeapBytes === void 0 ? "—" : Ie(e.dHeapBytes / 1048576),
200
+ rssMB: e.rssBytes === void 0 ? "—" : Ie(e.rssBytes / 1048576)
201
+ }));
202
+ }
203
+ }, Ne = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now();
204
+ function Pe() {
205
+ let e = typeof performance == "object" ? performance.memory : void 0;
206
+ if (e && typeof e.usedJSHeapSize == "number") return e.usedJSHeapSize;
207
+ let t = globalThis.process;
208
+ return typeof t == "object" && typeof t.memoryUsage == "function" ? t.memoryUsage().heapUsed : void 0;
209
+ }
210
+ function Fe() {
211
+ let e = globalThis.process;
212
+ if (typeof e == "object" && typeof e.memoryUsage == "function") return e.memoryUsage().rss;
213
+ }
214
+ function Ie(e) {
215
+ return Math.round(10 * e) / 10;
216
+ }
217
+ var Le = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", Re = `-${Le}.0-9·̀-ͯ‿-⁀`, ze = (RegExp(`^[${Le}]$`, "u"), RegExp(`^[${Re}]$`, "u"), RegExp(`^[${Le}][${Re}]*$`, "u")), Be = (RegExp(`^[${Re}]+$`, "u"), [
218
+ 32,
219
+ 10,
220
+ 13,
221
+ 9
222
+ ]);
223
+ function Ve(e) {
224
+ return e >= 65 && e <= 90 || e >= 97 && e <= 122 || e === 58 || e === 95 || e === 8204 || e === 8205 || e >= 192 && e <= 214 || e >= 216 && e <= 246 || e >= 248 && e <= 767 || e >= 880 && e <= 893 || e >= 895 && e <= 8191 || e >= 8304 && e <= 8591 || e >= 11264 && e <= 12271 || e >= 12289 && e <= 55295 || e >= 63744 && e <= 64975 || e >= 65008 && e <= 65533 || e >= 65536 && e <= 983039;
225
+ }
226
+ var He = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", Ue = `-${He}.0-9·̀-ͯ‿-⁀`;
227
+ RegExp(`^[${He}]$`, "u"), RegExp(`^[${Ue}]$`, "u"), RegExp(`^[${He}][${Ue}]*$`, "u"), RegExp(`^[${Ue}]+$`, "u");
228
+ var We = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", Ge = `-${We}.0-9·̀-ͯ‿-⁀`, Ke = (RegExp(`^[${We}]$`, "u"), RegExp(`^[${Ge}]$`, "u"), RegExp(`^[${We}][${Ge}]*$`, "u"));
229
+ function qe(e) {
230
+ return e >= 65 && e <= 90 || e === 95 || e >= 97 && e <= 122 || e >= 192 && e <= 214 || e >= 216 && e <= 246 || e >= 248 && e <= 767 || e >= 880 && e <= 893 || e >= 895 && e <= 8191 || e >= 8204 && e <= 8205 || e >= 8304 && e <= 8591 || e >= 11264 && e <= 12271 || e >= 12289 && e <= 55295 || e >= 63744 && e <= 64975 || e >= 65008 && e <= 65533 || e >= 65536 && e <= 983039;
231
+ }
232
+ var G = function(e) {
233
+ return e === 32 || e === 10 || e === 13 || e === 9;
234
+ }, Je = function(e) {
235
+ return e >= 32 && e <= 55295 || e === 10 || e === 13 || e === 9 || e >= 57344 && e <= 65533 || e >= 65536 && e <= 1114111;
236
+ }, Ye = Ve, Xe = function(e) {
237
+ return Ve(e) || e >= 48 && e <= 57 || e === 45 || e === 46 || e === 183 || e >= 768 && e <= 879 || e >= 8255 && e <= 8256;
238
+ }, Ze = Be, Qe = ze, $e = function(e) {
239
+ return e >= 1 && e <= 55295 || e >= 57344 && e <= 65533 || e >= 65536 && e <= 1114111;
240
+ }, K = qe, et = function(e) {
241
+ return qe(e) || e === 45 || e === 46 || e >= 48 && e <= 57 || e === 183 || e >= 768 && e <= 879 || e >= 8255 && e <= 8256;
242
+ }, tt = Ke, nt = "http://www.w3.org/XML/1998/namespace", rt = "http://www.w3.org/2000/xmlns/", it = {
243
+ __proto__: null,
244
+ xml: nt,
245
+ xmlns: rt
246
+ }, at = {
247
+ __proto__: null,
248
+ amp: "&",
249
+ gt: ">",
250
+ lt: "<",
251
+ quot: "\"",
252
+ apos: "'"
253
+ }, q = -1, ot = -2, J = 13, st = 33, ct = 10, lt = 60, ut = 61, Y = 62, X = 63, dt = 93, ft = (e) => e === 34 || e === 39, pt = [34, 39], mt = [
254
+ ...pt,
255
+ 91,
256
+ Y
257
+ ], ht = [
258
+ ...pt,
259
+ lt,
260
+ dt
261
+ ], gt = [
262
+ ut,
263
+ X,
264
+ ...Ze
265
+ ], _t = [
266
+ ...Ze,
267
+ Y,
268
+ 38,
269
+ lt
270
+ ];
271
+ function vt(e, t, n) {
272
+ switch (t) {
273
+ case "xml":
274
+ n !== nt && e.fail(`xml prefix must be bound to ${nt}.`);
275
+ break;
276
+ case "xmlns": n !== rt && e.fail(`xmlns prefix must be bound to ${rt}.`);
277
+ }
278
+ switch (n) {
279
+ case rt:
280
+ e.fail(t === "" ? `the default namespace may not be set to ${n}.` : `may not assign a prefix (even "xmlns") to the URI ${rt}.`);
281
+ break;
282
+ case nt: switch (t) {
283
+ case "xml": break;
284
+ case "":
285
+ e.fail(`the default namespace may not be set to ${n}.`);
286
+ break;
287
+ default: e.fail("may not assign the xml namespace to another prefix.");
288
+ }
289
+ }
290
+ }
291
+ var yt, bt = (e) => tt.test(e), xt = (e) => Qe.test(e), St = {
292
+ xmldecl: "xmlDeclHandler",
293
+ text: "textHandler",
294
+ processinginstruction: "piHandler",
295
+ doctype: "doctypeHandler",
296
+ comment: "commentHandler",
297
+ opentagstart: "openTagStartHandler",
298
+ attribute: "attributeHandler",
299
+ opentag: "openTagHandler",
300
+ closetag: "closeTagHandler",
301
+ cdata: "cdataHandler",
302
+ error: "errorHandler",
303
+ end: "endHandler",
304
+ ready: "readyHandler"
305
+ }, Ct = class {
306
+ get closed() {
307
+ return this._closed;
308
+ }
309
+ constructor(e) {
310
+ this.i = 0, this.prevI = 0, this.opt = e ?? {}, this.fragmentOpt = !!this.opt.fragment;
311
+ let t = this.xmlnsOpt = !!this.opt.xmlns;
312
+ if (this.trackPosition = !1 !== this.opt.position, this.fileName = this.opt.fileName, t) {
313
+ this.nameStartCheck = K, this.nameCheck = et, this.isName = bt, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = {
314
+ __proto__: null,
315
+ ...it
316
+ };
317
+ let e = this.opt.additionalNamespaces;
318
+ e != null && (function(e, t) {
319
+ for (let n of Object.keys(t)) vt(e, n, t[n]);
320
+ }(this, e), Object.assign(this.ns, e));
321
+ } else this.nameStartCheck = Ye, this.nameCheck = Xe, this.isName = xt, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
322
+ this.stateTable = [
323
+ this.sBegin,
324
+ this.sBeginWhitespace,
325
+ this.sDoctype,
326
+ this.sDoctypeQuote,
327
+ this.sDTD,
328
+ this.sDTDQuoted,
329
+ this.sDTDOpenWaka,
330
+ this.sDTDOpenWakaBang,
331
+ this.sDTDComment,
332
+ this.sDTDCommentEnding,
333
+ this.sDTDCommentEnded,
334
+ this.sDTDPI,
335
+ this.sDTDPIEnding,
336
+ this.sText,
337
+ this.sEntity,
338
+ this.sOpenWaka,
339
+ this.sOpenWakaBang,
340
+ this.sComment,
341
+ this.sCommentEnding,
342
+ this.sCommentEnded,
343
+ this.sCData,
344
+ this.sCDataEnding,
345
+ this.sCDataEnding2,
346
+ this.sPIFirstChar,
347
+ this.sPIRest,
348
+ this.sPIBody,
349
+ this.sPIEnding,
350
+ this.sXMLDeclNameStart,
351
+ this.sXMLDeclName,
352
+ this.sXMLDeclEq,
353
+ this.sXMLDeclValueStart,
354
+ this.sXMLDeclValue,
355
+ this.sXMLDeclSeparator,
356
+ this.sXMLDeclEnding,
357
+ this.sOpenTag,
358
+ this.sOpenTagSlash,
359
+ this.sAttrib,
360
+ this.sAttribName,
361
+ this.sAttribNameSawWhite,
362
+ this.sAttribValue,
363
+ this.sAttribValueQuoted,
364
+ this.sAttribValueClosed,
365
+ this.sAttribValueUnquoted,
366
+ this.sCloseTag,
367
+ this.sCloseTagSawWhite
368
+ ], this._init();
369
+ }
370
+ _init() {
371
+ this.openWakaBang = "", this.text = "", this.name = "", this.piTarget = "", this.entity = "", this.q = null, this.tags = [], this.tag = null, this.topNS = null, this.chunk = "", this.chunkPosition = 0, this.i = 0, this.prevI = 0, this.carriedFromPrevious = void 0, this.forbiddenState = 0, this.attribList = [];
372
+ let { fragmentOpt: e } = this;
373
+ this.state = e ? J : 0, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = e, this.xmlDeclPossible = !e, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
374
+ let { defaultXMLVersion: t } = this.opt;
375
+ if (t === void 0) {
376
+ if (!0 === this.opt.forceXMLVersion) throw Error("forceXMLVersion set but defaultXMLVersion is not set");
377
+ t = "1.0";
378
+ }
379
+ this.setXMLVersion(t), this.positionAtNewLine = 0, this.doctype = !1, this._closed = !1, this.xmlDecl = {
380
+ version: void 0,
381
+ encoding: void 0,
382
+ standalone: void 0
383
+ }, this.line = 1, this.column = 0, this.ENTITIES = Object.create(at), this.readyHandler?.();
384
+ }
385
+ get position() {
386
+ return this.chunkPosition + this.i;
387
+ }
388
+ get columnIndex() {
389
+ return this.position - this.positionAtNewLine;
390
+ }
391
+ on(e, t) {
392
+ this[St[e]] = t;
393
+ }
394
+ off(e) {
395
+ this[St[e]] = void 0;
396
+ }
397
+ makeError(e) {
398
+ let t = this.fileName ?? "";
399
+ return this.trackPosition && (t.length > 0 && (t += ":"), t += `${this.line}:${this.column}`), t.length > 0 && (t += ": "), Error(t + e);
400
+ }
401
+ fail(e) {
402
+ let t = this.makeError(e), n = this.errorHandler;
403
+ if (n === void 0) throw t;
404
+ return n(t), this;
405
+ }
406
+ write(e) {
407
+ if (this.closed) return this.fail("cannot write after close.");
408
+ let t = !1;
409
+ e === null ? (t = !0, e = "") : typeof e == "object" && (e = e.toString()), this.carriedFromPrevious !== void 0 && (e = `${this.carriedFromPrevious}${e}`, this.carriedFromPrevious = void 0);
410
+ let n = e.length, r = e.charCodeAt(n - 1);
411
+ !t && (r === 13 || r >= 55296 && r <= 56319) && (this.carriedFromPrevious = e[n - 1], n--, e = e.slice(0, n));
412
+ let { stateTable: i } = this;
413
+ for (this.chunk = e, this.i = 0; this.i < n;) i[this.state].call(this);
414
+ return this.chunkPosition += n, t ? this.end() : this;
415
+ }
416
+ close() {
417
+ return this.write(null);
418
+ }
419
+ getCode10() {
420
+ let e = this.chunk, t = this.i;
421
+ if (this.prevI = t, this.i++, t >= e.length) return q;
422
+ let n = e.charCodeAt(t);
423
+ if (this.column++, n < 55296) {
424
+ if (n >= 32 || n === 9) return n;
425
+ switch (n) {
426
+ case ct: return this.line++, this.column = 0, this.positionAtNewLine = this.position, ct;
427
+ case 13: return e.charCodeAt(t + 1) === ct && (this.i = t + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, ot;
428
+ default: return this.fail("disallowed character."), n;
429
+ }
430
+ }
431
+ if (n > 56319) return n >= 57344 && n <= 65533 || this.fail("disallowed character."), n;
432
+ let r = 65536 + 1024 * (n - 55296) + (e.charCodeAt(t + 1) - 56320);
433
+ return this.i = t + 2, r > 1114111 && this.fail("disallowed character."), r;
434
+ }
435
+ getCode11() {
436
+ let { chunk: e, i: t } = this;
437
+ if (this.prevI = t, this.i = t + 1, t >= e.length) return q;
438
+ let n = e.charCodeAt(t);
439
+ if (this.column++, n < 55296) {
440
+ if (n > 31 && n < 127 || n > 159 && n !== 8232 || n === 9) return n;
441
+ switch (n) {
442
+ case ct: return this.line++, this.column = 0, this.positionAtNewLine = this.position, ct;
443
+ case 13: {
444
+ let n = e.charCodeAt(t + 1);
445
+ n !== ct && n !== 133 || (this.i = t + 2);
446
+ }
447
+ case 133:
448
+ case 8232: return this.line++, this.column = 0, this.positionAtNewLine = this.position, ot;
449
+ default: return this.fail("disallowed character."), n;
450
+ }
451
+ }
452
+ if (n > 56319) return n >= 57344 && n <= 65533 || this.fail("disallowed character."), n;
453
+ let r = 65536 + 1024 * (n - 55296) + (e.charCodeAt(t + 1) - 56320);
454
+ return this.i = t + 2, r > 1114111 && this.fail("disallowed character."), r;
455
+ }
456
+ getCodeNorm() {
457
+ let e = this.getCode();
458
+ return e === ot ? ct : e;
459
+ }
460
+ unGet() {
461
+ this.i = this.prevI, this.column--;
462
+ }
463
+ captureTo(e) {
464
+ let { i: t } = this, { chunk: n } = this;
465
+ for (;;) {
466
+ let r = this.getCode(), i = r === ot, a = i ? ct : r;
467
+ if (a === q || e.includes(a)) return this.text += n.slice(t, this.prevI), a;
468
+ i && (this.text += `${n.slice(t, this.prevI)}\n`, t = this.i);
469
+ }
470
+ }
471
+ captureToChar(e) {
472
+ let { i: t } = this, { chunk: n } = this;
473
+ for (;;) {
474
+ let r = this.getCode();
475
+ switch (r) {
476
+ case ot:
477
+ this.text += `${n.slice(t, this.prevI)}\n`, t = this.i, r = ct;
478
+ break;
479
+ case q: return this.text += n.slice(t), !1;
480
+ }
481
+ if (r === e) return this.text += n.slice(t, this.prevI), !0;
482
+ }
483
+ }
484
+ captureNameChars() {
485
+ let { chunk: e, i: t } = this;
486
+ for (;;) {
487
+ let n = this.getCode();
488
+ if (n === q) return this.name += e.slice(t), q;
489
+ if (!Xe(n)) return this.name += e.slice(t, this.prevI), n === ot ? ct : n;
490
+ }
491
+ }
492
+ skipSpaces() {
493
+ for (;;) {
494
+ let e = this.getCodeNorm();
495
+ if (e === q || !G(e)) return e;
496
+ }
497
+ }
498
+ setXMLVersion(e) {
499
+ this.currentXMLVersion = e, e === "1.0" ? (this.isChar = Je, this.getCode = this.getCode10) : (this.isChar = $e, this.getCode = this.getCode11);
500
+ }
501
+ sBegin() {
502
+ this.chunk.charCodeAt(0) === 65279 && (this.i++, this.column++), this.state = 1;
503
+ }
504
+ sBeginWhitespace() {
505
+ let e = this.i, t = this.skipSpaces();
506
+ switch (this.prevI !== e && (this.xmlDeclPossible = !1), t) {
507
+ case lt:
508
+ if (this.state = 15, this.text.length !== 0) throw Error("no-empty text at start");
509
+ break;
510
+ case q: break;
511
+ default: this.unGet(), this.state = J, this.xmlDeclPossible = !1;
512
+ }
513
+ }
514
+ sDoctype() {
515
+ let e = this.captureTo(mt);
516
+ switch (e) {
517
+ case Y:
518
+ this.doctypeHandler?.(this.text), this.text = "", this.state = J, this.doctype = !0;
519
+ break;
520
+ case q: break;
521
+ default: this.text += String.fromCodePoint(e), e === 91 ? this.state = 4 : ft(e) && (this.state = 3, this.q = e);
522
+ }
523
+ }
524
+ sDoctypeQuote() {
525
+ let e = this.q;
526
+ this.captureToChar(e) && (this.text += String.fromCodePoint(e), this.q = null, this.state = 2);
527
+ }
528
+ sDTD() {
529
+ let e = this.captureTo(ht);
530
+ e !== q && (this.text += String.fromCodePoint(e), e === dt ? this.state = 2 : e === lt ? this.state = 6 : ft(e) && (this.state = 5, this.q = e));
531
+ }
532
+ sDTDQuoted() {
533
+ let e = this.q;
534
+ this.captureToChar(e) && (this.text += String.fromCodePoint(e), this.state = 4, this.q = null);
535
+ }
536
+ sDTDOpenWaka() {
537
+ let e = this.getCodeNorm();
538
+ switch (this.text += String.fromCodePoint(e), e) {
539
+ case 33:
540
+ this.state = 7, this.openWakaBang = "";
541
+ break;
542
+ case X:
543
+ this.state = 11;
544
+ break;
545
+ default: this.state = 4;
546
+ }
547
+ }
548
+ sDTDOpenWakaBang() {
549
+ let e = String.fromCodePoint(this.getCodeNorm()), t = this.openWakaBang += e;
550
+ this.text += e, t !== "-" && (this.state = t === "--" ? 8 : 4, this.openWakaBang = "");
551
+ }
552
+ sDTDComment() {
553
+ this.captureToChar(45) && (this.text += "-", this.state = 9);
554
+ }
555
+ sDTDCommentEnding() {
556
+ let e = this.getCodeNorm();
557
+ this.text += String.fromCodePoint(e), this.state = e === 45 ? 10 : 8;
558
+ }
559
+ sDTDCommentEnded() {
560
+ let e = this.getCodeNorm();
561
+ this.text += String.fromCodePoint(e), e === Y ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
562
+ }
563
+ sDTDPI() {
564
+ this.captureToChar(X) && (this.text += "?", this.state = 12);
565
+ }
566
+ sDTDPIEnding() {
567
+ let e = this.getCodeNorm();
568
+ this.text += String.fromCodePoint(e), e === Y && (this.state = 4);
569
+ }
570
+ sText() {
571
+ this.tags.length === 0 ? this.handleTextOutsideRoot() : this.handleTextInRoot();
572
+ }
573
+ sEntity() {
574
+ let { i: e } = this, { chunk: t } = this;
575
+ t: for (;;) switch (this.getCode()) {
576
+ case ot:
577
+ this.entity += `${t.slice(e, this.prevI)}\n`, e = this.i;
578
+ break;
579
+ case 59: {
580
+ let { entityReturnState: n } = this, r = this.entity + t.slice(e, this.prevI), i;
581
+ this.state = n, r === "" ? (this.fail("empty entity name."), i = "&;") : (i = this.parseEntity(r), this.entity = ""), n === J && this.textHandler === void 0 || (this.text += i);
582
+ break t;
583
+ }
584
+ case q:
585
+ this.entity += t.slice(e);
586
+ break t;
587
+ }
588
+ }
589
+ sOpenWaka() {
590
+ let e = this.getCode();
591
+ if (Ye(e)) this.state = 34, this.unGet(), this.xmlDeclPossible = !1;
592
+ else switch (e) {
593
+ case 47:
594
+ this.state = 43, this.xmlDeclPossible = !1;
595
+ break;
596
+ case 33:
597
+ this.state = 16, this.openWakaBang = "", this.xmlDeclPossible = !1;
598
+ break;
599
+ case X:
600
+ this.state = 23;
601
+ break;
602
+ default: this.fail("disallowed character in tag name"), this.state = J, this.xmlDeclPossible = !1;
603
+ }
604
+ }
605
+ sOpenWakaBang() {
606
+ switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
607
+ case "[CDATA[":
608
+ this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = !0), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = !0), this.state = 20, this.openWakaBang = "";
609
+ break;
610
+ case "--":
611
+ this.state = 17, this.openWakaBang = "";
612
+ break;
613
+ case "DOCTYPE":
614
+ this.state = 2, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
615
+ break;
616
+ default: this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
617
+ }
618
+ }
619
+ sComment() {
620
+ this.captureToChar(45) && (this.state = 18);
621
+ }
622
+ sCommentEnding() {
623
+ let e = this.getCodeNorm();
624
+ e === 45 ? (this.state = 19, this.commentHandler?.(this.text), this.text = "") : (this.text += `-${String.fromCodePoint(e)}`, this.state = 17);
625
+ }
626
+ sCommentEnded() {
627
+ let e = this.getCodeNorm();
628
+ e === Y ? this.state = J : (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(e)}`, this.state = 17);
629
+ }
630
+ sCData() {
631
+ this.captureToChar(dt) && (this.state = 21);
632
+ }
633
+ sCDataEnding() {
634
+ let e = this.getCodeNorm();
635
+ e === dt ? this.state = 22 : (this.text += `]${String.fromCodePoint(e)}`, this.state = 20);
636
+ }
637
+ sCDataEnding2() {
638
+ let e = this.getCodeNorm();
639
+ switch (e) {
640
+ case Y:
641
+ this.cdataHandler?.(this.text), this.text = "", this.state = J;
642
+ break;
643
+ case dt:
644
+ this.text += "]";
645
+ break;
646
+ default: this.text += `]]${String.fromCodePoint(e)}`, this.state = 20;
647
+ }
648
+ }
649
+ sPIFirstChar() {
650
+ let e = this.getCodeNorm();
651
+ this.nameStartCheck(e) ? (this.piTarget += String.fromCodePoint(e), this.state = 24) : e === X || G(e) ? (this.fail("processing instruction without a target."), this.state = e === X ? 26 : 25) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(e), this.state = 24);
652
+ }
653
+ sPIRest() {
654
+ let { chunk: e, i: t } = this;
655
+ for (;;) {
656
+ let n = this.getCodeNorm();
657
+ if (n === q) return void (this.piTarget += e.slice(t));
658
+ if (!this.nameCheck(n)) {
659
+ this.piTarget += e.slice(t, this.prevI);
660
+ let r = n === X;
661
+ r || G(n) ? this.piTarget === "xml" ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = r ? st : 27) : this.state = r ? 26 : 25 : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(n));
662
+ break;
663
+ }
664
+ }
665
+ }
666
+ sPIBody() {
667
+ if (this.text.length === 0) {
668
+ let e = this.getCodeNorm();
669
+ e === X ? this.state = 26 : G(e) || (this.text = String.fromCodePoint(e));
670
+ } else this.captureToChar(X) && (this.state = 26);
671
+ }
672
+ sPIEnding() {
673
+ let e = this.getCodeNorm();
674
+ if (e === Y) {
675
+ let { piTarget: e } = this;
676
+ e.toLowerCase() === "xml" && this.fail("the XML declaration must appear at the start of the document."), this.piHandler?.({
677
+ target: e,
678
+ body: this.text
679
+ }), this.piTarget = this.text = "", this.state = J;
680
+ } else e === X ? this.text += "?" : (this.text += `?${String.fromCodePoint(e)}`, this.state = 25);
681
+ this.xmlDeclPossible = !1;
682
+ }
683
+ sXMLDeclNameStart() {
684
+ let e = this.skipSpaces();
685
+ e === X ? this.state = st : e !== q && (this.state = 28, this.name = String.fromCodePoint(e));
686
+ }
687
+ sXMLDeclName() {
688
+ let e = this.captureTo(gt);
689
+ if (e === X) return this.state = st, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
690
+ if (G(e) || e === ut) {
691
+ if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name)) switch (this.name.length) {
692
+ case 0:
693
+ this.fail("did not expect any more name/value pairs.");
694
+ break;
695
+ case 1:
696
+ this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
697
+ break;
698
+ default: this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
699
+ }
700
+ this.state = e === ut ? 30 : 29;
701
+ }
702
+ }
703
+ sXMLDeclEq() {
704
+ let e = this.getCodeNorm();
705
+ if (e === X) return this.state = st, void this.fail("XML declaration is incomplete.");
706
+ G(e) || (e !== ut && this.fail("value required."), this.state = 30);
707
+ }
708
+ sXMLDeclValueStart() {
709
+ let e = this.getCodeNorm();
710
+ if (e === X) return this.state = st, void this.fail("XML declaration is incomplete.");
711
+ G(e) || (ft(e) ? this.q = e : (this.fail("value must be quoted."), this.q = 32), this.state = 31);
712
+ }
713
+ sXMLDeclValue() {
714
+ let e = this.captureTo([this.q, X]);
715
+ if (e === X) return this.state = st, this.text = "", void this.fail("XML declaration is incomplete.");
716
+ if (e === q) return;
717
+ let t = this.text;
718
+ switch (this.text = "", this.name) {
719
+ case "version": {
720
+ this.xmlDeclExpects = ["encoding", "standalone"];
721
+ let e = t;
722
+ this.xmlDecl.version = e, /^1\.[0-9]+$/.test(e) ? this.opt.forceXMLVersion || this.setXMLVersion(e) : this.fail("version number must match /^1\\.[0-9]+$/.");
723
+ break;
724
+ }
725
+ case "encoding":
726
+ /^[A-Za-z][A-Za-z0-9._-]*$/.test(t) || this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."), this.xmlDeclExpects = ["standalone"], this.xmlDecl.encoding = t;
727
+ break;
728
+ case "standalone": t !== "yes" && t !== "no" && this.fail("standalone value must match \"yes\" or \"no\"."), this.xmlDeclExpects = [], this.xmlDecl.standalone = t;
729
+ }
730
+ this.name = "", this.state = 32;
731
+ }
732
+ sXMLDeclSeparator() {
733
+ let e = this.getCodeNorm();
734
+ e === X ? this.state = st : (G(e) || (this.fail("whitespace required."), this.unGet()), this.state = 27);
735
+ }
736
+ sXMLDeclEnding() {
737
+ this.getCodeNorm() === Y ? (this.piTarget === "xml" ? this.name !== "version" && this.xmlDeclExpects.includes("version") && this.fail("XML declaration must contain a version.") : this.fail("processing instructions are not allowed before root."), this.xmlDeclHandler?.(this.xmlDecl), this.name = "", this.piTarget = this.text = "", this.state = J) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = !1;
738
+ }
739
+ sOpenTag() {
740
+ let e = this.captureNameChars();
741
+ if (e === q) return;
742
+ let t = this.tag = {
743
+ name: this.name,
744
+ attributes: Object.create(null)
745
+ };
746
+ switch (this.name = "", this.xmlnsOpt && (this.topNS = t.ns = Object.create(null)), this.openTagStartHandler?.(t), this.sawRoot = !0, !this.fragmentOpt && this.closedRoot && this.fail("documents may contain only one root."), e) {
747
+ case Y:
748
+ this.openTag();
749
+ break;
750
+ case 47:
751
+ this.state = 35;
752
+ break;
753
+ default: G(e) || this.fail("disallowed character in tag name."), this.state = 36;
754
+ }
755
+ }
756
+ sOpenTagSlash() {
757
+ this.getCode() === Y ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
758
+ }
759
+ sAttrib() {
760
+ let e = this.skipSpaces();
761
+ e !== q && (Ye(e) ? (this.unGet(), this.state = 37) : e === Y ? this.openTag() : e === 47 ? this.state = 35 : this.fail("disallowed character in attribute name."));
762
+ }
763
+ sAttribName() {
764
+ let e = this.captureNameChars();
765
+ e === ut ? this.state = 39 : G(e) ? this.state = 38 : e === Y ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : e !== q && this.fail("disallowed character in attribute name.");
766
+ }
767
+ sAttribNameSawWhite() {
768
+ let e = this.skipSpaces();
769
+ switch (e) {
770
+ case q: return;
771
+ case ut:
772
+ this.state = 39;
773
+ break;
774
+ default: this.fail("attribute without value."), this.text = "", this.name = "", e === Y ? this.openTag() : Ye(e) ? (this.unGet(), this.state = 37) : (this.fail("disallowed character in attribute name."), this.state = 36);
775
+ }
776
+ }
777
+ sAttribValue() {
778
+ let e = this.getCodeNorm();
779
+ ft(e) ? (this.q = e, this.state = 40) : G(e) || (this.fail("unquoted attribute value."), this.state = 42, this.unGet());
780
+ }
781
+ sAttribValueQuoted() {
782
+ let { q: e, chunk: t } = this, { i: n } = this;
783
+ for (;;) switch (this.getCode()) {
784
+ case e:
785
+ this.pushAttrib(this.name, this.text + t.slice(n, this.prevI)), this.name = this.text = "", this.q = null, this.state = 41;
786
+ return;
787
+ case 38:
788
+ this.text += t.slice(n, this.prevI), this.state = 14, this.entityReturnState = 40;
789
+ return;
790
+ case ct:
791
+ case ot:
792
+ case 9:
793
+ this.text += `${t.slice(n, this.prevI)} `, n = this.i;
794
+ break;
795
+ case lt:
796
+ this.text += t.slice(n, this.prevI), this.fail("disallowed character.");
797
+ return;
798
+ case q:
799
+ this.text += t.slice(n);
800
+ return;
801
+ }
802
+ }
803
+ sAttribValueClosed() {
804
+ let e = this.getCodeNorm();
805
+ G(e) ? this.state = 36 : e === Y ? this.openTag() : e === 47 ? this.state = 35 : Ye(e) ? (this.fail("no whitespace between attributes."), this.unGet(), this.state = 37) : this.fail("disallowed character in attribute name.");
806
+ }
807
+ sAttribValueUnquoted() {
808
+ let e = this.captureTo(_t);
809
+ switch (e) {
810
+ case 38:
811
+ this.state = 14, this.entityReturnState = 42;
812
+ break;
813
+ case lt:
814
+ this.fail("disallowed character.");
815
+ break;
816
+ case q: break;
817
+ default: this.text.includes("]]>") && this.fail("the string \"]]>\" is disallowed in char data."), this.pushAttrib(this.name, this.text), this.name = this.text = "", e === Y ? this.openTag() : this.state = 36;
818
+ }
819
+ }
820
+ sCloseTag() {
821
+ let e = this.captureNameChars();
822
+ e === Y ? this.closeTag() : G(e) ? this.state = 44 : e !== q && this.fail("disallowed character in closing tag.");
823
+ }
824
+ sCloseTagSawWhite() {
825
+ switch (this.skipSpaces()) {
826
+ case Y:
827
+ this.closeTag();
828
+ break;
829
+ case q: break;
830
+ default: this.fail("disallowed character in closing tag.");
831
+ }
832
+ }
833
+ handleTextInRoot() {
834
+ let { i: e, forbiddenState: t } = this, { chunk: n, textHandler: r } = this;
835
+ t: for (;;) switch (this.getCode()) {
836
+ case lt:
837
+ if (this.state = 15, r !== void 0) {
838
+ let { text: t } = this, i = n.slice(e, this.prevI);
839
+ t.length === 0 ? i.length !== 0 && r(i) : (r(t + i), this.text = "");
840
+ }
841
+ t = 0;
842
+ break t;
843
+ case 38:
844
+ this.state = 14, this.entityReturnState = J, r !== void 0 && (this.text += n.slice(e, this.prevI)), t = 0;
845
+ break t;
846
+ case dt:
847
+ switch (t) {
848
+ case 0:
849
+ t = 1;
850
+ break;
851
+ case 1:
852
+ t = 2;
853
+ break;
854
+ case 2: break;
855
+ default: throw Error("impossible state");
856
+ }
857
+ break;
858
+ case Y:
859
+ t === 2 && this.fail("the string \"]]>\" is disallowed in char data."), t = 0;
860
+ break;
861
+ case ot:
862
+ r !== void 0 && (this.text += `${n.slice(e, this.prevI)}\n`), e = this.i, t = 0;
863
+ break;
864
+ case q:
865
+ r !== void 0 && (this.text += n.slice(e));
866
+ break t;
867
+ default: t = 0;
868
+ }
869
+ this.forbiddenState = t;
870
+ }
871
+ handleTextOutsideRoot() {
872
+ let { i: e } = this, { chunk: t, textHandler: n } = this, r = !1;
873
+ t: for (;;) {
874
+ let i = this.getCode();
875
+ switch (i) {
876
+ case lt:
877
+ if (this.state = 15, n !== void 0) {
878
+ let { text: r } = this, i = t.slice(e, this.prevI);
879
+ r.length === 0 ? i.length !== 0 && n(i) : (n(r + i), this.text = "");
880
+ }
881
+ break t;
882
+ case 38:
883
+ this.state = 14, this.entityReturnState = J, n !== void 0 && (this.text += t.slice(e, this.prevI)), r = !0;
884
+ break t;
885
+ case ot:
886
+ n !== void 0 && (this.text += `${t.slice(e, this.prevI)}\n`), e = this.i;
887
+ break;
888
+ case q:
889
+ n !== void 0 && (this.text += t.slice(e));
890
+ break t;
891
+ default: G(i) || (r = !0);
892
+ }
893
+ }
894
+ r && (this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = !0), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = !0));
895
+ }
896
+ pushAttribNS(e, t) {
897
+ let { prefix: n, local: r } = this.qName(e), i = {
898
+ name: e,
899
+ prefix: n,
900
+ local: r,
901
+ value: t
902
+ };
903
+ if (this.attribList.push(i), this.attributeHandler?.(i), n === "xmlns") {
904
+ let e = t.trim();
905
+ this.currentXMLVersion === "1.0" && e === "" && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[r] = e, vt(this, r, e);
906
+ } else if (e === "xmlns") {
907
+ let e = t.trim();
908
+ this.topNS[""] = e, vt(this, "", e);
909
+ }
910
+ }
911
+ pushAttribPlain(e, t) {
912
+ let n = {
913
+ name: e,
914
+ value: t
915
+ };
916
+ this.attribList.push(n), this.attributeHandler?.(n);
917
+ }
918
+ end() {
919
+ this.sawRoot || this.fail("document must contain a root element.");
920
+ let { tags: e } = this;
921
+ for (; e.length > 0;) {
922
+ let t = e.pop();
923
+ this.fail(`unclosed tag: ${t.name}`);
924
+ }
925
+ this.state !== 0 && this.state !== J && this.fail("unexpected end.");
926
+ let { text: t } = this;
927
+ return t.length !== 0 && (this.textHandler?.(t), this.text = ""), this._closed = !0, this.endHandler?.(), this._init(), this;
928
+ }
929
+ resolve(e) {
930
+ let t = this.topNS[e];
931
+ if (t !== void 0) return t;
932
+ let { tags: n } = this;
933
+ for (let r = n.length - 1; r >= 0; r--) if (t = n[r].ns[e], t !== void 0) return t;
934
+ return t = this.ns[e], t === void 0 ? this.opt.resolvePrefix?.(e) : t;
935
+ }
936
+ qName(e) {
937
+ let t = e.indexOf(":");
938
+ if (t === -1) return {
939
+ prefix: "",
940
+ local: e
941
+ };
942
+ let n = e.slice(t + 1), r = e.slice(0, t);
943
+ return (r === "" || n === "" || n.includes(":")) && this.fail(`malformed name: ${e}.`), {
944
+ prefix: r,
945
+ local: n
946
+ };
947
+ }
948
+ processAttribsNS() {
949
+ let { attribList: e } = this, t = this.tag;
950
+ {
951
+ let { prefix: e, local: n } = this.qName(t.name);
952
+ t.prefix = e, t.local = n;
953
+ let r = t.uri = this.resolve(e) ?? "";
954
+ e !== "" && (e === "xmlns" && this.fail("tags may not have \"xmlns\" as prefix."), r === "" && (this.fail(`unbound namespace prefix: ${JSON.stringify(e)}.`), t.uri = e));
955
+ }
956
+ if (e.length === 0) return;
957
+ let { attributes: n } = t, r = /* @__PURE__ */ new Set();
958
+ for (let t of e) {
959
+ let { name: e, prefix: i, local: a } = t, o, s;
960
+ i === "" ? (o = e === "xmlns" ? rt : "", s = e) : (o = this.resolve(i), o === void 0 && (this.fail(`unbound namespace prefix: ${JSON.stringify(i)}.`), o = i), s = `{${o}}${a}`), r.has(s) && this.fail(`duplicate attribute: ${s}.`), r.add(s), t.uri = o, n[e] = t;
961
+ }
962
+ this.attribList = [];
963
+ }
964
+ processAttribsPlain() {
965
+ let { attribList: e } = this, t = this.tag.attributes;
966
+ for (let { name: n, value: r } of e) t[n] !== void 0 && this.fail(`duplicate attribute: ${n}.`), t[n] = r;
967
+ this.attribList = [];
968
+ }
969
+ openTag() {
970
+ this.processAttribs();
971
+ let { tags: e } = this, t = this.tag;
972
+ t.isSelfClosing = !1, this.openTagHandler?.(t), e.push(t), this.state = J, this.name = "";
973
+ }
974
+ openSelfClosingTag() {
975
+ this.processAttribs();
976
+ let { tags: e } = this, t = this.tag;
977
+ t.isSelfClosing = !0, this.openTagHandler?.(t), this.closeTagHandler?.(t), (this.tag = e[e.length - 1] ?? null) === null && (this.closedRoot = !0), this.state = J, this.name = "";
978
+ }
979
+ closeTag() {
980
+ let { tags: e, name: t } = this;
981
+ if (this.state = J, this.name = "", t === "") return this.fail("weird empty close tag."), void (this.text += "</>");
982
+ let n = this.closeTagHandler, r = e.length;
983
+ for (; r-- > 0;) {
984
+ let r = this.tag = e.pop();
985
+ if (this.topNS = r.ns, n?.(r), r.name === t) break;
986
+ this.fail(`unexpected close tag: ${t}.`);
987
+ }
988
+ r === 0 ? this.closedRoot = !0 : r < 0 && (this.fail(`unmatched closing tag: ${t}.`), this.text += `</${t}>`);
989
+ }
990
+ parseEntity(e) {
991
+ if (e[0] !== "#") {
992
+ let t = this.ENTITIES[e];
993
+ return t === void 0 ? (this.fail(this.isName(e) ? "undefined entity." : "disallowed character in entity name."), `&${e};`) : t;
994
+ }
995
+ let t = NaN;
996
+ return e[1] === "x" && /^#x[0-9a-f]+$/i.test(e) ? t = parseInt(e.slice(2), 16) : /^#[0-9]+$/.test(e) && (t = parseInt(e.slice(1), 10)), this.isChar(t) ? String.fromCodePoint(t) : (this.fail("malformed character entity."), `&${e};`);
997
+ }
998
+ }, wt = /&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, Tt = {
999
+ amp: "&",
1000
+ lt: "<",
1001
+ gt: ">",
1002
+ quot: "\"",
1003
+ apos: "'"
1004
+ }, Et = (e, t) => {
1005
+ let n = Tt[t];
1006
+ if (n !== void 0) return n;
1007
+ let r = t.charCodeAt(1) === 120 ? parseInt(t.slice(2), 16) : parseInt(t.slice(1), 10);
1008
+ return r > 0 && r <= 1114111 ? String.fromCodePoint(r) : e;
1009
+ }, Dt = (e) => {
1010
+ let t = e;
1011
+ return t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, "\n")), t.indexOf("&") !== -1 && (t = t.replace(wt, Et)), t;
1012
+ }, Ot = (e) => {
1013
+ let t = e, n = t.length;
1014
+ for (let e = 0; e < n; e++) {
1015
+ let n = t.charCodeAt(e);
1016
+ if (n === 9 || n === 10 || n === 13) {
1017
+ t = t.replace(/\r\n|[\t\n\r]/g, " ");
1018
+ break;
1019
+ }
1020
+ }
1021
+ return t.indexOf("&") !== -1 && (t = t.replace(wt, Et)), t;
1022
+ }, kt = (e) => e === 32 || e === 9 || e === 10 || e === 13, At = class e {
1023
+ constructor() {
1024
+ this._openTagHandler = void 0, this._closeTagHandler = void 0, this._textHandler = void 0, this._cdataHandler = void 0, this._errorHandler = void 0, this._endHandler = void 0, this._scanners = null, this._carry = "", this._text = "", this._tags = [], this._sawRoot = !1, this._closed = !1;
1025
+ }
1026
+ static {
1027
+ this.NEED_MORE = -1;
1028
+ }
1029
+ static {
1030
+ this.NOT_HANDLED = -2;
1031
+ }
1032
+ static decodeText(e) {
1033
+ return Dt(e);
1034
+ }
1035
+ on(e, t) {
1036
+ switch (e) {
1037
+ case "opentag":
1038
+ this._openTagHandler = t;
1039
+ break;
1040
+ case "closetag":
1041
+ this._closeTagHandler = t;
1042
+ break;
1043
+ case "text":
1044
+ this._textHandler = t;
1045
+ break;
1046
+ case "cdata":
1047
+ this._cdataHandler = t;
1048
+ break;
1049
+ case "error":
1050
+ this._errorHandler = t;
1051
+ break;
1052
+ case "end": this._endHandler = t;
1053
+ }
1054
+ }
1055
+ setElementScanners(e) {
1056
+ if (!e || e.length === 0) return void (this._scanners = null);
1057
+ let t = Array(128);
1058
+ for (let n of e) {
1059
+ let e = n.name.charCodeAt(0);
1060
+ if (!(e < 128) || t[e] !== void 0) throw Error(`Element scanner '${n.name}' needs an ASCII first character no other scanner uses.`);
1061
+ t[e] = n;
1062
+ }
1063
+ this._scanners = t;
1064
+ }
1065
+ fail(e) {
1066
+ let t = Error(e), n = this._errorHandler;
1067
+ if (n === void 0) throw t;
1068
+ n(t);
1069
+ }
1070
+ write(e) {
1071
+ if (this._closed) return this.fail("cannot write after close."), this;
1072
+ let t = e;
1073
+ this._carry.length !== 0 && (t = this._carry + e, this._carry = "");
1074
+ let n = t.length, r = 0;
1075
+ for (; r < n;) {
1076
+ let e = t.indexOf("<", r);
1077
+ if (e === -1) return this._text += t.slice(r), this;
1078
+ e > r && (this._text += t.slice(r, e));
1079
+ let i = this._markup(t, e, n);
1080
+ if (i === -1) return this._carry = t.slice(e), this;
1081
+ r = i;
1082
+ }
1083
+ return this;
1084
+ }
1085
+ close() {
1086
+ this._carry.length !== 0 && (this.fail("unexpected end."), this._carry = ""), this._sawRoot || this.fail("document must contain a root element.");
1087
+ let e = this._tags;
1088
+ for (; e.length > 0;) {
1089
+ let t = e.pop();
1090
+ this.fail(`unclosed tag: ${t.name}`);
1091
+ }
1092
+ return this._flushText(), this._closed = !0, this._endHandler?.(), this;
1093
+ }
1094
+ _flushText() {
1095
+ let e = this._text;
1096
+ if (e.length === 0) return;
1097
+ this._text = "";
1098
+ let t = this._textHandler;
1099
+ t !== void 0 && this._tags.length !== 0 && t(Dt(e));
1100
+ }
1101
+ _markup(t, n, r) {
1102
+ if (n + 1 >= r) return -1;
1103
+ let i = t.charCodeAt(n + 1);
1104
+ if (i === 47) {
1105
+ let e = t.indexOf(">", n + 2);
1106
+ return e === -1 ? -1 : (this._flushText(), this._closeTag(t.slice(n + 2, e).trimEnd()), e + 1);
1107
+ }
1108
+ if (i === 63) {
1109
+ let e = t.indexOf("?>", n + 2);
1110
+ return e === -1 ? -1 : e + 2;
1111
+ }
1112
+ if (i === 33) {
1113
+ if (n + 4 > r) return -1;
1114
+ if (t.charCodeAt(n + 2) === 45 && t.charCodeAt(n + 3) === 45) {
1115
+ let e = t.indexOf("-->", n + 4);
1116
+ return e === -1 ? -1 : e + 3;
1117
+ }
1118
+ if (n + 9 > r) return -1;
1119
+ if (t.startsWith("[CDATA[", n + 2)) {
1120
+ let e = t.indexOf("]]>", n + 9);
1121
+ return e === -1 ? -1 : (this._flushText(), this._cdataHandler?.(t.slice(n + 9, e)), e + 3);
1122
+ }
1123
+ let e = t.indexOf("[", n + 2), i = t.indexOf(">", n + 2);
1124
+ if (i === -1) return -1;
1125
+ if (e !== -1 && e < i) {
1126
+ let n = t.indexOf("]>", e);
1127
+ return n === -1 ? -1 : n + 2;
1128
+ }
1129
+ return i + 1;
1130
+ }
1131
+ let a = this._scanners;
1132
+ if (a !== null) {
1133
+ let o = i < 128 ? a[i] : void 0;
1134
+ if (o !== void 0 && t.startsWith(o.name, n + 1)) {
1135
+ let i = n + 1 + o.name.length;
1136
+ if (i >= r) return -1;
1137
+ let a = t.charCodeAt(i);
1138
+ if (a === 62 || a === 47 || kt(a)) {
1139
+ this._flushText();
1140
+ let i = o.scan(t, n, r);
1141
+ if (i !== e.NOT_HANDLED) {
1142
+ if (i !== e.NEED_MORE) {
1143
+ this._sawRoot = !0;
1144
+ let e = o.openTag;
1145
+ e !== void 0 && this._tags.push(e);
1146
+ }
1147
+ return i;
1148
+ }
1149
+ }
1150
+ }
1151
+ }
1152
+ return this._openTag(t, n, r);
1153
+ }
1154
+ _openTag(e, t, n) {
1155
+ let r = t + 1, i = 0;
1156
+ for (; r < n && (i = e.charCodeAt(r), i !== 62 && i !== 47 && !kt(i));) r++;
1157
+ if (r >= n) return -1;
1158
+ let a = e.slice(t + 1, r), o = {}, s = !1;
1159
+ for (;;) {
1160
+ for (; r < n && kt(i = e.charCodeAt(r));) r++;
1161
+ if (r >= n) return -1;
1162
+ if (i === 62) {
1163
+ r++;
1164
+ break;
1165
+ }
1166
+ if (i === 47) {
1167
+ if (r + 1 >= n) return -1;
1168
+ if (e.charCodeAt(r + 1) !== 62) {
1169
+ this.fail("forward-slash in opening tag not followed by >."), r++;
1170
+ continue;
1171
+ }
1172
+ s = !0, r += 2;
1173
+ break;
1174
+ }
1175
+ let t = r;
1176
+ for (; r < n && (i = e.charCodeAt(r), i !== 61 && i !== 62 && i !== 47 && !kt(i));) r++;
1177
+ if (r >= n) return -1;
1178
+ let a = e.slice(t, r);
1179
+ for (; r < n && kt(i = e.charCodeAt(r));) r++;
1180
+ if (r >= n) return -1;
1181
+ if (i !== 61) {
1182
+ this.fail("attribute without value.");
1183
+ continue;
1184
+ }
1185
+ for (r++; r < n && kt(i = e.charCodeAt(r));) r++;
1186
+ if (r >= n) return -1;
1187
+ if (i !== 34 && i !== 39) {
1188
+ this.fail("unquoted attribute value.");
1189
+ continue;
1190
+ }
1191
+ let c = e.indexOf(i === 34 ? "\"" : "'", r + 1);
1192
+ if (c === -1) return -1;
1193
+ a !== "__proto__" && (o[a] = Ot(e.slice(r + 1, c))), r = c + 1;
1194
+ }
1195
+ this._flushText(), this._sawRoot = !0;
1196
+ let c = {
1197
+ name: a,
1198
+ attributes: o,
1199
+ isSelfClosing: s
1200
+ };
1201
+ return this._openTagHandler?.(c), s ? this._closeTagHandler?.(c) : this._tags.push(c), r;
1202
+ }
1203
+ _closeTag(e) {
1204
+ if (e === "") return void this.fail("weird empty close tag.");
1205
+ let t = this._tags, n = this._closeTagHandler, r = t.length;
1206
+ for (; r-- > 0;) {
1207
+ let r = t.pop();
1208
+ if (n?.(r), r.name === e) return;
1209
+ this.fail(`unexpected close tag: ${e}.`);
1210
+ }
1211
+ this.fail(`unmatched closing tag: ${e}.`);
1212
+ }
1213
+ };
1214
+ (function(e) {
1215
+ e.Events = {
1216
+ XmlDecl: "xmldecl",
1217
+ Text: "text",
1218
+ ProcessingInstruction: "processinginstruction",
1219
+ Doctype: "doctype",
1220
+ Comment: "comment",
1221
+ OpenTagStart: "opentagstart",
1222
+ Attribute: "attribute",
1223
+ OpenTag: "opentag",
1224
+ CloseTag: "closetag",
1225
+ CDdata: "cdata",
1226
+ Error: "error",
1227
+ End: "end",
1228
+ Ready: "ready"
1229
+ }, e.parseStream = async (e, t, n) => {
1230
+ if (n?.lean) return (async (e, t) => {
1231
+ let n = new At(), r;
1232
+ t.elementScanners && n.setElementScanners(t.elementScanners), t.onOpenTag && n.on("opentag", t.onOpenTag), t.onCloseTag && n.on("closetag", t.onCloseTag), t.onText && n.on("text", t.onText), t.onError && n.on("error", t.onError);
1233
+ let i = t.onEnd;
1234
+ for (i && n.on("end", () => {
1235
+ r = i();
1236
+ });;) {
1237
+ let { value: t, done: r } = await e.read();
1238
+ if (r) break;
1239
+ n.write(t);
1240
+ }
1241
+ return n.close(), r;
1242
+ })(e, t);
1243
+ let r = new Ct({
1244
+ position: !1,
1245
+ ...n
1246
+ }), i;
1247
+ t.onOpenTagStart && r.on(yt.Events.OpenTagStart, t.onOpenTagStart), t.onOpenTag && r.on(yt.Events.OpenTag, t.onOpenTag), t.onCloseTag && r.on(yt.Events.CloseTag, t.onCloseTag), t.onAttribute && r.on(yt.Events.Attribute, t.onAttribute), t.onText && r.on(yt.Events.Text, t.onText), t.onError && r.on(yt.Events.Error, t.onError);
1248
+ let a = t.onEnd;
1249
+ for (a && r.on(yt.Events.End, () => {
1250
+ i = a();
1251
+ });;) {
1252
+ let { value: t, done: n } = await e.read();
1253
+ if (n) break;
1254
+ r.write(t);
1255
+ }
1256
+ return r.close(), i;
1257
+ };
1258
+ })(yt ||= {});
1259
+ var Z = (e) => !0 === e || e === "1" || e === "on" || e === "true" || !1 !== e && e !== "0" && e !== "off" && e !== "false" && null, Q = (e) => {
1260
+ let t = parseInt(e);
1261
+ return isNaN(t) ? null : t;
1262
+ }, jt = (e) => {
1263
+ let t = parseFloat(e);
1264
+ return isNaN(t) ? null : t;
1265
+ }, $ = null, Mt = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Nt = (e) => Mt(e).replace(/"/g, "&quot;"), Pt = class {
1266
+ constructor() {
1267
+ this._registeredVisitors = /* @__PURE__ */ new Map();
1268
+ }
1269
+ registerVisitor(e) {
1270
+ this._registeredVisitors.set(e.from, e);
1271
+ }
1272
+ createEventHandler(e, t, n) {
1273
+ let r = this._registeredVisitors, i = [], a = [], o = null, s = null, c = null, l = null, u = [], d = {
1274
+ key: null,
1275
+ source: e,
1276
+ parent: null
1277
+ }, f = null, p = !1, m = null, ee = null, h = null, g = (e, t) => {
1278
+ let n = c.attributes[e];
1279
+ if (t) {
1280
+ if (Array.isArray(t)) {
1281
+ let e = t.length;
1282
+ for (let r = 0; r < e; r++) if (n == null || (n = t[r](n), n == null)) return;
1283
+ } else if (n == null || (n = t(n), n == null)) return;
1284
+ }
1285
+ return n;
1286
+ }, _ = {
1287
+ getSource: () => f?.source ?? null,
1288
+ setSource: (e) => {
1289
+ f.source = e;
1290
+ },
1291
+ setKey: (e) => {
1292
+ f.key = e;
1293
+ },
1294
+ getFrom: () => c,
1295
+ getAttribute: (e, t) => g(e, t) ?? null,
1296
+ hasAttribute: (e) => _.getAttribute(e) !== null,
1297
+ getParent: () => {
1298
+ let e = u[u.length - 2];
1299
+ return e.parent ?? e.source;
1300
+ },
1301
+ getPath: () => {
1302
+ let e = [], t = a.length;
1303
+ for (let n = 0; n < t; n++) e.push(a[n].local);
1304
+ return e.join("\\");
1305
+ },
1306
+ parseAttribute: g,
1307
+ getRawXml: () => h,
1308
+ copyToObject: (e, t, n, r) => {
1309
+ let i = g(r ?? t, n);
1310
+ i !== void 0 && (e[t] = i);
1311
+ },
1312
+ copyTo: (e, t, n) => {
1313
+ let r = g(n ?? e, t);
1314
+ r !== void 0 && (f.source[e] = r);
1315
+ },
1316
+ warn: (e, t) => {
1317
+ n ? n(e, void 0, t?.onceKey) : console.warn(e);
1318
+ }
1319
+ };
1320
+ return {
1321
+ onOpenTag: (e) => {
1322
+ let t = e.name, n = t.indexOf(":");
1323
+ if (n !== -1 && (t = t.slice(n + 1)), m) return m.push(((e) => {
1324
+ let t = e.attributes ?? {}, n = `<${e.name}`;
1325
+ for (let e in t) {
1326
+ let r = t[e];
1327
+ n += ` ${e}="${Nt(typeof r == "string" ? r : r?.value ?? "")}"`;
1328
+ }
1329
+ return n + ">";
1330
+ })(e)), o = {
1331
+ local: t,
1332
+ tag: e,
1333
+ destination: null
1334
+ }, a.push(o), s = t, void (c = e);
1335
+ let h = (i.length > 0 ? i[i.length - 1] : r).get(t);
1336
+ if (o = {
1337
+ local: t,
1338
+ visitor: h,
1339
+ tag: e,
1340
+ destination: null
1341
+ }, p) return a.push(o), s = t, void (c = e);
1342
+ l = o?.visitor ?? null, s = t, c = e;
1343
+ let g = !!h && h.to === null;
1344
+ if (h && !g && h.scope) {
1345
+ let e = h.scope(_);
1346
+ e === null ? g = !0 : e && (i.push(e), o.pushedScope = !0);
1347
+ }
1348
+ h && (a.length === 0 ? (f = d, o.destination = f, o.pushedDestination = !0, u.push(f)) : g ? (f = null, o.destination = null) : h.transparent ? o.destination = f : (f = {
1349
+ key: null,
1350
+ source: {},
1351
+ parent: null
1352
+ }, o.destination = f, o.pushedDestination = !0, u.push(f))), a.push(o), p = g;
1353
+ let v = l?.openTag?.(_);
1354
+ v !== void 0 && (f.parent = v), h?.raw && !g && (m = [], ee = o);
1355
+ },
1356
+ onCloseTag: (e) => {
1357
+ let t = e.name, r = t.indexOf(":");
1358
+ if (r !== -1 && (t = t.slice(r + 1)), t !== s) throw Error(`mismatch open/close tag: '${t}'/'${s}'`);
1359
+ let g = !1;
1360
+ if (m) {
1361
+ if (a[a.length - 1] !== ee) return m.push(`</${e.name}>`), a.pop(), o = a[a.length - 1] ?? null, s = o?.local ?? null, void (c = o?.tag ?? null);
1362
+ h = m.join(""), m = null, ee = null, g = !0;
1363
+ }
1364
+ p || l?.closeTag?.(_), g && (h = null);
1365
+ let v = a.pop() ?? null;
1366
+ o = a[a.length - 1] ?? null, v?.pushedScope && i.pop();
1367
+ let y = v?.destination;
1368
+ if (y && v.pushedDestination) {
1369
+ u.pop(), f = u[u.length - 1] ?? d;
1370
+ let e = v.visitor;
1371
+ e && e.to && y.source !== void 0 && (Array.isArray(e.to) ? f.source.push ? f.source.push(y.source) : n?.(`Unable to parse array for ${e.from} at ${_.getPath()}`) : y.key ? f.source[y.key] = y.source : typeof e.to == "string" && (f.source[e.to] = y.source));
1372
+ } else y || (f = u[u.length - 1] ?? d);
1373
+ s = o?.local ?? null, c = o?.tag ?? null, l = o?.visitor ?? null, p = !o?.destination;
1374
+ },
1375
+ onText: (e) => {
1376
+ m ? m.push(Mt(e)) : l?.text?.(e, _);
1377
+ },
1378
+ onEnd: t
1379
+ };
1380
+ }
1381
+ }, Ft = `IFERROR(${b}(`, It = Ft.toUpperCase(), Lt = re.toUpperCase(), Rt = { kind: "none" }, zt = { kind: "spilled" }, Bt = (e, t) => {
1382
+ if (e.charCodeAt(t) !== 34) return null;
1383
+ let n = "", r = t + 1;
1384
+ for (; r < e.length;) if (e.charCodeAt(r) === 34) {
1385
+ if (e.charCodeAt(r + 1) !== 34) return {
1386
+ value: n,
1387
+ end: r + 1
1388
+ };
1389
+ n += "\"", r += 2;
1390
+ } else n += e[r], r++;
1391
+ return null;
1392
+ }, Vt = (e) => {
1393
+ let t = [], n = 0;
1394
+ for (; n < e.length;) {
1395
+ let r = e.charCodeAt(n);
1396
+ if (r === 34) {
1397
+ let t = Bt(e, n);
1398
+ if (t === null) break;
1399
+ n = t.end;
1400
+ continue;
1401
+ }
1402
+ if (!(r >= 65 && r <= 90 || r >= 97 && r <= 122 || r === 95)) {
1403
+ n++;
1404
+ continue;
1405
+ }
1406
+ let i = n + 1;
1407
+ for (; i < e.length;) {
1408
+ let t = e.charCodeAt(i);
1409
+ if (!(t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 48 && t <= 57 || t === 95 || t === 46)) break;
1410
+ i++;
1411
+ }
1412
+ e.charCodeAt(i) === 40 && t.push(e.slice(n, i).toUpperCase().replace(/^_XLFN\./, "").replace(/^_XLWS\./, "")), n = i;
1413
+ }
1414
+ return t;
1415
+ }, Ht = (e) => {
1416
+ let t = (t) => {
1417
+ if (e) return RegExp(`<(?:[\\w.-]+:)?${t}\\b[^>]*>([^<]*)<`).exec(e)?.[1];
1418
+ }, n = (e) => {
1419
+ let t = parseInt(e ?? "", 10);
1420
+ return isNaN(t) ? 0 : t;
1421
+ };
1422
+ return {
1423
+ c: n(t("col")),
1424
+ r: n(t("row")),
1425
+ x: m(t("colOff") ?? "0") ?? 0,
1426
+ y: m(t("rowOff") ?? "0") ?? 0
1427
+ };
1428
+ }, Ut = "formulaDialect", Wt = (e, t, r, i, a, o, s, l) => {
1429
+ let p = new Pt(), m = l?.get("parseInlineDxf"), ne = l?.get(Ut), b = (e) => ne && e ? ne.readDetached(e) : e, re = new Ce.TransposedBuilder(), x = null;
1430
+ p.registerVisitor({
1431
+ from: "autoFilter",
1432
+ to: "autoTable",
1433
+ openTag: (e) => {
1434
+ let t = e.getAttribute("ref"), n = N.fastStringToRange(t);
1435
+ e.getSource().r = n, e.getSource().v = {};
1436
+ },
1437
+ closeTag: (e) => {
1438
+ let t = e.getSource(), n = t.v, r = n.hiddenButtons;
1439
+ if (Array.isArray(r)) {
1440
+ let e = r.length, i = t.r, a = i.colEnd - i.colStart + 1;
1441
+ e === 0 ? n.hiddenButtons = !1 : e === a && (n.hiddenButtons = !0);
1442
+ }
1443
+ }
1444
+ }), p.registerVisitor({
1445
+ from: "conditionalFormatting",
1446
+ to: {},
1447
+ openTag: (e) => {
1448
+ let t = e.getParent();
1449
+ t.conditionals ||= [];
1450
+ let n = e.getAttribute("sqref");
1451
+ n &&= n.trim().split(/\s+/).join(",");
1452
+ let r = {
1453
+ r: n,
1454
+ conditionals: t.conditionals
1455
+ }, i = e.getAttribute("pivot", Z);
1456
+ i !== null && (r.pivot = i), e.setSource(r);
1457
+ }
1458
+ }), p.registerVisitor({
1459
+ from: "cfRule",
1460
+ to: {},
1461
+ openTag: (e) => {
1462
+ let t = e.getParent();
1463
+ if (!t?.r) return;
1464
+ let n = e.getSource() ?? {};
1465
+ t.pivot !== void 0 && (n.pivot = t.pivot), t.conditionals.push({
1466
+ r: t.r,
1467
+ v: null,
1468
+ rule: n
1469
+ }), e.copyToObject(n, "type", $), e.copyToObject(n, "priority", Q), e.copyToObject(n, "stopIfTrue", Z);
1470
+ let r = e.getAttribute("dxfId", Q);
1471
+ if (r !== null) {
1472
+ let t = i?.get(r);
1473
+ t ||= (o?.(`Unable to load conditional color. Invalid dxfI: '${r}' at '${e.getPath()}'.`), {}), n.style = t;
1474
+ }
1475
+ e.copyToObject(n, "aboveAverage", Z), e.copyToObject(n, "equalAverage", Z), e.copyToObject(n, "stdDev", Q), e.copyToObject(n, "bottom", Z), e.copyToObject(n, "percent", Z), e.copyToObject(n, "rank", Q), e.copyToObject(n, "operator", $), e.copyToObject(n, "text", $), e.copyToObject(n, "timePeriod", $);
1476
+ },
1477
+ closeTag: (e) => {
1478
+ let t = e.getParent();
1479
+ if (!t?.r) return;
1480
+ let n = t.conditionals[t.conditionals.length - 1], r = n?.rule;
1481
+ if (!r) return;
1482
+ let i = {}, a = w(r, o);
1483
+ a && (i.condition = a), r.style && (i.style = r.style), r.scale && (i.scale = r.scale), r.stopIfTrue && (i.stopIfTrue = !0), r.pivot && (i.pivot = !0), n.v = i, n.priority = r.priority, r.x14Id && (n.x14Id = r.x14Id), delete n.rule;
1484
+ }
1485
+ });
1486
+ let ie = (e) => {
1487
+ let t = e.conditions ?? [], n = [];
1488
+ for (let e = 0; e < t.length; e++) {
1489
+ let r = t[e], i = {};
1490
+ r.type && (i.type = r.type), r.value !== void 0 && (i.value = r.value), r.exclusive && (i.exclusive = !0), n.push(i);
1491
+ }
1492
+ return n;
1493
+ };
1494
+ p.registerVisitor({
1495
+ from: "colorScale",
1496
+ to: {},
1497
+ openTag: (e) => {},
1498
+ closeTag: (e) => {
1499
+ let t = e.getSource(), n = t.colors ?? [], r = ie(t);
1500
+ for (let e = 0; e < r.length; e++) r[e].color = n[e];
1501
+ e.getParent().scale = {
1502
+ type: L.ScaleType.ColorScale,
1503
+ stops: r
1504
+ };
1505
+ }
1506
+ }), p.registerVisitor({
1507
+ from: "dataBar",
1508
+ to: {},
1509
+ openTag: (e) => {
1510
+ e.copyTo("maxLength", Q), e.copyTo("minLength", Q), e.copyTo("showValue", Z);
1511
+ },
1512
+ closeTag: (e) => {
1513
+ let t = e.getSource(), n = {
1514
+ type: L.ScaleType.DataBar,
1515
+ stops: ie(t)
1516
+ }, r = t.colors?.[0];
1517
+ r && (n.color = r), t.minLength !== void 0 && (n.minLength = t.minLength), t.maxLength !== void 0 && (n.maxLength = t.maxLength), t.showValue !== void 0 && (n.showValue = t.showValue), e.getParent().scale = n;
1518
+ }
1519
+ }), p.registerVisitor({
1520
+ from: "iconSet",
1521
+ to: {},
1522
+ openTag: (e) => {
1523
+ e.copyTo("iconSet", $), e.copyTo("reverse", Z), e.copyTo("showValue", Z);
1524
+ },
1525
+ closeTag: (e) => {
1526
+ let t = e.getSource(), n = {
1527
+ type: L.ScaleType.IconSet,
1528
+ stops: ie(t)
1529
+ };
1530
+ t.iconSet !== void 0 && (n.iconSet = t.iconSet), t.reverse !== void 0 && (n.reverse = t.reverse), t.showValue !== void 0 && (n.showValue = t.showValue), e.getParent().scale = n;
1531
+ }
1532
+ }), p.registerVisitor({
1533
+ from: "formula",
1534
+ to: {},
1535
+ text: (e, t) => {
1536
+ let n = t.getParent(), r = n.formulas;
1537
+ r || (r = [], n.formulas = r), r.push(b(e));
1538
+ }
1539
+ }), p.registerVisitor({
1540
+ from: "cfvo",
1541
+ to: {},
1542
+ openTag: (e) => {
1543
+ let t = e.getParent();
1544
+ t.conditions ||= [];
1545
+ let n = e.getSource();
1546
+ if (t.conditions.push(n), e.copyTo("type", $), n.type === L.ColorStopType.Formula) {
1547
+ let t = e.getAttribute("val");
1548
+ t != null && (n.value = b(String(t)));
1549
+ } else e.copyTo("value", jt, "val");
1550
+ !1 === e.getAttribute("gte", Z) && (n.exclusive = !0);
1551
+ }
1552
+ }), p.registerVisitor({
1553
+ from: "color",
1554
+ to: {},
1555
+ openTag: (e) => {
1556
+ let t = e.getParent();
1557
+ t.colors ||= [];
1558
+ let n = Ae((t) => e.getAttribute(t));
1559
+ t.colors.push(n);
1560
+ }
1561
+ }), p.registerVisitor({
1562
+ from: "filterColumn",
1563
+ to: {},
1564
+ openTag: (e) => {
1565
+ let t = e.getParent().v, n = parseInt(e.getAttribute("colId")), r = e.getSource();
1566
+ r.index = n;
1567
+ let i = t.filter;
1568
+ i || (i = { conditions: [] }, t.filter = i);
1569
+ let a = i.conditions;
1570
+ if (a || (a = [], i.conditions = a), a.push(r), e.getAttribute("hiddenButton", Z) && t) {
1571
+ let e = t.hiddenButtons;
1572
+ e || (e = [], t.hiddenButtons = e), e.push(n);
1573
+ }
1574
+ if (e.getAttribute("showButton", Z) && t) {
1575
+ let e = t.showButtons;
1576
+ e || (e = [], t.showButtons = e), e.push(n);
1577
+ }
1578
+ return r;
1579
+ }
1580
+ }), p.registerVisitor({
1581
+ from: "colorFilter",
1582
+ openTag: (e) => {
1583
+ let t = e.getParent(), n = {};
1584
+ t.operator = I.BuiltInOperatorNames.Color, t.param = n, e.copyToObject(n, "cellColor", Z), e.copyToObject(n, "styleId", Q, "dxfId");
1585
+ }
1586
+ }), p.registerVisitor({
1587
+ from: "iconFilter",
1588
+ openTag: (e) => {
1589
+ let t = e.getParent(), n = {};
1590
+ t.operator = I.BuiltInOperatorNames.Icon, t.param = n, e.copyToObject(n, "iconId", Q), e.copyToObject(n, "iconSet", $);
1591
+ }
1592
+ }), p.registerVisitor({
1593
+ from: "top10",
1594
+ openTag: (e) => {
1595
+ let t = e.getParent(), n = {};
1596
+ t.operator = I.BuiltInOperatorNames.TopN, t.param = n, e.copyToObject(n, "filterVal", jt), e.copyToObject(n, "percent", Z), e.copyToObject(n, "top", Z), e.copyToObject(n, "limit", jt, "val");
1597
+ }
1598
+ }), p.registerVisitor({
1599
+ from: "dynamicFilter",
1600
+ openTag: (e) => {
1601
+ let t = e.getParent(), n = te(e.getAttribute("type"));
1602
+ t.operator = n.operator, t.param = n.param;
1603
+ }
1604
+ });
1605
+ let ae = {
1606
+ from: "filters",
1607
+ to: {},
1608
+ openTag: (e) => {
1609
+ let t = e.getParent(), n = {};
1610
+ return t.selector = I.BuiltInSelectorNames.Display, t.operator = I.BuiltInOperatorNames.InSet, t.param = n, e.copyToObject(n, "blank", Z), e.copyToObject(n, "calendarType", $), n;
1611
+ }
1612
+ };
1613
+ p.registerVisitor(ae);
1614
+ let C = {
1615
+ from: "filter",
1616
+ openTag: (e) => {
1617
+ let t = e.getParent(), n = t.items;
1618
+ n || (n = [], t.items = n), n.push(e.getAttribute("val", $));
1619
+ }
1620
+ };
1621
+ p.registerVisitor(C);
1622
+ let E = {
1623
+ from: "dateGroupItem",
1624
+ to: {},
1625
+ openTag: (e) => {
1626
+ let t = e.getParent(), n = t.dateGroups;
1627
+ n || (n = [], t.dateGroups = n), n.push(e.getSource()), e.copyTo("group", $, "dateTimeGrouping"), e.copyTo("day", Q), e.copyTo("hour", Q), e.copyTo("minute", Q), e.copyTo("month", Q), e.copyTo("second", Q), e.copyTo("year", Q);
1628
+ }
1629
+ };
1630
+ p.registerVisitor(E);
1631
+ let ce = /* @__PURE__ */ new Map();
1632
+ ce.set("filterColumn", {
1633
+ from: "filterColumn",
1634
+ transparent: !0
1635
+ }), ce.set("filters", ae), ce.set("filter", C), ce.set("dateGroupItem", E), p.registerVisitor({
1636
+ from: "customFilters",
1637
+ openTag: (e) => {
1638
+ let t = e.getParent(), n = e.getAttribute("and"), r = n === "and" || n === "1", i = [];
1639
+ return t.operator = r ? I.BuiltInOperatorNames.And : I.BuiltInOperatorNames.Or, t.param = i, e.setSource(t), i;
1640
+ },
1641
+ closeTag: (e) => {
1642
+ let t = e.getSource(), n = t?.param;
1643
+ if (!t || !n) return;
1644
+ let r = n.length === 1 ? n[0] : u(t);
1645
+ r !== t && (t.operator = r.operator, t.param = r.param);
1646
+ }
1647
+ }), p.registerVisitor({
1648
+ from: "customFilter",
1649
+ openTag: (e) => {
1650
+ let t = e.getParent(), n;
1651
+ Array.isArray(t) ? (n = {}, t.push(n)) : n = t;
1652
+ let r = D({
1653
+ operator: e.getAttribute("operator"),
1654
+ val: e.getAttribute("val")
1655
+ }, (t) => e.warn(t));
1656
+ r && (n.operator = r.operator, n.param = r.param);
1657
+ }
1658
+ }), p.registerVisitor({
1659
+ from: "sortState",
1660
+ to: {},
1661
+ openTag: (e) => {
1662
+ let t = e.getParent(), n = t.v;
1663
+ n && (n.sort = {}, e.setSource(t));
1664
+ }
1665
+ }), p.registerVisitor({
1666
+ from: "sortCondition",
1667
+ to: {},
1668
+ openTag: (e) => {
1669
+ let t = e.getParent(), n = t.v;
1670
+ if (!n) return;
1671
+ let r = n.sort;
1672
+ if (!r) return;
1673
+ let i = r.sorts;
1674
+ i || (i = [], r.sorts = i);
1675
+ let a = e.getAttribute("ref"), o = 0;
1676
+ if (a) {
1677
+ let e = N.fastStringToRange(a, qt).colStart, n = t.r, r = n.colStart;
1678
+ o = n ? e - r : e;
1679
+ }
1680
+ let s = {};
1681
+ e.copyToObject(s, "sortOn", $, "sortBy"), e.copyToObject(s, "dxfId", $, "sortBy"), e.copyToObject(s, "iconSet", $), e.copyToObject(s, "customList", $), s.reverse = e.getAttribute("descending", Z) ?? !1;
1682
+ let c = {
1683
+ index: o,
1684
+ criteria: s
1685
+ };
1686
+ i.push(c);
1687
+ }
1688
+ });
1689
+ let le = (e) => {
1690
+ x = e.getSource(), e.copyTo("topLeft", $, "topLeftCell");
1691
+ let t = A(e.getAttribute("defaultGridColor")), n = e.getAttribute("colorId");
1692
+ n === null || t || (e.getSource().gridLineColor = "index" + parseFloat(n)), e.copyTo("showZeros", Z), e.copyTo("showFormulas", Z), e.copyTo("zoomScale", Q), e.copyTo("showRowHeaders", Z, "showRowColHeaders"), e.copyTo("showColumnHeaders", Z, "showRowColHeaders"), e.copyTo("showRowGridlines", Z, "showGridLines"), e.copyTo("showColumnGridlines", Z, "showGridLines"), e.copyTo("rightToLeft", Z), e.copyTo("showOutlineSymbols", Z);
1693
+ };
1694
+ p.registerVisitor({
1695
+ from: "sheetView",
1696
+ to: "view",
1697
+ openTag: (e) => {
1698
+ le(e);
1699
+ },
1700
+ closeTag: () => {
1701
+ x = null;
1702
+ }
1703
+ }), p.registerVisitor({
1704
+ from: "customSheetViews",
1705
+ to: "customSheetViews",
1706
+ openTag: (e) => {
1707
+ e.setSource([]);
1708
+ }
1709
+ }), p.registerVisitor({
1710
+ from: "customSheetView",
1711
+ to: [],
1712
+ openTag: (e) => {
1713
+ le(e);
1714
+ },
1715
+ closeTag: () => {
1716
+ x = null;
1717
+ }
1718
+ }), p.registerVisitor({
1719
+ from: "selection",
1720
+ to: "selection",
1721
+ openTag: (e) => {
1722
+ if (!x) return;
1723
+ e.copyTo("cell", $, "activeCell"), e.copyTo("rangeIndex", Q, "activeCellId");
1724
+ let t = e.getAttribute("activeCell"), n = e.getAttribute("sqref");
1725
+ n && n !== t && (e.getSource().ranges = n.trim().split(/\s+/));
1726
+ }
1727
+ }), p.registerVisitor({
1728
+ from: "pane",
1729
+ to: null,
1730
+ openTag: (e) => {
1731
+ if (x && e.getAttribute("state") === "frozen") {
1732
+ let t = {};
1733
+ x.freezePanes = t, e.copyToObject(t, "topLeft", $, "topLeftCell");
1734
+ let n = (x.topLeft ? N.fastStringToCell(x.topLeft) : void 0) ?? {
1735
+ colIndex: 0,
1736
+ rowIndex: 0
1737
+ }, r = {
1738
+ colIndex: 0,
1739
+ rowIndex: 0
1740
+ };
1741
+ e.copyToObject(r, "colIndex", Q, "xSplit"), e.copyToObject(r, "rowIndex", Q, "ySplit");
1742
+ let i = {
1743
+ colIndex: n.colIndex + r.colIndex,
1744
+ rowIndex: n.rowIndex + r.rowIndex
1745
+ };
1746
+ t.coords = N.cellToString(i);
1747
+ }
1748
+ }
1749
+ }), p.registerVisitor({
1750
+ from: "sheetPr",
1751
+ transparent: !0,
1752
+ openTag: (t) => {
1753
+ let n = t.getAttribute("codeName");
1754
+ n && (e.codeName = n), !1 === t.getAttribute("enableFormatConditionsCalculation", Z) && (e.conditionalFormatCalculation = !1);
1755
+ }
1756
+ }), p.registerVisitor({
1757
+ from: "tabColor",
1758
+ to: null,
1759
+ openTag: (t) => {
1760
+ let n = Ae((e) => t.getAttribute(e));
1761
+ n && (e.tabColor = n);
1762
+ }
1763
+ }), p.registerVisitor({
1764
+ from: "pageSetUpPr",
1765
+ to: "pageSetUpPr",
1766
+ openTag: (e) => {}
1767
+ }), p.registerVisitor({
1768
+ from: "outlinePr",
1769
+ to: null,
1770
+ openTag: (t) => {
1771
+ let n = (e) => {
1772
+ let n = t.getAttribute(e);
1773
+ return n === "0" || n === "false";
1774
+ }, r = {};
1775
+ n("summaryBelow") && (r.summaryRow = "up"), n("summaryRight") && (r.summaryColumn = "left"), ((e) => {
1776
+ let n = t.getAttribute(e);
1777
+ return n === "1" || n === "true";
1778
+ })("applyStyles") && (r.automaticStyles = !0), Object.keys(r).length > 0 && (e.outline = r);
1779
+ }
1780
+ }), p.registerVisitor({
1781
+ from: "pageMargins",
1782
+ to: "pageMargins",
1783
+ openTag: (e) => {
1784
+ e.copyTo("bottom", jt), e.copyTo("footer", jt), e.copyTo("header", jt), e.copyTo("left", jt), e.copyTo("right", jt), e.copyTo("top", jt), e.copyTo("bottom", jt);
1785
+ }
1786
+ }), p.registerVisitor({
1787
+ from: "pageSetup",
1788
+ to: "pageSetup",
1789
+ openTag: (e) => {
1790
+ e.copyTo("blackAndWhite", Z), e.copyTo("cellComments"), e.copyTo("copies", Q), e.copyTo("draft", Z), e.copyTo("errors"), e.copyTo("firstPageNumber", Q), e.copyTo("fitToHeight", Q), e.copyTo("fitToWidth", Q), e.copyTo("horizontalDpi", Q), e.copyTo("orientation"), e.copyTo("pageOrder"), e.copyTo("paperSize", Q), e.copyTo("scale", Q), e.copyTo("useFirstPageNumber", Z), e.copyTo("usePrinterDefaults", Z), e.copyTo("verticalDpi", Q);
1791
+ }
1792
+ }), p.registerVisitor({
1793
+ from: "printOptions",
1794
+ to: "printOptions",
1795
+ openTag: (e) => {
1796
+ e.copyTo("gridLines", Z), e.copyTo("gridLinesSet", Z), e.copyTo("headings", Z), e.copyTo("horizontalCentered", Z), e.copyTo("verticalCentered", Z);
1797
+ }
1798
+ }), p.registerVisitor({
1799
+ from: "headerFoot",
1800
+ to: "headerFoot",
1801
+ openTag: (e) => {}
1802
+ }), p.registerVisitor({
1803
+ from: "mergeCells",
1804
+ to: "merges",
1805
+ openTag: (e) => {
1806
+ e.setSource([]);
1807
+ }
1808
+ }), p.registerVisitor({
1809
+ from: "dataValidations",
1810
+ to: "validations",
1811
+ openTag: (e) => {
1812
+ e.setSource([]);
1813
+ }
1814
+ });
1815
+ let ue = {
1816
+ from: "dataValidation",
1817
+ to: [],
1818
+ openTag: (e) => {
1819
+ let t = e.getAttribute("sqref");
1820
+ t &&= t.trim().split(/\s+/).join(",");
1821
+ let n = {}, r = {
1822
+ r: t,
1823
+ v: n,
1824
+ rule: {
1825
+ type: e.getAttribute("type") ?? void 0,
1826
+ operator: e.getAttribute("operator") ?? void 0
1827
+ }
1828
+ };
1829
+ !0 === e.getAttribute("showDropDown", Z) && (n.hideDropdown = !0), e.copyToObject(n, "alert", $, "error"), e.copyToObject(n, "alertTitle", $, "errorTitle"), e.copyToObject(n, "showAlertMessage", Z, "showErrorMessage"), n.alertStyle = e.getAttribute("errorStyle") ?? "stop", e.copyToObject(n, "imeMode"), e.copyToObject(n, "prompt"), e.copyToObject(n, "promptTitle"), e.copyToObject(n, "showPromptMessage", Z, "showInputMessage"), e.setSource(r);
1830
+ },
1831
+ closeTag: (e) => {
1832
+ let t = e.getSource();
1833
+ if (!t?.rule) return;
1834
+ let n = v(t.rule, o);
1835
+ n && (e.getAttribute("allowBlank", Z) && (n.includeBlanks = !0), t.v.condition = n), delete t.rule;
1836
+ }
1837
+ };
1838
+ p.registerVisitor(ue), p.registerVisitor({
1839
+ from: "formula1",
1840
+ to: {},
1841
+ text: (e, t) => {
1842
+ let n = t.getParent().rule;
1843
+ n?.type && (n.formula1 = T(b(e), n.type));
1844
+ }
1845
+ }), p.registerVisitor({
1846
+ from: "formula2",
1847
+ to: {},
1848
+ text: (e, t) => {
1849
+ let n = t.getParent().rule;
1850
+ n?.type && (n.formula2 = T(b(e), n.type));
1851
+ }
1852
+ }), p.registerVisitor({
1853
+ from: "picture",
1854
+ to: "picture",
1855
+ openTag: (e) => {
1856
+ let n = e.getAttribute("r:id");
1857
+ if (!n) return void e.warn("A picture names no image; it was not imported.", { onceKey: "xlsx.sheet.picture.noRel" });
1858
+ let r = t(n, "resource");
1859
+ e.getSource().resId = r;
1860
+ }
1861
+ });
1862
+ let de = {
1863
+ from: "slicer",
1864
+ to: {},
1865
+ openTag: (e) => {
1866
+ let n = e.getAttribute("r:id");
1867
+ if (!n) return void e.warn("A slicer names no cache; it was not imported.", { onceKey: "xlsx.sheet.slicer.noRel" });
1868
+ let r = t(n)?.slicers, i = e.getParent();
1869
+ i.slicers ||= {};
1870
+ let a = Object.keys(r);
1871
+ for (let e of a) i.slicers[e] = r[e];
1872
+ }
1873
+ };
1874
+ p.registerVisitor(de);
1875
+ let k = (e, t) => ({
1876
+ from: e,
1877
+ to: {},
1878
+ openTag: (e) => {
1879
+ e.setSource("");
1880
+ },
1881
+ text: (e, t) => {
1882
+ t.setSource((t.getSource() ?? "") + e);
1883
+ },
1884
+ closeTag: (e) => {
1885
+ t(String(e.getSource() ?? ""), e);
1886
+ }
1887
+ }), j = /* @__PURE__ */ new Map();
1888
+ j.set("dataValidations", {
1889
+ from: "dataValidations",
1890
+ to: "validations",
1891
+ openTag: (e) => {
1892
+ let t = e.getParent();
1893
+ e.setSource(t.validations ?? []);
1894
+ },
1895
+ closeTag: (e) => {
1896
+ (e.getSource()?.length ?? 0) === 0 && e.setSource(void 0);
1897
+ }
1898
+ }), j.set("dataValidation", {
1899
+ ...ue,
1900
+ closeTag: (e) => {
1901
+ ue.closeTag(e);
1902
+ let t = e.getSource();
1903
+ t && !t.r && (e.warn("x14 dataValidation with no xm:sqref was dropped."), e.setSource(void 0));
1904
+ }
1905
+ });
1906
+ let fe = (e) => ({
1907
+ from: e,
1908
+ to: {},
1909
+ openTag: (t) => {
1910
+ t.setSource({
1911
+ rule: t.getParent()?.rule,
1912
+ key: e
1913
+ });
1914
+ }
1915
+ });
1916
+ j.set("formula1", fe("formula1")), j.set("formula2", fe("formula2")), j.set("f", k("f", (e, t) => {
1917
+ let n = t.getParent(), r = n?.rule;
1918
+ r && (r[n.key] = T(b(e), r.type));
1919
+ })), j.set("sqref", k("sqref", (e, t) => {
1920
+ let n = t.getParent(), r = e.trim();
1921
+ n && r && (n.r = r.split(/\s+/).join(","));
1922
+ }));
1923
+ let pe = /* @__PURE__ */ new Map(), me = [], P = /* @__PURE__ */ new Map();
1924
+ P.set("conditionalFormattings", {
1925
+ from: "conditionalFormattings",
1926
+ transparent: !0
1927
+ }), P.set("conditionalFormatting", {
1928
+ from: "conditionalFormatting",
1929
+ to: {},
1930
+ openTag: (e) => {
1931
+ e.setSource({ rules: [] });
1932
+ },
1933
+ closeTag: (e) => {
1934
+ let t = e.getSource(), n = t?.rules ?? [];
1935
+ for (let e = 0; e < n.length; e++) {
1936
+ let r = n[e];
1937
+ r.sqref = t.sqref, r.id ? pe.set(r.id, r) : me.push(r);
1938
+ }
1939
+ }
1940
+ }), P.set("cfRule", {
1941
+ from: "cfRule",
1942
+ to: {},
1943
+ openTag: (e) => {
1944
+ e.copyTo("id", $), e.copyTo("type", $), e.copyTo("priority", Q), e.copyTo("stopIfTrue", Z), e.copyTo("operator", $), e.copyTo("text", $), e.copyTo("timePeriod", $), e.copyTo("aboveAverage", Z), e.copyTo("equalAverage", Z), e.copyTo("stdDev", Q), e.copyTo("bottom", Z), e.copyTo("percent", Z), e.copyTo("rank", Q);
1945
+ },
1946
+ closeTag: (e) => {
1947
+ let t = e.getSource();
1948
+ t && e.getParent()?.rules?.push(t);
1949
+ }
1950
+ }), P.set("sqref", k("sqref", (e, t) => {
1951
+ let n = t.getParent(), r = e.trim();
1952
+ n && r && (n.sqref = r);
1953
+ })), P.set("dataBar", {
1954
+ from: "dataBar",
1955
+ to: {},
1956
+ openTag: (e) => {
1957
+ e.copyTo("minLength", Q), e.copyTo("maxLength", Q), e.copyTo("gradient", Z), e.copyTo("border", Z), e.copyTo("direction", $), e.copyTo("axisPosition", $), e.copyTo("negativeBarColorSameAsPositive", Z), e.copyTo("negativeBarBorderColorSameAsPositive", Z);
1958
+ },
1959
+ closeTag: (e) => {
1960
+ e.getParent().dataBar = e.getSource();
1961
+ }
1962
+ }), P.set("iconSet", {
1963
+ from: "iconSet",
1964
+ to: {},
1965
+ openTag: (e) => {
1966
+ e.copyTo("iconSet", $), e.copyTo("custom", Z), e.copyTo("reverse", Z), e.copyTo("showValue", Z);
1967
+ },
1968
+ closeTag: (e) => {
1969
+ e.getParent().iconSet = e.getSource();
1970
+ }
1971
+ });
1972
+ let he = /* @__PURE__ */ new Map();
1973
+ he.set("f", k("f", (e, t) => {
1974
+ let n = t.getParent();
1975
+ if (!n) return;
1976
+ let r = e.trim(), i = Number(r);
1977
+ n.value = r.length > 0 && Number.isFinite(i) ? i : b(e);
1978
+ })), P.set("cfvo", {
1979
+ from: "cfvo",
1980
+ to: {},
1981
+ scope: () => he,
1982
+ openTag: (e) => {
1983
+ let t = e.getParent();
1984
+ t.conditions ||= [];
1985
+ let n = e.getSource();
1986
+ t.conditions.push(n), e.copyTo("type", $), !1 === e.getAttribute("gte", Z) && (n.exclusive = !0);
1987
+ }
1988
+ }), P.set("f", k("f", (e, t) => {
1989
+ let n = t.getParent();
1990
+ n && (n.formulas ??= []).push(b(e));
1991
+ })), P.set("dxf", {
1992
+ from: "dxf",
1993
+ to: {},
1994
+ raw: !0,
1995
+ closeTag: (e) => {
1996
+ if (!m) return;
1997
+ let t = e.getParent();
1998
+ if (!t) return;
1999
+ let n = m(e.getRawXml() ?? "");
2000
+ n && (t.style = n);
2001
+ }
2002
+ });
2003
+ let F = (e) => ({
2004
+ from: e,
2005
+ to: {},
2006
+ openTag: (t) => {
2007
+ let n = Ae((e) => t.getAttribute(e));
2008
+ n && (t.getParent()[e] = n);
2009
+ }
2010
+ });
2011
+ P.set("borderColor", F("borderColor")), P.set("negativeFillColor", F("negativeFillColor")), P.set("negativeBorderColor", F("negativeBorderColor")), P.set("axisColor", F("axisColor")), P.set("cfIcon", {
2012
+ from: "cfIcon",
2013
+ to: {},
2014
+ openTag: (e) => {
2015
+ let t = e.getAttribute("iconSet"), n = e.getAttribute("iconId", Q);
2016
+ if (t === null || n === null) return;
2017
+ let r = e.getParent();
2018
+ r.icons ||= [], r.icons.push({
2019
+ set: t,
2020
+ id: n
2021
+ });
2022
+ }
2023
+ });
2024
+ let ge = /* @__PURE__ */ new Map();
2025
+ ge.set("id", k("id", (e, t) => {
2026
+ let n = t.getParent(), r = e.trim();
2027
+ n && r && (n.x14Id = r);
2028
+ }));
2029
+ let _e = /* @__PURE__ */ new Map();
2030
+ _e.set("slicerList", {
2031
+ from: "slicerList",
2032
+ transparent: !0
2033
+ }), _e.set("slicer", de);
2034
+ let ve = /* @__PURE__ */ new Map([
2035
+ [d(n), j],
2036
+ [d(f), P],
2037
+ [d(M), P],
2038
+ [d(c), ge],
2039
+ [d(ee), _e],
2040
+ [d(g), _e],
2041
+ [d(h), ce]
2042
+ ]), ye = /* @__PURE__ */ new Set();
2043
+ p.registerVisitor({
2044
+ from: "extLst",
2045
+ transparent: !0
2046
+ }), p.registerVisitor({
2047
+ from: "ext",
2048
+ transparent: !0,
2049
+ scope: (e) => {
2050
+ let t = e.getAttribute("uri"), n = d(t), r = ve.get(n);
2051
+ if (r) return r;
2052
+ if (!y.has(n) && !ye.has(n)) {
2053
+ ye.add(n);
2054
+ let r = _[n];
2055
+ e.warn(r ? `Extension content '${r}' (${t}) is not read; it will be lost on resave.` : `Unknown extension content (uri ${t}) is not read; it will be lost on resave.`);
2056
+ }
2057
+ return null;
2058
+ }
2059
+ }), p.registerVisitor({
2060
+ from: "mergeCell",
2061
+ to: [],
2062
+ openTag: (e) => {
2063
+ let t = e.getAttribute("ref");
2064
+ e.setSource(t);
2065
+ }
2066
+ }), p.registerVisitor({
2067
+ from: "hyperlinks",
2068
+ to: "hyperlinks",
2069
+ openTag: (e) => {
2070
+ e.setSource([]);
2071
+ }
2072
+ }), p.registerVisitor({
2073
+ from: "hyperlink",
2074
+ to: [],
2075
+ openTag: (e) => {
2076
+ let n = e.getAttribute("r:id"), r = e.getAttribute("ref");
2077
+ if (!r) return void e.warn("A hyperlink has no ref; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.noRef" });
2078
+ e.setKey(r);
2079
+ let i = n ? t(n) : "";
2080
+ if (typeof i != "string") return void e.warn("A hyperlink has an invalid address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2081
+ i.endsWith("\\") && (i = i.substring(0, i.length - 1));
2082
+ let a = e.getAttribute("location");
2083
+ if (a && (i += "#" + a), !i) return void e.warn("A hyperlink has no address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2084
+ let o, s = e.getAttribute("tooltip");
2085
+ o = s ? {
2086
+ address: i,
2087
+ screenTip: s
2088
+ } : i, e.setSource({
2089
+ r,
2090
+ v: o
2091
+ });
2092
+ }
2093
+ }), p.registerVisitor({
2094
+ from: "drawing",
2095
+ to: "movables",
2096
+ openTag: (e) => {
2097
+ let n = e.getAttribute("r:id");
2098
+ if (!n) return;
2099
+ let r = t(n);
2100
+ r ? e.setSource(r.movables) : e.warn("A drawing part is missing; its shapes were not imported.", { onceKey: "xlsx.sheet.drawing.missing" });
2101
+ }
2102
+ }), p.registerVisitor({
2103
+ from: "legacyDrawing",
2104
+ to: "legacyDrawing",
2105
+ openTag: (e) => {
2106
+ e.setSource(t(e.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2107
+ }
2108
+ }), p.registerVisitor({
2109
+ from: "legacyDrawingHF",
2110
+ to: "legacyDrawingHF",
2111
+ openTag: (e) => {
2112
+ e.setSource(t(e.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2113
+ }
2114
+ });
2115
+ let R = null, be = !1, xe = /* @__PURE__ */ new Map(), Se = {
2116
+ from: "Fallback",
2117
+ to: null
2118
+ }, we = {
2119
+ from: "Choice",
2120
+ transparent: !0
2121
+ };
2122
+ xe.set("Fallback", Se), xe.set("Choice", we), xe.set("control", {
2123
+ from: "control",
2124
+ transparent: !0,
2125
+ openTag: (e) => {
2126
+ let n = e.getAttribute("name"), r = e.getAttribute("r:id"), i = r ? t(r, "formControl") : null;
2127
+ if (!i) return e.warn(`The form control '${n ?? ""}' has no properties and was not read.`, { onceKey: "xlsx.sheet.control.noProperties" }), void (R = null);
2128
+ let a = i.json, o = parseInt(e.getAttribute("shapeId") ?? "", 10);
2129
+ isNaN(o) || (a.shapeId = o);
2130
+ let s = {
2131
+ anchor: {
2132
+ tl: {
2133
+ c: 0,
2134
+ r: 0,
2135
+ x: 0,
2136
+ y: 0
2137
+ },
2138
+ br: {
2139
+ c: 0,
2140
+ r: 0,
2141
+ x: 0,
2142
+ y: 0
2143
+ }
2144
+ },
2145
+ content: {
2146
+ type: i.type,
2147
+ json: a
2148
+ }
2149
+ };
2150
+ n && (s.content.name = n), R = {
2151
+ movable: s,
2152
+ control: a
2153
+ };
2154
+ },
2155
+ closeTag: () => {
2156
+ R &&= (e.movables ||= [], e.movables.push(R.movable), null);
2157
+ }
2158
+ }), xe.set("controlPr", {
2159
+ from: "controlPr",
2160
+ transparent: !0,
2161
+ raw: !0,
2162
+ openTag: (e) => {
2163
+ if (!R) return;
2164
+ let t = e.getFrom().attributes ?? {}, n = {};
2165
+ for (let e in t) {
2166
+ let r = t[e];
2167
+ n[e] = typeof r == "string" ? r : r?.value ?? "";
2168
+ }
2169
+ S(n, R.control);
2170
+ },
2171
+ closeTag: (e) => {
2172
+ if (!R) return;
2173
+ let t = ((e) => {
2174
+ let t = /<(?:[\w.-]+:)?anchor\b([^>]*)>([\s\S]*?)<\/(?:[\w.-]+:)?anchor>/.exec(e);
2175
+ if (!t) return null;
2176
+ let n = t[2], r = (e) => RegExp(`<(?:[\\w.-]+:)?${e}\\b[^>]*>([\\s\\S]*?)<\\/(?:[\\w.-]+:)?${e}>`).exec(n)?.[1], i = t[1], a = /\bmoveWithCells="(?:1|true)"/.test(i), o = /\bsizeWithCells="(?:1|true)"/.test(i);
2177
+ return {
2178
+ anchor: {
2179
+ tl: Ht(r("from")),
2180
+ br: Ht(r("to"))
2181
+ },
2182
+ anchorType: a ? o ? "twoCell" : "oneCell" : "absolute",
2183
+ rest: (e.slice(0, t.index) + e.slice(t.index + t[0].length)).trim()
2184
+ };
2185
+ })(e.getRawXml() ?? "");
2186
+ t ? (R.movable.anchor = t.anchor, t.anchorType !== "twoCell" && (R.movable.anchorType = t.anchorType), t.rest && (R.control.xml = t.rest)) : be || (be = !0, e.warn("A form control has no anchor; it is placed at the top left of the sheet."));
2187
+ }
2188
+ });
2189
+ let Te = {
2190
+ from: "controls",
2191
+ transparent: !0,
2192
+ scope: () => xe
2193
+ };
2194
+ p.registerVisitor(Te);
2195
+ let Ee = /* @__PURE__ */ new Map([
2196
+ ["Choice", we],
2197
+ ["Fallback", Se],
2198
+ ["controls", Te]
2199
+ ]);
2200
+ p.registerVisitor({
2201
+ from: "AlternateContent",
2202
+ transparent: !0,
2203
+ scope: () => Ee
2204
+ }), p.registerVisitor({
2205
+ from: "tableParts",
2206
+ to: "tables",
2207
+ openTag: (e) => {
2208
+ e.setSource([]);
2209
+ }
2210
+ }), p.registerVisitor({
2211
+ from: "tablePart",
2212
+ to: [],
2213
+ openTag: (e) => {
2214
+ let n = e.getAttribute("r:id");
2215
+ if (!n) return;
2216
+ let r = t(n);
2217
+ r ? e.setSource(r) : e.warn("A table part is missing; the table was not imported.", { onceKey: "xlsx.sheet.table.missing" });
2218
+ }
2219
+ });
2220
+ let De = (e, t) => {
2221
+ t.conditions?.length && (e.stops = ie(t)), t.minLength !== void 0 && (e.minLength = t.minLength), t.maxLength !== void 0 && (e.maxLength = t.maxLength), (t.gradient ?? 1) && (e.gradient = !0), t.border && t.borderColor && (e.borderColor = t.borderColor), !t.negativeBarColorSameAsPositive && t.negativeFillColor && (e.negativeFillColor = t.negativeFillColor), !(t.negativeBarBorderColorSameAsPositive ?? 1) && t.negativeBorderColor && (e.negativeBorderColor = t.negativeBorderColor), t.axisColor && (e.axisColor = t.axisColor), t.axisPosition !== "middle" && t.axisPosition !== "none" || (e.axisPosition = t.axisPosition), t.direction !== "leftToRight" && t.direction !== "rightToLeft" || (e.direction = t.direction);
2222
+ }, z = (e, t) => {
2223
+ t.conditions?.length && (e.stops = ie(t)), t.iconSet && t.iconSet !== e.iconSet && (e.iconSet = t.iconSet), t.icons?.length && (e.icon = t.icons), t.reverse !== void 0 && (e.reverse = t.reverse), t.showValue !== void 0 && (e.showValue = t.showValue);
2224
+ }, Oe = (e) => {
2225
+ if (!e.sqref) return null;
2226
+ let t = e.sqref.split(/\s+/).join(",");
2227
+ if (e.type === "iconSet") {
2228
+ if (!e.iconSet) return null;
2229
+ let n = {
2230
+ type: L.ScaleType.IconSet,
2231
+ stops: []
2232
+ };
2233
+ return z(n, e.iconSet), {
2234
+ r: t,
2235
+ v: { scale: n },
2236
+ priority: e.priority
2237
+ };
2238
+ }
2239
+ let n = w(e, o);
2240
+ if (!n) return null;
2241
+ let r = { condition: n };
2242
+ return e.style && (r.style = e.style), e.stopIfTrue && (r.stopIfTrue = !0), {
2243
+ r: t,
2244
+ v: r,
2245
+ priority: e.priority
2246
+ };
2247
+ };
2248
+ p.registerVisitor({
2249
+ from: "worksheet",
2250
+ to: {},
2251
+ openTag: (e) => {},
2252
+ closeTag: (e) => {
2253
+ let t = e.getSource(), n = t?.conditionals;
2254
+ if (n) for (let e = 0; e < n.length; e++) {
2255
+ let t = n[e], r = t.x14Id;
2256
+ if (!r) continue;
2257
+ delete t.x14Id;
2258
+ let i = pe.get(r);
2259
+ if (!i) continue;
2260
+ pe.delete(r);
2261
+ let a = t.v?.scale;
2262
+ i.dataBar && a?.type === L.ScaleType.DataBar ? De(a, i.dataBar) : i.iconSet && a?.type === L.ScaleType.IconSet && z(a, i.iconSet);
2263
+ }
2264
+ let r = [...pe.values(), ...me], i = /* @__PURE__ */ new Set(), a = 0;
2265
+ for (let e = 0; e < r.length; e++) {
2266
+ let o = Oe(r[e]);
2267
+ o ? (n || (n = [], t.conditionals = n), n.push(o)) : (i.add(r[e].type ?? "unknown"), a++);
2268
+ }
2269
+ if (a > 0) {
2270
+ let e = [...i].map((e) => `'${e}'`).join(", ");
2271
+ o?.(a === 1 ? `An x14-only conditional formatting rule (type ${e}) is not read and will be lost on resave.` : `${a} x14-only conditional formatting rules (types ${e}) are not read and will be lost on resave.`);
2272
+ }
2273
+ if (n) {
2274
+ n.length > 1 && n.sort((e, t) => (e.priority ?? 1 / 0) - (t.priority ?? 1 / 0));
2275
+ for (let e = 0; e < n.length; e++) delete n[e].priority;
2276
+ }
2277
+ }
2278
+ }), p.registerVisitor({
2279
+ from: "customProperties",
2280
+ to: "customProperties",
2281
+ openTag: (e) => {
2282
+ e.setSource([]);
2283
+ },
2284
+ closeTag: (e) => {
2285
+ let t = e.getSource();
2286
+ t.length > 0 && (e.getParent().customProperties = t);
2287
+ }
2288
+ }), p.registerVisitor({
2289
+ from: "customPr",
2290
+ to: {},
2291
+ openTag: (e) => {
2292
+ let n = e.getParent();
2293
+ e.copyTo("name");
2294
+ let r = e.getAttribute("r:id");
2295
+ if (!r) return void e.warn("A custom property names no part; it was not imported.", { onceKey: "xlsx.sheet.customProperty.noRel" });
2296
+ let i = t(r, "resource"), a = e.getSource();
2297
+ a.resId = i, n.push(a);
2298
+ }
2299
+ }), p.registerVisitor({
2300
+ from: "sheetProtection",
2301
+ to: "protection",
2302
+ openTag: (e) => {
2303
+ let t = e.getSource();
2304
+ for (let n of O) {
2305
+ let r = e.hasAttribute(n.attribute) ? e.getAttribute(n.attribute) : null;
2306
+ t[n.key] = oe(n, r);
2307
+ }
2308
+ if (t.sheet) return;
2309
+ let n = {};
2310
+ e.copyToObject(n, "hash", $, "hashValue"), e.copyToObject(n, "algorithm", $, "algorithmName"), e.copyToObject(n, "salt", $, "saltValue"), e.copyToObject(n, "spinCount", Q), Object.keys(n).length > 0 && (e.getSource().password = n);
2311
+ }
2312
+ }), p.registerVisitor({
2313
+ from: "protectedRanges",
2314
+ to: "protectedRanges",
2315
+ openTag: (e) => {
2316
+ e.setSource([]);
2317
+ }
2318
+ }), p.registerVisitor({
2319
+ from: "protectedRange",
2320
+ to: [],
2321
+ openTag: (e) => {
2322
+ let t = e.getAttribute("sqref");
2323
+ t &&= t.trim().split(/\s+/).join(",");
2324
+ let n = {}, r = {
2325
+ r: t,
2326
+ v: n
2327
+ };
2328
+ e.copyToObject(n, "name"), e.copyToObject(n, "securityDescriptor");
2329
+ let i = {};
2330
+ e.copyToObject(i, "hash", $, "hashValue"), e.copyToObject(i, "algorithm", $, "algorithmName"), e.copyToObject(i, "salt", $, "saltValue"), e.copyToObject(i, "spinCount", Q), Object.keys(i).length > 0 && (n.password = i), e.setSource(r);
2331
+ },
2332
+ closeTag: (e) => {
2333
+ let t = e.getSource();
2334
+ t?.r && t.v.name || e.setSource(void 0);
2335
+ }
2336
+ }), p.registerVisitor({
2337
+ from: "sheetFormatPr",
2338
+ to: "sheetFormatPr",
2339
+ openTag: (t) => {
2340
+ t.copyToObject(e, "defaultColSize", jt, "defaultColWidth");
2341
+ let n = t.getAttribute("customHeight");
2342
+ n !== "1" && n !== "true" || t.copyToObject(e, "defaultRowSize", jt, "defaultRowHeight");
2343
+ }
2344
+ }), p.registerVisitor({
2345
+ from: "cols",
2346
+ to: "cols",
2347
+ openTag: (e) => {
2348
+ e.setSource([]);
2349
+ }
2350
+ }), p.registerVisitor({
2351
+ from: "col",
2352
+ to: [],
2353
+ openTag: (e) => {
2354
+ let t = e.getSource(), n = e.getAttribute("min"), r = e.getAttribute("max"), i = n === void 0 ? 0 : parseInt(n) - 1, a = r === void 0 ? i : parseInt(r) - 1;
2355
+ t.r = N.runToString(i, a, !0);
2356
+ let o = {};
2357
+ t.v = o, e.copyToObject(o, "sz", jt, "width"), e.copyToObject(o, "csz", Z, "customWidth"), e.copyToObject(o, "h", Z, "hidden"), e.copyToObject(o, "l", Q, "outlineLevel"), e.copyToObject(o, "cl", Z, "collapsed"), e.copyToObject(o, "s", Q, "style");
2358
+ }
2359
+ }), p.registerVisitor({
2360
+ from: "oleObjects",
2361
+ to: null,
2362
+ openTag: (e) => {
2363
+ e.warn("'OLE Objects' are not supported.");
2364
+ }
2365
+ });
2366
+ let B = !1, V = !1, ke = 0, H = "", je = (e) => {
2367
+ let t = e.indexOf(":");
2368
+ return t === -1 ? e : e.slice(t + 1);
2369
+ };
2370
+ return Jt(re, e, p.createEventHandler(e, a, o), o, s, {
2371
+ onOpenTag: (e) => {
2372
+ B = !0;
2373
+ let t = je(e.name);
2374
+ t === "t" || t === "v" ? ke === 0 && (V = !0) : t !== "rPh" && t !== "phoneticPr" || ke++;
2375
+ },
2376
+ onText: (e) => {
2377
+ V && (H += e);
2378
+ },
2379
+ onCloseTag: (e) => {
2380
+ let t = je(e.name);
2381
+ t === "t" || t === "v" ? V = !1 : t !== "rPh" && t !== "phoneticPr" || ke > 0 && ke--;
2382
+ },
2383
+ onEnd: () => {
2384
+ if (!B) return;
2385
+ let e = r(se(H));
2386
+ return B = !1, V = !1, ke = 0, H = "", e;
2387
+ },
2388
+ onError: (e) => {}
2389
+ }, l);
2390
+ }, Gt = class {
2391
+ static {
2392
+ this.Collapsed = 1;
2393
+ }
2394
+ static {
2395
+ this.CustomFormat = 2;
2396
+ }
2397
+ static {
2398
+ this.CustomHeight = 4;
2399
+ }
2400
+ static {
2401
+ this.Hidden = 8;
2402
+ }
2403
+ static {
2404
+ this.Ht = 16;
2405
+ }
2406
+ static {
2407
+ this.OutlineLevel = 32;
2408
+ }
2409
+ static {
2410
+ this.Ph = 64;
2411
+ }
2412
+ static {
2413
+ this.R = 128;
2414
+ }
2415
+ static {
2416
+ this.S = 256;
2417
+ }
2418
+ static {
2419
+ this.Spans = 512;
2420
+ }
2421
+ static {
2422
+ this.ThickBot = 1024;
2423
+ }
2424
+ static {
2425
+ this.ThickTop = 2048;
2426
+ }
2427
+ }, Kt = (e, t, n) => {
2428
+ if (e[0].value[0] === e[1].value[0]) return t;
2429
+ }, qt = {
2430
+ colStart: 0,
2431
+ colEnd: 0,
2432
+ rowStart: 0,
2433
+ rowEnd: 0
2434
+ }, Jt = (e, t, n, r, i, a, o) => {
2435
+ let s = !1, c = !1, l = [], u = !1, d = null, f = null, p = null, m = null, ee = null, h = null, g = o?.get("richData") ?? P.EmptyArray, _ = o?.get("dummyWrapped") ?? null, v = N.normalizeA1ToR1C1, y = he.createConflatingRanges(), te = /* @__PURE__ */ new Map(), ne = [], b = !1, re = !1, x = null, ie = !1, ae = he.createConflatingRanges(), oe = !1, S = -1, C = -1, w = null, se = null, T = null, E = [], D = null, ce = -2, O = 0, le = "", ue = "", de = "", k = "", A = "", j = "", M = "", fe = "", pe = "", me = "", ge = "", _e = "", ve = "", I = "", L = !0, R = null, be = !1, xe = !1, Se = !1, Ce = null, we = 0, Te = (e) => {
2436
+ let r = e.name, p = r.indexOf(":");
2437
+ if (p !== -1 && (r = r.slice(p + 1)), we++, we % 196608 == 0 && i?.(we), se) {
2438
+ let t = e.attributes;
2439
+ switch (r) {
2440
+ case "v":
2441
+ c = !0;
2442
+ break;
2443
+ case "f":
2444
+ switch (u = !0, t.t ?? null) {
2445
+ case null:
2446
+ case "normal": break;
2447
+ case "shared":
2448
+ let e = t.si;
2449
+ f = t.ref, d = e;
2450
+ break;
2451
+ case "array":
2452
+ f = t.ref, x = f;
2453
+ break;
2454
+ case "dataTable": f = t.ref, u = !0;
2455
+ }
2456
+ let e = t.ca;
2457
+ e !== void 0 && (ie = e === "1");
2458
+ break;
2459
+ case "is":
2460
+ oe = !0;
2461
+ return;
2462
+ }
2463
+ oe && !u && a?.onOpenTag?.(e);
2464
+ } else if (s) {
2465
+ if (r === "c") {
2466
+ se = e;
2467
+ let t = e.attributes, n = t.r;
2468
+ C = N.fastStringToCol(n);
2469
+ let r = t.t;
2470
+ r === void 0 ? T = null : (T = r, T === "str" && (oe = !0));
2471
+ let i = t.s;
2472
+ i === void 0 && (Ce !== null || Se) && (i = "0"), i !== void 0 && (i = parseInt(i), R && R.value === i && R.colEnd + 1 === C ? R.colEnd = C : (R = {
2473
+ colStart: C,
2474
+ rowStart: S,
2475
+ colEnd: C,
2476
+ rowEnd: S,
2477
+ value: i
2478
+ }, l.push(R))), x = null, re = !1;
2479
+ let a = t.cm;
2480
+ b = a !== void 0 && ((e) => {
2481
+ let t = o?.get("metadata")?.cells;
2482
+ if (!t) return !1;
2483
+ let n = parseInt(e, 10);
2484
+ return !(!Number.isFinite(n) || n < 1) && !0 === t[n - 1]?.get("XLDAPR")?.fDynamic;
2485
+ })(a);
2486
+ let s = t.vm;
2487
+ if (s !== void 0) {
2488
+ let e = g[parseInt(s) - 1];
2489
+ if (F.isError(e)) {
2490
+ let t = e.getCode();
2491
+ w = {
2492
+ t: "e",
2493
+ v: t
2494
+ }, b && t === F.Code.Spill && (re = !0);
2495
+ }
2496
+ }
2497
+ }
2498
+ } else {
2499
+ if (xe && r === "row") {
2500
+ s = !0;
2501
+ let t = e.attributes.r;
2502
+ if (S = parseInt(t) - 1, O = 0, ue = e.attributes.customHeight, ue !== void 0 && (O |= Gt.CustomHeight), ue !== pe && (L = !0, pe = ue), le = e.attributes.ht, le !== void 0 && (O |= Gt.Ht), le !== fe && (L = !0, fe = le), de = e.attributes.hidden, de !== void 0 && (O |= Gt.Hidden), de !== me && (L = !0, me = de), A = e.attributes.s, A !== void 0 && (O |= Gt.S), A !== _e && (L = !0, _e = A), k = e.attributes.customFormat, k !== void 0 && (O |= Gt.CustomFormat), k !== ge && (L = !0, ge = k), j = e.attributes.outlineLevel, j !== void 0 && (O |= Gt.OutlineLevel), j !== ve && (L = !0, ve = j), M = e.attributes.collapsed, M !== void 0 && (O |= Gt.Collapsed), M !== I && (L = !0, I = M), O !== 0) {
2503
+ if (ce + 1 !== S || L) {
2504
+ let e = ue !== void 0 && (ue === "1" || ue === "true"), t = k !== void 0 && (k === "1" || k === "true");
2505
+ Ce = t && A !== void 0 ? A : null, t && Ce === null && (Ce = "0"), D = {
2506
+ min: S,
2507
+ max: S,
2508
+ value: {
2509
+ sz: le === void 0 ? -1 : parseFloat(le),
2510
+ csz: e,
2511
+ h: de !== void 0 && (de === "1" || de === "true"),
2512
+ s: Ce === null ? void 0 : Ce === "0" ? 0 : parseInt(Ce),
2513
+ l: j === void 0 || j === "0" ? 0 : parseInt(j),
2514
+ cl: M !== void 0 && (M === "1" || M === "true")
2515
+ }
2516
+ }, E.push(D);
2517
+ } else D.max = S;
2518
+ }
2519
+ ce = S, L = !1;
2520
+ return;
2521
+ }
2522
+ if (r === "sheetData" && (xe = !0), !be && r === "sheetData") {
2523
+ be = !0;
2524
+ let e = t.cols, n = e ? e.length : 0;
2525
+ for (let t = 0; !Se && t < n; t++) e[t].v.s && (Se = !0);
2526
+ }
2527
+ n?.onOpenTag?.(e);
2528
+ }
2529
+ }, Ee = (t) => {
2530
+ let r = t.name;
2531
+ if (r === "sheetData" && (xe = !1), !u || r !== "c" && r !== "f" || (d && (m = te.get(d) ?? null), m && (y.append(S, C, m), ie && ae.append(S, C)), x !== null && ne.push([x, b ? re ? "error" : "dynamic" : "fixed"]), u = !1, m = null, d = null, f = null, c = !1, ie = !1, x = null, b = !1, re = !1), se) {
2532
+ let n = r.indexOf(":");
2533
+ if (n !== -1 && (r = r.slice(n + 1)), oe) {
2534
+ if (r === "is" || r === "v") {
2535
+ let t = a?.onEnd?.();
2536
+ t != null && e.pushAt(S, C, "" + t);
2537
+ } else r !== "f" && a?.onCloseTag?.(t);
2538
+ }
2539
+ c &&= !1, r === "c" && (se = null, oe = !1);
2540
+ } else {
2541
+ if (s) return s = !1, void (R = null);
2542
+ n?.onCloseTag?.(t);
2543
+ }
2544
+ }, De = (i) => {
2545
+ let o = i.trim();
2546
+ if (c) {
2547
+ switch (w = null, T) {
2548
+ case null:
2549
+ case "n":
2550
+ w = parseFloat(o);
2551
+ break;
2552
+ case "b":
2553
+ w = o === "1" || o === "true";
2554
+ break;
2555
+ case "s":
2556
+ w = o;
2557
+ break;
2558
+ case "e":
2559
+ if (o === "#VALUE!") {
2560
+ let e = se.attributes.vm;
2561
+ if (e !== void 0) {
2562
+ let t = g[parseInt(e) - 1];
2563
+ if (F.isError(t)) {
2564
+ w = {
2565
+ t: "e",
2566
+ v: t.getCode()
2567
+ };
2568
+ break;
2569
+ }
2570
+ }
2571
+ }
2572
+ let e = F.getBuiltInByLabel(o);
2573
+ e ? w = {
2574
+ t: "e",
2575
+ v: e.getCode()
2576
+ } : (w = o, r?.(`Unknown formula error '${o}' in cell ${N.cellToString({
2577
+ colIndex: C,
2578
+ rowIndex: S
2579
+ })}`));
2580
+ break;
2581
+ case "str":
2582
+ case "inlineStr": oe = !0;
2583
+ }
2584
+ w !== null && e.pushAt(S, C, w);
2585
+ }
2586
+ if (d) {
2587
+ if (ee === d) m = h;
2588
+ else {
2589
+ if (m = te.get(d) ?? null, !m) {
2590
+ let e = [];
2591
+ p = v(o, S, C, e), m = [
2592
+ p,
2593
+ e,
2594
+ o
2595
+ ], te.set(d, m);
2596
+ }
2597
+ ee = d, h = m;
2598
+ }
2599
+ d = null;
2600
+ }
2601
+ if (u) {
2602
+ if (_ !== null) {
2603
+ let e = ((e) => {
2604
+ if (e.length < Ft.length || e.slice(0, Ft.length).toUpperCase() !== It) return Rt;
2605
+ let t = Bt(e, Ft.length);
2606
+ if (t === null || e.charCodeAt(t.end) !== 41 || e.charCodeAt(t.end + 1) !== 44 || e.charCodeAt(e.length - 1) !== 41) return Rt;
2607
+ let n = t.value;
2608
+ return n.toUpperCase() === Lt ? zt : n.length === 0 ? Rt : {
2609
+ kind: "formula",
2610
+ formula: n
2611
+ };
2612
+ })(o);
2613
+ e.kind !== "none" && _.push({
2614
+ sheet: t,
2615
+ rowIndex: S,
2616
+ colIndex: C,
2617
+ formula: e.kind === "formula" ? e.formula : null
2618
+ });
2619
+ }
2620
+ let e = [];
2621
+ p = v(o, S, C, e), m = [
2622
+ p,
2623
+ e,
2624
+ o
2625
+ ];
2626
+ }
2627
+ oe ? a?.onText?.(i) : s || n?.onText?.(o);
2628
+ }, z = {
2629
+ r: void 0,
2630
+ t: void 0,
2631
+ s: void 0,
2632
+ cm: void 0,
2633
+ vm: void 0
2634
+ }, Oe = {
2635
+ name: "c",
2636
+ attributes: z,
2637
+ isSelfClosing: !1
2638
+ }, B = {
2639
+ t: void 0,
2640
+ si: void 0,
2641
+ ref: void 0,
2642
+ ca: void 0
2643
+ }, V = {
2644
+ name: "f",
2645
+ attributes: B,
2646
+ isSelfClosing: !1
2647
+ }, ke = {
2648
+ name: "v",
2649
+ attributes: {},
2650
+ isSelfClosing: !1
2651
+ }, H = {
2652
+ r: void 0,
2653
+ s: void 0,
2654
+ ht: void 0,
2655
+ hidden: void 0,
2656
+ collapsed: void 0,
2657
+ customHeight: void 0,
2658
+ customFormat: void 0,
2659
+ outlineLevel: void 0
2660
+ }, Ae = {
2661
+ name: "row",
2662
+ attributes: H,
2663
+ isSelfClosing: !1
2664
+ }, je = At.NEED_MORE, U = At.NOT_HANDLED, W = At.decodeText, Me = !1, Ne = (e, t, n, r) => {
2665
+ for (;;) {
2666
+ let i = 0;
2667
+ for (; t < n && ((i = e.charCodeAt(t)) === 32 || i === 9 || i === 10 || i === 13);) t++;
2668
+ if (t >= n) return je;
2669
+ if (i === 62) return Me = !1, t + 1;
2670
+ if (i === 47) return t + 1 >= n ? je : e.charCodeAt(t + 1) === 62 ? (Me = !0, t + 2) : U;
2671
+ let a = t;
2672
+ for (; t < n && (i = e.charCodeAt(t)) !== 61;) {
2673
+ if (i === 62 || i === 47 || i === 32 || i === 9 || i === 10 || i === 13) return U;
2674
+ t++;
2675
+ }
2676
+ if (t + 1 >= n) return je;
2677
+ let o = t - a, s = e.charCodeAt(t + 1);
2678
+ if (s !== 34 && s !== 39) return U;
2679
+ let c = t + 2, l = c;
2680
+ for (; l < n && (i = e.charCodeAt(l)) !== s;) {
2681
+ if (i === 38 || i < 32) return U;
2682
+ l++;
2683
+ }
2684
+ if (l >= n) return je;
2685
+ t = l + 1;
2686
+ let u = e.charCodeAt(a);
2687
+ if (r === 2) switch (o) {
2688
+ case 1:
2689
+ u === 114 ? H.r = e.slice(c, l) : u === 115 && (H.s = e.slice(c, l));
2690
+ break;
2691
+ case 2:
2692
+ e.startsWith("ht", a) && (H.ht = e.slice(c, l));
2693
+ break;
2694
+ case 6:
2695
+ e.startsWith("hidden", a) && (H.hidden = e.slice(c, l));
2696
+ break;
2697
+ case 9:
2698
+ e.startsWith("collapsed", a) && (H.collapsed = e.slice(c, l));
2699
+ break;
2700
+ case 12: e.startsWith("customHeight", a) ? H.customHeight = e.slice(c, l) : e.startsWith("customFormat", a) ? H.customFormat = e.slice(c, l) : e.startsWith("outlineLevel", a) && (H.outlineLevel = e.slice(c, l));
2701
+ }
2702
+ else if (r === 0) o === 1 ? u === 114 ? z.r = e.slice(c, l) : u === 116 ? z.t = e.slice(c, l) : u === 115 && (z.s = e.slice(c, l)) : o === 2 && e.charCodeAt(a + 1) === 109 && (u === 99 ? z.cm = e.slice(c, l) : u === 118 && (z.vm = e.slice(c, l)));
2703
+ else if (o === 1) u === 116 && (B.t = e.slice(c, l));
2704
+ else if (o === 2) {
2705
+ let t = e.charCodeAt(a + 1);
2706
+ u === 115 && t === 105 ? B.si = e.slice(c, l) : u === 99 && t === 97 && (B.ca = e.slice(c, l));
2707
+ } else o === 3 && e.startsWith("ref", a) && (B.ref = e.slice(c, l));
2708
+ }
2709
+ }, Pe = (e, t, n) => e.charCodeAt(t + 1) === 47 && e.charCodeAt(t + 2) === n && e.charCodeAt(t + 3) === 62;
2710
+ return {
2711
+ ...n,
2712
+ onEnd: () => {
2713
+ E.length > 0 && (t.rows = N.runsToRefs(E, !1));
2714
+ let r = y.done(Kt), i = r.length;
2715
+ if (i > 0) {
2716
+ let e = Array(i);
2717
+ for (let t = 0; t < i; t++) {
2718
+ let n = r[t], i = N.rangeToString(n), a = n.value[1], o = N.resolveRelativeToA1(a, n.rowStart, n.colStart);
2719
+ e[t] = [i, o];
2720
+ }
2721
+ t.formulas = e;
2722
+ }
2723
+ let a = ae.done(!0), o = a.length;
2724
+ if (o > 0) {
2725
+ let e = Array(o);
2726
+ for (let t = 0; t < o; t++) {
2727
+ let n = a[t], r = N.rangeToString(n);
2728
+ e[t] = r;
2729
+ }
2730
+ t.volatile = e;
2731
+ }
2732
+ ne.length > 0 && (t.formulaArray = [...ne]);
2733
+ let s = l.length;
2734
+ if (s > 0) {
2735
+ l.sort(he.createRangeComparator(ye.Axis.Column));
2736
+ let e = l[0], n = e.colStart, r = e.colEnd, i = e.rowEnd, a = e.value, o = [];
2737
+ o.push(e);
2738
+ let c = null;
2739
+ for (let t = 1; t < s; t++) c = l[t], a !== c.value || n !== c.colStart || r !== c.colEnd || i + 1 !== c.rowEnd ? (o.push(c), e = c, n = e.colStart, r = e.colEnd, i = e.rowEnd, a = e.value) : (i = c.rowEnd, e.rowEnd = i);
2740
+ let u = o.length, d = Array(u);
2741
+ for (let e = 0; e < u; e++) {
2742
+ let t = o[e], n = N.rangeToString(t);
2743
+ d[e] = [n, t.value];
2744
+ }
2745
+ t.directStyles = d;
2746
+ }
2747
+ let c = e.build();
2748
+ c && (t.data = c.tuples), n?.onEnd?.();
2749
+ },
2750
+ onOpenTag: Te,
2751
+ onCloseTag: Ee,
2752
+ onText: De,
2753
+ elementScanners: [{
2754
+ name: "c",
2755
+ scan: (e, t, n) => {
2756
+ if (!s || se !== null) return U;
2757
+ z.r = z.t = z.s = z.cm = z.vm = void 0;
2758
+ let r = Ne(e, t + 2, n, 0);
2759
+ if (r < 0) return r;
2760
+ let i = z.t;
2761
+ if (z.r === void 0 || i === "str" || i === "inlineStr") return U;
2762
+ let a = !1, o = -1, c = -1, l = -1, u = -1, d = r;
2763
+ if (!Me) for (B.t = B.si = B.ref = B.ca = void 0;;) {
2764
+ let t = e.indexOf("<", r);
2765
+ if (t === -1 || t + 3 >= n) return je;
2766
+ for (let n = r; n < t; n++) {
2767
+ let t = e.charCodeAt(n);
2768
+ if (t !== 32 && t !== 9 && t !== 10 && t !== 13) return U;
2769
+ }
2770
+ let i = e.charCodeAt(t + 1), s = e.charCodeAt(t + 2);
2771
+ if (i === 47) {
2772
+ if (!Pe(e, t, 99)) return U;
2773
+ d = t + 4;
2774
+ break;
2775
+ }
2776
+ if (i === 102 && !a && l === -1 && (s === 32 || s === 62 || s === 47)) {
2777
+ if (a = !0, r = Ne(e, t + 2, n, 1), r < 0) return r;
2778
+ if (Me) continue;
2779
+ let i = e.indexOf("<", r);
2780
+ if (i === -1 || i + 3 >= n) return je;
2781
+ if (!Pe(e, i, 102)) return U;
2782
+ o = r, c = i, r = i + 4;
2783
+ } else if (i === 118 && s === 62 && l === -1) {
2784
+ let i = e.indexOf("<", t + 3);
2785
+ if (i === -1 || i + 3 >= n) return je;
2786
+ if (!Pe(e, i, 118)) return U;
2787
+ l = t + 3, u = i, r = i + 4;
2788
+ } else return U;
2789
+ }
2790
+ return Te(Oe), a && (Te(V), c > o && De(W(e.slice(o, c))), Ee(V)), l !== -1 && (Te(ke), u > l && De(W(e.slice(l, u))), Ee(ke)), Ee(Oe), d;
2791
+ }
2792
+ }, {
2793
+ name: "row",
2794
+ openTag: Ae,
2795
+ scan: (e, t, n) => {
2796
+ if (!xe || s || se !== null) return U;
2797
+ H.r = H.s = H.ht = H.hidden = H.collapsed = H.customHeight = H.customFormat = H.outlineLevel = void 0;
2798
+ let r = Ne(e, t + 4, n, 2);
2799
+ return r < 0 ? r : Me || H.r === void 0 ? U : (Te(Ae), r);
2800
+ }
2801
+ }]
2802
+ };
2803
+ }, Yt = "hiddenXfs", Xt = (e) => (Array.isArray(e) ? e[1] : e?.v)?.s, Zt = (e) => {
2804
+ if (!e || e.length === 0) return !1;
2805
+ let t = N.refsToRuns(e, !0), n = 0;
2806
+ for (let e of t) {
2807
+ if (e.min > n || e.value?.s === void 0) return !1;
2808
+ n = Math.max(n, e.max + 1);
2809
+ }
2810
+ return n > le;
2811
+ }, Qt = (e, t) => {
2812
+ e.protection = {
2813
+ ...e.protection,
2814
+ showFormulas: t
2815
+ };
2816
+ }, $t = (e) => {
2817
+ let t = e.indexOf(":");
2818
+ return t === -1 ? e : e.slice(t + 1);
2819
+ }, en = {
2820
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",
2821
+ "application/vnd.ms-excel.sheet.macroEnabled.main+xml": "workbooks",
2822
+ "application/vnd.ms-excel.sheet.binary.macroEnabled.main": "workbooks",
2823
+ "application/vnd.ms-excel.addin.macroEnabled.main+xml": "workbooks",
2824
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": "workbooks",
2825
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": "sheets",
2826
+ "application/vnd.ms-excel.worksheet": "sheets",
2827
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": "charts",
2828
+ "application/vnd.ms-excel.chartsheet": "charts",
2829
+ "application/vnd.ms-excel.macrosheet+xml": "macros",
2830
+ "application/vnd.ms-excel.macrosheet": "macros",
2831
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": "dialogs",
2832
+ "application/vnd.ms-excel.dialogsheet": "dialogs",
2833
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml": "strs",
2834
+ "application/vnd.ms-excel.sharedStrings": "strs",
2835
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": "styles",
2836
+ "application/vnd.ms-excel.styles": "styles",
2837
+ "application/vnd.openxmlformats-package.core-properties+xml": "coreprops",
2838
+ "application/vnd.openxmlformats-officedocument.custom-properties+xml": "custprops",
2839
+ "application/vnd.openxmlformats-officedocument.extended-properties+xml": "extprops",
2840
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": "comments",
2841
+ "application/vnd.ms-excel.comments": "comments",
2842
+ "application/vnd.ms-excel.threadedcomments+xml": "threadedcomments",
2843
+ "application/vnd.ms-excel.person+xml": "people",
2844
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml": "metadata",
2845
+ "application/vnd.ms-excel.sheetMetadata": "metadata",
2846
+ "application/vnd.ms-excel.externalLink": "links",
2847
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml": "links",
2848
+ "application/vnd.openxmlformats-officedocument.theme+xml": "themes"
2849
+ }, tn = C({ readXLSX: () => on }), nn = (e) => e.startsWith("/") ? e.slice(1) : e, rn = /^xl\/(worksheets|chartsheets)\/[^/]+\.xml$/i, an = (e) => typeof e == "string" ? e : (e?.runs ?? []).map((e) => e.text ?? "").join(""), on = async (e, n) => {
2850
+ let { password: c, onVBA: u, profile: d, calcOnLoad: f = "auto", createWorkbookOptions: m = {}, ...ee } = n ?? {}, h = !!m.origin && typeof m.origin != "string", g = d ? new Me(typeof d == "function" ? d : void 0) : null, _ = [], v = (e, t, n) => {
2851
+ _.push([
2852
+ e,
2853
+ t ?? "",
2854
+ n
2855
+ ]);
2856
+ }, y = { onWarning: v }, te = n?.progress, ne = te?.onProgress ? te.onProgress.bind(te) : void 0, b = e.byteLength, re = 0, x = 0, oe = ne ? (e) => {
2857
+ if (re <= 0) return;
2858
+ x += e;
2859
+ let t = Math.min(b, Math.round(x / re * b));
2860
+ ne(t, b);
2861
+ } : void 0, S = import("./NQIuOQIleHC4NUW6.mjs"), C = null;
2862
+ try {
2863
+ C = new DOMParser();
2864
+ } catch {}
2865
+ let w = null;
2866
+ try {
2867
+ w = new XMLSerializer();
2868
+ } catch {}
2869
+ let T, E, D, O = null;
2870
+ C || (O = import("./2EOdn2WRK5y1L58S.mjs").then((e) => ce(e.default, 1)));
2871
+ try {
2872
+ let [e, t] = await Promise.all([O, S]);
2873
+ T = new t.DOMTransformer(), E = C ?? new e.DOMParser(), D = w ?? new e.XMLSerializer();
2874
+ } catch (e) {
2875
+ throw Error("Unable to load XLSX parser.", { cause: e });
2876
+ }
2877
+ let le = (e) => D.serializeToString(e), A;
2878
+ try {
2879
+ A = await W.create(e);
2880
+ } catch (e) {
2881
+ throw new me("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.", { cause: e });
2882
+ }
2883
+ g?.mark("zip-open");
2884
+ try {
2885
+ if (!A.has("[Content_Types].xml")) throw new me("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
2886
+ let e = (e) => {
2887
+ let t = A.getEntry(e);
2888
+ return t ? { content: t } : void 0;
2889
+ }, n = {
2890
+ workbooks: [],
2891
+ sheets: [],
2892
+ charts: [],
2893
+ dialogs: [],
2894
+ macros: [],
2895
+ strs: [],
2896
+ comments: [],
2897
+ threadedcomments: [],
2898
+ links: [],
2899
+ coreprops: [],
2900
+ extprops: [],
2901
+ custprops: [],
2902
+ themes: [],
2903
+ styles: [],
2904
+ metadata: [],
2905
+ people: [],
2906
+ overrides: {},
2907
+ sst: "",
2908
+ style: "",
2909
+ defaults: {}
2910
+ };
2911
+ {
2912
+ let e = ((e, t) => ({
2913
+ onOpenTag: (t) => {
2914
+ let n = ((e) => {
2915
+ let t = e.indexOf(":");
2916
+ return t === -1 ? e : e.slice(t + 1);
2917
+ })(t.name), r = t.attributes;
2918
+ if (n === "Override") {
2919
+ let t = r.ContentType, n = r.PartName;
2920
+ if (!t || !n) return;
2921
+ e.overrides[n.startsWith("/") ? n.slice(1) : n] = t;
2922
+ let i = en[t], a = i ? e[i] : void 0;
2923
+ Array.isArray(a) && a.push(n);
2924
+ } else if (n === "Default") {
2925
+ let t = r.Extension, n = r.ContentType;
2926
+ t && (e.defaults[t.toLowerCase()] = n);
2927
+ }
2928
+ },
2929
+ onEnd: () => {
2930
+ e.sst = e.strs.length > 0 ? e.strs[0] : "", e.style = e.styles.length > 0 ? e.styles[0] : "";
2931
+ },
2932
+ onError: (e) => {
2933
+ t?.(`Error parsing content types: ${e?.message ?? e}`);
2934
+ }
2935
+ }))(n, (e) => {
2936
+ _.push([e, "[Content_Types].xml"]);
2937
+ }), t = await A.getTextStream("[Content_Types].xml");
2938
+ if (!t) throw Error("Error parsing content types: '[Content_Types].xml'");
2939
+ try {
2940
+ await yt.parseStream(t, e, { xmlns: !1 });
2941
+ } catch (e) {
2942
+ throw Error("Error parsing content types: '[Content_Types].xml'", { cause: e });
2943
+ }
2944
+ h && await A.getBuffer("[Content_Types].xml");
2945
+ }
2946
+ g?.mark("content-types");
2947
+ let c = n.sst, ee = /* @__PURE__ */ new Set();
2948
+ for (let e of n.sheets) ee.add(nn(e));
2949
+ c && ee.add(nn(c));
2950
+ for (let e of ee) re += A.uncompressedSize(e);
2951
+ if (await A.prefetch((e) => !ee.has(e) && !rn.test(e)), g?.mark("prefetch-side-parts"), n.workbooks.length === 0) {
2952
+ let t = B("_rels/.rels", e, E, T, y);
2953
+ if (t) {
2954
+ for (let e of t.values()) if (e.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" && e.target) {
2955
+ n.workbooks.push(e.target);
2956
+ break;
2957
+ }
2958
+ }
2959
+ }
2960
+ if (n.workbooks.length === 0) throw new me("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
2961
+ n.richstructure = ["/xl/richData/rdrichvaluestructure.xml"], n.richdata = ["/xl/richData/rdrichvalue.xml"];
2962
+ let x = m?.resources ?? new xe(), S = x.beginPersist(), C = {}, w = /* @__PURE__ */ new Set(), D = /* @__PURE__ */ new Map();
2963
+ D.set("richTypes", []), D.set("parseInlineDxf", (e) => {
2964
+ if (!e) return;
2965
+ let t = E.parseFromString(`<dxf xmlns:x14="${s}" xmlns:xm="${o}">${e}</dxf>`, "text/xml")?.documentElement;
2966
+ if (!t) return;
2967
+ let n = T.parseDxf(t, "", y);
2968
+ return Object.keys(n).length > 0 ? n : void 0;
2969
+ });
2970
+ let ce = [];
2971
+ D.set("dummyWrapped", ce);
2972
+ let O = V("metadata", n, e, E, T, y).entries().next()?.value?.[1]?.metadata;
2973
+ O && D.set("metadata", O), D.set(Ut, ie());
2974
+ let M = /* @__PURE__ */ new Map(), P = [], he = /* @__PURE__ */ new Set(), F = (e) => {
2975
+ he.add(nn(e));
2976
+ }, ve = (t, n = M) => {
2977
+ let r = t.lastIndexOf("/"), i = t.substring(0, r + 1) + "_rels/" + t.substring(r + 1, t.length) + ".rels", a = n.get(i);
2978
+ return a || (a = B(i, e, E, T, W), n.set(i, a)), a;
2979
+ }, I = (t, n, r, i = M) => {
2980
+ let a = ve(n, i).get(t), o = a?.target;
2981
+ if (!o) return null;
2982
+ if (a.targetMode === "External") {
2983
+ if (!r) return a.target;
2984
+ let e = x.add({ source: { external: a.target } });
2985
+ return e.addReference(C), w.add(e), S.toResourceId(e);
2986
+ }
2987
+ let s = n.lastIndexOf("/"), c = n.substring(0, s + 1);
2988
+ o.startsWith("/") || (o = c + o), o = ke(o);
2989
+ let u = T?.getVisitorParamsState().get("dxfs"), d = i.get(o);
2990
+ if (!d) {
2991
+ if (a.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") {
2992
+ let e = {};
2993
+ d = e, P.push((async () => {
2994
+ let t = Wt(e, (e, t) => t === "legacyDrawing" ? R(e, o) : t === "formControl" ? Ce(e, o) : t === "part" ? Te(e, o) : I(e, o, t === "resource") ?? null, Ie, u, () => {}, (e, t, n) => {
2995
+ v(e, t ? `${t} (${o})` : o, n);
2996
+ }, void 0, D), n = await A.getTextStream(o, oe);
2997
+ if (n) try {
2998
+ await yt.parseStream(n, t, {
2999
+ xmlns: !1,
3000
+ lean: !0
3001
+ });
3002
+ } catch (e) {
3003
+ throw Error(`Error parsing sheet: '${o}'`, { cause: e });
3004
+ }
3005
+ let r = ve(o, i);
3006
+ if (r) {
3007
+ ye(e, o, r, i), ue(e), ae(e);
3008
+ let t = [];
3009
+ r.forEach((e, n) => {
3010
+ if (e.type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable") return;
3011
+ let r = Te(n, o, e.type, (e) => e !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition");
3012
+ if (!r?.xml) return;
3013
+ let i = /<pivotTableDefinition\b[^>]*>/.exec(r.xml)?.[0] ?? "", a = parseInt(/\scacheId="(\d+)"/.exec(i)?.[1] ?? "", 10);
3014
+ if (isNaN(a)) return void _.push([`Pivot table '${r.name}' names no cache and was dropped.`, o]);
3015
+ let s = /\sname="([^"]*)"/.exec(i)?.[1];
3016
+ t.push({
3017
+ ...s ? { name: l(s) } : {},
3018
+ cacheId: a,
3019
+ part: r
3020
+ });
3021
+ }), t.length > 0 && (e.pivotTables = t);
3022
+ }
3023
+ })());
3024
+ } else if (a.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink") {
3025
+ let t = Oe(o, e, E, T, W);
3026
+ if (t && Object.keys(t).length !== 0) {
3027
+ let e = t, n = e.__bookRelId, r = e.__absoluteUrlRelId;
3028
+ delete e.__bookRelId, delete e.__absoluteUrlRelId;
3029
+ let a = [];
3030
+ ve(o, i)?.forEach((e, t) => {
3031
+ if (e.targetMode === "External" && e.type && e.target) {
3032
+ let i = {
3033
+ type: e.type,
3034
+ target: e.target
3035
+ };
3036
+ t === n ? i.role = "book" : t === r && (i.role = "absoluteUrl"), a.push(i);
3037
+ }
3038
+ }), a.sort((e, t) => (e.role === "book" ? 0 : 1) - (t.role === "book" ? 0 : 1)), e.sources = a, F(o), d = e;
3039
+ } else d = null;
3040
+ } else d = r ? ((e, t, n, r = null) => {
3041
+ if (!e) return null;
3042
+ let i = e;
3043
+ i.startsWith("/") && (i = i.substring(1));
3044
+ let a = r?.parsedRefs?.get(e);
3045
+ if (a !== void 0) return a;
3046
+ let o = t(i);
3047
+ if (!o) return null;
3048
+ let s = o.content;
3049
+ try {
3050
+ n && (s = n(s, e));
3051
+ } catch (t) {
3052
+ z(e, t, r);
3053
+ }
3054
+ return r?.parsedRefs?.set(e, s), s;
3055
+ })(o, e, (e, t) => {
3056
+ let n = x.add({ source: { buffer: e } });
3057
+ return n.addReference(C), w.add(n), S.toResourceId(n);
3058
+ }, W) : Oe(o, e, E, T, W);
3059
+ }
3060
+ return d;
3061
+ }, L = (e, t) => {
3062
+ if (!e) return null;
3063
+ let n = ve(t, M)?.get(e);
3064
+ if (!n?.target || n.targetMode === "External") return null;
3065
+ let r = n.target;
3066
+ return r.startsWith("/") || (r = t.substring(0, t.lastIndexOf("/") + 1) + r), ke(r);
3067
+ }, ye = (e, t, n, r) => {
3068
+ let i = [], a = /* @__PURE__ */ new Map(), o = [];
3069
+ n.forEach((e, n) => {
3070
+ if (e.type !== "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment") return;
3071
+ let s = I(n, t, !1, r)?.comments;
3072
+ if (!s) return;
3073
+ for (let e = 0; e < s.length; e++) {
3074
+ let t = s[e];
3075
+ if (!t?.v?.id) continue;
3076
+ let { parentId: n, done: r, content: c, ...l } = t.v, u = {
3077
+ ...l,
3078
+ content: an(c)
3079
+ };
3080
+ n ? o.push({
3081
+ parentId: n,
3082
+ json: u
3083
+ }) : (r && (u.done = !0), a.set(u.id, u), i.push({
3084
+ r: t.r,
3085
+ v: u
3086
+ }));
3087
+ }
3088
+ let c = L(n, t);
3089
+ c && F(c);
3090
+ });
3091
+ for (let e = 0; e < o.length; e++) {
3092
+ let { parentId: t, json: n } = o[e], r = a.get(t);
3093
+ r && (r.replies ??= []).push(n);
3094
+ }
3095
+ let s = [];
3096
+ if (n.forEach((e, n) => {
3097
+ if (e.type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") return;
3098
+ let i = I(n, t, !1, r), o = i?.comments;
3099
+ if (!o) return;
3100
+ let c = i?.authors;
3101
+ for (let e = 0; e < o.length; e++) {
3102
+ let t = o[e];
3103
+ if (!t?.r) continue;
3104
+ let n = c && t.v.authorId !== void 0 ? c[t.v.authorId] : void 0;
3105
+ if (n && n.startsWith("tc=")) {
3106
+ if (a.has(je(n.substring(3)))) continue;
3107
+ n = void 0;
3108
+ }
3109
+ let r = {
3110
+ id: pe.uuidV4().toUpperCase(),
3111
+ asNote: !0,
3112
+ content: t.v.content ?? ""
3113
+ }, i = n ? U({ displayName: n }) : void 0;
3114
+ i && (r.personId = i.id), s.push({
3115
+ r: t.r,
3116
+ v: r
3117
+ });
3118
+ }
3119
+ let l = L(n, t);
3120
+ l && F(l);
3121
+ }), i.length === 0 && s.length === 0) return;
3122
+ let c = [...i, ...s], l = e.legacyDrawing;
3123
+ if (l?.xml) {
3124
+ let { rest: t, notes: n } = p(l.xml);
3125
+ if (n.length > 0) {
3126
+ let r = /* @__PURE__ */ new Map();
3127
+ for (let e = 0; e < n.length; e++) {
3128
+ let t = n[e];
3129
+ r.set(N.cellToString({
3130
+ rowIndex: t.row,
3131
+ colIndex: t.col
3132
+ }), t);
3133
+ }
3134
+ for (let e = 0; e < c.length; e++) {
3135
+ let t = c[e], n = r.get(String(t.r).toUpperCase());
3136
+ if (!n || (r.delete(String(t.r).toUpperCase()), !t.v.asNote)) continue;
3137
+ let i = k(n.xml), a = {};
3138
+ if (i.anchor) {
3139
+ let [e, t, r, o, s, c, l, u] = i.anchor;
3140
+ a.anchor = {
3141
+ tl: {
3142
+ c: e - n.col,
3143
+ x: t,
3144
+ r: r - n.row,
3145
+ y: o
3146
+ },
3147
+ br: {
3148
+ c: s - n.col,
3149
+ x: c,
3150
+ r: l - n.row,
3151
+ y: u
3152
+ }
3153
+ };
3154
+ }
3155
+ i.xml && (a.xml = i.xml), (a.anchor || a.xml) && (t.v.box = a), i.visible && (t.v.shown = !0), i.alt && (t.v.description = i.alt);
3156
+ }
3157
+ let i = [];
3158
+ r.forEach((e) => {
3159
+ i.push(e.xml);
3160
+ });
3161
+ let a = j(t, i);
3162
+ a ? l.xml = a : delete e.legacyDrawing;
3163
+ }
3164
+ }
3165
+ e.comments = c;
3166
+ }, R = (t, n) => {
3167
+ let r = L(t, n);
3168
+ if (!r) return null;
3169
+ let i = e(nn(r));
3170
+ if (!i) return null;
3171
+ let a = { xml: new TextDecoder("utf-8").decode(i.content) }, o = [];
3172
+ return ve(r, M)?.forEach((e, t) => {
3173
+ if (e.type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") return;
3174
+ let n = I(t, r, !0);
3175
+ typeof n == "number" && o.push({
3176
+ id: t,
3177
+ resId: n
3178
+ });
3179
+ }), o.length > 0 && (a.images = o), F(r), a;
3180
+ }, Ce = (t, n) => {
3181
+ let r = L(t, n);
3182
+ if (!r) return null;
3183
+ let i = Oe(r, e, E, T, W)?.formControl ?? null;
3184
+ return i && F(r), i;
3185
+ }, Te = (t, r, i, a, o = /* @__PURE__ */ new Set()) => {
3186
+ let s = L(t, r);
3187
+ if (!s || o.has(s)) return null;
3188
+ let c = i ?? ve(r, M)?.get(t)?.type;
3189
+ if (!c) return null;
3190
+ let l = e(nn(s));
3191
+ if (!l) return null;
3192
+ o.add(s);
3193
+ let u = s.substring(s.lastIndexOf("/") + 1), d = n.overrides[nn(s)] ?? n.defaults[u.substring(u.lastIndexOf(".") + 1).toLowerCase()], f = {
3194
+ id: t,
3195
+ type: c,
3196
+ name: u
3197
+ };
3198
+ if (d && (f.contentType = d), ((e, t) => e ? e.endsWith("+xml") || e === "application/xml" : /\.(xml|rels|vml)$/i.test(t))(d, u)) f.xml = new TextDecoder("utf-8").decode(l.content);
3199
+ else {
3200
+ let e = I(t, r, !0);
3201
+ if (typeof e != "number") return null;
3202
+ f.resId = e;
3203
+ }
3204
+ let p = [];
3205
+ return ve(s, M)?.forEach((e, t) => {
3206
+ if (!e?.type || a && !a(e.type)) return;
3207
+ if (e.targetMode === "External") {
3208
+ let n = I(t, s, !0);
3209
+ typeof n == "number" && p.push({
3210
+ id: t,
3211
+ type: e.type,
3212
+ resId: n
3213
+ });
3214
+ return;
3215
+ }
3216
+ let n = Te(t, s, e.type, a, o);
3217
+ n && p.push(n);
3218
+ }), p.length > 0 && (f.parts = p), F(s), f;
3219
+ };
3220
+ V("coreprops", n, e, E, T, y), V("extprops", n, e, E, T, y);
3221
+ let H = new be(), Ae = V("people", n, e, E, T, y);
3222
+ if (Ae.size > 0) {
3223
+ let [e, t] = Ae.entries().next().value;
3224
+ H.fromJSON(t?.persons), F(e);
3225
+ }
3226
+ let U = (e) => {
3227
+ if (e) return H.add(e).toJSON();
3228
+ }, W = {
3229
+ paramMap: D,
3230
+ getRefs: ve,
3231
+ getRef: I,
3232
+ parsedRefs: M,
3233
+ readEmbeddedPart: (e, t) => Te(e, t),
3234
+ addPerson: U,
3235
+ serializeElement: le,
3236
+ onWarning: v
3237
+ }, Me = [];
3238
+ if (c) {
3239
+ let e = await A.getTextStream(c, oe);
3240
+ if (e) {
3241
+ let t = ((e, t) => {
3242
+ let n = !1, r = !1, i = 0, a = "";
3243
+ return {
3244
+ onOpenTag: (e) => {
3245
+ let t = $t(e.name);
3246
+ t === "t" ? n && i === 0 && (r = !0) : t === "si" ? (n = !0, a = "", i = 0) : t !== "rPh" && t !== "phoneticPr" || i++;
3247
+ },
3248
+ onText: (e) => {
3249
+ r && (a += e);
3250
+ },
3251
+ onCloseTag: (t) => {
3252
+ let o = $t(t.name);
3253
+ o === "t" ? r = !1 : o === "si" ? (e(se(a)), n = !1, a = "") : o !== "rPh" && o !== "phoneticPr" || i > 0 && i--;
3254
+ },
3255
+ onError: (e) => {
3256
+ t?.(`Error parsing shared strings: ${e?.message ?? e}`);
3257
+ }
3258
+ };
3259
+ })((e) => {
3260
+ Me.push(e);
3261
+ }, (e) => {
3262
+ v(e, c);
3263
+ });
3264
+ try {
3265
+ await yt.parseStream(e, t, { xmlns: !1 });
3266
+ } catch (e) {
3267
+ throw Error(`Error parsing shared strings: '${c}'`, { cause: e });
3268
+ }
3269
+ }
3270
+ }
3271
+ g?.mark("shared-strings");
3272
+ let Ne = Me.length, Pe = /* @__PURE__ */ new Map(), Fe = Ne, Ie = (e) => {
3273
+ let t = Pe.get(e);
3274
+ if (t !== void 0) return t;
3275
+ let n = Fe;
3276
+ return Pe.set(e, Fe++), Me.push(e), n;
3277
+ }, Le = [];
3278
+ n.slicersCache = Le;
3279
+ let Re = A.getNames(), ze = Re.length;
3280
+ for (let e = 0; e < ze; e++) {
3281
+ let t = Re[e];
3282
+ t && t.startsWith("xl/slicerCache") && Le.push(`/${t}`);
3283
+ }
3284
+ let Be = V("slicersCache", n, e, E, T, W), Ve = /* @__PURE__ */ new Map();
3285
+ Be.forEach((e, t) => {
3286
+ e?.cacheName && (e.cachePath = t, Ve.set(e.cacheName, e));
3287
+ }), D.set("slicerCaches", Ve);
3288
+ let He = [];
3289
+ n.slicers = He;
3290
+ for (let e = 0; e < ze; e++) {
3291
+ let t = Re[e];
3292
+ t && t.startsWith("xl/slicers/") && t.endsWith(".xml") && He.push(`/${t}`);
3293
+ }
3294
+ V("richstructure", n, e, E, T, W), V("richdata", n, e, E, T, W);
3295
+ let Ue = V("themes", n, e, E, T, W), We = null;
3296
+ if (Ue && Ue.entries) {
3297
+ let e = Ue.entries().next();
3298
+ e?.value?.[1] && (We = e.value[1]);
3299
+ }
3300
+ let Ge = new Se(We), Ke = V("styles", n, e, E, T, W).entries().next()?.value?.[1];
3301
+ Ke &&= JSON.parse(fe.JSONStableStringify(Ke));
3302
+ let qe = V("workbooks", n, e, E, T, W);
3303
+ g?.mark("side-parts-json"), await Promise.all(P);
3304
+ {
3305
+ let e = qe.entries().next().value?.[1], n = ie(e?.names), r = e?.sheets ?? [];
3306
+ for (let e = 0; e < r.length; e++) {
3307
+ let i = r[e]?.sheet;
3308
+ i && t(i, n);
3309
+ }
3310
+ let i = e?.names;
3311
+ if (i) for (let e = 0; e < i.length; e++) {
3312
+ let t = i[e]?.ref;
3313
+ typeof t == "string" && (i[e].ref = n.readDetached(t));
3314
+ }
3315
+ }
3316
+ ne && re > 0 && (ne(b, b), await new Promise((e) => setTimeout(e, 0))), g?.mark("sheets");
3317
+ let G = {
3318
+ ...qe.entries().next().value?.[1],
3319
+ styles: Ke,
3320
+ theme: Ge.toJSON()
3321
+ };
3322
+ ((e, t) => {
3323
+ if (!t || t.size === 0) return;
3324
+ let n = e.styles;
3325
+ if (!n) return;
3326
+ let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
3327
+ for (let n of e.sheets ?? []) {
3328
+ let e = n?.sheet;
3329
+ if (!e) continue;
3330
+ let a = /* @__PURE__ */ new Set();
3331
+ Zt(e.cols) || a.add(0);
3332
+ for (let t of e.directStyles ?? []) a.add(Array.isArray(t) ? t[1] : t.v);
3333
+ for (let t of e.rows ?? []) {
3334
+ let e = Xt(t);
3335
+ e !== void 0 && a.add(e);
3336
+ }
3337
+ for (let t of e.cols ?? []) {
3338
+ let e = Xt(t);
3339
+ e !== void 0 && a.add(e);
3340
+ }
3341
+ let o = !1;
3342
+ for (let e of a) if (t.has(e)) {
3343
+ o = !0;
3344
+ break;
3345
+ }
3346
+ if (o) {
3347
+ e.protection = {
3348
+ ...e.protection ?? { sheet: !0 },
3349
+ showFormulas: !1
3350
+ };
3351
+ for (let e of a) (t.has(e) ? i : r).add(e);
3352
+ }
3353
+ }
3354
+ if (r.size === 0) return;
3355
+ let a = n.direct ??= [];
3356
+ for (let e of r) e !== 0 && Qt(a[e] ?? (a[e] = {}), !0);
3357
+ for (let e of i) e !== 0 && Qt(a[e] ?? (a[e] = {}), !1);
3358
+ if (r.has(0)) {
3359
+ let e = n.named ??= [], t = _e.BuiltInName.Normal.toLowerCase(), r = e.find((e) => e.name?.toLowerCase() === t);
3360
+ r || (r = {
3361
+ name: _e.BuiltInName.Normal,
3362
+ style: {}
3363
+ }, e.push(r)), Qt(r.style, !0);
3364
+ }
3365
+ })(G, D.get(Yt));
3366
+ {
3367
+ let t = /* @__PURE__ */ new Map();
3368
+ V("slicers", n, e, E, T, W).forEach((e, n) => {
3369
+ e?.slicers && t.set(n, e.slicers);
3370
+ }), function(e, t) {
3371
+ let n = e.sheets ?? [], r = /* @__PURE__ */ new Map();
3372
+ for (let e = 0; e < n.length; e++) {
3373
+ let t = n[e]?.sheet?.tables ?? [];
3374
+ for (let e = 0; e < t.length; e++) {
3375
+ let n = t[e], i = Array.isArray(n) ? n[1] : n?.v;
3376
+ if (!i?.id) continue;
3377
+ let a = (i.columns ?? []).map((e) => typeof e == "string" ? { name: e } : e);
3378
+ r.set(String(i.id), {
3379
+ name: i.name ?? "",
3380
+ columns: a
3381
+ });
3382
+ }
3383
+ }
3384
+ let i = /* @__PURE__ */ new Set();
3385
+ for (let e = 0; e < n.length; e++) {
3386
+ let a = n[e]?.sheet;
3387
+ if (!a) continue;
3388
+ let o = a.slicers, s = a.movables;
3389
+ if (o && s) for (let e = s.length - 1; e >= 0; e--) {
3390
+ let n = s[e].content;
3391
+ if (n?.type !== "slicer" || n.json?.source) continue;
3392
+ let a = n.name ?? "", c = o[a];
3393
+ if (!c?.tableId) continue;
3394
+ let l = r.get(String(c.tableId)), u = l ? Ee(l.columns, c.columnId) : null;
3395
+ l && u ? (n.json = De(c, n.json, ge.structuredReference(l.name, u.name)), i.add(a), c.cachePath && t.markAbsorbed(c.cachePath)) : (t.warn("A slicer names no table; it was not imported.", "xlsx.slicer.cacheDefinition"), s.splice(e, 1));
3396
+ }
3397
+ delete a.slicers;
3398
+ }
3399
+ t.slicerParts.forEach((e, n) => {
3400
+ let r = Object.keys(e);
3401
+ r.length > 0 && r.every((e) => i.has(e)) && t.markAbsorbed(n);
3402
+ });
3403
+ }(G, {
3404
+ warn: (e, t) => {
3405
+ v(e, "xl/slicers", t);
3406
+ },
3407
+ markAbsorbed: F,
3408
+ slicerParts: t
3409
+ });
3410
+ }
3411
+ G.calc = {
3412
+ ...G.calc ?? {},
3413
+ legacyIntersect: !0
3414
+ }, Me.length > 0 && (G.strings = Me);
3415
+ let Je = H.toJSON();
3416
+ Je && Je.length > 0 && (G.people = Je);
3417
+ let Ye = A.getEntry("xl/vbaProject.bin");
3418
+ if (Ye) try {
3419
+ let { VBAProject: e } = await import("./B-jb5SuiVh5NnBG_.mjs"), t = e.extract(Ye);
3420
+ if (t) {
3421
+ let n = /* @__PURE__ */ new Map();
3422
+ for (let e of G.sheets ?? []) {
3423
+ let t = e?.sheet?.codeName;
3424
+ t && n.set(t, e.sheet);
3425
+ }
3426
+ for (let r of t.modules) {
3427
+ let t = { language: "vba" }, { header: i, body: a } = e.splitAttributes(r.code);
3428
+ a && (t.source = a), i && (t.sourceHeader = i);
3429
+ let o = r.type === "document" ? n.get(r.name) : void 0;
3430
+ o || r.type !== "document" || (t.scope = "workbook");
3431
+ let s = o ? o.modules ??= {} : G.modules ??= {};
3432
+ s[r.name] || (s[r.name] = t);
3433
+ }
3434
+ u?.(t);
3435
+ } else _.push(["Unable to parse VBA project.", "xl/vbaProject.bin"]);
3436
+ } catch (e) {
3437
+ _.push([`Error extracting VBA: ${e?.message ?? e}`, "xl/vbaProject.bin"]);
3438
+ }
3439
+ let Xe = D.get("calcId"), Ze = Xe === void 0 || !(Number(Xe) >= 191029), Qe = m.calcOnLoad ?? (f === "auto" && Ze ? "full" : f), $e = {
3440
+ ...m,
3441
+ calcOnLoad: Qe,
3442
+ resources: x,
3443
+ json: G
3444
+ };
3445
+ $e.disableLoadAutoFit === void 0 && ($e.disableLoadAutoFit = !1), g?.mark("json-assembled");
3446
+ let K = new we($e);
3447
+ if (g?.mark("workbook-constructed"), ce.length > 0 && Qe !== "none") {
3448
+ await K.whenCalculationReady();
3449
+ let e = /* @__PURE__ */ new Map(), t = G.sheets ?? [], n = K.getSheets().getItems();
3450
+ for (let r = 0; r < t.length; r++) {
3451
+ let i = t[r]?.sheet, a = n[r];
3452
+ i && a && e.set(i, a);
3453
+ }
3454
+ ((e, t, n) => {
3455
+ if (t.length === 0) return;
3456
+ let r = e.getCalculation().getFunctions(), i = /* @__PURE__ */ new Map(), a = (e) => {
3457
+ let t = i.get(e);
3458
+ return t === void 0 && (t = r.getByName(e) !== null, i.set(e, t)), t;
3459
+ }, o = /* @__PURE__ */ new Map();
3460
+ for (let e of t) {
3461
+ let t = o.get(e.sheet);
3462
+ t || (t = [], o.set(e.sheet, t)), t.push(e);
3463
+ }
3464
+ for (let [e, t] of o) {
3465
+ let r = n.get(e);
3466
+ if (!r) continue;
3467
+ let i = (e, t) => `${e},${t}`, o = /* @__PURE__ */ new Set();
3468
+ for (let e of t) e.formula === null && o.add(i(e.rowIndex, e.colIndex));
3469
+ for (let e of t) {
3470
+ if (e.formula === null) continue;
3471
+ let t = Vt(e.formula), n = !0;
3472
+ for (let e of t) if (!a(e)) {
3473
+ n = !1;
3474
+ break;
3475
+ }
3476
+ if (!n) continue;
3477
+ let s = [], c = [[e.rowIndex, e.colIndex]], l = /* @__PURE__ */ new Set([i(e.rowIndex, e.colIndex)]);
3478
+ for (; c.length > 0;) {
3479
+ let [e, t] = c.pop(), n = [
3480
+ [e + 1, t],
3481
+ [e - 1, t],
3482
+ [e, t + 1],
3483
+ [e, t - 1]
3484
+ ];
3485
+ for (let [e, t] of n) {
3486
+ let n = i(e, t);
3487
+ !l.has(n) && o.has(n) && (l.add(n), s.push([e, t]), c.push([e, t]));
3488
+ }
3489
+ }
3490
+ for (let [e, t] of s) o.delete(i(e, t)), r.getRange({
3491
+ rowStart: e,
3492
+ colStart: t,
3493
+ rowEnd: e,
3494
+ colEnd: t
3495
+ }).clear();
3496
+ r.getRange({
3497
+ rowStart: e.rowIndex,
3498
+ colStart: e.colIndex,
3499
+ rowEnd: e.rowIndex,
3500
+ colEnd: e.colIndex
3501
+ }).setValue("=" + e.formula);
3502
+ }
3503
+ }
3504
+ })(K, ce, e);
3505
+ }
3506
+ if (w.forEach((e) => {
3507
+ e.deleteReference(C);
3508
+ }), S.endPersist(), h) {
3509
+ a(K);
3510
+ let e = /* @__PURE__ */ new Map(), t = 0;
3511
+ for (let n of A.getNames()) {
3512
+ let r = A.getEntry(n);
3513
+ if (!r) continue;
3514
+ let i = A.getRawEntry(n), a = i ? {
3515
+ data: r,
3516
+ uncompressedSize: A.uncompressedSize(n),
3517
+ raw: {
3518
+ compressedData: i.data,
3519
+ compressionMethod: i.compressionMethod,
3520
+ signature: i.signature
3521
+ }
3522
+ } : {
3523
+ data: r,
3524
+ uncompressedSize: A.uncompressedSize(n)
3525
+ };
3526
+ e.set(n, a), t += r.byteLength;
3527
+ }
3528
+ if (t > 67108864) _.push([`Source package too large to retain (${t} bytes, limit ${r}); unmodeled parts will be dropped on save.`, "SourcePackage"]);
3529
+ else if (e.size > 0) {
3530
+ let t = new de(e, he);
3531
+ i(K, t);
3532
+ let n = K.getSheets().getItems(), r = K.getTransactions().addListener({ onCommitEnd: (e) => {
3533
+ let n = e.getOperation()?.name;
3534
+ n !== "insertCells" && n !== "deleteCells" || t.markStructuralChange();
3535
+ } }), o = K.addListeners({ onSheetsChange: () => {
3536
+ let e = K.getSheets().getItems();
3537
+ (e.length !== n.length || e.some((e, t) => e !== n[t])) && t.markStructuralChange(), n = e;
3538
+ } });
3539
+ K.addListeners({ onClose: () => {
3540
+ r(), o(), a(K);
3541
+ } });
3542
+ }
3543
+ }
3544
+ if (_.length && te?.onWarning) {
3545
+ let e = /* @__PURE__ */ new Set();
3546
+ for (let t of _) {
3547
+ let [n, r, i] = t, a = i ?? n;
3548
+ e.has(a) || (e.add(a), te.onWarning(n, r));
3549
+ }
3550
+ }
3551
+ return g && !0 === d && console.table(g.toTable()), K;
3552
+ } catch (e) {
3553
+ let t = "Unable to parse XLSX.";
3554
+ throw e instanceof R && (t = "Unable to open XLSX. There are too many rows or columns."), Error(t, { cause: e });
3555
+ } finally {
3556
+ await A.close().catch(() => {});
3557
+ }
3558
+ };
3559
+ export { je as i, Yt as n, Ae as r, on as readXLSX, tn as t };