ooxml-core 1.27.1 → 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-OIR3ZY4Q.mjs → PptxHandler-AFVUHNJO.mjs} +3 -3
  2. package/dist/PptxHandler-EZW4YAWL.mjs +4 -0
  3. package/dist/{PptxHandler-NHOKKZ4S.cjs → PptxHandler-WI23AJHM.cjs} +3 -3
  4. package/dist/{PresentationBuilder-RFTSZUPR.mjs → PresentationBuilder-DYEHCRHX.mjs} +2 -2
  5. package/dist/{PresentationBuilder-EX6DAE5X.cjs → PresentationBuilder-KUNPJTRL.cjs} +5 -5
  6. package/dist/{PresentationBuilder-X5WFSHLB.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-ZWTXVWMY.mjs → chunk-D7CAHL6J.mjs} +1 -1
  13. package/dist/{chunk-JJ37PCNR.mjs → chunk-EYCM7RVL.mjs} +28 -7
  14. package/dist/{chunk-DMJIDRJE.cjs → chunk-IQ7CB7BJ.cjs} +1771 -1319
  15. package/dist/{chunk-5NJPYCGO.mjs → chunk-LGSBK3BV.mjs} +258 -258
  16. package/dist/{chunk-I57SMSU6.mjs → chunk-LNPVKKR5.mjs} +28 -7
  17. package/dist/{chunk-GZ4DIXZZ.mjs → chunk-N5ROEHEQ.mjs} +699 -247
  18. package/dist/{chunk-QIMNQDON.mjs → chunk-RCEHCVLC.mjs} +1 -1
  19. package/dist/{chunk-BXZF7H5G.mjs → chunk-V33RUK4D.mjs} +5 -5
  20. package/dist/{chunk-5KJAQKZG.mjs → chunk-YNGMSNF4.mjs} +718 -246
  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 +1009 -505
  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-D8DNpc1X.d.ts → index-0slnMhMO.d.ts} +161 -12
  37. package/dist/pptx/chunks/index-0slnMhMO.d.ts.map +1 -0
  38. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts → index-DP-R2qY1.d.ts} +3 -3
  39. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts.map → index-DP-R2qY1.d.ts.map} +1 -1
  40. package/dist/pptx/chunks/{index-GWpMAY-f.d.ts → index-OQwOyNYK.d.ts} +4 -4
  41. package/dist/pptx/chunks/{index-GWpMAY-f.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 +834 -333
  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 +1249 -726
  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-TZJNIXPX.mjs +0 -4
  72. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { NS, SMART_ART_DEFINITION_PARTS, VML_SHAPE_TAGS, isAlternateContentChoiceXmlSupported, parseVmlElement, unwrapAlternateContent, xmlChild, xmlAttr, parseDrawingMediaReference, cropShapeForPresetGeometry, isHeaderFooterPlaceholder, xmlPath, inheritedPlaceholderFieldType, parseParagraphLevel, xmlHasChild, parseParagraphExtraAttributes, parseParagraphMargins, parseAlignmentAttr, parseParagraphRtl, parseTabStops, resolveParagraphAlignment, xmlText, parseBodyPrBooleanAttrs, selectAlternateContentBranch, parseBulletSizePercent, extractColorChoiceXml, themeColorRefFromColorChoice, formatAutoNumberMarker, cloneXmlObject, parseParagraphSpacingPx, parseOoxmlPercent, createBuiltinVariables, resolveCoordinate, readPathListCommandOrder, parseAdjustmentValues, parseGuideDefinitions, evaluateGuides, orderedPathCommandEntries, ooxmlArcToSvg, inheritCustomGeometryCommandOrder, parseInkMlContent, parseModel3DScene, remapElementShapeIds, parseShapeId, isTemplateElementId, remapShapeIdReferences, reapplyAlternateContentToTree, openPptxZip, buildOle2, SHAPE_TREE_ELEMENT_TAGS, MAX_SHAPE_ID, orderedXmlKey, safeResolveZipPath, parseXml, elements, parseDataUrlToBytes, base64Decode, reorderObjectKeys, encodeCompressedPng, zlibStore, hash, concatArrays, encodePasswordUtf16LE, COLOR_MAP_ALIAS_KEYS, DEFAULT_COLOR_MAP, uint32LE, pptxActionToElementAction, buildClrMapOverrideXml, applyActiveXControlsToSlide, BLIP_FILL_ORDER, SP_PR_ORDER, ensureXmlChild, inkElementToStrokes, buildInkMlContent, ensureXmlChildOrCreate, isXmlNode, applyChartLayouts, stripXmlOrderSuffix, serializeTabStop, readCommentMentions, rebaseCommentMentions, applyCommentMentions, colorsEqual, generateFontGuid, applyBubbleChartOptions, applyChartUpDownBars, applyDataLabelsRangeToDLbls, applyChartAxisScaling, applyChartAxisLabelFormatting, upsertChartAxisChild, applyChartDateAxisUnits, applyChartAxisDisplayUnitsToXml, writeChartShapeProps, resolveTxPrDefRPr, buildDefRPrTextProperties, buildChartGradFillXml, applySeriesMarkerToXml, applySeriesDataPointsToXml, chartColorHex, applyChartManualLayout, chartTrendlineType, buildTrendlineLabel, serializeColorChoice, replaceOleEmbedding, findKey, collectAllText, buildNodeGuidMap, buildPresentationGuidMap, regenerateSmartArtDrawingShapes, buildFabricatedDrawingXml, buildFabricatedDiagramDataXml, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_REL_TYPE, applyDiagramRelationshipIds, applyDrawingMediaReference, DIAGRAM_XML_PROLOG, DIAGRAM_DATA_XMLNS, escapeDiagramXml, writeBodyPrBooleanAttrs, applyTextBodySp3d, customGeometryPathsToXml, ensureArrayValue, lookupPresetShape, writeShapeEffects, SHAPE_STYLE_ORDER, roundCoordinate, scaleVectorToIntegers, P14_GUIDE_URI, P15_GUIDE_URI, buildGuideListExtension, resetSpPrFormattingForStyleMatrix, restorePathListCommandOrder, fillIsPurelyStyleMatrix, serializeColorChoiceWithRef, createLineStyleGate, applyDrawingLineDash, getSignaturePathsToStrip, DIGITAL_SIGNATURE_ORIGIN_REL_TYPE, mergeSmartArtPointXml, mergeSmartArtConnectionXml, applySmartArtLayoutDefinition, obfuscateFont, containsConvertibleStrictNamespaceAttribute, convertXmlToStrict, applySeriesPictureOptionsToXml, findChartExtByUri, findChildByLocalName, regenerateClonedUniqueId, buildChartUniqueIdExtLst, createOfficeGuid, isContentPoint, newSmartArtGuid, parseChartUserShapesDrawing, DEFAULT_ROW_HEIGHT_EMU, createDefaultXmlCell, xmlChildren, applyChartGradientToSpPr, setAutoTitleDeleted, insertAt, replaceFirstText, shouldRebuildFromParagraphs, buildPointFromParagraphs, shouldRebuildFromRuns, buildPointFromRuns, buildPointText, tableCellTextBodyMatches, ensureXmlChildren, TC_PR_BORDERS_ORDER, relAttr, buildXml, writeChartColorChoice, first, stripParentDirSegments, children, parseChartUniqueId, buildChartMarkerXml, chartGradientsEqual, chartColorChoiceValue, attr, openZip, readChartManualLayoutValues, buildEffectDagTreeFromXml, syncPictureShapeTypeWithCropShape, buildSrgbColorChoice, fetchUrlToBytes, parseChartWideTextStyle, hasLocalName, parseDefRPrTextStyle, parseChartDataLabelOptions, shadowOffsetToDistanceAndDirection, positiveFixedAngleAttribute, xmlAttrNumber, parseCustomShows, parseShapeProps, parseActiveXControlsFromSlide, convertMetafileToDataUrl, ooxmlGradientAngleToCssDegrees, isAlternateContentChoiceSupported, detectStrictConformance, normalizeStrictXml, relayoutSmartArt, CHART_ERROR_VALUE_TYPES, CHART_ERROR_BAR_TYPES, CHART_ERROR_BAR_DIRECTIONS, themeColorRefToSolidFillWithOpacity, FONT_ADVANCE_TABLES, DEFAULT_FONT_ADVANCE_TABLE, measureTextWidth, applyDrawingColorTransforms, applyThemeToData, detectFileFormat, parseOle2, EncryptedFileError, decryptPptx, encryptPptx, encodeXmlAttributeValue, encodeXmlTextValue, svgToCustomGeometryPaths, IncorrectPasswordError, parseEncryptionInfo, RC4_ALG_ID, isOle2CompoundFile, ENTRY_TYPE_ROOT, supportsChartGradientFill, DEFAULT_CHART_GRADIENT_ANGLE, decodeXmlEntities, preservesXmlWhitespace, annotateCustomGeometryCommandOrder, annotateSmartArtTextOrder, stripXmlOrderMarkers, normalizeStShapeType, applyCustomShows, applySections, reorderObjectKeysByLocalName, PRESENTATION_CHILD_ORDER, applyKinsokuToXml, normalizeNamespaceUri, backgroundStyleRefIsCurrent, backgroundRefNode, captureStyleBaseline, STYLE_MATRIX_FILL_KEYS, STYLE_MATRIX_LINE_KEYS, STYLE_MATRIX_EFFECT_KEYS, detectOleObjectType, inferOleExtensionFromTarget, backgroundStylePreset, isDarkColorMap, backgroundStyleColorMap, reResolveElementsForColorMapChange, deriveSlideTitles, parseP14DirectChild, parseP14FromExtLst, P14_TRANSITION_TYPES, parseSlideDrawingGuides, slideBackgroundStyleRefFromNode, cloneSlide, parseDrawingFraction, scrgbLinearToSrgb8, parseDrawingHueDegrees, hslToRgb, themeColorRefToXml, effectChild, mergeEffectNode, mergeAttributeEffectNode, findThemeEffectScheme, wrapFormatSchemeXml, effectIsPurelyStyleMatrix, prismFamilyFlags, prismFamilyTypeOfNode, prismFamilyTypeForFlags, P14_DIR_IS_ORIENTATION_TYPE, estimateMediaDurationMs, parseVmlElements, parseDrawingLineDash, parseLineSpacingMultiplier, parseLineSpacingExactPt, formatSchemeKey, loadThemeVariants, parsePresentationDrawingGuides, parsePresentationSmartTags, resolveLayoutDisplayName, DEFAULT_MAX_UNCOMPRESSED_BYTES, guardZip, ZipBombError, MAX_ZIP_ENTRY_COUNT, detectDigitalSignatures, unwrapOleEmbedding, mimeTypeForOleFile, oleBytesToDataUrl, themeColorRefFromSchemeClr, extractGuidFromPartName, deobfuscateFont, detectFontFormat, parseKinsoku, parseLineStyle, parseChartUpDownBars, parseDataTable, parseChart3DSurfaces, parseChartAxes, parseBubbleChartOptions, parseChartLayouts, parseCxChartSeries, parseChartDataPointPictureBlipRel, parseSeriesDataPoints, parseMarker, parseSeriesDataLabels, parseChartDataPointPicture, parseImplicitBlipPictureFill, parseEmbeddedXlsx, chartTrendlineKind, parseChartManualLayout, parseDiagramRelationshipIds, parseSmartArtTextParagraphs, firstParagraphRuns, smartArtParagraphsText, parseSmartArtLayoutDefinition, parseSmartArtPresLayoutVars, parseSmartArtConnection, projectSmartArtNodeText, resolveSmartArtNodeStyleRoles, resolveSmartArtNodeCoherent3DOff, parseSmartArtDefinitionMetadata, parseSmartArtColorStyleLabels, buildSmartArtColorLists, buildSmartArtColorRoleMap, parseSmartArtQuickStyleLabels, resolveSmartArtEffectIntensity, parseSmartArtStyleLabelRefs, extractStyleReferenceColorXml, withThemePlaceholderColor, blendColorOntoWhite } from './chunk-I57SMSU6.mjs';
1
+ import { NS, SMART_ART_DEFINITION_PARTS, VML_SHAPE_TAGS, isAlternateContentChoiceXmlSupported, parseVmlElement, unwrapAlternateContent, xmlChild, xmlAttr, parseDrawingMediaReference, cropShapeForPresetGeometry, isHeaderFooterPlaceholder, xmlPath, inheritedPlaceholderFieldType, parseParagraphLevel, xmlHasChild, parseParagraphExtraAttributes, parseParagraphMargins, parseAlignmentAttr, parseParagraphRtl, parseTabStops, resolveParagraphAlignment, xmlText, parseBodyPrBooleanAttrs, selectAlternateContentBranch, parseBulletSizePercent, extractColorChoiceXml, themeColorRefFromColorChoice, formatAutoNumberMarker, cloneXmlObject, parseParagraphSpacingPx, parseOoxmlPercent, createBuiltinVariables, resolveCoordinate, readPathListCommandOrder, parseAdjustmentValues, parseGuideDefinitions, evaluateGuides, orderedPathCommandEntries, ooxmlArcToSvg, inheritCustomGeometryCommandOrder, parseInkMlContent, parseModel3DScene, remapElementShapeIds, parseShapeId, isTemplateElementId, remapShapeIdReferences, reapplyAlternateContentToTree, openPptxZip, buildOle2, SHAPE_TREE_ELEMENT_TAGS, MAX_SHAPE_ID, orderedXmlKey, safeResolveZipPath, parseXml, elements, parseDataUrlToBytes, base64Decode, reorderObjectKeys, encodeCompressedPng, zlibStore, hash, concatArrays, encodePasswordUtf16LE, COLOR_MAP_ALIAS_KEYS, DEFAULT_COLOR_MAP, uint32LE, pptxActionToElementAction, buildClrMapOverrideXml, applyActiveXControlsToSlide, BLIP_FILL_ORDER, SP_PR_ORDER, ensureXmlChild, inkElementToStrokes, buildInkMlContent, ensureXmlChildOrCreate, isXmlNode, applyChartLayouts, stripXmlOrderSuffix, serializeTabStop, readCommentMentions, rebaseCommentMentions, applyCommentMentions, colorsEqual, generateFontGuid, applyBubbleChartOptions, applyChartUpDownBars, applyDataLabelsRangeToDLbls, applyChartAxisScaling, applyChartAxisLabelFormatting, upsertChartAxisChild, applyChartDateAxisUnits, applyChartAxisDisplayUnitsToXml, writeChartShapeProps, resolveTxPrDefRPr, buildDefRPrTextProperties, buildChartGradFillXml, applySeriesMarkerToXml, applySeriesDataPointsToXml, chartColorHex, applyChartManualLayout, chartTrendlineType, buildTrendlineLabel, serializeColorChoice, replaceOleEmbedding, findKey, collectAllText, buildNodeGuidMap, buildPresentationGuidMap, regenerateSmartArtDrawingShapes, buildFabricatedDrawingXml, buildFabricatedDiagramDataXml, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_REL_TYPE, applyDiagramRelationshipIds, applyDrawingMediaReference, DIAGRAM_XML_PROLOG, DIAGRAM_DATA_XMLNS, escapeDiagramXml, writeBodyPrBooleanAttrs, applyTextBodySp3d, customGeometryPathsToXml, ensureArrayValue, lookupPresetShape, writeShapeEffects, SHAPE_STYLE_ORDER, roundCoordinate, scaleVectorToIntegers, P14_GUIDE_URI, P15_GUIDE_URI, buildGuideListExtension, resetSpPrFormattingForStyleMatrix, restorePathListCommandOrder, fillIsPurelyStyleMatrix, serializeColorChoiceWithRef, createLineStyleGate, applyDrawingLineDash, getSignaturePathsToStrip, DIGITAL_SIGNATURE_ORIGIN_REL_TYPE, mergeSmartArtPointXml, mergeSmartArtConnectionXml, applySmartArtLayoutDefinition, obfuscateFont, containsConvertibleStrictNamespaceAttribute, convertXmlToStrict, applySeriesPictureOptionsToXml, findChartExtByUri, findChildByLocalName, regenerateClonedUniqueId, buildChartUniqueIdExtLst, createOfficeGuid, isContentPoint, newSmartArtGuid, parseChartUserShapesDrawing, DEFAULT_ROW_HEIGHT_EMU, createDefaultXmlCell, xmlChildren, applyChartGradientToSpPr, setAutoTitleDeleted, insertAt, replaceFirstText, shouldRebuildFromParagraphs, buildPointFromParagraphs, shouldRebuildFromRuns, buildPointFromRuns, buildPointText, tableCellTextBodyMatches, ensureXmlChildren, TC_PR_BORDERS_ORDER, relAttr, buildXml, writeChartColorChoice, first, stripParentDirSegments, children, parseChartUniqueId, buildChartMarkerXml, chartGradientsEqual, chartColorChoiceValue, attr, openZip, readChartManualLayoutValues, buildEffectDagTreeFromXml, syncPictureShapeTypeWithCropShape, buildSrgbColorChoice, fetchUrlToBytes, parseChartWideTextStyle, hasLocalName, parseDefRPrTextStyle, parseChartDataLabelOptions, shadowOffsetToDistanceAndDirection, positiveFixedAngleAttribute, xmlAttrNumber, parseCustomShows, parseShapeProps, parseActiveXControlsFromSlide, convertMetafileToDataUrl, ooxmlGradientAngleToCssDegrees, isAlternateContentChoiceSupported, detectStrictConformance, normalizeStrictXml, relayoutSmartArt, CHART_ERROR_VALUE_TYPES, CHART_ERROR_BAR_TYPES, CHART_ERROR_BAR_DIRECTIONS, themeColorRefToSolidFillWithOpacity, FONT_ADVANCE_TABLES, DEFAULT_FONT_ADVANCE_TABLE, measureTextWidth, applyDrawingColorTransforms, applyThemeToData, detectFileFormat, parseOle2, EncryptedFileError, decryptPptx, encryptPptx, MAX_ZIP_ENTRY_COUNT, DEFAULT_MAX_UNCOMPRESSED_BYTES, encodeXmlAttributeValue, encodeXmlTextValue, svgToCustomGeometryPaths, IncorrectPasswordError, parseEncryptionInfo, RC4_ALG_ID, isOle2CompoundFile, ENTRY_TYPE_ROOT, supportsChartGradientFill, DEFAULT_CHART_GRADIENT_ANGLE, decodeXmlEntities, preservesXmlWhitespace, annotateCustomGeometryCommandOrder, annotateSmartArtTextOrder, stripXmlOrderMarkers, normalizeStShapeType, applyCustomShows, applySections, reorderObjectKeysByLocalName, PRESENTATION_CHILD_ORDER, applyKinsokuToXml, normalizeNamespaceUri, backgroundStyleRefIsCurrent, backgroundRefNode, captureStyleBaseline, STYLE_MATRIX_FILL_KEYS, STYLE_MATRIX_LINE_KEYS, STYLE_MATRIX_EFFECT_KEYS, detectOleObjectType, inferOleExtensionFromTarget, backgroundStylePreset, isDarkColorMap, backgroundStyleColorMap, reResolveElementsForColorMapChange, deriveSlideTitles, parseP14DirectChild, parseP14FromExtLst, P14_TRANSITION_TYPES, parseSlideDrawingGuides, slideBackgroundStyleRefFromNode, cloneSlide, parseDrawingFraction, scrgbLinearToSrgb8, parseDrawingHueDegrees, hslToRgb, themeColorRefToXml, effectChild, mergeEffectNode, mergeAttributeEffectNode, findThemeEffectScheme, wrapFormatSchemeXml, effectIsPurelyStyleMatrix, prismFamilyFlags, prismFamilyTypeOfNode, prismFamilyTypeForFlags, P14_DIR_IS_ORIENTATION_TYPE, estimateMediaDurationMs, parseVmlElements, parseDrawingLineDash, parseLineSpacingMultiplier, parseLineSpacingExactPt, formatSchemeKey, loadThemeVariants, parsePresentationDrawingGuides, parsePresentationSmartTags, resolveLayoutDisplayName, guardZip, detectDigitalSignatures, unwrapOleEmbedding, mimeTypeForOleFile, oleBytesToDataUrl, themeColorRefFromSchemeClr, ZipBombError, parseKinsoku, deobfuscateFont, detectFontFormat, parseLineStyle, parseChartUpDownBars, parseDataTable, parseChart3DSurfaces, parseChartAxes, parseBubbleChartOptions, extractGuidFromPartName, parseChartLayouts, parseCxChartSeries, parseChartDataPointPictureBlipRel, parseSeriesDataPoints, parseMarker, parseSeriesDataLabels, parseChartDataPointPicture, parseImplicitBlipPictureFill, parseEmbeddedXlsx, chartTrendlineKind, parseChartManualLayout, parseDiagramRelationshipIds, parseSmartArtTextParagraphs, firstParagraphRuns, smartArtParagraphsText, parseSmartArtLayoutDefinition, parseSmartArtPresLayoutVars, parseSmartArtConnection, projectSmartArtNodeText, resolveSmartArtNodeStyleRoles, resolveSmartArtNodeCoherent3DOff, parseSmartArtDefinitionMetadata, parseSmartArtColorStyleLabels, buildSmartArtColorLists, buildSmartArtColorRoleMap, parseSmartArtQuickStyleLabels, resolveSmartArtEffectIntensity, parseSmartArtStyleLabelRefs, extractStyleReferenceColorXml, withThemePlaceholderColor, blendColorOntoWhite } from './chunk-LNPVKKR5.mjs';
2
2
  import { hasShapeProperties, hasTextProperties } from './chunk-GXHKNSZX.mjs';
3
3
  import { EMU_PER_PX, EMU_PER_PIXEL, SYSTEM_COLOR_MAP, PRESET_COLOR_MAP, OOXML_PERCENT_UNITS, EMU_PER_POINT } from './chunk-CA7KCNL3.mjs';
4
4
  import JSZip from 'jszip';
@@ -498,9 +498,6 @@ function pptxDataFromJsonDocument(document2) {
498
498
  data.slides = document2.slides.map((slide) => deserializeSlide(slide));
499
499
  return data;
500
500
  }
501
- function deserializePptxFromJson(text) {
502
- return pptxDataFromJsonDocument(parsePptxJson(text));
503
- }
504
501
  function deserializeSlide(encoded) {
505
502
  const slide = {};
506
503
  for (const key2 of Object.keys(SLIDE_FIELD_KIND)) {
@@ -548,6 +545,181 @@ function applyImportedPptxData(base, imported) {
548
545
  return base;
549
546
  }
550
547
 
548
+ // pptx/core/core/load-limits.ts
549
+ var DEFAULT_PPTX_LOAD_LIMITS = Object.freeze({
550
+ maxInputBytes: Number.POSITIVE_INFINITY,
551
+ maxUncompressedBytes: DEFAULT_MAX_UNCOMPRESSED_BYTES,
552
+ maxEntries: MAX_ZIP_ENTRY_COUNT,
553
+ maxSlides: Number.POSITIVE_INFINITY,
554
+ maxShapes: Number.POSITIVE_INFINITY
555
+ });
556
+ var LIMIT_NAMES = Object.keys(DEFAULT_PPTX_LOAD_LIMITS);
557
+ var PptxLoadLimitError = class extends Error {
558
+ code = "PPTX_LOAD_LIMIT";
559
+ /** The limit that was exceeded. */
560
+ limit;
561
+ /** The value of that limit. */
562
+ maximum;
563
+ /**
564
+ * The observed value: exact for `maxSlides` and for `maxInputBytes` on
565
+ * `load()`; for `maxShapes`, and for `maxInputBytes` on `loadFromJson()`
566
+ * (which stops counting once past the limit), a lower bound.
567
+ */
568
+ actual;
569
+ constructor(message, limit, maximum, actual) {
570
+ super(message);
571
+ this.name = "PptxLoadLimitError";
572
+ this.limit = limit;
573
+ this.maximum = maximum;
574
+ this.actual = actual;
575
+ }
576
+ };
577
+ function resolvePptxLoadLimits(options = {}) {
578
+ const resolved = { ...DEFAULT_PPTX_LOAD_LIMITS };
579
+ const legacy = options.maxUncompressedBytes;
580
+ if (typeof legacy === "number" && legacy > 0) {
581
+ resolved.maxUncompressedBytes = legacy;
582
+ }
583
+ const limits = options.limits;
584
+ if (limits === void 0 || limits === null) {
585
+ return resolved;
586
+ }
587
+ for (const name of LIMIT_NAMES) {
588
+ const value = limits[name];
589
+ if (value === void 0) {
590
+ continue;
591
+ }
592
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
593
+ throw new RangeError(`limits.${name} must be a positive finite number`);
594
+ }
595
+ if (name === "maxEntries" && value > MAX_ZIP_ENTRY_COUNT) {
596
+ throw new RangeError(`limits.maxEntries must not exceed ${MAX_ZIP_ENTRY_COUNT}`);
597
+ }
598
+ resolved[name] = value;
599
+ }
600
+ return resolved;
601
+ }
602
+ function createPptxZipBombError(message, details) {
603
+ const { limit, kind, actual } = details;
604
+ if (kind === "maxEntries") {
605
+ return new ZipBombError(message, {
606
+ limit,
607
+ loadLimit: "maxEntries",
608
+ ...actual === void 0 ? {} : { entryCount: actual, actual }
609
+ });
610
+ }
611
+ if (kind === "maxEntryBytes" || kind === "maxTotalBytes") {
612
+ return new ZipBombError(message, {
613
+ limit,
614
+ loadLimit: "maxUncompressedBytes",
615
+ ...actual === void 0 ? {} : { uncompressedBytes: actual, actual }
616
+ });
617
+ }
618
+ return new ZipBombError(message, { limit });
619
+ }
620
+ var count = (value) => value.toLocaleString("en-US");
621
+ function assertPptxInputWithinLimits(byteLength, limits) {
622
+ if (byteLength > limits.maxInputBytes) {
623
+ throw new PptxLoadLimitError(
624
+ `PPTX input is ${count(byteLength)} bytes, more than the maxInputBytes limit of ${count(limits.maxInputBytes)}`,
625
+ "maxInputBytes",
626
+ limits.maxInputBytes,
627
+ byteLength
628
+ );
629
+ }
630
+ }
631
+ function assertPptxTextWithinLimits(text, limits) {
632
+ const maximum = limits.maxInputBytes;
633
+ if (text.length * 3 <= maximum) {
634
+ return;
635
+ }
636
+ const bytes = text.length > maximum ? text.length : utf8ByteLengthPast(text, maximum);
637
+ if (bytes > maximum) {
638
+ throw new PptxLoadLimitError(
639
+ `PPTX input is at least ${count(bytes)} bytes, more than the maxInputBytes limit of ${count(maximum)}`,
640
+ "maxInputBytes",
641
+ maximum,
642
+ bytes
643
+ );
644
+ }
645
+ }
646
+ function utf8ByteLengthPast(text, maximum) {
647
+ let bytes = 0;
648
+ for (let index = 0; index < text.length && bytes <= maximum; index++) {
649
+ const unit = text.charCodeAt(index);
650
+ if (unit < 128) {
651
+ bytes += 1;
652
+ } else if (unit < 2048) {
653
+ bytes += 2;
654
+ } else if (unit >= 55296 && unit <= 56319 && isLowSurrogate(text.charCodeAt(index + 1))) {
655
+ bytes += 4;
656
+ index++;
657
+ } else {
658
+ bytes += 3;
659
+ }
660
+ }
661
+ return bytes;
662
+ }
663
+ function isLowSurrogate(unit) {
664
+ return unit >= 56320 && unit <= 57343;
665
+ }
666
+ function assertPptxSlideCountWithinLimits(slideCount, limits) {
667
+ if (slideCount > limits.maxSlides) {
668
+ throw new PptxLoadLimitError(
669
+ `PPTX presentation has ${count(slideCount)} slides, more than the maxSlides limit of ${count(limits.maxSlides)}`,
670
+ "maxSlides",
671
+ limits.maxSlides,
672
+ slideCount
673
+ );
674
+ }
675
+ }
676
+ function countPptxShapesWithinLimits(counted, elements2, limits) {
677
+ const maximum = limits.maxShapes;
678
+ if (maximum === Number.POSITIVE_INFINITY) {
679
+ return counted;
680
+ }
681
+ const total = counted + countAuthoredElements(elements2);
682
+ if (total > maximum) {
683
+ throw new PptxLoadLimitError(
684
+ `PPTX presentation has at least ${count(total)} shapes, more than the maxShapes limit of ${count(maximum)}`,
685
+ "maxShapes",
686
+ maximum,
687
+ total
688
+ );
689
+ }
690
+ return total;
691
+ }
692
+ function countAuthoredElements(elements2) {
693
+ let total = 0;
694
+ const lists = [elements2];
695
+ const positions = [0];
696
+ while (lists.length > 0) {
697
+ const top = lists.length - 1;
698
+ const list2 = lists[top];
699
+ const position2 = positions[top];
700
+ if (position2 >= list2.length) {
701
+ lists.pop();
702
+ positions.pop();
703
+ continue;
704
+ }
705
+ positions[top] = position2 + 1;
706
+ const element = list2[position2];
707
+ if (typeof element !== "object" || element === null) {
708
+ continue;
709
+ }
710
+ const { id, type, children: children6 } = element;
711
+ if (typeof id === "string" && isTemplateElementId(id)) {
712
+ continue;
713
+ }
714
+ total++;
715
+ if (type === "group" && Array.isArray(children6) && children6.length > 0) {
716
+ lists.push(children6);
717
+ positions.push(0);
718
+ }
719
+ }
720
+ return total;
721
+ }
722
+
551
723
  // pptx/core/geometry/preset-adjustment-validation.ts
552
724
  function filterValidShapeAdjustmentEntries(presetGeometry, adjustments) {
553
725
  if (!adjustments) {
@@ -627,21 +799,21 @@ function parseChartFormulaRange(formula2) {
627
799
  }
628
800
  return { sheetName, start, end };
629
801
  }
630
- function expandRangeAddresses(range, count) {
802
+ function expandRangeAddresses(range, count2) {
631
803
  const { start, end } = range;
632
- if (count <= 0) {
804
+ if (count2 <= 0) {
633
805
  return void 0;
634
806
  }
635
807
  if (start.col === end.col && start.row === end.row) {
636
- return count === 1 ? [formatCellAddress(start)] : void 0;
808
+ return count2 === 1 ? [formatCellAddress(start)] : void 0;
637
809
  }
638
810
  if (start.col === end.col) {
639
811
  const length = end.row - start.row + 1;
640
- return length === count ? Array.from({ length }, (_, i) => formatCellAddress({ col: start.col, row: start.row + i })) : void 0;
812
+ return length === count2 ? Array.from({ length }, (_, i) => formatCellAddress({ col: start.col, row: start.row + i })) : void 0;
641
813
  }
642
814
  if (start.row === end.row) {
643
815
  const length = end.col - start.col + 1;
644
- return length === count ? Array.from({ length }, (_, i) => formatCellAddress({ col: start.col + i, row: start.row })) : void 0;
816
+ return length === count2 ? Array.from({ length }, (_, i) => formatCellAddress({ col: start.col + i, row: start.row })) : void 0;
645
817
  }
646
818
  return void 0;
647
819
  }
@@ -1414,8 +1586,8 @@ function readPairs(element, vt) {
1414
1586
  const out = [];
1415
1587
  for (let i = 0; i + 1 < variants.length; i += 2) {
1416
1588
  const name = variants[i]?.textContent ?? "";
1417
- const count = Number.parseInt(variants[i + 1]?.textContent ?? "", 10);
1418
- out.push({ name, count: Number.isFinite(count) ? count : 0 });
1589
+ const count2 = Number.parseInt(variants[i + 1]?.textContent ?? "", 10);
1590
+ out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
1419
1591
  }
1420
1592
  return out;
1421
1593
  }
@@ -1585,9 +1757,9 @@ function customPropertyFromText(name, type, text) {
1585
1757
  function titleGroups(headingPairs, titlesOfParts) {
1586
1758
  let offset = 0;
1587
1759
  return headingPairs.map((pair) => {
1588
- const count = Math.max(0, pair.count);
1589
- const titles = titlesOfParts.slice(offset, offset + count);
1590
- offset += count;
1760
+ const count2 = Math.max(0, pair.count);
1761
+ const titles = titlesOfParts.slice(offset, offset + count2);
1762
+ offset += count2;
1591
1763
  return { name: pair.name, titles };
1592
1764
  });
1593
1765
  }
@@ -8232,7 +8404,7 @@ function parsedParagraphSignature(paragraph2) {
8232
8404
  return signatureOf(counts);
8233
8405
  }
8234
8406
  function signatureOf(counts) {
8235
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
8407
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
8236
8408
  }
8237
8409
  function collectParsedParagraphs(root) {
8238
8410
  const result = [];
@@ -11386,23 +11558,23 @@ function classify(chars, index) {
11386
11558
  }
11387
11559
  function countParagraphWords(text) {
11388
11560
  const chars = Array.from(text);
11389
- let count = 0;
11561
+ let count2 = 0;
11390
11562
  let previous = "none";
11391
11563
  for (let index = 0; index < chars.length; index++) {
11392
11564
  const kind = classify(chars, index);
11393
11565
  if (kind === "space") {
11394
11566
  if (previous === "none" || previous === "control") {
11395
- count++;
11567
+ count2++;
11396
11568
  }
11397
11569
  previous = "space";
11398
11570
  continue;
11399
11571
  }
11400
11572
  if (kind === "ideograph" || kind === "control" || kind !== previous) {
11401
- count++;
11573
+ count2++;
11402
11574
  }
11403
11575
  previous = kind;
11404
11576
  }
11405
- return count;
11577
+ return count2;
11406
11578
  }
11407
11579
 
11408
11580
  // pptx/core/utils/app-properties-text-stats.ts
@@ -11888,6 +12060,91 @@ function applyBackground(style, background) {
11888
12060
  style.fillOpacity = 0;
11889
12061
  }
11890
12062
 
12063
+ // pptx/core/core/runtime/load-part-reader.ts
12064
+ var openReaders = /* @__PURE__ */ new WeakMap();
12065
+ var LoadPartReader = class {
12066
+ constructor(zip) {
12067
+ this.zip = zip;
12068
+ openReaders.set(zip, this);
12069
+ }
12070
+ zip;
12071
+ parts = /* @__PURE__ */ new Map();
12072
+ closed = false;
12073
+ entry(path3) {
12074
+ const file = this.zip.file(path3);
12075
+ if (!file) {
12076
+ this.parts.delete(path3);
12077
+ return void 0;
12078
+ }
12079
+ const previous = this.parts.get(path3);
12080
+ if (previous?.file === file) {
12081
+ return previous;
12082
+ }
12083
+ const entry2 = { file, text: file.async("string"), relationships: /* @__PURE__ */ new Map() };
12084
+ this.parts.set(path3, entry2);
12085
+ entry2.text.catch(() => {
12086
+ if (this.parts.get(path3) === entry2) {
12087
+ this.parts.delete(path3);
12088
+ }
12089
+ });
12090
+ return entry2;
12091
+ }
12092
+ readText(path3) {
12093
+ return this.entry(path3)?.text ?? Promise.resolve(void 0);
12094
+ }
12095
+ async readXml(parser, path3) {
12096
+ const entry2 = this.entry(path3);
12097
+ if (!entry2) {
12098
+ return void 0;
12099
+ }
12100
+ if (!path3.endsWith(".rels")) {
12101
+ return parseText(parser, await entry2.text);
12102
+ }
12103
+ let parsed = entry2.relationships.get(parser);
12104
+ if (!parsed) {
12105
+ const pending = entry2.text.then((text) => parseText(parser, text));
12106
+ entry2.relationships.set(parser, pending);
12107
+ pending.catch(() => {
12108
+ if (entry2.relationships.get(parser) === pending) {
12109
+ entry2.relationships.delete(parser);
12110
+ }
12111
+ });
12112
+ parsed = pending;
12113
+ }
12114
+ return structuredClone(await parsed);
12115
+ }
12116
+ /** Whether this reader still serves reads for its package. */
12117
+ get isOpen() {
12118
+ return !this.closed;
12119
+ }
12120
+ /** Drops every cached read; later reads of the package go to the archive. */
12121
+ close() {
12122
+ this.closed = true;
12123
+ if (openReaders.get(this.zip) === this) {
12124
+ openReaders.delete(this.zip);
12125
+ }
12126
+ this.parts.clear();
12127
+ }
12128
+ };
12129
+ function parseText(parser, text) {
12130
+ return text ? parser.parse(text) : void 0;
12131
+ }
12132
+ function readPartText(zip, path3) {
12133
+ const reader = openReaders.get(zip);
12134
+ if (reader) {
12135
+ return reader.readText(path3);
12136
+ }
12137
+ return zip.file(path3)?.async("string") ?? Promise.resolve(void 0);
12138
+ }
12139
+ async function readPartXml(zip, parser, path3) {
12140
+ const reader = openReaders.get(zip);
12141
+ if (reader) {
12142
+ return reader.readXml(parser, path3);
12143
+ }
12144
+ const text = await zip.file(path3)?.async("string");
12145
+ return text ? parseText(parser, text) : void 0;
12146
+ }
12147
+
11891
12148
  // pptx/core/core/builders/element-hidden-flag.ts
11892
12149
  var NV_CONTAINERS = [
11893
12150
  "p:nvSpPr",
@@ -11952,11 +12209,10 @@ function flattenElementsDeep(elements2) {
11952
12209
  // pptx/core/utils/slide-synchronization.ts
11953
12210
  var SLIDE_SYNC_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideSyncData+xml";
11954
12211
  async function loadSlideSynchronization(input) {
11955
- const relsXml = await input.zip.file(input.relsPath)?.async("string");
11956
- if (!relsXml) {
12212
+ const relsData = await readPartXml(input.zip, input.parser, input.relsPath);
12213
+ if (!relsData) {
11957
12214
  return void 0;
11958
12215
  }
11959
- const relsData = input.parser.parse(relsXml);
11960
12216
  const relationship2 = findSlideSyncRelationship(relsData);
11961
12217
  if (!relationship2) {
11962
12218
  return void 0;
@@ -11966,7 +12222,7 @@ async function loadSlideSynchronization(input) {
11966
12222
  return void 0;
11967
12223
  }
11968
12224
  const partPath = resolvePartPath2(input.slidePath, target);
11969
- const partXml = await input.zip.file(partPath)?.async("string");
12225
+ const partXml = await readPartText(input.zip, partPath);
11970
12226
  if (!partXml) {
11971
12227
  return void 0;
11972
12228
  }
@@ -12095,11 +12351,10 @@ function ensureArray2(value) {
12095
12351
  }
12096
12352
  async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
12097
12353
  try {
12098
- const relsXml = await zip.file(relsPath2)?.async("string");
12099
- if (!relsXml) {
12354
+ const relsData = await readPartXml(zip, parser, relsPath2);
12355
+ if (!relsData) {
12100
12356
  return [];
12101
12357
  }
12102
- const relsData = parser.parse(relsXml);
12103
12358
  const relationships2 = ensureArray2(
12104
12359
  relsData["Relationships"]?.["Relationship"]
12105
12360
  );
@@ -12122,7 +12377,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
12122
12377
  if (!resolved) {
12123
12378
  continue;
12124
12379
  }
12125
- const vmlXml = await zip.file(resolved)?.async("string");
12380
+ const vmlXml = await readPartText(zip, resolved);
12126
12381
  if (!vmlXml) {
12127
12382
  continue;
12128
12383
  }
@@ -14038,10 +14293,10 @@ function assertAfterAnimationClearSupported(effectCTn) {
14038
14293
  if (!isXmlObject3(sub)) return;
14039
14294
  const countAfterFlags = (value) => {
14040
14295
  if (Array.isArray(value))
14041
- return value.reduce((count, child16) => count + countAfterFlags(child16), 0);
14296
+ return value.reduce((count2, child16) => count2 + countAfterFlags(child16), 0);
14042
14297
  if (!isXmlObject3(value)) return 0;
14043
14298
  return Object.entries(value).reduce(
14044
- (count, [key2, child16]) => count + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child16)) ? 1 : countAfterFlags(child16)),
14299
+ (count2, [key2, child16]) => count2 + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child16)) ? 1 : countAfterFlags(child16)),
14045
14300
  0
14046
14301
  );
14047
14302
  };
@@ -14544,11 +14799,14 @@ var PptxSlideLoaderService = class {
14544
14799
  * @returns Map of relationship ID to target path string.
14545
14800
  */
14546
14801
  async loadPresentationSlideRels(params) {
14547
- const relsXml = await params.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
14548
- if (!relsXml) {
14802
+ const relsData = await readPartXml(
14803
+ params.zip,
14804
+ params.parser,
14805
+ "ppt/_rels/presentation.xml.rels"
14806
+ );
14807
+ if (!relsData) {
14549
14808
  return /* @__PURE__ */ new Map();
14550
14809
  }
14551
- const relsData = params.parser.parse(relsXml);
14552
14810
  const relationships2 = relsData["Relationships"]?.["Relationship"];
14553
14811
  const relNodes = this.toXmlObjectArray(relationships2);
14554
14812
  const relsMap = /* @__PURE__ */ new Map();
@@ -14588,7 +14846,7 @@ var PptxSlideLoaderService = class {
14588
14846
  if (!params.zip.file(path3)) {
14589
14847
  path3 = `ppt/${target}`;
14590
14848
  }
14591
- const slideXmlStr = await params.zip.file(path3)?.async("string");
14849
+ const slideXmlStr = await readPartText(params.zip, path3);
14592
14850
  if (!slideXmlStr) {
14593
14851
  return void 0;
14594
14852
  }
@@ -35428,8 +35686,8 @@ function reorderContainer(node, rawInner) {
35428
35686
  if (isGroupedByTag(children6.map((child16) => child16.tag))) {
35429
35687
  return;
35430
35688
  }
35431
- for (const [tag, count] of occurrence) {
35432
- if (ensureItems(node[tag]).length !== count) {
35689
+ for (const [tag, count2] of occurrence) {
35690
+ if (ensureItems(node[tag]).length !== count2) {
35433
35691
  return;
35434
35692
  }
35435
35693
  }
@@ -35451,8 +35709,8 @@ function annotateOmmlSiblingOrder(xml, parsed) {
35451
35709
  return;
35452
35710
  }
35453
35711
  const nodes = collectParsedOmathNodes(parsed);
35454
- const count = Math.min(fragments.length, nodes.length);
35455
- for (let index = 0; index < count; index++) {
35712
+ const count2 = Math.min(fragments.length, nodes.length);
35713
+ for (let index = 0; index < count2; index++) {
35456
35714
  if (fragments[index]) {
35457
35715
  reorderContainer(nodes[index], fragments[index]);
35458
35716
  }
@@ -36510,6 +36768,174 @@ function extractFontFromEot(data) {
36510
36768
  return { fontData, header };
36511
36769
  }
36512
36770
 
36771
+ // pptx/core/utils/deferred-embedded-font.ts
36772
+ function resolveEmbeddedFontGuid(source) {
36773
+ if (isEotFormat(source.originalPartBytes)) {
36774
+ return void 0;
36775
+ }
36776
+ const { fontKey } = source;
36777
+ const fromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
36778
+ return fromKey || extractGuidFromPartName(source.partPath) || void 0;
36779
+ }
36780
+ function hasSfntSignature(bytes) {
36781
+ if (bytes.length < 4) {
36782
+ return false;
36783
+ }
36784
+ const [v0, v1, v2, v3] = bytes;
36785
+ 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);
36786
+ }
36787
+ function warnInvalidSignature(name, bytes) {
36788
+ const hex3 = Array.from(bytes.subarray(0, 4), (b) => b.toString(16)).join(",");
36789
+ console.warn(
36790
+ `[pptx-viewer] Embedded font "${name}" has invalid sfnt header [${hex3}] after processing; skipping (web font fallback will be used)`
36791
+ );
36792
+ }
36793
+ function isEmbeddedFontPartPlausible(source) {
36794
+ const bytes = source.originalPartBytes;
36795
+ if (bytes.length === 0) {
36796
+ return false;
36797
+ }
36798
+ if (isEotFormat(bytes)) {
36799
+ return true;
36800
+ }
36801
+ const guid = resolveEmbeddedFontGuid(source);
36802
+ if (!guid) {
36803
+ console.warn(
36804
+ `[pptx-viewer] Embedded font "${source.name}" at "${source.partPath}" has no fontKey attribute and no GUID in filename; skipping`
36805
+ );
36806
+ return false;
36807
+ }
36808
+ const header = deobfuscateFont(bytes.subarray(0, Math.min(bytes.length, 32)), guid);
36809
+ if (header.length < 4) {
36810
+ return false;
36811
+ }
36812
+ if (!hasSfntSignature(header)) {
36813
+ warnInvalidSignature(source.name, header);
36814
+ return false;
36815
+ }
36816
+ return true;
36817
+ }
36818
+ function uint8ArrayToBase64(bytes) {
36819
+ let binary = "";
36820
+ const chunkSize = 8192;
36821
+ for (let i = 0; i < bytes.length; i += chunkSize) {
36822
+ const chunk = bytes.subarray(i, Math.min(i + chunkSize, bytes.length));
36823
+ for (let j = 0; j < chunk.length; j++) {
36824
+ binary += String.fromCharCode(chunk[j]);
36825
+ }
36826
+ }
36827
+ return btoa(binary);
36828
+ }
36829
+ function decodeEmbeddedFontPart(source) {
36830
+ const { name, partPath, originalPartBytes } = source;
36831
+ try {
36832
+ let fontData;
36833
+ const fontGuid = resolveEmbeddedFontGuid(source);
36834
+ if (isEotFormat(originalPartBytes)) {
36835
+ const extracted = extractFontFromEot(originalPartBytes);
36836
+ if (!extracted) {
36837
+ const header = parseEotHeader(originalPartBytes);
36838
+ console.info(
36839
+ `[pptx-viewer] Embedded font "${name}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""}; extraction failed, will use web font fallback`
36840
+ );
36841
+ return null;
36842
+ }
36843
+ fontData = extracted.fontData;
36844
+ } else if (fontGuid) {
36845
+ fontData = deobfuscateFont(originalPartBytes, fontGuid);
36846
+ } else {
36847
+ console.warn(
36848
+ `[pptx-viewer] Embedded font "${name}" at "${partPath}" has no fontKey attribute and no GUID in filename; skipping`
36849
+ );
36850
+ return null;
36851
+ }
36852
+ if (fontData.length < 4) {
36853
+ return null;
36854
+ }
36855
+ if (!hasSfntSignature(fontData)) {
36856
+ warnInvalidSignature(name, fontData);
36857
+ return null;
36858
+ }
36859
+ const format = detectFontFormat(fontData);
36860
+ const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
36861
+ return {
36862
+ name,
36863
+ dataUrl: `data:${mimeType};base64,${uint8ArrayToBase64(fontData)}`,
36864
+ bold: source.bold,
36865
+ italic: source.italic,
36866
+ format,
36867
+ rawFontData: fontData,
36868
+ partPath,
36869
+ fontGuid,
36870
+ originalRId: source.originalRId,
36871
+ originalPartBytes
36872
+ };
36873
+ } catch {
36874
+ return null;
36875
+ }
36876
+ }
36877
+ function createDeferredEmbeddedFont(source) {
36878
+ const fontGuid = resolveEmbeddedFontGuid(source);
36879
+ let fields;
36880
+ let pending;
36881
+ const decode = () => {
36882
+ if (!fields) {
36883
+ const decoded = decodeEmbeddedFontPart(source);
36884
+ fields = {
36885
+ dataUrl: decoded?.dataUrl ?? "",
36886
+ format: decoded?.format,
36887
+ rawFontData: decoded?.rawFontData
36888
+ };
36889
+ }
36890
+ return fields;
36891
+ };
36892
+ const font = {
36893
+ name: source.name,
36894
+ get dataUrl() {
36895
+ return decode().dataUrl;
36896
+ },
36897
+ set dataUrl(value) {
36898
+ decode().dataUrl = value;
36899
+ },
36900
+ bold: source.bold,
36901
+ italic: source.italic,
36902
+ get format() {
36903
+ return decode().format;
36904
+ },
36905
+ set format(value) {
36906
+ decode().format = value;
36907
+ },
36908
+ get rawFontData() {
36909
+ return decode().rawFontData;
36910
+ },
36911
+ set rawFontData(value) {
36912
+ decode().rawFontData = value;
36913
+ },
36914
+ partPath: source.partPath,
36915
+ fontGuid,
36916
+ originalRId: source.originalRId,
36917
+ originalPartBytes: source.originalPartBytes
36918
+ };
36919
+ Object.defineProperties(font, {
36920
+ load: {
36921
+ value: () => pending ??= Promise.resolve().then(
36922
+ () => decode().rawFontData?.length || decode().dataUrl ? font : null
36923
+ )
36924
+ },
36925
+ isLoaded: { get: () => fields !== void 0 }
36926
+ });
36927
+ return font;
36928
+ }
36929
+ function shouldSaveEmbeddedFontVerbatim(font) {
36930
+ if (font.isLoaded === void 0 || !font.originalPartBytes?.length) {
36931
+ return false;
36932
+ }
36933
+ if (!font.originalRId || !font.partPath) {
36934
+ return false;
36935
+ }
36936
+ return font.isLoaded === false || !font.rawFontData?.length;
36937
+ }
36938
+
36513
36939
  // pptx/core/core/runtime/header-footer-parts.ts
36514
36940
  var DEFAULT_DATE_FIELD_TYPE = "datetime1";
36515
36941
  function asArray2(value) {
@@ -38139,6 +38565,7 @@ function collectChartWorkbookWrite(xmlLookupService, container, isNumeric2, valu
38139
38565
  }
38140
38566
 
38141
38567
  // pptx/core/utils/chart-label-source.ts
38568
+ var relationshipParser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
38142
38569
  function formulaCount(value) {
38143
38570
  if (!value || typeof value !== "object") return 0;
38144
38571
  if (Array.isArray(value)) return value.reduce((total, item) => total + formulaCount(item), 0);
@@ -38186,12 +38613,11 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
38186
38613
  if (!external.targetPath || !external.embeddedWorkbookData) return false;
38187
38614
  const target = resolve(chartPartPath, external.targetPath);
38188
38615
  let references = 0;
38189
- const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
38190
38616
  try {
38191
38617
  for (const path3 of Object.keys(zip.files)) {
38192
38618
  if (!path3.endsWith(".rels") || !path3.includes("/_rels/")) continue;
38193
38619
  const source = path3.replace("/_rels/", "/").slice(0, -5);
38194
- const tree = parser.parse(await zip.file(path3).async("string"));
38620
+ const tree = await readPartXml(zip, relationshipParser, path3);
38195
38621
  for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
38196
38622
  const relationshipTarget2 = xmlAttr(rel, "Target");
38197
38623
  if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve(source, relationshipTarget2) === target)
@@ -38557,10 +38983,10 @@ function collectFilteredSeriesIndices(container, xmlLookup) {
38557
38983
  }
38558
38984
  return reserved;
38559
38985
  }
38560
- function assignSeriesIndices(count, reservedIndices) {
38986
+ function assignSeriesIndices(count2, reservedIndices) {
38561
38987
  const assigned = [];
38562
38988
  let cursor = 0;
38563
- for (let i = 0; i < count; i++) {
38989
+ for (let i = 0; i < count2; i++) {
38564
38990
  while (reservedIndices.has(cursor)) {
38565
38991
  cursor++;
38566
38992
  }
@@ -38879,8 +39305,8 @@ function parseCache(node) {
38879
39305
  return point;
38880
39306
  })
38881
39307
  };
38882
- const count = Number(cVal(node, "ptCount") ?? Number.NaN);
38883
- if (Number.isInteger(count) && count >= 0) cache.pointCount = count;
39308
+ const count2 = Number(cVal(node, "ptCount") ?? Number.NaN);
39309
+ if (Number.isInteger(count2) && count2 >= 0) cache.pointCount = count2;
38884
39310
  const formatCode2 = cChild(node, "formatCode")?.textContent;
38885
39311
  if (formatCode2) cache.formatCode = formatCode2;
38886
39312
  return cache;
@@ -38898,8 +39324,8 @@ function parseDataSource(element) {
38898
39324
  const levels = cChild(ref, "multiLvlStrCache");
38899
39325
  if (levels) {
38900
39326
  source.levels = children(levels, "lvl", NS.c).map(parseCache);
38901
- const count = Number(cVal(levels, "ptCount") ?? Number.NaN);
38902
- if (Number.isInteger(count) && count >= 0) source.levelPointCount = count;
39327
+ const count2 = Number(cVal(levels, "ptCount") ?? Number.NaN);
39328
+ if (Number.isInteger(count2) && count2 >= 0) source.levelPointCount = count2;
38903
39329
  }
38904
39330
  return source;
38905
39331
  }
@@ -40308,7 +40734,7 @@ function parseChartData(context, element) {
40308
40734
  }
40309
40735
  return out;
40310
40736
  }
40311
- function parseText(context, element) {
40737
+ function parseText2(context, element) {
40312
40738
  if (!element) return void 0;
40313
40739
  reportUnmodelled2(context, element, /* @__PURE__ */ new Set(["txData", "rich"]));
40314
40740
  const data = cxChild(element, "txData");
@@ -40329,7 +40755,7 @@ function parseTitle2(context, element) {
40329
40755
  return assignDefined(
40330
40756
  {},
40331
40757
  {
40332
- tx: parseText(context, cxChild(element, "tx")),
40758
+ tx: parseText2(context, cxChild(element, "tx")),
40333
40759
  spPr: shapeProperties2(element),
40334
40760
  txPr: textProperties2(element),
40335
40761
  position: attribute(element, "pos"),
@@ -40582,7 +41008,7 @@ function parseSeries2(context, element) {
40582
41008
  ownerIndex: numberAttribute(context, element, "ownerIdx"),
40583
41009
  uniqueId: attribute(element, "uniqueId"),
40584
41010
  formatIndex: numberAttribute(context, element, "formatIdx"),
40585
- tx: parseText(context, cxChild(element, "tx")),
41011
+ tx: parseText2(context, cxChild(element, "tx")),
40586
41012
  spPr: shapeProperties2(element),
40587
41013
  txPr: textProperties2(element),
40588
41014
  valueColorsXml: rawChild2(element, "valueColors"),
@@ -47540,9 +47966,9 @@ function buildFopt(simple, complex = []) {
47540
47966
  payload.bytes(bytes);
47541
47967
  }
47542
47968
  }
47543
- const count = simple.length + complex.length;
47969
+ const count2 = simple.length + complex.length;
47544
47970
  const data = new ByteWriter().append(entries).append(payload).toBytes();
47545
- return record(OA.FOPT, data, count, false, 3);
47971
+ return record(OA.FOPT, data, count2, false, 3);
47546
47972
  }
47547
47973
  var METRO_BLOB_OPID = 937;
47548
47974
  function buildMetroBlobTertiaryFopt(metroBlob) {
@@ -47579,9 +48005,9 @@ function buildDgg(shapesPerDrawing, totalShapes) {
47579
48005
  const cidcl = drawingCount + 1;
47580
48006
  const cspSaved = totalShapes - drawingCount;
47581
48007
  const w = new ByteWriter().u32(maxShapeId).u32(cidcl).u32(cspSaved).u32(drawingCount);
47582
- shapesPerDrawing.forEach((count, i) => {
48008
+ shapesPerDrawing.forEach((count2, i) => {
47583
48009
  const drawingId = i + 1;
47584
- w.u32(drawingId).u32(count);
48010
+ w.u32(drawingId).u32(count2);
47585
48011
  });
47586
48012
  return record(OA.Dgg, w.toBytes(), 0, false, 0);
47587
48013
  }
@@ -48378,8 +48804,8 @@ function atom(recType, data) {
48378
48804
  function textHeader(textType) {
48379
48805
  return atom(RT.TextHeaderAtom, new ByteWriter().u32(textType).toBytes());
48380
48806
  }
48381
- function textSpecInfo(count) {
48382
- return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count).u32(1).u16(0).toBytes());
48807
+ function textSpecInfo(count2) {
48808
+ return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count2).u32(1).u16(0).toBytes());
48383
48809
  }
48384
48810
  function promptText(textType, paragraphs) {
48385
48811
  const text = paragraphs.join("\r");
@@ -49027,17 +49453,17 @@ function slideMasterIndex(masterIndex, masterCount) {
49027
49453
  return masterIndex !== void 0 && Number.isInteger(masterIndex) && masterIndex >= 0 && masterIndex < masterCount ? masterIndex : 0;
49028
49454
  }
49029
49455
  function countDrawingShapes(shapes) {
49030
- let count = 1;
49456
+ let count2 = 1;
49031
49457
  const walk = (list2) => {
49032
49458
  for (const shape of list2) {
49033
- count++;
49459
+ count2++;
49034
49460
  if (shape.kind === "group") {
49035
49461
  walk(shape.children);
49036
49462
  }
49037
49463
  }
49038
49464
  };
49039
49465
  walk(shapes);
49040
- return count;
49466
+ return count2;
49041
49467
  }
49042
49468
  function collectFonts(deck, masters) {
49043
49469
  const collect = (shape) => {
@@ -49546,7 +49972,7 @@ function toLevel(style = {}, themeFonts = {}) {
49546
49972
  }
49547
49973
  };
49548
49974
  }
49549
- function toLevels(levels, count, themeFonts) {
49975
+ function toLevels(levels, count2, themeFonts) {
49550
49976
  if (!levels) {
49551
49977
  return void 0;
49552
49978
  }
@@ -49556,7 +49982,7 @@ function toLevels(levels, count, themeFonts) {
49556
49982
  }
49557
49983
  const base = levels[-1];
49558
49984
  return Array.from(
49559
- { length: count },
49985
+ { length: count2 },
49560
49986
  (_, i) => toLevel(base || levels[i] ? { ...base, ...levels[i] } : void 0, themeFonts)
49561
49987
  );
49562
49988
  }
@@ -50392,12 +50818,12 @@ function visitGraphicData(node, relationshipId, extended, getLocalName2) {
50392
50818
  }
50393
50819
  if (Array.isArray(node)) {
50394
50820
  return node.reduce(
50395
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId, extended, getLocalName2),
50821
+ (count3, entry2) => count3 + visitGraphicData(entry2, relationshipId, extended, getLocalName2),
50396
50822
  0
50397
50823
  );
50398
50824
  }
50399
50825
  const object = node;
50400
- let count = 0;
50826
+ let count2 = 0;
50401
50827
  for (const key2 of Object.keys(object)) {
50402
50828
  if (key2.startsWith("@_")) {
50403
50829
  continue;
@@ -50409,14 +50835,14 @@ function visitGraphicData(node, relationshipId, extended, getLocalName2) {
50409
50835
  const chart = chartKey ? candidate[chartKey] : void 0;
50410
50836
  if (chart && String(chart["@_r:id"]) === relationshipId) {
50411
50837
  rebindGraphicData(candidate, relationshipId, extended);
50412
- count += 1;
50838
+ count2 += 1;
50413
50839
  }
50414
50840
  }
50415
50841
  continue;
50416
50842
  }
50417
- count += visitGraphicData(value, relationshipId, extended, getLocalName2);
50843
+ count2 += visitGraphicData(value, relationshipId, extended, getLocalName2);
50418
50844
  }
50419
- return count;
50845
+ return count2;
50420
50846
  }
50421
50847
  async function rewriteChartGraphicFrames(deps, slidePath, relationshipId, extended) {
50422
50848
  const xml = await deps.zip.file(slidePath)?.async("string");
@@ -50424,11 +50850,11 @@ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId, extend
50424
50850
  return 0;
50425
50851
  }
50426
50852
  const tree = deps.parser.parse(xml);
50427
- const count = visitGraphicData(tree, relationshipId, extended, deps.getLocalName);
50428
- if (count > 0) {
50853
+ const count2 = visitGraphicData(tree, relationshipId, extended, deps.getLocalName);
50854
+ if (count2 > 0) {
50429
50855
  deps.zip.file(slidePath, deps.builder.build(tree));
50430
50856
  }
50431
- return count;
50857
+ return count2;
50432
50858
  }
50433
50859
 
50434
50860
  // pptx/core/utils/chart-color-style-writer.ts
@@ -52963,8 +53389,8 @@ async function discoverTagCollections(zip, codec) {
52963
53389
  if (!sourcePartPath) {
52964
53390
  continue;
52965
53391
  }
52966
- const data = codec.parse(await relFile.async("string"));
52967
- const root = data["Relationships"];
53392
+ const data = await readPartXml(zip, codec, relFile.name);
53393
+ const root = data?.["Relationships"];
52968
53394
  for (const relationship2 of ensureArray10(root?.["Relationship"])) {
52969
53395
  if (String(relationship2["@_Type"] ?? "") !== TAG_RELATIONSHIP_TYPE) {
52970
53396
  continue;
@@ -53069,7 +53495,7 @@ async function removeTagContentTypeOverride(zip, codec, path3) {
53069
53495
  zip.file("[Content_Types].xml", codec.build(data));
53070
53496
  }
53071
53497
  async function readTagCollection(zip, codec, path3) {
53072
- const xml = await zip.file(path3)?.async("string");
53498
+ const xml = await readPartText(zip, path3);
53073
53499
  if (!xml) {
53074
53500
  return void 0;
53075
53501
  }
@@ -58189,6 +58615,30 @@ var TemplateElementBaselineTracker = class {
58189
58615
  var PptxHandlerRuntime = class {
58190
58616
  /** The in-memory ZIP archive representing the OPC (.pptx) package. */
58191
58617
  zip;
58618
+ /** Shares part reads within the load in progress; see {@link LoadPartReader}. */
58619
+ loadPartReader;
58620
+ /** Opens a part reader for the current package, closing any earlier one. */
58621
+ beginPartReads() {
58622
+ this.endPartReads();
58623
+ const reader = new LoadPartReader(this.zip);
58624
+ this.loadPartReader = reader;
58625
+ return reader;
58626
+ }
58627
+ /** Closes `reader` (by default the open one) and releases its cached reads. */
58628
+ endPartReads(reader = this.loadPartReader) {
58629
+ reader?.close();
58630
+ if (reader && this.loadPartReader === reader) {
58631
+ this.loadPartReader = void 0;
58632
+ }
58633
+ }
58634
+ /** The text of a package part, shared within a load. */
58635
+ readPartText(path3) {
58636
+ return readPartText(this.zip, path3);
58637
+ }
58638
+ /** A parsed package part; relationship parts are parsed once per load. */
58639
+ readPartXml(path3) {
58640
+ return readPartXml(this.zip, this.parser, path3);
58641
+ }
58192
58642
  /** fast-xml-parser instance used to parse XML strings into JS objects. */
58193
58643
  parser;
58194
58644
  /** fast-xml-parser builder used to serialize JS objects back to XML strings. */
@@ -58452,6 +58902,8 @@ var PptxHandlerRuntime = class {
58452
58902
  alternateContentBlockByRawXml = /* @__PURE__ */ new WeakMap();
58453
58903
  /** Embedded fonts extracted during load, preserved for automatic re-embedding on save. */
58454
58904
  loadedEmbeddedFonts = [];
58905
+ /** Decode every embedded font variant during load (see `PptxHandlerLoadOptions`). */
58906
+ eagerDecodeEmbeddedFonts = false;
58455
58907
  /** Typed source metadata for lossless embedded-font list round trips. */
58456
58908
  loadedEmbeddedFontList;
58457
58909
  /**
@@ -58607,11 +59059,11 @@ var PptxHandlerRuntime = class {
58607
59059
  * @param relsPath - Path of the `.rels` part; derived from `partPath` when omitted.
58608
59060
  */
58609
59061
  async loadPartRelationships(partPath, relsPath2) {
58610
- const relsXml = await this.zip.file(relsPath2 ?? partRelsPath(partPath))?.async("string");
58611
- if (!relsXml) {
59062
+ const path3 = relsPath2 ?? partRelsPath(partPath);
59063
+ const relsData = await this.readPartXml(path3);
59064
+ if (!relsData) {
58612
59065
  return;
58613
59066
  }
58614
- const relsData = this.parser.parse(relsXml);
58615
59067
  const relationships2 = relsData?.["Relationships"];
58616
59068
  const raw2 = relationships2?.["Relationship"];
58617
59069
  const entries = Array.isArray(raw2) ? raw2 : raw2 ? [raw2] : [];
@@ -60057,10 +60509,6 @@ var PptxHandlerRuntime8 = class extends PptxHandlerRuntime7 {
60057
60509
  this.zip.file(relsPath2, this.builder.build(relsData));
60058
60510
  return true;
60059
60511
  }
60060
- /** The text of a package part, or `undefined` when the package has no such part. */
60061
- async readPartText(path3) {
60062
- return this.zip.file(path3)?.async("string");
60063
- }
60064
60512
  /**
60065
60513
  * Parse extended (application) properties from `docProps/app.xml`.
60066
60514
  */
@@ -60121,8 +60569,10 @@ var PptxHandlerRuntime8 = class extends PptxHandlerRuntime7 {
60121
60569
  if (!relsFile) {
60122
60570
  return [];
60123
60571
  }
60124
- const relsXml = await relsFile.async("string");
60125
- const relsData = this.parser.parse(relsXml);
60572
+ const relsData = await this.readPartXml(relsPath2);
60573
+ if (!relsData) {
60574
+ return [];
60575
+ }
60126
60576
  const relRoot = relsData["Relationships"] || {};
60127
60577
  const relationships2 = this.ensureArray(relRoot["Relationship"]);
60128
60578
  const relMap = /* @__PURE__ */ new Map();
@@ -60153,7 +60603,7 @@ var PptxHandlerRuntime8 = class extends PptxHandlerRuntime7 {
60153
60603
  try {
60154
60604
  const file = this.zip.file(resolvedPath);
60155
60605
  if (file) {
60156
- data = await file.async("string");
60606
+ data = await this.readPartText(resolvedPath);
60157
60607
  }
60158
60608
  } catch {
60159
60609
  }
@@ -60233,9 +60683,7 @@ var PptxHandlerRuntime8 = class extends PptxHandlerRuntime7 {
60233
60683
  */
60234
60684
  async parseTags() {
60235
60685
  try {
60236
- return await discoverTagCollections(this.zip, {
60237
- parse: (xml) => this.parser.parse(xml)
60238
- });
60686
+ return await discoverTagCollections(this.zip, this.parser);
60239
60687
  } catch (e) {
60240
60688
  console.warn("Failed to parse tags:", e);
60241
60689
  return [];
@@ -60359,7 +60807,7 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
60359
60807
  }
60360
60808
  for (const file of masterFiles) {
60361
60809
  const path3 = file.name;
60362
- const xml = await file.async("string");
60810
+ const xml = await this.readPartText(path3) ?? "";
60363
60811
  const data = this.parser.parse(xml);
60364
60812
  const sldMaster = data?.["p:sldMaster"];
60365
60813
  if (!sldMaster) {
@@ -60384,8 +60832,7 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
60384
60832
  );
60385
60833
  const relsFile = this.zip.file(relsPath2);
60386
60834
  if (relsFile) {
60387
- const relsXml = await relsFile.async("string");
60388
- const relsData = this.parser.parse(relsXml);
60835
+ const relsData = await this.readPartXml(relsPath2);
60389
60836
  const rels = this.ensureArray(
60390
60837
  xmlChild(relsData, "Relationships")?.["Relationship"]
60391
60838
  );
@@ -60399,8 +60846,7 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
60399
60846
  }
60400
60847
  const layoutPaths = [];
60401
60848
  if (relsFile) {
60402
- const relsXml = await relsFile.async("string");
60403
- const relsData = this.parser.parse(relsXml);
60849
+ const relsData = await this.readPartXml(relsPath2);
60404
60850
  const rels = this.ensureArray(
60405
60851
  xmlChild(relsData, "Relationships")?.["Relationship"]
60406
60852
  );
@@ -60444,7 +60890,7 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
60444
60890
  return void 0;
60445
60891
  }
60446
60892
  const path3 = files[0].name;
60447
- const xml = await files[0].async("string");
60893
+ const xml = await this.readPartText(path3) ?? "";
60448
60894
  const data = this.parser.parse(xml);
60449
60895
  const master = data?.["p:handoutMaster"];
60450
60896
  if (!master) {
@@ -60476,7 +60922,7 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
60476
60922
  return void 0;
60477
60923
  }
60478
60924
  const path3 = files[0].name;
60479
- const xml = await files[0].async("string");
60925
+ const xml = await this.readPartText(path3) ?? "";
60480
60926
  const data = this.parser.parse(xml);
60481
60927
  const master = data?.["p:notesMaster"];
60482
60928
  if (!master) {
@@ -60507,7 +60953,7 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
60507
60953
  if (!layoutFile) {
60508
60954
  return void 0;
60509
60955
  }
60510
- const xml = await layoutFile.async("string");
60956
+ const xml = await this.readPartText(layoutPath) ?? "";
60511
60957
  const data = this.parser.parse(xml);
60512
60958
  const sldLayout = data?.["p:sldLayout"];
60513
60959
  if (!sldLayout) {
@@ -60601,18 +61047,19 @@ var PptxHandlerRuntime10 = class extends PptxHandlerRuntime9 {
60601
61047
  */
60602
61048
  async parsePresentationProperties() {
60603
61049
  try {
60604
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
60605
- if (!relsXml) {
61050
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
61051
+ if (!relsData) {
60606
61052
  return void 0;
60607
61053
  }
60608
- const relsData = this.parser.parse(relsXml);
60609
- const rels = this.ensureArray(relsData?.Relationships?.Relationship);
61054
+ const rels = this.ensureArray(
61055
+ relsData.Relationships?.Relationship
61056
+ );
60610
61057
  const prRel = rels.find(
60611
61058
  (r) => String(r?.["@_Type"] || "").includes("presProps") || String(r?.["@_Target"] || "").includes("presProps")
60612
61059
  );
60613
61060
  const prTarget = prRel ? String(prRel["@_Target"] || "") : "presProps.xml";
60614
61061
  const prPath = prTarget.startsWith("/") ? prTarget.substring(1) : `ppt/${prTarget}`;
60615
- const prXmlStr = await this.zip.file(prPath)?.async("string");
61062
+ const prXmlStr = await this.readPartText(prPath);
60616
61063
  if (!prXmlStr) {
60617
61064
  return void 0;
60618
61065
  }
@@ -60658,7 +61105,7 @@ var PptxHandlerRuntime10 = class extends PptxHandlerRuntime9 {
60658
61105
  */
60659
61106
  async parseViewProperties() {
60660
61107
  try {
60661
- const viewPropsXml2 = await this.zip.file("ppt/viewProps.xml")?.async("string");
61108
+ const viewPropsXml2 = await this.readPartText("ppt/viewProps.xml");
60662
61109
  if (!viewPropsXml2) {
60663
61110
  return void 0;
60664
61111
  }
@@ -63049,10 +63496,10 @@ function detectDominantScript(text) {
63049
63496
  }
63050
63497
  let best;
63051
63498
  let bestCount = 0;
63052
- for (const [cat, count] of Object.entries(counts)) {
63053
- if (count > bestCount) {
63499
+ for (const [cat, count2] of Object.entries(counts)) {
63500
+ if (count2 > bestCount) {
63054
63501
  best = cat;
63055
- bestCount = count;
63502
+ bestCount = count2;
63056
63503
  }
63057
63504
  }
63058
63505
  return best;
@@ -64867,7 +65314,7 @@ var PptxHandlerRuntime23 = class extends PptxHandlerRuntime22 {
64867
65314
  if (existingRel?.target) {
64868
65315
  drawingPath = this.resolveImagePath(chartPartPath, existingRel.target);
64869
65316
  try {
64870
- const xml = await this.zip.file(drawingPath)?.async("string");
65317
+ const xml = await this.readPartText(drawingPath);
64871
65318
  if (xml) {
64872
65319
  const root = this.parser.parse(xml);
64873
65320
  onDisk = parseChartUserShapesDrawing(root, this.xmlLookupService, {
@@ -64918,11 +65365,10 @@ var PptxHandlerRuntime23 = class extends PptxHandlerRuntime22 {
64918
65365
  const slash = chartPartPath.lastIndexOf("/");
64919
65366
  const relsPath2 = `${chartPartPath.slice(0, slash + 1)}_rels/${chartPartPath.slice(slash + 1)}.rels`;
64920
65367
  try {
64921
- const xml = await this.zip.file(relsPath2)?.async("string");
64922
- if (!xml) {
65368
+ const tree = await this.readPartXml(relsPath2);
65369
+ if (!tree) {
64923
65370
  return void 0;
64924
65371
  }
64925
- const tree = this.parser.parse(xml);
64926
65372
  const root = tree["Relationships"];
64927
65373
  const rels = root?.["Relationship"];
64928
65374
  const list2 = rels === void 0 ? [] : Array.isArray(rels) ? rels : [rels];
@@ -68186,7 +68632,9 @@ var PptxHandlerRuntime25 = class _PptxHandlerRuntime extends PptxHandlerRuntime2
68186
68632
  return;
68187
68633
  }
68188
68634
  const fonts = explicitFonts ?? this.loadedEmbeddedFonts;
68189
- const fontsWithData = fonts.filter((f) => f.rawFontData && f.rawFontData.length > 0);
68635
+ const fontsWithData = fonts.filter(
68636
+ (f) => shouldSaveEmbeddedFontVerbatim(f) || f.rawFontData && f.rawFontData.length > 0
68637
+ );
68190
68638
  if (fontsWithData.length === 0) {
68191
68639
  const metadata = explicitFontList ?? this.loadedEmbeddedFontList;
68192
68640
  if (metadata && this.presentationData) {
@@ -68229,10 +68677,11 @@ var PptxHandlerRuntime25 = class _PptxHandlerRuntime extends PptxHandlerRuntime2
68229
68677
  "p:font": { "@_typeface": typeface }
68230
68678
  };
68231
68679
  for (const variant of variants) {
68232
- const fontData = variant.rawFontData;
68680
+ const verbatim = shouldSaveEmbeddedFontVerbatim(variant);
68681
+ const fontData = verbatim ? void 0 : variant.rawFontData;
68233
68682
  const hasOriginal = Boolean(variant.originalRId && variant.partPath);
68234
- const reuseObfuscation = hasOriginal && Boolean(variant.fontGuid);
68235
- const reuseVerbatim = hasOriginal && !variant.fontGuid && Boolean(variant.originalPartBytes);
68683
+ const reuseObfuscation = hasOriginal && !verbatim && Boolean(variant.fontGuid);
68684
+ const reuseVerbatim = hasOriginal && (verbatim || !variant.fontGuid) && Boolean(variant.originalPartBytes);
68236
68685
  let guid;
68237
68686
  let fontPartPath;
68238
68687
  let relativeTarget4;
@@ -71674,13 +72123,13 @@ function countDeclaredIds(node, counts, ensureArray12) {
71674
72123
  if (!countDeclaredIds(branch, branchCounts, ensureArray12)) {
71675
72124
  return false;
71676
72125
  }
71677
- for (const [id, count] of branchCounts) {
71678
- merged.set(id, Math.max(merged.get(id) ?? 0, count));
72126
+ for (const [id, count2] of branchCounts) {
72127
+ merged.set(id, Math.max(merged.get(id) ?? 0, count2));
71679
72128
  }
71680
72129
  }
71681
72130
  }
71682
- for (const [id, count] of merged) {
71683
- counts.set(id, (counts.get(id) ?? 0) + count);
72131
+ for (const [id, count2] of merged) {
72132
+ counts.set(id, (counts.get(id) ?? 0) + count2);
71684
72133
  }
71685
72134
  }
71686
72135
  return true;
@@ -71690,8 +72139,8 @@ function hasStructuralIdDefects(spTree, ensureArray12) {
71690
72139
  if (!countDeclaredIds(spTree, counts, ensureArray12)) {
71691
72140
  return true;
71692
72141
  }
71693
- for (const count of counts.values()) {
71694
- if (count > 1) {
72142
+ for (const count2 of counts.values()) {
72143
+ if (count2 > 1) {
71695
72144
  return true;
71696
72145
  }
71697
72146
  }
@@ -79523,7 +79972,7 @@ var PptxHandlerRuntime71 = class extends PptxHandlerRuntime70 {
79523
79972
  this.unwrapAlternateContent(spTree);
79524
79973
  let rawXmlStr;
79525
79974
  try {
79526
- rawXmlStr = await this.zip.file(slidePath)?.async("string") ?? void 0;
79975
+ rawXmlStr = await this.readPartText(slidePath);
79527
79976
  } catch {
79528
79977
  }
79529
79978
  const slidePrefix = slidePath ? `${slidePath}-` : "";
@@ -80076,7 +80525,7 @@ var PptxHandlerRuntime73 = class extends PptxHandlerRuntime72 {
80076
80525
  if (cached) {
80077
80526
  return cached;
80078
80527
  }
80079
- const xml = await this.zip.file(layoutPath)?.async("string");
80528
+ const xml = await this.readPartText(layoutPath);
80080
80529
  if (!xml) {
80081
80530
  return void 0;
80082
80531
  }
@@ -80090,7 +80539,7 @@ var PptxHandlerRuntime73 = class extends PptxHandlerRuntime72 {
80090
80539
  if (cached) {
80091
80540
  return cached;
80092
80541
  }
80093
- const xml = await this.zip.file(masterPath)?.async("string");
80542
+ const xml = await this.readPartText(masterPath);
80094
80543
  if (!xml) {
80095
80544
  return void 0;
80096
80545
  }
@@ -80541,7 +80990,7 @@ var PptxHandlerRuntime74 = class extends PptxHandlerRuntime73 {
80541
80990
  if (!notesPath) {
80542
80991
  return {};
80543
80992
  }
80544
- const notesXml = await this.zip.file(notesPath)?.async("string");
80993
+ const notesXml = await this.readPartText(notesPath);
80545
80994
  if (!notesXml) {
80546
80995
  return {};
80547
80996
  }
@@ -81015,7 +81464,7 @@ var PptxHandlerRuntime77 = class extends PptxHandlerRuntime76 {
81015
81464
  try {
81016
81465
  let masterXmlObj = this.masterXmlMap.get(master.path);
81017
81466
  if (!masterXmlObj) {
81018
- const xmlStr = await this.zip.file(master.path)?.async("string");
81467
+ const xmlStr = await this.readPartText(master.path);
81019
81468
  if (!xmlStr) {
81020
81469
  continue;
81021
81470
  }
@@ -81088,7 +81537,7 @@ var PptxHandlerRuntime77 = class extends PptxHandlerRuntime76 {
81088
81537
  }
81089
81538
  const masterToken = masterPath.split("/").pop()?.replace(/\.xml$/u, "") ?? masterPath;
81090
81539
  try {
81091
- const masterXmlStr = await this.zip.file(masterPath)?.async("string");
81540
+ const masterXmlStr = await this.readPartText(masterPath);
81092
81541
  if (!masterXmlStr) {
81093
81542
  return [];
81094
81543
  }
@@ -81239,7 +81688,7 @@ var PptxHandlerRuntime78 = class extends PptxHandlerRuntime77 {
81239
81688
  }
81240
81689
  const partPath = part.path;
81241
81690
  rememberMasterPartBackground(this, partPath, part.backgroundColor);
81242
- const xml = await this.zip.file(partPath)?.async("string");
81691
+ const xml = await this.readPartText(partPath);
81243
81692
  if (!xml) {
81244
81693
  return;
81245
81694
  }
@@ -81390,7 +81839,7 @@ var PptxHandlerRuntime79 = class extends PptxHandlerRuntime78 {
81390
81839
  }
81391
81840
  const layoutToken = layoutPath.split("/").pop()?.replace(/\.xml$/u, "") ?? layoutPath;
81392
81841
  try {
81393
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
81842
+ const layoutXmlStr = await this.readPartText(layoutPath);
81394
81843
  if (!layoutXmlStr) {
81395
81844
  return [];
81396
81845
  }
@@ -82103,7 +82552,7 @@ var PptxHandlerRuntime82 = class extends PptxHandlerRuntime81 {
82103
82552
  return cached;
82104
82553
  }
82105
82554
  try {
82106
- const overrideXml = await this.zip.file(overridePath)?.async("string");
82555
+ const overrideXml = await this.readPartText(overridePath);
82107
82556
  if (!overrideXml) {
82108
82557
  return null;
82109
82558
  }
@@ -82700,10 +83149,7 @@ var PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
82700
83149
  if (!relsXml) {
82701
83150
  return void 0;
82702
83151
  }
82703
- const relsData = this.parser.parse(
82704
- // eslint-disable-next-line no-await-in-loop
82705
- await relsXml.async("string")
82706
- );
83152
+ const relsData = await this.readPartXml(relsPath2);
82707
83153
  const relNodes = this.ensureArray(
82708
83154
  relsData?.Relationships?.Relationship
82709
83155
  );
@@ -82729,7 +83175,7 @@ var PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
82729
83175
  const options = [];
82730
83176
  for (const file of themeFiles) {
82731
83177
  try {
82732
- const xml = await file.async("string");
83178
+ const xml = await this.readPartText(file.name) ?? "";
82733
83179
  const data = this.parser.parse(xml);
82734
83180
  const root = data["a:theme"];
82735
83181
  const name = String(root?.["@_name"] || "").trim();
@@ -82809,7 +83255,7 @@ var PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
82809
83255
  ];
82810
83256
  for (const file of masterFiles) {
82811
83257
  try {
82812
- const masterXml = await file.async("string");
83258
+ const masterXml = await this.readPartText(file.name) ?? "";
82813
83259
  const masterData = this.parser.parse(masterXml);
82814
83260
  const clrMap = masterData?.["p:sldMaster"]?.["p:clrMap"];
82815
83261
  if (!clrMap) {
@@ -82842,7 +83288,7 @@ var PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
82842
83288
  if (!themeFile) {
82843
83289
  return null;
82844
83290
  }
82845
- const themeXml3 = await themeFile.async("string");
83291
+ const themeXml3 = await this.readPartText(themePath) ?? "";
82846
83292
  const model = this.parseThemePartXml(themeXml3);
82847
83293
  this.cacheThemePartModel(themePath, themeXml3, model);
82848
83294
  return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
@@ -82877,7 +83323,7 @@ var PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
82877
83323
  if (!relsXml) {
82878
83324
  return void 0;
82879
83325
  }
82880
- const relsData = this.parser.parse(await relsXml.async("string"));
83326
+ const relsData = await this.readPartXml(relsPath2);
82881
83327
  const relNodes = this.ensureArray(
82882
83328
  relsData?.Relationships?.Relationship
82883
83329
  );
@@ -83184,11 +83630,10 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83184
83630
  async extractModernSlideComments(slidePath) {
83185
83631
  try {
83186
83632
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
83187
- const relsXml = await this.zip.file(relsPath2)?.async("string");
83188
- if (!relsXml) {
83633
+ const relsData = await this.readPartXml(relsPath2);
83634
+ if (!relsData) {
83189
83635
  return [];
83190
83636
  }
83191
- const relsData = this.parser.parse(relsXml);
83192
83637
  const rels = this.ensureArray(
83193
83638
  xmlChild(relsData, "Relationships")?.Relationship
83194
83639
  );
@@ -83205,7 +83650,7 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83205
83650
  continue;
83206
83651
  }
83207
83652
  const filePath = this.resolvePath(slidePath, target);
83208
- const xml = await this.zip.file(filePath)?.async("string");
83653
+ const xml = await this.readPartText(filePath);
83209
83654
  if (!xml) {
83210
83655
  continue;
83211
83656
  }
@@ -83228,11 +83673,10 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83228
83673
  return [];
83229
83674
  }
83230
83675
  async loadModernCommentAuthors() {
83231
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
83232
- if (!relsXml) {
83676
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
83677
+ if (!relsData) {
83233
83678
  return;
83234
83679
  }
83235
- const relsData = this.parser.parse(relsXml);
83236
83680
  const relationships2 = this.ensureArray(
83237
83681
  xmlChild(relsData, "Relationships")?.Relationship
83238
83682
  );
@@ -83244,7 +83688,7 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83244
83688
  return;
83245
83689
  }
83246
83690
  const partPath = this.resolvePath("ppt/presentation.xml", target);
83247
- const xml = await this.zip.file(partPath)?.async("string");
83691
+ const xml = await this.readPartText(partPath);
83248
83692
  if (!xml) {
83249
83693
  return;
83250
83694
  }
@@ -83270,12 +83714,12 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83270
83714
  }
83271
83715
  }
83272
83716
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
83273
- const relsXml = await this.zip.file(relsPath2)?.async("string");
83717
+ const relsXml = await this.readPartText(relsPath2);
83274
83718
  if (!relsXml) {
83275
83719
  return void 0;
83276
83720
  }
83277
83721
  try {
83278
- const relsData = this.parser.parse(relsXml);
83722
+ const relsData = await this.readPartXml(relsPath2);
83279
83723
  const rels = this.ensureArray(
83280
83724
  xmlChild(relsData, "Relationships")?.Relationship
83281
83725
  );
@@ -83314,7 +83758,7 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83314
83758
  return [];
83315
83759
  }
83316
83760
  const commentsPath = this.resolveImagePath(slidePath, commentTarget);
83317
- const commentsXml = await this.zip.file(commentsPath)?.async("string");
83761
+ const commentsXml = await this.readPartText(commentsPath);
83318
83762
  if (!commentsXml) {
83319
83763
  return [];
83320
83764
  }
@@ -83349,7 +83793,7 @@ var PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
83349
83793
  }
83350
83794
  }
83351
83795
  async loadCommentAuthors() {
83352
- const commentAuthorsXml = await this.zip.file("ppt/commentAuthors.xml")?.async("string");
83796
+ const commentAuthorsXml = await this.readPartText("ppt/commentAuthors.xml");
83353
83797
  if (!commentAuthorsXml) {
83354
83798
  return;
83355
83799
  }
@@ -83411,7 +83855,7 @@ var PptxHandlerRuntime89 = class extends PptxHandlerRuntime88 {
83411
83855
  return void 0;
83412
83856
  }
83413
83857
  const partPath = this.resolveImagePath(slidePath, target);
83414
- const xmlString = await this.zip.file(partPath)?.async("string");
83858
+ const xmlString = await this.readPartText(partPath);
83415
83859
  if (!xmlString) {
83416
83860
  return void 0;
83417
83861
  }
@@ -85023,9 +85467,8 @@ var PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
85023
85467
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
85024
85468
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
85025
85469
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
85026
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
85027
- if (chartRelsXml) {
85028
- const chartRelsData = this.parser.parse(chartRelsXml);
85470
+ const chartRelsData = await this.readPartXml(chartRelsPath);
85471
+ if (chartRelsData) {
85029
85472
  const relsContainer = chartRelsData?.Relationships;
85030
85473
  if (relsContainer?.Relationship) {
85031
85474
  const rels = Array.isArray(relsContainer.Relationship) ? relsContainer.Relationship : [relsContainer.Relationship];
@@ -85107,7 +85550,7 @@ var PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
85107
85550
  if (drawingPath.length === 0) {
85108
85551
  return void 0;
85109
85552
  }
85110
- const drawingXml = await this.zip.file(drawingPath)?.async("string");
85553
+ const drawingXml = await this.readPartText(drawingPath);
85111
85554
  if (!drawingXml) {
85112
85555
  return void 0;
85113
85556
  }
@@ -85128,11 +85571,10 @@ var PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
85128
85571
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
85129
85572
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
85130
85573
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
85131
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
85132
- if (!chartRelsXml) {
85574
+ const chartRelsData = await this.readPartXml(chartRelsPath);
85575
+ if (!chartRelsData) {
85133
85576
  return [];
85134
85577
  }
85135
- const chartRelsData = this.parser.parse(chartRelsXml);
85136
85578
  const relsContainer = chartRelsData?.Relationships;
85137
85579
  if (!relsContainer?.Relationship) {
85138
85580
  return [];
@@ -85961,11 +86403,10 @@ var PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
85961
86403
  async loadPresentationFontRels() {
85962
86404
  const map = /* @__PURE__ */ new Map();
85963
86405
  try {
85964
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
85965
- if (!relsXml) {
86406
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
86407
+ if (!relsData) {
85966
86408
  return map;
85967
86409
  }
85968
- const relsData = this.parser.parse(relsXml);
85969
86410
  const rels = this.ensureArray(
85970
86411
  xmlChild(relsData, "Relationships")?.Relationship
85971
86412
  );
@@ -85984,7 +86425,13 @@ var PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
85984
86425
  }
85985
86426
  return map;
85986
86427
  }
85987
- /** Extract, de-obfuscate, and encode a single font variant. */
86428
+ /**
86429
+ * Read one variant's part. By default the result is a deferred descriptor
86430
+ * that decodes on first use (see `createDeferredEmbeddedFont`); parts that
86431
+ * fail the checks possible without decoding are skipped, as before. With
86432
+ * `eagerDecodeEmbeddedFonts` the variant is decoded now and skipped when
86433
+ * decoding fails.
86434
+ */
85988
86435
  async extractEmbeddedFontVariant(typeface, rId, bold, italic, relsMap, fontKey) {
85989
86436
  const fontPath = relsMap.get(rId);
85990
86437
  if (!fontPath) {
@@ -85995,80 +86442,25 @@ var PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
85995
86442
  if (!fontBinary || fontBinary.length === 0) {
85996
86443
  return null;
85997
86444
  }
85998
- const originalPartBytes = new Uint8Array(fontBinary);
85999
- let fontData;
86000
- let resolvedGuid;
86001
- if (isEotFormat(fontBinary)) {
86002
- const extracted = extractFontFromEot(fontBinary);
86003
- if (extracted) {
86004
- fontData = extracted.fontData;
86005
- } else {
86006
- const header = parseEotHeader(fontBinary);
86007
- console.info(
86008
- `[pptx-viewer] Embedded font "${typeface}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""} \u2014 extraction failed, will use web font fallback`
86009
- );
86010
- return null;
86011
- }
86012
- } else {
86013
- const guidFromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
86014
- const guidFromPath = extractGuidFromPartName(fontPath);
86015
- const guid = guidFromKey || guidFromPath;
86016
- if (guid) {
86017
- fontData = deobfuscateFont(fontBinary, guid);
86018
- resolvedGuid = guid;
86019
- } else {
86020
- console.warn(
86021
- `[pptx-viewer] Embedded font "${typeface}" at "${fontPath}" has no fontKey attribute and no GUID in filename \u2014 skipping`
86022
- );
86023
- return null;
86024
- }
86025
- }
86026
- if (fontData.length < 4) {
86027
- return null;
86028
- }
86029
- const v0 = fontData[0], v1 = fontData[1], v2 = fontData[2], v3 = fontData[3];
86030
- const isTrueType = v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0;
86031
- const isOTTO = v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79;
86032
- const isTTC = v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102;
86033
- const isWOFF = v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
86034
- if (!(isTrueType || isOTTO || isTTC || isWOFF)) {
86035
- console.warn(
86036
- `[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)`
86037
- );
86038
- return null;
86039
- }
86040
- const format = detectFontFormat(fontData);
86041
- const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
86042
- const base64 = this.uint8ArrayToBase64(fontData);
86043
- const dataUrl = `data:${mimeType};base64,${base64}`;
86044
- return {
86445
+ const source = {
86045
86446
  name: typeface,
86046
- dataUrl,
86047
86447
  bold,
86048
86448
  italic,
86049
- format,
86050
- rawFontData: fontData,
86051
- partPath: fontPath,
86052
- fontGuid: resolvedGuid,
86053
86449
  originalRId: rId,
86054
- originalPartBytes
86450
+ partPath: fontPath,
86451
+ // The descriptor owns a copy, so it outlives this handler's ZIP and
86452
+ // the save pipeline can write it back verbatim.
86453
+ originalPartBytes: new Uint8Array(fontBinary),
86454
+ fontKey
86055
86455
  };
86456
+ if (this.eagerDecodeEmbeddedFonts) {
86457
+ return decodeEmbeddedFontPart(source);
86458
+ }
86459
+ return isEmbeddedFontPartPlausible(source) ? createDeferredEmbeddedFont(source) : null;
86056
86460
  } catch {
86057
86461
  return null;
86058
86462
  }
86059
86463
  }
86060
- /** Convert Uint8Array to base64 string. */
86061
- uint8ArrayToBase64(bytes) {
86062
- let binary = "";
86063
- const chunkSize = 8192;
86064
- for (let i = 0; i < bytes.length; i += chunkSize) {
86065
- const chunk = bytes.subarray(i, Math.min(i + chunkSize, bytes.length));
86066
- for (let j = 0; j < chunk.length; j++) {
86067
- binary += String.fromCharCode(chunk[j]);
86068
- }
86069
- }
86070
- return btoa(binary);
86071
- }
86072
86464
  getLayoutOptions() {
86073
86465
  const options = [];
86074
86466
  for (const [path3, xmlObj] of this.layoutXmlMap.entries()) {
@@ -86116,6 +86508,10 @@ var PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
86116
86508
  // pptx/core/core/runtime/PptxHandlerRuntimeLoadSession.ts
86117
86509
  var MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
86118
86510
  var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
86511
+ /** The limits of the load in progress (see `PptxHandlerLoadOptions.limits`). */
86512
+ loadLimits = { ...DEFAULT_PPTX_LOAD_LIMITS };
86513
+ /** Slide elements parsed so far by the load in progress, for `maxShapes`. */
86514
+ loadedShapeCount = 0;
86119
86515
  isZipContainer(data) {
86120
86516
  const bytes = new Uint8Array(data);
86121
86517
  if (bytes.byteLength < 4) {
@@ -86124,7 +86520,9 @@ var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime
86124
86520
  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);
86125
86521
  }
86126
86522
  async initializeLoadSession(data, options) {
86523
+ const limits = resolvePptxLoadLimits(options);
86127
86524
  this.eagerDecodeImages = options.eagerDecodeImages ?? false;
86525
+ this.eagerDecodeEmbeddedFonts = options.eagerDecodeEmbeddedFonts === true;
86128
86526
  this.allowExternalImages = options.allowExternalImages === true;
86129
86527
  if (data.byteLength < 4) {
86130
86528
  throw new Error("Invalid PPTX binary: file is empty or truncated.");
@@ -86134,7 +86532,7 @@ var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime
86134
86532
  "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."
86135
86533
  );
86136
86534
  }
86137
- const maxBytes = typeof options.maxUncompressedBytes === "number" && options.maxUncompressedBytes > 0 ? options.maxUncompressedBytes : DEFAULT_MAX_UNCOMPRESSED_BYTES;
86535
+ const maxBytes = limits.maxUncompressedBytes;
86138
86536
  let loaded;
86139
86537
  try {
86140
86538
  loaded = await JSZip.loadAsync(data);
@@ -86144,11 +86542,13 @@ var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime
86144
86542
  }
86145
86543
  this.zip = guardZip(loaded, {
86146
86544
  label: "PPTX",
86147
- maxEntries: MAX_ZIP_ENTRY_COUNT,
86545
+ maxEntries: limits.maxEntries,
86148
86546
  maxEntryBytes: maxBytes,
86149
86547
  maxTotalBytes: maxBytes,
86150
- createError: (message, details) => new ZipBombError(message, details)
86548
+ createError: createPptxZipBombError
86151
86549
  });
86550
+ this.loadLimits = limits;
86551
+ this.loadedShapeCount = 0;
86152
86552
  try {
86153
86553
  this.documentPropertiesUpdater = this.dependencyFactory.createDocumentPropertiesUpdater(
86154
86554
  this.zip,
@@ -86275,13 +86675,13 @@ var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime
86275
86675
  if (!file) {
86276
86676
  continue;
86277
86677
  }
86278
- const data = await file.async("string");
86678
+ const data = await this.readPartText(entry2) ?? "";
86279
86679
  const propsPath = `customXml/itemProps${itemId}.xml`;
86280
86680
  const propsFile = this.zip.file(propsPath);
86281
86681
  let properties;
86282
86682
  let schemaUri;
86283
86683
  if (propsFile) {
86284
- properties = await propsFile.async("string");
86684
+ properties = await this.readPartText(propsPath) ?? "";
86285
86685
  try {
86286
86686
  const propsData = this.parser.parse(properties);
86287
86687
  const schemaRefs = propsData?.["ds:datastoreItem"]?.["ds:schemaRefs"]?.["ds:schemaRef"];
@@ -86301,19 +86701,24 @@ var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime
86301
86701
  const relsFile = this.zip.file(relsPath2);
86302
86702
  let rels;
86303
86703
  if (relsFile) {
86304
- rels = await relsFile.async("string");
86704
+ rels = await this.readPartText(relsPath2);
86305
86705
  }
86306
86706
  parts.push({ id: itemId, data, schemaUri, properties, rels });
86307
86707
  }
86308
86708
  this.customXmlParts = parts;
86309
86709
  }
86310
86710
  async loadPresentationState() {
86311
- const presentationXml3 = await this.zip.file("ppt/presentation.xml")?.async("string");
86711
+ const presentationXml3 = await this.readPartText("ppt/presentation.xml");
86312
86712
  if (!presentationXml3) {
86313
86713
  throw new Error("Invalid PPTX: presentation.xml not found");
86314
86714
  }
86315
86715
  this.presentationData = this.parser.parse(presentationXml3);
86316
86716
  this.detectAndSetStrictConformance(this.presentationData);
86717
+ const slideIds = this.presentationData?.["p:presentation"]?.["p:sldIdLst"]?.["p:sldId"];
86718
+ assertPptxSlideCountWithinLimits(
86719
+ Array.isArray(slideIds) ? slideIds.length : slideIds ? 1 : 0,
86720
+ this.loadLimits
86721
+ );
86317
86722
  await this.loadThemeData();
86318
86723
  this.parsePresentationDefaultTextStyle();
86319
86724
  await this.loadCommentAuthors();
@@ -86443,7 +86848,17 @@ var PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime
86443
86848
  loadThemeOverride: (partBasePath) => this.loadThemeOverride(partBasePath),
86444
86849
  applyThemeOverrideState: (override) => this.applyThemeOverrideState(override),
86445
86850
  getLayoutElements: (slidePath) => this.getLayoutElements(slidePath),
86446
- parseSlide: (slideXml3, slidePath) => this.parseSlide(slideXml3, slidePath),
86851
+ // `maxShapes`: each slide's own elements are counted as soon as they are
86852
+ // parsed, before that slide's media is resolved and before the next slide.
86853
+ parseSlide: async (slideXml3, slidePath) => {
86854
+ const elements2 = await this.parseSlide(slideXml3, slidePath);
86855
+ this.loadedShapeCount = countPptxShapesWithinLimits(
86856
+ this.loadedShapeCount,
86857
+ elements2,
86858
+ this.loadLimits
86859
+ );
86860
+ return elements2;
86861
+ },
86447
86862
  extractMediaTimingMap: (slideXml3, slidePath) => this.extractMediaTimingMap(slideXml3, slidePath),
86448
86863
  enrichMediaElementsWithTiming: (elements2, timingMap) => this.enrichMediaElementsWithTiming(elements2, timingMap),
86449
86864
  enrichOleElementsWithEmbeddedData: (elements2, slidePath) => this.enrichOleElementsWithEmbeddedData(elements2, slidePath),
@@ -86642,6 +87057,7 @@ var PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
86642
87057
  * or resolve images. Create a new `PptxHandler` instance instead.
86643
87058
  */
86644
87059
  dispose() {
87060
+ this.endPartReads();
86645
87061
  this.revokeBlobUrls();
86646
87062
  this.imageDataCache.clear();
86647
87063
  this.slideMap.clear();
@@ -86675,7 +87091,23 @@ var PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
86675
87091
  this.zip = null;
86676
87092
  }
86677
87093
  async load(data, options = {}) {
86678
- await this.initializeLoadSession(data, options);
87094
+ let reader;
87095
+ try {
87096
+ await this.initializeLoadSession(data, options);
87097
+ reader = this.beginPartReads();
87098
+ try {
87099
+ return await this.loadInitializedSession();
87100
+ } catch (error) {
87101
+ if (error instanceof PptxLoadLimitError) {
87102
+ this.dispose();
87103
+ }
87104
+ throw error;
87105
+ }
87106
+ } finally {
87107
+ this.endPartReads(reader);
87108
+ }
87109
+ }
87110
+ async loadInitializedSession() {
86679
87111
  await this.detectAndPreserveVbaProject();
86680
87112
  this.detectDigitalSignatureParts();
86681
87113
  await this.parseCustomXmlParts();
@@ -86825,7 +87257,7 @@ var PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
86825
87257
  options.push(this.buildLayoutOption(lp, xmlObj));
86826
87258
  } else {
86827
87259
  try {
86828
- const layoutXmlStr = await this.zip.file(lp)?.async("string");
87260
+ const layoutXmlStr = await this.readPartText(lp);
86829
87261
  if (layoutXmlStr) {
86830
87262
  const layoutXmlObj = this.parser.parse(layoutXmlStr);
86831
87263
  this.layoutXmlMap.set(lp, layoutXmlObj);
@@ -86868,7 +87300,7 @@ var PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
86868
87300
  }
86869
87301
  let layoutXml3 = this.layoutXmlMap.get(layoutPath);
86870
87302
  if (!layoutXml3) {
86871
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
87303
+ const layoutXmlStr = await this.readPartText(layoutPath);
86872
87304
  if (!layoutXmlStr) {
86873
87305
  throw new Error(`Layout not found: ${layoutPath}`);
86874
87306
  }
@@ -87970,24 +88402,24 @@ function parseStyleTextPropAtom(view, dataOffset, dataLen, textLength, scheme) {
87970
88402
  const charRuns = [];
87971
88403
  let covered = 0;
87972
88404
  while (covered < total && c.canRead(6)) {
87973
- const count = c.u32();
88405
+ const count2 = c.u32();
87974
88406
  const indentLevel = c.u16();
87975
- const props = { count, indentLevel };
88407
+ const props = { count: count2, indentLevel };
87976
88408
  if (!parsePfException(c, scheme, props)) {
87977
88409
  break;
87978
88410
  }
87979
88411
  paragraphRuns.push(props);
87980
- covered += count;
88412
+ covered += count2;
87981
88413
  }
87982
88414
  covered = 0;
87983
88415
  while (covered < total && c.canRead(8)) {
87984
- const count = c.u32();
87985
- const props = { count };
88416
+ const count2 = c.u32();
88417
+ const props = { count: count2 };
87986
88418
  if (!parseCfException(c, scheme, props)) {
87987
88419
  break;
87988
88420
  }
87989
88421
  charRuns.push(props);
87990
- covered += count;
88422
+ covered += count2;
87991
88423
  }
87992
88424
  return { paragraphRuns, charRuns };
87993
88425
  }
@@ -88984,13 +89416,13 @@ var OPT2 = {
88984
89416
  function parseProperties2(view, data, rec) {
88985
89417
  const values = /* @__PURE__ */ new Map();
88986
89418
  const complex = /* @__PURE__ */ new Map();
88987
- const count = rec.recInstance;
88988
- const entriesEnd = rec.dataOffset + count * 6;
89419
+ const count2 = rec.recInstance;
89420
+ const entriesEnd = rec.dataOffset + count2 * 6;
88989
89421
  if (entriesEnd > rec.dataOffset + rec.recLen) {
88990
89422
  return { values, complex };
88991
89423
  }
88992
89424
  const complexRefs = [];
88993
- for (let i = 0; i < count; i++) {
89425
+ for (let i = 0; i < count2; i++) {
88994
89426
  const at = rec.dataOffset + i * 6;
88995
89427
  const opid = view.getUint16(at, true);
88996
89428
  const value = view.getUint32(at + 2, true);
@@ -90036,8 +90468,8 @@ function levelXml(tag, level, fallbackSizePt) {
90036
90468
  }
90037
90469
  function styleLevels(levels, fallbackSizePt) {
90038
90470
  const result = [];
90039
- const count = Math.max(1, Math.min(levels.length, 9));
90040
- for (let i = 0; i < count; i++) {
90471
+ const count2 = Math.max(1, Math.min(levels.length, 9));
90472
+ for (let i = 0; i < count2; i++) {
90041
90473
  result.push(levelXml(`lvl${i + 1}pPr`, levels[i] ?? {}, fallbackSizePt));
90042
90474
  }
90043
90475
  return result.join("");
@@ -90865,6 +91297,7 @@ var PptxHandlerCore = class {
90865
91297
  * ```
90866
91298
  */
90867
91299
  async load(data, options = {}) {
91300
+ assertPptxInputWithinLimits(data.byteLength, resolvePptxLoadLimits(options));
90868
91301
  const detection = detectFileFormat(data);
90869
91302
  if (detection.format === "ole") {
90870
91303
  let ole;
@@ -91176,13 +91609,15 @@ var PptxHandler = class extends PptxHandlerCore {
91176
91609
  * archives and portable `pptx-viewer-json` documents.
91177
91610
  *
91178
91611
  * The buffer is sniffed first: JSON documents (leading `{` plus the
91179
- * `"pptx-viewer-json"` format marker) are routed to {@link loadFromJson};
91180
- * everything else goes through the regular ZIP/OLE2 pipeline.
91612
+ * `"pptx-viewer-json"` format marker) are imported as {@link loadFromJson}
91613
+ * does; everything else goes through the regular ZIP/OLE2 pipeline.
91181
91614
  */
91182
91615
  async load(data, options = {}) {
91616
+ const limits = resolvePptxLoadLimits(options);
91617
+ assertPptxInputWithinLimits(data.byteLength, limits);
91183
91618
  const jsonText = decodePptxJsonText(data);
91184
91619
  if (jsonText !== null) {
91185
- return this.loadFromJson(jsonText, options);
91620
+ return this.importJson(jsonText, options, limits);
91186
91621
  }
91187
91622
  return super.load(data, options);
91188
91623
  }
@@ -91193,9 +91628,26 @@ var PptxHandler = class extends PptxHandlerCore {
91193
91628
  * handler keeps a valid in-memory archive (editing and {@link save} keep
91194
91629
  * working), then the imported model is overlaid on top: imported
91195
91630
  * presentation fields win, and the slide array is replaced wholesale.
91631
+ *
91632
+ * `options.limits` applies as it does for {@link load}: `maxInputBytes` to
91633
+ * the UTF-8 size of `text` (checked before it is parsed), and `maxSlides`
91634
+ * and `maxShapes` to the document's slides with the same counting rule as
91635
+ * a `.pptx` package (layout and master elements are not counted).
91196
91636
  */
91197
91637
  async loadFromJson(text, options = {}) {
91198
- const imported = deserializePptxFromJson(text);
91638
+ const limits = resolvePptxLoadLimits(options);
91639
+ assertPptxTextWithinLimits(text, limits);
91640
+ return this.importJson(text, options, limits);
91641
+ }
91642
+ async importJson(text, options, limits) {
91643
+ const document2 = parsePptxJson(text);
91644
+ assertPptxSlideCountWithinLimits(document2.slides.length, limits);
91645
+ let shapes = 0;
91646
+ for (const slide of document2.slides) {
91647
+ const elements2 = Array.isArray(slide.elements) ? slide.elements : [];
91648
+ shapes = countPptxShapesWithinLimits(shapes, elements2, limits);
91649
+ }
91650
+ const imported = pptxDataFromJsonDocument(document2);
91199
91651
  const blankBytes = await buildBlankPresentationArchive({
91200
91652
  width: imported.widthEmu,
91201
91653
  height: imported.heightEmu,
@@ -91203,7 +91655,7 @@ var PptxHandler = class extends PptxHandlerCore {
91203
91655
  // the overlaid model, so the archive must carry the value itself.
91204
91656
  firstSlideNumber: imported.firstSlideNumber
91205
91657
  });
91206
- const base = await super.load(blankBytes, options);
91658
+ const base = await super.load(blankBytes, { ...options, limits: void 0 });
91207
91659
  return applyImportedPptxData(base, imported);
91208
91660
  }
91209
91661
  };