ooxml-core 1.27.2 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/{PptxHandler-WRJXTPGV.mjs → PptxHandler-AFVUHNJO.mjs} +3 -3
  2. package/dist/PptxHandler-EZW4YAWL.mjs +4 -0
  3. package/dist/{PptxHandler-FRQKHTCM.cjs → PptxHandler-WI23AJHM.cjs} +3 -3
  4. package/dist/{PresentationBuilder-POXKHTV7.mjs → PresentationBuilder-DYEHCRHX.mjs} +2 -2
  5. package/dist/{PresentationBuilder-YO5YOTA3.cjs → PresentationBuilder-KUNPJTRL.cjs} +5 -5
  6. package/dist/{PresentationBuilder-LWR5X3JA.mjs → PresentationBuilder-WGTZPVOG.mjs} +3 -3
  7. package/dist/automation/index.cjs +16 -7
  8. package/dist/automation/index.mjs +16 -7
  9. package/dist/chart/index.cjs +16 -7
  10. package/dist/chart/index.mjs +16 -7
  11. package/dist/{chunk-36TR3PER.cjs → chunk-A2PC3CBO.cjs} +28 -7
  12. package/dist/{chunk-XW4XB6P4.mjs → chunk-D7CAHL6J.mjs} +1 -1
  13. package/dist/{chunk-JJ37PCNR.mjs → chunk-EYCM7RVL.mjs} +28 -7
  14. package/dist/{chunk-K6DNX3YC.cjs → chunk-IQ7CB7BJ.cjs} +1581 -1232
  15. package/dist/{chunk-G67MARDL.mjs → chunk-LGSBK3BV.mjs} +258 -258
  16. package/dist/{chunk-I57SMSU6.mjs → chunk-LNPVKKR5.mjs} +28 -7
  17. package/dist/{chunk-RNUYMB73.mjs → chunk-N5ROEHEQ.mjs} +509 -160
  18. package/dist/{chunk-TIQWSSGI.mjs → chunk-RCEHCVLC.mjs} +1 -1
  19. package/dist/{chunk-3VIPI6IA.mjs → chunk-V33RUK4D.mjs} +5 -5
  20. package/dist/{chunk-6LCBTFNL.mjs → chunk-YNGMSNF4.mjs} +528 -159
  21. package/dist/docx/embedded.cjs +16 -7
  22. package/dist/docx/embedded.mjs +16 -7
  23. package/dist/docx/index.cjs +16 -7
  24. package/dist/docx/index.mjs +16 -7
  25. package/dist/docx/load/index.cjs +16 -7
  26. package/dist/docx/load/index.mjs +16 -7
  27. package/dist/index.cjs +16 -7
  28. package/dist/index.mjs +16 -7
  29. package/dist/opc/index.cjs +16 -7
  30. package/dist/opc/index.mjs +16 -7
  31. package/dist/opc/zip-limits.d.ts +8 -1
  32. package/dist/opc/zip-limits.d.ts.map +1 -1
  33. package/dist/pptx/automation/index.cjs +807 -418
  34. package/dist/pptx/automation/index.d.ts +4 -4
  35. package/dist/pptx/automation/index.mjs +6 -6
  36. package/dist/pptx/chunks/{index-D_d4NTVP.d.ts → index-0slnMhMO.d.ts} +126 -10
  37. package/dist/pptx/chunks/index-0slnMhMO.d.ts.map +1 -0
  38. package/dist/pptx/chunks/{index-CdRlUz-v.d.ts → index-DP-R2qY1.d.ts} +3 -3
  39. package/dist/pptx/chunks/{index-CdRlUz-v.d.ts.map → index-DP-R2qY1.d.ts.map} +1 -1
  40. package/dist/pptx/chunks/{index-lwMA6pP5.d.ts → index-OQwOyNYK.d.ts} +4 -4
  41. package/dist/pptx/chunks/{index-lwMA6pP5.d.ts.map → index-OQwOyNYK.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{text-operations-CNfUj45U.d.ts → text-operations-dyvh8gyE.d.ts} +23 -1
  43. package/dist/pptx/chunks/{text-operations-CNfUj45U.d.ts.map → text-operations-dyvh8gyE.d.ts.map} +1 -1
  44. package/dist/pptx/cli/index.cjs +632 -246
  45. package/dist/pptx/cli/index.d.ts +1 -1
  46. package/dist/pptx/cli/index.mjs +5 -5
  47. package/dist/pptx/converter/index.d.ts +1 -1
  48. package/dist/pptx/converter/index.mjs +3 -3
  49. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  50. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  51. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  52. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  53. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  54. package/dist/pptx/index.cjs +1047 -639
  55. package/dist/pptx/index.d.ts +5 -5
  56. package/dist/pptx/index.mjs +6 -6
  57. package/dist/pptx/node/index.d.ts +1 -1
  58. package/dist/pptx/signature-node/index.cjs +28 -7
  59. package/dist/pptx/signature-node/index.mjs +2 -2
  60. package/dist/visio/index.cjs +14 -6
  61. package/dist/visio/index.mjs +14 -6
  62. package/dist/visio/ui/index.cjs +14 -6
  63. package/dist/visio/ui/index.mjs +14 -6
  64. package/dist/xlsx/index.cjs +14 -6
  65. package/dist/xlsx/index.mjs +14 -6
  66. package/dist/xlsx/load/index.cjs +14 -6
  67. package/dist/xlsx/load/index.mjs +14 -6
  68. package/dist/xlsx/ui/index.cjs +14 -6
  69. package/dist/xlsx/ui/index.mjs +14 -6
  70. package/package.json +5 -5
  71. package/dist/PptxHandler-RETSKQ5E.mjs +0 -4
  72. package/dist/pptx/chunks/index-D_d4NTVP.d.ts.map +0 -1
@@ -1510,7 +1510,7 @@ function ensureArrayLocal(value) {
1510
1510
  return Array.isArray(value) ? value : value === void 0 ? [] : [value];
1511
1511
  }
1512
1512
  function countsSignature(counts) {
1513
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
1513
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
1514
1514
  }
1515
1515
  function pathSignature(path3) {
1516
1516
  const counts = /* @__PURE__ */ new Map();
@@ -5017,7 +5017,7 @@ function resolveLimits(limits) {
5017
5017
  maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
5018
5018
  maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
5019
5019
  label: limits.label ?? "ZIP",
5020
- fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
5020
+ fail: (message, limit, kind, actual) => create2 ? create2(message, { limit, kind, actual }) : new ZipLimitError(message, { limit, kind, actual })
5021
5021
  };
5022
5022
  }
5023
5023
  async function inflateEntryGuarded(entry2, alreadyRead, limits) {
@@ -5071,7 +5071,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
5071
5071
  r.fail(
5072
5072
  `${r.label} part ${entry2.name} inflates past its declared size`,
5073
5073
  r.maxEntryBytes,
5074
- size > declared ? "declaredSize" : "maxEntryBytes"
5074
+ size > declared ? "declaredSize" : "maxEntryBytes",
5075
+ size
5075
5076
  )
5076
5077
  );
5077
5078
  if (alreadyRead + size > r.maxTotalBytes)
@@ -5079,7 +5080,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
5079
5080
  r.fail(
5080
5081
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
5081
5082
  r.maxTotalBytes,
5082
- "maxTotalBytes"
5083
+ "maxTotalBytes",
5084
+ alreadyRead + size
5083
5085
  )
5084
5086
  );
5085
5087
  queue.push(chunk2);
@@ -5126,7 +5128,8 @@ function guardZip(zip, limits = {}) {
5126
5128
  throw r.fail(
5127
5129
  `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
5128
5130
  r.maxEntries,
5129
- "maxEntries"
5131
+ "maxEntries",
5132
+ entries.length
5130
5133
  );
5131
5134
  let declared = 0;
5132
5135
  for (const entry2 of entries) {
@@ -5139,7 +5142,8 @@ function guardZip(zip, limits = {}) {
5139
5142
  throw r.fail(
5140
5143
  `${r.label} part ${entry2.name} exceeds the uncompressed part size limit`,
5141
5144
  r.maxEntryBytes,
5142
- "maxEntryBytes"
5145
+ "maxEntryBytes",
5146
+ size
5143
5147
  );
5144
5148
  declared += size;
5145
5149
  }
@@ -5147,7 +5151,8 @@ function guardZip(zip, limits = {}) {
5147
5151
  throw r.fail(
5148
5152
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
5149
5153
  r.maxTotalBytes,
5150
- "maxTotalBytes"
5154
+ "maxTotalBytes",
5155
+ declared
5151
5156
  );
5152
5157
  const produced = /* @__PURE__ */ new Map();
5153
5158
  let total = 0;
@@ -5186,7 +5191,8 @@ async function openZip(input, limits = {}) {
5186
5191
  throw r.fail(
5187
5192
  `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
5188
5193
  maxInput,
5189
- "maxInputBytes"
5194
+ "maxInputBytes",
5195
+ bytes.byteLength
5190
5196
  );
5191
5197
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
5192
5198
  }
