ooxml-core 1.27.0 → 1.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{PptxHandler-6ZGALYYM.cjs → PptxHandler-FRQKHTCM.cjs} +3 -3
  2. package/dist/PptxHandler-RETSKQ5E.mjs +4 -0
  3. package/dist/{PptxHandler-HEPPGI32.mjs → PptxHandler-WRJXTPGV.mjs} +2 -2
  4. package/dist/{PresentationBuilder-BCDRASRT.mjs → PresentationBuilder-LWR5X3JA.mjs} +2 -2
  5. package/dist/{PresentationBuilder-OQOZE76H.mjs → PresentationBuilder-POXKHTV7.mjs} +2 -2
  6. package/dist/{PresentationBuilder-HFGK2BWN.cjs → PresentationBuilder-YO5YOTA3.cjs} +5 -5
  7. package/dist/{chunk-MU3XSASV.cjs → chunk-36TR3PER.cjs} +270 -13
  8. package/dist/{chunk-4SGBL2H4.mjs → chunk-3VIPI6IA.mjs} +4 -4
  9. package/dist/{chunk-KE2FUFIU.mjs → chunk-6LCBTFNL.mjs} +253 -380
  10. package/dist/{chunk-VRJOOHWV.mjs → chunk-G67MARDL.mjs} +271 -17
  11. package/dist/{chunk-2XMK5SXU.mjs → chunk-I57SMSU6.mjs} +268 -14
  12. package/dist/{chunk-HYCOBPCC.cjs → chunk-K6DNX3YC.cjs} +1330 -1457
  13. package/dist/{chunk-7E45SAZJ.mjs → chunk-RNUYMB73.mjs} +253 -380
  14. package/dist/{chunk-63GRFYAN.mjs → chunk-TIQWSSGI.mjs} +1 -1
  15. package/dist/{chunk-ANIFYTKH.mjs → chunk-XW4XB6P4.mjs} +1 -1
  16. package/dist/pptx/automation/index.cjs +555 -416
  17. package/dist/pptx/automation/index.d.ts +3 -3
  18. package/dist/pptx/automation/index.mjs +5 -5
  19. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts → index-CdRlUz-v.d.ts} +2 -2
  20. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts.map → index-CdRlUz-v.d.ts.map} +1 -1
  21. package/dist/pptx/chunks/{index-D8DNpc1X.d.ts → index-D_d4NTVP.d.ts} +36 -3
  22. package/dist/pptx/chunks/index-D_d4NTVP.d.ts.map +1 -0
  23. package/dist/pptx/chunks/{index-CbFowkp4.d.ts → index-lwMA6pP5.d.ts} +18 -5
  24. package/dist/pptx/chunks/index-lwMA6pP5.d.ts.map +1 -0
  25. package/dist/pptx/cli/index.cjs +555 -416
  26. package/dist/pptx/cli/index.mjs +4 -4
  27. package/dist/pptx/converter/index.d.ts +1 -1
  28. package/dist/pptx/converter/index.mjs +2 -2
  29. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  30. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  31. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  32. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  33. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  34. package/dist/pptx/index.cjs +557 -416
  35. package/dist/pptx/index.d.ts +4 -4
  36. package/dist/pptx/index.mjs +5 -5
  37. package/dist/pptx/node/index.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/dist/PptxHandler-NO7MNGOW.mjs +0 -4
  40. package/dist/pptx/chunks/index-CbFowkp4.d.ts.map +0 -1
  41. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +0 -1
@@ -51029,6 +51029,272 @@ var init_chart_data_sheet = __esm({
51029
51029
  }
51030
51030
  });
51031
51031
 
51032
+ // pptx/core/utils/modern-comment-mention-read.ts
51033
+ function readCommentMentions(node, authorName) {
51034
+ if (!node) {
51035
+ return void 0;
51036
+ }
51037
+ const found = [];
51038
+ for (const list3 of mentionChildrenNamed(node, "mentionLst")) {
51039
+ for (const entry2 of mentionChildrenNamed(list3, "mention")) {
51040
+ const mention = readMention(entry2, authorName);
51041
+ if (mention) {
51042
+ found.push(mention);
51043
+ }
51044
+ }
51045
+ }
51046
+ for (const extension of mentionChildrenNamed(mentionChildrenNamed(node, "extLst")[0], "ext")) {
51047
+ const uri = String(extension["@_uri"] || "");
51048
+ for (const list3 of mentionChildrenNamed(extension, "mentionLst")) {
51049
+ for (const entry2 of mentionChildrenNamed(list3, "mention")) {
51050
+ const mention = readMention(entry2, authorName, uri);
51051
+ if (mention) {
51052
+ found.push(mention);
51053
+ }
51054
+ }
51055
+ }
51056
+ }
51057
+ found.sort((a, b) => a.startIndex - b.startIndex);
51058
+ return found.length > 0 ? found : void 0;
51059
+ }
51060
+ var mentionLocalName, mentionNodesOf, mentionChildrenNamed, MENTION_PERSON_KEYS, MENTION_LENGTH_KEYS, attribute3, integer2, readMention;
51061
+ var init_modern_comment_mention_read = __esm({
51062
+ "pptx/core/utils/modern-comment-mention-read.ts"() {
51063
+ mentionLocalName = (key2) => key2.split(":").pop() || key2;
51064
+ mentionNodesOf = (value) => {
51065
+ if (Array.isArray(value)) {
51066
+ return value.filter((entry2) => Boolean(entry2) && typeof entry2 === "object");
51067
+ }
51068
+ return value && typeof value === "object" ? [value] : [];
51069
+ };
51070
+ mentionChildrenNamed = (node, name) => {
51071
+ if (!node) {
51072
+ return [];
51073
+ }
51074
+ const result = [];
51075
+ for (const [key2, value] of Object.entries(node)) {
51076
+ if (!key2.startsWith("@_") && mentionLocalName(key2) === name) {
51077
+ result.push(...mentionNodesOf(value));
51078
+ }
51079
+ }
51080
+ return result;
51081
+ };
51082
+ MENTION_PERSON_KEYS = [
51083
+ "@_mentionpersonId",
51084
+ "@_mentionPersonId",
51085
+ "@_personId",
51086
+ "@_authorId"
51087
+ ];
51088
+ MENTION_LENGTH_KEYS = ["@_length", "@_mentionCharCount", "@_len"];
51089
+ attribute3 = (node, keys) => {
51090
+ for (const key2 of keys) {
51091
+ const value = node[key2];
51092
+ if (value !== void 0 && value !== null && String(value).length > 0) {
51093
+ return String(value);
51094
+ }
51095
+ }
51096
+ return void 0;
51097
+ };
51098
+ integer2 = (value) => {
51099
+ if (value === void 0) {
51100
+ return void 0;
51101
+ }
51102
+ const parsed = Number.parseInt(value, 10);
51103
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
51104
+ };
51105
+ readMention = (node, authorName, containerUri) => {
51106
+ const personId = attribute3(node, MENTION_PERSON_KEYS);
51107
+ const startIndex = integer2(attribute3(node, ["@_startIndex"]));
51108
+ const length = integer2(attribute3(node, MENTION_LENGTH_KEYS));
51109
+ if (!personId || startIndex === void 0 || length === void 0 || length === 0) {
51110
+ return void 0;
51111
+ }
51112
+ return {
51113
+ personId,
51114
+ startIndex,
51115
+ length,
51116
+ id: attribute3(node, ["@_mentionId", "@_id"]),
51117
+ authorName: authorName(personId),
51118
+ containerUri,
51119
+ rawXml: node
51120
+ };
51121
+ };
51122
+ }
51123
+ });
51124
+
51125
+ // pptx/core/utils/modern-comment-mentions.ts
51126
+ function rebaseCommentMentions(mentions, oldText, newText, loaded) {
51127
+ if (!mentions || mentions.length === 0) {
51128
+ return void 0;
51129
+ }
51130
+ if (oldText === newText) {
51131
+ return mentions;
51132
+ }
51133
+ const prefix = commonPrefixLength(oldText, newText);
51134
+ const suffix = commonSuffixLength(
51135
+ oldText,
51136
+ newText,
51137
+ Math.min(oldText.length, newText.length) - prefix
51138
+ );
51139
+ const changeEnd = oldText.length - suffix;
51140
+ const delta2 = newText.length - oldText.length;
51141
+ const result = [];
51142
+ for (const mention of mentions) {
51143
+ const start = mention.startIndex;
51144
+ const end = start + mention.length;
51145
+ const coverage = loaded ? loadedCoverage(mention, loaded, oldText) : [];
51146
+ if (coverage === void 0 || coverage.includes(newText.slice(start, end))) {
51147
+ if (start >= 0 && mention.length > 0 && end <= newText.length) {
51148
+ result.push(mention);
51149
+ }
51150
+ continue;
51151
+ }
51152
+ const span = oldText.slice(start, end);
51153
+ if (span.length !== mention.length) {
51154
+ continue;
51155
+ }
51156
+ let next = -1;
51157
+ if (end <= prefix) {
51158
+ next = start;
51159
+ } else if (start >= changeEnd) {
51160
+ next = start + delta2;
51161
+ }
51162
+ if (next >= 0 && newText.slice(next, next + mention.length) === span) {
51163
+ result.push(next === start ? mention : { ...mention, startIndex: next });
51164
+ continue;
51165
+ }
51166
+ const relocated = nearestOccurrence(newText, span, next >= 0 ? next : start);
51167
+ if (relocated >= 0) {
51168
+ result.push({ ...mention, startIndex: relocated });
51169
+ }
51170
+ }
51171
+ return result.length > 0 ? result : void 0;
51172
+ }
51173
+ function buildMentionListNode(mentions) {
51174
+ if (!mentions || mentions.length === 0) {
51175
+ return void 0;
51176
+ }
51177
+ return { "p188:mention": mentions.map(buildMention) };
51178
+ }
51179
+ function applyCommentMentions(node, mentions, extension, replace) {
51180
+ if (!replace) {
51181
+ return extension;
51182
+ }
51183
+ const { direct, byUri } = groupByContainer(mentions);
51184
+ const directList = buildMentionListNode(direct);
51185
+ if (directList) {
51186
+ node["p188:mentionLst"] = directList;
51187
+ }
51188
+ if (!extension) {
51189
+ return void 0;
51190
+ }
51191
+ const rebuilt = stripMentionLists(extension);
51192
+ const extensionKey = Object.keys(rebuilt).find((key2) => mentionLocalName(key2) === "ext") || "p188:ext";
51193
+ const entries = mentionNodesOf(rebuilt[extensionKey]).map((entry2) => {
51194
+ const list3 = buildMentionListNode(byUri.get(String(entry2["@_uri"] || "")));
51195
+ const next = stripMentionLists(entry2);
51196
+ if (list3) {
51197
+ next["p188:mentionLst"] = list3;
51198
+ }
51199
+ return next;
51200
+ });
51201
+ if (entries.length > 0) {
51202
+ rebuilt[extensionKey] = entries.length === 1 ? entries[0] : entries;
51203
+ }
51204
+ return rebuilt;
51205
+ }
51206
+ var commonPrefixLength, commonSuffixLength, nearestOccurrence, loadedCoverage, buildMention, stripMentionLists, groupByContainer;
51207
+ var init_modern_comment_mentions = __esm({
51208
+ "pptx/core/utils/modern-comment-mentions.ts"() {
51209
+ init_modern_comment_mention_read();
51210
+ init_modern_comment_mention_read();
51211
+ commonPrefixLength = (a, b) => {
51212
+ const max = Math.min(a.length, b.length);
51213
+ let index = 0;
51214
+ while (index < max && a[index] === b[index]) {
51215
+ index += 1;
51216
+ }
51217
+ return index;
51218
+ };
51219
+ commonSuffixLength = (a, b, limit) => {
51220
+ let index = 0;
51221
+ while (index < limit && a[a.length - 1 - index] === b[b.length - 1 - index]) {
51222
+ index += 1;
51223
+ }
51224
+ return index;
51225
+ };
51226
+ nearestOccurrence = (text2, span, hint) => {
51227
+ let best = -1;
51228
+ let bestDistance = Number.POSITIVE_INFINITY;
51229
+ let at2 = text2.indexOf(span);
51230
+ while (at2 !== -1) {
51231
+ const distance = Math.abs(at2 - hint);
51232
+ if (distance < bestDistance) {
51233
+ best = at2;
51234
+ bestDistance = distance;
51235
+ }
51236
+ at2 = text2.indexOf(span, at2 + 1);
51237
+ }
51238
+ return best;
51239
+ };
51240
+ loadedCoverage = (mention, loaded, oldText) => {
51241
+ const records = loaded.filter(
51242
+ (record2) => mention.id ? record2.id === mention.id : !record2.id && record2.personId === mention.personId && record2.length === mention.length
51243
+ );
51244
+ if (records.length === 0) {
51245
+ return void 0;
51246
+ }
51247
+ return records.map(
51248
+ (record2) => oldText.slice(record2.startIndex, record2.startIndex + record2.length)
51249
+ );
51250
+ };
51251
+ buildMention = (mention) => {
51252
+ const node = {};
51253
+ for (const [key2, value] of Object.entries(mention.rawXml || {})) {
51254
+ if (key2.startsWith("@_")) {
51255
+ node[key2] = value;
51256
+ }
51257
+ }
51258
+ const personKey = MENTION_PERSON_KEYS.find((key2) => node[key2] !== void 0) || "@_mentionpersonId";
51259
+ const lengthKey = MENTION_LENGTH_KEYS.find((key2) => node[key2] !== void 0) || "@_length";
51260
+ node[personKey] = mention.personId;
51261
+ node[lengthKey] = String(mention.length);
51262
+ node["@_startIndex"] = String(mention.startIndex);
51263
+ if (mention.id) {
51264
+ const idKey = node["@_id"] !== void 0 && node["@_mentionId"] === void 0 ? "@_id" : "@_mentionId";
51265
+ node[idKey] = mention.id;
51266
+ }
51267
+ return node;
51268
+ };
51269
+ stripMentionLists = (node) => {
51270
+ const result = {};
51271
+ for (const [key2, value] of Object.entries(node)) {
51272
+ if (key2.startsWith("@_") || mentionLocalName(key2) !== "mentionLst") {
51273
+ result[key2] = value;
51274
+ }
51275
+ }
51276
+ return result;
51277
+ };
51278
+ groupByContainer = (mentions) => {
51279
+ const direct = [];
51280
+ const byUri = /* @__PURE__ */ new Map();
51281
+ for (const mention of mentions || []) {
51282
+ if (!mention.containerUri) {
51283
+ direct.push(mention);
51284
+ continue;
51285
+ }
51286
+ const bucket = byUri.get(mention.containerUri);
51287
+ if (bucket) {
51288
+ bucket.push(mention);
51289
+ } else {
51290
+ byUri.set(mention.containerUri, [mention]);
51291
+ }
51292
+ }
51293
+ return { direct, byUri };
51294
+ };
51295
+ }
51296
+ });
51297
+
51032
51298
  // pptx/core/utils/index.ts
