@sheetxl/io-xlsx 0.7.28-beta.4 → 0.8.0-beta.2

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 (89) hide show
  1. package/browser/cjs/BzOEBR0jaxXg9wvt.cjs +5 -0
  2. package/browser/cjs/C8oC1tPbhgR0Dqtx.cjs +2 -0
  3. package/browser/cjs/Ca-xJDjg5bOpUPXX.cjs +1 -0
  4. package/browser/cjs/{D5Y4KQhKdukOkjvA.cjs → D3EWCPfCu-qMOIGd.cjs} +1 -2
  5. package/browser/cjs/{DK9GutW2zPbyNlfU.cjs → DULsYP_GcPGLVYSE.cjs} +10 -1
  6. package/browser/cjs/DtBN3UOzNJjYBwJ6.cjs +1 -0
  7. package/browser/cjs/index.cjs +1 -1
  8. package/browser/cjs/sNZR19Wk-XQ2xZ9E.cjs +1 -0
  9. package/browser/esm/B9q618XELV7uWJsA.mjs +67 -0
  10. package/browser/esm/{D8qZcXzj_fdusd0Y.mjs → BwbMurFOptAFs7gC.mjs} +1596 -1130
  11. package/browser/esm/{BhohPLTubb_9rfrh.mjs → CMHb6pUUmsCP9r_9.mjs} +2 -2
  12. package/browser/esm/{saBnxecsRUpY6fGv.mjs → CMzkLUwbgA73RvCb.mjs} +1 -1
  13. package/browser/esm/D75_rfogFUfXADKc.mjs +3324 -0
  14. package/browser/esm/{DlBlJGlFQJrKovwJ.mjs → DfuBawaydlvgZMR-.mjs} +1827 -1050
  15. package/browser/esm/{BknJ4AeVeFJploh9.mjs → DhqYgh9G2vLn7mIE.mjs} +28 -13
  16. package/browser/esm/DoMlKUCnMSlR2qX5.mjs +159 -0
  17. package/browser/esm/{CV_L3E5OoPstI9lx.mjs → DtpWa7tZahylJ3HS.mjs} +446 -347
  18. package/browser/esm/{BXCOn1XvLvYSfpzi.mjs → IZf0hIeLYj3T0Xvu.mjs} +2 -2
  19. package/browser/esm/{C3sYFBc7Tym8l12A.mjs → _UDbQq5-pHbU1f82.mjs} +1 -1
  20. package/browser/esm/index.mjs +3 -3
  21. package/node/esm/{DsZ19z4oXoL-d0Lk.mjs → BD03jrMQ_UKA196-.mjs} +1937 -1142
  22. package/node/esm/{B6lQXVQjFT_OE3IA.mjs → Bi_kZVtZams7taqa.mjs} +2 -2
  23. package/node/esm/{BYCpXFieBgL_cwTO.mjs → BxHvzSROx_N_7nJH.mjs} +607 -506
  24. package/node/esm/{CfIzBnObj09fDuUX.mjs → CB1ijGbhl-e2l6Mm.mjs} +49 -35
  25. package/node/esm/CO1M1H1N6fB422K-.mjs +2959 -0
  26. package/node/esm/CWpezSa6TERGEv-B.mjs +3410 -0
  27. package/node/esm/{B9CUp-rqol5K1r1c.mjs → CY-pSutJLHskZfXZ.mjs} +1 -1
  28. package/node/esm/Dezt2uIDqlxjiuk5.mjs +170 -0
  29. package/node/esm/index.mjs +40 -25
  30. package/package.json +3 -3
  31. package/types/src/ConditionalFormatRules.d.ts +3 -3
  32. package/types/src/DataValidationRules.d.ts +18 -2
  33. package/types/src/ExcelCalcStamp.d.ts +39 -0
  34. package/types/src/ExcelCompat.d.ts +197 -42
  35. package/types/src/LegacyFormula.d.ts +28 -7
  36. package/types/src/Plugin.d.ts +16 -5
  37. package/types/src/ProtectionAttributes.d.ts +38 -0
  38. package/types/src/SourcePackage.d.ts +31 -12
  39. package/types/src/Types.d.ts +17 -0
  40. package/types/src/reader/HiddenFormulas.d.ts +16 -0
  41. package/types/src/reader/Warning.d.ts +29 -0
  42. package/types/src/reader/dom/DOMTransformer.d.ts +1 -1
  43. package/types/src/reader/dom/ExecutionContext.d.ts +16 -3
  44. package/types/src/reader/dom/Types.d.ts +19 -3
  45. package/types/src/reader/domVisitors/CommentVisitor.d.ts +18 -1
  46. package/types/src/reader/domVisitors/CommentsVisitor.d.ts +2 -2
  47. package/types/src/reader/domVisitors/ExternalLinkVisitor.d.ts +21 -3
  48. package/types/src/reader/domVisitors/SheetColorContainerVisitor.d.ts +2 -2
  49. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +6 -1
  50. package/types/src/reader/domVisitors/ThreadedCommentVisitor.d.ts +9 -1
  51. package/types/src/reader/domVisitors/ThreadedCommentsVisitor.d.ts +2 -2
  52. package/types/src/reader/domVisitors/WorkbookVisitor.d.ts +11 -1
  53. package/types/src/reader/sax/LeanSaxParser.d.ts +58 -0
  54. package/types/src/reader/sax/SaxParser.d.ts +11 -1
  55. package/types/src/reader/sax/SaxVisitor.d.ts +3 -2
  56. package/types/src/reader/saxVisitors/ContentTypesVisitor.d.ts +9 -0
  57. package/types/src/reader/saxVisitors/WorksheetVisitor.d.ts +11 -4
  58. package/types/src/utils/VmlNoteShapes.d.ts +75 -0
  59. package/types/src/vba/VBAProject.d.ts +52 -4
  60. package/types/src/writer/builder/ContentTypes.d.ts +13 -0
  61. package/types/src/writer/builder/Emitter.d.ts +6 -6
  62. package/types/src/writer/builder/EmitterRegistry.d.ts +7 -0
  63. package/types/src/writer/builder/OpcXmlUtils.d.ts +2 -0
  64. package/types/src/writer/builder/PackageBuilder.d.ts +70 -22
  65. package/types/src/writer/builder/PartWriter.d.ts +5 -0
  66. package/types/src/writer/builder/RelationshipSet.d.ts +3 -0
  67. package/types/src/writer/builder/Types.d.ts +107 -38
  68. package/types/src/writer/builder/_Types.d.ts +17 -0
  69. package/types/src/writer/emitters/CommentsEmitter.d.ts +52 -0
  70. package/types/src/writer/emitters/EmbeddedPartEmitter.d.ts +60 -0
  71. package/types/src/writer/emitters/ExternalLinkEmitter.d.ts +19 -0
  72. package/types/src/writer/emitters/LegacyDrawingEmitter.d.ts +18 -0
  73. package/types/src/writer/emitters/PersonsEmitter.d.ts +17 -0
  74. package/types/src/writer/emitters/PivotTableEmitter.d.ts +45 -0
  75. package/types/src/writer/emitters/ThreadedCommentsEmitter.d.ts +21 -0
  76. package/types/src/writer/emitters/WorkbookEmitter.d.ts +16 -3
  77. package/types/src/writer/utils/DrawMLUtils.d.ts +16 -1
  78. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +28 -0
  79. package/browser/cjs/Bhq8KfEhCnRykWeS.cjs +0 -1
  80. package/browser/cjs/BmG0GOcbuYvt3-R2.cjs +0 -1
  81. package/browser/cjs/D3YH3tTndeltJsh5.cjs +0 -1
  82. package/browser/cjs/DWkuoJSgvcXJTdN1.cjs +0 -1
  83. package/browser/cjs/Dmi-Tsz618B6vKpZ.cjs +0 -5
  84. package/browser/esm/BcnofzmeeuCVzr_M.mjs +0 -52
  85. package/browser/esm/C7R1lFA0iv-1bZ9i.mjs +0 -99
  86. package/browser/esm/DLEtaZiz_1cZH0dA.mjs +0 -2685
  87. package/node/esm/BSrW-J3BEH4Tza_S.mjs +0 -2486
  88. package/node/esm/Bqi4c7-14v0oNgFN.mjs +0 -108
  89. package/node/esm/D0frS50CfyeuXcuz.mjs +0 -2766
@@ -1,42 +1,42 @@
1
1
  /**
2
- * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.7.28-beta.4
2
+ * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.2
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
6
  */