@@ -5204,11 +5210,14 @@ var init_zip_limits = __esm({
5204
5210
  limit;
5205
5211
  /** The check that failed (absent when the error was built without one). */
5206
5212
  kind;
5213
+ /** The observed value, when known (a lower bound for a size found while inflating). */
5214
+ actual;
5207
5215
  constructor(message, details) {
5208
5216
  super(message);
5209
5217
  this.name = "ZipLimitError";
5210
5218
  this.limit = details.limit;
5211
5219
  this.kind = details.kind;
5220
+ this.actual = details.actual;
5212
5221
  }
5213
5222
  };
5214
5223
  mib = (bytes) => Math.round(bytes / 1048576);
@@ -5224,15 +5233,27 @@ var init_types2 = __esm({
5224
5233
  exports.MAX_ZIP_ENTRY_COUNT = 65536;
5225
5234
  exports.ZipBombError = class extends Error {
5226
5235
  code = "ZIP_BOMB";
5236
+ /** Inflated bytes declared or read when a size limit failed (a lower bound while streaming). */
5227
5237
  uncompressedBytes;
5238
+ /** The value of the limit that failed. */
5228
5239
  limit;
5240
+ /** Number of archive entries, when the entry-count limit failed. */
5229
5241
  entryCount;
5242
+ /**
5243
+ * The `PptxLoadLimits` field behind this error (`maxUncompressedBytes` or
5244
+ * `maxEntries`); `undefined` for a forged size or an unsafe part name.
5245
+ */
5246
+ loadLimit;
5247
+ /** The observed value for {@link loadLimit}, when known. */
5248
+ actual;
5230
5249
  constructor(message, details) {
5231
5250
  super(message);
5232
5251
  this.name = "ZipBombError";
5233
5252
  this.uncompressedBytes = details.uncompressedBytes;
5234
5253
  this.limit = details.limit;
5235
5254
  this.entryCount = details.entryCount;
5255
+ this.loadLimit = details.loadLimit;
5256
+ this.actual = details.actual;
5236
5257
  }
5237
5258
  };
5238
5259
  }
@@ -5333,13 +5354,13 @@ function layoutRelsXml(masterIndex = 1) {
5333
5354
  </Relationships>`;
5334
5355
  }
5335
5356
  function countExistingLayouts(zip) {
5336
- let count = 0;
5357
+ let count2 = 0;
5337
5358
  zip.forEach((relativePath) => {
5338
5359
  if (/^ppt\/slideLayouts\/slideLayout\d+\.xml$/.test(relativePath)) {
5339
- count++;
5360
+ count2++;
5340
5361
  }
5341
5362
  });
5342
- return count;
5363
+ return count2;
5343
5364
  }
5344
5365
  async function addLayoutToSlideMaster(zip, layoutIndex2, masterIndex = 1) {
5345
5366
  const masterRelsPath = `ppt/slideMasters/_rels/slideMaster${masterIndex}.xml.rels`;
@@ -5919,6 +5940,564 @@ var init_PresentationBuilder = __esm({
5919
5940
  }
5920
5941
  });
5921
5942
 
5943
+ // pptx/core/utils/clone-utils.ts
5944
+ function isPlainRecord(value) {
5945
+ if (typeof value !== "object" || value === null) {
5946
+ return false;
5947
+ }
5948
+ const prototype = Object.getPrototypeOf(value);
5949
+ return prototype === Object.prototype || prototype === null;
5950
+ }
5951
+ function cloneValue(value, seen) {
5952
+ if (Array.isArray(value)) {
5953
+ const cached2 = seen.get(value);
5954
+ if (cached2 !== void 0) {
5955
+ return cached2;
5956
+ }
5957
+ const copy3 = new Array(value.length);
5958
+ seen.set(value, copy3);
5959
+ for (let index = 0; index < value.length; index++) {
5960
+ copy3[index] = cloneValue(value[index], seen);
5961
+ }
5962
+ return copy3;
5963
+ }
5964
+ if (!isPlainRecord(value)) {
5965
+ return value;
5966
+ }
5967
+ const cached = seen.get(value);
5968
+ if (cached !== void 0) {
5969
+ return cached;
5970
+ }
5971
+ const copy2 = {};
5972
+ seen.set(value, copy2);
5973
+ for (const key2 of Object.keys(value)) {
5974
+ const child32 = value[key2];
5975
+ copy2[key2] = SHARED_RAW_XML_KEYS.has(key2) ? child32 : cloneValue(child32, seen);
5976
+ }
5977
+ return copy2;
5978
+ }
5979
+ function deepCloneData(value) {
5980
+ return cloneValue(value, /* @__PURE__ */ new WeakMap());
5981
+ }
5982
+ function cloneTextStyle(style) {
5983
+ if (!style) {
5984
+ return void 0;
5985
+ }
5986
+ return deepCloneData(style);
5987
+ }
5988
+ function cloneShapeStyle(style) {
5989
+ if (!style) {
5990
+ return void 0;
5991
+ }
5992
+ return deepCloneData(style);
5993
+ }
5994
+ function cloneElement(element) {
5995
+ return deepCloneData(element);
5996
+ }
5997
+ function cloneSlide(slide) {
5998
+ return deepCloneData(slide);
5999
+ }
6000
+ function cloneTemplateElementsBySlideId(templateElementsBySlideId) {
6001
+ const cloned = {};
6002
+ Object.entries(templateElementsBySlideId).forEach(([slideId, elements3]) => {
6003
+ cloned[slideId] = elements3.map(cloneElement);
6004
+ });
6005
+ return cloned;
6006
+ }
6007
+ function cloneXmlObject(value) {
6008
+ if (!value) {
6009
+ return void 0;
6010
+ }
6011
+ try {
6012
+ if (typeof structuredClone === "function") {
6013
+ return structuredClone(value);
6014
+ }
6015
+ return JSON.parse(JSON.stringify(value));
6016
+ } catch (error) {
6017
+ console.warn("Failed to clone XML object, returning undefined.", value, error);
6018
+ return void 0;
6019
+ }
6020
+ }
6021
+ var SHARED_RAW_XML_KEYS;
6022
+ var init_clone_utils = __esm({
6023
+ "pptx/core/utils/clone-utils.ts"() {
6024
+ SHARED_RAW_XML_KEYS = /* @__PURE__ */ new Set([
6025
+ "rawXml",
6026
+ "rawTiming",
6027
+ "inkPartRawXml",
6028
+ "rawMediaReferenceXml"
6029
+ ]);
6030
+ }
6031
+ });
6032
+
6033
+ // pptx/core/utils/element-utils.ts
6034
+ function isTemplateElement(element) {
6035
+ return element.id.startsWith("layout-") || element.id.startsWith("master-");
6036
+ }
6037
+ function isEditableTextElement(element) {
6038
+ if (element.type !== "text" && element.type !== "shape") {
6039
+ return false;
6040
+ }
6041
+ return element.type === "text" || typeof element.text === "string" || (element.textSegments?.length ?? 0) > 0;
6042
+ }
6043
+ function getElementLabel(element) {
6044
+ if (element.type === "text") {
6045
+ return "Text";
6046
+ }
6047
+ if (element.type === "connector") {
6048
+ return "Connector";
6049
+ }
6050
+ if (element.type === "image" || element.type === "picture") {
6051
+ return "Image";
6052
+ }
6053
+ if (element.type === "chart") {
6054
+ return "Chart";
6055
+ }
6056
+ if (element.type === "table") {
6057
+ return "Table";
6058
+ }
6059
+ if (element.type === "smartArt") {
6060
+ return "SmartArt";
6061
+ }
6062
+ if (element.type === "ole") {
6063
+ return "Embedded Object";
6064
+ }
6065
+ if (element.type === "media") {
6066
+ return "Media";
6067
+ }
6068
+ return "Shape";
6069
+ }
6070
+ function shouldRenderFallbackLabel(element, isTextElement2) {
6071
+ if (isTextElement2) {
6072
+ return false;
6073
+ }
6074
+ if (element.type === "shape" || element.type === "connector") {
6075
+ return false;
6076
+ }
6077
+ if (element.type === "picture" || element.type === "image") {
6078
+ return false;
6079
+ }
6080
+ if (element.type === "table") {
6081
+ return false;
6082
+ }
6083
+ return element.type === "chart" || element.type === "smartArt" || element.type === "ole" || element.type === "media" || element.type === "unknown";
6084
+ }
6085
+ function getElementTextContent(element) {
6086
+ if (!hasTextProperties(element)) {
6087
+ return "";
6088
+ }
6089
+ if (typeof element.text === "string") {
6090
+ return element.text;
6091
+ }
6092
+ if (!element.textSegments || element.textSegments.length === 0) {
6093
+ return "";
6094
+ }
6095
+ return element.textSegments.map((segment) => String(segment.text || "")).join("");
6096
+ }
6097
+ function createUniformTextSegments(text2, style) {
6098
+ return [
6099
+ {
6100
+ text: text2,
6101
+ style: cloneTextStyle(style) || {}
6102
+ }
6103
+ ];
6104
+ }
6105
+ function createEditorId(prefix) {
6106
+ const random = Math.random().toString(36).slice(2, 8).padEnd(6, "0");
6107
+ const sequence = (nextEditorIdSequence++).toString(36);
6108
+ return `${prefix}-${Date.now()}-${random}${sequence}`;
6109
+ }
6110
+ function createDrawingObjectId() {
6111
+ nextDrawingObjectId += 1;
6112
+ return nextDrawingObjectId;
6113
+ }
6114
+ function createArrayBufferCopy(bytes) {
6115
+ const copy2 = new Uint8Array(bytes.byteLength);
6116
+ copy2.set(bytes);
6117
+ return copy2.buffer;
6118
+ }
6119
+ function ensureArrayValue(value) {
6120
+ if (!value) {
6121
+ return [];
6122
+ }
6123
+ return Array.isArray(value) ? value : [value];
6124
+ }
6125
+ function formatCommentTimestamp(value) {
6126
+ const normalized = String(value || "").trim();
6127
+ if (normalized.length === 0) {
6128
+ return "";
6129
+ }
6130
+ const parsed = new Date(normalized);
6131
+ if (Number.isNaN(parsed.getTime())) {
6132
+ return "";
6133
+ }
6134
+ return parsed.toLocaleString(void 0, {
6135
+ month: "short",
6136
+ day: "numeric",
6137
+ hour: "2-digit",
6138
+ minute: "2-digit"
6139
+ });
6140
+ }
6141
+ function getCommentMarkerPosition(comment, index, width, height) {
6142
+ const fallbackX = 18 + index % 4 * 14;
6143
+ const fallbackY = 18 + Math.floor(index / 4) * 14;
6144
+ const rawX = typeof comment.x === "number" && Number.isFinite(comment.x) ? comment.x : fallbackX;
6145
+ const rawY = typeof comment.y === "number" && Number.isFinite(comment.y) ? comment.y : fallbackY;
6146
+ return {
6147
+ x: Math.min(Math.max(rawX, 8), Math.max(width - 8, 8)),
6148
+ y: Math.min(Math.max(rawY, 8), Math.max(height - 8, 8))
6149
+ };
6150
+ }
6151
+ async function readFileAsDataUrl(file) {
6152
+ return await new Promise((resolve, reject) => {
6153
+ const reader2 = new FileReader();
6154
+ reader2.onload = () => {
6155
+ const result = reader2.result;
6156
+ if (typeof result !== "string") {
6157
+ reject(new Error("Failed to read image file."));
6158
+ return;
6159
+ }
6160
+ resolve(result);
6161
+ };
6162
+ reader2.onerror = () => {
6163
+ reject(new Error("Failed to read image file."));
6164
+ };
6165
+ reader2.readAsDataURL(file);
6166
+ });
6167
+ }
6168
+ var nextEditorIdSequence, DRAWING_OBJECT_ID_BASE, nextDrawingObjectId;
6169
+ var init_element_utils = __esm({
6170
+ "pptx/core/utils/element-utils.ts"() {
6171
+ init_types();
6172
+ init_clone_utils();
6173
+ nextEditorIdSequence = 0;
6174
+ DRAWING_OBJECT_ID_BASE = 1e5;
6175
+ nextDrawingObjectId = DRAWING_OBJECT_ID_BASE;
6176
+ }
6177
+ });
6178
+
6179
+ // pptx/core/utils/group-ops.ts
6180
+ function isTemplateElementId(elementId) {
6181
+ return elementId.startsWith("layout-") || elementId.startsWith("master-");
6182
+ }
6183
+ function makeStoreAwareId(intoTemplate, sourceId) {
6184
+ if (!intoTemplate) {
6185
+ return createEditorId("el");
6186
+ }
6187
+ return sourceId.startsWith("master-") ? `master-${createEditorId("el")}` : `layout-${createEditorId("el")}`;
6188
+ }
6189
+ function reassignDescendantIds(element, mintId) {
6190
+ if (element.type !== "group") {
6191
+ return;
6192
+ }
6193
+ for (const child32 of element.children) {
6194
+ const next = mintId(child32);
6195
+ if (next !== void 0) {
6196
+ child32.id = next;
6197
+ }
6198
+ reassignDescendantIds(child32, mintId);
6199
+ }
6200
+ }
6201
+ function groupElements(elements3, ids, groupId) {
6202
+ const idSet = new Set(ids);
6203
+ const gathered = [];
6204
+ let insertionIndex = -1;
6205
+ for (let i2 = 0; i2 < elements3.length; i2++) {
6206
+ const el = elements3[i2];
6207
+ if (idSet.has(el.id)) {
6208
+ gathered.push(el);
6209
+ if (insertionIndex === -1) {
6210
+ insertionIndex = i2;
6211
+ }
6212
+ }
6213
+ }
6214
+ if (gathered.length < 2) {
6215
+ return { elements: [...elements3], groupId: null };
6216
+ }
6217
+ let minX = gathered[0].x;
6218
+ let minY = gathered[0].y;
6219
+ let maxX = gathered[0].x + gathered[0].width;
6220
+ let maxY = gathered[0].y + gathered[0].height;
6221
+ for (let i2 = 1; i2 < gathered.length; i2++) {
6222
+ const el = gathered[i2];
6223
+ if (el.x < minX) {
6224
+ minX = el.x;
6225
+ }
6226
+ if (el.y < minY) {
6227
+ minY = el.y;
6228
+ }
6229
+ const rx = el.x + el.width;
6230
+ const ry = el.y + el.height;
6231
+ if (rx > maxX) {
6232
+ maxX = rx;
6233
+ }
6234
+ if (ry > maxY) {
6235
+ maxY = ry;
6236
+ }
6237
+ }
6238
+ const children17 = gathered.map((el) => {
6239
+ const child32 = cloneElement(el);
6240
+ child32.x = el.x - minX;
6241
+ child32.y = el.y - minY;
6242
+ return child32;
6243
+ });
6244
+ const group = {
6245
+ type: "group",
6246
+ id: groupId,
6247
+ name: "Group",
6248
+ x: minX,
6249
+ y: minY,
6250
+ width: maxX - minX,
6251
+ height: maxY - minY,
6252
+ children: children17
6253
+ };
6254
+ const remaining = elements3.filter((el) => !idSet.has(el.id));
6255
+ let adjustedIndex = 0;
6256
+ for (let i2 = 0; i2 < insertionIndex; i2++) {
6257
+ if (!idSet.has(elements3[i2].id)) {
6258
+ adjustedIndex++;
6259
+ }
6260
+ }
6261
+ return {
6262
+ elements: [...remaining.slice(0, adjustedIndex), group, ...remaining.slice(adjustedIndex)],
6263
+ groupId
6264
+ };
6265
+ }
6266
+ function ungroupElements(elements3, groupId, childIds, options = {}) {
6267
+ const groupIndex = elements3.findIndex((el) => el.id === groupId);
6268
+ if (groupIndex === -1) {
6269
+ return { elements: [...elements3], childIds: [] };
6270
+ }
6271
+ const group = elements3[groupIndex];
6272
+ if (group.type !== "group") {
6273
+ return { elements: [...elements3], childIds: [] };
6274
+ }
6275
+ const intoTemplate = options.intoTemplate ?? isTemplateElementId(group.id);
6276
+ const usedChildIds = [];
6277
+ const expanded = group.children.map((child32, index) => {
6278
+ const newChildId = childIds[index] ?? child32.id;
6279
+ usedChildIds.push(newChildId);
6280
+ const promoted = cloneElement(child32);
6281
+ promoted.id = newChildId;
6282
+ promoted.x = child32.x + group.x;
6283
+ promoted.y = child32.y + group.y;
6284
+ reassignDescendantIds(
6285
+ promoted,
6286
+ (descendant) => isTemplateElementId(descendant.id) === intoTemplate ? void 0 : makeStoreAwareId(intoTemplate, newChildId)
6287
+ );
6288
+ return promoted;
6289
+ });
6290
+ return {
6291
+ elements: [...elements3.slice(0, groupIndex), ...expanded, ...elements3.slice(groupIndex + 1)],
6292
+ childIds: usedChildIds
6293
+ };
6294
+ }
6295
+ var init_group_ops = __esm({
6296
+ "pptx/core/utils/group-ops.ts"() {
6297
+ init_clone_utils();
6298
+ init_element_utils();
6299
+ }
6300
+ });
6301
+
6302
+ // pptx/core/core/load-limits.ts
6303
+ function isLimitName(value) {
6304
+ return typeof value === "string" && LIMIT_NAMES.includes(value);
6305
+ }
6306
+ function getPptxLoadLimitViolation(error) {
6307
+ if (typeof error !== "object" || error === null) {
6308
+ return void 0;
6309
+ }
6310
+ const fields = error;
6311
+ const actual = typeof fields.actual === "number" ? fields.actual : void 0;
6312
+ if (fields.code === "PPTX_LOAD_LIMIT" && isLimitName(fields.limit) && typeof fields.maximum === "number") {
6313
+ return { limit: fields.limit, maximum: fields.maximum, actual };
6314
+ }
6315
+ if (fields.code === "ZIP_BOMB" && isLimitName(fields.loadLimit) && typeof fields.limit === "number") {
6316
+ return { limit: fields.loadLimit, maximum: fields.limit, actual };
6317
+ }
6318
+ return void 0;
6319
+ }
6320
+ function resolvePptxLoadLimits(options = {}) {
6321
+ const resolved = { ...exports.DEFAULT_PPTX_LOAD_LIMITS };
6322
+ const legacy = options.maxUncompressedBytes;
6323
+ if (typeof legacy === "number" && legacy > 0) {
6324
+ resolved.maxUncompressedBytes = legacy;
6325
+ }
6326
+ const limits = options.limits;
6327
+ if (limits === void 0 || limits === null) {
6328
+ return resolved;
6329
+ }
6330
+ for (const name of LIMIT_NAMES) {
6331
+ const value = limits[name];
6332
+ if (value === void 0) {
6333
+ continue;
6334
+ }
6335
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
6336
+ throw new RangeError(`limits.${name} must be a positive finite number`);
6337
+ }
6338
+ if (name === "maxEntries" && value > exports.MAX_ZIP_ENTRY_COUNT) {
6339
+ throw new RangeError(`limits.maxEntries must not exceed ${exports.MAX_ZIP_ENTRY_COUNT}`);
6340
+ }
6341
+ resolved[name] = value;
6342
+ }
6343
+ return resolved;
6344
+ }
6345
+ function createPptxZipBombError(message, details) {
6346
+ const { limit, kind, actual } = details;
6347
+ if (kind === "maxEntries") {
6348
+ return new exports.ZipBombError(message, {
6349
+ limit,
6350
+ loadLimit: "maxEntries",
6351
+ ...actual === void 0 ? {} : { entryCount: actual, actual }
6352
+ });
6353
+ }
6354
+ if (kind === "maxEntryBytes" || kind === "maxTotalBytes") {
6355
+ return new exports.ZipBombError(message, {
6356
+ limit,
6357
+ loadLimit: "maxUncompressedBytes",
6358
+ ...actual === void 0 ? {} : { uncompressedBytes: actual, actual }
6359
+ });
6360
+ }
6361
+ return new exports.ZipBombError(message, { limit });
6362
+ }
6363
+ function assertPptxInputWithinLimits(byteLength, limits) {
6364
+ if (byteLength > limits.maxInputBytes) {
6365
+ throw new exports.PptxLoadLimitError(
6366
+ `PPTX input is ${count(byteLength)} bytes, more than the maxInputBytes limit of ${count(limits.maxInputBytes)}`,
6367
+ "maxInputBytes",
6368
+ limits.maxInputBytes,
6369
+ byteLength
6370
+ );
6371
+ }
6372
+ }
6373
+ function assertPptxTextWithinLimits(text2, limits) {
6374
+ const maximum = limits.maxInputBytes;
6375
+ if (text2.length * 3 <= maximum) {
6376
+ return;
6377
+ }
6378
+ const bytes = text2.length > maximum ? text2.length : utf8ByteLengthPast(text2, maximum);
6379
+ if (bytes > maximum) {
6380
+ throw new exports.PptxLoadLimitError(
6381
+ `PPTX input is at least ${count(bytes)} bytes, more than the maxInputBytes limit of ${count(maximum)}`,
6382
+ "maxInputBytes",
6383
+ maximum,
6384
+ bytes
6385
+ );
6386
+ }
6387
+ }
6388
+ function utf8ByteLengthPast(text2, maximum) {
6389
+ let bytes = 0;
6390
+ for (let index = 0; index < text2.length && bytes <= maximum; index++) {
6391
+ const unit = text2.charCodeAt(index);
6392
+ if (unit < 128) {
6393
+ bytes += 1;
6394
+ } else if (unit < 2048) {
6395
+ bytes += 2;
6396
+ } else if (unit >= 55296 && unit <= 56319 && isLowSurrogate(text2.charCodeAt(index + 1))) {
6397
+ bytes += 4;
6398
+ index++;
6399
+ } else {
6400
+ bytes += 3;
6401
+ }
6402
+ }
6403
+ return bytes;
6404
+ }
6405
+ function isLowSurrogate(unit) {
6406
+ return unit >= 56320 && unit <= 57343;
6407
+ }
6408
+ function assertPptxSlideCountWithinLimits(slideCount, limits) {
6409
+ if (slideCount > limits.maxSlides) {
6410
+ throw new exports.PptxLoadLimitError(
6411
+ `PPTX presentation has ${count(slideCount)} slides, more than the maxSlides limit of ${count(limits.maxSlides)}`,
6412
+ "maxSlides",
6413
+ limits.maxSlides,
6414
+ slideCount
6415
+ );
6416
+ }
6417
+ }
6418
+ function countPptxShapesWithinLimits(counted, elements3, limits) {
6419
+ const maximum = limits.maxShapes;
6420
+ if (maximum === Number.POSITIVE_INFINITY) {
6421
+ return counted;
6422
+ }
6423
+ const total = counted + countAuthoredElements(elements3);
6424
+ if (total > maximum) {
6425
+ throw new exports.PptxLoadLimitError(
6426
+ `PPTX presentation has at least ${count(total)} shapes, more than the maxShapes limit of ${count(maximum)}`,
6427
+ "maxShapes",
6428
+ maximum,
6429
+ total
6430
+ );
6431
+ }
6432
+ return total;
6433
+ }
6434
+ function countAuthoredElements(elements3) {
6435
+ let total = 0;
6436
+ const lists = [elements3];
6437
+ const positions = [0];
6438
+ while (lists.length > 0) {
6439
+ const top = lists.length - 1;
6440
+ const list3 = lists[top];
6441
+ const position3 = positions[top];
6442
+ if (position3 >= list3.length) {
6443
+ lists.pop();
6444
+ positions.pop();
6445
+ continue;
6446
+ }
6447
+ positions[top] = position3 + 1;
6448
+ const element = list3[position3];
6449
+ if (typeof element !== "object" || element === null) {
6450
+ continue;
6451
+ }
6452
+ const { id, type, children: children17 } = element;
6453
+ if (typeof id === "string" && isTemplateElementId(id)) {
6454
+ continue;
6455
+ }
6456
+ total++;
6457
+ if (type === "group" && Array.isArray(children17) && children17.length > 0) {
6458
+ lists.push(children17);
6459
+ positions.push(0);
6460
+ }
6461
+ }
6462
+ return total;
6463
+ }
6464
+ exports.DEFAULT_PPTX_LOAD_LIMITS = void 0; var LIMIT_NAMES; exports.PptxLoadLimitError = void 0; var count;
6465
+ var init_load_limits = __esm({
6466
+ "pptx/core/core/load-limits.ts"() {
6467
+ init_group_ops();
6468
+ init_types2();
6469
+ exports.DEFAULT_PPTX_LOAD_LIMITS = Object.freeze({
6470
+ maxInputBytes: Number.POSITIVE_INFINITY,
6471
+ maxUncompressedBytes: exports.DEFAULT_MAX_UNCOMPRESSED_BYTES,
6472
+ maxEntries: exports.MAX_ZIP_ENTRY_COUNT,
6473
+ maxSlides: Number.POSITIVE_INFINITY,
6474
+ maxShapes: Number.POSITIVE_INFINITY
6475
+ });
6476
+ LIMIT_NAMES = Object.keys(exports.DEFAULT_PPTX_LOAD_LIMITS);
6477
+ exports.PptxLoadLimitError = class extends Error {
6478
+ code = "PPTX_LOAD_LIMIT";
6479
+ /** The limit that was exceeded. */
6480
+ limit;
6481
+ /** The value of that limit. */
6482
+ maximum;
6483
+ /**
6484
+ * The observed value: exact for `maxSlides` and for `maxInputBytes` on
6485
+ * `load()`; for `maxShapes`, and for `maxInputBytes` on `loadFromJson()`
6486
+ * (which stops counting once past the limit), a lower bound.
6487
+ */
6488
+ actual;
6489
+ constructor(message, limit, maximum, actual) {
6490
+ super(message);
6491
+ this.name = "PptxLoadLimitError";
6492
+ this.limit = limit;
6493
+ this.maximum = maximum;
6494
+ this.actual = actual;
6495
+ }
6496
+ };
6497
+ count = (value) => value.toLocaleString("en-US");
6498
+ }
6499
+ });
6500
+
5922
6501
  // geometry/indexed.ts
5923
6502
  function at(items, index) {
5924
6503
  const value = items[index];
@@ -20501,365 +21080,6 @@ var init_preset_connection_sites_table = __esm({
20501
21080
  }
20502
21081
  });
20503
21082
 
20504
- // pptx/core/utils/clone-utils.ts
20505
- function isPlainRecord(value) {
20506
- if (typeof value !== "object" || value === null) {
20507
- return false;
20508
- }
20509
- const prototype = Object.getPrototypeOf(value);
20510
- return prototype === Object.prototype || prototype === null;
20511
- }
20512
- function cloneValue(value, seen) {
20513
- if (Array.isArray(value)) {
20514
- const cached2 = seen.get(value);
20515
- if (cached2 !== void 0) {
20516
- return cached2;
20517
- }
20518
- const copy3 = new Array(value.length);
20519
- seen.set(value, copy3);
20520
- for (let index = 0; index < value.length; index++) {
20521
- copy3[index] = cloneValue(value[index], seen);
20522
- }
20523
- return copy3;
20524
- }
20525
- if (!isPlainRecord(value)) {
20526
- return value;
20527
- }
20528
- const cached = seen.get(value);
20529
- if (cached !== void 0) {
20530
- return cached;
20531
- }
20532
- const copy2 = {};
20533
- seen.set(value, copy2);
20534
- for (const key2 of Object.keys(value)) {
20535
- const child32 = value[key2];
20536
- copy2[key2] = SHARED_RAW_XML_KEYS.has(key2) ? child32 : cloneValue(child32, seen);
20537
- }
20538
- return copy2;
20539
- }
20540
- function deepCloneData(value) {
20541
- return cloneValue(value, /* @__PURE__ */ new WeakMap());
20542
- }
20543
- function cloneTextStyle(style) {
20544
- if (!style) {
20545
- return void 0;
20546
- }
20547
- return deepCloneData(style);
20548
- }
20549
- function cloneShapeStyle(style) {
20550
- if (!style) {
20551
- return void 0;
20552
- }
20553
- return deepCloneData(style);
20554
- }
20555
- function cloneElement(element) {
20556
- return deepCloneData(element);
20557
- }
20558
- function cloneSlide(slide) {
20559
- return deepCloneData(slide);
20560
- }
20561
- function cloneTemplateElementsBySlideId(templateElementsBySlideId) {
20562
- const cloned = {};
20563
- Object.entries(templateElementsBySlideId).forEach(([slideId, elements3]) => {
20564
- cloned[slideId] = elements3.map(cloneElement);
20565
- });
20566
- return cloned;
20567
- }
20568
- function cloneXmlObject(value) {
20569
- if (!value) {
20570
- return void 0;
20571
- }
20572
- try {
20573
- if (typeof structuredClone === "function") {
20574
- return structuredClone(value);
20575
- }
20576
- return JSON.parse(JSON.stringify(value));
20577
- } catch (error) {
20578
- console.warn("Failed to clone XML object, returning undefined.", value, error);
20579
- return void 0;
20580
- }
20581
- }
20582
- var SHARED_RAW_XML_KEYS;
20583
- var init_clone_utils = __esm({
20584
- "pptx/core/utils/clone-utils.ts"() {
20585
- SHARED_RAW_XML_KEYS = /* @__PURE__ */ new Set([
20586
- "rawXml",
20587
- "rawTiming",
20588
- "inkPartRawXml",
20589
- "rawMediaReferenceXml"
20590
- ]);
20591
- }
20592
- });
20593
-
20594
- // pptx/core/utils/element-utils.ts
20595
- function isTemplateElement(element) {
20596
- return element.id.startsWith("layout-") || element.id.startsWith("master-");
20597
- }
20598
- function isEditableTextElement(element) {
20599
- if (element.type !== "text" && element.type !== "shape") {
20600
- return false;
20601
- }
20602
- return element.type === "text" || typeof element.text === "string" || (element.textSegments?.length ?? 0) > 0;
20603
- }
20604
- function getElementLabel(element) {
20605
- if (element.type === "text") {
20606
- return "Text";
20607
- }
20608
- if (element.type === "connector") {
20609
- return "Connector";
20610
- }
20611
- if (element.type === "image" || element.type === "picture") {
20612
- return "Image";
20613
- }
20614
- if (element.type === "chart") {
20615
- return "Chart";
20616
- }
20617
- if (element.type === "table") {
20618
- return "Table";
20619
- }
20620
- if (element.type === "smartArt") {
20621
- return "SmartArt";
20622
- }
20623
- if (element.type === "ole") {
20624
- return "Embedded Object";
20625
- }
20626
- if (element.type === "media") {
20627
- return "Media";
20628
- }
20629
- return "Shape";
20630
- }
20631
- function shouldRenderFallbackLabel(element, isTextElement2) {
20632
- if (isTextElement2) {
20633
- return false;
20634
- }
20635
- if (element.type === "shape" || element.type === "connector") {
20636
- return false;
20637
- }
20638
- if (element.type === "picture" || element.type === "image") {
20639
- return false;
20640
- }
20641
- if (element.type === "table") {
20642
- return false;
20643
- }
20644
- return element.type === "chart" || element.type === "smartArt" || element.type === "ole" || element.type === "media" || element.type === "unknown";
20645
- }
20646
- function getElementTextContent(element) {
20647
- if (!hasTextProperties(element)) {
20648
- return "";
20649
- }
20650
- if (typeof element.text === "string") {
20651
- return element.text;
20652
- }
20653
- if (!element.textSegments || element.textSegments.length === 0) {
20654
- return "";
20655
- }
20656
- return element.textSegments.map((segment) => String(segment.text || "")).join("");
20657
- }
20658
- function createUniformTextSegments(text2, style) {
20659
- return [
20660
- {
20661
- text: text2,
20662
- style: cloneTextStyle(style) || {}
20663
- }
20664
- ];
20665
- }
20666
- function createEditorId(prefix) {
20667
- const random = Math.random().toString(36).slice(2, 8).padEnd(6, "0");
20668
- const sequence = (nextEditorIdSequence++).toString(36);
20669
- return `${prefix}-${Date.now()}-${random}${sequence}`;
20670
- }
20671
- function createDrawingObjectId() {
20672
- nextDrawingObjectId += 1;
20673
- return nextDrawingObjectId;
20674
- }
20675
- function createArrayBufferCopy(bytes) {
20676
- const copy2 = new Uint8Array(bytes.byteLength);
20677
- copy2.set(bytes);
20678
- return copy2.buffer;
20679
- }
20680
- function ensureArrayValue(value) {
20681
- if (!value) {
20682
- return [];
20683
- }
20684
- return Array.isArray(value) ? value : [value];
20685
- }
20686
- function formatCommentTimestamp(value) {
20687
- const normalized = String(value || "").trim();
20688
- if (normalized.length === 0) {
20689
- return "";
20690
- }
20691
- const parsed = new Date(normalized);
20692
- if (Number.isNaN(parsed.getTime())) {
20693
- return "";
20694
- }
20695
- return parsed.toLocaleString(void 0, {
20696
- month: "short",
20697
- day: "numeric",
20698
- hour: "2-digit",
20699
- minute: "2-digit"
20700
- });
20701
- }
20702
- function getCommentMarkerPosition(comment, index, width, height) {
20703
- const fallbackX = 18 + index % 4 * 14;
20704
- const fallbackY = 18 + Math.floor(index / 4) * 14;
20705
- const rawX = typeof comment.x === "number" && Number.isFinite(comment.x) ? comment.x : fallbackX;
20706
- const rawY = typeof comment.y === "number" && Number.isFinite(comment.y) ? comment.y : fallbackY;
20707
- return {
20708
- x: Math.min(Math.max(rawX, 8), Math.max(width - 8, 8)),
20709
- y: Math.min(Math.max(rawY, 8), Math.max(height - 8, 8))
20710
- };
20711
- }
20712
- async function readFileAsDataUrl(file) {
20713
- return await new Promise((resolve, reject) => {
20714
- const reader2 = new FileReader();
20715
- reader2.onload = () => {
20716
- const result = reader2.result;
20717
- if (typeof result !== "string") {
20718
- reject(new Error("Failed to read image file."));
20719
- return;
20720
- }
20721
- resolve(result);
20722
- };
20723
- reader2.onerror = () => {
20724
- reject(new Error("Failed to read image file."));
20725
- };
20726
- reader2.readAsDataURL(file);
20727
- });
20728
- }
20729
- var nextEditorIdSequence, DRAWING_OBJECT_ID_BASE, nextDrawingObjectId;
20730
- var init_element_utils = __esm({
20731
- "pptx/core/utils/element-utils.ts"() {
20732
- init_types();
20733
- init_clone_utils();
20734
- nextEditorIdSequence = 0;
20735
- DRAWING_OBJECT_ID_BASE = 1e5;
20736
- nextDrawingObjectId = DRAWING_OBJECT_ID_BASE;
20737
- }
20738
- });
20739
-
20740
- // pptx/core/utils/group-ops.ts
20741
- function isTemplateElementId(elementId) {
20742
- return elementId.startsWith("layout-") || elementId.startsWith("master-");
20743
- }
20744
- function makeStoreAwareId(intoTemplate, sourceId) {
20745
- if (!intoTemplate) {
20746
- return createEditorId("el");
20747
- }
20748
- return sourceId.startsWith("master-") ? `master-${createEditorId("el")}` : `layout-${createEditorId("el")}`;
20749
- }
20750
- function reassignDescendantIds(element, mintId) {
20751
- if (element.type !== "group") {
20752
- return;
20753
- }
20754
- for (const child32 of element.children) {
20755
- const next = mintId(child32);
20756
- if (next !== void 0) {
20757
- child32.id = next;
20758
- }
20759
- reassignDescendantIds(child32, mintId);
20760
- }
20761
- }
20762
- function groupElements(elements3, ids, groupId) {
20763
- const idSet = new Set(ids);
20764
- const gathered = [];
20765
- let insertionIndex = -1;
20766
- for (let i2 = 0; i2 < elements3.length; i2++) {
20767
- const el = elements3[i2];
20768
- if (idSet.has(el.id)) {
20769
- gathered.push(el);
20770
- if (insertionIndex === -1) {
20771
- insertionIndex = i2;
20772
- }
20773
- }
20774
- }
20775
- if (gathered.length < 2) {
20776
- return { elements: [...elements3], groupId: null };
20777
- }
20778
- let minX = gathered[0].x;
20779
- let minY = gathered[0].y;
20780
- let maxX = gathered[0].x + gathered[0].width;
20781
- let maxY = gathered[0].y + gathered[0].height;
20782
- for (let i2 = 1; i2 < gathered.length; i2++) {
20783
- const el = gathered[i2];
20784
- if (el.x < minX) {
20785
- minX = el.x;
20786
- }
20787
- if (el.y < minY) {
20788
- minY = el.y;
20789
- }
20790
- const rx = el.x + el.width;
20791
- const ry = el.y + el.height;
20792
- if (rx > maxX) {
20793
- maxX = rx;
20794
- }
20795
- if (ry > maxY) {
20796
- maxY = ry;
20797
- }
20798
- }
20799
- const children17 = gathered.map((el) => {
20800
- const child32 = cloneElement(el);
20801
- child32.x = el.x - minX;
20802
- child32.y = el.y - minY;
20803
- return child32;
20804
- });
20805
- const group = {
20806
- type: "group",
20807
- id: groupId,
20808
- name: "Group",
20809
- x: minX,
20810
- y: minY,
20811
- width: maxX - minX,
20812
- height: maxY - minY,
20813
- children: children17
20814
- };
20815
- const remaining = elements3.filter((el) => !idSet.has(el.id));
20816
- let adjustedIndex = 0;
20817
- for (let i2 = 0; i2 < insertionIndex; i2++) {
20818
- if (!idSet.has(elements3[i2].id)) {
20819
- adjustedIndex++;
20820
- }
20821
- }
20822
- return {
20823
- elements: [...remaining.slice(0, adjustedIndex), group, ...remaining.slice(adjustedIndex)],
20824
- groupId
20825
- };
20826
- }
20827
- function ungroupElements(elements3, groupId, childIds, options = {}) {
20828
- const groupIndex = elements3.findIndex((el) => el.id === groupId);
20829
- if (groupIndex === -1) {
20830
- return { elements: [...elements3], childIds: [] };
20831
- }
20832
- const group = elements3[groupIndex];
20833
- if (group.type !== "group") {
20834
- return { elements: [...elements3], childIds: [] };
20835
- }
20836
- const intoTemplate = options.intoTemplate ?? isTemplateElementId(group.id);
20837
- const usedChildIds = [];
20838
- const expanded = group.children.map((child32, index) => {
20839
- const newChildId = childIds[index] ?? child32.id;
20840
- usedChildIds.push(newChildId);
20841
- const promoted = cloneElement(child32);
20842
- promoted.id = newChildId;
20843
- promoted.x = child32.x + group.x;
20844
- promoted.y = child32.y + group.y;
20845
- reassignDescendantIds(
20846
- promoted,
20847
- (descendant) => isTemplateElementId(descendant.id) === intoTemplate ? void 0 : makeStoreAwareId(intoTemplate, newChildId)
20848
- );
20849
- return promoted;
20850
- });
20851
- return {
20852
- elements: [...elements3.slice(0, groupIndex), ...expanded, ...elements3.slice(groupIndex + 1)],
20853
- childIds: usedChildIds
20854
- };
20855
- }
20856
- var init_group_ops = __esm({
20857
- "pptx/core/utils/group-ops.ts"() {
20858
- init_clone_utils();
20859
- init_element_utils();
20860
- }
20861
- });
20862
-
20863
21083
  // pptx/core/utils/presentation-collections.ts
20864
21084
  function remapReferenceList(references, mapping, removed) {
20865
21085
  const result = [];
@@ -22531,9 +22751,9 @@ function decodeSlot(dir, id, majorVersion, warnings) {
22531
22751
  };
22532
22752
  }
22533
22753
  function readDirectory(dir, majorVersion, strict, warnings) {
22534
- const count = Math.floor(dir.length / DIR_ENTRY_SIZE);
22754
+ const count2 = Math.floor(dir.length / DIR_ENTRY_SIZE);
22535
22755
  const slots = [];
22536
- for (let id = 0; id < count; id++)
22756
+ for (let id = 0; id < count2; id++)
22537
22757
  slots.push(decodeSlot(dir, id, majorVersion, warnings));
22538
22758
  const roots = slots.filter((slot) => slot.type === ENTRY_TYPE_ROOT);
22539
22759
  if (roots.length !== 1 || !roots[0].nameValid)
@@ -23074,10 +23294,10 @@ function writeFatChain(fat, chain2) {
23074
23294
  fat[chain2.sectors[i2]] = i2 < chain2.sectors.length - 1 ? chain2.sectors[i2 + 1] : ENDOFCHAIN;
23075
23295
  }
23076
23296
  }
23077
- function writeFatRun(fat, firstSector, count) {
23078
- for (let i2 = 0; i2 < count; i2++) {
23297
+ function writeFatRun(fat, firstSector, count2) {
23298
+ for (let i2 = 0; i2 < count2; i2++) {
23079
23299
  const sector = firstSector + i2;
23080
- fat[sector] = i2 < count - 1 ? sector + 1 : ENDOFCHAIN;
23300
+ fat[sector] = i2 < count2 - 1 ? sector + 1 : ENDOFCHAIN;
23081
23301
  }
23082
23302
  }
23083
23303
  function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorSize) {
@@ -23595,21 +23815,21 @@ function parseChartFormulaRange(formula2) {
23595
23815
  }
23596
23816
  return { sheetName, start, end };
23597
23817
  }
23598
- function expandRangeAddresses(range, count) {
23818
+ function expandRangeAddresses(range, count2) {
23599
23819
  const { start, end } = range;
23600
- if (count <= 0) {
23820
+ if (count2 <= 0) {
23601
23821
  return void 0;
23602
23822
  }
23603
23823
  if (start.col === end.col && start.row === end.row) {
23604
- return count === 1 ? [formatCellAddress(start)] : void 0;
23824
+ return count2 === 1 ? [formatCellAddress(start)] : void 0;
23605
23825
  }
23606
23826
  if (start.col === end.col) {
23607
23827
  const length = end.row - start.row + 1;
23608
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
23828
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
23609
23829
  }
23610
23830
  if (start.row === end.row) {
23611
23831
  const length = end.col - start.col + 1;
23612
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
23832
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
23613
23833
  }
23614
23834
  return void 0;
23615
23835
  }
@@ -25539,8 +25759,8 @@ function fcLcbFieldOffset(fib, key2) {
25539
25759
  }
25540
25760
  function readFcLcbAt(wordDoc, fib, index) {
25541
25761
  const view = new DataView(wordDoc.buffer, wordDoc.byteOffset, wordDoc.byteLength);
25542
- const count = view.getUint16(fib.fibRgFcLcbOffset - 2, true);
25543
- if (!Number.isInteger(index) || index < 0 || index >= count || fib.fibRgFcLcbCount !== void 0 && fib.fibRgFcLcbCount !== count)
25762
+ const count2 = view.getUint16(fib.fibRgFcLcbOffset - 2, true);
25763
+ if (!Number.isInteger(index) || index < 0 || index >= count2 || fib.fibRgFcLcbCount !== void 0 && fib.fibRgFcLcbCount !== count2)
25544
25764
  throw new Error("FIB fc/lcb index outside declared array");
25545
25765
  const off = fib.fibRgFcLcbOffset + index * 8;
25546
25766
  return { fc: view.getUint32(off, true), lcb: view.getUint32(off + 4, true) };
@@ -25772,7 +25992,7 @@ function appendCompoundAllocations(input, existingFatIds, payloads, sectorSize =
25772
25992
  const sectorCount = input.length / sectorSize - 1;
25773
25993
  const entriesPerFat = sectorSize / 4;
25774
25994
  const counts = payloads.map((payload) => Math.ceil(payload.length / sectorSize));
25775
- const payloadSectors = counts.reduce((sum, count) => sum + count, 0);
25995
+ const payloadSectors = counts.reduce((sum, count2) => sum + count2, 0);
25776
25996
  let fatCount = existingFatIds.length;
25777
25997
  while (sectorCount + payloadSectors + fatCount - existingFatIds.length > fatCount * entriesPerFat)
25778
25998
  fatCount++;
@@ -25857,21 +26077,21 @@ function resizeMiniCompoundStream(input, fat, fatIds, root, target, replacement,
25857
26077
  output2.view.setUint32(target.offset + 120, replacement.length, true);
25858
26078
  return output2.bytes;
25859
26079
  }
25860
- const firstMini = Math.ceil(root.size / MINI), count = Math.ceil(replacement.length / MINI);
25861
- const newRootSize = count ? (firstMini + count) * MINI : root.size;
26080
+ const firstMini = Math.ceil(root.size / MINI), count2 = Math.ceil(replacement.length / MINI);
26081
+ const newRootSize = count2 ? (firstMini + count2) * MINI : root.size;
25862
26082
  const newRoot = new Uint8Array(newRootSize);
25863
26083
  rootSectors.forEach((id, i2) => newRoot.set(input.subarray((id + 1) * SECTOR, (id + 1) * SECTOR + Math.min(SECTOR, root.size - i2 * SECTOR)), i2 * SECTOR));
25864
- if (count)
26084
+ if (count2)
25865
26085
  newRoot.set(replacement, firstMini * MINI);
25866
- const newMiniFatCount = Math.max(miniFatCount, Math.ceil((firstMini + count) / 128));
26086
+ const newMiniFatCount = Math.max(miniFatCount, Math.ceil((firstMini + count2) / 128));
25867
26087
  const newMiniFat = new Uint8Array(newMiniFatCount * SECTOR).fill(255);
25868
26088
  miniFatSectors.forEach((id, i2) => newMiniFat.set(input.subarray((id + 1) * SECTOR, (id + 2) * SECTOR), i2 * SECTOR));
25869
26089
  const miniView = new DataView(newMiniFat.buffer);
25870
26090
  if (wasMini)
25871
26091
  for (const id of oldChain)
25872
26092
  miniView.setUint32(id * 4, FREE2, true);
25873
- for (let i2 = 0; i2 < count; i2++)
25874
- miniView.setUint32((firstMini + i2) * 4, i2 + 1 === count ? END3 : firstMini + i2 + 1, true);
26093
+ for (let i2 = 0; i2 < count2; i2++)
26094
+ miniView.setUint32((firstMini + i2) * 4, i2 + 1 === count2 ? END3 : firstMini + i2 + 1, true);
25875
26095
  const output = appendCompoundAllocations(input, fatIds, [newRoot, newMiniFat]);
25876
26096
  if (!output)
25877
26097
  return void 0;
@@ -25881,7 +26101,7 @@ function resizeMiniCompoundStream(input, fat, fatIds, root, target, replacement,
25881
26101
  output.view.setUint32(root.offset + 120, newRootSize, true);
25882
26102
  output.view.setUint32(60, output.chains[1][0] ?? END3, true);
25883
26103
  output.view.setUint32(64, newMiniFatCount, true);
25884
- output.view.setUint32(target.offset + 116, count ? firstMini : END3, true);
26104
+ output.view.setUint32(target.offset + 116, count2 ? firstMini : END3, true);
25885
26105
  output.view.setUint32(target.offset + 120, replacement.length, true);
25886
26106
  return output.bytes;
25887
26107
  }
@@ -27396,9 +27616,9 @@ var init_deflate_encode = __esm({
27396
27616
  len = 0;
27397
27617
  acc = 0;
27398
27618
  nbits = 0;
27399
- bits(value, count) {
27619
+ bits(value, count2) {
27400
27620
  this.acc |= value << this.nbits;
27401
- this.nbits += count;
27621
+ this.nbits += count2;
27402
27622
  while (this.nbits >= 8) {
27403
27623
  this.push(this.acc & 255);
27404
27624
  this.acc >>>= 8;
@@ -27406,12 +27626,12 @@ var init_deflate_encode = __esm({
27406
27626
  }
27407
27627
  }
27408
27628
  /** Huffman codes are packed most-significant bit first. */
27409
- code(value, count) {
27629
+ code(value, count2) {
27410
27630
  let reversed = 0;
27411
- for (let i2 = 0; i2 < count; i2++) {
27631
+ for (let i2 = 0; i2 < count2; i2++) {
27412
27632
  reversed = reversed << 1 | value >>> i2 & 1;
27413
27633
  }
27414
- this.bits(reversed, count);
27634
+ this.bits(reversed, count2);
27415
27635
  }
27416
27636
  finish() {
27417
27637
  if (this.nbits > 0) {
@@ -31797,12 +32017,12 @@ function functionValue(condition, point2, lookup) {
31797
32017
  if (!target) {
31798
32018
  return void 0;
31799
32019
  }
31800
- const { pos: pos2, count } = siblingPosition(target, ptType);
32020
+ const { pos: pos2, count: count2 } = siblingPosition(target, ptType);
31801
32021
  if (condition.func === "pos") {
31802
32022
  return pos2;
31803
32023
  }
31804
32024
  if (condition.func === "revPos") {
31805
- return count - pos2 + 1;
32025
+ return count2 - pos2 + 1;
31806
32026
  }
31807
32027
  return condition.func === "posEven" ? pos2 % 2 === 0 ? 1 : 0 : pos2 % 2 === 1 ? 1 : 0;
31808
32028
  }
@@ -35014,19 +35234,19 @@ function pointTypeMatches(node, pointType2) {
35014
35234
  }
35015
35235
  return node.nodeType === pointType2;
35016
35236
  }
35017
- function selectRange(nodes, start, count) {
35018
- if (start === void 0 && count === void 0) {
35237
+ function selectRange(nodes, start, count2) {
35238
+ if (start === void 0 && count2 === void 0) {
35019
35239
  return nodes;
35020
35240
  }
35021
35241
  const zeroBasedStart = Math.max(0, (start ?? 1) - 1);
35022
- const take2 = count !== void 0 && count > 0 ? count : nodes.length - zeroBasedStart;
35242
+ const take2 = count2 !== void 0 && count2 > 0 ? count2 : nodes.length - zeroBasedStart;
35023
35243
  return nodes.slice(zeroBasedStart, zeroBasedStart + take2);
35024
35244
  }
35025
- function applyPointTypeAndRange(nodes, pointType2, start, count) {
35245
+ function applyPointTypeAndRange(nodes, pointType2, start, count2) {
35026
35246
  const filtered = pointType2 ? nodes.filter((n) => pointTypeMatches(n, pointType2)) : nodes;
35027
- return selectRange(filtered, start, count);
35247
+ return selectRange(filtered, start, count2);
35028
35248
  }
35029
- function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
35249
+ function resolveAxisNodes(nodes, axis, pointTypes, start, count2, context) {
35030
35250
  if (axis.length === 0) {
35031
35251
  return void 0;
35032
35252
  }
@@ -35056,21 +35276,21 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
35056
35276
  let current;
35057
35277
  let nextHop;
35058
35278
  if (axis[0] === "root" && axis.length > 1) {
35059
- current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
35279
+ current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count2?.[1]);
35060
35280
  nextHop = 2;
35061
35281
  } else if (axis[0] === "root") {
35062
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
35282
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
35063
35283
  nextHop = 1;
35064
35284
  } else if (context !== void 0) {
35065
35285
  current = applyPointTypeAndRange(
35066
35286
  navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
35067
35287
  pointTypes?.[0],
35068
35288
  start?.[0],
35069
- count?.[0]
35289
+ count2?.[0]
35070
35290
  );
35071
35291
  nextHop = 1;
35072
35292
  } else {
35073
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
35293
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
35074
35294
  nextHop = 1;
35075
35295
  }
35076
35296
  for (let hop = nextHop; hop < axis.length; hop += 1) {
@@ -35078,13 +35298,13 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
35078
35298
  navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
35079
35299
  pointTypes?.[hop],
35080
35300
  start?.[hop],
35081
- count?.[hop]
35301
+ count2?.[hop]
35082
35302
  );
35083
35303
  }
35084
35304
  return current;
35085
35305
  }
35086
- function resolveAxisCount(nodes, axis, pointTypes, start, count, context) {
35087
- return resolveAxisNodes(nodes, axis, pointTypes, start, count, context)?.length;
35306
+ function resolveAxisCount(nodes, axis, pointTypes, start, count2, context) {
35307
+ return resolveAxisNodes(nodes, axis, pointTypes, start, count2, context)?.length;
35088
35308
  }
35089
35309
  var init_smartart_layout_interpreter_axis_count = __esm({
35090
35310
  "diagram/layout/smartart-layout-interpreter-axis-count.ts"() {
@@ -35110,14 +35330,14 @@ function depthFromAnchor(node, anchorId, byId) {
35110
35330
  }
35111
35331
  return void 0;
35112
35332
  }
35113
- function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count, anchor) {
35333
+ function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count2, anchor) {
35114
35334
  if (anchor.length === 0) {
35115
35335
  return void 0;
35116
35336
  }
35117
35337
  const byId = new Map(nodes.map((n) => [n.id, n]));
35118
35338
  let max = 0;
35119
35339
  for (const anchorPoint of anchor) {
35120
- const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count, [anchorPoint]);
35340
+ const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count2, [anchorPoint]);
35121
35341
  if (resolved === void 0) {
35122
35342
  return void 0;
35123
35343
  }
@@ -35603,8 +35823,8 @@ function selectArrangedNodes(node, flat, roots) {
35603
35823
  const followSibCounts = collectFollowSibNodeCounts(node);
35604
35824
  if (followSibCounts.length > 0) {
35605
35825
  for (const i2 of [...indices]) {
35606
- for (const count of followSibCounts) {
35607
- for (let k = 1; k <= count; k++) {
35826
+ for (const count2 of followSibCounts) {
35827
+ for (let k = 1; k <= count2; k++) {
35608
35828
  const j = i2 + k;
35609
35829
  if (j < base.length) {
35610
35830
  indices.add(j);
@@ -37179,12 +37399,12 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path3) {
37179
37399
  const baseAngleRad = dist > 1e-6 ? Math.atan2(dy, dx) : 0;
37180
37400
  const halfExtent = Math.max(context.itemWidth, context.itemHeight) / 2;
37181
37401
  const radius = context.itemWidth / 2 + Math.max(0, context.gapPx) + halfExtent;
37182
- const count = children17.length;
37402
+ const count2 = children17.length;
37183
37403
  const spanRad = context.fanSpanDeg * DEG_TO_RAD2;
37184
37404
  const nodes = [];
37185
37405
  const connectors2 = [];
37186
37406
  children17.forEach((child32, i2) => {
37187
- const angle = count === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count - 1);
37407
+ const angle = count2 === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count2 - 1);
37188
37408
  const cx = parentCentre.x + Math.cos(angle) * radius;
37189
37409
  const cy = parentCentre.y + Math.sin(angle) * radius;
37190
37410
  const key2 = `${context.elementId}-cycle-ext-${path3}-${i2}`;
@@ -37197,7 +37417,7 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path3) {
37197
37417
  height: context.itemHeight,
37198
37418
  node: child32,
37199
37419
  index: i2,
37200
- total: count,
37420
+ total: count2,
37201
37421
  palette: context.palette,
37202
37422
  style: context.style,
37203
37423
  ctx: context.ctx,
@@ -38374,12 +38594,12 @@ var init_smartart_layout_interpreter_linear_content_size = __esm({
38374
38594
  });
38375
38595
 
38376
38596
  // diagram/layout/smartart-layout-interpreter-axis-range.ts
38377
- function positionRange(start, count, step, total) {
38597
+ function positionRange(start, count2, step, total) {
38378
38598
  const out = [];
38379
38599
  const s = step > 0 ? step : 1;
38380
38600
  for (let i2 = Math.max(0, start - 1); i2 < total; i2 += s) {
38381
38601
  out.push(i2 + 1);
38382
- if (count !== void 0 && count > 0 && out.length >= count) {
38602
+ if (count2 !== void 0 && count2 > 0 && out.length >= count2) {
38383
38603
  break;
38384
38604
  }
38385
38605
  }
@@ -38399,8 +38619,8 @@ function compoundChildIds(role, node, childrenOf) {
38399
38619
  }
38400
38620
  const children17 = childrenOf.get(node.id) ?? [];
38401
38621
  const start = role.presentationOf?.start?.[chIndex] ?? 1;
38402
- const count = role.presentationOf?.count?.[chIndex];
38403
- const positions = positionRange(start, count, 1, children17.length);
38622
+ const count2 = role.presentationOf?.count?.[chIndex];
38623
+ const positions = positionRange(start, count2, 1, children17.length);
38404
38624
  const ids = [];
38405
38625
  for (const position3 of positions) {
38406
38626
  const child32 = children17[position3 - 1];
@@ -38974,9 +39194,9 @@ function arrangeSnake2(plan, nodes, box, palette, style, elementId, index = expo
38974
39194
  let y = INSET + row * (cellH + gapY);
38975
39195
  if (centerIncompleteLines) {
38976
39196
  const key2 = flowDir === "row" ? row : col;
38977
- const count = lineCounts.get(key2) ?? fullLineCount;
38978
- if (count < fullLineCount) {
38979
- const shift = (fullLineCount - count) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
39197
+ const count2 = lineCounts.get(key2) ?? fullLineCount;
39198
+ if (count2 < fullLineCount) {
39199
+ const shift = (fullLineCount - count2) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
38980
39200
  if (flowDir === "row") {
38981
39201
  x += shift;
38982
39202
  } else {
@@ -39890,26 +40110,26 @@ var init_smartart_layout_interpreter_composite_foreach = __esm({
39890
40110
  });
39891
40111
 
39892
40112
  // diagram/hierarchy/smartart-hierarchy-pitch.ts
39893
- function computeAxisPitch(dimension, margin, itemSize, count, fixedGapRatio) {
39894
- const n = Math.max(1, count);
40113
+ function computeAxisPitch(dimension, margin, itemSize, count2, fixedGapRatio) {
40114
+ const n = Math.max(1, count2);
39895
40115
  const gap = n <= 1 ? 0 : fixedGapRatio !== void 0 ? itemSize * Math.max(0, fixedGapRatio) : Math.max(0, (dimension - margin - n * itemSize) / (n - 1));
39896
40116
  const pitch = itemSize + gap;
39897
40117
  const centeredShift = (dimension - n * pitch + margin) / 2;
39898
40118
  const maxShift = dimension - n * itemSize - gap * (n - 0.5);
39899
40119
  return { pitch, shift: Math.min(centeredShift, maxShift) };
39900
40120
  }
39901
- function centeredAxisPitch(dimension, itemSize, gapRatio, count) {
39902
- const n = Math.max(1, count);
40121
+ function centeredAxisPitch(dimension, itemSize, gapRatio, count2) {
40122
+ const n = Math.max(1, count2);
39903
40123
  const gap = n > 1 ? itemSize * Math.max(0, gapRatio) : 0;
39904
40124
  const pitch = itemSize + gap;
39905
40125
  const span = n * itemSize + Math.max(0, n - 1) * gap;
39906
40126
  const shift = (dimension - span) / 2;
39907
40127
  return { pitch, shift };
39908
40128
  }
39909
- function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count) {
40129
+ function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count2) {
39910
40130
  const compositeW = compositeWidthFactor ? boxW / compositeWidthFactor : boxW;
39911
40131
  const cardOffsetX = cardOffsetXRatio * compositeW;
39912
- const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count);
40132
+ const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count2);
39913
40133
  const correction = cardOffsetX + boxW / 2 - centred.pitch / 2;
39914
40134
  return { pitch: centred.pitch, shift: centred.shift + correction };
39915
40135
  }
@@ -40010,16 +40230,16 @@ function childAxisSpec(template, childCount) {
40010
40230
  const ownIndex = axis.indexOf("ch");
40011
40231
  if (ownIndex >= 0) {
40012
40232
  const start = template.presentationOf?.start?.[ownIndex] ?? 1;
40013
- const count = template.presentationOf?.count?.[ownIndex];
40014
- return { positions: positionRange(start, count, 1, childCount), fold };
40233
+ const count2 = template.presentationOf?.count?.[ownIndex];
40234
+ return { positions: positionRange(start, count2, 1, childCount), fold };
40015
40235
  }
40016
40236
  const origin = template.forEachOrigin;
40017
40237
  const originIndex = origin?.axis?.indexOf("ch") ?? -1;
40018
40238
  if (origin && originIndex >= 0) {
40019
40239
  const start = origin.start?.[originIndex] ?? 1;
40020
- const count = origin.count?.[originIndex];
40240
+ const count2 = origin.count?.[originIndex];
40021
40241
  const step = origin.step?.[originIndex] ?? 1;
40022
- return { positions: positionRange(start, count, step, childCount), fold };
40242
+ return { positions: positionRange(start, count2, step, childCount), fold };
40023
40243
  }
40024
40244
  return void 0;
40025
40245
  }
@@ -40215,8 +40435,8 @@ function slotRect(slot, box, absX, absY) {
40215
40435
  }
40216
40436
  function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
40217
40437
  const perPoint = representativeSlotsPerPoint(slotted, nodes.length);
40218
- const count = Math.min(perPoint.length, nodes.length);
40219
- const slots = perPoint.slice(0, count).map((entry2) => slotRect(entry2, box, absX, absY));
40438
+ const count2 = Math.min(perPoint.length, nodes.length);
40439
+ const slots = perPoint.slice(0, count2).map((entry2) => slotRect(entry2, box, absX, absY));
40220
40440
  const fontFit = fontCtx ? resolveSharedFontFit(
40221
40441
  fontCtx,
40222
40442
  perPoint[0]?.node,
@@ -40228,7 +40448,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
40228
40448
  }))
40229
40449
  ) : void 0;
40230
40450
  const rendered = [];
40231
- for (let i2 = 0; i2 < count; i2++) {
40451
+ for (let i2 = 0; i2 < count2; i2++) {
40232
40452
  const slot = slots[i2];
40233
40453
  rendered.push(
40234
40454
  presetBoxNode({
@@ -40239,7 +40459,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
40239
40459
  height: slot.height,
40240
40460
  node: nodes[i2],
40241
40461
  index: i2,
40242
- total: count,
40462
+ total: count2,
40243
40463
  palette: ctx.palette,
40244
40464
  style: ctx.style,
40245
40465
  fontSizeOverride: fontFit?.rootSizePx,
@@ -40284,9 +40504,9 @@ var init_smartart_layout_interpreter_composite_ring = __esm({
40284
40504
  });
40285
40505
 
40286
40506
  // diagram/layout/smartart-layout-interpreter-composite-pairs.ts
40287
- function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count) {
40507
+ function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count2) {
40288
40508
  const pairs = [];
40289
- for (let i2 = 0; i2 < count; i2++) {
40509
+ for (let i2 = 0; i2 < count2; i2++) {
40290
40510
  const node = nodes[i2];
40291
40511
  const selfRect = resolveSlot(selfSlots[i2].dims, box, absX, absY);
40292
40512
  const desSlotted = desSlots[i2];
@@ -40379,7 +40599,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
40379
40599
  }
40380
40600
  const desSlots = slotsWithAxis(slotted, "des");
40381
40601
  const childRepeaterSlots = slotted.filter((slot) => !slot.node.presentationOf);
40382
- const count = Math.min(selfSlots.length, nodes.length);
40602
+ const count2 = Math.min(selfSlots.length, nodes.length);
40383
40603
  const pairs = collectSelfDesPairs(
40384
40604
  selfSlots,
40385
40605
  desSlots,
@@ -40389,14 +40609,14 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
40389
40609
  absX,
40390
40610
  absY,
40391
40611
  childrenOf,
40392
- count
40612
+ count2
40393
40613
  );
40394
40614
  const fontFit = resolveFontFitFromPairs(fontCtx, selfSlots[0]?.node, pairs);
40395
40615
  const rendered = [];
40396
- for (let i2 = 0; i2 < count; i2++) {
40616
+ for (let i2 = 0; i2 < count2; i2++) {
40397
40617
  const { node, selfRect, selfLayoutNode, desSlot } = pairs[i2];
40398
40618
  rendered.push(
40399
- ...renderAnchoredPair(node, i2, count, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
40619
+ ...renderAnchoredPair(node, i2, count2, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
40400
40620
  );
40401
40621
  for (const wrapperSlot of childRepeaterSlots) {
40402
40622
  rendered.push(
@@ -40429,7 +40649,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
40429
40649
  absY,
40430
40650
  childrenOf,
40431
40651
  ctx,
40432
- count
40652
+ count2
40433
40653
  )
40434
40654
  );
40435
40655
  return rendered;
@@ -41146,11 +41366,11 @@ var init_smartart_hierarchy_orgchart_tree = __esm({
41146
41366
  // diagram/hierarchy/smartart-hierarchy-hang-depth.ts
41147
41367
  function countDescendants(t, orgChart) {
41148
41368
  const { normal } = partitionChildren(t, orgChart);
41149
- let count = normal.length;
41369
+ let count2 = normal.length;
41150
41370
  for (const child32 of normal) {
41151
- count += countDescendants(child32, orgChart);
41371
+ count2 += countDescendants(child32, orgChart);
41152
41372
  }
41153
- return count;
41373
+ return count2;
41154
41374
  }
41155
41375
  function fanContinues(t, perRow, orgChart, siblingCount, normalCount) {
41156
41376
  const chPrefFanEligible = Number.isFinite(perRow) && siblingCount === perRow && normalCount >= perRow;
@@ -41287,7 +41507,7 @@ var init_smartart_hierarchy_fan_aware_width = __esm({
41287
41507
  });
41288
41508
 
41289
41509
  // diagram/hierarchy/smartart-hierarchy-fold-depth.ts
41290
- function endsInUnboundedDescendantHop(axis, count) {
41510
+ function endsInUnboundedDescendantHop(axis, count2) {
41291
41511
  if (!axis || axis.length === 0) {
41292
41512
  return false;
41293
41513
  }
@@ -41296,7 +41516,7 @@ function endsInUnboundedDescendantHop(axis, count) {
41296
41516
  if (lastAxis !== "des" && lastAxis !== "desOrSelf") {
41297
41517
  return false;
41298
41518
  }
41299
- const lastCount = count?.[lastIndex];
41519
+ const lastCount = count2?.[lastIndex];
41300
41520
  return lastCount === void 0 || lastCount === 0;
41301
41521
  }
41302
41522
  function hierarchyLeafFoldsDescendants(node) {
@@ -41628,17 +41848,17 @@ var init_smartart_hierarchy_hanging_box = __esm({
41628
41848
  // diagram/hierarchy/smartart-hierarchy-hanging-fold.ts
41629
41849
  function countRows(t, level2, orgChart, fold) {
41630
41850
  const { assistants, normal } = partitionChildren(t, orgChart);
41631
- let count = 1 + assistants.length;
41851
+ let count2 = 1 + assistants.length;
41632
41852
  if (normal.length === 0) {
41633
- return count;
41853
+ return count2;
41634
41854
  }
41635
41855
  if (fold && level2 >= 1) {
41636
- return count;
41856
+ return count2;
41637
41857
  }
41638
41858
  for (const child32 of normal) {
41639
- count += countRows(child32, level2 + 1, orgChart, fold);
41859
+ count2 += countRows(child32, level2 + 1, orgChart, fold);
41640
41860
  }
41641
- return count;
41861
+ return count2;
41642
41862
  }
41643
41863
  function countHangingRows(roots, orgChart, fold) {
41644
41864
  return roots.reduce((sum, root) => sum + countRows(root, 0, orgChart, fold), 0);
@@ -47286,8 +47506,8 @@ function readPairs(element, vt) {
47286
47506
  const out = [];
47287
47507
  for (let i2 = 0; i2 + 1 < variants.length; i2 += 2) {
47288
47508
  const name = variants[i2]?.textContent ?? "";
47289
- const count = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
47290
- out.push({ name, count: Number.isFinite(count) ? count : 0 });
47509
+ const count2 = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
47510
+ out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
47291
47511
  }
47292
47512
  return out;
47293
47513
  }
@@ -47504,9 +47724,9 @@ var init_custom = __esm({
47504
47724
  function titleGroups(headingPairs, titlesOfParts) {
47505
47725
  let offset = 0;
47506
47726
  return headingPairs.map((pair) => {
47507
- const count = Math.max(0, pair.count);
47508
- const titles = titlesOfParts.slice(offset, offset + count);
47509
- offset += count;
47727
+ const count2 = Math.max(0, pair.count);
47728
+ const titles = titlesOfParts.slice(offset, offset + count2);
47729
+ offset += count2;
47510
47730
  return { name: pair.name, titles };
47511
47731
  });
47512
47732
  }
@@ -69071,8 +69291,8 @@ var init_image_first_pixel_gif = __esm({
69071
69291
  return this.blockBytes[this.blockPos++];
69072
69292
  }
69073
69293
  /** Read `count` bits, LSB-first. Returns `undefined` at end of data. */
69074
- bits(count) {
69075
- while (this.bitCount < count) {
69294
+ bits(count2) {
69295
+ while (this.bitCount < count2) {
69076
69296
  const byte = this.nextByte();
69077
69297
  if (byte === void 0) {
69078
69298
  return void 0;
@@ -69080,9 +69300,9 @@ var init_image_first_pixel_gif = __esm({
69080
69300
  this.bitBuf |= byte << this.bitCount;
69081
69301
  this.bitCount += 8;
69082
69302
  }
69083
- const value = this.bitBuf & (1 << count) - 1;
69084
- this.bitBuf >>>= count;
69085
- this.bitCount -= count;
69303
+ const value = this.bitBuf & (1 << count2) - 1;
69304
+ this.bitBuf >>>= count2;
69305
+ this.bitCount -= count2;
69086
69306
  return value;
69087
69307
  }
69088
69308
  };
@@ -69103,12 +69323,12 @@ function decodeJpegHuffmanSymbol(reader2, table) {
69103
69323
  let index = 0;
69104
69324
  for (let len = 1; len <= 16; len++) {
69105
69325
  code = code << 1 | reader2.bits(1);
69106
- const count = table.counts[len];
69107
- if (count > 0 && code - first2 < count) {
69326
+ const count2 = table.counts[len];
69327
+ if (count2 > 0 && code - first2 < count2) {
69108
69328
  return table.symbols[index + (code - first2)];
69109
69329
  }
69110
- index += count;
69111
- first2 += count;
69330
+ index += count2;
69331
+ first2 += count2;
69112
69332
  first2 <<= 1;
69113
69333
  }
69114
69334
  throw new Error("jpeg: invalid Huffman code");
@@ -69158,9 +69378,9 @@ var init_image_first_pixel_jpeg_bitstream = __esm({
69158
69378
  return this.currentByte >> this.bitsLeftInByte & 1;
69159
69379
  }
69160
69380
  /** Read `count` (0-16) bits MSB-first as an unsigned integer. */
69161
- bits(count) {
69381
+ bits(count2) {
69162
69382
  let value = 0;
69163
- for (let i2 = 0; i2 < count; i2++) {
69383
+ for (let i2 = 0; i2 < count2; i2++) {
69164
69384
  value = value << 1 | this.nextBit();
69165
69385
  }
69166
69386
  return value >>> 0;
@@ -69446,12 +69666,12 @@ function decodeSymbol(reader2, table) {
69446
69666
  let index = 0;
69447
69667
  for (let len = 1; len < table.counts.length; len++) {
69448
69668
  code |= reader2.bits(1);
69449
- const count = table.counts[len];
69450
- if (code - first2 < count) {
69669
+ const count2 = table.counts[len];
69670
+ if (code - first2 < count2) {
69451
69671
  return table.symbols[index + (code - first2)];
69452
69672
  }
69453
- index += count;
69454
- first2 += count;
69673
+ index += count2;
69674
+ first2 += count2;
69455
69675
  first2 <<= 1;
69456
69676
  code <<= 1;
69457
69677
  }
@@ -69705,8 +69925,8 @@ var init_inflate = __esm({
69705
69925
  get bytePos() {
69706
69926
  return this.pos;
69707
69927
  }
69708
- bits(count) {
69709
- while (this.bitCount < count) {
69928
+ bits(count2) {
69929
+ while (this.bitCount < count2) {
69710
69930
  if (this.pos >= this.data.length) {
69711
69931
  throw new Error("inflate: unexpected end of stream");
69712
69932
  }
@@ -69714,9 +69934,9 @@ var init_inflate = __esm({
69714
69934
  this.pos++;
69715
69935
  this.bitCount += 8;
69716
69936
  }
69717
- const value = this.bitBuf & (1 << count) - 1;
69718
- this.bitBuf >>>= count;
69719
- this.bitCount -= count;
69937
+ const value = this.bitBuf & (1 << count2) - 1;
69938
+ this.bitBuf >>>= count2;
69939
+ this.bitCount -= count2;
69720
69940
  return value;
69721
69941
  }
69722
69942
  alignToByte() {
@@ -71141,12 +71361,12 @@ var init_chart_grid_operations = __esm({
71141
71361
 
71142
71362
  // pptx/core/utils/chart-data-sheet.ts
71143
71363
  function chartDataToSheet(data) {
71144
- const count = data.categories.length;
71364
+ const count2 = data.categories.length;
71145
71365
  return {
71146
71366
  categories: [...data.categories],
71147
71367
  series: data.series.map((series) => ({
71148
71368
  name: series.name,
71149
- values: Array.from({ length: count }, (_, index) => {
71369
+ values: Array.from({ length: count2 }, (_, index) => {
71150
71370
  const value = series.values[index];
71151
71371
  return typeof value === "number" && Number.isFinite(value) ? value : null;
71152
71372
  })
@@ -79790,7 +80010,7 @@ function parsedParagraphSignature(paragraph2) {
79790
80010
  return signatureOf(counts);
79791
80011
  }
79792
80012
  function signatureOf(counts) {
79793
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
80013
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
79794
80014
  }
79795
80015
  function collectParsedParagraphs2(root) {
79796
80016
  const result = [];
@@ -83141,23 +83361,23 @@ function classify(chars, index) {
83141
83361
  }
83142
83362
  function countParagraphWords(text2) {
83143
83363
  const chars = Array.from(text2);
83144
- let count = 0;
83364
+ let count2 = 0;
83145
83365
  let previous = "none";
83146
83366
  for (let index = 0; index < chars.length; index++) {
83147
83367
  const kind = classify(chars, index);
83148
83368
  if (kind === "space") {
83149
83369
  if (previous === "none" || previous === "control") {
83150
- count++;
83370
+ count2++;
83151
83371
  }
83152
83372
  previous = "space";
83153
83373
  continue;
83154
83374
  }
83155
83375
  if (kind === "ideograph" || kind === "control" || kind !== previous) {
83156
- count++;
83376
+ count2++;
83157
83377
  }
83158
83378
  previous = kind;
83159
83379
  }
83160
- return count;
83380
+ return count2;
83161
83381
  }
83162
83382
  var LINE_BREAK_CHAR, WORD_CHAR, DIGIT_CHAR, IDEOGRAPH_CHAR, SPACE_CHAR, WORD_JOINERS, NUMBER_JOINERS;
83163
83383
  var init_app_properties_word_count = __esm({
@@ -86234,10 +86454,10 @@ function assertAfterAnimationClearSupported(effectCTn) {
86234
86454
  if (!isXmlObject5(sub)) return;
86235
86455
  const countAfterFlags = (value) => {
86236
86456
  if (Array.isArray(value))
86237
- return value.reduce((count, child32) => count + countAfterFlags(child32), 0);
86457
+ return value.reduce((count2, child32) => count2 + countAfterFlags(child32), 0);
86238
86458
  if (!isXmlObject5(value)) return 0;
86239
86459
  return Object.entries(value).reduce(
86240
- (count, [key2, child32]) => count + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child32)) ? 1 : countAfterFlags(child32)),
86460
+ (count2, [key2, child32]) => count2 + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child32)) ? 1 : countAfterFlags(child32)),
86241
86461
  0
86242
86462
  );
86243
86463
  };
@@ -108421,8 +108641,8 @@ function reorderContainer(node, rawInner) {
108421
108641
  if (isGroupedByTag(children17.map((child32) => child32.tag))) {
108422
108642
  return;
108423
108643
  }
108424
- for (const [tag, count] of occurrence) {
108425
- if (ensureItems(node[tag]).length !== count) {
108644
+ for (const [tag, count2] of occurrence) {
108645
+ if (ensureItems(node[tag]).length !== count2) {
108426
108646
  return;
108427
108647
  }
108428
108648
  }
@@ -108444,8 +108664,8 @@ function annotateOmmlSiblingOrder(xml, parsed) {
108444
108664
  return;
108445
108665
  }
108446
108666
  const nodes = collectParsedOmathNodes(parsed);
108447
- const count = Math.min(fragments.length, nodes.length);
108448
- for (let index = 0; index < count; index++) {
108667
+ const count2 = Math.min(fragments.length, nodes.length);
108668
+ for (let index = 0; index < count2; index++) {
108449
108669
  if (fragments[index]) {
108450
108670
  reorderContainer(nodes[index], fragments[index]);
108451
108671
  }
@@ -109585,6 +109805,180 @@ var init_eot_parser = __esm({
109585
109805
  }
109586
109806
  });
109587
109807
 
109808
+ // pptx/core/utils/deferred-embedded-font.ts
109809
+ function resolveEmbeddedFontGuid(source) {
109810
+ if (isEotFormat(source.originalPartBytes)) {
109811
+ return void 0;
109812
+ }
109813
+ const { fontKey } = source;
109814
+ const fromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
109815
+ return fromKey || extractGuidFromPartName(source.partPath) || void 0;
109816
+ }
109817
+ function hasSfntSignature(bytes) {
109818
+ if (bytes.length < 4) {
109819
+ return false;
109820
+ }
109821
+ const [v0, v1, v2, v3] = bytes;
109822
+ return v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0 || v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79 || v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102 || v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
109823
+ }
109824
+ function warnInvalidSignature(name, bytes) {
109825
+ const hex3 = Array.from(bytes.subarray(0, 4), (b) => b.toString(16)).join(",");
109826
+ console.warn(
109827
+ `[pptx-viewer] Embedded font "${name}" has invalid sfnt header [${hex3}] after processing; skipping (web font fallback will be used)`
109828
+ );
109829
+ }
109830
+ function isEmbeddedFontPartPlausible(source) {
109831
+ const bytes = source.originalPartBytes;
109832
+ if (bytes.length === 0) {
109833
+ return false;
109834
+ }
109835
+ if (isEotFormat(bytes)) {
109836
+ return true;
109837
+ }
109838
+ const guid = resolveEmbeddedFontGuid(source);
109839
+ if (!guid) {
109840
+ console.warn(
109841
+ `[pptx-viewer] Embedded font "${source.name}" at "${source.partPath}" has no fontKey attribute and no GUID in filename; skipping`
109842
+ );
109843
+ return false;
109844
+ }
109845
+ const header = deobfuscateFont(bytes.subarray(0, Math.min(bytes.length, 32)), guid);
109846
+ if (header.length < 4) {
109847
+ return false;
109848
+ }
109849
+ if (!hasSfntSignature(header)) {
109850
+ warnInvalidSignature(source.name, header);
109851
+ return false;
109852
+ }
109853
+ return true;
109854
+ }
109855
+ function uint8ArrayToBase642(bytes) {
109856
+ let binary = "";
109857
+ const chunkSize = 8192;
109858
+ for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
109859
+ const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
109860
+ for (let j = 0; j < chunk2.length; j++) {
109861
+ binary += String.fromCharCode(chunk2[j]);
109862
+ }
109863
+ }
109864
+ return btoa(binary);
109865
+ }
109866
+ function decodeEmbeddedFontPart(source) {
109867
+ const { name, partPath, originalPartBytes } = source;
109868
+ try {
109869
+ let fontData;
109870
+ const fontGuid = resolveEmbeddedFontGuid(source);
109871
+ if (isEotFormat(originalPartBytes)) {
109872
+ const extracted = extractFontFromEot(originalPartBytes);
109873
+ if (!extracted) {
109874
+ const header = parseEotHeader(originalPartBytes);
109875
+ console.info(
109876
+ `[pptx-viewer] Embedded font "${name}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""}; extraction failed, will use web font fallback`
109877
+ );
109878
+ return null;
109879
+ }
109880
+ fontData = extracted.fontData;
109881
+ } else if (fontGuid) {
109882
+ fontData = deobfuscateFont(originalPartBytes, fontGuid);
109883
+ } else {
109884
+ console.warn(
109885
+ `[pptx-viewer] Embedded font "${name}" at "${partPath}" has no fontKey attribute and no GUID in filename; skipping`
109886
+ );
109887
+ return null;
109888
+ }
109889
+ if (fontData.length < 4) {
109890
+ return null;
109891
+ }
109892
+ if (!hasSfntSignature(fontData)) {
109893
+ warnInvalidSignature(name, fontData);
109894
+ return null;
109895
+ }
109896
+ const format = detectFontFormat(fontData);
109897
+ const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
109898
+ return {
109899
+ name,
109900
+ dataUrl: `data:${mimeType};base64,${uint8ArrayToBase642(fontData)}`,
109901
+ bold: source.bold,
109902
+ italic: source.italic,
109903
+ format,
109904
+ rawFontData: fontData,
109905
+ partPath,
109906
+ fontGuid,
109907
+ originalRId: source.originalRId,
109908
+ originalPartBytes
109909
+ };
109910
+ } catch {
109911
+ return null;
109912
+ }
109913
+ }
109914
+ function createDeferredEmbeddedFont(source) {
109915
+ const fontGuid = resolveEmbeddedFontGuid(source);
109916
+ let fields;
109917
+ let pending;
109918
+ const decode = () => {
109919
+ if (!fields) {
109920
+ const decoded = decodeEmbeddedFontPart(source);
109921
+ fields = {
109922
+ dataUrl: decoded?.dataUrl ?? "",
109923
+ format: decoded?.format,
109924
+ rawFontData: decoded?.rawFontData
109925
+ };
109926
+ }
109927
+ return fields;
109928
+ };
109929
+ const font = {
109930
+ name: source.name,
109931
+ get dataUrl() {
109932
+ return decode().dataUrl;
109933
+ },
109934
+ set dataUrl(value) {
109935
+ decode().dataUrl = value;
109936
+ },
109937
+ bold: source.bold,
109938
+ italic: source.italic,
109939
+ get format() {
109940
+ return decode().format;
109941
+ },
109942
+ set format(value) {
109943
+ decode().format = value;
109944
+ },
109945
+ get rawFontData() {
109946
+ return decode().rawFontData;
109947
+ },
109948
+ set rawFontData(value) {
109949
+ decode().rawFontData = value;
109950
+ },
109951
+ partPath: source.partPath,
109952
+ fontGuid,
109953
+ originalRId: source.originalRId,
109954
+ originalPartBytes: source.originalPartBytes
109955
+ };
109956
+ Object.defineProperties(font, {
109957
+ load: {
109958
+ value: () => pending ??= Promise.resolve().then(
109959
+ () => decode().rawFontData?.length || decode().dataUrl ? font : null
109960
+ )
109961
+ },
109962
+ isLoaded: { get: () => fields !== void 0 }
109963
+ });
109964
+ return font;
109965
+ }
109966
+ function shouldSaveEmbeddedFontVerbatim(font) {
109967
+ if (font.isLoaded === void 0 || !font.originalPartBytes?.length) {
109968
+ return false;
109969
+ }
109970
+ if (!font.originalRId || !font.partPath) {
109971
+ return false;
109972
+ }
109973
+ return font.isLoaded === false || !font.rawFontData?.length;
109974
+ }
109975
+ var init_deferred_embedded_font = __esm({
109976
+ "pptx/core/utils/deferred-embedded-font.ts"() {
109977
+ init_eot_parser();
109978
+ init_font_deobfuscation();
109979
+ }
109980
+ });
109981
+
109588
109982
  // pptx/core/core/runtime/header-footer-parts.ts
