@vivix-labs/media-tools 0.0.0-stage → 1.0.0-beta.2

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 (76) hide show
  1. package/README.md +132 -2
  2. package/dist/Inter-LICENSE.txt +93 -0
  3. package/dist/UI-LICENSE.txt +21 -0
  4. package/dist/assets/35a50-G5EJUNOC.svg +6 -0
  5. package/dist/assets/369ca-BISNKZ3M.svg +6 -0
  6. package/dist/assets/441bc-BCMNQ72W.svg +6 -0
  7. package/dist/assets/483f0-T6ZAGTDG.svg +6 -0
  8. package/dist/assets/6911b-ESLYKSC6.svg +6 -0
  9. package/dist/assets/Inter-LICENSE.txt +93 -0
  10. package/dist/assets/UI-system-LICENSE.txt +21 -0
  11. package/dist/assets/add-JY533O73.svg +5 -0
  12. package/dist/assets/area-P2WOMBT5.svg +9 -0
  13. package/dist/assets/b70bb-BTTOKPOH.svg +6 -0
  14. package/dist/assets/b9919-3S3O6YOT.svg +6 -0
  15. package/dist/assets/calendar-JI6USFRJ.svg +1 -0
  16. package/dist/assets/check-JSRRIXN5.svg +5 -0
  17. package/dist/assets/check-on-content-FQUVG3IZ.svg +5 -0
  18. package/dist/assets/chevron-down-K7YKS2EY.svg +5 -0
  19. package/dist/assets/chevron-left-JQCLK2WZ.svg +3 -0
  20. package/dist/assets/chevron-right-TNE35DBJ.svg +3 -0
  21. package/dist/assets/chevron-up-VBHYAJVB.svg +5 -0
  22. package/dist/assets/clear-XNEZJKFC.svg +5 -0
  23. package/dist/assets/close-GO5F7YFS.svg +10 -0
  24. package/dist/assets/dccd4-CZJXWICW.svg +6 -0
  25. package/dist/assets/dd163-3S3O6YOT.svg +6 -0
  26. package/dist/assets/detail-E52XPONK.svg +4 -0
  27. package/dist/assets/draw-FOFX5TOM.svg +6 -0
  28. package/dist/assets/e8aed-CZJXWICW.svg +6 -0
  29. package/dist/assets/ea990-CZJXWICW.svg +6 -0
  30. package/dist/assets/edit-JUVJDD5A.svg +6 -0
  31. package/dist/assets/expand-IAV75AFA.svg +6 -0
  32. package/dist/assets/export-W2OBXZDQ.svg +6 -0
  33. package/dist/assets/fullscreen-L2JCXIN2.svg +6 -0
  34. package/dist/assets/fullscreen-large-MPLIWDMI.svg +6 -0
  35. package/dist/assets/grid-TLG5JYWB.svg +8 -0
  36. package/dist/assets/import-AFBUV2VV.svg +4 -0
  37. package/dist/assets/inter-latin-400-normal-55WT6UWF.woff2 +0 -0
  38. package/dist/assets/inter-latin-500-normal-W62DVTXI.woff2 +0 -0
  39. package/dist/assets/inter-latin-600-normal-R6Y2SZCR.woff2 +0 -0
  40. package/dist/assets/inter-latin-700-normal-SU5XVJMF.woff2 +0 -0
  41. package/dist/assets/list-5VUAOZUH.svg +9 -0
  42. package/dist/assets/magic-OMME7FOV.svg +9 -0
  43. package/dist/assets/more-AEJ5MHWV.svg +5 -0
  44. package/dist/assets/mute-SXOSCR2U.svg +6 -0
  45. package/dist/assets/mute-large-LSZZ44HF.svg +6 -0
  46. package/dist/assets/pause-2E4UY4FW.svg +6 -0
  47. package/dist/assets/pause-large-XEUBL4KC.svg +6 -0
  48. package/dist/assets/placeholder-audio-EJEBE7OB.svg +11 -0
  49. package/dist/assets/placeholder-image-NOVXFVRL.svg +10 -0
  50. package/dist/assets/placeholder-script-LR2GKWKS.svg +7 -0
  51. package/dist/assets/placeholder-video-ZFOYHYCR.svg +7 -0
  52. package/dist/assets/play-WIIT3XQK.svg +5 -0
  53. package/dist/assets/play-cover-WQLOHHPZ.svg +5 -0
  54. package/dist/assets/playback-play-YRMIX5W4.svg +5 -0
  55. package/dist/assets/playback-play-large-TM3QUJGG.svg +5 -0
  56. package/dist/assets/player-cover-shade-LLH6KOCQ.png +0 -0
  57. package/dist/assets/reset-JESMTEMV.svg +6 -0
  58. package/dist/assets/search-JUOSGQRM.svg +6 -0
  59. package/dist/assets/select-VU7WR7B4.svg +7 -0
  60. package/dist/assets/sound-file-YYY6VNYN.svg +3 -0
  61. package/dist/assets/volume-2TYGJL6F.svg +6 -0
  62. package/dist/assets/volume-large-QNULSJ2I.svg +6 -0
  63. package/dist/client.bundle.js +1872 -0
  64. package/dist/client.css +2575 -0
  65. package/dist/client.d.ts +19 -0
  66. package/dist/client.js +3 -0
  67. package/dist/server.d.ts +11 -0
  68. package/dist/server.js +1763 -0
  69. package/dist/shared.d.ts +667 -0
  70. package/dist/shared.js +217 -0
  71. package/dist/worker.d.ts +2 -0
  72. package/dist/worker.js +189 -0
  73. package/package.json +42 -3
  74. package/skills/SKILL.md +49 -0
  75. package/skills/references/processing.md +32 -0
  76. package/studio-plugin.json +11 -0
