ooxml-core 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/{PptxHandler-BTXB54UC.mjs → PptxHandler-BL4B7CZO.mjs} +2 -2
  2. package/dist/automation/index.cjs +482 -232
  3. package/dist/automation/index.mjs +482 -232
  4. package/dist/{chunk-CS7HRNHL.mjs → chunk-GAGSCAR3.mjs} +43 -43
  5. package/dist/{chunk-5CJRDY7Q.mjs → chunk-NIHPA63A.mjs} +1 -1
  6. package/dist/{chunk-Q5LESLDA.mjs → chunk-TTPZITQN.mjs} +841 -614
  7. package/dist/{chunk-4L4UB3RQ.mjs → chunk-Z7IQR4S4.mjs} +3 -3
  8. package/dist/{chunk-RIFVZP2S.mjs → chunk-ZAP5WLEN.mjs} +1 -1
  9. package/dist/crypto/index.cjs +281 -109
  10. package/dist/crypto/index.mjs +281 -109
  11. package/dist/docx/load/index.cjs +481 -254
  12. package/dist/docx/load/index.mjs +481 -254
  13. package/dist/geometry/index.cjs +25 -0
  14. package/dist/geometry/index.d.ts +1 -0
  15. package/dist/geometry/index.d.ts.map +1 -1
  16. package/dist/geometry/index.mjs +24 -1
  17. package/dist/geometry/nudge.d.ts +12 -0
  18. package/dist/geometry/nudge.d.ts.map +1 -0
  19. package/dist/geometry/rotation-drag.d.ts +6 -0
  20. package/dist/geometry/rotation-drag.d.ts.map +1 -1
  21. package/dist/index.cjs +25 -0
  22. package/dist/index.mjs +25 -0
  23. package/dist/pptx/automation/index.cjs +1395 -1156
  24. package/dist/pptx/automation/index.d.ts +1 -1
  25. package/dist/pptx/automation/index.mjs +5 -5
  26. package/dist/pptx/chunks/{index-DkHgeV1p.d.ts → index-Cn-GzYGp.d.ts} +62 -13
  27. package/dist/pptx/chunks/{index-DkHgeV1p.d.ts.map → index-Cn-GzYGp.d.ts.map} +1 -1
  28. package/dist/pptx/cli/index.cjs +1274 -1090
  29. package/dist/pptx/cli/index.mjs +4 -4
  30. package/dist/pptx/converter/index.cjs +7 -2
  31. package/dist/pptx/converter/index.mjs +2 -2
  32. package/dist/pptx/index.cjs +1415 -1176
  33. package/dist/pptx/index.d.ts +1 -1
  34. package/dist/pptx/index.mjs +5 -5
  35. package/dist/teams/index.cjs +7 -2
  36. package/dist/teams/index.mjs +7 -2
  37. package/dist/visio/edit-commands.d.ts +3 -1
  38. package/dist/visio/edit-commands.d.ts.map +1 -1
  39. package/dist/visio/edit-layer-properties.d.ts +22 -0
  40. package/dist/visio/edit-layer-properties.d.ts.map +1 -0
  41. package/dist/visio/edit-text-instance.d.ts +21 -0
  42. package/dist/visio/edit-text-instance.d.ts.map +1 -0
  43. package/dist/visio/edit-text-ranges.d.ts.map +1 -1
  44. package/dist/visio/edit-text-scope.d.ts +6 -1
  45. package/dist/visio/edit-text-scope.d.ts.map +1 -1
  46. package/dist/visio/edit-text-target.d.ts +11 -1
  47. package/dist/visio/edit-text-target.d.ts.map +1 -1
  48. package/dist/visio/edit-text.d.ts +2 -1
  49. package/dist/visio/edit-text.d.ts.map +1 -1
  50. package/dist/visio/edit.d.ts +1 -1
  51. package/dist/visio/edit.d.ts.map +1 -1
  52. package/dist/visio/index.cjs +1038 -538
  53. package/dist/visio/index.d.ts +1 -1
  54. package/dist/visio/index.d.ts.map +1 -1
  55. package/dist/visio/index.mjs +1038 -538
  56. package/dist/visio/text-fields.d.ts.map +1 -1
  57. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  58. package/dist/visio/ui/edit-error.d.ts +4 -1
  59. package/dist/visio/ui/edit-error.d.ts.map +1 -1
  60. package/dist/visio/ui/guides.d.ts +5 -0
  61. package/dist/visio/ui/guides.d.ts.map +1 -1
  62. package/dist/visio/ui/index.cjs +19768 -1874
  63. package/dist/visio/ui/index.d.ts +1 -0
  64. package/dist/visio/ui/index.d.ts.map +1 -1
  65. package/dist/visio/ui/index.mjs +19765 -1877
  66. package/dist/visio/ui/sample-drawing.d.ts +8 -0
  67. package/dist/visio/ui/sample-drawing.d.ts.map +1 -0
  68. package/dist/visio/ui/shape-move.d.ts +6 -0
  69. package/dist/visio/ui/shape-move.d.ts.map +1 -1
  70. package/dist/xlsx/load/index.cjs +415 -188
  71. package/dist/xlsx/load/index.mjs +415 -188
  72. package/package.json +6 -5
@@ -35,7 +35,7 @@ function isOoxmlCryptoError(error) {
35
35
  return code === "password-required" || code === "incorrect-password" || code === "data-integrity";
36
36
  }
37
37
 
38
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole2-parser-types.js
38
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-parser-types.js
39
39
  var OLE_MAGIC = new Uint8Array([208, 207, 17, 224, 161, 177, 26, 225]);
40
40
  var ENDOFCHAIN = 4294967294;
41
41
  var FREESECT = 4294967295;
@@ -43,7 +43,9 @@ var FATSECT = 4294967293;
43
43
  var DIFSECT = 4294967292;
44
44
  var MAXREGSECT = 4294967290;
45
45
  var ENTRY_TYPE_EMPTY = 0;
46
+ var ENTRY_TYPE_STORAGE = 1;
46
47
  var ENTRY_TYPE_STREAM = 2;
48
+ var NOSTREAM = 4294967295;
47
49
  var ENTRY_TYPE_ROOT = 5;
48
50
  var DIR_ENTRY_SIZE = 128;
49
51
  var Ole2ParseError = class extends Error {
@@ -53,10 +55,174 @@ var Ole2ParseError = class extends Error {
53
55
  }
54
56
  };
55
57
 