51033
51299
  var init_utils = __esm({
51034
51300
  "pptx/core/utils/index.ts"() {
@@ -58758,7 +59024,7 @@ var init_effect_style_extractor_fill_overlay = __esm({
58758
59024
  });
58759
59025
 
58760
59026
  // pptx/core/core/builders/effect-style-extractor-reflection.ts
58761
- function integer2(value) {
59027
+ function integer3(value) {
58762
59028
  if (value === void 0 || value === null || value === "") {
58763
59029
  return void 0;
58764
59030
  }
@@ -58775,19 +59041,19 @@ function boolean2(value) {
58775
59041
  return void 0;
58776
59042
  }
58777
59043
  function fixedFraction(value) {
58778
- const parsed = integer2(value);
59044
+ const parsed = integer3(value);
58779
59045
  return parsed !== void 0 && parsed >= 0 && parsed <= 1e5 ? parsed / 1e5 : void 0;
58780
59046
  }
58781
59047
  function extractReflectionAttributes(node, emuPerPx) {
58782
- const blur = integer2(node["@_blurRad"]);
58783
- const distance = integer2(node["@_dist"]);
58784
- const startOpacity = integer2(node["@_stA"]);
58785
- const endOpacity = integer2(node["@_endA"]);
58786
- const startPosition = integer2(node["@_stPos"]);
58787
- const endPosition = integer2(node["@_endPos"]);
58788
- const direction = integer2(node["@_dir"]);
58789
- const rotation = integer2(node["@_rot"]);
58790
- const fadeDirection = integer2(node["@_fadeDir"]);
59048
+ const blur = integer3(node["@_blurRad"]);
59049
+ const distance = integer3(node["@_dist"]);
59050
+ const startOpacity = integer3(node["@_stA"]);
59051
+ const endOpacity = integer3(node["@_endA"]);
59052
+ const startPosition = integer3(node["@_stPos"]);
59053
+ const endPosition = integer3(node["@_endPos"]);
59054
+ const direction = integer3(node["@_dir"]);
59055
+ const rotation = integer3(node["@_rot"]);
59056
+ const fadeDirection = integer3(node["@_fadeDir"]);
58791
59057
  const alignment = String(node["@_algn"] ?? "").trim();
58792
59058
  return {
58793
59059
  reflectionBlurRadius: blur !== void 0 && blur >= 0 ? blur / emuPerPx : void 0,
@@ -58799,10 +59065,10 @@ function extractReflectionAttributes(node, emuPerPx) {
58799
59065
  reflectionRotation: rotation !== void 0 ? rotation / 6e4 : void 0,
58800
59066
  reflectionDistance: distance !== void 0 && distance >= 0 ? distance / emuPerPx : void 0,
58801
59067
  reflectionFadeDirection: fadeDirection !== void 0 ? fadeDirection / 6e4 : void 0,
58802
- reflectionScaleX: integer2(node["@_sx"]),
58803
- reflectionScaleY: integer2(node["@_sy"]),
58804
- reflectionSkewX: integer2(node["@_kx"]),
58805
- reflectionSkewY: integer2(node["@_ky"]),
59068
+ reflectionScaleX: integer3(node["@_sx"]),
59069
+ reflectionScaleY: integer3(node["@_sy"]),
59070
+ reflectionSkewX: integer3(node["@_kx"]),
59071
+ reflectionSkewY: integer3(node["@_ky"]),
58806
59072
  reflectionAlignment: VALID_ALIGNMENTS.has(alignment) ? alignment : void 0,
58807
59073
  reflectionRotateWithShape: boolean2(node["@_rotWithShape"])
58808
59074
  };
@@ -64987,6 +65253,96 @@ var init_background_fill_shapes = __esm({
64987
65253
  }
64988
65254
  });
64989
65255
 
65256
+ // pptx/core/core/runtime/load-part-reader.ts
65257
+ function parseText2(parser, text2) {
65258
+ return text2 ? parser.parse(text2) : void 0;
65259
+ }
65260
+ function readPartText(zip, path4) {
65261
+ const reader2 = openReaders.get(zip);
65262
+ if (reader2) {
65263
+ return reader2.readText(path4);
65264
+ }
65265
+ return zip.file(path4)?.async("string") ?? Promise.resolve(void 0);
65266
+ }
65267
+ async function readPartXml(zip, parser, path4) {
65268
+ const reader2 = openReaders.get(zip);
65269
+ if (reader2) {
65270
+ return reader2.readXml(parser, path4);
65271
+ }
65272
+ const text2 = await zip.file(path4)?.async("string");
65273
+ return text2 ? parseText2(parser, text2) : void 0;
65274
+ }
65275
+ var openReaders, LoadPartReader;
65276
+ var init_load_part_reader = __esm({
65277
+ "pptx/core/core/runtime/load-part-reader.ts"() {
65278
+ openReaders = /* @__PURE__ */ new WeakMap();
65279
+ LoadPartReader = class {
65280
+ constructor(zip) {
65281
+ this.zip = zip;
65282
+ openReaders.set(zip, this);
65283
+ }
65284
+ zip;
65285
+ parts = /* @__PURE__ */ new Map();
65286
+ closed = false;
65287
+ entry(path4) {
65288
+ const file = this.zip.file(path4);
65289
+ if (!file) {
65290
+ this.parts.delete(path4);
65291
+ return void 0;
65292
+ }
65293
+ const previous = this.parts.get(path4);
65294
+ if (previous?.file === file) {
65295
+ return previous;
65296
+ }
65297
+ const entry2 = { file, text: file.async("string"), relationships: /* @__PURE__ */ new Map() };
65298
+ this.parts.set(path4, entry2);
65299
+ entry2.text.catch(() => {
65300
+ if (this.parts.get(path4) === entry2) {
65301
+ this.parts.delete(path4);
65302
+ }
65303
+ });
65304
+ return entry2;
65305
+ }
65306
+ readText(path4) {
65307
+ return this.entry(path4)?.text ?? Promise.resolve(void 0);
65308
+ }
65309
+ async readXml(parser, path4) {
65310
+ const entry2 = this.entry(path4);
65311
+ if (!entry2) {
65312
+ return void 0;
65313
+ }
65314
+ if (!path4.endsWith(".rels")) {
65315
+ return parseText2(parser, await entry2.text);
65316
+ }
65317
+ let parsed = entry2.relationships.get(parser);
65318
+ if (!parsed) {
65319
+ const pending = entry2.text.then((text2) => parseText2(parser, text2));
65320
+ entry2.relationships.set(parser, pending);
65321
+ pending.catch(() => {
65322
+ if (entry2.relationships.get(parser) === pending) {
65323
+ entry2.relationships.delete(parser);
65324
+ }
65325
+ });
65326
+ parsed = pending;
65327
+ }
65328
+ return structuredClone(await parsed);
65329
+ }
65330
+ /** Whether this reader still serves reads for its package. */
65331
+ get isOpen() {
65332
+ return !this.closed;
65333
+ }
65334
+ /** Drops every cached read; later reads of the package go to the archive. */
65335
+ close() {
65336
+ this.closed = true;
65337
+ if (openReaders.get(this.zip) === this) {
65338
+ openReaders.delete(this.zip);
65339
+ }
65340
+ this.parts.clear();
65341
+ }
65342
+ };
65343
+ }
65344
+ });
65345
+
64990
65346
  // pptx/core/core/builders/element-hidden-flag.ts
64991
65347
  function findCNvPr(shape) {
64992
65348
  if (!shape) {
@@ -65060,11 +65416,10 @@ var init_flatten_elements = __esm({
65060
65416
 
65061
65417
  // pptx/core/utils/slide-synchronization.ts
65062
65418
  async function loadSlideSynchronization(input) {
65063
- const relsXml = await input.zip.file(input.relsPath)?.async("string");
65064
- if (!relsXml) {
65419
+ const relsData = await readPartXml(input.zip, input.parser, input.relsPath);
65420
+ if (!relsData) {
65065
65421
  return void 0;
65066
65422
  }
65067
- const relsData = input.parser.parse(relsXml);
65068
65423
  const relationship2 = findSlideSyncRelationship(relsData);
65069
65424
  if (!relationship2) {
65070
65425
  return void 0;
@@ -65074,7 +65429,7 @@ async function loadSlideSynchronization(input) {
65074
65429
  return void 0;
65075
65430
  }
65076
65431
  const partPath = resolvePartPath2(input.slidePath, target);
65077
- const partXml = await input.zip.file(partPath)?.async("string");
65432
+ const partXml = await readPartText(input.zip, partPath);
65078
65433
  if (!partXml) {
65079
65434
  return void 0;
65080
65435
  }
@@ -65195,6 +65550,7 @@ function nextSlideSyncPath(files) {
65195
65550
  var SLIDE_SYNC_CONTENT_TYPE;
65196
65551
  var init_slide_synchronization = __esm({
65197
65552
  "pptx/core/utils/slide-synchronization.ts"() {
65553
+ init_load_part_reader();
65198
65554
  SLIDE_SYNC_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideSyncData+xml";
65199
65555
  }
65200
65556
  });
@@ -65208,11 +65564,10 @@ function ensureArray8(value) {
65208
65564
  }
65209
65565
  async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
65210
65566
  try {
65211
- const relsXml = await zip.file(relsPath2)?.async("string");
65212
- if (!relsXml) {
65567
+ const relsData = await readPartXml(zip, parser, relsPath2);
65568
+ if (!relsData) {
65213
65569
  return [];
65214
65570
  }
65215
- const relsData = parser.parse(relsXml);
65216
65571
  const relationships3 = ensureArray8(
65217
65572
  relsData["Relationships"]?.["Relationship"]
65218
65573
  );
@@ -65235,7 +65590,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
65235
65590
  if (!resolved) {
65236
65591
  continue;
65237
65592
  }
65238
- const vmlXml = await zip.file(resolved)?.async("string");
65593
+ const vmlXml = await readPartText(zip, resolved);
65239
65594
  if (!vmlXml) {
65240
65595
  continue;
65241
65596
  }
@@ -65254,6 +65609,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
65254
65609
  var VML_DRAWING_REL_SUFFIX;
65255
65610
  var init_vml_drawing_loader = __esm({
65256
65611
  "pptx/core/utils/vml-drawing-loader.ts"() {
65612
+ init_load_part_reader();
65257
65613
  init_safe_path();
65258
65614
  init_vml_parser();
65259
65615
  VML_DRAWING_REL_SUFFIX = "/relationships/vmlDrawing";
@@ -67761,6 +68117,7 @@ var PptxSlideLoaderService;
67761
68117
  var init_PptxSlideLoaderService = __esm({
67762
68118
  "pptx/core/services/PptxSlideLoaderService.ts"() {
67763
68119
  init_background_fill_shapes();
68120
+ init_load_part_reader();
67764
68121
  init_element_hidden_flag();
67765
68122
  init_background_style_ref();
67766
68123
  init_flatten_elements();
@@ -67821,11 +68178,14 @@ var init_PptxSlideLoaderService = __esm({
67821
68178
  * @returns Map of relationship ID to target path string.
67822
68179
  */
67823
68180
  async loadPresentationSlideRels(params) {
67824
- const relsXml = await params.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
67825
- if (!relsXml) {
68181
+ const relsData = await readPartXml(
68182
+ params.zip,
68183
+ params.parser,
68184
+ "ppt/_rels/presentation.xml.rels"
68185
+ );
68186
+ if (!relsData) {
67826
68187
  return /* @__PURE__ */ new Map();
67827
68188
  }
67828
- const relsData = params.parser.parse(relsXml);
67829
68189
  const relationships3 = relsData["Relationships"]?.["Relationship"];
67830
68190
  const relNodes = this.toXmlObjectArray(relationships3);
67831
68191
  const relsMap = /* @__PURE__ */ new Map();
@@ -67865,7 +68225,7 @@ var init_PptxSlideLoaderService = __esm({
67865
68225
  if (!params.zip.file(path4)) {
67866
68226
  path4 = `ppt/${target}`;
67867
68227
  }
67868
- const slideXmlStr = await params.zip.file(path4)?.async("string");
68228
+ const slideXmlStr = await readPartText(params.zip, path4);
67869
68229
  if (!slideXmlStr) {
67870
68230
  return void 0;
67871
68231
  }
@@ -92054,12 +92414,11 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
92054
92414
  if (!external.targetPath || !external.embeddedWorkbookData) return false;
92055
92415
  const target = resolve2(chartPartPath, external.targetPath);
92056
92416
  let references = 0;
92057
- const parser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
92058
92417
  try {
92059
92418
  for (const path4 of Object.keys(zip.files)) {
92060
92419
  if (!path4.endsWith(".rels") || !path4.includes("/_rels/")) continue;
92061
92420
  const source = path4.replace("/_rels/", "/").slice(0, -5);
92062
- const tree = parser.parse(await zip.file(path4).async("string"));
92421
+ const tree = await readPartXml(zip, relationshipParser, path4);
92063
92422
  for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
92064
92423
  const relationshipTarget2 = xmlAttr(rel, "Target");
92065
92424
  if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve2(source, relationshipTarget2) === target)
@@ -92076,11 +92435,14 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
92076
92435
  return false;
92077
92436
  }
92078
92437
  }
92438
+ var relationshipParser;
92079
92439
  var init_chart_label_source = __esm({
92080
92440
  "pptx/core/utils/chart-label-source.ts"() {
92441
+ init_load_part_reader();
92081
92442
  init_chart_xlsx_writer();
92082
92443
  init_xml_access();
92083
92444
  init_chart_xlsx_cellref();
92445
+ relationshipParser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
92084
92446
  }
92085
92447
  });
92086
92448
 
@@ -92868,7 +93230,7 @@ function malformed(context, element, value) {
92868
93230
  function cBool(context, parent, local) {
92869
93231
  const element = cChild(parent, local);
92870
93232
  if (!element) return void 0;
92871
- const raw2 = attribute3(element, "val");
93233
+ const raw2 = attribute4(element, "val");
92872
93234
  if (raw2 === void 0) return true;
92873
93235
  const value = raw2.trim().toLowerCase();
92874
93236
  if (value === "1" || value === "true") return true;
@@ -92878,7 +93240,7 @@ function cBool(context, parent, local) {
92878
93240
  }
92879
93241
  function cNumber(context, parent, local) {
92880
93242
  const element = cChild(parent, local);
92881
- const raw2 = attribute3(element, "val");
93243
+ const raw2 = attribute4(element, "val");
92882
93244
  if (!element || raw2 === void 0) return void 0;
92883
93245
  const value = raw2.trim() ? Number(raw2) : Number.NaN;
92884
93246
  if (Number.isFinite(value)) return value;
@@ -92887,7 +93249,7 @@ function cNumber(context, parent, local) {
92887
93249
  }
92888
93250
  function cEnum(context, parent, local, allowed) {
92889
93251
  const element = cChild(parent, local);
92890
- const raw2 = attribute3(element, "val");
93252
+ const raw2 = attribute4(element, "val");
92891
93253
  if (!element || raw2 === void 0) return void 0;
92892
93254
  if (allowed.includes(raw2)) return raw2;
92893
93255
  malformed(context, element, raw2);
@@ -92944,9 +93306,9 @@ function chartLines(parent, local) {
92944
93306
  }
92945
93307
  function numberFormat(parent) {
92946
93308
  const element = cChild(parent, "numFmt");
92947
- const formatCode2 = attribute3(element, "formatCode");
93309
+ const formatCode2 = attribute4(element, "formatCode");
92948
93310
  if (formatCode2 === void 0) return void 0;
92949
- const linked = attribute3(element, "sourceLinked");
93311
+ const linked = attribute4(element, "sourceLinked");
92950
93312
  return {
92951
93313
  formatCode: formatCode2,
92952
93314
  ...linked === "1" || linked === "true" ? { sourceLinked: true } : {},
@@ -92970,7 +93332,7 @@ function assignDefined(target, values) {
92970
93332
  if (value !== void 0) target[key2] = value;
92971
93333
  return target;
92972
93334
  }
92973
- var cChild, attribute3, cVal, path, textProperties;
93335
+ var cChild, attribute4, cVal, path, textProperties;
92974
93336
  var init_parse_util = __esm({
92975
93337
  "chart/parse-util.ts"() {
92976
93338
  init_xml2();
@@ -92979,8 +93341,8 @@ var init_parse_util = __esm({
92979
93341
  init_manual_layout();
92980
93342
  init_xml_fragment();
92981
93343
  cChild = (parent, local) => first(parent, local, NS.c);
92982
- attribute3 = (element, name) => element?.hasAttribute(name) ? element.getAttribute(name) ?? void 0 : void 0;
92983
- cVal = (parent, local) => attribute3(cChild(parent, local), "val");
93344
+ attribute4 = (element, name) => element?.hasAttribute(name) ? element.getAttribute(name) ?? void 0 : void 0;
93345
+ cVal = (parent, local) => attribute4(cChild(parent, local), "val");
92984
93346
  path = (element) => `c:${element.parentNode?.localName ?? ""}/c:${element.localName}`;
92985
93347
  textProperties = (parent) => chartTextBody(cChild(parent, "txPr"));
92986
93348
  }
@@ -92992,9 +93354,9 @@ function parseCache(node) {
92992
93354
  type: node.localName === "numCache" || node.localName === "numLit" ? "number" : "string",
92993
93355
  points: children2(node, "pt", NS.c).map((pt2) => {
92994
93356
  const point2 = { value: cChild(pt2, "v")?.textContent ?? "" };
92995
- const index = Number(attribute3(pt2, "idx") ?? Number.NaN);
93357
+ const index = Number(attribute4(pt2, "idx") ?? Number.NaN);
92996
93358
  if (Number.isInteger(index) && index >= 0) point2.index = index;
92997
- const formatCode3 = attribute3(pt2, "formatCode");
93359
+ const formatCode3 = attribute4(pt2, "formatCode");
92998
93360
  if (formatCode3 !== void 0) point2.formatCode = formatCode3;
92999
93361
  return point2;
93000
93362
  })
@@ -93197,10 +93559,10 @@ function readDisplayNaAsBlank(chartExtLst) {
93197
93559
  return void 0;
93198
93560
  }
93199
93561
  for (const ext of elements(root)) {
93200
- if (ext.localName !== "ext" || attribute3(ext, "uri") !== DATA_DISPLAY_OPTIONS_URI) continue;
93562
+ if (ext.localName !== "ext" || attribute4(ext, "uri") !== DATA_DISPLAY_OPTIONS_URI) continue;
93201
93563
  const flag2 = first(first(ext, "dataDisplayOptions16", C16R3), "dispNaAsBlank", C16R3);
93202
93564
  if (!flag2) continue;
93203
- const raw2 = attribute3(flag2, "val")?.trim().toLowerCase();
93565
+ const raw2 = attribute4(flag2, "val")?.trim().toLowerCase();
93204
93566
  return raw2 === void 0 || raw2 === "1" || raw2 === "true";
93205
93567
  }
93206
93568
  return void 0;
@@ -93445,7 +93807,7 @@ function customSplit(context, element) {
93445
93807
  if (!element) return void 0;
93446
93808
  reportUnmodelled(context, element, /* @__PURE__ */ new Set(["secondPiePt"]));
93447
93809
  return children2(element, "secondPiePt", NS.c).flatMap((point2) => {
93448
- const raw2 = attribute3(point2, "val")?.trim();
93810
+ const raw2 = attribute4(point2, "val")?.trim();
93449
93811
  const index = raw2 ? Number(raw2) : Number.NaN;
93450
93812
  return Number.isInteger(index) && index >= 0 ? [index] : [];
93451
93813
  });
@@ -93466,7 +93828,7 @@ function parseGroup(context, element) {
93466
93828
  is3D,
93467
93829
  series: children2(element, "ser", NS.c).map((ser) => parseSeries(context, ser)),
93468
93830
  axisIds: children2(element, "axId", NS.c).flatMap((axis) => {
93469
- const raw2 = attribute3(axis, "val")?.trim();
93831
+ const raw2 = attribute4(axis, "val")?.trim();
93470
93832
  const id = raw2 ? Number(raw2) : Number.NaN;
93471
93833
  return Number.isFinite(id) ? [id] : [];
93472
93834
  })
@@ -93748,7 +94110,7 @@ function chartStyle(context, space) {
93748
94110
  }
93749
94111
  function c14Style(space) {
93750
94112
  for (const alternate of children2(space, "AlternateContent", NS.mc)) {
93751
- const raw2 = attribute3(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
94113
+ const raw2 = attribute4(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
93752
94114
  const value = raw2?.trim() ? Number(raw2) : Number.NaN;
93753
94115
  if (Number.isFinite(value)) return value;
93754
94116
  }
@@ -94437,7 +94799,7 @@ function malformed2(context, where, value) {
94437
94799
  });
94438
94800
  }
94439
94801
  function boolAttribute(context, element, name) {
94440
- const raw2 = attribute3(element, name);
94802
+ const raw2 = attribute4(element, name);
94441
94803
  if (!element || raw2 === void 0) return void 0;
94442
94804
  const value = raw2.trim().toLowerCase();
94443
94805
  if (value === "1" || value === "true") return true;
@@ -94446,7 +94808,7 @@ function boolAttribute(context, element, name) {
94446
94808
  return void 0;
94447
94809
  }
94448
94810
  function numberAttribute(context, element, name) {
94449
- const raw2 = attribute3(element, name);
94811
+ const raw2 = attribute4(element, name);
94450
94812
  if (!element || raw2 === void 0) return void 0;
94451
94813
  const value = raw2.trim() ? Number(raw2) : Number.NaN;
94452
94814
  if (Number.isFinite(value)) return value;
@@ -94456,11 +94818,11 @@ function numberAttribute(context, element, name) {
94456
94818
  function indexAttribute(context, element, name) {
94457
94819
  const value = numberAttribute(context, element, name);
94458
94820
  if (value === void 0 || Number.isInteger(value) && value >= 0) return value;
94459
- malformed2(context, path2(element, name), attribute3(element, name) ?? "");
94821
+ malformed2(context, path2(element, name), attribute4(element, name) ?? "");
94460
94822
  return void 0;
94461
94823
  }
94462
94824
  function autoNumberAttribute(context, element, name) {
94463
- return attribute3(element, name)?.trim() === "auto" ? "auto" : numberAttribute(context, element, name);
94825
+ return attribute4(element, name)?.trim() === "auto" ? "auto" : numberAttribute(context, element, name);
94464
94826
  }
94465
94827
  function reportUnmodelled2(context, element, handled) {
94466
94828
  for (const child31 of elements(element)) {
@@ -94491,9 +94853,9 @@ function lines(parent, local) {
94491
94853
  }
94492
94854
  function numberFormat2(parent) {
94493
94855
  const element = cxChild(parent, "numFmt");
94494
- const formatCode2 = attribute3(element, "formatCode");
94856
+ const formatCode2 = attribute4(element, "formatCode");
94495
94857
  if (formatCode2 === void 0) return void 0;
94496
- const linked = attribute3(element, "sourceLinked");
94858
+ const linked = attribute4(element, "sourceLinked");
94497
94859
  return {
94498
94860
  formatCode: formatCode2,
94499
94861
  ...linked === "1" || linked === "true" ? { sourceLinked: true } : {},
@@ -94504,7 +94866,7 @@ function formula(parent, local) {
94504
94866
  const element = cxChild(parent, local);
94505
94867
  if (!element) return void 0;
94506
94868
  const out = { formula: element.textContent ?? "" };
94507
- const direction = attribute3(element, "dir");
94869
+ const direction = attribute4(element, "dir");
94508
94870
  if (direction !== void 0) out.direction = direction;
94509
94871
  return out;
94510
94872
  }
@@ -94538,8 +94900,8 @@ function parseLevel(context, element) {
94538
94900
  { points: points7 },
94539
94901
  {
94540
94902
  pointCount: indexAttribute(context, element, "ptCount"),
94541
- formatCode: attribute3(element, "formatCode"),
94542
- name: attribute3(element, "name"),
94903
+ formatCode: attribute4(element, "formatCode"),
94904
+ name: attribute4(element, "name"),
94543
94905
  extLst: extensionList2(element)
94544
94906
  }
94545
94907
  );
@@ -94552,7 +94914,7 @@ function parseDimension(context, element) {
94552
94914
  levels: cxChildren(element, "lvl").map((level2) => parseLevel(context, level2))
94553
94915
  },
94554
94916
  {
94555
- type: attribute3(element, "type"),
94917
+ type: attribute4(element, "type"),
94556
94918
  formula: formula(element, "f"),
94557
94919
  nameFormula: formula(element, "nf"),
94558
94920
  extLst: extensionList2(element)
@@ -94586,7 +94948,7 @@ function parseChartData(context, element) {
94586
94948
  }
94587
94949
  return out;
94588
94950
  }
94589
- function parseText2(context, element) {
94951
+ function parseText3(context, element) {
94590
94952
  if (!element) return void 0;
94591
94953
  reportUnmodelled2(context, element, /* @__PURE__ */ new Set(["txData", "rich"]));
94592
94954
  const data = cxChild(element, "txData");
@@ -94606,11 +94968,11 @@ function parseTitle2(context, element) {
94606
94968
  return assignDefined(
94607
94969
  {},
94608
94970
  {
94609
- tx: parseText2(context, cxChild(element, "tx")),
94971
+ tx: parseText3(context, cxChild(element, "tx")),
94610
94972
  spPr: shapeProperties2(element),
94611
94973
  txPr: textProperties2(element),
94612
- position: attribute3(element, "pos"),
94613
- align: attribute3(element, "align"),
94974
+ position: attribute4(element, "pos"),
94975
+ align: attribute4(element, "align"),
94614
94976
  overlay: boolAttribute(context, element, "overlay"),
94615
94977
  extLst: extensionList2(element)
94616
94978
  }
@@ -94621,8 +94983,8 @@ function parseLegend2(context, element) {
94621
94983
  return assignDefined(
94622
94984
  {},
94623
94985
  {
94624
- position: attribute3(element, "pos"),
94625
- align: attribute3(element, "align"),
94986
+ position: attribute4(element, "pos"),
94987
+ align: attribute4(element, "align"),
94626
94988
  overlay: boolAttribute(context, element, "overlay"),
94627
94989
  spPr: shapeProperties2(element),
94628
94990
  txPr: textProperties2(element),
@@ -94671,7 +95033,7 @@ function parseUnits(context, element) {
94671
95033
  return assignDefined(
94672
95034
  {},
94673
95035
  {
94674
- unit: attribute3(element, "unit"),
95036
+ unit: attribute4(element, "unit"),
94675
95037
  label: label ? parseTitle2(context, label) : void 0,
94676
95038
  extLst: extensionList2(element)
94677
95039
  }
@@ -94722,7 +95084,7 @@ var init_parse_axis = __esm({
94722
95084
  "txPr",
94723
95085
  "extLst"
94724
95086
  ]);
94725
- tickMarks = (element) => element ? assignDefined({}, { type: attribute3(element, "type") }) : void 0;
95087
+ tickMarks = (element) => element ? assignDefined({}, { type: attribute4(element, "type") }) : void 0;
94726
95088
  }
94727
95089
  });
94728
95090
 
@@ -94741,7 +95103,7 @@ function labelVisibility(context, element) {
94741
95103
  function labelOptions2(context, element) {
94742
95104
  const separator = cxChild(element, "separator");
94743
95105
  return {
94744
- position: attribute3(element, "pos"),
95106
+ position: attribute4(element, "pos"),
94745
95107
  numberFormat: numberFormat2(element),
94746
95108
  spPr: shapeProperties2(element),
94747
95109
  txPr: textProperties2(element),
@@ -94774,7 +95136,7 @@ function parseBinning(context, element) {
94774
95136
  return assignDefined(
94775
95137
  {},
94776
95138
  {
94777
- intervalClosed: attribute3(element, "intervalClosed"),
95139
+ intervalClosed: attribute4(element, "intervalClosed"),
94778
95140
  underflow: autoNumberAttribute(context, element, "underflow"),
94779
95141
  overflow: autoNumberAttribute(context, element, "overflow"),
94780
95142
  binSize: scalar4("binSize"),
@@ -94787,11 +95149,11 @@ function parseGeography(context, element) {
94787
95149
  return assignDefined(
94788
95150
  {},
94789
95151
  {
94790
- projectionType: attribute3(element, "projectionType"),
94791
- viewedRegionType: attribute3(element, "viewedRegionType"),
94792
- cultureLanguage: attribute3(element, "cultureLanguage"),
94793
- cultureRegion: attribute3(element, "cultureRegion"),
94794
- attribution: attribute3(element, "attribution"),
95152
+ projectionType: attribute4(element, "projectionType"),
95153
+ viewedRegionType: attribute4(element, "viewedRegionType"),
95154
+ cultureLanguage: attribute4(element, "cultureLanguage"),
95155
+ cultureRegion: attribute4(element, "cultureRegion"),
95156
+ attribution: attribute4(element, "attribution"),
94795
95157
  geoCacheXml: rawChild2(element, "geoCache"),
94796
95158
  extLst: extensionList2(element)
94797
95159
  }
@@ -94807,8 +95169,8 @@ function parseLayout(context, element) {
94807
95169
  return assignDefined(
94808
95170
  {},
94809
95171
  {
94810
- parentLabelLayout: attribute3(cxChild(element, "parentLabelLayout"), "val"),
94811
- regionLabelLayout: attribute3(cxChild(element, "regionLabelLayout"), "val"),
95172
+ parentLabelLayout: attribute4(cxChild(element, "parentLabelLayout"), "val"),
95173
+ regionLabelLayout: attribute4(cxChild(element, "regionLabelLayout"), "val"),
94812
95174
  visibility: visibility ? assignDefined(
94813
95175
  {},
94814
95176
  Object.fromEntries(
@@ -94820,7 +95182,7 @@ function parseLayout(context, element) {
94820
95182
  geography: geography ? parseGeography(context, geography) : void 0,
94821
95183
  statistics: statistics ? assignDefined(
94822
95184
  {},
94823
- { quartileMethod: attribute3(statistics, "quartileMethod") }
95185
+ { quartileMethod: attribute4(statistics, "quartileMethod") }
94824
95186
  ) : void 0,
94825
95187
  subtotals: subtotals ? cxChildren(subtotals, "idx").map((idx) => indexAttribute(context, idx, "val")).filter((index) => index !== void 0) : void 0,
94826
95188
  extLst: extensionList2(element)
@@ -94845,13 +95207,13 @@ function parseSeries2(context, element) {
94845
95207
  const layout = cxChild(element, "layoutPr");
94846
95208
  const axisIds = cxChildren(element, "axisId").map((axis) => indexAttribute(context, axis, "val")).filter((id) => id !== void 0);
94847
95209
  return assignDefined(
94848
- { layoutId: attribute3(element, "layoutId") ?? "", dataPoints, axisIds },
95210
+ { layoutId: attribute4(element, "layoutId") ?? "", dataPoints, axisIds },
94849
95211
  {
94850
95212
  hidden: boolAttribute(context, element, "hidden"),
94851
95213
  ownerIndex: numberAttribute(context, element, "ownerIdx"),
94852
- uniqueId: attribute3(element, "uniqueId"),
95214
+ uniqueId: attribute4(element, "uniqueId"),
94853
95215
  formatIndex: numberAttribute(context, element, "formatIdx"),
94854
- tx: parseText2(context, cxChild(element, "tx")),
95216
+ tx: parseText3(context, cxChild(element, "tx")),
94855
95217
  spPr: shapeProperties2(element),
94856
95218
  txPr: textProperties2(element),
94857
95219
  valueColorsXml: rawChild2(element, "valueColors"),
@@ -98510,254 +98872,6 @@ var init_modern_comment_fields = __esm({
98510
98872
  }
98511
98873
  });
98512
98874
 
98513
- // pptx/core/utils/modern-comment-mention-read.ts
98514
- function readCommentMentions(node, authorName) {
98515
- if (!node) {
98516
- return void 0;
98517
- }
98518
- const found = [];
98519
- for (const list3 of mentionChildrenNamed(node, "mentionLst")) {
98520
- for (const entry2 of mentionChildrenNamed(list3, "mention")) {
98521
- const mention = readMention(entry2, authorName);
98522
- if (mention) {
98523
- found.push(mention);
98524
- }
98525
- }
98526
- }
98527
- for (const extension of mentionChildrenNamed(mentionChildrenNamed(node, "extLst")[0], "ext")) {
98528
- const uri = String(extension["@_uri"] || "");
98529
- for (const list3 of mentionChildrenNamed(extension, "mentionLst")) {
98530
- for (const entry2 of mentionChildrenNamed(list3, "mention")) {
98531
- const mention = readMention(entry2, authorName, uri);
98532
- if (mention) {
98533
- found.push(mention);
98534
- }
98535
- }
98536
- }
98537
- }
98538
- found.sort((a, b) => a.startIndex - b.startIndex);
98539
- return found.length > 0 ? found : void 0;
98540
- }
98541
- var mentionLocalName, mentionNodesOf, mentionChildrenNamed, MENTION_PERSON_KEYS, MENTION_LENGTH_KEYS, attribute4, integer3, readMention;
98542
- var init_modern_comment_mention_read = __esm({
98543
- "pptx/core/utils/modern-comment-mention-read.ts"() {
98544
- mentionLocalName = (key2) => key2.split(":").pop() || key2;
98545
- mentionNodesOf = (value) => {
98546
- if (Array.isArray(value)) {
98547
- return value.filter((entry2) => Boolean(entry2) && typeof entry2 === "object");
98548
- }
98549
- return value && typeof value === "object" ? [value] : [];
98550
- };
98551
- mentionChildrenNamed = (node, name) => {
98552
- if (!node) {
98553
- return [];
98554
- }
98555
- const result = [];
98556
- for (const [key2, value] of Object.entries(node)) {
98557
- if (!key2.startsWith("@_") && mentionLocalName(key2) === name) {
98558
- result.push(...mentionNodesOf(value));
98559
- }
98560
- }
98561
- return result;
98562
- };
98563
- MENTION_PERSON_KEYS = [
98564
- "@_mentionpersonId",
98565
- "@_mentionPersonId",
98566
- "@_personId",
98567
- "@_authorId"
98568
- ];
98569
- MENTION_LENGTH_KEYS = ["@_length", "@_mentionCharCount", "@_len"];
98570
- attribute4 = (node, keys) => {
98571
- for (const key2 of keys) {
98572
- const value = node[key2];
98573
- if (value !== void 0 && value !== null && String(value).length > 0) {
98574
- return String(value);
98575
- }
98576
- }
98577
- return void 0;
98578
- };
98579
- integer3 = (value) => {
98580
- if (value === void 0) {
98581
- return void 0;
98582
- }
98583
- const parsed = Number.parseInt(value, 10);
98584
- return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
98585
- };
98586
- readMention = (node, authorName, containerUri) => {
98587
- const personId = attribute4(node, MENTION_PERSON_KEYS);
98588
- const startIndex = integer3(attribute4(node, ["@_startIndex"]));
98589
- const length = integer3(attribute4(node, MENTION_LENGTH_KEYS));
98590
- if (!personId || startIndex === void 0 || length === void 0 || length === 0) {
98591
- return void 0;
98592
- }
98593
- return {
98594
- personId,
98595
- startIndex,
98596
- length,
98597
- id: attribute4(node, ["@_mentionId", "@_id"]),
98598
- authorName: authorName(personId),
98599
- containerUri,
98600
- rawXml: node
98601
- };
98602
- };
98603
- }
98604
- });
98605
-
98606
- // pptx/core/utils/modern-comment-mentions.ts
98607
- function rebaseCommentMentions(mentions, oldText, newText) {
98608
- if (!mentions || mentions.length === 0) {
98609
- return void 0;
98610
- }
98611
- if (oldText === newText) {
98612
- return mentions;
98613
- }
98614
- const prefix = commonPrefixLength(oldText, newText);
98615
- const suffix = commonSuffixLength(
98616
- oldText,
98617
- newText,
98618
- Math.min(oldText.length, newText.length) - prefix
98619
- );
98620
- const changeEnd = oldText.length - suffix;
98621
- const delta2 = newText.length - oldText.length;
98622
- const result = [];
98623
- for (const mention of mentions) {
98624
- const start = mention.startIndex;
98625
- const end = start + mention.length;
98626
- const span = oldText.slice(start, end);
98627
- if (span.length !== mention.length) {
98628
- continue;
98629
- }
98630
- let next = -1;
98631
- if (end <= prefix) {
98632
- next = start;
98633
- } else if (start >= changeEnd) {
98634
- next = start + delta2;
98635
- }
98636
- if (next >= 0 && newText.slice(next, next + mention.length) === span) {
98637
- result.push(next === start ? mention : { ...mention, startIndex: next });
98638
- continue;
98639
- }
98640
- const relocated = nearestOccurrence(newText, span, next >= 0 ? next : start);
98641
- if (relocated >= 0) {
98642
- result.push({ ...mention, startIndex: relocated });
98643
- }
98644
- }
98645
- return result.length > 0 ? result : void 0;
98646
- }
98647
- function buildMentionListNode(mentions) {
98648
- if (!mentions || mentions.length === 0) {
98649
- return void 0;
98650
- }
98651
- return { "p188:mention": mentions.map(buildMention) };
98652
- }
98653
- function applyCommentMentions(node, mentions, extension, replace) {
98654
- if (!replace) {
98655
- return extension;
98656
- }
98657
- const { direct, byUri } = groupByContainer(mentions);
98658
- const directList = buildMentionListNode(direct);
98659
- if (directList) {
98660
- node["p188:mentionLst"] = directList;
98661
- }
98662
- if (!extension) {
98663
- return void 0;
98664
- }
98665
- const rebuilt = stripMentionLists(extension);
98666
- const extensionKey = Object.keys(rebuilt).find((key2) => mentionLocalName(key2) === "ext") || "p188:ext";
98667
- const entries = mentionNodesOf(rebuilt[extensionKey]).map((entry2) => {
98668
- const list3 = buildMentionListNode(byUri.get(String(entry2["@_uri"] || "")));
98669
- const next = stripMentionLists(entry2);
98670
- if (list3) {
98671
- next["p188:mentionLst"] = list3;
98672
- }
98673
- return next;
98674
- });
98675
- if (entries.length > 0) {
98676
- rebuilt[extensionKey] = entries.length === 1 ? entries[0] : entries;
98677
- }
98678
- return rebuilt;
98679
- }
98680
- var commonPrefixLength, commonSuffixLength, nearestOccurrence, buildMention, stripMentionLists, groupByContainer;
98681
- var init_modern_comment_mentions = __esm({
98682
- "pptx/core/utils/modern-comment-mentions.ts"() {
98683
- init_modern_comment_mention_read();
98684
- init_modern_comment_mention_read();
98685
- commonPrefixLength = (a, b) => {
98686
- const max = Math.min(a.length, b.length);
98687
- let index = 0;
98688
- while (index < max && a[index] === b[index]) {
98689
- index += 1;
98690
- }
98691
- return index;
98692
- };
98693
- commonSuffixLength = (a, b, limit) => {
98694
- let index = 0;
98695
- while (index < limit && a[a.length - 1 - index] === b[b.length - 1 - index]) {
98696
- index += 1;
98697
- }
98698
- return index;
98699
- };
98700
- nearestOccurrence = (text2, span, hint) => {
98701
- let best = -1;
98702
- let bestDistance = Number.POSITIVE_INFINITY;
98703
- let at2 = text2.indexOf(span);
98704
- while (at2 !== -1) {
98705
- const distance = Math.abs(at2 - hint);
98706
- if (distance < bestDistance) {
98707
- best = at2;
98708
- bestDistance = distance;
98709
- }
98710
- at2 = text2.indexOf(span, at2 + 1);
98711
- }
98712
- return best;
98713
- };
98714
- buildMention = (mention) => {
98715
- const node = {};
98716
- for (const [key2, value] of Object.entries(mention.rawXml || {})) {
98717
- if (key2.startsWith("@_")) {
98718
- node[key2] = value;
98719
- }
98720
- }
98721
- const personKey = MENTION_PERSON_KEYS.find((key2) => node[key2] !== void 0) || "@_mentionpersonId";
98722
- const lengthKey = MENTION_LENGTH_KEYS.find((key2) => node[key2] !== void 0) || "@_length";
98723
- node[personKey] = mention.personId;
98724
- node[lengthKey] = String(mention.length);
98725
- node["@_startIndex"] = String(mention.startIndex);
98726
- if (mention.id) {
98727
- const idKey = node["@_id"] !== void 0 && node["@_mentionId"] === void 0 ? "@_id" : "@_mentionId";
98728
- node[idKey] = mention.id;
98729
- }
98730
- return node;
98731
- };
98732
- stripMentionLists = (node) => {
98733
- const result = {};
98734
- for (const [key2, value] of Object.entries(node)) {
98735
- if (key2.startsWith("@_") || mentionLocalName(key2) !== "mentionLst") {
98736
- result[key2] = value;
98737
- }
98738
- }
98739
- return result;
98740
- };
98741
- groupByContainer = (mentions) => {
98742
- const direct = [];
98743
- const byUri = /* @__PURE__ */ new Map();
98744
- for (const mention of mentions || []) {
98745
- if (!mention.containerUri) {
98746
- direct.push(mention);
98747
- continue;
98748
- }
98749
- const bucket = byUri.get(mention.containerUri);
98750
- if (bucket) {
98751
- bucket.push(mention);
98752
- } else {
98753
- byUri.set(mention.containerUri, [mention]);
98754
- }
98755
- }
98756
- return { direct, byUri };
98757
- };
98758
- }
98759
- });
98760
-
98761
98875
  // pptx/core/utils/modern-comment-text-body.ts
98762
98876
  function flattenBodyText(node) {
98763
98877
  if (!node) {
@@ -99151,7 +99265,13 @@ var init_modern_comment_xml = __esm({
99151
99265
  const originalBody = child23(raw2, "txBody");
99152
99266
  node["p188:txBody"] = applyModernCommentText(originalBody, comment.text);
99153
99267
  const originalText = originalBody ? flattenBodyText(originalBody).join("\n") : comment.text;
99154
- const mentions = rebaseCommentMentions(comment.mentions, originalText, comment.text);
99268
+ const loadedMentions = raw2 ? readCommentMentions(raw2, () => void 0) : void 0;
99269
+ const mentions = rebaseCommentMentions(
99270
+ comment.mentions,
99271
+ originalText,
99272
+ comment.text,
99273
+ loadedMentions ?? []
99274
+ );
99155
99275
  const extension = applyCommentMentions(node, mentions, child23(raw2, "extLst"), ownsMentions);
99156
99276
  if (extension) {
99157
99277
  node["p188:extLst"] = extension;
@@ -108644,8 +108764,8 @@ async function discoverTagCollections(zip, codec) {
108644
108764
  if (!sourcePartPath) {
108645
108765
  continue;
108646
108766
  }
108647
- const data = codec.parse(await relFile.async("string"));
108648
- const root = data["Relationships"];
108767
+ const data = await readPartXml(zip, codec, relFile.name);
108768
+ const root = data?.["Relationships"];
108649
108769
  for (const relationship2 of ensureArray16(root?.["Relationship"])) {
108650
108770
  if (String(relationship2["@_Type"] ?? "") !== TAG_RELATIONSHIP_TYPE) {
108651
108771
  continue;
@@ -108750,7 +108870,7 @@ async function removeTagContentTypeOverride(zip, codec, path4) {
108750
108870
  zip.file("[Content_Types].xml", codec.build(data));
108751
108871
  }
108752
108872
  async function readTagCollection(zip, codec, path4) {
108753
- const xml = await zip.file(path4)?.async("string");
108873
+ const xml = await readPartText(zip, path4);
108754
108874
  if (!xml) {
108755
108875
  return void 0;
108756
108876
  }
@@ -108859,6 +108979,7 @@ function ensureArray16(value) {
108859
108979
  var TAG_RELATIONSHIP_TYPE, TAG_CONTENT_TYPE;
108860
108980
  var init_tag_package = __esm({
108861
108981
  "pptx/core/utils/tag-package.ts"() {
108982
+ init_load_part_reader();
108862
108983
  init_safe_path();
108863
108984
  init_tag_package_owning_element();
108864
108985
  TAG_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags";
@@ -113225,10 +113346,35 @@ var init_PptxHandlerRuntimeState = __esm({
113225
113346
  "pptx/core/core/runtime/PptxHandlerRuntimeState.ts"() {
113226
113347
  init_utils();
113227
113348
  init_part_rels_path();
113349
+ init_load_part_reader();
113228
113350
  init_template_element_baselines();
113229
113351
  PptxHandlerRuntime = class {
113230
113352
  /** The in-memory ZIP archive representing the OPC (.pptx) package. */
113231
113353
  zip;
113354
+ /** Shares part reads within the load in progress; see {@link LoadPartReader}. */
113355
+ loadPartReader;
113356
+ /** Opens a part reader for the current package, closing any earlier one. */
113357
+ beginPartReads() {
113358
+ this.endPartReads();
113359
+ const reader2 = new LoadPartReader(this.zip);
113360
+ this.loadPartReader = reader2;
113361
+ return reader2;
113362
+ }
113363
+ /** Closes `reader` (by default the open one) and releases its cached reads. */
113364
+ endPartReads(reader2 = this.loadPartReader) {
113365
+ reader2?.close();
113366
+ if (reader2 && this.loadPartReader === reader2) {
113367
+ this.loadPartReader = void 0;
113368
+ }
113369
+ }
113370
+ /** The text of a package part, shared within a load. */
113371
+ readPartText(path4) {
113372
+ return readPartText(this.zip, path4);
113373
+ }
113374
+ /** A parsed package part; relationship parts are parsed once per load. */
113375
+ readPartXml(path4) {
113376
+ return readPartXml(this.zip, this.parser, path4);
113377
+ }
113232
113378
  /** fast-xml-parser instance used to parse XML strings into JS objects. */
113233
113379
  parser;
113234
113380
  /** fast-xml-parser builder used to serialize JS objects back to XML strings. */
@@ -113647,11 +113793,11 @@ var init_PptxHandlerRuntimeState = __esm({
113647
113793
  * @param relsPath - Path of the `.rels` part; derived from `partPath` when omitted.
113648
113794
  */
113649
113795
  async loadPartRelationships(partPath, relsPath2) {
113650
- const relsXml = await this.zip.file(relsPath2 ?? partRelsPath(partPath))?.async("string");
113651
- if (!relsXml) {
113796
+ const path4 = relsPath2 ?? partRelsPath(partPath);
113797
+ const relsData = await this.readPartXml(path4);
113798
+ if (!relsData) {
113652
113799
  return;
113653
113800
  }
113654
- const relsData = this.parser.parse(relsXml);
113655
113801
  const relationships3 = relsData?.["Relationships"];
113656
113802
  const raw2 = relationships3?.["Relationship"];
113657
113803
  const entries = Array.isArray(raw2) ? raw2 : raw2 ? [raw2] : [];
@@ -115180,10 +115326,6 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115180
115326
  this.zip.file(relsPath2, this.builder.build(relsData));
115181
115327
  return true;
115182
115328
  }
115183
- /** The text of a package part, or `undefined` when the package has no such part. */
115184
- async readPartText(path4) {
115185
- return this.zip.file(path4)?.async("string");
115186
- }
115187
115329
  /**
115188
115330
  * Parse extended (application) properties from `docProps/app.xml`.
115189
115331
  */
@@ -115244,8 +115386,10 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115244
115386
  if (!relsFile) {
115245
115387
  return [];
115246
115388
  }
115247
- const relsXml = await relsFile.async("string");
115248
- const relsData = this.parser.parse(relsXml);
115389
+ const relsData = await this.readPartXml(relsPath2);
115390
+ if (!relsData) {
115391
+ return [];
115392
+ }
115249
115393
  const relRoot = relsData["Relationships"] || {};
115250
115394
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
115251
115395
  const relMap = /* @__PURE__ */ new Map();
@@ -115276,7 +115420,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115276
115420
  try {
115277
115421
  const file = this.zip.file(resolvedPath);
115278
115422
  if (file) {
115279
- data = await file.async("string");
115423
+ data = await this.readPartText(resolvedPath);
115280
115424
  }
115281
115425
  } catch {
115282
115426
  }
@@ -115356,9 +115500,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115356
115500
  */
115357
115501
  async parseTags() {
115358
115502
  try {
115359
- return await discoverTagCollections(this.zip, {
115360
- parse: (xml) => this.parser.parse(xml)
115361
- });
115503
+ return await discoverTagCollections(this.zip, this.parser);
115362
115504
  } catch (e) {
115363
115505
  console.warn("Failed to parse tags:", e);
115364
115506
  return [];
@@ -115498,7 +115640,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115498
115640
  }
115499
115641
  for (const file of masterFiles) {
115500
115642
  const path4 = file.name;
115501
- const xml = await file.async("string");
115643
+ const xml = await this.readPartText(path4) ?? "";
115502
115644
  const data = this.parser.parse(xml);
115503
115645
  const sldMaster = data?.["p:sldMaster"];
115504
115646
  if (!sldMaster) {
@@ -115523,8 +115665,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115523
115665
  );
115524
115666
  const relsFile = this.zip.file(relsPath2);
115525
115667
  if (relsFile) {
115526
- const relsXml = await relsFile.async("string");
115527
- const relsData = this.parser.parse(relsXml);
115668
+ const relsData = await this.readPartXml(relsPath2);
115528
115669
  const rels = this.ensureArray(
115529
115670
  xmlChild(relsData, "Relationships")?.["Relationship"]
115530
115671
  );
@@ -115538,8 +115679,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115538
115679
  }
115539
115680
  const layoutPaths = [];
115540
115681
  if (relsFile) {
115541
- const relsXml = await relsFile.async("string");
115542
- const relsData = this.parser.parse(relsXml);
115682
+ const relsData = await this.readPartXml(relsPath2);
115543
115683
  const rels = this.ensureArray(
115544
115684
  xmlChild(relsData, "Relationships")?.["Relationship"]
115545
115685
  );
@@ -115583,7 +115723,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115583
115723
  return void 0;
115584
115724
  }
115585
115725
  const path4 = files[0].name;
115586
- const xml = await files[0].async("string");
115726
+ const xml = await this.readPartText(path4) ?? "";
115587
115727
  const data = this.parser.parse(xml);
115588
115728
  const master = data?.["p:handoutMaster"];
115589
115729
  if (!master) {
@@ -115615,7 +115755,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115615
115755
  return void 0;
115616
115756
  }
115617
115757
  const path4 = files[0].name;
115618
- const xml = await files[0].async("string");
115758
+ const xml = await this.readPartText(path4) ?? "";
115619
115759
  const data = this.parser.parse(xml);
115620
115760
  const master = data?.["p:notesMaster"];
115621
115761
  if (!master) {
@@ -115646,7 +115786,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115646
115786
  if (!layoutFile) {
115647
115787
  return void 0;
115648
115788
  }
115649
- const xml = await layoutFile.async("string");
115789
+ const xml = await this.readPartText(layoutPath) ?? "";
115650
115790
  const data = this.parser.parse(xml);
115651
115791
  const sldLayout = data?.["p:sldLayout"];
115652
115792
  if (!sldLayout) {
@@ -115754,18 +115894,19 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
115754
115894
  */
115755
115895
  async parsePresentationProperties() {
115756
115896
  try {
115757
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
115758
- if (!relsXml) {
115897
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
115898
+ if (!relsData) {
115759
115899
  return void 0;
115760
115900
  }
115761
- const relsData = this.parser.parse(relsXml);
115762
- const rels = this.ensureArray(relsData?.Relationships?.Relationship);
115901
+ const rels = this.ensureArray(
115902
+ relsData.Relationships?.Relationship
115903
+ );
115763
115904
  const prRel = rels.find(
115764
115905
  (r) => String(r?.["@_Type"] || "").includes("presProps") || String(r?.["@_Target"] || "").includes("presProps")
115765
115906
  );
115766
115907
  const prTarget = prRel ? String(prRel["@_Target"] || "") : "presProps.xml";
115767
115908
  const prPath = prTarget.startsWith("/") ? prTarget.substring(1) : `ppt/${prTarget}`;
115768
- const prXmlStr = await this.zip.file(prPath)?.async("string");
115909
+ const prXmlStr = await this.readPartText(prPath);
115769
115910
  if (!prXmlStr) {
115770
115911
  return void 0;
115771
115912
  }
@@ -115811,7 +115952,7 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
115811
115952
  */
115812
115953
  async parseViewProperties() {
115813
115954
  try {
115814
- const viewPropsXml2 = await this.zip.file("ppt/viewProps.xml")?.async("string");
115955
+ const viewPropsXml2 = await this.readPartText("ppt/viewProps.xml");
115815
115956
  if (!viewPropsXml2) {
115816
115957
  return void 0;
115817
115958
  }
@@ -120275,7 +120416,7 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
120275
120416
  if (existingRel?.target) {
120276
120417
  drawingPath = this.resolveImagePath(chartPartPath, existingRel.target);
120277
120418
  try {
120278
- const xml = await this.zip.file(drawingPath)?.async("string");
120419
+ const xml = await this.readPartText(drawingPath);
120279
120420
  if (xml) {
120280
120421
  const root = this.parser.parse(xml);
120281
120422
  onDisk = parseChartUserShapesDrawing(root, this.xmlLookupService, {
@@ -120326,11 +120467,10 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
120326
120467
  const slash = chartPartPath.lastIndexOf("/");
120327
120468
  const relsPath2 = `${chartPartPath.slice(0, slash + 1)}_rels/${chartPartPath.slice(slash + 1)}.rels`;
120328
120469
  try {
120329
- const xml = await this.zip.file(relsPath2)?.async("string");
120330
- if (!xml) {
120470
+ const tree = await this.readPartXml(relsPath2);
120471
+ if (!tree) {
120331
120472
  return void 0;
120332
120473
  }
120333
- const tree = this.parser.parse(xml);
120334
120474
  const root = tree["Relationships"];
120335
120475
  const rels = root?.["Relationship"];
120336
120476
  const list3 = rels === void 0 ? [] : Array.isArray(rels) ? rels : [rels];
@@ -135706,7 +135846,7 @@ var init_PptxHandlerRuntimeSlideParsing = __esm({
135706
135846
  this.unwrapAlternateContent(spTree);
135707
135847
  let rawXmlStr;
135708
135848
  try {
135709
- rawXmlStr = await this.zip.file(slidePath)?.async("string") ?? void 0;
135849
+ rawXmlStr = await this.readPartText(slidePath);
135710
135850
  } catch {
135711
135851
  }
135712
135852
  const slidePrefix = slidePath ? `${slidePath}-` : "";
@@ -136275,7 +136415,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
136275
136415
  if (cached) {
136276
136416
  return cached;
136277
136417
  }
136278
- const xml = await this.zip.file(layoutPath)?.async("string");
136418
+ const xml = await this.readPartText(layoutPath);
136279
136419
  if (!xml) {
136280
136420
  return void 0;
136281
136421
  }
@@ -136289,7 +136429,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
136289
136429
  if (cached) {
136290
136430
  return cached;
136291
136431
  }
136292
- const xml = await this.zip.file(masterPath)?.async("string");
136432
+ const xml = await this.readPartText(masterPath);
136293
136433
  if (!xml) {
136294
136434
  return void 0;
136295
136435
  }
@@ -136749,7 +136889,7 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
136749
136889
  if (!notesPath) {
136750
136890
  return {};
136751
136891
  }
136752
- const notesXml = await this.zip.file(notesPath)?.async("string");
136892
+ const notesXml = await this.readPartText(notesPath);
136753
136893
  if (!notesXml) {
136754
136894
  return {};
136755
136895
  }
@@ -137248,7 +137388,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
137248
137388
  try {
137249
137389
  let masterXmlObj = this.masterXmlMap.get(master.path);
137250
137390
  if (!masterXmlObj) {
137251
- const xmlStr = await this.zip.file(master.path)?.async("string");
137391
+ const xmlStr = await this.readPartText(master.path);
137252
137392
  if (!xmlStr) {
137253
137393
  continue;
137254
137394
  }
@@ -137321,7 +137461,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
137321
137461
  }
137322
137462
  const masterToken = masterPath.split("/").pop()?.replace(/\.xml$/u, "") ?? masterPath;
137323
137463
  try {
137324
- const masterXmlStr = await this.zip.file(masterPath)?.async("string");
137464
+ const masterXmlStr = await this.readPartText(masterPath);
137325
137465
  if (!masterXmlStr) {
137326
137466
  return [];
137327
137467
  }
@@ -137483,7 +137623,7 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
137483
137623
  }
137484
137624
  const partPath = part.path;
137485
137625
  rememberMasterPartBackground(this, partPath, part.backgroundColor);
137486
- const xml = await this.zip.file(partPath)?.async("string");
137626
+ const xml = await this.readPartText(partPath);
137487
137627
  if (!xml) {
137488
137628
  return;
137489
137629
  }
@@ -137643,7 +137783,7 @@ var init_PptxHandlerRuntimeLayoutElements = __esm({
137643
137783
  }
137644
137784
  const layoutToken = layoutPath.split("/").pop()?.replace(/\.xml$/u, "") ?? layoutPath;
137645
137785
  try {
137646
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
137786
+ const layoutXmlStr = await this.readPartText(layoutPath);
137647
137787
  if (!layoutXmlStr) {
137648
137788
  return [];
137649
137789
  }
@@ -138377,7 +138517,7 @@ var init_PptxHandlerRuntimeThemeOverrides = __esm({
138377
138517
  return cached;
138378
138518
  }
138379
138519
  try {
138380
- const overrideXml = await this.zip.file(overridePath)?.async("string");
138520
+ const overrideXml = await this.readPartText(overridePath);
138381
138521
  if (!overrideXml) {
138382
138522
  return null;
138383
138523
  }
@@ -139006,10 +139146,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139006
139146
  if (!relsXml) {
139007
139147
  return void 0;
139008
139148
  }
139009
- const relsData = this.parser.parse(
139010
- // eslint-disable-next-line no-await-in-loop
139011
- await relsXml.async("string")
139012
- );
139149
+ const relsData = await this.readPartXml(relsPath2);
139013
139150
  const relNodes = this.ensureArray(
139014
139151
  relsData?.Relationships?.Relationship
139015
139152
  );
@@ -139035,7 +139172,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139035
139172
  const options = [];
139036
139173
  for (const file of themeFiles) {
139037
139174
  try {
139038
- const xml = await file.async("string");
139175
+ const xml = await this.readPartText(file.name) ?? "";
139039
139176
  const data = this.parser.parse(xml);
139040
139177
  const root = data["a:theme"];
139041
139178
  const name = String(root?.["@_name"] || "").trim();
@@ -139115,7 +139252,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139115
139252
  ];
139116
139253
  for (const file of masterFiles) {
139117
139254
  try {
139118
- const masterXml = await file.async("string");
139255
+ const masterXml = await this.readPartText(file.name) ?? "";
139119
139256
  const masterData = this.parser.parse(masterXml);
139120
139257
  const clrMap = masterData?.["p:sldMaster"]?.["p:clrMap"];
139121
139258
  if (!clrMap) {
@@ -139148,7 +139285,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139148
139285
  if (!themeFile) {
139149
139286
  return null;
139150
139287
  }
139151
- const themeXml3 = await themeFile.async("string");
139288
+ const themeXml3 = await this.readPartText(themePath) ?? "";
139152
139289
  const model = this.parseThemePartXml(themeXml3);
139153
139290
  this.cacheThemePartModel(themePath, themeXml3, model);
139154
139291
  return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
@@ -139183,7 +139320,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139183
139320
  if (!relsXml) {
139184
139321
  return void 0;
139185
139322
  }
139186
- const relsData = this.parser.parse(await relsXml.async("string"));
139323
+ const relsData = await this.readPartXml(relsPath2);
139187
139324
  const relNodes = this.ensureArray(
139188
139325
  relsData?.Relationships?.Relationship
139189
139326
  );
@@ -139512,11 +139649,10 @@ var init_PptxHandlerRuntimeComments = __esm({
139512
139649
  async extractModernSlideComments(slidePath) {
139513
139650
  try {
139514
139651
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
139515
- const relsXml = await this.zip.file(relsPath2)?.async("string");
139516
- if (!relsXml) {
139652
+ const relsData = await this.readPartXml(relsPath2);
139653
+ if (!relsData) {
139517
139654
  return [];
139518
139655
  }
139519
- const relsData = this.parser.parse(relsXml);
139520
139656
  const rels = this.ensureArray(
139521
139657
  xmlChild(relsData, "Relationships")?.Relationship
139522
139658
  );
@@ -139533,7 +139669,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139533
139669
  continue;
139534
139670
  }
139535
139671
  const filePath = this.resolvePath(slidePath, target);
139536
- const xml = await this.zip.file(filePath)?.async("string");
139672
+ const xml = await this.readPartText(filePath);
139537
139673
  if (!xml) {
139538
139674
  continue;
139539
139675
  }
@@ -139556,11 +139692,10 @@ var init_PptxHandlerRuntimeComments = __esm({
139556
139692
  return [];
139557
139693
  }
139558
139694
  async loadModernCommentAuthors() {
139559
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
139560
- if (!relsXml) {
139695
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
139696
+ if (!relsData) {
139561
139697
  return;
139562
139698
  }
139563
- const relsData = this.parser.parse(relsXml);
139564
139699
  const relationships3 = this.ensureArray(
139565
139700
  xmlChild(relsData, "Relationships")?.Relationship
139566
139701
  );
@@ -139572,7 +139707,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139572
139707
  return;
139573
139708
  }
139574
139709
  const partPath = this.resolvePath("ppt/presentation.xml", target);
139575
- const xml = await this.zip.file(partPath)?.async("string");
139710
+ const xml = await this.readPartText(partPath);
139576
139711
  if (!xml) {
139577
139712
  return;
139578
139713
  }
@@ -139598,12 +139733,12 @@ var init_PptxHandlerRuntimeComments = __esm({
139598
139733
  }
139599
139734
  }
139600
139735
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
139601
- const relsXml = await this.zip.file(relsPath2)?.async("string");
139736
+ const relsXml = await this.readPartText(relsPath2);
139602
139737
  if (!relsXml) {
139603
139738
  return void 0;
139604
139739
  }
139605
139740
  try {
139606
- const relsData = this.parser.parse(relsXml);
139741
+ const relsData = await this.readPartXml(relsPath2);
139607
139742
  const rels = this.ensureArray(
139608
139743
  xmlChild(relsData, "Relationships")?.Relationship
139609
139744
  );
@@ -139642,7 +139777,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139642
139777
  return [];
139643
139778
  }
139644
139779
  const commentsPath = this.resolveImagePath(slidePath, commentTarget);
139645
- const commentsXml = await this.zip.file(commentsPath)?.async("string");
139780
+ const commentsXml = await this.readPartText(commentsPath);
139646
139781
  if (!commentsXml) {
139647
139782
  return [];
139648
139783
  }
@@ -139677,7 +139812,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139677
139812
  }
139678
139813
  }
139679
139814
  async loadCommentAuthors() {
139680
- const commentAuthorsXml = await this.zip.file("ppt/commentAuthors.xml")?.async("string");
139815
+ const commentAuthorsXml = await this.readPartText("ppt/commentAuthors.xml");
139681
139816
  if (!commentAuthorsXml) {
139682
139817
  return;
139683
139818
  }
@@ -139749,7 +139884,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
139749
139884
  return void 0;
139750
139885
  }
139751
139886
  const partPath = this.resolveImagePath(slidePath, target);
139752
- const xmlString = await this.zip.file(partPath)?.async("string");
139887
+ const xmlString = await this.readPartText(partPath);
139753
139888
  if (!xmlString) {
139754
139889
  return void 0;
139755
139890
  }
@@ -141464,9 +141599,8 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141464
141599
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
141465
141600
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
141466
141601
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
141467
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
141468
- if (chartRelsXml) {
141469
- const chartRelsData = this.parser.parse(chartRelsXml);
141602
+ const chartRelsData = await this.readPartXml(chartRelsPath);
141603
+ if (chartRelsData) {
141470
141604
  const relsContainer = chartRelsData?.Relationships;
141471
141605
  if (relsContainer?.Relationship) {
141472
141606
  const rels = Array.isArray(relsContainer.Relationship) ? relsContainer.Relationship : [relsContainer.Relationship];
@@ -141548,7 +141682,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141548
141682
  if (drawingPath.length === 0) {
141549
141683
  return void 0;
141550
141684
  }
141551
- const drawingXml = await this.zip.file(drawingPath)?.async("string");
141685
+ const drawingXml = await this.readPartText(drawingPath);
141552
141686
  if (!drawingXml) {
141553
141687
  return void 0;
141554
141688
  }
@@ -141569,11 +141703,10 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141569
141703
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
141570
141704
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
141571
141705
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
141572
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
141573
- if (!chartRelsXml) {
141706
+ const chartRelsData = await this.readPartXml(chartRelsPath);
141707
+ if (!chartRelsData) {
141574
141708
  return [];
141575
141709
  }
141576
- const chartRelsData = this.parser.parse(chartRelsXml);
141577
141710
  const relsContainer = chartRelsData?.Relationships;
141578
141711
  if (!relsContainer?.Relationship) {
141579
141712
  return [];
@@ -142465,11 +142598,10 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142465
142598
  async loadPresentationFontRels() {
142466
142599
  const map = /* @__PURE__ */ new Map();
142467
142600
  try {
142468
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
142469
- if (!relsXml) {
142601
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
142602
+ if (!relsData) {
142470
142603
  return map;
142471
142604
  }
142472
- const relsData = this.parser.parse(relsXml);
142473
142605
  const rels = this.ensureArray(
142474
142606
  xmlChild(relsData, "Relationships")?.Relationship
142475
142607
  );
@@ -142790,13 +142922,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142790
142922
  if (!file) {
142791
142923
  continue;
142792
142924
  }
142793
- const data = await file.async("string");
142925
+ const data = await this.readPartText(entry2) ?? "";
142794
142926
  const propsPath = `customXml/itemProps${itemId}.xml`;
142795
142927
  const propsFile = this.zip.file(propsPath);
142796
142928
  let properties;
142797
142929
  let schemaUri;
142798
142930
  if (propsFile) {
142799
- properties = await propsFile.async("string");
142931
+ properties = await this.readPartText(propsPath) ?? "";
142800
142932
  try {
142801
142933
  const propsData = this.parser.parse(properties);
142802
142934
  const schemaRefs = propsData?.["ds:datastoreItem"]?.["ds:schemaRefs"]?.["ds:schemaRef"];
@@ -142816,14 +142948,14 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142816
142948
  const relsFile = this.zip.file(relsPath2);
142817
142949
  let rels;
142818
142950
  if (relsFile) {
142819
- rels = await relsFile.async("string");
142951
+ rels = await this.readPartText(relsPath2);
142820
142952
  }
142821
142953
  parts.push({ id: itemId, data, schemaUri, properties, rels });
142822
142954
  }
142823
142955
  this.customXmlParts = parts;
142824
142956
  }
142825
142957
  async loadPresentationState() {
142826
- const presentationXml3 = await this.zip.file("ppt/presentation.xml")?.async("string");
142958
+ const presentationXml3 = await this.readPartText("ppt/presentation.xml");
142827
142959
  if (!presentationXml3) {
142828
142960
  throw new Error("Invalid PPTX: presentation.xml not found");
142829
142961
  }
@@ -143175,6 +143307,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143175
143307
  * or resolve images. Create a new `PptxHandler` instance instead.
143176
143308
  */
143177
143309
  dispose() {
143310
+ this.endPartReads();
143178
143311
  this.revokeBlobUrls();
143179
143312
  this.imageDataCache.clear();
143180
143313
  this.slideMap.clear();
@@ -143208,18 +143341,24 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143208
143341
  this.zip = null;
143209
143342
  }
143210
143343
  async load(data, options = {}) {
143211
- await this.initializeLoadSession(data, options);
143212
- await this.detectAndPreserveVbaProject();
143213
- this.detectDigitalSignatureParts();
143214
- await this.parseCustomXmlParts();
143215
- const presentationState = await this.loadPresentationState();
143216
- const slideMasters = await this.parseSlideMasters();
143217
- await this.enrichSlideMastersWithTxStyles(slideMasters);
143218
- const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
143219
- const slidesWithWarnings = this.attachSlideWarnings(slides);
143220
- this.resetElementIdCounter(slides);
143221
- recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
143222
- return this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
143344
+ let reader2;
143345
+ try {
143346
+ await this.initializeLoadSession(data, options);
143347
+ reader2 = this.beginPartReads();
143348
+ await this.detectAndPreserveVbaProject();
143349
+ this.detectDigitalSignatureParts();
143350
+ await this.parseCustomXmlParts();
143351
+ const presentationState = await this.loadPresentationState();
143352
+ const slideMasters = await this.parseSlideMasters();
143353
+ await this.enrichSlideMastersWithTxStyles(slideMasters);
143354
+ const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
143355
+ const slidesWithWarnings = this.attachSlideWarnings(slides);
143356
+ this.resetElementIdCounter(slides);
143357
+ recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
143358
+ return await this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
143359
+ } finally {
143360
+ this.endPartReads(reader2);
143361
+ }
143223
143362
  }
143224
143363
  /**
143225
143364
  * Retrieve the current background colour for a layout or master.
@@ -143358,7 +143497,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143358
143497
  options.push(this.buildLayoutOption(lp, xmlObj));
143359
143498
  } else {
143360
143499
  try {
143361
- const layoutXmlStr = await this.zip.file(lp)?.async("string");
143500
+ const layoutXmlStr = await this.readPartText(lp);
143362
143501
  if (layoutXmlStr) {
143363
143502
  const layoutXmlObj = this.parser.parse(layoutXmlStr);
143364
143503
  this.layoutXmlMap.set(lp, layoutXmlObj);
@@ -143401,7 +143540,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143401
143540
  }
143402
143541
  let layoutXml3 = this.layoutXmlMap.get(layoutPath);
143403
143542
  if (!layoutXml3) {
143404
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
143543
+ const layoutXmlStr = await this.readPartText(layoutPath);
143405
143544
  if (!layoutXmlStr) {
143406
143545
  throw new Error(`Layout not found: ${layoutPath}`);
143407
143546
  }