@ryangarber/markitdown-ts 0.1.5 → 0.2.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.
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
10
10
  var __copyProps = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
12
  key = keys[i];
@@ -21,12 +21,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  value: mod,
22
22
  enumerable: true
23
23
  }) : target, mod));
24
- //#endregion
25
- let _joplin_turndown_plugin_gfm = require("@joplin/turndown-plugin-gfm");
26
- _joplin_turndown_plugin_gfm = __toESM(_joplin_turndown_plugin_gfm, 1);
24
+ let linkedom = require("linkedom");
25
+ let _truto_turndown_plugin_gfm = require("@truto/turndown-plugin-gfm");
26
+ _truto_turndown_plugin_gfm = __toESM(_truto_turndown_plugin_gfm, 1);
27
27
  let turndown = require("turndown");
28
28
  turndown = __toESM(turndown, 1);
29
- let linkedom = require("linkedom");
29
+ let file_type = require("file-type");
30
+ let mime = require("mime");
31
+ let mime_types_other_js = require("mime/types/other.js");
32
+ mime_types_other_js = __toESM(mime_types_other_js, 1);
33
+ let mime_types_standard_js = require("mime/types/standard.js");
34
+ mime_types_standard_js = __toESM(mime_types_standard_js, 1);
30
35
  let mammoth = require("mammoth");
31
36
  mammoth = __toESM(mammoth, 1);
32
37
  let unpdf = require("unpdf");
@@ -34,7 +39,7 @@ let _xmldom_xmldom = require("@xmldom/xmldom");
34
39
  let read_excel_file_universal = require("read-excel-file/universal");
35
40
  read_excel_file_universal = __toESM(read_excel_file_universal, 1);
36
41
  let fflate = require("fflate");
37
- //#region src/bytes.ts
42
+ // src/utils/bytes.ts
38
43
  async function toUint8Array(source) {
39
44
  if (source instanceof Uint8Array) return source;
40
45
  if (isBlob(source)) return new Uint8Array(await source.arrayBuffer());
@@ -50,12 +55,11 @@ function decodeText(source) {
50
55
  function isBlob(value) {
51
56
  return typeof Blob !== "undefined" && value instanceof Blob;
52
57
  }
53
- //#endregion
54
- //#region src/custom-turndown.ts
55
- var CustomTurnDown = class {
58
+ // src/utils/turndown.ts
59
+ var Turndown = class {
56
60
  convertSoup(document) {
57
61
  const service = new turndown.default({ headingStyle: "atx" });
58
- service.use(_joplin_turndown_plugin_gfm.default.gfm);
62
+ service.use(_truto_turndown_plugin_gfm.default);
59
63
  service.addRule("anchor tags", {
60
64
  filter: ["a"],
61
65
  replacement(content, node) {
@@ -90,48 +94,166 @@ var CustomTurnDown = class {
90
94
  return `![${alt}](${source}${title ? ` "${title}"` : ""})`;
91
95
  }
92
96
  });
93
- return service.turndown(document);
97
+ return service.turndown(serializeNode(document));
94
98
  }
95
99
  };
96
- //#endregion
97
- //#region src/html-document.ts
98
- function parseHtmlDocument(html) {
99
- return (0, linkedom.parseHTML)(html).document;
100
+ /**
101
+ * Turndown and its GFM plugin rely on DOM APIs (e.g. `HTMLTableElement.rows`, `Element.closest`)
102
+ * that linkedom does not implement, which silently drops content such as tables. Serializing
103
+ * lets Turndown re-parse the markup with its own spec-compliant DOM.
104
+ */
105
+ function serializeNode(node) {
106
+ if (typeof node === "string") return node;
107
+ if (node.nodeType === node.DOCUMENT_NODE) return node.documentElement?.outerHTML ?? "";
108
+ if (node.nodeType === node.ELEMENT_NODE) return node.outerHTML;
109
+ if (node.nodeType === node.TEXT_NODE) return escapeHtml$2(node.textContent ?? "");
110
+ return [...node.childNodes].map(serializeNode).join("");
111
+ }
112
+ function escapeHtml$2(value) {
113
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
114
+ }
115
+ // src/utils/html.ts
116
+ function parseHtmlDocument(html, transform) {
117
+ const document = (0, linkedom.parseHTML)(wrapFragment(html)).document;
118
+ return Object.fromEntries(Object.entries(transform(document)).map(([key, value]) => {
119
+ if (value.type === "node") return [key, (Array.isArray(value.value) ? value.value : [value.value]).map((node) => new Turndown().convertSoup(node).split(/\n+/).map((line) => line.trim()).filter(Boolean).join("\n\n")).join("\n\n")];
120
+ return [key, value.value];
121
+ }));
122
+ }
123
+ /**
124
+ * linkedom only parses complete documents: given a fragment (e.g. mammoth output or an RSS
125
+ * description), it promotes the first element to `documentElement` and drops its siblings
126
+ * from the tree, so wrap fragments in a full document first.
127
+ */
128
+ function wrapFragment(html) {
129
+ if (/<html[\s>]/i.test(html)) return html;
130
+ if (/<(head|body)[\s>]/i.test(html)) return `<html>${html}</html>`;
131
+ return `<html><head></head><body>${html}</body></html>`;
132
+ }
133
+ // src/utils/mime.ts
134
+ const mime$1 = new mime.Mime(mime_types_standard_js.default, mime_types_other_js.default);
135
+ function extensionFromMime(contentType) {
136
+ if (!contentType) return null;
137
+ return extensionNormalized(mime$1.getExtension(contentType));
138
+ }
139
+ async function extensionFromBuffer(buffer) {
140
+ const type = await (0, file_type.fileTypeFromBuffer)(buffer);
141
+ if (!type) return null;
142
+ return extensionNormalized(type.ext);
143
+ }
144
+ /**
145
+ * Sniffs text formats that have no magic number. Returns null for binary content, and `txt`
146
+ * for text that is not recognized as anything more specific.
147
+ */
148
+ function extensionFromText(buffer) {
149
+ let text;
150
+ try {
151
+ text = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
152
+ } catch {
153
+ return null;
154
+ }
155
+ if (hasBinaryControlCharacters(text)) return null;
156
+ const start = text.trimStart().slice(0, 1024).toLowerCase();
157
+ if (start.startsWith("<")) {
158
+ if (/<rss[\s>]/.test(start)) return "rss";
159
+ if (/<feed[\s>]/.test(start)) return "atom";
160
+ if (/^<!doctype html|<(html|head|body)[\s>]/.test(start)) return "html";
161
+ if (start.startsWith("<?xml")) return "xml";
162
+ }
163
+ if (start.startsWith("{") && /"nbformat"\s*:/.test(text) && /"cells"\s*:/.test(text)) return "ipynb";
164
+ return "txt";
165
+ }
166
+ function hasBinaryControlCharacters(text) {
167
+ for (let index = 0; index < text.length; index++) {
168
+ const code = text.charCodeAt(index);
169
+ if (code < 32 && (code < 9 || code > 13) && code !== 27) return true;
170
+ }
171
+ return false;
100
172
  }
101
- //#endregion
102
- //#region src/converters/bingserp.ts
173
+ function extensionFromPathname(pathname) {
174
+ const filename = pathname.split("/").pop() ?? "";
175
+ const dot = filename.lastIndexOf(".");
176
+ return dot > 0 ? extensionNormalized(filename.slice(dot)) : null;
177
+ }
178
+ /** Reads the filename from a Content-Disposition header, preferring the RFC 5987 form. */
179
+ function filenameFromDisposition(disposition) {
180
+ if (!disposition) return null;
181
+ const extended = disposition.match(/filename\*\s*=\s*[\w-]*'[^']*'([^;]+)/i)?.[1]?.trim();
182
+ if (extended) try {
183
+ return decodeURIComponent(extended);
184
+ } catch {
185
+ return extended;
186
+ }
187
+ const plain = disposition.match(/filename\s*=\s*(?:"([^"]*)"|([^;]+))/i);
188
+ return (plain?.[1] ?? plain?.[2])?.trim() || null;
189
+ }
190
+ /**
191
+ * Lists candidate extensions for the content, most reliable first: explicit extensions, then
192
+ * names, then declared MIME types, then the content itself.
193
+ */
194
+ async function detectExtensions(buffer, { extension, filename, urls = [], contentType } = {}) {
195
+ const candidates = [
196
+ extensionNormalized(extension),
197
+ filename ? extensionFromPathname(filename) : null,
198
+ ...urls.map((url) => url ? extensionFromUrl(url) : null),
199
+ extensionFromMime(contentType),
200
+ await extensionFromBuffer(buffer) ?? extensionFromText(buffer)
201
+ ];
202
+ return [...new Set(candidates.filter((candidate) => !!candidate))];
203
+ }
204
+ function extensionFromUrl(url) {
205
+ try {
206
+ return extensionFromPathname(decodeURIComponent(new URL(url).pathname));
207
+ } catch {
208
+ return null;
209
+ }
210
+ }
211
+ function extensionNormalized(extension, withDot = false) {
212
+ if (!extension) return "";
213
+ const normalized = extension.trim().toLowerCase().replace(/^[.-]+/, "");
214
+ return withDot ? `.${normalized}` : normalized;
215
+ }
216
+ function isTextExtension(extension) {
217
+ const type = mime$1.getType(extension);
218
+ if (!type) return false;
219
+ return type.startsWith("text/");
220
+ }
221
+ // src/converters/bingserp.ts
103
222
  const BING_SEARCH_URL = /^https:\/\/www\.bing\.com\/search\?q=/i;
104
223
  const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
105
224
  var BingSerpConverter = class {
106
225
  async convert(source, options = {}) {
107
- const extension = options.file_extension?.toLowerCase() ?? "";
108
- const url = options.url ?? "";
109
- if (extension !== ".html" && extension !== ".htm" || !BING_SEARCH_URL.test(url)) return null;
110
- const document = parseHtmlDocument(decodeText(source));
111
- const query = new URL(url).searchParams.get("q") ?? "";
112
- document.querySelectorAll(".tptt").forEach((element) => {
113
- if (element.textContent) element.textContent += " ";
114
- });
115
- document.querySelectorAll(".algoSlug_icon").forEach((element) => {
116
- element.remove();
117
- });
118
- const turndown = new CustomTurnDown();
119
- const markdown = `## A Bing search for '${query}' found the following results:\n\n${[...document.querySelectorAll(".b_algo")].map((result) => {
120
- result.querySelectorAll("a[href]").forEach((anchor) => {
121
- const href = anchor.getAttribute("href");
122
- if (!href) return;
123
- try {
124
- const encoded = new URL(href, url).searchParams.get("u");
125
- if (encoded) anchor.setAttribute("href", decodeBingUrl(encoded));
126
- } catch {}
226
+ if (options.extension !== "html" && options.extension !== "htm" || !BING_SEARCH_URL.test(options.url ?? "")) return null;
227
+ let query = new URL(options.url ?? "").searchParams.get("q") || null;
228
+ if (query) query = `Search results for "${query}"`;
229
+ return parseHtmlDocument(decodeText(source), (document) => {
230
+ document.querySelectorAll(".tptt").forEach((element) => {
231
+ if (element.textContent) element.textContent += " ";
127
232
  });
128
- return turndown.convertSoup(result).split(/\n+/).map((line) => line.trim()).filter(Boolean).join("\n");
129
- }).join("\n\n")}`;
130
- return {
131
- title: document.title || null,
132
- markdown,
133
- text_content: markdown
134
- };
233
+ document.querySelectorAll(".algoSlug_icon").forEach((element) => {
234
+ element.remove();
235
+ });
236
+ return {
237
+ title: {
238
+ type: "metadata",
239
+ value: query || document.title || null
240
+ },
241
+ markdown: {
242
+ type: "node",
243
+ value: [...document.querySelectorAll(".b_algo")].map((result) => {
244
+ result.querySelectorAll("a[href]").forEach((anchor) => {
245
+ const href = anchor.getAttribute("href");
246
+ if (!href) return;
247
+ try {
248
+ const encoded = new URL(href, options.url ?? "").searchParams.get("u");
249
+ if (encoded) anchor.setAttribute("href", decodeBingUrl(encoded));
250
+ } catch {}
251
+ });
252
+ return result;
253
+ })
254
+ }
255
+ };
256
+ });
135
257
  }
136
258
  };
137
259
  function decodeBingUrl(encoded) {
@@ -151,52 +273,46 @@ function decodeBingUrl(encoded) {
151
273
  }
152
274
  return new TextDecoder().decode(new Uint8Array(bytes));
153
275
  }
154
- //#endregion
155
- //#region src/converters/html.ts
276
+ // src/converters/html.ts
156
277
  var HtmlConverter = class {
157
278
  async convert(source, options) {
158
- const extension = options.file_extension?.toLowerCase() ?? "";
159
- if (extension !== ".html" && extension !== ".htm") return null;
279
+ if (options.extension !== "html" && options.extension !== "htm") return null;
160
280
  return this.convertHtml(decodeText(source));
161
281
  }
162
282
  async convertHtml(html) {
163
- const document = parseHtmlDocument(html);
164
- const title = document.title;
165
- document.querySelectorAll("script, style, title").forEach((element) => {
166
- element.remove();
283
+ return parseHtmlDocument(html, (document) => {
284
+ const title = document.title || null;
285
+ document.querySelectorAll("script, style, title").forEach((element) => {
286
+ element.remove();
287
+ });
288
+ return {
289
+ title: {
290
+ type: "metadata",
291
+ value: title
292
+ },
293
+ markdown: {
294
+ type: "node",
295
+ value: document
296
+ }
297
+ };
167
298
  });
168
- const markdown = new CustomTurnDown().convertSoup(document);
169
- return {
170
- title: title || null,
171
- markdown,
172
- text_content: markdown
173
- };
174
299
  }
175
300
  };
176
- //#endregion
177
- //#region src/converters/docx.ts
301
+ // src/converters/docx.ts
178
302
  var DocxConverter = class extends HtmlConverter {
179
303
  async convert(source, options) {
180
- if (options.file_extension?.toLowerCase() !== ".docx") return null;
304
+ if (options.extension !== "docx") return null;
181
305
  let mammothInput = { arrayBuffer: toArrayBuffer(source) };
182
306
  if (typeof process !== "undefined" && process.versions !== null && process.versions.node !== null) mammothInput = { buffer: Buffer.from(source) };
183
- const mammothOptions = {
184
- styleMap: options.styleMap,
185
- includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,
186
- includeDefaultStyleMap: options.includeDefaultStyleMap,
187
- ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,
188
- idPrefix: options.idPrefix
189
- };
190
- if (options.transformDocument) mammothOptions.transformDocument = options.transformDocument;
307
+ const mammothOptions = Object.fromEntries(Object.entries(options.mammoth ?? {}).flatMap(([key, value]) => value !== void 0 ? [[key, value]] : []));
191
308
  const html = await mammoth.default.convertToHtml(mammothInput, mammothOptions);
192
309
  return this.convertHtml(html.value);
193
310
  }
194
311
  };
195
- //#endregion
196
- //#region src/converters/ipynb.ts
312
+ // src/converters/ipynb.ts
197
313
  var IpynbConverter = class {
198
314
  async convert(source, options = {}) {
199
- if (options.file_extension?.toLowerCase() !== ".ipynb") return null;
315
+ if (options.extension !== "ipynb") return null;
200
316
  const notebook = JSON.parse(decodeText(source));
201
317
  const output = [];
202
318
  let title = notebook.metadata?.title ?? null;
@@ -211,85 +327,37 @@ var IpynbConverter = class {
211
327
  const markdown = output.join("\n\n");
212
328
  return {
213
329
  title,
214
- markdown,
215
- text_content: markdown
330
+ markdown
216
331
  };
217
332
  }
218
333
  };
219
- //#endregion
220
- //#region src/converters/pdf.ts
334
+ // src/converters/pdf.ts
221
335
  var PdfConverter = class {
222
336
  async convert(source, options) {
223
- if (options.file_extension?.toLowerCase() !== ".pdf") return null;
337
+ if (options.extension !== "pdf") return null;
224
338
  const pdf = await (0, unpdf.getDocumentProxy)(source.slice());
225
339
  try {
226
340
  const [{ text }, { info }] = await Promise.all([(0, unpdf.extractText)(pdf, { mergePages: true }), (0, unpdf.getMeta)(pdf)]);
227
341
  return {
228
342
  title: typeof info.Title === "string" && info.Title.trim() ? info.Title : null,
229
- markdown: text,
230
- text_content: text
343
+ markdown: text
231
344
  };
232
345
  } finally {
233
346
  await pdf.loadingTask.destroy();
234
347
  }
235
348
  }
236
349
  };
237
- //#endregion
238
- //#region src/mime.ts
239
- const MIME_EXTENSIONS = {
240
- "application/atom+xml": ".atom",
241
- "application/json": ".json",
242
- "application/pdf": ".pdf",
243
- "application/zip": ".zip",
244
- "application/rss+xml": ".rss",
245
- "application/x-pdf": ".pdf",
246
- "application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
247
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
248
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
249
- "application/xml": ".xml",
250
- "text/csv": ".csv",
251
- "text/html": ".html",
252
- "text/markdown": ".md",
253
- "text/plain": ".txt",
254
- "text/xml": ".xml"
255
- };
256
- const TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
257
- ".csv",
258
- ".json",
259
- ".log",
260
- ".markdown",
261
- ".md",
262
- ".text",
263
- ".txt"
264
- ]);
265
- function extensionFromMime(contentType) {
266
- if (!contentType) return null;
267
- const mime = contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
268
- return MIME_EXTENSIONS[mime] ?? (mime.startsWith("text/") ? ".txt" : null);
269
- }
270
- function isTextExtension(extension) {
271
- return TEXT_EXTENSIONS.has(extension.toLowerCase());
272
- }
273
- function extensionFromPathname(pathname) {
274
- const filename = pathname.split("/").pop() ?? "";
275
- const dot = filename.lastIndexOf(".");
276
- return dot > 0 ? filename.slice(dot).toLowerCase() : null;
277
- }
278
- //#endregion
279
- //#region src/converters/plain-text.ts
350
+ // src/converters/plain-text.ts
280
351
  var PlainTextConverter = class {
281
352
  async convert(source, options = {}) {
282
- if (!isTextExtension(options.file_extension ?? "")) return null;
283
- const content = decodeText(source);
353
+ if (!isTextExtension(options.extension ?? "")) return null;
284
354
  return {
285
355
  title: null,
286
- markdown: content,
287
- text_content: content
356
+ markdown: decodeText(source)
288
357
  };
289
358
  }
290
359
  };
291
- //#endregion
292
- //#region node_modules/.pnpm/process-nextick-args@2.0.1/node_modules/process-nextick-args/index.js
360
+ // node_modules/.pnpm/process-nextick-args@2.0.1/node_modules/process-nextick-args/index.js
293
361
  var require_process_nextick_args = /* @__PURE__ */ __commonJSMin(((exports, module) => {
294
362
  if (typeof process === "undefined" || !process.version || process.version.indexOf("v0.") === 0 || process.version.indexOf("v1.") === 0 && process.version.indexOf("v1.8.") !== 0) module.exports = { nextTick };
295
363
  else module.exports = process;
@@ -319,21 +387,18 @@ var require_process_nextick_args = /* @__PURE__ */ __commonJSMin(((exports, modu
319
387
  }
320
388
  }
321
389
  }));
322
- //#endregion
323
- //#region node_modules/.pnpm/isarray@1.0.0/node_modules/isarray/index.js
390
+ // node_modules/.pnpm/isarray@1.0.0/node_modules/isarray/index.js
324
391
  var require_isarray = /* @__PURE__ */ __commonJSMin(((exports, module) => {
325
392
  var toString = {}.toString;
326
393
  module.exports = Array.isArray || function(arr) {
327
394
  return toString.call(arr) == "[object Array]";
328
395
  };
329
396
  }));
330
- //#endregion
331
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/stream.js
397
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/stream.js
332
398
  var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
333
399
  module.exports = require("stream");
334
400
  }));
335
- //#endregion
336
- //#region node_modules/.pnpm/safe-buffer@5.1.2/node_modules/safe-buffer/index.js
401
+ // node_modules/.pnpm/safe-buffer@5.1.2/node_modules/safe-buffer/index.js
337
402
  var require_safe_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
338
403
  var buffer = require("buffer");
339
404
  var Buffer = buffer.Buffer;
@@ -371,8 +436,7 @@ var require_safe_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
371
436
  return buffer.SlowBuffer(size);
372
437
  };
373
438
  }));