@@ -0,0 +1,1872 @@
1
+ // packages/media-tools/src/client.tsx
2
+ import * as React7 from "react";
3
+
4
+ // packages/media-tools/src/shared.ts
5
+ import { z, PluginError } from "vivix-studio/sdk/shared";
6
+ var Config = z.object({
7
+ dataInstance: z.string().min(1).default("user:data"),
8
+ studioInstance: z.string().min(1).default("studio"),
9
+ executionNamespace: z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/).default("media"),
10
+ ffmpegPath: z.string().min(1).default("ffmpeg"),
11
+ ffprobePath: z.string().min(1).default("ffprobe")
12
+ }).strict();
13
+ var versionRef = z.object({ storeId: z.uuid(), objectId: z.uuid(), versionId: z.uuid() }).strict();
14
+ var videoFileRef = z.object({ source: versionRef, fileId: z.uuid() }).strict();
15
+ var sourceInput = z.object({ kind: z.literal("source"), file: videoFileRef }).strict();
16
+ var editInput = z.object({ kind: z.literal("edit"), editRef: versionRef }).strict();
17
+ var videoInput = z.discriminatedUnion("kind", [sourceInput, editInput]);
18
+ var sequenceVideoInput = z.discriminatedUnion("kind", [
19
+ sourceInput.extend({ trimEndMs: z.number().int().positive().optional() }),
20
+ editInput
21
+ ]);
22
+ var recipe = z.object({
23
+ trim: z.object({ inMs: z.number().int().nonnegative(), outMs: z.number().int().positive() }).strict(),
24
+ crop: z.object({
25
+ x: z.number().finite().nonnegative(),
26
+ y: z.number().finite().nonnegative(),
27
+ width: z.number().finite().positive().max(1),
28
+ height: z.number().finite().positive().max(1)
29
+ }).strict()
30
+ }).strict().superRefine((v, c) => {
31
+ if (v.trim.inMs >= v.trim.outMs)
32
+ c.addIssue({ code: "custom", message: "The selected interval must have positive duration." });
33
+ if (v.crop.x + v.crop.width > 1 + 1e-9 || v.crop.y + v.crop.height > 1 + 1e-9)
34
+ c.addIssue({ code: "custom", message: "The crop must remain inside the source picture." });
35
+ });
36
+ var pixelRect = z.object({
37
+ x: z.number().int().nonnegative(),
38
+ y: z.number().int().nonnegative(),
39
+ width: z.number().int().positive(),
40
+ height: z.number().int().positive()
41
+ }).strict();
42
+ var geometry = z.object({
43
+ displayWidth: z.number().int().positive(),
44
+ displayHeight: z.number().int().positive(),
45
+ pixelRect
46
+ }).strict();
47
+ var metadata = z.object({
48
+ durationMs: z.number().int().positive(),
49
+ width: z.number().int().positive(),
50
+ height: z.number().int().positive(),
51
+ displayWidth: z.number().int().positive(),
52
+ displayHeight: z.number().int().positive(),
53
+ rotation: z.union([z.literal(0), z.literal(90), z.literal(180), z.literal(270)]),
54
+ frameRate: z.number().positive().max(60),
55
+ startTime: z.number().finite(),
56
+ hasAudio: z.boolean(),
57
+ audioSampleRate: z.number().int().nullable(),
58
+ audioChannels: z.number().int().nullable(),
59
+ audioStartTime: z.number().finite().nullable(),
60
+ sizeBytes: z.number().int().nonnegative(),
61
+ sha256: z.string().regex(/^[a-f0-9]{64}$/),
62
+ colorInterpretation: z.enum(["declared-bt709", "assumed-bt709"]).optional()
63
+ }).strict();
64
+ var editDescriptor = z.object({ format: z.literal(1), file: videoFileRef, recipe, geometry, metadata }).strict();
65
+ var saveEdit = z.object({
66
+ file: videoFileRef,
67
+ recipe,
68
+ editId: z.uuid().optional(),
69
+ expectedRevision: z.number().int().positive().optional()
70
+ }).strict().superRefine((v, c) => {
71
+ if (Boolean(v.editId) !== Boolean(v.expectedRevision))
72
+ c.addIssue({ code: "custom", message: "An edit update requires its revision." });
73
+ });
74
+ var outputName = z.string().trim().min(1).max(200);
75
+ var processVideo = z.object({ input: videoInput, outputName, retryOfJobId: z.uuid().optional() }).strict();
76
+ var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.number().int().min(2).max(3840) }).strict().refine(
77
+ (v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
78
+ "Canvas dimensions must be even and within 3840 by 2160."
79
+ );
80
+ var processSequence = z.object({
81
+ inputs: z.array(sequenceVideoInput).min(1).max(64),
82
+ outputName,
83
+ canvas,
84
+ retryOfJobId: z.uuid().optional()
85
+ }).strict();
86
+ var mediaRequest = z.discriminatedUnion("operation", [
87
+ z.object({ operation: z.literal("video.process"), input: processVideo }).strict(),
88
+ z.object({ operation: z.literal("sequence.process"), input: processSequence }).strict()
89
+ ]);
90
+ var jobsQuery = z.object({
91
+ limit: z.number().int().min(1).max(100).default(50),
92
+ offset: z.number().int().nonnegative().default(0),
93
+ request: z.object({
94
+ operation: z.enum(["video.process", "sequence.process"]),
95
+ requestKey: z.string().min(1).max(128),
96
+ intent: z.union([processVideo, processSequence])
97
+ }).strict().optional()
98
+ }).strict();
99
+ function mediaError(code, message) {
100
+ throw new PluginError(
101
+ code,
102
+ message,
103
+ "Review the fixed source, edit and current project, then retry explicitly."
104
+ );
105
+ }
106
+ function normalizeRecipe(raw, displayWidth, displayHeight, durationMs) {
107
+ const value = recipe.parse(raw);
108
+ if (![displayWidth, displayHeight, durationMs].every(Number.isSafeInteger) || displayWidth < 2 || displayHeight < 2 || durationMs < 1 || displayWidth % 2 !== 0 || displayHeight % 2 !== 0)
109
+ mediaError("UNSUPPORTED_GEOMETRY", "The source needs positive even display dimensions.");
110
+ if (value.trim.outMs > durationMs)
111
+ mediaError("INVALID_RECIPE", "The trim exceeds the fixed source duration.");
112
+ const edge = (fraction2, size) => Math.round(fraction2 * size / 2) * 2;
113
+ const x = edge(value.crop.x, displayWidth);
114
+ const y = edge(value.crop.y, displayHeight);
115
+ const right = Math.min(displayWidth, edge(value.crop.x + value.crop.width, displayWidth));
116
+ const bottom = Math.min(displayHeight, edge(value.crop.y + value.crop.height, displayHeight));
117
+ if (right - x < 2 || bottom - y < 2)
118
+ mediaError("INVALID_RECIPE", "The crop must contain at least two pixels in each dimension.");
119
+ const pixelRect2 = { x, y, width: right - x, height: bottom - y };
120
+ return {
121
+ recipe: {
122
+ trim: { ...value.trim },
123
+ crop: {
124
+ x: x / displayWidth,
125
+ y: y / displayHeight,
126
+ width: pixelRect2.width / displayWidth,
127
+ height: pixelRect2.height / displayHeight
128
+ }
129
+ },
130
+ geometry: { displayWidth, displayHeight, pixelRect: pixelRect2 }
131
+ };
132
+ }
133
+
134
+ // packages/media-tools/src/ui/context.tsx
135
+ import * as React from "react";
136
+ var MediaContext = React.createContext(null);
137
+ function useMediaClient() {
138
+ const value = React.useContext(MediaContext);
139
+ if (!value) throw Error("Resolve this component from an activated media-tools instance.");
140
+ return value;
141
+ }
142
+ function readableError(error) {
143
+ return error instanceof Error ? error.message : "The media operation could not be completed.";
144
+ }
145
+ function requestRejected(error) {
146
+ return Boolean(
147
+ error && typeof error === "object" && "code" in error && ["MEDIA_BUSY", "MEDIA_QUEUE_FULL", "PROJECT_ARCHIVED"].includes(String(error.code))
148
+ );
149
+ }
150
+ async function submitOrFind(client, instanceId, request, requestKey) {
151
+ try {
152
+ return await client.invoke(
153
+ { instanceId, operationId: request.operation },
154
+ request.input,
155
+ { requestKey }
156
+ );
157
+ } catch (error) {
158
+ const code = error && typeof error === "object" && "code" in error ? error.code : void 0;
159
+ if (code !== void 0 && !["EXECUTION_UNKNOWN", "OPERATION_CONTRACT_CHANGED", "TRANSPORT_UNKNOWN"].includes(
160
+ String(code)
161
+ ))
162
+ throw error;
163
+ const result = await client.invoke(
164
+ { instanceId, operationId: "jobs.list" },
165
+ { request: { operation: request.operation, requestKey, intent: request.input } }
166
+ );
167
+ const accepted = result.items[0];
168
+ if (!accepted) throw Error("No accepted task was found. Keep the original request identity.");
169
+ return { jobId: accepted.jobId, state: accepted.state };
170
+ }
171
+ }
172
+
173
+ // packages/media-tools/src/ui/editor.tsx
174
+ import * as React4 from "react";
175
+
176
+ // packages/ui-system/dist/button.js
177
+ import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
178
+
179
+ // packages/ui-system/dist/icon.js
180
+ import { jsx as _jsx } from "react/jsx-runtime";
181
+ var iconGeometry = {
182
+ add: {
183
+ width: 16,
184
+ height: 16,
185
+ slot: 16
186
+ },
187
+ check: {
188
+ width: 12,
189
+ height: 12,
190
+ slot: 12
191
+ },
192
+ "check-on-content": {
193
+ width: 12,
194
+ height: 12,
195
+ slot: 12
196
+ },
197
+ "chevron-up": {
198
+ width: 12,
199
+ height: 12,
200
+ slot: 12
201
+ },
202
+ expand: {
203
+ width: 16,
204
+ height: 16,
205
+ slot: 16
206
+ },
207
+ "chevron-down": {
208
+ width: 12,
209
+ height: 12,
210
+ slot: 12
211
+ },
212
+ clear: {
213
+ width: 14.5332,
214
+ height: 14.5332,
215
+ slot: 16
216
+ },
217
+ grid: {
218
+ width: 13.2039,
219
+ height: 13.2,
220
+ slot: 16
221
+ },
222
+ list: {
223
+ width: 13.3372,
224
+ height: 12.0039,
225
+ slot: 16
226
+ },
227
+ search: {
228
+ width: 13.2,
229
+ height: 13.2,
230
+ slot: 16
231
+ },
232
+ calendar: {
233
+ width: 16,
234
+ height: 16,
235
+ slot: 16
236
+ },
237
+ import: {
238
+ width: 16,
239
+ height: 16,
240
+ slot: 16
241
+ },
242
+ magic: {
243
+ width: 14.0625,
244
+ height: 15.5625,
245
+ slot: 18
246
+ },
247
+ select: {
248
+ width: 14.6298,
249
+ height: 16.065,
250
+ slot: 18
251
+ },
252
+ area: {
253
+ width: 16.125,
254
+ height: 16.125,
255
+ slot: 18
256
+ },
257
+ draw: {
258
+ width: 16.125,
259
+ height: 16.125,
260
+ slot: 18
261
+ },
262
+ close: {
263
+ width: 18,
264
+ height: 18,
265
+ slot: 18
266
+ },
267
+ reset: {
268
+ width: 16.35,
269
+ height: 16.35,
270
+ slot: 18
271
+ },
272
+ more: {
273
+ width: 16,
274
+ height: 16,
275
+ slot: 16
276
+ },
277
+ play: {
278
+ width: 12.381,
279
+ height: 13.2143,
280
+ slot: 20
281
+ },
282
+ pause: {
283
+ width: 14.1905,
284
+ height: 14.1905,
285
+ slot: 20
286
+ },
287
+ mute: {
288
+ width: 17.5239,
289
+ height: 14.1922,
290
+ slot: 20
291
+ },
292
+ volume: {
293
+ width: 17.5239,
294
+ height: 14.1922,
295
+ slot: 20
296
+ },
297
+ fullscreen: {
298
+ width: 20,
299
+ height: 20,
300
+ slot: 20
301
+ },
302
+ "placeholder-image": {
303
+ width: 20,
304
+ height: 20,
305
+ slot: 20
306
+ },
307
+ "placeholder-video": {
308
+ width: 17.9199,
309
+ height: 16.2506,
310
+ slot: 20
311
+ },
312
+ "placeholder-audio": {
313
+ width: 17.5017,
314
+ height: 17.4992,
315
+ slot: 20
316
+ },
317
+ "placeholder-script": {
318
+ width: 17.0834,
319
+ height: 17.0837,
320
+ slot: 20
321
+ },
322
+ export: {
323
+ width: 11.8667,
324
+ height: 13.2,
325
+ slot: 16
326
+ },
327
+ edit: {
328
+ width: 10.8791,
329
+ height: 12.0459,
330
+ slot: 14
331
+ },
332
+ "play-cover": {
333
+ width: 12.9167,
334
+ height: 13.7501,
335
+ slot: 20
336
+ },
337
+ "playback-play": {
338
+ width: 13.29564,
339
+ height: 14.1905,
340
+ slot: 20
341
+ },
342
+ "playback-play-large": {
343
+ width: 15.95477,
344
+ height: 17.0286,
345
+ slot: 24
346
+ },
347
+ "pause-large": {
348
+ width: 17.0286,
349
+ height: 17.0286,
350
+ slot: 24
351
+ },
352
+ "volume-large": {
353
+ width: 21.02868,
354
+ height: 17.03064,
355
+ slot: 24
356
+ },
357
+ "mute-large": {
358
+ width: 21.0286,
359
+ height: 17.0307,
360
+ slot: 24
361
+ },
362
+ "fullscreen-large": {
363
+ width: 24,
364
+ height: 24,
365
+ slot: 24
366
+ }
367
+ };
368
+ function Icon({ name, size }) {
369
+ const geometry2 = iconGeometry[name];
370
+ const style = {
371
+ ...geometry2 && {
372
+ "--vx-icon-native-size": `${geometry2.slot}px`,
373
+ "--vx-icon-width": `${geometry2.width / geometry2.slot * 100}%`,
374
+ "--vx-icon-height": `${geometry2.height / geometry2.slot * 100}%`
375
+ },
376
+ ...size === void 0 ? {} : { "--vx-icon-size": `${size}px` }
377
+ };
378
+ return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style });
379
+ }
380
+
381
+ // packages/ui-system/dist/button-variants.js
382
+ var buttonVariants = {
383
+ "text-filled-sm": { size: 32, appearance: "filled", shape: "text", width: 215 },
384
+ "text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
385
+ "text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
386
+ "text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
387
+ "text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
388
+ // The medium recipes are shared by all dialog footer actions.
389
+ "text-filled-md": { size: 40, appearance: "filled", shape: "text" },
390
+ "text-tonal-md": { size: 40, appearance: "tonal", shape: "text" },
391
+ "text-ghost-md": { size: 40, appearance: "ghost", shape: "text" },
392
+ "icon-ghost-md": { size: 40, appearance: "ghost", shape: "icon" },
393
+ "text-filled-lg": { size: 44, appearance: "filled", shape: "text", width: 412 },
394
+ "text-tonal-lg": { size: 44, appearance: "tonal", shape: "text", width: 412 },
395
+ "text-outline-lg": {
396
+ size: 44,
397
+ appearance: "outline",
398
+ shape: "text",
399
+ width: 412
400
+ },
401
+ "pill-filled": { size: 44, appearance: "filled", shape: "pill" },
402
+ "pill-plain": { size: 48, appearance: "plain", shape: "pill" },
403
+ "pill-small": { size: 32, appearance: "plain", shape: "pill" },
404
+ "icon-outline-sm": { size: 32, appearance: "outline", shape: "icon" },
405
+ "icon-on-content": { size: 24, appearance: "on-content", shape: "icon" },
406
+ "icon-outline-lg": { size: 48, appearance: "outline", shape: "icon" },
407
+ // Compact bare action: reuse the transparent/default and surface-hover ghost treatment.
408
+ "icon-bare-xs": { size: 24, appearance: "ghost", shape: "icon" },
409
+ "icon-ghost-sm": { size: 32, appearance: "ghost", shape: "icon" },
410
+ "icon-ghost-lg": { size: 48, appearance: "ghost", shape: "icon" },
411
+ "icon-circle-sm": { size: 32, appearance: "filled", shape: "circle" },
412
+ "icon-circle-lg": { size: 44, appearance: "filled", shape: "circle" }
413
+ };
414
+
415
+ // packages/ui-system/dist/button.js
416
+ function ButtonFrame({ label, variant, loading = false, width, children, disabled, type = "button", style, className, ...props }) {
417
+ const spec = buttonVariants[variant];
418
+ const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
419
+ return _jsxs("button", { ...props, type, className: className ? `vx-button ${className}` : "vx-button", "data-variant": variant, "data-appearance": spec.appearance, "data-shape": spec.shape, "data-size": spec.size, "data-width": width, "data-state": loading ? "loading" : disabled ? "disabled" : "default", style: buttonStyle, disabled: disabled || loading, "aria-label": label, "aria-busy": loading || void 0, children: [_jsx2("span", { className: "vx-button-content", children }), loading && _jsx2("span", { className: "vx-button-loading", "aria-hidden": "true" })] });
420
+ }
421
+ function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
422
+ return _jsxs(ButtonFrame, { ...props, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
423
+ }
424
+ function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
425
+ return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
426
+ }
427
+
428
+ // packages/ui-system/dist/segmented-control.js
429
+ import { jsx as _jsx3, jsxs as _jsxs2 } from "react/jsx-runtime";
430
+ import { useId } from "react";
431
+ function SegmentedControl({ label, items, value, onValueChange, size = "medium", width = "fixed", iconOnly = false }) {
432
+ const id = useId();
433
+ return _jsx3("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs2("label", { children: [_jsx3("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs2("span", { className: "vx-segment-item", children: [item.icon && _jsx3(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
434
+ }
435
+
436
+ // packages/ui-system/dist/tag.js
437
+ import { jsx as _jsx4 } from "react/jsx-runtime";
438
+ function Tag({ children, variant = "overlay", className }) {
439
+ return _jsx4("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
440
+ }
441
+
442
+ // packages/ui-system/dist/frame-range.js
443
+ import { jsx as _jsx5, jsxs as _jsxs3, Fragment as _Fragment } from "react/jsx-runtime";
444
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
445
+ function timeLabel(seconds) {
446
+ const whole = Math.floor(seconds);
447
+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
448
+ }
449
+ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range", onValueChange }) {
450
+ const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
451
+ const increment = Math.min(length, Number.isFinite(step) && step > 0 ? step : 0.1);
452
+ const start = clamp(Number.isFinite(value.start) ? value.start : 0, 0, length - increment);
453
+ const end = clamp(Number.isFinite(value.end) ? value.end : length, Math.min(length, start + increment), length);
454
+ function move(edge, next) {
455
+ const rounded = Math.round(next / increment) * increment;
456
+ const range = edge === "start" ? { start: clamp(rounded, 0, end - increment), end } : { start, end: clamp(next >= length ? length : rounded, start + increment, length) };
457
+ if (range.start !== start || range.end !== end)
458
+ onValueChange(range);
459
+ }
460
+ function drag(event, edge) {
461
+ if (!event.currentTarget.hasPointerCapture(event.pointerId))
462
+ return;
463
+ const box = event.currentTarget.closest(".vx-frame-range")?.getBoundingClientRect();
464
+ if (box?.width)
465
+ move(edge, (event.clientX - box.left) / box.width * length);
466
+ }
467
+ function handleKey(event, edge, current) {
468
+ const changes = {
469
+ ArrowLeft: current - increment,
470
+ ArrowDown: current - increment,
471
+ ArrowRight: current + increment,
472
+ ArrowUp: current + increment,
473
+ Home: 0,
474
+ End: length
475
+ };
476
+ const next = changes[event.key];
477
+ if (next === void 0)
478
+ return;
479
+ event.preventDefault();
480
+ move(edge, next);
481
+ }
482
+ return _jsxs3("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
483
+ "--vx-range-start": `${start / length * 100}%`,
484
+ "--vx-range-end": `${end / length * 100}%`
485
+ } : void 0, children: [thumbnail && length > 0 && _jsx5("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs3(_Fragment, { children: [_jsx5("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs3(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
486
+ const current = edge === "start" ? start : end;
487
+ return _jsx5("div", { tabIndex: 0, role: "slider", className: "vx-frame-handle", "data-edge": edge, "aria-label": edge === "start" ? "Range start" : "Range end", "aria-valuemin": edge === "start" ? 0 : start + increment, "aria-valuemax": edge === "start" ? end - increment : length, "aria-valuenow": current, "aria-valuetext": `${Number(current.toFixed(3))} seconds`, onKeyDown: (event) => handleKey(event, edge, current), onPointerDown: (event) => {
488
+ if (event.button !== 0)
489
+ return;
490
+ event.currentTarget.focus();
491
+ event.currentTarget.setPointerCapture(event.pointerId);
492
+ }, onPointerMove: (event) => drag(event, edge) }, edge);
493
+ })] })] });
494
+ }
495
+
496
+ // packages/ui-system/dist/dialog.js
497
+ import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment2 } from "react/jsx-runtime";
498
+ import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
499
+ import { createPortal } from "react-dom";
500
+
501
+ // packages/ui-system/dist/dialog-surface.js
502
+ function createDialogSurface(anchor) {
503
+ const source = anchor.ownerDocument;
504
+ let target;
505
+ try {
506
+ target = source.defaultView?.top?.document ?? source;
507
+ } catch {
508
+ return void 0;
509
+ }
510
+ if (target === source)
511
+ return void 0;
512
+ const host = target.createElement("div");
513
+ host.dataset.studioDialogSurface = "";
514
+ const shadow = host.attachShadow({ mode: "open" });
515
+ for (const original of source.querySelectorAll('link[rel="stylesheet"], style')) {
516
+ const clone = original.cloneNode(true);
517
+ if (original.tagName === "LINK")
518
+ clone.setAttribute("href", original.href);
519
+ shadow.append(clone);
520
+ }
521
+ const theme = anchor.closest("[data-vx-theme]");
522
+ const root = target.createElement("div");
523
+ root.dataset.vxTheme = theme?.dataset.vxTheme ?? "light";
524
+ root.className = theme?.className ?? "";
525
+ root.style.display = "contents";
526
+ const style = source.defaultView.getComputedStyle(anchor);
527
+ for (const name of style)
528
+ if (name.startsWith("--"))
529
+ root.style.setProperty(name, style.getPropertyValue(name));
530
+ shadow.append(root);
531
+ let container = root;
532
+ const ancestors = [];
533
+ for (let parent = anchor.parentElement; parent && parent !== theme; parent = parent.parentElement)
534
+ ancestors.unshift(parent);
535
+ for (const original of ancestors) {
536
+ const wrapper = target.createElement("div");
537
+ wrapper.className = original.className;
538
+ for (const { name, value } of original.attributes)
539
+ if (name.startsWith("data-"))
540
+ wrapper.setAttribute(name, value);
541
+ wrapper.style.display = "contents";
542
+ container.append(wrapper);
543
+ container = wrapper;
544
+ }
545
+ target.body.append(host);
546
+ return { root: container, dispose: () => host.remove() };
547
+ }
548
+
549
+ // packages/ui-system/dist/dialog.js
550
+ function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
551
+ const ref = useRef(null);
552
+ const anchor = useRef(null);
553
+ const [surface, setSurface] = useState();
554
+ const heading = useId2();
555
+ useLayoutEffect(() => {
556
+ if (!open || !anchor.current)
557
+ return;
558
+ const mounted = createDialogSurface(anchor.current);
559
+ const active = anchor.current.getRootNode().activeElement;
560
+ setSurface(mounted?.root ?? null);
561
+ return () => {
562
+ mounted?.dispose();
563
+ setSurface(void 0);
564
+ queueMicrotask(() => {
565
+ if (active?.isConnected)
566
+ active.focus();
567
+ });
568
+ };
569
+ }, [open]);
570
+ useLayoutEffect(() => {
571
+ const dialog2 = ref.current;
572
+ if (!open || surface === void 0 || !dialog2)
573
+ return;
574
+ dialog2.showModal();
575
+ return () => {
576
+ if (dialog2.open)
577
+ dialog2.close();
578
+ };
579
+ }, [open, surface]);
580
+ const dialog = _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
581
+ event.preventDefault();
582
+ event.stopPropagation();
583
+ onOpenChange(false);
584
+ }, onClose: (event) => {
585
+ if (open && event.currentTarget.isConnected && !event.currentTarget.open)
586
+ onOpenChange(false);
587
+ }, children: [_jsxs4("header", { children: [_jsx6("h2", { id: heading, children: title }), _jsx6(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) })] }), _jsx6("div", { className: "vx-dialog-body", children }), actions && _jsx6("footer", { children: actions })] });
588
+ return _jsxs4(_Fragment2, { children: [_jsx6("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
589
+ }
590
+
591
+ // packages/ui-system/dist/menu.js
592
+ import { jsx as _jsx7, jsxs as _jsxs5 } from "react/jsx-runtime";
593
+ import { useEffect, useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
594
+ import { createPortal as createPortal2 } from "react-dom";
595
+ function isEnabled(item) {
596
+ return !item.disabled && item.items?.length !== 0;
597
+ }
598
+ function Menu({ label, items, triggerIcon, floating = false }) {
599
+ const id = useId3();
600
+ const trigger = useRef2(null);
601
+ const popup = useRef2(null);
602
+ const focusIndex = useRef2(0);
603
+ const [path, setPath] = useState2(null);
604
+ const [placement, setPlacement] = useState2({ visibility: "hidden" });
605
+ const portalRoot = floating ? trigger.current?.closest("dialog, [data-vx-theme]") : null;
606
+ useLayoutEffect2(() => {
607
+ if (!floating || !path || !portalRoot)
608
+ return;
609
+ const position = () => {
610
+ const anchor = trigger.current, menu2 = popup.current;
611
+ if (!anchor || !menu2)
612
+ return;
613
+ const document3 = anchor.ownerDocument;
614
+ const window2 = document3.defaultView;
615
+ const rect = anchor.getBoundingClientRect();
616
+ const width = document3.documentElement.clientWidth, height = window2.innerHeight;
617
+ const bounds = menu2.getBoundingClientRect();
618
+ const naturalHeight = menu2.scrollHeight + bounds.height - menu2.clientHeight;
619
+ const below = Math.max(0, height - rect.bottom - 12), above = Math.max(0, rect.top - 12);
620
+ const flip = naturalHeight > below && above > below;
621
+ const maxHeight = Math.max(0, Math.min(480, height - 16, flip ? above : below));
622
+ const menuHeight = Math.min(naturalHeight, maxHeight);
623
+ setPlacement({
624
+ position: "fixed",
625
+ visibility: "visible",
626
+ insetInlineStart: "auto",
627
+ left: Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8)),
628
+ top: Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8)),
629
+ maxHeight,
630
+ zIndex: 100
631
+ });
632
+ };
633
+ const outside = (event) => {
634
+ const path2 = event.composedPath();
635
+ if (!path2.includes(trigger.current) && !path2.includes(popup.current))
636
+ setPath(null);
637
+ };
638
+ const document2 = portalRoot.ownerDocument;
639
+ const window = document2.defaultView;
640
+ position();
641
+ window.addEventListener("resize", position);
642
+ window.addEventListener("scroll", position, true);
643
+ document2.addEventListener("pointerdown", outside);
644
+ return () => {
645
+ window.removeEventListener("resize", position);
646
+ window.removeEventListener("scroll", position, true);
647
+ document2.removeEventListener("pointerdown", outside);
648
+ };
649
+ }, [floating, path, portalRoot]);
650
+ let entries = items;
651
+ let menuLabel = label;
652
+ for (const key of path ?? []) {
653
+ const entry = entries.find((item) => item.id === key);
654
+ if (!entry?.items)
655
+ break;
656
+ menuLabel = entry.label;
657
+ entries = entry.items;
658
+ }
659
+ function buttons() {
660
+ return [...popup.current?.querySelectorAll("button:not(:disabled)") ?? []];
661
+ }
662
+ useEffect(() => {
663
+ if (path && (!floating || !portalRoot || placement.visibility === "visible"))
664
+ buttons().at(focusIndex.current)?.focus();
665
+ }, [path, floating && placement.visibility, portalRoot]);
666
+ function close() {
667
+ setPath(null);
668
+ trigger.current?.focus();
669
+ }
670
+ function back() {
671
+ if (!path?.length)
672
+ return;
673
+ const parentPath = path.slice(0, -1);
674
+ const parent = parentPath.reduce((level, key) => level.find((item) => item.id === key)?.items ?? level, items);
675
+ focusIndex.current = Math.max(0, parent.filter(isEnabled).findIndex((item) => item.id === path.at(-1)));
676
+ setPath(parentPath);
677
+ }
678
+ function choose(item) {
679
+ if (item.items?.length) {
680
+ focusIndex.current = 0;
681
+ setPath([...path ?? [], item.id]);
682
+ } else if (item.onSelect) {
683
+ if (item.checked === void 0)
684
+ close();
685
+ item.onSelect();
686
+ }
687
+ }
688
+ function handleKey(event) {
689
+ if (event.key === "Tab" && floating && portalRoot) {
690
+ if (event.shiftKey)
691
+ event.preventDefault();
692
+ close();
693
+ return;
694
+ }
695
+ const available = buttons();
696
+ const index = available.findIndex((button) => button === event.target);
697
+ if (event.key === "Escape") {
698
+ event.preventDefault();
699
+ event.stopPropagation();
700
+ if (path?.length)
701
+ back();
702
+ else
703
+ close();
704
+ return;
705
+ }
706
+ if (event.key === "ArrowLeft" && path?.length) {
707
+ event.preventDefault();
708
+ back();
709
+ return;
710
+ }
711
+ if (event.key === "ArrowRight") {
712
+ const item = entries.filter(isEnabled)[index];
713
+ if (item?.items?.length) {
714
+ event.preventDefault();
715
+ choose(item);
716
+ }
717
+ return;
718
+ }
719
+ const next = {
720
+ ArrowDown: (index + 1) % available.length,
721
+ ArrowUp: (index - 1 + available.length) % available.length,
722
+ Home: 0,
723
+ End: available.length - 1
724
+ }[event.key];
725
+ if (next !== void 0) {
726
+ event.preventDefault();
727
+ available[next]?.focus();
728
+ }
729
+ }
730
+ function open(index = 0) {
731
+ focusIndex.current = index;
732
+ setPath([]);
733
+ }
734
+ function triggerKey(event) {
735
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
736
+ event.preventDefault();
737
+ open(event.key === "ArrowUp" ? -1 : 0);
738
+ }
739
+ }
740
+ const menu = _jsx7("div", { ref: popup, className: "vx-action-menu-items", role: "menu", id, "aria-label": menuLabel, hidden: !path, onKeyDown: handleKey, "data-floating": floating || void 0, style: floating && portalRoot ? placement : void 0, children: entries.map((item) => _jsxs5("button", { type: "button", role: item.checked === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": item.checked, "aria-haspopup": item.items?.length ? "menu" : void 0, "data-size": item.size ?? "medium", disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item), children: [item.icon && _jsx7(Icon, { name: item.icon }), _jsx7("span", { children: item.label }), item.checked && _jsx7(Icon, { name: "check" }), item.items?.length ? _jsx7(Icon, { name: "chevron-right" }) : null] }, item.id)) });
741
+ return _jsxs5("div", { className: "vx-action-menu", onBlur: (event) => {
742
+ if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)))
743
+ setPath(null);
744
+ }, children: [triggerIcon ? _jsx7(IconButton, { ref: trigger, label, icon: triggerIcon, variant: "icon-ghost-sm", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }) : _jsx7(Button, { ref: trigger, label, variant: "text-tonal-sm", trailingIcon: "chevron-down", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }), portalRoot ? createPortal2(menu, portalRoot) : menu] });
745
+ }
746
+
747
+ // packages/ui-system/dist/video-player.js
748
+ import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
749
+ import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
750
+ function timeLabel2(seconds) {
751
+ const whole = Math.floor(seconds);
752
+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
753
+ }
754
+ function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen }) {
755
+ return _jsxs6("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, style: {
756
+ "--vx-playback-progress": `${duration > 0 ? Math.min(100, Math.max(0, time / duration * 100)) : 0}%`
757
+ }, children: [_jsx8(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), _jsx8("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }), _jsxs6("span", { "aria-hidden": "true", children: [timeLabel2(time), " / ", timeLabel2(duration)] }), _jsx8(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), onFullscreen && _jsx8(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: "Toggle fullscreen", onClick: onFullscreen })] });
758
+ }
759
+ function VideoPlayer(props) {
760
+ return _jsx8(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
761
+ }
762
+ function Playback({ src, poster, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", controlsSize, showFullscreen = true, overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
763
+ const root = useRef3(null);
764
+ const video = useRef3(null);
765
+ const position = useRef3(0);
766
+ const callbacks = useRef3({ onTimeChange, onStateChange, onEnded });
767
+ const [time, setTime] = useState3(0);
768
+ const [metadataDuration, setMetadataDuration] = useState3(0);
769
+ const [state, setState] = useState3("cover");
770
+ const [muted, setMuted] = useState3(defaultMuted);
771
+ const stillDuration = poster && Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
772
+ const duration = src ? metadataDuration : stillDuration;
773
+ useEffect2(() => {
774
+ const element = video.current;
775
+ return () => {
776
+ if (!element)
777
+ return;
778
+ element.pause();
779
+ element.removeAttribute("src");
780
+ element.load();
781
+ };
782
+ }, []);
783
+ function updateTime(next) {
784
+ position.current = next;
785
+ setTime(next);
786
+ onTimeChange?.(next);
787
+ }
788
+ function changeState(next) {
789
+ setState(next);
790
+ onStateChange?.(next);
791
+ }
792
+ useEffect2(() => {
793
+ callbacks.current = { onTimeChange, onStateChange, onEnded };
794
+ }, [onTimeChange, onStateChange, onEnded]);
795
+ useEffect2(() => {
796
+ if (src || state !== "playing" || !duration)
797
+ return;
798
+ let previous = performance.now();
799
+ let frame = requestAnimationFrame(tick);
800
+ function tick(now) {
801
+ const next = Math.min(duration, position.current + (now - previous) / 1e3);
802
+ previous = now;
803
+ position.current = next;
804
+ setTime(next);
805
+ callbacks.current.onTimeChange?.(next);
806
+ if (next < duration)
807
+ frame = requestAnimationFrame(tick);
808
+ else {
809
+ setState("paused");
810
+ callbacks.current.onStateChange?.("paused");
811
+ callbacks.current.onEnded?.();
812
+ }
813
+ }
814
+ return () => cancelAnimationFrame(frame);
815
+ }, [src, state, duration]);
816
+ function togglePlay() {
817
+ if (state === "playing") {
818
+ if (video.current)
819
+ video.current.pause();
820
+ else
821
+ changeState("paused");
822
+ return;
823
+ }
824
+ if (onBeforePlay?.() === false)
825
+ return;
826
+ if (video.current)
827
+ void video.current.play().catch((error) => onError?.(error));
828
+ else if (duration) {
829
+ if (position.current >= duration)
830
+ updateTime(0);
831
+ changeState("playing");
832
+ }
833
+ }
834
+ function seek(seconds) {
835
+ if (video.current)
836
+ video.current.currentTime = seconds;
837
+ else
838
+ updateTime(seconds);
839
+ }
840
+ async function toggleFullscreen() {
841
+ try {
842
+ const player = root.current;
843
+ if (!player?.requestFullscreen)
844
+ return;
845
+ if (player.ownerDocument.fullscreenElement === player)
846
+ await player.ownerDocument.exitFullscreen();
847
+ else
848
+ await player.requestFullscreen();
849
+ } catch (error) {
850
+ onError?.(error);
851
+ }
852
+ }
853
+ return _jsxs6("section", { ref: root, className: "vx-video-player", "aria-label": title, "data-placement": controlsPlacement, "data-state": state, children: [_jsxs6("div", { className: "vx-video-stage", children: [src ? _jsx8("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onDurationChange: (event) => {
854
+ const value = event.currentTarget.duration;
855
+ setMetadataDuration(Number.isFinite(value) ? value : 0);
856
+ }, onPlay: () => changeState("playing"), onPause: (event) => {
857
+ updateTime(event.currentTarget.currentTime);
858
+ changeState("paused");
859
+ }, onTimeUpdate: (event) => updateTime(event.currentTarget.currentTime), onEnded, onError: (event) => onError?.(event.currentTarget.error) }) : poster && _jsx8("img", { src: poster, alt: "" }), overlay, state === "cover" && _jsxs6("div", { className: "vx-video-cover", children: [_jsxs6("div", { className: "vx-video-info", children: [_jsxs6("div", { className: "vx-video-title", children: [_jsx8("strong", { title, children: title }), version && _jsx8(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs6("div", { className: "vx-video-meta", children: [durationLabel && _jsx8("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx8("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx8("span", { children: sceneLabel })] })] }), (src || duration > 0) && _jsx8(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx8(PlaybackControls, { playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen ? () => void toggleFullscreen() : void 0 })] });
860
+ }
861
+
862
+ // packages/media-tools/src/ui/recipe-player.tsx
863
+ import * as React2 from "react";
864
+ function RecipePlayer({
865
+ video,
866
+ recipe: recipe2 = video.recipe,
867
+ editingCrop = false,
868
+ controlsPlacement = "below",
869
+ children
870
+ }) {
871
+ const root = React2.useRef(null);
872
+ const media = React2.useRef(null);
873
+ const fit = React2.useRef(null);
874
+ const [box, setBox] = React2.useState({ width: 640, height: 360 });
875
+ const [playing, setPlaying] = React2.useState(false);
876
+ const [muted, setMuted] = React2.useState(false);
877
+ const [time, setTime] = React2.useState(recipe2.trim.inMs / 1e3);
878
+ const [error, setError] = React2.useState("");
879
+ const bounds = React2.useRef(recipe2.trim);
880
+ bounds.current = recipe2.trim;
881
+ const crop = editingCrop ? { x: 0, y: 0, width: 1, height: 1 } : recipe2.crop;
882
+ const aspect = video.displayWidth * crop.width / (video.displayHeight * crop.height);
883
+ const width = Math.max(1, Math.min(box.width, box.height * aspect));
884
+ React2.useEffect(() => {
885
+ const element = fit.current;
886
+ if (!element) return;
887
+ const resize = () => setBox({ width: element.clientWidth, height: element.clientHeight });
888
+ resize();
889
+ const observer = new ResizeObserver(resize);
890
+ observer.observe(element);
891
+ return () => observer.disconnect();
892
+ }, []);
893
+ React2.useEffect(() => {
894
+ const element = media.current;
895
+ if (!element) return;
896
+ return () => {
897
+ element.pause();
898
+ element.removeAttribute("src");
899
+ element.load();
900
+ };
901
+ }, [video.previewUrl]);
902
+ React2.useEffect(() => {
903
+ const element = media.current;
904
+ if (!element || !playing) return;
905
+ let frame = 0;
906
+ const check = () => {
907
+ const range = bounds.current;
908
+ if (!element.paused && element.currentTime * 1e3 >= range.outMs - 1) {
909
+ element.pause();
910
+ element.currentTime = Math.max(range.inMs, range.outMs - 1) / 1e3;
911
+ }
912
+ frame = requestAnimationFrame(check);
913
+ };
914
+ frame = requestAnimationFrame(check);
915
+ return () => {
916
+ cancelAnimationFrame(frame);
917
+ };
918
+ }, [video.previewUrl, playing]);
919
+ React2.useEffect(() => {
920
+ const element = media.current;
921
+ if (element && Number.isFinite(element.duration)) {
922
+ const clamped = Math.max(
923
+ recipe2.trim.inMs / 1e3,
924
+ Math.min((recipe2.trim.outMs - 1) / 1e3, element.currentTime)
925
+ );
926
+ if (element.currentTime !== clamped) element.currentTime = clamped;
927
+ setTime(clamped);
928
+ }
929
+ }, [recipe2.trim.inMs, recipe2.trim.outMs]);
930
+ const seek = (seconds) => {
931
+ const element = media.current;
932
+ if (element)
933
+ element.currentTime = Math.max(
934
+ recipe2.trim.inMs,
935
+ Math.min(recipe2.trim.outMs - 1, recipe2.trim.inMs + seconds * 1e3)
936
+ ) / 1e3;
937
+ };
938
+ async function fullscreen() {
939
+ try {
940
+ if (document.fullscreenElement === root.current) await document.exitFullscreen();
941
+ else await root.current?.requestFullscreen();
942
+ } catch (failure) {
943
+ setError(readableError(failure));
944
+ }
945
+ }
946
+ return /* @__PURE__ */ React2.createElement(
947
+ "div",
948
+ {
949
+ className: "mt-player",
950
+ "data-placement": controlsPlacement,
951
+ ref: root,
952
+ "aria-label": video.name
953
+ },
954
+ /* @__PURE__ */ React2.createElement("div", { className: "mt-player-fit", ref: fit }, /* @__PURE__ */ React2.createElement("div", { className: "mt-picture", style: { width, height: width / aspect } }, /* @__PURE__ */ React2.createElement("div", { className: "mt-picture-clip" }, /* @__PURE__ */ React2.createElement(
955
+ "video",
956
+ {
957
+ ref: media,
958
+ src: video.previewUrl,
959
+ preload: "metadata",
960
+ playsInline: true,
961
+ muted,
962
+ "aria-label": video.name,
963
+ style: {
964
+ width: `${100 / crop.width}%`,
965
+ height: `${100 / crop.height}%`,
966
+ left: `${-crop.x * 100 / crop.width}%`,
967
+ top: `${-crop.y * 100 / crop.height}%`
968
+ },
969
+ onLoadedMetadata: (event) => {
970
+ event.currentTarget.currentTime = bounds.current.inMs / 1e3;
971
+ setTime(bounds.current.inMs / 1e3);
972
+ },
973
+ onSeeking: (event) => {
974
+ const element = event.currentTarget;
975
+ const value = Math.max(
976
+ bounds.current.inMs,
977
+ Math.min(bounds.current.outMs - 1, element.currentTime * 1e3)
978
+ ) / 1e3;
979
+ if (Math.abs(element.currentTime - value) > 5e-4) element.currentTime = value;
980
+ },
981
+ onPlay: () => setPlaying(true),
982
+ onPause: () => setPlaying(false),
983
+ onEnded: () => setPlaying(false),
984
+ onTimeUpdate: (event) => setTime(event.currentTarget.currentTime),
985
+ onError: () => setError("This fixed video could not be played. Reload its preview.")
986
+ }
987
+ )), children)),
988
+ /* @__PURE__ */ React2.createElement(
989
+ PlaybackControls,
990
+ {
991
+ playing,
992
+ muted,
993
+ time: Math.max(0, time - recipe2.trim.inMs / 1e3),
994
+ duration: (recipe2.trim.outMs - recipe2.trim.inMs) / 1e3,
995
+ onSeek: seek,
996
+ onToggleMute: () => setMuted(!muted),
997
+ onFullscreen: () => void fullscreen(),
998
+ onTogglePlay: () => {
999
+ const element = media.current;
1000
+ if (!element) return;
1001
+ if (element.paused) {
1002
+ if (element.currentTime * 1e3 >= recipe2.trim.outMs - 2)
1003
+ element.currentTime = recipe2.trim.inMs / 1e3;
1004
+ void element.play().catch((failure) => setError(readableError(failure)));
1005
+ } else element.pause();
1006
+ }
1007
+ }
1008
+ ),
1009
+ error && /* @__PURE__ */ React2.createElement("p", { role: "alert", className: "mt-error" }, error)
1010
+ );
1011
+ }
1012
+
1013
+ // packages/media-tools/src/ui/use-filmstrip.ts
1014
+ import * as React3 from "react";
1015
+ function useFilmstrip(src, enabled) {
1016
+ const [result, setResult] = React3.useState();
1017
+ React3.useEffect(() => {
1018
+ if (!src || !enabled) return;
1019
+ const controller = new AbortController();
1020
+ const video = document.createElement("video");
1021
+ const canvas2 = document.createElement("canvas");
1022
+ video.crossOrigin = "anonymous";
1023
+ video.muted = true;
1024
+ video.playsInline = true;
1025
+ video.preload = "auto";
1026
+ function waitFor(event) {
1027
+ return new Promise((resolve, reject) => {
1028
+ function finish(error) {
1029
+ clearTimeout(timer);
1030
+ video.removeEventListener(event, ready);
1031
+ video.removeEventListener("error", failed);
1032
+ controller.signal.removeEventListener("abort", aborted);
1033
+ if (error) reject(error);
1034
+ else resolve();
1035
+ }
1036
+ const ready = () => finish();
1037
+ const failed = () => finish(new Error("The source frames could not be decoded."));
1038
+ const aborted = () => finish(new DOMException("Thumbnail decoding stopped.", "AbortError"));
1039
+ const timer = setTimeout(() => finish(new Error("Thumbnail decoding timed out.")), 5e3);
1040
+ video.addEventListener(event, ready, { once: true });
1041
+ video.addEventListener("error", failed, { once: true });
1042
+ controller.signal.addEventListener("abort", aborted, { once: true });
1043
+ });
1044
+ }
1045
+ async function decode() {
1046
+ const loaded = waitFor("loadeddata");
1047
+ video.src = src;
1048
+ video.load();
1049
+ await loaded;
1050
+ if (!Number.isFinite(video.duration) || video.duration <= 0) throw new Error("No duration.");
1051
+ const count = 10;
1052
+ const tileWidth = 80;
1053
+ const tileHeight = 48;
1054
+ canvas2.width = count * tileWidth;
1055
+ canvas2.height = tileHeight;
1056
+ const context = canvas2.getContext("2d");
1057
+ if (!context || !video.videoWidth || !video.videoHeight) throw new Error("No video frames.");
1058
+ for (let index = 0; index < count; index++) {
1059
+ if (controller.signal.aborted) return;
1060
+ const time = video.duration * (index + 0.5) / count;
1061
+ const seeked = waitFor("seeked");
1062
+ video.currentTime = time;
1063
+ await seeked;
1064
+ if (controller.signal.aborted) return;
1065
+ const scale = Math.max(tileWidth / video.videoWidth, tileHeight / video.videoHeight);
1066
+ const width = tileWidth / scale;
1067
+ const height = tileHeight / scale;
1068
+ context.drawImage(
1069
+ video,
1070
+ (video.videoWidth - width) / 2,
1071
+ (video.videoHeight - height) / 2,
1072
+ width,
1073
+ height,
1074
+ index * tileWidth,
1075
+ 0,
1076
+ tileWidth,
1077
+ tileHeight
1078
+ );
1079
+ }
1080
+ if (!controller.signal.aborted)
1081
+ setResult({ src, thumbnail: canvas2.toDataURL("image/jpeg", 0.75) });
1082
+ }
1083
+ void decode().catch(() => {
1084
+ if (!controller.signal.aborted)
1085
+ setResult({
1086
+ src,
1087
+ error: "Thumbnail preview is unavailable. Timing controls still work."
1088
+ });
1089
+ }).finally(() => {
1090
+ video.pause();
1091
+ video.removeAttribute("src");
1092
+ video.load();
1093
+ canvas2.width = 0;
1094
+ canvas2.height = 0;
1095
+ });
1096
+ return () => {
1097
+ controller.abort();
1098
+ video.pause();
1099
+ video.removeAttribute("src");
1100
+ video.load();
1101
+ };
1102
+ }, [src, enabled]);
1103
+ return result?.src === src && enabled ? result : void 0;
1104
+ }
1105
+
1106
+ // packages/media-tools/src/ui/editor.tsx
1107
+ var ratios = ["Original", "Freeform", "9:16", "3:4", "1:1", "4:3", "16:9", "21:9"];
1108
+ var clamp2 = (value, min, max) => Math.max(min, Math.min(max, value));
1109
+ function gcd(a, b) {
1110
+ return b ? gcd(b, a % b) : a;
1111
+ }
1112
+ function ratioParts(value, width, height) {
1113
+ if (value === "Freeform") return null;
1114
+ const [w, h] = value === "Original" ? [width, height] : value.split(":").map(Number);
1115
+ const divisor = gcd(w, h);
1116
+ return [w / divisor, h / divisor];
1117
+ }
1118
+ function fraction(rect, video) {
1119
+ return {
1120
+ x: rect.x / video.displayWidth,
1121
+ y: rect.y / video.displayHeight,
1122
+ width: rect.width / video.displayWidth,
1123
+ height: rect.height / video.displayHeight
1124
+ };
1125
+ }
1126
+ function CropFrame({
1127
+ video,
1128
+ crop,
1129
+ ratio,
1130
+ onChange
1131
+ }) {
1132
+ const drag = React4.useRef(null);
1133
+ const parts = ratioParts(ratio, video.displayWidth, video.displayHeight);
1134
+ function move(original, dx, dy, edge) {
1135
+ if (edge === "move") {
1136
+ onChange({
1137
+ ...original,
1138
+ x: clamp2(original.x + dx, 0, 1 - original.width),
1139
+ y: clamp2(original.y + dy, 0, 1 - original.height)
1140
+ });
1141
+ return;
1142
+ }
1143
+ const east = edge.endsWith("e"), south = edge.startsWith("s");
1144
+ const ax = east ? original.x : original.x + original.width;
1145
+ const ay = south ? original.y : original.y + original.height;
1146
+ const maxW = east ? 1 - ax : ax, maxH = south ? 1 - ay : ay;
1147
+ let width = clamp2(original.width + (east ? dx : -dx), 2 / video.displayWidth, maxW);
1148
+ let height = clamp2(original.height + (south ? dy : -dy), 2 / video.displayHeight, maxH);
1149
+ if (parts) {
1150
+ const [p, q] = parts;
1151
+ const proposed = Math.abs(dx) >= Math.abs(dy) ? width * video.displayWidth / (2 * p) : height * video.displayHeight / (2 * q);
1152
+ const maximum = Math.floor(
1153
+ Math.min(maxW * video.displayWidth / (2 * p), maxH * video.displayHeight / (2 * q)) + 1e-8
1154
+ );
1155
+ if (maximum < 1) return;
1156
+ const multiple = clamp2(Math.round(proposed), 1, maximum);
1157
+ width = 2 * p * multiple / video.displayWidth;
1158
+ height = 2 * q * multiple / video.displayHeight;
1159
+ }
1160
+ onChange({ x: east ? ax : ax - width, y: south ? ay : ay - height, width, height });
1161
+ }
1162
+ function start(event, edge) {
1163
+ if (event.button !== 0) return;
1164
+ event.stopPropagation();
1165
+ event.preventDefault();
1166
+ event.currentTarget.focus();
1167
+ event.currentTarget.setPointerCapture(event.pointerId);
1168
+ drag.current = {
1169
+ element: event.currentTarget,
1170
+ pointerId: event.pointerId,
1171
+ x: event.clientX,
1172
+ y: event.clientY,
1173
+ crop,
1174
+ edge
1175
+ };
1176
+ }
1177
+ function key(event, edge) {
1178
+ const step = event.shiftKey ? 10 : 1;
1179
+ const x = (parts && edge !== "move" ? 2 * parts[0] : 2) * step / video.displayWidth;
1180
+ const y = (parts && edge !== "move" ? 2 * parts[1] : 2) * step / video.displayHeight;
1181
+ const changes = {
1182
+ ArrowLeft: [-x, 0],
1183
+ ArrowRight: [x, 0],
1184
+ ArrowUp: [0, -y],
1185
+ ArrowDown: [0, y]
1186
+ };
1187
+ const change = changes[event.key];
1188
+ if (!change) return;
1189
+ event.preventDefault();
1190
+ event.stopPropagation();
1191
+ move(crop, ...change, edge);
1192
+ }
1193
+ const position = {
1194
+ left: `${crop.x * 100}%`,
1195
+ top: `${crop.y * 100}%`,
1196
+ width: `${crop.width * 100}%`,
1197
+ height: `${crop.height * 100}%`
1198
+ };
1199
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "mt-crop-shade", "aria-hidden": "true" }, /* @__PURE__ */ React4.createElement("span", { style: position })), /* @__PURE__ */ React4.createElement(
1200
+ "div",
1201
+ {
1202
+ className: "mt-crop-frame",
1203
+ tabIndex: 0,
1204
+ role: "group",
1205
+ "aria-label": "Crop selection",
1206
+ "aria-description": "Drag to move. Arrow keys move two pixels. Shift moves ten steps.",
1207
+ style: position,
1208
+ onKeyDown: (event) => key(event, "move"),
1209
+ onPointerDown: (event) => start(event, "move"),
1210
+ onPointerMove: (event) => {
1211
+ const current = drag.current;
1212
+ const box = event.currentTarget.closest(".mt-picture")?.getBoundingClientRect();
1213
+ if (current && current.pointerId === event.pointerId && box?.width && box.height)
1214
+ move(
1215
+ current.crop,
1216
+ (event.clientX - current.x) / box.width,
1217
+ (event.clientY - current.y) / box.height,
1218
+ current.edge
1219
+ );
1220
+ },
1221
+ onPointerUp: () => {
1222
+ const current = drag.current;
1223
+ if (current?.element.hasPointerCapture(current.pointerId))
1224
+ current.element.releasePointerCapture(current.pointerId);
1225
+ drag.current = null;
1226
+ },
1227
+ onPointerCancel: () => {
1228
+ drag.current = null;
1229
+ }
1230
+ },
1231
+ /* @__PURE__ */ React4.createElement("span", { className: "mt-crop-grid", "aria-hidden": "true" }),
1232
+ ["nw", "ne", "sw", "se"].map((edge) => /* @__PURE__ */ React4.createElement(
1233
+ "button",
1234
+ {
1235
+ type: "button",
1236
+ key: edge,
1237
+ className: "mt-crop-handle",
1238
+ "data-corner": edge,
1239
+ "aria-label": `Resize ${edge.startsWith("n") ? "top" : "bottom"} ${edge.endsWith("w") ? "left" : "right"}`,
1240
+ onPointerDown: (event) => start(event, edge),
1241
+ onKeyDown: (event) => key(event, edge)
1242
+ }
1243
+ ))
1244
+ ));
1245
+ }
1246
+ function VideoEditor({ input, mode, onApply, onClose }) {
1247
+ const { client, instanceId, resolve } = useMediaClient();
1248
+ const [video, setVideo] = React4.useState(null);
1249
+ const [draft, setDraft] = React4.useState(null);
1250
+ const [ratio, setRatio] = React4.useState("Freeform");
1251
+ const [error, setError] = React4.useState("");
1252
+ const [saving, setSaving] = React4.useState(false);
1253
+ const [reload, setReload] = React4.useState(0);
1254
+ const generation = React4.useRef(0);
1255
+ const edit = React4.useRef(null);
1256
+ const request = React4.useRef(null);
1257
+ const saved = React4.useRef(null);
1258
+ const identity = JSON.stringify(input);
1259
+ const filmstrip = useFilmstrip(video?.previewUrl, mode === "trim");
1260
+ React4.useEffect(() => {
1261
+ const current = ++generation.current;
1262
+ setVideo(null);
1263
+ setDraft(null);
1264
+ setError("");
1265
+ setSaving(false);
1266
+ saved.current = null;
1267
+ request.current = null;
1268
+ edit.current = null;
1269
+ void resolve(input).then((value) => {
1270
+ if (generation.current !== current) return;
1271
+ setVideo(value);
1272
+ setDraft(value.recipe);
1273
+ if (value.editRef && value.revision)
1274
+ edit.current = { editId: value.editRef.objectId, expectedRevision: value.revision };
1275
+ const r = value.geometry.pixelRect;
1276
+ const known = ratios.filter((label) => label !== "Freeform").find((label) => {
1277
+ const [p, q] = ratioParts(label, value.displayWidth, value.displayHeight);
1278
+ return r.width * q === r.height * p;
1279
+ });
1280
+ setRatio(known || "Freeform");
1281
+ }).catch((failure) => {
1282
+ if (generation.current === current) setError(readableError(failure));
1283
+ });
1284
+ return () => {
1285
+ generation.current++;
1286
+ };
1287
+ }, [resolve, identity, reload]);
1288
+ function change(value) {
1289
+ if (!video) return;
1290
+ try {
1291
+ setDraft(
1292
+ normalizeRecipe(value, video.displayWidth, video.displayHeight, video.durationMs).recipe
1293
+ );
1294
+ setError("");
1295
+ } catch (failure) {
1296
+ setError(readableError(failure));
1297
+ }
1298
+ }
1299
+ function chooseRatio(value) {
1300
+ setRatio(value);
1301
+ if (!video || !draft) return;
1302
+ const parts = ratioParts(value, video.displayWidth, video.displayHeight);
1303
+ if (!parts) return;
1304
+ const [p, q] = parts;
1305
+ const multiple = Math.floor(
1306
+ Math.min(video.displayWidth / (2 * p), video.displayHeight / (2 * q))
1307
+ );
1308
+ if (!multiple) {
1309
+ setError("This picture cannot represent that ratio on the encoding grid.");
1310
+ return;
1311
+ }
1312
+ const width = 2 * p * multiple, height = 2 * q * multiple;
1313
+ const centerX = (draft.crop.x + draft.crop.width / 2) * video.displayWidth;
1314
+ const centerY = (draft.crop.y + draft.crop.height / 2) * video.displayHeight;
1315
+ const x = Math.round(clamp2(centerX - width / 2, 0, video.displayWidth - width) / 2) * 2;
1316
+ const y = Math.round(clamp2(centerY - height / 2, 0, video.displayHeight - height) / 2) * 2;
1317
+ change({ ...draft, crop: fraction({ x, y, width, height }, video) });
1318
+ }
1319
+ async function apply() {
1320
+ if (!video || !draft || saving) return;
1321
+ const current = generation.current;
1322
+ setSaving(true);
1323
+ setError("");
1324
+ try {
1325
+ const digest = JSON.stringify(draft);
1326
+ let value = saved.current?.digest === digest ? saved.current.value : null;
1327
+ if (!value) {
1328
+ const intent = { file: video.file, recipe: draft, ...edit.current || {} };
1329
+ const encoded = JSON.stringify(intent);
1330
+ if (request.current?.input !== encoded)
1331
+ request.current = { input: encoded, key: crypto.randomUUID() };
1332
+ value = await client.invoke({ instanceId, operationId: "edits.save" }, intent, {
1333
+ requestKey: request.current.key
1334
+ });
1335
+ if (generation.current !== current) return;
1336
+ saved.current = { digest, value };
1337
+ edit.current = { editId: value.editRef.objectId, expectedRevision: value.revision };
1338
+ }
1339
+ if (generation.current !== current) return;
1340
+ await onApply(value);
1341
+ if (generation.current === current) onClose();
1342
+ } catch (failure) {
1343
+ if (requestRejected(failure)) request.current = null;
1344
+ if (generation.current === current) setError(readableError(failure));
1345
+ } finally {
1346
+ if (generation.current === current) setSaving(false);
1347
+ }
1348
+ }
1349
+ const rect = video && draft ? normalizeRecipe(draft, video.displayWidth, video.displayHeight, video.durationMs).geometry.pixelRect : null;
1350
+ return /* @__PURE__ */ React4.createElement(
1351
+ "div",
1352
+ {
1353
+ className: "mt-editor",
1354
+ "data-mode": mode,
1355
+ onKeyDownCapture: (event) => {
1356
+ if (event.key === "Escape") event.stopPropagation();
1357
+ }
1358
+ },
1359
+ /* @__PURE__ */ React4.createElement(
1360
+ Dialog,
1361
+ {
1362
+ title: mode === "crop" ? "Crop Video" : "Trim Video",
1363
+ open: true,
1364
+ onOpenChange: (open) => {
1365
+ if (!open && !saving) onClose();
1366
+ },
1367
+ actions: /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-actions" }, /* @__PURE__ */ React4.createElement(
1368
+ Button,
1369
+ {
1370
+ label: "Reset",
1371
+ leadingIcon: "reset",
1372
+ width: "hug",
1373
+ variant: "text-ghost-md",
1374
+ disabled: !draft || saving,
1375
+ onClick: () => {
1376
+ if (!draft || !video) return;
1377
+ if (mode === "crop") {
1378
+ setRatio("Original");
1379
+ change({ ...draft, crop: { x: 0, y: 0, width: 1, height: 1 } });
1380
+ } else change({ ...draft, trim: { inMs: 0, outMs: video.durationMs } });
1381
+ }
1382
+ }
1383
+ ), /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-confirm" }, /* @__PURE__ */ React4.createElement(
1384
+ Button,
1385
+ {
1386
+ label: "Cancel",
1387
+ variant: "text-tonal-md",
1388
+ width: "hug",
1389
+ disabled: saving,
1390
+ onClick: onClose
1391
+ }
1392
+ ), /* @__PURE__ */ React4.createElement(
1393
+ Button,
1394
+ {
1395
+ variant: "text-filled-md",
1396
+ width: "hug",
1397
+ label: "Apply",
1398
+ loading: saving,
1399
+ disabled: !draft || !video,
1400
+ onClick: () => void apply()
1401
+ }
1402
+ )))
1403
+ },
1404
+ video && draft ? /* @__PURE__ */ React4.createElement("div", { inert: saving, "aria-busy": saving }, /* @__PURE__ */ React4.createElement("p", { className: "mt-subtitle" }, video.name, " \xB7 v", video.versionNumber), video.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React4.createElement("p", { className: "mt-subtitle" }, "Color information is missing. Standard SDR colors are assumed; export may differ slightly."), /* @__PURE__ */ React4.createElement(
1405
+ RecipePlayer,
1406
+ {
1407
+ video,
1408
+ recipe: draft,
1409
+ editingCrop: mode === "crop",
1410
+ controlsPlacement: mode === "crop" ? "below" : "overlay"
1411
+ },
1412
+ mode === "crop" && /* @__PURE__ */ React4.createElement(
1413
+ CropFrame,
1414
+ {
1415
+ video,
1416
+ crop: draft.crop,
1417
+ ratio,
1418
+ onChange: (crop) => change({ ...draft, crop })
1419
+ }
1420
+ )
1421
+ ), mode === "trim" ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("p", { className: "mt-editor-hint" }, "Drag the handle to trim the video"), /* @__PURE__ */ React4.createElement(
1422
+ FrameRange,
1423
+ {
1424
+ thumbnail: filmstrip?.thumbnail,
1425
+ duration: video.durationMs / 1e3,
1426
+ variant: "trim",
1427
+ step: 1e-3,
1428
+ value: { start: draft.trim.inMs / 1e3, end: draft.trim.outMs / 1e3 },
1429
+ onValueChange: (value) => change({
1430
+ ...draft,
1431
+ trim: {
1432
+ inMs: Math.round(value.start * 1e3),
1433
+ outMs: Math.round(value.end * 1e3)
1434
+ }
1435
+ })
1436
+ }
1437
+ ), filmstrip?.error && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, filmstrip.error), /* @__PURE__ */ React4.createElement("details", { className: "mt-precision" }, /* @__PURE__ */ React4.createElement("summary", null, "Precise timing"), /* @__PURE__ */ React4.createElement("div", { className: "mt-fields" }, ["inMs", "outMs"].map((edge) => /* @__PURE__ */ React4.createElement("label", { key: edge }, edge === "inMs" ? "In (seconds)" : "Out (seconds)", /* @__PURE__ */ React4.createElement(
1438
+ "input",
1439
+ {
1440
+ type: "number",
1441
+ min: "0",
1442
+ max: video.durationMs / 1e3,
1443
+ step: "0.001",
1444
+ value: draft.trim[edge] / 1e3,
1445
+ disabled: saving,
1446
+ onChange: (event) => {
1447
+ if (Number.isFinite(event.currentTarget.valueAsNumber))
1448
+ change({
1449
+ ...draft,
1450
+ trim: {
1451
+ ...draft.trim,
1452
+ [edge]: Math.round(event.currentTarget.valueAsNumber * 1e3)
1453
+ }
1454
+ });
1455
+ }
1456
+ }
1457
+ )))))) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-hint" }, /* @__PURE__ */ React4.createElement("span", null, "Drag the frame to move. Drag a corner to resize."), /* @__PURE__ */ React4.createElement("span", { role: "status" }, rect?.width, " \xD7 ", rect?.height)), /* @__PURE__ */ React4.createElement(
1458
+ SegmentedControl,
1459
+ {
1460
+ label: "Aspect ratio",
1461
+ items: ratios.map((value) => ({ value, label: value })),
1462
+ value: ratio,
1463
+ onValueChange: chooseRatio,
1464
+ size: "large",
1465
+ width: "full"
1466
+ }
1467
+ ))) : !error && /* @__PURE__ */ React4.createElement("p", { role: "status" }, "Loading fixed video\u2026"),
1468
+ error && /* @__PURE__ */ React4.createElement("div", { role: "alert", className: "mt-error" }, error, !video && /* @__PURE__ */ React4.createElement(
1469
+ Button,
1470
+ {
1471
+ label: "Reload preview",
1472
+ variant: "text-ghost-sm",
1473
+ onClick: () => setReload(reload + 1)
1474
+ }
1475
+ ))
1476
+ )
1477
+ );
1478
+ }
1479
+
1480
+ // packages/media-tools/src/ui/compare.tsx
1481
+ import * as React5 from "react";
1482
+ function formatLabel(width, height) {
1483
+ let a = width, b = height;
1484
+ while (b) {
1485
+ const remainder = a % b;
1486
+ a = b;
1487
+ b = remainder;
1488
+ }
1489
+ return `${width / a}:${height / a}`;
1490
+ }
1491
+ function Candidate({
1492
+ slot,
1493
+ menu,
1494
+ replacing,
1495
+ onChoose,
1496
+ emptyState
1497
+ }) {
1498
+ const { resolve } = useMediaClient();
1499
+ const [video, setVideo] = React5.useState(null);
1500
+ const [error, setError] = React5.useState("");
1501
+ const [revision, setRevision] = React5.useState(0);
1502
+ const identity = JSON.stringify(slot.input);
1503
+ React5.useEffect(() => {
1504
+ let active = true;
1505
+ setVideo(null);
1506
+ setError("");
1507
+ if (slot.input)
1508
+ void resolve(slot.input).then((value) => {
1509
+ if (active) setVideo(value);
1510
+ }).catch((failure) => {
1511
+ if (active) setError(readableError(failure));
1512
+ });
1513
+ return () => {
1514
+ active = false;
1515
+ };
1516
+ }, [resolve, identity, revision]);
1517
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: "mt-compare-preview" }, replacing ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "status" }, "Choosing replacement\u2026") : !slot.input ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty" }, emptyState ?? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("p", null, "No video selected."), /* @__PURE__ */ React5.createElement(
1518
+ Button,
1519
+ {
1520
+ label: "Choose video",
1521
+ variant: "text-tonal-sm",
1522
+ width: "hug",
1523
+ onClick: onChoose
1524
+ }
1525
+ ))) : error ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React5.createElement("p", null, error), /* @__PURE__ */ React5.createElement(
1526
+ Button,
1527
+ {
1528
+ label: "Reload preview",
1529
+ variant: "text-ghost-sm",
1530
+ width: "hug",
1531
+ onClick: () => setRevision(revision + 1)
1532
+ }
1533
+ )) : !video ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React5.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React5.createElement(
1534
+ VideoPlayer,
1535
+ {
1536
+ src: video.previewUrl,
1537
+ title: video.name,
1538
+ controlsPlacement: "overlay",
1539
+ onError: () => setError("This video could not be played. Reload its fixed preview.")
1540
+ }
1541
+ )), /* @__PURE__ */ React5.createElement("div", { className: "mt-candidate-caption" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-candidate-heading" }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("strong", null, slot.input ? slot.context?.shotName || video?.name || "Video" : "Candidate"), video && /* @__PURE__ */ React5.createElement("span", null, "Variant ", video.versionNumber, video.edited ? " \xB7 Edited" : "")), menu), video?.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React5.createElement("span", null, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")), /* @__PURE__ */ React5.createElement("div", { className: "mt-candidate-context" }, slot.input && (video || slot.context?.spokenLine || slot.context?.hook || slot.context?.cta) && /* @__PURE__ */ React5.createElement("dl", null, slot.context?.spokenLine && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "Spoken line"), /* @__PURE__ */ React5.createElement("dd", null, slot.context.spokenLine)), slot.context?.hook && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "Opening Hook"), /* @__PURE__ */ React5.createElement("dd", null, slot.context.hook)), slot.context && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "CTA"), /* @__PURE__ */ React5.createElement("dd", null, slot.context.cta || "None")), video && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "Format"), /* @__PURE__ */ React5.createElement("dd", null, formatLabel(video.geometry.pixelRect.width, video.geometry.pixelRect.height)), /* @__PURE__ */ React5.createElement("dt", null, "Duration"), /* @__PURE__ */ React5.createElement("dd", null, Number((video.effectiveDurationMs / 1e3).toFixed(2)), "s")))));
1542
+ }
1543
+ function VideoCompare(props) {
1544
+ const [generation, setGeneration] = React5.useState(0);
1545
+ const [replacing, setReplacing] = React5.useState(null);
1546
+ const [error, setError] = React5.useState("");
1547
+ const active = React5.useRef(true);
1548
+ React5.useEffect(() => {
1549
+ active.current = true;
1550
+ return () => {
1551
+ active.current = false;
1552
+ };
1553
+ }, []);
1554
+ if (props.slots.length < 2 || props.slots.length > 4 || new Set(props.slots.map((slot) => slot.id)).size !== props.slots.length)
1555
+ return /* @__PURE__ */ React5.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
1556
+ const remove = (slot) => props.onSlotsChange(
1557
+ props.slots.length > 2 ? props.slots.filter((value) => value.id !== slot.id) : props.slots.map((value) => value.id === slot.id ? { ...value, input: null } : value)
1558
+ );
1559
+ async function replace(slot) {
1560
+ if (!props.onRequestReplacement) return;
1561
+ setReplacing(slot.id);
1562
+ setError("");
1563
+ try {
1564
+ const input = await props.onRequestReplacement(slot.id);
1565
+ if (input && active.current)
1566
+ props.onSlotsChange(
1567
+ props.slots.map((value) => value.id === slot.id ? { ...value, input } : value)
1568
+ );
1569
+ } catch (failure) {
1570
+ if (active.current) setError(readableError(failure));
1571
+ } finally {
1572
+ if (active.current) setReplacing(null);
1573
+ }
1574
+ }
1575
+ function candidateChoices(slot) {
1576
+ return (props.candidates || []).filter(
1577
+ (candidate) => !props.slots.some(
1578
+ (other) => other.id !== slot.id && JSON.stringify(other.input) === JSON.stringify(candidate.input)
1579
+ )
1580
+ ).map((candidate, index) => ({
1581
+ id: `candidate-${index}`,
1582
+ label: candidate.label,
1583
+ onSelect: () => props.onSlotsChange(
1584
+ props.slots.map(
1585
+ (value) => value.id === slot.id ? { ...value, input: candidate.input, context: candidate.context } : value
1586
+ )
1587
+ )
1588
+ }));
1589
+ }
1590
+ return /* @__PURE__ */ React5.createElement("section", { className: "mt-compare", "aria-label": "Compare videos" }, error && /* @__PURE__ */ React5.createElement("p", { role: "alert", className: "mt-error" }, error), /* @__PURE__ */ React5.createElement(
1591
+ "div",
1592
+ {
1593
+ className: "mt-compare-columns",
1594
+ style: { gridTemplateColumns: `repeat(${props.slots.length}, minmax(240px,1fr))` }
1595
+ },
1596
+ props.slots.map((slot, index) => /* @__PURE__ */ React5.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React5.createElement(
1597
+ Candidate,
1598
+ {
1599
+ key: JSON.stringify([slot.id, slot.input, generation]),
1600
+ slot,
1601
+ replacing: replacing === slot.id,
1602
+ onChoose: () => void replace(slot),
1603
+ emptyState: props.candidates ? candidateChoices(slot).length ? /* @__PURE__ */ React5.createElement(Menu, { label: "Choose video", floating: true, items: candidateChoices(slot) }) : /* @__PURE__ */ React5.createElement("p", null, "No other candidates yet.") : void 0,
1604
+ menu: /* @__PURE__ */ React5.createElement(
1605
+ Menu,
1606
+ {
1607
+ label: `Options for video ${index + 1}`,
1608
+ triggerIcon: "more",
1609
+ floating: true,
1610
+ items: [
1611
+ ...props.slotMenuItems?.(slot) ?? [],
1612
+ ...props.candidates ? [
1613
+ {
1614
+ id: "replace",
1615
+ label: "Choose video",
1616
+ disabled: candidateChoices(slot).length === 0,
1617
+ items: candidateChoices(slot)
1618
+ }
1619
+ ] : [
1620
+ {
1621
+ id: "replace",
1622
+ label: slot.input ? "Replace" : "Choose video",
1623
+ disabled: replacing !== null,
1624
+ onSelect: () => void replace(slot)
1625
+ }
1626
+ ],
1627
+ ...slot.input ? [
1628
+ {
1629
+ id: "details",
1630
+ label: "Details",
1631
+ onSelect: () => {
1632
+ setGeneration((value) => value + 1);
1633
+ props.onOpenDetails(slot.input, {
1634
+ slots: props.slots,
1635
+ origin: props.origin
1636
+ });
1637
+ }
1638
+ }
1639
+ ] : [],
1640
+ {
1641
+ id: "add-column",
1642
+ label: "Add column",
1643
+ disabled: props.slots.length >= 4,
1644
+ onSelect: () => props.onSlotsChange([
1645
+ ...props.slots,
1646
+ { id: crypto.randomUUID(), input: null }
1647
+ ])
1648
+ },
1649
+ { id: "remove", label: "Remove", onSelect: () => remove(slot) }
1650
+ ]
1651
+ }
1652
+ )
1653
+ }
1654
+ ), slot.input && props.renderSlotActions && /* @__PURE__ */ React5.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot))))
1655
+ ));
1656
+ }
1657
+
1658
+ // packages/media-tools/src/ui/jobs.tsx
1659
+ import * as React6 from "react";
1660
+ var labels = {
1661
+ queued: "Queued",
1662
+ running: "Processing",
1663
+ saving: "Saving result",
1664
+ succeeded: "Completed",
1665
+ failed: "Failed",
1666
+ canceled: "Canceled",
1667
+ interrupted: "Interrupted"
1668
+ };
1669
+ function MediaJobs({ onOpenResult }) {
1670
+ const { client, instanceId } = useMediaClient();
1671
+ const [page, setPage] = React6.useState({ items: [], nextOffset: null });
1672
+ const [offset, setOffset] = React6.useState(0);
1673
+ const [refresh, setRefresh] = React6.useState(0);
1674
+ const [error, setError] = React6.useState("");
1675
+ const [pending, setPending] = React6.useState(null);
1676
+ const keys = React6.useRef(/* @__PURE__ */ new Map());
1677
+ const live = React6.useRef(true);
1678
+ React6.useEffect(() => {
1679
+ live.current = true;
1680
+ return () => {
1681
+ live.current = false;
1682
+ };
1683
+ }, []);
1684
+ React6.useEffect(() => {
1685
+ let active = true, timer;
1686
+ async function poll() {
1687
+ try {
1688
+ const result = await client.invoke(
1689
+ { instanceId, operationId: "jobs.list" },
1690
+ { limit: 50, offset }
1691
+ );
1692
+ if (active) {
1693
+ setPage(result);
1694
+ setError("");
1695
+ }
1696
+ } catch (failure) {
1697
+ if (active) setError(readableError(failure));
1698
+ } finally {
1699
+ if (active) timer = setTimeout(() => void poll(), 1e3);
1700
+ }
1701
+ }
1702
+ void poll();
1703
+ return () => {
1704
+ active = false;
1705
+ if (timer) clearTimeout(timer);
1706
+ };
1707
+ }, [client, instanceId, offset, refresh]);
1708
+ async function act(job, action) {
1709
+ const identity = `${action}:${job.jobId}`;
1710
+ const key = keys.current.get(identity) || crypto.randomUUID();
1711
+ keys.current.set(identity, key);
1712
+ setPending(identity);
1713
+ setError("");
1714
+ try {
1715
+ if (action === "cancel")
1716
+ await client.invoke(
1717
+ { instanceId, operationId: "jobs.cancel" },
1718
+ { jobId: job.jobId },
1719
+ { requestKey: key }
1720
+ );
1721
+ else await submitOrFind(client, instanceId, job.retryRequest, key);
1722
+ keys.current.delete(identity);
1723
+ if (live.current) {
1724
+ setOffset(0);
1725
+ setRefresh((value) => value + 1);
1726
+ }
1727
+ } catch (failure) {
1728
+ if (requestRejected(failure)) keys.current.delete(identity);
1729
+ if (live.current) setError(readableError(failure));
1730
+ } finally {
1731
+ if (live.current) setPending(null);
1732
+ }
1733
+ }
1734
+ return /* @__PURE__ */ React6.createElement("section", { className: "mt-jobs", "aria-label": "Media tasks" }, /* @__PURE__ */ React6.createElement("div", { className: "mt-toolbar" }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("h2", null, "Media tasks"), /* @__PURE__ */ React6.createElement("p", { className: "mt-help" }, "Processing continues when this page closes.")), /* @__PURE__ */ React6.createElement(
1735
+ Button,
1736
+ {
1737
+ label: "Refresh tasks",
1738
+ variant: "text-ghost-sm",
1739
+ width: "hug",
1740
+ onClick: () => setRefresh(refresh + 1)
1741
+ }
1742
+ )), error && /* @__PURE__ */ React6.createElement("p", { role: "alert", className: "mt-error" }, error), !page.items.length && /* @__PURE__ */ React6.createElement("p", { className: "mt-empty" }, "No media tasks on this page."), page.items.map((job) => /* @__PURE__ */ React6.createElement("article", { className: "mt-job", key: job.jobId }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("strong", null, job.outputName), /* @__PURE__ */ React6.createElement("p", null, job.kind === "sequence" ? "Sequence export" : "Video processing", " \xB7", " ", job.cancelRequested && !["succeeded", "failed", "canceled", "interrupted"].includes(job.state) ? "Stopping\u2026" : labels[job.state]), job.cleanupPending && /* @__PURE__ */ React6.createElement("p", { className: "mt-error" }, "Cleanup is pending. New processing is blocked until the old process is confirmed stopped."), job.error && /* @__PURE__ */ React6.createElement("p", { className: "mt-error" }, job.error.message)), /* @__PURE__ */ React6.createElement("div", { className: "mt-job-progress" }, /* @__PURE__ */ React6.createElement(
1743
+ "progress",
1744
+ {
1745
+ "aria-label": `Progress for ${job.outputName}`,
1746
+ max: 1,
1747
+ value: job.state === "succeeded" ? 1 : job.progress === null ? void 0 : Math.min(0.99, job.progress)
1748
+ }
1749
+ ), /* @__PURE__ */ React6.createElement("span", null, job.state === "succeeded" ? "100%" : job.progress === null ? "Unknown progress" : `${Math.floor(Math.min(0.99, job.progress) * 100)}%`)), /* @__PURE__ */ React6.createElement("div", { className: "mt-column-actions" }, ["queued", "running", "saving"].includes(job.state) && /* @__PURE__ */ React6.createElement(
1750
+ Button,
1751
+ {
1752
+ label: "Cancel task",
1753
+ width: "hug",
1754
+ variant: "text-tonal-sm",
1755
+ disabled: pending !== null || job.cancelRequested,
1756
+ onClick: () => void act(job, "cancel")
1757
+ }
1758
+ ), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React6.createElement(
1759
+ Button,
1760
+ {
1761
+ label: "Retry task",
1762
+ width: "hug",
1763
+ variant: "text-tonal-sm",
1764
+ disabled: pending !== null || job.cleanupPending,
1765
+ onClick: () => void act(job, "retry")
1766
+ }
1767
+ ), job.result && onOpenResult && /* @__PURE__ */ React6.createElement(Button, { label: "Open result", width: "hug", onClick: () => onOpenResult(job.result) }), /* @__PURE__ */ React6.createElement("details", null, /* @__PURE__ */ React6.createElement("summary", null, "Task identity"), /* @__PURE__ */ React6.createElement("code", null, job.jobId))))), /* @__PURE__ */ React6.createElement("div", { className: "mt-pagination" }, /* @__PURE__ */ React6.createElement(
1768
+ Button,
1769
+ {
1770
+ label: "Previous tasks",
1771
+ variant: "text-ghost-sm",
1772
+ disabled: offset === 0,
1773
+ onClick: () => setOffset(Math.max(0, offset - 50))
1774
+ }
1775
+ ), /* @__PURE__ */ React6.createElement(
1776
+ Button,
1777
+ {
1778
+ label: "Next tasks",
1779
+ variant: "text-ghost-sm",
1780
+ disabled: page.nextOffset === null,
1781
+ onClick: () => {
1782
+ if (page.nextOffset !== null) setOffset(page.nextOffset);
1783
+ }
1784
+ }
1785
+ )));
1786
+ }
1787
+
1788
+ // packages/media-tools/src/client.tsx
1789
+ var dependencies = (config) => [
1790
+ config.dataInstance,
1791
+ config.studioInstance
1792
+ ];
1793
+ async function activate(client) {
1794
+ const description = await client.describe();
1795
+ const instances = description.instances.filter(
1796
+ (value) => value.pluginId === "media-tools" && value.state === "ready"
1797
+ );
1798
+ if (instances.length !== 1)
1799
+ throw Error("Exactly one ready media-tools instance is required per project.");
1800
+ const instanceId = instances[0].id;
1801
+ let active = true;
1802
+ let resolving = Promise.resolve();
1803
+ const resolve = (input) => {
1804
+ const next = resolving.then(() => {
1805
+ if (!active) throw Error("This media-tools instance has stopped.");
1806
+ return client.invoke(
1807
+ { instanceId, operationId: "video.resolve" },
1808
+ input
1809
+ );
1810
+ });
1811
+ resolving = next.then(
1812
+ () => void 0,
1813
+ () => void 0
1814
+ );
1815
+ return next;
1816
+ };
1817
+ client.provide({
1818
+ capabilityVersion: "media-tools/client/1",
1819
+ resolve,
1820
+ submit: (request, requestKey) => submitOrFind(client, instanceId, request, requestKey)
1821
+ });
1822
+ const listeners = /* @__PURE__ */ new Set();
1823
+ const subscribe = (listener) => {
1824
+ listeners.add(listener);
1825
+ return () => {
1826
+ listeners.delete(listener);
1827
+ };
1828
+ };
1829
+ function Bound({
1830
+ component: Component,
1831
+ props
1832
+ }) {
1833
+ const ready = React7.useSyncExternalStore(
1834
+ subscribe,
1835
+ () => active,
1836
+ () => active
1837
+ );
1838
+ return ready ? /* @__PURE__ */ React7.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React7.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React7.createElement(Component, { ...props }))) : null;
1839
+ }
1840
+ client.registerUI({
1841
+ id: "media.video-editor",
1842
+ title: "Video editor",
1843
+ kind: "component",
1844
+ component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: VideoEditor, props })
1845
+ });
1846
+ client.registerUI({
1847
+ id: "media.video-compare",
1848
+ title: "Video comparison",
1849
+ kind: "component",
1850
+ component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: VideoCompare, props })
1851
+ });
1852
+ client.registerUI({
1853
+ id: "media.jobs",
1854
+ title: "Media tasks",
1855
+ kind: "component",
1856
+ component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: MediaJobs, props })
1857
+ });
1858
+ client.onDispose(() => {
1859
+ active = false;
1860
+ for (const listener of listeners) listener();
1861
+ listeners.clear();
1862
+ });
1863
+ }
1864
+ export {
1865
+ Config,
1866
+ MediaJobs,
1867
+ VideoCompare,
1868
+ VideoEditor,
1869
+ activate as default,
1870
+ dependencies,
1871
+ submitOrFind
1872
+ };