ooxml-core 1.25.2 → 1.26.1

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 (103) hide show
  1. package/README.md +16 -0
  2. package/dist/{PptxHandler-AUK27AQD.mjs → PptxHandler-64BZOBWX.mjs} +3 -3
  3. package/dist/{PptxHandler-QBGEZDCO.cjs → PptxHandler-AILFLRH7.cjs} +3 -3
  4. package/dist/PptxHandler-PMLQGMFQ.mjs +4 -0
  5. package/dist/{PresentationBuilder-RX7D75GZ.mjs → PresentationBuilder-EJY2TYWL.mjs} +2 -2
  6. package/dist/{PresentationBuilder-MEETJGEA.mjs → PresentationBuilder-HBCCO2CF.mjs} +3 -3
  7. package/dist/{PresentationBuilder-CI45KEHL.cjs → PresentationBuilder-RBQP6A37.cjs} +5 -5
  8. package/dist/automation/index.cjs +273 -156
  9. package/dist/automation/index.mjs +273 -156
  10. package/dist/automation/xlsx-read.d.ts +2 -8
  11. package/dist/automation/xlsx-read.d.ts.map +1 -1
  12. package/dist/automation/xlsx.d.ts +2 -2
  13. package/dist/chart/index.cjs +89 -47
  14. package/dist/chart/index.mjs +89 -47
  15. package/dist/{chunk-6DHZZD5R.mjs → chunk-2XMK5SXU.mjs} +106 -48
  16. package/dist/{chunk-VGDHSED6.mjs → chunk-DHAZSMC7.mjs} +1 -1
  17. package/dist/{chunk-TX2QFS3J.mjs → chunk-FZBAMWCJ.mjs} +788 -542
  18. package/dist/{chunk-E2PYQQQV.mjs → chunk-JJ37PCNR.mjs} +89 -47
  19. package/dist/{chunk-S5TGOEQX.cjs → chunk-MU3XSASV.cjs} +106 -47
  20. package/dist/{chunk-GMETZZ3V.cjs → chunk-NXTHB2M3.cjs} +1857 -1611
  21. package/dist/{chunk-HVRFRYYS.mjs → chunk-OQPT5IC3.mjs} +5 -5
  22. package/dist/{chunk-5F7OB7PA.mjs → chunk-OTXJVFMY.mjs} +785 -539
  23. package/dist/{chunk-635WPRNJ.mjs → chunk-R7RL7W43.mjs} +19 -3
  24. package/dist/{chunk-E3PRAHL6.mjs → chunk-WRFMS5CL.mjs} +1 -1
  25. package/dist/docx/embedded.cjs +89 -47
  26. package/dist/docx/embedded.mjs +89 -47
  27. package/dist/docx/index.cjs +89 -47
  28. package/dist/docx/index.mjs +89 -47
  29. package/dist/docx/load/index.cjs +89 -47
  30. package/dist/docx/load/index.mjs +89 -47
  31. package/dist/index.cjs +128 -53
  32. package/dist/index.mjs +128 -53
  33. package/dist/opc/index.cjs +90 -47
  34. package/dist/opc/index.mjs +90 -48
  35. package/dist/opc/zip-limits.d.ts +6 -0
  36. package/dist/opc/zip-limits.d.ts.map +1 -1
  37. package/dist/pptx/automation/index.cjs +954 -622
  38. package/dist/pptx/automation/index.d.ts +4 -4
  39. package/dist/pptx/automation/index.mjs +6 -6
  40. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts → index-CbFowkp4.d.ts} +12 -5
  41. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts.map → index-CbFowkp4.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts → index-D4FnOx6x.d.ts} +3 -3
  43. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts.map → index-D4FnOx6x.d.ts.map} +1 -1
  44. package/dist/pptx/chunks/{index-CgjEEpfK.d.ts → index-D8DNpc1X.d.ts} +289 -118
  45. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +1 -0
  46. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts → text-operations-CNfUj45U.d.ts} +16 -2
  47. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts.map → text-operations-CNfUj45U.d.ts.map} +1 -1
  48. package/dist/pptx/cli/index.cjs +954 -622
  49. package/dist/pptx/cli/index.d.ts +1 -1
  50. package/dist/pptx/cli/index.mjs +5 -5
  51. package/dist/pptx/converter/index.d.ts +1 -1
  52. package/dist/pptx/converter/index.mjs +3 -3
  53. package/dist/pptx/editor/render/editor-history.cjs +21 -0
  54. package/dist/pptx/editor/render/editor-history.d.ts +9 -0
  55. package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
  56. package/dist/pptx/editor/render/editor-history.mjs +21 -0
  57. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  58. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  59. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  60. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  61. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  62. package/dist/pptx/index.cjs +953 -620
  63. package/dist/pptx/index.d.ts +5 -5
  64. package/dist/pptx/index.mjs +6 -6
  65. package/dist/pptx/node/index.d.ts +1 -1
  66. package/dist/pptx/signature-node/index.cjs +89 -47
  67. package/dist/pptx/signature-node/index.mjs +2 -2
  68. package/dist/visio/index.cjs +266 -150
  69. package/dist/visio/index.mjs +266 -150
  70. package/dist/visio/ui/index.cjs +266 -150
  71. package/dist/visio/ui/index.mjs +266 -150
  72. package/dist/xlsx/index.cjs +518 -153
  73. package/dist/xlsx/index.mjs +518 -154
  74. package/dist/xlsx/load/index.cjs +266 -150
  75. package/dist/xlsx/load/index.mjs +266 -150
  76. package/dist/xlsx/numfmt/view.d.ts +13 -0
  77. package/dist/xlsx/numfmt/view.d.ts.map +1 -0
  78. package/dist/xlsx/read/index.d.ts +1 -0
  79. package/dist/xlsx/read/index.d.ts.map +1 -1
  80. package/dist/xlsx/read/limits.d.ts +5 -0
  81. package/dist/xlsx/read/limits.d.ts.map +1 -1
  82. package/dist/xlsx/read/package.d.ts +6 -0
  83. package/dist/xlsx/read/package.d.ts.map +1 -1
  84. package/dist/xlsx/read/rows-stream.d.ts +12 -0
  85. package/dist/xlsx/read/rows-stream.d.ts.map +1 -0
  86. package/dist/xlsx/read/rows.d.ts +37 -0
  87. package/dist/xlsx/read/rows.d.ts.map +1 -0
  88. package/dist/xlsx/read/shared-strings.d.ts +6 -1
  89. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  90. package/dist/xlsx/read/sheet-data-source.d.ts +30 -3
  91. package/dist/xlsx/read/sheet-data-source.d.ts.map +1 -1
  92. package/dist/xlsx/read/sheet-data.d.ts +13 -2
  93. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  94. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  95. package/dist/xlsx/ui/index.cjs +266 -150
  96. package/dist/xlsx/ui/index.mjs +266 -150
  97. package/dist/xml/index.cjs +38 -6
  98. package/dist/xml/index.mjs +37 -7
  99. package/dist/xml/lite.d.ts +15 -0
  100. package/dist/xml/lite.d.ts.map +1 -1
  101. package/package.json +1 -1
  102. package/dist/PptxHandler-5UO5DD5K.mjs +0 -4
  103. package/dist/pptx/chunks/index-CgjEEpfK.d.ts.map +0 -1
@@ -4504,57 +4504,98 @@ function resolveLimits(limits) {
4504
4504
  fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
4505
4505
  };
4506
4506
  }