374
- //#endregion
375
- //#region node_modules/.pnpm/core-util-is@1.0.3/node_modules/core-util-is/lib/util.js
439
+ // node_modules/.pnpm/core-util-is@1.0.3/node_modules/core-util-is/lib/util.js
376
440
  var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
377
441
  function isArray(arg) {
378
442
  if (Array.isArray) return Array.isArray(arg);
@@ -436,8 +500,7 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
436
500
  return Object.prototype.toString.call(o);
437
501
  }
438
502
  }));
439
- //#endregion
440
- //#region node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js
503
+ // node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js
441
504
  var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
442
505
  if (typeof Object.create === "function") module.exports = function inherits(ctor, superCtor) {
443
506
  if (superCtor) {
@@ -460,21 +523,19 @@ var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module)
460
523
  }
461
524
  };
462
525
  }));
463
- //#endregion
464
- //#region node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js
526
+ // node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js
465
527
  var require_inherits = /* @__PURE__ */ __commonJSMin(((exports, module) => {
466
528
  try {
467
- var util$1 = require("util");
529
+ var util = require("util");
468
530
  /* istanbul ignore next */
469
- if (typeof util$1.inherits !== "function") throw "";
470
- module.exports = util$1.inherits;
531
+ if (typeof util.inherits !== "function") throw "";
532
+ module.exports = util.inherits;
471
533
  } catch (e) {
472
534
  /* istanbul ignore next */
473
535
  module.exports = require_inherits_browser();
474
536
  }
475
537
  }));
476
- //#endregion
477
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/BufferList.js
538
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/BufferList.js
478
539
  var require_BufferList = /* @__PURE__ */ __commonJSMin(((exports, module) => {
479
540
  function _classCallCheck(instance, Constructor) {
480
541
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
@@ -548,8 +609,7 @@ var require_BufferList = /* @__PURE__ */ __commonJSMin(((exports, module) => {
548
609
  return this.constructor.name + " " + obj;
549
610
  };
550
611
  }));
551
- //#endregion
552
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/destroy.js
612
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/destroy.js
553
613
  var require_destroy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
554
614
  var pna = require_process_nextick_args();
555
615
  function destroy(err, cb) {
@@ -605,16 +665,14 @@ var require_destroy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
605
665
  undestroy
606
666
  };
607
667
  }));
608
- //#endregion
609
- //#region node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/node.js
668
+ // node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/node.js
610
669
  var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
611
670
  /**
612
671
  * For Node.js, simply re-export the core `util.deprecate` function.
613
672
  */
614
673
  module.exports = require("util").deprecate;
615
674
  }));
616
- //#endregion
617
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_writable.js
675
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_writable.js
618
676
  var require__stream_writable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
619
677
  var pna = require_process_nextick_args();
620
678
  module.exports = Writable;
@@ -1018,8 +1076,7 @@ var require__stream_writable = /* @__PURE__ */ __commonJSMin(((exports, module)
1018
1076
  cb(err);
1019
1077
  };
1020
1078
  }));
1021
- //#endregion
1022
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_duplex.js
1079
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_duplex.js
1023
1080
  var require__stream_duplex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1024
1081
  var pna = require_process_nextick_args();
1025
1082
  var objectKeys = Object.keys || function(obj) {
@@ -1078,8 +1135,7 @@ var require__stream_duplex = /* @__PURE__ */ __commonJSMin(((exports, module) =>
1078
1135
  pna.nextTick(cb, err);
1079
1136
  };
1080
1137
  }));
1081
- //#endregion
1082
- //#region node_modules/.pnpm/string_decoder@1.1.1/node_modules/string_decoder/lib/string_decoder.js
1138
+ // node_modules/.pnpm/string_decoder@1.1.1/node_modules/string_decoder/lib/string_decoder.js
1083
1139
  var require_string_decoder = /* @__PURE__ */ __commonJSMin(((exports) => {
1084
1140
  var Buffer = require_safe_buffer().Buffer;
1085
1141
  var isEncoding = Buffer.isEncoding || function(encoding) {
@@ -1302,8 +1358,7 @@ var require_string_decoder = /* @__PURE__ */ __commonJSMin(((exports) => {
1302
1358
  return buf && buf.length ? this.write(buf) : "";
1303
1359
  }
1304
1360
  }));
1305
- //#endregion
1306
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_readable.js
1361
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_readable.js
1307
1362
  var require__stream_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1308
1363
  var pna = require_process_nextick_args();
1309
1364
  module.exports = Readable;
@@ -1939,8 +1994,7 @@ var require__stream_readable = /* @__PURE__ */ __commonJSMin(((exports, module)
1939
1994
  return -1;
1940
1995
  }
1941
1996
  }));
1942
- //#endregion
1943
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_transform.js
1997
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_transform.js
1944
1998
  var require__stream_transform = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1945
1999
  module.exports = Transform;
1946
2000
  var Duplex = require__stream_duplex();
@@ -2025,8 +2079,7 @@ var require__stream_transform = /* @__PURE__ */ __commonJSMin(((exports, module)
2025
2079
  return stream.push(null);
2026
2080
  }
2027
2081
  }));
2028
- //#endregion
2029
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_passthrough.js
2082
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/_stream_passthrough.js
2030
2083
  var require__stream_passthrough = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2031
2084
  module.exports = PassThrough;
2032
2085
  var Transform = require__stream_transform();
@@ -2041,8 +2094,7 @@ var require__stream_passthrough = /* @__PURE__ */ __commonJSMin(((exports, modul
2041
2094
  cb(null, chunk);
2042
2095
  };
2043
2096
  }));
2044
- //#endregion
2045
- //#region node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/readable.js
2097
+ // node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/readable.js
2046
2098
  var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2047
2099
  var Stream = require("stream");
2048
2100
  if (process.env.READABLE_STREAM === "disable" && Stream) {
@@ -2064,8 +2116,7 @@ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2064
2116
  exports.PassThrough = require__stream_passthrough();
2065
2117
  }
2066
2118
  }));
2067
- //#endregion
2068
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/support.js
2119
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/support.js
2069
2120
  var require_support = /* @__PURE__ */ __commonJSMin(((exports) => {
2070
2121
  exports.base64 = true;
2071
2122
  exports.array = true;
@@ -2094,8 +2145,7 @@ var require_support = /* @__PURE__ */ __commonJSMin(((exports) => {
2094
2145
  exports.nodestream = false;
2095
2146
  }
2096
2147
  }));
2097
- //#endregion
2098
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/base64.js
2148
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/base64.js
2099
2149
  var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
2100
2150
  var utils = require_utils();
2101
2151
  var support = require_support();
@@ -2153,8 +2203,7 @@ var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
2153
2203
  return output;
2154
2204
  };
2155
2205
  }));
2156
- //#endregion
2157
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/nodejsUtils.js
2206
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/nodejsUtils.js
2158
2207
  var require_nodejsUtils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2159
2208
  module.exports = {
2160
2209
  /**
@@ -2202,8 +2251,7 @@ var require_nodejsUtils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2202
2251
  }
2203
2252
  };
2204
2253
  }));
2205
- //#endregion
2206
- //#region node_modules/.pnpm/immediate@3.0.6/node_modules/immediate/lib/index.js
2254
+ // node_modules/.pnpm/immediate@3.0.6/node_modules/immediate/lib/index.js
2207
2255
  var require_lib$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2208
2256
  var Mutation = global.MutationObserver || global.WebKitMutationObserver;
2209
2257
  var scheduleDrain;
@@ -2258,8 +2306,7 @@ var require_lib$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2258
2306
  if (queue.push(task) === 1 && !draining) scheduleDrain();
2259
2307
  }
2260
2308
  }));
2261
- //#endregion
2262
- //#region node_modules/.pnpm/lie@3.3.0/node_modules/lie/lib/index.js
2309
+ // node_modules/.pnpm/lie@3.3.0/node_modules/lie/lib/index.js
2263
2310
  var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2264
2311
  var immediate = require_lib$2();
2265
2312
  /* istanbul ignore next */
@@ -2474,8 +2521,7 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2474
2521
  }
2475
2522
  }
2476
2523
  }));
2477
- //#endregion
2478
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/external.js
2524
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/external.js
2479
2525
  var require_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2480
2526
  var ES6Promise = null;
2481
2527
  if (typeof Promise !== "undefined") ES6Promise = Promise;
@@ -2485,8 +2531,7 @@ var require_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2485
2531
  */
2486
2532
  module.exports = { Promise: ES6Promise };
2487
2533
  }));
2488
- //#endregion
2489
- //#region node_modules/.pnpm/setimmediate@1.0.5/node_modules/setimmediate/setImmediate.js
2534
+ // node_modules/.pnpm/setimmediate@1.0.5/node_modules/setimmediate/setImmediate.js
2490
2535
  var require_setImmediate = /* @__PURE__ */ __commonJSMin((() => {
2491
2536
  (function(global, undefined) {
2492
2537
  "use strict";
@@ -2613,8 +2658,7 @@ var require_setImmediate = /* @__PURE__ */ __commonJSMin((() => {
2613
2658
  attachTo.clearImmediate = clearImmediate;
2614
2659
  })(typeof self === "undefined" ? typeof global === "undefined" ? void 0 : global : self);
2615
2660
  }));
2616
- //#endregion
2617
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/utils.js
2661
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/utils.js
2618
2662
  var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
2619
2663
  var support = require_support();
2620
2664
  var base64 = require_base64();
@@ -2877,10 +2921,11 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
2877
2921
  */
2878
2922
  exports.getTypeOf = function(input) {
2879
2923
  if (typeof input === "string") return "string";
2880
- if (Object.prototype.toString.call(input) === "[object Array]") return "array";
2924
+ var proto = Object.prototype.toString.call(input);
2925
+ if (proto === "[object Array]") return "array";
2881
2926
  if (support.nodebuffer && nodejsUtils.isBuffer(input)) return "nodebuffer";
2882
- if (support.uint8array && input instanceof Uint8Array) return "uint8array";
2883
- if (support.arraybuffer && input instanceof ArrayBuffer) return "arraybuffer";
2927
+ if (support.uint8array && proto === "[object Uint8Array]") return "uint8array";
2928
+ if (support.arraybuffer && proto === "[object ArrayBuffer]") return "arraybuffer";
2884
2929
  };
2885
2930
  /**
2886
2931
  * Throw an exception if the type is not supported.
@@ -2898,8 +2943,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
2898
2943
  * @return {string} a pretty string.
2899
2944
  */
2900
2945
  exports.pretty = function(str) {
2901
- var res = "", code, i;
2902
- for (i = 0; i < (str || "").length; i++) {
2946
+ var res = "", code, i = 0;
2947
+ for (; i < (str || "").length; i++) {
2903
2948
  code = str.charCodeAt(i);
2904
2949
  res += "\\x" + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
2905
2950
  }
@@ -2933,8 +2978,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
2933
2978
  * @return {Object} a new object with the data of the others.
2934
2979
  */
2935
2980
  exports.extend = function() {
2936
- var result = {}, i, attr;
2937
- for (i = 0; i < arguments.length; i++) for (attr in arguments[i]) if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === "undefined") result[attr] = arguments[i][attr];
2981
+ var result = {}, i = 0, attr;
2982
+ for (; i < arguments.length; i++) for (attr in arguments[i]) if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === "undefined") result[attr] = arguments[i][attr];
2938
2983
  return result;
2939
2984
  };
2940
2985
  /**
@@ -2948,17 +2993,21 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
2948
2993
  */
2949
2994
  exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
2950
2995
  return external.Promise.resolve(inputData).then(function(data) {
2951
- if (support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1) && typeof FileReader !== "undefined") return new external.Promise(function(resolve, reject) {
2952
- var reader = new FileReader();
2953
- reader.onload = function(e) {
2954
- resolve(e.target.result);
2955
- };
2956
- reader.onerror = function(e) {
2957
- reject(e.target.error);
2958
- };
2959
- reader.readAsArrayBuffer(data);
2960
- });
2961
- else return data;
2996
+ if (support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1)) {
2997
+ if (typeof Blob.prototype.arrayBuffer !== "undefined") return data.arrayBuffer();
2998
+ else if (typeof FileReader !== "undefined") return new external.Promise(function(resolve, reject) {
2999
+ var reader = new FileReader();
3000
+ reader.onload = function(e) {
3001
+ resolve(e.target.result);
3002
+ };
3003
+ reader.onerror = function(e) {
3004
+ reject(e.target.error);
3005
+ };
3006
+ reader.readAsArrayBuffer(data);
3007
+ });
3008
+ else return external.Promise.reject(/* @__PURE__ */ new Error(name + " is a Blob, but we have no way of reading it."));
3009
+ }
3010
+ return data;
2962
3011
  }).then(function(data) {
2963
3012
  var dataType = exports.getTypeOf(data);
2964
3013
  if (!dataType) return external.Promise.reject(/* @__PURE__ */ new Error("Can't read the data of '" + name + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
@@ -2973,8 +3022,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
2973
3022
  });
2974
3023
  };
2975
3024
  }));
2976
- //#endregion
2977
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/stream/GenericWorker.js
3025
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/stream/GenericWorker.js
2978
3026
  var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2979
