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
@@ -10496,7 +10496,7 @@ function ensureArrayLocal(value) {
10496
10496
  return Array.isArray(value) ? value : value === void 0 ? [] : [value];
10497
10497
  }
10498
10498
  function countsSignature(counts) {
10499
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
10499
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
10500
10500
  }
10501
10501
  function pathSignature(path4) {
10502
10502
  const counts = /* @__PURE__ */ new Map();
@@ -13722,9 +13722,9 @@ function decodeSlot(dir, id, majorVersion, warnings) {
13722
13722
  };
13723
13723
  }
13724
13724
  function readDirectory(dir, majorVersion, strict, warnings) {
13725
- const count = Math.floor(dir.length / DIR_ENTRY_SIZE);
13725
+ const count2 = Math.floor(dir.length / DIR_ENTRY_SIZE);
13726
13726
  const slots = [];
13727
- for (let id = 0; id < count; id++)
13727
+ for (let id = 0; id < count2; id++)
13728
13728
  slots.push(decodeSlot(dir, id, majorVersion, warnings));
13729
13729
  const roots = slots.filter((slot) => slot.type === ENTRY_TYPE_ROOT);
13730
13730
  if (roots.length !== 1 || !roots[0].nameValid)
@@ -14265,10 +14265,10 @@ function writeFatChain(fat, chain) {
14265
14265
  fat[chain.sectors[i2]] = i2 < chain.sectors.length - 1 ? chain.sectors[i2 + 1] : ENDOFCHAIN;
14266
14266
  }
14267
14267
  }
14268
- function writeFatRun(fat, firstSector, count) {
14269
- for (let i2 = 0; i2 < count; i2++) {
14268
+ function writeFatRun(fat, firstSector, count2) {
14269
+ for (let i2 = 0; i2 < count2; i2++) {
14270
14270
  const sector = firstSector + i2;
14271
- fat[sector] = i2 < count - 1 ? sector + 1 : ENDOFCHAIN;
14271
+ fat[sector] = i2 < count2 - 1 ? sector + 1 : ENDOFCHAIN;
14272
14272
  }
14273
14273
  }
14274
14274
  function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorSize) {
@@ -14695,7 +14695,7 @@ function resolveLimits(limits) {
14695
14695
  maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
14696
14696
  maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
14697
14697
  label: limits.label ?? "ZIP",
14698
- fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
14698
+ fail: (message, limit, kind, actual) => create2 ? create2(message, { limit, kind, actual }) : new ZipLimitError(message, { limit, kind, actual })
14699
14699
  };
14700
14700
  }
14701
14701
  async function inflateEntryGuarded(entry2, alreadyRead, limits) {
@@ -14749,7 +14749,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
14749
14749
  r.fail(
14750
14750
  `${r.label} part ${entry2.name} inflates past its declared size`,
14751
14751
  r.maxEntryBytes,
14752
- size > declared ? "declaredSize" : "maxEntryBytes"
14752
+ size > declared ? "declaredSize" : "maxEntryBytes",
14753
+ size
14753
14754
  )
14754
14755
  );
14755
14756
  if (alreadyRead + size > r.maxTotalBytes)
@@ -14757,7 +14758,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
14757
14758
  r.fail(
14758
14759
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
14759
14760
  r.maxTotalBytes,
14760
- "maxTotalBytes"
14761
+ "maxTotalBytes",
14762
+ alreadyRead + size
14761
14763
  )
14762
14764
  );
14763
14765
  queue.push(chunk2);
@@ -14804,7 +14806,8 @@ function guardZip(zip, limits = {}) {
14804
14806
  throw r.fail(
14805
14807
  `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
14806
14808
  r.maxEntries,
14807
- "maxEntries"
14809
+ "maxEntries",
14810
+ entries.length
14808
14811
  );
14809
14812
  let declared = 0;
14810
14813
  for (const entry2 of entries) {
@@ -14817,7 +14820,8 @@ function guardZip(zip, limits = {}) {
14817
14820
  throw r.fail(
14818
14821
  `${r.label} part ${entry2.name} exceeds the uncompressed part size limit`,
14819
14822
  r.maxEntryBytes,
14820
- "maxEntryBytes"
14823
+ "maxEntryBytes",
14824
+ size
14821
14825
  );
14822
14826
  declared += size;
14823
14827
  }
@@ -14825,7 +14829,8 @@ function guardZip(zip, limits = {}) {
14825
14829
  throw r.fail(
14826
14830
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
14827
14831
  r.maxTotalBytes,
14828
- "maxTotalBytes"
14832
+ "maxTotalBytes",
14833
+ declared
14829
14834
  );
14830
14835
  const produced = /* @__PURE__ */ new Map();
14831
14836
  let total = 0;
@@ -14864,7 +14869,8 @@ async function openZip(input, limits = {}) {
14864
14869
  throw r.fail(
14865
14870
  `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
14866
14871
  maxInput,
14867
- "maxInputBytes"
14872
+ "maxInputBytes",
14873
+ bytes.byteLength
14868
14874
  );
14869
14875
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
14870
14876
  }