7
- import "./BcnofzmeeuCVzr_M.mjs";
8
- import { D as e, E as t, F as n, H as r, I as i, K as a, L as o, M as s, N as c, O as l, P as u, U as d, _ as f, a as p, b as m, f as h, g, h as _, i as v, k as y, l as b, n as x, s as S, u as ee, w as C, z as w } from "./D8qZcXzj_fdusd0Y.mjs";
9
- import { AddressUtils as T, BufferUtils as E, Color as te, CommonUtils as D, CoordUtils as O, FormulaError as ne, IColor as k, ICondition as A, IConditionalFormat as j, IEffect as M, IFill as N, ISheet as P, IStroke as F, IStyle as I, ITextFrame as L, LicenseManager as re, NumberFormat as R, ScalarType as z } from "@sheetxl/sdk";
10
- var B = class {
7
+ import "./B9q618XELV7uWJsA.mjs";
8
+ import { $ as e, A as t, C as n, E as r, G as i, J as a, L as o, P as s, Q as c, R as l, S as u, U as d, W as f, X as p, Y as m, Z as h, _ as g, a as _, at as v, b as y, c as b, ct as x, f as S, h as C, i as w, it as T, j as E, k as D, l as O, m as ee, n as k, o as A, r as j, s as te, t as M, tt as ne, u as re, w as ie, y as N } from "./BwbMurFOptAFs7gC.mjs";
9
+ import { AddressUtils as P, BufferUtils as F, Color as ae, CommonUtils as I, CoordUtils as oe, FormulaError as se, FormulaText as ce, IColor as L, ICondition as R, IConditionalFormat as z, IEffect as le, IFill as B, ISheet as ue, IStroke as de, IStyle as V, ITextFrame as H, LicenseManager as fe, NumberFormat as pe, ScalarType as me } from "@sheetxl/sdk";
10
+ var he = "resourcesById", U = class {
11
11
  constructor(e) {
12
12
  this._kind = e.kind, this._contentType = e.contentType, this._relTypeUri = e.relTypeUri, this._path = e.path;
13
13
  }
14
- get kind() {
14
+ getKind() {
15
15
  return this._kind;
16
16
  }
17
- get contentType() {
17
+ getContentType(e) {
18
18
  return this._contentType;
19
19
  }
20
- get relTypeUri() {
20
+ getRelTypeUri(e) {
21
21
  return this._relTypeUri;
22
22
  }
23
23
  getPath(e) {
24
24
  return typeof this._path == "function" ? this._path(e) : this._path;
25
25
  }
26
- }, ie = class e {
26
+ }, ge = class e {
27
27
  constructor(e, t, n) {
28
28
  this.zipWriter = e, this.outputKind = t, this.outWritable = n;
29
29
  }
30
30
  static createUint8Array(t) {
31
- let r = new y(new n(), t);
32
- return new e(r, "uint8array");
31
+ let n = new i(new h(), t);
32
+ return new e(n, "uint8array");
33
33
  }
34
34
  static createBlob(t) {
35
- let n = new y(new s("application/zip"), t);
35
+ let n = new i(new a("application/zip"), t);
36
36
  return new e(n, "blob");
37
37
  }
38
38
  static createWritableStream(t, n) {
39
- let r = new y(t, n);
39
+ let r = new i(t, n);
40
40
  return new e(r, "writable", t);
41
41
  }
42
42
  async add(e, t, n) {
@@ -57,10 +57,10 @@ var B = class {
57
57
  compressionMethod: n?.compressionMethod,
58
58
  signature: n?.signature
59
59
  };
60
- if (typeof t == "string") return void await this.zipWriter.add(r, new c(t), i);
60
+ if (typeof t == "string") return void await this.zipWriter.add(r, new m(t), i);
61
61
  if (t instanceof Uint8Array || ArrayBuffer.isView(t) || t && typeof t.byteLength == "number" && typeof t.byteOffset == "number") {
62
62
  try {
63
- await this.zipWriter.add(r, new u(t), i);
63
+ await this.zipWriter.add(r, new p(t), i);
64
64
  } catch (e) {
65
65
  throw console.log("Error adding Uint8Array source to zip:", r, i), e;
66
66
  }
@@ -88,7 +88,7 @@ var B = class {
88
88
  return this.outputKind === "writable" ? this.outWritable ?? n : n;
89
89
  }
90
90
  };
91
- function ae(e) {
91
+ function _e(e) {
92
92
  let t = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), n = (e) => t(e).replace(/"/g, "&quot;"), r = (e) => {
93
93
  if (!e) return "";
94
94
  let t = "";
@@ -149,13 +149,13 @@ function ae(e) {
149
149
  }
150
150
  };
151
151
  }
152
- function oe(e) {
152
+ function ve(e) {
153
153
  switch (e.kind) {
154
154
  case "bytes": return e.bytes;
155
155
  case "text": return e.text;
156
156
  case "stream": return e.stream;
157
157
  case "xmlStream": {
158
- let t = [], n = ae({ write: (e) => t.push(e) });
158
+ let t = [], n = _e({ write: (e) => t.push(e) });
159
159
  return e.writeXml(n), n.close(), function(e) {
160
160
  let t = 0;
161
161
  for (let n of e) t += n.byteLength;
@@ -167,32 +167,36 @@ function oe(e) {
167
167
  case "xmlStreamed": return e.write();
168
168
  }
169
169
  }
170
- function se(e) {
171
- let t = V(e);
170
+ function ye(e) {
171
+ let t = be(e);
172
172
  if (!t) return "_rels/.rels";
173
173
  let n = t.lastIndexOf("/"), r = n >= 0 ? t.slice(0, n) : "";
174
174
  return `${r ? `${r}/_rels` : "_rels"}/${n >= 0 ? t.slice(n + 1) : t}.rels`;
175
175
  }
176
- function V(e) {
176
+ function be(e) {
177
177
  let t = (e ?? "").replace(/\\/g, "/").trim();
178
178
  for (; t.startsWith("/");) t = t.slice(1);
179
179
  return t;
180
180
  }
181
- function ce(e) {
181
+ function xe(e) {
182
+ let t = (e ?? "").replace(/\\/g, "/").trim();
183
+ return t.startsWith("/") || (t = "/" + t), t;
184
+ }
185
+ function Se(e) {
182
186
  let t = /^rId(\d+)$/.exec(e);
183
187
  return t ? parseInt(t[1], 10) : 2 ** 53 - 1;
184
188
  }
185
- function H(e) {
189
+ function W(e) {
186
190
  return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;").replace(/>/g, "&gt;");
187
191
  }
188
- function le(e, t, n, r = !1) {
192
+ function Ce(e, t, n, r = !1) {
189
193
  let i = t;
190
194
  if (t.startsWith("/")) i = t.slice(1);
191
195
  else {
192
196
  if (!e) throw Error(`Relative path "${t}" cannot be used at root level. Use an absolute path starting with "/" (e.g., "/xl/workbook.xml").`);
193
197
  i = (e.includes("/") ? e.slice(0, e.lastIndexOf("/") + 1) : "") + t;
194
198
  }
195
- if (i = ue(i), !i.includes("{n}")) {
199
+ if (i = we(i), !i.includes("{n}")) {
196
200
  if (!r && n.has(i)) throw Error(`Path already existing path: ${i}`);
197
201
  return i;
198
202
  }
@@ -202,7 +206,7 @@ function le(e, t, n, r = !1) {
202
206
  while (n.has(a));
203
207
  return a;
204
208
  }
205
- function ue(e) {
209
+ function we(e) {
206
210
  let t = e.split("/"), n = [];
207
211
  for (let r of t) if (r !== "" && r !== ".") if (r === "..") {
208
212
  if (n.length === 0) throw Error(`Invalid path: too many ".." segments in "${e}"`);
@@ -210,17 +214,17 @@ function ue(e) {
210
214
  } else n.push(r);
211
215
  return n.join("/");
212
216
  }
213
- function de(e, t) {
217
+ function Te(e, t) {
214
218
  if (!e) return t;
215
219
  let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = n ? n.split("/") : [], i = t.split("/"), a = 0, o = Math.min(r.length, i.length - 1);
216
220
  for (let e = 0; e < o && r[e] === i[e]; e++) a++;
217
221
  let s = r.length - a;
218
222
  return "../".repeat(s) + i.slice(a).join("/");
219
223
  }
220
- function fe(e) {
224
+ function Ee(e) {
221
225
  return new TextEncoder().encode(e);
222
226
  }
223
- function pe(e, t) {
227
+ function De(e, t) {
224
228
  return function(e, t = " ") {
225
229
  let n = "", r = 0, i = e.split(/(<[^>]+>)/g).filter(Boolean);
226
230
  for (let e = 0; e < i.length; e++) {
@@ -237,46 +241,15 @@ function pe(e, t) {
237
241
  return new TextDecoder("utf-8").decode(e);
238
242
  }(e), t);
239
243
  }
240
- var me = /&(amp|lt|gt|quot|apos|#x[0-9a-fA-F]+|#[0-9]+);/g;
241
- function he(e, t) {
242
- switch (t) {
243
- case "amp": return "&";
244
- case "lt": return "<";
245
- case "gt": return ">";
246
- case "quot": return "\"";
247
- case "apos": return "'";
248
- default: return t.startsWith("#x") ? String.fromCodePoint(parseInt(t.slice(2), 16)) : t.startsWith("#") ? String.fromCodePoint(parseInt(t.slice(1), 10)) : e;
249
- }
250
- }
251
- function ge(e) {
252
- return e.replace(me, he);
253
- }
254
- function _e(e) {
255
- let t = {}, n = /([A-Za-z_:][-A-Za-z0-9_:.]*)\s*=\s*"([^"]*)"/g, r;
256
- for (; r = n.exec(e);) t[r[1]] = ge(r[2]);
257
- return t;
258
- }
259
- function ve(e, t) {
260
- let n = [], r = RegExp(`<${t}\\b([^>]*)/?>`, "g"), i;
261
- for (; i = r.exec(e);) n.push(_e(i[1]));
262
- return n;
263
- }
264
- function ye(e) {
265
- return ve(new TextDecoder("utf-8").decode(e), "Relationship").filter((e) => e.Type && e.Target).map((e) => ({
266
- type: e.Type,
267
- target: e.Target,
268
- external: e.TargetMode === "External"
269
- }));
270
- }
271
- var be = class {
244
+ var Oe = class {
272
245
  constructor(e) {
273
- this.rels = [], this.usedIds = /* @__PURE__ */ new Set(), this.nextId = 1, this.sourcePart = V(e);
246
+ this.rels = [], this.usedIds = /* @__PURE__ */ new Set(), this.reservedIds = /* @__PURE__ */ new Set(), this.nextId = 1, this.sourcePart = be(e);
274
247
  }
275
248
  add(e, t, n) {
276
249
  let r = n?.idHint && !this.usedIds.has(n.idHint) ? n.idHint : void 0;
277
250
  if (!r) do
278
251
  r = "rId" + this.nextId++;
279
- while (this.usedIds.has(r));
252
+ while (this.usedIds.has(r) || this.reservedIds.has(r));
280
253
  let i = /^rId(\d+)$/.exec(r);
281
254
  return i && (this.nextId = Math.max(this.nextId, parseInt(i[1], 10) + 1)), this.usedIds.add(r), this.rels.push({
282
255
  id: r,
@@ -285,23 +258,31 @@ var be = class {
285
258
  targetMode: n?.external ? "External" : void 0
286
259
  }), r;
287
260
  }
261
+ reserve(e) {
262
+ for (let t of e) {
263
+ if (!t) continue;
264
+ this.reservedIds.add(t);
265
+ let e = /^rId(\d+)$/.exec(t);
266
+ e && (this.nextId = Math.max(this.nextId, parseInt(e[1], 10) + 1));
267
+ }
268
+ }
288
269
  list() {
289
270
  return this.rels;
290
271
  }
291
272
  toXmlBytes() {
292
- let e = [...this.rels].sort((e, t) => ce(t.id) - ce(e.id) || e.id.localeCompare(t.id)), t = [];
293
- t.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), t.push(`<Relationships xmlns="${xe}">`);
273
+ let e = [...this.rels].sort((e, t) => Se(t.id) - Se(e.id) || e.id.localeCompare(t.id)), t = [];
274
+ t.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), t.push(`<Relationships xmlns="${ke}">`);
294
275
  for (let n of e) {
295
276
  let e = [
296
- `Id="${H(n.id)}"`,
297
- `Type="${H(n.type)}"`,
298
- `Target="${H(n.target)}"`
277
+ `Id="${W(n.id)}"`,
278
+ `Type="${W(n.type)}"`,
279
+ `Target="${W(n.target)}"`
299
280
  ];
300
281
  n.targetMode === "External" && e.push("TargetMode=\"External\""), t.push(`<Relationship ${e.join(" ")}/>`);
301
282
  }
302
- return t.push("</Relationships>"), fe(t.join(""));
283
+ return t.push("</Relationships>"), Ee(t.join(""));
303
284
  }
304
- }, xe = "http://schemas.openxmlformats.org/package/2006/relationships", Se = class {
285
+ }, ke = "http://schemas.openxmlformats.org/package/2006/relationships", Ae = class {
305
286
  constructor() {
306
287
  this._defaultsSet = /* @__PURE__ */ new Set(), this._overridesSet = /* @__PURE__ */ new Set(), this._defaults = [], this._overrides = [];
307
288
  }
@@ -316,38 +297,44 @@ var be = class {
316
297
  }));
317
298
  }
318
299
  addOverride(e, t) {
319
- let n = function(e) {
320
- let t = (e ?? "").replace(/\\/g, "/").trim();
321
- return t.startsWith("/") || (t = "/" + t), t;
322
- }(e);
300
+ let n = xe(e);
323
301
  this._overridesSet.has(n) || (this._overridesSet.add(n), this._overrides.push({
324
302
  key: n,
325
303
  content: t
326
304
  }));
327
305
  }
306
+ replaceOverride(e, t) {
307
+ let n = xe(e);
308
+ if (!this._overridesSet.has(n)) return;
309
+ let r = this._overrides.find((e) => e.key === n);
310
+ r && (r.content = t);
311
+ }
328
312
  toXmlBytes() {
329
313
  let e = [];
330
- e.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), e.push(`<Types xmlns="${Ce}">`);
314
+ e.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), e.push(`<Types xmlns="${je}">`);
331
315
  let t = this._defaults.reverse();
332
316
  this.addDefault("rels", "application/vnd.openxmlformats-package.relationships+xml"), this.addDefault("xml", "application/xml");
333
- for (let { key: n, content: r } of t) e.push(`<Default Extension="${H(n)}" ContentType="${H(r)}"/>`);
317
+ for (let { key: n, content: r } of t) e.push(`<Default Extension="${W(n)}" ContentType="${W(r)}"/>`);
334
318
  let n = this._overrides;
335
- for (let { key: t, content: r } of n) e.push(`<Override PartName="${H(t)}" ContentType="${H(r)}"/>`);
336
- return e.push("</Types>"), fe(e.join(""));
319
+ for (let { key: t, content: r } of n) e.push(`<Override PartName="${W(t)}" ContentType="${W(r)}"/>`);
320
+ return e.push("</Types>"), Ee(e.join(""));
337
321
  }
338
- }, Ce = "http://schemas.openxmlformats.org/package/2006/content-types", we = class {
322
+ }, je = "http://schemas.openxmlformats.org/package/2006/content-types", Me = class {
339
323
  constructor(e) {
340
- this.parts = [], this.relsRoot = new be(""), this.relsByPart = /* @__PURE__ */ new Map(), this.contentTypes = new Se(), this.zip = e;
324
+ this.parts = [], this.relsRoot = new Oe(""), this.relsByPart = /* @__PURE__ */ new Map(), this.contentTypes = new Ae(), this.zip = e;
341
325
  }
342
326
  addContentType(e, t) {
343
- let n = V(e);
327
+ let n = be(e);
344
328
  this.contentTypes.addOverride("/" + n, t);
345
329
  }
346
330
  addDefaultType(e, t) {
347
331
  this.contentTypes.addDefault(e, t);
348
332
  }
333
+ replaceContentType(e, t) {
334
+ this.contentTypes.replaceOverride("/" + be(e), t);
335
+ }
349
336
  addPart(e, t, n, r) {
350
- let i = V(e);
337
+ let i = be(e);
351
338
  this.parts.push({
352
339
  path: i,
353
340
  body: t,
@@ -355,22 +342,22 @@ var be = class {
355
342
  }), n && this.contentTypes.addOverride("/" + i, n);
356
343
  }
357
344
  rels(e) {
358
- let t = V(e || "");
345
+ let t = be(e || "");
359
346
  if (!t) return this.relsRoot;
360
347
  let n = this.relsByPart.get(t);
361
- return n || (n = new be(t), this.relsByPart.set(t, n)), n;
348
+ return n || (n = new Oe(t), this.relsByPart.set(t, n)), n;
362
349
  }
363
350
  async emit() {
364
351
  let e = [...this.parts].sort((e, t) => e.path.localeCompare(t.path));
365
352
  for (let t of e) {
366
- let e = oe(t.body);
353
+ let e = ve(t.body);
367
354
  await this.zip.add(t.path, e, t.optionsZip);
368
355
  }
369
356
  let t = this.relsRoot.toXmlBytes();
370
357
  await this.zip.add("_rels/.rels", t, {});
371
358
  let n = [...this.relsByPart.values()].sort((e, t) => e.sourcePart.localeCompare(t.sourcePart));
372
359
  for (let e of n) {
373
- let t = se(e.sourcePart), n = e.toXmlBytes();
360
+ let t = ye(e.sourcePart), n = e.toXmlBytes();
374
361
  await this.zip.add(t, n, {});
375
362
  }
376
363
  let r = this.contentTypes.toXmlBytes();
@@ -379,31 +366,39 @@ var be = class {
379
366
  async build(e) {
380
367
  return await this.emit(), await this.zip.close(e);
381
368
  }
382
- }, Te = /* @__PURE__ */ new Set(["xl/calcChain.xml"]), Ee = [
383
- /^xl\/drawings\/vmlDrawing\d+\.vml$/i,
384
- /^xl\/ctrlProps\//i,
385
- /^xl\/slicers\//i,
386
- /^xl\/slicerCaches\//i,
387
- /^xl\/pivotCache\//i,
388
- /^xl\/pivotTables\//i
389
- ];
390
- function De(e) {
391
- return Ee.some((t) => t.test(e));
392
- }
393
- function Oe(e) {
394
- return e === "[Content_Types].xml" || ke.test(e);
369
+ }, Ne = /* @__PURE__ */ new Set(["xl/calcChain.xml"]), Pe = [/^xl\/slicers\//i, /^xl\/slicerCaches\//i];
370
+ function Fe(e) {
371
+ return e === "[Content_Types].xml" || Ie.test(e);
395
372
  }
396
- var ke = /^(?:(.*)\/)?_rels\/(.*)\.rels$/;
397
- function Ae(e) {
373
+ var Ie = /^(?:(.*)\/)?_rels\/(.*)\.rels$/;
374
+ function Le(e) {
398
375
  if (e === "_rels/.rels") return "";
399
- let t = ke.exec(e);
376
+ let t = Ie.exec(e);
400
377
  if (!t) return null;
401
378
  let n = t[1] ?? "", r = t[2];
402
379
  return n ? `${n}/${r}` : r;
403
380
  }
404
- var je = class {
381
+ function Re(e) {
382
+ return e.startsWith("#");
383
+ }
384
+ function ze(e, t) {
385
+ if (t.startsWith("/")) return we(t);
386
+ let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
387
+ return we((n ? n + "/" : "") + t);
388
+ }
389
+ var Be = class {
405
390
  constructor(e, t, n) {
406
- this._queue = [], this._scheduledByNodeKey = /* @__PURE__ */ new Map(), this._nodesByPath = /* @__PURE__ */ new Map(), this._writtenPaths = /* @__PURE__ */ new Set(), this._explicitRelTargets = /* @__PURE__ */ new Set(), this._partWriter = new we(e), this._registry = t, this._options = n ?? {}, this._mapState = this._options.mapState ?? /* @__PURE__ */ new Map(), this._sourcePackage = this._options.sourcePackage ?? null;
391
+ this._queue = [], this._scheduledByNodeKey = /* @__PURE__ */ new Map(), this._nodesByPath = /* @__PURE__ */ new Map(), this._writtenPaths = /* @__PURE__ */ new Set(), this._explicitRelTargets = /* @__PURE__ */ new Set(), this._partWriter = new Me(e), this._registry = t, this._options = n ?? {}, this._mapState = this._options.mapState ?? /* @__PURE__ */ new Map(), this._sourcePackage = this._options.sourcePackage ?? null, this._macroEnabled = this._options.macroEnabled ?? !1, this._reserveSourceRelIds("");
392
+ }
393
+ _isSourcePartCarried(e) {
394
+ let t = this._sourcePackage;
395
+ return !(!t || !t.has(e)) && !Ne.has(e) && !t.isAbsorbed(e) && !(!this._macroEnabled && e === "xl/vbaProject.bin") && !Fe(e) && (!t.hasStructuralChange() || !function(e) {
396
+ return Pe.some((t) => t.test(e));
397
+ }(e));
398
+ }
399
+ _reserveSourceRelIds(e) {
400
+ let t = this._sourcePackage?.getPart(ye(e));
401
+ t && this._partWriter.rels(e).reserve(f(t.data).map((e) => e.id));
407
402
  }
408
403
  async waitEmit() {
409
404
  let e = this._queue;
@@ -413,29 +408,19 @@ var je = class {
413
408
  }
414
409
  }
415
410
  async build(e) {
416
- return await this.waitEmit(), this._passthroughSourceParts(), await this._partWriter.build(e ?? {});
411
+ return await this.waitEmit(), this._passthroughSourceParts(), this._applyWorkbookContentTypeVariant(), await this._partWriter.build(e ?? {});
417
412
  }
418
413
  _passthroughSourceParts() {
419
414
  let e = this._sourcePackage;
420
415
  if (!e) return;
421
- let t = new Set(this._writtenPaths), n = e.hasStructuralChange(), r = [];
422
- for (let i of e.getNames()) t.has(i) || Te.has(i) || Oe(i) || n && De(i) || r.push(i);
423
- let i = new Set(t);
424
- for (let e of r) i.add(e);
425
- let a = e.getPart("[Content_Types].xml"), o = a ? function(e) {
426
- let t = new TextDecoder("utf-8").decode(e), n = ve(t, "Default").map((e) => ({
427
- ext: (e.Extension ?? "").toLowerCase(),
428
- contentType: e.ContentType ?? ""
429
- })).filter((e) => e.ext && e.contentType), r = /* @__PURE__ */ new Map();
430
- for (let e of ve(t, "Override")) e.PartName && e.ContentType && r.set(e.PartName, e.ContentType);
431
- return {
432
- defaults: n,
433
- overrides: r
434
- };
435
- }(a.data) : null;
436
- if (o) for (let { ext: e, contentType: t } of o.defaults) this._partWriter.addDefaultType(e, t);
437
- for (let t of r) {
438
- let n = e.getPart(t), r = o?.overrides.get("/" + t);
416
+ let t = new Set(this._writtenPaths), n = [];
417
+ for (let r of e.getNames()) t.has(r) || this._isSourcePartCarried(r) && n.push(r);
418
+ let r = new Set(t);
419
+ for (let e of n) r.add(e);
420
+ let i = e.getPart("[Content_Types].xml"), a = i ? d(i.data) : null;
421
+ if (a) for (let { ext: e, contentType: t } of a.defaults) this._partWriter.addDefaultType(e, t);
422
+ for (let t of n) {
423
+ let n = e.getPart(t), r = a?.overrides.get("/" + t);
439
424
  n.raw ? this._partWriter.addPart(t, {
440
425
  kind: "bytes",
441
426
  bytes: n.raw.compressedData
@@ -450,100 +435,92 @@ var je = class {
450
435
  }, r), this._writtenPaths.add(t);
451
436
  }
452
437
  for (let n of e.getNames()) {
453
- if (n === "[Content_Types].xml" || !Oe(n)) continue;
454
- let r = Ae(n);
455
- r !== null && (r === "" || i.has(r)) && this._mergeSourceRelsInto(r, e.getPart(n).data, t, i);
438
+ if (n === "[Content_Types].xml" || !Fe(n)) continue;
439
+ let i = Le(n);
440
+ i !== null && (i === "" || r.has(i)) && (e.isAbsorbed(i) || this._mergeSourceRelsInto(i, e.getPart(n).data, t, r));
456
441
  }
457
442
  }
443
+ _applyWorkbookContentTypeVariant() {
444
+ this._macroEnabled && this._partWriter.replaceContentType("xl/workbook.xml", "application/vnd.ms-excel.sheet.macroEnabled.main+xml");
445
+ }
458
446
  _mergeSourceRelsInto(e, t, n, r) {
459
- let i = this._partWriter.rels(e), a = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
460
- for (let o of ye(t)) {
461
- if (o.external) {
462
- i.add(o.type, o.target, { external: !0 });
447
+ let i = this._partWriter.rels(e), a = e === "" || n.has(e);
448
+ for (let o of f(t)) {
449
+ if (o.external || Re(o.target)) {
450
+ i.add(o.type, o.target, {
451
+ external: o.external,
452
+ idHint: o.id
453
+ });
463
454
  continue;
464
455
  }
465
- let t = ue((a ? a + "/" : "") + o.target);
466
- n.has(t) || this._explicitRelTargets.has(`${e}::${t}`) || (r.has(t) ? i.add(o.type, o.target) : console.warn(`Dropping preserved relationship to missing part '${t}'`, e || "(root)"));
467
- }
468
- }
469
- addPart(e, t, n) {
470
- return this._addPartInternal("", e, t, n);
471
- }
472
- _addPartInternal(e, t, n, r) {
473
- let i = this._registry.get(t);
474
- if (!i) throw Error(`No emitter registered for kind '${t}'.`);
475
- let a = r ?? i.getPath?.(n);
476
- if (!a) throw Error("No path provided in either argument or emitter.");
477
- let o = this._writtenPaths, s = le(e, a, o), c = `${t}:${s}`, l = this._scheduledByNodeKey.get(c);
478
- if (!l) {
479
- let e, r = new Promise((t) => {
480
- e = t;
481
- });
482
- l = {
456
+ let t = ze(e, o.target);
457
+ a && (n.has(t) || this._explicitRelTargets.has(`${e}::${t}`)) || (r.has(t) ? i.add(o.type, o.target, { idHint: o.id }) : this._registry.ownsRelType(o.type) || Ne.has(t) || this._sourcePackage?.isAbsorbed(t) || console.warn(`Dropping preserved relationship to missing part '${t}'`, e || "(root)"));
458
+ }
459
+ }
460
+ addPart(e, t, n, r) {
461
+ return this._addPartInternal("", e, t, n, r);
462
+ }
463
+ _addPartInternal(e, t, n, r, i) {
464
+ let a = this._registry.get(t);
465
+ if (!a) throw Error(`No emitter registered for kind '${t}'.`);
466
+ let o = a.getContentType(n), s = a.getRelTypeUri(n), c = r ?? a.getPath?.(n);
467
+ if (!c) throw Error("No path provided in either argument or emitter.");
468
+ let l = this._writtenPaths, u = Ce(e, c, l), d = `${t}:${u}`, f = this._scheduledByNodeKey.get(d);
469
+ if (!f) {
470
+ let e;
471
+ this._reserveSourceRelIds(u), f = {
483
472
  kind: t,
484
- key: c,
473
+ key: d,
485
474
  payload: n,
486
- path: s,
487
- contentType: i.contentType,
488
- promise: r,
475
+ path: u,
476
+ contentType: o,
477
+ promise: new Promise((t) => {
478
+ e = t;
479
+ }),
489
480
  resolve: e
490
- }, this._scheduledByNodeKey.set(c, l), this._queue.push(l);
491
- }
492
- let u = this._nodesByPath.get(e);
493
- u || (u = /* @__PURE__ */ new Set(), this._nodesByPath.set(e, u)), u.add(c), !i.contentType || i.relTypeUri || e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", s);
494
- let d = null;
495
- if (i.relTypeUri) {
496
- let t = de(e, l.path);
497
- d = this._partWriter.rels(e).add(i.relTypeUri, t);
498
- }
499
- return o.add(s), {
500
- path: s,
501
- contentTypeUri: i.contentType,
502
- relId: d
481
+ }, this._scheduledByNodeKey.set(d, f), this._queue.push(f);
482
+ }
483
+ let p = this._nodesByPath.get(e);
484
+ p || (p = /* @__PURE__ */ new Set(), this._nodesByPath.set(e, p)), p.add(d), !o || s || e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", u);
485
+ let m = null;
486
+ if (s) {
487
+ let t = Te(e, f.path);
488
+ m = this._partWriter.rels(e).add(s, t, { idHint: i });
489
+ }
490
+ return l.add(u), {
491
+ path: u,
492
+ contentTypeUri: o,
493
+ relId: m
503
494
  };
504
495
  }
505
- addBinary(e, t, n, r, i = !1) {
506
- return this._addBinaryInternal("", e, t, n, r, i);
496
+ addBinary(e, t, n, r, i = !1, a) {
497
+ return this._addBinaryInternal("", e, t, n, r, i, a);
507
498
  }
508
- _addBinaryInternal(e, t, n, r, i, a = !1) {
499
+ _addBinaryInternal(e, t, n, r, i, a = !1, o) {
509
500
  if (!i) throw Error("No path provided for binary.");
510
501
  if (!n) throw Error("No content type provided for binary.");
511
- let o = this._writtenPaths, s = le(e, i, o, a), c = null;
502
+ let s = this._writtenPaths, c = Ce(e, i, s, a), l = null;
512
503
  if (r) {
513
- let t = de(e, s);
514
- c = this._partWriter.rels(e).add(r, t);
504
+ let t = Te(e, c);
505
+ l = this._partWriter.rels(e).add(r, t, { idHint: o });
515
506
  }
516
- if (e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", s), !o.has(s)) {
517
- let e = s.split(".").pop() || "";
518
- e && this._partWriter.addDefaultType(e, n), this._partWriter.addPart(s, {
507
+ if (e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", c), !s.has(c)) {
508
+ let e = c.split(".").pop() || "";
509
+ e && this._partWriter.addDefaultType(e, n), this._partWriter.addPart(c, {
519
510
  kind: "bytes",
520
511
  bytes: t
521
512
  }, void 0, {
522
513
  level: 0,
523
514
  uncompressedSize: t.byteLength,
524
515
  dataDescriptor: !1
525
- }), o.add(s);
516
+ }), s.add(c);
526
517
  }
527
518
  return {
528
- path: s,
519
+ path: c,
529
520
  contentTypeUri: n,
530
- relId: c
521
+ relId: l
531
522
  };
532
523
  }
533
- _forkPreservedPart(e, t, n, r, i) {
534
- let a = this._sourcePackage;
535
- if (!a) return null;
536
- let o = a.getPart(t);
537
- if (!o) return null;
538
- let s = new Set(this._writtenPaths);
539
- for (let e of a.getNames()) s.add(e);
540
- let c = le(e, i, s), l = this._addBinaryInternal(e, o.data, n, r, "/" + c), u = a.getPart(se(t));
541
- if (u) {
542
- let e = this._partWriter.rels(l.path);
543
- for (let t of ye(u.data)) e.add(t.type, t.target, t.external ? { external: !0 } : void 0);
544
- }
545
- return l;
546
- }
547
524
  async _waitForDescendants(e) {
548
525
  let t = this._nodesByPath.get(e);
549
526
  if (!t || t.size === 0) return;
@@ -567,24 +544,31 @@ var je = class {
567
544
  r.push(e);
568
545
  } }, a;
569
546
  await t.emit(e.payload, {
570
- getXMLWriter: () => a || (a = ae(i), a),
571
- addPart: (e, t, r) => this._addPartInternal(n, e, t, r),
572
- addBinary: (e, t, r, i, a = !1) => this._addBinaryInternal(n, e, t, r, i, a),
573
- addExternal: (e, t) => ({
547
+ getXMLWriter: () => a || (a = _e(i), a),
548
+ addPart: (e, t, r, i) => this._addPartInternal(n, e, t, r, i),
549
+ addBinary: (e, t, r, i, a = !1, o) => this._addBinaryInternal(n, e, t, r, i, a, o),
550
+ addExternal: (e, t, r) => ({
574
551
  path: t,
575
552
  contentTypeUri: null,
576
- relId: this._partWriter.rels(n).add(e, t, { external: !0 })
553
+ relId: this._partWriter.rels(n).add(e, t, {
554
+ external: !0,
555
+ idHint: r
556
+ })
577
557
  }),
578
- addPreservedRelationship: (e, t, r) => {
579
- let i = de(n, t), a = this._partWriter.rels(n).add(e, i, { idHint: r });
558
+ addRelationship: (e, t, r) => {
559
+ if (!this._writtenPaths.has(t) && !this._isSourcePartCarried(t)) return null;
560
+ let i = Te(n, t), a = this._partWriter.rels(n).add(e, i, { idHint: r });
580
561
  return this._explicitRelTargets.add(`${n}::${t}`), a;
581
562
  },
582
- forkPreservedPart: (e, t, r, i) => this._forkPreservedPart(n, e, t, r, i),
583
563
  waitEmit: () => this._waitForDescendants(e.path),
584
564
  getPath: () => e.path,
585
565
  getSharedStates: () => this._mapState,
586
- warn: (e, t) => {
587
- console.warn(e, t);
566
+ warn: (t, n, r) => {
567
+ let i = n ?? e.path, a = this._options.onWarning;
568
+ a ? a(t, i, r) : console.warn(t, i);
569
+ },
570
+ log: (t, n) => {
571
+ console.warn(t, n ?? e.path);
588
572
  }
589
573
  });
590
574
  let o = function(e) {
@@ -594,7 +578,7 @@ var je = class {
594
578
  for (let t of e) n.set(t, r), r += t.byteLength;
595
579
  return n;
596
580
  }(r), s = this._options.onPartEmitted;
597
- s && await s(e.kind, e.path, o), Me && (console.log(`\n=== ${e.path} ===`), console.log(pe(o))), this._partWriter.addPart(e.path, {
581
+ s && await s(e.kind, e.path, o), Ve && (console.log(`\n=== ${e.path} ===`), console.log(De(o))), this._partWriter.addPart(e.path, {
598
582
  kind: "bytes",
599
583
  bytes: o
600
584
  }, e.contentType);
@@ -604,13 +588,14 @@ var je = class {
604
588
  this._nodesByPath.delete(e.path), this._scheduledByNodeKey.delete(e.key), e.resolve();
605
589
  }
606
590
  }
607
- }, Me = !1, Ne = class {
591
+ }, Ve = !1, He = class {
608
592
  constructor() {
609
593
  this.map = /* @__PURE__ */ new Map();
610
594
  }
611
595
  register(e) {
612
- if (this.map.has(e.kind)) throw Error(`Duplicate part kind: ${e.kind}`);
613
- this.map.set(e.kind, e);
596
+ let t = e.getKind();
597
+ if (this.map.has(t)) throw Error(`Duplicate part kind: ${t}`);
598
+ this.map.set(t, e);
614
599
  }
615
600
  get(e) {
616
601
  let t = this.map.get(e);
@@ -620,11 +605,32 @@ var je = class {
620
605
  has(e) {
621
606
  return this.map.has(e);
622
607
  }
608
+ ownsRelType(e) {
609
+ for (let t of this.map.values()) if (t.getRelTypeUri() === e) return !0;
610
+ return !1;
611
+ }
623
612
  };
624
- function Pe(e, t, n) {
613
+ function Ue(e, t, n) {
625
614
  e && (e.algorithm && (t[n ? `${n}AlgorithmName` : "algorithmName"] = e.algorithm), e.hash && (t[n ? `${n}HashValue` : "hashValue"] = e.hash), e.salt && (t[n ? `${n}SaltValue` : "saltValue"] = e.salt), e.spinCount !== void 0 && (t[n ? `${n}SpinCount` : "spinCount"] = e.spinCount));
626
615
  }
627
- var Fe = class {
616
+ var We = "hiddenFormulaXfs", Ge = class {
617
+ constructor(e, t) {
618
+ this._variants = /* @__PURE__ */ new Map(), this._sources = [], this._json = e, this._styles = t, this._directCount = Math.max(1, e?.direct?.length ?? 0);
619
+ }
620
+ getHiddenXf(e) {
621
+ let t = this._variants.get(e);
622
+ return t !== void 0 || (this._isShown(e) ? t = e : (t = this._directCount + this._sources.length, this._sources.push(e)), this._variants.set(e, t)), t;
623
+ }
624
+ getSources() {
625
+ return this._sources;
626
+ }
627
+ _isShown(e) {
628
+ let t = this._json?.direct?.[e], n = t?.protection?.showFormulas;
629
+ if (n !== void 0) return n;
630
+ let r = (e === 0 ? void 0 : t?.named) ?? V.BuiltInName.Normal;
631
+ return this._styles.getNamedStyles().getByName(r)?.toJSON().style?.protection?.showFormulas ?? !1;
632
+ }
633
+ }, Ke = class {
628
634
  constructor() {
629
635
  this._daprFMBks = [], this._daprFMBkMap = /* @__PURE__ */ new Map(), this._rvFMBks = [], this._rvFMBkMap = /* @__PURE__ */ new Map(), this._valueMeta = [];
630
636
  }
@@ -659,20 +665,20 @@ var Fe = class {
659
665
  getValueMeta() {
660
666
  return this._valueMeta;
661
667
  }
662
- }, Ie = class {
668
+ }, qe = class {
663
669
  constructor(e, t = console.warn) {
664
670
  this._entries = [], this._keyMap = /* @__PURE__ */ new Map(), this._metaCollector = e, this._onWarn = t;
665
671
  }
666
672
  add(e) {
667
673
  if (e == null) return this._onWarn?.("RichValueCollector.add: null/undefined value — falling back to #UNKNOWN!"), this._registerFallback();
668
- if (ne.isError(e)) {
669
- let t = e.getCode(), n = this._register(`_error:${t}`, { errorType: "" + (t - 1) }, Le);
674
+ if (se.isError(e)) {
675
+ let t = e.getCode(), n = this._register(`_error:${t}`, { errorType: "" + (t - 1) }, Je);
670
676
  return this._metaCollector.registerRichValueCell(n);
671
677
  }
672
678
  return e.isIRichData && e.getType(), this._onWarn?.("RichValueCollector.add: unsupported rich value type — falling back to #UNKNOWN!", e), this._registerFallback();
673
679
  }
674
680
  _registerFallback() {
675
- let e = this._register("_error:fallback", { errorType: ne.Code.Unknown - 1 }, Le);
681
+ let e = this._register("_error:fallback", { errorType: se.Code.Unknown - 1 }, Je);
676
682
  return this._metaCollector.registerRichValueCell(e);
677
683
  }
678
684
  _register(e, t, n) {
@@ -704,7 +710,7 @@ var Fe = class {
704
710
  }
705
711
  return -1;
706
712
  }
707
- }, Le = new class {
713
+ }, Je = new class {
708
714
  constructor(e, t) {
709
715
  this.type = e, this.props = t;
710
716
  }
@@ -722,58 +728,91 @@ var Fe = class {
722
728
  "subType",
723
729
  "i",
724
730
  "0"
725
- ]]), Re = {
731
+ ]]), Ye = "application/xml", Xe = async (e, t) => {
732
+ let n = e.parts, r = n ? n.length : 0;
733
+ for (let i = 0; i < r; i++) {
734
+ let r = n[i];
735
+ try {
736
+ await Ze(r, t);
737
+ } catch (n) {
738
+ t.log(`Unable to write the part '${r.name ?? r.id}' referenced by '${e.name ?? e.id}'`, n);
739
+ }
740
+ }
741
+ }, Ze = async (e, t, n) => {
742
+ let r = e.resId === void 0 ? void 0 : t.getSharedStates().get(he)?.get(e.resId);
743
+ if (!r) return e.resId === void 0 ? t.addPart("embeddedPart", e, n, e.id) : (t.log(`The part '${e.name ?? e.id}' cites resource ${e.resId}, which is not in the workbook.`), null);
744
+ let i = await r.getExternalURI();
745
+ if (i) {
746
+ let n = t.addExternal(e.type, i, e.id);
747
+ return n.relId !== e.id && t.log(`The external reference '${e.id}' was written as '${n.relId}'; the markup will not find it.`), n;
748
+ }
749
+ let a = await r.toBuffer();
750
+ return t.addBinary(new Uint8Array(a), e.contentType || Ye, e.type, n ?? `./${Qe(e.name)}`, !1, e.id);
751
+ }, Qe = (e) => {
752
+ let t = e && /^[\w.\-~%]+$/.test(e) ? e : "part.xml", n = t.lastIndexOf("."), r = n > 0 ? t.slice(0, n) : t, i = n > 0 ? t.slice(n) : "";
753
+ return `${r.replace(/\d+$/, "")}{n}${i}`;
754
+ }, $e = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml", et = (e, t) => e.getSharedStates().get("pivotCachePaths")?.get(t) ?? null, tt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink", nt = "fileVersion", rt = "sheetParts", it = "externalLinkParts";
755
+ function at(e) {
756
+ if (!e || e.indexOf("[") === -1) return [];
757
+ let t = [], n = e.replace(/"(?:[^"]|"")*"/g, "");
758
+ for (let e of n.matchAll(/\[(\d+)\]/g)) {
759
+ let n = Number(e[1]);
760
+ n > 0 && !t.includes(n) && t.push(n);
761
+ }
762
+ return t;
763
+ }
764
+ var ot = {
726
765
  auto: "auto",
727
766
  automaticExceptTables: "autoNoTable",
728
767
  manual: "manual"
729
768
  };
730
- function U(e, t, n, r) {
769
+ function G(e, t, n, r) {
731
770
  if (!n) return;
732
771
  let i = typeof n == "string" ? t.parseColor(n) : n;
733
772
  r && e.start(r);
734
773
  let a = i.getType(), o = i.getVal(), s = i.getAdjustments(), c = s && s.length > 0;
735
774
  switch (a) {
736
775
  case "scheme":
737
- c ? (e.start("schemeClr", { val: o }), W(e, s), e.end("schemeClr")) : e.empty("schemeClr", { val: o });
776
+ c ? (e.start("schemeClr", { val: o }), K(e, s), e.end("schemeClr")) : e.empty("schemeClr", { val: o });
738
777
  break;
739
778
  case "named":
740
- if (te.isSystem(o)) {
779
+ if (ae.isSystem(o)) {
741
780
  let t = i.getLastColor() ?? i.getBaseColor().toHex().toString(!1).replace("#", "");
742
781
  c ? (e.start("sysClr", {
743
782
  val: o,
744
783
  lastClr: t
745
- }), W(e, s), e.end("sysClr")) : e.empty("sysClr", {
784
+ }), K(e, s), e.end("sysClr")) : e.empty("sysClr", {
746
785
  val: o,
747
786
  lastClr: t
748
787
  });
749
- } else c ? (e.start("prstClr", { val: o }), W(e, s), e.end("prstClr")) : e.empty("prstClr", { val: o });
788
+ } else c ? (e.start("prstClr", { val: o }), K(e, s), e.end("prstClr")) : e.empty("prstClr", { val: o });
750
789
  break;
751
790
  case "auto": {
752
791
  let t = i.getLastColor() ?? i.getBaseColor().toHex().toString(!1).replace("#", "");
753
792
  c ? (e.start("sysClr", {
754
793
  val: "windowText",
755
794
  lastClr: t
756
- }), W(e, s), e.end("sysClr")) : e.empty("sysClr", {
795
+ }), K(e, s), e.end("sysClr")) : e.empty("sysClr", {
757
796
  val: "windowText",
758
797
  lastClr: t
759
798
  });
760
799
  break;
761
800
  }
762
801
  case "index":
763
- c ? (e.start("srgbClr", { val: o }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: o });
802
+ c ? (e.start("srgbClr", { val: o }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: o });
764
803
  break;
765
804
  case "hsl":
766
805
  let t = i.toHex().toString();
767
- c ? (e.start("srgbClr", { val: t }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: t });
806
+ c ? (e.start("srgbClr", { val: t }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: t });
768
807
  break;
769
808
  case "rgb":
770
809
  case "lrgb":
771
810
  let n = i.toHex().toString();
772
- c ? (e.start("srgbClr", { val: n }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: n });
811
+ c ? (e.start("srgbClr", { val: n }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: n });
773
812
  break;
774
813
  case "hex":
775
814
  let r = o.replace("#", "").toUpperCase();
776
- c ? (e.start("srgbClr", { val: r }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: r });
815
+ c ? (e.start("srgbClr", { val: r }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: r });
777
816
  break;
778
817
  default:
779
818
  let a = o.replace("#", "").toUpperCase();
@@ -781,7 +820,7 @@ function U(e, t, n, r) {
781
820
  }
782
821
  r && e.end(r);
783
822
  }
784
- function W(e, t) {
823
+ function K(e, t) {
785
824
  if (t && t.length !== 0) for (let n of t) for (let [t, r] of Object.entries(n)) {
786
825
  if (r == null) continue;
787
826
  let n = t;
@@ -804,47 +843,47 @@ function W(e, t) {
804
843
  }
805
844
  }
806
845
  }
807
- function G(e, t, n, r, i = !1, a = !1) {
846
+ function q(e, t, n, r, i = !1, a = !1) {
808
847
  if (!n) return;
809
848
  let o = typeof n == "string" ? t.parseColor(n) : n, s = () => {
810
- e.empty(r, { rgb: Ke(o.toHex().toString(!0)) });
849
+ e.empty(r, { rgb: mt(o.toHex().toString(!0)) });
811
850
  }, c = o.getAdjustments(), l = c && c.length > 0, u = o.getType();
812
- if (u !== k.Type.Auto) {
813
- if (u === k.Type.Scheme) {
814
- let t = o.getVal(), n = ze[t] ?? t, i = He.get(n);
851
+ if (u !== L.Type.Auto) {
852
+ if (u === L.Type.Scheme) {
853
+ let t = o.getVal(), n = st[t] ?? t, i = ut.get(n);
815
854
  if (i === void 0 && n !== "phClr") return console.warn(`Color scheme not in theme. schemeVal=${t} themeKey=${n}`), s();
816
855
  let a = {};
817
856
  if (a.theme = i, l) {
818
857
  if (!function(e) {
819
858
  for (let t of e) switch (Object.keys(t)[0]) {
820
- case k.AdjustmentType.Tint:
821
- case k.AdjustmentType.ETint:
822
- case k.AdjustmentType.Shade:
823
- case k.AdjustmentType.Lum:
824
- case k.AdjustmentType.LumOff:
825
- case k.AdjustmentType.LumMod:
826
- case k.AdjustmentType.Alpha:
827
- case k.AdjustmentType.AlphaOff:
828
- case k.AdjustmentType.AlphaMod: continue;
859
+ case L.AdjustmentType.Tint:
860
+ case L.AdjustmentType.ETint:
861
+ case L.AdjustmentType.Shade:
862
+ case L.AdjustmentType.Lum:
863
+ case L.AdjustmentType.LumOff:
864
+ case L.AdjustmentType.LumMod:
865
+ case L.AdjustmentType.Alpha:
866
+ case L.AdjustmentType.AlphaOff:
867
+ case L.AdjustmentType.AlphaMod: continue;
829
868
  default: return !1;
830
869
  }
831
870
  return !0;
832
871
  }(c)) return s();
833
- let e = c.length === 1 ? c[0][k.AdjustmentType.ETint] : void 0, t;
834
- if (e !== void 0) t = We(e);
872
+ let e = c.length === 1 ? c[0][L.AdjustmentType.ETint] : void 0, t;
873
+ if (e !== void 0) t = ft(e);
835
874
  else {
836
875
  let e = o.getBaseColor().toHex().toString(!0), n = o.toHex().toString(!0);
837
- t = We(function(e, t) {
838
- let n = Ue(e, 0, 255), r = Ue(t, 0, 255);
839
- return Math.abs(r - n) < 1e-9 ? 0 : r < n ? n <= 1e-9 ? -1 : Ue(r / n - 1, -1, 0) : 255 - n <= 1e-9 ? 0 : Ue((r - n) / (255 - n), 0, 1);
840
- }(Ge(e), Ge(n)));
876
+ t = ft(function(e, t) {
877
+ let n = dt(e, 0, 255), r = dt(t, 0, 255);
878
+ return Math.abs(r - n) < 1e-9 ? 0 : r < n ? n <= 1e-9 ? -1 : dt(r / n - 1, -1, 0) : 255 - n <= 1e-9 ? 0 : dt((r - n) / (255 - n), 0, 1);
879
+ }(pt(e), pt(n)));
841
880
  }
842
881
  t !== 0 && (a.tint = t);
843
882
  }
844
883
  e.empty(r, a);
845
884
  return;
846
885
  }
847
- if (u === k.Type.Index) {
886
+ if (u === L.Type.Index) {
848
887
  let t = o.getVal(), n = t.substring(5, t.length);
849
888
  e.empty(r, { indexed: Number(n) });
850
889
  return;
@@ -853,7 +892,7 @@ function G(e, t, n, r, i = !1, a = !1) {
853
892
  }
854
893
  e.empty(r, { auto: 1 });
855
894
  }
856
- var ze = {
895
+ var st = {
857
896
  bg1: "lt1",
858
897
  tx1: "dk1",
859
898
  bg2: "lt2",
@@ -866,7 +905,7 @@ var ze = {
866
905
  accent6: "accent6",
867
906
  hlink: "hlink",
868
907
  folHlink: "folHlink"
869
- }, Be = Object.freeze([
908
+ }, ct = Object.freeze([
870
909
  "lt1",
871
910
  "dk1",
872
911
  "lt2",
@@ -879,7 +918,7 @@ var ze = {
879
918
  "accent6",
880
919
  "hlink",
881
920
  "folHlink"
882
- ]), Ve = Object.freeze([
921
+ ]), lt = Object.freeze([
883
922
  "dk1",
884
923
  "lt1",
885
924
  "dk2",
@@ -892,15 +931,15 @@ var ze = {
892
931
  "accent6",
893
932
  "hlink",
894
933
  "folHlink"
895
- ]), He = new Map(Be.map((e, t) => [e, t]));
896
- function Ue(e, t, n) {
934
+ ]), ut = new Map(ct.map((e, t) => [e, t]));
935
+ function dt(e, t, n) {
897
936
  return Math.max(t, Math.min(n, e));
898
937
  }
899
- function We(e) {
900
- let t = Ue(e, -1, 1);
938
+ function ft(e) {
939
+ let t = dt(e, -1, 1);
901
940
  return Math.abs(t) < 1e-12 ? 0 : t;
902
941
  }
903
- function Ge(e) {
942
+ function pt(e) {
904
943
  let t = function(e) {
905
944
  let t = e.replace(/^#/, "").toUpperCase();
906
945
  if (t.length === 8) return t.slice(2);
@@ -909,31 +948,58 @@ function Ge(e) {
909
948
  }(e), n = parseInt(t.slice(0, 2), 16) / 255, r = parseInt(t.slice(2, 4), 16) / 255, i = parseInt(t.slice(4, 6), 16) / 255;
910
949
  return (Math.max(n, r, i) + Math.min(n, r, i)) / 2 * 255;
911
950
  }
912
- function Ke(e) {
951
+ function mt(e) {
913
952
  let t = e.replace(/^#/, "").toUpperCase();
914
953
  if (t.length === 8) return t;
915
954
  if (t.length === 6) return "FF" + t;
916
955
  throw Error(`Invalid hex: ${e}`);
917
956
  }
918
- function qe(e, t = !1) {
957
+ function ht(e, t = !1) {
919
958
  let n = e;
920
959
  return n.length === 8 && (n = n.substring(2, 8)), n.length === 6 && (n = (t ? "00" : "FF") + n), n.toUpperCase();
921
960
  }
922
- function K(e, t, n, r, i = !1, a = !1) {
961
+ function gt(e) {
962
+ return `[Threaded comment]\n\nYour version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more: https://go.microsoft.com/fwlink/?linkid=870924\n\nComment:\n ${e.getContent()}`;
963
+ }
964
+ function _t(e, t) {
965
+ if (typeof t == "string") return void vt(e, t);
966
+ let n = t.runs;
967
+ for (let t = 0; t < n.length; t++) {
968
+ let r = n[t];
969
+ e.start("r"), (r.bold || r.italic || r.size !== void 0 || r.font || r.color) && (e.start("rPr"), r.bold && e.empty("b"), r.italic && e.empty("i"), r.size !== void 0 && e.empty("sz", { val: r.size }), r.color && e.empty("color", { rgb: "FF" + r.color.replace(/^#/, "").toUpperCase() }), r.font && e.empty("rFont", { val: r.font }), e.end("rPr")), vt(e, r.text ?? ""), e.end("r");
970
+ }
971
+ }
972
+ function vt(e, t) {
973
+ e.start("t", ie.test(t) || /[\n\r]/.test(t) ? n : void 0), e.text(t), e.end("t");
974
+ }
975
+ function yt(e) {
976
+ let t = e.getRanges();
977
+ if (t.isInvalid()) return null;
978
+ let n = t.getCoords()[0];
979
+ return n ? {
980
+ ref: P.cellToString({
981
+ rowIndex: n.rowStart,
982
+ colIndex: n.colStart
983
+ }),
984
+ row: n.rowStart,
985
+ col: n.colStart
986
+ } : null;
987
+ }
988
+ function J(e, t, n, r, i = !1, a = !1) {
923
989
  let o = r.getTheme();
924
990
  if (i && t.start("fill"), typeof n == "string" && (n = {
925
- type: N.Type.Solid,
991
+ type: B.Type.Solid,
926
992
  color: n
927
- }), n.type === N.Type.None) i ? t.empty("patternFill", { patternType: "none" }) : t.empty("noFill");
928
- else if (n.type === N.Type.Solid) {
993
+ }), n.type === B.Type.None) i ? t.empty("patternFill", { patternType: "none" }) : t.empty("noFill");
994
+ else if (n.type === B.Type.Solid) {
929
995
  let e = n;
930
- i ? t.start("patternFill", { patternType: "solid" }) : t.start("solidFill"), e.color && (i ? G(t, o, e.color, "fgColor") : U(t, o, e.color)), i ? t.end("patternFill") : t.end("solidFill");
931
- } else if (n.type === N.Type.Pattern) {
996
+ i ? t.start("patternFill", { patternType: "solid" }) : t.start("solidFill"), e.color && (i ? q(t, o, e.color, "fgColor") : G(t, o, e.color)), i ? t.end("patternFill") : t.end("solidFill");
997
+ } else if (n.type === B.Type.Pattern) {
932
998
  let e = n, r = e.patternType || "solid";
933
- t.start("patternFill", { patternType: r }), e.foreground && (i ? G(t, o, a ? e.background : e.foreground, "fgColor") : U(t, o, a ? e.background : e.foreground)), e.background && (i ? G(t, o, a ? e.foreground : e.background, "bgColor") : U(t, o, a ? e.foreground : e.background)), t.end("patternFill");
934
- } else if (n.type === N.Type.Gradient && i) {
999
+ t.start("patternFill", { patternType: r }), e.foreground && (i ? q(t, o, a ? e.background : e.foreground, "fgColor") : G(t, o, a ? e.background : e.foreground)), e.background && (i ? q(t, o, a ? e.foreground : e.background, "bgColor") : G(t, o, a ? e.foreground : e.background)), t.end("patternFill");
1000
+ } else if (n.type === B.Type.Gradient && i) {
935
1001
  let e = n, r = {}, i = e.gradientType;
936
- if (i !== N.GradientType.Path && i !== N.GradientType.Linear || (r.type = i), e.angle !== void 0) {
1002
+ if (i !== B.GradientType.Path && i !== B.GradientType.Linear || (r.type = i), e.angle !== void 0) {
937
1003
  let t = (e.angle - 90) % 360;
938
1004
  t !== 0 && (r.degree = String(t));
939
1005
  }
@@ -947,10 +1013,10 @@ function K(e, t, n, r, i = !1, a = !1) {
947
1013
  let t = e;
948
1014
  r = t.offset || 0, n = t.color;
949
1015
  }
950
- t.start("stop", { position: String(r) }), n && G(t, o, n, "color"), t.end("stop");
1016
+ t.start("stop", { position: String(r) }), n && q(t, o, n, "color"), t.end("stop");
951
1017
  }
952
1018
  t.end("gradientFill");
953
- } else if (n.type === N.Type.Gradient) {
1019
+ } else if (n.type === B.Type.Gradient) {
954
1020
  let e = n, r = {};
955
1021
  e.isRotatedWithShape !== void 0 && (r.rotWithShape = e.isRotatedWithShape ? "1" : "0"), t.start("gradFill", r), t.start("gsLst");
956
1022
  let i = e.stops;
@@ -961,22 +1027,22 @@ function K(e, t, n, r, i = !1, a = !1) {
961
1027
  let t = e;
962
1028
  r = t.offset || 0, n = t.color;
963
1029
  }
964
- t.start("gs", { pos: String(D.roundAccurately(1e3 * r, 0)) }), n && U(t, o, n), t.end("gs");
1030
+ t.start("gs", { pos: String(I.roundAccurately(1e3 * r, 0)) }), n && G(t, o, n), t.end("gs");
965
1031
  }
966
1032
  t.end("gsLst");
967
1033
  let a = e.gradientType;
968
- if (a && a !== N.GradientType.Linear) {
1034
+ if (a && a !== B.GradientType.Linear) {
969
1035
  let n = a === "radial" ? "circle" : a;
970
1036
  t.start("path", { path: n });
971
1037
  let r = e.focus;
972
1038
  if (r) {
973
1039
  let e = {};
974
- r.t !== void 0 && (e.t = String(D.roundAccurately(1e3 * r.t, 0))), r.l !== void 0 && (e.l = String(D.roundAccurately(1e3 * r.l, 0))), r.b !== void 0 && (e.b = String(D.roundAccurately(1e3 * r.b, 0))), r.r !== void 0 && (e.r = String(D.roundAccurately(1e3 * r.r, 0))), t.empty("fillToRect", e);
1040
+ r.t !== void 0 && (e.t = String(I.roundAccurately(1e3 * r.t, 0))), r.l !== void 0 && (e.l = String(I.roundAccurately(1e3 * r.l, 0))), r.b !== void 0 && (e.b = String(I.roundAccurately(1e3 * r.b, 0))), r.r !== void 0 && (e.r = String(I.roundAccurately(1e3 * r.r, 0))), t.empty("fillToRect", e);
975
1041
  }
976
1042
  t.end("path");
977
1043
  } else {
978
1044
  let n = {};
979
- e.angle !== void 0 && (n.ang = String(D.roundAccurately(6e4 * e.angle, 0)));
1045
+ e.angle !== void 0 && (n.ang = String(I.roundAccurately(6e4 * e.angle, 0)));
980
1046
  let r = e.scaled;
981
1047
  r !== void 0 && (n.scaled = r ? "1" : "0"), t.empty("lin", n);
982
1048
  }
@@ -984,70 +1050,70 @@ function K(e, t, n, r, i = !1, a = !1) {
984
1050
  } else i ? t.empty("patternFill", { patternType: "none" }) : t.empty("noFill");
985
1051
  i && t.end("fill");
986
1052
  }
987
- var Je = (e, t, n, r) => {
1053
+ var bt = (e, t, n, r) => {
988
1054
  if (!n) return t.start("ln"), t.empty("noFill"), void t.end("ln");
989
1055
  typeof n == "string" && (n = { fill: n });
990
1056
  let i = n, a = {};
991
- if (i.width !== void 0 && (a.w = String(q(i.width))), i.lineCap !== void 0 && (a.cap = Ye(i.lineCap)), i.compound !== void 0 && (a.cmpd = i.compound), i.align !== void 0 && (a.algn = i.align), t.start("ln", a), K(0, t, i.fill ?? $e, r), Array.isArray(i.dash)) {
1057
+ if (i.width !== void 0 && (a.w = String(Y(i.width))), i.lineCap !== void 0 && (a.cap = xt(i.lineCap)), i.compound !== void 0 && (a.cmpd = i.compound), i.align !== void 0 && (a.algn = i.align), t.start("ln", a), J(0, t, i.fill ?? Tt, r), Array.isArray(i.dash)) {
992
1058
  t.start("custDash");
993
1059
  for (let e = 0; e < i.dash.length; e += 2) t.empty("ds", {
994
- d: String(D.roundAccurately(1e3 * i.dash[e], 0)),
995
- sp: String(D.roundAccurately(1e3 * (i.dash[e + 1] ?? 0), 0))
1060
+ d: String(I.roundAccurately(1e3 * i.dash[e], 0)),
1061
+ sp: String(I.roundAccurately(1e3 * (i.dash[e + 1] ?? 0), 0))
996
1062
  });
997
1063
  t.end("custDash");
998
1064
  } else typeof i.dash == "string" && t.empty("prstDash", { val: i.dash });
999
- if (i.lineJoin === F.LineJoin.Round) t.empty("round");
1000
- else if (i.lineJoin === F.LineJoin.Bevel) t.empty("bevel");
1001
- else if (i.lineJoin === F.LineJoin.Miter) {
1065
+ if (i.lineJoin === de.LineJoin.Round) t.empty("round");
1066
+ else if (i.lineJoin === de.LineJoin.Bevel) t.empty("bevel");
1067
+ else if (i.lineJoin === de.LineJoin.Miter) {
1002
1068
  let e = {};
1003
- i.miterLimit !== void 0 && (e.lim = String(D.roundAccurately(1e5 * i.miterLimit, 0))), t.empty("miter", e);
1069
+ i.miterLimit !== void 0 && (e.lim = String(I.roundAccurately(1e5 * i.miterLimit, 0))), t.empty("miter", e);
1004
1070
  }
1005
1071
  t.end("ln");
1006
- }, Ye = (e) => e === "round" ? "rnd" : e === "butt" ? "flat" : e === "square" ? "sq" : e, Xe = (e, t, n, r = void 0, i = !1) => {
1072
+ }, xt = (e) => e === "round" ? "rnd" : e === "butt" ? "flat" : e === "square" ? "sq" : e, St = (e, t, n, r = void 0, i = !1) => {
1007
1073
  if (!n || !(n.fill || n.stroke || n.effects?.length || i)) return;
1008
1074
  let a = e.getXMLWriter();
1009
- r && a.start(r), a.pushDefaultNamespace("a"), n.fill && K(0, a, n.fill, t), n.stroke && Je(0, a, n.stroke, t), n.effects?.length ? Ze(e, a, t.getTheme(), n.effects) : i && a.empty("effectLst"), a.popDefaultNamespace(), r && a.end(r);
1010
- }, Ze = (e, t, n, r) => {
1075
+ r && a.start(r), a.pushDefaultNamespace("a"), n.fill && J(0, a, n.fill, t), n.stroke && bt(0, a, n.stroke, t), n.effects?.length ? Ct(e, a, t.getTheme(), n.effects) : i && a.empty("effectLst"), a.popDefaultNamespace(), r && a.end(r);
1076
+ }, Ct = (e, t, n, r) => {
1011
1077
  t.start("effectLst");
1012
- for (let e of r) Qe(t, n, e);
1078
+ for (let e of r) wt(t, n, e);
1013
1079
  t.end("effectLst");
1014
- }, Qe = (e, t, n) => {
1080
+ }, wt = (e, t, n) => {
1015
1081
  switch (n.type) {
1016
- case M.Type.OuterShadow: {
1082
+ case le.Type.OuterShadow: {
1017
1083
  let r = n, i = {};
1018
- r.blur !== void 0 && (i.blurRad = String(q(r.blur))), r.distance !== void 0 && (i.dist = String(q(r.distance))), r.angle !== void 0 && (i.dir = String(Y(r.angle))), r.alignment !== void 0 && (i.algn = r.alignment), r.isRotatedWithShape !== void 0 && (i.rotWithShape = r.isRotatedWithShape ? "1" : "0"), r.scaleX !== void 0 && (i.sx = String(D.roundAccurately(1e3 * r.scaleX, 0))), r.scaleY !== void 0 && (i.sy = String(D.roundAccurately(1e3 * r.scaleY, 0))), r.skewX !== void 0 && (i.kx = String(Y(r.skewX))), r.skewY !== void 0 && (i.ky = String(Y(r.skewY))), e.start("outerShdw", i), U(e, t, r.color), e.end("outerShdw");
1084
+ r.blur !== void 0 && (i.blurRad = String(Y(r.blur))), r.distance !== void 0 && (i.dist = String(Y(r.distance))), r.angle !== void 0 && (i.dir = String(Z(r.angle))), r.alignment !== void 0 && (i.algn = r.alignment), r.isRotatedWithShape !== void 0 && (i.rotWithShape = r.isRotatedWithShape ? "1" : "0"), r.scaleX !== void 0 && (i.sx = String(I.roundAccurately(1e3 * r.scaleX, 0))), r.scaleY !== void 0 && (i.sy = String(I.roundAccurately(1e3 * r.scaleY, 0))), r.skewX !== void 0 && (i.kx = String(Z(r.skewX))), r.skewY !== void 0 && (i.ky = String(Z(r.skewY))), e.start("outerShdw", i), G(e, t, r.color), e.end("outerShdw");
1019
1085
  break;
1020
1086
  }
1021
- case M.Type.InnerShadow: {
1087
+ case le.Type.InnerShadow: {
1022
1088
  let r = n, i = {};
1023
- r.blur !== void 0 && (i.blurRad = String(q(r.blur))), r.distance !== void 0 && (i.dist = String(q(r.distance))), r.angle !== void 0 && (i.dir = String(Y(r.angle))), e.start("innerShdw", i), U(e, t, r.color), e.end("innerShdw");
1089
+ r.blur !== void 0 && (i.blurRad = String(Y(r.blur))), r.distance !== void 0 && (i.dist = String(Y(r.distance))), r.angle !== void 0 && (i.dir = String(Z(r.angle))), e.start("innerShdw", i), G(e, t, r.color), e.end("innerShdw");
1024
1090
  break;
1025
1091
  }
1026
- case M.Type.PresetShadow: {
1092
+ case le.Type.PresetShadow: {
1027
1093
  let r = n, i = { prst: r.preset };
1028
- r.distance !== void 0 && (i.dist = String(q(r.distance))), r.angle !== void 0 && (i.dir = String(Y(r.angle))), e.start("prstShdw", i), U(e, t, r.color), e.end("prstShdw");
1094
+ r.distance !== void 0 && (i.dist = String(Y(r.distance))), r.angle !== void 0 && (i.dir = String(Z(r.angle))), e.start("prstShdw", i), G(e, t, r.color), e.end("prstShdw");
1029
1095
  break;
1030
1096
  }
1031
- case M.Type.Glow: {
1097
+ case le.Type.Glow: {
1032
1098
  let r = n, i = {};
1033
- r.radius !== void 0 && (i.rad = String(q(r.radius))), e.start("glow", i), U(e, t, r.color), e.end("glow");
1099
+ r.radius !== void 0 && (i.rad = String(Y(r.radius))), e.start("glow", i), G(e, t, r.color), e.end("glow");
1034
1100
  break;
1035
1101
  }
1036
- case M.Type.SoftEdge: {
1102
+ case le.Type.SoftEdge: {
1037
1103
  let t = n, r = {};
1038
- t.radius !== void 0 && (r.rad = String(q(t.radius))), e.empty("softEdge", r);
1104
+ t.radius !== void 0 && (r.rad = String(Y(t.radius))), e.empty("softEdge", r);
1039
1105
  break;
1040
1106
  }
1041
- case M.Type.Reflection: {
1107
+ case le.Type.Reflection: {
1042
1108
  let t = n, r = {};
1043
- t.blur !== void 0 && (r.blurRad = String(q(t.blur))), t.distance !== void 0 && (r.dist = String(q(t.distance))), t.angle !== void 0 && (r.dir = String(Y(t.angle))), t.fadeAngle !== void 0 && (r.fadeDir = String(Y(t.fadeAngle))), t.startAlpha !== void 0 && (r.stA = String(D.roundAccurately(1e3 * t.startAlpha, 0))), t.startPosition !== void 0 && (r.stPos = String(D.roundAccurately(1e3 * t.startPosition, 0))), t.endAlpha !== void 0 && (r.endA = String(D.roundAccurately(1e3 * t.endAlpha, 0))), t.endPosition !== void 0 && (r.endPos = String(D.roundAccurately(1e3 * t.endPosition, 0))), t.scaleX !== void 0 && (r.sx = String(D.roundAccurately(1e3 * t.scaleX, 0))), t.scaleY !== void 0 && (r.sy = String(D.roundAccurately(1e3 * t.scaleY, 0))), t.skewX !== void 0 && (r.kx = String(Y(t.skewX))), t.skewY !== void 0 && (r.ky = String(Y(t.skewY))), t.alignment !== void 0 && (r.algn = t.alignment), t.isRotatedWithShape !== void 0 && (r.rotWithShape = t.isRotatedWithShape ? "1" : "0"), e.empty("reflection", r);
1109
+ t.blur !== void 0 && (r.blurRad = String(Y(t.blur))), t.distance !== void 0 && (r.dist = String(Y(t.distance))), t.angle !== void 0 && (r.dir = String(Z(t.angle))), t.fadeAngle !== void 0 && (r.fadeDir = String(Z(t.fadeAngle))), t.startAlpha !== void 0 && (r.stA = String(I.roundAccurately(1e3 * t.startAlpha, 0))), t.startPosition !== void 0 && (r.stPos = String(I.roundAccurately(1e3 * t.startPosition, 0))), t.endAlpha !== void 0 && (r.endA = String(I.roundAccurately(1e3 * t.endAlpha, 0))), t.endPosition !== void 0 && (r.endPos = String(I.roundAccurately(1e3 * t.endPosition, 0))), t.scaleX !== void 0 && (r.sx = String(I.roundAccurately(1e3 * t.scaleX, 0))), t.scaleY !== void 0 && (r.sy = String(I.roundAccurately(1e3 * t.scaleY, 0))), t.skewX !== void 0 && (r.kx = String(Z(t.skewX))), t.skewY !== void 0 && (r.ky = String(Z(t.skewY))), t.alignment !== void 0 && (r.algn = t.alignment), t.isRotatedWithShape !== void 0 && (r.rotWithShape = t.isRotatedWithShape ? "1" : "0"), e.empty("reflection", r);
1044
1110
  break;
1045
1111
  }
1046
1112
  }
1047
- }, $e = { type: "none" }, et = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", tt = {
1113
+ }, Tt = { type: "none" }, Et = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", Dt = "imagesWritten", Ot = {
1048
1114
  mime: "image/png",
1049
1115
  ext: "png"
1050
- }, q = (e = 0) => D.roundAccurately(12700 * e, 0), J = (e = 0) => D.roundAccurately(9525 * e, 0), Y = (e) => 6e4 * e, nt = (e = 0) => D.roundAccurately(100 * e, 2), rt = class {
1116
+ }, Y = (e = 0) => I.roundAccurately(12700 * e, 0), X = (e = 0) => I.roundAccurately(9525 * e, 0), Z = (e) => 6e4 * e, kt = (e = 0) => I.roundAccurately(100 * e, 2), At = class {
1051
1117
  constructor() {
1052
1118
  this._dxfs = [], this._byKey = /* @__PURE__ */ new Map();
1053
1119
  }
@@ -1061,64 +1127,64 @@ var Je = (e, t, n, r) => {
1061
1127
  getCount() {
1062
1128
  return this._dxfs.length;
1063
1129
  }
1064
- }, it = "cfDxfs", at = [
1130
+ }, jt = "cfDxfs", Mt = [
1065
1131
  "font",
1066
1132
  "fill",
1067
- "border",
1133
+ "borders",
1068
1134
  "numberFormat",
1069
1135
  "alignment"
1070
1136
  ];
1071
- function ot(e, t, n) {
1137
+ function Nt(e, t, n) {
1072
1138
  if (t) {
1073
1139
  if (t.named) {
1074
1140
  let r = t.named, i = r.toLowerCase(), a = n.namedStyleMap;
1075
1141
  if (!a.has(i)) {
1076
1142
  a.set(i, "" + a.size);
1077
- let t = e.getNamed(r).toJSON();
1078
- ot(e, t.style ?? D.EmptyObject, n), n.namedStyles.push(t);
1143
+ let t = e.getNamedStyles().getByName(r).toJSON();
1144
+ Nt(e, t.style ?? I.EmptyObject, n), n.namedStyles.push(t);
1079
1145
  }
1080
1146
  }
1081
1147
  t.font && function(e, t, n) {
1082
1148
  if (!t) return;
1083
- let r = E.JSONStableStringify(t), i = n.fontMap;
1149
+ let r = F.JSONStableStringify(t), i = n.fontMap;
1084
1150
  if (!i.has(r)) {
1085
1151
  let e = i.size;
1086
1152
  i.set(r, "" + e), n.fonts.push(t);
1087
1153
  }
1088
1154
  }(0, t.font, n), t.fill && function(e, t, n) {
1089
1155
  if (!t) return;
1090
- let r = E.JSONStableStringify(t), i = n.fillMap;
1156
+ let r = F.JSONStableStringify(t), i = n.fillMap;
1091
1157
  if (!i.has(r) && typeof t == "object" && t.type) {
1092
1158
  let e = i.size;
1093
1159
  i.set(r, "" + e), n.fills.push(t);
1094
1160
  }
1095
- }(0, t.fill, n), t.border && function(e, t, n) {
1161
+ }(0, t.fill, n), t.borders && function(e, t, n) {
1096
1162
  if (!t) return;
1097
- let r = E.JSONStableStringify(t), i = n.borderMap;
1163
+ let r = F.JSONStableStringify(t), i = n.borderMap;
1098
1164
  if (!i.has(r)) {
1099
1165
  let e = i.size;
1100
1166
  i.set(r, "" + e), n.borders.push(t);
1101
1167
  }
1102
- }(0, t.border, n), t.numberFormat !== void 0 && function(e, t, n) {
1168
+ }(0, t.borders, n), t.numberFormat !== void 0 && function(e, t, n) {
1103
1169
  if (!t) return;
1104
- let r = R.toBuiltInID(t), i = n.numFmtMap;
1170
+ let r = pe.toBuiltInID(t), i = n.numFmtMap;
1105
1171
  if (!i.has(r)) {
1106
1172
  let e = 0;
1107
- typeof r == "number" ? e = r : (e = n.numFmtsCustom.length + pt, n.numFmtsCustom.push(r)), i.set(t, "" + e);
1173
+ typeof r == "number" ? e = r : (e = n.numFmtsCustom.length + Vt, n.numFmtsCustom.push(r)), i.set(t, "" + e);
1108
1174
  }
1109
1175
  }(0, t.numberFormat, n);
1110
1176
  }
1111
1177
  }
1112
- function st(e, t, n) {
1178
+ function Pt(e, t, n) {
1113
1179
  if (!t) return;
1114
1180
  let r = t.name.toLowerCase();
1115
- n.namedStyleMap.has(r) || (n.namedStyleMap.set(r, "" + n.namedStyleMap.size), n.namedStyles.push(t), ot(e, t.style, n));
1181
+ n.namedStyleMap.has(r) || (n.namedStyleMap.set(r, "" + n.namedStyleMap.size), n.namedStyles.push(t), Nt(e, t.style, n));
1116
1182
  }
1117
- function ct(e, t, n, r, i = !1) {
1183
+ function Ft(e, t, n, r, i = !1) {
1118
1184
  let a = r.getDefaultFontSize(), o = r.getTheme().getFontScheme().getMinorFont() ?? "Calibri", s = r.getNormal().getFont().getColor();
1119
1185
  t.start("font"), n.weight && n.weight >= 700 && t.empty("b"), n.style && n.style !== "normal" && t.empty("i"), n.strike && t.empty("strike"), n.underline && t.empty("u", { val: n.underline }), n.outline && t.empty("outline"), n.shadow && t.empty("shadow"), n.extend && t.empty("extend");
1120
1186
  let c = n.verticalAlign;
1121
- c && (c === "super" && (c = "superscript"), c === "sub" && (c = "subscript"), t.empty("vertAlign", { val: c })), i ? n.size !== void 0 && t.empty("sz", { val: String(n.size) }) : t.empty("sz", { val: String(n.size ?? a) }), G(t, r.getTheme(), n.color ?? s, "color", !i);
1187
+ c && (c === "super" && (c = "superscript"), c === "sub" && (c = "subscript"), t.empty("vertAlign", { val: c })), i ? n.size !== void 0 && t.empty("sz", { val: String(n.size) }) : t.empty("sz", { val: String(n.size ?? a) }), q(t, r.getTheme(), n.color ?? s, "color", !i);
1122
1188
  let l = !i || n.family && n.family !== o;
1123
1189
  if (l && (t.empty("name", { val: n.family ?? o }), n.fallbacks && n.fallbacks.length > 0)) {
1124
1190
  let e = n.fallbacks;
@@ -1128,57 +1194,59 @@ function ct(e, t, n, r, i = !1) {
1128
1194
  let u = n.scheme ?? (n.family === void 0 ? "minor" : void 0);
1129
1195
  l && u !== void 0 && u !== "none" && t.empty("scheme", { val: u }), t.end("font");
1130
1196
  }
1131
- function X(e, t, n, r, i, a = !1) {
1197
+ function It(e, t, n, r, i, a = !1) {
1132
1198
  if (!i || i.style === "none" || !i.style) return void (a && !i || t.empty(r));
1133
1199
  t.start(r, { style: i.style });
1134
1200
  let o = i.color;
1135
- o && G(t, n, o, "color", !a, a), t.end(r);
1201
+ o && q(t, n, o, "color", !a, a), t.end(r);
1136
1202
  }
1137
- function lt(e, t, n, r, i = !1) {
1203
+ function Lt(e, t, n, r, i = !1) {
1138
1204
  let a = {};
1139
- i ? (a.diagonalUp = "0", a.diagonalDown = "0") : (n.diagonalUp && (a.diagonalUp = "1"), n.diagonalDown && (a.diagonalDown = "1")), t.start("border", a), X(0, t, r, "left", n.left, i), X(0, t, r, "right", n.right, i), X(0, t, r, "top", n.top, i), X(0, t, r, "bottom", n.bottom, i), i ? (X(0, t, r, "vertical", n.vertical, i), X(0, t, r, "horizontal", n.horizontal, i)) : X(0, t, r, "diagonal", n.diagonalUp ?? n.diagonalDown, i), t.end("border");
1205
+ i ? (a.diagonalUp = "0", a.diagonalDown = "0") : (n.diagonalUp && (a.diagonalUp = "1"), n.diagonalDown && (a.diagonalDown = "1")), t.start("border", a), It(0, t, r, "left", n.left, i), It(0, t, r, "right", n.right, i), It(0, t, r, "top", n.top, i), It(0, t, r, "bottom", n.bottom, i), i ? (It(0, t, r, "vertical", n.vertical, i), It(0, t, r, "horizontal", n.horizontal, i)) : It(0, t, r, "diagonal", n.diagonalUp ?? n.diagonalDown, i), t.end("border");
1140
1206
  }
1141
- function ut(e, t, n, r = !1) {
1207
+ function Rt(e, t, n, r = !1) {
1142
1208
  let i = {};
1143
- n.horizontal && n.horizontal !== L.HorizontalAlignment.General && (i.horizontal = n.horizontal), n.vertical && n.vertical !== L.VerticalAlignment.Bottom && (i.vertical = n.vertical);
1209
+ n.horizontal && n.horizontal !== H.HorizontalAlignment.General && (i.horizontal = n.horizontal), n.vertical && n.vertical !== H.VerticalAlignment.Bottom && (i.vertical = n.vertical);
1144
1210
  let a = n.rotation;
1145
1211
  n.stacked && (i.textRotation = "255", a = 0), a && (a >= 270 && a < 360 ? a = 360 - a : a > 0 && a <= 90 && (a += 90), i.textRotation = String(a));
1146
1212
  let o = n.overflow;
1147
- switch (o === L.Overflow.Wrap && (i.wrapText = "1"), n.indent && (i.indent = "" + n.indent), n.relativeIndent && (i.relativeIndent = "" + n.relativeIndent), n.justifyLastLine && (i.justifyLastLine = "1"), o === L.Overflow.Shrink && (i.shrinkToFit = "1"), n.readingDirection) {
1148
- case L.ReadingDirection.Auto: break;
1149
- case L.ReadingDirection.LeftToRight:
1213
+ switch (o === H.Overflow.Wrap && (i.wrapText = "1"), n.indent && (i.indent = "" + n.indent), n.relativeIndent && (i.relativeIndent = "" + n.relativeIndent), n.justifyLastLine && (i.justifyLastLine = "1"), o === H.Overflow.Shrink && (i.shrinkToFit = "1"), n.readingDirection) {
1214
+ case H.ReadingDirection.Auto: break;
1215
+ case H.ReadingDirection.LeftToRight:
1150
1216
  i.readingOrder = "1";
1151
1217
  break;
1152
- case L.ReadingDirection.RightToLeft: i.readingOrder = "2";
1218
+ case H.ReadingDirection.RightToLeft: i.readingOrder = "2";
1153
1219
  }
1154
1220
  return Object.keys(i).length > 0 ? i : null;
1155
1221
  }
1156
- function dt(e, t, n, r, i, a) {
1157
- let o = {}, s = null, c = r.named;
1158
- c && (s = n.getNamed(c).toJSON().style);
1159
- let l = r.font ?? s?.font, u = l ? i.fontMap.get(E.JSONStableStringify(l)) ?? 0 : 0, d = r.fill ?? s?.fill, f = d ? i.fillMap.get(E.JSONStableStringify(d)) ?? 0 : 0, p = r.border ?? s?.border, m = p ? i.borderMap.get(E.JSONStableStringify(p)) ?? 0 : 0, h = r.numberFormat ?? s?.numberFormat;
1160
- if (o.numFmtId = (h === void 0 ? void 0 : i.numFmtMap.get(h)) ?? "0", o.fontId = String(u), o.fillId = String(f), o.borderId = String(m), a) {
1161
- let e = r.named ?? I.BuiltInName.Normal;
1162
- o.xfId = i.namedStyleMap.get(e.toLowerCase());
1163
- }
1164
- let g = null, _ = r.alignment ?? s?.alignment;
1165
- _ && (g = ut(0, 0, _)), r.font && (o.applyFont = "1"), r.fill && (o.applyFill = "1"), r.numberFormat && (o.applyNumberFormat = "1"), r.border && (o.applyBorder = "1"), g && (o.applyAlignment = "1"), r.quotePrefix && (o.quotePrefix = "1"), g ? (t.start("xf", o), g && t.empty("alignment", g), t.end("xf")) : t.empty("xf", o);
1222
+ function zt(e, t, n, r, i, a, o = !1) {
1223
+ let s = {}, c = null, l = r.named;
1224
+ l && (c = n.getNamedStyles().getByName(l).toJSON().style);
1225
+ let u = r.font ?? c?.font, d = u ? i.fontMap.get(F.JSONStableStringify(u)) ?? 0 : 0, f = r.fill ?? c?.fill, p = f ? i.fillMap.get(F.JSONStableStringify(f)) ?? 0 : 0, m = r.borders ?? c?.borders, h = m ? i.borderMap.get(F.JSONStableStringify(m)) ?? 0 : 0, g = r.numberFormat ?? c?.numberFormat;
1226
+ if (s.numFmtId = (g === void 0 ? void 0 : i.numFmtMap.get(g)) ?? "0", s.fontId = String(d), s.fillId = String(p), s.borderId = String(h), a) {
1227
+ let e = r.named ?? V.BuiltInName.Normal;
1228
+ s.xfId = i.namedStyleMap.get(e.toLowerCase());
1229
+ }
1230
+ let _ = null, v = r.alignment ?? c?.alignment;
1231
+ v && (_ = Rt(0, 0, v)), r.font && (s.applyFont = "1"), r.fill && (s.applyFill = "1"), r.numberFormat && (s.applyNumberFormat = "1"), r.borders && (s.applyBorder = "1"), _ && (s.applyAlignment = "1");
1232
+ let y = null, b = r.protection?.alwaysUnlocked ?? c?.protection?.alwaysUnlocked ?? !1;
1233
+ (b || o) && (y = {}, b && (y.locked = "0"), o && (y.hidden = "1"), s.applyProtection = "1"), r.quotePrefix && (s.quotePrefix = "1"), _ || y ? (t.start("xf", s), _ && t.empty("alignment", _), y && t.empty("protection", y), t.end("xf")) : t.empty("xf", s);
1166
1234
  }
1167
- function ft(e, t, n, r, i, a = "dxf", o = pt) {
1168
- if (t.start(a), n.font && ct(0, t, n.font, r, !0), n.numberFormat !== void 0 && n.numberFormat !== null) {
1169
- let e = R.toBuiltInID(n.numberFormat), r = typeof e == "number", i = r ? R.builtInFormat(e) : String(e);
1235
+ function Bt(e, t, n, r, i, a = "dxf", o = Vt) {
1236
+ if (t.start(a), n.font && Ft(0, t, n.font, r, !0), n.numberFormat !== void 0 && n.numberFormat !== null) {
1237
+ let e = pe.toBuiltInID(n.numberFormat), r = typeof e == "number", i = r ? pe.builtInFormat(e) : String(e);
1170
1238
  i && t.empty("numFmt", {
1171
1239
  numFmtId: String(r ? e : o++),
1172
1240
  formatCode: i
1173
1241
  });
1174
1242
  }
1175
- if (n.fill && K(0, t, n.fill, r, !0, !0), n.alignment) {
1176
- let e = ut(0, 0, n.alignment, !0);
1243
+ if (n.fill && J(0, t, n.fill, r, !0, !0), n.alignment) {
1244
+ let e = Rt(0, 0, n.alignment, !0);
1177
1245
  e && t.empty("alignment", e);
1178
1246
  }
1179
- return n.border && lt(0, t, n.border, i, !0), t.end(a), o;
1247
+ return n.borders && Lt(0, t, n.borders, i, !0), t.end(a), o;
1180
1248
  }
1181
- var pt = 164, mt = Object.freeze([
1249
+ var Vt = 164, Ht = Object.freeze([
1182
1250
  "wholeTable",
1183
1251
  "headerRow",
1184
1252
  "totalRow",
@@ -1192,7 +1260,7 @@ var pt = 164, mt = Object.freeze([
1192
1260
  "lastHeaderCell",
1193
1261
  "firstTotalCell",
1194
1262
  "lastTotalCell"
1195
- ]), ht = A.BuiltInOperatorNames, gt = (e, t, n, r, i, a) => {
1263
+ ]), Ut = R.BuiltInOperatorNames, Wt = (e, t, n, r, i, a) => {
1196
1264
  let o = r.sorts, s = o ? o.length : 0;
1197
1265
  if (s === 0) return;
1198
1266
  let c = {};
@@ -1211,7 +1279,7 @@ var pt = 164, mt = Object.freeze([
1211
1279
  }).toString(), r.sortOn && (c.sortBy = r.sortOn), r.dxfId !== void 0 && (c.dxfId = r.dxfId), r.iconSet !== void 0 && (c.iconSet = r.iconSet), r.customList !== void 0 && (c.customList = r.customList), t.empty("sortCondition", c);
1212
1280
  }
1213
1281
  t.end("sortState");
1214
- }, _t = (e, t, n, r, i = !1) => {
1282
+ }, Gt = (e, t, n, r, i = !1) => {
1215
1283
  let a = n.getRange();
1216
1284
  n.isShowTotals() && (a = a.getResizeBy(-1, 0));
1217
1285
  let o = a.getCoords(), s = r.sort, c = r.filter, l = c ? c.conditions : void 0, u = l ? l.length : 0, d = r.hiddenButtons, f = {};
@@ -1231,58 +1299,58 @@ var pt = 164, mt = Object.freeze([
1231
1299
  r.columns ? c = r.columns.length : i && (c = a.getColumnCount()), t.start("autoFilter", f);
1232
1300
  for (let n = 0; n < c; n++) {
1233
1301
  let r = !0 === d || !0 === p?.[n], i = m[n];
1234
- (i || r) && yt(e, t, n, i, r);
1302
+ (i || r) && qt(e, t, n, i, r);
1235
1303
  }
1236
- s && i && gt(0, t, n, s, a, o), t.end("autoFilter");
1304
+ s && i && Wt(0, t, n, s, a, o), t.end("autoFilter");
1237
1305
  } else t.empty("autoFilter", f);
1238
- s && !i && gt(0, t, n, s, a, o);
1239
- }, vt = (e, t, n) => {
1240
- let r = v(n, (t) => e.warn(t, n));
1306
+ s && !i && Wt(0, t, n, s, a, o);
1307
+ }, Kt = (e, t, n) => {
1308
+ let r = ee(n, (t) => e.warn(t, n));
1241
1309
  if (!r) return;
1242
1310
  let i = { operator: r.operator };
1243
1311
  r.val !== void 0 && (i.val = r.val), t.empty("customFilter", i);
1244
- }, yt = (e, t, n, r, i) => {
1312
+ }, qt = (e, t, n, r, i) => {
1245
1313
  let a = {};
1246
1314
  a.colId = "" + n, i && (a.hiddenButton = "1"), r ? (t.start("filterColumn", a), ((e, t, n) => {
1247
1315
  let r = n.operator;
1248
- if (r !== A.BuiltInOperatorNames.Expression) if (r !== A.BuiltInOperatorNames.Unique) {
1249
- if (r === A.BuiltInOperatorNames.Color) {
1316
+ if (r !== R.BuiltInOperatorNames.Expression) if (r !== R.BuiltInOperatorNames.Unique) {
1317
+ if (r === R.BuiltInOperatorNames.Color) {
1250
1318
  let e = n.param, r = {};
1251
1319
  e.cellColor !== void 0 && (r.cellColor = e.cellColor ? "1" : "0"), e.styleId !== void 0 && (r.dxfId = e.styleId), t.empty("colorFilter", r);
1252
1320
  }
1253
- if (bt(r)) if (r === "between") {
1321
+ if (Jt(r)) if (r === "between") {
1254
1322
  let r = n.param;
1255
- t.start("customFilters", { and: "1" }), vt(e, t, {
1256
- operator: ht.GreaterThanEqualTo,
1323
+ t.start("customFilters", { and: "1" }), Kt(e, t, {
1324
+ operator: Ut.GreaterThanEqualTo,
1257
1325
  param: r.from
1258
- }), vt(e, t, {
1259
- operator: ht.LessThanEqualTo,
1326
+ }), Kt(e, t, {
1327
+ operator: Ut.LessThanEqualTo,
1260
1328
  param: r.to
1261
1329
  }), t.end("customFilters");
1262
- } else if (r === A.BuiltInOperatorNames.Not) {
1330
+ } else if (r === R.BuiltInOperatorNames.Not) {
1263
1331
  let r = n.param;
1264
- p(r?.operator) ? (t.start("customFilters"), vt(e, t, n), t.end("customFilters")) : e.warn("Not rule with non-comparison criteria not supported in OOXML", r);
1265
- } else if (r === A.BuiltInOperatorNames.And || r === A.BuiltInOperatorNames.Or) {
1332
+ C(r?.operator) ? (t.start("customFilters"), Kt(e, t, n), t.end("customFilters")) : e.warn("Not rule with non-comparison criteria not supported in OOXML", r);
1333
+ } else if (r === R.BuiltInOperatorNames.And || r === R.BuiltInOperatorNames.Or) {
1266
1334
  let i = n.param, a = i.length;
1267
1335
  if (a > 0) {
1268
1336
  let n = {};
1269
- r === A.BuiltInOperatorNames.And && a > 1 && (n.and = "1"), t.start("customFilters", n);
1337
+ r === R.BuiltInOperatorNames.And && a > 1 && (n.and = "1"), t.start("customFilters", n);
1270
1338
  for (let n = 0; n < a; n++) {
1271
- let r = i[n], a = r.operator === ht.Not && p(r.param?.operator);
1272
- p(r.operator) || a ? vt(e, t, r) : e.warn("Only Comparison criteria supported in Union conditions for Table AutoFilters", r);
1339
+ let r = i[n], a = r.operator === Ut.Not && C(r.param?.operator);
1340
+ C(r.operator) || a ? Kt(e, t, r) : e.warn("Only Comparison criteria supported in Union conditions for Table AutoFilters", r);
1273
1341
  }
1274
1342
  t.end("customFilters");
1275
1343
  }
1276
- } else p(r) && (t.start("customFilters"), vt(e, t, n), t.end("customFilters"));
1277
- if (r === A.BuiltInOperatorNames.TimePeriod) {
1344
+ } else C(r) && (t.start("customFilters"), Kt(e, t, n), t.end("customFilters"));
1345
+ if (r === R.BuiltInOperatorNames.TimePeriod) {
1278
1346
  let e = n.param, r = {};
1279
1347
  e.type && (r.type = e.type), e.anchorDate !== void 0 && (r.val = "" + e.anchorDate), e.maxVal !== void 0 && (r.maxVal = "" + e.maxVal), t.empty("dynamicFilter", r);
1280
1348
  }
1281
- if (r === A.BuiltInOperatorNames.Average) {
1349
+ if (r === R.BuiltInOperatorNames.Average) {
1282
1350
  let e = n.param, r = {}, i = e.type;
1283
- i && (i === A.AverageType.Above ? r.type = "aboveAverage" : i === A.AverageType.Below && (r.type = "belowAverage")), e.stdDevs !== void 0 && (r.val = "" + e.stdDevs), t.empty("dynamicFilter", r);
1351
+ i && (i === R.AverageType.Above ? r.type = "aboveAverage" : i === R.AverageType.Below && (r.type = "belowAverage")), e.stdDevs !== void 0 && (r.val = "" + e.stdDevs), t.empty("dynamicFilter", r);
1284
1352
  }
1285
- if (r === A.BuiltInOperatorNames.InSet) {
1353
+ if (r === R.BuiltInOperatorNames.InSet) {
1286
1354
  let e = n.param;
1287
1355
  if (e.dateGroups) {
1288
1356
  let n = e.dateGroups, r = n.length;
@@ -1303,153 +1371,162 @@ var pt = 164, mt = Object.freeze([
1303
1371
  t.end("filters");
1304
1372
  }
1305
1373
  }
1306
- if (r === A.BuiltInOperatorNames.Icon) {
1374
+ if (r === R.BuiltInOperatorNames.Icon) {
1307
1375
  let e = n.param, r = {};
1308
1376
  e.iconSet !== void 0 && (r.iconSet = e.iconSet), e.iconId !== void 0 && (r.iconId = "" + e.iconId), t.empty("iconFilter", r);
1309
1377
  }
1310
- if (r === A.BuiltInOperatorNames.TopN) {
1378
+ if (r === R.BuiltInOperatorNames.TopN) {
1311
1379
  let e = n.param, r = {};
1312
1380
  e.percent && (r.percent = "1"), e.top !== void 0 && (r.top = e.top ? "1" : "0"), e.limit !== void 0 && (r.val = "" + e.limit), e.filterVal !== void 0 && (r.filterVal = "" + e.filterVal), t.empty("top10", r);
1313
1381
  }
1314
1382
  } else e.warn("Unique conditions not supported in Table AutoFilters", n);
1315
1383
  else e.warn("Expression conditions not supported in Table AutoFilters", n);
1316
1384
  })(e, t, r), t.end("filterColumn")) : t.empty("filterColumn", a);
1317
- }, bt = (e) => e === A.BuiltInOperatorNames.GreaterThan || e === A.BuiltInOperatorNames.GreaterThanEqualTo || e === A.BuiltInOperatorNames.LessThan || e === A.BuiltInOperatorNames.LessThanEqualTo || e === A.BuiltInOperatorNames.EqualTo || e === A.BuiltInOperatorNames.And || e === A.BuiltInOperatorNames.Or || e === A.BuiltInOperatorNames.Not || e === "between", xt = "16.0000", St = 1048575, Ct = 16383, wt = {
1385
+ }, Jt = (e) => e === R.BuiltInOperatorNames.GreaterThan || e === R.BuiltInOperatorNames.GreaterThanEqualTo || e === R.BuiltInOperatorNames.LessThan || e === R.BuiltInOperatorNames.LessThanEqualTo || e === R.BuiltInOperatorNames.EqualTo || e === R.BuiltInOperatorNames.And || e === R.BuiltInOperatorNames.Or || e === R.BuiltInOperatorNames.Not || e === "between", Yt = {
1318
1386
  names: /* @__PURE__ */ new Set(),
1319
1387
  perFormula: [],
1320
1388
  affects: () => !1
1321
- }, Tt = 1048576, Et = (e, t, n) => {
1389
+ }, Xt = 1048576, Zt = (e, t, n) => {
1322
1390
  if (!n) return [];
1323
1391
  let r = 0;
1324
1392
  for (let i = 0; i < n.length; i++) {
1325
1393
  let a = n[i][0], o = t.getRange(a).getCoords();
1326
- if (r += (o.rowEnd - o.rowStart + 1) * (o.colEnd - o.colStart + 1), r > Tt) return e.warn(`Direct styles cover more than ${Tt} cells; not writing the styles from '${a}' on. A range that size belongs in a column or row style.`), n.slice(0, i);
1394
+ if (r += (o.rowEnd - o.rowStart + 1) * (o.colEnd - o.colStart + 1), r > Xt) return e.warn(`Direct styles cover more than ${Xt} cells; not writing the styles from '${a}' on. A range that size belongs in a column or row style.`), n.slice(0, i);
1327
1395
  }
1328
1396
  return n;
1329
1397
  };
1330
- function Dt(e, t) {
1398
+ function Qt(e, t) {
1331
1399
  let n = t.type;
1332
- n === j.ColorStopType.AutoMin ? n = j.ColorStopType.Min : n === j.ColorStopType.AutoMax && (n = j.ColorStopType.Max), e.empty("cfvo", {
1400
+ n === z.ColorStopType.AutoMin ? n = z.ColorStopType.Min : n === z.ColorStopType.AutoMax && (n = z.ColorStopType.Max), e.empty("cfvo", {
1333
1401
  type: n,
1334
1402
  val: t.value,
1335
1403
  gte: t.exclusive ? "0" : void 0
1336
1404
  });
1337
1405
  }
1338
- function Ot(e, t) {
1406
+ function $t(e, t) {
1339
1407
  let n = {
1340
1408
  type: t.type,
1341
1409
  gte: t.exclusive ? "0" : void 0
1342
1410
  };
1343
1411
  t.value === void 0 ? e.empty("x14:cfvo", n) : (e.start("x14:cfvo", n), e.start("xm:f"), e.text(t.value), e.end("xm:f"), e.end("x14:cfvo"));
1344
1412
  }
1345
- var kt = /* @__PURE__ */ new Set([
1346
- I.IconSet.Arrows3,
1347
- I.IconSet.ArrowsGray3,
1348
- I.IconSet.Flags3,
1349
- I.IconSet.Signs3,
1350
- I.IconSet.Symbols3,
1351
- I.IconSet.Symbols3_2,
1352
- I.IconSet.TrafficLights3,
1353
- I.IconSet.TrafficLights3_2,
1354
- I.IconSet.Arrows4,
1355
- I.IconSet.ArrowsGray4,
1356
- I.IconSet.Rating4,
1357
- I.IconSet.RedToBlack4,
1358
- I.IconSet.TrafficLights4,
1359
- I.IconSet.Arrows5,
1360
- I.IconSet.ArrowsGray5,
1361
- I.IconSet.Quarters5,
1362
- I.IconSet.Rating5
1413
+ var en = /* @__PURE__ */ new Set([
1414
+ V.IconSet.Arrows3,
1415
+ V.IconSet.ArrowsGray3,
1416
+ V.IconSet.Flags3,
1417
+ V.IconSet.Signs3,
1418
+ V.IconSet.Symbols3,
1419
+ V.IconSet.Symbols3_2,
1420
+ V.IconSet.TrafficLights3,
1421
+ V.IconSet.TrafficLights3_2,
1422
+ V.IconSet.Arrows4,
1423
+ V.IconSet.ArrowsGray4,
1424
+ V.IconSet.Rating4,
1425
+ V.IconSet.RedToBlack4,
1426
+ V.IconSet.TrafficLights4,
1427
+ V.IconSet.Arrows5,
1428
+ V.IconSet.ArrowsGray5,
1429
+ V.IconSet.Quarters5,
1430
+ V.IconSet.Rating5
1363
1431
  ]);
1364
- function At(e) {
1365
- return (e.icon?.length ?? 0) > 0 || e.iconSet !== void 0 && !kt.has(e.iconSet);
1432
+ function tn(e) {
1433
+ return (e.icon?.length ?? 0) > 0 || e.iconSet !== void 0 && !en.has(e.iconSet);
1366
1434
  }
1367
- function jt(e, t, n, o, s, c, l, u, d) {
1368
- let f = o.scale;
1369
- o.ext && e.warn("Conditional format extension payload is not written to xlsx; it will be lost.");
1370
- let p = {
1371
- type: s.type,
1372
- dxfId: o.style && Object.keys(o.style).length > 0 ? u.add(o.style) : void 0,
1373
- priority: l,
1374
- stopIfTrue: Z(o.stopIfTrue),
1375
- aboveAverage: Z(s.aboveAverage),
1376
- equalAverage: Z(s.equalAverage),
1377
- stdDev: s.stdDev,
1378
- bottom: Z(s.bottom),
1379
- percent: Z(s.percent),
1380
- rank: s.rank,
1381
- operator: s.operator,
1382
- text: s.text,
1383
- timePeriod: s.timePeriod
1384
- }, m;
1385
- f?.type === j.ScaleType.DataBar && function(e) {
1435
+ function nn(e, t, n, r, i, a, o, s, l) {
1436
+ let u = r.scale;
1437
+ r.ext && e.warn("Conditional format extension payload is not written to xlsx; it will be lost.");
1438
+ let d = {
1439
+ type: i.type,
1440
+ dxfId: r.style && Object.keys(r.style).length > 0 ? s.add(r.style) : void 0,
1441
+ priority: o,
1442
+ stopIfTrue: Q(r.stopIfTrue),
1443
+ aboveAverage: Q(i.aboveAverage),
1444
+ equalAverage: Q(i.equalAverage),
1445
+ stdDev: i.stdDev,
1446
+ bottom: Q(i.bottom),
1447
+ percent: Q(i.percent),
1448
+ rank: i.rank,
1449
+ operator: i.operator,
1450
+ text: i.text,
1451
+ timePeriod: i.timePeriod
1452
+ }, f;
1453
+ u?.type === z.ScaleType.DataBar && function(e) {
1386
1454
  if (e.gradient || e.borderColor || e.negativeFillColor || e.negativeBorderColor || e.axisColor || e.axisPosition || e.direction) return !0;
1387
1455
  let t = e.stops, n = t ? t.length : 0;
1388
1456
  for (let e = 0; e < n; e++) {
1389
1457
  let n = t[e].type;
1390
- if (n === j.ColorStopType.AutoMin || n === j.ColorStopType.AutoMax) return !0;
1458
+ if (n === z.ColorStopType.AutoMin || n === z.ColorStopType.AutoMax) return !0;
1391
1459
  }
1392
1460
  return !1;
1393
- }(f) && (m = a(D.uuidV4), d.push({
1394
- guid: m,
1395
- sqref: c,
1396
- priority: l,
1397
- scale: f
1461
+ }(u) && (f = x(I.uuidV4), l.push({
1462
+ guid: f,
1463
+ sqref: a,
1464
+ priority: o,
1465
+ scale: u
1398
1466
  }));
1399
- let h = s.formulas, g = h ? h.length : 0;
1400
- if (g !== 0 || f) {
1401
- t.start("cfRule", p);
1402
- for (let e = 0; e < g; e++) t.start("formula"), t.text(h[e]), t.end("formula");
1403
- if (f?.type === j.ScaleType.ColorScale) {
1404
- let e = f.stops ?? [];
1467
+ let p = i.formulas, m = p ? p.length : 0;
1468
+ if (m !== 0 || u) {
1469
+ t.start("cfRule", d);
1470
+ for (let e = 0; e < m; e++) t.start("formula"), t.text(p[e]), t.end("formula");
1471
+ if (u?.type === z.ScaleType.ColorScale) {
1472
+ let e = u.stops ?? [];
1405
1473
  t.start("colorScale");
1406
- for (let n = 0; n < e.length; n++) Dt(t, e[n]);
1407
- for (let r = 0; r < e.length; r++) G(t, n, e[r].color, "color");
1474
+ for (let n = 0; n < e.length; n++) Qt(t, e[n]);
1475
+ for (let r = 0; r < e.length; r++) q(t, n, e[r].color, "color");
1408
1476
  t.end("colorScale");
1409
- } else if (f?.type === j.ScaleType.DataBar) {
1410
- let e = f.stops ?? [];
1477
+ } else if (u?.type === z.ScaleType.DataBar) {
1478
+ let e = u.stops ?? [];
1411
1479
  t.start("dataBar", {
1412
- minLength: f.minLength,
1413
- maxLength: f.maxLength,
1414
- showValue: Z(f.showValue)
1480
+ minLength: u.minLength,
1481
+ maxLength: u.maxLength,
1482
+ showValue: Q(u.showValue)
1415
1483
  });
1416
- for (let n = 0; n < e.length; n++) Dt(t, e[n]);
1417
- f.color && G(t, n, f.color, "color"), t.end("dataBar");
1418
- } else if (f?.type === j.ScaleType.IconSet) {
1419
- let e = f.stops ?? [];
1484
+ for (let n = 0; n < e.length; n++) Qt(t, e[n]);
1485
+ u.color && q(t, n, u.color, "color"), t.end("dataBar");
1486
+ } else if (u?.type === z.ScaleType.IconSet) {
1487
+ let e = u.stops ?? [];
1420
1488
  t.start("iconSet", {
1421
- iconSet: f.iconSet,
1422
- reverse: Z(f.reverse),
1423
- showValue: Z(f.showValue)
1489
+ iconSet: u.iconSet,
1490
+ reverse: Q(u.reverse),
1491
+ showValue: Q(u.showValue)
1424
1492
  });
1425
- for (let n = 0; n < e.length; n++) Dt(t, e[n]);
1493
+ for (let n = 0; n < e.length; n++) Qt(t, e[n]);
1426
1494
  t.end("iconSet");
1427
1495
  }
1428
- m && (t.start("extLst"), t.start("ext", {
1429
- uri: i,
1430
- "xmlns:x14": r
1431
- }), t.start("x14:id"), t.text(m), t.end("x14:id"), t.end("ext"), t.end("extLst")), t.end("cfRule");
1432
- } else t.empty("cfRule", p);
1496
+ f && (t.start("extLst"), t.start("ext", {
1497
+ uri: c,
1498
+ "xmlns:x14": T
1499
+ }), t.start("x14:id"), t.text(f), t.end("x14:id"), t.end("ext"), t.end("extLst")), t.end("cfRule");
1500
+ } else t.empty("cfRule", d);
1433
1501
  }
1434
- function Mt(e) {
1435
- return e.split(" ")[0].split(":")[0];
1502
+ function rn(e) {
1503
+ let t = 2 ** 53 - 1, n = 2 ** 53 - 1, r = e.split(" ");
1504
+ for (let e = 0; e < r.length; e++) {
1505
+ if (!r[e]) continue;
1506
+ let i = P.fastStringToRange(r[e]);
1507
+ i.rowStart < t && (t = i.rowStart), i.colStart < n && (n = i.colStart);
1508
+ }
1509
+ return P.cellToString({
1510
+ rowIndex: t,
1511
+ colIndex: n
1512
+ });
1436
1513
  }
1437
- function Nt(e) {
1514
+ function an(e) {
1438
1515
  if (typeof e == "string") return e.split(",").join(" ");
1439
1516
  if (Array.isArray(e)) {
1440
1517
  let t = [];
1441
1518
  for (let n = 0; n < e.length; n++) {
1442
- let r = T.rangeToString(e[n]);
1519
+ let r = P.rangeToString(e[n]);
1443
1520
  r && t.push(r);
1444
1521
  }
1445
1522
  return t.length > 0 ? t.join(" ") : null;
1446
1523
  }
1447
- return T.rangeToString(e);
1524
+ return P.rangeToString(e);
1448
1525
  }
1449
- function Z(e) {
1526
+ function Q(e) {
1450
1527
  if (e !== void 0) return e ? "1" : "0";
1451
1528
  }
1452
- function Pt(e) {
1529
+ function on(e) {
1453
1530
  if (typeof e != "string") return !1;
1454
1531
  let t = !1;
1455
1532
  for (let n = 0; n < e.length; n++) {
@@ -1459,18 +1536,112 @@ function Pt(e) {
1459
1536
  }
1460
1537
  return !1;
1461
1538
  }
1462
- function Ft(e) {
1539
+ function sn(e) {
1463
1540
  let t = e.formulas, n = t ? t.length : 0;
1464
- for (let e = 0; e < n; e++) if (Pt(t[e])) return !0;
1541
+ for (let e = 0; e < n; e++) if (on(t[e])) return !0;
1465
1542
  return !1;
1466
1543
  }
1467
- var It = {
1544
+ function cn(e) {
1545
+ let t = 2 ** 53 - 1, n = 2 ** 53 - 1, r = e.split(" ");
1546
+ for (let e = 0; e < r.length; e++) {
1547
+ if (!r[e]) continue;
1548
+ let i = P.fastStringToRange(r[e]);
1549
+ i.rowStart < t && (t = i.rowStart), i.colStart < n && (n = i.colStart);
1550
+ }
1551
+ return t === 2 ** 53 - 1 ? null : {
1552
+ rowIndex: t,
1553
+ colIndex: n
1554
+ };
1555
+ }
1556
+ function ln(e, t, n) {
1557
+ if (typeof e != "string" || !e || !t || !n) return e;
1558
+ try {
1559
+ let r = n.parse(e, t);
1560
+ return r && ce.image(n.spell(r, !0), { at: t }) || e;
1561
+ } catch {
1562
+ return e;
1563
+ }
1564
+ }
1565
+ function un(e, t, n) {
1566
+ let r = e?.stops;
1567
+ if (!r || !n) return e;
1568
+ let i;
1569
+ for (let e = 0; e < r.length; e++) {
1570
+ let a = r[e]?.value;
1571
+ if (typeof a != "string") continue;
1572
+ let o = ln(a, t, n);
1573
+ o !== a && (i ||= [...r], i[e] = {
1574
+ ...r[e],
1575
+ value: o
1576
+ });
1577
+ }
1578
+ return i ? {
1579
+ ...e,
1580
+ stops: i
1581
+ } : e;
1582
+ }
1583
+ function dn(e, t, n, r) {
1584
+ if (!r?.xml) return;
1585
+ let i = e.addPart("legacyDrawing", r);
1586
+ t.empty(n, { "r:id": i.relId });
1587
+ }
1588
+ var fn = (e, t) => {
1589
+ if (!t) return e;
1590
+ let n = e?.xml ?? null, r = _(n ?? ""), i = [], a = t.comments;
1591
+ for (let e = 0; e < a.length; e++) {
1592
+ let { comment: t, row: n, col: o } = a[e], s = t.toJSON()?.box, c = s?.xml ? te(s.xml).notes[0] : void 0;
1593
+ if (c) {
1594
+ let e = A(c.xml);
1595
+ e !== null && (r = Math.max(r, e)), i.push(O(c, n, o));
1596
+ } else i.push(b(n, o, ++r));
1597
+ }
1598
+ let o = w(n, i);
1599
+ return o ? o === n ? e : e ? {
1600
+ ...e,
1601
+ xml: o
1602
+ } : { xml: o } : e;
1603
+ }, pn = (e) => e.content?.type !== "control", mn = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp", hn = (e, t) => {
1604
+ if (!e?.xml) return e;
1605
+ let n = t.movables;
1606
+ if (!n) return e;
1607
+ let r = /* @__PURE__ */ new Map(), i = n.length;
1608
+ for (let e = 0; e < i; e++) {
1609
+ let t = n[e];
1610
+ if (pn(t)) continue;
1611
+ let i = t.content?.json?.shapeId;
1612
+ typeof i == "number" && r.set(i, t);
1613
+ }
1614
+ if (r.size === 0) return e;
1615
+ let a = e.xml.replace(/<v:shape\b[\s\S]*?<\/v:shape>/g, (e) => {
1616
+ let t = /\bo:spid="_x0000_s(\d+)"/.exec(e) ?? /\bid="_x0000_s(\d+)"/.exec(e), n = t ? r.get(parseInt(t[1], 10)) : void 0;
1617
+ if (!n) return e;
1618
+ let i = n.anchor, a = [
1619
+ i.tl.c,
1620
+ i.tl.r,
1621
+ i.br.c,
1622
+ i.br.r
1623
+ ];
1624
+ return e.replace(/(<x:Anchor>)([\s\d,-]*)(<\/x:Anchor>)/, (e, t, n, r) => {
1625
+ let i = n.split(",").map((e) => e.trim());
1626
+ if (i.length !== 8) return e;
1627
+ let o = i.slice();
1628
+ for (let e = 0; e < 4; e++) o[2 * e] = String(a[e] ?? 0);
1629
+ return o.join(",") === i.join(",") ? e : `${t}${o.join(", ")}${r}`;
1630
+ });
1631
+ });
1632
+ return a === e.xml ? e : {
1633
+ ...e,
1634
+ xml: a
1635
+ };
1636
+ }, gn = (e, t, n) => {
1637
+ e.start(t), e.start("xdr:col"), e.text(n.c ?? 0), e.end("xdr:col"), e.start("xdr:colOff"), e.text(X(n.x)), e.end("xdr:colOff"), e.start("xdr:row"), e.text(n.r ?? 0), e.end("xdr:row"), e.start("xdr:rowOff"), e.text(X(n.y)), e.end("xdr:rowOff"), e.end(t);
1638
+ }, _n = {
1468
1639
  r: void 0,
1469
1640
  s: void 0,
1470
1641
  t: void 0,
1471
1642
  cm: void 0,
1472
1643
  vm: void 0
1473
- }, Lt = {
1644
+ }, vn = {
1474
1645
  r: void 0,
1475
1646
  s: void 0,
1476
1647
  customFormat: void 0,
@@ -1480,29 +1651,29 @@ var It = {
1480
1651
  "x14ac:dyDescent": "0.25",
1481
1652
  outlineLevel: void 0,
1482
1653
  collapsed: void 0
1483
- }, Rt = {
1654
+ }, yn = {
1484
1655
  t: void 0,
1485
1656
  aca: void 0,
1486
1657
  ref: void 0,
1487
1658
  ca: void 0,
1488
1659
  si: void 0
1489
- }, zt = {
1660
+ }, bn = {
1490
1661
  t: "shared",
1491
1662
  aca: void 0,
1492
1663
  ref: void 0,
1493
1664
  ca: void 0,
1494
1665
  si: void 0
1495
- }, Bt = {
1666
+ }, xn = {
1496
1667
  t: "array",
1497
1668
  aca: void 0,
1498
1669
  ref: void 0,
1499
1670
  ca: void 0,
1500
1671
  si: void 0
1501
1672
  };
1502
- function Vt(e, t, n, r) {
1673
+ function Sn(e, t, n, r) {
1503
1674
  n && (t.start(r), t.empty("latin", { typeface: n }), t.empty("ea", { typeface: "" }), t.empty("cs", { typeface: "" }), t.end(r));
1504
1675
  }
1505
- var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1676
+ var Cn = (e) => e.toISOString().split(".")[0] + "Z", wn = (e, t, n) => {
1506
1677
  switch (t) {
1507
1678
  case "creator":
1508
1679
  e.start("dc:creator"), e.text(n), e.end("dc:creator");
@@ -1515,10 +1686,10 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1515
1686
  break;
1516
1687
  case "modified": e.start("dcterms:modified", { "xsi:type": "dcterms:W3CDTF" }), e.text(n), e.end("dcterms:modified");
1517
1688
  }
1518
- }, Q = (e, t, n, r) => {
1689
+ }, $ = (e, t, n, r) => {
1519
1690
  t.start(n), t.text(r), t.end(n);
1520
- }, Wt = (e, t, n) => {
1521
- let r = n.getSheets().getItems({ visibility: P.Visibility.Hidden }).map((e) => e.getName()), i = n.getNames().getItems({ type: "formula" }).filter((e) => !!e.getRanges?.()).map((e) => e.getName());
1691
+ }, Tn = (e, t, n) => {
1692
+ let r = n.getSheets().getItems({ visibility: ue.Visibility.Hidden }).map((e) => e.getName()), i = n.getNames().getItems({ type: "formula" }).filter((e) => !!e.getRanges?.()).map((e) => e.getName());
1522
1693
  t.start("HeadingPairs"), t.start("vt:vector", {
1523
1694
  size: i.length > 0 ? "4" : "2",
1524
1695
  baseType: "variant"
@@ -1529,7 +1700,7 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1529
1700
  for (let e of r) t.start("vt:lpstr"), t.text(e), t.end("vt:lpstr");
1530
1701
  for (let e of i) t.start("vt:lpstr"), t.text(e), t.end("vt:lpstr");
1531
1702
  t.end("vt:vector"), t.end("TitlesOfParts");
1532
- }, Gt = {
1703
+ }, En = {
1533
1704
  minSupportedVersion: "120000",
1534
1705
  copy: "1",
1535
1706
  pasteAll: "1",
@@ -1541,17 +1712,17 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1541
1712
  clearComments: "1",
1542
1713
  assign: "1",
1543
1714
  coerce: "1"
1544
- }, Kt = (e, t, n = D.EmptyArray) => {
1715
+ }, Dn = (e, t, n = I.EmptyArray) => {
1545
1716
  if (!t) return { ...n };
1546
1717
  let { text: r, runs: i, color: a, size: o, kern: s, weight: c, style: l, b: u, i: d, spc: f, baseline: p, ...m } = t, h = {
1547
1718
  ...n,
1548
1719
  ...m
1549
1720
  };
1550
- return o !== void 0 && (h.sz = "" + nt(o)), u !== void 0 && (h.b = u ? "1" : "0"), c !== void 0 && (h.b = c > 500 ? "1" : "0"), d !== void 0 && (h.i = d ? "1" : "0"), l !== void 0 && (h.i = l === "italic" ? "1" : "0"), s !== void 0 && (h.kern = "" + nt(s)), f !== void 0 && (h.spc = "" + nt(f)), p !== void 0 && (h.baseline = "" + nt(p)), h;
1551
- }, qt = (e, t, n) => {
1721
+ return o !== void 0 && (h.sz = "" + kt(o)), u !== void 0 && (h.b = u ? "1" : "0"), c !== void 0 && (h.b = c > 500 ? "1" : "0"), d !== void 0 && (h.i = d ? "1" : "0"), l !== void 0 && (h.i = l === "italic" ? "1" : "0"), s !== void 0 && (h.kern = "" + kt(s)), f !== void 0 && (h.spc = "" + kt(f)), p !== void 0 && (h.baseline = "" + kt(p)), h;
1722
+ }, On = (e, t, n) => {
1552
1723
  if (!n) return;
1553
1724
  let r = e.getXMLWriter();
1554
- r.start("txBody"), r.pushDefaultNamespace("a"), Yt(e, t, {
1725
+ r.start("txBody"), r.pushDefaultNamespace("a"), An(e, t, {
1555
1726
  vertOverflow: "clip",
1556
1727
  horzOverflow: "clip",
1557
1728
  rtlCol: "0",
@@ -1560,28 +1731,28 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1560
1731
  if (!n) return;
1561
1732
  let r = e.getXMLWriter();
1562
1733
  r.pushDefaultNamespace("a"), typeof n == "string" && (n = { runs: [{ text: n }] }), r.start("p"), r.empty("pPr", { algn: "ctr" });
1563
- let i = Kt(0, n, {
1564
- ...Xt,
1734
+ let i = Dn(0, n, {
1735
+ ...jn,
1565
1736
  size: t.getDefaultFontSize()
1566
1737
  }), a = n?.runs, o = a ? a.length : 0;
1567
1738
  if (o > 0) for (let e = 0; e < o; e++) {
1568
1739
  let n = a[e];
1569
1740
  r.start("r", {});
1570
- let i = Kt(0, n, Xt), o = n.color;
1571
- o ? (r.start("rPr", i), K(0, r, o, t), r.end("rPr")) : r.empty("rPr", i), r.start("t"), r.text(n?.text ?? ""), r.end("t"), r.end("r");
1741
+ let i = Dn(0, n, jn), o = n.color;
1742
+ o ? (r.start("rPr", i), J(0, r, o, t), r.end("rPr")) : r.empty("rPr", i), r.start("t"), r.text(n?.text ?? ""), r.end("t"), r.end("r");
1572
1743
  }
1573
1744
  else r.empty("endParaRPr", i);
1574
1745
  r.end("p"), r.popDefaultNamespace();
1575
1746
  })(e, t, n), r.popDefaultNamespace(), r.end("txBody");
1576
- }, Jt = (e, t, n) => {
1747
+ }, kn = (e, t, n) => {
1577
1748
  if (!n) return;
1578
- let r = e.getXMLWriter(), i = Kt(0, n);
1749
+ let r = e.getXMLWriter(), i = Dn(0, n);
1579
1750
  r.empty("defRPr", i);
1580
- }, Yt = (e, t, n) => {
1751
+ }, An = (e, t, n) => {
1581
1752
  if (!n) return;
1582
1753
  let r = e.getXMLWriter(), { spAutoFit: i, ...a } = n;
1583
1754
  i ? (r.start("bodyPr", a), r.empty("spAutoFit"), r.end("bodyPr")) : r.empty("bodyPr", a);
1584
- }, Xt = Object.freeze({ lang: "en-US" }), Zt = (e, t) => {
1755
+ }, jn = Object.freeze({ lang: "en-US" }), Mn = (e, t) => {
1585
1756
  if (t.length !== 0) {
1586
1757
  e.start("a:extLst");
1587
1758
  for (let n of t) {
@@ -1590,22 +1761,22 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1590
1761
  }
1591
1762
  e.end("a:extLst");
1592
1763
  }
1593
- }, Qt = async (e, t, n, r, i) => {
1764
+ }, Nn = async (e, t, n, r, i) => {
1594
1765
  let a = e.getSharedStates(), o = r.getContent().getResource(), s = await o.getExternalURI(), c;
1595
- if (s) c = e.addExternal(et, s);
1766
+ if (s) c = e.addExternal(Et, s);
1596
1767
  else if (c = n.get(o), !c) {
1597
- let t = a.get("imagesWritten");
1598
- t || (t = /* @__PURE__ */ new Map(), a.set("imagesWritten", t));
1768
+ let t = a.get(Dt);
1769
+ t || (t = /* @__PURE__ */ new Map(), a.set(Dt, t));
1599
1770
  let r = t.get(o);
1600
1771
  if (!r) {
1601
1772
  let e = await o.toBuffer();
1602
1773
  r = {
1603
1774
  bytes: new Uint8Array(e),
1604
- type: await o.getType() ?? tt,
1775
+ type: await o.getType() ?? Ot,
1605
1776
  index: t.size + 1
1606
1777
  }, t.set(o, r);
1607
1778
  }
1608
- c = e.addBinary(r.bytes, r.type.mime, et, `../media/image${r.index}.${r.type.ext}`, !0), n.set(o, c);
1779
+ c = e.addBinary(r.bytes, r.type.mime, Et, `../media/image${r.index}.${r.type.ext}`, !0), n.set(o, c);
1609
1780
  }
1610
1781
  let l = { "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" };
1611
1782
  s ? l["r:link"] = c.relId : l["r:embed"] = c.relId;
@@ -1619,30 +1790,26 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1619
1790
  }
1620
1791
  ]);
1621
1792
  let d = e.getXMLWriter();
1622
- d.start("pic"), d.start("nvPicPr"), cn(e, d, r, i, t), un(e, d, r, i), d.end("nvPicPr"), d.start("blipFill"), d.start("a:blip", l), Zt(d, u), d.end("a:blip"), d.start("a:stretch"), d.empty("a:fillRect"), d.end("a:stretch"), d.end("blipFill"), on(e, t, n, r, i), d.end("pic");
1623
- }, $t = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", en = async (e, t, n, r, i, a) => {
1624
- let o = i.content?.json, s = o?.xml, c = o?.chartRelId, l = o?.chartTargetPath;
1625
- if (!s || !c || !l) return $(e, t, n, r, i);
1626
- let u = e.getSharedStates(), d, f = u.get("claimedChartTargets");
1627
- if (f || (f = /* @__PURE__ */ new Set(), u.set("claimedChartTargets", f)), f.has(l)) {
1628
- let a = e.forkPreservedPart(l, "application/vnd.openxmlformats-officedocument.drawingml.chart+xml", $t, "../charts/chart{n}.xml");
1629
- if (!a?.relId) return $(e, t, n, r, i);
1630
- d = a.relId;
1631
- } else f.add(l), d = e.addPreservedRelationship($t, l, c);
1632
- let p = d === c ? s : s.replace(`r:id="${c}"`, `r:id="${d}"`);
1633
- a !== void 0 && typeof o?.sourceId == "number" && (p = p.replace(`cNvPr id="${o.sourceId}"`, `cNvPr id="${a}"`)), e.getXMLWriter().raw(p);
1634
- }, tn = async (e, t, n, r, i) => $(e, t, n, r, i), nn = async (e, t, n, r, i) => $(e, t, n, r, i), rn = async (e, t, n, r, i) => $(e, t, n, r, i), an = async (e, t, n, r, i, a) => {
1793
+ d.start("pic"), d.start("nvPicPr"), Hn(e, d, r, i, t), Wn(e, d, r, i), d.end("nvPicPr"), d.start("blipFill"), d.start("a:blip", l), Mn(d, u), d.end("a:blip"), d.start("a:stretch"), d.empty("a:fillRect"), d.end("a:stretch"), d.end("blipFill"), Bn(e, t, n, r, i), d.end("pic");
1794
+ }, Pn = async (e, t, n, r, i, a) => {
1795
+ let o = i.content?.json, s = o?.xml, c = o?.part;
1796
+ if (!s || !c) return zn(e, t, n, r, i);
1797
+ let l = await Ze(c, e, "../charts/chart{n}.xml");
1798
+ if (!l?.relId) return zn(e, t, n, r, i);
1799
+ let u = l.relId === c.id ? s : s.replace(`r:id="${c.id}"`, `r:id="${l.relId}"`);
1800
+ a !== void 0 && typeof i.content?.json?.sourceId == "number" && (u = u.replace(`cNvPr id="${i.content.json.sourceId}"`, `cNvPr id="${a}"`)), e.getXMLWriter().raw(u);
1801
+ }, Fn = async (e, t, n, r, i) => zn(e, t, n, r, i), In = async (e, t, n, r, i) => zn(e, t, n, r, i), Ln = async (e, t, n, r, i) => zn(e, t, n, r, i), Rn = async (e, t, n, r, i, a) => {
1635
1802
  let o = i.content?.json, s = o?.xml;
1636
- if (!s) return $(e, t, n, r, i);
1803
+ if (!s) return zn(e, t, n, r, i);
1637
1804
  let c = a !== void 0 && typeof o?.sourceId == "number" ? s.replace(`cNvPr id="${o.sourceId}"`, `cNvPr id="${a}"`) : s;
1638
1805
  e.getXMLWriter().raw(c);
1639
- }, $ = async (e, t, n, r, i) => {
1806
+ }, zn = async (e, t, n, r, i) => {
1640
1807
  (async (e, t, n, r, i) => {
1641
1808
  let a = e.getXMLWriter(), o = {}, s = i.content?.json, c = s?.type ?? "sp", l = t.getStyles();
1642
- c === "cxnSp" ? (o.macro = "", a.start("cxnSp", o), a.start("nvCxnSpPr"), cn(e, a, r, i, t), ln(e, a, r, i, t), a.start("cNvCxnSpPr"), a.empty("a:stCnx", {
1809
+ c === "cxnSp" ? (o.macro = "", a.start("cxnSp", o), a.start("nvCxnSpPr"), Hn(e, a, r, i, t), Un(e, a, r, i, t), a.start("cNvCxnSpPr"), a.empty("a:stCnx", {
1643
1810
  id: "0",
1644
1811
  idx: "0"
1645
- }), a.end("cNvCxnSpPr"), a.end("nvCxnSpPr"), on(e, t, n, r, i), sn(e, t, n, r, i), qt(e, l, s?.text), a.end("cxnSp")) : c === "grpSp" || (o.macro = "", o.textlink = "", a.start("sp", o), a.start("nvSpPr"), cn(e, a, r, i, t), ln(e, a, r, i, t), a.end("nvSpPr"), on(e, t, n, r, i), sn(e, t, n, r, i), qt(e, l, s?.text), a.end("sp"));
1812
+ }), a.end("cNvCxnSpPr"), a.end("nvCxnSpPr"), Bn(e, t, n, r, i), Vn(e, t, n, r, i), On(e, l, s?.text), a.end("cxnSp")) : c === "grpSp" || (o.macro = "", o.textlink = "", a.start("sp", o), a.start("nvSpPr"), Hn(e, a, r, i, t), Un(e, a, r, i, t), a.end("nvSpPr"), Bn(e, t, n, r, i), Vn(e, t, n, r, i), On(e, l, s?.text), a.end("sp"));
1646
1813
  })(e, t, n, r, {
1647
1814
  ...i,
1648
1815
  content: {
@@ -1660,13 +1827,13 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1660
1827
  }
1661
1828
  }
1662
1829
  });
1663
- }, on = (e, t, n, r, i) => {
1830
+ }, Bn = (e, t, n, r, i) => {
1664
1831
  let a = e.getXMLWriter(), o = i.content?.json, s = o?.geometry ?? "rect", c = t.getStyles();
1665
- a.start("spPr"), a.pushDefaultNamespace("a"), dn(a, r, i), a.start("prstGeom", { prst: s }), a.empty("avLst"), a.end("prstGeom"), Xe(e, c, o), a.popDefaultNamespace(), a.end("spPr");
1666
- }, sn = (e, t, n, r, i) => {
1832
+ a.start("spPr"), a.pushDefaultNamespace("a"), Gn(a, r, i), a.start("prstGeom", { prst: s }), a.empty("avLst"), a.end("prstGeom"), St(e, c, o), a.popDefaultNamespace(), a.end("spPr");
1833
+ }, Vn = (e, t, n, r, i) => {
1667
1834
  let a = e.getXMLWriter();
1668
1835
  a.start("style"), a.pushDefaultNamespace("a"), a.start("lnRef", { idx: "1" }), a.start("schemeClr", { val: "accent1" }), a.empty("shade", { val: "15000" }), a.end("schemeClr"), a.end("lnRef"), a.start("fillRef", { idx: "1" }), a.empty("schemeClr", { val: "accent1" }), a.end("fillRef"), a.start("effectRef", { idx: "0" }), a.empty("schemeClr", { val: "accent1" }), a.end("effectRef"), a.start("fontRef", { idx: "minor" }), a.empty("schemeClr", { val: "lt1" }), a.end("fontRef"), a.popDefaultNamespace(), a.end("style");
1669
- }, cn = (e, t, n, r, i) => {
1836
+ }, Hn = (e, t, n, r, i) => {
1670
1837
  let a = e.getSharedStates(), o = a.get("uniqueIdCounter");
1671
1838
  o || (o = /* @__PURE__ */ new Map(), a.set("uniqueIdCounter", o));
1672
1839
  let s = o.get(i) ?? 1;
@@ -1682,41 +1849,90 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1682
1849
  "a16:creationId",
1683
1850
  {
1684
1851
  "xmlns:a16": "http://schemas.microsoft.com/office/drawing/2014/main",
1685
- id: `{${D.uuidV4().toUpperCase()}}`
1852
+ id: `{${I.uuidV4().toUpperCase()}}`
1686
1853
  }
1687
- ]), t.start("cNvPr", c), Zt(t, l), t.end("cNvPr");
1688
- }, ln = (e, t, n, r, i) => {
1854
+ ]), t.start("cNvPr", c), Mn(t, l), t.end("cNvPr");
1855
+ }, Un = (e, t, n, r, i) => {
1689
1856
  t.empty("cNvSpPr");
1690
- }, un = (e, t, n, r) => {
1857
+ }, Wn = (e, t, n, r) => {
1691
1858
  let i = {};
1692
1859
  if (r.lockAspect && (i.noChangeAspect = "1"), r.locks) for (let e of Object.keys(r.locks)) !0 === r.locks[e] && (i[e] = "1");
1693
1860
  t.start("cNvPicPr", {}), t.empty("a:picLocks", i), t.end("cNvPicPr");
1694
- }, dn = (e, t, n) => {
1861
+ }, Gn = (e, t, n) => {
1695
1862
  let r = t.getBounds(), i = {}, a = n.rotation;
1696
- a !== void 0 && a !== 0 && (i.rot = "" + Y(a)), e.start("xfrm", i), e.start("off", {
1697
- x: J(r.x),
1698
- y: J(r.y)
1863
+ a !== void 0 && a !== 0 && (i.rot = "" + Z(a)), e.start("xfrm", i), e.start("off", {
1864
+ x: X(r.x),
1865
+ y: X(r.y)
1699
1866
  }), e.end("off"), e.start("ext", {
1700
- cx: J(r.width),
1701
- cy: J(r.height)
1867
+ cx: X(r.width),
1868
+ cy: X(r.height)
1702
1869
  }), e.end("ext"), e.end("xfrm");
1703
- }, fn = (e, t, n) => {
1704
- e.start(t), e.start("col"), e.text(n.c ?? 0), e.end("col"), e.start("colOff"), e.text(J(n.x)), e.end("colOff"), e.start("row"), e.text(n.r ?? 0), e.end("row"), e.start("rowOff"), e.text(J(n.y)), e.end("rowOff"), e.end(t);
1705
- }, pn = 0, mn = (e, t, n, r) => {
1870
+ }, Kn = (e, t, n) => {
1871
+ e.start(t), e.start("col"), e.text(n.c ?? 0), e.end("col"), e.start("colOff"), e.text(X(n.x)), e.end("colOff"), e.start("row"), e.text(n.r ?? 0), e.end("row"), e.start("rowOff"), e.text(X(n.y)), e.end("rowOff"), e.end(t);
1872
+ }, qn = async (e, t, n) => {
1873
+ let r = await n.getExternalURI();
1874
+ if (r) return void e.addExternal(Et, r);
1875
+ let i = e.getSharedStates(), a = i.get(Dt);
1876
+ a || (a = /* @__PURE__ */ new Map(), i.set(Dt, a));
1877
+ let o = a.get(n);
1878
+ if (!o) {
1879
+ let e = await n.toBuffer();
1880
+ o = {
1881
+ bytes: new Uint8Array(e),
1882
+ type: await n.getType() ?? Ot,
1883
+ index: a.size + 1
1884
+ }, a.set(n, o);
1885
+ }
1886
+ let s = e.addBinary(o.bytes, o.type.mime, Et, `../media/image${o.index}.${o.type.ext}`, !0, t);
1887
+ s.relId !== t && e.log(`Legacy drawing image '${t}' was written as '${s.relId}'; the markup will not find it.`);
1888
+ };
1889
+ function Jn(e, t, r, i, a, o, s, c) {
1890
+ let l = {
1891
+ ref: t,
1892
+ dT: (a ?? /* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "Z"),
1893
+ personId: i ? Yn(i) : void 0,
1894
+ id: Yn(r),
1895
+ parentId: s ? Yn(s) : void 0,
1896
+ done: c ? "1" : void 0
1897
+ };
1898
+ e.start("threadedComment", l), e.start("text", ie.test(o) || /[\n\r]/.test(o) ? n : void 0), e.text(o), e.end("text"), e.end("threadedComment");
1899
+ }
1900
+ function Yn(e) {
1901
+ return `{${e.replace(/^\{|\}$/g, "").toUpperCase()}}`;
1902
+ }
1903
+ var Xn = 0, Zn = (e, t, n, r) => {
1706
1904
  let i = r.columns, a = i ? i.length : 0;
1707
1905
  if (a !== 0) {
1708
1906
  t.start("tableColumns", { count: a });
1709
- for (let e = 0; e < a; e++) {
1710
- let n = i[e];
1711
- typeof n == "string" && (n = { name: n });
1712
- let r = {};
1713
- r.id = e + 1, r.name = n.name ?? `Column${e + 1}`;
1714
- let a = null, o = n.totalsRowFormula;
1715
- o && (typeof o == "number" && (o = _n.get(o)), o && !gn.has(o.toLowerCase()) && (a = o, o = "custom"), o && (r.totalsRowFunction = o)), n.totalsRowLabel && (r.totalsRowLabel = n.totalsRowLabel), a ? (t.start("tableColumn", r), t.start("totalsRowFormula"), t.text(a), t.end("totalsRowFormula"), t.end("tableColumn")) : t.empty("tableColumn", r);
1907
+ for (let o = 0; o < a; o++) {
1908
+ let a = i[o];
1909
+ typeof a == "string" && (a = { name: a });
1910
+ let s = {};
1911
+ s.id = o + 1, s.name = a.name ?? `Column${o + 1}`;
1912
+ let c = null, l = a.totalsRowFormula;
1913
+ if (typeof l == "number") {
1914
+ let e = er.get(l);
1915
+ e ? s.totalsRowFunction = e : c = `SUBTOTAL(${l},${r.name?.trim()}[${s.name}])`;
1916
+ } else l && (c = Qn(e, n, o, l.startsWith("=") ? l.substring(1) : l));
1917
+ c && (s.totalsRowFunction = "custom"), a.totalsRowLabel && (s.totalsRowLabel = a.totalsRowLabel);
1918
+ let u = a.calculatedColumnFormula ? Qn(e, n, o, a.calculatedColumnFormula) : null;
1919
+ (c || u) && (t.start("tableColumn", s), u && (t.start("calculatedColumnFormula"), t.text(u), t.end("calculatedColumnFormula"))), c && (t.start("totalsRowFormula"), t.text(c), t.end("totalsRowFormula")), c || u ? t.end("tableColumn") : t.empty("tableColumn", s);
1716
1920
  }
1717
1921
  t.end("tableColumns");
1718
1922
  }
1719
- }, hn = (e, t, n, r) => {
1923
+ }, Qn = (e, t, n, r) => {
1924
+ let i = e.getSharedStates().get(o);
1925
+ if (!i) return r;
1926
+ try {
1927
+ let e = t.getDataRange().getCoords(), a = {
1928
+ rowIndex: e.rowStart,
1929
+ colIndex: e.colStart + n
1930
+ }, o = i.parse(r, a);
1931
+ return o && ce.image(i.spell(o, !1, t.getName()), { at: a }) || r;
1932
+ } catch {
1933
+ return r;
1934
+ }
1935
+ }, $n = (e, t, n, r) => {
1720
1936
  let i = {
1721
1937
  name: n.getStyle().getName(),
1722
1938
  showFirstColumn: n.isShowHighlightFirstColumn() ? "1" : "0",
@@ -1725,33 +1941,56 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1725
1941
  showColumnStripes: n.isShowBandedColumns() ? "1" : "0"
1726
1942
  };
1727
1943
  t.empty("tableStyleInfo", i);
1728
- }, gn = /* @__PURE__ */ new Map([
1729
- ["average", 101],
1730
- ["countnums", 102],
1731
- ["count", 103],
1732
- ["max", 104],
1733
- ["min", 105],
1734
- ["product", 106],
1735
- ["stddev", 107],
1736
- ["stddevp", 108],
1737
- ["sum", 109],
1738
- ["var", 110]
1739
- ]), _n = /* @__PURE__ */ new Map();
1740
- gn.forEach((e, t) => {
1741
- _n.set(e, t);
1742
- });
1743
- var vn = (e, t, n, r) => {
1944
+ }, er = /* @__PURE__ */ new Map([
1945
+ [101, "average"],
1946
+ [102, "countNums"],
1947
+ [103, "count"],
1948
+ [104, "max"],
1949
+ [105, "min"],
1950
+ [107, "stdDev"],
1951
+ [109, "sum"],
1952
+ [110, "var"]
1953
+ ]), tr = {
1954
+ rowIndex: 0,
1955
+ colIndex: 0
1956
+ };
1957
+ function nr(e, t, n, r) {
1958
+ if (r == null) return;
1959
+ tr.rowIndex = t, tr.colIndex = n;
1960
+ let i = P.cellToString(tr), a, o;
1961
+ switch (typeof r) {
1962
+ case "number":
1963
+ o = "" + r;
1964
+ break;
1965
+ case "boolean":
1966
+ a = "b", o = r ? "1" : "0";
1967
+ break;
1968
+ case "string":
1969
+ a = "str", o = r;
1970
+ break;
1971
+ default: {
1972
+ let e = r;
1973
+ if (e.t !== "e") return;
1974
+ a = "e", o = se.getBuiltInByCode(e.v)?.getLabel() ?? se.BuiltIn.Value.getLabel();
1975
+ }
1976
+ }
1977
+ e.start("cell", a ? {
1978
+ r: i,
1979
+ t: a
1980
+ } : { r: i }), e.start("v"), e.text(o), e.end("v"), e.end("cell");
1981
+ }
1982
+ var rr = (e, t, n, r) => {
1744
1983
  t.start("mc:AlternateContent", { "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006" }), t.start("mc:Choice", {
1745
1984
  Requires: "c14",
1746
1985
  "xmlns:c14": "http://schemas.microsoft.com/office/drawing/2007/8/2/chart"
1747
1986
  }), t.empty("c14:style", { val: "102" }), t.end("mc:Choice"), t.start("mc:Fallback"), t.empty("c:style", { val: "2" }), t.end("mc:Fallback"), t.end("mc:AlternateContent");
1748
- }, yn = (e, t, n, r, i) => {
1987
+ }, ir = (e, t, n, r, i) => {
1749
1988
  t.start("chart"), ((e, t, n, r, i) => {
1750
- t.start("title"), t.empty("overlay", { val: "0" }), Xe(e, n, i, "spPr", !0), t.end("title"), t.empty("autoTitleDeleted", { val: "0" });
1989
+ t.start("title"), t.empty("overlay", { val: "0" }), St(e, n, i, "spPr", !0), t.end("title"), t.empty("autoTitleDeleted", { val: "0" });
1751
1990
  })(e, t, n, 0, i), ((e, t, n, r, i) => {
1752
- t.start("plotArea"), t.empty("layout"), Xe(e, n, i, "spPr", !0), t.end("plotArea");
1991
+ t.start("plotArea"), t.empty("layout"), St(e, n, i, "spPr", !0), t.end("plotArea");
1753
1992
  })(e, t, n, 0, i), t.empty("plotVisOnly", { val: "1" }), t.empty("dispBlanksAs", { val: "gap" }), t.empty("showDLblsOverMax", { val: "0" }), t.end("chart");
1754
- }, bn = (e, t, n, r) => {
1993
+ }, ar = (e, t, n, r) => {
1755
1994
  t.start("printSettings"), t.empty("headerFooter"), t.empty("pageMargins", {
1756
1995
  b: "0.75",
1757
1996
  l: "0.7",
@@ -1760,16 +1999,16 @@ var vn = (e, t, n, r) => {
1760
1999
  header: "0.3",
1761
2000
  footer: "0.3"
1762
2001
  }), t.empty("pageSetup"), t.end("printSettings");
1763
- }, xn = (e, t, n, r, i, a = "0") => {
2002
+ }, or = (e, t, n, r, i, a = "0") => {
1764
2003
  let o = i?.color, s = { idx: i?.idx ?? a };
1765
- o === void 0 ? t.empty(r, s) : (t.start(r, s), o === "auto" ? t.empty("styleClr", { val: "auto" }) : (t.pushDefaultNamespace("a"), U(t, n.getTheme(), o), t.popDefaultNamespace()), t.end(r));
1766
- }, Sn = (e, t, n, r) => {
2004
+ o === void 0 ? t.empty(r, s) : (t.start(r, s), o === "auto" ? t.empty("styleClr", { val: "auto" }) : (t.pushDefaultNamespace("a"), G(t, n.getTheme(), o), t.popDefaultNamespace()), t.end(r));
2005
+ }, sr = (e, t, n, r) => {
1767
2006
  let i = n.length;
1768
2007
  for (let a = 0; a < i; a++) {
1769
2008
  let i = n[a];
1770
- i.empty ? t.empty(i.type, i.mods) : (t.start(i.type, i.mods), xn(0, t, r, "lnRef", i.lineRef, "0"), xn(0, t, r, "fillRef", i.fillRef, "0"), xn(0, t, r, "effectRef", i.effectRef, "0"), xn(0, t, r, "fontRef", i.fontRef, "minor"), Xe(e, r, i, "spPr"), Jt(e, 0, i.defRPr), Yt(e, r, i.bodyPr), t.end(i.type));
2009
+ i.empty ? t.empty(i.type, i.mods) : (t.start(i.type, i.mods), or(0, t, r, "lnRef", i.lineRef, "0"), or(0, t, r, "fillRef", i.fillRef, "0"), or(0, t, r, "effectRef", i.effectRef, "0"), or(0, t, r, "fontRef", i.fontRef, "minor"), St(e, r, i, "spPr"), kn(e, 0, i.defRPr), An(e, r, i.bodyPr), t.end(i.type));
1771
2010
  }
1772
- }, Cn = Object.freeze([
2011
+ }, cr = Object.freeze([
1773
2012
  {
1774
2013
  type: "axisTitle",
1775
2014
  fontRef: { color: "tx1 lumMod 65 lumOff 35" },
@@ -2121,13 +2360,13 @@ var vn = (e, t, n, r) => {
2121
2360
  fill: { type: "none" },
2122
2361
  stroke: {}
2123
2362
  }
2124
- ]), wn = (e, t, n) => {
2363
+ ]), lr = (e, t, n) => {
2125
2364
  let r = n.length;
2126
2365
  for (let e = 0; e < r; e++) {
2127
2366
  let r = n[e], i = {}, a = r[0], o = r[1];
2128
2367
  a || o ? (t.start("variation", i), a && t.empty("a:lumMod", { val: a }), o && t.empty("a:lumOff", { val: o }), t.end("variation")) : t.empty("variation", i);
2129
2368
  }
2130
- }, Tn = Object.freeze([
2369
+ }, ur = Object.freeze([
2131
2370
  [0, 0],
2132
2371
  [6e4, 0],
2133
2372
  [8e4, 2e4],
@@ -2137,8 +2376,8 @@ var vn = (e, t, n, r) => {
2137
2376
  [7e4, 3e4],
2138
2377
  [7e4, 0],
2139
2378
  [5e4, 5e4]
2140
- ]), En = [
2141
- new class extends B {
2379
+ ]), dr = [
2380
+ new class extends U {
2142
2381
  constructor() {
2143
2382
  super({
2144
2383
  kind: "workbook",
@@ -2160,24 +2399,39 @@ var vn = (e, t, n, r) => {
2160
2399
  "xmlns:xr10": "http://schemas.microsoft.com/office/spreadsheetml/2016/revision10",
2161
2400
  "xmlns:xr2": "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"
2162
2401
  });
2163
- let r = /* @__PURE__ */ new Set(), i = e.getCalculation().getNamedFormulas().getItems();
2164
- for (let e = 0; e < i.length; e++) r.add(i[e].getName().toUpperCase());
2165
- let a = l(r), o = await e.toJSON({
2402
+ let r = t.getSharedStates().get(he), i = await e.toJSON({
2166
2403
  ignoreData: !0,
2167
- ignoreResources: !0,
2404
+ resources: (e, t) => (r?.set(t, e), null),
2168
2405
  includeHeaderStyles: !0,
2169
- formulaTransform: a,
2170
2406
  splitDirectBorders: !0
2171
2407
  });
2172
- (function(e, t, n) {
2173
- let r = {};
2174
- n.getRuntime().isDate1904() && (r.date1904 = "1"), t.empty("workbookPr", r);
2175
- })(0, n, e), function(e, t, n, r) {
2408
+ t.getSharedStates().set(o, l(i.names, function(e) {
2409
+ let t = [], n = e.sheets ?? [];
2410
+ for (let e = 0; e < n.length; e++) {
2411
+ let r = n[e]?.sheet?.tables;
2412
+ if (r) for (let e = 0; e < r.length; e++) {
2413
+ let n = r[e], i = Array.isArray(n) ? n[1]?.name : n?.v?.name;
2414
+ i && t.push(String(i));
2415
+ }
2416
+ }
2417
+ return t;
2418
+ }(i))), function(e, t) {
2419
+ let n = e.getSharedStates().get(nt);
2420
+ n && t.empty("fileVersion", n);
2421
+ }(t, n), function(e, t, n, r) {
2422
+ let i = {}, a = n.getCodeName();
2423
+ a && (i.codeName = a), n.getRuntime().isDate1904() && (i.date1904 = "1"), r.updateLinks && (i.updateLinks = r.updateLinks), t.empty("workbookPr", i);
2424
+ }(0, n, e, i), function(e, t, n, r) {
2176
2425
  let i = r.protection;
2177
- if (!i) return;
2426
+ if (!i || i.workbook) return;
2178
2427
  let a = {};
2179
- Pe(i.password ?? {}, a, "workbook"), Pe(i.revisionsPassword ?? {}, a, "revisions"), i.structure && (a.lockStructure = "1"), i.windows && (a.lockWindows = "1"), i.revision && (a.lockRevision = "1"), t.empty("workbookProtection", a);
2180
- }(0, n, 0, o), function(e, t, n) {
2428
+ Ue(i.password ?? {}, a, "workbook"), Ue(i.revisionsPassword ?? {}, a, "revisions");
2429
+ for (let e of y) {
2430
+ let t = u(e, i[e.key]);
2431
+ t !== null && (a[e.attribute] = t);
2432
+ }
2433
+ t.empty("workbookProtection", a);
2434
+ }(0, n, 0, i), function(e, t, n) {
2181
2435
  t.start("bookViews");
2182
2436
  let r = n.getView(), i = {};
2183
2437
  r.isShowHorizontalScrollbar() || (i.showHorizontalScroll = "0"), r.isShowVerticalScrollbar() || (i.showVerticalScroll = "0"), r.isShowTabs() || (i.showSheetTabs = "0");
@@ -2185,89 +2439,177 @@ var vn = (e, t, n, r) => {
2185
2439
  a !== 600 && (i.tabRatio = a);
2186
2440
  let o = n.getSelectedSheet().getIndex();
2187
2441
  o !== 0 && (i.activeTab = "" + o), t.empty("workbookView", i), t.end("bookViews");
2188
- }(0, n, e, o.view), n.start("sheets");
2189
- let s = t.getSharedStates();
2190
- s.set("formulaTransform", a);
2191
- let c = e.getStrings().beginPersist();
2442
+ }(0, n, e, i.view);
2443
+ let a = await (async (e, t) => {
2444
+ let n = [], r = t ? t.length : 0;
2445
+ if (r === 0) return n;
2446
+ let i = /* @__PURE__ */ new Map();
2447
+ e.getSharedStates().set("pivotCachePaths", i);
2448
+ for (let a = 0; a < r; a++) {
2449
+ let r = t[a], o = r.cacheId, s = r.part;
2450
+ if (s?.xml && !i.has(o)) try {
2451
+ let t = await Ze({
2452
+ ...s,
2453
+ type: s.type || "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
2454
+ contentType: s.contentType || "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
2455
+ }, e, "/xl/pivotCache/pivotCacheDefinition{n}.xml");
2456
+ if (!t?.relId) continue;
2457
+ i.set(o, t.path), n.push({
2458
+ cacheId: o,
2459
+ relId: t.relId
2460
+ });
2461
+ } catch (t) {
2462
+ e.log(`Unable to write the pivot cache ${o}; the pivot tables on it will be dropped.`, t);
2463
+ }
2464
+ }
2465
+ return n;
2466
+ })(t, i.pivotCaches);
2467
+ (function(e, t) {
2468
+ t.getComments().some((e) => !e.isNote()) && e.addPart("persons", t.getPeople());
2469
+ })(t, e), n.start("sheets");
2470
+ let s = t.getSharedStates(), c = e.getStrings().beginPersist();
2192
2471
  s.set("persistStrings", c);
2193
- let u = new Fe();
2194
- s.set("metaCollector", u);
2195
- let d = new Ie(u, t.warn.bind(t));
2196
- s.set("persistRichTypes", d);
2472
+ let d = new Ke();
2473
+ s.set("metaCollector", d);
2474
+ let f = new qe(d, t.log.bind(t));
2475
+ s.set("persistRichTypes", f), s.set(We, new Ge(i.styles, e.getStyles()));
2197
2476
  try {
2198
- let r = e.getSheets().getItems({ visibility: P.Visibility.VeryHidden }), i = o.sheets, a = e.getSelectedSheet(), l = r.length;
2477
+ let r = e.getSheets().getItems({ visibility: ue.Visibility.VeryHidden }), a = i.sheets, o = e.getSelectedSheet(), l = r.length, u = ((e, t) => {
2478
+ let n = Array(t), r = /* @__PURE__ */ new Set(), i = 1;
2479
+ for (let a = 0; a < t; a++) {
2480
+ let t = e?.[a]?.sheetId;
2481
+ t === void 0 || !Number.isInteger(t) || t < 1 || r.has(t) || (r.add(t), n[a] = t, t >= i && (i = t + 1));
2482
+ }
2483
+ for (let e = 0; e < t; e++) if (n[e] === void 0) {
2484
+ for (; r.has(i);) i++;
2485
+ r.add(i), n[e] = i++;
2486
+ }
2487
+ return n;
2488
+ })(a, l), d = ((e, t, n) => {
2489
+ let r = t.length, i = Array(r), a = new Set(n?.values() ?? []), o = /* @__PURE__ */ new Set();
2490
+ for (let a = 0; a < r; a++) {
2491
+ let r = e?.[a]?.sheetId;
2492
+ if (r === void 0 || t[a] !== r) continue;
2493
+ let s = n?.get(r);
2494
+ s && !o.has(s) && (o.add(s), i[a] = s);
2495
+ }
2496
+ let s = 1;
2497
+ for (let e = 0; e < r; e++) {
2498
+ if (i[e]) continue;
2499
+ let t;
2500
+ do
2501
+ t = `xl/worksheets/sheet${s++}.xml`;
2502
+ while (a.has(t) || o.has(t));
2503
+ o.add(t), i[e] = t;
2504
+ }
2505
+ return i;
2506
+ })(a, u, s.get(rt));
2199
2507
  for (let e = 0; e < l; e++) {
2200
- let o = r[e], s = "" + (o.getIndex() + 1), l = {
2201
- name: o.getName(),
2508
+ let i = r[e], s = "" + u[e], l = {
2509
+ name: i.getName(),
2202
2510
  sheetId: s
2203
- }, u = o.getVisibility();
2204
- u === "hidden" ? l.state = "hidden" : u === "veryHidden" && (l.state = "veryHidden");
2205
- let d = i[e].sheet;
2511
+ }, f = i.getVisibility();
2512
+ f === "hidden" ? l.state = "hidden" : f === "veryHidden" && (l.state = "veryHidden");
2513
+ let p = a[e].sheet;
2206
2514
  l["r:id"] = t.addPart("worksheet", {
2207
- model: o,
2208
- isSelected: a === o,
2209
- json: d,
2515
+ model: i,
2516
+ isSelected: o === i,
2517
+ json: p,
2210
2518
  persistStrings: c
2211
- }).relId, n.empty("sheet", l);
2519
+ }, "/" + d[e]).relId, n.empty("sheet", l);
2212
2520
  }
2213
2521
  await t.waitEmit();
2214
- let u = e.getTheme();
2522
+ let f = e.getTheme();
2215
2523
  t.addPart("theme", {
2216
- model: u,
2217
- json: o.theme
2524
+ model: f,
2525
+ json: i.theme
2218
2526
  }), await t.waitEmit(), t.addPart("styles", {
2219
2527
  styles: e.getStyles(),
2220
2528
  theme: e.getTheme(),
2221
- json: o.styles
2529
+ json: i.styles
2222
2530
  }), await t.waitEmit();
2223
- let d = await c.toJSONAsync();
2224
- d && d.length > 0 && (t.addPart("sharedStrings", {
2225
- model: d,
2226
- json: d
2531
+ let p = await c.toJSONAsync();
2532
+ p && p.length > 0 && (t.addPart("sharedStrings", {
2533
+ model: p,
2534
+ json: p
2227
2535
  }), await t.waitEmit());
2228
- let f = s.get("persistRichTypes");
2229
- f?.hasAny() && (t.addPart("richValue", f), t.addPart("richValueStructure", f), t.addPart("richValueTypes", null), await t.waitEmit());
2230
- let p = s.get("metaCollector");
2231
- p?.hasAny() && (t.addPart("metadata", p), await t.waitEmit()), s.delete("persistRichTypes"), s.delete("metaCollector"), s.delete("persistStrings");
2536
+ let m = s.get("persistRichTypes");
2537
+ m?.hasAny() && (t.addPart("richValue", m), t.addPart("richValueStructure", m), t.addPart("richValueTypes", null), await t.waitEmit());
2538
+ let h = s.get("metaCollector");
2539
+ h?.hasAny() && (t.addPart("metadata", h), await t.waitEmit()), s.delete("persistRichTypes"), s.delete("metaCollector"), s.delete("persistStrings");
2232
2540
  } catch (e) {
2233
2541
  throw e;
2234
2542
  } finally {
2235
2543
  c.endPersist();
2236
2544
  }
2237
- n.end("sheets"), function(e, t, n, r, i) {
2238
- let a = r.names, o = a ? a.length : 0;
2239
- if (o === 0) return;
2240
- let s = n.getCalculation().getNamedFormulas(), c = /* @__PURE__ */ new Map(), l = n.getSheets().getItems({ visibility: P.Visibility.VeryHidden });
2241
- for (let e = 0; e < l.length; e++) c.set(l[e].getName().toLowerCase(), e);
2545
+ n.end("sheets"), function(e, t, n) {
2546
+ let r = n.externalBooks, i = r ? r.length : 0;
2547
+ if (i === 0) return;
2548
+ let a = e.getSharedStates().get(it), o = /* @__PURE__ */ new Set();
2549
+ if (a) for (let e = 0; e < i; e++) !r[e] && a[e] && o.add(a[e]);
2550
+ let s = [], c = 1;
2551
+ for (let t = 0; t < i; t++) {
2552
+ let n = r[t];
2553
+ if (n) {
2554
+ let t;
2555
+ do
2556
+ t = `xl/externalLinks/externalLink${c++}.xml`;
2557
+ while (o.has(t));
2558
+ s.push(e.addPart("externalLink", n, "/" + t).relId);
2559
+ continue;
2560
+ }
2561
+ let i = a?.[t], l = i ? e.addRelationship(tt, i) : null;
2562
+ l ? s.push(l) : e.log(`External link [${t + 1}] cannot be written and is being dropped; later links will renumber.`);
2563
+ }
2564
+ if (s.length !== 0) {
2565
+ t.start("externalReferences");
2566
+ for (let e = 0; e < s.length; e++) t.empty("externalReference", { "r:id": s[e] });
2567
+ t.end("externalReferences");
2568
+ }
2569
+ }(t, n, i), function(e, t, n, r) {
2570
+ let i = e.getSharedStates().get(o), a = r.names, s = a ? a.length : 0;
2571
+ if (s === 0) return;
2572
+ let c = r.externalBooks?.length ?? 0, l = /* @__PURE__ */ new Map(), u = n.getSheets().getItems({ visibility: ue.Visibility.VeryHidden });
2573
+ for (let e = 0; e < u.length; e++) l.set(u[e].getName().toLowerCase(), e);
2242
2574
  t.start("definedNames");
2243
- for (let n = 0; n < o; n++) {
2575
+ for (let n = 0; n < s; n++) {
2244
2576
  let r = a[n], o = { name: r.name };
2245
2577
  if (r.comment && (o.comment = r.comment), r.scope) {
2246
- let t = c.get(r.scope.toLowerCase());
2247
- t === void 0 ? e.warn(`Defined name '${r.name}' is scoped to unknown sheet '${r.scope}'; writing it as global.`) : o.localSheetId = "" + t;
2578
+ let t = l.get(r.scope.toLowerCase());
2579
+ t === void 0 ? e.log(`Defined name '${r.name}' is scoped to unknown sheet '${r.scope}'; writing it as global.`) : o.localSheetId = "" + t;
2248
2580
  }
2249
2581
  r.hidden && (o.hidden = "1");
2250
- let l = r.ref, u = s.getItems({
2251
- name: r.name,
2252
- scope: r.scope ?? null
2253
- })[0];
2254
- u && (l = u.getExpression({ formulaTransform: i })), t.start("definedName", o), t.text(l), t.end("definedName");
2582
+ let s = i.writeName(r.ref);
2583
+ for (let t of at(s)) t > c && e.log(`Defined name '${r.name}' cites external book [${t}], but only ${c} ${c === 1 ? "is" : "are"} written; Excel will report the file as needing repair.`);
2584
+ t.start("definedName", o), t.text(s), t.end("definedName");
2255
2585
  }
2256
2586
  t.end("definedNames");
2257
- }(t, n, e, o, a), function(e, t, n) {
2258
- let r = n.getCalculation().toJSON(), i = {}, a = (e, t) => {
2587
+ }(t, n, e, i), function(e, t, n) {
2588
+ let r = n.getCalculation().toJSON(), i = { calcId: e.getSharedStates().get("calcId") ?? "191029" }, a = (e, t) => {
2259
2589
  let n = r[e];
2260
2590
  typeof n == "boolean" && (i[t] = n ? "1" : "0");
2261
2591
  };
2262
2592
  if (r.calcMode) {
2263
- let e = Re[r.calcMode];
2593
+ let e = ot[r.calcMode];
2264
2594
  e && e !== "auto" && (i.calcMode = e);
2265
2595
  }
2266
- a("fullCalcOnLoad", "fullCalcOnLoad"), a("calcOnSave", "calcOnSave"), a("calcCompleted", "calcCompleted"), a("fullPrecision", "fullPrecision"), a("forceFullCalc", "forceFullCalc"), a("concurrentCalc", "concurrentCalc"), r.refMode && (i.refMode = r.refMode), r.iterate && (i.iterate = "1"), r.maxIterations !== void 0 && (i.iterateCount = String(r.maxIterations)), r.maxIterateChange !== void 0 && (i.iterateDelta = String(r.maxIterateChange)), Object.keys(i).length !== 0 && t.empty("calcPr", i);
2267
- }(0, n, e), n.end("workbook"), n.close();
2596
+ a("fullCalcOnLoad", "fullCalcOnLoad"), a("calcOnSave", "calcOnSave"), a("calcCompleted", "calcCompleted"), a("fullPrecision", "fullPrecision"), a("forceFullCalc", "forceFullCalc"), a("concurrentCalc", "concurrentCalc"), r.refMode && (i.refMode = r.refMode), r.iterate && (i.iterate = "1"), r.maxIteration !== void 0 && (i.iterateCount = String(r.maxIteration)), r.maxIterateChange !== void 0 && (i.iterateDelta = String(r.maxIterateChange)), t.empty("calcPr", i);
2597
+ }(t, n, e), function(e, t) {
2598
+ if (t.length !== 0) {
2599
+ e.start("pivotCaches");
2600
+ for (let n = 0; n < t.length; n++) e.empty("pivotCache", {
2601
+ cacheId: t[n].cacheId,
2602
+ "r:id": t[n].relId
2603
+ });
2604
+ e.end("pivotCaches");
2605
+ }
2606
+ }(n, a), function(e, t) {
2607
+ let n = e.getSharedStates().get("calcFeatures") ?? "<ext uri=\"{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}\" xmlns:xcalcf=\"http://schemas.microsoft.com/office/spreadsheetml/2018/calcfeatures\"><xcalcf:calcFeatures><xcalcf:feature name=\"microsoft.com:RD\"/><xcalcf:feature name=\"microsoft.com:Single\"/><xcalcf:feature name=\"microsoft.com:FV\"/><xcalcf:feature name=\"microsoft.com:CNMTM\"/><xcalcf:feature name=\"microsoft.com:LET_WF\"/><xcalcf:feature name=\"microsoft.com:LAMBDA_WF\"/><xcalcf:feature name=\"microsoft.com:ARRAYTEXT_WF\"/></xcalcf:calcFeatures></ext>";
2608
+ t.start("extLst"), t.raw(n), t.end("extLst");
2609
+ }(t, n), n.end("workbook"), n.close();
2268
2610
  }
2269
2611
  }(),
2270
- new class extends B {
2612
+ new class extends U {
2271
2613
  constructor() {
2272
2614
  super({
2273
2615
  kind: "worksheet",
@@ -2276,8 +2618,8 @@ var vn = (e, t, n, r) => {
2276
2618
  path: () => "/xl/worksheets/sheet{n}.xml"
2277
2619
  });
2278
2620
  }
2279
- async emit(n, i) {
2280
- let s = i.getXMLWriter(), c = n.model, l = n.json;
2621
+ async emit(i, a) {
2622
+ let s = a.getXMLWriter(), c = i.model, d = i.json;
2281
2623
  s.decl(), s.start("worksheet", {
2282
2624
  xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
2283
2625
  "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
@@ -2285,10 +2627,17 @@ var vn = (e, t, n, r) => {
2285
2627
  "mc:Ignorable": "x14ac",
2286
2628
  "xmlns:x14ac": "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
2287
2629
  }), function(e, t, n) {
2288
- let r = n.getTabColor();
2289
- r && (t.start("sheetPr"), r && G(t, n.getStyles().getTheme(), r, "tabColor", !1), t.end("sheetPr"));
2630
+ let r = n.getTabColor(), i = n.getCodeName(), a = {};
2631
+ i && (a.codeName = i), n.isConditionalFormatCalculationEnabled() || (a.enableFormatConditionsCalculation = "0");
2632
+ let o = n.getOutlineSettings(), s = {};
2633
+ o.summaryBelow || (s.summaryBelow = "0"), o.summaryRight || (s.summaryRight = "0"), o.showOutlineSymbols || (s.showOutlineSymbols = "0"), o.applyStyles && (s.applyStyles = "1");
2634
+ let c = Object.keys(s).length > 0, l = !!r || c;
2635
+ if (!(!l && Object.keys(a).length === 0)) {
2636
+ if (!l) return void t.empty("sheetPr", a);
2637
+ t.start("sheetPr", a), r && q(t, n.getStyles().getTheme(), r, "tabColor", !1), c && t.empty("outlinePr", s), t.end("sheetPr");
2638
+ }
2290
2639
  }(0, s, c), function(e, t, n, r) {
2291
- let i = n.getUsedRange({ features: [] }), a = i ? i.getCoords() : null, o = St, s = Ct, c = r.directStyles, l = c ? c.length : 0;
2640
+ let i = n.getUsedRange({ features: [] }), a = i ? i.getCoords() : null, o = k, s = M, c = r.directStyles, l = c ? c.length : 0;
2292
2641
  for (let e = 0; e < l; e++) {
2293
2642
  let t = n.getRange(c[e][0]).getCoords();
2294
2643
  if (t.colEnd === s) {
@@ -2307,12 +2656,12 @@ var vn = (e, t, n, r) => {
2307
2656
  rowEnd: e
2308
2657
  };
2309
2658
  }
2310
- a = O.unionRanges(a, t);
2659
+ a = oe.unionRanges(a, t);
2311
2660
  }
2312
2661
  let u = r.merges, d = u ? u.length : 0;
2313
2662
  for (let e = 0; e < d; e++) {
2314
2663
  let t = n.getRange(u[e]).getCoords();
2315
- t.colEnd === s && (t = { ...a }, t.colStart = a?.colStart ?? 0, t.colEnd = t.colStart), t.rowEnd === o && (t = { ...t }, t.rowStart = a?.rowStart ?? 0, t.rowEnd = t.rowStart), a = O.unionRanges(a, t);
2664
+ t.colEnd === s && (t = { ...a }, t.colStart = a?.colStart ?? 0, t.colEnd = t.colStart), t.rowEnd === o && (t = { ...t }, t.rowStart = a?.rowStart ?? 0, t.rowEnd = t.rowStart), a = oe.unionRanges(a, t);
2316
2665
  }
2317
2666
  let f = "A1";
2318
2667
  a && (i = n.getRange(a), f = a.colStart === a.colEnd && a.rowStart === a.rowEnd ? i.getAddress() : `${i.getIntersect({
@@ -2326,8 +2675,8 @@ var vn = (e, t, n, r) => {
2326
2675
  colEnd: a.colEnd,
2327
2676
  rowEnd: a.rowEnd
2328
2677
  }).getAddress()}`), t.empty("dimension", { ref: f });
2329
- }(0, s, c, l), function(e, t, n, r, i) {
2330
- let a = n.getView(), o = a.getTopLeft(), s = n.getRowHeaders().getIndex(o.top), c = n.getColumnHeaders().getIndex(o.left), l = T.cellToString({
2678
+ }(0, s, c, d), function(e, t, n, r, i) {
2679
+ let a = n.getView(), o = a.getTopLeft(), s = n.getRowHeaders().getIndex(o.top), c = n.getColumnHeaders().getIndex(o.left), l = P.cellToString({
2331
2680
  colIndex: c,
2332
2681
  rowIndex: s
2333
2682
  });
@@ -2347,20 +2696,20 @@ var vn = (e, t, n, r) => {
2347
2696
  u.colorId = "" + s;
2348
2697
  }
2349
2698
  u.workbookViewId = "0";
2350
- let p = n.getSelection().getCoords(), m = T.cellToString(p.cell), h = {}, g = a.getFreezePanes(), _ = g.coords ?? {}, v = _.colIndex ?? 0, y = _.rowIndex ?? 0;
2699
+ let p = n.getSelection().getCoords(), m = P.cellToString(p.cell), h = {}, g = a.getFreezePanes(), _ = g.coords ?? {}, v = _.colIndex ?? 0, y = _.rowIndex ?? 0;
2351
2700
  if (v > 0 || y > 0) {
2352
- let e = g.topLeft ?? {}, r = e.top ?? 0, i = e.left ?? 0, a = n.getRowHeaders().getIndex(r), s = n.getColumnHeaders().getIndex(i), c = v - s, l = y - a, d = Math.max(v, n.getColumnHeaders().getIndex(o.left + n.getColumnHeaders().getOffset(v) - i)), f = Math.max(y, n.getRowHeaders().getIndex(o.top + n.getRowHeaders().getOffset(y) - r)), p = T.cellToString({
2701
+ let e = g.topLeft ?? {}, r = e.top ?? 0, i = e.left ?? 0, a = n.getRowHeaders().getIndex(r), s = n.getColumnHeaders().getIndex(i), c = v - s, l = y - a, d = Math.max(v, n.getColumnHeaders().getIndex(o.left + n.getColumnHeaders().getOffset(v) - i)), f = Math.max(y, n.getRowHeaders().getIndex(o.top + n.getRowHeaders().getOffset(y) - r)), p = P.cellToString({
2353
2702
  colIndex: s,
2354
2703
  rowIndex: a
2355
2704
  });
2356
2705
  p === "A1" ? delete u.topLeftCell : u.topLeftCell = p, t.start("sheetView", u);
2357
2706
  let m = {};
2358
- if (c > 0 && (m.xSplit = c), l > 0 && (m.ySplit = l), m.topLeftCell = T.cellToString({
2707
+ if (c > 0 && (m.xSplit = c), l > 0 && (m.ySplit = l), m.topLeftCell = P.cellToString({
2359
2708
  colIndex: d,
2360
2709
  rowIndex: f
2361
2710
  }), m.state = "frozen", v === 0) {
2362
2711
  m.activePane = "bottomLeft", t.empty("pane", m);
2363
- let e = T.cellToString({
2712
+ let e = P.cellToString({
2364
2713
  colIndex: d,
2365
2714
  rowIndex: a
2366
2715
  });
@@ -2370,7 +2719,7 @@ var vn = (e, t, n, r) => {
2370
2719
  }), h.pane = "bottomLeft";
2371
2720
  } else if (y === 0) {
2372
2721
  m.activePane = "topRight", t.empty("pane", m);
2373
- let e = T.cellToString({
2722
+ let e = P.cellToString({
2374
2723
  colIndex: s,
2375
2724
  rowIndex: f
2376
2725
  });
@@ -2383,7 +2732,7 @@ var vn = (e, t, n, r) => {
2383
2732
  activeCell: p,
2384
2733
  sqref: p
2385
2734
  });
2386
- let e = T.cellToString({
2735
+ let e = P.cellToString({
2387
2736
  colIndex: d,
2388
2737
  rowIndex: a
2389
2738
  });
@@ -2392,7 +2741,7 @@ var vn = (e, t, n, r) => {
2392
2741
  activeCell: e,
2393
2742
  sqref: e
2394
2743
  });
2395
- let n = T.cellToString({
2744
+ let n = P.cellToString({
2396
2745
  colIndex: s,
2397
2746
  rowIndex: f
2398
2747
  });
@@ -2409,87 +2758,109 @@ var vn = (e, t, n, r) => {
2409
2758
  let e = "";
2410
2759
  for (let t = 0; t < x; t++) {
2411
2760
  let n = b[t];
2412
- t > 0 && (e += " "), e += T.rangeToString(n);
2761
+ t > 0 && (e += " "), e += P.rangeToString(n);
2413
2762
  }
2414
2763
  h.sqref = e, (p.rangeIndex ?? 0) > 0 && (h.activeCellId = "" + p.rangeIndex);
2415
2764
  } else m === "A1" ? h = null : h.sqref = m;
2416
2765
  h && t.empty("selection", h), t.end("sheetView"), t.end("sheetViews");
2417
- }(0, s, c, 0, n.isSelected), function(e, t, n, r) {
2766
+ }(0, s, c, 0, i.isSelected), function(e, t, n, r) {
2418
2767
  let i = r.defaultColSize, a = r.defaultRowSize, o = {};
2419
2768
  i !== void 0 && (o.defaultColWidth = i), o.defaultRowHeight = a ?? .75 * n.getRowHeaders().getDefaultSize(), a !== void 0 && (o.customHeight = "1"), o["x14ac:dyDescent"] = "0.25", t.empty("sheetFormatPr", o);
2420
- }(0, s, c, l), function(e, t, n, r) {
2421
- let i = r.cols ? T.refsToRuns(r.cols, !0) : null, a = i ? i.length : 0;
2769
+ }(0, s, c, d);
2770
+ let f = !1 === d.protection?.showFormulas ? a.getSharedStates().get("hiddenFormulaXfs") ?? null : null;
2771
+ (function(e, t, n, r, i) {
2772
+ let a = r.cols ? P.refsToRuns(r.cols, !0) : null, o = a ? a.length : 0;
2422
2773
  n.getEntireRange().getColumnEnd();
2423
- let o = n.getColumnHeaders().getDefaultSizeNative();
2424
- if (a > 0) {
2774
+ let s = n.getColumnHeaders().getDefaultSizeNative(), c = i ? i.getHiddenXf(0) : 0, l = 1, u = (e) => {
2775
+ c !== 0 && e >= l && t.empty("col", {
2776
+ min: l,
2777
+ max: e,
2778
+ width: s,
2779
+ style: c
2780
+ });
2781
+ };
2782
+ if (o > 0 || c !== 0) {
2425
2783
  t.start("cols");
2426
- for (let e = 0; e < a; e++) {
2427
- let n = i[e], r = n.min + 1, a = 16384;
2428
- if (r > a) continue;
2429
- let s = {
2784
+ for (let e = 0; e < o; e++) {
2785
+ let n = a[e], r = n.min + 1, o = M + 1;
2786
+ if (r > o) continue;
2787
+ let c = Math.min(n.max + 1, o);
2788
+ u(r - 1), l = c + 1;
2789
+ let d = {
2430
2790
  min: r,
2431
- max: Math.min(n.max + 1, a)
2432
- }, c = n.value, l = c.sz;
2433
- l === void 0 ? s.width = o : l !== 0 && (s.width = Math.round(256 * l) / 256), c.s && (s.style = c.s), c.h !== void 0 && (s.hidden = 1), c.csz && (s.customWidth = 1), c.l !== void 0 && (s.outlineLevel = c.l), c.cl !== void 0 && (s.collapsed = 1), t.empty("col", s);
2791
+ max: c
2792
+ }, f = n.value, p = f.sz;
2793
+ p === void 0 ? d.width = s : p !== 0 && (d.width = Math.round(256 * p) / 256);
2794
+ let m = i ? i.getHiddenXf(f.s ?? 0) : f.s;
2795
+ m && (d.style = m), f.h !== void 0 && (d.hidden = 1), f.csz && (d.customWidth = 1), f.l !== void 0 && (d.outlineLevel = f.l), f.cl !== void 0 && (d.collapsed = 1), t.empty("col", d);
2434
2796
  }
2435
- t.end("cols");
2797
+ u(M + 1), t.end("cols");
2436
2798
  }
2437
- }(0, s, c, l), function(n, r, i, a, o) {
2438
- let s = n.getSharedStates(), c = s.get("persistStrings"), l = s.get("metaCollector"), u = s.get("persistRichTypes"), d = s.get("formulaTransform"), p = 0, m = 0, _ = i.getUsedRange(), v = 0, y = a.rows ? T.refsToRuns(a.rows, !1) : null, x = y ? y.length : 0, S = y?.[x - 1]?.max ?? -1, w = a.cols ? T.refsToRuns(a.cols, !0) : null, E = w ? w.length : 0, te = w?.[E - 1]?.max ?? -1;
2439
- if (_ || x > 0) {
2440
- let s = .75, _ = a.defaultRowSize ?? i.getRowHeaders().getDefaultSize() * s, x = i.getStyles().getNormal().getBestFit().height * s, E = (e, t) => {
2441
- let n = Lt;
2799
+ })(0, s, c, d, f), function(e, i, a, o, s, c) {
2800
+ let u = e.getSharedStates(), d = u.get("persistStrings"), f = u.get("metaCollector"), p = u.get("persistRichTypes"), m = 0, h = 0, g = a.getUsedRange(), _ = 0, v = o.rows ? P.refsToRuns(o.rows, !1) : null, y = v ? v.length : 0, b = v?.[y - 1]?.max ?? -1, x = o.cols ? P.refsToRuns(o.cols, !0) : null, S = x ? x.length : 0, C = x?.[S - 1]?.max ?? -1;
2801
+ if (g || y > 0) {
2802
+ let u = .75, g = o.defaultRowSize ?? a.getRowHeaders().getDefaultSize() * u, y = a.getStyles().getNormal().getBestFit().height * u, S = (e, t) => {
2803
+ let n = vn;
2442
2804
  if (n.r = "" + (e + 1), n.s = void 0, n.customFormat = void 0, n.hidden = void 0, n.ht = void 0, n.customHeight = void 0, n.outlineLevel = void 0, n.collapsed = void 0, !t) return n;
2443
2805
  let r = t.value;
2444
- r.s !== void 0 && (n.s = "" + r.s, n.customFormat = "1"), r.h && (n.hidden = "1");
2445
- let i = r.csz ?? !1, a = r.sz ?? _;
2446
- return (a !== x || i) && (n.ht = "" + a), i && (n.customHeight = "1"), r.l !== void 0 && (n.outlineLevel = "" + r.l), r.cl !== void 0 && (n.collapsed = "" + r.cl), n;
2447
- }, D = 0, O = y?.[D] ?? null, k = O?.min ?? 2 ** 53 - 1, A = O?.max ?? 2 ** 53 - 1, j = O?.value?.s, M = -1, N = 0, P = w?.[N] ?? null, F = P?.min ?? 2 ** 53 - 1, I = P?.max ?? 2 ** 53 - 1, L = P?.value?.s, re = (e, t = !1) => {
2448
- if (M !== e) {
2449
- for (M !== -1 && (r.end("row"), N !== 0 && (N = 0, P = w?.[N] ?? null, F = P?.min ?? 2 ** 53 - 1, I = P?.max ?? 2 ** 53 - 1, L = P?.value?.s)); M + 1 <= e;) {
2450
- M++, O && M > A && (O = y[++D] ?? null, O ? (k = O.min, A = O.max, j = O.value?.s) : (k = 2 ** 53 - 1, A = 2 ** 53 - 1, j = void 0)), M < k && M < e && (M = O ? Math.min(k, e) : e);
2451
- let n = M < e || t && M === e, i = E(M, O && M >= k && M <= A ? O : null);
2452
- n ? r.empty("row", i) : r.start("row", i);
2806
+ r.s !== void 0 && (n.s = "" + (c ? c.getHiddenXf(r.s) : r.s), n.customFormat = "1"), r.h && (n.hidden = "1");
2807
+ let i = r.csz ?? !1, a = r.sz ?? g;
2808
+ return (a !== y || i) && (n.ht = "" + a), i && (n.customHeight = "1"), r.l !== void 0 && (n.outlineLevel = "" + r.l), r.cl !== void 0 && (n.collapsed = "" + r.cl), n;
2809
+ }, w = 0, T = v?.[w] ?? null, D = T?.min ?? 2 ** 53 - 1, O = T?.max ?? 2 ** 53 - 1, ee = T?.value?.s, k = -1, A = 0, j = x?.[A] ?? null, te = j?.min ?? 2 ** 53 - 1, M = j?.max ?? 2 ** 53 - 1, ne = j?.value?.s, re = (e, t = !1) => {
2810
+ if (k !== e) {
2811
+ for (k !== -1 && (i.end("row"), A !== 0 && (A = 0, j = x?.[A] ?? null, te = j?.min ?? 2 ** 53 - 1, M = j?.max ?? 2 ** 53 - 1, ne = j?.value?.s)); k + 1 <= e;) {
2812
+ k++, T && k > O && (T = v[++w] ?? null, T ? (D = T.min, O = T.max, ee = T.value?.s) : (D = 2 ** 53 - 1, O = 2 ** 53 - 1, ee = void 0)), k < D && k < e && (k = T ? Math.min(D, e) : e);
2813
+ let n = k < e || t && k === e, r = S(k, T && k >= D && k <= O ? T : null);
2814
+ n ? i.empty("row", r) : i.start("row", r);
2453
2815
  }
2454
- if (e < M) {
2455
- let t = E(e, null);
2456
- r.start("row", t);
2816
+ if (e < k) {
2817
+ let t = S(e, null);
2818
+ i.start("row", t);
2457
2819
  }
2458
2820
  }
2459
2821
  };
2460
- r.setValidationDisabled(!0), r.start("sheetData");
2461
- let R = [];
2462
- R.push(Et(n, i, a.directStyles));
2463
- let B = a.formulas, ie = B ? B.length : 0;
2464
- if (ie > 0) {
2822
+ i.setValidationDisabled(!0), i.start("sheetData");
2823
+ let N = [];
2824
+ N.push(Zt(e, a, o.directStyles));
2825
+ let F = o.formulas, ae = F ? F.length : 0;
2826
+ if (ae > 0) {
2465
2827
  let n = /* @__PURE__ */ new Map();
2466
- if (o.names.size > 0 && a.formulaArray) for (let e of a.formulaArray) try {
2467
- let t = i.getRange(e[0]).getCoords();
2828
+ if (s.names.size > 0 && o.formulaArray) for (let e of o.formulaArray) try {
2829
+ let t = a.getRange(e[0]).getCoords();
2468
2830
  n.set(`${t.rowStart},${t.colStart}`, t);
2469
2831
  } catch {}
2470
2832
  let r = [];
2471
- if (a.formulaArray) for (let e of a.formulaArray) try {
2472
- r.push(i.getRange(e[0]).getCoords());
2833
+ if (o.formulaArray) for (let e of o.formulaArray) try {
2834
+ r.push(a.getRange(e[0]).getCoords());
2473
2835
  } catch {}
2474
- let s = (e) => {
2836
+ let i = (e) => {
2475
2837
  for (let t = 0; t < r.length; t++) {
2476
2838
  let n = r[t];
2477
2839
  if (n.rowStart <= e.rowEnd && n.rowEnd >= e.rowStart && n.colStart <= e.colEnd && n.colEnd >= e.colStart) return !0;
2478
2840
  }
2479
2841
  return !1;
2480
- }, c = C(() => i.getCalculation()), l = (e) => {
2481
- if (!e) return;
2482
- let t;
2483
- return e.getExpression({ formulaTransform: (e, n) => {
2484
- n === void 0 && (t = e);
2485
- } }), t;
2486
- }, u = [];
2487
- for (let r = 0; r < ie; r++) {
2488
- let a = B[r];
2842
+ }, c = e.getSharedStates().get("xlsxFormulaDialect") ?? l(a.getCalculation().getNamedFormulas().toJSON(), a.getTables().getItems().map((e) => e.getName())), u = a.getEntireRange().getCoords(), d = [];
2843
+ for (let e of a.getTables().getItems()) d.push([e.getRange().getCoords(), e.getName()]);
2844
+ let f = (e, t) => {
2845
+ for (let n = 0; n < d.length; n++) {
2846
+ let r = d[n][0];
2847
+ if (e >= r.rowStart && e <= r.rowEnd && t >= r.colStart && t <= r.colEnd) return d[n][1];
2848
+ }
2849
+ return null;
2850
+ }, p = /* @__PURE__ */ new Set();
2851
+ for (let e = 0; e < r.length; e++) p.add(`${r[e].rowStart},${r[e].colStart}`);
2852
+ let m = [];
2853
+ for (let r = 0; r < ae; r++) {
2854
+ let o = F[r];
2489
2855
  try {
2490
- let p = a[0], m = i.getRange(p), h = m.getCoords(), _ = a[1], y = null, b = l(m.getCell().getFormula()), x = !!b && t(b, c), S = e(b);
2491
- if (o.affects(r)) {
2492
- y = null, x = !1;
2856
+ let e = o[0], l = a.getRange(e), d = l.getCoords(), h = o[1], g = null, v = {
2857
+ rowIndex: d.rowStart,
2858
+ colIndex: d.colStart
2859
+ }, y = c.parse(h, v), b = y ? c.annotate(y) : void 0, x = y ? c.spell(y, p.has(`${d.rowStart},${d.colStart}`), f(d.rowStart, d.colStart)) : null, S = x ? ce.imager(x, { entireCoords: u }) : null;
2860
+ S && (h = S(v));
2861
+ let C = !0 === b?.cm, w = !0 === b?.ca;
2862
+ if (s.affects(r)) {
2863
+ g = null, C = !1;
2493
2864
  let e = (e, t, n) => {
2494
2865
  let r = {
2495
2866
  rowStart: e,
@@ -2497,91 +2868,77 @@ var vn = (e, t, n, r) => {
2497
2868
  rowEnd: e,
2498
2869
  colEnd: t
2499
2870
  };
2500
- u.push([r, {
2871
+ m.push([r, {
2501
2872
  coords: r,
2502
2873
  formula: n,
2503
2874
  sharedId: null,
2504
- ref: T.rangeToString(r),
2875
+ ref: P.rangeToString(r),
2505
2876
  isDynamicRange: !1,
2506
2877
  isWrapped: !0
2507
2878
  }]);
2508
- }, t = n.get(`${h.rowStart},${h.colStart}`), r = t !== void 0 && (t.rowEnd > t.rowStart || t.colEnd > t.colStart), a = !1;
2509
- if (r) {
2510
- let n = g(_, m.getCell().getValue());
2511
- if (n !== null) for (let r = t.rowStart; r <= t.rowEnd; r++) for (let o = t.colStart; o <= t.colEnd; o++) {
2512
- if (r === t.rowStart && o === t.colStart) {
2513
- e(r, o, n), a = !0;
2879
+ }, r = n.get(`${d.rowStart},${d.colStart}`), i = r !== void 0 && (r.rowEnd > r.rowStart || r.colEnd > r.colStart), o = !1;
2880
+ if (i) {
2881
+ let n = t(h, l.getCell().getValue());
2882
+ if (n !== null) for (let t = r.rowStart; t <= r.rowEnd; t++) for (let i = r.colStart; i <= r.colEnd; i++) {
2883
+ if (t === r.rowStart && i === r.colStart) {
2884
+ e(t, i, n), o = !0;
2514
2885
  continue;
2515
2886
  }
2516
- let s = f(i.getRange(T.rangeToString({
2517
- rowStart: r,
2518
- colStart: o,
2519
- rowEnd: r,
2520
- colEnd: o
2887
+ let s = E(a.getRange(P.rangeToString({
2888
+ rowStart: t,
2889
+ colStart: i,
2890
+ rowEnd: t,
2891
+ colEnd: i
2521
2892
  })).getCell().getValue());
2522
- s !== null && e(r, o, s);
2523
- }
2524
- } else {
2525
- let t = m.getCells();
2526
- for (let n = 0; n < t.length; n++) {
2527
- let r = t[n];
2528
- for (let t = 0; t < r.length; t++) {
2529
- let i = r[t], o = g(i.getFormula()?.getExpression() ?? _, i.getValue());
2530
- o !== null && (e(h.rowStart + n, h.colStart + t, o), a = !0);
2531
- }
2893
+ s !== null && e(t, i, s);
2532
2894
  }
2533
- }
2534
- if (a) continue;
2535
- }
2536
- let ee = _.indexOf("!") !== -1 || _.indexOf("[") !== -1, C;
2537
- if (x || m.isSingleCell() || ee || s(h) || (y = "" + v++), y === null && !m.isSingleCell()) {
2538
- C = [];
2539
- let e = m.getCells();
2540
- for (let t = 0; t < e.length; t++) {
2541
- let n = e[t], r = Array(n.length);
2542
- for (let e = 0; e < n.length; e++) t === 0 && e === 0 || (r[e] = n[e].getFormula()?.getExpression({ formulaTransform: d }) ?? void 0);
2543
- C.push(r);
2544
- }
2895
+ } else l.forEach((n, r) => {
2896
+ let i = r.getCoords(), a = t(S?.(i) ?? h, r.getCell().getValue());
2897
+ a !== null && (e(i.rowIndex, i.colIndex, a), o = !0);
2898
+ }, { includeEmpty: !0 });
2899
+ if (o) continue;
2545
2900
  }
2546
- let w = [h, {
2547
- coords: h,
2548
- formula: _,
2549
- sharedId: y,
2550
- ref: p,
2551
- isDynamicRange: x,
2552
- isExcelVolatile: S,
2553
- memberTexts: C
2901
+ let T = h.indexOf("!") !== -1 || h.indexOf("[") !== -1;
2902
+ C || l.isSingleCell() || T || i(d) || (g = "" + _++);
2903
+ let D = g !== null || l.isSingleCell() ? null : S, O = [d, {
2904
+ coords: d,
2905
+ formula: h,
2906
+ sharedId: g,
2907
+ ref: e,
2908
+ isDynamicRange: C,
2909
+ isExcelVolatile: w,
2910
+ memberImage: D
2554
2911
  }];
2555
- u.push(w);
2556
- } catch (e) {
2557
- console.warn(`Failed to parse formula: ${a[1]}`, e);
2912
+ m.push(O);
2913
+ } catch (t) {
2914
+ e.log(`Could not write the formula '${o[1]}' over '${o[0]}'; those cells are written as values only. ${t}`);
2558
2915
  continue;
2559
2916
  }
2560
2917
  }
2561
- R.push(u);
2562
- } else R.push([]);
2563
- let ae = a.volatile, oe = ae ? ae.length : 0;
2918
+ N.push(m);
2919
+ } else N.push([]);
2920
+ let I = o.volatile, oe = I ? I.length : 0;
2564
2921
  if (oe > 0) {
2565
2922
  let e = Array(oe);
2566
2923
  for (let t = 0; t < oe; t++) {
2567
- let n = ae[t];
2924
+ let n = I[t];
2568
2925
  try {
2569
- e[t] = [i.getRange(n).getCoords(), !0];
2926
+ e[t] = [a.getRange(n).getCoords(), !0];
2570
2927
  } catch (e) {
2571
2928
  console.warn(`Failed to parse volatile: ${n}`, e);
2572
2929
  continue;
2573
2930
  }
2574
2931
  }
2575
- R.push(e);
2576
- } else R.push([]);
2577
- let se = a.formulaArray, V = se ? se.length : 0;
2578
- if (V > 0) {
2579
- let e = Array(V);
2580
- for (let t = 0; t < V; t++) {
2581
- let n = se[t];
2932
+ N.push(e);
2933
+ } else N.push([]);
2934
+ let L = o.formulaArray, R = L ? L.length : 0;
2935
+ if (R > 0) {
2936
+ let e = Array(R);
2937
+ for (let t = 0; t < R; t++) {
2938
+ let n = L[t];
2582
2939
  try {
2583
2940
  let r = n[0];
2584
- e[t] = [i.getRange(r).getCoords(), {
2941
+ e[t] = [a.getRange(r).getCoords(), {
2585
2942
  ref: r,
2586
2943
  kind: n[1] ?? "dynamic"
2587
2944
  }];
@@ -2590,89 +2947,95 @@ var vn = (e, t, n, r) => {
2590
2947
  continue;
2591
2948
  }
2592
2949
  }
2593
- R.push(e);
2594
- } else R.push([]);
2595
- i.getEntireRange().forEach((e, t) => {
2596
- let i = t.getCoords(), a = i.rowIndex, o = i.colIndex;
2597
- M !== a && re(a);
2598
- let s = t.getInjectedReference(0);
2599
- if (s === void 0 && j !== void 0 && a >= k && a <= A && (s = j), s === void 0) {
2600
- for (; o <= te && o > I;) N++, P = w?.[N] ?? null, F = P?.min ?? 2 ** 53 - 1, I = P?.max ?? 2 ** 53 - 1, L = P?.value?.s;
2601
- L !== void 0 && o >= F && o <= I && (s = L);
2950
+ N.push(e);
2951
+ } else N.push([]);
2952
+ a.getEntireRange().forEach((t, a) => {
2953
+ let o = a.getCoords(), s = o.rowIndex, l = o.colIndex;
2954
+ k !== s && re(s);
2955
+ let u = a.getInjectedReference(0);
2956
+ if (u === void 0 && ee !== void 0 && s >= D && s <= O && (u = ee), u === void 0) {
2957
+ for (; l <= C && l > M;) A++, j = x?.[A] ?? null, te = j?.min ?? 2 ** 53 - 1, M = j?.max ?? 2 ** 53 - 1, ne = j?.value?.s;
2958
+ ne !== void 0 && l >= te && l <= M && (u = ne);
2602
2959
  }
2603
- let d = t.getType(), f = null;
2604
- ie > 0 && (f = t.getInjectedReference(1) ?? null);
2605
- let g = !1;
2606
- oe > 0 && (g = t.getInjectedReference(2) ?? !1);
2607
- let _ = null;
2608
- V > 0 && (_ = t.getInjectedReference(3) ?? null);
2609
- let v = _?.kind === "dynamicSpillError", y = _?.kind === "static", x = It;
2610
- x.r = t.getAddress(), x.s = void 0, x.t = void 0, x.cm = void 0, x.vm = void 0, s !== void 0 && s !== 0 && (x.s = "" + s);
2611
- let S = null, C = null;
2612
- switch (d) {
2613
- case z.Boolean:
2614
- S = e ? "1" : "0", C = "b";
2960
+ let g = a.getType(), _ = null;
2961
+ ae > 0 && (_ = a.getInjectedReference(1) ?? null);
2962
+ let v = !1;
2963
+ oe > 0 && (v = a.getInjectedReference(2) ?? !1);
2964
+ let y = null;
2965
+ R > 0 && (y = a.getInjectedReference(3) ?? null);
2966
+ let b = y?.kind === "error", S = y?.kind === "fixed", w = _n;
2967
+ w.r = a.getAddress(), w.s = void 0, w.t = void 0, w.cm = void 0, w.vm = void 0, c && (u = c.getHiddenXf(u ?? 0)), u !== void 0 && u !== 0 && (w.s = "" + u);
2968
+ let T = null, E = null;
2969
+ switch (g) {
2970
+ case me.Boolean:
2971
+ T = t ? "1" : "0", E = "b";
2615
2972
  break;
2616
- case z.Error:
2617
- let t = e.getCode();
2618
- if (C = "e", t > 7) S = ne.BuiltIn.Value.getLabel(), x.vm = "" + u.add(e);
2619
- else if (t < 1) {
2620
- let t;
2621
- C = "s", f ? (t = "=" + f.formula, f = null) : t = "" + e.getLabel(), S = "" + c.add(t), p++;
2622
- } else S = "" + e.getLabel();
2973
+ case me.Error:
2974
+ let e = t.getCode();
2975
+ if (E = "e", e > 7) T = se.BuiltIn.Value.getLabel(), w.vm = "" + p.add(t);
2976
+ else if (e < 1) {
2977
+ let e;
2978
+ E = "s", _ ? (e = "=" + _.formula, _ = null) : e = "" + t.getLabel(), T = "" + d.add(e), m++;
2979
+ } else T = "" + t.getLabel();
2623
2980
  break;
2624
- case z.Number:
2625
- S = "" + e, C = null;
2981
+ case me.Number:
2982
+ T = "" + t, E = null;
2626
2983
  break;
2627
- case z.String:
2628
- S = e, f ? (C = "str", S = e) : (C = "s", S = "" + c.add(S), p++);
2984
+ case me.String:
2985
+ T = t, _ ? (E = "str", T = t) : (E = "s", T = "" + d.add(T), m++);
2629
2986
  break;
2630
- case z.RichData: C = "e", S = ne.BuiltIn.Value.getLabel(), x.vm = "" + u.add(e);
2987
+ case me.RichData: E = "e", T = se.BuiltIn.Value.getLabel(), w.vm = "" + p.add(t);
2631
2988
  }
2632
- C && (x.t = C);
2633
- let T = !f?.isWrapped && (_ !== null || (f?.isDynamicRange ?? !1));
2634
- if (f !== null || S !== null) {
2635
- if (T && f !== null && !y && (x.cm = "" + l.registerArrayCell(v)), r.start("c", x), f) {
2636
- let e = f.memberTexts?.[a - f.coords.rowStart]?.[o - f.coords.colStart] ?? f.formula, t, n = null, i = f.sharedId;
2637
- if (i) {
2638
- t = zt;
2639
- let e = f.coords;
2640
- e.colStart === o && e.rowStart === a ? (t.ref = f.ref, t.si = i, n = f.formula) : (t.ref = void 0, t.si = i);
2641
- } else T ? (t = Bt, t.aca = v ? "1" : void 0, t.ref = v ? x.r : _?.ref ?? x.r, n = e) : (t = Rt, n = e);
2642
- t.ca = g || v || f.isExcelVolatile ? "1" : void 0, n ? (r.start("f", t), r.text(n), r.end("f")) : r.empty("f", t);
2989
+ E && (w.t = E);
2990
+ let N = !_?.isWrapped && (y !== null || (_?.isDynamicRange ?? !1));
2991
+ if (_ !== null || T !== null) {
2992
+ if (N && _ !== null && !S && (w.cm = "" + f.registerArrayCell(b)), i.start("c", w), _) {
2993
+ let e = s === _.coords.rowStart && l === _.coords.colStart, t = _.formula;
2994
+ _.memberImage && !e && (t = _.memberImage({
2995
+ rowIndex: s,
2996
+ colIndex: l
2997
+ }));
2998
+ let n, r = null, a = _.sharedId;
2999
+ if (a) {
3000
+ n = bn;
3001
+ let e = _.coords;
3002
+ e.colStart === l && e.rowStart === s ? (n.ref = _.ref, n.si = a, r = _.formula) : (n.ref = void 0, n.si = a);
3003
+ } else N ? (n = xn, n.aca = b ? "1" : void 0, n.ref = b ? w.r : y?.ref ?? w.r, r = t) : (n = yn, r = t);
3004
+ n.ca = v || b || _.isExcelVolatile ? "1" : void 0, r ? (i.start("f", n), i.text(r), i.end("f")) : i.empty("f", n);
2643
3005
  }
2644
- S !== null && (C === "str" && S ? (r.start("v", ee.test(S) ? b : void 0), r.text(h(S))) : (r.start("v"), S && r.text(S)), r.end("v")), r.end("c");
2645
- } else m++ < Tt ? r.empty("c", x) : m === 1048577 && n.warn(`Reached ${Tt} style-only cells at '${x.r}'; not writing the rest.`);
3006
+ T !== null && (E === "str" && T ? (i.start("v", ie.test(T) ? n : void 0), i.text(r(T))) : (i.start("v"), T && i.text(T)), i.end("v")), i.end("c");
3007
+ } else h++ < Xt ? i.empty("c", w) : h === 1048577 && e.warn(`Reached ${Xt} style-only cells at '${w.r}'; not writing the rest.`);
2646
3008
  }, {
2647
- injectReferences: R,
3009
+ injectReferences: N,
2648
3010
  features: []
2649
- }), M !== -1 && M >= S ? r.end("row") : re(S, !0), r.end("sheetData"), r.setValidationDisabled(!1);
2650
- } else r.empty("sheetData");
2651
- if (p > 0) {
2652
- let e = s.get("stringsCount") ?? 0;
2653
- s.set("stringsCount", e + p);
3011
+ }), k !== -1 && k >= b ? i.end("row") : re(b, !0), i.end("sheetData"), i.setValidationDisabled(!1);
3012
+ } else i.empty("sheetData");
3013
+ if (m > 0) {
3014
+ let e = u.get("stringsCount") ?? 0;
3015
+ u.set("stringsCount", e + m);
2654
3016
  }
2655
- }(i, s, c, l, await (async (e, t) => {
3017
+ }(a, s, c, d, await (async (e, t) => {
2656
3018
  let n = t ? t.length : 0;
2657
- if (n === 0) return wt;
3019
+ if (n === 0) return Yt;
2658
3020
  let r = /* @__PURE__ */ new Set(), i = Array(n);
2659
- for (let a = 0; a < n; a++) {
2660
- i[a] = null;
3021
+ for (let e = 0; e < n; e++) {
3022
+ i[e] = null;
2661
3023
  try {
2662
- let n = e.getRange(t[a][0]).getCell().getFormula()?.getTokens();
3024
+ let n = ce.parse(t[e][1]);
2663
3025
  if (!n) continue;
2664
- let o = null;
2665
- for (let e = 0; e < n.length; e++) {
2666
- let t = n[e], i = null;
2667
- t.type === "function" ? i = String(t.value) : t.type === "named" && n[e + 1]?.type === "paren" && n[e + 1].value === "(" && (i = String(t.value?.name ?? "")), i && (i = i.toUpperCase(), r.add(i), (o ??= /* @__PURE__ */ new Set()).add(i));
2668
- }
2669
- i[a] = o;
3026
+ let a = null, o = (e) => {
3027
+ let t = null;
3028
+ e.type === "function" ? t = String(e.value) : e.type === "call" && e.inputs?.[0]?.type === "named" && (t = String(e.inputs[0].value?.name ?? "")), t && (t = t.toUpperCase(), r.add(t), (a ??= /* @__PURE__ */ new Set()).add(t));
3029
+ let n = e.inputs;
3030
+ if (n) for (let e = 0; e < n.length; e++) n[e] && o(n[e]);
3031
+ };
3032
+ o(n), i[e] = a;
2670
3033
  } catch {}
2671
3034
  }
2672
3035
  let a = e.getWorkbook();
2673
- if (!a) return wt;
2674
- let o = await _(a, r);
2675
- return o.size === 0 ? wt : {
3036
+ if (!a) return Yt;
3037
+ let o = await D(a, r);
3038
+ return o.size === 0 ? Yt : {
2676
3039
  names: o,
2677
3040
  perFormula: i,
2678
3041
  affects: (e) => {
@@ -2682,136 +3045,141 @@ var vn = (e, t, n, r) => {
2682
3045
  return !1;
2683
3046
  }
2684
3047
  };
2685
- })(c, l.formulas)), function(e, t, n, r) {
3048
+ })(c, d.formulas), f), function(e, t, n, r) {
2686
3049
  let i = r.protection;
2687
3050
  if (!i) return;
2688
3051
  let a = {};
2689
- Pe(i.password ?? {}, a), a.sheet = "1";
2690
- let o = (e, t, n) => {
2691
- let r = i[e];
2692
- r !== void 0 && r !== t && (a[n ?? e] = r ? "1" : "0");
2693
- };
2694
- o("objects", "0"), o("scenarios", "0"), o("formatCells", "0"), o("formatColumns", "0"), o("formatRows", "0"), o("insertColumns", "0"), o("insertRows", "0"), o("insertHyperlinks", "0"), o("deleteColumns", "0"), o("deleteRows", "0"), o("selectLockedCells", "1"), o("sort", "0"), o("autoTable", "0", "autoFilter"), o("pivotTables", "0"), o("selectUnlockedCells", "1"), t.empty("sheetProtection", a);
2695
- }(0, s, 0, l), function(e, t, n, r) {
3052
+ i.sheet || Ue(i.password ?? {}, a);
3053
+ for (let e of N) {
3054
+ let t = u(e, i[e.key]);
3055
+ t !== null && (a[e.attribute] = t);
3056
+ }
3057
+ t.empty("sheetProtection", a);
3058
+ }(0, s, 0, d), function(e, t, n, r) {
2696
3059
  let i = r.protectedRanges, a = i ? i.length : 0;
2697
3060
  if (a === 0) return;
2698
3061
  let o = [];
2699
3062
  for (let t = 0; t < a; t++) {
2700
3063
  let n = i[t], r, a;
2701
3064
  Array.isArray(n) ? (r = n[0], a = n[1]) : (r = n.r, a = n.v);
2702
- let s = Nt(r);
3065
+ let s = an(r);
2703
3066
  if (!s || !a) {
2704
- e.warn("Skipping protectedRange with no range.");
3067
+ e.log("Skipping protectedRange with no range.");
2705
3068
  continue;
2706
3069
  }
2707
3070
  if (!a.name) {
2708
- e.warn("Skipping protectedRange with no name.");
3071
+ e.log("Skipping protectedRange with no name.");
2709
3072
  continue;
2710
3073
  }
2711
3074
  let c = {};
2712
- Pe(a.password ?? {}, c), c.sqref = s, c.name = a.name, a.securityDescriptor && (c.securityDescriptor = a.securityDescriptor), o.push(c);
3075
+ Ue(a.password ?? {}, c), c.sqref = s, c.name = a.name, a.securityDescriptor && (c.securityDescriptor = a.securityDescriptor), o.push(c);
2713
3076
  }
2714
3077
  if (o.length !== 0) {
2715
3078
  t.start("protectedRanges");
2716
3079
  for (let e = 0; e < o.length; e++) t.empty("protectedRange", o[e]);
2717
3080
  t.end("protectedRanges");
2718
3081
  }
2719
- }(i, s, 0, l);
2720
- let u = l.autoTable;
2721
- if (u) {
2722
- let e, t = u;
2723
- e = Array.isArray(t) ? t[1] : t.v, _t(i, s, c.getAutoTable(), e, !0);
3082
+ }(a, s, 0, d);
3083
+ let p = d.autoTable;
3084
+ if (p) {
3085
+ let e, t = p;
3086
+ e = Array.isArray(t) ? t[1] : t.v, Gt(a, s, c.getAutoTable(), e, !0);
2724
3087
  }
2725
3088
  (function(e, t, n, r) {
2726
3089
  let i = r.merges ? r.merges.length : 0;
2727
3090
  if (i > 0) {
2728
3091
  t.start("mergeCells", { count: i });
2729
3092
  for (let e = 0; e < i; e++) {
2730
- let n = r.merges[e], i = typeof n == "string" ? n : T.rangeToString(n);
3093
+ let n = r.merges[e], i = typeof n == "string" ? n : P.rangeToString(n);
2731
3094
  t.empty("mergeCell", { ref: i });
2732
3095
  }
2733
3096
  t.end("mergeCells");
2734
3097
  }
2735
- })(0, s, 0, l);
2736
- let p = function(e, t, n, r) {
2737
- let i = [], o = r.conditionals, s = o ? o.length : 0;
3098
+ })(0, s, 0, d);
3099
+ let m = function(e, t, n, r) {
3100
+ let i = [], a = r.conditionals, s = a ? a.length : 0;
2738
3101
  if (s === 0) return i;
2739
- let c = e.getSharedStates(), l = c.get(it);
2740
- l || (l = new rt(), c.set(it, l));
2741
- let u = n.getStyles().getTheme(), d = null, f = 0;
3102
+ let c = e.getSharedStates(), l = c.get(jt);
3103
+ l || (l = new At(), c.set(jt, l));
3104
+ let u = n.getStyles().getTheme(), d = c.get(o), f = null, p = 0;
2742
3105
  for (let n = 0; n < s; n++) {
2743
- let r = o[n], s, c;
2744
- Array.isArray(r) ? (s = r[0], c = r[1]) : (s = r.r, c = r.v);
2745
- let p = Nt(s);
2746
- if (!p || !c) {
2747
- e.warn("Skipping conditionalFormatting with no range.");
3106
+ let r = a[n], o, s;
3107
+ Array.isArray(r) ? (o = r[0], s = r[1]) : (o = r.r, s = r.v);
3108
+ let c = an(o);
3109
+ if (!c || !s) {
3110
+ e.log("Skipping conditionalFormatting with no range.");
2748
3111
  continue;
2749
3112
  }
2750
- let m = c.scale, h = m ? { type: m.type } : S(c.condition, Mt(p), (t) => e.warn(t));
2751
- h ? m?.type === j.ScaleType.IconSet && At(m) ? (f++, i.push({
2752
- guid: a(D.uuidV4),
2753
- sqref: p,
2754
- priority: f,
2755
- scale: m
2756
- })) : m || !Ft(h) ? (p !== d && (d !== null && t.end("conditionalFormatting"), t.start("conditionalFormatting", {
2757
- sqref: p,
2758
- pivot: c.pivot ? "1" : void 0
2759
- }), d = p), f++, jt(e, t, u, c, h, p, f, l, i)) : (f++, i.push({
2760
- guid: a(D.uuidV4),
2761
- sqref: p,
2762
- priority: f,
2763
- rule: h,
2764
- style: c.style,
2765
- stopIfTrue: c.stopIfTrue
2766
- })) : c.condition || e.warn("Skipping conditional format with neither a condition nor a scale.");
3113
+ let m = cn(c), h = un(s.scale, m, d);
3114
+ h !== s.scale && (s = {
3115
+ ...s,
3116
+ scale: h
3117
+ });
3118
+ let _ = h ? { type: h.type } : g(s.condition, rn(c), (t, n) => e.warn(t, void 0, n));
3119
+ _ ? (_.formulas &&= _.formulas.map((e) => ln(e, m, d)), h?.type === z.ScaleType.IconSet && tn(h) ? (p++, i.push({
3120
+ guid: x(I.uuidV4),
3121
+ sqref: c,
3122
+ priority: p,
3123
+ scale: h
3124
+ })) : h || !sn(_) ? (c !== f && (f !== null && t.end("conditionalFormatting"), t.start("conditionalFormatting", {
3125
+ sqref: c,
3126
+ pivot: s.pivot ? "1" : void 0
3127
+ }), f = c), p++, nn(e, t, u, s, _, c, p, l, i)) : (p++, i.push({
3128
+ guid: x(I.uuidV4),
3129
+ sqref: c,
3130
+ priority: p,
3131
+ rule: _,
3132
+ style: s.style,
3133
+ stopIfTrue: s.stopIfTrue
3134
+ }))) : s.condition || e.log("Skipping conditional format with neither a condition nor a scale.");
2767
3135
  }
2768
- return d !== null && t.end("conditionalFormatting"), i;
2769
- }(i, s, c, l), m = function(e, t, n, r) {
2770
- let i = [], a = r.validations, o = a ? a.length : 0;
2771
- if (o === 0) return i;
2772
- let s = [];
2773
- for (let t = 0; t < o; t++) {
2774
- let n = a[t], r, o;
3136
+ return f !== null && t.end("conditionalFormatting"), i;
3137
+ }(a, s, c, d), h = function(e, t, n, r) {
3138
+ let i = [], a = e.getSharedStates().get(o), s = r.validations, c = s ? s.length : 0;
3139
+ if (c === 0) return i;
3140
+ let l = [];
3141
+ for (let t = 0; t < c; t++) {
3142
+ let n = s[t], r, o;
2775
3143
  Array.isArray(n) ? (r = n[0], o = n[1]) : (r = n.r, o = n.v);
2776
- let c = Nt(r);
3144
+ let c = an(r);
2777
3145
  if (!c || !o) {
2778
- e.warn?.("Skipping dataValidation with no range.");
3146
+ e.log("Skipping dataValidation with no range.");
2779
3147
  continue;
2780
3148
  }
2781
3149
  o.ext && e.warn("DataValidation extension payload is not written to xlsx; it will be lost.");
2782
- let { type: l, operator: u, formula1: d, formula2: f } = x(o.condition, (t) => e.warn(t)) ?? {}, p = {
2783
- type: l,
2784
- operator: u,
2785
- allowBlank: Z(o.condition?.includeBlanks ?? !1),
3150
+ let u = (t, n) => e.warn(t, void 0, n), d = S(o.condition, u), { type: f, operator: p } = d ?? {}, m = cn(c), h = ln(d?.formula1, m, a), g = ln(d?.formula2, m, a), _ = {
3151
+ type: f,
3152
+ operator: p,
3153
+ allowBlank: Q(o.condition?.includeBlanks ?? !1),
2786
3154
  showDropDown: o.hideDropdown ? "1" : void 0,
2787
- showInputMessage: Z(o.showPromptMessage),
2788
- showErrorMessage: Z(o.showAlertMessage),
2789
- errorStyle: o.alertStyle ?? "information",
2790
- errorTitle: o.alertTitle,
2791
- error: o.alert,
2792
- promptTitle: o.promptTitle,
2793
- prompt: o.prompt,
3155
+ showInputMessage: Q(o.showPromptMessage),
3156
+ showErrorMessage: Q(o.showAlertMessage),
3157
+ errorStyle: o.alertStyle ?? "stop",
3158
+ errorTitle: re(o.alertTitle, "errorTitle", u),
3159
+ error: re(o.alert, "error", u),
3160
+ promptTitle: re(o.promptTitle, "promptTitle", u),
3161
+ prompt: re(o.prompt, "prompt", u),
2794
3162
  imeMode: o.imeMode
2795
3163
  };
2796
- Pt(d) || Pt(f) ? i.push({
2797
- attrs: p,
2798
- formula1: d,
2799
- formula2: f,
3164
+ on(h) || on(g) ? i.push({
3165
+ attrs: _,
3166
+ formula1: h,
3167
+ formula2: g,
2800
3168
  sqref: c
2801
- }) : (p.sqref = c, s.push({
2802
- attrs: p,
2803
- formula1: d,
2804
- formula2: f
3169
+ }) : (_.sqref = c, l.push({
3170
+ attrs: _,
3171
+ formula1: h,
3172
+ formula2: g
2805
3173
  }));
2806
3174
  }
2807
- if (s.length === 0) return i;
2808
- t.start("dataValidations", { count: s.length });
2809
- for (let e = 0; e < s.length; e++) {
2810
- let { attrs: n, formula1: r, formula2: i } = s[e];
3175
+ if (l.length === 0) return i;
3176
+ t.start("dataValidations", { count: l.length });
3177
+ for (let e = 0; e < l.length; e++) {
3178
+ let { attrs: n, formula1: r, formula2: i } = l[e];
2811
3179
  r !== void 0 || i !== void 0 ? (t.start("dataValidation", n), r !== void 0 && (t.start("formula1"), t.text(r), t.end("formula1")), i !== void 0 && (t.start("formula2"), t.text(i), t.end("formula2")), t.end("dataValidation")) : t.empty("dataValidation", n);
2812
3180
  }
2813
3181
  return t.end("dataValidations"), i;
2814
- }(i, s, 0, l);
3182
+ }(a, s, 0, d);
2815
3183
  (function(e, t, n, r) {
2816
3184
  let i = r.hyperlinks, a = i ? i.length : 0;
2817
3185
  if (a !== 0) {
@@ -2824,7 +3192,7 @@ var vn = (e, t, n, r) => {
2824
3192
  }
2825
3193
  t.end("hyperlinks");
2826
3194
  }
2827
- })(i, s, 0, l), function(e, t, n, r) {
3195
+ })(a, s, 0, d), function(e, t, n, r) {
2828
3196
  let i = r.pageMargins;
2829
3197
  t.empty("pageMargins", {
2830
3198
  left: i?.left ?? .7,
@@ -2834,8 +3202,8 @@ var vn = (e, t, n, r) => {
2834
3202
  header: i?.header ?? .3,
2835
3203
  footer: i?.footer ?? .3
2836
3204
  });
2837
- }(0, s, 0, l), function(e, t, n, r) {
2838
- let i = r.movables;
3205
+ }(0, s, 0, d), function(e, t, n, r) {
3206
+ let i = r.movables?.filter(pn);
2839
3207
  if ((i ? i.length : 0) === 0 || !i.some((e) => {
2840
3208
  let t = e.content?.type;
2841
3209
  if (t === "picture" || t === "chart") return !0;
@@ -2845,14 +3213,93 @@ var vn = (e, t, n, r) => {
2845
3213
  }
2846
3214
  return !1;
2847
3215
  })) return;
2848
- let a = n.getMovables().getItems(), o = e.addPart("drawing", {
3216
+ let a = n.getMovables().getItems().filter((e, t) => pn(r.movables[t])), o = e.addPart("drawing", {
2849
3217
  sheet: n,
2850
3218
  movables: a,
2851
3219
  jsonMovables: i,
2852
3220
  resources: n.getResources()
2853
3221
  });
2854
3222
  t.empty("drawing", { "r:id": o.relId });
2855
- }(i, s, c, l), function(e, t, n, r) {
3223
+ }(a, s, c, d);
3224
+ let _ = function(e) {
3225
+ let t = e.getComments().toArray();
3226
+ if (t.length === 0) return null;
3227
+ let n = [];
3228
+ for (let e = 0; e < t.length; e++) {
3229
+ let r = t[e], i = yt(r);
3230
+ i && n.push({
3231
+ comment: r,
3232
+ ...i
3233
+ });
3234
+ }
3235
+ return n.length === 0 ? null : (n.sort((e, t) => e.row - t.row || e.col - t.col), {
3236
+ sheet: e,
3237
+ comments: n
3238
+ });
3239
+ }(c);
3240
+ dn(a, s, "legacyDrawing", fn(hn(d.legacyDrawing ?? null, d), _)), dn(a, s, "legacyDrawingHF", d.legacyDrawingHF ?? null), await async function(e, t, n) {
3241
+ let r = n.getPicture();
3242
+ if (!r) return;
3243
+ let i = r.getResource(), a = await i.getExternalURI(), o;
3244
+ if (a) o = e.addExternal(Et, a);
3245
+ else {
3246
+ let t = e.getSharedStates(), n = t.get(Dt);
3247
+ n || (n = /* @__PURE__ */ new Map(), t.set(Dt, n));
3248
+ let r = n.get(i);
3249
+ if (!r) {
3250
+ let e = await i.toBuffer();
3251
+ r = {
3252
+ bytes: new Uint8Array(e),
3253
+ type: await i.getType() ?? Ot,
3254
+ index: n.size + 1
3255
+ }, n.set(i, r);
3256
+ }
3257
+ o = e.addBinary(r.bytes, r.type.mime, Et, `../media/image${r.index}.${r.type.ext}`, !0);
3258
+ }
3259
+ t.empty("picture", { "r:id": o.relId });
3260
+ }(a, s, c), await async function(e, t, n) {
3261
+ let r = n.movables;
3262
+ if (!r || r.every(pn)) return;
3263
+ let i = [], a = r.length;
3264
+ for (let t = 0; t < a; t++) {
3265
+ let n = r[t];
3266
+ if (pn(n)) continue;
3267
+ let a = n.content?.json ?? {}, o = a.part, s;
3268
+ if (o) try {
3269
+ s = (await Ze(o.type ? o : {
3270
+ ...o,
3271
+ type: mn
3272
+ }, e, "../ctrlProps/ctrlProp{n}.xml"))?.relId ?? void 0;
3273
+ } catch (t) {
3274
+ e.log(`Unable to write the properties of the control '${n.name}'`, t);
3275
+ }
3276
+ s ? i.push({
3277
+ jsonMovable: n,
3278
+ jsonControl: a,
3279
+ relId: s
3280
+ }) : e.log(`The control '${n.name}' has no properties to write and was dropped.`);
3281
+ }
3282
+ if (i.length === 0) return;
3283
+ t.start("mc:AlternateContent", {
3284
+ "xmlns:x14": T,
3285
+ "xmlns:xdr": "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
3286
+ }), t.start("mc:Choice", { Requires: "x14" }), t.start("controls");
3287
+ let o = i.length;
3288
+ for (let e = 0; e < o; e++) {
3289
+ let { jsonMovable: n, jsonControl: r, relId: a } = i[e];
3290
+ t.start("mc:AlternateContent"), t.start("mc:Choice", { Requires: "x14" }), t.start("control", {
3291
+ shapeId: r.shapeId,
3292
+ "r:id": a,
3293
+ name: n.name ?? void 0
3294
+ });
3295
+ let o = n.anchorType ?? "twoCell";
3296
+ t.start("controlPr", r.props), t.start("anchor", {
3297
+ moveWithCells: o === "absolute" ? void 0 : "1",
3298
+ sizeWithCells: o === "twoCell" ? "1" : void 0
3299
+ }), gn(t, "from", n.anchor.tl), gn(t, "to", n.anchor.br), t.end("anchor"), r.xml && t.raw(r.xml), t.end("controlPr"), t.end("control"), t.end("mc:Choice"), t.end("mc:AlternateContent");
3300
+ }
3301
+ t.end("controls"), t.end("mc:Choice"), t.end("mc:AlternateContent");
3302
+ }(a, s, d), function(e, t, n, r) {
2856
3303
  let i = r.tables, a = i ? i.length : 0;
2857
3304
  if (a === 0) return;
2858
3305
  let o = n.getTables().getItems();
@@ -2868,97 +3315,105 @@ var vn = (e, t, n, r) => {
2868
3315
  l["r:id"] = c.relId, t.empty("tablePart", l);
2869
3316
  }
2870
3317
  t.end("tableParts");
2871
- }(i, s, c, l), function(e, t, n, i, a) {
3318
+ }(a, s, c, d), function(t, n, r, i, a) {
2872
3319
  if (i.length === 0 && a.length === 0) return;
2873
- let s = n.getStyles(), c = s.getTheme();
2874
- if (t.start("extLst"), i.length > 0) {
2875
- t.start("ext", {
2876
- uri: o,
2877
- "xmlns:x14": r
2878
- }), t.start("x14:conditionalFormattings");
3320
+ let o = r.getStyles(), s = o.getTheme();
3321
+ if (n.start("extLst"), i.length > 0) {
3322
+ n.start("ext", {
3323
+ uri: e,
3324
+ "xmlns:x14": T
3325
+ }), n.start("x14:conditionalFormattings");
2879
3326
  for (let e = 0; e < i.length; e++) {
2880
- let { guid: n, sqref: r, priority: a, scale: o, rule: l, style: u, stopIfTrue: f } = i[e];
2881
- if (t.start("x14:conditionalFormatting", { "xmlns:xm": d }), o) if (o.type === j.ScaleType.DataBar) {
2882
- t.start("x14:cfRule", {
3327
+ let { guid: t, sqref: r, priority: a, scale: c, rule: l, style: u, stopIfTrue: d } = i[e];
3328
+ if (n.start("x14:conditionalFormatting", { "xmlns:xm": v }), c) if (c.type === z.ScaleType.DataBar) {
3329
+ n.start("x14:cfRule", {
2883
3330
  type: "dataBar",
2884
- id: n
2885
- }), t.start("x14:dataBar", {
2886
- minLength: o.minLength,
2887
- maxLength: o.maxLength,
2888
- gradient: o.gradient ? void 0 : "0",
2889
- border: o.borderColor ? "1" : void 0,
2890
- direction: o.direction,
2891
- negativeBarColorSameAsPositive: o.negativeFillColor ? "0" : "1",
2892
- negativeBarBorderColorSameAsPositive: o.negativeBorderColor ? "0" : void 0,
2893
- axisPosition: o.axisPosition
3331
+ id: t
3332
+ }), n.start("x14:dataBar", {
3333
+ minLength: c.minLength,
3334
+ maxLength: c.maxLength,
3335
+ gradient: c.gradient ? void 0 : "0",
3336
+ border: c.borderColor ? "1" : void 0,
3337
+ direction: c.direction,
3338
+ negativeBarColorSameAsPositive: c.negativeFillColor ? "0" : "1",
3339
+ negativeBarBorderColorSameAsPositive: c.negativeBorderColor ? "0" : void 0,
3340
+ axisPosition: c.axisPosition
2894
3341
  });
2895
- let e = o.stops ?? [];
2896
- if (e.length === 0) Ot(t, { type: j.ColorStopType.AutoMin }), Ot(t, { type: j.ColorStopType.AutoMax });
2897
- else for (let n = 0; n < e.length; n++) Ot(t, e[n]);
2898
- o.borderColor && G(t, c, o.borderColor, "x14:borderColor"), o.negativeFillColor && G(t, c, o.negativeFillColor, "x14:negativeFillColor"), o.negativeBorderColor && G(t, c, o.negativeBorderColor, "x14:negativeBorderColor"), o.axisColor && G(t, c, o.axisColor, "x14:axisColor"), t.end("x14:dataBar"), t.end("x14:cfRule");
3342
+ let e = c.stops ?? [];
3343
+ if (e.length === 0) $t(n, { type: z.ColorStopType.AutoMin }), $t(n, { type: z.ColorStopType.AutoMax });
3344
+ else for (let t = 0; t < e.length; t++) $t(n, e[t]);
3345
+ c.borderColor && q(n, s, c.borderColor, "x14:borderColor"), c.negativeFillColor && q(n, s, c.negativeFillColor, "x14:negativeFillColor"), c.negativeBorderColor && q(n, s, c.negativeBorderColor, "x14:negativeBorderColor"), c.axisColor && q(n, s, c.axisColor, "x14:axisColor"), n.end("x14:dataBar"), n.end("x14:cfRule");
2899
3346
  } else {
2900
- t.start("x14:cfRule", {
3347
+ n.start("x14:cfRule", {
2901
3348
  type: "iconSet",
2902
3349
  priority: a,
2903
- id: n
2904
- }), t.start("x14:iconSet", {
2905
- iconSet: o.iconSet,
2906
- reverse: Z(o.reverse),
2907
- showValue: Z(o.showValue),
2908
- custom: (o.icon?.length ?? 0) > 0 ? "1" : void 0
3350
+ id: t
3351
+ }), n.start("x14:iconSet", {
3352
+ iconSet: c.iconSet,
3353
+ reverse: Q(c.reverse),
3354
+ showValue: Q(c.showValue),
3355
+ custom: (c.icon?.length ?? 0) > 0 ? "1" : void 0
2909
3356
  });
2910
- let e = o.stops ?? [];
2911
- for (let n = 0; n < e.length; n++) Ot(t, e[n]);
2912
- let r = o.icon ?? [];
2913
- for (let e = 0; e < r.length; e++) t.empty("x14:cfIcon", {
3357
+ let e = c.stops ?? [];
3358
+ for (let t = 0; t < e.length; t++) $t(n, e[t]);
3359
+ let r = c.icon ?? [];
3360
+ for (let e = 0; e < r.length; e++) n.empty("x14:cfIcon", {
2914
3361
  iconSet: r[e].set,
2915
3362
  iconId: r[e].id
2916
3363
  });
2917
- t.end("x14:iconSet"), t.end("x14:cfRule");
3364
+ n.end("x14:iconSet"), n.end("x14:cfRule");
2918
3365
  }
2919
3366
  else {
2920
- t.start("x14:cfRule", {
3367
+ n.start("x14:cfRule", {
2921
3368
  type: l.type,
2922
3369
  priority: a,
2923
- stopIfTrue: Z(f),
2924
- aboveAverage: Z(l.aboveAverage),
2925
- equalAverage: Z(l.equalAverage),
3370
+ stopIfTrue: Q(d),
3371
+ aboveAverage: Q(l.aboveAverage),
3372
+ equalAverage: Q(l.equalAverage),
2926
3373
  stdDev: l.stdDev,
2927
- bottom: Z(l.bottom),
2928
- percent: Z(l.percent),
3374
+ bottom: Q(l.bottom),
3375
+ percent: Q(l.percent),
2929
3376
  rank: l.rank,
2930
3377
  operator: l.operator,
2931
3378
  text: l.text,
2932
3379
  timePeriod: l.timePeriod,
2933
- id: n
3380
+ id: t
2934
3381
  });
2935
3382
  let e = l.formulas ?? [];
2936
- for (let n = 0; n < e.length; n++) t.start("xm:f"), t.text(e[n]), t.end("xm:f");
2937
- u && Object.keys(u).length > 0 && ft(0, t, u, s, c, "x14:dxf"), t.end("x14:cfRule");
3383
+ for (let t = 0; t < e.length; t++) n.start("xm:f"), n.text(e[t]), n.end("xm:f");
3384
+ u && Object.keys(u).length > 0 && Bt(0, n, u, o, s, "x14:dxf"), n.end("x14:cfRule");
2938
3385
  }
2939
- t.start("xm:sqref"), t.text(r), t.end("xm:sqref"), t.end("x14:conditionalFormatting");
3386
+ n.start("xm:sqref"), n.text(r), n.end("xm:sqref"), n.end("x14:conditionalFormatting");
2940
3387
  }
2941
- t.end("x14:conditionalFormattings"), t.end("ext");
3388
+ n.end("x14:conditionalFormattings"), n.end("ext");
2942
3389
  }
2943
3390
  if (a.length > 0) {
2944
- t.start("ext", {
2945
- uri: w,
2946
- "xmlns:x14": r
2947
- }), t.start("x14:dataValidations", {
2948
- "xmlns:xm": d,
3391
+ n.start("ext", {
3392
+ uri: ne,
3393
+ "xmlns:x14": T
3394
+ }), n.start("x14:dataValidations", {
3395
+ "xmlns:xm": v,
2949
3396
  count: a.length
2950
3397
  });
2951
3398
  for (let e = 0; e < a.length; e++) {
2952
- let { attrs: n, formula1: r, formula2: i, sqref: o } = a[e];
2953
- t.start("x14:dataValidation", n), r !== void 0 && (t.start("x14:formula1"), t.start("xm:f"), t.text(r), t.end("xm:f"), t.end("x14:formula1")), i !== void 0 && (t.start("x14:formula2"), t.start("xm:f"), t.text(i), t.end("xm:f"), t.end("x14:formula2")), t.start("xm:sqref"), t.text(o), t.end("xm:sqref"), t.end("x14:dataValidation");
3399
+ let { attrs: t, formula1: r, formula2: i, sqref: o } = a[e];
3400
+ n.start("x14:dataValidation", t), r !== void 0 && (n.start("x14:formula1"), n.start("xm:f"), n.text(r), n.end("xm:f"), n.end("x14:formula1")), i !== void 0 && (n.start("x14:formula2"), n.start("xm:f"), n.text(i), n.end("xm:f"), n.end("x14:formula2")), n.start("xm:sqref"), n.text(o), n.end("xm:sqref"), n.end("x14:dataValidation");
2954
3401
  }
2955
- t.end("x14:dataValidations"), t.end("ext");
3402
+ n.end("x14:dataValidations"), n.end("ext");
2956
3403
  }
2957
- t.end("extLst");
2958
- }(0, s, c, p, m), s.end("worksheet"), s.close();
3404
+ n.end("extLst");
3405
+ }(0, s, c, m, h), function(e, t) {
3406
+ let n = t.pivotTables, r = n ? n.length : 0;
3407
+ for (let t = 0; t < r; t++) {
3408
+ let r = n[t], i = r.part;
3409
+ i?.xml && (et(e, r.cacheId) ? e.addPart("pivotTable", r) : e.log(`The pivot table '${i.name ?? ""}' has no cache with id ${r.cacheId} and was dropped.`));
3410
+ }
3411
+ }(a, d), function(e, t) {
3412
+ t && (e.addPart("comments", t), t.comments.some((e) => !e.comment.isNote()) && e.addPart("threadedComments", t));
3413
+ }(a, _), s.end("worksheet"), s.close();
2959
3414
  }
2960
3415
  }(),
2961
- new class extends B {
3416
+ new class extends U {
2962
3417
  constructor() {
2963
3418
  super({
2964
3419
  kind: "sharedStrings",
@@ -2968,22 +3423,22 @@ var vn = (e, t, n, r) => {
2968
3423
  });
2969
3424
  }
2970
3425
  async emit(e, t) {
2971
- let n = t.getXMLWriter(), r = e.json, i = r ? r.length : 0, a = t.getSharedStates().get("stringsCount") ?? 0;
2972
- n.decl(), n.start("sst", {
3426
+ let i = t.getXMLWriter(), a = e.json, o = a ? a.length : 0, s = t.getSharedStates().get("stringsCount") ?? 0;
3427
+ i.decl(), i.start("sst", {
2973
3428
  xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
2974
- count: a,
2975
- uniqueCount: i
3429
+ count: s,
3430
+ uniqueCount: o
2976
3431
  });
2977
- for (let e = 0; e < i; e++) {
2978
- let t = r[e];
2979
- n.start("si");
2980
- let i = ee.test(t) ? b : void 0;
2981
- n.start("t", i), n.text(h(t)), n.end("t"), n.end("si");
3432
+ for (let e = 0; e < o; e++) {
3433
+ let t = a[e];
3434
+ i.start("si");
3435
+ let o = ie.test(t) ? n : void 0;
3436
+ i.start("t", o), i.text(r(t)), i.end("t"), i.end("si");
2982
3437
  }
2983
- n.end("sst"), n.close();
3438
+ i.end("sst"), i.close();
2984
3439
  }
2985
3440
  }(),
2986
- new class extends B {
3441
+ new class extends U {
2987
3442
  constructor() {
2988
3443
  super({
2989
3444
  kind: "theme",
@@ -3001,22 +3456,22 @@ var vn = (e, t, n, r) => {
3001
3456
  let i = n?.getColorScheme();
3002
3457
  if (i) {
3003
3458
  t.start(r, { name: i.getName() || "Office" });
3004
- for (let e of Ve) t.start(e), U(t, n, i["get" + e.charAt(0).toUpperCase() + e.slice(1)]()), t.end(e);
3459
+ for (let e of lt) t.start(e), G(t, n, i["get" + e.charAt(0).toUpperCase() + e.slice(1)]()), t.end(e);
3005
3460
  t.end(r);
3006
3461
  }
3007
3462
  }(0, n, r, "clrScheme"), function(e, t, n, r) {
3008
- n && (t.start(r, { name: n.getName() || "Office" }), Vt(e, t, n.getMajorFont() || "Calibri Light", "majorFont"), Vt(e, t, n.getMinorFont() || "Calibri", "minorFont"), t.end(r));
3463
+ n && (t.start(r, { name: n.getName() || "Office" }), Sn(e, t, n.getMajorFont() || "Calibri Light", "majorFont"), Sn(e, t, n.getMinorFont() || "Calibri", "minorFont"), t.end(r));
3009
3464
  }(t, n, r.getFontScheme(), "fontScheme"), function(e, t, n, r, i) {
3010
3465
  if (i?.fillStyleLst && i?.lnStyleLst && i?.effectStyleLst && i?.bgFillStyleLst) return void function(e, t, n, r, i) {
3011
3466
  let a = { getTheme: () => r };
3012
3467
  t.start(n, { name: "Office" }), t.start("fillStyleLst");
3013
- for (let e of i.fillStyleLst) K(0, t, e, a);
3468
+ for (let e of i.fillStyleLst) J(0, t, e, a);
3014
3469
  t.end("fillStyleLst"), t.start("lnStyleLst");
3015
- for (let e of i.lnStyleLst) Je(0, t, e, a);
3470
+ for (let e of i.lnStyleLst) bt(0, t, e, a);
3016
3471
  t.end("lnStyleLst"), t.start("effectStyleLst");
3017
- for (let n of i.effectStyleLst) t.start("effectStyle"), n.length > 0 ? Ze(e, t, r, n) : t.empty("effectLst"), t.end("effectStyle");
3472
+ for (let n of i.effectStyleLst) t.start("effectStyle"), n.length > 0 ? Ct(e, t, r, n) : t.empty("effectLst"), t.end("effectStyle");
3018
3473
  t.end("effectStyleLst"), t.start("bgFillStyleLst");
3019
- for (let e of i.bgFillStyleLst) K(0, t, e, a);
3474
+ for (let e of i.bgFillStyleLst) J(0, t, e, a);
3020
3475
  t.end("bgFillStyleLst"), t.end(n);
3021
3476
  }(e, t, n, r, i);
3022
3477
  if (i?.formatSchemeXml) return void t.raw(i.formatSchemeXml);
@@ -3067,7 +3522,7 @@ var vn = (e, t, n, r) => {
3067
3522
  }(t, n, "fmtScheme", r, i), n.end("themeElements"), n.start("objectDefaults"), n.end("objectDefaults"), n.start("extraClrSchemeLst"), n.end("extraClrSchemeLst"), n.end("theme"), n.close();
3068
3523
  }
3069
3524
  }(),
3070
- new class extends B {
3525
+ new class extends U {
3071
3526
  constructor() {
3072
3527
  super({
3073
3528
  kind: "styles",
@@ -3093,11 +3548,11 @@ var vn = (e, t, n, r) => {
3093
3548
  for (let t = 0; t < r; t++) {
3094
3549
  let r = t === 0 ? {
3095
3550
  ...n[t],
3096
- named: I.BuiltInName.Normal
3551
+ named: V.BuiltInName.Normal
3097
3552
  } : n[t], a = e.resolve(r), o = {};
3098
- r.named !== void 0 && (o.named = r.named), r.quotePrefix !== void 0 && (o.quotePrefix = r.quotePrefix);
3099
- for (let e = 0; e < at.length; e++) {
3100
- let t = at[e];
3553
+ r.named !== void 0 && (o.named = r.named), r.quotePrefix !== void 0 && (o.quotePrefix = r.quotePrefix), r.protection !== void 0 && (o.protection = r.protection);
3554
+ for (let e = 0; e < Mt.length; e++) {
3555
+ let t = Mt[e];
3101
3556
  if (r[t] === void 0 && t !== "alignment") continue;
3102
3557
  let n = a?.[t] ?? r[t];
3103
3558
  n !== void 0 && (o[t] = n);
@@ -3119,16 +3574,16 @@ var vn = (e, t, n, r) => {
3119
3574
  namedStyles: []
3120
3575
  };
3121
3576
  (function(e, t) {
3122
- let n = (e.getNamed(I.BuiltInName.Normal).toJSON().style ?? {}).font ?? {};
3123
- t.fontMap.set(E.JSONStableStringify(n), "0"), t.fonts.push(n);
3577
+ let n = (e.getNamedStyles().getByName(V.BuiltInName.Normal).toJSON().style ?? {}).font ?? {};
3578
+ t.fontMap.set(F.JSONStableStringify(n), "0"), t.fonts.push(n);
3124
3579
  })(e, r), function(e) {
3125
3580
  let t = { type: "none" };
3126
- e.fillMap.set(E.JSONStableStringify(t), "0"), e.fills.push(t);
3581
+ e.fillMap.set(F.JSONStableStringify(t), "0"), e.fills.push(t);
3127
3582
  let n = {
3128
3583
  type: "pattern",
3129
3584
  patternType: "gray125"
3130
3585
  };
3131
- e.fillMap.set(E.JSONStableStringify(n), "1"), e.fills.push(n);
3586
+ e.fillMap.set(F.JSONStableStringify(n), "1"), e.fills.push(n);
3132
3587
  }(r), function(e) {
3133
3588
  let t = {
3134
3589
  bottom: { style: "none" },
@@ -3136,27 +3591,27 @@ var vn = (e, t, n, r) => {
3136
3591
  right: { style: "none" },
3137
3592
  top: { style: "none" }
3138
3593
  };
3139
- e.borderMap.set(E.JSONStableStringify(t), "0"), e.borders.push(t);
3594
+ e.borderMap.set(F.JSONStableStringify(t), "0"), e.borders.push(t);
3140
3595
  }(r), function(e, t) {
3141
- st(e, e.getNamed(I.BuiltInName.Normal).toJSON(), t);
3596
+ Pt(e, e.getNamedStyles().getByName(V.BuiltInName.Normal).toJSON(), t);
3142
3597
  }(e, r);
3143
- let i = t?.named ?? D.EmptyArray;
3144
- for (let t of i) st(e, t, r);
3145
- for (let t of n) ot(e, t, r);
3598
+ let i = t?.named ?? I.EmptyArray;
3599
+ for (let t of i) Pt(e, t, r);
3600
+ for (let t of n) Nt(e, t, r);
3146
3601
  return r;
3147
- }(i, r, a), s = t.getSharedStates().get(it), c = function(e, t = 0) {
3602
+ }(i, r, a), s = t.getSharedStates().get(jt), c = function(e, t = 0) {
3148
3603
  let n = e?.tables;
3149
3604
  if (!n) return null;
3150
3605
  let r = n.styles;
3151
3606
  if (!r) return null;
3152
- let i = [], a = /* @__PURE__ */ new Map(), o = Object.keys(r), s = [...mt].reverse();
3607
+ let i = [], a = /* @__PURE__ */ new Map(), o = Object.keys(r), s = [...Ht].reverse();
3153
3608
  for (let e of o) {
3154
3609
  let n = r[e];
3155
3610
  for (let r of s) {
3156
3611
  let o = n[r];
3157
3612
  if (!o) continue;
3158
3613
  let s = {};
3159
- if (o.font && (s.font = o.font), o.fill && (s.fill = o.fill), o.border && (s.border = o.border), o.numberFormat !== void 0 && (s.numberFormat = o.numberFormat), Object.keys(s).length === 0) continue;
3614
+ if (o.font && (s.font = o.font), o.fill && (s.fill = o.fill), o.borders && (s.borders = o.borders), o.numberFormat !== void 0 && (s.numberFormat = o.numberFormat), Object.keys(s).length === 0) continue;
3160
3615
  let c = t + i.length;
3161
3616
  i.push(s);
3162
3617
  let l = `${e}:${r}`;
@@ -3175,7 +3630,7 @@ var vn = (e, t, n, r) => {
3175
3630
  for (let e = 0; e < i; e++) {
3176
3631
  let n = r[e];
3177
3632
  t.empty("numFmt", {
3178
- numFmtId: String(e + pt),
3633
+ numFmtId: String(e + Vt),
3179
3634
  formatCode: n
3180
3635
  });
3181
3636
  }
@@ -3187,30 +3642,31 @@ var vn = (e, t, n, r) => {
3187
3642
  count: String(a),
3188
3643
  "x14ac:knownFonts": "1"
3189
3644
  });
3190
- for (let r of i) ct(e, t, r, n);
3645
+ for (let r of i) Ft(e, t, r, n);
3191
3646
  t.end("fonts");
3192
3647
  }(t, n, i, o), function(e, t, n, r) {
3193
3648
  let i = r.fills, a = i.length;
3194
3649
  t.start("fills", { count: String(a) });
3195
- for (let e of i) K(0, t, e, n, !0);
3650
+ for (let e of i) J(0, t, e, n, !0);
3196
3651
  t.end("fills");
3197
3652
  }(0, n, i, o), function(e, t, n, r) {
3198
3653
  let i = r.borders, a = i.length;
3199
3654
  t.start("borders", { count: String(a) });
3200
3655
  let o = n.getTheme();
3201
- for (let n of i) lt(e, t, n, o, !1);
3656
+ for (let n of i) Lt(e, t, n, o, !1);
3202
3657
  t.end("borders");
3203
3658
  }(t, n, i, o), function(e, t, n, r, i) {
3204
3659
  let a = i.namedStyles, o = a.length;
3205
3660
  t.start("cellStyleXfs", { count: String(o) });
3206
- for (let r of a) dt(e, t, n, r.style ?? D.EmptyObject, i, !1);
3661
+ for (let r of a) zt(e, t, n, r.style ?? I.EmptyObject, i, !1);
3207
3662
  t.end("cellStyleXfs");
3208
- }(t, n, i, 0, o), function(e, t, n, r, i) {
3209
- let a = r.length;
3210
- t.start("cellXfs", { count: String(a) });
3211
- for (let o = 0; o < a; o++) dt(e, t, n, r[o], i, !0);
3663
+ }(t, n, i, 0, o), function(e, t, n, r, i, a) {
3664
+ let o = r.length, s = a?.getSources() ?? [];
3665
+ t.start("cellXfs", { count: String(o + s.length) });
3666
+ for (let a = 0; a < o; a++) zt(e, t, n, r[a], i, !0);
3667
+ for (let a = 0; a < s.length; a++) zt(e, t, n, r[s[a]], i, !0, !0);
3212
3668
  t.end("cellXfs");
3213
- }(t, n, i, a, o), function(e, t, n, r, i) {
3669
+ }(t, n, i, a, o, t.getSharedStates().get(We)), function(e, t, n, r, i) {
3214
3670
  let a = i.namedStyles, o = a.length;
3215
3671
  t.start("cellStyles", { count: String(o) });
3216
3672
  let s = i.namedStyleMap;
@@ -3221,7 +3677,7 @@ var vn = (e, t, n, r) => {
3221
3677
  };
3222
3678
  r.hidden && (c.hidden = "1"), r.iLevel && (c.iLevel = String(r.iLevel));
3223
3679
  let l = null;
3224
- l = o === I.BuiltInName.Normal.toLowerCase() ? 0 : n.getNamed(i).getBuiltInID(), l !== null && (c.builtinId = String(l), c.customBuiltin = "1"), t.empty("cellStyle", c);
3680
+ l = o === V.BuiltInName.Normal.toLowerCase() ? 0 : n.getNamedStyles().getByName(i).getBuiltInID(), l !== null && (c.builtinId = String(l), c.customBuiltin = "1"), t.empty("cellStyle", c);
3225
3681
  }
3226
3682
  t.end("cellStyles");
3227
3683
  }(0, n, i, 0, o), function(e, t, n, r, i) {
@@ -3229,8 +3685,8 @@ var vn = (e, t, n, r) => {
3229
3685
  if (a.length === 0) return void t.empty("dxfs", { count: "0" });
3230
3686
  let o = n.getTheme();
3231
3687
  t.start("dxfs", { count: String(a.length) });
3232
- let s = pt;
3233
- for (let r of a) s = ft(e, t, r, n, o, "dxf", s);
3688
+ let s = Vt;
3689
+ for (let r of a) s = Bt(e, t, r, n, o, "dxf", s);
3234
3690
  t.end("dxfs");
3235
3691
  }(t, n, i, c, s), function(e, t, n, r, i) {
3236
3692
  let a = r?.tables, o = a?.styles ?? null, s = o ? Object.keys(o) : null, c = s ? s.length : 0, l = {
@@ -3242,7 +3698,7 @@ var vn = (e, t, n, r) => {
3242
3698
  t.start("tableStyles", l);
3243
3699
  for (let e of s) {
3244
3700
  let n = o[e], r = [];
3245
- for (let e of mt) {
3701
+ for (let e of Ht) {
3246
3702
  let t = n[e];
3247
3703
  t && r.push([e, t]);
3248
3704
  }
@@ -3265,7 +3721,7 @@ var vn = (e, t, n, r) => {
3265
3721
  if (t.start("colors"), i) {
3266
3722
  t.start("indexedColors");
3267
3723
  for (let e of r.indexedColors) {
3268
- let n = qe(e, !0);
3724
+ let n = ht(e, !0);
3269
3725
  t.empty("rgbColor", { rgb: n });
3270
3726
  }
3271
3727
  t.end("indexedColors");
@@ -3273,7 +3729,7 @@ var vn = (e, t, n, r) => {
3273
3729
  if (a) {
3274
3730
  t.start("mruColors");
3275
3731
  for (let e of r.mruColors) {
3276
- let n = qe(e);
3732
+ let n = ht(e);
3277
3733
  t.empty("color", { rgb: n });
3278
3734
  }
3279
3735
  t.end("mruColors");
@@ -3291,7 +3747,7 @@ var vn = (e, t, n, r) => {
3291
3747
  }(0, n), n.end("styleSheet"), n.close();
3292
3748
  }
3293
3749
  }(),
3294
- new class extends B {
3750
+ new class extends U {
3295
3751
  constructor() {
3296
3752
  super({
3297
3753
  kind: "propsCore",
@@ -3312,14 +3768,14 @@ var vn = (e, t, n, r) => {
3312
3768
  let r = /* @__PURE__ */ new Date(), i = [
3313
3769
  ["creator", "SheetXL"],
3314
3770
  ["lastModifiedBy", "SheetXL"],
3315
- ["created", Ht(r)],
3316
- ["modified", Ht(r)]
3771
+ ["created", Cn(r)],
3772
+ ["modified", Cn(r)]
3317
3773
  ];
3318
- for (let e of i) Ut(n, e[0], e[1]);
3774
+ for (let e of i) wn(n, e[0], e[1]);
3319
3775
  n.end("cp:coreProperties"), n.close();
3320
3776
  }
3321
3777
  }(),
3322
- new class extends B {
3778
+ new class extends U {
3323
3779
  constructor() {
3324
3780
  super({
3325
3781
  kind: "propsApp",
@@ -3329,21 +3785,14 @@ var vn = (e, t, n, r) => {
3329
3785
  });
3330
3786
  }
3331
3787
  async emit(e, t) {
3332
- let n = t.getXMLWriter(), r = e.model, i = await re.getDetails(), a = function(e) {
3333
- if (!e || typeof e != "string") return xt;
3334
- if (e === "local" || e === "dev" || e === "development") return "00.0000";
3335
- let t = e.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
3336
- if (!t) return xt;
3337
- let n = parseInt(t[1], 10), r = parseInt(t[2] || "0", 10);
3338
- return n > 99 || r > 9999 ? xt : `${n.toString()}.${r.toString().padStart(4, "0")}`;
3339
- }(i.getBuildVersion()), o = i.getLicensee() || "";
3788
+ let n = t.getXMLWriter(), r = e.model, i = await fe.getDetails(), a = j(i.getBuildVersion()), o = i.getLicensee() || "";
3340
3789
  n.setValidationDisabled(!0), n.decl(), n.start("Properties", {
3341
3790
  xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
3342
3791
  "xmlns:vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
3343
- }), Q(t, n, "Application", "SheetXL"), Q(t, n, "DocSecurity", "0"), Q(t, n, "ScaleCrop", "false"), Wt(t, n, r), Q(t, n, "Company", o), Q(t, n, "LinksUpToDate", "false"), Q(t, n, "SharedDoc", "false"), Q(t, n, "HyperlinksChanged", "false"), Q(t, n, "AppVersion", a), n.end("Properties"), n.close();
3792
+ }), $(t, n, "Application", "SheetXL"), $(t, n, "DocSecurity", "0"), $(t, n, "ScaleCrop", "false"), Tn(t, n, r), $(t, n, "Company", o), $(t, n, "LinksUpToDate", "false"), $(t, n, "SharedDoc", "false"), $(t, n, "HyperlinksChanged", "false"), $(t, n, "AppVersion", a), n.end("Properties"), n.close();
3344
3793
  }
3345
3794
  }(),
3346
- new class extends B {
3795
+ new class extends U {
3347
3796
  constructor() {
3348
3797
  super({
3349
3798
  kind: "metadata",
@@ -3358,11 +3807,11 @@ var vn = (e, t, n, r) => {
3358
3807
  let d = { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" };
3359
3808
  if (r && (d["xmlns:xda"] = "http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray"), i && (d["xmlns:xlrd"] = "http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"), n.decl(), n.start("metadata", d), n.start("metadataTypes", { count: u }), r && n.empty("metadataType", {
3360
3809
  name: "XLDAPR",
3361
- ...Gt,
3810
+ ...En,
3362
3811
  cellMeta: "1"
3363
3812
  }), i && n.empty("metadataType", {
3364
3813
  name: "XLRICHVALUE",
3365
- ...Gt
3814
+ ...En
3366
3815
  }), n.end("metadataTypes"), r) {
3367
3816
  n.start("futureMetadata", {
3368
3817
  name: "XLDAPR",
@@ -3401,7 +3850,7 @@ var vn = (e, t, n, r) => {
3401
3850
  n.end("metadata"), n.close();
3402
3851
  }
3403
3852
  }(),
3404
- new class extends B {
3853
+ new class extends U {
3405
3854
  constructor() {
3406
3855
  super({
3407
3856
  kind: "richValue",
@@ -3426,7 +3875,7 @@ var vn = (e, t, n, r) => {
3426
3875
  n.end("rvData"), n.close();
3427
3876
  }
3428
3877
  }(),
3429
- new class extends B {
3878
+ new class extends U {
3430
3879
  constructor() {
3431
3880
  super({
3432
3881
  kind: "richValueStructure",
@@ -3452,7 +3901,7 @@ var vn = (e, t, n, r) => {
3452
3901
  n.end("rvStructures"), n.close();
3453
3902
  }
3454
3903
  }(),
3455
- new class extends B {
3904
+ new class extends U {
3456
3905
  constructor() {
3457
3906
  super({
3458
3907
  kind: "richValueTypes",
@@ -3493,7 +3942,7 @@ var vn = (e, t, n, r) => {
3493
3942
  n.end("keyFlags"), n.end("global"), n.end("rvTypesInfo"), n.close();
3494
3943
  }
3495
3944
  }(),
3496
- new class extends B {
3945
+ new class extends U {
3497
3946
  constructor() {
3498
3947
  super({
3499
3948
  kind: "drawing",
@@ -3528,33 +3977,208 @@ var vn = (e, t, n, r) => {
3528
3977
  }
3529
3978
  for (let e = 0; e < s; e++) {
3530
3979
  let s = o[e], c = a[e], u = s.content?.type;
3531
- switch (n.start("twoCellAnchor", { editAs: s.anchorType || "twoCell" }), fn(n, "from", s.anchor.tl), fn(n, "to", s.anchor.br), u) {
3980
+ switch (n.start("twoCellAnchor", { editAs: s.anchorType || "twoCell" }), Kn(n, "from", s.anchor.tl), Kn(n, "to", s.anchor.br), u) {
3532
3981
  case "picture":
3533
- await Qt(t, i, r, c, s);
3982
+ await Nn(t, i, r, c, s);
3534
3983
  break;
3535
3984
  case "chart":
3536
- await en(t, i, r, c, s, l.get(s));
3985
+ await Pn(t, i, r, c, s, l.get(s));
3537
3986
  break;
3538
3987
  case "shape":
3539
- await an(t, i, r, c, s, l.get(s));
3988
+ await Rn(t, i, r, c, s, l.get(s));
3540
3989
  break;
3541
3990
  case "smartArt":
3542
- await tn(t, i, r, c, s);
3991
+ await Fn(t, i, r, c, s);
3543
3992
  break;
3544
3993
  case "slicer":
3545
- await nn(t, i, r, c, s);
3994
+ await In(t, i, r, c, s);
3546
3995
  break;
3547
3996
  case "graphicFrame":
3548
- await rn(t, i, r, c, s);
3997
+ await Ln(t, i, r, c, s);
3549
3998
  break;
3550
- default: await $(t, i, r, c, s);
3999
+ default: await zn(t, i, r, c, s);
3551
4000
  }
3552
4001
  n.empty("clientData"), n.end("twoCellAnchor");
3553
4002
  }
3554
4003
  n.end("wsDr"), n.close();
3555
4004
  }
3556
4005
  }(),
3557
- new class extends B {
4006
+ new class extends U {
4007
+ constructor() {
4008
+ super({
4009
+ kind: "legacyDrawing",
4010
+ contentType: "application/vnd.openxmlformats-officedocument.vmlDrawing",
4011
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
4012
+ path: "../drawings/vmlDrawing{n}.vml"
4013
+ });
4014
+ }
4015
+ async emit(e, t) {
4016
+ let n = e.images, r = n ? n.length : 0;
4017
+ if (r > 0) {
4018
+ let e = t.getSharedStates().get(he);
4019
+ for (let i = 0; i < r; i++) {
4020
+ let r = n[i], a = e?.get(r.resId);
4021
+ if (a) try {
4022
+ await qn(t, r.id, a);
4023
+ } catch (e) {
4024
+ t.log(`Unable to write legacy drawing image '${r.id}'`, e);
4025
+ }
4026
+ else t.log(`Legacy drawing image '${r.id}' has no resource ${r.resId} and was not written.`);
4027
+ }
4028
+ }
4029
+ let i = t.getXMLWriter();
4030
+ i.setValidationDisabled(!0), i.raw(e.xml), i.close();
4031
+ }
4032
+ }(),
4033
+ new class extends U {
4034
+ constructor() {
4035
+ super({
4036
+ kind: "embeddedPart",
4037
+ contentType: Ye,
4038
+ relTypeUri: ""
4039
+ });
4040
+ }
4041
+ getContentType(e) {
4042
+ return e?.contentType || Ye;
4043
+ }
4044
+ getRelTypeUri(e) {
4045
+ return e?.type ?? "";
4046
+ }
4047
+ getPath(e) {
4048
+ return `./${Qe(e.name)}`;
4049
+ }
4050
+ async emit(e, t) {
4051
+ await Xe(e, t);
4052
+ let n = t.getXMLWriter();
4053
+ n.setValidationDisabled(!0), n.raw(e.xml ?? ""), n.close();
4054
+ }
4055
+ }(),
4056
+ new class extends U {
4057
+ constructor() {
4058
+ super({
4059
+ kind: "pivotTable",
4060
+ contentType: $e,
4061
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
4062
+ path: "../pivotTables/pivotTable{n}.xml"
4063
+ });
4064
+ }
4065
+ getContentType(e) {
4066
+ return e?.part?.contentType || $e;
4067
+ }
4068
+ async emit(e, t) {
4069
+ let n = e.part;
4070
+ await Xe(n, t);
4071
+ let r = et(t, e.cacheId);
4072
+ if (!r || !t.addRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition", r)) throw Error(`Pivot table '${n.name ?? ""}' has no cache with id ${e.cacheId}.`);
4073
+ let i = t.getXMLWriter();
4074
+ i.setValidationDisabled(!0), i.raw(n.xml ?? ""), i.close();
4075
+ }
4076
+ }(),
4077
+ new class extends U {
4078
+ constructor() {
4079
+ super({
4080
+ kind: "comments",
4081
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
4082
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
4083
+ path: "../comments{n}.xml"
4084
+ });
4085
+ }
4086
+ async emit(e, t) {
4087
+ let n = t.getXMLWriter();
4088
+ n.decl(), n.start("comments", {
4089
+ xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
4090
+ "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
4091
+ "mc:Ignorable": "xr",
4092
+ "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
4093
+ });
4094
+ let r = [], i = /* @__PURE__ */ new Map(), a = (e) => {
4095
+ let t = i.get(e);
4096
+ return t === void 0 && (t = r.length, r.push(e), i.set(e, t)), t;
4097
+ }, o = e.comments, s = [];
4098
+ for (let e = 0; e < o.length; e++) {
4099
+ let { comment: t, ref: n } = o[e];
4100
+ t.isNote() ? s.push({
4101
+ ref: n,
4102
+ authorId: a(t.getAuthor()?.getDisplayName() ?? ""),
4103
+ content: t.getRichContent() ?? t.getContent()
4104
+ }) : s.push({
4105
+ ref: n,
4106
+ authorId: a(`tc={${t.getId().toUpperCase()}}`),
4107
+ content: gt(t)
4108
+ });
4109
+ }
4110
+ n.start("authors");
4111
+ for (let e = 0; e < r.length; e++) n.start("author"), n.text(r[e]), n.end("author");
4112
+ n.end("authors"), n.start("commentList");
4113
+ for (let e = 0; e < s.length; e++) {
4114
+ let t = s[e];
4115
+ n.start("comment", {
4116
+ ref: t.ref,
4117
+ authorId: t.authorId,
4118
+ shapeId: 0
4119
+ }), n.start("text"), _t(n, t.content), n.end("text"), n.end("comment");
4120
+ }
4121
+ n.end("commentList"), n.end("comments"), n.close();
4122
+ }
4123
+ }(),
4124
+ new class extends U {
4125
+ constructor() {
4126
+ super({
4127
+ kind: "threadedComments",
4128
+ contentType: "application/vnd.ms-excel.threadedcomments+xml",
4129
+ relTypeUri: "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment",
4130
+ path: "../threadedComments/threadedComment{n}.xml"
4131
+ });
4132
+ }
4133
+ async emit(e, t) {
4134
+ let n = t.getXMLWriter();
4135
+ n.decl(), n.start("ThreadedComments", {
4136
+ xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
4137
+ "xmlns:x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
4138
+ });
4139
+ let r = e.comments;
4140
+ for (let e = 0; e < r.length; e++) {
4141
+ let { comment: t, ref: i } = r[e];
4142
+ if (t.isNote()) continue;
4143
+ Jn(n, i, t.getId(), t.getAuthor()?.getId(), t.getCreationDate(), t.getContent(), null, t.isResolved());
4144
+ let a = t.getReplies();
4145
+ for (let e = 0; e < a.length; e++) {
4146
+ let r = a[e];
4147
+ Jn(n, i, r.getId(), r.getAuthor()?.getId(), r.getCreationDate(), r.getContent(), t.getId(), !1);
4148
+ }
4149
+ }
4150
+ n.end("ThreadedComments"), n.close();
4151
+ }
4152
+ }(),
4153
+ new class extends U {
4154
+ constructor() {
4155
+ super({
4156
+ kind: "persons",
4157
+ contentType: "application/vnd.ms-excel.person+xml",
4158
+ relTypeUri: "http://schemas.microsoft.com/office/2017/10/relationships/person",
4159
+ path: "persons/person.xml"
4160
+ });
4161
+ }
4162
+ async emit(e, t) {
4163
+ let n = t.getXMLWriter();
4164
+ n.decl(), n.start("personList", {
4165
+ xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
4166
+ "xmlns:x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
4167
+ });
4168
+ let r = e.toArray();
4169
+ for (let e = 0; e < r.length; e++) {
4170
+ let t = r[e];
4171
+ n.empty("person", {
4172
+ displayName: t.getDisplayName(),
4173
+ id: Yn(t.getId()),
4174
+ userId: t.getUserId() ?? t.getDisplayName(),
4175
+ providerId: t.getProviderId() ?? "None"
4176
+ });
4177
+ }
4178
+ n.end("personList"), n.close();
4179
+ }
4180
+ }(),
4181
+ new class extends U {
3558
4182
  constructor() {
3559
4183
  super({
3560
4184
  kind: "table",
@@ -3573,10 +4197,79 @@ var vn = (e, t, n, r) => {
3573
4197
  "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
3574
4198
  "xmlns:xr3": "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"
3575
4199
  }, i = e.json, a = e.model;
3576
- a.isShowHeaders(), r.id = ++pn, r.name = i.name?.trim(), r.displayName = i.description ?? i.name, r.ref = e.ref, i.headerRowCount !== 1 && (r.headerRowCount = i.headerRowCount), i.totalsRowCount !== 0 && (r.totalsRowCount = i.totalsRowCount), a.isShowTotals() || (r.totalsRowShown = "0"), n.start("table", r), a.isShowHeaders() && _t(t, n, a, i), mn(t, n, a, i), hn(t, n, a, i), n.end("table"), n.close();
4200
+ a.isShowHeaders(), r.id = ++Xn, r.name = i.name?.trim(), r.displayName = i.description ?? i.name, r.ref = e.ref, i.headerRowCount !== 1 && (r.headerRowCount = i.headerRowCount), i.totalsRowCount !== 0 && (r.totalsRowCount = i.totalsRowCount), i.totalsRowShown || a.isShowTotals() || (r.totalsRowShown = "0"), n.start("table", r), a.isShowHeaders() && Gt(t, n, a, i), Zn(t, n, a, i), $n(t, n, a, i), n.end("table"), n.close();
3577
4201
  }
3578
4202
  }(),
3579
- new class extends B {
4203
+ new class extends U {
4204
+ constructor() {
4205
+ super({
4206
+ kind: "externalLink",
4207
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml",
4208
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink",
4209
+ path: "../externalLinks/externalLink{n}.xml"
4210
+ });
4211
+ }
4212
+ async emit(e, t) {
4213
+ let n = t.getXMLWriter(), r = e.sources ?? [], i = r.findIndex((e) => e.role === "book");
4214
+ i < 0 && r.length > 0 && (i = 0);
4215
+ let a = null, o = null;
4216
+ for (let e = 0; e < r.length; e++) {
4217
+ let n = r[e], s = t.addExternal(n.type || "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath", n.target).relId;
4218
+ e === i ? a = s : n.role === "absoluteUrl" && (o = s);
4219
+ }
4220
+ a || t.log("External book has no path relationship; Excel cannot locate its source.", e.sheetNames), n.decl();
4221
+ let s = { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" };
4222
+ (e.mceIgnorable || o) && (s["xmlns:mc"] = "http://schemas.openxmlformats.org/markup-compatibility/2006", s["mc:Ignorable"] = "x14 xxl21", s["xmlns:x14"] = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main", s["xmlns:xxl21"] = "http://schemas.microsoft.com/office/spreadsheetml/2021/extlinks2021"), n.start("externalLink", s);
4223
+ let c = { "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" };
4224
+ a && (c["r:id"] = a), n.start("externalBook", c), o && (n.start("xxl21:alternateUrls"), n.empty("xxl21:absoluteUrl", { "r:id": o }), n.end("xxl21:alternateUrls")), function(e, t) {
4225
+ let n = t.sheetNames, r = n ? n.length : 0;
4226
+ if (r !== 0) {
4227
+ e.start("sheetNames");
4228
+ for (let t = 0; t < r; t++) e.empty("sheetName", { val: n[t] });
4229
+ e.end("sheetNames");
4230
+ }
4231
+ }(n, e), function(e, t) {
4232
+ let n = t.definedNames, r = n ? n.length : 0;
4233
+ if (r !== 0) {
4234
+ e.start("definedNames");
4235
+ for (let t = 0; t < r; t++) {
4236
+ let r = n[t], i = {
4237
+ name: r.name,
4238
+ refersTo: r.refersTo
4239
+ };
4240
+ r.sheetIndex !== void 0 && (i.sheetId = "" + r.sheetIndex), e.empty("definedName", i);
4241
+ }
4242
+ e.end("definedNames");
4243
+ }
4244
+ }(n, e), function(e, t) {
4245
+ let n = t.sheetDataSet, r = n ? n.length : 0;
4246
+ if (r !== 0) {
4247
+ e.start("sheetDataSet");
4248
+ for (let t = 0; t < r; t++) {
4249
+ let r = n[t], i = { sheetId: "" + r.sheetIndex };
4250
+ r.refreshError && (i.refreshError = "1");
4251
+ let a = r.data, o = a ? a.length : 0;
4252
+ if (o !== 0) {
4253
+ e.start("sheetData", i);
4254
+ for (let t = 0; t < o; t++) {
4255
+ let [n, r] = a[t];
4256
+ e.start("row", { r: "" + (n + 1) });
4257
+ let i = r.length;
4258
+ for (let t = 0; t < i; t++) {
4259
+ let [i, a] = r[t], o = a.length;
4260
+ for (let t = 0; t < o; t++) nr(e, n, i + t, a.at(t));
4261
+ }
4262
+ e.end("row");
4263
+ }
4264
+ e.end("sheetData");
4265
+ } else e.empty("sheetData", i);
4266
+ }
4267
+ e.end("sheetDataSet");
4268
+ }
4269
+ }(n, e), n.end("externalBook"), n.end("externalLink"), n.close();
4270
+ }
4271
+ }(),
4272
+ new class extends U {
3580
4273
  constructor() {
3581
4274
  super({
3582
4275
  kind: "chart",
@@ -3592,10 +4285,10 @@ var vn = (e, t, n, r) => {
3592
4285
  "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
3593
4286
  "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
3594
4287
  "xmlns:c16r2": "http://schemas.microsoft.com/office/drawing/2015/06/chart"
3595
- }), n.empty("date1904", { val: "0" }), n.empty("lang", { val: "en-US" }), n.empty("roundedCorners", { val: "0" }), vn(t, n, e.model, e.json), yn(t, n, e.styles, e.model, e.json), bn(t, n, e.model, e.json), n.end("chartSpace"), n.popDefaultNamespace(), n.close(), t.addPart("chartStyle", { styles: e.styles }), t.addPart("chartColors", { styles: e.styles });
4288
+ }), n.empty("date1904", { val: "0" }), n.empty("lang", { val: "en-US" }), n.empty("roundedCorners", { val: "0" }), rr(t, n, e.model, e.json), ir(t, n, e.styles, e.model, e.json), ar(t, n, e.model, e.json), n.end("chartSpace"), n.popDefaultNamespace(), n.close(), t.addPart("chartStyle", { styles: e.styles }), t.addPart("chartColors", { styles: e.styles });
3596
4289
  }
3597
4290
  }(),
3598
- new class extends B {
4291
+ new class extends U {
3599
4292
  constructor() {
3600
4293
  super({
3601
4294
  kind: "chartStyle",
@@ -3610,10 +4303,10 @@ var vn = (e, t, n, r) => {
3610
4303
  "xmlns:cs": "http://schemas.microsoft.com/office/drawing/2012/chartStyle",
3611
4304
  "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
3612
4305
  id: "297"
3613
- }), Sn(t, n, Cn, e.styles), n.end("chartStyle"), n.close();
4306
+ }), sr(t, n, cr, e.styles), n.end("chartStyle"), n.close();
3614
4307
  }
3615
4308
  }(),
3616
- new class extends B {
4309
+ new class extends U {
3617
4310
  constructor() {
3618
4311
  super({
3619
4312
  kind: "chartColors",
@@ -3629,23 +4322,107 @@ var vn = (e, t, n, r) => {
3629
4322
  "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
3630
4323
  meth: "cycle",
3631
4324
  id: "10"
3632
- }), n.empty("a:schemeClr", { val: "accent1" }), n.empty("a:schemeClr", { val: "accent2" }), n.empty("a:schemeClr", { val: "accent3" }), n.empty("a:schemeClr", { val: "accent4" }), n.empty("a:schemeClr", { val: "accent5" }), n.empty("a:schemeClr", { val: "accent6" }), wn(t, n, Tn), n.end("cs:colorStyle"), n.close();
4325
+ }), n.empty("a:schemeClr", { val: "accent1" }), n.empty("a:schemeClr", { val: "accent2" }), n.empty("a:schemeClr", { val: "accent3" }), n.empty("a:schemeClr", { val: "accent4" }), n.empty("a:schemeClr", { val: "accent5" }), n.empty("a:schemeClr", { val: "accent6" }), lr(t, n, ur), n.end("cs:colorStyle"), n.close();
3633
4326
  }
3634
4327
  }()
3635
- ], Dn = async (e, t) => {
3636
- let n = new Ne();
3637
- for (let e of En) n.register(e);
3638
- let r = On, i = ie.createUint8Array({
4328
+ ], fr = (e) => {
4329
+ let t = e.getPart("xl/_rels/workbook.xml.rels");
4330
+ if (!t) return null;
4331
+ let n = /* @__PURE__ */ new Map();
4332
+ for (let e of f(t.data)) {
4333
+ if (!e.id) continue;
4334
+ let t = e.external ? e.target : we(e.target.startsWith("/") ? e.target : "xl/" + e.target);
4335
+ n.set(e.id, {
4336
+ type: e.type,
4337
+ target: t,
4338
+ external: e.external
4339
+ });
4340
+ }
4341
+ return n;
4342
+ }, pr = (e) => {
4343
+ let t = e.getPart("xl/workbook.xml");
4344
+ return t ? new TextDecoder("utf-8").decode(t.data) : null;
4345
+ }, mr = (e) => {
4346
+ let t = hr.get(e);
4347
+ if (t !== void 0) return t;
4348
+ let n = e.getPart("xl/workbook.xml"), r = n ? new TextDecoder("utf-8").decode(n.data) : null;
4349
+ return hr.set(e, r), r;
4350
+ }, hr = /* @__PURE__ */ new WeakMap(), gr = async (e, t) => {
4351
+ let n = new He();
4352
+ for (let e of dr) n.register(e);
4353
+ let r = _r, i = ge.createUint8Array({
3639
4354
  lastModDate: new Date(1899, 11, 29, 19, 0, 0),
3640
4355
  level: r
3641
- }), a = e.getOrigin(), o = t?.format === "Excel" ? m(a) : null, s = /* @__PURE__ */ new Map(), c = new je(i, n, {
4356
+ }), a = t?.format === "Excel" || t?.format === "ExcelMacro" ? s(e) : null, o = /* @__PURE__ */ new Map(), c = a ? ((e) => {
4357
+ let t = e.getPart("xl/workbook.xml");
4358
+ if (!t) return null;
4359
+ let n = new TextDecoder("utf-8").decode(t.data.subarray(0, 4096)).match(/<fileVersion\b([^>]*)\/?>/);
4360
+ if (!n) return null;
4361
+ let r = {};
4362
+ for (let e of n[1].matchAll(/([\w:]+)="([^"]*)"/g)) r[e[1]] = e[2];
4363
+ return Object.keys(r).length > 0 ? r : null;
4364
+ })(a) : null;
4365
+ c && (t?.macroEnabled || delete c.codeName, o.set(nt, c));
4366
+ let l = a ? ((e) => {
4367
+ let t = mr(e)?.match(/<calcPr\b[^>]*?\bcalcId="([^"]*)"/);
4368
+ return t ? t[1] : null;
4369
+ })(a) : null;
4370
+ l !== null && o.set("calcId", l);
4371
+ let u = a ? ((e) => {
4372
+ let t = mr(e)?.match(/<ext\b[^>]*>\s*<xcalcf:calcFeatures\b[\s\S]*?<\/xcalcf:calcFeatures>\s*<\/ext>/);
4373
+ return t ? t[0] : null;
4374
+ })(a) : null;
4375
+ u !== null && o.set("calcFeatures", u);
4376
+ let d = a ? ((e) => {
4377
+ let t = pr(e);
4378
+ if (!t) return null;
4379
+ let n = /<externalReferences\b[^>]*>([\s\S]*?)<\/externalReferences>/.exec(t);
4380
+ if (!n) return null;
4381
+ let r = [...n[1].matchAll(/<externalReference\b[^>]*\sr:id="([^"]*)"/g)].map((e) => e[1]);
4382
+ if (r.length === 0) return null;
4383
+ let i = fr(e);
4384
+ return i ? r.map((e) => {
4385
+ let t = i.get(e);
4386
+ return t && !t.external ? t.target : null;
4387
+ }) : null;
4388
+ })(a) : null;
4389
+ d && o.set(it, d);
4390
+ let f = a ? ((e) => {
4391
+ let t = pr(e), n = t ? fr(e) : null;
4392
+ if (!t || !n) return null;
4393
+ let r = /* @__PURE__ */ new Map();
4394
+ for (let e of t.matchAll(/<sheet\b([^>]*)\/?>/g)) {
4395
+ let t = /\bsheetId="(\d+)"/.exec(e[1])?.[1], i = /\br:id="([^"]*)"/.exec(e[1])?.[1];
4396
+ if (!t || !i) continue;
4397
+ let a = n.get(i);
4398
+ a && !a.external && a.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" && r.set(parseInt(t, 10), a.target);
4399
+ }
4400
+ return r.size > 0 ? r : null;
4401
+ })(a) : null;
4402
+ f && o.set(rt, f), o.set(he, /* @__PURE__ */ new Map());
4403
+ let p = [], m = new Be(i, n, {
3642
4404
  strictDuplicateChildren: !0,
3643
4405
  onPartEmitted: t?.onPartEmitted,
3644
- mapState: s,
3645
- sourcePackage: o
4406
+ onWarning: (e, t, n) => {
4407
+ p.push([
4408
+ e,
4409
+ t,
4410
+ n
4411
+ ]);
4412
+ },
4413
+ mapState: o,
4414
+ sourcePackage: a,
4415
+ macroEnabled: t?.macroEnabled ?? !1
3646
4416
  });
3647
- c.addPart("workbook", e, "/xl/workbook.xml"), await c.waitEmit(), c.addPart("propsCore", {}), c.addPart("propsApp", { model: e });
3648
- let l = await c.build();
3649
- return l.byteOffset === 0 && l.byteLength === l.buffer.byteLength ? l.buffer : l.slice().buffer;
3650
- }, On = 1;
3651
- export { Dn as writeXLSX };
4417
+ m.addPart("workbook", e, "/xl/workbook.xml"), await m.waitEmit(), m.addPart("propsCore", {}), m.addPart("propsApp", { model: e });
4418
+ let h = await m.build(), g = t?.progress?.onWarning;
4419
+ if (p.length && g) {
4420
+ let e = /* @__PURE__ */ new Set();
4421
+ for (let [n, r, i] of p) {
4422
+ let a = i ?? n;
4423
+ e.has(a) || (e.add(a), g.call(t.progress, n, r));
4424
+ }
4425
+ }
4426
+ return h.byteOffset === 0 && h.byteLength === h.buffer.byteLength ? h.buffer : h.slice().buffer;
4427
+ }, _r = 1;
4428
+ export { gr as writeXLSX };