@sheetxl/io-xlsx 0.8.0-beta.15 → 0.8.0-beta.16

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 (57) hide show
  1. package/LICENSE.md +8 -7
  2. package/browser/esm/BQaNticMfvf7-y0L.mjs +2474 -0
  3. package/browser/esm/{BFHIFwfouCmmizKM.mjs → BalqIL4s8nR3NbK8.mjs} +2528 -1702
  4. package/browser/esm/{DPgI3veM7LuSesNu.mjs → BiueQ3eVPDOEdEeL.mjs} +1321 -1087
  5. package/browser/esm/{DsepJB2krbe8n-h0.mjs → BtLo1V0gnJ3ktOw9.mjs} +2 -2
  6. package/browser/esm/{VJT_B2rC29Twv3oJ.mjs → C3H8HKjSun-wLDrE.mjs} +5 -5
  7. package/browser/esm/{CbQ6xSA_Ryc9x49z.mjs → CCGqD5BzdZMq2pTI.mjs} +2 -2
  8. package/browser/esm/{B0as56gGm8o91eha.mjs → DT-3sV5qGuHTFmnB.mjs} +3295 -2163
  9. package/browser/esm/{CirSa4nJDHuHyGFb.mjs → W3dYk6brWDUtMZca.mjs} +3 -3
  10. package/browser/esm/{B5T6ZjCOm6tpqIxy.mjs → X5YJn8ZwrgDKMwwO.mjs} +3 -3
  11. package/browser/esm/{CVAAfrHVJ6jjaD4l.mjs → ekV6d7YNDF6FkKLw.mjs} +423 -318
  12. package/browser/esm/{cD_3iBL0XZP3GHGG.mjs → idgOmd_zpVTKLyek.mjs} +3 -3
  13. package/browser/esm/index.mjs +3 -3
  14. package/node/esm/{B_bFXQdvg63_jXXv.mjs → BO8o53Yo-gLFNELS.mjs} +3 -3
  15. package/node/esm/{CcMI8GfS94qlNCB0.mjs → BT0HKieizRDqDegH.mjs} +440 -330
  16. package/node/esm/BmIrpH_719z1aqvw.mjs +2562 -0
  17. package/node/esm/CJYMs5EGkLOZKyF0.mjs +4676 -0
  18. package/node/esm/{CQ3fUb7A8HUgTAIh.mjs → CZsPzV1CsMPKiICx.mjs} +2 -2
  19. package/node/esm/CdFqKswnjeM_u8-g.mjs +7242 -0
  20. package/node/esm/CnYiZh1EVKY4BNVs.mjs +6851 -0
  21. package/node/esm/{Cz6FfReTe9Ps5moN.mjs → OO5K_WYvAj-UV14K.mjs} +3 -3
  22. package/node/esm/index.mjs +5 -5
  23. package/package.json +4 -4
  24. package/types/src/AutoFilterRules.d.ts +26 -4
  25. package/types/src/OOXMLExtensions.d.ts +12 -1
  26. package/types/src/pivot/PivotArea.d.ts +20 -0
  27. package/types/src/pivot/PivotCacheRead.d.ts +30 -0
  28. package/types/src/pivot/PivotCacheWrite.d.ts +23 -0
  29. package/types/src/pivot/PivotFilters.d.ts +29 -0
  30. package/types/src/pivot/PivotFormats.d.ts +60 -0
  31. package/types/src/pivot/PivotTableRead.d.ts +44 -0
  32. package/types/src/pivot/PivotTableWrite.d.ts +13 -0
  33. package/types/src/pivot/_PivotCacheXml.d.ts +48 -0
  34. package/types/src/pivot/_PivotTableXml.d.ts +23 -0
  35. package/types/src/reader/PivotButtons.d.ts +14 -0
  36. package/types/src/reader/PivotCellFormats.d.ts +22 -0
  37. package/types/src/reader/SlicerJoin.d.ts +6 -4
  38. package/types/src/reader/_SlicerRecord.d.ts +22 -0
  39. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +5 -0
  40. package/types/src/reader/domVisitors/SlicerCacheDefinitionVisitor.d.ts +6 -2
  41. package/types/src/reader/domVisitors/SlicersVisitor.d.ts +2 -0
  42. package/types/src/reader/domVisitors/TimelinesVisitor.d.ts +13 -0
  43. package/types/src/reader/domVisitors/index.d.ts +2 -0
  44. package/types/src/writer/EvaluationSheet.d.ts +5 -0
  45. package/types/src/writer/builder/Types.d.ts +13 -0
  46. package/types/src/writer/emitters/PivotTableEmitter.d.ts +30 -1
  47. package/types/src/writer/emitters/SlicerEmitter.d.ts +81 -18
  48. package/types/src/writer/emitters/StylesEmitter.d.ts +32 -1
  49. package/types/src/writer/emitters/WorkbookEmitter.d.ts +19 -2
  50. package/types/src/writer/utils/DateSystem.d.ts +6 -0
  51. package/types/src/writer/utils/XfVariants.d.ts +61 -0
  52. package/browser/esm/CE5CJXtA1SK_ve3k.mjs +0 -2265
  53. package/node/esm/B0IbtakI6lvldj5N.mjs +0 -5693
  54. package/node/esm/C87CEL-9kIrXknM_.mjs +0 -2346
  55. package/node/esm/CPb9rk-UywrH-U7Y.mjs +0 -4437
  56. package/node/esm/Dw3qQRUIJShJWc_D.mjs +0 -6367
  57. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +0 -28