109589
109983
  function asArray3(value) {
109590
109984
  if (Array.isArray(value)) {
@@ -111641,10 +112035,10 @@ function collectFilteredSeriesIndices(container2, xmlLookup) {
111641
112035
  }
111642
112036
  return reserved;
111643
112037
  }
111644
- function assignSeriesIndices(count, reservedIndices) {
112038
+ function assignSeriesIndices(count2, reservedIndices) {
111645
112039
  const assigned = [];
111646
112040
  let cursor = 0;
111647
- for (let i2 = 0; i2 < count; i2++) {
112041
+ for (let i2 = 0; i2 < count2; i2++) {
111648
112042
  while (reservedIndices.has(cursor)) {
111649
112043
  cursor++;
111650
112044
  }
@@ -112333,8 +112727,8 @@ function parseCache(node) {
112333
112727
  return point2;
112334
112728
  })
112335
112729
  };
112336
- const count = Number(cVal(node, "ptCount") ?? Number.NaN);
112337
- if (Number.isInteger(count) && count >= 0) cache2.pointCount = count;
112730
+ const count2 = Number(cVal(node, "ptCount") ?? Number.NaN);
112731
+ if (Number.isInteger(count2) && count2 >= 0) cache2.pointCount = count2;
112338
112732
  const formatCode2 = cChild(node, "formatCode")?.textContent;
112339
112733
  if (formatCode2) cache2.formatCode = formatCode2;
112340
112734
  return cache2;
@@ -112352,8 +112746,8 @@ function parseDataSource(element) {
112352
112746
  const levels = cChild(ref, "multiLvlStrCache");
112353
112747
  if (levels) {
112354
112748
  source.levels = children2(levels, "lvl", NS.c).map(parseCache);
112355
- const count = Number(cVal(levels, "ptCount") ?? Number.NaN);
112356
- if (Number.isInteger(count) && count >= 0) source.levelPointCount = count;
112749
+ const count2 = Number(cVal(levels, "ptCount") ?? Number.NaN);
112750
+ if (Number.isInteger(count2) && count2 >= 0) source.levelPointCount = count2;
112357
112751
  }
112358
112752
  return source;
112359
112753
  }
@@ -122076,9 +122470,9 @@ function buildFopt(simple, complex = []) {
122076
122470
  payload.bytes(bytes);
122077
122471
  }
122078
122472
  }
122079
- const count = simple.length + complex.length;
122473
+ const count2 = simple.length + complex.length;
122080
122474
  const data = new ByteWriter().append(entries).append(payload).toBytes();
122081
- return record(OA.FOPT, data, count, false, 3);
122475
+ return record(OA.FOPT, data, count2, false, 3);
122082
122476
  }
122083
122477
  function buildMetroBlobTertiaryFopt(metroBlob) {
122084
122478
  const data = new ByteWriter().u16(METRO_BLOB_OPID | 32768 | FBID_FLAG).u32(metroBlob.length >>> 0).bytes(metroBlob).toBytes();
@@ -122142,9 +122536,9 @@ function buildDgg(shapesPerDrawing, totalShapes) {
122142
122536
  const cidcl = drawingCount + 1;
122143
122537
  const cspSaved = totalShapes - drawingCount;
122144
122538
  const w = new ByteWriter().u32(maxShapeId).u32(cidcl).u32(cspSaved).u32(drawingCount);
122145
- shapesPerDrawing.forEach((count, i2) => {
122539
+ shapesPerDrawing.forEach((count2, i2) => {
122146
122540
  const drawingId = i2 + 1;
122147
- w.u32(drawingId).u32(count);
122541
+ w.u32(drawingId).u32(count2);
122148
122542
  });
122149
122543
  return record(OA.Dgg, w.toBytes(), 0, false, 0);
122150
122544
  }
@@ -122972,8 +123366,8 @@ function atom(recType, data) {
122972
123366
  function textHeader(textType) {
122973
123367
  return atom(RT.TextHeaderAtom, new ByteWriter().u32(textType).toBytes());
122974
123368
  }
122975
- function textSpecInfo(count) {
122976
- return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count).u32(1).u16(0).toBytes());
123369
+ function textSpecInfo(count2) {
123370
+ return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count2).u32(1).u16(0).toBytes());
122977
123371
  }
122978
123372
  function promptText(textType, paragraphs) {
122979
123373
  const text2 = paragraphs.join("\r");
@@ -123784,17 +124178,17 @@ function slideMasterIndex(masterIndex, masterCount) {
123784
124178
  return masterIndex !== void 0 && Number.isInteger(masterIndex) && masterIndex >= 0 && masterIndex < masterCount ? masterIndex : 0;
123785
124179
  }
123786
124180
  function countDrawingShapes(shapes) {
123787
- let count = 1;
124181
+ let count2 = 1;
123788
124182
  const walk3 = (list3) => {
123789
124183
  for (const shape of list3) {
123790
- count++;
124184
+ count2++;
123791
124185
  if (shape.kind === "group") {
123792
124186
  walk3(shape.children);
123793
124187
  }
123794
124188
  }
123795
124189
  };
123796
124190
  walk3(shapes);
123797
- return count;
124191
+ return count2;
123798
124192
  }
123799
124193
  function collectFonts(deck, masters) {
123800
124194
  const collect = (shape) => {
@@ -124375,7 +124769,7 @@ function toLevel(style = {}, themeFonts = {}) {
124375
124769
  }
124376
124770
  };
124377
124771
  }
124378
- function toLevels(levels, count, themeFonts) {
124772
+ function toLevels(levels, count2, themeFonts) {
124379
124773
  if (!levels) {
124380
124774
  return void 0;
124381
124775
  }
@@ -124385,7 +124779,7 @@ function toLevels(levels, count, themeFonts) {
124385
124779
  }
124386
124780
  const base = levels[-1];
124387
124781
  return Array.from(
124388
- { length: count },
124782
+ { length: count2 },
124389
124783
  (_, i2) => toLevel(base || levels[i2] ? { ...base, ...levels[i2] } : void 0, themeFonts)
124390
124784
  );
124391
124785
  }
@@ -125294,12 +125688,12 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
125294
125688
  }
125295
125689
  if (Array.isArray(node)) {
125296
125690
  return node.reduce(
125297
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
125691
+ (count3, entry2) => count3 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
125298
125692
  0
125299
125693
  );
125300
125694
  }
125301
125695
  const object = node;
125302
- let count = 0;
125696
+ let count2 = 0;
125303
125697
  for (const key2 of Object.keys(object)) {
125304
125698
  if (key2.startsWith("@_")) {
125305
125699
  continue;
@@ -125311,14 +125705,14 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
125311
125705
  const chart = chartKey ? candidate[chartKey] : void 0;
125312
125706
  if (chart && String(chart["@_r:id"]) === relationshipId2) {
125313
125707
  rebindGraphicData(candidate, relationshipId2, extended);
125314
- count += 1;
125708
+ count2 += 1;
125315
125709
  }
125316
125710
  }
125317
125711
  continue;
125318
125712
  }
125319
- count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
125713
+ count2 += visitGraphicData(value, relationshipId2, extended, getLocalName2);
125320
125714
  }
125321
- return count;
125715
+ return count2;
125322
125716
  }
125323
125717
  async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
125324
125718
  const xml = await deps.zip.file(slidePath)?.async("string");
@@ -125326,11 +125720,11 @@ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, exten
125326
125720
  return 0;
125327
125721
  }