4507
- function inflateEntryGuarded(entry2, alreadyRead, limits) {
4507
+ async function inflateEntryGuarded(entry2, alreadyRead, limits) {
4508
+ const chunks = [];
4509
+ let size = 0;
4510
+ for await (const chunk2 of streamEntryGuarded(entry2, alreadyRead, limits)) {
4511
+ chunks.push(chunk2);
4512
+ size += chunk2.byteLength;
4513
+ }
4514
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
4515
+ const out = new Uint8Array(size);
4516
+ let offset = 0;
4517
+ for (const chunk2 of chunks) {
4518
+ out.set(chunk2, offset);
4519
+ offset += chunk2.byteLength;
4520
+ }
4521
+ return out;
4522
+ }
4523
+ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
4508
4524
  const r = resolveLimits(limits);
4509
4525
  const declared = declaredEntrySize(entry2);
4510
- return new Promise((resolvePromise, reject) => {
4511
- const chunks = [];
4512
- let size = 0;
4513
- let done = false;
4514
- const stream = entry2.internalStream("uint8array");
4515
- const abort = (error62) => {
4516
- if (done) return;
4517
- done = true;
4518
- stream.pause();
4519
- chunks.length = 0;
4520
- reject(error62);
4521
- };
4522
- stream.on("data", (chunk2) => {
4523
- if (done) return;
4524
- size += chunk2.byteLength;
4525
- if (size > declared || size > r.maxEntryBytes)
4526
- return abort(
4527
- r.fail(
4528
- `${r.label} part ${entry2.name} inflates past its declared size`,
4529
- r.maxEntryBytes,
4530
- size > declared ? "declaredSize" : "maxEntryBytes"
4531
- )
4532
- );
4533
- if (alreadyRead + size > r.maxTotalBytes)
4534
- return abort(
4535
- r.fail(
4536
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
4537
- r.maxTotalBytes,
4538
- "maxTotalBytes"
4539
- )
4540
- );
4541
- chunks.push(chunk2);
4542
- });
4543
- stream.on("error", (error62) => abort(error62));
4544
- stream.on("end", () => {
4545
- if (done) return;
4546
- done = true;
4547
- if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
4548
- const out = new Uint8Array(size);
4549
- let offset = 0;
4550
- for (const chunk2 of chunks) {
4551
- out.set(chunk2, offset);
4552
- offset += chunk2.byteLength;
4553
- }
4554
- resolvePromise(out);
4555
- });
4526
+ const stream = entry2.internalStream("uint8array");
4527
+ const queue = [];
4528
+ let size = 0;
4529
+ let ended = false;
4530
+ let stopped = false;
4531
+ let failure2;
4532
+ let paused = false;
4533
+ let wake;
4534
+ const pause = () => {
4535
+ paused = true;
4536
+ stream.pause();
4537
+ };
4538
+ const resume = () => {
4539
+ if (!paused || stopped) return;
4540
+ paused = false;
4556
4541
  stream.resume();
4542
+ };
4543
+ const fail2 = (error62) => {
4544
+ failure2 ??= error62;
4545
+ stopped = true;
4546
+ queue.length = 0;
4547
+ pause();
4548
+ wake?.();
4549
+ };
4550
+ stream.on("data", (chunk2) => {
4551
+ if (stopped) return pause();
4552
+ size += chunk2.byteLength;
4553
+ if (size > declared || size > r.maxEntryBytes)
4554
+ return fail2(
4555
+ r.fail(
4556
+ `${r.label} part ${entry2.name} inflates past its declared size`,
4557
+ r.maxEntryBytes,
4558
+ size > declared ? "declaredSize" : "maxEntryBytes"
4559
+ )
4560
+ );
4561
+ if (alreadyRead + size > r.maxTotalBytes)
4562
+ return fail2(
4563
+ r.fail(
4564
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
4565
+ r.maxTotalBytes,
4566
+ "maxTotalBytes"
4567
+ )
4568
+ );
4569
+ queue.push(chunk2);
4570
+ if (queue.length >= AHEAD) pause();
4571
+ wake?.();
4572
+ });
4573
+ stream.on("error", (error62) => fail2(error62));
4574
+ stream.on("end", () => {
4575
+ ended = true;
4576
+ wake?.();
4557
4577
  });
4578
+ stream.resume();
4579
+ try {
4580
+ for (; ; ) {
4581
+ if (failure2) throw failure2;
4582
+ const chunk2 = queue.shift();
4583
+ if (chunk2) {
4584
+ if (queue.length < AHEAD / 2) resume();
4585
+ yield chunk2;
4586
+ continue;
4587
+ }
4588
+ if (ended) return;
4589
+ await new Promise((resolve) => {
4590
+ wake = resolve;
4591
+ resume();
4592
+ });
4593
+ wake = void 0;
4594
+ }
4595
+ } finally {
4596
+ stopped = true;
4597
+ if (!ended) pause();
4598
+ }
4558
4599
  }
4559
4600
  function toBase64(bytes) {
4560
4601
  let binary = "";
@@ -4633,7 +4674,7 @@ async function openZip(input2, limits = {}) {
4633
4674
  );
4634
4675
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
4635
4676
  }
4636
- var DEFAULT_ZIP_LIMITS, ZipLimitError, mib;
4677
+ var DEFAULT_ZIP_LIMITS, ZipLimitError, mib, AHEAD;
4637
4678
  var init_zip_limits = __esm({
4638
4679
  "opc/zip-limits.ts"() {
4639
4680
  DEFAULT_ZIP_LIMITS = {
@@ -4655,6 +4696,7 @@ var init_zip_limits = __esm({
4655
4696
  }
4656
4697
  };
4657
4698
  mib = (bytes) => Math.round(bytes / 1048576);
4699
+ AHEAD = 8;
4658
4700
  }
4659
4701
  });
4660
4702
 
@@ -54540,6 +54582,22 @@ var init_theme_effect_schemes_data = __esm({
54540
54582
  function findThemeEffectScheme(id) {
54541
54583
  return THEME_EFFECT_SCHEMES.find((scheme) => scheme.id === id);
54542
54584
  }
54585
+ function formatSchemeKey(scheme) {
54586
+ const raw2 = (styles) => (styles ?? []).map((style) => style.rawNode ?? null);
54587
+ const lists = [scheme.fillStyles, scheme.lineStyles, scheme.effectStyles];
54588
+ return JSON.stringify(
54589
+ [scheme.name ?? null, ...lists.map(raw2), raw2(scheme.backgroundFillStyles)],
54590
+ (_key, value) => {
54591
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
54592
+ return value;
54593
+ }
54594
+ const entries = Object.entries(value);
54595
+ const isAttribute = ([key2]) => key2.startsWith("@_");
54596
+ const attributes3 = entries.filter(isAttribute).sort(([x], [y]) => x < y ? -1 : 1);
54597
+ return Object.fromEntries([...attributes3, ...entries.filter((entry2) => !isAttribute(entry2))]);
54598
+ }
54599
+ );
54600
+ }
54543
54601
  function wrapFormatSchemeXml(fmtSchemeXml) {
54544
54602
  return fmtSchemeXml.replace(
54545
54603
  /^<a:fmtScheme/u,
@@ -94855,6 +94913,42 @@ var init_master_save_helpers = __esm({
94855
94913
  }
94856
94914
  });
94857
94915
 
94916
+ // pptx/core/core/runtime/held-format-schemes.ts
94917
+ function partsKey(deckScheme, themePaths) {
94918
+ return JSON.stringify([formatSchemeKey(deckScheme), [...new Set(themePaths)].sort()]);
94919
+ }
94920
+ var HeldFormatSchemes;
94921
+ var init_held_format_schemes = __esm({
94922
+ "pptx/core/core/runtime/held-format-schemes.ts"() {
94923
+ init_theme_effect_schemes();
94924
+ HeldFormatSchemes = class {
94925
+ elements = /* @__PURE__ */ new Map();
94926
+ partsByDeckScheme = /* @__PURE__ */ new Map();
94927
+ /** Keep `element`, which `scheme` was parsed from. */
94928
+ hold(scheme, element) {
94929
+ this.elements.set(formatSchemeKey(scheme), structuredClone(element));
94930
+ }
94931
+ /** The element `scheme` was parsed from, if one was held. */
94932
+ element(scheme) {
94933
+ return this.elements.get(formatSchemeKey(scheme));
94934
+ }
94935
+ /** What each part in `parts` held while the deck's scheme was `deckScheme`. */
94936
+ holdParts(deckScheme, parts) {
94937
+ if (parts.size > 0) {
94938
+ this.partsByDeckScheme.set(partsKey(deckScheme, [...parts.keys()]), new Map(parts));
94939
+ }
94940
+ }
94941
+ /**
94942
+ * The element each of `themePaths` held the last time the deck's scheme was `deckScheme` over
94943
+ * exactly those parts, if known.
94944
+ */
94945
+ parts(deckScheme, themePaths) {
94946
+ return this.partsByDeckScheme.get(partsKey(deckScheme, themePaths));
94947
+ }
94948
+ };
94949
+ }
94950
+ });
94951
+
94858
94952
  // pptx/core/builders/fluent/PptxXmlBuilder.ts
94859
94953
  var PptxXmlBuilder, PptxSlideBuilder, PptxSlideElementsBuilder, PptxSlideNotesBuilder;
94860
94954
  var init_PptxXmlBuilder = __esm({
@@ -111340,6 +111434,157 @@ var init_pptx_view_props_helpers = __esm({
111340
111434
  }
111341
111435
  });
111342
111436
 
111437
+ // pptx/core/core/runtime/chart-part-registration.ts
111438
+ function asArray4(value) {
111439
+ if (value === void 0 || value === null) {
111440
+ return [];
111441
+ }
111442
+ return (Array.isArray(value) ? value : [value]).filter(
111443
+ (entry2) => Boolean(entry2) && typeof entry2 === "object"
111444
+ );
111445
+ }
111446
+ function nextFreeChartPartPath(zip, directory) {
111447
+ let n = 1;
111448
+ while (zip.file(`${directory}/chart${n}.xml`)) {
111449
+ n += 1;
111450
+ }
111451
+ return `${directory}/chart${n}.xml`;
111452
+ }
111453
+ function resolvePartTarget(fromPart, target) {
111454
+ if (target.startsWith("/")) {
111455
+ return target.slice(1);
111456
+ }
111457
+ const segments = fromPart.split("/").slice(0, -1);
111458
+ for (const segment of target.split("/")) {
111459
+ if (segment === "..") {
111460
+ segments.pop();
111461
+ } else if (segment !== "." && segment !== "") {
111462
+ segments.push(segment);
111463
+ }
111464
+ }
111465
+ return segments.join("/");
111466
+ }
111467
+ function relativePartTarget2(fromPart, toPart) {
111468
+ const from = fromPart.split("/").slice(0, -1);
111469
+ const to = toPart.split("/");
111470
+ let common = 0;
111471
+ while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
111472
+ common += 1;
111473
+ }
111474
+ return [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/");
111475
+ }
111476
+ async function ensureContentTypeOverride2(deps, partPath, contentType) {
111477
+ const xml = await deps.zip.file("[Content_Types].xml")?.async("string");
111478
+ if (!xml) {
111479
+ return;
111480
+ }
111481
+ const tree = deps.parser.parse(xml);
111482
+ const types = tree["Types"] ?? {};
111483
+ const overrides = asArray4(types["Override"]);
111484
+ const partName = `/${partPath}`;
111485
+ if (overrides.some((entry2) => String(entry2["@_PartName"]) === partName)) {
111486
+ return;
111487
+ }
111488
+ overrides.push({ "@_PartName": partName, "@_ContentType": contentType });
111489
+ types["Override"] = overrides;
111490
+ tree["Types"] = types;
111491
+ deps.zip.file("[Content_Types].xml", deps.builder.build(tree));
111492
+ }
111493
+ async function rewriteChartRelationship(deps, slidePath, rewrite) {
111494
+ const slash = slidePath.lastIndexOf("/");
111495
+ const relsPath2 = `${slidePath.slice(0, slash + 1)}_rels/${slidePath.slice(slash + 1)}.rels`;
111496
+ const xml = await deps.zip.file(relsPath2)?.async("string");
111497
+ if (!xml) {
111498
+ return void 0;
111499
+ }
111500
+ const tree = deps.parser.parse(xml);
111501
+ const root = tree["Relationships"];
111502
+ const relationships3 = asArray4(root?.["Relationship"]);
111503
+ const match = relationships3.find((rel) => String(rel["@_Id"]) === rewrite.relationshipId) ?? relationships3.find(
111504
+ (rel) => resolvePartTarget(slidePath, String(rel["@_Target"] ?? "")) === rewrite.oldPartPath
111505
+ );
111506
+ if (!match || !root) {
111507
+ return void 0;
111508
+ }
111509
+ match["@_Type"] = rewrite.relationshipType;
111510
+ match["@_Target"] = relativePartTarget2(slidePath, rewrite.newPartPath);
111511
+ delete match["@_TargetMode"];
111512
+ root["Relationship"] = relationships3.length === 1 ? relationships3[0] : relationships3;
111513
+ deps.zip.file(relsPath2, deps.builder.build(tree));
111514
+ return String(match["@_Id"]);
111515
+ }
111516
+ function rebindGraphicData(node2, relationshipId2, extended2) {
111517
+ for (const key2 of Object.keys(node2)) {
111518
+ delete node2[key2];
111519
+ }
111520
+ node2["@_uri"] = extended2 ? CHART_EX_GRAPHIC_DATA_URI : CHART_GRAPHIC_DATA_URI;
111521
+ if (extended2) {
111522
+ node2["cx:chart"] = {
111523
+ "@_xmlns:cx": CHART_EX_GRAPHIC_DATA_URI,
111524
+ "@_xmlns:r": NS_R,
111525
+ "@_r:id": relationshipId2
111526
+ };
111527
+ } else {
111528
+ node2["c:chart"] = {
111529
+ "@_xmlns:c": CHART_GRAPHIC_DATA_URI,
111530
+ "@_xmlns:r": NS_R,
111531
+ "@_r:id": relationshipId2
111532
+ };
111533
+ }
111534
+ }
111535
+ function visitGraphicData(node2, relationshipId2, extended2, getLocalName2) {
111536
+ if (!node2 || typeof node2 !== "object") {
111537
+ return 0;
111538
+ }
111539
+ if (Array.isArray(node2)) {
111540
+ return node2.reduce(
111541
+ (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended2, getLocalName2),
111542
+ 0
111543
+ );
111544
+ }
111545
+ const object2 = node2;
111546
+ let count = 0;
111547
+ for (const key2 of Object.keys(object2)) {
111548
+ if (key2.startsWith("@_")) {
111549
+ continue;
111550
+ }
111551
+ const value = object2[key2];
111552
+ if (getLocalName2(key2) === "graphicData" && value && typeof value === "object") {
111553
+ for (const candidate of asArray4(value)) {
111554
+ const chartKey = Object.keys(candidate).find((k) => getLocalName2(k) === "chart");
111555
+ const chart = chartKey ? candidate[chartKey] : void 0;
111556
+ if (chart && String(chart["@_r:id"]) === relationshipId2) {
111557
+ rebindGraphicData(candidate, relationshipId2, extended2);
111558
+ count += 1;
111559
+ }
111560
+ }
111561
+ continue;
111562
+ }
111563
+ count += visitGraphicData(value, relationshipId2, extended2, getLocalName2);
111564
+ }
111565
+ return count;
111566
+ }
111567
+ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended2) {
111568
+ const xml = await deps.zip.file(slidePath)?.async("string");
111569
+ if (!xml) {
111570
+ return 0;
111571
+ }
111572
+ const tree = deps.parser.parse(xml);
111573
+ const count = visitGraphicData(tree, relationshipId2, extended2, deps.getLocalName);
111574
+ if (count > 0) {
111575
+ deps.zip.file(slidePath, deps.builder.build(tree));
111576
+ }
111577
+ return count;
111578
+ }
111579
+ var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
111580
+ var init_chart_part_registration = __esm({
111581
+ "pptx/core/core/runtime/chart-part-registration.ts"() {
111582
+ CHART_GRAPHIC_DATA_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
111583
+ CHART_EX_GRAPHIC_DATA_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
111584
+ NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
111585
+ }
111586
+ });
111587
+
111343
111588
  // pptx/core/utils/chart-color-style-writer.ts
111344
111589
  function localName22(key2) {
111345
111590
  return key2.replace(/^.*:/u, "");
@@ -111609,7 +111854,7 @@ function buildChartExSpaceXml(chartData) {
111609
111854
  const chartSpace = {
111610
111855
  "@_xmlns:cx": NS_CX,
111611
111856
  "@_xmlns:a": NS_A,
111612
- "@_xmlns:r": NS_R,
111857
+ "@_xmlns:r": NS_R2,
111613
111858
  "cx:chartData": {
111614
111859
  "cx:data": chartData.series.map(
111615
111860
  (series, index2) => buildChartExData(chartData, series, index2)
@@ -111623,7 +111868,7 @@ function buildChartExSpaceXml(chartData) {
111623
111868
  }
111624
111869
  return { "cx:chartSpace": chartSpace };
111625
111870
  }
111626
- var NS_CX, NS_A, NS_R, NS_C;
111871
+ var NS_CX, NS_A, NS_R2, NS_C;
111627
111872
  var init_chart_cx_generator = __esm({
111628
111873
  "pptx/core/utils/chart-cx-generator.ts"() {
111629
111874
  init_chart_cx_legend();
@@ -111631,7 +111876,7 @@ var init_chart_cx_generator = __esm({
111631
111876
  init_chart_cx_legend();
111632
111877
  NS_CX = "http://schemas.microsoft.com/office/drawing/2014/chartex";
111633
111878
  NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main";
111634
- NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
111879
+ NS_R2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
111635
111880
  NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart";
111636
111881
  }
111637
111882
  });
@@ -113258,7 +113503,7 @@ function buildChartSpaceXml(chartData) {
113258
113503
  "c:chartSpace": {
113259
113504
  "@_xmlns:c": NS_C2,
113260
113505
  "@_xmlns:a": NS_A2,
113261
- "@_xmlns:r": NS_R2,
113506
+ "@_xmlns:r": NS_R3,
113262
113507
  "c:chart": chart
113263
113508
  }
113264
113509
  };
@@ -113266,7 +113511,7 @@ function buildChartSpaceXml(chartData) {
113266
113511
  applyGeneratedChartSpaceFormat(result, chartData);
113267
113512
  return result;
113268
113513
  }
113269
- var NS_C2, NS_A2, NS_R2, CAT_AX_ID, VAL_AX_ID, SER_AX_ID, SCATTER_LIKE;
113514
+ var NS_C2, NS_A2, NS_R3, CAT_AX_ID, VAL_AX_ID, SER_AX_ID, SCATTER_LIKE;
113270
113515
  var init_chart_xml_generator = __esm({
113271
113516
  "pptx/core/utils/chart-xml-generator.ts"() {
113272
113517
  init_chart_bubble_options();
@@ -113287,7 +113532,7 @@ var init_chart_xml_generator = __esm({
113287
113532
  init_chart_xml_series_fill();
113288
113533
  NS_C2 = "http://schemas.openxmlformats.org/drawingml/2006/chart";
113289
113534
  NS_A2 = "http://schemas.openxmlformats.org/drawingml/2006/main";
113290
- NS_R2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
113535
+ NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
113291
113536
  CAT_AX_ID = 111111111;
113292
113537
  VAL_AX_ID = 222222222;
113293
113538
  SER_AX_ID = 333333333;
@@ -115439,7 +115684,7 @@ function buildTitleDefRPr(style, existing, resolveColor2) {
115439
115684
  }
115440
115685
  return rPr;
115441
115686
  }
115442
- function asArray4(value) {
115687
+ function asArray5(value) {
115443
115688
  if (Array.isArray(value)) {
115444
115689
  return value;
115445
115690
  }
@@ -115458,7 +115703,7 @@ function applyRichTitleFont(title, style, getLocalName2, resolveColor2) {
115458
115703
  return txKey;
115459
115704
  }
115460
115705
  const pKey = findKey30(rich, "p", getLocalName2) ?? "a:p";
115461
- const paragraphs = asArray4(rich[pKey]).map((para) => {
115706
+ const paragraphs = asArray5(rich[pKey]).map((para) => {
115462
115707
  const next = { ...para };
115463
115708
  const pPrKey = findKey30(next, "pPr", getLocalName2) ?? "a:pPr";
115464
115709
  const pPr = { ...ensureXmlChildOrCreate(next, pPrKey, "first") };
@@ -115471,7 +115716,7 @@ function applyRichTitleFont(title, style, getLocalName2, resolveColor2) {
115471
115716
  next[pPrKey] = pPr;
115472
115717
  const rKey = findKey30(next, "r", getLocalName2);
115473
115718
  if (rKey) {
115474
- const runs = asArray4(next[rKey]).map((run2) => {
115719
+ const runs = asArray5(next[rKey]).map((run2) => {
115475
115720
  const rPrKey = findKey30(run2, "rPr", getLocalName2) ?? "a:rPr";
115476
115721
  const existingRPr = run2[rPrKey] ?? {};
115477
115722
  const nextRun = { ...run2 };
@@ -115865,7 +116110,7 @@ var init_chart_neutral_save = __esm({
115865
116110
  function findKey31(node2, localName28, getLocalName2) {
115866
116111
  return Object.keys(node2).find((key2) => getLocalName2(key2) === localName28);
115867
116112
  }
115868
- function asArray5(value) {
116113
+ function asArray6(value) {
115869
116114
  if (value === void 0 || value === null) {
115870
116115
  return [];
115871
116116
  }
@@ -115879,8 +116124,8 @@ function dimensionType(node2) {
115879
116124
  function replaceLevels(target, source, getLocalName2) {
115880
116125
  const targetKey = findKey31(target, "lvl", getLocalName2) ?? "cx:lvl";
115881
116126
  const sourceKey = findKey31(source, "lvl", getLocalName2);
115882
- const oldLevels = asArray5(target[targetKey]);
115883
- const newLevels = asArray5(sourceKey ? source[sourceKey] : void 0).map((level2, index2) => {
116127
+ const oldLevels = asArray6(target[targetKey]);
116128
+ const newLevels = asArray6(sourceKey ? source[sourceKey] : void 0).map((level2, index2) => {
115884
116129
  const old = oldLevels[index2];
115885
116130
  if (!old) {
115886
116131
  return level2;
@@ -115899,8 +116144,8 @@ function replaceChartExDataDimensions(target, fresh, getLocalName2) {
115899
116144
  for (const kind of ["strDim", "numDim"]) {
115900
116145
  const targetKey = findKey31(target, kind, getLocalName2) ?? `cx:${kind}`;
115901
116146
  const freshKey = findKey31(fresh, kind, getLocalName2);
115902
- const existing = asArray5(target[targetKey]);
115903
- const incoming = asArray5(freshKey ? fresh[freshKey] : void 0);
116147
+ const existing = asArray6(target[targetKey]);
116148
+ const incoming = asArray6(freshKey ? fresh[freshKey] : void 0);
115904
116149
  for (const dimension of incoming) {
115905
116150
  const wantedType = dimensionType(dimension);
115906
116151
  let match = existing.find((candidate) => dimensionType(candidate) === wantedType);
@@ -115938,7 +116183,7 @@ function child28(node2, localName28, getLocalName2) {
115938
116183
  const value = key2 ? node2[key2] : void 0;
115939
116184
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
115940
116185
  }
115941
- function asArray6(value) {
116186
+ function asArray7(value) {
115942
116187
  if (value === void 0 || value === null) {
115943
116188
  return [];
115944
116189
  }
@@ -116127,7 +116372,7 @@ function chartExLayoutChanged(chartSpace, chartData, getLocalName2) {
116127
116372
  getLocalName2
116128
116373
  );
116129
116374
  const seriesKey = region ? findKey32(region, "series", getLocalName2) : void 0;
116130
- const first2 = region && seriesKey ? asArray6(region[seriesKey])[0] : void 0;
116375
+ const first2 = region && seriesKey ? asArray7(region[seriesKey])[0] : void 0;
116131
116376
  const existing = String(first2?.["@_layoutId"] ?? "").toLowerCase();
116132
116377
  const series = chartData.series[0];
116133
116378
  if (!existing || !series) {
@@ -116145,9 +116390,9 @@ function applyChartExUpdate(chartSpace, chartData, getLocalName2) {
116145
116390
  const chartDataKey = findKey32(chartSpace, "chartData", getLocalName2);
116146
116391
  const chartDataNode = (chartDataKey ? chartSpace[chartDataKey] : void 0) ?? {};
116147
116392
  const dataKey = findKey32(chartDataNode, "data", getLocalName2) ?? "cx:data";
116148
- const dataNodes = asArray6(chartDataNode[dataKey]);
116393
+ const dataNodes = asArray7(chartDataNode[dataKey]);
116149
116394
  const seriesKey = findKey32(region, "series", getLocalName2) ?? "cx:series";
116150
- const existing = asArray6(region[seriesKey]);
116395
+ const existing = asArray7(region[seriesKey]);
116151
116396
  const updated = [];
116152
116397
  chartData.series.forEach((series, index2) => {
116153
116398
  const node2 = existing[index2];
@@ -116229,157 +116474,6 @@ var init_chart_external_workbook_save = __esm({
116229
116474
  }
116230
116475
  });
116231
116476
 
116232
- // pptx/core/core/runtime/chart-part-registration.ts
116233
- function asArray7(value) {
116234
- if (value === void 0 || value === null) {
116235
- return [];
116236
- }
116237
- return (Array.isArray(value) ? value : [value]).filter(
116238
- (entry2) => Boolean(entry2) && typeof entry2 === "object"
116239
- );
116240
- }
116241
- function nextFreeChartPartPath(zip, directory) {
116242
- let n = 1;
116243
- while (zip.file(`${directory}/chart${n}.xml`)) {
116244
- n += 1;
116245
- }
116246
- return `${directory}/chart${n}.xml`;
116247
- }
116248
- function resolvePartTarget(fromPart, target) {
116249
- if (target.startsWith("/")) {
116250
- return target.slice(1);
116251
- }
116252
- const segments = fromPart.split("/").slice(0, -1);
116253
- for (const segment of target.split("/")) {
116254
- if (segment === "..") {
116255
- segments.pop();
116256
- } else if (segment !== "." && segment !== "") {
116257
- segments.push(segment);
116258
- }
116259
- }
116260
- return segments.join("/");
116261
- }
116262
- function relativePartTarget2(fromPart, toPart) {
116263
- const from = fromPart.split("/").slice(0, -1);
116264
- const to = toPart.split("/");
116265
- let common = 0;
116266
- while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
116267
- common += 1;
116268
- }
116269
- return [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/");
116270
- }
116271
- async function ensureContentTypeOverride2(deps, partPath, contentType) {
116272
- const xml = await deps.zip.file("[Content_Types].xml")?.async("string");
116273
- if (!xml) {
116274
- return;
116275
- }
116276
- const tree = deps.parser.parse(xml);
116277
- const types = tree["Types"] ?? {};
116278
- const overrides = asArray7(types["Override"]);
116279
- const partName = `/${partPath}`;
116280
- if (overrides.some((entry2) => String(entry2["@_PartName"]) === partName)) {
116281
- return;
116282
- }
116283
- overrides.push({ "@_PartName": partName, "@_ContentType": contentType });
116284
- types["Override"] = overrides;
116285
- tree["Types"] = types;
116286
- deps.zip.file("[Content_Types].xml", deps.builder.build(tree));
116287
- }
116288
- async function rewriteChartRelationship(deps, slidePath, rewrite) {
116289
- const slash = slidePath.lastIndexOf("/");
116290
- const relsPath2 = `${slidePath.slice(0, slash + 1)}_rels/${slidePath.slice(slash + 1)}.rels`;
116291
- const xml = await deps.zip.file(relsPath2)?.async("string");
116292
- if (!xml) {
116293
- return void 0;
116294
- }
116295
- const tree = deps.parser.parse(xml);
116296
- const root = tree["Relationships"];
116297
- const relationships3 = asArray7(root?.["Relationship"]);
116298
- const match = relationships3.find((rel) => String(rel["@_Id"]) === rewrite.relationshipId) ?? relationships3.find(
116299
- (rel) => resolvePartTarget(slidePath, String(rel["@_Target"] ?? "")) === rewrite.oldPartPath
116300
- );
116301
- if (!match || !root) {
116302
- return void 0;
116303
- }
116304
- match["@_Type"] = rewrite.relationshipType;
116305
- match["@_Target"] = relativePartTarget2(slidePath, rewrite.newPartPath);
116306
- delete match["@_TargetMode"];
116307
- root["Relationship"] = relationships3.length === 1 ? relationships3[0] : relationships3;
116308
- deps.zip.file(relsPath2, deps.builder.build(tree));
116309
- return String(match["@_Id"]);
116310
- }
116311
- function rebindGraphicData(node2, relationshipId2, extended2) {
116312
- for (const key2 of Object.keys(node2)) {
116313
- delete node2[key2];
116314
- }
116315
- node2["@_uri"] = extended2 ? CHART_EX_GRAPHIC_DATA_URI : CHART_GRAPHIC_DATA_URI;
116316
- if (extended2) {
116317
- node2["cx:chart"] = {
116318
- "@_xmlns:cx": CHART_EX_GRAPHIC_DATA_URI,
116319
- "@_xmlns:r": NS_R3,
116320
- "@_r:id": relationshipId2
116321
- };
116322
- } else {
116323
- node2["c:chart"] = {
116324
- "@_xmlns:c": CHART_GRAPHIC_DATA_URI,
116325
- "@_xmlns:r": NS_R3,
116326
- "@_r:id": relationshipId2
116327
- };
116328
- }
116329
- }
116330
- function visitGraphicData(node2, relationshipId2, extended2, getLocalName2) {
116331
- if (!node2 || typeof node2 !== "object") {
116332
- return 0;
116333
- }
116334
- if (Array.isArray(node2)) {
116335
- return node2.reduce(
116336
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended2, getLocalName2),
116337
- 0
116338
- );
116339
- }
116340
- const object2 = node2;
116341
- let count = 0;
116342
- for (const key2 of Object.keys(object2)) {
116343
- if (key2.startsWith("@_")) {
116344
- continue;
116345
- }
116346
- const value = object2[key2];
116347
- if (getLocalName2(key2) === "graphicData" && value && typeof value === "object") {
116348
- for (const candidate of asArray7(value)) {
116349
- const chartKey = Object.keys(candidate).find((k) => getLocalName2(k) === "chart");
116350
- const chart = chartKey ? candidate[chartKey] : void 0;
116351
- if (chart && String(chart["@_r:id"]) === relationshipId2) {
116352
- rebindGraphicData(candidate, relationshipId2, extended2);
116353
- count += 1;
116354
- }
116355
- }
116356
- continue;
116357
- }
116358
- count += visitGraphicData(value, relationshipId2, extended2, getLocalName2);
116359
- }
116360
- return count;
116361
- }
116362
- async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended2) {
116363
- const xml = await deps.zip.file(slidePath)?.async("string");
116364
- if (!xml) {
116365
- return 0;
116366
- }
116367
- const tree = deps.parser.parse(xml);
116368
- const count = visitGraphicData(tree, relationshipId2, extended2, deps.getLocalName);
116369
- if (count > 0) {
116370
- deps.zip.file(slidePath, deps.builder.build(tree));
116371
- }
116372
- return count;
116373
- }
116374
- var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R3;
116375
- var init_chart_part_registration = __esm({
116376
- "pptx/core/core/runtime/chart-part-registration.ts"() {
116377
- CHART_GRAPHIC_DATA_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
116378
- CHART_EX_GRAPHIC_DATA_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
116379
- NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
116380
- }
116381
- });
116382
-
116383
116477
  // pptx/core/core/runtime/chart-part-family-switch.ts
116384
116478
  function detectChartPartFamily(chartSpace, getLocalName2) {
116385
116479
  const keys = Object.keys(chartSpace);
@@ -120426,18 +120520,22 @@ var init_PptxHandlerRuntimeElementActions = __esm({
120426
120520
  * Write or remove a single `a:hlinkClick` / `a:hlinkHover` node on
120427
120521
  * a `p:cNvPr` parent.
120428
120522
  */
120429
- serializeSingleAction(cNvPr, nodeName, action, resolveHyperlinkRelationshipId) {
120523
+ serializeSingleAction(cNvPr, nodeName, action, links) {
120430
120524
  if (!action) {
120431
120525
  delete cNvPr[nodeName];
120432
120526
  return;
120433
120527
  }
120434
120528
  const node2 = {};
120529
+ const url2 = action.url?.trim() || (/^ppaction:\/\/hlinksldjump\b/iu.test(action.action ?? "") && typeof action.targetSlideIndex === "number" ? links.slideTargetAt?.(action.targetSlideIndex) : void 0);
120435
120530
  let rId = action.rId;
120436
- if (!rId && action.url) {
120531
+ if (rId && url2 && links.getSlideRelationshipMap().get(rId) !== url2) {
120532
+ rId = void 0;
120533
+ }
120534
+ if (!rId && url2) {
120437
120535
  const forceExternal = /^ppaction:\/\/(program|hlinkfile|hlinkpres)\b/iu.test(
120438
120536
  action.action ?? ""
120439
120537
  );
120440
- rId = resolveHyperlinkRelationshipId(action.url, forceExternal) ?? void 0;
120538
+ rId = links.resolveHyperlinkRelationshipId(url2, forceExternal) ?? void 0;
120441
120539
  }
120442
120540
  node2["@_r:id"] = rId ?? "";
120443
120541
  if (action.action) {
@@ -120511,7 +120609,7 @@ var init_PptxHandlerRuntimeElementActions = __esm({
120511
120609
  * the `a:hlinkClick` and `a:hlinkHover` nodes on the element's
120512
120610
  * non-visual properties.
120513
120611
  */
120514
- serializeElementActions(shape, el, resolveHyperlinkRelationshipId) {
120612
+ serializeElementActions(shape, el, links) {
120515
120613
  const key2 = this.getTreeBucketKeyForElementType(el.type);
120516
120614
  const cNvPr = this.getCnvPrNode(shape, key2);
120517
120615
  if (!cNvPr) {
@@ -120519,8 +120617,8 @@ var init_PptxHandlerRuntimeElementActions = __esm({
120519
120617
  }
120520
120618
  const actionClick = "actionClick" in el ? el.actionClick : void 0;
120521
120619
  const actionHover = "actionHover" in el ? el.actionHover : void 0;
120522
- this.serializeSingleAction(cNvPr, "a:hlinkClick", actionClick, resolveHyperlinkRelationshipId);
120523
- this.serializeSingleAction(cNvPr, "a:hlinkHover", actionHover, resolveHyperlinkRelationshipId);
120620
+ this.serializeSingleAction(cNvPr, "a:hlinkClick", actionClick, links);
120621
+ this.serializeSingleAction(cNvPr, "a:hlinkHover", actionHover, links);
120524
120622
  const isDecorative = "isDecorative" in el ? el.isDecorative : void 0;
120525
120623
  serializeDecorativeExtension(cNvPr, isDecorative);
120526
120624
  }
@@ -121426,6 +121524,11 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121426
121524
  const upSegments = Array.from({ length: fromParts.length }).fill("..");
121427
121525
  return [...upSegments, ...toParts].join("/");
121428
121526
  }
121527
+ /**
121528
+ * Point a slide master's theme relationship at `themePath`.
121529
+ *
121530
+ * @returns whether the master had a theme relationship to rewrite
121531
+ */
121429
121532
  async setMasterThemeRelationship(masterPath, themePath) {
121430
121533
  const relsPath2 = masterPath.replace(
121431
121534
  /ppt\/slideMasters\/(slideMaster\d+)\.xml/,
@@ -121433,7 +121536,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121433
121536
  );
121434
121537
  const relsFile = this.zip.file(relsPath2);
121435
121538
  if (!relsFile) {
121436
- return;
121539
+ return false;
121437
121540
  }
121438
121541
  const relsXml = await relsFile.async("string");
121439
121542
  const relsData = this.parser.parse(relsXml);
@@ -121441,28 +121544,13 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121441
121544
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
121442
121545
  const themeRel = relationships3.find((rel) => String(rel["@_Type"] || "").includes("/theme"));
121443
121546
  if (!themeRel) {
121444
- return;
121547
+ return false;
121445
121548
  }
121446
121549
  themeRel["@_Target"] = this.buildRelativeTargetPath(masterPath, themePath);
121447
121550
  relRoot["Relationship"] = relationships3;
121448
121551
  relsData["Relationships"] = relRoot;
121449
121552
  this.zip.file(relsPath2, this.builder.build(relsData));
121450
- }
121451
- async setPresentationTheme(themePath, applyToAllMasters = true) {
121452
- const normalizedThemePath = themePath.trim().replace(/\\/g, "/");
121453
- if (!normalizedThemePath.startsWith("ppt/theme/")) {
121454
- return;
121455
- }
121456
- const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
121457
- if (!masterFiles || masterFiles.length === 0) {
121458
- return;
121459
- }
121460
- const targetMasters = applyToAllMasters ? masterFiles : [masterFiles[0]];
121461
- await Promise.all(
121462
- targetMasters.map(async (masterFile) => {
121463
- await this.setMasterThemeRelationship(masterFile.name, normalizedThemePath);
121464
- })
121465
- );
121553
+ return true;
121466
121554
  }
121467
121555
  /** The text of a package part, or `undefined` when the package has no such part. */
121468
121556
  async readPartText(path4) {
@@ -121792,8 +121880,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121792
121880
  this.masterXmlMap.set(path4, data);
121793
121881
  }
121794
121882
  const masterCSldName = (xmlAttr(sldMaster["p:cSld"], "name") ?? "").trim();
121795
- const bg = sldMaster["p:cSld"]?.["p:bg"];
121796
- const backgroundColor = this.parseBackgroundColor(bg);
121797
121883
  const spTree = sldMaster["p:cSld"]?.["p:spTree"];
121798
121884
  const placeholders = this.extractPlaceholderList(spTree);
121799
121885
  let preserve;
@@ -121847,7 +121933,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121847
121933
  results.push({
121848
121934
  path: path4,
121849
121935
  name: masterCSldName.length > 0 ? masterCSldName : void 0,
121850
- backgroundColor,
121851
121936
  themePath,
121852
121937
  layoutPaths: layoutPaths.length > 0 ? layoutPaths : void 0,
121853
121938
  layouts: layouts.length > 0 ? layouts : void 0,
@@ -121985,11 +122070,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121985
122070
  layout.clrMapOverride = overrideMap;
121986
122071
  }
121987
122072
  }
121988
- const bg = xmlPath(sldLayout, "p:cSld", "p:bg");
121989
- const bgColor = this.parseBackgroundColor(bg);
121990
- if (bgColor) {
121991
- layout.backgroundColor = bgColor;
121992
- }
121993
122073
  const spTree = xmlPath(sldLayout, "p:cSld", "p:spTree");
121994
122074
  const placeholders = this.extractPlaceholderList(spTree);
121995
122075
  if (placeholders.length > 0) {
@@ -133827,7 +133907,7 @@ var init_PptxHandlerRuntimeSaveElementWriter = __esm({
133827
133907
  if (ctx.connectorShapeIds) {
133828
133908
  applyConnectorShapeIds(shape, el, ctx.connectorShapeIds);
133829
133909
  }
133830
- this.serializeElementActions(shape, el, ctx.resolveHyperlinkRelationshipId);
133910
+ this.serializeElementActions(shape, el, ctx);
133831
133911
  this.serializeShapeLocks(shape, el);
133832
133912
  this.applyHiddenToCnvPr(shape, el);
133833
133913
  this.applyNameToCnvPr(shape, el);
@@ -134805,6 +134885,7 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
134805
134885
  init_theme_override_utils();
134806
134886
  init_builders();
134807
134887
  init_authored_slide_background();
134888
+ init_chart_part_registration();
134808
134889
  init_PptxHandlerRuntimeSaveElementWriter();
134809
134890
  init_save_structural_id_gate();
134810
134891
  init_slide_fingerprint();
@@ -134940,7 +135021,7 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
134940
135021
  * Process a single slide during save: update slide XML, process elements,
134941
135022
  * rebuild shape tree, and persist relationships.
134942
135023
  */
134943
- async processSlideForSave(slide, saveSession, constants) {
135024
+ async processSlideForSave(slide, saveSession, constants, slidePaths = []) {
134944
135025
  if (this.canSkipSlideSave(slide)) {
134945
135026
  return;
134946
135027
  }
@@ -135125,6 +135206,10 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
135125
135206
  slideRelationshipRegistry,
135126
135207
  resolveHyperlinkRelationshipId: (target, forceExternal) => slideRelationshipRegistry.resolveHyperlinkRelationshipId(target, forceExternal),
135127
135208
  getSlideRelationshipMap: () => slideRelationshipRegistry.toRelationshipMap(),
135209
+ slideTargetAt: (index2) => {
135210
+ const target = slidePaths[index2];
135211
+ return target ? relativePartTarget2(slide.id, target) : void 0;
135212
+ },
135128
135213
  resolvedMediaBytes,
135129
135214
  saveSession,
135130
135215
  slideImageRelationshipType: constants.slideImageRelationshipType,
@@ -137434,7 +137519,23 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
137434
137519
  }
137435
137520
  return this.isStrictOoxml ? "strict" : "transitional";
137436
137521
  }
137522
+ /** The save running now, or the last one: see {@link save}. */
137523
+ saveQueue = Promise.resolve();
137524
+ /**
137525
+ * Saves run one at a time. A save rewrites `this.zip` in place across many awaits and moves
137526
+ * per-part baselines (slide fingerprints, chart data, pending chart updates) while it runs, so
137527
+ * a second save that starts mid-way (a viewer's autosave snapshot firing during the user's own
137528
+ * save) read half-written state: it skipped the slide as unchanged and wrote the chart part's
137529
+ * original XML back over the edit, in both outputs. Each save now waits for the one before it;
137530
+ * one that fails does not hold up the next.
137531
+ */
137437
137532
  async save(slides, options) {
137533
+ const run2 = this.saveQueue.then(() => this.saveNow(slides, options));
137534
+ this.saveQueue = run2.catch(() => void 0);
137535
+ return run2;
137536
+ }
137537
+ /** One save, with the package to itself; callers go through {@link save}. */
137538
+ async saveNow(slides, options) {
137438
137539
  validateSlideGeometry(slides);
137439
137540
  const templates = [
137440
137541
  ...options?.slideMasters ?? [],
@@ -137452,7 +137553,7 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
137452
137553
  return this.saveAsLegacyPpt(
137453
137554
  slides,
137454
137555
  options,
137455
- () => this.save(slides, {
137556
+ () => this.saveNow(slides, {
137456
137557
  ...options,
137457
137558
  pptPassword: void 0,
137458
137559
  outputFormat: "pptx",
@@ -137484,8 +137585,9 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
137484
137585
  await this.ensureNotesMasterForAuthoredNotes(slides, saveConstants);
137485
137586
  await this.ensureHandoutMasterInfrastructure(options?.handoutMaster, saveConstants);
137486
137587
  this.templateElementBaselines.beginSave();
137588
+ const slidePaths = slides.map((slide) => slide.id);
137487
137589
  for (const slide of slides) {
137488
- await this.processSlideForSave(slide, saveSession, saveConstants);
137590
+ await this.processSlideForSave(slide, saveSession, saveConstants, slidePaths);
137489
137591
  }
137490
137592
  this.templateElementBaselines.commitSave();
137491
137593
  const contentTypesXml3 = await this.zip.file("[Content_Types].xml")?.async("string");
@@ -142439,6 +142541,25 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
142439
142541
  }
142440
142542
  return void 0;
142441
142543
  }
142544
+ /**
142545
+ * The colour a slide master or layout paints from its own `p:bg`, resolved exactly as a
142546
+ * slide's background is: through the active master's colour map and format scheme, with
142547
+ * `clrMapOverride` (a layout's `p:clrMapOvr`, or `null`) taking precedence. The caller makes
142548
+ * the part's master active first; a master's `bgRef` on `bg1` means `dk1` under a dark
142549
+ * `p:clrMap`, which no other state can tell.
142550
+ */
142551
+ extractTemplateBackgroundColor(partXml, rootTag2, clrMapOverride) {
142552
+ if (!partXml) {
142553
+ return void 0;
142554
+ }
142555
+ const previousOverride = this.currentSlideClrMapOverride;
142556
+ this.currentSlideClrMapOverride = clrMapOverride;
142557
+ try {
142558
+ return this.extractBackgroundColor(partXml, rootTag2);
142559
+ } finally {
142560
+ this.currentSlideClrMapOverride = previousOverride;
142561
+ }
142562
+ }
142442
142563
  /**
142443
142564
  * Composite a resolved background colour with its `a:alpha` (or
142444
142565
  * `a:alphaMod`/`a:alphaOff`) opacity onto opaque white.
@@ -143005,6 +143126,31 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
143005
143126
  const masterFormatScheme = this.masterThemeFormatSchemes.get(masterPath);
143006
143127
  this.themeFormatScheme = masterFormatScheme ?? this.globalThemeFormatSchemeSnapshot;
143007
143128
  }
143129
+ /**
143130
+ * Run `work` with one master's theme state active and no slide colour-map override, then
143131
+ * put back whatever state was active before, so a part parsed on request (a layout preview)
143132
+ * resolves through its own master without disturbing the caller's.
143133
+ */
143134
+ async withMasterThemeState(masterPath, work) {
143135
+ const saved = {
143136
+ colors: this.themeColorMap,
143137
+ fonts: this.themeFontMap,
143138
+ format: this.themeFormatScheme,
143139
+ clrMap: this.currentMasterClrMap,
143140
+ slideClrMap: this.currentSlideClrMapOverride
143141
+ };
143142
+ this.applyMasterThemeState(masterPath);
143143
+ this.currentSlideClrMapOverride = null;
143144
+ try {
143145
+ return await work();
143146
+ } finally {
143147
+ this.themeColorMap = saved.colors;
143148
+ this.themeFontMap = saved.fonts;
143149
+ this.themeFormatScheme = saved.format;
143150
+ this.currentMasterClrMap = saved.clrMap;
143151
+ this.currentSlideClrMapOverride = saved.slideClrMap;
143152
+ }
143153
+ }
143008
143154
  /**
143009
143155
  * Extract the `p:bg/@showAnimation` flag from a slide's XML.
143010
143156
  * Returns `true` when the background should animate, `false` when
@@ -143919,18 +144065,33 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
143919
144065
  this.rememberUnparsedMasterNodes(partPath, spTree, part.elements);
143920
144066
  }
143921
144067
  /**
143922
- * Populate `elements` on every slide master and on each of its layouts.
144068
+ * Resolve the background of every slide master and of each of its layouts,
144069
+ * and populate their `elements`.
143923
144070
  *
143924
- * Scheme colours on a master's own shapes must resolve through that
143925
- * master's colour map and theme, so the active master state is switched
143926
- * per part and reset to the deck-wide snapshot afterwards.
144071
+ * Scheme colours on a master, its own `p:bgRef` included, must resolve
144072
+ * through that master's colour map and theme, so the active master state is
144073
+ * switched per part and reset to the deck-wide snapshot afterwards.
143927
144074
  */
143928
144075
  async enrichSlideMasterElements(masters) {
143929
144076
  for (const master of masters) {
143930
144077
  try {
143931
144078
  this.applyMasterThemeState(master.path);
144079
+ master.backgroundColor = this.extractTemplateBackgroundColor(
144080
+ this.masterXmlMap.get(master.path),
144081
+ "p:sldMaster",
144082
+ null
144083
+ );
143932
144084
  await this.enrichMasterPartElements(master, "p:sldMaster");
143933
144085
  for (const layout of master.layouts ?? []) {
144086
+ const layoutXml3 = this.layoutXmlMap.get(layout.path);
144087
+ const backgroundColor = this.extractTemplateBackgroundColor(
144088
+ layoutXml3,
144089
+ "p:sldLayout",
144090
+ layoutXml3 ? this.parseLayoutClrMapOverride(layoutXml3) : null
144091
+ );
144092
+ if (backgroundColor) {
144093
+ layout.backgroundColor = backgroundColor;
144094
+ }
143934
144095
  await this.enrichMasterPartElements(layout, "p:sldLayout");
143935
144096
  }
143936
144097
  } catch (e) {
@@ -144201,20 +144362,23 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
144201
144362
  this.layoutCache.delete(layoutPath);
144202
144363
  this.eagerDecodeImages = true;
144203
144364
  }
144204
- let elements3;
144365
+ const masterPath = this.resolveMasterPathForLayout(layoutPath);
144366
+ let parsed;
144205
144367
  try {
144206
- elements3 = await this.getLayoutElementsByPath(layoutPath);
144368
+ parsed = await this.withMasterThemeState(masterPath, async () => ({
144369
+ elements: await this.getLayoutElementsByPath(layoutPath),
144370
+ background: this.resolveLayoutPreviewBackground(layoutXml3, masterPath)
144371
+ }));
144207
144372
  } finally {
144208
144373
  this.eagerDecodeImages = previousEagerDecode;
144209
144374
  }
144210
144375
  const cSld = xmlPath(layoutXml3, "p:sldLayout", "p:cSld");
144211
- const background = this.resolveLayoutPreviewBackground(layoutPath, cSld);
144212
144376
  const preview = {
144213
144377
  path: layoutPath,
144214
144378
  width: this.rawSlideWidthEmu / EMU_PER_PX,
144215
144379
  height: this.rawSlideHeightEmu / EMU_PER_PX,
144216
- ...background,
144217
- elements: elements3,
144380
+ ...parsed.background,
144381
+ elements: parsed.elements,
144218
144382
  placeholders: this.extractPlaceholderList(xmlChild(cSld, "p:spTree"))
144219
144383
  };
144220
144384
  this.layoutPreviewCache.set(layoutPath, preview);
@@ -144250,19 +144414,18 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
144250
144414
  }
144251
144415
  /**
144252
144416
  * Resolve the background a layout thumbnail should paint, falling back to
144253
- * the layout's master when the layout itself declares none.
144417
+ * the layout's master when the layout itself declares none. Runs with the
144418
+ * master active; the layout's own colour map override applies to an
144419
+ * inherited background too, as a slide's does.
144254
144420
  */
144255
- resolveLayoutPreviewBackground(layoutPath, cSld) {
144256
- const ownBackground = this.parseBackgroundColor(xmlChild(cSld, "p:bg"));
144257
- if (ownBackground) {
144258
- return { backgroundColor: ownBackground };
144259
- }
144260
- const masterPath = this.resolveMasterPathForLayout(layoutPath);
144261
- const masterXml = masterPath ? this.masterXmlMap.get(masterPath) : void 0;
144262
- const masterBackground = this.parseBackgroundColor(
144263
- xmlChild(xmlPath(masterXml, "p:sldMaster", "p:cSld"), "p:bg")
144421
+ resolveLayoutPreviewBackground(layoutXml3, masterPath) {
144422
+ const clrMapOverride = this.parseLayoutClrMapOverride(layoutXml3);
144423
+ const backgroundColor = this.extractTemplateBackgroundColor(layoutXml3, "p:sldLayout", clrMapOverride) ?? this.extractTemplateBackgroundColor(
144424
+ masterPath ? this.masterXmlMap.get(masterPath) : void 0,
144425
+ "p:sldMaster",
144426
+ clrMapOverride
144264
144427
  );
144265
- return masterBackground ? { backgroundColor: masterBackground } : {};
144428
+ return backgroundColor ? { backgroundColor } : {};
144266
144429
  }
144267
144430
  };
144268
144431
  }
@@ -145070,15 +145233,298 @@ var init_PptxHandlerRuntimeThemeRefResolution = __esm({
145070
145233
  }
145071
145234
  });
145072
145235
 
145236
+ // pptx/core/core/runtime/theme-scheme-edit.ts
145237
+ function normalizeHex6(hex5) {
145238
+ return hex5.replace(/^#/, "").toUpperCase();
145239
+ }
145240
+ function buildSrgbClrNode(hex5) {
145241
+ return { "a:srgbClr": { "@_val": normalizeHex6(hex5) } };
145242
+ }
145243
+ function themeElementsOf(data) {
145244
+ const root = data["a:theme"];
145245
+ return root?.["a:themeElements"];
145246
+ }
145247
+ function applyColorSchemeToThemeXml(data, colorScheme) {
145248
+ const themeElements = themeElementsOf(data);
145249
+ if (!themeElements) {
145250
+ return false;
145251
+ }
145252
+ const clrScheme = themeElements["a:clrScheme"] ?? {};
145253
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145254
+ clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
145255
+ }
145256
+ themeElements["a:clrScheme"] = clrScheme;
145257
+ return true;
145258
+ }
145259
+ function applyLatinTypeface(group, latin) {
145260
+ const font = group ?? {};
145261
+ font["a:latin"] = { "@_typeface": latin };
145262
+ if (!font["a:ea"]) {
145263
+ font["a:ea"] = { "@_typeface": "" };
145264
+ }
145265
+ if (!font["a:cs"]) {
145266
+ font["a:cs"] = { "@_typeface": "" };
145267
+ }
145268
+ return font;
145269
+ }
145270
+ function applyFontSchemeToThemeXml(data, fontScheme) {
145271
+ const themeElements = themeElementsOf(data);
145272
+ if (!themeElements) {
145273
+ return false;
145274
+ }
145275
+ const fntScheme = themeElements["a:fontScheme"] ?? {};
145276
+ if (fontScheme.majorFont?.latin) {
145277
+ fntScheme["a:majorFont"] = applyLatinTypeface(
145278
+ fntScheme["a:majorFont"],
145279
+ fontScheme.majorFont.latin
145280
+ );
145281
+ }
145282
+ if (fontScheme.minorFont?.latin) {
145283
+ fntScheme["a:minorFont"] = applyLatinTypeface(
145284
+ fntScheme["a:minorFont"],
145285
+ fontScheme.minorFont.latin
145286
+ );
145287
+ }
145288
+ themeElements["a:fontScheme"] = fntScheme;
145289
+ return true;
145290
+ }
145291
+ function applyColorSchemeToMap(map2, colorScheme, clrMap) {
145292
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145293
+ map2[key2] = normalizeHex6(colorScheme[key2]);
145294
+ }
145295
+ for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
145296
+ const target = clrMap?.[alias] ?? defaultTarget;
145297
+ const resolved = map2[target];
145298
+ if (resolved !== void 0) {
145299
+ map2[alias] = resolved;
145300
+ }
145301
+ }
145302
+ }
145303
+ function applyFontSchemeToMap(map2, fontScheme) {
145304
+ if (fontScheme.majorFont?.latin) {
145305
+ map2["mj-lt"] = fontScheme.majorFont.latin;
145306
+ map2["mj-ea"] = fontScheme.majorFont.latin;
145307
+ map2["mj-cs"] = fontScheme.majorFont.latin;
145308
+ }
145309
+ if (fontScheme.minorFont?.latin) {
145310
+ map2["mn-lt"] = fontScheme.minorFont.latin;
145311
+ map2["mn-ea"] = fontScheme.minorFont.latin;
145312
+ map2["mn-cs"] = fontScheme.minorFont.latin;
145313
+ }
145314
+ }
145315
+ var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
145316
+ var init_theme_scheme_edit = __esm({
145317
+ "pptx/core/core/runtime/theme-scheme-edit.ts"() {
145318
+ THEME_COLOR_SCHEME_KEYS2 = [
145319
+ "dk1",
145320
+ "lt1",
145321
+ "dk2",
145322
+ "lt2",
145323
+ "accent1",
145324
+ "accent2",
145325
+ "accent3",
145326
+ "accent4",
145327
+ "accent5",
145328
+ "accent6",
145329
+ "hlink",
145330
+ "folHlink"
145331
+ ];
145332
+ DEFAULT_CLR_MAP_ALIASES = {
145333
+ tx1: "dk1",
145334
+ bg1: "lt1",
145335
+ tx2: "dk2",
145336
+ bg2: "lt2"
145337
+ };
145338
+ }
145339
+ });
145340
+
145341
+ // pptx/core/core/runtime/theme-part-model.ts
145342
+ function colorSchemeFromMap(colorMap) {
145343
+ const scheme = {};
145344
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145345
+ scheme[key2] = colorMap[key2] || "";
145346
+ }
145347
+ return scheme;
145348
+ }
145349
+ function fontGroup(fontMap, prefix, byScript) {
145350
+ const latin = fontMap[`${prefix}-lt`];
145351
+ const eastAsia = fontMap[`${prefix}-ea`];
145352
+ const complexScript = fontMap[`${prefix}-cs`];
145353
+ return {
145354
+ ...latin ? { latin } : {},
145355
+ ...eastAsia ? { eastAsia } : {},
145356
+ ...complexScript ? { complexScript } : {},
145357
+ ...Object.keys(byScript).length > 0 ? { byScript: { ...byScript } } : {}
145358
+ };
145359
+ }
145360
+ function fontSchemeFromMap(fontMap, majorByScript, minorByScript) {
145361
+ return {
145362
+ majorFont: fontGroup(fontMap, "mj", majorByScript),
145363
+ minorFont: fontGroup(fontMap, "mn", minorByScript)
145364
+ };
145365
+ }
145366
+ var init_theme_part_model = __esm({
145367
+ "pptx/core/core/runtime/theme-part-model.ts"() {
145368
+ init_theme_scheme_edit();
145369
+ }
145370
+ });
145371
+
145372
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts
145373
+ var FONT_SLOTS, PptxHandlerRuntime84;
145374
+ var init_PptxHandlerRuntimeThemePartModel = __esm({
145375
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts"() {
145376
+ init_PptxHandlerRuntimeThemeRefResolution();
145377
+ init_theme_part_model();
145378
+ init_theme_scheme_edit();
145379
+ FONT_SLOTS = [
145380
+ ["mj", "a:majorFont"],
145381
+ ["mn", "a:minorFont"]
145382
+ ];
145383
+ PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
145384
+ /** Parse one theme part's XML. Side-effect free. */
145385
+ parseThemePartXml(themeXml3) {
145386
+ const themeData = this.parser.parse(themeXml3);
145387
+ const themeRoot = themeData["a:theme"];
145388
+ const themeElements = themeRoot?.["a:themeElements"];
145389
+ const colorScheme = themeElements?.["a:clrScheme"];
145390
+ const fontScheme = themeElements?.["a:fontScheme"];
145391
+ const fmtScheme = themeElements?.["a:fmtScheme"];
145392
+ const text2 = (value) => String(value || "").trim() || void 0;
145393
+ const colorMap = { ...this.getDefaultSchemeColorMap() };
145394
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145395
+ const parsed = this.parseColorChoice(colorScheme?.[`a:${key2}`]);
145396
+ if (parsed) {
145397
+ colorMap[key2] = parsed;
145398
+ }
145399
+ }
145400
+ const fontMap = {};
145401
+ const typeface = (node2) => this.normalizeTypefaceToken(String(node2?.["@_typeface"] || ""));
145402
+ for (const [prefix, tag] of FONT_SLOTS) {
145403
+ const group = fontScheme?.[tag];
145404
+ const latin = typeface(group?.["a:latin"]);
145405
+ if (latin) {
145406
+ fontMap[`${prefix}-lt`] = latin;
145407
+ fontMap[`${prefix}-ea`] = latin;
145408
+ fontMap[`${prefix}-cs`] = latin;
145409
+ }
145410
+ const eastAsia = typeface(group?.["a:ea"]);
145411
+ if (eastAsia) {
145412
+ fontMap[`${prefix}-ea`] = eastAsia;
145413
+ }
145414
+ const complexScript = typeface(group?.["a:cs"]);
145415
+ if (complexScript) {
145416
+ fontMap[`${prefix}-cs`] = complexScript;
145417
+ }
145418
+ }
145419
+ const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
145420
+ const objectDefaults = objectDefaultsNode && {
145421
+ spDef: objectDefaultsNode["a:spDef"],
145422
+ lnDef: objectDefaultsNode["a:lnDef"],
145423
+ txDef: objectDefaultsNode["a:txDef"]
145424
+ };
145425
+ const hasObjectDefaults = objectDefaults !== void 0 && (objectDefaults.spDef !== void 0 || objectDefaults.lnDef !== void 0 || objectDefaults.txDef !== void 0);
145426
+ return {
145427
+ name: text2(themeRoot?.["@_name"]),
145428
+ colorSchemeName: text2(colorScheme?.["@_name"]),
145429
+ fontSchemeName: text2(fontScheme?.["@_name"]),
145430
+ colorMap,
145431
+ fontMap,
145432
+ // Per-script fonts (`<a:font script="Hans|Hant|Arab|...">`): M4.
145433
+ majorFontScripts: this.collectFontScriptOverrides(
145434
+ fontScheme?.["a:majorFont"]
145435
+ ),
145436
+ minorFontScripts: this.collectFontScriptOverrides(
145437
+ fontScheme?.["a:minorFont"]
145438
+ ),
145439
+ // objectDefaults: M5.
145440
+ objectDefaults: hasObjectDefaults ? objectDefaults : void 0,
145441
+ extraClrSchemeLst: themeRoot?.["a:extraClrSchemeLst"],
145442
+ custClrLst: themeRoot?.["a:custClrLst"],
145443
+ extLst: themeRoot?.["a:extLst"],
145444
+ formatScheme: fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0
145445
+ };
145446
+ }
145447
+ /**
145448
+ * Record a parsed part under its path: its original XML (byte-stable passthrough on save,
145449
+ * C-H3), its names, per-script fonts and the raw subtrees the save re-emits.
145450
+ */
145451
+ cacheThemePartModel(themePath, themeXml3, model) {
145452
+ this.originalThemeXmlByPath.set(themePath, themeXml3);
145453
+ const keyed = [
145454
+ [this.masterThemeNames, model.name],
145455
+ [this.masterThemeColorSchemeNames, model.colorSchemeName],
145456
+ [this.masterThemeFontSchemeNames, model.fontSchemeName],
145457
+ [this.masterThemeObjectDefaults, model.objectDefaults],
145458
+ [this.masterThemeExtraClrSchemeLst, model.extraClrSchemeLst],
145459
+ [this.masterThemeCustClrLst, model.custClrLst],
145460
+ [this.masterThemeExtLst, model.extLst]
145461
+ ];
145462
+ for (const [map2, value] of keyed) {
145463
+ if (value !== void 0) {
145464
+ map2.set(themePath, value);
145465
+ }
145466
+ }
145467
+ if (Object.keys(model.majorFontScripts).length > 0) {
145468
+ this.masterThemeMajorFontScripts.set(themePath, model.majorFontScripts);
145469
+ }
145470
+ if (Object.keys(model.minorFontScripts).length > 0) {
145471
+ this.masterThemeMinorFontScripts.set(themePath, model.minorFontScripts);
145472
+ }
145473
+ }
145474
+ /**
145475
+ * Parse `<a:font script="..." typeface="..."/>` children of a major or minor font node into a
145476
+ * `script -> typeface` dictionary. fast-xml-parser collapses repeated tags into arrays, so the
145477
+ * array form is walked regardless of how many siblings are present. Phase 4 Stream A / M4.
145478
+ */
145479
+ collectFontScriptOverrides(fontNode) {
145480
+ const overrides = {};
145481
+ if (!fontNode) {
145482
+ return overrides;
145483
+ }
145484
+ const fontEntries = this.ensureArray(fontNode["a:font"]);
145485
+ for (const entry2 of fontEntries) {
145486
+ const script = String(entry2?.["@_script"] || "").trim();
145487
+ const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
145488
+ if (script && typeface) {
145489
+ overrides[script] = typeface;
145490
+ }
145491
+ }
145492
+ return overrides;
145493
+ }
145494
+ /**
145495
+ * The colour, font and format schemes and name of one theme part in the package, as the part holds
145496
+ * them now (a scheme edit already written to it included). Reads only: the loaded theme, the
145497
+ * masters and what a save writes are unchanged. `undefined` when the package has no such part.
145498
+ */
145499
+ async getThemePartSchemes(themePath) {
145500
+ const path4 = themePath.trim().replace(/\\/g, "/");
145501
+ const themeXml3 = await this.zip.file(path4)?.async("string");
145502
+ if (themeXml3 === void 0) {
145503
+ return void 0;
145504
+ }
145505
+ const model = this.parseThemePartXml(themeXml3);
145506
+ return {
145507
+ path: path4,
145508
+ ...model.name ? { name: model.name } : {},
145509
+ colorScheme: colorSchemeFromMap(model.colorMap),
145510
+ fontScheme: fontSchemeFromMap(model.fontMap, model.majorFontScripts, model.minorFontScripts),
145511
+ ...model.formatScheme ? { formatScheme: model.formatScheme } : {}
145512
+ };
145513
+ }
145514
+ };
145515
+ }
145516
+ });
145517
+
145073
145518
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts
145074
145519
  function isPresentationThemePartPath(path4) {
145075
145520
  return /^ppt\/theme\/(?!themeOverride)[^/]+\.xml$/iu.test(path4);
145076
145521
  }
145077
- var PptxHandlerRuntime84;
145522
+ var PptxHandlerRuntime85;
145078
145523
  var init_PptxHandlerRuntimeThemeLoading = __esm({
145079
145524
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts"() {
145080
- init_PptxHandlerRuntimeThemeRefResolution();
145081
- PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
145525
+ init_PptxHandlerRuntimeThemePartModel();
145526
+ init_theme_part_model();
145527
+ PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
145082
145528
  async resolvePrimaryThemePath() {
145083
145529
  const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
145084
145530
  if (!masterFiles || masterFiles.length === 0) {
@@ -145154,42 +145600,12 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145154
145600
  if (!hasColors && !hasFonts) {
145155
145601
  return void 0;
145156
145602
  }
145157
- let colorScheme;
145158
- if (hasColors) {
145159
- colorScheme = {
145160
- dk1: this.themeColorMap["dk1"] || "",
145161
- lt1: this.themeColorMap["lt1"] || "",
145162
- dk2: this.themeColorMap["dk2"] || "",
145163
- lt2: this.themeColorMap["lt2"] || "",
145164
- accent1: this.themeColorMap["accent1"] || "",
145165
- accent2: this.themeColorMap["accent2"] || "",
145166
- accent3: this.themeColorMap["accent3"] || "",
145167
- accent4: this.themeColorMap["accent4"] || "",
145168
- accent5: this.themeColorMap["accent5"] || "",
145169
- accent6: this.themeColorMap["accent6"] || "",
145170
- hlink: this.themeColorMap["hlink"] || "",
145171
- folHlink: this.themeColorMap["folHlink"] || ""
145172
- };
145173
- }
145174
- let fontScheme;
145175
- if (hasFonts) {
145176
- const majorByScript = this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts);
145177
- const minorByScript = this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts);
145178
- fontScheme = {
145179
- majorFont: {
145180
- latin: this.themeFontMap["mj-lt"],
145181
- eastAsia: this.themeFontMap["mj-ea"],
145182
- complexScript: this.themeFontMap["mj-cs"],
145183
- ...Object.keys(majorByScript).length > 0 ? { byScript: majorByScript } : {}
145184
- },
145185
- minorFont: {
145186
- latin: this.themeFontMap["mn-lt"],
145187
- eastAsia: this.themeFontMap["mn-ea"],
145188
- complexScript: this.themeFontMap["mn-cs"],
145189
- ...Object.keys(minorByScript).length > 0 ? { byScript: minorByScript } : {}
145190
- }
145191
- };
145192
- }
145603
+ const colorScheme = hasColors ? colorSchemeFromMap(this.themeColorMap) : void 0;
145604
+ const fontScheme = hasFonts ? fontSchemeFromMap(
145605
+ this.themeFontMap,
145606
+ this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts),
145607
+ this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts)
145608
+ ) : void 0;
145193
145609
  return {
145194
145610
  colorScheme,
145195
145611
  fontScheme,
@@ -145266,134 +145682,10 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145266
145682
  return null;
145267
145683
  }
145268
145684
  const themeXml3 = await themeFile.async("string");
145269
- this.originalThemeXmlByPath.set(themePath, themeXml3);
145270
- const themeData = this.parser.parse(themeXml3);
145271
- const themeRoot = themeData["a:theme"];
145272
- const themeElements = themeRoot?.["a:themeElements"];
145273
- const colorScheme = themeElements?.["a:clrScheme"];
145274
- const fontScheme = themeElements?.["a:fontScheme"];
145275
- const fmtScheme = themeElements?.["a:fmtScheme"];
145276
- const themeName = String(themeRoot?.["@_name"] || "").trim();
145277
- if (themeName) {
145278
- this.masterThemeNames.set(themePath, themeName);
145279
- }
145280
- const colorSchemeName = String(colorScheme?.["@_name"] || "").trim();
145281
- if (colorSchemeName) {
145282
- this.masterThemeColorSchemeNames.set(themePath, colorSchemeName);
145283
- }
145284
- const fontSchemeName = String(fontScheme?.["@_name"] || "").trim();
145285
- if (fontSchemeName) {
145286
- this.masterThemeFontSchemeNames.set(themePath, fontSchemeName);
145287
- }
145288
- const defaultMap = this.getDefaultSchemeColorMap();
145289
- const colorMap = { ...defaultMap };
145290
- if (colorScheme) {
145291
- const schemeKeys = [
145292
- "dk1",
145293
- "lt1",
145294
- "dk2",
145295
- "lt2",
145296
- "accent1",
145297
- "accent2",
145298
- "accent3",
145299
- "accent4",
145300
- "accent5",
145301
- "accent6",
145302
- "hlink",
145303
- "folHlink"
145304
- ];
145305
- for (const key2 of schemeKeys) {
145306
- const colorNode = colorScheme[`a:${key2}`];
145307
- const parsed = this.parseColorChoice(colorNode);
145308
- if (parsed) {
145309
- colorMap[key2] = parsed;
145310
- }
145311
- }
145312
- }
145313
- const majorFontNode = fontScheme?.["a:majorFont"];
145314
- const minorFontNode = fontScheme?.["a:minorFont"];
145315
- const majorLatin = majorFontNode?.["a:latin"];
145316
- const minorLatin = minorFontNode?.["a:latin"];
145317
- const majorFont = this.normalizeTypefaceToken(String(majorLatin?.["@_typeface"] || ""));
145318
- const minorFont = this.normalizeTypefaceToken(String(minorLatin?.["@_typeface"] || ""));
145319
- const fontMap = {};
145320
- if (majorFont) {
145321
- fontMap["mj-lt"] = majorFont;
145322
- fontMap["mj-ea"] = majorFont;
145323
- fontMap["mj-cs"] = majorFont;
145324
- }
145325
- if (minorFont) {
145326
- fontMap["mn-lt"] = minorFont;
145327
- fontMap["mn-ea"] = minorFont;
145328
- fontMap["mn-cs"] = minorFont;
145329
- }
145330
- const majorEa = this.normalizeTypefaceToken(
145331
- String(majorFontNode?.["a:ea"]?.["@_typeface"] || "")
145332
- );
145333
- if (majorEa) {
145334
- fontMap["mj-ea"] = majorEa;
145335
- }
145336
- const majorCs = this.normalizeTypefaceToken(
145337
- String(majorFontNode?.["a:cs"]?.["@_typeface"] || "")
145338
- );
145339
- if (majorCs) {
145340
- fontMap["mj-cs"] = majorCs;
145341
- }
145342
- const minorEa = this.normalizeTypefaceToken(
145343
- String(minorFontNode?.["a:ea"]?.["@_typeface"] || "")
145344
- );
145345
- if (minorEa) {
145346
- fontMap["mn-ea"] = minorEa;
145347
- }
145348
- const minorCs = this.normalizeTypefaceToken(
145349
- String(minorFontNode?.["a:cs"]?.["@_typeface"] || "")
145350
- );
145351
- if (minorCs) {
145352
- fontMap["mn-cs"] = minorCs;
145353
- }
145354
- const majorScripts = this.collectFontScriptOverrides(majorFontNode);
145355
- if (Object.keys(majorScripts).length > 0) {
145356
- this.masterThemeMajorFontScripts.set(themePath, majorScripts);
145357
- }
145358
- const minorScripts = this.collectFontScriptOverrides(minorFontNode);
145359
- if (Object.keys(minorScripts).length > 0) {
145360
- this.masterThemeMinorFontScripts.set(themePath, minorScripts);
145361
- }
145362
- const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
145363
- if (objectDefaultsNode) {
145364
- const od = {
145365
- spDef: objectDefaultsNode["a:spDef"],
145366
- lnDef: objectDefaultsNode["a:lnDef"],
145367
- txDef: objectDefaultsNode["a:txDef"]
145368
- };
145369
- if (od.spDef !== void 0 || od.lnDef !== void 0 || od.txDef !== void 0) {
145370
- this.masterThemeObjectDefaults.set(themePath, od);
145371
- }
145372
- }
145373
- const extraClrSchemeLst = themeRoot?.["a:extraClrSchemeLst"];
145374
- if (extraClrSchemeLst !== void 0) {
145375
- this.masterThemeExtraClrSchemeLst.set(themePath, extraClrSchemeLst);
145376
- }
145377
- const custClrLst = themeRoot?.["a:custClrLst"];
145378
- if (custClrLst !== void 0) {
145379
- this.masterThemeCustClrLst.set(themePath, custClrLst);
145380
- }
145381
- const themeExtLst = themeRoot?.["a:extLst"];
145382
- if (themeExtLst !== void 0) {
145383
- this.masterThemeExtLst.set(themePath, themeExtLst);
145384
- }
145385
- const formatScheme = fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0;
145386
- return { colorMap, fontMap, formatScheme };
145685
+ const model = this.parseThemePartXml(themeXml3);
145686
+ this.cacheThemePartModel(themePath, themeXml3, model);
145687
+ return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
145387
145688
  }
145388
- /**
145389
- * Parse `<a:font script="…" typeface="…"/>` children of a major or
145390
- * minor font node into a `script -> typeface` dictionary.
145391
- *
145392
- * fast-xml-parser collapses repeated tags into arrays, so iterate
145393
- * over the array form regardless of how many siblings are present.
145394
- *
145395
- * Phase 4 Stream A / M4.
145396
- */
145397
145689
  /**
145398
145690
  * Flatten a per-theme-path script-override map (`themePath -> {script ->
145399
145691
  * typeface}`) into a single `{script -> typeface}` lookup for
@@ -145411,21 +145703,6 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145411
145703
  }
145412
145704
  return aggregate;
145413
145705
  }
145414
- collectFontScriptOverrides(fontNode) {
145415
- const overrides = {};
145416
- if (!fontNode) {
145417
- return overrides;
145418
- }
145419
- const fontEntries = this.ensureArray(fontNode["a:font"]);
145420
- for (const entry2 of fontEntries) {
145421
- const script = String(entry2?.["@_script"] || "").trim();
145422
- const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
145423
- if (script && typeface) {
145424
- overrides[script] = typeface;
145425
- }
145426
- }
145427
- return overrides;
145428
- }
145429
145706
  /**
145430
145707
  * Resolve the theme file path referenced by a given master's `.rels`.
145431
145708
  * Returns `undefined` when the master has no theme relationship.
@@ -145511,119 +145788,14 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145511
145788
  }
145512
145789
  });
145513
145790
 
145514
- // pptx/core/core/runtime/theme-scheme-edit.ts
145515
- function normalizeHex6(hex5) {
145516
- return hex5.replace(/^#/, "").toUpperCase();
145517
- }
145518
- function buildSrgbClrNode(hex5) {
145519
- return { "a:srgbClr": { "@_val": normalizeHex6(hex5) } };
145520
- }
145521
- function themeElementsOf(data) {
145522
- const root = data["a:theme"];
145523
- return root?.["a:themeElements"];
145524
- }
145525
- function applyColorSchemeToThemeXml(data, colorScheme) {
145526
- const themeElements = themeElementsOf(data);
145527
- if (!themeElements) {
145528
- return false;
145529
- }
145530
- const clrScheme = themeElements["a:clrScheme"] ?? {};
145531
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145532
- clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
145533
- }
145534
- themeElements["a:clrScheme"] = clrScheme;
145535
- return true;
145536
- }
145537
- function applyLatinTypeface(group, latin) {
145538
- const font = group ?? {};
145539
- font["a:latin"] = { "@_typeface": latin };
145540
- if (!font["a:ea"]) {
145541
- font["a:ea"] = { "@_typeface": "" };
145542
- }
145543
- if (!font["a:cs"]) {
145544
- font["a:cs"] = { "@_typeface": "" };
145545
- }
145546
- return font;
145547
- }
145548
- function applyFontSchemeToThemeXml(data, fontScheme) {
145549
- const themeElements = themeElementsOf(data);
145550
- if (!themeElements) {
145551
- return false;
145552
- }
145553
- const fntScheme = themeElements["a:fontScheme"] ?? {};
145554
- if (fontScheme.majorFont?.latin) {
145555
- fntScheme["a:majorFont"] = applyLatinTypeface(
145556
- fntScheme["a:majorFont"],
145557
- fontScheme.majorFont.latin
145558
- );
145559
- }
145560
- if (fontScheme.minorFont?.latin) {
145561
- fntScheme["a:minorFont"] = applyLatinTypeface(
145562
- fntScheme["a:minorFont"],
145563
- fontScheme.minorFont.latin
145564
- );
145565
- }
145566
- themeElements["a:fontScheme"] = fntScheme;
145567
- return true;
145568
- }
145569
- function applyColorSchemeToMap(map2, colorScheme, clrMap) {
145570
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145571
- map2[key2] = normalizeHex6(colorScheme[key2]);
145572
- }
145573
- for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
145574
- const target = clrMap?.[alias] ?? defaultTarget;
145575
- const resolved = map2[target];
145576
- if (resolved !== void 0) {
145577
- map2[alias] = resolved;
145578
- }
145579
- }
145580
- }
145581
- function applyFontSchemeToMap(map2, fontScheme) {
145582
- if (fontScheme.majorFont?.latin) {
145583
- map2["mj-lt"] = fontScheme.majorFont.latin;
145584
- map2["mj-ea"] = fontScheme.majorFont.latin;
145585
- map2["mj-cs"] = fontScheme.majorFont.latin;
145586
- }
145587
- if (fontScheme.minorFont?.latin) {
145588
- map2["mn-lt"] = fontScheme.minorFont.latin;
145589
- map2["mn-ea"] = fontScheme.minorFont.latin;
145590
- map2["mn-cs"] = fontScheme.minorFont.latin;
145591
- }
145592
- }
145593
- var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
145594
- var init_theme_scheme_edit = __esm({
145595
- "pptx/core/core/runtime/theme-scheme-edit.ts"() {
145596
- THEME_COLOR_SCHEME_KEYS2 = [
145597
- "dk1",
145598
- "lt1",
145599
- "dk2",
145600
- "lt2",
145601
- "accent1",
145602
- "accent2",
145603
- "accent3",
145604
- "accent4",
145605
- "accent5",
145606
- "accent6",
145607
- "hlink",
145608
- "folHlink"
145609
- ];
145610
- DEFAULT_CLR_MAP_ALIASES = {
145611
- tx1: "dk1",
145612
- bg1: "lt1",
145613
- tx2: "dk2",
145614
- bg2: "lt2"
145615
- };
145616
- }
145617
- });
145618
-
145619
145791
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts
145620
- var THEME_PART_PATTERN, PptxHandlerRuntime85;
145792
+ var THEME_PART_PATTERN, PptxHandlerRuntime86;
145621
145793
  var init_PptxHandlerRuntimeThemeProcessing = __esm({
145622
145794
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts"() {
145623
145795
  init_PptxHandlerRuntimeThemeLoading();
145624
145796
  init_theme_scheme_edit();
145625
145797
  THEME_PART_PATTERN = /^ppt\/theme\/theme\d+\.xml$/;
145626
- PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
145798
+ PptxHandlerRuntime86 = class extends PptxHandlerRuntime85 {
145627
145799
  /**
145628
145800
  * The theme parts an edit should touch, primary theme first.
145629
145801
  *
@@ -145664,8 +145836,9 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
145664
145836
  return this.parser.parse(xml);
145665
145837
  }
145666
145838
  /**
145667
- * Parse, edit, and write back every target theme part. Parts the edit
145668
- * cannot apply to (no `a:themeElements`) are left untouched.
145839
+ * Parse, edit, and write back every target theme part (`edit` gets the
145840
+ * part's path too). Parts the edit cannot apply to (no `a:themeElements`)
145841
+ * are left untouched.
145669
145842
  *
145670
145843
  * @returns the paths that were rewritten
145671
145844
  */
@@ -145673,7 +145846,7 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
145673
145846
  const written = [];
145674
145847
  for (const path4 of await this.resolveThemeEditTargets(themePaths)) {
145675
145848
  const data = await this.readThemePart(path4);
145676
- if (!data || !edit(data)) {
145849
+ if (!data || !edit(data, path4)) {
145677
145850
  continue;
145678
145851
  }
145679
145852
  this.zip.file(path4, this.builder.build(data));
@@ -145777,15 +145950,90 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
145777
145950
  }
145778
145951
  });
145779
145952
 
145953
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts
145954
+ function themePartPath(themePath) {
145955
+ const path4 = themePath.trim().replace(/\\/g, "/");
145956
+ return path4.startsWith("ppt/theme/") ? path4 : void 0;
145957
+ }
145958
+ var SLIDE_MASTER_PART, PptxHandlerRuntime87;
145959
+ var init_PptxHandlerRuntimeThemeSwitching = __esm({
145960
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts"() {
145961
+ init_PptxHandlerRuntimeThemeProcessing();
145962
+ SLIDE_MASTER_PART = /^ppt\/slideMasters\/slideMaster\d+\.xml$/;
145963
+ PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
145964
+ /**
145965
+ * Point the first slide master, or every one, at a theme part already in the package. Does
145966
+ * nothing when the package has no such part.
145967
+ */
145968
+ async setPresentationTheme(themePath, applyToAllMasters = true) {
145969
+ const path4 = themePartPath(themePath);
145970
+ if (!path4 || !this.zip.file(path4)) {
145971
+ return;
145972
+ }
145973
+ const masters = this.zip.file(SLIDE_MASTER_PART);
145974
+ for (const master of applyToAllMasters ? masters : masters.slice(0, 1)) {
145975
+ await this.retargetMasterTheme(master.name, path4);
145976
+ }
145977
+ }
145978
+ /**
145979
+ * Point one slide master at a theme part already in the package (Undo of a theme switch puts
145980
+ * each master back on its own part). Does nothing when the package has no such master or part.
145981
+ */
145982
+ async setSlideMasterTheme(masterPath, themePath) {
145983
+ const path4 = themePartPath(themePath);
145984
+ if (!path4 || !this.zip.file(path4) || !SLIDE_MASTER_PART.test(masterPath)) {
145985
+ return;
145986
+ }
145987
+ if (this.zip.file(masterPath)) {
145988
+ await this.retargetMasterTheme(masterPath, path4);
145989
+ }
145990
+ }
145991
+ async retargetMasterTheme(masterPath, themePath) {
145992
+ if (await this.setMasterThemeRelationship(masterPath, themePath)) {
145993
+ await this.adoptMasterTheme(masterPath, themePath);
145994
+ }
145995
+ }
145996
+ /** Point the runtime's theme state for `masterPath` at the part it now uses. */
145997
+ async adoptMasterTheme(masterPath, themePath) {
145998
+ const themeXml3 = await this.zip.file(themePath)?.async("string");
145999
+ if (themeXml3 === void 0) {
146000
+ return;
146001
+ }
146002
+ const model = this.parseThemePartXml(themeXml3);
146003
+ if (!this.originalThemeXmlByPath.has(themePath)) {
146004
+ this.cacheThemePartModel(themePath, themeXml3, model);
146005
+ }
146006
+ this.masterThemePaths.set(masterPath, themePath);
146007
+ this.masterThemeColorMaps.set(masterPath, { ...model.colorMap });
146008
+ this.masterThemeFontMaps.set(masterPath, { ...model.fontMap });
146009
+ if (model.formatScheme) {
146010
+ this.masterThemeFormatSchemes.set(masterPath, model.formatScheme);
146011
+ } else {
146012
+ this.masterThemeFormatSchemes.delete(masterPath);
146013
+ }
146014
+ if (this.zip.file(SLIDE_MASTER_PART)[0]?.name !== masterPath) {
146015
+ return;
146016
+ }
146017
+ this.themeColorMap = { ...model.colorMap };
146018
+ this.themeFontMap = { ...model.fontMap };
146019
+ this.themeFormatScheme = model.formatScheme;
146020
+ this.globalThemeColorMapSnapshot = { ...model.colorMap };
146021
+ this.globalThemeFontMapSnapshot = { ...model.fontMap };
146022
+ this.globalThemeFormatSchemeSnapshot = model.formatScheme;
146023
+ }
146024
+ };
146025
+ }
146026
+ });
146027
+
145780
146028
  // pptx/core/core/runtime/PptxHandlerRuntimeComments.ts
145781
- var PptxHandlerRuntime86;
146029
+ var PptxHandlerRuntime88;
145782
146030
  var init_PptxHandlerRuntimeComments = __esm({
145783
146031
  "pptx/core/core/runtime/PptxHandlerRuntimeComments.ts"() {
145784
146032
  init_legacy_comment_threading();
145785
146033
  init_modern_comment_xml();
145786
146034
  init_xml_access();
145787
- init_PptxHandlerRuntimeThemeProcessing();
145788
- PptxHandlerRuntime86 = class _PptxHandlerRuntime extends PptxHandlerRuntime85 {
146035
+ init_PptxHandlerRuntimeThemeSwitching();
146036
+ PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
145789
146037
  /**
145790
146038
  * Parse modern threaded comments (PowerPoint 2019+ / Office 365).
145791
146039
  * Modern comments use `p188:cmLst`/`p15:cmLst` roots within
@@ -146014,7 +146262,7 @@ var init_PptxHandlerRuntimeComments = __esm({
146014
146262
  });
146015
146263
 
146016
146264
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts
146017
- var PptxHandlerRuntime87;
146265
+ var PptxHandlerRuntime89;
146018
146266
  var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
146019
146267
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts"() {
146020
146268
  init_smartart_color_lists();
@@ -146022,7 +146270,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
146022
146270
  init_smart_art_text_helpers();
146023
146271
  init_PptxHandlerRuntimeComments();
146024
146272
  init_smartart_text_paragraphs();
146025
- PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
146273
+ PptxHandlerRuntime89 = class extends PptxHandlerRuntime88 {
146026
146274
  async readXmlPartByRelationshipId(slidePath, relationshipId2) {
146027
146275
  const normalizedRelationshipId = String(relationshipId2 || "").trim();
146028
146276
  if (normalizedRelationshipId.length === 0) {
@@ -146626,7 +146874,7 @@ var init_smartart_text_style_resolution = __esm({
146626
146874
  });
146627
146875
 
146628
146876
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts
146629
- var PptxHandlerRuntime88;
146877
+ var PptxHandlerRuntime90;
146630
146878
  var init_PptxHandlerRuntimeSmartArtParsing = __esm({
146631
146879
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts"() {
146632
146880
  init_diagram();
@@ -146640,7 +146888,7 @@ var init_PptxHandlerRuntimeSmartArtParsing = __esm({
146640
146888
  init_smartart_style_label_refs();
146641
146889
  init_smartart_text_paragraphs();
146642
146890
  init_smartart_text_style_resolution();
146643
- PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
146891
+ PptxHandlerRuntime90 = class _PptxHandlerRuntime extends PptxHandlerRuntime89 {
146644
146892
  reportIncompleteSmartArtRelationships(graphicFrame, relationshipIds, slidePath) {
146645
146893
  const missing = [
146646
146894
  ["dm", relationshipIds?.dataRelId],
@@ -147035,7 +147283,7 @@ var init_smartart_layout_category = __esm({
147035
147283
  });
147036
147284
 
147037
147285
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts
147038
- var PptxHandlerRuntime89;
147286
+ var PptxHandlerRuntime91;
147039
147287
  var init_PptxHandlerRuntimeSmartArt = __esm({
147040
147288
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts"() {
147041
147289
  init_utils();
@@ -147050,7 +147298,7 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
147050
147298
  init_smartart_text_paragraphs();
147051
147299
  init_smartart_text_style_resolution();
147052
147300
  init_smartart_xml_builders();
147053
- PptxHandlerRuntime89 = class _PptxHandlerRuntime extends PptxHandlerRuntime88 {
147301
+ PptxHandlerRuntime91 = class _PptxHandlerRuntime extends PptxHandlerRuntime90 {
147054
147302
  async getSmartArtDataForGraphicFrame(slidePath, graphicFrame) {
147055
147303
  const graphicData = this.xmlLookupService.getChildByLocalName(
147056
147304
  this.xmlLookupService.getChildByLocalName(graphicFrame, "graphic"),
@@ -147226,12 +147474,12 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
147226
147474
  });
147227
147475
 
147228
147476
  // pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts
147229
- var PptxHandlerRuntime90;
147477
+ var PptxHandlerRuntime92;
147230
147478
  var init_PptxHandlerRuntimeChartDetection = __esm({
147231
147479
  "pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts"() {
147232
147480
  init_chart_multi_level_category_parser();
147233
147481
  init_PptxHandlerRuntimeSmartArt();
147234
- PptxHandlerRuntime90 = class extends PptxHandlerRuntime89 {
147482
+ PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
147235
147483
  detectChartType(plotArea) {
147236
147484
  if (!plotArea) {
147237
147485
  return "unknown";
@@ -147442,14 +147690,14 @@ function parseNumberVal(node2) {
147442
147690
  const num4 = Number.parseFloat(String(raw2));
147443
147691
  return Number.isFinite(num4) ? num4 : void 0;
147444
147692
  }
147445
- var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime91;
147693
+ var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime93;
147446
147694
  var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
147447
147695
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsingHelpers.ts"() {
147448
147696
  init_chart_ext_lookup();
147449
147697
  init_chart_pivot_source2();
147450
147698
  init_PptxHandlerRuntimeChartDetection();
147451
147699
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI2 = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
147452
- PptxHandlerRuntime91 = class extends PptxHandlerRuntime90 {
147700
+ PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
147453
147701
  /**
147454
147702
  * Parse `c:plotVisOnly` from the chart root element.
147455
147703
  *
@@ -147709,14 +147957,14 @@ var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
147709
147957
  });
147710
147958
 
147711
147959
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts
147712
- var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime92;
147960
+ var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime94;
147713
147961
  var init_PptxHandlerRuntimeChartExternalData = __esm({
147714
147962
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts"() {
147715
147963
  init_chart_user_shapes_parser();
147716
147964
  init_chart_xlsx_parser();
147717
147965
  init_PptxHandlerRuntimeChartParsingHelpers();
147718
147966
  CHART_USER_SHAPES_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
147719
- PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
147967
+ PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
147720
147968
  /**
147721
147969
  * Parse `c:externalData` from the chart's `c:chartSpace` and resolve
147722
147970
  * the external relationship target from the chart part's .rels file.
@@ -147878,12 +148126,12 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
147878
148126
  });
147879
148127
 
147880
148128
  // pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts
147881
- var PptxHandlerRuntime93;
148129
+ var PptxHandlerRuntime95;
147882
148130
  var init_PptxHandlerRuntimeChartColorStyle = __esm({
147883
148131
  "pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts"() {
147884
148132
  init_chart_style_definition_parser();
147885
148133
  init_PptxHandlerRuntimeChartExternalData();
147886
- PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
148134
+ PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
147887
148135
  /**
147888
148136
  * Parse the Office 2013+ chart-style part (`ppt/charts/style#.xml`)
147889
148137
  * referenced from the chart's relationships, sibling to
@@ -148044,7 +148292,7 @@ var init_PptxHandlerRuntimeChartColorStyle = __esm({
148044
148292
  });
148045
148293
 
148046
148294
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts
148047
- var PptxHandlerRuntime94;
148295
+ var PptxHandlerRuntime96;
148048
148296
  var init_PptxHandlerRuntimeChartExParsing = __esm({
148049
148297
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts"() {
148050
148298
  init_chart_cx_parser();
@@ -148054,7 +148302,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
148054
148302
  init_chart_protection2();
148055
148303
  init_chart_space_flags();
148056
148304
  init_PptxHandlerRuntimeChartColorStyle();
148057
- PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
148305
+ PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
148058
148306
  /**
148059
148307
  * The facts of a chart part that live outside the plot (or in other parts): the external data
148060
148308
  * reference and the embedded workbook's rows, pivot source and formats, the colour-style and
@@ -148174,7 +148422,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
148174
148422
  });
148175
148423
 
148176
148424
  // pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts
148177
- var PptxHandlerRuntime95;
148425
+ var PptxHandlerRuntime97;
148178
148426
  var init_PptxHandlerRuntimeChartParsing = __esm({
148179
148427
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts"() {
148180
148428
  init_chart_element_format_read_xml();
@@ -148196,7 +148444,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
148196
148444
  init_chart_element_pictures();
148197
148445
  init_chart_embedded_fallback();
148198
148446
  init_PptxHandlerRuntimeChartExParsing();
148199
- PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
148447
+ PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
148200
148448
  /**
148201
148449
  * Parse chart data from a graphic frame element on a slide.
148202
148450
  *
@@ -148480,7 +148728,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
148480
148728
  });
148481
148729
 
148482
148730
  // pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts
148483
- var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime96;
148731
+ var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime98;
148484
148732
  var init_PptxHandlerRuntimePresentationStructure = __esm({
148485
148733
  "pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts"() {
148486
148734
  init_kinsoku_parser();
@@ -148489,7 +148737,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
148489
148737
  init_PptxHandlerRuntimeChartParsing();
148490
148738
  XSD_INT_MIN = -2147483648;
148491
148739
  XSD_INT_MAX = 2147483647;
148492
- PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
148740
+ PptxHandlerRuntime98 = class extends PptxHandlerRuntime97 {
148493
148741
  parseEditorAnimations(slideXml3) {
148494
148742
  return this.editorAnimationService.parseEditorAnimations(slideXml3);
148495
148743
  }
@@ -148692,7 +148940,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
148692
148940
  });
148693
148941
 
148694
148942
  // pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts
148695
- var PptxHandlerRuntime97;
148943
+ var PptxHandlerRuntime99;
148696
148944
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
148697
148945
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
148698
148946
  init_eot_parser();
@@ -148701,7 +148949,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
148701
148949
  init_strip_parent_dir_segments();
148702
148950
  init_xml_access();
148703
148951
  init_PptxHandlerRuntimePresentationStructure();
148704
- PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
148952
+ PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
148705
148953
  async getEmbeddedFonts(fontList) {
148706
148954
  if (!fontList || fontList.fonts.length === 0) {
148707
148955
  return [];
@@ -148903,7 +149151,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
148903
149151
  };
148904
149152
  }
148905
149153
  });
148906
- var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime98;
149154
+ var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime100;
148907
149155
  var init_PptxHandlerRuntimeLoadSession = __esm({
148908
149156
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadSession.ts"() {
148909
149157
  init_zip_limits();
@@ -148915,7 +149163,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
148915
149163
  init_bullet_picture_image_enrichment();
148916
149164
  init_PptxHandlerRuntimeEmbeddedFonts();
148917
149165
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
148918
- PptxHandlerRuntime98 = class _PptxHandlerRuntime extends PptxHandlerRuntime97 {
149166
+ PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
148919
149167
  isZipContainer(data) {
148920
149168
  const bytes = new Uint8Array(data);
148921
149169
  if (bytes.byteLength < 4) {
@@ -149283,7 +149531,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
149283
149531
  });
149284
149532
 
149285
149533
  // pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts
149286
- var PptxHandlerRuntime99;
149534
+ var PptxHandlerRuntime101;
149287
149535
  var init_PptxHandlerRuntimeLoadPipeline = __esm({
149288
149536
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts"() {
149289
149537
  init_fluent();
@@ -149299,7 +149547,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
149299
149547
  init_layout_switch_placeholder_prompts();
149300
149548
  init_PptxHandlerRuntimeLoadSession();
149301
149549
  init_slide_fingerprint();
149302
- PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
149550
+ PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
149303
149551
  async buildLoadData(presentationState, slidesWithWarnings, slideMasters) {
149304
149552
  const headerFooter = this.extractHeaderFooter();
149305
149553
  const presentationProperties = await this.parsePresentationProperties();
@@ -149799,12 +150047,12 @@ function refIndex2(node2) {
149799
150047
  const idx = Number.parseInt(String(node2["@_idx"] ?? ""), 10);
149800
150048
  return Number.isFinite(idx) ? idx : void 0;
149801
150049
  }
149802
- var PptxHandlerRuntime100;
150050
+ var PptxHandlerRuntime102;
149803
150051
  var init_PptxHandlerRuntimeStyleMatrixResolve = __esm({
149804
150052
  "pptx/core/core/runtime/PptxHandlerRuntimeStyleMatrixResolve.ts"() {
149805
150053
  init_authored_shape_style();
149806
150054
  init_PptxHandlerRuntimeLoadPipeline();
149807
- PptxHandlerRuntime100 = class extends PptxHandlerRuntime99 {
150055
+ PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
149808
150056
  /**
149809
150057
  * Resolve a `<p:style>` node (`a:lnRef`, `a:fillRef`, `a:effectRef`,
149810
150058
  * `a:fontRef`) against the current theme's format scheme, with the same
@@ -149869,14 +150117,17 @@ function withKeys(style, from, keys) {
149869
150117
  function refNode(idx, colorXml2) {
149870
150118
  return { "@_idx": String(idx), ...colorXml2 ?? {} };
149871
150119
  }
149872
- var PptxHandlerRuntime101;
150120
+ var PptxHandlerRuntime103;
149873
150121
  var init_PptxHandlerRuntimeThemeEffects = __esm({
149874
150122
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeEffects.ts"() {
149875
150123
  init_theme_effect_schemes();
149876
150124
  init_authored_shape_style();
150125
+ init_held_format_schemes();
149877
150126
  init_PptxHandlerRuntimeStyleMatrixResolve();
149878
- PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
150127
+ PptxHandlerRuntime103 = class extends PptxHandlerRuntime102 {
149879
150128
  effectSchemeCache = /* @__PURE__ */ new Map();
150129
+ /** Every `a:fmtScheme` written into a theme part or over one ({@link restoreThemeFormatScheme}). */
150130
+ heldFormatSchemes = new HeldFormatSchemes();
149880
150131
  /**
149881
150132
  * Resolve a `<p:style>` node as the base class does, against built-in effect scheme
149882
150133
  * `effectSchemeId` instead of the deck's own (the Effects gallery draws each tile this way).
@@ -149929,32 +150180,79 @@ var init_PptxHandlerRuntimeThemeEffects = __esm({
149929
150180
  */
149930
150181
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
149931
150182
  const parsed = this.parseEffectScheme({ fmtSchemeXml });
149932
- if (!parsed) {
149933
- return void 0;
150183
+ return parsed ? this.writeFormatScheme(() => parsed.node) : void 0;
150184
+ }
150185
+ /**
150186
+ * Put back a format scheme the deck held before (Undo and Redo of an Effects pick), as the parts
150187
+ * held it: each theme part a master references gets back what it held the last time the deck's
150188
+ * scheme was `scheme` over those same parts, so a part with a scheme of its own gets its own back
150189
+ * (with no such time, `scheme`'s own element goes into every one). With `themePaths`, `scheme`'s
150190
+ * own element goes into those parts only.
150191
+ *
150192
+ * @returns the deck's format scheme now, or `undefined` (nothing written) for a scheme no part
150193
+ * held while this handler wrote into it
150194
+ */
150195
+ async restoreThemeFormatScheme(scheme, themePaths) {
150196
+ const parts = themePaths ? void 0 : this.heldFormatSchemes.parts(scheme, await this.resolveThemeEditTargets());
150197
+ if (parts) {
150198
+ return this.writeFormatScheme((path4) => parts.get(path4));
149934
150199
  }
149935
- const written = await this.rewriteThemeParts(void 0, (data) => {
150200
+ const element = this.heldFormatSchemes.element(scheme);
150201
+ return element ? this.writeFormatScheme(() => element, themePaths) : void 0;
150202
+ }
150203
+ /**
150204
+ * Write `elementFor(part)` into every theme part a master references (or only `themePaths`),
150205
+ * skipping a part it gives none, holding what each part held and now holds, and refresh the
150206
+ * in-memory format schemes of the masters on those parts and, when the deck's part is among
150207
+ * them, the deck's.
150208
+ */
150209
+ async writeFormatScheme(elementFor, themePaths) {
150210
+ const deckBefore = this.getThemeFormatScheme();
150211
+ const replaced = /* @__PURE__ */ new Map();
150212
+ const schemes = /* @__PURE__ */ new Map();
150213
+ const written = await this.rewriteThemeParts(themePaths, (data, path4) => {
150214
+ const element = elementFor(path4);
149936
150215
  const elements3 = data["a:theme"]?.["a:themeElements"];
149937
- if (!elements3) {
150216
+ if (!element || !elements3) {
149938
150217
  return false;
149939
150218
  }
149940
- elements3["a:fmtScheme"] = structuredClone(parsed.node);
150219
+ const previous = elements3["a:fmtScheme"];
150220
+ if (previous) {
150221
+ this.heldFormatSchemes.hold(this.parseFormatScheme(previous), previous);
150222
+ replaced.set(path4, structuredClone(previous));
150223
+ }
150224
+ const scheme = this.parseFormatScheme(element);
150225
+ this.heldFormatSchemes.hold(scheme, element);
150226
+ elements3["a:fmtScheme"] = structuredClone(element);
150227
+ schemes.set(path4, scheme);
149941
150228
  return true;
149942
150229
  });
149943
150230
  if (written.length === 0) {
149944
150231
  return void 0;
149945
150232
  }
150233
+ if (deckBefore) {
150234
+ this.heldFormatSchemes.holdParts(deckBefore, replaced);
150235
+ }
149946
150236
  for (const path4 of written) {
149947
150237
  const xml = await this.zip.file(path4)?.async("string");
149948
150238
  if (xml !== void 0) {
149949
150239
  this.originalThemeXmlByPath.set(path4, xml);
149950
150240
  }
150241
+ for (const masterPath of this.mastersUsingThemes([path4])) {
150242
+ this.masterThemeFormatSchemes.set(masterPath, schemes.get(path4));
150243
+ }
149951
150244
  }
149952
- for (const masterPath of this.mastersUsingThemes(written)) {
149953
- this.masterThemeFormatSchemes.set(masterPath, parsed.scheme);
150245
+ const primary = await this.resolvePrimaryThemePath();
150246
+ const deck = primary === void 0 ? void 0 : schemes.get(primary);
150247
+ if (deck) {
150248
+ this.globalThemeFormatSchemeSnapshot = deck;
150249
+ this.themeFormatScheme = deck;
150250
+ this.heldFormatSchemes.holdParts(
150251
+ deck,
150252
+ new Map(written.map((path4) => [path4, elementFor(path4)]))
150253
+ );
149954
150254
  }
149955
- this.globalThemeFormatSchemeSnapshot = parsed.scheme;
149956
- this.themeFormatScheme = parsed.scheme;
149957
- return parsed.scheme;
150255
+ return this.getThemeFormatScheme();
149958
150256
  }
149959
150257
  /** The real theme variants the loaded package carries, or none. */
149960
150258
  getThemeVariants() {
@@ -150080,7 +150378,7 @@ function schemeFromColorMap(map2) {
150080
150378
  folHlink: pick2("folHlink")
150081
150379
  };
150082
150380
  }
150083
- var PptxHandlerRuntime102;
150381
+ var PptxHandlerRuntime104;
150084
150382
  var init_PptxHandlerRuntimeBackgroundStyles = __esm({
150085
150383
  "pptx/core/core/runtime/PptxHandlerRuntimeBackgroundStyles.ts"() {
150086
150384
  init_background_style();
@@ -150088,7 +150386,7 @@ var init_PptxHandlerRuntimeBackgroundStyles = __esm({
150088
150386
  init_theme_switching();
150089
150387
  init_master_save_helpers();
150090
150388
  init_PptxHandlerRuntimeThemeEffects();
150091
- PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
150389
+ PptxHandlerRuntime104 = class extends PptxHandlerRuntime103 {
150092
150390
  resolveBackgroundStyle(preset) {
150093
150391
  const xml = {
150094
150392
  "p:sld": { "p:cSld": { "p:bg": backgroundRefNode(preset.idx, preset.scheme) } }
@@ -150348,14 +150646,14 @@ var init_sdk_placeholder = __esm({
150348
150646
  });
150349
150647
 
150350
150648
  // pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts
150351
- var PptxHandlerRuntime103;
150649
+ var PptxHandlerRuntime105;
150352
150650
  var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
150353
150651
  "pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts"() {
150354
150652
  init_placeholder_remap();
150355
150653
  init_xml_access();
150356
150654
  init_PptxHandlerRuntimeBackgroundStyles();
150357
150655
  init_sdk_placeholder();
150358
- PptxHandlerRuntime103 = class _PptxHandlerRuntime extends PptxHandlerRuntime102 {
150656
+ PptxHandlerRuntime105 = class _PptxHandlerRuntime extends PptxHandlerRuntime104 {
150359
150657
  createPlaceholderElement(layoutPath, input2, type, options) {
150360
150658
  if (input2.type !== "text") throw new Error("Placeholder input must be text");
150361
150659
  const layout = this.layoutXmlMap.get(layoutPath);
@@ -150409,14 +150707,14 @@ var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
150409
150707
  };
150410
150708
  }
150411
150709
  });
150412
- var PptxHandlerRuntime104;
150710
+ var PptxHandlerRuntime106;
150413
150711
  var init_PptxHandlerRuntimeImplementation = __esm({
150414
150712
  "pptx/core/core/runtime/PptxHandlerRuntimeImplementation.ts"() {
150415
150713
  init_PptxElementXmlBuilder();
150416
150714
  init_builders();
150417
150715
  init_factories();
150418
150716
  init_PptxHandlerRuntimeSdkPlaceholders();
150419
- PptxHandlerRuntime104 = class _PptxHandlerRuntime extends PptxHandlerRuntime103 {
150717
+ PptxHandlerRuntime106 = class _PptxHandlerRuntime extends PptxHandlerRuntime105 {
150420
150718
  constructor(dependencyFactory = new PptxRuntimeDependencyFactory()) {
150421
150719
  super();
150422
150720
  this.dependencyFactory = dependencyFactory;
@@ -150556,11 +150854,11 @@ var init_PptxHandlerRuntimeImplementation = __esm({
150556
150854
  });
150557
150855
 
150558
150856
  // pptx/core/core/PptxHandlerRuntime.ts
150559
- var PptxHandlerRuntime105;
150857
+ var PptxHandlerRuntime107;
150560
150858
  var init_PptxHandlerRuntime = __esm({
150561
150859
  "pptx/core/core/PptxHandlerRuntime.ts"() {
150562
150860
  init_PptxHandlerRuntimeImplementation();
150563
- PptxHandlerRuntime105 = class extends PptxHandlerRuntime104 {
150861
+ PptxHandlerRuntime107 = class extends PptxHandlerRuntime106 {
150564
150862
  };
150565
150863
  }
150566
150864
  });
@@ -150570,7 +150868,7 @@ var createDefaultPptxHandlerRuntime;
150570
150868
  var init_PptxHandlerRuntimeFactory = __esm({
150571
150869
  "pptx/core/core/PptxHandlerRuntimeFactory.ts"() {
150572
150870
  init_PptxHandlerRuntime();
150573
- createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime105();
150871
+ createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime107();
150574
150872
  }
150575
150873
  });
150576
150874
 
@@ -153829,10 +154127,32 @@ var init_PptxHandlerCore = __esm({
153829
154127
  async setPresentationTheme(themePath, applyToAllMasters = true) {
153830
154128
  await this.runtime.setPresentationTheme(themePath, applyToAllMasters);
153831
154129
  }
154130
+ /**
154131
+ * Point one slide master at a theme part already in the package; scheme edits and saves follow
154132
+ * it. Does nothing when the package has no such master or part.
154133
+ *
154134
+ * @param masterPath - The master's part path (e.g. `ppt/slideMasters/slideMaster2.xml`).
154135
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme1.xml`).
154136
+ */
154137
+ async setSlideMasterTheme(masterPath, themePath) {
154138
+ await this.runtime.setSlideMasterTheme(masterPath, themePath);
154139
+ }
154140
+ /**
154141
+ * Read one theme part's colour, font and format schemes and its name without changing the
154142
+ * loaded theme, for example to show what switching to it would apply.
154143
+ *
154144
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme2.xml`).
154145
+ * @returns The part's schemes, or `undefined` when the package has no such part.
154146
+ */
154147
+ async getThemePartSchemes(themePath) {
154148
+ return this.runtime.getThemePartSchemes(themePath);
154149
+ }
153832
154150
  /**
153833
154151
  * Modify the theme’s colour scheme (accent colours, background, text, etc.).
153834
154152
  *
153835
154153
  * @param colorScheme - A {@link PptxThemeColorScheme} with hex colour values.
154154
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
154155
+ * master uses when omitted.
153836
154156
  *
153837
154157
  * @example
153838
154158
  * ```ts
@@ -153845,13 +154165,15 @@ var init_PptxHandlerCore = __esm({
153845
154165
  * // => void — colour scheme updated in the in-memory theme XML
153846
154166
  * ```
153847
154167
  */
153848
- async updateThemeColorScheme(colorScheme) {
153849
- await this.runtime.updateThemeColorScheme(colorScheme);
154168
+ async updateThemeColorScheme(colorScheme, themePaths) {
154169
+ await this.runtime.updateThemeColorScheme(colorScheme, themePaths);
153850
154170
  }
153851
154171
  /**
153852
154172
  * Update the theme’s font scheme (heading + body typefaces).
153853
154173
  *
153854
154174
  * @param fontScheme - A {@link PptxThemeFontScheme} with font family names.
154175
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
154176
+ * master uses when omitted.
153855
154177
  *
153856
154178
  * @example
153857
154179
  * ```ts
@@ -153862,16 +154184,18 @@ var init_PptxHandlerCore = __esm({
153862
154184
  * // => void — font scheme updated in the in-memory theme XML
153863
154185
  * ```
153864
154186
  */
153865
- async updateThemeFontScheme(fontScheme) {
153866
- await this.runtime.updateThemeFontScheme(fontScheme);
154187
+ async updateThemeFontScheme(fontScheme, themePaths) {
154188
+ await this.runtime.updateThemeFontScheme(fontScheme, themePaths);
153867
154189
  }
153868
154190
  /**
153869
154191
  * Rename the presentation theme.
153870
154192
  *
153871
154193
  * @param name - New display name for the theme.
154194
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
154195
+ * master uses when omitted.
153872
154196
  */
153873
- async updateThemeName(name) {
153874
- await this.runtime.updateThemeName(name);
154197
+ async updateThemeName(name, themePaths) {
154198
+ await this.runtime.updateThemeName(name, themePaths);
153875
154199
  }
153876
154200
  /**
153877
154201
  * Resolve a `<p:style>` block (`a:lnRef` / `a:fillRef` / `a:effectRef` /
@@ -153894,6 +154218,14 @@ var init_PptxHandlerCore = __esm({
153894
154218
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
153895
154219
  return this.runtime.applyThemeFormatSchemeXml(fmtSchemeXml);
153896
154220
  }
154221
+ /**
154222
+ * Put a format scheme a theme part held before back into the theme parts (or only `themePaths`),
154223
+ * as the part held it: Undo and Redo of an Effects pick. Only a scheme this handler wrote into a
154224
+ * part or over one can come back; for any other it writes nothing and returns `undefined`.
154225
+ */
154226
+ async restoreThemeFormatScheme(scheme, themePaths) {
154227
+ return this.runtime.restoreThemeFormatScheme(scheme, themePaths);
154228
+ }
153897
154229
  /** The real theme variants the loaded package carries (`themeVariants/` parts), or none. */
153898
154230
  getThemeVariants() {
153899
154231
  return this.runtime.getThemeVariants();