@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,423 @@
1
+ import { BuildQueryError, resolveSlideFromLocator } from "../../../core/dist/query.js";
2
+ // ../capabilities/dist/motion/motion-query.js
3
+ const referenceOwners = /* @__PURE__ */ new WeakMap();
4
+ const queryByObservation = /* @__PURE__ */ new WeakMap();
5
+ function frozenRef(value, owner) {
6
+ const ref = Object.freeze(value);
7
+ referenceOwners.set(ref, owner);
8
+ return ref;
9
+ }
10
+ function freezeMoment(ref, time) {
11
+ return Object.freeze({
12
+ ...time,
13
+ ref
14
+ });
15
+ }
16
+ function projectEffectObservation(source) {
17
+ const target = Object.freeze({
18
+ id: source.target.id,
19
+ name: source.target.name,
20
+ ...source.target.authorId === void 0 ? {} : { authorId: source.target.authorId },
21
+ ...source.target.range === void 0 ? {} : { range: Object.freeze({ ...source.target.range }) }
22
+ });
23
+ return Object.freeze({
24
+ target,
25
+ kind: source.kind,
26
+ preset: source.preset,
27
+ durationMs: source.durationMs,
28
+ ...source.repeatCount === void 0 ? {} : { repeatCount: source.repeatCount },
29
+ delayMs: source.delayMs,
30
+ ...source.by === void 0 ? {} : { by: source.by },
31
+ ...source.intervalMs === void 0 ? {} : { intervalMs: source.intervalMs },
32
+ ...source.from === void 0 ? {} : { from: source.from },
33
+ ...source.to === void 0 ? {} : { to: source.to },
34
+ ...source.fromColor === void 0 ? {} : { fromColor: source.fromColor },
35
+ ...source.toColor === void 0 ? {} : { toColor: source.toColor },
36
+ ...source.easing === void 0 ? {} : { easing: Object.freeze({ ...source.easing }) },
37
+ ...source.startMs === void 0 ? {} : { startMs: source.startMs },
38
+ ...source.endMs === void 0 ? {} : { endMs: source.endMs },
39
+ ...source.completion === void 0 ? {} : { completion: source.completion },
40
+ ...source.startAfter === void 0 ? {} : { startAfter: Object.freeze({ ...source.startAfter }) },
41
+ ...source.startAfterAll === void 0 ? {} : { startAfterAll: Object.freeze(source.startAfterAll.map((dependency) => Object.freeze({ ...dependency }))) }
42
+ });
43
+ }
44
+ function assertOwnedReference(ref, queryIdentity, kind) {
45
+ const owner = referenceOwners.get(ref);
46
+ if (owner === void 0 || owner.kind !== kind) throw new BuildQueryError("invalid-reference", "Invalid motion query reference");
47
+ if (owner.query !== queryIdentity) throw new BuildQueryError("foreign-reference", "Motion query reference belongs to another build or slide");
48
+ return owner;
49
+ }
50
+ function unknownDecision(reason) {
51
+ return {
52
+ state: "unknown",
53
+ reason
54
+ };
55
+ }
56
+ function timeDifference(from, to, facts) {
57
+ if (from.time.state === "no-natural-completion" || to.time.state === "no-natural-completion") return { state: "no-natural-completion" };
58
+ if (from.eventId === void 0 || to.eventId === void 0) return {
59
+ state: "unknown",
60
+ reason: "insufficient-facts"
61
+ };
62
+ const exact = facts.exactOffset(from.eventId, to.eventId);
63
+ if (exact !== void 0) return {
64
+ state: "known",
65
+ ms: exact
66
+ };
67
+ const minimumMs = facts.lowerBound(from.eventId, to.eventId);
68
+ const reverseMinimum = facts.lowerBound(to.eventId, from.eventId);
69
+ const maximumMs = reverseMinimum === void 0 ? void 0 : -reverseMinimum;
70
+ return {
71
+ state: "unknown",
72
+ reason: "insufficient-facts",
73
+ ...minimumMs === void 0 ? {} : { minimumMs },
74
+ ...maximumMs === void 0 ? {} : { maximumMs }
75
+ };
76
+ }
77
+ function compareBefore(difference) {
78
+ if (difference.state === "known") return {
79
+ state: "known",
80
+ value: difference.ms > 0
81
+ };
82
+ if (difference.state === "no-natural-completion") return difference;
83
+ if (difference.minimumMs !== void 0 && difference.minimumMs > 0) return {
84
+ state: "known",
85
+ value: true
86
+ };
87
+ if (difference.maximumMs !== void 0 && difference.maximumMs <= 0) return {
88
+ state: "known",
89
+ value: false
90
+ };
91
+ return unknownDecision(difference.reason);
92
+ }
93
+ function combineOverlap(first, second) {
94
+ if (first.state === "known" && !first.value || second.state === "known" && !second.value) return {
95
+ state: "known",
96
+ value: false
97
+ };
98
+ if (first.state === "known" && first.value && second.state === "known" && second.value) return {
99
+ state: "known",
100
+ value: true
101
+ };
102
+ if (first.state === "unknown" && first.reason === "different-step" || second.state === "unknown" && second.reason === "different-step") return unknownDecision("different-step");
103
+ if (first.state === "no-natural-completion" || second.state === "no-natural-completion") return { state: "no-natural-completion" };
104
+ return unknownDecision("insufficient-facts");
105
+ }
106
+ function intervalMembership(ms, start, end) {
107
+ if (start.state === "known" && ms < start.ms) return {
108
+ state: "known",
109
+ value: false
110
+ };
111
+ if (end.state === "known" && ms >= end.ms) return {
112
+ state: "known",
113
+ value: false
114
+ };
115
+ if (start.state === "known" && end.state === "known") return {
116
+ state: "known",
117
+ value: start.ms <= ms && ms < end.ms
118
+ };
119
+ if (start.state === "known" && end.state === "no-natural-completion") return { state: "no-natural-completion" };
120
+ if (start.state === "no-natural-completion" || end.state === "no-natural-completion") return start.state === "known" ? { state: "no-natural-completion" } : unknownDecision("insufficient-facts");
121
+ return unknownDecision("insufficient-facts");
122
+ }
123
+ function createMotionQuery(sources) {
124
+ const queryIdentity = {};
125
+ const stepIdentities = /* @__PURE__ */ new Map();
126
+ for (const source of sources) stepIdentities.set(source.key, {});
127
+ const steps = sources.map((source) => {
128
+ const stepIdentity = stepIdentities.get(source.key);
129
+ if (stepIdentity === void 0) throw new Error("Missing motion step query reference");
130
+ const stepRef = frozenRef({}, {
131
+ query: queryIdentity,
132
+ step: stepIdentity,
133
+ kind: "step",
134
+ time: { state: "unknown" }
135
+ });
136
+ const scopesByIdentity = /* @__PURE__ */ new Map();
137
+ const effectsByTarget = /* @__PURE__ */ new Map();
138
+ const effectSourcesByRef = /* @__PURE__ */ new Map();
139
+ const momentOwners = /* @__PURE__ */ new Map();
140
+ for (const scope of source.scopes) {
141
+ const ref = frozenRef({ id: scope.id }, {
142
+ query: queryIdentity,
143
+ step: stepIdentity,
144
+ kind: "scope",
145
+ time: scope.start.time
146
+ });
147
+ scopesByIdentity.set(scope.identity, ref);
148
+ }
149
+ for (const effect of source.effects) {
150
+ const ref = frozenRef({
151
+ targetId: effect.targetId,
152
+ effectIndex: effect.effectIndex,
153
+ ...effect.partIndex === void 0 ? {} : { partIndex: effect.partIndex }
154
+ }, {
155
+ query: queryIdentity,
156
+ step: stepIdentity,
157
+ kind: "effect",
158
+ time: effect.start.time
159
+ });
160
+ const instances = effectsByTarget.get(effect.targetId) ?? [];
161
+ instances.push(ref);
162
+ effectsByTarget.set(effect.targetId, instances);
163
+ effectSourcesByRef.set(ref, effect);
164
+ }
165
+ const makeMoment = (kind, ownerRef, point, sourceMoment) => {
166
+ const ref = Object.freeze(kind === "effect" ? {
167
+ kind,
168
+ effect: ownerRef,
169
+ point
170
+ } : {
171
+ kind,
172
+ scope: ownerRef,
173
+ point
174
+ });
175
+ const owner = {
176
+ query: queryIdentity,
177
+ step: stepIdentity,
178
+ kind: "moment",
179
+ ...sourceMoment.eventId === void 0 ? {} : { eventId: sourceMoment.eventId },
180
+ time: sourceMoment.time
181
+ };
182
+ referenceOwners.set(ref, owner);
183
+ momentOwners.set(ref, owner);
184
+ return freezeMoment(ref, sourceMoment.time);
185
+ };
186
+ const effectObservations = source.effects.map((effect) => {
187
+ const ref = [...effectsByTarget.get(effect.targetId) ?? []].find((candidate) => candidate.effectIndex === effect.effectIndex && candidate.partIndex === effect.partIndex);
188
+ if (ref === void 0) throw new Error("Missing motion effect instance reference");
189
+ const start = makeMoment("effect", ref, "start", effect.start);
190
+ const end = makeMoment("effect", ref, "end", effect.end);
191
+ referenceOwners.set(ref, {
192
+ query: queryIdentity,
193
+ step: stepIdentity,
194
+ kind: "effect",
195
+ time: effect.start.time,
196
+ start: start.ref,
197
+ end: end.ref
198
+ });
199
+ const scopes = effect.scopeIdentities.flatMap((identity) => {
200
+ const scope = scopesByIdentity.get(identity);
201
+ return scope === void 0 ? [] : [scope];
202
+ });
203
+ const observation = projectEffectObservation(effect.observation);
204
+ return Object.freeze({
205
+ ...observation,
206
+ ref,
207
+ effectIndex: effect.effectIndex,
208
+ ...effect.partIndex === void 0 ? {} : { partIndex: effect.partIndex },
209
+ scopes: Object.freeze(scopes),
210
+ start,
211
+ end
212
+ });
213
+ });
214
+ const scopeObservations = source.scopes.map((scope) => {
215
+ const ref = scopesByIdentity.get(scope.identity);
216
+ if (ref === void 0) throw new Error("Missing MotionScope reference");
217
+ const start = makeMoment("scope", ref, "start", scope.start);
218
+ const end = makeMoment("scope", ref, "end", scope.end);
219
+ referenceOwners.set(ref, {
220
+ query: queryIdentity,
221
+ step: stepIdentity,
222
+ kind: "scope",
223
+ time: scope.start.time,
224
+ start: start.ref,
225
+ end: end.ref
226
+ });
227
+ const parent = scope.parentIdentity === void 0 ? void 0 : scopesByIdentity.get(scope.parentIdentity);
228
+ const members = scope.members.flatMap((member) => {
229
+ if (member.kind === "scope") {
230
+ const child = scopesByIdentity.get(member.identity);
231
+ return child === void 0 ? [] : [Object.freeze({
232
+ kind: "scope",
233
+ ref: child
234
+ })];
235
+ }
236
+ return (effectsByTarget.get(member.targetId) ?? []).map((effectRef) => ({
237
+ kind: "effect",
238
+ ref: effectRef
239
+ })).map((effect) => Object.freeze(effect));
240
+ });
241
+ return Object.freeze({
242
+ ref,
243
+ step: stepRef,
244
+ ...parent === void 0 ? {} : { parent },
245
+ mode: scope.mode,
246
+ ...scope.eachMs === void 0 ? {} : { eachMs: scope.eachMs },
247
+ delayMs: scope.delayMs,
248
+ members: Object.freeze(members),
249
+ start,
250
+ end
251
+ });
252
+ });
253
+ const cuesByKey = /* @__PURE__ */ new Map();
254
+ const cues = source.cues.flatMap((cue) => {
255
+ const scope = scopesByIdentity.get(cue.scopeIdentity);
256
+ if (scope === void 0) return [];
257
+ const at = scopeObservations.find(({ ref }) => ref === scope)?.[cue.point].ref;
258
+ if (at === void 0) return [];
259
+ const ref = frozenRef({
260
+ name: cue.name,
261
+ scopeId: scope.id,
262
+ point: cue.point
263
+ }, {
264
+ query: queryIdentity,
265
+ step: stepIdentity,
266
+ kind: "cue",
267
+ time: { state: "unknown" }
268
+ });
269
+ const observation = Object.freeze({
270
+ ref,
271
+ name: cue.name,
272
+ publishedBy: scope,
273
+ point: cue.point,
274
+ at
275
+ });
276
+ cuesByKey.set(cue.key, observation);
277
+ return [observation];
278
+ });
279
+ const dependencies = [];
280
+ for (const scope of source.scopes) {
281
+ const consumer = scopesByIdentity.get(scope.identity);
282
+ if (consumer === void 0 || scope.declaration.startAt === void 0) continue;
283
+ const { moment, offsetMs } = timingParts(scope.declaration.startAt);
284
+ if (moment.point === "named") {
285
+ const cue = cuesByKey.get(momentKey(moment));
286
+ if (cue !== void 0) dependencies.push({
287
+ kind: "cue-use",
288
+ scope: consumer,
289
+ cue: cue.ref,
290
+ offsetMs
291
+ });
292
+ } else {
293
+ const sourceScope = scopesByIdentity.get(moment.scope);
294
+ const sourceMoment = scopeObservations.find(({ ref }) => ref === sourceScope)?.[moment.point].ref;
295
+ if (sourceMoment !== void 0) dependencies.push({
296
+ kind: "scope-start",
297
+ scope: consumer,
298
+ source: sourceMoment,
299
+ offsetMs
300
+ });
301
+ }
302
+ }
303
+ for (const cue of cues) dependencies.push({
304
+ kind: "cue-publish",
305
+ cue: cue.ref,
306
+ scope: cue.publishedBy,
307
+ point: cue.point
308
+ });
309
+ for (const effect of effectObservations) {
310
+ const ref = effect.ref;
311
+ const scheduled = effectSourcesByRef.get(ref);
312
+ if (scheduled?.observation.startAfter !== void 0) dependencies.push({
313
+ kind: "start-after",
314
+ effect: ref,
315
+ source: Object.freeze({ ...scheduled.observation.startAfter })
316
+ });
317
+ for (const source of scheduled?.observation.startAfterAll ?? []) dependencies.push({
318
+ kind: "start-after",
319
+ effect: ref,
320
+ source: Object.freeze({ ...source })
321
+ });
322
+ }
323
+ const momentOwner = (ref) => momentOwners.get(ref) ?? assertOwnedReference(ref, queryIdentity, "moment");
324
+ const difference = (from, to) => {
325
+ const first = momentOwner(from);
326
+ const second = momentOwner(to);
327
+ if (first.step !== stepIdentity || second.step !== stepIdentity) return {
328
+ state: "unknown",
329
+ reason: "different-step"
330
+ };
331
+ return timeDifference(first, second, source.facts);
332
+ };
333
+ const queryStep = {
334
+ ref: stepRef,
335
+ trigger: source.trigger,
336
+ ...source.number === void 0 ? {} : { number: source.number },
337
+ effects: Object.freeze(effectObservations),
338
+ scopes: Object.freeze(scopeObservations),
339
+ dependencies: Object.freeze(dependencies.map((item) => Object.freeze(item))),
340
+ cues: Object.freeze(cues),
341
+ difference,
342
+ before(from, to) {
343
+ return compareBefore(difference(from, to));
344
+ },
345
+ overlap(a, b) {
346
+ const first = assertInterval(a, queryIdentity);
347
+ const second = assertInterval(b, queryIdentity);
348
+ if (first.step !== stepIdentity || second.step !== stepIdentity) return unknownDecision("different-step");
349
+ const firstStart = first.start === void 0 ? void 0 : momentOwner(first.start);
350
+ const firstEnd = first.end === void 0 ? void 0 : momentOwner(first.end);
351
+ const secondStart = second.start === void 0 ? void 0 : momentOwner(second.start);
352
+ const secondEnd = second.end === void 0 ? void 0 : momentOwner(second.end);
353
+ if (firstStart === void 0 || firstEnd === void 0 || secondStart === void 0 || secondEnd === void 0) return { state: "no-natural-completion" };
354
+ const isEmpty = (start, end) => {
355
+ const duration = timeDifference(start, end, source.facts);
356
+ return duration.state === "known" && duration.ms === 0;
357
+ };
358
+ if (isEmpty(firstStart, firstEnd) || isEmpty(secondStart, secondEnd)) return {
359
+ state: "known",
360
+ value: false
361
+ };
362
+ return combineOverlap(compareBefore(timeDifference(firstStart, secondEnd, source.facts)), compareBefore(timeDifference(secondStart, firstEnd, source.facts)));
363
+ },
364
+ intervalsCovering(ms, selected) {
365
+ if (!Number.isFinite(ms) || ms < 0) throw new BuildQueryError("invalid-query", "Local time must be non-negative finite milliseconds");
366
+ const items = (selected ?? effectObservations.map(({ ref }) => ref)).map((effectRef) => {
367
+ if (assertOwnedReference(effectRef, queryIdentity, "effect").step !== stepIdentity) return Object.freeze({
368
+ effect: effectRef,
369
+ result: unknownDecision("different-step")
370
+ });
371
+ const effect = effectSourcesByRef.get(effectRef);
372
+ if (effect === void 0) throw new Error("Missing motion query effect source");
373
+ return Object.freeze({
374
+ effect: effectRef,
375
+ result: intervalMembership(ms, effect.start.time, effect.end.time)
376
+ });
377
+ });
378
+ return Object.freeze({
379
+ complete: items.every(({ result }) => result.state === "known"),
380
+ items: Object.freeze(items)
381
+ });
382
+ }
383
+ };
384
+ return Object.freeze(queryStep);
385
+ });
386
+ return Object.freeze({
387
+ evidence: "generation",
388
+ steps: Object.freeze(steps)
389
+ });
390
+ }
391
+ function assertInterval(ref, queryIdentity) {
392
+ const owner = referenceOwners.get(ref);
393
+ if (owner === void 0 || owner.kind !== "effect" && owner.kind !== "scope") throw new BuildQueryError("invalid-reference", "Invalid motion interval reference");
394
+ if (owner.query !== queryIdentity) throw new BuildQueryError("foreign-reference", "Motion query reference belongs to another build or slide");
395
+ return owner;
396
+ }
397
+ function registerMotionObservation(observation, query) {
398
+ queryByObservation.set(observation, query);
399
+ }
400
+ /** Accepts only resolved slides or slide locators directly emitted by the current build; reread files will not masquerade as build results. */
401
+ function motionSchedule(slide) {
402
+ const resolvedSlide = resolveSlideFromLocator(slide);
403
+ if (resolvedSlide === void 0) throw new BuildQueryError("unbound-observation", "The motion slide observation does not belong to the current successful build");
404
+ const capability = resolvedSlide.capabilities?.["motion"];
405
+ if (capability === void 0) return void 0;
406
+ if (typeof capability !== "object" || capability === null) throw new BuildQueryError("unbound-observation", "The motion slide observation does not belong to the current successful build");
407
+ const query = queryByObservation.get(capability);
408
+ if (query === void 0) throw new BuildQueryError("unbound-observation", "The motion slide observation does not belong to the current successful build");
409
+ return query;
410
+ }
411
+ function timingParts(timing) {
412
+ return timing.type === "motion-offset" ? {
413
+ moment: timing.moment,
414
+ offsetMs: timing.offsetMs
415
+ } : {
416
+ moment: timing,
417
+ offsetMs: 0
418
+ };
419
+ }
420
+ function momentKey(moment) {
421
+ return `${moment.scope}\u0000${moment.name ?? ""}`;
422
+ }
423
+ export { createMotionQuery, motionSchedule, registerMotionObservation };