@microfox/remotion 1.2.0 → 1.2.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,4519 @@
1
+ // src/core/registry/componentRegistry.ts
2
+ var ComponentRegistryManager = class {
3
+ constructor() {
4
+ this.registry = {};
5
+ this.packageRegistry = {};
6
+ }
7
+ registerComponent(name, component, type, config15 = { displayName: "" }, packageName) {
8
+ this.registry[name] = { component, config: config15 };
9
+ if (packageName) {
10
+ if (!this.packageRegistry[packageName]) {
11
+ this.packageRegistry[packageName] = {};
12
+ }
13
+ this.packageRegistry[packageName][name] = { component, config: config15 };
14
+ }
15
+ }
16
+ registerEffect(name, component, config15 = { displayName: "" }, packageName) {
17
+ this.registerComponent(
18
+ name?.includes("effect-") ? name : `effect-${name}`,
19
+ component,
20
+ "layout",
21
+ config15,
22
+ packageName
23
+ );
24
+ }
25
+ getComponent(name) {
26
+ return this.registry[name]?.component;
27
+ }
28
+ getComponentConfig(name) {
29
+ return this.registry[name]?.config;
30
+ }
31
+ getComponentWithConfig(name) {
32
+ return this.registry[name];
33
+ }
34
+ registerPackage(packageName, components) {
35
+ this.packageRegistry[packageName] = components;
36
+ Object.entries(components).forEach(([name, { component, config: config15 }]) => {
37
+ this.registry[`${packageName}:${name}`] = { component, config: config15 };
38
+ });
39
+ }
40
+ getPackageComponents(packageName) {
41
+ return this.packageRegistry[packageName];
42
+ }
43
+ getAllComponents() {
44
+ return { ...this.registry };
45
+ }
46
+ clear() {
47
+ this.registry = {};
48
+ this.packageRegistry = {};
49
+ }
50
+ };
51
+ var componentRegistry = new ComponentRegistryManager();
52
+ var registerComponent = (name, component, type, config15 = { displayName: "" }, packageName) => {
53
+ componentRegistry.registerComponent(
54
+ name,
55
+ component,
56
+ type,
57
+ config15,
58
+ packageName
59
+ );
60
+ };
61
+ var registerEffect = (name, component, config15 = { displayName: "" }, packageName) => {
62
+ componentRegistry.registerEffect(name, component, config15, packageName);
63
+ };
64
+ var registerPackage = (packageName, components) => {
65
+ componentRegistry.registerPackage(packageName, components);
66
+ };
67
+ var getComponent = (name) => componentRegistry.getComponent(name);
68
+ var getComponentConfig = (name) => componentRegistry.getComponentConfig(name);
69
+ var getComponentWithConfig = (name) => componentRegistry.getComponentWithConfig(name);
70
+
71
+ // src/core/context/CompositionContext.tsx
72
+ import React, { createContext, useContext } from "react";
73
+ var CompositionContext = createContext(null);
74
+ var CompositionProvider = ({ children, value }) => {
75
+ return /* @__PURE__ */ React.createElement(CompositionContext.Provider, { value }, children);
76
+ };
77
+ var useComposition = () => {
78
+ const context = useContext(CompositionContext);
79
+ if (!context) {
80
+ throw new Error("useComposition must be used within a CompositionProvider");
81
+ }
82
+ return context;
83
+ };
84
+
85
+ // src/core/context/timing.ts
86
+ import { ALL_FORMATS, Input, UrlSource } from "mediabunny";
87
+ var findMatchingComponents = (childrenData, targetIds) => {
88
+ const matches = [];
89
+ const searchRecursively = (components) => {
90
+ for (const component of components) {
91
+ if (targetIds.includes(component.id)) {
92
+ matches.push(component);
93
+ }
94
+ if (component.childrenData && component.childrenData.length > 0) {
95
+ searchRecursively(component.childrenData);
96
+ }
97
+ }
98
+ };
99
+ searchRecursively(childrenData);
100
+ return matches;
101
+ };
102
+ var findMatchingComponentsByQuery = (childrenData, query) => {
103
+ const matches = [];
104
+ const searchRecursively = (components) => {
105
+ for (const component of components) {
106
+ let matchesQuery = false;
107
+ if (query.type && component.type === query.type) {
108
+ matchesQuery = true;
109
+ }
110
+ if (query.componentId && component.componentId === query.componentId) {
111
+ matchesQuery = true;
112
+ }
113
+ if (query.type && query.componentId) {
114
+ matchesQuery = component.type === query.type && component.componentId === query.componentId;
115
+ }
116
+ if (matchesQuery) {
117
+ matches.push(component);
118
+ }
119
+ if (component.childrenData && component.childrenData.length > 0) {
120
+ searchRecursively(component.childrenData);
121
+ }
122
+ }
123
+ };
124
+ searchRecursively(childrenData);
125
+ return matches;
126
+ };
127
+ var calculateComponentDuration = async (component) => {
128
+ const src = component.data.src;
129
+ if (src.startsWith("http")) {
130
+ const audioInput = new Input({
131
+ formats: ALL_FORMATS,
132
+ source: new UrlSource(src)
133
+ });
134
+ const audioDuration = await audioInput.computeDuration();
135
+ let trimmedDuration = audioDuration;
136
+ if (component.data.startFrom || component.data.endAt) {
137
+ trimmedDuration = audioDuration - (component.data.startFrom || 0) - (component.data.endAt ? audioDuration - (component.data.endAt || 0) : 0);
138
+ }
139
+ const playbackRate = component.data.playbackRate || 1;
140
+ const effectiveDuration = trimmedDuration / playbackRate;
141
+ return effectiveDuration;
142
+ } else {
143
+ }
144
+ };
145
+ var calculateDuration = async (childrenData, config15) => {
146
+ let calculatedDuration = void 0;
147
+ const targetIds = Array.isArray(config15.fitDurationTo) ? config15.fitDurationTo : [config15.fitDurationTo];
148
+ const matchingComponents = findMatchingComponents(
149
+ childrenData || [],
150
+ targetIds
151
+ );
152
+ if (matchingComponents.length === 1) {
153
+ if (matchingComponents[0].type === "atom" && (matchingComponents[0].componentId === "AudioAtom" || matchingComponents[0].componentId === "VideoAtom")) {
154
+ calculatedDuration = await calculateComponentDuration(
155
+ matchingComponents[0]
156
+ );
157
+ }
158
+ if ((matchingComponents[0].type === "scene" || matchingComponents[0].type === "layout") && matchingComponents[0].context?.timing?.duration) {
159
+ calculatedDuration = matchingComponents[0].context.timing.duration;
160
+ }
161
+ }
162
+ return calculatedDuration;
163
+ };
164
+ var setDurationsInContext = async (root) => {
165
+ const iterateRecursively = async (components, onlyScene = false) => {
166
+ const updatedComponents = [];
167
+ for (const component of components) {
168
+ let updatedComponent = { ...component };
169
+ if (component.childrenData && component.childrenData.length > 0) {
170
+ updatedComponent.childrenData = await iterateRecursively(
171
+ component.childrenData,
172
+ onlyScene
173
+ );
174
+ }
175
+ if (updatedComponent.context?.timing?.fitDurationTo?.length > 0 && !onlyScene && updatedComponent.context?.timing?.fitDurationTo != updatedComponent.id && updatedComponent.context?.timing?.fitDurationTo != "this" && updatedComponent.context?.timing?.fitDurationTo != "fill") {
176
+ const duration = await calculateDuration(
177
+ updatedComponent.childrenData,
178
+ {
179
+ fitDurationTo: updatedComponent.context?.timing?.fitDurationTo
180
+ }
181
+ );
182
+ updatedComponent = {
183
+ ...updatedComponent,
184
+ context: {
185
+ ...updatedComponent.context,
186
+ timing: {
187
+ ...updatedComponent.context.timing,
188
+ duration
189
+ }
190
+ }
191
+ };
192
+ }
193
+ if ((updatedComponent.type === "scene" || updatedComponent.type === "layout") && onlyScene) {
194
+ let duration;
195
+ if (updatedComponent.context?.timing?.fitDurationTo && updatedComponent.context.timing.fitDurationTo !== updatedComponent.id && updatedComponent.context.timing.fitDurationTo !== "this") {
196
+ duration = await calculateDuration(updatedComponent.childrenData, {
197
+ fitDurationTo: updatedComponent.context.timing.fitDurationTo
198
+ });
199
+ } else if (!updatedComponent.context?.timing?.duration) {
200
+ duration = updatedComponent.childrenData.reduce(
201
+ (acc, child) => acc + (child.context?.timing?.duration ?? 0),
202
+ 0
203
+ ) ?? 10;
204
+ }
205
+ if (duration !== void 0) {
206
+ updatedComponent.context = {
207
+ ...updatedComponent.context || {},
208
+ timing: {
209
+ ...updatedComponent.context?.timing || {},
210
+ duration
211
+ }
212
+ };
213
+ }
214
+ }
215
+ if (updatedComponent.type === "atom" && !onlyScene) {
216
+ if (updatedComponent.componentId === "VideoAtom" || updatedComponent.componentId === "AudioAtom") {
217
+ const mediaDuration = await calculateComponentDuration(updatedComponent);
218
+ if (!updatedComponent.context?.timing?.fitDurationTo) {
219
+ updatedComponent.context = {
220
+ ...updatedComponent.context || {},
221
+ timing: {
222
+ ...updatedComponent.context?.timing || {},
223
+ duration: updatedComponent?.context?.timing?.duration || mediaDuration
224
+ }
225
+ };
226
+ updatedComponent.data = {
227
+ ...updatedComponent.data,
228
+ ...updatedComponent.data.loop ? { srcDuration: mediaDuration } : {}
229
+ };
230
+ } else if (updatedComponent.context?.timing?.fitDurationTo) {
231
+ updatedComponent.data = {
232
+ ...updatedComponent.data,
233
+ srcDuration: mediaDuration
234
+ };
235
+ }
236
+ }
237
+ }
238
+ updatedComponents.push(updatedComponent);
239
+ }
240
+ return updatedComponents;
241
+ };
242
+ let updatedChildrenData = await iterateRecursively(root.childrenData, false);
243
+ updatedChildrenData = await iterateRecursively(updatedChildrenData, true);
244
+ return {
245
+ ...root,
246
+ childrenData: updatedChildrenData
247
+ };
248
+ };
249
+
250
+ // src/components/base/ComponentRenderer.tsx
251
+ import React3, { createContext as createContext2, useContext as useContext2 } from "react";
252
+ import { Sequence, Series, useVideoConfig } from "remotion";
253
+
254
+ // src/core/utils/timing.ts
255
+ var calculateTiming = (type, context, videoConfig) => {
256
+ let newTiming;
257
+ if (type !== "atom" && context?.timing) {
258
+ const { start = 0, duration = 0 } = context.timing;
259
+ newTiming = {
260
+ startInFrames: Math.round(
261
+ context.timing?.startInFrames ? context.timing.startInFrames : type === "scene" ? start * videoConfig.fps : start * videoConfig.fps
262
+ ),
263
+ durationInFrames: Math.round(
264
+ context.timing?.durationInFrames ? context.timing.durationInFrames : type === "scene" ? duration * videoConfig.fps : duration * videoConfig.fps
265
+ ),
266
+ duration,
267
+ start
268
+ };
269
+ } else {
270
+ newTiming = {
271
+ startInFrames: context.timing?.startInFrames ? context.timing.startInFrames : context.timing?.start ? Math.round(videoConfig.fps * (context.timing.start || 0)) : 0,
272
+ durationInFrames: Math.round(
273
+ context.timing?.durationInFrames ? context.timing.durationInFrames : context.timing?.duration ? Math.round(videoConfig.fps * (context.timing.duration || 0)) : 0
274
+ ),
275
+ duration: context.timing?.duration,
276
+ start: context.timing?.start
277
+ };
278
+ }
279
+ return newTiming;
280
+ };
281
+
282
+ // src/core/utils/hierarchyUtils.ts
283
+ var findComponentById = (root, targetId) => {
284
+ if (!root) return null;
285
+ const search = (components) => {
286
+ for (const component of components) {
287
+ if (component.id === targetId) {
288
+ return component;
289
+ }
290
+ if (component.childrenData && component.childrenData.length > 0) {
291
+ const found = search(component.childrenData);
292
+ if (found) return found;
293
+ }
294
+ }
295
+ return null;
296
+ };
297
+ return search(root);
298
+ };
299
+ var findParentComponent = (root, targetId) => {
300
+ if (!root) return null;
301
+ const search = (components, parent) => {
302
+ for (const component of components) {
303
+ if (component.childrenData && component.childrenData.length > 0) {
304
+ const hasTargetChild = component.childrenData.some(
305
+ (child) => child.id === targetId
306
+ );
307
+ if (hasTargetChild) {
308
+ return component;
309
+ }
310
+ const found = search(component.childrenData, component);
311
+ if (found) return found;
312
+ }
313
+ }
314
+ return null;
315
+ };
316
+ return search(root, null);
317
+ };
318
+ var calculateHierarchy = (root, componentId, currentContext) => {
319
+ if (!root) {
320
+ return {
321
+ depth: (currentContext?.hierarchy?.depth || 0) + 1,
322
+ parentIds: [...currentContext?.hierarchy?.parentIds || [], componentId]
323
+ };
324
+ }
325
+ const parentIds = [];
326
+ let depth = 0;
327
+ const traverse = (components, currentDepth) => {
328
+ for (const component of components) {
329
+ if (component.id === componentId) {
330
+ depth = currentDepth;
331
+ return true;
332
+ }
333
+ if (component.childrenData && component.childrenData.length > 0) {
334
+ parentIds.push(component.id);
335
+ const found = traverse(component.childrenData, currentDepth + 1);
336
+ if (found) return true;
337
+ parentIds.pop();
338
+ }
339
+ }
340
+ return false;
341
+ };
342
+ traverse(root, 0);
343
+ return {
344
+ depth,
345
+ parentIds: [...parentIds]
346
+ };
347
+ };
348
+ var calculateTimingWithInheritance = (component, root, videoConfig) => {
349
+ const currentContext = component.context || {};
350
+ const baseTiming = calculateTiming(
351
+ component.type,
352
+ currentContext,
353
+ videoConfig
354
+ );
355
+ if (!baseTiming.durationInFrames || baseTiming.durationInFrames <= 0) {
356
+ const findParentWithTiming = (targetId) => {
357
+ const parent = findParentComponent(root, targetId);
358
+ if (!parent) return null;
359
+ const parentContext = parent.context || {};
360
+ const parentTiming = calculateTiming(
361
+ parent.type,
362
+ parentContext,
363
+ videoConfig
364
+ );
365
+ if (parentTiming.durationInFrames && parentTiming.durationInFrames > 0) {
366
+ return parentTiming;
367
+ }
368
+ return findParentWithTiming(parent.id);
369
+ };
370
+ const inheritedTiming = findParentWithTiming(component.id);
371
+ if (inheritedTiming) {
372
+ return {
373
+ ...baseTiming,
374
+ durationInFrames: inheritedTiming.durationInFrames ? inheritedTiming.durationInFrames : inheritedTiming.duration ? inheritedTiming.duration * videoConfig.fps : 0,
375
+ duration: inheritedTiming.duration
376
+ };
377
+ }
378
+ }
379
+ return baseTiming;
380
+ };
381
+
382
+ // src/components/base/EffectWrapper.tsx
383
+ import React2 from "react";
384
+ import { nanoid } from "zod";
385
+ var EffectWrapper = ({
386
+ effects,
387
+ children,
388
+ context
389
+ }) => {
390
+ if (!effects || effects.length === 0) {
391
+ return children;
392
+ }
393
+ let wrappedContent = children;
394
+ effects.forEach((effect, index) => {
395
+ const effectId = typeof effect === "string" ? `effect-${effect}` : `effect-${effect.componentId}`;
396
+ const EffectComponent = getComponent(effectId);
397
+ if (!EffectComponent) {
398
+ console.warn(`Effect component ${effectId} not found in registry`);
399
+ return;
400
+ }
401
+ const effectData = typeof effect === "string" ? {} : effect.data || {};
402
+ const effectContext = typeof effect === "string" ? context : effect.context || context;
403
+ const effectProps = {
404
+ id: typeof effect === "string" ? `effect-${nanoid()}` : effect.id,
405
+ componentId: effectId,
406
+ type: "layout",
407
+ // Effects use the same rendering logic as layout
408
+ data: effectData,
409
+ context: effectContext,
410
+ children: wrappedContent
411
+ };
412
+ wrappedContent = /* @__PURE__ */ React2.createElement(EffectComponent, { ...effectProps });
413
+ });
414
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, wrappedContent);
415
+ };
416
+
417
+ // src/components/base/ComponentRenderer.tsx
418
+ var RenderContext = createContext2(null);
419
+ var useRenderContext = () => {
420
+ const context = useContext2(RenderContext);
421
+ if (!context) {
422
+ throw new Error("useRenderContext must be used within a ComponentRenderer");
423
+ }
424
+ return context;
425
+ };
426
+ var ComponentRenderer = ({
427
+ id,
428
+ componentId,
429
+ type,
430
+ data,
431
+ childrenData,
432
+ context,
433
+ effects
434
+ }) => {
435
+ const videoConfig = useVideoConfig();
436
+ const { root } = useComposition();
437
+ const defaultContext = {
438
+ boundaries: {
439
+ left: 0,
440
+ top: 0,
441
+ width: videoConfig.width,
442
+ height: videoConfig.height,
443
+ zIndex: 0
444
+ },
445
+ timing: {
446
+ startInFrames: 0,
447
+ durationInFrames: videoConfig.durationInFrames
448
+ },
449
+ hierarchy: {
450
+ depth: 0,
451
+ parentIds: []
452
+ }
453
+ };
454
+ if (!context) {
455
+ context = {};
456
+ }
457
+ const newHierarchy = calculateHierarchy(root, id, context ?? defaultContext);
458
+ const componentData = {
459
+ id,
460
+ componentId,
461
+ type,
462
+ data,
463
+ childrenData,
464
+ context,
465
+ effects
466
+ };
467
+ let newTiming = calculateTimingWithInheritance(componentData, root, videoConfig);
468
+ const newContext = {
469
+ ...context,
470
+ boundaries: context?.boundaries,
471
+ hierarchy: newHierarchy,
472
+ timing: newTiming
473
+ };
474
+ const ComponentClass = getComponent(componentId);
475
+ if (type === "scene") {
476
+ return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(Series, null, childrenData?.map((child) => {
477
+ const childTiming = calculateTimingWithInheritance(child, root, videoConfig);
478
+ return /* @__PURE__ */ React3.createElement(
479
+ Series.Sequence,
480
+ {
481
+ key: child.id,
482
+ name: child.componentId + " - " + child.id,
483
+ offset: childTiming.startInFrames ?? 0,
484
+ durationInFrames: childTiming.durationInFrames ?? 0
485
+ },
486
+ child.effects && child.effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects: child.effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })) : /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })
487
+ );
488
+ })));
489
+ }
490
+ if (!ComponentClass) {
491
+ console.warn(`Component type ${id} not found in registry`);
492
+ return null;
493
+ }
494
+ const props = {
495
+ id,
496
+ componentId,
497
+ data,
498
+ context
499
+ };
500
+ if (type === "layout") {
501
+ const config15 = getComponentConfig(componentId);
502
+ const isInnerSequence = config15?.isInnerSequence;
503
+ if (isInnerSequence) {
504
+ return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child }))) : childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child }))));
505
+ }
506
+ return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(Sequence, { layout: "none", name: componentId + " - " + id, from: newTiming.startInFrames, durationInFrames: newTiming.durationInFrames }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }, childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })))) : /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }, childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })))));
507
+ }
508
+ if (type === "atom") {
509
+ if (newTiming.durationInFrames && newTiming.durationInFrames > 0) {
510
+ return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(Sequence, { layout: "none", name: componentId + " - " + id, from: newTiming.startInFrames, durationInFrames: newTiming.durationInFrames }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...{
511
+ ...props,
512
+ context: {
513
+ timing: {
514
+ durationInFrames: newTiming.durationInFrames
515
+ }
516
+ }
517
+ } })) : /* @__PURE__ */ React3.createElement(ComponentClass, { ...{
518
+ ...props,
519
+ context: {
520
+ timing: {
521
+ durationInFrames: newTiming.durationInFrames
522
+ }
523
+ }
524
+ } })));
525
+ }
526
+ return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props })) : /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }));
527
+ }
528
+ };
529
+
530
+ // src/components/frames/Frame.tsx
531
+ import React4 from "react";
532
+ import { AbsoluteFill } from "remotion";
533
+ var Frame = ({ children, data }) => {
534
+ return /* @__PURE__ */ React4.createElement(AbsoluteFill, { style: data?.style }, children);
535
+ };
536
+
537
+ // src/components/frames/SceneFrame.tsx
538
+ import React5 from "react";
539
+ import { AbsoluteFill as AbsoluteFill2 } from "remotion";
540
+ var SceneFrame = ({ children }) => {
541
+ return /* @__PURE__ */ React5.createElement(AbsoluteFill2, null, children);
542
+ };
543
+
544
+ // src/components/layouts/BaseLayout.tsx
545
+ import React13, { Children, useMemo as useMemo7 } from "react";
546
+ import { AbsoluteFill as AbsoluteFill3 } from "remotion";
547
+
548
+ // src/components/effects/BlurEffect.tsx
549
+ import React7, { useMemo as useMemo2 } from "react";
550
+
551
+ // src/components/effects/UniversalEffect.tsx
552
+ import React6, { useMemo, createContext as createContext3, useContext as useContext3 } from "react";
553
+
554
+ // src/components/effects/mergeCSSStyles.ts
555
+ var parseFunctionsString = (functions) => {
556
+ const result = /* @__PURE__ */ new Map();
557
+ if (!functions) {
558
+ return result;
559
+ }
560
+ const regex = /(\w+)\(([^)]*)\)/g;
561
+ let match;
562
+ while ((match = regex.exec(functions)) !== null) {
563
+ result.set(match[1], match[0]);
564
+ }
565
+ return result;
566
+ };
567
+ var mergeFunctionStrings = (parentValue, childValue, preferParentOnOverlap) => {
568
+ const parentFunctions = parseFunctionsString(parentValue);
569
+ const childFunctions = parseFunctionsString(childValue);
570
+ const orderedFunctionNames = [];
571
+ parentFunctions.forEach((_v, k) => orderedFunctionNames.push(k));
572
+ childFunctions.forEach((_v, k) => {
573
+ if (!orderedFunctionNames.includes(k)) {
574
+ orderedFunctionNames.push(k);
575
+ }
576
+ });
577
+ const finalFunctions = orderedFunctionNames.map((name) => {
578
+ if (preferParentOnOverlap && parentFunctions.has(name)) {
579
+ return parentFunctions.get(name);
580
+ }
581
+ return childFunctions.get(name) ?? parentFunctions.get(name);
582
+ });
583
+ return finalFunctions.join(" ").trim();
584
+ };
585
+ var mergeCSSStyles = (parent = {}, child = {}, options = {}) => {
586
+ const result = { ...parent };
587
+ const preferParentOnOverlap = Boolean(options.preferParentOnOverlap);
588
+ for (const key in child) {
589
+ if (Object.prototype.hasOwnProperty.call(child, key)) {
590
+ const pValue = result[key];
591
+ const cValue = child[key];
592
+ if (cValue === void 0 || cValue === null) {
593
+ continue;
594
+ }
595
+ switch (key) {
596
+ case "transform":
597
+ case "filter": {
598
+ result[key] = mergeFunctionStrings(
599
+ pValue,
600
+ cValue,
601
+ preferParentOnOverlap
602
+ );
603
+ break;
604
+ }
605
+ case "opacity":
606
+ if (preferParentOnOverlap && pValue !== void 0 && cValue !== void 0) {
607
+ const parentOpacity = typeof pValue === "number" && !isNaN(pValue) ? pValue : 1;
608
+ result.opacity = Math.max(0, Math.min(1, parentOpacity));
609
+ } else {
610
+ const parentOpacity = typeof pValue === "number" && !isNaN(pValue) ? pValue : 1;
611
+ const childOpacity = typeof cValue === "number" && !isNaN(cValue) ? cValue : 1;
612
+ result.opacity = Math.max(
613
+ 0,
614
+ Math.min(1, parentOpacity * childOpacity)
615
+ );
616
+ }
617
+ break;
618
+ case "transformOrigin":
619
+ result.transformOrigin = cValue;
620
+ break;
621
+ case "color":
622
+ case "backgroundColor":
623
+ result[key] = cValue;
624
+ break;
625
+ default:
626
+ if (preferParentOnOverlap && pValue !== void 0) {
627
+ result[key] = pValue;
628
+ } else {
629
+ result[key] = cValue;
630
+ }
631
+ break;
632
+ }
633
+ }
634
+ }
635
+ if (result.transform === "") {
636
+ delete result.transform;
637
+ }
638
+ if (result.filter === "") {
639
+ delete result.filter;
640
+ }
641
+ return result;
642
+ };
643
+ var mergeCSSStyles_default = mergeCSSStyles;
644
+
645
+ // src/components/effects/UniversalEffect.tsx
646
+ import { useCurrentFrame, useVideoConfig as useVideoConfig2, interpolate, Easing } from "remotion";
647
+ var UniversalEffectContext = createContext3(null);
648
+ var useUniversalEffect = () => {
649
+ const context = useContext3(UniversalEffectContext);
650
+ if (!context) {
651
+ throw new Error("useUniversalEffect must be used within a UniversalEffectProvider");
652
+ }
653
+ return context;
654
+ };
655
+ var useUniversalEffectOptional = () => {
656
+ return useContext3(UniversalEffectContext);
657
+ };
658
+ var useHasUniversalEffectProvider = () => {
659
+ const context = useContext3(UniversalEffectContext);
660
+ return context !== null;
661
+ };
662
+ var parseDuration = (duration, contextDuration, fps) => {
663
+ if (!duration) return contextDuration;
664
+ if (typeof duration === "number") {
665
+ return duration * fps;
666
+ }
667
+ if (typeof duration === "string" && duration.endsWith("%")) {
668
+ const percentage = parseFloat(duration.replace("%", "")) / 100;
669
+ return Math.floor(contextDuration * percentage);
670
+ }
671
+ return contextDuration;
672
+ };
673
+ var parseDelay = (delay, contextDuration, fps) => {
674
+ if (!delay) return 0;
675
+ if (typeof delay === "number") {
676
+ return delay * fps;
677
+ }
678
+ if (typeof delay === "string" && delay.endsWith("%")) {
679
+ const percentage = parseFloat(delay) / 100;
680
+ return Math.floor(contextDuration * percentage);
681
+ }
682
+ return 0;
683
+ };
684
+ var getEasingFunction = (type) => {
685
+ switch (type) {
686
+ case "linear":
687
+ return Easing.linear;
688
+ case "ease-in":
689
+ return Easing.in(Easing.ease);
690
+ case "ease-out":
691
+ return Easing.out(Easing.ease);
692
+ case "ease-in-out":
693
+ return Easing.inOut(Easing.ease);
694
+ default:
695
+ return Easing.linear;
696
+ }
697
+ };
698
+ var parseHexColor = (hex) => {
699
+ hex = hex.replace("#", "").toLowerCase();
700
+ if (!/^[0-9a-f]+$/.test(hex)) {
701
+ return { r: 0, g: 0, b: 0, a: 1 };
702
+ }
703
+ if (hex.length === 3) {
704
+ hex = hex.split("").map((char) => char + char).join("");
705
+ }
706
+ if (hex.length === 6) {
707
+ return {
708
+ r: Math.max(0, Math.min(255, parseInt(hex.substr(0, 2), 16))),
709
+ g: Math.max(0, Math.min(255, parseInt(hex.substr(2, 2), 16))),
710
+ b: Math.max(0, Math.min(255, parseInt(hex.substr(4, 2), 16))),
711
+ a: 1
712
+ };
713
+ }
714
+ if (hex.length === 8) {
715
+ return {
716
+ r: Math.max(0, Math.min(255, parseInt(hex.substr(0, 2), 16))),
717
+ g: Math.max(0, Math.min(255, parseInt(hex.substr(2, 2), 16))),
718
+ b: Math.max(0, Math.min(255, parseInt(hex.substr(4, 2), 16))),
719
+ a: Math.max(0, Math.min(1, parseInt(hex.substr(6, 2), 16) / 255))
720
+ };
721
+ }
722
+ return { r: 0, g: 0, b: 0, a: 1 };
723
+ };
724
+ var parseRgbaColor = (rgba) => {
725
+ const match = rgba.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);
726
+ if (match) {
727
+ return {
728
+ r: Math.max(0, Math.min(255, parseInt(match[1], 10))),
729
+ g: Math.max(0, Math.min(255, parseInt(match[2], 10))),
730
+ b: Math.max(0, Math.min(255, parseInt(match[3], 10))),
731
+ a: match[4] ? Math.max(0, Math.min(1, parseFloat(match[4]))) : 1
732
+ };
733
+ }
734
+ return { r: 0, g: 0, b: 0, a: 1 };
735
+ };
736
+ var parseColor = (color) => {
737
+ const trimmedColor = color.trim();
738
+ if (trimmedColor.startsWith("#")) {
739
+ return parseHexColor(trimmedColor);
740
+ } else if (trimmedColor.toLowerCase().startsWith("rgb")) {
741
+ return parseRgbaColor(trimmedColor);
742
+ }
743
+ return { r: 0, g: 0, b: 0, a: 1 };
744
+ };
745
+ var rgbaToString = (color) => {
746
+ if (color.a === 1) {
747
+ return `rgb(${Math.round(color.r)}, ${Math.round(color.g)}, ${Math.round(color.b)})`;
748
+ } else {
749
+ return `rgba(${Math.round(color.r)}, ${Math.round(color.g)}, ${Math.round(color.b)}, ${color.a})`;
750
+ }
751
+ };
752
+ var interpolateColors = (color1, color2, progress) => {
753
+ const parsedColor1 = parseColor(color1);
754
+ const parsedColor2 = parseColor(color2);
755
+ const interpolatedColor = {
756
+ r: interpolate(progress, [0, 1], [parsedColor1.r, parsedColor2.r]),
757
+ g: interpolate(progress, [0, 1], [parsedColor1.g, parsedColor2.g]),
758
+ b: interpolate(progress, [0, 1], [parsedColor1.b, parsedColor2.b]),
759
+ a: interpolate(progress, [0, 1], [parsedColor1.a, parsedColor2.a])
760
+ };
761
+ return rgbaToString(interpolatedColor);
762
+ };
763
+ var calculateAnimatedValue = (ranges, progress, key) => {
764
+ const sortedRanges = [...ranges].sort((a, b) => a.prog - b.prog);
765
+ if (sortedRanges.length === 0) return 0;
766
+ if (sortedRanges.length === 1) return sortedRanges[0].val;
767
+ const clampedProgress = Math.max(0, Math.min(1, progress));
768
+ if (clampedProgress <= sortedRanges[0].prog) {
769
+ return sortedRanges[0].val;
770
+ }
771
+ if (clampedProgress >= sortedRanges[sortedRanges.length - 1].prog) {
772
+ return sortedRanges[sortedRanges.length - 1].val;
773
+ }
774
+ for (let i = 0; i < sortedRanges.length - 1; i++) {
775
+ const currentRange = sortedRanges[i];
776
+ const nextRange = sortedRanges[i + 1];
777
+ if (clampedProgress >= currentRange.prog && clampedProgress <= nextRange.prog) {
778
+ const localProgress = (clampedProgress - currentRange.prog) / (nextRange.prog - currentRange.prog);
779
+ const currentValue = currentRange.val;
780
+ const nextValue = nextRange.val;
781
+ if (typeof currentValue === "number" && typeof nextValue === "number") {
782
+ if (isFinite(currentValue) && isFinite(nextValue) && !isNaN(currentValue) && !isNaN(nextValue)) {
783
+ const interpolatedValue = currentValue + (nextValue - currentValue) * localProgress;
784
+ if (isFinite(interpolatedValue) && !isNaN(interpolatedValue)) {
785
+ return interpolatedValue;
786
+ }
787
+ }
788
+ return currentValue;
789
+ } else if (typeof currentValue === "string" && typeof nextValue === "string") {
790
+ const isColor = (str) => {
791
+ const trimmed = str.trim().toLowerCase();
792
+ return trimmed.startsWith("#") || trimmed.startsWith("rgb");
793
+ };
794
+ if (isColor(currentValue) && isColor(nextValue)) {
795
+ return interpolateColors(currentValue, nextValue, localProgress);
796
+ }
797
+ const getUnitAndValue = (str) => {
798
+ const units = ["vmax", "vmin", "rem", "deg", "bpm", "vh", "vw", "px", "em", "ms", "hz", "db", "fr", "s", "%"];
799
+ for (const unit of units) {
800
+ if (str.endsWith(unit)) {
801
+ const value2 = parseFloat(str.slice(0, -unit.length));
802
+ return {
803
+ value: isNaN(value2) ? 0 : value2,
804
+ unit
805
+ };
806
+ }
807
+ }
808
+ const value = parseFloat(str);
809
+ return {
810
+ value: isNaN(value) ? 0 : value,
811
+ unit: ""
812
+ };
813
+ };
814
+ const current = getUnitAndValue(currentValue);
815
+ const next = getUnitAndValue(nextValue);
816
+ if (current.unit === next.unit && isFinite(current.value) && isFinite(next.value)) {
817
+ const interpolatedValue = interpolate(localProgress, [0, 1], [current.value, next.value]);
818
+ if (isFinite(interpolatedValue)) {
819
+ return current.unit ? `${interpolatedValue}${current.unit}` : interpolatedValue;
820
+ }
821
+ }
822
+ return currentValue;
823
+ }
824
+ return currentValue;
825
+ }
826
+ }
827
+ return sortedRanges[0]?.val || 0;
828
+ };
829
+ var rangesToCSSProperties = (ranges, progress) => {
830
+ const styles = {};
831
+ if (!ranges || !Array.isArray(ranges) || ranges.length === 0) {
832
+ return styles;
833
+ }
834
+ const rangesByKey = ranges.reduce((acc, range) => {
835
+ if (!acc[range.key]) {
836
+ acc[range.key] = [];
837
+ }
838
+ acc[range.key].push(range);
839
+ return acc;
840
+ }, {});
841
+ Object.entries(rangesByKey).forEach(([key, keyRanges]) => {
842
+ const value = calculateAnimatedValue(keyRanges, progress, key);
843
+ switch (key) {
844
+ case "scale":
845
+ styles.transform = `scale(${value})`;
846
+ break;
847
+ case "rotate":
848
+ const rotateValue = typeof value === "string" && value.includes("deg") ? value : `${value}deg`;
849
+ styles.transform = `${styles.transform || ""} rotate(${rotateValue})`.trim();
850
+ break;
851
+ case "translateX":
852
+ const translateXValue = typeof value === "string" && (value.includes("px") || value.includes("%") || value.includes("vw") || value.includes("vh")) ? value : `${value}px`;
853
+ styles.transform = `${styles.transform || ""} translateX(${translateXValue})`.trim();
854
+ break;
855
+ case "translateY":
856
+ const translateYValue = typeof value === "string" && (value.includes("px") || value.includes("%") || value.includes("vw") || value.includes("vh")) ? value : `${value}px`;
857
+ styles.transform = `${styles.transform || ""} translateY(${translateYValue})`.trim();
858
+ break;
859
+ case "opacity":
860
+ const opacityValue = typeof value === "number" ? Math.max(0, Math.min(1, isFinite(value) && !isNaN(value) ? Math.round(value * 1e3) / 1e3 : 1)) : 1;
861
+ styles.opacity = opacityValue;
862
+ break;
863
+ case "blur":
864
+ const blurValue = typeof value === "string" && (value.includes("px") || value.includes("rem") || value.includes("em")) ? value : `${value}px`;
865
+ styles.filter = `blur(${blurValue})`;
866
+ break;
867
+ case "brightness":
868
+ styles.filter = `${styles.filter || ""} brightness(${value})`.trim();
869
+ break;
870
+ case "contrast":
871
+ styles.filter = `${styles.filter || ""} contrast(${value})`.trim();
872
+ break;
873
+ case "filter":
874
+ styles.filter = value;
875
+ break;
876
+ case "color":
877
+ styles.color = value;
878
+ break;
879
+ case "backgroundColor":
880
+ styles.backgroundColor = value;
881
+ break;
882
+ default:
883
+ styles[key] = value;
884
+ }
885
+ });
886
+ return styles;
887
+ };
888
+ var useUniversalAnimation = (data, context) => {
889
+ let frame = 0;
890
+ let fps = 30;
891
+ try {
892
+ frame = useCurrentFrame();
893
+ const videoConfig = useVideoConfig2();
894
+ fps = videoConfig.fps;
895
+ } catch (error) {
896
+ console.warn("useUniversalAnimation used outside Remotion context, using fallback values");
897
+ }
898
+ const effectData = data;
899
+ const { timing } = context ?? {};
900
+ const contextDuration = timing?.durationInFrames || 50;
901
+ const start = parseDelay(effectData?.start, contextDuration, fps);
902
+ const duration = parseDuration(effectData?.duration, contextDuration, fps);
903
+ const type = effectData?.type || "linear";
904
+ const ranges = effectData?.ranges || [];
905
+ const targetIds = effectData?.targetIds || [];
906
+ const mode = effectData?.mode || "wrapper";
907
+ const easing = getEasingFunction(type);
908
+ const progress = interpolate(
909
+ frame - start,
910
+ [0, duration],
911
+ [0, 1],
912
+ {
913
+ easing,
914
+ extrapolateLeft: "clamp",
915
+ extrapolateRight: "clamp"
916
+ }
917
+ );
918
+ const isActive = frame >= start && frame <= start + duration;
919
+ const isBeforeStart = frame < start;
920
+ const isAfterEnd = frame > start + duration;
921
+ return {
922
+ frame,
923
+ fps,
924
+ progress,
925
+ isActive,
926
+ isBeforeStart,
927
+ isAfterEnd,
928
+ start,
929
+ duration,
930
+ type,
931
+ ranges,
932
+ targetIds,
933
+ mode,
934
+ effectData
935
+ };
936
+ };
937
+ var UniversalEffect = ({
938
+ id,
939
+ data,
940
+ children,
941
+ context,
942
+ effectType = "universal",
943
+ customAnimationLogic
944
+ }) => {
945
+ const { progress, isActive, isBeforeStart, isAfterEnd, frame, ranges, mode, targetIds, effectData } = useUniversalAnimation(data, context);
946
+ const parentContext = useUniversalEffectOptional();
947
+ const animatedStyles = useMemo(() => {
948
+ const parentStyles = parentContext?.animatedStyles || {};
949
+ let currentStyles = {};
950
+ if (isActive) {
951
+ if (customAnimationLogic) {
952
+ currentStyles = customAnimationLogic(effectData, progress, frame);
953
+ } else if (ranges.length > 0) {
954
+ currentStyles = rangesToCSSProperties(ranges, progress);
955
+ }
956
+ } else if (isBeforeStart) {
957
+ if (customAnimationLogic) {
958
+ currentStyles = customAnimationLogic(effectData, 0, frame);
959
+ } else if (ranges.length > 0) {
960
+ currentStyles = rangesToCSSProperties(ranges, 0);
961
+ }
962
+ } else if (isAfterEnd) {
963
+ if (customAnimationLogic) {
964
+ currentStyles = customAnimationLogic(effectData, 1, frame);
965
+ } else if (ranges.length > 0) {
966
+ currentStyles = rangesToCSSProperties(ranges, 1);
967
+ }
968
+ }
969
+ const preferParentOnOverlap = progress <= 0;
970
+ if (parentContext && mode === "provider") {
971
+ const combinedStyles = mergeCSSStyles_default(
972
+ parentStyles,
973
+ currentStyles,
974
+ { preferParentOnOverlap: false }
975
+ );
976
+ return combinedStyles;
977
+ }
978
+ return currentStyles;
979
+ }, [ranges, progress, parentContext?.animatedStyles, mode, customAnimationLogic, effectData, frame]);
980
+ const contextValue = useMemo(() => ({
981
+ animatedStyles,
982
+ targetIds,
983
+ effectType
984
+ }), [animatedStyles, targetIds, effectType]);
985
+ if (mode === "provider") {
986
+ return /* @__PURE__ */ React6.createElement(UniversalEffectContext.Provider, { value: contextValue }, children);
987
+ } else {
988
+ return /* @__PURE__ */ React6.createElement("div", { ...effectData.props, style: animatedStyles }, children);
989
+ }
990
+ };
991
+ var UniversalEffectProvider = ({
992
+ children,
993
+ data,
994
+ effectType = "universal",
995
+ customAnimationLogic,
996
+ id = "generic",
997
+ componentId = "generic",
998
+ type = "effect"
999
+ }) => {
1000
+ return /* @__PURE__ */ React6.createElement(
1001
+ UniversalEffect,
1002
+ {
1003
+ id,
1004
+ componentId,
1005
+ type,
1006
+ data,
1007
+ context: void 0,
1008
+ effectType,
1009
+ customAnimationLogic
1010
+ },
1011
+ children
1012
+ );
1013
+ };
1014
+ var useAnimatedStyles = (componentId) => {
1015
+ const context = useUniversalEffectOptional();
1016
+ if (!context) {
1017
+ return {};
1018
+ }
1019
+ const { animatedStyles, targetIds } = context;
1020
+ if (targetIds.includes(componentId)) {
1021
+ return animatedStyles;
1022
+ }
1023
+ return {};
1024
+ };
1025
+ var config = {
1026
+ displayName: "generic",
1027
+ description: "Universal effect that can be extended for any effect type",
1028
+ isInnerSequence: false,
1029
+ props: {}
1030
+ };
1031
+
1032
+ // src/components/effects/BlurEffect.tsx
1033
+ var BlurEffect = ({
1034
+ id,
1035
+ componentId,
1036
+ type,
1037
+ data,
1038
+ children,
1039
+ context
1040
+ }) => {
1041
+ const { progress, mode, targetIds, effectData } = useUniversalAnimation(data, context);
1042
+ const { intensity = 10, direction = "in" } = effectData;
1043
+ const parentContext = useUniversalEffectOptional();
1044
+ const animatedStyles = useMemo2(() => {
1045
+ if (progress <= 0 || progress >= 1) {
1046
+ return {};
1047
+ }
1048
+ const blurValue = direction === "in" ? intensity * (1 - progress) : intensity * progress;
1049
+ const currentStyles = { filter: `blur(${blurValue}px)` };
1050
+ if (parentContext && mode === "provider") {
1051
+ const combinedStyles = mergeCSSStyles_default(parentContext.animatedStyles, currentStyles);
1052
+ return combinedStyles;
1053
+ }
1054
+ return currentStyles;
1055
+ }, [progress, intensity, direction, parentContext?.animatedStyles, mode]);
1056
+ const contextValue = useMemo2(() => ({
1057
+ animatedStyles,
1058
+ targetIds,
1059
+ effectType: "blur"
1060
+ }), [animatedStyles, targetIds]);
1061
+ if (mode === "provider") {
1062
+ return /* @__PURE__ */ React7.createElement(UniversalEffectContext.Provider, { value: contextValue }, children);
1063
+ }
1064
+ return /* @__PURE__ */ React7.createElement("div", { ...effectData.props, style: animatedStyles }, children);
1065
+ };
1066
+ var config2 = {
1067
+ displayName: "blur",
1068
+ description: "Blur effect with configurable intensity and direction",
1069
+ isInnerSequence: false,
1070
+ props: {
1071
+ intensity: {
1072
+ type: "number",
1073
+ default: 10,
1074
+ description: "Blur intensity in pixels"
1075
+ },
1076
+ direction: {
1077
+ type: "enum",
1078
+ values: ["in", "out"],
1079
+ default: "in",
1080
+ description: "Blur direction (in = start blurred, out = end blurred)"
1081
+ }
1082
+ }
1083
+ };
1084
+
1085
+ // src/components/effects/Loop.tsx
1086
+ import React8 from "react";
1087
+ import { Loop } from "remotion";
1088
+ var LoopEffect = ({
1089
+ data,
1090
+ children,
1091
+ context
1092
+ }) => {
1093
+ const { timing } = context ?? {};
1094
+ const loopData = data;
1095
+ const durationInFrames = loopData?.durationInFrames || timing?.durationInFrames || 50;
1096
+ const times = loopData?.times ?? Infinity;
1097
+ const layout = loopData?.layout || "absolute-fill";
1098
+ return (
1099
+ // @ts-ignore
1100
+ /* @__PURE__ */ React8.createElement(
1101
+ Loop,
1102
+ {
1103
+ durationInFrames,
1104
+ times,
1105
+ layout
1106
+ },
1107
+ /* @__PURE__ */ React8.createElement(React8.Fragment, null, children)
1108
+ )
1109
+ );
1110
+ };
1111
+ var config3 = {
1112
+ displayName: "loop",
1113
+ type: "layout",
1114
+ isInnerSequence: false,
1115
+ props: {
1116
+ durationInFrames: {
1117
+ type: "number",
1118
+ description: "How many frames one iteration of the loop should be long",
1119
+ default: 50
1120
+ },
1121
+ times: {
1122
+ type: "number",
1123
+ description: "How many times to loop the content (defaults to Infinity)",
1124
+ default: void 0
1125
+ },
1126
+ layout: {
1127
+ type: "string",
1128
+ description: 'Either "absolute-fill" (default) or "none"',
1129
+ default: "absolute-fill"
1130
+ }
1131
+ }
1132
+ };
1133
+
1134
+ // src/components/effects/Pan.tsx
1135
+ import React9, { useMemo as useMemo3 } from "react";
1136
+ import { useCurrentFrame as useCurrentFrame2, useVideoConfig as useVideoConfig3, interpolate as interpolate2, spring, Easing as Easing2 } from "remotion";
1137
+ var parseDuration2 = (duration, contextDuration, fps) => {
1138
+ if (!duration) return contextDuration;
1139
+ if (typeof duration === "number") {
1140
+ return duration * fps;
1141
+ }
1142
+ if (typeof duration === "string" && duration.endsWith("%")) {
1143
+ const percentage = parseFloat(duration.replace("%", "")) / 100;
1144
+ return Math.floor(contextDuration * percentage);
1145
+ }
1146
+ return contextDuration;
1147
+ };
1148
+ var parseDelay2 = (delay, contextDuration, fps) => {
1149
+ if (!delay) return 0;
1150
+ if (typeof delay === "number") {
1151
+ return delay * fps;
1152
+ }
1153
+ if (typeof delay === "string" && delay.endsWith("%")) {
1154
+ const percentage = parseFloat(delay) / 100;
1155
+ return Math.floor(contextDuration * percentage);
1156
+ }
1157
+ return 0;
1158
+ };
1159
+ var getPanDistance = (progress, panDistance) => {
1160
+ if (typeof panDistance === "number") {
1161
+ return panDistance;
1162
+ }
1163
+ if (Array.isArray(panDistance)) {
1164
+ if (panDistance.length === 0) return 0;
1165
+ if (panDistance.length === 1) return panDistance[0][1];
1166
+ for (let i = 0; i < panDistance.length - 1; i++) {
1167
+ const [currentProgress, currentDistance] = panDistance[i];
1168
+ const [nextProgress, nextDistance] = panDistance[i + 1];
1169
+ if (progress >= currentProgress && progress <= nextProgress) {
1170
+ const localProgress = (progress - currentProgress) / (nextProgress - currentProgress);
1171
+ return interpolate2(localProgress, [0, 1], [currentDistance, nextDistance]);
1172
+ }
1173
+ }
1174
+ return panDistance[panDistance.length - 1][1];
1175
+ }
1176
+ return 0;
1177
+ };
1178
+ var getPosition = (position) => {
1179
+ if (!position) return [0.5, 0.5];
1180
+ if (Array.isArray(position)) {
1181
+ return position;
1182
+ }
1183
+ const positions = {
1184
+ "top-left": [0, 0],
1185
+ "top": [0.5, 0],
1186
+ "top-right": [1, 0],
1187
+ "left": [0, 0.5],
1188
+ "center": [0.5, 0.5],
1189
+ "right": [1, 0.5],
1190
+ "bottom-left": [0, 1],
1191
+ "bottom": [0.5, 1],
1192
+ "bottom-right": [1, 1]
1193
+ };
1194
+ return positions[position] || [0.5, 0.5];
1195
+ };
1196
+ var getEasingFunction2 = (animationType) => {
1197
+ switch (animationType) {
1198
+ case "linear":
1199
+ return Easing2.linear;
1200
+ case "ease-in":
1201
+ return Easing2.in(Easing2.ease);
1202
+ case "ease-out":
1203
+ return Easing2.out(Easing2.ease);
1204
+ case "ease-in-out":
1205
+ return Easing2.inOut(Easing2.ease);
1206
+ default:
1207
+ return Easing2.linear;
1208
+ }
1209
+ };
1210
+ var getPanVector = (direction, distance) => {
1211
+ switch (direction) {
1212
+ case "left":
1213
+ return [-distance, 0];
1214
+ case "right":
1215
+ return [distance, 0];
1216
+ case "up":
1217
+ return [0, -distance];
1218
+ case "down":
1219
+ return [0, distance];
1220
+ case "diagonal":
1221
+ return [distance * 0.707, distance * 0.707];
1222
+ // 45-degree diagonal
1223
+ default:
1224
+ return [0, 0];
1225
+ }
1226
+ };
1227
+ var PanEffect = ({
1228
+ data,
1229
+ children,
1230
+ context
1231
+ }) => {
1232
+ const frame = useCurrentFrame2();
1233
+ const { fps } = useVideoConfig3();
1234
+ const panData = data;
1235
+ const { timing } = context ?? {};
1236
+ const contextDuration = timing?.durationInFrames || 50;
1237
+ const effectTiming = panData?.effectTiming || "start";
1238
+ const panDuration = parseDuration2(panData?.panDuration, contextDuration, fps);
1239
+ const panStartDelay = parseDelay2(panData?.panStartDelay, contextDuration, fps);
1240
+ const panEndDelay = parseDelay2(panData?.panEndDelay, contextDuration, fps);
1241
+ const panDirection = panData?.panDirection || "right";
1242
+ let panDistance = panData?.panDistance || 100;
1243
+ const loopTimes = panData?.loopTimes || 0;
1244
+ const panStartPosition = getPosition(panData?.panStartPosition);
1245
+ const panEndPosition = getPosition(panData?.panEndPosition);
1246
+ const animationType = panData?.animationType || "linear";
1247
+ if (loopTimes > 0 && typeof panDistance === "number") {
1248
+ const loopedPanDistance = [];
1249
+ for (let i = 0; i < loopTimes; i++) {
1250
+ const loopProgress = i / loopTimes;
1251
+ const nextLoopProgress = (i + 1) / loopTimes;
1252
+ loopedPanDistance.push([loopProgress, 0]);
1253
+ loopedPanDistance.push([loopProgress + (nextLoopProgress - loopProgress) * 0.5, panDistance]);
1254
+ loopedPanDistance.push([nextLoopProgress, 0]);
1255
+ }
1256
+ panDistance = loopedPanDistance;
1257
+ }
1258
+ let progress;
1259
+ if (animationType === "spring") {
1260
+ progress = spring({
1261
+ frame,
1262
+ fps,
1263
+ config: {
1264
+ stiffness: 100,
1265
+ damping: 10,
1266
+ mass: 1
1267
+ },
1268
+ durationInFrames: panDuration,
1269
+ delay: effectTiming === "start" ? panStartDelay : contextDuration - panEndDelay - panDuration
1270
+ });
1271
+ } else {
1272
+ let animationFrame;
1273
+ if (effectTiming === "start") {
1274
+ animationFrame = frame - panStartDelay;
1275
+ } else {
1276
+ animationFrame = frame - (contextDuration - panEndDelay - panDuration);
1277
+ }
1278
+ const easing = getEasingFunction2(animationType);
1279
+ progress = interpolate2(
1280
+ animationFrame,
1281
+ [0, panDuration],
1282
+ [0, 1],
1283
+ {
1284
+ easing,
1285
+ extrapolateLeft: "clamp",
1286
+ extrapolateRight: "clamp"
1287
+ }
1288
+ );
1289
+ }
1290
+ let panOffset;
1291
+ if (panDirection === "custom") {
1292
+ const [startX, startY] = panStartPosition;
1293
+ const [endX, endY] = panEndPosition;
1294
+ const offsetX = (endX - startX) * 100;
1295
+ const offsetY = (endY - startY) * 100;
1296
+ panOffset = [
1297
+ interpolate2(progress, [0, 1], [0, offsetX]),
1298
+ interpolate2(progress, [0, 1], [0, offsetY])
1299
+ ];
1300
+ } else {
1301
+ const distance = getPanDistance(progress, panDistance);
1302
+ const [vectorX, vectorY] = getPanVector(panDirection, distance);
1303
+ panOffset = [vectorX, vectorY];
1304
+ }
1305
+ const style = useMemo3(() => {
1306
+ return {
1307
+ width: "100%",
1308
+ height: "100%",
1309
+ transform: `translate(${panOffset[0]}px, ${panOffset[1]}px)`
1310
+ };
1311
+ }, [panOffset]);
1312
+ return /* @__PURE__ */ React9.createElement("div", { style }, children);
1313
+ };
1314
+ var config4 = {
1315
+ displayName: "pan",
1316
+ type: "layout",
1317
+ isInnerSequence: false,
1318
+ props: {
1319
+ effectTiming: {
1320
+ type: "string",
1321
+ description: 'When the pan effect should occur: "start" or "end"',
1322
+ default: "start"
1323
+ },
1324
+ panDuration: {
1325
+ type: "string",
1326
+ description: 'Duration of the pan animation in seconds or percentage (e.g., "2" or "50%")',
1327
+ default: void 0
1328
+ },
1329
+ panStart: {
1330
+ type: "number",
1331
+ description: "Start time of pan in seconds",
1332
+ default: 0
1333
+ },
1334
+ panEnd: {
1335
+ type: "number",
1336
+ description: "End time of pan in seconds",
1337
+ default: void 0
1338
+ },
1339
+ panStartDelay: {
1340
+ type: "string",
1341
+ description: "Delay before pan starts in seconds or percentage",
1342
+ default: 0
1343
+ },
1344
+ panEndDelay: {
1345
+ type: "string",
1346
+ description: "Delay before video ends in seconds or percentage",
1347
+ default: 0
1348
+ },
1349
+ panDirection: {
1350
+ type: "string",
1351
+ description: 'Direction of pan: "left", "right", "up", "down", "diagonal", or "custom"',
1352
+ default: "right"
1353
+ },
1354
+ panDistance: {
1355
+ type: "string",
1356
+ description: "Pan distance in pixels or array of [progress, distance] pairs",
1357
+ default: 100
1358
+ },
1359
+ panStartPosition: {
1360
+ type: "string",
1361
+ description: "Starting position: [x, y] coordinates or position string (top-left, center, etc.)",
1362
+ default: "center"
1363
+ },
1364
+ panEndPosition: {
1365
+ type: "string",
1366
+ description: "Ending position: [x, y] coordinates or position string (top-left, center, etc.)",
1367
+ default: "center"
1368
+ },
1369
+ animationType: {
1370
+ type: "string",
1371
+ description: 'Animation curve: "linear", "spring", "ease-in", "ease-out", "ease-in-out"',
1372
+ default: "linear"
1373
+ }
1374
+ }
1375
+ };
1376
+
1377
+ // src/components/effects/Zoom.tsx
1378
+ import React10, { useMemo as useMemo4 } from "react";
1379
+ import { useCurrentFrame as useCurrentFrame3, useVideoConfig as useVideoConfig4, interpolate as interpolate3, spring as spring2, Easing as Easing3 } from "remotion";
1380
+ var parseDuration3 = (duration, contextDuration, fps) => {
1381
+ if (!duration) return contextDuration;
1382
+ if (typeof duration === "number") {
1383
+ return duration * fps;
1384
+ }
1385
+ if (typeof duration === "string" && duration.endsWith("%")) {
1386
+ const percentage = parseFloat(duration.replace("%", "")) / 100;
1387
+ return Math.floor(contextDuration * percentage);
1388
+ }
1389
+ return contextDuration;
1390
+ };
1391
+ var parseDelay3 = (delay, contextDuration, fps) => {
1392
+ if (!delay) return 0;
1393
+ if (typeof delay === "number") {
1394
+ return delay * fps;
1395
+ }
1396
+ if (typeof delay === "string" && delay.endsWith("%")) {
1397
+ const percentage = parseFloat(delay) / 100;
1398
+ return Math.floor(contextDuration * percentage);
1399
+ }
1400
+ return 0;
1401
+ };
1402
+ var getZoomScale = (progress, zoomDepth) => {
1403
+ if (typeof zoomDepth === "number") {
1404
+ return zoomDepth;
1405
+ }
1406
+ if (Array.isArray(zoomDepth)) {
1407
+ if (zoomDepth.length === 0) return 1;
1408
+ if (zoomDepth.length === 1) return zoomDepth[0][1];
1409
+ for (let i = 0; i < zoomDepth.length - 1; i++) {
1410
+ const [currentProgress, currentScale] = zoomDepth[i];
1411
+ const [nextProgress, nextScale] = zoomDepth[i + 1];
1412
+ if (progress >= currentProgress && progress <= nextProgress) {
1413
+ const localProgress = (progress - currentProgress) / (nextProgress - currentProgress);
1414
+ return interpolate3(localProgress, [0, 1], [currentScale, nextScale]);
1415
+ }
1416
+ }
1417
+ return zoomDepth[zoomDepth.length - 1][1];
1418
+ }
1419
+ return 1;
1420
+ };
1421
+ var getZoomPosition = (position) => {
1422
+ if (!position) return [0.5, 0.5];
1423
+ if (Array.isArray(position)) {
1424
+ return position;
1425
+ }
1426
+ const positions = {
1427
+ "top-left": [0, 0],
1428
+ "top": [0.5, 0],
1429
+ "top-right": [1, 0],
1430
+ "left": [0, 0.5],
1431
+ "center": [0.5, 0.5],
1432
+ "right": [1, 0.5],
1433
+ "bottom-left": [0, 1],
1434
+ "bottom": [0.5, 1],
1435
+ "bottom-right": [1, 1]
1436
+ };
1437
+ return positions[position] || [0.5, 0.5];
1438
+ };
1439
+ var getEasingFunction3 = (animationType) => {
1440
+ switch (animationType) {
1441
+ case "linear":
1442
+ return Easing3.linear;
1443
+ case "ease-in":
1444
+ return Easing3.in(Easing3.ease);
1445
+ case "ease-out":
1446
+ return Easing3.out(Easing3.ease);
1447
+ case "ease-in-out":
1448
+ return Easing3.inOut(Easing3.ease);
1449
+ default:
1450
+ return Easing3.linear;
1451
+ }
1452
+ };
1453
+ var ZoomEffect = ({
1454
+ data,
1455
+ children,
1456
+ context
1457
+ }) => {
1458
+ const frame = useCurrentFrame3();
1459
+ const { fps } = useVideoConfig4();
1460
+ const zoomData = data;
1461
+ const { timing } = context ?? {};
1462
+ const contextDuration = timing?.durationInFrames || 50;
1463
+ const effectTiming = zoomData?.effectTiming || "start";
1464
+ const zoomDuration = parseDuration3(zoomData?.zoomDuration, contextDuration, fps);
1465
+ const zoomStartDelay = parseDelay3(zoomData?.zoomStartDelay, contextDuration, fps);
1466
+ const zoomEndDelay = parseDelay3(zoomData?.zoomEndDelay, contextDuration, fps);
1467
+ const zoomDirection = zoomData?.zoomDirection || "in";
1468
+ let zoomDepth = zoomData?.zoomDepth || 1.5;
1469
+ const loopTimes = zoomData?.loopTimes || 0;
1470
+ if (loopTimes > 1 && Array.isArray(zoomDepth)) {
1471
+ const loopedZoomDepth = [];
1472
+ for (let i = 0; i < loopTimes; i++) {
1473
+ const loopProgress = i / loopTimes;
1474
+ const nextLoopProgress = (i + 1) / loopTimes;
1475
+ zoomDepth.forEach(([x, y]) => {
1476
+ const mappedX = loopProgress + x * (nextLoopProgress - loopProgress);
1477
+ loopedZoomDepth.push([mappedX, y]);
1478
+ });
1479
+ }
1480
+ zoomDepth = loopedZoomDepth;
1481
+ } else if (loopTimes > 0 && typeof zoomDepth === "number") {
1482
+ const loopedZoomDepth = [];
1483
+ for (let i = 0; i < loopTimes; i++) {
1484
+ const loopProgress = i / loopTimes;
1485
+ const nextLoopProgress = (i + 1) / loopTimes;
1486
+ loopedZoomDepth.push([loopProgress, 1]);
1487
+ loopedZoomDepth.push([loopProgress + (nextLoopProgress - loopProgress) * 0.5, zoomDepth]);
1488
+ loopedZoomDepth.push([nextLoopProgress, 1]);
1489
+ }
1490
+ zoomDepth = loopedZoomDepth;
1491
+ }
1492
+ const zoomPosition = getZoomPosition(zoomData?.zoomPosition);
1493
+ const animationType = zoomData?.animationType || "linear";
1494
+ let progress;
1495
+ if (animationType === "spring") {
1496
+ progress = spring2({
1497
+ frame,
1498
+ fps,
1499
+ config: {
1500
+ stiffness: 100,
1501
+ damping: 10,
1502
+ mass: 1
1503
+ },
1504
+ durationInFrames: zoomDuration,
1505
+ delay: effectTiming === "start" ? zoomStartDelay : contextDuration - zoomEndDelay - zoomDuration
1506
+ });
1507
+ } else {
1508
+ let animationFrame;
1509
+ if (effectTiming === "start") {
1510
+ animationFrame = frame - zoomStartDelay;
1511
+ } else {
1512
+ animationFrame = frame - (contextDuration - zoomEndDelay - zoomDuration);
1513
+ }
1514
+ const easing = getEasingFunction3(animationType);
1515
+ progress = interpolate3(
1516
+ animationFrame,
1517
+ [0, zoomDuration],
1518
+ [0, 1],
1519
+ {
1520
+ easing,
1521
+ extrapolateLeft: "clamp",
1522
+ extrapolateRight: "clamp"
1523
+ }
1524
+ );
1525
+ }
1526
+ let scale;
1527
+ if (typeof zoomDepth === "number") {
1528
+ const baseScale = zoomDirection === "in" ? 1 : zoomDepth;
1529
+ const targetScale = zoomDirection === "in" ? zoomDepth : 1;
1530
+ scale = interpolate3(progress, [0, 1], [baseScale, targetScale]);
1531
+ } else if (Array.isArray(zoomDepth)) {
1532
+ scale = getZoomScale(progress, zoomDepth);
1533
+ } else {
1534
+ const baseScale = zoomDirection === "in" ? 1 : 1.5;
1535
+ const targetScale = zoomDirection === "in" ? 1.5 : 1;
1536
+ scale = interpolate3(progress, [0, 1], [baseScale, targetScale]);
1537
+ }
1538
+ const [originX, originY] = zoomPosition;
1539
+ const transformOrigin = `${originX * 100}% ${originY * 100}%`;
1540
+ const style = useMemo4(() => {
1541
+ return {
1542
+ width: "100%",
1543
+ height: "100%",
1544
+ transform: `scale(${scale})`,
1545
+ transformOrigin
1546
+ };
1547
+ }, [scale, transformOrigin]);
1548
+ return /* @__PURE__ */ React10.createElement("div", { style }, children);
1549
+ };
1550
+ var config5 = {
1551
+ displayName: "zoom",
1552
+ type: "layout",
1553
+ isInnerSequence: false,
1554
+ props: {
1555
+ effectTiming: {
1556
+ type: "string",
1557
+ description: 'When the zoom effect should occur: "start" or "end"',
1558
+ default: "start"
1559
+ },
1560
+ zoomDuration: {
1561
+ type: "string",
1562
+ description: 'Duration of the zoom animation in seconds or percentage (e.g., "2" or "50%")',
1563
+ default: void 0
1564
+ },
1565
+ zoomStart: {
1566
+ type: "number",
1567
+ description: "Start time of zoom in seconds",
1568
+ default: 0
1569
+ },
1570
+ zoomEnd: {
1571
+ type: "number",
1572
+ description: "End time of zoom in seconds",
1573
+ default: void 0
1574
+ },
1575
+ zoomStartDelay: {
1576
+ type: "string",
1577
+ description: "Delay before zoom starts in seconds or percentage",
1578
+ default: 0
1579
+ },
1580
+ zoomEndDelay: {
1581
+ type: "string",
1582
+ description: "Delay before video ends in seconds or percentage",
1583
+ default: 0
1584
+ },
1585
+ zoomDirection: {
1586
+ type: "string",
1587
+ description: 'Direction of zoom: "in" or "out"',
1588
+ default: "in"
1589
+ },
1590
+ zoomDepth: {
1591
+ type: "string",
1592
+ description: "Zoom scale factor or array of [progress, scale] pairs",
1593
+ default: 1.5
1594
+ },
1595
+ zoomPosition: {
1596
+ type: "string",
1597
+ description: "Zoom anchor point: [x, y] coordinates or position string (top-left, center, etc.)",
1598
+ default: "center"
1599
+ },
1600
+ animationType: {
1601
+ type: "string",
1602
+ description: 'Animation curve: "linear", "spring", "ease-in", "ease-out", "ease-in-out"',
1603
+ default: "linear"
1604
+ }
1605
+ }
1606
+ };
1607
+
1608
+ // src/components/effects/Shake.tsx
1609
+ import React11, { useMemo as useMemo5 } from "react";
1610
+ var ShakeEffect = ({
1611
+ id,
1612
+ componentId,
1613
+ type,
1614
+ data,
1615
+ children,
1616
+ context
1617
+ }) => {
1618
+ const { progress, frame, mode, targetIds, effectData } = useUniversalAnimation(data, context);
1619
+ const { amplitude = 10, frequency = 0.1, decay = true, axis = "both" } = effectData;
1620
+ const parentContext = useUniversalEffectOptional();
1621
+ const animatedStyles = useMemo5(() => {
1622
+ if (progress <= 0 || progress >= 1) {
1623
+ return parentContext?.animatedStyles || {};
1624
+ }
1625
+ const decayFactor = decay ? 1 - progress : 1;
1626
+ const currentAmplitude = amplitude * decayFactor;
1627
+ const time = frame * frequency;
1628
+ const shakeX = axis === "x" || axis === "both" ? Math.sin(time) * currentAmplitude : 0;
1629
+ const shakeY = axis === "y" || axis === "both" ? Math.cos(time * 1.3) * currentAmplitude : 0;
1630
+ const styles = {};
1631
+ if (axis === "x" || axis === "both") {
1632
+ styles.transform = `translateX(${shakeX}px)`;
1633
+ }
1634
+ if (axis === "y" || axis === "both") {
1635
+ styles.transform = `${styles.transform || ""} translateY(${shakeY}px)`.trim();
1636
+ }
1637
+ if (parentContext && mode === "provider") {
1638
+ const combinedStyles = mergeCSSStyles_default(parentContext.animatedStyles, styles);
1639
+ return combinedStyles;
1640
+ }
1641
+ return styles;
1642
+ }, [progress, frame, amplitude, frequency, decay, axis, id, targetIds, mode, parentContext?.animatedStyles]);
1643
+ const contextValue = useMemo5(() => ({
1644
+ animatedStyles,
1645
+ targetIds,
1646
+ effectType: "shake"
1647
+ }), [animatedStyles, targetIds]);
1648
+ if (mode === "provider") {
1649
+ return /* @__PURE__ */ React11.createElement(UniversalEffectContext.Provider, { value: contextValue }, children);
1650
+ }
1651
+ return /* @__PURE__ */ React11.createElement("div", { ...effectData.props, style: animatedStyles }, children);
1652
+ };
1653
+ var config6 = {
1654
+ displayName: "shake",
1655
+ description: "Shake effect with configurable amplitude, frequency, and decay",
1656
+ isInnerSequence: false,
1657
+ props: {
1658
+ amplitude: {
1659
+ type: "number",
1660
+ default: 10,
1661
+ description: "Shake intensity in pixels"
1662
+ },
1663
+ frequency: {
1664
+ type: "number",
1665
+ default: 0.1,
1666
+ description: "Shake frequency (higher = faster shake)"
1667
+ },
1668
+ decay: {
1669
+ type: "boolean",
1670
+ default: true,
1671
+ description: "Whether shake should decay over time"
1672
+ },
1673
+ axis: {
1674
+ type: "enum",
1675
+ values: ["x", "y", "both"],
1676
+ default: "both",
1677
+ description: "Which axis to shake"
1678
+ }
1679
+ }
1680
+ };
1681
+
1682
+ // src/components/effects/StretchEffect.tsx
1683
+ import React12, { useMemo as useMemo6 } from "react";
1684
+ import { spring as spring3 } from "remotion";
1685
+ var StretchEffect = ({
1686
+ id,
1687
+ componentId,
1688
+ type,
1689
+ data,
1690
+ children,
1691
+ context
1692
+ }) => {
1693
+ const { fps, frame, mode, targetIds, effectData, start, duration } = useUniversalAnimation(data, context);
1694
+ const { stretchFrom = 0.8, stretchTo = 1, springConfig } = effectData;
1695
+ const parentContext = useUniversalEffectOptional();
1696
+ const springProgress = spring3({
1697
+ fps,
1698
+ frame: frame - start,
1699
+ config: {
1700
+ stiffness: 100,
1701
+ damping: 10,
1702
+ mass: 1,
1703
+ ...springConfig
1704
+ },
1705
+ durationInFrames: duration
1706
+ });
1707
+ const animatedStyles = useMemo6(() => {
1708
+ if (springProgress <= 0 || springProgress >= 1) {
1709
+ return parentContext?.animatedStyles || {};
1710
+ }
1711
+ const scaleX = springProgress * (stretchTo - stretchFrom) + stretchFrom;
1712
+ const scaleY = 1 + (1 - scaleX) * 0.1;
1713
+ const currentStyles = {
1714
+ transform: `scaleX(${scaleX}) scaleY(${scaleY})`,
1715
+ transformOrigin: "center"
1716
+ };
1717
+ if (parentContext && mode === "provider") {
1718
+ const combinedStyles = mergeCSSStyles_default(parentContext.animatedStyles, currentStyles);
1719
+ return combinedStyles;
1720
+ }
1721
+ return currentStyles;
1722
+ }, [springProgress, stretchFrom, stretchTo, parentContext?.animatedStyles, mode]);
1723
+ const contextValue = useMemo6(() => ({
1724
+ animatedStyles,
1725
+ targetIds,
1726
+ effectType: "stretch"
1727
+ }), [animatedStyles, targetIds]);
1728
+ if (mode === "provider") {
1729
+ return /* @__PURE__ */ React12.createElement(UniversalEffectContext.Provider, { value: contextValue }, children);
1730
+ }
1731
+ return /* @__PURE__ */ React12.createElement("div", { ...effectData.props, style: animatedStyles }, children);
1732
+ };
1733
+ var config7 = {
1734
+ displayName: "stretch",
1735
+ description: "Stretches a component with a spring motion, ideal for subtitles.",
1736
+ isInnerSequence: false,
1737
+ props: {
1738
+ stretchFrom: {
1739
+ type: "number",
1740
+ default: 0.8,
1741
+ description: "The initial horizontal scale of the component."
1742
+ },
1743
+ stretchTo: {
1744
+ type: "number",
1745
+ default: 1,
1746
+ description: "The final horizontal scale of the component."
1747
+ }
1748
+ }
1749
+ };
1750
+
1751
+ // src/components/effects/GenericPresets.ts
1752
+ var fadeInPreset = [
1753
+ { key: "opacity", val: 0, prog: 0 },
1754
+ { key: "opacity", val: 1, prog: 1 }
1755
+ ];
1756
+ var fadeOutPreset = [
1757
+ { key: "opacity", val: 1, prog: 0 },
1758
+ { key: "opacity", val: 0, prog: 1 }
1759
+ ];
1760
+ var scaleInPreset = [
1761
+ { key: "scale", val: 0, prog: 0 },
1762
+ { key: "scale", val: 1, prog: 1 }
1763
+ ];
1764
+ var scaleOutPreset = [
1765
+ { key: "scale", val: 1, prog: 0 },
1766
+ { key: "scale", val: 0, prog: 1 }
1767
+ ];
1768
+ var slideInLeftPreset = [
1769
+ { key: "translateX", val: -100, prog: 0 },
1770
+ { key: "translateX", val: 0, prog: 1 }
1771
+ ];
1772
+ var slideInRightPreset = [
1773
+ { key: "translateX", val: 100, prog: 0 },
1774
+ { key: "translateX", val: 0, prog: 1 }
1775
+ ];
1776
+ var slideInTopPreset = [
1777
+ { key: "translateY", val: -100, prog: 0 },
1778
+ { key: "translateY", val: 0, prog: 1 }
1779
+ ];
1780
+ var slideInBottomPreset = [
1781
+ { key: "translateY", val: 100, prog: 0 },
1782
+ { key: "translateY", val: 0, prog: 1 }
1783
+ ];
1784
+ var bouncePreset = [
1785
+ { key: "scale", val: 0, prog: 0 },
1786
+ { key: "scale", val: 1.2, prog: 0.6 },
1787
+ { key: "scale", val: 1, prog: 1 }
1788
+ ];
1789
+ var pulsePreset = [
1790
+ { key: "scale", val: 1, prog: 0 },
1791
+ { key: "scale", val: 1.1, prog: 0.5 },
1792
+ { key: "scale", val: 1, prog: 1 }
1793
+ ];
1794
+ var rotateInPreset = [
1795
+ { key: "rotate", val: -180, prog: 0 },
1796
+ { key: "rotate", val: 0, prog: 1 }
1797
+ ];
1798
+ var blurInPreset = [
1799
+ { key: "blur", val: 10, prog: 0 },
1800
+ { key: "blur", val: 0, prog: 1 }
1801
+ ];
1802
+ var fadeInScalePreset = [
1803
+ { key: "opacity", val: 0, prog: 0 },
1804
+ { key: "opacity", val: 1, prog: 1 },
1805
+ { key: "scale", val: 0.8, prog: 0 },
1806
+ { key: "scale", val: 1, prog: 1 }
1807
+ ];
1808
+ var slideInFadePreset = [
1809
+ { key: "translateX", val: -50, prog: 0 },
1810
+ { key: "translateX", val: 0, prog: 1 },
1811
+ { key: "opacity", val: 0, prog: 0 },
1812
+ { key: "opacity", val: 1, prog: 1 }
1813
+ ];
1814
+ var slideInLeftStringPreset = [
1815
+ { key: "translateX", val: "-100px", prog: 0 },
1816
+ { key: "translateX", val: "0px", prog: 1 }
1817
+ ];
1818
+ var slideInRightStringPreset = [
1819
+ { key: "translateX", val: "100px", prog: 0 },
1820
+ { key: "translateX", val: "0px", prog: 1 }
1821
+ ];
1822
+ var slideInTopStringPreset = [
1823
+ { key: "translateY", val: "-100px", prog: 0 },
1824
+ { key: "translateY", val: "0px", prog: 1 }
1825
+ ];
1826
+ var slideInBottomStringPreset = [
1827
+ { key: "translateY", val: "100px", prog: 0 },
1828
+ { key: "translateY", val: "0px", prog: 1 }
1829
+ ];
1830
+ var rotateInStringPreset = [
1831
+ { key: "rotate", val: "-180deg", prog: 0 },
1832
+ { key: "rotate", val: "0deg", prog: 1 }
1833
+ ];
1834
+ var blurInStringPreset = [
1835
+ { key: "blur", val: "10px", prog: 0 },
1836
+ { key: "blur", val: "0px", prog: 1 }
1837
+ ];
1838
+ var scaleInStringPreset = [
1839
+ { key: "scale", val: 0, prog: 0 },
1840
+ { key: "scale", val: 1, prog: 1 }
1841
+ ];
1842
+ var slideInLeftResponsivePreset = [
1843
+ { key: "translateX", val: "-50vw", prog: 0 },
1844
+ { key: "translateX", val: "0vw", prog: 1 }
1845
+ ];
1846
+ var slideInTopResponsivePreset = [
1847
+ { key: "translateY", val: "-50vh", prog: 0 },
1848
+ { key: "translateY", val: "0vh", prog: 1 }
1849
+ ];
1850
+ var backgroundColorPreset = [
1851
+ { key: "backgroundColor", val: "#ff0000", prog: 0 },
1852
+ { key: "backgroundColor", val: "#0000ff", prog: 1 }
1853
+ ];
1854
+ var borderRadiusPreset = [
1855
+ { key: "borderRadius", val: "0px", prog: 0 },
1856
+ { key: "borderRadius", val: "50px", prog: 1 }
1857
+ ];
1858
+ var boxShadowPreset = [
1859
+ { key: "boxShadow", val: "0px 0px 0px rgba(0,0,0,0)", prog: 0 },
1860
+ { key: "boxShadow", val: "10px 10px 20px rgba(0,0,0,0.5)", prog: 1 }
1861
+ ];
1862
+ var fontSizePreset = [
1863
+ { key: "fontSize", val: "12px", prog: 0 },
1864
+ { key: "fontSize", val: "24px", prog: 1 }
1865
+ ];
1866
+ var letterSpacingPreset = [
1867
+ { key: "letterSpacing", val: "0px", prog: 0 },
1868
+ { key: "letterSpacing", val: "5px", prog: 1 }
1869
+ ];
1870
+ var lineHeightPreset = [
1871
+ { key: "lineHeight", val: "1", prog: 0 },
1872
+ { key: "lineHeight", val: "2", prog: 1 }
1873
+ ];
1874
+ var textShadowPreset = [
1875
+ { key: "textShadow", val: "0px 0px 0px rgba(0,0,0,0)", prog: 0 },
1876
+ { key: "textShadow", val: "2px 2px 4px rgba(0,0,0,0.5)", prog: 1 }
1877
+ ];
1878
+ var widthPreset = [
1879
+ { key: "width", val: "0px", prog: 0 },
1880
+ { key: "width", val: "100%", prog: 1 }
1881
+ ];
1882
+ var heightPreset = [
1883
+ { key: "height", val: "0px", prog: 0 },
1884
+ { key: "height", val: "100%", prog: 1 }
1885
+ ];
1886
+ var marginPreset = [
1887
+ { key: "margin", val: "0px", prog: 0 },
1888
+ { key: "margin", val: "20px", prog: 1 }
1889
+ ];
1890
+ var paddingPreset = [
1891
+ { key: "padding", val: "0px", prog: 0 },
1892
+ { key: "padding", val: "20px", prog: 1 }
1893
+ ];
1894
+ var morphingCardPreset = [
1895
+ { key: "borderRadius", val: "0px", prog: 0 },
1896
+ { key: "borderRadius", val: "20px", prog: 0.5 },
1897
+ { key: "borderRadius", val: "50px", prog: 1 },
1898
+ { key: "boxShadow", val: "0px 0px 0px rgba(0,0,0,0)", prog: 0 },
1899
+ { key: "boxShadow", val: "0px 10px 30px rgba(0,0,0,0.3)", prog: 1 },
1900
+ { key: "backgroundColor", val: "#ffffff", prog: 0 },
1901
+ { key: "backgroundColor", val: "#f0f0f0", prog: 1 }
1902
+ ];
1903
+ var textRevealPreset = [
1904
+ { key: "opacity", val: 0, prog: 0 },
1905
+ { key: "opacity", val: 1, prog: 1 },
1906
+ { key: "letterSpacing", val: "10px", prog: 0 },
1907
+ { key: "letterSpacing", val: "0px", prog: 1 },
1908
+ { key: "textShadow", val: "0px 0px 0px rgba(0,0,0,0)", prog: 0 },
1909
+ { key: "textShadow", val: "2px 2px 4px rgba(0,0,0,0.5)", prog: 1 }
1910
+ ];
1911
+ var GenericEffectPresets = {
1912
+ fadeInPreset,
1913
+ fadeOutPreset,
1914
+ scaleInPreset,
1915
+ scaleOutPreset,
1916
+ slideInLeftPreset,
1917
+ slideInRightPreset,
1918
+ slideInTopPreset,
1919
+ slideInBottomPreset,
1920
+ bouncePreset,
1921
+ pulsePreset,
1922
+ rotateInPreset,
1923
+ blurInPreset,
1924
+ fadeInScalePreset,
1925
+ slideInFadePreset,
1926
+ // String-based presets
1927
+ slideInLeftStringPreset,
1928
+ slideInRightStringPreset,
1929
+ slideInTopStringPreset,
1930
+ slideInBottomStringPreset,
1931
+ rotateInStringPreset,
1932
+ blurInStringPreset,
1933
+ scaleInStringPreset,
1934
+ slideInLeftResponsivePreset,
1935
+ slideInTopResponsivePreset,
1936
+ // Custom CSS property presets
1937
+ backgroundColorPreset,
1938
+ borderRadiusPreset,
1939
+ boxShadowPreset,
1940
+ fontSizePreset,
1941
+ letterSpacingPreset,
1942
+ lineHeightPreset,
1943
+ textShadowPreset,
1944
+ widthPreset,
1945
+ heightPreset,
1946
+ marginPreset,
1947
+ paddingPreset,
1948
+ morphingCardPreset,
1949
+ textRevealPreset
1950
+ };
1951
+
1952
+ // src/components/effects/index.ts
1953
+ registerEffect(config2.displayName, BlurEffect, config2);
1954
+ registerEffect(config3.displayName, LoopEffect, config3);
1955
+ registerEffect(config4.displayName, PanEffect, config4);
1956
+ registerEffect(config5.displayName, ZoomEffect, config5);
1957
+ registerEffect("generic", UniversalEffect, config);
1958
+ registerEffect(config6.displayName, ShakeEffect, config6);
1959
+ registerEffect(
1960
+ config7.displayName,
1961
+ StretchEffect,
1962
+ config7
1963
+ );
1964
+
1965
+ // src/components/layouts/BaseLayout.tsx
1966
+ var Layout = ({ id, children, data, context }) => {
1967
+ const { containerProps = {}, childrenProps = [], repeatChildrenProps = {} } = data;
1968
+ const overrideStyles = useAnimatedStyles(id);
1969
+ const childrenArray = Children.toArray(children);
1970
+ const enhancedStyle = useMemo7(
1971
+ () => ({
1972
+ ...!context?.boundaries?.reset ? context?.boundaries : {},
1973
+ ...containerProps.style,
1974
+ ...overrideStyles
1975
+ }),
1976
+ [
1977
+ !context?.boundaries?.reset ? context?.boundaries : {},
1978
+ containerProps.style,
1979
+ overrideStyles
1980
+ ]
1981
+ );
1982
+ if (Object.keys(repeatChildrenProps).length <= 0 && childrenProps.length <= 0) {
1983
+ if (data.isAbsoluteFill) {
1984
+ return /* @__PURE__ */ React13.createElement(
1985
+ AbsoluteFill3,
1986
+ {
1987
+ ...containerProps,
1988
+ style: enhancedStyle
1989
+ },
1990
+ childrenArray
1991
+ );
1992
+ }
1993
+ return /* @__PURE__ */ React13.createElement(
1994
+ "div",
1995
+ {
1996
+ id,
1997
+ ...containerProps,
1998
+ style: enhancedStyle
1999
+ },
2000
+ childrenArray.map((child, index) => /* @__PURE__ */ React13.createElement(React13.Fragment, { key: index }, child))
2001
+ );
2002
+ }
2003
+ if (data.isAbsoluteFill) {
2004
+ return /* @__PURE__ */ React13.createElement(
2005
+ AbsoluteFill3,
2006
+ {
2007
+ id,
2008
+ ...containerProps,
2009
+ style: enhancedStyle
2010
+ },
2011
+ childrenArray.map((child, index) => /* @__PURE__ */ React13.createElement(
2012
+ "div",
2013
+ {
2014
+ key: index,
2015
+ ...childrenProps.length > 0 && index < childrenProps.length ? childrenProps[index] : repeatChildrenProps ? repeatChildrenProps : {}
2016
+ },
2017
+ child
2018
+ ))
2019
+ );
2020
+ }
2021
+ return /* @__PURE__ */ React13.createElement(
2022
+ "div",
2023
+ {
2024
+ id,
2025
+ ...containerProps,
2026
+ style: enhancedStyle
2027
+ },
2028
+ childrenArray.map((child, index) => /* @__PURE__ */ React13.createElement(
2029
+ "div",
2030
+ {
2031
+ key: index,
2032
+ ...childrenProps.length > 0 && index < childrenProps.length ? childrenProps[index] : repeatChildrenProps ? repeatChildrenProps : {}
2033
+ },
2034
+ child
2035
+ ))
2036
+ );
2037
+ };
2038
+ var config8 = {
2039
+ displayName: "BaseLayout",
2040
+ type: "layout",
2041
+ isInnerSequence: false
2042
+ };
2043
+
2044
+ // src/components/layouts/index.ts
2045
+ registerComponent(
2046
+ config8.displayName,
2047
+ Layout,
2048
+ "layout",
2049
+ config8
2050
+ );
2051
+
2052
+ // src/components/atoms/ShapeAtom.tsx
2053
+ import React14 from "react";
2054
+ import { Easing as Easing4, interpolate as interpolate4, useCurrentFrame as useCurrentFrame4 } from "remotion";
2055
+ var Atom = ({ data }) => {
2056
+ const frame = useCurrentFrame4();
2057
+ const { shape, color, rotation, style } = data;
2058
+ const rotationStyle = rotation ? {
2059
+ transform: `rotate(${interpolate4(
2060
+ frame % rotation.duration,
2061
+ [0, rotation.duration],
2062
+ [0, 360],
2063
+ {
2064
+ extrapolateLeft: "clamp",
2065
+ extrapolateRight: "clamp",
2066
+ easing: Easing4.linear
2067
+ }
2068
+ )}deg)`
2069
+ } : {};
2070
+ const baseStyle = {
2071
+ width: "100%",
2072
+ height: "100%",
2073
+ ...style,
2074
+ ...rotationStyle
2075
+ };
2076
+ switch (shape) {
2077
+ case "circle":
2078
+ return /* @__PURE__ */ React14.createElement("div", { style: { ...baseStyle, backgroundColor: color, borderRadius: "50%" } });
2079
+ case "rectangle":
2080
+ return /* @__PURE__ */ React14.createElement("div", { style: { ...baseStyle, backgroundColor: color } });
2081
+ default:
2082
+ return null;
2083
+ }
2084
+ };
2085
+ var config9 = {
2086
+ displayName: "ShapeAtom",
2087
+ type: "atom",
2088
+ isInnerSequence: false
2089
+ };
2090
+
2091
+ // src/components/atoms/ImageAtom.tsx
2092
+ import React15, { useMemo as useMemo8, useState, useEffect } from "react";
2093
+ import { continueRender, delayRender, Img, staticFile } from "remotion";
2094
+ var CORS_PROXIES = [
2095
+ "https://thingproxy.freeboard.io/fetch/",
2096
+ "https://api.allorigins.win/raw?url=",
2097
+ "https://corsproxy.io/?"
2098
+ ];
2099
+ var getCorsProxyUrl = (url) => {
2100
+ return `${CORS_PROXIES[0]}${encodeURIComponent(url)}`;
2101
+ };
2102
+ var useImageSource = (src, proxySrc) => {
2103
+ const [imageSource, setImageSource] = useState(src);
2104
+ const [isLoading, setIsLoading] = useState(false);
2105
+ const [hasError, setHasError] = useState(false);
2106
+ const [handle] = useState(() => delayRender("Loading image"));
2107
+ useEffect(() => {
2108
+ if (!src.startsWith("http")) {
2109
+ setImageSource(src);
2110
+ continueRender(handle);
2111
+ return;
2112
+ }
2113
+ setIsLoading(true);
2114
+ setHasError(false);
2115
+ const testImage = new Image();
2116
+ testImage.crossOrigin = "anonymous";
2117
+ const handleSuccess = () => {
2118
+ setImageSource(src);
2119
+ setIsLoading(false);
2120
+ continueRender(handle);
2121
+ };
2122
+ const handleError = () => {
2123
+ let proxyUrl;
2124
+ if (proxySrc) {
2125
+ proxyUrl = `${proxySrc}?url=${encodeURIComponent(src)}`;
2126
+ } else {
2127
+ proxyUrl = getCorsProxyUrl(src);
2128
+ }
2129
+ setImageSource(proxyUrl);
2130
+ setIsLoading(false);
2131
+ continueRender(handle);
2132
+ };
2133
+ testImage.onload = handleSuccess;
2134
+ testImage.onerror = handleError;
2135
+ testImage.src = src;
2136
+ return () => {
2137
+ testImage.onload = null;
2138
+ testImage.onerror = null;
2139
+ };
2140
+ }, [src, proxySrc, handle]);
2141
+ return { imageSource, isLoading, hasError };
2142
+ };
2143
+ var Atom2 = ({ data, id }) => {
2144
+ const overrideStyles = useAnimatedStyles(id);
2145
+ const { imageSource, isLoading, hasError } = useImageSource(data.src, data.proxySrc);
2146
+ const source = useMemo8(() => {
2147
+ if (data.src.startsWith("http")) {
2148
+ return imageSource;
2149
+ }
2150
+ return staticFile(data.src);
2151
+ }, [data.src, imageSource]);
2152
+ const enhancedStyle = useMemo8(() => ({
2153
+ ...data.style,
2154
+ ...overrideStyles
2155
+ }), [data.style, overrideStyles, isLoading, hasError]);
2156
+ return /* @__PURE__ */ React15.createElement(
2157
+ Img,
2158
+ {
2159
+ className: data.className,
2160
+ src: source,
2161
+ style: enhancedStyle,
2162
+ crossOrigin: data.src.startsWith("http") ? "anonymous" : void 0,
2163
+ maxRetries: 4,
2164
+ onError: () => {
2165
+ console.warn(`Failed to load image: ${data.src}`);
2166
+ }
2167
+ }
2168
+ );
2169
+ };
2170
+ var config10 = {
2171
+ displayName: "ImageAtom",
2172
+ type: "atom",
2173
+ isInnerSequence: false
2174
+ };
2175
+
2176
+ // src/components/atoms/TextAtom.tsx
2177
+ import React16, { useEffect as useEffect3, useMemo as useMemo9, useState as useState3 } from "react";
2178
+ import { delayRender as delayRender3, continueRender as continueRender3 } from "remotion";
2179
+
2180
+ // src/hooks/useFontLoader.ts
2181
+ import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
2182
+ import { delayRender as delayRender2, continueRender as continueRender2 } from "remotion";
2183
+
2184
+ // src/utils/fontUtils.ts
2185
+ import * as fontUtils from "@remotion/google-fonts";
2186
+ var availableFonts = [];
2187
+ var getAvailableFonts2 = async () => {
2188
+ if (availableFonts.length === 0) {
2189
+ try {
2190
+ availableFonts = fontUtils.getAvailableFonts();
2191
+ } catch (error) {
2192
+ console.warn("Failed to load @remotion/google-fonts:", error);
2193
+ availableFonts = [];
2194
+ }
2195
+ }
2196
+ return availableFonts;
2197
+ };
2198
+ var loadedFonts = /* @__PURE__ */ new Map();
2199
+ var loadGoogleFont = async (fontFamily, options = {}) => {
2200
+ if (!fontFamily || typeof fontFamily !== "string" || fontFamily === "") {
2201
+ console.warn("Invalid fontFamily provided:", fontFamily);
2202
+ return "sans-serif";
2203
+ }
2204
+ const fontKey = `${fontFamily}-${JSON.stringify(options)}`;
2205
+ if (loadedFonts.has(fontKey)) {
2206
+ return loadedFonts.get(fontKey);
2207
+ }
2208
+ try {
2209
+ const fonts = await getAvailableFonts2();
2210
+ const thisFont = fonts.find((font) => font.importName === fontFamily);
2211
+ if (thisFont?.load) {
2212
+ const fontPackage = await thisFont.load();
2213
+ const allFontStuff = fontPackage.loadFont("normal", {
2214
+ subsets: options.subsets || ["latin"],
2215
+ weights: options.weights || ["400"]
2216
+ });
2217
+ await allFontStuff.waitUntilDone();
2218
+ loadedFonts.set(fontKey, allFontStuff.fontFamily);
2219
+ return allFontStuff.fontFamily;
2220
+ } else {
2221
+ throw new Error(
2222
+ `Font Package @remotion/google-fonts/${fontFamily} does not have loadFont method`
2223
+ );
2224
+ }
2225
+ } catch (error) {
2226
+ console.warn(`Failed to load font ${fontFamily}:`, error);
2227
+ try {
2228
+ const alternativeNames = [
2229
+ fontFamily.toLowerCase().replace(/\s+/g, ""),
2230
+ fontFamily.toLowerCase().replace(/\s+/g, "-"),
2231
+ fontFamily.toLowerCase().replace(/\s+/g, "_")
2232
+ ];
2233
+ for (const altName of alternativeNames) {
2234
+ if (altName === fontFamily.toLowerCase().replace(/\s+/g, "-")) {
2235
+ continue;
2236
+ }
2237
+ try {
2238
+ const altFontPackage = await import(`@remotion/google-fonts/${altName}`);
2239
+ if (altFontPackage.loadFont) {
2240
+ const { fontFamily: loadedFontFamily } = await altFontPackage.loadFont("normal", {
2241
+ subsets: options.subsets || ["latin"],
2242
+ weights: options.weights || ["400"],
2243
+ display: options.display || "swap",
2244
+ preload: options.preload !== false
2245
+ });
2246
+ loadedFonts.set(fontKey, loadedFontFamily);
2247
+ return loadedFontFamily;
2248
+ }
2249
+ } catch (altError) {
2250
+ continue;
2251
+ }
2252
+ }
2253
+ } catch (altError) {
2254
+ }
2255
+ const fallbackFontFamily = `"${fontFamily}"`;
2256
+ loadedFonts.set(fontKey, fallbackFontFamily);
2257
+ return fallbackFontFamily;
2258
+ }
2259
+ };
2260
+ var loadMultipleFonts = async (fonts) => {
2261
+ const loadPromises = fonts.map(async ({ family, options }) => {
2262
+ const fontFamily = await loadGoogleFont(family, options);
2263
+ return { family, fontFamily };
2264
+ });
2265
+ const results = await Promise.all(loadPromises);
2266
+ const fontMap = /* @__PURE__ */ new Map();
2267
+ results.forEach(({ family, fontFamily }) => {
2268
+ fontMap.set(family, fontFamily);
2269
+ });
2270
+ return fontMap;
2271
+ };
2272
+ var getLoadedFontFamily = (fontFamily, options = {}) => {
2273
+ const fontKey = `${fontFamily}-${JSON.stringify(options)}`;
2274
+ return loadedFonts.get(fontKey);
2275
+ };
2276
+ var preloadCommonFonts = async () => {
2277
+ const commonFonts = [
2278
+ { family: "Inter", options: { weights: ["400", "500", "600", "700"] } },
2279
+ { family: "Roboto", options: { weights: ["400", "500", "700"] } },
2280
+ { family: "Open Sans", options: { weights: ["400", "600", "700"] } },
2281
+ { family: "Lato", options: { weights: ["400", "700"] } }
2282
+ ];
2283
+ return await loadMultipleFonts(commonFonts);
2284
+ };
2285
+ var isFontLoaded = (fontFamily, options = {}) => {
2286
+ const fontKey = `${fontFamily}-${JSON.stringify(options)}`;
2287
+ return loadedFonts.has(fontKey);
2288
+ };
2289
+ var clearFontCache = () => {
2290
+ loadedFonts.clear();
2291
+ };
2292
+ var getLoadedFonts = () => {
2293
+ return new Map(loadedFonts);
2294
+ };
2295
+ var isFontAvailable = async (fontFamily) => {
2296
+ if (!fontFamily || typeof fontFamily !== "string") {
2297
+ return false;
2298
+ }
2299
+ try {
2300
+ const fonts = await getAvailableFonts2();
2301
+ const isInAvailableFonts = fonts.some(
2302
+ (font) => font.importName === fontFamily
2303
+ );
2304
+ if (isInAvailableFonts) {
2305
+ return true;
2306
+ }
2307
+ const normalizedFontName = fontFamily.trim().replace(/\s+/g, "-").toLowerCase();
2308
+ const fontPackage = await import(`@remotion/google-fonts/${normalizedFontName}`);
2309
+ return !!fontPackage.loadFont;
2310
+ } catch (error) {
2311
+ return false;
2312
+ }
2313
+ };
2314
+ var getNormalizedFontName = (fontFamily) => {
2315
+ if (!fontFamily || typeof fontFamily !== "string") {
2316
+ return "";
2317
+ }
2318
+ return fontFamily.trim().replace(/\s+/g, "-").toLowerCase();
2319
+ };
2320
+
2321
+ // src/hooks/useFontLoader.ts
2322
+ var useFontLoader = (options = {}) => {
2323
+ const [state, setState] = useState2({
2324
+ loadedFonts: /* @__PURE__ */ new Map(),
2325
+ loadingFonts: /* @__PURE__ */ new Set(),
2326
+ errorFonts: /* @__PURE__ */ new Map()
2327
+ });
2328
+ const loadFont = useCallback(
2329
+ async (fontFamily, fontOptions = {}) => {
2330
+ const fontKey = `${fontFamily}-${JSON.stringify(fontOptions)}`;
2331
+ if (state.loadedFonts.has(fontKey) || state.loadingFonts.has(fontFamily)) {
2332
+ return state.loadedFonts.get(fontKey) || `"${fontFamily}", sans-serif`;
2333
+ }
2334
+ setState((prev) => ({
2335
+ ...prev,
2336
+ loadingFonts: new Set(prev.loadingFonts).add(fontFamily)
2337
+ }));
2338
+ try {
2339
+ const cssValue = await loadGoogleFont(fontFamily, fontOptions);
2340
+ if (cssValue !== null) {
2341
+ setState((prev) => ({
2342
+ ...prev,
2343
+ loadedFonts: new Map(prev.loadedFonts).set(fontKey, cssValue),
2344
+ loadingFonts: new Set(
2345
+ [...prev.loadingFonts].filter((f) => f !== fontFamily)
2346
+ )
2347
+ }));
2348
+ options.onLoad?.(fontFamily, cssValue);
2349
+ return cssValue;
2350
+ } else {
2351
+ throw new Error(
2352
+ `Font Package @remotion/google-fonts/${fontFamily} not found`
2353
+ );
2354
+ }
2355
+ } catch (error) {
2356
+ const errorObj = error instanceof Error ? error : new Error(String(error));
2357
+ setState((prev) => ({
2358
+ ...prev,
2359
+ errorFonts: new Map(prev.errorFonts).set(fontFamily, errorObj),
2360
+ loadingFonts: new Set(
2361
+ [...prev.loadingFonts].filter((f) => f !== fontFamily)
2362
+ )
2363
+ }));
2364
+ options.onError?.(fontFamily, errorObj);
2365
+ const fallbackValue = `"${fontFamily}", sans-serif`;
2366
+ return fallbackValue;
2367
+ }
2368
+ },
2369
+ [state.loadedFonts, state.loadingFonts, options]
2370
+ );
2371
+ const loadMultipleFonts2 = useCallback(
2372
+ async (fonts) => {
2373
+ const fontsToLoad = fonts.filter(({ family, options: options2 = {} }) => {
2374
+ const fontKey = `${family}-${JSON.stringify(options2)}`;
2375
+ return !state.loadedFonts.has(fontKey) && !state.loadingFonts.has(family);
2376
+ });
2377
+ if (fontsToLoad.length === 0) {
2378
+ return state.loadedFonts;
2379
+ }
2380
+ setState((prev) => ({
2381
+ ...prev,
2382
+ loadingFonts: /* @__PURE__ */ new Set([
2383
+ ...prev.loadingFonts,
2384
+ ...fontsToLoad.map((f) => f.family)
2385
+ ])
2386
+ }));
2387
+ try {
2388
+ const fontMap = await loadMultipleFonts(fontsToLoad);
2389
+ const newFontsMap = /* @__PURE__ */ new Map();
2390
+ fontsToLoad.forEach(({ family, options: options2 = {} }) => {
2391
+ const fontKey = `${family}-${JSON.stringify(options2)}`;
2392
+ const cssValue = fontMap.get(family);
2393
+ if (cssValue) {
2394
+ newFontsMap.set(fontKey, cssValue);
2395
+ }
2396
+ });
2397
+ setState((prev) => ({
2398
+ ...prev,
2399
+ loadedFonts: new Map([...prev.loadedFonts, ...newFontsMap]),
2400
+ loadingFonts: new Set(
2401
+ [...prev.loadingFonts].filter(
2402
+ (f) => !fontsToLoad.some((ftl) => ftl.family === f)
2403
+ )
2404
+ )
2405
+ }));
2406
+ fontsToLoad.forEach(({ family }) => {
2407
+ const cssValue = fontMap.get(family);
2408
+ if (cssValue) {
2409
+ options.onLoad?.(family, cssValue);
2410
+ }
2411
+ });
2412
+ return fontMap;
2413
+ } catch (error) {
2414
+ const errorObj = error instanceof Error ? error : new Error(String(error));
2415
+ setState((prev) => ({
2416
+ ...prev,
2417
+ errorFonts: new Map(prev.errorFonts).set("multiple", errorObj),
2418
+ loadingFonts: new Set(
2419
+ [...prev.loadingFonts].filter(
2420
+ (f) => !fontsToLoad.some((ftl) => ftl.family === f)
2421
+ )
2422
+ )
2423
+ }));
2424
+ options.onError?.("multiple", errorObj);
2425
+ return state.loadedFonts;
2426
+ }
2427
+ },
2428
+ [state.loadedFonts, state.loadingFonts, options]
2429
+ );
2430
+ const isFontReady = useCallback(
2431
+ (fontFamily, options2 = {}) => {
2432
+ const fontKey = `${fontFamily}-${JSON.stringify(options2)}`;
2433
+ return state.loadedFonts.has(fontKey);
2434
+ },
2435
+ [state.loadedFonts]
2436
+ );
2437
+ const areFontsReady = useCallback(
2438
+ (fontFamilies) => {
2439
+ return fontFamilies.every(({ family, options: options2 = {} }) => {
2440
+ const fontKey = `${family}-${JSON.stringify(options2)}`;
2441
+ return state.loadedFonts.has(fontKey);
2442
+ });
2443
+ },
2444
+ [state.loadedFonts]
2445
+ );
2446
+ const getFontFamily = useCallback(
2447
+ (fontFamily, options2 = {}) => {
2448
+ const fontKey = `${fontFamily}-${JSON.stringify(options2)}`;
2449
+ return state.loadedFonts.get(fontKey);
2450
+ },
2451
+ [state.loadedFonts]
2452
+ );
2453
+ const getFontError = useCallback(
2454
+ (fontFamily) => {
2455
+ return state.errorFonts.get(fontFamily);
2456
+ },
2457
+ [state.errorFonts]
2458
+ );
2459
+ const clearErrors = useCallback(() => {
2460
+ setState((prev) => ({
2461
+ ...prev,
2462
+ errorFonts: /* @__PURE__ */ new Map()
2463
+ }));
2464
+ }, []);
2465
+ return {
2466
+ // State
2467
+ loadedFonts: state.loadedFonts,
2468
+ loadingFonts: state.loadingFonts,
2469
+ errorFonts: state.errorFonts,
2470
+ // Actions
2471
+ loadFont,
2472
+ loadMultipleFonts: loadMultipleFonts2,
2473
+ isFontReady,
2474
+ areFontsReady,
2475
+ getFontFamily,
2476
+ getFontError,
2477
+ clearErrors
2478
+ };
2479
+ };
2480
+ var useFont = (fontFamily, options = {}) => {
2481
+ const { loadFont, isFontReady, getFontFamily, getFontError, ...rest } = useFontLoader(options);
2482
+ const [isLoaded, setIsLoaded] = useState2(false);
2483
+ const [error, setError] = useState2(null);
2484
+ const [renderHandle] = useState2(
2485
+ () => delayRender2(`Loading font: ${fontFamily}`)
2486
+ );
2487
+ const initialFontFamily = getFontFamily(fontFamily, options) || `"${fontFamily}", sans-serif`;
2488
+ const [fontFamilyValue, setFontFamilyValue] = useState2(initialFontFamily);
2489
+ useEffect2(() => {
2490
+ const loadFontAsync = async () => {
2491
+ try {
2492
+ const cssValue = await loadFont(fontFamily, options);
2493
+ setFontFamilyValue(cssValue);
2494
+ setIsLoaded(true);
2495
+ setError(null);
2496
+ continueRender2(renderHandle);
2497
+ } catch (err) {
2498
+ setError(err instanceof Error ? err : new Error(String(err)));
2499
+ setIsLoaded(false);
2500
+ continueRender2(renderHandle);
2501
+ }
2502
+ };
2503
+ if (!isFontReady(fontFamily, options)) {
2504
+ loadFontAsync();
2505
+ } else {
2506
+ const cachedValue = getFontFamily(fontFamily, options);
2507
+ if (cachedValue) {
2508
+ setFontFamilyValue(cachedValue);
2509
+ }
2510
+ setIsLoaded(true);
2511
+ continueRender2(renderHandle);
2512
+ }
2513
+ }, [fontFamily, loadFont, isFontReady, getFontFamily, options, renderHandle]);
2514
+ return {
2515
+ isLoaded,
2516
+ error,
2517
+ isReady: isFontReady(fontFamily, options),
2518
+ fontFamily: fontFamilyValue,
2519
+ ...rest
2520
+ };
2521
+ };
2522
+
2523
+ // src/components/atoms/TextAtom.tsx
2524
+ var Atom3 = ({ id, data }) => {
2525
+ const overrideStyles = useAnimatedStyles(id);
2526
+ const [isFontLoading, setIsFontLoading] = useState3(false);
2527
+ const [renderHandle] = useState3(
2528
+ () => delayRender3(`Loading font: ${data.font?.family}`)
2529
+ );
2530
+ const { isLoaded, error, isReady, fontFamily } = useFont(
2531
+ data.font?.family || "Inter",
2532
+ {
2533
+ weights: data.font?.weights || ["400"],
2534
+ subsets: data.font?.subsets || ["latin"],
2535
+ display: data.font?.display || "swap",
2536
+ preload: data.font?.preload !== false,
2537
+ onLoad: (family, cssValue) => {
2538
+ setIsFontLoading(false);
2539
+ continueRender3(renderHandle);
2540
+ },
2541
+ onError: (family, error2) => {
2542
+ setIsFontLoading(false);
2543
+ continueRender3(renderHandle);
2544
+ }
2545
+ }
2546
+ );
2547
+ useEffect3(() => {
2548
+ if (data.font?.family) {
2549
+ if (isReady || isLoaded) {
2550
+ setIsFontLoading(false);
2551
+ } else if (!isReady && !isLoaded && !error) {
2552
+ setIsFontLoading(true);
2553
+ }
2554
+ }
2555
+ }, [data.font, isReady, isLoaded, error]);
2556
+ const enhancedStyle = useMemo9(() => {
2557
+ const baseStyle = {
2558
+ fontFamily,
2559
+ ...data.style
2560
+ };
2561
+ if (data.gradient) {
2562
+ return {
2563
+ ...baseStyle,
2564
+ backgroundImage: data.gradient,
2565
+ backgroundClip: "text",
2566
+ WebkitBackgroundClip: "text",
2567
+ color: "transparent",
2568
+ ...overrideStyles
2569
+ };
2570
+ }
2571
+ return {
2572
+ ...baseStyle,
2573
+ ...overrideStyles
2574
+ };
2575
+ }, [fontFamily, data.style, data.gradient, overrideStyles]);
2576
+ if (isFontLoading && data.loadingState?.showLoadingIndicator) {
2577
+ return /* @__PURE__ */ React16.createElement("div", { style: enhancedStyle, className: data.className }, /* @__PURE__ */ React16.createElement("span", { style: data.loadingState.loadingStyle }, data.loadingState.loadingText || "Loading..."));
2578
+ }
2579
+ if (error && data.errorState?.showErrorIndicator) {
2580
+ return /* @__PURE__ */ React16.createElement("div", { style: enhancedStyle, className: data.className }, /* @__PURE__ */ React16.createElement("span", { style: data.errorState.errorStyle }, data.errorState.errorText || data.text));
2581
+ }
2582
+ return /* @__PURE__ */ React16.createElement(
2583
+ "div",
2584
+ {
2585
+ style: enhancedStyle,
2586
+ className: data.className,
2587
+ "data-font-loading": isFontLoading,
2588
+ "data-font-loaded": isReady || isLoaded,
2589
+ "data-font-error": !!error,
2590
+ "data-font-family": data.font?.family || "system"
2591
+ },
2592
+ data.text
2593
+ );
2594
+ };
2595
+ var config11 = {
2596
+ displayName: "TextAtom",
2597
+ type: "atom",
2598
+ isInnerSequence: false
2599
+ };
2600
+
2601
+ // src/components/atoms/VideoAtom.tsx
2602
+ import React17, { useMemo as useMemo10 } from "react";
2603
+ import { staticFile as staticFile2, useCurrentFrame as useCurrentFrame5, useVideoConfig as useVideoConfig5, OffthreadVideo, Loop as Loop2 } from "remotion";
2604
+ import { z } from "zod";
2605
+ var VideoAtomDataProps = z.object({
2606
+ src: z.string(),
2607
+ // Video source URL
2608
+ srcDuration: z.number().optional(),
2609
+ // Video duration in seconds (or to say it more accurately, each iteration duration in a loop))
2610
+ style: z.record(z.string(), z.any()).optional(),
2611
+ // CSS styles object
2612
+ containerClassName: z.string().optional(),
2613
+ // CSS class names
2614
+ className: z.string().optional(),
2615
+ // CSS class names
2616
+ startFrom: z.number().optional(),
2617
+ // Start playback from this time (seconds)
2618
+ endAt: z.number().optional(),
2619
+ // End playback at this time (seconds)
2620
+ playbackRate: z.number().optional(),
2621
+ // Playback speed multiplier
2622
+ volume: z.number().optional(),
2623
+ // Volume level (0-1)
2624
+ muted: z.boolean().optional(),
2625
+ // Mute video audio
2626
+ loop: z.boolean().optional(),
2627
+ // Whether to loop the video
2628
+ fit: z.enum(["contain", "cover", "fill", "none", "scale-down"]).optional()
2629
+ // Object fit style
2630
+ });
2631
+ var Atom4 = ({ data, id, context }) => {
2632
+ const { fps } = useVideoConfig5();
2633
+ const overrideStyles = useAnimatedStyles(id);
2634
+ const frame = useCurrentFrame5();
2635
+ const source = useMemo10(() => {
2636
+ if (data.src.startsWith("http")) {
2637
+ return data.src;
2638
+ }
2639
+ return staticFile2(data.src);
2640
+ }, [data.src]);
2641
+ const trimBefore = useMemo10(() => {
2642
+ return data.startFrom ? data.startFrom * fps : void 0;
2643
+ }, [data.startFrom, fps]);
2644
+ const trimAfter = useMemo10(() => {
2645
+ return data.endAt ? data.endAt * fps : void 0;
2646
+ }, [data.endAt, fps]);
2647
+ const videoComponent = /* @__PURE__ */ React17.createElement(
2648
+ OffthreadVideo,
2649
+ {
2650
+ className: data.className,
2651
+ src: source,
2652
+ style: data.style ? { ...data.style, ...data.fit ? { objectFit: data.fit } : {} } : {},
2653
+ trimBefore,
2654
+ trimAfter,
2655
+ playbackRate: data.playbackRate,
2656
+ volume: data.volume,
2657
+ muted: data.muted
2658
+ }
2659
+ );
2660
+ const videoWithStyles = data.containerClassName ? videoComponent : /* @__PURE__ */ React17.createElement(
2661
+ OffthreadVideo,
2662
+ {
2663
+ className: data.className,
2664
+ src: source,
2665
+ style: data.style ? { ...data.style, ...data.fit ? { objectFit: data.fit } : {}, ...overrideStyles } : overrideStyles,
2666
+ trimBefore,
2667
+ trimAfter,
2668
+ playbackRate: data.playbackRate,
2669
+ volume: data.volume,
2670
+ muted: data.muted
2671
+ }
2672
+ );
2673
+ if (data.loop) {
2674
+ return /* @__PURE__ */ React17.createElement(Loop2, { times: Infinity, durationInFrames: data.srcDuration ? data.srcDuration * fps : context.timing?.durationInFrames, layout: "none" }, data.containerClassName ? /* @__PURE__ */ React17.createElement("div", { className: data.containerClassName, style: overrideStyles }, videoComponent) : videoWithStyles);
2675
+ }
2676
+ return data.containerClassName ? /* @__PURE__ */ React17.createElement("div", { className: data.containerClassName, style: overrideStyles }, videoComponent) : videoWithStyles;
2677
+ };
2678
+ var config12 = {
2679
+ displayName: "VideoAtom",
2680
+ type: "atom",
2681
+ isInnerSequence: false
2682
+ };
2683
+
2684
+ // src/components/atoms/AudioAtom.tsx
2685
+ import React18, { useMemo as useMemo11 } from "react";
2686
+ import { Audio, staticFile as staticFile3, useCurrentFrame as useCurrentFrame6, useVideoConfig as useVideoConfig6 } from "remotion";
2687
+ import { z as z2 } from "zod";
2688
+ var AudioAtomMutedRangeProps = z2.object({
2689
+ type: z2.literal("range"),
2690
+ values: z2.array(z2.object({
2691
+ start: z2.number(),
2692
+ // Start time in seconds
2693
+ end: z2.number()
2694
+ // End time in seconds
2695
+ }))
2696
+ });
2697
+ var AudioAtomMutedFullProps = z2.object({
2698
+ type: z2.literal("full"),
2699
+ value: z2.boolean()
2700
+ // true = muted, false = unmuted
2701
+ });
2702
+ var AudioAtomDataProps = z2.object({
2703
+ src: z2.string(),
2704
+ // Audio source URL
2705
+ startFrom: z2.number().optional(),
2706
+ // Start playback from this time (seconds)
2707
+ endAt: z2.number().optional(),
2708
+ // End playback at this time (seconds)
2709
+ volume: z2.number().optional(),
2710
+ // Volume level (0-1)
2711
+ playbackRate: z2.number().optional(),
2712
+ // Playback speed multiplier
2713
+ muted: z2.union([AudioAtomMutedFullProps, AudioAtomMutedRangeProps]).optional()
2714
+ // Mute configuration
2715
+ });
2716
+ var Atom5 = ({ data }) => {
2717
+ const { fps } = useVideoConfig6();
2718
+ const { muted } = data;
2719
+ const frame = useCurrentFrame6();
2720
+ const isMuted = useMemo11(() => {
2721
+ if (muted?.type === "full") {
2722
+ return muted.value;
2723
+ }
2724
+ if (muted?.type === "range") {
2725
+ return muted?.values.some(
2726
+ (value) => frame >= value.start * fps && frame <= value.end * fps
2727
+ );
2728
+ }
2729
+ return false;
2730
+ }, [muted, frame, fps]);
2731
+ const source = useMemo11(() => {
2732
+ if (data.src.startsWith("http")) {
2733
+ return data.src;
2734
+ }
2735
+ return staticFile3(data.src);
2736
+ }, [data.src]);
2737
+ return (
2738
+ // @ts-ignore
2739
+ /* @__PURE__ */ React18.createElement(
2740
+ Audio,
2741
+ {
2742
+ src: source,
2743
+ trimBefore: data.startFrom ? data.startFrom * fps : void 0,
2744
+ trimAfter: data.endAt ? data.endAt * fps : void 0,
2745
+ volume: data.volume,
2746
+ playbackRate: data.playbackRate,
2747
+ muted: isMuted
2748
+ }
2749
+ )
2750
+ );
2751
+ };
2752
+ var config13 = {
2753
+ displayName: "AudioAtom",
2754
+ type: "atom",
2755
+ isInnerSequence: false
2756
+ };
2757
+
2758
+ // src/components/atoms/LottieAtom.tsx
2759
+ import React19, { useMemo as useMemo12, useState as useState4, useEffect as useEffect4 } from "react";
2760
+ import { continueRender as continueRender4, delayRender as delayRender5, staticFile as staticFile4, useCurrentFrame as useCurrentFrame7, useVideoConfig as useVideoConfig7 } from "remotion";
2761
+ import { Lottie } from "@remotion/lottie";
2762
+ import { z as z3 } from "zod";
2763
+ var LottieAtomDataProps = z3.object({
2764
+ src: z3.string(),
2765
+ // Lottie JSON source URL or local path
2766
+ style: z3.record(z3.string(), z3.any()).optional(),
2767
+ // CSS styles object
2768
+ className: z3.string().optional(),
2769
+ // CSS class names
2770
+ loop: z3.boolean().optional(),
2771
+ // Whether to loop the animation (handled by Remotion timeline)
2772
+ playbackRate: z3.number().optional(),
2773
+ // Playback speed multiplier (default: 1)
2774
+ direction: z3.enum(["forward", "reverse"]).optional()
2775
+ // Animation direction
2776
+ });
2777
+ var useLottieData = (src) => {
2778
+ const [animationData, setAnimationData] = useState4(null);
2779
+ const [isLoading, setIsLoading] = useState4(true);
2780
+ const [hasError, setHasError] = useState4(false);
2781
+ const [handle] = useState4(() => delayRender5("Loading Lottie animation"));
2782
+ useEffect4(() => {
2783
+ if (!src) {
2784
+ console.error("LottieAtom: No source provided");
2785
+ setHasError(true);
2786
+ setIsLoading(false);
2787
+ continueRender4(handle);
2788
+ return;
2789
+ }
2790
+ setIsLoading(true);
2791
+ setHasError(false);
2792
+ const sourceUrl = src.startsWith("http") ? src : staticFile4(src);
2793
+ fetch(sourceUrl, {
2794
+ mode: "cors",
2795
+ credentials: "omit"
2796
+ }).then((response) => {
2797
+ if (!response.ok) {
2798
+ throw new Error(`HTTP ${response.status}: ${response.statusText} for ${sourceUrl}`);
2799
+ }
2800
+ return response.json();
2801
+ }).then((json) => {
2802
+ if (!json || typeof json !== "object") {
2803
+ throw new Error("Invalid Lottie JSON data");
2804
+ }
2805
+ setAnimationData(json);
2806
+ setIsLoading(false);
2807
+ continueRender4(handle);
2808
+ }).catch((error) => {
2809
+ console.error(`Failed to load Lottie animation from ${sourceUrl}:`, error.message || error);
2810
+ setHasError(true);
2811
+ setIsLoading(false);
2812
+ continueRender4(handle);
2813
+ });
2814
+ return () => {
2815
+ };
2816
+ }, [src, handle]);
2817
+ return { animationData, isLoading, hasError };
2818
+ };
2819
+ var Atom6 = ({ data, id }) => {
2820
+ const { fps } = useVideoConfig7();
2821
+ const frame = useCurrentFrame7();
2822
+ const overrideStyles = useAnimatedStyles(id);
2823
+ const { animationData, isLoading, hasError } = useLottieData(data.src);
2824
+ const effectiveFrame = useMemo12(() => {
2825
+ const playbackRate = data.playbackRate || 1;
2826
+ const direction = data.direction || "forward";
2827
+ if (direction === "reverse") {
2828
+ return frame * playbackRate * -1;
2829
+ }
2830
+ return frame * playbackRate;
2831
+ }, [frame, data.playbackRate, data.direction]);
2832
+ const enhancedStyle = useMemo12(() => ({
2833
+ ...data.style,
2834
+ ...overrideStyles
2835
+ }), [data.style, overrideStyles]);
2836
+ if (isLoading) {
2837
+ return /* @__PURE__ */ React19.createElement(
2838
+ "div",
2839
+ {
2840
+ className: data.className,
2841
+ style: {
2842
+ ...enhancedStyle,
2843
+ display: "flex",
2844
+ alignItems: "center",
2845
+ justifyContent: "center",
2846
+ opacity: 0.5
2847
+ }
2848
+ }
2849
+ );
2850
+ }
2851
+ if (hasError || !animationData) {
2852
+ console.warn(`LottieAtom: Failed to render animation from ${data.src}`);
2853
+ return /* @__PURE__ */ React19.createElement(
2854
+ "div",
2855
+ {
2856
+ className: data.className,
2857
+ style: {
2858
+ ...enhancedStyle,
2859
+ display: "flex",
2860
+ alignItems: "center",
2861
+ justifyContent: "center",
2862
+ backgroundColor: "rgba(255, 0, 0, 0.1)",
2863
+ border: "2px dashed rgba(255, 0, 0, 0.3)",
2864
+ color: "red",
2865
+ fontSize: 12,
2866
+ textAlign: "center",
2867
+ padding: 10
2868
+ }
2869
+ },
2870
+ "\u26A0\uFE0F Lottie Error"
2871
+ );
2872
+ }
2873
+ return /* @__PURE__ */ React19.createElement(
2874
+ Lottie,
2875
+ {
2876
+ animationData,
2877
+ style: enhancedStyle,
2878
+ className: data.className
2879
+ }
2880
+ );
2881
+ };
2882
+ var config14 = {
2883
+ displayName: "LottieAtom",
2884
+ type: "atom",
2885
+ isInnerSequence: false
2886
+ };
2887
+
2888
+ // src/components/atoms/index.ts
2889
+ registerComponent(
2890
+ config9.displayName,
2891
+ Atom,
2892
+ "atom",
2893
+ config9
2894
+ );
2895
+ registerComponent(
2896
+ config10.displayName,
2897
+ Atom2,
2898
+ "atom",
2899
+ config10
2900
+ );
2901
+ registerComponent(config11.displayName, Atom3, "atom", config11);
2902
+ registerComponent(
2903
+ config12.displayName,
2904
+ Atom4,
2905
+ "atom",
2906
+ config12
2907
+ );
2908
+ registerComponent(
2909
+ config13.displayName,
2910
+ Atom5,
2911
+ "atom",
2912
+ config13
2913
+ );
2914
+ registerComponent(
2915
+ config14.displayName,
2916
+ Atom6,
2917
+ "atom",
2918
+ config14
2919
+ );
2920
+
2921
+ // src/hooks/useComponentRegistry.ts
2922
+ import { useMemo as useMemo13 } from "react";
2923
+ var useComponentRegistry = () => {
2924
+ return useMemo13(() => {
2925
+ return {
2926
+ registerComponent: componentRegistry.registerComponent.bind(componentRegistry),
2927
+ registerPackage: componentRegistry.registerPackage.bind(componentRegistry),
2928
+ getComponent: componentRegistry.getComponent.bind(componentRegistry),
2929
+ getAllComponents: componentRegistry.getAllComponents.bind(componentRegistry)
2930
+ };
2931
+ }, []);
2932
+ };
2933
+
2934
+ // src/hooks/useBoundaryCalculation.ts
2935
+ import { useMemo as useMemo14 } from "react";
2936
+ var useBoundaryCalculation = ({
2937
+ parentBoundaries,
2938
+ constraints,
2939
+ layout
2940
+ }) => {
2941
+ return useMemo14(() => {
2942
+ const { x, y, width, height } = parentBoundaries;
2943
+ const calculatedX = typeof constraints.x === "number" ? constraints.x : x;
2944
+ const calculatedY = typeof constraints.y === "number" ? constraints.y : y;
2945
+ const calculatedWidth = typeof constraints.width === "number" ? constraints.width : width;
2946
+ const calculatedHeight = typeof constraints.height === "number" ? constraints.height : height;
2947
+ return {
2948
+ x: calculatedX,
2949
+ y: calculatedY,
2950
+ width: calculatedWidth,
2951
+ height: calculatedHeight,
2952
+ zIndex: constraints.zIndex || 0
2953
+ };
2954
+ }, [parentBoundaries, constraints, layout]);
2955
+ };
2956
+
2957
+ // src/hooks/buildTransitionHook.ts
2958
+ import { useContext as useContext5 } from "react";
2959
+
2960
+ // src/core/types/transition.types.ts
2961
+ import { createContext as createContext4, useContext as useContext4 } from "react";
2962
+ var LayoutContext = createContext4(null);
2963
+
2964
+ // src/hooks/buildTransitionHook.ts
2965
+ function buildLayoutHook(schema, defaultValue) {
2966
+ return () => {
2967
+ const context = useContext5(LayoutContext);
2968
+ if (!context) {
2969
+ return defaultValue;
2970
+ }
2971
+ try {
2972
+ const validatedData = schema.parse(context);
2973
+ return validatedData;
2974
+ } catch (error) {
2975
+ console.warn("Transition data validation failed, using defaults:", error);
2976
+ return defaultValue;
2977
+ }
2978
+ };
2979
+ }
2980
+
2981
+ // src/utils/contextUtils.ts
2982
+ var createRootContext = (width, height, duration, fps) => {
2983
+ return {
2984
+ boundaries: {
2985
+ left: 0,
2986
+ top: 0,
2987
+ width,
2988
+ height,
2989
+ zIndex: 0
2990
+ },
2991
+ timing: {
2992
+ startInFrames: 0,
2993
+ durationInFrames: duration
2994
+ },
2995
+ hierarchy: {
2996
+ depth: 0,
2997
+ parentIds: []
2998
+ }
2999
+ };
3000
+ };
3001
+ var mergeContexts = (parent, child) => {
3002
+ return {
3003
+ boundaries: {
3004
+ ...parent.boundaries,
3005
+ ...child.boundaries
3006
+ },
3007
+ timing: { ...parent.timing, ...child.timing },
3008
+ hierarchy: {
3009
+ depth: (parent.hierarchy?.depth || 0) + 1,
3010
+ parentIds: [...parent.hierarchy?.parentIds || [], "root"]
3011
+ }
3012
+ };
3013
+ };
3014
+
3015
+ // src/utils/boundaryUtils.ts
3016
+ var calculateGridPosition = (index, columns, cellWidth, cellHeight, spacing) => {
3017
+ const row = Math.floor(index / columns);
3018
+ const col = index % columns;
3019
+ return {
3020
+ x: col * (cellWidth + spacing),
3021
+ y: row * (cellHeight + spacing),
3022
+ width: cellWidth,
3023
+ height: cellHeight
3024
+ };
3025
+ };
3026
+ var calculateCircularPosition = (index, total, radius, centerX, centerY) => {
3027
+ const angle = index / total * 2 * Math.PI;
3028
+ return {
3029
+ x: centerX + radius * Math.cos(angle),
3030
+ y: centerY + radius * Math.sin(angle)
3031
+ };
3032
+ };
3033
+
3034
+ // src/utils/imageProxy.ts
3035
+ var createImageProxyUrl = (imageUrl, proxyEndpoint = "/api/proxy/image") => {
3036
+ return `${proxyEndpoint}?url=${encodeURIComponent(imageUrl)}`;
3037
+ };
3038
+ var createImageDataWithProxy = (src, proxyEndpoint) => {
3039
+ return {
3040
+ src,
3041
+ proxySrc: proxyEndpoint || "/api/proxy/image",
3042
+ style: {},
3043
+ className: ""
3044
+ };
3045
+ };
3046
+ var needsProxying = (url) => {
3047
+ return url.startsWith("http://") || url.startsWith("https://");
3048
+ };
3049
+
3050
+ // src/templates/rings/NextjsLogo.tsx
3051
+ import { evolvePath } from "@remotion/paths";
3052
+ import React22, { useMemo as useMemo15 } from "react";
3053
+ import { interpolate as interpolate5, spring as spring5, useCurrentFrame as useCurrentFrame9, useVideoConfig as useVideoConfig9 } from "remotion";
3054
+
3055
+ // src/templates/rings/RippleOutLayout.tsx
3056
+ import React21 from "react";
3057
+ import { spring as spring4, useCurrentFrame as useCurrentFrame8, useVideoConfig as useVideoConfig8, Sequence as Sequence2, AbsoluteFill as AbsoluteFill4 } from "remotion";
3058
+ import { z as z4 } from "zod";
3059
+ var RippleOutTransitionSchema = z4.object({
3060
+ progress: z4.number().min(0).max(1),
3061
+ logoOut: z4.number().min(0).max(1)
3062
+ });
3063
+ var defaultRippleOutData = {
3064
+ progress: 0,
3065
+ logoOut: 0
3066
+ };
3067
+ var useRippleOutLayout = buildLayoutHook(
3068
+ RippleOutTransitionSchema,
3069
+ defaultRippleOutData
3070
+ );
3071
+ var container = {
3072
+ backgroundColor: "white"
3073
+ };
3074
+ var RippleOutLayout = ({ data, context, children }) => {
3075
+ const {
3076
+ transitionStart,
3077
+ transitionDuration
3078
+ } = data || { transitionStart: 2, transitionDuration: 1 };
3079
+ const frame = useCurrentFrame8();
3080
+ const { fps } = useVideoConfig8();
3081
+ const { hierarchy } = useRenderContext();
3082
+ React21.useEffect(() => {
3083
+ loadGoogleFont("Inter", {
3084
+ subsets: ["latin"],
3085
+ weights: ["400", "700"]
3086
+ }).catch(console.warn);
3087
+ }, []);
3088
+ const transitionStartFrame = transitionStart * fps;
3089
+ const transitionDurationFrames = transitionDuration * fps;
3090
+ const logoOut = spring4({
3091
+ fps,
3092
+ frame,
3093
+ config: {
3094
+ damping: 200
3095
+ },
3096
+ durationInFrames: transitionDurationFrames,
3097
+ delay: transitionStartFrame
3098
+ });
3099
+ const transitionData = {
3100
+ progress: logoOut,
3101
+ logoOut
3102
+ };
3103
+ const childrenArray = React21.Children.toArray(children).filter(
3104
+ (child) => React21.isValidElement(child)
3105
+ );
3106
+ const [from, to] = childrenArray;
3107
+ return /* @__PURE__ */ React21.createElement(LayoutContext.Provider, { value: transitionData }, /* @__PURE__ */ React21.createElement(AbsoluteFill4, { style: {
3108
+ ...container,
3109
+ ...context?.boundaries
3110
+ } }, /* @__PURE__ */ React21.createElement(Sequence2, { name: from.props.componentId + " - " + from.props.id, from: 0, durationInFrames: transitionStartFrame + transitionDurationFrames }, from), /* @__PURE__ */ React21.createElement(Sequence2, { name: to.props.componentId + " - " + to.props.id, from: transitionStartFrame + transitionDurationFrames / 2 }, to)));
3111
+ };
3112
+ var rippleOutLayoutConfig = {
3113
+ displayName: "RippleOutLayout",
3114
+ type: "layout",
3115
+ isInnerSequence: true
3116
+ };
3117
+
3118
+ // src/templates/rings/NextjsLogo.tsx
3119
+ var mask = {
3120
+ maskType: "alpha"
3121
+ };
3122
+ var nStroke = "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
3123
+ var NextjsLogo = () => {
3124
+ const { logoOut } = useRippleOutLayout();
3125
+ const outProgress = logoOut;
3126
+ const { fps } = useVideoConfig9();
3127
+ const frame = useCurrentFrame9();
3128
+ const evolve1 = spring5({
3129
+ fps,
3130
+ frame,
3131
+ config: {
3132
+ damping: 200
3133
+ }
3134
+ });
3135
+ const evolve2 = spring5({
3136
+ fps,
3137
+ frame: frame - 15,
3138
+ config: {
3139
+ damping: 200
3140
+ }
3141
+ });
3142
+ const evolve3 = spring5({
3143
+ fps,
3144
+ frame: frame - 30,
3145
+ config: {
3146
+ damping: 200,
3147
+ mass: 3
3148
+ },
3149
+ durationInFrames: 30
3150
+ });
3151
+ const style = useMemo15(() => {
3152
+ return {
3153
+ height: 140,
3154
+ borderRadius: 70,
3155
+ scale: String(1 - outProgress)
3156
+ };
3157
+ }, [outProgress]);
3158
+ const firstPath = `M 60.0568 54 v 71.97`;
3159
+ const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
3160
+ const thirdPath = `M 121 54 L 121 126`;
3161
+ const evolution1 = evolvePath(evolve1, firstPath);
3162
+ const evolution2 = evolvePath(evolve2, secondPath);
3163
+ const evolution3 = evolvePath(
3164
+ interpolate5(evolve3, [0, 1], [0, 0.7]),
3165
+ thirdPath
3166
+ );
3167
+ return /* @__PURE__ */ React22.createElement("svg", { style, fill: "none", viewBox: "0 0 180 180" }, /* @__PURE__ */ React22.createElement("mask", { height: "180", id: "mask", style: mask, width: "180", x: "0", y: "0" }, /* @__PURE__ */ React22.createElement("circle", { cx: "90", cy: "90", fill: "black", r: "90" })), /* @__PURE__ */ React22.createElement("mask", { id: "n-mask", style: mask }, /* @__PURE__ */ React22.createElement("path", { d: nStroke, fill: "black" })), /* @__PURE__ */ React22.createElement("g", { mask: "url(#mask)" }, /* @__PURE__ */ React22.createElement("circle", { cx: "90", cy: "90", fill: "black", r: "90" }), /* @__PURE__ */ React22.createElement("g", { stroke: "url(#gradient0)", mask: "url(#n-mask)" }, /* @__PURE__ */ React22.createElement(
3168
+ "path",
3169
+ {
3170
+ strokeWidth: "12.1136",
3171
+ d: firstPath,
3172
+ strokeDasharray: evolution1.strokeDasharray,
3173
+ strokeDashoffset: evolution1.strokeDashoffset
3174
+ }
3175
+ ), /* @__PURE__ */ React22.createElement(
3176
+ "path",
3177
+ {
3178
+ strokeWidth: 12.1136,
3179
+ d: secondPath,
3180
+ strokeDasharray: evolution2.strokeDasharray,
3181
+ strokeDashoffset: evolution2.strokeDashoffset
3182
+ }
3183
+ )), /* @__PURE__ */ React22.createElement(
3184
+ "path",
3185
+ {
3186
+ stroke: "url(#gradient1)",
3187
+ d: thirdPath,
3188
+ strokeDasharray: evolution3.strokeDasharray,
3189
+ strokeDashoffset: evolution3.strokeDashoffset,
3190
+ strokeWidth: "12"
3191
+ }
3192
+ )), /* @__PURE__ */ React22.createElement("defs", null, /* @__PURE__ */ React22.createElement(
3193
+ "linearGradient",
3194
+ {
3195
+ gradientUnits: "userSpaceOnUse",
3196
+ id: "gradient0",
3197
+ x1: "109",
3198
+ x2: "144.5",
3199
+ y1: "116.5",
3200
+ y2: "160.5"
3201
+ },
3202
+ /* @__PURE__ */ React22.createElement("stop", { stopColor: "white" }),
3203
+ /* @__PURE__ */ React22.createElement("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
3204
+ ), /* @__PURE__ */ React22.createElement(
3205
+ "linearGradient",
3206
+ {
3207
+ gradientUnits: "userSpaceOnUse",
3208
+ id: "gradient1",
3209
+ x1: "121",
3210
+ x2: "120.799",
3211
+ y1: "54",
3212
+ y2: "106.875"
3213
+ },
3214
+ /* @__PURE__ */ React22.createElement("stop", { stopColor: "white" }),
3215
+ /* @__PURE__ */ React22.createElement("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
3216
+ )));
3217
+ };
3218
+ var nextjsLogoConfig = {
3219
+ displayName: "NextjsLogo",
3220
+ type: "atom",
3221
+ isInnerSequence: false
3222
+ };
3223
+
3224
+ // src/templates/rings/Rings.tsx
3225
+ import React23 from "react";
3226
+ import { AbsoluteFill as AbsoluteFill5, interpolateColors as interpolateColors2, useVideoConfig as useVideoConfig10 } from "remotion";
3227
+ var RadialGradient = ({ radius, color }) => {
3228
+ const height = radius * 2;
3229
+ const width = radius * 2;
3230
+ return (
3231
+ // @ts-ignore
3232
+ /* @__PURE__ */ React23.createElement(
3233
+ AbsoluteFill5,
3234
+ {
3235
+ style: {
3236
+ justifyContent: "center",
3237
+ alignItems: "center"
3238
+ }
3239
+ },
3240
+ /* @__PURE__ */ React23.createElement(
3241
+ "div",
3242
+ {
3243
+ style: {
3244
+ height,
3245
+ width,
3246
+ borderRadius: "50%",
3247
+ backgroundColor: color,
3248
+ position: "absolute",
3249
+ boxShadow: "0 0 100px rgba(0, 0, 0, 0.05)"
3250
+ }
3251
+ }
3252
+ )
3253
+ )
3254
+ );
3255
+ };
3256
+ var Rings = ({ context, data }) => {
3257
+ const { logoOut } = useRippleOutLayout();
3258
+ const outProgress = logoOut;
3259
+ const scale = 1 / (1 - outProgress);
3260
+ const { height } = useVideoConfig10();
3261
+ return (
3262
+ // @ts-ignore
3263
+ /* @__PURE__ */ React23.createElement(
3264
+ AbsoluteFill5,
3265
+ {
3266
+ style: {
3267
+ transform: `scale(${scale})`,
3268
+ ...context?.boundaries
3269
+ }
3270
+ },
3271
+ new Array(5).fill(true).map((_, i) => {
3272
+ return /* @__PURE__ */ React23.createElement(
3273
+ RadialGradient,
3274
+ {
3275
+ key: i,
3276
+ radius: height * 0.3 * i,
3277
+ color: interpolateColors2(i, [0, 4], ["#fff", "#fff"])
3278
+ }
3279
+ );
3280
+ }).reverse()
3281
+ )
3282
+ );
3283
+ };
3284
+ var ringsConfig = {
3285
+ displayName: "Rings",
3286
+ type: "atom",
3287
+ isInnerSequence: false
3288
+ };
3289
+
3290
+ // src/templates/rings/TextFade.tsx
3291
+ import React24, { useMemo as useMemo16 } from "react";
3292
+ import {
3293
+ AbsoluteFill as AbsoluteFill6,
3294
+ interpolate as interpolate6,
3295
+ spring as spring6,
3296
+ useCurrentFrame as useCurrentFrame10,
3297
+ useVideoConfig as useVideoConfig11
3298
+ } from "remotion";
3299
+ var TextFade = (props) => {
3300
+ const { children, context, data } = props;
3301
+ const { animation } = data || {
3302
+ animation: {
3303
+ duration: 1
3304
+ }
3305
+ };
3306
+ const { fps } = useVideoConfig11();
3307
+ const frame = useCurrentFrame10();
3308
+ const progress = spring6({
3309
+ fps,
3310
+ frame,
3311
+ config: {
3312
+ damping: 200
3313
+ },
3314
+ durationInFrames: animation.duration * fps
3315
+ });
3316
+ const rightStop = interpolate6(progress, [0, 1], [200, 0]);
3317
+ const leftStop = Math.max(0, rightStop - 60);
3318
+ const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
3319
+ const container2 = useMemo16(() => {
3320
+ return {
3321
+ width: "100%",
3322
+ height: "100%",
3323
+ justifyContent: "center",
3324
+ alignItems: "center"
3325
+ };
3326
+ }, []);
3327
+ const content = useMemo16(() => {
3328
+ return {
3329
+ ...context?.boundaries,
3330
+ maskImage,
3331
+ WebkitMaskImage: maskImage,
3332
+ justifyContent: "center",
3333
+ alignItems: "center",
3334
+ display: "flex"
3335
+ };
3336
+ }, [maskImage]);
3337
+ return (
3338
+ // @ts-ignore
3339
+ /* @__PURE__ */ React24.createElement(AbsoluteFill6, { style: container2 }, /* @__PURE__ */ React24.createElement("div", { style: content }, children))
3340
+ );
3341
+ };
3342
+ var textFadeConfig = {
3343
+ displayName: "TextFade",
3344
+ type: "layout",
3345
+ isInnerSequence: false
3346
+ };
3347
+
3348
+ // src/templates/rings/index.ts
3349
+ registerComponent(
3350
+ nextjsLogoConfig.displayName,
3351
+ NextjsLogo,
3352
+ "atom",
3353
+ nextjsLogoConfig
3354
+ );
3355
+ registerComponent(
3356
+ textFadeConfig.displayName,
3357
+ TextFade,
3358
+ "layout",
3359
+ textFadeConfig
3360
+ );
3361
+ registerComponent(ringsConfig.displayName, Rings, "atom", ringsConfig);
3362
+ registerComponent(
3363
+ rippleOutLayoutConfig.displayName,
3364
+ RippleOutLayout,
3365
+ "layout",
3366
+ rippleOutLayoutConfig
3367
+ );
3368
+
3369
+ // src/templates/waveform/components/WaveformCircle.tsx
3370
+ import React26, { useMemo as useMemo18 } from "react";
3371
+
3372
+ // src/templates/waveform/Waveform.tsx
3373
+ import React25, { createContext as createContext5, useContext as useContext6 } from "react";
3374
+ import { useCurrentFrame as useCurrentFrame11, useVideoConfig as useVideoConfig12 } from "remotion";
3375
+
3376
+ // src/templates/waveform/hooks/useWaveformData.ts
3377
+ import { useMemo as useMemo17 } from "react";
3378
+ import {
3379
+ useAudioData,
3380
+ visualizeAudioWaveform,
3381
+ visualizeAudio
3382
+ } from "@remotion/media-utils";
3383
+ import { staticFile as staticFile5 } from "remotion";
3384
+ var isValidPowerOfTwo = (num) => {
3385
+ return num > 0 && (num & num - 1) === 0;
3386
+ };
3387
+ var getClosestPowerOfTwo = (num) => {
3388
+ if (num <= 0) return 32;
3389
+ let power = 1;
3390
+ while (power < num) {
3391
+ power *= 2;
3392
+ }
3393
+ const lower = power / 2;
3394
+ const upper = power;
3395
+ return Math.abs(num - lower) < Math.abs(num - upper) ? lower : upper;
3396
+ };
3397
+ var useWaveformData = (config15) => {
3398
+ const {
3399
+ audioSrc,
3400
+ numberOfSamples,
3401
+ windowInSeconds,
3402
+ dataOffsetInSeconds = 0,
3403
+ normalize = false,
3404
+ frame,
3405
+ fps,
3406
+ posterize,
3407
+ includeFrequencyData = false,
3408
+ minDb = -100,
3409
+ maxDb = -30
3410
+ } = config15;
3411
+ const { root } = useComposition();
3412
+ const validatedNumberOfSamples = useMemo17(() => {
3413
+ if (!isValidPowerOfTwo(numberOfSamples)) {
3414
+ console.warn(
3415
+ `numberOfSamples must be a power of 2. Adjusting ${numberOfSamples} to ${getClosestPowerOfTwo(numberOfSamples)}`
3416
+ );
3417
+ return getClosestPowerOfTwo(numberOfSamples);
3418
+ }
3419
+ return numberOfSamples;
3420
+ }, [numberOfSamples]);
3421
+ const { source, audioStartsFrom } = useMemo17(() => {
3422
+ if (audioSrc.startsWith("http")) {
3423
+ return { source: audioSrc, audioStartsFrom: void 0 };
3424
+ }
3425
+ if (audioSrc.startsWith("ref:")) {
3426
+ const matchingComponent = findMatchingComponents(root, [
3427
+ audioSrc.replace("ref:", "")
3428
+ ]);
3429
+ if (matchingComponent.length > 0) {
3430
+ const firstMatchingComponent = matchingComponent[0];
3431
+ if (firstMatchingComponent.componentId === "AudioAtom") {
3432
+ return {
3433
+ source: firstMatchingComponent.data.src,
3434
+ audioStartsFrom: firstMatchingComponent.data?.startFrom ?? void 0
3435
+ };
3436
+ }
3437
+ if (firstMatchingComponent.type === "layout" || firstMatchingComponent.type === "scene") {
3438
+ const audioComponents = findMatchingComponentsByQuery(
3439
+ firstMatchingComponent.childrenData,
3440
+ { componentId: "AudioAtom" }
3441
+ );
3442
+ if (audioComponents.length > 0) {
3443
+ return {
3444
+ source: audioComponents[0].data.src,
3445
+ audioStartsFrom: audioComponents[0].data?.startFrom ?? void 0
3446
+ };
3447
+ }
3448
+ }
3449
+ }
3450
+ }
3451
+ return { source: staticFile5(audioSrc), audioStartsFrom: void 0 };
3452
+ }, [audioSrc]);
3453
+ const audioData = useAudioData(source);
3454
+ const adjustedFrame = useMemo17(() => {
3455
+ if (posterize && posterize > 1) {
3456
+ return Math.round(frame / posterize) * posterize;
3457
+ }
3458
+ let offset = 0;
3459
+ if (audioStartsFrom && audioStartsFrom != 0) {
3460
+ offset += Math.round(audioStartsFrom * fps);
3461
+ }
3462
+ if (dataOffsetInSeconds != 0) {
3463
+ offset += Math.round(dataOffsetInSeconds * fps);
3464
+ }
3465
+ return frame + offset;
3466
+ }, [frame, posterize, dataOffsetInSeconds, audioStartsFrom]);
3467
+ const waveformData = useMemo17(() => {
3468
+ if (!audioData) return null;
3469
+ try {
3470
+ const waveform = visualizeAudioWaveform({
3471
+ fps,
3472
+ frame: adjustedFrame,
3473
+ audioData,
3474
+ numberOfSamples: validatedNumberOfSamples,
3475
+ windowInSeconds,
3476
+ dataOffsetInSeconds: 0,
3477
+ normalize
3478
+ });
3479
+ return waveform;
3480
+ } catch (error2) {
3481
+ console.error("Error generating waveform:", error2);
3482
+ return null;
3483
+ }
3484
+ }, [
3485
+ audioData,
3486
+ adjustedFrame,
3487
+ fps,
3488
+ validatedNumberOfSamples,
3489
+ windowInSeconds,
3490
+ dataOffsetInSeconds,
3491
+ normalize
3492
+ ]);
3493
+ const {
3494
+ frequencyData,
3495
+ amplitudes,
3496
+ bass,
3497
+ mid,
3498
+ treble,
3499
+ bassValues,
3500
+ midValues,
3501
+ trebleValues
3502
+ } = useMemo17(() => {
3503
+ if (!audioData || !includeFrequencyData) {
3504
+ return {
3505
+ frequencyData: null,
3506
+ amplitudes: null,
3507
+ bass: null,
3508
+ mid: null,
3509
+ treble: null,
3510
+ bassValues: null,
3511
+ midValues: null,
3512
+ trebleValues: null
3513
+ };
3514
+ }
3515
+ try {
3516
+ const frequencyData2 = visualizeAudio({
3517
+ fps,
3518
+ frame: adjustedFrame,
3519
+ audioData,
3520
+ numberOfSamples: validatedNumberOfSamples
3521
+ });
3522
+ const { sampleRate } = audioData;
3523
+ const bassValues2 = [];
3524
+ const midValues2 = [];
3525
+ const trebleValues2 = [];
3526
+ for (let i = 0; i < frequencyData2.length; i++) {
3527
+ const freq = i * sampleRate / (2 * frequencyData2.length);
3528
+ const value = frequencyData2[i];
3529
+ if (freq >= 0 && freq < 250) {
3530
+ bassValues2.push(value * 2.5);
3531
+ } else if (freq >= 250 && freq < 4e3) {
3532
+ midValues2.push(value * 3);
3533
+ midValues2.push(value * 4.5);
3534
+ midValues2.push(value * 5);
3535
+ } else if (freq >= 4e3 && freq < sampleRate / 2) {
3536
+ trebleValues2.push(value * 30);
3537
+ }
3538
+ }
3539
+ const getAverage = (arr) => arr.length > 0 ? arr.reduce((a, b) => a + b, 0) / arr.length : 0;
3540
+ const bass2 = getAverage(bassValues2);
3541
+ const mid2 = getAverage(midValues2);
3542
+ const treble2 = getAverage(trebleValues2);
3543
+ const amplitudes2 = frequencyData2.map((value) => {
3544
+ const db = 20 * Math.log10(value);
3545
+ const scaled = (db - minDb) / (maxDb - minDb);
3546
+ return Math.max(0, Math.min(1, scaled));
3547
+ });
3548
+ return {
3549
+ frequencyData: frequencyData2,
3550
+ amplitudes: amplitudes2,
3551
+ bass: bass2,
3552
+ mid: mid2,
3553
+ treble: treble2,
3554
+ bassValues: bassValues2,
3555
+ midValues: midValues2,
3556
+ trebleValues: trebleValues2.reverse()
3557
+ };
3558
+ } catch (error2) {
3559
+ console.error("Error generating frequency data:", error2);
3560
+ return {
3561
+ frequencyData: null,
3562
+ amplitudes: null,
3563
+ bass: null,
3564
+ mid: null,
3565
+ treble: null
3566
+ };
3567
+ }
3568
+ }, [
3569
+ audioData,
3570
+ includeFrequencyData,
3571
+ adjustedFrame,
3572
+ fps,
3573
+ validatedNumberOfSamples,
3574
+ windowInSeconds,
3575
+ dataOffsetInSeconds,
3576
+ minDb,
3577
+ maxDb
3578
+ ]);
3579
+ const isLoading = !audioData;
3580
+ const error = audioData === null && !isLoading ? "Failed to load audio data" : null;
3581
+ return {
3582
+ waveformData,
3583
+ frequencyData,
3584
+ amplitudes,
3585
+ audioData,
3586
+ isLoading,
3587
+ error,
3588
+ bass,
3589
+ bassValues,
3590
+ mid,
3591
+ midValues,
3592
+ treble,
3593
+ trebleValues
3594
+ };
3595
+ };
3596
+
3597
+ // src/templates/waveform/Waveform.tsx
3598
+ var WaveformContext = createContext5(null);
3599
+ var useWaveformContext = () => {
3600
+ const context = useContext6(WaveformContext);
3601
+ if (!context) {
3602
+ throw new Error("useWaveformContext must be used within a Waveform component");
3603
+ }
3604
+ return context;
3605
+ };
3606
+ var Waveform = ({
3607
+ config: config15,
3608
+ children,
3609
+ className = "",
3610
+ style = {}
3611
+ }) => {
3612
+ const frame = useCurrentFrame11();
3613
+ const { width: videoWidth, height: videoHeight, fps } = useVideoConfig12();
3614
+ const { waveformData, frequencyData, amplitudes, audioData, bass, mid, treble, bassValues, midValues, trebleValues } = useWaveformData({
3615
+ audioSrc: config15.audioSrc,
3616
+ numberOfSamples: config15.numberOfSamples || 128,
3617
+ windowInSeconds: config15.windowInSeconds || 1 / fps,
3618
+ dataOffsetInSeconds: config15.dataOffsetInSeconds || 0,
3619
+ normalize: config15.normalize || false,
3620
+ frame,
3621
+ fps,
3622
+ posterize: config15.posterize,
3623
+ includeFrequencyData: config15.useFrequencyData || false
3624
+ });
3625
+ const width = config15.width || videoWidth;
3626
+ const height = config15.height || videoHeight;
3627
+ const contextValue = {
3628
+ waveformData,
3629
+ frequencyData,
3630
+ amplitudes,
3631
+ audioData,
3632
+ frame,
3633
+ fps,
3634
+ config: config15,
3635
+ width,
3636
+ height,
3637
+ bass,
3638
+ mid,
3639
+ treble,
3640
+ bassValues,
3641
+ midValues,
3642
+ trebleValues
3643
+ };
3644
+ return /* @__PURE__ */ React25.createElement(WaveformContext.Provider, { value: contextValue }, /* @__PURE__ */ React25.createElement(
3645
+ "div",
3646
+ {
3647
+ className: `relative ${className}`,
3648
+ style: {
3649
+ width,
3650
+ height,
3651
+ position: "relative",
3652
+ backgroundColor: config15.backgroundColor || "transparent",
3653
+ ...style
3654
+ }
3655
+ },
3656
+ children
3657
+ ));
3658
+ };
3659
+
3660
+ // src/templates/waveform/components/WaveformCircle.tsx
3661
+ var WaveformCircle = ({ data }) => {
3662
+ const {
3663
+ config: config15,
3664
+ className = "",
3665
+ style = {},
3666
+ strokeColor = "#FF6B6B",
3667
+ strokeWidth = 3,
3668
+ fill = "none",
3669
+ opacity = 1,
3670
+ radius = 80,
3671
+ centerX = 50,
3672
+ centerY = 50,
3673
+ startAngle = 0,
3674
+ endAngle = 360,
3675
+ amplitude = 1,
3676
+ rotationSpeed = 0,
3677
+ gradientStartColor,
3678
+ gradientEndColor
3679
+ } = data;
3680
+ return /* @__PURE__ */ React26.createElement(Waveform, { config: config15, className, style }, /* @__PURE__ */ React26.createElement(
3681
+ WaveformCircleContent,
3682
+ {
3683
+ strokeColor,
3684
+ strokeWidth,
3685
+ fill,
3686
+ opacity,
3687
+ radius,
3688
+ centerX,
3689
+ centerY,
3690
+ startAngle,
3691
+ endAngle,
3692
+ amplitude,
3693
+ rotationSpeed,
3694
+ gradientStartColor,
3695
+ gradientEndColor
3696
+ }
3697
+ ));
3698
+ };
3699
+ var WaveformCircleContent = ({
3700
+ strokeColor,
3701
+ strokeWidth,
3702
+ fill,
3703
+ opacity,
3704
+ radius,
3705
+ centerX,
3706
+ centerY,
3707
+ startAngle,
3708
+ endAngle,
3709
+ amplitude,
3710
+ rotationSpeed,
3711
+ gradientStartColor,
3712
+ gradientEndColor
3713
+ }) => {
3714
+ const { waveformData, width, height, frame } = useWaveformContext();
3715
+ const circleRadius = Math.min(width, height) * (radius || 80) / 100;
3716
+ const circleCenterX = width * (centerX || 50) / 100;
3717
+ const circleCenterY = height * (centerY || 50) / 100;
3718
+ const rotation = frame * (rotationSpeed || 0) % 360;
3719
+ const circularPath = useMemo18(() => {
3720
+ if (!waveformData) return "";
3721
+ const totalAngle = (endAngle || 360) - (startAngle || 0);
3722
+ const angleStep = totalAngle / waveformData.length;
3723
+ let path = "";
3724
+ waveformData.forEach((value, index) => {
3725
+ const angle = ((startAngle || 0) + index * angleStep + rotation) * (Math.PI / 180);
3726
+ const waveRadius = circleRadius + value * (amplitude || 1) * circleRadius * 0.3;
3727
+ const x = circleCenterX + waveRadius * Math.cos(angle);
3728
+ const y = circleCenterY + waveRadius * Math.sin(angle);
3729
+ if (index === 0) {
3730
+ path += `M ${x} ${y}`;
3731
+ } else {
3732
+ path += ` L ${x} ${y}`;
3733
+ }
3734
+ });
3735
+ if (Math.abs((endAngle || 360) - (startAngle || 0)) >= 360) {
3736
+ path += " Z";
3737
+ }
3738
+ return path;
3739
+ }, [waveformData, circleRadius, circleCenterX, circleCenterY, startAngle, endAngle, rotation, amplitude]);
3740
+ if (!waveformData) {
3741
+ return /* @__PURE__ */ React26.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading circular waveform...");
3742
+ }
3743
+ const gradientId = "circle-waveform-gradient";
3744
+ const hasGradient = gradientStartColor && gradientEndColor;
3745
+ return /* @__PURE__ */ React26.createElement(
3746
+ "svg",
3747
+ {
3748
+ width,
3749
+ height,
3750
+ className: "absolute inset-0",
3751
+ style: { pointerEvents: "none" }
3752
+ },
3753
+ hasGradient && /* @__PURE__ */ React26.createElement("defs", null, /* @__PURE__ */ React26.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "0%" }, /* @__PURE__ */ React26.createElement("stop", { offset: "0%", stopColor: gradientStartColor }), /* @__PURE__ */ React26.createElement("stop", { offset: "100%", stopColor: gradientEndColor }))),
3754
+ /* @__PURE__ */ React26.createElement(
3755
+ "path",
3756
+ {
3757
+ d: circularPath,
3758
+ stroke: hasGradient ? `url(#${gradientId})` : strokeColor,
3759
+ strokeWidth,
3760
+ fill,
3761
+ opacity,
3762
+ strokeLinecap: "round",
3763
+ strokeLinejoin: "round"
3764
+ }
3765
+ )
3766
+ );
3767
+ };
3768
+
3769
+ // src/templates/waveform/components/WaveformHistogram.tsx
3770
+ import React27 from "react";
3771
+ var WaveformHistogram = ({ data }) => {
3772
+ const {
3773
+ config: config15,
3774
+ className = "",
3775
+ style = {},
3776
+ barColor = "#FF6B6B",
3777
+ barWidth = 4,
3778
+ barSpacing = 2,
3779
+ barBorderRadius = 2,
3780
+ opacity = 1,
3781
+ horizontalSymmetry = true,
3782
+ verticalMirror = false,
3783
+ histogramStyle = "centered",
3784
+ amplitude = 1,
3785
+ multiplier = 1,
3786
+ gradientStartColor,
3787
+ gradientEndColor,
3788
+ gradientDirection = "vertical",
3789
+ gradientStyle = "normal",
3790
+ waveDirection = "right-to-left"
3791
+ } = data;
3792
+ return /* @__PURE__ */ React27.createElement(Waveform, { config: config15, className, style }, /* @__PURE__ */ React27.createElement(
3793
+ WaveformHistogramContent,
3794
+ {
3795
+ barColor,
3796
+ barWidth,
3797
+ barSpacing,
3798
+ barBorderRadius,
3799
+ opacity,
3800
+ horizontalSymmetry,
3801
+ verticalMirror,
3802
+ histogramStyle,
3803
+ amplitude,
3804
+ gradientStartColor,
3805
+ gradientEndColor,
3806
+ gradientDirection,
3807
+ multiplier,
3808
+ gradientStyle,
3809
+ waveDirection
3810
+ }
3811
+ ));
3812
+ };
3813
+ var WaveformHistogramContent = ({
3814
+ barColor,
3815
+ barWidth,
3816
+ barSpacing,
3817
+ barBorderRadius,
3818
+ opacity,
3819
+ horizontalSymmetry,
3820
+ verticalMirror,
3821
+ histogramStyle,
3822
+ amplitude,
3823
+ gradientStartColor,
3824
+ gradientEndColor,
3825
+ gradientDirection,
3826
+ multiplier,
3827
+ gradientStyle,
3828
+ waveDirection
3829
+ }) => {
3830
+ const { waveformData, frequencyData, amplitudes, width, height } = useWaveformContext();
3831
+ const dataToUse = amplitudes || waveformData;
3832
+ if (!dataToUse) {
3833
+ return /* @__PURE__ */ React27.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading histogram...");
3834
+ }
3835
+ let directedData = waveDirection === "left-to-right" ? dataToUse.slice(1).reverse() : dataToUse;
3836
+ const frequencies = horizontalSymmetry ? [...directedData, ...directedData.slice(1).reverse()] : Array(multiplier).fill(directedData).flat();
3837
+ const Bars = ({ growUpwards }) => {
3838
+ const styleGradientProp = gradientStartColor && gradientEndColor ? {
3839
+ background: `linear-gradient(${gradientDirection === "horizontal" ? gradientStyle === "mirrored" ? "to right" : growUpwards ? "to right" : "to left" : gradientStyle === "normal" ? growUpwards ? "to top" : "to bottom" : "to bottom"}, ${gradientStartColor}, ${gradientEndColor})`
3840
+ } : { backgroundColor: barColor };
3841
+ const containerStyle2 = {
3842
+ display: "flex",
3843
+ flexDirection: "row",
3844
+ alignItems: growUpwards ? "flex-end" : "flex-start",
3845
+ height: "100%",
3846
+ width: "100%",
3847
+ ...histogramStyle === "centered" && {
3848
+ justifyContent: "center",
3849
+ gap: `${barSpacing}px`
3850
+ },
3851
+ ...histogramStyle === "full-width" && {
3852
+ gap: `${barSpacing}px`,
3853
+ justifyContent: "space-between"
3854
+ },
3855
+ opacity: gradientStyle === "mirrored" && !growUpwards ? 0.25 : 1
3856
+ };
3857
+ return /* @__PURE__ */ React27.createElement("div", { style: containerStyle2 }, frequencies.map((value, index) => /* @__PURE__ */ React27.createElement(
3858
+ "div",
3859
+ {
3860
+ key: index,
3861
+ style: {
3862
+ ...histogramStyle === "full-width" ? { width: `${barWidth}px` } : { width: `${barWidth}px` },
3863
+ ...styleGradientProp,
3864
+ height: `${Math.min(
3865
+ height / 2,
3866
+ Math.abs(value) * (height / 2) * (amplitude || 1)
3867
+ )}px`,
3868
+ borderRadius: growUpwards ? `${barBorderRadius}px ${barBorderRadius}px 0 0` : `0 0 ${barBorderRadius}px ${barBorderRadius}px`,
3869
+ opacity
3870
+ }
3871
+ }
3872
+ )));
3873
+ };
3874
+ if (verticalMirror) {
3875
+ const topHalfStyle = {
3876
+ position: "absolute",
3877
+ bottom: `calc(100% - ${height / 2}px)`,
3878
+ height: `${height / 2}px`,
3879
+ width: "100%",
3880
+ left: 0
3881
+ };
3882
+ const bottomHalfStyle = {
3883
+ position: "absolute",
3884
+ top: `${height / 2}px`,
3885
+ height: `${height / 2}px`,
3886
+ width: "100%",
3887
+ left: 0
3888
+ };
3889
+ return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement("div", { style: topHalfStyle }, /* @__PURE__ */ React27.createElement(Bars, { growUpwards: true })), /* @__PURE__ */ React27.createElement("div", { style: bottomHalfStyle }, /* @__PURE__ */ React27.createElement(Bars, { growUpwards: false })));
3890
+ }
3891
+ const containerStyle = {
3892
+ width: "100%",
3893
+ position: "absolute",
3894
+ top: `${height / 2 - height / 4}px`,
3895
+ height: `${height / 2}px`,
3896
+ left: 0
3897
+ };
3898
+ return /* @__PURE__ */ React27.createElement("div", { style: containerStyle }, /* @__PURE__ */ React27.createElement(Bars, { growUpwards: true }));
3899
+ };
3900
+
3901
+ // src/templates/waveform/components/WaveformHistogramRanged.tsx
3902
+ import React28 from "react";
3903
+ var WaveformHistogramRanged = ({ data }) => {
3904
+ const {
3905
+ config: config15,
3906
+ className = "",
3907
+ style = {},
3908
+ barColor = "#FF6B6B",
3909
+ barWidth = 4,
3910
+ barSpacing = 2,
3911
+ barBorderRadius = 2,
3912
+ opacity = 1,
3913
+ verticalMirror = false,
3914
+ histogramStyle = "centered",
3915
+ amplitude = 1,
3916
+ showFrequencyRanges = true,
3917
+ rangeDividerColor = "#666",
3918
+ rangeLabels = false,
3919
+ bassBarColor = "#5DADE2",
3920
+ midBarColor = "#58D68D",
3921
+ trebleBarColor = "#F5B041",
3922
+ gradientStartColor,
3923
+ gradientEndColor,
3924
+ gradientDirection = "vertical",
3925
+ gradientStyle = "normal",
3926
+ horizontalSymmetry = false,
3927
+ waveDirection = "right-to-left"
3928
+ } = data;
3929
+ return /* @__PURE__ */ React28.createElement(Waveform, { config: config15, className, style }, /* @__PURE__ */ React28.createElement(
3930
+ WaveformHistogramRangedContent,
3931
+ {
3932
+ barColor,
3933
+ barWidth,
3934
+ barSpacing,
3935
+ barBorderRadius,
3936
+ opacity,
3937
+ verticalMirror,
3938
+ histogramStyle,
3939
+ amplitude,
3940
+ showFrequencyRanges,
3941
+ rangeDividerColor,
3942
+ rangeLabels,
3943
+ bassBarColor,
3944
+ midBarColor,
3945
+ trebleBarColor,
3946
+ gradientStartColor,
3947
+ gradientEndColor,
3948
+ gradientDirection,
3949
+ gradientStyle,
3950
+ horizontalSymmetry,
3951
+ waveDirection
3952
+ }
3953
+ ));
3954
+ };
3955
+ var WaveformHistogramRangedContent = ({
3956
+ barColor,
3957
+ barWidth,
3958
+ barSpacing,
3959
+ barBorderRadius,
3960
+ opacity,
3961
+ verticalMirror,
3962
+ histogramStyle,
3963
+ amplitude,
3964
+ showFrequencyRanges,
3965
+ rangeDividerColor,
3966
+ rangeLabels,
3967
+ bassBarColor,
3968
+ midBarColor,
3969
+ trebleBarColor,
3970
+ gradientStartColor,
3971
+ gradientEndColor,
3972
+ gradientDirection,
3973
+ gradientStyle,
3974
+ horizontalSymmetry,
3975
+ waveDirection
3976
+ }) => {
3977
+ const { amplitudes, bassValues, midValues, trebleValues, height } = useWaveformContext();
3978
+ if (!amplitudes || !bassValues || !midValues || !trebleValues) {
3979
+ return /* @__PURE__ */ React28.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading frequency data...");
3980
+ }
3981
+ const bassFrequencies = bassValues;
3982
+ const midFrequencies = midValues;
3983
+ const trebleFrequencies = trebleValues;
3984
+ const allFrequencies = waveDirection === "right-to-left" ? [bassFrequencies, midFrequencies, trebleFrequencies].flat() : [trebleFrequencies, midFrequencies, bassFrequencies].flat();
3985
+ const unifiedWaveform = horizontalSymmetry ? [...allFrequencies.slice(1).reverse(), ...allFrequencies] : allFrequencies;
3986
+ const Bars = ({ growUpwards }) => {
3987
+ const containerStyle2 = {
3988
+ display: "flex",
3989
+ flexDirection: "row",
3990
+ alignItems: growUpwards ? "flex-end" : "flex-start",
3991
+ height: "100%",
3992
+ width: "100%",
3993
+ ...histogramStyle === "centered" && {
3994
+ justifyContent: "center",
3995
+ gap: `${barSpacing}px`
3996
+ },
3997
+ ...histogramStyle === "full-width" && {
3998
+ gap: `${barSpacing}px`,
3999
+ justifyContent: "space-between"
4000
+ },
4001
+ opacity: gradientStyle === "mirrored" && !growUpwards ? 0.25 : 1
4002
+ };
4003
+ return /* @__PURE__ */ React28.createElement("div", { style: containerStyle2 }, unifiedWaveform.map((value, index) => {
4004
+ const rangeName = index === 0 ? "Bass" : index === 1 ? "Mid" : "Treble";
4005
+ const styleGradientProp = gradientStartColor && gradientEndColor ? {
4006
+ background: `linear-gradient(${gradientDirection === "horizontal" ? gradientStyle === "mirrored" ? "to right" : growUpwards ? "to right" : "to left" : gradientStyle === "normal" ? growUpwards ? "to top" : "to bottom" : "to bottom"}, ${gradientStartColor}, ${gradientEndColor})`
4007
+ } : { backgroundColor: barColor };
4008
+ return /* @__PURE__ */ React28.createElement(
4009
+ "div",
4010
+ {
4011
+ key: index,
4012
+ style: {
4013
+ width: `${barWidth || 4}px`,
4014
+ // Wider bars for the three ranges
4015
+ ...styleGradientProp,
4016
+ height: `${Math.min(
4017
+ height / 2,
4018
+ Math.abs(value) * (height / 2) * (amplitude || 1)
4019
+ )}px`,
4020
+ borderRadius: growUpwards ? `${barBorderRadius}px ${barBorderRadius}px 0 0` : `0 0 ${barBorderRadius}px ${barBorderRadius}px`,
4021
+ opacity,
4022
+ position: "relative"
4023
+ },
4024
+ title: `${rangeName}: ${(value * 100).toFixed(1)}%`
4025
+ },
4026
+ rangeLabels && /* @__PURE__ */ React28.createElement("div", { style: {
4027
+ position: "absolute",
4028
+ bottom: growUpwards ? "-20px" : "auto",
4029
+ top: growUpwards ? "auto" : "-20px",
4030
+ left: "50%",
4031
+ transform: "translateX(-50%)",
4032
+ fontSize: "10px",
4033
+ color: rangeDividerColor,
4034
+ whiteSpace: "nowrap"
4035
+ } }, rangeName)
4036
+ );
4037
+ }));
4038
+ };
4039
+ if (verticalMirror) {
4040
+ const topHalfStyle = {
4041
+ position: "absolute",
4042
+ bottom: `calc(100% - ${height / 2}px)`,
4043
+ height: `${height / 2}px`,
4044
+ width: "100%",
4045
+ left: 0
4046
+ };
4047
+ const bottomHalfStyle = {
4048
+ position: "absolute",
4049
+ top: `${height / 2}px`,
4050
+ height: `${height / 2}px`,
4051
+ width: "100%",
4052
+ left: 0
4053
+ };
4054
+ return /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement("div", { style: topHalfStyle }, /* @__PURE__ */ React28.createElement(Bars, { growUpwards: true })), /* @__PURE__ */ React28.createElement("div", { style: bottomHalfStyle }, /* @__PURE__ */ React28.createElement(Bars, { growUpwards: false })));
4055
+ }
4056
+ const containerStyle = {
4057
+ width: "100%",
4058
+ position: "absolute",
4059
+ top: `${height / 2 - height / 4}px`,
4060
+ height: `${height / 2}px`,
4061
+ left: 0
4062
+ };
4063
+ return /* @__PURE__ */ React28.createElement("div", { style: containerStyle }, /* @__PURE__ */ React28.createElement(Bars, { growUpwards: true }));
4064
+ };
4065
+
4066
+ // src/templates/waveform/components/WaveformLine.tsx
4067
+ import React29, { useMemo as useMemo19 } from "react";
4068
+ import { createSmoothSvgPath } from "@remotion/media-utils";
4069
+ import { useCurrentFrame as useCurrentFrame12, useVideoConfig as useVideoConfig13 } from "remotion";
4070
+ var detectBeat = (frequencyData, amplitudes, threshold = 0.7, bpm, frame = 0, fps = 30) => {
4071
+ if (!frequencyData || !amplitudes || frequencyData.length === 0) return false;
4072
+ if (bpm) {
4073
+ const beatInterval = 60 / bpm * fps;
4074
+ const beatFrame = Math.round(frame / beatInterval) * beatInterval;
4075
+ return Math.abs(frame - beatFrame) < 2;
4076
+ }
4077
+ const bassFrequencies = amplitudes.slice(0, Math.floor(amplitudes.length * 0.15));
4078
+ const midFrequencies = amplitudes.slice(Math.floor(amplitudes.length * 0.15), Math.floor(amplitudes.length * 0.4));
4079
+ const bassEnergy = Math.sqrt(bassFrequencies.reduce((sum, val) => sum + val * val, 0) / bassFrequencies.length);
4080
+ const midEnergy = Math.sqrt(midFrequencies.reduce((sum, val) => sum + val * val, 0) / midFrequencies.length);
4081
+ const bassPeak = Math.max(...bassFrequencies);
4082
+ const midPeak = Math.max(...midFrequencies);
4083
+ const totalEnergy = bassEnergy * 0.6 + midEnergy * 0.2 + bassPeak * 0.15 + midPeak * 0.05;
4084
+ const normalizedEnergy = Math.min(totalEnergy, 1);
4085
+ return normalizedEnergy > threshold;
4086
+ };
4087
+ var easingFunctions = {
4088
+ linear: (t) => t,
4089
+ "ease-in": (t) => t * t,
4090
+ "ease-out": (t) => 1 - (1 - t) * (1 - t),
4091
+ "ease-in-out": (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2,
4092
+ bounce: (t) => {
4093
+ if (t < 1 / 2.75) return 7.5625 * t * t;
4094
+ if (t < 2 / 2.75) return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;
4095
+ if (t < 2.5 / 2.75) return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375;
4096
+ return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
4097
+ }
4098
+ };
4099
+ var WaveformLine = ({ data }) => {
4100
+ const {
4101
+ config: config15,
4102
+ className = "",
4103
+ style = {},
4104
+ strokeColor = "#FF6B6B",
4105
+ strokeWidth = 3,
4106
+ strokeLinecap = "round",
4107
+ strokeLinejoin = "round",
4108
+ fill = "none",
4109
+ opacity = 1,
4110
+ centerLine = false,
4111
+ centerLineColor = "#666",
4112
+ centerLineWidth = 1,
4113
+ beatSync = false,
4114
+ bpm,
4115
+ beatThreshold = 0.7,
4116
+ beatAmplitudeMultiplier = 1.2,
4117
+ beatAnimationDuration = 30,
4118
+ smoothAnimation = true,
4119
+ waveSpacing = 0.1,
4120
+ waveSegments = 1,
4121
+ waveOffset = 0,
4122
+ waveDirection = "horizontal",
4123
+ amplitudeCurve = "ease-out",
4124
+ animationSpeed = 0.5,
4125
+ pulseOnBeat = false,
4126
+ pulseColor = "#FFD700",
4127
+ pulseScale = 1.2
4128
+ } = data;
4129
+ return /* @__PURE__ */ React29.createElement(Waveform, { config: config15, className, style }, /* @__PURE__ */ React29.createElement(
4130
+ WaveformLineContent,
4131
+ {
4132
+ strokeColor,
4133
+ strokeWidth,
4134
+ strokeLinecap,
4135
+ strokeLinejoin,
4136
+ fill,
4137
+ opacity,
4138
+ centerLine,
4139
+ centerLineColor,
4140
+ centerLineWidth,
4141
+ beatSync,
4142
+ bpm,
4143
+ beatThreshold,
4144
+ beatAmplitudeMultiplier,
4145
+ beatAnimationDuration,
4146
+ smoothAnimation,
4147
+ waveSpacing,
4148
+ waveSegments,
4149
+ waveOffset,
4150
+ waveDirection,
4151
+ amplitudeCurve,
4152
+ animationSpeed,
4153
+ pulseOnBeat,
4154
+ pulseColor,
4155
+ pulseScale
4156
+ }
4157
+ ));
4158
+ };
4159
+ var WaveformLineContent = ({
4160
+ strokeColor,
4161
+ strokeWidth,
4162
+ strokeLinecap,
4163
+ strokeLinejoin,
4164
+ fill,
4165
+ opacity,
4166
+ centerLine,
4167
+ centerLineColor,
4168
+ centerLineWidth,
4169
+ beatSync,
4170
+ bpm,
4171
+ beatThreshold,
4172
+ beatAmplitudeMultiplier,
4173
+ beatAnimationDuration,
4174
+ smoothAnimation,
4175
+ waveSpacing,
4176
+ waveSegments,
4177
+ waveOffset,
4178
+ waveDirection,
4179
+ amplitudeCurve,
4180
+ animationSpeed,
4181
+ pulseOnBeat,
4182
+ pulseColor,
4183
+ pulseScale
4184
+ }) => {
4185
+ const { waveformData, frequencyData, amplitudes, width, height, config: config15, frame, fps } = useWaveformContext();
4186
+ const currentFrame = useCurrentFrame12();
4187
+ const videoConfig = useVideoConfig13();
4188
+ const isBeat = useMemo19(() => {
4189
+ if (!beatSync || !frequencyData || !amplitudes) return false;
4190
+ return detectBeat(frequencyData, amplitudes, beatThreshold, bpm, currentFrame, fps);
4191
+ }, [beatSync, frequencyData, amplitudes, beatThreshold, bpm, currentFrame, fps]);
4192
+ const beatProgress = useMemo19(() => {
4193
+ if (!isBeat || !beatAnimationDuration) return 0;
4194
+ const beatStartFrame = Math.floor(currentFrame / beatAnimationDuration) * beatAnimationDuration;
4195
+ const progress = (currentFrame - beatStartFrame) / beatAnimationDuration;
4196
+ const clampedProgress = Math.max(0, Math.min(1, progress));
4197
+ if (smoothAnimation) {
4198
+ return 1 - Math.pow(1 - clampedProgress, 3);
4199
+ }
4200
+ return clampedProgress;
4201
+ }, [isBeat, currentFrame, beatAnimationDuration, smoothAnimation]);
4202
+ const currentBeatMultiplier = useMemo19(() => {
4203
+ if (!beatSync || !isBeat || !beatAmplitudeMultiplier || !amplitudeCurve) return 1;
4204
+ const easing = easingFunctions[amplitudeCurve];
4205
+ const easedProgress = easing(beatProgress);
4206
+ return 1 + (beatAmplitudeMultiplier - 1) * (1 - easedProgress);
4207
+ }, [beatSync, isBeat, beatProgress, beatAmplitudeMultiplier, amplitudeCurve]);
4208
+ const smoothFactor = useMemo19(() => {
4209
+ if (!beatSync) {
4210
+ return 0.3;
4211
+ }
4212
+ return smoothAnimation ? 0.7 : 1;
4213
+ }, [beatSync, smoothAnimation]);
4214
+ const waveformPaths = useMemo19(() => {
4215
+ if (!waveformData) return [];
4216
+ const paths = [];
4217
+ const segments = waveSegments || 1;
4218
+ const spacing = waveSpacing || 0.1;
4219
+ const offset = waveOffset || 0;
4220
+ const speed = animationSpeed || 1;
4221
+ const segmentWidth = width / segments;
4222
+ const segmentSpacing = segmentWidth * spacing;
4223
+ for (let i = 0; i < segments; i++) {
4224
+ const segmentStart = i * segmentWidth;
4225
+ const segmentEnd = (i + 1) * segmentWidth;
4226
+ const segmentDataWidth = segmentEnd - segmentStart;
4227
+ const points = waveformData.map((y, index) => {
4228
+ const progress = index / (waveformData.length - 1);
4229
+ const x = segmentStart + progress * segmentDataWidth + offset;
4230
+ let animatedAmplitude = y * (config15.amplitude || 1) * currentBeatMultiplier * speed;
4231
+ const baseAmplitude = y * (config15.amplitude || 1) * speed;
4232
+ const beatAmplitude = animatedAmplitude - baseAmplitude;
4233
+ animatedAmplitude = baseAmplitude + beatAmplitude * smoothFactor;
4234
+ const yPos = waveDirection === "horizontal" ? animatedAmplitude * height / 2 + height / 2 : animatedAmplitude * width / 2 + width / 2;
4235
+ return waveDirection === "horizontal" ? { x, y: yPos } : { x: yPos, y: x };
4236
+ });
4237
+ const path = createSmoothSvgPath({ points });
4238
+ paths.push({ path, segmentIndex: i });
4239
+ }
4240
+ return paths;
4241
+ }, [waveformData, width, height, config15.amplitude, currentBeatMultiplier, animationSpeed, waveSegments, waveSpacing, waveOffset, waveDirection, smoothFactor]);
4242
+ if (!waveformData) {
4243
+ return /* @__PURE__ */ React29.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading waveform...");
4244
+ }
4245
+ return /* @__PURE__ */ React29.createElement(
4246
+ "svg",
4247
+ {
4248
+ width,
4249
+ height,
4250
+ className: "absolute inset-0",
4251
+ style: { pointerEvents: "none" }
4252
+ },
4253
+ centerLine && /* @__PURE__ */ React29.createElement(
4254
+ "line",
4255
+ {
4256
+ x1: waveDirection === "horizontal" ? 0 : width / 2,
4257
+ y1: waveDirection === "horizontal" ? height / 2 : 0,
4258
+ x2: waveDirection === "horizontal" ? width : width / 2,
4259
+ y2: waveDirection === "horizontal" ? height / 2 : height,
4260
+ stroke: centerLineColor,
4261
+ strokeWidth: centerLineWidth,
4262
+ opacity: 0.3
4263
+ }
4264
+ ),
4265
+ waveformPaths.map(({ path, segmentIndex }) => /* @__PURE__ */ React29.createElement("g", { key: segmentIndex }, pulseOnBeat && isBeat && /* @__PURE__ */ React29.createElement(
4266
+ "path",
4267
+ {
4268
+ d: path,
4269
+ stroke: pulseColor,
4270
+ strokeWidth: (strokeWidth || 3) * (pulseScale || 1.2),
4271
+ strokeLinecap,
4272
+ strokeLinejoin,
4273
+ fill: "none",
4274
+ opacity: (opacity || 1) * (1 - beatProgress)
4275
+ }
4276
+ ), /* @__PURE__ */ React29.createElement(
4277
+ "path",
4278
+ {
4279
+ d: path,
4280
+ stroke: strokeColor,
4281
+ strokeWidth,
4282
+ strokeLinecap,
4283
+ strokeLinejoin,
4284
+ fill,
4285
+ opacity
4286
+ }
4287
+ )))
4288
+ );
4289
+ };
4290
+
4291
+ // src/templates/waveform/utils.ts
4292
+ var WaveformPresets = {
4293
+ stopgapLine: (props) => {
4294
+ return {
4295
+ componentId: "WaveformLine",
4296
+ type: "atom",
4297
+ data: {
4298
+ strokeColor: "#58C4DC",
4299
+ strokeWidth: 8,
4300
+ strokeLinecap: "round",
4301
+ opacity: 1,
4302
+ amplitudeCurve: "ease-in-out",
4303
+ animationSpeed: 0.15,
4304
+ smoothAnimation: true,
4305
+ ...props,
4306
+ config: {
4307
+ numberOfSamples: 64,
4308
+ // Increased for better frequency resolution
4309
+ windowInSeconds: 1 / 30,
4310
+ amplitude: 4,
4311
+ height: 300,
4312
+ width: 1920 * 3,
4313
+ posterize: 4,
4314
+ ...props.config
4315
+ }
4316
+ }
4317
+ };
4318
+ }
4319
+ };
4320
+
4321
+ // src/templates/waveform/index.ts
4322
+ registerComponent("WaveformLine", WaveformLine, "atom", {
4323
+ displayName: "WaveformLine"
4324
+ });
4325
+ registerComponent("WaveformHistogram", WaveformHistogram, "atom", {
4326
+ displayName: "WaveformHistogram"
4327
+ });
4328
+ registerComponent("WaveformHistogramRanged", WaveformHistogramRanged, "atom", {
4329
+ displayName: "WaveformHistogramRanged"
4330
+ });
4331
+ registerComponent("WaveformCircle", WaveformCircle, "atom", {
4332
+ displayName: "WaveformCircle"
4333
+ });
4334
+
4335
+ // src/components/Composition.tsx
4336
+ import { Player as RemotionPlayer } from "@remotion/player";
4337
+ import React30 from "react";
4338
+ import { AbsoluteFill as AbsoluteFill7, Composition as RemotionComposition } from "remotion";
4339
+ import z5 from "zod";
4340
+ var CompositionLayout = ({ childrenData, style, config: config15 }) => {
4341
+ return /* @__PURE__ */ React30.createElement(
4342
+ CompositionProvider,
4343
+ {
4344
+ value: {
4345
+ root: childrenData,
4346
+ duration: config15.duration
4347
+ }
4348
+ },
4349
+ /* @__PURE__ */ React30.createElement(AbsoluteFill7, { style }, childrenData?.map((component) => /* @__PURE__ */ React30.createElement(
4350
+ ComponentRenderer,
4351
+ {
4352
+ key: component.id,
4353
+ ...component
4354
+ }
4355
+ )))
4356
+ );
4357
+ };
4358
+ var calculateCompositionLayoutMetadata = async ({ props, defaultProps, abortSignal, isRendering }) => {
4359
+ const updatedProps = await setDurationsInContext(props);
4360
+ let calculatedDuration = void 0;
4361
+ if (props.config?.fitDurationTo?.length > 0) {
4362
+ calculatedDuration = await calculateDuration(updatedProps.childrenData, {
4363
+ fitDurationTo: updatedProps.config.fitDurationTo
4364
+ });
4365
+ }
4366
+ const duration = calculatedDuration ?? props.config.duration ?? defaultProps.config.duration;
4367
+ const fps = props.config.fps ?? defaultProps.config.fps;
4368
+ const durationInFrames = Math.round(duration * fps);
4369
+ return {
4370
+ // Change the metadata
4371
+ durationInFrames,
4372
+ // or transform some props
4373
+ props: updatedProps,
4374
+ // // or add per-composition default codec
4375
+ // defaultCodec: 'h264',
4376
+ // // or add per-composition default video image format
4377
+ // defaultVideoImageFormat: 'png',
4378
+ // // or add per-composition default pixel format
4379
+ // defaultPixelFormat: 'yuv420p',
4380
+ width: props.config?.width || defaultProps.config.width,
4381
+ height: props.config?.height || defaultProps.config.height,
4382
+ fps,
4383
+ duration
4384
+ };
4385
+ };
4386
+ var Composition = ({
4387
+ id,
4388
+ childrenData,
4389
+ config: config15,
4390
+ style
4391
+ }) => {
4392
+ return /* @__PURE__ */ React30.createElement(
4393
+ RemotionComposition,
4394
+ {
4395
+ id,
4396
+ component: CompositionLayout,
4397
+ durationInFrames: Math.round(config15.duration * config15.fps),
4398
+ fps: config15.fps,
4399
+ width: config15.width ?? 1080,
4400
+ height: config15.height ?? 1920,
4401
+ defaultProps: { childrenData, style, config: config15 },
4402
+ calculateMetadata: calculateCompositionLayoutMetadata,
4403
+ schema: z5.object({})
4404
+ }
4405
+ );
4406
+ };
4407
+ var Player = (props) => {
4408
+ return /* @__PURE__ */ React30.createElement(
4409
+ RemotionPlayer,
4410
+ {
4411
+ component: CompositionLayout,
4412
+ durationInFrames: props.durationInFrames > 0 ? props.durationInFrames : 20,
4413
+ compositionWidth: props.compositionWidth > 0 ? props.compositionWidth : 1920,
4414
+ compositionHeight: props.compositionHeight > 0 ? props.compositionHeight : 1080,
4415
+ fps: props.fps > 0 ? props.fps : 30,
4416
+ ...props
4417
+ }
4418
+ );
4419
+ };
4420
+ export {
4421
+ Atom5 as AudioAtom,
4422
+ config13 as AudioAtomConfig,
4423
+ Layout as BaseLayout,
4424
+ config8 as BaseLayoutConfig,
4425
+ BlurEffect,
4426
+ config2 as BlurEffectConfig,
4427
+ ComponentRenderer,
4428
+ Composition,
4429
+ CompositionLayout,
4430
+ CompositionProvider,
4431
+ Frame,
4432
+ GenericEffectPresets,
4433
+ Atom2 as ImageAtom,
4434
+ config10 as ImageAtomConfig,
4435
+ LoopEffect,
4436
+ config3 as LoopEffectConfig,
4437
+ Atom6 as LottieAtom,
4438
+ config14 as LottieAtomConfig,
4439
+ NextjsLogo,
4440
+ PanEffect,
4441
+ config4 as PanEffectConfig,
4442
+ Player,
4443
+ Rings,
4444
+ RippleOutLayout,
4445
+ SceneFrame,
4446
+ ShakeEffect,
4447
+ config6 as ShakeEffectConfig,
4448
+ Atom as ShapeAtom,
4449
+ config9 as ShapeAtomConfig,
4450
+ StretchEffect,
4451
+ config7 as StretchEffectConfig,
4452
+ Atom3 as TextAtom,
4453
+ config11 as TextAtomConfig,
4454
+ TextFade,
4455
+ UniversalEffect,
4456
+ UniversalEffectProvider,
4457
+ Atom4 as VideoAtom,
4458
+ config12 as VideoAtomConfig,
4459
+ Waveform,
4460
+ WaveformCircle,
4461
+ WaveformHistogram,
4462
+ WaveformHistogramRanged,
4463
+ WaveformLine,
4464
+ WaveformPresets,
4465
+ ZoomEffect,
4466
+ config5 as ZoomEffectConfig,
4467
+ buildLayoutHook,
4468
+ calculateCircularPosition,
4469
+ calculateComponentDuration,
4470
+ calculateCompositionLayoutMetadata,
4471
+ calculateDuration,
4472
+ calculateGridPosition,
4473
+ calculateHierarchy,
4474
+ calculateTimingWithInheritance,
4475
+ clearFontCache,
4476
+ componentRegistry,
4477
+ createImageDataWithProxy,
4478
+ createImageProxyUrl,
4479
+ createRootContext,
4480
+ findComponentById,
4481
+ findMatchingComponents,
4482
+ findMatchingComponentsByQuery,
4483
+ findParentComponent,
4484
+ getComponent,
4485
+ getComponentConfig,
4486
+ getComponentWithConfig,
4487
+ getLoadedFontFamily,
4488
+ getLoadedFonts,
4489
+ getNormalizedFontName,
4490
+ isFontAvailable,
4491
+ isFontLoaded,
4492
+ loadGoogleFont,
4493
+ loadMultipleFonts,
4494
+ mergeContexts,
4495
+ needsProxying,
4496
+ nextjsLogoConfig,
4497
+ preloadCommonFonts,
4498
+ registerComponent,
4499
+ registerEffect,
4500
+ registerPackage,
4501
+ ringsConfig,
4502
+ rippleOutLayoutConfig,
4503
+ setDurationsInContext,
4504
+ textFadeConfig,
4505
+ useAnimatedStyles,
4506
+ useBoundaryCalculation,
4507
+ useComponentRegistry,
4508
+ useComposition,
4509
+ useFont,
4510
+ useFontLoader,
4511
+ useHasUniversalEffectProvider,
4512
+ useRenderContext,
4513
+ useRippleOutLayout,
4514
+ useUniversalEffect,
4515
+ useUniversalEffectOptional,
4516
+ useWaveformContext,
4517
+ useWaveformData
4518
+ };
4519
+ //# sourceMappingURL=index.mjs.map