@officedk/pptxdk 0.0.0-stage → 0.1.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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -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 +2272 -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 +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -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 +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -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 +48 -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 +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,1372 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import "../../../core/dist/capability.js";
3
+ import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
4
+ import "../../../emit/dist/index.js";
5
+ import { ownerMotionSchema } from "./motion-schemas.js";
6
+ import "../../../import/dist/index.js";
7
+ import { defineShowMechanism } from "../../../import/dist/mechanism.js";
8
+ import { after, breathe, createMotionScopeHandle, fade, fillColor, floatDown, floatUp, fly, motionScopeAnnotation, motionStepAnnotation, repeat, spin, spinIn, stretch, wipe, zoom } from "./motion-api.js";
9
+ import { motionCodegen } from "./motion-codegen.js";
10
+ import { readSlideMotionImport } from "./motion-import.js";
11
+ import { addMotionPlanStartDelay, compileMotionPlan, composeMotionPlanStarts, motionPlanStartLayers } from "./motion-plan.js";
12
+ import { observeMotion, registerMotionObservation } from "./motion-query.js";
13
+ // ../capabilities/dist/motion/motion.js
14
+ function invalidMotionTime(field) {
15
+ throw new CapabilityError("invalid-motion-time", `${field} must be an exact non-negative integer in milliseconds, and must not exceed ST_TLTime range when written`);
16
+ }
17
+ function validateKnownTime(value, field) {
18
+ if (value !== void 0 && (!Number.isSafeInteger(value) || value < 0)) invalidMotionTime(field);
19
+ }
20
+ function timeNodeValue(value, field) {
21
+ validateKnownTime(value, field);
22
+ if (value > 4294967295) invalidMotionTime(field);
23
+ return value;
24
+ }
25
+ function validateKnownMotionTimes(observation) {
26
+ for (const scope of observation.scopes ?? []) {
27
+ validateKnownTime(scope.delayMs, "orchestration scope delay");
28
+ validateKnownTime(scope.eachMs, "stagger interval");
29
+ validateKnownTime(scope.startMs, "orchestration scope start time");
30
+ validateKnownTime(scope.endMs, "orchestration scope completion time");
31
+ validateKnownTime(scope.startAfter?.offsetMs, "scope completion dependency offset");
32
+ for (const dependency of scope.startAfterAll ?? []) validateKnownTime(dependency.offsetMs, "scope start constraint offset");
33
+ }
34
+ for (const step of observation.steps) for (const effect of step.effects) {
35
+ validateKnownTime(effect.durationMs, "animation duration");
36
+ validateKnownTime(effect.delayMs, "animation delay");
37
+ validateKnownTime(effect.intervalMs, "animation iteration interval");
38
+ validateKnownTime(effect.startMs, "animation start time");
39
+ validateKnownTime(effect.endMs, "animation completion time");
40
+ validateKnownTime(effect.startAfter?.offsetMs, "animation completion dependency offset");
41
+ for (const dependency of effect.startAfterAll ?? []) validateKnownTime(dependency.offsetMs, "animation start constraint offset");
42
+ }
43
+ }
44
+ function element(name, attributes, ...children) {
45
+ return `<${name}${Object.entries(attributes ?? {}).filter(([, value]) => value !== void 0).map(([key, value]) => {
46
+ return ` ${key}="${xmlEscape(String(typeof value === "boolean" ? value ? "1" : "0" : value))}"`;
47
+ }).join("")}>${children.filter(Boolean).join("")}</${name}>`;
48
+ }
49
+ function createTimingIds() {
50
+ let next = 1;
51
+ return { take() {
52
+ return next++;
53
+ } };
54
+ }
55
+ function timingTarget(effect, range = effect.target.range, background = false) {
56
+ return element("p:tgtEl", void 0, element("p:spTgt", { spid: effect.target.id }, background ? element("p:bg", void 0) : void 0, range?.type === "paragraph" ? element("p:txEl", void 0, element("p:pRg", {
57
+ st: range.start,
58
+ end: range.end
59
+ })) : void 0, range?.type === "chart" ? element("p:graphicEl", void 0, element("a:chart", {
60
+ seriesIdx: range.seriesIndex,
61
+ categoryIdx: range.categoryIndex,
62
+ bldStep: range.step
63
+ })) : void 0));
64
+ }
65
+ function nativeChartBuild(by) {
66
+ switch (by) {
67
+ case "series": return "series";
68
+ case "category": return "category";
69
+ case "seriesElements": return "seriesEl";
70
+ case "categoryElements": return "categoryEl";
71
+ default: return;
72
+ }
73
+ }
74
+ function attributeNames(value) {
75
+ return element("p:attrNameLst", void 0, element("p:attrName", void 0, value));
76
+ }
77
+ function visibilitySet(targetElement, visibility, ids) {
78
+ return element("p:set", void 0, element("p:cBhvr", void 0, element("p:cTn", {
79
+ id: ids.take(),
80
+ dur: 1,
81
+ fill: "hold"
82
+ }, element("p:stCondLst", void 0, element("p:cond", { delay: 0 }))), targetElement, attributeNames("style.visibility")), element("p:to", void 0, element("p:strVal", { val: visibility })));
83
+ }
84
+ function direction(effect) {
85
+ return typeof effect.from === "string" ? effect.from : "bottom";
86
+ }
87
+ /**
88
+ * Shape.text is native text inside the shape object, not a standalone text box. A whole entrance on
89
+ * such a shape must keep its fill and text in one object target so applications cannot reveal the
90
+ * background before the text. Standalone Text and explicit granularity keep their text projection.
91
+ */
92
+ function isWholeShapeTextEntrance(effect) {
93
+ return effect.kind === "entrance" && effect.targetKind === "shape" && effect.targetTextBody && effect.targetHasBackground && effect.target.range === void 0 && effect.by !== "paragraph" && effect.by !== "word" && effect.by !== "letter";
94
+ }
95
+ function wholeTextRanges(effect) {
96
+ if (isWholeShapeTextEntrance(effect)) return [];
97
+ if (!effect.targetTextBody || effect.target.range !== void 0 || effect.preset === "breathe" || effect.preset === "fillColor" || effect.by === "word" || effect.by === "letter" || effect.targetParagraphCount === void 0 || effect.targetParagraphCount < 1) return [];
98
+ return Array.from({ length: effect.targetParagraphCount }, (_, index) => ({
99
+ type: "paragraph",
100
+ start: index,
101
+ end: index
102
+ }));
103
+ }
104
+ function isWholeTextProjection(effect) {
105
+ return wholeTextRanges(effect).length > 0;
106
+ }
107
+ function hasWholeTextBackgroundBehaviors(effect) {
108
+ return isWholeTextProjection(effect) && effect.targetHasBackground;
109
+ }
110
+ function formulaNumber(value) {
111
+ return Number(value.toPrecision(15)).toString();
112
+ }
113
+ function formulaOffset(value, offset) {
114
+ if (offset === 0) return value;
115
+ return `${value}${offset < 0 ? "-" : "+"}${formulaNumber(Math.abs(offset))}`;
116
+ }
117
+ function geometryCenter(box, dimensions) {
118
+ if (dimensions.width <= 0 || dimensions.height <= 0) throw new CapabilityError("invalid-motion-page-size", "Slide dimensions must be greater than 0");
119
+ return {
120
+ x: (box.x + box.width / 2) / dimensions.width,
121
+ y: (box.y + box.height / 2) / dimensions.height
122
+ };
123
+ }
124
+ /** Common rotation center is calculated using integer EMUs from serialized xfrm and sldSz to avoid differing rounding results on readback. */
125
+ function serializedGeometryCenter(box, dimensions) {
126
+ const widthEmu = pxToEmu(dimensions.width);
127
+ const heightEmu = pxToEmu(dimensions.height);
128
+ if (widthEmu <= 0 || heightEmu <= 0) throw new CapabilityError("invalid-motion-page-size", "Slide dimensions must be greater than 0");
129
+ return {
130
+ x: (pxToEmu(box.x) + pxToEmu(box.width) / 2) / widthEmu,
131
+ y: (pxToEmu(box.y) + pxToEmu(box.height) / 2) / heightEmu
132
+ };
133
+ }
134
+ function targetBox(effect, purpose) {
135
+ if (effect.targetBox === void 0) throw new CapabilityError("motion-target-geometry", `${purpose} requires native object bounds obtained from the same layout`);
136
+ return effect.targetBox;
137
+ }
138
+ function rotationFormula(effect) {
139
+ const relativeBy = typeof effect.by === "number";
140
+ const degrees = relativeBy ? effect.by : typeof effect.from === "number" ? effect.from : 360;
141
+ return {
142
+ angle: `(${formulaNumber(degrees)}*pi/180)*${relativeBy ? "$" : "(1-$)"}`,
143
+ degrees
144
+ };
145
+ }
146
+ function centerRotationDelta(effect, center, dimensions, scaleToCenter = false, absolute = false) {
147
+ const widthEmu = pxToEmu(dimensions.width);
148
+ const heightEmu = pxToEmu(dimensions.height);
149
+ const ratioX = formulaNumber(heightEmu / widthEmu);
150
+ const ratioY = formulaNumber(widthEmu / heightEmu);
151
+ const centerX = formulaNumber(center.x);
152
+ const centerY = formulaNumber(center.y);
153
+ const { angle } = rotationFormula(effect);
154
+ const positionX = scaleToCenter ? `${centerX}+$*((#ppt_x-${centerX})*cos(${angle})-(#ppt_y-${centerY})*${ratioX}*sin(${angle}))` : `${centerX}+((#ppt_x-${centerX})*cos(${angle})-(#ppt_y-${centerY})*${ratioX}*sin(${angle}))`;
155
+ const positionY = scaleToCenter ? `${centerY}+$*((#ppt_x-${centerX})*${ratioY}*sin(${angle})+(#ppt_y-${centerY})*cos(${angle}))` : `${centerY}+((#ppt_x-${centerX})*${ratioY}*sin(${angle})+(#ppt_y-${centerY})*cos(${angle}))`;
156
+ return absolute ? [positionX, positionY] : [`${positionX}-#ppt_x`, `${positionY}-#ppt_y`];
157
+ }
158
+ function flyOffset(effect, dimensions) {
159
+ const box = effect.targetBox;
160
+ if (box === void 0) throw new CapabilityError("motion-target-geometry", "Whole-text entrance requires native object bounds obtained from the same layout");
161
+ const value = direction(effect);
162
+ switch (value) {
163
+ case "left": return {
164
+ x: -(box.x + box.width) / dimensions.width,
165
+ y: 0
166
+ };
167
+ case "right": return {
168
+ x: (dimensions.width - box.x) / dimensions.width,
169
+ y: 0
170
+ };
171
+ case "top": return {
172
+ x: 0,
173
+ y: -(box.y + box.height) / dimensions.height
174
+ };
175
+ case "bottom": return {
176
+ x: 0,
177
+ y: (dimensions.height - box.y) / dimensions.height
178
+ };
179
+ default: throw new Error(`Unsupported direction: ${JSON.stringify(value)}`);
180
+ }
181
+ }
182
+ function behaviorIds(effect, ids, dimensions, mixedShapeText) {
183
+ const ranges = wholeTextRanges(effect);
184
+ const wholeText = ranges.length > 0;
185
+ const target = () => timingTarget(effect);
186
+ const paragraphTargets = () => ranges.map((range) => timingTarget(effect, range));
187
+ const backgroundTarget = () => timingTarget(effect, void 0, true);
188
+ const duration = effect.durationMs;
189
+ validateKnownTime(duration, "animation duration");
190
+ if (effect.preset === "breathe") timeNodeValue(Math.round(duration / 2), "breathe half-period");
191
+ else timeNodeValue(duration, "animation behavior duration");
192
+ if (effect.repeatCount !== void 0 && effect.repeatCount !== "forever") timeNodeValue(effect.repeatCount * 1e3, "animation repeat count");
193
+ if (effect.intervalMs !== void 0) timeNodeValue(effect.intervalMs, "animation iteration interval");
194
+ const show = (targetElement) => visibilitySet(targetElement, "visible", ids);
195
+ const filter = (name, targetElement) => element("p:animEffect", {
196
+ transition: "in",
197
+ filter: name
198
+ }, element("p:cBhvr", void 0, element("p:cTn", {
199
+ id: ids.take(),
200
+ dur: duration
201
+ }), targetElement));
202
+ const value = (item) => typeof item === "number" ? element("p:fltVal", { val: item }) : element("p:strVal", { val: item });
203
+ const motion = (name, from, to, additive, targetElement, progressFormula) => element("p:anim", {
204
+ calcmode: "lin",
205
+ valueType: "num"
206
+ }, element("p:cBhvr", { additive: additive === true ? "base" : additive || void 0 }, element("p:cTn", {
207
+ id: ids.take(),
208
+ dur: duration,
209
+ fill: "hold"
210
+ }), targetElement, attributeNames(name)), element("p:tavLst", void 0, element("p:tav", {
211
+ tm: 0,
212
+ ...progressFormula === void 0 ? {} : { fmla: progressFormula }
213
+ }, element("p:val", void 0, value(from))), element("p:tav", { tm: 1e5 }, element("p:val", void 0, value(to)))));
214
+ const singleMotion = (name, from, to, additive, targetElement = target()) => motion(name, from, to, additive, targetElement);
215
+ const progressMotion = (name, formula, targetElement = target(), additive = "sum") => motion(name, 0, 1, additive, targetElement, formula);
216
+ const rotation = (targetElement, additive = false) => element("p:animRot", typeof effect.by === "number" ? { by: Math.round(effect.by * 6e4) } : {
217
+ from: Math.round((typeof effect.from === "number" ? effect.from : 360) * 6e4),
218
+ to: 0
219
+ }, element("p:cBhvr", { additive: additive === false ? void 0 : additive === true ? "base" : additive }, element("p:cTn", {
220
+ id: ids.take(),
221
+ dur: duration,
222
+ fill: "hold"
223
+ }), targetElement, attributeNames("r")));
224
+ const showOnce = () => wholeText && effect.kind === "entrance" ? [...paragraphTargets(), ...backgroundTargets()].map((targetElement) => show(targetElement)).join("") : show(wholeText ? timingTarget(effect, void 0) : target());
225
+ const filterTargets = () => wholeText ? paragraphTargets() : [target()];
226
+ const positionTargets = () => wholeText ? paragraphTargets() : [target()];
227
+ const backgroundTargets = () => wholeText && effect.targetHasBackground ? [backgroundTarget()] : [];
228
+ const mixedShapeRanges = isWholeShapeTextEntrance(effect) && mixedShapeText ? Array.from({ length: effect.targetParagraphCount ?? 0 }, (_, index) => ({
229
+ type: "paragraph",
230
+ start: index,
231
+ end: index
232
+ })) : [];
233
+ const mixedShapeGeometryForTarget = (targetElement) => {
234
+ switch (effect.preset) {
235
+ case "fly": {
236
+ const offset = flyOffset(effect, dimensions);
237
+ return [singleMotion("ppt_x", formulaOffset("#ppt_x", offset.x), "#ppt_x", true, targetElement), singleMotion("ppt_y", formulaOffset("#ppt_y", offset.y), "#ppt_y", true, targetElement)];
238
+ }
239
+ case "zoom": {
240
+ const center = geometryCenter(targetBox(effect, "whole-text zoom"), dimensions);
241
+ return [
242
+ singleMotion("ppt_x", `${formulaNumber(center.x)}-#ppt_x`, 0, "sum", targetElement),
243
+ singleMotion("ppt_y", `${formulaNumber(center.y)}-#ppt_y`, 0, "sum", targetElement),
244
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
245
+ singleMotion("ppt_h", 0, "#ppt_h", false, targetElement)
246
+ ];
247
+ }
248
+ case "spinIn": {
249
+ const position = centerRotationDelta(effect, serializedGeometryCenter(targetBox(effect, "whole-text spin-in"), dimensions), dimensions, true, true);
250
+ return [
251
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
252
+ singleMotion("ppt_h", 0, "#ppt_h", false, targetElement),
253
+ singleMotion("style.rotation", 360, 0, false, targetElement),
254
+ progressMotion("ppt_x", position[0], targetElement, "base"),
255
+ progressMotion("ppt_y", position[1], targetElement, "base")
256
+ ];
257
+ }
258
+ case "stretch": {
259
+ const center = geometryCenter(targetBox(effect, "whole-text stretch"), dimensions);
260
+ return [
261
+ singleMotion("ppt_x", `${formulaNumber(center.x)}-#ppt_x`, 0, "sum", targetElement),
262
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
263
+ singleMotion("ppt_h", "#ppt_h", "#ppt_h", false, targetElement)
264
+ ];
265
+ }
266
+ case "floatUp":
267
+ case "floatDown": {
268
+ const fromY = effect.preset === "floatDown" ? -.1 : .1;
269
+ return [singleMotion("ppt_x", 0, 0, "sum", targetElement), singleMotion("ppt_y", fromY, 0, "sum", targetElement)];
270
+ }
271
+ default: return [];
272
+ }
273
+ };
274
+ const primaryBehaviors = () => {
275
+ switch (effect.preset) {
276
+ case "fade": return [
277
+ showOnce(),
278
+ ...filterTargets().map((targetElement) => filter("fade", targetElement)),
279
+ ...backgroundTargets().map((targetElement) => filter("fade", targetElement))
280
+ ];
281
+ case "wipe": {
282
+ const filters = {
283
+ top: "wipe(up)",
284
+ right: "wipe(right)",
285
+ bottom: "wipe(down)",
286
+ left: "wipe(left)"
287
+ };
288
+ return [
289
+ showOnce(),
290
+ ...filterTargets().map((targetElement) => filter(filters[direction(effect)], targetElement)),
291
+ ...backgroundTargets().map((targetElement) => filter(filters[direction(effect)], targetElement))
292
+ ];
293
+ }
294
+ case "zoom": {
295
+ const targets = positionTargets();
296
+ if (!wholeText) return [
297
+ showOnce(),
298
+ singleMotion("ppt_w", 0, "#ppt_w", false),
299
+ singleMotion("ppt_h", 0, "#ppt_h", false),
300
+ filter("fade", target())
301
+ ];
302
+ const center = geometryCenter(targetBox(effect, "whole-text zoom"), dimensions);
303
+ const geometry = targets.flatMap((targetElement) => [
304
+ singleMotion("ppt_x", `${formulaNumber(center.x)}-#ppt_x`, 0, "sum", targetElement),
305
+ singleMotion("ppt_y", `${formulaNumber(center.y)}-#ppt_y`, 0, "sum", targetElement),
306
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
307
+ singleMotion("ppt_h", 0, "#ppt_h", false, targetElement)
308
+ ]);
309
+ const backgroundGeometry = backgroundTargets().flatMap((targetElement) => [
310
+ singleMotion("ppt_x", `${formulaNumber(center.x)}-#ppt_x`, 0, "sum", targetElement),
311
+ singleMotion("ppt_y", `${formulaNumber(center.y)}-#ppt_y`, 0, "sum", targetElement),
312
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
313
+ singleMotion("ppt_h", 0, "#ppt_h", false, targetElement)
314
+ ]);
315
+ return [
316
+ showOnce(),
317
+ ...geometry,
318
+ ...backgroundGeometry,
319
+ ...filterTargets().map((targetElement) => filter("fade", targetElement)),
320
+ ...backgroundTargets().map((targetElement) => filter("fade", targetElement))
321
+ ];
322
+ }
323
+ case "fly": {
324
+ const flyFrom = {
325
+ left: ["0-#ppt_w/2", "#ppt_y"],
326
+ right: ["1+#ppt_w/2", "#ppt_y"],
327
+ top: ["#ppt_x", "0-#ppt_h/2"],
328
+ bottom: ["#ppt_x", "1+#ppt_h/2"]
329
+ };
330
+ if (!wholeText) {
331
+ const [x, y] = flyFrom[direction(effect)];
332
+ return [
333
+ showOnce(),
334
+ singleMotion("ppt_x", x, "#ppt_x", true),
335
+ singleMotion("ppt_y", y, "#ppt_y", true)
336
+ ];
337
+ }
338
+ const offset = flyOffset(effect, dimensions);
339
+ const geometries = [...positionTargets(), ...backgroundTargets()].flatMap((targetElement) => [singleMotion("ppt_x", formulaOffset("#ppt_x", offset.x), "#ppt_x", true, targetElement), singleMotion("ppt_y", formulaOffset("#ppt_y", offset.y), "#ppt_y", true, targetElement)]);
340
+ return [showOnce(), ...geometries];
341
+ }
342
+ case "spinIn": {
343
+ if (!wholeText) return [
344
+ showOnce(),
345
+ singleMotion("ppt_w", 0, "#ppt_w", false),
346
+ singleMotion("ppt_h", 0, "#ppt_h", false),
347
+ singleMotion("style.rotation", 360, 0, false),
348
+ filter("fade", target())
349
+ ];
350
+ const position = centerRotationDelta(effect, serializedGeometryCenter(targetBox(effect, "whole-text spin-in"), dimensions), dimensions, true);
351
+ const geometry = positionTargets().flatMap((targetElement) => [
352
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
353
+ singleMotion("ppt_h", 0, "#ppt_h", false, targetElement),
354
+ singleMotion("style.rotation", 360, 0, false, targetElement),
355
+ progressMotion("ppt_x", position[0], targetElement),
356
+ progressMotion("ppt_y", position[1], targetElement)
357
+ ]);
358
+ return [
359
+ showOnce(),
360
+ ...geometry,
361
+ ...backgroundTargets().flatMap((targetElement) => [
362
+ progressMotion("ppt_x", position[0], targetElement),
363
+ progressMotion("ppt_y", position[1], targetElement),
364
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
365
+ singleMotion("ppt_h", 0, "#ppt_h", false, targetElement),
366
+ rotation(targetElement, "sum"),
367
+ filter("fade", targetElement)
368
+ ]),
369
+ ...filterTargets().map((targetElement) => filter("fade", targetElement))
370
+ ];
371
+ }
372
+ case "stretch": {
373
+ if (!wholeText) return [
374
+ showOnce(),
375
+ singleMotion("ppt_w", 0, "#ppt_w", false),
376
+ singleMotion("ppt_h", "#ppt_h", "#ppt_h", false)
377
+ ];
378
+ const center = geometryCenter(targetBox(effect, "whole-text stretch"), dimensions);
379
+ return [showOnce(), ...[...positionTargets(), ...backgroundTargets()].flatMap((targetElement) => [
380
+ singleMotion("ppt_x", `${formulaNumber(center.x)}-#ppt_x`, 0, "sum", targetElement),
381
+ singleMotion("ppt_w", 0, "#ppt_w", false, targetElement),
382
+ singleMotion("ppt_h", "#ppt_h", "#ppt_h", false, targetElement)
383
+ ])];
384
+ }
385
+ case "floatUp":
386
+ case "floatDown": {
387
+ if (!wholeText) return [
388
+ showOnce(),
389
+ filter("fade", target()),
390
+ singleMotion("ppt_x", "#ppt_x", "#ppt_x", false),
391
+ singleMotion("ppt_y", effect.preset === "floatDown" ? "#ppt_y-.1" : "#ppt_y+.1", "#ppt_y", false)
392
+ ];
393
+ const fromY = effect.preset === "floatDown" ? -.1 : .1;
394
+ const targets = [...positionTargets(), ...backgroundTargets()];
395
+ return [
396
+ showOnce(),
397
+ ...filterTargets().map((targetElement) => filter("fade", targetElement)),
398
+ ...backgroundTargets().map((targetElement) => filter("fade", targetElement)),
399
+ ...targets.flatMap((targetElement) => [singleMotion("ppt_x", 0, 0, "sum", targetElement), singleMotion("ppt_y", fromY, 0, "sum", targetElement)])
400
+ ];
401
+ }
402
+ case "spin": {
403
+ if (!wholeText && effect.groupSpinCenter === void 0) return [rotation(target(), typeof effect.by === "number" ? "sum" : false)];
404
+ const position = centerRotationDelta(effect, effect.groupSpinCenter ?? serializedGeometryCenter(targetBox(effect, "whole-text spin"), dimensions), dimensions);
405
+ if (wholeText) return [...positionTargets().flatMap((targetElement) => [
406
+ rotation(targetElement, "sum"),
407
+ progressMotion("ppt_x", position[0], targetElement),
408
+ progressMotion("ppt_y", position[1], targetElement)
409
+ ]), ...backgroundTargets().flatMap((targetElement) => [
410
+ rotation(targetElement, "sum"),
411
+ progressMotion("ppt_x", position[0], targetElement),
412
+ progressMotion("ppt_y", position[1], targetElement)
413
+ ])];
414
+ return [
415
+ rotation(target(), "sum"),
416
+ progressMotion("ppt_x", position[0]),
417
+ progressMotion("ppt_y", position[1])
418
+ ];
419
+ }
420
+ case "fillColor":
421
+ case "breathe": return [element("p:animClr", { clrSpc: "rgb" }, element("p:cBhvr", void 0, element("p:cTn", {
422
+ id: ids.take(),
423
+ dur: effect.preset === "breathe" ? Math.round(duration / 2) : duration,
424
+ fill: "hold"
425
+ }), target(), attributeNames("fillcolor")), element("p:from", void 0, element("a:srgbClr", { val: effect.fromColor?.slice(1) })), element("p:to", void 0, element("a:srgbClr", { val: effect.toColor?.slice(1) })))];
426
+ default: {
427
+ const exhaustiveCheck = effect.preset;
428
+ throw new Error(`Unsupported preset: ${JSON.stringify(exhaustiveCheck)}`);
429
+ }
430
+ }
431
+ };
432
+ return {
433
+ primary: primaryBehaviors(),
434
+ companions: mixedShapeRanges.map((range) => ({
435
+ range,
436
+ behaviors: mixedShapeGeometryForTarget(timingTarget(effect, range))
437
+ })).filter(({ behaviors }) => behaviors.length > 0)
438
+ };
439
+ }
440
+ function effectTreeXml(effect, nodeType, startCondition, effectId, buildGroupId, behaviors) {
441
+ if (effect.startAfter !== void 0) validateKnownTime(effect.startAfter.offsetMs, "completion dependency offset");
442
+ const preset = {
443
+ fade: {
444
+ id: 10,
445
+ class: "entr"
446
+ },
447
+ wipe: {
448
+ id: 22,
449
+ class: "entr"
450
+ },
451
+ zoom: {
452
+ id: 53,
453
+ class: "entr"
454
+ },
455
+ fly: {
456
+ id: 2,
457
+ class: "entr"
458
+ },
459
+ floatUp: {
460
+ id: 42,
461
+ class: "entr"
462
+ },
463
+ floatDown: {
464
+ id: 47,
465
+ class: "entr"
466
+ },
467
+ spinIn: {
468
+ id: 49,
469
+ class: "entr"
470
+ },
471
+ stretch: {
472
+ id: 17,
473
+ class: "entr"
474
+ },
475
+ spin: {
476
+ id: 8,
477
+ class: "emph"
478
+ },
479
+ breathe: {
480
+ id: 0,
481
+ class: "emph"
482
+ },
483
+ fillColor: {
484
+ id: 9,
485
+ class: "emph"
486
+ }
487
+ }[effect.preset];
488
+ const subtype = effect.preset === "zoom" ? 16 : effect.preset === "stretch" ? 10 : effect.preset === "wipe" || effect.preset === "fly" ? {
489
+ top: 1,
490
+ right: 2,
491
+ bottom: 4,
492
+ left: 8
493
+ }[direction(effect)] : 0;
494
+ const easing = effect.easing;
495
+ return element("p:par", void 0, element("p:cTn", {
496
+ id: effectId,
497
+ presetID: preset.id,
498
+ presetClass: preset.class,
499
+ presetSubtype: subtype,
500
+ repeatCount: effect.repeatCount === "forever" ? "indefinite" : effect.repeatCount === void 0 ? void 0 : effect.repeatCount * 1e3,
501
+ autoRev: effect.preset === "breathe" ? true : void 0,
502
+ accel: easing?.accelerate === void 0 || easing.accelerate === 0 ? void 0 : Math.round(easing.accelerate * 1e5),
503
+ decel: easing?.decelerate === void 0 || easing.decelerate === 0 ? void 0 : Math.round(easing.decelerate * 1e5),
504
+ fill: "hold",
505
+ grpId: effect.buildGroupId ?? (effect.targetTextBody ? 0 : buildGroupId),
506
+ nodeType
507
+ }, element("p:stCondLst", void 0, startCondition), effect.by !== "word" && effect.by !== "letter" ? void 0 : element("p:iterate", { type: effect.by === "word" ? "wd" : "lt" }, element("p:tmAbs", { val: effect.intervalMs })), element("p:childTnLst", void 0, ...behaviors)));
508
+ }
509
+ function emitMotionEffectTree(model) {
510
+ const projection = behaviorIds(model.effect, model.ids, model.dimensions, model.mixedShapeText);
511
+ return {
512
+ xml: effectTreeXml(model.effect, model.nodeType, model.startCondition, model.effectId, model.buildGroupId, projection.primary),
513
+ companions: projection.companions.map((companion) => effectTreeXml(model.effect, "withEffect", model.startCondition, model.ids.take(), model.buildGroupId, companion.behaviors))
514
+ };
515
+ }
516
+ /** Native show mechanism for `<p:par>` fade entrance (`presetID="10"`). */
517
+ const motionFadeMechanism = defineShowMechanism({
518
+ key: "motion-fade",
519
+ role: "show",
520
+ emit: (model, _context) => emitMotionEffectTree(model),
521
+ import: {
522
+ target: "slide",
523
+ slot: "timing",
524
+ read: readSlideMotionImport
525
+ }
526
+ });
527
+ /** Native show mechanism for `<p:par>` wipe entrance (`presetID="22"`). */
528
+ const motionWipeMechanism = defineShowMechanism({
529
+ key: "motion-wipe",
530
+ role: "show",
531
+ emit: (model, _context) => emitMotionEffectTree(model),
532
+ import: {
533
+ target: "slide",
534
+ slot: "timing",
535
+ matches: () => false,
536
+ read: readSlideMotionImport
537
+ }
538
+ });
539
+ /** Native show mechanism for `<p:par>` zoom entrance (`presetID="53"`). */
540
+ const motionZoomMechanism = defineShowMechanism({
541
+ key: "motion-zoom",
542
+ role: "show",
543
+ emit: (model, _context) => emitMotionEffectTree(model),
544
+ import: {
545
+ target: "slide",
546
+ slot: "timing",
547
+ matches: () => false,
548
+ read: readSlideMotionImport
549
+ }
550
+ });
551
+ /** Native show mechanism for `<p:par>` fly entrance (`presetID="2"`). */
552
+ const motionFlyMechanism = defineShowMechanism({
553
+ key: "motion-fly",
554
+ role: "show",
555
+ emit: (model, _context) => emitMotionEffectTree(model),
556
+ import: {
557
+ target: "slide",
558
+ slot: "timing",
559
+ matches: () => false,
560
+ read: readSlideMotionImport
561
+ }
562
+ });
563
+ /** Native show mechanism for `<p:par>` floatUp/floatDown entrance (`presetID="42"|"47"`). */
564
+ const motionFloatMechanism = defineShowMechanism({
565
+ key: "motion-float",
566
+ role: "show",
567
+ emit: (model, _context) => emitMotionEffectTree(model),
568
+ import: {
569
+ target: "slide",
570
+ slot: "timing",
571
+ matches: () => false,
572
+ read: readSlideMotionImport
573
+ }
574
+ });
575
+ /** Native show mechanism for `<p:par>` spinIn entrance (`presetID="49"`). */
576
+ const motionSpinInMechanism = defineShowMechanism({
577
+ key: "motion-spin-in",
578
+ role: "show",
579
+ emit: (model, _context) => emitMotionEffectTree(model),
580
+ import: {
581
+ target: "slide",
582
+ slot: "timing",
583
+ matches: () => false,
584
+ read: readSlideMotionImport
585
+ }
586
+ });
587
+ /** Native show mechanism for `<p:par>` stretch entrance (`presetID="17"`). */
588
+ const motionStretchMechanism = defineShowMechanism({
589
+ key: "motion-stretch",
590
+ role: "show",
591
+ emit: (model, _context) => emitMotionEffectTree(model),
592
+ import: {
593
+ target: "slide",
594
+ slot: "timing",
595
+ matches: () => false,
596
+ read: readSlideMotionImport
597
+ }
598
+ });
599
+ /** Native show mechanism for `<p:par>` spin emphasis (`presetID="8"`). */
600
+ const motionSpinMechanism = defineShowMechanism({
601
+ key: "motion-spin",
602
+ role: "show",
603
+ emit: (model, _context) => emitMotionEffectTree(model),
604
+ import: {
605
+ target: "slide",
606
+ slot: "timing",
607
+ matches: () => false,
608
+ read: readSlideMotionImport
609
+ }
610
+ });
611
+ /** Native show mechanism for `<p:par>` breathe emphasis (`presetID="0"` with `autoRev`). */
612
+ const motionBreatheMechanism = defineShowMechanism({
613
+ key: "motion-breathe",
614
+ role: "show",
615
+ emit: (model, _context) => emitMotionEffectTree(model),
616
+ import: {
617
+ target: "slide",
618
+ slot: "timing",
619
+ matches: () => false,
620
+ read: readSlideMotionImport
621
+ }
622
+ });
623
+ /** Native show mechanism for `<p:par>` fillColor emphasis (`presetID="9"`). */
624
+ const motionFillColorMechanism = defineShowMechanism({
625
+ key: "motion-fill-color",
626
+ role: "show",
627
+ emit: (model, _context) => emitMotionEffectTree(model),
628
+ import: {
629
+ target: "slide",
630
+ slot: "timing",
631
+ matches: () => false,
632
+ read: readSlideMotionImport
633
+ }
634
+ });
635
+ /** Native show mechanism for root `<p:timing>` (`tmRoot`, `mainSeq`, `endSync`, `bldLst`) choreography. */
636
+ const motionChoreographyMechanism = defineShowMechanism({
637
+ key: "motion-choreography",
638
+ role: "show",
639
+ emit(model, _context) {
640
+ return { xml: element("p:timing", void 0, element("p:tnLst", void 0, element("p:par", void 0, element("p:cTn", {
641
+ id: model.rootId,
642
+ dur: "indefinite",
643
+ restart: "never",
644
+ nodeType: "tmRoot"
645
+ }, element("p:childTnLst", void 0, element("p:seq", {
646
+ concurrent: true,
647
+ nextAc: "seek"
648
+ }, element("p:cTn", {
649
+ id: model.sequenceId,
650
+ dur: "indefinite",
651
+ nodeType: "mainSeq"
652
+ }, element("p:childTnLst", void 0, ...model.stepGroups)), element("p:prevCondLst", void 0, element("p:cond", {
653
+ evt: "onPrev",
654
+ delay: 0
655
+ }, model.slideTarget)), element("p:nextCondLst", void 0, element("p:cond", {
656
+ evt: "onNext",
657
+ delay: 0
658
+ }, model.slideTarget))))))), model.buildList.length === 0 ? void 0 : element("p:bldLst", void 0, ...model.buildList)) };
659
+ },
660
+ import: {
661
+ target: "slide",
662
+ slot: "timing",
663
+ matches: () => false,
664
+ read: readSlideMotionImport
665
+ }
666
+ });
667
+ const effectMechanismByPreset = {
668
+ fade: motionFadeMechanism,
669
+ wipe: motionWipeMechanism,
670
+ zoom: motionZoomMechanism,
671
+ fly: motionFlyMechanism,
672
+ floatUp: motionFloatMechanism,
673
+ floatDown: motionFloatMechanism,
674
+ spinIn: motionSpinInMechanism,
675
+ stretch: motionStretchMechanism,
676
+ spin: motionSpinMechanism,
677
+ breathe: motionBreatheMechanism,
678
+ fillColor: motionFillColorMechanism
679
+ };
680
+ function effectTree(effect, nodeType, startCondition, ids, effectId, buildGroupId, dimensions, mixedShapeText) {
681
+ const output = effectMechanismByPreset[effect.preset].emit({
682
+ effect,
683
+ nodeType,
684
+ startCondition,
685
+ ids,
686
+ effectId,
687
+ buildGroupId,
688
+ dimensions,
689
+ mixedShapeText
690
+ }, void 0);
691
+ return {
692
+ primary: output.xml,
693
+ companions: output.companions
694
+ };
695
+ }
696
+ function effectKey(effect) {
697
+ return `${effect.target.id}:${effect.effectIndex}:${effect.partIndex ?? ""}`;
698
+ }
699
+ function addNativeStartDelay(start, delayMs) {
700
+ const delayed = addMotionPlanStartDelay(start, delayMs);
701
+ if (delayed === void 0) return void 0;
702
+ const { base, delays } = motionPlanStartLayers(delayed);
703
+ return [base.kind === "parent-start" ? base.delayMs : base.kind === "end" || base.kind === "event" ? base.dependency.offsetMs : base.kind === "condition-end" ? base.delayMs : void 0, ...delays].every((value) => value === void 0 || Number.isSafeInteger(value) && value >= 0 && value <= 4294967295) ? delayed : void 0;
704
+ }
705
+ function dependencyTimingId(dependency, stepKey, effectNodeIds, scopeNodeIds, targetGroupIds) {
706
+ if ("scopeId" in dependency) return scopeNodeIds.get(`${stepKey}:${dependency.point}:${dependency.scopeId}`);
707
+ if ("group" in dependency) return targetGroupIds.get(`${stepKey}:${dependency.targetId}`);
708
+ return effectNodeIds.get(`${dependency.targetId}:${dependency.effectIndex}:${dependency.partIndex ?? ""}`);
709
+ }
710
+ function nativeStartCondition(start, stepKey, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds) {
711
+ if (start.kind === "parent-start") return element("p:cond", { delay: timeNodeValue(start.delayMs, "animation start delay") });
712
+ if (start.kind === "condition-join") throw new Error("MotionPlan condition join must be emitted before its consumers");
713
+ if (start.kind === "delay-layer") throw new Error("MotionPlan delay layer must be emitted through native time container");
714
+ if (start.kind === "condition-end") {
715
+ const conditionId = conditionNodeIds.get(`${stepKey}:${start.id}`);
716
+ if (conditionId === void 0) throw new Error("MotionPlan condition join is missing native time node identity");
717
+ return element("p:cond", {
718
+ evt: "end",
719
+ delay: timeNodeValue(start.delayMs, "condition join completion offset")
720
+ }, element("p:tn", { val: conditionId }));
721
+ }
722
+ const dependencyId = dependencyTimingId(start.dependency, stepKey, effectNodeIds, scopeNodeIds, targetGroupIds);
723
+ if (dependencyId === void 0) throw new Error("MotionPlan completion dependency lacks corresponding native timing node");
724
+ return element("p:cond", {
725
+ evt: start.kind === "event" || start.dependency.point === "start" ? "begin" : "end",
726
+ delay: timeNodeValue(start.dependency.offsetMs, "completion dependency offset")
727
+ }, element("p:tn", { val: dependencyId }));
728
+ }
729
+ function endSync() {
730
+ return element("p:endSync", {
731
+ evt: "end",
732
+ delay: 0
733
+ }, element("p:rtn", { val: "all" }));
734
+ }
735
+ function timingContainer(id, startCondition, children, nodeType) {
736
+ const isEmpty = children.length === 0;
737
+ return element("p:par", void 0, element("p:cTn", {
738
+ id,
739
+ ...isEmpty ? { dur: 0 } : {},
740
+ fill: "hold",
741
+ nodeType
742
+ }, element("p:stCondLst", void 0, startCondition), isEmpty ? void 0 : endSync(), isEmpty ? void 0 : element("p:childTnLst", void 0, ...children)));
743
+ }
744
+ function conditionJoinTree(start, stepKey, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds) {
745
+ const id = conditionNodeIds.get(`${stepKey}:${start.id}`);
746
+ if (id === void 0) throw new Error("MotionPlan condition join is missing native time node identity");
747
+ return endCollectorTree(id, element("p:cond", { delay: 0 }), start.gates, stepKey, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds);
748
+ }
749
+ function gateStart(gate) {
750
+ switch (gate.kind) {
751
+ case "parent-start": return {
752
+ kind: "parent-start",
753
+ delayMs: gate.delayMs
754
+ };
755
+ case "end": return {
756
+ kind: "end",
757
+ dependency: gate.dependency
758
+ };
759
+ case "begin": return {
760
+ kind: "event",
761
+ dependency: gate.dependency
762
+ };
763
+ case "plan-start": return gate.start;
764
+ default: throw new Error(`Unsupported gate: ${JSON.stringify(gate)}`);
765
+ }
766
+ }
767
+ function endCollectorTree(id, startCondition, gates, stepKey, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds, nodeType) {
768
+ const gateTree = (gate) => {
769
+ const { base, delays } = motionPlanStartLayers(gateStart(gate));
770
+ if (base.kind === "condition-join") throw new Error("MotionPlan native condition gate cannot embed undefined condition joins");
771
+ const container = (start, children = []) => timingContainer(ids.take(), nativeStartCondition(start, stepKey, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), children);
772
+ const lastDelay = delays.at(-1);
773
+ let children = [container(lastDelay === void 0 ? base : {
774
+ kind: "parent-start",
775
+ delayMs: lastDelay
776
+ })];
777
+ for (let layerIndex = delays.length - 2; layerIndex >= 0; layerIndex -= 1) {
778
+ const delayMs = delays[layerIndex];
779
+ if (delayMs !== void 0) children = [container({
780
+ kind: "parent-start",
781
+ delayMs
782
+ }, children)];
783
+ }
784
+ return delays.length === 0 ? children[0] : container(base, children);
785
+ };
786
+ return timingContainer(id, startCondition, gates.map(gateTree), nodeType);
787
+ }
788
+ function mainSequenceWithGroup(id, children) {
789
+ return element("p:par", void 0, element("p:cTn", {
790
+ id,
791
+ fill: "hold"
792
+ }, element("p:stCondLst", void 0, element("p:cond", { delay: 0 })), element("p:childTnLst", void 0, ...children)));
793
+ }
794
+ function timingXml(steps, dimensions) {
795
+ const ids = createTimingIds();
796
+ const rootId = ids.take();
797
+ const sequenceId = ids.take();
798
+ const effectNodeIds = /* @__PURE__ */ new Map();
799
+ const scopeNodeIds = /* @__PURE__ */ new Map();
800
+ const targetGroupIds = /* @__PURE__ */ new Map();
801
+ const conditionNodeIds = /* @__PURE__ */ new Map();
802
+ const referencedScopeNodes = /* @__PURE__ */ new Set();
803
+ const referencedScopeStartNodes = /* @__PURE__ */ new Set();
804
+ const referencedTargetGroups = /* @__PURE__ */ new Set();
805
+ const keepDependencyContainer = (dependency, stepKey) => {
806
+ if ("scopeId" in dependency) {
807
+ const key = `${stepKey}:${dependency.point}:${dependency.scopeId}`;
808
+ if (dependency.point === "start") referencedScopeStartNodes.add(key);
809
+ else referencedScopeNodes.add(key);
810
+ } else if ("group" in dependency) referencedTargetGroups.add(`${stepKey}:${dependency.targetId}`);
811
+ };
812
+ const collectStartReferences = (start, stepKey) => {
813
+ if (start.kind === "delay-layer") collectStartReferences(start.start, stepKey);
814
+ else if (start.kind === "end" || start.kind === "event") keepDependencyContainer(start.dependency, stepKey);
815
+ else if (start.kind === "condition-join") {
816
+ referencedScopeStartNodes.add(`${stepKey}:start:${start.hostScopeId}`);
817
+ referencedScopeStartNodes.add(`${stepKey}:start:${start.consumerParentScopeId}`);
818
+ for (const gate of start.gates) collectStartReferences(gateStart(gate), stepKey);
819
+ }
820
+ };
821
+ const collectReferencedContainers = (nodes, stepKey) => {
822
+ for (const node of nodes) {
823
+ collectStartReferences(node.nativeStart, stepKey);
824
+ if (node.kind === "completion-collector") for (const gate of node.gates) collectStartReferences(gateStart(gate), stepKey);
825
+ if (node.kind === "scope") {
826
+ for (const placement of node.conditionDefinitionsBefore ?? []) {
827
+ referencedScopeStartNodes.add(`${stepKey}:start:${placement.join.hostScopeId}`);
828
+ referencedScopeStartNodes.add(`${stepKey}:start:${placement.join.consumerParentScopeId}`);
829
+ for (const gate of placement.join.gates) collectStartReferences(gateStart(gate), stepKey);
830
+ }
831
+ collectReferencedContainers(node.children, stepKey);
832
+ }
833
+ }
834
+ };
835
+ for (const step of steps) {
836
+ collectReferencedContainers(step.nodes, step.key);
837
+ for (const placement of step.conditionDefinitionsBefore ?? []) for (const gate of placement.join.gates) collectStartReferences(gateStart(gate), step.key);
838
+ }
839
+ const registerNodeIds = (nodes, stepKey) => {
840
+ for (const node of nodes) {
841
+ const { base: startBase } = motionPlanStartLayers(node.nativeStart);
842
+ if (startBase.kind === "condition-join") conditionNodeIds.set(`${stepKey}:${startBase.id}`, ids.take());
843
+ if (node.kind === "scope") {
844
+ for (const placement of node.conditionDefinitionsBefore ?? []) conditionNodeIds.set(`${stepKey}:${placement.join.id}`, ids.take());
845
+ const scopeTimingId = ids.take();
846
+ scopeNodeIds.set(`${stepKey}:start:${node.id}`, scopeTimingId);
847
+ if (node.splitCompletion !== true) scopeNodeIds.set(`${stepKey}:end:${node.id}`, scopeTimingId);
848
+ registerNodeIds(node.children, stepKey);
849
+ continue;
850
+ }
851
+ if (node.kind === "completion-collector") {
852
+ scopeNodeIds.set(`${stepKey}:end:${node.scopeId}`, ids.take());
853
+ continue;
854
+ }
855
+ if (node.effects.length > 1) targetGroupIds.set(`${stepKey}:${node.targetId}`, ids.take());
856
+ for (const effect of node.effects) effectNodeIds.set(effectKey(effect), ids.take());
857
+ }
858
+ };
859
+ for (const step of steps) {
860
+ for (const placement of step.conditionDefinitionsBefore ?? []) conditionNodeIds.set(`${step.key}:${placement.join.id}`, ids.take());
861
+ registerNodeIds(step.nodes, step.key);
862
+ }
863
+ const chartBuildGroupIds = /* @__PURE__ */ new Map();
864
+ for (const step of steps) for (const effect of step.effects) if (effect.target.range?.type === "chart" && !chartBuildGroupIds.has(effect.target.id)) {
865
+ const id = effectNodeIds.get(effectKey(effect));
866
+ if (id !== void 0) chartBuildGroupIds.set(effect.target.id, id);
867
+ }
868
+ const slideEffects = steps.flatMap((step) => step.effects.map((effect) => effect));
869
+ const paragraphTextTargets = new Set(slideEffects.filter((effect) => effect.targetTextBody && effect.target.range?.type === "paragraph").map((effect) => effect.target.id));
870
+ const nativeProjections = [];
871
+ const nativeTextEffects = [];
872
+ const collectNativeTextEffect = (effect, declaration) => {
873
+ if (effect.targetTextBody) nativeTextEffects.push({
874
+ effect,
875
+ declaration
876
+ });
877
+ };
878
+ const memberIds = (members) => {
879
+ const result = /* @__PURE__ */ new Set();
880
+ const pending = [...members];
881
+ while (pending.length > 0) {
882
+ const member = pending.pop();
883
+ if (member === void 0) continue;
884
+ result.add(member.id);
885
+ pending.push(...member.members ?? []);
886
+ }
887
+ return result;
888
+ };
889
+ const leafMembers = (members) => members.flatMap((member) => member.members === void 0 || member.members.length === 0 ? [member] : leafMembers(member.members));
890
+ const renderedEffect = (effect, nodeType, startCondition, effectId, chartGroupId) => {
891
+ const mixedShapeText = paragraphTextTargets.has(effect.target.id);
892
+ const members = effect.targetMembers;
893
+ const descendantIds = members === void 0 ? /* @__PURE__ */ new Set() : memberIds(members);
894
+ const hasAnimatedMember = slideEffects.some(({ target }) => target.id !== effect.target.id && descendantIds.has(target.id));
895
+ if (effect.preset === "spin" && members !== void 0 && hasAnimatedMember) {
896
+ const box = effect.targetBox;
897
+ if (box === void 0) throw new CapabilityError("motion-target-geometry", "Native Group rotation projection requires combination bounds obtained from the same layout");
898
+ const center = serializedGeometryCenter(box, dimensions);
899
+ const projectedMembers = leafMembers(members);
900
+ if (projectedMembers.length === 0) throw new CapabilityError("empty-group-projection", "Native Group rotation requires at least one real member target");
901
+ const nativeEffects = [];
902
+ const { targetMembers: _targetMembers, buildGroupId: _buildGroupId, ...groupEffect } = effect;
903
+ const rendered = projectedMembers.map((member, index) => {
904
+ const targetEffectId = index === 0 ? effectId : ids.take();
905
+ nativeEffects.push({
906
+ targetId: member.id,
907
+ timingId: targetEffectId
908
+ });
909
+ const memberEffect = slideEffects.find(({ target }) => target.id === member.id);
910
+ const targetTextBody = memberEffect?.targetTextBody ?? false;
911
+ const projected = {
912
+ ...groupEffect,
913
+ target: {
914
+ id: member.id,
915
+ name: member.name,
916
+ ...member.authorId === void 0 ? {} : { authorId: member.authorId }
917
+ },
918
+ targetTextBody,
919
+ targetFilled: memberEffect?.targetFilled ?? false,
920
+ targetKind: member.kind,
921
+ targetHasBackground: memberEffect?.targetHasBackground ?? false,
922
+ ...member.box === void 0 ? {} : { targetBox: member.box },
923
+ ...memberEffect?.targetRotationDegrees === void 0 ? {} : { targetRotationDegrees: memberEffect.targetRotationDegrees },
924
+ ...memberEffect?.targetParagraphCount === void 0 ? {} : { targetParagraphCount: memberEffect.targetParagraphCount },
925
+ ...targetTextBody ? { buildGroupId: 1 } : {},
926
+ groupSpinCenter: center
927
+ };
928
+ collectNativeTextEffect(projected, effect);
929
+ return effectTree(projected, index === 0 ? nodeType : "withEffect", startCondition, ids, targetEffectId, void 0, dimensions, false).primary;
930
+ });
931
+ nativeProjections.push({
932
+ logicalTargetId: effect.target.id,
933
+ logicalEffectIndex: effect.effectIndex,
934
+ preset: effect.preset,
935
+ nativeEffects
936
+ });
937
+ return {
938
+ primary: rendered,
939
+ companions: []
940
+ };
941
+ }
942
+ const textBuildGroupId = effect.targetTextBody ? isWholeTextProjection(effect) ? 1 : 0 : void 0;
943
+ const nativeEffect = {
944
+ ...effect,
945
+ ...textBuildGroupId === void 0 ? {} : { buildGroupId: textBuildGroupId }
946
+ };
947
+ collectNativeTextEffect(nativeEffect, effect);
948
+ const projection = effectTree(nativeEffect, nodeType, startCondition, ids, effectId, chartGroupId, dimensions, mixedShapeText);
949
+ return {
950
+ primary: [projection.primary],
951
+ companions: projection.companions
952
+ };
953
+ };
954
+ const stepGroups = steps.filter(({ nodes }) => nodes.length > 0).map((step) => {
955
+ const hasConditionJoin = (start) => start.kind === "condition-join" || start.kind === "delay-layer" && hasConditionJoin(start.start);
956
+ const hasPrivateTimingDefinitions = (nodes) => nodes.some((node) => {
957
+ if (node.kind === "completion-collector" || hasConditionJoin(node.nativeStart)) return true;
958
+ return node.kind === "scope" && ((node.conditionDefinitionsBefore?.length ?? 0) > 0 || hasPrivateTimingDefinitions(node.children));
959
+ });
960
+ const preserveStepHost = (step.conditionDefinitionsBefore?.length ?? 0) > 0 || hasPrivateTimingDefinitions(step.nodes);
961
+ const stepId = ids.take();
962
+ const trigger = step.trigger === "click" ? element("p:cond", { delay: "indefinite" }) : `${element("p:cond", { delay: "indefinite" })}${element("p:cond", {
963
+ evt: "onBegin",
964
+ delay: 0
965
+ }, element("p:tn", { val: sequenceId }))}`;
966
+ const childDelay = (effect) => timeNodeValue(effect.delayMs + (effect.partIndex ?? 0) * effect.durationMs, "animated object member delay");
967
+ const renderedRoot = (xml, kind, stepEntryRole = false, promoteToStep = false) => ({
968
+ xml,
969
+ kind,
970
+ stepEntryRole,
971
+ promoteToStep
972
+ });
973
+ const effectRoots = (xml, carriesStepEntryRole) => xml.map((item, index) => renderedRoot(item, "effect", index === 0 && carriesStepEntryRole));
974
+ const wrapDelayLayers = (start, children, nodeType) => {
975
+ const { base, delays } = motionPlanStartLayers(start);
976
+ if (delays.length === 0) return [...children];
977
+ const rendered = [];
978
+ let outerStart = base;
979
+ if (outerStart.kind === "condition-join") {
980
+ rendered.push(renderedRoot(conditionJoinTree(outerStart, step.key, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), "condition-definition"));
981
+ outerStart = {
982
+ kind: "condition-end",
983
+ id: outerStart.id,
984
+ delayMs: 0
985
+ };
986
+ }
987
+ let nestedChildren = children.map(({ xml }) => xml);
988
+ for (let layerIndex = delays.length - 2; layerIndex >= 0; layerIndex -= 1) {
989
+ const delayMs = delays[layerIndex];
990
+ if (delayMs === void 0) continue;
991
+ nestedChildren = [timingContainer(ids.take(), nativeStartCondition({
992
+ kind: "parent-start",
993
+ delayMs
994
+ }, step.key, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), nestedChildren)];
995
+ }
996
+ rendered.push(renderedRoot(timingContainer(ids.take(), nativeStartCondition(outerStart, step.key, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), nestedChildren, nodeType), "delay-layer", nodeType !== void 0));
997
+ return rendered;
998
+ };
999
+ const renderNodes = (nodes, inheritedStart, isTopLevel, firstRootNodeType, conditionDefinitionsBefore = []) => {
1000
+ const rendered = [];
1001
+ const deferredCompanions = [];
1002
+ let pendingRootNodeType = firstRootNodeType;
1003
+ for (const [index, node] of nodes.entries()) {
1004
+ const nodeId = node.kind === "scope" ? `scope:${node.id}` : node.kind === "completion-collector" ? `completion:${node.scopeId}` : `target:${node.targetId}`;
1005
+ for (const placement of conditionDefinitionsBefore) {
1006
+ if (placement.join.beforeNodeId !== nodeId) continue;
1007
+ rendered.push(renderedRoot(conditionJoinTree(placement.join, step.key, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), "condition-definition"));
1008
+ }
1009
+ const defaultNodeType = index === 0 && isTopLevel && step.trigger === "click" ? "clickEffect" : index === 0 ? "afterEffect" : "withEffect";
1010
+ const nodeType = defaultNodeType;
1011
+ let effectiveStart = composeMotionPlanStarts(inheritedStart, node.nativeStart);
1012
+ if (effectiveStart === void 0) throw new Error("Native timing projection must preserve delay layering");
1013
+ if (effectiveStart.kind === "delay-layer") {
1014
+ const { delays } = motionPlanStartLayers(effectiveStart);
1015
+ const lastDelay = delays.at(-1);
1016
+ if (lastDelay === void 0) throw new Error("MotionPlan delay layer is missing actual delay field");
1017
+ const delayedNode = {
1018
+ ...node,
1019
+ nativeStart: {
1020
+ kind: "parent-start",
1021
+ delayMs: lastDelay
1022
+ }
1023
+ };
1024
+ const delayedRoots = wrapDelayLayers(effectiveStart, renderNodes([delayedNode], void 0, false), pendingRootNodeType);
1025
+ rendered.push(...delayedRoots);
1026
+ if (delayedRoots.some(({ stepEntryRole }) => stepEntryRole)) pendingRootNodeType = void 0;
1027
+ continue;
1028
+ }
1029
+ if (effectiveStart.kind === "condition-join") {
1030
+ rendered.push(renderedRoot(conditionJoinTree(effectiveStart, step.key, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), "condition-definition"));
1031
+ effectiveStart = {
1032
+ kind: "condition-end",
1033
+ id: effectiveStart.id,
1034
+ delayMs: 0
1035
+ };
1036
+ }
1037
+ if (node.kind === "scope") {
1038
+ const scopeId = scopeNodeIds.get(`${step.key}:start:${node.id}`);
1039
+ if (scopeId === void 0) throw new Error("MotionPlan scope is missing native time node identity");
1040
+ const needsCompletionNode = node.splitCompletion !== true && referencedScopeNodes.has(`${step.key}:end:${node.id}`);
1041
+ const needsStartNode = node.preserveStart === true || referencedScopeStartNodes.has(`${step.key}:start:${node.id}`);
1042
+ const promoteScopeToStep = isTopLevel && !preserveStepHost && (needsCompletionNode || needsStartNode);
1043
+ const childrenCanLift = node.children.every((child) => {
1044
+ const childStart = composeMotionPlanStarts(effectiveStart, child.nativeStart);
1045
+ if (childStart === void 0) return false;
1046
+ if (child.kind === "scope" || child.kind === "completion-collector" || child.effects.length > 1) return true;
1047
+ const [effect] = child.effects;
1048
+ return effect !== void 0 && addNativeStartDelay(childStart, childDelay(effect)) !== void 0;
1049
+ });
1050
+ if (needsCompletionNode || needsStartNode || !childrenCanLift) {
1051
+ const condition = nativeStartCondition(effectiveStart, step.key, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds);
1052
+ const children = renderNodes(node.children, void 0, false, promoteScopeToStep ? pendingRootNodeType ?? defaultNodeType : void 0, node.conditionDefinitionsBefore);
1053
+ const renderedScope = renderedRoot(timingContainer(scopeId, condition, children.map(({ xml }) => xml), promoteScopeToStep ? void 0 : pendingRootNodeType), "scope", promoteScopeToStep ? pendingRootNodeType !== void 0 && children.some(({ stepEntryRole }) => stepEntryRole) : pendingRootNodeType !== void 0, promoteScopeToStep);
1054
+ rendered.push(renderedScope);
1055
+ if (pendingRootNodeType !== void 0 && renderedScope.stepEntryRole) pendingRootNodeType = void 0;
1056
+ } else {
1057
+ const liftedRoots = renderNodes(node.children, effectiveStart, false, pendingRootNodeType, node.conditionDefinitionsBefore);
1058
+ rendered.push(...liftedRoots);
1059
+ if (pendingRootNodeType !== void 0 && liftedRoots.some(({ stepEntryRole }) => stepEntryRole)) pendingRootNodeType = void 0;
1060
+ }
1061
+ continue;
1062
+ }
1063
+ if (node.kind === "completion-collector") {
1064
+ const collectorId = scopeNodeIds.get(`${step.key}:end:${node.scopeId}`);
1065
+ if (collectorId === void 0) throw new Error("MotionPlan completion collection is missing native time node identity");
1066
+ const condition = nativeStartCondition(effectiveStart, step.key, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds);
1067
+ rendered.push(renderedRoot(endCollectorTree(collectorId, condition, node.gates, step.key, ids, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds), "completion-definition"));
1068
+ continue;
1069
+ }
1070
+ const condition = nativeStartCondition(effectiveStart, step.key, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds);
1071
+ const targetGroupKey = `${step.key}:${node.targetId}`;
1072
+ const effectStarts = node.effects.map((effect) => addNativeStartDelay(effectiveStart, childDelay(effect)));
1073
+ if (node.effects.length > 1 && (referencedTargetGroups.has(targetGroupKey) || effectStarts.some((start) => start === void 0))) {
1074
+ const groupId = targetGroupIds.get(targetGroupKey);
1075
+ if (groupId === void 0) throw new Error("MotionPlan object member is missing native aggregate node identity");
1076
+ const primaryChildren = [];
1077
+ const companionChildren = [];
1078
+ for (const [effectIndex, effect] of node.effects.entries()) {
1079
+ const effectId = effectNodeIds.get(effectKey(effect));
1080
+ if (effectId === void 0) throw new Error("MotionPlan effect is missing native time node identity");
1081
+ const buildGroupId = effect.target.range?.type === "chart" ? chartBuildGroupIds.get(effect.target.id) : void 0;
1082
+ const projection = renderedEffect(effect, effectIndex === 0 ? "afterEffect" : "withEffect", element("p:cond", { delay: childDelay(effect) }), effectId, buildGroupId);
1083
+ primaryChildren.push(...projection.primary);
1084
+ companionChildren.push(...projection.companions);
1085
+ }
1086
+ const children = [...primaryChildren, ...companionChildren];
1087
+ rendered.push(renderedRoot(timingContainer(groupId, condition, children, pendingRootNodeType), "target-group", pendingRootNodeType !== void 0 && children.length > 0));
1088
+ pendingRootNodeType = void 0;
1089
+ continue;
1090
+ }
1091
+ for (const [effectIndex, effect] of node.effects.entries()) {
1092
+ const effectId = effectNodeIds.get(effectKey(effect));
1093
+ if (effectId === void 0) throw new Error("MotionPlan effect is missing native time node identity");
1094
+ const localStart = effectStarts[effectIndex];
1095
+ if (localStart === void 0) throw new Error("Native timing projection lost encodable animation delay layering");
1096
+ let effectStart = localStart;
1097
+ const rootNodeType = effectIndex === 0 ? pendingRootNodeType ?? nodeType : "withEffect";
1098
+ let effectNodeType = rootNodeType;
1099
+ if (localStart.kind === "delay-layer") {
1100
+ const lastDelay = motionPlanStartLayers(localStart).delays.at(-1);
1101
+ if (lastDelay === void 0) throw new Error("MotionPlan effect delay layer is missing actual delay field");
1102
+ effectStart = {
1103
+ kind: "parent-start",
1104
+ delayMs: lastDelay
1105
+ };
1106
+ effectNodeType = effectIndex === 0 ? "afterEffect" : "withEffect";
1107
+ }
1108
+ const effectCondition = nativeStartCondition(effectStart, step.key, effectNodeIds, scopeNodeIds, targetGroupIds, conditionNodeIds);
1109
+ const buildGroupId = effect.target.range?.type === "chart" ? chartBuildGroupIds.get(effect.target.id) : void 0;
1110
+ const projection = renderedEffect(effect, effectNodeType, effectCondition, effectId, buildGroupId);
1111
+ if (localStart.kind === "delay-layer") rendered.push(...wrapDelayLayers(localStart, effectRoots([...projection.primary, ...projection.companions], false), rootNodeType));
1112
+ else {
1113
+ rendered.push(...effectRoots(projection.primary, effectIndex === 0 && pendingRootNodeType !== void 0));
1114
+ deferredCompanions.push(...effectRoots(projection.companions, false));
1115
+ }
1116
+ pendingRootNodeType = void 0;
1117
+ }
1118
+ }
1119
+ rendered.push(...deferredCompanions);
1120
+ return rendered;
1121
+ };
1122
+ const stepChildren = renderNodes(step.nodes, void 0, true, step.trigger === "click" ? "clickEffect" : "afterEffect", step.conditionDefinitionsBefore);
1123
+ const stepTimingGroups = [];
1124
+ if (stepChildren.some(({ kind, promoteToStep }) => kind === "scope" && promoteToStep)) {
1125
+ let groupChildren = [];
1126
+ const flushGroup = () => {
1127
+ if (groupChildren.length === 0) return;
1128
+ stepTimingGroups.push(mainSequenceWithGroup(ids.take(), groupChildren));
1129
+ groupChildren = [];
1130
+ };
1131
+ for (const root of stepChildren) if (root.kind === "scope" && root.promoteToStep) {
1132
+ flushGroup();
1133
+ stepTimingGroups.push(root.xml);
1134
+ } else groupChildren.push(root.xml);
1135
+ flushGroup();
1136
+ } else if (stepChildren.length > 0) stepTimingGroups.push(mainSequenceWithGroup(ids.take(), stepChildren.map(({ xml }) => xml)));
1137
+ return element("p:par", void 0, element("p:cTn", {
1138
+ id: stepId,
1139
+ fill: "hold"
1140
+ }, element("p:stCondLst", void 0, trigger), element("p:childTnLst", void 0, ...stepTimingGroups)));
1141
+ });
1142
+ const slideTarget = element("p:tgtEl", void 0, element("p:sldTgt", void 0));
1143
+ const paragraphBuilds = /* @__PURE__ */ new Map();
1144
+ const chartBuildTargets = /* @__PURE__ */ new Map();
1145
+ const wholeTextArrays = /* @__PURE__ */ new Map();
1146
+ const wholeTextEntranceTargets = /* @__PURE__ */ new Set();
1147
+ const wholeTextDeclarations = /* @__PURE__ */ new Map();
1148
+ for (const { effect, declaration } of nativeTextEffects) {
1149
+ if (!declaration.targetTextBody || declaration.target.id !== effect.target.id) continue;
1150
+ if (!isWholeTextProjection(declaration)) continue;
1151
+ if (declaration.kind === "entrance") wholeTextEntranceTargets.add(effect.target.id);
1152
+ const declarations = wholeTextDeclarations.get(effect.target.id) ?? /* @__PURE__ */ new Set();
1153
+ declarations.add(declaration.effectIndex);
1154
+ wholeTextDeclarations.set(effect.target.id, declarations);
1155
+ }
1156
+ for (const [targetId, declarations] of wholeTextDeclarations) if (declarations.size > 1) wholeTextArrays.set(targetId, declarations);
1157
+ for (const { effect, declaration } of nativeTextEffects) {
1158
+ const groupId = effect.buildGroupId ?? 0;
1159
+ const key = `${effect.target.id}:${groupId}`;
1160
+ const previous = paragraphBuilds.get(key);
1161
+ const isDeclaredTextEffect = declaration.targetTextBody && declaration.target.id === effect.target.id;
1162
+ const wholeShape = isWholeShapeTextEntrance(effect) && declaration.target.id === effect.target.id;
1163
+ const build = groupId === 1 ? wholeTextEntranceTargets.has(effect.target.id) || wholeTextArrays.has(effect.target.id) ? "p" : "allAtOnce" : isDeclaredTextEffect && (declaration.by === "paragraph" || declaration.target.range?.type === "paragraph") ? "p" : previous?.build;
1164
+ const animBg = previous?.animBg === true || groupId === 1 && hasWholeTextBackgroundBehaviors(effect) || wholeShape && effect.targetHasBackground;
1165
+ paragraphBuilds.set(key, {
1166
+ effect,
1167
+ groupId,
1168
+ ...build === void 0 ? {} : { build },
1169
+ ...effect.targetHasBackground ? { animBg } : {}
1170
+ });
1171
+ }
1172
+ for (const step of steps) for (const effect of step.effects) {
1173
+ const timed = effect;
1174
+ if (!timed.targetTextBody && timed.target.range?.type === "chart") chartBuildTargets.set(timed.target.id, timed);
1175
+ }
1176
+ const buildList = [...[...paragraphBuilds.values()].map(({ effect, groupId, build, animBg }) => element("p:bldP", {
1177
+ spid: effect.target.id,
1178
+ grpId: groupId,
1179
+ build,
1180
+ animBg
1181
+ })), ...[...chartBuildTargets.values()].map((effect) => {
1182
+ const build = nativeChartBuild(effect.by);
1183
+ return element("p:bldGraphic", {
1184
+ spid: effect.target.id,
1185
+ grpId: chartBuildGroupIds.get(effect.target.id)
1186
+ }, build === void 0 ? element("p:bldAsOne", void 0) : element("p:bldSub", void 0, element("a:bldChart", { bld: build })));
1187
+ })];
1188
+ return {
1189
+ xml: motionChoreographyMechanism.emit({
1190
+ rootId,
1191
+ sequenceId,
1192
+ slideTarget,
1193
+ stepGroups,
1194
+ buildList
1195
+ }, void 0).xml,
1196
+ nativeProjections
1197
+ };
1198
+ }
1199
+ function buildOwnerMotionSteps(ownerPath, rawMotion, rawPlaceholders) {
1200
+ const parsed = ownerMotionSchema.safeParse(rawMotion);
1201
+ if (!parsed.success) throw new CapabilityError("invalid-owner-motion", parsed.error.issues[0]?.message ?? `${ownerPath} motion declaration is invalid`, ownerPath);
1202
+ const placeholderEntries = typeof rawPlaceholders === "object" && rawPlaceholders !== null ? Object.entries(rawPlaceholders) : [];
1203
+ const placeholderByKey = /* @__PURE__ */ new Map();
1204
+ placeholderEntries.forEach(([key, spec], index) => {
1205
+ placeholderByKey.set(key, {
1206
+ spid: 2 + index,
1207
+ name: spec.name ?? key,
1208
+ spec
1209
+ });
1210
+ });
1211
+ let clickCounter = 0;
1212
+ return parsed.data.steps.map((step, stepIdx) => {
1213
+ const stepKey = step.trigger === "auto" ? "auto" : `click:${++clickCounter}`;
1214
+ const targetGroups = /* @__PURE__ */ new Map();
1215
+ step.effects.forEach((item, effectIdx) => {
1216
+ let spid;
1217
+ let targetName;
1218
+ let box;
1219
+ if ("placeholder" in item.target) {
1220
+ const entry = placeholderByKey.get(item.target.placeholder);
1221
+ if (entry === void 0) throw new CapabilityError("missing-motion-target", `${ownerPath} motion references unknown placeholder ${JSON.stringify(item.target.placeholder)}`, ownerPath);
1222
+ spid = entry.spid;
1223
+ targetName = entry.name;
1224
+ if (entry.spec.x !== void 0 && entry.spec.y !== void 0 && entry.spec.width !== void 0 && entry.spec.height !== void 0) box = {
1225
+ x: entry.spec.x,
1226
+ y: entry.spec.y,
1227
+ width: entry.spec.width,
1228
+ height: entry.spec.height
1229
+ };
1230
+ } else {
1231
+ spid = item.target.spid;
1232
+ targetName = `sp-${spid}`;
1233
+ }
1234
+ const rawEffect = item.effect.type === "repeated-effect" ? {
1235
+ ...item.effect.effect,
1236
+ repeatCount: item.effect.count
1237
+ } : item.effect;
1238
+ const delayMs = Math.round(rawEffect.delay);
1239
+ const durationMs = Math.round(rawEffect.duration);
1240
+ const repeatCount = rawEffect.repeatCount;
1241
+ const endMs = repeatCount === "forever" ? void 0 : delayMs + durationMs * (typeof repeatCount === "number" ? repeatCount : 1);
1242
+ const scheduledEffect = {
1243
+ target: {
1244
+ id: spid,
1245
+ name: targetName,
1246
+ ...item.range === void 0 ? {} : { range: item.range }
1247
+ },
1248
+ kind: rawEffect.kind,
1249
+ preset: rawEffect.preset,
1250
+ durationMs,
1251
+ delayMs,
1252
+ ...repeatCount === void 0 ? {} : { repeatCount },
1253
+ ...rawEffect.from === void 0 ? {} : { from: rawEffect.from },
1254
+ ...rawEffect.by === void 0 ? {} : { by: rawEffect.by },
1255
+ ...rawEffect.intervalMs === void 0 ? {} : { intervalMs: rawEffect.intervalMs },
1256
+ ...rawEffect.easing === void 0 ? {} : { easing: rawEffect.easing },
1257
+ ...rawEffect.fromColor === void 0 ? {} : { fromColor: rawEffect.fromColor },
1258
+ ...rawEffect.toColor === void 0 ? {} : { toColor: rawEffect.toColor },
1259
+ startMs: delayMs,
1260
+ ...endMs === void 0 ? { completion: "no-natural-completion" } : { endMs },
1261
+ stepKey,
1262
+ order: stepIdx * 1e3 + effectIdx,
1263
+ effectIndex: effectIdx,
1264
+ targetKind: "shape",
1265
+ targetTextBody: false,
1266
+ targetFilled: true,
1267
+ targetHasBackground: true,
1268
+ ...box === void 0 ? {} : { targetBox: box }
1269
+ };
1270
+ const existing = targetGroups.get(spid) ?? [];
1271
+ existing.push(scheduledEffect);
1272
+ targetGroups.set(spid, existing);
1273
+ });
1274
+ const effects = [...targetGroups.values()].flat();
1275
+ const nodes = [...targetGroups.entries()].map(([targetId, list]) => ({
1276
+ kind: "target",
1277
+ targetId,
1278
+ nativeStart: {
1279
+ kind: "parent-start",
1280
+ delayMs: 0
1281
+ },
1282
+ effects: list
1283
+ }));
1284
+ return {
1285
+ key: stepKey,
1286
+ order: stepIdx,
1287
+ trigger: step.trigger,
1288
+ nodes,
1289
+ effects
1290
+ };
1291
+ });
1292
+ }
1293
+ /** Slide-level motion module binds choreography, writes object timing, and leaves preview on the static edit canvas. */
1294
+ const motionCapability = Object.freeze({
1295
+ declaration: "motion",
1296
+ slideProp: "motion",
1297
+ slot: "timing",
1298
+ always: true,
1299
+ mechanisms: [
1300
+ motionFadeMechanism,
1301
+ motionWipeMechanism,
1302
+ motionZoomMechanism,
1303
+ motionFlyMechanism,
1304
+ motionFloatMechanism,
1305
+ motionSpinInMechanism,
1306
+ motionStretchMechanism,
1307
+ motionSpinMechanism,
1308
+ motionBreatheMechanism,
1309
+ motionFillColorMechanism,
1310
+ motionChoreographyMechanism
1311
+ ],
1312
+ codegen: motionCodegen,
1313
+ transparentDeclarations: [{
1314
+ declaration: "motion-scope",
1315
+ compileDeclaration(input) {
1316
+ return [motionScopeAnnotation(input.props)];
1317
+ }
1318
+ }, {
1319
+ declaration: "motion-step",
1320
+ compileDeclaration(input) {
1321
+ return motionStepAnnotation(input.props);
1322
+ }
1323
+ }],
1324
+ bindSlide(input, parseContext) {
1325
+ if (input.type === "slide-master" || input.type === "slide-layout") {
1326
+ const steps = buildOwnerMotionSteps(parseContext.path, input.props["motion"], input.props["placeholders"]);
1327
+ return { resolveSlide(_context) {
1328
+ if (!steps.some((step) => step.effects.length > 0)) return {
1329
+ extensions: [],
1330
+ emit() {
1331
+ return { xml: "" };
1332
+ }
1333
+ };
1334
+ return {
1335
+ extensions: [],
1336
+ observation: input.props["motion"],
1337
+ emit(emitContext) {
1338
+ return { xml: timingXml(steps, emitContext.dimensions).xml };
1339
+ }
1340
+ };
1341
+ } };
1342
+ }
1343
+ return { resolveSlide(context) {
1344
+ const plan = compileMotionPlan(context.contributions);
1345
+ validateKnownMotionTimes(plan.observation);
1346
+ if (!plan.steps.some((step) => step.effects.length > 0)) {
1347
+ registerMotionObservation(plan.observation, plan.query);
1348
+ return {
1349
+ extensions: [],
1350
+ ...plan.observation.scopes === void 0 ? {} : { observation: plan.observation },
1351
+ emit() {
1352
+ return { xml: "" };
1353
+ }
1354
+ };
1355
+ }
1356
+ const timing = timingXml(plan.steps, context.dimensions);
1357
+ const observation = {
1358
+ ...plan.observation,
1359
+ ...timing.nativeProjections.length === 0 ? {} : { nativeProjections: timing.nativeProjections }
1360
+ };
1361
+ registerMotionObservation(observation, plan.query);
1362
+ return {
1363
+ extensions: [],
1364
+ observation,
1365
+ emit(emitContext) {
1366
+ return { xml: timingXml(plan.steps, emitContext.dimensions).xml };
1367
+ }
1368
+ };
1369
+ } };
1370
+ }
1371
+ });
1372
+ export { after, breathe, createMotionScopeHandle, fade, fillColor, floatDown, floatUp, fly, motionBreatheMechanism, motionCapability, motionChoreographyMechanism, motionFadeMechanism, motionFillColorMechanism, motionFloatMechanism, motionFlyMechanism, motionSpinInMechanism, motionSpinMechanism, motionStretchMechanism, motionWipeMechanism, motionZoomMechanism, observeMotion, repeat, spin, spinIn, stretch, wipe, zoom };