@officedk/pptxdk 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build-zrZuX4fK.d.ts +3 -0
  3. package/dist/build.d.ts +35 -0
  4. package/dist/build.js +128 -0
  5. package/dist/capabilities/dist/all.js +34 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +84 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +32 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +142 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2403 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1119 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +192 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +592 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +60 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +168 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +119 -0
  38. package/dist/capabilities/dist/font/font-engine.js +834 -0
  39. package/dist/capabilities/dist/font/font-import.js +766 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +72 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +74 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +41 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +649 -0
  46. package/dist/capabilities/dist/group/group-xml.js +8 -0
  47. package/dist/capabilities/dist/group/group.js +260 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +164 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +244 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +984 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +147 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +552 -0
  57. package/dist/capabilities/dist/line/line-codegen.js +89 -0
  58. package/dist/capabilities/dist/line/line-declaration.js +72 -0
  59. package/dist/capabilities/dist/line/line-elements.js +12 -0
  60. package/dist/capabilities/dist/line/line-import.js +504 -0
  61. package/dist/capabilities/dist/line/line-xml.js +9 -0
  62. package/dist/capabilities/dist/line/line.js +331 -0
  63. package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
  64. package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
  65. package/dist/capabilities/dist/masters/masters.js +250 -0
  66. package/dist/capabilities/dist/motion/motion-api.js +757 -0
  67. package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
  68. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  69. package/dist/capabilities/dist/motion/motion-import.js +1568 -0
  70. package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
  71. package/dist/capabilities/dist/motion/motion-query.js +423 -0
  72. package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
  73. package/dist/capabilities/dist/motion/motion.js +1617 -0
  74. package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
  75. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  76. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  77. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  78. package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
  79. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  80. package/dist/capabilities/dist/notes/notes.js +194 -0
  81. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
  82. package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
  83. package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
  84. package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
  85. package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
  86. package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
  87. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  88. package/dist/capabilities/dist/shape/shape-import.js +628 -0
  89. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  90. package/dist/capabilities/dist/shape/shape.js +320 -0
  91. package/dist/capabilities/dist/shared/geometry.js +1681 -0
  92. package/dist/capabilities/dist/shared/identity.js +205 -0
  93. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  94. package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
  95. package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
  96. package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
  97. package/dist/capabilities/dist/shared/text-schemas.js +241 -0
  98. package/dist/capabilities/dist/shared/text-service.js +2252 -0
  99. package/dist/capabilities/dist/shared/visual.js +1197 -0
  100. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  101. package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
  102. package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
  103. package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
  104. package/dist/capabilities/dist/table/table-codegen.js +125 -0
  105. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  106. package/dist/capabilities/dist/table/table-elements.js +27 -0
  107. package/dist/capabilities/dist/table/table-import.js +606 -0
  108. package/dist/capabilities/dist/table/table-schemas.js +334 -0
  109. package/dist/capabilities/dist/table/table-xml.js +30 -0
  110. package/dist/capabilities/dist/table/table.js +739 -0
  111. package/dist/capabilities/dist/text/text-codegen.js +198 -0
  112. package/dist/capabilities/dist/text/text-declaration.js +27 -0
  113. package/dist/capabilities/dist/text/text-elements.js +54 -0
  114. package/dist/capabilities/dist/text/text-import.js +1224 -0
  115. package/dist/capabilities/dist/text/text-xml.js +9 -0
  116. package/dist/capabilities/dist/text/text.js +320 -0
  117. package/dist/capabilities/dist/transition/transition-api.js +136 -0
  118. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  119. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  120. package/dist/capabilities/dist/transition/transition.js +260 -0
  121. package/dist/capability-BbKW9w4O.d.ts +2131 -0
  122. package/dist/cli.js +20 -0
  123. package/dist/codegen/dist/assets.js +79 -0
  124. package/dist/codegen/dist/codegen.js +691 -0
  125. package/dist/codegen/dist/identifiers.js +203 -0
  126. package/dist/codegen/dist/index.js +3 -0
  127. package/dist/codegen/dist/printer.js +143 -0
  128. package/dist/codegen/dist/types.js +77 -0
  129. package/dist/core/dist/author-ids.js +51 -0
  130. package/dist/core/dist/author-schemas.js +330 -0
  131. package/dist/core/dist/block-flex-layout.js +801 -0
  132. package/dist/core/dist/build.js +4 -0
  133. package/dist/core/dist/capability.js +15 -0
  134. package/dist/core/dist/declaration.js +16 -0
  135. package/dist/core/dist/diagnostics.js +353 -0
  136. package/dist/core/dist/document-internals.js +26 -0
  137. package/dist/core/dist/document.js +417 -0
  138. package/dist/core/dist/font-seal.js +204 -0
  139. package/dist/core/dist/geometry-schemas.js +256 -0
  140. package/dist/core/dist/grid-layout.js +449 -0
  141. package/dist/core/dist/host.js +40 -0
  142. package/dist/core/dist/index.js +15 -0
  143. package/dist/core/dist/input-values.js +61 -0
  144. package/dist/core/dist/layout-protocol.js +61 -0
  145. package/dist/core/dist/layout-schemas.js +201 -0
  146. package/dist/core/dist/layout.js +340 -0
  147. package/dist/core/dist/masters.js +194 -0
  148. package/dist/core/dist/morph.js +30 -0
  149. package/dist/core/dist/placeholders.js +275 -0
  150. package/dist/core/dist/query.js +190 -0
  151. package/dist/core/dist/resolution.js +12 -0
  152. package/dist/core/dist/resolve.js +2246 -0
  153. package/dist/core/dist/stage-options.js +300 -0
  154. package/dist/core/dist/theme.js +1023 -0
  155. package/dist/core/dist/transform-geometry.js +72 -0
  156. package/dist/document-41spD7bq.d.ts +1350 -0
  157. package/dist/emit/dist/emit.js +957 -0
  158. package/dist/emit/dist/index.js +5 -0
  159. package/dist/emit/dist/ooxml.js +661 -0
  160. package/dist/emit/dist/shape-tree.js +12 -0
  161. package/dist/import/dist/alternate-content.js +54 -0
  162. package/dist/import/dist/diagnostics.js +157 -0
  163. package/dist/import/dist/fonts.js +309 -0
  164. package/dist/import/dist/import.js +513 -0
  165. package/dist/import/dist/index.js +16 -0
  166. package/dist/import/dist/masters.js +1293 -0
  167. package/dist/import/dist/mechanism.js +10 -0
  168. package/dist/import/dist/namespaces.js +61 -0
  169. package/dist/import/dist/notes-masters.js +300 -0
  170. package/dist/import/dist/opc.js +233 -0
  171. package/dist/import/dist/resources.js +166 -0
  172. package/dist/import/dist/sections.js +139 -0
  173. package/dist/import/dist/themes.js +777 -0
  174. package/dist/import/dist/visual.js +821 -0
  175. package/dist/import/dist/xml-fragments.js +277 -0
  176. package/dist/import/dist/xml-reader.js +267 -0
  177. package/dist/index-1ag7U9Jt.d.ts +63 -0
  178. package/dist/index-BEwhk7c8.d.ts +72 -0
  179. package/dist/index-cK2KtukZ.d.ts +161 -0
  180. package/dist/index-v77CTJev.d.ts +55 -0
  181. package/dist/index.d.ts +8 -0
  182. package/dist/index.js +82 -0
  183. package/dist/node.d.ts +53 -0
  184. package/dist/node.js +225 -0
  185. package/dist/pptxdk/src/cli-commands.js +907 -0
  186. package/dist/pptxdk/src/compose.js +53 -0
  187. package/dist/pptxdk/src/slide.js +9 -0
  188. package/dist/preview/dist/index.js +342 -0
  189. package/dist/preview/dist/options.js +40 -0
  190. package/dist/preview/dist/svg-guard.js +1089 -0
  191. package/dist/preview.d.ts +12 -0
  192. package/dist/preview.js +29 -0
  193. package/dist/react/dist/append.js +66 -0
  194. package/dist/react/dist/document-adapter.js +404 -0
  195. package/dist/react/dist/elements.js +82 -0
  196. package/dist/react/dist/from-vanilla.js +57 -0
  197. package/dist/react/dist/index.js +89 -0
  198. package/dist/react/dist/mount.js +34 -0
  199. package/dist/react/dist/reconciler.js +290 -0
  200. package/dist/react.d.ts +235 -0
  201. package/dist/react.js +31 -0
  202. package/dist/transition-6n8GZxSg.d.ts +9 -0
  203. package/dist/vanilla.d.ts +4 -0
  204. package/dist/vanilla.js +15 -0
  205. package/package.json +79 -3
  206. package/README.md +0 -3