@@ -14882,11 +14888,14 @@ var init_zip_limits = __esm({
14882
14888
  limit;
14883
14889
  /** The check that failed (absent when the error was built without one). */
14884
14890
  kind;
14891
+ /** The observed value, when known (a lower bound for a size found while inflating). */
14892
+ actual;
14885
14893
  constructor(message, details) {
14886
14894
  super(message);
14887
14895
  this.name = "ZipLimitError";
14888
14896
  this.limit = details.limit;
14889
14897
  this.kind = details.kind;
14898
+ this.actual = details.actual;
14890
14899
  }
14891
14900
  };
14892
14901
  mib = (bytes) => Math.round(bytes / 1048576);
@@ -14902,15 +14911,27 @@ var init_types2 = __esm({
14902
14911
  MAX_ZIP_ENTRY_COUNT = 65536;
14903
14912
  ZipBombError = class extends Error {
14904
14913
  code = "ZIP_BOMB";
14914
+ /** Inflated bytes declared or read when a size limit failed (a lower bound while streaming). */
14905
14915
  uncompressedBytes;
14916
+ /** The value of the limit that failed. */
14906
14917
  limit;
14918
+ /** Number of archive entries, when the entry-count limit failed. */
14907
14919
  entryCount;
14920
+ /**
14921
+ * The `PptxLoadLimits` field behind this error (`maxUncompressedBytes` or
14922
+ * `maxEntries`); `undefined` for a forged size or an unsafe part name.
14923
+ */
14924
+ loadLimit;
14925
+ /** The observed value for {@link loadLimit}, when known. */
14926
+ actual;
14908
14927
  constructor(message, details) {
14909
14928
  super(message);
14910
14929
  this.name = "ZipBombError";
14911
14930
  this.uncompressedBytes = details.uncompressedBytes;
14912
14931
  this.limit = details.limit;
14913
14932
  this.entryCount = details.entryCount;
14933
+ this.loadLimit = details.loadLimit;
14934
+ this.actual = details.actual;
14914
14935
  }
14915
14936
  };
14916
14937
  }
@@ -14992,21 +15013,21 @@ function parseChartFormulaRange(formula2) {
14992
15013
  }
14993
15014
  return { sheetName, start, end };
14994
15015
  }
14995
- function expandRangeAddresses(range, count) {
15016
+ function expandRangeAddresses(range, count2) {
14996
15017
  const { start, end } = range;
14997
- if (count <= 0) {
15018
+ if (count2 <= 0) {
14998
15019
  return void 0;
14999
15020
  }
15000
15021
  if (start.col === end.col && start.row === end.row) {
15001
- return count === 1 ? [formatCellAddress(start)] : void 0;
15022
+ return count2 === 1 ? [formatCellAddress(start)] : void 0;
15002
15023
  }
15003
15024
  if (start.col === end.col) {
15004
15025
  const length = end.row - start.row + 1;
15005
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
15026
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
15006
15027
  }
15007
15028
  if (start.row === end.row) {
15008
15029
  const length = end.col - start.col + 1;
15009
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
15030
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
15010
15031
  }
15011
15032
  return void 0;
15012
15033
  }
@@ -15801,9 +15822,9 @@ var init_deflate_encode = __esm({
15801
15822
  len = 0;
15802
15823
  acc = 0;
15803
15824
  nbits = 0;
15804
- bits(value, count) {
15825
+ bits(value, count2) {
15805
15826
  this.acc |= value << this.nbits;
15806
- this.nbits += count;
15827
+ this.nbits += count2;
15807
15828
  while (this.nbits >= 8) {
15808
15829
  this.push(this.acc & 255);
15809
15830
  this.acc >>>= 8;
@@ -15811,12 +15832,12 @@ var init_deflate_encode = __esm({
15811
15832
  }
15812
15833
  }
15813
15834
  /** Huffman codes are packed most-significant bit first. */
15814
- code(value, count) {
15835
+ code(value, count2) {
15815
15836
  let reversed = 0;
15816
- for (let i2 = 0; i2 < count; i2++) {
15837
+ for (let i2 = 0; i2 < count2; i2++) {
15817
15838
  reversed = reversed << 1 | value >>> i2 & 1;
15818
15839
  }
15819
- this.bits(reversed, count);
15840
+ this.bits(reversed, count2);
15820
15841
  }
15821
15842
  finish() {
15822
15843
  if (this.nbits > 0) {
@@ -19661,12 +19682,12 @@ function functionValue(condition, point2, lookup) {
19661
19682
  if (!target) {
19662
19683
  return void 0;
19663
19684
  }
19664
- const { pos: pos2, count } = siblingPosition(target, ptType);
19685
+ const { pos: pos2, count: count2 } = siblingPosition(target, ptType);
19665
19686
  if (condition.func === "pos") {
19666
19687
  return pos2;
19667
19688
  }
19668
19689
  if (condition.func === "revPos") {
19669
- return count - pos2 + 1;
19690
+ return count2 - pos2 + 1;
19670
19691
  }
19671
19692
  return condition.func === "posEven" ? pos2 % 2 === 0 ? 1 : 0 : pos2 % 2 === 1 ? 1 : 0;
19672
19693
  }
@@ -22752,19 +22773,19 @@ function pointTypeMatches(node, pointType2) {
22752
22773
  }
22753
22774
  return node.nodeType === pointType2;
22754
22775
  }
22755
- function selectRange(nodes, start, count) {
22756
- if (start === void 0 && count === void 0) {
22776
+ function selectRange(nodes, start, count2) {
22777
+ if (start === void 0 && count2 === void 0) {
22757
22778
  return nodes;
22758
22779
  }
22759
22780
  const zeroBasedStart = Math.max(0, (start ?? 1) - 1);
22760
- const take2 = count !== void 0 && count > 0 ? count : nodes.length - zeroBasedStart;
22781
+ const take2 = count2 !== void 0 && count2 > 0 ? count2 : nodes.length - zeroBasedStart;
22761
22782
  return nodes.slice(zeroBasedStart, zeroBasedStart + take2);
22762
22783
  }
22763
- function applyPointTypeAndRange(nodes, pointType2, start, count) {
22784
+ function applyPointTypeAndRange(nodes, pointType2, start, count2) {
22764
22785
  const filtered = pointType2 ? nodes.filter((n) => pointTypeMatches(n, pointType2)) : nodes;
22765
- return selectRange(filtered, start, count);
22786
+ return selectRange(filtered, start, count2);
22766
22787
  }
22767
- function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
22788
+ function resolveAxisNodes(nodes, axis, pointTypes, start, count2, context) {
22768
22789
  if (axis.length === 0) {
22769
22790
  return void 0;
22770
22791
  }
@@ -22794,21 +22815,21 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
22794
22815
  let current;
22795
22816
  let nextHop;
22796
22817
  if (axis[0] === "root" && axis.length > 1) {
22797
- current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
22818
+ current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count2?.[1]);
22798
22819
  nextHop = 2;
22799
22820
  } else if (axis[0] === "root") {
22800
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
22821
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
22801
22822
  nextHop = 1;
22802
22823
  } else if (context !== void 0) {
22803
22824
  current = applyPointTypeAndRange(
22804
22825
  navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
22805
22826
  pointTypes?.[0],
22806
22827
  start?.[0],
22807
- count?.[0]
22828
+ count2?.[0]
22808
22829
  );
22809
22830
  nextHop = 1;
22810
22831
  } else {
22811
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
22832
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
22812
22833
  nextHop = 1;
22813
22834
  }
22814
22835
  for (let hop = nextHop; hop < axis.length; hop += 1) {
@@ -22816,13 +22837,13 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
22816
22837
  navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
22817
22838
  pointTypes?.[hop],
22818
22839
  start?.[hop],
22819
- count?.[hop]
22840
+ count2?.[hop]
22820
22841
  );
22821
22842
  }
22822
22843
  return current;
22823
22844
  }
22824
- function resolveAxisCount(nodes, axis, pointTypes, start, count, context) {
22825
- return resolveAxisNodes(nodes, axis, pointTypes, start, count, context)?.length;
22845
+ function resolveAxisCount(nodes, axis, pointTypes, start, count2, context) {
22846
+ return resolveAxisNodes(nodes, axis, pointTypes, start, count2, context)?.length;
22826
22847
  }
22827
22848
  var init_smartart_layout_interpreter_axis_count = __esm({
22828
22849
  "diagram/layout/smartart-layout-interpreter-axis-count.ts"() {
@@ -22848,14 +22869,14 @@ function depthFromAnchor(node, anchorId, byId) {
22848
22869
  }
22849
22870
  return void 0;
22850
22871
  }
22851
- function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count, anchor) {
22872
+ function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count2, anchor) {
22852
22873
  if (anchor.length === 0) {
22853
22874
  return void 0;
22854
22875
  }
22855
22876
  const byId = new Map(nodes.map((n) => [n.id, n]));
22856
22877
  let max = 0;
22857
22878
  for (const anchorPoint of anchor) {
22858
- const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count, [anchorPoint]);
22879
+ const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count2, [anchorPoint]);
22859
22880
  if (resolved === void 0) {
22860
22881
  return void 0;
22861
22882
  }
@@ -23341,8 +23362,8 @@ function selectArrangedNodes(node, flat, roots) {
23341
23362
  const followSibCounts = collectFollowSibNodeCounts(node);
23342
23363
  if (followSibCounts.length > 0) {
23343
23364
  for (const i2 of [...indices]) {
23344
- for (const count of followSibCounts) {
23345
- for (let k = 1; k <= count; k++) {
23365
+ for (const count2 of followSibCounts) {
23366
+ for (let k = 1; k <= count2; k++) {
23346
23367
  const j = i2 + k;
23347
23368
  if (j < base.length) {
23348
23369
  indices.add(j);
@@ -24917,12 +24938,12 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path4) {
24917
24938
  const baseAngleRad = dist > 1e-6 ? Math.atan2(dy, dx) : 0;
24918
24939
  const halfExtent = Math.max(context.itemWidth, context.itemHeight) / 2;
24919
24940
  const radius = context.itemWidth / 2 + Math.max(0, context.gapPx) + halfExtent;
24920
- const count = children16.length;
24941
+ const count2 = children16.length;
24921
24942
  const spanRad = context.fanSpanDeg * DEG_TO_RAD2;
24922
24943
  const nodes = [];
24923
24944
  const connectors2 = [];
24924
24945
  children16.forEach((child31, i2) => {
24925
- const angle = count === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count - 1);
24946
+ const angle = count2 === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count2 - 1);
24926
24947
  const cx = parentCentre.x + Math.cos(angle) * radius;
24927
24948
  const cy = parentCentre.y + Math.sin(angle) * radius;
24928
24949
  const key2 = `${context.elementId}-cycle-ext-${path4}-${i2}`;
@@ -24935,7 +24956,7 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path4) {
24935
24956
  height: context.itemHeight,
24936
24957
  node: child31,
24937
24958
  index: i2,
24938
- total: count,
24959
+ total: count2,
24939
24960
  palette: context.palette,
24940
24961
  style: context.style,
24941
24962
  ctx: context.ctx,
@@ -26112,12 +26133,12 @@ var init_smartart_layout_interpreter_linear_content_size = __esm({
26112
26133
  });
26113
26134
 
26114
26135
  // diagram/layout/smartart-layout-interpreter-axis-range.ts
26115
- function positionRange(start, count, step, total) {
26136
+ function positionRange(start, count2, step, total) {
26116
26137
  const out = [];
26117
26138
  const s = step > 0 ? step : 1;
26118
26139
  for (let i2 = Math.max(0, start - 1); i2 < total; i2 += s) {
26119
26140
  out.push(i2 + 1);
26120
- if (count !== void 0 && count > 0 && out.length >= count) {
26141
+ if (count2 !== void 0 && count2 > 0 && out.length >= count2) {
26121
26142
  break;
26122
26143
  }
26123
26144
  }
@@ -26137,8 +26158,8 @@ function compoundChildIds(role, node, childrenOf) {
26137
26158
  }
26138
26159
  const children16 = childrenOf.get(node.id) ?? [];
26139
26160
  const start = role.presentationOf?.start?.[chIndex] ?? 1;
26140
- const count = role.presentationOf?.count?.[chIndex];
26141
- const positions = positionRange(start, count, 1, children16.length);
26161
+ const count2 = role.presentationOf?.count?.[chIndex];
26162
+ const positions = positionRange(start, count2, 1, children16.length);
26142
26163
  const ids = [];
26143
26164
  for (const position3 of positions) {
26144
26165
  const child31 = children16[position3 - 1];
@@ -26712,9 +26733,9 @@ function arrangeSnake2(plan, nodes, box, palette, style, elementId, index = EMPT
26712
26733
  let y = INSET + row * (cellH + gapY);
26713
26734
  if (centerIncompleteLines) {
26714
26735
  const key2 = flowDir === "row" ? row : col;
26715
- const count = lineCounts.get(key2) ?? fullLineCount;
26716
- if (count < fullLineCount) {
26717
- const shift = (fullLineCount - count) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
26736
+ const count2 = lineCounts.get(key2) ?? fullLineCount;
26737
+ if (count2 < fullLineCount) {
26738
+ const shift = (fullLineCount - count2) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
26718
26739
  if (flowDir === "row") {
26719
26740
  x += shift;
26720
26741
  } else {
@@ -27628,26 +27649,26 @@ var init_smartart_layout_interpreter_composite_foreach = __esm({
27628
27649
  });
27629
27650
 
27630
27651
  // diagram/hierarchy/smartart-hierarchy-pitch.ts
27631
- function computeAxisPitch(dimension, margin, itemSize, count, fixedGapRatio) {
27632
- const n = Math.max(1, count);
27652
+ function computeAxisPitch(dimension, margin, itemSize, count2, fixedGapRatio) {
27653
+ const n = Math.max(1, count2);
27633
27654
  const gap = n <= 1 ? 0 : fixedGapRatio !== void 0 ? itemSize * Math.max(0, fixedGapRatio) : Math.max(0, (dimension - margin - n * itemSize) / (n - 1));
27634
27655
  const pitch = itemSize + gap;
27635
27656
  const centeredShift = (dimension - n * pitch + margin) / 2;
27636
27657
  const maxShift = dimension - n * itemSize - gap * (n - 0.5);
27637
27658
  return { pitch, shift: Math.min(centeredShift, maxShift) };
27638
27659
  }
27639
- function centeredAxisPitch(dimension, itemSize, gapRatio, count) {
27640
- const n = Math.max(1, count);
27660
+ function centeredAxisPitch(dimension, itemSize, gapRatio, count2) {
27661
+ const n = Math.max(1, count2);
27641
27662
  const gap = n > 1 ? itemSize * Math.max(0, gapRatio) : 0;
27642
27663
  const pitch = itemSize + gap;
27643
27664
  const span = n * itemSize + Math.max(0, n - 1) * gap;
27644
27665
  const shift = (dimension - span) / 2;
27645
27666
  return { pitch, shift };
27646
27667
  }
27647
- function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count) {
27668
+ function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count2) {
27648
27669
  const compositeW = compositeWidthFactor ? boxW / compositeWidthFactor : boxW;
27649
27670
  const cardOffsetX = cardOffsetXRatio * compositeW;
27650
- const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count);
27671
+ const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count2);
27651
27672
  const correction = cardOffsetX + boxW / 2 - centred.pitch / 2;
27652
27673
  return { pitch: centred.pitch, shift: centred.shift + correction };
27653
27674
  }
@@ -27748,16 +27769,16 @@ function childAxisSpec(template, childCount) {
27748
27769
  const ownIndex = axis.indexOf("ch");
27749
27770
  if (ownIndex >= 0) {
27750
27771
  const start = template.presentationOf?.start?.[ownIndex] ?? 1;
27751
- const count = template.presentationOf?.count?.[ownIndex];
27752
- return { positions: positionRange(start, count, 1, childCount), fold };
27772
+ const count2 = template.presentationOf?.count?.[ownIndex];
27773
+ return { positions: positionRange(start, count2, 1, childCount), fold };
27753
27774
  }
27754
27775
  const origin = template.forEachOrigin;
27755
27776
  const originIndex = origin?.axis?.indexOf("ch") ?? -1;
27756
27777
  if (origin && originIndex >= 0) {
27757
27778
  const start = origin.start?.[originIndex] ?? 1;
27758
- const count = origin.count?.[originIndex];
27779
+ const count2 = origin.count?.[originIndex];
27759
27780
  const step = origin.step?.[originIndex] ?? 1;
27760
- return { positions: positionRange(start, count, step, childCount), fold };
27781
+ return { positions: positionRange(start, count2, step, childCount), fold };
27761
27782
  }
27762
27783
  return void 0;
27763
27784
  }
@@ -27953,8 +27974,8 @@ function slotRect(slot, box, absX, absY) {
27953
27974
  }
27954
27975
  function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
27955
27976
  const perPoint = representativeSlotsPerPoint(slotted, nodes.length);
27956
- const count = Math.min(perPoint.length, nodes.length);
27957
- const slots = perPoint.slice(0, count).map((entry2) => slotRect(entry2, box, absX, absY));
27977
+ const count2 = Math.min(perPoint.length, nodes.length);
27978
+ const slots = perPoint.slice(0, count2).map((entry2) => slotRect(entry2, box, absX, absY));
27958
27979
  const fontFit = fontCtx ? resolveSharedFontFit(
27959
27980
  fontCtx,
27960
27981
  perPoint[0]?.node,
@@ -27966,7 +27987,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
27966
27987
  }))
27967
27988
  ) : void 0;
27968
27989
  const rendered = [];
27969
- for (let i2 = 0; i2 < count; i2++) {
27990
+ for (let i2 = 0; i2 < count2; i2++) {
27970
27991
  const slot = slots[i2];
27971
27992
  rendered.push(
27972
27993
  presetBoxNode({
@@ -27977,7 +27998,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
27977
27998
  height: slot.height,
27978
27999
  node: nodes[i2],
27979
28000
  index: i2,
27980
- total: count,
28001
+ total: count2,
27981
28002
  palette: ctx.palette,
27982
28003
  style: ctx.style,
27983
28004
  fontSizeOverride: fontFit?.rootSizePx,
@@ -28022,9 +28043,9 @@ var init_smartart_layout_interpreter_composite_ring = __esm({
28022
28043
  });
28023
28044
 
28024
28045
  // diagram/layout/smartart-layout-interpreter-composite-pairs.ts
28025
- function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count) {
28046
+ function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count2) {
28026
28047
  const pairs = [];
28027
- for (let i2 = 0; i2 < count; i2++) {
28048
+ for (let i2 = 0; i2 < count2; i2++) {
28028
28049
  const node = nodes[i2];
28029
28050
  const selfRect = resolveSlot(selfSlots[i2].dims, box, absX, absY);
28030
28051
  const desSlotted = desSlots[i2];
@@ -28117,7 +28138,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
28117
28138
  }
28118
28139
  const desSlots = slotsWithAxis(slotted, "des");
28119
28140
  const childRepeaterSlots = slotted.filter((slot) => !slot.node.presentationOf);
28120
- const count = Math.min(selfSlots.length, nodes.length);
28141
+ const count2 = Math.min(selfSlots.length, nodes.length);
28121
28142
  const pairs = collectSelfDesPairs(
28122
28143
  selfSlots,
28123
28144
  desSlots,
@@ -28127,14 +28148,14 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
28127
28148
  absX,
28128
28149
  absY,
28129
28150
  childrenOf,
28130
- count
28151
+ count2
28131
28152
  );
28132
28153
  const fontFit = resolveFontFitFromPairs(fontCtx, selfSlots[0]?.node, pairs);
28133
28154
  const rendered = [];
28134
- for (let i2 = 0; i2 < count; i2++) {
28155
+ for (let i2 = 0; i2 < count2; i2++) {
28135
28156
  const { node, selfRect, selfLayoutNode, desSlot } = pairs[i2];
28136
28157
  rendered.push(
28137
- ...renderAnchoredPair(node, i2, count, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
28158
+ ...renderAnchoredPair(node, i2, count2, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
28138
28159
  );
28139
28160
  for (const wrapperSlot of childRepeaterSlots) {
28140
28161
  rendered.push(
@@ -28167,7 +28188,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
28167
28188
  absY,
28168
28189
  childrenOf,
28169
28190
  ctx,
28170
- count
28191
+ count2
28171
28192
  )
28172
28193
  );
28173
28194
  return rendered;
@@ -28884,11 +28905,11 @@ var init_smartart_hierarchy_orgchart_tree = __esm({
28884
28905
  // diagram/hierarchy/smartart-hierarchy-hang-depth.ts
28885
28906
  function countDescendants(t, orgChart) {
28886
28907
  const { normal } = partitionChildren(t, orgChart);
28887
- let count = normal.length;
28908
+ let count2 = normal.length;
28888
28909
  for (const child31 of normal) {
28889
- count += countDescendants(child31, orgChart);
28910
+ count2 += countDescendants(child31, orgChart);
28890
28911
  }
28891
- return count;
28912
+ return count2;
28892
28913
  }
28893
28914
  function fanContinues(t, perRow, orgChart, siblingCount, normalCount) {
28894
28915
  const chPrefFanEligible = Number.isFinite(perRow) && siblingCount === perRow && normalCount >= perRow;
@@ -29025,7 +29046,7 @@ var init_smartart_hierarchy_fan_aware_width = __esm({
29025
29046
  });
29026
29047
 
29027
29048
  // diagram/hierarchy/smartart-hierarchy-fold-depth.ts
29028
- function endsInUnboundedDescendantHop(axis, count) {
29049
+ function endsInUnboundedDescendantHop(axis, count2) {
29029
29050
  if (!axis || axis.length === 0) {
29030
29051
  return false;
29031
29052
  }
@@ -29034,7 +29055,7 @@ function endsInUnboundedDescendantHop(axis, count) {
29034
29055
  if (lastAxis !== "des" && lastAxis !== "desOrSelf") {
29035
29056
  return false;
29036
29057
  }
29037
- const lastCount = count?.[lastIndex];
29058
+ const lastCount = count2?.[lastIndex];
29038
29059
  return lastCount === void 0 || lastCount === 0;
29039
29060
  }
29040
29061
  function hierarchyLeafFoldsDescendants(node) {
@@ -29366,17 +29387,17 @@ var init_smartart_hierarchy_hanging_box = __esm({
29366
29387
  // diagram/hierarchy/smartart-hierarchy-hanging-fold.ts
29367
29388
  function countRows(t, level2, orgChart, fold) {
29368
29389
  const { assistants, normal } = partitionChildren(t, orgChart);
29369
- let count = 1 + assistants.length;
29390
+ let count2 = 1 + assistants.length;
29370
29391
  if (normal.length === 0) {
29371
- return count;
29392
+ return count2;
29372
29393
  }
29373
29394
  if (fold && level2 >= 1) {
29374
- return count;
29395
+ return count2;
29375
29396
  }
29376
29397
  for (const child31 of normal) {
29377
- count += countRows(child31, level2 + 1, orgChart, fold);
29398
+ count2 += countRows(child31, level2 + 1, orgChart, fold);
29378
29399
  }
29379
- return count;
29400
+ return count2;
29380
29401
  }
29381
29402
  function countHangingRows(roots, orgChart, fold) {
29382
29403
  return roots.reduce((sum, root) => sum + countRows(root, 0, orgChart, fold), 0);
@@ -34079,8 +34100,8 @@ function readPairs(element, vt) {
34079
34100
  const out = [];
34080
34101
  for (let i2 = 0; i2 + 1 < variants.length; i2 += 2) {
34081
34102
  const name = variants[i2]?.textContent ?? "";
34082
- const count = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
34083
- out.push({ name, count: Number.isFinite(count) ? count : 0 });
34103
+ const count2 = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
34104
+ out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
34084
34105
  }
34085
34106
  return out;
34086
34107
  }
@@ -34297,9 +34318,9 @@ var init_custom = __esm({
34297
34318
  function titleGroups(headingPairs, titlesOfParts) {
34298
34319
  let offset = 0;
34299
34320
  return headingPairs.map((pair) => {
34300
- const count = Math.max(0, pair.count);
34301
- const titles = titlesOfParts.slice(offset, offset + count);
34302
- offset += count;
34321
+ const count2 = Math.max(0, pair.count);
34322
+ const titles = titlesOfParts.slice(offset, offset + count2);
34323
+ offset += count2;
34303
34324
  return { name: pair.name, titles };
34304
34325
  });
34305
34326
  }
@@ -52925,9 +52946,6 @@ function pptxDataFromJsonDocument(document2) {
52925
52946
  data.slides = document2.slides.map((slide) => deserializeSlide(slide));
52926
52947
  return data;
52927
52948
  }
52928
- function deserializePptxFromJson(text2) {
52929
- return pptxDataFromJsonDocument(parsePptxJson(text2));
52930
- }
52931
52949
  function deserializeSlide(encoded) {
52932
52950
  const slide = {};
52933
52951
  for (const key2 of Object.keys(SLIDE_FIELD_KIND)) {
@@ -54938,6 +54956,188 @@ var init_PresentationBuilder = __esm({
54938
54956
  }
54939
54957
  });
54940
54958
 
54959
+ // pptx/core/core/load-limits.ts
54960
+ function resolvePptxLoadLimits(options = {}) {
54961
+ const resolved = { ...DEFAULT_PPTX_LOAD_LIMITS };
54962
+ const legacy = options.maxUncompressedBytes;
54963
+ if (typeof legacy === "number" && legacy > 0) {
54964
+ resolved.maxUncompressedBytes = legacy;
54965
+ }
54966
+ const limits = options.limits;
54967
+ if (limits === void 0 || limits === null) {
54968
+ return resolved;
54969
+ }
54970
+ for (const name of LIMIT_NAMES) {
54971
+ const value = limits[name];
54972
+ if (value === void 0) {
54973
+ continue;
54974
+ }
54975
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
54976
+ throw new RangeError(`limits.${name} must be a positive finite number`);
54977
+ }
54978
+ if (name === "maxEntries" && value > MAX_ZIP_ENTRY_COUNT) {
54979
+ throw new RangeError(`limits.maxEntries must not exceed ${MAX_ZIP_ENTRY_COUNT}`);
54980
+ }
54981
+ resolved[name] = value;
54982
+ }
54983
+ return resolved;
54984
+ }
54985
+ function createPptxZipBombError(message, details) {
54986
+ const { limit, kind, actual } = details;
54987
+ if (kind === "maxEntries") {
54988
+ return new ZipBombError(message, {
54989
+ limit,
54990
+ loadLimit: "maxEntries",
54991
+ ...actual === void 0 ? {} : { entryCount: actual, actual }
54992
+ });
54993
+ }
54994
+ if (kind === "maxEntryBytes" || kind === "maxTotalBytes") {
54995
+ return new ZipBombError(message, {
54996
+ limit,
54997
+ loadLimit: "maxUncompressedBytes",
54998
+ ...actual === void 0 ? {} : { uncompressedBytes: actual, actual }
54999
+ });
55000
+ }
55001
+ return new ZipBombError(message, { limit });
55002
+ }
55003
+ function assertPptxInputWithinLimits(byteLength, limits) {
55004
+ if (byteLength > limits.maxInputBytes) {
55005
+ throw new PptxLoadLimitError(
55006
+ `PPTX input is ${count(byteLength)} bytes, more than the maxInputBytes limit of ${count(limits.maxInputBytes)}`,
55007
+ "maxInputBytes",
55008
+ limits.maxInputBytes,
55009
+ byteLength
55010
+ );
55011
+ }
55012
+ }
55013
+ function assertPptxTextWithinLimits(text2, limits) {
55014
+ const maximum = limits.maxInputBytes;
55015
+ if (text2.length * 3 <= maximum) {
55016
+ return;
55017
+ }
55018
+ const bytes = text2.length > maximum ? text2.length : utf8ByteLengthPast(text2, maximum);
55019
+ if (bytes > maximum) {
55020
+ throw new PptxLoadLimitError(
55021
+ `PPTX input is at least ${count(bytes)} bytes, more than the maxInputBytes limit of ${count(maximum)}`,
55022
+ "maxInputBytes",
55023
+ maximum,
55024
+ bytes
55025
+ );
55026
+ }
55027
+ }
55028
+ function utf8ByteLengthPast(text2, maximum) {
55029
+ let bytes = 0;
55030
+ for (let index = 0; index < text2.length && bytes <= maximum; index++) {
55031
+ const unit = text2.charCodeAt(index);
55032
+ if (unit < 128) {
55033
+ bytes += 1;
55034
+ } else if (unit < 2048) {
55035
+ bytes += 2;
55036
+ } else if (unit >= 55296 && unit <= 56319 && isLowSurrogate(text2.charCodeAt(index + 1))) {
55037
+ bytes += 4;
55038
+ index++;
55039
+ } else {
55040
+ bytes += 3;
55041
+ }
55042
+ }
55043
+ return bytes;
55044
+ }
55045
+ function isLowSurrogate(unit) {
55046
+ return unit >= 56320 && unit <= 57343;
55047
+ }
55048
+ function assertPptxSlideCountWithinLimits(slideCount, limits) {
55049
+ if (slideCount > limits.maxSlides) {
55050
+ throw new PptxLoadLimitError(
55051
+ `PPTX presentation has ${count(slideCount)} slides, more than the maxSlides limit of ${count(limits.maxSlides)}`,
55052
+ "maxSlides",
55053
+ limits.maxSlides,
55054
+ slideCount
55055
+ );
55056
+ }
55057
+ }
55058
+ function countPptxShapesWithinLimits(counted, elements2, limits) {
55059
+ const maximum = limits.maxShapes;
55060
+ if (maximum === Number.POSITIVE_INFINITY) {
55061
+ return counted;
55062
+ }
55063
+ const total = counted + countAuthoredElements(elements2);
55064
+ if (total > maximum) {
55065
+ throw new PptxLoadLimitError(
55066
+ `PPTX presentation has at least ${count(total)} shapes, more than the maxShapes limit of ${count(maximum)}`,
55067
+ "maxShapes",
55068
+ maximum,
55069
+ total
55070
+ );
55071
+ }
55072
+ return total;
55073
+ }
55074
+ function countAuthoredElements(elements2) {
55075
+ let total = 0;
55076
+ const lists = [elements2];
55077
+ const positions = [0];
55078
+ while (lists.length > 0) {
55079
+ const top = lists.length - 1;
55080
+ const list3 = lists[top];
55081
+ const position3 = positions[top];
55082
+ if (position3 >= list3.length) {
55083
+ lists.pop();
55084
+ positions.pop();
55085
+ continue;
55086
+ }
55087
+ positions[top] = position3 + 1;
55088
+ const element = list3[position3];
55089
+ if (typeof element !== "object" || element === null) {
55090
+ continue;
55091
+ }
55092
+ const { id, type, children: children16 } = element;
55093
+ if (typeof id === "string" && isTemplateElementId(id)) {
55094
+ continue;
55095
+ }
55096
+ total++;
55097
+ if (type === "group" && Array.isArray(children16) && children16.length > 0) {
55098
+ lists.push(children16);
55099
+ positions.push(0);
55100
+ }
55101
+ }
55102
+ return total;
55103
+ }
55104
+ var DEFAULT_PPTX_LOAD_LIMITS, LIMIT_NAMES, PptxLoadLimitError, count;
55105
+ var init_load_limits = __esm({
55106
+ "pptx/core/core/load-limits.ts"() {
55107
+ init_group_ops();
55108
+ init_types2();
55109
+ DEFAULT_PPTX_LOAD_LIMITS = Object.freeze({
55110
+ maxInputBytes: Number.POSITIVE_INFINITY,
55111
+ maxUncompressedBytes: DEFAULT_MAX_UNCOMPRESSED_BYTES,
55112
+ maxEntries: MAX_ZIP_ENTRY_COUNT,
55113
+ maxSlides: Number.POSITIVE_INFINITY,
55114
+ maxShapes: Number.POSITIVE_INFINITY
55115
+ });
55116
+ LIMIT_NAMES = Object.keys(DEFAULT_PPTX_LOAD_LIMITS);
55117
+ PptxLoadLimitError = class extends Error {
55118
+ code = "PPTX_LOAD_LIMIT";
55119
+ /** The limit that was exceeded. */
55120
+ limit;
55121
+ /** The value of that limit. */
55122
+ maximum;
55123
+ /**
55124
+ * The observed value: exact for `maxSlides` and for `maxInputBytes` on
55125
+ * `load()`; for `maxShapes`, and for `maxInputBytes` on `loadFromJson()`
55126
+ * (which stops counting once past the limit), a lower bound.
55127
+ */
55128
+ actual;
55129
+ constructor(message, limit, maximum, actual) {
55130
+ super(message);
55131
+ this.name = "PptxLoadLimitError";
55132
+ this.limit = limit;
55133
+ this.maximum = maximum;
55134
+ this.actual = actual;
55135
+ }
55136
+ };
55137
+ count = (value) => value.toLocaleString("en-US");
55138
+ }
55139
+ });
55140
+
54941
55141
  // pptx/core/builders/factories/ConnectorXmlFactory.ts
54942
55142
  var ConnectorXmlFactory;
54943
55143
  var init_ConnectorXmlFactory = __esm({
@@ -61352,7 +61552,7 @@ function parsedParagraphSignature(paragraph2) {
61352
61552
  return signatureOf(counts);
61353
61553
  }
61354
61554
  function signatureOf(counts) {
61355
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
61555
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
61356
61556
  }
61357
61557
  function collectParsedParagraphs2(root) {
61358
61558
  const result = [];
@@ -64699,23 +64899,23 @@ function classify(chars, index) {
64699
64899
  }
64700
64900
  function countParagraphWords(text2) {
64701
64901
  const chars = Array.from(text2);
64702
- let count = 0;
64902
+ let count2 = 0;
64703
64903
  let previous = "none";
64704
64904
  for (let index = 0; index < chars.length; index++) {
64705
64905
  const kind = classify(chars, index);
64706
64906
  if (kind === "space") {
64707
64907
  if (previous === "none" || previous === "control") {
64708
- count++;
64908
+ count2++;
64709
64909
  }
64710
64910
  previous = "space";
64711
64911
  continue;
64712
64912
  }
64713
64913
  if (kind === "ideograph" || kind === "control" || kind !== previous) {
64714
- count++;
64914
+ count2++;
64715
64915
  }
64716
64916
  previous = kind;
64717
64917
  }
64718
- return count;
64918
+ return count2;
64719
64919
  }
64720
64920
  var LINE_BREAK_CHAR, WORD_CHAR, DIGIT_CHAR, IDEOGRAPH_CHAR, SPACE_CHAR, WORD_JOINERS, NUMBER_JOINERS;
64721
64921
  var init_app_properties_word_count = __esm({
@@ -67616,10 +67816,10 @@ function assertAfterAnimationClearSupported(effectCTn) {
67616
67816
  if (!isXmlObject5(sub)) return;
67617
67817
  const countAfterFlags = (value) => {
67618
67818
  if (Array.isArray(value))
67619
- return value.reduce((count, child31) => count + countAfterFlags(child31), 0);
67819
+ return value.reduce((count2, child31) => count2 + countAfterFlags(child31), 0);
67620
67820
  if (!isXmlObject5(value)) return 0;
67621
67821
  return Object.entries(value).reduce(
67622
- (count, [key2, child31]) => count + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child31)) ? 1 : countAfterFlags(child31)),
67822
+ (count2, [key2, child31]) => count2 + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child31)) ? 1 : countAfterFlags(child31)),
67623
67823
  0
67624
67824
  );
67625
67825
  };
@@ -89463,8 +89663,8 @@ function reorderContainer(node, rawInner) {
89463
89663
  if (isGroupedByTag(children16.map((child31) => child31.tag))) {
89464
89664
  return;
89465
89665
  }
89466
- for (const [tag, count] of occurrence) {
89467
- if (ensureItems(node[tag]).length !== count) {
89666
+ for (const [tag, count2] of occurrence) {
89667
+ if (ensureItems(node[tag]).length !== count2) {
89468
89668
  return;
89469
89669
  }
89470
89670
  }
@@ -89486,8 +89686,8 @@ function annotateOmmlSiblingOrder(xml, parsed) {
89486
89686
  return;
89487
89687
  }
89488
89688
  const nodes = collectParsedOmathNodes(parsed);
89489
- const count = Math.min(fragments.length, nodes.length);
89490
- for (let index = 0; index < count; index++) {
89689
+ const count2 = Math.min(fragments.length, nodes.length);
89690
+ for (let index = 0; index < count2; index++) {
89491
89691
  if (fragments[index]) {
89492
89692
  reorderContainer(nodes[index], fragments[index]);
89493
89693
  }
@@ -90627,6 +90827,180 @@ var init_eot_parser = __esm({
90627
90827
  }
90628
90828
  });
90629
90829
 
90830
+ // pptx/core/utils/deferred-embedded-font.ts
90831
+ function resolveEmbeddedFontGuid(source) {
90832
+ if (isEotFormat(source.originalPartBytes)) {
90833
+ return void 0;
90834
+ }
90835
+ const { fontKey } = source;
90836
+ const fromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
90837
+ return fromKey || extractGuidFromPartName(source.partPath) || void 0;
90838
+ }
90839
+ function hasSfntSignature(bytes) {
90840
+ if (bytes.length < 4) {
90841
+ return false;
90842
+ }
90843
+ const [v0, v1, v2, v3] = bytes;
90844
+ 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);
90845
+ }
90846
+ function warnInvalidSignature(name, bytes) {
90847
+ const hex3 = Array.from(bytes.subarray(0, 4), (b) => b.toString(16)).join(",");
90848
+ console.warn(
90849
+ `[pptx-viewer] Embedded font "${name}" has invalid sfnt header [${hex3}] after processing; skipping (web font fallback will be used)`
90850
+ );
90851
+ }
90852
+ function isEmbeddedFontPartPlausible(source) {
90853
+ const bytes = source.originalPartBytes;
90854
+ if (bytes.length === 0) {
90855
+ return false;
90856
+ }
90857
+ if (isEotFormat(bytes)) {
90858
+ return true;
90859
+ }
90860
+ const guid = resolveEmbeddedFontGuid(source);
90861
+ if (!guid) {
90862
+ console.warn(
90863
+ `[pptx-viewer] Embedded font "${source.name}" at "${source.partPath}" has no fontKey attribute and no GUID in filename; skipping`
90864
+ );
90865
+ return false;
90866
+ }
90867
+ const header = deobfuscateFont(bytes.subarray(0, Math.min(bytes.length, 32)), guid);
90868
+ if (header.length < 4) {
90869
+ return false;
90870
+ }
90871
+ if (!hasSfntSignature(header)) {
90872
+ warnInvalidSignature(source.name, header);
90873
+ return false;
90874
+ }
90875
+ return true;
90876
+ }
90877
+ function uint8ArrayToBase64(bytes) {
90878
+ let binary = "";
90879
+ const chunkSize = 8192;
90880
+ for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
90881
+ const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
90882
+ for (let j = 0; j < chunk2.length; j++) {
90883
+ binary += String.fromCharCode(chunk2[j]);
90884
+ }
90885
+ }
90886
+ return btoa(binary);
90887
+ }
90888
+ function decodeEmbeddedFontPart(source) {
90889
+ const { name, partPath, originalPartBytes } = source;
90890
+ try {
90891
+ let fontData;
90892
+ const fontGuid = resolveEmbeddedFontGuid(source);
90893
+ if (isEotFormat(originalPartBytes)) {
90894
+ const extracted = extractFontFromEot(originalPartBytes);
90895
+ if (!extracted) {
90896
+ const header = parseEotHeader(originalPartBytes);
90897
+ console.info(
90898
+ `[pptx-viewer] Embedded font "${name}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""}; extraction failed, will use web font fallback`
90899
+ );
90900
+ return null;
90901
+ }
90902
+ fontData = extracted.fontData;
90903
+ } else if (fontGuid) {
90904
+ fontData = deobfuscateFont(originalPartBytes, fontGuid);
90905
+ } else {
90906
+ console.warn(
90907
+ `[pptx-viewer] Embedded font "${name}" at "${partPath}" has no fontKey attribute and no GUID in filename; skipping`
90908
+ );
90909
+ return null;
90910
+ }
90911
+ if (fontData.length < 4) {
90912
+ return null;
90913
+ }
90914
+ if (!hasSfntSignature(fontData)) {
90915
+ warnInvalidSignature(name, fontData);
90916
+ return null;
90917
+ }
90918
+ const format = detectFontFormat(fontData);
90919
+ const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
90920
+ return {
90921
+ name,
90922
+ dataUrl: `data:${mimeType};base64,${uint8ArrayToBase64(fontData)}`,
90923
+ bold: source.bold,
90924
+ italic: source.italic,
90925
+ format,
90926
+ rawFontData: fontData,
90927
+ partPath,
90928
+ fontGuid,
90929
+ originalRId: source.originalRId,
90930
+ originalPartBytes
90931
+ };
90932
+ } catch {
90933
+ return null;
90934
+ }
90935
+ }
90936
+ function createDeferredEmbeddedFont(source) {
90937
+ const fontGuid = resolveEmbeddedFontGuid(source);
90938
+ let fields;
90939
+ let pending;
90940
+ const decode = () => {
90941
+ if (!fields) {
90942
+ const decoded = decodeEmbeddedFontPart(source);
90943
+ fields = {
90944
+ dataUrl: decoded?.dataUrl ?? "",
90945
+ format: decoded?.format,
90946
+ rawFontData: decoded?.rawFontData
90947
+ };
90948
+ }
90949
+ return fields;
90950
+ };
90951
+ const font = {
90952
+ name: source.name,
90953
+ get dataUrl() {
90954
+ return decode().dataUrl;
90955
+ },
90956
+ set dataUrl(value) {
90957
+ decode().dataUrl = value;
90958
+ },
90959
+ bold: source.bold,
90960
+ italic: source.italic,
90961
+ get format() {
90962
+ return decode().format;
90963
+ },
90964
+ set format(value) {
90965
+ decode().format = value;
90966
+ },
90967
+ get rawFontData() {
90968
+ return decode().rawFontData;
90969
+ },
90970
+ set rawFontData(value) {
90971
+ decode().rawFontData = value;
90972
+ },
90973
+ partPath: source.partPath,
90974
+ fontGuid,
90975
+ originalRId: source.originalRId,
90976
+ originalPartBytes: source.originalPartBytes
90977
+ };
90978
+ Object.defineProperties(font, {
90979
+ load: {
90980
+ value: () => pending ??= Promise.resolve().then(
90981
+ () => decode().rawFontData?.length || decode().dataUrl ? font : null
90982
+ )
90983
+ },
90984
+ isLoaded: { get: () => fields !== void 0 }
90985
+ });
90986
+ return font;
90987
+ }
90988
+ function shouldSaveEmbeddedFontVerbatim(font) {
90989
+ if (font.isLoaded === void 0 || !font.originalPartBytes?.length) {
90990
+ return false;
90991
+ }
90992
+ if (!font.originalRId || !font.partPath) {
90993
+ return false;
90994
+ }
90995
+ return font.isLoaded === false || !font.rawFontData?.length;
90996
+ }
90997
+ var init_deferred_embedded_font = __esm({
90998
+ "pptx/core/utils/deferred-embedded-font.ts"() {
90999
+ init_eot_parser();
91000
+ init_font_deobfuscation();
91001
+ }
91002
+ });
91003
+
90630
91004
  // pptx/core/core/runtime/header-footer-parts.ts
90631
91005
  function asArray3(value) {
90632
91006
  if (Array.isArray(value)) {
@@ -92669,10 +93043,10 @@ function collectFilteredSeriesIndices(container2, xmlLookup) {
92669
93043
  }
92670
93044
  return reserved;
92671
93045
  }
92672
- function assignSeriesIndices(count, reservedIndices) {
93046
+ function assignSeriesIndices(count2, reservedIndices) {
92673
93047
  const assigned = [];
92674
93048
  let cursor = 0;
92675
- for (let i2 = 0; i2 < count; i2++) {
93049
+ for (let i2 = 0; i2 < count2; i2++) {
92676
93050
  while (reservedIndices.has(cursor)) {
92677
93051
  cursor++;
92678
93052
  }
@@ -93361,8 +93735,8 @@ function parseCache(node) {
93361
93735
  return point2;
93362
93736
  })
93363
93737
  };
93364
- const count = Number(cVal(node, "ptCount") ?? Number.NaN);
93365
- if (Number.isInteger(count) && count >= 0) cache.pointCount = count;
93738
+ const count2 = Number(cVal(node, "ptCount") ?? Number.NaN);
93739
+ if (Number.isInteger(count2) && count2 >= 0) cache.pointCount = count2;
93366
93740
  const formatCode2 = cChild(node, "formatCode")?.textContent;
93367
93741
  if (formatCode2) cache.formatCode = formatCode2;
93368
93742
  return cache;
@@ -93380,8 +93754,8 @@ function parseDataSource(element) {
93380
93754
  const levels = cChild(ref, "multiLvlStrCache");
93381
93755
  if (levels) {
93382
93756
  source.levels = children2(levels, "lvl", NS.c).map(parseCache);
93383
- const count = Number(cVal(levels, "ptCount") ?? Number.NaN);
93384
- if (Number.isInteger(count) && count >= 0) source.levelPointCount = count;
93757
+ const count2 = Number(cVal(levels, "ptCount") ?? Number.NaN);
93758
+ if (Number.isInteger(count2) && count2 >= 0) source.levelPointCount = count2;
93385
93759
  }
93386
93760
  return source;
93387
93761
  }
@@ -103035,9 +103409,9 @@ function buildFopt(simple, complex = []) {
103035
103409
  payload.bytes(bytes);
103036
103410
  }
103037
103411
  }
103038
- const count = simple.length + complex.length;
103412
+ const count2 = simple.length + complex.length;
103039
103413
  const data = new ByteWriter().append(entries).append(payload).toBytes();
103040
- return record(OA.FOPT, data, count, false, 3);
103414
+ return record(OA.FOPT, data, count2, false, 3);
103041
103415
  }
103042
103416
  function buildMetroBlobTertiaryFopt(metroBlob) {
103043
103417
  const data = new ByteWriter().u16(METRO_BLOB_OPID | 32768 | FBID_FLAG).u32(metroBlob.length >>> 0).bytes(metroBlob).toBytes();
@@ -103101,9 +103475,9 @@ function buildDgg(shapesPerDrawing, totalShapes) {
103101
103475
  const cidcl = drawingCount + 1;
103102
103476
  const cspSaved = totalShapes - drawingCount;
103103
103477
  const w = new ByteWriter().u32(maxShapeId).u32(cidcl).u32(cspSaved).u32(drawingCount);
103104
- shapesPerDrawing.forEach((count, i2) => {
103478
+ shapesPerDrawing.forEach((count2, i2) => {
103105
103479
  const drawingId = i2 + 1;
103106
- w.u32(drawingId).u32(count);
103480
+ w.u32(drawingId).u32(count2);
103107
103481
  });
103108
103482
  return record(OA.Dgg, w.toBytes(), 0, false, 0);
103109
103483
  }
@@ -103931,8 +104305,8 @@ function atom(recType, data) {
103931
104305
  function textHeader(textType) {
103932
104306
  return atom(RT.TextHeaderAtom, new ByteWriter().u32(textType).toBytes());
103933
104307
  }
103934
- function textSpecInfo(count) {
103935
- return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count).u32(1).u16(0).toBytes());
104308
+ function textSpecInfo(count2) {
104309
+ return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count2).u32(1).u16(0).toBytes());
103936
104310
  }
103937
104311
  function promptText(textType, paragraphs) {
103938
104312
  const text2 = paragraphs.join("\r");
@@ -104743,17 +105117,17 @@ function slideMasterIndex(masterIndex, masterCount) {
104743
105117
  return masterIndex !== void 0 && Number.isInteger(masterIndex) && masterIndex >= 0 && masterIndex < masterCount ? masterIndex : 0;
104744
105118
  }
104745
105119
  function countDrawingShapes(shapes) {
104746
- let count = 1;
105120
+ let count2 = 1;
104747
105121
  const walk3 = (list3) => {
104748
105122
  for (const shape of list3) {
104749
- count++;
105123
+ count2++;
104750
105124
  if (shape.kind === "group") {
104751
105125
  walk3(shape.children);
104752
105126
  }
104753
105127
  }
104754
105128
  };
104755
105129
  walk3(shapes);
104756
- return count;
105130
+ return count2;
104757
105131
  }
104758
105132
  function collectFonts(deck, masters) {
104759
105133
  const collect = (shape) => {
@@ -105334,7 +105708,7 @@ function toLevel(style = {}, themeFonts = {}) {
105334
105708
  }
105335
105709
  };
105336
105710
  }
105337
- function toLevels(levels, count, themeFonts) {
105711
+ function toLevels(levels, count2, themeFonts) {
105338
105712
  if (!levels) {
105339
105713
  return void 0;
105340
105714
  }
@@ -105344,7 +105718,7 @@ function toLevels(levels, count, themeFonts) {
105344
105718
  }
105345
105719
  const base = levels[-1];
105346
105720
  return Array.from(
105347
- { length: count },
105721
+ { length: count2 },
105348
105722
  (_, i2) => toLevel(base || levels[i2] ? { ...base, ...levels[i2] } : void 0, themeFonts)
105349
105723
  );
105350
105724
  }
@@ -106253,12 +106627,12 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
106253
106627
  }
106254
106628
  if (Array.isArray(node)) {
106255
106629
  return node.reduce(
106256
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
106630
+ (count3, entry2) => count3 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
106257
106631
  0
106258
106632
  );
106259
106633
  }
106260
106634
  const object = node;
106261
- let count = 0;
106635
+ let count2 = 0;
106262
106636
  for (const key2 of Object.keys(object)) {
106263
106637
  if (key2.startsWith("@_")) {
106264
106638
  continue;
@@ -106270,14 +106644,14 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
106270
106644
  const chart = chartKey ? candidate[chartKey] : void 0;
106271
106645
  if (chart && String(chart["@_r:id"]) === relationshipId2) {
106272
106646
  rebindGraphicData(candidate, relationshipId2, extended);
106273
- count += 1;
106647
+ count2 += 1;
106274
106648
  }
106275
106649
  }
106276
106650
  continue;
106277
106651
  }
106278
- count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
106652
+ count2 += visitGraphicData(value, relationshipId2, extended, getLocalName2);
106279
106653
  }
106280
- return count;
106654
+ return count2;
106281
106655
  }
106282
106656
  async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
106283
106657
  const xml = await deps.zip.file(slidePath)?.async("string");
@@ -106285,11 +106659,11 @@ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, exten
106285
106659
  return 0;
106286
106660
  }
106287
106661
  const tree = deps.parser.parse(xml);
106288
- const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
106289
- if (count > 0) {
106662
+ const count2 = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
106663
+ if (count2 > 0) {
106290
106664
  deps.zip.file(slidePath, deps.builder.build(tree));
106291
106665
  }
106292
- return count;
106666
+ return count2;
106293
106667
  }
106294
106668
  var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
106295
106669
  var init_chart_part_registration = __esm({
@@ -113638,6 +114012,8 @@ var init_PptxHandlerRuntimeState = __esm({
113638
114012
  alternateContentBlockByRawXml = /* @__PURE__ */ new WeakMap();
113639
114013
  /** Embedded fonts extracted during load, preserved for automatic re-embedding on save. */
113640
114014
  loadedEmbeddedFonts = [];
114015
+ /** Decode every embedded font variant during load (see `PptxHandlerLoadOptions`). */
114016
+ eagerDecodeEmbeddedFonts = false;
113641
114017
  /** Typed source metadata for lossless embedded-font list round trips. */
113642
114018
  loadedEmbeddedFontList;
113643
114019
  /**
@@ -118457,10 +118833,10 @@ function detectDominantScript(text2) {
118457
118833
  }
118458
118834
  let best;
118459
118835
  let bestCount = 0;
118460
- for (const [cat, count] of Object.entries(counts)) {
118461
- if (count > bestCount) {
118836
+ for (const [cat, count2] of Object.entries(counts)) {
118837
+ if (count2 > bestCount) {
118462
118838
  best = cat;
118463
- bestCount = count;
118839
+ bestCount = count2;
118464
118840
  }
118465
118841
  }
118466
118842
  return best;
@@ -123462,6 +123838,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
123462
123838
  "pptx/core/core/runtime/PptxHandlerRuntimeSaveDocumentParts.ts"() {
123463
123839
  init_utils();
123464
123840
  init_customer_data_package();
123841
+ init_deferred_embedded_font();
123465
123842
  init_embedded_font_list();
123466
123843
  init_font_deobfuscation();
123467
123844
  init_safe_path();
@@ -123923,7 +124300,9 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
123923
124300
  return;
123924
124301
  }
123925
124302
  const fonts = explicitFonts ?? this.loadedEmbeddedFonts;
123926
- const fontsWithData = fonts.filter((f6) => f6.rawFontData && f6.rawFontData.length > 0);
124303
+ const fontsWithData = fonts.filter(
124304
+ (f6) => shouldSaveEmbeddedFontVerbatim(f6) || f6.rawFontData && f6.rawFontData.length > 0
124305
+ );
123927
124306
  if (fontsWithData.length === 0) {
123928
124307
  const metadata = explicitFontList ?? this.loadedEmbeddedFontList;
123929
124308
  if (metadata && this.presentationData) {
@@ -123966,10 +124345,11 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
123966
124345
  "p:font": { "@_typeface": typeface }
123967
124346
  };
123968
124347
  for (const variant of variants) {
123969
- const fontData = variant.rawFontData;
124348
+ const verbatim = shouldSaveEmbeddedFontVerbatim(variant);
124349
+ const fontData = verbatim ? void 0 : variant.rawFontData;
123970
124350
  const hasOriginal = Boolean(variant.originalRId && variant.partPath);
123971
- const reuseObfuscation = hasOriginal && Boolean(variant.fontGuid);
123972
- const reuseVerbatim = hasOriginal && !variant.fontGuid && Boolean(variant.originalPartBytes);
124351
+ const reuseObfuscation = hasOriginal && !verbatim && Boolean(variant.fontGuid);
124352
+ const reuseVerbatim = hasOriginal && (verbatim || !variant.fontGuid) && Boolean(variant.originalPartBytes);
123973
124353
  let guid;
123974
124354
  let fontPartPath;
123975
124355
  let relativeTarget4;
@@ -127585,13 +127965,13 @@ function countDeclaredIds(node, counts, ensureArray19) {
127585
127965
  if (!countDeclaredIds(branch, branchCounts, ensureArray19)) {
127586
127966
  return false;
127587
127967
  }
127588
- for (const [id, count] of branchCounts) {
127589
- merged.set(id, Math.max(merged.get(id) ?? 0, count));
127968
+ for (const [id, count2] of branchCounts) {
127969
+ merged.set(id, Math.max(merged.get(id) ?? 0, count2));
127590
127970
  }
127591
127971
  }
127592
127972
  }
127593
- for (const [id, count] of merged) {
127594
- counts.set(id, (counts.get(id) ?? 0) + count);
127973
+ for (const [id, count2] of merged) {
127974
+ counts.set(id, (counts.get(id) ?? 0) + count2);
127595
127975
  }
127596
127976
  }
127597
127977
  return true;
@@ -127601,8 +127981,8 @@ function hasStructuralIdDefects(spTree, ensureArray19) {
127601
127981
  if (!countDeclaredIds(spTree, counts, ensureArray19)) {
127602
127982
  return true;
127603
127983
  }
127604
- for (const count of counts.values()) {
127605
- if (count > 1) {
127984
+ for (const count2 of counts.values()) {
127985
+ if (count2 > 1) {
127606
127986
  return true;
127607
127987
  }
127608
127988
  }
@@ -142543,8 +142923,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
142543
142923
  var PptxHandlerRuntime99;
142544
142924
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142545
142925
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
142546
- init_eot_parser();
142547
- init_font_deobfuscation();
142926
+ init_deferred_embedded_font();
142548
142927
  init_layout_display_name();
142549
142928
  init_strip_parent_dir_segments();
142550
142929
  init_xml_access();
@@ -142620,7 +142999,13 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142620
142999
  }
142621
143000
  return map;
142622
143001
  }
142623
- /** Extract, de-obfuscate, and encode a single font variant. */
143002
+ /**
143003
+ * Read one variant's part. By default the result is a deferred descriptor
143004
+ * that decodes on first use (see `createDeferredEmbeddedFont`); parts that
143005
+ * fail the checks possible without decoding are skipped, as before. With
143006
+ * `eagerDecodeEmbeddedFonts` the variant is decoded now and skipped when
143007
+ * decoding fails.
143008
+ */
142624
143009
  async extractEmbeddedFontVariant(typeface, rId, bold, italic, relsMap, fontKey) {
142625
143010
  const fontPath = relsMap.get(rId);
142626
143011
  if (!fontPath) {
@@ -142631,80 +143016,25 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142631
143016
  if (!fontBinary || fontBinary.length === 0) {
142632
143017
  return null;
142633
143018
  }
142634
- const originalPartBytes = new Uint8Array(fontBinary);
142635
- let fontData;
142636
- let resolvedGuid;
142637
- if (isEotFormat(fontBinary)) {
142638
- const extracted = extractFontFromEot(fontBinary);
142639
- if (extracted) {
142640
- fontData = extracted.fontData;
142641
- } else {
142642
- const header = parseEotHeader(fontBinary);
142643
- console.info(
142644
- `[pptx-viewer] Embedded font "${typeface}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""} \u2014 extraction failed, will use web font fallback`
142645
- );
142646
- return null;
142647
- }
142648
- } else {
142649
- const guidFromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
142650
- const guidFromPath = extractGuidFromPartName(fontPath);
142651
- const guid = guidFromKey || guidFromPath;
142652
- if (guid) {
142653
- fontData = deobfuscateFont(fontBinary, guid);
142654
- resolvedGuid = guid;
142655
- } else {
142656
- console.warn(
142657
- `[pptx-viewer] Embedded font "${typeface}" at "${fontPath}" has no fontKey attribute and no GUID in filename \u2014 skipping`
142658
- );
142659
- return null;
142660
- }
142661
- }
142662
- if (fontData.length < 4) {
142663
- return null;
142664
- }
142665
- const v0 = fontData[0], v1 = fontData[1], v2 = fontData[2], v3 = fontData[3];
142666
- const isTrueType = v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0;
142667
- const isOTTO = v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79;
142668
- const isTTC = v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102;
142669
- const isWOFF = v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
142670
- if (!(isTrueType || isOTTO || isTTC || isWOFF)) {
142671
- console.warn(
142672
- `[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)`
142673
- );
142674
- return null;
142675
- }
142676
- const format = detectFontFormat(fontData);
142677
- const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
142678
- const base64 = this.uint8ArrayToBase64(fontData);
142679
- const dataUrl = `data:${mimeType};base64,${base64}`;
142680
- return {
143019
+ const source = {
142681
143020
  name: typeface,
142682
- dataUrl,
142683
143021
  bold,
142684
143022
  italic,
142685
- format,
142686
- rawFontData: fontData,
142687
- partPath: fontPath,
142688
- fontGuid: resolvedGuid,
142689
143023
  originalRId: rId,
142690
- originalPartBytes
143024
+ partPath: fontPath,
143025
+ // The descriptor owns a copy, so it outlives this handler's ZIP and
143026
+ // the save pipeline can write it back verbatim.
143027
+ originalPartBytes: new Uint8Array(fontBinary),
143028
+ fontKey
142691
143029
  };
143030
+ if (this.eagerDecodeEmbeddedFonts) {
143031
+ return decodeEmbeddedFontPart(source);
143032
+ }
143033
+ return isEmbeddedFontPartPlausible(source) ? createDeferredEmbeddedFont(source) : null;
142692
143034
  } catch {
142693
143035
  return null;
142694
143036
  }
142695
143037
  }
142696
- /** Convert Uint8Array to base64 string. */
142697
- uint8ArrayToBase64(bytes) {
142698
- let binary = "";
142699
- const chunkSize = 8192;
142700
- for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
142701
- const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
142702
- for (let j = 0; j < chunk2.length; j++) {
142703
- binary += String.fromCharCode(chunk2[j]);
142704
- }
142705
- }
142706
- return btoa(binary);
142707
- }
142708
143038
  getLayoutOptions() {
142709
143039
  const options = [];
142710
143040
  for (const [path4, xmlObj] of this.layoutXmlMap.entries()) {
@@ -142757,12 +143087,16 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142757
143087
  init_ole_embedded_extract();
142758
143088
  init_ole_utils();
142759
143089
  init_signature_detection();
142760
- init_types2();
143090
+ init_load_limits();
142761
143091
  init_authored_slide_background();
142762
143092
  init_bullet_picture_image_enrichment();
142763
143093
  init_PptxHandlerRuntimeEmbeddedFonts();
142764
143094
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
142765
143095
  PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
143096
+ /** The limits of the load in progress (see `PptxHandlerLoadOptions.limits`). */
143097
+ loadLimits = { ...DEFAULT_PPTX_LOAD_LIMITS };
143098
+ /** Slide elements parsed so far by the load in progress, for `maxShapes`. */
143099
+ loadedShapeCount = 0;
142766
143100
  isZipContainer(data) {
142767
143101
  const bytes = new Uint8Array(data);
142768
143102
  if (bytes.byteLength < 4) {
@@ -142771,7 +143105,9 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142771
143105
  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);
142772
143106
  }
142773
143107
  async initializeLoadSession(data, options) {
143108
+ const limits = resolvePptxLoadLimits(options);
142774
143109
  this.eagerDecodeImages = options.eagerDecodeImages ?? false;
143110
+ this.eagerDecodeEmbeddedFonts = options.eagerDecodeEmbeddedFonts === true;
142775
143111
  this.allowExternalImages = options.allowExternalImages === true;
142776
143112
  if (data.byteLength < 4) {
142777
143113
  throw new Error("Invalid PPTX binary: file is empty or truncated.");
@@ -142781,7 +143117,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142781
143117
  "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."
142782
143118
  );
142783
143119
  }
142784
- const maxBytes = typeof options.maxUncompressedBytes === "number" && options.maxUncompressedBytes > 0 ? options.maxUncompressedBytes : DEFAULT_MAX_UNCOMPRESSED_BYTES;
143120
+ const maxBytes = limits.maxUncompressedBytes;
142785
143121
  let loaded;
142786
143122
  try {
142787
143123
  loaded = await JSZip__default.default.loadAsync(data);
@@ -142791,11 +143127,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142791
143127
  }
142792
143128
  this.zip = guardZip(loaded, {
142793
143129
  label: "PPTX",
142794
- maxEntries: MAX_ZIP_ENTRY_COUNT,
143130
+ maxEntries: limits.maxEntries,
142795
143131
  maxEntryBytes: maxBytes,
142796
143132
  maxTotalBytes: maxBytes,
142797
- createError: (message, details) => new ZipBombError(message, details)
143133
+ createError: createPptxZipBombError
142798
143134
  });
143135
+ this.loadLimits = limits;
143136
+ this.loadedShapeCount = 0;
142799
143137
  try {
142800
143138
  this.documentPropertiesUpdater = this.dependencyFactory.createDocumentPropertiesUpdater(
142801
143139
  this.zip,
@@ -142961,6 +143299,11 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142961
143299
  }
142962
143300
  this.presentationData = this.parser.parse(presentationXml3);
142963
143301
  this.detectAndSetStrictConformance(this.presentationData);
143302
+ const slideIds = this.presentationData?.["p:presentation"]?.["p:sldIdLst"]?.["p:sldId"];
143303
+ assertPptxSlideCountWithinLimits(
143304
+ Array.isArray(slideIds) ? slideIds.length : slideIds ? 1 : 0,
143305
+ this.loadLimits
143306
+ );
142964
143307
  await this.loadThemeData();
142965
143308
  this.parsePresentationDefaultTextStyle();
142966
143309
  await this.loadCommentAuthors();
@@ -143090,7 +143433,17 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
143090
143433
  loadThemeOverride: (partBasePath) => this.loadThemeOverride(partBasePath),
143091
143434
  applyThemeOverrideState: (override) => this.applyThemeOverrideState(override),
143092
143435
  getLayoutElements: (slidePath) => this.getLayoutElements(slidePath),
143093
- parseSlide: (slideXml3, slidePath) => this.parseSlide(slideXml3, slidePath),
143436
+ // `maxShapes`: each slide's own elements are counted as soon as they are
143437
+ // parsed, before that slide's media is resolved and before the next slide.
143438
+ parseSlide: async (slideXml3, slidePath) => {
143439
+ const elements2 = await this.parseSlide(slideXml3, slidePath);
143440
+ this.loadedShapeCount = countPptxShapesWithinLimits(
143441
+ this.loadedShapeCount,
143442
+ elements2,
143443
+ this.loadLimits
143444
+ );
143445
+ return elements2;
143446
+ },
143094
143447
  extractMediaTimingMap: (slideXml3, slidePath) => this.extractMediaTimingMap(slideXml3, slidePath),
143095
143448
  enrichMediaElementsWithTiming: (elements2, timingMap) => this.enrichMediaElementsWithTiming(elements2, timingMap),
143096
143449
  enrichOleElementsWithEmbeddedData: (elements2, slidePath) => this.enrichOleElementsWithEmbeddedData(elements2, slidePath),
@@ -143143,6 +143496,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143143
143496
  init_smart_tags_parser();
143144
143497
  init_strip_parent_dir_segments();
143145
143498
  init_builders();
143499
+ init_load_limits();
143146
143500
  init_authored_slide_background();
143147
143501
  init_layout_switch_placeholder_prompts();
143148
143502
  init_PptxHandlerRuntimeLoadSession();
@@ -143345,21 +143699,31 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143345
143699
  try {
143346
143700
  await this.initializeLoadSession(data, options);
143347
143701
  reader2 = this.beginPartReads();
143348
- await this.detectAndPreserveVbaProject();
143349
- this.detectDigitalSignatureParts();
143350
- await this.parseCustomXmlParts();
143351
- const presentationState = await this.loadPresentationState();
143352
- const slideMasters = await this.parseSlideMasters();
143353
- await this.enrichSlideMastersWithTxStyles(slideMasters);
143354
- const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
143355
- const slidesWithWarnings = this.attachSlideWarnings(slides);
143356
- this.resetElementIdCounter(slides);
143357
- recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
143358
- return await this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
143702
+ try {
143703
+ return await this.loadInitializedSession();
143704
+ } catch (error) {
143705
+ if (error instanceof PptxLoadLimitError) {
143706
+ this.dispose();
143707
+ }
143708
+ throw error;
143709
+ }
143359
143710
  } finally {
143360
143711
  this.endPartReads(reader2);
143361
143712
  }
143362
143713
  }
143714
+ async loadInitializedSession() {
143715
+ await this.detectAndPreserveVbaProject();
143716
+ this.detectDigitalSignatureParts();
143717
+ await this.parseCustomXmlParts();
143718
+ const presentationState = await this.loadPresentationState();
143719
+ const slideMasters = await this.parseSlideMasters();
143720
+ await this.enrichSlideMastersWithTxStyles(slideMasters);
143721
+ const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
143722
+ const slidesWithWarnings = this.attachSlideWarnings(slides);
143723
+ this.resetElementIdCounter(slides);
143724
+ recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
143725
+ return this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
143726
+ }
143363
143727
  /**
143364
143728
  * Retrieve the current background colour for a layout or master.
143365
143729
  */
@@ -144743,24 +145107,24 @@ function parseStyleTextPropAtom(view, dataOffset, dataLen, textLength, scheme) {
144743
145107
  const charRuns = [];
144744
145108
  let covered = 0;
144745
145109
  while (covered < total && c.canRead(6)) {
144746
- const count = c.u32();
145110
+ const count2 = c.u32();
144747
145111
  const indentLevel = c.u16();
144748
- const props = { count, indentLevel };
145112
+ const props = { count: count2, indentLevel };
144749
145113
  if (!parsePfException(c, scheme, props)) {
144750
145114
  break;
144751
145115
  }
144752
145116
  paragraphRuns.push(props);
144753
- covered += count;
145117
+ covered += count2;
144754
145118
  }
144755
145119
  covered = 0;
144756
145120
  while (covered < total && c.canRead(8)) {
144757
- const count = c.u32();
144758
- const props = { count };
145121
+ const count2 = c.u32();
145122
+ const props = { count: count2 };
144759
145123
  if (!parseCfException(c, scheme, props)) {
144760
145124
  break;
144761
145125
  }
144762
145126
  charRuns.push(props);
144763
- covered += count;
145127
+ covered += count2;
144764
145128
  }
144765
145129
  return { paragraphRuns, charRuns };
144766
145130
  }
@@ -145822,13 +146186,13 @@ var init_geometry_map = __esm({
145822
146186
  function parseProperties2(view, data, rec) {
145823
146187
  const values = /* @__PURE__ */ new Map();
145824
146188
  const complex = /* @__PURE__ */ new Map();
145825
- const count = rec.recInstance;
145826
- const entriesEnd = rec.dataOffset + count * 6;
146189
+ const count2 = rec.recInstance;
146190
+ const entriesEnd = rec.dataOffset + count2 * 6;
145827
146191
  if (entriesEnd > rec.dataOffset + rec.recLen) {
145828
146192
  return { values, complex };
145829
146193
  }
145830
146194
  const complexRefs = [];
145831
- for (let i2 = 0; i2 < count; i2++) {
146195
+ for (let i2 = 0; i2 < count2; i2++) {
145832
146196
  const at2 = rec.dataOffset + i2 * 6;
145833
146197
  const opid = view.getUint16(at2, true);
145834
146198
  const value = view.getUint32(at2 + 2, true);
@@ -147029,8 +147393,8 @@ function levelXml(tag, level2, fallbackSizePt) {
147029
147393
  }
147030
147394
  function styleLevels(levels, fallbackSizePt) {
147031
147395
  const result = [];
147032
- const count = Math.max(1, Math.min(levels.length, 9));
147033
- for (let i2 = 0; i2 < count; i2++) {
147396
+ const count2 = Math.max(1, Math.min(levels.length, 9));
147397
+ for (let i2 = 0; i2 < count2; i2++) {
147034
147398
  result.push(levelXml(`lvl${i2 + 1}pPr`, levels[i2] ?? {}, fallbackSizePt));
147035
147399
  }
147036
147400
  return result.join("");
@@ -147526,6 +147890,7 @@ var PptxHandlerCore;
147526
147890
  var init_PptxHandlerCore = __esm({
147527
147891
  "pptx/core/PptxHandlerCore.ts"() {
147528
147892
  init_core2();
147893
+ init_load_limits();
147529
147894
  init_ppt();
147530
147895
  init_encryption_detection();
147531
147896
  init_ole2_parser();
@@ -147915,6 +148280,7 @@ var init_PptxHandlerCore = __esm({
147915
148280
  * ```
147916
148281
  */
147917
148282
  async load(data, options = {}) {
148283
+ assertPptxInputWithinLimits(data.byteLength, resolvePptxLoadLimits(options));
147918
148284
  const detection = detectFileFormat(data);
147919
148285
  if (detection.format === "ole") {
147920
148286
  let ole;
@@ -148163,6 +148529,7 @@ var init_PptxHandler = __esm({
148163
148529
  "pptx/core/PptxHandler.ts"() {
148164
148530
  init_json();
148165
148531
  init_PresentationBuilder();
148532
+ init_load_limits();
148166
148533
  init_PptxHandlerCore();
148167
148534
  PptxHandler = class extends PptxHandlerCore {
148168
148535
  /**
@@ -148234,13 +148601,15 @@ var init_PptxHandler = __esm({
148234
148601
  * archives and portable `pptx-viewer-json` documents.
148235
148602
  *
148236
148603
  * The buffer is sniffed first: JSON documents (leading `{` plus the
148237
- * `"pptx-viewer-json"` format marker) are routed to {@link loadFromJson};
148238
- * everything else goes through the regular ZIP/OLE2 pipeline.
148604
+ * `"pptx-viewer-json"` format marker) are imported as {@link loadFromJson}
148605
+ * does; everything else goes through the regular ZIP/OLE2 pipeline.
148239
148606
  */
148240
148607
  async load(data, options = {}) {
148608
+ const limits = resolvePptxLoadLimits(options);
148609
+ assertPptxInputWithinLimits(data.byteLength, limits);
148241
148610
  const jsonText = decodePptxJsonText(data);
148242
148611
  if (jsonText !== null) {
148243
- return this.loadFromJson(jsonText, options);
148612
+ return this.importJson(jsonText, options, limits);
148244
148613
  }
148245
148614
  return super.load(data, options);
148246
148615
  }
@@ -148251,9 +148620,26 @@ var init_PptxHandler = __esm({
148251
148620
  * handler keeps a valid in-memory archive (editing and {@link save} keep
148252
148621
  * working), then the imported model is overlaid on top: imported
148253
148622
  * presentation fields win, and the slide array is replaced wholesale.
148623
+ *
148624
+ * `options.limits` applies as it does for {@link load}: `maxInputBytes` to
148625
+ * the UTF-8 size of `text` (checked before it is parsed), and `maxSlides`
148626
+ * and `maxShapes` to the document's slides with the same counting rule as
148627
+ * a `.pptx` package (layout and master elements are not counted).
148254
148628
  */
148255
148629
  async loadFromJson(text2, options = {}) {
148256
- const imported = deserializePptxFromJson(text2);
148630
+ const limits = resolvePptxLoadLimits(options);
148631
+ assertPptxTextWithinLimits(text2, limits);
148632
+ return this.importJson(text2, options, limits);
148633
+ }
148634
+ async importJson(text2, options, limits) {
148635
+ const document2 = parsePptxJson(text2);
148636
+ assertPptxSlideCountWithinLimits(document2.slides.length, limits);
148637
+ let shapes = 0;
148638
+ for (const slide of document2.slides) {
148639
+ const elements2 = Array.isArray(slide.elements) ? slide.elements : [];
148640
+ shapes = countPptxShapesWithinLimits(shapes, elements2, limits);
148641
+ }
148642
+ const imported = pptxDataFromJsonDocument(document2);
148257
148643
  const blankBytes = await buildBlankPresentationArchive({
148258
148644
  width: imported.widthEmu,
148259
148645
  height: imported.heightEmu,
@@ -148261,7 +148647,7 @@ var init_PptxHandler = __esm({
148261
148647
  // the overlaid model, so the archive must carry the value itself.
148262
148648
  firstSlideNumber: imported.firstSlideNumber
148263
148649
  });
148264
- const base = await super.load(blankBytes, options);
148650
+ const base = await super.load(blankBytes, { ...options, limits: void 0 });
148265
148651
  return applyImportedPptxData(base, imported);
148266
148652
  }
148267
148653
  };
@@ -151945,14 +152331,14 @@ async function resolveBlobImageUrls(elements2) {
151945
152331
  }
151946
152332
  }
151947
152333
  function countElements(elements2) {
151948
- let count = 0;
152334
+ let count2 = 0;
151949
152335
  for (const el of elements2) {
151950
- count++;
152336
+ count2++;
151951
152337
  if (el.type === "group" && "children" in el) {
151952
- count += countElements(el.children);
152338
+ count2 += countElements(el.children);
151953
152339
  }
151954
152340
  }
151955
- return count;
152341
+ return count2;
151956
152342
  }
151957
152343
  function extractSlideText(elements2) {
151958
152344
  const texts = [];
@@ -152067,10 +152453,10 @@ async function handleFind(bytes, search, options) {
152067
152453
  async function handleReplace(bytes, search, replacement, options) {
152068
152454
  const { handler, data } = await loadPptx(bytes);
152069
152455
  const pattern = options?.caseSensitive === false ? new RegExp(search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi") : search;
152070
- const count = replaceText(data.slides, pattern, replacement);
152456
+ const count2 = replaceText(data.slides, pattern, replacement);
152071
152457
  const outputBytes = await handler.save(data.slides);
152072
152458
  return {
152073
- replacementCount: count,
152459
+ replacementCount: count2,
152074
152460
  outputBytes
152075
152461
  };
152076
152462
  }