@shbernal/ts-pptx 3.3.0 → 3.4.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 (60) hide show
  1. package/dist/{autopage-D1sqK6j7.js → autopage-BYlTzX-l.js} +8 -5
  2. package/dist/autopage-BYlTzX-l.js.map +1 -0
  3. package/dist/browser.d.ts +4 -4
  4. package/dist/browser.js +11 -11
  5. package/dist/browser.js.map +1 -1
  6. package/dist/{diagnostics-B2yWpcjB.d.ts → diagnostics-B0OmTOoz.d.ts} +38 -6
  7. package/dist/diagnostics-B0OmTOoz.d.ts.map +1 -0
  8. package/dist/{diagnostics-H1QzgRSw.js → diagnostics-CPVADSL1.js} +29 -3
  9. package/dist/{diagnostics-H1QzgRSw.js.map → diagnostics-CPVADSL1.js.map} +1 -1
  10. package/dist/{fit-CYJ1jkQI.js → fit-TjpNbMru.js} +3 -3
  11. package/dist/{fit-CYJ1jkQI.js.map → fit-TjpNbMru.js.map} +1 -1
  12. package/dist/{html-dom-CzewEdE1.js → html-dom-yUSdCExA.js} +5 -5
  13. package/dist/html-dom-yUSdCExA.js.map +1 -0
  14. package/dist/html.d.ts +2 -2
  15. package/dist/html.js +1 -1
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +16 -33
  18. package/dist/index.js.map +1 -1
  19. package/dist/inspect.js +5 -4
  20. package/dist/inspect.js.map +1 -1
  21. package/dist/measure.d.ts +1 -1
  22. package/dist/measure.js +1 -1
  23. package/dist/{st-enums-bVnezkMJ.js → namespaces-Sy_m7Nhd.js} +288 -200
  24. package/dist/namespaces-Sy_m7Nhd.js.map +1 -0
  25. package/dist/node.d.ts +4 -4
  26. package/dist/node.js +7 -19
  27. package/dist/node.js.map +1 -1
  28. package/dist/{notes-SCvpJz0l.js → notes-bWApshah.js} +221 -140
  29. package/dist/notes-bWApshah.js.map +1 -0
  30. package/dist/{pres-Cb-1xDne.d.ts → pres-Dybf7ZUl.d.ts} +2 -2
  31. package/dist/{pres-Cb-1xDne.d.ts.map → pres-Dybf7ZUl.d.ts.map} +1 -1
  32. package/dist/{presentation-DeKTJGHf.js → presentation-3rAKKRfm.js} +154 -230
  33. package/dist/presentation-3rAKKRfm.js.map +1 -0
  34. package/dist/{presentation-types-B50aOUFI.d.ts → presentation-types-D7cgT-eG.d.ts} +191 -16
  35. package/dist/presentation-types-D7cgT-eG.d.ts.map +1 -0
  36. package/dist/read.d.ts +3 -3
  37. package/dist/read.js +3 -3
  38. package/dist/script.d.ts +1 -1
  39. package/dist/script.d.ts.map +1 -1
  40. package/dist/script.js +67 -40
  41. package/dist/script.js.map +1 -1
  42. package/dist/{shapes-BXVgsk0F.js → shapes-Dyw5bxwO.js} +371 -52
  43. package/dist/shapes-Dyw5bxwO.js.map +1 -0
  44. package/dist/{slide-DWw9UoI6.d.ts → slide-B_aInw3N.d.ts} +208 -180
  45. package/dist/slide-B_aInw3N.d.ts.map +1 -0
  46. package/dist/{text-uM-zGton.js → text-DSN3anEh.js} +3563 -3437
  47. package/dist/text-DSN3anEh.js.map +1 -0
  48. package/dist/{units-internal-CGf4VrXy.js → units-internal-DNvK2I6o.js} +54 -34
  49. package/dist/{units-internal-CGf4VrXy.js.map → units-internal-DNvK2I6o.js.map} +1 -1
  50. package/package.json +4 -4
  51. package/dist/autopage-D1sqK6j7.js.map +0 -1
  52. package/dist/diagnostics-B2yWpcjB.d.ts.map +0 -1
  53. package/dist/html-dom-CzewEdE1.js.map +0 -1
  54. package/dist/notes-SCvpJz0l.js.map +0 -1
  55. package/dist/presentation-DeKTJGHf.js.map +0 -1
  56. package/dist/presentation-types-B50aOUFI.d.ts.map +0 -1
  57. package/dist/shapes-BXVgsk0F.js.map +0 -1
  58. package/dist/slide-DWw9UoI6.d.ts.map +0 -1
  59. package/dist/st-enums-bVnezkMJ.js.map +0 -1
  60. package/dist/text-uM-zGton.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, t as InternalError } from "./errors-Bvln0H-7.js";
2
- import { ft as emuToInches } from "./units-internal-CGf4VrXy.js";
3
- import { E as voidEl, T as raw, _ as FONT_DATA_EXTENSION, g as FONT_DATA_CONTENT_TYPE, h as EMBEDDED_FONT_SLOTS, n as makeXmlNotesMaster, o as makeXmlNotesSlideSkeleton, v as FONT_REL_TYPE, w as el } from "./notes-SCvpJz0l.js";
4
- import { _ as SLIDE_LAYOUT_REL, b as THEME_REL, d as IMAGE_REL, f as NOTES_MASTER_REL, h as OFFICE_REL, m as OFFICE_DOCUMENT_REL, p as NOTES_SLIDE_REL, v as SLIDE_MASTER_REL, y as SLIDE_REL } from "./st-enums-bVnezkMJ.js";
2
+ import { mt as emuToInches } from "./units-internal-DNvK2I6o.js";
3
+ import { D as voidEl, E as raw, T as el, g as FONT_REL_TYPE, h as FONT_DATA_EXTENSION, m as FONT_DATA_CONTENT_TYPE, n as makeXmlNotesMaster, o as makeXmlNotesSlideSkeleton, p as EMBEDDED_FONT_SLOTS } from "./notes-bWApshah.js";
4
+ import { _ as THEME_REL, a as NOTES_MASTER_REL, c as OFFICE_DOCUMENT_REL, d as SLIDE_LAYOUT_CONTENT_TYPE, f as SLIDE_LAYOUT_REL, g as THEME_CONTENT_TYPE, h as SLIDE_REL, i as NOTES_MASTER_CONTENT_TYPE, l as OFFICE_REL, m as SLIDE_MASTER_REL, o as NOTES_SLIDE_CONTENT_TYPE, p as SLIDE_MASTER_CONTENT_TYPE, r as IMAGE_REL, s as NOTES_SLIDE_REL, t as OOXML_NS } from "./namespaces-Sy_m7Nhd.js";
5
5
  import { ZipWriter, readZip } from "./zip.js";