3027
  /**
2980
3028
  * A worker that does nothing but passing chunks to the next one. This is like
@@ -3180,8 +3228,7 @@ var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
3180
3228
  };
3181
3229
  module.exports = GenericWorker;
3182
3230
  }));
3183
- //#endregion
3184
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/utf8.js
3231
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/utf8.js
3185
3232
  var require_utf8 = /* @__PURE__ */ __commonJSMin(((exports) => {
3186
3233
  var utils = require_utils();
3187
3234
  var support = require_support();
@@ -3375,8 +3422,7 @@ var require_utf8 = /* @__PURE__ */ __commonJSMin(((exports) => {
3375
3422
  };
3376
3423
  exports.Utf8EncodeWorker = Utf8EncodeWorker;
3377
3424
  }));
3378
- //#endregion
3379
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/stream/ConvertWorker.js
3425
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/stream/ConvertWorker.js
3380
3426
  var require_ConvertWorker = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3381
3427
  var GenericWorker = require_GenericWorker();
3382
3428
  var utils = require_utils();
@@ -3401,8 +3447,7 @@ var require_ConvertWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
3401
3447
  };
3402
3448
  module.exports = ConvertWorker;
3403
3449
  }));
3404
- //#endregion
3405
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js
3450
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js
3406
3451
  var require_NodejsStreamOutputAdapter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3407
3452
  var Readable = require_readable().Readable;
3408
3453
  require_utils().inherits(NodejsStreamOutputAdapter, Readable);
@@ -3432,8 +3477,7 @@ var require_NodejsStreamOutputAdapter = /* @__PURE__ */ __commonJSMin(((exports,
3432
3477
  };
3433
3478
  module.exports = NodejsStreamOutputAdapter;
3434
3479
  }));
3435
- //#endregion
3436
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/stream/StreamHelper.js
3480
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/stream/StreamHelper.js
3437
3481
  var require_StreamHelper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3438
3482
  var utils = require_utils();
3439
3483
  var ConvertWorker = require_ConvertWorker();
@@ -3597,8 +3641,7 @@ var require_StreamHelper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3597
3641
  };
3598
3642
  module.exports = StreamHelper;
3599
3643
  }));
3600
- //#endregion
3601
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/defaults.js
3644
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/defaults.js
3602
3645
  var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
3603
3646
  exports.base64 = false;
3604
3647
  exports.binary = false;
@@ -3611,8 +3654,7 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
3611
3654
  exports.unixPermissions = null;
3612
3655
  exports.dosPermissions = null;
3613
3656
  }));
3614
- //#endregion
3615
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/stream/DataWorker.js
3657
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/stream/DataWorker.js
3616
3658
  var require_DataWorker = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3617
3659
  var utils = require_utils();
3618
3660
  var GenericWorker = require_GenericWorker();
@@ -3700,8 +3742,7 @@ var require_DataWorker = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3700
3742
  };
3701
3743
  module.exports = DataWorker;
3702
3744
  }));
3703
- //#endregion
3704
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/crc32.js
3745
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/crc32.js
3705
3746
  var require_crc32$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3706
3747
  var utils = require_utils();
3707
3748
  /**
@@ -3746,8 +3787,7 @@ var require_crc32$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3746
3787
  else return crc32str(crc | 0, input, input.length, 0);
3747
3788
  };
3748
3789
  }));
3749
- //#endregion
3750
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/stream/Crc32Probe.js
3790
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/stream/Crc32Probe.js
3751
3791
  var require_Crc32Probe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3752
3792
  var GenericWorker = require_GenericWorker();
3753
3793
  var crc32 = require_crc32$1();
@@ -3770,8 +3810,7 @@ var require_Crc32Probe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3770
3810
  };
3771
3811
  module.exports = Crc32Probe;
3772
3812
  }));
3773
- //#endregion
3774
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/stream/DataLengthProbe.js
3813
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/stream/DataLengthProbe.js
3775
3814
  var require_DataLengthProbe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3776
3815
  var utils = require_utils();
3777
3816
  var GenericWorker = require_GenericWorker();
@@ -3798,8 +3837,7 @@ var require_DataLengthProbe = /* @__PURE__ */ __commonJSMin(((exports, module) =
3798
3837
  };
3799
3838
  module.exports = DataLengthProbe;
3800
3839
  }));
3801
- //#endregion
3802
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/compressedObject.js
3840
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/compressedObject.js
3803
3841
  var require_compressedObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3804
3842
  var external = require_external();
3805
3843
  var DataWorker = require_DataWorker();
@@ -3855,8 +3893,7 @@ var require_compressedObject = /* @__PURE__ */ __commonJSMin(((exports, module)
3855
3893
  };
3856
3894
  module.exports = CompressedObject;
3857
3895
  }));
3858
- //#endregion
3859
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/zipObject.js
3896
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/zipObject.js
3860
3897
  var require_zipObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3861
3898
  var StreamHelper = require_StreamHelper();
3862
3899
  var DataWorker = require_DataWorker();
@@ -3964,8 +4001,7 @@ var require_zipObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3964
4001
  for (var i = 0; i < removedMethods.length; i++) ZipObject.prototype[removedMethods[i]] = removedFn;
3965
4002
  module.exports = ZipObject;
3966
4003
  }));
3967
- //#endregion
3968
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/common.js
4004
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/common.js
3969
4005
  var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
3970
4006
  var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
3971
4007
  function _has(obj, key) {
@@ -4031,8 +4067,7 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
4031
4067
  };
4032
4068
  exports.setTyped(TYPED_OK);
4033
4069
  }));
4034
- //#endregion
4035
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/trees.js
4070
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/trees.js
4036
4071
  var require_trees = /* @__PURE__ */ __commonJSMin(((exports) => {
4037
4072
  var utils = require_common();
4038
4073
  var Z_FIXED = 4;
@@ -4357,8 +4392,8 @@ var require_trees = /* @__PURE__ */ __commonJSMin(((exports) => {
4357
4392
  static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);
4358
4393
  }
4359
4394
  function init_block(s) {
4360
- var n;
4361
- for (n = 0; n < L_CODES; n++) s.dyn_ltree[n * 2] = 0;
4395
+ var n = 0;
4396
+ for (; n < L_CODES; n++) s.dyn_ltree[n * 2] = 0;
4362
4397
  for (n = 0; n < D_CODES; n++) s.dyn_dtree[n * 2] = 0;
4363
4398
  for (n = 0; n < BL_CODES; n++) s.bl_tree[n * 2] = 0;
4364
4399
  s.dyn_ltree[END_BLOCK * 2] = 1;
@@ -4574,8 +4609,8 @@ var require_trees = /* @__PURE__ */ __commonJSMin(((exports) => {
4574
4609
  }
4575
4610
  function detect_data_type(s) {
4576
4611
  var black_mask = 4093624447;
4577
- var n;
4578
- for (n = 0; n <= 31; n++, black_mask >>>= 1) if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) return Z_BINARY;
4612
+ var n = 0;
4613
+ for (; n <= 31; n++, black_mask >>>= 1) if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) return Z_BINARY;
4579
4614
  if (s.dyn_ltree[18] !== 0 || s.dyn_ltree[20] !== 0 || s.dyn_ltree[26] !== 0) return Z_TEXT;
4580
4615
  for (n = 32; n < LITERALS; n++) if (s.dyn_ltree[n * 2] !== 0) return Z_TEXT;
4581
4616
  return Z_BINARY;
@@ -4646,8 +4681,7 @@ var require_trees = /* @__PURE__ */ __commonJSMin(((exports) => {
4646
4681
  exports._tr_tally = _tr_tally;
4647
4682
  exports._tr_align = _tr_align;
4648
4683
  }));
4649
- //#endregion
4650
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/adler32.js
4684
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/adler32.js
4651
4685
  var require_adler32 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4652
4686
  function adler32(adler, buf, len, pos) {
4653
4687
  var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;
@@ -4665,8 +4699,7 @@ var require_adler32 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4665
4699
  }
4666
4700
  module.exports = adler32;
4667
4701
  }));
4668
- //#endregion
4669
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/crc32.js
4702
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/crc32.js
4670
4703
  var require_crc32 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4671
4704
  function makeTable() {
4672
4705
  var c, table = [];
@@ -4686,8 +4719,7 @@ var require_crc32 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4686
4719
  }
4687
4720
  module.exports = crc32;
4688
4721
  }));
4689
- //#endregion
4690
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/messages.js
4722
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/messages.js
4691
4723
  var require_messages = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4692
4724
  module.exports = {
4693
4725
  2: "need dictionary",
@@ -4701,8 +4733,7 @@ var require_messages = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4701
4733
  "-6": "incompatible version"
4702
4734
  };
4703
4735
  }));
4704
- //#endregion
4705
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/deflate.js
4736
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/deflate.js
4706
4737
  var require_deflate$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
4707
4738
  var utils = require_common();
4708
4739
  var trees = require_trees();
@@ -4820,8 +4851,8 @@ var require_deflate$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
4820
4851
  if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) continue;
4821
4852
  scan += 2;
4822
4853
  match++;
4823
- do ;
4824
- while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);
4854
+ do;
4855
+ while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);
4825
4856
  len = MAX_MATCH - (strend - scan);
4826
4857
  scan = strend - MAX_MATCH;
4827
4858
  if (len > best_len) {
@@ -5078,8 +5109,8 @@ while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[
5078
5109
  prev = _win[scan];
5079
5110
  if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
5080
5111
  strend = s.strstart + MAX_MATCH;
5081
- do ;
5082
- while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);
5112
+ do;
5113
+ while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);
5083
5114
  s.match_length = MAX_MATCH - (strend - scan);
5084
5115
  if (s.match_length > s.lookahead) s.match_length = s.lookahead;
5085
5116
  }
@@ -5585,8 +5616,7 @@ while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] &
5585
5616
  exports.deflateSetDictionary = deflateSetDictionary;
5586
5617
  exports.deflateInfo = "pako deflate (from Nodeca project)";
5587
5618
  }));
5588
- //#endregion
5589
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/strings.js
5619
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/strings.js
5590
5620
  var require_strings = /* @__PURE__ */ __commonJSMin(((exports) => {
5591
5621
  var utils = require_common();
5592
5622
  var STR_APPLY_OK = true;
@@ -5705,8 +5735,7 @@ var require_strings = /* @__PURE__ */ __commonJSMin(((exports) => {
5705
5735
  return pos + _utf8len[buf[pos]] > max ? pos : max;
5706
5736
  };
5707
5737
  }));
5708
- //#endregion
5709
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/zstream.js
5738
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/zstream.js
5710
5739
  var require_zstream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5711
5740
  function ZStream() {
5712
5741
  this.input = null;
@@ -5724,8 +5753,7 @@ var require_zstream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5724
5753
  }
5725
5754
  module.exports = ZStream;
5726
5755
  }));
5727
- //#endregion
5728
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/deflate.js
5756
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/deflate.js
5729
5757
  var require_deflate = /* @__PURE__ */ __commonJSMin(((exports) => {
5730
5758
  var zlib_deflate = require_deflate$1();
5731
5759
  var utils = require_common();
@@ -6024,8 +6052,7 @@ var require_deflate = /* @__PURE__ */ __commonJSMin(((exports) => {
6024
6052
  exports.deflateRaw = deflateRaw;
6025
6053
  exports.gzip = gzip;
6026
6054
  }));
6027
- //#endregion
6028
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js
6055
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js
6029
6056
  var require_inffast = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6030
6057
  var BAD = 30;
6031
6058
  var TYPE = 12;
@@ -6241,8 +6268,7 @@ var require_inffast = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6241
6268
  state.bits = bits;
6242
6269
  };
6243
6270
  }));
6244
- //#endregion
6245
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inftrees.js
6271
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inftrees.js
6246
6272
  var require_inftrees = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6247
6273
  var utils = require_common();
6248
6274
  var MAXBITS = 15;
@@ -6508,8 +6534,7 @@ var require_inftrees = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6508
6534
  return 0;
6509
6535
  };
6510
6536
  }));
6511
- //#endregion
6512
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inflate.js
6537
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inflate.js
6513
6538
  var require_inflate$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
6514
6539
  var utils = require_common();
6515
6540
  var adler32 = require_adler32();
@@ -7532,8 +7557,7 @@ var require_inflate$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
7532
7557
  exports.inflateSetDictionary = inflateSetDictionary;
7533
7558
  exports.inflateInfo = "pako inflate (from Nodeca project)";
7534
7559
  }));
7535
- //#endregion
7536
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js
7560
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js
7537
7561
  var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7538
7562
  module.exports = {
7539
7563
  Z_NO_FLUSH: 0,
@@ -7565,8 +7589,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7565
7589
  Z_DEFLATED: 8
7566
7590
  };
7567
7591
  }));
7568
- //#endregion
7569
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/gzheader.js
7592
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/gzheader.js
7570
7593
  var require_gzheader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7571
7594
  function GZheader() {
7572
7595
  this.text = 0;
@@ -7582,8 +7605,7 @@ var require_gzheader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7582
7605
  }
7583
7606
  module.exports = GZheader;
7584
7607
  }));
7585
- //#endregion
7586
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/inflate.js
7608
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/inflate.js
7587
7609
  var require_inflate = /* @__PURE__ */ __commonJSMin(((exports) => {
7588
7610
  var zlib_inflate = require_inflate$1();
7589
7611
  var utils = require_common();
@@ -7886,8 +7908,7 @@ var require_inflate = /* @__PURE__ */ __commonJSMin(((exports) => {
7886
7908
  exports.inflateRaw = inflateRaw;
7887
7909
  exports.ungzip = inflate;
7888
7910
  }));
7889
- //#endregion
7890
- //#region node_modules/.pnpm/pako@1.0.11/node_modules/pako/index.js
7911
+ // node_modules/.pnpm/pako@1.0.11/node_modules/pako/index.js
7891
7912
  var require_pako = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7892
7913
  var assign = require_common().assign;
7893
7914
  var deflate = require_deflate();
@@ -7897,8 +7918,7 @@ var require_pako = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7897
7918
  assign(pako, deflate, inflate, constants);
7898
7919
  module.exports = pako;
7899
7920
  }));
7900
- //#endregion
7901
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/flate.js
7921
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/flate.js
7902
7922
  var require_flate = /* @__PURE__ */ __commonJSMin(((exports) => {
7903
7923
  var USE_TYPEDARRAY = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Uint32Array !== "undefined";
7904
7924
  var pako = require_pako();
@@ -7969,8 +7989,7 @@ var require_flate = /* @__PURE__ */ __commonJSMin(((exports) => {
7969
7989
  return new FlateWorker("Inflate", {});
7970
7990
  };
7971
7991
  }));
7972
- //#endregion
7973
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/compressions.js
7992
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/compressions.js
7974
7993
  var require_compressions = /* @__PURE__ */ __commonJSMin(((exports) => {
7975
7994
  var GenericWorker = require_GenericWorker();
7976
7995
  exports.STORE = {
@@ -7984,8 +8003,7 @@ var require_compressions = /* @__PURE__ */ __commonJSMin(((exports) => {
7984
8003
  };
7985
8004
  exports.DEFLATE = require_flate();
7986
8005
  }));
7987
- //#endregion
7988
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/signature.js
8006
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/signature.js
7989
8007
  var require_signature = /* @__PURE__ */ __commonJSMin(((exports) => {
7990
8008
  exports.LOCAL_FILE_HEADER = "PK";
7991
8009
  exports.CENTRAL_FILE_HEADER = "PK";
@@ -7994,8 +8012,7 @@ var require_signature = /* @__PURE__ */ __commonJSMin(((exports) => {
7994
8012
  exports.ZIP64_CENTRAL_DIRECTORY_END = "PK";
7995
8013
  exports.DATA_DESCRIPTOR = "PK\x07\b";
7996
8014
  }));
7997
- //#endregion
7998
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/generate/ZipFileWorker.js
8015
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/generate/ZipFileWorker.js
7999
8016
  var require_ZipFileWorker = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8000
8017
  var utils = require_utils();
8001
8018
  var GenericWorker = require_GenericWorker();
@@ -8010,8 +8027,8 @@ var require_ZipFileWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
8010
8027
  * @returns {string} the result.
8011
8028
  */
8012
8029
  var decToHex = function(dec, bytes) {
8013
- var hex = "", i;
8014
- for (i = 0; i < bytes; i++) {
8030
+ var hex = "", i = 0;
8031
+ for (; i < bytes; i++) {
8015
8032
  hex += String.fromCharCode(dec & 255);
8016
8033
  dec = dec >>> 8;
8017
8034
  }
@@ -8308,8 +8325,7 @@ var require_ZipFileWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
8308
8325
  };
8309
8326
  module.exports = ZipFileWorker;
8310
8327
  }));
8311
- //#endregion
8312
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/generate/index.js
8328
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/generate/index.js
8313
8329
  var require_generate = /* @__PURE__ */ __commonJSMin(((exports) => {
8314
8330
  var compressions = require_compressions();
8315
8331
  var ZipFileWorker = require_ZipFileWorker();
@@ -8356,8 +8372,7 @@ var require_generate = /* @__PURE__ */ __commonJSMin(((exports) => {
8356
8372
  return zipFileWorker;
8357
8373
  };
8358
8374
  }));
8359
- //#endregion
8360
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js
8375
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js
8361
8376
  var require_NodejsStreamInputAdapter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8362
8377
  var utils = require_utils();
8363
8378
  var GenericWorker = require_GenericWorker();
@@ -8408,8 +8423,7 @@ var require_NodejsStreamInputAdapter = /* @__PURE__ */ __commonJSMin(((exports,
8408
8423
  };
8409
8424
  module.exports = NodejsStreamInputAdapter;
8410
8425
  }));
8411
- //#endregion
8412
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/object.js
8426
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/object.js
8413
8427
  var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8414
8428
  var utf8 = require_utf8();
8415
8429
  var utils = require_utils();
@@ -8660,8 +8674,7 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8660
8674
  }
8661
8675
  };
8662
8676
  }));
8663
- //#endregion
8664
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/reader/DataReader.js
8677
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/reader/DataReader.js
8665
8678
  var require_DataReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8666
8679
  var utils = require_utils();
8667
8680
  function DataReader(data) {
@@ -8759,8 +8772,7 @@ var require_DataReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8759
8772
  };
8760
8773
  module.exports = DataReader;
8761
8774
  }));
