@shotstack/shotstack-studio 2.0.0-beta.15 → 2.0.0-beta.16

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.
@@ -2,7 +2,7 @@ import * as j from "pixi.js";
2
2
  import { Filter as ep, deprecation as tp, GpuProgram as ip, GlProgram as sp, Color as ap } from "pixi.js";
3
3
  import * as rp from "howler";
4
4
  import * as Qo from "opentype.js";
5
- const np = "2.0.0-beta.15", op = {
5
+ const np = "2.0.0-beta.16", op = {
6
6
  version: np
7
7
  };
8
8
  class lp {
@@ -1,4 +1,4 @@
1
- (function(pe,ai){typeof exports=="object"&&typeof module<"u"?ai(exports,require("pixi.js"),require("howler"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js","howler","opentype.js"],ai):(pe=typeof globalThis<"u"?globalThis:pe||self,ai(pe.ShotstackStudio={},pe.PIXI,pe.Howler,pe.opentype))})(this,function(pe,ai,gp,mp){"use strict";var Ai=typeof document<"u"?document.currentScript:null;function ao(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const q=ao(ai),yp=ao(gp),ro=ao(mp),bp={version:"2.0.0-beta.15"};class wp{curves={};constructor(){this.initializeCurves()}initializeCurves(){this.curves={smooth:[[.5,0],[.5,1]],ease:[[.25,.1],[.25,1]],easeIn:[[.42,0],[1,1]],easeOut:[[0,0],[.58,1]],easeInOut:[[.42,0],[.58,1]],easeInQuad:[[.55,.085],[.68,.53]],easeInCubic:[[.55,.055],[.675,.19]],easeInQuart:[[.895,.03],[.685,.22]],easeInQuint:[[.755,.05],[.855,.06]],easeInSine:[[.47,0],[.745,.715]],easeInExpo:[[.95,.05],[.795,.035]],easeInCirc:[[.6,.04],[.98,.335]],easeInBack:[[.6,-.28],[.735,.045]],easeOutQuad:[[.25,.46],[.45,.94]],easeOutCubic:[[.215,.61],[.355,1]],easeOutQuart:[[.165,.84],[.44,1]],easeOutQuint:[[.23,1],[.32,1]],easeOutSine:[[.39,.575],[.565,1]],easeOutExpo:[[.19,1],[.22,1]],easeOutCirc:[[.075,.82],[.165,1]],easeOutBack:[[.175,.885],[.32,1.275]],easeInOutQuad:[[.455,.03],[.515,.955]],easeInOutCubic:[[.645,.045],[.355,1]],easeInOutQuart:[[.77,0],[.175,1]],easeInOutQuint:[[.86,0],[.07,1]],easeInOutSine:[[.445,.05],[.55,.95]],easeInOutExpo:[[1,0],[0,1]],easeInOutCirc:[[.785,.135],[.15,.86]],easeInOutBack:[[.68,-.55],[.265,1.55]]}}getValue(e,t,s,a){const r=this.curves[a??""]??this.curves.ease,[[n,o],[l,c]]=r,f=s+(3*n-3*l+1)*s*(1-s),d=e,h=e+(t-e)*o,p=e+(t-e)*c,m=t,w=f,x=1-w;return x**3*d+3*x**2*w*h+3*x*w**2*p+w**3*m}}class Ca{property;length;cubicBuilder;cachedIndex=0;constructor(e,t,s=0){this.property=this.createKeyframes(e,t,s),this.length=t,this.cubicBuilder=new wp}getValue(e){const t=this.findKeyframe(e);if(!t){if(this.property.length>0){if(e>=this.length)return this.property[this.property.length-1].to;if(e<0)return this.property[0].from}return 1}const s=(e-t.start)/t.length;switch(t.interpolation){case"bezier":return this.cubicBuilder.getValue(t.from,t.to,s,t.easing);case"constant":return t.from;case"linear":default:return t.from+(t.to-t.from)*s}}findKeyframe(e){const t=this.property;if(t.length===0)return;const s=t[this.cachedIndex];if(s){const o=s.start+s.length;if(Number.isFinite(o)&&e>=s.start&&e<o)return s}const a=this.cachedIndex+1;if(a<t.length){const o=t[a],l=o.start+o.length;if(Number.isFinite(l)&&e>=o.start&&e<l)return this.cachedIndex=a,o}const r=this.cachedIndex-1;if(r>=0){const o=t[r],l=o.start+o.length;if(Number.isFinite(l)&&e>=o.start&&e<l)return this.cachedIndex=r,o}const n=this.binarySearchKeyframe(e);if(n!==-1)return this.cachedIndex=n,t[n]}binarySearchKeyframe(e){const t=this.property;let s=0,a=t.length-1;for(;s<=a;){const r=Math.floor((s+a)/2),n=t[r],o=n.start+n.length;if(!Number.isFinite(o)){s=r+1;continue}if(e<n.start)a=r-1;else if(e>=o)s=r+1;else return r}return-1}createKeyframes(e,t,s=0){if(typeof e=="number")return[{start:0,length:t,from:e,to:e}];if(!e.length)throw new Error("Keyframes should have at least one value.");const a=this.createNormalizedKeyframes(e);try{this.validateKeyframes(a)}catch(r){console.warn("Keyframe configuration issues detected:",r)}return this.insertFillerKeyframes(a,t,s)}createNormalizedKeyframes(e){return e.filter(t=>typeof t.start=="number"&&typeof t.length=="number").toSorted((t,s)=>t.start-s.start).map(t=>({start:t.start,length:t.length,from:typeof t.from=="number"?t.from:0,to:typeof t.to=="number"?t.to:0,interpolation:t.interpolation,easing:t.easing}))}validateKeyframes(e){for(let t=0;t<e.length;t+=1){const s=e[t],a=e[t+1];if(!a){if(s.start+s.length>this.length)throw new Error("Last keyframe exceeds the maximum duration.");break}if(s.start+s.length>a.start)throw new Error("Overlapping keyframes detected.")}}insertFillerKeyframes(e,t,s=0){const a=[];for(let r=0;r<e.length;r+=1){const n=e[r],o=e[r+1];if(r===0&&n.start!==0){const f={start:0,length:n.start,from:s,to:n.from};a.push(f)}if(a.push(n),!o){if(n.start+n.length<t){const d=n.start+n.length,h={start:d,length:t-d,from:n.to,to:n.to};a.push(h)}break}if(n.start+n.length!==o.start){const f=n.start+n.length,d=o.start-f,h={start:f,length:d,from:n.to,to:o.from};a.push(h)}}return a}}class Sa{static Name="AudioLoadParser";id;name;extension;validAudioExtensions;constructor(){this.id=Sa.Name,this.name=Sa.Name,this.extension={type:[q.ExtensionType.LoadParser],priority:q.LoaderParserPriority.Normal,ref:null},this.validAudioExtensions=["mp3","mpeg","ogg","wav"]}test(e){const t=e.split("?")[0]?.split(".").pop()??"";return this.validAudioExtensions.includes(t)}async load(e,t,s){return new Promise(a=>{const r={src:e},n=new Howl(r);n.on("load",()=>a(n)),n.on("loaderror",()=>a(null))})}unload(e){e?.unload()}}class us{baseValue;mode;layers=[];length;clampRange;constructor(e,t,s,a){this.baseValue=e,this.length=t,this.mode=s,this.clampRange=a}addLayer(e){if(e.length===0)return;const t=this.mode==="additive"?0:1;this.layers.push(new Ca(e,this.length,t))}getValue(e){if(this.layers.length===0)return this.baseValue;if(this.mode==="additive"){let s=this.baseValue;for(const a of this.layers)s+=a.getValue(e);return s}let t=this.baseValue;for(const s of this.layers)t*=s.getValue(e);return this.clampRange&&(t=Math.max(this.clampRange.min,Math.min(this.clampRange.max,t))),t}}class vp{clipConfiguration;constructor(e){this.clipConfiguration=e}buildRelative(e,t){const s=[],a=[],r=[],n=[],o=[],{effect:l,length:c}=this.clipConfiguration;if(!l)return{offsetXKeyframes:s,offsetYKeyframes:a,opacityKeyframes:r,scaleKeyframes:n,rotationKeyframes:o};const f=0;switch(this.getPresetName()){case"zoomIn":{const h=this.getZoomSpeed();n.push({from:1,to:h,start:f,length:c,interpolation:"linear"});break}case"zoomOut":{const h=this.getZoomSpeed();n.push({from:h,to:1,start:f,length:c,interpolation:"linear"});break}case"slideLeft":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.width+e.width*p*2;if(h.width<m){const w=m/h.width;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.width-e.width)/2/e.width;s.push({from:p,to:-p,start:f,length:c});break}case"slideRight":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.width+e.width*p*2;if(h.width<m){const w=m/h.width;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.width-e.width)/2/e.width;s.push({from:-p,to:p,start:f,length:c});break}case"slideUp":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.height+e.height*p*2;if(h.height<m){const w=m/h.height;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.height-e.height)/2/e.height;a.push({from:p,to:-p,start:f,length:c});break}case"slideDown":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.height+e.height*p*2;if(h.height<m){const w=m/h.height;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.height-e.height)/2/e.height;a.push({from:-p,to:p,start:f,length:c});break}}return{offsetXKeyframes:s,offsetYKeyframes:a,opacityKeyframes:r,scaleKeyframes:n,rotationKeyframes:o}}getPresetName(){const[e]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);return e}getZoomSpeed(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("zoom"))switch(t){case"Slow":return 1.1;case"Fast":return 1.7;default:return 1.3}return 0}getSlideStart(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("slide"))switch(t){case"Slow":return .03;case"Fast":return .2;default:return .12}return 0}getFittedSize(e,t){switch(this.clipConfiguration.fit??"crop"){case"cover":case"crop":{const a=Math.max(e.width/t.width,e.height/t.height);return{width:t.width*a,height:t.height*a}}case"contain":{const a=Math.min(e.width/t.width,e.height/t.height);return{width:t.width*a,height:t.height*a}}case"none":default:return t}}}class xp{clipConfiguration;constructor(e){this.clipConfiguration=e}buildRelative(){return{in:this.buildInPresetRelative(),out:this.buildOutPresetRelative()}}buildInPresetRelative(){const e=[],t=[],s=[],a=[],r=[],n=[];if(!this.clipConfiguration.transition?.in)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n};const o=0,l=this.getInPresetLength();switch(this.getInPresetName()){case"fade":{s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"zoom":{a.push({from:10,to:1,start:o,length:l,interpolation:"bezier",easing:"easeIn"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"easeIn"});break}case"slideLeft":{e.push({from:.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"slideRight":{e.push({from:-.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"slideUp":{t.push({from:.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"slideDown":{t.push({from:-.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"carouselLeft":{e.push({from:1,to:0,start:o,length:l,interpolation:"linear"});break}case"carouselRight":{e.push({from:-1,to:0,start:o,length:l,interpolation:"linear"});break}case"carouselUp":{t.push({from:-1.05,to:0,start:o,length:l,interpolation:"linear"});break}case"carouselDown":{t.push({from:1.05,to:0,start:o,length:l,interpolation:"linear"});break}case"reveal":case"wipeRight":{n.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"wipeLeft":{n.push({from:1,to:0,start:o,length:l,interpolation:"bezier",easing:"ease"});break}}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n}}buildOutPresetRelative(){const e=[],t=[],s=[],a=[],r=[],n=[];if(!this.clipConfiguration.transition?.out)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n};const o=this.getOutPresetLength(),l=this.clipConfiguration.length-o;switch(this.getOutPresetName()){case"fade":{s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"zoom":{a.push({from:1,to:10,start:l,length:o,interpolation:"bezier",easing:"easeOut"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideLeft":{e.push({from:0,to:-.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"slideRight":{e.push({from:0,to:.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"slideUp":{t.push({from:0,to:-.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"slideDown":{t.push({from:0,to:.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselLeft":{e.push({from:0,to:-1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselRight":{e.push({from:0,to:1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselUp":{t.push({from:0,to:1.1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselDown":{t.push({from:0,to:-1.1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"reveal":case"wipeRight":{n.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"wipeLeft":{n.push({from:0,to:1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n}}getInPresetName(){const[e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);return e}getOutPresetName(){const[e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);return e}getInPresetLength(){const e=this.clipConfiguration.transition?.in??"",[t,s]=e.split(/(Slow|Fast|VeryFast)/),a=t.startsWith("carousel"),r=t.startsWith("slide");if(t==="zoom")return .4;switch(s){case"Slow":return 2;case"Fast":return a||r?.25:.5;case"VeryFast":return .25;default:return a||r?.5:1}}getOutPresetLength(){const e=this.clipConfiguration.transition?.out??"",[t,s]=e.split(/(Slow|Fast|VeryFast)/),a=t.startsWith("carousel"),r=t.startsWith("slide");if(t==="zoom")return .4;switch(s){case"Slow":return 2;case"Fast":return a||r?.25:.5;case"VeryFast":return .25;default:return a||r?.5:1}}}const U={PlaybackPlay:"playback:play",PlaybackPause:"playback:pause",TimelineUpdated:"timeline:updated",TimelineBackgroundChanged:"timeline:backgroundChanged",ClipAdded:"clip:added",ClipSplit:"clip:split",ClipSelected:"clip:selected",ClipUpdated:"clip:updated",ClipDeleted:"clip:deleted",ClipRestored:"clip:restored",ClipCopied:"clip:copied",ClipLoadFailed:"clip:loadFailed",SelectionCleared:"selection:cleared",EditChanged:"edit:changed",EditUndo:"edit:undo",EditRedo:"edit:redo",TrackAdded:"track:added",TrackRemoved:"track:removed",DurationChanged:"duration:changed",OutputResized:"output:resized",OutputResolutionChanged:"output:resolutionChanged",OutputAspectRatioChanged:"output:aspectRatioChanged",OutputFpsChanged:"output:fpsChanged",OutputFormatChanged:"output:formatChanged",OutputDestinationsChanged:"output:destinationsChanged",MergeFieldRegistered:"mergefield:registered",MergeFieldUpdated:"mergefield:updated",MergeFieldRemoved:"mergefield:removed",MergeFieldChanged:"mergefield:changed",MergeFieldApplied:"mergefield:applied",TranscriptionProgress:"transcription:progress",TranscriptionCompleted:"transcription:completed",TranscriptionFailed:"transcription:failed",LumaAttached:"luma:attached",LumaDetached:"luma:detached"},Hi={CanvasClipClicked:"canvas:clipClicked",CanvasBackgroundClicked:"canvas:backgroundClicked",FontCapabilitiesChanged:"font:capabilitiesChanged",ToolbarButtonsChanged:"toolbar:buttonsChanged"};function kp(i,e,t){const s=e.width/i.width,a=e.height/i.height;switch(t??"crop"){case"crop":case"cover":return Math.max(s,a);case"contain":return Math.min(s,a);case"none":default:return 1}}function Cp(i,e,t,s,a){if(a)return{x:s,y:s};if(i.width===0||i.height===0)return{x:s,y:s};const r=e.width/i.width,n=e.height/i.height;switch(t??"crop"){case"contain":{const o=Math.min(r,n)*s;return{x:o,y:o}}case"crop":{const o=Math.max(r,n)*s;return{x:o,y:o}}case"cover":return{x:r*s,y:n*s};case"none":default:return{x:s,y:s}}}function Sp(i,e,t){const s=e.width/2,a=e.height/2;switch(t??"crop"){case"cover":{const r=e.width/i.width,n=e.height/i.height;return{scaleX:r,scaleY:n,positionX:s,positionY:a}}case"crop":{const r=Math.max(e.width/i.width,e.height/i.height);return{scaleX:r,scaleY:r,positionX:s,positionY:a}}case"contain":{const r=Math.min(e.width/i.width,e.height/i.height);return{scaleX:r,scaleY:r,positionX:s,positionY:a}}case"none":default:return{scaleX:1,scaleY:1,positionX:s,positionY:a}}}function xr(i){return!!(i&&typeof i=="object"&&!Array.isArray(i))}function no(i,e){const t={...i};return xr(i)&&xr(e)&&Object.keys(e).forEach(s=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const a=e[s],r=i[s];xr(a)?s in i&&xr(r)?t[s]=no(r,a):t[s]=no({},a):t[s]=a}),t}function oo(i,e,t){const s=e.split(".");let a=i;for(let r=0;r<s.length-1;r+=1){if(a==null||typeof a!="object")return;a=a[s[r]]}a!=null&&typeof a=="object"&&(a[s[s.length-1]]=t)}function Rs(i,e){const t=e.split(".");let s=i;for(const a of t){if(s==null||typeof s!="object")return;s=s[a]}return s}async function Sc(i){try{new URL(i)}catch{return{valid:!1,error:"Invalid URL format"}}try{const e=await fetch(i,{method:"HEAD",mode:"cors"});return e.ok?{valid:!0}:{valid:!1,error:`URL returned ${e.status} ${e.statusText}`}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"URL not accessible"}}}function Ap(i){return i/1e3}function G8(i){return i}function Z8(i){return i}let Ac=class{static ButtonLeftClick=0;static ButtonRightClick=3};class Tc{containerSize;constructor(e){this.containerSize=e}relativeToAbsolute(e,t,s){switch(t){case"topLeft":return{x:s.x*this.containerSize.width,y:-s.y*this.containerSize.height};case"topRight":return{x:(s.x+1)*this.containerSize.width-e.width,y:-s.y*this.containerSize.height};case"bottomLeft":return{x:s.x*this.containerSize.width,y:(-s.y+1)*this.containerSize.height-e.height};case"bottomRight":return{x:(s.x+1)*this.containerSize.width-e.width,y:(-s.y+1)*this.containerSize.height-e.height};case"left":return{x:s.x*this.containerSize.width,y:(-s.y+.5)*this.containerSize.height-e.height/2};case"right":return{x:(s.x+1)*this.containerSize.width-e.width,y:(-s.y+.5)*this.containerSize.height-e.height/2};case"top":return{x:(s.x+.5)*this.containerSize.width-e.width/2,y:-s.y*this.containerSize.height};case"bottom":return{x:(s.x+.5)*this.containerSize.width-e.width/2,y:(-s.y+1)*this.containerSize.height-e.height};case"center":default:return{x:(s.x+.5)*this.containerSize.width-e.width/2,y:(-s.y+.5)*this.containerSize.height-e.height/2}}}absoluteToRelative(e,t,s){switch(t){case"topLeft":return{x:s.x/this.containerSize.width,y:-(s.y/this.containerSize.height)};case"topRight":return{x:(s.x+e.width)/this.containerSize.width-1,y:-(s.y/this.containerSize.height)};case"bottomLeft":return{x:s.x/this.containerSize.width,y:-((s.y+e.height)/this.containerSize.height-1)};case"bottomRight":return{x:(s.x+e.width)/this.containerSize.width-1,y:-((s.y+e.height)/this.containerSize.height-1)};case"left":return{x:s.x/this.containerSize.width,y:-((s.y+e.height/2)/this.containerSize.height-.5)};case"right":return{x:(s.x+e.width)/this.containerSize.width-1,y:-((s.y+e.height/2)/this.containerSize.height-.5)};case"top":return{x:(s.x+e.width/2)/this.containerSize.width-.5,y:-(s.y/this.containerSize.height)};case"bottom":return{x:(s.x+e.width/2)/this.containerSize.width-.5,y:-((s.y+e.height)/this.containerSize.height-1)};case"center":default:return{x:(s.x+e.width/2)/this.containerSize.width-.5,y:-((s.y+e.height/2)/this.containerSize.height-.5)}}}}class kr{container;constructor(){this.container=new q.Container}getContainer(){return this.container}}var Ze=(i=>(i.Video="video",i.Image="image",i.Audio="audio",i.Text="text",i.RichText="rich-text",i.Luma="luma",i.Html="html",i.Shape="shape",i.Caption="caption",i.Svg="svg",i))(Ze||{});class Zt extends kr{static DiscardedFrameCount=0;layer;shouldDispose;playerType;edit;clipConfiguration;timingIntent;resolvedTiming;positionBuilder;offsetXKeyframeBuilder;offsetYKeyframeBuilder;scaleKeyframeBuilder;opacityKeyframeBuilder;rotationKeyframeBuilder;maskXKeyframeBuilder;wipeMask;contentContainer;mergeFieldBindings=new Map;constructor(e,t,s){super(),this.edit=e,this.layer=0,this.shouldDispose=!1,this.playerType=s,this.clipConfiguration=t,this.positionBuilder=new Tc(e.size),this.timingIntent={start:t.start,length:t.length},this.resolvedTiming={start:t.start,length:t.length},this.wipeMask=null,this.contentContainer=new q.Container,this.getContainer().addChild(this.contentContainer)}reconfigureAfterRestore(){this.configureKeyframes()}async reloadAsset(){}configureKeyframes(){const e=this.getLength(),t=this.clipConfiguration,s=typeof t.offset?.x=="number"?t.offset.x:0,a=typeof t.offset?.y=="number"?t.offset.y:0,r=typeof t.scale=="number"?t.scale:1,n=typeof t.opacity=="number"?t.opacity:1,o=typeof t.transform?.rotate?.angle=="number"?t.transform.rotate.angle:0;if(this.offsetXKeyframeBuilder=new us(s,e,"additive"),this.offsetYKeyframeBuilder=new us(a,e,"additive"),this.scaleKeyframeBuilder=new us(r,e,"multiplicative"),this.opacityKeyframeBuilder=new us(n,e,"multiplicative",{min:0,max:1}),this.rotationKeyframeBuilder=new us(o,e,"additive"),this.clipHasKeyframes())return;const l={...t,start:this.getStart(),length:e},c=new vp(l).buildRelative(this.edit.size,this.getSize()),f=new xp(l).buildRelative();this.offsetXKeyframeBuilder.addLayer(c.offsetXKeyframes),this.offsetYKeyframeBuilder.addLayer(c.offsetYKeyframes),this.scaleKeyframeBuilder.addLayer(c.scaleKeyframes),this.opacityKeyframeBuilder.addLayer(c.opacityKeyframes),this.rotationKeyframeBuilder.addLayer(c.rotationKeyframes),this.offsetXKeyframeBuilder.addLayer(f.in.offsetXKeyframes),this.offsetYKeyframeBuilder.addLayer(f.in.offsetYKeyframes),this.scaleKeyframeBuilder.addLayer(f.in.scaleKeyframes),this.opacityKeyframeBuilder.addLayer(f.in.opacityKeyframes),this.rotationKeyframeBuilder.addLayer(f.in.rotationKeyframes),this.offsetXKeyframeBuilder.addLayer(f.out.offsetXKeyframes),this.offsetYKeyframeBuilder.addLayer(f.out.offsetYKeyframes),this.scaleKeyframeBuilder.addLayer(f.out.scaleKeyframes),this.opacityKeyframeBuilder.addLayer(f.out.opacityKeyframes),this.rotationKeyframeBuilder.addLayer(f.out.rotationKeyframes);const d=[...f.in.maskXKeyframes,...f.out.maskXKeyframes];d.length&&(this.maskXKeyframeBuilder=new Ca(d,e))}async load(){this.contentContainer?.destroyed&&(this.contentContainer=new q.Container,this.getContainer().addChild(this.contentContainer)),this.getContainer().sortableChildren=!0,this.getContainer().cursor="pointer",this.getContainer().eventMode="static",this.getContainer().on?.("pointerdown",this.onPointerDown.bind(this))}update(e,t){if(this.getContainer().visible=this.isActive(),this.getContainer().zIndex=1e5-this.layer*100,!this.isActive())return;const s=this.getPivot(),a=this.getPosition(),r=this.getContainerScale();this.getContainer().scale.set(r.x,r.y),this.getContainer().pivot.set(s.x,s.y),this.getContainer().position.set(a.x+s.x,a.y+s.y);const n=this.getRotation();this.contentContainer.alpha=this.getOpacity(),this.getContainer().angle=n,this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.updateWipeMask(),this.shouldDiscardFrame()&&(this.contentContainer.alpha=0)}updateWipeMask(){if(!this.maskXKeyframeBuilder){this.wipeMask&&(this.getContainer().mask=null,this.wipeMask.destroy(),this.wipeMask=null);return}const e=this.maskXKeyframeBuilder.getValue(this.getPlaybackTime()),t=this.getSize();this.wipeMask||(this.wipeMask=new q.Graphics,this.getContainer().addChild(this.wipeMask),this.getContainer().mask=this.wipeMask),this.wipeMask.clear(),this.wipeMask.rect(0,0,t.width*e,t.height),this.wipeMask.fill(16777215)}draw(){this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions()}dispose(){this.wipeMask?.destroy(),this.wipeMask=null,this.contentContainer?.destroy()}getStart(){return this.resolvedTiming.start}getLength(){return this.resolvedTiming.length}getEnd(){return this.resolvedTiming.start+this.resolvedTiming.length}getTimingIntent(){return{...this.timingIntent}}setTimingIntent(e){e.start!==void 0&&(this.timingIntent.start=e.start),e.length!==void 0&&(this.timingIntent.length=e.length)}getResolvedTiming(){return{...this.resolvedTiming}}setResolvedTiming(e){this.resolvedTiming={...e}}convertToFixedTiming(){this.timingIntent={start:this.resolvedTiming.start,length:this.resolvedTiming.length}}setMergeFieldBinding(e,t){this.mergeFieldBindings.set(e,t)}getMergeFieldBinding(e){return this.mergeFieldBindings.get(e)}removeMergeFieldBinding(e){this.mergeFieldBindings.delete(e)}getMergeFieldBindings(){return this.mergeFieldBindings}setInitialBindings(e){this.mergeFieldBindings=new Map(e)}getExportableClip(){const e=structuredClone(this.clipConfiguration);for(const[s,{placeholder:a,resolvedValue:r}]of this.mergeFieldBindings)Rs(e,s)===r&&oo(e,s,a);const t=this.getTimingIntent();return e.start=t.start,e.length=t.length,e}getPlaybackTime(){const t=this.edit.playbackTime/1e3-this.getStart();return t<0?0:t>this.getLength()?this.getLength():t}getContentSize(){return this.getSize()}getContentContainer(){return this.contentContainer}getOpacity(){return this.opacityKeyframeBuilder?.getValue(this.getPlaybackTime())??1}getPosition(){const e={x:this.offsetXKeyframeBuilder?.getValue(this.getPlaybackTime())??0,y:this.offsetYKeyframeBuilder?.getValue(this.getPlaybackTime())??0};return this.positionBuilder.relativeToAbsolute(this.getSize(),this.clipConfiguration.position??"center",e)}getPivot(){const e=this.getSize();return{x:e.width/2,y:e.height/2}}moveBy(e,t){const s=this.getPosition(),a={x:s.x+e,y:s.y+t},r=this.positionBuilder.absoluteToRelative(this.getSize(),this.clipConfiguration.position??"center",a);this.clipConfiguration.offset||(this.clipConfiguration.offset={x:0,y:0}),this.clipConfiguration.offset.x=r.x,this.clipConfiguration.offset.y=r.y,this.offsetXKeyframeBuilder=new us(r.x,this.getLength(),"additive"),this.offsetYKeyframeBuilder=new us(r.y,this.getLength(),"additive")}getFitScale(){const e={width:this.clipConfiguration.width??this.edit.size.width,height:this.clipConfiguration.height??this.edit.size.height},t=this.getContentSize(),s=this.clipConfiguration.fit??"crop";return kp(t,e,s)}getScale(){return(this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1)*this.getFitScale()}getContainerScale(){const e=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1,t=this.getContentSize(),s=this.clipConfiguration.fit??"crop",a=!!(this.clipConfiguration.width&&this.clipConfiguration.height);return Cp(t,this.edit.size,s,e,a)}getRotation(){return this.rotationKeyframeBuilder?.getValue(this.getPlaybackTime())??0}isActive(){const e=this.edit.playbackTime/1e3;return e>=this.getStart()&&e<this.getEnd()}shouldDiscardFrame(){return this.getPlaybackTime()<Zt.DiscardedFrameCount}onPointerDown(e){e.button===Ac.ButtonLeftClick&&this.edit.events.emit(Hi.CanvasClipClicked,{player:this})}clipHasKeyframes(){return[this.clipConfiguration.scale,this.clipConfiguration.offset?.x,this.clipConfiguration.offset?.y,this.clipConfiguration.transform?.rotate?.angle].some(e=>e&&typeof e!="number")}applyFixedDimensions(){const e=this.clipConfiguration.width,t=this.clipConfiguration.height;if(!e||!t)return;const s=this.contentContainer.children.find(p=>p instanceof q.Sprite);if(!s?.texture)return;const a=s.texture.width,r=s.texture.height,n=this.clipConfiguration.fit||"crop",o=this.contentContainer.mask;let l=null;o instanceof q.Graphics?l=o:o||(l=new q.Graphics,this.contentContainer.addChild(l),this.contentContainer.mask=l),l&&(l.clear(),l.rect(0,0,e,t),l.fill(16777215));const c=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1;s.anchor.set(.5,.5);const h=Sp({width:a,height:r},{width:e,height:t},n);s.scale.set(h.scaleX,h.scaleY),s.position.set(h.positionX,h.positionY),this.contentContainer.scale.set(c,c),this.contentContainer.position.set(e/2*(1-c),t/2*(1-c))}applyAnchorPositioning(e,t,s,a){const r=a.width,n=a.height;if(!!a.mask){a.position.set(0,0);return}const l=(e??"center").toLowerCase();let c=0,f=0;l.includes("left")||l==="left"?c=0:l.includes("right")||l==="right"?c=t-r:c=(t-r)/2,l.includes("top")||l==="top"?f=0:l.includes("bottom")||l==="bottom"?f=s-n:f=(s-n)/2,a.position.set(c,f)}supportsEdgeResize(){return!1}onDimensionsChanged(){}notifyDimensionsChanged(){this.onDimensionsChanged()}}class Nc extends Zt{audioResource;isPlaying;volumeKeyframeBuilder;syncTimer;constructor(e,t){super(e,t,Ze.Audio),this.audioResource=null,this.isPlaying=!1,this.syncTimer=0}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,s={src:t,parser:Sa.Name},a=await this.edit.assetLoader.load(t,s);if(!(a instanceof yp.Howl))throw new Error(`Invalid audio source '${e.src}'.`);this.audioResource=a;const n=typeof e.volume=="number"?e.volume:1;this.volumeKeyframeBuilder=new Ca(this.createVolumeKeyframes(e,n),this.getLength(),n),this.configureKeyframes()}update(e,t){super.update(e,t);const{trim:s=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,this.getContainer().alpha=0,!this.audioResource)return;const a=this.edit.isPlaying&&this.isActive(),r=this.getPlaybackTime();a&&(this.isPlaying||(this.isPlaying=!0,this.audioResource.seek(r+s),this.audioResource.play()),this.audioResource.volume()!==this.getVolume()&&this.audioResource.volume(this.getVolume()),Math.abs(this.audioResource.seek()-s-r)>.1&&(this.audioResource.seek(r+s),this.edit.recordSyncCorrection())),this.isPlaying&&!a&&(this.isPlaying=!1,this.audioResource.pause());const n=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&n&&(this.syncTimer=0,this.audioResource.seek(r+s))}draw(){super.draw()}dispose(){this.audioResource?.unload(),this.audioResource=null}reconfigureAfterRestore(){super.reconfigureAfterRestore();const e=this.clipConfiguration.asset,t=typeof e.volume=="number"?e.volume:1;this.volumeKeyframeBuilder=new Ca(this.createVolumeKeyframes(e,t),this.getLength(),t)}getSize(){return{width:0,height:0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}getCurrentDrift(){if(!this.audioResource)return 0;const{trim:e=0}=this.clipConfiguration.asset,t=this.audioResource.seek(),s=this.getPlaybackTime();return Math.abs(t-e-s)}createVolumeKeyframes(e,t){const{effect:s,volume:a}=e;if(!s||s==="none"||Array.isArray(a))return a??1;const r=this.getLength()/1e3,n=Math.min(2,r/2);return s==="fadeIn"?[{from:0,to:t,start:0,length:n}]:s==="fadeOut"?[{from:t,to:0,start:r-n,length:n}]:[{from:0,to:t,start:0,length:n},{from:t,to:0,start:r-n,length:n}]}}function Cr(i){const e=i.trim().replace(",","."),t=e.split(":");if(t.length===3){const s=parseInt(t[0],10),a=parseInt(t[1],10),r=parseFloat(t[2]);return s*3600+a*60+r}if(t.length===2){const s=parseInt(t[0],10),a=parseFloat(t[1]);return s*60+a}return parseFloat(e)||0}function Tp(i){const e=[],t=i.split(/\r?\n/);let s=0;for(;s<t.length&&!t[s].includes("-->");)s+=1;for(;s<t.length;){const a=t[s].trim();if(a.includes("-->")){const[r,n]=a.split("-->").map(f=>f.trim().split(" ")[0]),o=Cr(r),l=Cr(n),c=[];for(s+=1;s<t.length&&t[s].trim()!==""&&!t[s].includes("-->");){const f=t[s].trim();f.startsWith("NOTE")||c.push(f),s+=1}c.length>0&&e.push({start:o,end:l,text:c.join(`
1
+ (function(pe,ai){typeof exports=="object"&&typeof module<"u"?ai(exports,require("pixi.js"),require("howler"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js","howler","opentype.js"],ai):(pe=typeof globalThis<"u"?globalThis:pe||self,ai(pe.ShotstackStudio={},pe.PIXI,pe.Howler,pe.opentype))})(this,function(pe,ai,gp,mp){"use strict";var Ai=typeof document<"u"?document.currentScript:null;function ao(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const q=ao(ai),yp=ao(gp),ro=ao(mp),bp={version:"2.0.0-beta.16"};class wp{curves={};constructor(){this.initializeCurves()}initializeCurves(){this.curves={smooth:[[.5,0],[.5,1]],ease:[[.25,.1],[.25,1]],easeIn:[[.42,0],[1,1]],easeOut:[[0,0],[.58,1]],easeInOut:[[.42,0],[.58,1]],easeInQuad:[[.55,.085],[.68,.53]],easeInCubic:[[.55,.055],[.675,.19]],easeInQuart:[[.895,.03],[.685,.22]],easeInQuint:[[.755,.05],[.855,.06]],easeInSine:[[.47,0],[.745,.715]],easeInExpo:[[.95,.05],[.795,.035]],easeInCirc:[[.6,.04],[.98,.335]],easeInBack:[[.6,-.28],[.735,.045]],easeOutQuad:[[.25,.46],[.45,.94]],easeOutCubic:[[.215,.61],[.355,1]],easeOutQuart:[[.165,.84],[.44,1]],easeOutQuint:[[.23,1],[.32,1]],easeOutSine:[[.39,.575],[.565,1]],easeOutExpo:[[.19,1],[.22,1]],easeOutCirc:[[.075,.82],[.165,1]],easeOutBack:[[.175,.885],[.32,1.275]],easeInOutQuad:[[.455,.03],[.515,.955]],easeInOutCubic:[[.645,.045],[.355,1]],easeInOutQuart:[[.77,0],[.175,1]],easeInOutQuint:[[.86,0],[.07,1]],easeInOutSine:[[.445,.05],[.55,.95]],easeInOutExpo:[[1,0],[0,1]],easeInOutCirc:[[.785,.135],[.15,.86]],easeInOutBack:[[.68,-.55],[.265,1.55]]}}getValue(e,t,s,a){const r=this.curves[a??""]??this.curves.ease,[[n,o],[l,c]]=r,f=s+(3*n-3*l+1)*s*(1-s),d=e,h=e+(t-e)*o,p=e+(t-e)*c,m=t,w=f,x=1-w;return x**3*d+3*x**2*w*h+3*x*w**2*p+w**3*m}}class Ca{property;length;cubicBuilder;cachedIndex=0;constructor(e,t,s=0){this.property=this.createKeyframes(e,t,s),this.length=t,this.cubicBuilder=new wp}getValue(e){const t=this.findKeyframe(e);if(!t){if(this.property.length>0){if(e>=this.length)return this.property[this.property.length-1].to;if(e<0)return this.property[0].from}return 1}const s=(e-t.start)/t.length;switch(t.interpolation){case"bezier":return this.cubicBuilder.getValue(t.from,t.to,s,t.easing);case"constant":return t.from;case"linear":default:return t.from+(t.to-t.from)*s}}findKeyframe(e){const t=this.property;if(t.length===0)return;const s=t[this.cachedIndex];if(s){const o=s.start+s.length;if(Number.isFinite(o)&&e>=s.start&&e<o)return s}const a=this.cachedIndex+1;if(a<t.length){const o=t[a],l=o.start+o.length;if(Number.isFinite(l)&&e>=o.start&&e<l)return this.cachedIndex=a,o}const r=this.cachedIndex-1;if(r>=0){const o=t[r],l=o.start+o.length;if(Number.isFinite(l)&&e>=o.start&&e<l)return this.cachedIndex=r,o}const n=this.binarySearchKeyframe(e);if(n!==-1)return this.cachedIndex=n,t[n]}binarySearchKeyframe(e){const t=this.property;let s=0,a=t.length-1;for(;s<=a;){const r=Math.floor((s+a)/2),n=t[r],o=n.start+n.length;if(!Number.isFinite(o)){s=r+1;continue}if(e<n.start)a=r-1;else if(e>=o)s=r+1;else return r}return-1}createKeyframes(e,t,s=0){if(typeof e=="number")return[{start:0,length:t,from:e,to:e}];if(!e.length)throw new Error("Keyframes should have at least one value.");const a=this.createNormalizedKeyframes(e);try{this.validateKeyframes(a)}catch(r){console.warn("Keyframe configuration issues detected:",r)}return this.insertFillerKeyframes(a,t,s)}createNormalizedKeyframes(e){return e.filter(t=>typeof t.start=="number"&&typeof t.length=="number").toSorted((t,s)=>t.start-s.start).map(t=>({start:t.start,length:t.length,from:typeof t.from=="number"?t.from:0,to:typeof t.to=="number"?t.to:0,interpolation:t.interpolation,easing:t.easing}))}validateKeyframes(e){for(let t=0;t<e.length;t+=1){const s=e[t],a=e[t+1];if(!a){if(s.start+s.length>this.length)throw new Error("Last keyframe exceeds the maximum duration.");break}if(s.start+s.length>a.start)throw new Error("Overlapping keyframes detected.")}}insertFillerKeyframes(e,t,s=0){const a=[];for(let r=0;r<e.length;r+=1){const n=e[r],o=e[r+1];if(r===0&&n.start!==0){const f={start:0,length:n.start,from:s,to:n.from};a.push(f)}if(a.push(n),!o){if(n.start+n.length<t){const d=n.start+n.length,h={start:d,length:t-d,from:n.to,to:n.to};a.push(h)}break}if(n.start+n.length!==o.start){const f=n.start+n.length,d=o.start-f,h={start:f,length:d,from:n.to,to:o.from};a.push(h)}}return a}}class Sa{static Name="AudioLoadParser";id;name;extension;validAudioExtensions;constructor(){this.id=Sa.Name,this.name=Sa.Name,this.extension={type:[q.ExtensionType.LoadParser],priority:q.LoaderParserPriority.Normal,ref:null},this.validAudioExtensions=["mp3","mpeg","ogg","wav"]}test(e){const t=e.split("?")[0]?.split(".").pop()??"";return this.validAudioExtensions.includes(t)}async load(e,t,s){return new Promise(a=>{const r={src:e},n=new Howl(r);n.on("load",()=>a(n)),n.on("loaderror",()=>a(null))})}unload(e){e?.unload()}}class us{baseValue;mode;layers=[];length;clampRange;constructor(e,t,s,a){this.baseValue=e,this.length=t,this.mode=s,this.clampRange=a}addLayer(e){if(e.length===0)return;const t=this.mode==="additive"?0:1;this.layers.push(new Ca(e,this.length,t))}getValue(e){if(this.layers.length===0)return this.baseValue;if(this.mode==="additive"){let s=this.baseValue;for(const a of this.layers)s+=a.getValue(e);return s}let t=this.baseValue;for(const s of this.layers)t*=s.getValue(e);return this.clampRange&&(t=Math.max(this.clampRange.min,Math.min(this.clampRange.max,t))),t}}class vp{clipConfiguration;constructor(e){this.clipConfiguration=e}buildRelative(e,t){const s=[],a=[],r=[],n=[],o=[],{effect:l,length:c}=this.clipConfiguration;if(!l)return{offsetXKeyframes:s,offsetYKeyframes:a,opacityKeyframes:r,scaleKeyframes:n,rotationKeyframes:o};const f=0;switch(this.getPresetName()){case"zoomIn":{const h=this.getZoomSpeed();n.push({from:1,to:h,start:f,length:c,interpolation:"linear"});break}case"zoomOut":{const h=this.getZoomSpeed();n.push({from:h,to:1,start:f,length:c,interpolation:"linear"});break}case"slideLeft":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.width+e.width*p*2;if(h.width<m){const w=m/h.width;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.width-e.width)/2/e.width;s.push({from:p,to:-p,start:f,length:c});break}case"slideRight":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.width+e.width*p*2;if(h.width<m){const w=m/h.width;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.width-e.width)/2/e.width;s.push({from:-p,to:p,start:f,length:c});break}case"slideUp":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.height+e.height*p*2;if(h.height<m){const w=m/h.height;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.height-e.height)/2/e.height;a.push({from:p,to:-p,start:f,length:c});break}case"slideDown":{const h=this.getFittedSize(e,t);let p=this.getSlideStart();const m=e.height+e.height*p*2;if(h.height<m){const w=m/h.height;n.push({from:w,to:w,start:f,length:c,interpolation:"linear"})}else p=(h.height-e.height)/2/e.height;a.push({from:-p,to:p,start:f,length:c});break}}return{offsetXKeyframes:s,offsetYKeyframes:a,opacityKeyframes:r,scaleKeyframes:n,rotationKeyframes:o}}getPresetName(){const[e]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);return e}getZoomSpeed(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("zoom"))switch(t){case"Slow":return 1.1;case"Fast":return 1.7;default:return 1.3}return 0}getSlideStart(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("slide"))switch(t){case"Slow":return .03;case"Fast":return .2;default:return .12}return 0}getFittedSize(e,t){switch(this.clipConfiguration.fit??"crop"){case"cover":case"crop":{const a=Math.max(e.width/t.width,e.height/t.height);return{width:t.width*a,height:t.height*a}}case"contain":{const a=Math.min(e.width/t.width,e.height/t.height);return{width:t.width*a,height:t.height*a}}case"none":default:return t}}}class xp{clipConfiguration;constructor(e){this.clipConfiguration=e}buildRelative(){return{in:this.buildInPresetRelative(),out:this.buildOutPresetRelative()}}buildInPresetRelative(){const e=[],t=[],s=[],a=[],r=[],n=[];if(!this.clipConfiguration.transition?.in)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n};const o=0,l=this.getInPresetLength();switch(this.getInPresetName()){case"fade":{s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"zoom":{a.push({from:10,to:1,start:o,length:l,interpolation:"bezier",easing:"easeIn"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"easeIn"});break}case"slideLeft":{e.push({from:.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"slideRight":{e.push({from:-.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"slideUp":{t.push({from:.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"slideDown":{t.push({from:-.025,to:0,start:o,length:l,interpolation:"linear"}),s.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"carouselLeft":{e.push({from:1,to:0,start:o,length:l,interpolation:"linear"});break}case"carouselRight":{e.push({from:-1,to:0,start:o,length:l,interpolation:"linear"});break}case"carouselUp":{t.push({from:-1.05,to:0,start:o,length:l,interpolation:"linear"});break}case"carouselDown":{t.push({from:1.05,to:0,start:o,length:l,interpolation:"linear"});break}case"reveal":case"wipeRight":{n.push({from:0,to:1,start:o,length:l,interpolation:"bezier",easing:"ease"});break}case"wipeLeft":{n.push({from:1,to:0,start:o,length:l,interpolation:"bezier",easing:"ease"});break}}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n}}buildOutPresetRelative(){const e=[],t=[],s=[],a=[],r=[],n=[];if(!this.clipConfiguration.transition?.out)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n};const o=this.getOutPresetLength(),l=this.clipConfiguration.length-o;switch(this.getOutPresetName()){case"fade":{s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"zoom":{a.push({from:1,to:10,start:l,length:o,interpolation:"bezier",easing:"easeOut"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideLeft":{e.push({from:0,to:-.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"slideRight":{e.push({from:0,to:.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"slideUp":{t.push({from:0,to:-.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"slideDown":{t.push({from:0,to:.025,start:l,length:o,interpolation:"bezier",easing:"ease"}),s.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselLeft":{e.push({from:0,to:-1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselRight":{e.push({from:0,to:1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselUp":{t.push({from:0,to:1.1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"carouselDown":{t.push({from:0,to:-1.1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"reveal":case"wipeRight":{n.push({from:1,to:0,start:l,length:o,interpolation:"bezier",easing:"ease"});break}case"wipeLeft":{n.push({from:0,to:1,start:l,length:o,interpolation:"bezier",easing:"ease"});break}}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:s,scaleKeyframes:a,rotationKeyframes:r,maskXKeyframes:n}}getInPresetName(){const[e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);return e}getOutPresetName(){const[e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);return e}getInPresetLength(){const e=this.clipConfiguration.transition?.in??"",[t,s]=e.split(/(Slow|Fast|VeryFast)/),a=t.startsWith("carousel"),r=t.startsWith("slide");if(t==="zoom")return .4;switch(s){case"Slow":return 2;case"Fast":return a||r?.25:.5;case"VeryFast":return .25;default:return a||r?.5:1}}getOutPresetLength(){const e=this.clipConfiguration.transition?.out??"",[t,s]=e.split(/(Slow|Fast|VeryFast)/),a=t.startsWith("carousel"),r=t.startsWith("slide");if(t==="zoom")return .4;switch(s){case"Slow":return 2;case"Fast":return a||r?.25:.5;case"VeryFast":return .25;default:return a||r?.5:1}}}const U={PlaybackPlay:"playback:play",PlaybackPause:"playback:pause",TimelineUpdated:"timeline:updated",TimelineBackgroundChanged:"timeline:backgroundChanged",ClipAdded:"clip:added",ClipSplit:"clip:split",ClipSelected:"clip:selected",ClipUpdated:"clip:updated",ClipDeleted:"clip:deleted",ClipRestored:"clip:restored",ClipCopied:"clip:copied",ClipLoadFailed:"clip:loadFailed",SelectionCleared:"selection:cleared",EditChanged:"edit:changed",EditUndo:"edit:undo",EditRedo:"edit:redo",TrackAdded:"track:added",TrackRemoved:"track:removed",DurationChanged:"duration:changed",OutputResized:"output:resized",OutputResolutionChanged:"output:resolutionChanged",OutputAspectRatioChanged:"output:aspectRatioChanged",OutputFpsChanged:"output:fpsChanged",OutputFormatChanged:"output:formatChanged",OutputDestinationsChanged:"output:destinationsChanged",MergeFieldRegistered:"mergefield:registered",MergeFieldUpdated:"mergefield:updated",MergeFieldRemoved:"mergefield:removed",MergeFieldChanged:"mergefield:changed",MergeFieldApplied:"mergefield:applied",TranscriptionProgress:"transcription:progress",TranscriptionCompleted:"transcription:completed",TranscriptionFailed:"transcription:failed",LumaAttached:"luma:attached",LumaDetached:"luma:detached"},Hi={CanvasClipClicked:"canvas:clipClicked",CanvasBackgroundClicked:"canvas:backgroundClicked",FontCapabilitiesChanged:"font:capabilitiesChanged",ToolbarButtonsChanged:"toolbar:buttonsChanged"};function kp(i,e,t){const s=e.width/i.width,a=e.height/i.height;switch(t??"crop"){case"crop":case"cover":return Math.max(s,a);case"contain":return Math.min(s,a);case"none":default:return 1}}function Cp(i,e,t,s,a){if(a)return{x:s,y:s};if(i.width===0||i.height===0)return{x:s,y:s};const r=e.width/i.width,n=e.height/i.height;switch(t??"crop"){case"contain":{const o=Math.min(r,n)*s;return{x:o,y:o}}case"crop":{const o=Math.max(r,n)*s;return{x:o,y:o}}case"cover":return{x:r*s,y:n*s};case"none":default:return{x:s,y:s}}}function Sp(i,e,t){const s=e.width/2,a=e.height/2;switch(t??"crop"){case"cover":{const r=e.width/i.width,n=e.height/i.height;return{scaleX:r,scaleY:n,positionX:s,positionY:a}}case"crop":{const r=Math.max(e.width/i.width,e.height/i.height);return{scaleX:r,scaleY:r,positionX:s,positionY:a}}case"contain":{const r=Math.min(e.width/i.width,e.height/i.height);return{scaleX:r,scaleY:r,positionX:s,positionY:a}}case"none":default:return{scaleX:1,scaleY:1,positionX:s,positionY:a}}}function xr(i){return!!(i&&typeof i=="object"&&!Array.isArray(i))}function no(i,e){const t={...i};return xr(i)&&xr(e)&&Object.keys(e).forEach(s=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const a=e[s],r=i[s];xr(a)?s in i&&xr(r)?t[s]=no(r,a):t[s]=no({},a):t[s]=a}),t}function oo(i,e,t){const s=e.split(".");let a=i;for(let r=0;r<s.length-1;r+=1){if(a==null||typeof a!="object")return;a=a[s[r]]}a!=null&&typeof a=="object"&&(a[s[s.length-1]]=t)}function Rs(i,e){const t=e.split(".");let s=i;for(const a of t){if(s==null||typeof s!="object")return;s=s[a]}return s}async function Sc(i){try{new URL(i)}catch{return{valid:!1,error:"Invalid URL format"}}try{const e=await fetch(i,{method:"HEAD",mode:"cors"});return e.ok?{valid:!0}:{valid:!1,error:`URL returned ${e.status} ${e.statusText}`}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"URL not accessible"}}}function Ap(i){return i/1e3}function G8(i){return i}function Z8(i){return i}let Ac=class{static ButtonLeftClick=0;static ButtonRightClick=3};class Tc{containerSize;constructor(e){this.containerSize=e}relativeToAbsolute(e,t,s){switch(t){case"topLeft":return{x:s.x*this.containerSize.width,y:-s.y*this.containerSize.height};case"topRight":return{x:(s.x+1)*this.containerSize.width-e.width,y:-s.y*this.containerSize.height};case"bottomLeft":return{x:s.x*this.containerSize.width,y:(-s.y+1)*this.containerSize.height-e.height};case"bottomRight":return{x:(s.x+1)*this.containerSize.width-e.width,y:(-s.y+1)*this.containerSize.height-e.height};case"left":return{x:s.x*this.containerSize.width,y:(-s.y+.5)*this.containerSize.height-e.height/2};case"right":return{x:(s.x+1)*this.containerSize.width-e.width,y:(-s.y+.5)*this.containerSize.height-e.height/2};case"top":return{x:(s.x+.5)*this.containerSize.width-e.width/2,y:-s.y*this.containerSize.height};case"bottom":return{x:(s.x+.5)*this.containerSize.width-e.width/2,y:(-s.y+1)*this.containerSize.height-e.height};case"center":default:return{x:(s.x+.5)*this.containerSize.width-e.width/2,y:(-s.y+.5)*this.containerSize.height-e.height/2}}}absoluteToRelative(e,t,s){switch(t){case"topLeft":return{x:s.x/this.containerSize.width,y:-(s.y/this.containerSize.height)};case"topRight":return{x:(s.x+e.width)/this.containerSize.width-1,y:-(s.y/this.containerSize.height)};case"bottomLeft":return{x:s.x/this.containerSize.width,y:-((s.y+e.height)/this.containerSize.height-1)};case"bottomRight":return{x:(s.x+e.width)/this.containerSize.width-1,y:-((s.y+e.height)/this.containerSize.height-1)};case"left":return{x:s.x/this.containerSize.width,y:-((s.y+e.height/2)/this.containerSize.height-.5)};case"right":return{x:(s.x+e.width)/this.containerSize.width-1,y:-((s.y+e.height/2)/this.containerSize.height-.5)};case"top":return{x:(s.x+e.width/2)/this.containerSize.width-.5,y:-(s.y/this.containerSize.height)};case"bottom":return{x:(s.x+e.width/2)/this.containerSize.width-.5,y:-((s.y+e.height)/this.containerSize.height-1)};case"center":default:return{x:(s.x+e.width/2)/this.containerSize.width-.5,y:-((s.y+e.height/2)/this.containerSize.height-.5)}}}}class kr{container;constructor(){this.container=new q.Container}getContainer(){return this.container}}var Ze=(i=>(i.Video="video",i.Image="image",i.Audio="audio",i.Text="text",i.RichText="rich-text",i.Luma="luma",i.Html="html",i.Shape="shape",i.Caption="caption",i.Svg="svg",i))(Ze||{});class Zt extends kr{static DiscardedFrameCount=0;layer;shouldDispose;playerType;edit;clipConfiguration;timingIntent;resolvedTiming;positionBuilder;offsetXKeyframeBuilder;offsetYKeyframeBuilder;scaleKeyframeBuilder;opacityKeyframeBuilder;rotationKeyframeBuilder;maskXKeyframeBuilder;wipeMask;contentContainer;mergeFieldBindings=new Map;constructor(e,t,s){super(),this.edit=e,this.layer=0,this.shouldDispose=!1,this.playerType=s,this.clipConfiguration=t,this.positionBuilder=new Tc(e.size),this.timingIntent={start:t.start,length:t.length},this.resolvedTiming={start:t.start,length:t.length},this.wipeMask=null,this.contentContainer=new q.Container,this.getContainer().addChild(this.contentContainer)}reconfigureAfterRestore(){this.configureKeyframes()}async reloadAsset(){}configureKeyframes(){const e=this.getLength(),t=this.clipConfiguration,s=typeof t.offset?.x=="number"?t.offset.x:0,a=typeof t.offset?.y=="number"?t.offset.y:0,r=typeof t.scale=="number"?t.scale:1,n=typeof t.opacity=="number"?t.opacity:1,o=typeof t.transform?.rotate?.angle=="number"?t.transform.rotate.angle:0;if(this.offsetXKeyframeBuilder=new us(s,e,"additive"),this.offsetYKeyframeBuilder=new us(a,e,"additive"),this.scaleKeyframeBuilder=new us(r,e,"multiplicative"),this.opacityKeyframeBuilder=new us(n,e,"multiplicative",{min:0,max:1}),this.rotationKeyframeBuilder=new us(o,e,"additive"),this.clipHasKeyframes())return;const l={...t,start:this.getStart(),length:e},c=new vp(l).buildRelative(this.edit.size,this.getSize()),f=new xp(l).buildRelative();this.offsetXKeyframeBuilder.addLayer(c.offsetXKeyframes),this.offsetYKeyframeBuilder.addLayer(c.offsetYKeyframes),this.scaleKeyframeBuilder.addLayer(c.scaleKeyframes),this.opacityKeyframeBuilder.addLayer(c.opacityKeyframes),this.rotationKeyframeBuilder.addLayer(c.rotationKeyframes),this.offsetXKeyframeBuilder.addLayer(f.in.offsetXKeyframes),this.offsetYKeyframeBuilder.addLayer(f.in.offsetYKeyframes),this.scaleKeyframeBuilder.addLayer(f.in.scaleKeyframes),this.opacityKeyframeBuilder.addLayer(f.in.opacityKeyframes),this.rotationKeyframeBuilder.addLayer(f.in.rotationKeyframes),this.offsetXKeyframeBuilder.addLayer(f.out.offsetXKeyframes),this.offsetYKeyframeBuilder.addLayer(f.out.offsetYKeyframes),this.scaleKeyframeBuilder.addLayer(f.out.scaleKeyframes),this.opacityKeyframeBuilder.addLayer(f.out.opacityKeyframes),this.rotationKeyframeBuilder.addLayer(f.out.rotationKeyframes);const d=[...f.in.maskXKeyframes,...f.out.maskXKeyframes];d.length&&(this.maskXKeyframeBuilder=new Ca(d,e))}async load(){this.contentContainer?.destroyed&&(this.contentContainer=new q.Container,this.getContainer().addChild(this.contentContainer)),this.getContainer().sortableChildren=!0,this.getContainer().cursor="pointer",this.getContainer().eventMode="static",this.getContainer().on?.("pointerdown",this.onPointerDown.bind(this))}update(e,t){if(this.getContainer().visible=this.isActive(),this.getContainer().zIndex=1e5-this.layer*100,!this.isActive())return;const s=this.getPivot(),a=this.getPosition(),r=this.getContainerScale();this.getContainer().scale.set(r.x,r.y),this.getContainer().pivot.set(s.x,s.y),this.getContainer().position.set(a.x+s.x,a.y+s.y);const n=this.getRotation();this.contentContainer.alpha=this.getOpacity(),this.getContainer().angle=n,this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.updateWipeMask(),this.shouldDiscardFrame()&&(this.contentContainer.alpha=0)}updateWipeMask(){if(!this.maskXKeyframeBuilder){this.wipeMask&&(this.getContainer().mask=null,this.wipeMask.destroy(),this.wipeMask=null);return}const e=this.maskXKeyframeBuilder.getValue(this.getPlaybackTime()),t=this.getSize();this.wipeMask||(this.wipeMask=new q.Graphics,this.getContainer().addChild(this.wipeMask),this.getContainer().mask=this.wipeMask),this.wipeMask.clear(),this.wipeMask.rect(0,0,t.width*e,t.height),this.wipeMask.fill(16777215)}draw(){this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions()}dispose(){this.wipeMask?.destroy(),this.wipeMask=null,this.contentContainer?.destroy()}getStart(){return this.resolvedTiming.start}getLength(){return this.resolvedTiming.length}getEnd(){return this.resolvedTiming.start+this.resolvedTiming.length}getTimingIntent(){return{...this.timingIntent}}setTimingIntent(e){e.start!==void 0&&(this.timingIntent.start=e.start),e.length!==void 0&&(this.timingIntent.length=e.length)}getResolvedTiming(){return{...this.resolvedTiming}}setResolvedTiming(e){this.resolvedTiming={...e}}convertToFixedTiming(){this.timingIntent={start:this.resolvedTiming.start,length:this.resolvedTiming.length}}setMergeFieldBinding(e,t){this.mergeFieldBindings.set(e,t)}getMergeFieldBinding(e){return this.mergeFieldBindings.get(e)}removeMergeFieldBinding(e){this.mergeFieldBindings.delete(e)}getMergeFieldBindings(){return this.mergeFieldBindings}setInitialBindings(e){this.mergeFieldBindings=new Map(e)}getExportableClip(){const e=structuredClone(this.clipConfiguration);for(const[s,{placeholder:a,resolvedValue:r}]of this.mergeFieldBindings)Rs(e,s)===r&&oo(e,s,a);const t=this.getTimingIntent();return e.start=t.start,e.length=t.length,e}getPlaybackTime(){const t=this.edit.playbackTime/1e3-this.getStart();return t<0?0:t>this.getLength()?this.getLength():t}getContentSize(){return this.getSize()}getContentContainer(){return this.contentContainer}getOpacity(){return this.opacityKeyframeBuilder?.getValue(this.getPlaybackTime())??1}getPosition(){const e={x:this.offsetXKeyframeBuilder?.getValue(this.getPlaybackTime())??0,y:this.offsetYKeyframeBuilder?.getValue(this.getPlaybackTime())??0};return this.positionBuilder.relativeToAbsolute(this.getSize(),this.clipConfiguration.position??"center",e)}getPivot(){const e=this.getSize();return{x:e.width/2,y:e.height/2}}moveBy(e,t){const s=this.getPosition(),a={x:s.x+e,y:s.y+t},r=this.positionBuilder.absoluteToRelative(this.getSize(),this.clipConfiguration.position??"center",a);this.clipConfiguration.offset||(this.clipConfiguration.offset={x:0,y:0}),this.clipConfiguration.offset.x=r.x,this.clipConfiguration.offset.y=r.y,this.offsetXKeyframeBuilder=new us(r.x,this.getLength(),"additive"),this.offsetYKeyframeBuilder=new us(r.y,this.getLength(),"additive")}getFitScale(){const e={width:this.clipConfiguration.width??this.edit.size.width,height:this.clipConfiguration.height??this.edit.size.height},t=this.getContentSize(),s=this.clipConfiguration.fit??"crop";return kp(t,e,s)}getScale(){return(this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1)*this.getFitScale()}getContainerScale(){const e=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1,t=this.getContentSize(),s=this.clipConfiguration.fit??"crop",a=!!(this.clipConfiguration.width&&this.clipConfiguration.height);return Cp(t,this.edit.size,s,e,a)}getRotation(){return this.rotationKeyframeBuilder?.getValue(this.getPlaybackTime())??0}isActive(){const e=this.edit.playbackTime/1e3;return e>=this.getStart()&&e<this.getEnd()}shouldDiscardFrame(){return this.getPlaybackTime()<Zt.DiscardedFrameCount}onPointerDown(e){e.button===Ac.ButtonLeftClick&&this.edit.events.emit(Hi.CanvasClipClicked,{player:this})}clipHasKeyframes(){return[this.clipConfiguration.scale,this.clipConfiguration.offset?.x,this.clipConfiguration.offset?.y,this.clipConfiguration.transform?.rotate?.angle].some(e=>e&&typeof e!="number")}applyFixedDimensions(){const e=this.clipConfiguration.width,t=this.clipConfiguration.height;if(!e||!t)return;const s=this.contentContainer.children.find(p=>p instanceof q.Sprite);if(!s?.texture)return;const a=s.texture.width,r=s.texture.height,n=this.clipConfiguration.fit||"crop",o=this.contentContainer.mask;let l=null;o instanceof q.Graphics?l=o:o||(l=new q.Graphics,this.contentContainer.addChild(l),this.contentContainer.mask=l),l&&(l.clear(),l.rect(0,0,e,t),l.fill(16777215));const c=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1;s.anchor.set(.5,.5);const h=Sp({width:a,height:r},{width:e,height:t},n);s.scale.set(h.scaleX,h.scaleY),s.position.set(h.positionX,h.positionY),this.contentContainer.scale.set(c,c),this.contentContainer.position.set(e/2*(1-c),t/2*(1-c))}applyAnchorPositioning(e,t,s,a){const r=a.width,n=a.height;if(!!a.mask){a.position.set(0,0);return}const l=(e??"center").toLowerCase();let c=0,f=0;l.includes("left")||l==="left"?c=0:l.includes("right")||l==="right"?c=t-r:c=(t-r)/2,l.includes("top")||l==="top"?f=0:l.includes("bottom")||l==="bottom"?f=s-n:f=(s-n)/2,a.position.set(c,f)}supportsEdgeResize(){return!1}onDimensionsChanged(){}notifyDimensionsChanged(){this.onDimensionsChanged()}}class Nc extends Zt{audioResource;isPlaying;volumeKeyframeBuilder;syncTimer;constructor(e,t){super(e,t,Ze.Audio),this.audioResource=null,this.isPlaying=!1,this.syncTimer=0}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,s={src:t,parser:Sa.Name},a=await this.edit.assetLoader.load(t,s);if(!(a instanceof yp.Howl))throw new Error(`Invalid audio source '${e.src}'.`);this.audioResource=a;const n=typeof e.volume=="number"?e.volume:1;this.volumeKeyframeBuilder=new Ca(this.createVolumeKeyframes(e,n),this.getLength(),n),this.configureKeyframes()}update(e,t){super.update(e,t);const{trim:s=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,this.getContainer().alpha=0,!this.audioResource)return;const a=this.edit.isPlaying&&this.isActive(),r=this.getPlaybackTime();a&&(this.isPlaying||(this.isPlaying=!0,this.audioResource.seek(r+s),this.audioResource.play()),this.audioResource.volume()!==this.getVolume()&&this.audioResource.volume(this.getVolume()),Math.abs(this.audioResource.seek()-s-r)>.1&&(this.audioResource.seek(r+s),this.edit.recordSyncCorrection())),this.isPlaying&&!a&&(this.isPlaying=!1,this.audioResource.pause());const n=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&n&&(this.syncTimer=0,this.audioResource.seek(r+s))}draw(){super.draw()}dispose(){this.audioResource?.unload(),this.audioResource=null}reconfigureAfterRestore(){super.reconfigureAfterRestore();const e=this.clipConfiguration.asset,t=typeof e.volume=="number"?e.volume:1;this.volumeKeyframeBuilder=new Ca(this.createVolumeKeyframes(e,t),this.getLength(),t)}getSize(){return{width:0,height:0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}getCurrentDrift(){if(!this.audioResource)return 0;const{trim:e=0}=this.clipConfiguration.asset,t=this.audioResource.seek(),s=this.getPlaybackTime();return Math.abs(t-e-s)}createVolumeKeyframes(e,t){const{effect:s,volume:a}=e;if(!s||s==="none"||Array.isArray(a))return a??1;const r=this.getLength()/1e3,n=Math.min(2,r/2);return s==="fadeIn"?[{from:0,to:t,start:0,length:n}]:s==="fadeOut"?[{from:t,to:0,start:r-n,length:n}]:[{from:0,to:t,start:0,length:n},{from:t,to:0,start:r-n,length:n}]}}function Cr(i){const e=i.trim().replace(",","."),t=e.split(":");if(t.length===3){const s=parseInt(t[0],10),a=parseInt(t[1],10),r=parseFloat(t[2]);return s*3600+a*60+r}if(t.length===2){const s=parseInt(t[0],10),a=parseFloat(t[1]);return s*60+a}return parseFloat(e)||0}function Tp(i){const e=[],t=i.split(/\r?\n/);let s=0;for(;s<t.length&&!t[s].includes("-->");)s+=1;for(;s<t.length;){const a=t[s].trim();if(a.includes("-->")){const[r,n]=a.split("-->").map(f=>f.trim().split(" ")[0]),o=Cr(r),l=Cr(n),c=[];for(s+=1;s<t.length&&t[s].trim()!==""&&!t[s].includes("-->");){const f=t[s].trim();f.startsWith("NOTE")||c.push(f),s+=1}c.length>0&&e.push({start:o,end:l,text:c.join(`
2
2
  `)})}else s+=1}return e}function Np(i){const e=[],t=i.split(/\r?\n/);let s=0;for(;s<t.length;){const a=t[s].trim();if(/^\d+$/.test(a)||a==="")s+=1;else if(a.includes("-->")){const[r,n]=a.split("-->").map(f=>f.trim()),o=Cr(r),l=Cr(n),c=[];for(s+=1;s<t.length&&t[s].trim()!=="";)c.push(t[s].trim()),s+=1;c.length>0&&e.push({start:o,end:l,text:c.join(`
3
3
  `)})}else s+=1}return e}function Ip(i){return i.trim().startsWith("WEBVTT")?Tp(i):Np(i)}function Ep(i,e){return i.find(t=>e>=t.start&&e<=t.end)??null}const Pp=`
4
4
  let transcriber = null;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "cpuccino",
6
6
  "dazzatron"
7
7
  ],
8
- "version": "2.0.0-beta.15",
8
+ "version": "2.0.0-beta.16",
9
9
  "description": "A video editing library for creating and editing videos with Shotstack",
10
10
  "type": "module",
11
11
  "main": "dist/shotstack-studio.umd.js",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@huggingface/transformers": "^3.0.0",
94
- "@shotstack/schemas": "^1.4.1",
94
+ "@shotstack/schemas": "^1.4.2",
95
95
  "@shotstack/shotstack-canvas": "^1.9.2",
96
96
  "fast-deep-equal": "^3.1.3",
97
97
  "howler": "^2.2.4",