@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,683 @@
1
+ import { schemeColorNameSchema, textStyleFrom } from "../../../core/dist/theme.js";
2
+ import { resolvePlaceholderBoxFromLayers } from "../../../core/dist/placeholders.js";
3
+ import { slideFooterValueSchema, slideNumberValueSchema } from "../../../core/dist/author-schemas.js";
4
+ import { footerPlaceholdersSchema } from "../../../core/dist/masters.js";
5
+ import "../../../core/dist/index.js";
6
+ import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
7
+ import "../../../core/dist/capability.js";
8
+ import { A_NS, P_NS, XML_NS, emuToPx } from "../../../import/dist/namespaces.js";
9
+ import "../../../emit/dist/index.js";
10
+ import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, readOoxmlBoxInsets, readOoxmlRunAttrStyles } from "../../../import/dist/xml-fragments.js";
11
+ import { readRunFontSlots } from "../../../import/dist/fonts.js";
12
+ import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
13
+ import "../../../import/dist/index.js";
14
+ import { emitTextBody, parseTextContent, renderTextOutlinesSvg, resolveTextBody } from "../shared/text-service.js";
15
+ import { footerPlaceholderCodegen } from "./masters-codegen.js";
16
+ import { z } from "zod";
17
+ // ../capabilities/dist/masters/footer-placeholder.js
18
+ const slotToOoxmlType = {
19
+ dateTime: "dt",
20
+ footer: "ftr",
21
+ slideNumber: "sldNum"
22
+ };
23
+ const ooxmlTypeToSlot = {
24
+ dt: "dateTime",
25
+ ftr: "footer",
26
+ sldNum: "slideNumber"
27
+ };
28
+ const slotDefaultMeta = {
29
+ dateTime: {
30
+ idx: 2,
31
+ size: "half",
32
+ namePrefix: "Date Placeholder"
33
+ },
34
+ footer: {
35
+ idx: 3,
36
+ size: "quarter",
37
+ namePrefix: "Footer Placeholder"
38
+ },
39
+ slideNumber: {
40
+ idx: 4,
41
+ size: "quarter",
42
+ namePrefix: "Slide Number Placeholder"
43
+ }
44
+ };
45
+ const slotOrder = [
46
+ "dateTime",
47
+ "footer",
48
+ "slideNumber"
49
+ ];
50
+ function defaultSlotBox(slot, dimensions) {
51
+ const y = Math.round(dimensions.height * .88);
52
+ const height = Math.max(18, Math.round(dimensions.height * .06));
53
+ switch (slot) {
54
+ case "dateTime": return {
55
+ x: Math.round(dimensions.width * .05),
56
+ y,
57
+ width: Math.round(dimensions.width * .25),
58
+ height
59
+ };
60
+ case "footer": return {
61
+ x: Math.round(dimensions.width * .32),
62
+ y,
63
+ width: Math.round(dimensions.width * .36),
64
+ height
65
+ };
66
+ case "slideNumber": return {
67
+ x: Math.round(dimensions.width * .72),
68
+ y,
69
+ width: Math.round(dimensions.width * .23),
70
+ height
71
+ };
72
+ }
73
+ }
74
+ function hasExplicitGeometry(spec) {
75
+ if (spec === void 0) return false;
76
+ const style = spec.style;
77
+ if (style === void 0) return false;
78
+ return style["left"] !== void 0 || style["top"] !== void 0 || style["right"] !== void 0 || style["bottom"] !== void 0 || style["inset"] !== void 0 || style["width"] !== void 0 || style["height"] !== void 0;
79
+ }
80
+ function mergeFooterStyle(...styles) {
81
+ const merged = {};
82
+ for (const style of styles) {
83
+ if (style === void 0) continue;
84
+ for (const [key, value] of Object.entries(style)) if (value !== void 0) merged[key] = value;
85
+ }
86
+ return Object.keys(merged).length === 0 ? void 0 : merged;
87
+ }
88
+ function resolveBoxFromSpecs(slot, dimensions, ...specs) {
89
+ const fallback = defaultSlotBox(slot, dimensions);
90
+ const resolved = resolvePlaceholderBoxFromLayers(specs, dimensions);
91
+ return {
92
+ x: typeof resolved.x === "number" ? resolved.x : fallback.x,
93
+ y: typeof resolved.y === "number" ? resolved.y : fallback.y,
94
+ width: typeof resolved.width === "number" ? resolved.width : fallback.width,
95
+ height: typeof resolved.height === "number" ? resolved.height : fallback.height
96
+ };
97
+ }
98
+ function buildFooterTextBody(args) {
99
+ const { slot, content, style, box, theme, slideNumber } = args;
100
+ const parsed = parseTextContent(slot === "slideNumber" ? [{
101
+ type: "slide-number",
102
+ props: {},
103
+ children: []
104
+ }] : content === void 0 || content === "" ? [] : [{
105
+ type: "#text",
106
+ text: content
107
+ }], style === void 0 ? void 0 : textStyleFrom(style, theme), theme, { slideNumber }, `footerPlaceholders.${slot}.style`);
108
+ return resolveTextBody(parsed.paragraphs, parsed.style, theme, parsed.style.verticalAlign ?? "middle", {
109
+ width: box.width,
110
+ height: box.height,
111
+ insets: {
112
+ top: 0,
113
+ right: 0,
114
+ bottom: 0,
115
+ left: 0
116
+ }
117
+ }, "text-box");
118
+ }
119
+ function emitFooterPlaceholderItemXml(item, shapeId, emitContext) {
120
+ const spPrXml = item.emitGeometry ? `<p:spPr><a:xfrm><a:off x="${pxToEmu(item.box.x)}" y="${pxToEmu(item.box.y)}"/><a:ext cx="${pxToEmu(item.box.width)}" cy="${pxToEmu(item.box.height)}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr>` : "<p:spPr/>";
121
+ const embedFonts = emitContext.options.embedFonts;
122
+ const emittedBody = emitTextBody(item.text, emitContext.theme, {
123
+ createFieldId: emitContext.createTextFieldId,
124
+ ...embedFonts === void 0 ? {} : { embedFonts }
125
+ });
126
+ return {
127
+ xml: `<p:sp><p:nvSpPr><p:cNvPr id="${shapeId}" name="${xmlEscape(item.name)}"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="${item.phType}" sz="${item.size}" idx="${item.idx}"/></p:nvPr></p:nvSpPr>${spPrXml}${emittedBody.xml}</p:sp>`,
128
+ presentationContributions: emittedBody.presentationContributions
129
+ };
130
+ }
131
+ function emitFooterPlaceholderModel(model, emitContext) {
132
+ if (model.items.length === 0) return { xml: "" };
133
+ let fallbackShapeId = 2;
134
+ const nextId = () => emitContext.allocateObjectId?.() ?? fallbackShapeId++;
135
+ let xml = "";
136
+ const contributions = [];
137
+ for (const item of model.items) {
138
+ const out = emitFooterPlaceholderItemXml(item, nextId(), emitContext);
139
+ xml += out.xml;
140
+ contributions.push(...out.presentationContributions);
141
+ }
142
+ return {
143
+ xml,
144
+ ...contributions.length === 0 ? {} : { presentationContributions: contributions }
145
+ };
146
+ }
147
+ function paintFooterPlaceholderModel(model, paintContext) {
148
+ if (model.items.length === 0) return { svg: "" };
149
+ const svgParts = [];
150
+ for (const item of model.items) {
151
+ if (item.text.text === "") continue;
152
+ const glyphs = renderTextOutlinesSvg({
153
+ paragraphs: item.text.paragraphs,
154
+ box: item.box,
155
+ insets: {
156
+ top: 0,
157
+ right: 0,
158
+ bottom: 0,
159
+ left: 0
160
+ },
161
+ verticalAlign: item.text.verticalAlign,
162
+ theme: paintContext.theme,
163
+ measuredLayout: item.text.measuredLayout,
164
+ idPrefix: `ftr-s${paintContext.slideNumber}-${item.slot}`
165
+ });
166
+ if (glyphs !== "") svgParts.push(glyphs);
167
+ }
168
+ return { svg: svgParts.join("") };
169
+ }
170
+ function normalizeSlideSlotOverride(slot, value) {
171
+ if (value === void 0) return { explicit: false };
172
+ if (typeof value === "boolean") return {
173
+ explicit: true,
174
+ visible: value
175
+ };
176
+ if (typeof value === "string") return {
177
+ explicit: true,
178
+ visible: true,
179
+ text: value
180
+ };
181
+ return {
182
+ explicit: true,
183
+ visible: value.visible ?? true,
184
+ ...typeof value === "object" && "text" in value && value.text !== void 0 ? { text: value.text } : {},
185
+ ...value.style === void 0 ? {} : { style: value.style },
186
+ ...value.idx === void 0 ? {} : { idx: value.idx },
187
+ ...value.size === void 0 ? {} : { size: value.size }
188
+ };
189
+ }
190
+ function isHeaderFooterEnabled(slot, masterHf, layoutHf) {
191
+ const layoutFlag = layoutHf?.[slot];
192
+ if (layoutFlag !== void 0) return layoutFlag;
193
+ const masterFlag = masterHf?.[slot];
194
+ if (masterFlag !== void 0) return masterFlag;
195
+ return true;
196
+ }
197
+ function resolveSlideFooterModel(args) {
198
+ const { slideProps, inheritance, dimensions, theme, slideNumber } = args;
199
+ const masterPlaceholders = inheritance?.master?.footerPlaceholders;
200
+ const layoutPlaceholders = inheritance?.layout?.footerPlaceholders;
201
+ const masterHf = inheritance?.master?.headerFooter;
202
+ const layoutHf = inheritance?.layout?.headerFooter;
203
+ const parsedDateTime = slideProps["dateTime"] === void 0 ? void 0 : slideFooterValueSchema.parse(slideProps["dateTime"]);
204
+ const parsedFooter = slideProps["footer"] === void 0 ? void 0 : slideFooterValueSchema.parse(slideProps["footer"]);
205
+ const parsedSlideNumber = slideProps["slideNumber"] === void 0 ? void 0 : slideNumberValueSchema.parse(slideProps["slideNumber"]);
206
+ const items = [];
207
+ for (const slot of slotOrder) {
208
+ const slideOverride = normalizeSlideSlotOverride(slot, slot === "dateTime" ? parsedDateTime : slot === "footer" ? parsedFooter : parsedSlideNumber);
209
+ const masterSpec = masterPlaceholders?.[slot];
210
+ const layoutSpec = layoutPlaceholders?.[slot];
211
+ const hfEnabled = isHeaderFooterEnabled(slot, masterHf, layoutHf);
212
+ let active = false;
213
+ if (slideOverride.explicit) active = slideOverride.visible && hfEnabled;
214
+ else if (hfEnabled) {
215
+ if (layoutSpec?.visible !== void 0) active = layoutSpec.visible;
216
+ else if (layoutSpec !== void 0) active = masterSpec?.visible ?? true;
217
+ else if (masterSpec !== void 0) active = masterSpec.visible ?? true;
218
+ }
219
+ if (!active) continue;
220
+ const defaults = slotDefaultMeta[slot];
221
+ const slideStyleSpec = slideOverride.explicit && slideOverride.style !== void 0 ? { style: slideOverride.style } : void 0;
222
+ const box = resolveBoxFromSpecs(slot, dimensions, masterSpec, layoutSpec, slideStyleSpec);
223
+ const style = mergeFooterStyle(masterSpec?.style, layoutSpec?.style, slideOverride.explicit ? slideOverride.style : void 0);
224
+ const content = slot === "slideNumber" ? void 0 : (slideOverride.explicit && slideOverride.text !== void 0 ? slideOverride.text : layoutSpec?.text ?? masterSpec?.text) ?? "";
225
+ const idx = (slideOverride.explicit ? slideOverride.idx : void 0) ?? layoutSpec?.idx ?? masterSpec?.idx ?? defaults.idx;
226
+ const size = (slideOverride.explicit ? slideOverride.size : void 0) ?? layoutSpec?.size ?? masterSpec?.size ?? defaults.size;
227
+ const text = buildFooterTextBody({
228
+ slot,
229
+ content,
230
+ style,
231
+ box,
232
+ theme,
233
+ slideNumber
234
+ });
235
+ items.push({
236
+ slot,
237
+ phType: slotToOoxmlType[slot],
238
+ idx,
239
+ size,
240
+ box,
241
+ emitGeometry: !hasExplicitGeometry(layoutSpec) || slideStyleSpec !== void 0,
242
+ name: `${defaults.namePrefix} ${idx}`,
243
+ text
244
+ });
245
+ }
246
+ return { items };
247
+ }
248
+ function resolveContainerFooterModel(args) {
249
+ const { targetType, footerPlaceholders, dimensions, theme } = args;
250
+ const items = [];
251
+ for (const slot of slotOrder) {
252
+ const spec = footerPlaceholders[slot];
253
+ if (spec === void 0) continue;
254
+ const defaults = slotDefaultMeta[slot];
255
+ const box = resolveBoxFromSpecs(slot, dimensions, spec);
256
+ const idx = spec.idx ?? defaults.idx;
257
+ const size = spec.size ?? defaults.size;
258
+ const text = buildFooterTextBody({
259
+ slot,
260
+ content: spec.text,
261
+ style: spec.style,
262
+ box,
263
+ theme,
264
+ slideNumber: 1
265
+ });
266
+ items.push({
267
+ slot,
268
+ phType: slotToOoxmlType[slot],
269
+ idx,
270
+ size,
271
+ box,
272
+ emitGeometry: targetType === "slide-master" || hasExplicitGeometry(spec),
273
+ name: `${defaults.namePrefix} ${idx}`,
274
+ text
275
+ });
276
+ }
277
+ return { items };
278
+ }
279
+ const PlaceholderAttrSchema = z.object({
280
+ type: z.enum([
281
+ "dt",
282
+ "ftr",
283
+ "sldNum"
284
+ ]),
285
+ sz: z.enum([
286
+ "full",
287
+ "half",
288
+ "quarter"
289
+ ]).optional(),
290
+ idx: ooxmlNonNegativeIntSchema.optional()
291
+ });
292
+ const NonVisualIdAttrSchema = z.object({
293
+ id: ooxmlNonNegativeIntSchema,
294
+ name: z.string().optional()
295
+ });
296
+ const SpLocksAttrSchema = z.object({ noGrp: ooxmlBoolSchema.optional() });
297
+ const PrstGeomAttrSchema = z.object({ prst: z.string().min(1) });
298
+ const BodyPrAttrSchema = z.object({
299
+ vert: z.string().optional(),
300
+ wrap: z.enum(["square", "none"]).optional(),
301
+ rtlCol: ooxmlBoolSchema.optional(),
302
+ anchor: z.enum([
303
+ "t",
304
+ "ctr",
305
+ "b"
306
+ ]).optional()
307
+ });
308
+ const LvlPPrAttrSchema = z.object({ algn: z.enum([
309
+ "l",
310
+ "ctr",
311
+ "r",
312
+ "just"
313
+ ]).optional() });
314
+ const FieldAttrSchema = z.object({
315
+ id: z.string().min(1),
316
+ type: z.string().min(1)
317
+ });
318
+ const percentValAttrSchema = z.object({ val: ooxmlNonNegativeIntSchema });
319
+ const SrgbAttrSchema = z.object({ val: hexRgb6Schema });
320
+ const SchemeClrAttrSchema = z.object({ val: schemeColorNameSchema });
321
+ const algnMap = {
322
+ l: "left",
323
+ ctr: "center",
324
+ r: "right",
325
+ just: "justify"
326
+ };
327
+ const anchorMap = {
328
+ t: "top",
329
+ ctr: "middle",
330
+ b: "bottom"
331
+ };
332
+ function directDomChild(parent, namespaceUri, localName) {
333
+ for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
334
+ if (child.nodeType !== 1) continue;
335
+ const el = child;
336
+ if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
337
+ }
338
+ }
339
+ function readFooterPlaceholderOoxmlType(cursor) {
340
+ const nvSpPr = directDomChild(cursor.element, P_NS, "nvSpPr");
341
+ if (nvSpPr === void 0) return void 0;
342
+ const nvPr = directDomChild(nvSpPr, P_NS, "nvPr");
343
+ if (nvPr === void 0) return void 0;
344
+ const ph = directDomChild(nvPr, P_NS, "ph");
345
+ if (ph === void 0) return void 0;
346
+ const rawType = ph.getAttribute("type");
347
+ if (rawType === "dt" || rawType === "ftr" || rawType === "sldNum") return rawType;
348
+ }
349
+ function readFooterXmlColor(fillCursor, location, diagnostics) {
350
+ const srgb = fillCursor.child(A_NS, "srgbClr");
351
+ const scheme = srgb === void 0 ? fillCursor.child(A_NS, "schemeClr") : void 0;
352
+ const colorCursor = srgb ?? scheme;
353
+ if (colorCursor === void 0) return void 0;
354
+ let slot;
355
+ let hex;
356
+ if (srgb !== void 0) {
357
+ const parsed = SrgbAttrSchema.safeParse(srgb.attrsObject(["val"]));
358
+ if (!parsed.success) return void 0;
359
+ hex = `#${parsed.data.val.toUpperCase()}`;
360
+ } else if (scheme !== void 0) {
361
+ const parsed = SchemeClrAttrSchema.safeParse(scheme.attrsObject(["val"]));
362
+ if (!parsed.success) return void 0;
363
+ slot = parsed.data.val;
364
+ }
365
+ let lumMod;
366
+ let lumOff;
367
+ let alpha;
368
+ for (const mod of colorCursor.remainingElementChildren()) {
369
+ if (mod.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
370
+ const parsed = percentValAttrSchema.safeParse(mod.attrsObject(["val"]));
371
+ if (!parsed.success) continue;
372
+ const fraction = Math.min(1, Math.max(0, parsed.data.val / 1e5));
373
+ if (mod.localName === "tint") {
374
+ lumMod = fraction;
375
+ lumOff = 1 - fraction;
376
+ } else if (mod.localName === "lumMod") lumMod = fraction;
377
+ else if (mod.localName === "lumOff") lumOff = fraction;
378
+ else if (mod.localName === "alpha") alpha = fraction;
379
+ else diagnostics.push({
380
+ code: "unsupported-mechanism",
381
+ category: "unsupported",
382
+ disposition: "omitted",
383
+ location: {
384
+ ...location,
385
+ xpath: mod.xpath
386
+ },
387
+ namespaceUri: mod.namespaceUri,
388
+ localName: mod.localName,
389
+ mechanismHint: `color-transform:${mod.localName}`
390
+ });
391
+ }
392
+ const baseColor = slot !== void 0 ? lumMod !== void 0 ? {
393
+ slot,
394
+ lumMod,
395
+ ...lumOff === void 0 ? {} : { lumOff }
396
+ } : slot : hex;
397
+ if (baseColor === void 0) return void 0;
398
+ return alpha !== void 0 && alpha < 1 ? {
399
+ color: baseColor,
400
+ alpha
401
+ } : baseColor;
402
+ }
403
+ function readFooterRunStyle(rPrCursor, location, diagnostics) {
404
+ const attrStyles = readOoxmlRunAttrStyles({
405
+ rPrCursor,
406
+ location,
407
+ diagnostics,
408
+ allowBaseline: false,
409
+ allowNoneTextDecoration: false,
410
+ diagnoseUnsupportedEnums: false
411
+ });
412
+ const solidFill = rPrCursor.child(A_NS, "solidFill");
413
+ const color = solidFill === void 0 ? void 0 : readFooterXmlColor(solidFill, location, diagnostics);
414
+ const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPrCursor);
415
+ return {
416
+ ...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
417
+ ...attrStyles.fontWeight === void 0 ? {} : { fontWeight: attrStyles.fontWeight },
418
+ ...attrStyles.fontStyle === void 0 ? {} : { fontStyle: attrStyles.fontStyle },
419
+ ...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang },
420
+ ...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
421
+ ...color === void 0 ? {} : { color },
422
+ ...fontFamily === void 0 ? {} : { fontFamily },
423
+ ...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily }
424
+ };
425
+ }
426
+ function readSpPrTransformBox(spPr, location, diagnostics) {
427
+ const prstGeom = spPr.child(A_NS, "prstGeom");
428
+ if (prstGeom !== void 0) {
429
+ PrstGeomAttrSchema.safeParse(prstGeom.attrsObject(["prst"]));
430
+ prstGeom.ignoreEmptyChild(A_NS, "avLst");
431
+ }
432
+ const xfrm = spPr.child(A_NS, "xfrm");
433
+ if (xfrm === void 0) return void 0;
434
+ const off = xfrm.child(A_NS, "off");
435
+ const ext = xfrm.child(A_NS, "ext");
436
+ if (off === void 0 || ext === void 0) return void 0;
437
+ const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
438
+ const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
439
+ if (!parsedOff.success || !parsedExt.success) {
440
+ diagnostics.push({
441
+ code: "invalid-xml-value",
442
+ category: "corrupt-input",
443
+ disposition: "omitted",
444
+ location: {
445
+ ...location,
446
+ xpath: xfrm.xpath
447
+ },
448
+ attributeOrElement: "a:xfrm"
449
+ });
450
+ return;
451
+ }
452
+ return {
453
+ x: emuToPx(parsedOff.data.x),
454
+ y: emuToPx(parsedOff.data.y),
455
+ width: Math.max(1, emuToPx(parsedExt.data.cx)),
456
+ height: Math.max(1, emuToPx(parsedExt.data.cy))
457
+ };
458
+ }
459
+ function readFooterPlaceholderImport(context) {
460
+ const { cursor, part, slideIndex, containerNode } = context;
461
+ const location = {
462
+ part,
463
+ xpath: cursor.xpath,
464
+ ...containerNode !== void 0 && (containerNode.kind === "slide-master" || containerNode.kind === "slide-layout") ? {} : { slideIndex }
465
+ };
466
+ const diagnostics = [];
467
+ const nvSpPr = cursor.child(P_NS, "nvSpPr");
468
+ if (nvSpPr === void 0) return {};
469
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
470
+ if (cNvPr !== void 0) NonVisualIdAttrSchema.safeParse(cNvPr.attrsObject(["id", "name"]));
471
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
472
+ if (cNvSpPr !== void 0) {
473
+ const spLocks = cNvSpPr.child(A_NS, "spLocks");
474
+ if (spLocks !== void 0) SpLocksAttrSchema.safeParse(spLocks.attrsObject(["noGrp"]));
475
+ }
476
+ const ph = nvSpPr.child(P_NS, "nvPr")?.child(P_NS, "ph");
477
+ if (ph === void 0) return {};
478
+ const parsedPh = PlaceholderAttrSchema.safeParse(ph.attrsObject([
479
+ "type",
480
+ "sz",
481
+ "idx"
482
+ ]));
483
+ if (!parsedPh.success) return {};
484
+ const slot = ooxmlTypeToSlot[parsedPh.data.type];
485
+ const spPr = cursor.child(P_NS, "spPr");
486
+ const box = spPr === void 0 ? void 0 : readSpPrTransformBox(spPr, location, diagnostics);
487
+ let style;
488
+ const textParts = [];
489
+ const txBody = cursor.child(P_NS, "txBody");
490
+ if (txBody !== void 0) {
491
+ const bodyPr = txBody.child(A_NS, "bodyPr");
492
+ if (bodyPr !== void 0) {
493
+ const rawBody = bodyPr.attrsObject([
494
+ "vert",
495
+ "wrap",
496
+ "rtlCol",
497
+ "lIns",
498
+ "tIns",
499
+ "rIns",
500
+ "bIns",
501
+ "anchor"
502
+ ]);
503
+ const parsedBody = BodyPrAttrSchema.safeParse(rawBody);
504
+ if (parsedBody.success && parsedBody.data.anchor !== void 0) style = mergeFooterStyle(style, { verticalAlign: anchorMap[parsedBody.data.anchor] });
505
+ readOoxmlBoxInsets({
506
+ rawAttrs: rawBody,
507
+ attrNames: {
508
+ left: "lIns",
509
+ top: "tIns",
510
+ right: "rIns",
511
+ bottom: "bIns"
512
+ },
513
+ elementXpath: bodyPr.xpath,
514
+ location,
515
+ diagnostics
516
+ });
517
+ bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
518
+ bodyPr.ignoreEmptyChild(A_NS, "normAutofit");
519
+ bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
520
+ }
521
+ const lstStyle = txBody.child(A_NS, "lstStyle");
522
+ if (lstStyle !== void 0) {
523
+ const lvl1 = lstStyle.child(A_NS, "lvl1pPr");
524
+ if (lvl1 !== void 0) {
525
+ const parsedLvl1 = LvlPPrAttrSchema.safeParse(lvl1.attrsObject(["algn"]));
526
+ if (parsedLvl1.success && parsedLvl1.data.algn !== void 0) style = mergeFooterStyle(style, { align: algnMap[parsedLvl1.data.algn] });
527
+ const defRPr = lvl1.child(A_NS, "defRPr");
528
+ if (defRPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(defRPr, location, diagnostics));
529
+ }
530
+ }
531
+ for (const pCursor of txBody.children(A_NS, "p")) {
532
+ const pPr = pCursor.child(A_NS, "pPr");
533
+ if (pPr !== void 0) {
534
+ const parsedPPr = LvlPPrAttrSchema.safeParse(pPr.attrsObject(["algn"]));
535
+ if (parsedPPr.success && parsedPPr.data.algn !== void 0) style = mergeFooterStyle(style, { align: algnMap[parsedPPr.data.algn] });
536
+ const defRPr = pPr.child(A_NS, "defRPr");
537
+ if (defRPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(defRPr, location, diagnostics));
538
+ }
539
+ let paragraphText = "";
540
+ let hasRunOrField = false;
541
+ for (const child of pCursor.remainingElementChildren()) if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
542
+ hasRunOrField = true;
543
+ const rPr = child.child(A_NS, "rPr");
544
+ if (rPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(rPr, location, diagnostics));
545
+ const t = child.child(A_NS, "t");
546
+ if (t !== void 0) {
547
+ t.consumeAttr("space", XML_NS);
548
+ paragraphText += t.textContent;
549
+ }
550
+ } else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
551
+ hasRunOrField = true;
552
+ FieldAttrSchema.safeParse(child.attrsObject(["id", "type"]));
553
+ const rPr = child.child(A_NS, "rPr");
554
+ if (rPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(rPr, location, diagnostics));
555
+ child.ignoreEmptyChild(A_NS, "pPr");
556
+ const t = child.child(A_NS, "t");
557
+ if (t !== void 0) {
558
+ t.consumeAttr("space", XML_NS);
559
+ paragraphText += t.textContent;
560
+ }
561
+ } else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
562
+ const endStyle = readFooterRunStyle(child, location, diagnostics);
563
+ if (!hasRunOrField) style = mergeFooterStyle(style, endStyle);
564
+ }
565
+ textParts.push(paragraphText);
566
+ }
567
+ }
568
+ const combinedText = textParts.join("\n");
569
+ if (containerNode !== void 0 && (containerNode.kind === "slide-master" || containerNode.kind === "slide-layout")) {
570
+ const existingRaw = containerNode.props["footerPlaceholders"];
571
+ const existingParsed = existingRaw === void 0 ? {} : footerPlaceholdersSchema.parse(existingRaw);
572
+ const specStyle = mergeFooterStyle(box === void 0 ? void 0 : {
573
+ position: "absolute",
574
+ left: box.x,
575
+ top: box.y,
576
+ width: box.width,
577
+ height: box.height
578
+ }, style);
579
+ const spec = {
580
+ ...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
581
+ ...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz },
582
+ ...slot !== "slideNumber" && combinedText !== "" ? { text: combinedText } : {},
583
+ ...specStyle === void 0 ? {} : { style: specStyle },
584
+ visible: false
585
+ };
586
+ const nextFooterPlaceholders = {
587
+ ...existingParsed,
588
+ [slot]: spec
589
+ };
590
+ containerNode.set({ footerPlaceholders: nextFooterPlaceholders });
591
+ } else if (containerNode !== void 0 && containerNode.kind === "slide") {
592
+ if (slot === "slideNumber") {
593
+ const value = style === void 0 && parsedPh.data.idx === void 0 && parsedPh.data.sz === void 0 ? true : {
594
+ ...style === void 0 ? {} : { style },
595
+ ...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
596
+ ...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz }
597
+ };
598
+ containerNode.set({ slideNumber: value });
599
+ } else {
600
+ const value = style === void 0 && parsedPh.data.idx === void 0 && parsedPh.data.sz === void 0 ? combinedText : {
601
+ ...combinedText !== "" ? { text: combinedText } : {},
602
+ ...style === void 0 ? {} : { style },
603
+ ...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
604
+ ...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz }
605
+ };
606
+ containerNode.set({ [slot]: value });
607
+ }
608
+ }
609
+ return diagnostics.length === 0 ? {} : { diagnostics };
610
+ }
611
+ const footerPlaceholderShapeImportHandler = {
612
+ target: "shape-tree",
613
+ localName: "sp",
614
+ matches(cursor) {
615
+ return readFooterPlaceholderOoxmlType(cursor) !== void 0;
616
+ },
617
+ read: readFooterPlaceholderImport
618
+ };
619
+ /** Native canvas mechanism for `dt`, `ftr`, and `sldNum` metadata placeholders (`footer-placeholder`). */
620
+ const footerPlaceholderMechanism = defineCanvasMechanism({
621
+ key: "footer-placeholder",
622
+ role: "canvas",
623
+ emit: emitFooterPlaceholderModel,
624
+ paint: paintFooterPlaceholderModel,
625
+ import: footerPlaceholderShapeImportHandler
626
+ });
627
+ /** Slide capability resolving, painting, emitting, and importing `dateTime`, `footer`, `slideNumber`, and master/layout `footerPlaceholders`. */
628
+ const footerPlaceholderCapability = {
629
+ declaration: "footer-placeholder",
630
+ slideProp: "footer",
631
+ slideProps: [
632
+ "footer",
633
+ "dateTime",
634
+ "slideNumber"
635
+ ],
636
+ slot: "shape-tree",
637
+ always: true,
638
+ mechanisms: [footerPlaceholderMechanism],
639
+ codegen: footerPlaceholderCodegen,
640
+ bindSlide(input, context) {
641
+ const model = input.type === "slide-master" || input.type === "slide-layout" ? resolveContainerFooterModel({
642
+ targetType: input.type,
643
+ footerPlaceholders: footerPlaceholdersSchema.parse(input.props["footerPlaceholders"] ?? {}),
644
+ dimensions: context.dimensions,
645
+ theme: context.theme
646
+ }) : resolveSlideFooterModel({
647
+ slideProps: input.props,
648
+ ...context.inheritance === void 0 ? {} : { inheritance: context.inheritance },
649
+ dimensions: context.dimensions,
650
+ theme: context.theme,
651
+ slideNumber: context.slideNumber
652
+ });
653
+ return { resolveSlide() {
654
+ const claims = model.items.flatMap((item) => item.text.resourceClaims);
655
+ const fontUsages = model.items.flatMap((item) => item.text.fontUsages.map((usage) => ({
656
+ ...usage,
657
+ path: `footerPlaceholders.${item.slot}`
658
+ })));
659
+ let footer;
660
+ if (input.type === "slide" && model.items.length > 0) {
661
+ const slots = {};
662
+ for (const item of model.items) {
663
+ if (item.text.textMetrics === void 0) continue;
664
+ slots[item.slot] = {
665
+ box: item.box,
666
+ text: item.text.text,
667
+ textMetrics: item.text.textMetrics
668
+ };
669
+ }
670
+ if (Object.keys(slots).length > 0) footer = slots;
671
+ }
672
+ return {
673
+ extensions: [],
674
+ ...footer === void 0 ? {} : { footer },
675
+ ...claims.length === 0 ? {} : { resourceClaims: claims },
676
+ ...fontUsages.length === 0 ? {} : { fontUsages },
677
+ emit: (emitContext) => footerPlaceholderMechanism.emit(model, emitContext),
678
+ ...model.items.length === 0 ? {} : { paint: (paintContext) => footerPlaceholderMechanism.paint(model, paintContext) }
679
+ };
680
+ } };
681
+ }
682
+ };
683
+ export { footerPlaceholderCapability, footerPlaceholderMechanism, footerPlaceholderShapeImportHandler };