56
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole2-parser-read.js
57
- function parseOle2(buffer) {
58
- const data = new Uint8Array(buffer);
59
- const view = new DataView(buffer);
58
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-directory.js
59
+ var FILETIME_UNIX_EPOCH = 116444736000000000n;
60
+ function readFileTime(view, offset2) {
61
+ const ticks = view.getBigUint64(offset2, true);
62
+ if (ticks === 0n)
63
+ return void 0;
64
+ const ms = Number((ticks - FILETIME_UNIX_EPOCH) / 10000n);
65
+ const date = new Date(ms);
66
+ return Number.isNaN(date.getTime()) ? void 0 : date;
67
+ }
68
+ function decodeSlot(dir, id, majorVersion, warnings) {
69
+ const view = new DataView(dir.buffer, dir.byteOffset + id * DIR_ENTRY_SIZE, DIR_ENTRY_SIZE);
70
+ const nameLen = view.getUint16(64, true);
71
+ const type = view.getUint8(66);
72
+ const nameValid = nameLen >= 2 && nameLen <= 64 && nameLen % 2 === 0 && view.getUint16(nameLen - 2, true) === 0;
73
+ let name = "";
74
+ if (nameValid)
75
+ for (let j = 0; j < nameLen - 2; j += 2)
76
+ name += String.fromCharCode(view.getUint16(j, true));
77
+ const link = (offset2) => {
78
+ const value = view.getUint32(offset2, true);
79
+ return value === NOSTREAM ? -1 : value;
80
+ };
81
+ const sizeLow = view.getUint32(120, true);
82
+ const sizeHigh = view.getUint32(124, true);
83
+ let size = sizeLow;
84
+ if (majorVersion === 4)
85
+ size = sizeLow + sizeHigh * 4294967296;
86
+ else if (sizeHigh !== 0 && type !== ENTRY_TYPE_EMPTY) {
87
+ warnings.push({ code: "size-high-bits", message: `Ignored v3 stream-size high bits on directory entry ${id}` });
88
+ }
89
+ return {
90
+ id,
91
+ type,
92
+ nameValid,
93
+ entry: {
94
+ id,
95
+ name,
96
+ type,
97
+ color: view.getUint8(67),
98
+ leftSiblingId: link(68),
99
+ rightSiblingId: link(72),
100
+ childId: link(76),
101
+ clsid: new Uint8Array(view.buffer.slice(view.byteOffset + 80, view.byteOffset + 96)),
102
+ stateBits: view.getUint32(96, true),
103
+ created: readFileTime(view, 100),
104
+ modified: readFileTime(view, 108),
105
+ startSector: view.getUint32(116, true),
106
+ size,
107
+ parentId: -1
108
+ }
109
+ };
110
+ }
111
+ function readDirectory(dir, majorVersion, strict, warnings) {
112
+ const count2 = Math.floor(dir.length / DIR_ENTRY_SIZE);
113
+ const slots = [];
114
+ for (let id = 0; id < count2; id++)
115
+ slots.push(decodeSlot(dir, id, majorVersion, warnings));
116
+ const roots = slots.filter((slot2) => slot2.type === ENTRY_TYPE_ROOT);
117
+ if (roots.length !== 1 || !roots[0].nameValid)
118
+ throw new Ole2ParseError("Invalid root directory entry");
119
+ const root = roots[0];
120
+ root.entry.path = [];
121
+ const reached = /* @__PURE__ */ new Set([root.id]);
122
+ const fail2 = (message) => {
123
+ if (strict)
124
+ throw new Ole2ParseError(message);
125
+ warnings.push({ code: "directory-link", message });
126
+ };
127
+ const pending2 = [];
128
+ const push = (id, parent, from) => {
129
+ if (id === -1)
130
+ return;
131
+ const target = slots[id];
132
+ if (!target || target.type === ENTRY_TYPE_EMPTY || target.type === ENTRY_TYPE_ROOT) {
133
+ fail2(`Directory entry ${from} links to invalid entry ${id}`);
134
+ return;
135
+ }
136
+ if (reached.has(id)) {
137
+ fail2(`Cyclic directory tree at entry ${id}`);
138
+ return;
139
+ }
140
+ reached.add(id);
141
+ pending2.push({ id, parent });
142
+ };
143
+ push(root.entry.childId, root, root.id);
144
+ while (pending2.length) {
145
+ const { id, parent } = pending2.pop();
146
+ const slot2 = slots[id];
147
+ if (!slot2.nameValid)
148
+ throw new Ole2ParseError("Invalid directory entry name");
149
+ slot2.entry.parentId = parent.id;
150
+ slot2.entry.path = [...parent.entry.path, slot2.entry.name];
151
+ push(slot2.entry.leftSiblingId, parent, id);
152
+ push(slot2.entry.rightSiblingId, parent, id);
153
+ if (slot2.type === ENTRY_TYPE_STORAGE)
154
+ push(slot2.entry.childId, slot2, id);
155
+ }
156
+ const entries = [];
157
+ for (const slot2 of slots) {
158
+ if (slot2.type === ENTRY_TYPE_EMPTY)
159
+ continue;
160
+ if (!reached.has(slot2.id)) {
161
+ if (!slot2.nameValid) {
162
+ if (strict)
163
+ throw new Ole2ParseError("Invalid directory entry name");
164
+ warnings.push({ code: "invalid-unreachable-entry", message: `Skipped undecodable stale directory entry ${slot2.id}` });
165
+ continue;
166
+ }
167
+ if (strict)
168
+ throw new Ole2ParseError(`Directory entry ${slot2.id} is not reachable from the root`);
169
+ warnings.push({ code: "unreachable-entry", message: `Directory entry ${slot2.id} (${slot2.entry.name}) is not reachable from the root` });
170
+ }
171
+ entries.push(slot2.entry);
172
+ }
173
+ return entries;
174
+ }
175
+ function sameName(a2, b) {
176
+ return a2.length === b.length && a2.toUpperCase() === b.toUpperCase();
177
+ }
178
+ function bareName(name) {
179
+ return name.replace(/^[\u0001-\u0006]/, "");
180
+ }
181
+ function normalizePath(path2, rootName2) {
182
+ const parts = typeof path2 === "string" ? path2.split("/").filter((part) => part !== "") : [...path2];
183
+ if (parts.length && sameName(parts[0], rootName2) && typeof path2 === "string")
184
+ parts.shift();
185
+ return parts;
186
+ }
187
+ function child(entries, parentId, name) {
188
+ const children2 = entries.filter((entry3) => entry3.parentId === parentId && entry3.path !== void 0);
189
+ const pick2 = (matches2) => matches2.length === 1 ? matches2[0] : void 0;
190
+ const exact = children2.filter((entry3) => entry3.name === name);
191
+ if (exact.length)
192
+ return pick2(exact);
193
+ const folded = children2.filter((entry3) => sameName(entry3.name, name));
194
+ if (folded.length)
195
+ return pick2(folded);
196
+ return pick2(children2.filter((entry3) => sameName(bareName(entry3.name), bareName(name))));
197
+ }
198
+ function findDirectoryEntry(entries, path2) {
199
+ const root = entries.find((entry3) => entry3.type === ENTRY_TYPE_ROOT);
200
+ if (!root)
201
+ return void 0;
202
+ let current = root;
203
+ for (const name of normalizePath(path2, root.name)) {
204
+ if (current.type !== ENTRY_TYPE_ROOT && current.type !== ENTRY_TYPE_STORAGE)
205
+ return void 0;
206
+ current = child(entries, current.id, name);
207
+ if (!current)
208
+ return void 0;
209
+ }
210
+ return current;
211
+ }
212
+ function findStreamByName(entries, name, isReadable) {
213
+ const root = entries.find((entry3) => entry3.type === ENTRY_TYPE_ROOT);
214
+ if (root && root.name === name)
215
+ return root;
216
+ const top = entries.filter((entry3) => entry3.parentId === root?.id && isReadable(entry3));
217
+ return top.find((entry3) => entry3.name === name) ?? top.find((entry3) => sameName(entry3.name, name)) ?? entries.find((entry3) => entry3.name === name && isReadable(entry3));
218
+ }
219
+
220
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-parser-read.js
221
+ function parseOle2(buffer, options = {}) {
222
+ const strict = options.strict === true;
223
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
224
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
225
+ const warnings = [];
60
226
  if (data.length < 512) {
61
227
  throw new Ole2ParseError("Truncated OLE2 compound file header");
62
228
  }
@@ -65,11 +231,12 @@ function parseOle2(buffer) {
65
231
  throw new Ole2ParseError("Not a valid OLE2 compound file");
66
232
  }
67
233
  }
68
- view.getUint16(24, true);
69
234
  const majorVersion = view.getUint16(26, true);
70
235
  const byteOrder = view.getUint16(28, true);
71
236
  if (byteOrder !== 65534) {
72
- throw new Ole2ParseError("Invalid byte order mark");
237
+ if (strict)
238
+ throw new Ole2ParseError("Invalid byte order mark");
239
+ warnings.push({ code: "byte-order", message: `Ignored byte order mark 0x${byteOrder.toString(16)}` });
73
240
  }
74
241
  const sectorSizePower = view.getUint16(30, true);
75
242
  const miniSectorSizePower = view.getUint16(32, true);
@@ -78,10 +245,14 @@ function parseOle2(buffer) {
78
245
  }
79
246
  const sectorSize = 1 << sectorSizePower;
80
247
  const miniSectorSize = 1 << miniSectorSizePower;
81
- if (data.length < sectorSize || data.length % sectorSize !== 0) {
248
+ if (data.length < sectorSize)
82
249
  throw new Ole2ParseError("Truncated OLE2 sector");
250
+ if (data.length % sectorSize !== 0) {
251
+ if (strict)
252
+ throw new Ole2ParseError("Truncated OLE2 sector");
253
+ warnings.push({ code: "unaligned-length", message: `File length ${data.length} is not a multiple of ${sectorSize}` });
83
254
  }
84
- const sectorCount = data.length / sectorSize - 1;
255
+ const sectorCount = Math.ceil(data.length / sectorSize) - 1;
85
256
  const totalFATSectors = view.getUint32(44, true);
86
257
  const firstDirectorySector = view.getUint32(48, true);
87
258
  const miniStreamCutoff = view.getUint32(56, true);
@@ -102,6 +273,13 @@ function parseOle2(buffer) {
102
273
  }
103
274
  return data.subarray(offset2, offset2 + sectorSize);
104
275
  }
276
+ function copySector(sector, target, at, want) {
277
+ const offset2 = sectorOffset(sector);
278
+ if (sector >= sectorCount || offset2 + want > data.length) {
279
+ throw new Ole2ParseError(`Sector ${sector} at offset ${offset2} exceeds file size ${data.length}`);
280
+ }
281
+ target.set(data.subarray(offset2, offset2 + want), at);
282
+ }
105
283
  const fatSectors = [];
106
284
  for (let i2 = 0; i2 < 109 && fatSectors.length < totalFATSectors; i2++) {
107
285
  const sector = view.getUint32(76 + i2 * 4, true);
@@ -137,29 +315,36 @@ function parseOle2(buffer) {
137
315
  fatEntries.push(fatView.getUint32(i2 * 4, true));
138
316
  }
139
317
  }
140
- function readSectorChain(startSector) {
141
- const sectors = [];
142
- let current = startSector;
318
+ function followChain(table2, start, label2, needed) {
319
+ const ids = [];
143
320
  const visited = /* @__PURE__ */ new Set();
321
+ let current = start;
144
322
  while (current <= MAXREGSECT) {
323
+ if (!strict && needed !== void 0 && ids.length >= needed)
324
+ return ids;
145
325
  if (visited.has(current)) {
146
- throw new Ole2ParseError(`Circular reference in FAT chain at sector ${current}`);
326
+ throw new Ole2ParseError(`Circular reference in ${label2} chain at sector ${current}`);
147
327
  }
148
328
  visited.add(current);
149
- sectors.push(readSector(current));
150
- if (fatEntries[current] === void 0)
151
- throw new Ole2ParseError("Missing FAT chain entry");
152
- current = fatEntries[current];
153
- }
154
- if (current !== ENDOFCHAIN)
155
- throw new Ole2ParseError("Invalid FAT chain terminator");
156
- const totalLength = sectors.length * sectorSize;
157
- const result2 = new Uint8Array(totalLength);
158
- let offset2 = 0;
159
- for (const sector of sectors) {
160
- result2.set(sector, offset2);
161
- offset2 += sectorSize;
329
+ ids.push(current);
330
+ if (table2[current] === void 0)
331
+ throw new Ole2ParseError(`Missing ${label2} chain entry`);
332
+ current = table2[current];
333
+ }
334
+ if (current !== ENDOFCHAIN) {
335
+ if (strict || needed === void 0 || ids.length < needed) {
336
+ throw new Ole2ParseError(`Invalid ${label2} chain terminator`);
337
+ }
338
+ warnings.push({ code: "chain-terminator", message: `Accepted ${label2} chain ending in 0x${current.toString(16)}` });
162
339
  }
340
+ return ids;
341
+ }
342
+ function readMetadataChain(startSector, label2) {
343
+ if (startSector > MAXREGSECT)
344
+ return new Uint8Array(0);
345
+ const ids = followChain(fatEntries, startSector, label2 === "directory" ? "FAT" : label2);
346
+ const result2 = new Uint8Array(ids.length * sectorSize);
347
+ ids.forEach((id, i2) => result2.set(readSector(id), i2 * sectorSize));
163
348
  return result2;
164
349
  }
165
350
  function readStream(startSector, size) {
@@ -167,68 +352,44 @@ function parseOle2(buffer) {
167
352
  return new Uint8Array(0);
168
353
  if (size > sectorCount * sectorSize)
169
354
  throw new Ole2ParseError("Stream size exceeds file size");
170
- const raw2 = readSectorChain(startSector);
171
- if (raw2.length < size)
355
+ const needed = Math.ceil(size / sectorSize);
356
+ const ids = followChain(fatEntries, startSector, "FAT", needed);
357
+ if (ids.length < needed)
172
358
  throw new Ole2ParseError("Truncated stream sector chain");
173
- return raw2.subarray(0, size);
174
- }
175
- const dirRaw = readSectorChain(firstDirectorySector);
176
- const numEntries = Math.floor(dirRaw.length / DIR_ENTRY_SIZE);
177
- const entries = [];
178
- for (let i2 = 0; i2 < numEntries; i2++) {
179
- const entryOffset = i2 * DIR_ENTRY_SIZE;
180
- const entryView = new DataView(dirRaw.buffer, dirRaw.byteOffset + entryOffset, DIR_ENTRY_SIZE);
181
- const nameLen = entryView.getUint16(64, true);
182
- const objectType = entryView.getUint8(66);
183
- if (objectType === ENTRY_TYPE_EMPTY) {
184
- continue;
359
+ const result2 = new Uint8Array(size);
360
+ for (let i2 = 0; i2 < needed; i2++) {
361
+ copySector(ids[i2], result2, i2 * sectorSize, Math.min(sectorSize, size - i2 * sectorSize));
185
362
  }
186
- if (nameLen < 2 || nameLen > 64 || nameLen % 2 !== 0 || entryView.getUint16(nameLen - 2, true) !== 0) {
187
- throw new Ole2ParseError("Invalid directory entry name");
188
- }
189
- const nameBytes = Math.max(0, nameLen - 2);
190
- let name = "";
191
- for (let j = 0; j < nameBytes; j += 2) {
192
- name += String.fromCharCode(entryView.getUint16(j, true));
193
- }
194
- const leftSiblingId = entryView.getUint32(68, true);
195
- const rightSiblingId = entryView.getUint32(72, true);
196
- const childId = entryView.getUint32(76, true);
197
- const clsid = new Uint8Array(entryView.buffer.slice(entryView.byteOffset + 80, entryView.byteOffset + 96));
198
- const startSector = entryView.getUint32(116, true);
199
- const sizeLow = entryView.getUint32(120, true);
200
- let size = sizeLow;
201
- if (majorVersion === 4) {
202
- const sizeHigh = entryView.getUint32(124, true);
203
- size = sizeLow + sizeHigh * 4294967296;
204
- if (!Number.isSafeInteger(size) || size > sectorCount * sectorSize) {
205
- throw new Ole2ParseError("Stream size exceeds supported file bounds");
206
- }
363
+ return result2;
364
+ }
365
+ if (firstDirectorySector > MAXREGSECT)
366
+ throw new Ole2ParseError("Missing directory chain");
367
+ const entries = readDirectory(readMetadataChain(firstDirectorySector, "directory"), majorVersion, strict, warnings);
368
+ for (const entry3 of entries) {
369
+ if (majorVersion === 4 && (!Number.isSafeInteger(entry3.size) || entry3.size > sectorCount * sectorSize)) {
370
+ throw new Ole2ParseError("Stream size exceeds supported file bounds");
207
371
  }
208
- entries.push({
209
- name,
210
- type: objectType,
211
- startSector,
212
- size,
213
- childId: childId === 4294967295 ? -1 : childId,
214
- leftSiblingId: leftSiblingId === 4294967295 ? -1 : leftSiblingId,
215
- rightSiblingId: rightSiblingId === 4294967295 ? -1 : rightSiblingId,
216
- clsid
217
- });
218
372
  }
219
373
  const rootEntry = entries.find((e) => e.type === ENTRY_TYPE_ROOT);
220
- if (!rootEntry || entries.filter((e) => e.type === ENTRY_TYPE_ROOT).length !== 1) {
221
- throw new Ole2ParseError("Invalid root directory entry");
222
- }
223
374
  let miniStreamData;
224
- if (rootEntry && rootEntry.startSector <= MAXREGSECT) {
375
+ if (rootEntry.startSector <= MAXREGSECT) {
225
376
  miniStreamData = readStream(rootEntry.startSector, rootEntry.size);
226
377
  }
227
378
  const miniFatEntries = [];
228
- if (firstMiniFATSector <= MAXREGSECT && totalMiniFATSectors > 0) {
229
- const miniFatRaw = readSectorChain(firstMiniFATSector);
230
- if (miniFatRaw.length !== totalMiniFATSectors * sectorSize) {
379
+ if (firstMiniFATSector > MAXREGSECT && totalMiniFATSectors > 0) {
380
+ if (strict)
231
381
  throw new Ole2ParseError("Unexpected mini FAT chain length");
382
+ warnings.push({ code: "mini-fat-count", message: `Header lists ${totalMiniFATSectors} mini FAT sectors but no chain` });
383
+ }
384
+ if (firstMiniFATSector <= MAXREGSECT && (totalMiniFATSectors > 0 || !strict)) {
385
+ const miniFatRaw = readMetadataChain(firstMiniFATSector, "mini FAT");
386
+ if (miniFatRaw.length !== totalMiniFATSectors * sectorSize) {
387
+ if (strict)
388
+ throw new Ole2ParseError("Unexpected mini FAT chain length");
389
+ warnings.push({
390
+ code: "mini-fat-count",
391
+ message: `Header lists ${totalMiniFATSectors} mini FAT sectors; chain has ${miniFatRaw.length / sectorSize}`
392
+ });
232
393
  }
233
394
  const miniFatView = new DataView(miniFatRaw.buffer, miniFatRaw.byteOffset, miniFatRaw.byteLength);
234
395
  const miniCapacity = Math.floor((miniStreamData?.length ?? 0) / miniSectorSize);
@@ -242,48 +403,59 @@ function parseOle2(buffer) {
242
403
  if (!miniStreamData) {
243
404
  throw new Ole2ParseError("Mini stream container not found");
244
405
  }
245
- const sectors = [];
246
- let current = startSector;
247
- const visited = /* @__PURE__ */ new Set();
248
- while (current <= MAXREGSECT) {
249
- if (visited.has(current)) {
250
- throw new Ole2ParseError(`Circular reference in mini FAT chain at sector ${current}`);
406
+ const needed = Math.ceil(size / miniSectorSize);
407
+ const capacity = miniStreamData.length / miniSectorSize;
408
+ let ids;
409
+ try {
410
+ ids = followChain(miniFatEntries, startSector, "mini FAT", needed);
411
+ } catch (error) {
412
+ if (error instanceof Ole2ParseError && /Missing mini FAT/.test(error.message)) {
413
+ throw new Ole2ParseError("Mini stream sector exceeds allocation bounds");
251
414
  }
252
- visited.add(current);
253
- const offset3 = current * miniSectorSize;
254
- if (offset3 + miniSectorSize > miniStreamData.length || miniFatEntries[current] === void 0) {
415
+ throw error;
416
+ }
417
+ const result2 = new Uint8Array(size);
418
+ for (let i2 = 0; i2 < ids.length && i2 < needed; i2++) {
419
+ const id = ids[i2];
420
+ if (id >= capacity || (id + 1) * miniSectorSize > miniStreamData.length) {
255
421
  throw new Ole2ParseError("Mini stream sector exceeds allocation bounds");
256
422
  }
257
- sectors.push(miniStreamData.subarray(offset3, offset3 + miniSectorSize));
258
- current = miniFatEntries[current];
423
+ const want = Math.min(miniSectorSize, size - i2 * miniSectorSize);
424
+ result2.set(miniStreamData.subarray(id * miniSectorSize, id * miniSectorSize + want), i2 * miniSectorSize);
259
425
  }
260
- if (current !== ENDOFCHAIN)
261
- throw new Ole2ParseError("Invalid mini FAT chain terminator");
262
- const totalLength = sectors.length * miniSectorSize;
263
- if (totalLength < size)
426
+ if (ids.length < needed)
264
427
  throw new Ole2ParseError("Truncated mini stream sector chain");
265
- const result2 = new Uint8Array(totalLength);
266
- let offset2 = 0;
267
- for (const sector of sectors) {
268
- result2.set(sector, offset2);
269
- offset2 += miniSectorSize;
270
- }
271
- return result2.subarray(0, size);
428
+ return result2;
272
429
  }
273
- function getStream(name) {
274
- const entry3 = entries.find((e) => (e.type === ENTRY_TYPE_STREAM || e.type === ENTRY_TYPE_ROOT) && e.name === name);
275
- if (!entry3) {
276
- return void 0;
277
- }
430
+ function readEntry(entry3) {
278
431
  if (entry3.size < miniStreamCutoff && entry3.type !== ENTRY_TYPE_ROOT) {
279
432
  return readMiniStream(entry3.startSector, entry3.size);
280
433
  }
281
434
  return readStream(entry3.startSector, entry3.size);
282
435
  }
283
- return { entries, getStream };
436
+ const readable = (entry3) => entry3.type === ENTRY_TYPE_STREAM || entry3.type === ENTRY_TYPE_ROOT;
437
+ return {
438
+ entries,
439
+ warnings,
440
+ getStream(name) {
441
+ const entry3 = findStreamByName(entries, name, readable);
442
+ return entry3 ? readEntry(entry3) : void 0;
443
+ },
444
+ getStreamByPath(path2) {
445
+ const entry3 = findDirectoryEntry(entries, path2);
446
+ return entry3 && entry3.type === ENTRY_TYPE_STREAM ? readEntry(entry3) : void 0;
447
+ },
448
+ getStreamById(id) {
449
+ const entry3 = entries.find((candidate) => candidate.id === id);
450
+ return entry3 && readable(entry3) ? readEntry(entry3) : void 0;
451
+ },
452
+ findEntry(path2) {
453
+ return findDirectoryEntry(entries, path2);
454
+ }
455
+ };
284
456
  }
285
457
 
286
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/utils/ooxml-crypto-primitives.js
458
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/utils/ooxml-crypto-primitives.js
287
459
  function getSubtle() {
288
460
  if (typeof globalThis.crypto !== "undefined" && globalThis.crypto.subtle) {
289
461
  return globalThis.crypto.subtle;
@@ -2391,7 +2563,7 @@ function isEncryptedOoxmlPackage(input) {
2391
2563
  }
2392
2564
  }
2393
2565
 
2394
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole2-parser-write-helpers.js
2566
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-parser-write-helpers.js
2395
2567
  function compareDirEntryNames(a2, b) {
2396
2568
  const ua = a2.toUpperCase();
2397
2569
  const ub = b.toUpperCase();
@@ -2458,7 +2630,7 @@ function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorS
2458
2630
  }
2459
2631
  }
2460
2632
 
2461
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole2-parser-write-serialize.js
2633
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-parser-write-serialize.js
2462
2634
  function writeHeader(outView, outBytes, params) {
2463
2635
  outBytes.set(OLE_MAGIC, 0);
2464
2636
  outView.setUint16(24, 62, true);
@@ -2551,7 +2723,7 @@ function writeStreamSectors(outBytes, streamData, chain2, sectorSize) {
2551
2723
  }
2552
2724
  }
2553
2725
 
2554
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole2-parser-write.js
2726
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-parser-write.js
2555
2727
  function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
2556
2728
  const sectorSize = 512;
2557
2729
  const miniSectorSize = 64;
@@ -3487,7 +3659,7 @@ function scan(xml) {
3487
3659
  }
3488
3660
  const children2 = [];
3489
3661
  let depth = 0;
3490
- let child3;
3662
+ let child4;
3491
3663
  i2 = openEnd;
3492
3664
  for (; ; ) {
3493
3665
  const lt = xml.indexOf("<", i2);
@@ -3505,13 +3677,13 @@ function scan(xml) {
3505
3677
  return { root, children: children2 };
3506
3678
  }
3507
3679
  depth--;
3508
- if (depth === 0 && child3)
3509
- children2.push({ ...child3, closeStart: lt, end, selfClosing: false });
3680
+ if (depth === 0 && child4)
3681
+ children2.push({ ...child4, closeStart: lt, end, selfClosing: false });
3510
3682
  } else if (xml[end - 2] === "/") {
3511
3683
  if (depth === 0)
3512
3684
  children2.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
3513
3685
  } else {
3514
- if (depth === 0) child3 = { start: lt, openEnd: end };
3686
+ if (depth === 0) child4 = { start: lt, openEnd: end };
3515
3687
  depth++;
3516
3688
  }
3517
3689
  }
@@ -5499,7 +5671,7 @@ function selfContainedXml(element2) {
5499
5671
  clone.setAttribute(`xmlns:${prefix}`, uri);
5500
5672
  }
5501
5673
  }
5502
- for (const child3 of elements(node)) visit(child3);
5674
+ for (const child4 of elements(node)) visit(child4);
5503
5675
  };
5504
5676
  visit(element2);
5505
5677
  return outerXml(clone);
@@ -5760,8 +5932,8 @@ function parseDynamicArrayMetadata(xml) {
5760
5932
  }
5761
5933
  if (!root) return out;
5762
5934
  const top = /* @__PURE__ */ new Map();
5763
- for (const child3 of elements(root))
5764
- top.set(child3.localName, [...top.get(child3.localName) ?? [], child3]);
5935
+ for (const child4 of elements(root))
5936
+ top.set(child4.localName, [...top.get(child4.localName) ?? [], child4]);
5765
5937
  const types = childrenNamed(top.get("metadataTypes")?.[0], "metadataType").map(
5766
5938
  (t) => att(t, "name") ?? ""
5767
5939
  );
@@ -6105,10 +6277,10 @@ function booleanAttribute(element2, name) {
6105
6277
  function descendants2(root, local) {
6106
6278
  const result2 = [];
6107
6279
  const visit = (node) => {
6108
- for (const child3 of Array.from(node.childNodes)) {
6109
- if (!isElement(child3)) continue;
6110
- if (child3.localName === local) result2.push(child3);
6111
- visit(child3);
6280
+ for (const child4 of Array.from(node.childNodes)) {
6281
+ if (!isElement(child4)) continue;
6282
+ if (child4.localName === local) result2.push(child4);
6283
+ visit(child4);
6112
6284
  }
6113
6285
  };
6114
6286
  visit(root);
@@ -6145,9 +6317,9 @@ function parseDrawingColor(element2) {
6145
6317
  const color = {
6146
6318
  kind,
6147
6319
  value: colorValue(kind, element2),
6148
- transforms: elements(element2).map((child3) => ({
6149
- name: child3.localName,
6150
- value: child3.getAttribute("val") ?? ""
6320
+ transforms: elements(element2).map((child4) => ({
6321
+ name: child4.localName,
6322
+ value: child4.getAttribute("val") ?? ""
6151
6323
  }))
6152
6324
  };
6153
6325
  const fallback = kind === "system" ? element2.getAttribute("lastClr") : null;
@@ -7577,9 +7749,9 @@ function parseRun(run2) {
7577
7749
  }
7578
7750
  function parseParagraph(paragraph2) {
7579
7751
  const runs = [];
7580
- for (const child3 of elements(paragraph2))
7581
- if (child3.namespaceURI === NS.a && ["r", "fld", "br"].includes(child3.localName))
7582
- runs.push(parseRun(child3));
7752
+ for (const child4 of elements(paragraph2))
7753
+ if (child4.namespaceURI === NS.a && ["r", "fld", "br"].includes(child4.localName))
7754
+ runs.push(parseRun(child4));
7583
7755
  const properties2 = first(paragraph2, "pPr", NS.a);
7584
7756
  const align = properties2?.getAttribute("algn");
7585
7757
  const defaults = parseProperties(first(properties2, "defRPr", NS.a));
@@ -7801,9 +7973,9 @@ function parseDiagramDrawing(source2, part) {
7801
7973
  const tree = root.localName === "spTree" ? root : first(root, "spTree", NS.dsp);
7802
7974
  let counter = 0;
7803
7975
  const visit = (container2, group) => {
7804
- for (const child3 of Array.from(container2.childNodes)) {
7805
- if (child3.nodeType !== 1) continue;
7806
- const element2 = child3;
7976
+ for (const child4 of Array.from(container2.childNodes)) {
7977
+ if (child4.nodeType !== 1) continue;
7978
+ const element2 = child4;
7807
7979
  if (element2.localName === "sp") {
7808
7980
  const shape2 = parseShape(element2, counter++, group, issues);
7809
7981
  if (shape2) shapes.push(shape2);
@@ -8258,8 +8430,8 @@ function readHeaderFooter(node) {
8258
8430
  if (value !== void 0) out[key] = value;
8259
8431
  }
8260
8432
  for (const [key, local] of Object.entries(HEADER_FOOTER_TEXT)) {
8261
- const child3 = xFirst(node, local);
8262
- if (child3) out[key] = xText(child3);
8433
+ const child4 = xFirst(node, local);
8434
+ if (child4) out[key] = xText(child4);
8263
8435
  }
8264
8436
  return out;
8265
8437
  }
@@ -8858,11 +9030,11 @@ function cNumber(context, parent, local) {
8858
9030
  return void 0;
8859
9031
  }
8860
9032
  function reportUnmodelled(context, element2, handled) {
8861
- for (const child3 of elements(element2)) {
8862
- if (handled.has(child3.localName)) continue;
9033
+ for (const child4 of elements(element2)) {
9034
+ if (handled.has(child4.localName)) continue;
8863
9035
  context.issues.push({
8864
9036
  code: "CHART_ELEMENT_NOT_MODELLED",
8865
- message: `${path(child3)} is not modelled; it is kept only in the source part.`
9037
+ message: `${path(child4)} is not modelled; it is kept only in the source part.`
8866
9038
  });
8867
9039
  }
8868
9040
  }
@@ -9429,15 +9601,15 @@ function parsePlotArea(context, element2) {
9429
9601
  return plotArea;
9430
9602
  }
9431
9603
  const handled = new Set(PLOT_AREA);
9432
- for (const child3 of elements(element2)) {
9433
- if (CHART_GROUP_ELEMENTS[child3.localName]) {
9434
- plotArea.groups.push(parseGroup(context, child3));
9435
- handled.add(child3.localName);
9604
+ for (const child4 of elements(element2)) {
9605
+ if (CHART_GROUP_ELEMENTS[child4.localName]) {
9606
+ plotArea.groups.push(parseGroup(context, child4));
9607
+ handled.add(child4.localName);
9436
9608
  }
9437
- const axis = AXIS_ELEMENTS[child3.localName];
9609
+ const axis = AXIS_ELEMENTS[child4.localName];
9438
9610
  if (axis) {
9439
- plotArea.axes.push(parseAxis(context, child3, axis));
9440
- handled.add(child3.localName);
9611
+ plotArea.axes.push(parseAxis(context, child4, axis));
9612
+ handled.add(child4.localName);
9441
9613
  }
9442
9614
  }
9443
9615
  reportUnmodelled(context, element2, handled);
@@ -9763,13 +9935,13 @@ function chartColorStyleXml(palette, source2) {
9763
9935
  const root = doc.documentElement;
9764
9936
  if (root.localName !== "colorStyle" || root.namespaceURI !== CHART_COLOR_STYLE_NS)
9765
9937
  return buildXml(fresh);
9766
- for (const child3 of elements(root)) {
9767
- if (child3.namespaceURI === NS.a || child3.namespaceURI === CHART_COLOR_STYLE_NS && child3.localName === "variation")
9768
- root.removeChild(child3);
9938
+ for (const child4 of elements(root)) {
9939
+ if (child4.namespaceURI === NS.a || child4.namespaceURI === CHART_COLOR_STYLE_NS && child4.localName === "variation")
9940
+ root.removeChild(child4);
9769
9941
  }
9770
- for (const child3 of elements(fresh.documentElement))
9942
+ for (const child4 of elements(fresh.documentElement))
9771
9943
  root.insertBefore(
9772
- doc.importNode(child3, true),
9944
+ doc.importNode(child4, true),
9773
9945
  elements(root).find(
9774
9946
  (node) => node.namespaceURI === CHART_COLOR_STYLE_NS && node.localName === "extLst"
9775
9947
  ) ?? null
@@ -9780,7 +9952,7 @@ function chartColorStyleXml(palette, source2) {
9780
9952
  }
9781
9953
 
9782
9954
  // chart/read-style.ts
9783
- var child = (parent, name) => first(parent, name, CHART_COLOR_STYLE_NS);
9955
+ var child2 = (parent, name) => first(parent, name, CHART_COLOR_STYLE_NS);
9784
9956
  function reference(node) {
9785
9957
  if (!node) return void 0;
9786
9958
  const out = { index: node.getAttribute("idx") ?? "" };
@@ -9791,10 +9963,10 @@ function reference(node) {
9791
9963
  function entry2(node) {
9792
9964
  const out = {
9793
9965
  sourceXml: buildXml(node),
9794
- ...readChartAppearance(child(node, "defRPr"), child(node, "spPr"))
9966
+ ...readChartAppearance(child2(node, "defRPr"), child2(node, "spPr"))
9795
9967
  };
9796
9968
  for (const key of ["fontRef", "lineRef", "fillRef", "effectRef"]) {
9797
- const ref = reference(child(node, key === "lineRef" ? "lnRef" : key));
9969
+ const ref = reference(child2(node, key === "lineRef" ? "lnRef" : key));
9798
9970
  if (ref) out[key] = ref;
9799
9971
  }
9800
9972
  return out;
@@ -10698,7 +10870,7 @@ function writeChartAxisFormatting(root, formatting) {
10698
10870
  if (!node) {
10699
10871
  node = root.ownerDocument.createElementNS(NS.c, "c:" + name);
10700
10872
  const before = elements(axis).find(
10701
- (child3) => child3.namespaceURI === NS.c && successors.includes(child3.localName)
10873
+ (child4) => child4.namespaceURI === NS.c && successors.includes(child4.localName)
10702
10874
  );
10703
10875
  axis.insertBefore(node, before ?? null);
10704
10876
  }
@@ -10742,7 +10914,7 @@ function writeChartFillFormatting(root, formatting) {
10742
10914
  node.insertBefore(
10743
10915
  properties2,
10744
10916
  elements(node).find(
10745
- (child3) => child3.namespaceURI === NS.c && successors.includes(child3.localName)
10917
+ (child4) => child4.namespaceURI === NS.c && successors.includes(child4.localName)
10746
10918
  ) ?? null
10747
10919
  );
10748
10920
  }
@@ -10771,12 +10943,12 @@ function writeChartLayoutFormatting(root, formatting) {
10771
10943
  target.insertBefore(
10772
10944
  clone,
10773
10945
  elements(target).find(
10774
- (child3) => child3.namespaceURI === NS.c && ![
10946
+ (child4) => child4.namespaceURI === NS.c && ![
10775
10947
  "tx",
10776
10948
  "legendPos",
10777
10949
  "legendEntry",
10778
10950
  ...name === "overlay" ? ["layout"] : []
10779
- ].includes(child3.localName)
10951
+ ].includes(child4.localName)
10780
10952
  ) ?? null
10781
10953
  );
10782
10954
  changed = true;
@@ -10789,7 +10961,7 @@ function writeChartLayoutFormatting(root, formatting) {
10789
10961
  var FILLS = /* @__PURE__ */ new Set(["noFill", "solidFill", "gradFill", "pattFill"]);
10790
10962
  function dropDrawingDeclarations(element2) {
10791
10963
  if (element2.getAttribute("xmlns:a") === NS.a) element2.removeAttribute("xmlns:a");
10792
- for (const child3 of elements(element2)) dropDrawingDeclarations(child3);
10964
+ for (const child4 of elements(element2)) dropDrawingDeclarations(child4);
10793
10965
  }
10794
10966
  function patchDrawingLine(ln2, line2) {
10795
10967
  if (line2.widthEmu === void 0) ln2.removeAttribute("w");
@@ -11266,8 +11438,8 @@ function writeChartTextFormatting(root, formatting) {
11266
11438
  node.insertBefore(
11267
11439
  clone,
11268
11440
  elements(node).find(
11269
- (child3) => child3.namespaceURI === NS.c && ["crossAx", "externalData", "printSettings", "userShapes", "extLst"].includes(
11270
- child3.localName
11441
+ (child4) => child4.namespaceURI === NS.c && ["crossAx", "externalData", "printSettings", "userShapes", "extLst"].includes(
11442
+ child4.localName
11271
11443
  )
11272
11444
  ) ?? null
11273
11445
  );
@@ -12106,8 +12278,8 @@ function reanchor(xml, anchor) {
12106
12278
  rowOff: Math.round(m.rowOffset)
12107
12279
  };
12108
12280
  for (const [local, value] of Object.entries(values2)) {
12109
- const child3 = first(node, local, NS.xdr);
12110
- if (child3) child3.textContent = String(value);
12281
+ const child4 = first(node, local, NS.xdr);
12282
+ if (child4) child4.textContent = String(value);
12111
12283
  }
12112
12284
  };
12113
12285
  set("from", anchor.from);
@@ -21122,7 +21294,7 @@ var ORDER = [
21122
21294
  "extLst"
21123
21295
  ];
21124
21296
  var kids = (parent, local) => elements(parent).filter((e) => e.localName === local);
21125
- function child2(doc, root, local) {
21297
+ function child3(doc, root, local) {
21126
21298
  const existing = kids(root, local)[0];
21127
21299
  if (existing) return existing;
21128
21300
  const node = doc.createElementNS(NS.x, local);
@@ -21141,7 +21313,7 @@ function mergeDynamicArray(xml) {
21141
21313
  }
21142
21314
  const root = doc.documentElement;
21143
21315
  if (root.localName !== "metadata") return void 0;
21144
- const types = child2(doc, root, "metadataTypes");
21316
+ const types = child3(doc, root, "metadataTypes");
21145
21317
  let typeIndex = kids(types, "metadataType").findIndex(
21146
21318
  (t) => t.getAttribute("name") === DYNAMIC_ARRAY_TYPE
21147
21319
  );
@@ -21180,7 +21352,7 @@ function mergeDynamicArray(xml) {
21180
21352
  bk.appendChild(extLst);
21181
21353
  future.appendChild(bk);
21182
21354
  setCount(future, "bk");
21183
- const cells = child2(doc, root, "cellMetadata");
21355
+ const cells = child3(doc, root, "cellMetadata");
21184
21356
  const cellBk = doc.createElementNS(NS.x, "bk");
21185
21357
  const rc = doc.createElementNS(NS.x, "rc");
21186
21358
  rc.setAttribute("t", String(typeIndex + 1));
@@ -21487,7 +21659,7 @@ function themePart(theme, sourceXml) {
21487
21659
  const scheme = first(themeElements, "clrScheme", NS.a);
21488
21660
  if (!scheme) return defaultThemeXml(theme);
21489
21661
  for (const slot2 of elements(scheme)) {
21490
- for (const child3 of elements(slot2)) slot2.removeChild(child3);
21662
+ for (const child4 of elements(slot2)) slot2.removeChild(child4);
21491
21663
  const color = doc.createElementNS(NS.a, "a:srgbClr");
21492
21664
  color.setAttribute("val", colorOf(theme, slot2.localName ?? ""));
21493
21665
  slot2.appendChild(color);
@@ -22144,9 +22316,9 @@ function setOrRemove(element2, name, value) {
22144
22316
  else element2.setAttribute(name, value);
22145
22317
  }
22146
22318
  var flag = (value, fallback) => value ?? fallback ? "1" : "0";
22147
- function insertBefore(parent, child3, before) {
22319
+ function insertBefore(parent, child4, before) {
22148
22320
  const next = elements(parent).find((e) => before.includes(e.localName));
22149
- parent.insertBefore(child3, next ?? null);
22321
+ parent.insertBefore(child4, next ?? null);
22150
22322
  }
22151
22323
  function setChildText(doc, parent, local, text, before) {
22152
22324
  const existing = xKid(parent, local);
@@ -23160,7 +23332,7 @@ var xlsbUnsupported = () => new UnsupportedWorkbookError(
23160
23332
  "Excel Binary Workbook (.xlsb) files are not supported; save as .xlsx in Excel."
23161
23333
  );
23162
23334
 
23163
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole2-stream-edit.js
23335
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-stream-edit.js
23164
23336
  var END = 4294967294;
23165
23337
  var MAX = 4294967290;
23166
23338
  var NIL = 4294967295;
@@ -23195,6 +23367,58 @@ function chainToEnd(table2, start, max) {
23195
23367
  }
23196
23368
  return out;
23197
23369
  }
23370
+ function chainPrefix(table2, start, needed) {
23371
+ const out = [], seen = /* @__PURE__ */ new Set();
23372
+ let id = start;
23373
+ while (out.length < needed) {
23374
+ if (id > MAX || id >= table2.length || seen.has(id))
23375
+ throw new Error("Invalid CFB chain");
23376
+ seen.add(id);
23377
+ out.push(id);
23378
+ id = table2[id];
23379
+ }
23380
+ return out;
23381
+ }
23382
+ function readTarget(input, target, root, fat, sector, sectorCount, sectorSize, miniSize, read32) {
23383
+ const size = target.size;
23384
+ if (size === 0)
23385
+ return new Uint8Array(0);
23386
+ const out = new Uint8Array(size);
23387
+ const copyPhysical = (at, want, into) => {
23388
+ if (at + want > input.length)
23389
+ throw new Error("Stream data exceeds file size");
23390
+ out.set(input.subarray(at, at + want), into);
23391
+ };
23392
+ if (size >= read32(56)) {
23393
+ if (size > sectorCount * sectorSize)
23394
+ throw new Error("Stream size exceeds file size");
23395
+ chainPrefix(fat, target.start, Math.ceil(size / sectorSize)).forEach((id, i2) => {
23396
+ if (id >= sectorCount)
23397
+ throw new Error("Invalid sector");
23398
+ copyPhysical((id + 1) * sectorSize, Math.min(sectorSize, size - i2 * sectorSize), i2 * sectorSize);
23399
+ });
23400
+ return out;
23401
+ }
23402
+ const miniFatSectors = chainToEnd(fat, read32(60), sectorCount);
23403
+ const miniCapacity = Math.floor(Math.min(root.size, sectorCount * sectorSize) / miniSize);
23404
+ const miniFat = [];
23405
+ for (const id of miniFatSectors) {
23406
+ const bytes = sector(id), dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
23407
+ for (let j = 0; j < sectorSize / 4 && miniFat.length < miniCapacity; j++)
23408
+ miniFat.push(dv.getUint32(j * 4, true));
23409
+ }
23410
+ const rootSectors = chainPrefix(fat, root.start, Math.ceil(root.size / sectorSize));
23411
+ chainPrefix(miniFat, target.start, Math.ceil(size / miniSize)).forEach((id, i2) => {
23412
+ const start = id * miniSize, want = Math.min(miniSize, size - i2 * miniSize);
23413
+ if (start + want > root.size)
23414
+ throw new Error("Mini stream out of bounds");
23415
+ const rootSector = rootSectors[Math.floor(start / sectorSize)];
23416
+ if (rootSector >= sectorCount)
23417
+ throw new Error("Invalid sector");
23418
+ copyPhysical((rootSector + 1) * sectorSize + start % sectorSize, want, i2 * miniSize);
23419
+ });
23420
+ return out;
23421
+ }
23198
23422
  function processCompoundFileStream(input, path2, replacement) {
23199
23423
  const reject = () => replacement ? input : void 0;
23200
23424
  try {
@@ -23202,18 +23426,19 @@ function processCompoundFileStream(input, path2, replacement) {
23202
23426
  return reject();
23203
23427
  const view = new DataView(input.buffer, input.byteOffset, input.byteLength);
23204
23428
  const read32 = (offset3) => view.getUint32(offset3, true);
23205
- if (input[0] !== 208 || input[1] !== 207 || input[2] !== 17 || input[3] !== 224 || input[4] !== 161 || input[5] !== 177 || input[6] !== 26 || input[7] !== 225 || view.getUint16(28, true) !== 65534)
23429
+ if (input[0] !== 208 || input[1] !== 207 || input[2] !== 17 || input[3] !== 224 || input[4] !== 161 || input[5] !== 177 || input[6] !== 26 || input[7] !== 225 || // Readers tolerate a non-canonical byte-order mark; edits do not.
23430
+ replacement && view.getUint16(28, true) !== 65534)
23206
23431
  return reject();
23207
23432
  const major = view.getUint16(26, true), shift2 = view.getUint16(30, true), miniShift = view.getUint16(32, true);
23208
23433
  if (major !== 3 && major !== 4 || shift2 !== (major === 3 ? 9 : 12) || miniShift !== 6)
23209
23434
  return reject();
23210
23435
  const sectorSize = 1 << shift2, miniSize = 1 << miniShift;
23211
- if (input.length % sectorSize !== 0)
23436
+ if (input.length < sectorSize || replacement && input.length % sectorSize !== 0)
23212
23437
  return reject();
23213
- const sectorCount = input.length / sectorSize - 1;
23438
+ const sectorCount = Math.ceil(input.length / sectorSize) - 1;
23214
23439
  const offset2 = (id) => (id + 1) * sectorSize;
23215
23440
  const sector = (id) => {
23216
- if (id > MAX || id >= sectorCount)
23441
+ if (id > MAX || id >= sectorCount || offset2(id) + sectorSize > input.length)
23217
23442
  throw new Error("Invalid sector");
23218
23443
  return input.subarray(offset2(id), offset2(id) + sectorSize);
23219
23444
  };
@@ -23263,7 +23488,7 @@ function processCompoundFileStream(input, path2, replacement) {
23263
23488
  for (let i2 = 0; i2 < nameLength - 2; i2 += 2)
23264
23489
  name += String.fromCharCode(dvDir.getUint16(p + i2, true));
23265
23490
  const sizeLow = dvDir.getUint32(p + 120, true), sizeHigh = dvDir.getUint32(p + 124, true);
23266
- if (sizeHigh !== 0)
23491
+ if (sizeHigh !== 0 && (replacement || major === 4))
23267
23492
  return reject();
23268
23493
  entries.push({
23269
23494
  id,
@@ -23310,6 +23535,8 @@ function processCompoundFileStream(input, path2, replacement) {
23310
23535
  }
23311
23536
  if (!target)
23312
23537
  return reject();
23538
+ if (!replacement)
23539
+ return readTarget(input, target, root, fat, sector, sectorCount, sectorSize, miniSize, read32);
23313
23540
  const names = entries.map((e) => e.name.toLowerCase());
23314
23541
  if (replacement && (names.includes("encryptioninfo") || names.includes("encryptedpackage")))
23315
23542
  return reject();
@@ -23433,7 +23660,7 @@ function replaceCompoundFileStream(input, path2, replacement) {
23433
23660
  return processCompoundFileStream(input, path2, replacement) ?? input;
23434
23661
  }
23435
23662
 
23436
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-cfb.js
23663
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-cfb.js
23437
23664
  var WORKBOOK_STREAM_NAMES = ["workbook", "book"];
23438
23665
  function unwrapXlsBytes(bytes) {
23439
23666
  if (!isCfb(bytes)) {
@@ -23500,7 +23727,7 @@ function isCfb(bytes) {
23500
23727
  return OLE_MAGIC.every((value, index2) => bytes[index2] === value);
23501
23728
  }
23502
23729
 
23503
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-functions.js
23730
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-functions.js
23504
23731
  var TABLE = `0 COUNT -1|1 IF -1|2 ISNA 1|3 ISERROR 1|4 SUM -1|5 AVERAGE -1|6 MIN -1|7 MAX -1|8 ROW -1|9 COLUMN -1|10 NA 0|11 NPV -1|12 STDEV -1|13 DOLLAR -1|14 FIXED -1|15 SIN 1|16 COS 1|17 TAN 1|18 ATAN 1|19 PI 0|20 SQRT 1|21 EXP 1|22 LN 1|23 LOG10 1|24 ABS 1|25 INT 1|26 SIGN 1|27 ROUND 2|28 LOOKUP -1|29 INDEX -1|30 REPT 2|31 MID 3|32 LEN 1|33 VALUE 1|34 TRUE 0|35 FALSE 0|36 AND -1|37 OR -1|38 NOT 1|39 MOD 2|40 DCOUNT 3|41 DSUM 3|42 DAVERAGE 3|43 DMIN 3|44 DMAX 3|45 DSTDEV 3|46 VAR -1|47 DVAR 3|48 TEXT 2|49 LINEST -1|50 TREND -1|51 LOGEST -1|52 GROWTH -1|56 PV -1|57 FV -1|58 NPER -1|59 PMT -1|60 RATE -1|61 MIRR 3|62 IRR -1|63 RAND 0|64 MATCH -1|65 DATE 3|66 TIME 3|67 DAY 1|68 MONTH 1|69 YEAR 1|70 WEEKDAY -1|71 HOUR 1|72 MINUTE 1|73 SECOND 1|74 NOW 0|75 AREAS 1|76 ROWS 1|77 COLUMNS 1|78 OFFSET -1|82 SEARCH -1|83 TRANSPOSE 1|86 TYPE 1|97 ATAN2 2|98 ASIN 1|99 ACOS 1|100 CHOOSE -1|101 HLOOKUP -1|102 VLOOKUP -1|105 ISREF 1|109 LOG -1|111 CHAR 1|112 LOWER 1|113 UPPER 1|114 PROPER 1|115 LEFT -1|116 RIGHT -1|117 EXACT 2|118 TRIM 1|119 REPLACE 4|120 SUBSTITUTE -1|121 CODE 1|124 FIND -1|125 CELL -1|126 ISERR 1|127 ISTEXT 1|128 ISNUMBER 1|129 ISBLANK 1|130 T 1|131 N 1|140 DATEVALUE 1|141 TIMEVALUE 1|142 SLN 3|143 SYD 4|144 DDB -1|148 INDIRECT -1|150 CALL -1|162 CLEAN 1|163 MDETERM 1|164 MINVERSE 1|165 MMULT 2|167 IPMT -1|168 PPMT -1|169 COUNTA -1|183 PRODUCT -1|184 FACT 1|189 DPRODUCT 3|190 ISNONTEXT 1|193 STDEVP -1|194 VARP -1|195 DSTDEVP 3|196 DVARP 3|197 TRUNC -1|198 ISLOGICAL 1|199 DCOUNTA 3|204 USDOLLAR -1|205 FINDB -1|206 SEARCHB -1|207 REPLACEB 4|208 LEFTB -1|209 RIGHTB -1|210 MIDB 3|211 LENB 1|212 ROUNDUP 2|213 ROUNDDOWN 2|214 ASC 1|215 DBCS 1|216 RANK -1|219 ADDRESS -1|220 DAYS360 -1|221 TODAY 0|222 VDB -1|227 MEDIAN -1|228 SUMPRODUCT -1|229 SINH 1|230 COSH 1|231 TANH 1|232 ASINH 1|233 ACOSH 1|234 ATANH 1|235 DGET 3|244 INFO 1|247 DB -1|252 FREQUENCY 2|261 ERROR.TYPE 1|269 AVEDEV -1|270 BETADIST -1|271 GAMMALN 1|272 BETAINV -1|273 BINOMDIST 4|274 CHIDIST 2|275 CHIINV 2|276 COMBIN 2|277 CONFIDENCE 3|278 CRITBINOM 3|279 EVEN 1|280 EXPONDIST 3|281 FDIST 3|282 FINV 3|283 FISHER 1|284 FISHERINV 1|285 FLOOR 2|286 GAMMADIST 4|287 GAMMAINV 3|288 CEILING 2|289 HYPGEOMDIST 4|290 LOGNORMDIST 3|291 LOGINV 3|292 NEGBINOMDIST 3|293 NORMDIST 4|294 NORMSDIST 1|295 NORMINV 3|296 NORMSINV 1|297 STANDARDIZE 3|298 ODD 1|299 PERMUT 2|300 POISSON 3|301 TDIST 3|302 WEIBULL 4|303 SUMXMY2 2|304 SUMX2MY2 2|305 SUMX2PY2 2|306 CHITEST 2|307 CORREL 2|308 COVAR 2|309 FORECAST 3|310 FTEST 2|311 INTERCEPT 2|312 PEARSON 2|313 RSQ 2|314 STEYX 2|315 SLOPE 2|316 TTEST 4|317 PROB -1|318 DEVSQ -1|319 GEOMEAN -1|320 HARMEAN -1|321 SUMSQ -1|322 KURT -1|323 SKEW -1|324 ZTEST -1|325 LARGE 2|326 SMALL 2|327 QUARTILE 2|328 PERCENTILE 2|329 PERCENTRANK -1|330 MODE -1|331 TRIMMEAN 2|332 TINV 2|336 CONCATENATE -1|337 POWER 2|342 RADIANS 1|343 DEGREES 1|344 SUBTOTAL -1|345 SUMIF -1|346 COUNTIF 2|347 COUNTBLANK 1|350 ISPMT 4|351 DATEDIF 3|352 DATESTRING 1|353 NUMBERSTRING 2|354 ROMAN -1|358 GETPIVOTDATA -1|359 HYPERLINK -1|360 PHONETIC 1|361 AVERAGEA -1|362 MAXA -1|363 MINA -1|364 STDEVPA -1|365 VARPA -1|366 STDEVA -1|367 VARA -1|368 BAHTTEXT 1`;
23505
23732
  var XLS_FUNCTIONS = new Map(TABLE.split("|").map((entry3) => {
23506
23733
  const [id, name, argc] = entry3.split(" ");
@@ -23508,7 +23735,7 @@ var XLS_FUNCTIONS = new Map(TABLE.split("|").map((entry3) => {
23508
23735
  }));
23509
23736
  var XLS_USER_FUNCTION_ID = 255;
23510
23737
 
23511
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-ptg-text.js
23738
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-ptg-text.js
23512
23739
  var BIFF_ERRORS = {
23513
23740
  0: "#NULL!",
23514
23741
  7: "#DIV/0!",
@@ -23603,7 +23830,7 @@ function readArrayConstant(extra) {
23603
23830
  return `{${lines.join(";")}}`;
23604
23831
  }
23605
23832
 
23606
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-records.js
23833
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-records.js
23607
23834
  var RT_CONTINUE = 60;
23608
23835
  function readXlsRecords(bytes, start = 0, end = bytes.length) {
23609
23836
  const records = [];
@@ -23769,7 +23996,7 @@ function joinedData(record) {
23769
23996
  return out;
23770
23997
  }
23771
23998
 
23772
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-ptg.js
23999
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-ptg.js
23773
24000
  function decodeFormula(rgce, extra, context, options) {
23774
24001
  try {
23775
24002
  return decode2(rgce, new ByteReader(extra), context, options);
@@ -24000,7 +24227,7 @@ function readAttr(reader, stack2, whitespace) {
24000
24227
  }
24001
24228
  }
24002
24229
 
24003
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sst.js
24230
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sst.js
24004
24231
  function parseSharedStrings2(record) {
24005
24232
  const reader = SegmentReader.of(record);
24006
24233
  reader.u32();
@@ -24017,7 +24244,7 @@ function parseSharedStrings2(record) {
24017
24244
  return strings;
24018
24245
  }
24019
24246
 
24020
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-styles.js
24247
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-styles.js
24021
24248
  var DEFAULT_XLS_PALETTE = "000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 800000 008000 000080 808000 800080 008080 C0C0C0 808080 9999FF 993366 FFFFCC CCFFFF 660066 FF8080 0066CC CCCCFF 000080 FF00FF FFFF00 00FFFF 800080 800000 008080 0000FF 00CCFF CCFFFF CCFFCC FFFF99 99CCFF FF99CC CC99FF FFCC99 3366FF 33CCCC 99CC00 FFCC00 FF9900 FF6600 666699 969696 003366 339966 003300 333300 993300 993366 333399 333333".split(" ");
24022
24249
  var XLS_BUILTIN_FORMATS = {
24023
24250
  0: "General",
@@ -24274,7 +24501,7 @@ function applyXfExt(data, xfs, palette) {
24274
24501
  }
24275
24502
  }
24276
24503
 
24277
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-types.js
24504
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-types.js
24278
24505
  var XlsReadError = class extends Error {
24279
24506
  code;
24280
24507
  constructor(code, message) {
@@ -24284,7 +24511,7 @@ var XlsReadError = class extends Error {
24284
24511
  }
24285
24512
  };
24286
24513
 
24287
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-globals.js
24514
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-globals.js
24288
24515
  var RT = {
24289
24516
  BOF: 2057,
24290
24517
  EOF: 10,
@@ -24522,7 +24749,7 @@ function parseGlobals(records) {
24522
24749
  return out;
24523
24750
  }
24524
24751
 
24525
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-biff8.js
24752
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-biff8.js
24526
24753
  function decodeRk(rk) {
24527
24754
  const isInt = (rk & 2) !== 0;
24528
24755
  const isDiv100 = (rk & 1) !== 0;
@@ -24539,7 +24766,7 @@ function decodeRk(rk) {
24539
24766
  return isDiv100 ? value / 100 : value;
24540
24767
  }
24541
24768
 
24542
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-formulas.js
24769
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-formulas.js
24543
24770
  function readRefU(r) {
24544
24771
  return { firstRow: r.u16(), lastRow: r.u16(), firstCol: r.u8(), lastCol: r.u8() };
24545
24772
  }
@@ -24597,7 +24824,7 @@ function resolveFormulas(formulas, shared, arrays, globals) {
24597
24824
  }
24598
24825
  }
24599
24826
 
24600
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sheet-extras.js
24827
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sheet-extras.js
24601
24828
  function parseMergedCells(data) {
24602
24829
  const r = new ByteReader(data);
24603
24830
  const count2 = r.u16();
@@ -24792,7 +25019,7 @@ function parseNote(data) {
24792
25019
  return { row: row2, col, visible: (flags & 2) !== 0, id, author: r.xlString() };
24793
25020
  }
24794
25021
 
24795
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sheet.js
25022
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sheet.js
24796
25023
  var UNSUPPORTED = {
24797
25024
  432: "conditional formatting",
24798
25025
  2169: "conditional formatting",
@@ -25048,7 +25275,7 @@ function parseSheet(bound, records, start, globals) {
25048
25275
  return sheet;
25049
25276
  }
25050
25277
 
25051
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook.js
25278
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook.js
25052
25279
  function compoundStreamNames(bytes) {
25053
25280
  if (!OLE_MAGIC.every((value, index2) => bytes[index2] === value))
25054
25281
  return [];
@@ -25118,7 +25345,7 @@ function readXlsWorkbook(bytes) {
25118
25345
  };
25119
25346
  }
25120
25347
 
25121
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole-document-doc-cp1252.js
25348
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole-document-doc-cp1252.js
25122
25349
  var CP1252_HIGH_BLOCK = [
25123
25350
  8364,
25124
25351
  129,
@@ -25168,7 +25395,7 @@ function decodeCp1252(bytes) {
25168
25395
  return out;
25169
25396
  }
25170
25397
 
25171
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/ole-summary-properties.js
25398
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole-summary-properties.js
25172
25399
  var SUMMARY_STREAM_NAME = "SummaryInformation";
25173
25400
  var SUMMARY_TEXT_PROPERTIES = {
25174
25401
  title: 2,
@@ -25283,7 +25510,7 @@ function readSummaryProperties(bytes) {
25283
25510
  return result2;
25284
25511
  }
25285
25512
 
25286
- // ../../node_modules/.bun/@christophervr+ole2@0.12.0/node_modules/@christophervr/ole2/dist/legacy-office-metadata.js
25513
+ // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-office-metadata.js
25287
25514
  function summaryStream(bytes) {
25288
25515
  return readCompoundFileStream(bytes, [SUMMARY_STREAM_NAME]);
25289
25516
  }