@@ -1,4437 +0,0 @@
1
- /**
2
- * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.15
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 t, Bn as e, Bt as s, C as o, Cn as r, Dt as n, En as i, Et as a, Fn as l, Hn as c, It as h, Jt as u, Kt as d, Ln as p, Nn as f, On as g, Ot as m, Pn as b, Pt as x, Q as y, Qn as v, Sn as w, Tn as T, Tt as S, Vt as C, X as A, Xn as k, Xt as E, Zt as I, _n as P, _t as O, bn as D, bt as _, d as N, dt as $, en as R, et as L, fn as V, ft as M, gn as B, gt as j, h as F, hn as H, ht as W, in as z, jn as X, kn as q, mn as U, n as K, nn as G, pt as Z, qn as Q, qt as Y, rn as tt, rt as et, sn as st, st as ot, t as rt, tt as nt, u as it, vn as at, vt as lt, w as ct, wn as ht, wt as ut, x as dt, xn as pt, xt as ft, yn as gt, zt as mt } from "./B0IbtakI6lvldj5N.mjs";
8
- import { BufferUtils as bt, CommonUtils as xt, ExpectedError as yt, OverlappingRange as vt, RangeAxis as wt } from "@sheetxl/utils";
9
- import { AddressUtils as Tt, CommonUtils as St, CoordUtils as Ct, FormulaError as At, FormulaText as kt, FunctionDeclarations as Et, ICellStyle as It, ICondition as Pt, IConditionalFormat as Ot, ICustomProperty as Dt, IFont as _t, IRange as Nt, OutOfBoundsError as $t, PersonCollection as Rt, ResourceCollection as Lt, RichDataRegistry as Vt, Scalar as Mt, Sort as Bt, Theme as jt, Tuple as Ft, Workbook as Ht } from "@sheetxl/sdk";
10
- import { BlobReader as Wt, Uint8ArrayReader as zt, Uint8ArrayWriter as Xt, ZipReader as qt } from "@zip.js/zip.js";
11
- var Ut = {
12
- ascending: "ascending",
13
- descending: "descending",
14
- natural: "dataSource"
15
- };
16
- function Kt(t, e) {
17
- if (!e) return null;
18
- for (let s = 0; s < t.length; s++) if (void 0 !== t[s].id && String(t[s].id) === e) return t[s];
19
- const s = Number(e);
20
- return Number.isInteger(s) && s >= 1 && s <= t.length ? t[s - 1] : null;
21
- }
22
- function Gt(t, e, s) {
23
- const o = {
24
- ...e,
25
- source: s
26
- };
27
- if (void 0 !== t.caption && t.caption !== t.sourceName && (o.caption = t.caption), !1 === t.showCaption && (o.hiddenCaption = !0), void 0 !== t.columnCount && t.columnCount > 1 && (o.columnCount = t.columnCount), void 0 !== t.rowHeight) {
28
- const e = Math.round(t.rowHeight / 9525);
29
- e > 0 && 27 !== e && (o.rowHeight = e);
30
- }
31
- t.style && "SlicerStyleLight1" !== t.style && (o.style = t.style);
32
- const r = t.sortOrder ? Ut[t.sortOrder] : void 0;
33
- return r && "ascending" !== r && (o.sortOrder = r), t.crossFilter && "showItemsWithDataAtTop" !== t.crossFilter && (o.crossFilter = t.crossFilter), t.lockedPosition && (o.lockedPosition = !0), !1 === t.customListSort && (o.disabledCustomListSort = !0), t.cacheName && (o.cacheName = t.cacheName), t.startItem && (o.startItem = t.startItem), void 0 !== t.level && (o.level = t.level), t.uid && (o.uid = t.uid), o;
34
- }
35
- var Jt = "xl/richData/rdrichvaluestructure.xml", Zt = "xl/richData/rdrichvalue.xml", Qt = "xl/richData/rdarray.xml", Yt = "xl/richData/rdsupportingpropertybagstructure.xml", te = "xl/richData/rdsupportingpropertybag.xml", ee = "xl/richData/rdRichValueTypes.xml", se = "xl/richData/richStyles.xml", oe = (t, e) => {
36
- const s = [], o = t?.childNodes, r = o?.length ?? 0;
37
- for (let t = 0; t < r; t++) {
38
- const r = o.item(t);
39
- 1 !== r.nodeType || e && r.localName !== e || s.push(r);
40
- }
41
- return s;
42
- }, re = (t) => oe(t, "k").map((t) => [t.getAttribute("n") ?? "", t.getAttribute("t") || null]), ne = (t) => oe(t, "v").map((t) => ({
43
- t: t.getAttribute("t") || null,
44
- text: t.textContent ?? ""
45
- })), ie = (t) => {
46
- const e = /* @__PURE__ */ new Map();
47
- for (const s of oe(t, "key")) {
48
- const t = /* @__PURE__ */ new Map();
49
- for (const e of oe(s, "flag")) t.set(e.getAttribute("name") ?? "", e.getAttribute("value") ?? "");
50
- e.set(s.getAttribute("name") ?? "", t);
51
- }
52
- return e;
53
- }, ae = /* @__PURE__ */ new Uint8Array(0), le = class t {
54
- constructor(t, e, s) {
55
- this.buffers = /* @__PURE__ */ new Map(), this.zip = t, this.entries = e, this.rawBuffer = s;
56
- }
57
- static normalize(t) {
58
- return t.startsWith("/") ? t.slice(1) : t;
59
- }
60
- static async create(e) {
61
- const s = e instanceof Blob ? ae : e instanceof Uint8Array ? e : new Uint8Array(e), o = e instanceof Blob ? new Wt(e) : new zt(s), r = new qt(o), n = /* @__PURE__ */ new Map();
62
- for (const t of await r.getEntries()) t.directory || n.set(t.filename, t);
63
- return new t(r, n, s);
64
- }
65
- getNames() {
66
- return [...this.entries.keys()];
67
- }
68
- has(e) {
69
- return this.entries.has(t.normalize(e));
70
- }
71
- uncompressedSize(e) {
72
- return this.entries.get(t.normalize(e))?.uncompressedSize ?? 0;
73
- }
74
- async getBuffer(e) {
75
- const s = t.normalize(e), o = this.buffers.get(s);
76
- if (o) return o;
77
- const r = this.entries.get(s);
78
- if (!r) return null;
79
- const n = await r.getData(new Xt());
80
- return this.buffers.set(s, n), n;
81
- }
82
- async prefetch(t) {
83
- const e = [];
84
- for (const [s, o] of this.entries) !this.buffers.has(s) && t(s, o) && e.push(o.getData(new Xt()).then((t) => {
85
- this.buffers.set(s, t);
86
- }));
87
- await Promise.all(e);
88
- }
89
- getEntry(e) {
90
- return this.buffers.get(t.normalize(e)) ?? null;
91
- }
92
- async getTextStream(e, s) {
93
- const o = this.entries.get(t.normalize(e));
94
- if (!o) return null;
95
- const r = new TransformStream();
96
- o.getData(r.writable).catch(() => {});
97
- const n = r.readable.getReader(), i = new TextDecoder("utf-8");
98
- return new ReadableStream({ async pull(t) {
99
- const { value: e, done: o } = await n.read();
100
- if (o) {
101
- const e = i.decode();
102
- e && t.enqueue(e), t.close();
103
- return;
104
- }
105
- s?.(e.byteLength);
106
- const r = i.decode(e, { stream: !0 });
107
- r && t.enqueue(r);
108
- } }).getReader();
109
- }
110
- getRawEntry(e) {
111
- const s = this.entries.get(t.normalize(e));
112
- if (!s || s.encrypted || void 0 === s.crc32) return null;
113
- const o = s.offset;
114
- if (o + 30 > this.rawBuffer.byteLength) return null;
115
- const r = new DataView(this.rawBuffer.buffer, this.rawBuffer.byteOffset + o, 30);
116
- if (67324752 !== r.getUint32(0, !0)) return null;
117
- const n = o + 30 + r.getUint16(26, !0) + r.getUint16(28, !0), i = n + s.compressedSize;
118
- return i > this.rawBuffer.byteLength ? null : {
119
- data: this.rawBuffer.subarray(n, i),
120
- compressionMethod: s.compressionMethod,
121
- signature: s.crc32
122
- };
123
- }
124
- async close() {
125
- await this.zip.close();
126
- }
127
- }, ce = class {
128
- constructor(t) {
129
- this._sink = t, this._samples = [], this._t0 = he(), this._tPrev = this._t0, this._heapPrev = ue();
130
- }
131
- mark(t) {
132
- const e = he(), s = ue(), o = {
133
- label: t,
134
- tMs: e - this._t0,
135
- dtMs: e - this._tPrev,
136
- heapBytes: s,
137
- dHeapBytes: void 0 !== s && void 0 !== this._heapPrev ? s - this._heapPrev : void 0,
138
- rssBytes: de()
139
- };
140
- this._tPrev = e, this._heapPrev = s, this._samples.push(o), this._sink?.(o);
141
- }
142
- samples() {
143
- return this._samples;
144
- }
145
- toTable() {
146
- return this._samples.map((t) => ({
147
- phase: t.label,
148
- tMs: Math.round(t.tMs),
149
- dtMs: Math.round(t.dtMs),
150
- heapMB: void 0 !== t.heapBytes ? pe(t.heapBytes / 1048576) : "—",
151
- dHeapMB: void 0 !== t.dHeapBytes ? pe(t.dHeapBytes / 1048576) : "—",
152
- rssMB: void 0 !== t.rssBytes ? pe(t.rssBytes / 1048576) : "—"
153
- }));
154
- }
155
- }, he = "object" == typeof performance && "function" == typeof performance.now ? () => performance.now() : () => Date.now();
156
- function ue() {
157
- const t = "object" == typeof performance ? performance.memory : void 0;
158
- if (t && "number" == typeof t.usedJSHeapSize) return t.usedJSHeapSize;
159
- const e = globalThis.process;
160
- return "object" == typeof e && "function" == typeof e.memoryUsage ? e.memoryUsage().heapUsed : void 0;
161
- }
162
- function de() {
163
- const t = globalThis.process;
164
- if ("object" == typeof t && "function" == typeof t.memoryUsage) return t.memoryUsage().rss;
165
- }
166
- function pe(t) {
167
- return Math.round(10 * t) / 10;
168
- }
169
- var fe = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", ge = `-${fe}.0-9·̀-ͯ‿-⁀`, me = (new RegExp(`^[${fe}]$`, "u"), new RegExp(`^[${ge}]$`, "u"), new RegExp(`^[${fe}][${ge}]*$`, "u")), be = (new RegExp(`^[${ge}]+$`, "u"), [
170
- 32,
171
- 10,
172
- 13,
173
- 9
174
- ]);
175
- function xe(t) {
176
- return t >= 65 && t <= 90 || t >= 97 && t <= 122 || 58 === t || 95 === t || 8204 === t || 8205 === t || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 767 || t >= 880 && t <= 893 || t >= 895 && t <= 8191 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
177
- }
178
- var ye = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", ve = `-${ye}.0-9·̀-ͯ‿-⁀`;
179
- new RegExp(`^[${ye}]$`, "u"), new RegExp(`^[${ve}]$`, "u"), new RegExp(`^[${ye}][${ve}]*$`, "u"), new RegExp(`^[${ve}]+$`, "u");
180
- var we = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", Te = `-${we}.0-9·̀-ͯ‿-⁀`, Se = (new RegExp(`^[${we}]$`, "u"), new RegExp(`^[${Te}]$`, "u"), new RegExp(`^[${we}][${Te}]*$`, "u"));
181
- function Ce(t) {
182
- return t >= 65 && t <= 90 || 95 === t || t >= 97 && t <= 122 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 767 || t >= 880 && t <= 893 || t >= 895 && t <= 8191 || t >= 8204 && t <= 8205 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
183
- }
184
- var Ae = function(t) {
185
- return 32 === t || 10 === t || 13 === t || 9 === t;
186
- }, ke = function(t) {
187
- return t >= 32 && t <= 55295 || 10 === t || 13 === t || 9 === t || t >= 57344 && t <= 65533 || t >= 65536 && t <= 1114111;
188
- }, Ee = xe, Ie = function(t) {
189
- return xe(t) || t >= 48 && t <= 57 || 45 === t || 46 === t || 183 === t || t >= 768 && t <= 879 || t >= 8255 && t <= 8256;
190
- }, Pe = be, Oe = me, De = function(t) {
191
- return t >= 1 && t <= 55295 || t >= 57344 && t <= 65533 || t >= 65536 && t <= 1114111;
192
- }, _e = Ce, Ne = function(t) {
193
- return Ce(t) || 45 === t || 46 === t || t >= 48 && t <= 57 || 183 === t || t >= 768 && t <= 879 || t >= 8255 && t <= 8256;
194
- }, $e = Se, Re = "http://www.w3.org/XML/1998/namespace", Le = "http://www.w3.org/2000/xmlns/", Ve = {
195
- __proto__: null,
196
- xml: Re,
197
- xmlns: Le
198
- }, Me = {
199
- __proto__: null,
200
- amp: "&",
201
- gt: ">",
202
- lt: "<",
203
- quot: "\"",
204
- apos: "'"
205
- }, Be = -1, je = -2, Fe = 13, He = 33, We = 10, ze = 60, Xe = 61, qe = 62, Ue = 63, Ke = 93, Ge = (t) => 34 === t || 39 === t, Je = [34, 39], Ze = [
206
- ...Je,
207
- 91,
208
- qe
209
- ], Qe = [
210
- ...Je,
211
- ze,
212
- Ke
213
- ], Ye = [
214
- Xe,
215
- Ue,
216
- ...Pe
217
- ], ts = [
218
- ...Pe,
219
- qe,
220
- 38,
221
- ze
222
- ];
223
- function es(t, e, s) {
224
- switch (e) {
225
- case "xml":
226
- s !== Re && t.fail(`xml prefix must be bound to ${Re}.`);
227
- break;
228
- case "xmlns": s !== Le && t.fail(`xmlns prefix must be bound to ${Le}.`);
229
- }
230
- switch (s) {
231
- case Le:
232
- t.fail("" === e ? `the default namespace may not be set to ${s}.` : `may not assign a prefix (even "xmlns") to the URI ${Le}.`);
233
- break;
234
- case Re: switch (e) {
235
- case "xml": break;
236
- case "":
237
- t.fail(`the default namespace may not be set to ${s}.`);
238
- break;
239
- default: t.fail("may not assign the xml namespace to another prefix.");
240
- }
241
- }
242
- }
243
- var ss, os = (t) => $e.test(t), rs = (t) => Oe.test(t), ns = {
244
- xmldecl: "xmlDeclHandler",
245
- text: "textHandler",
246
- processinginstruction: "piHandler",
247
- doctype: "doctypeHandler",
248
- comment: "commentHandler",
249
- opentagstart: "openTagStartHandler",
250
- attribute: "attributeHandler",
251
- opentag: "openTagHandler",
252
- closetag: "closeTagHandler",
253
- cdata: "cdataHandler",
254
- error: "errorHandler",
255
- end: "endHandler",
256
- ready: "readyHandler"
257
- }, is = class {
258
- get closed() {
259
- return this._closed;
260
- }
261
- constructor(t) {
262
- this.i = 0, this.prevI = 0, this.opt = t ?? {}, this.fragmentOpt = !!this.opt.fragment;
263
- const e = this.xmlnsOpt = !!this.opt.xmlns;
264
- if (this.trackPosition = !1 !== this.opt.position, this.fileName = this.opt.fileName, e) {
265
- this.nameStartCheck = _e, this.nameCheck = Ne, this.isName = os, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = {
266
- __proto__: null,
267
- ...Ve
268
- };
269
- const t = this.opt.additionalNamespaces;
270
- null != t && (function(t, e) {
271
- for (const s of Object.keys(e)) es(t, s, e[s]);
272
- }(this, t), Object.assign(this.ns, t));
273
- } else this.nameStartCheck = Ee, this.nameCheck = Ie, this.isName = rs, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
274
- this.stateTable = [
275
- this.sBegin,
276
- this.sBeginWhitespace,
277
- this.sDoctype,
278
- this.sDoctypeQuote,
279
- this.sDTD,
280
- this.sDTDQuoted,
281
- this.sDTDOpenWaka,
282
- this.sDTDOpenWakaBang,
283
- this.sDTDComment,
284
- this.sDTDCommentEnding,
285
- this.sDTDCommentEnded,
286
- this.sDTDPI,
287
- this.sDTDPIEnding,
288
- this.sText,
289
- this.sEntity,
290
- this.sOpenWaka,
291
- this.sOpenWakaBang,
292
- this.sComment,
293
- this.sCommentEnding,
294
- this.sCommentEnded,
295
- this.sCData,
296
- this.sCDataEnding,
297
- this.sCDataEnding2,
298
- this.sPIFirstChar,
299
- this.sPIRest,
300
- this.sPIBody,
301
- this.sPIEnding,
302
- this.sXMLDeclNameStart,
303
- this.sXMLDeclName,
304
- this.sXMLDeclEq,
305
- this.sXMLDeclValueStart,
306
- this.sXMLDeclValue,
307
- this.sXMLDeclSeparator,
308
- this.sXMLDeclEnding,
309
- this.sOpenTag,
310
- this.sOpenTagSlash,
311
- this.sAttrib,
312
- this.sAttribName,
313
- this.sAttribNameSawWhite,
314
- this.sAttribValue,
315
- this.sAttribValueQuoted,
316
- this.sAttribValueClosed,
317
- this.sAttribValueUnquoted,
318
- this.sCloseTag,
319
- this.sCloseTagSawWhite
320
- ], this._init();
321
- }
322
- _init() {
323
- 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 = [];
324
- const { fragmentOpt: t } = this;
325
- this.state = t ? Fe : 0, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = t, this.xmlDeclPossible = !t, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
326
- let { defaultXMLVersion: e } = this.opt;
327
- if (void 0 === e) {
328
- if (!0 === this.opt.forceXMLVersion) throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
329
- e = "1.0";
330
- }
331
- this.setXMLVersion(e), this.positionAtNewLine = 0, this.doctype = !1, this._closed = !1, this.xmlDecl = {
332
- version: void 0,
333
- encoding: void 0,
334
- standalone: void 0
335
- }, this.line = 1, this.column = 0, this.ENTITIES = Object.create(Me), this.readyHandler?.();
336
- }
337
- get position() {
338
- return this.chunkPosition + this.i;
339
- }
340
- get columnIndex() {
341
- return this.position - this.positionAtNewLine;
342
- }
343
- on(t, e) {
344
- this[ns[t]] = e;
345
- }
346
- off(t) {
347
- this[ns[t]] = void 0;
348
- }
349
- makeError(t) {
350
- let e = this.fileName ?? "";
351
- return this.trackPosition && (e.length > 0 && (e += ":"), e += `${this.line}:${this.column}`), e.length > 0 && (e += ": "), new Error(e + t);
352
- }
353
- fail(t) {
354
- const e = this.makeError(t), s = this.errorHandler;
355
- if (void 0 === s) throw e;
356
- return s(e), this;
357
- }
358
- write(t) {
359
- if (this.closed) return this.fail("cannot write after close.");
360
- let e = !1;
361
- null === t ? (e = !0, t = "") : "object" == typeof t && (t = t.toString()), void 0 !== this.carriedFromPrevious && (t = `${this.carriedFromPrevious}${t}`, this.carriedFromPrevious = void 0);
362
- let s = t.length;
363
- const o = t.charCodeAt(s - 1);
364
- !e && (13 === o || o >= 55296 && o <= 56319) && (this.carriedFromPrevious = t[s - 1], s--, t = t.slice(0, s));
365
- const { stateTable: r } = this;
366
- for (this.chunk = t, this.i = 0; this.i < s;) r[this.state].call(this);
367
- return this.chunkPosition += s, e ? this.end() : this;
368
- }
369
- close() {
370
- return this.write(null);
371
- }
372
- getCode10() {
373
- const t = this.chunk, e = this.i;
374
- if (this.prevI = e, this.i++, e >= t.length) return Be;
375
- const s = t.charCodeAt(e);
376
- if (this.column++, s < 55296) {
377
- if (s >= 32 || 9 === s) return s;
378
- switch (s) {
379
- case We: return this.line++, this.column = 0, this.positionAtNewLine = this.position, We;
380
- case 13: return t.charCodeAt(e + 1) === We && (this.i = e + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, je;
381
- default: return this.fail("disallowed character."), s;
382
- }
383
- }
384
- if (s > 56319) return s >= 57344 && s <= 65533 || this.fail("disallowed character."), s;
385
- const o = 65536 + 1024 * (s - 55296) + (t.charCodeAt(e + 1) - 56320);
386
- return this.i = e + 2, o > 1114111 && this.fail("disallowed character."), o;
387
- }
388
- getCode11() {
389
- const { chunk: t, i: e } = this;
390
- if (this.prevI = e, this.i = e + 1, e >= t.length) return Be;
391
- const s = t.charCodeAt(e);
392
- if (this.column++, s < 55296) {
393
- if (s > 31 && s < 127 || s > 159 && 8232 !== s || 9 === s) return s;
394
- switch (s) {
395
- case We: return this.line++, this.column = 0, this.positionAtNewLine = this.position, We;
396
- case 13: {
397
- const s = t.charCodeAt(e + 1);
398
- s !== We && 133 !== s || (this.i = e + 2);
399
- }
400
- case 133:
401
- case 8232: return this.line++, this.column = 0, this.positionAtNewLine = this.position, je;
402
- default: return this.fail("disallowed character."), s;
403
- }
404
- }
405
- if (s > 56319) return s >= 57344 && s <= 65533 || this.fail("disallowed character."), s;
406
- const o = 65536 + 1024 * (s - 55296) + (t.charCodeAt(e + 1) - 56320);
407
- return this.i = e + 2, o > 1114111 && this.fail("disallowed character."), o;
408
- }
409
- getCodeNorm() {
410
- const t = this.getCode();
411
- return t === je ? We : t;
412
- }
413
- unGet() {
414
- this.i = this.prevI, this.column--;
415
- }
416
- captureTo(t) {
417
- let { i: e } = this;
418
- const { chunk: s } = this;
419
- for (;;) {
420
- const o = this.getCode(), r = o === je, n = r ? We : o;
421
- if (n === Be || t.includes(n)) return this.text += s.slice(e, this.prevI), n;
422
- r && (this.text += `${s.slice(e, this.prevI)}\n`, e = this.i);
423
- }
424
- }
425
- captureToChar(t) {
426
- let { i: e } = this;
427
- const { chunk: s } = this;
428
- for (;;) {
429
- let o = this.getCode();
430
- switch (o) {
431
- case je:
432
- this.text += `${s.slice(e, this.prevI)}\n`, e = this.i, o = We;
433
- break;
434
- case Be: return this.text += s.slice(e), !1;
435
- }
436
- if (o === t) return this.text += s.slice(e, this.prevI), !0;
437
- }
438
- }
439
- captureNameChars() {
440
- const { chunk: t, i: e } = this;
441
- for (;;) {
442
- const s = this.getCode();
443
- if (s === Be) return this.name += t.slice(e), Be;
444
- if (!Ie(s)) return this.name += t.slice(e, this.prevI), s === je ? We : s;
445
- }
446
- }
447
- skipSpaces() {
448
- for (;;) {
449
- const t = this.getCodeNorm();
450
- if (t === Be || !Ae(t)) return t;
451
- }
452
- }
453
- setXMLVersion(t) {
454
- this.currentXMLVersion = t, "1.0" === t ? (this.isChar = ke, this.getCode = this.getCode10) : (this.isChar = De, this.getCode = this.getCode11);
455
- }
456
- sBegin() {
457
- 65279 === this.chunk.charCodeAt(0) && (this.i++, this.column++), this.state = 1;
458
- }
459
- sBeginWhitespace() {
460
- const t = this.i, e = this.skipSpaces();
461
- switch (this.prevI !== t && (this.xmlDeclPossible = !1), e) {
462
- case ze:
463
- if (this.state = 15, 0 !== this.text.length) throw new Error("no-empty text at start");
464
- break;
465
- case Be: break;
466
- default: this.unGet(), this.state = Fe, this.xmlDeclPossible = !1;
467
- }
468
- }
469
- sDoctype() {
470
- const t = this.captureTo(Ze);
471
- switch (t) {
472
- case qe:
473
- this.doctypeHandler?.(this.text), this.text = "", this.state = Fe, this.doctype = !0;
474
- break;
475
- case Be: break;
476
- default: this.text += String.fromCodePoint(t), 91 === t ? this.state = 4 : Ge(t) && (this.state = 3, this.q = t);
477
- }
478
- }
479
- sDoctypeQuote() {
480
- const t = this.q;
481
- this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.q = null, this.state = 2);
482
- }
483
- sDTD() {
484
- const t = this.captureTo(Qe);
485
- t !== Be && (this.text += String.fromCodePoint(t), t === Ke ? this.state = 2 : t === ze ? this.state = 6 : Ge(t) && (this.state = 5, this.q = t));
486
- }
487
- sDTDQuoted() {
488
- const t = this.q;
489
- this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.state = 4, this.q = null);
490
- }
491
- sDTDOpenWaka() {
492
- const t = this.getCodeNorm();
493
- switch (this.text += String.fromCodePoint(t), t) {
494
- case 33:
495
- this.state = 7, this.openWakaBang = "";
496
- break;
497
- case Ue:
498
- this.state = 11;
499
- break;
500
- default: this.state = 4;
501
- }
502
- }
503
- sDTDOpenWakaBang() {
504
- const t = String.fromCodePoint(this.getCodeNorm()), e = this.openWakaBang += t;
505
- this.text += t, "-" !== e && (this.state = "--" === e ? 8 : 4, this.openWakaBang = "");
506
- }
507
- sDTDComment() {
508
- this.captureToChar(45) && (this.text += "-", this.state = 9);
509
- }
510
- sDTDCommentEnding() {
511
- const t = this.getCodeNorm();
512
- this.text += String.fromCodePoint(t), this.state = 45 === t ? 10 : 8;
513
- }
514
- sDTDCommentEnded() {
515
- const t = this.getCodeNorm();
516
- this.text += String.fromCodePoint(t), t === qe ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
517
- }
518
- sDTDPI() {
519
- this.captureToChar(Ue) && (this.text += "?", this.state = 12);
520
- }
521
- sDTDPIEnding() {
522
- const t = this.getCodeNorm();
523
- this.text += String.fromCodePoint(t), t === qe && (this.state = 4);
524
- }
525
- sText() {
526
- 0 !== this.tags.length ? this.handleTextInRoot() : this.handleTextOutsideRoot();
527
- }
528
- sEntity() {
529
- let { i: t } = this;
530
- const { chunk: e } = this;
531
- t: for (;;) switch (this.getCode()) {
532
- case je:
533
- this.entity += `${e.slice(t, this.prevI)}\n`, t = this.i;
534
- break;
535
- case 59: {
536
- const { entityReturnState: s } = this, o = this.entity + e.slice(t, this.prevI);
537
- let r;
538
- this.state = s, "" === o ? (this.fail("empty entity name."), r = "&;") : (r = this.parseEntity(o), this.entity = ""), s === Fe && void 0 === this.textHandler || (this.text += r);
539
- break t;
540
- }
541
- case Be:
542
- this.entity += e.slice(t);
543
- break t;
544
- }
545
- }
546
- sOpenWaka() {
547
- const t = this.getCode();
548
- if (Ee(t)) this.state = 34, this.unGet(), this.xmlDeclPossible = !1;
549
- else switch (t) {
550
- case 47:
551
- this.state = 43, this.xmlDeclPossible = !1;
552
- break;
553
- case 33:
554
- this.state = 16, this.openWakaBang = "", this.xmlDeclPossible = !1;
555
- break;
556
- case Ue:
557
- this.state = 23;
558
- break;
559
- default: this.fail("disallowed character in tag name"), this.state = Fe, this.xmlDeclPossible = !1;
560
- }
561
- }
562
- sOpenWakaBang() {
563
- switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
564
- case "[CDATA[":
565
- 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 = "";
566
- break;
567
- case "--":
568
- this.state = 17, this.openWakaBang = "";
569
- break;
570
- case "DOCTYPE":
571
- this.state = 2, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
572
- break;
573
- default: this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
574
- }
575
- }
576
- sComment() {
577
- this.captureToChar(45) && (this.state = 18);
578
- }
579
- sCommentEnding() {
580
- const t = this.getCodeNorm();
581
- 45 === t ? (this.state = 19, this.commentHandler?.(this.text), this.text = "") : (this.text += `-${String.fromCodePoint(t)}`, this.state = 17);
582
- }
583
- sCommentEnded() {
584
- const t = this.getCodeNorm();
585
- t !== qe ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t)}`, this.state = 17) : this.state = Fe;
586
- }
587
- sCData() {
588
- this.captureToChar(Ke) && (this.state = 21);
589
- }
590
- sCDataEnding() {
591
- const t = this.getCodeNorm();
592
- t === Ke ? this.state = 22 : (this.text += `]${String.fromCodePoint(t)}`, this.state = 20);
593
- }
594
- sCDataEnding2() {
595
- const t = this.getCodeNorm();
596
- switch (t) {
597
- case qe:
598
- this.cdataHandler?.(this.text), this.text = "", this.state = Fe;
599
- break;
600
- case Ke:
601
- this.text += "]";
602
- break;
603
- default: this.text += `]]${String.fromCodePoint(t)}`, this.state = 20;
604
- }
605
- }
606
- sPIFirstChar() {
607
- const t = this.getCodeNorm();
608
- this.nameStartCheck(t) ? (this.piTarget += String.fromCodePoint(t), this.state = 24) : t === Ue || Ae(t) ? (this.fail("processing instruction without a target."), this.state = t === Ue ? 26 : 25) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(t), this.state = 24);
609
- }
610
- sPIRest() {
611
- const { chunk: t, i: e } = this;
612
- for (;;) {
613
- const s = this.getCodeNorm();
614
- if (s === Be) return void (this.piTarget += t.slice(e));
615
- if (!this.nameCheck(s)) {
616
- this.piTarget += t.slice(e, this.prevI);
617
- const o = s === Ue;
618
- o || Ae(s) ? "xml" === this.piTarget ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = o ? He : 27) : this.state = o ? 26 : 25 : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(s));
619
- break;
620
- }
621
- }
622
- }
623
- sPIBody() {
624
- if (0 === this.text.length) {
625
- const t = this.getCodeNorm();
626
- t === Ue ? this.state = 26 : Ae(t) || (this.text = String.fromCodePoint(t));
627
- } else this.captureToChar(Ue) && (this.state = 26);
628
- }
629
- sPIEnding() {
630
- const t = this.getCodeNorm();
631
- if (t === qe) {
632
- const { piTarget: t } = this;
633
- "xml" === t.toLowerCase() && this.fail("the XML declaration must appear at the start of the document."), this.piHandler?.({
634
- target: t,
635
- body: this.text
636
- }), this.piTarget = this.text = "", this.state = Fe;
637
- } else t === Ue ? this.text += "?" : (this.text += `?${String.fromCodePoint(t)}`, this.state = 25);
638
- this.xmlDeclPossible = !1;
639
- }
640
- sXMLDeclNameStart() {
641
- const t = this.skipSpaces();
642
- t !== Ue ? t !== Be && (this.state = 28, this.name = String.fromCodePoint(t)) : this.state = He;
643
- }
644
- sXMLDeclName() {
645
- const t = this.captureTo(Ye);
646
- if (t === Ue) return this.state = He, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
647
- if (Ae(t) || t === Xe) {
648
- if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name)) switch (this.name.length) {
649
- case 0:
650
- this.fail("did not expect any more name/value pairs.");
651
- break;
652
- case 1:
653
- this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
654
- break;
655
- default: this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
656
- }
657
- this.state = t === Xe ? 30 : 29;
658
- }
659
- }
660
- sXMLDeclEq() {
661
- const t = this.getCodeNorm();
662
- if (t === Ue) return this.state = He, void this.fail("XML declaration is incomplete.");
663
- Ae(t) || (t !== Xe && this.fail("value required."), this.state = 30);
664
- }
665
- sXMLDeclValueStart() {
666
- const t = this.getCodeNorm();
667
- if (t === Ue) return this.state = He, void this.fail("XML declaration is incomplete.");
668
- Ae(t) || (Ge(t) ? this.q = t : (this.fail("value must be quoted."), this.q = 32), this.state = 31);
669
- }
670
- sXMLDeclValue() {
671
- const t = this.captureTo([this.q, Ue]);
672
- if (t === Ue) return this.state = He, this.text = "", void this.fail("XML declaration is incomplete.");
673
- if (t === Be) return;
674
- const e = this.text;
675
- switch (this.text = "", this.name) {
676
- case "version": {
677
- this.xmlDeclExpects = ["encoding", "standalone"];
678
- const t = e;
679
- this.xmlDecl.version = t, /^1\.[0-9]+$/.test(t) ? this.opt.forceXMLVersion || this.setXMLVersion(t) : this.fail("version number must match /^1\\.[0-9]+$/.");
680
- break;
681
- }
682
- case "encoding":
683
- /^[A-Za-z][A-Za-z0-9._-]*$/.test(e) || this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."), this.xmlDeclExpects = ["standalone"], this.xmlDecl.encoding = e;
684
- break;
685
- case "standalone": "yes" !== e && "no" !== e && this.fail("standalone value must match \"yes\" or \"no\"."), this.xmlDeclExpects = [], this.xmlDecl.standalone = e;
686
- }
687
- this.name = "", this.state = 32;
688
- }
689
- sXMLDeclSeparator() {
690
- const t = this.getCodeNorm();
691
- t !== Ue ? (Ae(t) || (this.fail("whitespace required."), this.unGet()), this.state = 27) : this.state = He;
692
- }
693
- sXMLDeclEnding() {
694
- this.getCodeNorm() === qe ? ("xml" !== this.piTarget ? this.fail("processing instructions are not allowed before root.") : "version" !== this.name && this.xmlDeclExpects.includes("version") && this.fail("XML declaration must contain a version."), this.xmlDeclHandler?.(this.xmlDecl), this.name = "", this.piTarget = this.text = "", this.state = Fe) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = !1;
695
- }
696
- sOpenTag() {
697
- const t = this.captureNameChars();
698
- if (t === Be) return;
699
- const e = this.tag = {
700
- name: this.name,
701
- attributes: Object.create(null)
702
- };
703
- switch (this.name = "", this.xmlnsOpt && (this.topNS = e.ns = Object.create(null)), this.openTagStartHandler?.(e), this.sawRoot = !0, !this.fragmentOpt && this.closedRoot && this.fail("documents may contain only one root."), t) {
704
- case qe:
705
- this.openTag();
706
- break;
707
- case 47:
708
- this.state = 35;
709
- break;
710
- default: Ae(t) || this.fail("disallowed character in tag name."), this.state = 36;
711
- }
712
- }
713
- sOpenTagSlash() {
714
- this.getCode() === qe ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
715
- }
716
- sAttrib() {
717
- const t = this.skipSpaces();
718
- t !== Be && (Ee(t) ? (this.unGet(), this.state = 37) : t === qe ? this.openTag() : 47 === t ? this.state = 35 : this.fail("disallowed character in attribute name."));
719
- }
720
- sAttribName() {
721
- const t = this.captureNameChars();
722
- t === Xe ? this.state = 39 : Ae(t) ? this.state = 38 : t === qe ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t !== Be && this.fail("disallowed character in attribute name.");
723
- }
724
- sAttribNameSawWhite() {
725
- const t = this.skipSpaces();
726
- switch (t) {
727
- case Be: return;
728
- case Xe:
729
- this.state = 39;
730
- break;
731
- default: this.fail("attribute without value."), this.text = "", this.name = "", t === qe ? this.openTag() : Ee(t) ? (this.unGet(), this.state = 37) : (this.fail("disallowed character in attribute name."), this.state = 36);
732
- }
733
- }
734
- sAttribValue() {
735
- const t = this.getCodeNorm();
736
- Ge(t) ? (this.q = t, this.state = 40) : Ae(t) || (this.fail("unquoted attribute value."), this.state = 42, this.unGet());
737
- }
738
- sAttribValueQuoted() {
739
- const { q: t, chunk: e } = this;
740
- let { i: s } = this;
741
- for (;;) switch (this.getCode()) {
742
- case t:
743
- this.pushAttrib(this.name, this.text + e.slice(s, this.prevI)), this.name = this.text = "", this.q = null, this.state = 41;
744
- return;
745
- case 38:
746
- this.text += e.slice(s, this.prevI), this.state = 14, this.entityReturnState = 40;
747
- return;
748
- case We:
749
- case je:
750
- case 9:
751
- this.text += `${e.slice(s, this.prevI)} `, s = this.i;
752
- break;
753
- case ze:
754
- this.text += e.slice(s, this.prevI), this.fail("disallowed character.");
755
- return;
756
- case Be:
757
- this.text += e.slice(s);
758
- return;
759
- }
760
- }
761
- sAttribValueClosed() {
762
- const t = this.getCodeNorm();
763
- Ae(t) ? this.state = 36 : t === qe ? this.openTag() : 47 === t ? this.state = 35 : Ee(t) ? (this.fail("no whitespace between attributes."), this.unGet(), this.state = 37) : this.fail("disallowed character in attribute name.");
764
- }
765
- sAttribValueUnquoted() {
766
- const t = this.captureTo(ts);
767
- switch (t) {
768
- case 38:
769
- this.state = 14, this.entityReturnState = 42;
770
- break;
771
- case ze:
772
- this.fail("disallowed character.");
773
- break;
774
- case Be: break;
775
- default: this.text.includes("]]>") && this.fail("the string \"]]>\" is disallowed in char data."), this.pushAttrib(this.name, this.text), this.name = this.text = "", t === qe ? this.openTag() : this.state = 36;
776
- }
777
- }
778
- sCloseTag() {
779
- const t = this.captureNameChars();
780
- t === qe ? this.closeTag() : Ae(t) ? this.state = 44 : t !== Be && this.fail("disallowed character in closing tag.");
781
- }
782
- sCloseTagSawWhite() {
783
- switch (this.skipSpaces()) {
784
- case qe:
785
- this.closeTag();
786
- break;
787
- case Be: break;
788
- default: this.fail("disallowed character in closing tag.");
789
- }
790
- }
791
- handleTextInRoot() {
792
- let { i: t, forbiddenState: e } = this;
793
- const { chunk: s, textHandler: o } = this;
794
- t: for (;;) switch (this.getCode()) {
795
- case ze:
796
- if (this.state = 15, void 0 !== o) {
797
- const { text: e } = this, r = s.slice(t, this.prevI);
798
- 0 !== e.length ? (o(e + r), this.text = "") : 0 !== r.length && o(r);
799
- }
800
- e = 0;
801
- break t;
802
- case 38:
803
- this.state = 14, this.entityReturnState = Fe, void 0 !== o && (this.text += s.slice(t, this.prevI)), e = 0;
804
- break t;
805
- case Ke:
806
- switch (e) {
807
- case 0:
808
- e = 1;
809
- break;
810
- case 1:
811
- e = 2;
812
- break;
813
- case 2: break;
814
- default: throw new Error("impossible state");
815
- }
816
- break;
817
- case qe:
818
- 2 === e && this.fail("the string \"]]>\" is disallowed in char data."), e = 0;
819
- break;
820
- case je:
821
- void 0 !== o && (this.text += `${s.slice(t, this.prevI)}\n`), t = this.i, e = 0;
822
- break;
823
- case Be:
824
- void 0 !== o && (this.text += s.slice(t));
825
- break t;
826
- default: e = 0;
827
- }
828
- this.forbiddenState = e;
829
- }
830
- handleTextOutsideRoot() {
831
- let { i: t } = this;
832
- const { chunk: e, textHandler: s } = this;
833
- let o = !1;
834
- t: for (;;) {
835
- const r = this.getCode();
836
- switch (r) {
837
- case ze:
838
- if (this.state = 15, void 0 !== s) {
839
- const { text: o } = this, r = e.slice(t, this.prevI);
840
- 0 !== o.length ? (s(o + r), this.text = "") : 0 !== r.length && s(r);
841
- }
842
- break t;
843
- case 38:
844
- this.state = 14, this.entityReturnState = Fe, void 0 !== s && (this.text += e.slice(t, this.prevI)), o = !0;
845
- break t;
846
- case je:
847
- void 0 !== s && (this.text += `${e.slice(t, this.prevI)}\n`), t = this.i;
848
- break;
849
- case Be:
850
- void 0 !== s && (this.text += e.slice(t));
851
- break t;
852
- default: Ae(r) || (o = !0);
853
- }
854
- }
855
- o && (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));
856
- }
857
- pushAttribNS(t, e) {
858
- const { prefix: s, local: o } = this.qName(t), r = {
859
- name: t,
860
- prefix: s,
861
- local: o,
862
- value: e
863
- };
864
- if (this.attribList.push(r), this.attributeHandler?.(r), "xmlns" === s) {
865
- const t = e.trim();
866
- "1.0" === this.currentXMLVersion && "" === t && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[o] = t, es(this, o, t);
867
- } else if ("xmlns" === t) {
868
- const t = e.trim();
869
- this.topNS[""] = t, es(this, "", t);
870
- }
871
- }
872
- pushAttribPlain(t, e) {
873
- const s = {
874
- name: t,
875
- value: e
876
- };
877
- this.attribList.push(s), this.attributeHandler?.(s);
878
- }
879
- end() {
880
- this.sawRoot || this.fail("document must contain a root element.");
881
- const { tags: t } = this;
882
- for (; t.length > 0;) {
883
- const e = t.pop();
884
- this.fail(`unclosed tag: ${e.name}`);
885
- }
886
- 0 !== this.state && this.state !== Fe && this.fail("unexpected end.");
887
- const { text: e } = this;
888
- return 0 !== e.length && (this.textHandler?.(e), this.text = ""), this._closed = !0, this.endHandler?.(), this._init(), this;
889
- }
890
- resolve(t) {
891
- let e = this.topNS[t];
892
- if (void 0 !== e) return e;
893
- const { tags: s } = this;
894
- for (let o = s.length - 1; o >= 0; o--) if (e = s[o].ns[t], void 0 !== e) return e;
895
- return e = this.ns[t], void 0 !== e ? e : this.opt.resolvePrefix?.(t);
896
- }
897
- qName(t) {
898
- const e = t.indexOf(":");
899
- if (-1 === e) return {
900
- prefix: "",
901
- local: t
902
- };
903
- const s = t.slice(e + 1), o = t.slice(0, e);
904
- return ("" === o || "" === s || s.includes(":")) && this.fail(`malformed name: ${t}.`), {
905
- prefix: o,
906
- local: s
907
- };
908
- }
909
- processAttribsNS() {
910
- const { attribList: t } = this, e = this.tag;
911
- {
912
- const { prefix: t, local: s } = this.qName(e.name);
913
- e.prefix = t, e.local = s;
914
- const o = e.uri = this.resolve(t) ?? "";
915
- "" !== t && ("xmlns" === t && this.fail("tags may not have \"xmlns\" as prefix."), "" === o && (this.fail(`unbound namespace prefix: ${JSON.stringify(t)}.`), e.uri = t));
916
- }
917
- if (0 === t.length) return;
918
- const { attributes: s } = e, o = /* @__PURE__ */ new Set();
919
- for (const e of t) {
920
- const { name: t, prefix: r, local: n } = e;
921
- let i, a;
922
- "" === r ? (i = "xmlns" === t ? Le : "", a = t) : (i = this.resolve(r), void 0 === i && (this.fail(`unbound namespace prefix: ${JSON.stringify(r)}.`), i = r), a = `{${i}}${n}`), o.has(a) && this.fail(`duplicate attribute: ${a}.`), o.add(a), e.uri = i, s[t] = e;
923
- }
924
- this.attribList = [];
925
- }
926
- processAttribsPlain() {
927
- const { attribList: t } = this, e = this.tag.attributes;
928
- for (const { name: s, value: o } of t) void 0 !== e[s] && this.fail(`duplicate attribute: ${s}.`), e[s] = o;
929
- this.attribList = [];
930
- }
931
- openTag() {
932
- this.processAttribs();
933
- const { tags: t } = this, e = this.tag;
934
- e.isSelfClosing = !1, this.openTagHandler?.(e), t.push(e), this.state = Fe, this.name = "";
935
- }
936
- openSelfClosingTag() {
937
- this.processAttribs();
938
- const { tags: t } = this, e = this.tag;
939
- e.isSelfClosing = !0, this.openTagHandler?.(e), this.closeTagHandler?.(e), null === (this.tag = t[t.length - 1] ?? null) && (this.closedRoot = !0), this.state = Fe, this.name = "";
940
- }
941
- closeTag() {
942
- const { tags: t, name: e } = this;
943
- if (this.state = Fe, this.name = "", "" === e) return this.fail("weird empty close tag."), void (this.text += "</>");
944
- const s = this.closeTagHandler;
945
- let o = t.length;
946
- for (; o-- > 0;) {
947
- const o = this.tag = t.pop();
948
- if (this.topNS = o.ns, s?.(o), o.name === e) break;
949
- this.fail(`unexpected close tag: ${e}.`);
950
- }
951
- 0 === o ? this.closedRoot = !0 : o < 0 && (this.fail(`unmatched closing tag: ${e}.`), this.text += `</${e}>`);
952
- }
953
- parseEntity(t) {
954
- if ("#" !== t[0]) {
955
- const e = this.ENTITIES[t];
956
- return void 0 !== e ? e : (this.fail(this.isName(t) ? "undefined entity." : "disallowed character in entity name."), `&${t};`);
957
- }
958
- let e = NaN;
959
- return "x" === t[1] && /^#x[0-9a-f]+$/i.test(t) ? e = parseInt(t.slice(2), 16) : /^#[0-9]+$/.test(t) && (e = parseInt(t.slice(1), 10)), this.isChar(e) ? String.fromCodePoint(e) : (this.fail("malformed character entity."), `&${t};`);
960
- }
961
- }, as = /&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, ls = {
962
- amp: "&",
963
- lt: "<",
964
- gt: ">",
965
- quot: "\"",
966
- apos: "'"
967
- }, cs = (t, e) => {
968
- const s = ls[e];
969
- if (void 0 !== s) return s;
970
- const o = 120 === e.charCodeAt(1) ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
971
- return o > 0 && o <= 1114111 ? String.fromCodePoint(o) : t;
972
- }, hs = (t) => {
973
- let e = t;
974
- return -1 !== e.indexOf("\r") && (e = e.replace(/\r\n?/g, "\n")), -1 !== e.indexOf("&") && (e = e.replace(as, cs)), e;
975
- }, us = (t) => {
976
- let e = t;
977
- const s = e.length;
978
- for (let t = 0; t < s; t++) {
979
- const s = e.charCodeAt(t);
980
- if (9 === s || 10 === s || 13 === s) {
981
- e = e.replace(/\r\n|[\t\n\r]/g, " ");
982
- break;
983
- }
984
- }
985
- return -1 !== e.indexOf("&") && (e = e.replace(as, cs)), e;
986
- }, ds = (t) => 32 === t || 9 === t || 10 === t || 13 === t, ps = class t {
987
- constructor() {
988
- 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;
989
- }
990
- static {
991
- this.NEED_MORE = -1;
992
- }
993
- static {
994
- this.NOT_HANDLED = -2;
995
- }
996
- static decodeText(t) {
997
- return hs(t);
998
- }
999
- on(t, e) {
1000
- switch (t) {
1001
- case "opentag":
1002
- this._openTagHandler = e;
1003
- break;
1004
- case "closetag":
1005
- this._closeTagHandler = e;
1006
- break;
1007
- case "text":
1008
- this._textHandler = e;
1009
- break;
1010
- case "cdata":
1011
- this._cdataHandler = e;
1012
- break;
1013
- case "error":
1014
- this._errorHandler = e;
1015
- break;
1016
- case "end": this._endHandler = e;
1017
- }
1018
- }
1019
- setElementScanners(t) {
1020
- if (!t || 0 === t.length) return void (this._scanners = null);
1021
- const e = new Array(128);
1022
- for (const s of t) {
1023
- const t = s.name.charCodeAt(0);
1024
- if (!(t < 128) || void 0 !== e[t]) throw new Error(`Element scanner '${s.name}' needs an ASCII first character no other scanner uses.`);
1025
- e[t] = s;
1026
- }
1027
- this._scanners = e;
1028
- }
1029
- fail(t) {
1030
- const e = new Error(t), s = this._errorHandler;
1031
- if (void 0 === s) throw e;
1032
- s(e);
1033
- }
1034
- write(t) {
1035
- if (this._closed) return this.fail("cannot write after close."), this;
1036
- let e = t;
1037
- 0 !== this._carry.length && (e = this._carry + t, this._carry = "");
1038
- const s = e.length;
1039
- let o = 0;
1040
- for (; o < s;) {
1041
- const t = e.indexOf("<", o);
1042
- if (-1 === t) return this._text += e.slice(o), this;
1043
- t > o && (this._text += e.slice(o, t));
1044
- const r = this._markup(e, t, s);
1045
- if (-1 === r) return this._carry = e.slice(t), this;
1046
- o = r;
1047
- }
1048
- return this;
1049
- }
1050
- close() {
1051
- 0 !== this._carry.length && (this.fail("unexpected end."), this._carry = ""), this._sawRoot || this.fail("document must contain a root element.");
1052
- const t = this._tags;
1053
- for (; t.length > 0;) {
1054
- const e = t.pop();
1055
- this.fail(`unclosed tag: ${e.name}`);
1056
- }
1057
- return this._flushText(), this._closed = !0, this._endHandler?.(), this;
1058
- }
1059
- _flushText() {
1060
- const t = this._text;
1061
- if (0 === t.length) return;
1062
- this._text = "";
1063
- const e = this._textHandler;
1064
- void 0 !== e && 0 !== this._tags.length && e(hs(t));
1065
- }
1066
- _markup(e, s, o) {
1067
- if (s + 1 >= o) return -1;
1068
- const r = e.charCodeAt(s + 1);
1069
- if (47 === r) {
1070
- const t = e.indexOf(">", s + 2);
1071
- return -1 === t ? -1 : (this._flushText(), this._closeTag(e.slice(s + 2, t).trimEnd()), t + 1);
1072
- }
1073
- if (63 === r) {
1074
- const t = e.indexOf("?>", s + 2);
1075
- return -1 === t ? -1 : t + 2;
1076
- }
1077
- if (33 === r) {
1078
- if (s + 4 > o) return -1;
1079
- if (45 === e.charCodeAt(s + 2) && 45 === e.charCodeAt(s + 3)) {
1080
- const t = e.indexOf("-->", s + 4);
1081
- return -1 === t ? -1 : t + 3;
1082
- }
1083
- if (s + 9 > o) return -1;
1084
- if (e.startsWith("[CDATA[", s + 2)) {
1085
- const t = e.indexOf("]]>", s + 9);
1086
- return -1 === t ? -1 : (this._flushText(), this._cdataHandler?.(e.slice(s + 9, t)), t + 3);
1087
- }
1088
- const t = e.indexOf("[", s + 2), r = e.indexOf(">", s + 2);
1089
- if (-1 === r) return -1;
1090
- if (-1 !== t && t < r) {
1091
- const s = e.indexOf("]>", t);
1092
- return -1 === s ? -1 : s + 2;
1093
- }
1094
- return r + 1;
1095
- }
1096
- const n = this._scanners;
1097
- if (null !== n) {
1098
- const i = r < 128 ? n[r] : void 0;
1099
- if (void 0 !== i && e.startsWith(i.name, s + 1)) {
1100
- const r = s + 1 + i.name.length;
1101
- if (r >= o) return -1;
1102
- const n = e.charCodeAt(r);
1103
- if (62 === n || 47 === n || ds(n)) {
1104
- this._flushText();
1105
- const r = i.scan(e, s, o);
1106
- if (r !== t.NOT_HANDLED) {
1107
- if (r !== t.NEED_MORE) {
1108
- this._sawRoot = !0;
1109
- const t = i.openTag;
1110
- void 0 !== t && this._tags.push(t);
1111
- }
1112
- return r;
1113
- }
1114
- }
1115
- }
1116
- }
1117
- return this._openTag(e, s, o);
1118
- }
1119
- _openTag(t, e, s) {
1120
- let o = e + 1, r = 0;
1121
- for (; o < s && (r = t.charCodeAt(o), 62 !== r && 47 !== r && !ds(r));) o++;
1122
- if (o >= s) return -1;
1123
- const n = t.slice(e + 1, o), i = {};
1124
- let a = !1;
1125
- for (;;) {
1126
- for (; o < s && ds(r = t.charCodeAt(o));) o++;
1127
- if (o >= s) return -1;
1128
- if (62 === r) {
1129
- o++;
1130
- break;
1131
- }
1132
- if (47 === r) {
1133
- if (o + 1 >= s) return -1;
1134
- if (62 !== t.charCodeAt(o + 1)) {
1135
- this.fail("forward-slash in opening tag not followed by >."), o++;
1136
- continue;
1137
- }
1138
- a = !0, o += 2;
1139
- break;
1140
- }
1141
- const e = o;
1142
- for (; o < s && (r = t.charCodeAt(o), 61 !== r && 62 !== r && 47 !== r && !ds(r));) o++;
1143
- if (o >= s) return -1;
1144
- const n = t.slice(e, o);
1145
- for (; o < s && ds(r = t.charCodeAt(o));) o++;
1146
- if (o >= s) return -1;
1147
- if (61 !== r) {
1148
- this.fail("attribute without value.");
1149
- continue;
1150
- }
1151
- for (o++; o < s && ds(r = t.charCodeAt(o));) o++;
1152
- if (o >= s) return -1;
1153
- if (34 !== r && 39 !== r) {
1154
- this.fail("unquoted attribute value.");
1155
- continue;
1156
- }
1157
- const l = t.indexOf(34 === r ? "\"" : "'", o + 1);
1158
- if (-1 === l) return -1;
1159
- "__proto__" !== n && (i[n] = us(t.slice(o + 1, l))), o = l + 1;
1160
- }
1161
- this._flushText(), this._sawRoot = !0;
1162
- const l = {
1163
- name: n,
1164
- attributes: i,
1165
- isSelfClosing: a
1166
- };
1167
- return this._openTagHandler?.(l), a ? this._closeTagHandler?.(l) : this._tags.push(l), o;
1168
- }
1169
- _closeTag(t) {
1170
- if ("" === t) return void this.fail("weird empty close tag.");
1171
- const e = this._tags, s = this._closeTagHandler;
1172
- let o = e.length;
1173
- for (; o-- > 0;) {
1174
- const o = e.pop();
1175
- if (s?.(o), o.name === t) return;
1176
- this.fail(`unexpected close tag: ${t}.`);
1177
- }
1178
- this.fail(`unmatched closing tag: ${t}.`);
1179
- }
1180
- };
1181
- (function(t) {
1182
- t.Events = {
1183
- XmlDecl: "xmldecl",
1184
- Text: "text",
1185
- ProcessingInstruction: "processinginstruction",
1186
- Doctype: "doctype",
1187
- Comment: "comment",
1188
- OpenTagStart: "opentagstart",
1189
- Attribute: "attribute",
1190
- OpenTag: "opentag",
1191
- CloseTag: "closetag",
1192
- CDdata: "cdata",
1193
- Error: "error",
1194
- End: "end",
1195
- Ready: "ready"
1196
- };
1197
- t.parseStream = async (t, e, s) => {
1198
- if (s?.lean) return (async (t, e) => {
1199
- const s = new ps();
1200
- let o;
1201
- e.elementScanners && s.setElementScanners(e.elementScanners), e.onOpenTag && s.on("opentag", e.onOpenTag), e.onCloseTag && s.on("closetag", e.onCloseTag), e.onText && s.on("text", e.onText), e.onError && s.on("error", e.onError);
1202
- const r = e.onEnd;
1203
- for (r && s.on("end", () => {
1204
- o = r();
1205
- });;) {
1206
- const { value: e, done: o } = await t.read();
1207
- if (o) break;
1208
- s.write(e);
1209
- }
1210
- return s.close(), o;
1211
- })(t, e);
1212
- const o = new is({
1213
- position: !1,
1214
- ...s
1215
- });
1216
- let r;
1217
- e.onOpenTagStart && o.on(ss.Events.OpenTagStart, e.onOpenTagStart), e.onOpenTag && o.on(ss.Events.OpenTag, e.onOpenTag), e.onCloseTag && o.on(ss.Events.CloseTag, e.onCloseTag), e.onAttribute && o.on(ss.Events.Attribute, e.onAttribute), e.onText && o.on(ss.Events.Text, e.onText), e.onError && o.on(ss.Events.Error, e.onError);
1218
- const n = e.onEnd;
1219
- if (n) {
1220
- const t = () => {
1221
- r = n();
1222
- };
1223
- o.on(ss.Events.End, t);
1224
- }
1225
- for (;;) {
1226
- const { value: e, done: s } = await t.read();
1227
- if (s) break;
1228
- o.write(e);
1229
- }
1230
- return o.close(), r;
1231
- };
1232
- })(ss || (ss = {}));
1233
- var fs = (t) => !0 === t || "1" === t || "on" === t || "true" === t || !1 !== t && "0" !== t && "off" !== t && "false" !== t && null, gs = (t) => {
1234
- const e = parseInt(t);
1235
- return isNaN(e) ? null : e;
1236
- }, ms = (t) => {
1237
- const e = parseFloat(t);
1238
- return isNaN(e) ? null : e;
1239
- }, bs = null, xs = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), ys = (t) => xs(t).replace(/"/g, "&quot;"), vs = class {
1240
- constructor() {
1241
- this._registeredVisitors = /* @__PURE__ */ new Map();
1242
- }
1243
- registerVisitor(t) {
1244
- this._registeredVisitors.set(t.from, t);
1245
- }
1246
- createEventHandler(t, e, s) {
1247
- const o = this._registeredVisitors, r = [], n = [];
1248
- let i = null, a = null, l = null, c = null;
1249
- const h = [], u = {
1250
- key: null,
1251
- source: t,
1252
- parent: null
1253
- };
1254
- let d = null, p = !1, f = null, g = null, m = null;
1255
- const b = (t, e) => {
1256
- let s = l.attributes[t];
1257
- if (e) if (Array.isArray(e)) {
1258
- const t = e.length;
1259
- for (let o = 0; o < t; o++) {
1260
- if (null == s) return;
1261
- if (s = e[o](s), null == s) return;
1262
- }
1263
- } else {
1264
- if (null == s) return;
1265
- if (s = e(s), null == s) return;
1266
- }
1267
- return s;
1268
- }, x = {
1269
- getSource: () => d?.source ?? null,
1270
- setSource: (t) => {
1271
- d.source = t;
1272
- },
1273
- setKey: (t) => {
1274
- d.key = t;
1275
- },
1276
- getFrom: () => l,
1277
- getAttribute: (t, e) => b(t, e) ?? null,
1278
- hasAttribute: (t) => null !== x.getAttribute(t),
1279
- getParent: () => {
1280
- const t = h[h.length - 2];
1281
- return t.parent ?? t.source;
1282
- },
1283
- getPath: () => {
1284
- const t = [], e = n.length;
1285
- for (let s = 0; s < e; s++) t.push(n[s].local);
1286
- return t.join("\\");
1287
- },
1288
- parseAttribute: b,
1289
- getRawXml: () => m,
1290
- copyToObject: (t, e, s, o) => {
1291
- const r = b(o ?? e, s);
1292
- void 0 !== r && (t[e] = r);
1293
- },
1294
- copyTo: (t, e, s) => {
1295
- const o = b(s ?? t, e);
1296
- void 0 !== o && (d.source[t] = o);
1297
- },
1298
- warn: (t, e) => {
1299
- s ? s(t, void 0, e?.onceKey) : console.warn(t);
1300
- }
1301
- };
1302
- return {
1303
- onOpenTag: (t) => {
1304
- let e = t.name;
1305
- const s = e.indexOf(":");
1306
- if (-1 !== s && (e = e.slice(s + 1)), f) return f.push(((t) => {
1307
- const e = t.attributes ?? {};
1308
- let s = `<${t.name}`;
1309
- for (const t in e) {
1310
- const o = e[t];
1311
- s += ` ${t}="${ys("string" == typeof o ? o : o?.value ?? "")}"`;
1312
- }
1313
- return s + ">";
1314
- })(t)), i = {
1315
- local: e,
1316
- tag: t,
1317
- destination: null
1318
- }, n.push(i), a = e, void (l = t);
1319
- const m = (r.length > 0 ? r[r.length - 1] : o).get(e);
1320
- if (i = {
1321
- local: e,
1322
- visitor: m,
1323
- tag: t,
1324
- destination: null
1325
- }, p) return n.push(i), a = e, void (l = t);
1326
- c = i?.visitor ?? null, a = e, l = t;
1327
- let b = !!m && null === m.to;
1328
- if (m && !b && m.scope) {
1329
- const t = m.scope(x);
1330
- null === t ? b = !0 : t && (r.push(t), i.pushedScope = !0);
1331
- }
1332
- m && (0 === n.length ? (d = u, i.destination = d, i.pushedDestination = !0, h.push(d)) : b ? (d = null, i.destination = null) : m.transparent ? i.destination = d : (d = {
1333
- key: null,
1334
- source: {},
1335
- parent: null
1336
- }, i.destination = d, i.pushedDestination = !0, h.push(d))), n.push(i), p = b;
1337
- const y = c?.openTag?.(x);
1338
- void 0 !== y && (d.parent = y), m?.raw && !b && (f = [], g = i);
1339
- },
1340
- onCloseTag: (t) => {
1341
- let e = t.name;
1342
- const o = e.indexOf(":");
1343
- if (-1 !== o && (e = e.slice(o + 1)), e !== a) throw new Error(`mismatch open/close tag: '${e}'/'${a}'`);
1344
- let b = !1;
1345
- if (f) {
1346
- if (n[n.length - 1] !== g) return f.push(`</${t.name}>`), n.pop(), i = n[n.length - 1] ?? null, a = i?.local ?? null, void (l = i?.tag ?? null);
1347
- m = f.join(""), f = null, g = null, b = !0;
1348
- }
1349
- p || c?.closeTag?.(x), b && (m = null);
1350
- const y = n.pop() ?? null;
1351
- i = n[n.length - 1] ?? null, y?.pushedScope && r.pop();
1352
- const v = y?.destination;
1353
- if (v && y.pushedDestination) {
1354
- h.pop(), d = h[h.length - 1] ?? u;
1355
- const t = y.visitor;
1356
- t && t.to && void 0 !== v.source && (Array.isArray(t.to) ? d.source.push ? d.source.push(v.source) : s?.(`Unable to parse array for ${t.from} at ${x.getPath()}`) : v.key ? d.source[v.key] = v.source : "string" == typeof t.to && (d.source[t.to] = v.source));
1357
- } else v || (d = h[h.length - 1] ?? u);
1358
- a = i?.local ?? null, l = i?.tag ?? null, c = i?.visitor ?? null, p = !i?.destination;
1359
- },
1360
- onText: (t) => {
1361
- f ? f.push(xs(t)) : c?.text?.(t, x);
1362
- },
1363
- onEnd: e
1364
- };
1365
- }
1366
- }, ws = `IFERROR(${C}(`, Ts = ws.toUpperCase(), Ss = s.toUpperCase(), Cs = { kind: "none" }, As = { kind: "spilled" }, ks = (t, e) => {
1367
- if (34 !== t.charCodeAt(e)) return null;
1368
- let s = "", o = e + 1;
1369
- for (; o < t.length;) if (34 === t.charCodeAt(o)) {
1370
- if (34 !== t.charCodeAt(o + 1)) return {
1371
- value: s,
1372
- end: o + 1
1373
- };
1374
- s += "\"", o += 2;
1375
- } else s += t[o], o++;
1376
- return null;
1377
- }, Es = (t) => {
1378
- const e = [];
1379
- let s = 0;
1380
- for (; s < t.length;) {
1381
- const o = t.charCodeAt(s);
1382
- if (34 === o) {
1383
- const e = ks(t, s);
1384
- if (null === e) break;
1385
- s = e.end;
1386
- continue;
1387
- }
1388
- if (!(o >= 65 && o <= 90 || o >= 97 && o <= 122 || 95 === o)) {
1389
- s++;
1390
- continue;
1391
- }
1392
- let r = s + 1;
1393
- for (; r < t.length;) {
1394
- const e = t.charCodeAt(r);
1395
- if (!(e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57 || 95 === e || 46 === e)) break;
1396
- r++;
1397
- }
1398
- 40 === t.charCodeAt(r) && e.push(t.slice(s, r).toUpperCase().replace(/^_XLFN\./, "").replace(/^_XLWS\./, "")), s = r;
1399
- }
1400
- return e;
1401
- }, Is = class {
1402
- constructor(t) {
1403
- this._restored = [], this._byColumn = /* @__PURE__ */ new Map(), this._isKnown = t;
1404
- }
1405
- anchor(t, e, s) {
1406
- const o = this._byColumn.get(e);
1407
- o && t === o.rowEnd + 1 && t > o.rowStart && (o.closed = !0);
1408
- const r = Es(s);
1409
- let n = !0;
1410
- for (let t = 0; t < r.length && n; t++) n = this._isKnown(r[t]);
1411
- const i = {
1412
- rowStart: t,
1413
- colStart: e,
1414
- rowEnd: t,
1415
- colEnd: e,
1416
- closed: !1,
1417
- restored: n
1418
- };
1419
- return this._byColumn.set(e, i), n && this._restored.push(i), n;
1420
- }
1421
- placeholder(t, e) {
1422
- const s = this._byColumn.get(e);
1423
- if (s && !s.closed && t > s.rowStart && t <= s.rowEnd + 1 && e >= s.colStart && e <= s.colEnd) return s.rowEnd = t, s.restored;
1424
- const o = this._byColumn.get(e - 1);
1425
- return !(!o || o.rowStart !== t || o.colEnd !== e - 1) && (o.colEnd = e, this._byColumn.set(e, o), o.restored);
1426
- }
1427
- getFormulaArray() {
1428
- return this._restored.map((t) => [Tt.rangeToString(t), "dynamic"]);
1429
- }
1430
- }, Ps = /^\s*TABLE\s*\(([^()]*)\)\s*$/i, Os = /^\s*(\$?)([A-Za-z]{1,3})(\$?)(\d{1,7})\s*$/, Ds = (t) => {
1431
- const e = Os.exec(t);
1432
- if (!e) return null;
1433
- const s = Tt.fastStringToCol(e[2]), o = parseInt(e[4], 10) - 1;
1434
- return s < 0 || o < 0 ? null : {
1435
- row: o,
1436
- col: s,
1437
- colAbsolute: "$" === e[1],
1438
- rowAbsolute: "$" === e[3]
1439
- };
1440
- }, _s = (t) => Tt.cellToString({
1441
- rowIndex: t.row,
1442
- colIndex: t.col
1443
- }), Ns = (t, e) => {
1444
- const s = Ps.exec(t);
1445
- if (!s) return null;
1446
- const o = s[1].split(",");
1447
- if (3 !== o.length && 5 !== o.length) return null;
1448
- const r = [];
1449
- for (let t = 0; t < o.length; t++) {
1450
- const e = Ds(o[t]);
1451
- if (!e) return null;
1452
- r.push(e);
1453
- }
1454
- const n = e.rowStart, i = e.colStart, a = (t) => t.colAbsolute && !t.rowAbsolute && t.col === i - 1 && t.row === n, l = (t) => t.rowAbsolute && !t.colAbsolute && t.row === n - 1 && t.col === i, c = {
1455
- rowStart: n,
1456
- colStart: i,
1457
- rowEnd: e.rowEnd,
1458
- colEnd: e.colEnd
1459
- }, h = r[0];
1460
- if (3 === r.length) {
1461
- const [, t, e] = r;
1462
- return a(e) && l(h) ? {
1463
- ref: c,
1464
- columnInput: _s(t)
1465
- } : l(e) && a(h) ? {
1466
- ref: c,
1467
- rowInput: _s(t)
1468
- } : null;
1469
- }
1470
- if (!h.rowAbsolute || !h.colAbsolute || h.row !== n - 1 || h.col !== i - 1) return null;
1471
- const [, u, d, p, f] = r;
1472
- return a(d) && l(f) ? {
1473
- ref: c,
1474
- rowInput: _s(p),
1475
- columnInput: _s(u)
1476
- } : l(d) && a(f) ? {
1477
- ref: c,
1478
- rowInput: _s(u),
1479
- columnInput: _s(p)
1480
- } : null;
1481
- }, $s = /^(?:(\d{4})-(\d{2})-(\d{2}))?T?(?:(\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?)?(?:Z|[+-]\d{2}:?\d{2})?$/, Rs = /^PT(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?$/, Ls = (t, e, s) => {
1482
- const o = Math.floor((14 - e) / 12), r = t + 4800 - o, n = e + 12 * o - 3;
1483
- return s + Math.floor((153 * n + 2) / 5) + 365 * r + Math.floor(r / 4) - Math.floor(r / 100) + Math.floor(r / 400) - 32045;
1484
- }, Vs = Ls(1899, 12, 30), Ms = (t) => {
1485
- const e = t.indexOf(":");
1486
- return -1 === e ? t : t.slice(e + 1);
1487
- }, Bs = class {
1488
- constructor() {
1489
- this._runs = null, this._text = "", this._font = null, this._inRun = !1, this._inRPr = !1;
1490
- }
1491
- reset() {
1492
- this._runs = null, this._inRun = !1, this._inRPr = !1;
1493
- }
1494
- onOpenTag(t, e) {
1495
- "r" === t ? (this._inRun = !0, this._text = "", this._font = null, this._runs ??= []) : "rPr" === t ? this._inRun && (this._inRPr = !0) : this._inRPr && function(t, e, s) {
1496
- switch (t) {
1497
- case "b":
1498
- s.weight = Hs(e) ? 700 : 400;
1499
- break;
1500
- case "i":
1501
- s.style = Hs(e) ? _t.Style.Italic : _t.Style.Normal;
1502
- break;
1503
- case "strike":
1504
- s.strike = n(Hs(e));
1505
- break;
1506
- case "outline":
1507
- s.outline = Hs(e);
1508
- break;
1509
- case "shadow":
1510
- s.shadow = Hs(e);
1511
- break;
1512
- case "condense":
1513
- case "extend": {
1514
- const o = a(t, Hs(e));
1515
- void 0 !== o && (s.letterSpacing = o);
1516
- break;
1517
- }
1518
- case "u":
1519
- s.underline = m(e.val);
1520
- break;
1521
- case "vertAlign": {
1522
- const t = ut(e.val);
1523
- void 0 !== t && (s.baseline = t);
1524
- break;
1525
- }
1526
- case "sz": {
1527
- const t = parseFloat(e.val ?? "");
1528
- isNaN(t) || (s.size = t);
1529
- break;
1530
- }
1531
- case "rFont": {
1532
- const t = e.val;
1533
- t && (s.family = t);
1534
- break;
1535
- }
1536
- case "family": {
1537
- const t = Fs[e.val ?? ""];
1538
- t && (s.fallbacks = [t]);
1539
- break;
1540
- }
1541
- case "charset": {
1542
- const t = parseInt(e.val ?? "", 10);
1543
- isNaN(t) || (s.charset = t);
1544
- break;
1545
- }
1546
- case "scheme":
1547
- S(s, e.val);
1548
- break;
1549
- case "color": {
1550
- const t = e.rgb;
1551
- if (t && void 0 === e.theme) {
1552
- s.color = "#" + (8 === t.length ? t.substring(2) : t).toUpperCase();
1553
- break;
1554
- }
1555
- const o = gt((t) => e[t]);
1556
- o && (s.color = o);
1557
- break;
1558
- }
1559
- }
1560
- }(t, e, this._font ??= {});
1561
- }
1562
- onText(t) {
1563
- this._inRun && (this._text += t);
1564
- }
1565
- onCloseTag(t) {
1566
- if ("rPr" === t) this._inRPr = !1, this._font ??= {};
1567
- else if ("r" === t && this._inRun) {
1568
- const t = k(this._text), e = this._font;
1569
- this._runs.push(e ? {
1570
- text: t,
1571
- font: e
1572
- } : { text: t }), this._inRun = !1;
1573
- }
1574
- }
1575
- take() {
1576
- const t = this._runs;
1577
- if (this.reset(), !t) return null;
1578
- for (let e = 0; e < t.length; e++) if (t[e].font) return t;
1579
- return null;
1580
- }
1581
- };
1582
- function js(t, e) {
1583
- const s = {
1584
- family: "Calibri",
1585
- size: 11,
1586
- ...e,
1587
- weight: 400,
1588
- style: _t.Style.Normal,
1589
- underline: _t.UnderlineStyle.None,
1590
- strike: _t.StrikeStyle.None,
1591
- baseline: 0
1592
- }, o = new Array(t.length);
1593
- for (let e = 0; e < t.length; e++) {
1594
- const r = t[e];
1595
- if (!r.font) {
1596
- o[e] = r;
1597
- continue;
1598
- }
1599
- const n = {
1600
- ...s,
1601
- ...r.font
1602
- };
1603
- o[e] = {
1604
- text: r.text,
1605
- font: n
1606
- };
1607
- }
1608
- return o;
1609
- }
1610
- var Fs = {
1611
- 1: "serif",
1612
- 2: "sans-serif",
1613
- 3: "monospace",
1614
- 4: "cursive",
1615
- 5: "fantasy"
1616
- }, Hs = (t) => {
1617
- const e = t.val;
1618
- return void 0 === e || "1" === e || "true" === e;
1619
- };
1620
- var Ws = (t) => {
1621
- const e = (e) => {
1622
- if (t) return new RegExp(`<(?:[\\w.-]+:)?${e}\\b[^>]*>([^<]*)<`).exec(t)?.[1];
1623
- }, s = (t) => {
1624
- const e = parseInt(t ?? "", 10);
1625
- return isNaN(e) ? 0 : e;
1626
- };
1627
- return {
1628
- c: s(e("col")),
1629
- r: s(e("row")),
1630
- x: Y(e("colOff") ?? "0") ?? 0,
1631
- y: Y(e("rowOff") ?? "0") ?? 0
1632
- };
1633
- }, zs = "formulaDialect", Xs = "isKnownFunction", qs = "date1904", Us = "richStrings", Ks = "defaultFont", Gs = (t, e, s, o, n, a, c, f) => {
1634
- const m = new vs(), v = (t) => {
1635
- const e = t.getAttribute("dxfId", gs);
1636
- if (null === e) return;
1637
- return o?.get(e) || (a?.(`A color filter or sort names a format that does not exist (dxfId '${e}').`), {});
1638
- };
1639
- let S = !1;
1640
- const C = f?.get("parseInlineDxf"), E = f?.get(zs), I = (t) => E && t ? E.readDetached(t) : t, P = new Ft.TransposedBuilder();
1641
- let D = null, N = "topLeft";
1642
- m.registerVisitor({
1643
- from: "autoFilter",
1644
- to: "autoTable",
1645
- openTag: (t) => {
1646
- const e = t.getAttribute("ref"), s = Tt.fastStringToRange(e);
1647
- t.getSource().r = s, t.getSource().v = {};
1648
- },
1649
- closeTag: (t) => {
1650
- const e = t.getSource(), s = e.v, o = s.hiddenButtons;
1651
- if (Array.isArray(o)) {
1652
- const t = o.length, r = e.r, n = r.colEnd - r.colStart + 1;
1653
- 0 === t ? s.hiddenButtons = !1 : t === n && (s.hiddenButtons = !0);
1654
- }
1655
- }
1656
- }), m.registerVisitor({
1657
- from: "conditionalFormatting",
1658
- to: {},
1659
- openTag: (t) => {
1660
- const e = t.getParent();
1661
- e.conditionals || (e.conditionals = []);
1662
- let s = t.getAttribute("sqref");
1663
- s && (s = s.trim().split(/\s+/).join(","));
1664
- const o = {
1665
- r: s,
1666
- conditionals: e.conditionals
1667
- }, r = t.getAttribute("pivot", fs);
1668
- null !== r && (o.pivot = r), t.setSource(o);
1669
- }
1670
- }), m.registerVisitor({
1671
- from: "cfRule",
1672
- to: {},
1673
- openTag: (t) => {
1674
- const e = t.getParent();
1675
- if (!e?.r) return;
1676
- const s = t.getSource() ?? {};
1677
- void 0 !== e.pivot && (s.pivot = e.pivot), e.conditionals.push({
1678
- r: e.r,
1679
- v: null,
1680
- rule: s
1681
- }), t.copyToObject(s, "type", bs), t.copyToObject(s, "priority", gs), t.copyToObject(s, "stopIfTrue", fs);
1682
- const r = t.getAttribute("dxfId", gs);
1683
- if (null !== r) {
1684
- let e = o?.get(r);
1685
- e || (a?.(`Unable to load conditional color. Invalid dxfI: '${r}' at '${t.getPath()}'.`), e = {}), s.style = e;
1686
- }
1687
- t.copyToObject(s, "aboveAverage", fs), t.copyToObject(s, "equalAverage", fs), t.copyToObject(s, "stdDev", gs), t.copyToObject(s, "bottom", fs), t.copyToObject(s, "percent", fs), t.copyToObject(s, "rank", gs), t.copyToObject(s, "operator", bs), t.copyToObject(s, "text", bs), t.copyToObject(s, "timePeriod", bs);
1688
- },
1689
- closeTag: (t) => {
1690
- const e = t.getParent();
1691
- if (!e?.r) return;
1692
- const s = e.conditionals[e.conditionals.length - 1], o = s?.rule;
1693
- if (!o) return;
1694
- const r = {}, n = $(o, a);
1695
- n && (r.condition = n), o.style && (r.style = o.style), o.scale && (r.scale = o.scale), o.stopIfTrue && (r.stopIfTrue = !0), o.pivot && (r.pivot = !0), s.v = r, s.priority = o.priority, o.x14Id && (s.x14Id = o.x14Id), delete s.rule;
1696
- }
1697
- });
1698
- const R = (t) => {
1699
- const e = t.conditions ?? [], s = [];
1700
- for (let t = 0; t < e.length; t++) {
1701
- const o = e[t], r = {};
1702
- o.type && (r.type = o.type), void 0 !== o.value && (r.value = o.value), o.exclusive && (r.exclusive = !0), s.push(r);
1703
- }
1704
- return s;
1705
- };
1706
- m.registerVisitor({
1707
- from: "colorScale",
1708
- to: {},
1709
- openTag: (t) => {},
1710
- closeTag: (t) => {
1711
- const e = t.getSource(), s = e.colors ?? [], o = R(e);
1712
- for (let t = 0; t < o.length; t++) o[t].color = s[t];
1713
- t.getParent().scale = {
1714
- type: Ot.ScaleType.ColorScale,
1715
- stops: o
1716
- };
1717
- }
1718
- }), m.registerVisitor({
1719
- from: "dataBar",
1720
- to: {},
1721
- openTag: (t) => {
1722
- t.copyTo("maxLength", gs), t.copyTo("minLength", gs), t.copyTo("showValue", fs);
1723
- },
1724
- closeTag: (t) => {
1725
- const e = t.getSource(), s = {
1726
- type: Ot.ScaleType.DataBar,
1727
- stops: R(e)
1728
- }, o = e.colors?.[0];
1729
- o && (s.color = o), void 0 !== e.minLength && (s.minLength = e.minLength), void 0 !== e.maxLength && (s.maxLength = e.maxLength), void 0 !== e.showValue && (s.showValue = e.showValue), t.getParent().scale = s;
1730
- }
1731
- }), m.registerVisitor({
1732
- from: "iconSet",
1733
- to: {},
1734
- openTag: (t) => {
1735
- t.copyTo("iconSet", bs), t.copyTo("reverse", fs), t.copyTo("showValue", fs);
1736
- },
1737
- closeTag: (t) => {
1738
- const e = t.getSource(), s = {
1739
- type: Ot.ScaleType.IconSet,
1740
- stops: R(e)
1741
- };
1742
- void 0 !== e.iconSet && (s.iconSet = e.iconSet), void 0 !== e.reverse && (s.reverse = e.reverse), void 0 !== e.showValue && (s.showValue = e.showValue), t.getParent().scale = s;
1743
- }
1744
- }), m.registerVisitor({
1745
- from: "formula",
1746
- to: {},
1747
- text: (t, e) => {
1748
- const s = e.getParent();
1749
- let o = s.formulas;
1750
- o || (o = [], s.formulas = o), o.push(I(t));
1751
- }
1752
- }), m.registerVisitor({
1753
- from: "cfvo",
1754
- to: {},
1755
- openTag: (t) => {
1756
- const e = t.getParent();
1757
- e.conditions || (e.conditions = []);
1758
- const s = t.getSource();
1759
- if (e.conditions.push(s), t.copyTo("type", bs), s.type === Ot.ColorStopType.Formula) {
1760
- const e = t.getAttribute("val");
1761
- null != e && (s.value = I(String(e)));
1762
- } else t.copyTo("value", ms, "val");
1763
- !1 === t.getAttribute("gte", fs) && (s.exclusive = !0);
1764
- }
1765
- }), m.registerVisitor({
1766
- from: "color",
1767
- to: {},
1768
- openTag: (t) => {
1769
- const e = t.getParent();
1770
- e.colors || (e.colors = []);
1771
- const s = gt((e) => t.getAttribute(e));
1772
- e.colors.push(s);
1773
- }
1774
- }), m.registerVisitor({
1775
- from: "filterColumn",
1776
- to: {},
1777
- openTag: (t) => {
1778
- const e = t.getParent().v, s = parseInt(t.getAttribute("colId")), o = t.getSource();
1779
- o.index = s;
1780
- let r = e.filter;
1781
- r || (r = { conditions: [] }, e.filter = r);
1782
- let n = r.conditions;
1783
- if (n || (n = [], r.conditions = n), n.push(o), t.getAttribute("hiddenButton", fs) && e) {
1784
- let t = e.hiddenButtons;
1785
- t || (t = [], e.hiddenButtons = t), t.push(s);
1786
- }
1787
- if (t.getAttribute("showButton", fs) && e) {
1788
- let t = e.showButtons;
1789
- t || (t = [], e.showButtons = t), t.push(s);
1790
- }
1791
- return o;
1792
- }
1793
- }), m.registerVisitor({
1794
- from: "colorFilter",
1795
- openTag: (t) => {
1796
- const e = t.getParent(), s = {};
1797
- e.operator = Pt.BuiltInOperatorNames.Color, e.param = s, t.copyToObject(s, "cellColor", fs);
1798
- const o = v(t);
1799
- o && (s.style = o);
1800
- }
1801
- }), m.registerVisitor({
1802
- from: "iconFilter",
1803
- openTag: (t) => {
1804
- const e = t.getParent(), s = {};
1805
- e.operator = Pt.BuiltInOperatorNames.Icon, e.param = s, t.copyToObject(s, "iconId", gs), t.copyToObject(s, "iconSet", bs);
1806
- }
1807
- }), m.registerVisitor({
1808
- from: "top10",
1809
- openTag: (t) => {
1810
- const e = t.getParent(), s = {};
1811
- e.operator = Pt.BuiltInOperatorNames.TopN, e.param = s, t.copyToObject(s, "filterVal", ms), t.copyToObject(s, "percent", fs), t.copyToObject(s, "top", fs), t.copyToObject(s, "limit", ms, "val");
1812
- }
1813
- }), m.registerVisitor({
1814
- from: "dynamicFilter",
1815
- openTag: (t) => {
1816
- const e = t.getParent(), s = L(t.getAttribute("type"));
1817
- e.operator = s.operator, e.param = s.param;
1818
- }
1819
- });
1820
- const V = {
1821
- from: "filters",
1822
- to: {},
1823
- openTag: (t) => {
1824
- const e = t.getParent(), s = {};
1825
- return e.selector = Pt.BuiltInSelectorNames.Display, e.operator = Pt.BuiltInOperatorNames.InSet, e.param = s, t.copyToObject(s, "blank", fs), t.copyToObject(s, "calendarType", bs), s;
1826
- }
1827
- };
1828
- m.registerVisitor(V);
1829
- const M = {
1830
- from: "filter",
1831
- openTag: (t) => {
1832
- const e = t.getParent();
1833
- let s = e.items;
1834
- s || (s = [], e.items = s), s.push(t.getAttribute("val", bs));
1835
- }
1836
- };
1837
- m.registerVisitor(M);
1838
- const B = {
1839
- from: "dateGroupItem",
1840
- to: {},
1841
- openTag: (t) => {
1842
- const e = t.getParent();
1843
- let s = e.dateGroups;
1844
- s || (s = [], e.dateGroups = s), s.push(t.getSource()), t.copyTo("group", bs, "dateTimeGrouping"), t.copyTo("day", gs), t.copyTo("hour", gs), t.copyTo("minute", gs), t.copyTo("month", gs), t.copyTo("second", gs), t.copyTo("year", gs);
1845
- }
1846
- };
1847
- m.registerVisitor(B);
1848
- const H = /* @__PURE__ */ new Map();
1849
- H.set("filterColumn", {
1850
- from: "filterColumn",
1851
- transparent: !0
1852
- }), H.set("filters", V), H.set("filter", M), H.set("dateGroupItem", B), m.registerVisitor({
1853
- from: "customFilters",
1854
- openTag: (t) => {
1855
- const e = t.getParent(), s = t.getAttribute("and"), o = "and" === s || "1" === s, r = [];
1856
- return e.operator = o ? Pt.BuiltInOperatorNames.And : Pt.BuiltInOperatorNames.Or, e.param = r, t.setSource(e), r;
1857
- },
1858
- closeTag: (t) => {
1859
- const e = t.getSource(), s = e?.param;
1860
- if (!e || !s) return;
1861
- const o = 1 === s.length ? s[0] : nt(e);
1862
- o !== e && (e.operator = o.operator, e.param = o.param);
1863
- }
1864
- }), m.registerVisitor({
1865
- from: "customFilter",
1866
- openTag: (t) => {
1867
- const e = t.getParent();
1868
- let s;
1869
- Array.isArray(e) ? (s = {}, e.push(s)) : s = e;
1870
- const o = ot({
1871
- operator: t.getAttribute("operator"),
1872
- val: t.getAttribute("val")
1873
- }, (e) => t.warn(e));
1874
- o && (s.operator = o.operator, s.param = o.param);
1875
- }
1876
- });
1877
- let z = {}, X = null;
1878
- m.registerVisitor({
1879
- from: "sortState",
1880
- to: {},
1881
- openTag: (t) => {
1882
- const e = t.getParent();
1883
- let s = e.v;
1884
- if (!s) return;
1885
- const o = {};
1886
- z = {};
1887
- const r = t.getAttribute("caseSensitive", fs);
1888
- null != r && (z.collatorOptions = r ? Bt.CaseSensitiveOptions : Bt.CaseInsensitiveOptions);
1889
- const n = t.getAttribute("sortMethod");
1890
- "stroke" !== n && "pinYin" !== n || (z.collatorOptions = {
1891
- ...z.collatorOptions,
1892
- collation: "stroke" === n ? "stroke" : "pinyin"
1893
- }), t.getAttribute("columnSort", fs) && (o.axis = Nt.Axis.Column);
1894
- const i = t.getAttribute("ref"), a = e.r;
1895
- X = i && a ? Tt.fastStringToRange(i) : null, X && (o.extent = { range: h(a, X) }), s.sort = o, t.setSource(e);
1896
- }
1897
- }), m.registerVisitor({
1898
- from: "sortCondition",
1899
- to: {},
1900
- openTag: (t) => {
1901
- const e = t.getParent(), s = e.v;
1902
- if (!s) return;
1903
- const o = s.sort;
1904
- if (!o) return;
1905
- let r = o.sorts;
1906
- r || (r = [], o.sorts = r);
1907
- const n = t.getAttribute("ref");
1908
- let i = 0, a = null;
1909
- if (n) {
1910
- const t = Tt.fastStringToRange(n, Ys), s = t.colStart, o = e.r, r = o.colStart;
1911
- i = o ? s - r : s, o && X && (a = x(o, X, t));
1912
- }
1913
- o.extent && (o.extent.sorts ??= []).push(a);
1914
- const l = { ...z }, c = et(t.getAttribute("sortBy"));
1915
- c && (l.sortOn = c);
1916
- const h = v(t);
1917
- h && (l.style = h), t.copyToObject(l, "iconSet", bs), t.copyToObject(l, "customList", bs), l.reverse = t.getAttribute("descending", fs) ?? !1;
1918
- const u = {
1919
- index: i,
1920
- criteria: l
1921
- };
1922
- r.push(u);
1923
- }
1924
- });
1925
- const U = (t) => {
1926
- D = t.getSource(), N = "topLeft", t.copyTo("topLeft", bs, "topLeftCell");
1927
- const e = d(t.getAttribute("defaultGridColor")), s = t.getAttribute("colorId");
1928
- null === s || e || (t.getSource().gridLineColor = "index" + parseFloat(s)), t.copyTo("showZeros", fs), t.copyTo("showFormulas", fs), t.copyTo("zoomScale", gs), t.copyTo("viewMode", bs, "view");
1929
- const o = {};
1930
- for (const [e, s] of lt) {
1931
- const r = t.getAttribute(s, gs);
1932
- r && (o[e] = Math.min(400, Math.max(10, r)));
1933
- }
1934
- Object.keys(o).length > 0 && (t.getSource().zoomScales = o), t.copyTo("showRuler", fs), t.copyTo("showWhitespace", fs, "showWhiteSpace"), t.copyTo("windowProtection", fs), t.copyTo("showRowHeaders", fs, "showRowColHeaders"), t.copyTo("showColumnHeaders", fs, "showRowColHeaders"), t.copyTo("showRowGridlines", fs, "showGridLines"), t.copyTo("showColumnGridlines", fs, "showGridLines"), t.copyTo("rightToLeft", fs), t.copyTo("showOutlineSymbols", fs);
1935
- };
1936
- m.registerVisitor({
1937
- from: "sheetView",
1938
- to: "view",
1939
- openTag: (t) => {
1940
- U(t);
1941
- },
1942
- closeTag: () => {
1943
- D = null;
1944
- }
1945
- }), m.registerVisitor({
1946
- from: "customSheetViews",
1947
- to: "customSheetViews",
1948
- openTag: (t) => {
1949
- t.setSource([]);
1950
- }
1951
- }), m.registerVisitor({
1952
- from: "customSheetView",
1953
- to: [],
1954
- openTag: (t) => {
1955
- K = !0, U(t);
1956
- },
1957
- closeTag: () => {
1958
- K = !1, D = null;
1959
- }
1960
- }), m.registerVisitor({
1961
- from: "selection",
1962
- to: null,
1963
- openTag: (t) => {
1964
- if (!D) return;
1965
- const e = t.getAttribute("activeCell")?.replace(/\$/g, ""), s = t.getAttribute("sqref")?.replace(/\$/g, ""), o = t.getAttribute("pane") ?? "topLeft";
1966
- if (o !== N) {
1967
- const t = D.freezePanes;
1968
- if (t && e) {
1969
- const r = { activeCell: e };
1970
- s && s !== e && (r.sqref = s), (t.paneSelections ??= {})[o] = r;
1971
- }
1972
- return;
1973
- }
1974
- const r = {};
1975
- e && (r.cell = e);
1976
- const n = t.getAttribute("activeCellId", gs);
1977
- null !== n && (r.rangeIndex = n), s && s !== e && (r.ranges = s.trim().split(/\s+/)), D.selection = r;
1978
- }
1979
- }), m.registerVisitor({
1980
- from: "pane",
1981
- to: null,
1982
- openTag: (t) => {
1983
- if (!D) return;
1984
- N = t.getAttribute("activePane") ?? "topLeft";
1985
- const e = t.getAttribute("state");
1986
- if ("frozen" === e || "frozenSplit" === e) {
1987
- const e = {};
1988
- D.freezePanes = e, t.copyToObject(e, "topLeft", bs, "topLeftCell");
1989
- const s = (D.topLeft ? Tt.fastStringToCell(D.topLeft) : void 0) ?? {
1990
- colIndex: 0,
1991
- rowIndex: 0
1992
- }, o = {
1993
- colIndex: 0,
1994
- rowIndex: 0
1995
- };
1996
- t.copyToObject(o, "colIndex", gs, "xSplit"), t.copyToObject(o, "rowIndex", gs, "ySplit");
1997
- const r = {
1998
- colIndex: s.colIndex + o.colIndex,
1999
- rowIndex: s.rowIndex + o.rowIndex
2000
- };
2001
- e.coords = Tt.cellToString(r);
2002
- }
2003
- }
2004
- }), m.registerVisitor({
2005
- from: "sheetPr",
2006
- transparent: !0,
2007
- openTag: (e) => {
2008
- const s = e.getAttribute("codeName");
2009
- s && (t.codeName = s), !1 === e.getAttribute("enableFormatConditionsCalculation", fs) && (t.conditionalFormatCalculation = !1), !0 === e.getAttribute("transitionEvaluation", fs) && (t.transitionFormulaEvaluation = !0), !0 === e.getAttribute("transitionEntry", fs) && (t.transitionFormulaEntry = !0), !1 === e.getAttribute("published", fs) && (t.excludeFromPublishing = !0);
2010
- const o = {};
2011
- !0 === e.getAttribute("syncHorizontal", fs) && (o.horizontal = !0), !0 === e.getAttribute("syncVertical", fs) && (o.vertical = !0);
2012
- const r = e.getAttribute("syncRef");
2013
- r && (o.anchor = r), Object.keys(o).length > 0 && (t.syncScroll = o);
2014
- }
2015
- }), m.registerVisitor({
2016
- from: "tabColor",
2017
- to: null,
2018
- openTag: (e) => {
2019
- const s = gt((t) => e.getAttribute(t));
2020
- s && (t.tabColor = s);
2021
- }
2022
- });
2023
- let K = !1;
2024
- const G = () => t.pageLayout ??= {};
2025
- m.registerVisitor({
2026
- from: "pageSetUpPr",
2027
- to: null,
2028
- openTag: (t) => {
2029
- !0 === t.getAttribute("fitToPage", fs) && (G().fitToPage = !0), !1 === t.getAttribute("autoPageBreaks", fs) && (G().hideAutoPageBreaks = !0);
2030
- }
2031
- }), m.registerVisitor({
2032
- from: "outlinePr",
2033
- to: null,
2034
- openTag: (e) => {
2035
- const s = (t) => {
2036
- const s = e.getAttribute(t);
2037
- return "0" === s || "false" === s;
2038
- }, o = {};
2039
- s("summaryBelow") && (o.summaryRow = "up"), s("summaryRight") && (o.summaryColumn = "left"), ((t) => {
2040
- const s = e.getAttribute(t);
2041
- return "1" === s || "true" === s;
2042
- })("applyStyles") && (o.automaticStyles = !0), Object.keys(o).length > 0 && (t.outline = o);
2043
- }
2044
- }), m.registerVisitor({
2045
- from: "pageMargins",
2046
- to: null,
2047
- openTag: (t) => {
2048
- if (K) return;
2049
- const e = (e, s) => t.getAttribute(e, ms) ?? s, s = {
2050
- left: e("left", .7),
2051
- right: e("right", .7),
2052
- top: e("top", .75),
2053
- bottom: e("bottom", .75),
2054
- header: e("header", .3),
2055
- footer: e("footer", .3)
2056
- };
2057
- .7 === s.left && .7 === s.right && .75 === s.top && .75 === s.bottom && .3 === s.header && .3 === s.footer || (G().margins = s);
2058
- }
2059
- }), m.registerVisitor({
2060
- from: "pageSetup",
2061
- to: null,
2062
- openTag: (t) => {
2063
- if (K) return;
2064
- const s = G(), o = (e) => t.getAttribute(e, gs) ?? void 0, r = (e) => t.getAttribute(e, fs), n = t.getAttribute("orientation");
2065
- "landscape" !== n && "portrait" !== n || (s.orientation = n);
2066
- for (const t of [
2067
- "paperSize",
2068
- "scale",
2069
- "fitToWidth",
2070
- "fitToHeight",
2071
- "firstPageNumber",
2072
- "horizontalDpi",
2073
- "verticalDpi",
2074
- "copies"
2075
- ]) {
2076
- const e = o(t);
2077
- void 0 !== e && (s[t] = e);
2078
- }
2079
- const i = t.getAttribute("paperHeight");
2080
- i && (s.paperHeight = i);
2081
- const a = t.getAttribute("paperWidth");
2082
- a && (s.paperWidth = a), "overThenDown" === t.getAttribute("pageOrder") && (s.printOrder = "overThenDown"), !0 === r("blackAndWhite") && (s.blackAndWhite = !0), !0 === r("draft") && (s.draftMode = !0), !0 === r("useFirstPageNumber") && (s.useFirstPageNumber = !0), !1 === r("usePrinterDefaults") && (s.ignorePrinterDefaults = !0);
2083
- const l = t.getAttribute("cellComments"), c = W.find(([t]) => t === l)?.[1];
2084
- c && (s.printComments = c);
2085
- const h = t.getAttribute("errors"), u = O.find(([t]) => t === h)?.[1];
2086
- u && (s.printErrors = u);
2087
- const d = t.getAttribute("r:id"), p = d ? e(d, "part") : null;
2088
- p && (s.printerSettings = p);
2089
- }
2090
- }), m.registerVisitor({
2091
- from: "printOptions",
2092
- to: null,
2093
- openTag: (t) => {
2094
- if (K) return;
2095
- const e = (e) => !0 === t.getAttribute(e, fs);
2096
- e("horizontalCentered") && (G().centerHorizontally = !0), e("verticalCentered") && (G().centerVertically = !0), e("gridLines") && (G().printGridlines = !0), e("headings") && (G().printHeadings = !0);
2097
- }
2098
- }), m.registerVisitor({
2099
- from: "headerFooter",
2100
- to: {},
2101
- openTag: (t) => {
2102
- if (K) return;
2103
- const e = {}, s = (e) => t.getAttribute(e, fs);
2104
- !0 === s("differentOddEven") && (e.differentOddEven = !0), !0 === s("differentFirst") && (e.differentFirst = !0), !1 === s("scaleWithDoc") && (e.ignoreSheetScale = !0), !1 === s("alignWithMargins") && (e.ignoreSheetMargins = !0), Object.keys(e).length > 0 && (G().headerFooter = e);
2105
- }
2106
- });
2107
- for (const t of j) m.registerVisitor({
2108
- from: t,
2109
- to: {},
2110
- text: (e, s) => {
2111
- if (K) return;
2112
- const o = G(), r = o.headerFooter ??= {};
2113
- r[t] = (r[t] ?? "") + k(e);
2114
- }
2115
- });
2116
- let J = "rowBreaks";
2117
- for (const [t, e] of [["rowBreaks", "rowBreaks"], ["colBreaks", "columnBreaks"]]) m.registerVisitor({
2118
- from: t,
2119
- to: {},
2120
- openTag: () => {
2121
- J = e;
2122
- }
2123
- });
2124
- m.registerVisitor({
2125
- from: "brk",
2126
- to: null,
2127
- openTag: (t) => {
2128
- if (K) return;
2129
- const e = t.getAttribute("id", gs);
2130
- if (null == e) return;
2131
- const s = { index: e }, o = t.getAttribute("min", gs);
2132
- null != o && (s.min = o);
2133
- const r = t.getAttribute("max", gs);
2134
- null != r && (s.max = r), !0 !== t.getAttribute("man", fs) && (s.automatic = !0), !0 === t.getAttribute("pt", fs) && (s.pivot = !0);
2135
- const n = G();
2136
- (n[J] ??= []).push(s);
2137
- }
2138
- }), m.registerVisitor({
2139
- from: "ignoredErrors",
2140
- transparent: !0
2141
- }), m.registerVisitor({
2142
- from: "ignoredError",
2143
- to: null,
2144
- openTag: (e) => {
2145
- const s = e.getAttribute("sqref");
2146
- if (!s) return;
2147
- const o = [];
2148
- for (const t of u) !0 === e.getAttribute(t, fs) && o.push(t);
2149
- if (0 !== o.length) for (const e of s.trim().split(/\s+/)) (t.ignoredErrors ??= []).push({
2150
- r: e,
2151
- v: o
2152
- });
2153
- }
2154
- }), m.registerVisitor({
2155
- from: "mergeCells",
2156
- to: "merges",
2157
- openTag: (t) => {
2158
- t.setSource([]);
2159
- }
2160
- }), m.registerVisitor({
2161
- from: "dataValidations",
2162
- to: "validations",
2163
- openTag: (e) => {
2164
- e.setSource([]);
2165
- const s = {};
2166
- !0 === e.getAttribute("disablePrompts", fs) && (s.disablePrompts = !0);
2167
- const o = e.getAttribute("xWindow", gs);
2168
- null !== o && (s.windowX = o);
2169
- const r = e.getAttribute("yWindow", gs);
2170
- null !== r && (s.windowY = r), Object.keys(s).length > 0 && (t.validationSettings = {
2171
- ...t.validationSettings,
2172
- ...s
2173
- });
2174
- }
2175
- });
2176
- const Z = {
2177
- from: "dataValidation",
2178
- to: [],
2179
- openTag: (t) => {
2180
- let e = t.getAttribute("sqref");
2181
- e && (e = e.trim().split(/\s+/).join(","));
2182
- const s = {}, o = {
2183
- r: e,
2184
- v: s,
2185
- rule: {
2186
- type: t.getAttribute("type") ?? void 0,
2187
- operator: t.getAttribute("operator") ?? void 0
2188
- }
2189
- };
2190
- !0 === t.getAttribute("showDropDown", fs) && (s.hideDropdown = !0), t.copyToObject(s, "alert", bs, "error"), t.copyToObject(s, "alertTitle", bs, "errorTitle"), t.copyToObject(s, "showAlertMessage", fs, "showErrorMessage"), s.alertStyle = t.getAttribute("errorStyle") ?? "stop", t.copyToObject(s, "imeMode"), t.copyToObject(s, "prompt"), t.copyToObject(s, "promptTitle"), t.copyToObject(s, "showPromptMessage", fs, "showInputMessage"), t.setSource(o);
2191
- },
2192
- closeTag: (t) => {
2193
- const e = t.getSource();
2194
- if (!e?.rule) return;
2195
- const s = y(e.rule, a);
2196
- s && (t.getAttribute("allowBlank", fs) && (s.includeBlanks = !0), e.v.condition = s), delete e.rule;
2197
- }
2198
- };
2199
- m.registerVisitor(Z), m.registerVisitor({
2200
- from: "formula1",
2201
- to: {},
2202
- text: (t, e) => {
2203
- const s = e.getParent().rule;
2204
- s?.type && (s.formula1 = A(I(t), s.type));
2205
- }
2206
- }), m.registerVisitor({
2207
- from: "formula2",
2208
- to: {},
2209
- text: (t, e) => {
2210
- const s = e.getParent().rule;
2211
- s?.type && (s.formula2 = A(I(t), s.type));
2212
- }
2213
- }), m.registerVisitor({
2214
- from: "picture",
2215
- to: "picture",
2216
- openTag: (t) => {
2217
- const s = t.getAttribute("r:id");
2218
- if (!s) return void t.warn("A picture names no image; it was not imported.", { onceKey: "xlsx.sheet.picture.noRel" });
2219
- const o = e(s, "resource");
2220
- t.getSource().resId = o;
2221
- }
2222
- });
2223
- const Q = {
2224
- from: "slicer",
2225
- to: {},
2226
- openTag: (t) => {
2227
- const s = t.getAttribute("r:id");
2228
- if (!s) return void t.warn("A slicer names no cache; it was not imported.", { onceKey: "xlsx.sheet.slicer.noRel" });
2229
- const o = e(s)?.slicers, r = t.getParent();
2230
- r.slicers || (r.slicers = {});
2231
- const n = Object.keys(o);
2232
- for (const t of n) r.slicers[t] = o[t];
2233
- }
2234
- };
2235
- m.registerVisitor(Q);
2236
- const Y = (t, e) => ({
2237
- from: t,
2238
- to: {},
2239
- openTag: (t) => {
2240
- t.setSource("");
2241
- },
2242
- text: (t, e) => {
2243
- e.setSource((e.getSource() ?? "") + t);
2244
- },
2245
- closeTag: (t) => {
2246
- e(String(t.getSource() ?? ""), t);
2247
- }
2248
- }), tt = /* @__PURE__ */ new Map();
2249
- tt.set("dataValidations", {
2250
- from: "dataValidations",
2251
- to: "validations",
2252
- openTag: (t) => {
2253
- const e = t.getParent();
2254
- t.setSource(e.validations ?? []);
2255
- },
2256
- closeTag: (t) => {
2257
- 0 === (t.getSource()?.length ?? 0) && t.setSource(void 0);
2258
- }
2259
- }), tt.set("dataValidation", {
2260
- ...Z,
2261
- closeTag: (t) => {
2262
- Z.closeTag(t);
2263
- const e = t.getSource();
2264
- e && !e.r && (t.warn("x14 dataValidation with no xm:sqref was dropped."), t.setSource(void 0));
2265
- }
2266
- });
2267
- const st = (t) => ({
2268
- from: t,
2269
- to: {},
2270
- openTag: (e) => {
2271
- e.setSource({
2272
- rule: e.getParent()?.rule,
2273
- key: t
2274
- });
2275
- }
2276
- });
2277
- tt.set("formula1", st("formula1")), tt.set("formula2", st("formula2")), tt.set("f", Y("f", (t, e) => {
2278
- const s = e.getParent(), o = s?.rule;
2279
- o && (o[s.key] = A(I(t), o.type));
2280
- })), tt.set("sqref", Y("sqref", (t, e) => {
2281
- const s = e.getParent(), o = t.trim();
2282
- s && o && (s.r = o.split(/\s+/).join(","));
2283
- }));
2284
- const rt = /* @__PURE__ */ new Map(), it = [], at = /* @__PURE__ */ new Map();
2285
- at.set("conditionalFormattings", {
2286
- from: "conditionalFormattings",
2287
- transparent: !0
2288
- }), at.set("conditionalFormatting", {
2289
- from: "conditionalFormatting",
2290
- to: {},
2291
- openTag: (t) => {
2292
- t.setSource({ rules: [] });
2293
- },
2294
- closeTag: (t) => {
2295
- const e = t.getSource(), s = e?.rules ?? [];
2296
- for (let t = 0; t < s.length; t++) {
2297
- const o = s[t];
2298
- o.sqref = e.sqref, o.id ? rt.set(o.id, o) : it.push(o);
2299
- }
2300
- }
2301
- }), at.set("cfRule", {
2302
- from: "cfRule",
2303
- to: {},
2304
- openTag: (t) => {
2305
- t.copyTo("id", bs), t.copyTo("type", bs), t.copyTo("priority", gs), t.copyTo("stopIfTrue", fs), t.copyTo("operator", bs), t.copyTo("text", bs), t.copyTo("timePeriod", bs), t.copyTo("aboveAverage", fs), t.copyTo("equalAverage", fs), t.copyTo("stdDev", gs), t.copyTo("bottom", fs), t.copyTo("percent", fs), t.copyTo("rank", gs);
2306
- },
2307
- closeTag: (t) => {
2308
- const e = t.getSource();
2309
- e && t.getParent()?.rules?.push(e);
2310
- }
2311
- }), at.set("sqref", Y("sqref", (t, e) => {
2312
- const s = e.getParent(), o = t.trim();
2313
- s && o && (s.sqref = o);
2314
- })), at.set("dataBar", {
2315
- from: "dataBar",
2316
- to: {},
2317
- openTag: (t) => {
2318
- t.copyTo("minLength", gs), t.copyTo("maxLength", gs), t.copyTo("gradient", fs), t.copyTo("border", fs), t.copyTo("direction", bs), t.copyTo("axisPosition", bs), t.copyTo("negativeBarColorSameAsPositive", fs), t.copyTo("negativeBarBorderColorSameAsPositive", fs);
2319
- },
2320
- closeTag: (t) => {
2321
- t.getParent().dataBar = t.getSource();
2322
- }
2323
- }), at.set("iconSet", {
2324
- from: "iconSet",
2325
- to: {},
2326
- openTag: (t) => {
2327
- t.copyTo("iconSet", bs), t.copyTo("custom", fs), t.copyTo("reverse", fs), t.copyTo("showValue", fs);
2328
- },
2329
- closeTag: (t) => {
2330
- t.getParent().iconSet = t.getSource();
2331
- }
2332
- });
2333
- const ct = /* @__PURE__ */ new Map();
2334
- ct.set("f", Y("f", (t, e) => {
2335
- const s = e.getParent();
2336
- if (!s) return;
2337
- const o = t.trim(), r = Number(o);
2338
- s.value = o.length > 0 && Number.isFinite(r) ? r : I(t);
2339
- })), at.set("cfvo", {
2340
- from: "cfvo",
2341
- to: {},
2342
- scope: () => ct,
2343
- openTag: (t) => {
2344
- const e = t.getParent();
2345
- e.conditions || (e.conditions = []);
2346
- const s = t.getSource();
2347
- e.conditions.push(s), t.copyTo("type", bs), !1 === t.getAttribute("gte", fs) && (s.exclusive = !0);
2348
- }
2349
- }), at.set("f", Y("f", (t, e) => {
2350
- const s = e.getParent();
2351
- s && (s.formulas ??= []).push(I(t));
2352
- })), at.set("dxf", {
2353
- from: "dxf",
2354
- to: {},
2355
- raw: !0,
2356
- closeTag: (t) => {
2357
- if (!C) return;
2358
- const e = t.getParent();
2359
- if (!e) return;
2360
- const s = C(t.getRawXml() ?? "");
2361
- s && (e.style = s);
2362
- }
2363
- });
2364
- const ut = (t) => ({
2365
- from: t,
2366
- to: {},
2367
- openTag: (e) => {
2368
- const s = gt((t) => e.getAttribute(t));
2369
- s && (e.getParent()[t] = s);
2370
- }
2371
- });
2372
- at.set("borderColor", ut("borderColor")), at.set("negativeFillColor", ut("negativeFillColor")), at.set("negativeBorderColor", ut("negativeBorderColor")), at.set("axisColor", ut("axisColor")), at.set("cfIcon", {
2373
- from: "cfIcon",
2374
- to: {},
2375
- openTag: (t) => {
2376
- const e = t.getAttribute("iconSet"), s = t.getAttribute("iconId", gs);
2377
- if (null === e || null === s) return;
2378
- const o = t.getParent();
2379
- o.icons || (o.icons = []), o.icons.push({
2380
- set: e,
2381
- id: s
2382
- });
2383
- }
2384
- });
2385
- const dt = /* @__PURE__ */ new Map();
2386
- dt.set("id", Y("id", (t, e) => {
2387
- const s = e.getParent(), o = t.trim();
2388
- s && o && (s.x14Id = o);
2389
- }));
2390
- const pt = /* @__PURE__ */ new Map();
2391
- pt.set("slicerList", {
2392
- from: "slicerList",
2393
- transparent: !0
2394
- }), pt.set("slicer", Q);
2395
- const mt = /* @__PURE__ */ new Map([
2396
- [p(T), tt],
2397
- [p(r), at],
2398
- [p(ht), at],
2399
- [p(w), dt],
2400
- [p(g), pt],
2401
- [p(q), pt],
2402
- [p(i), H]
2403
- ]), bt = /* @__PURE__ */ new Set();
2404
- m.registerVisitor({
2405
- from: "extLst",
2406
- transparent: !0
2407
- }), m.registerVisitor({
2408
- from: "ext",
2409
- transparent: !0,
2410
- scope: (t) => {
2411
- const e = t.getAttribute("uri"), s = p(e), o = mt.get(s);
2412
- if (o) return o;
2413
- if (!b.has(s) && !bt.has(s)) {
2414
- bt.add(s);
2415
- const o = l[s];
2416
- t.warn(o ? `Extension content '${o}' (${e}) is not read; it will be lost on resave.` : `Unknown extension content (uri ${e}) is not read; it will be lost on resave.`);
2417
- }
2418
- return null;
2419
- }
2420
- }), m.registerVisitor({
2421
- from: "mergeCell",
2422
- to: [],
2423
- openTag: (t) => {
2424
- const e = t.getAttribute("ref");
2425
- t.setSource(e);
2426
- }
2427
- }), m.registerVisitor({
2428
- from: "hyperlinks",
2429
- to: "hyperlinks",
2430
- openTag: (t) => {
2431
- t.setSource([]);
2432
- }
2433
- }), m.registerVisitor({
2434
- from: "hyperlink",
2435
- to: [],
2436
- openTag: (t) => {
2437
- const s = t.getAttribute("r:id"), o = t.getAttribute("ref");
2438
- if (!o) return void t.warn("A hyperlink has no ref; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.noRef" });
2439
- t.setKey(o);
2440
- let r = s ? e(s) : "";
2441
- if ("string" != typeof r) return void t.warn("A hyperlink has an invalid address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2442
- r.endsWith("\\") && (r = r.substring(0, r.length - 1));
2443
- const n = t.getAttribute("location");
2444
- if (n && (r += "#" + n), !r) return void t.warn("A hyperlink has no address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2445
- let i;
2446
- const a = t.getAttribute("tooltip"), l = t.getAttribute("display");
2447
- a || l ? (i = { address: r }, a && (i.screenTip = a), l && (i.display = l)) : i = r, t.setSource({
2448
- r: o,
2449
- v: i
2450
- });
2451
- }
2452
- }), m.registerVisitor({
2453
- from: "drawing",
2454
- to: "movables",
2455
- openTag: (t) => {
2456
- const s = t.getAttribute("r:id");
2457
- if (!s) return;
2458
- const o = e(s);
2459
- o ? t.setSource(o.movables) : t.warn("A drawing part is missing; its shapes were not imported.", { onceKey: "xlsx.sheet.drawing.missing" });
2460
- }
2461
- }), m.registerVisitor({
2462
- from: "legacyDrawing",
2463
- to: "legacyDrawing",
2464
- openTag: (t) => {
2465
- t.setSource(e(t.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2466
- }
2467
- }), m.registerVisitor({
2468
- from: "legacyDrawingHF",
2469
- to: "legacyDrawingHF",
2470
- openTag: (t) => {
2471
- t.setSource(e(t.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2472
- }
2473
- });
2474
- let xt = null, yt = !1;
2475
- const vt = /* @__PURE__ */ new Map(), wt = {
2476
- from: "Fallback",
2477
- to: null
2478
- }, St = {
2479
- from: "Choice",
2480
- transparent: !0
2481
- };
2482
- vt.set("Fallback", wt), vt.set("Choice", St), vt.set("control", {
2483
- from: "control",
2484
- transparent: !0,
2485
- openTag: (t) => {
2486
- const s = t.getAttribute("name"), o = t.getAttribute("r:id"), r = o ? e(o, "formControl") : null;
2487
- if (!r) return t.warn(`The form control '${s ?? ""}' has no properties and was not read.`, { onceKey: "xlsx.sheet.control.noProperties" }), void (xt = null);
2488
- const n = r.json, i = parseInt(t.getAttribute("shapeId") ?? "", 10);
2489
- isNaN(i) || (n.shapeId = i);
2490
- const a = {
2491
- anchor: {
2492
- tl: {
2493
- c: 0,
2494
- r: 0,
2495
- x: 0,
2496
- y: 0
2497
- },
2498
- br: {
2499
- c: 0,
2500
- r: 0,
2501
- x: 0,
2502
- y: 0
2503
- }
2504
- },
2505
- content: {
2506
- type: r.type,
2507
- json: n
2508
- }
2509
- };
2510
- s && (a.content.name = s), xt = {
2511
- movable: a,
2512
- control: n
2513
- };
2514
- },
2515
- closeTag: () => {
2516
- xt && (t.movables || (t.movables = []), t.movables.push(xt.movable), xt = null);
2517
- }
2518
- }), vt.set("controlPr", {
2519
- from: "controlPr",
2520
- transparent: !0,
2521
- raw: !0,
2522
- openTag: (t) => {
2523
- if (!xt) return;
2524
- const e = t.getFrom().attributes ?? {}, s = {};
2525
- for (const t in e) {
2526
- const o = e[t];
2527
- s[t] = "string" == typeof o ? o : o?.value ?? "";
2528
- }
2529
- F(s, xt.control);
2530
- },
2531
- closeTag: (t) => {
2532
- if (!xt) return;
2533
- const e = ((t) => {
2534
- const e = /<(?:[\w.-]+:)?anchor\b([^>]*)>([\s\S]*?)<\/(?:[\w.-]+:)?anchor>/.exec(t);
2535
- if (!e) return null;
2536
- const s = e[2], o = (t) => new RegExp(`<(?:[\\w.-]+:)?${t}\\b[^>]*>([\\s\\S]*?)<\\/(?:[\\w.-]+:)?${t}>`).exec(s)?.[1], r = e[1], n = /\bmoveWithCells="(?:1|true)"/.test(r), i = /\bsizeWithCells="(?:1|true)"/.test(r);
2537
- return {
2538
- anchor: {
2539
- tl: Ws(o("from")),
2540
- br: Ws(o("to"))
2541
- },
2542
- anchorType: n ? i ? "twoCell" : "oneCell" : "absolute",
2543
- rest: (t.slice(0, e.index) + t.slice(e.index + e[0].length)).trim()
2544
- };
2545
- })(t.getRawXml() ?? "");
2546
- e ? (xt.movable.anchor = e.anchor, "twoCell" !== e.anchorType && (xt.movable.anchorType = e.anchorType), e.rest && (xt.control.xml = e.rest)) : yt || (yt = !0, t.warn("A form control has no anchor; it is placed at the top left of the sheet."));
2547
- }
2548
- });
2549
- const Ct = {
2550
- from: "controls",
2551
- transparent: !0,
2552
- scope: () => vt
2553
- };
2554
- m.registerVisitor(Ct);
2555
- const At = /* @__PURE__ */ new Map([
2556
- ["Choice", St],
2557
- ["Fallback", wt],
2558
- ["controls", Ct]
2559
- ]);
2560
- m.registerVisitor({
2561
- from: "AlternateContent",
2562
- transparent: !0,
2563
- scope: () => At
2564
- }), m.registerVisitor({
2565
- from: "tableParts",
2566
- to: "tables",
2567
- openTag: (t) => {
2568
- t.setSource([]);
2569
- }
2570
- }), m.registerVisitor({
2571
- from: "tablePart",
2572
- to: [],
2573
- openTag: (t) => {
2574
- const s = t.getAttribute("r:id");
2575
- if (!s) return;
2576
- const o = e(s);
2577
- o ? t.setSource(o) : t.warn("A table part is missing; the table was not imported.", { onceKey: "xlsx.sheet.table.missing" });
2578
- }
2579
- });
2580
- const kt = (t, e) => {
2581
- e.conditions?.length && (t.stops = R(e)), void 0 !== e.minLength && (t.minLength = e.minLength), void 0 !== e.maxLength && (t.maxLength = e.maxLength), (e.gradient ?? 1) && (t.gradient = !0), e.border && e.borderColor && (t.borderColor = e.borderColor), !e.negativeBarColorSameAsPositive && e.negativeFillColor && (t.negativeFillColor = e.negativeFillColor), !(e.negativeBarBorderColorSameAsPositive ?? 1) && e.negativeBorderColor && (t.negativeBorderColor = e.negativeBorderColor), e.axisColor && (t.axisColor = e.axisColor), "middle" !== e.axisPosition && "none" !== e.axisPosition || (t.axisPosition = e.axisPosition), "leftToRight" !== e.direction && "rightToLeft" !== e.direction || (t.direction = e.direction);
2582
- }, Et = (t, e) => {
2583
- e.conditions?.length && (t.stops = R(e)), e.iconSet && e.iconSet !== t.iconSet && (t.iconSet = e.iconSet), e.icons?.length && (t.icon = e.icons), void 0 !== e.reverse && (t.reverse = e.reverse), void 0 !== e.showValue && (t.showValue = e.showValue);
2584
- }, It = (t) => {
2585
- if (!t.sqref) return null;
2586
- const e = t.sqref.split(/\s+/).join(",");
2587
- if ("iconSet" === t.type) {
2588
- if (!t.iconSet) return null;
2589
- const s = {
2590
- type: Ot.ScaleType.IconSet,
2591
- stops: []
2592
- };
2593
- return Et(s, t.iconSet), {
2594
- r: e,
2595
- v: { scale: s },
2596
- priority: t.priority
2597
- };
2598
- }
2599
- const s = $(t, a);
2600
- if (!s) return null;
2601
- const o = { condition: s };
2602
- return t.style && (o.style = t.style), t.stopIfTrue && (o.stopIfTrue = !0), {
2603
- r: e,
2604
- v: o,
2605
- priority: t.priority
2606
- };
2607
- };
2608
- m.registerVisitor({
2609
- from: "worksheet",
2610
- to: {},
2611
- openTag: (t) => {},
2612
- closeTag: (t) => {
2613
- const e = t.getSource();
2614
- let s = e?.conditionals;
2615
- if (s) for (let t = 0; t < s.length; t++) {
2616
- const e = s[t], o = e.x14Id;
2617
- if (!o) continue;
2618
- delete e.x14Id;
2619
- const r = rt.get(o);
2620
- if (!r) continue;
2621
- rt.delete(o);
2622
- const n = e.v?.scale;
2623
- r.dataBar && n?.type === Ot.ScaleType.DataBar ? kt(n, r.dataBar) : r.iconSet && n?.type === Ot.ScaleType.IconSet && Et(n, r.iconSet);
2624
- }
2625
- const o = [...rt.values(), ...it], r = /* @__PURE__ */ new Set();
2626
- let n = 0;
2627
- for (let t = 0; t < o.length; t++) {
2628
- const i = It(o[t]);
2629
- i ? (s || (s = [], e.conditionals = s), s.push(i)) : (r.add(o[t].type ?? "unknown"), n++);
2630
- }
2631
- if (n > 0) {
2632
- const t = [...r].map((t) => `'${t}'`).join(", ");
2633
- a?.(1 === n ? `An x14-only conditional formatting rule (type ${t}) is not read and will be lost on resave.` : `${n} x14-only conditional formatting rules (types ${t}) are not read and will be lost on resave.`);
2634
- }
2635
- if (s) {
2636
- s.length > 1 && s.sort((t, e) => (t.priority ?? 1 / 0) - (e.priority ?? 1 / 0));
2637
- for (let t = 0; t < s.length; t++) delete s[t].priority;
2638
- }
2639
- }
2640
- }), m.registerVisitor({
2641
- from: "customProperties",
2642
- to: "customProperties",
2643
- openTag: (t) => {
2644
- t.setSource([]);
2645
- },
2646
- closeTag: (t) => {
2647
- const e = t.getSource();
2648
- if (e.length > 0) t.getParent().customProperties = e;
2649
- }
2650
- }), m.registerVisitor({
2651
- from: "customPr",
2652
- to: {},
2653
- openTag: (t) => {
2654
- const s = t.getParent();
2655
- t.copyTo("name");
2656
- const o = t.getAttribute("r:id");
2657
- if (!o) return void t.warn("A custom property names no part; it was not imported.", { onceKey: "xlsx.sheet.customProperty.noRel" });
2658
- const r = e(o, "resource"), n = t.getSource();
2659
- n.resId = r, s.push(n);
2660
- }
2661
- }), m.registerVisitor({
2662
- from: "sheetProtection",
2663
- to: "protection",
2664
- openTag: (t) => {
2665
- const e = t.getSource();
2666
- for (const s of _) {
2667
- const o = t.hasAttribute(s.attribute) ? t.getAttribute(s.attribute) : null;
2668
- e[s.key] = ft(s, o);
2669
- }
2670
- if (e.sheet) return;
2671
- const s = {};
2672
- if (t.copyToObject(s, "hash", bs, "hashValue"), t.copyToObject(s, "algorithm", bs, "algorithmName"), t.copyToObject(s, "salt", bs, "saltValue"), t.copyToObject(s, "spinCount", gs), t.copyToObject(s, "legacyHash", bs, "password"), Object.keys(s).length > 0) t.getSource().password = s;
2673
- }
2674
- }), m.registerVisitor({
2675
- from: "protectedRanges",
2676
- to: "protectedRanges",
2677
- openTag: (t) => {
2678
- t.setSource([]);
2679
- }
2680
- }), m.registerVisitor({
2681
- from: "protectedRange",
2682
- to: [],
2683
- openTag: (t) => {
2684
- let e = t.getAttribute("sqref");
2685
- e && (e = e.trim().split(/\s+/).join(","));
2686
- const s = {}, o = {
2687
- r: e,
2688
- v: s
2689
- };
2690
- t.copyToObject(s, "name"), t.copyToObject(s, "securityDescriptor");
2691
- const r = {};
2692
- t.copyToObject(r, "hash", bs, "hashValue"), t.copyToObject(r, "algorithm", bs, "algorithmName"), t.copyToObject(r, "salt", bs, "saltValue"), t.copyToObject(r, "spinCount", gs), t.copyToObject(r, "legacyHash", bs, "password"), Object.keys(r).length > 0 && (s.password = r), t.setSource(o);
2693
- },
2694
- closeTag: (t) => {
2695
- const e = t.getSource();
2696
- e?.r && e.v.name || t.setSource(void 0);
2697
- }
2698
- }), m.registerVisitor({
2699
- from: "sheetFormatPr",
2700
- to: "sheetFormatPr",
2701
- openTag: (e) => {
2702
- e.copyToObject(t, "defaultColSize", ms, "defaultColWidth");
2703
- const s = e.getAttribute("customHeight");
2704
- "1" !== s && "true" !== s || e.copyToObject(t, "defaultRowSize", ms, "defaultRowHeight");
2705
- const o = e.getAttribute("baseColWidth", gs);
2706
- o && 8 !== o && (t.baseColSize = o), S = !!e.getAttribute("zeroHeight", fs);
2707
- }
2708
- }), m.registerVisitor({
2709
- from: "cols",
2710
- to: "cols",
2711
- openTag: (t) => {
2712
- t.setSource([]);
2713
- }
2714
- }), m.registerVisitor({
2715
- from: "col",
2716
- to: [],
2717
- openTag: (t) => {
2718
- const e = t.getSource(), s = t.getAttribute("min"), o = t.getAttribute("max"), r = void 0 === s ? 0 : parseInt(s) - 1, n = void 0 === o ? r : parseInt(o) - 1;
2719
- e.r = Tt.runToString(r, n, !0);
2720
- const i = {};
2721
- e.v = i, t.copyToObject(i, "sz", ms, "width"), t.copyToObject(i, "csz", fs, "customWidth"), t.copyToObject(i, "h", fs, "hidden"), t.copyToObject(i, "l", gs, "outlineLevel"), t.copyToObject(i, "cl", fs, "collapsed"), t.getAttribute("bestFit", fs) && (i.bf = !0), t.copyToObject(i, "s", gs, "style");
2722
- }
2723
- }), m.registerVisitor({
2724
- from: "oleObjects",
2725
- to: null,
2726
- openTag: (t) => {
2727
- t.warn("'OLE Objects' are not supported.");
2728
- }
2729
- });
2730
- let Dt = !1, _t = !1, $t = 0, Rt = "", Lt = "";
2731
- const Vt = (t) => {
2732
- const e = t.indexOf(":");
2733
- return -1 === e ? t : t.slice(e + 1);
2734
- }, Mt = new Bs();
2735
- return eo(P, t, m.createEventHandler(t, n, a), a, c, {
2736
- onOpenTag: (t) => {
2737
- Dt = !0;
2738
- const e = Vt(t.name);
2739
- "t" === e || "v" === e ? 0 === $t && (_t = !0) : "rPh" === e || "phoneticPr" === e ? $t++ : 0 === $t && Mt.onOpenTag(e, t.attributes);
2740
- },
2741
- onText: (t) => {
2742
- _t && (Rt += t, Mt.onText(t));
2743
- },
2744
- onCloseTag: (t) => {
2745
- const e = Vt(t.name);
2746
- "t" === e || "v" === e ? _t = !1 : "rPh" === e || "phoneticPr" === e ? $t > 0 && $t-- : Mt.onCloseTag(e);
2747
- },
2748
- onEnd: () => {
2749
- if (!Dt) return;
2750
- const t = Mt.take();
2751
- Dt = !1, _t = !1, $t = 0;
2752
- const e = k(Rt);
2753
- return Rt = "", Lt = e, t ? {
2754
- t: "r",
2755
- v: {
2756
- type: "richText",
2757
- data: { runs: js(t, f?.get(Ks)) }
2758
- }
2759
- } : s(e);
2760
- },
2761
- onError: (t) => {}
2762
- }, f, s, () => S, () => Lt);
2763
- }, Js = class {
2764
- static {
2765
- this.Collapsed = 1;
2766
- }
2767
- static {
2768
- this.CustomFormat = 2;
2769
- }
2770
- static {
2771
- this.CustomHeight = 4;
2772
- }
2773
- static {
2774
- this.Hidden = 8;
2775
- }
2776
- static {
2777
- this.Ht = 16;
2778
- }
2779
- static {
2780
- this.OutlineLevel = 32;
2781
- }
2782
- static {
2783
- this.Ph = 64;
2784
- }
2785
- static {
2786
- this.R = 128;
2787
- }
2788
- static {
2789
- this.S = 256;
2790
- }
2791
- static {
2792
- this.Spans = 512;
2793
- }
2794
- }, Zs = (t, e, s) => {
2795
- if (t[0].value[0] === t[1].value[0]) return e;
2796
- }, Qs = /^\s*TABLE\s*\(/i, Ys = {
2797
- colStart: 0,
2798
- colEnd: 0,
2799
- rowStart: 0,
2800
- rowEnd: 0
2801
- }, to = (t) => "1" === t || "true" === t, eo = (t, e, s, o, r, n, i, a, l, c) => {
2802
- let h = !1;
2803
- const u = [], d = i?.get(Us), p = i?.get(Ks), f = /* @__PURE__ */ new Map();
2804
- let g = !1, m = [], b = !1, x = null, y = null, v = null, w = null, T = null, S = null;
2805
- const C = i?.get("richData") ?? St.EmptyArray;
2806
- let A = null, k = !1;
2807
- const E = Tt.normalizeA1ToR1C1, I = Ct.createConflatingRanges(), P = /* @__PURE__ */ new Map(), O = [], D = [];
2808
- let _ = !1, N = !1, $ = null;
2809
- const R = (t) => {
2810
- const e = (i?.get("metadata"))?.values;
2811
- if (!e) return;
2812
- const s = parseInt(t, 10);
2813
- if (!Number.isFinite(s) || s < 1) return;
2814
- const o = e[s - 1]?.get("XLRICHVALUE");
2815
- return void 0 !== o?.richValueIndex ? C[o.richValueIndex] : void 0;
2816
- };
2817
- let L = !1;
2818
- const V = Ct.createConflatingRanges();
2819
- let M, B = !1, j = -1, F = -1, H = null, W = null;
2820
- const X = (t) => ({
2821
- t: "r",
2822
- v: {
2823
- type: "hyperlink",
2824
- data: {
2825
- address: M,
2826
- friendly: t
2827
- }
2828
- }
2829
- });
2830
- let q = null;
2831
- const U = [];
2832
- let K = null, G = -2, J = 0, Q = "", Y = "", tt = "", et = "", st = "", ot = "", rt = "", nt = "", it = "", at = "", lt = "", ct = "", ht = "", ut = "", dt = !0, pt = null, ft = !1, gt = !1, bt = !1, xt = null, yt = 0;
2833
- const vt = (t) => {
2834
- let o = t.name;
2835
- const a = o.indexOf(":");
2836
- if (-1 !== a && (o = o.slice(a + 1)), yt++, yt % 196608 == 0 && r?.(yt), W) {
2837
- const e = t.attributes;
2838
- switch (o) {
2839
- case "v":
2840
- g = !0;
2841
- break;
2842
- case "f":
2843
- switch (b = !0, e.t ?? null) {
2844
- case null:
2845
- case "normal": break;
2846
- case "shared":
2847
- const t = e.si;
2848
- y = e.ref, x = t;
2849
- break;
2850
- case "array":
2851
- y = e.ref, $ = y;
2852
- break;
2853
- case "dataTable": {
2854
- const t = ((t, e, s) => {
2855
- const o = t.r1, r = to(t.del1);
2856
- if (!o && !r) return null;
2857
- const n = t.ref ?? Tt.cellToString({
2858
- rowIndex: e,
2859
- colIndex: s
2860
- }), i = Tt.fastStringToRange(n);
2861
- if (!i) return null;
2862
- const a = { ref: {
2863
- rowStart: i.rowStart,
2864
- colStart: i.colStart,
2865
- rowEnd: i.rowEnd,
2866
- colEnd: i.colEnd
2867
- } }, l = to(t.dt2D);
2868
- if (l || to(t.dtr) ? (o && (a.rowInput = o), r && (a.rowInputDeleted = !0)) : (o && (a.columnInput = o), r && (a.columnInputDeleted = !0)), l) {
2869
- const e = t.r2;
2870
- e && (a.columnInput = e), to(t.del2) && (a.columnInputDeleted = !0);
2871
- }
2872
- return a;
2873
- })(e, j, F);
2874
- t && (D.push(t), to(e.ca) && V.append(j, F));
2875
- return;
2876
- }
2877
- }
2878
- const t = e.ca;
2879
- void 0 !== t && (L = "1" === t);
2880
- break;
2881
- case "is":
2882
- B = !0;
2883
- return;
2884
- }
2885
- B && !b && n?.onOpenTag?.(t);
2886
- return;
2887
- }
2888
- if (h) {
2889
- if ("c" === o) {
2890
- W = t, M = void 0;
2891
- const e = t.attributes, s = e.r;
2892
- F = void 0 !== s ? Tt.fastStringToCol(s) : F + 1;
2893
- const o = e.t;
2894
- void 0 === o ? q = null : (q = o, "str" === q && (B = !0));
2895
- let r = e.s;
2896
- void 0 === r && (null !== xt || bt) && (r = "0"), void 0 !== r && (r = parseInt(r), pt && pt.value === r && pt.colEnd + 1 === F ? pt.colEnd = F : (pt = {
2897
- colStart: F,
2898
- rowStart: j,
2899
- colEnd: F,
2900
- rowEnd: j,
2901
- value: r
2902
- }, m.push(pt))), $ = null, N = !1, k = !1;
2903
- const n = e.cm;
2904
- _ = void 0 !== n && ((t) => {
2905
- const e = (i?.get("metadata"))?.cells;
2906
- if (!e) return !1;
2907
- const s = parseInt(t, 10);
2908
- return !(!Number.isFinite(s) || s < 1) && !0 === (e[s - 1]?.get("XLDAPR"))?.fDynamic;
2909
- })(n);
2910
- const a = e.vm;
2911
- if (void 0 !== a) {
2912
- const t = R(a);
2913
- if (At.isError(t)) {
2914
- const e = t.getCode();
2915
- H = {
2916
- t: "e",
2917
- v: e
2918
- }, _ && e === At.Code.Spill && (N = !0);
2919
- }
2920
- }
2921
- }
2922
- } else {
2923
- if (gt && "row" === o) {
2924
- h = !0;
2925
- const e = t.attributes.r;
2926
- if (j = void 0 !== e ? parseInt(e) - 1 : j + 1, F = -1, l?.()) {
2927
- const t = u[u.length - 1];
2928
- t && t.max + 1 === j ? t.max = j : u.push({
2929
- min: j,
2930
- max: j
2931
- });
2932
- }
2933
- if (J = 0, Y = t.attributes.customHeight, void 0 !== Y && (J |= Js.CustomHeight), Y !== it && (dt = !0, it = Y), Q = t.attributes.ht, void 0 !== Q && (J |= Js.Ht), Q !== nt && (dt = !0, nt = Q), tt = t.attributes.hidden, void 0 !== tt && (J |= Js.Hidden), tt !== at && (dt = !0, at = tt), st = t.attributes.s, void 0 !== st && (J |= Js.S), st !== ct && (dt = !0, ct = st), et = t.attributes.customFormat, void 0 !== et && (J |= Js.CustomFormat), et !== lt && (dt = !0, lt = et), ot = t.attributes.outlineLevel, void 0 !== ot && (J |= Js.OutlineLevel), ot !== ht && (dt = !0, ht = ot), rt = t.attributes.collapsed, void 0 !== rt && (J |= Js.Collapsed), rt !== ut && (dt = !0, ut = rt), 0 !== J) if (G + 1 !== j || dt) {
2934
- const t = void 0 !== Y && ("1" === Y || "true" === Y), e = void 0 !== et && ("1" === et || "true" === et);
2935
- xt = e && void 0 !== st ? st : null, e && null === xt && (xt = "0"), K = {
2936
- min: j,
2937
- max: j,
2938
- value: {
2939
- sz: void 0 === Q ? -1 : parseFloat(Q),
2940
- csz: t,
2941
- h: void 0 !== tt && ("1" === tt || "true" === tt),
2942
- s: null === xt ? void 0 : "0" === xt ? 0 : parseInt(xt),
2943
- l: void 0 === ot || "0" === ot ? 0 : parseInt(ot),
2944
- cl: void 0 !== rt && ("1" === rt || "true" === rt)
2945
- }
2946
- }, U.push(K);
2947
- } else K.max = j;
2948
- G = j, dt = !1;
2949
- return;
2950
- }
2951
- if ("sheetData" === o && (gt = !0), !ft && "sheetData" === o) {
2952
- ft = !0;
2953
- const t = e.cols, s = t ? t.length : 0;
2954
- for (let e = 0; !bt && e < s; e++) t[e].v.s && (bt = !0);
2955
- }
2956
- s?.onOpenTag?.(t);
2957
- }
2958
- }, wt = (e) => {
2959
- let o = e.name;
2960
- if ("sheetData" === o && (gt = !1), !b || "c" !== o && "f" !== o || (x && (w = P.get(x) ?? null), w && (M = ((t) => {
2961
- if (t.length < 11 || 104 != (32 | t.charCodeAt(0))) return;
2962
- if (!/^HYPERLINK\(/i.test(t)) return;
2963
- let e = 1, s = !1, o = 10;
2964
- for (; o < t.length && e > 0; o++) {
2965
- const r = t.charCodeAt(o);
2966
- s ? 34 === r && (34 === t.charCodeAt(o + 1) ? o++ : s = !1) : 34 === r ? s = !0 : 40 === r ? e++ : 41 === r && e--;
2967
- }
2968
- if (0 !== e || t.slice(o).trim().length > 0) return;
2969
- const r = /^HYPERLINK\(\s*"((?:[^"]|"")*)"\s*[,)]/i.exec(t);
2970
- return r ? r[1].replace(/""/g, "\"") : null;
2971
- })(w[2]), I.append(j, F, w), L && V.append(j, F)), null !== $ && O.push([$, _ ? N ? "error" : "dynamic" : "fixed"]), b = !1, w = null, x = null, y = null, g = !1, L = !1, $ = null, _ = !1, N = !1), W) {
2972
- const s = o.indexOf(":");
2973
- if (-1 !== s && (o = o.slice(s + 1)), B) if ("is" === o || "v" === o) {
2974
- const e = n?.onEnd?.();
2975
- null == e || k && "" === c?.() || t.pushAt(j, F, void 0 !== M && "number" == typeof e ? X(c?.() ?? "") : "number" == typeof e ? "" + e : e);
2976
- } else "f" !== o && n?.onCloseTag?.(e);
2977
- g && (g = !1), "c" === o && (W = null, B = !1);
2978
- return;
2979
- }
2980
- if (h) return h = !1, void (pt = null);
2981
- s?.onCloseTag?.(e);
2982
- }, kt = (e) => {
2983
- const r = e.trim();
2984
- if (g) {
2985
- switch (H = null, q) {
2986
- case null:
2987
- case "n":
2988
- H = Mt.flushSubnormal(parseFloat(r));
2989
- break;
2990
- case "b":
2991
- H = "1" === r || "true" === r;
2992
- break;
2993
- case "s": {
2994
- const t = parseInt(r, 10);
2995
- let e = f.get(t);
2996
- if (void 0 === e) {
2997
- const s = d?.get(t);
2998
- e = s ? js(s, p) : null, f.set(t, e);
2999
- }
3000
- H = e ? {
3001
- t: "r",
3002
- v: {
3003
- type: "richText",
3004
- data: { runs: e }
3005
- }
3006
- } : r;
3007
- break;
3008
- }
3009
- case "d": {
3010
- const t = ((t, e = !1) => {
3011
- if (!t) return null;
3012
- const s = Rs.exec(t);
3013
- if (s) {
3014
- const [, t, e, o] = s;
3015
- return void 0 === t && void 0 === e && void 0 === o ? null : (3600 * parseFloat(t ?? "0") + 60 * parseFloat(e ?? "0") + parseFloat(o ?? "0")) / 86400;
3016
- }
3017
- const o = $s.exec(t);
3018
- if (!o) return null;
3019
- const [, r, n, i, a, l, c, h] = o;
3020
- if (void 0 === r && void 0 === a) return null;
3021
- let u = 0;
3022
- if (void 0 !== r) {
3023
- const t = parseInt(r, 10), s = parseInt(n, 10), o = parseInt(i, 10);
3024
- if (s < 1 || s > 12 || o < 1 || o > 31) return null;
3025
- const a = Ls(t, s, o) - Vs;
3026
- if (u = a <= 60 ? a - 1 : a, e && (u -= 1462), u < 0) return null;
3027
- }
3028
- void 0 !== a && (u += (3600 * parseInt(a, 10) + 60 * parseInt(l, 10) + (void 0 !== c ? parseInt(c, 10) : 0) + (void 0 !== h ? parseFloat(h) : 0)) / 86400);
3029
- return u;
3030
- })(r, !0 === i?.get(qs));
3031
- null !== t ? H = t : a && (o?.(`Date '${r}' in cell ${Tt.cellToString({
3032
- colIndex: F,
3033
- rowIndex: j
3034
- })} is not a date this workbook can hold; kept as text.`, void 0, "xlsx.cell.isoDateText"), H = "" + a(r));
3035
- break;
3036
- }
3037
- case "e":
3038
- if ("#VALUE!" === r) {
3039
- const t = W.attributes.vm;
3040
- if (void 0 !== t) {
3041
- const e = R(t);
3042
- if (At.isError(e)) {
3043
- H = {
3044
- t: "e",
3045
- v: e.getCode()
3046
- };
3047
- break;
3048
- }
3049
- if (Vt.isJSON(e)) {
3050
- H = {
3051
- t: "r",
3052
- v: e
3053
- };
3054
- break;
3055
- }
3056
- }
3057
- }
3058
- const t = At.getBuiltInByLabel(r);
3059
- t ? H = {
3060
- t: "e",
3061
- v: t.getCode()
3062
- } : (H = r, o?.(`Unknown formula error '${r}' in cell ${Tt.cellToString({
3063
- colIndex: F,
3064
- rowIndex: j
3065
- })}`));
3066
- break;
3067
- case "str":
3068
- case "inlineStr": B = !0;
3069
- }
3070
- null !== H && t.pushAt(j, F, void 0 === M || "number" != typeof H && "boolean" != typeof H ? H : X(H));
3071
- }
3072
- const l = null !== x;
3073
- if (x) {
3074
- if (T === x) w = S;
3075
- else {
3076
- if (w = P.get(x) ?? null, !w) {
3077
- const t = [];
3078
- v = E(r, j, F, t), w = [
3079
- v,
3080
- t,
3081
- r
3082
- ], P.set(x, w);
3083
- }
3084
- T = x, S = w;
3085
- }
3086
- x = null;
3087
- }
3088
- if (b) {
3089
- let t = r;
3090
- const e = l ? void 0 : i?.get(Xs);
3091
- if (e) {
3092
- const s = ((t) => {
3093
- if (t.length < ws.length) return Cs;
3094
- if (t.slice(0, ws.length).toUpperCase() !== Ts) return Cs;
3095
- const e = ks(t, ws.length);
3096
- if (null === e) return Cs;
3097
- if (41 !== t.charCodeAt(e.end)) return Cs;
3098
- if (44 !== t.charCodeAt(e.end + 1)) return Cs;
3099
- if (41 !== t.charCodeAt(t.length - 1)) return Cs;
3100
- const s = e.value;
3101
- return s.toUpperCase() === Ss ? As : 0 === s.length ? Cs : {
3102
- kind: "formula",
3103
- formula: s
3104
- };
3105
- })(r);
3106
- "none" !== s.kind && (A ??= new Is(e), "spilled" === s.kind ? k = A.placeholder(j, F) : A.anchor(j, F, s.formula) && (t = s.formula, L ||= ((t) => Es(t).some((t) => z(t) || !0 === Et.get(t)?.getDeclaration().getReturnType()?.isVolatile()))(t)));
3107
- }
3108
- if (k) L = !1;
3109
- else {
3110
- const e = [];
3111
- v = E(t, j, F, e), w = [
3112
- v,
3113
- e,
3114
- t
3115
- ];
3116
- }
3117
- }
3118
- B ? n?.onText?.(e) : h || s?.onText?.(r);
3119
- }, It = {
3120
- r: void 0,
3121
- t: void 0,
3122
- s: void 0,
3123
- cm: void 0,
3124
- vm: void 0
3125
- }, Pt = {
3126
- name: "c",
3127
- attributes: It,
3128
- isSelfClosing: !1
3129
- }, Ot = {
3130
- t: void 0,
3131
- si: void 0,
3132
- ref: void 0,
3133
- ca: void 0
3134
- }, Dt = {
3135
- name: "f",
3136
- attributes: Ot,
3137
- isSelfClosing: !1
3138
- }, _t = {
3139
- name: "v",
3140
- attributes: {},
3141
- isSelfClosing: !1
3142
- }, $t = {
3143
- r: void 0,
3144
- s: void 0,
3145
- ht: void 0,
3146
- hidden: void 0,
3147
- collapsed: void 0,
3148
- customHeight: void 0,
3149
- customFormat: void 0,
3150
- outlineLevel: void 0
3151
- }, Rt = {
3152
- name: "row",
3153
- attributes: $t,
3154
- isSelfClosing: !1
3155
- }, Lt = ps.NEED_MORE, Bt = ps.NOT_HANDLED, jt = ps.decodeText;
3156
- let Ft = !1;
3157
- const Ht = (t, e, s, o) => {
3158
- for (;;) {
3159
- let r = 0;
3160
- for (; e < s && (32 === (r = t.charCodeAt(e)) || 9 === r || 10 === r || 13 === r);) e++;
3161
- if (e >= s) return Lt;
3162
- if (62 === r) return Ft = !1, e + 1;
3163
- if (47 === r) return e + 1 >= s ? Lt : 62 !== t.charCodeAt(e + 1) ? Bt : (Ft = !0, e + 2);
3164
- const n = e;
3165
- for (; e < s && 61 !== (r = t.charCodeAt(e));) {
3166
- if (62 === r || 47 === r || 32 === r || 9 === r || 10 === r || 13 === r) return Bt;
3167
- e++;
3168
- }
3169
- if (e + 1 >= s) return Lt;
3170
- const i = e - n, a = t.charCodeAt(e + 1);
3171
- if (34 !== a && 39 !== a) return Bt;
3172
- const l = e + 2;
3173
- let c = l;
3174
- for (; c < s && (r = t.charCodeAt(c)) !== a;) {
3175
- if (38 === r || r < 32) return Bt;
3176
- c++;
3177
- }
3178
- if (c >= s) return Lt;
3179
- e = c + 1;
3180
- const h = t.charCodeAt(n);
3181
- if (2 === o) switch (i) {
3182
- case 1:
3183
- 114 === h ? $t.r = t.slice(l, c) : 115 === h && ($t.s = t.slice(l, c));
3184
- break;
3185
- case 2:
3186
- t.startsWith("ht", n) && ($t.ht = t.slice(l, c));
3187
- break;
3188
- case 6:
3189
- t.startsWith("hidden", n) && ($t.hidden = t.slice(l, c));
3190
- break;
3191
- case 9:
3192
- t.startsWith("collapsed", n) && ($t.collapsed = t.slice(l, c));
3193
- break;
3194
- case 12: t.startsWith("customHeight", n) ? $t.customHeight = t.slice(l, c) : t.startsWith("customFormat", n) ? $t.customFormat = t.slice(l, c) : t.startsWith("outlineLevel", n) && ($t.outlineLevel = t.slice(l, c));
3195
- }
3196
- else if (0 === o) 1 === i ? 114 === h ? It.r = t.slice(l, c) : 116 === h ? It.t = t.slice(l, c) : 115 === h && (It.s = t.slice(l, c)) : 2 === i && 109 === t.charCodeAt(n + 1) && (99 === h ? It.cm = t.slice(l, c) : 118 === h && (It.vm = t.slice(l, c)));
3197
- else if (1 === i) 116 === h && (Ot.t = t.slice(l, c));
3198
- else if (2 === i) {
3199
- const e = t.charCodeAt(n + 1);
3200
- 115 === h && 105 === e ? Ot.si = t.slice(l, c) : 99 === h && 97 === e && (Ot.ca = t.slice(l, c));
3201
- } else 3 === i && t.startsWith("ref", n) && (Ot.ref = t.slice(l, c));
3202
- }
3203
- }, Wt = (t, e, s) => 47 === t.charCodeAt(e + 1) && t.charCodeAt(e + 2) === s && 62 === t.charCodeAt(e + 3);
3204
- return {
3205
- ...s,
3206
- onEnd: () => {
3207
- if (l?.()) {
3208
- let t = 0;
3209
- const e = [], s = (t, e) => ({
3210
- min: t,
3211
- max: e,
3212
- value: {
3213
- sz: -1,
3214
- csz: !1,
3215
- h: !0,
3216
- s: void 0,
3217
- l: 0,
3218
- cl: !1
3219
- }
3220
- });
3221
- for (const o of u) o.min > t && e.push(s(t, o.min - 1)), t = Math.max(t, o.max + 1);
3222
- t <= Z && e.push(s(t, Z)), e.length > 0 && (U.push(...e), U.sort((t, e) => t.min - e.min));
3223
- }
3224
- U.length > 0 && (e.rows = Tt.runsToRefs(U, !1));
3225
- let o = I.done(Zs);
3226
- o = ((t, e) => {
3227
- let s = null;
3228
- for (let e = 0; e < t.length; e++) {
3229
- const o = t[e];
3230
- if (!Qs.test(o.value[2])) continue;
3231
- s ??= /* @__PURE__ */ new Map();
3232
- const r = o.value[0], n = s.get(r);
3233
- n ? n.push(o) : s.set(r, [o]);
3234
- }
3235
- if (null === s) return t;
3236
- const o = /* @__PURE__ */ new Set();
3237
- for (const t of s.values()) {
3238
- const s = t[0], r = {
3239
- rowStart: s.rowStart,
3240
- colStart: s.colStart,
3241
- rowEnd: s.rowEnd,
3242
- colEnd: s.colEnd
3243
- };
3244
- let n = 0;
3245
- for (let e = 0; e < t.length; e++) {
3246
- const s = t[e];
3247
- s.rowStart < r.rowStart && (r.rowStart = s.rowStart), s.colStart < r.colStart && (r.colStart = s.colStart), s.rowEnd > r.rowEnd && (r.rowEnd = s.rowEnd), s.colEnd > r.colEnd && (r.colEnd = s.colEnd), n += (s.rowEnd - s.rowStart + 1) * (s.colEnd - s.colStart + 1);
3248
- }
3249
- if (n !== (r.rowEnd - r.rowStart + 1) * (r.colEnd - r.colStart + 1)) continue;
3250
- const a = Ns(Tt.resolveRelativeToA1(s.value[1], r.rowStart, r.colStart), r);
3251
- if (a) {
3252
- e.push(a);
3253
- for (let e = 0; e < t.length; e++) o.add(t[e]);
3254
- }
3255
- }
3256
- return 0 === o.size ? t : t.filter((t) => !o.has(t));
3257
- })(o, D);
3258
- const r = o.length;
3259
- if (r > 0 || D.length > 0) {
3260
- const t = new Array(r);
3261
- for (let e = 0; e < r; e++) {
3262
- const s = o[e], r = Tt.rangeToString(s), n = s.value[1], i = Tt.resolveRelativeToA1(n, s.rowStart, s.colStart);
3263
- t[e] = [r, i];
3264
- }
3265
- for (let e = 0; e < D.length; e++) {
3266
- const s = D[e], o = s.ref;
3267
- t.push([Tt.cellToString({
3268
- rowIndex: o.rowStart,
3269
- colIndex: o.colStart
3270
- }), mt(s)]), O.push([Tt.rangeToString(o), "dynamic"]);
3271
- }
3272
- e.formulas = t;
3273
- }
3274
- const n = V.done(!0), i = n.length;
3275
- if (i > 0) {
3276
- const t = new Array(i);
3277
- for (let e = 0; e < i; e++) {
3278
- const s = n[e], o = Tt.rangeToString(s);
3279
- t[e] = o;
3280
- }
3281
- e.volatile = t;
3282
- }
3283
- A && O.push(...A.getFormulaArray()), O.length > 0 && (e.formulaArray = [...O]);
3284
- const a = m.length;
3285
- if (a > 0) {
3286
- m.sort(Ct.createRangeComparator(Nt.Axis.Column));
3287
- let t = m[0], s = t.colStart, o = t.colEnd, r = t.rowEnd, n = t.value;
3288
- const i = [];
3289
- i.push(t);
3290
- let l = null;
3291
- for (let e = 1; e < a; e++) l = m[e], n !== l.value || s !== l.colStart || o !== l.colEnd || r + 1 !== l.rowEnd ? (i.push(l), t = l, s = t.colStart, o = t.colEnd, r = t.rowEnd, n = t.value) : (r = l.rowEnd, t.rowEnd = r);
3292
- const c = i.length, h = new Array(c);
3293
- for (let t = 0; t < c; t++) {
3294
- const e = i[t], s = Tt.rangeToString(e);
3295
- h[t] = [s, e.value];
3296
- }
3297
- e.directStyles = h;
3298
- }
3299
- const c = t.build();
3300
- c && (e.data = c.tuples), s?.onEnd?.();
3301
- },
3302
- onOpenTag: vt,
3303
- onCloseTag: wt,
3304
- onText: kt,
3305
- elementScanners: [{
3306
- name: "c",
3307
- scan: (t, e, s) => {
3308
- if (!h || null !== W) return Bt;
3309
- It.r = It.t = It.s = It.cm = It.vm = void 0;
3310
- let o = Ht(t, e + 2, s, 0);
3311
- if (o < 0) return o;
3312
- const r = It.t;
3313
- if (void 0 === It.r || "str" === r || "inlineStr" === r) return Bt;
3314
- let n = !1, i = -1, a = -1, l = -1, c = -1, u = o;
3315
- if (!Ft) for (Ot.t = Ot.si = Ot.ref = Ot.ca = void 0;;) {
3316
- const e = t.indexOf("<", o);
3317
- if (-1 === e || e + 3 >= s) return Lt;
3318
- for (let s = o; s < e; s++) {
3319
- const e = t.charCodeAt(s);
3320
- if (32 !== e && 9 !== e && 10 !== e && 13 !== e) return Bt;
3321
- }
3322
- const r = t.charCodeAt(e + 1), h = t.charCodeAt(e + 2);
3323
- if (47 === r) {
3324
- if (!Wt(t, e, 99)) return Bt;
3325
- u = e + 4;
3326
- break;
3327
- }
3328
- if (102 === r && !n && -1 === l && (32 === h || 62 === h || 47 === h)) {
3329
- if (n = !0, o = Ht(t, e + 2, s, 1), o < 0) return o;
3330
- if ("dataTable" === Ot.t) return Bt;
3331
- if (Ft) continue;
3332
- const r = t.indexOf("<", o);
3333
- if (-1 === r || r + 3 >= s) return Lt;
3334
- if (!Wt(t, r, 102)) return Bt;
3335
- i = o, a = r, o = r + 4;
3336
- continue;
3337
- }
3338
- if (118 === r && 62 === h && -1 === l) {
3339
- const r = t.indexOf("<", e + 3);
3340
- if (-1 === r || r + 3 >= s) return Lt;
3341
- if (!Wt(t, r, 118)) return Bt;
3342
- l = e + 3, c = r, o = r + 4;
3343
- continue;
3344
- }
3345
- return Bt;
3346
- }
3347
- return vt(Pt), n && (vt(Dt), a > i && kt(jt(t.slice(i, a))), wt(Dt)), -1 !== l && (vt(_t), c > l && kt(jt(t.slice(l, c))), wt(_t)), wt(Pt), u;
3348
- }
3349
- }, {
3350
- name: "row",
3351
- openTag: Rt,
3352
- scan: (t, e, s) => {
3353
- if (!gt || h || null !== W) return Bt;
3354
- $t.r = $t.s = $t.ht = $t.hidden = $t.collapsed = $t.customHeight = $t.customFormat = $t.outlineLevel = void 0;
3355
- const o = Ht(t, e + 4, s, 2);
3356
- return o < 0 ? o : Ft || void 0 === $t.r ? Bt : (vt(Rt), o);
3357
- }
3358
- }]
3359
- };
3360
- }, so = /* @__PURE__ */ new Map([
3361
- ["urn:schemas-microsoft-com:vml", "v"],
3362
- ["urn:schemas-microsoft-com:office:office", "o"],
3363
- ["urn:schemas-microsoft-com:office:excel", "x"]
3364
- ]), oo = [...so].map(([t, e]) => ` xmlns:${e}="${t}"`).join(""), ro = /<(\/?)([A-Za-z_][\w.-]*(?::[\w.-]+)?)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g, no = /(\s+)([A-Za-z_][\w.-]*(?::[\w.-]+)?)(\s*=\s*)("[^"]*"|'[^']*')/g, io = /\sxmlns(?::([\w.-]+))?\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
3365
- function ao(t) {
3366
- if (!t || !((t) => {
3367
- let e;
3368
- for (io.lastIndex = 0; null !== (e = io.exec(t));) {
3369
- const t = so.get(e[2] ?? e[3] ?? "");
3370
- if (t && t !== (e[1] ?? "")) return !0;
3371
- }
3372
- return !1;
3373
- })(t)) return t;
3374
- const e = [], s = (t, s, o) => {
3375
- const r = t.indexOf(":");
3376
- if (-1 === r && o) return null;
3377
- const n = -1 === r ? "" : t.substring(0, r);
3378
- if ("xmlns" === n) return null;
3379
- const i = ((t, s) => {
3380
- const o = s?.get(t);
3381
- if (void 0 !== o) return o;
3382
- for (let s = e.length - 1; s >= 0; s--) {
3383
- const o = e[s].bindings.get(t);
3384
- if (void 0 !== o) return o;
3385
- }
3386
- })(n, s), a = void 0 !== i ? so.get(i) : void 0;
3387
- return a ? `${a}:${-1 === r ? t : t.substring(r + 1)}` : null;
3388
- };
3389
- let o = !1, r = !1;
3390
- const n = t.replace(ro, (t, n, i, a, l) => {
3391
- if (n) {
3392
- const o = e[e.length - 1], r = s(i, null, !1);
3393
- return o && o.name === i && (o.nested > 0 ? o.nested-- : e.pop()), r ? `</${r}>` : t;
3394
- }
3395
- const c = ((t) => {
3396
- let e, s = null;
3397
- for (io.lastIndex = 0; null !== (e = io.exec(t));) (s ??= /* @__PURE__ */ new Map()).set(e[1] ?? "", e[2] ?? e[3] ?? "");
3398
- return s;
3399
- })(a);
3400
- c?.forEach((t, e) => {
3401
- const s = [...so].find(([, t]) => t === e)?.[0];
3402
- s && s !== t && (o = !0);
3403
- });
3404
- const h = s(i, c, !1);
3405
- let u = a.replace(no, (t, e, o, r, n) => {
3406
- if ("xmlns" === o || o.startsWith("xmlns:")) {
3407
- const e = n.slice(1, -1);
3408
- return so.has(e) ? "" : t;
3409
- }
3410
- const i = s(o, c, !0);
3411
- return i ? `${e}${i}${r}${n}` : t;
3412
- });
3413
- if (r || (r = !0, u = u.replace(/\s+$/, "") + oo), !l) {
3414
- const t = e[e.length - 1];
3415
- c ? e.push({
3416
- name: i,
3417
- bindings: c,
3418
- nested: 0
3419
- }) : t && t.name === i && t.nested++;
3420
- }
3421
- return `<${h ?? i}${u}${l}>`;
3422
- });
3423
- return o ? t : n;
3424
- }
3425
- var lo = {
3426
- creator: "author",
3427
- category: "category",
3428
- description: "comments",
3429
- contentStatus: "contentStatus",
3430
- created: "creationDate",
3431
- keywords: "keywords",
3432
- lastModifiedBy: "lastAuthor",
3433
- modified: "lastModifiedDate",
3434
- lastPrinted: "lastPrinted",
3435
- revision: "revisionNumber",
3436
- subject: "subject",
3437
- title: "title"
3438
- }, co = {
3439
- Company: "company",
3440
- Manager: "manager"
3441
- }, ho = {
3442
- lpwstr: Dt.Type.String,
3443
- lpstr: Dt.Type.String,
3444
- bstr: Dt.Type.String,
3445
- i1: Dt.Type.Number,
3446
- i2: Dt.Type.Number,
3447
- i4: Dt.Type.Number,
3448
- i8: Dt.Type.Number,
3449
- int: Dt.Type.Number,
3450
- ui1: Dt.Type.Number,
3451
- ui2: Dt.Type.Number,
3452
- ui4: Dt.Type.Number,
3453
- ui8: Dt.Type.Number,
3454
- uint: Dt.Type.Number,
3455
- r4: Dt.Type.Float,
3456
- r8: Dt.Type.Float,
3457
- decimal: Dt.Type.Float,
3458
- bool: Dt.Type.Boolean,
3459
- filetime: Dt.Type.Date,
3460
- date: Dt.Type.Date
3461
- }, uo = (t) => {
3462
- const e = t.kind ? ho[t.kind] : void 0;
3463
- if (!e) return null;
3464
- const s = t.value.trim();
3465
- let o;
3466
- if (e === Dt.Type.String) o = {
3467
- key: t.key,
3468
- type: e,
3469
- value: t.value
3470
- };
3471
- else if (e === Dt.Type.Boolean) {
3472
- if ("true" !== s && "false" !== s && "1" !== s && "0" !== s) return null;
3473
- o = {
3474
- key: t.key,
3475
- type: e,
3476
- value: "true" === s || "1" === s
3477
- };
3478
- } else if (e === Dt.Type.Date) {
3479
- const r = new Date(s);
3480
- if (!s || isNaN(r.getTime())) return null;
3481
- o = {
3482
- key: t.key,
3483
- type: e,
3484
- value: r.toISOString()
3485
- };
3486
- } else {
3487
- const r = Number(s);
3488
- if (!s || !Number.isFinite(r)) return null;
3489
- const n = e === Dt.Type.Number && r >= -2147483648 && r <= 2147483647;
3490
- o = {
3491
- key: t.key,
3492
- type: n ? e : Dt.Type.Float,
3493
- value: r
3494
- };
3495
- }
3496
- return t.linkTarget && (o.linkTarget = t.linkTarget), o;
3497
- }, po = "hiddenXfs", fo = (t) => (Array.isArray(t) ? t[1] : t?.v)?.s, go = (t) => {
3498
- if (!t || 0 === t.length) return !1;
3499
- const e = Tt.refsToRuns(t, !0);
3500
- let s = 0;
3501
- for (const t of e) {
3502
- if (t.min > s || void 0 === t.value?.s) return !1;
3503
- s = Math.max(s, t.max + 1);
3504
- }
3505
- return s > M;
3506
- }, mo = (t, e) => {
3507
- t.protection = {
3508
- ...t.protection,
3509
- showFormulas: e
3510
- };
3511
- }, bo = "xfComplements", xo = (t, e) => {
3512
- if ("string" == typeof t) return void e.push(t);
3513
- const s = Array.isArray(t) ? t : [t];
3514
- for (let t = 0; t < s.length; t++) {
3515
- const o = Tt.rangeToString(s[t]);
3516
- o && e.push(o);
3517
- }
3518
- }, yo = (t) => {
3519
- const e = Array.isArray(t) ? t[1] : t.v;
3520
- if (!e || !("s" in e)) return;
3521
- const s = e.s;
3522
- return delete e.s, s;
3523
- }, vo = (t, e, s, o) => {
3524
- if (!t) return;
3525
- const r = e ? 2 : 1, n = e ? s.rowStart : s.colStart, i = e ? s.rowEnd : s.colEnd;
3526
- let a, l = -1;
3527
- for (const s of t) {
3528
- const t = Tt.refToRun(s, e), c = yo(s);
3529
- t && void 0 !== c ? c !== l || (e ? a.colEnd : a.rowEnd) + 1 !== t.min ? (a = {
3530
- colStart: e ? t.min : n,
3531
- rowStart: e ? n : t.min,
3532
- colEnd: e ? t.max : i,
3533
- rowEnd: e ? i : t.max,
3534
- value: {
3535
- kind: r,
3536
- index: c
3537
- }
3538
- }, l = c, o.push(a)) : e ? a.colEnd = t.max : a.rowEnd = t.max : l = -1;
3539
- }
3540
- }, wo = {
3541
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",
3542
- "application/vnd.ms-excel.sheet.macroEnabled.main+xml": "workbooks",
3543
- "application/vnd.ms-excel.sheet.binary.macroEnabled.main": "workbooks",
3544
- "application/vnd.ms-excel.addin.macroEnabled.main+xml": "workbooks",
3545
- "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": "workbooks",
3546
- "application/vnd.ms-excel.template.macroEnabled.main+xml": "workbooks",
3547
- "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": "sheets",
3548
- "application/vnd.ms-excel.worksheet": "sheets",
3549
- "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": "charts",
3550
- "application/vnd.ms-excel.chartsheet": "charts",
3551
- "application/vnd.ms-excel.macrosheet+xml": "macros",
3552
- "application/vnd.ms-excel.macrosheet": "macros",
3553
- "application/vnd.ms-excel.intlmacrosheet+xml": "macros",
3554
- "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": "dialogs",
3555
- "application/vnd.ms-excel.dialogsheet": "dialogs",
3556
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml": "strs",
3557
- "application/vnd.ms-excel.sharedStrings": "strs",
3558
- "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": "styles",
3559
- "application/vnd.ms-excel.styles": "styles",
3560
- "application/vnd.openxmlformats-package.core-properties+xml": "coreprops",
3561
- "application/vnd.openxmlformats-officedocument.custom-properties+xml": "custprops",
3562
- "application/vnd.openxmlformats-officedocument.extended-properties+xml": "extprops",
3563
- "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": "comments",
3564
- "application/vnd.ms-excel.comments": "comments",
3565
- "application/vnd.ms-excel.threadedcomments+xml": "threadedcomments",
3566
- "application/vnd.ms-excel.person+xml": "people",
3567
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml": "metadata",
3568
- "application/vnd.ms-excel.sheetMetadata": "metadata",
3569
- "application/vnd.ms-excel.featurepropertybag+xml": "featurePropertyBag",
3570
- "application/vnd.ms-excel.externalLink": "links",
3571
- "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml": "links",
3572
- "application/vnd.openxmlformats-officedocument.theme+xml": "themes"
3573
- }, To = v({ readXLSX: () => Eo }), So = (t) => t.startsWith("/") ? t.slice(1) : t, Co = [
3574
- 208,
3575
- 207,
3576
- 17,
3577
- 224,
3578
- 161,
3579
- 177,
3580
- 26,
3581
- 225
3582
- ], Ao = /^xl\/worksheets\/[^/]+\.xml$/i, ko = (t) => "string" == typeof t ? t : (t?.runs ?? []).map((t) => t.text ?? "").join(""), Eo = async (s, r) => {
3583
- const { password: n, onVBA: i, profile: a, calcOnLoad: l = "auto", createWorkbookOptions: h = {}, ...u } = r ?? {};
3584
- await kt.load();
3585
- const d = !!h.origin && "string" != typeof h.origin, p = a ? new ce("function" == typeof a ? a : void 0) : null, g = [], m = (t, e, s) => {
3586
- g.push([
3587
- t,
3588
- e ?? "",
3589
- s
3590
- ]);
3591
- }, b = { onWarning: m }, x = r?.progress, y = x?.onProgress ? x.onProgress.bind(x) : void 0, v = s.byteLength;
3592
- let w = 0, T = 0;
3593
- const S = y ? (t) => {
3594
- if (w <= 0) return;
3595
- T += t;
3596
- const e = Math.min(v, Math.round(T / w * v));
3597
- y(e, v);
3598
- } : void 0, C = import("./CcMI8GfS94qlNCB0.mjs");
3599
- let A = null;
3600
- try {
3601
- A = new DOMParser();
3602
- } catch (t) {}
3603
- let O = null;
3604
- try {
3605
- O = new XMLSerializer();
3606
- } catch (t) {}
3607
- let _, $, L, j = null;
3608
- A || (j = import("@xmldom/xmldom"));
3609
- try {
3610
- const [t, e] = await Promise.all([j, C]);
3611
- _ = new e.DOMTransformer(), $ = A ?? new t.DOMParser(), L = O ?? new t.XMLSerializer();
3612
- } catch (t) {
3613
- throw new Error("Unable to load XLSX parser.", { cause: t });
3614
- }
3615
- const F = (t) => L.serializeToString(t);
3616
- if (((t) => {
3617
- if (t.byteLength < Co.length) return !1;
3618
- const e = new Uint8Array(t, 0, Co.length);
3619
- return Co.every((t, s) => e[s] === t);
3620
- })(s)) throw new yt("This is an Excel 97-2003 workbook (.xls), which cannot be read. Save it as '.xlsx' and try again.");
3621
- let W;
3622
- try {
3623
- W = await le.create(s);
3624
- } catch (t) {
3625
- throw new yt("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.", { cause: t });
3626
- }
3627
- p?.mark("zip-open");
3628
- try {
3629
- if (!W.has("[Content_Types].xml")) throw new yt("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
3630
- const s = (t) => {
3631
- const e = W.getEntry(t);
3632
- return e ? { content: e } : void 0;
3633
- }, r = {
3634
- workbooks: [],
3635
- sheets: [],
3636
- charts: [],
3637
- dialogs: [],
3638
- macros: [],
3639
- strs: [],
3640
- comments: [],
3641
- threadedcomments: [],
3642
- links: [],
3643
- coreprops: [],
3644
- extprops: [],
3645
- custprops: [],
3646
- themes: [],
3647
- styles: [],
3648
- metadata: [],
3649
- people: [],
3650
- featurePropertyBag: [],
3651
- overrides: {},
3652
- sst: "",
3653
- style: "",
3654
- defaults: {}
3655
- };
3656
- {
3657
- const t = ((t, e) => ({
3658
- onOpenTag: (e) => {
3659
- const s = ((t) => {
3660
- const e = t.indexOf(":");
3661
- return -1 === e ? t : t.slice(e + 1);
3662
- })(e.name), o = e.attributes;
3663
- if ("Override" === s) {
3664
- const e = o.ContentType, s = o.PartName;
3665
- if (!e || !s) return;
3666
- t.overrides[s.startsWith("/") ? s.slice(1) : s] = e;
3667
- const r = wo[e], n = r ? t[r] : void 0;
3668
- Array.isArray(n) && n.push(s);
3669
- } else if ("Default" === s) {
3670
- const e = o.Extension, s = o.ContentType;
3671
- e && (t.defaults[e.toLowerCase()] = s);
3672
- }
3673
- },
3674
- onEnd: () => {
3675
- t.sst = t.strs.length > 0 ? t.strs[0] : "", t.style = t.styles.length > 0 ? t.styles[0] : "";
3676
- },
3677
- onError: (t) => {
3678
- e?.(`Error parsing content types: ${t?.message ?? t}`);
3679
- }
3680
- }))(r, (t) => {
3681
- g.push([t, "[Content_Types].xml"]);
3682
- }), e = await W.getTextStream("[Content_Types].xml");
3683
- if (!e) throw new Error("Error parsing content types: '[Content_Types].xml'");
3684
- try {
3685
- await ss.parseStream(e, t, { xmlns: !1 });
3686
- } catch (t) {
3687
- throw new Error("Error parsing content types: '[Content_Types].xml'", { cause: t });
3688
- }
3689
- d && await W.getBuffer("[Content_Types].xml");
3690
- }
3691
- p?.mark("content-types");
3692
- const n = r.sst, u = /* @__PURE__ */ new Set();
3693
- for (const t of r.sheets) u.add(So(t));
3694
- n && u.add(So(n));
3695
- for (const t of u) w += W.uncompressedSize(t);
3696
- if (await W.prefetch((t) => !u.has(t) && !Ao.test(t)), p?.mark("prefetch-side-parts"), 0 === r.workbooks.length) {
3697
- const t = H("_rels/.rels", s, $, _, b), e = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
3698
- if (t) {
3699
- for (const s of t.values()) if (s.type === e && s.target) {
3700
- r.workbooks.push(s.target);
3701
- break;
3702
- }
3703
- }
3704
- }
3705
- if (0 === r.workbooks.length) throw new yt("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
3706
- const T = h?.resources ?? new Lt(), C = T.beginPersist(), A = {}, O = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Map();
3707
- L.set("parseInlineDxf", (t) => {
3708
- if (!t) return;
3709
- const e = $.parseFromString(`<dxf xmlns:x14="${X}" xmlns:xm="${f}">${t}</dxf>`, "text/xml")?.documentElement;
3710
- if (!e) return;
3711
- const s = _.parseDxf(e, "", b);
3712
- return Object.keys(s).length > 0 ? s : void 0;
3713
- });
3714
- const j = at("metadata", r, s, $, _, b).entries().next()?.value?.[1]?.metadata;
3715
- j && L.set("metadata", j), L.set(zs, G());
3716
- const z = /* @__PURE__ */ new Map(), q = [], J = /* @__PURE__ */ new Set(), Y = (t) => {
3717
- J.add(So(t));
3718
- }, et = (t, e = z) => {
3719
- const o = t.lastIndexOf("/"), r = t.substring(0, o + 1) + "_rels/" + t.substring(o + 1, t.length) + ".rels";
3720
- let n = e.get(r);
3721
- return n || (n = H(r, s, $, _, Ot), e.set(r, n)), n;
3722
- }, ot = (t, e, o, r = z) => {
3723
- let n = et(e, r).get(t), i = n?.target;
3724
- if (!i) return null;
3725
- if ("External" === n.targetMode) {
3726
- if (!o) return n.target;
3727
- const t = T.add({ source: { external: n.target } });
3728
- return t.addReference(A), O.add(t), C.toResourceId(t);
3729
- }
3730
- const a = e.lastIndexOf("/"), l = e.substring(0, a + 1);
3731
- i.startsWith("/") || (i = l + i), i = pt(i);
3732
- const c = _?.getVisitorParamsState().get("dxfs");
3733
- let h = r.get(i);
3734
- if (!h) {
3735
- const t = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", e = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink";
3736
- if (n.type === t) {
3737
- const t = {};
3738
- h = t;
3739
- const e = async () => {
3740
- const e = Gs(t, (t, e) => "legacyDrawing" === e ? ht(t, i) : "formControl" === e ? ut(t, i) : "part" === e ? ft(t, i) : ot(t, i, "resource" === e) ?? null, Mt, c, () => {}, (t, e, s) => {
3741
- m(t, e ? `${e} (${i})` : i, s);
3742
- }, void 0, L), s = await W.getTextStream(i, S);
3743
- if (s) try {
3744
- await ss.parseStream(s, e, {
3745
- xmlns: !1,
3746
- lean: !0
3747
- });
3748
- } catch (t) {
3749
- throw new Error(`Error parsing sheet: '${i}'`, { cause: t });
3750
- }
3751
- const o = et(i, r);
3752
- if (o) {
3753
- lt(t, i, o, r), N(t), it(t);
3754
- const e = [];
3755
- o.forEach((t, s) => {
3756
- if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable" !== t.type) return;
3757
- const o = ft(s, i, t.type, (t) => "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" !== t);
3758
- if (!o?.xml) return;
3759
- const r = /<pivotTableDefinition\b[^>]*>/.exec(o.xml)?.[0] ?? "", n = parseInt(/\scacheId="(\d+)"/.exec(r)?.[1] ?? "", 10);
3760
- if (isNaN(n)) return void g.push([`Pivot table '${o.name}' names no cache and was dropped.`, i]);
3761
- const a = /\sname="([^"]*)"/.exec(r)?.[1];
3762
- e.push({
3763
- ...a ? { name: st(a) } : {},
3764
- cacheId: n,
3765
- part: o
3766
- });
3767
- }), e.length > 0 && (t.pivotTables = e);
3768
- }
3769
- };
3770
- q.push(e());
3771
- } else if (n.type === e) {
3772
- const t = P(i, s, $, _, Ot);
3773
- if (t && 0 !== Object.keys(t).length) {
3774
- const e = t, s = e.__bookRelId, o = e.__absoluteUrlRelId;
3775
- delete e.__bookRelId, delete e.__absoluteUrlRelId;
3776
- const n = [];
3777
- et(i, r)?.forEach((t, e) => {
3778
- if ("External" === t.targetMode && t.type && t.target) {
3779
- const r = {
3780
- type: t.type,
3781
- target: t.target
3782
- };
3783
- e === s ? r.role = "book" : e === o && (r.role = "absoluteUrl"), n.push(r);
3784
- }
3785
- }), n.sort((t, e) => ("book" === t.role ? 0 : 1) - ("book" === e.role ? 0 : 1)), e.sources = n, Y(i), h = e;
3786
- } else h = null;
3787
- } else h = o ? B(i, s, (t, e) => {
3788
- const s = T.add({ source: { buffer: t } });
3789
- return s.addReference(A), O.add(s), C.toResourceId(s);
3790
- }, Ot) : P(i, s, $, _, Ot);
3791
- }
3792
- return h;
3793
- }, nt = (t, e) => {
3794
- if (!t) return null;
3795
- const s = et(e, z)?.get(t);
3796
- if (!s?.target || "External" === s.targetMode) return null;
3797
- let o = s.target;
3798
- return o.startsWith("/") || (o = e.substring(0, e.lastIndexOf("/") + 1) + o), pt(o);
3799
- }, lt = (t, e, s, r) => {
3800
- const n = [], i = /* @__PURE__ */ new Map(), a = [];
3801
- s.forEach((t, s) => {
3802
- if ("http://schemas.microsoft.com/office/2017/10/relationships/threadedComment" !== t.type) return;
3803
- const o = ot(s, e, !1, r)?.comments;
3804
- if (!o) return;
3805
- for (let t = 0; t < o.length; t++) {
3806
- const e = o[t];
3807
- if (!e?.v?.id) continue;
3808
- const { parentId: s, done: r, content: l, ...c } = e.v, h = {
3809
- ...c,
3810
- content: ko(l)
3811
- };
3812
- s ? a.push({
3813
- parentId: s,
3814
- json: h
3815
- }) : (r && (h.done = !0), i.set(h.id, h), n.push({
3816
- r: e.r,
3817
- v: h
3818
- }));
3819
- }
3820
- const l = nt(s, e);
3821
- l && Y(l);
3822
- });
3823
- for (let t = 0; t < a.length; t++) {
3824
- const { parentId: e, json: s } = a[t], o = i.get(e);
3825
- o && (o.replies ??= []).push(s);
3826
- }
3827
- const l = [];
3828
- if (s.forEach((t, s) => {
3829
- if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" !== t.type) return;
3830
- const o = ot(s, e, !1, r), n = o?.comments;
3831
- if (!n) return;
3832
- const a = o?.authors;
3833
- for (let t = 0; t < n.length; t++) {
3834
- const e = n[t];
3835
- if (!e?.r) continue;
3836
- let s = a && void 0 !== e.v.authorId ? a[e.v.authorId] : void 0;
3837
- if (s && s.startsWith("tc=")) {
3838
- if (i.has(D(s.substring(3)))) continue;
3839
- s = void 0;
3840
- }
3841
- const o = {
3842
- id: xt.uuidV4().toUpperCase(),
3843
- asNote: !0,
3844
- content: e.v.content ?? ""
3845
- }, r = s ? Pt({ displayName: s }) : void 0;
3846
- r && (o.personId = r.id), l.push({
3847
- r: e.r,
3848
- v: o
3849
- });
3850
- }
3851
- const c = nt(s, e);
3852
- c && Y(c);
3853
- }), 0 === n.length && 0 === l.length) return;
3854
- const c = [...n, ...l], h = t.legacyDrawing;
3855
- if (h?.xml) {
3856
- const { rest: e, notes: s } = ct(h.xml);
3857
- if (s.length > 0) {
3858
- const r = /* @__PURE__ */ new Map();
3859
- for (let t = 0; t < s.length; t++) {
3860
- const e = s[t];
3861
- r.set(Tt.cellToString({
3862
- rowIndex: e.row,
3863
- colIndex: e.col
3864
- }), e);
3865
- }
3866
- for (let t = 0; t < c.length; t++) {
3867
- const e = c[t], s = r.get(String(e.r).toUpperCase());
3868
- if (!s) continue;
3869
- if (r.delete(String(e.r).toUpperCase()), !e.v.asNote) continue;
3870
- const n = o(s.xml), i = {};
3871
- if (n.anchor) {
3872
- const [t, e, o, r, a, l, c, h] = n.anchor;
3873
- i.anchor = {
3874
- tl: {
3875
- c: t - s.col,
3876
- x: e,
3877
- r: o - s.row,
3878
- y: r
3879
- },
3880
- br: {
3881
- c: a - s.col,
3882
- x: l,
3883
- r: c - s.row,
3884
- y: h
3885
- }
3886
- };
3887
- } else n.bounds && (i.bounds = n.bounds);
3888
- n.style.fill && (i.fill = n.style.fill), n.style.stroke && (i.stroke = n.style.stroke), n.xml && (i.xml = n.xml), (i.anchor || i.bounds || i.fill || i.stroke || i.xml) && (e.v.box = i), n.visible && (e.v.shown = !0), n.alt && (e.v.description = n.alt);
3889
- }
3890
- const n = [];
3891
- r.forEach((t) => {
3892
- n.push(t.xml);
3893
- });
3894
- const i = dt(e, n);
3895
- i ? h.xml = i : delete t.legacyDrawing;
3896
- }
3897
- }
3898
- t.comments = c;
3899
- }, ht = (t, e) => {
3900
- const o = nt(t, e);
3901
- if (!o) return null;
3902
- const r = s(So(o));
3903
- if (!r) return null;
3904
- const n = { xml: ao(new TextDecoder("utf-8").decode(r.content)) }, i = [];
3905
- return et(o, z)?.forEach((t, e) => {
3906
- if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" !== t.type) return;
3907
- const s = ot(e, o, !0);
3908
- "number" == typeof s && i.push({
3909
- id: e,
3910
- resId: s
3911
- });
3912
- }), i.length > 0 && (n.images = i), Y(o), n;
3913
- }, ut = (t, e) => {
3914
- const o = nt(t, e);
3915
- if (!o) return null;
3916
- const r = P(o, s, $, _, Ot)?.formControl ?? null;
3917
- return r && Y(o), r;
3918
- }, ft = (t, e, o, n, i = /* @__PURE__ */ new Set()) => {
3919
- const a = nt(t, e);
3920
- if (!a || i.has(a)) return null;
3921
- const l = o ?? et(e, z)?.get(t)?.type;
3922
- if (!l) return null;
3923
- const c = s(So(a));
3924
- if (!c) return null;
3925
- i.add(a);
3926
- const h = a.substring(a.lastIndexOf("/") + 1), u = r.overrides[So(a)] ?? r.defaults[h.substring(h.lastIndexOf(".") + 1).toLowerCase()], d = {
3927
- id: t,
3928
- type: l,
3929
- name: h
3930
- };
3931
- if (u && (d.contentType = u), ((t, e) => t ? t.endsWith("+xml") || "application/xml" === t : /\.(xml|rels|vml)$/i.test(e))(u, h)) d.xml = new TextDecoder("utf-8").decode(c.content);
3932
- else {
3933
- const s = ot(t, e, !0);
3934
- if ("number" != typeof s) return null;
3935
- d.resId = s;
3936
- }
3937
- const p = [];
3938
- return et(a, z)?.forEach((t, e) => {
3939
- if (!t?.type) return;
3940
- if (n && !n(t.type)) return;
3941
- if ("External" === t.targetMode) {
3942
- const s = ot(e, a, !0);
3943
- "number" == typeof s && p.push({
3944
- id: e,
3945
- type: t.type,
3946
- resId: s
3947
- });
3948
- return;
3949
- }
3950
- const s = ft(e, a, t.type, n, i);
3951
- s && p.push(s);
3952
- }), p.length > 0 && (d.parts = p), Y(a), d;
3953
- }, gt = at("coreprops", r, s, $, _, b), mt = at("extprops", r, s, $, _, b), St = at("custprops", r, s, $, _, b);
3954
- St.forEach((t, e) => {
3955
- t?.custom && Y(e);
3956
- });
3957
- const Ct = new Rt(), At = at("people", r, s, $, _, b);
3958
- if (At.size > 0) {
3959
- const [t, e] = At.entries().next().value;
3960
- Ct.fromJSON(e?.persons), Y(t);
3961
- }
3962
- const Pt = (t) => {
3963
- if (t) return Ct.add(t).toJSON();
3964
- }, Ot = {
3965
- paramMap: L,
3966
- getRefs: et,
3967
- getRef: ot,
3968
- parsedRefs: z,
3969
- readEmbeddedPart: (t, e) => ft(t, e),
3970
- addPerson: Pt,
3971
- serializeElement: F,
3972
- onWarning: m
3973
- }, Dt = [], _t = /* @__PURE__ */ new Map();
3974
- if (L.set(Us, _t), n) {
3975
- const t = await W.getTextStream(n, S);
3976
- if (t) {
3977
- const e = ((t, e) => {
3978
- let s = !1, o = !1, r = 0, n = "";
3979
- const i = new Bs();
3980
- return {
3981
- onOpenTag: (t) => {
3982
- const e = Ms(t.name);
3983
- "t" === e ? s && 0 === r && (o = !0) : "si" === e ? (s = !0, n = "", i.reset(), r = 0) : "rPh" === e || "phoneticPr" === e ? r++ : s && 0 === r && i.onOpenTag(e, t.attributes);
3984
- },
3985
- onText: (t) => {
3986
- o && (n += t, i.onText(t));
3987
- },
3988
- onCloseTag: (e) => {
3989
- const a = Ms(e.name);
3990
- "t" === a ? o = !1 : "si" === a ? (t(k(n), i.take() ?? void 0), s = !1, n = "") : "rPh" === a || "phoneticPr" === a ? r > 0 && r-- : i.onCloseTag(a);
3991
- },
3992
- onError: (t) => {
3993
- e?.(`Error parsing shared strings: ${t?.message ?? t}`);
3994
- }
3995
- };
3996
- })((t, e) => {
3997
- e && _t.set(Dt.length, e), Dt.push(t);
3998
- }, (t) => {
3999
- m(t, n);
4000
- });
4001
- try {
4002
- await ss.parseStream(t, e, { xmlns: !1 });
4003
- } catch (t) {
4004
- throw new Error(`Error parsing shared strings: '${n}'`, { cause: t });
4005
- }
4006
- }
4007
- }
4008
- p?.mark("shared-strings");
4009
- let Nt = Dt.length;
4010
- const $t = /* @__PURE__ */ new Map();
4011
- let Vt = Nt;
4012
- const Mt = (t) => {
4013
- const e = $t.get(t);
4014
- if (void 0 !== e) return e;
4015
- const s = Vt;
4016
- return $t.set(t, Vt++), Dt.push(t), s;
4017
- }, Bt = [];
4018
- r.slicersCache = Bt;
4019
- const Ft = W.getNames(), Wt = Ft.length;
4020
- for (let t = 0; t < Wt; t++) {
4021
- const e = Ft[t];
4022
- e && e.startsWith("xl/slicerCache") && Bt.push(`/${e}`);
4023
- }
4024
- const zt = at("slicersCache", r, s, $, _, Ot), Xt = /* @__PURE__ */ new Map();
4025
- zt.forEach((t, e) => {
4026
- t?.cacheName && (t.cachePath = e, Xt.set(t.cacheName, t));
4027
- }), L.set("slicerCaches", Xt);
4028
- const qt = [];
4029
- r.slicers = qt;
4030
- for (let t = 0; t < Wt; t++) {
4031
- const e = Ft[t];
4032
- e && e.startsWith("xl/slicers/") && e.endsWith(".xml") && qt.push(`/${e}`);
4033
- }
4034
- const Ut = {
4035
- getFile: s,
4036
- domParser: $,
4037
- getAddress: (t, e) => {
4038
- const s = ot(e, t, !1);
4039
- return "string" == typeof s ? s : null;
4040
- },
4041
- getBytes: (t, e) => {
4042
- const o = nt(e, t), r = o ? s(o.substring(1))?.content : void 0;
4043
- return r ? r.slice().buffer : null;
4044
- },
4045
- addFetched: (t, e) => {
4046
- const s = T.add({
4047
- source: { buffer: t },
4048
- fetchedFrom: e
4049
- });
4050
- return s.addReference(A), O.add(s), C.toResourceId(s);
4051
- },
4052
- markAbsorbed: Y
4053
- }, ae = /* @__PURE__ */ new Map();
4054
- for (const t of U.getAll()) ae.set(t.structure, t.beginRead(Ut));
4055
- const le = ((t, e) => {
4056
- const s = (s) => {
4057
- const o = t(s);
4058
- return o ? e.parseFromString(new TextDecoder().decode(o.content), "text/xml").documentElement ?? null : null;
4059
- }, o = oe(s(Jt), "s").map((t) => ({
4060
- t: t.getAttribute("t") ?? "",
4061
- keys: re(t)
4062
- })), r = oe(s(Zt), "rv").map((t) => {
4063
- const e = oe(t, "fb")[0];
4064
- return {
4065
- s: parseInt(t.getAttribute("s") ?? "-1", 10),
4066
- values: oe(t, "v").map((t) => t.textContent ?? ""),
4067
- fb: e ? e.textContent ?? "" : null
4068
- };
4069
- }), n = oe(s(Qt), "a").map((t) => {
4070
- const e = ne(t), s = parseInt(t.getAttribute("r") ?? "", 10), o = parseInt(t.getAttribute("c") ?? "", 10), r = s > 0 ? s : e.length;
4071
- return {
4072
- rows: r,
4073
- columns: o > 0 ? o : Math.max(1, Math.ceil(e.length / Math.max(1, r))),
4074
- items: e
4075
- };
4076
- }), i = oe(s(Yt), "s").map(re), a = s(te), l = oe(oe(a, "spbArrays")[0], "a").map(ne), c = oe(oe(a, "spbData")[0], "spb").map((t) => ({
4077
- s: parseInt(t.getAttribute("s") ?? "-1", 10),
4078
- values: oe(t, "v").map((t) => t.textContent ?? "")
4079
- })), h = s(ee), u = ie(oe(oe(h, "global")[0], "keyFlags")[0]), d = /* @__PURE__ */ new Map();
4080
- for (const t of oe(oe(h, "types")[0], "type")) d.set(t.getAttribute("name") ?? "", ie(oe(t, "keyFlags")[0]));
4081
- const p = s(se), f = oe(oe(p, "dxfs")[0], "dxf").map((t) => oe(t, "numFmt")[0]?.getAttribute("formatCode") ?? null), g = oe(oe(p, "richProperties")[0], "rPr").map((t) => t.getAttribute("n") ?? "");
4082
- return {
4083
- structures: o,
4084
- values: r,
4085
- arrays: n,
4086
- bagStructures: i,
4087
- bagArrays: l,
4088
- bags: c,
4089
- globalKeyFlags: u,
4090
- typeKeyFlags: d,
4091
- richStyles: oe(oe(p, "richStyles")[0], "rSty").map((t) => {
4092
- const e = /* @__PURE__ */ new Map();
4093
- for (const s of oe(t, "rpv")) {
4094
- const t = g[parseInt(s.getAttribute("i") ?? "-1", 10)];
4095
- t && e.set(t, s.textContent ?? "");
4096
- }
4097
- const s = parseInt(t.getAttribute("dxfid") ?? "", 10);
4098
- return {
4099
- numberFormat: e.get("NumberFormat") ?? (s >= 0 ? f[s] ?? null : null),
4100
- isTitle: "1" === e.get("IsTitleField"),
4101
- isHero: "1" === e.get("IsHeroField")
4102
- };
4103
- })
4104
- };
4105
- })(s, $), ce = V(le, ae, (t) => {
4106
- m(t, "/xl/richData/rdrichvalue.xml");
4107
- });
4108
- L.set("richData", le.values.map((t, e) => ce.cellValue(e)));
4109
- for (let t = 0; t < Wt; t++) {
4110
- const e = Ft[t];
4111
- e.startsWith("xl/richData/") && !e.includes("/_rels/") && Y(e);
4112
- }
4113
- const he = at("themes", r, s, $, _, Ot);
4114
- let ue = null;
4115
- if (he && he.entries) {
4116
- let t = he.entries().next();
4117
- t?.value?.[1] && (ue = t.value[1]);
4118
- }
4119
- const de = new jt(ue);
4120
- let pe = at("styles", r, s, $, _, Ot).entries().next()?.value?.[1];
4121
- pe && (pe = JSON.parse(bt.JSONStableStringify(pe)));
4122
- const fe = at("workbooks", r, s, $, _, Ot);
4123
- L.set(qs, !0 === fe.entries().next().value?.[1]?.date1904), "none" !== (h.calcOnLoad ?? l) && L.set(Xs, ((t, e) => {
4124
- const s = /* @__PURE__ */ new Set();
4125
- if (t) for (let e = 0; e < t.length; e++) s.add(String(t[e]?.name).toUpperCase());
4126
- if (e) for (let t = 0; t < e.length; t++) try {
4127
- const o = e[t](() => {
4128
- throw new Error("Not evaluating.");
4129
- }, (t, e, o, r) => {
4130
- for (const t of Object.keys(r)) s.add(t.toUpperCase());
4131
- }, /* @__PURE__ */ new Map());
4132
- for (const t of o.keys()) s.add(t.toUpperCase());
4133
- } catch {}
4134
- return (t) => s.has(t) || Et.has(t);
4135
- })(fe.entries().next().value?.[1]?.names, h.functions)), p?.mark("side-parts-json"), await Promise.all(q);
4136
- {
4137
- const t = fe.entries().next().value?.[1], s = G(t?.names), o = t?.sheets ?? [];
4138
- for (let t = 0; t < o.length; t++) {
4139
- const r = o[t], n = c(r);
4140
- if ("macro" === r?.kind && n?.part.xml) {
4141
- n.part.xml = e(n.part.xml, Dt);
4142
- continue;
4143
- }
4144
- const i = Q(r);
4145
- i && tt(i, s);
4146
- }
4147
- const r = t?.names;
4148
- if (r) for (let t = 0; t < r.length; t++) {
4149
- const e = r[t]?.ref;
4150
- "string" == typeof e && (r[t].ref = s.readDetached(e));
4151
- }
4152
- }
4153
- y && w > 0 && (y(v, v), await new Promise((t) => setTimeout(t, 0))), p?.mark("sheets");
4154
- const ge = {
4155
- ...fe.entries().next().value?.[1],
4156
- styles: pe,
4157
- theme: de.toJSON()
4158
- }, me = ((t, e, s, o) => {
4159
- const r = {}, n = (t, e) => {
4160
- if (t) for (const { key: s, value: o } of t) {
4161
- const t = e[s];
4162
- if (t && o) if ("revisionNumber" === t) {
4163
- const t = parseInt(o, 10);
4164
- Number.isFinite(t) && (r.revisionNumber = t);
4165
- } else r[t] = o;
4166
- }
4167
- };
4168
- if (n(t, lo), n(e, co), s) {
4169
- const t = [];
4170
- for (const e of s) {
4171
- const s = uo(e);
4172
- s ? t.push(s) : o?.(`The custom document property '${e.key}' holds a value of a kind that is not read (${e.kind ? "vt:" + e.kind : "none"}); it was dropped.`, "xlsx.docProps.custom.kind");
4173
- }
4174
- t.length > 0 && (r.custom = t);
4175
- }
4176
- return Object.keys(r).length > 0 ? r : void 0;
4177
- })(gt.values().next().value?.properties, mt.values().next().value?.properties, St.values().next().value?.custom, (t, e) => {
4178
- m(t, "docProps/custom.xml", e);
4179
- });
4180
- me && (ge.properties = me), ((t, e) => {
4181
- if (!e || 0 === e.size) return;
4182
- const s = t.styles;
4183
- if (!s) return;
4184
- const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
4185
- for (const s of t.sheets ?? []) {
4186
- const t = Q(s);
4187
- if (!t) continue;
4188
- const n = /* @__PURE__ */ new Set();
4189
- go(t.cols) || n.add(0);
4190
- for (const e of t.directStyles ?? []) n.add(Array.isArray(e) ? e[1] : e.v);
4191
- for (const e of t.rows ?? []) {
4192
- const t = fo(e);
4193
- void 0 !== t && n.add(t);
4194
- }
4195
- for (const e of t.cols ?? []) {
4196
- const t = fo(e);
4197
- void 0 !== t && n.add(t);
4198
- }
4199
- let i = !1;
4200
- for (const t of n) if (e.has(t)) {
4201
- i = !0;
4202
- break;
4203
- }
4204
- if (i) {
4205
- t.protection = {
4206
- ...t.protection ?? { sheet: !0 },
4207
- showFormulas: !1
4208
- };
4209
- for (const t of n) (e.has(t) ? r : o).add(t);
4210
- }
4211
- }
4212
- if (0 === o.size) return;
4213
- const n = s.direct ?? (s.direct = []);
4214
- for (const t of o) 0 !== t && mo(n[t] ?? (n[t] = {}), !0);
4215
- for (const t of r) 0 !== t && mo(n[t] ?? (n[t] = {}), !1);
4216
- if (o.has(0)) {
4217
- const t = s.named ?? (s.named = []), e = It.BuiltInName.Normal.toLowerCase();
4218
- let o = t.find((t) => t.name?.toLowerCase() === e);
4219
- o || (o = {
4220
- name: It.BuiltInName.Normal,
4221
- style: {}
4222
- }, t.push(o)), mo(o.style, !0);
4223
- }
4224
- })(ge, L.get(po)), ((t) => {
4225
- const e = {
4226
- colStart: 0,
4227
- rowStart: 0,
4228
- colEnd: M,
4229
- rowEnd: Z
4230
- };
4231
- for (const s of t.sheets ?? []) {
4232
- const t = Q(s);
4233
- if (!t) continue;
4234
- const o = [];
4235
- if (vo(t.cols, !0, e, o), vo(t.rows, !1, e, o), 0 === o.length) continue;
4236
- const r = [];
4237
- for (const [e, s] of t.directStyles ?? []) r.push({
4238
- ...Tt.fastStringToRange(e),
4239
- value: {
4240
- kind: 0,
4241
- index: s
4242
- }
4243
- });
4244
- r.push(...o);
4245
- const n = [], i = new vt.IteratorInstance(r, { axis: wt.Column });
4246
- for (let t = i.next(); !t.done; t = i.next()) {
4247
- const s = t.value.overlaps;
4248
- let o;
4249
- if (1 === s.length) {
4250
- if (o = s[0].value, 0 === o.index) continue;
4251
- } else {
4252
- let t, e, r;
4253
- for (let o = 0; !t && o < s.length; o++) {
4254
- const n = s[o].value;
4255
- 0 === n.kind ? t = n : 1 === n.kind ? e = n : r = n;
4256
- }
4257
- o = t ?? e ?? r;
4258
- }
4259
- n.push([Tt.rangeToString(t.value.range, e), o.index]);
4260
- }
4261
- n.length > 0 ? t.directStyles = n : delete t.directStyles;
4262
- }
4263
- })(ge);
4264
- {
4265
- const t = L.get(bo);
4266
- if (t) ((t, e, s) => {
4267
- if (!e || 0 === e.size || !s) return;
4268
- const o = (t) => {
4269
- if (void 0 === t || 0 === t) return null;
4270
- const o = e.get(t);
4271
- return void 0 !== o ? s.controls[o] ?? null : null;
4272
- };
4273
- for (const e of t.sheets ?? []) {
4274
- const t = Q(e);
4275
- if (!t) continue;
4276
- const s = /* @__PURE__ */ new Map();
4277
- for (const e of t.directStyles ?? []) {
4278
- const t = Array.isArray(e) ? e[0] : e.r, r = o(Array.isArray(e) ? e[1] : e.v);
4279
- if (!r) continue;
4280
- const n = JSON.stringify(r);
4281
- let i = s.get(n);
4282
- i || (i = {
4283
- control: r,
4284
- addresses: []
4285
- }, s.set(n, i)), xo(t, i.addresses);
4286
- }
4287
- if (0 === s.size) continue;
4288
- const r = [...t.cellControls ?? []];
4289
- for (const { control: t, addresses: e } of s.values()) r.push({
4290
- r: e.join(","),
4291
- v: t
4292
- });
4293
- t.cellControls = r;
4294
- }
4295
- })(ge, t, at("featurePropertyBag", r, s, $, _, Ot).values().next().value?.featurePropertyBag);
4296
- }
4297
- {
4298
- const t = /* @__PURE__ */ new Map();
4299
- at("slicers", r, s, $, _, Ot).forEach((e, s) => {
4300
- e?.slicers && t.set(s, e.slicers);
4301
- }), function(t, e) {
4302
- const s = t.sheets ?? [], o = /* @__PURE__ */ new Map();
4303
- for (let t = 0; t < s.length; t++) {
4304
- const e = s[t], r = Q(e)?.tables ?? [];
4305
- for (let t = 0; t < r.length; t++) {
4306
- const e = r[t], s = Array.isArray(e) ? e[1] : e?.v;
4307
- if (!s?.id) continue;
4308
- const n = (s.columns ?? []).map((t) => "string" == typeof t ? { name: t } : t);
4309
- o.set(String(s.id), {
4310
- name: s.name ?? "",
4311
- columns: n
4312
- });
4313
- }
4314
- }
4315
- const r = /* @__PURE__ */ new Set();
4316
- for (let t = 0; t < s.length; t++) {
4317
- const n = s[t], i = Q(n);
4318
- if (!i) continue;
4319
- const a = i.slicers, l = i.movables;
4320
- if (a && l) for (let t = l.length - 1; t >= 0; t--) {
4321
- const s = l[t].content;
4322
- if ("slicer" !== s?.type || s.json?.source) continue;
4323
- const n = s.name ?? "", i = a[n];
4324
- if (!i?.tableId) continue;
4325
- const c = o.get(String(i.tableId)), h = c ? Kt(c.columns, i.columnId) : null;
4326
- c && h ? (s.json = Gt(i, s.json, kt.structuredReference(c.name, h.name)), r.add(n), i.cachePath && e.markAbsorbed(i.cachePath)) : (e.warn("A slicer names no table; it was not imported.", "xlsx.slicer.cacheDefinition"), l.splice(t, 1));
4327
- }
4328
- delete i.slicers;
4329
- }
4330
- e.slicerParts.forEach((t, s) => {
4331
- const o = Object.keys(t);
4332
- o.length > 0 && o.every((t) => r.has(t)) && e.markAbsorbed(s);
4333
- });
4334
- }(ge, {
4335
- warn: (t, e) => {
4336
- m(t, "xl/slicers", e);
4337
- },
4338
- markAbsorbed: Y,
4339
- slicerParts: t
4340
- });
4341
- }
4342
- ge.calc = {
4343
- ...ge.calc ?? {},
4344
- legacyIntersect: !0
4345
- }, Dt.length > 0 && (ge.strings = Dt);
4346
- const be = Ct.toJSON();
4347
- be && be.length > 0 && (ge.people = be);
4348
- const xe = W.getEntry("xl/vbaProject.bin");
4349
- if (xe) try {
4350
- const { VBAProject: t } = await import("./B_bFXQdvg63_jXXv.mjs"), e = t.extract(xe);
4351
- if (e) {
4352
- const s = /* @__PURE__ */ new Map();
4353
- for (const t of ge.sheets ?? []) {
4354
- const e = Q(t), o = e?.codeName;
4355
- o && s.set(o, e);
4356
- }
4357
- for (const o of e.modules) {
4358
- const e = { language: "vba" }, { header: r, body: n } = t.splitAttributes(o.code);
4359
- n && (e.source = n), r && (e.sourceHeader = r);
4360
- const i = "document" === o.type ? s.get(o.name) : void 0;
4361
- i || "document" !== o.type || (e.scope = "workbook");
4362
- const a = i ? i.modules ??= {} : ge.modules ??= {};
4363
- a[o.name] || (a[o.name] = e);
4364
- }
4365
- i?.(e);
4366
- } else g.push(["Unable to parse VBA project.", "xl/vbaProject.bin"]);
4367
- } catch (t) {
4368
- g.push([`Error extracting VBA: ${t?.message ?? t}`, "xl/vbaProject.bin"]);
4369
- }
4370
- const ye = L.get("calcId"), ve = void 0 === ye || !(Number(ye) >= 191029), we = h.calcOnLoad ?? ("auto" === l && ve ? "full" : l), Te = {
4371
- ...h,
4372
- calcOnLoad: we,
4373
- resources: T,
4374
- json: ge
4375
- };
4376
- if (void 0 === Te.disableLoadAutoFit) {
4377
- const t = L.get(rt);
4378
- Te.disableLoadAutoFit = !!t?.declared && t.normalIsThemeFont && await K(t.faces);
4379
- }
4380
- p?.mark("json-assembled");
4381
- const Se = new Ht(Te);
4382
- if (p?.mark("workbook-constructed"), O.forEach((t) => {
4383
- t.deleteReference(A);
4384
- }), C.endPersist(), d) {
4385
- t(Se);
4386
- const e = /* @__PURE__ */ new Map();
4387
- let s = 0;
4388
- for (const t of W.getNames()) {
4389
- const o = W.getEntry(t);
4390
- if (!o) continue;
4391
- const r = W.getRawEntry(t), n = r ? {
4392
- data: o,
4393
- uncompressedSize: W.uncompressedSize(t),
4394
- raw: {
4395
- compressedData: r.data,
4396
- compressionMethod: r.compressionMethod,
4397
- signature: r.signature
4398
- }
4399
- } : {
4400
- data: o,
4401
- uncompressedSize: W.uncompressedSize(t)
4402
- };
4403
- e.set(t, n), s += o.byteLength;
4404
- }
4405
- if (s > 67108864) g.push([`Source package too large to retain (${s} bytes, limit ${E}); unmodeled parts will be dropped on save.`, "SourcePackage"]);
4406
- else if (e.size > 0) {
4407
- const s = new I(e, J);
4408
- R(Se, s);
4409
- let o = Se.getWorksheets().getItems();
4410
- const r = Se.getTransactions().addListener({ onCommitEnd: (t) => {
4411
- const e = t.getOperation()?.name;
4412
- "insertCells" !== e && "deleteCells" !== e || s.markStructuralChange();
4413
- } }), n = Se.addListeners({ onSheetsChange: () => {
4414
- const t = Se.getWorksheets().getItems();
4415
- (t.length !== o.length || t.some((t, e) => t !== o[e])) && s.markStructuralChange(), o = t;
4416
- } });
4417
- Se.addListeners({ onClose: () => {
4418
- r(), n(), t(Se);
4419
- } });
4420
- }
4421
- }
4422
- if (g.length && x?.onWarning) {
4423
- const t = /* @__PURE__ */ new Set();
4424
- for (const e of g) {
4425
- const [s, o, r] = e, n = r ?? s;
4426
- t.has(n) || (t.add(n), x.onWarning(s, o));
4427
- }
4428
- }
4429
- return p && !0 === a && console.table(p.toTable()), await Se.whenFontsReady(), Se;
4430
- } catch (t) {
4431
- let e = "Unable to parse XLSX.";
4432
- throw t instanceof $t && (e = "Unable to open XLSX. There are too many rows or columns."), new Error(e, { cause: t });
4433
- } finally {
4434
- await W.close().catch(() => {});
4435
- }
4436
- };
4437
- export { Ks as i, bo as n, po as r, Eo as readXLSX, To as t };