@@ -0,0 +1,766 @@
1
+ import { defaultTheme, defineTheme, isFont, isTheme } from "../../../core/dist/theme.js";
2
+ import { masterTextStyleCategoryForRole, matchMasterPlaceholderSpec } from "../../../core/dist/placeholders.js";
3
+ import "../../../core/dist/capability.js";
4
+ import { CommonNode } from "../../../core/dist/document.js";
5
+ import { P_NS } from "../../../import/dist/namespaces.js";
6
+ import { readEmbeddedFontList, readPresentationThemeFontScheme, unpackEotFontData } from "../../../import/dist/fonts.js";
7
+ import "../../../import/dist/index.js";
8
+ import { fontFamilyKey, inspectImportedEmbeddedFont } from "./font-engine.js";
9
+ import { font } from "./font.js";
10
+ // ../capabilities/dist/font/font-import.js
11
+ const reservedThemeFontPattern = /^(?:major|minor|\+(?:mj|mn)-)/iu;
12
+ function isPlainRecord(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function fallbackWeightForSlot(slot) {
16
+ return slot === "bold" || slot === "boldItalic" ? 700 : 400;
17
+ }
18
+ function fallbackStyleForSlot(slot) {
19
+ return slot === "italic" || slot === "boldItalic" ? "italic" : "normal";
20
+ }
21
+ function isBoldWeight(weight) {
22
+ if (weight === "bold") return true;
23
+ if (weight === "normal") return false;
24
+ if (typeof weight === "number") return weight >= 600;
25
+ }
26
+ function numericWeightOrUndefined(weight) {
27
+ if (weight === "normal") return 400;
28
+ if (weight === "bold") return 700;
29
+ if (typeof weight === "number") return weight;
30
+ }
31
+ function isItalicFontStyle(style) {
32
+ if (style === "italic") return true;
33
+ if (style === "normal") return false;
34
+ }
35
+ function slotForBoldItalic(bold, italic) {
36
+ if (bold) return italic ? "boldItalic" : "bold";
37
+ return italic ? "italic" : "regular";
38
+ }
39
+ function upgradeFontToken(family, fontsByKey) {
40
+ if (typeof family !== "string" || family === "major" || family === "minor") return;
41
+ return fontsByKey.get(fontFamilyKey(family));
42
+ }
43
+ function resolveEffectiveFamilyKey(fontFamily, themeFonts, script = "latin") {
44
+ if (isFont(fontFamily)) return fontFamilyKey(fontFamily.family);
45
+ if (typeof fontFamily !== "string" || fontFamily.trim() === "") return;
46
+ if (fontFamily === "major" || fontFamily === "minor") {
47
+ const mapped = script === "ea" ? themeFonts[fontFamily === "major" ? "majorEastAsian" : "minorEastAsian"] ?? themeFonts[fontFamily] : themeFonts[fontFamily];
48
+ if (isFont(mapped)) return fontFamilyKey(mapped.family);
49
+ if (typeof mapped === "string" && mapped.trim() !== "") return fontFamilyKey(mapped);
50
+ }
51
+ return fontFamilyKey(fontFamily);
52
+ }
53
+ function applyStyleContextOnly(inherited, style) {
54
+ if (!isPlainRecord(style)) return inherited;
55
+ const nextFontFamily = style["fontFamily"] !== void 0 ? style["fontFamily"] : inherited.fontFamily;
56
+ const nextEaFontFamily = style["eastAsianFontFamily"] !== void 0 ? style["eastAsianFontFamily"] : inherited.eastAsianFontFamily;
57
+ const nextBold = isBoldWeight(style["fontWeight"]) ?? inherited.bold;
58
+ const nextItalic = isItalicFontStyle(style["fontStyle"]) ?? inherited.italic;
59
+ const nextWeight = numericWeightOrUndefined(style["fontWeight"]) ?? inherited.effectiveWeight;
60
+ return {
61
+ themeFonts: inherited.themeFonts,
62
+ fontFamily: nextFontFamily,
63
+ eastAsianFontFamily: nextEaFontFamily,
64
+ bold: nextBold,
65
+ italic: nextItalic,
66
+ effectiveWeight: nextWeight
67
+ };
68
+ }
69
+ function foldStyleLayers(base, layers) {
70
+ let current = base;
71
+ for (const layer of layers) current = applyStyleContextOnly(current, layer);
72
+ return current;
73
+ }
74
+ function upgradeStyleRecordFontAndWeight(style, inherited, lookup, options) {
75
+ if (!isPlainRecord(style)) {
76
+ if (options?.backfillInheritedLeaf === true) {
77
+ const familyKey = resolveEffectiveFamilyKey(inherited.fontFamily, inherited.themeFonts);
78
+ const slot = slotForBoldItalic(inherited.bold, inherited.italic);
79
+ const slotWeight = familyKey === void 0 ? void 0 : lookup.slotWeightsByKey.get(familyKey)?.[slot];
80
+ if (slotWeight !== void 0 && slotWeight !== inherited.effectiveWeight) return {
81
+ changed: true,
82
+ value: { fontWeight: slotWeight },
83
+ nextContext: {
84
+ ...inherited,
85
+ effectiveWeight: slotWeight
86
+ }
87
+ };
88
+ }
89
+ return {
90
+ changed: false,
91
+ nextContext: inherited
92
+ };
93
+ }
94
+ const matched = upgradeFontToken(style["fontFamily"], lookup.fontsByKey);
95
+ const matchedEa = upgradeFontToken(style["eastAsianFontFamily"], lookup.fontsByKey);
96
+ const nextRec = {
97
+ ...style,
98
+ ...matched === void 0 ? {} : { fontFamily: matched },
99
+ ...matchedEa === void 0 ? {} : { eastAsianFontFamily: matchedEa }
100
+ };
101
+ let changed = matched !== void 0 || matchedEa !== void 0;
102
+ const hasLocalFontFamily = style["fontFamily"] !== void 0;
103
+ const hasLocalEaFontFamily = style["eastAsianFontFamily"] !== void 0;
104
+ const hasLocalFontWeight = style["fontWeight"] !== void 0;
105
+ const hasLocalFontStyle = style["fontStyle"] !== void 0;
106
+ const hasAnyLocalFontDecl = hasLocalFontFamily || hasLocalEaFontFamily || hasLocalFontWeight || hasLocalFontStyle;
107
+ const nextFontFamily = hasLocalFontFamily ? nextRec["fontFamily"] : inherited.fontFamily;
108
+ const nextEaFontFamily = hasLocalEaFontFamily ? nextRec["eastAsianFontFamily"] : inherited.eastAsianFontFamily;
109
+ const nextBold = isBoldWeight(style["fontWeight"]) ?? inherited.bold;
110
+ const nextItalic = isItalicFontStyle(style["fontStyle"]) ?? inherited.italic;
111
+ const currentEffectiveWeight = numericWeightOrUndefined(style["fontWeight"]) ?? inherited.effectiveWeight;
112
+ const familyKey = hasLocalEaFontFamily && !hasLocalFontFamily ? resolveEffectiveFamilyKey(nextEaFontFamily, inherited.themeFonts, "ea") ?? resolveEffectiveFamilyKey(nextFontFamily, inherited.themeFonts) : resolveEffectiveFamilyKey(nextFontFamily, inherited.themeFonts);
113
+ const slot = slotForBoldItalic(nextBold, nextItalic);
114
+ const slotWeights = familyKey === void 0 ? void 0 : lookup.slotWeightsByKey.get(familyKey);
115
+ let slotWeight = slotWeights?.[slot];
116
+ if (slotWeight === void 0 && nextBold && slotWeights !== void 0) {
117
+ const candidate = slotWeights[nextItalic ? "italic" : "regular"];
118
+ if (candidate !== void 0 && candidate >= 600) slotWeight = candidate;
119
+ }
120
+ let nextEffectiveWeight = currentEffectiveWeight;
121
+ if (slotWeight !== void 0 && slotWeight !== currentEffectiveWeight && (hasAnyLocalFontDecl || options?.backfillInheritedLeaf === true)) {
122
+ nextRec["fontWeight"] = slotWeight;
123
+ changed = true;
124
+ nextEffectiveWeight = slotWeight;
125
+ }
126
+ const nextContext = {
127
+ themeFonts: inherited.themeFonts,
128
+ fontFamily: nextFontFamily,
129
+ eastAsianFontFamily: nextEaFontFamily,
130
+ bold: nextBold,
131
+ italic: nextItalic,
132
+ effectiveWeight: nextEffectiveWeight
133
+ };
134
+ return changed ? {
135
+ changed: true,
136
+ value: nextRec,
137
+ nextContext
138
+ } : {
139
+ changed: false,
140
+ nextContext
141
+ };
142
+ }
143
+ function hasUnstyledTextLeaf(node) {
144
+ if (node.type === "span" || node.type === "sup" || node.type === "sub" || node.type === "slide-number") return true;
145
+ if (node.type === "text" || node.type === "cell" || node.type === "notes" || node.type === "paragraph") return node.children.length === 0 || node.children.some((child) => !(child instanceof CommonNode));
146
+ if (node.type === "shape") return node.children.some((child) => !(child instanceof CommonNode));
147
+ return false;
148
+ }
149
+ function upgradePlaceholderListStylesFont(listStyles, contextForLevel, lookup) {
150
+ if (listStyles === void 0) return {
151
+ value: void 0,
152
+ changed: false
153
+ };
154
+ let changed = false;
155
+ const next = {};
156
+ for (const [levelKey, levelStyle] of Object.entries(listStyles)) {
157
+ if (levelStyle === void 0) continue;
158
+ const levelNum = Number(levelKey);
159
+ const upgraded = upgradeStyleRecordFontAndWeight(levelStyle, contextForLevel(Number.isInteger(levelNum) && levelNum >= 1 ? levelNum : 1), lookup);
160
+ if (upgraded.changed && upgraded.value !== void 0) {
161
+ next[levelKey] = upgraded.value;
162
+ changed = true;
163
+ } else next[levelKey] = levelStyle;
164
+ }
165
+ return changed ? {
166
+ value: next,
167
+ changed: true
168
+ } : {
169
+ value: listStyles,
170
+ changed: false
171
+ };
172
+ }
173
+ function upgradePlaceholdersFont(placeholders, baseContext, masterTextStyles, masterPlaceholders, lookup) {
174
+ if (placeholders === void 0) return {
175
+ value: void 0,
176
+ changed: false
177
+ };
178
+ let changed = false;
179
+ const next = {};
180
+ for (const [key, spec] of Object.entries(placeholders)) {
181
+ const isFooterRole = spec.type === "dt" || spec.type === "ftr" || spec.type === "sldNum";
182
+ const category = masterTextStyleCategoryForRole(spec.type);
183
+ const masterTx = isFooterRole ? void 0 : masterTextStyles?.[category];
184
+ const masterPh = masterPlaceholders === void 0 ? void 0 : matchMasterPlaceholderSpec(masterPlaceholders, spec.type);
185
+ const styleInherited = foldStyleLayers(baseContext, [
186
+ masterTx?.[1],
187
+ masterPh?.style,
188
+ masterPh?.listStyles?.[1]
189
+ ]);
190
+ const styleUp = upgradeStyleRecordFontAndWeight(spec.style, styleInherited, lookup);
191
+ const effectiveSpecStyle = styleUp.changed ? styleUp.value : spec.style;
192
+ const listUp = upgradePlaceholderListStylesFont(spec.listStyles, (levelNum) => {
193
+ const key1to9 = Math.min(9, Math.max(1, levelNum));
194
+ return foldStyleLayers(baseContext, [
195
+ masterTx?.[key1to9],
196
+ masterPh?.style,
197
+ masterPh?.listStyles?.[key1to9],
198
+ effectiveSpecStyle
199
+ ]);
200
+ }, lookup);
201
+ if (styleUp.changed || listUp.changed) {
202
+ changed = true;
203
+ next[key] = {
204
+ ...spec,
205
+ ...styleUp.changed && styleUp.value !== void 0 ? { style: styleUp.value } : {},
206
+ ...listUp.changed && listUp.value !== void 0 ? { listStyles: listUp.value } : {}
207
+ };
208
+ } else next[key] = spec;
209
+ }
210
+ return changed ? {
211
+ value: next,
212
+ changed: true
213
+ } : {
214
+ value: placeholders,
215
+ changed: false
216
+ };
217
+ }
218
+ function upgradeFooterPlaceholdersRecord(rawFooterPlaceholders, baseContext, inheritedFooterPlaceholders, lookup) {
219
+ if (!isPlainRecord(rawFooterPlaceholders)) return { changed: false };
220
+ let changed = false;
221
+ const nextPlaceholders = { ...rawFooterPlaceholders };
222
+ for (const [slot, spec] of Object.entries(nextPlaceholders)) {
223
+ if (!isPlainRecord(spec)) continue;
224
+ const inheritedSpec = inheritedFooterPlaceholders?.[slot];
225
+ const inheritedContext = isPlainRecord(inheritedSpec) ? applyStyleContextOnly(baseContext, inheritedSpec["style"]) : baseContext;
226
+ const nextStyle = upgradeStyleRecordFontAndWeight(spec["style"], inheritedContext, lookup);
227
+ if (nextStyle.changed && nextStyle.value !== void 0) {
228
+ nextPlaceholders[slot] = {
229
+ ...spec,
230
+ style: nextStyle.value
231
+ };
232
+ changed = true;
233
+ }
234
+ }
235
+ return changed ? {
236
+ value: nextPlaceholders,
237
+ changed: true
238
+ } : {
239
+ value: rawFooterPlaceholders,
240
+ changed: false
241
+ };
242
+ }
243
+ function upgradeThemeFontMap(fonts, fontsByKey) {
244
+ if (fonts === void 0) return { changed: false };
245
+ const nextFonts = {};
246
+ let changed = false;
247
+ for (const slot of [
248
+ "major",
249
+ "minor",
250
+ "majorEastAsian",
251
+ "minorEastAsian"
252
+ ]) {
253
+ const token = fonts[slot];
254
+ if (token === void 0) continue;
255
+ if (typeof token === "string") {
256
+ const matched = fontsByKey.get(fontFamilyKey(token));
257
+ if (matched !== void 0) {
258
+ nextFonts[slot] = matched;
259
+ changed = true;
260
+ continue;
261
+ }
262
+ nextFonts[slot] = token;
263
+ } else if (isFont(token)) nextFonts[slot] = token;
264
+ }
265
+ return changed ? {
266
+ fonts: nextFonts,
267
+ changed: true
268
+ } : { changed: false };
269
+ }
270
+ function extractThemeFonts(themeValue) {
271
+ if (isTheme(themeValue)) return themeValue.fonts;
272
+ if (isPlainRecord(themeValue) && isPlainRecord(themeValue["fonts"])) return themeValue["fonts"];
273
+ return {};
274
+ }
275
+ function upgradeThemeOverrideOnNode(node, fontsByKey) {
276
+ const rawOverride = node.props["themeOverride"];
277
+ if (!isPlainRecord(rawOverride)) return void 0;
278
+ const rawFonts = isPlainRecord(rawOverride["fonts"]) ? rawOverride["fonts"] : void 0;
279
+ const upgraded = upgradeThemeFontMap(rawFonts, fontsByKey);
280
+ if (upgraded.changed && upgraded.fonts !== void 0) {
281
+ node.set({ themeOverride: {
282
+ ...rawOverride,
283
+ fonts: upgraded.fonts
284
+ } });
285
+ return upgraded.fonts;
286
+ }
287
+ return rawFonts;
288
+ }
289
+ function upgradeChartTextStyleContainer(container, inherited, lookup) {
290
+ if (!isPlainRecord(container)) return {
291
+ changed: false,
292
+ nextContext: inherited
293
+ };
294
+ const styleUp = upgradeStyleRecordFontAndWeight(container["style"], inherited, lookup);
295
+ if (!styleUp.changed || styleUp.value === void 0) return {
296
+ changed: false,
297
+ nextContext: styleUp.nextContext
298
+ };
299
+ return {
300
+ changed: true,
301
+ value: {
302
+ ...container,
303
+ style: styleUp.value
304
+ },
305
+ nextContext: styleUp.nextContext
306
+ };
307
+ }
308
+ function upgradeChartPropsFonts(node, chartContext, lookup) {
309
+ const patch = {};
310
+ const titleUp = upgradeChartTextStyleContainer(node.props["title"], chartContext, lookup);
311
+ if (titleUp.changed && titleUp.value !== void 0) patch["title"] = titleUp.value;
312
+ const rawAxes = node.props["axes"];
313
+ if (isPlainRecord(rawAxes)) {
314
+ let axesChanged = false;
315
+ const nextAxes = { ...rawAxes };
316
+ for (const [axisKey, rawAxis] of Object.entries(rawAxes)) {
317
+ if (!isPlainRecord(rawAxis)) continue;
318
+ const axisUp = upgradeChartTextStyleContainer(rawAxis, chartContext, lookup);
319
+ let nextAxis = axisUp.changed && axisUp.value !== void 0 ? { ...axisUp.value } : { ...rawAxis };
320
+ let axisModified = axisUp.changed;
321
+ const axisTitleUp = upgradeChartTextStyleContainer(nextAxis["title"], axisUp.nextContext, lookup);
322
+ if (axisTitleUp.changed && axisTitleUp.value !== void 0) {
323
+ nextAxis = {
324
+ ...nextAxis,
325
+ title: axisTitleUp.value
326
+ };
327
+ axisModified = true;
328
+ }
329
+ if (axisModified) {
330
+ nextAxes[axisKey] = nextAxis;
331
+ axesChanged = true;
332
+ }
333
+ }
334
+ if (axesChanged) patch["axes"] = nextAxes;
335
+ }
336
+ const rawGroups = node.props["groups"];
337
+ if (Array.isArray(rawGroups)) {
338
+ let groupsChanged = false;
339
+ const nextGroups = rawGroups.map((group) => {
340
+ if (!isPlainRecord(group)) return group;
341
+ const labelsUp = upgradeChartTextStyleContainer(group["dataLabels"], chartContext, lookup);
342
+ if (labelsUp.changed && labelsUp.value !== void 0) {
343
+ groupsChanged = true;
344
+ return {
345
+ ...group,
346
+ dataLabels: labelsUp.value
347
+ };
348
+ }
349
+ return group;
350
+ });
351
+ if (groupsChanged) patch["groups"] = nextGroups;
352
+ }
353
+ if (Object.keys(patch).length > 0) node.set(patch);
354
+ }
355
+ const footerSlotToRole = {
356
+ dateTime: "dt",
357
+ footer: "ftr",
358
+ slideNumber: "sldNum"
359
+ };
360
+ function resolveFooterInheritanceLayers(slideSlot, layout) {
361
+ const role = footerSlotToRole[slideSlot];
362
+ const masterFooterStyle = isPlainRecord(layout?.master?.footerPlaceholders?.[slideSlot]) ? layout.master.footerPlaceholders[slideSlot]["style"] : void 0;
363
+ const masterPh = layout?.master?.placeholders === void 0 ? void 0 : matchMasterPlaceholderSpec(layout.master.placeholders, role);
364
+ const layoutFooterStyle = isPlainRecord(layout?.footerPlaceholders?.[slideSlot]) ? layout.footerPlaceholders[slideSlot]["style"] : void 0;
365
+ const layoutPh = layout?.placeholders === void 0 ? void 0 : matchMasterPlaceholderSpec(layout.placeholders, role);
366
+ return [
367
+ masterPh?.style,
368
+ masterPh?.listStyles?.[1],
369
+ masterFooterStyle,
370
+ layoutPh?.style,
371
+ layoutPh?.listStyles?.[1],
372
+ layoutFooterStyle
373
+ ];
374
+ }
375
+ function buildMasterCascadeLookup(masterNode, deckThemeFonts) {
376
+ const masterFonts = extractThemeFonts(masterNode.props["theme"]);
377
+ return {
378
+ themeFonts: Object.keys(masterFonts).length > 0 ? {
379
+ ...deckThemeFonts,
380
+ ...masterFonts
381
+ } : deckThemeFonts,
382
+ textStyles: masterNode.props["textStyles"],
383
+ placeholders: masterNode.props["placeholders"],
384
+ footerPlaceholders: isPlainRecord(masterNode.props["footerPlaceholders"]) ? masterNode.props["footerPlaceholders"] : void 0
385
+ };
386
+ }
387
+ function resolveSlideLayoutLookup(slideNode, deckThemeFonts, masterLookups, layoutLookups) {
388
+ const layoutProp = slideNode.props["layout"];
389
+ if (layoutProp === void 0) return void 0;
390
+ if (layoutProp instanceof CommonNode) {
391
+ const cached = layoutLookups.get(layoutProp);
392
+ if (cached !== void 0) return cached;
393
+ const parentMaster = layoutProp.parent instanceof CommonNode && layoutProp.parent.type === "slide-master" ? layoutProp.parent : void 0;
394
+ const masterLookup = parentMaster === void 0 ? void 0 : masterLookups.get(parentMaster) ?? buildMasterCascadeLookup(parentMaster, deckThemeFonts);
395
+ const baseFonts = masterLookup?.themeFonts ?? deckThemeFonts;
396
+ const overrideFonts = extractThemeFonts(layoutProp.props["themeOverride"]);
397
+ return {
398
+ themeFonts: Object.keys(overrideFonts).length > 0 ? {
399
+ ...baseFonts,
400
+ ...overrideFonts
401
+ } : baseFonts,
402
+ ...masterLookup === void 0 ? {} : { master: masterLookup },
403
+ placeholders: layoutProp.props["placeholders"],
404
+ footerPlaceholders: isPlainRecord(layoutProp.props["footerPlaceholders"]) ? layoutProp.props["footerPlaceholders"] : void 0
405
+ };
406
+ }
407
+ if (isPlainRecord(layoutProp)) {
408
+ const overrideFonts = extractThemeFonts(layoutProp["themeOverride"]);
409
+ return {
410
+ themeFonts: Object.keys(overrideFonts).length > 0 ? {
411
+ ...deckThemeFonts,
412
+ ...overrideFonts
413
+ } : deckThemeFonts,
414
+ placeholders: layoutProp["placeholders"],
415
+ footerPlaceholders: isPlainRecord(layoutProp["footerPlaceholders"]) ? layoutProp["footerPlaceholders"] : void 0
416
+ };
417
+ }
418
+ }
419
+ function attachEmbeddedFontsToSubtree(node, inherited, lookup, masterLookups, layoutLookups, activeLayout, placeholderContext) {
420
+ const mutableNode = node;
421
+ let currentContext = inherited;
422
+ let nextLayout = activeLayout;
423
+ if (node.type === "slide-master") {
424
+ const masterThemeFonts = extractThemeFonts(node.props["theme"]);
425
+ currentContext = {
426
+ themeFonts: Object.keys(masterThemeFonts).length > 0 ? {
427
+ ...inherited.themeFonts,
428
+ ...masterThemeFonts
429
+ } : inherited.themeFonts,
430
+ fontFamily: "minor",
431
+ eastAsianFontFamily: "minor",
432
+ bold: false,
433
+ italic: false,
434
+ effectiveWeight: 400
435
+ };
436
+ const rawTextStyles = node.props["textStyles"];
437
+ if (rawTextStyles !== void 0) {
438
+ const levelContext = (_levelNum) => currentContext;
439
+ const titleUp = upgradePlaceholderListStylesFont(rawTextStyles.titleStyle, levelContext, lookup);
440
+ const bodyUp = upgradePlaceholderListStylesFont(rawTextStyles.bodyStyle, levelContext, lookup);
441
+ const otherUp = upgradePlaceholderListStylesFont(rawTextStyles.otherStyle, levelContext, lookup);
442
+ if (titleUp.changed || bodyUp.changed || otherUp.changed) mutableNode.set({ textStyles: {
443
+ ...titleUp.value === void 0 ? {} : { titleStyle: titleUp.value },
444
+ ...bodyUp.value === void 0 ? {} : { bodyStyle: bodyUp.value },
445
+ ...otherUp.value === void 0 ? {} : { otherStyle: otherUp.value }
446
+ } });
447
+ }
448
+ const updatedTextStyles = node.props["textStyles"];
449
+ const rawPlaceholders = node.props["placeholders"];
450
+ const upgradedPh = upgradePlaceholdersFont(rawPlaceholders, currentContext, updatedTextStyles, void 0, lookup);
451
+ if (upgradedPh.changed && upgradedPh.value !== void 0) mutableNode.set({ placeholders: upgradedPh.value });
452
+ const footerUp = upgradeFooterPlaceholdersRecord(node.props["footerPlaceholders"], currentContext, void 0, lookup);
453
+ if (footerUp.changed && footerUp.value !== void 0) mutableNode.set({ footerPlaceholders: footerUp.value });
454
+ masterLookups.set(node, buildMasterCascadeLookup(node, inherited.themeFonts));
455
+ } else if (node.type === "slide-layout") {
456
+ const parentMaster = node.parent instanceof CommonNode && node.parent.type === "slide-master" ? masterLookups.get(node.parent) : void 0;
457
+ const overrideFonts = upgradeThemeOverrideOnNode(mutableNode, lookup.fontsByKey);
458
+ const baseFonts = parentMaster?.themeFonts ?? inherited.themeFonts;
459
+ const effectiveThemeFonts = overrideFonts !== void 0 && Object.keys(overrideFonts).length > 0 ? {
460
+ ...baseFonts,
461
+ ...overrideFonts
462
+ } : baseFonts;
463
+ currentContext = {
464
+ themeFonts: effectiveThemeFonts,
465
+ fontFamily: "minor",
466
+ eastAsianFontFamily: "minor",
467
+ bold: false,
468
+ italic: false,
469
+ effectiveWeight: 400
470
+ };
471
+ const rawPlaceholders = node.props["placeholders"];
472
+ const upgradedPh = upgradePlaceholdersFont(rawPlaceholders, currentContext, parentMaster?.textStyles, parentMaster?.placeholders, lookup);
473
+ if (upgradedPh.changed && upgradedPh.value !== void 0) mutableNode.set({ placeholders: upgradedPh.value });
474
+ const footerUp = upgradeFooterPlaceholdersRecord(node.props["footerPlaceholders"], currentContext, parentMaster?.footerPlaceholders, lookup);
475
+ if (footerUp.changed && footerUp.value !== void 0) mutableNode.set({ footerPlaceholders: footerUp.value });
476
+ layoutLookups.set(node, {
477
+ themeFonts: effectiveThemeFonts,
478
+ ...parentMaster === void 0 ? {} : { master: parentMaster },
479
+ placeholders: node.props["placeholders"],
480
+ footerPlaceholders: isPlainRecord(node.props["footerPlaceholders"]) ? node.props["footerPlaceholders"] : void 0
481
+ });
482
+ } else if (node.type === "slide") {
483
+ nextLayout = resolveSlideLayoutLookup(node, inherited.themeFonts, masterLookups, layoutLookups);
484
+ const overrideFonts = upgradeThemeOverrideOnNode(mutableNode, lookup.fontsByKey);
485
+ const effectiveThemeFonts = {
486
+ ...nextLayout?.themeFonts ?? inherited.themeFonts,
487
+ ...overrideFonts
488
+ };
489
+ currentContext = {
490
+ ...inherited,
491
+ themeFonts: effectiveThemeFonts
492
+ };
493
+ }
494
+ let childPlaceholderContext = placeholderContext;
495
+ let nodeStyleInherited = currentContext;
496
+ if (node.type !== "deck" && node.type !== "slide-master" && node.type !== "slide-layout" && node.type !== "slide") {
497
+ if (placeholderContext !== void 0 && node.type === "paragraph" && isPlainRecord(node.props["style"])) {
498
+ const listProp = node.props["style"]["list"];
499
+ const levelIndex0 = isPlainRecord(listProp) && typeof listProp["level"] === "number" ? listProp["level"] : 0;
500
+ const key1to9 = Math.min(9, Math.max(1, levelIndex0 + 1));
501
+ nodeStyleInherited = foldStyleLayers({
502
+ themeFonts: currentContext.themeFonts,
503
+ fontFamily: "minor",
504
+ eastAsianFontFamily: "minor",
505
+ bold: false,
506
+ italic: false,
507
+ effectiveWeight: 400
508
+ }, [
509
+ placeholderContext.masterTx?.[key1to9],
510
+ placeholderContext.masterPh?.style,
511
+ placeholderContext.masterPh?.listStyles?.[key1to9],
512
+ placeholderContext.layoutPh?.style,
513
+ placeholderContext.layoutPh?.listStyles?.[key1to9],
514
+ placeholderContext.slideTextNodeStyle
515
+ ]);
516
+ } else if (node.props["placeholder"] !== void 0 || node.props["nativePlaceholder"] !== void 0) {
517
+ const placeholderKey = typeof node.props["placeholder"] === "string" ? node.props["placeholder"] : void 0;
518
+ const nativeRef = isPlainRecord(node.props["nativePlaceholder"]) ? node.props["nativePlaceholder"] : void 0;
519
+ const layoutPh = placeholderKey === void 0 ? void 0 : nextLayout?.placeholders?.[placeholderKey];
520
+ const role = layoutPh?.type ?? nativeRef?.type;
521
+ if (role !== void 0) {
522
+ const category = masterTextStyleCategoryForRole(role);
523
+ const masterTx = nextLayout?.master?.textStyles?.[category];
524
+ const masterPh = nextLayout?.master?.placeholders === void 0 ? void 0 : matchMasterPlaceholderSpec(nextLayout.master.placeholders, role);
525
+ nodeStyleInherited = foldStyleLayers({
526
+ themeFonts: currentContext.themeFonts,
527
+ fontFamily: "minor",
528
+ eastAsianFontFamily: "minor",
529
+ bold: false,
530
+ italic: false,
531
+ effectiveWeight: 400
532
+ }, [
533
+ masterTx?.[1],
534
+ masterPh?.style,
535
+ masterPh?.listStyles?.[1],
536
+ layoutPh?.style,
537
+ layoutPh?.listStyles?.[1]
538
+ ]);
539
+ childPlaceholderContext = {
540
+ layoutPh,
541
+ masterPh,
542
+ masterTx,
543
+ slideTextNodeStyle: node.props["style"]
544
+ };
545
+ }
546
+ }
547
+ }
548
+ const styleUp = upgradeStyleRecordFontAndWeight(node.props["style"], nodeStyleInherited, lookup, { backfillInheritedLeaf: hasUnstyledTextLeaf(node) });
549
+ if (styleUp.changed && styleUp.value !== void 0) {
550
+ const patch = {};
551
+ const prevStyle = isPlainRecord(node.props["style"]) ? node.props["style"] : void 0;
552
+ if (styleUp.value["fontFamily"] !== prevStyle?.["fontFamily"]) patch["fontFamily"] = styleUp.value["fontFamily"];
553
+ if (styleUp.value["eastAsianFontFamily"] !== prevStyle?.["eastAsianFontFamily"]) patch["eastAsianFontFamily"] = styleUp.value["eastAsianFontFamily"];
554
+ if (styleUp.value["fontWeight"] !== prevStyle?.["fontWeight"]) patch["fontWeight"] = styleUp.value["fontWeight"];
555
+ if (Object.keys(patch).length > 0) mutableNode.style(patch);
556
+ if (childPlaceholderContext !== void 0 && placeholderContext === void 0) childPlaceholderContext = {
557
+ ...childPlaceholderContext,
558
+ slideTextNodeStyle: node.props["style"]
559
+ };
560
+ }
561
+ if (node.type === "chart") upgradeChartPropsFonts(mutableNode, styleUp.nextContext, lookup);
562
+ if (node.type === "slide") for (const slideSlot of [
563
+ "dateTime",
564
+ "footer",
565
+ "slideNumber"
566
+ ]) {
567
+ const rawSlot = node.props[slideSlot];
568
+ if (!isPlainRecord(rawSlot)) continue;
569
+ const footerInherited = foldStyleLayers(currentContext, resolveFooterInheritanceLayers(slideSlot, nextLayout));
570
+ const nextStyle = upgradeStyleRecordFontAndWeight(rawSlot["style"], footerInherited, lookup);
571
+ if (nextStyle.changed && nextStyle.value !== void 0) mutableNode.set({ [slideSlot]: {
572
+ ...rawSlot,
573
+ style: nextStyle.value
574
+ } });
575
+ }
576
+ const childInherited = node.type === "deck" || node.type === "slide-master" || node.type === "slide-layout" || node.type === "slide" ? {
577
+ ...styleUp.nextContext,
578
+ themeFonts: currentContext.themeFonts
579
+ } : styleUp.nextContext;
580
+ for (const child of node.children) if (child instanceof CommonNode) attachEmbeddedFontsToSubtree(child, childInherited, lookup, masterLookups, layoutLookups, nextLayout, node.type === "slide-master" || node.type === "slide-layout" || node.type === "slide" ? void 0 : childPlaceholderContext);
581
+ }
582
+ /**
583
+ * Reads `<p:embeddedFontLst>` from `presentation.xml`, unpacks uncompressed EOT font parts
584
+ * into detached `Font` resources, attaches them to theme font slots and text nodes, and
585
+ * isolates compressed, obfuscated, or corrupt `.fntdata` gracefully.
586
+ */
587
+ function readEmbeddedFontsIntoDeck(context) {
588
+ const { presentationCursor, deckNode, package: pkg } = context;
589
+ const diagnostics = [];
590
+ const records = readEmbeddedFontList(presentationCursor, pkg.presentationRels, pkg, diagnostics);
591
+ const fontsByKey = /* @__PURE__ */ new Map();
592
+ const slotWeightsByKey = /* @__PURE__ */ new Map();
593
+ for (const record of records) {
594
+ const faces = [];
595
+ const slotWeights = {};
596
+ let requiresSubstitute = false;
597
+ for (const slot of record.slots) {
598
+ const unpacked = unpackEotFontData(slot.bytes);
599
+ if (unpacked.status === "unsupported") {
600
+ diagnostics.push({
601
+ code: "unsupported-mechanism",
602
+ category: "unsupported",
603
+ disposition: "omitted",
604
+ location: {
605
+ part: slot.partPath,
606
+ xpath: slot.xpath
607
+ },
608
+ namespaceUri: P_NS,
609
+ localName: slot.slot,
610
+ mechanismHint: unpacked.reason
611
+ });
612
+ continue;
613
+ }
614
+ if (unpacked.status === "corrupt") {
615
+ diagnostics.push({
616
+ code: "corrupt-part",
617
+ category: "corrupt-input",
618
+ disposition: "omitted",
619
+ location: {
620
+ part: slot.partPath,
621
+ xpath: slot.xpath
622
+ }
623
+ });
624
+ continue;
625
+ }
626
+ const inspected = inspectImportedEmbeddedFont(unpacked.ttfBytes, record.typeface);
627
+ if (inspected === void 0) {
628
+ diagnostics.push({
629
+ code: "corrupt-part",
630
+ category: "corrupt-input",
631
+ disposition: "omitted",
632
+ location: {
633
+ part: slot.partPath,
634
+ xpath: slot.xpath
635
+ }
636
+ });
637
+ continue;
638
+ }
639
+ if (!inspected.familyMatches) requiresSubstitute = true;
640
+ const weight = inspected.weight ?? fallbackWeightForSlot(slot.slot);
641
+ const style = inspected.style ?? fallbackStyleForSlot(slot.slot);
642
+ slotWeights[slot.slot] = weight;
643
+ faces.push({
644
+ weight,
645
+ style,
646
+ data: new Uint8Array(unpacked.ttfBytes)
647
+ });
648
+ }
649
+ if (faces.length > 0 && record.typeface.trim() !== "" && !reservedThemeFontPattern.test(record.typeface.trim())) {
650
+ const key = fontFamilyKey(record.typeface);
651
+ fontsByKey.set(key, font(record.typeface, faces, requiresSubstitute ? { substitute: true } : {}));
652
+ slotWeightsByKey.set(key, slotWeights);
653
+ }
654
+ }
655
+ const schemeDiagnostics = [...context.existingDiagnostics ?? []];
656
+ const previousDiagnosticsCount = schemeDiagnostics.length;
657
+ const scheme = readPresentationThemeFontScheme(pkg, schemeDiagnostics);
658
+ diagnostics.push(...schemeDiagnostics.slice(previousDiagnosticsCount));
659
+ const attachFontsToThemeInput = (existing) => {
660
+ if (existing === void 0) return { changed: false };
661
+ const existingFonts = existing.fonts ?? {};
662
+ const nextFonts = {};
663
+ let changed = false;
664
+ for (const slot of [
665
+ "major",
666
+ "minor",
667
+ "majorEastAsian",
668
+ "minorEastAsian"
669
+ ]) {
670
+ const token = existingFonts[slot];
671
+ if (token === void 0) continue;
672
+ if (typeof token === "string") {
673
+ const matched = fontsByKey.get(fontFamilyKey(token));
674
+ if (matched !== void 0) {
675
+ nextFonts[slot] = matched;
676
+ changed = true;
677
+ continue;
678
+ }
679
+ }
680
+ nextFonts[slot] = token;
681
+ }
682
+ if (!changed) return { changed: false };
683
+ return {
684
+ changed: true,
685
+ theme: defineTheme({
686
+ ...existing,
687
+ fonts: nextFonts
688
+ })
689
+ };
690
+ };
691
+ let masterFallbackTheme;
692
+ const mutatedThemes = /* @__PURE__ */ new Set();
693
+ for (const child of deckNode.children) if (child instanceof CommonNode && child.type === "slide-master") {
694
+ const masterTheme = child.props["theme"];
695
+ masterFallbackTheme ??= masterTheme;
696
+ if (isTheme(masterTheme) && masterTheme !== defaultTheme) {
697
+ if (!mutatedThemes.has(masterTheme)) {
698
+ mutatedThemes.add(masterTheme);
699
+ const updatedMasterTheme = attachFontsToThemeInput(masterTheme);
700
+ if (updatedMasterTheme.changed && updatedMasterTheme.theme !== void 0) masterTheme.set({ fonts: updatedMasterTheme.theme.fonts });
701
+ }
702
+ } else {
703
+ const updatedMasterTheme = attachFontsToThemeInput(masterTheme);
704
+ if (updatedMasterTheme.changed && updatedMasterTheme.theme !== void 0) child.set({ theme: updatedMasterTheme.theme });
705
+ }
706
+ }
707
+ const existingDeckTheme = deckNode.props["theme"];
708
+ const baseDeckTheme = existingDeckTheme ?? masterFallbackTheme;
709
+ if (scheme !== void 0) {
710
+ const resolvedMajor = scheme.majorTypeface === void 0 ? void 0 : fontsByKey.get(fontFamilyKey(scheme.majorTypeface)) ?? scheme.majorTypeface;
711
+ const resolvedMinor = scheme.minorTypeface === void 0 ? void 0 : fontsByKey.get(fontFamilyKey(scheme.minorTypeface)) ?? scheme.minorTypeface;
712
+ const hasDistinctMajorEa = scheme.majorEastAsianTypeface !== void 0 && scheme.majorEastAsianTypeface !== scheme.majorTypeface;
713
+ const hasDistinctMinorEa = scheme.minorEastAsianTypeface !== void 0 && scheme.minorEastAsianTypeface !== scheme.minorTypeface;
714
+ const resolvedMajorEa = !hasDistinctMajorEa ? void 0 : fontsByKey.get(fontFamilyKey(scheme.majorEastAsianTypeface)) ?? scheme.majorEastAsianTypeface;
715
+ const resolvedMinorEa = !hasDistinctMinorEa ? void 0 : fontsByKey.get(fontFamilyKey(scheme.minorEastAsianTypeface)) ?? scheme.minorEastAsianTypeface;
716
+ const hasCustomMajor = resolvedMajor !== void 0 && resolvedMajor !== defaultTheme.fonts.major;
717
+ const hasCustomMinor = resolvedMinor !== void 0 && resolvedMinor !== defaultTheme.fonts.minor;
718
+ if (hasCustomMajor || hasCustomMinor || resolvedMajorEa !== void 0 || resolvedMinorEa !== void 0) {
719
+ const upgradedBase = attachFontsToThemeInput(baseDeckTheme).theme ?? baseDeckTheme;
720
+ const themeName = scheme.themeName ?? upgradedBase?.name;
721
+ const nextFonts = {};
722
+ if (upgradedBase?.fonts !== void 0) for (const slot of [
723
+ "major",
724
+ "minor",
725
+ "majorEastAsian",
726
+ "minorEastAsian"
727
+ ]) {
728
+ const token = upgradedBase.fonts[slot];
729
+ if (token !== void 0) nextFonts[slot] = token;
730
+ }
731
+ if (resolvedMajor !== void 0) nextFonts["major"] = resolvedMajor;
732
+ if (resolvedMinor !== void 0) nextFonts["minor"] = resolvedMinor;
733
+ if (resolvedMajorEa !== void 0) nextFonts["majorEastAsian"] = resolvedMajorEa;
734
+ if (resolvedMinorEa !== void 0) nextFonts["minorEastAsian"] = resolvedMinorEa;
735
+ deckNode.set({ theme: defineTheme({
736
+ ...upgradedBase,
737
+ ...themeName === void 0 ? {} : { name: themeName },
738
+ fonts: nextFonts
739
+ }) });
740
+ } else if (existingDeckTheme !== void 0) {
741
+ const updated = attachFontsToThemeInput(existingDeckTheme);
742
+ if (updated.changed && updated.theme !== void 0) deckNode.set({ theme: updated.theme });
743
+ }
744
+ } else if (existingDeckTheme !== void 0) {
745
+ const updated = attachFontsToThemeInput(existingDeckTheme);
746
+ if (updated.changed && updated.theme !== void 0) deckNode.set({ theme: updated.theme });
747
+ }
748
+ if (fontsByKey.size > 0) attachEmbeddedFontsToSubtree(deckNode, {
749
+ themeFonts: extractThemeFonts(deckNode.props["theme"]),
750
+ fontFamily: "minor",
751
+ eastAsianFontFamily: "minor",
752
+ bold: false,
753
+ italic: false,
754
+ effectiveWeight: 400
755
+ }, {
756
+ fontsByKey,
757
+ slotWeightsByKey
758
+ }, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), void 0);
759
+ return { diagnostics };
760
+ }
761
+ /** Deck-level import handler wired into `embeddedFontMechanism`. */
762
+ const embeddedFontImportHandler = {
763
+ target: "deck",
764
+ read: readEmbeddedFontsIntoDeck
765
+ };
766
+ export { embeddedFontImportHandler, readEmbeddedFontsIntoDeck };