8762
- //#endregion
8763
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/reader/ArrayReader.js
8775
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/reader/ArrayReader.js
8764
8776
  var require_ArrayReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8765
8777
  var DataReader = require_DataReader();
8766
8778
  var utils = require_utils();
@@ -8802,8 +8814,7 @@ var require_ArrayReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8802
8814
  };
8803
8815
  module.exports = ArrayReader;
8804
8816
  }));
8805
- //#endregion
8806
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/reader/StringReader.js
8817
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/reader/StringReader.js
8807
8818
  var require_StringReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8808
8819
  var DataReader = require_DataReader();
8809
8820
  var utils = require_utils();
@@ -8840,8 +8851,7 @@ var require_StringReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8840
8851
  };
8841
8852
  module.exports = StringReader;
8842
8853
  }));
8843
- //#endregion
8844
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/reader/Uint8ArrayReader.js
8854
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/reader/Uint8ArrayReader.js
8845
8855
  var require_Uint8ArrayReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8846
8856
  var ArrayReader = require_ArrayReader();
8847
8857
  var utils = require_utils();
@@ -8861,8 +8871,7 @@ var require_Uint8ArrayReader = /* @__PURE__ */ __commonJSMin(((exports, module)
8861
8871
  };
8862
8872
  module.exports = Uint8ArrayReader;
8863
8873
  }));
8864
- //#endregion
8865
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/reader/NodeBufferReader.js
8874
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/reader/NodeBufferReader.js
8866
8875
  var require_NodeBufferReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8867
8876
  var Uint8ArrayReader = require_Uint8ArrayReader();
8868
8877
  var utils = require_utils();
@@ -8881,8 +8890,7 @@ var require_NodeBufferReader = /* @__PURE__ */ __commonJSMin(((exports, module)
8881
8890
  };
8882
8891
  module.exports = NodeBufferReader;
8883
8892
  }));
8884
- //#endregion
8885
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/reader/readerFor.js
8893
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/reader/readerFor.js
8886
8894
  var require_readerFor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8887
8895
  var utils = require_utils();
8888
8896
  var support = require_support();
@@ -8904,8 +8912,7 @@ var require_readerFor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8904
8912
  return new ArrayReader(utils.transformTo("array", data));
8905
8913
  };
8906
8914
  }));
8907
- //#endregion
8908
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/zipEntry.js
8915
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/zipEntry.js
8909
8916
  var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8910
8917
  var readerFor = require_readerFor();
8911
8918
  var utils = require_utils();
@@ -9092,8 +9099,7 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9092
9099
  };
9093
9100
  module.exports = ZipEntry;
9094
9101
  }));
9095
- //#endregion
9096
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/zipEntries.js
9102
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/zipEntries.js
9097
9103
  var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9098
9104
  var readerFor = require_readerFor();
9099
9105
  var utils = require_utils();
@@ -9192,8 +9198,8 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9192
9198
  * Read the local files, based on the offset read in the central part.
9193
9199
  */
9194
9200
  readLocalFiles: function() {
9195
- var i, file;
9196
- for (i = 0; i < this.files.length; i++) {
9201
+ var i = 0, file;
9202
+ for (; i < this.files.length; i++) {
9197
9203
  file = this.files[i];
9198
9204
  this.reader.setIndex(file.localHeaderOffset);
9199
9205
  this.checkSignature(sig.LOCAL_FILE_HEADER);
@@ -9271,8 +9277,7 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9271
9277
  };
9272
9278
  module.exports = ZipEntries;
9273
9279
  }));
9274
- //#endregion
9275
- //#region node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/load.js
9280
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/load.js
9276
9281
  var require_load = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9277
9282
  var utils = require_utils();
9278
9283
  var external = require_external();
@@ -9339,9 +9344,8 @@ var require_load = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9339
9344
  });
9340
9345
  };
9341
9346
  }));