125328
125722
  const tree = deps.parser.parse(xml);
125329
- const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
125330
- if (count > 0) {
125723
+ const count2 = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
125724
+ if (count2 > 0) {
125331
125725
  deps.zip.file(slidePath, deps.builder.build(tree));
125332
125726
  }
125333
- return count;
125727
+ return count2;
125334
125728
  }
125335
125729
  var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
125336
125730
  var init_chart_part_registration = __esm({
@@ -133646,6 +134040,8 @@ var init_PptxHandlerRuntimeState = __esm({
133646
134040
  alternateContentBlockByRawXml = /* @__PURE__ */ new WeakMap();
133647
134041
  /** Embedded fonts extracted during load, preserved for automatic re-embedding on save. */
133648
134042
  loadedEmbeddedFonts = [];
134043
+ /** Decode every embedded font variant during load (see `PptxHandlerLoadOptions`). */
134044
+ eagerDecodeEmbeddedFonts = false;
133649
134045
  /** Typed source metadata for lossless embedded-font list round trips. */
133650
134046
  loadedEmbeddedFontList;
133651
134047
  /**
@@ -138465,10 +138861,10 @@ function detectDominantScript(text2) {
138465
138861
  }
138466
138862
  let best;
138467
138863
  let bestCount = 0;
138468
- for (const [cat, count] of Object.entries(counts)) {
138469
- if (count > bestCount) {
138864
+ for (const [cat, count2] of Object.entries(counts)) {
138865
+ if (count2 > bestCount) {
138470
138866
  best = cat;
138471
- bestCount = count;
138867
+ bestCount = count2;
138472
138868
  }
138473
138869
  }
138474
138870
  return best;
@@ -141334,9 +141730,9 @@ function applyTableStructureEditXml(table, source, next, edit) {
141334
141730
  if (axis !== "row" && axis !== "column" || action !== "insert" && action !== "delete") {
141335
141731
  return false;
141336
141732
  }
141337
- const count = axis === "row" ? rows.length : columns.length;
141733
+ const count2 = axis === "row" ? rows.length : columns.length;
141338
141734
  const delta2 = action === "insert" ? 1 : -1;
141339
- if (!grid || !Number.isInteger(index) || index < 0 || index > count - (action === "delete" ? 1 : 0) || action === "delete" && count <= 1 || next.rows.length !== rows.length + (axis === "row" ? delta2 : 0) || next.columnWidths.length !== columns.length + (axis === "column" ? delta2 : 0)) {
141735
+ if (!grid || !Number.isInteger(index) || index < 0 || index > count2 - (action === "delete" ? 1 : 0) || action === "delete" && count2 <= 1 || next.rows.length !== rows.length + (axis === "row" ? delta2 : 0) || next.columnWidths.length !== columns.length + (axis === "column" ? delta2 : 0)) {
141340
141736
  return false;
141341
141737
  }
141342
141738
  if (axis === "row") {
@@ -143983,6 +144379,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
143983
144379
  "pptx/core/core/runtime/PptxHandlerRuntimeSaveDocumentParts.ts"() {
143984
144380
  init_utils();
143985
144381
  init_customer_data_package();
144382
+ init_deferred_embedded_font();
143986
144383
  init_embedded_font_list();
143987
144384
  init_font_deobfuscation();
143988
144385
  init_safe_path();
@@ -144444,7 +144841,9 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
144444
144841
  return;
144445
144842
  }
144446
144843
  const fonts = explicitFonts ?? this.loadedEmbeddedFonts;
144447
- const fontsWithData = fonts.filter((f6) => f6.rawFontData && f6.rawFontData.length > 0);
144844
+ const fontsWithData = fonts.filter(
144845
+ (f6) => shouldSaveEmbeddedFontVerbatim(f6) || f6.rawFontData && f6.rawFontData.length > 0
144846
+ );
144448
144847
  if (fontsWithData.length === 0) {
144449
144848
  const metadata = explicitFontList ?? this.loadedEmbeddedFontList;
144450
144849
  if (metadata && this.presentationData) {
@@ -144487,10 +144886,11 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
144487
144886
  "p:font": { "@_typeface": typeface }
144488
144887
  };
144489
144888
  for (const variant of variants) {
144490
- const fontData = variant.rawFontData;
144889
+ const verbatim = shouldSaveEmbeddedFontVerbatim(variant);
144890
+ const fontData = verbatim ? void 0 : variant.rawFontData;
144491
144891
  const hasOriginal = Boolean(variant.originalRId && variant.partPath);
144492
- const reuseObfuscation = hasOriginal && Boolean(variant.fontGuid);
144493
- const reuseVerbatim = hasOriginal && !variant.fontGuid && Boolean(variant.originalPartBytes);
144892
+ const reuseObfuscation = hasOriginal && !verbatim && Boolean(variant.fontGuid);
144893
+ const reuseVerbatim = hasOriginal && (verbatim || !variant.fontGuid) && Boolean(variant.originalPartBytes);
144494
144894
  let guid;
144495
144895
  let fontPartPath;
144496
144896
  let relativeTarget4;
@@ -148106,13 +148506,13 @@ function countDeclaredIds(node, counts, ensureArray20) {
148106
148506
  if (!countDeclaredIds(branch, branchCounts, ensureArray20)) {
148107
148507
  return false;
148108
148508
  }
148109
- for (const [id, count] of branchCounts) {
148110
- merged.set(id, Math.max(merged.get(id) ?? 0, count));
148509
+ for (const [id, count2] of branchCounts) {
148510
+ merged.set(id, Math.max(merged.get(id) ?? 0, count2));
148111
148511
  }
148112
148512
  }
148113
148513
  }
148114
- for (const [id, count] of merged) {
148115
- counts.set(id, (counts.get(id) ?? 0) + count);
148514
+ for (const [id, count2] of merged) {
148515
+ counts.set(id, (counts.get(id) ?? 0) + count2);
148116
148516
  }
148117
148517
  }
148118
148518
  return true;
@@ -148122,8 +148522,8 @@ function hasStructuralIdDefects(spTree, ensureArray20) {
148122
148522
  if (!countDeclaredIds(spTree, counts, ensureArray20)) {
148123
148523
  return true;
148124
148524
  }
148125
- for (const count of counts.values()) {
148126
- if (count > 1) {
148525
+ for (const count2 of counts.values()) {
148526
+ if (count2 > 1) {
148127
148527
  return true;
148128
148528
  }
148129
148529
  }
@@ -163064,8 +163464,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
163064
163464
  var PptxHandlerRuntime99;
163065
163465
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
163066
163466
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
163067
- init_eot_parser();
163068
- init_font_deobfuscation();
163467
+ init_deferred_embedded_font();
163069
163468
  init_layout_display_name();
163070
163469
  init_strip_parent_dir_segments();
163071
163470
  init_xml_access();
@@ -163141,7 +163540,13 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
163141
163540
  }
163142
163541
  return map;
163143
163542
  }
163144
- /** Extract, de-obfuscate, and encode a single font variant. */
163543
+ /**
163544
+ * Read one variant's part. By default the result is a deferred descriptor
163545
+ * that decodes on first use (see `createDeferredEmbeddedFont`); parts that
163546
+ * fail the checks possible without decoding are skipped, as before. With
163547
+ * `eagerDecodeEmbeddedFonts` the variant is decoded now and skipped when
163548
+ * decoding fails.
163549
+ */
163145
163550
  async extractEmbeddedFontVariant(typeface, rId, bold, italic, relsMap, fontKey) {
163146
163551
  const fontPath = relsMap.get(rId);
163147
163552
  if (!fontPath) {
@@ -163152,80 +163557,25 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
163152
163557
  if (!fontBinary || fontBinary.length === 0) {
163153
163558
  return null;
163154
163559
  }
163155
- const originalPartBytes = new Uint8Array(fontBinary);
163156
- let fontData;
163157
- let resolvedGuid;
163158
- if (isEotFormat(fontBinary)) {
163159
- const extracted = extractFontFromEot(fontBinary);
163160
- if (extracted) {
163161
- fontData = extracted.fontData;
163162
- } else {
163163
- const header = parseEotHeader(fontBinary);
163164
- console.info(
163165
- `[pptx-viewer] Embedded font "${typeface}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""} \u2014 extraction failed, will use web font fallback`
163166
- );
163167
- return null;
163168
- }
163169
- } else {
163170
- const guidFromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
163171
- const guidFromPath = extractGuidFromPartName(fontPath);
163172
- const guid = guidFromKey || guidFromPath;
163173
- if (guid) {
163174
- fontData = deobfuscateFont(fontBinary, guid);
163175
- resolvedGuid = guid;
163176
- } else {
163177
- console.warn(
163178
- `[pptx-viewer] Embedded font "${typeface}" at "${fontPath}" has no fontKey attribute and no GUID in filename \u2014 skipping`
163179
- );
163180
- return null;
163181
- }
163182
- }
163183
- if (fontData.length < 4) {
163184
- return null;
163185
- }
163186
- const v0 = fontData[0], v1 = fontData[1], v2 = fontData[2], v3 = fontData[3];
163187
- const isTrueType = v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0;
163188
- const isOTTO = v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79;
163189
- const isTTC = v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102;
163190
- const isWOFF = v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
163191
- if (!(isTrueType || isOTTO || isTTC || isWOFF)) {
163192
- console.warn(
163193
- `[pptx-viewer] Embedded font "${typeface}" has invalid sfnt header [${v0.toString(16)},${v1.toString(16)},${v2.toString(16)},${v3.toString(16)}] after processing \u2014 skipping (web font fallback will be used)`
163194
- );
163195
- return null;
163196
- }
163197
- const format = detectFontFormat(fontData);
163198
- const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
163199
- const base64 = this.uint8ArrayToBase64(fontData);
163200
- const dataUrl = `data:${mimeType};base64,${base64}`;
163201
- return {
163560
+ const source = {
163202
163561
  name: typeface,
163203
- dataUrl,
163204
163562
  bold,
163205
163563
  italic,
163206
- format,
163207
- rawFontData: fontData,
163208
- partPath: fontPath,
163209
- fontGuid: resolvedGuid,
163210
163564
  originalRId: rId,
163211
- originalPartBytes
163565
+ partPath: fontPath,
163566
+ // The descriptor owns a copy, so it outlives this handler's ZIP and
163567
+ // the save pipeline can write it back verbatim.
163568
+ originalPartBytes: new Uint8Array(fontBinary),
163569
+ fontKey
163212
163570
  };
163571
+ if (this.eagerDecodeEmbeddedFonts) {
163572
+ return decodeEmbeddedFontPart(source);
163573
+ }
163574
+ return isEmbeddedFontPartPlausible(source) ? createDeferredEmbeddedFont(source) : null;
163213
163575
  } catch {
163214
163576
  return null;
163215
163577
  }
163216
163578
  }
163217
- /** Convert Uint8Array to base64 string. */
163218
- uint8ArrayToBase64(bytes) {
163219
- let binary = "";
163220
- const chunkSize = 8192;
163221
- for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
163222
- const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
163223
- for (let j = 0; j < chunk2.length; j++) {
163224
- binary += String.fromCharCode(chunk2[j]);
163225
- }
163226
- }
163227
- return btoa(binary);
163228
- }
163229
163579
  getLayoutOptions() {
163230
163580
  const options = [];
163231
163581
  for (const [path3, xmlObj] of this.layoutXmlMap.entries()) {
@@ -163278,12 +163628,16 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163278
163628
  init_ole_embedded_extract();
163279
163629
  init_ole_utils();
163280
163630
  init_signature_detection();
163281
- init_types2();
163631
+ init_load_limits();
163282
163632
  init_authored_slide_background();
163283
163633
  init_bullet_picture_image_enrichment();
163284
163634
  init_PptxHandlerRuntimeEmbeddedFonts();
163285
163635
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
163286
163636
  PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
163637
+ /** The limits of the load in progress (see `PptxHandlerLoadOptions.limits`). */
163638
+ loadLimits = { ...exports.DEFAULT_PPTX_LOAD_LIMITS };
163639
+ /** Slide elements parsed so far by the load in progress, for `maxShapes`. */
163640
+ loadedShapeCount = 0;
163287
163641
  isZipContainer(data) {
163288
163642
  const bytes = new Uint8Array(data);
163289
163643
  if (bytes.byteLength < 4) {
@@ -163292,7 +163646,9 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163292
163646
  return bytes[0] === 80 && bytes[1] === 75 && (bytes[2] === 3 && bytes[3] === 4 || bytes[2] === 5 && bytes[3] === 6 || bytes[2] === 7 && bytes[3] === 8);
163293
163647
  }
163294
163648
  async initializeLoadSession(data, options) {
163649
+ const limits = resolvePptxLoadLimits(options);
163295
163650
  this.eagerDecodeImages = options.eagerDecodeImages ?? false;
163651
+ this.eagerDecodeEmbeddedFonts = options.eagerDecodeEmbeddedFonts === true;
163296
163652
  this.allowExternalImages = options.allowExternalImages === true;
163297
163653
  if (data.byteLength < 4) {
163298
163654
  throw new Error("Invalid PPTX binary: file is empty or truncated.");
@@ -163302,7 +163658,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163302
163658
  "Invalid PPTX binary: not a ZIP/OpenXML package. The file is neither an OpenXML archive nor an OLE compound file (which is how legacy .ppt and encrypted presentations arrive), so it is most likely corrupt, truncated, or not a presentation at all."
163303
163659
  );
163304
163660
  }
163305
- const maxBytes = typeof options.maxUncompressedBytes === "number" && options.maxUncompressedBytes > 0 ? options.maxUncompressedBytes : exports.DEFAULT_MAX_UNCOMPRESSED_BYTES;
163661
+ const maxBytes = limits.maxUncompressedBytes;
163306
163662
  let loaded;
163307
163663
  try {
163308
163664
  loaded = await JSZip__default.default.loadAsync(data);
@@ -163312,11 +163668,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163312
163668
  }
163313
163669
  this.zip = guardZip(loaded, {
163314
163670
  label: "PPTX",
163315
- maxEntries: exports.MAX_ZIP_ENTRY_COUNT,
163671
+ maxEntries: limits.maxEntries,
163316
163672
  maxEntryBytes: maxBytes,
163317
163673
  maxTotalBytes: maxBytes,
163318
- createError: (message, details) => new exports.ZipBombError(message, details)
163674
+ createError: createPptxZipBombError
163319
163675
  });
163676
+ this.loadLimits = limits;
163677
+ this.loadedShapeCount = 0;
163320
163678
  try {
163321
163679
  this.documentPropertiesUpdater = this.dependencyFactory.createDocumentPropertiesUpdater(
163322
163680
  this.zip,
@@ -163482,6 +163840,11 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163482
163840
  }
163483
163841
  this.presentationData = this.parser.parse(presentationXml3);
163484
163842
  this.detectAndSetStrictConformance(this.presentationData);
163843
+ const slideIds = this.presentationData?.["p:presentation"]?.["p:sldIdLst"]?.["p:sldId"];
163844
+ assertPptxSlideCountWithinLimits(
163845
+ Array.isArray(slideIds) ? slideIds.length : slideIds ? 1 : 0,
163846
+ this.loadLimits
163847
+ );
163485
163848
  await this.loadThemeData();
163486
163849
  this.parsePresentationDefaultTextStyle();
163487
163850
  await this.loadCommentAuthors();
@@ -163611,7 +163974,17 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163611
163974
  loadThemeOverride: (partBasePath) => this.loadThemeOverride(partBasePath),
163612
163975
  applyThemeOverrideState: (override) => this.applyThemeOverrideState(override),
163613
163976
  getLayoutElements: (slidePath) => this.getLayoutElements(slidePath),
163614
- parseSlide: (slideXml3, slidePath) => this.parseSlide(slideXml3, slidePath),
163977
+ // `maxShapes`: each slide's own elements are counted as soon as they are
163978
+ // parsed, before that slide's media is resolved and before the next slide.
163979
+ parseSlide: async (slideXml3, slidePath) => {
163980
+ const elements3 = await this.parseSlide(slideXml3, slidePath);
163981
+ this.loadedShapeCount = countPptxShapesWithinLimits(
163982
+ this.loadedShapeCount,
163983
+ elements3,
163984
+ this.loadLimits
163985
+ );
163986
+ return elements3;
163987
+ },
163615
163988
  extractMediaTimingMap: (slideXml3, slidePath) => this.extractMediaTimingMap(slideXml3, slidePath),
163616
163989
  enrichMediaElementsWithTiming: (elements3, timingMap) => this.enrichMediaElementsWithTiming(elements3, timingMap),
163617
163990
  enrichOleElementsWithEmbeddedData: (elements3, slidePath) => this.enrichOleElementsWithEmbeddedData(elements3, slidePath),
@@ -163664,6 +164037,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163664
164037
  init_smart_tags_parser();
163665
164038
  init_strip_parent_dir_segments();
163666
164039
  init_builders();
164040
+ init_load_limits();
163667
164041
  init_authored_slide_background();
163668
164042
  init_layout_switch_placeholder_prompts();
163669
164043
  init_PptxHandlerRuntimeLoadSession();
@@ -163866,21 +164240,31 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163866
164240
  try {
163867
164241
  await this.initializeLoadSession(data, options);
163868
164242
  reader2 = this.beginPartReads();
163869
- await this.detectAndPreserveVbaProject();
163870
- this.detectDigitalSignatureParts();
163871
- await this.parseCustomXmlParts();
163872
- const presentationState = await this.loadPresentationState();
163873
- const slideMasters = await this.parseSlideMasters();
163874
- await this.enrichSlideMastersWithTxStyles(slideMasters);
163875
- const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
163876
- const slidesWithWarnings = this.attachSlideWarnings(slides);
163877
- this.resetElementIdCounter(slides);
163878
- recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
163879
- return await this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
164243
+ try {
164244
+ return await this.loadInitializedSession();
164245
+ } catch (error) {
164246
+ if (error instanceof exports.PptxLoadLimitError) {
164247
+ this.dispose();
164248
+ }
164249
+ throw error;
164250
+ }
163880
164251
  } finally {
163881
164252
  this.endPartReads(reader2);
163882
164253
  }
163883
164254
  }
164255
+ async loadInitializedSession() {
164256
+ await this.detectAndPreserveVbaProject();
164257
+ this.detectDigitalSignatureParts();
164258
+ await this.parseCustomXmlParts();
164259
+ const presentationState = await this.loadPresentationState();
164260
+ const slideMasters = await this.parseSlideMasters();
164261
+ await this.enrichSlideMastersWithTxStyles(slideMasters);
164262
+ const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
164263
+ const slidesWithWarnings = this.attachSlideWarnings(slides);
164264
+ this.resetElementIdCounter(slides);
164265
+ recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
164266
+ return this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
164267
+ }
163884
164268
  /**
163885
164269
  * Retrieve the current background colour for a layout or master.
163886
164270
  */
@@ -165170,6 +165554,7 @@ var init_core2 = __esm({
165170
165554
  init_builders();
165171
165555
  init_factories();
165172
165556
  init_types2();
165557
+ init_load_limits();
165173
165558
  init_table_structural_ops();
165174
165559
  init_table_style_defaults();
165175
165560
  init_auto_number_sequence();
@@ -165434,24 +165819,24 @@ function parseStyleTextPropAtom(view, dataOffset, dataLen, textLength, scheme) {
165434
165819
  const charRuns = [];
165435
165820
  let covered = 0;
165436
165821
  while (covered < total && c.canRead(6)) {
165437
- const count = c.u32();
165822
+ const count2 = c.u32();
165438
165823
  const indentLevel = c.u16();
165439
- const props = { count, indentLevel };
165824
+ const props = { count: count2, indentLevel };
165440
165825
  if (!parsePfException(c, scheme, props)) {
165441
165826
  break;
165442
165827
  }
165443
165828
  paragraphRuns.push(props);
165444
- covered += count;
165829
+ covered += count2;
165445
165830
  }
165446
165831
  covered = 0;
165447
165832
  while (covered < total && c.canRead(8)) {
165448
- const count = c.u32();
165449
- const props = { count };
165833
+ const count2 = c.u32();
165834
+ const props = { count: count2 };
165450
165835
  if (!parseCfException(c, scheme, props)) {
165451
165836
  break;
165452
165837
  }
165453
165838
  charRuns.push(props);
165454
- covered += count;
165839
+ covered += count2;
165455
165840
  }
165456
165841
  return { paragraphRuns, charRuns };
165457
165842
  }
@@ -166513,13 +166898,13 @@ var init_geometry_map = __esm({
166513
166898
  function parseProperties2(view, data, rec) {
166514
166899
  const values = /* @__PURE__ */ new Map();
166515
166900
  const complex = /* @__PURE__ */ new Map();
166516
- const count = rec.recInstance;
166517
- const entriesEnd = rec.dataOffset + count * 6;
166901
+ const count2 = rec.recInstance;
166902
+ const entriesEnd = rec.dataOffset + count2 * 6;
166518
166903
  if (entriesEnd > rec.dataOffset + rec.recLen) {
166519
166904
  return { values, complex };
166520
166905
  }
166521
166906
  const complexRefs = [];
166522
- for (let i2 = 0; i2 < count; i2++) {
166907
+ for (let i2 = 0; i2 < count2; i2++) {
166523
166908
  const at2 = rec.dataOffset + i2 * 6;
166524
166909
  const opid = view.getUint16(at2, true);
166525
166910
  const value = view.getUint32(at2 + 2, true);
@@ -167720,8 +168105,8 @@ function levelXml(tag, level2, fallbackSizePt) {
167720
168105
  }
167721
168106
  function styleLevels(levels, fallbackSizePt) {
167722
168107
  const result = [];
167723
- const count = Math.max(1, Math.min(levels.length, 9));
167724
- for (let i2 = 0; i2 < count; i2++) {
168108
+ const count2 = Math.max(1, Math.min(levels.length, 9));
168109
+ for (let i2 = 0; i2 < count2; i2++) {
167725
168110
  result.push(levelXml(`lvl${i2 + 1}pPr`, levels[i2] ?? {}, fallbackSizePt));
167726
168111
  }
167727
168112
  return result.join("");
@@ -168218,6 +168603,7 @@ var PptxHandlerCore;
168218
168603
  var init_PptxHandlerCore = __esm({
168219
168604
  "pptx/core/PptxHandlerCore.ts"() {
168220
168605
  init_core2();
168606
+ init_load_limits();
168221
168607
  init_ppt();
168222
168608
  init_encryption_detection();
168223
168609
  init_ole2_parser();
@@ -168607,6 +168993,7 @@ var init_PptxHandlerCore = __esm({
168607
168993
  * ```
168608
168994
  */
168609
168995
  async load(data, options = {}) {
168996
+ assertPptxInputWithinLimits(data.byteLength, resolvePptxLoadLimits(options));
168610
168997
  const detection = detectFileFormat(data);
168611
168998
  if (detection.format === "ole") {
168612
168999
  let ole;
@@ -168859,6 +169246,7 @@ var init_PptxHandler = __esm({
168859
169246
  "pptx/core/PptxHandler.ts"() {
168860
169247
  init_json();
168861
169248
  init_PresentationBuilder();
169249
+ init_load_limits();
168862
169250
  init_PptxHandlerCore();
168863
169251
  exports.PptxHandler = class extends PptxHandlerCore {
168864
169252
  /**
@@ -168930,13 +169318,15 @@ var init_PptxHandler = __esm({
168930
169318
  * archives and portable `pptx-viewer-json` documents.
168931
169319
  *
168932
169320
  * The buffer is sniffed first: JSON documents (leading `{` plus the
168933
- * `"pptx-viewer-json"` format marker) are routed to {@link loadFromJson};
168934
- * everything else goes through the regular ZIP/OLE2 pipeline.
169321
+ * `"pptx-viewer-json"` format marker) are imported as {@link loadFromJson}
169322
+ * does; everything else goes through the regular ZIP/OLE2 pipeline.
168935
169323
  */
168936
169324
  async load(data, options = {}) {
169325
+ const limits = resolvePptxLoadLimits(options);
169326
+ assertPptxInputWithinLimits(data.byteLength, limits);
168937
169327
  const jsonText = decodePptxJsonText(data);
168938
169328
  if (jsonText !== null) {
168939
- return this.loadFromJson(jsonText, options);
169329
+ return this.importJson(jsonText, options, limits);
168940
169330
  }
168941
169331
  return super.load(data, options);
168942
169332
  }
@@ -168947,9 +169337,26 @@ var init_PptxHandler = __esm({
168947
169337
  * handler keeps a valid in-memory archive (editing and {@link save} keep
168948
169338
  * working), then the imported model is overlaid on top: imported
168949
169339
  * presentation fields win, and the slide array is replaced wholesale.
169340
+ *
169341
+ * `options.limits` applies as it does for {@link load}: `maxInputBytes` to
169342
+ * the UTF-8 size of `text` (checked before it is parsed), and `maxSlides`
169343
+ * and `maxShapes` to the document's slides with the same counting rule as
169344
+ * a `.pptx` package (layout and master elements are not counted).
168950
169345
  */
168951
169346
  async loadFromJson(text2, options = {}) {
168952
- const imported = deserializePptxFromJson(text2);
169347
+ const limits = resolvePptxLoadLimits(options);
169348
+ assertPptxTextWithinLimits(text2, limits);
169349
+ return this.importJson(text2, options, limits);
169350
+ }
169351
+ async importJson(text2, options, limits) {
169352
+ const document2 = parsePptxJson(text2);
169353
+ assertPptxSlideCountWithinLimits(document2.slides.length, limits);
169354
+ let shapes = 0;
169355
+ for (const slide of document2.slides) {
169356
+ const elements3 = Array.isArray(slide.elements) ? slide.elements : [];
169357
+ shapes = countPptxShapesWithinLimits(shapes, elements3, limits);
169358
+ }
169359
+ const imported = pptxDataFromJsonDocument(document2);
168953
169360
  const blankBytes = await buildBlankPresentationArchive({
168954
169361
  width: imported.widthEmu,
168955
169362
  height: imported.heightEmu,
@@ -168957,7 +169364,7 @@ var init_PptxHandler = __esm({
168957
169364
  // the overlaid model, so the archive must carry the value itself.
168958
169365
  firstSlideNumber: imported.firstSlideNumber
168959
169366
  });
168960
- const base = await super.load(blankBytes, options);
169367
+ const base = await super.load(blankBytes, { ...options, limits: void 0 });
168961
169368
  return applyImportedPptxData(base, imported);
168962
169369
  }
168963
169370
  };
@@ -171488,10 +171895,10 @@ function resolveNodeAtPath(nodes, path3) {
171488
171895
  }
171489
171896
  function validateShapeIndex(element, index) {
171490
171897
  ensureChartData2(element);
171491
- const count = element.chartData.userShapes?.length ?? 0;
171492
- if (index < 0 || index >= count) {
171898
+ const count2 = element.chartData.userShapes?.length ?? 0;
171899
+ if (index < 0 || index >= count2) {
171493
171900
  throw new RangeError(
171494
- `Overlay-shape index ${index} is out of range. Chart has ${count} overlay shape(s) (indices 0-${count - 1}).`
171901
+ `Overlay-shape index ${index} is out of range. Chart has ${count2} overlay shape(s) (indices 0-${count2 - 1}).`
171495
171902
  );
171496
171903
  }
171497
171904
  }
@@ -171631,13 +172038,13 @@ function masterIndexFromPath(masterPath) {
171631
172038
  return match ? parseInt(match[1], 10) : void 0;
171632
172039
  }
171633
172040
  function countExistingMasters(zip) {
171634
- let count = 0;
172041
+ let count2 = 0;
171635
172042
  zip.forEach((relativePath) => {
171636
172043
  if (/^ppt\/slideMasters\/slideMaster\d+\.xml$/.test(relativePath)) {
171637
- count++;
172044
+ count2++;
171638
172045
  }
171639
172046
  });
171640
- return count;
172047
+ return count2;
171641
172048
  }
171642
172049
  function escapeRegex2(value) {
171643
172050
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -187685,6 +188092,7 @@ exports.getOleNestedDeckDetail = getOleNestedDeckDetail;
187685
188092
  exports.getOleObjectTypeLabel = getOleObjectTypeLabel;
187686
188093
  exports.getOleSheetGrid = getOleSheetGrid;
187687
188094
  exports.getPanoseWeight = getPanoseWeight;
188095
+ exports.getPptxLoadLimitViolation = getPptxLoadLimitViolation;
187688
188096
  exports.getPresetConnectionSites = getPresetConnectionSites;
187689
188097
  exports.getPresetShapeClipPath = getPresetShapeClipPath;
187690
188098
  exports.getPresetTextRect = getPresetTextRect;