6
- import { $ as parseClrScheme, A as readGradientFill, At as getElements, B as placeholderInheritedAnchor, Bt as setAttr, Ct as boolValue, D as spPrXfrmEmu, Dt as escapeXmlAttribute, E as TextFrame, Et as descendantsByTag, F as resolveSlideColorContext, Ft as parseXml, G as placeholderOf, H as placeholderInheritedListStyles, I as resolveSlideThemeParts, It as removeAttr, J as SCHEME_SLOTS, K as slideDefinesColor, Lt as removeChildrenByQName, M as resolveLayoutColorContext, Mt as insertInOrder, N as resolveMasterColorContext, Nt as intValue, O as readPatternFill, Ot as firstChild, P as resolveNotesColorContext, Pt as ownerDocumentOf, Q as parseClrMap, R as LST_STYLE_LEVELS, Rt as replaceInParent, S as AutoShape, St as attr, Tt as createElement, U as placeholderInheritedRunProps, V as placeholderInheritedColor, W as placeholderInheritedXfrm, X as intAttr, Y as fmtEntry, Z as isA, _t as relsPartNameFor, at as FILL_CHOICES, bt as zipPathToPartName, ct as SPPR_AFTER_XFRM, dt as SPPR_LN_AFTER, et as resolveColor, ft as SPPR_SCENE3D_AFTER, gt as relativePartName, ht as partNameToZipPath, it as substitutePhClr, j as resolveColorElement, jt as getOrAddChild, k as readPictureFill, kt as firstChildElement, l as wrapShapeElement, lt as SPPR_EFFECT_AFTER, mt as partNameExtension, n as buildShapes, nt as styleRefFill, ot as RPR_FILL_AFTER, pt as SPPR_SP3D_AFTER, q as slideDefinesProp, r as findShapeByIdDeep, rt as styleRefLine, st as SHAPE_AFTER_SPPR, t as GroupShape, tt as resolveSchemeToken, u as GraphicFrame, ut as SPPR_FILL_AFTER, vt as resolveRelativePartName, wt as childElements, x as Picture, xt as OOXML_NS, yt as resolveSingleRel, z as RUN_PROP_NAMES, zt as serializeXml } from "./shapes-BXVgsk0F.js";
6
+ import { $ as collectElements, A as readPatternFill, At as zipPathToPartName, B as LST_STYLE_LEVELS, Bt as getOrAddChild, C as Picture, Ct as SPPR_SP3D_AFTER, Dt as relsPartNameFor, Et as relativePartName, F as resolveMasterColorContext, Ft as descendantsByTag, G as placeholderInheritedRunProps, Gt as removeAttr, H as placeholderInheritedAnchor, Ht as intValue, I as resolveNotesColorContext, It as escapeXmlAttribute, J as slideDefinesColor, Jt as serializeXml, K as placeholderInheritedXfrm, Kt as removeChildrenByQName, L as resolveSlideColorContext, Lt as firstChild, M as readGradientFill, Mt as boolValue, N as resolveColorElement, Nt as childElements, O as TextFrame, Ot as resolveRelativePartName, P as resolveLayoutColorContext, Pt as createElement, Q as carriedDecorations, R as resolveSlideThemeParts, Rt as firstChildElement, St as SPPR_SCENE3D_AFTER, Tt as partNameToZipPath, U as placeholderInheritedColor, Ut as ownerDocumentOf, V as RUN_PROP_NAMES, Vt as insertInOrder, W as placeholderInheritedListStyles, Wt as parseXml, X as cSldName, Y as slideDefinesProp, Yt as setAttr, Z as cSldOf, _t as SHAPE_AFTER_SPPR, at as fmtEntry, bt as SPPR_FILL_AFTER, ct as parseClrMap, dt as resolveSchemeToken, et as firstShapeChild, ft as styleRefFill, gt as RPR_FILL_AFTER, ht as FILL_CHOICES, it as SCHEME_SLOTS, j as readPictureFill, jt as attr, k as spPrXfrmEmu, kt as resolveSingleRel, l as wrapShapeElement, lt as parseClrScheme, mt as substitutePhClr, n as buildShapes, nt as nvPrOf, ot as intAttr, pt as styleRefLine, q as placeholderOf, qt as replaceInParent, r as findShapeByIdDeep, rt as spTreeOf, st as isA, t as GroupShape, tt as nthShapeChild, u as GraphicFrame, ut as resolveColor, vt as SPPR_AFTER_XFRM, w as AutoShape, wt as partNameExtension, xt as SPPR_LN_AFTER, yt as SPPR_EFFECT_AFTER, zt as getElements } from "./shapes-Dyw5bxwO.js";
7
7
  //#region src/read/opc/content-types.ts
8
8
  /**
9
9
  * Overlay over `[Content_Types].xml`, used to resolve part content types at
@@ -594,7 +594,7 @@ function reverseClrMap(clrMap) {
594
594
  function applyInheritedBackground(slideRoot, ctx) {
595
595
  const inherited = ctx.inheritedBackground;
596
596
  if (!inherited) return;
597
- const cSld = firstChild(slideRoot, "p:cSld");
597
+ const cSld = cSldOf(slideRoot);
598
598
  if (!cSld || firstChild(cSld, "p:bg")) return;
599
599
  const bg = ownerDocumentOf(slideRoot).importNode(inherited, true);
600
600
  insertInOrder(cSld, bg, [
@@ -644,6 +644,28 @@ function resolveSchemeColors(root, ctx) {
644
644
  * re-bind to the destination styles.
645
645
  */