9342
- //#endregion
9343
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/typeof.js
9344
- var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
9347
+ // node_modules/.pnpm/jszip@3.10.2/node_modules/jszip/lib/index.js
9348
+ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9345
9349
  /**
9346
9350
  * Representation a of zip file in js
9347
9351
  * @constructor
@@ -9362,13 +9366,14 @@ var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((export
9362
9366
  JSZip.prototype.loadAsync = require_load();
9363
9367
  JSZip.support = require_support();
9364
9368
  JSZip.defaults = require_defaults();
9365
- JSZip.version = "3.10.1";
9369
+ JSZip.version = "3.10.2";
9366
9370
  JSZip.loadAsync = function(content, options) {
9367
9371
  return new JSZip().loadAsync(content, options);
9368
9372
  };
9369
9373
  JSZip.external = require_external();
9370
9374
  module.exports = JSZip;
9371
- })))(), 1);
9375
+ }));
9376
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/typeof.js
9372
9377
  function _typeof(o) {
9373
9378
  "@babel/helpers - typeof";
9374
9379
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -9377,8 +9382,7 @@ function _typeof(o) {
9377
9382
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
9378
9383
  }, _typeof(o);
9379
9384
  }
9380
- //#endregion
9381
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPrimitive.js
9385
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/toPrimitive.js
9382
9386
  function toPrimitive(t, r) {
9383
9387
  if ("object" != _typeof(t) || !t) return t;
9384
9388
  var e = t[Symbol.toPrimitive];
@@ -9389,14 +9393,12 @@ function toPrimitive(t, r) {
9389
9393
  }
9390
9394
  return ("string" === r ? String : Number)(t);
9391
9395
  }
9392
- //#endregion
9393
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPropertyKey.js
9396
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/toPropertyKey.js
9394
9397
  function toPropertyKey(t) {
9395
9398
  var i = toPrimitive(t, "string");
9396
9399
  return "symbol" == _typeof(i) ? i : i + "";
9397
9400
  }
9398
- //#endregion
9399
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/defineProperty.js
9401
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/defineProperty.js
9400
9402
  function _defineProperty(e, r, t) {
9401
9403
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
9402
9404
  value: t,
@@ -9405,8 +9407,8 @@ function _defineProperty(e, r, t) {
9405
9407
  writable: !0
9406
9408
  }) : e[r] = t, e;
9407
9409
  }
9408
- //#endregion
9409
- //#region node_modules/.pnpm/@jvmr+pptx-to-html@1.1.1/node_modules/@jvmr/pptx-to-html/dist/index.js
9410
+ // node_modules/.pnpm/@jvmr+pptx-to-html@1.1.2/node_modules/@jvmr/pptx-to-html/dist/index.js
9411
+ var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
9410
9412
  var _XmlHelper;
9411
9413
  function libWarn(msg) {
9412
9414
  if (typeof console !== "undefined" && console.warn) console.warn(`[pptx-to-html] ${msg}`);
@@ -9446,6 +9448,56 @@ var XmlHelper = (_XmlHelper = class XmlHelper {
9446
9448
  if (!top || top.parentElement !== spTree) return 0;
9447
9449
  return Array.from(spTree.children).indexOf(top);
9448
9450
  }
9451
+ /**
9452
+ * Resolves a drawing object's transform into slide coordinates. Child objects
9453
+ * inside a `p:grpSp` are expressed in the group's child coordinate system,
9454
+ * so using their local `a:xfrm` directly places them incorrectly.
9455
+ */
9456
+ static getAbsoluteTransform(element, spTree) {
9457
+ const readTransform = (node) => {
9458
+ const xfrm = node.getElementsByTagNameNS("*", "xfrm")[0] ?? null;
9459
+ const off = xfrm?.getElementsByTagNameNS("*", "off")[0] ?? null;
9460
+ const ext = xfrm?.getElementsByTagNameNS("*", "ext")[0] ?? null;
9461
+ const chOff = xfrm?.getElementsByTagNameNS("*", "chOff")[0] ?? null;
9462
+ const chExt = xfrm?.getElementsByTagNameNS("*", "chExt")[0] ?? null;
9463
+ return {
9464
+ xfrm,
9465
+ x: off ? XmlHelper.getAttrAsNumber(off, "x") : 0,
9466
+ y: off ? XmlHelper.getAttrAsNumber(off, "y") : 0,
9467
+ cx: ext ? XmlHelper.getAttrAsNumber(ext, "cx") : 1e6,
9468
+ cy: ext ? XmlHelper.getAttrAsNumber(ext, "cy") : 5e5,
9469
+ chX: chOff ? XmlHelper.getAttrAsNumber(chOff, "x") : 0,
9470
+ chY: chOff ? XmlHelper.getAttrAsNumber(chOff, "y") : 0,
9471
+ chCx: chExt ? XmlHelper.getAttrAsNumber(chExt, "cx") : 0,
9472
+ chCy: chExt ? XmlHelper.getAttrAsNumber(chExt, "cy") : 0,
9473
+ rotationDeg: xfrm?.getAttribute("rot") ? Number(xfrm.getAttribute("rot")) / 6e4 : 0
9474
+ };
9475
+ };
9476
+ const own = readTransform(element);
9477
+ let { x, y, cx, cy } = own;
9478
+ let rotationDeg = own.rotationDeg;
9479
+ let parent = element.parentElement;
9480
+ while (parent && parent !== spTree) {
9481
+ if (parent.localName === "grpSp") {
9482
+ const group = readTransform(parent);
9483
+ const sx = group.chCx > 0 ? group.cx / group.chCx : 1;
9484
+ const sy = group.chCy > 0 ? group.cy / group.chCy : 1;
9485
+ x = group.x + (x - group.chX) * sx;
9486
+ y = group.y + (y - group.chY) * sy;
9487
+ cx *= sx;
9488
+ cy *= sy;
9489
+ rotationDeg += group.rotationDeg;
9490
+ }
9491
+ parent = parent.parentElement;
9492
+ }
9493
+ return {
9494
+ x,
9495
+ y,
9496
+ cx,
9497
+ cy,
9498
+ rotationDeg: rotationDeg || void 0
9499
+ };
9500
+ }
9449
9501
  static getColorFromElement(el, themeColors) {
9450
9502
  if (!el) return void 0;
9451
9503
  const srgb = el.getElementsByTagNameNS("*", "srgbClr")[0];
@@ -9710,15 +9762,11 @@ var TextExtractor = class {
9710
9762
  }
9711
9763
  if (content === "") continue;
9712
9764
  const xfrm = shape.getElementsByTagNameNS("*", "xfrm")[0];
9713
- let off = xfrm?.getElementsByTagNameNS("*", "off")[0] ?? null;
9714
- let ext = xfrm?.getElementsByTagNameNS("*", "ext")[0] ?? null;
9715
- let x, y, cx, cy;
9716
- if (off && ext) {
9717
- x = XmlHelper.getAttrAsNumber(off, "x");
9718
- y = XmlHelper.getAttrAsNumber(off, "y");
9719
- cx = XmlHelper.getAttrAsNumber(ext, "cx");
9720
- cy = XmlHelper.getAttrAsNumber(ext, "cy");
9721
- } else if (opts.placeholderGeom) {
9765
+ const off = xfrm?.getElementsByTagNameNS("*", "off")[0] ?? null;
9766
+ const ext = xfrm?.getElementsByTagNameNS("*", "ext")[0] ?? null;
9767
+ let x, y, cx, cy, rotationDeg;
9768
+ if (off && ext) ({x, y, cx, cy, rotationDeg} = XmlHelper.getAbsoluteTransform(shape, spTree));
9769
+ else if (opts.placeholderGeom) {
9722
9770
  const g = (phIdx ? opts.placeholderGeom[phIdx] : void 0) ?? (phType ? opts.placeholderGeom["type:" + phType] : void 0);
9723
9771
  x = g?.x ?? 0;
9724
9772
  y = g?.y ?? 0;
@@ -9767,6 +9815,7 @@ var TextExtractor = class {
9767
9815
  const element = {
9768
9816
  type: "text",
9769
9817
  zIndex: XmlHelper.getZIndex(shape, spTree),
9818
+ rotationDeg,
9770
9819
  content,
9771
9820
  position: {
9772
9821
  x,
@@ -9880,13 +9929,14 @@ var ImageExtractor = class {
9880
9929
  if (!imageFile) continue;
9881
9930
  const binary = await imageFile.async("base64");
9882
9931
  const dataUri = `data:${imageMimeType(normalizedPath)};base64,${binary}`;
9883
- const xfrm = pic.getElementsByTagNameNS("*", "xfrm")[0];
9884
- const off = xfrm?.getElementsByTagNameNS("*", "off")[0];
9885
- const ext = xfrm?.getElementsByTagNameNS("*", "ext")[0];
9886
- const x = off ? XmlHelper.getAttrAsNumber(off, "x") : 0;
9887
- const y = off ? XmlHelper.getAttrAsNumber(off, "y") : 0;
9888
- const cx = ext ? XmlHelper.getAttrAsNumber(ext, "cx") : 1e6;
9889
- const cy = ext ? XmlHelper.getAttrAsNumber(ext, "cy") : 5e5;
9932
+ const { x, y, cx, cy, rotationDeg } = XmlHelper.getAbsoluteTransform(pic, spTree);
9933
+ const srcRect = pic.getElementsByTagNameNS("*", "srcRect")[0] ?? null;
9934
+ const crop = srcRect ? {
9935
+ left: Math.max(0, Number(srcRect.getAttribute("l") || 0)),
9936
+ top: Math.max(0, Number(srcRect.getAttribute("t") || 0)),
9937
+ right: Math.max(0, Number(srcRect.getAttribute("r") || 0)),
9938
+ bottom: Math.max(0, Number(srcRect.getAttribute("b") || 0))
9939
+ } : void 0;
9890
9940
  const element = {
9891
9941
  type: "image",
9892
9942
  zIndex: XmlHelper.getZIndex(pic, spTree),
@@ -9899,7 +9949,9 @@ var ImageExtractor = class {
9899
9949
  size: {
9900
9950
  width: cx,
9901
9951
  height: cy
9902
- }
9952
+ },
9953
+ crop,
9954
+ rotationDeg
9903
9955
  };
9904
9956
  elements.push(element);
9905
9957
  }
@@ -9912,10 +9964,11 @@ var ImageExtractor = class {
9912
9964
  * @returns Normalized path inside the zip (e.g. "ppt/media/image1.png")
9913
9965
  */
9914
9966
  static normalizePath(target, basePath) {
9967
+ if (target.startsWith("/")) return target.slice(1);
9915
9968
  const parts = (basePath + "/" + target).split("/");
9916
9969
  const resolved = [];
9917
9970
  for (const part of parts) if (part === "..") resolved.pop();
9918
- else if (part !== ".") resolved.push(part);
9971
+ else if (part !== "." && part !== "") resolved.push(part);
9919
9972
  return resolved.join("/");
9920
9973
  }
9921
9974
  };
@@ -9934,15 +9987,7 @@ var ShapeExtractor = class {
9934
9987
  const elements = [];
9935
9988
  const allShapes = [...Array.from(spTree.getElementsByTagNameNS("*", "sp")), ...Array.from(spTree.getElementsByTagNameNS("*", "cxnSp"))];
9936
9989
  for (const shape of allShapes) {
9937
- const xfrm = shape.getElementsByTagNameNS("*", "xfrm")[0];
9938
- const off = xfrm?.getElementsByTagNameNS("*", "off")[0];
9939
- const ext = xfrm?.getElementsByTagNameNS("*", "ext")[0];
9940
- const x = off ? XmlHelper.getAttrAsNumber(off, "x") : 0;
9941
- const y = off ? XmlHelper.getAttrAsNumber(off, "y") : 0;
9942
- const cx = ext ? XmlHelper.getAttrAsNumber(ext, "cx") : 1e6;
9943
- const cy = ext ? XmlHelper.getAttrAsNumber(ext, "cy") : 5e5;
9944
- const rotAttr = xfrm?.getAttribute("rot");
9945
- const rotationDeg = rotAttr ? Number(rotAttr) / 6e4 : void 0;
9990
+ const { x, y, cx, cy, rotationDeg } = XmlHelper.getAbsoluteTransform(shape, spTree);
9946
9991
  const shapeType = shape.getElementsByTagNameNS("*", "prstGeom")[0]?.getAttribute("prst") ?? "rect";
9947
9992
  const spPr = shape.getElementsByTagNameNS("*", "spPr")[0];
9948
9993
  let fillColor = "transparent";
@@ -10013,13 +10058,7 @@ var TableExtractor = class {
10013
10058
  for (const gf of Array.from(gFrames)) {
10014
10059
  const tbl = this.findTbl(gf);
10015
10060
  if (!tbl) continue;
10016
- const xfrm = gf.getElementsByTagNameNS("*", "xfrm")[0] ?? null;
10017
- const off = xfrm?.getElementsByTagNameNS("*", "off")[0] ?? null;
10018
- const ext = xfrm?.getElementsByTagNameNS("*", "ext")[0] ?? null;
10019
- const x = off ? XmlHelper.getAttrAsNumber(off, "x") : 0;
10020
- const y = off ? XmlHelper.getAttrAsNumber(off, "y") : 0;
10021
- const cx = ext ? XmlHelper.getAttrAsNumber(ext, "cx") : 1e6;
10022
- const cy = ext ? XmlHelper.getAttrAsNumber(ext, "cy") : 5e5;
10061
+ const { x, y, cx, cy, rotationDeg } = XmlHelper.getAbsoluteTransform(gf, spTree);
10023
10062
  const columns = [];
10024
10063
  const grid = tbl.getElementsByTagNameNS("*", "tblGrid")[0] ?? null;
10025
10064
  if (grid) for (const col of Array.from(grid.getElementsByTagNameNS("*", "gridCol"))) {
@@ -10047,9 +10086,10 @@ var TableExtractor = class {
10047
10086
  for (const tr of Array.from(tbl.getElementsByTagNameNS("*", "tr"))) {
10048
10087
  const cells = [];
10049
10088
  for (const tc of Array.from(tr.getElementsByTagNameNS("*", "tc"))) {
10089
+ const tcPr = tc.getElementsByTagNameNS("*", "tcPr")[0] ?? null;
10090
+ if (tcPr?.getAttribute("hMerge") === "1" || tcPr?.getAttribute("hMerge") === "true" || tcPr?.getAttribute("vMerge") === "1" || tcPr?.getAttribute("vMerge") === "true" || !!tcPr?.getElementsByTagNameNS("*", "hMerge")[0] || !!tcPr?.getElementsByTagNameNS("*", "vMerge")[0]) continue;
10050
10091
  const txBody = tc.getElementsByTagNameNS("*", "txBody")[0] ?? null;
10051
10092
  const { text, font, align, padding } = this.extractCellText(txBody, themeColors, tc);
10052
- const tcPr = tc.getElementsByTagNameNS("*", "tcPr")[0] ?? null;
10053
10093
  const cell = {
10054
10094
  text,
10055
10095
  font,
@@ -10069,6 +10109,7 @@ var TableExtractor = class {
10069
10109
  tables.push({
10070
10110
  type: "table",
10071
10111
  zIndex: XmlHelper.getZIndex(gf, spTree),
10112
+ rotationDeg,
10072
10113
  position: {
10073
10114
  x,
10074
10115
  y
@@ -10359,16 +10400,11 @@ var ChartExtractor = class {
10359
10400
  const doc = XmlHelper.parseXml(xmlStr);
10360
10401
  const parsed = this.parseChart(doc, themeColors);
10361
10402
  if (!parsed) continue;
10362
- const xfrm = gf.getElementsByTagNameNS("*", "xfrm")[0] ?? null;
10363
- const off = xfrm?.getElementsByTagNameNS("*", "off")[0] ?? null;
10364
- const ext = xfrm?.getElementsByTagNameNS("*", "ext")[0] ?? null;
10365
- const x = off ? XmlHelper.getAttrAsNumber(off, "x") : 0;
10366
- const y = off ? XmlHelper.getAttrAsNumber(off, "y") : 0;
10367
- const cx = ext ? XmlHelper.getAttrAsNumber(ext, "cx") : 1e6;
10368
- const cy = ext ? XmlHelper.getAttrAsNumber(ext, "cy") : 6e5;
10403
+ const { x, y, cx, cy, rotationDeg } = XmlHelper.getAbsoluteTransform(gf, spTree);
10369
10404
  charts.push({
10370
10405
  type: "chart",
10371
10406
  zIndex: XmlHelper.getZIndex(gf, spTree),
10407
+ rotationDeg,
10372
10408
  chartType: parsed.type,
10373
10409
  position: {
10374
10410
  x,
@@ -10391,10 +10427,11 @@ var ChartExtractor = class {
10391
10427
  return charts;
10392
10428
  }
10393
10429
  static resolvePath(target, baseDir) {
10430
+ if (target.startsWith("/")) return target.slice(1);
10394
10431
  const parts = (baseDir + "/" + target).split("/");
10395
10432
  const resolved = [];
10396
10433
  for (const part of parts) if (part === "..") resolved.pop();
10397
- else if (part !== ".") resolved.push(part);
10434
+ else if (part !== "." && part !== "") resolved.push(part);
10398
10435
  return resolved.join("/");
10399
10436
  }
10400
10437
  static parseChart(doc, themeColors) {
@@ -10407,6 +10444,7 @@ var ChartExtractor = class {
10407
10444
  const line = plotArea.getElementsByTagNameNS("*", "lineChart")[0] || null;
10408
10445
  const area = plotArea.getElementsByTagNameNS("*", "areaChart")[0] || null;
10409
10446
  const pie = plotArea.getElementsByTagNameNS("*", "pieChart")[0] || null;
10447
+ const doughnut = plotArea.getElementsByTagNameNS("*", "doughnutChart")[0] || null;
10410
10448
  const scatter = plotArea.getElementsByTagNameNS("*", "scatterChart")[0] || null;
10411
10449
  const chartNumFmt = plotArea.getElementsByTagNameNS("*", "dLbls")[0]?.getElementsByTagNameNS("*", "numFmt")[0]?.getAttribute("formatCode") || void 0;
10412
10450
  const palette = [
@@ -10466,17 +10504,20 @@ var ChartExtractor = class {
10466
10504
  valueFormat: chartNumFmt
10467
10505
  };
10468
10506
  }
10469
- if (pie) return {
10470
- type: "pie",
10471
- categories: this.extractCategories(pie) || [],
10472
- series: this.extractSeries(pie, themeColors) || [],
10473
- palette,
10474
- title: titleText,
10475
- showLegend,
10476
- showDataLabels,
10477
- stackedMode: "none",
10478
- valueFormat: chartNumFmt
10479
- };
10507
+ if (pie || doughnut) {
10508
+ const chartEl = pie || doughnut;
10509
+ return {
10510
+ type: "pie",
10511
+ categories: this.extractCategories(chartEl) || [],
10512
+ series: this.extractSeries(chartEl, themeColors) || [],
10513
+ palette,
10514
+ title: titleText,
10515
+ showLegend,
10516
+ showDataLabels,
10517
+ stackedMode: "none",
10518
+ valueFormat: chartNumFmt
10519
+ };
10520
+ }
10480
10521
  if (scatter) return {
10481
10522
  type: "scatter",
10482
10523
  categories: [],
@@ -10495,16 +10536,30 @@ var ChartExtractor = class {
10495
10536
  if (!title) return void 0;
10496
10537
  const tx = title.getElementsByTagNameNS("*", "tx")[0] || null;
10497
10538
  const rich = tx?.getElementsByTagNameNS("*", "rich")[0] || null;
10498
- if (rich) return rich.getElementsByTagNameNS("*", "t")[0]?.textContent || void 0;
10539
+ if (rich) return Array.from(rich.getElementsByTagNameNS("*", "t")).map((t) => t.textContent || "").join("") || void 0;
10499
10540
  return tx?.getElementsByTagNameNS("*", "v")[0]?.textContent || void 0;
10500
10541
  }
10501
10542
  static extractCategories(parent) {
10502
10543
  const cat = parent.getElementsByTagNameNS("*", "cat")[0] || null;
10503
10544
  if (!cat) return null;
10504
10545
  const strCache = cat.getElementsByTagNameNS("*", "strCache")[0] || null;
10505
- if (strCache) return Array.from(strCache.getElementsByTagNameNS("*", "pt")).map((p) => p.getElementsByTagNameNS("*", "v")[0]?.textContent || "");
10546
+ if (strCache) {
10547
+ const pts = Array.from(strCache.getElementsByTagNameNS("*", "pt"));
10548
+ return this.indexedValues(pts, (p) => p.getElementsByTagNameNS("*", "v")[0]?.textContent || "");
10549
+ }
10506
10550
  const numCache = cat.getElementsByTagNameNS("*", "numCache")[0] || null;
10507
- if (numCache) return Array.from(numCache.getElementsByTagNameNS("*", "pt")).map((p) => Number(p.getElementsByTagNameNS("*", "v")[0]?.textContent || 0));
10551
+ if (numCache) {
10552
+ const pts = Array.from(numCache.getElementsByTagNameNS("*", "pt"));
10553
+ return this.indexedValues(pts, (p) => Number(p.getElementsByTagNameNS("*", "v")[0]?.textContent || 0));
10554
+ }
10555
+ const multiLvlStrCache = cat.getElementsByTagNameNS("*", "multiLvlStrCache")[0] || null;
10556
+ if (multiLvlStrCache) {
10557
+ const firstLvl = multiLvlStrCache.getElementsByTagNameNS("*", "lvl")[0] || null;
10558
+ if (firstLvl) {
10559
+ const pts = Array.from(firstLvl.getElementsByTagNameNS("*", "pt"));
10560
+ return this.indexedValues(pts, (p) => p.getElementsByTagNameNS("*", "v")[0]?.textContent || "");
10561
+ }
10562
+ }
10508
10563
  return null;
10509
10564
  }
10510
10565
  static extractSeries(parent, themeColors) {
@@ -10515,15 +10570,26 @@ var ChartExtractor = class {
10515
10570
  const name = s.getElementsByTagNameNS("*", "tx")[0]?.getElementsByTagNameNS("*", "v")[0]?.textContent || void 0;
10516
10571
  const numCache = s.getElementsByTagNameNS("*", "numCache")[0] || null;
10517
10572
  let values = [];
10518
- if (numCache) values = Array.from(numCache.getElementsByTagNameNS("*", "pt")).map((p) => Number(p.getElementsByTagNameNS("*", "v")[0]?.textContent || 0));
10573
+ if (numCache) {
10574
+ const pts = Array.from(numCache.getElementsByTagNameNS("*", "pt"));
10575
+ values = this.indexedValues(pts, (p) => Number(p.getElementsByTagNameNS("*", "v")[0]?.textContent || 0));
10576
+ }
10519
10577
  const valueFormat = s.getElementsByTagNameNS("*", "dLbls")[0]?.getElementsByTagNameNS("*", "numFmt")[0]?.getAttribute("formatCode") || void 0;
10520
10578
  const solidFill = (s.getElementsByTagNameNS("*", "spPr")[0] || null)?.getElementsByTagNameNS("*", "solidFill")[0] || null;
10521
10579
  const color = XmlHelper.getColorFromElement(solidFill, themeColors);
10580
+ const ptColors = [];
10581
+ for (const dp of Array.from(s.getElementsByTagNameNS("*", "dPt"))) {
10582
+ const di = Number(dp.getElementsByTagNameNS("*", "idx")[0]?.getAttribute("val") || 0);
10583
+ const df = (dp.getElementsByTagNameNS("*", "spPr")[0] || null)?.getElementsByTagNameNS("*", "solidFill")[0] || null;
10584
+ const dc = XmlHelper.getColorFromElement(df, themeColors);
10585
+ if (dc) ptColors[di] = dc;
10586
+ }
10522
10587
  series.push({
10523
10588
  name,
10524
10589
  values,
10525
10590
  color,
10526
- valueFormat
10591
+ valueFormat,
10592
+ ptColors: ptColors.length > 0 ? ptColors : void 0
10527
10593
  });
10528
10594
  idx += 1;
10529
10595
  }
@@ -10538,16 +10604,14 @@ var ChartExtractor = class {
10538
10604
  const yCache = s.getElementsByTagNameNS("*", "yVal")[0]?.getElementsByTagNameNS("*", "numCache")[0] || null;
10539
10605
  const xPts = xCache ? Array.from(xCache.getElementsByTagNameNS("*", "pt")) : [];
10540
10606
  const yPts = yCache ? Array.from(yCache.getElementsByTagNameNS("*", "pt")) : [];
10541
- const len = Math.min(xPts.length, yPts.length);
10607
+ const xValues = this.indexedValues(xPts, (p) => Number(p.getElementsByTagNameNS("*", "v")[0]?.textContent || 0));
10608
+ const yValues = this.indexedValues(yPts, (p) => Number(p.getElementsByTagNameNS("*", "v")[0]?.textContent || 0));
10609
+ const len = Math.max(xValues.length, yValues.length);
10542
10610
  const points = [];
10543
- for (let i = 0; i < len; i++) {
10544
- const xv = Number(xPts[i].getElementsByTagNameNS("*", "v")[0]?.textContent || 0);
10545
- const yv = Number(yPts[i].getElementsByTagNameNS("*", "v")[0]?.textContent || 0);
10546
- points.push({
10547
- x: xv,
10548
- y: yv
10549
- });
10550
- }
10611
+ for (let i = 0; i < len; i++) if (xValues[i] !== void 0 && yValues[i] !== void 0) points.push({
10612
+ x: xValues[i],
10613
+ y: yValues[i]
10614
+ });
10551
10615
  const solidFill = (s.getElementsByTagNameNS("*", "spPr")[0] || null)?.getElementsByTagNameNS("*", "solidFill")[0] || null;
10552
10616
  const color = XmlHelper.getColorFromElement(solidFill, themeColors);
10553
10617
  const valueFormat = s.getElementsByTagNameNS("*", "dLbls")[0]?.getElementsByTagNameNS("*", "numFmt")[0]?.getAttribute("formatCode") || void 0;
@@ -10560,6 +10624,23 @@ var ChartExtractor = class {
10560
10624
  }
10561
10625
  return out;
10562
10626
  }
10627
+ /** OOXML caches address points by `idx`; XML order is not guaranteed. */
10628
+ static indexedValues(points, value) {
10629
+ let max = -1;
10630
+ const indexed = [];
10631
+ points.forEach((point, fallbackIndex) => {
10632
+ const raw = point.getAttribute("idx");
10633
+ const index = raw !== null && /^\d+$/.test(raw) ? Number(raw) : fallbackIndex;
10634
+ max = Math.max(max, index);
10635
+ indexed.push({
10636
+ index,
10637
+ value: value(point)
10638
+ });
10639
+ });
10640
+ const result = new Array(max + 1);
10641
+ for (const point of indexed) result[point.index] = point.value;
10642
+ return result;
10643
+ }
10563
10644
  };
10564
10645
  /**
10565
10646
  * Responsible for extracting all slides from the .pptx file as lists of SlideElement.
@@ -10677,6 +10758,7 @@ var SlideExtractor = class {
10677
10758
  }
10678
10759
  /** Normalize a relative path against a base directory inside ppt folder */
10679
10760
  resolvePath(target, baseDir) {
10761
+ if (target.startsWith("/")) return target.slice(1);
10680
10762
  const parts = (baseDir + "/" + target).split("/");
10681
10763
  const resolved = [];
10682
10764
  for (const part of parts) if (part === "..") {
@@ -10859,6 +10941,7 @@ function renderTextElement(el) {
10859
10941
  const textAlign = el.align?.horizontal || "left";
10860
10942
  const justify = el.align?.vertical === "middle" ? "center" : el.align?.vertical === "bottom" ? "flex-end" : "flex-start";
10861
10943
  const inner = el.html ? el.html : escape$2(el.content);
10944
+ const rotation = Number.isFinite(el.rotationDeg) && el.rotationDeg ? `transform:rotate(${el.rotationDeg}deg); transform-origin:center;` : "";
10862
10945
  return `<div style="
10863
10946
  position: absolute;
10864
10947
  left: ${x}px;
@@ -10878,6 +10961,7 @@ function renderTextElement(el) {
10878
10961
  color: ${safeColor(el.font?.color, "#000")};
10879
10962
  overflow: hidden;
10880
10963
  white-space: pre-wrap;
10964
+ ${rotation}
10881
10965
  ">${inner}</div>`;
10882
10966
  }
10883
10967
  function escape$2(str) {
@@ -10890,14 +10974,32 @@ function escape$2(str) {
10890
10974
  */
10891
10975
  function renderImageElement(el) {
10892
10976
  const nf = (n, fb = 0) => Number.isFinite(n) ? n : fb;
10893
- return `<img src="${escapeAttribute(el.src)}" style="
10977
+ const x = nf(el.position?.x, 0) / 9525;
10978
+ const y = nf(el.position?.y, 0) / 9525;
10979
+ const width = nf(el.size?.width, 0) / 9525;
10980
+ const height = nf(el.size?.height, 0) / 9525;
10981
+ const zIndex = Number.isFinite(el.zIndex) ? el.zIndex : 0;
10982
+ const rotation = Number.isFinite(el.rotationDeg) && el.rotationDeg ? `transform:rotate(${el.rotationDeg}deg); transform-origin:center;` : "";
10983
+ const src = escapeAttribute(el.src);
10984
+ const crop = el.crop;
10985
+ if (crop && crop.left + crop.right < 1e5 && crop.top + crop.bottom < 1e5) {
10986
+ const visibleX = 1e5 - crop.left - crop.right;
10987
+ const visibleY = 1e5 - crop.top - crop.bottom;
10988
+ const imageWidth = width * 1e5 / visibleX;
10989
+ const imageHeight = height * 1e5 / visibleY;
10990
+ return `<div style="position:absolute; z-index:${zIndex}; left:${x}px; top:${y}px; width:${width}px; height:${height}px; overflow:hidden; ${rotation}">
10991
+ <img src="${src}" style="position:absolute; left:${-imageWidth * crop.left / 1e5}px; top:${-imageHeight * crop.top / 1e5}px; width:${imageWidth}px; height:${imageHeight}px;" />
10992
+ </div>`;
10993
+ }
10994
+ return `<img src="${src}" style="
10894
10995
  position: absolute;
10895
- z-index: ${Number.isFinite(el.zIndex) ? el.zIndex : 0};
10896
- left: ${nf(el.position?.x, 0) / 9525}px;
10897
- top: ${nf(el.position?.y, 0) / 9525}px;
10898
- width: ${nf(el.size?.width, 0) / 9525}px;
10899
- height: ${nf(el.size?.height, 0) / 9525}px;
10900
- object-fit: cover;
10996
+ z-index: ${zIndex};
10997
+ left: ${x}px;
10998
+ top: ${y}px;
10999
+ width: ${width}px;
11000
+ height: ${height}px;
11001
+ object-fit: fill;
11002
+ ${rotation}
10901
11003
  " />`;
10902
11004
  }
10903
11005
  /**
@@ -11112,6 +11214,7 @@ function renderTableElement(el) {
11112
11214
  const y = nf(el.position?.y, 0) / 9525;
11113
11215
  const width = nf(el.size?.width, 0) / 9525;
11114
11216
  const height = nf(el.size?.height, 0) / 9525;
11217
+ const rotation = Number.isFinite(el.rotationDeg) && el.rotationDeg ? `transform:rotate(${el.rotationDeg}deg); transform-origin:center;` : "";
11115
11218
  const colWidthsPx = el.columns.map((w) => nf(w, 0) / 9525);
11116
11219
  const colTotal = colWidthsPx.reduce((a, b) => a + b, 0) || 1;
11117
11220
  const cols = colWidthsPx.map((w) => `<col style="width:${w / colTotal * 100}%">`).join("");
@@ -11151,7 +11254,7 @@ function renderTableElement(el) {
11151
11254
  rowIndex += 1;
11152
11255
  return trHtml;
11153
11256
  }).join("");
11154
- return `<div style="position:absolute; z-index:${Number.isFinite(el.zIndex) ? el.zIndex : 0}; left:${x}px; top:${y}px; width:${width}px; height:${height}px;">
11257
+ return `<div style="position:absolute; z-index:${Number.isFinite(el.zIndex) ? el.zIndex : 0}; left:${x}px; top:${y}px; width:${width}px; height:${height}px; ${rotation}">
11155
11258
  <table style="border-collapse:collapse; width:100%; height:100%; table-layout:fixed;${tableBg ? ` background-color:${safeColor(tableBg)};` : ""}">
11156
11259
  <colgroup>${cols}</colgroup>
11157
11260
  <tbody>${rowsHtml}</tbody>
@@ -11268,37 +11371,28 @@ function renderChartElement(el) {
11268
11371
  else if (el.chartType === "pie") svg = renderPie(el, width, height, palette);
11269
11372
  else if (el.chartType === "scatter") svg = renderScatter(el, width, height, padding, palette);
11270
11373
  const zIndex = Number.isFinite(el.zIndex) ? el.zIndex : 0;
11271
- return `${el.title ? `<div style="position:absolute;z-index:${zIndex};left:${x}px;top:${y - 20}px;width:${width}px;text-align:center;font-weight:600;">${escape(el.title)}</div>` : ""}<div style="position:absolute; z-index:${zIndex}; left:${x}px; top:${y}px; width:${width}px; height:${height}px;">
11374
+ return `${el.title ? `<div style="position:absolute;z-index:${zIndex};left:${x}px;top:${y - 20}px;width:${width}px;text-align:center;font-weight:600;">${escape(el.title)}</div>` : ""}<div style="position:absolute; z-index:${zIndex}; left:${x}px; top:${y}px; width:${width}px; height:${height}px;${Number.isFinite(el.rotationDeg) && el.rotationDeg ? ` transform:rotate(${el.rotationDeg}deg); transform-origin:center;` : ""}">
11272
11375
  <svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
11273
11376
  ${svg}
11274
11377
  </svg>
11275
11378
  </div>`;
11276
11379
  }
11277
11380
  function renderBarLike(el, width, height, pad, palette) {
11278
- const catCount = el.categories.length || 1;
11381
+ const catCount = Math.max(1, el.categories.length, ...el.series.map((series) => series.values?.length || 0));
11279
11382
  const chartW = width - pad * 2;
11280
11383
  const chartH = height - pad * 2;
11281
11384
  const isHorizontal = el.chartType === "bar";
11282
11385
  const stacked = el.stackedMode && el.stackedMode !== "none";
11283
11386
  const percent = el.stackedMode === "percent";
11284
- let maxVal = 1;
11285
- if (stacked) {
11286
- const sums = new Array(catCount).fill(0).map((_, i) => el.series.reduce((acc, s) => acc + ((s.values || [])[i] || 0), 0));
11287
- maxVal = percent ? 1 : Math.max(1, ...sums);
11288
- } else {
11289
- let mv = 1;
11290
- for (const s of el.series) {
11291
- const vals = s.values || [];
11292
- for (const v of vals) mv = Math.max(mv, v);
11293
- }
11294
- maxVal = mv;
11295
- }
11387
+ const domain = chartDomain(el, catCount, Boolean(stacked), percent);
11388
+ const range = Math.max(1e-9, domain.max - domain.min);
11389
+ const scale = (v) => (v - domain.min) / range;
11296
11390
  const parts = [];
11297
11391
  if (isHorizontal) {
11298
11392
  parts.push(`<line x1="${pad}" y1="${height - pad}" x2="${width - pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11299
11393
  parts.push(`<line x1="${pad}" y1="${pad}" x2="${pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11300
- computeTicks(0, maxVal, 4).forEach((t) => {
11301
- const tx = pad + t / maxVal * chartW;
11394
+ computeTicks(domain.min, domain.max, 4).forEach((t) => {
11395
+ const tx = pad + scale(t) * chartW;
11302
11396
  const ty = height - pad;
11303
11397
  parts.push(`<line x1="${tx}" y1="${ty}" x2="${tx}" y2="${ty + 4}" stroke="#999" stroke-width="1" />`);
11304
11398
  parts.push(`<text x="${tx}" y="${ty + 16}" text-anchor="middle" font-size="10" fill="#666">${formatNumber(t, percent ? "0%" : el.valueFormat)}</text>`);
@@ -11306,8 +11400,8 @@ function renderBarLike(el, width, height, pad, palette) {
11306
11400
  } else {
11307
11401
  parts.push(`<line x1="${pad}" y1="${height - pad}" x2="${width - pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11308
11402
  parts.push(`<line x1="${pad}" y1="${pad}" x2="${pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11309
- computeTicks(0, maxVal, 4).forEach((t) => {
11310
- const ty = height - pad - t / maxVal * chartH;
11403
+ computeTicks(domain.min, domain.max, 4).forEach((t) => {
11404
+ const ty = height - pad - scale(t) * chartH;
11311
11405
  parts.push(`<line x1="${pad - 4}" y1="${ty}" x2="${pad}" y2="${ty}" stroke="#999" stroke-width="1" />`);
11312
11406
  parts.push(`<text x="${pad - 6}" y="${ty + 3}" text-anchor="end" font-size="10" fill="#666">${formatNumber(t, percent ? "0%" : el.valueFormat)}</text>`);
11313
11407
  parts.push(`<line x1="${pad}" y1="${ty}" x2="${width - pad}" y2="${ty}" stroke="#eee" stroke-width="1" />`);
@@ -11321,11 +11415,14 @@ function renderBarLike(el, width, height, pad, palette) {
11321
11415
  (s.values || []).forEach((v, ci) => {
11322
11416
  const baseY = pad + ci * catBand + (catBand - (stacked ? barH : el.series.length * barH)) / 2;
11323
11417
  if (stacked) {
11324
- const prev = el.series.slice(0, si).reduce((acc, ss) => acc + ((ss.values || [])[ci] || 0), 0);
11325
11418
  const sum = el.series.reduce((acc, ss) => acc + ((ss.values || [])[ci] || 0), 0) || 1;
11326
- const start = (percent ? prev / sum : prev) / maxVal * chartW;
11327
- const w = (percent ? (v || 0) / sum : v) / maxVal * chartW;
11328
- const x = pad + start;
11419
+ const rawPrev = stackedPrevious(el, si, ci, v);
11420
+ const startValue = percent ? rawPrev / sum : rawPrev;
11421
+ const endValue = startValue + (percent ? v / sum : v);
11422
+ const start = scale(startValue) * chartW;
11423
+ const end = scale(endValue) * chartW;
11424
+ const x = pad + Math.min(start, end);
11425
+ const w = Math.abs(end - start);
11329
11426
  const y = baseY;
11330
11427
  parts.push(`<rect x="${x}" y="${y}" width="${w}" height="${barH}" fill="${color}" />`);
11331
11428
  if (el.showDataLabels) {
@@ -11333,9 +11430,11 @@ function renderBarLike(el, width, height, pad, palette) {
11333
11430
  parts.push(`<text x="${x + w - 2}" y="${y + barH / 2 + 3}" text-anchor="end" font-size="10" fill="#000">${formatNumber(percent ? v / sum : v, percent ? "0%" : fmt)}</text>`);
11334
11431
  }
11335
11432
  } else {
11336
- const w = v / maxVal * chartW;
11433
+ const zero = scale(0) * chartW;
11434
+ const value = scale(v) * chartW;
11435
+ const w = Math.abs(value - zero);
11337
11436
  const y = baseY + si * barH;
11338
- parts.push(`<rect x="${pad}" y="${y}" width="${w}" height="${barH}" fill="${color}" />`);
11437
+ parts.push(`<rect x="${pad + Math.min(zero, value)}" y="${y}" width="${w}" height="${barH}" fill="${color}" />`);
11339
11438
  if (el.showDataLabels) {
11340
11439
  const fmt = s.valueFormat || el.valueFormat;
11341
11440
  parts.push(`<text x="${pad + w + 2}" y="${y + barH / 2 + 3}" font-size="10" fill="#000">${formatNumber(v, fmt)}</text>`);
@@ -11356,21 +11455,24 @@ function renderBarLike(el, width, height, pad, palette) {
11356
11455
  (s.values || []).forEach((v, ci) => {
11357
11456
  const baseX = pad + ci * catBand + (catBand - (stacked ? barW : el.series.length * barW)) / 2;
11358
11457
  if (stacked) {
11359
- const prev = el.series.slice(0, si).reduce((acc, ss) => acc + ((ss.values || [])[ci] || 0), 0);
11360
11458
  const sum = el.series.reduce((acc, ss) => acc + ((ss.values || [])[ci] || 0), 0) || 1;
11361
- const start = (percent ? prev / sum : prev) / maxVal * chartH;
11362
- const h = (percent ? (v || 0) / sum : v) / maxVal * chartH;
11459
+ const rawPrev = stackedPrevious(el, si, ci, v);
11460
+ const start = scale(percent ? rawPrev / sum : rawPrev) * chartH;
11461
+ const end = scale((percent ? rawPrev / sum : rawPrev) + (percent ? v / sum : v)) * chartH;
11462
+ const h = Math.abs(end - start);
11363
11463
  const x = baseX;
11364
- const y = height - pad - start - h;
11464
+ const y = height - pad - Math.max(start, end);
11365
11465
  parts.push(`<rect x="${x}" y="${y}" width="${barW}" height="${h}" fill="${color}" />`);
11366
11466
  if (el.showDataLabels) {
11367
11467
  const fmt = s.valueFormat || el.valueFormat;
11368
11468
  parts.push(`<text x="${x + barW / 2}" y="${y - 2}" text-anchor="middle" font-size="10" fill="#000">${formatNumber(percent ? v / sum : v, percent ? "0%" : fmt)}</text>`);
11369
11469
  }
11370
11470
  } else {
11371
- const h = v / maxVal * chartH;
11471
+ const zero = scale(0) * chartH;
11472
+ const value = scale(v) * chartH;
11473
+ const h = Math.abs(value - zero);
11372
11474
  const x = baseX + si * barW;
11373
- const y = height - pad - h;
11475
+ const y = height - pad - Math.max(zero, value);
11374
11476
  parts.push(`<rect x="${x}" y="${y}" width="${barW}" height="${h}" fill="${color}" />`);
11375
11477
  if (el.showDataLabels) {
11376
11478
  const fmt = s.valueFormat || el.valueFormat;
@@ -11390,26 +11492,24 @@ function renderBarLike(el, width, height, pad, palette) {
11390
11492
  return parts.join("\n");
11391
11493
  }
11392
11494
  function renderLine(el, width, height, pad, palette) {
11393
- const catCount = el.categories.length || 1;
11495
+ const catCount = Math.max(1, el.categories.length, ...el.series.map((series) => series.values?.length || 0));
11394
11496
  const chartW = width - pad * 2;
11395
11497
  const chartH = height - pad * 2;
11396
- let maxVal = 1;
11397
- for (const s of el.series) {
11398
- const vals = s.values || [];
11399
- for (const v of vals) maxVal = Math.max(maxVal, v);
11400
- }
11498
+ const stacked = el.stackedMode && el.stackedMode !== "none";
11499
+ const percent = el.stackedMode === "percent";
11500
+ const domain = chartDomain(el, catCount, Boolean(stacked), percent);
11501
+ const range = Math.max(1e-9, domain.max - domain.min);
11502
+ const scale = (v) => (v - domain.min) / range;
11401
11503
  const xStep = chartW / Math.max(1, catCount - 1);
11402
11504
  const parts = [];
11403
11505
  parts.push(`<line x1="${pad}" y1="${height - pad}" x2="${width - pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11404
11506
  parts.push(`<line x1="${pad}" y1="${pad}" x2="${pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11405
- computeTicks(0, maxVal, 4).forEach((t) => {
11406
- const ty = height - pad - t / maxVal * chartH;
11507
+ computeTicks(domain.min, domain.max, 4).forEach((t) => {
11508
+ const ty = height - pad - scale(t) * chartH;
11407
11509
  parts.push(`<line x1="${pad - 4}" y1="${ty}" x2="${pad}" y2="${ty}" stroke="#999" stroke-width="1" />`);
11408
11510
  parts.push(`<text x="${pad - 6}" y="${ty + 3}" text-anchor="end" font-size="10" fill="#666">${formatNumber(t, el.valueFormat)}</text>`);
11409
11511
  parts.push(`<line x1="${pad}" y1="${ty}" x2="${width - pad}" y2="${ty}" stroke="#eee" stroke-width="1" />`);
11410
11512
  });
11411
- const stacked = el.stackedMode && el.stackedMode !== "none";
11412
- const percent = el.stackedMode === "percent";
11413
11513
  const totals = percent ? new Array(catCount).fill(0).map((_, i) => el.series.reduce((acc, sr) => acc + ((sr.values || [])[i] || 0), 0)) : void 0;
11414
11514
  el.series.forEach((s, si) => {
11415
11515
  const color = s.color || palette[si % palette.length];
@@ -11418,54 +11518,62 @@ function renderLine(el, width, height, pad, palette) {
11418
11518
  const x = pad + i * xStep;
11419
11519
  let val = v;
11420
11520
  if (stacked) {
11421
- val = el.series.slice(0, si).reduce((acc, ss) => acc + ((ss.values || [])[i] || 0), 0) + v;
11521
+ val = stackedPrevious(el, si, i, v) + v;
11422
11522
  if (percent && totals) val = totals[i] ? val / totals[i] : 0;
11423
11523
  }
11424
- const y = height - pad - val / (percent ? 1 : maxVal) * chartH;
11524
+ const y = height - pad - scale(val) * chartH;
11425
11525
  d += i === 0 ? `M ${x} ${y}` : ` L ${x} ${y}`;
11426
11526
  });
11427
11527
  parts.push(`<path d="${d}" fill="none" stroke="${color}" stroke-width="2" />`);
11428
11528
  if (el.showDataLabels) (s.values || []).forEach((v, i) => {
11429
11529
  const x = pad + i * xStep;
11430
- const basePrev = stacked ? el.series.slice(0, si).reduce((acc, ss) => acc + ((ss.values || [])[i] || 0), 0) : 0;
11530
+ const basePrev = stacked ? stackedPrevious(el, si, i, v) : 0;
11431
11531
  const dispVal = percent && totals ? v / (totals[i] || 1) : v;
11432
- const y = height - pad - (stacked ? basePrev + v : v) / (percent ? 1 : maxVal) * chartH;
11532
+ const plotValue = stacked ? basePrev + v : v;
11533
+ const y = height - pad - scale(percent && totals ? totals[i] ? plotValue / totals[i] : 0 : plotValue) * chartH;
11433
11534
  parts.push(`<circle cx="${x}" cy="${y}" r="2.5" fill="${color}" />`);
11434
11535
  const fmt = s.valueFormat || el.valueFormat;
11435
11536
  parts.push(`<text x="${x}" y="${y - 6}" text-anchor="middle" font-size="10" fill="#000">${formatNumber(dispVal, percent ? "0%" : fmt)}</text>`);
11436
11537
  });
11437
11538
  });
11539
+ if (el.categories.length > 0) {
11540
+ const labelSize = Math.max(10, Math.min(12, chartW / (catCount * 4)));
11541
+ el.categories.forEach((c, i) => {
11542
+ const cx = pad + i * xStep;
11543
+ parts.push(`<text x="${cx}" y="${height - pad + 14}" text-anchor="middle" font-size="${labelSize}" fill="#333">${escape(String(c))}</text>`);
11544
+ });
11545
+ }
11438
11546
  return parts.join("\n");
11439
11547
  }
11440
11548
  function renderArea(el, width, height, pad, palette) {
11441
- const catCount = el.categories.length || 1;
11549
+ const catCount = Math.max(1, el.categories.length, ...el.series.map((series) => series.values?.length || 0));
11442
11550
  const chartW = width - pad * 2;
11443
11551
  const chartH = height - pad * 2;
11444
- let maxVal = 1;
11445
- for (const s of el.series) {
11446
- const vals = s.values || [];
11447
- for (const v of vals) maxVal = Math.max(maxVal, v);
11448
- }
11552
+ const stacked = el.stackedMode && el.stackedMode !== "none";
11553
+ const percent = el.stackedMode === "percent";
11554
+ const domain = chartDomain(el, catCount, Boolean(stacked), percent);
11555
+ const range = Math.max(1e-9, domain.max - domain.min);
11556
+ const scale = (v) => (v - domain.min) / range;
11449
11557
  const xStep = chartW / Math.max(1, catCount - 1);
11450
11558
  const parts = [];
11451
11559
  parts.push(`<line x1="${pad}" y1="${height - pad}" x2="${width - pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11452
11560
  parts.push(`<line x1="${pad}" y1="${pad}" x2="${pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11453
- const stacked = el.stackedMode && el.stackedMode !== "none";
11454
- const percent = el.stackedMode === "percent";
11455
11561
  const totals = percent ? new Array(catCount).fill(0).map((_, i) => el.series.reduce((acc, sr) => acc + ((sr.values || [])[i] || 0), 0)) : void 0;
11456
- const baseline = new Array(catCount).fill(0);
11562
+ const positiveBaseline = new Array(catCount).fill(0);
11563
+ const negativeBaseline = new Array(catCount).fill(0);
11457
11564
  el.series.forEach((s, si) => {
11458
11565
  const color = s.color || palette[si % palette.length];
11459
11566
  const topY = [];
11460
11567
  const botY = [];
11461
11568
  (s.values || []).forEach((v, i) => {
11462
- const prev = stacked ? baseline[i] : 0;
11569
+ const prev = stacked ? v >= 0 ? positiveBaseline[i] : negativeBaseline[i] : 0;
11463
11570
  const val = stacked ? prev + (percent && totals ? totals[i] ? v / totals[i] : 0 : v) : v;
11464
- const top = height - pad - val / (percent ? 1 : maxVal) * chartH;
11465
- const bottom = height - pad - prev / (percent ? 1 : maxVal) * chartH;
11571
+ const top = height - pad - scale(val) * chartH;
11572
+ const bottom = height - pad - scale(prev) * chartH;
11466
11573
  topY.push(top);
11467
11574
  botY.push(bottom);
11468
- if (stacked) baseline[i] = percent && totals ? val : prev + v;
11575
+ if (stacked) if (v >= 0) positiveBaseline[i] = percent && totals ? val : prev + v;
11576
+ else negativeBaseline[i] = percent && totals ? val : prev + v;
11469
11577
  });
11470
11578
  let d = "";
11471
11579
  for (let i = 0; i < topY.length; i++) {
@@ -11481,6 +11589,43 @@ function renderArea(el, width, height, pad, palette) {
11481
11589
  });
11482
11590
  return parts.join("\n");
11483
11591
  }
11592
+ function stackedPrevious(el, seriesIndex, categoryIndex, value) {
11593
+ return el.series.slice(0, seriesIndex).reduce((sum, series) => {
11594
+ const prior = (series.values || [])[categoryIndex] || 0;
11595
+ return sum + (value >= 0 ? Math.max(0, prior) : Math.min(0, prior));
11596
+ }, 0);
11597
+ }
11598
+ function chartDomain(el, catCount, stacked, percent) {
11599
+ if (percent) return {
11600
+ min: 0,
11601
+ max: 1
11602
+ };
11603
+ let min = 0;
11604
+ let max = 0;
11605
+ if (stacked) for (let i = 0; i < catCount; i++) {
11606
+ let positive = 0;
11607
+ let negative = 0;
11608
+ for (const series of el.series) {
11609
+ const value = (series.values || [])[i] || 0;
11610
+ if (value >= 0) positive += value;
11611
+ else negative += value;
11612
+ }
11613
+ min = Math.min(min, negative);
11614
+ max = Math.max(max, positive);
11615
+ }
11616
+ else for (const series of el.series) for (const value of series.values || []) {
11617
+ min = Math.min(min, value);
11618
+ max = Math.max(max, value);
11619
+ }
11620
+ if (min === max) return {
11621
+ min: min - 1,
11622
+ max: max + 1
11623
+ };
11624
+ return {
11625
+ min,
11626
+ max
11627
+ };
11628
+ }
11484
11629
  function renderPie(el, width, height, palette) {
11485
11630
  const s0 = el.series[0];
11486
11631
  const values = s0 && s0.values ? s0.values : [];
@@ -11498,14 +11643,16 @@ function renderPie(el, width, height, palette) {
11498
11643
  const x2 = cx + r * Math.cos(end);
11499
11644
  const y2 = cy + r * Math.sin(end);
11500
11645
  const large = end - start > Math.PI ? 1 : 0;
11501
- const color = s0 && s0.color || palette[i % palette.length];
11502
- const d = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
11503
- parts.push(`<path d="${d}" fill="${color}" />`);
11646
+ const color = s0 && s0.ptColors && s0.ptColors[i] || s0 && s0.color || palette[i % palette.length];
11647
+ const d = frac >= 1 ? `<circle cx="${cx}" cy="${cy}" r="${r}" fill="${color}" />` : `<path d="M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z" fill="${color}" />`;
11648
+ parts.push(d);
11504
11649
  if (el.showDataLabels && frac > 0) {
11505
11650
  const mid = (start + end) / 2;
11506
11651
  const lx = cx + (r + 12) * Math.cos(mid);
11507
11652
  const ly = cy + (r + 12) * Math.sin(mid);
11508
- parts.push(`<text x="${lx}" y="${ly}" text-anchor="middle" font-size="10" fill="#000">${(frac * 100).toFixed(0)}%</text>`);
11653
+ const catName = String(el.categories[i] || "");
11654
+ const pieLabel = catName ? `${escape(catName)} ${(frac * 100).toFixed(0)}%` : `${(frac * 100).toFixed(0)}%`;
11655
+ parts.push(`<text x="${lx}" y="${ly}" text-anchor="middle" font-size="10" fill="#000">${pieLabel}</text>`);
11509
11656
  }
11510
11657
  start = end;
11511
11658
  });
@@ -11519,10 +11666,26 @@ function renderScatter(el, width, height, pad, palette) {
11519
11666
  const pts = s.points || [];
11520
11667
  for (const p of pts) allPoints.push(p);
11521
11668
  }
11522
- const minX = Math.min(...allPoints.map((p) => p.x), 0);
11523
- const maxX = Math.max(...allPoints.map((p) => p.x), 1);
11524
- const minY = Math.min(...allPoints.map((p) => p.y), 0);
11525
- const maxY = Math.max(...allPoints.map((p) => p.y), 1);
11669
+ let minX = Math.min(...allPoints.map((p) => p.x));
11670
+ let maxX = Math.max(...allPoints.map((p) => p.x));
11671
+ let minY = Math.min(...allPoints.map((p) => p.y));
11672
+ let maxY = Math.max(...allPoints.map((p) => p.y));
11673
+ if (!Number.isFinite(minX) || !Number.isFinite(maxX)) {
11674
+ minX = 0;
11675
+ maxX = 1;
11676
+ }
11677
+ if (!Number.isFinite(minY) || !Number.isFinite(maxY)) {
11678
+ minY = 0;
11679
+ maxY = 1;
11680
+ }
11681
+ if (minX === maxX) {
11682
+ minX -= .5;
11683
+ maxX += .5;
11684
+ }
11685
+ if (minY === maxY) {
11686
+ minY -= .5;
11687
+ maxY += .5;
11688
+ }
11526
11689
  const parts = [];
11527
11690
  parts.push(`<line x1="${pad}" y1="${height - pad}" x2="${width - pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
11528
11691
  parts.push(`<line x1="${pad}" y1="${pad}" x2="${pad}" y2="${height - pad}" stroke="#999" stroke-width="1" />`);
@@ -11694,22 +11857,19 @@ async function pptxToHtml(buffer, config) {
11694
11857
  };
11695
11858
  return slides.map((slideElements) => HtmlRenderer.render(slideElements, opts));
11696
11859
  }
11697
- //#endregion
11698
- //#region src/converters/pptx.ts
11860
+ // src/converters/pptx.ts
11699
11861
  var PptxConverter = class extends HtmlConverter {
11700
11862
  async convert(source, options) {
11701
- if (options.file_extension?.toLowerCase() !== ".pptx") return null;
11863
+ if (options.extension !== "pptx") return null;
11702
11864
  const slides = await pptxToHtml(toArrayBuffer(source), { domParserFactory: createPptxDomParser });
11703
11865
  const sections = [];
11704
11866
  for (const [index, html] of slides.entries()) {
11705
11867
  const result = await this.convertHtml(`<html><body>${html}</body></html>`);
11706
11868
  sections.push(`<!-- Slide number: ${index + 1} -->\n${result?.markdown.trim() ?? ""}`);
11707
11869
  }
11708
- const markdown = sections.join("\n\n");
11709
11870
  return {
11710
11871
  title: null,
11711
- markdown,
11712
- text_content: markdown
11872
+ markdown: sections.join("\n\n")
11713
11873
  };
11714
11874
  }
11715
11875
  };
@@ -11773,32 +11933,33 @@ function defineGetter(target, name, get) {
11773
11933
  get
11774
11934
  });
11775
11935
  }
11776
- //#endregion
11777
- //#region src/converters/wikipedia.ts
11936
+ // src/converters/wikipedia.ts
11778
11937
  const WIKIPEDIA_URL = /^https?:\/\/[a-z]{2,3}\.wikipedia\.org\//i;
11779
11938
  var WikipediaConverter = class {
11780
11939
  async convert(source, options = {}) {
11781
- const extension = options.file_extension?.toLowerCase() ?? "";
11782
- if (extension !== ".html" && extension !== ".htm" || !WIKIPEDIA_URL.test(options.url ?? "")) return null;
11783
- const document = parseHtmlDocument(decodeText(source));
11784
- document.querySelectorAll("script, style").forEach((element) => {
11785
- element.remove();
11940
+ if (options.extension !== "html" && options.extension !== "htm" || !WIKIPEDIA_URL.test(options.url ?? "")) return null;
11941
+ return parseHtmlDocument(decodeText(source), (document) => {
11942
+ document.querySelectorAll("script, style").forEach((element) => {
11943
+ element.remove();
11944
+ });
11945
+ const body = document.querySelector("div#mw-content-text");
11946
+ return {
11947
+ title: {
11948
+ type: "metadata",
11949
+ value: document.querySelector("span.mw-page-title-main")?.textContent?.trim() || document.title || null
11950
+ },
11951
+ markdown: {
11952
+ type: "node",
11953
+ value: body || document
11954
+ }
11955
+ };
11786
11956
  });
11787
- const body = document.querySelector("div#mw-content-text");
11788
- const title = document.querySelector("span.mw-page-title-main")?.textContent?.trim() || document.title || null;
11789
- const markdown = body ? `# ${title ?? "Wikipedia"}\n\n${new CustomTurnDown().convertSoup(body)}` : new CustomTurnDown().convertSoup(document);
11790
- return {
11791
- title,
11792
- markdown,
11793
- text_content: markdown
11794
- };
11795
11957
  }
11796
11958
  };
11797
- //#endregion
11798
- //#region src/converters/xlsx.ts
11959
+ // src/converters/xlsx.ts
11799
11960
  var XlsxConverter = class extends HtmlConverter {
11800
11961
  async convert(source, options) {
11801
- if (options.file_extension?.toLowerCase() !== ".xlsx") return null;
11962
+ if (options.extension !== "xlsx") return null;
11802
11963
  const sheets = await (0, read_excel_file_universal.default)(toArrayBuffer(source));
11803
11964
  const sections = [];
11804
11965
  for (const { sheet, data } of sheets) {
@@ -11807,11 +11968,9 @@ var XlsxConverter = class extends HtmlConverter {
11807
11968
  const result = await this.convertHtml(html);
11808
11969
  sections.push(`## ${sheet}\n${result?.markdown.trim() ?? ""}`);
11809
11970
  }
11810
- const markdown = sections.join("\n\n");
11811
11971
  return {
11812
11972
  title: null,
11813
- markdown,
11814
- text_content: markdown
11973
+ markdown: sections.join("\n\n")
11815
11974
  };
11816
11975
  }
11817
11976
  };
@@ -11832,129 +11991,126 @@ function cellText(value) {
11832
11991
  function escapeHtml(value) {
11833
11992
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
11834
11993
  }
11835
- //#endregion
11836
- //#region src/converters/xml-rss-atom.ts
11994
+ // src/converters/xml-rss-atom.ts
11837
11995
  var RSSConverter = class {
11838
11996
  async convert(source, options = {}) {
11839
- const extension = options.file_extension?.toLowerCase() ?? "";
11840
- if (![
11841
- ".xml",
11842
- ".rss",
11843
- ".atom"
11844
- ].includes(extension)) return null;
11997
+ if (options.extension !== "xml" && options.extension !== "rss" && options.extension !== "atom") return null;
11845
11998
  const document = new _xmldom_xmldom.DOMParser().parseFromString(decodeText(source), "text/xml");
11846
- if (document.getElementsByTagName("rss").length > 0) return this.parseRss(document);
11847
- if (document.getElementsByTagName("feed")[0]?.getElementsByTagName("entry").length) return this.parseAtom(document);
11999
+ if (document.getElementsByTagName("rss").length > 0) return parseRss(document);
12000
+ if (document.getElementsByTagName("feed")[0]?.getElementsByTagName("entry").length) return parseAtom(document);
11848
12001
  return null;
11849
12002
  }
11850
- parseAtom(document) {
11851
- const root = document.getElementsByTagName("feed")[0];
11852
- if (!root) return null;
11853
- const title = getText(root, "title");
11854
- const subtitle = getText(root, "subtitle");
11855
- const sections = [`# ${title ?? "Feed"}`];
11856
- if (subtitle) sections.push(subtitle);
11857
- for (const entry of [...root.getElementsByTagName("entry")]) {
11858
- const entryTitle = getText(entry, "title");
11859
- const updated = getText(entry, "updated");
11860
- const summary = getText(entry, "summary");
11861
- const content = getText(entry, "content");
11862
- const lines = [];
11863
- if (entryTitle) lines.push(`## ${entryTitle}`);
11864
- if (updated) lines.push(`Updated on: ${updated}`);
11865
- if (summary) lines.push(parseContent(summary));
11866
- if (content) lines.push(parseContent(content));
11867
- sections.push(lines.join("\n"));
11868
- }
11869
- const markdown = sections.join("\n\n");
11870
- return {
11871
- title,
11872
- markdown,
11873
- text_content: markdown
11874
- };
12003
+ };
12004
+ function parseAtom(document) {
12005
+ const root = document.getElementsByTagName("feed")[0];
12006
+ if (!root) return null;
12007
+ const title = getText(root, "title");
12008
+ const subtitle = getText(root, "subtitle");
12009
+ const sections = [`# ${title ?? "Feed"}`];
12010
+ if (subtitle) sections.push(subtitle);
12011
+ for (const entry of [...root.getElementsByTagName("entry")]) {
12012
+ const entryTitle = getText(entry, "title");
12013
+ const updated = getText(entry, "updated");
12014
+ const summary = getText(entry, "summary");
12015
+ const content = getText(entry, "content");
12016
+ const lines = [];
12017
+ if (entryTitle) lines.push(`## ${entryTitle}`);
12018
+ if (updated) lines.push(`Updated on: ${updated}`);
12019
+ const node = summary || content;
12020
+ if (node) lines.push(parseHtmlDocument(node, (document) => ({ markdown: {
12021
+ type: "node",
12022
+ value: document.documentElement
12023
+ } })).markdown);
12024
+ sections.push(lines.join("\n\n"));
11875
12025
  }
11876
- parseRss(document) {
11877
- const channel = document.getElementsByTagName("rss")[0]?.getElementsByTagName("channel")[0];
11878
- if (!channel) return null;
11879
- const title = getText(channel, "title");
11880
- const description = getText(channel, "description");
11881
- const sections = title ? [`# ${title}`] : [];
11882
- if (description) sections.push(description);
11883
- for (const item of [...channel.getElementsByTagName("item")]) {
11884
- const itemTitle = getText(item, "title");
11885
- const published = getText(item, "pubDate");
11886
- const itemDescription = getText(item, "description");
11887
- const content = getText(item, "content:encoded");
11888
- const lines = [];
11889
- if (itemTitle) lines.push(`## ${itemTitle}`);
11890
- if (published) lines.push(`Published on: ${published}`);
11891
- if (itemDescription) lines.push(parseContent(itemDescription));
11892
- if (content) lines.push(parseContent(content));
11893
- sections.push(lines.join("\n"));
11894
- }
11895
- const markdown = sections.join("\n\n");
11896
- return {
11897
- title,
11898
- markdown,
11899
- text_content: markdown
11900
- };
12026
+ return {
12027
+ title,
12028
+ markdown: sections.join("\n\n")
12029
+ };
12030
+ }
12031
+ function parseRss(document) {
12032
+ const channel = document.getElementsByTagName("rss")[0]?.getElementsByTagName("channel")[0];
12033
+ if (!channel) return null;
12034
+ const title = getText(channel, "title");
12035
+ const description = getText(channel, "description");
12036
+ const sections = title ? [`# ${title}`] : [];
12037
+ if (description) sections.push(description);
12038
+ for (const item of [...channel.getElementsByTagName("item")]) {
12039
+ const itemTitle = getText(item, "title");
12040
+ const published = getText(item, "pubDate");
12041
+ const itemDescription = getText(item, "description");
12042
+ const content = getText(item, "content:encoded");
12043
+ const lines = [];
12044
+ if (itemTitle) lines.push(`## ${itemTitle}`);
12045
+ if (published) lines.push(`Published on: ${published}`);
12046
+ const node = itemDescription || content;
12047
+ if (node) lines.push(parseHtmlDocument(node, (document) => ({ markdown: {
12048
+ type: "node",
12049
+ value: document.documentElement
12050
+ } })).markdown);
12051
+ sections.push(lines.join("\n\n"));
11901
12052
  }
11902
- };
11903
- function parseContent(content) {
11904
- return new CustomTurnDown().convertSoup(parseHtmlDocument(content).documentElement);
12053
+ return {
12054
+ title,
12055
+ markdown: sections.join("\n\n")
12056
+ };
11905
12057
  }
11906
12058
  function getText(element, tagName) {
11907
12059
  return element.getElementsByTagName(tagName)[0]?.textContent?.trim() || null;
11908
12060
  }
11909
- //#endregion
11910
- //#region src/converters/youtube.ts
12061
+ // src/converters/youtube.ts
12062
+ const YOUTUBE_URL = /^https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|shorts\/)?([a-zA-Z0-9_-]+)/i;
11911
12063
  var YouTubeConverter = class {
11912
12064
  async convert(source, options = {}) {
11913
- const extension = options.file_extension?.toLowerCase() ?? "";
11914
- if (extension !== ".html" && extension !== ".htm" || !options.url?.startsWith("https://www.youtube.com/watch?")) return null;
11915
- const document = parseHtmlDocument(decodeText(source));
11916
- const metadata = { title: document.title };
11917
- document.querySelectorAll("meta").forEach((meta) => {
11918
- const content = meta.getAttribute("content");
11919
- const key = meta.getAttribute("itemprop") ?? meta.getAttribute("property") ?? meta.getAttribute("name");
11920
- if (key && content) metadata[key] = content;
11921
- });
11922
- try {
11923
- for (const script of document.querySelectorAll("script")) {
11924
- const content = script.textContent ?? "";
11925
- if (!content.includes("ytInitialData")) continue;
11926
- const start = content.indexOf("{");
11927
- const end = content.lastIndexOf("}");
11928
- if (start >= 0 && end > start) {
11929
- const description = findKey(JSON.parse(content.slice(start, end + 1)), "attributedDescriptionBodyText");
11930
- if (isRecord(description) && typeof description.content === "string") metadata.description = description.content;
12065
+ if (options.extension !== "html" && options.extension !== "htm" || !YOUTUBE_URL.test(options.url ?? "")) return null;
12066
+ return parseHtmlDocument(decodeText(source), (document) => {
12067
+ const metadata = {};
12068
+ document.querySelectorAll("meta").forEach((meta) => {
12069
+ const content = meta.getAttribute("content");
12070
+ const key = meta.getAttribute("itemprop") ?? meta.getAttribute("property") ?? meta.getAttribute("name");
12071
+ if (key && content) metadata[key] = content;
12072
+ });
12073
+ try {
12074
+ for (const script of document.querySelectorAll("script")) {
12075
+ const content = script.textContent ?? "";
12076
+ if (!content.includes("ytInitialData")) continue;
12077
+ const start = content.indexOf("{");
12078
+ const end = content.lastIndexOf("}");
12079
+ if (start >= 0 && end > start) {
12080
+ const description = findKey(JSON.parse(content.slice(start, end + 1)), "attributedDescriptionBodyText");
12081
+ if (isRecord(description) && typeof description.content === "string") metadata.description = description.content;
12082
+ }
12083
+ break;
11931
12084
  }
11932
- break;
11933
- }
11934
- } catch {}
11935
- const title = first(metadata, [
11936
- "title",
11937
- "og:title",
11938
- "name"
11939
- ]) || document.title || null;
11940
- const lines = ["# YouTube"];
11941
- if (title) lines.push(`## ${title}`);
11942
- const stats = [];
11943
- const views = first(metadata, ["interactionCount"]);
11944
- const keywords = first(metadata, ["keywords"]);
11945
- const runtime = first(metadata, ["duration"]);
11946
- if (views) stats.push(`- **Views:** ${views}`);
11947
- if (keywords) stats.push(`- **Keywords:** ${keywords}`);
11948
- if (runtime) stats.push(`- **Runtime:** ${runtime}`);
11949
- if (stats.length > 0) lines.push(`### Video Metadata\n${stats.join("\n")}`);
11950
- const description = first(metadata, ["description", "og:description"]);
11951
- if (description) lines.push(`### Description\n${description}`);
11952
- const markdown = lines.join("\n\n");
11953
- return {
11954
- title,
11955
- markdown,
11956
- text_content: markdown
11957
- };
12085
+ } catch {}
12086
+ const title = first(metadata, [
12087
+ "title",
12088
+ "og:title",
12089
+ "name"
12090
+ ]) || document.title || null;
12091
+ const lines = ["# YouTube"];
12092
+ if (title) lines.push(`## ${title}`);
12093
+ const stats = [];
12094
+ const views = first(metadata, ["interactionCount"]);
12095
+ const keywords = first(metadata, ["keywords"]);
12096
+ const runtime = first(metadata, ["duration"]);
12097
+ if (views) stats.push(`- **Views:** ${views}`);
12098
+ if (keywords) stats.push(`- **Keywords:** ${keywords}`);
12099
+ if (runtime) stats.push(`- **Runtime:** ${runtime}`);
12100
+ if (stats.length > 0) lines.push(`### Video Metadata\n\n${stats.join("\n")}`);
12101
+ const description = first(metadata, ["description", "og:description"]);
12102
+ if (description) lines.push(`### Description\n\n${description}`);
12103
+ return {
12104
+ title: {
12105
+ type: "metadata",
12106
+ value: title
12107
+ },
12108
+ markdown: {
12109
+ type: "metadata",
12110
+ value: lines.join("\n\n")
12111
+ }
12112
+ };
12113
+ });
11958
12114
  }
11959
12115
  };
11960
12116
  function first(metadata, keys) {
@@ -11977,23 +12133,20 @@ function findKey(value, key) {
11977
12133
  function isRecord(value) {
11978
12134
  return typeof value === "object" && value !== null;
11979
12135
  }
11980
- //#endregion
11981
- //#region src/converters/zip.ts
12136
+ // src/converters/zip.ts
11982
12137
  var ZipConverter = class {
11983
12138
  async convert(source, options = {}) {
11984
- if (options.file_extension?.toLowerCase() !== ".zip") return null;
12139
+ if (options.extension !== "zip") return null;
11985
12140
  const files = (0, fflate.unzipSync)(source, { filter: (file) => !file.name.endsWith("/") });
11986
- const converters = options._parent_converters ?? [];
12141
+ const converters = options._converters ?? [];
11987
12142
  const sections = [`Content from the zip file \`${options.url ?? "archive.zip"}\`:`];
11988
12143
  for (const [name, bytes] of Object.entries(files)) {
11989
12144
  const result = await convertEntry(bytes, name, converters, options);
11990
12145
  if (result) sections.push(`## File: ${name}\n\n${result.markdown}`);
11991
12146
  }
11992
- const markdown = sections.join("\n\n");
11993
12147
  return {
11994
12148
  title: null,
11995
- markdown,
11996
- text_content: markdown
12149
+ markdown: sections.join("\n\n")
11997
12150
  };
11998
12151
  }
11999
12152
  };
@@ -12002,9 +12155,9 @@ async function convertEntry(source, name, converters, options) {
12002
12155
  if (!extension) return null;
12003
12156
  const entryOptions = {
12004
12157
  ...options,
12005
- file_extension: extension,
12158
+ extension,
12006
12159
  url: void 0,
12007
- _parent_converters: converters
12160
+ _converters: converters
12008
12161
  };
12009
12162
  for (const converter of converters) try {
12010
12163
  const result = await converter.convert(source, entryOptions);
@@ -12012,42 +12165,38 @@ async function convertEntry(source, name, converters, options) {
12012
12165
  } catch {}
12013
12166
  return null;
12014
12167
  }
12015
- //#endregion
12016
- //#region src/markitdown.ts
12168
+ // src/markitdown.ts
12017
12169
  var MarkItDown = class {
12018
12170
  constructor() {
12019
- this.converters = [];
12020
- this.registerConverter(new PlainTextConverter());
12021
- this.registerConverter(new HtmlConverter());
12022
- this.registerConverter(new ZipConverter());
12023
- this.registerConverter(new RSSConverter());
12024
- this.registerConverter(new WikipediaConverter());
12025
- this.registerConverter(new YouTubeConverter());
12026
- this.registerConverter(new BingSerpConverter());
12027
- this.registerConverter(new DocxConverter());
12028
- this.registerConverter(new XlsxConverter());
12029
- this.registerConverter(new PptxConverter());
12030
- this.registerConverter(new PdfConverter());
12031
- this.registerConverter(new IpynbConverter());
12171
+ _defineProperty(this, "converters", []);
12172
+ const ordered = [
12173
+ PlainTextConverter,
12174
+ HtmlConverter,
12175
+ ZipConverter,
12176
+ RSSConverter,
12177
+ WikipediaConverter,
12178
+ YouTubeConverter,
12179
+ BingSerpConverter,
12180
+ DocxConverter,
12181
+ XlsxConverter,
12182
+ PptxConverter,
12183
+ PdfConverter,
12184
+ IpynbConverter
12185
+ ];
12186
+ for (const converter of ordered) this.registerConverter(new converter());
12032
12187
  }
12033
12188
  /** Convert a URL, response, blob, array buffer, data view, or typed array. */
12034
12189
  async convert(source, options = {}) {
12035
12190
  if (typeof source === "string" || source instanceof URL) return this.convertUrl(source.toString(), options);
12036
12191
  if (isResponse(source)) return this.convertResponse(source, options);
12037
- const extensions = /* @__PURE__ */ new Set();
12038
- this.addExtension(extensions, options.file_extension?.replace(/^\./, ""));
12039
- if (isBlob(source)) {
12040
- this.addExtension(extensions, extensionFromMime(source.type));
12041
- if ("name" in source && typeof source.name === "string") this.addExtension(extensions, extensionFromPathname(source.name));
12042
- }
12043
- if (extensions.size === 0) throw new Error("Could not determine the file type. Provide `file_extension` when converting bytes.");
12044
- return this.convertBytes(await toUint8Array(source), extensions, options);
12045
- }
12046
- /**
12047
- * @deprecated Pass the byte source directly to `convert`.
12048
- */
12049
- async convertBuffer(source, options) {
12050
- return this.convert(source, options);
12192
+ const bytes = await toUint8Array(source);
12193
+ const extensions = await detectExtensions(bytes, {
12194
+ extension: options.extension,
12195
+ filename: isBlob(source) && "name" in source ? String(source.name) : null,
12196
+ urls: [options.url],
12197
+ contentType: isBlob(source) ? source.type : null
12198
+ });
12199
+ return this.convertBytes(bytes, extensions, options);
12051
12200
  }
12052
12201
  async convertUrl(source, { fetch: fetchImplementation = globalThis.fetch, ...options }) {
12053
12202
  const url = new URL(source);
@@ -12061,44 +12210,39 @@ var MarkItDown = class {
12061
12210
  });
12062
12211
  }
12063
12212
  async convertResponse(response, options) {
12064
- const extensions = /* @__PURE__ */ new Set();
12065
- this.addExtension(extensions, options.file_extension);
12066
- this.addExtension(extensions, extensionFromMime(response.headers.get("content-type")));
12067
- const filename = (response.headers.get("content-disposition") ?? "").match(/filename\*?=(?:UTF-8''|["']?)([^;"']+)/i)?.[1];
12068
- if (filename) this.addExtension(extensions, extensionFromPathname(decodeURIComponent(filename.trim())));
12069
- const responseUrl = options.url || response.url;
12070
- if (responseUrl) this.addExtension(extensions, extensionFromPathname(new URL(responseUrl).pathname));
12071
- if (extensions.size === 0) throw new Error("Could not determine the file type. Provide `file_extension` or a Content-Type header.");
12072
- return this.convertBytes(new Uint8Array(await response.arrayBuffer()), extensions, {
12213
+ const bytes = new Uint8Array(await response.arrayBuffer());
12214
+ const extensions = await detectExtensions(bytes, {
12215
+ extension: options.extension,
12216
+ filename: filenameFromDisposition(response.headers.get("content-disposition")),
12217
+ urls: [options.url, response.url],
12218
+ contentType: response.headers.get("content-type")
12219
+ });
12220
+ return this.convertBytes(bytes, extensions, {
12073
12221
  ...options,
12074
- url: responseUrl
12222
+ url: options.url || response.url || void 0
12075
12223
  });
12076
12224
  }
12077
12225
  async convertBytes(source, extensions, options) {
12226
+ if (extensions.length === 0) throw new Error("Could not determine the file type. Provide `extension` for better results.");
12078
12227
  let lastError;
12079
12228
  for (const extension of extensions) for (const converter of this.converters) try {
12080
12229
  const result = await converter.convert(source, {
12081
12230
  ...options,
12082
- file_extension: extension,
12083
- _parent_converters: this.converters
12231
+ extension,
12232
+ _converters: this.converters
12084
12233
  });
12085
12234
  if (result) {
12086
12235
  result.markdown = result.markdown.replace(/\r\n|\r|\n/g, "\n").trim().replace(/\n{3,}/g, "\n\n");
12087
- result.text_content = result.markdown;
12088
12236
  return result;
12089
12237
  }
12090
12238
  } catch (error) {
12091
12239
  if (options.debug) console.error("Converter threw error:", error);
12092
12240
  lastError = error;
12093
12241
  }
12094
- const formats = [...extensions].join(", ");
12242
+ const formats = extensions.join(", ");
12095
12243
  if (lastError) throw new Error(`Could not convert ${formats} to Markdown: ${String(lastError)}`);
12096
12244
  throw new Error(`Unsupported file type: ${formats}.`);
12097
12245
  }
12098
- addExtension(extensions, extension) {
12099
- if (!extension) return;
12100
- extensions.add(extension.startsWith(".") ? extension.toLowerCase() : `.${extension.toLowerCase()}`);
12101
- }
12102
12246
  registerConverter(converter) {
12103
12247
  this.converters.unshift(converter);
12104
12248
  }
@@ -12106,7 +12250,6 @@ var MarkItDown = class {
12106
12250
  function isResponse(value) {
12107
12251
  return typeof Response !== "undefined" && value instanceof Response;
12108
12252
  }
12109
- //#endregion
12110
12253
  exports.MarkItDown = MarkItDown;
12111
12254
 
12112
12255
  //# sourceMappingURL=index.cjs.map