@sheetxl/io-xlsx 0.8.0-beta.7 → 1.0.0

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