646
646
  function resolvePlaceholderRunColors(slideRoot, ctx) {
647
+ bakePlaceholderRunProperty(slideRoot, ctx, placeholderInheritedColor, (run, color, pPr, slideLst, level) => {
648
+ if (slideDefinesColor(run, pPr, slideLst, level)) return;
649
+ writeRunColor(run, color);
650
+ });
651
+ }
652
+ /**
653
+ * The traversal both run-property passes share: every placeholder shape's text body, every
654
+ * paragraph in it, every `a:r` and `a:fld` in that paragraph.
655
+ *
656
+ * `resolve` is asked once per *list level* per shape and memoized, because walking the
657
+ * layout/master style chain is the expensive half and every paragraph at the same level gets
658
+ * the same answer. `write` then runs per run, and owns the decision to skip a run the slide
659
+ * already fixes — the two passes ask that question differently (one colour check versus three
660
+ * independent property checks), so it stays on their side of the boundary rather than becoming
661
+ * a predicate parameter only one caller could use.
662
+ *
663
+ * @param slideRoot - the slide part's root element
664
+ * @param ctx - the flatten context, carrying the source layout/master roots
665
+ * @param resolve - the inherited value for a placeholder type/idx at a list level, or `null`
666
+ * @param write - apply a resolved value to one run
667
+ */
668
+ function bakePlaceholderRunProperty(slideRoot, ctx, resolve, write) {
647
669
  if (!ctx.layoutRoot && !ctx.masterRoot) return;
648
670
  for (const sp of descendantsByTag(slideRoot, OOXML_NS.p, "sp")) {
649
671
  const ph = placeholderOf(sp);
@@ -659,16 +681,13 @@ function resolvePlaceholderRunColors(slideRoot, ctx) {
659
681
  const level = (pPr && intValue(attr(pPr, "lvl"))) ?? 0;
660
682
  const runs = [...getElements(p, "a:r"), ...getElements(p, "a:fld")];
661
683
  if (runs.length === 0) continue;
662
- let color = byLevel.get(level);
663
- if (color === void 0) {
664
- color = placeholderInheritedColor(type, idx, level, ctx);
665
- byLevel.set(level, color);
666
- }
667
- if (!color) continue;
668
- for (const run of runs) {
669
- if (slideDefinesColor(run, pPr, slideLst, level)) continue;
670
- writeRunColor(run, color);
684
+ let value = byLevel.get(level);
685
+ if (value === void 0) {
686
+ value = resolve(type, idx, level, ctx);
687
+ byLevel.set(level, value);
671
688
  }
689
+ if (!value) continue;
690
+ for (const run of runs) write(run, value, pPr, slideLst, level);
672
691
  }
673
692
  }
674
693
  }
@@ -788,8 +807,7 @@ function resolvePlaceholderListStyle(shapeRoot, ctx) {
788
807
  */
789
808
  function demotePlaceholders(shapeRoot) {
790
809
  for (const sp of descendantsByTag(shapeRoot, OOXML_NS.p, "sp")) {
791
- const nvSpPr = firstChild(sp, "p:nvSpPr");
792
- const nvPr = nvSpPr && firstChild(nvSpPr, "p:nvPr");
810
+ const nvPr = nvPrOf(sp);
793
811
  if (nvPr) removeChildrenByQName(nvPr, ["p:ph"]);
794
812
  }
795
813
  }
@@ -803,30 +821,7 @@ function demotePlaceholders(shapeRoot) {
803
821
  * is left to re-bind to the destination theme, as the colour pass does for the `fontRef`.
804
822
  */
805
823
  function resolvePlaceholderRunSizes(slideRoot, ctx) {
806
- if (!ctx.layoutRoot && !ctx.masterRoot) return;
807
- for (const sp of descendantsByTag(slideRoot, OOXML_NS.p, "sp")) {
808
- const ph = placeholderOf(sp);
809
- if (!ph) continue;
810
- const txBody = firstChild(sp, "p:txBody");
811
- if (!txBody) continue;
812
- const type = attr(ph, "type");
813
- const idx = attr(ph, "idx") ?? "0";
814
- const slideLst = firstChild(txBody, "a:lstStyle");
815
- const byLevel = /* @__PURE__ */ new Map();
816
- for (const p of getElements(txBody, "a:p")) {
817
- const pPr = firstChild(p, "a:pPr");
818
- const level = (pPr && intValue(attr(pPr, "lvl"))) ?? 0;
819
- const runs = [...getElements(p, "a:r"), ...getElements(p, "a:fld")];
820
- if (runs.length === 0) continue;
821
- let props = byLevel.get(level);
822
- if (props === void 0) {
823
- props = placeholderInheritedRunProps(type, idx, level, ctx);
824
- byLevel.set(level, props);
825
- }
826
- if (!props) continue;
827
- for (const run of runs) writeRunProps(run, props, pPr, slideLst, level);
828
- }
829
- }
824
+ bakePlaceholderRunProperty(slideRoot, ctx, placeholderInheritedRunProps, writeRunProps);
830
825
  }
831
826
  /** Write each resolved run property onto a run's `a:rPr`, skipping ones the slide already fixes. */
832
827
  function writeRunProps(run, props, pPr, slideLst, level) {
@@ -907,7 +902,7 @@ function neutralizeRef(ref) {
907
902
  */
908
903
  /** The `p:cSld/p:bg` element of a slide/layout/master root, or `null`. */
909
904
  function backgroundElementOf(root) {
910
- const cSld = root && firstChild(root, "p:cSld");
905
+ const cSld = cSldOf(root);
911
906
  return cSld ? firstChild(cSld, "p:bg") : null;
912
907
  }
913
908
  /**
@@ -1012,8 +1007,7 @@ var NotesPlaceholder = class {
1012
1007
  this.relationships = relationships;
1013
1008
  }
1014
1009
  #ph() {
1015
- const nvSpPr = firstChild(this.sp, "p:nvSpPr");
1016
- const nvPr = nvSpPr && firstChild(nvSpPr, "p:nvPr");
1010
+ const nvPr = nvPrOf(this.sp);
1017
1011
  return nvPr ? firstChild(nvPr, "p:ph") : null;
1018
1012
  }
1019
1013
  #cNvPr() {
@@ -1147,12 +1141,26 @@ var NotesSlide = class {
1147
1141
  return this.placeholders.find((ph) => ph.type === type) ?? null;
1148
1142
  }
1149
1143
  #spTree() {
1150
- const root = this.part.dom.documentElement;
1151
- const cSld = root && firstChild(root, "p:cSld");
1152
- return cSld ? firstChild(cSld, "p:spTree") : null;
1144
+ return spTreeOf(this.part.dom.documentElement);
1153
1145
  }
1154
1146
  };
1155
1147
  //#endregion
1148
+ //#region src/read/api/ops/deck-target.ts
1149
+ /**
1150
+ * `ppt/_rels/presentation.xml.rels` -- the deck's own relationship part.
1151
+ *
1152
+ * Every part that masters, layouts, the notes master and embedded fonts hang off
1153
+ * is reached through here, so the two-step `dest.presentationPart` ->
1154
+ * `dest.opc.relationshipsFor(part.partName)` was written out at every one of
1155
+ * those wiring sites. Naming it once means a call site says which rels it wants
1156
+ * rather than how to find them.
1157
+ * @param {DeckTarget} dest - the destination deck
1158
+ * @returns {Relationships} the presentation part's relationships
1159
+ */
1160
+ function presentationRels(dest) {
1161
+ return dest.opc.relationshipsFor(dest.presentationPart.partName);
1162
+ }
1163
+ //#endregion
1156
1164
  //#region src/read/api/ops/master-registry.ts
1157
1165
  /**
1158
1166
  * Slide-master bookkeeping in `presentation.xml` and in a master's own
@@ -1175,7 +1183,7 @@ var NotesSlide = class {
1175
1183
  */
1176
1184
  function registerMaster(dest, masterPartName) {
1177
1185
  const presPart = dest.presentationPart;
1178
- const presRels = dest.opc.relationshipsFor(presPart.partName);
1186
+ const presRels = presentationRels(dest);
1179
1187
  for (const rel of presRels.byType(SLIDE_MASTER_REL)) if (presRels.resolveTarget(rel.id) === masterPartName) return;
1180
1188
  const relId = presRels.add(SLIDE_MASTER_REL, relativePartName(presPart.partName, masterPartName)).id;
1181
1189
  const root = presPart.dom.documentElement;
@@ -1214,7 +1222,7 @@ function promoteMasters(dest, masterPartNames) {
1214
1222
  const root = presPart.dom.documentElement;
1215
1223
  const lst = root && firstChild(root, "p:sldMasterIdLst");
1216
1224
  if (!lst) return;
1217
- const rels = dest.opc.relationshipsFor(presPart.partName);
1225
+ const rels = presentationRels(dest);
1218
1226
  const promote = new Set(masterPartNames);
1219
1227
  const entries = getElements(lst, "p:sldMasterId");
1220
1228
  const isPromoted = (entry) => {
@@ -1240,14 +1248,13 @@ function promoteMasters(dest, masterPartNames) {
1240
1248
  */
1241
1249
  function nextMasterLayoutId(dest) {
1242
1250
  let max = 2147483647;
1243
- const presPart = dest.presentationPart;
1244
- const root = presPart.dom.documentElement;
1251
+ const root = dest.presentationPart.dom.documentElement;
1245
1252
  const masterLst = root && firstChild(root, "p:sldMasterIdLst");
1246
1253
  if (masterLst) for (const entry of getElements(masterLst, "p:sldMasterId")) {
1247
1254
  const id = intValue(attr(entry, "id"));
1248
1255
  if (id !== null && id > max) max = id;
1249
1256
  }
1250
- const presRels = dest.opc.relationshipsFor(presPart.partName);
1257
+ const presRels = presentationRels(dest);
1251
1258
  for (const rel of presRels.byType(SLIDE_MASTER_REL)) {
1252
1259
  const masterRoot = dest.opc.part(presRels.resolveTarget(rel.id))?.dom.documentElement;
1253
1260
  const layoutLst = masterRoot && firstChild(masterRoot, "p:sldLayoutIdLst");
@@ -1385,9 +1392,6 @@ function duplicateSubtree(opc, partName, copies) {
1385
1392
  }
1386
1393
  //#endregion
1387
1394
  //#region src/read/api/ops/part-copy.ts
1388
- const SLIDE_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
1389
- const SLIDE_LAYOUT_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
1390
- const NOTES_SLIDE_CONTENT_TYPE$2 = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
1391
1395
  /** Open an ownership scope for one page copy. */
1392
1396
  function newOwnedScope() {
1393
1397
  return /* @__PURE__ */ new Map();
@@ -1477,7 +1481,7 @@ function copyPart(ctx, sourcePartName, owned) {
1477
1481
  clearLayoutIdList(ctx.dest, newPartName);
1478
1482
  registerMaster(ctx.dest, newPartName);
1479
1483
  }
1480
- if (sourcePart.contentType === SLIDE_LAYOUT_CONTENT_TYPE) linkLayoutIntoMaster(ctx, sourceRels, newPartName);
1484
+ if (sourcePart.contentType === "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml") linkLayoutIntoMaster(ctx, sourceRels, newPartName);
1481
1485
  return newPartName;
1482
1486
  }
1483
1487
  const NO_NOTES = {
@@ -1516,8 +1520,8 @@ function checkSelectionCopyable(source, registry, selected, notes = NO_NOTES) {
1516
1520
  const part = source.part(partName);
1517
1521
  if (!part) throw new PackageReadError("package/part-missing", `importSlides: source package has no part ${partName}`);
1518
1522
  const isMaster = part.contentType === SLIDE_MASTER_CONTENT_TYPE;
1519
- const isNotesSlide = part.contentType === NOTES_SLIDE_CONTENT_TYPE$2;
1520
- if (isMaster || part.contentType === SLIDE_LAYOUT_CONTENT_TYPE) part.dom;
1523
+ const isNotesSlide = part.contentType === NOTES_SLIDE_CONTENT_TYPE;
1524
+ if (isMaster || part.contentType === "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml") part.dom;
1521
1525
  const rels = source.relationshipsFor(partName);
1522
1526
  for (const rel of rels) {
1523
1527
  if (rel.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide") {
@@ -1563,8 +1567,6 @@ function linkLayoutIntoMaster(ctx, layoutSourceRels, layoutPartName) {
1563
1567
  * `Presentation`-to-`Presentation` path and the generator-XML path funnel through
1564
1568
  * `registerNotesMaster`: they differ only in how the *part* comes into being.
1565
1569
  */
1566
- const NOTES_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
1567
- const THEME_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.theme+xml";
1568
1570
  const textEncoder$3 = new TextEncoder();
1569
1571
  /**
1570
1572
  * Carry the source slide's speaker notes onto the just-imported slide (the
@@ -1625,8 +1627,7 @@ function carryNotes(dest, source, ctx, sourceSlidePartName, newSlidePartName) {
1625
1627
  * registered in `presentation.xml`. Returns the destination notesMaster partname.
1626
1628
  */
1627
1629
  function ensureNotesMaster(dest, ctx, sourceNotesMasterPartName) {
1628
- const presPart = dest.presentationPart;
1629
- const presRels = dest.opc.relationshipsFor(presPart.partName);
1630
+ const presRels = presentationRels(dest);
1630
1631
  const existing = presRels.byType(NOTES_MASTER_REL)[0];
1631
1632
  if (existing) return presRels.resolveTarget(existing.id);
1632
1633
  return registerNotesMaster(dest, copyPart(ctx, sourceNotesMasterPartName));
@@ -1643,7 +1644,7 @@ function ensureNotesMaster(dest, ctx, sourceNotesMasterPartName) {
1643
1644
  */
1644
1645
  function registerNotesMaster(dest, notesMasterPartName) {
1645
1646
  const presPart = dest.presentationPart;
1646
- const relId = dest.opc.relationshipsFor(presPart.partName).add(NOTES_MASTER_REL, relativePartName(presPart.partName, notesMasterPartName)).id;
1647
+ const relId = presentationRels(dest).add(NOTES_MASTER_REL, relativePartName(presPart.partName, notesMasterPartName)).id;
1647
1648
  const root = presPart.dom.documentElement;
1648
1649
  if (!root) throw new PackageReadError("package/part-has-no-root", "presentation.xml has no document element to register a notes master in");
1649
1650
  const lst = getOrAddChild(root, "p:notesMasterIdLst", [
@@ -1675,8 +1676,7 @@ function registerNotesMaster(dest, notesMasterPartName) {
1675
1676
  * theme its `.rels` requires (the normal write path emits that as `theme2.xml`).
1676
1677
  */
1677
1678
  function ensureNotesMasterFromXml(dest, master) {
1678
- const presPart = dest.presentationPart;
1679
- const presRels = dest.opc.relationshipsFor(presPart.partName);
1679
+ const presRels = presentationRels(dest);
1680
1680
  const existing = presRels.byType(NOTES_MASTER_REL)[0];
1681
1681
  if (existing) return presRels.resolveTarget(existing.id);
1682
1682
  const masterPartName = dest.opc.reservePartNameLike("/ppt/notesMasters/notesMaster1.xml");
@@ -1712,8 +1712,7 @@ function ensureNotesMasterFromXml(dest, master) {
1712
1712
  * @return {string} the destination notesMaster partname
1713
1713
  */
1714
1714
  function ensureNotesMasterForAuthoring(dest, slidePartName) {
1715
- const presPart = dest.presentationPart;
1716
- const presRels = dest.opc.relationshipsFor(presPart.partName);
1715
+ const presRels = presentationRels(dest);
1717
1716
  const existing = presRels.byType(NOTES_MASTER_REL)[0];
1718
1717
  if (existing) return presRels.resolveTarget(existing.id);
1719
1718
  const themePartName = resolveSlideThemeParts(dest.opc, slidePartName).themePartName;
@@ -1755,8 +1754,6 @@ function ensureNotesMasterForAuthoring(dest, slidePartName) {
1755
1754
  * multi-run paragraphs are reached afterwards through `slide.notesTextFrame`, which
1756
1755
  * is the read model's normal text-editing surface.
1757
1756
  */
1758
- const NOTES_SLIDE_CONTENT_TYPE$1 = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
1759
- const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
1760
1757
  const textEncoder$2 = new TextEncoder();
1761
1758
  /**
1762
1759
  * The `a:p` children of a notes body, one per `\n`-separated line: the write path's
@@ -1791,7 +1788,7 @@ function replaceNotesParagraphs(txBody, text) {
1791
1788
  const doc = txBody.ownerDocument;
1792
1789
  if (!doc) throw new InternalError("oxml/node-has-no-document", "Notes body has no owner document");
1793
1790
  removeChildrenByQName(txBody, ["a:p"]);
1794
- const wrapper = parseXml(`<w xmlns:a="${A_NS}">${notesParagraphsXml(text)}</w>`).documentElement;
1791
+ const wrapper = parseXml(`<w xmlns:a="${OOXML_NS.a}">${notesParagraphsXml(text)}</w>`).documentElement;
1795
1792
  if (!wrapper) throw new InternalError("oxml/node-has-no-document", "Authored notes paragraphs did not parse to a root");
1796
1793
  for (const paragraph of Array.from(wrapper.childNodes)) txBody.appendChild(doc.importNode(paragraph, true));
1797
1794
  }
@@ -1804,12 +1801,10 @@ function replaceNotesParagraphs(txBody, text) {
1804
1801
  * @return {Element | null} the body placeholder's text body
1805
1802
  */
1806
1803
  function notesBodyTxBody(root) {
1807
- const cSld = root && firstChild(root, "p:cSld");
1808
- const spTree = cSld && firstChild(cSld, "p:spTree");
1804
+ const spTree = spTreeOf(root);
1809
1805
  if (!spTree) return null;
1810
1806
  for (const sp of getElements(spTree, "p:sp")) {
1811
- const nvSpPr = firstChild(sp, "p:nvSpPr");
1812
- const nvPr = nvSpPr && firstChild(nvSpPr, "p:nvPr");
1807
+ const nvPr = nvPrOf(sp);
1813
1808
  const ph = nvPr && firstChild(nvPr, "p:ph");
1814
1809
  if (ph && attr(ph, "type") === "body") return firstChild(sp, "p:txBody");
1815
1810
  }
@@ -1848,7 +1843,7 @@ function authorNotes(slide, text) {
1848
1843
  }
1849
1844
  const slideNum = slide.index + 1;
1850
1845
  const partName = opc.reservePartNameLike("/ppt/notesSlides/notesSlide1.xml");
1851
- opc.addPart(partName, NOTES_SLIDE_CONTENT_TYPE$1, textEncoder$2.encode(makeXmlNotesSlideSkeleton(notesParagraphsXml(text), slideNum)));
1846
+ opc.addPart(partName, NOTES_SLIDE_CONTENT_TYPE, textEncoder$2.encode(makeXmlNotesSlideSkeleton(notesParagraphsXml(text), slideNum)));
1852
1847
  slide.relationships.add(NOTES_SLIDE_REL, relativePartName(slide.partName, partName));
1853
1848
  const notesRels = opc.relationshipsFor(partName);
1854
1849
  const masterPartName = ensureNotesMasterForAuthoring(slide.presentation, slide.partName);
@@ -2328,12 +2323,10 @@ var SlideMaster = class {
2328
2323
  return rel ? this.opc.part(rels.resolveTarget(rel.id)) ?? null : null;
2329
2324
  }
2330
2325
  #cSld() {
2331
- const root = this.part.dom.documentElement;
2332
- return root ? firstChild(root, "p:cSld") : null;
2326
+ return cSldOf(this.part.dom.documentElement);
2333
2327
  }
2334
2328
  #spTree() {
2335
- const cSld = this.#cSld();
2336
- return cSld ? firstChild(cSld, "p:spTree") : null;
2329
+ return spTreeOf(this.part.dom.documentElement);
2337
2330
  }
2338
2331
  };
2339
2332
  /**
@@ -2439,12 +2432,10 @@ var SlideLayout = class {
2439
2432
  return this.#themeContext ??= resolveLayoutColorContext(this.opc, this.partName);
2440
2433
  }
2441
2434
  #cSld() {
2442
- const root = this.part.dom.documentElement;
2443
- return root ? firstChild(root, "p:cSld") : null;
2435
+ return cSldOf(this.part.dom.documentElement);
2444
2436
  }
2445
2437
  #spTree() {
2446
- const cSld = this.#cSld();
2447
- return cSld ? firstChild(cSld, "p:spTree") : null;
2438
+ return spTreeOf(this.part.dom.documentElement);
2448
2439
  }
2449
2440
  };
2450
2441
  //#endregion
@@ -3103,9 +3094,14 @@ var Slide = class {
3103
3094
  * All text on the slide, flattened in document order — the read-model
3104
3095
  * counterpart to {@link TextFrame.text} one level up. Every text-bearing shape
3105
3096
  * contributes its text, recursing into groups ({@link GroupShape}) and reading
3106
- * table cells ({@link GraphicFrame.table}); text-free shapes (pictures,
3107
- * connectors, empty boxes) contribute nothing. Blocks are joined by `\n`; within
3108
- * a table, cells in a row are joined by `\t` and rows by `\n`.
3097
+ * table cells ({@link GraphicFrame.table}) and SmartArt node text
3098
+ * ({@link GraphicFrame.diagram}); text-free shapes (pictures, connectors, empty
3099
+ * boxes) contribute nothing. Blocks are joined by `\n`; within a table, cells in
3100
+ * a row are joined by `\t` and rows by `\n`.
3101
+ *
3102
+ * A diagram contributes for the same reason a table does: its nodes are body text
3103
+ * PowerPoint itself searches and spell-checks, so a slide whose whole message is a
3104
+ * SmartArt graphic would otherwise flatten to the empty string.
3109
3105
  *
3110
3106
  * This is deliberately scoped to the slide's own shape tree. It does **not**
3111
3107
  * include speaker notes (read those via {@link notesText}) or chart data labels
@@ -3119,11 +3115,16 @@ var Slide = class {
3119
3115
  for (const shape of shapes) if (shape instanceof GroupShape) walk(shape.shapes);
3120
3116
  else if (shape instanceof GraphicFrame) {
3121
3117
  const table = shape.table;
3122
- if (!table) continue;
3123
- for (const row of table.rows) {
3124
- const cells = row.cells.map((cell) => cell.text);
3125
- if (cells.some((cell) => cell.length > 0)) blocks.push(cells.join(" "));
3118
+ if (table) {
3119
+ for (const row of table.rows) {
3120
+ const cells = row.cells.map((cell) => cell.text);
3121
+ if (cells.some((cell) => cell.length > 0)) blocks.push(cells.join(" "));
3122
+ }
3123
+ continue;
3126
3124
  }
3125
+ const diagram = shape.diagram;
3126
+ const diagramText = diagram ? diagram.text : "";
3127
+ if (diagramText.length > 0) blocks.push(diagramText);
3127
3128
  } else {
3128
3129
  const text = shape.text;
3129
3130
  if (text.length > 0) blocks.push(text);
@@ -3462,12 +3463,10 @@ var Slide = class {
3462
3463
  return max + 1;
3463
3464
  }
3464
3465
  #cSld() {
3465
- const root = this.part.dom.documentElement;
3466
- return root ? firstChild(root, "p:cSld") : null;
3466
+ return cSldOf(this.part.dom.documentElement);
3467
3467
  }
3468
3468
  #spTree() {
3469
- const cSld = this.#cSld();
3470
- return cSld ? firstChild(cSld, "p:spTree") : null;
3469
+ return spTreeOf(this.part.dom.documentElement);
3471
3470
  }
3472
3471
  };
3473
3472
  function requireFinite(value, name) {
@@ -3477,39 +3476,53 @@ function requirePositive(value, name) {
3477
3476
  requireFinite(value, name);
3478
3477
  if (value <= 0) throw new InvalidOptionError("coord/not-positive", `${name} must be positive, got ${value}`);
3479
3478
  }
3480
- /** Build a minimal, schema-valid text-box `p:sp` element (not yet attached). */
3481
- function buildTextBox(doc, spec) {
3482
- const make = (qname) => createElement(doc, qname);
3483
- const append = (parent, qname) => {
3484
- const child = make(qname);
3485
- parent.appendChild(child);
3486
- return child;
3487
- };
3488
- const sp = make("p:sp");
3489
- const nvSpPr = append(sp, "p:nvSpPr");
3490
- const cNvPr = append(nvSpPr, "p:cNvPr");
3491
- setAttr(cNvPr, "id", String(spec.id));
3492
- setAttr(cNvPr, "name", spec.name);
3493
- const cNvSpPr = append(nvSpPr, "p:cNvSpPr");
3494
- setAttr(cNvSpPr, "txBox", "1");
3495
- append(nvSpPr, "p:nvPr");
3496
- const spPr = append(sp, "p:spPr");
3497
- const xfrm = append(spPr, "a:xfrm");
3498
- const off = append(xfrm, "a:off");
3479
+ /**
3480
+ * Create `qname` in the parent's document and append it.
3481
+ *
3482
+ * The builders below are uniformly parent-then-child, so this is the only shape
3483
+ * of element creation they need; `ownerDocumentOf` is what lets it take the
3484
+ * parent alone rather than threading a `Document` through every call.
3485
+ */
3486
+ function appendEl(parent, qname) {
3487
+ const child = createElement(ownerDocumentOf(parent), qname);
3488
+ parent.appendChild(child);
3489
+ return child;
3490
+ }
3491
+ /**
3492
+ * Append the `p:spPr` a built `p:sp` and `p:pic` share: the spec's box as an
3493
+ * `a:xfrm`, then a rect `prstGeom` with the empty `a:avLst` the schema requires.
3494
+ */
3495
+ function appendSpPr(parent, spec) {
3496
+ const spPr = appendEl(parent, "p:spPr");
3497
+ const xfrm = appendEl(spPr, "a:xfrm");
3498
+ const off = appendEl(xfrm, "a:off");
3499
3499
  setAttr(off, "x", String(spec.left));
3500
3500
  setAttr(off, "y", String(spec.top));
3501
- const ext = append(xfrm, "a:ext");
3501
+ const ext = appendEl(xfrm, "a:ext");
3502
3502
  setAttr(ext, "cx", String(spec.width));
3503
3503
  setAttr(ext, "cy", String(spec.height));
3504
- const prstGeom = append(spPr, "a:prstGeom");
3504
+ const prstGeom = appendEl(spPr, "a:prstGeom");
3505
3505
  setAttr(prstGeom, "prst", "rect");
3506
- append(prstGeom, "a:avLst");
3507
- const txBody = append(sp, "p:txBody");
3508
- append(txBody, "a:bodyPr");
3509
- append(txBody, "a:lstStyle");
3510
- const p = append(txBody, "a:p");
3506
+ appendEl(prstGeom, "a:avLst");
3507
+ return spPr;
3508
+ }
3509
+ /** Build a minimal, schema-valid text-box `p:sp` element (not yet attached). */
3510
+ function buildTextBox(doc, spec) {
3511
+ const sp = createElement(doc, "p:sp");
3512
+ const nvSpPr = appendEl(sp, "p:nvSpPr");
3513
+ const cNvPr = appendEl(nvSpPr, "p:cNvPr");
3514
+ setAttr(cNvPr, "id", String(spec.id));
3515
+ setAttr(cNvPr, "name", spec.name);
3516
+ const cNvSpPr = appendEl(nvSpPr, "p:cNvSpPr");
3517
+ setAttr(cNvSpPr, "txBox", "1");
3518
+ appendEl(nvSpPr, "p:nvPr");
3519
+ appendSpPr(sp, spec);
3520
+ const txBody = appendEl(sp, "p:txBody");
3521
+ appendEl(txBody, "a:bodyPr");
3522
+ appendEl(txBody, "a:lstStyle");
3523
+ const p = appendEl(txBody, "a:p");
3511
3524
  if (spec.text !== "") {
3512
- const t = append(append(p, "a:r"), "a:t");
3525
+ const t = appendEl(appendEl(p, "a:r"), "a:t");
3513
3526
  t.textContent = spec.text;
3514
3527
  if (spec.text !== spec.text.trim()) setAttr(t, "xml:space", "preserve");
3515
3528
  }
@@ -3517,35 +3530,19 @@ function buildTextBox(doc, spec) {
3517
3530
  }
3518
3531
  /** Build a minimal, schema-valid `p:pic` element (not yet attached). */
3519
3532
  function buildPicture(doc, spec) {
3520
- const make = (qname) => createElement(doc, qname);
3521
- const append = (parent, qname) => {
3522
- const child = make(qname);
3523
- parent.appendChild(child);
3524
- return child;
3525
- };
3526
- const pic = make("p:pic");
3527
- const nvPicPr = append(pic, "p:nvPicPr");
3528
- const cNvPr = append(nvPicPr, "p:cNvPr");
3533
+ const pic = createElement(doc, "p:pic");
3534
+ const nvPicPr = appendEl(pic, "p:nvPicPr");
3535
+ const cNvPr = appendEl(nvPicPr, "p:cNvPr");
3529
3536
  setAttr(cNvPr, "id", String(spec.id));
3530
3537
  setAttr(cNvPr, "name", spec.name);
3531
- const picLocks = append(append(nvPicPr, "p:cNvPicPr"), "a:picLocks");
3538
+ const picLocks = appendEl(appendEl(nvPicPr, "p:cNvPicPr"), "a:picLocks");
3532
3539
  setAttr(picLocks, "noChangeAspect", "1");
3533
- append(nvPicPr, "p:nvPr");
3534
- const blipFill = append(pic, "p:blipFill");
3535
- const blip = append(blipFill, "a:blip");
3540
+ appendEl(nvPicPr, "p:nvPr");
3541
+ const blipFill = appendEl(pic, "p:blipFill");
3542
+ const blip = appendEl(blipFill, "a:blip");
3536
3543
  setAttr(blip, "r:embed", spec.relId);
3537
- append(append(blipFill, "a:stretch"), "a:fillRect");
3538
- const spPr = append(pic, "p:spPr");
3539
- const xfrm = append(spPr, "a:xfrm");
3540
- const off = append(xfrm, "a:off");
3541
- setAttr(off, "x", String(spec.left));
3542
- setAttr(off, "y", String(spec.top));
3543
- const ext = append(xfrm, "a:ext");
3544
- setAttr(ext, "cx", String(spec.width));
3545
- setAttr(ext, "cy", String(spec.height));
3546
- const prstGeom = append(spPr, "a:prstGeom");
3547
- setAttr(prstGeom, "prst", "rect");
3548
- append(prstGeom, "a:avLst");
3544
+ appendEl(appendEl(blipFill, "a:stretch"), "a:fillRect");
3545
+ appendSpPr(pic, spec);
3549
3546
  return pic;
3550
3547
  }
3551
3548
  //#endregion
@@ -3657,70 +3654,6 @@ function readCustomProperties(opc) {
3657
3654
  return out;
3658
3655
  }
3659
3656
  //#endregion
3660
- //#region src/read/oxml/slide-dom.ts
3661
- /** The `p:cSld@name` of a slide/layout/master part (`''` when absent). */
3662
- function cSldName(part) {
3663
- const root = part?.dom.documentElement;
3664
- const cSld = root && firstChild(root, "p:cSld");
3665
- return (cSld && attr(cSld, "name")) ?? "";
3666
- }
3667
- /** Whether `el` is a `p:spTree`'s own group properties (`p:nvGrpSpPr`/`p:grpSpPr`), not a shape. */
3668
- function isSpTreeProperty(el) {
3669
- return el.namespaceURI === OOXML_NS.p && (el.localName === "nvGrpSpPr" || el.localName === "grpSpPr");
3670
- }
3671
- /** Whether a `p:spTree` child is a placeholder shape (its `*nvPr` carries a `p:ph`). */
3672
- function isPlaceholderShape(shape) {
3673
- const nv = firstChildElement(shape);
3674
- const nvPr = nv && firstChild(nv, "p:nvPr");
3675
- return !!(nvPr && firstChild(nvPr, "p:ph"));
3676
- }
3677
- /** The decorative shapes on a layout/master `p:spTree`: every shape child except placeholders. */
3678
- function carriedDecorations(root) {
3679
- if (!root) return [];
3680
- const cSld = firstChild(root, "p:cSld");
3681
- const spTree = cSld && firstChild(cSld, "p:spTree");
3682
- if (!spTree) return [];
3683
- const out = [];
3684
- for (let node = spTree.firstChild; node; node = node.nextSibling) {
3685
- if (node.nodeType !== 1) continue;
3686
- const el = node;
3687
- if (isSpTreeProperty(el) || isPlaceholderShape(el)) continue;
3688
- out.push(el);
3689
- }
3690
- return out;
3691
- }
3692
- /**
3693
- * The `n`-th shape child of a `p:spTree` in document (z-)order, skipping the
3694
- * tree's own `nvGrpSpPr`/`grpSpPr` and any trailing `p:extLst`. Returns `null`
3695
- * when `n` is past the last shape (the caller then appends).
3696
- */
3697
- function nthShapeChild(spTree, n) {
3698
- let i = 0;
3699
- for (let node = spTree.firstChild; node; node = node.nextSibling) {
3700
- if (node.nodeType !== 1) continue;
3701
- const el = node;
3702
- if (isSpTreeProperty(el)) continue;
3703
- if (el.namespaceURI === OOXML_NS.p && el.localName === "extLst") continue;
3704
- if (i === n) return el;
3705
- i++;
3706
- }
3707
- return null;
3708
- }
3709
- /** The first shape child of a `p:spTree` (skipping `nvGrpSpPr`/`grpSpPr`), or `null`. */
3710
- function firstShapeChild(spTree) {
3711
- for (let node = spTree.firstChild; node; node = node.nextSibling) {
3712
- if (node.nodeType !== 1) continue;
3713
- const el = node;
3714
- if (!isSpTreeProperty(el)) return el;
3715
- }
3716
- return null;
3717
- }
3718
- /** Collect `node` and all its descendant elements (document order) into `out`. */
3719
- function collectElements(node, out) {
3720
- out.push(node);
3721
- for (let child = node.firstChild; child; child = child.nextSibling) if (child.nodeType === 1) collectElements(child, out);
3722
- }
3723
- //#endregion
3724
3657
  //#region src/read/api/ops/rescale.ts
3725
3658
  /** Build the EMU transform mapping source-canvas coordinates onto the target canvas (see {@link ImportSlideOptions.rescale}). */
3726
3659
  function computeRescale(source, target, mode) {
@@ -4131,7 +4064,7 @@ function mergeEmbeddedFontEntries(dest, entries) {
4131
4064
  const presPart = dest.presentationPart;
4132
4065
  const presRoot = presPart.dom.documentElement;
4133
4066
  if (!presRoot) throw new PackageReadError("package/part-has-no-root", "presentation.xml has no document element to carry embedded fonts into");
4134
- const presRels = dest.opc.relationshipsFor(presPart.partName);
4067
+ const presRels = presentationRels(dest);
4135
4068
  const targetLst = getOrAddChild(presRoot, "p:embeddedFontLst", PRESENTATION_EMBEDDED_FONT_LST_SUCCESSORS);
4136
4069
  const targetByTypeface = /* @__PURE__ */ new Map();
4137
4070
  for (const entry of getElements(targetLst, "p:embeddedFont")) {
@@ -4178,21 +4111,16 @@ function mergeEmbeddedFontEntries(dest, entries) {
4178
4111
  * Pure with respect to the destination deck: it reads only the source package. It was a
4179
4112
  * private method on `Presentation` that used no instance state.
4180
4113
  */
4181
- /** The `p:cSld/p:bg` element of a slide/layout/master root, or `null`. */
4182
- function backgroundOf(root) {
4183
- const cSld = firstChild(root, "p:cSld");
4184
- return cSld ? firstChild(cSld, "p:bg") : null;
4185
- }
4186
4114
  /**
4187
4115
  * The background the slide effectively inherits from its source subgraph: the layout's
4188
4116
  * `p:bg`, else the master's. Returns `null` when the slide carries its own `p:bg` (it stays
4189
4117
  * on the slide and is flattened directly) or when none exists.
4190
4118
  */
4191
4119
  function effectiveBackground(sourceOpc, slideRoot, layoutPartName, masterPartName) {
4192
- if (slideRoot && backgroundOf(slideRoot)) return null;
4120
+ if (slideRoot && backgroundElementOf(slideRoot)) return null;
4193
4121
  const layoutRoot = layoutPartName ? sourceOpc.part(layoutPartName)?.dom.documentElement ?? null : null;
4194
4122
  const masterRoot = masterPartName ? sourceOpc.part(masterPartName)?.dom.documentElement ?? null : null;
4195
- return (layoutRoot && backgroundOf(layoutRoot)) ?? (masterRoot && backgroundOf(masterRoot)) ?? null;
4123
+ return (layoutRoot && backgroundElementOf(layoutRoot)) ?? (masterRoot && backgroundElementOf(masterRoot)) ?? null;
4196
4124
  }
4197
4125
  /**
4198
4126
  * Gather the flatten context for a source slide: walk slide → layout → master → theme,
@@ -4401,8 +4329,7 @@ function carryMasterGraphics(dest, ctx, slideRoot, newPartName, slidePartName, o
4401
4329
  const sourceOpc = ctx.source;
4402
4330
  const layoutPartName = resolveSingleRel(sourceOpc, slidePartName, SLIDE_LAYOUT_REL);
4403
4331
  const masterPartName = layoutPartName ? resolveSingleRel(sourceOpc, layoutPartName, SLIDE_MASTER_REL) : null;
4404
- const cSld = firstChild(slideRoot, "p:cSld");
4405
- const spTree = cSld && firstChild(cSld, "p:spTree");
4332
+ const spTree = spTreeOf(slideRoot);
4406
4333
  if (!spTree) return;
4407
4334
  const doc = ownerDocumentOf(slideRoot);
4408
4335
  const slideRels = dest.opc.relationshipsFor(newPartName);
@@ -4455,11 +4382,11 @@ function destinationLayoutPartName(dest) {
4455
4382
  * orphan, even while momentarily unreferenced.
4456
4383
  */
4457
4384
  const SHARED_CHROME_CONTENT_TYPES = /* @__PURE__ */ new Set([
4458
- "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml",
4459
- "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml",
4460
- "application/vnd.openxmlformats-officedocument.theme+xml",
4385
+ SLIDE_MASTER_CONTENT_TYPE,
4386
+ SLIDE_LAYOUT_CONTENT_TYPE,
4387
+ THEME_CONTENT_TYPE,
4461
4388
  "application/vnd.openxmlformats-officedocument.themeOverride+xml",
4462
- "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
4389
+ NOTES_MASTER_CONTENT_TYPE,
4463
4390
  "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml",
4464
4391
  "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml",
4465
4392
  "application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml",
@@ -4532,9 +4459,7 @@ function rescalePartGeometry(dest, rescaledParts, partName, transform) {
4532
4459
  if (rescaledParts.has(partName)) return;
4533
4460
  rescaledParts.add(partName);
4534
4461
  const part = dest.opc.part(partName);
4535
- const root = part?.dom.documentElement;
4536
- const cSld = root && firstChild(root, "p:cSld");
4537
- const spTree = cSld && firstChild(cSld, "p:spTree");
4462
+ const spTree = spTreeOf(part?.dom.documentElement);
4538
4463
  if (!part || !spTree) return;
4539
4464
  rescaleSpTree(spTree, transform);
4540
4465
  part.markDirty();
@@ -4563,7 +4488,6 @@ const AUDIO_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relatio
4563
4488
  const VIDEO_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
4564
4489
  const MS_MEDIA_REL = "http://schemas.microsoft.com/office/2007/relationships/media";
4565
4490
  const SLIDE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
4566
- const NOTES_SLIDE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
4567
4491
  const CHART_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
4568
4492
  const CHARTEX_CONTENT_TYPE = "application/vnd.ms-office.chartex+xml";
4569
4493
  const CHART_STYLE_CONTENT_TYPE = "application/vnd.ms-office.chartstyle+xml";
@@ -4841,7 +4765,7 @@ var Presentation = class Presentation {
4841
4765
  const slideRels = this.opc.relationshipsFor(partName);
4842
4766
  const formerTargets = [...slideRels].filter((rel) => rel.targetMode !== "External").map((rel) => slideRels.resolveTarget(rel.id));
4843
4767
  const presPart = this.presentationPart;
4844
- const presRels = this.opc.relationshipsFor(presPart.partName);
4768
+ const presRels = presentationRels(this);
4845
4769
  const root = presPart.dom.documentElement;
4846
4770
  const sldIdLst = root && firstChild(root, "p:sldIdLst");
4847
4771
  if (sldIdLst) for (const sldId of getElements(sldIdLst, "p:sldId")) {
@@ -5413,7 +5337,7 @@ var Presentation = class Presentation {
5413
5337
  */
5414
5338
  #insertSlidePart(newPart, at) {
5415
5339
  const presPart = this.presentationPart;
5416
- const presRels = this.opc.relationshipsFor(presPart.partName);
5340
+ const presRels = presentationRels(this);
5417
5341
  for (const rel of presRels) {
5418
5342
  if (rel.type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" || rel.targetMode === "External") continue;
5419
5343
  if (presRels.resolveTarget(rel.id) !== newPart.partName) continue;
@@ -5453,4 +5377,4 @@ var Presentation = class Presentation {
5453
5377
  //#endregion
5454
5378
  export { Placeholder as a, Theme as c, NotesSlide as d, OpcPackage as f, ContentTypes as h, Slide as i, readTagsForPart as l, Part as m, readCoreProperties as n, SlideLayout as o, Relationships as p, readCustomProperties as r, SlideMaster as s, Presentation as t, NotesPlaceholder as u };
5455
5379
 
5456
- //# sourceMappingURL=presentation-DeKTJGHf.js.map
5380
+ //# sourceMappingURL=presentation-3rAKKRfm.js.map