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