@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,13 @@
1
+ import { createPlaceholderNode } from "./placeholder-schemas.js";
2
+ import { hostNodeCreator } from "../../../core/dist/host.js";
3
+ import "./placeholder.js";
4
+ import { createElement } from "react";
5
+ // ../capabilities/dist/placeholder/placeholder-elements.js
6
+ /** Declares an unpopulated native content placeholder bound to a layout placeholder slot. */
7
+ function Placeholder(props) {
8
+ return createElement("placeholder", {
9
+ ...props,
10
+ [hostNodeCreator]: createPlaceholderNode
11
+ });
12
+ }
13
+ export { Placeholder };
@@ -0,0 +1,33 @@
1
+ import { authorIdSchema } from "../../../core/dist/author-ids.js";
2
+ import { layoutStyleShape } from "../../../core/dist/layout-schemas.js";
3
+ import { visualStyleShape } from "../../../core/dist/theme.js";
4
+ import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
5
+ import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
6
+ import "../../../core/dist/capability.js";
7
+ import { CommonNode } from "../../../core/dist/document.js";
8
+ import { optionalNameSchema } from "../shared/identity.js";
9
+ import { morphKeySchema } from "../shared/morph-api.js";
10
+ import { z } from "zod";
11
+ // ../capabilities/dist/placeholder/placeholder-schemas.js
12
+ const placeholderObjectStyleObjectSchema = z.strictObject({
13
+ ...layoutStyleShape,
14
+ ...visualStyleShape
15
+ });
16
+ const placeholderStyleKeys = Object.keys(placeholderObjectStyleObjectSchema.shape);
17
+ const placeholderObjectStyleSchema = placeholderObjectStyleObjectSchema.readonly();
18
+ const placeholderDeclarationPropsObjectSchema = z.strictObject({
19
+ id: authorIdSchema.optional(),
20
+ name: optionalNameSchema.optional(),
21
+ morphKey: morphKeySchema.optional(),
22
+ placeholder: z.string().min(1).optional(),
23
+ nativePlaceholder: nativePlaceholderRefSchema.optional(),
24
+ link: linkTargetSchema.optional(),
25
+ style: placeholderObjectStyleSchema.optional()
26
+ });
27
+ placeholderDeclarationPropsObjectSchema.readonly();
28
+ const placeholderAllowedPropKeys = new Set(Object.keys(placeholderDeclarationPropsObjectSchema.shape));
29
+ /** Creates an editable AST node representing an unpopulated native content placeholder (`<p:sp><p:ph .../></p:sp>` without `<p:txBody>`). */
30
+ function createPlaceholderNode(props) {
31
+ return new CommonNode("placeholder", "placeholder", props);
32
+ }
33
+ export { createPlaceholderNode, placeholderAllowedPropKeys, placeholderObjectStyleSchema, placeholderStyleKeys };
@@ -0,0 +1,451 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
3
+ import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
4
+ import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
5
+ import "../../../core/dist/capability.js";
6
+ import { assertXml10Characters, placeholderRefXml, xmlEscape } from "../../../emit/dist/ooxml.js";
7
+ import "../../../emit/dist/index.js";
8
+ import { A_NS, EMU_PER_PX, P_NS, emuToPx } from "../../../import/dist/namespaces.js";
9
+ import { extentEmuFragmentSchema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
10
+ import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
11
+ import "../../../import/dist/index.js";
12
+ import { createShapeNode, shapeStyleSchema } from "../shape/shape-declaration.js";
13
+ import { nativeLinkXml, parseMorphKey, parseOptionalName, readClickLink } from "../shared/identity.js";
14
+ import { directElementChild, emitPlaceholderUnbindDiagnostic, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, stripPlaceholderClearSentinels } from "../shared/placeholder-import.js";
15
+ import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
16
+ import { assertVisualBoxExtent, emitPlaceholderVisualSpPr, readSpPrAppearance, resolveVisualModel } from "../shared/visual.js";
17
+ import { placeholderCodegen } from "./placeholder-codegen.js";
18
+ import { createPlaceholderNode, placeholderAllowedPropKeys, placeholderObjectStyleSchema, placeholderStyleKeys } from "./placeholder-schemas.js";
19
+ import { z } from "zod";
20
+ // ../capabilities/dist/placeholder/placeholder.js
21
+ const NonVisualSpIdSchema = z.object({
22
+ id: ooxmlNonNegativeIntSchema,
23
+ name: z.string().optional()
24
+ });
25
+ const NonVisualSpPrFlagsSchema = z.object({ txBox: ooxmlBoolSchema.optional() });
26
+ const placeholderAllowedStyleKeys = new Set(placeholderStyleKeys);
27
+ function emitPlaceholderModel(model, emitContext) {
28
+ const escapedName = xmlEscape(model.name);
29
+ const spPrXml = emitPlaceholderVisualSpPr(model.visual, model.spPrFlags, (resource) => emitContext.registerResource(resource));
30
+ return { xml: `<p:sp><p:nvSpPr><p:cNvPr id="${emitContext.id}" name="${escapedName}">${nativeLinkXml(emitContext.nativeLink)}</p:cNvPr><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${placeholderRefXml(model.nativeRef)}</p:nvPr></p:nvSpPr>${spPrXml}</p:sp>` };
31
+ }
32
+ function paintPlaceholderModel() {
33
+ return { svg: "" };
34
+ }
35
+ /**
36
+ * Reads an unpopulated `<p:sp>` content/object placeholder (no `<p:txBody>`)
37
+ * into a layout-bound `PlaceholderNode` while preserving `<p:ph>` binding.
38
+ */
39
+ function readContentPlaceholderSp(context) {
40
+ const { cursor, part, slideIndex } = context;
41
+ const diagnostics = [];
42
+ const nvSpPr = cursor.child(P_NS, "nvSpPr");
43
+ if (nvSpPr === void 0) {
44
+ diagnostics.push({
45
+ code: "corrupt-part",
46
+ category: "corrupt-input",
47
+ disposition: "omitted",
48
+ location: {
49
+ part,
50
+ xpath: cursor.xpath,
51
+ slideIndex
52
+ }
53
+ });
54
+ return { diagnostics };
55
+ }
56
+ let objectId;
57
+ let objectName;
58
+ let clickResult;
59
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
60
+ if (cNvPr !== void 0) {
61
+ const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
62
+ const parsedCNvPr = NonVisualSpIdSchema.safeParse(rawCNvPr);
63
+ if (!parsedCNvPr.success) diagnostics.push({
64
+ code: "invalid-xml-value",
65
+ category: "corrupt-input",
66
+ disposition: "recovered",
67
+ location: {
68
+ part,
69
+ xpath: cNvPr.xpath,
70
+ slideIndex
71
+ },
72
+ attributeOrElement: "p:cNvPr",
73
+ rawValue: JSON.stringify(rawCNvPr)
74
+ });
75
+ else {
76
+ objectId = parsedCNvPr.data.id;
77
+ if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
78
+ }
79
+ const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
80
+ if (hlinkClick !== void 0) {
81
+ clickResult = readClickLink(hlinkClick, context, {
82
+ ...objectId === void 0 ? {} : { objectId },
83
+ ...objectName === void 0 ? {} : { objectName }
84
+ });
85
+ diagnostics.push(...clickResult.diagnostics);
86
+ }
87
+ cNvPr.ignoreEmptyChild(A_NS, "extLst");
88
+ }
89
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
90
+ if (cNvSpPr !== void 0) {
91
+ NonVisualSpPrFlagsSchema.safeParse(cNvSpPr.attrsObject(["txBox"]));
92
+ cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
93
+ "noGrp",
94
+ "noRot",
95
+ "noChangeAspect",
96
+ "noMove",
97
+ "noResize",
98
+ "noSelect"
99
+ ]);
100
+ }
101
+ const phLocation = {
102
+ part,
103
+ xpath: cursor.xpath,
104
+ slideIndex,
105
+ ...objectId === void 0 ? {} : { objectId },
106
+ ...objectName === void 0 ? {} : { objectName }
107
+ };
108
+ const nvPr = nvSpPr.child(P_NS, "nvPr");
109
+ const phResult = readNvPrPlaceholder(nvPr, phLocation, diagnostics);
110
+ if (phResult.kind === "none") {
111
+ diagnostics.push({
112
+ code: "corrupt-part",
113
+ category: "corrupt-input",
114
+ disposition: "omitted",
115
+ location: phLocation
116
+ });
117
+ return { diagnostics };
118
+ }
119
+ if (phResult.kind === "error") return { diagnostics };
120
+ const nativeRef = phResult.nativeRef;
121
+ const spPr = cursor.child(P_NS, "spPr");
122
+ if (spPr === void 0) {
123
+ diagnostics.push({
124
+ code: "corrupt-part",
125
+ category: "corrupt-input",
126
+ disposition: "omitted",
127
+ location: phLocation
128
+ });
129
+ return { diagnostics };
130
+ }
131
+ let localBox;
132
+ let rotate;
133
+ let flipH;
134
+ let flipV;
135
+ let fallbackUnits = {
136
+ w: 0,
137
+ h: 0
138
+ };
139
+ const xfrm = spPr.child(A_NS, "xfrm");
140
+ if (xfrm !== void 0) {
141
+ const hasExplicitFlipH = xfrm.element.hasAttribute("flipH");
142
+ const hasExplicitFlipV = xfrm.element.hasAttribute("flipV");
143
+ const rawXfrm = xfrm.attrsObject([
144
+ "rot",
145
+ "flipH",
146
+ "flipV"
147
+ ]);
148
+ const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
149
+ if (parsedXfrm.success) {
150
+ if (parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0) rotate = parsedXfrm.data.rot / 6e4;
151
+ if (hasExplicitFlipH && parsedXfrm.data.flipH !== void 0) flipH = parsedXfrm.data.flipH;
152
+ if (hasExplicitFlipV && parsedXfrm.data.flipV !== void 0) flipV = parsedXfrm.data.flipV;
153
+ }
154
+ const off = xfrm.child(A_NS, "off");
155
+ const ext = xfrm.child(A_NS, "ext");
156
+ if (off !== void 0 && ext !== void 0) {
157
+ const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
158
+ const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
159
+ if (parsedOff.success && parsedExt.success) {
160
+ fallbackUnits = {
161
+ w: parsedExt.data.cx,
162
+ h: parsedExt.data.cy
163
+ };
164
+ localBox = {
165
+ x: emuToPx(parsedOff.data.x),
166
+ y: emuToPx(parsedOff.data.y),
167
+ width: emuToPx(parsedExt.data.cx),
168
+ height: emuToPx(parsedExt.data.cy)
169
+ };
170
+ } else diagnostics.push({
171
+ code: "invalid-xml-value",
172
+ category: "corrupt-input",
173
+ disposition: "recovered",
174
+ location: {
175
+ ...phLocation,
176
+ xpath: xfrm.xpath
177
+ },
178
+ attributeOrElement: "a:xfrm"
179
+ });
180
+ }
181
+ }
182
+ const claim = resolvePlaceholderImportClaim({
183
+ context,
184
+ nativeRef
185
+ });
186
+ const layoutPlaceholder = claim.layoutPlaceholder;
187
+ const masterPlaceholder = claim.masterPlaceholder;
188
+ const inheritedWidth = (typeof layoutPlaceholder?.style?.width === "number" ? layoutPlaceholder.style.width : void 0) ?? (typeof masterPlaceholder?.style?.width === "number" ? masterPlaceholder.style.width : void 0);
189
+ const inheritedHeight = (typeof layoutPlaceholder?.style?.height === "number" ? layoutPlaceholder.style.height : void 0) ?? (typeof masterPlaceholder?.style?.height === "number" ? masterPlaceholder.style.height : void 0);
190
+ const inheritedBox = inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
191
+ width: inheritedWidth,
192
+ height: inheritedHeight
193
+ } : void 0;
194
+ const effectiveFallbackUnits = localBox === void 0 && inheritedBox !== void 0 ? {
195
+ w: Math.round(inheritedBox.width * EMU_PER_PX),
196
+ h: Math.round(inheritedBox.height * EMU_PER_PX)
197
+ } : fallbackUnits;
198
+ const appearance = readSpPrAppearance(spPr, context.package, effectiveFallbackUnits, phLocation, diagnostics, { preservePlaceholderClears: true });
199
+ const { border: rawBorder, ...restVisualStyle } = appearance.style;
200
+ const border = rawBorder;
201
+ const boxSize = localBox ?? inheritedBox;
202
+ let borderRadius;
203
+ if (appearance.geometry === "roundRect") {
204
+ if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
205
+ } else if (typeof appearance.geometry === "object" && appearance.geometry.type === "preset" && appearance.geometry.name === "roundRect" && boxSize !== void 0) {
206
+ const adj = appearance.geometry.adjust?.["adj"] ?? 16667;
207
+ if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
208
+ }
209
+ const combinedStyle = {
210
+ ...localBox === void 0 ? {} : {
211
+ position: "absolute",
212
+ left: localBox.x,
213
+ top: localBox.y,
214
+ width: localBox.width,
215
+ height: localBox.height
216
+ },
217
+ ...restVisualStyle,
218
+ ...border === void 0 ? {} : { border },
219
+ ...borderRadius === void 0 ? {} : { borderRadius },
220
+ ...rotate === void 0 ? {} : { rotate },
221
+ ...flipH === void 0 ? {} : { flipH },
222
+ ...flipV === void 0 ? {} : { flipV }
223
+ };
224
+ if (!claim.bound) {
225
+ const resolvedBox = resolveUnboundPlaceholderBox({
226
+ inheritanceContext: claim.inheritanceContext,
227
+ ...localBox === void 0 ? {} : { localBox },
228
+ requireHeight: true
229
+ });
230
+ if (resolvedBox === void 0 || resolvedBox.height === void 0) {
231
+ diagnostics.push({
232
+ code: "unsupported-mechanism",
233
+ category: "unsupported",
234
+ disposition: "omitted",
235
+ location: phLocation,
236
+ namespaceUri: P_NS,
237
+ localName: "ph",
238
+ mechanismHint: "orphan-placeholder-without-box"
239
+ });
240
+ return { diagnostics };
241
+ }
242
+ const freeVisual = materializeUnboundVisualStyle({
243
+ inheritanceContext: claim.inheritanceContext,
244
+ localVisualStyle: {
245
+ ...restVisualStyle,
246
+ ...border === void 0 ? {} : { border },
247
+ ...borderRadius === void 0 ? {} : { borderRadius },
248
+ ...rotate === void 0 ? {} : { rotate },
249
+ ...flipH === void 0 ? {} : { flipH },
250
+ ...flipV === void 0 ? {} : { flipV }
251
+ },
252
+ ...appearance.geometry === void 0 ? {} : { localGeometry: appearance.geometry },
253
+ boxSize: {
254
+ width: resolvedBox.width,
255
+ height: resolvedBox.height
256
+ }
257
+ });
258
+ const rawFreeStyle = stripPlaceholderClearSentinels({
259
+ ...freeVisual,
260
+ position: "absolute",
261
+ left: resolvedBox.x,
262
+ top: resolvedBox.y,
263
+ width: resolvedBox.width,
264
+ height: resolvedBox.height
265
+ });
266
+ const parsedFreeStyle = shapeStyleSchema.safeParse(rawFreeStyle);
267
+ const effectiveGeom = appearance.geometry ?? layoutPlaceholder?.geometry ?? masterPlaceholder?.geometry;
268
+ const freeShape = createShapeNode({
269
+ ...objectName === void 0 ? {} : { name: objectName },
270
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
271
+ ...effectiveGeom === void 0 ? {} : { geometry: effectiveGeom },
272
+ style: parsedFreeStyle.success ? parsedFreeStyle.data : {
273
+ position: "absolute",
274
+ left: resolvedBox.x,
275
+ top: resolvedBox.y,
276
+ width: resolvedBox.width,
277
+ height: resolvedBox.height
278
+ }
279
+ });
280
+ if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
281
+ const deferred = clickResult.deferredSlideLink;
282
+ context.registerDeferredSlideLink({
283
+ ...deferred,
284
+ apply(targetSlideId) {
285
+ freeShape.set({ link: { id: targetSlideId } });
286
+ }
287
+ });
288
+ }
289
+ emitPlaceholderUnbindDiagnostic({
290
+ diagnostics,
291
+ location: phLocation,
292
+ retainedAs: "shape"
293
+ });
294
+ return {
295
+ node: freeShape,
296
+ diagnostics
297
+ };
298
+ }
299
+ const matchedKey = claim.key;
300
+ let validatedStyle;
301
+ if (Object.keys(combinedStyle).length > 0) {
302
+ const parsedStyle = placeholderObjectStyleSchema.safeParse(combinedStyle);
303
+ if (parsedStyle.success) validatedStyle = parsedStyle.data;
304
+ }
305
+ const node = createPlaceholderNode({
306
+ ...objectName === void 0 ? {} : { name: objectName },
307
+ placeholder: matchedKey,
308
+ nativePlaceholder: nativeRef,
309
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
310
+ ...validatedStyle === void 0 ? {} : { style: validatedStyle }
311
+ });
312
+ if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
313
+ const deferred = clickResult.deferredSlideLink;
314
+ context.registerDeferredSlideLink({
315
+ ...deferred,
316
+ apply(targetSlideId) {
317
+ node.set({ link: { id: targetSlideId } });
318
+ }
319
+ });
320
+ }
321
+ return {
322
+ node,
323
+ diagnostics
324
+ };
325
+ }
326
+ /** Shape-tree import handler wired into `contentPlaceholderMechanism` for unpopulated `<p:sp><p:ph .../></p:sp>` placeholders without `<p:txBody>`. */
327
+ const contentPlaceholderImportHandler = {
328
+ target: "shape-tree",
329
+ localName: "sp",
330
+ matches: (cursor) => isPlaceholderSpElement(cursor) && directElementChild(cursor.element, "http://schemas.openxmlformats.org/presentationml/2006/main", "txBody") === void 0,
331
+ read: readContentPlaceholderSp
332
+ };
333
+ /** Typed native canvas mechanism connecting emit, paint, and import for unpopulated `content-placeholder`. */
334
+ const contentPlaceholderMechanism = defineCanvasMechanism({
335
+ key: "content-placeholder",
336
+ role: "canvas",
337
+ emit: emitPlaceholderModel,
338
+ paint: paintPlaceholderModel,
339
+ import: contentPlaceholderImportHandler
340
+ });
341
+ /** Capability preserving unpopulated non-text content placeholder slots across import/emit without synthesizing empty text bodies. */
342
+ const placeholderCapability = {
343
+ declaration: "placeholder",
344
+ mechanisms: [contentPlaceholderMechanism],
345
+ codegen: placeholderCodegen,
346
+ bind(input, context) {
347
+ const unknown = Object.keys(input.props).find((key) => !placeholderAllowedPropKeys.has(key));
348
+ if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Placeholder contains unsupported parameter ${unknown}`);
349
+ if (input.children.length > 0) throw new CapabilityError("unsupported-children", "Unpopulated content placeholder does not accept children");
350
+ const placeholder = context.placeholder;
351
+ const rawNative = nativePlaceholderRefSchema.safeParse(input.props["nativePlaceholder"]);
352
+ const nativeRef = placeholder?.nativeRef ?? (rawNative.success ? rawNative.data : void 0);
353
+ if (nativeRef === void 0) throw new CapabilityError("missing-placeholder-binding", "Content placeholder requires a bound layout placeholder or nativePlaceholder descriptor");
354
+ const requestedName = parseOptionalName(input.props["name"]);
355
+ const morphKey = parseMorphKey(input.props["morphKey"]);
356
+ const link = parseLinkTarget(input.props["link"]);
357
+ const contract = parseCapabilityLayoutContract({
358
+ nativeKind: "sp",
359
+ props: input.props,
360
+ allowedStyleKeys: placeholderAllowedStyleKeys,
361
+ allowPadding: false,
362
+ path: context.path
363
+ });
364
+ const rawSlideStyle = typeof input.props["style"] === "object" && input.props["style"] !== null && !Array.isArray(input.props["style"]) ? input.props["style"] : void 0;
365
+ const inheritedPlaceholderGeometry = placeholder?.layoutPlaceholder?.geometry ?? placeholder?.masterPlaceholder?.geometry;
366
+ const visualStyle = placeholder !== void 0 ? resolvePlaceholderVisualStyle(placeholder, rawSlideStyle) : rawSlideStyle !== void 0 ? { ...rawSlideStyle } : {};
367
+ resolveVisualModel({
368
+ theme: placeholder?.masterTheme ?? context.theme,
369
+ style: visualStyle,
370
+ box: {
371
+ x: 0,
372
+ y: 0,
373
+ width: 100,
374
+ height: 100
375
+ },
376
+ ...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
377
+ layoutOnlyWhenInvisible: true
378
+ });
379
+ const placeholderGeometry = placeholder === void 0 ? void 0 : resolvePlaceholderGeometry(placeholder, input.props);
380
+ const rawX = placeholderGeometry?.x;
381
+ const rawY = placeholderGeometry?.y;
382
+ const rawWidth = placeholderGeometry?.width;
383
+ const rawHeight = placeholderGeometry?.height;
384
+ const native = {
385
+ ...morphKey === void 0 ? {} : { morphKey },
386
+ ...requestedName === void 0 ? {} : { hasExplicitName: true },
387
+ ...link === void 0 ? {} : { link }
388
+ };
389
+ return {
390
+ contract,
391
+ ...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
392
+ resolve(resolveContext) {
393
+ const box = {
394
+ x: resolveContext.layoutBox?.x ?? (typeof rawX === "number" ? rawX : 0),
395
+ y: resolveContext.layoutBox?.y ?? (typeof rawY === "number" ? rawY : 0),
396
+ width: resolveContext.layoutBox?.width ?? (typeof rawWidth === "number" ? rawWidth : 100),
397
+ height: resolveContext.layoutBox?.height ?? (typeof rawHeight === "number" ? rawHeight : 100)
398
+ };
399
+ const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `Placeholder ${resolveContext.id - 1}`;
400
+ try {
401
+ assertXml10Characters(name);
402
+ } catch {
403
+ throw new CapabilityError("invalid-xml-character", "Placeholder.name contains characters not allowed in XML 1.0");
404
+ }
405
+ const hasBox = placeholder === void 0 || placeholderGeometry?.hasLocalBoxOverride === true;
406
+ if (hasBox) assertVisualBoxExtent(box);
407
+ const visual = resolveVisualModel({
408
+ theme: placeholder?.masterTheme ?? resolveContext.theme,
409
+ style: visualStyle,
410
+ box,
411
+ ...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
412
+ layoutOnlyWhenInvisible: !hasBox
413
+ });
414
+ const spPrFlags = {
415
+ hasBox,
416
+ hasRotate: hasLocalDeclaration(rawSlideStyle, "rotate"),
417
+ hasFlipH: hasLocalDeclaration(rawSlideStyle, "flipH"),
418
+ hasFlipV: hasLocalDeclaration(rawSlideStyle, "flipV"),
419
+ hasGeometryOrRadius: hasLocalDeclaration(rawSlideStyle, "borderRadius"),
420
+ hasFill: hasLocalDeclaration(rawSlideStyle, "background"),
421
+ hasBorder: hasLocalDeclaration(rawSlideStyle, "border"),
422
+ hasEffects: hasLocalDeclaration(rawSlideStyle, "boxShadow") || hasLocalDeclaration(rawSlideStyle, "softEdge"),
423
+ includeDefaultRectWhenHasBox: true
424
+ };
425
+ const model = {
426
+ box,
427
+ name,
428
+ nativeRef,
429
+ visual,
430
+ spPrFlags
431
+ };
432
+ return {
433
+ observation: {
434
+ id: resolveContext.id,
435
+ kind: "placeholder",
436
+ name,
437
+ box
438
+ },
439
+ extensions: [],
440
+ emit(emitContext) {
441
+ return contentPlaceholderMechanism.emit(model, emitContext);
442
+ },
443
+ paint() {
444
+ return contentPlaceholderMechanism.paint(model, void 0);
445
+ }
446
+ };
447
+ }
448
+ };
449
+ }
450
+ };
451
+ export { contentPlaceholderImportHandler, contentPlaceholderMechanism, createPlaceholderNode, placeholderCapability, placeholderObjectStyleSchema, readContentPlaceholderSp };