1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PhotoEditor-VOO3sXpD.js","assets/jsx-runtime-CqrCmrYQ.js","assets/vendor-react-DWiRq_5Q.js","assets/AuthContext-D_aQViLm.js","assets/vendor-redux-BFhIuSuA.js","assets/secureTransport-BT8gXiVx.js","assets/studioTools-l1aejion.js","assets/jszip.min-BBttjx9z.js"])))=>i.map(i=>d[i]); 2var vb=Object.defineProperty;var wb=(e,n,r)=>n in e?vb(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var fn=(e,n,r)=>wb(e,typeof n!="symbol"?n+"":n,r);import{s as Jt,r as bl,_ as c0}from"./secureTransport-BT8gXiVx.js";import{j as t}from"./jsx-runtime-CqrCmrYQ.js";import{b as jb,e as Ea,c as Hp}from"./studioTools-l1aejion.js";import{r as i,a as Un,R as qe,b as d0,d as Nb,c as kb,D as Sb,h as Cb}from"./vendor-react-DWiRq_5Q.js";import{toast as me}from"./react-toastify.esm-dODcvvAN.js";import{C as Kc}from"./ConfirmDialog-B7A2Hzkv.js";import{f as Wd,g as Kp,r as Eb,t as Mb,S as Ib}from"./StudioVideoPlayer-BB1ZNZd0.js";import{t as Pc}from"./editorUsage-B6bN9lIs.js";import{v as Pm,i as Fb}from"./cloudinaryOps-Ct2fKHRk.js";import{k as Zs,i as Xs,w as zl,a as ft,v as ho,C as Po,h as ga,z as Nl,A as fo,ay as _i,az as Fl,ax as oi,D as $s,l as Ta,S as zi,aA as Rb,d as Ri,M as Rl,r as ba,N as Wc,av as Ko,t as Da,L as Yd,as as xa,aB as u0,U as go,ab as qs,I as Pl,O as Js,u as ss,aC as m
20,H as fs,aa as ni,a7 as Tl,aD as Ra,a5 as p0,aw as Di,aE as Li,aF as Tm,Z as Yc,aG as Fa,ai as Ts,ac as Fs,ah as f0,$ as Tc,aH as Pb,aI as Tb,aJ as Ab,am as $b,ak as _b,Y as Qa,ap as _u,p as Al,x as Du,y as Db,c as Lb,aK as h0,aL as Wp,aM as Gd,aN as Yp,af as Gp,aO as Ob,aP as Vb,aQ as Ub,aR as qp,aS as zb,aT as Bb,aU as Xp,aV as Hb,aW as Jp,aX as Mo,aY as Zp,g as Kb}from"./index-COyPRzeT.js";import{L as Wb}from"./index-D4pxbIbR.js";import{T as Am}from"./TabSelector-CyOkNz0p.js";import{u as x0,D as Yb,S as Qp}from"./tryOnFavorites-CIuPD5tx.js";import{FEMALE_HEADSHOTS as Gb,MALE_HEADSHOTS as qb,thumbUrl as $l}from"./tryOnCdnAssets-B97xlmHA.js";import{b as Ao,c as Xb}from"./index-MSypKfEb.js";import{u as g0}from"./autoPaging-C5LHISlF.js";import{a as b0}from"./SessionResumeDialog-BwAtYG6W.js";import{m as Jb,u as Zb,g as Gc,e as $a}from"./AuthContext-D_aQViLm.js";import{P as Qb}from"./index-DpHmcKyI.js";import{b as Lu,i as ey}from"./subscription-BI2A8kyt.js";import{C as ty}from"./ColorPickerModal-lP8VnRQC.js";import{m as y0,p as v0,f as w0,i as $m,s as qo}from"./uploadPrep-LCedjOzL.js";import{u as ny}from"./AuthModalContext-Dn1r-5W7.js";import{D as Sn}from"./DropdownMenu-Jz4QorZx.js";import"./TokenCostPill-DyxFPAvf.js";import"./time-C6oRCTH3.js";import"./vendor-redux-BFhIuSuA.js";import"./errorReporter-D_obZs0p.js";const ry=6*60*60*1e3,ef="studioe:lastSession:aesKey:v1";function Mr(e,n=4e3){return typeof e!="string"?"":e.length>n?e.slice(0,n):e}function _l(e){if(typeof e!="string")return null;const n=e.trim();return/^https:\/\//i.test(n)&&n.length<=8e3?n:null}function qc(e,n=12){return Array.isArray(e)?e.map(_l).filter(Boolean).slice(0,n):[]}function Ac(e,{min:n=-1/0,max:r=1/0,fallback:s=null}={}){const o=Number(e);return Number.isFinite(o)&&o>=n&&o<=r?o:s}function Dl(e,n,r){return n.includes(e)?e:r}function Xc(e){return typeof e=="string"&&/^[\w-]{1,64}$/.test(e)?e:null}const Ou=e=>btoa(String.fromCharCode(...e)),Vu=e=>Uint8Array.from(atob(e),n=>n.charCodeAt(0));async function j0(){let e=null;try{const n=localStorage.getItem(ef);n&&(e=Vu(n))}catch{}if(!e){e=crypto.getRandomValues(new Uint8Array(32));try{localStorage.setItem(ef,Ou(e))}catch{}}return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt","decrypt"])}async function sy(e){const n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},await j0(),new TextEncoder().encode(JSON.stringify(e)));return{v:1,iv:Ou(n),ct:Ou(new Uint8Array(r))}}async function oy(e){if(!e||e.v!==1||!e.iv||!e.ct)return null;const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:Vu(e.iv)},await j0(),Vu(e.ct));return JSON.parse(new TextDecoder().decode(n))}function N0({name:e,sanitize:n,maxAgeMs:r=ry}){const s=`studioe:${e}:v1`,o=`studioe:${e}:enc:v1`;let a=0;const l=p=>{if(!p||typeof p!="object")return null;const b=typeof p.ts=="number"?p.ts:0;if(!b||Date.now()-b>r)return null;const y=n(p);return y?{...y,v:1,ts:b,...p.finished===!0?{finished:!0}:{}}:null},c=()=>{a+=1;for(const p of[s,o])try{localStorage.removeItem(p)}catch{}},u=()=>{try{return l(JSON.parse(localStorage.getItem(s)||"null"))}catch{return null}};return{key:s,read:async()=>{let p=null;try{const y=localStorage.getItem(o);y&&(p=l(await oy(JSON.parse(y))))}catch{p=null}const b=u();return p&&(!b||p.ts>b.ts)?p:b},readPlain:u,write:(p,{clearWhenEmpty:b=!0}={})=>{const y=l({...p,ts:typeof(p==null?void 0:p.ts)=="number"?p.ts:Date.now()});if(!y)return b&&c(),!1;if(Jb(s,p==null?void 0:p.owner))return!1;a+=1;const v=a;let w=!1;try{localStorage.setItem(s,JSON.stringify(y)),w=!0}catch{}return(async()=>{try{const C=JSON.stringify(await sy(y));v===a&&localStorage.setItem(o,C)}catch{}})(),w},clear:c}}const _m=new Set,k0=e=>_m.has(e),S0=e=>{_m.add(e)},ay=()=>{_m.clear()},Gs=216e3,tf=50,fa=(e,n,r,s)=>{const o=Number(e);return Number.isFinite(o)?Math.min(r,Math.max(n,o)):s},ei=(e,n,r)=>Math.max(n,Math.min(r,Number.isFinite(Number(e))?Number(e):n)),Wr=e=>e+Math.random().toString(36).slice(2,8),nf=(e,n)=>Number.isFinite(Number(e))?Math.round(Number(e)):n;function kl(e){let n=0;for(const r of(e==null?void 0:e.tracks)||[])for(const s of(r==null?void 0:r.clips)||[]){const o=Math.max(0,nf(s.fromFrame,0)),a=Math.max(1,nf(s.durationInFrames,1));o<=Gs&&a<=Gs&&(n=Math.max(n,o+a))}return n}function C0(e){if(e!=null&&e.loop)return 0;const n=Math.round(fa(e==null?void 0:e.srcFrames,0,Gs,0));if(!n)return 0;
2const r=Math.max(.1,fa(e==null?void 0:e.speed,.1,100,1)),s=Math.max(0,Math.round(fa(e==null?void 0:e.trimStart,0,Gs,0)));return Math.max(1,Math.round((n-s)/r))}function nc(e,n){const r=C0(e),s=Math.max(1,Math.round(Number(n)||1));return r?Math.min(s,r):s}function rc(e,n){const r=Math.max(1,Math.round(Number(n)||1)),s=Math.round(Number(e==null?void 0:e.durationInFrames)||1);return s>1||kl(e)?Math.max(1,Math.min(r,s)):r}function iy(e,n,r,s){const o=Math.round(Number(n)||0),a=o+Math.max(1,Math.round(Number(r)||1));return!((e==null?void 0:e.clips)||[]).some(l=>{if(l.id===s)return!1;const c=Math.round(Number(l.fromFrame)||0);return o<c+Math.max(1,Math.round(Number(l.durationInFrames)||1))&&c<a})}function el(e,n,r,{prefer:s,name:o,firstTrackId:a}={}){let l=[...(e==null?void 0:e.tracks)||[]],c=null;for(const u of r){let h=[...l.filter(b=>b.id===s&&b.type===n),...l.filter(b=>b.id!==s&&b.type===n)].find(b=>iy(b,u.fromFrame,u.durationInFrames));if(!h){const b=l.filter(y=>y.type===n).length;h={id:b===0&&a?a:Wr(n.slice(0,3)+"_"),type:n,name:b===0?o||n:`${o||n} ${b+1}`,clips:[]},l=[...l,h]}const p=h.id;l=l.map(b=>b.id===p?{...b,clips:[...b.clips||[],u]}:b),c||(c=p)}return{tracks:l,trackId:c}}function ly(e){if(!Array.isArray(e==null?void 0:e.tracks))return e;let n=!1;const r=[];for(const s of e.tracks){const o=Array.isArray(s==null?void 0:s.clips)?s.clips:[],a=[],l=[],c=d=>{const h=Math.round(Number(d==null?void 0:d.fromFrame)||0);return[h,h+Math.max(1,Math.round(Number(d==null?void 0:d.durationInFrames)||1))]};if(o.forEach((d,h)=>{const[p,b]=c(d);let y=0;for(let v=0;v<h;v++){const[w,C]=c(o[v]);p<C&&w<b&&(y=Math.max(y,l[v]+1))}l[h]=y,(a[y]=a[y]||[]).push(d)}),a.length<=1){r.push(s);continue}n=!0,r.push({...s,clips:a[0]});const u=new Set(e.tracks.map(d=>d==null?void 0:d.id));for(let d=1;d<a.length;d++){let h=`${s.id}_${d+1}`;for(;u.has(h);)h=Wr(`${s.id}_`);u.add(h),r.push({...s,id:h,name:`${s.name||s.type} ${d+1}`,clips:a[d]})}}return n?{...e,tracks:r}:e}function sc(e,n,r){const s=Math.max(1,Math.round(Number(e)||1)),o=Math.max(1,Math.round(Number(n)||1)),a=Math.max(0,Math.round(Number(r)||0));return Math.max(0,Math.min(a,Math.max(0,s-o)))}const cy={maxSeconds:60*60,maxFps:60,maxDim:4096,maxPixelFrames:1080*1920*30*60*30};function E0(e){const n=Number(e==null?void 0:e.fps)||30,r=Number(e==null?void 0:e.durationInFrames)||1,s=Number(e==null?void 0:e.width)||1080,o=Number(e==null?void 0:e.height)||1920,a=cy;return n>a.maxFps?"Videos can be exported at up to 60 frames a second.":r/n>a.maxSeconds?`Videos can be up to ${a.maxSeconds/60} minutes long.`:s>a.maxDim||o>a.maxDim?`Videos can be up to ${a.maxDim}px on a side.`:s*o*r>a.maxPixelFrames?"That video is too long for its size. Make it shorter or smaller to export it.":null}const dy=new Set(["video","image","shape","caption","audio"]),uy=200,my=5e3,py=2e3,fy={text:5e3,name:300,sceneTitle:300,title:300},M0=new Set(["__proto__","constructor","prototype"]),hy=e=>e===null||["string","number","boolean"].includes(typeof e),qd=e=>{const n={};for(const[r,s]of Object.entries(e||{}))!M0.has(r)&&hy(s)&&(n[r]=s);return n};function xy(e){if(!e||typeof e!="object"||Array.isArray(e))return{tracks:[]};let n=my;const r=new Set,s=[];for(const o of Array.isArray(e.tracks)?e.tracks:[]){if(s.length>=uy)break;if(!o||typeof o!="object"||!dy.has(o.type))continue;let a=typeof o.id=="string"&&o.id?o.id.slice(0,80):Wr("t_");for(;r.has(a);)a=Wr(`${a.slice(0,60)}_`);r.add(a);const l=new Set,c=[];for(const u of Array.isArray(o.clips)?o.clips:[]){if(n<=0)break;if(!u||typeof u!="object"||Array.isArray(u))continue;const d=qd(u);for(const[p,b]of Object.entries(fy))typeof d[p]=="string"&&d[p].length>b&&(d[p]=d[p].slice(0,b));if(u.keys&&typeof u.keys=="object"&&!Array.isArray(u.keys)){const p={};for(const[b,y]of Object.entries(u.keys))!M0.has(b)&&Array.isArray(y)&&(p[b]=y.slice(0,py).filter(v=>v&&typeof v=="object").map(v=>({f:v.f,v:v.v,...typeof v.ease=="string"?{ease:v.ease}:{}})));Object.keys(p).length&&(d.keys=p)}let h=typeof d.id=="string"&&d.id?d.id.slice(0,80):Wr("c_");for(;l.has(h);)h=Wr("c_");l.add(h),d.id=h,c.push(d),n--}s.push({...qd(o),id:a,type:o.type,clips:c})}return{...qd(e),tracks:s}}function $c(e){if(!e||typeof e!="object")return{fps:30,width:1080,height:1920,durationInFrames:1,minDurationInFrames:1,tracks:[]};const n=Math.round(fa(e.fps,1,240,30)),r=Math.round(fa(e.width,1,8192,1080)),s=Math.round(fa(e.height,1,8192,1920)),o=Math.round(fa(e.minDurationInFrames,1,Gs,1));let a=!1;for(const u of e.tracks||[])for(const d of u.clips||[]){const h=Number(d.fromFrame)||0,p=Number(d.durationInFrames)||1;(!Number.isFinite(h)||!Number.isFinite(p)||h<0||p<1||h>Gs||p>Gs)&&(a=!0)}const l=a?{...e,tracks:(e.tracks||[]).map(u=>({...u,clips:(u.clips||[]).map(d=>({...d,fromFrame:Math.round(fa(d.fromFrame,0,Gs,0)),durationInFrames:Math.round(fa(d.durationInFrames,1,Gs,1))}))}))}:e,c=Math.max(o,kl(l));return{...l,fps:n,width:r,height:s,minDurationInFrames:Math.min(Gs,Math.max(1,o)),durationInFrames:Math.min(Gs,Math.max(1,c))}}
2function Ps(e,n,r,s){return{...e,tracks:(e.tracks||[]).map(o=>o.id!==n?o:{...o,clips:(o.clips||[]).map(a=>a.id!==r?a:{...a,...typeof s=="function"?s(a):s})})}}function gy(e,n){switch(n.type){case"load":return{doc:$c(n.doc),past:[],future:[]};case"snapshot":return e.doc?{...e,past:[...e.past.slice(1-tf),e.doc],future:[]}:e;case"live":return e.doc?{...e,doc:$c(n.fn(e.doc))}:e;case"commit":return e.doc?{doc:$c(n.fn(e.doc)),past:[...e.past.slice(1-tf),e.doc],future:[]}:e;case"discard":return e.past.length?{doc:e.past[e.past.length-1],past:e.past.slice(0,-1),future:e.future}:e;case"undo":return e.past.length?{doc:e.past[e.past.length-1],past:e.past.slice(0,-1),future:[e.doc,...e.future]}:e;case"redo":return e.future.length?{doc:e.future[0],past:[...e.past,e.doc],future:e.future.slice(1)}:e;default:return e}}function by(e){const n=String(e||"").replace(/^/,"").replace(/\r/g,""),r=/(\d{1,2}:)?(\d{1,2}):(\d{2})[.,](\d{1,3})/g,s=l=>parseInt(l[1]||"0",10)*3600+parseInt(l[2],10)*60+parseInt(l[3],10)+parseInt(String(l[4]).padEnd(3,"0"),10)/1e3;let o=n.split(/\n{2,}/);if(o.filter(l=>l.includes("-->")).length===1&&(n.match(/-->/g)||[]).length>1){const l=n.split(` 3`),c=[];let u=[];for(let d=0;d<l.length;d++)(l[d].includes("-->")||/^\s*\d+\s*$/.test(l[d])&&(l[d+1]||"").includes("-->"))&&u.some(p=>p.includes("-->"))&&(c.push(u.join(` 4`)),u=[]),u.push(l[d]);u.length&&c.push(u.join(` 5`)),o=c}const a=[];for(const l of o){const c=l.split(` 6`).filter(v=>v.trim()),u=c.findIndex(v=>v.includes("-->"));if(u<0)continue;r.lastIndex=0;const d=r.exec(c[u]),h=d&&r.exec(c[u]);if(!h)continue;const p=s(d),b=s(h),y=c.slice(u+1).join(` 7`).replace(/<[^>]+>/g,"").trim();y&&b>p&&a.push({startSec:p,endSec:b,text:y})}return a}const yy=e=>[...e||[]].sort((n,r)=>(Number(n.fromFrame)||0)-(Number(r.fromFrame)||0)),I0=e=>!!(e!=null&&e.kenBurns)&&e.kenBurns!=="none",F0=e=>({kbFrom:Math.round(Number(e.kbFrom)||0),kbTotal:Math.max(1,Math.round(Number(e.kbTotal)||Number(e.durationInFrames)||1))});function Uu(e){return I0(e)?F0(e):{}}function zu(e,n){const r={anim:"none"};if(I0(e)){const s=F0(e);r.kbFrom=s.kbFrom+Math.round(Number(n)||0),r.kbTotal=s.kbTotal}return r}function vy(e,n,r){const s=((e==null?void 0:e.tracks)||[]).find(u=>u.id===n);if(!s)return e;const o=(s.clips||[]).find(u=>u.id===r);if(!o)return e;const a=Math.max(0,Math.round(Number(o.fromFrame)||0)),l=a+Math.max(1,Math.round(Number(o.durationInFrames)||1)),c=[];for(const u of s.clips||[]){if(u.id===r){c.push(u);continue}const d=Math.max(0,Math.round(Number(u.fromFrame)||0)),h=Math.max(1,Math.round(Number(u.durationInFrames)||1)),p=d+h;if(p<=a||d>=l){c.push(u);continue}if(d>=a&&p<=l)continue;const b=Math.max(.1,Number(u.speed)||1),y=v=>u.src!=null?{trimStart:Math.max(0,Math.round(Number(u.trimStart)||0)+Math.round(v*b))}:{};if(d<a&&p>l){const[v]=Ku(u,a-d),[,w]=Ku(u,l-d);c.push({...u,durationInFrames:a-d,fadeOut:0,keys:v,...Uu(u)}),c.push({...u,id:Wr("c_"),fromFrame:l,durationInFrames:p-l,fadeIn:0,transitionIn:0,keys:w,...y(l-d),...zu(u,l-d)});continue}if(d<a){c.push({...u,durationInFrames:a-d,...Uu(u)});continue}c.push({...u,fromFrame:l,durationInFrames:p-l,keys:A0(u,l-d).keys,...y(l-d),...zu(u,l-d)})}return{...e,tracks:e.tracks.map(u=>u.id===n?{...u,clips:yy(c)}:u)}}function wy(e,n,r){const s=((e==null?void 0:e.tracks)||[]).find(c=>c.id===n),o=((s==null?void 0:s.clips)||[]).find(c=>c.id===r);if(!s||!o)return e;const a=Math.max(0,Math.round(Number(o.fromFrame)||0)),l=Math.max(1,Math.round(Number(o.durationInFrames)||1));return{...e,tracks:e.tracks.map(c=>c.id!==n?c:{...c,clips:(c.clips||[]).filter(u=>u.id!==r).map(u=>(Number(u.fromFrame)||0)>=a+l?{...u,fromFrame:Math.max(0,(Number(u.fromFrame)||0)-l)}:u)})}}const R0={video:{x:50,y:50,opacity:100,volume:1,w:100,h:100,radius:0,handheld:0,brightness:100,contrast:100,saturate:100},image:{x:50,y:50,opacity:100,w:38,rotation:0,radius:0},shape:{x:50,y:50,opacity:100,width:30,height:30,rotation:0,radius:0,points:5},caption:{x:50,y:84,opacity:100,size:60},audio:{volume:1}},wr={min:-100,max:200},jy=Object.fromEntries(Object.entries(R0).map(([e,n])=>[e,Object.keys(n)])),Jc=(e,n)=>{var r;return(r=R0[e])==null?void 0:r[n]},Bu=(e,n)=>Fr(e,n).length>0,Ny=e=>1+(1.70158+1)*(e-1)**3+1.70158*(e-1)**2,ky=e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,Bi={linear:e=>e,in:e=>e**3,out:e=>1-(1-e)**3,ease:e=>e<.5?2*e*e:1-(-2*e+2)**2/2,smooth:e=>(1-Math.cos(Math.PI*e))/2,back:Ny,bounce:ky,hold:()=>0},wi=[{id:"linear",label:"Linear",hint:"Steady speed"},{id:"in",label:"Ease in",hint:"Starts slow"},{id:"out",label:"Ease out",hint:"Slows to a stop"},{id:"ease",label:"Ease",hint:"Slow at both ends"},{id:"smooth",label:"Smooth",hint:"A gentle curve"},{id:"back",label:"Overshoot",hint:"Goes past, settles back"},{id:"bounce",label:"Bounce",hint:"Lands with a bounce"},{id:"hold",label:"Hold",hint:"Stays, then jumps"}],Sy=(e,n)=>(Bi[e]||Bi.linear)(n);function Fr(e,n){var l;const r=(l=e==null?void 0:e.keys)==null?void 0:l[n];if(!Array.isArray(r)||!r.length)return[];const s=c=>(typeof c=="number"||typeof c=="string"&&c.trim()!=="")&&Number.isFinite(Number(c)),o=new Map,a=c=>typeof c=="string"&&Object.prototype.hasOwnProperty.call(Bi,c)?c:"linear";for(const c of r)c&&s(c.f)&&s(c.v)&&o.set(Math.round(Number(c.f)),{f:Math.round(Number(c.f)),v:Number(c.v),ease:a(c.ease)});return[...o.values()].sort((c,u)=>c.f-u.f)}const P0=e=>Math.max(1,Math.round(Number(e==null?void 0:e.durationInFrames)||1)),Dm=(e,n)=>n.f>=0&&n.f<P0(e);
7function Go(e,n,r,s){const o=Fr(e,n),a=e==null?void 0:e[n],l=a!=null&&a!==""&&Number.isFinite(Number(a))?Number(a):s;if(!o.length)return l;const c=Math.max(0,Math.round(Number(r)||0));if(c<=o[0].f)return o[0].v;const u=o[o.length-1];if(c>=u.f)return u.v;for(let d=0;d<o.length-1;d++){const h=o[d],p=o[d+1];if(c<h.f||c>=p.f)continue;if(p.f===h.f)return p.v;const b=(c-h.f)/(p.f-h.f),y=Bi[h.ease]||Bi.linear;return h.v+(p.v-h.v)*y(b)}return l}function Hu(e,n,r,s,o){const a=Math.max(0,Math.round(Number(r)||0)),l=Number(s);if(!Number.isFinite(l))return e;const c=Fr(e,n),u=c.find(h=>h.f===a),d=c.filter(h=>h.f!==a);return d.push({f:a,v:l,ease:(u==null?void 0:u.ease)||"linear"}),d.sort((h,p)=>h.f-p.f),{...e,keys:{...e.keys||{},[n]:d}}}function T0(e,n,r){const s=Math.max(0,Math.round(Number(r)||0)),o=Fr(e,n);if(!o.some(u=>u.f===s))return e;const a=o.filter(u=>u.f!==s),l={...e.keys||{}};if(a.some(u=>Dm(e,u)))return l[n]=a,{...e,keys:l};delete l[n];const c=Go(e,n,s,e==null?void 0:e[n]);return{...e,[n]:c,keys:Object.keys(l).length?l:void 0}}function Cy(e,n){const r=Math.round(Number(n)||0);let s=e;for(const o of Object.keys((e==null?void 0:e.keys)||{}))Fr(s,o).some(a=>a.f===r)&&(s=T0(s,o,r));return s}function rf(e,n){const r=Math.round(Number(n)||0),s=new Set;for(const o of Object.keys((e==null?void 0:e.keys)||{})){const a=Fr(e,o).find(l=>l.f===r);a&&s.add(a.ease)}return s.size?s.size===1?[...s][0]:"mixed":null}function Ey(e,n){const r=Math.round(Number(n)||0);return Object.keys((e==null?void 0:e.keys)||{}).some(s=>{const o=Fr(e,s);return o.some(a=>a.f===r)&&o.some(a=>a.f>r)})}function My(e,n,r){if(!Object.prototype.hasOwnProperty.call(Bi,r))return e;const s=Math.round(Number(n)||0);let o=!1;const a={...(e==null?void 0:e.keys)||{}};for(const l of Object.keys(a)){const c=Fr(e,l);c.some(u=>u.f===s)&&(o=!0,a[l]=c.map(u=>u.f===s?{...u,ease:r}:u))}return o?{...e,keys:a}:e}const sf=(e,n,r)=>Fr(e,n).some(s=>s.f===Math.max(0,Math.round(Number(r)||0)));function Xd(e){const n=new Set;for(const r of Object.keys((e==null?void 0:e.keys)||{}))for(const s of Fr(e,r))Dm(e,s)&&n.add(s.f);return[...n].sort((r,s)=>r-s)}const Hi=e=>Object.keys((e==null?void 0:e.keys)||{}).filter(n=>Fr(e,n).length),Ll=(e,n,r)=>{const s=new Map;for(const a of r)s.set(Math.round(a.f),{...a,f:Math.round(a.f)});const o=[...s.values()].sort((a,l)=>a.f-l.f);return o.length?e[n]=o:delete e[n],e};function A0(e,n){const r=Math.round(Number(n)||0);if(!r||!Hi(e).length)return e;const s={};for(const o of Hi(e))Ll(s,o,Fr(e,o).map(a=>({...a,f:a.f-r})));return{...e,keys:Object.keys(s).length?s:void 0}}function Ku(e,n){const r=Math.round(Number(n)||0),s={},o={};for(const a of Hi(e)){const l=Fr(e,a);Ll(s,a,l),Ll(o,a,l.map(c=>({...c,f:c.f-r})))}return[Object.keys(s).length?s:void 0,Object.keys(o).length?o:void 0]}function Iy(e,n){const r=Number(n);if(!Number.isFinite(r)||r<=0||r===1||!Hi(e).length)return e;const s={};for(const o of Hi(e))Ll(s,o,Fr(e,o).map(a=>({...a,f:a.f*r})));return{...e,keys:s}}function Fy(e,n,r){const s=Math.round(Number(n)||0),o=Math.round(Number(r)||0);if(s===o)return e;let a=!1;const l={};for(const c of Hi(e)){const u=Fr(e,c),d=u.find(h=>h.f===s);if(!d){l[c]=u;continue}a=!0,Ll(l,c,[...u.filter(h=>h.f!==s&&h.f!==o),{...d,f:o}])}return a?{...e,keys:l}:e}function Ry(e,n,r){const s=Fr(e,n);if(!s.length){const l=e==null?void 0:e[n];return l!=null&&l!==""&&Number.isFinite(Number(l))?Number(l):r}const o=P0(e)-1,a=[];for(let l=0;l<s.length-1;l++){if(s[l].ease!=="back")continue;const c=Math.max(0,s[l].f),u=Math.min(o,s[l+1].f);for(let d=1;d<24&&u>c;d++)a.push(Go(e,n,c+(u-c)*d/24,r))}return Math.max(Go(e,n,0,r),Go(e,n,o,r),...s.filter(l=>Dm(e,l)).map(l=>l.v),...a)}function Jd(e,n,r){var o,a,l;const s=e==null?void 0:e.creditsPerSecond;if(s&&Object.keys(s).length){const c=Number(s[n]??s["720p"])||0,u=Number((o=e==null?void 0:e.billedSeconds)==null?void 0:o.min)||4,d=Number((a=e==null?void 0:e.billedSeconds)==null?void 0:a.max)||15,h=Math.round(Number(r)),p=Number.isFinite(h)&&h>0?h:12;return c*Math.max(u,Math.min(d,p))}return Number((l=e==null?void 0:e.creditCost)==null?void 0:l[n])||0}const Wu=8,Zc=60,Qc=600,of=10,Py=14,af=2e3,ed=8,Ty=3,$0=.25,Ay=["num_images","num_outputs","num_videos","num_results","number_of_images","number_of_outputs","number_of_videos","num_generations","num_layers","n","outputs","num_samples","samples","batch_size"],$y=new Set(["num_samples","samples","batch_size"]),_y=/memory|faster|speed|inference|throughput|quality|better|longer|face id/i,Yu=[["duration",1],["duration_seconds",1],["video_length",1],["video_duration",1],["length",1],["seconds",1]],Dy=[["music_length_ms",1e3],["duration_ms",1e3],["duration",1],["duration_seconds",1],["seconds_total",1],["total_seconds",1],["music_duration",1],["audio_length_in_s",1],["audio_duration",1],["length",1],["seconds",1]],Ly=[["extend_seconds_before",1],["extend_seconds_after",1],["extend_before_duration",1],["extend_after_duration",1],["append_duration",1],["extend_duration",1]],Oy=[["duration",1],["duration_seconds",1],["duration_ms",1e3]],Vy=["frames_per_second","fps","frame_rate","export_fps","output_fps"],_0=/^(text|script|speech|transcript|dialogue|tts_text|input_text|narration)$/i,Lm=/avatar|talking|digital-twin|video-agent|fabric|flashhead|presenter|spokes|narrat|lip-?sync/i,Uy=/trim|retake|cut|shorten/i,zy=/extend|extension|continu|outpaint/i,By=/reference|^target_/i,Hy=/reference-to-video|\/reference$/i,Ky=/truncat|trimmed to the (requested )?(video )?duration|first `?duration`? seconds/i,Wy=/audio|sound|music|song|voice|speech|vocal/i,Yy=/video-agent/i,dd=e=>e!=null&&e!==""&&!(Array.isArray(e)&&e.length===0),Yr=e=>{const n=typeof e=="number"?e:parseFloat(String(e??""));return Number.isFinite(n)?n:NaN},di=e=>e&&e.properties&&typeof e.properties=="object"?e.properties:{},As=(e,n,r)=>{var s;return dd(e==null?void 0:e[r])?e[r]:(s=n[r])==null?void 0:s.default};function tl(e){const n=String(e||"");return/video/.test(n)?"video":/audio|speech/.test(n)?"audio":"image"}function Gy(e,n){const r=di(n),s=Object.keys(r),o=e&&typeof e=="object"&&!Array.isArray(e)?e:{};if(!s.length)return{...o};const a={};for(const l of s)Object.prototype.hasOwnProperty.call(o,l)&&(a[l]=o[l]);return a}function D0(e){const n=di(e);return Ay.find(r=>{const s=n[r];return!(!s||s.type&&s.type!=="integer"&&s.type!=="number"||$y.has(r)&&_y.test(`${s.title||""} ${s.description||""}`))})||null}function qy(e,n,r=""){const s=di(n),o=D0(n);let a=1;if(o&&dd(e==null?void 0:e[o])){const l=Math.trunc(Yr(e[o]));l>=1&&(a=l)}if("max_images"in s){const l=Math.trunc(Yr(As(e,s,"max_images")));l>1&&(a*=l)}if("num_images_per_size"in s&&"target_sizes"in s){const l=As(e,s,"target_sizes"),c=Math.trunc(Yr(As(e,s,"num_images_per_size")));a=(Array.isArray(l)&&l.length?l.length:1)*(c>=1?c:1)}if("series_amount"in s&&As(e,s,"result_type")==="series"){const l=Math.trunc(Yr(As(e,s,"series_amount")));l>1&&(a*=l)}if("placement_type"in s&&As(e,s,"placement_type")==="automatic"&&(a*=10),!o)for(const l of["texts","prompts"]){const c=e==null?void 0:e[l];Array.isArray(c)&&c.length>1&&c.every(u=>typeof u=="string")&&(a*=c.length)}if(r==="image"&&!o&&"num_frames"in s){const l=Math.trunc(Yr(As(e,s,"num_frames")));l>1&&(a*=l)}return a}const Xy=/(video|audio|clip|footage|speech|voice|music|sound|song|vocal)/i,Jy=/(^voice$|_id$|voice_id|setting|mode|format|language|_type$|enable|style|prompt|text|codec|bitrate|quality|fps)/i;
7function Om(e){const n=di(e);return Object.keys(n).filter(r=>{var u;const s=n[r]||{};if(!Xy.test(r)||Jy.test(r)||Array.isArray(s.enum))return!1;const a=s.type==="array"?s.items||{}:s,l=a.type==="object"&&a.properties&&"url"in a.properties;return!(!a.type||a.type==="string")&&!l?!1:l||/(_urls?|_files?|_paths?)$/i.test(r)||s.format==="uri"||((u=s.items)==null?void 0:u.format)==="uri"||/^((input|source|reference|driving)_)?(video|audio|clip|speech|music|sound)s?$/i.test(r)})}const Zy=e=>typeof e=="string"?e:e&&typeof e=="object"&&typeof e.url=="string"?e.url:"";function L0(e,n){const r=[];for(const s of Om(n)){const o=e==null?void 0:e[s],a=(Array.isArray(o)?o:[o]).map(Zy).map(l=>l.trim()).filter(l=>/^https?:\/\//i.test(l));a.length&&r.push({key:s,urls:a,list:Array.isArray(o)})}return r}function Qy(e,n){return[...new Set(L0(e,n).flatMap(r=>r.urls))]}function lf(e,n,r){const s=[];for(const[o,a]of r){const l=n[o];if(!l)continue;const c=dd(e==null?void 0:e[o])||l.default!==void 0;let u=Yr(As(e,n,o))/a;if(u>0){s.push({seconds:u,exact:!0});continue}const d=Array.isArray(l.enum)?l.enum.map(Yr).filter(h=>h>0):[];u=(d.length?Math.max(...d):Yr(l.maximum))/a,s.push({seconds:u>0?u:null,exact:!1,open:!c})}return s}function ev(e,n){var c,u,d;if(!("num_frames"in n))return[];if(/between the/i.test(((c=n.num_frames)==null?void 0:c.description)||""))return[];const r=dd(e==null?void 0:e.num_frames)||((u=n.num_frames)==null?void 0:u.default)!==void 0;let s=Yr(As(e,n,"num_frames")),o=!0;if(!(s>0)&&(o=!1,s=Yr((d=n.num_frames)==null?void 0:d.maximum),!(s>0)))return[];const a=Vy.find(h=>h in n);let l=a?Yr(As(e,n,a)):NaN;if(l>0||(l=24),"num_interpolated_frames"in n&&As(e,n,"adjust_fps_for_interpolation")===!1){const h=Math.trunc(Yr(As(e,n,"num_interpolated_frames")));h>0&&(s*=h+1)}return[{seconds:s/l,exact:o,open:!r}]}function _c(e,n=0){if(!e||typeof e!="object"||n>5)return!1;if(Array.isArray(e))return e.some(s=>_c(s,n+1));const r=e.properties;if(r&&typeof r=="object"){for(const[s,o]of Object.entries(r))if(n>0&&/^duration$/i.test(s)&&/millisecond/i.test((o==null?void 0:o.description)||"")||_c(o,n+1))return!0}return _c(e.items,n+1)}function tv(e,n,r){const s=[],o=l=>{for(const[c,u]of Oy){const d=Yr(l==null?void 0:l[c])/(r&&/^duration$/i.test(c)?1e3:u);if(d>0)return d}return 0},a=(l,c)=>{if(!l||typeof l!="object"||c>3)return 0;if(Array.isArray(l))return l.reduce((d,h)=>d+(h&&typeof h=="object"?o(h)||a(h,c+1):0),0);let u=o(l);for(const d of Object.values(l))d&&typeof d=="object"&&(u=Math.max(u,a(d,c+1)));return u};for(const l of Object.keys(n)){const c=e==null?void 0:e[l];if(!c||typeof c!="object")continue;const u=a(c,0);u>0&&s.push({seconds:u,exact:!0})}return s}function nv(e,n,r){let s=0;const o=Lm.test(String(r||""));for(const a of Object.keys(n)){const l=e==null?void 0:e[a];if(typeof l=="string"&&!/^https?:\/\//i.test(l)&&(_0.test(a)||o&&/prompt/i.test(a)&&!/negative/i.test(a))&&(s+=l.length),l&&typeof l=="object"&&!Array.isArray(l))for(const[c,u]of Object.entries(l))typeof u=="string"&&/^(prompt|text|script)$/i.test(c)&&!/^https?:\/\//i.test(u)&&(s+=u.length)}return s}function rv(e){let n=0;for(const r of Object.values(e||{}))if(typeof r=="string"&&!/^https?:\/\//i.test(r))n+=r.length;else if(Array.isArray(r))for(const s of r)typeof s=="string"&&!/^https?:\/\//i.test(s)&&(n+=s.length);return n}function sv(e,n,r){if(n!=="video")return!1;const s=di(e);return Yu.some(([o])=>o in s)||"num_frames"in s||Om(e).length?!1:Lm.test(String(r||""))||Object.keys(s).some(o=>_0.test(o))}function ov(e,n,r,s,o={},a=""){if(r!=="video"&&r!=="audio")return{seconds:null,basis:"none",missing:[]};const l=di(n),c=r==="video",u=c?Zc:Qc,d=String(s||"").replace(/_/g,"-"),h=L0(e,n),p=c||/^(audio|video)-to-/.test(d),b=new Set(Array.isArray(n==null?void 0:n.required)?n.required:[]);if(p&&!h.length&&Om(n).some(N=>b.has(N)))return{seconds:null,basis:"input",missing:[],waiting:!0};const y=String(a||""),v=c&&lf(e,l,Yu).some(N=>N.exact),w=N=>{var F;return v&&!Lm.test(y)&&Wy.test(N.key)&&(By.test(N.key)||Hy.test(y)||Ky.test(String(((F=l[N.key])==null?void 0:F.description)||"")))},C=h.filter(N=>!w(N)),k=C.length>0&&p,E=[];let m=0;if(k){for(const F of C){let R=0;for(const A of F.urls){const V=Yr(o==null?void 0:o[A]);V>0?R=F.list?R+V:Math.max(R,V):E.push(A)}m=Math.max(m,R)}if(E.length)return{seconds:null,basis:"input",missing:[...new Set(E)]};const N=Yr(As(e,l,"slowdown_factor"));N>1&&(m*=N);for(const[F,R]of Ly)F in l&&(m+=Math.max(0,Yr(As(e,l,F))/R||0))}let M=[...lf(e,l,c?Yu:Dy),...c?ev(e,l):[],...tv(e,l,_c(n))];const I=M.filter(N=>!N.open);if((I.length||k)&&(M=I),k){const N=M.filter(A=>A.seconds>0),F=N.length?Math.max(...N.map(A=>A.seconds)):0,R=String(a||"");return F>0&&Uy.test(R)?{seconds:F,basis:N.every(A=>A.exact)?"set":"upTo",missing:[]}:F>0&&zy.test(R)?{seconds:m+F,basis:"input",missing:[]}:F>m?{seconds:F,basis:N.every(A=>A.exact)?"set":"upTo",missing:[]}:{seconds:m,basis:"input",missing:[]}}if(M.length)return M.some(F=>!(F.seconds>0))?{seconds:u,basis:"upTo",missing:[]}:{seconds:Math.max(...M.map(F=>F.seconds)),basis:M.every(F=>F.exact)?"set":"upTo",missing:[]};if(c){const N=nv(e,l,a)/Py,F=sv(n,r,a)&&rv(e)>af?`This model speaks its text, so it can be up to ${af} characters here.`:"";return Yy.test(y)?{seconds:Math.max(u,N),basis:"upTo",missing:[],textProblem:F}:{seconds:Math.max(of,N),basis:N>of?"set":"upTo",missing:[],textProblem:F}}return{seconds:null,basis:"none",missing:[]}}
7function av(e,n,r){const s=Math.max(0,Yr(n)-$0);return e==="video"?Math.max(Ty,Math.ceil(s)):e==="audio"&&r!=="none"&&s>0?Math.max(1,Math.ceil(s/60)):1}function iv(e,n){for(const[r,s]of Object.entries(di(n))){const o=Number(s==null?void 0:s.maxItems),a=e==null?void 0:e[r];if(!(!Array.isArray(a)||!(o>0)||a.length<=o)&&(/image/i.test(r)||/image/i.test(String((s==null?void 0:s.title)||""))))return{max:o}}return null}function Zd(e,n,{mediaType:r="image",generationType:s="",mediaSeconds:o={},modelId:a=""}={}){const l=Gy(e,n),c=qy(l,n,r),u=ov(l,n,r,s,o,a),d=u.missing.length===0&&!u.waiting,h=d?av(r,u.seconds,u.basis):null,p=r==="video"?Zc:Qc;let b="";const y=iv(l,n);return c>Wu?b=`Up to ${Wu} outputs at a time.`:y?b=`This model takes up to ${y.max} images. Remove some and try again.`:Qy(l,n).length>ed?b=`Up to ${ed} video or audio files at a time.`:u.textProblem?b=u.textProblem:d&&u.seconds!=null&&u.seconds-$0>p&&(b=r==="video"?`Videos can be up to ${Zc} seconds here.`:`Audio can be up to ${Qc/60} minutes here.`),{count:c,seconds:u.seconds,basis:u.basis,missing:u.missing,unit:h,total:h==null?null:h*c,problem:b}}const lv=[{id:"models",label:"Models"},{id:"describe",label:"Describe one"},{id:"mine",label:"My Models"}],Gu=["lite","pro","elite"],qu="headshots",cv=4e3,dv=2e4,cf=10*60*1e3,uv=(e,n)=>`${e}:${String(n||"").trim().toLowerCase()}`,O0=[...Gu.flatMap(e=>(Gb[e]||[]).map(n=>({...n,gender:"female"}))),...Gu.flatMap(e=>(qb[e]||[]).map(n=>({...n,gender:"male"})))].map(e=>({...e,id:uv(e.gender,e.name)})),mv=new Map(O0.map(e=>[e.id,e])),pv=e=>mv.get(String(e||"").toLowerCase())||null,V0=e=>e==="elite"?"Elite":e==="pro"?"Pro":"Lite";function U0(e){return e==="elite"?"bg-amber-500/20 text-amber-400 border-amber-500/30":e==="pro"?"bg-purple-500/20 text-purple-400 border-purple-500/30":"bg-blue-500/20 text-blue-400 border-blue-500/30"}const z0="grid grid-cols-[repeat(auto-fill,minmax(130px,1fr))] gap-3";function Dc({children:e,className:n="text-blue-400 border-blue-500/40 bg-blue-500/10"}){return t.jsxs("div",{className:"flex items-center gap-2 mb-3 py-1",children:[t.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded border ${n}`,children:e}),t.jsx("div",{className:"flex-1 h-px bg-white/10"})]})}const B0=i.memo(function({model:n,name:r,imageUrl:s,selected:o,locked:a,badge:l,note:c,onSelect:u,disabled:d,favorite:h,onToggleFavorite:p,onZoom:b}){const[y,v]=i.useState(!1);return t.jsxs("div",{className:"relative group",children:[t.jsxs("button",{type:"button",onClick:()=>u(n),disabled:d,"aria-pressed":!!o,"aria-label":a?`${r}, locked`:r,className:`w-full relative rounded-xl overflow-hidden border-2 transition-all aspect-[3/4] bg-black/40 disabled:cursor-not-allowed ${o?"border-blue-500 ring-2 ring-blue-500/40":"border-white/10 hover:border-white/30"} ${a?"opacity-60":""}`,children:[!y&&t.jsx("span",{className:"absolute inset-0 animate-pulse bg-white/[0.04]"}),t.jsx("img",{src:$l(s,360),alt:"",loading:"lazy",decoding:"async",onLoad:()=>v(!0),onError:()=>v(!0),className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 ${y?"opacity-100":"opacity-0"}`}),a&&t.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:t.jsx(Po,{className:"w-5 h-5 text-white/70"})}),!a&&o&&t.jsx("span",{className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full bg-blue-500 flex items-center justify-center",children:t.jsx(ga,{className:"w-3 h-3 text-white"})}),t.jsxs("span",{className:"absolute bottom-0 inset-x-0 bg-gradient-to-t from-black/85 to-transparent p-2 text-left",children:[t.jsx("span",{className:"text-[11px] sm:text-xs font-medium text-white truncate block",children:r}),l&&t.jsx("span",{className:`mt-0.5 inline-block text-[9px] font-bold uppercase tracking-wide px-1.5 py-[1px] rounded border ${U0(l)}`,children:V0(l)}),c&&t.jsx("span",{className:"text-[10px] text-blue-200/90 block truncate",children:c})]})]}),p&&(!a||h)&&t.jsx("button",{type:"button",onClick:()=>p(n),"aria-pressed":!!h,title:h?"Remove from favorites":"Add to favorites","aria-label":`${h?"Remove":"Add"} ${r} ${h?"from":"to"} favorites`,className:`absolute top-1.5 left-1.5 w-6 h-6 rounded-full flex items-center justify-center transition-all z-20 ${h?"bg-pink-500/90 text-white opacity-100":"bg-black/60 text-white/70 hover:text-pink-400 opacity-100 lg:opacity-0 lg:group-hover:opacity-100"}`,children:t.jsx(Nl,{className:`w-3 h-3 ${h?"fill-white":""}`})}),b&&!a&&t.jsx("button",{type:"button",onClick:()=>b(n),title:"View enlarged","aria-label":`View ${r} enlarged`,className:`absolute top-1.5 ${p?"left-9":"left-1.5"} w-6 h-6 rounded-full bg-black/60 text-white/70 hover:text-white hover:bg-black/80 flex items-center justify-center transition-all z-20 opacity-100 lg:opacity-0 lg:group-hover:opacity-100`,children:t.jsx(Wb,{className:"w-3 h-3"})})]})}),fv=[{id:"female",label:"Women"},{id:"male",label:"Men"}],hv=i.memo(function({value:n,onChange:r,canUseTier:s,onLocked:o,disabled:a,isFav:l,toggleFav:c,favUrls:u,onZoom:d}){const[h,p]=i.useState(()=>((n==null?void 0:n.kind)==="model"?n.gender:"")||"female"),[b,y]=i.useState(""),v=i.useCallback(m=>s(m.tier)?r({kind:"model",id:m.id,name:m.name,gender:m.gender,imageUrl:m.url,ready:!0}):o(m.tier),[s,r,o]),w=i.useRef("");i.useEffect(()=>{(n==null?void 0:n.kind)!=="model"||!n.gender||w.current!==n.id&&(w.current=n.id,p(n.gender))},[n==null?void 0:n.kind,n==null?void 0:n.id,n==null?void 0:n.gender]);const C=i.useCallback(m=>c(qu,m.url),[c]),k=b.trim().toLowerCase(),E=i.useMemo(()=>{const m=[],M=new Set(u||[]),I=O0.filter(F=>F.gender===h&&(!k||F.name.toLowerCase().includes(k))),N=I.filter(F=>M.has(F.url));N.length&&m.push(["favorites",N]);for(const F of Gu){const R=I.filter(A=>A.tier===F&&!M.has(A.url));R.length&&m.push([F,R])}return m},[h,k,u]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[t.jsx(Am,{tabs:fv,value:h,onChange:p,fullWidth:!0,className:"sm:max-w-[260px] w-full"}),t.jsxs("div",{className:"relative flex-1",children:[t.jsx(zl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500 pointer-events-none"}),t.jsx("input",{type:"search",value:b,onChange:m=>y(m.target.value),placeholder:`Search ${h==="female"?"women":"men"} by name`,"aria-label":"Search models by name",className:"w-full pl-9 pr-3 py-2 text-base sm:text-sm bg-white/5 border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/25"})]})]}),E.length===0?t.jsxs("p",{className:"text-sm text-gray-500 text-center py-10",children:["No models match â",b,"â."]}):E.map(([m,M])=>t.jsxs("div",{children:[t.jsx(Dc,{className:m==="favorites"?"text-pink-400 border-pink-500/40 bg-pink-500/10":U0(m),children:m==="favorites"?"â
Favorites":V0(m)}),t.jsx("div",{className:z0,children:M.map(I=>t.jsx(B0,{model:I,name:I.name,imageUrl:I.url,selected:(n==null?void 0:n.kind)==="model"&&n.id===I.id,locked:!s(I.tier),badge:m==="favorites"?I.tier:"",disabled:a,onSelect:v,favorite:l(qu,I.url),onToggleFavorite:C,onZoom:d},I.id))})]},m))]})});function xv({candidates:e,freeLeft:n,retrying:r,saving:s,name:o,onNameChange:a,onRetry:l,onConfirm:c,onCancel:u,error:d}){const[h,p]=i.useState(null);return i.useEffect(()=>{h!=null&&h>=e.length&&p(null)},[e.length,h]),t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-[#14161a] overflow-hidden",children:[t.jsxs("div",{className:"px-4 sm:px-5 pt-4 pb-3 border-b border-white/[0.06]",children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:"Your model is ready"}),t.jsx("p",{className:"text-[13px] mt-1 text-gray-400",children:e.length>1?"Choose the model you like best":"Not happy? You can try again for free below"})]}),t.jsxs("div",{className:"p-4 sm:p-5 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[e.map((b,y)=>{const v=h===y;return t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("button",{type:"button",onClick:()=>!s&&!r&&p(y),"aria-pressed":v,"aria-label":`Option ${y+1}`,className:`relative rounded-xl overflow-hidden bg-black/40 aspect-[3/4] border-2 transition ${v?"border-blue-500 ring-2 ring-blue-500/40":"border-white/10 hover:border-white/30"}`,children:[t.jsx("img",{src:$l(b,420),alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.length>1&&y===e.length-1&&t.jsx("span",{className:"absolute top-2 right-2 px-2 py-0.5 rounded-full bg-green-500/90 text-white text-[10px] font-bold uppercase tracking-wide",children:"Latest"})]}),t.jsx("button",{type:"button",onClick:()=>v?c(b):p(y),disabled:s||r,className:`mt-2 w-full py-2 rounded-full text-xs font-semibold text-white transition disabled:opacity-50 ${v?"bg-green-600 hover:bg-green-500":"bg-blue-600 hover:bg-blue-500"}`,children:v?s?"Savingâ¦":"Confirm":"Select"})]},b)}),Array.from({length:n},(b,y)=>t.jsx("button",{type:"button",onClick:l,disabled:r||s,"aria-label":r&&y===0?"Generating another option":"Try again for free",className:"rounded-xl border-2 border-dashed border-purple-500/30 bg-purple-500/[0.04] hover:bg-purple-500/[0.08] hover:border-purple-500/50 transition disabled:opacity-50 disabled:cursor-not-allowed",children:t.jsx("span",{className:"flex aspect-[3/4] flex-col items-center justify-center gap-2 px-3 text-center",children:r&&y===0?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-7 h-7 border-2 border-purple-400/30 border-t-purple-400 rounded-full animate-spin"}),t.jsx("span",{className:"text-xs text-purple-300/80 font-medium",children:"Generatingâ¦"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:t.jsx(fo,{className:"w-4 h-4 text-purple-400"})}),t.jsx("span",{className:"text-xs font-semibold text-purple-300",children:"Try again (free)"}),y===0&&t.jsxs("span",{className:"text-[10px] text-gray-500",children:[n," free ",n===1?"try":"tries"," remaining"]})]})})},`try-${y}`))]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[t.jsx("input",{value:o,onChange:b=>a(b.target.value.slice(0,100)),placeholder:"Name this model (optional)","aria-label":"Model name",className:"flex-1 px-3 py-2 rounded-lg bg-white/[0.06] border border-white/10 text-base sm:text-sm text-white placeholder:text-gray-600 focus:outline-none focus:border-blue-500/50"}),t.jsx("button",{type:"button",onClick:u,disabled:s,className:"px-4 py-2 rounded-full border border-white/15 text-sm text-gray-300 hover:bg-white/[0.06] disabled:opacity-50",children:"Start over"})]}),d&&t.jsx("p",{role:"alert",className:"text-xs text-red-400 font-medium",children:d})]})]})}const df={gender:"",skinTone:"",race:"",raceOther:"",age:"",makeup:"",hairColour:"",details:""};function uf({source:e,api:n,onCreated:r,onCreditsChanged:s}){const[o,a]=i.useState(null),[l,c]=i.useState(!1),[u,d]=i.useState(df),[h,p]=i.useState([]),[b,y]=i.useState(0),[v,w]=i.useState(""),[C,k]=i.useState(!1),[E,m]=i.useState(!1),[M,I]=i.useState(""),[N,F]=i.useState(""),R=i.useRef(null),A=O=>D=>d(W=>({...W,[O]:D})),V=e==="describe",z=i.useRef(""),H=O=>{z.current&&z.current!==(O==null?void 0:O.preview)&&URL.revokeObjectURL(z.current),z.current=(O==null?void 0:O.preview)||"",a(O)};i.useEffect(()=>()=>z.current&&URL.revokeObjectURL(z.current),[]);const ne=async O=>{if(O){if(!/^image\//i.test(O.type||"")&&!/\.hei[cf]$/i.test(O.name||"")){F("Upload a photo (JPG or PNG).");return}F(""),c(!0);
7try{const{file:D,dataUrl:W}=await n.preparePhoto(O);if(H({preview:URL.createObjectURL(D),dataUrl:W}),W)try{const oe=await n.tryOn("detect-model-meta",{image:{data:W},skinToneOptions:Qp});oe!=null&&oe.ok&&d(we=>({...we,gender:oe.gender==="male"||oe.gender==="female"?oe.gender:we.gender,skinTone:oe.skinTone&&Qp.includes(oe.skinTone)?oe.skinTone:we.skinTone}))}catch{}}catch(D){F((D==null?void 0:D.message)||"That photo could not be read. Please try another one.")}finally{c(!1)}}},se=async(O=!1)=>{if(u.gender!=="male"&&u.gender!=="female"){F("Choose your model's gender first.");return}if(!u.skinTone){F("Choose your model's skin tone first.");return}if(!V&&!(o!=null&&o.dataUrl)){F("Upload a headshot first.");return}F(""),k(!0);try{const D=await n.tryOn("create-model",{...V?{describe:!0,details:u.details}:{headshotData:{data:o.dataUrl.split(",").pop(),mimeType:"image/jpeg"}},gender:u.gender,skinTone:u.skinTone,race:(u.race==="__other__"?u.raceOther:u.race)||void 0,age:u.age?String(u.age):void 0,makeup:u.makeup||void 0,hairColour:u.hairColour||void 0,regenCount:O?b+1:0,...O&&v?{retrySessionId:v}:{}}),W=Array.isArray(D==null?void 0:D.candidates)?D.candidates.filter(Boolean):[];if(!(D!=null&&D.ok)||!W.length)throw new Error((D==null?void 0:D.error)||"Model generation failed. Please try again.");p(oe=>O?[...oe,...W]:W),y(typeof D.regenCount=="number"?D.regenCount:O?b+1:0),O||w(D.retrySessionId||""),s==null||s()}catch(D){const W=(D==null?void 0:D.data)||{};(D==null?void 0:D.code)==="INSUFFICIENT_TOKENS"||W.code==="INSUFFICIENT_TOKENS"?F(`Not enough credits. You need ${W.required||1} and have ${W.currentBalance??0}.`):(D==null?void 0:D.code)==="FREE_RETRIES_USED"||W.code==="FREE_RETRIES_USED"?(y(2),F(W.error||D.message)):F(W.error||(D==null?void 0:D.message)||"Model generation failed. Please try again.")}finally{k(!1)}},pe=async O=>{var D;m(!0),F("");try{const W=await n.tryOn("save-model",{imageUrl:O,headshotUrl:null,gender:u.gender,skinTone:u.skinTone,name:M.trim()||void 0});if(!(W!=null&&W.ok)||!W.model)throw new Error((W==null?void 0:W.error)||"The model could not be saved.");r(W.model),ie()}catch(W){F(((D=W==null?void 0:W.data)==null?void 0:D.error)||(W==null?void 0:W.message)||"The model could not be saved. Please try again.")}finally{m(!1)}},ie=()=>{p([]),y(0),w(""),I(""),F(""),H(null),d(df)};if(h.length){const O=Math.max(0,Math.min(2-b,3-h.length));return t.jsx(xv,{candidates:h,freeLeft:O,retrying:C,saving:E,name:M,onNameChange:I,onRetry:()=>se(!0),onConfirm:pe,onCancel:ie,error:N})}return t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-3",children:[!V&&t.jsx("div",{className:"w-full max-w-[220px] mx-auto sm:mx-0 sm:w-[180px] shrink-0",children:o?t.jsxs("div",{className:"relative rounded-xl overflow-hidden border-2 border-white/10 aspect-[3/4] bg-black/40",children:[t.jsx("img",{src:o.preview,alt:"Your headshot",className:"absolute inset-0 w-full h-full object-cover"}),l&&t.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:t.jsx("span",{className:"w-7 h-7 border-2 border-white/20 border-t-blue-400 rounded-full animate-spin"})}),t.jsx("button",{type:"button",onClick:()=>H(null),disabled:C,"aria-label":"Remove photo",className:"absolute top-1.5 right-1.5 w-8 h-8 rounded-full bg-black/70 flex items-center justify-center text-white",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]}):t.jsxs("label",{onDragOver:O=>O.preventDefault(),onDrop:O=>{var D,W;O.preventDefault(),ne((W=(D=O.dataTransfer)==null?void 0:D.files)==null?void 0:W[0])},className:"w-full relative rounded-xl overflow-hidden border-2 border-dashed border-white/20 aspect-[3/4] flex flex-col items-center justify-center gap-2 bg-[#1a1a1f] cursor-pointer hover:border-blue-500/50 transition",children:[t.jsx("input",{ref:R,type:"file",accept:"image/*,.heic,.heif",className:"hidden",onChange:O=>{var W;const D=(W=O.target.files)==null?void 0:W[0];O.target.value="",ne(D)}}),l?t.jsx("span",{className:"w-7 h-7 border-2 border-white/20 border-t-blue-400 rounded-full animate-spin"}):t.jsx(ho,{className:"w-6 h-6 text-gray-500"}),t.jsx("span",{className:"text-xs font-medium text-white/70 px-3 text-center",children:l?"Reading your photoâ¦":"Upload a headshot"}),!l&&t.jsx("span",{className:"text-[10px] text-gray-500 px-3 text-center",children:"A clear, well lit face works best"})]})}),(V||o)&&t.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[V&&t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] p-3 sm:p-4",children:[t.jsx("label",{className:"block text-[10px] text-gray-500 mb-1 font-medium",htmlFor:"ugc-describe-details",children:"Anything else about them"}),t.jsx("textarea",{id:"ugc-describe-details",rows:2,maxLength:400,value:u.details,onChange:O=>A("details")(O.target.value),placeholder:'e.g. "short curly hair, freckles, friendly and relaxed"',className:"w-full px-3 py-2 rounded-lg bg-white/[0.06] border border-white/10 text-base sm:text-sm text-white placeholder:text-gray-600 focus:outline-none focus:border-blue-500/50"})]}),t.jsx(Yb,{race:u.race,onRaceChange:A("race"),raceOther:u.raceOther,onRaceOtherChange:A("raceOther"),age:u.age,onAgeChange:A("age"),skinTone:u.skinTone,onSkinToneChange:A("skinTone"),makeup:u.makeup,onMakeupChange:A("makeup"),hairColour:u.hairColour,onHairColourChange:A("hairColour"),gender:u.gender,onGenderChange:A("gender"),onGenerate:()=>se(!1),generating:C}),N&&t.jsx("p",{role:"alert",className:"text-xs text-red-400 font-medium",children:N})]}),!V&&!o&&N&&t.jsx("p",{role:"alert",className:"text-xs text-red-400 font-medium",children:N})]})}
7function gv({state:e,onRetry:n,onChooseAnother:r}){const[s,o]=i.useState(0);i.useEffect(()=>{if(e.failed)return;o(0);const l=setInterval(()=>o(c=>c+1),1e3);return()=>clearInterval(l)},[e.failed,e.id]),i.useEffect(()=>{if(e.failed)return;const l=c=>(c.preventDefault(),c.returnValue="","");return window.addEventListener("beforeunload",l),()=>window.removeEventListener("beforeunload",l)},[e.failed]);const a=`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;return Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[9998] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",role:"dialog","aria-modal":"true","aria-labelledby":"ugc-prep-title",children:t.jsx("div",{className:"modal-pop-in w-full max-w-md rounded-2xl border border-white/10 bg-[#14161a] p-6 text-center shadow-2xl",children:e.failed?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-500/10 border border-red-500/30",children:t.jsx(Xs,{className:"h-5 w-5 text-red-400"})}),t.jsxs("h3",{id:"ugc-prep-title",className:"text-base font-semibold text-white",children:["We could not finish updating ",e.name]}),t.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-gray-400",children:"Your model itself is untouched and still works everywhere else. You can try again, or use a different model for this video."}),t.jsxs("div",{className:"mt-5 flex flex-col sm:flex-row gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"flex-1 rounded-full border border-white/15 px-4 py-2.5 text-sm text-gray-200 hover:bg-white/[0.06]",children:"Choose another model"}),t.jsx("button",{type:"button",onClick:n,className:"flex-1 rounded-full bg-[#326CB4] px-4 py-2.5 text-sm font-semibold text-white hover:bg-[#3A78C6]",children:"Try again"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-500/10 border border-blue-500/30",children:t.jsx("span",{className:"h-6 w-6 rounded-full border-2 border-blue-400/30 border-t-blue-400 animate-spin"})}),t.jsx("h3",{id:"ugc-prep-title",className:"text-base font-semibold text-white",children:e.isNew?`Getting ${e.name} ready for UGC Studio`:`Updating ${e.name} for UGC Studio`}),t.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-gray-400",children:e.isNew?"We are preparing the version of your model that videos are made from. This happens once, and it takes a minute or two.":"This model was made before UGC Studio used your own models, so we are preparing the version videos are made from. Your model stays exactly the same, and this happens only once."}),t.jsx("p",{className:"mt-3 text-[12px] text-blue-200/90",children:"Please keep this page open. No extra credits are used."}),t.jsx("p",{className:"mt-4 text-[12px] tabular-nums text-gray-500",children:a})]})})}),document.body)}function mf(){return t.jsxs("p",{className:"text-[12px] text-gray-400",children:[t.jsx("span",{className:"font-semibold text-gray-200",children:"1 credit"})," for the model, with 2 free tries if you do not like the first one. Getting it ready for UGC Studio is included, and it is saved to My Models to use again for free."]})}function bv({model:e,onClose:n}){return i.useEffect(()=>{const r=s=>s.key==="Escape"&&n();return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-[fadeIn_.14s_ease-out]",onClick:n,role:"dialog","aria-modal":"true","aria-label":`${e.name} enlarged`,children:t.jsxs("div",{className:"relative flex items-center justify-center max-w-[90vw] max-h-[90vh] bg-[#16181A] rounded-xl shadow-2xl border border-[#27272A] p-4",onClick:r=>r.stopPropagation(),children:[t.jsxs("button",{type:"button",onClick:n,className:"absolute top-2 left-2 inline-flex items-center gap-2 px-3 h-9 rounded-md bg-[#252525] hover:bg-[#2f2f2f] text-gray-100 border border-white/10 focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer z-10","aria-label":"Close enlarged view",title:"Close",children:[t.jsx(ft,{className:"w-4 h-4"}),t.jsx("span",{className:"text-xs font-medium",children:"Close"})]}),t.jsx("img",{src:e.url||e.imageUrl,alt:`${e.name} enlarged`,className:"max-w-full max-h-[85vh] object-contain rounded-lg"}),t.jsx("span",{className:"absolute bottom-3 right-4 text-[11px] font-medium text-white/70",children:e.name})]})}),document.body)}function pf({onLocked:e,children:n}){return t.jsxs("button",{type:"button",onClick:()=>e("elite"),className:"w-full rounded-2xl border-2 border-dashed border-white/15 bg-[#1a1a1f] px-4 py-8 flex flex-col items-center gap-2 text-center hover:border-white/25 transition",children:[t.jsx(Po,{className:"w-5 h-5 text-white/70"}),t.jsx("span",{className:"text-sm font-semibold text-white/80",children:"Elite only"}),t.jsx("span",{className:"text-xs text-gray-500 max-w-sm",children:n})]})}
7function yv({value:e,onChange:n,tab:r,onTabChange:s,api:o,canUseTier:a,hasElite:l,onLocked:c,onCreditsChanged:u,signedIn:d=!0,disabled:h=!1}){const{isFav:p,toggleFav:b,getFavUrls:y}=x0(),v=y(qu),[w,C]=i.useState(null),k=i.useCallback(()=>C(null),[]),[E,m]=i.useState(null),[M,I]=i.useState(""),[N,F]=i.useState(null),R=i.useRef(null),A=i.useRef(e);A.current=e;const V=i.useRef(""),z=i.useRef(!1),H=i.useCallback(async()=>{if(!z.current){z.current=!0,I("");try{const O=await o.ugc("my-models");m(Array.isArray(O==null?void 0:O.models)?O.models:[])}catch(O){I((O==null?void 0:O.message)||"Your models could not be loaded."),m(D=>D||[])}finally{z.current=!1}}},[o]);i.useEffect(()=>{d&&r==="mine"&&E===null&&H()},[d,r,E,H]),i.useEffect(()=>{d&&(e==null?void 0:e.kind)==="custom"&&E===null&&H()},[d,e==null?void 0:e.kind,E,H]),i.useEffect(()=>()=>clearTimeout(R.current),[]);const ne=i.useCallback(async(O,{isNew:D=!1,retry:W=!1}={})=>{clearTimeout(R.current),V.current=O.id;const oe=Date.now();let we=0,Re=!0,le=cv;F({id:O.id,name:O.name,isNew:D,failed:!1});const Ne=async()=>{var ce,Ae;try{const De=await o.ugc("prepare-model",{customModelId:O.id,...W&&Re?{retry:!0}:{}});Re=!1;const Ze=De==null?void 0:De.model;if(Ze&&m(Ye=>Ye&&Ye.map(at=>at.id===Ze.id?{...at,...Ze}:at)),((ce=A.current)==null?void 0:ce.kind)!=="custom"||A.current.id!==O.id){V.current===O.id&&(V.current=""),F(Ye=>(Ye==null?void 0:Ye.id)===O.id?null:Ye);return}if(V.current!==O.id)return;if(Ze!=null&&Ze.ugcReady){F(null),n({...A.current,ready:!0});return}if(we=0,(Ze==null?void 0:Ze.scrambledStatus)==="failed"||Date.now()-oe>cf){F({id:O.id,name:O.name,isNew:D,failed:!0}),n({...A.current,ready:!1,prepareFailed:!0});return}}catch{if(we+=1,we>=3||Date.now()-oe>cf){F({id:O.id,name:O.name,isNew:D,failed:!0}),((Ae=A.current)==null?void 0:Ae.kind)==="custom"&&A.current.id===O.id&&n({...A.current,ready:!1,prepareFailed:!0});return}}R.current=setTimeout(Ne,le),le=Math.min(dv,Math.round(le*1.5))};Ne()},[o,n]),se=(O,D)=>{const W={kind:"custom",id:O.id,name:O.name,gender:O.gender,imageUrl:O.imageUrl,ready:!!O.ugcReady};n(W),A.current=W,O.ugcReady?(clearTimeout(R.current),V.current="",F(null)):ne(O,D)};i.useEffect(()=>{if((e==null?void 0:e.kind)!=="custom"||!E||V.current===e.id)return;const O=E.find(D=>D.id===e.id);O&&!O.ugcReady&&(n({...e,ready:!1}),ne(O))},[e==null?void 0:e.kind,e==null?void 0:e.id,E]);const pe=O=>{const D={...O,ugcReady:!1,scrambledStatus:"pending"};m(W=>W&&[D,...W]),s("mine"),se(D,{isNew:!0})},ie=N&&(e==null?void 0:e.kind)==="custom"&&e.id===N.id?N:null;return t.jsxs("div",{className:`space-y-4 ${h?"opacity-60 pointer-events-none":""}`,children:[t.jsx(Am,{tabs:lv,value:r,onChange:s,fullWidth:!0,className:"w-full sm:max-w-[420px]"}),ie&&t.jsx(gv,{state:ie,onRetry:()=>ne({id:ie.id,name:ie.name},{retry:!0}),onChooseAnother:()=>{clearTimeout(R.current),V.current="",F(null),n(null),s("models")}}),r==="models"&&t.jsx(hv,{value:e,onChange:n,canUseTier:a,onLocked:c,disabled:h,isFav:p,toggleFav:b,favUrls:v,onZoom:C}),w&&t.jsx(bv,{model:w,onClose:k}),t.jsx("div",{hidden:r!=="describe",className:"space-y-3",children:l?t.jsxs(t.Fragment,{children:[t.jsx(Dc,{children:"Create a model from a description"}),t.jsx("p",{className:"text-[12px] text-gray-400 -mt-1",children:"Describe the person and we create a model for you, just like in Model Try-On."}),t.jsx(mf,{}),t.jsx(uf,{source:"describe",api:o,onCreated:pe,onCreditsChanged:u})]}):t.jsx(pf,{onLocked:c,children:"Creating your own model from a description is part of the Elite plan."})}),t.jsxs("div",{hidden:r!=="mine",className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx(Dc,{children:"Create Your Own Model"}),l?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-[12px] text-gray-400 mb-3",children:"Upload a photo and we create a model who looks like it, just like in Model Try-On."}),t.jsx("div",{className:"mb-3",children:t.jsx(mf,{})}),t.jsx(uf,{source:"upload",api:o,onCreated:pe,onCreditsChanged:u})]}):t.jsx(pf,{onLocked:c,children:"Creating your own model from a photo is part of the Elite plan."})]}),t.jsxs("div",{children:[t.jsx(Dc,{className:"text-gray-400 border-gray-500/40 bg-gray-500/10",children:"Saved Models"}),d?E===null?t.jsx("div",{className:"flex items-center justify-center py-10",children:t.jsx("span",{className:"w-8 h-8 border-2 border-white/20 border-t-blue-400 rounded-full animate-spin"})}):E.length===0?t.jsxs("div",{className:"text-center py-8 space-y-2",children:[t.jsx("span",{className:"w-12 h-12 mx-auto rounded-full bg-white/5 border border-white/10 flex items-center justify-center",children:t.jsx(Zs,{className:"w-5 h-5 text-gray-600"})}),t.jsx("p",{className:"text-sm text-gray-500",children:M||"No saved models yet"}),M&&t.jsx("button",{type:"button",onClick:H,className:"text-xs underline text-gray-400",children:"Try again"})]}):t.jsx("div",{className:z0,children:E.map(O=>t.jsx(B0,{model:O,name:O.name,imageUrl:O.imageUrl,selected:(e==null?void 0:e.kind)==="custom"&&e.id===O.id,note:(N==null?void 0:N.id)===O.id&&!N.failed?"Updatingâ¦":"",disabled:h,onSelect:se,onZoom:C},O.id))}):t.jsx("p",{className:"text-sm text-gray-500 text-center py-8","data-my-models-signedout":!0,children:"Sign in to see the models you have saved."})]})]})]})}const vv=i.memo(yv),wv=30,jv=180,H0=20,Xu={"9x16":{width:1080,height:1920},"4x5":{width:1080,height:1350}
7,"1x1":{width:1080,height:1080},"16x9":{width:1920,height:1080}},Nv=Object.keys(Xu),kv=e=>Xu[e]||Xu["9x16"],Vm={aspect:"9x16",fit:"cover",transition:"cut",imageSeconds:3,lengthMode:"clips",musicVolume:30,clipSound:!1,captionPos:"bottom",captionStyle:"shadow"},ff=50,Sv=240,Cv=12,hf=8,Ev=15,Mv=10,Iv={top:14,middle:50,bottom:80},Fv={shadow:{color:"#ffffff"},dark:{color:"#ffffff",bg:"rgba(0,0,0,0.62)"},light:{color:"#111111",bg:"#ffffff"}},Ro=(e,n=0)=>Number.isFinite(Number(e))?Number(e):n,Ju=(e,n,r)=>Math.min(r,Math.max(n,e)),ji=(e,n,r)=>n.includes(e)?e:r,Lc=e=>typeof e=="string"&&/^https?:\/\//i.test(e.trim());function Rv(e,n=24){const r=String(e||"").replace(/\r/g,"").trim();if(!r)return[];let s=r.split(/\n+/).map(o=>o.trim()).filter(Boolean);return s.length===1&&(s=s[0].replace(/([.!?]+["')\]]*)\s+/g,`$1 8`).split(` 9`).map(o=>o.trim()).filter(Boolean)),s=s.map(o=>o.slice(0,220)),s.length>n&&(s=[...s.slice(0,n-1),s.slice(n-1).join(" ")]),s}function Pv(e={}){const n=Vm;return{aspect:ji(e.aspect,Nv,n.aspect),fit:ji(e.fit,["cover","contain"],n.fit),transition:ji(e.transition,["cut","crossfade"],n.transition),imageSeconds:Ju(Ro(e.imageSeconds,n.imageSeconds),1,15),lengthMode:ji(e.lengthMode,["clips","voice"],n.lengthMode),musicVolume:Ju(Ro(e.musicVolume,n.musicVolume),0,100),clipSound:e.clipSound===!0,captionPos:ji(e.captionPos,["top","middle","bottom"],n.captionPos),captionStyle:ji(e.captionStyle,["shadow","dark","light"],n.captionStyle)}}function Tv({clips:e=[],voice:n=null,music:r=null,captions:s="",settings:o={}}={}){const a=Pv(o),l=wv,c=le=>Math.round(le*l),u=(Array.isArray(e)?e:[]).filter(le=>le&&Lc(le.url)&&(le.kind==="video"||le.kind==="image")).slice(0,H0);if(!u.length)return{error:"Connect at least one finished video or image to Clips."};const{width:d,height:h}=kv(a.aspect),p=c(jv),b=le=>le.kind==="image"?c(a.imageSeconds):Ju(c(Ro(le.seconds)>0?Ro(le.seconds):Ro(le.fallbackSeconds,5)||5),c(.5),c(120)),y=u.map(b),v=y.reduce((le,Ne)=>le+Ne,0),w=n&&Lc(n.url)?n.url.trim():null,C=w&&Ro(n.seconds)>0?c(Ro(n.seconds)):0,k=a.lengthMode==="voice"&&C>0,E=Math.min(p,k?C+Ev:v),m=[];let M=0;for(let le=0;M<E&&m.length<Sv;le++){const Ne=le%u.length,ce=Math.min(y[Ne],E-M);ce<Mv&&m.length?m[m.length-1].frames+=ce:m.push({clip:u[Ne],frames:ce}),M+=ce}const I=Math.max(1,m.reduce((le,Ne)=>le+Ne.frames,0)),N=[],F=[];let R=0;m.forEach((le,Ne)=>{const ce=m[Ne-1],Ae=m[Ne+1],De=at=>at&&at.clip.kind===le.clip.kind,Ze=a.transition==="crossfade",Ye={id:`${le.clip.kind==="image"?"s":"v"}${Ne+1}`,src:le.clip.url.trim(),fromFrame:R,durationInFrames:le.frames};if(Ze&&Ne>0&&De(ce)&&(Ye.transitionIn=Math.min(Cv,Math.max(1,le.frames-1))),Ze&&ce&&!De(ce)&&(Ye.fadeIn=Math.min(hf,le.frames)),Ze&&Ae&&!De(Ae)&&(Ye.fadeOut=Math.min(hf,le.frames)),le.clip.kind==="image"){const at=Ro(le.clip.width),ut=Ro(le.clip.height),Xe=a.fit==="cover"&&at>0&&ut>0?Math.max(d/h/(at/ut),at/ut/(d/h)):1;F.push({...Ye,x:50,y:50,w:Math.round(100*Xe*100)/100,h:Math.round(100*Xe*100)/100,kenBurns:"in"})}else N.push({...Ye,fit:a.fit,...a.clipSound?{volume:w?.35:1}:{}});R+=le.frames});const A=Rv(s,Math.max(1,Math.min(24,Math.floor(I/15)))),V=Fv[a.captionStyle],z=Math.round(Math.min(d,h)*.058),H=A.map(le=>Math.max(1,le.split(/\s+/).filter(Boolean).length)),ne=H.reduce((le,Ne)=>le+Ne,0),se=A.length?Math.min(15,Math.floor(I/A.length)):0,pe=I-se*A.length,ie=[];let O=0;A.forEach((le,Ne)=>{const Ae=Ne===A.length-1?I-O:Math.max(1,se+Math.round(pe*H[Ne]/ne));Ae<1||O>=I||(ie.push({id:`c${Ne+1}`,text:le,fromFrame:O,durationInFrames:Math.min(Ae,I-O),x:50,y:Iv[a.captionPos],size:z,anim:"pop",weight:800,...V}),O+=Ae)});const D=[];N.length&&D.push({id:"scenes",type:"video",name:"Clips",muted:!a.clipSound,clips:N}),F.length&&D.push({id:"stills",type:"image",name:"Stills",clips:F}),D.push({id:"captions",type:"caption",name:"Captions",clips:ie}),w&&D.push({id:"voice",type:"audio",name:"Voiceover",clips:[{id:"vo",src:w,fromFrame:0,durationInFrames:C?Math.min(I,C):I,volume:1}]});const W=r&&Lc(r.url)?r.url.trim():null;if(W){const le=Ro(r.seconds)>0?c(Ro(r.seconds)):0;D.push({id:"music",type:"audio",name:"Music",clips:[{id:"music",src:W,fromFrame:0,durationInFrames:I,volume:Math.round(a.musicVolume)/100,fadeOut:Math.min(30,Math.floor(I/3)),...le>1&&le<I?{loop:!0,loopFrames:le}:{}}]})}const oe=(a.clipSound?N.length:0)+(w?1:0)+(W?1:0);if(oe>ff)return{error:`That's ${oe} sounds playing in one ad, and ${ff} is the most. Set Clip sound to Muted, or use fewer, longer clips.`};const we={fps:l,width:d,height:h,durationInFrames:I,minDurationInFrames:1,background:"#000000",tracks:D},Re=E0(we);return Re?{error:Re}:{doc:we,seconds:I/l}}function Qd(e,n,r=15e3){return new Promise(s=>{if(typeof document>"u"||!Lc(e))return s({seconds:0,width:0,height:0});let o=!1,a=null;const l=u=>{var d;if(!o){o=!0,clearTimeout(c);try{a&&n!=="image"&&(a.removeAttribute("src"),(d=a.load)==null||d.call(a))}catch{}s(u)}},c=setTimeout(()=>l({seconds:0,width:0,height:0}),r);if(n==="image"){a=new Image,a.onload=()=>
9l({seconds:0,width:a.naturalWidth||0,height:a.naturalHeight||0}),a.onerror=()=>l({seconds:0,width:0,height:0}),a.src=e;return}a=document.createElement(n==="audio"?"audio":"video"),a.preload="metadata",a.muted=!0,a.onloadedmetadata=()=>l({seconds:Number.isFinite(a.duration)?a.duration:0,width:a.videoWidth||0,height:a.videoHeight||0}),a.onerror=()=>l({seconds:0,width:0,height:0}),a.src=e})}function ud(e){return typeof e!="string"||!/^https?:\/\//i.test(e.trim())?null:/res\.cloudinary\.com/.test(e)&&e.includes("/upload/")?e.replace("/upload/","/upload/fl_attachment/"):e}const Av="https://api.studioe.ai",$v=20,K0=5e3,W0=e=>(e==null?void 0:e.status)==="processing"||(e==null?void 0:e.status)==="pending";function _v(e,n=Date.now()){const r=(e||[]).filter(W0);if(!r.length)return null;const s=Math.max(...r.map(a=>Date.parse(a.createdAt)||n)),o=n-s;return o<2*6e4?K0:o<10*6e4?1e4:3e4}const Dv=(e,n)=>{const r=new Date(n.createdAt).getTime()-new Date(e.createdAt).getTime();return r||(e.id<n.id?1:e.id>n.id?-1:0)};function eu(e,n){return!(n!=null&&n.size)||!Array.isArray(e)?e:e.flatMap(r=>{const s=(r.outputs||[]).filter(o=>!n.has(o.id));return!n.has(r.id)&&s.length===(r.outputs||[]).length?[r]:s.length?[{...r,...n.has(r.id)?{id:s[0].id}:{},outputs:s}]:[]})}function oc(e,n){if(!Array.isArray(n)||!n.length)return e;const r=new Map(e.map(s=>[s.id,s]));for(const s of n){const o=r.get(s.id);r.set(s.id,o?{...o,...s,inputs:s.inputs??o.inputs,prompt:s.prompt??o.prompt}:s)}return[...r.values()].sort(Dv)}function Lv({enabled:e,owner:n=null}){const[r,s]=i.useState([]),[o,a]=i.useState("idle"),[l,c]=i.useState(!1),[u,d]=i.useState(!1),h=i.useRef(null),p=i.useRef(n);p.current=n;const[b,y]=i.useState(n),v=i.useRef(new Set);b!==n&&(y(n),v.current=new Set,s([]),a("idle"),c(!1),d(!1),h.current=null);const w=i.useRef(!0);i.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const C=i.useCallback(F=>Jt(`${Av}/api/creatify/asset-history`,{limit:$v,...F?{before:F}:{}}),[]),k=i.useCallback(async()=>{const F=p.current;a(R=>R==="ready"?R:"loading");try{const R=await C(null);if(!w.current||p.current!==F)return;if(!(R!=null&&R.ok))throw new Error((R==null?void 0:R.error)||"history");s(A=>oc(A,eu(R.runs||[],v.current))),(!h.current||!R.hasMore)&&(h.current=R.nextBefore||null,c(!!R.hasMore)),a("ready")}catch{w.current&&p.current===F&&a(R=>R==="ready"?R:"error")}},[C]);i.useEffect(()=>{e&&k()},[e,k,n]);const E=r.some(W0),m=i.useRef(r);m.current=r,i.useEffect(()=>{if(!e||!E)return;let F=null,R=!1;const A=()=>typeof document<"u"&&document.hidden,V=()=>{R||H()},z=()=>{R||(A()?document.addEventListener("visibilitychange",V,{once:!0}):F=setTimeout(H,_v(m.current)||K0))},H=async()=>{if(R)return;if(A())return z();const ne=p.current;try{const se=await C(null);w.current&&!R&&p.current===ne&&(se!=null&&se.ok)&&s(pe=>oc(pe,eu(se.runs||[],v.current)))}catch{}z()};return z(),()=>{R=!0,clearTimeout(F),typeof document<"u"&&document.removeEventListener("visibilitychange",V)}},[e,E,C]);const M=i.useCallback(async()=>{if(!h.current||u)return!0;const F=p.current;d(!0);try{const R=await C(h.current);if(!w.current||p.current!==F)return!0;if(!(R!=null&&R.ok))throw new Error("more");return s(A=>oc(A,eu(R.runs||[],v.current))),h.current=R.nextBefore||null,c(!!R.hasMore),!0}catch{return!1}finally{w.current&&d(!1)}},[C,u]),I=i.useCallback(F=>s(R=>oc(R,[F])),[]),N=i.useCallback(F=>{v.current.add(F),s(R=>R.flatMap(A=>{var z;if(!((z=A.outputs)!=null&&z.some(H=>H.id===F))&&A.id!==F)return[A];const V=(A.outputs||[]).filter(H=>H.id!==F);return V.length?[{...A,...A.id===F?{id:V[0].id}:{},outputs:V}]:[]}))},[]);return{runs:r,status:o,hasMore:l,loadingMore:u,load:k,loadMore:M,addRun:I,forget:N}}const Ov=/music|song|lyria|musicgen|ace-step|stable-audio|diffrhythm|beatoven|suno|\budio\b/i,Vv=/tts|speech|voice|dialogue|kokoro|\bdia\b|orpheus|chatterbox|minimax-speech|playai|f5-tts/i;function Uv(e="",n=""){return n==="music"||Ov.test(e||"")?"music":n==="tts"||Vv.test(e||"")?"voice":"sound"}const zv=24*60*60*1e3,xf=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function Bv(e,n=new Date){const r=new Date(e);if(Number.isNaN(r.getTime()))return"Earlier";const s=Math.round((xf(n)-xf(r))/zv);return s<=0?"Today":s===1?"Yesterday":s<7?"Previous 7 days":s<30?"Previous 30 days":r.toLocaleDateString(void 0,{month:"long",year:"numeric"})}function Hv(e,n=new Date){const r=[];for(const s of e){const o=Bv(s.createdAt,n),a=r[r.length-1];a&&a.label===o?a.runs.push(s):r.push({label:o,runs:[s]})}return r}const Kv=e=>(e==null?void 0:e.status)==="processing"||(e==null?void 0:e.status)==="pending",Wv={music:oi,voice:Fl,sound:_i};function Yv(e,n=640){return!e||typeof e!="string"?null:Fb(e,[`w_${n},c_limit,q_auto,f_auto`])||e}function Gv({run:e}){const r=(e.outputs||[]).find(a=>a.resultUrl)||null;if(Kv(e))return t.jsxs("div",{className:"absolute inset-0 grid place-items-center bg-gradient-to-br from-violet-500/15 via-white/[0.03] to-fuchsia-500/10",children:[t.jsx("div",{className:"absolute inset-0 animate-pulse bg-white/[0.03]"}),t.jsxs("div",{className:"relative flex flex-col items-center gap-2 text-violet-200",children:[t.jsx("span",{className:"w-9 h-9 rounded-full border-2 border-violet-300/30 border-t-violet-200 animate-spin"}),t.jsx("span",{className:"text-[11px] font-medium",children:"Generatingâ¦"})]})]});if(e.status==="failed"||!r)return t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-1.5 px-3 text-center bg-white/[0.02]",children:[t.jsx(Xs,{className:"w-5 h-5 text-amber-300/80"}),t.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:"Didn't finish"}),e.refunded&&t.jsx("span",{className:"text-[10px] text-emerald-300/80",children:"Credits given back"})]});const s=r.mediaType||e.mediaType;if(s==="audio"){const a=Wv[Uv(e.modelName||"")]||oi;return t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-gradient-to-br from-violet-600/30 via-[#151726] to-fuchsia-600/20",children:[t.jsx("span",{className:"w-12 h-12 rounded-2xl grid place-items-center bg-white/10 ring-1 ring-white/15",children:t.jsx(a,{className:"w-5 h-5 text-white"})}
9),t.jsx("span",{"aria-hidden":!0,className:"flex items-end gap-[3px] h-5",children:[40,75,55,100,65,85,45,70,35].map((l,c)=>t.jsx("span",{className:"w-[3px] rounded-full bg-white/50",style:{height:`${l}%`}},c))})]})}const o=s==="video"?r.thumbnailUrl||Pm(r.resultUrl,{width:640}):Yv(r.resultUrl);return t.jsxs(t.Fragment,{children:[o?t.jsx("img",{src:o,alt:"",loading:"lazy",decoding:"async",className:"absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-[1.03]"}):t.jsx("div",{className:"absolute inset-0 grid place-items-center bg-white/[0.03]",children:t.jsx($s,{className:"w-6 h-6 text-gray-500"})}),s==="video"&&t.jsx("span",{className:"absolute top-2 left-2 w-7 h-7 rounded-full grid place-items-center bg-black/55 backdrop-blur-sm",children:t.jsx(Ta,{className:"w-3.5 h-3.5 text-white translate-x-[1px]"})})]})}function qv({run:e,active:n,onOpen:r}){const s=(e.outputs||[]).filter(o=>o.resultUrl).length;return t.jsxs("button",{type:"button","data-history-run":e.id,"aria-current":n?"true":void 0,onClick:()=>r(e),"aria-label":e.prompt||e.modelLabel||"Open this generation",className:`group relative aspect-square w-full overflow-hidden rounded-2xl border bg-[#0E1117] text-left outline-none transition focus-visible:ring-2 focus-visible:ring-violet-400/70 ${n?"border-violet-400/70 ring-2 ring-violet-500/30":"border-white/[0.08] hover:border-white/25"}`,children:[t.jsx(Gv,{run:e}),s>1&&t.jsx("span",{className:"absolute top-2 right-2 h-6 min-w-6 px-1.5 rounded-full grid place-items-center bg-black/60 backdrop-blur-sm text-[11px] font-semibold text-white tabular-nums",children:s}),t.jsxs("span",{className:"absolute inset-x-0 bottom-0 p-2.5 pt-8 bg-gradient-to-t from-black/85 via-black/45 to-transparent opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 [@media(hover:none)]:opacity-100",children:[t.jsx("span",{className:"block text-[12px] leading-snug text-white line-clamp-2 [@media(hover:none)]:hidden",children:e.prompt||e.modelLabel}),t.jsx("span",{className:"block mt-0.5 text-[10px] text-white/60 truncate",children:e.modelLabel})]})]})}const Xv=[{x:128,rotate:"-rotate-[8deg]",shift:"translate-y-2"},{x:394,rotate:"rotate-0",shift:"-translate-y-1 z-10"},{x:660,rotate:"rotate-[8deg]",shift:"translate-y-2"}],Y0=88,ac=Y0/235;function gf({examples:e=[],onExample:n}){return t.jsxs("div",{className:"flex flex-col items-center text-center px-4 py-6","data-asset-empty":!0,children:[t.jsx("div",{className:"flex items-end justify-center -space-x-3 mb-6","aria-hidden":!0,children:Xv.map(r=>t.jsx("span",{className:`relative block rounded-2xl ring-1 ring-white/15 shadow-[0_18px_40px_-14px_rgba(0,0,0,0.9)] ${r.rotate} ${r.shift}`,style:{width:Y0,height:Math.round(299*ac),backgroundImage:"url(/workflow-tools/asset-gen.webp)",backgroundSize:`${Math.round(1024*ac)}px auto`,backgroundPosition:`-${Math.round(r.x*ac)}px -${Math.round(138*ac)}px`}},r.x))}),t.jsxs("h2",{className:"text-2xl sm:text-[32px] leading-tight font-semibold tracking-tight text-white",children:["Create anything with"," ",t.jsx("span",{className:"bg-gradient-to-r from-violet-300 via-fuchsia-300 to-amber-200 bg-clip-text text-transparent",children:"any model"})]}),t.jsx("p",{className:"mt-2 max-w-md text-sm leading-relaxed text-gray-400",children:"Hundreds of image, video and audio models in one place. Describe it below, and everything you make shows up here."}),n&&e.length>0&&t.jsx("div",{className:"mt-6 flex flex-wrap justify-center gap-2 max-w-2xl",children:e.map(r=>t.jsxs("button",{type:"button",onClick:()=>n(r),className:"inline-flex items-center gap-1.5 px-3.5 py-2 rounded-full border border-white/10 bg-white/[0.04] text-[12px] text-gray-300 hover:text-white hover:bg-white/[0.08] hover:border-white/20 transition",children:[t.jsx(Ao,{className:"w-3.5 h-3.5 text-violet-300 shrink-0"}),t.jsx("span",{className:"text-left",children:r})]},r))})]})}const bf=[{value:"all",label:"All"},{value:"image",label:"Images"},{value:"video",label:"Videos"},{value:"audio",label:"Audio"}];function Jv({runs:e,status:n,hasMore:r,loadingMore:s,activeId:o,onOpen:a,onLoadMore:l,onRetry:c,empty:u=null}){var F;const[d,h]=i.useState("all"),p=e||[],b=g0(),{auto:y,pause:v}=b,w=i.useRef({});w.current={hasMore:r,loadingMore:s,onLoadMore:l};const C=i.useCallback(async()=>{var A,V;await((V=(A=w.current).onLoadMore)==null?void 0:V.call(A))===!1&&v()},[v]),k=i.useRef(null),E=i.useRef(null),m=i.useCallback(()=>{const R=E.current;if(!(R!=null&&R.isConnected))return!1;const A=R.getBoundingClientRect();return!A.width&&!A.height?!1:A.top<window.innerHeight+600&&A.bottom>-600},[]),M=i.useCallback(()=>y({ready:()=>w.current.hasMore&&!w.current.loadingMore,load:C,inReach:m}),[y,C,m]),I=i.useCallback(R=>{var A;(A=k.current)==null||A.disconnect(),k.current=null,E.current=R,!(!R||typeof IntersectionObserver>
9"u")&&(k.current=new IntersectionObserver(V=>{var z;(z=V[0])!=null&&z.isIntersecting&&M()},{rootMargin:"600px 0px"}),k.current.observe(R))},[M]);if(i.useEffect(()=>()=>{var R;return(R=k.current)==null?void 0:R.disconnect()},[]),i.useEffect(()=>{r&&!s&&m()&&M()},[p.length,d,r,s,m,M]),!p.length)return n==="loading"||n==="idle"?t.jsx("div",{"data-asset-gallery":!0,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 2xl:grid-cols-6 gap-2 sm:gap-3",children:Array.from({length:8},(R,A)=>t.jsx("div",{className:"aspect-square rounded-2xl bg-white/[0.04] animate-pulse"},A))}):n==="error"?t.jsxs("div",{"data-asset-gallery":!0,className:"flex flex-col items-center gap-3 py-12 text-center",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Your generations couldn't be loaded."}),t.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1.5 h-9 px-4 rounded-full bg-white/[0.08] border border-white/15 text-xs font-semibold text-white hover:bg-white/[0.14] transition",children:[t.jsx(fo,{className:"w-3.5 h-3.5"})," Try again"]})]}):t.jsx("div",{"data-asset-gallery":!0,children:u});const N=d==="all"?p:p.filter(R=>(R.mediaType||"image")===d);return t.jsxs("div",{"data-asset-gallery":!0,children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[t.jsx("h2",{className:"text-sm font-semibold text-white",children:"Your generations"}),t.jsx("div",{role:"tablist","aria-label":"Show",className:"inline-flex items-center gap-0.5 p-0.5 rounded-full border border-white/10 bg-white/[0.03]",children:bf.map(R=>t.jsx("button",{type:"button",role:"tab","aria-selected":d===R.value,"data-gallery-filter":R.value,onClick:()=>h(R.value),className:`h-7 px-3 rounded-full text-[12px] font-medium transition ${d===R.value?"bg-white text-black":"text-gray-400 hover:text-white"}`,children:R.label},R.value))})]}),!N.length&&t.jsxs("p",{className:"py-10 text-center text-sm text-gray-500",children:["No ",(F=bf.find(R=>R.value===d))==null?void 0:F.label.toLowerCase()," here yet."]}),t.jsx("div",{className:"space-y-6",children:Hv(N).map(R=>t.jsxs("section",{children:[t.jsx("h3",{className:"mb-2.5 text-[11px] font-semibold uppercase tracking-wider text-gray-500",children:R.label}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 2xl:grid-cols-6 gap-2 sm:gap-3",children:R.runs.map(A=>t.jsx(qv,{run:A,active:A.id===o,onOpen:a},A.id))})]},R.label))}),r&&t.jsx("div",{ref:I,className:"flex justify-center mt-6 min-h-9",children:b.paused&&!s?t.jsx("button",{type:"button",onClick:()=>b.resume(C),className:"inline-flex items-center gap-1.5 h-9 px-5 rounded-full bg-white/[0.06] border border-white/10 text-xs font-semibold text-gray-200 hover:text-white hover:bg-white/[0.1] transition",children:"Load more"}):s?t.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-gray-500",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full border-2 border-white/20 border-t-white/70 animate-spin"}),"Loading more"]}):null})]})}function G0({open:e,onClose:n,title:r,subtitle:s=null,icon:o=null,footer:a=null,keepMounted:l=!1,zClassName:c="z-[9997]",widthClassName:u="sm:w-[400px]",closeOnEscape:d=!0,children:h,...p}){const[b,y]=i.useState(e),[v,w]=i.useState(!1),C=i.useRef(null),k=i.useRef(n);k.current=n;const E=i.useRef(d);return E.current=d,i.useEffect(()=>{if(e){y(!0);return}w(!1);const m=setTimeout(()=>y(!1),Wd);return()=>clearTimeout(m)},[e]),i.useLayoutEffect(()=>{var m;!e||!b||v||((m=C.current)==null||m.getBoundingClientRect(),w(!0))},[e,b,v]),i.useEffect(()=>{if(!e)return;const m=I=>{var N;I.key==="Escape"&&E.current&&((N=k.current)==null||N.call(k))};window.addEventListener("keydown",m);const M=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",m),document.body.style.overflow=M}},[e]),!b&&!l?null:Un.createPortal(t.jsxs("div",{className:`fixed inset-0 ${c} ${b?"":"hidden"}`,role:"dialog","aria-modal":"true","aria-label":typeof r=="string"?r:void 0,"data-slide-panel":v?"open":"closed",style:{pointerEvents:v?"auto":"none"},...p,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm motion-reduce:!transition-none",style:{opacity:v?1:0,transition:`opacity ${Wd}ms ${Kp}`},onClick:n,"aria-hidden":"true"}),t.jsxs("div",{ref:C,className:`absolute flex flex-col bg-[#16181A] border-white/10 shadow-2xl motion-reduce:!transition-none 10 inset-x-0 bottom-0 max-h-[85vh] rounded-t-2xl border-t 11 sm:inset-x-auto sm:right-0 sm:top-0 sm:bottom-0 sm:max-h-none ${u} sm:rounded-t-none sm:rounded-l-2xl sm:border-t-0 sm:border-l 12 ${v?"translate-y-0 sm:translate-x-0":"translate-y-full sm:translate-y-0 sm:translate-x-full"}`,style:{transition:`transform ${Wd}ms ${Kp}`},children:[t.jsx("div",{className:"sm:hidden flex justify-center pt-2.5","aria-hidden":"true",children:t.jsx("div",{className:"w-10 h-1 rounded-full bg-white/20"})}),t.jsxs("header",{className:"shrink-0 flex items-center gap-3 px-5 pt-3 pb-3 sm:pt-5 border-b border-white/10",children:[o&&t.jsx("span",{className:"w-9 h-9 shrink-0 rounded-xl grid place-items-center bg-white/[0.06] border border-white/10",children:o}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold text-white",children:r}),s&&t.jsx("p",{className:"text-[11px] text-gray-500 truncate",children:s})]}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"w-9 h-9 grid place-items-center rounded-full text-gray-400 hover:text-white hover:bg-white/[0.06] transition",children:t.jsx(ft,{className:"w-4 h-4"})})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overscroll-contain px-5 py-4",children:h}),a&&t.jsx("div",{className:"shrink-0 px-5 py-4 border-t border-white/10",children:a})]})]}),document.body)}function Zv({checking:e=!1,favoritedCount:n=0,collections:r=[]}
12){if(e)return t.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[t.jsx("div",{className:"w-3.5 h-3.5 border-2 border-white/20 border-t-white/70 rounded-full animate-spin"}),"Checking favourites and collectionsâ¦"]});const s=r.length;return!n&&!s?null:t.jsxs("div",{className:"space-y-3",children:[n>0&&t.jsx("div",{className:"rounded-xl border border-pink-400/30 bg-pink-500/10 p-3",children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx(Nl,{className:"w-4 h-4 text-pink-400 flex-shrink-0 mt-0.5",fill:"currentColor"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed text-pink-100/90",children:[t.jsx("span",{className:"font-semibold text-pink-200",children:"In your Favourites:"})," this is saved in your Favourites. Deleting removes it from there too."]})]})}),s>0&&t.jsx("div",{className:"rounded-xl border border-blue-400/30 bg-blue-500/10 p-3",children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx(zi,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed text-blue-100/90",children:[t.jsx("span",{className:"font-semibold text-blue-200",children:"In your Collections:"})," this appears in"," ",s," collection",s===1?"":"s",t.jsxs("span",{className:"text-blue-200/80",children:[" (",r.slice(0,3).map(o=>o.name).join(", "),s>3?`, +${s-3} more`:"",")"]}),". Deleting removes it from ",s===1?"it":"them"," too."]})]})})]})}const Qv=/^[a-z][a-z0-9_]{0,31}$/;function e1(e){if(!e||typeof e!="object")return null;const n=Dl(e.kind,["model","custom"],null),r=typeof e.id=="string"?e.id.slice(0,128):"";return!n||!r?null:{kind:n,id:r,name:Mr(e.name,80),gender:Mr(e.gender,16),imageUrl:_l(e.imageUrl)||"",ready:e.ready!==!1}}function t1(e){const n={};if(!e||typeof e!="object")return n;for(const[r,s]of Object.entries(e).slice(0,12)){if(!Qv.test(r))continue;const o=qc(s,8);o.length&&(n[r]=o)}return n}function q0(e){const n={owner:Xc(e.owner),jobId:Xc(e.jobId),jobTitle:Mr(e.jobTitle,120),mode:Dl(e.mode,["create","clone"],"create"),productUrls:qc(e.productUrls,12),refImages:t1(e.refImages),productName:Mr(e.productName,200),productDetails:Mr(e.productDetails,4e3),styleKey:Mr(e.styleKey,120),creator:e1(e.creator),modelTab:Dl(e.modelTab,["models","mine"],"models"),aspect:/^\d{1,2}x\d{1,2}$/.test(e.aspect)?e.aspect:"9x16",resolution:/^\d{3,4}p$/.test(e.resolution)?e.resolution:"720p",duration:Ac(e.duration,{min:1,max:120,fallback:12}),audioMode:Mr(e.audioMode,24)||"off",voiceMode:Mr(e.voiceMode,24)||"native",voice:Mr(e.voice,64)||"Rachel",wantCaptions:e.wantCaptions!==!1,batchCount:Ac(e.batchCount,{min:1,max:10,fallback:1}),industry:Mr(e.industry,400),targetAudience:Mr(e.targetAudience,1e3),painPoints:Mr(e.painPoints,2e3),desiredOutcome:Mr(e.desiredOutcome,2e3),emotionalTriggers:Mr(e.emotionalTriggers,1e3),cta:Mr(e.cta,400),tone:Mr(e.tone,200),sourceUrl:_l(e.sourceUrl)||"",sourceDuration:Ac(e.sourceDuration,{min:0,max:3600,fallback:0})};return n1(n)?n:null}function n1(e){var n,r,s,o,a,l,c,u;return e?!!(e.jobId||(n=e.productUrls)!=null&&n.length||Object.keys(e.refImages||{}).length||e.styleKey||e.creator||e.sourceUrl||(r=e.productName)!=null&&r.trim()||(s=e.productDetails)!=null&&s.trim()||(o=e.industry)!=null&&o.trim()||(a=e.targetAudience)!=null&&a.trim()||(l=e.painPoints)!=null&&l.trim()||(c=e.desiredOutcome)!=null&&c.trim()||(u=e.cta)!=null&&u.trim()):!1}function yf(e){var r,s;const n={product:e.productUrls||[],...e.refImages||{}};return{id:`draft:${e.ts}`,mode:e.mode,productAssets:n,productImageUrls:e.productUrls||[],productName:e.productName,productDetails:e.productDetails,styleKey:e.styleKey,sourceVideoUrl:e.sourceUrl,sourceDurationSeconds:e.sourceDuration,aspectRatio:e.aspect,videoResolution:e.resolution,durationSeconds:e.duration,audioMode:e.audioMode,voiceMode:e.voiceMode,voice:e.voice,wantCaptions:e.wantCaptions,batchCount:e.batchCount,industry:e.industry,targetAudience:e.targetAudience,painPoints:e.painPoints,desiredOutcome:e.desiredOutcome,emotionalTriggers:e.emotionalTriggers,cta:e.cta,tone:e.tone,...((r=e.creator)==null?void 0:r.kind)==="model"?{creatorChoice:"model",creatorModelId:e.creator.id,avatarName:e.creator.name,avatarGender:e.creator.gender,creatorImageUrl:e.creator.imageUrl}:((s=e.creator)==null?void 0:s.kind)==="custom"?{creatorChoice:"custom",customModelId:e.creator.id,avatarName:e.creator.name,avatarGender:e.creator.gender,creatorImageUrl:e.creator.imageUrl}:{}}}const Ma=N0({name:"ugcStudioSession",sanitize:q0});function td({title:e,children:n,buttonLabel:r="Get Started For Free",onClick:s,note:o="",className:a="",...l}){return t.jsxs("div",{className:`rounded-xl border border-white/10 bg-[#1a1a1f] p-4 space-y-3 ${a}`,...l,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Qb,{className:"w-4 h-4 text-blue-400 shrink-0"}),t.jsx("p",{className:"text-sm font-semibold text-white",children:e})]}),n?t.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:n}):null,t.jsx("button",{type:"button",onClick:s,className:"w-full px-4 py-3 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-sm font-semibold text-white transition-colors text-center",children:r}),o?t.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-1",children:[t.jsx("svg",{className:"w-3.5 h-3.5 text-amber-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),t.jsx("span",{className:"text-[12px] text-amber-400/90 font-medium",children:o})]}):null]})}const vf="studioe_static_ads_v1";function X0(e){const n={owner:Xc(e.owner),jobId:Xc(e.jobId),mode:Dl(e.mode,["manual","url"],"manual"),productUrl:_l(e.productUrl)||"",productUrls:qc(e.productUrls,6),extractedImages:qc(e.extractedImages,24),productName:Mr(e.productName,200),productDescription:Mr(e.productDescription,4e3),keyPoints:Mr(e.keyPoints,4e3),brandUrl:_l(e.brandUrl)||"",format:Dl(e.format,["square","portrait","both"],"square"),count:Ac(e.count,{min:1,max:40,fallback:20})};return r1(n)?n:null}function r1(e){var n,r,s,o;return e?!!(e.jobId||(n=e.productUrls)!=null&&n.length||e.productUrl||(r=e.productName)!=null&&r.trim()||(s=e.productDescription)!=null&&s.trim()||(o=e.keyPoints)!=null&&o.trim()||e.brandUrl):!1}const Ho=N0({name:"staticAdsSession",sanitize:X0});function s1(){let e=null;try{e=JSON.parse(localStorage.getItem(vf)||"null"),localStorage.removeItem(vf)}catch{e=null}e&&typeof e=="object"&&!Ho.readPlain()&&Ho.write(e)}const o1=["px","in","cm","mm"],a1=[{category:"Social",presets:[{label:"FB Page Cover",width:1640,height:664,unit:"px"},{label:"FB Event Image",width:1920,height:1080,unit:"px"},{label:"FB Group Header",width:1640,height:856,unit:"px"},{label:"Instagram",width:1080,height:1080,unit:"px"},{label:"Insta Story",width:1080,height:1920,unit:"px"},{label:"Insta Portrait",width:1080,height:1350,unit:"px"},{label:"YouTube Thumbnail",width:1280,height:720,unit:"px"},{label:"YouTube Profile",width:800,height:800,unit:"px"},{label:"YouTube Cover",width:2560,height:1440,unit:"px"},{label:"Twitter Profile",width:400,height:400,unit:"px"},{label:"Twitter Header",width:1500,height:500,unit:"px"}]},{category:"Print",presets:[{label:"A3",width:297,height:420,unit:"mm",dpi:300},{label:"A4",width:210,height:297,unit:"mm",dpi:300},{label:"A5",width:148,height:210,unit:"mm",dpi:300},{label:"A6",width:105,height:148,unit:"mm",dpi:300},{label:"B3",width:353,height:500,unit:"mm",dpi:300},{label:"B4",width:250,height:353,unit:"mm",dpi:300},{label:"B5",width:176,height:250,unit:"mm",dpi:300},{label:"Letter",width:8.5,height:11,unit:"in",dpi:300},{label:"Ledger",width:11,height:17,unit:"in",dpi:300},{label:"Business Card",width:3.5,height:2,unit:"in",dpi:300}]},{category:"Photo",presets:[{label:"Wallet",width:2,height:3,unit:"in",dpi:300},{label:"Enprint",width:3.5,height:5,unit:"in",dpi:300},{label:'5 à 7"',width:5,height:7,unit:"in",dpi:300},{label:'8 à 12"',width:8,height:12,unit:"in",dpi:300},{label:'12 à 18"',width:12,height:18,unit:"in",dpi:300},{label:'16 à 24"',width:16,height:24,unit:"in",dpi:300},{label:'20 à 30"',width:20,height:30,unit:"in",dpi:300},{label:'24 à 36"',width:24,height:36,unit:"in",dpi:300}]},{category:"Screen",presets:[{label:"VGA",width:640,height:480,unit:"px"},{label:"XGA",width:1024,height:768,unit:"px"},{label:"HD",width:1280,height:720,unit:"px"},{label:"WXGA",width:1366,height:768,unit:"px"},{label:"HD+",width:1600,height:900,unit:"px"},{label:"Full HD",width:1920,height:1080,unit:"px"},{label:"2K",width:2048,height:1080,unit:"px"},{label:"UHD",width:3840,height:2160,unit:"px"},{label:"4K",width:4096,height:2160,unit:"px"}]},{category:"Mobile",presets:[{label:"iPhone SE",width:640,height:1136,unit:"px"},{label:"iPhone 8",width:750,height:1334,unit:"px"},{label:"iPhone 8 Plus",width:1080,height:1920,unit:"px"},{label:"iPhone X / 11+",width:1125,height:2436,unit:"px"},{label:"Pixel / Galaxy",width:1080,height:1920,unit:"px"},{label:"Galaxy S6+",width:1440,height:2560,unit:"px"},{label:'iPad 9.7"',width:1536,height:2048,unit:"px"},{label:'iPad Pro 10.5"',width:1668,height:2224,unit:"px"},{label:'iPad Pro 12.9"',width:2048,height:2732,unit:"px"}]},{category:"Ads",presets:[{label:"Small Square",width:200,height:200,unit:"px"},{label:"Square",width:250,height:250,unit:"px"},{label:"Medium Rect",width:300,height:250,unit:"px"},{label:"Large Rect",width:336,height:280,unit:"px"},{label:"Mobile Leaderboard",width:320,height:50,unit:"px"},{label:"Large Mobile",width:320,height:100,unit:"px"},{label:"Banner",width:468,height:60,unit:"px"},{label:"Leaderboard",width:728,height:90,unit:"px"},{label:"Large Leaderboard",width:970,height:90,unit:"px"},{label:"Billboard",width:970,height:250,unit:"px"},{label:"Skyscraper",width:120,height:600,unit:"px"},{label:"Wide Skyscraper",width:160,height:600,unit:"px"},{label:"Half Page",width:300,height:600,unit:"px"}]},{category:"2â¿",presets:[{label:"16²",width:16,height:16,unit:"px"},{label:"32²",width:32,height:32,unit:"px"},{label:"64²",width:64,height:64,unit:"px"},{label:"128²",width:128,height:128,unit:"px"},{label:"256²",width:256,height:256,unit:"px"},{label:"512²",width:512,height:512,unit:"px"},{label:"1024²",width:1024,height:1024,unit:"px"},{label:"2048²",width:2048,height:2048,unit:"px"},{label:"4096²",width:4096,height:4096,unit:"px"}]}],i1=[23.976,24,25,29.97,30,50,60],l1=[{group:"Social Vertical (9:16)",presets:[{label:"TikTok / Reels / Shorts",
12width:1080,height:1920,aspect:"9:16",fps:30,use:"Full-screen vertical short-form â the most common UGC/ad export."},{label:"Reels / Shorts · 60fps",width:1080,height:1920,aspect:"9:16",fps:60,use:"Vertical short-form with smoother motion / slow-mo headroom."},{label:"Vertical HD (720)",width:720,height:1280,aspect:"9:16",fps:30,use:"Lightweight vertical for fast previews or low-bandwidth delivery."},{label:"Vertical 4K",width:2160,height:3840,aspect:"9:16",fps:30,use:"High-res vertical master with reframe headroom."}]},{group:"Social Square & Portrait",presets:[{label:"Instagram Square",width:1080,height:1080,aspect:"1:1",fps:30,use:"Square feed posts â safe crop on any platform."},{label:"Instagram Portrait (4:5)",width:1080,height:1350,aspect:"4:5",fps:30,use:"Tallest in-feed ratio â best-performing feed post."},{label:"Pinterest 2:3",width:1e3,height:1500,aspect:"2:3",fps:30,use:"Pinterest Idea Pins and 2:3 vertical placements."}]},{group:"Standard / Web (16:9)",presets:[{label:"YouTube 1080p (Full HD)",width:1920,height:1080,aspect:"16:9",fps:30,use:"The universal HD deliverable â YouTube, embeds, landscape feeds."},{label:"1080p · 24fps (Cine)",width:1920,height:1080,aspect:"16:9",fps:24,use:"1080p with a filmic 24fps cadence for branded/narrative content."},{label:"1080p · 60fps",width:1920,height:1080,aspect:"16:9",fps:60,use:"Gaming, sports, screen-capture and high-motion content."},{label:"720p (HD)",width:1280,height:720,aspect:"16:9",fps:30,use:"Lightweight HD for fast uploads or proxy timelines."},{label:"1440p (QHD)",width:2560,height:1440,aspect:"16:9",fps:30,use:"Sharper than 1080p, lighter than 4K â tutorials, screen recordings."},{label:"YouTube 4K (UHD)",width:3840,height:2160,aspect:"16:9",fps:30,use:"4K horizontal master with reframe/crop headroom."},{label:"4K · 60fps",width:3840,height:2160,aspect:"16:9",fps:60,use:"4K high-motion â gaming, sports, action."}]},{group:"Cinema / Wide",presets:[{label:"DCI 2K (Flat 1.85)",width:1998,height:1080,aspect:"1.85:1",fps:24,use:"Theatrical 'flat' 2K at 24fps."},{label:"Cinemascope 2.39 (1080)",width:1920,height:803,aspect:"2.39:1",fps:24,use:"Anamorphic 'scope' widescreen â trailers, film-look spots."},{label:"DCI 4K (Scope 2.39)",width:4096,height:1716,aspect:"2.39:1",fps:24,use:"True DCI 4K cinemascope master for high-end delivery."},{label:"Ultrawide 21:9",width:2560,height:1080,aspect:"21:9",fps:30,use:"Ultrawide monitor / immersive web hero video, signage."}]},{group:"Broadcast (PAL / NTSC)",presets:[{label:"1080p25 (PAL / EU)",width:1920,height:1080,aspect:"16:9",fps:25,use:"European/PAL broadcast â 25fps avoids 50Hz flicker."},{label:"1080p50 (PAL motion)",width:1920,height:1080,aspect:"16:9",fps:50,use:"PAL high-motion (sports/live) at 50fps."},{label:"1080p23.976 (NTSC film)",width:1920,height:1080,aspect:"16:9",fps:23.976,use:"NTSC film cadence for cinematic US broadcast/streaming."},{label:"1080p29.97 (NTSC)",width:1920,height:1080,aspect:"16:9",fps:29.97,use:"NTSC (US/Japan) broadcast standard frame rate."}]}],c1={"Social Vertical (9:16)":15,"Social Square & Portrait":15,"Standard / Web (16:9)":30,"Cinema / Wide":30,"Broadcast (PAL / NTSC)":30},d1=["RGB","Grayscale"],u1=[8,16],m1=["sRGB","Display P3","Adobe RGB"],tu=[{key:"white",label:"White",color:"#ffffff"},{key:"black",label:"Black",color:"#000000"},{key:"transparent",label:"Transparent",color:null},{key:"custom",label:"Custom",color:"#7c3aed"}];function ic(e,n,r=72){const s=Number(e)||0;switch(n){case"in":return Math.round(s*r);case"cm":return Math.round(s*r/2.54);case"mm":return Math.round(s*r/25.4);default:return Math.round(s)}}function p1(e,n){if(!e||!n)return"";const r=(o,a)=>a?r(a,o%a):o,s=r(Math.round(e),Math.round(n))||1;return`${Math.round(e/s)}:${Math.round(n/s)}`}function f1({mode:e="image",open:n,onClose:r,onCreate:s,initial:o}){var xt;const a=e==="video",l=a?l1:a1,[c,u]=i.useState(0),[d,h]=i.useState(""),[p,b]=i.useState(1080),[y,v]=i.useState(1080),[w,C]=i.useState("px"),[k,E]=i.useState(72),[m,M]=i.useState("RGB"),[I,N]=i.useState(8),[F,R]=i.useState("sRGB"),[A,V]=i.useState(30),[z,H]=i.useState(15),[ne,se]=i.useState("white"),[pe,ie]=i.useState("#7c3aed"),[O,D]=i.useState(!0),[W,oe]=i.useState("");i.useEffect(()=>{n&&(u(0),oe(""),a?(h("Untitled Composition"),b(1080),v(1920),C("px"),V(30),H(15),se("black"),D(!0)):(h("New Project"),b((o==null?void 0:o.width)||1080),v((o==null?void 0:o.height)||1080),C("px"),E(72),M("RGB"),N(8),R("sRGB"),se("white")),ie("#7c3aed"))},[n,a,o]);const we=a?Math.round(p):ic(p,w,k),Re=a?Math.round(y):ic(y,w,k),le=p1(we,Re),Ne=i.useMemo(()=>{const Ie=we&&Re?Math.min(168/we,168/Re,1):1,ht=Math.max(8,Math.round(we*Ie)),Et=Math.max(8,Math.round(Re*Ie));return{w:Number.isFinite(ht)?ht:80,h:Number.isFinite(Et)?Et:80}},[we,Re]);if(!n)return null;const ce=tu.find(J=>J.key===ne)||tu[0],Ae=ne==="custom"?pe:ce.color,De=(J,Ie)=>{oe(J.label),a?(b(J.width),v(J.height),V(J.fps),H(c1[Ie]??z)):(b(J.width),v(J.height),C(J.unit),E(J.dpi||72))},Ze=()=>{b(y),v(p),oe("")},Ye=J=>{const Ie=Number(J);oe(""),b(J),a&&O&&Number.isFinite(Ie)&&we&&v(Math.round(Ie*(y/p)))},at=J=>{const Ie=Number(J);oe(""),v(J),a&&O&&Number.isFinite(Ie)&&Re&&b(Math.round(Ie*(p/y)))},ut=()=>{if(!we||!Re)return;const J=ne==="transparent"?"transparent":Ae||"#ffffff";s(a?{name:d.trim()||"Untitled Composition",width:we,height:Re,fps:Number(A)||30,durationInFrames:Math.max(1,Math.round((Number(z)||1)*(Number(A)||30))),background:J}:{name:d.trim()||"New Project",width:we,height:Re,background:J,mode:m,bitDepth:I,profile:F,dpi:Number(k)||72,unit:w})},Xe="w-full rounded-lg bg-[#16181A] border border-white/10 px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-violet-500/50 focus:border-violet-500/50 transition",nt="block text-[11px] font-medium text-gray-400 mb-1";return Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[80] grid place-items-center bg-black/60 backdrop-blur-sm p-4",onMouseDown:J=>{J.target===J.currentTarget&&r()},children:t.jsxs("div",{className:"modal-pop-in w-full max-w-[940px] max-h-[90vh] flex flex-col rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-white/10",children:[t.jsxs("h2",{className:"text-sm font-semibold text-white",children:["New ",a?"video composition":"project"]}),t.jsx("button",{type:"button",onClick:r,className:"w-8 h-8 grid place-items-center rounded-lg text-gray-400 hover:text-white hover:bg-white/[0.06] transition",children:t.jsx(ft,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row min-h-0 flex-1",children:[t.jsxs("div",{className:"sm:w-[58%] flex flex-col min-h-0 border-b sm:border-b-0 sm:border-r border-white/10",children:[t.jsx("div",{className:"flex flex-wrap gap-1 px-3 pt-3 pb-2",children:l.map((J,Ie)=>t.jsx("button",{type:"button",onClick:()=>u(Ie),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition ${c===Ie?"bg-violet-500/20 border border-violet-500/40 text-violet-100":"border border-transparent text-gray-400 hover:text-gray-200 hover:bg-white/[0.05]"}`,children:J.category||J.group},J.category||J.group))}),t.jsx("div",{className:"px-3 pb-3 overflow-y-auto grid grid-cols-2 lg:grid-cols-3 gap-2 content-start",children:(((xt=l[c])==null?void 0:xt.presets)||[]).map(J=>{const Ie=W===J.label,ht=a?J.width:ic(J.width,J.unit,J.dpi||72),Et=a?J.height:ic(J.height,J.unit,J.dpi||72),Ft=Math.min(46/ht,30/Et,1);return t.jsxs("button",{type:"button",title:a?J.use:void 0,onClick:()=>De(J,l[c].group),className:`flex flex-col items-center gap-1.5 rounded-xl border px-2 py-2.5 text-center transition ${Ie?"border-violet-500 bg-violet-500/10":"border-white/10 bg-white/[0.02] hover:border-white/25"}`,children:[t.jsx("span",{className:"h-8 grid place-items-center",children:t.jsx("span",{className:"border border-white/30 bg-white/10 rounded-[2px]",style:{width:Math.max(8,ht*Ft),height:Math.max(6,Et*Ft)}})}),t.jsx("span",{className:"text-[11px] font-medium text-gray-200 leading-tight line-clamp-2",children:J.label}),t.jsx("span",{className:"text-[9.5px] tabular-nums text-gray-500",children:a?`${J.width}Ã${J.height} · ${J.fps}fps`:`${J.width}Ã${J.height} ${J.unit}`})]},J.label)})})]}),t.jsx("div",{className:"sm:w-[42%] flex flex-col min-h-0",children:t.jsxs("div",{className:"overflow-y-auto px-5 py-4 space-y-3.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:nt,children:"Name"}),t.jsx("input",{className:Xe,value:d,onChange:J=>h(J.target.value)})]}),t.jsxs("div",{children:[t.jsx("label",{className:nt,children:a?"Resolution":"Size"}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"block text-[10px] text-gray-500 mb-0.5",children:"Width"}),t.jsx("input",{type:"number",className:Xe,value:p,onChange:J=>Ye(J.target.value)})]}),t.jsx("button",{type:"button",onClick:Ze,title:"Swap orientation",className:"mb-1 w-8 h-8 shrink-0 grid place-items-center rounded-lg border border-white/10 bg-white/[0.04] text-gray-300 hover:text-white hover:border-white/25 transition",children:t.jsx(Xb,{className:"w-3.5 h-3.5"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"block text-[10px] text-gray-500 mb-0.5",children:"Height"}),t.jsx("input",{type:"number",className:Xe,value:y,onChange:J=>at(J.target.value)})]}
12),!a&&t.jsxs("div",{className:"w-16 shrink-0",children:[t.jsx("span",{className:"block text-[10px] text-gray-500 mb-0.5",children:"Unit"}),t.jsx("select",{className:Xe,value:w,onChange:J=>{C(J.target.value),oe("")},children:o1.map(J=>t.jsx("option",{value:J,children:J},J))})]})]}),t.jsxs("div",{className:"mt-1 text-[10px] tabular-nums text-gray-500",children:[we," à ",Re," px",le?` · ${le}`:""]})]}),a?t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:nt,children:"Frame rate"}),t.jsx("select",{className:Xe,value:A,onChange:J=>V(Number(J.target.value)),children:i1.map(J=>t.jsxs("option",{value:J,children:[J," fps"]},J))})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:nt,children:"Duration (s)"}),t.jsx("input",{type:"number",min:"1",className:Xe,value:z,onChange:J=>H(J.target.value)})]})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"w-20",children:[t.jsx("label",{className:nt,children:"DPI"}),t.jsx("input",{type:"number",className:Xe,value:k,onChange:J=>{E(J.target.value),oe("")}})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:nt,children:"Color mode"}),t.jsx("select",{className:Xe,value:m,onChange:J=>M(J.target.value),children:d1.map(J=>t.jsx("option",{value:J,children:J},J))})]}),t.jsxs("div",{className:"w-16",children:[t.jsx("label",{className:nt,children:"Bits"}),t.jsx("select",{className:Xe,value:I,onChange:J=>N(Number(J.target.value)),children:u1.map(J=>t.jsx("option",{value:J,children:J},J))})]})]}),!a&&t.jsxs("div",{children:[t.jsx("label",{className:nt,children:"Color profile"}),t.jsx("select",{className:Xe,value:F,onChange:J=>R(J.target.value),children:m1.map(J=>t.jsx("option",{value:J,children:J},J))})]}),t.jsxs("div",{children:[t.jsx("label",{className:nt,children:"Backgroun
12d"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[tu.map(J=>t.jsx("button",{type:"button",onClick:()=>se(J.key),className:`px-2.5 py-1.5 rounded-lg text-xs font-medium border transition ${ne===J.key?"border-violet-500/50 bg-violet-500/15 text-violet-100":"border-white/10 bg-white/[0.03] text-gray-300 hover:border-white/25"}`,children:J.label},J.key)),ne==="custom"&&t.jsx("input",{type:"color",value:pe,onChange:J=>ie(J.target.value),className:"w-8 h-8 rounded-lg bg-transparent border border-white/10 cursor-pointer"})]})]}),a&&t.jsxs("label",{className:"flex items-center gap-2 text-xs text-gray-300 select-none cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:O,onChange:J=>D(J.target.checked),className:"accent-violet-500"}),"Lock aspect ratio"]}),t.jsxs("div",{children:[t.jsx("label",{className:nt,children:"Preview"}),t.jsx("div",{className:"h-[180px] rounded-xl border border-white/10 bg-[#080A10] grid place-items-center overflow-hidden",children:t.jsx("div",{className:"border border-white/20",style:{width:Ne.w,height:Ne.h,background:Ae||"repeating-conic-gradient(#3a3a3a 0% 25%, #555 0% 50%) 0 / 16px 16px"}})})]})]})})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-white/10",children:[t.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-300 hover:text-white hover:bg-white/[0.06] transition",children:"Cancel"}),t.jsx("button",{type:"button",onClick:ut,disabled:!we||!Re,className:"px-6 py-2 rounded-lg bg-gradient-to-r from-violet-500 to-fuchsia-500 hover:from-violet-400 hover:to-fuchsia-400 disabled:opacity-50 text-white text-sm font-semibold shadow-[0_4px_20px_-4px_rgba(139,92,246,0.55)] transition",children:"Create"})]})]})}),document.body)}var h1=Object.defineProperty,J0=(e,n)=>{for(var r in n)h1(e,r,{get:n[r],enumerable:!0,configurable:!0,set:s=>n[r]=()=>s})};if(typeof i.createContext!="function"){const e=['Remotion requires React.createContext, but it is "undefined".','If you are in a React Server Component, turn it into a client component by adding "use client" at the top of the file.',"","Before:",' import {useCurrentFrame} from "remotion";',"","After:",' "use client";',' import {useCurrentFrame} from "remotion";'];throw new Error(e.join(` 13`))}var ui=i.createContext(!1),Zu=({children:e})=>t.jsx(ui.Provider,{value:!0,children:e}),Z0=i.createContext({setError:()=>{},clearError:()=>{}}),wf=()=>{try{return typeof __webpack_module__>"u"?null:__webpack_module__.hot??null}catch{return null}};class x1 extends qe.Component{constructor(){super(...arguments);fn(this,"state",{hasError:!1});fn(this,"hmrStatusHandler",null)}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(r){this.props.onError(r),this.subscribeToHmrReset()}componentDidMount(){this.state.hasError||this.props.onClear()}componentDidUpdate(r,s){s.hasError&&!this.state.hasError&&this.props.onClear()}componentWillUnmount(){this.unsubscribeFromHmrReset()}subscribeToHmrReset(){if(this.hmrStatusHandler)return;const r=wf();if(!r)return;const s=o=>{o==="idle"&&(this.unsubscribeFromHmrReset(),this.setState({hasError:!1}))};this.hmrStatusHandler=s,r.addStatusHandler(s)}unsubscribeFromHmrReset(){const r=this.hmrStatusHandler;if(!r)return;this.hmrStatusHandler=null;const s=wf();s&&s.removeStatusHandler(r)}render(){return this.state.hasError?null:this.props.children}}var Ki=i.createContext({compositions:[],folders:[],currentCompositionMetadata:null,canvasContent:null}),Bl=i.createContext({registerComposition:()=>{},unregisterComposition:()=>{},registerFolder:()=>{},unregisterFolder:()=>{},setCanvasContent:()=>{},onlyRenderComposition:null}),Hl=i.createContext({getNonce:()=>0}),Oc=0;try{typeof __webpack_module__<"u"&&__webpack_module__.hot&&__webpack_module__.hot.addStatusHandler(e=>{e==="idle"&&Oc++})}catch{}var md=()=>{const n=i.useContext(Hl).getNonce(),r=i.useRef(n);r.current=n;const s=i.useRef([[Oc,n]]),o=i.useCallback(()=>(Oc!==s.current[s.current.length-1][0]&&(s.current=[...s.current,[Oc,r.current]]),s.current),[s]);return i.useMemo(()=>({get:o}),[o])};function Wi(e){return!!e}var Q0=()=>/^([a-zA-Z0-9-\u4E00-\u9FFF])+$/g,ex=e=>e.match(Q0()),g1=e=>{if(e==null)throw new TypeError("You must pass a name to a <Folder />.");if(typeof e!="string")throw new TypeError(`The "name" you pass into <Folder /> must be a string. Got: ${typeof e}`);if(!ex(e))throw new Error(`Folder name can only contain a-z, A-Z, 0-9 and -. You passed ${e}`)},b1=`Folder name must match ${String(Q0())}`,Qu=i.createContext({folderName:null,parentName:null}),y1=e=>{const{name:n,children:r}=e,s=i.useContext(Qu),{registerFolder:o,unregisterFolder:a}=i.useContext(Bl),l=md(),c=e.stack??null;g1(n);const u=[s.parentName,s.folderName].filter(Wi),d=u.length===0?null:u.join("/"),h=i.useMemo(()=>({folderName:n,parentName:d}),[n,d]);return i.useEffect(()=>(o(n,d,l.get(),c),()=>{a(n,d)}),[n,s.folderName,d,o,a,l,c]),t.jsx(Qu.Provider,{value:h,children:r})};function jf(){return["NOD","E_EN","V"].join("")}var Nf=()=>["e","nv"].join(""),xo=()=>{const e=typeof window<"u"&&window.remotion_isPlayer,n=typeof window<"u"&&typeof window.process<"u"&&typeof window.process.env<"u"&&(window.process[Nf()][jf()]==="test"||window.process[Nf()][jf()]==="production"&&typeof window<"u"&&typeof window.remotion_puppeteerTimeout<"u"),r=typeof window<"u"&&window.remotion_isStudio,s=typeof window<"u"&&window.remotion_isReadOnlyStudio;return{isStudio:r,isRendering:n,isPlayer:e,isReadOnlyStudio:s,isClientSideRendering:!1}},em="remotion-date:",tm="remotion-file:",v1=({data:e,indent:n,staticBase:r})=>{let s=!1,o=!1,a=!1,l=!1;try{return{serializedString:JSON.stringify(e,function(u,d){const h=this[u];return h instanceof Date?(s=!0,`${em}${h.toISOString()}`):h instanceof Map?(a=!0,d):h instanceof Set?(l=!0,d):typeof h=="string"&&r!==null&&h.startsWith(r)?(o=!0,`${tm}${h.replace(r+"/","")}`):d},n),customDateUsed:s,customFileUsed:o,mapUsed:a,setUsed:l}}catch(c){throw new Error("Could not serialize the passed input props to JSON: "+c.message)}},tx=e=>JSON.parse(e,(n,r)=>typeof r=="string"&&r.startsWith(em)?new Date(r.replace(em,"")):typeof r=="string"&&r.startsWith(tm)?`${window.remotion_staticBase}/${r.replace(tm,"")}`:r),w1=e=>tx(v1({data:e,indent:2,staticBase:window.remotion_staticBase}).serializedString),Xa=e=>xo().isStudio?w1(e):e,nx=i.createContext(!1),j1=({children:e})=>t.jsx(nx.Provider,{value:!0,children:e}),Um=()=>i.useContext(nx),Ia=({className:e,classPrefix:n,type:r})=>{if(!e)return!1;if(r==="exact"){const s=e.split(" ");return n.some(o=>s.some(a=>a.trim()===o||a.trim().endsWith(`:${o}`)||a.trim().endsWith(`!${o}`)))}return n.some(s=>e.startsWith(s)||e.includes(` ${s}`)||e.includes(`!${s}`)||e.includes(`:${s}`))},N1=(e,n)=>{const{style:r,...s}=e,o=i.useMemo(()=>({position:"absolute",top:Ia({className:s.className,classPrefix:["top-","inset-"],type:"prefix"})?void 0:0,left:Ia({className:s.className,classPrefix:["left-","inset-"],type:"prefix"})?void 0:0,right:Ia({className:s.className,classPrefix:["right-","inset-"],type:"prefix"})?void 0:0,bottom:Ia({className:s.className,classPrefix:["bottom-","inset-"],type:"prefix"})?void 0:0,width:Ia({className:s.className,classPrefix:["w-"],type:"prefix"})?void 0:"100%",height:Ia({className:s.className,classPrefix:["h-"],type:"prefix"})?void 0:"100%",display:Ia({className:s.className,classPrefix:["block","inline-block","inline","flex","inline-flex","flow-root","grid","inline-grid","contents","list-item","hidden"],type:"exact"})?void 0:"flex",flexDirection:Ia({className:s.className,classPrefix:["flex-row","flex-col","flex-row-reverse","flex-col-reverse"],type:"exact"})?void 0:"column",...r}),[s.className,r]);return t.jsx("div",{ref:n,style:o,...s})},pd=i.forwardRef(N1),k1={transform:"rotate(90deg)"},kf=40,S1={color:"white",fontSize:14,fontFamily:"sans-serif"},C1={justifyContent:"center",alignItems:"center"},E1=()=>t.jsxs(pd,{style:C1,id:"remotion-comp-loading",children:[t.jsx("style",{type:"text/css",children:` 14 @keyframes anim { 15 from { 16 opacity: 0 17 } 18 to { 19 opacity: 1 20 } 21 } 22 #remotion-comp-loading { 23 animation: anim 2s; 24 animation-fill-mode: forwards; 25 } 26 `}),t.jsx("svg",{width:kf,height:kf,viewBox:"-100 -100 400 400",style:k1,children:t.jsx("path",{fill:"#555",stroke:"#555",strokeWidth:"100",strokeLinejoin:"round",d:"M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z"})}),t.jsxs("p",{style:S1,children:["Resolving ","<Suspense>","..."]})]}),Ys=null,nm=()=>{if(!Ys){if(typeof document>"u")throw new Error("Tried to call an API that only works in the browser from outside the browser");Ys=document.createElement("div"),Ys.style.position="absolute",Ys.style.top="0px",Ys.style.left="0px",Ys.style.right="0px",Ys.style.bottom="0px",Ys.style.width="100%",Ys.style.height="100%",Ys.style.display="flex",Ys.style.flexDirection="column";const e=document.createElement("div");e.style.position="fixed",e.style.top="-999999px",e.appendChild(Ys),document.body.appendChild(e)}return Ys},rm=()=>"remotion_inputPropsOverride"+window.location.origin,rx=()=>
26{if(typeof localStorage>"u")return null;const e=localStorage.getItem(rm());return e?JSON.parse(e):null},M1=e=>{if(!(typeof localStorage>"u")){if(e===null){localStorage.removeItem(rm());return}localStorage.setItem(rm(),JSON.stringify(e))}},Sf=!1,I1=()=>{Sf||(Sf=!0,console.warn("Called `getInputProps()` on the server. This function is not available server-side and has returned an empty object."),console.warn("To hide this warning, don't call this function on the server:"),console.warn(" typeof window === 'undefined' ? {} : getInputProps()"))},F1=()=>{if(typeof window>"u")return I1(),{};if(xo().isPlayer)throw new Error("You cannot call `getInputProps()` from a <Player>. Instead, the props are available as React props from component that you passed as `component` prop.");const e=rx();if(e)return e;if(typeof window>"u"||typeof window.remotion_inputProps>"u")throw new Error("Cannot call `getInputProps()` - window.remotion_inputProps is not set. This API is only available if you are in the Studio, or while you are rendering server-side.");const n=window.remotion_inputProps;return n?tx(n):{}},zm=i.createContext({props:{},updateProps:()=>{throw new Error("Not implemented")}}),R1=qe.createRef(),sx=({children:e})=>{const[n,r]=qe.useState({}),s=i.useCallback(({defaultProps:a,id:l,newProps:c})=>{r(u=>({...u,[l]:typeof c=="function"?c(u[l]??a):c}))},[]),o=i.useMemo(()=>({props:n,updateProps:s}),[n,s]);return t.jsx(zm.Provider,{value:o,children:e})},ox=qe.createContext(null),Pr=()=>{const e=i.useContext(ox),[n]=i.useState(()=>xo());return e??n};function nd(e,n,r){if(typeof e!="number")throw new Error(`The "${n}" prop ${r} must be a number, but you passed a value of type ${typeof e}`);if(isNaN(e))throw new TypeError(`The "${n}" prop ${r} must not be NaN, but is NaN.`);if(!Number.isFinite(e))throw new TypeError(`The "${n}" prop ${r} must be finite, but is ${e}.`);if(e%1!==0)throw new TypeError(`The "${n}" prop ${r} must be an integer, but is ${e}.`);if(e<=0)throw new TypeError(`The "${n}" prop ${r} must be positive, but got ${e}.`)}function fd(e,n){const{allowFloats:r,component:s}=n;if(typeof e>"u")throw new Error(`The "durationInFrames" prop ${s} is missing.`);if(typeof e!="number")throw new Error(`The "durationInFrames" prop ${s} must be a number, but you passed a value of type ${typeof e}`);if(e<=0)throw new TypeError(`The "durationInFrames" prop ${s} must be positive, but got ${e}.`);if(!r&&e%1!==0)throw new TypeError(`The "durationInFrames" prop ${s} must be an integer, but got ${e}.`);if(!Number.isFinite(e))throw new TypeError(`The "durationInFrames" prop ${s} must be finite, but got ${e}.`)}function hd(e,n,r){if(typeof e!="number")throw new Error(`"fps" must be a number, but you passed a value of type ${typeof e} ${n}`);if(!Number.isFinite(e))throw new Error(`"fps" must be a finite, but you passed ${e} ${n}`);if(isNaN(e))throw new Error(`"fps" must not be NaN, but got ${e} ${n}`);if(e<=0)throw new TypeError(`"fps" must be positive, but got ${e} ${n}`)}var xd=i.createContext(null),P1=i.createRef(),T1=e=>!!e.calculateMetadata,Bm=e=>{const n=i.useContext(xd),{props:r}=i.useContext(zm),{compositions:s,canvasContent:o,currentCompositionMetadata:a}=i.useContext(Ki),l=(o==null?void 0:o.type)==="composition"?o.compositionId:null,c=e??l,u=s.find(p=>p.id===c),d=i.useMemo(()=>u?r[u.id]??{}:{},[r,u]),h=Pr();return i.useMemo(()=>u?a?{type:"success",result:{...a,id:u.id,defaultProps:u.defaultProps??{}}}:T1(u)?!n||!n[u.id]?null:n[u.id]:(fd(u.durationInFrames,{allowFloats:!1,component:`in <Composition id="${u.id}">`}),hd(u.fps,`in <Composition id="${u.id}">`),nd(u.width,"width",`in <Composition id="${u.id}">`),nd(u.height,"height",`in <Composition id="${u.id}">`),{type:"success",result:{width:u.width,height:u.height,fps:u.fps,id:u.id,durationInFrames:u.durationInFrames,defaultProps:u.defaultProps??{},props:{...u.defaultProps??{},...d??{},...typeof window>"u"||h.isPlayer||!window.remotion_inputProps?{}:F1()??{}},defaultCodec:null,defaultOutName:null,defaultVideoImageFormat:null,defaultPixelFormat:null,defaultProResProfile:null,defaultSampleRate:null}}):null,[u,n,a,d,h.isPlayer])},ax=e=>{const n=e.stack??"";return n.startsWith("Error:")?n:`${e.message} 27${n}`},A1=e=>e instanceof Error?!0:!(e===null||typeof e!="object"||!("stack"in e)||typeof e.stack!="string"||!("message"in e)||typeof e.message!="string");function Hm(e,n){let r;throw A1(n)?(r=n,r.stack||(r.stack=new Error(r.message).stack)):typeof n=="string"?r=Error(n):r=Error("Rendering was cancelled"),e&&(e.remotion_cancelledError=ax(r)),r}function Ol(e){return Hm(typeof window<"u"?window:void 0,e)}var $1=["trace","verbose","info","warn","error"],Cf=e=>$1.indexOf(e),gd=(e,n)=>Cf(e)<=Cf(n),Kl=({args:e,logLevel:n,tag:r})=>{const s=[...e];
27return xo().isRendering&&!xo().isClientSideRendering&&s.unshift(Symbol.for(`__remotion_level_${n}`)),r&&xo().isRendering&&!xo().isClientSideRendering&&s.unshift(Symbol.for(`__remotion_tag_${r}`)),s},_1=(e,...n)=>{if(gd(e.logLevel,"verbose"))return console.debug(...Kl({args:n,logLevel:"verbose",tag:e.tag}))},D1=(e,...n)=>{if(gd(e.logLevel,"trace"))return console.debug(...Kl({args:n,logLevel:"trace",tag:e.tag}))},L1=(e,...n)=>{if(gd(e.logLevel,"info"))return console.log(...Kl({args:n,logLevel:"info",tag:e.tag}))},O1=(e,...n)=>{if(gd(e.logLevel,"warn"))return console.warn(...Kl({args:n,logLevel:"warn",tag:e.tag}))},V1=(e,...n)=>console.error(...Kl({args:n,logLevel:"error",tag:e.tag})),Dr={trace:D1,verbose:_1,info:L1,warn:O1,error:V1};typeof window<"u"&&(window.remotion_renderReady=!1,window.remotion_delayRenderTimeouts||(window.remotion_delayRenderTimeouts={}),window.remotion_delayRenderHandles=[]);var U1="The delayRender was called:",z1="Retries left: ",B1="- Rendering the frame will be retried.",H1="handle was cleared after",K1=3e4,ix=({scope:e,environment:n,label:r,options:s})=>{var l;if(typeof r!="string"&&r!==null)throw new Error("The label parameter of delayRender() must be a string or undefined, got: "+JSON.stringify(r));const o=Math.random();e.remotion_delayRenderHandles.push(o);const a=((l=Error().stack)==null?void 0:l.replace(/^Error/g,""))??"";if(n.isRendering){const c=((s==null?void 0:s.timeoutInMilliseconds)??e.remotion_puppeteerTimeout??K1)-2e3,u=((s==null?void 0:s.retries)??0)-(e.remotion_attempt-1);e.remotion_delayRenderTimeouts[o]={label:r??null,startTime:Date.now(),timeout:setTimeout(()=>{const d=["A delayRender()",r?`"${r}"`:null,`was called but not cleared after ${c}ms. See https://remotion.dev/docs/timeout for help.`,u>0?z1+u:null,u>0?B1:null,U1,a].filter(Wi).join(" ");n.isClientSideRendering?e.remotion_cancelledError=ax(Error(d)):Hm(e,Error(d))},c)}}return e.remotion_renderReady=!1,o},Ef=(e,n)=>typeof window>"u"?Math.random():ix({scope:window,environment:xo(),label:e??null,options:{}}),W1=({scope:e,handle:n,environment:r,logLevel:s})=>{if(typeof n>"u")throw new TypeError("The continueRender() method must be called with a parameter that is the return value of delayRender(). No value was passed.");if(typeof n!="number")throw new TypeError("The parameter passed into continueRender() must be the return value of delayRender() which is a number. Got: "+JSON.stringify(n));e.remotion_delayRenderHandles=e.remotion_delayRenderHandles.filter(o=>{if(o===n){if(r.isRendering&&e!==void 0){if(!e.remotion_delayRenderTimeouts[n])return!1;const{label:a,startTime:l,timeout:c}=e.remotion_delayRenderTimeouts[n];clearTimeout(c);const u=[a?`"${a}"`:"A handle",H1,`${Date.now()-l}ms`].filter(Wi).join(" ");Dr.verbose({logLevel:s,tag:"delayRender()"},u),delete e.remotion_delayRenderTimeouts[n]}return!1}return!0}),e.remotion_delayRenderHandles.length===0&&(e.remotion_renderReady=!0)},mi=i.createContext({logLevel:"info",mountTime:0}),Jo=()=>{const{logLevel:e}=i.useContext(mi);if(e===null)throw new Error("useLogLevel must be used within a LogLevelProvider");return e},Wl=()=>{const{mountTime:e}=i.useContext(mi);if(e===null)throw new Error("useMountTime must be used within a LogLevelProvider");return e},lx=i.createContext(null),$o=()=>{const e=Pr(),n=i.useContext(lx)??(typeof window<"u"?window:void 0),r=Jo(),s=i.useCallback((l,c)=>n?ix({scope:n,environment:e,label:l??null,options:c??{}}):Math.random(),[e,n]),o=i.useCallback(l=>{n&&W1({scope:n,handle:l,environment:e,logLevel:r})},[e,r,n]),a=i.useCallback(l=>Hm(n??(typeof window<"u"?window:void 0),l),[n]);return{delayRender:s,continueRender:o,cancelRender:a}},cx=({compProps:e,componentName:n,noSuspense:r})=>{const s=i.useRef(null);return"component"in e&&(s.current=e.component),i.useMemo(()=>{if("component"in e){if(typeof document>"u"||r)return e.component;if(typeof e.component>"u")throw new Error(`A value of \`undefined\` was passed to the \`component\` prop. Check the value you are passing to the <${n}/> component.`);return l=>{const c=s.current;return qe.createElement(c,l)}}if("lazyComponent"in e&&typeof e.lazyComponent<"u"){if(typeof e.lazyComponent>"u")throw new Error(`A value of \`undefined\` was passed to the \`lazyComponent\` prop. Check the value you are passing to the <${n}/> component.`);return qe.lazy(e.lazyComponent)}throw new Error("You must pass either 'component' or 'lazyComponent'")},[e.lazyComponent])},bd=()=>{const{canvasContent:e,compositions:n,currentCompositionMetadata:r}=i.useContext(Ki),s=n.find(a=>(e==null?void 0:e.type)==="composition"&&a.id===e.compositionId),o=Bm((s==null?void 0:s.id)??null);return i.useMemo(()=>!o||o.type==="error"||o.type==="loading"||!s?null:{...o.result,defaultProps:s.defaultProps??{},id:s.id,...r??{},component:s.component},[r,o,s])},dx=()=>/^([a-zA-Z0-9-\u4E00-\u9FFF])+$/g,ux=e=>e.match(dx()),Y1=e=>{if(!ux(e))throw new Error(`Composition id can only contain a-z, A-Z, 0-9, CJK characters and -. You passed ${e}`)},G1=`Composition ID must match ${String(dx())}`,q1=(e,n,r)=>{if(e){if(typeof e!="object")throw new Error(`"${n}" must be an object, but you passed a value of type ${typeof e}`);if(Array.isArray(e))throw new Error(`"${n}" must be an object, an array was passed ${r?`for composition "${r}"`:""}`)}},X1=()=>{const{continueRender:e,delayRender:n}=$o();return i.useEffect(()=>{const r=n("Waiting for Root component to unsuspend");return()=>e(r)},[e,n]),null},J1=({width:e,height:n,fps:r,durationInFrames:s,id:o,defaultProps:a,schema:l,...c})=>{const u=i.useContext(Bl),{registerComposition:d,unregisterComposition:h}=u,p=bd(),b=cx({compProps:c,componentName:"Composition",noSuspense:!1}),y=md(),v=Um(),w=Pr(),C=i.useContext(ui);if(typeof window<"u"&&(window.remotion_seenCompositionIds=Array.from(new Set([...window.remotion_seenCompositionIds??[],o]))),
27C)throw v?new Error("<Composition> was mounted inside the `component` that was passed to the <Player>. See https://remotion.dev/docs/wrong-composition-mount for help."):new Error("<Composition> mounted inside another composition. See https://remotion.dev/docs/wrong-composition-mount for help.");const{folderName:k,parentName:E}=i.useContext(Qu),m=c.stack??null;i.useEffect(()=>{if(!o)throw new Error("No id for composition passed.");return Y1(o),q1(a,"defaultProps",o),d({durationInFrames:s??void 0,fps:r??void 0,height:n??void 0,width:e??void 0,id:o,folderName:k,component:b,defaultProps:Xa(a??{}),nonce:y.get(),parentFolderName:E,schema:l??null,calculateMetadata:c.calculateMetadata??null,stack:m}),()=>{h(o)}},[s,r,n,b,o,k,a,e,y,E,l,c.calculateMetadata,m,d,h]);const M=Bm(o),{setError:I,clearError:N}=i.useContext(Z0),F=i.useCallback(A=>{I(A)},[I]),R=i.useCallback(()=>{N()},[N]);if(w.isStudio&&p&&p.component===b&&p.id===o){const A=b;return M===null||M.type!=="success"&&M.type!=="success-and-refreshing"?null:Un.createPortal(t.jsx(Zu,{children:t.jsx(x1,{onError:F,onClear:R,children:t.jsx(i.Suspense,{fallback:t.jsx(E1,{}),children:t.jsx(A,{...M.result.props??{}})})})}),nm())}if(w.isRendering&&p&&p.component===b&&p.id===o){const A=b;return M===null||M.type!=="success"&&M.type!=="success-and-refreshing"?null:Un.createPortal(t.jsx(Zu,{children:t.jsx(i.Suspense,{fallback:t.jsx(X1,{}),children:t.jsx(A,{...M.result.props??{}})})}),nm())}return null},sm=e=>{const{onlyRenderComposition:n}=i.useContext(Bl);return n&&n!==e.id?null:t.jsx(J1,{...e})},mx=[],Z1=()=>mx,_s=e=>{mx.push(e)},yl="4.0.478",Q1=()=>{if(typeof globalThis>"u")return;const e=()=>{globalThis.remotion_imported=yl,typeof window<"u"&&(window.remotion_imported=yl)},n=globalThis.remotion_imported||typeof window<"u"&&window.remotion_imported;if(n){if(n===yl)return;if(typeof n=="string"&&n.includes("webcodecs")){e();return}throw new TypeError(`ð¨ Multiple versions of Remotion detected: ${[yl,typeof n=="string"?n:"an older version"].filter(Wi).join(" and ")}. This will cause things to break in an unexpected way. 28Check that all your Remotion packages are on the same version. If your dependencies depend on Remotion, make them peer dependencies. You can also run \`npx remotion versions\` from your terminal to see which versions are mismatching.`)}e()},Rr=i.createContext(null),om={};J0(om,{useTimelineSetFrame:()=>yx,useTimelinePosition:()=>Ua,useTimelineContext:()=>Va,usePlayingState:()=>vx,usePlaybackRate:()=>Gm,useAbsoluteTimelinePosition:()=>bx,persistCurrentFrame:()=>px,getInitialFrameState:()=>fx,getFrameForComposition:()=>hx,clampFrameToCompositionRange:()=>xx});function Mf(e){let n=e+1831565813;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}function ew(e){let n=0,r=0,s=0;for(n=0;n<e.length;n++)r=e.charCodeAt(n),s=(s<<5)-s+r,s|=0;return s}var Oa=(e,n)=>{if(e===null)return Math.random();if(typeof e=="string")return Mf(ew(e));if(typeof e=="number")return Mf(e*1e10);throw new Error("random() argument must be a number or a string")},Yi=i.createContext({setFrame:()=>{throw new Error("default")},setPlaying:()=>{throw new Error("default")}}),Gi=i.createContext(null),Km=i.createContext(null),Wm=i.createContext(null),tw=({children:e,frameState:n})=>{const[r,s]=i.useState(!1),o=i.useRef(!1),[a,l]=i.useState(1),c=i.useRef([]),[u]=i.useState(()=>String(Oa(null))),[d,h]=i.useState(()=>fx()),p=n??d,{delayRender:b,continueRender:y}=$o();typeof window<"u"&&i.useLayoutEffect(()=>{window.remotion_setFrame=(k,E,m)=>{window.remotion_attempt=m;const M=b(`Setting the current frame to ${k}`);let I=!0;h(N=>(N[E]??window.remotion_initialFrame)===k?(I=!1,N):{...N,[E]:k}),I?requestAnimationFrame(()=>y(M)):y(M)},window.remotion_isPlayer=!1},[y,b]);const v=i.useMemo(()=>({frame:p,playing:r,imperativePlaying:o,rootId:u,audioAndVideoTags:c}),[p,r,u]),w=i.useMemo(()=>({playbackRate:a,setPlaybackRate:l}),[a]),C=i.useMemo(()=>({setFrame:h,setPlaying:s}),[]);return t.jsx(Wm.Provider,{value:v,children:t.jsx(Km.Provider,{value:w,children:t.jsx(Gi.Provider,{value:v,children:t.jsx(Yi.Provider,{value:C,children:e})})})})},Ym=()=>"remotion.time-all",px=e=>{localStorage.setItem(Ym(),JSON.stringify(e))},fx=()=>{const e=localStorage.getItem(Ym())??"{}";return JSON.parse(e)},hx=e=>{const n=localStorage.getItem(Ym())??"{}",r=JSON.parse(n);return r[e]!==void 0?Number(r[e]):typeof window>"u"?0:window.remotion_initialFrame??0},xx=(e,n)=>Math.max(0,Math.min(Math.max(0,n-1),e)),gx=e=>{const n=bd(),r=Pr();if(!n)return typeof window>"u"?0:window.remotion_initialFrame??0;const s=e.frame[n.id]??(r.isPlayer?0:hx(n.id));return xx(s,n.durationInFrames)},Va=()=>{const e=i.useContext(Gi);if(e===null)throw new Error("TimelineContext is not available. This hook must be used inside a <Player> or the Remotion Studio.");return e},Gm=()=>{const e=i.useContext(Km);if(e===null)throw new Error("PlaybackRateContext is not available. This hook must be used inside a <Player> or the Remotion Studio.");return e},Ua=()=>{const e=Va();return gx(e)},bx=()=>{const e=i.useContext(Wm);if(e===null)throw new Error("AbsoluteTimeContext is not available. This hook must be used inside a <Player> or the Remotion Studio.");return gx(e)},yx=()=>{const{setFrame:e}=i.useContext(Yi);return e},vx=()=>{const{playing:e,imperativePlaying:n}=Va(),{setPlaying:r}=i.useContext(Yi);return i.useMemo(()=>[e,r,n],[n,e,r])},xs=()=>{const e=i.useContext(ui),n=Pr();if(!e)throw n.isPlayer?new Error("useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples"):new Error("useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions");const r=Ua(),s=i.useContext(Rr),o=s?s.cumulatedFrom+s.relativeFrom:0;return r-o},yd=()=>{const e=i.useContext(Rr),n=(e==null?void 0:e.width)??null,r=(e==null?void 0:e.he
28ight)??null,s=(e==null?void 0:e.durationInFrames)??null,o=bd();return i.useMemo(()=>{if(!o)return null;const{id:a,durationInFrames:l,fps:c,height:u,width:d,defaultProps:h,props:p,defaultCodec:b,defaultOutName:y,defaultVideoImageFormat:v,defaultPixelFormat:w,defaultProResProfile:C,defaultSampleRate:k}=o;return{id:a,width:n??d,height:r??u,fps:c,durationInFrames:s??l,defaultProps:h,props:p,defaultCodec:b,defaultOutName:y,defaultVideoImageFormat:v,defaultPixelFormat:w,defaultProResProfile:C,defaultSampleRate:k}},[s,r,n,o])},as=()=>{const e=yd(),n=i.useContext(ui),r=Um();if(!e)throw typeof window<"u"&&window.remotion_isPlayer||r?new Error(["No video config found. Likely reasons:","- You are probably calling useVideoConfig() from outside the component passed to <Player />. See https://www.remotion.dev/docs/player/examples for how to set up the Player correctly.","- You have multiple versions of Remotion installed which causes the React context to get lost."].join("-")):new Error("No video config found. You are probably calling useVideoConfig() from a component which has not been registered as a <Composition />. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions for more information.");if(!n)throw new Error("Called useVideoConfig() outside a Remotion composition.");return e},wx=({frame:e,children:n,active:r=!0})=>{const s=xs(),o=as();if(typeof e>"u")throw new Error("The <Freeze /> component requires a 'frame' prop, but none was passed.");if(typeof e!="number")throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof e}`);if(Number.isNaN(e))throw new Error("The 'frame' prop of <Freeze /> must be a real number, but it is NaN.");if(!Number.isFinite(e))throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${e}.`);const a=i.useMemo(()=>{if(typeof r=="boolean")return r;if(typeof r=="function")return r(s)},[r,s]),l=Va(),c=i.useContext(Rr),u=(c==null?void 0:c.relativeFrom)??0,d=i.useMemo(()=>a?{...l,playing:!1,imperativePlaying:{current:!1},frame:{[o.id]:e+u}}:l,[a,l,o.id,e,u]),h=i.useMemo(()=>c?a?{...c,cumulatedFrom:0}:c:null,[c,a]);return t.jsx(Gi.Provider,{value:d,children:t.jsx(Rr.Provider,{value:h,children:n})})},jx=i.createContext({premountFramesRemaining:0}),za={"style.transformOrigin":{type:"transform-origin",step:1,default:"50% 50%",description:"Transform origin"},"style.translate":{type:"translate",step:1,default:"0px 0px",description:"Offset"},"style.scale":{type:"scale",max:100,step:.01,default:1,description:"Scale"},"style.rotate":{type:"rotation-css",step:1,default:"0deg",description:"Rotation"},"style.opacity":{type:"number",min:0,max:1,step:.01,default:1,description:"Opacity",hiddenFromList:!1}},Nx={premountFor:{type:"number",default:0,description:"Premount For",min:0,step:1,hiddenFromList:!1},postmountFor:{type:"number",default:0,min:0,step:1,hiddenFromList:!0},styleWhilePremounted:{type:"hidden"},styleWhilePostmounted:{type:"hidden"}},kx={...za,...Nx},ya={type:"boolean",default:!1,description:"Hidden"},Sx={type:"hidden"},nw={type:"hidden"},qm=e=>({name:nw,...e}),va={type:"number",default:void 0,min:1,step:1,hiddenFromList:!0},Ba={type:"number",default:0,step:1,hiddenFromList:!0},wa={type:"number",default:null,step:1,hiddenFromList:!0},Vl=qm({hidden:ya,showInTimeline:Sx,from:Ba,freeze:wa,durationInFrames:va,layout:{type:"enum",default:"absolute-fill",description:"Layout",variants:{"absolute-fill":kx,none:{}}}}),rw=qm({hidden:ya,showInTimeline:Sx,freeze:wa,durationInFrames:va,layout:Vl.layout}),sw={...Vl,layout:{...Vl.layout,default:"none"}},qi=qe.createContext({registerSequence:()=>{throw new Error("SequenceManagerContext not initialized")},unregisterSequence:()=>{throw new Error("SequenceManagerContext not initialized")},sequences:[]}),vd=qe.createContext({current:[]}),ha=e=>`${e.nodePath.join(".")}.${e.sequenceKeys.join(".")}.${e.effectKeys.map(n=>n.join(".")).join(".")}`,wd=qe.createContext({propStatuses:{}}),jd=qe.createContext({current:{}}),Nd=qe.createContext({getDragOverrides:()=>{throw new Error("VisualModeDragOverridesContext not initialized")},getEffectDragOverrides:()=>{throw new Error("VisualModeDragOverridesContext not initialized")}}),Cx=qe.createContext({setDragOverrides:()=>{throw new Error("VisualModeSettersContext not initialized")},clearDragOverrides:()=>{throw new Error("VisualModeSettersContext not initialized")},setEffectDragOverrides:()=>{throw new Error("VisualModeSettersContext not initialized")},clearEffectDragOverrides:()=>{throw new Error("VisualModeSettersContext not initialized")},setPropStatuses:()=>{throw new Error("VisualModeSettersContext not initialized")}}),nu=(e,n)=>`${ha(e)}.effects.${n}`,ow=({children:e})=>{const[n,r]=i.useState([]),s=i.useRef(n);s.current=n;const[o,a]=i.useState({}),l=i.useRef(o);l.current=o;const[c,u]=i.useState({}),[d,h]=i.useState({}),p=i.useRef(d);p.current=d;const b=i.useCallback((A,V,z)=>{a(H=>({...H,[ha(A)]:{...H[ha(A)],[V]:z}}))},[]),y=i.useCallback(A=>{a(V=>{const z=ha(A);if(!V[z])return V;const H={...V};return delete H[z],H})},[]),v=i.useCallback((A,V,z,H)=>{u(ne=>{const se=nu(A,V);return{...ne,[se]:{...ne[se],[z]:H}}})},[]),w=i.useCallback((A,V)=>{u(z=>{const H=nu(A,V);if(!z[H])return z;const ne={...z};return delete ne[H],ne})},[]),C=i.useCallback((A,V)=>{h(z=>{const H=ha(A),ne=z[H],se=V(ne);return ne===se?z:{...z,[H]:se}})},[]),k=i.useCallback(A=>{r(V=>[...V,A])},[]),E=i.useCallback(A=>{r(V=>V.filter(z=>z.id!==A))},[]),m=i.useMemo(()=>({registerSequence:k,sequences:n,unregisterSequence:E}),[k,n,E]),M=i.useCallback(A=>o[ha(A)]??{},[o]),I=i.useCallback((A,V)=>c[nu(A,V)]??{},[c]),N=i.useMemo(()=>({propStatuses:d}),[d]),F=i.useMemo(()=>({getDragOverrides:M,getEffectDragOverrides:I}),[M,I]),R=i.useMemo(()=>({setDragOverrides:b,clearDragOverrides:y,setEffectDragOverrides:v,clearEffectDragOverrides:w,setPropStatuses:C}),[b,y,v,w,C]);return t.jsx(vd.Provider,{value:s,children:t.jsx(qi.Provider,{value:m,children:t.jsx(jd.Provider,{value:p,children:t.jsx(wd.Provider,{value:N,children:t.jsx(Nd.Provider,{value:F,children:t.jsx(Cx.Provider,{value:R,children:e})})})})})})},kd=i.createContext(!1),aw=({children:e})=>t.jsx(kd.Provider,{value:!0,children:e}),iw=({children:e})=>t.jsx(kd.Provider,{value:!1,children:e}),lw=()=>
28{if(!qe.useContext(kd))throw new Error("This component must be inside a <Series /> component.")},cw=(e,n)=>{for(const r of n){const s=r.split("."),o=[e];let a=e;for(let l=0;l<s.length-1;l++){const c=s[l],u=a[c];if(u==null){a=null;break}a=u,o.push(a)}if(a!==null){delete a[s[s.length-1]];for(let l=o.length-1;l>0;l--){const c=o[l];if(Object.keys(c).length===0){const u=s[l-1];delete o[l-1][u]}else break}}}return e},dw=4,uw=.001,mw=1e-7,pw=10,vl=11,lc=1/(vl-1),fw=typeof Float32Array=="function";function Ex(e,n){return 1-3*n+3*e}function Mx(e,n){return 3*n-6*e}function Ix(e){return 3*e}function rd(e,n,r){return((Ex(n,r)*e+Mx(n,r))*e+Ix(n))*e}function Fx(e,n,r){return 3*Ex(n,r)*e*e+2*Mx(n,r)*e+Ix(n)}function hw({aX:e,_aA:n,_aB:r,mX1:s,mX2:o}){let a,l,c=0,u=n,d=r;do l=u+(d-u)/2,a=rd(l,s,o)-e,a>0?d=l:u=l;while(Math.abs(a)>mw&&++c<pw);return l}function xw(e,n,r,s){let o=n;for(let a=0;a<dw;++a){const l=Fx(o,r,s);if(l===0)return o;const c=rd(o,r,s)-e;o-=c/l}return o}function Rx(e,n,r,s){if(!(e>=0&&e<=1&&r>=0&&r<=1))throw new Error("bezier x values must be in [0, 1] range");const o=fw?new Float32Array(vl):new Array(vl);if(e!==n||r!==s)for(let l=0;l<vl;++l)o[l]=rd(l*lc,e,r);function a(l){let c=0,u=1;const d=vl-1;for(;u!==d&&o[u]<=l;++u)c+=lc;--u;const h=(l-o[u])/(o[u+1]-o[u]),p=c+h*lc,b=Fx(p,e,r);return b>=uw?xw(l,p,e,r):b===0?p:hw({aX:l,_aA:c,_aB:c+lc,mX1:e,mX2:r})}return function(l){const c=Math.min(1,Math.max(0,l));return e===n&&r===s?c:c===0?0:c===1?1:rd(a(c),n,s)}}var gw=e=>Math.round(e*1e6)/1e6,bw=new Set(["deg","rad","grad","turn"]),Px=new Set(["%","cap","ch","cm","cqb","cqh","cqi","cqmax","cqmin","cqw","dvh","dvw","em","ex","ic","in","lh","lvh","lvw","mm","pc","pt","px","q","rem","rlh","svh","svw","vb","vh","vi","vmax","vmin","vw"]),Tx=/^([+-]?(?:\d+\.?\d*|\.\d+))([a-zA-Z%]+)?$/,Ax=new Set(["left","center","right","top","bottom"]),Pi=e=>e==="left"?[{axis:"x",value:{value:0,unit:"%"}}]:e==="right"?[{axis:"x",value:{value:100,unit:"%"}}]:e==="top"?[{axis:"y",value:{value:0,unit:"%"}}]:e==="bottom"?[{axis:"y",value:{value:100,unit:"%"}}]:[{axis:"x",value:{value:50,unit:"%"}},{axis:"y",value:{value:50,unit:"%"}}],nl={value:50,unit:"%"},If=e=>String(gw(e)),yw=(e,n)=>{const r=Tx.exec(e);if(r===null)throw new TypeError(`Cannot interpolate "${n}" because "${e}" is not a supported scale, translate, or rotate value`);const s=r[2]??null,o=Number(r[1]);if(!Number.isFinite(o))throw new TypeError(`Cannot interpolate "${n}" because "${e}" is not finite`);if(s===null)return{kind:"scale",value:o,unit:null};if(bw.has(s))return{kind:"rotate",value:o,unit:s};if(Px.has(s))return{kind:"translate",value:o,unit:s};throw new TypeError(`Cannot interpolate "${n}" because "${s}" is not a supported translate or rotate unit`)},$x=({component:e,value:n,allowPercentage:r})=>{const s=Tx.exec(e);if(s===null)throw new TypeError(`Cannot interpolate "${n}" because "${e}" is not a supported transform-origin ${r?"length-percentage":"z length"}`);const o=s[2]??null,a=Number(s[1]);if(!Number.isFinite(a))throw new TypeError(`Cannot interpolate "${n}" because "${e}" is not finite`);if(o===null||!Px.has(o)||!r&&o==="%")throw new TypeError(`Cannot interpolate "${n}" because "${e}" is not a supported transform-origin ${r?"length-percentage":"z length"}`);return{value:a,unit:o}},ru=(e,n)=>{const r=e.toLowerCase();return Ax.has(r)?{type:"keyword",keyword:r}:{type:"length-percentage",parsed:$x({component:e,value:n,allowPercentage:!0})}},vw=(e,n,r)=>{const s=[];for(const o of Pi(e))for(const a of Pi(n))o.axis!==a.axis&&s.push(o.axis==="x"?[o.value,a.value]:[a.value,o.value]);if(s.length===0)throw new TypeError(`Cannot interpolate "${r}" because "${e} ${n}" is not a valid transform-origin keyword pair`);return s[0]},ww=(e,n)=>{if(e.length===1){const c=ru(e[0],n);return c.type==="length-percentage"?[c.parsed,nl]:c.keyword==="top"||c.keyword==="bottom"?[nl,Pi(c.keyword)[0].value]:[Pi(c.keyword)[0].value,nl]}const r=ru(e[0],n),s=ru(e[1],n);if(r.type==="length-percentage"&&s.type==="length-percentage")return[r.parsed,s.parsed];if(r.type==="keyword"&&s.type==="keyword")return vw(r.keyword,s.keyword,n);
28const o=r.type==="keyword"?r:s.type==="keyword"?s:null,a=r.type==="length-percentage"?r.parsed:s.type==="length-percentage"?s.parsed:null;if(o===null||a===null)throw new Error("Expected a keyword and a length-percentage value");const l=r.type==="keyword";if(o.keyword==="left"||o.keyword==="right"){if(!l)throw new TypeError(`Cannot interpolate "${n}" because horizontal transform-origin keywords must come before a length-percentage value`);return[Pi(o.keyword)[0].value,a]}return o.keyword==="top"||o.keyword==="bottom"?[a,Pi(o.keyword)[0].value]:l?[nl,a]:[a,nl]},jw=(e,n)=>{const[r,s]=ww(n.slice(0,2),e),o=n[2]===void 0?{value:0,unit:null}:$x({component:n[2],value:e,allowPercentage:!1});return{kind:"translate",values:[r.value,s.value,o.value],units:[r.unit,s.unit,o.unit],dimensions:n[2]===void 0?2:3}},Nw=e=>{var o,a,l,c,u,d;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error(`outputRange must contain only finite numbers, but got [${e}]`);return{kind:"scale",values:[e,e,1],units:[null,null,null],dimensions:1}}const n=e.trim().split(/\s+/);if(n.length<1||n.length>3||n[0]==="")throw new TypeError(`String outputRange values must contain 1 to 3 components, but got "${e}"`);if(n.some(h=>Ax.has(h.toLowerCase())))return jw(e,n);const r=n.map(h=>yw(h,e)),[{kind:s}]=r;for(const h of r)if(h.kind!==s)throw new TypeError(`Cannot interpolate "${e}" because it mixes ${s} and ${h.kind} values`);if(s==="scale"){const h=r[0].value,p=((o=r[1])==null?void 0:o.value)??h,b=((a=r[2])==null?void 0:a.value)??1;return{kind:s,values:[h,p,b],units:[null,null,null],dimensions:r.length}}return{kind:s,values:[r[0].value,((l=r[1])==null?void 0:l.value)??0,((c=r[2])==null?void 0:c.value)??0],units:[r[0].unit,((u=r[1])==null?void 0:u.unit)??null,((d=r[2])==null?void 0:d.unit)??null],dimensions:r.length}},kw=({kind:e,values:n,units:r,dimensions:s})=>e==="scale"?n.slice(0,s).map(o=>If(o)).join(" "):n.slice(0,s).map((o,a)=>`${If(o)}${r[a]}`).join(" ");function Sw(e,n,r,s){const{extrapolateLeft:o,extrapolateRight:a,easing:l}=s;let c=e;const[u,d]=n,[h,p]=r;if(c<u){if(o==="identity")return c;if(o==="clamp")c=u;else if(o==="wrap"){const b=d-u;c=((c-u)%b+b)%b+u}}if(c>d){if(a==="identity")return c;if(a==="clamp")c=d;else if(a==="wrap"){const b=d-u;c=((c-u)%b+b)%b+u}}return h===p?h:(c=(c-u)/(d-u),c=l(c),c=c*(p-h)+h,c)}function Cw(e,n){let r;for(r=1;r<n.length-1&&!(n[r]>=e);++r);return r-1}var Ew=e=>e,Xm=({input:e,inputRange:n,outputRange:r,options:s})=>{if(n.length===1)return r[0];const o=s==null?void 0:s.easing,a=h=>o===void 0?Ew:typeof o=="function"?o:o[h];let l="extend";(s==null?void 0:s.extrapolateLeft)!==void 0&&(l=s.extrapolateLeft);let c="extend";(s==null?void 0:s.extrapolateRight)!==void 0&&(c=s.extrapolateRight);const u=(s==null?void 0:s.posterize)===void 0?e:Math.floor(e/s.posterize)*s.posterize,d=Cw(u,n);return Sw(u,[n[d],n[d+1]],[r[d],r[d+1]],{easing:a(d),extrapolateLeft:l,extrapolateRight:c})},Mw=({input:e,inputRange:n,outputRange:r,options:s})=>{var u;const o=r.map(Nw),a=(u=o[0])==null?void 0:u.kind;if(a===void 0)throw new Error("outputRange must have at least 1 element");for(const d of o)if(d.kind!==a)throw new TypeError(`Cannot interpolate ${a} values with ${d.kind} values`);const l=Math.max(...o.map(d=>d.dimensions)),c=[null,null,null];if(a!=="scale")for(let d=0;d<l;d++){for(const h of o){const p=h.units[d];if(p!==null){if(c[d]===null){c[d]=p;continue}if(c[d]!==p)throw new TypeError(`Cannot interpolate ${a} values with different units on axis ${d+1}: ${c[d]} and ${p}`)}}if(c[d]===null)throw new TypeError(`Cannot interpolate ${a} values because axis ${d+1} has no unit`)}return kw({kind:a,values:[0,0,0].map((d,h)=>Xm({input:e,inputRange:n,outputRange:o.map(p=>p.values[h]),options:s})),units:c,dimensions:l})},Iw=e=>{var r;const n=(r=e[0])==null?void 0:r.length;if(n===void 0)throw new Error("outputRange must have at least 1 element");if(n===0)throw new TypeError("outputRange tuples must contain at least 1 number");for(const s of e){if(s.length!==n)throw new TypeError(`outputRange tuples must all have the same length, but got ${n} and ${s.length}`);for(const o of s)if(typeof o!="number"||!Number.isFinite(o))throw new TypeError(`outputRange tuples must contain only finite numbers, but got [${s.join(",")}]`)}return n},Fw=({input:e,inputRange:n,outputRange:r,options:s})=>{const o=Iw(r);return new Array(o).fill(!0).map((a,l)=>Xm({input:e,inputRange:n,outputRange:r.map(c=>c[l]),options:s}))};function Rw(e){for(let n=1;n<e.length;++n)if(!(e[n]>e[n-1]))throw new Error(`inputRange must be strictly monotonically increasing but got [${e.join(",")}]`)}function Ff(e,n){if(n.length<1)throw new Error(e+" must have at least 1 element");for(const r of n){if(typeof r!="number")throw new Error(`${e} must contain only numbers`);if(!Number.isFinite(r))throw new Error(`${e} must contain only finite numbers, but got [${n.join(",")}]`)}}function Pw(e,n){if(e===void 0||typeof e=="function")return;const r=n-1;if(e.length!==r)throw new Error(`When easing is an array, it must have one entry per segment between keyframes (length inputRange.length - 1 = ${r}), but got length ${e.length}`);for(let s=0;s<e.length;s++)if(typeof e[s]!="function")throw new Error(`easing[${s}] must be a function`)}function Tw(e){if(e!==void 0&&(typeof e!="number"||!Number.isFinite(e)||e<=0))throw new Error(`posterize must be a positive finite number, but got ${e}`)}
28function Gn(e,n,r,s){if(typeof e>"u")throw new Error("input can not be undefined");if(typeof n>"u")throw new Error("inputRange can not be undefined");if(typeof r>"u")throw new Error("outputRange can not be undefined");if(n.length!==r.length)throw new Error("inputRange ("+n.length+") and outputRange ("+r.length+") must have the same length");if(Ff("inputRange",n),Rw(n),Pw(s==null?void 0:s.easing,n.length),Tw(s==null?void 0:s.posterize),typeof e!="number")throw new TypeError("Cannot interpolate an input which is not a number");if(!Array.isArray(r))throw new Error("outputRange must contain only numbers");if(r.some(a=>typeof a=="string")){if(!r.every(a=>typeof a=="string"||typeof a=="number"))throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");return Mw({input:e,inputRange:n,outputRange:r,options:s})}if(r.every(a=>Array.isArray(a)))return Fw({input:e,inputRange:n,outputRange:r,options:s});if(!r.every(a=>typeof a=="number"))throw new TypeError("outputRange must contain only numbers, numeric tuples, or supported scale, translate, and rotate strings");return Ff("outputRange",r),Xm({input:e,inputRange:n,outputRange:r,options:s})}var Aw=({allowFloats:e,durationInFrames:n,frame:r})=>{if(typeof r>"u")throw new TypeError('Argument missing for parameter "frame"');if(typeof r!="number")throw new TypeError(`Argument passed for "frame" is not a number: ${r}`);if(!Number.isFinite(r))throw new RangeError(`Frame ${r} is not finite`);if(r<0&&r<-n)throw new RangeError(`Cannot use frame ${r}: Duration of composition is ${n}, therefore the lowest frame that can be rendered is ${-n}`);if(r>n-1)throw new RangeError(`Cannot use frame ${r}: Duration of composition is ${n}, therefore the highest frame that can be rendered is ${n-1}`)},$w=e=>{if(!(typeof e>"u")){if(typeof e!="number")throw new TypeError(`A "duration" of a spring must be a "number" but is "${typeof e}"`);if(Number.isNaN(e))throw new TypeError('A "duration" of a spring is NaN, which it must not be');if(!Number.isFinite(e))throw new TypeError('A "duration" of a spring must be finite, but is '+e);if(e<=0)throw new TypeError('A "duration" of a spring must be positive, but is '+e)}},_w={damping:10,mass:1,stiffness:100,overshootClamping:!1},su={};function Dw({animation:e,now:n,config:r}){const{toValue:s,lastTimestamp:o,current:a,velocity:l}=e,c=Math.min(n-o,64);if(r.damping<=0)throw new Error("Spring damping must be greater than 0, otherwise the spring() animation will never end, causing an infinite loop.");const u=r.damping,d=r.mass,h=r.stiffness,p=[s,o,a,l,u,d,h,n].join("-");if(su[p])return su[p];const b=-l,y=s-a,v=u/(2*Math.sqrt(h*d)),w=Math.sqrt(h/d),C=w*Math.sqrt(1-v**2),k=c/1e3,E=Math.sin(C*k),m=Math.cos(C*k),M=Math.exp(-v*w*k),I=M*(E*((b+v*w*y)/C)+y*m),N=s-I,F=v*w*I-M*(m*(b+v*w*y)-C*y*E),R=Math.exp(-w*k),A=s-R*(y+(b+w*y)*k),V=R*(b*(k*w-1)+k*y*w*w),z={toValue:s,prevPosition:a,lastTimestamp:n,current:v<1?N:A,velocity:v<1?F:V};return su[p]=z,z}var ou={};function _x({frame:e,fps:n,config:r={}}){const a=[e,n,r.damping,r.mass,r.overshootClamping,r.stiffness].join("-");if(ou[a])return ou[a];let l={lastTimestamp:0,current:0,toValue:1,velocity:0,prevPosition:0};const c=Math.max(0,e),u=c%1;for(let d=0;d<=Math.floor(c);d++){d===Math.floor(c)&&(d+=u);const h=d/n*1e3;l=Dw({animation:l,now:h,config:{..._w,...r}})}return ou[a]=l,l}var au=new Map;function Lw({fps:e,config:n={},threshold:r=.005}){if(typeof r!="number")throw new TypeError(`threshold must be a number, got ${r} of type ${typeof r}`);if(r===0)return 1/0;if(r===1)return 0;if(isNaN(r))throw new TypeError("Threshold is NaN");if(!Number.isFinite(r))throw new TypeError("Threshold is not finite");if(r<0)throw new TypeError("Threshold is below 0");const s=[e,n.damping,n.mass,n.overshootClamping,n.stiffness,r].join("-");if(au.has(s))return au.get(s);hd(e,"to the measureSpring() function");let o=0,a=0;const l=()=>_x({fps:e,frame:o,config:n});let c=l();const u=()=>Math.abs(c.current-c.toValue);let d=u();for(;d>=r;)o++,c=l(),d=u();a=o;for(let h=0;h<20;h++)o++,c=l(),d=u(),d>=r&&(h=0,a=o+1);return au.set(s,a),a}function Jm({frame:e,fps:n,config:r={},from:s=0,to:o=1,durationInFrames:a,durationRestThreshold:l,delay:c=0,reverse:u=!1}){$w(a),Aw({frame:e,durationInFrames:1/0,allowFloats:!0}),hd(n,"to spring()");const d=u||typeof a<"u",h=d?Lw({fps:n,config:r,threshold:l}):void 0,p=d?{get:()=>h}:{get:()=>{throw new Error("did not calculate natural duration, this is an error with Remotion. Please report")}},y=(u?(a??p.get())-e:e)+(u?c:-c),v=a===void 0?y:y/(a/p.get());if(a&&y>a)return o;const w=_x({fps:n,frame:v,config:r}),C=r.overshootClamping?o>=s?Math.min(w.current,o):Math.max(w.current,o):w.current;return s===0&&o===1?C:Gn(C,[0,1],[s,o])}var Rf=e=>Math.min(1,Math.max(0,e)),iu=30;class To{static step0(n){return n>0?1:0}static step1(n){return n>=1?1:0}static linear(n){return n}static ease(n){return To.bezier(.42,0,1,1)(n)}static quad(n){return n*n}static cubic(n){return n*n*n}static poly(n){return r=>r**n}static sin(n){return 1-Math.cos(n*Math.PI/2)}static circle(n){const r=Rf(n);return 1-Math.sqrt(1-r*r)}static exp(n){return 2**(10*(n-1))}static elastic(n=1){const r=n*Math.PI;return s=>1-Math.cos(s*Math.PI/2)**3*Math.cos(s*r)}static back(n=1.70158){return r=>r*r*((n+1)*r-n)}static spring(n={}){return r=>r<=0?0:r>=1?1:Jm({fps:iu,frame:r*iu,config:n,durationInFrames:iu})}static bounce(n){const r=Rf(n);if(r<1/2.75)return 7.5625*r*r;if(r<2/2.75){const o=r-.5454545454545454;return 7.5625*o*o+.75}if(r<2.5/2.75){const o=r-.8181818181818182;return 7.5625*o*o+.9375}const s=r-2.625/2.75;return 7.5625*s*s+.984375}static bezier(n,r,s,o){return Rx(n,r,s,o)}static in(n){return n}static out(n){return r=>1-n(1-r)}static inOut(n){return r=>r<.5?n(r*2)/2:1-n((1-r)*2)/2}}var Fo="[-+]?\\d*\\.?\\d+",cc=Fo+"%";function dc(...e){return"\\(\\s*("+e.join(")\\s*,\\s*(")+")\\s*\\)"}var uc="(?:none|[-+]?\\d*\\.?\\d+(?:%|deg|rad|grad|turn)?)";function rl(e){return new RegExp(e+"\\(\\s*("+uc+")\\s+("+uc+")\\s+("+uc+")(?:\\s*\\/\\s*("+uc+"))?\\s*\\)")}function Ow(){const e={rgb:void 0,rgba:void 0,hsl:void 0,hsla:void 0,hex3:void 0,hex4:void 0,hex5:void 0,hex6:void 0,hex8:void 0,oklch:void 0,oklab:void 0,lab:void 0,lch:void 0,hwb:void 0};return e.rgb===void 0&&(e.rgb=new RegExp("rgb"+dc(Fo,Fo,Fo)),e.rgba=new RegExp("rgba"+dc(Fo,Fo,Fo,Fo)),e.hsl=new RegExp("hsl"+dc(Fo,cc,cc)),e.hsla=new RegExp("hsla"
28+dc(Fo,cc,cc,Fo)),e.hex3=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,e.hex4=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,e.hex6=/^#([0-9a-fA-F]{6})$/,e.hex8=/^#([0-9a-fA-F]{8})$/,e.oklch=rl("oklch"),e.oklab=rl("oklab"),e.lab=rl("lab"),e.lch=rl("lch"),e.hwb=rl("hwb")),e}function Oi(e,n,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(n-e)*6*r:r<1/2?n:r<2/3?e+(n-e)*(2/3-r)*6:e}function Pf(e,n,r){const s=r<.5?r*(1+n):r+n-r*n,o=2*r-s,a=Oi(o,s,e+1/3),l=Oi(o,s,e),c=Oi(o,s,e-1/3);return Math.round(a*255)<<24|Math.round(l*255)<<16|Math.round(c*255)<<8}function Ni(e){const n=Number.parseInt(e,10);return n<0?0:n>255?255:n}function Tf(e){return(Number.parseFloat(e)%360+360)%360/360}function Af(e){const n=Number.parseFloat(e);return n<0?0:n>1?255:Math.round(n*255)}function mc(e){const n=Number.parseFloat(e);return n<0?0:n>100?1:n/100}function uo(e,n){return e==="none"?0:e.endsWith("%")?Number.parseFloat(e)/100*n:Number.parseFloat(e)}function lu(e){return e==="none"?0:e.endsWith("rad")?Number.parseFloat(e)*180/Math.PI:e.endsWith("grad")?Number.parseFloat(e)*.9:e.endsWith("turn")?Number.parseFloat(e)*360:Number.parseFloat(e)}function sl(e){return e===void 0||e==="none"?1:e.endsWith("%")?Math.max(0,Math.min(1,Number.parseFloat(e)/100)):Math.max(0,Math.min(1,Number.parseFloat(e)))}function Vi(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function pc(e){return Math.max(0,Math.min(1,e))}function ol(e,n,r,s){const o=Math.round(pc(e)*255),a=Math.round(pc(n)*255),l=Math.round(pc(r)*255),c=Math.round(pc(s)*255);return(o<<24|a<<16|l<<8|c)>>>0}function $f(e,n,r){const s=e+.3963377774*n+.2158037573*r,o=e-.1055613458*n-.0638541728*r,a=e-.0894841775*n-1.291485548*r,l=s*s*s,c=o*o*o,u=a*a*a,d=4.0767416621*l-3.3077115913*c+.2309699292*u,h=-1.2684380046*l+2.6097574011*c-.3413193965*u,p=-.0041960863*l-.7034186147*c+1.707614701*u;return[Vi(d),Vi(h),Vi(p)]}function _f(e,n,r){const s=.008856451679035631,o=24389/27,a=.95047,l=1,c=1.08883,u=(e+16)/116,d=n/500+u,h=u-r/200,p=d*d*d,b=h*h*h,y=p>s?p:(116*d-16)/o,v=e>o*s?((e+16)/116)**3:e/o,w=b>s?b:(116*h-16)/o,C=y*a,k=v*l,E=w*c,m=3.2404542*C-1.5371385*k-.4985314*E,M=-.969266*C+1.8760108*k+.041556*E,I=.0556434*C-.2040259*k+1.0572252*E;return[Vi(m),Vi(M),Vi(I)]}function Vw(e,n,r){if(n+r>=1){const d=n/(n+r);return[d,d,d]}const s=1,o=0,a=Oi(o,s,e+1/3),l=Oi(o,s,e),c=Oi(o,s,e-1/3),u=1-n-r;return[a*u+n,l*u+n,c*u+n]}var Df={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199};function Uw(e){const n=Ow();let r;if(n.hex6&&(r=n.hex6.exec(e)))return Number.parseInt(r[1]+"ff",16)>>>0;if(Df[e]!==void 0)return Df[e];if(n.rgb&&(r=n.rgb.exec(e)))return(Ni(r[1])<<24|Ni(r[2])<<16|Ni(r[3])<<8|255)>>>0;if(n.rgba&&(r=n.rgba.exec(e)))return(Ni(r[1])<<24|Ni(r[2])<<16|Ni(r[3])<<8|Af(r[4]))>>>0;if(n.hex3&&(r=n.hex3.exec(e)))return Number.parseInt(r[1]+r[1]+r[2]+r[2]+r[3]+r[3]+"ff",16)>>>0;if(n.hex8&&(r=n.hex8.exec(e)))return Number.parseInt(r[1],16)>>>0;if(n.hex4&&(r=n.hex4.exec(e)))return Number.parseInt(r[1]+r[1]+r[2]+r[2]+r[3]+r[3]+r[4]+r[4],16)>>>0;if(n.hsl&&(r=n.hsl.exec(e)))return(Pf(Tf(r[1]),mc(r[2]),mc(r[3]))|255)>>>0;if(n.hsla&&(r=n.hsla.exec(e)))return(Pf(Tf(r[1]),mc(r[2]),mc(r[3]))|Af(r[4]))>>>0;if(n.oklch&&(r=n.oklch.exec(e))){const s=uo(r[1],1),o=uo(r[2],.4),a=lu(r[3]),l=sl(r[4]),c=a*Math.PI/180,[u,d,h]=$f(s,o*Math.cos(c),o*Math.sin(c));return ol(u,d,h,l)}if(n.oklab&&(r=n.oklab.exec(e))){const s=uo(r[1],1),o=uo(r[2],.4),a=uo(r[3],.4),l=sl(r[4]),[c,u,d]=$f(s,o,a);return ol(c,u,d,l)}if(n.lab&&(r=n.lab.exec(e))){const s=uo(r[1],100),o=uo(r[2],125),a=uo(r[3],125),l=sl(r[4]),[c,u,d]=_f(s,o,a);return ol(c,u,d,l)}if(n.lch&&(r=n.lch.exec(e))){const s=uo(r[1],100),o=uo(r[2],150),a=lu(r[3]),l=sl(r[4]),c=a*Math.PI/180,[u,d,h]=_f(s,o*Math.cos(c),o*Math.sin(c));return ol(u,d,h,l)}if(n.hwb&&(r=n.hwb.exec(e))){const s=lu(r[1]),o=uo(r[2],1),a=uo(r[3],1),l=sl(r[4]),[c,u,d]=Vw(s/360,o,a);return ol(c,u,d,l)}throw new Error(`invalid color string ${e} provided`)}var Lf=e=>(e>>24&255)/255,zw=e=>e>>16&255,Bw=e=>e>>8&255,Hw=e=>
28e&255,Kw=(e,n,r,s)=>`rgba(${e}, ${n}, ${r}, ${s})`;function Ww(e){const n=Uw(e);return(n<<24|n>>>8)>>>0}var Yw=(e,n,r,s)=>{const[o,a,l,c]=[zw,Bw,Hw,Lf].map(u=>{const d=Gn(e,n,r.map(h=>u(h)),{easing:s==null?void 0:s.easing,extrapolateLeft:"clamp",extrapolateRight:"clamp",posterize:s==null?void 0:s.posterize});return u===Lf?Number(d.toFixed(3)):Math.round(d)});return Kw(o,a,l,c)},Gw=(e,n,r,s)=>{if(typeof e>"u")throw new TypeError("input can not be undefined");if(typeof n>"u")throw new TypeError("inputRange can not be undefined");if(typeof r>"u")throw new TypeError("outputRange can not be undefined");if(n.length!==r.length)throw new TypeError("inputRange ("+n.length+" values provided) and outputRange ("+r.length+" values provided) must have the same length");const o=r.map(a=>Ww(a));return Yw(e,n,o,s)},Of=e=>e==="linear"?To.linear:Rx(e[0],e[1],e[2],e[3]),Yl=({frame:e,status:n})=>{const{keyframes:r,easing:s,clamping:o,interpolationFunction:a}=n;if(r.length===0)return null;const l=[...r].sort((d,h)=>d.frame-h.frame),c=l.map(d=>d.frame),u=l.map(d=>d.value);if(a==="interpolateColors"){if(!u.every(d=>typeof d=="string"))return null;if(r.length===1)return u[0];try{return Gw(e,c,u,{easing:s.map(Of),posterize:n.posterize})}catch{return null}}if(a!=="interpolate")return null;try{return Gn(e,c,u,{easing:s.map(Of),extrapolateLeft:o.left,extrapolateRight:o.right,posterize:n.posterize})}catch{return null}},Sd=({dragOverrideValue:e,frame:n})=>{if(e===void 0)return{type:"none"};if(e.type==="static")return{type:"resolved",value:e.value};if(n===null)return{type:"none"};const r=Yl({frame:n,status:e.status});return r===null?{type:"none"}:{type:"resolved",value:r}},Dx=({propStatus:e,dragOverrideValue:n,defaultValue:r,frame:s=null,shouldResortToDefaultValueIfUndef
28ined:o=!1})=>{const a=Sd({dragOverrideValue:n,frame:s});return a.type==="resolved"&&a.value!==void 0?a.value:e.status==="keyframed"?s!==null?Yl({frame:s,status:e}):o?r:void 0:e.codeValue===void 0&&o?r:e.codeValue},Zm=i.createContext({overrideIdToNodePathMappings:{}}),qw=i.createContext({setOverrideIdToNodePath:()=>{throw new Error("OverrideIdsToNodePathsSettersContext not initialized")}}),Xw=({descriptor:e,propStatusOverrides:n,dragOverrides:r,frame:s})=>{if(!n&&!r)return{params:e.params,effectKey:e.effectKey};const o={...e.params};if(n)for(const[a,l]of Object.entries(n))l!==void 0&&(o[a]=l);if(r)for(const[a,l]of Object.entries(r)){const c=Sd({dragOverrideValue:l,frame:s});c.type==="resolved"&&(o[a]=c.value)}return{params:o,effectKey:e.definition.calculateKey(o)}},Jw=(e,n)=>{if(!e)return null;const r={};let s=!1;for(const[o,a]of Object.entries(e)){if(a.status==="static"){r[o]=a.codeValue,s=!0;continue}if(a.status==="keyframed"){const l=Yl({frame:n,status:a});l!==null&&(r[o]=l,s=!0)}}return s?r:null},Gl=e=>{const n=i.useRef(null),r=e.map(a=>a.definition),s=n.current;return s!==null&&s.length===r.length&&s.every((a,l)=>a===r[l])?s:(n.current=r,r)},Lx=({propStatuses:e,nodePath:n,effectIndex:r})=>{const s=e[ha(n)];if(!s)return{type:"cannot-update-sequence",reason:"not-found"};if(!s.canUpdate)return{type:"cannot-update-sequence",reason:s.reason};const o=s.effects.find(a=>a.effectIndex===r);return o?o.canUpdate?{type:"can-update-effect",props:o.props}:{type:"cannot-update-effect",reason:o.reason}:{type:"cannot-update-effect",reason:"not-found"}},Ox=(e,n)=>{const r=e[ha(n)];if(r&&r.canUpdate)return r.props},ql=({effects:e,overrideId:n})=>{const r=i.useRef(null),{propStatuses:s}=i.useContext(wd),{getEffectDragOverrides:o}=i.useContext(Nd),a=xs(),{overrideIdToNodePathMappings:l}=i.useContext(Zm),c=r.current,u=n?l[n]??null:null,d=e.map((b,y)=>{if(u===null)return{descriptor:b,params:b.params,effectKey:b.effectKey};const v=Lx({propStatuses:s,nodePath:u,effectIndex:y}),w=v.type==="can-update-effect"?Jw(v.props,a):null,C=o(u,y),k=Object.keys(C).length===0?null:C,{params:E,effectKey:m}=Xw({descriptor:b,propStatusOverrides:w,dragOverrides:k,frame:a});return{descriptor:b,params:E,effectKey:m}});if(c!==null&&c.length===d.length&&c.every((b,y)=>b.definition===d[y].descriptor.definition&&b.effectKey===d[y].effectKey))return c;const p=d.map(({descriptor:b,params:y,effectKey:v})=>({definition:b.definition,effectKey:v,params:y,memoized:!0}));return r.current=p,p},Qm=(e,n)=>{const r={};for(const s of Object.keys(e)){const o=e[s];if(o.type!=="hidden")if(o.type==="enum"){r[s]=o;const a=n(s)??o.default,l=o.variants[a];l&&Object.assign(r,Qm(l,n))}else r[s]=o}return r},ep=e=>{const n={},r=(s,o)=>
28{if(s in n)throw new Error(`Duplicate key "${s}" in schema: discriminated union variants must not share keys`);n[s]=o};for(const s of Object.keys(e)){const o=e[s];if(r(s,o),o.type==="enum")for(const a of Object.values(o.variants)){const l=ep(a);for(const c of Object.keys(l))r(c,l[c])}}return n},Vx=({schema:e,key:n,value:r})=>{const s=e[n];if(!s)throw new Error("Key "+JSON.stringify(n)+" not found in schema");if(typeof r!="string")throw new Error("Value must be a string, but is "+JSON.stringify(r));if(s.type!=="enum")throw new Error("Key "+JSON.stringify(n)+" is not an enum");if(!s.variants[r])throw new Error("Value for "+JSON.stringify(n)+" must be one of "+Object.keys(s.variants).map(c=>JSON.stringify(c)).join(", ")+", got "+JSON.stringify(r));const a=Object.keys(s.variants).filter(c=>c!==r),l=new Set;for(const c of a){const u=s.variants[c],d=Object.keys(u);for(const h of d)l.add(h)}return[...l]},Zw=e=>({type:"static",value:e}),Qw=({status:e,frame:n,value:r})=>{const s=e.keyframes.findIndex(l=>l.frame===n),o=s===-1?[...e.keyframes,{frame:n,value:r}].sort((l,c)=>l.frame-c.frame):e.keyframes.map((l,c)=>c===s?{frame:n,value:r}:l),a=[...e.easing];for(;a.length<o.length-1;)a.push("linear");return a.length>o.length-1&&(a.length=o.length-1),{type:"keyframed",status:{...e,keyframes:o,easing:a}}},e2=e=>{if((e==null?void 0:e.type)==="static")return e.value},t2=e=>e!==null&&e.status==="keyframed",Ux=(e,n)=>{if(n in e)return e[n];for(const r of Object.values(e))if(r.type==="enum")for(const s of Object.values(r.variants)
28){const o=Ux(s,n);if(o)return o}},zx=({schema:e,currentValue:n,overrideValues:r,propStatus:s,frame:o})=>{var c;const a={},l=new Set;for(const u of Object.keys(n)){const d=(s==null?void 0:s[u])??null,h=Ux(e,u);if((h==null?void 0:h.type)==="hidden")continue;let p;if(d===null)p=n[u];else if(t2(d))if((h==null?void 0:h.type)==="array"||(h==null?void 0:h.keyframable)===!1)p=n[u];else{const b=Sd({dragOverrideValue:r[u],frame:o});b.type==="resolved"?p=b.value:o!==null?p=Yl({frame:o,status:d})??n[u]:p=n[u]}else d.status==="computed"?p=n[u]:p=Dx({propStatus:d,dragOverrideValue:r[u],defaultValue:h==null?void 0:h.default,frame:o,shouldResortToDefaultValueIfUndefined:!1});p===void 0&&l.add(u),a[u]=p}for(const u of Object.keys(r))if(((c=e[u])==null?void 0:c.type)==="enum"){const d=Vx({schema:e,key:u,value:a[u]});for(const h of d)l.add(h)}return{merged:a,propsToDelete:l}},Bx=(e,n)=>{const r=n.split(".");let s=e;for(const o of r){if(s==null||typeof s!="object")return;s=s[o]}return s},n2=(e,n)=>{const r={};for(const s of n)r[s]=Bx(e,s);return r},r2=(e,n)=>Object.keys(Qm(e,r=>n[r])),s2=({props:e,valuesDotNotation:n,schemaKeys:r,propsToDelete:s})=>{const o={...e};for(const a of r){const l=n[a],c=a.split(".");if(c.length===1){o[a]=l;continue}let u=o;for(let d=0;d<c.length-1;d++){const h=c[d];typeof u[h]=="object"&&u[h]!==null?u[h]={...u[h]}:u[h]={},u=u[h]}u[c[c.length-1]]=l}return cw(o,s),o},Vf={},Zo=({Component:e,componentIdentity:n,schema:r,supportsEffects:s})=>{const o=qm(r),a=ep(o),l=Object.keys(a),c=i.forwardRef((u,d)=>{const h=Pr();if(!h.isStudio||h.isReadOnlyStudio||h.isRendering)return qe.createElement(e,{...u,_experimentalControls:null,ref:d});const{propStatuses:p}=i.useContext(wd),{getDragOverrides:b}=i.useContext(Nd),y=i.useContext(Zm),v=xs();if(u._experimentalControls)return qe.createElement(e,{...u,ref:d});const[w]=i.useState(()=>{const{stack:R}=u;if(!R)return String(Math.random());const A=Vf[R];if(A)return A;const V=String(Math.random());return Vf[R]=V,V}),C=y.overrideIdToNodePathMappings[w]??null,k=l.map(R=>Bx(u,R)),E=i.useMemo(()=>n2(u,l),k),m=i.useMemo(()=>({schema:o,currentRuntimeValueDotNotation:E,overrideId:w,supportsEffects:s,componentIdentity:n}),[E,w]),{merged:M,propsToDelete:I}=i.useMemo(()=>zx({schema:o,currentValue:E,overrideValues:C===null?{}:b(C),propStatus:C===null?void 0:Ox(p,C),frame:v}),[E,b,C,p,v]),N=r2(o,M),F=s2({props:u,valuesDotNotation:M,schemaKeys:N,propsToDelete:I});return qe.createElement(e,{...F,_experimentalControls:m,ref:d})});return c.displayName=`wrapInSchema(${e.displayName||e.name||"Component"})`,c},cu=[],o2=({from:e=0,freeze:n,durationInFrames:r=1/0,children:s,name:o,height:a,width:l,showInTimeline:c=!0,hidden:u=!1,_experimentalControls:d,_remotionInternalEffects:h,_remotionInternalLoopDisplay:p,_remotionInternalStack:b,_remotionInternalDocumentationLink:y,_remotionInternalPremountDisplay:v,_remotionInternalPostmountDisplay:w,_remotionInternalIsMedia:C,_remotionInternalRefForOutline:k,...E},m)=>{const{layout:M="absolute-fill"}=E,[I]=i.useState(()=>String(Math.random())),N=i.useContext(Rr),{rootId:F}=Va(),R=N?N.cumulatedFrom+N.relativeFrom:0,A=((N==null?void 0:N.absoluteFrom)??0)+e,V=md();if(M!=="absolute-fill"&&M!=="none")throw new TypeError(`The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${M}`);if(M==="none"&&typeof E.style<"u")throw new TypeError('If layout="none", you may not pass a style. Passed: '+JSON.stringify(E.style));if(typeof r!="number")throw new TypeError(`You passed to durationInFrames an argument of type ${typeof r}, but it must be a number.`);if(r<=0)throw new TypeError(`durationInFrames must be positive, but got ${r}`);if(typeof e!="number")throw new TypeError(`You passed to the "from" props of your <Sequence> an argument of type ${typeof e}, but it must be a number.`);if(!Number.isFinite(e))throw new TypeError(`The "from" prop of a sequence must be finite, but got ${e}.`);if(typeof n<"u"&&n!==null){if(typeof n!="number")throw new TypeError(`The "freeze" prop of <Sequence /> must be a number, but is of type ${typeof n}.`);if(Number.isNaN(n))throw new TypeError('The "freeze" prop of <Sequence /> must be a real number, but it is NaN.');if(!Number.isFinite(n))throw new TypeError(`The "freeze" prop of <Sequence /> must be finite, but it is ${n}.`)}const z=Ua(),H=as(),ne=N?Math.min(N.durationInFrames-e,r):r,se=Math.max(0,Math.min(H.durationInFrames-e,ne)),{registerSequence:pe,unregisterSequence:ie}=i.useContext(qi),O=i.useRef(null),D=E.layout==="none"?k??null:k??O,W=i.useMemo(()=>(N==null?void 0:N.premounting)||!!E._remotionInternalIsPremounting,[E._remotionInternalIsPremounting,N==null?void 0:N.premounting]),oe=i.useMemo(()=>(N==null?void 0:N.postmounting)||!!E._remotionInternalIsPostmounting,[E._remotionInternalIsPostmounting,N==null?void 0:N.postmounting]),we=R+e,Re=N?N.cumulatedFrom+N.relativeFrom:0,le=N?Re-N.cumulatedNegativeFrom:0,Ne=Math.max(0,le,we),ce=we-Ne,Ae=i.useMemo(()=>({absoluteFrom:A,cumulatedFrom:R,relativeFrom:e,cumulatedNegativeFrom:ce,durationInFrames:se,parentFrom:(N==null?void 0:N.relativeFrom)??0,id:I,height:a??(N==null?void 0:N.height)??null,width:l??(N==null?void 0:N.width)??null,premounting:W,postmounting:oe,premountDisplay:v??null,postmountDisplay:w??null}),[R,A,e,se,N,I,a,l,W,oe,v,w,ce]),De=i.useMemo(()=>o??"",[o]),Ze=y??"https://www.remotion.dev/docs/sequence",Ye=Pr(),at=i.useContext(kd),ut=(E==null?void 0:E.stack)??null,Xe=i.useRef(null);Xe.current=b??ut;const nt=typeof n=="number"?n:null,xt=(N==null?void 0:N.cumulatedNegativeFrom)??0,J=C&&C.type!=="image"?C.data.startMediaFrom+xt-ce:null,Ie=C&&C.type!=="image"?C.data.startMediaFrom+xt:null,ht=C&&C.type!=="image"&&Ie!==null?nt===null?null:Ie+(p?nt%p.durationInFrames:nt)*C.data.playbackRate:null;i.useEffect(()=>{if(Ye.isStudio)return C?(C.type==="image"?pe({type:"image",controls:d??null,effects:h??cu,displayName:
28De,documentationLink:Ze,duration:se,from:e,id:I,loopDisplay:p,nonce:V.get(),parent:(N==null?void 0:N.id)??null,postmountDisplay:w??null,premountDisplay:v??null,rootId:F,showInTimeline:c,src:C.src,getStack:()=>Xe.current,refForOutline:D??null,isInsideSeries:at,frozenFrame:nt}):pe({type:C.type,controls:d??null,effects:h??cu,displayName:De,documentationLink:Ze,doesVolumeChange:C.data.doesVolumeChange,duration:se,from:e,id:I,loopDisplay:p,nonce:V.get(),parent:(N==null?void 0:N.id)??null,playbackRate:C.data.playbackRate,postmountDisplay:w??null,premountDisplay:v??null,rootId:F,showInTimeline:c,src:C.data.src,getStack:()=>Xe.current,startMediaFrom:J??C.data.startMediaFrom,volume:C.data.volumes,refForOutline:D??null,isInsideSeries:at,frozenFrame:nt,frozenMediaFrame:ht}),()=>{ie(I)}):(pe({from:e,duration:se,id:I,displayName:De,documentationLink:Ze,parent:(N==null?void 0:N.id)??null,type:"sequence",rootId:F,showInTimeline:c,nonce:V.get(),loopDisplay:p,getStack:()=>Xe.current,premountDisplay:v??null,postmountDisplay:w??null,controls:d??null,effects:h??cu,refForOutline:D??null,isInsideSeries:at,frozenFrame:nt}),()=>{ie(I)})},[r,I,o,pe,De,ie,N==null?void 0:N.id,se,F,e,c,V,p,v,w,Ye.isStudio,d,h,C,Ze,D,at,nt,J,ht]);const Et=Math.ceil(R+e+r-1),Ft=z<R+e||z>Et?null:s,Rt=Ft===null||typeof n>"u"||n===null?Ft:t.jsx(wx,{frame:n,children:Ft}),Pt=E.layout==="none"?void 0:E.style,Ht=i.useCallback(Kt=>{O.current=Kt,typeof m=="function"?m(Kt):m&&(m.current=Kt)},[m]),Gt=i.useMemo(()=>({flexDirection:void 0,...l?{width:l}:{},...a?{height:a}:{},...Pt??{}}),[a,Pt,l]);if(m!==null&&M==="none")throw new TypeError('It is not supported to pass both a `ref` and `layout="none"` to <Sequence />.');return u?null:t.jsx(Rr.Provider,{value:Ae,children:Rt===null?null:E.layout==="none"?Rt:t.jsx(pd,{ref:Ht,style:Gt,className:E.className,children:Rt})})},a2=i.forwardRef(o2),i2=(e,n)=>{const r=i.useContext(jx),s=xs()-r.premountFramesRemaining;if(e.layout==="none")throw new Error('`<Sequence>` with `premountFor` and `postmountFor` props does not support layout="none"');const{style:o,from:a=0,durationInFrames:l=1/0,premountFor:c=0,postmountFor:u=0,styleWhilePremounted:d,styleWhilePostmounted:h,...p}=e,b=Math.ceil(a+l-1),y=s<a&&s>=a-c,v=s>b&&s<=b+u,w=y?a:v?a+l-1:0,C=y||v,k=i.useMemo(()=>({...o,opacity:y||v?0:1,pointerEvents:y||v?"none":(o==null?void 0:o.pointerEvents)??void 0,...y?d:{},...v?h:{}}),[o,y,v,d,h]);return t.jsx(wx,{frame:w,active:C,children:t.jsx(Cd,{ref:n,from:a,durationInFrames:l,style:k,_remotionInternalPremountDisplay:c,_remotionInternalPostmountDisplay:u,_remotionInternalIsPremounting:y,_remotionInternalIsPostmounting:v,...p})})},l2=i.forwardRef(i2),c2=(e,n)=>{const r=Pr(),{fps:s}=as();if(e.layout!=="none"&&!r.isRendering){const o=e.premountFor;if(o||e.postmountFor)return t.jsx(l2,{ref:n,...e,premountFor:o})}return t.jsx(a2,{...e,ref:n})},Cd=i.forwardRef(c2),Hx=Cd,Ir=Zo({Component:Cd,componentIdentity:"dev.remotion.remotion.Sequence",schema:Vl,supportsEffects:!1});Zo({Component:Cd,componentIdentity:null,schema:rw,supportsEffects:!1});var Kx=(e,n,r)=>{switch(e){case"fill":return[0,0,n.width,n.height,0,0,r.width,r.height];case"contain":{const s=Math.min(r.width/n.width,r.height/n.height),o=(r.width-n.width*s)/2,a=(r.height-n.height*s)/2;return[0,0,n.width,n.height,o,a,n.width*s,n.height*s]}case"cover":{const s=Math.max(r.width/n.width,r.height/n.height),o=(r.width-n.width*s)/2,a=(r.height-n.height*s)/2;return[0,0,n.width,n.height,o,a,n.width*s,n.height*s]}default:throw new Error("Unknown fit: "+e)}},d2="https://remotion.dev/docs/troubleshooting/webgl2-context",Wx=(e,n)=>`Failed to acquire ${e} context for ${n}. Pass --gl=angle when using the CLI, set chromiumOptions: { gl: "angle" } when using SSR APIs, or set "OpenGL render backend" to "angle" in the Advanced section when rendering in the Studio. See ${d2}`,u2=e=>new Error(Wx("WebGL",e)),Yx=e=>new Error(Wx("WebGL2",e));class m2{constructor(n,r){fn(this,"width");fn(this,"height");fn(this,"pairs",new Map);fn(this,"lostContexts",new Set);this.width=n,this.height=r}getPair(n){const r=this.pairs.get(n);if(r)return r;const s=[this.allocateCanvas(n),this.allocateCanvas(n)];return this.pairs.set(n,s),s}assertContextNotLost(n){if(this.lostContexts.has(n))throw new Error("WebGL context was lost during canvas effect rendering. This typically happens in headless or memory-constrained environments (e.g. Remotion Lambda). Try reducing concurrency or increasing the Lambda function memory.")}allocateCanvas(n){const r=document.createElement("canvas");switch(r.width=this.width,r.height=this.height,n){case"2d":{if(!r.getContext("2d",{colorSpace:"srgb"}))throw new Error("Failed to acquire 2D context for canvas effect");return r}case"webgl2":{const s=r.getContext("webgl2",{premultipliedAlpha:!0,alpha:!0,preserveDrawingBuffer:!0});if(!s)throw Yx("canvas effect");return r.addEventListener("webglcontextlost",o=>{o.preventDefault(),this.lostContexts.add(r)}),r.addEventListener("webglcontextrestored",()=>{this.lostContexts.delete(r)}),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),r}case"webgpu":{if(typeof navigator>"u"||!("gpu"in navigator))throw new Error("WebGPU is not available in this environment for canvas effect");return r}default:{const s=n;throw new Error(`Unknown effect backend: ${s}`)}}}}var p2=e=>{const n=[];let r=[],s=null;for(const o of e){const{backend:a}=o.definition;s===null||a===s?(r.push(o),s=a):(n.push({backend:s,effects:r}),r=[o],s=a)}return s!==null&&r.length>0&&n.push({backend:s,effects:r}),n},fc=null,f2=()=>fc||(fc=(async()=>
28{if(typeof navigator>"u"||!("gpu"in navigator))throw new Error("WebGPU is not available in this environment");const{gpu:e}=navigator,n=await e.requestAdapter();if(!n)throw new Error("No WebGPU adapter available");return n.requestDevice()})(),fc),Gx=(e,n)=>({pool:new m2(e,n),setupCache:new WeakMap,cleanupRegistry:[],currentRunId:0}),am=e=>{e.currentRunId++;for(const n of e.cleanupRegistry)n.definition.cleanup(n.state)},h2=(e,n,r)=>{const s=n;let o=e.setupCache.get(s);if(o||(o=new WeakMap,e.setupCache.set(s,o)),o.has(r))return o.get(r);const a=n.setup(r);return o.set(r,a),e.cleanupRegistry.push({definition:s,state:a}),a},Xl=async({state:e,source:n,effects:r,output:s,width:o,height:a})=>{const l=++e.currentRunId,c=()=>e.currentRunId!==l,u=r.filter(C=>!C.params.disabled),d=p2(u);let h=n,p=null;if(d.length===0){if(n===s)return!0;const C=s.getContext("2d");if(!C)throw new Error("Failed to acquire 2D context for output canvas");return C.clearRect(0,0,o,a),C.drawImage(h,0,0,o,a),!0}let b=!1;for(const C of d)if(C.backend==="webgpu"){b=!0;break}const y=b?await f2():null;if(c())return!1;let v=!0;for(let C=0;C<d.length;C++){const k=d[C],[E,m]=e.pool.getPair(k.backend);let M=E;for(const N of k.effects){const F=N.definition,R=h2(e,F,M);F.apply({source:h,target:M,state:R,params:N.params,width:o,height:a,gpuDevice:y,flipSourceY:k.backend==="webgl2"?v:!1}),k.backend==="webgl2"&&(v=!0,e.pool.assertContextNotLost(M)),h=M,M=M===E?m:E}p=h??p;const I=d[C+1];if(I&&I.backend!==k.backend&&p)if(k.backend==="2d"&&I.backend==="webgl2")h=p,v=!0;else{const N=await createImageBitmap(p);if(c())return N.close(),!1;h=N,I.backend==="webgl2"&&(v=!1)}}if(!p)return!0;const w=s.getContext("2d");if(!w)throw new Error("Failed to acquire 2D context for output canvas");return w.clearRect(0,0,o,a),w.drawImage(p,0,0,o,a),!0},Jl=()=>{const e=i.useRef(null),n=i.useRef(null);return i.useEffect(()=>()=>{e.current&&am(e.current)},[]),i.useMemo(()=>({get:(r,s)=>((!n.current||n.current.width!==r||n.current.height!==s)&&(e.current&&am(e.current),e.current=Gx(r,s),n.current={width:r,height:s}),e.current)}),[])},x2=({width:e,height:n,fit:r,className:s,style:o,effects:a},l)=>{const c=i.useRef(null),u=Jl(),d=i.useMemo(()=>typeof document>"u"?null:document.createElement("canvas"),[]),h=i.useCallback(p=>{const b=c.current,y=e??p.displayWidth,v=n??p.displayHeight;if(!b)throw new Error("Canvas ref is not set");if(!d)throw new Error("Source canvas is not available");d.width=y,d.height=v;const w=d.getContext("2d");if(!w)throw new Error("Could not get 2d context for source canvas");return w.drawImage(p,...Kx(r,{height:p.displayHeight,width:p.displayWidth},{width:y,height:v})),b.width=y,b.height=v,Xl({state:u.get(y,v),source:d,effects:a,output:b,width:y,height:v})},[u,a,r,n,d,e]);return i.useImperativeHandle(l,()=>({draw:h,getCanvas:()=>{if(!c.current)throw new Error("Canvas ref is not set");return c.current},clear:()=>{var b;const p=(b=c.current)==null?void 0:b.getContext("2d");if(!p)throw new Error("Could not get 2d context");p.clearRect(0,0,c.current.width,c.current.height)}}),[h]),t.jsx("canvas",{ref:c,className:s,style:o})},g2=qe.forwardRef(x2),b2=5,Uf=({loopBehavior:e,durationFound:n,timeInSec:r})=>e==="loop"?n?r%n:r:Math.min(r,n||1/0),y2=async({resolvedSrc:e,signal:n,requestInit:r,currentTime:s,initialLoopBehavior:o})=>{if(typeof ImageDecoder>"u")throw new Error("Your browser does not support the WebCodecs ImageDecoder API.");const a=await fetch(e,{...r,signal:n}),{body:l}=a;if(!l)throw new Error("Got no body");const c=new ImageDecoder({data:l,type:a.headers.get("Content-Type")||"image/gif"});await c.completed;const{selectedTrack:u}=c.tracks;if(!u)throw new Error("No selected track");const d=[];let h=null;const p=async w=>{const C=d.find(E=>E.frameIndex===w);if(C&&C.frame)return C;const k=await c.decode({frameIndex:w,completeFramesOnly:!0});return C?C.frame=k.image:d.push({frame:k.image,frameIndex:w,timeInSeconds:k.image.timestamp/1e6}),{frame:k.image,frameIndex:w,timeInSeconds:k.image.timestamp/1e6}},b=w=>{const k=d.filter(E=>E.frame).sort((E,m)=>{const M=Math.abs(E.timeInSeconds-w),I=Math.abs(m.timeInSeconds-w);return M-I});for(let E=0;E<k.length;E++){if(E<b2)continue;const m=k[E];m.frame=null}},y=async({timeInSec:w,loopBehavior:C})=>{const k=Uf({durationFound:h,loopBehavior:C,timeInSec:w}),m=d.filter(I=>I.timeInSeconds<=k).map(I=>I.frameIndex).reduce((I,N)=>Math.max(I,N),0);let M=m;for(;;){const I=await p(M);if(M++,!I.frame)throw new Error("No frame found");if(!I.frame.duration||(M===u.frameCount&&h===null&&(h=(I.frame.timestamp+I.frame.duration)/1e6),I.timeInSeconds>k||M===u.frameCount))break}u.frameCount-m<3&&C==="loop"&&await p(0),b(k)};return await y({timeInSec:s,loopBehavior:o}),await y({timeInSec:s,loopBehavior:o}),{getFrame:async(w,C)=>{if(h!==null&&w>h&&C==="clear-after-finish")return null;
28const k=Uf({loopBehavior:C,durationFound:h,timeInSec:w});await y({timeInSec:k,loopBehavior:C});const m=d.filter(M=>M.frame).reduce((M,I)=>{const N=Math.abs(M.timeInSeconds-k),F=Math.abs(I.timeInSeconds-k);return N<F?M:I});if(!m.frame)throw new Error("No frame found");return m},frameCount:u.frameCount}},v2=e=>{if(!e)return null;const n={...e};delete n.signal;const{headers:r,...s}=n;return JSON.stringify({...s,headers:r?Array.from(new Headers(r).entries()):null})},w2=e=>typeof window>"u"?e:new URL(e,window.origin).href,j2={durationInFrames:va,from:Ba,freeze:wa,playbackRate:{type:"number",min:0,max:10,step:.1,default:1,description:"Playback rate",hiddenFromList:!1,keyframable:!1},...za,hidden:ya},qx=i.forwardRef(({src:e,width:n,height:r,onError:s,loopBehavior:o="loop",playbackRate:a=1,fit:l="fill",requestInit:c,effects:u,controls:d,...h},p)=>{const b=w2(e),[y,v]=i.useState(null),{delayRender:w,continueRender:C}=$o(),[k]=i.useState(()=>w(`Rendering <AnimatedImage/> with src="${b}"`)),E=xs(),{fps:m}=as(),M=E/a/m,I=i.useRef(M);I.current=M;const N=v2(c),F=i.useRef(c);F.current=c;const R=i.useRef(null),A=ql({effects:u,overrideId:(d==null?void 0:d.overrideId)??null});i.useImperativeHandle(p,()=>{var H;const z=(H=R.current)==null?void 0:H.getCanvas();if(!z)throw new Error("Canvas ref is not set");return z},[]);const[V]=i.useState(()=>o);return i.useEffect(()=>{const z=new AbortController;return y2({resolvedSrc:b,signal:z.signal,requestInit:F.current,currentTime:I.current,initialLoopBehavior:V}).then(H=>{v(H),C(k)}).catch(H=>{if(H.name==="AbortError"){C(k);return}s?(s==null||s(H),C(k)):Ol(H)}),()=>{z.abort()}},[b,k,s,N,V,C]),i.useLayoutEffect(()=>{if(!y)return;const z=w(`Rendering frame at ${M} of <AnimatedImage src="${e}"/>`);let H=!1;return y.getFrame(M,o).then(async ne=>{var pe,ie;if(H)return;if(ne===null){(pe=R.current)==null||pe.clear(),C(z);return}await((ie=R.current)==null?void 0:ie.draw(ne.frame))&&!H&&C(z)}).catch(ne=>{H||(s?(s(ne),C(z)):Ol(ne))}),()=>{H=!0,C(z)}},[M,y,o,s,e,C,w,A,l,n,r]),t.jsx(g2,{ref:R,width:n,height:r,fit:l,effects:A,...h})});qx.displayName="AnimatedImageContent";var N2=({src:e,width:n,height:r,onError:s,fit:o,playbackRate:a,loopBehavior:l,id:c,className:u,style:d,durationInFrames:h,requestInit:p,effects:b=[],_experimentalControls:y,ref:v,...w})=>{const{durationInFrames:C}=as(),k=h??C,E=i.useRef(null),m=Gl(b);i.useImperativeHandle(v,()=>E.current,[]);const M={src:e,width:n,height:r,onError:s,fit:o,playbackRate:a,loopBehavior:l,id:c,className:u,style:d,requestInit:p};return t.jsx(Ir,{layout:"none",durationInFrames:k,name:"<AnimatedImage>",_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/animatedimage",_experimentalControls:y,_remotionInternalEffects:m,...w,_remotionInternalRefForOutline:E,children:t.jsx(qx,{...M,ref:E,effects:b,controls:y})})},Xx=Zo({Component:N2,componentIdentity:"dev.remotion.remotion.AnimatedImage",schema:j2,supportsEffects:!0});Xx.displayName="AnimatedImage";_s(Xx);var k2=e=>{if(typeof e!="string")throw new TypeError(`The "filename" must be a string, but you passed a value of type ${typeof e}`);if(e.trim()==="")throw new Error("The `filename` must not be empty");if(!e.match(/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g))throw new Error('The `filename` must match "/^([0-9a-zA-Z-!_.*\'()/:&$@=;+,?]+)/g". Use forward slashes only, even on Windows.')},S2=e=>{if(typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError(`The "content" must be a string or Uint8Array, but you passed a value of type ${typeof e}`);if(typeof e=="string"&&e.trim()==="")throw new Error("The `content` must not be empty")},Jx=e=>{e.type==="artifact"&&(k2(e.filename),e.contentType!=="thumbnail"&&S2(e.content))},pi=i.createContext({registerRenderAsset:()=>{},unregisterRenderAsset:()=>{},renderAssets:[]}),C2=({children:e,collectAssets:n})=>{const[r,s]=i.useState([]),o=i.useRef([]),a=i.useCallback(u=>{Jx(u),o.current=[...o.current,u],s(o.current)},[]);n&&i.useImperativeHandle(n,()=>({collectAssets:()=>{const u=o.current;return o.current=[],s([]),u}}),[]);const l=i.useCallback(u=>{o.current=o.current.filter(d=>d.id!==u),s(o.current)},[]);i.useLayoutEffect(()=>{typeof window<"u"&&(window.remotion_collectAssets=()=>{const u=o.current;return o.current=[],s([]),u})},[]);const c=i.useMemo(()=>({registerRenderAsset:a,unregisterRenderAsset:l,renderAssets:r}),[r,a,l]);return t.jsx(pi.Provider,{value:c,children:e})},Xo=e=>typeof window>"u"||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("file://")||e.startsWith("blob:")||e.startsWith("data:")?e:ne
28w URL(e,window.origin).href,Ed=({trimAfter:e,mediaDurationInFrames:n,playbackRate:r,trimBefore:s})=>{let o=n;typeof e<"u"&&(o=e),typeof s<"u"&&(o-=s);const a=o/r;return Number(a.toFixed(10))},Zx=i.createContext(null),E2=()=>qe.useContext(Zx),Zl=({durationInFrames:e,times:n=1/0,children:r,name:s,showInTimeline:o,...a})=>{const l=xs(),{durationInFrames:c}=as();if(fd(e,{component:"of the <Loop /> component",allowFloats:!0}),typeof n!="number")throw new TypeError(`You passed to "times" an argument of type ${typeof n}, but it must be a number.`);if(n!==1/0&&n%1!==0)throw new TypeError(`The "times" prop of a loop must be an integer, but got ${n}.`);if(n<0)throw new TypeError(`The "times" prop of a loop must be at least 0, but got ${n}`);const u=Math.ceil(c/e),d=Math.min(u,n),h=a.layout==="none"?void 0:a.style,p=e*(d-1),y=Math.floor(l/e)*e,v=Math.min(y,p),w=i.useMemo(()=>({numberOfTimes:Math.min(c/e,n),startOffset:-v,durationInFrames:e}),[c,e,v,n]),C=i.useMemo(()=>({iteration:Math.floor(l/e),durationInFrames:e}),[l,e]);return t.jsx(Zx.Provider,{value:C,children:t.jsx(Ir,{durationInFrames:e,from:v,name:s??"<Loop>",_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/loop",_remotionInternalLoopDisplay:w,layout:a.layout,style:h,showInTimeline:o,children:r})})};Zl.useLoop=E2;var os=({logLevel:e,tag:n,message:r,mountTime:s})=>{const o=[s?Date.now()-s+"ms ":null,n].filter(Boolean).join(" ");Dr.trace({logLevel:e,tag:null},`[${o}]`,r)},Md=i.createContext({}),zf={},du=[],Qx=({children:e})=>{const[n,r]=i.useState(()=>zf);return i.useEffect(()=>{const s=()=>{r(zf)};return du.push(s),()=>{du=du.filter(o=>o!==s)}},[]),t.jsx(Md.Provider,{value:n,children:e})},eg=e=>{const n=e.indexOf("#");return n===-1?null:n},M2=e=>{const n=eg(e);return n===null?e:e.slice(0,n)},fi=e=>{const n=i.useContext(Md),r=eg(e),s=M2(e);return n[s]?r!==null?n[s]+e.slice(r):n[s]:e},Id=(e,n)=>{if(typeof e.volume!="number"&&typeof e.volume!="function"&&typeof e.volume<"u")throw new TypeError(`You have passed a volume of type ${typeof e.volume} to your <${n} /> component. Volume must be a number or a function with the signature '(frame: number) => number' undefined.`);if(typeof e.volume=="number"&&e.volume<0)throw new TypeError(`You have passed a volume below 0 to your <${n} /> component. Volume must be between 0 and 1`);if(typeof e.playbackRate!="number"&&typeof e.playbackRate<"u")throw new TypeError(`You have passed a playbackRate of type ${typeof e.playbackRate} to your <${n} /> component. Playback rate must a real number or undefined.`);if(typeof e.playbackRate=="number"&&(isNaN(e.playbackRate)||!Number.isFinite(e.playbackRate)||e.playbackRate<=0))throw new TypeError(`You have passed a playbackRate of ${e.playbackRate} to your <${n} /> component. Playback rate must be a real number above 0.`);if(typeof e.preservePitch!="boolean"&&typeof e.preservePitch<"u")throw new TypeError(`'preservePitch' must be a boolean or undefined but got '${typeof e.preservePitch}' instead`)},I2=(e,n)=>{if(typeof e<"u"){if(typeof e!="number")throw new TypeError(`type of startFrom prop must be a number, instead got type ${typeof e}.`);if(isNaN(e)||e===1/0)throw new TypeError("startFrom prop can not be NaN or Infinity.");if(e<0)throw new TypeError(`startFrom must be greater than equal to 0 instead got ${e}.`)}if(typeof n<"u"){if(typeof n!="number")throw new TypeError(`type of endAt prop must be a number, instead got type ${typeof n}.`);if(isNaN(n))throw new TypeError("endAt prop can not be NaN.");if(n<=0)throw new TypeError(`endAt must be a positive number, instead got ${n}.`)}if(n<e)throw new TypeError("endAt prop must be greater than startFrom prop.")},F2=(e,n)=>{if(typeof e<"u"){if(typeof e!="number")throw new TypeError(`type of trimBefore prop must be a number, instead got type ${typeof e}.`);if(isNaN(e)||e===1/0)throw new TypeError("trimBefore prop can not be NaN or Infinity.");if(e<0)throw new TypeError(`trimBefore must be greater than equal to 0 instead got ${e}.`)}if(typeof n<"u"){if(typeof n!="number")throw new TypeError(`type of trimAfter prop must be a number, instead got type ${typeof n}.`);if(isNaN(n))throw new TypeError("trimAfter prop can not be NaN.");
28if(n<=0)throw new TypeError(`trimAfter must be a positive number, instead got ${n}.`)}if(n<=e)throw new TypeError("trimAfter prop must be greater than trimBefore prop.")},Fd=({startFrom:e,endAt:n,trimBefore:r,trimAfter:s})=>{if(typeof e<"u"&&typeof r<"u")throw new TypeError("Cannot use both startFrom and trimBefore props. Use trimBefore instead as startFrom is deprecated.");if(typeof n<"u"&&typeof s<"u")throw new TypeError("Cannot use both endAt and trimAfter props. Use trimAfter instead as endAt is deprecated.");typeof r<"u"||typeof s<"u"?F2(r,s):(typeof e<"u"||typeof n<"u")&&I2(e,n)},Rd=({startFrom:e,endAt:n,trimBefore:r,trimAfter:s})=>({trimBeforeValue:r??e??void 0,trimAfterValue:s??n??void 0}),R2=(e,n)=>{switch(n.type){case"got-duration":{const r=Xo(n.src);return e[r]===n.durationInSeconds?e:{...e,[r]:n.durationInSeconds}}default:return e}},tp=i.createContext({durations:{},setDurations:()=>{throw new Error("context missing")}}),tg=({children:e})=>{const[n,r]=i.useReducer(R2,{}),s=i.useMemo(()=>({durations:n,setDurations:r}),[n]);return t.jsx(tp.Provider,{value:s,children:e})},np=({crossOrigin:e,requestsVideoFrame:n,isClientSideRendering:r})=>{if(e!=null)return e;if(r||n)return"anonymous"},sd=({mediaRef:e,mediaType:n,onAutoPlayError:r,logLevel:s,mountTime:o,reason:a,isPlayer:l})=>{const{current:c}=e;if(!c)return;os({logLevel:s,tag:"play",message:`Attempting to play ${c.src}. Reason: ${a}`,mountTime:o});const u=c.play();u.catch&&u.catch(d=>{if(c&&!d.message.includes("request was interrupted by a call to pause")&&!d.message.includes("The operation was aborted.")&&!d.message.includes("The fetching process for the media resource was aborted by the user agent")&&!d.message.includes("request was interrupted by a new load request")&&!d.message.includes("because the media was removed from the document")&&!(d.message.includes("user didn't interact with the document")&&c.muted)&&(console.log(`Could not play ${n} due to following error: `,d),!c.muted)){if(r){r();return}n==="video"&&l&&(Dr.info({logLevel:s,tag:"<"+n+">"},"The video will be muted and we'll retry playing it."),Dr.info({logLevel:s,tag:"<"+n+">"},"Use onAutoPlayError() to handle this error yourself."),c.muted=!0,c.play())}})},rp=({audioContext:e,ref:n})=>{let r=null,s=!1;return{attemptToConnect:()=>{if(s)throw new Error("SharedElementSourceNode has been disposed");!r&&n.current&&(r=e.createMediaElementSource(n.current))},get:()=>{if(!r)throw new Error("Audio element not connected");return r},cleanup:()=>{r&&(r.disconnect(),r=null),s=!0}}},Bf=!1,P2=e=>{Bf||(Bf=!0,typeof window<"u"&&Dr.warn({logLevel:e,tag:null},"AudioContext is not supported in this browser"))},T2=({logLevel:e,latencyHint:n,audioEnabled:r,sampleRate:s})=>{const o=Pr(),a=i.useRef(s);if(s!==a.current)throw new Error(`Changing the AudioContext sample rate dynamically is not supported. The sample rate was initialized with ${a.current} Hz, but ${s} Hz was passed later.`);return i.useMemo(()=>{if(o.isRendering||!r)return null;if(typeof AudioContext>"u")return P2(e),null;const c=new AudioContext({latencyHint:n,sampleRate:s}),u=c.createGain();u.connect(c.destination),Dr.trace({logLevel:e,tag:"audio"},"Creating new audio context"),c.suspend();let d=null;return{audioContext:c,gainNode:u,getState:()=>{const y=c.state;return d==="running"&&y!=="running"?"suspended-to-running":d==="suspended"&&y!=="suspended"?"running-to-suspended":y},resume:()=>{d="running";const y=c.resume();return y.finally(()=>{d==="running"&&(d=null)}),y},suspend:()=>{d="suspended";const y=c.suspend();return y.finally(()=>{d==="suspended"&&(d=null)}),y}}},[e,n,o.isRendering,r,s])},A2=(e,n)=>new Promise(r=>{const s=e.currentTime,a=e.getOutputTimestamp().performanceTime,l=performance.now(),c=()=>{var p;const{currentTime:u}=e,d=e.getOutputTimestamp(),h=performance.now()-l;if(a!==void 0&&d.performanceTime!==void 0&&d.performanceTime>a&&d.contextTime!==void 0&&d.contextTime>s){Dr.verbose({logLevel:n,tag:"audio"},`waitUntilActuallyResumed: getOutputTimestamp.performanceTime advanced from ${a.toFixed(6)} to ${d.performanceTime.toFixed(6)} after ${h.toFixed(1)}ms. currentTime=${u.toFixed(6)} (advanced by ${(u-s).toFixed(6)}), getOutputTimestamp.performanceTime=${((p=d.performanceTime)==null?void 0:p.toFixed(1))??"undefined"}`),r();return}requestAnimationFrame(c)};requestAnimationFrame(c)}),Hf="data:audio/mp3;base64,/+MYxAAJcAV8AAgAABn//////+/gQ5BAMA+D4Pg+BAQBAEAwD4Pg+D4EBAEAQDAPg++hYBH///hUFQVBUFREDQNHmf///////+MYxBUGkAGIMAAAAP/29Xt6lUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV/+MYxDUAAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",$2=(e,n)=>{const r=Object.keys(e).sort(),s=Object.keys(n).sort();if(r.length!==s.length)return!1;for(let o=0;o<r.length;o++)if(r[o]!==s[o]||e[r[o]]!==n[s[o]])return!1;return!0},_2=(e,n,r)=>e==="src"&&!r.startsWith("data:")&&!n.startsWith("data:")?new URL(r,window.origin).toString()!==new URL(n,window.origin).toString():r!==n,Xi=i.createContext(null),Pd=i.createContext(null),D2=e=>{if(e==="suspended"||e==="running-to-suspended"||e==="interrupted")return!0;
28if(e==="running"||e==="suspended-to-running")return!1;throw new Error(`Unexpected audio context state: ${e}`)},ng=({children:e,audioLatencyHint:n,audioEnabled:r,previewSampleRate:s})=>{const o=Jo(),a=s??48e3;i.useEffect(()=>{typeof window>"u"||(window.remotion_sampleRate=a)},[a]);const l=T2({logLevel:o,latencyHint:n,audioEnabled:r,sampleRate:a}),c=i.useRef(!1),u=i.useRef(null),d=i.useMemo(()=>({value:0}),[]),h=i.useRef([]),p=i.useMemo(()=>({dispatch:M=>{h.current.forEach(I=>I(M))},subscribe:M=>(h.current.push(M),{remove:()=>{h.current=h.current.filter(I=>I!==M)}})}),[]),b=i.useRef({scheduledEndTime:null,mediaEndTime:null}),y=i.useRef(new Map),v=i.useCallback(M=>{y.current.delete(M)},[]),w=i.useMemo(()=>({node:M,mediaTimestamp:I,scheduledTime:N,duration:F,offset:R,originalUnloopedMediaTimestamp:A})=>{if(!l)throw new Error("Audio context not found");const V=l.getState();if(V==="closed")return{type:"not-started",reason:"audio context is closed"};const z=D2(V);F>0&&(z?y.current.set(M,{scheduledTime:N,offset:R,duration:F}):M.start(N,R,F));const H=N+F/M.playbackRate.value,ne=I+R,se=ne+F,pe=l.audioContext.baseLatency+l.audioContext.outputLatency,ie=N-l.audioContext.currentTime,O=b.current,D=O.scheduledEndTime!==null&&Math.abs(N-O.scheduledEndTime)>.001,W=O.mediaEndTime!==null&&Math.abs(ne-O.mediaEndTime)>.001;return Dr.verbose({logLevel:o,tag:"audio-scheduling"},"scheduled %c%s%c %s %c%s%c %s %c%s%c %s %s %s %s %s",D?"color: red; font-weight: bold":"",N.toFixed(4),"",H.toFixed(4),W?"color: red; font-weight: bold":"",ne.toFixed(4),"",se.toFixed(4),F<0||ie<0?"color: red; font-weight: bold":"color: blue; font-weight: bold",F<0?"missed "+Math.abs(R).toFixed(2)+"s":Math.abs(ie).toFixed(2)+(ie<0?" delay":" ahead"),"","current="+l.audioContext.currentTime.toFixed(4),"offset="+R.toFixed(4),"latency="+pe.toFixed(4),"state="+l.audioContext.state,A!==ne?"original_ts="+A.toFixed(4):"","action="+(z?"schedule":"start"),""),O.scheduledEndTime=H,O.mediaEndTime=se,F>0?{type:"started",scheduledTime:N}:{type:"not-started",reason:"missed "+Math.abs(R).toFixed(2)+"s"}},[l,o]),C=i.useCallback(()=>{if(!l||c.current)return Promise.resolve();c.current=!0,l.gainNode.gain.cancelScheduledValues(l.audioContext.currentTime),l.gainNode.gain.setValueAtTime(0,l.audioContext.currentTime),l.gainNode.gain.linearRampToValueAtTime(1,l.audioContext.currentTime+.03),y.current.forEach((I,N)=>{N.start(I.scheduledTime,I.offset,I.duration)}),y.current.clear();const M=l.resume();return u.current=new Promise(I=>{A2(l.audioContext,o).then(I),M.catch(N=>{Dr.warn({logLevel:o,tag:"audio"},"AudioContext resume rejected, continuing without audio sync",N),I()})}).finally(()=>{u.current=null}),M.catch(()=>{})},[l,o]),k=i.useCallback(()=>u.current,[]),E=i.useCallback(()=>!l||!c.current?Promise.resolve():(c.current=!1,l.suspend()),[l]),m=i.useMemo(()=>({audioContext:(l==null?void 0:l.audioContext)??null,getAudioContextState:()=>(l==null?void 0:l.getState())??null,gainNode:(l==null?void 0:l.gainNode)??null,audioSyncAnchor:d,audioSyncAnchorEmitter:p,scheduleAudioNode:w,resume:C,suspend:E,getIsResumingAudioContext:k,unscheduleAudioNode:v}),[l,d,p,w,C,E,k,v]);return t.jsx(Xi.Provider,{value:m,children:e})},rg=({children:e,numberOfAudioTags:n})=>{const r=i.useRef([]),[s]=i.useState(n);if(n!==s)throw new Error("The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.");const o=Jo(),a=Wl(),l=Pr(),c=i.useContext(Xi),u=(c==null?void 0:c.audioContext)??null,d=c==null?void 0:c.resume,h=i.useMemo(()=>new Array(n).fill(!0).map(()=>{const m=i.createRef();return{id:Math.random(),ref:m,mediaElementSourceNode:u?rp({audioContext:u,ref:m}):null}}),[u,n]);(qe.useInsertionEffect??qe.useLayoutEffect)(()=>()=>{requestAnimationFrame(()=>{h.forEach(({mediaElementSourceNode:m})=>{m==null||m.cleanup()})})},[h]);const b=i.useRef(new Array(n).fill(!1)),y=i.useCallback(()=>{h.forEach(({ref:m,id:M})=>{var F;const I=(F=r.current)==null?void 0:F.find(R=>R.id===M),{current:N}
28=m;if(N){if(I===void 0){N.src=Hf;return}if(!I)throw new TypeError("Expected audio data to be there");Object.keys(I.props).forEach(R=>{_2(R,I.props[R],N[R])&&(N[R]=I.props[R])})}})},[h]),v=i.useCallback(m=>{var pe,ie;const{aud:M,audioId:I,premounting:N,postmounting:F}=m,R=(pe=r.current)==null?void 0:pe.find(O=>O.audioId===I);if(R)return R;const A=b.current.findIndex(O=>O===!1);if(A===-1)throw new Error(`Tried to simultaneously mount ${n+1} <Html5Audio /> tags at the same time. With the current settings, the maximum amount of <Html5Audio /> tags is limited to ${n} at the same time. Remotion pre-mounts silent audio tags to help avoid browser autoplay restrictions. See https://remotion.dev/docs/player/autoplay#using-the-numberofsharedaudiotags-prop for more information on how to increase this limit.`);const{id:V,ref:z,mediaElementSourceNode:H}=h[A],ne=[...b.current];ne[A]=V,b.current=ne;const se={props:M,id:V,el:z,audioId:I,mediaElementSourceNode:H,premounting:N,audioMounted:!!z.current,postmounting:F,cleanupOnMediaTagUnmount:()=>{}};return(ie=r.current)==null||ie.push(se),y(),se},[n,h,y]),w=i.useCallback(m=>{var N;const M=[...b.current],I=h.findIndex(F=>F.id===m);if(I===-1)throw new TypeError("Error occured in ");M[I]=!1,b.current=M,r.current=(N=r.current)==null?void 0:N.filter(F=>F.id!==m),y()},[h,y]),C=i.useCallback(({aud:m,audioId:M,id:I,premounting:N,postmounting:F})=>{var A;let R=!1;r.current=(A=r.current)==null?void 0:A.map(V=>{const z=!!V.el.current;return V.audioMounted!==z&&(R=!0),V.id===I?$2(m,V.props)&&V.premounting===N&&V.postmounting===F?V:(R=!0,{...V,props:m,premounting:N,postmounting:F,audioId:M,audioMounted:z}):V}),R&&y()},[y]),k=i.useCallback(()=>{h.forEach(m=>{const M=r.current.find(I=>I.el===m.ref);M!=null&&M.premounting||sd({mediaRef:m.ref,mediaType:"audio",onAutoPlayError:null,logLevel:o,mountTime:a,reason:"playing all audios",isPlayer:l.isPlayer})}),d==null||d()},[o,a,h,l.isPlayer,d]),E=i.useMemo(()=>({registerAudio:v,unregisterAudio:w,updateAudio:C,playAllAudios:k,numberOfAudioTags:n}),[n,k,v,w,C]);return t.jsxs(Pd.Provider,{value:E,children:[h.map(({id:m,ref:M})=>t.jsx("audio",{ref:M,preload:"metadata",src:Hf},m)),e]})},L2=({aud:e,audioId:n,premounting:r,postmounting:s})=>{const o=i.useContext(Xi),a=i.useContext(Pd),[l]=i.useState(()=>{if(a&&a.numberOfAudioTags>0)return a.registerAudio({aud:e,audioId:n,premounting:r,postmounting:s});const u=qe.createRef(),d=o!=null&&o.audioContext?rp({audioContext:o.audioContext,ref:u}):null;return{el:u,id:Math.random(),props:e,audioId:n,mediaElementSourceNode:d,premounting:r,audioMounted:!!u.current,postmounting:s,cleanupOnMediaTagUnmount:()=>{d==null||d.cleanup()}}}),c=qe.useInsertionEffect??qe.useLayoutEffect;return typeof document<"u"&&(c(()=>{a&&a.numberOfAudioTags>0&&a.updateAudio({id:l.id,aud:e,audioId:n,premounting:r,postmounting:s})},[e,a,l.id,n,r,s]),c(()=>()=>{a&&a.numberOfAudioTags>0&&a.unregisterAudio(l.id)},[a,l.id])),l},O2=1e-5,od=(e,n)=>Math.abs(e-n)<O2,sg=(e,n)=>Math.round(e/n*100)/100,im=()=>typeof window>"u"||!/AppleWebKit/.test(window.navigator.userAgent)?!1:!window.navigator.userAgent.includes("Chrome/"),Td=()=>typeof window>"u"?!1:/iP(ad|od|hone)/i.test(window.navigator.userAgent)&&im(),V2=e=>Td()&&e.startsWith("blob:"),lm=({actualFrom:e,fps:n})=>sg(Math.max(0,-e),n),cm=({duration:e,fps:n})=>sg(e,n),U2=({actualSrc:e,actualFrom:n,duration:r,fps:s})=>{if(V2(e)||e.startsWith("data:")||!!new URL(e,(typeof window>"u"?null:window.location.href)??"http://localhost:3000").hash||!Number.isFinite(n))return e;const a=`${e}#t=${lm({actualFrom:n,fps:s})}`;return Number.isFinite(r)?`${a},${cm({duration:r,fps:s})}`:a},z2=({prevStartFrom:e,newStartFrom:n,prevDuration:r,newDuration:s,fps:o})=>{const a=lm({actualFrom:e,fps:o}),l=lm({actualFrom:n,fps:o}),c=cm({duration:r,fps:o}),u=cm({duration:s,fps:o});return!(l<a||u>c)},B2=({actualSrc:e,actualFrom:n,duration:r,fps:s})=>{const o=i.useRef(n),a=i.useRef(r),l=i.useRef(e);return(!z2({prevStartFrom:o.current,newStartFrom:n,prevDuration:a.current,newDuration:r,fps:s})||e!==l.current)&&(o.current=n,a.current=r,l.current=e),U2({actualSrc:l.current,actualFrom:o.current,duration:a.current,fps:s})},Kf=!1,H2=e=>{Kf||(Kf=!0,Dr.warn({logLevel:e,tag:null},"In Safari, setting a volume and a playback rate at the same time is buggy."),Dr.warn({logLevel:e,tag:null},"In Desktop Safari, only volumes <= 1 will be applied."),Dr.warn({logLevel:e,tag:null},e,"In Mobile Safari, the volume will be ignored and set to 1 if a playbackRate is set."))},og=({mediaRef:e,volume:n,logLevel:r,source:s,shouldUseWebAudioApi:o})=>{var b,y,v;const a=i.useRef(null),l=i.useRef(n);l.current=n;const c=i.useContext(Xi);if(!c)throw new Error("useAmplification must be used within a SharedAudioContext");const{audioContext:u,gainNode:d}=c;if(typeof window<"u"&&i.useLayoutEffect(()=>{var C,k;if(!u||!e.current||!o)return;if(e.current.playbackRate!==1&&im()){H2(r);return}if(!s||!d)return;const w=new GainNode(u,{gain:l.current});return s.attemptToConnect(),s.get().connect(w),w.connect(d),a.current={gainNode:w},Dr.trace({logLevel:r,tag:null},`Starting to amplify ${(C=e.current)==null?void 0:C.src}. Gain = ${l.current}, playbackRate = ${(k=e.current)==null?void 0:k.playbackRate}`),()=>{a.current=null,w.disconnect(),s.get().disconnect()}},[r,e,u,s,o,d]),a.current){const w=n;od(a.current.gainNode.gain.value,w)||(a.current.gainNode.gain.value=w,Dr.trace({logLevel:r,tag:null},`Setting gain to ${w} for ${(b=e.current)==null?void 0:b.src}`))}return(im()&&e.current&&((y=e.current)==null?void 0:y.playbackRate)!==1||!o)&&e.current&&!od(n,(v=e.current)==null?void 0:v.volume)&&(e.current.volume=Math.min(n,1)),a},ai=()=>{const e=i.useContext(Rr);return(e==null?void 0:e.cumulatedNegativeFrom)??0},Ji=e=>{const n=Zl.useLoop(),r=xs(),s=ai();return e==="repeat"||n===null?r+s:r+s+n.durationInFrames*n.iteration},ag=e=>{if(/data:|blob:/.test(e.substring(0,5)))return"Data URL";const n=e.split("/").map(r=>r.split("\\")).flat(1);return n[n.length-1]},K2=({compositionDurationInFrames:e,playbackRate:n,trimBefore:r,trimAfter:s,parentSequenceDurationInFrames:o,loop:a})=>{if(a)return e;const l=Ed({mediaDurationInFrames:e*n+(r??0),playbackRate:n,trimBefore:r,trimAfter:s});if(o!==null){const c=Math.min(o*n,l);return Number(c.toFixed(10))}return l},hi=({frame:e,volume:n,mediaVolume:r=1})=>{if(typeof n=="number")return n*r;if(typeof n>"u")return Number(r);const s=n(e)*r;if(typeof s!="number")throw new TypeError(`You passed in a a function to the volume prop but it did not return a number but a value of type ${typeof s} for frame ${e}`);if(Number.isNaN(s))throw new TypeError(`You passed in a function to the volume prop but it returned NaN for frame ${e}.`);if(!Number.isFinite(s))throw new TypeError(`You passed in a function to the volume prop but it returned a non-finite number for frame ${e}.`);return Math.max(0,s)},Wf={},W2=e=>{Wf[e]||(console.warn(e),Wf[e]=!0)},ig=({volume:e,mediaVolume:n,mediaType:r,src:s,displayName:o,trimBefore:a,trimAfter:l,playbackRate:c,sequenceDurationInFrames:u,mediaStartsAt
28:d,loop:h})=>{if(!s)throw new Error("No src passed");const p=i.useContext(Rr),[b]=i.useState(()=>e),y=K2({compositionDurationInFrames:u,playbackRate:c,trimBefore:a,trimAfter:l,parentSequenceDurationInFrames:(p==null?void 0:p.durationInFrames)??null,loop:h}),v=i.useMemo(()=>typeof e=="number"?e:new Array(Math.floor(Math.max(0,y+d))).fill(!0).map((M,I)=>hi({frame:I+d,volume:e,mediaVolume:n})).join(","),[y,d,e,n]);i.useEffect(()=>{typeof e=="number"&&e!==b&&W2(`Remotion: The ${r} with src ${s} has changed it's volume. Prefer the callback syntax for setting volume to get better timeline display: https://www.remotion.dev/docs/audio/volume`)},[b,r,s,e]);const w=typeof e=="function",C=md(),{rootId:k}=Va(),E=0-d+(a??0);return i.useMemo(()=>({volumes:v,duration:y,doesVolumeChange:w,nonce:C,rootId:k,finalDisplayName:o??ag(s),startMediaFrom:E,src:s,playbackRate:c}),[v,y,w,C,k,o,s,E,c])},sp=({volume:e,mediaVolume:n,src:r,mediaType:s,playbackRate:o,displayName:a,id:l,getStack:c,showInTimeline:u,premountDisplay:d,postmountDisplay:h,loopDisplay:p,documentationLink:b,refForOutline:y})=>{const v=i.useContext(Rr),w=ai(),{registerSequence:C,unregisterSequence:k}=i.useContext(qi),{durationInFrames:E}=as(),m=ai(),{volumes:M,duration:I,doesVolumeChange:N,nonce:F,rootId:R,finalDisplayName:A}=ig({volume:e,mediaVolume:n,mediaType:s,src:r,displayName:a,trimAfter:void 0,trimBefore:void 0,playbackRate:o,sequenceDurationInFrames:E,mediaStartsAt:m,loop:!1}),{isStudio:V}=Pr();i.useEffect(()=>{var z,H;if(!r)throw new Error("No src passed");if(!(!V&&((H=(z=window.process)==null?void 0:z.env)==null?void 0:H.NODE_ENV)!=="test")&&u)return C({type:s,src:r,id:l,duration:I,from:0,parent:(v==null?void 0:v.id)??null,displayName:A,documentationLink:b,rootId:R,volume:M,showInTimeline:!0,nonce:F.get(),startMediaFrom:0-w,doesVolumeChange:N,loopDisplay:p,playbackRate:o,getStack:c,premountDisplay:d,postmountDisplay:h,controls:null,effects:[],refForOutline:y,isInsideSeries:!1,frozenFrame:null,frozenMediaFrame:null}),()=>{k(l)}},[I,l,v,r,C,k,M,N,F,s,w,o,c,u,d,h,p,b,R,A,V,y])},Y2=(e,n)=>{const[r,s]=i.useState([]),[o,a]=i.useState([]),[l,c]=i.useState([]),d=Pr().isRendering,h=i.useRef(!1),p=i.useCallback(v=>{if(d)return{unblock:()=>{}};let w=!1;return s(C=>[...C,v]),{unblock:()=>{w||(w=!0,s(C=>{const k=C.filter(E=>E!==v);return k.length===C.length?C:k}))}}},[d]),b=i.useCallback(v=>(a(w=>[...w,v]),{remove:()=>{a(w=>w.filter(C=>C!==v))}}),[]),y=i.useCallback(v=>(c(w=>[...w,v]),{remove:()=>{c(w=>w.filter(C=>C!==v))}}),[]);return i.useEffect(()=>{d||r.length>0&&(o.forEach(v=>v()),os({logLevel:e,message:"Player is entering buffer state",mountTime:n,tag:"player"}))},[r]),typeof window<"u"&&i.useLayoutEffect(()=>{d||r.length===0&&(l.forEach(v=>v()),os({logLevel:e,message:"Player is exiting buffer state",mountTime:n,tag:"player"}))},[r]),i.useMemo(()=>({addBlock:p,listenForBuffering:b,listenForResume:y,buffering:h}),[p,h,b,y])},Zi=qe.createContext(null),lg=({children:e})=>{const{logLevel:n,mountTime:r}=i.useContext(mi),s=Y2(n??"info",r);return t.jsx(Zi.Provider,{value:s,children:e})},cg=e=>{const[n,r]=i.useState(e.buffering.current);return i.useEffect(()=>{const s=()=>{r(!0)},o=()=>{r(!1)};return e.listenForBuffering(s),e.listenForResume(o),()=>{e.listenForBuffering(()=>{}),e.listenForResume(()=>{})}},[e]),n},Ad=()=>{const e=i.useContext(Zi),n=Jo(),r=e?e.addBlock:null;return i.useMemo(()=>({delayPlayback:()=>{if(!r)throw new Error("Tried to enable the buffering state, but a Remotion context was not found. This API can only be called in a component that was passed to the Remotion Player or a <Composition>. Or you might have experienced a version mismatch - run `npx remotion versions` and ensure all packages have the same version. This error is thrown by the buffer state https://remotion.dev/docs/player/buffer-state");Dr.trace({logLevel:n,tag:"[buffer-state]"},"Adding buffer handle",new Error().stack);const{unblock:s}=r({id:String(Math.random())});let o=!1;return{unblock:()=>{o||(o=!0,Dr.trace({logLevel:n,tag:"[buffer-state]"},"Removing buffer handle"),s())}}}}),[r,n])},G2=()=>/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent),q2=({mediaRef:e,mediaType:n,onVariableFpsVideoDetected:r,pauseWhenBuffering:s,logLevel:o,mountTime:a})=>{const l=i.useRef(!1),{delayPlayback:c}=Ad(),u=i.useCallback(d=>{var v;if(n!=="video"||!s)return;const h=e.current;if(!h)return;if(h.readyState>=h.HAVE_FUTURE_DATA&&!G2()){os({logLevel:o,message:`Not using buffer until first frame, because readyState is ${h.readyState} and is not Safari or Desktop Chrome`,mountTime:a,tag:"buffer"});return}if(!h.requestVideoFrameCallback){os({logLevel:o,message:"Not using buffer until first frame, because requestVideoFrameCallback is not supported",mountTime:a,tag:"buffer"});return}
28l.current=!0,os({logLevel:o,message:`Buffering ${(v=e.current)==null?void 0:v.src} until the first frame is received`,mountTime:a,tag:"buffer"});const p=c(),b=()=>{p.unblock(),h.removeEventListener("ended",b,{once:!0}),h.removeEventListener("pause",b,{once:!0}),l.current=!1},y=()=>{b()};h.requestVideoFrameCallback((w,C)=>{Math.abs(C.mediaTime-d)>.5&&r(),b()}),h.addEventListener("ended",y,{once:!0}),h.addEventListener("pause",y,{once:!0}),h.addEventListener("canplay",y,{once:!0})},[c,o,e,n,a,r,s]);return i.useMemo(()=>({isBuffering:()=>l.current,bufferUntilFirstFrame:u}),[u])},X2=e=>{var s,o;const n=qe.useRef({time:((s=e.current)==null?void 0:s.currentTime)??0,lastUpdate:performance.now()}),r=((o=e.current)==null?void 0:o.currentTime)??null;return r!==null&&n.current.time!==r&&(n.current.time=r,n.current.lastUpdate=performance.now()),n},Vc=({mediaRef:e,time:n,logLevel:r,why:s,mountTime:o})=>{const a=Td()?Number(n.toFixed(1)):n;return os({logLevel:r,tag:"seek",message:`Seeking from ${e.currentTime} to ${a}. src= ${e.src} Reason: ${s}`,mountTime:o}),e.currentTime=a,a},J2=({element:e,shouldBuffer:n,isPremounting:r,isPostmounting:s,logLevel:o,mountTime:a,src:l})=>{const c=Ad(),[u,d]=i.useState(!1);return i.useEffect(()=>{let h=[];const{current:p}=e;if(!p||!n)return;if(r||s){if((r||s)&&p.readyState<p.HAVE_FUTURE_DATA&&!navigator.userAgent.includes("Firefox/")){os({logLevel:o,message:`Calling .load() on ${p.src} because readyState is ${p.readyState} and it is not Firefox. Element is premounted ${p.playbackRate}`,tag:"load",mountTime:a});const w=p.playbackRate;p.load(),p.playbackRate=w}return}const b=w=>{let C=!1;h.forEach(k=>{k(w),C=!0}),h=[],d(k=>(k&&(C=!0),!1)),C&&os({logLevel:o,message:`Unmarking as buffering: ${p.src}. Reason: ${w}`,tag:"buffer",mountTime:a})},y=w=>{d(!0),os({logLevel:o,message:`Marking as buffering: ${p.src}. Reason: ${w}`,tag:"buffer",mountTime:a});const{unblock:C}=c.delayPlayback(),k=()=>{b('"canplay" was fired'),v()},E=()=>{b('"error" event was occurred'),v()};p.addEventListener("canplay",k,{once:!0}),h.push(()=>{p.removeEventListener("canplay",k)}),p.addEventListener("error",E,{once:!0}),h.push(()=>{p.removeEventListener("error",E)}),h.push(m=>{os({logLevel:o,message:`Unblocking ${p.src} from buffer. Reason: ${m}`,tag:"buffer",mountTime:a}),C()})},v=()=>{if(p.readyState<p.HAVE_FUTURE_DATA){if(y(`readyState is ${p.readyState}, which is less than HAVE_FUTURE_DATA`),!navigator.userAgent.includes("Firefox/")){os({logLevel:o,message:`Calling .load() on ${l} because readyState is ${p.readyState} and it is not Firefox. ${p.playbackRate}`,tag:"load",mountTime:a});const w=p.playbackRate;p.load(),p.playbackRate=w}}else{const w=()=>{y('"waiting" event was fired')};p.addEventListener("waiting",w),h.push(()=>{p.removeEventListener("waiting",w)})}};return v(),()=>{b("element was unmounted or prop changed")}},[c,l,e,r,s,o,n,a]),u},Z2=({mediaRef:e,mediaType:n,lastSeek:r,onVariableFpsVideoDetected:s})=>{const o=i.useRef(null);return i.useEffect(()=>{const{current:a}=e;if(a)o.current={time:a.currentTime,lastUpdate:performance.now()};else{o.current=null;return}if(n!=="video"){o.current=null;return}const l=a;if(!l.requestVideoFrameCallback)return;let c=()=>{};const u=()=>{if(!l)return;const d=l.requestVideoFrameCallback((h,p)=>{if(o.current!==null){const b=Math.abs(o.current.time-p.mediaTime),y=Math.abs(r.current===null?1/0:p.mediaTime-r.current);b>.5&&y>.5&&p.mediaTime>o.current.time&&s()}o.current={time:p.mediaTime,lastUpdate:performance.now()},u()});c=()=>{l.cancelVideoFrameCallback(d),c=()=>{}}};return u(),()=>{c()}},[r,e,n,s]),o},dg=({frame:e,playbackRate:n,startFrom:r})=>Gn(e,[-1,r,r+1],[-1,r,r+n]),ug=({fps:e,frame:n,playbackRate:r,startFrom:s})=>{const o=dg({frame:n,playbackRate:r,startFrom:s}),a=1e3/e;return o*a/1e3},Yf={},Q2=(e,n)=>{if(e===null||e.seekable.length===0||e.seekable.length>1||Yf[e.src])return;const r={start:e.seekable.start(0),end:e.seekable.end(0)};if(r.start===0&&r.end===0){const s=[`The media ${e.src} cannot be seeked. This could be one of few reasons:`,"1) The media resource was replaced while the video is playing but it was not loaded yet.","2) The media does not support seeking.","3) The media was loaded with security headers prventing it from being included.","Please see https://remotion.dev/docs/non-seekable-media for assistance."].join(` 29`);if(n==="console-error")console.error(s);else if(n==="console-warning")console.warn(`The media ${e.src}
29 does not support seeking. The video will render fine, but may not play correctly in the Remotion Studio and in the <Player>. See https://remotion.dev/docs/non-seekable-media for an explanation.`);else throw new Error(s);Yf[e.src]=!0}},mg=({mediaRef:e,src:n,mediaType:r,playbackRate:s,preservePitch:o=!0,onlyWarnForMediaSeekingError:a,acceptableTimeshift:l,pauseWhenBuffering:c,isPremounting:u,isPostmounting:d,onAutoPlayError:h})=>{const{playbackRate:p}=Gm(),b=xs(),y=Ua(),[v]=vx(),w=i.useContext(Zi),{fps:C}=as(),k=ai(),E=i.useRef(null),m=i.useRef(null),M=Jo(),I=Wl();if(!w)throw new Error("useMediaPlayback must be used inside a <BufferingContext>");const N=i.useRef({}),F=i.useCallback(()=>{n&&(N.current[n]||(Dr.verbose({logLevel:M,tag:null},`Detected ${n} as a variable FPS video. Disabling buffering while seeking.`),N.current[n]=!0))},[M,n]),R=Z2({mediaRef:e,mediaType:r,lastSeek:m,onVariableFpsVideoDetected:F}),A=X2(e),V=ug({frame:b,playbackRate:s,startFrom:-k,fps:C}),z=J2({element:e,shouldBuffer:c,isPremounting:u,isPostmounting:d,logLevel:M,mountTime:I,src:n??null}),{bufferUntilFirstFrame:H,isBuffering:ne}=q2({mediaRef:e,mediaType:r,onVariableFpsVideoDetected:F,pauseWhenBuffering:c,logLevel:M,mountTime:I}),se=s*p,pe=(()=>{var we;return(we=e.current)!=null&&we.duration?Math.min(e.current.duration,l??.65):l??.65})(),ie=cg(w);i.useEffect(()=>{var oe,we,Re,le,Ne;if((oe=e.current)!=null&&oe.paused)return;if(!v){os({logLevel:M,tag:"pause",message:`Pausing ${(we=e.current)==null?void 0:we.src} because ${u?"media is premounting":d?"media is postmounting":"Player is not playing"}`,mountTime:I}),(Re=e.current)==null||Re.pause();return}const D=z||ne();w.buffering.current&&!D&&(os({logLevel:M,tag:"pause",message:`Pausing ${(le=e.current)==null?void 0:le.src} because player is buffering but media tag is not`,mountTime:I}),(Ne=e.current)==null||Ne.pause())},[ne,z,w,ie,u,M,e,r,I,v,d]);const O=Pr();i.useLayoutEffect(()=>{const D=Math.max(0,se);e.current&&e.current.playbackRate!==D&&(e.current.playbackRate=D),e.current&&e.current.preservesPitch!==o&&(e.current.preservesPitch=o)},[e,se,o]),i.useEffect(()=>{var xt,J;const D=r==="audio"?"<Html5Audio>":"<Html5Video>";if(!e.current)throw new Error(`No ${r} ref found`);if(!n)throw new Error(`No 'src' attribute was passed to the ${D} element.`);const{duration:W}=e.current,oe=!Number.isNaN(W)&&Number.isFinite(W)?Math.min(W,V):V,we=A.current.time,Re=((xt=R.current)==null?void 0:xt.time)??null,le=N.current[n],Ne=Math.abs(oe-we),ce=Re?Math.abs(oe-Re):null,Ae=(J=R.current)!=null&&J.lastUpdate&&R.current.time>A.current.lastUpdate?ce:Ne,De=ce&&!le?Ae:Ne;if(De>pe&&E.current!==oe){m.current=Vc({mediaRef:e.current,time:oe,logLevel:M,why:`because time shift is too big. shouldBeTime = ${oe}, isTime = ${we}, requestVideoCallbackTime = ${Re}, timeShift = ${De}${le?", isVariableFpsVideo = true":""}, isPremounting = ${u}, isPostmounting = ${d}, pauseWhenBuffering = ${c}`,mountTime:I}),E.current=m.current,v&&(se>0&&H(oe),e.current.paused&&sd({mediaRef:e,mediaType:r,onAutoPlayError:h,logLevel:M,mountTime:I,reason:"player is playing but media tag is paused, and just seeked",isPlayer:O.isPlayer})),a||Q2(e.current,a?"console-warning":"console-error");return}const Ze=v?.15:.01,Ye=Math.abs(e.current.currentTime-oe)>Ze,at=z||ne(),ut=w.buffering.current&&!at;if(!v||ut){Ye&&(m.current=Vc({mediaRef:e.current,time:oe,logLevel:M,why:`not playing or something else is buffering. time offset is over seek threshold (${Ze})`,mountTime:I}));return}if(!v||w.buffering.current)return;const Xe=e.current.paused&&!e.current.ended;if(Xe||y===0){const Ie=Xe?"media tag is paused":"absolute frame is 0";Ye&&(m.current=Vc({mediaRef:e.current,time:oe,logLevel:M,why:`is over timeshift threshold (threshold = ${Ze}) and ${Ie}`,mountTime:I})),sd({mediaRef:e,mediaType:r,onAutoPlayError:h,logLevel:M,mountTime:I,reason:`player is playing and ${Ie}`,isPlayer:O.isPlayer}),!le&&se>0&&H(oe)}},[y,pe,H,w.buffering,R,M,V,ne,z,e,r,a,se,v,n,h,u,d,c,I,A,O.isPlayer])},pg=({mediaRef:e,id:n,mediaType:r,onAutoPlayError:s,isPremounting:o,isPostmounting:a})=>{const{audioAndVideoTags:l,imperativePlaying:c}=Va(),u=Jo(),d=Wl(),h=Pr();i.useEffect(()=>{const p={id:n,play:b=>{if(c.current&&!(o||a))return sd({mediaRef:e,mediaType:r,onAutoPlayError:s,logLevel:u,mountTime:d,reason:b,isPlayer:h.isPlayer})}};return l.current.push(p),()=>{l.current=l.current.filter(b=>b.id!==n)}},[l,n,e,r,s,c,o,a,u,d,h.isPlayer])},op=i.createContext({mediaMuted:!1,mediaVolume:1}),ap=i.createContext({setMediaMuted:()=>{throw new Error("default")},setMediaVolume:()=>{throw new Error("default")}}),ip=()=>{const{mediaVolume:e}=i.useContext(op),{setMediaVolume:n}=i.useContext(ap);return i.useMemo(()=>[e,n],[e,n])},lp=()=>{const{mediaMuted:e}=i.useContext(op),{setMediaMuted:n}=i.useContext(ap);return i.useMemo(()=>[e,n],[e,n])},Qi=e=>{if(e>=100)throw new Error(`Volume was set to ${e}, but regular volume is 1, not 100. Did you forget to divide by 100? Set a volume of less than 100 to dismiss this error.`)},e5=(e,n)=>{const[r]=i.useState(e.shouldPreMountAudioTags);if(e.shouldPreMountAudioTags!==r)throw new Error("Cannot change the behavior for pre-mounting audio tags dynamically.");const s=Jo(),{volume:o,muted:a,playbackRate:l,preservePitch:c,shouldPreMountAudioTags:u,src:d,onDuration:h,acceptableTimeShiftInSeconds:p,_remotionInternalNeedsDurationCalculation:b,_remotionInternalNativeLoopPassed:y,_remotionInternalStack:v,allowAmplificationDuringRender:w,name:C,pauseWhenBuffering:k,showInTimeline:E,loopVolumeCurveBehavior:m,stack:M,crossOrigin:I,delayRenderRetries:N,delayRenderTimeoutInMilliseconds:F,toneFrequency:R,useWebAudioApi:A,onError:V,onNativeError:z,audioStreamIndex:H,...ne}=e,[se]=ip(),[pe]=lp(),ie=Ji(m??"repeat");if(!d)throw new TypeError("No 'src' was passed to <Html5Audio>.");const O=fi(d),D=i.useContext(Rr),[W]=i.useState(()=>String(Math.random())),oe=hi({frame:ie,volume:o,mediaVolume:se});Qi(oe);const we=np({crossOrigin:I,requestsVideoFrame:!1,isClientSideRendering:!1}),Re=i.useMemo(()=>({muted:a||pe||oe<=0,src:O,loop:y,crossOrigin:we,...ne}),[y,pe,a,ne,O,oe,we]),le=i.useMemo(()=>`audio-${Oa(d??"")}-${D==null?void 0:D.relativeFrom}-${D==null?void 0:D.cumulatedFrom}-${D==null?void 0:D.durationInFrames}-muted:${e.muted}-loop:${e.loop}`,[d,D==null?void 0:D.relativeFrom,D==null?void 0:D.cumulatedFrom,D==null?void 0:D.durationInFrames,e.muted,e.loop]),{el:Ne,mediaElementSourceNode:ce,cleanupOnMediaTagUnmount:Ae}=L2({aud:Re,audioId:le,premounting:!!(D!=null&&D.premounting),postmounting:!!(D!=null&&D.postmounting)}),De=i.useCallback(()=>v??null,[v]);sp({volume:o,mediaVolume:se,src:d,mediaType:"audio",playbackRate:l??1,displayName:C??null,id:W,getStack:De,showInTimeline:E,premountDisplay:(D==null?void 0:D.premou
29ntDisplay)??null,postmountDisplay:(D==null?void 0:D.postmountDisplay)??null,loopDisplay:void 0,documentationLink:"https://www.remotion.dev/docs/html5-audio",refForOutline:null}),mg({mediaRef:Ne,src:d,mediaType:"audio",playbackRate:l??1,preservePitch:c,onlyWarnForMediaSeekingError:!1,acceptableTimeshift:p??null,isPremounting:!!(D!=null&&D.premounting),isPostmounting:!!(D!=null&&D.postmounting),pauseWhenBuffering:k,onAutoPlayError:null}),pg({id:W,isPostmounting:!!(D!=null&&D.postmounting),isPremounting:!!(D!=null&&D.premounting),mediaRef:Ne,mediaType:"audio",onAutoPlayError:null}),og({logLevel:s,mediaRef:Ne,source:ce,volume:oe,shouldUseWebAudioApi:A??!1}),(qe.useInsertionEffect??qe.useLayoutEffect)(()=>()=>{requestAnimationFrame(()=>{Ae()})},[Ae]),i.useImperativeHandle(n,()=>Ne.current,[Ne]);const Ye=i.useRef(h);return Ye.current=h,i.useEffect(()=>{var Xe;const{current:at}=Ne;if(!at)return;if(at.duration){(Xe=Ye.current)==null||Xe.call(Ye,at.src,at.duration);return}const ut=()=>{var nt;(nt=Ye.current)==null||nt.call(Ye,at.src,at.duration)};return at.addEventListener("loadedmetadata",ut),()=>{at.removeEventListener("loadedmetadata",ut)}},[Ne,d]),r?null:t.jsx("audio",{ref:Ne,preload:"metadata",crossOrigin:we,...Re})},fg=i.forwardRef(e5),t5=(e,n)=>{const r=i.useRef(null),{volume:s,playbackRate:o,allowAmplificationDuringRender:a,onDuration:l,toneFrequency:c,_remotionInternalNeedsDurationCalculation:u,_remotionInternalNativeLoopPassed:d,acceptableTimeShiftInSeconds:h,name:p,onNativeError:b,delayRenderRetries:y,delayRenderTimeoutInMilliseconds:v,loopVolumeCurveBehavior:w,pauseWhenBuffering:C,audioStreamIndex:k,preservePitch:E,...m}=e,M=Ua(),I=Ji(w??"repeat"),N=xs(),F=i.useContext(Rr),{registerRenderAsset:R,unregisterRenderAsset:A}=i.useContext(pi),{delayRender:V,continueRender:z}=$o(),H=i.useMemo(()=>`audio-${Oa(e.src??"")}-${F==null?void 0:F.relativeFrom}-${F==null?void 0:F.cumulatedFrom}-${F==null?void 0:F.durationInFrames}`,[e.src,F==null?void 0:F.relativeFrom,F==null?void 0:F.cumulatedFrom,F==null?void 0:F.durationInFrames]),ne=hi({volume:s,frame:I,mediaVolume:1});Qi(ne),i.useImperativeHandle(n,()=>r.current,[]),i.useEffect(()=>{if(!e.src)throw new Error("No src passed");if(window.remotion_audioEnabled&&!e.muted&&!(ne<=0))return R({type:"audio",src:Xo(e.src),id:H,frame:M,volume:ne,mediaFrame:N,playbackRate:e.playbackRate??1,toneFrequency:c??1,audioStartFrame:Math.max(0,-((F==null?void 0:F.cumulatedNegativeFrom)??0)),audioStreamIndex:k??0}),()=>A(H)},[e.muted,e.src,R,M,H,A,ne,I,N,o,e.playbackRate,c,F==null?void 0:F.cumulatedNegativeFrom,k]);const{src:se}=e,pe=n||u;return i.useLayoutEffect(()=>{var W,oe;if(((oe=(W=window.process)==null?void 0:W.env)==null?void 0:oe.NODE_ENV)==="test"||!pe)return;const ie=V("Loading <Html5Audio> duration with src="+se,{retries:y??void 0,timeoutInMilliseconds:v??void 0}),{current:O}=r,D=()=>{O!=null&&O.duration&&l(O.src,O.duration),z(ie)};return O!=null&&O.duration?(l(O.src,O.duration),z(ie)):O==null||O.addEventListener("loadedmetadata",D,{once:!0}),()=>{O==null||O.removeEventListener("loadedmetadata",D),z(ie)}},[se,l,pe,y,v,z,V]),pe?t.jsx("audio",{ref:r,...m,onError:b}):null},n5=i.forwardRef(t5),r5=(e,n)=>{const r=i.useContext(Pd),{startFrom:s,endAt:o,trimBefore:a,trimAfter:l,name:c,stack:u,pauseWhenBuffering:d,showInTimeline:h,onError:p,...b}=e,{loop:y,...v}=e,{fps:w}=as(),C=Pr();if(C.isClientSideRendering)throw new Error("<Html5Audio> is not supported in @remotion/web-renderer. Use <Audio> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations");const{durations:k,setDurations:E}=i.useContext(tp);if(typeof e.src!="string")throw new TypeError(`The \`<Html5Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(e.src)} instead.`);const m=fi(e.src),M=i.useCallback(A=>{console.log(A.currentTarget.error);const V=`Could not play audio with src ${m}: ${A.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;if(y){if(p){p(new Error(V));return}Ol(new Error(V))}else p==null||p(new Error(V)),console.warn(V)},[y,p,m]),I=i.useCallback((A,V)=>{E({type:"got-duration",durationInSeconds:V,src:A})},[E]),N=k[Xo(m)]??k[Xo(e.src)];
29Fd({startFrom:s,endAt:o,trimBefore:a,trimAfter:l});const{trimBeforeValue:F,trimAfterValue:R}=Rd({startFrom:s,endAt:o,trimBefore:a,trimAfter:l});if(y&&N!==void 0){if(!Number.isFinite(N))return t.jsx(Sl,{...v,ref:n,_remotionInternalNativeLoopPassed:!0});const A=N*w;return t.jsx(Zl,{layout:"none",durationInFrames:Ed({trimAfter:R,mediaDurationInFrames:A,playbackRate:e.playbackRate??1,trimBefore:F}),children:t.jsx(Sl,{...v,ref:n,_remotionInternalNativeLoopPassed:!0})})}return typeof F<"u"||typeof R<"u"?t.jsx(Ir,{layout:"none",from:0-(F??0),showInTimeline:!1,durationInFrames:R,name:c,children:t.jsx(Sl,{_remotionInternalNeedsDurationCalculation:!!y,pauseWhenBuffering:d??!1,...b,ref:n})}):(Id({playbackRate:e.playbackRate,preservePitch:e.preservePitch,volume:e.volume},"Html5Audio"),C.isRendering?t.jsx(n5,{onDuration:I,...e,ref:n,onNativeError:M,_remotionInternalNeedsDurationCalculation:!!y}):t.jsx(fg,{_remotionInternalNativeLoopPassed:e._remotionInternalNativeLoopPassed??!1,_remotionInternalStack:u??null,shouldPreMountAudioTags:r!==null&&r.numberOfAudioTags>0,...e,ref:n,onNativeError:M,onDuration:I,pauseWhenBuffering:d??!1,_remotionInternalNeedsDurationCalculation:!!y,showInTimeline:h??!0}))},Sl=i.forwardRef(r5);_s(Sl);var s5=Sl,o5=e=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new Error(`<Solid>: \`pixelDensity\` must be a positive finite number. Received: ${String(e)}.`);return e},a5={durationInFrames:va,from:Ba,freeze:wa,color:{type:"color",default:"transparent",description:"Color"},width:{type:"number",min:1,step:1,default:1920,description:"Width",hiddenFromList:!1},height:{type:"number",min:1,step:1,default:1080,description:"Height",hiddenFromList:!1},...za,hidden:ya},i5=({color:e,width:n,height:r,effects:s=[],className:o,style:a,pixelDensity:l,overrideId:c,reference:u})=>{const{delayRender:d,continueRender:h,cancelRender:p}=$o(),b=o5(l),y=Math.ceil(n*b),v=Math.ceil(r*b),[w,C]=i.useState(null),k=ql({effects:s,overrideId:c??null}),E=i.useMemo(()=>{if(typeof document>"u")return null;const N=document.createElement("canvas");return N.width=1,N.height=1,N},[]),m=Jl(),M=i.useCallback(N=>{C(N),typeof u=="function"?u(N):u&&(u.current=N)},[u]);i.useEffect(()=>{if(!w||!E)return;const N=d("Solid effect chain");if(!m)return h(N),()=>{h(N)};const F=E.getContext("2d",{colorSpace:"srgb"});if(!F){p(new Error("Failed to acquire 2D context for <Solid> source"));return}return F.clearRect(0,0,1,1),e!==void 0&&(F.fillStyle=e,F.fillRect(0,0,1,1)),Xl({state:m.get(y,v),source:E,effects:k,output:w,width:y,height:v}).then(R=>{R&&h(N)}).catch(R=>{p(R)}),()=>{h(N)}},[e,w,E,m,y,v,d,h,p,k]);const I=i.useMemo(()=>({width:n,height:r,...a??{}}),[r,a,n]);return t.jsx("canvas",{ref:M,width:y,height:v,className:o,style:I})},l5=i.forwardRef(({effects:e=[],_experimentalControls:n,color:r,height:s,width:o,className:a,durationInFrames:l,style:c,name:u,from:d,freeze:h,hidden:p,showInTimeline:b,pixelDensity:y,...v},w)=>{const C=Gl(e),k=i.useRef(null);return i.useImperativeHandle(w,()=>k.current,[]),t.jsx(Ir,{layout:"none",from:d,freeze:h,hidden:p,showInTimeline:b,_experimentalControls:n,_remotionInternalEffects:C,durationInFrames:l,name:u??"<Solid>",_remotionInternalRefForOutline:k,_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/solid",...v,children:t.jsx(i5,{reference:k,overrideId:(n==null?void 0:n.overrideId)??null,color:r,height:s,width:o,className:a,style:c,effects:e,pixelDensity:y})})}),hg=Zo({Component:l5,componentIdentity:"dev.remotion.remotion.Solid",schema:a5,supportsEffects:!0});hg.displayName="Solid";_s(hg);var hc=null,xg=()=>{if(hc!==null)return hc;if(typeof document>"u")return!1;const e=document.createElement("canvas"),n=e.getContext("2d");return hc=typeof(n==null?void 0:n.drawElementImage)=="function"&&typeof e.requestPaint=="function"&&typeof e.captureElementImage=="function"&&"transferControlToOffscreen"in HTMLCanvasElement.prototype,hc},c5="HTML in Canvas is not supported. Two common causes: Chrome is older than version 148 (update Chrome), or the HTML-in-Canvas flag is disabled at chrome://flags/#canvas-draw-element (enable it and restart Chrome).";function d5(e,n){if(typeof e!="number"||typeof n!="number")throw new Error(`HtmlInCanvas: \`width\` and \`height\` must be numbers. Received width=${String(e)}, height=${String(n)}.`);if(!Number.isInteger(e)||e<=0)throw new Error(`HtmlInCanvas: \`width\` must be a positive integer. Received: ${String(e)}.`);
29if(!Number.isInteger(n)||n<=0)throw new Error(`HtmlInCanvas: \`height\` must be a positive integer. Received: ${String(n)}.`)}function u5(e){if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new Error(`HtmlInCanvas: \`pixelDensity\` must be a positive finite number. Received: ${String(e)}.`);return e}var Gf=({offscreen:e,width:n,height:r})=>{e.width!==n&&(e.width=n),e.height!==r&&(e.height=r)},m5=({canvas:e,element:n,elementImage:r})=>{const s=e.getContext("2d");if(!s)throw new Error("Failed to acquire 2D context for <HtmlInCanvas> canvas");s.reset();const o=s.drawElementImage(r,0,0);n.style.transform=o.toString()},qf=i.createContext(!1),gg=i.forwardRef(({width:e,height:n,effects:r,children:s,onPaint:o,onInit:a,pixelDensity:l,controls:c,style:u},d)=>{const h=i.useContext(qf);d5(e,n);const p=u5(l),b=Math.ceil(e*p),y=Math.ceil(n*p),{continueRender:v,cancelRender:w}=$o();xg()||w(new Error(c5));const C=i.useRef(null),k=i.useRef(null),E=i.useRef(null),m=`${e}x${n}@${p}`,M=i.useCallback(O=>{C.current=O,typeof d=="function"?d(O):d&&(d.current=O)},[d]),I=Jl(),N=ql({effects:r,overrideId:(c==null?void 0:c.overrideId)??null}),F=i.useRef(N);F.current=N;const R=i.useRef(o);R.current=o;const A=i.useRef(a);A.current=a;const V=i.useRef(!1),z=i.useRef(null),H=i.useRef(!1),ne=i.useCallback(async()=>{const O=E.current;if(!O)throw new Error("Canvas or scene element not found");const D=k.current;if(!D)throw new Error("HtmlInCanvas: offscreen canvas not ready (transferControlToOffscreen failed or canvas is remounting)");Gf({offscreen:D,width:b,height:y});try{const W=C.current;if(!W)throw new Error("Canvas not found");if(!D.getContext("2d"))throw new Error("Failed to acquire 2D context for <HtmlInCanvas> offscreen canvas");const we=Ef("onPaint");if(!V.current){V.current=!0;const Ne=W.captureElementImage(O),ce=A.current;if(ce){const Ae=await ce({canvas:D,element:O,elementImage:Ne,pixelDensity:p});if(typeof Ae!="function")throw new Error("HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.");H.current?Ae():z.current=Ae}}const Re=R.current??m5,le=W.captureElementImage(O);await Re({canvas:D,element:O,elementImage:le,pixelDensity:p}),await Xl({state:I.get(b,y),source:D,effects:F.current,output:D,width:b,height:y}),v(we)}catch(W){w(W)}},[y,b,I,v,w,p]);i.useLayoutEffect(()=>{const O=C.current;if(!O)throw new Error("Canvas not found");O.layoutSubtree=!0;const D=O.transferControlToOffscreen();return k.current=D,Gf({offscreen:D,width:b,height:y}),V.current=!1,H.current=!1,O.addEventListener("paint",ne),()=>{var W;O.removeEventListener("paint",ne),k.current=null,V.current=!1,H.current=!0,(W=z.current)==null||W.call(z),z.current=null}},[ne,w,b,y]);const se=i.useRef(!1);i.useLayoutEffect(()=>{var D;if(!se.current){se.current=!0;return}const O=C.current;O&&((D=O.requestPaint)==null||D.call(O))},[o,N]),i.useLayoutEffect(()=>{const O=C.current;if(!O)return;const D=Ef("waiting for first paint after canvas resize");return O.addEventListener("paint",()=>{v(D)},{once:!0}),()=>{v(D)}},[e,n,v,m]);const pe=i.useMemo(()=>({width:e,height:n}),[e,n]),ie=i.useMemo(()=>({width:e,height:n,...u??{}}),[n,u,e]);if(h)throw new Error("<HtmlInCanvas> effects cannot be nested together. Chrome will only display the outer effect. Consider merging the effects into one if you can.");return t.jsx(qf.Provider,{value:!0,children:t.jsx("canvas",{ref:M,width:b,height:y,style:ie,children:t.jsx("div",{ref:E,style:pe,children:s})},m)})});gg.displayName="HtmlInCanvasContent";var bg=i.forwardRef(({width:e,height:n,effects:r=[],children:s,onPaint:o,onInit:a,pixelDensity:l,_experimentalControls:c,style:u,durationInFrames:d,name:h,...p},b)=>{const{durationInFrames:y}=as(),v=d??y,w=Gl(r),C=i.useRef(null),k=i.useCallback(E=>{C.current=E,typeof b=="function"?b(E):b&&(b.current=E)},[b]);return t.jsx(Ir,{durationInFrames:v,name:h??"<HtmlInCanvas>",_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/remotion/html-in-canvas",_experimentalControls:c,_remotionInternalEffects:w,_remotionInternalRefForOutline:C,layout:"none",...p,children:t.jsx(gg,{ref:k,width:e,height:n,effects:r,onPaint:o,onInit:a,pixelDensity:l,controls:c,style:u,children:s})})});bg.displayName="HtmlInCanvas";var p5={durationInFrames:va,from:Ba,freeze:wa,...za,hidden:ya},f5=Zo({Component:bg,componentIdentity:"dev.remotion.remotion.HtmlInCanvas",schema:p5,supportsEffects:!0}),cp=Object.assign(f5,{isSupported:xg});cp.displayName="HtmlInCanvas";_s(cp);function _a(e){return e.startsWith("data:")&&e.length>100?e.slice(0,60)+"...["+e.length+" chars total]":e}var h5={durationInFrames:va,from:Ba,freeze:wa,fit:{type:"enum",default:"fill",description:"Fit",variants:{fill:{},contain:{},cover:{}}},...za,hidden:ya},x5=()=>
29{if(typeof DOMException<"u")return new DOMException("Image loading was aborted","AbortError");const e=new Error("Image loading was aborted");return e.name="AbortError",e},g5=({src:e,signal:n})=>new Promise((r,s)=>{const o=new Image;let a=!1;function l(){o.onload=null,o.onerror=null}function c(d){a||(a=!0,l(),d())}function u(){c(()=>s(x5()))}if(o.onload=()=>{var d;Promise.resolve((d=o.decode)==null?void 0:d.call(o)).catch(()=>{}).then(()=>{const h=o.naturalWidth||o.width,p=o.naturalHeight||o.height;if(h<=0||p<=0){c(()=>s(new Error(`Could not determine dimensions for <CanvasImage> with src="${_a(e)}"`)));return}c(()=>r({element:o,width:h,height:p}))})},o.onerror=()=>{c(()=>s(new Error(`Could not load <CanvasImage> with src="${_a(e)}"`)))},n.addEventListener("abort",u,{once:!0}),n.aborted){u();return}o.crossOrigin="anonymous",o.src=e});function b5(e){return 1e3*2**(e-1)}var yg=i.forwardRef(({src:e,width:n,height:r,fit:s="fill",effects:o,controls:a,onError:l,className:c,style:u,id:d,pauseWhenLoading:h,maxRetries:p=2,delayRenderRetries:b,delayRenderTimeoutInMilliseconds:y,refForOutline:v,...w},C)=>{const{delayRender:k,continueRender:E,cancelRender:m}=$o(),{delayPlayback:M}=Ad(),[I,N]=i.useState(null),F=fi(e),R=Jl(),A=ql({effects:o,overrideId:(a==null?void 0:a.overrideId)??null}),V=i.useContext(Rr),z=i.useMemo(()=>typeof document>"u"?null:document.createElement("canvas"),[]),H=i.useCallback(ne=>{N(ne),v&&(v.current=ne),typeof C=="function"?C(ne):C&&(C.current=ne)},[C,v]);return i.useEffect(()=>{if(!I||!z)return;const ne=!!(V!=null&&V.premounting),se=!!(V!=null&&V.postmounting),pe=k(`Rendering <CanvasImage> with src="${_a(F)}"`,{retries:b??void 0,timeoutInMilliseconds:y??void 0}),ie=h&&!ne&&!se?M().unblock:()=>{},O=new AbortController;let D=!1,W=!1,oe=0,we=null;const Re=()=>{W||(W=!0,ie(),E(pe))},le=()=>{g5({src:F,signal:O.signal}).then(Ne=>{if(D)return;const ce=n??Ne.width,Ae=r??Ne.height,De=z.getContext("2d",{colorSpace:"srgb"});if(!De)throw new Error("Could not get 2D context for <CanvasImage> source canvas");return z.width=ce,z.height=Ae,I.width=ce,I.height=Ae,De.clearRect(0,0,ce,Ae),De.drawImage(Ne.element,...Kx(s,{width:Ne.width,height:Ne.height},{width:ce,height:Ae})),Xl({state:R.get(ce,Ae),source:z,effects:A,output:I,width:ce,height:Ae})}).then(Ne=>{Ne&&!D&&Re()}).catch(Ne=>{if(Ne.name==="AbortError"){Re();return}if(oe++,oe<=p){const ce=b5(oe);console.warn(`Could not load <CanvasImage> with src="${_a(F)}", retrying in ${ce}ms`),we=setTimeout(()=>{D||le()},ce)}else l?(l(Ne),Re()):m(Ne)})};return le(),()=>{D=!0,we!==null&&clearTimeout(we),O.abort(),Re()}},[F,m,R,E,M,k,b,y,s,r,p,A,l,I,h,V==null?void 0:V.postmounting,V==null?void 0:V.premounting,z,n]),t.jsx("canvas",{...w,ref:H,width:n,height:r,className:c,style:u,id:d})});yg.displayName="CanvasImageContent";var y5=i.forwardRef(({src:e,width:n,height:r,fit:s,effects:o=[],className:a,style:l,id:c,onError:u,pauseWhenLoading:d,maxRetries:h,delayRenderRetries:p,delayRenderTimeoutInMilliseconds:b,durationInFrames:y,from:v,freeze:w,hidden:C,name:k,showInTimeline:E,stack:m,_experimentalControls:M,_remotionInternalDocumentationLink:I,_remotionInternalRefForOutline:N,...F},R)=>{if(!e)throw new Error('No "src" prop was passed to <CanvasImage>.');const A=Gl(o),V=i.useRef(null);return i.useImperativeHandle(R,()=>V.current,[]),t.jsx(Ir,{layout:"none",from:v??0,durationInFrames:y??1/0,freeze:w,hidden:C,showInTimeline:E??!0,name:k??"<CanvasImage>",_remotionInternalDocumentationLink:I??"https://www.remotion.dev/docs/canvasimage",_experimentalControls:M,_remotionInternalEffects:A,_remotionInternalIsMedia:{type:"image",src:e},_remotionInternalStack:m,_remotionInternalRefForOutline:N??V,children:t.jsx(yg,{ref:V,src:e,width:n,height:r,fit:s,effects:o,controls:M,className:a,style:l,id:c,onError:u,pauseWhenLoading:d,maxRetries:h,delayRenderRetries:p,delayRenderTimeoutInMilliseconds:b,refForOutline:N??null,...F})})}),dp=Zo({Component:y5,componentIdentity:"dev.remotion.remotion.CanvasImage",schema:h5,supportsEffects:!0});dp.displayName="CanvasImage";_s(dp);var v5=({onLoad:e,onError:n,delayRenderRetries:r,delayRenderTimeoutInMilliseconds:s,...o},a)=>{const{delayRender:l,continueRender:c}=$o(),[u]=i.useState(()=>l(`Loading <IFrame> with source ${o.src}`,{retries:r??void 0,timeoutInMilliseconds:s??void 0})),d=i.useCallback(p=>{c(u),e==null||e(p)},[u,e,c]),h=i.useCallback(p=>{c(u),n?n(p):console.error("Error loading iframe:",p,"Handle the event using the onError() prop to make this message disappear.")},[u,n,c]);
29return t.jsx("iframe",{referrerPolicy:"strict-origin-when-cross-origin",...o,ref:a,onError:h,onLoad:d})};i.forwardRef(v5);function w5(e){return 1e3*2**(e-1)}var j5=({onError:e,maxRetries:n=2,src:r,pauseWhenLoading:s,delayRenderRetries:o,delayRenderTimeoutInMilliseconds:a,onImageFrame:l,crossOrigin:c,decoding:u,ref:d,refForOutline:h,...p})=>{const b=i.useRef(null),y=i.useRef({}),{delayPlayback:v}=Ad(),w=i.useContext(Rr),C=i.useCallback(V=>{b.current=V,h.current=V,typeof d=="function"?d(V):d&&(d.current=V)},[d,h]),k=fi(r),E=i.useCallback(V=>{if(!b.current)return;const z=b.current.src;setTimeout(()=>{var ne;if(!b.current)return;const H=(ne=b.current)==null?void 0:ne.src;H===z&&(b.current.removeAttribute("src"),b.current.setAttribute("src",H))},V)},[]),{delayRender:m,continueRender:M,cancelRender:I}=$o(),N=i.useCallback(V=>{var z,H,ne,se,pe,ie,O;if(y.current){if(y.current[(z=b.current)==null?void 0:z.src]=(y.current[(H=b.current)==null?void 0:H.src]??0)+1,e&&(y.current[(ne=b.current)==null?void 0:ne.src]??0)>n){e(V);return}if((y.current[(se=b.current)==null?void 0:se.src]??0)<=n){const D=w5(y.current[(pe=b.current)==null?void 0:pe.src]??0);console.warn(`Could not load image with source ${_a((ie=b.current)==null?void 0:ie.src)}, retrying again in ${D}ms`),E(D);return}try{I("Error loading image with src: "+_a((O=b.current)==null?void 0:O.src))}catch{}}},[I,n,e,E]);if(typeof window<"u"){const V=!!(w!=null&&w.premounting),z=!!(w!=null&&w.postmounting);i.useLayoutEffect(()=>{var O,D;if(((D=(O=window.process)==null?void 0:O.env)==null?void 0:D.NODE_ENV)==="test"){b.current&&(b.current.src=k);return}const{current:H}=b;if(!H)return;const ne=m("Loading <Img> with src="+_a(k),{retries:o??void 0,timeoutInMilliseconds:a??void 0}),se=s&&!V&&!z?v().unblock:()=>{};let pe=!1;const ie=()=>{var W,oe,we;if(pe){M(ne);return}(y.current[(W=b.current)==null?void 0:W.src]??0)>0&&(delete y.current[(oe=b.current)==null?void 0:oe.src],console.info(`Retry successful - ${_a((we=b.current)==null?void 0:we.src)} is now loaded`)),H&&(l==null||l(H)),se(),M(ne)};if(!b.current){ie();return}return H.src=k,H.decode().then(ie).catch(W=>{console.warn(W),H.complete&&H.naturalWidth>0&&H.naturalHeight>0?ie():H.addEventListener("load",ie)}),()=>{pe=!0,H.removeEventListener("load",ie),se(),M(ne)}},[k,v,o,a,s,V,z,l,M,m])}const{isClientSideRendering:F,isRendering:R}=Pr(),A=np({crossOrigin:c,requestsVideoFrame:!1,isClientSideRendering:F});return t.jsx("img",{...p,ref:C,crossOrigin:A,onError:N,decoding:R?"sync":u})},N5=({hidden:e,name:n,stack:r,showInTimeline:s,src:o,from:a,durationInFrames:l,freeze:c,_experimentalControls:u,_remotionInternalRefForOutline:d,...h})=>{if(!o)throw new Error('No "src" prop was passed to <Img>.');return t.jsx(Ir,{layout:"none",from:a??0,durationInFrames:l??1/0,freeze:c,_remotionInternalStack:r,_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/img",_remotionInternalIsMedia:{type:"image",src:o},name:n??"<Img>",_experimentalControls:u,showInTimeline:s??!0,hidden:e,_remotionInternalRefForOutline:d,children:t.jsx(j5,{src:o,refForOutline:d,...h})})},k5=dp,S5={durationInFrames:va,from:Ba,freeze:wa,...za,hidden:ya},C5=new Set(["alt","crossOrigin","decoding","fetchPriority","loading","onError","onImageFrame","onLoad","sizes","srcSet","useMap"]),E5=e=>Object.keys(e).filter(n=>e[n]!==void 0&&C5.has(n)),M5=e=>e.map(n=>`"${n}"`).join(", "),I5=({props:e,ref:n,width:r,height:s})=>{if(typeof r=="string"||typeof s=="string")throw new Error('The "width" and "height" props must be numbers on <Img> when effects are passed, because <Img> renders a <CanvasImage>. Use numeric props or CSS dimensions in "style".');const o=E5(e);if(n!=null&&o.unshift("ref"),o.length!==0)throw new Error(`The ${M5(o)} prop${o.length===1?"":"s"} cannot be used on <Img> when effects are passed, because <Img> renders a <canvas> instead of a native <img>. Remove ${o.length===1?"this prop":"these props"}.`)},F5=e=>{const n=e==null?void 0:e.objectFit;if(n==="fill"||n==="contain"||n==="cover")return n},R5=({effects:e=[],ref:n,hidden:r,name:s,stack:o,showInTimeline:a,src:l,from:c,durationInFrames:u,freeze:d,_experimentalControls:h,width:p,height:b,className:y,style:v,id:w,pauseWhenLoading:C,maxRetries:k,delayRenderRetries:E,delayRenderTimeoutInMilliseconds:m,...M})=>{const I=i.useRef(null);if(e.length===0)return t.jsx(N5,{...M,ref:n,hidden:r,name:s,stack:o,showInTimeline:a,src:l,from:c,durationInFrames:u,freeze:d,_experimentalControls:h,width:p,height:b,className:y,style:v,id:w,pauseWhenLoading:C,maxRetries:k,delayRenderRetries:E,delayRenderTimeoutInMilliseconds:m,_remotionInternalRefForOutline:I});
29if(!l)throw new Error('No "src" prop was passed to <Img>.');I5({props:M,ref:n,width:p,height:b});const N=typeof p=="number"?p:void 0,F=typeof b=="number"?b:void 0,R=M,A=F5(v)??"fill";return t.jsx(k5,{src:l,width:N,height:F,fit:A,effects:e,className:y,style:v,id:w,pauseWhenLoading:C,maxRetries:k,delayRenderRetries:E,delayRenderTimeoutInMilliseconds:m,from:c,durationInFrames:u,freeze:d,hidden:r,name:s??"<Img>",showInTimeline:a,stack:o,_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/img",_experimentalControls:h,_remotionInternalRefForOutline:I,...R})},up=Zo({Component:R5,componentIdentity:"dev.remotion.remotion.Img",schema:S5,supportsEffects:!0});_s(up);var P5={durationInFrames:va,from:Ba,freeze:wa,...za,hidden:ya},T5=(e,n)=>{typeof e=="function"?e(n):e&&(e.current=n)},zt=(e,n)=>{const r=i.forwardRef((o,a)=>{const{durationInFrames:l,from:c,freeze:u,hidden:d,name:h,showInTimeline:p,stack:b,_experimentalControls:y,...v}=o,w=i.useRef(null),C=i.useCallback(k=>{w.current=k,T5(a,k)},[a]);return t.jsx(Ir,{layout:"none",from:c??0,durationInFrames:l??1/0,freeze:u,hidden:d,name:h??n,showInTimeline:p??!0,_experimentalControls:y,_remotionInternalStack:b,_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/interactive",_remotionInternalRefForOutline:w,children:qe.createElement(e,{...v,ref:C})})});r.displayName=n;const s=Zo({Component:r,componentIdentity:`dev.remotion.remotion.${n.slice(1,-1)}`,schema:P5,supportsEffects:!1});return s.displayName=n,_s(s),s};zt("a","<Interactive.A>"),zt("article","<Interactive.Article>"),zt("aside","<Interactive.Aside>"),zt("button","<Interactive.Button>"),zt("circle","<Interactive.Circle>"),zt("code","<Interactive.Code>"),zt("div","<Interactive.Div>"),zt("ellipse","<Interactive.Ellipse>"),zt("em","<Interactive.Em>"),zt("footer","<Interactive.Footer>"),zt("g","<Interactive.G>"),zt("h1","<Interactive.H1>"),zt("h2","<Interactive.H2>"),zt("h3","<Interactive.H3>"),zt("h4","<Interactive.H4>"),zt("h5","<Interactive.H5>"),zt("h6","<Interactive.H6>"),zt("header","<Interactive.Header>"),zt("label","<Interactive.Label>"),zt("li","<Interactive.Li>"),zt("line","<Interactive.Line>"),zt("main","<Interactive.Main>"),zt("nav","<Interactive.Nav>"),zt("ol","<Interactive.Ol>"),zt("p","<Interactive.P>"),zt("path","<Interactive.Path>"),zt("pre","<Interactive.Pre>"),zt("rect","<Interactive.Rect>"),zt("section","<Interactive.Section>"),zt("small","<Interactive.Small>"),zt("span","<Interactive.Span>"),zt("strong","<Interactive.Strong>"),zt("svg","<Interactive.Svg>"),zt("text","<Interactive.Text>"),zt("ul","<Interactive.Ul>");var vg=qe.createRef(),A5=({children:e,onlyRenderComposition:n,currentCompositionMetadata:r,initialCompositions:s,initialCanvasContent:o})=>{const[a,l]=i.useState([]),[c,u]=i.useState(o),[d,h]=i.useState(s),p=i.useRef(d),b=i.useCallback(m=>{h(M=>{const I=m(M);return p.current=I,I})},[]),y=i.useCallback(m=>{b(M=>{if(M.find(I=>I.id===m.id))throw new Error(`Multiple composition with id ${m.id} are registered.`);return[...M,m]})},[b]),v=i.useCallback(m=>{h(M=>M.filter(I=>I.id!==m))},[]),w=i.useCallback((m,M,I,N)=>{l(F=>[...F,{name:m,parent:M,nonce:I,stack:N}])},[]),C=i.useCallback((m,M)=>{l(I=>I.filter(N=>!(N.name===m&&N.parent===M)))},[]);i.useImperativeHandle(vg,()=>({getCompositions:()=>p.current}),[]);const k=i.useMemo(()=>({registerComposition:y,unregisterComposition:v,registerFolder:w,unregisterFolder:C,setCanvasContent:u,onlyRenderComposition:n}),[y,w,v,C,n]),E=i.useMemo(()=>({compositions:d,folders:a,currentCompositionMetadata:r,canvasContent:c}),[d,a,r,c]);return t.jsx(Ki.Provider,{value:E,children:t.jsx(Bl.Provider,{value:k,children:e})})},wg={};J0(wg,{makeDefaultPreviewCSS:()=>_5,injectCSS:()=>$5,OBJECTFIT_CONTAIN_CLASS_NAME:()=>Ul});var xc={},$5=e=>{if(typeof document>"u")return()=>{};if(xc[e])return()=>{};const n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");return r.appendChild(document.createTextNode(e)),n.prepend(r),xc[e]=r,()=>{const s=xc[e];s&&(s.parentNode&&s.parentNode.removeChild(s),delete xc[e])}},Ul="__remotion_objectfitcontain",_5=(e,n)=>e?` 30 ${e} * { 31 box-sizing: border-box; 32 } 33 ${e} *:-webkit-full-screen { 34 width: 100%; 35 height: 100%; 36 } 37 ${e} .${Ul} { 38 object-fit: contain; 39 } 40 `:` 41 * { 42 box-sizing: border-box; 43 } 44 body { 45 margin: 0; 46 background-color: ${n}; 47 } 48 .${Ul} { 49 object-fit: contain; 50 } 51 `,D5={type:"boolean",default:!1,description:"Disabled"},L5=e=>{const{calculateKey:n,validateParams:r}=e,s={...e,documentationLink:e.documentationLink??null,calculateKey:a=>{const l=a.disabled??!1;return`${n(a)}-disabled-${l}`},schema:{disabled:D5,...e.schema}};return(a={})=>
51(r(a),{definition:s,params:a,effectKey:s.calculateKey(a),memoized:!1})},jg="__remotion-studio-container",O5=()=>document.getElementById(jg),V5=qe.createContext(null),U5=null,uu=[],z5=()=>U5,B5=e=>(uu.push(e),()=>{uu=uu.filter(n=>n!==e)}),mp=i.createContext(null),H5=()=>{const e=i.useContext(mp);return!e||e.videoEnabled===null?window.remotion_videoEnabled:e.videoEnabled},K5=()=>{const e=i.useContext(mp);return!e||e.audioEnabled===null?window.remotion_audioEnabled:e.audioEnabled},W5=({children:e,videoEnabled:n,audioEnabled:r})=>{const s=i.useMemo(()=>({videoEnabled:n,audioEnabled:r}),[n,r]);return t.jsx(mp.Provider,{value:s,children:e})},Y5=({children:e,numberOfAudioTags:n,logLevel:r,audioLatencyHint:s,previewSampleRate:o,videoEnabled:a,audioEnabled:l,frameState:c})=>{const u=i.useMemo(()=>{let h=0;return{getNonce:()=>h++}},[]),d=i.useMemo(()=>({logLevel:r,mountTime:Date.now()}),[r]);return t.jsx(mi.Provider,{value:d,children:t.jsx(Hl.Provider,{value:u,children:t.jsx(tw,{frameState:c,children:t.jsx(W5,{videoEnabled:a,audioEnabled:l,children:t.jsx(sx,{children:t.jsx(Qx,{children:t.jsx(ow,{children:t.jsx(tg,{children:t.jsx(lg,{children:t.jsx(ng,{audioLatencyHint:s,audioEnabled:l,previewSampleRate:o,children:t.jsx(rg,{numberOfAudioTags:n,children:e})})})})})})})})})})})},Xf=["h264","h265","vp8","vp9","av1","mp3","aac","wav","prores","h264-mkv","h264-ts","gif"];function G5(e,n,r){if(!(typeof e>"u")){if(typeof e!="string")throw new TypeError(`The "${r}" prop ${n} must be a string, but you passed a value of type ${typeof e}.`);if(!Xf.includes(e))throw new Error(`The "${r}" prop ${n} must be one of ${Xf.join(", ")}, but you passed ${e}.`)}}var Jf=({calculated:e,compositionId:n,compositionFps:r,compositionHeight:s,compositionWidth:o,compositionDurationInFrames:a})=>{const l=`calculated by calculateMetadata() for the composition "${n}"`,c=`of the "<Composition />" component with the id "${n}"`,u=(e==null?void 0:e.width)??o??void 0;nd(u,"width",e!=null&&e.width?l:c);const d=(e==null?void 0:e.height)??s??void 0;nd(d,"height",e!=null&&e.height?l:c);const h=(e==null?void 0:e.fps)??r??null;hd(h,e!=null&&e.fps?l:c);const p=(e==null?void 0:e.durationInFrames)??a??null;fd(p,{allowFloats:!1,component:`of the "<Composition />" component with the id "${n}"`});const b=e==null?void 0:e.defaultCodec;G5(b,l,"defaultCodec");const y=e==null?void 0:e.defaultOutName,v=e==null?void 0:e.defaultVideoImageFormat,w=e==null?void 0:e.defaultPixelFormat,C=e==null?void 0:e.defaultProResProfile,k=e==null?void 0:e.defaultSampleRate;return{width:u,height:d,fps:h,durationInFrames:p,defaultCodec:b,defaultOutName:y,defaultVideoImageFormat:v,defaultPixelFormat:w,defaultProResProfile:C,defaultSampleRate:k}},Ng=({calculateMetadata:e,signal:n,defaultProps:r,inputProps:s,compositionId:o,compositionDurationInFrames:a,compositionFps:l,compositionHeight:c,compositionWidth:u})=>{const d=e?e({defaultProps:r,props:s,abortSignal:n,compositionId:o,isRendering:xo().isRendering}):null;if(d!==null&&typeof d=="object"&&"then"in d)return d.then(p=>{const{height:b,width:y,durationInFrames:v,fps:w,defaultCodec:C,defaultOutName:k,defaultVideoImageFormat:E,defaultPixelFormat:m,defaultProResProfile:M,defaultSampleRate:I}=Jf({calculated:p,compositionDurationInFrames:a,compositionFps:l,compositionHeight:c,compositionWidth:u,compositionId:o});return{width:y,height:b,fps:w,durationInFrames:v,id:o,defaultProps:Xa(r),props:Xa(p.props??s),defaultCodec:C??null,defaultOutName:k??null,defaultVideoImageFormat:E??null,defaultPixelFormat:m??null,defaultProResProfile:M??null,defaultSampleRate:I??null}});const h=Jf({calculated:d,compositionDurationInFrames:a,compositionFps:l,compositionHeight:c,compositionWidth:u,compositionId:o});return d===null?{...h,id:o,defaultProps:Xa(r??{}),props:Xa(s),defaultCodec:null,defaultOutName:null,defaultVideoImageFormat:null,defaultPixelFormat:null,defaultProResProfile:null,defaultSampleRate:null}:{...h,id:o,defaultProps:Xa(r??{}),props:Xa(d.props??s),defaultCodec:d.defaultCodec??null,defaultOutName:d.defaultOutName??null,defaultVideoImageFormat:d.defaultVideoImageFormat??null,defaultPixelFormat:d.defaultPixelFormat??null,defaultProResProfile:d.defaultProResProfile??null,defaultSampleRate:d.defaultSampleRate??null}},q5=e=>{try{return{type:"success",result:Ng(e)}}catch(n){return{type:"error",error:n}}},X5=qe.createContext(()=>{}),J5=()=>
51{if(xo().isRendering){const e=window.remotion_envVariables;return e?{...JSON.parse(e),NODE_ENV:"production"}:{}}return{NODE_ENV:"production"}},Z5=()=>{const e=J5();window.process||(window.process={}),window.process.env||(window.process.env={}),Object.keys(e).forEach(n=>{window.process.env[n]=e[n]})},Q5=qe.createContext(null),ej=i.createContext({setSize:()=>{},size:{size:"auto",translation:{x:0,y:0}}}),tj=({canvasSize:e,compositionHeight:n,compositionWidth:r,previewSize:s})=>{const o=e.height/n,a=e.width/r,l=Math.min(o,a);return s==="auto"?l===0?1:l:Number(s)},nj=qe.createContext(null),rj=({src:e,transparent:n,currentTime:r,toneMapped:s})=>`http://localhost:${window.remotion_proxyPort}/proxy?src=${encodeURIComponent(Xo(e))}&time=${encodeURIComponent(Math.max(0,r))}&transparent=${String(n)}&toneMapped=${String(s)}`,sj=({onError:e,volume:n,playbackRate:r,src:s,muted:o,allowAmplificationDuringRender:a,transparent:l,toneMapped:c,toneFrequency:u,name:d,loopVolumeCurveBehavior:h,delayRenderRetries:p,delayRenderTimeoutInMilliseconds:b,onVideoFrame:y,crossOrigin:v,audioStreamIndex:w,preservePitch:C,...k})=>{const E=Ua(),m=xs(),M=Ji(h),I=yd(),N=i.useContext(Rr),F=ai(),{registerRenderAsset:R,unregisterRenderAsset:A}=i.useContext(pi);if(!s)throw new TypeError("No `src` was passed to <OffthreadVideo>.");const V=i.useMemo(()=>`offthreadvideo-${Oa(s)}-${N==null?void 0:N.cumulatedFrom}-${N==null?void 0:N.relativeFrom}-${N==null?void 0:N.durationInFrames}`,[s,N==null?void 0:N.cumulatedFrom,N==null?void 0:N.relativeFrom,N==null?void 0:N.durationInFrames]);if(!I)throw new Error("No video config found");const z=hi({volume:n,frame:M,mediaVolume:1});Qi(z),i.useEffect(()=>{if(!s)throw new Error("No src passed");if(window.remotion_audioEnabled&&!o&&!(z<=0))return R({type:"video",src:Xo(s),id:V,frame:E,volume:z,mediaFrame:m,playbackRate:r,toneFrequency:u,audioStartFrame:Math.max(0,-((N==null?void 0:N.cumulatedNegativeFrom)??0)),audioStreamIndex:w}),()=>A(V)},[o,s,R,V,A,z,m,E,r,u,N==null?void 0:N.cumulatedNegativeFrom,w]);const H=i.useMemo(()=>dg({frame:m,playbackRate:r||1,startFrom:-F})/I.fps,[m,F,r,I.fps]),ne=i.useMemo(()=>rj({src:s,currentTime:H,transparent:l,toneMapped:c}),[c,H,s,l]),[se,pe]=i.useState(null),{delayRender:ie,continueRender:O}=$o();i.useLayoutEffect(()=>{if(!window.remotion_videoEnabled)return;const we=[];pe(null);const Re=new AbortController,le=ie(`Fetching ${ne} from server`,{retries:p??void 0,timeoutInMilliseconds:b??void 0});return(async()=>{try{const ce=await fetch(ne,{signal:Re.signal,cache:"no-store"});if(ce.status!==200){if(ce.status===500){const Ze=await ce.json();if(Ze.error){const Ye=Ze.error.replace(/^Error: /,"");throw new Error(Ye)}}throw new Error(`Server returned status ${ce.status} while fetching ${ne}`)}const Ae=await ce.blob(),De=URL.createObjectURL(Ae);we.push(()=>URL.revokeObjectURL(De)),pe({src:De,handle:le})}catch(ce){if(ce.message.includes("aborted")){O(le);return}if(Re.signal.aborted){O(le);return}ce.message.includes("Failed to fetch")&&(ce=new Error(`Failed to fetch ${ne}. This could be caused by Chrome rejecting the request because the disk space is low. Consider increasing the disk size of your environment.`,{cause:ce})),e?e(ce):Ol(ce)}})(),we.push(()=>{Re.signal.aborted||Re.abort()}),()=>{we.forEach(ce=>ce())}},[ne,p,b,e,O,ie]);const D=i.useCallback(()=>{e?e==null||e(new Error("Failed to load image with src "+se)):Ol("Failed to load image with src "+se)},[se,e]),W=i.useMemo(()=>[Ul,k.className].filter(Wi).join(" "),[k.className]),oe=i.useCallback(we=>{y&&y(we)},[y]);return!se||!window.remotion_videoEnabled?null:(O(se.handle),t.jsx(up,{src:se.src,delayRenderRetries:p,delayRenderTimeoutInMilliseconds:b,onImageFrame:oe,...k,onError:D,className:W}))},kg=({ref:e,onVideoFrame:n})=>{i.useEffect(()=>{const{current:r}=e;if(!r||!n)return;let s=0;const o=(a,l)=>{e.current&&(n(e.current,a,l),s=e.current.requestVideoFrameCallback(o))};if(n(r),!!r.requestVideoFrameCallback)return s=r.requestVideoFrameCallback(o),()=>{s&&r.cancelVideoFrameCallback(s)}},[n,e])};class Ti extends Error{constructor({message:r,src:s}){super(r);fn(this,"src");this.name="MediaPlaybackError",this.src=s}}var oj=(e,n)=>{const r=i.useContext(Xi);if(!r)throw new Error("SharedAudioContext not found");const s=i.useRef(null),o=i.useMemo(()=>r.audioContext?rp({audioContext:r.audioContext,ref:s}):null,[r.audioContext]);(qe.useInsertionEffect??qe.useLayoutEffect)(()=>()=>{requestAnimationFrame(()=>{o==null||o.cleanup()})},[o]);const{volume:l,muted:c,playbackRate:u,preservePitch:d,onlyWarnForMediaSeekingError:h,src:p,onDuration:b,acceptableTimeShift:y,acceptableTimeShiftInSeconds:v,toneFrequency:w,name:C,_remotionInternalNativeLoopPassed:k,_remotionInternalStack:E,style:m,pauseWhenBuffering:M,showInTimeline:I,loopVolumeCurveBehavior:N,onError:F,onAutoPlayError:R,onVideoFrame:A,crossOrigin:V,delayRenderRetries:z,delayRenderTimeoutInMilliseconds:H,allowAmplificationDuringRender:ne,useWebAudioApi:se,audioStreamIndex:pe,...ie}=e,O=Ji(N??"repeat"),{fps:D,durationInFrames:W}=as(),oe=i.useContext(Rr),we=Jo(),Re=Wl(),[le]=i.useState(()=>String(Math.random()));if(typeof y<"u")throw new Error("acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.");const[Ne]=ip(),[ce]=lp(),Ae=hi({frame:O,volume:l,mediaVolume:Ne});Qi(Ae);const De=i.useCallback(()=>E??null,[E]);sp({volume:l,mediaVolume:Ne,mediaType:"video",src:p,playbackRate:e.playbackRate??1,displayName:C??null,id:le,getStack:De,showInTimeline:I,premou
51ntDisplay:(oe==null?void 0:oe.premountDisplay)??null,postmountDisplay:(oe==null?void 0:oe.postmountDisplay)??null,loopDisplay:void 0,documentationLink:h?"https://www.remotion.dev/docs/offthreadvideo":"https://www.remotion.dev/docs/html5-video",refForOutline:s}),mg({mediaRef:s,src:p,mediaType:"video",playbackRate:e.playbackRate??1,preservePitch:d,onlyWarnForMediaSeekingError:h,acceptableTimeshift:v??null,isPremounting:!!(oe!=null&&oe.premounting),isPostmounting:!!(oe!=null&&oe.postmounting),pauseWhenBuffering:M,onAutoPlayError:R??null}),pg({id:le,isPostmounting:!!(oe!=null&&oe.postmounting),isPremounting:!!(oe!=null&&oe.premounting),mediaRef:s,mediaType:"video",onAutoPlayError:R??null}),og({logLevel:we,mediaRef:s,volume:Ae,source:o,shouldUseWebAudioApi:se??!1});const Ze=oe?oe.relativeFrom:0,Ye=oe?Math.min(oe.durationInFrames,W):W,at=fi(p),ut=B2({actualSrc:at,actualFrom:Ze,duration:Ye,fps:D});i.useImperativeHandle(n,()=>s.current,[]),i.useState(()=>os({logLevel:we,message:`Mounting video with source = ${ut}, v=${yl}, user agent=${typeof navigator>"u"?"server":navigator.userAgent}`,tag:"video",mountTime:Re})),i.useEffect(()=>{const{current:J}=s;if(!J)return;const Ie=()=>{var ht;if(J.error){if(console.error("Error occurred in video",J==null?void 0:J.error),F){const Et=new Ti({message:`Code ${J.error.code}: ${J.error.message}`,src:p});F(Et);return}throw new Ti({message:`The browser threw an error while playing the video ${p}: Code ${J.error.code} - ${(ht=J==null?void 0:J.error)==null?void 0:ht.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`,src:p})}else{if(F){const Et=new Ti({message:`The browser threw an error while playing the video ${p}`,src:p});F(Et);return}throw new Ti({message:"The browser threw an error while playing the video",src:p})}};return J.addEventListener("error",Ie,{once:!0}),()=>{J.removeEventListener("error",Ie)}},[F,p]);const Xe=i.useRef(b);Xe.current=b,kg({ref:s,onVideoFrame:A}),i.useEffect(()=>{var ht;const{current:J}=s;if(!J)return;if(J.duration){(ht=Xe.current)==null||ht.call(Xe,p,J.duration);return}const Ie=()=>{var Et;(Et=Xe.current)==null||Et.call(Xe,p,J.duration)};return J.addEventListener("loadedmetadata",Ie),()=>{J.removeEventListener("loadedmetadata",Ie)}},[p]),i.useEffect(()=>{const{current:J}=s;J&&(Td()?J.preload="metadata":J.preload="auto")},[]);const nt=i.useMemo(()=>({...m}),[m]),xt=np({crossOrigin:V,requestsVideoFrame:!!A,isClientSideRendering:!1});return t.jsx("video",{...ie,ref:s,muted:c||ce||Ae<=0,playsInline:!0,src:ut,loop:k,style:nt,disableRemotePlayback:!0,crossOrigin:xt,controls:!1})},pp=i.forwardRef(oj),fp=e=>{const{startFrom:n,endAt:r,trimBefore:s,trimAfter:o,name:a,pauseWhenBuffering:l,stack:c,showInTimeline:u,...d}=e,h=Pr();if(h.isClientSideRendering)throw new Error("<OffthreadVideo> is not supported in @remotion/web-renderer. Use <Video> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations");const p=i.useCallback(()=>{},[]);if(typeof e.src!="string")throw new TypeError(`The \`<OffthreadVideo>\` tag requires a string for \`src\`, but got ${JSON.stringify(e.src)} instead.`);Fd({startFrom:n,endAt:r,trimBefore:s,trimAfter:o});const{trimBeforeValue:b,trimAfterValue:y}=Rd({startFrom:n,endAt:r,trimBefore:s,trimAfter:o});if(typeof b<"u"||typeof y<"u")return t.jsx(Ir,{layout:"none",from:0-(b??0),showInTimeline:!1,durationInFrames:y,name:a,children:t.jsx(fp,{pauseWhenBuffering:l??!1,...d,trimAfter:void 0,name:void 0,showInTimeline:u,trimBefore:void 0,stack:void 0,startFrom:void 0,endAt:void 0})});if(Id(e,"Video"),h.isRendering)return t.jsx(sj,{pauseWhenBuffering:l??!1,...d,trimAfter:void 0,name:void 0,showInTimeline:u,trimBefore:void 0,stack:void 0,startFrom:void 0,endAt:void 0});const{transparent:v,toneMapped:w,onAutoPlayError:C,onVideoFrame:k,crossOrigin:E,delayRenderRetries:m,delayRenderTimeoutInMilliseconds:M,...I}=d;return t.jsx(pp,{_remotionInternalStack:c??null,onDuration:p,onlyWarnForMediaSeekingError:!0,pauseWhenBuffering:l??!1,showInTimeline:u??!0,onAutoPlayError:C??void 0,onVideoFrame:k??null,crossOrigin:E,...I,_remotionInternalNativeLoopPassed:!1}
51)},Sg=({src:e,acceptableTimeShiftInSeconds:n,allowAmplificationDuringRender:r,audioStreamIndex:s,crossOrigin:o,delayRenderRetries:a,delayRenderTimeoutInMilliseconds:l,loopVolumeCurveBehavior:c,muted:u,name:d,onAutoPlayError:h,onError:p,onVideoFrame:b,pauseWhenBuffering:y,playbackRate:v,preservePitch:w,showInTimeline:C,style:k,toneFrequency:E,toneMapped:m,transparent:M,trimAfter:I,trimBefore:N,useWebAudioApi:F,volume:R,_remotionInternalNativeLoopPassed:A,endAt:V,stack:z,startFrom:H,imageFormat:ne,...se})=>{if(ne)throw new TypeError("The `<OffthreadVideo>` tag does no longer accept `imageFormat`. Use the `transparent` prop if you want to render a transparent video.");return t.jsx(fp,{acceptableTimeShiftInSeconds:n,allowAmplificationDuringRender:r??!0,audioStreamIndex:s??0,crossOrigin:o,delayRenderRetries:a,delayRenderTimeoutInMilliseconds:l,loopVolumeCurveBehavior:c??"repeat",muted:u??!1,name:d,onAutoPlayError:h??null,onError:p,onVideoFrame:b,pauseWhenBuffering:y??!0,playbackRate:v??1,preservePitch:w,toneFrequency:E??1,showInTimeline:C??!0,src:e,stack:z,startFrom:H,_remotionInternalNativeLoopPassed:A??!1,endAt:V,style:k,toneMapped:m??!0,transparent:M??!1,trimAfter:I,trimBefore:N,useWebAudioApi:F??!1,volume:R,...se})};_s(Sg);var aj="remotion_staticFilesChanged";function ij(){const e=qe.useContext(Ki),n=qe.useContext(Gi),r=qe.useContext(Yi),s=qe.useContext(Rr),o=qe.useContext(Hl),a=qe.useContext(ui),l=qe.useContext(Md),c=qe.useContext(xd),u=qe.useContext(pi),d=qe.useContext(qi),h=qe.useContext(vd),p=qe.useContext(jd),b=qe.useContext(Zi),y=qe.useContext(mi);return i.useMemo(()=>({compositionManagerCtx:e,timelineContext:n,setTimelineContext:r,sequenceContext:s,nonceContext:o,canUseRemotionHooksContext:a,preloadContext:l,resolveCompositionContext:c,renderAssetManagerContext:u,sequenceManagerContext:d,sequenceManagerRefContext:h,visualModePropStatusesRefContext:p,bufferManagerContext:b,logLevelContext:y}),[e,o,s,r,n,a,l,c,u,d,h,p,b,y])}var lj=e=>{const{children:n,contexts:r}=e;return t.jsx(mi.Provider,{value:r.logLevelContext,children:t.jsx(ui.Provider,{value:r.canUseRemotionHooksContext,children:t.jsx(Hl.Provider,{value:r.nonceContext,children:t.jsx(Md.Provider,{value:r.preloadContext,children:t.jsx(Ki.Provider,{value:r.compositionManagerCtx,children:t.jsx(vd.Provider,{value:r.sequenceManagerRefContext,children:t.jsx(qi.Provider,{value:r.sequenceManagerContext,children:t.jsx(jd.Provider,{value:r.visualModePropStatusesRefContext,children:t.jsx(pi.Provider,{value:r.renderAssetManagerContext,children:t.jsx(xd.Provider,{value:r.resolveCompositionContext,children:t.jsx(Gi.Provider,{value:r.timelineContext,children:t.jsx(Yi.Provider,{value:r.setTimelineContext,children:t.jsx(Rr.Provider,{value:r.sequenceContext,children:t.jsx(Zi.Provider,{value:r.bufferManagerContext,children:n})})})})})})})})})})})})})})},cj=i.createRef(),Pe={MaxMediaCacheSizeContext:V5,useUnsafeVideoConfig:yd,useFrameForVolumeProp:Ji,useTimelinePosition:Ua,useAbsoluteTimelinePosition:bx,evaluateVolume:hi,getAbsoluteSrc:Xo,getAssetDisplayName:ag,Timeline:om,validateMediaTrimProps:Fd,validateMediaProps:Id,resolveTrimProps:Rd,VideoForPreview:pp,CompositionManager:Ki,CompositionSetters:Bl,VisualModePropStatusesContext:wd,VisualModePropStatusesRefContext:jd,VisualModeDragOverridesContext:Nd,VisualModeSettersContext:Cx,SequenceManager:qi,SequenceManagerRefContext:vd,SequenceStackTracesUpdateContext:X5,wrapInSchema:Zo,sequenceSchema:Vl,SequenceWithoutSchema:Hx,sequenceStyleSchema:kx,sequenceVisualStyleSchema:za,sequencePremountSchema:Nx,flattenActiveSchema:Qm,getFlatSchemaWithAllKeys:ep,RemotionRootContexts:Y5,CompositionManagerProvider:A5,useVideo:bd,getRoot:z5,useMediaVolumeState:ip,useMediaMutedState:lp,useMediaInTimeline:sp,useLazyComponent:cx,truthy:Wi,SequenceContext:Rr,PremountContext:jx,useRemotionContexts:ij,RemotionContextProvider:lj,CSSUtils:wg,setupEnvVariables:Z5,MediaVolumeContext:op,SetMediaVolumeContext:ap,getRemotionEnvironment:xo,SharedAudioContext:Xi,SharedAudioContextProvider:ng,SharedAudioTagsContext:Pd,SharedAudioTagsContextProvider:rg,invalidCompositionErrorMessage:G1,invalidFolderNameErrorMessage:b1,calculateMediaDuration:Ed,isCompositionIdValid:ux,isFolderNameValid:ex,getPreviewDomElement:O5,compositionsRef:vg,portalNode:nm,waitForRoot:B5,SetTimelineContext:Yi,CanUseRemotionHooksProvider:Zu,CanUseRemotionHooks:ui,PrefetchProvi
51der:Qx,DurationsContextProvider:tg,IsPlayerContextProvider:j1,useIsPlayer:Um,EditorPropsProvider:sx,EditorPropsContext:zm,usePreload:fi,NonceContext:Hl,resolveVideoConfig:Ng,resolveVideoConfigOrCatch:q5,ResolveCompositionContext:xd,useResolvedVideoConfig:Bm,resolveCompositionsRef:P1,REMOTION_STUDIO_CONTAINER_ELEMENT:jg,RenderAssetManager:pi,persistCurrentFrame:px,usePlaybackRate:Gm,useTimelineContext:Va,useTimelineSetFrame:yx,isIosSafari:Td,WATCH_REMOTION_STATIC_FILES:aj,addSequenceStackTraces:_s,useMediaStartsAt:ai,BufferingProvider:lg,BufferingContextReact:Zi,getComponentsToAddStacksTo:Z1,CurrentScaleContext:Q5,PixelDensityContext:nj,PreviewSizeContext:ej,calculateScale:tj,validateRenderAsset:Jx,Log:Dr,LogLevelContext:mi,useLogLevel:Jo,playbackLogging:os,timeValueRef:R1,compositionSelectorRef:cj,RemotionEnvironmentContext:ox,warnAboutTooHighVolume:Qi,AudioForPreview:fg,OBJECTFIT_CONTAIN_CLASS_NAME:Ul,InnerOffthreadVideo:fp,useBasicMediaInTimeline:ig,getInputPropsOverride:rx,setInputPropsOverride:M1,useVideoEnabled:H5,useAudioEnabled:K5,useIsPlayerBuffering:cg,TimelinePosition:om,DelayRenderContextType:lx,TimelineContext:Gi,PlaybackRateContext:Km,AbsoluteTimeContext:Wm,RenderAssetManagerProvider:C2,getEffectiveVisualModeValue:Dx,CompositionRenderErrorContext:Z0,useEffectChainState:Jl,createEffectChainState:Gx,cleanupEffectChainState:am,runEffectChain:Xl,useMemoizedEffects:ql,useMemoizedEffectDefinitions:Gl,createEffect:L5,createWebGLContextError:u2,createWebGL2ContextError:Yx,computeEffectiveSchemaValuesDotNotation:zx,interpolateKeyframedStatus:Yl,makeStaticDragOverride:Zw,makeKeyframedDragOverride:Qw,resolveDragOverrideValue:Sd,getStaticDragOverrideValue:e2,OverrideIdsToNodePathsGettersContext:Zm,OverrideIdsToNodePathsSettersContext:qw,findPropsToDelete:Vx,makeSequencePropsSubscriptionKey:ha,getPropStatusesCtx:Ox,getEffectPropStatusesCtx:Lx,hiddenField:ya,durationInFramesField:va,freezeField:wa,fromField:Ba},Cg=e=>qe.Children.toArray(e).reduce((r,s)=>s.type===qe.Fragment?r.concat(Cg(s.props.children)):(r.push(s),r),[]),dj=({children:e},n)=>(lw(),t.jsx(iw,{children:e})),Eg=i.forwardRef(dj),uj=Hx,mj=e=>{const n=i.useMemo(()=>{let r=0;const s=Cg(e.children);return i.Children.map(s,(o,a)=>{const l=o;if(typeof l=="string"){if(l.trim()==="")return null;throw new TypeError(`The <Series /> component only accepts a list of <Series.Sequence /> components as its children, but you passed a string "${l}"`)}if(l.type!==Eg)throw new TypeError(`The <Series /> component only accepts a list of <Series.Sequence /> components as its children, but got ${l} instead`);const c=`index = ${a}, duration = ${l.props.durationInFrames}`,u=l.props.durationInFrames,{durationInFrames:d,children:h,from:p,name:b,...y}=l.props;(a!==s.length-1||u!==1/0)&&fd(u,{component:"of a <Series.Sequence /> component",allowFloats:!0});const v=l.props.offset??0;if(Number.isNaN(v))throw new TypeError(`The "offset" property of a <Series.Sequence /> must not be NaN, but got NaN (${c}).`);if(!Number.isFinite(v))throw new TypeError(`The "offset" property of a <Series.Sequence /> must be finite, but got ${v} (${c}).`);if(v%1!==0)throw new TypeError(`The "offset" property of a <Series.Sequence /> must be finite, but got ${v} (${c}).`);const w=r+v;return r+=u+v,t.jsx(uj,{ref:l.ref,name:b||"<Series.Sequence>",_remotionInternalDocumentationLink:b?void 0:"https://www.remotion.dev/docs/series",from:w,durationInFrames:u,...y,children:o})})},[e.children]);return t.jsx(aw,{children:t.jsx(Ir,{layout:"none",name:"<Series>",_remotionInternalDocumentationLink:"https://www.remotion.dev/docs/series",...e,children:n})})},pj=Object.assign(Zo({Component:mj,componentIdentity:"dev.remotion.remotion.Series",schema:sw,supportsEffects:!1}),{Sequence:Eg});_s(pj);var Zf=e=>Math.round(e*1e5)/1e5,mu=({element:e,desiredTime:n,logLevel:r,mountTime:s})=>{if(od(e.currentTime,n))return{wait:Promise.resolve(n),cancel:()=>{}};Vc({logLevel:r,mediaRef:e,time:n,why:"Seeking during rendering",mountTime:s});let o,a=null;const l=new Promise(u=>{o=e.requestVideoFrameCallback((d,h)=>{const p=h.expectedDisplayTime-d;if(p<=0){u(h.mediaTime);return}setTimeout(()=>{u(h.mediaTime)},p+150)})}),c=new Promise(u=>{const d=()=>{u()};e.addEventListener("seeked",d,{once:!0}),a=()=>{e.removeEventListener("seeked",d)}});return{wait:Promise.all([l,c]).then(([u])=>u),cancel:()=>{a==null||a(),e.cancelVideoFrameCallback(o)}}},fj=({element:e,desiredTime:n,fps:r,logLevel:s,mountTime:o})=>{const a=1/r/2;let l=()=>{};return Number.isFinite(e.duration)&&e.currentTime>=e.duration&&n>=e.duration?{prom:Promise.resolve(),cancel:()=>{}}:{prom:new Promise((u,d)=>{const h=mu({element:e,desiredTime:n+a,logLevel:s,mountTime:o});h.wait.then(p=>{if(Math.abs(n-p)<=a)return u();const y=n>p?1:-1,v=mu({element:e,desiredTime:p+a*y,logLevel:s,mountTime:o});l=v.cancel,v.wait.then(w=>{const C=Math.abs(n-w);if(Zf(C)<=Zf(a))return u();const k=mu({element:e,desiredTime:n+a,logLevel:s,mountTime:o});return l=k.cancel,k.wait.then(()=>{u()}).catch(E=>{d(E)})}).catch(w=>{d(w)})}),l=h.cancel}),cancel:()=>{l()}}},hj=({onError:e,volume:n,allowAmplificationDuringRender:r,playbackRate:s,onDuration:o,toneFrequency:a,name:l,acceptableTimeShiftInSeconds:c,delayRenderRetries:u,delayRenderTimeoutInMilliseconds:d,loopVolumeCurveBehavior:h,audioStreamIndex:p,onVideoFrame:b,preservePitch:y,...v},w)=>
51{const C=Ua(),k=xs(),E=Ji(h??"repeat"),m=yd(),M=i.useRef(null),I=i.useContext(Rr),N=ai(),F=Pr(),R=Jo(),A=Wl(),{delayRender:V,continueRender:z}=$o(),{registerRenderAsset:H,unregisterRenderAsset:ne}=i.useContext(pi),se=i.useMemo(()=>`video-${Oa(v.src??"")}-${I==null?void 0:I.cumulatedFrom}-${I==null?void 0:I.relativeFrom}-${I==null?void 0:I.durationInFrames}`,[v.src,I==null?void 0:I.cumulatedFrom,I==null?void 0:I.relativeFrom,I==null?void 0:I.durationInFrames]);if(!m)throw new Error("No video config found");const pe=hi({volume:n,frame:E,mediaVolume:1});Qi(pe),i.useEffect(()=>{if(!v.src)throw new Error("No src passed");if(!v.muted&&!(pe<=0)&&window.remotion_audioEnabled)return H({type:"video",src:Xo(v.src),id:se,frame:C,volume:pe,mediaFrame:k,playbackRate:s??1,toneFrequency:a??1,audioStartFrame:Math.max(0,-((I==null?void 0:I.cumulatedNegativeFrom)??0)),audioStreamIndex:p??0}),()=>ne(se)},[v.muted,v.src,H,se,ne,pe,k,C,s,a,I==null?void 0:I.cumulatedNegativeFrom,p]),i.useImperativeHandle(w,()=>M.current,[]),kg({ref:M,onVideoFrame:b}),i.useEffect(()=>{var le,Ne;if(!window.remotion_videoEnabled)return;const{current:O}=M;if(!O)return;const D=ug({frame:k,playbackRate:s||1,startFrom:-N,fps:m.fps}),W=V(`Rendering <Html5Video /> with src="${v.src}" at time ${D}`,{retries:u??void 0,timeoutInMilliseconds:d??void 0});if(((Ne=(le=window.process)==null?void 0:le.env)==null?void 0:Ne.NODE_ENV)==="test"){z(W);return}if(od(O.currentTime,D)){if(O.readyState>=2){z(W);return}const ce=()=>{z(W)};return O.addEventListener("loadeddata",ce,{once:!0}),()=>{O.removeEventListener("loadeddata",ce)}}const oe=()=>{z(W)},we=fj({element:O,desiredTime:D,fps:m.fps,logLevel:R,mountTime:A});we.prom.then(()=>{z(W)}),O.addEventListener("ended",oe,{once:!0});const Re=()=>{var ce;if(O!=null&&O.error){if(console.error("Error occurred in video",O==null?void 0:O.error),e)return;throw new Ti({message:`The browser threw an error while playing the video ${v.src}: Code ${O.error.code} - ${(ce=O==null?void 0:O.error)==null?void 0:ce.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`,src:v.src})}else throw new Ti({message:"The browser threw an error",src:v.src})};return O.addEventListener("error",Re,{once:!0}),()=>{we.cancel(),O.removeEventListener("ended",oe),O.removeEventListener("error",Re),z(W)}},[E,v.src,s,m.fps,k,N,e,u,d,R,A,z,V]);const{src:ie}=v;return F.isRendering&&i.useLayoutEffect(()=>{var oe,we;if(((we=(oe=window.process)==null?void 0:oe.env)==null?void 0:we.NODE_ENV)==="test")return;const O=V("Loading <Html5Video> duration with src="+ie,{retries:u??void 0,timeoutInMilliseconds:d??void 0}),{current:D}=M,W=()=>{D!=null&&D.duration&&o(ie,D.duration),z(O)};return D!=null&&D.duration?(o(ie,D.duration),z(O)):D==null||D.addEventListener("loadedmetadata",W,{once:!0}),()=>{D==null||D.removeEventListener("loadedmetadata",W),z(O)}},[ie,o,u,d,z,V]),t.jsx("video",{ref:M,disableRemotePlayback:!0,...v})},xj=i.forwardRef(hj),gj=(e,n)=>{const{startFrom:r,endAt:s,trimBefore:o,trimAfter:a,name:l,pauseWhenBuffering:c,stack:u,_remotionInternalNativeLoopPassed:d,showInTimeline:h,onAutoPlayError:p,onVideoFrame:b,...y}=e,{loop:v,...w}=e,{fps:C}=as(),k=Pr();if(k.isClientSideRendering)throw new Error("<Html5Video> is not supported in @remotion/web-renderer. Use <Video> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations");const{durations:E,setDurations:m}=i.useContext(tp);if(typeof n=="string")throw new Error("string refs are not supported");if(typeof e.src!="string")throw new TypeError(`The \`<Html5Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(e.src)} instead.`);const M=fi(e.src),I=i.useCallback((A,V)=>{m({type:"got-duration",durationInSeconds:V,src:A})},[m]),N=E[Xo(M)]??E[Xo(e.src)];Fd({startFrom:r,endAt:s,trimBefore:o,trimAfter:a});const{trimBeforeValue:F,trimAfterValue:R}=Rd({startFrom:r,endAt:s,trimBefore:o,trimAfter:a});if(v&&N!==void 0){if(!Number.isFinite(N))return t.jsx(Cl,{...w,ref:n,stack:u,_remotionInternalNativeLoopPassed:!0});const A=N*C;return t.jsx(Zl,{durationInFrames:Ed({trimAfter:R,mediaDurationInFrames:A,playbackRate:e.playbackRate??1,trimBefore:F}),layout:"none",name:l,showInTimeline:!1,children:t.jsx(Cl,{...w,ref:n,stack:u,_remotionInternalNativeLoopPassed:!0})})}return typeof F<"u"||typeof R<"u"?t.jsx(Ir,{layout:"none",from:0-(F??0),showInTimeline:!1,durationInFrames:R===void 0?void 0:R/(e.playbackRate??1),name:l,children:t.jsx(Cl,{pauseWhenBuffering:c??!1,onVideoFrame:b,...y,ref:n,stack:u})}):(Id({playbackRate:e.playbackRate,preservePitch:e.preservePitch,volume:e.volume},"Html5Video"),k.isRendering?t.jsx(xj,{onDuration:I,onVideoFrame:b??null,...y,ref:n}):t.jsx(pp,{onlyWarnForMediaSeekingError:!1,...y,ref:n,onVideoFrame:b??null,pauseWhenBuffering:c??!1,onDuration:I,_remotionInternalStack:u??null,_remotionInternalNativeLoopPassed:d??!1,showInTimeline:h??!0,onAutoPlayError:p??void 0}))},Cl=i.forwardRef(gj);_s(Cl);var bj=Cl;Q1();var yj={},vj=new Proxy(yj,{get(e,n){return n==="Bundling"||n==="Rendering"||n==="Log"||n==="Puppeteer"||n==="Output"?vj:()=>{console.warn("â ï¸ The CLI configuration has been extracted from Remotion Core."),console.warn("Update the import from the config file:"),console.warn(),console.warn("- Delete:"),console.warn('import {Config} from "remotion";'),console.warn("+ Replace:"),console.warn('import {Config} from "@remotion/cli/config";'),console.warn(),console.warn("For more information, see https://www.remotion.dev/docs/4-0-migration."),process.exit(1)}}});Ir.displayName="Sequence";_s(Ir);_s(sm);_s(y1);typeof window<"u"&&(window.remotion_renderReady=!1,window.remotion_delayRenderTimeouts||(window.remotion_delayRenderTimeouts={}),window.remotion_delayRenderHandles=[]);var wj={"style.transformOrigin":{type:"transform-origin",step:1,default:"50% 50%",description:"Transform origin"},"style.translate":{type:"translate",step:1,default:"0px 0px",description:"Offset"}
51,"style.scale":{type:"scale",max:100,step:.01,default:1,description:"Scale"},"style.rotate":{type:"rotation-css",step:1,default:"0deg",description:"Rotation"},"style.opacity":{type:"number",min:0,max:1,step:.01,default:1,description:"Opacity",hiddenFromList:!1}},jj={premountFor:{type:"number",default:0,description:"Premount For",min:0,step:1,hiddenFromList:!1},postmountFor:{type:"number",default:0,min:0,step:1,hiddenFromList:!0},styleWhilePremounted:{type:"hidden"},styleWhilePostmounted:{type:"hidden"}},Nj={...wj,...jj},Mg={type:"boolean",default:!1,description:"Hidden"},Ig={type:"hidden"},kj={type:"hidden"},Fg=e=>({name:kj,...e}),Rg={type:"number",default:void 0,min:1,step:1,hiddenFromList:!0},Sj={type:"number",default:0,step:1,hiddenFromList:!0},Pg={type:"number",default:null,step:1,hiddenFromList:!0},dm=Fg({hidden:Mg,showInTimeline:Ig,from:Sj,freeze:Pg,durationInFrames:Rg,layout:{type:"enum",default:"absolute-fill",description:"Layout",variants:{"absolute-fill":Nj,none:{}}}});Fg({hidden:Mg,showInTimeline:Ig,freeze:Pg,durationInFrames:Rg,layout:dm.layout});({...dm,layout:{...dm.layout}});var Cj=(e,n,r)=>{if(e){if(typeof e!="object")throw new Error(`"${n}" must be an object, but you passed a value of type ${typeof e}`);if(Array.isArray(e))throw new Error(`"${n}" must be an object, an array was passed ${r?`for composition "${r}"`:""}`)}};function Ej(e,n,r){if(typeof e!="number")throw new Error(`The "${n}" prop ${r} must be a number, but you passed a value of type ${typeof e}`);if(isNaN(e))throw new TypeError(`The "${n}" prop ${r} must not be NaN, but is NaN.`);if(!Number.isFinite(e))throw new TypeError(`The "${n}" prop ${r} must be finite, but is ${e}.`);if(e%1!==0)throw new TypeError(`The "${n}" prop ${r} must be an integer, but is ${e}.`);if(e<=0)throw new TypeError(`The "${n}" prop ${r} must be positive, but got ${e}.`)}function Mj(e,n){const{allowFloats:r,component:s}=n;if(typeof e>"u")throw new Error(`The "durationInFrames" prop ${s} is missing.`);if(typeof e!="number")throw new Error(`The "durationInFrames" prop ${s} must be a number, but you passed a value of type ${typeof e}`);if(e<=0)throw new TypeError(`The "durationInFrames" prop ${s} must be positive, but got ${e}.`);if(!r&&e%1!==0)throw new TypeError(`The "durationInFrames" prop ${s} must be an integer, but got ${e}.`);if(!Number.isFinite(e))throw new TypeError(`The "durationInFrames" prop ${s} must be finite, but got ${e}.`)}function Ij(e,n,r){if(typeof e!="number")throw new Error(`"fps" must be a number, but you passed a value of type ${typeof e} ${n}`);if(!Number.isFinite(e))throw new Error(`"fps" must be a finite, but you passed ${e} ${n}`);if(isNaN(e))throw new Error(`"fps" must not be NaN, but got ${e} ${n}`);if(e<=0)throw new TypeError(`"fps" must be positive, but got ${e} ${n}`);if(r&&e>50)throw new TypeError("The FPS for a GIF cannot be higher than 50. Use the --every-nth-frame option to lower the FPS: https://remotion.dev/docs/render-as-gif")}var $d={validateFps:Ij,validateDimension:Ej,validateDurationInFrames:Mj,validateDefaultAndInputProps:Cj};if(typeof i.createContext!="function"){const e=['Remotion requires React.createContext, but it is "undefined".','If you are in a React Server Component, turn it into a client component by adding "use client" at the top of the file.',"","Before:",' import {Player} from "@remotion/player";',"","After:",' "use client";',' import {Player} from "@remotion/player";'];throw new Error(e.join(` 52`))}var Gr=25,um=16,Fj=()=>t.jsx("svg",{width:Gr,height:Gr,viewBox:"0 0 25 25",fill:"none",children:t.jsx("path",{d:"M8 6.375C7.40904 8.17576 7.06921 10.2486 7.01438 12.3871C6.95955 14.5255 7.19163 16.6547 7.6875 18.5625C9.95364 18.2995 12.116 17.6164 14.009 16.5655C15.902 15.5147 17.4755 14.124 18.6088 12.5C17.5158 10.8949 15.9949 9.51103 14.1585 8.45082C12.3222 7.3906 10.2174 6.68116 8 6.375Z",fill:"white",stroke:"white",strokeWidth:"6.25",strokeLinejoin:"round"})}),Rj=()=>t.jsxs("svg",{viewBox:"0 0 100 100",width:Gr,height:Gr,children:[t.jsx("rect",{x:"25",y:"20",width:"20",height:"60",fill:"#fff",ry:"5",rx:"5"}),t.jsx("rect",{x:"55",y:"20",width:"20",height:"60",fill:"#fff",ry:"5",rx:"5"})]}),Pj=({isFullscreen:e})=>{const s=e?0:3,o=e?6*1.6:6/2,a=e?6*1.6:6*2;return t.jsxs("svg",{viewBox:"0 0 32 32",height:um,width:um,children:[t.jsx("path",{d:` 53 M ${s} ${a} 54 L ${o} ${o} 55 L ${a} ${s} 56 `,stroke:"#fff",strokeWidth:6,fill:"none"}),t.jsx("path",{d:`
57 M ${32-s} ${a} 58 L ${32-o} ${o} 59 L ${32-a} ${s} 60 `,stroke:"#fff",strokeWidth:6,fill:"none"}),t.jsx("path",{d:` 61 M ${s} ${32-a} 62 L ${o} ${32-o} 63 L ${a} ${32-s} 64 `,stroke:"#fff",strokeWidth:6,fill:"none"}),t.jsx("path",{d:` 65 M ${32-s} ${32-a} 66 L ${32-o} ${32-o} 67 L ${32-a} ${32-s} 68 `,stroke:"#fff",strokeWidth:6,fill:"none"})]})},Tj=()=>t.jsx("svg",{width:Gr,height:Gr,viewBox:"0 0 24 24",children:t.jsx("path",{d:"M3.63 3.63a.996.996 0 000 1.41L7.29 8.7 7 9H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71v-4.17l4.18 4.18c-.49.37-1.02.68-1.6.91-.36.15-.58.53-.58.92 0 .72.73 1.18 1.39.91.8-.33 1.55-.77 2.22-1.31l1.34 1.34a.996.996 0 101.41-1.41L5.05 3.63c-.39-.39-1.02-.39-1.42 0zM19 12c0 .82-.15 1.61-.41 2.34l1.53 1.53c.56-1.17.88-2.48.88-3.87 0-3.83-2.4-7.11-5.78-8.4-.59-.23-1.22.23-1.22.86v.19c0 .38.25.71.61.85C17.18 6.54 19 9.06 19 12zm-8.71-6.29l-.17.17L12 7.76V6.41c0-.89-1.08-1.33-1.71-.7zM16.5 12A4.5 4.5 0 0014 7.97v1.79l2.48 2.48c.01-.08.02-.16.02-.24z",fill:"#fff"})}),Aj=()=>t.jsx("svg",{width:Gr,height:Gr,viewBox:"0 0 24 24",children:t.jsx("path",{d:"M3 10v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71V6.41c0-.89-1.08-1.34-1.71-.71L7 9H4c-.55 0-1 .45-1 1zm13.5 2A4.5 4.5 0 0014 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 4.45v.2c0 .38.25.71.6.85C17.18 6.53 19 9.06 19 12s-1.82 5.47-4.4 6.5c-.36.14-.6.47-.6.85v.2c0 .63.63 1.07 1.21.85C18.6 19.11 21 15.84 21 12s-2.4-7.11-5.79-8.4c-.58-.23-1.21.22-1.21.85z",fill:"#fff"})}),Qf="__remotion_buffering_indicator",eh="__remotion_buffering_animation",$j={width:Gr,height:Gr,overflow:"hidden",lineHeight:"normal",fontSize:"inherit"},_j={width:14,height:14,overflow:"hidden",lineHeight:"normal",fontSize:"inherit"},Dj=({type:e})=>{const n=e==="player"?$j:_j;return t.jsxs(t.Fragment,{children:[t.jsx("style",{type:"text/css",children:` 69 @keyframes ${eh} { 70 0% { 71 rotate: 0deg; 72 } 73 100% { 74 rotate: 360deg; 75 } 76 } 77 78 .${Qf} { 79 animation: ${eh} 1s linear infinite; 80 } 81 `}),t.jsx("div",{style:n,children:t.jsx("svg",{viewBox:e==="player"?"0 0 22 22":"0 0 18 18",style:n,className:Qf,children:t.jsx("path",{d:e==="player"?"M 11 4 A 7 7 0 0 1 15.1145 16.66312":"M 9 2 A 7 7 0 0 1 13.1145 14.66312",stroke:"white",strokeLinecap:"round",fill:"none",strokeWidth:3})})})]})},Lj=({currentSize:e,width:n,height:r,compositionWidth:s,compositionHeight:o})=>n!==void 0&&r===void 0?{aspectRatio:[s,o].join("/")}:r!==void 0&&n===void 0?{aspectRatio:[s,o].join("/")}:e?{width:s,height:o}:{width:s,height:o},Tg=({previewSize:e,compositionWidth:n,compositionHeight:r,canvasSize:s})=>{const o=Pe.calculateScale({canvasSize:s,compositionHeight:r,compositionWidth:n,previewSize:e}),a=0-(1-o)/2,l=a*n,c=a*r,u=n*o,d=r*o,h=s.width/2-u/2,p=s.height/2-d/2;return{centerX:h,centerY:p,xCorrection:l,yCorrection:c,scale:o}},Ag=({config:e,style:n,canvasSize:r,overflowVisible:s,layout:o})=>e?{position:"relative",overflow:s?"visible":"hidden",...Lj({compositionHeight:e.height,compositionWidth:e.width,currentSize:r,height:n==null?void 0:n.height,width:n==null?void 0:n.width}),opacity:o?1:0,...n}:{},$g=({config:e,layout:n,scale:r,overflowVisible:s})=>e?n?{position:"absolute",width:e.width,height:e.height,display:"flex",transform:`scale(${r})`,marginLeft:n.xCorrection,marginTop:n.yCorrection,overflow:s?"visible":"hidden"}:{position:"absolute",width:e.width,height:e.height,display:"flex",transform:`scale(${r})`,overflow:s?"visible":"hidden"}:{},_g=({layout:e,scale:n,config:r,overflowVisible:s})=>{if(!r)return{};if(!e)return{width:r.width*n,height:r.height*n,display:"flex",flexDirection:"column",position:"absolute",overflow:s?"visible":"hidden"};const{centerX:o,centerY:a}=e;return{width:r.width*n,height:r.height*n,display:"flex",flexDirection:"column",position:"absolute",left:o,top:a,overflow:s?"visible":"hidden"}},Dg=qe.createContext(void 0),Lg=qe.createContext(void 0);class Oj{constructor(){fn(this,"listeners",{ended:[],error:[],pause:[],play:[],ratechange:[],scalechange:[],seeked:[],timeupdate:[],frameupdate:[],fullscreenchange:[],volumechange:[],mutechange:[],waiting:[],resume:[]});fn(this,"dispatchSeek",n=>{this.dispatchEvent("seeked",{frame:n})});fn(this,"dispatchVolumeChange",n=>{this.dispatchEvent("volumechange",{volume:n})});fn(this,"dispatchPause",()=>{this.dispatchEvent("pause",void 0)});fn(this,"dispatchPlay",()=>{this.dispatchEvent("play",void 0)});fn(this,"dispatchEnded",()=>{this.dispatchEvent("ended",void 0)});fn(this,"dispatchRateChange",n=>{this.dispatchEvent("ratechange",{playbackRate:n})});fn(this,"dispatchScaleChange",n=>{this.dispatchEvent("scalechange",{scale:n})});fn(this,"dispatchError",n=>{this.dispatchEvent("error",{error:n})});fn(this,"dispatchTimeUpdate",n=>{this.dispatchEvent("timeupdate",n)});fn(this,"dispatchFrameUpdate",n=>{this.dispatchEvent("frameupdate",n)});fn(this,"dispatchFullscreenChange",n=>{this.dispatchEvent("fullscreenchange",n)});fn(this,"dispatchMuteChange",n=>{this.dispatchEvent("mutechange",n)});fn(this,"dispatchWaiting",n=>{this.dispatchEvent("waiting",n)});fn(this,"dispatchResume",n=>{this.dispatchEvent("resume",n)})}addEventListener(n,r){this.listeners[n].push(r)}removeEventListener(n,r){this.listeners[n]=this.listeners[n].filter(s=>s!==r)}
81dispatchEvent(n,r){this.listeners[n].forEach(s=>{s({detail:r})})}}class Vj{constructor(){fn(this,"listeners",{error:[],waiting:[],resume:[]});fn(this,"dispatchError",n=>{this.dispatchEvent("error",{error:n})});fn(this,"dispatchWaiting",n=>{this.dispatchEvent("waiting",n)});fn(this,"dispatchResume",n=>{this.dispatchEvent("resume",n)})}addEventListener(n,r){this.listeners[n].push(r)}removeEventListener(n,r){this.listeners[n]=this.listeners[n].filter(s=>s!==r)}dispatchEvent(n,r){this.listeners[n].forEach(s=>{s({detail:r})})}}var Og=e=>{const n=i.useContext(Pe.BufferingContextReact);if(!n)throw new Error("BufferingContextReact not found");i.useLayoutEffect(()=>{const r=n.listenForBuffering(()=>{n.buffering.current=!0,e.dispatchWaiting({})}),s=n.listenForResume(()=>{n.buffering.current=!1,e.dispatchResume({})});return()=>{r.remove(),s.remove()}},[n,e])},Uj=({children:e,currentPlaybackRate:n})=>{const[r]=i.useState(()=>new Oj);if(!i.useContext(Pe.BufferingContextReact))throw new Error("BufferingContextReact not found");return i.useEffect(()=>{n&&r.dispatchRateChange(n)},[r,n]),Og(r),t.jsx(Dg.Provider,{value:r,children:e})},hp=(e,n)=>{const[r,s]=i.useState(!1);return i.useEffect(()=>{const{current:o}=e;if(!o)return;let a;const l=()=>{n&&(clearTimeout(a),a=setTimeout(()=>{s(!1)},n===!0?3e3:n))},c=()=>{s(!0),l()},u=()=>{s(!1),clearTimeout(a)},d=()=>{s(!0),l()};return o.addEventListener("mouseenter",c),o.addEventListener("mouseleave",u),o.addEventListener("mousemove",d),()=>{o.removeEventListener("mouseenter",c),o.removeEventListener("mouseleave",u),o.removeEventListener("mousemove",d),clearTimeout(a)}},[n,e]),r},_d=()=>{const[e,n,r]=Pe.Timeline.usePlayingState(),[s,o]=i.useState(!1),a=Pe.Timeline.useTimelinePosition(),l=i.useRef(a),c=Pe.Timeline.useTimelineSetFrame(),u=Pe.Timeline.useTimelineSetFrame(),d=i.useContext(Pe.SharedAudioContext),h=i.useContext(Pe.SharedAudioTagsContext),{audioAndVideoTags:p}=Pe.useTimelineContext(),b=i.useRef(a);b.current=a;const y=Pe.useVideo(),v=Pe.useUnsafeVideoConfig(),w=i.useContext(Dg),C=((v==null?void 0:v.durationInFrames)??1)-1,k=a===C,E=a===0;if(!w)throw new TypeError("Expected Player event emitter context");const m=i.useContext(Pe.BufferingContextReact);if(!m)throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");const{buffering:M}=m,I=i.useCallback(O=>{const D=v?Pe.TimelinePosition.clampFrameToCompositionRange(O,v.durationInFrames):Math.max(0,O);y!=null&&y.id&&u(W=>({...W,[y.id]:D})),b.current=D,w.dispatchSeek(D)},[v,w,u,y==null?void 0:y.id]),N=i.useCallback(O=>{r.current||(o(!0),k&&I(0),d==null||d.resume(),h&&h.numberOfAudioTags>0&&O&&h.playAllAudios(),p.current.forEach(D=>D.play("player play() was called and playing audio from a click")),r.current=!0,n(!0),l.current=b.current,w.dispatchPlay())},[r,k,d,h,n,w,I,p]),F=i.useCallback(()=>{r.current&&(r.current=!1,n(!1),w.dispatchPause(),d==null||d.suspend())},[w,r,n,d]),R=i.useCallback(()=>{r.current&&(r.current=!1,b.current=l.current,v&&(u(O=>({...O,[v.id]:l.current})),n(!1),w.dispatchPause()))},[v,w,r,n,u]),A=y==null?void 0:y.id,V=i.useCallback(O=>{if(!A)return null;r.current||c(D=>{const W=D[A]??window.remotion_initialFrame??0,oe=Math.max(0,W-O);return W===oe?D:{...D,[A]:oe}})},[r,c,A]),z=i.useCallback(O=>{if(!A)return null;r.current||c(D=>{const W=D[A]??window.remotion_initialFrame??0,oe=Math.min(C,W+O);return W===oe?D:{...D,[A]:oe}})},[A,r,C,c]),H=i.useCallback(O=>{r.current?F():N(O)},[r,F,N]),ne=i.useCallback(()=>r.current,[r]),se=i.useCallback(()=>b.current,[b]),pe=i.useCallback(()=>M.current,[M]);return i.useMemo(()=>({frameBack:V,frameForward:z,isLastFrame:k,emitter:w,playing:e,play:N,pause:F,seek:I,isFirstFrame:E,getCurrentFrame:se,isPlaying:ne,isBuffering:pe,pauseAndReturnToPlayStart:R,hasPlayed:s,toggle:H}),[w,V,z,s,E,k,se,F,R,N,e,I,H,ne,pe])},zj=({browserMediaControlsBehavior:e,videoConfig:n,playbackRate:r})=>{const{playing:s,pause:o,play:a,emitter:l,getCurrentFrame:c,seek:u}=_d(),d=i.useRef(!1);i.useEffect(()=>{s&&(d.current=!0)},[s]),i.useEffect(()=>{navigator.mediaSession&&e.mode!=="do-nothing"&&(s?navigator.mediaSession.playbackState="playing":d.current&&(navigator.mediaSession.playbackState="paused"))},[e.mode,s]),i.useEffect(()=>{if(!navigator.mediaSession||e.mode==="do-nothing")return;const h=()=>{n&&navigator.mediaSession&&navigator.mediaSession.setPositionState({duration:n.durationInFrames/n.fps,playbackRate:r,position:c()/n.fps}
81)};return l.addEventListener("timeupdate",h),()=>{l.removeEventListener("timeupdate",h)}},[e.mode,l,c,r,n]),i.useEffect(()=>{if(navigator.mediaSession&&e.mode!=="do-nothing")return navigator.mediaSession.setActionHandler("play",()=>{e.mode==="register-media-session"&&a()}),navigator.mediaSession.setActionHandler("pause",()=>{e.mode==="register-media-session"&&o()}),navigator.mediaSession.setActionHandler("seekto",h=>{e.mode==="register-media-session"&&h.seekTime!==void 0&&n&&u(Math.round(h.seekTime*n.fps))}),navigator.mediaSession.setActionHandler("seekbackward",()=>{e.mode==="register-media-session"&&n&&u(Math.max(0,Math.round((c()-10)*n.fps)))}),navigator.mediaSession.setActionHandler("seekforward",()=>{e.mode==="register-media-session"&&n&&u(Math.max(n.durationInFrames-1,Math.round((c()+10)*n.fps)))}),navigator.mediaSession.setActionHandler("previoustrack",()=>{e.mode==="register-media-session"&&u(0)}),()=>{navigator.mediaSession.metadata=null,navigator.mediaSession.setActionHandler("play",null),navigator.mediaSession.setActionHandler("pause",null),navigator.mediaSession.setActionHandler("seekto",null),navigator.mediaSession.setActionHandler("seekbackward",null),navigator.mediaSession.setActionHandler("seekforward",null),navigator.mediaSession.setActionHandler("previoustrack",null)}},[e.mode,c,o,a,u,n])},Bj=({time:e,currentFrame:n,playbackSpeed:r,fps:s,actualLastFrame:o,actualFirstFrame:a,framesAdvanced:l,shouldLoop:c})=>{const d=(r<0?Math.ceil:Math.floor)(e*r/(1e3/s))-l,h=d+n,p=n>o||n<a,b=h>o||h<a,y=!c&&b&&!p;return r>0?b?{nextFrame:a,framesToAdvance:d,hasEnded:y}:{nextFrame:h,framesToAdvance:d,hasEnded:y}:b?{nextFrame:o,framesToAdvance:d,hasEnded:y}:{nextFrame:h,framesToAdvance:d,hasEnded:y}},th=()=>typeof document>"u"?!1:document.visibilityState==="hidden",Hj=()=>{const e=i.useRef(th());return i.useEffect(()=>{const n=()=>{e.current=th()};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n)}},[]),e},Kj=.1,nh=({audioContext:e,audioSyncAnchor:n,absoluteTimeInSeconds:r,globalPlaybackRate:s,logLevel:o,force:a})=>{const l=e.currentTime-r/s,c=l-n.value,{outputLatency:u}=e,d=u===0?.3:u,h=e.baseLatency+d;return Math.abs(c)<Kj+h&&!a||Math.abs(c)<Number.EPSILON?!1:(Pe.Log.verbose({logLevel:o,tag:"audio-scheduling"},"Anchor "+(a?"forcibly ":"")+"changed from %s to %s with shift %s",n.value,l,c),n.value=l,!0)},Wj=e=>{if(e==="suspended"||e==="running-to-suspended")return!0;if(e==="closed"||e==="interrupted"||e==="running"||e==="suspended-to-running")return!1;throw new Error(`Unexpected audio context state: ${e}`)},Yj=({loop:e,playbackRate:n,moveToBeginningWhenEnded:r,inFrame:s,outFrame:o,browserMediaControlsBehavior:a,getCurrentFrame:l,muted:c})=>{const u=Pe.useUnsafeVideoConfig(),d=Pe.Timeline.useTimelinePosition(),{playing:h,pause:p,emitter:b,isPlaying:y}=_d(),v=Pe.Timeline.useTimelineSetFrame(),w=i.useContext(Pe.SharedAudioContext),C=Pe.useLogLevel(),k=Hj(),E=i.useRef(0),m=i.useContext(Pe.BufferingContextReact);if(!m)throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");zj({browserMediaControlsBehavior:a,playbackRate:n,videoConfig:u}),i.useLayoutEffect(()=>{if(!w||!w.audioContext||!u||c)return;nh({audioContext:w.audioContext,audioSyncAnchor:w.audioSyncAnchor,absoluteTimeInSeconds:d/u.fps,globalPlaybackRate:n,logLevel:C,force:!1})&&w.audioSyncAnchorEmitter.dispatch("changed")},[u,d,C,n,w,c]),i.useLayoutEffect(()=>{const M=w==null?void 0:w.audioContext;if(!M||!u||c)return;const I=()=>{const N=w==null?void 0:w.getAudioContextState();N&&Wj(N)&&nh({audioContext:M,audioSyncAnchor:w.audioSyncAnchor,absoluteTimeInSeconds:l()/u.fps,globalPlaybackRate:n,logLevel:C,force:!0})};return M==null||M.addEventListener("statechange",I),()=>{M==null||M.removeEventListener("statechange",I)}},[u,l,C,c,n,w]),i.useEffect(()=>{var ne;if(!u)return;if(!h){(ne=w==null?void 0:w.suspend)==null||ne.call(w);return}let M=!1,I=null,N=performance.now(),F=0;const R=()=>{I!==null&&(I.type==="raf"?cancelAnimationFrame(I.id):clearTimeout(I.id))},A=()=>{M=!0,R()},V=()=>{var we,Re;if(M)return;if(!y()){(we=w==null?void 0:w.suspend)==null||we.call(w);return}!c&&!m.buffering.current&&((Re=w==null?void 0:w.resume)==null||Re.call(w));const se=performance.now()-N,pe=o??u.durationInFrames-1,ie=s??0,O=l(),{nextFrame:D,framesToAdvance:W,hasEnded:oe}=Bj({time:se,currentFrame:O,playbackSpeed:n,fps:u.fps,actualFirstFrame:ie,actualLastFrame:pe,framesAdvanced:F,shouldLoop:e});if(F+=W,D!==l()&&(!oe||r)&&!m.buffering.current&&v(le=>({...le,[u.id]:D})),oe){A(),p(),b.dispatchEnded();return}z()},z=()=>{var pe,ie;const se=((pe=w==null?void 0:w.getIsResumingAudioContext)==null?void 0:pe.call(w))??null;if(se!==null&&!c){se.then(()=>{N=performance.now(),F=0,z()});return}if(m.buffering.current){c||(ie=w==null?void 0:w.suspend)==null||ie.call(w);const O=m.listenForResume(()=>{O.remove(),N=performance.now(),F=0,z()});return}if(k.current){I={type:"timeout",id:setTimeout(V,1e3/u.fps)};return}I={type:"raf",id:requestAnimationFrame(V)}};z();const H=()=>{document.visibilityState!=="visible"&&(R(),V())};return window.addEventListener("visibilitychange",H),()=>{window.removeEventListener("visibilitychange",H),A()}},[u,e,p,h,v,b,n,s,o,r,k,l,m,y,w,C,c]),i.useEffect(()=>{const M=performance.now(),I=M-E.current;if(I>=250){b.dispatchTimeUpdate({frame:d}),E.current=M;return}const N=setTimeout(()=>{b.dispatchTimeUpdate({frame:d}),E.current=performance.now()},250-I);return()=>clearTimeout(N)},[b,d]),i.useEffect(()=>{b.dispatchFrameUpdate({frame:d})},[b,d])},pu=[],fu=e=>e?"current"in e?e.current:e:null,xp=(e,n)=>{const[r,s]=i.useState(()=>{const l=fu(e);if(!l)return null;const c=l.getClientRects();return c[0]?{width:c[0].width,height:c[0].height,left:c[0].x,top:c[0].y,windowSize:{height:window.innerHeight,width:window.innerWidth}}:null}),o=i.useMemo(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(l=>{const{contentRect:c,target:u}=l[0],d=u.getClientRects();if(!(d!=null&&d[0])){s(null);return}const h=c.width===0?1:d[0].width/c.width,p=c.height===0?1:d[0].height/c.height,b=n.shouldApplyCssTransforms||h===0?d[0].width:d[0].width*(1/h),y=n.shouldApplyCssTransforms||p===0?d[0].height:d[0].height*(1/p);s(v=>v&&v.width===b&&v.height===y&&v.left===d[0].x&&v.top===d[0].y&&v.windowSize.height===window.innerHeight&&v.windowSize.width===window.innerWidth?v:{width:b,height:y,left:d[0].x,top:d[0].y,windowSize:{height:window.innerHeight,width:window.innerWidth}})}),[n.shouldApplyCssTransforms]),a=i.useCallback(()=>{const l=fu(e);if(!l)return;const c=l.getClientRects();if(!c[0]){s(null);return}s(u=>u&&u.width===c[0].width&&u.height===c[0].height&&u.left===c[0].x&&u.top===c[0].y&&u.windowSize.height===window.innerHeight&&u.windowSize.width===window.innerWidth?u:{width:c[0].width,height:c[0].height,left:c[0].x,top:c[0].y,windowSize:{height:window.innerHeight,width:window.innerWidth}})},[e]);return i.useEffect(()=>{a()},[a]),i.useEffect(()=>{if(!o)return;const l=fu(e);return l&&o.observe(l),()=>{l&&o.unobserve(l)}},[o,e]),i.useEffect(()=>{if(n.triggerOnWindowResize)return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[n.triggerOnWindowResize,a]),i.useEffect(()=>(pu.push(a),()=>{pu=pu.filter(l=>l!==a)}),[a]),i.useMemo(()=>r?{...r,refresh:a}:null,[r,a])},gp=e=>e??"__remotion-player",Gj={display:"flex",justifyContent:"center",alignItems:"center",flex:1,height:"100%",width:"100%"};class Vg extends qe.Component{constructor(){super(...arguments);fn(this,"state",{hasError:null})}static getDerivedStateFromError(r){return{hasError:r}}componentDidCatch(r){this.props.onError(r)}render(){return this.state.hasError?t.jsx("div",{style:Gj,children:this.props.errorFallback({error:this.state.hasError})}):this.props.children}}var qj=async()=>
81{if(typeof window>"u"||typeof window.crypto>"u"||typeof window.crypto.subtle>"u")return null;try{const e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(window.location.hostname));return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}catch{return null}},hu={backgroundColor:"red",position:"absolute",padding:12,fontFamily:"Arial"},Xj=["28d262b44cc61fa750f1686b16ad0604dabfe193fbc263eec05c89b7ad4c2cd6","4db1b0a94be33165dfefcb3ba03d04c7a2666dd27c496d3dc9fa41858e94925e","fbc48530bbf245da790f63675e84e06bab38c3b114fab07eb350025119922bdc","7baf10a8932757b1b3a22b3fce10a048747ac2f8eaf638603487e3705b07eb83","8a6c21a598d8c667272b5207c051b85997bf5b45d5fb712378be3f27cd72c6a6","a2f7aaac9c50a9255e7fc376110c4e0bfe153722dc66ed3c5d3bf2a135f65518"],rh=!1,Jj=()=>{const[e,n]=qe.useState(!1);return i.useEffect(()=>{rh||(rh=!0,qj().then(r=>{r&&Xj.includes(r)&&n(!0)}).catch(()=>{}))},[]),i.useEffect(()=>{if(!e)return;const r=()=>{if(!document.querySelector(".warning-banner")){const a=document.createElement("div");a.className="warning-banner",Object.assign(a.style,hu,{zIndex:"9999",cssText:`${hu.cssText} !important;`}),a.innerHTML=` 82 <a href="https://github.com/remotion-dev/remotion/pull/4589" style="color: white;"> 83 Remotion Unlicensed â Contact [email protected] 84 </a> 85 `,document.body.appendChild(a)}},s=new MutationObserver(()=>r());return s.observe(document.body,{childList:!0,subtree:!0}),()=>{s.disconnect()}},[e]),e?t.jsx("div",{style:hu,className:"warning-banner",children:t.jsx("a",{style:{color:"white"},href:"https://github.com/remotion-dev/remotion/pull/4589",children:"Remotion Unlicensed â Contact [email protected]"})}):null},sh=({playing:e,buffering:n})=>e&&n?t.jsx(Dj,{type:"player"}):e?t.jsx(Rj,{}):t.jsx(Fj,{}),ki=12,oh=5,Zj=({volume:e,isVertical:n,onBlur:r,inputRef:s,setVolume:o})=>{const a=i.useMemo(()=>{const b={paddingLeft:5,height:Gr,width:ri,display:"inline-flex",alignItems:"center"};return n?{...b,position:"absolute",transform:`rotate(-90deg) translateX(${ri/2+Gr/2}px)`}:{...b}},[n]),l=typeof qe.useId>"u"?"volume-slider":qe.useId(),[c]=i.useState(()=>`__remotion-volume-slider-${Oa(l)}`.replace(".","")),u=i.useCallback(p=>{o(parseFloat(p.target.value))},[o]),d=i.useMemo(()=>{const p={WebkitAppearance:"none",backgroundColor:"rgba(255, 255, 255, 0.5)",borderRadius:oh/2,cursor:"pointer",height:oh,width:ri,backgroundImage:`linear-gradient( 86 to right, 87 white ${e*100}%, rgba(255, 255, 255, 0) ${e*100}% 88 )`};return n?{...p,bottom:Gr+ri/2}:p},[n,e]),h=` 89 .${c}::-webkit-slider-thumb { 90 -webkit-appearance: none; 91 background-color: white; 92 border-radius: ${ki/2}px; 93 box-shadow: 0 0 2px black; 94 height: ${ki}px; 95 width: ${ki}px; 96 } 97 98 .${c}::-moz-range-thumb { 99 -webkit-appearance: none; 100 background-color: white; 101 border-radius: ${ki/2}px; 102 box-shadow: 0 0 2px black; 103 height: ${ki}px; 104 width: ${ki}px; 105 } 106`;return t.jsxs("div",{style:a,children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:h}}),t.jsx("input",{ref:s,"aria-label":"Change volume",className:c,max:1,min:0,onBlur:r,onChange:u,step:.01,type:"range",value:e,style:d})]})},Qj=e=>t.jsx(Zj,{...e}),ri=100,eN=({displayVerticalVolumeSlider:e,renderMuteButton:n,renderVolumeSlider:r})=>{const[s,o]=Pe.useMediaMutedState(),[a,l]=Pe.useMediaVolumeState(),[c,u]=i.useState(!1),d=i.useRef(null),h=i.useRef(null),p=hp(d,!1),b=i.useCallback(()=>{setTimeout(()=>{h.current&&document.activeElement!==h.current&&u(!1)},10)},[]),y=a===0,v=i.useCallback(()=>{if(y){l(1),o(!1);return}o(M=>!M)},[y,o,l]),w=i.useMemo(()=>({display:"inline-flex",background:"none",border:"none",justifyContent:"center",alignItems:"center",touchAction:"none",...e&&{position:"relative"}}),[e]),C=i.useMemo(()=>({display:"inline",width:Gr,height:Gr,cursor:"pointer",appearance:"none",background:"none",border:"none",padding:0}),[]),k=i.useCallback(({muted:M,volume:I})=>{const N=M||I===0;return t.jsx("button",{"aria-label":N?"Unmute sound":"Mute sound",title:N?"Unmute sound":"Mute sound",onClick:v,onBlur:b,onFocus:()=>u(!0),style:C,type:"button",children:N?t.jsx(Tj,{}):t.jsx(Aj,{})})},[b,v,C]),E=i.useMemo(()=>n?n({muted:s,volume:a}):k({muted:s,volume:a}),[s,a,k,n]),m=i.useMemo(()=>(c||p)&&!s&&!Pe.isIosSafari()?(r??Qj)({isVertical:e,volume:a,onBlur:()=>u(!1),inputRef:h,setVolume:l}):null,[e,c,p,s,a,r,l]);return t.jsxs("div",{ref:d,style:w,children:[E,m]})};function tN(e){const[n,r]=i.useState(e),s=i.useRef(null);return i.useEffect(()=>{const o=a=>{s.current&&!s.current.contains(a.target)&&r(!1)};return document.addEventListener("pointerup",o,!0),()=>{document.removeEventListener("pointerup",o,!0)}},[]),{ref:s,isComponentVisible:n,setIsComponentVisible:r}}var nN=35,rN=70,sN={height:30,paddingRight:15,paddingLeft:12,display:"flex",flexDirection:"row",alignItems:"center"},oN={width:22,display:"flex",alignItems:"center"},aN={width:14,height:14,color:"black"},iN=()=>t.jsx("svg",{viewBox:"0 0 512 512",style:aN,children:t.jsx("path",{fill:"currentColor",d:"M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"})}),lN=e=>{const n=e.toString();return n.includes(".")?n:n+".0"},cN=({rate:e,onSelect:n,selectedRate:r,keyboardSelectedRate:s})=>{const o=i.useCallback(p=>{p.stopPropagation(),p.preventDefault(),n(e)},[n,e]),[a,l]=i.useState(!1),c=i.useCallback(()=>
106{l(!0)},[]),u=i.useCallback(()=>{l(!1)},[]),d=s===e,h=i.useMemo(()=>({...sN,backgroundColor:a||d?"#eee":"transparent"}),[a,d]);return t.jsxs("div",{onPointerEnter:c,onPointerLeave:u,tabIndex:0,style:h,onClick:o,children:[t.jsx("div",{style:oN,children:e===r?t.jsx(iN,{}):null}),lN(e),"x"]},e)},dN=({setIsComponentVisible:e,playbackRates:n,canvasSize:r})=>{const{setPlaybackRate:s,playbackRate:o}=Pe.usePlaybackRate(),[a,l]=i.useState(o);i.useEffect(()=>{const d=h=>{if(h.preventDefault(),h.key==="ArrowUp"){const p=n.findIndex(b=>b===a);if(p===0)return;l(p===-1?n[0]:n[p-1])}else if(h.key==="ArrowDown"){const p=n.findIndex(b=>b===a);if(p===n.length-1)return;l(p===-1?n[n.length-1]:n[p+1])}else h.key==="Enter"&&(s(a),e(!1))};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[n,a,s,e]);const c=i.useCallback(d=>{s(d),e(!1)},[e,s]),u=i.useMemo(()=>({position:"absolute",right:0,width:125,maxHeight:r.height-rN-nN,bottom:35,background:"#fff",borderRadius:4,overflow:"auto",color:"black",textAlign:"left"}),[r.height]);return t.jsx("div",{style:u,children:n.map(d=>t.jsx(cN,{selectedRate:o,onSelect:c,rate:d,keyboardSelectedRate:a},d))})},uN={fontSize:13,fontWeight:"bold",color:"white",border:"2px solid white",borderRadius:20,paddingLeft:8,paddingRight:8,paddingTop:2,paddingBottom:2},mm={appearance:"none",backgroundColor:"transparent",border:"none",cursor:"pointer",paddingLeft:0,paddingRight:0,paddingTop:6,paddingBottom:6,height:37,display:"inline-flex",marginBottom:0,marginTop:0,alignItems:"center"},mN={...mm,position:"relative"},pN=({playbackRates:e,canvasSize:n})=>{const{ref:r,isComponentVisible:s,setIsComponentVisible:o}=tN(!1),{playbackRate:a}=Pe.usePlaybackRate(),l=i.useCallback(c=>{c.stopPropagation(),c.preventDefault(),o(u=>!u)},[o]);return t.jsx("div",{ref:r,children:t.jsxs("button",{type:"button","aria-label":"Change playback rate",style:mN,onClick:l,children:[t.jsxs("div",{style:uN,children:[a,"x"]}),s&&t.jsx(dN,{canvasSize:n,playbackRates:e,setIsComponentVisible:o})]})})},ah=(e,n,r)=>Math.round(Gn(e,[0,r],[0,n-1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}
106)),Ai=5,al=12,pm=4,fN={userSelect:"none",WebkitUserSelect:"none",paddingTop:pm,paddingBottom:pm,boxSizing:"border-box",cursor:"pointer",position:"relative",touchAction:"none"},hN={height:Ai,backgroundColor:"rgba(255, 255, 255, 0.25)",width:"100%",borderRadius:Ai/2},xN=e=>{let n=e;for(;n.parentElement;)n=n.parentElement;return n},gN=({durationInFrames:e,onSeekEnd:n,onSeekStart:r,inFrame:s,outFrame:o})=>{const a=i.useRef(null),l=hp(a,!1),c=xp(a,{triggerOnWindowResize:!0,shouldApplyCssTransforms:!0}),{seek:u,play:d,pause:h,playing:p}=_d(),b=Pe.Timeline.useTimelinePosition(),[y,v]=i.useState({dragging:!1}),w=(c==null?void 0:c.width)??0,C=i.useCallback(N=>{var A;if(N.button!==0)return;const F=(A=a.current)==null?void 0:A.getBoundingClientRect().left,R=ah(N.clientX-F,e,w);h(),u(R),v({dragging:!0,wasPlaying:p}),r()},[e,w,h,u,p,r]),k=i.useCallback(N=>{var A;if(!c)throw new Error("Player has no size");if(!y.dragging)return;const F=(A=a.current)==null?void 0:A.getBoundingClientRect().left,R=ah(N.clientX-F,e,c.width);u(R)},[y.dragging,e,u,c]),E=i.useCallback(()=>{v({dragging:!1}),y.dragging&&(y.wasPlaying?d():h(),n())},[y,n,h,d]);i.useEffect(()=>{if(!y.dragging)return;const N=xN(a.current);return N.addEventListener("pointermove",k),N.addEventListener("pointerup",E),()=>{N.removeEventListener("pointermove",k),N.removeEventListener("pointerup",E)}},[y.dragging,k,E]);const m=i.useMemo(()=>({height:al,width:al,borderRadius:al/2,position:"absolute",top:pm-al/2+5/2,backgroundColor:"white",left:Math.max(0,b/Math.max(1,e-1)*w-al/2),boxShadow:"0 0 2px black",opacity:Number(l||y.dragging)}),[l,y.dragging,e,b,w]),M=i.useMemo(()=>({height:Ai,backgroundColor:"rgba(255, 255, 255, 1)",width:(b-(s??0))/(e-1)*w,marginLeft:(s??0)/(e-1)*w,borderRadius:Ai/2}),[e,b,s,w]),I=i.useMemo(()=>({height:Ai,backgroundColor:"rgba(255, 255, 255, 0.25)",width:((o??e-1)-(s??0))/(e-1)*100+"%",marginLeft:(s??0)/(e-1)*100+"%",borderRadius:Ai/2,position:"absolute"}),[e,s,o]);return t.jsxs("div",{ref:a,onPointerDown:C,style:fN,children:[t.jsxs("div",{style:hN,children:[t.jsx("div",{style:I}),t.jsx("div",{style:M})]}),t.jsx("div",{style:m})]})},ih=e=>{const n=Math.floor(e/60),r=Math.floor(e-n*60);return`${String(n)}:${String(r).padStart(2,"0")}`},bN=({durationInFrames:e,maxTimeLabelWidth:n,fps:r})=>{const s=Pe.Timeline.useTimelinePosition(),o=i.useMemo(()=>({color:"white",fontFamily:"sans-serif",fontSize:14,maxWidth:n===null?void 0:n,overflow:"hidden",textOverflow:"ellipsis"}),[n]),l=s===e-1?s+1:s;return t.jsxs("div",{style:o,children:[ih(l/r)," / ",ih(e/r)]})},yN=10,fm=12,vN=({allowFullscreen:e,playerWidth:n})=>i.useMemo(()=>{const s=Gr,o=Gr,a=e?um:0,l=o+s+a+fm*2+yN*2,c=n-l,u=Math.max(c,0),d=u-ri,p=(d<ri?u:d)+l+ri,b=n<p;return{maxTimeLabelWidth:u===0?null:u,displayVerticalVolumeSlider:b}},[e,n]),wN=[0,.013,.049,.104,.175,.259,.352,.45,.55,.648,.741,.825,.896,.951,.987],jN=[0,8.1,15.5,22.5,29,35.3,41.2,47.1,52.9,58.8,64.7,71,77.5,84.5,91.9],NN=1/.7,kN={boxSizing:"border-box",position:"absolute",bottom:0,width:"100%",paddingTop:40,paddingBottom:10,backgroundImage:`linear-gradient(to bottom,${wN.map((e,n)=>`hsla(0, 0%, 0%, ${e}) ${jN[n]*NN}%`).join(", ")}, hsl(0, 0%, 0%) 100%)`,backgroundSize:"auto 145px",display:"flex",paddingRight:fm,paddingLeft:fm,flexDirection:"column",transition:"opacity 0.3s"},SN={display:"flex",flexDirection:"row",width:"100%",alignItems:"center",justifyContent:"center",userSelect:"none",WebkitUserSelect:"none"},CN={display:"flex",flexDirection:"row",userSelect:"none",WebkitUserSelect:"none",alignItems:"center"},il={width:12},EN={height:8},MN={flex:1},IN={},FN=({durationInFrames:e,isFullscreen:n,fps:r,showVolumeControls:s,onFullscreenButtonClick:o,allowFullscreen:a,onExitFullscreenButtonClick:l,spaceKeyToPlayOrPause:c,onSeekEnd:u,onSeekStart:d,inFrame:h,outFrame:p,initiallyShowControls:b,canvasSize:y,renderPlayPauseButton:v,renderFullscreenButton:w,alwaysShowControls:C,showPlaybackRateControl:k,containerRef:E,buffering:m,hideControlsWhenPointerDoesntMove:M,onPointerDown:I,onDoubleClick:N,renderMuteButton:F,renderVolumeSlider:R,playing:A,toggle:V,renderCustomControls:z})=>
106{const H=i.useRef(null),[ne,se]=i.useState(!1),pe=hp(E,M),{maxTimeLabelWidth:ie,displayVerticalVolumeSlider:O}=vN({allowFullscreen:a,playerWidth:(y==null?void 0:y.width)??0}),[D,W]=i.useState(()=>{if(typeof b=="boolean")return b;if(typeof b=="number"){if(b%1!==0)throw new Error("initiallyShowControls must be an integer or a boolean");if(Number.isNaN(b))throw new Error("initiallyShowControls must not be NaN");if(!Number.isFinite(b))throw new Error("initiallyShowControls must be finite");if(b<=0)throw new Error("initiallyShowControls must be a positive integer");return b}throw new TypeError("initiallyShowControls must be a number or a boolean")}),oe=i.useMemo(()=>({...kN,opacity:Number(pe||!A||D||C)}),[pe,D,A,C]);i.useEffect(()=>{H.current&&c&&H.current.focus({preventScroll:!0})},[A,c]),i.useEffect(()=>{se((typeof document<"u"&&(document.fullscreenEnabled||document.webkitFullscreenEnabled))??!1)},[]),i.useEffect(()=>{if(D===!1)return;const Ze=setTimeout(()=>{W(!1)},D===!0?2e3:D);return()=>{clearInterval(Ze)}},[D]);const we=i.useMemo(()=>{if(k===!0)return[.5,.8,1,1.2,1.5,1.8,2,2.5,3];if(Array.isArray(k)){for(const De of k){if(typeof De!="number")throw new Error("Every item in showPlaybackRateControl must be a number");if(De<=0)throw new Error("Every item in showPlaybackRateControl must be positive")}return k}return null},[k]),Re=z?z():null,le=i.useRef(null),Ne=i.useRef(null),ce=i.useCallback(De=>{(De.target===le.current||De.target===Ne.current)&&(I==null||I(De))},[I]),Ae=i.useCallback(De=>{(De.target===le.current||De.target===Ne.current)&&(N==null||N(De))},[N]);return t.jsxs("div",{ref:le,style:oe,onPointerDown:ce,onDoubleClick:Ae,children:[t.jsxs("div",{ref:Ne,style:SN,children:[t.jsxs("div",{style:CN,children:[t.jsx("button",{ref:H,type:"button",style:mm,onClick:V,"aria-label":A?"Pause video":"Play video",title:A?"Pause video":"Play video",children:v===null?t.jsx(sh,{buffering:m,playing:A}):v({playing:A,isBuffering:m})??t.jsx(sh,{buffering:m,playing:A})}),s?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:il}),t.jsx(eN,{renderMuteButton:F,renderVolumeSlider:R,displayVerticalVolumeSlider:O})]}):null,t.jsx("div",{style:il}),t.jsx(bN,{durationInFrames:e,fps:r,maxTimeLabelWidth:ie}),t.jsx("div",{style:il})]}),t.jsx("div",{style:MN}),Re,Re&&we&&y?t.jsx("div",{style:il}):null,we&&y&&t.jsx(pN,{canvasSize:y,playbackRates:we}),we&&ne&&a?t.jsx("div",{style:il}):null,t.jsx("div",{style:IN,children:ne&&a?t.jsx("button",{type:"button","aria-label":n?"Exit fullscreen":"Enter Fullscreen",title:n?"Exit fullscreen":"Enter Fullscreen",style:mm,onClick:n?l:o,children:w===null?t.jsx(Pj,{isFullscreen:n}):w({isFullscreen:n})}):null})]}),t.jsx("div",{style:EN}),t.jsx(gN,{onSeekEnd:u,onSeekStart:d,durationInFrames:e,inFrame:h,outFrame:p})]})},Ug=typeof document>"u",RN=e=>{let n=!1;return{promise:new Promise((s,o)=>{e.then(a=>{if(n){o({isCanceled:n,value:a});return}s(a)}).catch(a=>{o({isCanceled:n,error:a})})}),cancel:()=>{n=!0}}},PN=e=>new Promise(n=>setTimeout(n,e)),TN=()=>{const e=i.useRef([]),n=i.useCallback(a=>{e.current=[...e.current,a]},[]),r=i.useCallback(a=>{e.current=e.current.filter(l=>l!==a)},[]),s=i.useCallback(()=>e.current.map(a=>a.cancel()),[]);return i.useMemo(()=>({appendPendingPromise:n,removePendingPromise:r,clearPendingPromises:s}),[n,s,r])},AN=(e,n,r)=>{const s=TN(),o=i.useCallback(async u=>{if(u instanceof PointerEvent?u.pointerType==="touch":u.nativeEvent.pointerType==="touch"){e(u);return}s.clearPendingPromises();const d=RN(PN(200));s.appendPendingPromise(d);try{await d.promise,s.removePendingPromise(d),e(u)}catch(h){const p=h;if(s.removePendingPromise(d),!p.isCanceled)throw p.error}},[s,e]),a=i.useCallback(()=>{document.addEventListener("pointerup",u=>{o(u)},{once:!0})},[o]),l=i.useCallback(()=>{s.clearPendingPromises(),n()},[s,n]);return i.useMemo(()=>r?{handlePointerDown:a,handleDoubleClick:l}:{handlePointerDown:e,handleDoubleClick:()=>{}},[r,l,a,e])},hm=qe.version.split(".")[0];if(hm==="0")throw new Error(`Version ${hm} of "react" is not supported by Remotion`);var $N=parseInt(hm,10)>=18,_N=({controls:e,style:n,loop:r,autoPlay:s,allowFullscreen:o,inputProps:a,clickToPlay:l,showVolumeControls:c,doubleClickToFullscreen:u,spaceKeyToPlayOrPause:d,errorFallback:h,playbackRate:p,renderLoading:b,renderPoster:y,className:v,moveToBeginningWhenEnded:w,showPosterWhenUnplayed:C,showPosterWhenEnded:k,showPosterWhenPaused:E,showPosterWhenBuffering:m,showPosterWhenBufferingAndPaused:M,inFrame:I,outFrame:N,initiallyShowControls:F,renderFullscreen:R,renderPlayPauseButton:A,renderMuteButton:V,renderVolumeSlider:z,renderCustomControls:H,alwaysShowControls:ne,showPlaybackRateControl:se,posterFillMode:pe,bufferStateDelayInMilliseconds:ie,hideControlsWhenPointerDoesntMove:O,overflowVisible:D,browserMediaControl
106sBehavior:W,overrideInternalClassName:oe,noSuspense:we},Re)=>{const le=Pe.useUnsafeVideoConfig(),Ne=Pe.useVideo(),ce=i.useRef(null),Ae=xp(ce,{triggerOnWindowResize:!1,shouldApplyCssTransforms:!1}),[De,Ze]=i.useState(!1),[Ye,at]=i.useState(s),[ut,Xe]=i.useState(()=>!1),[nt,xt]=i.useState(!1),J=i.useMemo(()=>typeof document>"u"?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled),[]),Ie=_d(),ht=Ie.toggle,{mediaMuted:Et,mediaVolume:Ft}=i.useContext(Pe.MediaVolumeContext);i.useEffect(()=>{Ie.emitter.dispatchVolumeChange(Ft)},[Ie.emitter,Ft]);const Rt=Et||Ft===0;i.useEffect(()=>{Ie.emitter.dispatchMuteChange({isMuted:Rt})},[Ie.emitter,Rt]),Yj({loop:r,playbackRate:p,moveToBeginningWhenEnded:w,inFrame:I,outFrame:N,getCurrentFrame:Ie.getCurrentFrame,browserMediaControlsBehavior:W,muted:Rt}),i.useEffect(()=>{De&&!Ie.playing&&(Ze(!1),Ie.play())},[De,Ie]),i.useEffect(()=>{const{current:Ke}=ce;if(!Ke)return;const ot=()=>{const qt=document.fullscreenElement===Ke||document.webkitFullscreenElement===Ke;Xe(qt)};return document.addEventListener("fullscreenchange",ot),document.addEventListener("webkitfullscreenchange",ot),()=>{document.removeEventListener("fullscreenchange",ot),document.removeEventListener("webkitfullscreenchange",ot)}},[]);const Pt=i.useCallback(Ke=>{ht(Ke)},[ht]),Ht=i.useCallback(()=>{if(!o)throw new Error("allowFullscreen is false");if(!J)throw new Error("Browser doesnt support fullscreen");if(!ce.current)throw new Error("No player ref found");ce.current.webkitRequestFullScreen?ce.current.webkitRequestFullScreen():ce.current.requestFullscreen()},[o,J]),Gt=i.useCallback(()=>{document.webkitExitFullscreen?document.webkitExitFullscreen():document.exitFullscreen()},[]);i.useEffect(()=>{const{current:Ke}=ce;if(!Ke)return;const ot=()=>{const qt=document.webkitFullscreenElement??document.fullscreenElement;qt&&qt===ce.current?Ie.emitter.dispatchFullscreenChange({isFullscreen:!0}):Ie.emitter.dispatchFullscreenChange({isFullscreen:!1})};return Ke.addEventListener("webkitfullscreenchange",ot),Ke.addEventListener("fullscreenchange",ot),()=>{Ke.removeEventListener("webkitfullscreenchange",ot),Ke.removeEventListener("fullscreenchange",ot)}},[Ie.emitter]);const Kt=(le==null?void 0:le.durationInFrames)??1,un=i.useMemo(()=>!le||!Ae?null:Tg({canvasSize:Ae,compositionHeight:le.height,compositionWidth:le.width,previewSize:"auto"}),[Ae,le]),jt=(un==null?void 0:un.scale)??1,ln=i.useRef(!1);i.useEffect(()=>{if(!ln.current){ln.current=!0;return}Ie.emitter.dispatchScaleChange(jt)},[Ie.emitter,jt]);const{setMediaVolume:Je,setMediaMuted:Qt}=i.useContext(Pe.SetMediaVolumeContext),[rn,Ot]=i.useState(!1);i.useEffect(()=>{let Ke=null,ot=!1;const qt=()=>{ot=!1,requestAnimationFrame(()=>{ie===0?Ot(!0):Ke=setTimeout(()=>{ot||Ot(!0)},ie)})},sr=()=>{requestAnimationFrame(()=>{ot=!0,Ot(!1),Ke&&clearTimeout(Ke)})};return Ie.emitter.addEventListener("waiting",qt),Ie.emitter.addEventListener("resume",sr),()=>{Ie.emitter.removeEventListener("waiting",qt),Ie.emitter.removeEventListener("resume",sr),Ot(!1),Ke&&clearTimeout(Ke),ot=!0}},[ie,Ie.emitter]),i.useImperativeHandle(Re,()=>{const Ke={play:Ie.play,pause:()=>{Ze(!1),Ie.pause()},toggle:Pt,getContainerNode:()=>ce.current,getCurrentFrame:Ie.getCurrentFrame,isPlaying:Ie.isPlaying,seekTo:ot=>{const qt=Kt-1,sr=Math.max(0,Math.min(qt,ot));Ie.isPlaying()&&(Ze(sr!==qt||r),Ie.pause()),sr===qt&&!r&&Ie.emitter.dispatchEnded(),Ie.seek(sr)},isFullscreen:()=>{const{current:ot}=ce;return ot?document.fullscreenElement===ot||document.webkitFullscreenElement===ot:!1},requestFullscreen:Ht,exitFullscreen:Gt,getVolume:()=>Et?0:Ft,setVolume:ot=>{if(typeof ot!="number")throw new TypeError(`setVolume() takes a number, got value of type ${typeof ot}`);if(isNaN(ot))throw new TypeError("setVolume() got a number that is NaN. Volume must be between 0 and 1.");if(ot<0||ot>1)throw new TypeError(`setVolume() got a number that is out of range. Must be between 0 and 1, got ${ot}`);Je(ot)},isMuted:()=>Rt,mute:()=>{Qt(!0)},unmute:()=>{Qt(!1)},getScale:()=>jt,pauseAndReturnToPlayStart:()=>{Ie.pauseAndReturnToPlayStart()}};return Object.assign(Ie.emitter,Ke)},[Kt,Gt,r,Et,Rt,Ft,Ie,Ht,Qt,Je,Pt,jt]);const Qe=Ne?Ne.component:null,Vt=i.useMemo(()=>Ag({canvasSize:Ae,config:le,style:n,overflowVisible:D,layout:un}),[Ae,le,un,D,n]),En=i.useMemo(()=>_g({config:le,layout:un,scale:jt,overflowVisible:D}),[le,un,D,jt]),An=i.useMemo(()=>$g({config:le,layout:un,scale:jt,overflowVisible:D}),[le,un,D,jt]),Lr=Ie.pause,ur=Ie.emitter.dispatchError,rt=i.useCallback(Ke
106=>{Lr(),ur(Ke)},[ur,Lr]),mt=i.useCallback(Ke=>{Ke.stopPropagation(),Ht()},[Ht]),Ct=i.useCallback(Ke=>{Ke.stopPropagation(),Gt()},[Gt]),mr=i.useCallback(Ke=>{(Ke instanceof MouseEvent?Ke.button===2:Ke.nativeEvent.button)||Pt(Ke)},[Pt]),pr=i.useCallback(()=>{xt(!0)},[]),rr=i.useCallback(()=>{xt(!1)},[]),qn=i.useCallback(()=>{ut?Gt():Ht()},[Gt,ut,Ht]),{handlePointerDown:Z,handleDoubleClick:xe}=AN(mr,qn,u&&o&&J);i.useEffect(()=>{Ye&&(Ie.play(),at(!1))},[Ye,Ie]);const Le=i.useMemo(()=>b?b({height:Vt.height,width:Vt.width,isBuffering:rn}):null,[Vt.height,Vt.width,b,rn]),et=i.useMemo(()=>({type:"scale",scale:jt}),[jt]);if(!le)return null;const ct=y?y({height:pe==="player-size"?Vt.height:le.height,width:pe==="player-size"?Vt.width:le.width,isBuffering:rn}):null;if(ct===void 0)throw new TypeError("renderPoster() must return a React element, but undefined was returned");const pt=ct&&[E&&!Ie.isPlaying()&&!nt,k&&Ie.isLastFrame&&!Ie.isPlaying(),C&&!Ie.hasPlayed&&!Ie.isPlaying(),m&&rn&&Ie.isPlaying(),M&&rn&&!Ie.isPlaying()].some(Boolean),{left:_t,top:$n,width:xn,height:tt,...Xn}=En,mn=t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:En,onPointerDown:l?Z:void 0,onDoubleClick:u?xe:void 0,children:[t.jsxs("div",{style:An,className:gp(oe),children:[Qe?t.jsx(Vg,{onError:rt,errorFallback:h,children:t.jsx(Pe.CurrentScaleContext.Provider,{value:et,children:t.jsx(Qe,{...(Ne==null?void 0:Ne.props)??{},...a??{}})})}):null,pt&&pe==="composition-size"?t.jsx("div",{style:{...Xn,width:le.width,height:le.height},onPointerDown:l?Z:void 0,onDoubleClick:u?xe:void 0,children:ct}):null]}),t.jsx(Jj,{})]}),pt&&pe==="player-size"?t.jsx("div",{style:En,onPointerDown:l?Z:void 0,onDoubleClick:u?xe:void 0,children:ct}):null,e?t.jsx(FN,{fps:le.fps,playing:Ie.playing,toggle:Ie.toggle,durationInFrames:le.durationInFrames,containerRef:ce,onFullscreenButtonClick:mt,isFullscreen:ut,allowFullscreen:o,showVolumeControls:c,onExitFullscreenButtonClick:Ct,spaceKeyToPlayOrPause:d,onSeekEnd:rr,onSeekStart:pr,inFrame:I,outFrame:N,initiallyShowControls:F,canvasSize:Ae,renderFullscreenButton:R,renderPlayPauseButton:A,alwaysShowControls:ne,showPlaybackRateControl:se,buffering:rn,hideControlsWhenPointerDoesntMove:O,onDoubleClick:u?xe:void 0,onPointerDown:l?Z:void 0,renderMuteButton:V,renderVolumeSlider:z,renderCustomControls:H}):null]});return we||Ug&&!$N?t.jsx("div",{ref:ce,style:Vt,className:v,children:mn}):t.jsx("div",{ref:ce,style:Vt,className:v,children:t.jsx(i.Suspense,{fallback:Le,children:mn})})},DN=i.forwardRef(_N),zg="remotion.volumePreference",LN=(e,n,r)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(r??zg,String(e))}catch(s){Pe.Log.error({logLevel:n,tag:null},"Could not persist volume",s)}},ON=e=>{if(typeof window>"u")return 1;try{const n=window.localStorage.getItem(e??zg);return n?Number(n):1}catch{return 1}},bp="player-comp",Bg=({children:e,timelineContext:n,playbackRateContext:r,fps:s,compositionHeight:o,compositionWidth:a,durationInFrames:l,component:c,numberOfSharedAudioTags:u,initiallyMuted:d,logLevel:h,audioLatencyHint:p,sampleRate:b,volumePersistenceKey:y,initialVolume:v,inputProps:w,audioEnabled:C})=>{const k=v===void 0,E=i.useMemo(()=>({compositions:[{component:c,durationInFrames:l,height:o,width:a,fps:s,id:bp,nonce:[[0,777]],folderName:null,parentFolderName:null,schema:null,calculateMetadata:null,stack:null}],folders:[],currentCompositionMetadata:{defaultCodec:null,defaultOutName:null,defaultPixelFormat:null,defaultProResProfile:null,defaultSampleRate:null,defaultVideoImageFormat:null,durationInFrames:l,fps:s,height:o,width:a,props:w},canvasContent:{type:"composition",compositionId:"player-comp"}}),[c,l,o,a,s,w]),[m,M]=i.useState(()=>d),[I,N]=i.useState(()=>k?ON(y??null):v),F=i.useMemo(()=>({mediaMuted:m,mediaVolume:I}),[m,I]),R=i.useCallback(H=>{N(H),k&&LN(H,h,y??null)},[k,h,y]),A=i.useMemo(()=>({setMediaMuted:M,setMediaVolume:R}),[R]),V=i.useMemo(()=>({logLevel:h,mountTime:Date.now()}),[h]),z=i.useMemo(()=>({isPlayer:!0,isRendering:!1,isStudio:!1,isClientSideRendering:!1,isReadOnlyStudio:!1}),[]);return t.jsx(Pe.RemotionEnvironmentContext.Provider,{value:z,children:t.jsx(Pe.LogLevelContext.Provider,{value:V,children:t.jsx(Pe.CanUseRemotionHooksProvider,{children:t.jsx(Pe.AbsoluteTimeContext.Provider,{value:n,children:t.jsx(Pe.PlaybackRateContext.Provider,{value:r,children:t.jsx(Pe.TimelineContext.Provider,{value:n,children:t.jsx(Pe.CompositionManager.Provider,{value:E,children:t.jsx(Pe.PrefetchProvi
106der,{children:t.jsx(Pe.DurationsContextProvider,{children:t.jsx(Pe.MediaVolumeContext.Provider,{value:F,children:t.jsx(Pe.SetMediaVolumeContext.Provider,{value:A,children:t.jsx(Pe.BufferingProvider,{children:t.jsx(Pe.SharedAudioContextProvider,{audioLatencyHint:p,audioEnabled:C,previewSampleRate:b,children:t.jsx(Pe.SharedAudioTagsContextProvider,{numberOfAudioTags:u,children:e})})})})})})})})})})})})})})},lh=!1,VN=(e,n)=>{e||lh||(lh=!0,Pe.Log.warn({logLevel:n,tag:null},"Note: Some companies are required to obtain a license to use Remotion. See: https://remotion.dev/license\nPass the `acknowledgeRemotionLicense` prop to `<Player />` function to make this message disappear."))},ch=(e,n)=>{if(typeof e>"u"||e===null)return e??null;if(typeof e!="number")throw new TypeError(`"${n}" must be a number, but is ${JSON.stringify(e)}`);if(Number.isNaN(e))throw new TypeError(`"${n}" must not be NaN, but is ${JSON.stringify(e)}`);if(!Number.isFinite(e))throw new TypeError(`"${n}" must be finite, but is ${JSON.stringify(e)}`);if(e%1!==0)throw new TypeError(`"${n}" must be an integer, but is ${JSON.stringify(e)}`);return e},UN=({inFrame:e,durationInFrames:n,outFrame:r})=>{const s=ch(e,"inFrame"),o=ch(r,"outFrame");if(!(s===null&&o===null)){if(s!==null&&s>n-1)throw new Error("inFrame must be less than (durationInFrames - 1), but is "+s);if(o!==null&&o>n-1)throw new Error("outFrame must be less than (durationInFrames - 1), but is "+o);if(s!==null&&s<0)throw new Error("inFrame must be greater than 0, but is "+s);if(o!==null&&o<=0)throw new Error(`outFrame must be greater than 0, but is ${o}. If you want to render a single frame, use <Thumbnail /> instead.`);if(o!==null&&s!==null&&o<=s)throw new Error("outFrame must be greater than inFrame, but is "+o+" <= "+s)}},zN=({initialFrame:e,durationInFrames:n})=>{if(typeof n!="number")throw new Error(`\`durationInFrames\` must be a number, but is ${JSON.stringify(n)}`);if(!(typeof e>"u")){if(typeof e!="number")throw new Error(`\`initialFrame\` must be a number, but is ${JSON.stringify(e)}`);if(Number.isNaN(e))throw new Error("`initialFrame` must be a number, but is NaN");if(!Number.isFinite(e))throw new Error("`initialFrame` must be a number, but is Infinity");if(e%1!==0)throw new Error(`\`initialFrame\` must be an integer, but is ${JSON.stringify(e)}`);if(e>n-1)throw new Error(`\`initialFrame\` must be less or equal than \`durationInFrames - 1\`, but is ${JSON.stringify(e)}`)}},BN=e=>{if(e!==void 0){if(e>10)throw new Error(`The highest possible playback rate is 10. You passed: ${e}`);if(e<-10)throw new Error(`The lowest possible playback rate is -10. You passed: ${e}`);if(e===0)throw new Error("A playback rate of 0 is not supported.")}},HN=$d.validateFps,dh=$d.validateDimension,KN=$d.validateDurationInFrames,WN=$d.validateDefaultAndInputProps,YN=e=>"component"in e?e.component:null,GN=({durationInFrames:e,compositionHeight:n,compositionWidth:r,fps:s,inputProps:o,style:a,controls:l=!1,loop:c=!1,autoPlay:u=!1,showVolumeControls:d=!0,allowFullscreen:h=!0,clickToPlay:p,doubleClickToFullscreen:b=!1,spaceKeyToPlayOrPause:y=!0,moveToBeginningWhenEnded:v=!0,numberOfSharedAudioTags:w=5,errorFallback:C=()=>"â ï¸",playbackRate:k=1,renderLoading:E,className:m,showPosterWhenUnplayed:M,showPosterWhenEnded:I,showPosterWhenPaused:N,showPosterWhenBuffering:F,showPosterWhenBufferingAndPaused:R,initialFrame:A,renderPoster:V,inFrame:z,outFrame:H,initiallyShowControls:ne,renderFullscreenButton:se,renderPlayPauseButton:pe,renderVolumeSlider:ie,renderCustomControls:O,alwaysShowControls:D=!1,initiallyMuted:W=!1,showPlaybackRateControl:oe=!1,posterFillMode:we="player-size",bufferStateDelayInMilliseconds:Re,hideControlsWhenPointerDoesntMove:le=!0,overflowVisible:Ne=!1,renderMuteButton:ce,browserMediaControlsBehavior:Ae,overrideInternalClassName:De,logLevel:Ze="info",noSuspense:Ye,acknowledgeRemotionLicense:at,audioLatencyHint:ut="playback",sampleRate:Xe=48e3,volumePersistenceKey:nt,initialVolume:xt,...J},Ie)=>{if(typeof window<"u"&&(window.remotion_isPlayer=!0),J.defaultProps!==void 0)throw new Error("The <Player /> component does not accept `defaultProps`, but some were passed. Use `inputProps` instead.");const ht=YN(J);if((ht==null?void 0:ht.type)===sm)throw new TypeError("'component' should not be an instance of <Composition/>. Pass the React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.");if(ht===sm)throw new TypeError("'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.");i.useState(()=>VN(!!at,Ze));const Et=Pe.useLazyComponent({compProps:J,componentName:"Player",noSuspense:!!Ye});zN({initialFrame:A,durationInFrames:e});const[Ft,Rt]=i.useState(()=>({[bp]:A??0})),[Pt,Ht]=i.useState(!1),[Gt]=i.useState("player-comp"),Kt=i.useRef(null),un=i.useRef([]),jt=i.useRef(!1),[ln,Je]=i.useState(k);if(typeof n!="number")throw new TypeError(`'compositionHeight' must be a number but got '${typeof n}' instead`);if(typeof r!="number")throw new TypeError(`'compositionWidth' must be a number but got '${typeof r}' instead`);if(dh(n,"compositionHeight","of the <Player /> component"),dh(r,"compositionWidth","of the <Player /> component"),KN(e,{component:"of the <Player/> component",allowFloats:!1}),HN(s,"as a prop of the <Player/> component",!1),WN(o,"inputProps",null),UN({durationInFrames:e,inFrame:z,outFrame:H}),typeof l!="boolean"&&typeof l<"u")throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof l}' instead`);if(typeof u!="boolean"&&typeof u<"u")throw new TypeError(`'autoPlay' must be a boolean or undefined but got '${typeof u}' instead`);if(typeof c!="boolean"&&typeof c<"u")throw new TypeError(`'loop' must be a boolean or undefined but got '${typeof c}' instead`);if(typeof b!="boolean"&&typeof b<"u")throw new TypeError(`'doubleClickToFullscreen' must be a boolean or undefined but got '${typeof b}' instead`);if(typeof d!="boolean"&&typeof d<"u")throw new TypeError(`'showVolumeControls' must be a boolean or undefined but got '${typeof d}' instead`);if(typeof h!="boolean"&&typeof h<"u")throw new TypeError(`'allowFullscreen' must be a boolean or undefined but got '${typeof h}' instead`);if(typeof p!="boolean"&&typeof p<"u")throw new TypeError(`'clickToPlay' must be a boolean or undefined but got '${typeof p}' instead`);if(typeof y!="boolean"&&typeof y<"u")throw new TypeError(`'spaceKeyToPlayOrPause' must be a boolean or undefined but got '${typeof y}' instead`);if(typeof Xe!="number"||!Number.isFinite(Xe)||Number.isNaN(Xe)||Xe<=0||Xe%1!==0)throw new TypeError(`'sampleRate' must be a positive integer but got '${Xe}' instead`);if(typeof xt<"u"&&typeof xt!="number")throw new TypeError(`'initialVolume' must be a number or undefined but got '${typeof xt}' instead`);if(typeof xt=="number"&&(!Number.isFinite(xt)||Number.isNaN(xt)||xt<0||xt>1))throw new TypeError(`'initialVolume' must be between 0 and 1 but got '${xt}' instead`);if(typeof w!="number"||w%1!==0||!Number.isFinite(w)||Number.isNaN(w)||w<0)throw new TypeError(`'numberOfSharedAudioTags' must be an integer but got '${w}' instead`);BN(ln),i.useEffect(()=>{Je(k)},[k]),i.useImperativeHandle(Ie,()=>Kt.current,[]),i.useState(()=>{Pe.playbackLogging({logLevel:Ze,message:`[player] Mounting <Player>. User agent = ${typeof navigator>
106"u"?"server":navigator.userAgent}`,tag:"player",mountTime:Date.now()})});const Qt=i.useMemo(()=>({frame:Ft,playing:Pt,rootId:Gt,imperativePlaying:jt,audioAndVideoTags:un}),[Ft,Pt,Gt]),rn=i.useMemo(()=>({playbackRate:ln,setPlaybackRate:Je}),[ln]),Ot=i.useMemo(()=>({setFrame:Rt,setPlaying:Ht}),[Rt]);typeof window<"u"&&i.useLayoutEffect(()=>{Pe.CSSUtils.injectCSS(Pe.CSSUtils.makeDefaultPreviewCSS(`.${gp(De)}`,"#fff"))},[De]);const Qe=i.useMemo(()=>o??{},[o]),Vt=i.useMemo(()=>Ae??{mode:"prevent-media-session"},[Ae]);return t.jsx(Pe.IsPlayerContextProvider,{children:t.jsx(Bg,{timelineContext:Qt,playbackRateContext:rn,component:Et,compositionHeight:n,compositionWidth:r,durationInFrames:e,fps:s,numberOfSharedAudioTags:w,initiallyMuted:W,logLevel:Ze,audioLatencyHint:ut,sampleRate:Xe,volumePersistenceKey:nt,initialVolume:xt,inputProps:Qe,audioEnabled:!0,children:t.jsx(Pe.SetTimelineContext.Provider,{value:Ot,children:t.jsx(Uj,{currentPlaybackRate:ln,children:t.jsx(DN,{ref:Kt,posterFillMode:we,renderLoading:E,autoPlay:!!u,loop:!!c,controls:!!l,errorFallback:C,style:a,inputProps:Qe,allowFullscreen:!!h,moveToBeginningWhenEnded:!!v,clickToPlay:typeof p=="boolean"?p:!!l,showVolumeControls:!!d,doubleClickToFullscreen:!!b,spaceKeyToPlayOrPause:!!y,playbackRate:ln,className:m??void 0,showPosterWhenUnplayed:!!M,showPosterWhenEnded:!!I,showPosterWhenPaused:!!N,showPosterWhenBuffering:!!F,showPosterWhenBufferingAndPaused:!!R,renderPoster:V,inFrame:z??null,outFrame:H??null,initiallyShowControls:ne??!0,renderFullscreen:se??null,renderPlayPauseButton:pe??null,renderMuteButton:ce??null,renderVolumeSlider:ie??null,renderCustomControls:O??null,alwaysShowControls:D,showPlaybackRateControl:oe,bufferStateDelayInMilliseconds:Re??300,hideControlsWhenPointerDoesntMove:le,overflowVisible:Ne,browserMediaControlsBehavior:Vt,overrideInternalClassName:De??void 0,noSuspense:!!Ye})})})})})},qN=i.forwardRef,XN=qN(GN),JN=()=>{const e=i.useContext(Lg);if(!e)throw new TypeError("Expected Player event emitter context");return i.useMemo(()=>({emitter:e}),[e])},xm=qe.version.split(".")[0];if(xm==="0")throw new Error(`Version ${xm} of "react" is not supported by Remotion`);var ZN=parseInt(xm,10)>=18,QN=({style:e,inputProps:n,errorFallback:r,renderLoading:s,className:o,overflowVisible:a,noSuspense:l,overrideInternalClassName:c},u)=>{const d=Pe.useUnsafeVideoConfig(),h=Pe.useVideo(),p=i.useRef(null),b=xp(p,{triggerOnWindowResize:!1,shouldApplyCssTransforms:!1}),y=i.useMemo(()=>!d||!b?null:Tg({canvasSize:b,compositionHeight:d.height,compositionWidth:d.width,previewSize:"auto"}),[b,d]),v=(y==null?void 0:y.scale)??1,w=JN();Og(w.emitter),i.useImperativeHandle(u,()=>{const R={getContainerNode:()=>p.current,getScale:()=>v};return Object.assign(w.emitter,R)},[v,w.emitter]);const C=h?h.component:null,k=i.useMemo(()=>Ag({config:d,style:e,canvasSize:b,overflowVisible:a,layout:y}),[b,d,y,a,e]),E=i.useMemo(()=>_g({config:d,layout:y,scale:v,overflowVisible:a}),[d,y,a,v]),m=i.useMemo(()=>$g({config:d,layout:y,scale:v,overflowVisible:a}),[d,y,a,v]),M=i.useCallback(R=>{w.emitter.dispatchError(R)},[w.emitter]),I=i.useMemo(()=>s?s({height:k.height,width:k.width,isBuffering:!1}):null,[k.height,k.width,s]),N=i.useMemo(()=>({type:"scale",scale:v}),[v]);if(!d)return null;const F=t.jsx("div",{style:E,children:t.jsx("div",{style:m,className:gp(c),children:C?t.jsx(Vg,{onError:M,errorFallback:r,children:t.jsx(Pe.CurrentScaleContext.Provider,{value:N,children:t.jsx(C,{...(h==null?void 0:h.props)??{},...n??{}})})}):null})});return l||Ug&&!ZN?t.jsx("div",{ref:p,style:k,className:o,children:F}):t.jsx("div",{ref:p,style:k,className:o,children:t.jsx(i.Suspense,{fallback:I,children:F})})},e3=i.forwardRef(QN),t3=({frameToDisplay:e,style:n,inputProps:r,compositionHeight:s,compositionWidth:o,durationInFrames:a,fps:l,className:c,errorFallback:u=()=>"â ï¸",renderLoading:d,overflowVisible:h=!1,overrideInternalClassName:p,logLevel:b="info",noSuspense:y,...v},w)=>{typeof window<"u"&&i.useLayoutEffect(()=>{window.remotion_isPlayer=!0},[]);const[C]=i.useState(()=>String(Oa(null))),k=i.useRef(null),E=i.useMemo(()=>({playing:!1,frame:{[bp]:e},rootId:C,imperativePlaying:{current:!1},audioAndVideoTags:{current:[]}}),[e,C]),m=i.useMemo(()=>({playbackRate:1,setPlaybackRate:()=>{throw new Error("thumbnail")}}),[]);i.useImperativeHandle(w,()=>k.current,[]);
106const M=Pe.useLazyComponent({compProps:v,componentName:"Thumbnail",noSuspense:!!y}),[I]=i.useState(()=>new Vj),N=i.useMemo(()=>r??{},[r]);return t.jsx(Pe.IsPlayerContextProvider,{children:t.jsx(Bg,{timelineContext:E,playbackRateContext:m,component:M,compositionHeight:s,compositionWidth:o,durationInFrames:a,fps:l,numberOfSharedAudioTags:0,initiallyMuted:!0,logLevel:b,audioLatencyHint:"playback",sampleRate:48e3,inputProps:N,audioEnabled:!1,children:t.jsx(Lg.Provider,{value:I,children:t.jsx(e3,{ref:k,className:c,errorFallback:u,inputProps:N,renderLoading:d,style:n,overflowVisible:h,overrideInternalClassName:p,noSuspense:!!y})})})})},n3=i.forwardRef;n3(t3);var r3=({instruction:e,lastPoint:n,progress:r})=>{const s=n.x+(e.x-n.x)*r,o=n.y+(e.y-n.y)*r;return{type:"L",x:s,y:o}};function Si(e,n,r){return{x:e.x+(n.x-e.x)*r,y:e.y+(n.y-e.y)*r}}function s3({progress:e,lastPoint:n,instruction:r}){const s=e,o={x:n.x,y:n.y},a={x:r.cp1x,y:r.cp1y},l={x:r.cp2x,y:r.cp2y},c={x:r.x,y:r.y},u=Si(o,a,s),d=Si(a,l,s),h=Si(l,c,s),p=Si(u,d,s),b=Si(d,h,s),y=Si(p,b,s);return{type:"C",cp1x:u.x,cp1y:u.y,cp2x:p.x,cp2y:p.y,x:y.x,y:y.y}}var o3=({instruction:e,lastPoint:n,progress:r})=>{if(e.type==="M")return e;if(e.type==="L")return r3({instruction:e,lastPoint:n,progress:r});if(e.type==="C")return s3({instruction:e,lastPoint:n,progress:r});if(e.type==="Z")return e;throw new TypeError(`${e.type} is not supported.`)},a3=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,
106-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],i3=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.122555206
10671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],l3=[[1],[1,1],[1,2,1],[1,3,3,1]],c3=(e,n,r)=>{const s=(1-r)*(1-r)*(1-r)*e[0]+3*(1-r)*(1-r)*r*e[1]+3*(1-r)*r*r*e[2]+r*r*r*e[3],o=(1-r)*(1-r)*(1-r)*n[0]+3*(1-r)*(1-r)*r*n[1]+3*(1-r)*r*r*n[2]+r*r*r*n[3];return{x:s,y:o}},gm=(e,n,r)=>{const s=r.length-1;let o;if(s===0)return 0;if(e===0){o=0;for(let l=0;l<=s;l++)o+=l3[s][l]*(1-n)**(s-l)*n**l*r[l];return o}const a=new Array(s);for(let l=0;l<s;l++)a[l]=s*(r[l+1]-r[l]);return gm(e-1,n,a)};function d3(e,n,r){const s=gm(1,r,e),o=gm(1,r,n),a=s*s+o*o;return Math.sqrt(a)}var xu=({sx:e,sy:n,t:r})=>{let s;const a=r/2;let l=0;for(let c=0;c<20;c++)s=a*a3[20][c]+a,l+=i3[20][c]*d3(e,n,s);return a*l},u3=(e,n,r)=>{const s=(1-r)*(1-r)*e[0]+2*(1-r)*r*e[1]+r*r*e[2],o=(1-r)*(1-r)*n[0]+2*(1-r)*r*n[1]+r*r*n[2];return{x:s,y:o}},m3=(e,n,r)=>u3([3*(e[1]-e[0]),3*(e[2]-e[1]),3*(e[3]-e[2])],[3*(n[1]-n[0]),3*(n[2]-n[1]),3*(n[3]-n[2])],r),uh=({length:e,totalLength:n,func:r})=>{let s=1,o=e/n,a=(e-r(o))/n,l=0;for(;s>.001;){const c=r(o+a),u=Math.abs(e-c)/n;if(u<s)s=u,o+=a;else{const d=r(o-a),h=Math.abs(e-d)/n;h<s?(s=h,o-=a):a/=2}if(l++,l>500)break}return o},p3=({startX:e,startY:n,cp1x:r,cp1y:s,cp2x:o,cp2y:a,x:l,y:c})=>{const u={x:e,y:n},d={x:r,y:s},h={x:o,y:a},p={x:l,y:c},b=xu({sx:[u.x,d.x,h.x,p.x],sy:[u.y,d.y,h.y,p.y],t:1});return{getPointAtLength:E=>{const m=[u.x,d.x,h.x,p.x],M=[u.y,d.y,h.y,p.y],I=uh({length:E,totalLength:b,func:N=>xu({sx:m,sy:M,t:N})});return c3(m,M,I)},getTangentAtLength:E=>{const m=[u.x,d.x,h.x,p.x],M=[u.y,d.y,h.y,p.y],I=uh({length:E,totalLength:b,func:A=>xu({sx:m,sy:M,t:A})}),N=m3(m,M,I),F=Math.sqrt(N.x*N.x+N.y*N.y);let R;return F>0?R={x:N.x/F,y:N.y/F}:R={x:0,y:0},R},getTotalLength:()=>b,getC:()=>h,getD:()=>p,type:"cubic-bezier"}},mh=({x0:e,x1:n,y0:r,y1:s})=>({getTotalLength:()=>Math.sqrt((e-n)**2+(r-s)**2),getPointAtLength:o=>{let a=o/Math.sqrt((e-n)**2+(r-s)**2);a=Number.isNaN(a)?1:a;const l=(n-e)*a,c=(s-r)*a;return{x:e+l,y:r+c}},getTangentAtLength:()=>{const o=Math.sqrt((n-e)*(n-e)+(s-r)*(s-r));return{x:(n-e)/o,y:(s-r)/o}},type:"linear"}),f3=e=>{let n={x:0,y:0},r={x:0,y:0};const s=[];for(let o=0;o<e.length;o++){const a=e[o];if(a.type==="M"&&(n={x:a.x,y:a.y},r={x:n.x,y:n.y},s.push({startPoint:{x:a.x,y:a.y},instructionsAndInfo:[{instruction:a,function:null,length:0,startPoint:n}]})),a.type==="L"){if(s.length>0){const l=Math.sqrt((n.x-a.x)**2+(n.y-a.y)**2);s[s.length-1].instructionsAndInfo.push({instruction:a,length:l,function:mh({x0:n.x,x1:a.x,y0:n.y,y1:a.y}),startPoint:n})}n={x:a.x,y:a.y}}if(a.type==="Z"){if(s.length>0){const l=Math.sqrt((s[s.length-1].startPoint.x-n.x)**2+(s[s.length-1].startPoint.y-n.y)**2);s[s.length-1].instructionsAndInfo.push({instruction:a,function:mh({x0:n.x,x1:r.x,y0:n.y,y1:r.y}),length:l,startPoint:{...n}})}n={x:r.x,y:r.y}}
106if(a.type==="C"){const l=p3({startX:n.x,startY:n.y,cp1x:a.cp1x,cp1y:a.cp1y,cp2x:a.cp2x,cp2y:a.cp2y,x:a.x,y:a.y}),c=l.getTotalLength();s.length>0&&s[s.length-1].instructionsAndInfo.push({instruction:a,length:c,function:l,startPoint:{...n}}),n={x:a.x,y:a.y}}}return s},Hg={a:7,A:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0},h3=(e,n)=>{const r=[],s=Hg[n];if(e.length%s!==0)throw new Error(`Expected number of arguments of SVG instruction "${n} ${e.join(" ")}" to be a multiple of ${s}`);for(let o=0;o<e.length;o+=s)r.push(e.slice(o,o+s));return r},vr=(e,n,r)=>h3(e,n).map(s=>r(s)),x3=/([astvzqmhlc])([^astvzqmhlc]*)/gi,g3=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi,b3=(e,n)=>{const r=e.match(g3);if(!r){if(n==="Z"||n==="z")return[];throw new Error(`Malformed path data: ${n} was expected to have numbers afterwards`)}const s=Hg[n];if(r.length%s!==0)throw new Error(`Malformed path data: ${n} was expected to have a multiple of ${s} numbers, but got "${n} ${r.join(" ")} instead"`);return r.map(Number)},Dd=e=>{if(!e)throw new Error("No path provided");const n=e.match(x3);if(!n)throw new Error(`No path elements found in string ${e}`);return n.map(r=>{const s=r.charAt(0),o=b3(r.substring(1),s);if(s==="M"&&o.length>2){const a=[];return a.push({type:s,x:o[0],y:o[1]}),a.push(...vr(o.slice(2),"L",l=>({type:"L",x:l[0],y:l[1]}))),a}if(s==="m"&&o.length>2){const a=[];return a.push({type:s,dx:o[0],dy:o[1]}),a.push(...vr(o.slice(2),"l",l=>({type:"l",dx:l[0],dy:l[1]}))),a}if(s==="Z"||s==="z")return[{type:"Z"}];if(s==="A")return vr(o,s,a=>({type:s,rx:a[0],ry:a[1],xAxisRotation:a[2],largeArcFlag:a[3]===1,sweepFlag:a[4]===1,x:a[5],y:a[6]}));if(s==="a")return vr(o,s,a=>({type:s,rx:a[0],ry:a[1],xAxisRotation:a[2],largeArcFlag:a[3]===1,sweepFlag:a[4]===1,dx:a[5],dy:a[6]}));if(s==="C")return vr(o,s,a=>({type:s,cp1x:a[0],cp1y:a[1],cp2x:a[2],cp2y:a[3],x:a[4],y:a[5]}));if(s==="c")return vr(o,s,a=>({type:s,cp1dx:a[0],cp1dy:a[1],cp2dx:a[2],cp2dy:a[3],dx:a[4],dy:a[5]}));if(s==="S")return vr(o,s,a=>({type:s,cpx:a[0],cpy:a[1],x:a[2],y:a[3]}));if(s==="s")return vr(o,s,a=>({type:s,cpdx:a[0],cpdy:a[1],dx:a[2],dy:a[3]}));if(s==="H")return vr(o,s,a=>({type:s,x:a[0]}));if(s==="h")return vr(o,s,a=>({type:s,dx:a[0]}));if(s==="V")return vr(o,s,a=>({type:s,y:a[0]}));if(s==="v")return vr(o,s,a=>({type:s,dy:a[0]}));if(s==="L")return vr(o,s,a=>({type:s,x:a[0],y:a[1]}));if(s==="M")return vr(o,s,a=>({type:s,x:a[0],y:a[1]}));if(s==="m")return vr(o,s,a=>({type:s,dx:a[0],dy:a[1]}));if(s==="l")return vr(o,s,a=>({type:s,dx:a[0],dy:a[1]}));if(s==="Q")return vr(o,s,a=>({type:s,cpx:a[0],cpy:a[1],x:a[2],y:a[3]}));if(s==="q")return vr(o,s,a=>({type:s,cpdx:a[0],cpdy:a[1],dx:a[2],dy:a[3]}));if(s==="T")return vr(o,s,a=>({type:s,x:a[0],y:a[1]}));if(s==="t")return vr(o,s,a=>({type:s,dx:a[0],dy:a[1]}));throw new Error(`Invalid path element ${r}`)},[]).flat(1)},ph=(e,n)=>{const r=n.x+.6666666666666666*(e.cpx-n.x),s=n.y+2/3*(e.cpy-n.y),o=e.x+2/3*(e.cpx-e.x),a=e.y+2/3*(e.cpy-e.y);return{type:"C",cp1x:r,cp1y:s,cp2x:o,cp2y:a,x:e.x,y:e.y}},y3=({segments:e,iterate:n})=>{let r=0,s=0,o=0,a=0,l=null,c=null;return e.map((d,h)=>{const p=n({segment:d,x:r,y:s,prevSegment:e[h-1]??null,initialX:o,initialY:a,cpX:l,cpY:c});switch(d.type){case"M":o=d.x,a=d.y,r=d.x,s=d.y,l=null,c=null;break;case"Q":r=d.x,s=d.y,l=d.cpx,c=d.cpy;break;case"A":r=d.x,s=d.y,l=null,c=null;break;case"C":r=d.x,s=d.y,l=d.cp2x,c=d.cp2y;break;case"S":r=d.x,s=d.y,l=d.cpx,c=d.cpy;break;case"T":l!==null&&c!==null&&(l=r-(l-r),c=s-(c-s)),r=d.x,s=d.y;break;case"L":r=d.x,s=d.y,l=null,c=null;break;case"V":s=d.y,l=null,c=null;break;case"H":r=d.x,l=null,c=null;break;case"Z":r=o,s=a,l=null,c=null;break;default:throw new Error(`Unexpected instruction ${d.type}`)}return p}).flat(1)},El=Math.PI*2;function v3(e,n){const r=1.3333333333333333*Math.tan(n/4),s=Math.cos(e),o=Math.sin(e),a=Math.cos(e+n),l=Math.sin(e+n);return[s,o,s-o*r,o+s*r,a+l*r,l-a*r,a,l]}function fh(e,n,r,s){const o=e*s-n*r<0?-1:1;let a=e*r+n*s;return a>1&&(a=1),a<-1&&(a=-1),o*Math.acos(a)}function w3({x1:e,y1:n,x2:r,y2:s,largeArcFlag:o,sweepFlag:a,rx:l,ry:c,sin_phi:u,cos_phi:d}){const h=d*(e-r)/2+u*(n-s)/2,p=-u*(e-r)/2+d*(n-s)/2,b=l*l,y=c*c,v=h*h,w=p*p;let C=b*y-b*w-y*v;C<0&&(C=0),C/=b*w+y*v,C=Math.sqrt(C)*(o===a?-1:1);const k=C*l/c*p,E=C*-c/l*h,m=d*k-u*E+(e+r)/2,M=u*k+d*E+(n+s)/2,I=(h-k)/l,N=(p-E)/c,F=(-h-k)/l,R=(-p-E)/c,A=fh(1,0,I,N);let V=fh(I,N,F,R);return a===!1&&V>0&&(V-=El),a===!0&&V<0&&(V+=El),[m,M,A,V]}function j3({x1:e,y1:n,x2:r,y2:s,largeArcFlag:o,sweepFlag:a,rx:l,ry:c,phi:u}){const d=Math.sin(u*El/360),h=Math.cos(u*El/360),p=h*(e-r)/2+d*(n-s)/2,b=-d*(e-r)/2+h*(n-s)/2;if(p===0&&b===0)return[];if(l===0||c===0)return[];l=Math.abs(l),c=Math.abs(c);const y=p*p/(l*l)+b*b/(c*c);y>1&&(l*=Math.sqrt(y),c*=Math.sqrt(y));const v=w3({x1:e,y1:n,x2:r,y2:s,largeArcFlag:o,sweepFlag:a,rx:l,ry:c,sin_phi:d,cos_phi:h}),w=[];let C=v[2],k=v[3];const E=Math.max(Math.ceil(Math.abs(k)/(El/4)),1);k/=E;for(let m=0;m<E;m++)w.push(v3(C,k)),C+=k;return w.map(m=>{for(let M=0;M<m.length;M+=2){let I=m[M+0],N=m[M+1];I*=l,N*=c;const F=h*I-d*N,R=d*I+h*N;m[M+0]=F+v[0],m[M+1]=R+v[1]}return m})}var Kg=e=>y3({segments:e,iterate:({segment:n,prevSegment:r,x:s,y:o,cpX:a,cpY:l})=>
106{if(n.type==="H")return[{type:"L",x:n.x,y:o}];if(n.type==="V")return[{type:"L",x:s,y:n.y}];if(n.type==="A"){const c=n.x,u=n.y,d=j3({x1:s,y1:o,x2:c,y2:u,largeArcFlag:n.largeArcFlag,sweepFlag:n.sweepFlag,rx:n.rx,ry:n.ry,phi:n.xAxisRotation});return d.length===0?[{type:"L",x:n.x,y:n.y}]:d.map(p=>({type:"C",cp1x:p[2],cp1y:p[3],cp2x:p[4],cp2y:p[5],x:p[6],y:p[7]}))}if(n.type==="T"){let c=0,u=0;r&&(r.type==="Q"||r.type==="T")?(c=a,u=l):(c=s,u=o);const d=c-s,h=u-o,p=s-d,b=o-h;return[ph({cpx:p,cpy:b,x:n.x,y:n.y},{x:s,y:o})]}if(n.type==="S"){let c=0,u=0;r&&r.type==="C"?(c=r.cp2x,u=r.cp2y):r&&r.type==="S"?(c=r.cpx,u=r.cpy):(c=s,u=o);const d=c-s,h=u-o,p=s-d,b=o-h;return[{type:"C",cp1x:p,cp1y:b,cp2x:n.cpx,cp2y:n.cpy,x:n.x,y:n.y}]}return n.type==="Q"?[ph(n,{x:s,y:o})]:[n]}}),N3=e=>{if(e.type==="A")return`A ${e.rx} ${e.ry} ${e.xAxisRotation} ${Number(e.largeArcFlag)} ${Number(e.sweepFlag)} ${e.x} ${e.y}`;if(e.type==="a")return`a ${e.rx} ${e.ry} ${e.xAxisRotation} ${Number(e.largeArcFlag)} ${Number(e.sweepFlag)} ${e.dx} ${e.dy}`;if(e.type==="C")return`C ${e.cp1x} ${e.cp1y} ${e.cp2x} ${e.cp2y} ${e.x} ${e.y}`;if(e.type==="c")return`c ${e.cp1dx} ${e.cp1dy} ${e.cp2dx} ${e.cp2dy} ${e.dx} ${e.dy}`;if(e.type==="S")return`S ${e.cpx} ${e.cpy} ${e.x} ${e.y}`;if(e.type==="s")return`s ${e.cpdx} ${e.cpdy} ${e.dx} ${e.dy}`;if(e.type==="Q")return`Q ${e.cpx} ${e.cpy} ${e.x} ${e.y}`;if(e.type==="q")return`q ${e.cpdx} ${e.cpdy} ${e.dx} ${e.dy}`;if(e.type==="Z")return"Z";if(e.type==="H")return`H ${e.x}`;if(e.type==="h")return`h ${e.dx}`;if(e.type==="V")return`V ${e.y}`;if(e.type==="v")return`v ${e.dy}`;if(e.type==="L")return`L ${e.x} ${e.y}`;if(e.type==="l")return`l ${e.dx} ${e.dy}`;if(e.type==="M")return`M ${e.x} ${e.y}`;if(e.type==="m")return`m ${e.dx} ${e.dy}`;if(e.type==="T")return`T ${e.x} ${e.y}`;if(e.type==="t")return`t ${e.dx} ${e.dy}`;throw new Error(`Unknown instruction type: ${e.type}`)},hs=e=>e.map(n=>N3(n)).join(" "),yp=e=>{const n=[];let r=0,s=0,o=0,a=0;for(let l=0;l<e.length;l++){const c=e[l];if(c.type==="M"?(o=c.x,a=c.y):c.type==="m"&&(o+=c.dx,a+=c.dy),c.type==="A"||c.type==="C"||c.type==="L"||c.type==="M"||c.type==="Q"||c.type==="S"||c.type==="T"){n.push(c),r=c.x,s=c.y;continue}if(c.type==="a"||c.type==="c"||c.type==="l"||c.type==="m"||c.type==="q"||c.type==="s"||c.type==="t"){const u=r,d=s;if(r+=c.dx,s+=c.dy,c.type==="a"){n.push({type:"A",largeArcFlag:c.largeArcFlag,rx:c.rx,ry:c.ry,sweepFlag:c.sweepFlag,xAxisRotation:c.xAxisRotation,x:r,y:s});continue}if(c.type==="c"){n.push({type:"C",cp1x:c.cp1dx+u,cp1y:c.cp1dy+d,cp2x:c.cp2dx+u,cp2y:c.cp2dy+d,x:r,y:s});continue}if(c.type==="l"){n.push({type:"L",x:r,y:s});continue}if(c.type==="m"){n.push({type:"M",x:r,y:s});continue}if(c.type==="q"){n.push({type:"Q",cpx:c.cpdx+u,cpy:c.cpdy+d,x:r,y:s});continue}if(c.type==="s"){n.push({type:"S",cpx:c.cpdx+u,cpy:c.cpdy+d,x:r,y:s});continue}if(c.type==="t"){n.push({type:"T",x:r,y:s});continue}}if(c.type==="H"){n.push(c),r=c.x;continue}if(c.type==="V"){n.push(c),s=c.y;continue}if(c.type==="Z"){n.push(c),r=o,s=a;continue}if(c.type==="h"){r+=c.dx,n.push({type:"H",x:r});continue}if(c.type==="v"){s+=c.dy,n.push({type:"V",y:s});continue}throw new Error("Unknown instruction type: "+c.type)}return n},vp=e=>{const n=yp(e);return Kg(n)},k3=(e,n)=>{const r=Dd(e),s=vp(r),o=f3(s),a=[];let l=0;for(const c of o)for(const u of c.instructionsAndInfo){if(l+u.length>n){const h=(n-l)/u.length,p=o3({instruction:u.instruction,lastPoint:u.startPoint,progress:h});return a.push(p),hs(a)}if(l+=u.length,a.push(u.instruction),l===n)return hs(a)}return hs(a)},S3=e=>{const n=yp(Dd(e));return n.map((r,s)=>{if(r.type==="Z"||r.type==="H"||r.type==="V")return null;const o=[r.x-5,r.y-5],a=[r.x+5,r.y-5],l=[r.x-5,r.y+5],c=[r.x+5,r.y+5],u=[{type:"M",x:o[0],y:o[1]},{type:"L",x:a[0],y:a[1]},{type:"L",x:c[0],y:c[1]},{type:"L",x:l[0],y:l[1]},{type:"Z"}];return{d:hs(u),color:s===n.length-1?"red":r.type==="M"?"blue":"green"}}).filter(Boolean)},C3=1e-8;function E3(e){const n=Math.min(e[0],e[2]),r=Math.max(e[0],e[2]);if(e[1]>e[0]?e[2]>=e[1]:e[2]<=e[1])return[n,r];const s=(e[0]*e[2]-e[1]*e[1])/(e[0]-2*e[1]+e[2]);return s<n?[s,r]:[n,s]}function hh(e){const n=e[0]-3*e[1]+3*e[2]-e[3];
106if(Math.abs(n)<C3)return e[0]===e[3]&&e[0]===e[1]?[e[0],e[3]]:E3([e[0],-.5*e[0]+1.5*e[1],e[0]-3*e[1]+3*e[2]]);const r=-e[0]*e[2]+e[0]*e[3]-e[1]*e[2]-e[1]*e[3]+e[1]*e[1]+e[2]*e[2];if(r<=0)return[Math.min(e[0],e[3]),Math.max(e[0],e[3])];const s=Math.sqrt(r);let o=Math.min(e[0],e[3]),a=Math.max(e[0],e[3]);const l=e[0]-2*e[1]+e[2];for(let c=(l+s)/n,u=1;u<=2;c=(l-s)/n,u++)if(c>0&&c<1){const d=e[0]*(1-c)*(1-c)*(1-c)+e[1]*3*(1-c)*(1-c)*c+e[2]*3*(1-c)*c*c+e[3]*c*c*c;d<o&&(o=d),d>a&&(a=d)}return[o,a]}var Wg=e=>{let n=1/0,r=1/0,s=-1/0,o=-1/0,a=0,l=0,c=0,u=0;for(const d of e)switch(d.type){case"M":{c=d.x,u=d.y,n>d.x&&(n=d.x),r>d.y&&(r=d.y),s<d.x&&(s=d.x),o<d.y&&(o=d.y),a=d.x,l=d.y;break}case"L":{n>d.x&&(n=d.x),r>d.y&&(r=d.y),s<d.x&&(s=d.x),o<d.y&&(o=d.y),a=d.x,l=d.y;break}case"C":{const h=hh([a,d.cp1x,d.cp2x,d.x]);n>h[0]&&(n=h[0]),s<h[1]&&(s=h[1]);const p=hh([l,d.cp1y,d.cp2y,d.y]);r>p[0]&&(r=p[0]),o<p[1]&&(o=p[1]),a=d.x,l=d.y;break}case"Z":a=c,l=u;break;default:throw new Error(`Unknown instruction ${d.type}`)}return{x1:n,y1:r,x2:s,y2:o,viewBox:`${n} ${r} ${s-n} ${o-r}`,width:s-n,height:o-r}},M3=e=>{const n=Dd(e),r=Kg(yp(n));return Wg(r)},I3=(e,n,r)=>e.map(s=>{if(s.type==="a"||s.type==="c"||s.type==="v"||s.type==="s"||s.type==="h"||s.type==="l"||s.type==="m"||s.type==="q"||s.type==="t")return s;if(s.type==="V")return{type:"V",y:s.y+r};if(s.type==="H")return{type:"H",x:s.x+n};if(s.type==="A")return{type:"A",rx:s.rx,ry:s.ry,largeArcFlag:s.largeArcFlag,sweepFlag:s.sweepFlag,xAxisRotation:s.xAxisRotation,x:s.x+n,y:s.y+r};if(s.type==="Z")return s;if(s.type==="C")return{type:"C",cp1x:s.cp1x+n,cp1y:s.cp1y+r,cp2x:s.cp2x+n,cp2y:s.cp2y+r,x:s.x+n,y:s.y+r};if(s.type==="Q")return{type:"Q",cpx:s.cpx+n,cpy:s.cpy+r,x:s.x+n,y:s.y+r};if(s.type==="S")return{type:"S",cpx:s.cpx+n,cpy:s.cpy+r,x:s.x+n,y:s.y+r};if(s.type==="T")return{type:"T",x:s.x+n,y:s.y+r};if(s.type==="L")return{type:"L",x:s.x+n,y:s.y+r};if(s.type==="M")return{type:"M",x:s.x+n,y:s.y+r};throw new Error(`Unknown segment type: ${s.type}`)}),F3=(e,n,r)=>hs(I3(Dd(e),n,r)),Yg=e=>{const n=M3(e);return F3(e,-n.x1,-n.y1)},Gg={getBoundingBoxFromInstructions:Wg,debugPath:S3,cutPath:k3},gc=(e,n)=>{const r=n[0]-e[0],s=n[1]-e[1],o=Math.sqrt(r*r+s*s);return o===0?[0,0]:[r/o,s/o]},R3=(e,n,r)=>{const s=e.length;if(r===0)return[{type:"M",x:e[0][0],y:e[0][1]},...e.slice(1).map(([d,h])=>({type:"L",x:d,y:h})),{type:"Z"}];const o=gc(e[0],e[1]),a=e[0][0]+o[0]*r,l=e[0][1]+o[1]*r,c=[{type:"M",x:a,y:l}];for(let d=1;d<s;d++){const h=e[d];if(n.has(d)){const p=e[d-1],b=e[(d+1)%s],y=gc(p,h),v=gc(h,b);c.push({type:"L",x:h[0]-y[0]*r,y:h[1]-y[1]*r},{type:"C",cp1x:h[0],cp1y:h[1],cp2x:h[0],cp2y:h[1],x:h[0]+v[0]*r,y:h[1]+v[1]*r})}else c.push({type:"L",x:h[0],y:h[1]})}const u=gc(e[s-1],e[0]);return c.push({type:"L",x:e[0][0]-u[0]*r,y:e[0][1]-u[1]*r},{type:"C",cp1x:e[0][0],cp1y:e[0][1],cp2x:e[0][0],cp2y:e[0][1],x:a,y:l},{type:"Z"}),c},P3=({length:e=300,headWidth:n=185,headLength:r=120,shaftWidth:s=80,direction:o="right",cornerRadius:a=0})=>{if(e<=0||n<=0||r<=0||s<=0)throw new Error('All dimension parameters ("length", "headWidth", "headLength", "shaftWidth") must be positive numbers');if(n<s)throw new Error(`"headWidth" must be greater than or equal to "shaftWidth", got headWidth=${n} and shaftWidth=${s}`);if(r>e)throw new Error(`"headLength" must be less than or equal to "length", got headLength=${r} and length=${e}`);const l=(n-s)/2,c=l+s,u=e-r,d=[[0,l],[u,l],[u,0],[e,n/2],[u,n],[u,c],[0,c]];let h,p,b;o==="right"?(h=d,p=e,b=n):o==="left"?(h=d.map(([C,k])=>[e-C,k]),p=e,b=n):o==="down"?(h=[[l,0],[c,0],[c,u],[n,u],[n/2,e],[0,u],[l,u]],p=n,b=e):(h=[[l,e],[c,e],[c,r],[n,r],[n/2,0],[0,r],[l,r]],p=n,b=e);const v=R3(h,o==="right"||o==="left"?new Set([0,2,3,4,6]):new Set([0,1,3,4,5]),a);return{path:hs(v),instructions:v,width:p,height:b,transformOrigin:`${p/2} ${b/2}`}},T3=e=>{if(e.includes("canary")||e.includes("experimental"))return parseInt(e.slice(-8),10)>20230209;const[n]=e.split(".").map(Number);return n>18},Qo=({defaultName:e,documentationLink:n,width:r,height:s,path:o,style:a,pathStyle:l,transformOrigin:c,debug:u,effects:d=[],instructions:h,pixelDensity:p,durationInFrames:b,from:y,freeze:v,hidden:w,name:C,showInTimeline:k,_experimentalControls:E,stack:m,...M})=>{const I=i.useMemo(()=>({overflow:"visible",...a??{}}),[a]),N=i.useMemo(()=>({transformBox:"fill-box",...l??{}}),[l]),F=i.useRef(null),R=i.useCallback(ie=>{F.current=ie},[]),A=i.useCallback(ie=>{F.current=ie},[]),V=Pe.useMemoizedEffectDefinitions(d),z=Pe.useUnsafeVideoConfig(),H=T3(Un.version),ne=t.jsxs("svg",{ref:d.length===0||!z?R:void 0,width:r,height:s,viewBox:`0 0 ${r} ${s}`,xmlns:"http://www.w3.org/2000/svg",style:d.length===0||!z?I:{overflow:"visible"},children:[t.jsx("path",{...H?{transformOrigin:c}:{"transform-origin":c},d:o,style:N,...M}),u?h.map((ie,O)=>{if(ie.type==="C"){const D=O===0?h[h.length-1]:h[O-1];if(D.type==="V"||D.type==="H"||D.type==="a"||D.type==="Z"||D.type==="t"||D.type==="q"||D.type==="l"||D.type==="c"||D.type==="m"||D.type==="h"||D.type==="s"||D.type==="v")return null;const W=D.x,oe=D.y;return t.jsxs(qe.Fragment,{children:[t.jsx("path",{d:`M ${W} ${oe} ${ie.cp1x} ${ie.cp1y}`,strokeWidth:2,stroke:"rgba(0, 0, 0, 0.4)"}),t.jsx("path",{d:`M ${ie.x} ${ie.y} ${ie.cp2x} ${ie.cp2y}`,strokeWidth:2,stroke:"rgba(0, 0, 0, 0.4)"}),t.jsx("circle",{cx:ie.cp1x,cy:ie.cp1y,r:3,fill:"white",strokeWidth:2,stroke:"black"}),t.jsx("circle",{cx:ie.cp2x,cy:ie.cp2y,r:3,strokeWidth:2,fill:"white",stroke:"black"})]},O)}return null}):null]}),se=d.length===0?ne:t.jsx(cp,{ref:A,width:Math.ceil(r),height:Math.ceil(s),effects:d,pixelDensity:p,showInTimeline:!1,style:I,_experimentalControls:E,children:ne}),pe=m===void 0?null:{stack:m};return z?t.jsx(Ir,{layout:"none",from:y,freeze:v,hidden:w,showInTimeline:k,_experimentalControls:E,_remotionInternalEffects:V,durationInFrames:b,name:C??e,_remotionInternalRefForOutline:F,_remotionInternalDocumentationLink:C===void 0?n:void 0,...pe,children:se}):ne},Zt=({defaultValue:e,description:n,hiddenFromList:r=!1,max:s,min:o,step:a=1}
106)=>({type:"number",default:e,description:n,hiddenFromList:r,max:s,min:o,step:a}),xh=({defaultValue:e,description:n})=>({type:"boolean",default:e,description:n}),A3=({defaultValue:e,description:n})=>({type:"color",default:e,description:n}),wp=({defaultValue:e,description:n,variants:r})=>({type:"enum",default:e,description:n,variants:Object.fromEntries(r.map(s=>[s,{}]))}),ea=e=>({from:Pe.sequenceSchema.from,freeze:Pe.sequenceSchema.freeze,durationInFrames:Pe.sequenceSchema.durationInFrames,...e,fill:A3({defaultValue:"#0b84ff",description:"Fill"}),...Pe.sequenceVisualStyleSchema,hidden:Pe.sequenceSchema.hidden}),$3=ea({length:Zt({defaultValue:300,description:"Length",min:0}),headWidth:Zt({defaultValue:185,description:"Head Width",min:0}),headLength:Zt({defaultValue:120,description:"Head Length",min:0}),shaftWidth:Zt({defaultValue:80,description:"Shaft Width",min:0}),direction:wp({defaultValue:"right",description:"Direction",variants:["right","left","up","down"]}),cornerRadius:Zt({defaultValue:0,description:"Corner Radius",min:0})}),_3=({length:e,headWidth:n,headLength:r,shaftWidth:s,direction:o,cornerRadius:a,...l})=>t.jsx(Qo,{defaultName:"<Arrow>",documentationLink:"https://www.remotion.dev/docs/shapes/arrow",...P3({length:e,headWidth:n,headLength:r,shaftWidth:s,direction:o,cornerRadius:a}),...l}),D3=Pe.wrapInSchema({Component:_3,componentIdentity:"dev.remotion.shapes.Arrow",schema:$3,supportsEffects:!0});Pe.addSequenceStackTraces(D3);var gh=(e,n)=>{const[r,s]=e,o=Math.sqrt(r*r+s*s),a=(o-n)/o;return[r*a,s*a]},bh=(e,n)=>{const[r,s]=e,o=Math.sqrt(r*r+s*s),a=n/o;return[r*a,s*a]},Ql=(e,{edgeRoundness:n,cornerRadius:r,roundCornerStrategy:s})=>e.map(([o,a],l)=>{const c=l===0?e.length-2:l-1,u=e[c],d=l===e.length-1?1:l+1,h=e[d],p=[(o+h[0])/2,(a+h[1])/2],b=[(o+u[0])/2,(a+u[1])/2],y=[o-u[0],a-u[1]],v=[h[0]-o,h[1]-a];if(l===0){if(n!==null)return[{type:"M",x:p[0],y:p[1]}];if(r!==0){const k=gh(v,r);return[{type:"M",x:k[0]+o,y:k[1]+a}]}return[{type:"M",x:o,y:a}]}if(r&&n!==null)throw new Error('"cornerRadius" and "edgeRoundness" cannot be specified at the same time.');if(n===null){if(r===0)return[{type:"L",x:o,y:a}];const k=gh(y,r),E=bh(y,r),m=bh(v,r),M=[u[0]+k[0],u[1]+k[1]];return[{type:"L",x:M[0],y:M[1]},s==="arc"?{type:"a",rx:r,ry:r,xAxisRotation:0,dx:E[0]+m[0],dy:E[1]+m[1],largeArcFlag:!1,sweepFlag:!0}:{type:"C",x:M[0]+E[0]+m[0],y:M[1]+E[1]+m[1],cp1x:o,cp1y:a,cp2x:o,cp2y:a}]}const w=[b[0]+y[0]*n*.5,b[1]+y[1]*n*.5],C=[p[0]-v[0]*n*.5,p[1]-v[1]*n*.5];return[{type:"C",cp1x:w[0],cp1y:w[1],cp2x:C[0],cp2y:C[1],x:p[0],y:p[1]}]}).flat(1),bc=(e,n)=>{if(typeof n!="number"||n<=0)throw new Error(`"${e}" must be a positive number, got ${n}`)},yh=({availableLength:e,pointerBaseWidth:n,pointerPosition:r})=>{const s=e*r,o=n/2;return{center:s,start:Math.max(0,s-o),end:Math.min(e,s+o)}},bm=(e,n)=>e[0]===n[0]&&e[1]===n[1],L3=e=>{const n=e.reduce((o,a)=>{const l=o[o.length-1];return l&&bm(l.point,a.point)?(o[o.length-1]={point:l.point,round:l.round&&a.round},o):[...o,a]},[]);if(n.length===0)return n;const r=n[0],s=n[n.length-1];if(bm(r.point,s.point)){const[o,...a]=n,l=a.slice(0,-1),c={point:o.point,round:o.round&&s.round};return[c,...l,c]}return[...n,r]},yc=(e,n)=>{const r=n[0]-e[0],s=n[1]-e[1],o=Math.sqrt(r*r+s*s);return o===0?[0,0]:[r/o,s/o]},O3=({points:e,edgeRoundness:n,cornerRadius:r})=>{const s=e.map(d=>d.point);if(n!==null||r===0)return[...Ql(s,{edgeRoundness:n,cornerRadius:r,roundCornerStrategy:"arc"}),{type:"Z"}];const o=bm(e[0].point,e[e.length-1].point)?e.slice(0,-1):e,a=o[0],l=a.round?yc(o[0].point,o[1].point):null,c=l?[a.point[0]+l[0]*r,a.point[1]+l[1]*r]:a.point,u=[{type:"M",x:c[0],y:c[1]}];for(let d=1;d<o.length;d++){const h=o[d];if(!h.round){u.push({type:"L",x:h.point[0],y:h.point[1]});continue}const p=o[d-1].point,b=o[(d+1)%o.length].point,y=yc(p,h.point),v=yc(h.point,b),w=[h.point[0]-y[0]*r,h.point[1]-y[1]*r];u.push({type:"L",x:w[0],y:w[1]},{type:"a",rx:r,ry:r,xAxisRotation:0,dx:y[0]*r+v[0]*r,dy:y[1]*r+v[1]*r,largeArcFlag:!1,sweepFlag:!0})}if(a.round){const d=o[o.length-1].point,h=yc(d,a.point);
106u.push({type:"L",x:a.point[0]-h[0]*r,y:a.point[1]-h[1]*r},{type:"a",rx:r,ry:r,xAxisRotation:0,dx:h[0]*r+l[0]*r,dy:h[1]*r+l[1]*r,largeArcFlag:!1,sweepFlag:!0})}return u.push({type:"Z"}),u},V3=({width:e=500,height:n=200,pointerLength:r=40,pointerBaseWidth:s=60,pointerPosition:o=.5,pointerDirection:a="down",edgeRoundness:l=null,cornerRadius:c=0})=>{if(bc("width",e),bc("height",n),bc("pointerLength",r),bc("pointerBaseWidth",s),typeof o!="number"||o<0||o>1)throw new Error(`"pointerPosition" must be a number between 0 and 1, got ${o}`);const u=yh({availableLength:e,pointerBaseWidth:s,pointerPosition:o}),d=yh({availableLength:n,pointerBaseWidth:s,pointerPosition:o}),h={up:[{point:[0,r],round:!0},{point:[u.start,r],round:!1},{point:[u.center,0],round:!1},{point:[u.end,r],round:!1},{point:[e,r],round:!0},{point:[e,n+r],round:!0},{point:[0,n+r],round:!0},{point:[0,r],round:!0}],down:[{point:[0,0],round:!0},{point:[e,0],round:!0},{point:[e,n],round:!0},{point:[u.end,n],round:!1},{point:[u.center,n+r],round:!1},{point:[u.start,n],round:!1},{point:[0,n],round:!0},{point:[0,0],round:!0}],left:[{point:[r,0],round:!0},{point:[e+r,0],round:!0},{point:[e+r,n],round:!0},{point:[r,n],round:!0},{point:[r,d.end],round:!1},{point:[0,d.center],round:!1},{point:[r,d.start],round:!1},{point:[r,0],round:!0}],right:[{point:[0,0],round:!0},{point:[e,0],round:!0},{point:[e,d.start],round:!1},{point:[e+r,d.center],round:!1},{point:[e,d.end],round:!1},{point:[e,n],round:!0},{point:[0,n],round:!0},{point:[0,0],round:!0}]},p=L3(h[a]),b=O3({points:p,edgeRoundness:l,cornerRadius:c}),y=hs(b),v=a==="left"||a==="right"?e+r:e,w=a==="up"||a==="down"?n+r:n,C=a==="left"?r:0,k=a==="up"?r:0;return{width:v,height:w,instructions:b,path:y,transformOrigin:`${C+e/2} ${k+n/2}`}},U3=ea({width:Zt({defaultValue:500,description:"Width",min:1}),height:Zt({defaultValue:200,description:"Height",min:1}),pointerLength:Zt({defaultValue:40,description:"Pointer Length",min:1}),pointerBaseWidth:Zt({defaultValue:60,description:"Pointer Base Width",min:1}),pointerPosition:Zt({defaultValue:.5,description:"Pointer Position",min:0,max:1,step:.01}),pointerDirection:wp({defaultValue:"down",description:"Pointer Direction",variants:["up","down","left","right"]}),cornerRadius:Zt({defaultValue:0,description:"Corner Radius",min:0})}),z3=({width:e,height:n,pointerLength:r,pointerBaseWidth:s,pointerPosition:o,pointerDirection:a,edgeRoundness:l,cornerRadius:c,...u})=>t.jsx(Qo,{defaultName:"<Callout>",documentationLink:"https://www.remotion.dev/docs/shapes/callout",...V3({width:e,height:n,pointerLength:r,pointerBaseWidth:s,pointerPosition:o,pointerDirection:a,edgeRoundness:l,cornerRadius:c}),...u}),B3=Pe.wrapInSchema({Component:z3,componentIdentity:"dev.remotion.shapes.Callout",schema:U3,supportsEffects:!0});Pe.addSequenceStackTraces(B3);var H3=({radius:e})=>{const n=[{type:"M",x:e,y:0},{type:"a",rx:e,ry:e,xAxisRotation:0,largeArcFlag:!0,sweepFlag:!0,dx:0,dy:e*2},{type:"a",rx:e,ry:e,xAxisRotation:0,largeArcFlag:!0,sweepFlag:!0,dx:0,dy:-e*2},{type:"Z"}],r=hs(n);return{height:e*2,width:e*2,path:r,instructions:n,transformOrigin:`${e} ${e}`}},K3=ea({radius:Zt({defaultValue:100,description:"Radius",min:0})}),W3=({radius:e,...n})=>t.jsx(Qo,{defaultName:"<Circle>",documentationLink:"https://www.remotion.dev/docs/shapes/circle",...H3({radius:e}),...n}),qg=Pe.wrapInSchema({Component:W3,componentIdentity:"dev.remotion.shapes.Circle",schema:K3,supportsEffects:!0});Pe.addSequenceStackTraces(qg);var Y3=({rx:e,ry:n})=>{const r=[{type:"M",x:e,y:0},{type:"a",rx:e,ry:n,xAxisRotation:0,largeArcFlag:!0,sweepFlag:!1,dx:1,dy:0},{type:"Z"}],s=hs(r);return{width:e*2,height:n*2,path:s,instructions:r,transformOrigin:`${e} ${n}`}},G3=ea({rx:Zt({defaultValue:100,description:"X Radius",min:0}),ry:Zt({defaultValue:50,description:"Y Radius",min:0})}),q3=({rx:e,ry:n,...r})=>t.jsx(Qo,{defaultName:"<Ellipse>",documentationLink:"https://www.remotion.dev/docs/shapes/ellipse",...Y3({rx:e,ry:n}),...r}),Xg=Pe.wrapInSchema({Component:q3,componentIdentity:"dev.remotion.shapes.Ellipse",schema:G3,supportsEffects:!0});Pe.addSequenceStackTraces(Xg);var X3=({height:e,aspectRatio:n=1.1,bottomRoundnessAdjustment:r=0,depthAdjustment:s=0})=>{const o=e*n,a=23/110*o+r*o,l=69/100*e,c=60/100*e,u=13/100*e,d=29/110*o,h=15/110*o,p=5/110*o,b=7/100*e,y=17/100*e+s*e,v=[{type:"M",x:o/2,y:e},{type:"C",cp1x:o/2-a,cp1y:l,cp2x:0,cp2y:c,x:0,y:e/4},{type:"C",cp1x:0,cp1y:u,cp2x:o/4-d/2,cp2y:0,x:o/4,y:0},{type:"C",cp1x:o/4+d/2,cp1y:0,cp2x:o/2-p,cp2y:b,x:o/2,y},{type:"C",cp1x:o/2+p,cp1y:b,cp2x:o/2+h,cp2y:0,x:o/4*3,y:0},{type:"C",cp1x:o/4*3+d/2,cp1y:0,cp2x:o,cp2y:u,x:o,y:e/4},{type:"C",x:o/2,y:e,cp1x:o,cp1y:c,cp2x:o/2+a,cp2y:l},{type:"Z"}];return{path:hs(v),width:o,height:e,transformOrigin:`${o/2} ${e/2}`,instructions:v}}
106,J3=ea({height:Zt({defaultValue:100,description:"Height",min:0}),aspectRatio:Zt({defaultValue:1.1,description:"Aspect Ratio",min:0,step:.01}),bottomRoundnessAdjustment:Zt({defaultValue:0,description:"Bottom Roundness Adjustment",step:.01}),depthAdjustment:Zt({defaultValue:0,description:"Depth Adjustment",step:.01})}),Z3=({aspectRatio:e,height:n,bottomRoundnessAdjustment:r=0,depthAdjustment:s=0,...o})=>t.jsx(Qo,{defaultName:"<Heart>",documentationLink:"https://www.remotion.dev/docs/shapes/heart",...X3({aspectRatio:e,height:n,bottomRoundnessAdjustment:r,depthAdjustment:s}),...o}),Q3=Pe.wrapInSchema({Component:Z3,componentIdentity:"dev.remotion.shapes.Heart",schema:J3,supportsEffects:!0});Pe.addSequenceStackTraces(Q3);var Ci=({counterClockwise:e,actualProgress:n,rotation:r,radius:s,coord:o})=>{const a=e?-1:1,l=Math[o==="x"?"cos":"sin"](a*n*Math.PI*2+Math.PI*1.5+r)*s+s;return Math.round(l*1e5)/1e5},e4=({progress:e,radius:n,closePath:r=!0,counterClockwise:s=!1,rotation:o=0})=>{const a=Math.min(Math.max(e,0),1),l=Ci({actualProgress:a,coord:"x",counterClockwise:s,radius:n,rotation:o}),c=Ci({actualProgress:a,coord:"y",counterClockwise:s,radius:n,rotation:o}),u={x:Ci({actualProgress:0,coord:"x",counterClockwise:s,radius:n,rotation:o}),y:Ci({actualProgress:0,coord:"y",counterClockwise:s,radius:n,rotation:o})},d={x:l,y:c},h=[{type:"M",...u},{type:"A",rx:n,ry:n,xAxisRotation:0,largeArcFlag:!1,sweepFlag:!s,x:a<=.5?l:Ci({actualProgress:.5,coord:"x",counterClockwise:s,radius:n,rotation:o}),y:a<=.5?c:Ci({actualProgress:.5,coord:"y",counterClockwise:s,radius:n,rotation:o})},a>.5?{type:"A",rx:n,ry:n,xAxisRotation:0,largeArcFlag:!1,sweepFlag:!s,...d}:null,a>0&&a<1&&r?{type:"L",x:n,y:n}:null,r?{type:"Z"}:null].filter(Boolean),p=hs(h);return{height:n*2,width:n*2,path:p,instructions:h,transformOrigin:`${n} ${n}`}},t4=ea({radius:Zt({defaultValue:100,description:"Radius",min:0}),progress:Zt({defaultValue:.5,description:"Progress",max:1,min:0,step:.01}),closePath:xh({defaultValue:!0,description:"Close Path"}),counterClockwise:xh({defaultValue:!1,description:"Counter Clockwise"}),rotation:Zt({defaultValue:0,description:"Rotation",step:.01})}),n4=({radius:e,progress:n,closePath:r,counterClockwise:s,rotation:o,...a})=>t.jsx(Qo,{defaultName:"<Pie>",documentationLink:"https://www.remotion.dev/docs/shapes/pie",...e4({radius:e,progress:n,closePath:r,counterClockwise:s,rotation:o}),...a}),r4=Pe.wrapInSchema({Component:n4,componentIdentity:"dev.remotion.shapes.Pie",schema:t4,supportsEffects:!0});Pe.addSequenceStackTraces(r4);function s4({points:e,radius:n,centerX:r,centerY:s,cornerRadius:o,edgeRoundness:a}){const l=Math.PI*2/e,c=new Array(e).fill(0).map((u,d)=>{const h=l*d-Math.PI/2,p={x:r+n*Math.cos(h),y:s+n*Math.sin(h)};return[p.x,p.y]});return Ql([...c,c[0]],{edgeRoundness:a,cornerRadius:o,roundCornerStrategy:o>0?"bezier":"arc"})}var o4=({points:e,radius:n,cornerRadius:r=0,edgeRoundness:s=null})=>{if(e<3)throw new Error(`"points" should be minimum 3, got ${e}`);const o=2*n,a=2*n,l=o/2,c=a/2,u=s4({points:e,radius:n,centerX:l,centerY:c,cornerRadius:r,edgeRoundness:s}),d=vp(u),h=Yg(hs(d)),p=Gg.getBoundingBoxFromInstructions(d);return{path:h,width:p.width,height:p.height,transformOrigin:`${l} ${c}`,instructions:u}},a4=ea({points:Zt({defaultValue:5,description:"Points",min:3,step:1}),radius:Zt({defaultValue:100,description:"Radius",min:0}),cornerRadius:Zt({defaultValue:0,description:"Corner Radius",min:0})}),i4=({points:e,radius:n,cornerRadius:r,edgeRoundness:s,...o})=>t.jsx(Qo,{defaultName:"<Polygon>",documentationLink:"https://www.remotion.dev/docs/shapes/polygon",...o4({points:e,cornerRadius:r,edgeRoundness:s,radius:n}),...o}),l4=Pe.wrapInSchema({Component:i4,componentIdentity:"dev.remotion.shapes.Polygon",schema:a4,supportsEffects:!0});Pe.addSequenceStackTraces(l4);var c4=({width:e,height:n,edgeRoundness:r=null,cornerRadius:s=0})=>{const o=[e/2,n/2],a=[...Ql([[s,0],[e,0],[e,n],[0,n],[0,0]],{edgeRoundness:r,cornerRadius:s,roundCornerStrategy:"arc"}),{type:"Z"}],l=hs(a);return{width:e,height:n,instructions:a,path:l,transformOrigin:o.join(" ")}},d4=ea({width:Zt({defaultValue:100,description:"Width",min:0}
106),height:Zt({defaultValue:100,description:"Height",min:0}),cornerRadius:Zt({defaultValue:0,description:"Corner Radius",min:0})}),u4=({width:e,edgeRoundness:n,height:r,cornerRadius:s,...o})=>t.jsx(Qo,{defaultName:"<Rect>",documentationLink:"https://www.remotion.dev/docs/shapes/rect",...c4({height:r,width:e,edgeRoundness:n,cornerRadius:s}),...o}),jp=Pe.wrapInSchema({Component:u4,componentIdentity:"dev.remotion.shapes.Rect",schema:d4,supportsEffects:!0});Pe.addSequenceStackTraces(jp);var m4=({centerX:e,centerY:n,points:r,innerRadius:s,outerRadius:o,cornerRadius:a,edgeRoundness:l})=>{const c=Math.PI*2/(r*2),u=new Array(r*2).fill(!0).map((d,h)=>{const p=h%2===0?o:s,b=c*h-Math.PI/2,y={x:e+p*Math.cos(b),y:n+p*Math.sin(b)};return[y.x,y.y]});return[...Ql([...u,u[0]],{edgeRoundness:l,cornerRadius:a,roundCornerStrategy:a>0?"bezier":"arc"}),{type:"Z"}]},p4=({points:e,innerRadius:n,outerRadius:r,cornerRadius:s=0,edgeRoundness:o=null})=>{const a=r*2,l=r*2,c=a/2,u=l/2,d=m4({centerX:c,centerY:u,points:e,innerRadius:n,outerRadius:r,cornerRadius:s,edgeRoundness:o}),h=vp(d),p=Yg(hs(h)),b=Gg.getBoundingBoxFromInstructions(h);return{path:p,width:b.width,height:b.height,transformOrigin:`${c} ${u}`,instructions:d}},f4=ea({points:Zt({defaultValue:5,description:"Points",min:3,step:1}),innerRadius:Zt({defaultValue:50,description:"Inner Radius",min:0}),outerRadius:Zt({defaultValue:100,description:"Outer Radius",min:0}),cornerRadius:Zt({defaultValue:0,description:"Corner Radius",min:0})}),h4=({innerRadius:e,outerRadius:n,points:r,cornerRadius:s,edgeRoundness:o,...a})=>t.jsx(Qo,{defaultName:"<Star>",documentationLink:"https://www.remotion.dev/docs/shapes/star",...p4({innerRadius:e,outerRadius:n,points:r,cornerRadius:s,edgeRoundness:o}),...a}),Jg=Pe.wrapInSchema({Component:h4,componentIdentity:"dev.remotion.shapes.Star",schema:f4,supportsEffects:!0});Pe.addSequenceStackTraces(Jg);var x4=({length:e,direction:n="right",edgeRoundness:r=null,cornerRadius:s=0})=>{if(typeof e!="number")throw new Error(`"length" of a triangle must be a number, got ${JSON.stringify(e)}`);const o=e,a=Math.sqrt(e**2*.75),l={up:[[o/2,0],[0,a],[o,a],[o/2,0]],right:[[0,0],[0,o],[a,o/2],[0,0]],down:[[0,0],[o,0],[o/2,a],[0,0]],left:[[a,0],[a,o],[0,o/2],[a,0]]},c={left:a/3*2,right:a/3,up:o/2,down:o/2}[n],u={up:a/3*2,down:a/3,left:o/2,right:o/2}[n],d=[...Ql(l[n],{edgeRoundness:r,cornerRadius:s,roundCornerStrategy:"bezier"}),{type:"Z"}];return{path:hs(d),instructions:d,width:n==="up"||n==="down"?e:a,height:n==="up"||n==="down"?a:e,transformOrigin:`${c} ${u}`}},g4=ea({length:Zt({defaultValue:100,description:"Length",min:0}),direction:wp({defaultValue:"right",description:"Direction",variants:["right","left","up","down"]}),cornerRadius:Zt({defaultValue:0,description:"Corner Radius",min:0})}),b4=({length:e,direction:n,edgeRoundness:r,cornerRadius:s,...o})=>t.jsx(Qo,{defaultName:"<Triangle>",documentationLink:"https://www.remotion.dev/docs/shapes/triangle",...x4({length:e,direction:n,edgeRoundness:r,cornerRadius:s}),...o}),Zg=Pe.wrapInSchema({Component:b4,componentIdentity:"dev.remotion.shapes.Triangle",schema:g4,supportsEffects:!0});Pe.addSequenceStackTraces(Zg);const y4=.5*(Math.sqrt(3)-1),ll=(3-Math.sqrt(3))/6,vh=e=>Math.floor(e)|0,wh=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]);function v4(e=Math.random){const n=w4(e),r=new Float64Array(n).map(o=>wh[o%12*2]),s=new Float64Array(n).map(o=>wh[o%12*2+1]);return function(a,l){let c=0,u=0,d=0;const h=(a+l)*y4,p=vh(a+h),b=vh(l+h),y=(p+b)*ll,v=p-y,w=b-y,C=a-v,k=l-w;let E,m;C>k?(E=1,m=0):(E=0,m=1);const M=C-E+ll,I=k-m+ll,N=C-1+2*ll,F=k-1+2*ll,R=p&255,A=b&255;let V=.5-C*C-k*k;if(V>=0){const ne=R+n[A],se=r[ne],pe=s[ne];V*=V,c=V*V*(se*C+pe*k)}let z=.5-M*M-I*I;if(z>=0){const ne=R+E+n[A+m],se=r[ne],pe=s[ne];z*=z,u=z*z*(se*M+pe*I)}let H=.5-N*N-F*F;if(H>=0){const ne=R+1+n[A+1],se=r[ne],pe=s[ne];H*=H,d=H*H*(se*N+pe*F)}return 70*(c+u+d)}}function w4(e){const r=new Uint8Array(512);for(let s=0;s<512/2;s++)r[s]=s;for(let s=0;s<512/2-1;s++){const o=s+~~(e()*(256-s)),a=r[s];r[s]=r[o],r[o]=a}for(let s=256;s<512;s++)r[s]=r[s-256];return r}var cl=new Map,j4=e=>{const n=cl.get(e);if(n)return n;cl.size>
10610&&cl.delete(cl.keys().next().value);const r=v4(()=>Oa(e));return cl.set(e,r),r},gu=(e,n,r)=>j4(e)(n,r);const hn=(e,n=0)=>Number.isFinite(Number(e))?Number(e):n,N4=new Set(["w","h","width","height","size","radius","points","opacity","volume","handheld","brightness","contrast","saturate"]),Np=(e,n,r,s=0)=>{const o=hn(Go(e,n,r,s),s);return N4.has(n)?Math.max(0,o):o},Cn=(e,n,r,s)=>Np(n,r,s,Jc(e,r)),Qg=e=>Math.max(0,Math.round(hn(e))),k4=e=>Math.max(1,Math.round(hn(e)||1)),S4=150,kp=e=>Math.max(0,Math.min(S4,Math.round(hn(e==null?void 0:e.transitionIn)))),jh=(e,n,r,s)=>{let o=0;for(const a of e||[]){if(a===n)continue;const l=kp(a);l>0&&Qg(a.fromFrame)===r+s&&(o=Math.max(o,l))}return o},Ld=(e,n,r,s)=>{let o=1;return r>0&&(o=Math.min(o,Gn(e,[0,r],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}))),s>0&&(o=Math.min(o,Gn(e,[Math.max(0,n-s),n],[1,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}))),o},eb=(e,n,r)=>{if(!r||r==="none")return{scale:1,x:0,y:0};const s=n>1?Math.min(1,Math.max(0,e/n)):0,o=To.inOut(To.ease)(s);switch(r){case"in":return{scale:Gn(o,[0,1],[1,1.18]),x:0,y:0};case"out":return{scale:Gn(o,[0,1],[1.18,1]),x:0,y:0};case"left":return{scale:1.16,x:Gn(o,[0,1],[5,-5]),y:0};case"right":return{scale:1.16,x:Gn(o,[0,1],[-5,5]),y:0};case"up":return{scale:1.16,x:0,y:Gn(o,[0,1],[5,-5])};case"down":return{scale:1.16,x:0,y:Gn(o,[0,1],[-5,5])};default:return{scale:1,x:0,y:0}}},C4=(e,n)=>{const r=hn(n);return r?{x:gu("hx",e/22,0)*1.6*r,y:gu("hy",0,e/22)*1.6*r,rot:gu("hr",e/28,9)*.8*r}:{x:0,y:0,rot:0}},tb=(e,n,r)=>{if(!r||r==="none")return{};const o=Gn(e,[0,14],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:To.out(To.cubic)});switch(r){case"fade":return{opacity:o};case"slide":return{tx:Gn(o,[0,1],[100,0]),opacity:Math.min(1,o*1.4)};case"zoom":{const a=Jm({frame:e,fps:n,config:{damping:14,stiffness:120,mass:.7}});return{scale:Gn(a,[0,1],[1.14,1])}}case"wipe":return{clip:o};case"blur":return{blur:Gn(o,[0,1],[20,0]),opacity:o};default:return{}}},E4=qe.memo(({clip:e,muted:n,durationInFrames:r,scale:s=1})=>{var I,N;const o=xs(),{fps:a}=as();let l=Ld(o,r,Math.max(hn(e.fadeIn),kp(e)),hn(e.fadeOut))*(Cn("video",e,"opacity",o)/100);const c=eb(o+hn(e.kbFrom),hn(e.kbTotal)||r,e.kenBurns),u=C4(o,Cn("video",e,"handheld",o)),d=tb(o,a,e.anim);d.opacity!=null&&(l=Math.min(l,d.opacity));let h=(c.scale||1)*(d.scale||1);Ry(e,"handheld",0)>0&&(h=Math.max(h,1.06));const p=(c.x||0)+u.x+(d.tx||0),b=(c.y||0)+u.y,y=d.blur||0,v=Cn("video",e,"brightness",o),w=Cn("video",e,"contrast",o),C=Cn("video",e,"saturate",o),k=[];y&&k.push(`blur(${y*s}px)`),v!==100&&k.push(`brightness(${v}%)`),w!==100&&k.push(`contrast(${w}%)`),C!==100&&k.push(`saturate(${C}%)`);const E=xo().isRendering?Sg:bj,m=t.jsx(E,{src:e.src,startFrom:Math.max(0,Math.round(hn(e.trimStart))),playbackRate:Math.max(.1,hn(e.speed,1)),muted:n??!0,volume:(N=(I=e.keys)==null?void 0:I.volume)!=null&&N.length?F=>Math.max(0,Math.min(1,hn(Go(e,"volume",F,e.volume??1),1))):Math.max(0,Math.min(1,hn(e.volume,1))),style:{width:"100%",height:"100%",objectFit:e.fit||"cover",transform:`translate(${p}%, ${b}%) scale(${h}) rotate(${u.rot}deg)`,filter:k.length?k.join(" "):void 0}});if(e.w!=null||e.x!=null||e.y!=null||e.h!=null||hn(e.radius)>0||["w","h","x","y","radius"].some(F=>Bu(e,F))){const F=Cn("video",e,"w",o),R=Np(e,"h",o,F),A=F>=99&&R>=99;return t.jsx("div",{style:{position:"absolute",left:`${Cn("video",e,"x",o)}%`,top:`${Cn("video",e,"y",o)}%`,width:`${F}%`,height:`${R}%`,transform:"translate(-50%, -50%)",opacity:l,overflow:"hidden",borderRadius:Cn("video",e,"radius",o)*s,boxShadow:A?"none":`0 ${10*s}px ${34*s}px rgba(0,0,0,0.5)`,backgroundColor:e.fit==="contain"?"#000000":void 0,clipPath:d.clip!=null?`inset(0 ${(1-d.clip)*100}% 0 0)`:void 0},children:m})}return t.jsx(pd,{style:{backgroundColor:"#000000",opacity:l,overflow:"hidden",clipPath:d.clip!=null?`inset(0 ${(1-d.clip)*100}% 0 0)`:void 0},children:m})}),M4=qe.memo(({clip:e,durationInFrames:n,scale:r=1})=>{const s=xs(),{fps:o}=as(),a=Math.max(hn(e.fadeIn)||(e.anim&&e.anim!=="none"?6:0),kp(e));let l=Ld(s,n,a,hn(e.fadeOut))*(Cn("image",e,"opacity",s)/100);const c=eb(s+hn(e.kbFrom),hn(e.kbTotal)||n,e.kenBurns),u=tb(s,o,e.anim);u.opacity!=null&&(l=Math.min(l,u.opacity));const d=(c.scale||1)*(u.scale||1),h=(c.x||0)+(u.tx||0),p=c.y||0,b=e.width!=null&&Number.isFinite(Number(e.width))?Number(e.width):null,y=Np(e,"w",s,b??Jc("image","w")),v=e.h!=null;return t.jsx("div",{style:{position:"absolute",left:`${Cn("image",e,"x",s)}%`,top:`${Cn("image",e,"y",s)}%`,width:`${y}%`,height:v?`${hn(e.h)}%`:void 0,transform:`translate(-50%, -50%) translate(${h}%, ${p}%) scale(${d}) rotate(${Cn("image",e,"rotation",s)}deg)`,opacity:l,filter:u.blur?`blur(${u.blur*r}px)`:void 0},children:t.jsx(up,{src:e.src,style:{width:"100%",height:v?"100%":"auto",objectFit:"contain",display:"block",borderRadius:Cn("image",e,"radius",s)*r}})})}),I4={rect:jp,circle:qg,ellipse:Xg,triangle:Zg,star:Jg},F4=qe.memo(({clip:e,durationInFrames:n,scale:r=1})=>{const s=xs(),{width:o,height:a}=as(),l=Ld(s,n,hn(e.fadeIn),hn(e.fadeOut))*(Cn("shape",e,"opacity",s)/100),c=I4[e.shape]||jp,u=Math.max(2,Math.round(Cn("shape",e,"width",s)/100*o)),d=Math.max(2,Math.round(Cn("shape",e,"height",s)/100*a)),h=e.color||"#8b5cf6";let p;return e.shape==="circle"?p={radius:Math.round(Math.min(u,d)/2),fill:h}:e.shape==="ellipse"?p={rx:Math.round(u/2),ry:Math.round(d/2),fill:h}:e.shape==="triangle"?p={length:Math.min(u,d),direction:"up",fill:h}:e.shape==="star"?p={innerRadius:Math.round(Math.min(u,d)/4),outerRadius:Math.round(Math.min(u,d)/2),points:Math.max(3,Math.round(Cn("shape",e,"points",s))),fill:h}:p={width:u,height:d,cornerRadius:Cn("shape",e,"radius",s)*r,fill:h},t.jsx("div",{style:{position:"absolute",left:`${Cn("shape",e,"x",s)}%`,top:`${Cn("shape",e,"y",s)}%`,transform:`translate(-50%, -50%) rotate(${Cn("shape",e,"rotation",s)}deg)`,opacity:l,lineHeight:0},children:t.jsx(c,{...p})})}),R4=qe.memo(({clip:e,durationInFrames:n,scale:r=1})=>{const s=xs(),{fps:o}=as(),a=e.anim||"fade",l=e.fadeIn!=null?Number(e.fadeIn):a==="none"?0:6,c=e.fadeOut!=null?Number(e.fadeOut):0;let u=Ld(s,n,l,c)*(Cn("caption",e,"opacity",s)/100),d=0,h=1;if(a==="pop"){const b=Jm({frame:s,fps:o,config:{damping:12,stiffness:180,mass:.6}});h=Gn(b,[0,1],[.72,1])}else a==="slide"?d=Gn(s,[0,12],[28,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:To.out(To.cubic)}):a==="rise"&&(d=Gn(s,[0,14],[60,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:To.out(To.cubic)}),u=Math.min(u,Gn(s,[0,10],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"})));const p=e.bg&&e.bg!=="transparent";return t.jsx("div",{style:{position:"absolute",left:`${Cn("caption",e,"x",s)}%`,top:`${Cn("caption",e,"y",s)}%`,transform:`translate(-50%, -50%) translateY(${d}px) scale(${h})`,width:"max-content",maxWidth:"86%",textAlign:e.align||"center",fontFamily:e.font||"Inter, Helvetica, Arial, sans-serif",fontSize:Cn("caption",e,"size",s)*r,fontWeight:e.weight||800,fontStyle:e.italic?"italic":"normal",color:e.color||"#ffffff",lineHeight:1.12,whiteSpace:"pre-wrap",o
106pacity:u,textShadow:p?"none":`0 ${2*r}px ${14*r}px rgba(0,0,0,0.65)`,background:p?e.bg:"transparent",padding:p?"0.18em 0.55em":0,borderRadius:p?14*r:0},children:e.text})}),P4=({editDoc:e,previewScale:n=1})=>{const r=e||{},s=Array.isArray(r.tracks)?r.tracks:[],o=Math.max(12,Math.round(hn(r.fps,30)));return t.jsx(pd,{style:{backgroundColor:r.background||"#000000"},children:s.filter(a=>!a.hidden).map(a=>(a.clips||[]).map(l=>{var h,p;const c=Qg(l.fromFrame),u=k4(l.durationInFrames),d=`${a.id||a.type}-${l.id}`;if(a.type==="video"){const b=jh(a.clips,l,c,u);return t.jsx(Ir,{from:c,durationInFrames:u+b,layout:"none",children:t.jsx(E4,{clip:l,muted:a.muted,durationInFrames:u+b,scale:n})},d)}if(a.type==="image"){const b=jh(a.clips,l,c,u);return t.jsx(Ir,{from:c,durationInFrames:u+b,premountFor:o,layout:"none",children:t.jsx(M4,{clip:l,durationInFrames:u+b,scale:n})},d)}if(a.type==="shape")return t.jsx(Ir,{from:c,durationInFrames:u,layout:"none",children:t.jsx(F4,{clip:l,durationInFrames:u,scale:n})},d);if(a.type==="caption")return t.jsx(Ir,{from:c,durationInFrames:u,layout:"none",children:t.jsx(R4,{clip:l,durationInFrames:u,scale:n})},d);if(a.type==="audio"){const b=N=>a.muted?0:Math.max(0,Math.min(1,hn(Go(l,"volume",N,l.volume??1),1))),y=a.muted?0:l.volume??1,v=Math.max(0,Math.round(hn(l.fadeIn))),w=Math.max(0,Math.round(hn(l.fadeOut))),C=!!((p=(h=l.keys)==null?void 0:h.volume)!=null&&p.length),k=v||w||C?N=>{const F=C?b(N):y;let R=F;return v>0&&(R=Math.min(R,F*Gn(N,[0,v],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}))),w>0&&(R=Math.min(R,F*Gn(N,[Math.max(0,u-w),u],[1,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}))),Math.max(0,R)}:y,E=Math.max(.1,hn(l.speed,1)),m=Math.max(1,Math.round(hn(l.loopFrames)/E)),M=!!l.loop&&m>1,I=t.jsx(s5,{src:l.src,playbackRate:E,volume:k,startFrom:M?void 0:Math.max(0,Math.round(hn(l.trimStart))),loopVolumeCurveBehavior:"extend"});return t.jsx(Ir,{from:c,durationInFrames:u,premountFor:o,children:M?t.jsx(Zl,{durationInFrames:m,children:I}):I},d)}return null}))})},T4=i.lazy(()=>c0(()=>import("./PhotoEditor-VOO3sXpD.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),$t="https://api.studioe.ai",Nh={violet:{grad:"from-violet-600/25 to-fuchsia-600/10",ring:"hover:border-violet-400/50",ico:"bg-violet-500/20 text-violet-200",dot:"bg-violet-400"},sky:{grad:"from-sky-600/25 to-cyan-600/10",ring:"hover:border-sky-400/50",ico:"bg-sky-500/20 text-sky-200",dot:"bg-sky-400"},amber:{grad:"from-amber-600/25 to-orange-600/10",ring:"hover:border-amber-400/50",ico:"bg-amber-500/20 text-amber-200",dot:"bg-amber-400"},emerald:{grad:"from-emerald-600/25 to-teal-600/10",ring:"hover:border-emerald-400/50",ico:"bg-emerald-500/20 text-emerald-200",dot:"bg-emerald-400"},rose:{grad:"from-rose-600/25 to-pink-600/10",ring:"hover:border-rose-400/50",ico:"bg-rose-500/20 text-rose-200",dot:"bg-rose-400"},indigo:{grad:"from-indigo-600/25 to-violet-600/10",ring:"hover:border-indigo-400/50",ico:"bg-indigo-500/20 text-indigo-200",dot:"bg-indigo-400"},cyan:{grad:"from-cyan-600/25 to-sky-600/10",ring:"hover:border-cyan-400/50",ico:"bg-cyan-500/20 text-cyan-200",dot:"bg-cyan-400"},fuchsia:{grad:"from-fuchsia-600/25 to-violet-600/10",ring:"hover:border-fuchsia-400/50",ico:"bg-fuchsia-500/20 text-fuchsia-200",dot:"bg-fuchsia-400"},slate:{grad:"from-slate-600/25 to-slate-700/10",ring:"hover:border-slate-400/40",ico:"bg-slate-500/20 text-slate-200",dot:"bg-slate-400"}},nb=[{key:"discover",label:"Discover",icon:Rb,accent:"violet",blurb:"Your studio home, start here"},{key:"ugc-studio",label:"UGC Studio",icon:Ri,accent:"violet",blurb:"Product in â authentic UGC video out"},{key:"static-ads",label:"Static Ads",icon:Rl,accent:"amber",blurb:"20 scroll stopping image ads per product"},{key:"asset-gen",label:"Asset Generator",icon:Ao,accent:"emerald",blurb:"Any image, video or audio model, one place"},{key:"editor",label:"Video Editor",icon:ba,accent:"indigo",blurb:"Layered timeline: scenes, captions, voice"},{key:"image-editor",label:"Photo Editor",icon:Wc,accent:"emerald",blurb:"Layers, masks, vector, adjustments, filters, and PSD"}
106,{key:"adflow",label:"AdFlow",icon:Ko,accent:"fuchsia",blurb:"Wire your own pipeline on a node canvas"}],bu={renders:"/projects?tab=videos","ai-avatar":"/content-studio",avatars:"/content-studio"},A4=Object.fromEntries(nb.map(e=>[e.key,e])),Ml=nb.map(e=>e.key),$4=e=>e&&e!=="discover"&&Ml.includes(e)?`/content-studio/${e}`:"/content-studio",_4=e=>{var r;const n=(r=/^\/content-studio\/([^/]+)\/?$/.exec(String(e||"")))==null?void 0:r[1];return!!n&&n!=="discover"&&Ml.includes(n)},D4=(e,n="")=>{const r=new URLSearchParams(n);e!=="adflow"&&r.delete("w"),r.delete("resume");const s=r.toString();return`${$4(e)}${s?`?${s}`:""}`},si=new Set(["pending","processing"]),kh={standard:{label:"Standard",hint:"5 credits / 30s"},aurora_v1:{label:"Aurora v1",hint:"Most realistic · 1 credit/sec"},aurora_v1_fast:{label:"Aurora v1 Fast",hint:"Faster · 0.5 credit/sec"}};function L4(e){return e==="1x1"?"aspect-square":e==="16x9"?"aspect-video":"aspect-[9/16]"}const yu=5e3,Ei=6,O4=[{value:"Rachel",label:"Rachel, warm (F)"},{value:"Jessica",label:"Jessica, youthful (F)"},{value:"Aria",label:"Aria, expressive (F)"},{value:"Sarah",label:"Sarah, soft (F)"},{value:"Charlotte",label:"Charlotte, natural (F)"},{value:"Will",label:"Will, easygoing (M)"},{value:"Liam",label:"Liam, youthful (M)"},{value:"George",label:"George, warm (M)"},{value:"Brian",label:"Brian, deep (M)"}],rb=Object.freeze({uploadHours:24*7,exportHours:48});function Ja(e){const n=Math.round(Number(e)||0);return n<=0?"":n>=48&&n%24===0?`${n/24} days`:`${n} ${n===1?"hour":"hours"}`}async function La(e,n=""){var s;if(!e||typeof e!="string")return null;if(/^https?:\/\//i.test(e))return e;if(!e.startsWith("data:"))return null;const r=await Jt(`${$t}/api/upload`,{file:e,...n?{purpose:n}:{}});return((s=r==null?void 0:r.upload)==null?void 0:s.secure_url)||null}const ym=e=>new Promise((n,r)=>{const s=new FileReader;s.onload=()=>n(s.result),s.onerror=r,s.readAsDataURL(e)});async function Sh(e,n,r){var a;let s;try{s=await La(await ym(n),"photo-editor")}catch(l){throw(l==null?void 0:l.status)===413?new Error("This image is too large to upload. Crop or resize it, then try again."):l}if(!s)throw new Error("Couldn't upload the image, check your connection and try again.");let o;try{o=await Jt(`${$t}${e}`,{imageUrl:s})}catch(l){throw r==null||r((a=l==null?void 0:l.data)==null?void 0:a.creditBalance),l}if(r==null||r(o==null?void 0:o.creditBalance),!o||o.ok===!1||!o.url)throw new Error((o==null?void 0:o.error)||"That didn't come back with an image.");return o.url}function V4(e){return!e||typeof e!="string"||!/\/upload\//.test(e)||/\/upload\/[^/]*f_mp4/.test(e)||!/\.(mov|m4v|webm|mkv|avi|ogv)(\?|$)/i.test(e)?e:e.replace("/upload/","/upload/f_mp4,vc_h264/").replace(/\.(mov|m4v|webm|mkv|avi|ogv)(\?|$)/i,".mp4$1")}function Od(e,n){return new Promise((r,s)=>{const o=new FileReader;o.onload=()=>r(o.result),o.onerror=()=>s(new Error("Could not read that file.")),n&&(o.onprogress=a=>{a.lengthComputable&&a.total&&n(Math.min(100,Math.round(a.loaded/a.total*100)))}),o.readAsDataURL(e)})}function U4(e){return new Promise(n=>{let r="",s=!1;const o=l=>{s||(s=!0,r&&URL.revokeObjectURL(r),n(Number.isFinite(l)&&l>0?l:0))};try{r=URL.createObjectURL(e)}catch{return o(0)}const a=document.createElement("video");a.preload="metadata",a.muted=!0,a.onloadedmetadata=()=>o(a.duration),a.onerror=()=>o(0),setTimeout(()=>o(a.duration),4e3),a.src=r})}const Ch=e=>{const n=Math.round(Number(e)||0);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`};async function ii(e,n=""){const r=await y0(e,$t,{strict:!0}),s=await v0(r),o=await w0(s);return La(o,n)}const z4=new Set(["video/mp4","video/quicktime","video/webm","video/x-matroska","video/x-m4v"]),Eh=/\.(mp4|mov|webm|mkv|m4v)$/i,Il=35,B4=Il*1024*1024,vc=Il,vu=60;function ad(e){if(!e){const s=new Error("unsupported-file-type");throw s.code="unsupported-file-type",s}const n=e.type?z4.has(e.type):Eh.test(e.name||""),r=Eh.test(e.name||"");if(!(n||r)){const s=new Error("unsupported-video-type");throw s.code="unsupported-video-type",s}if(typeof e.size=="number"&&e.size>B4){const s=new Error("file-too-large");throw s.code="file-too-large",s}return!0}const H4=/\.(mp3|wav|m4a|aac|ogg|oga|flac|webm)$/i,K4=50*1024*1024;function W4(e){if(!e){const r=new Error("unsupported-file-type");throw r.code="unsupported-file-type",r}if(!((e.type||"").startsWith("audio/")||H4.test(e.name||""))){const r=new Error("unsupported-audio-type");throw r.code="unsupported-audio-type",r}if(typeof e.size=="number"&&e.size>K4){const r=new Error("file-too-large");throw r.code="file-too-large",r}return!0}function wl(e,{disabled:n=!1}={}){const r=["ring-2","ring-violet-400/80"];return n?{}:{onDragOver:s=>{var o,a;(a=(o=s.dataTransfer)==null?void 0:o.types)!=null&&a.includes("Files")&&(s.preventDefault(),s.currentTarget.classList.add(...r))},onDragLeave:s=>s.currentTarget.classList.remove(...r),onDrop:s=>{var a;s.preventDefault(),s.currentTarget.classList.remove(...r);const o=(a=s.dataTransfer)==null?void 0:a.files;o&&o.length&&e(o)}}}function Y4(e,{disabled:n=!1}={}){const[r,s]=i.useState(!1);return n?[!1,{}]:[r,{onDragOver:o=>{o.preventDefault(),o.stopPropagation(),r||s(!0)},onDragLeave:o=>{o.preventDefault(),o.stopPropagation(),s(!1)},onDrop:o=>{var l,c;o.preventDefault(),o.stopPropagation(),s(!1);const a=(c=(l=o.dataTransfer)==null?void 0:l.files)==null?void 0:c[0];a&&e(a)}}]}function Tn({className:e="w-5 h-5"}){return t.jsx("span",{className:`inline-block ${e} border-2 border-white/20 border-t-white/80 rounded-full animate-spin`})}function G4({status:e}){const n={completed:{label:"Ready",cls:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},processing:{label:"Rendering",cls:"bg-amber-500/15 text-amber-300 border-amber-500/30"},pending:{label:"Queued",cls:"bg-sky-500/15 text-sky-300 border-sky-500/30"},failed:{label:"Failed",cls:"bg-rose-500/15 text-rose-300 border-rose-500/30"}}
106,r=n[e]||n.pending;return t.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-medium border ${r.cls}`,children:[si.has(e)&&t.jsx(Tn,{className:"w-3 h-3"}),r.label]})}function Fe({label:e,hint:n,children:r,as:s="label"}){return t.jsxs(s,{className:"block",children:[t.jsx("span",{className:"block text-xs font-semibold text-gray-300 mb-1.5",children:e}),r,n&&t.jsx("span",{className:"block text-[11px] text-gray-500 mt-1",children:n})]})}const nr="w-full rounded-xl bg-[#0E1117] border border-white/10 px-3.5 py-2.5 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-violet-500/50 focus:border-violet-500/50 transition";function dr({value:e,onChange:n,options:r}){return t.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(s=>{const o=e===s.value;return t.jsx("button",{type:"button",onClick:()=>n(s.value),className:`px-3 py-1.5 rounded-lg text-xs font-medium border transition ${o?"bg-violet-500/20 border-violet-500/50 text-violet-200":"bg-white/[0.03] border-white/10 text-gray-400 hover:border-white/20 hover:text-gray-200"}`,children:s.label},s.value)})})}function wu({value:e,onChange:n,min:r=0,max:s=1,step:o=.05,format:a}){const l=Number.isFinite(Number(e))?Number(e):r,c=(l-r)/(s-r)*100;return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"range",min:r,max:s,step:o,value:l,onChange:u=>n(Number(u.target.value)),className:"flex-1 h-1.5 appearance-none rounded-full bg-white/10 accent-violet-500 cursor-pointer",style:{background:`linear-gradient(90deg, rgb(139 92 246 / 0.7) ${c}%, rgb(255 255 255 / 0.1) ${c}%)`}}),t.jsx("span",{className:"w-9 shrink-0 text-right text-[11px] font-semibold tabular-nums text-violet-200",children:a?a(l):l.toFixed(2)})]})}function q4({label:e,active:n,onClick:r}){return t.jsx("button",{type:"button",onClick:r,className:`px-3 py-1.5 rounded-lg text-xs font-medium border transition ${n?"bg-violet-500/20 border-violet-500/50 text-violet-100":"bg-white/[0.02] border-white/10 text-gray-400 hover:border-white/25 hover:text-gray-200"}`,children:e})}function Sp({checked:e,onChange:n,label:r}){return t.jsxs("button",{type:"button",role:"switch","aria-checked":!!e,onClick:()=>n(!e),className:"flex items-center gap-2.5 group",children:[t.jsx("span",{className:`relative w-9 h-5 rounded-full transition ${e?"bg-violet-500":"bg-white/15"}`,children:t.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${e?"translate-x-4":""}`})}),t.jsx("span",{className:"text-sm text-gray-300 group-hover:text-gray-100",children:r})]})}function Mh({url:e,onEdit:n}){return t.jsxs("div",{className:"flex items-center justify-center gap-4 text-[12px]",children:[t.jsxs("a",{href:e,download:!0,className:"inline-flex items-center gap-1 min-h-[36px] text-violet-300 hover:text-violet-200",children:[t.jsx(go,{className:"w-3.5 h-3.5"}),"Download"]}),n&&t.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1 min-h-[36px] text-gray-300 hover:text-white",children:[t.jsx(ba,{className:"w-3.5 h-3.5"}),"Edit in Video Editor"]})]})}const vm=e=>{const n=/^(\d+)\s*[x:]\s*(\d+)$/.exec(String(e||""));return n?`${n[1]} / ${n[2]}`:"9 / 16"};function wc({url:e,title:n,poster:r,aspectRatio:s,children:o}){return t.jsxs("div",{"data-ugc-result-video":!0,className:"relative w-full overflow-hidden rounded-xl bg-[#111111]",style:{aspectRatio:vm(s)},children:[t.jsx("div",{className:"absolute inset-0",children:t.jsx(Ib,{url:e,title:n,poster:r})}),o]})}function Vd(e,n=Date.now()){const r=Date.parse(e||"");if(!Number.isFinite(r))return"";const s=Math.floor((n-r)/6e4);if(s<1)return"Just now";if(s<60)return`${s} min ago`;const o=Math.floor(s/60);if(o<24)return`${o} h ago`;const a=Math.floor(o/24);return a<7?`${a} d ago`:new Date(r).toLocaleDateString(void 0,{month:"short",day:"numeric",year:new Date(r).getFullYear()===new Date(n).getFullYear()?void 0:"numeric"})}const Ih=(e,n)=>{const r=document.createElement("a");r.href=e,n&&(r.download=n),r.rel="noopener",document.body.appendChild(r),r.click(),r.remove()};async function ec(e,n="render",r="video"){const s=ud(e);if(!s)return;if(s!==e){Ih(s);return}const o=(String(e).split("?")[0].match(/\.([a-z0-9]{2,4})$/i)||[])[1]||(r==="image"?"png":r==="audio"?"mp3":"mp4"),a=`${String(n||"render").replace(/[^\w\s.-]+/g,"").trim().replace(/\s+/g,"-").slice(0,60)||"render"}.${o}`;try{const l=await fetch(e,{mode:"cors"});if(!l.ok)throw new Error(String(l.status));const c=URL.createObjectURL(await l.blob());Ih(c,a),setTimeout(()=>URL.revokeObjectURL(c),6e4)}catch{window.open(e,"_blank","noopener")}}function X4(e,n="400px"){const[r,s]=i.useState(()=>typeof IntersectionObserver>"u");return i.useEffect(()=>{if(r)return;const o=e.current;if(!o)return;const a=new IntersectionObserver(l=>
106{l.some(c=>c.isIntersecting)&&(s(!0),a.disconnect())},{rootMargin:n});return a.observe(o),()=>a.disconnect()},[r,n,e]),r}function J4({job:e}){const n=i.useRef(null),r=X4(n),s=e.thumbnailUrl||Pm(e.resultUrl)||void 0;return t.jsx("div",{ref:n,className:"absolute inset-0 bg-black",children:r?t.jsx("video",{"data-render-video":!0,src:s?e.resultUrl:`${e.resultUrl}#t=0.1`,poster:s,preload:s?"none":"metadata",controls:!0,playsInline:!0,className:"w-full h-full object-contain bg-black"}):t.jsx("div",{className:"w-full h-full grid place-items-center",children:t.jsx(Js,{className:"w-7 h-7 text-gray-700"})})})}function Z4({run:e,onClose:n,onReuse:r,onOpenActions:s}){return i.useEffect(()=>{if(!e)return;const o=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,n]),e?Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[90] flex items-center justify-center bg-black/60 backdrop-blur-sm p-3 sm:p-6",onMouseDown:n,children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Generation",onMouseDown:o=>o.stopPropagation(),className:"modal-pop-in w-full sm:max-w-5xl max-h-[88vh] overflow-y-auto rounded-xl border border-[#27272A] bg-[#16181a] shadow-2xl",children:[t.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-3 px-4 sm:px-5 py-3 border-b border-white/10 bg-[#16181a]/95 backdrop-blur",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-white truncate",children:e.modelLabel||"Generation"}),t.jsx("p",{className:"text-[11px] text-gray-500",children:Vd(e.createdAt)})]}),e.modelName&&t.jsxs("button",{type:"button",onClick:()=>r(e),className:"inline-flex items-center gap-1.5 h-9 px-4 rounded-full bg-white text-xs font-semibold text-black hover:bg-white/90 transition",children:[t.jsx(fo,{className:"w-3.5 h-3.5"}),"Reuse settings"]}),t.jsx("button",{type:"button","aria-label":"Close",onClick:n,className:"w-9 h-9 grid place-items-center rounded-full text-gray-400 hover:text-white hover:bg-white/[0.06] transition",children:t.jsx(ft,{className:"w-4 h-4"})})]}),t.jsx("div",{className:"p-3 sm:p-5",children:t.jsx(Q4,{run:e,onOpenActions:s})})]})}),document.body):null}function Q4({run:e,onOpenActions:n}){var s;if(!e)return null;const r=(s=e.outputs)!=null&&s.length?e.outputs:[{id:e.id,status:e.status,mediaType:e.mediaType,resultUrl:null,title:e.modelLabel}];return t.jsxs("div",{"data-asset-run":e.id,className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 sm:p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold text-white",children:"Results"}),t.jsx("p",{className:"text-xs text-gray-400 line-clamp-2",children:e.prompt||e.modelLabel})]}),t.jsx("span",{className:"text-[11px] text-gray-500 shrink-0",children:Vd(e.createdAt)})]}),!e.inputs&&t.jsx("p",{className:"mb-3 text-[11px] text-gray-500",children:"This run is from before settings were kept, so its model is back with its defaults."}),e.returned>0&&t.jsxs("p",{"data-asset-returned":!0,className:"mb-3 text-[11px] text-emerald-300/90",children:["It came out shorter or with fewer results than paid for, so"," ",e.returned," unused credit",e.returned===1?" was":"s were"," ","given back."]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3",children:r.map(o=>t.jsx(ek,{job:{...o,kind:"asset_generator",createdAt:e.createdAt,refunded:!!e.refunded,error:e.error||(e.status==="failed"?"This run didn't finish.":null)},onOpenActions:n},o.id))})]})}const jc=e=>!!e&&e.kind==="ugc"&&e.source!=="adflow";function ek({job:e,onOpenActions:n,onDelete:r}){const s=e.mediaType==="audio",o=e.mediaType==="image",a=si.has(e.status),l=e.status==="completed"&&!!e.resultUrl,c=Vd(e.createdAt);return t.jsxs("div",{"data-render-card":e.id,className:"rounded-2xl border border-white/10 bg-white/[0.02] overflow-hidden flex flex-col",children:[t.jsx("div",{className:`relative bg-[#0E1117] ${s?"aspect-[16/6]":L4(e.aspectRatio||"9x16")} grid place-items-center`,children:l?s?t.jsxs("div",{className:"w-full px-4",children:[t.jsx(Fl,{className:"w-7 h-7 text-violet-300 mx-auto mb-3"}),t.jsx("audio",{src:e.resultUrl,preload:"none",controls:!0,className:"w-full"})]}):o?t.jsx("img",{src:e.resultUrl,alt:e.title||"Image",loading:"lazy",className:"absolute inset-0 w-full h-full object-contain bg-black"}):t.jsx(J4,{job:e}):e.status==="failed"?t.jsxs("div",{className:"text-center px-4",children:[t.jsx(Xs,{className:"w-7 h-7 text-rose-400 mx-auto mb-2"}),t.jsx("p",{className:"text-xs text-rose-300 line-clamp-4 break-words",title:e.error||void 0,children:e.error||"This couldn't be generated."}),e.refunded&&!/credit/i.test(e.error||"")&&t.jsx("p",{"data-render-refunded":!0,className:"mt-1.5 text-[11px] text-gray-400",children:"Your credits were given back."})]}):a?t.jsxs("div",{className:"text-center px-4",children:[t.jsx(Tn,{className:"w-8 h-8 mx-auto mb-2"}),t.jsx("p",{className:"text-xs text-gray-400",children:e.kind==="asset_generator"?"Generatingâ¦":"Renderingâ¦"})]}):t.jsxs("div",{className:"text-center px-4",children:[t.jsx(Js,{className:"w-7 h-7 text-gray-600 mx-auto mb-2"}),t.jsx("p",{className:"text-xs text-gray-500",children:"No file to show"})]})}),t.jsxs("div",{className:"p-3 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-100 truncate",children:e.title||"Render"}),t.jsx(G4,{status:e.status})]}),e.text&&t.jsx("p",{className:"text-xs text-gray-500 line-clamp-2",children:e.text}),(e.avatarName||e.modelVersion||e.visualStyle||e.creditsUsed!=null)&&t.jsxs("p",{className:"text-[11px] text-gray-500 truncate",children:[e.avatarName?`${e.avatarName} · `:"",e.modelVersion&&kh[e.modelVersion]?kh[e.modelVersion].label:e.visualStyle||"",e.creditsUsed!=null?` · ${e.creditsUsed} cr`:""]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-gray-500",children:[t.jsxs("span",{className:"truncate",title:e.createdAt?new Date(e.createdAt).toLocaleStr
106ing():void 0,children:[c,e.durationSeconds?`${c?" · ":""}${Math.round(e.durationSeconds)}s`:""]}),l&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(e),className:"inline-flex items-center gap-1 p-2 -m-2 sm:p-0 sm:m-0 text-gray-400 hover:text-white",title:s?"Open":o?"Edit in Photo Editor, export or share":"Edit in Video Editor, export or share","aria-label":s?"Open":"Edit",children:[t.jsx(qs,{className:"w-4 h-4"}),!s&&t.jsx("span",{className:"text-[11px] font-medium",children:"Edit"})]}),t.jsx("button",{type:"button",onClick:()=>ec(e.resultUrl,e.title,e.mediaType),className:"p-2 -m-2 sm:p-0 sm:m-0 text-gray-400 hover:text-white",title:"Download","aria-label":"Download",children:t.jsx(go,{className:"w-4 h-4"})})]}),!l&&!a&&r&&t.jsxs("button",{type:"button",onClick:()=>r(e),className:"shrink-0 inline-flex items-center gap-1 p-2 -m-2 sm:p-0 sm:m-0 text-gray-400 hover:text-rose-300",title:"Remove",children:[t.jsx(ss,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"text-[11px] font-medium",children:"Remove"})]})]})]})]})}function tk({job:e,onClose:n,onEditInEditor:r,onEditInPhotoEditor:s,onDelete:o}){const[a,l]=i.useState(!1);if(!e)return null;const c=e.resultUrl||"",u=e.mediaType==="video"&&!!c,d=e.mediaType==="audio"&&!!c,h=async()=>{try{await navigator.clipboard.writeText(c),l(!0),setTimeout(()=>l(!1),1500)}catch{}};return Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[95] grid place-items-center bg-black/60 backdrop-blur-sm p-4",onMouseDown:n,children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-xl border border-[#27272A] bg-[#16181a] shadow-2xl overflow-hidden",onMouseDown:p=>p.stopPropagation(),children:[t.jsxs("div",{className:"relative bg-black",children:[u?t.jsx("video",{src:c,controls:!0,playsInline:!0,className:"w-full max-h-[52vh] object-contain bg-black"}):d?t.jsx("div",{className:"p-6",children:t.jsx("audio",{src:c,controls:!0,className:"w-full"})}):t.jsx("img",{src:c,alt:e.title||"Render",className:"w-full max-h-[52vh] object-contain bg-black"}),t.jsx("button",{type:"button",onClick:n,title:"Close",className:"absolute top-2 right-2 w-8 h-8 grid place-items-center rounded-full bg-black/60 text-white/80 hover:bg-black/80 hover:text-white transition",children:t.jsx(ft,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold text-white truncate",children:e.title||"Render"}),t.jsxs("p",{className:"text-[11px] text-gray-500 capitalize",children:[e.mediaType||"video",e.durationSeconds?" · "+Math.round(e.durationSeconds)+"s":""]})]}),t.jsxs("div",{className:"grid gap-2",children:[u&&t.jsxs("button",{type:"button",onClick:()=>r(e),className:"inline-flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-xl bg-gradient-to-r from-violet-500 to-fuchsia-500 text-white text-sm font-semibold hover:from-violet-400 hover:to-fuchsia-400 transition",children:[t.jsx(ba,{className:"w-4 h-4"})," Edit in Video Editor"]}),u&&t.jsx("p",{className:"-mt-0.5 text-center text-[11px] text-gray-500",children:"Add captions, voice and more. Your original stays as it is."}),!u&&!d&&!!c&&t.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(e),className:"inline-flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-xl bg-gradient-to-r from-violet-500 to-fuchsia-500 text-white text-sm font-semibold hover:from-violet-400 hover:to-fuchsia-400 transition",children:[t.jsx(qs,{className:"w-4 h-4"})," Edit in Photo Editor"]}),!u&&!d&&!!c&&t.jsx("p",{className:"-mt-0.5 text-center text-[11px] text-gray-500",children:"Adjust, retouch and add layers. Your original stays as it is."}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>ec(c,e.title,e.mediaType),className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:bg-white/[0.09] hover:border-white/20 transition",children:[t.jsx(go,{className:"w-4 h-4"})," Export"]}),t.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:bg-white/[0.09] hover:border-white/20 transition",children:[t.jsx(m0,{className:"w-4 h-4"})," ",a?"Copied":"Copy link"]})]}),o&&t.jsxs("button",{type:"button",onClick:()=>o(e),className:"inline-flex items-center justify-center gap-2 w-full px-4 py-2 rounded-xl text-rose-300 hover:text-rose-200 hover:bg-rose-500/10 text-sm font-medium transition",children:[t.jsx(ss,{className:"w-4 h-4"})," Delete render"]})]})]})]})}),document.body)}function Wo(e=""){return String(e).replace(/[_\-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase()).trim()}function Aa(e){const n=(e==null?void 0:e.properties)||{},r=s=>{const o=n[s]||{};return(!o.type||o.type==="string")&&!Array.isArray(o.enum)&&!/negative/i.test(s)&&o.format!=="uri"&&o.format!=="url"&&!/(^|_)urls?$/i.test(s)&&!li(s,o)&&!Bd(s,o)&&!ci(s,o)};return Object.keys(n).find(s=>/^(prompt|text|description|input_text)$/i.test(s)&&r(s))||Object.keys(n).find(s=>r(s)&&db(s,n[s]))||null}function Ud(e){const n=(e==null?void 0:e.properties)||{},r=Array.isArray(e==null?void 0:e["x-fal-order-properties"])?e["x-fal-order-properties"].filter(s=>n[s]):[];return[...new Set([...r,...Object.keys(n)])]}const sb=/(^|_)(end|last|tail|final|mid|middle)(_|$)/i;function wm(e){const n=(e==null?void 0:e.properties)||{},r=Array.isArray(e==null?void 0:e.required)?e.required:[],s=a=>{var l;return n[a]&&!/mask/i.test(a)&&li(a,n[a])&&((l=n[a])==null?void 0:l.type)!=="array"},o=a=>s(a)&&!sb.test(a);return r.find(o)||Ud(e).find(o)||r.find(s)||null}function jm(e){const n=(e==null?void 0:e.properties)||{},r=Array.isArray(e==null?void 0:e.required)?e.required:[],s=a=>n[a]&&!/mask/i.test(a)&&Cp(a,n[a]),o=a=>s(a)&&!sb.test(a);return r.find(o)||Ud(e).find(o)||r.find(s)||null}function nk(e){var r,s;const n=D0(e);return n&&!Array.isArray((s=(r=e==null?void 0:e.properties)==null?void 0:r[n])==null?void 0:s.enum)?n:null}function rk(e){const n=(e==null?void 0:e.properties)||{},r=a=>/duration|length/i.test(a)&&!/sequence|token|prompt|_ms$|millisecond/i.test(a),s=a=>/^(duration|duration_seconds|seconds|seconds_total|total_seconds|length|video_length|video_duration|audio_length|audio_duration|music_duration)$/i.test(a),o=a=>((a==null?void 0:a.type)==="integer"||(a==null?void 0:a.type)==="number")&&Number.isFinite(a.minimum)&&Number.isFinite(a.maximum)&&a.maximum>a.minimum&&a.maximum-a.minimum<=60&&!/millisecond|frames/i.test(`${a.title||""} ${a.description||""}`);return Object.keys(n).find(a=>{var l;
106return Array.isArray((l=n[a])==null?void 0:l.enum)&&r(a)})||Object.keys(n).find(a=>s(a)&&o(n[a]))||null}function Fh(e){var w;const n=(e==null?void 0:e.properties)||{},r=Array.isArray(e==null?void 0:e.required)?e.required:[],s=["aspect_ratio","aspect","ratio"].find(C=>{var k;return Array.isArray((k=n[C])==null?void 0:k.enum)})||null,o=Aa(e),a=wm(e),l=jm(e),c=nk(e),u=rk(e),d=s||!o?null:Object.keys(n).find(C=>{var k,E;return((E=(k=Mp(C,n[C]))==null?void 0:k.presets)==null?void 0:E.length)>0})||null,h=o?r.filter(C=>C!==a&&n[C]&&n[C].type!=="array"&&li(C,n[C])).slice(0,2):[],p=o?r.filter(C=>n[C]&&n[C].type!=="array"&&(ci(C,n[C])||Bd(C,n[C]))).slice(0,2):[],b=!!u&&Array.isArray((w=n[u])==null?void 0:w.enum),y=u&&(b||o)?u:null,v=[o,a,l,...h,...p,s,c,b?u:null].filter(Boolean);return{aspectKey:s,sizeKey:d,promptKey:o,imageKey:a,imageArrayKey:l,countKey:c,durationKey:y,extraImageKeys:h,mediaKeys:p,quickKeys:v}}function sk(e={}){if(Array.isArray(e.enum))return e.enum;const n=Math.ceil(e.minimum),r=Math.floor(e.maximum);if(!(r>=n))return[];const s=Math.max(1,Math.ceil((r-n)/15)),o=[];for(let l=n;l<=r;l+=s)o.push(l);o[o.length-1]!==r&&o.push(r);const a=Number(e.default);return Number.isFinite(a)&&a>=e.minimum&&a<=e.maximum&&!o.includes(a)&&o.push(a),o.sort((l,c)=>l-c)}function Nc(e){const n=String(e||"");if(/^square/.test(n))return"1:1";const r=n.match(/^(portrait|landscape)_(\d+)_(\d+)$/);return r?r[1]==="landscape"?`${r[2]}:${r[3]}`:`${r[3]}:${r[2]}`:null}function Rh(e,n){const r=ob(e,null,null),s=(e==null?void 0:e.properties)||{};if(n&&typeof n=="object"&&!Array.isArray(n))for(const[o,a]of Object.entries(n))s[o]&&(r[o]=a);return r}function ob(e,n,r){var C;const s=(e==null?void 0:e.properties)||{},o=new Set(Array.isArray(e==null?void 0:e.required)?e.required:[]),a=k=>{var E;return k==="sync_mode"&&((E=s[k])==null?void 0:E.type)==="boolean"},l={};for(const[k,E]of Object.entries(s)){if(a(k))continue;const m=(E==null?void 0:E.type)==="number"||(E==null?void 0:E.type)==="integer",M=(E==null?void 0:E.type)==="boolean"||m||Array.isArray(E==null?void 0:E.enum);if(E&&Object.prototype.hasOwnProperty.call(E,"default"))l[k]=E.default;else if((E==null?void 0:E.type)==="boolean")o.has(k)&&(l[k]=!1);else if(Array.isArray(E==null?void 0:E.enum)&&E.enum.length&&o.has(k))l[k]=E.enum[0];else if(m&&o.has(k)&&Number.isFinite(E==null?void 0:E.minimum)){const I=Array.isArray(E.examples)?Number(E.examples[0]):NaN,N=Number.isFinite(I)&&I>=E.minimum&&(!Number.isFinite(E.maximum)||I<=E.maximum);l[k]=N?I:E.minimum}else M||(l[k]="")}if(!r||typeof r!="object")return l;const c=Aa(n),u=Aa(e),d=c?r[c]:void 0;if(u&&typeof d=="string"&&d.trim()){const k=(C=s[u])==null?void 0:C.maxLength;l[u]=k?d.slice(0,k):d}const h=wm(n),p=jm(n),b=[...h&&typeof r[h]=="string"&&r[h]?[r[h]]:[],...p&&Array.isArray(r[p])?r[p].filter(k=>typeof k=="string"&&k):[]],y=wm(e),v=jm(e),w=(k,E)=>{var M;const m=(M=s[k])==null?void 0:M.maxItems;return Number.isFinite(m)&&m>0?E.slice(0,m):E};b.length&&(y&&(!v||y===h||o.has(y)&&!o.has(v))?l[y]=b[0]:v&&(l[v]=w(v,b)));for(const[k,E]of Object.entries(s)){if(k===u||k===y||k===v||a(k))continue;const m=r[k];if(m==null||m==="")continue;const M=li(k,E)||Bd(k,E)||ci(k,E);M&&typeof m=="string"?l[k]=m:M&&Array.isArray(m)?l[k]=w(k,m):(Array.isArray(E==null?void 0:E.enum)&&E.enum.includes(m)&&/aspect|ratio|image_size|resolution/i.test(k)||(E==null?void 0:E.type)==="string"&&!Array.isArray(E==null?void 0:E.enum)&&typeof m=="string"&&/negative/i.test(k))&&(l[k]=m)}return l}function ju(e=""){if(e==="tts")return"Text to speech";if(e==="music")return"Text to music";const n=String(e).toLowerCase().trim().replace(/-/g,"_"),r={text_to_video:"Text to video",image_to_video:"Image to video",video_to_video:"Video to video",text_to_image:"Text to image",image_to_image:"Image to image",text_to_music:"Text to music",text_to_audio:"Text to audio",text_to_speech:"Text to speech",text_to_sound:"Text to sound",audio_to_audio:"Audio to audio"};if(r[n])return r[n];if(!n)return"Model";const s=n.replace(/_/g," ").replace(/\bto\b/g,"to");return s.charAt(0).toUpperCase()+s.slice(1)}const Ph=[{id:"fal-ai/lyria2",name:"Lyria 2",desc:"Google's high fidelity text to music. ~30s, rich and polished.",duration:!1},{id:"cassetteai/music-generator",name:"CassetteAI",desc:"Fast text to music with a custom length (10 to 180s).",duration:!0,min:10,max:180,default:30}],Nu=[{id:"fal-ai/elevenlabs/sound-effects/v2",name:"ElevenLabs SFX V2"},{id:"cassetteai/sound-effects-generator",name:"CassetteAI SFX"}],Mi={image:["text-to-image","image-to-image"],video:["text-to-vi
106deo","image-to-video","video-to-video"],audio:["text-to-speech","text-to-music","text-to-audio","audio-to-audio"]},Th={image:["A cream linen shirt on a sunlit balcony, editorial fashion photo","Flat lay of a denim jacket on warm beige paper, soft shadows","Close up of a chunky knit sweater, moody studio light"],video:["A model in a camel coat walking through Paris at dusk, slow push in","A silk scarf rippling in the wind at golden hour, slow motion"],"text-to-speech":["Meet our new spring collection: soft linen, made to breathe.","Free shipping on every order, this weekend only."],"text-to-music":["Upbeat lo fi beat for a fashion reel","Warm acoustic guitar for a slow product video"],"text-to-audio":["Fabric rustling and a zipper closing","Footsteps on a wooden runway, soft applause"]};function ok(e,n){return Th[n]||(e==="audio"?[]:Th[e])||[]}const ak={"text-to-music":{category:"text-to-audio",q:"music"}};function Uc(e=""){const n=e.toLowerCase();return/openai|gpt|sora|dall/.test(n)?"OpenAI":/imagen|nano-banana|gemini|lyria|veo/.test(n)?"Google":/seedance|seedream|bytedance/.test(n)?"ByteDance":/kling/.test(n)?"Kuaishou":/flux|black-forest|bfl/.test(n)?"Black Forest Labs":/recraft/.test(n)?"Recraft":/ideogram/.test(n)?"Ideogram":/wan|qwen|alibaba/.test(n)?"Alibaba":/minimax|hailuo/.test(n)?"MiniMax":/luma|ray/.test(n)?"Luma":/elevenlabs/.test(n)?"ElevenLabs":/stable-?audio|stability|stable-?diffusion|\bsd[0-9]/.test(n)?"Stability AI":/runway/.test(n)?"Runway":/pika/.test(n)?"Pika":/ltx|lightricks/.test(n)?"Lightricks":/cassette/.test(n)?"CassetteAI":/topaz/.test(n)?"Topaz":/mystic|magnific/.test(n)?"Magnific":"AI"}const ab=[{key:"high-res",label:"High-res",re:/(ultra|high.?res|\b4k\b|\b2k\b|upscal|resolution|\bpro\b|\bmax\b)/i},{key:"photorealism",label:"Photorealism",re:/(photo|realis|\breal\b)/i},{key:"character",label:"Character consistency",re:/(kontext|character|consist|\bedit\b|identity|\bface)/i},{key:"graphic",label:"Graphic design",re:/(recraft|design|vector|svg|logo|typograph|brand)/i},{key:"illustration",label:"Illustration",re:/(illustration|anime|cartoon|\bart\b|drawing|sketch)/i},{key:"fast",label:"Fast",re:/(schnell|\bfast\b|\blite\b|turbo|flash|\bquick|distill)/i},{key:"cinematic",label:"Cinematic",re:/(cinema|\bfilm\b|movie|dramatic)/i},{key:"ads",label:"Ads",re:/(\bad\b|\bads\b|product|commercial|marketing)/i}];function ik(e,n){const r=ab.find(s=>s.key===n);return r?r.re.test(`${e.name} ${e.id} ${e.description} ${(e.tags||[]).join(" ")}`):!0}const ib="studioe:falModelRecents";function lb(){try{return JSON.parse(localStorage.getItem(ib)||"[]")}catch{return[]}}function lk(e){try{const n=lb().filter(r=>r!==e);n.unshift(e),localStorage.setItem(ib,JSON.stringify(n.slice(0,40)))}catch{}}function ck({open:e,models:n,value:r,onSelect:s,onClose:o}){const[a,l]=i.useState(""),[c,u]=i.useState("all"),[d,h]=i.useState("all"),[p,b]=i.useState("default");if(i.useEffect(()=>{e&&(l(""),u("all"),h("all"),b("default"))},[e]),!e)return null;const y=lb(),v=Array.from(new Set(n.map(k=>Uc(k.id)))).sort(),w=a.toLowerCase().trim();let C=n.filter(k=>!(w&&!`${k.name} ${k.id} ${k.description}`.toLowerCase().includes(w)||c!=="all"&&Uc(k.id)!==c||d!=="all"&&!ik(k,d)));return p==="alpha"?C=[...C].sort((k,E)=>k.name.localeCompare(E.name)):p==="newest"?C=[...C].sort((k,E)=>String(E.updatedAt||"").localeCompare(String(k.updatedAt||""))):p==="lastused"&&(C=[...C].sort((k,E)=>{const m=y.indexOf(k.id),M=y.indexOf(E.id);return(m<0?1e9:m)-(M<0?1e9:M)})),Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[130] grid place-items-center p-4 bg-black/60 backdrop-blur-sm",onMouseDown:o,children:t.jsxs("div",{className:"modal-pop-in w-full max-w-4xl h-[82vh] flex flex-col rounded-xl border border-[#27272A] bg-[#16181a] shadow-2xl",onMouseDown:k=>k.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-white/10 flex-wrap",children:[t.jsxs("h3",{className:"text-base font-semibold text-white mr-1",children:["All models"," ",t.jsxs("span",{className:"text-gray-500 text-sm",children:["(",n.length,")"]})]}),t.jsx("div",{className:"flex-1 min-w-[8px]"}),t.jsx("div",{className:"w-40",children:t.jsx(Sn,{options:[{value:"all",label:"All providers"},...v.map(k=>({value:k,label:k}))],selectedValue:c,onSelect:u})}),t.jsx("div",{className:"w-44",children:t.jsx(Sn,{options:[{value:"all",label:"Best for: any"},...ab.map(k=>({value:k.key,label:k.label}))],selectedValue:d,onSelect:h})}),t.jsx("div",{className:"w-36",children:t.jsx(Sn,{options:[{value:"default",label:"Default"},{value:"newest",label:"Newest"},{value:"alpha",label:"A â Z"},{value:"lastused",label:"Last used"}],selectedValue:p,onSelect:b})}),t.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-white/[0.04] border border-white/10 w-44",children:[t.jsx(zl,{className:"w-3.5 h-3.5 text-gray-500"}),t.jsx("input",{autoFocus:!0,value:a,onChange:k=>l(k.target.value),placeholder:"Search",className:"flex-1 bg-transparent outline-none text-sm text-gray-200 placeholder:text-gray-500 min-w-0"})]}),t.jsx("button",{type:"button",onClick:o,className:"w-8 h-8 grid place-items-center rounded-lg text-gray-400 hover:text-white hover:bg-white/5",children:t.jsx(ft,{className:"w-4.5 h-4.5"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:C.length?C.map(k=>t.jsxs("button",{type:"button",onClick:()=>{s(k.id),o()},className:`w-full flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg hover:bg-white/5 text-left ${k.id===r?"bg-violet-500/10":""}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-100 truncate",children:k.name}),(k.tags||[]).slice(0,2).map(E=>t.jsx("span",{className:"text-[9px] uppercase tracking-wide text-violet-300/80 shrink-0",children:E},E))]}),t.jsx("div",{className:"text-[11px] text-gray-500 line-clamp-1",children:k.description||k.id})]}),t.jsx("span",{className:"text-[10px] text-gray-500 shrink-0",children:Uc(k.id)})]},k.id)):t.jsx("div",{className:"py-16 text-center text-sm text-gray-500",children:"No models match those filters."})})]})}),document.body)}function Nm({models:e,value:n,onSelect:r,loading:s,failed:o=!1,onRetry:a,variant:l="field"}){const c=l==="chip",[u,d]=i.useState(!1),[h,p]=i.useState(!1),[b,y]=i.useState(""),v=e.find(E=>E.id===n),w=b.toLowerCase().trim(),C=E=>{r(E),lk(E)},k=w?e.filter(E=>`${E.name} ${E.id} ${E.description}`.toLowerCase().includes(w)):e.slice(0,8);return t.jsxs("div",{className:c?"relative min-w-0 max-sm:flex-1 max-sm:basis-[88px]":"relative",children:[t.jsxs("button",{type:"button",onClick:()=>o&&a&&!s?a():d(E=>
106!E),className:c?`inline-flex w-full sm:w-auto sm:max-w-[260px] items-center gap-2 h-8 sm:h-9 pl-1 sm:pl-1.5 pr-3 rounded-full border text-[12px] sm:text-[13px] font-medium transition ${u?"bg-white/[0.12] border-white/25 text-white":"bg-white/[0.06] border-white/10 text-gray-100 hover:bg-white/[0.1] hover:border-white/20"}`:"w-full flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-white/[0.04] border border-white/10 text-sm text-gray-200 hover:border-white/25 transition",children:[c&&t.jsx("span",{className:"w-6 h-6 shrink-0 rounded-full grid place-items-center bg-gradient-to-br from-violet-500 to-fuchsia-500",children:t.jsx(Ao,{className:"w-3.5 h-3.5 text-white"})}),t.jsx("span",{className:"truncate text-left",children:s?"Loading modelsâ¦":o&&!e.length?"Couldn't load the models. Try again":v?v.name:e.length?`Pick a model (${e.length})`:"No models"}),t.jsx(Al,{className:`w-4 h-4 shrink-0 text-gray-400 transition-transform ${c&&u?"rotate-180":""} ${c?"max-sm:hidden":""}`})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-20",onClick:()=>d(!1)}),t.jsxs("div",{className:c?"z-30 rounded-2xl border border-white/10 bg-[#0E1117] shadow-[0_24px_60px_-12px_rgba(0,0,0,0.85)] overflow-hidden max-sm:fixed max-sm:inset-x-3 max-sm:top-20 sm:absolute sm:bottom-full sm:left-0 sm:mb-2 sm:w-[400px]":"absolute z-30 mt-1 w-full rounded-xl border border-white/10 bg-[#0E1117] shadow-2xl overflow-hidden",children:[t.jsx("div",{className:"p-2 border-b border-white/5",children:t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-white/[0.04]",children:[t.jsx(zl,{className:"w-3.5 h-3.5 text-gray-500"}),t.jsx("input",{autoFocus:!0,value:b,onChange:E=>y(E.target.value),placeholder:`Search ${e.length} modelsâ¦`,className:"flex-1 bg-transparent outline-none text-sm text-gray-200 placeholder:text-gray-500"})]})}),t.jsxs("div",{className:`${c?"max-h-[min(52vh,400px)] p-1.5":"max-h-72 py-1"} overflow-y-auto`,children:[!w&&k.length>0&&t.jsx("div",{className:"px-3 pt-1 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:c?"Featured models":"Recommended"}),k.length===0?t.jsxs("div",{className:"px-3 py-4 text-center text-xs text-gray-500",children:["No models match â",b,"â."]}):k.slice(0,50).map(E=>t.jsxs("button",{type:"button",onClick:()=>{C(E.id),d(!1),y("")},title:E.description?`${E.id} 107 108${E.description}`:E.id,className:c?`w-full flex items-center gap-3 text-left px-2.5 py-2 rounded-xl transition ${E.id===n?"bg-white/[0.07]":"hover:bg-white/[0.05]"}`:`w-full text-left px-3 py-2 hover:bg-white/5 ${E.id===n?"bg-violet-500/10":""}`,children:[c&&t.jsx("span",{className:"w-9 h-9 shrink-0 rounded-xl grid place-items-center bg-white/[0.06] border border-white/10 text-[13px] font-semibold text-gray-200",children:Uc(E.id).charAt(0)}),t.jsxs("div",{className:c?"min-w-0 flex-1":"",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm text-gray-100 truncate",children:E.name}),Array.isArray(E.tags)&&E.tags[0]&&t.jsx("span",{className:"text-[9px] uppercase tracking-wide text-violet-300/80 shrink-0",children:E.tags[0]})]}),E.description?t.jsx("div",{className:"text-[10px] text-gray-500 line-clamp-2",children:E.description}):t.jsx("div",{className:"text-[10px] text-gray-500 truncate",children:E.id})]}),c&&E.id===n&&t.jsx(ga,{className:"w-4 h-4 shrink-0 text-violet-300"})]},E.id))]}),t.jsxs("button",{type:"button",onClick:()=>{d(!1),p(!0)},className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 border-t border-white/10 text-[12px] font-medium text-violet-300 hover:bg-white/5",children:[t.jsx(Rl,{className:"w-3.5 h-3.5"})," View all models (",e.length,")"]})]})]}),t.jsx(ck,{open:h,models:e,value:n,onSelect:C,onClose:()=>p(!1)})]})}function kc({ratio:e,className:n="text-[10px] text-gray-400"}){const r=String(e).match(/(\d+)\s*[:xÃ/]\s*(\d+)/),s=r?Number(r[1]):1,o=r?Number(r[2]):1,a=16,l=s>=o?a:Math.round(a*s/o),c=o>=s?a:Math.round(a*o/s);return t.jsxs("span",{className:`inline-flex items-center gap-1 ${n}`,title:String(e),children:[t.jsx("span",{className:"inline-block rounded-[2px] border border-gray-500",style:{width:l,height:c}}),String(e).replace("x",":")]})}const Ah=/(image|photo|picture|logo|avatar|background|thumbnail|visual|banner|poster|img)/i,id=/(^|_)(image|img|photo|picture|avatar|logo|poster|thumbnail|frame|mask)(s|_urls?)?$/i,zd=e=>String(e||"").replace(/\s+/g,"_"),$h=/(^|_)(video|clip|footage)(s|_urls?)?$/i;function Cp(e,n={}){var s,o,a,l;return n.type!=="array"||cb(e,n)||!(!((s=n.items)!=null&&s.type)||n.items.type==="string")||/prompt|caption|description|text|negative|count|number|num_|qty/i.test(e)?!1:((o=n.items)==null?void 0:o.format)==="uri"||((a=n.items)==null?void 0:a["x-media"])==="image"||typeof((l=n.items)==null?void 0:l.contentMediaType)=="string"&&n.items.contentMediaType.startsWith("image/")||id.test(e)||id.test(zd(n.title))}function li(e,n={}){return n.format==="uri"||n.format==="url"?Ah.test(e)||Ah.test(n.title||"")||/image|photo|logo|picture/i.test(n.description||""):n["x-media"]==="image"?!0:typeof n.contentMediaType=="string"?n.contentMediaType.startsWith("image/"):!!((n.type==="string"||n.type===void 0)&&!Array.isArray(n.enum)&&!/prompt|caption|description|text|negative|count|number|num_|qty/i.test(e)&&(id.test(e)||id.test(zd(n.title))))}function Bd(e,n={}){return typeof n.contentMediaType=="string"?n.contentMediaType.startsWith("audio/"):n["x-media"]==="audio"?!0:(n.type==="string"||n.type===void 0)&&!Array.isArray(n.enum)&&!/prompt|caption|description|text|voice_id|model/i.test(e)?/(^|_)audio(_url)?($|_)|_audio_url$|^audio$/i.test(e)||/(^|_)(reference|source|input)_audio/i.test(e)||n.format==="uri"&&/audio|sound|music|voice/i.test(e):!1}function ci(e,n={}){return typeof n.contentMediaType=="string"?n.contentMediaType.startsWith("video/"):n["x-media"]==="video"?!0:(n.type==="string"||n.type===void 0)&&!Array.isArray(n.enum)&&!/prompt|caption|description|text|count|number|num_/i.test(e)?$h.test(e)||$h.test(zd(n.title))||n.format==="uri"&&/v
108ideo|clip|footage/i.test(e):!1}function cb(e,n={}){var s;if(n.type!=="array"||(s=n.items)!=null&&s.type&&n.items.type!=="string")return null;const r=`${e} ${zd(n.title)}`;return/(^|_)(video|clip|footage)(s|_urls?)?(\s|$)/i.test(r)?"video":/(^|_)(audio|sound|music|voice_sample|speech)(s|_urls?)?(\s|$)/i.test(r)?"audio":null}function db(e,n={}){return typeof n.maxLength=="number"&&n.maxLength>80||/(^|_)text$|^input$|(^|_)(ssml|transcript)($|_)/i.test(e)?!0:/(description|script|caption|details|body|about|summary|message|prompt|lyric)/i.test(e+(n.title||""))}const xi=i.createContext(null),dk=e=>({signIn:n=>e?e(n):!0,begin:()=>{},end:()=>{},setInvalid:()=>{}}),Ui=35;function ub({onLink:e,kind:n}){const[r,s]=i.useState(""),o=()=>{const a=r.trim();if(a){if(!/^https:\/\/\S+$/i.test(a)){me.error("Paste a link that starts with https://");return}e(a),s("")}};return t.jsx("input",{type:"url",value:r,onChange:a=>s(a.target.value),onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),o())},placeholder:`Or paste a link to the ${n}`,className:"mt-1.5 w-full rounded-lg bg-[#0E1117] border border-white/10 px-2.5 py-1.5 text-xs text-gray-100 placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-violet-500/40 focus:border-violet-500/40 transition"})}function ld({value:e,onChange:n,optional:r,compact:s=!1}){const[o,a]=i.useState(!1),l=i.useContext(xi),c=async h=>{if(h){if(!$m(h)){qo({code:"unsupported-file-type"});return}if(!(l!=null&&l.signIn&&!l.signIn("Sign in to upload your file."))){a(!0),l==null||l.begin();try{const p=await ii(h);p?n(p):me.error("Couldn't upload that image, try a public URL instead.")}catch(p){qo(p,"Couldn't upload that image.")}finally{a(!1),l==null||l.end()}}}},[u,d]=Y4(c);return e&&s?t.jsxs("div",{className:"relative w-14 h-14 rounded-xl overflow-hidden border border-white/15 bg-[#0E1117]",children:[t.jsx("img",{src:e,alt:"",className:"w-full h-full object-cover"}),t.jsx("button",{type:"button","aria-label":"Remove this image",onClick:()=>n(""),className:"absolute top-0.5 right-0.5 w-5 h-5 [@media(pointer:coarse)]:w-7 [@media(pointer:coarse)]:h-7 grid place-items-center rounded-full bg-black/70 text-white opacity-80 hover:opacity-100 hover:bg-black/90",children:t.jsx(ft,{className:"w-2.5 h-2.5"})})]}):e?t.jsxs("div",{className:"relative rounded-xl overflow-hidden border border-white/15 bg-[#0E1117]",children:[t.jsx("img",{src:e,alt:"upload",className:"w-full h-28 object-contain bg-black/30"}),t.jsx("button",{type:"button",onClick:()=>n(""),className:"absolute top-1.5 right-1.5 w-7 h-7 grid place-items-center rounded-full bg-black/70 text-white hover:bg-black/90",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]}):t.jsxs("label",{...d,className:`flex flex-col items-center justify-center rounded-xl border border-dashed bg-white/[0.02] hover:border-violet-400/50 cursor-pointer transition text-center ${s?"gap-0.5 w-14 h-14":"gap-1 h-28 px-3"} ${u?"border-violet-400 bg-violet-500/10":"border-white/20"}`,children:[o?t.jsx(Tn,{className:s?"w-4 h-4":"w-5 h-5"}):s?t.jsxs(t.Fragment,{children:[t.jsx(ho,{className:"w-4 h-4 text-gray-400"}),t.jsx("span",{className:"text-[9px] text-gray-500",children:u?"Drop":"Add"})]}):t.jsxs(t.Fragment,{children:[t.jsx(ho,{className:"w-5 h-5 text-gray-400"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:u?"Drop image here":`Drop or click to upload${r?" (optional)":""}`})]}),t.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/heic,image/heif",className:"hidden",onChange:h=>{var p;c((p=h.target.files)==null?void 0:p[0]),h.target.value=""}})]})}function Ep({value:e,onChange:n,optional:r}){const[s,o]=i.useState(!1),[a,l]=i.useState(!1),c=i.useContext(xi),u=async d=>{if(d&&!(c!=null&&c.signIn&&!c.signIn("Sign in to upload your file."))){try{W4(d)}catch(h){me.error(h.code==="file-too-large"?`That file is over ${Ui}MB, the most that can be uploaded here. Paste a link to it instead.`:"Invalid audio, use MP3, WAV, M4A, OGG or FLAC.");return}if(d.size>Ui*1024*1024){me.error(`That file is over ${Ui}MB, the most that can be uploaded here. Paste a link to it instead.`);return}o(!0),c==null||c.begin();try{const h=await La(await Od(d));h?n(h):me.error("Couldn't upload that audio. Try again, or paste a link to it.")}catch{me.error("Couldn't upload that audio. Try again, or paste a link to it.")}finally{o(!1),c==null||c.end()}}};return e?t.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-white/15 bg-[#0E1117] p-2",children:[t.jsx("audio",{src:e,controls:!0,className:"h-8 flex-1 min-w-0"}),t.jsx("button",{type:"button",onClick:()=>n(""),className:"w-7 h-7 grid place-items-center rounded-full bg-black/60 text-white hover:bg-black/80 shrink-0",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]}):t.jsxs("div",{children:[t.jsxs("label",{onDragOver:d=>{d.preventDefault(),d.stopPropagation(),l(!0)},onDragLeave:d=>{d.preventDefault(),l(!1)},onDrop:d=>{var h,p;d.preventDefault(),d.stopPropagation(),l(!1),u((p=(h=d.dataTransfer)==null?void 0:h.files)==null?void 0:p[0])},className:`flex flex-col items-center justify-center gap-1 h-20 rounded-xl border border-dashed bg-white/[0.02] hover:border-violet-400/50 cursor-pointer transition text-center px-3 ${a?"border-violet-400 bg-vi
108olet-500/10":"border-white/20"}`,children:[s?t.jsx(Tn,{className:"w-5 h-5"}):t.jsxs(t.Fragment,{children:[t.jsx(Fl,{className:"w-5 h-5 text-gray-400"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:a?"Drop audio here":`Drop or click to upload audio${r?" (optional)":""}`})]}),t.jsx("input",{type:"file",accept:"audio/*,.mp3,.wav,.m4a,.aac,.ogg,.flac",className:"hidden",onChange:d=>{var h;u((h=d.target.files)==null?void 0:h[0]),d.target.value=""}})]}),t.jsx(ub,{kind:"audio",onLink:n})]})}function Hd({value:e,onChange:n,optional:r}){const[s,o]=i.useState(!1),[a,l]=i.useState(!1),c=i.useContext(xi),u=async d=>{if(d&&!(c!=null&&c.signIn&&!c.signIn("Sign in to upload your file."))){try{ad(d)}catch(h){me.error(h.code==="file-too-large"?`That file is over ${Ui}MB, the most that can be uploaded here. Paste a link to it instead.`:"Invalid video, use MP4, MOV, WEBM or similar.");return}if(d.size>Ui*1024*1024){me.error(`That file is over ${Ui}MB, the most that can be uploaded here. Paste a link to it instead.`);return}o(!0),c==null||c.begin();try{const h=await La(await Od(d));h?n(h):me.error("Couldn't upload that video. Try again, or paste a link to it.")}catch{me.error("Couldn't upload that video. Try again, or paste a link to it.")}finally{o(!1),c==null||c.end()}}};return e?t.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-white/15 bg-[#0E1117] p-2",children:[t.jsx("video",{src:e,controls:!0,className:"h-16 flex-1 min-w-0 rounded-lg bg-black"}),t.jsx("button",{type:"button",onClick:()=>n(""),className:"w-7 h-7 grid place-items-center rounded-full bg-black/60 text-white hover:bg-black/80 shrink-0",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]}):t.jsxs("div",{children:[t.jsxs("label",{onDragOver:d=>{d.preventDefault(),d.stopPropagation(),l(!0)},onDragLeave:d=>{d.preventDefault(),l(!1)},onDrop:d=>{var h,p;d.preventDefault(),d.stopPropagation(),l(!1),u((p=(h=d.dataTransfer)==null?void 0:h.files)==null?void 0:p[0])},className:`flex flex-col items-center justify-center gap-1 h-20 rounded-xl border border-dashed bg-white/[0.02] hover:border-violet-400/50 cursor-pointer transition text-center px-3 ${a?"border-violet-400 bg-violet-500/10":"border-white/20"}`,children:[s?t.jsx(Tn,{className:"w-5 h-5"}):t.jsxs(t.Fragment,{children:[t.jsx($s,{className:"w-5 h-5 text-gray-400"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:a?"Drop video here":`Drop or click to upload video${r?" (optional)":""}`})]}),t.jsx("input",{type:"file",accept:"video/*,.mp4,.mov,.webm,.m4v,.avi,.mkv",className:"hidden",onChange:d=>{var h;u((h=d.target.files)==null?void 0:h[0]),d.target.value=""}})]}),t.jsx(ub,{kind:"video",onLink:n})]})}const mb=20,uk={};function pb(e,n,r){const s=e&&uk[e];return Number.isFinite(s)?{cap:s,real:!0}:n&&Number.isFinite(n.maxItems)?{cap:n.maxItems,real:!0}:Number.isFinite(r)?{cap:r,real:!1}:{cap:mb,real:!1}}function Mp(e,n={}){const r=Array.isArray(n.x_variants)?n.x_variants:[],s=r.find(a=>a&&a.properties&&("width"in a.properties||"height"in a.properties))||(n.properties&&("width"in n.properties||"height"in n.properties)?n:null);if(!s)return null;const o=r.find(a=>Array.isArray(a.enum))||(Array.isArray(n.enum)?n:null);return!o&&!/(^|_)(image_)?size$/i.test(e)?null:{presets:Array.isArray(o==null?void 0:o.enum)?o.enum:[],widthDef:s.properties.width||{},heightDef:s.properties.height||{},defaultPreset:typeof n.default=="string"?n.default:typeof(o==null?void 0:o.default)=="string"?o.default:void 0}}function mk({cfg:e,value:n,onChange:r}){var p,b,y,v,w,C;const s=n&&typeof n=="object",o=Number.isFinite((p=e.widthDef)==null?void 0:p.default)?e.widthDef.default:1024,a=Number.isFinite((b=e.heightDef)==null?void 0:b.default)?e.heightDef.default:1024,l=s?"__custom__":typeof n=="string"&&n?n:e.defaultPreset||"",c=[...e.defaultPreset?[]:[{value:"",label:"Model default"}],...e.presets.map(k=>({value:k,label:Wo(String(k))})),{value:"__custom__",label:"Custom"}],u=k=>{r(k==="__custom__"?{width:s?n.width:o,height:s?n.height:a}:k||void 0)},d=(k,E)=>{r({...s?n:{width:o,height:a},[k]:E===""?"":Number(E)})},h="flex-1 min-w-0 rounded-xl bg-[#0E1117] border border-white/10 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-violet-500/50 focus:border-violet-500/50 transition";return t.jsxs("div",{className:"space-y-2",children:[e.presets.length>0?t.jsx(Sn,{options:c,selectedValue:l,onSelect:u}):null,(l==="__custom__"||e.presets.length===0)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",placeholder:"Width",min:(y=e.widthDef)==null?void 0:y.minimum,max:(v=e.widthDef)==null?void 0:v.maximum,value:s?n.width??"":"",onChange:k=>d("width",k.target.value),className:h}),t.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"Ã"}),t.jsx("input",{type:"number",placeholder:"Height",min:(w=e.heightDef)==null?void 0:w.minimum,max:(C=e.heightDef)==null?void 0:C.maximum,value:s?n.height??"":"",onChange:k=>d("height",k.target.value),className:h})]})]})}const pk={num_images:8,num_outputs:8,num_samples:8,n:8,num_inference_steps:50};function km(e,n=0){if(!e||typeof e!="object"||n>6)return null;if(e.default!==void 0)return e.default;if(e.type==="object"){const r={};for(const[s,o]of Object.entries(e.properties||{}))r[s]=km(o,n+1);return r}return e.type==="array"?e.items?[km(e.items,n+1)]:[]:e.type==="integer"||e.type==="number"?typeof e.minimum=="number"?e.minimum:0:e.type==="boolean"?!1:Array.isArray(e.enum)&&e.enum.length?e.enum[0]:""}function _h(e={}){if(!e||typeof e!="object")return!1;if(Array.isArray(e.enum)&&e.enum.length)return!0;const n=e.type;
108return n==="boolean"||n==="string"||n==="integer"||n==="number"?!0:n==="array"?!e.items||e.items.type!=="object":!1}const Sc=e=>e&&typeof e=="object"&&Object.keys(e).length?JSON.stringify(e,null,2):"";function Dh({label:e,hint:n,def:r,value:s,onChange:o}){const[a,l]=i.useState(()=>Sc(s)),[c,u]=i.useState(""),d=Sc(s),h=i.useRef(d);i.useEffect(()=>{d!==h.current&&(h.current=d,l(d),u(""))},[d]);const p=i.useContext(xi),b=i.useId();i.useEffect(()=>(p==null||p.setInvalid(b,!!c,e),()=>p==null?void 0:p.setInvalid(b,!1)),[c,p,b,e]);const y=w=>{const C=w.trim();if(!C){u(""),h.current="",o(void 0);return}try{const k=JSON.parse(C);u(""),h.current=Sc(k),o(k)}catch{u("Invalid JSON, fix it to generate.")}},v=()=>{const w=km(r);l(JSON.stringify(w,null,2)),u(""),h.current=Sc(w),o(w)};return t.jsxs(Fe,{label:e,hint:n,children:[t.jsx("textarea",{rows:6,spellCheck:!1,placeholder:"{ ⦠}",value:a,onChange:w=>l(w.target.value),onBlur:w=>y(w.target.value),className:"w-full rounded-xl bg-[#0E1117] border border-white/10 px-3.5 py-2.5 text-xs font-mono text-gray-100 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-violet-500/50 focus:border-violet-500/50 transition"}),t.jsxs("div",{className:"flex items-start justify-between gap-3 mt-1.5",children:[t.jsx("button",{type:"button",onClick:v,className:"shrink-0 whitespace-nowrap text-[11px] font-medium text-violet-300 hover:text-violet-200",children:"Insert example"}),c?t.jsx("span",{className:"text-[11px] text-right text-rose-400",children:c}):t.jsx("span",{className:"text-[11px] text-gray-500",children:"JSON object"})]})]})}const zc=new Map,Sm=new Set;function fk(e){if(zc.has(e)||typeof document>"u")return;zc.set(e,void 0);const n=document.createElement(/\.(mp3|wav|m4a|aac|ogg|flac|opus)$/i.test(e)?"audio":"video");n.preload="metadata";const r=s=>{zc.set(e,s),n.onloadedmetadata=n.onerror=null,n.removeAttribute("src"),Sm.forEach(o=>o())};n.onloadedmetadata=()=>r(Number.isFinite(n.duration)&&n.duration>0?n.duration:NaN),n.onerror=()=>r(NaN),n.src=e}function hk(e){const[,n]=i.useState(0);i.useEffect(()=>{const o=()=>n(a=>a+1);return Sm.add(o),()=>Sm.delete(o)},[]);const r=e.join(` 109`);i.useEffect(()=>{for(const o of e)fk(o)},[r]);const s={};for(const o of e){const a=zc.get(o);a>0&&(s[o]=a)}return s}function xk({value:e,numeric:n,placeholder:r,onChange:s}){const o=Array.isArray(e)?e.join(", "):"",[a,l]=i.useState(o),c=i.useRef(o);return i.useEffect(()=>{o!==c.current&&(c.current=o,l(o))},[o]),t.jsx("input",{type:"text",value:a,placeholder:r,onChange:u=>{l(u.target.value);const d=u.target.value.split(",").map(p=>p.trim()).filter(Boolean),h=n?d.map(Number).filter(p=>Number.isFinite(p)):d;c.current=h.join(", "),s(h)},className:"w-full rounded-lg bg-[#0E1117] border border-white/10 px-2.5 py-1.5 text-xs text-gray-100 placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-violet-500/40 focus:border-violet-500/40 transition"})}function gk({kind:e,value:n,onChange:r,max:s=10,optional:o}){const a=Array.isArray(n)?n.filter(u=>typeof u=="string"&&u):[],l=i.useRef(a);l.current=a;const c=e==="audio"?Ep:Hd;return t.jsxs("div",{className:"space-y-2",children:[a.map((u,d)=>t.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-white/15 bg-[#0E1117] p-2",children:[e==="audio"?t.jsx("audio",{src:u,controls:!0,className:"h-8 flex-1 min-w-0"}):t.jsx("video",{src:u,controls:!0,className:"h-16 flex-1 min-w-0 rounded-lg bg-black"}),t.jsx("button",{type:"button","aria-label":`Remove this ${e}`,onClick:()=>r(l.current.filter((h,p)=>p!==d)),className:"w-7 h-7 grid place-items-center rounded-full bg-black/60 text-white hover:bg-black/80 shrink-0",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]},`${u}-${d}`)),a.length<s&&t.jsx(c,{value:"",onChange:u=>u&&r([...l.current,u].slice(0,s)),optional:o||a.length>0})]})}function bk({label:e,hint:n,itemDef:r,value:s,onChange:o}){const a=Array.isArray(s)?s:[],l=i.useRef(a);l.current=a;const c=Object.entries((r==null?void 0:r.properties)||{}),u=()=>{const h={};for(const[p,b]of c){const y=b.type==="number"||b.type==="integer";h[p]=b.default??(Array.isArray(b.enum)&&b.enum.length?b.enum[0]:y?b.minimum??0:b.type==="boolean"?!1:b.type==="array"?[]:"")}return h},d=(h,p,b)=>o(l.current.map((y,v)=>v===h?{...y,[p]:b}:y));return t.jsx(Fe,{as:"div",label:e,hint:n,children:t.jsxs("div",{className:"space-y-2",children:[a.map((h,p)=>t.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-white/10 bg-white/[0.02] p-2.5",children:[t.jsx("div",{className:"flex-1 flex flex-wrap gap-2",children:c.map(([b,y])=>{var R,A,V;const v=li(b,y),w=ci(b,y),C=Array.isArray(y.enum)&&y.enum.length>0,k=y.type==="number"||y.type==="integer",E=y.type==="boolean",m=y.type==="array"&&Cp(b,y),M=y.type==="array"&&!v&&!w&&!m&&(!((R=y.items)!=null&&R.type)||["string","number","integer"].includes(y.items.type)),I=((A=y.items)==null?void 0:A.type)==="number"||((V=y.items)==null?void 0:V.type)==="integer",
109N=v||w||m,F=N||C||E?"div":"label";return t.jsxs(F,{className:N?"basis-full w-full":k?"w-24":"flex-1 min-w-[150px]",children:[t.jsx("span",{className:"block text-[10px] text-gray-500 mb-0.5",children:Wo(b)}),v?t.jsx(ld,{value:typeof(h==null?void 0:h[b])=="string"?h[b]:"",onChange:z=>d(p,b,z),optional:!0}):m?t.jsx(Ip,{value:Array.isArray(h==null?void 0:h[b])?h[b]:[],onChange:z=>d(p,b,z),max:Number.isFinite(y.maxItems)?y.maxItems:mb,optional:!0}):w?t.jsx(Hd,{value:typeof(h==null?void 0:h[b])=="string"?h[b]:"",onChange:z=>d(p,b,z),optional:!0}):C?t.jsx(Sn,{options:y.enum.map(z=>({value:z,label:Wo(String(z))})),selectedValue:(h==null?void 0:h[b])??y.default??"",onSelect:z=>d(p,b,z)}):E?t.jsx(Sp,{checked:(h==null?void 0:h[b])===void 0||(h==null?void 0:h[b])===null||(h==null?void 0:h[b])===""?y.default===!0:!!h[b],onChange:z=>d(p,b,z),label:""}):M?t.jsx(xk,{value:h==null?void 0:h[b],numeric:I,placeholder:(y.description||"Comma separated").slice(0,40),onChange:z=>d(p,b,z)}):t.jsx("input",{type:k?"number":"text",value:(h==null?void 0:h[b])??"",placeholder:(y.description||"").slice(0,40),step:k?y.multipleOf||(y.type==="integer"?1:.01):void 0,onChange:z=>d(p,b,k?z.target.value===""?"":Number(z.target.value):z.target.value),className:"w-full rounded-lg bg-[#0E1117] border border-white/10 px-2.5 py-1.5 text-xs text-gray-100 placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-violet-500/40 focus:border-violet-500/40 transition"})]},b)})}),t.jsx("button",{type:"button",onClick:()=>o(a.filter((b,y)=>y!==p)),className:"mt-5 w-6 h-6 grid place-items-center rounded-md bg-white/5 text-gray-400 hover:text-white shrink-0",children:t.jsx(ft,{className:"w-3 h-3"})})]},p)),t.jsxs("button",{type:"button",onClick:()=>o([...a,u()]),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-dashed border-white/20 text-xs font-medium text-gray-300 hover:border-violet-400/50 hover:text-white transition",children:[t.jsx(fs,{className:"w-3 h-3"})," Add"]})]})})}function Ip({value:e,onChange:n,max:r=10,optional:s}){const o=Array.isArray(e)?e.filter(y=>typeof y=="string"&&y):[],a=i.useRef(o);a.current=o;const[l,c]=i.useState(!1),[u,d]=i.useState(!1),h=i.useContext(xi),p=async y=>{if(l)return;const v=Array.from(y||[]),w=v.filter($m);if(!w.length){v.length&&qo({code:"unsupported-file-type"});return}if(!(h!=null&&h.signIn&&!h.signIn("Sign in to upload your file."))){c(!0),h==null||h.begin();try{const C=Math.max(0,r-a.current.length);for(const k of w.slice(0,C))try{const E=await ii(k);E&&n([...a.current,E].slice(0,r))}catch(E){qo(E,"Couldn't upload one of the images.")}}finally{c(!1),h==null||h.end()}}},b={onDragOver:y=>{y.preventDefault(),y.stopPropagation(),u||d(!0)},onDragLeave:y=>{y.preventDefault(),y.stopPropagation(),d(!1)},onDrop:y=>{var v,w;y.preventDefault(),y.stopPropagation(),d(!1),(w=(v=y.dataTransfer)==null?void 0:v.files)!=null&&w.length&&p(y.dataTransfer.files)}};return t.jsxs("div",{...b,children:[o.length>0&&t.jsxs("div",{className:"mb-1.5 text-[10px] tabular-nums text-gray-500",children:[o.length," / ",r]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.map((y,v)=>t.jsxs("div",{className:"relative w-14 h-14 rounded-lg overflow-hidden border border-white/15 bg-[#0E1117]",children:[t.jsx("img",{src:y,alt:"",className:"w-full h-full object-cover"}),t.jsx("button",{type:"button","aria-label":"Remove this image",onClick:()=>n(a.current.filter((w,C)=>C!==v)),className:"absolute top-0.5 right-0.5 w-5 h-5 [@media(pointer:coarse)]:w-7 [@media(pointer:coarse)]:h-7 grid place-items-center rounded-full bg-black/70 text-white opacity-80 hover:opacity-100 hover:bg-black/90",children:t.jsx(ft,{className:"w-2.5 h-2.5"})})]},y+v)),o.length<r&&t.jsxs("label",{"aria-disabled":l,className:`flex flex-col items-center justify-center gap-0.5 w-14 h-14 rounded-lg border border-dashed bg-white/[0.02] hover:border-violet-400/50 transition ${l?"cursor-wait":"cursor-pointer"} ${u?"border-violet-400 bg-violet-500/10":"border-white/20"}`,children:[l?t.jsx(Tn,{className:"w-4 h-4"}):t.jsxs(t.Fragment,{children:[t.jsx(ho,{className:"w-4 h-4 text-gray-400"}),t.jsx("span",{className:"text-[9px] text-gray-500",children:"Add"})]}),t.jsx("input",{type:"file",accept:"image/*",multiple:!0,disabled:l,className:"hidden",onChange:y=>{p(y.target.files),y.target.value=""}})]})]})]})}
109function Lh({value:e,onChange:n,clamp:r,className:s,placeholder:o,min:a,max:l,step:c}){const u=e==null?"":String(e),[d,h]=i.useState(u),p=i.useRef(u);return i.useEffect(()=>{u!==p.current&&(p.current=u,h(u))},[u]),t.jsx("input",{type:"number",inputMode:"decimal",className:s,value:d,min:a,max:l,step:c,placeholder:o,onChange:b=>{const y=b.target.value;if(h(y),y===""){p.current="",n("");return}const v=Number(y);Number.isFinite(v)&&r(v)===v&&(p.current=String(v),n(v))},onBlur:()=>{if(d==="")return;const b=Number(d);if(!Number.isFinite(b)){h(p.current);return}const y=r(b);p.current=String(y),h(String(y)),String(y)!==u&&n(y)}})}function yk({value:e,numeric:n,onChange:r}){const s=Array.isArray(e)?e.join(` 110`):"",[o,a]=i.useState(s),l=i.useRef(s);return i.useEffect(()=>{s!==l.current&&(l.current=s,a(s))},[s]),t.jsx("textarea",{rows:3,className:nr,value:o,onChange:c=>{a(c.target.value);const u=c.target.value.split(` 111`).map(h=>h.trim()).filter(Boolean),d=n?u.map(Number).filter(h=>Number.isFinite(h)):u;l.current=d.join(` 112`),r(d)}})}function vk({schema:e,value:n,onChange:r,modelId:s,imageInputLimit:o}){const a=i.useRef(n);return a.current=n,t.jsx(cd,{schema:e,values:n,onChange:(l,c)=>r({...a.current,[l]:c}),modelId:s,imageInputLimit:o})}function cd({schema:e,values:n,onChange:r,exclude:s=[],modelId:o="",imageInputLimit:a}){const l=(e==null?void 0:e.properties)||{},c=new Set((e==null?void 0:e.required)||[]),u=Ud(e).filter(d=>!s.includes(d)).map(d=>[d,l[d]]);return u.length?t.jsx("div",{className:"space-y-3.5",children:u.map(([d,h])=>{var E,m,M,I;const p=h||{},b=p.title||Wo(d),y=!c.has(d),v=n[d],w=y?"Optional":void 0;if(p.type==="boolean"){const N=v==null;return t.jsx(Sp,{checked:N?p.default===!0:!!v,onChange:F=>r(d,F),label:N&&p.default===void 0?t.jsxs(t.Fragment,{children:[b,t.jsx("span",{className:"ml-1.5 text-[11px] text-gray-500",children:"Model default"})]}):b},d)}if(Cp(d,p)){const{cap:N,real:F}=pb(o,p,a),R=y?"Optional":"Required",A=F?`${R} · up to ${N} image${N===1?"":"s"}`:R;return t.jsx(Fe,{as:"div",label:b,hint:A,children:t.jsx(Ip,{value:Array.isArray(v)?v:[],onChange:V=>r(d,V),max:N,optional:y})},d)}const C=cb(d,p);if(C)return t.jsx(Fe,{as:"div",label:b,hint:w,children:t.jsx(gk,{kind:C,value:v,onChange:N=>r(d,N),max:Math.min(Number.isFinite(p.maxItems)&&p.maxItems>0?p.maxItems:ed,ed),optional:y})},d);if(li(d,p))return t.jsx(Fe,{as:"div",label:b,hint:w,children:t.jsx(ld,{value:typeof v=="string"?v:"",onChange:N=>r(d,N),optional:y})},d);if(Bd(d,p))return t.jsx(Fe,{as:"div",label:b,hint:w,children:t.jsx(Ep,{value:typeof v=="string"?v:"",onChange:N=>r(d,N),optional:y})},d);if(ci(d,p))return t.jsx(Fe,{as:"div",label:b,hint:w,children:t.jsx(Hd,{value:typeof v=="string"?v:"",onChange:N=>r(d,N),optional:y})},d);const k=Mp(d,p);if(k)return t.jsx(Fe,{as:"div",label:b,hint:w,children:t.jsx(mk,{cfg:k,value:v,onChange:N=>r(d,N)})},d);if(Array.isArray(p.enum)&&p.enum.length){const N=p.type==="integer"||p.type==="number",F=V=>N&&V!==""&&V!=null&&Number.isFinite(Number(V))?Number(V):V,R=p.enum.map(V=>({value:F(V),label:Wo(String(V))})),A=F(v??p.default??"");return t.jsx(Fe,{as:"div",label:b,hint:w,children:R.length<=5?t.jsx(dr,{value:A,onChange:V=>r(d,V),options:R}):t.jsx(Sn,{options:R,selectedValue:A,onSelect:V=>r(d,V)})},d)}if(p.type==="integer"||p.type==="number"){const N=p.type==="integer",F=typeof p.minimum=="number",R=typeof p.maximum=="number",A=typeof p.multipleOf=="number"&&p.multipleOf||(N?1:.01),V=R?void 0:pk[d],z=se=>{if(!Number.isFinite(se))return se;let pe=N?Math.round(se):se;return F&&(pe=Math.max(p.minimum,pe)),R?pe=Math.min(p.maximum,pe):Number.isFinite(V)&&(pe=Math.min(V,pe)),pe},H=Number.isFinite(Number(v))?Number(v):Number.isFinite(p.default)?p.default:F?p.minimum:R?p.maximum:0,ne=F&&R?`${p.minimum} to ${p.maximum}`:F?`min ${p.minimum}`:R?`max ${p.maximum}`:w;if(F&&R){const se=p.maximum===p.minimum?0:(H-p.minimum)/(p.maximum-p.minimum)*100;return t.jsx(Fe,{label:b,children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"range",min:p.minimum,max:p.maximum,step:A,value:H,onChange:pe=>r(d,z(Number(pe.target.value))),className:"flex-1 h-1.5 appearance-none rounded-full cursor-pointer accent-violet-500 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:shadow-[0_1px_4px_rgba(0,0,0,0.4)] [&::-webkit-slider-thumb]:border [&::-webkit-slider-thumb]:border-violet-400",style:{background:`linear-gradient(90deg, rgb(139 92 246) ${se}%, rgb(255 255 255 / 0.1) ${se}%)`}}),t.jsx(Lh,{min:p.minimum,max:p.maximum,step:A,value:v,clamp:z,placeholder:Number.isFinite(p.default)?String(p.default):"",onCh
112ange:pe=>r(d,pe),className:"w-16 shrink-0 rounded-lg bg-[#0E1117] border border-white/10 px-2 py-1.5 text-sm text-center text-gray-100 tabular-nums focus:outline-none focus:ring-2 focus:ring-violet-500/50 focus:border-violet-500/50 transition"})]}),t.jsxs("div",{className:"flex justify-between px-0.5 text-[10px] tabular-nums text-gray-600",children:[t.jsx("span",{children:p.minimum}),t.jsx("span",{children:p.maximum})]})]})},d)}return t.jsx(Fe,{label:b,hint:ne,children:t.jsx(Lh,{className:nr,value:v,min:F?p.minimum:void 0,max:R?p.maximum:void 0,step:A,clamp:z,placeholder:Number.isFinite(p.default)?String(p.default):"",onChange:se=>r(d,se)})},d)}if(p.type==="array"&&((E=p.items)==null?void 0:E.type)==="object"&&((m=p.items)!=null&&m.properties)){const N=Object.entries(p.items.properties);return N.length>0&&N.every(([R,A])=>_h(A)||li(R,A)||ci(R,A))?t.jsx(bk,{label:b,hint:w,itemDef:p.items,value:Array.isArray(v)?v:[],onChange:R=>r(d,R)},d):t.jsx(Dh,{label:b,hint:y?"Optional · JSON":"Required · JSON",def:p,value:v,onChange:R=>r(d,R)},d)}if(p.type==="array")return t.jsx(Fe,{label:b,hint:"One per line",children:t.jsx(yk,{value:v,numeric:((M=p.items)==null?void 0:M.type)==="number"||((I=p.items)==null?void 0:I.type)==="integer",onChange:N=>r(d,N)})},d);if(p.properties&&typeof p.properties=="object"&&!Array.isArray(p.enum)){const N=Object.entries(p.properties);if(N.length>0&&N.every(([,R])=>_h(R))){const R=v&&typeof v=="object"&&!Array.isArray(v)?v:{};return t.jsx(Fe,{as:"div",label:b,hint:y?"Optional":"Required",children:t.jsx("div",{className:"rounded-lg border border-white/10 bg-white/[0.02] p-3",children:t.jsx(vk,{schema:p,value:R,onChange:A=>r(d,A),modelId:o,imageInputLimit:a})})},d)}return t.jsx(Dh,{label:b,hint:y?"Optional · JSON":"Required · JSON",def:p,value:v,onChange:R=>r(d,R)},d)}if(db(d,p)){const N=p.maxLength||5e3,F=typeof v=="string"?v.length:0;return t.jsx(Fe,{label:b,hint:`${F} / ${N}`,children:t.jsx("textarea",{rows:4,className:nr,maxLength:N,placeholder:p.default||p.description||"",value:typeof v=="string"?v:"",onChange:R=>r(d,R.target.value)})},d)}return t.jsx(Fe,{label:b,hint:w,children:t.jsx("input",{type:"text",className:nr,maxLength:p.maxLength||void 0,placeholder:p.description||"",value:typeof v=="string"?v:"",onChange:N=>r(d,N.target.value)})},d)})}):t.jsx("p",{className:"text-xs text-gray-500",children:"This template has no extra inputs, just hit Generate."})}function ku(e,n,r="bezier"){const s=e.x+e.w,o=e.y+e.h/2,a=n.x,l=n.y+n.h/2;if(r==="ortho"){const u=(s+a)/2,d=Math.min(12,Math.abs(l-o)/2,Math.abs(u-s)||12);if(Math.abs(l-o)<1)return`M ${s} ${o} L ${a} ${l}`;const h=l>o?1:-1;return`M ${s} ${o} L ${u-d} ${o} Q ${u} ${o} ${u} ${o+h*d} L ${u} ${l-h*d} Q ${u} ${l} ${u+d} ${l} L ${a} ${l}`}const c=Math.max(40,(a-s)/2);return`M ${s} ${o} C ${s+c} ${o}, ${a-c} ${l}, ${a} ${l}`}function fb({state:e,error:n,onClick:r}){if(e==="running")return t.jsx(Tn,{className:"w-3.5 h-3.5 shrink-0"});if(e==="done")return t.jsx(ga,{className:"w-3.5 h-3.5 shrink-0 text-emerald-400"});if(e==="failed"){const s=n||"This node failed, check its inputs and try again.";return t.jsx("button",{type:"button",title:s,onMouseDown:o=>o.stopPropagation(),onClick:o=>{o.stopPropagation(),r?r():me.error(s)},className:"inline-flex shrink-0 cursor-pointer text-rose-400 hover:text-rose-300",children:t.jsx(Xs,{className:"w-3.5 h-3.5"})})}return t.jsx("span",{className:"w-2 h-2 shrink-0 rounded-full bg-white/20 inline-block"})}function wk({text:e,placeholder:n}){return t.jsx("div",{className:"text-[11px] leading-relaxed text-gray-300 max-h-32 overflow-y-auto whitespace-pre-wrap break-words",children:e||t.jsx("span",{className:"text-gray-600 italic",children:n})})}function Su({state:e,label:n,error:r}){return t.jsx("div",{className:"h-32 grid place-items-center rounded-lg bg-black/30 border border-white/10 text-center px-2",children:e==="running"?t.jsxs("div",{className:"flex flex-col items-center gap-1.5 text-gray-400 text-[11px]",children:[t.jsx(Tn,{className:"w-5 h-5"}),t.jsx("span",{children:"Generatingâ¦"})]}):e==="failed"?t.jsxs("div",{className:"flex w-full min-w-0 flex-col items-center gap-1 text-rose-300 text-[11px]",title:r||"Failed",children:[t.jsx(Xs,{className:"w-5 h-5"}),t.jsx("div",{className:"font-medium",children:"Failed"}),r?t.jsx("div",{className:"w-full text-[10px] text-rose-300/70 line-clamp-3 leading-snug break-words",children:r}):null]}):t.jsx("span",{className:"text-gray-600 text-[11px]",children:n})})}const Oh=e=>{var n,r;return Number((r=((n=e==null?void 0:e.data)==null?void 0:n.missing)||(e==null?void 0:e.missing))==null?void 0:r.length)||-1};function Vh({url:e,onExpand:n}){return e?t.jsxs("div",{className:"absolute top-1.5 right-1.5 flex items-center gap-1 opacity-0 group-hover/media:opacity-100 [@media(hover:none)]:opacity-100 transition",children:[t.jsx("button",{type:"button",title:"View full screen",onMouseDown:r=>r.stopPropagation(),onClick:r=>{r.stopPropagation(),n==null||n()},className:"w-6 h-6 grid place-items-center rounded-md bg-black/70 text-white/90 hover:bg-black/90 border border-white/15",children:t.jsx(Ts,{className:"w-3 h-3"})}),t.jsx("a",{href:ud(e)||void 0,download:!0,title:"Download",onMouseDown:r=>r.stopPropagation(),onClick:r=>r.stopPropagation(),className:"w-6 h-6 grid place-items-center rounded-md bg-black/70 text-white/90 hover:bg-black/90 border border-white/15",children:t.jsx(go,{className:"w-3 h-3"})})]}):null}function Yo({onClose:e,children:n,align:r="center",z:s="z-[140]"}){return Un.createPortal(t.jsx("div",{className:`fixed inset-0 ${s} grid ${r==="top"?"items-start justify-items-center pt-[12vh]":"place-items-center"} p-4 bg-black/60 backdrop-blur-sm`,onMouseDown:e,children:n}),document.body)}function jk({media:e,onClose:n}){if(!(e!=null&&e.url))return null;const{url:r,kind:s}=e;return Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[140] grid place-items-center p-6 bg-black/60 backdrop-blur-sm",onMouseDown:n,children:t.jsxs("div",{className:"relative modal-pop-in",onMouseDown:o=>o.stopPropagation(),children:[s==="video"?t.jsx("video",{src:r,controls:!0,autoPlay:!0,className:"max-w-[92vw] max-h-[85vh] rounded-xl bg-black"}):s==="audio"?t.jsx("div",{className:"w-[min(92vw,520px)] rounded-2xl border border-white/10 bg-[#0E1117] p-6",children:t.jsx("audio",{src:r,controls:!0,autoPlay:!0,className:"w-full"})}):t.jsx("img",{src:r,alt:"",className:"max-w-[92vw] max-h-[85vh] rounded-xl bg-black object-contain"}),t.jsxs("div",{className:"absolute -top-3 -right-3 flex gap-2",children:[t.jsx("a",{href:ud(r)||void 0,download:!0,title:"Download",className:"w-9 h-9 grid place-items-center rounded-full bg-black/80 text-white hover:bg-black/95 border border-white/15",children:t.jsx(go,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",onClick:n,title:"Close (Esc)",className:"w-9 h-9 grid place-items-center rounded-full bg-black/80 text-white hover:bg-black/95 border border-white/15",children:t.jsx(ft,{className:"w-4 h-4"})})]})]})}),document.body)}function Nk(e){return String(e||"").split("/").filter((n,r)=>
112!(r===0&&/^(fal-ai|fal)$/i.test(n))).map(n=>n.replace(/[-_]/g," ").replace(/\b\w/g,r=>r.toUpperCase())).join(" · ")}function Uh({model:e,schema:n,loading:r,values:s,onChange:o,signIn:a}){const[l,c]=i.useState(!1);if(!e)return null;if(r)return t.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] text-gray-500",children:[t.jsx(Tn,{className:"w-3 h-3"})," Loading model optionsâ¦"]});const u=(n==null?void 0:n.properties)||null;if(!u)return null;const d=Object.keys(u).filter(h=>!Yh.includes(h)).length;return d?t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02]",children:[t.jsxs("button",{type:"button",onClick:()=>c(h=>!h),className:"w-full flex items-center justify-between gap-2 px-3 py-2 text-xs font-semibold text-gray-200 hover:text-white",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(ba,{className:"w-3.5 h-3.5 text-violet-300"})," Model options (",d,")"]}),t.jsx(Al,{className:`w-4 h-4 text-gray-400 transition-transform ${l?"rotate-180":""}`})]}),l&&t.jsx("div",{className:"px-3 pb-3 pt-1",children:t.jsx(xi.Provider,{value:dk(a),children:t.jsx(cd,{schema:n,values:s,onChange:(h,p)=>o({...s,[h]:p}),exclude:Yh,modelId:e})})})]}):null}function Ga({names:e,what:n="Prompt",overrides:r=!0}){return t.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-violet-400/30 bg-violet-500/10 px-2.5 py-2 text-[11px] leading-snug text-violet-100",children:[t.jsx(Ko,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-violet-300"}),t.jsxs("span",{children:[n," comes from ",t.jsx("b",{children:e}),r?", the connected node's output is used, so there's nothing to type here.":", used together with anything you type."]})]})}function kk({title:e,desc:n,onClose:r,children:s,readOnly:o=!1,onLocked:a,onRun:l,runState:c,runDisabled:u=!1}){return t.jsxs("div",{"data-adf-ui":!0,className:"absolute w-[22rem] max-w-[calc(100vw-2rem)] overflow-y-auto overscroll-contain rounded-xl border border-white/10 bg-[#0E1117]/95 backdrop-blur shadow-2xl p-4 space-y-3 z-50 sm:top-3 sm:right-3 sm:max-h-[calc(100%-1.5rem)] max-sm:left-2 max-sm:right-2 max-sm:bottom-2 max-sm:w-auto max-sm:max-w-none max-sm:max-h-[58%] max-sm:rounded-2xl",onMouseDown:d=>d.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h4",{className:"text-sm font-semibold text-white truncate",children:e}),c&&t.jsx(fb,{state:c})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[l&&t.jsxs("button",{type:"button",onClick:l,disabled:u,title:u?"Pick a model / flow is running":"Run this node (and any inputs it needs)",className:"inline-flex items-center gap-1 px-2.5 h-7 rounded-lg bg-violet-500 hover:bg-violet-400 text-white text-xs font-semibold disabled:opacity-40 transition",children:[t.jsx(Ta,{className:"w-3 h-3"})," Run"]}),t.jsx("button",{type:"button",onClick:r,className:"w-7 h-7 grid place-items-center rounded-lg text-gray-400 hover:text-white hover:bg-white/5",children:t.jsx(ft,{className:"w-4 h-4"})})]})]}),n&&t.jsxs("p",{className:"flex items-start gap-1.5 text-[11px] leading-snug text-gray-400 -mt-1",children:[t.jsx(Qa,{className:"w-3 h-3 mt-0.5 shrink-0 text-violet-300/80"}),t.jsx("span",{children:n})]}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:o?"space-y-3 opacity-60 pointer-events-none":"space-y-3",children:s}),o&&t.jsx("button",{type:"button",onClick:a,title:"Sign in to edit",className:"absolute inset-0 cursor-pointer"})]})]})}function Sk({open:e,onClose:n,onAdd:r}){const[s,o]=i.useState(""),[a,l]=i.useState(0),c=i.useRef(null);if(i.useEffect(()=>{if(e){o(""),l(0);const y=setTimeout(()=>{var v;return(v=c.current)==null?void 0:v.focus()},30);return()=>clearTimeout(y)}},[e]),!e)return null;const u=s.trim().toLowerCase(),d=hb.flatMap(y=>y.types.map(v=>({t:v,group:y.label,def:lt[v]}))),h=u?d.filter(({t:y,def:v})=>`${v.label} ${v.desc||""} ${y}`.toLowerCase().includes(u)):d,p=y=>{r(y),n()},b=y=>{y.key==="ArrowDown"?(y.preventDefault(),l(v=>Math.min(h.length-1,v+1))):y.key==="ArrowUp"?(y.preventDefault(),l(v=>Math.max(0,v-1))):y.key==="Enter"?(y.preventDefault(),h[a]&&p(h[a].t)):y.key==="Escape"&&(y.preventDefault(),n())};return t.jsx(Yo,{onClose:n,align:"top",z:"z-[130]",children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl overflow-hidden",onMouseDown:y=>y.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-3 border-b border-white/10",children:[t.jsx(zl,{className:"w-4 h-4 text-gray-500 shrink-0"}),t.jsx("input",{ref:c,value:s,onChange:y=>{o(y.target.value),l(0)}
112,onKeyDown:b,placeholder:"Add a node. Type to filter, ââ then Enter",className:"flex-1 bg-transparent text-sm text-gray-100 placeholder-gray-500 focus:outline-none"}),t.jsx("kbd",{className:"text-[10px] text-gray-500 border border-white/10 rounded px-1 shrink-0",children:"esc"})]}),t.jsxs("div",{className:"max-h-[50vh] overflow-y-auto py-1",children:[h.length===0&&t.jsxs("div",{className:"px-4 py-6 text-center text-sm text-gray-500",children:["No nodes match â",s,"â."]}),h.map((y,v)=>{const w=y.def.icon,C=y.def.out?Za(y.def.out).text:"text-gray-400";return t.jsxs("button",{type:"button",onMouseEnter:()=>l(v),onClick:()=>p(y.t),className:`w-full flex items-center gap-2.5 px-3.5 py-2 text-left ${v===a?"bg-violet-500/15":"hover:bg-white/5"}`,children:[t.jsx(w,{className:`w-4 h-4 shrink-0 ${C}`}),t.jsx("span",{className:"text-sm text-gray-100 shrink-0",children:y.def.label}),t.jsx("span",{className:"text-[11px] text-gray-500 truncate",children:y.def.desc}),t.jsx("span",{className:"ml-auto text-[10px] uppercase tracking-wide text-gray-600 shrink-0",children:y.group})]},y.t)})]})]})})}function Ck({open:e,initialName:n,saving:r,onClose:s,onSave:o}){const[a,l]=i.useState(n||"Untitled workflow");if(i.useEffect(()=>{e&&l(n||"Untitled workflow")},[e,n]),!e)return null;const c=()=>{const u=a.trim();u&&o(u)};return t.jsx(Yo,{onClose:s,children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-2xl border border-white/10 bg-[#0E1117] p-5 shadow-2xl",onMouseDown:u=>u.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[t.jsx(ni,{className:"w-4 h-4 text-violet-300"})," Save workflow"]}),t.jsx("button",{type:"button",onClick:s,className:"text-gray-400 hover:text-white",children:t.jsx(ft,{className:"w-5 h-5"})})]}),t.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Name"}),t.jsx("input",{autoFocus:!0,value:a,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:"e.g. Coffee dripper UGC ad",className:"w-full rounded-lg bg-black/40 border border-white/10 px-3 py-2 text-sm text-gray-100 outline-none focus:border-violet-400/50"}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:s,className:"px-3.5 py-2 rounded-xl bg-white/[0.05] border border-white/10 text-gray-200 text-sm hover:border-white/25",children:"Cancel"}),t.jsxs("button",{type:"button",onClick:c,disabled:r||!a.trim(),className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-xl bg-violet-500 hover:bg-violet-400 text-white text-sm font-semibold disabled:opacity-50",children:[r?t.jsx(Tn,{className:"w-4 h-4"}):t.jsx(ni,{className:"w-4 h-4"})," ","Save"]})]})]})})}function Ek({open:e,url:n,isShared:r,onClose:s,onToggle:o}){const[a,l]=i.useState(!1);if(i.useEffect(()=>{e||l(!1)},[e]),!e)return null;const c=async()=>{try{await navigator.clipboard.writeText(n),l(!0),me.success("Link copied."),setTimeout(()=>l(!1),1800)}catch{me.error("Copy failed. Select the link and copy it manually.")}};return t.jsx(Yo,{onClose:s,children:t.jsxs("div",{className:"modal-pop-in w-full max-w-lg rounded-2xl border border-white/10 bg-[#0E1117] p-5 shadow-2xl",onMouseDown:u=>u.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[t.jsx(Ko,{className:"w-4 h-4 text-violet-300"})," Share workflow"]}),t.jsx("button",{type:"button",onClick:s,className:"text-gray-400 hover:text-white",children:t.jsx(ft,{className:"w-5 h-5"})})]}),t.jsx("p",{className:"text-sm text-gray-400 mb-3",children:"Anyone with this link can view this workflow and its outputs, and save their own copy."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:n,onFocus:u=>u.target.select(),className:"flex-1 min-w-0 rounded-lg bg-black/40 border border-white/10 px-3 py-2 text-sm text-gray-200 outline-none"}),t.jsxs("button",{type:"button",onClick:c,className:"shrink-0 inline-flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-violet-500 hover:bg-violet-400 text-white text-sm font-semibold",children:[a?t.jsx(ga,{className:"w-4 h-4"}
112):t.jsx(xa,{className:"w-4 h-4"})," ",a?"Copied":"Copy"]})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-gray-500",children:r?"Link sharing is on.":"Link sharing is off."}),t.jsx("button",{type:"button",onClick:()=>o(!r),className:"text-xs font-medium text-rose-300 hover:text-rose-200",children:r?"Disable link":"Enable link"})]})]})})}function Mk({open:e,loading:n,workflows:r,currentId:s,onClose:o,onOpen:a,onDelete:l,onDuplicate:c,buildShareUrl:u}){const[d,h]=i.useState(null);return i.useEffect(()=>{e||h(null)},[e]),e?t.jsx(Yo,{onClose:o,children:t.jsxs("div",{className:"modal-pop-in w-full max-w-3xl max-h-[80vh] flex flex-col rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl",onMouseDown:p=>p.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/10",children:[t.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[t.jsx(zi,{className:"w-4 h-4 text-violet-300"})," My workflows",t.jsxs("span",{className:`text-[11px] font-semibold px-2 py-0.5 rounded-full border ${r.length>=8?"bg-amber-500/15 border-amber-500/30 text-amber-300":"bg-white/[0.04] border-white/10 text-gray-400"}`,title:"You can keep up to 8 workspaces",children:[r.length," / 8"]})]}),t.jsx("button",{type:"button",onClick:o,className:"text-gray-400 hover:text-white",children:t.jsx(ft,{className:"w-5 h-5"})})]}),t.jsx("div",{className:"p-5 overflow-y-auto",children:n?t.jsx("div",{className:"py-16 grid place-items-center text-gray-400",children:t.jsx(Tn,{className:"w-6 h-6"})}):r.length?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:r.map(p=>t.jsxs("div",{className:`group rounded-xl border ${p.id===s?"border-violet-400/50":"border-white/10"} bg-black/30 overflow-hidden`,children:[t.jsxs("button",{type:"button",onClick:()=>a(p.id),className:"block w-full text-left",children:[t.jsx("div",{className:"aspect-video bg-black/50 grid place-items-center overflow-hidden",children:p.thumbnailUrl?t.jsx("img",{src:p.thumbnailUrl,alt:"",loading:"lazy",className:"w-full h-full object-cover"}):t.jsx(Ko,{className:"w-6 h-6 text-gray-700"})}),t.jsxs("div",{className:"px-3 pt-2.5",children:[t.jsx("div",{className:"text-sm font-medium text-gray-100 truncate",title:p.name,children:p.name}),t.jsxs("div",{className:"text-[11px] text-gray-500 mt-0.5",children:[p.nodeCount," nodes",p.isShared?" · shared":""]})]})]}),t.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[t.jsx("button",{type:"button",onClick:()=>a(p.id),className:"text-xs font-medium text-violet-300 hover:text-violet-200",children:"Open"}),t.jsxs("div",{className:"flex items-center gap-2",children:[c&&t.jsx("button",{type:"button",title:"Duplicate",onClick:()=>c(p.id),className:"text-gray-400 hover:text-white",children:t.jsx(xa,{className:"w-4 h-4"})}),p.isShared&&p.shareId&&t.jsx("button",{type:"button",title:"Copy share link",onClick:async()=>{try{await navigator.clipboard.writeText(u(p.shareId)),me.success("Link copied.")}catch{}},className:"text-gray-400 hover:text-white",children:t.jsx(m0,{className:"w-4 h-4"})}),d===p.id?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] text-gray-400",children:"Delete?"}),t.jsx("button",{type:"button",title:"Confirm delete",onClick:()=>{l(p.id),h(null)},className:"text-rose-300 hover:text-rose-200",children:t.jsx(ga,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",title:"Cancel",onClick:()=>h(null),className:"text-gray-400 hover:text-white",children:t.jsx(ft,{className:"w-4 h-4"})})]}):t.jsx("button",{type:"button",title:"Delete",onClick:()=>h(p.id),className:"text-gray-500 hover:text-rose-300",children:t.jsx(ss,{className:"w-4 h-4"})})]})]})]},p.id))}):t.jsx("div",{className:"py-16 text-center text-gray-500 text-sm",children:"No saved workflows yet. Build a graph and hit Save."})})]})}):null}const zh=[{value:"9x16",label:"9:16"},{value:"1x1",label:"1:1"},{value:"16x9",label:"16:9"}],lt={"input-text":{label:"Text",icon:qs,out:"text",inputs:[],desc:"A text value you type yourself (no AI). Drag its Output dot into another node's prompt or text input. Use it for product descriptions, scripts, or instructions."},"input-image":{label:"Image",icon:Zs,out:"image",inputs:[],desc:"Upload or drop an image. Drag its Output into an image input (e.g. an Image Gen / Video Gen / Upscaler node). No AI."},image:{label:"Image Gen",icon:Zs,out:"image",inputs:[{id:"prompt",kind:"text",label:"Prompt"},{id:"image",kind:"image",label:"Image",multi:!0}],desc:"Generates an image. Pick a mode (text or image to image) and a model. Wire text into Prompt and, for image to image, an image into Image."},video:{label:"Video Gen",icon:$s,out:"video",inputs:[{id:"prompt",kind:"text",label:"Prompt"},{id:"image",kind:"image",label:"Image",multi:!0}],desc:"Generates video. Pick a model and mode (text or image to video). Wire a Prompt and (for image to video) an Image."},music:{label:"Music",icon:oi,out:"audio",inputs:[{id:"text",kind:"text",label:"Prompt"}],desc:"Generates a music track from a text prompt. Wire a description into Prompt."},sfx:{label:"Sound Effects",icon:_i,out:"audio",inputs:[{id:"text",kind:"text",label:"Prompt"}],desc:"Generates a sound effect from a text prompt. Wire a description into Prompt."},upscale:{label:"Image Upscaler",icon:Yc,out:"image",inputs:[{id:"image",kind:"image",label:"Image"}],desc:"Creative upscale (2Ã/4Ã). Creativity invents new detail; Resemblance keeps fidelity to the source. The Magnific style levers on fal's clarity upscaler."},relight:{label:"Relight",icon:Tm,out:"image",inputs:[{id:"image",kind:"image",label:"Image"}],desc:"Relight a wired image: pick a light direction or mood (left, golden hour, studio, dramaticâ¦) and optionally keep the background. Preserves the subject."},style:{label:"Style Transfer",icon:Li,out:"image",inputs:[{id:"image",kind:"image",label:"Image"},{id:"style",kind:"image",label:"Style ref"}],desc:"Restyle the Image to match the look of a Style reference image: palette, texture, rendering, while keeping the original composition."}
112,background:{label:"Background",icon:Di,out:"image",inputs:[{id:"image",kind:"image",label:"Image"}],desc:"Remove the background (clean transparent cutout) or Replace it with a described scene, keeping the subject intact."},brand:{label:"Brand Kit",icon:p0,out:"text",inputs:[],desc:"Your brand in one node: name, colours, fonts, voice. Drag its Output into any Prompt to keep generations on brand. No AI."},caption:{label:"Caption / Overlay",icon:Ra,out:"image",inputs:[{id:"image",kind:"image",label:"Image"},{id:"text",kind:"text",label:"Caption"}],desc:"Burn ad copy onto an image: a headline or CTA at the position you choose. Wire an Image and (optionally) a Caption text node."},assemble:{label:"Assemble Ad",icon:Js,out:"video",inputs:[{id:"clips",kind:"video",accepts:["video","image"],multi:!0,label:"Clips"},{id:"voice",kind:"audio",label:"Voice or sound"},{id:"music",kind:"audio",label:"Music"},{id:"text",kind:"text",label:"Captions"}],desc:"Puts your finished pieces together as one ad: the clips in order, with sound, music and captions mixed in. Free, it uses no credits."},sticky:{label:"Sticky note",icon:Tl,out:null,inputs:[],annotation:!0,desc:"A free-floating note for yourself. Not run and not connected to anything."}},Bh={text:{dot:"bg-sky-500",border:"border-sky-400/70 hover:border-sky-300 hover:bg-sky-500/40",stroke:"#38bdf8",text:"text-sky-300"},image:{dot:"bg-violet-500",border:"border-violet-400/70 hover:border-violet-300 hover:bg-violet-500/40",stroke:"#a78bfa",text:"text-violet-300"},video:{dot:"bg-emerald-500",border:"border-emerald-400/70 hover:border-emerald-300 hover:bg-emerald-500/40",stroke:"#34d399",text:"text-emerald-300"},audio:{dot:"bg-amber-500",border:"border-amber-400/70 hover:border-amber-300 hover:bg-amber-500/40",stroke:"#fbbf24",text:"text-amber-300"}},Za=e=>Bh[e]||Bh.image,ti=e=>e?e.accepts||[e.kind]:[],Bc=e=>!!e&&e.multi===!0,Hh=(e,n,r)=>{const s=window.innerWidth,o=window.innerHeight,a=Math.max(8,Math.min(e,s-r-8)),l=Math.max(8,Math.min(n,o-8-Math.min(420,o-16)));return{left:a,top:l,maxHeight:o-l-8}},Kh=(e,n,{preferred:r,srcType:s,taken:o=[]}={})=>{var l;const a=(((l=lt[e])==null?void 0:l.inputs)||[]).filter(c=>ti(c).includes(n));return a.length?r&&a.some(c=>c.id===r)?r:s==="music"&&a.some(c=>c.id==="music")?"music":(a.find(c=>Bc(c)||!o.includes(c.id))||a[0]).id:null},Ik={"your own words in place of the instruction in it":"your own words","a background description":"a background"},Fk=e=>Ik[e]||e;function dl(e,n){if(!e)return[];const r=[],s=l=>(n||[]).some(c=>c.to===e.id&&c.toPort===l),o=l=>!!String(l??"").trim(),a=e.type;if(a==="input-text")o(e.value)?e.needsRewrite&&r.push("your own words in place of the instruction in it"):r.push("text");else if(a==="input-image")e.imageUrl||r.push("an image");else if(a==="brand")!o(e.brandName)&&!o(e.colors)&&!o(e.fonts)&&!o(e.tone)&&r.push("brand details");else if(a==="image"){const l=e.mode||"text-to-image";e.model||r.push("a model"),l==="image-to-image"&&!s("image")&&r.push("an image"),!o(e.prompt)&&!s("prompt")&&r.push("a prompt")}else if(a==="video"){const l=e.mode||"text-to-video";e.model||r.push("a model"),l==="image-to-video"&&!s("image")&&r.push("an image"),l==="text-to-video"&&!o(e.prompt)&&!s("prompt")&&r.push("a prompt")}else a==="music"||a==="sfx"?!o(e.prompt)&&!s("text")&&r.push("a prompt"):a==="upscale"||a==="relight"?s("image")||r.push("an image"):a==="background"?(s("image")||r.push("an image"),e.bgMode==="replace"&&!o(e.prompt)&&r.push("a background description")):a==="style"?(s("image")||r.push("an image"),s("style")||r.push("a style reference")):a==="caption"?(s("image")||r.push("an image"),!o(e.caption)&&!s("text")&&r.push("caption text")):a==="assemble"&&(s("clips")||r.push("a clip"));return r}const Cu=e=>{var n,r;return e?e.type==="input-text"?{text:e.value||""}:e.type==="brand"?{text:Em(e)}:e.type==="input-image"?{url:e.imageUrl||void 0}:{url:(n=e.out)==null?void 0:n.url,text:(r=e.out)==null?void 0:r.text}:{}},Cm=(e,n,r)=>{const s=Array.isArray(e==null?void 0:e.clipOrder)?e.clipOrder:[],o=l=>{const c=s.indexOf(l.from);return c<0?1/0:c},a=l=>r(l.from)||{x:0,y:0};return(n||[]).filter(l=>l.to===(e==null?void 0:e.id)&&l.toPort==="clips").sort((l,c)=>o(l)-o(c)||(Number(a(l).y)||0)-(Number(a(c).y)||0)||(Number(a(l).x)||0)-(Number(a(c).x)||0))};
112async function Wh(e,n,r,s){var y,v;const a=Cm(e,n,r).slice(0,H0).map(w=>{var m,M;const C=r(w.from),k=(m=s(w.from))==null?void 0:m.url,E=(M=lt[C==null?void 0:C.type])==null?void 0:M.out;return k&&(E==="video"||E==="image")?{url:k,kind:E,fallbackSeconds:Number(C==null?void 0:C.duration)||5}:null}).filter(Boolean),l=w=>{const C=(n||[]).find(k=>k.to===e.id&&k.toPort===w);return C?s(C.from)||{}:null},c=(y=l("voice"))==null?void 0:y.url,u=(v=l("music"))==null?void 0:v.url,d=(n||[]).filter(w=>w.to===e.id&&w.toPort==="text").map(w=>{var C;return(C=s(w.from))==null?void 0:C.text}).filter(Boolean).join(` 113`),[h,p,b]=await Promise.all([Promise.all(a.map(w=>Qd(w.url,w.kind))),c?Qd(c,"audio"):null,u?Qd(u,"audio"):null]);return Tv({clips:a.map((w,C)=>({...w,...h[C]})),voice:c?{url:c,seconds:p==null?void 0:p.seconds}:null,music:u?{url:u,seconds:b==null?void 0:b.seconds}:null,captions:d||e.captions||"",settings:e})}const Em=e=>{const n=[];return e.brandName&&n.push(`Brand: ${e.brandName}.`),e.colors&&n.push(`Brand colours: ${e.colors}.`),e.fonts&&n.push(`Fonts: ${e.fonts}.`),e.tone&&n.push(`Tone / voice: ${e.tone}.`),n.join(" ")},Yh=["prompt","text","description","input_text","image_url","image","image_urls","images","start_image","input_image","first_frame_image","aspect_ratio","aspect","ratio","duration","duration_seconds","video_length","length","seconds","num_frames","num_images","num_outputs","num_videos","n","batch_size","sync_mode","seed"],hb=[{label:"Sources",types:["input-text","input-image","brand"]},{label:"Generate",types:["image","video"]},{label:"Audio",types:["music","sfx"]},{label:"Refine",types:["upscale","relight","style","background","caption"]},{label:"Finish",types:["assemble"]},{label:"Notes",types:["sticky"]}],Eu=[{key:"amber",bg:"#3a2e12",border:"#a16207",text:"#fde68a"},{key:"violet",bg:"#2a2350",border:"#7c3aed",text:"#ddd6fe"},{key:"emerald",bg:"#10312a",border:"#059669",text:"#a7f3d0"},{key:"sky",bg:"#10293f",border:"#0284c7",text:"#bae6fd"},{key:"rose",bg:"#3a1620",border:"#e11d48",text:"#fecdd3"}],rs=240,$i=24,Rs=48,zo=60,ps=6e3,Pa=e=>Math.round(e/$i)*$i;let Mm=100;const mo=e=>`${e}_${Mm+=1}`,Rk=(...e)=>{for(const n of e)if(Array.isArray(n))for(const r of n){const s=/_(\d+)$/.exec(r&&r.id);if(s){const o=parseInt(s[1],10);Number.isFinite(o)&&o>Mm&&(Mm=o)}}},Pk=e=>{if(!e||typeof e!="object")return e;const n=o=>typeof o=="string"&&o!==""&&!/^https?:\/\//i.test(o.trim()),r=n(e.imageUrl),s=e.out&&typeof e.out=="object"&&n(e.out.url);return!r&&!s?e:{...e,...r?{imageUrl:""}:{},...s?{out:{...e.out,url:void 0}}:{}}},Tk=(e,n)=>{var r;if(!e||typeof e!="object")return e;if(e.type==="text"){const s=typeof((r=e.out)==null?void 0:r.text)=="string"?e.out.text.trim():"",o=String(e.prompt||"").trim(),{model:a,prompt:l,out:c,status:u,jobId:d,pinned:h,dirty:p,...b}=e;return{...b,type:"input-text",title:!e.title||e.title==="AI Text"?"Text":e.title,value:(s||o).slice(0,ps),...s||!o?{}:{needsRewrite:!0}}}if(e.type==="audio"){const s=String(e.text||"").trim();if(!s)return e;const{voiceId:o,text:a,model:l,out:c,status:u,jobId:d,pinned:h,dirty:p,...b}=e;return{...b,type:"input-text",title:!e.title||e.title==="Voiceover"?"Voiceover script":e.title,value:s.slice(0,ps)}}if(e.type==="image"&&(e.model==="product"||e.mode==="product"||!e.mode&&!e.model)){const{jobId:s,...o}=e,a=e.status==="running"&&e.jobId;return{...o,...a?{jobId:e.jobId}:{},mode:n.has(e.id)?"image-to-image":"text-to-image",model:""}}return e},Gh=(e,n)=>{if(Rk(e,n),!Array.isArray(e))return e;const r=new Set;let s=!1;const o=new Set((Array.isArray(n)?n:[]).filter(u=>(u==null?void 0:u.toPort)==="image").map(u=>u.to)),a=e.map(u=>Tk(u,o));a.some((u,d)=>u!==e[d])&&(s=!0);const l=a.filter(u=>u&&typeof u=="object"&<[u.type]);l.length!==e.length&&(s=!0);const c=l.map(u=>{let d=Pk(u);return d.type==="video"&&!d.mode&&o.has(d.id)&&(d={...d,mode:"image-to-video"}),d!==u&&(s=!0),d&&r.has(d.id)?(s=!0,{...d,id:mo(d.type||"node")}):(d&&r.add(d.id),d)});return s?c:e},qh=(e,n)=>{const r=new Map((Array.isArray(e)?e:[]).filter(s=>s&<[s.type]).map(s=>[s.id,s]));return(Array.isArray(n)?n:[]).filter(s=>{if(!s||typeof s!="object"||!r.has(s.from)||!r.has(s.to))return!1;const o=(lt[r.get(s.to).type].inputs||[]).find(a=>a.id===s.toPort);
113return!!o&&ti(o).includes(lt[r.get(s.from).type].out)})},Ak=new Set(["x","y","title","locked","pinned","dirty","status","out","w","h","color","jobId"]),Im=e=>JSON.stringify(Object.keys(e||{}).filter(n=>!Ak.has(n)).sort().map(n=>[n,e[n]])),Mu=(e,n)=>JSON.stringify([(e||[]).map(r=>[r.id,r.type,r.title,Math.round(r.x||0),Math.round(r.y||0),Im(r)]),(n||[]).map(r=>[r.from,r.to,r.toPort])]),Iu=e=>({x:e.x+rs,y:e.y+26}),Xh=(e,n)=>({x:e.x,y:e.y+34+n*24}),$k={"input-text":132,"input-image":152,image:188,video:188,music:188,sfx:188,upscale:188,relight:188,style:200,background:188,brand:150,caption:188,assemble:192,sticky:150},po=e=>$k[e.type]||120;function Fp(e,n,r=po){const s=rs+Rs,o=Rs,a=24,l=24,c={},u={};e.forEach(k=>{c[k.id]=[],u[k.id]=0}),n.forEach(k=>{c[k.from]&&u[k.to]!=null&&(c[k.from].push(k.to),u[k.to]+=1)});const d={...u},h=e.filter(k=>d[k.id]===0).map(k=>k.id),p={};e.forEach(k=>p[k.id]=0);let b=0;for(;h.length&&b++<1e4;){const k=h.shift();for(const E of c[k]||[])p[E]=Math.max(p[E],p[k]+1),--d[E]===0&&h.push(E)}const y={};e.forEach(k=>{var E;(y[E=p[k.id]]||(y[E]=[])).push(k)});const v={};Object.entries(y).forEach(([k,E])=>{E.sort((m,M)=>m.y-M.y||String(m.id).localeCompare(String(M.id))),v[k]=E.reduce((m,M)=>m+r(M)+o,-o)});const w=Math.max(0,...Object.values(v)),C={};return Object.entries(y).forEach(([k,E])=>{const m=Pa(a+Number(k)*s);let M=Pa(l+Math.max(0,(w-v[k])/2));for(const I of E)C[I.id]={x:m,y:Math.round(M)},M+=r(I)+o}),e.map(k=>{var E,m;return{...k,x:((E=C[k.id])==null?void 0:E.x)??k.x,y:((m=C[k.id])==null?void 0:m.y)??k.y}})}function Hc(){const e=[{id:"prompt",type:"input-text",x:0,y:0,title:"Ad Prompt",value:"A photoreal, scroll-stopping UGC product ad photo of a relatable real person using this product in a natural home setting."},{id:"pimg",type:"input-image",x:0,y:0,title:"Product Image",imageUrl:""},{id:"imagegen",type:"image",x:0,y:0,title:"Image Gen",mode:"image-to-image",model:"",aspect:"9x16"},{id:"videogen",type:"video",x:0,y:0,title:"Video Gen",mode:"image-to-video",model:"",aspect:"9x16",duration:"5",prompt:"subtle natural motion, handheld phone camera"}],n=[{id:"e2",from:"prompt",to:"imagegen",toPort:"prompt"},{id:"e3",from:"pimg",to:"imagegen",toPort:"image"},{id:"e4",from:"imagegen",to:"videogen",toPort:"image"}];return{nodes:Fp(e,n),edges:n}}function _k(){return{nodes:[],edges:[]}}function Dk(){const e=[{id:"content",type:"input-image",x:0,y:0,title:"Your image",imageUrl:""},{id:"styleref",type:"input-image",x:0,y:0,title:"Style reference",imageUrl:""},{id:"styler",type:"style",x:0,y:0,title:"Style Transfer",styleStrength:"strong"},{id:"up",type:"upscale",x:0,y:0,title:"Image Upscaler",scale:"2",creativity:.35,resemblance:.6}],n=[{id:"r1",from:"content",to:"styler",toPort:"image"},{id:"r2",from:"styleref",to:"styler",toPort:"style"},{id:"r3",from:"styler",to:"up",toPort:"image"}];return{nodes:Fp(e,n),edges:n}}function Lk(){const e=[{id:"prompt",type:"input-text",x:0,y:0,title:"Ad Prompt",value:"A photoreal, scroll-stopping UGC product ad photo of a relatable real person using this product in a natural home setting."},{id:"pimg",type:"input-image",x:0,y:0,title:"Product Image",imageUrl:""},{id:"imagegen",type:"image",x:0,y:0,title:"Image Gen",mode:"image-to-image",model:"",aspect:"9x16"},{id:"videogen",type:"video",x:0,y:0,title:"Video Gen",mode:"image-to-video",model:"",aspect:"9x16",duration:"5",prompt:"subtle natural motion, handheld phone camera"},{id:"music",type:"music",x:0,y:0,title:"Music",model:"fal-ai/lyria2",duration:"30",prompt:"upbeat modern background music for a product ad"},{id:"ad",type:"assemble",x:0,y:0,title:"Assemble Ad",...Vm,captions:"",clipOrder:["videogen"]}],n=[{id:"f3",from:"prompt",to:"imagegen",toPort:"prompt"},{id:"f4",from:"pimg",to:"imagegen",toPort:"image"},{id:"f5",from:"imagegen",to:"videogen",toPort:"image"},{id:"f7",from:"videogen",to:"ad",toPort:"clips"},{id:"f9",from:"music",to:"ad",toPort:"music"}];return{nodes:Fp(e,n),edges:n}}const Ok=[{key:"product",title:"Product ad",desc:"Your prompt + a product photo â an ad image â a video.",icon:$s,build:Hc},{key:"finished",title:"Finished video ad",desc:"A clip and a music bed, put together as one ad.",icon:Js,build:Lk},{key:"restyle",title:"Restyle & upscale",desc:"Apply a reference look to your image, then upscale.",icon:Li,build:Dk},{key:"blank",title:"Blank canvas",desc:"Start from scratch.",icon:fs,build:_k}];function Vk({open:e,onClose:n,onPick:r}){return e?t.jsx(Yo,{onClose:n,z:"z-[130]",children:t.jsxs("div",{className:"modal-pop-in w-full max-w-lg rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl p-5",onMouseDown:s=>s.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:"New workflow"}),t.jsx("button",{type:"button",onClick:n,className:"w-7 h-7 grid place-items-center rounded-lg text-gray-400 hover:text-white hover:bg-white/5",children:t.jsx(ft,{className:"w-4 h-4"})})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-2.5",children:Ok.map(s=>{const o=s.icon;return t.jsxs("button",{type:"button",onClick:()=>r(s.build),className:"text-left rounded-xl border border-white/10 bg-white/[0.02] p-3.5 hover:border-violet-400/40 hover:bg-white/[0.04] transition",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-7 h-7 grid place-items-center rounded-lg bg-violet-500/15 text-violet-300",children:t.jsx(o,{className:"w-3.5 h-3.5"})}),t.jsx("span",{className:"text-sm font-semibold text-white",children:s.title})]}),t.jsx("p",{className:"text-[11px] leading-snug text-gray-400",children:s.desc})]},s.key)})})]})}):null}function Uk({open:e,onClose:n,isMac:r}){if(!e)return null;const s=r?"â":"Ctrl",o=[["Run flow",`${s} âµ`],["Save workflow",`${s} S`],["Add node","N"],["Search nodes (command palette)","/"],["Add sticky note","S"],["Select / Hand tool","V / H"],["Select all",`${s} A`],["Duplicate",`${s} D`],["Copy / Paste",`${s} C / ${s} V`],["Undo / Redo",`${s} Z / ${s} â§ Z`],["Recenter view","F"],["Zoom in / out","+ / â"],["Delete selected node or link","Del / â«"],["Deselect · cancel · close","Esc"],["Toggle this help","?"]];return t.jsx(Yo,{onClose:n,children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-xl border border-[#27272A] bg-[#16181a] p-5 shadow-2xl",onMouseDown:a=>a.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:"Keyboard shortcuts"}),t.jsx("button",{type:"button",onClick:n,className:"text-gray-400 hover:text-white",children:t.jsx(ft,{className:"w-5 h-5"})})]}),t.jsx("div",{className:"divide-y divide-white/5",children:o.map(([a,l])=>t.jsxs("div",{className:"flex items-center justify-between py-2",children:[t.jsx("span",{className:"text-sm text-gray-300",children:a}),t.jsx("kbd",{className:"px-2 py-1 rounded-md bg-white/[0.06] border border-white/10 text-[11px] font-medium text-gray-200",children:l})]},a))}),t.jsx("p",{className:"mt-3 text-[11px] text-gray-500",children:"Tip: click a connection line to select it, then press Delete to remove it."})]})})}const zk=e=>(e==null?void 0:e.source)==="adflow"||/^AdFlow /.test(String((e==null?void 0:e.title)||""));function Bk({open:e,onClose:n,signedIn:r=!0,onSignUp:s}){const[o,a]=i.useState([]),[l,c]=i.useState("idle"),[u,d]=i.useState(null),[h,p]=i.useState(!1),[b,y]=i.useState(null);i.useEffect(()=>{e||y(null)},[e]);const v=i.useRef(!0);i.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const w=i.useCallback(M=>Jt(`${$t}/api/creatify/jobs`,{origin:"adflow",limit:24,...M?{before:M.before,beforeId:M.beforeId}:{}}),[]),C=M=>({jobs:((M==null?void 0:M.jobs)||[]).filter(zk),next:M!=null&&M.hasMore&&M.nextBefore?{before:M.nextBefore,beforeId:M.nextBeforeId}:null}),k=i.useCallback(async()=>{c("loading");try{const M=await w(null);if(!v.current)return;if(!(M!=null&&M.ok))throw new Error("results");const{jobs:I,next:N}=C(M);a(I),d(N),c("ready")}catch{v.current&&c("error")}},[w]);i.useEffect(()=>{e&&r&&k()},[e,r,k]);const E=async()=>
113{if(!(!u||h)){p(!0);try{const M=await w(u);if(!v.current||!(M!=null&&M.ok))return;const{jobs:I,next:N}=C(M);a(F=>{const R=new Set(F.map(A=>A.id));return[...F,...I.filter(A=>!R.has(A.id))]}),d(N)}catch{}finally{v.current&&p(!1)}}},m=async M=>{try{const I=await Jt(`${$t}/api/creatify/jobs/delete`,{id:M.id});if(!(I!=null&&I.ok))throw new Error((I==null?void 0:I.error)||"Couldn't delete it. Try again.");a(N=>N.filter(F=>F.id!==M.id)),me.success("Result deleted.")}catch(I){me.error((I==null?void 0:I.message)||"Couldn't delete it. Try again.")}};return t.jsxs(G0,{open:e,onClose:n,title:"AdFlow results",icon:t.jsx(Js,{className:"w-4 h-4 text-white/80"}),zClassName:"z-[140]",widthClassName:"sm:w-full sm:max-w-3xl",closeOnEscape:!b,children:[t.jsxs("div",{children:[t.jsx("p",{className:"mb-5 text-sm text-gray-400",children:"Everything your flows have made, whether or not the board was saved."}),r?null:t.jsxs("div",{className:"space-y-3","data-adflow-results-signedout":!0,children:[t.jsx("p",{className:"text-sm text-gray-300",children:"Whatever your flows make shows up here, once you have an account."}),t.jsx("button",{type:"button",onClick:()=>s==null?void 0:s(),className:"w-full px-4 py-2.5 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-sm font-semibold text-white transition-colors",children:"Get Started For Free"})]}),r&&l==="loading"&&!o.length&&t.jsx("div",{className:"text-sm text-gray-400",children:"Loading your resultsâ¦"}),r&&l==="error"&&t.jsxs("div",{className:"text-sm text-gray-300",children:["Couldn't load your results."," ",t.jsx("button",{type:"button",onClick:k,className:"font-semibold underline underline-offset-2",children:"Try again"})]}),r&&l==="ready"&&!o.length&&t.jsx("div",{className:"text-sm text-gray-400",children:"Nothing yet. Whatever your flows make shows up here."}),!!o.length&&t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:o.map(M=>{const I=M.status==="completed"&&!!M.resultUrl,N=si.has(M.status);return t.jsxs("div",{"data-adflow-result":M.id,className:"rounded-xl border border-white/10 bg-white/[0.03] overflow-hidden flex flex-col",children:[t.jsx("div",{className:"aspect-square bg-black/40 grid place-items-center overflow-hidden",children:I&&M.mediaType==="image"?t.jsx("img",{src:M.resultUrl,alt:M.title||"Result",loading:"lazy",className:"w-full h-full object-contain"}):I&&M.mediaType==="video"?t.jsx("video",{src:M.resultUrl,poster:M.thumbnailUrl||void 0,preload:"metadata",controls:!0,playsInline:!0,className:"w-full h-full object-contain"}):I&&M.mediaType==="audio"?t.jsx("audio",{src:M.resultUrl,controls:!0,preload:"none",className:"w-[90%]"}):t.jsx("span",{className:"text-[11px] text-gray-400 px-3 text-center",children:N?"Still being madeâ¦":M.error||"This one didn't work."})}),t.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[11px] text-gray-300 truncate flex-1",children:M.title||"AdFlow result"}),t.jsx("span",{className:"text-[10px] text-gray-500 shrink-0",children:Vd(M.createdAt)}),I&&t.jsx("button",{type:"button",onClick:()=>ec(M.resultUrl,M.title,M.mediaType),title:"Download","aria-label":"Download",className:"shrink-0 text-gray-400 hover:text-white",children:t.jsx(go,{className:"w-3.5 h-3.5"})}),!N&&t.jsx("button",{type:"button",onClick:()=>y(M),title:"Delete","aria-label":"Delete",className:"shrink-0 text-gray-400 hover:text-rose-300",children:t.jsx(ss,{className:"w-3.5 h-3.5"})})]})]},M.id)})}),u&&t.jsx("div",{className:"mt-4 flex justify-center",children:t.jsx("button",{type:"button",onClick:E,disabled:h,className:"px-4 py-2 rounded-full text-xs font-semibold bg-white/[0.06] border border-white/15 text-white hover:bg-white/[0.12] disabled:opacity-50",children:h?"Loadingâ¦":"Load more"})})]}),t.jsx(Kc,{isOpen:!!b,title:"Delete this result?",description:"It's deleted for good. A board that still shows it keeps its copy. Download it first if you want to keep one.",confirmLabel:"Delete",cancelLabel:"Keep it",tone:"danger",onConfirm:()=>{const M=b;y(null),M&&m(M)},onClose:()=>y(null)})]})}function Hk({configured:e,requireUser:n,onSignUp:r,onCredits:s,user:o=null,onOpenInEditor:a,visible:l=!0,onActiveChange:c=null,onRunChange:u=null}
113){var Ws,lr,Ss,Cs,Uo,Es,la,ca,Hr,gr;const d=i.useRef(void 0);d.current===void 0&&(d.current=(()=>{try{if(new URLSearchParams(window.location.search).get("w"))return null;const f=sessionStorage.getItem("adflow:draft"),j=f?JSON.parse(f):null;return j&&Array.isArray(j.nodes)&&j.nodes.length?j:null}catch{return null}})());const h=d.current,p=i.useRef(null);p.current||(p.current=Hc());const b=p.current,y=i.useRef(null),v=i.useRef(null);if(!v.current){const f=h||b,j=Gh(f.nodes,f.edges);v.current={nodes:j,edges:qh(j,f.edges)}}const[w,C]=i.useState(()=>v.current.nodes.map(f=>f.status==="running"&&!f.jobId?{...f,status:void 0}:f)),[k,E]=i.useState(()=>v.current.edges),[m,M]=i.useState((h==null?void 0:h.pan)||{x:16,y:8}),[I,N]=i.useState(typeof(h==null?void 0:h.zoom)=="number"?h.zoom:.7),[F,R]=i.useState(null),[A,V]=i.useState(null),[z,H]=i.useState(null),[ne,se]=i.useState(!1),[pe,ie]=i.useState(null),[O,D]=i.useState({}),[W,oe]=i.useState(null),[we,Re]=i.useState(()=>new Set),[le,Ne]=i.useState(null),ce=async(f,j)=>{if(o)return Jt(`${$t}/api/creatify/fal/${f}`,j);const P=new URLSearchParams(Object.entries(j).filter(([,B])=>B!=null&&B!=="")).toString(),$=await fetch(`${$t}/api/creatify/fal/public-${f}?${P}`);if(!$.ok)throw new Error(`fal ${f} ${$.status}`);return $.json()},Ae=async f=>{if(!(!f||O[f]||W===f)){oe(f);try{const j=await ce("models",{category:f});D(P=>({...P,[f]:Array.isArray(j==null?void 0:j.models)?j.models:[]})),Re(P=>{const $=new Set(P);return $.delete(f),$})}catch{Re(j=>new Set(j).add(f))}finally{oe(null)}}},[De,Ze]=i.useState({}),[Ye,at]=i.useState(null),ut=async f=>{if(!(!f||De[f]!==void 0||Ye===f)){at(f);try{const j=await ce("schema",{modelName:f});Ze(P=>{var $;return{...P,[f]:(($=j==null?void 0:j.model)==null?void 0:$.schema)||null}})}catch{}finally{at(null)}}},[Xe,nt]=i.useState(!1),[xt,J]=i.useState(!1),[Ie,ht]=i.useState(!1),[Et,Ft]=i.useState(!1),[Rt,Pt]=i.useState(!1),[Ht,Gt]=i.useState(null),[Kt,un]=i.useState(!1),[jt,ln]=i.useState(!1);i.useEffect(()=>{l||ln(!1)},[l]);const Je=Kt||w.some(f=>f.status==="running");i.useEffect(()=>{c==null||c(Je)},[Je]),i.useEffect(()=>{u==null||u(Kt)},[Kt]),i.useEffect(()=>()=>{c==null||c(!1),u==null||u(!1)},[]);const Qt=i.useRef(null),rn=i.useRef(.7),Ot=i.useRef({x:16,y:8}),Qe=i.useRef(null),Vt=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||""),[En,An]=i.useState(!1),[Lr,ur]=i.useState(0),rt=i.useRef(w);rt.current=w;const mt=i.useRef(k);mt.current=k;const Ct=i.useRef({past:[],future:[]}),mr=()=>({nodes:rt.current.map(({status:f,out:j,...P})=>JSON.parse(JSON.stringify(P))),edges:JSON.parse(JSON.stringify(mt.current))}),pr=i.useRef(new Map),rr=f=>{const j={};return rt.current.forEach(P=>j[P.id]=P),f.map(P=>{var ae,Y;const $=j[P.id]||pr.current.get(P.id);if(!$)return P;const B=$.status==="done"||$.status==="failed",re=!!$.jobId&&$.status!=="failed";if(!B&&!re)return P;const X={...P,status:$.status,out:$.out,jobId:re?$.jobId:void 0};return((ae=$.out)!=null&&ae.url||(Y=$.out)!=null&&Y.text||re)&&Im($)!==Im(P)&&(X.dirty=!0),X})},qn=25,Z=i.useRef({key:"",t:0}),xe=i.useRef(!1),Le=i.useRef(!1);i.useEffect(()=>()=>{Le.current=!0},[]);const et=()=>{const f=Ct.current;for(f.past.push(mr());f.past.length>qn;)f.past.shift();f.future=[],ur(j=>j+1)},ct=f=>{const j=Date.now(),P=Z.current;(P.key!==f||j-P.t>600)&&et(),Z.current={key:f,t:j}},pt=()=>{if(je())return;const f=Ct.current;if(!f.past.length)return;f.future.push(mr());const j=f.past.pop();C(rr(j.nodes)),E(j.edges),R(null),V(null),ur(P=>P+1)},_t=()=>{if(je())return;const f=Ct.current;if(!f.future.length)return;f.past.push(mr());const j=f.future.pop();C(rr(j.nodes)),E(j.edges),R(null),V(null),ur(P=>P+1)},$n=Ct.current.past.length>0,xn=Ct.current.future.length>0,tt=i.useRef(0),Xn=()=>{Ct.current={past:[],future:[]},pr.current=new Map,tt.current+=1,ur(f=>f+1)},[mn,Ke]=i.useState([]),[ot,qt]=i.useState("select"),[sr,zn]=i.useState((h==null?void 0:h.edgeStyle)==="ortho"?"ortho":"bezier"),[Bn,jn]=i.useState(null),[vt,Mn]=i.useState(null),[fr,or]=i.useState(null),[bo,In]=i.useState(""),[jr,Jn]=i.useState(null),[en,Nr]=i.useState(null),Zn=i.useRef(null),Or=i.useRef(!1),[gn,Hn]=i.useState((h==null?void 0:h.workflowId)||null),[hr,kr]=i.useState((h==null?void 0:h.workflowName)||"Untitled workflow"),[ze,Qn]=i.useState(!!(h!=null&&h.isShared)),[Kn,ar]=i.useState((h==null?void 0:h.shareId)||null),[_n,bn]=i.useState(!1),[Dn,Se]=i.useState([]),[is,Wt]=i.useState(!1),[_o,Tr]=i.useState(!1),[ta,Nt]=i.useState(!1),[qr,Wn]=i.useState(!1),[Vr,gs]=i.useState(""),[Qs,eo]=i.useState(!1),[gt,U]=i.useState(null),[ue,Q]=i.useState(!1);i.useEffect(()=>{const f=w.find(j=>j.id===F);
113f&&(f.type==="video"?Ae(f.mode||"text-to-video"):f.type==="image"&&Ae(f.mode||"text-to-image"))},[F]);const fe=!!gt&&!o,ge=f=>o?!0:(n==null||n(f||"Sign in to continue."),!1),je=()=>Kt?(me.error("The flow is running, press Stop to make changes."),!0):!1,Oe=new Set(["x","y","title","locked","pinned","dirty","status","out","w","h","color","jobId"]),st=f=>{const j=new Set([f]);let P=!0;for(;P;){P=!1;for(const $ of mt.current)j.has($.from)&&!j.has($.to)&&(j.add($.to),P=!0)}C($=>$.map(B=>j.has(B.id)&&!B.dirty?{...B,dirty:!0}:B))},Ee=(f,j)=>{const P=Object.keys(j),$=P.length>0&&P.every(B=>B==="status"||B==="out"||B==="dirty"||B==="jobId");!fe&&!xe.current&&!$&&ct(f+"|"+P.sort().join(",")),C(B=>B.map(re=>re.id===f?{...re,...j}:re)),!fe&&P.some(B=>!Oe.has(B))&&st(f)},tn=i.useRef(new Map),Dt=i.useRef(!1),Ds=async()=>{if(Dt.current)return;Dt.current=!0;const f=Date.now();try{for(;tn.current.size;){const j=Date.now()-f;for(await new Promise(B=>setTimeout(B,j<6e4?5e3:j<5*6e4?1e4:15e3));typeof document<"u"&&document.hidden;)await new Promise(B=>setTimeout(B,2e3));const P=tn.current;for(const[B,re]of[...P]){const X=re.filter(ae=>{var Y;return(Y=ae.cancelled)!=null&&Y.call(ae)||Date.now()>ae.deadline?(ae.resolve(null),!1):!0});X.length?P.set(B,X):P.delete(B)}if(!P.size)break;const $=(B,re)=>{for(const X of P.get(B)||[])X.resolve(re);P.delete(B)};try{const B=[...P.keys()].slice(0,8),re=await Jt(`${$t}/api/creatify/adflow/status`,{ids:B});for(const X of(re==null?void 0:re.jobs)||[])(X.status==="completed"||X.status==="failed")&&$(X.id,X);for(const X of(re==null?void 0:re.gone)||[])$(X,{status:"gone"});for(const X of B){const ae=P.get(X);ae&&(P.delete(X),P.set(X,ae))}}catch{}}}finally{Dt.current=!1}},Xr=(f,j,P)=>new Promise($=>{const B=tn.current.get(f)||[];B.push({resolve:$,deadline:Date.now()+j,cancelled:P}),tn.current.set(f,B),Ds()}),ls=i.useRef(!!o);ls.current=!!o;const Do=i.useRef(!1);o&&(Do.current=!0);const cs=!!o||Do.current;i.useEffect(()=>{const f=setInterval(async()=>{if(!ls.current||typeof document<"u"&&document.hidden)return;const j=(rt.current||[]).filter(P=>P.jobId&&P.status!=="failed"&&!tn.current.has(P.jobId)).slice(0,8);if(j.length)try{const P=await Jt(`${$t}/api/creatify/adflow/status`,{ids:j.map($=>$.jobId)});for(const $ of(P==null?void 0:P.jobs)||[]){const B=(rt.current||[]).find(re=>re.jobId===$.id);B&&($.status==="completed"&&$.resultUrl?Ee(B.id,{status:"done",out:{url:$.resultUrl},jobId:void 0}):$.status==="failed"&&Sr(B.id,$.error||"Generation failed."))}for(const $ of(P==null?void 0:P.gone)||[]){const B=(rt.current||[]).find(re=>re.jobId===$);B&&Ee(B.id,{jobId:void 0,...B.status==="running"?{status:void 0}:{}})}}catch{}},8e3);return()=>clearInterval(f)},[]);const Sr=(f,j)=>{const P=rt.current.find(B=>B.id===f),$=P!=null&&P.out&&(P.out.url||P.out.text)?{url:P.out.url,text:P.out.text}:{};Ee(f,{status:"failed",out:{...$,error:j||"Generation failed."},jobId:void 0,...$.url||$.text?{dirty:!0}:{}})},yo=f=>{const j=new Set(f);for(const $ of rt.current)j.has($.id)&&($.out||$.jobId)&&pr.current.set($.id,{status:$.status,out:$.out,jobId:$.jobId,...$});et(),new Set(mt.current.filter($=>j.has($.from)&&!j.has($.to)).map($=>$.to)).forEach($=>st($)),C($=>$.filter(B=>!j.has(B.id))),E($=>$.filter(B=>!j.has(B.from)&&!j.has(B.to))),R($=>j.has($)?null:$),Ke($=>$.filter(B=>!j.has(B)))},Cr=f=>{if(je())return;if(fe)return ge("Sign in to edit this workflow.");const j=(Array.isArray(f)?f:[f]).filter(P=>{var $;return!(($=rt.current.find(B=>B.id===P))!=null&&$.locked)});j.length&&Gt(j)},bs=f=>Cr([f]),Ls=(f,j)=>(j==="image"?(f.mode="text-to-image",f.model="",f.aspect="9x16"):j==="video"?(f.mode="text-to-video",f.model="",f.aspect="9x16",f.duration="5"):j==="music"?(f.model="fal-ai/lyria2",f.duration="30"):j==="sfx"?f.model=Nu[0].id:j==="upscale"?(f.scale="2",f.creativity=.35,f.resemblance=.6):j==="relight"?(f.relightDir="left",f.keepBg=!0):j==="style"?f.styleStrength="strong":j==="background"?f.bgMode="remove":j==="brand"?(f.brandName="",f.colors="",f.fonts="",f.tone=""):j==="caption"?(f.captionPos="bottom",f.caption=""):j==="assemble"?Object.assign(f,Vm,{captions:""}):j==="input-text"?f.value="":j==="input-image"?f.imageUrl="":j==="sticky"&&(f.text="",f.color="amber",f.w=220,f.h=104),f),Nn=f=>{var ke;if(je())return;if(fe){ge("Sign in to edit this workflow."),nt(!1);return}if(w.length>=zo){me.error(`Node limit reached (${zo}). Delete a node first.`),nt(!1);return}const j=lt[f],P=mo(f),$=w.find(Me=>Me.id===F);let B,re;if($)B=$.x+rs+Rs,re=$.y;else{const Me=(ke=y.current)==null?void 0:ke.getBoundingClientRect();
113B=Pa((-m.x+(Me?Me.width/2:400))/I),re=Pa((-m.y+120)/I)}const X=po({type:f}),ae=(Me,te)=>w.some(_e=>Me<_e.x+rs+Rs&&Me+rs+Rs>_e.x&&te<_e.y+po(_e)+Rs&&te+X+Rs>_e.y);let Y=0;for(;ae(B,re)&&Y++<80;)re+=$i;const he=Ls({id:P,type:f,x:Pa(B),y:Pa(re),title:j.label},f);et(),C(Me=>[...Me,he]),R(P),Ke([P]),nt(!1),On(he)},Fn=(f,j,P,$)=>{var dn,Ut,it;if(je())return;if(fe){ge("Sign in to edit this workflow.");return}if(rt.current.length>=zo){me.error(`Node limit reached (${zo}). Delete a node first.`),Mn(null);return}const B=rt.current.find(Tt=>Tt.id===f),re=lt[$];if(!B||!re)return;const X=((dn=Br(f))==null?void 0:dn.w)||rs;let ae=P==="out"?B.x+X+Rs:B.x-rs-Rs,Y=B.y;const he=po({type:$}),ke=(Tt,wn)=>rt.current.some(an=>Tt<an.x+rs+Rs&&Tt+rs+Rs>an.x&&wn<an.y+po(an)+Rs&&wn+he+Rs>an.y);let Me=0;for(;ke(ae,Y)&&Me++<80;)Y+=$i;const te=mo($),_e=Ls({id:te,type:$,x:Pa(ae),y:Pa(Y),title:re.label},$);P==="out"&&((Ut=lt[B.type])==null?void 0:Ut.out)==="image"&&($==="video"?_e.mode="image-to-video":$==="image"&&(_e.mode="image-to-image",_e.model=""));const He=(it=lt[B.type])==null?void 0:it.out,yt=P==="out"?Kh($,He,{srcType:B.type}):null;yt==="clips"&&(_e.clipOrder=[f]),et(),C(Tt=>[...Tt,_e]),P==="in"&&j==="clips"&&vs(f,te),P==="out"?yt&&E(Tt=>[...Bc(re.inputs.find(ns=>ns.id===yt))?Tt:Tt.filter(ns=>!(ns.to===te&&ns.toPort===yt)),{id:mo("e"),from:f,to:te,toPort:yt}]):E(Tt=>{var ns;return[...Bc((ns=lt[B.type])==null?void 0:ns.inputs.find(Ms=>Ms.id===j))?Tt:Tt.filter(Ms=>!(Ms.to===f&&Ms.toPort===j)),{id:mo("e"),from:te,to:f,toPort:j}]}),R(te),Ke([te]),Mn(null),setTimeout(()=>{const Tt=rt.current.find(wn=>wn.id===te);Tt&&On(Tt)},60)},We=(f,j,P=[f])=>{const $=Object.keys(lt).filter(B=>!lt[B].annotation);return j==="out"?$.filter(B=>(lt[B].inputs||[]).some(re=>ti(re).includes(f))):$.filter(B=>P.includes(lt[B].out))},Ln=i.useRef(null),er=()=>{Ln.current&&(cancelAnimationFrame(Ln.current),Ln.current=null)},Lo=i.useRef("pan"),yn=i.useRef(0),to=(f,j)=>{Ln.current&&cancelAnimationFrame(Ln.current);const P={...Ot.current},$=performance.now(),B=380,re=ae=>1-Math.pow(1-ae,3),X=ae=>{const Y=Math.min(1,(ae-$)/B),he=re(Y);M({x:P.x+(f-P.x)*he,y:P.y+(j-P.y)*he}),Y<1?Ln.current=requestAnimationFrame(X):Ln.current=null};Ln.current=requestAnimationFrame(X)},ds=(f,j,P)=>{Ln.current&&cancelAnimationFrame(Ln.current);const $={...Ot.current},B=rn.current,re=performance.now(),X=420,ae=he=>1-Math.pow(1-he,3),Y=he=>{const ke=Math.min(1,(he-re)/X),Me=ae(ke);N(Math.round((B+(P-B)*Me)*1e3)/1e3),M({x:$.x+(f-$.x)*Me,y:$.y+(j-$.y)*Me}),ke<1?Ln.current=requestAnimationFrame(Y):Ln.current=null};Ln.current=requestAnimationFrame(Y)},On=f=>{var B;const j=(B=y.current)==null?void 0:B.getBoundingClientRect();if(!j||!f)return;const P=f.w||rs,$=po(f);to(j.width/2-(f.x+P/2)*I,Zr()?12-f.y*I:j.height/2-(f.y+$/2)*I)},no=f=>{var P;const j=rt.current.find($=>$.id===f);return j?(P=lt[j.type])==null?void 0:P.out:null},ys=(f,j,P)=>{var ae;if(f===j||je())return;const $=lt[(ae=rt.current.find(Y=>Y.id===j))==null?void 0:ae.type],B=$==null?void 0:$.inputs.find(Y=>Y.id===P);if(!B)return;if(!ti(B).includes(no(f))){me.error(`That output doesn't fit the "${B.label}" input.`);return}if(((Y,he)=>{const ke=new Set,Me=[Y];for(;Me.length;){const te=Me.pop();if(te===he)return!0;ke.has(te)||(ke.add(te),mt.current.filter(_e=>_e.from===te).forEach(_e=>Me.push(_e.to)))}return!1})(j,f)){me.error("That connection would create a loop.");return}if(mt.current.some(Y=>Y.from===f&&Y.to===j&&Y.toPort===P))return;et(),E(Y=>Y.some(ke=>ke.from===f&&ke.to===j&&ke.toPort===P)?Y:[...Bc(B)?Y:Y.filter(ke=>!(ke.to===j&&ke.toPort===P)),{id:mo("e"),from:f,to:j,toPort:P}]),P==="clips"&&vs(j,f);const X=rt.current.find(Y=>Y.id===j);(X==null?void 0:X.type)==="video"&&P==="image"&&!X.model&&(X.mode||"text-to-video")==="text-to-video"&&(C(Y=>Y.map(he=>he.id===j?{...he,mode:"image-to-video"}:he)),Ae("image-to-video")),st(j)},vs=(f,j)=>C(P=>P.map($=>{if($.id!==f||$.type!=="assemble")return $;const B=X=>P.find(ae=>ae.id===X),re=Cm($,mt.current,B).map(X=>X.from).filter(X=>X!==j);return{...$,clipOrder:[...re,j]}})),vo=(f,j)=>{var re,X,ae;if(!f||f===j)return;const P=rt.current.find(Y=>Y.id===j);if(!P||(re=lt[P.type])!=null&&re.annotation)return;const $=no(f),B=Kh(P.type,$,{srcType:(X=rt.current.find(Y=>Y.id===f))==null?void 0:X.type,taken:mt.current.filter(Y=>Y.to===j).map(Y=>Y.toPort)});if(!B){me.error(`That output doesn't fit any input on "${P.title||((ae=lt[P.type])==null?void 0:ae.label)}".`);return}ys(f,j,B)},Jr=f=>{if(je())return;if(fe){ge("Sign in to edit this workflow.");return}const j=mt.current.find(P=>P.id===f);et(),E(P=>P.filter($=>$.id!==f)),V(P=>P===f?null:P),j&&st(j.to)},Os=(f,j,P)=>{if(je())return;if(fe){ge("Sign in to edit this workflow.");return}const $=P==="out"?[...new Set(mt.current.filter(B=>B.from===f).map(B=>B.to))]:[];et(),E(B=>B.filter(re=>P==="out"?re.from!==f:!(re.to===f&&re.toPort===j))),P==="in"&&st(f),$.forEach(B=>st(B))},Xt=(f,j)=>k.filter(P=>P.to===f&&P.toPort===j).map(P=>{var $;return(($=w.find(B=>
113B.id===P.from))==null?void 0:$.title)||"a node"}),wo=f=>{fe||f.locked||(In(f.title||""),or(f.id))},Vs=()=>{const f=fr;if(or(null),!f)return;const j=bo.trim().slice(0,60),P=rt.current.find($=>$.id===f);!j||!P||j===P.title||Ee(f,{title:j})},ro=()=>mn.length?mn:F?[F]:[],so=()=>{const f=rt.current.map(j=>j.id);Ke(f),R(f.length===1?f[0]:null),V(null),H(null)},Us=(f,j=28,P=28)=>{const $=new Set(f),B=rt.current.filter(Y=>$.has(Y.id));if(!B.length)return null;const re={},X=B.map(Y=>{const he=mo(Y.type);return re[Y.id]=he,{...JSON.parse(JSON.stringify(Y)),id:he,x:(Y.x||0)+j,y:(Y.y||0)+P,status:void 0,out:void 0,jobId:void 0,locked:!1}});for(const Y of X)Array.isArray(Y.clipOrder)&&(Y.clipOrder=Y.clipOrder.map(he=>re[he]||he));const ae=mt.current.filter(Y=>$.has(Y.from)&&$.has(Y.to)).map(Y=>({id:mo("e"),from:re[Y.from],to:re[Y.to],toPort:Y.toPort}));return{clones:X,newEdges:ae}},zs=()=>{if(je())return;if(fe)return ge("Sign in to edit this workflow.");const f=ro();if(!f.length)return;if(rt.current.length+f.length>zo)return me.error(`Node limit reached (${zo}).`);const j=Us(f);if(!j)return;et(),C($=>[...$,...j.clones]),E($=>[...$,...j.newEdges]);const P=j.clones.map($=>$.id);Ke(P),R(P.length===1?P[0]:null)},$e=(f,j,P)=>{if(je())return;if(fe)return ge("Sign in to edit this workflow.");const $=rt.current.find(he=>he.id===f);if(!$)return;const B=j.length;if(!B)return;if(rt.current.length+B>zo)return me.error(`Node limit reached (${zo}).`);const re=mt.current.filter(he=>he.to===f),X=po($);et();const ae=[],Y=[];j.forEach((he,ke)=>{const Me=mo($.type);ae.push({...$,...he,id:Me,x:$.x,y:$.y+(ke+1)*(X+Rs),status:void 0,out:void 0,jobId:void 0,dirty:!0,pinned:!1,locked:!1,title:P($,he,ke)}),re.forEach(te=>Y.push({id:mo("e"),from:te.from,to:Me,toPort:te.toPort}))}),C(he=>[...he,...ae]),E(he=>[...he,...Y]),Ke(ae.map(he=>he.id)),R(ae.length===1?ae[0].id:null),me.success(`Added ${B} variation${B>
1131?"s":""}.`)},kt=(f,j)=>{const P=f.seed!=null&&f.seed!==""&&Number.isFinite(Number(f.seed))?Number(f.seed):null,$=Array.from({length:j},(B,re)=>({seed:P!=null?P+re+1:void 0}));$e(f.id,$,(B,re,X)=>`${B.title||lt[B.type].label} v${X+2}`)},on=f=>{const j=["9x16","1x1","16x9"].filter(P=>P!==(f.aspect||"9x16"));$e(f.id,j.map(P=>({aspect:P})),(P,$)=>`${P.title||lt[P.type].label} ${$.aspect.replace("x",":")}`)},kn=()=>{const f=ro();if(!f.length)return;const j=new Set(f);Zn.current={nodes:rt.current.filter(P=>j.has(P.id)).map(P=>JSON.parse(JSON.stringify(P))),edges:mt.current.filter(P=>j.has(P.from)&&j.has(P.to)).map(P=>({...P}))},me.success(`Copied ${f.length} node${f.length>1?"s":""}.`)},ws=()=>{var re;if(je())return;if(fe)return ge("Sign in to edit this workflow.");const f=Zn.current;if(!((re=f==null?void 0:f.nodes)!=null&&re.length))return;if(rt.current.length+f.nodes.length>zo)return me.error(`Node limit reached (${zo}).`);const j={},P=f.nodes.map(X=>{const ae=mo(X.type);return j[X.id]=ae,{...JSON.parse(JSON.stringify(X)),id:ae,x:(X.x||0)+28,y:(X.y||0)+28,status:void 0,out:void 0,jobId:void 0,locked:!1}});for(const X of P)Array.isArray(X.clipOrder)&&(X.clipOrder=X.clipOrder.map(ae=>j[ae]||ae));const $=f.edges.map(X=>({id:mo("e"),from:j[X.from],to:j[X.to],toPort:X.toPort}));et(),C(X=>[...X,...P]),E(X=>[...X,...$]);const B=P.map(X=>X.id);Ke(B),R(B.length===1?B[0]:null)},oo=()=>Cr(ro()),Oo=f=>{if(fe)return ge("Sign in to edit this workflow.");et(),C(j=>j.map(P=>P.id===f?{...P,locked:!P.locked}:P))},Bs=async(f,j)=>{if(j){if(fe){ge("Sign in to edit this workflow.");return}if(ge("Sign in to upload your image.")){if(!$m(j)){qo({code:"unsupported-file-type"});return}try{const P=await ii(j);P?Ee(f,{imageUrl:P}):me.error("Upload failed, paste a URL in the panel.")}catch(P){qo(P,"Couldn't upload that image.")}}}},[ao,na]=i.useState(!1),tc=async f=>{if(!(!a||ao||!f)){na(!0);try{const j=$=>rt.current.find(B=>B.id===$),P=await Wh(f,mt.current,j,$=>Cu(j($)));if(P.error){me.error(P.error);return}a({title:f.title||"Assembled ad",editDoc:P.doc})}finally{na(!1)}}},io=(f,j)=>{var $;const P=($=y.current)==null?void 0:$.getBoundingClientRect();return P?{x:(f-P.left-m.x)/I,y:(j-P.top-m.y)/I}:{x:0,y:0}},jo=i.useRef(null),js=i.useRef(null);if(js.current===null)try{js.current=!!((lr=(Ws=window.matchMedia)==null?void 0:Ws.call(window,"(hover: none)"))!=null&&lr.matches)}catch{js.current=!1}const Ur=f=>(f==null?void 0:f.pointerType)==="touch"||(f==null?void 0:f.pointerType)==="pen"&&js.current,ja=i.useRef(0),ra=f=>{var j;return((j=f==null?void 0:f.nativeEvent)==null?void 0:j.pointerType)==="touch"||Ns.current.size>0||Date.now()-ja.current<1200},Zr=()=>{var f,j;try{return!!((j=(f=window.matchMedia)==null?void 0:f.call(window,"(max-width: 639px)"))!=null&&j.matches)}catch{return!1}},No=i.useRef(null),gi=f=>{var ke,Me,te;if(!Zr())return;const j=rt.current.find(_e=>_e.id===f),P=(ke=y.current)==null?void 0:ke.getBoundingClientRect();if(!j||!P||(Me=lt[j.type])!=null&&Me.annotation)return;const $=rn.current,B=Ot.current,re=j.y*$+B.y,X=j.x*$+B.x,ae=(j.w||rs)*$,Y=P.height*.42-12,he=Math.min((((te=Br(j.id))==null?void 0:te.h)||po(j))*$,Y);re>=8&&re+he<=Y&&X>=0&&X+ae<=P.width||to(P.width/2-ae/2-j.x*$,12-j.y*$)},Qr=(f,{move:j,end:P,longPress:$}={})=>
113{const B=Ur(f),re=f.pointerId,X=f.clientX,ae=f.clientY;let Y=!1,he=!1;const ke=Ut=>!B||Ut.pointerId===re,Me=Ut=>{ke(Ut)&&(!Y&&Math.hypot(Ut.clientX-X,Ut.clientY-ae)>8&&(Y=!0,clearTimeout(dn)),j==null||j(Ut,Y))},te=()=>he?!1:(he=!0,clearTimeout(dn),window.removeEventListener(B?"pointermove":"mousemove",Me),window.removeEventListener(B?"pointerup":"mouseup",_e),window.removeEventListener("pointercancel",He),jo.current===yt&&(jo.current=null),!0),_e=Ut=>{if(!ke(Ut)||!te())return;P==null||P(Ut,!1);const it=No.current;No.current=null,it&&!Y&&gi(it)},He=Ut=>{B&&Ut.pointerId===re&&te()&&(P==null||P(Ut,!0))},yt={cancel:()=>{te()&&(P==null||P(null,!0))}},dn=B&&$?setTimeout(()=>{Y||!te()||(P==null||P(null,!0),$(X,ae))},480):null;return window.addEventListener(B?"pointermove":"mousemove",Me),window.addEventListener(B?"pointerup":"mouseup",_e),B&&window.addEventListener("pointercancel",He),jo.current=yt,yt},Ha=f=>{var j;return!!((j=f==null?void 0:f.closest)!=null&&j.call(f,"input, textarea, select, button, a, label, video, audio, [contenteditable='true'], [data-adf-nodrag]"))},Hs=(f,j,P)=>{mn.includes(f)||(R(f),Ke([f])),jn({x:j,y:P,type:"node",nodeId:f})},Ns=i.useRef(new Map),ks=i.useRef(null),[Na,Vo]=i.useState(()=>{var f,j;try{return!!((j=(f=window.matchMedia)==null?void 0:f.call(window,"(pointer: coarse)"))!=null&&j.matches)&&!sessionStorage.getItem("adflow:touchHint")}catch{return!1}});i.useEffect(()=>{if(!Na)return;try{sessionStorage.setItem("adflow:touchHint","1")}catch{}const f=setTimeout(()=>Vo(!1),7e3);return()=>clearTimeout(f)},[Na]);const zr=()=>{var ae,Y;(ae=jo.current)==null||ae.cancel(),Vo(!1);const[f,j]=[...Ns.current.values()],P=(Y=y.current)==null?void 0:Y.getBoundingClientRect();if(!f||!j||!P)return;er();const $=rn.current,B=Ot.current,re=(f.x+j.x)/2-P.left,X=(f.y+j.y)/2-P.top;ks.current={dist:Math.max(1,Math.hypot(f.x-j.x,f.y-j.y)),z0:$,world:{x:(re-B.x)/$,y:(X-B.y)/$}}};i.useEffect(()=>{const f=P=>{var Me;const $=Ns.current;if(!$.has(P.pointerId))return;$.set(P.pointerId,{x:P.clientX,y:P.clientY});const B=ks.current;if(!B||$.size<2)return;const[re,X]=[...$.values()],ae=(Me=y.current)==null?void 0:Me.getBoundingClientRect();if(!ae)return;const Y=Math.min(1.4,Math.max(.35,B.z0*Math.hypot(re.x-X.x,re.y-X.y)/B.dist)),he=(re.x+X.x)/2-ae.left,ke=(re.y+X.y)/2-ae.top;N(Math.round(Y*1e3)/1e3),M({x:he-B.world.x*Y,y:ke-B.world.y*Y})},j=P=>{P.pointerType==="touch"&&(ja.current=Date.now());const $=Ns.current;$.delete(P.pointerId)&&($.size<2?ks.current=null:ks.current&&zr())};return window.addEventListener("pointermove",f),window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j)}},[]);const Te=f=>{var j,P;f.pointerType==="touch"&&(ja.current=Date.now()),Ur(f)&&f.currentTarget.contains(f.target)&&((P=(j=f.target)==null?void 0:j.closest)!=null&&P.call(j,"[data-adf-ui]")||(Ns.current.set(f.pointerId,{x:f.clientX,y:f.clientY}),Ns.current.size===2&&!ks.current&&zr()))},Yn=f=>{var Y,he;if(!Ur(f)||ks.current||!f.currentTarget.contains(f.target))return;const j=f.target;if((Y=j==null?void 0:j.closest)!=null&&Y.call(j,"[data-adf-ui]"))return;const P=(he=j==null?void 0:j.closest)==null?void 0:he.call(j,"[data-node-id]");if(Ha(j))return;f.preventDefault(),nt(!1),jn(null),Mn(null),er();const $=(P==null?void 0:P.getAttribute("data-node-id"))||null,B=f.clientX,re=f.clientY,X={...Ot.current};let ae=!1;Qr(f,{move:(ke,Me)=>{!Me&&!ae||(ae=!0,M({x:X.x+(ke.clientX-B),y:X.y+(ke.clientY-re)}))},end:(ke,Me)=>{Me||ae||(V(null),H(null),R($),Ke($?[$]:[]))},longPress:(ke,Me)=>$?Hs($,ke,Me):jn({x:ke,y:Me,type:"canvas",canvasPt:io(ke,Me)})})},Rn=f=>j=>{!Ur(j)||ks.current||Ha(j.target)||lo(f)(j)},us=(f,j)=>P=>{!Ur(P)||ks.current||(P.stopPropagation(),P.preventDefault(),!(fe||Kt)&&Qr(P,{end:($,B)=>{B||!$||Math.hypot($.clientX-P.clientX,$.clientY-P.clientY)>12||(er(),Mn({nodeId:f.id,port:j.id,kind:j.kind,accepts:ti(j),dir:"in",x:$.clientX,y:$.clientY}))}}))},sa=f=>j=>{!Ur(j)||ks.current||yi(f)(j)},lo=f=>j=>{if(j.stopPropagation(),jn(null),V(null),H(null),Mn(null),er(),j.shiftKey||j.metaKey||j.ctrlKey){const ke=mn.length?mn:F?[F]:[],Me=ke.includes(f)?ke.filter(te=>te!==f):[...ke,f];Ke(Me),R(Me.length===1?Me[0]:null);return}const P=mn.length>1&&mn.includes(f);P||(R(f),Ke([f]));const $=Ur(j),B=()=>{$&&(j.preventDefault(),Qr(j,{longPress:(ke,Me)=>Hs(f,ke,Me)}))};if(fe||Kt)return B();j.preventDefault();const re=j.clientX,X=j.clientY,ae=(P?mn:[f]).filter(ke=>{var Me;return!((Me=w.find(te=>te.id===ke))!=null&&Me.locked)});if(!ae.length)return B();document.body.style.userSelect="none";const Y={};for(const ke of ae){const Me=w.find(te=>te.id===ke);Me&&(Y[ke]={x:Number.isFinite(+Me.x)?+Me.x:0,y:Number.isFinite(+Me.y)?+Me.y:0})}let he=!1;Qr(j,{move:(ke,Me)=>{if($&&!Me)return;he||(he=!0,et());const te=(ke.clientX-re)/I,_e=(ke.clientY-X)/I;C(He=>He.map(yt=>Y[yt.id]?{...yt,x:Math.round(Y[yt.id].x+te),y:Math.round(Y[yt.id].y+_e)}:yt))},end:()=>{document.body.style.userSelect=""},longPress:(ke,Me)=>Hs(f,ke,Me)})},bi=f=>{if(f.button!==0&&f.button!==1)return;if(nt(!1),jn(null),Mn(null),er(),ot==="hand"||Or.current||f.button===1){f.preventDefault(),document.body.style.userSelect="none";const re=f.clientX,X=f.clientY,ae={...Ot.current};Qr(f,{move:Y=>M({x:ae.x+(Y.clientX-re),y:ae.y+(Y.clientY-X)}),end:()=>{document.body.style.userSelect=""}});return}f.shiftKey||(R(null),Ke([]),V(null),H(null));const P=io(f.clientX,f.clientY);Nr({x0:P.x,y0:P.y,x1:P.x,y1:P.y}),document.body.style.userSelect="none",Qr(f,{move:re=>{const X=io(re.clientX,re.clientY);Nr({x0:P.x,y0:P.y,x1:X.x,y1:X.y})},end:(re,X)=>{if(document.body.style.userSelect="",X||!re){Nr(null);return}const ae=io(re.clientX,re.clientY),Y=Math.min(P.x,ae.x),he=Math.max(P.x,ae.x),ke=Math.min(P.y,ae.y),Me=Math.max(P.y,ae.y);if(Nr(null),Math.abs(he-Y)<5&&Math.abs(Me-ke)<5)return;const te=rt.current.filter(He=>{var Ut;const yt=He.w||rs,dn=((Ut=Br(He.id))==null?void 0:Ut.h)||po(He);return He.x<he&&He.x+yt>Y&&He.y<Me&&He.y+dn>ke}).map(He=>He.id),_e=f.shiftKey?Array.from(new Set([...mn,...te])):te;Ke(_e),R(_e.length===1?_e[0]:null)}})},ka=f=>j=>{if(j.stopPropagation(),j.preventDefault(),fe){ge("Sign in to edit this workflow.");return}
113const P=j.clientX,$=j.clientY,B=f.w||220,re=f.h||104;document.body.style.userSelect="none";let X=!1;Qr(j,{move:ae=>{X||(X=!0,xe.current=!0,et());const Y=Math.max(160,Math.round(B+(ae.clientX-P)/I)),he=Math.max(80,Math.round(re+(ae.clientY-$)/I));Ee(f.id,{w:Y,h:he})},end:()=>{xe.current=!1,document.body.style.userSelect=""}})},yi=f=>j=>{if(j.stopPropagation(),Kt)return;if(fe){ge("Sign in to edit this workflow.");return}j.preventDefault(),er(),Mn(null),document.body.style.userSelect="none";const P=j.clientX,$=j.clientY,B=io(j.clientX,j.clientY);ie({from:f,x:B.x,y:B.y});const re=Ur(j);let X=!1;Qr(j,{move:ae=>{(Math.abs(ae.clientX-P)>4||Math.abs(ae.clientY-$)>4)&&(X=!0);const Y=io(ae.clientX,ae.clientY);ie(he=>he&&{...he,x:Y.x,y:Y.y})},end:(ae,Y)=>{var te,_e,He,yt,dn,Ut;if(document.body.style.userSelect="",Y||!ae){ie(null);return}if(setTimeout(()=>ie(null),0),!X){const it=(_e=lt[(te=rt.current.find(Tt=>Tt.id===f))==null?void 0:te.type])==null?void 0:_e.out;Mn({nodeId:f,port:null,kind:it,dir:"out",x:ae.clientX,y:ae.clientY});return}const he=(He=document.elementFromPoint)==null?void 0:He.call(document,ae.clientX,ae.clientY),ke=(yt=he==null?void 0:he.closest)==null?void 0:yt.call(he,"[data-adf-in]");if(ke){re&&ys(f,ke.getAttribute("data-adf-in"),ke.getAttribute("data-adf-port"));return}const Me=(Ut=(dn=he==null?void 0:he.closest)==null?void 0:dn.call(he,"[data-node-id]"))==null?void 0:Ut.getAttribute("data-node-id");Me&&Me!==f&&vo(f,Me)}})},vn=(f,j)=>P=>{P.stopPropagation(),pe&&ys(pe.from,f,j),ie(null)},es=f=>N(j=>Math.min(1.4,Math.max(.35,Math.round((j+f)*1e3)/1e3))),oa=i.useRef(null),co=i.useRef(0),ko=()=>{co.current=0;const f=oa.current;if(oa.current=null,!f)return;const j=rn.current,P=Ot.current;if(f.dz!==1){const $=Math.min(1.4,Math.max(.35,j*f.dz));M({x:f.cx-(f.cx-P.x)*($/j),y:f.cy-(f.cy-P.y)*($/j)}),N(Math.round($*1e3)/1e3)}else(f.dx||f.dy)&&M({x:P.x-f.dx,y:P.y-f.dy})},ms=f=>{const j=oa.current||{dz:1,dx:0,dy:0,cx:0,cy:0};f(j),oa.current=j,co.current||(co.current=requestAnimationFrame(ko))},Br=f=>{var P;const j=(P=y.current)==null?void 0:P.querySelector(`[data-node-id="${f}"]`);return j?{w:j.offsetWidth,h:j.offsetHeight}:null},So=({animate:f=!0}={})=>{var _e;if(!w.length){f?ds(16,8,.7):(N(.7),M({x:16,y:8}));return}const j=(_e=y.current)==null?void 0:_e.getBoundingClientRect(),P=(j==null?void 0:j.width)||1100,$=(j==null?void 0:j.height)||680;let B=1/0,re=1/0,X=-1/0,ae=-1/0;for(const He of w){const yt=Br(He.id),dn=(yt==null?void 0:yt.w)||rs,Ut=(yt==null?void 0:yt.h)||po(He);B=Math.min(B,He.x),re=Math.min(re,He.y),X=Math.max(X,He.x+dn),ae=Math.max(ae,He.y+Ut)}const Y=60,he=Math.max(.35,Math.min(1.2,Math.min(P/(X-B+Y*2),$/(ae-re+Y*2)))),ke=Math.round(he*100)/100,Me=Math.round((P-(B+X)*ke)/2),te=Math.round(($-(re+ae)*ke)/2);f?ds(Me,te,ke):(N(ke),M({x:Me,y:te}))};i.useEffect(()=>{const f=j=>{var P;return(P=Qt.current)==null?void 0:P.call(Qt,j)};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[]),i.useEffect(()=>{const f=document.documentElement,j=document.body,P=f.style.overscrollBehaviorX,$=j.style.overscrollBehaviorX;if(l)return f.style.overscrollBehaviorX="none",j.style.overscrollBehaviorX="none",()=>{f.style.overscrollBehaviorX=P,j.style.overscrollBehaviorX=$}},[l]),i.useEffect(()=>{l||An(!1)},[l]);const xr=i.useRef(null);i.useEffect(()=>{const f=()=>{var j;return(j=xr.current)==null?void 0:j.call(xr)};return window.addEventListener("pagehide",f),()=>window.removeEventListener("pagehide",f)},[]),i.useEffect(()=>{if(!En)return;const f=document.body,j=document.documentElement,P={bodyOverflow:f.style.overflow,htmlOverscroll:j.style.overscrollBehavior,bodyOverscroll:f.style.overscrollBehavior};return f.style.overflow="hidden",j.style.overscrollBehavior="none",f.style.overscrollBehavior="none",()=>{f.style.overflow=P.bodyOverflow,j.style.overscrollBehavior=P.htmlOverscroll,f.style.overscrollBehavior=P.bodyOverscroll}},[En]),i.useEffect(()=>{const f=y.current;if(!f)return;const j=P=>{const $=P.ctrlKey||P.metaKey;if(er(),!$){const re=P.timeStamp||0,X=re-yn.current<250;if(yn.current=re,!X){let ae="pan",Y=P.target;for(;Y&&Y!==f;){const he=Y.tagName;
113if(he==="TEXTAREA"||he==="INPUT"||he==="SELECT"){ae="scroll";break}if(Y instanceof Element){const ke=getComputedStyle(Y).overflowY;if((ke==="auto"||ke==="scroll")&&Y.scrollHeight>Y.clientHeight+1){ae="scroll";break}}Y=Y.parentElement}Lo.current=ae}if(Lo.current==="scroll")return}P.preventDefault();const B=f.getBoundingClientRect();if(P.ctrlKey||P.metaKey){const re=P.clientX-B.left,X=P.clientY-B.top;ms(ae=>{ae.dz*=Math.exp(-P.deltaY*.0015),ae.cx=re,ae.cy=X})}else ms(re=>{re.dx+=P.deltaX,re.dy+=P.deltaY})};return f.addEventListener("wheel",j,{passive:!1}),()=>{f.removeEventListener("wheel",j),co.current&&cancelAnimationFrame(co.current)}},[En,ue&&!o]),i.useEffect(()=>{if(!Bn&&!vt)return;const f=j=>{var P,$;($=(P=j.target)==null?void 0:P.closest)!=null&&$.call(P,"[data-adf-menu]")||(j.preventDefault(),j.stopPropagation())};return window.addEventListener("wheel",f,{passive:!1,capture:!0}),window.addEventListener("touchmove",f,{passive:!1,capture:!0}),()=>{window.removeEventListener("wheel",f,{capture:!0}),window.removeEventListener("touchmove",f,{capture:!0})}},[Bn,vt]);const vi=i.useRef(!!o);o&&(vi.current=!0);const Ka=vi.current&&!o;xr.current=()=>{if(!Ka&&!gt&&!new URLSearchParams(window.location.search).get("w"))try{sessionStorage.setItem("adflow:draft",JSON.stringify({nodes:rt.current,edges:mt.current,pan:Ot.current,zoom:rn.current,workflowId:gn,workflowName:hr,isShared:ze,shareId:Kn}))}catch{}},i.useEffect(()=>{if(gt||new URLSearchParams(window.location.search).get("w"))return;const f=setTimeout(()=>{var j;return(j=xr.current)==null?void 0:j.call(xr)},350);return()=>clearTimeout(f)},[w,k,m,I,gn,hr,ze,Kn,gt]);const Sa=async(f=null)=>{var sn,tr,cr,da,$p,_p,Dp,Lp;if(!ge("Sign in to run this workflow."))return;Le.current=!1,un(!0);const j=tt.current,P=()=>tt.current===j,$=(ye,ve)=>{P()&&Ee(ye,ve)},B=(ye,ve)=>{P()&&Sr(ye,ve)};let re=null;if(f){re=new Set([f]);let ye=!0;for(;ye;){ye=!1;for(const ve of k)re.has(ve.to)&&!re.has(ve.from)&&(re.add(ve.from),ye=!0)}}let X=null,ae=null;for(const ye of w){if(re&&!re.has(ye.id)||(sn=lt[ye.type])!=null&&sn.annotation||!!((tr=ye.out)!=null&&tr.url||(cr=ye.out)!=null&&cr.text)&&(!ye.dirty||ye.pinned)&&ye.id!==f)continue;const nn=dl(ye,k);if(nn.length){X=ye,ae=nn;break}}if(X){un(!1),R(X.id),Ke([X.id]),On(X),me.error(`"${X.title||lt[X.type].label}" needs ${ae.join(" and ")} before it can run.`);return}const Y={},he=ye=>!re||re.has(ye),ke=w.filter(ye=>he(ye.id)).map(ye=>ye.id),Me=new Set(ke),te={},_e={};ke.forEach(ye=>{te[ye]=0,_e[ye]=[]}),k.forEach(ye=>{Me.has(ye.from)&&Me.has(ye.to)&&(te[ye.to]+=1,_e[ye.from].push(ye))});const He={};ke.forEach(ye=>He[ye]=[]),k.forEach(ye=>{Me.has(ye.from)&&Me.has(ye.to)&&He[ye.to].push(ye.from)});const yt=[];{const ye={...te},ve=ke.filter(nn=>ye[nn]===0);for(;ve.length;){const nn=ve.shift();yt.push(nn),(_e[nn]||[]).forEach(br=>{--ye[br.to]===0&&ve.push(br.to)})}}const dn={};w.forEach(ye=>dn[ye.id]=ye);const Ut=ke.filter(ye=>{var ve,nn;return!yt.includes(ye)&&!((nn=lt[(ve=dn[ye])==null?void 0:ve.type])!=null&&nn.annotation)});if(Ut.length){const ye=dn[Ut[0]];un(!1),R(ye.id),Ke([ye.id]),On(ye),me.error(`"${ye.title||((da=lt[ye.type])==null?void 0:da.label)||"A node"}" is part of a loop, so it can never run. Remove one of the connections in the loop.`);return}const it=new Set,Tt=new Set;for(const ye of yt){const ve=dn[ye];if(!ve||($p=lt[ve.type])!=null&&$p.annotation)continue;if(ve.type==="input-text"||ve.type==="input-image"||ve.type==="brand"){ve.dirty&&Tt.add(ye);continue}const nn=!!((_p=ve.out)!=null&&_p.url||(Dp=ve.out)!=null&&Dp.text),br=ve.pinned&&nn,Kr=(He[ye]||[]).some(Eo=>Tt.has(Eo));ye===f?(it.add(ye),Tt.add(ye)):br||(ve.dirty||!nn||Kr)&&(it.add(ye),Tt.add(ye))}if(it.size===0){un(!1),me.success("Everything's already up to date.");return}C(ye=>ye.map(ve=>{if(!it.has(ve.id))return ve;const nn=ve.jobId&&ve.status!=="failed"&&!ve.dirty,br=ve.out&&(ve.out.url||ve.out.text)?{url:ve.out.url,text:ve.out.text}:void 0;return{...ve,status:void 0,out:br,...nn?{}:{jobId:void 0}}}));const wn=new Set,an=new Set,ns=[],Ms=(ye,ve=!1)=>{const nn=[ye];for(;nn.length;){const br=nn.pop();
113(_e[br]||[]).forEach(Kr=>{wn.has(Kr.to)||(wn.add(Kr.to),ve&&an.add(Kr.to),nn.push(Kr.to))})}},g=()=>w;let _=Promise.resolve();const G=(ye,ve=6*60*1e3)=>Xr(ye,ve,()=>Le.current),de=async ye=>{var Op,Vp,Up,zp;const ve=g().find(Lt=>Lt.id===ye);if(!ve||(Op=lt[ve.type])!=null&&Op.annotation)return!0;if(wn.has(ye))return an.has(ye)?"pending":(B(ye,"Skipped, an upstream step failed."),!1);if(!(ve.type==="input-text"||ve.type==="input-image"||ve.type==="brand")&&!it.has(ye))return Y[ye]={url:(Vp=ve.out)==null?void 0:Vp.url,text:(Up=ve.out)==null?void 0:Up.text},!0;if(ve.type==="input-text")return Y[ye]={text:ve.value||""},ve.dirty&&$(ye,{dirty:!1}),!0;if(ve.type==="brand")return Y[ye]={text:Em(ve)},ve.dirty&&$(ye,{dirty:!1}),!0;if(ve.type==="input-image")return ve.imageUrl?(Y[ye]={url:ve.imageUrl},ve.dirty&&$(ye,{dirty:!1}),!0):(B(ye,"Add an image, upload a file or paste a URL."),!1);const br=k.filter(Lt=>Lt.to===ye),Kr={};for(const Lt of br){const Is=Y[Lt.from];Is&&(Kr[zp=Lt.toPort]||(Kr[zp]=[])).push(Is)}const Eo=Lt=>(Kr[Lt]||[]).map(Is=>Is.text).filter(Boolean).join(` 114 115`),Ya=Lt=>(Kr[Lt]||[]).map(Is=>Is.url).filter(Boolean);let ua={};ve.type==="image"?ua={prompt:Eo("prompt"),imageUrls:Ya("image")}:ve.type==="video"?ua={prompt:Eo("prompt"),imageUrls:Ya("image")}:ve.type==="music"?ua={text:Eo("text")}:ve.type==="sfx"?ua={text:Eo("text")}:ve.type==="upscale"?ua={imageUrls:Ya("image")}:ve.type==="relight"||ve.type==="background"?ua={imageUrls:Ya("image")}:ve.type==="caption"?ua={imageUrls:Ya("image"),caption:Eo("text")}:ve.type==="style"&&(ua={imageUrls:Ya("image"),styleUrls:Ya("style")});const Kd=async Lt=>{$(ye,{status:"running",jobId:Lt,dirty:!1});const Is=ve.type==="video"?(Number(ve.duration)>=10?18:12)*60*1e3:ve.type==="assemble"?15*60*1e3:6*60*1e3,yr=await G(Lt,Is);if(yr&&yr.status==="completed"&&yr.resultUrl)return Y[ye]={url:yr.resultUrl},$(ye,{status:"done",out:{url:yr.resultUrl},jobId:void 0,dirty:!1}),!0;if(yr&&yr.status==="failed")throw new Error(yr.error||"Generation failed.");return yr&&yr.status==="gone"?($(ye,{jobId:void 0}),"gone"):($(ye,{status:"running",jobId:Lt}),"pending")};if(ve.jobId&&ve.status!=="failed"&&!ve.dirty)try{const Lt=await Kd(ve.jobId);if(Lt!=="gone")return Lt}catch(Lt){return B(ye,Lt==null?void 0:Lt.message),!1}if(ve.type==="assemble"){const Lt=_;let Is;_=new Promise(yr=>Is=yr);try{if($(ye,{status:"running",jobId:void 0}),await Lt,Le.current)return $(ye,{status:void 0}),!1;const yr=await Wh(ve,k,Ca=>dn[Ca],Ca=>Y[Ca]);if(yr.error)throw new Error(yr.error);if(Le.current)return $(ye,{status:void 0}),!1;const bb=Date.now()+10*60*1e3;let ma;for(;;)try{ma=await Jt(`${$t}/api/creatify/adflow/node`,{type:"assemble",params:{title:ve.title||""},inputs:{editDoc:yr.doc}});break}catch(Ca){if((Ca==null?void 0:Ca.code)!=="RENDER_IN_PROGRESS"||Date.now()>bb)throw Ca;if(await new Promise(yb=>setTimeout(yb,1e4)),Le.current)return $(ye,{status:void 0}),!1}if(!(ma!=null&&ma.ok)||!ma.jobId)throw new Error((ma==null?void 0:ma.error)||"The ad couldn't be put together.");const Bp=await Kd(ma.jobId);if(Bp==="gone")throw new Error("The render couldn't be found. Run it again.");return Bp}catch(yr){return B(ye,yr==null?void 0:yr.message),!1}finally{Is()}}$(ye,{status:"running"});try{const Lt=await Jt(`${$t}/api/creatify/adflow/node`,{type:ve.type,model:ve.model||"",params:{prompt:ve.prompt,aspect:ve.aspect,duration:ve.duration,scale:ve.scale,creativity:ve.creativity,resemblance:ve.resemblance,relightDir:ve.relightDir,keepBg:ve.keepBg,bgMode:ve.bgMode,styleStrength:ve.styleStrength,seed:ve.seed,caption:ve.caption,captionPos:ve.captionPos,config:ve.config&&typeof ve.config=="object"?ve.config:void 0},inputs:ua});if(!(Lt!=null&&Lt.ok))throw new Error((Lt==null?void 0:Lt.error)||"Node failed.");if(Lt.jobId){const Is=await Kd(Lt.jobId);if(Is==="gone")throw new Error("The job couldn't be found. Run it again.");return Is}else throw new Error("Node returned nothing.")}catch(Lt){return B(ye,Lt==null?void 0:Lt.message),!1}},Ue=4,dt=ke.filter(ye=>te[ye]===0);let At=0;try{if(await new Promise(ye=>{const ve=()=>{for(;!Le.current&&At<Ue&&dt.length;){const br=dt.shift();At+=1,de(br).then(Kr=>nn(br,Kr),()=>nn(br,!1))}At===0&&(Le.current||dt.length===0)&&ye()},nn=(br,Kr)=>{At-=1,Kr==="pending"?(an.has(br)||ns.push(br),Ms(br,!0)):Kr||Ms(br),(_e[br]||[]).forEac
115h(Eo=>{te[Eo.to]-=1,te[Eo.to]===0&&dt.push(Eo.to)}),ve()};ke.length?ve():ye()}),Le.current)P()&&C(ye=>ye.map(ve=>ve.status==="running"&&!ve.jobId?{...ve,status:void 0}:ve)),me("Run stopped. Anything already generating will still finish.");else{const ye=rt.current.find(nn=>(!re||re.has(nn.id))&&nn.status==="failed"),ve=ns.length?rt.current.find(nn=>nn.id===ns[0]):null;ve&&!ye?me(`"${ve.title||((Lp=lt[ve.type])==null?void 0:Lp.label)||"A step"}" is still generating. Its result appears on the node when it's ready; run the flow again then to finish the steps after it.`,{autoClose:8e3}):ye?me.error(({closeToast:nn})=>t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{children:"A node couldn't run."}),t.jsx("button",{type:"button",onClick:()=>{nn==null||nn(),R(ye.id),Ke([ye.id]),H(ye.id),On(ye)},className:"underline font-semibold text-rose-100",children:"Go to node"})]}),{autoClose:6e3}):me.success("Flow run complete. See the output nodes.")}}catch(ye){me.error((ye==null?void 0:ye.message)||"Flow run failed.")}finally{Le.current=!1,un(!1),s==null||s()}},Ar=()=>({nodes:w,edges:k,pan:m,zoom:I}),Wa=f=>{if(!f||!Array.isArray(f.nodes))return!1;const P=Gh(f.nodes,f.edges).map(B=>B.status==="running"&&!B.jobId||B.status==="pending"?{...B,status:void 0}:B),$=qh(P,f.edges);return Xn(),C(P),E($),T(P,$),f.pan&&typeof f.pan=="object"&&M(f.pan),typeof f.zoom=="number"&&N(f.zoom),R(null),ie(null),!0},x=()=>{try{const f=new URL(window.location.href);f.searchParams.has("w")&&(f.searchParams.delete("w"),window.history.replaceState({},"",f.pathname+f.search))}catch{}},S=i.useRef(h?null:Mu(b.nodes,b.edges)),T=(f,j)=>{S.current=Mu(f,j)},L=()=>rt.current.length>0&&S.current!==Mu(rt.current,mt.current),K=i.useRef(!1),ee=async f=>{if(!ge("Sign in to save this workflow.")||K.current)return null;K.current=!0,bn(!0);try{const j=await Jt(`${$t}/api/creatify/adflow/workflows/save`,{id:gn||void 0,name:f,graph:Ar()});if(!(j!=null&&j.ok))throw new Error((j==null?void 0:j.error)||"Could not save workflow.");const P=j.workflow;return Hn(P.id),kr(P.name),Qn(!!P.isShared),ar(P.shareId||null),U(null),x(),T(rt.current,mt.current),me.success("Workflow saved."),P}catch(j){return(j==null?void 0:j.status)===404&&gn?(Hn(null),Qn(!1),ar(null),Nt(!0),me.info("That workflow was deleted. Save this board as a new one."),null):(me.error((j==null?void 0:j.message)||"Could not save workflow."),null)}finally{K.current=!1,bn(!1)}},be=()=>{ge(gt?"Sign in to save your own copy of this workflow.":"Sign in to save this workflow.")&&(gn?ee(hr):Nt(!0))},Ce=()=>{fe||gt||(gs(hr==="Untitled workflow"?"":hr),Wn(!0))},Be=()=>{Wn(!1);const f=Vr.trim().slice(0,80);!f||f===hr||(kr(f),gn&&ee(f))},Ve=async()=>{Tr(!0);try{const f=await Jt(`${$t}/api/creatify/adflow/workflows/list`,{});f!=null&&f.ok&&Se(f.workflows||[])}catch{}finally{Tr(!1)}},wt=()=>{ge("Sign in to see your saved workflows.")&&(Wt(!0),Ve())},[Yt,St]=i.useState(null),[bt,Mt]=i.useState(null),cn=f=>{je()||(L()?St(f):Er(f))},Co=async()=>{const f=Yt;St(null),ge("Sign in to save this workspace.")&&(gn?await ee(hr)&&Er(f):(Mt(f),Nt(!0)))},Er=async f=>{if(ge("Sign in to open a saved workflow.")&&!je())try{const j=await Jt(`${$t}/api/creatify/adflow/workflows/get`,{id:f});if(!(j!=null&&j.ok))throw new Error((j==null?void 0:j.error)||"Could not load workflow.");const P=j.workflow;Wa(P.graph),Hn(P.id),kr(P.name),Qn(!!P.isShared),ar(P.shareId||null),U(null),x(),Wt(!1),me.success("Workflow loaded.")}catch(j){me.error((j==null?void 0:j.message)||"Could not load workflow.")}},aa=async f=>{if(ge("Sign in to delete a saved workflow."))try{const j=await Jt(`${$t}/api/creatify/adflow/workflows/delete`,{id:f});if(!(j!=null&&j.ok))throw new Error((j==null?void 0:j.error)||"Could not delete.");Se(P=>P.filter($=>$.id!==f)),gn===f&&(Hn(null),Qn(!1),ar(null)),me.success("Workflow deleted.")}catch(j){me.error((j==null?void 0:j.message)||"Could not delete workflow.")}},ia=async f=>{if(ge("Sign in to duplicate a workflow."))try{const j=await Jt(`${$t}/api/creatify/adflow/workflows/duplicate`,{id:f});if(!(j!=null&&j.ok))throw new Error((j==null?void 0:j.error)||"Could not duplicate.");await Ve(),me.success("Workflow duplicated.")}catch(j){me.error((j==null?void 0:j.message)||"Could not duplicate workflow.")}},Vn=(f=Hc)=>{if(je())return;const j=(typeof f=="function"?f:Hc)();Xn(),C(j.nodes),E(j.edges),T(j.nodes,j.edges),M({x:16,y:8}),N(.7),R(null),Ke([]),ie(null),Hn(null),kr("Untitled workflow"),Qn(!1),ar(null),U(null),ht(!1),x(),setTimeout(()=>{var P;return(P=Qe.current)==null?void 0:P.call(Qe,{animate:!1})},90)},pn=()=>
115{if(!je()){if(rt.current.length===0){ht(!0);return}Ft(!0)}},ts=async()=>{Ft(!1),ge("Sign in to save this workspace.")&&(gn?await ee(hr)&&ht(!0):(Pt(!0),Nt(!0)))},It=f=>`${window.location.origin}/content-studio/adflow?w=${encodeURIComponent(f)}`,Pn=async f=>{if(ge("Sign in to share this workflow.")){if(!gn)return null;try{const j=await Jt(`${$t}/api/creatify/adflow/workflows/share`,{id:gn,share:f});if(!(j!=null&&j.ok))throw new Error((j==null?void 0:j.error)||"Could not update sharing.");return Qn(j.isShared),ar(j.shareId||null),j}catch(j){return me.error((j==null?void 0:j.message)||"Could not update sharing."),null}}},$r=async()=>{if(ge("Sign in to share this workflow.")){if(!gn){me("Save this workflow first, then share it."),Nt(!0);return}!ze&&!await Pn(!0)||eo(!0)}},Ge=(o==null?void 0:o._id)||(o==null?void 0:o.id)||null,_r=i.useRef(null);i.useEffect(()=>{let f=null;try{f=new URLSearchParams(window.location.search).get("w")}catch{}if(!f)return;if(!o){Q(!0);return}Q(!1);const j=`${f}|${Ge}`;if(_r.current===j)return;_r.current=j;let P=!1;return(async()=>{try{const $=await Jt(`${$t}/api/creatify/adflow/workflows/shared`,{shareId:f});if(P)return;if(!($!=null&&$.ok)){me.error(($==null?void 0:$.error)||"This shared workflow is unavailable.",{toastId:"adflow-shared-fail"});return}const B=$.workflow;Wa(B.graph),kr(B.name||"Shared workflow"),Hn(null),Qn(!1),ar(null),U({ownerName:B.ownerName||null,name:B.name||""})}catch{P||me.error("Could not open the shared workflow.",{toastId:"adflow-shared-fail"})}})(),()=>{P=!0}},[Ge]);const q=w.find(f=>f.id===F)||null;i.useEffect(()=>{q&&(q.type==="image"||q.type==="video")&&q.model&&ut(q.model)},[q==null?void 0:q.id,q==null?void 0:q.model]);const ir=f=>w.find(j=>j.id===f);if(rn.current=I,Ot.current=m,Qe.current=So,i.useEffect(()=>{if(!(!F||!Zr())){if(jo.current){No.current=F;return}Bn||gi(F)}},[F]),i.useEffect(()=>{if(h||new URLSearchParams(window.location.search).get("w"))return;const f=setTimeout(()=>{var j;return(j=Qe.current)==null?void 0:j.call(Qe,{animate:!1})},90);return()=>clearTimeout(f)},[]),Qt.current=f=>{if(!l||jt)return;const j=f.target,P=j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable);if(f.key==="Escape"){if(P){j.blur();return}if(Xe||ne){nt(!1),se(!1);return}if(jr){Jn(null);return}if(fr){or(null);return}if(xt||Xe||Ie||Et||Ht||Yt){J(!1),nt(!1),ht(!1),Ft(!1),Gt(null),St(null);return}if(pe||F||mn.length||A||z||Bn||vt||en){ie(null),R(null),Ke([]),V(null),H(null),jn(null),Mn(null),Nr(null);return}if(En){An(!1);return}return}if(P)return;const $=f.metaKey||f.ctrlKey;if($&&(f.key==="c"||f.key==="C")){f.preventDefault(),kn();return}if($&&(f.key==="v"||f.key==="V")){f.preventDefault(),ws();return}if($&&(f.key==="d"||f.key==="D")){f.preventDefault(),zs();return}if($&&(f.key==="a"||f.key==="A")){f.preventDefault(),so();return}if($&&(f.key==="s"||f.key==="S")){f.preventDefault(),be();return}if($&&f.key==="Enter"){f.preventDefault(),Kt||Sa();return}if($&&(f.key==="z"||f.key==="Z")){f.preventDefault(),f.shiftKey?_t():pt();return}if($&&(f.key==="y"||f.key==="Y")){f.preventDefault(),_t();return}if(!$){if(f.key==="Delete"||f.key==="Backspace"){A?(f.preventDefault(),Jr(A)):(mn.length||F)&&(f.preventDefault(),oo());return}f.key==="f"||f.key==="F"?So():f.key==="v"||f.key==="V"?qt("select"):f.key==="h"||f.key==="H"?qt("hand"):f.key==="+"||f.key==="="?es(.1):f.key==="-"||f.key==="_"?es(-.1):f.key==="n"||f.key==="N"?nt(B=>!B):f.key==="/"&&!f.shiftKey?(f.preventDefault(),J(!0)):f.key==="s"||f.key==="S"?Nn("sticky"):(f.key==="?"||f.shiftKey&&f.key==="/")&&se(B=>!B)}},ue&&!o)return t.jsx("div",{className:"min-h-[60vh] grid place-items-center",children:t.jsxs("div",{className:"max-w-md w-full text-center rounded-2xl border border-white/10 bg-white/[0.02] p-8",children:[t.jsx("div",{className:"w-12 h-12 mx-auto mb-4 grid place-items-center rounded-full bg-violet-500/15 border border-violet-500/30 text-violet-300",children:t.jsx(Ko,{className:"w-5 h-5"})}),t.jsx("h2",{className:"text-lg font-semibold text-white",children:"A workflow was shared with you"}),t.jsx("p",{className:"text-sm text-gray-400 mt-1.5",children:"Sign in to view this
115shared AdFlow workspace."}),t.jsx("button",{type:"button",onClick:()=>n==null?void 0:n("Sign in to open the workflow shared with you."),className:"mt-5 inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-violet-500 hover:bg-violet-400 text-white text-sm font-semibold transition",children:"Sign in to view"})]})});const Ks=t.jsxs("div",{className:En?"fixed inset-0 z-[100] bg-[#0b0d12] p-4 flex flex-col gap-3 overflow-hidden":"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"AdFlow"}),t.jsx("span",{className:"text-gray-600",children:"/"}),qr?t.jsx("input",{autoFocus:!0,value:Vr,onChange:f=>gs(f.target.value),onBlur:Be,onKeyDown:f=>{f.key==="Enter"?(f.preventDefault(),Be()):f.key==="Escape"&&(f.preventDefault(),Wn(!1))},maxLength:80,placeholder:"Workflow name",className:"w-52 px-2 py-0.5 rounded-md bg-white/[0.06] border border-violet-400/50 outline-none text-sm font-medium text-gray-100 placeholder:text-gray-500"}):t.jsxs("button",{type:"button",onClick:Ce,disabled:fe||!!gt,title:fe||gt?hr:"Rename workflow",className:"group inline-flex items-center gap-1 min-w-0 max-w-[260px] text-sm font-medium text-gray-200 hover:text-white disabled:cursor-default disabled:hover:text-gray-200",children:[t.jsx("span",{className:"truncate",children:hr}),!fe&&!gt&&t.jsx(qs,{className:"w-3 h-3 shrink-0 opacity-0 group-hover:opacity-60 transition"})]}),ze&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-violet-500/15 border border-violet-400/30 text-violet-200 text-[10px] font-semibold",children:[t.jsx(Ko,{className:"w-3 h-3"})," Shared"]})]}),t.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:["Wire nodes left â right, then press"," ",t.jsx(Ta,{className:"inline w-3 h-3 -mt-0.5 text-violet-300"})," Run on the final node. It builds everything before it."]})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[t.jsxs("button",{type:"button",onClick:pn,title:"Start a new workflow",className:"inline-flex items-center gap-1.5 px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:border-white/25 transition",children:[t.jsx(fs,{className:"w-4 h-4"})," New"]}),t.jsxs("button",{type:"button",onClick:wt,className:"inline-flex items-center gap-1.5 px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:border-white/25 transition",children:[t.jsx(zi,{className:"w-4 h-4"})," Workflows"]}),t.jsxs("button",{type:"button",onClick:be,disabled:_n,className:"inline-flex items-center gap-1.5 px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:border-white/25 transition disabled:opacity-50",children:[_n?t.jsx(Tn,{className:"w-4 h-4"}):t.jsx(ni,{className:"w-4 h-4"})," ","Save"]}),t.jsxs("button",{type:"button",onClick:$r,className:"inline-flex items-center gap-1.5 px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:border-white/25 transition",children:[t.jsx(Ko,{className:"w-4 h-4"})," Share"]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{type:"button",onClick:()=>nt(f=>!f),className:"inline-flex items-center gap-1.5 px-3.5 py-2.5 rounded-xl bg-white/[0.05] border border-white/10 text-gray-100 text-sm font-medium hover:border-white/25 transition",children:[t.jsx(fs,{className:"w-4 h-4"})," Add node"]}),Xe&&t.jsx("div",{className:"absolute right-0 mt-2 w-56 max-h-[70vh] overflow-y-auto rounded-xl border border-white/10 bg-[#0E1117] shadow-2xl p-1.5 z-30",children:hb.map(f=>t.jsxs("div",{className:"mb-1 last:mb-0",children:[t.jsx("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:f.label}),f.types.map(j=>{const P=lt[j],$=P.icon,B=P.out?Za(P.out).text:"text-gray-400";return t.jsxs("button",{type:"button",onClick:()=>Nn(j),title:P.desc||"",className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-sm text-gray-200 hover:bg-white/5",children:[t.jsx($,{className:`w-3.5 h-3.5 shrink-0 ${B}`}),P.label]},j)})]},f.label))})]}),t.jsxs("button",{type:"button",onClick:()=>ln(!0),title:"Everything your flows have made, saved on a board or not",className:"shrink-0 inline-flex items-center gap-2 px-4 py-2.5 rounded-xl border text-sm font-semibold transition bg-white/[0.04] border-white/10 text-gray-200 hover:border-white/25",children:[t.jsx(Js,{className:"w-4 h-4"})," Results"]}),Kt?t.jsxs("button",{onClick:()=>{Le.current=!0},className:"shrink-0 inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-rose-500 hover:bg-rose-400 text-white text-sm font-semibold transition",children:[t.jsx(Fa,{className:"w-3.5 h-3.5"})," Stop"]}):t.jsxs("span",{className:"shrink-0 hidden sm:inline-flex items-center gap-1.5 text-[11px] font-medium text-gray-500",children:[t.jsx(Ta,{className:"w-3 h-3 text-violet-300"})," Press"," ",t.jsx(Ta,{className:"w-2.5 h-2.5 inline"})," Run on an output node"]})]})]}),gt&&t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-xl border border-violet-400/30 bg-violet-500/10 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-violet-100",children:[t.jsx(Ko,{className:"w-4 h-4 shrink-0"}),t.jsxs("span",{children:["You're viewing a shared workflow",gt.ownerName?` from ${gt.ownerName}
115`:"",". Save a copy to make it your own, edits here won't change the original."]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{ge("Sign in to save your own copy of this workflow.")&&Nt(!0)},className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg bg-violet-500 hover:bg-violet-400 text-white text-xs font-semibold transition",children:[t.jsx(ni,{className:"w-3.5 h-3.5"})," ",o?"Save a copy":"Sign in to save a copy"]}),t.jsxs("button",{type:"button",onClick:pn,className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg bg-white/[0.05] border border-white/10 text-gray-200 text-xs font-medium hover:border-white/25 transition",children:[t.jsx(ft,{className:"w-3.5 h-3.5"})," Dismiss"]})]})]}),t.jsxs("div",{ref:y,"data-adf-canvas":!0,className:`relative w-full overflow-hidden overscroll-none rounded-2xl border border-white/10 bg-[#080A10] select-none [&_input]:select-text [&_textarea]:select-text ${ot==="hand"?"cursor-grab active:cursor-grabbing":"cursor-default"} ${En?"flex-1 min-h-0":"h-[680px] [@media(pointer:coarse)]:max-h-[calc(100svh-8rem)] [@media(pointer:coarse)]:min-h-[240px]"}`,style:{backgroundImage:"radial-gradient(circle at 1px 1px, rgba(148,163,184,0.16) 1px, transparent 0)",backgroundSize:`${$i*I}px ${$i*I}px`,backgroundPosition:`${m.x}px ${m.y}px`,touchAction:"none",WebkitTouchCallout:"none"},onPointerDownCapture:Te,onPointerDown:Yn,onMouseDown:bi,onContextMenu:f=>{f.preventDefault(),!ra(f)&&jn({x:f.clientX,y:f.clientY,type:"canvas",canvasPt:io(f.clientX,f.clientY)})},children:[Na&&t.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-30 max-w-[calc(100%-6rem)] px-3 py-1.5 rounded-full bg-black/75 text-center text-[11px] leading-snug text-gray-200 border border-white/10 pointer-events-none",children:"Drag to move around, pinch to zoom, press and hold for more"}),t.jsxs("div",{className:"absolute top-0 left-0 origin-top-left",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${I})`},children:[en&&t.jsx("div",{className:"absolute border border-violet-400 bg-violet-400/10 pointer-events-none z-50",style:{left:Math.min(en.x0,en.x1),top:Math.min(en.y0,en.y1),width:Math.abs(en.x1-en.x0),height:Math.abs(en.y1-en.y0)}}),t.jsxs("svg",{className:"absolute pointer-events-none overflow-visible",style:{left:0,top:0},children:[t.jsx("defs",{children:Object.entries({text:"#38bdf8",image:"#a78bfa",video:"#34d399",audio:"#fbbf24",sel:"#f43f5e"}).map(([f,j])=>t.jsx("marker",{id:`adf-arrow-${f}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:t.jsx("path",{d:"M 0 1 L 9 5 L 0 9 z",fill:j})},f))}),k.map(f=>{var _e;const j=ir(f.from),P=ir(f.to);if(!j||!P)return null;const $=lt[P.type].inputs.findIndex(He=>He.id===f.toPort),B=Iu(j),re=Xh(P,Math.max(0,$)),X=ku({x:B.x,y:B.y,w:0,h:0},{x:re.x,y:re.y,h:0},sr),ae=A===f.id,Y=(B.x+re.x)/2,he=(B.y+re.y)/2,ke=(_e=lt[j.type])==null?void 0:_e.out,Me=Za(ke).stroke,te=["text","image","video","audio"].includes(ke)?ke:"image";return t.jsxs("g",{children:[t.jsx("path",{d:X,fill:"none",stroke:ae?"rgba(244,63,94,0.9)":Me,strokeOpacity:ae?1:.5,strokeWidth:ae?2.4:1.6,markerEnd:`url(#adf-arrow-${ae?"sel":te})`}),P.status==="running"&&t.jsx("path",{d:X,fill:"none",stroke:Me,strokeWidth:"2.2",strokeOpacity:"0.9",strokeDasharray:"6 5",className:"adf-edge-flow"}),t.jsx("path",{d:X,fill:"none",stroke:"transparent",strokeWidth:"14",className:"[@media(pointer:coarse)]:[stroke-width:30px]",style:{pointerEvents:"stroke",cursor:"pointer"},onMouseDown:He=>He.stopPropagation(),onClick:He=>{He.stopPropagation(),R(null),H(null),V(f.id)}}),ae&&t.jsxs("g",{"data-adf-nodrag":!0,style:{pointerEvents:"auto",cursor:"pointer"},onMouseDown:He=>He.stopPropagation(),onClick:He=>{He.stopPropagation(),Jr(f.id)},children:[t.jsx("circle",{cx:Y,cy:he,r:"22",fill:"transparent",className:"hidden [@media(pointer:coarse)]:block"}),t.jsx("circle",{cx:Y,cy:he,r:"9",fill:"#1b1020",stroke:"rgba(244,63,94,0.9)",strokeWidth:"1.5"}),t.jsx("path",{d:`M ${Y-3.2} ${he-3.2} L ${Y+3.2} ${he+3.2} M ${Y+3.2} ${he-3.2} L ${Y-3.2} ${he+3.2}`,stroke:"rgba(244,63,94,0.95)",strokeWidth:"1.6",strokeLinecap:"round"})]})]},f.id)}),pe&&(()=>{const f=ir(pe.from);if(!f)return null;const j=Iu(f);return t.jsx("path",{d:ku({x:j.x,y:j.y,w:0,h:0},{x:pe.x,y:pe.y,h:0},sr),fill:"none",stroke:"rgba(139,92,246,0.8)",strokeWidth:"1.8",strokeDasharray:"4 4"})})()]}),w.map(f=>{var re,X,ae,Y,he,ke,Me;const j=lt[f.type],P=j.icon,$=F===f.id||mn.includes(f.id),B=$||z===f.id;if(j.annotation){const te=Eu.find(_e=>_e.key===f.color)||Eu[0];return t.jsxs("div",{"data-node-id":f.id,className:"absolute rounded-xl shadow-lg group",style:{left:f.x,top:f.y,width:f.w||220,background:te.bg,border:`1px solid ${te.border}`,outline:$?`2px solid ${te.border}`:"none",zIndex:B?40:1},onMouseDown:_e=>_e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-2 py-1 cursor-move select-none",style:{borderBottom:`1px solid ${te.border}66`},onMouseDown:lo(f.id),onPointerDown:Rn(f.id),onClick:()=>R(f.id),children:[t.jsx(Tl,{className:"w-3 h-3",style:{color:te.text,opacity:.8}}),t.jsxs("div",{className:`flex items-center gap-1 transition ${$?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[Eu.map(_e=>t.jsx("button",{type:"button",title:_e.key,onMouseDown:He=>He.stopPropagation(),onClick:He=>{He.stopPropagation(),Ee(f.id,{color:_e.key})},className:"w-3 h-3 rounded-full border border-black/40",style:{background:_e.border}},_e.key)),t.jsx("button",{type:"button",title:"Delete note",onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>{_e.stopPropagation(),bs(f.id)},className:"ml-0.5",children:t.jsx(ft,{className:"w-3 h-3",style:{color:te.text}})})]})]}),t.jsx("textarea",{value:f.text||"",onChange:_e=>Ee(f.id,{text:_e.target.value}),onMouseDown:_e=>_e.stopPropagation(),placeholder:"Type a noteâ¦",maxLength:ps,readOnly:fe,className:"w-full bg-transparent resize-none outline-none px-2.5 py-2 text-[12px] leading-snug",style:{color:te.text,height:f.h||104}}),!fe&&t.jsx("span",{onMouseDown:ka(f),onPointerDown:_e=>{Ur(_e)&&!ks.current&&ka(f)(_e)},title:"Drag to resize",className:"absolute bottom-0 right-0 w-4 h-4 [@media(pointer:coarse)]:w-7 [@media(pointer:coarse)]:h-7 grid place-items-end justify-end p-0.5 cursor-nwse-resize opacity-50 hover:opacity-100",style:{color:te.text},children:t.jsx("svg",{viewBox:"0 0 10 10",className:"w-2.5 h-2.5",children:t.jsx("path",{d:"M9 2 L2 9 M9 6 L6 9",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})})})]},f.id)}return t.jsxs("div",{"data-node-id":f.id,className:`absolute rounded-xl border bg-[#0E1117] shadow-lg ${$?"border-violet-500 ring-2 ring-violet-500/40":"border-white/10"}`,style:{left:f.x,top:f.y,width:rs,zIndex:B?40:1},onMouseDown:te=>te.stopPropagation(),onContextMenu:te=>{te.preventDefault(),te.stopPropagation(),!ra(te)&&(mn.includes(f.id)||(R(f.id),Ke([f.id])),jn({x:te.clientX,y:te.clientY,type:"node",nodeId:f.id}))},children:[t.jsxs("div",{className:`flex items-center justify-between gap-2 px-2.5 py-2 select-none border-b border-white/5 ${f.locked?"cursor-default":"cursor-move"}`,onMouseDown:lo(f.id),onPointerDown:Rn(f.id),onClick:()=>R(f.id),children:[fr===f.id?t.jsx("input",{autoFocus:!0,value:bo,onChange:te=>In(te.target.value),onBlur:Vs,onMouseDown:te=>te.stopPropagation(),onKeyDown:te=>{te.key==="Enter"?(te.preventDefault(),Vs()):te.key==="Escape"&&(te.preventDefault(),or(null))},maxLength:60,className:"min-w-0 flex-1 px-1 py-0.5 rounded bg-white/10 border border-violet-400/50 outline-none text-[11px] font-semibold text-gray-100"}):t.jsxs("span",{className:"inline-flex min-w-[18px] flex-1 items-center gap-1.5 overflow-hidden text-[11px] font-semibold text-gray-200",title:f.locked?j.desc||"":"Double-click to rename",onDoubleClick:te=>{te.stopPropagation(),wo(f)},children:[t.jsx(P,{className:"w-3.5 h-3.5 text-violet-300 shrink-0"}),t.jsx("span",{className:"truncate",children:f.title})]}),(()=>{var yt,dn,Ut,it,Tt,wn;const te=(yt=lt[f.type])!=null&&yt.annotation?[]:dl(f,k),_e=Kt||te.length>0,He=te.length?`Add ${te.join(" and ")} before running`:null;return t.jsxs("span",{className:"inline-flex min-w-0 items-center justify-end gap-1.5",children:[!fe&&!["input-text","input-image","brand"].includes(f.type)&&(k.some(an=>an.from===f.id)?t.jsx("button",{type:"button",title:He||"Run up to here: this branch and its inputs",disabled:_e,onMouseDown:an=>an.stopPropagation(),onClick:an=>{an.stopPropagation(),Sa(f.id)},className:"w-5 h-5 shrink-0 grid place-items-center rounded text-gray-400 hover:text-violet-300 hover:bg-white/10 disabled:opacity-30",children:t.jsx(Ta,{className:"w-3 h-3"})}):t.jsxs("button",{type:"button",title:He||"Run this output: executes the whole chain leading to it",disabled:_e,onMouseDown:an=>an.stopPropagation(),onClick:an=>{an.stopPropagation(),Sa(f.id)},className:"inline-flex shrink-0 items-center gap-1 px-2 h-6 rounded-md bg-vi
115olet-500 hover:bg-violet-400 text-white text-[11px] font-semibold disabled:opacity-40 transition",children:[t.jsx(Ta,{className:"w-2.5 h-2.5"})," Run"]})),f.locked&&t.jsx(Po,{className:"w-3 h-3 shrink-0 text-amber-400",title:"Locked"}),f.pinned&&(((dn=f.out)==null?void 0:dn.url)||((Ut=f.out)==null?void 0:Ut.text))&&t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1.5 rounded bg-violet-500/20 text-violet-200 text-[9px] font-semibold",title:"Output kept: reruns reuse it instead of regenerating",children:[t.jsx(Po,{className:"w-2.5 h-2.5"})," kept"]}),f.dirty&&!f.pinned&&!te.length&&(((it=f.out)==null?void 0:it.url)||((Tt=f.out)==null?void 0:Tt.text))&&f.status!=="running"&&t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1.5 rounded bg-amber-500/15 text-amber-300 text-[9px] font-semibold",title:"Inputs changed since this ran. Rerun to update",children:[t.jsx(Xs,{className:"w-2.5 h-2.5"})," stale"]}),te.length>0?t.jsxs("span",{className:"inline-flex min-w-0 max-w-[104px] shrink items-center gap-1 overflow-hidden rounded bg-amber-500/15 px-1.5 text-[9px] font-semibold text-amber-300",title:`Add ${te.join(" and ")} in the panel before running`,children:[t.jsx(Xs,{className:"w-2.5 h-2.5 shrink-0"}),t.jsxs("span",{className:"truncate",children:["needs ",Fk(te[0])]})]}):(f.type==="image"||f.type==="video")&&t.jsx("span",{className:"min-w-0 text-[9px] text-gray-500 max-w-[80px] truncate",children:Nk(f.model)}),f.status&&t.jsx(fb,{state:f.status,error:(wn=f.out)==null?void 0:wn.error,onClick:f.status==="failed"?()=>H(an=>an===f.id?null:f.id):void 0})]})})()]}),z===f.id&&f.status==="failed"&&t.jsx("div",{className:"absolute inset-0 z-50 grid place-items-center p-2 pointer-events-none",children:t.jsx("div",{className:"pointer-events-auto w-[200px] max-w-full rounded-lg border border-rose-500/40 bg-[#1b1014] shadow-2xl p-2.5",onMouseDown:te=>te.stopPropagation(),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Xs,{className:"w-4 h-4 text-rose-400 mt-0.5 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[11px] font-semibold text-rose-200 mb-0.5",children:"Couldn't run this node"}),t.jsx("div",{className:"text-[11px] text-rose-100/80 leading-snug break-words",children:((re=f.out)==null?void 0:re.error)||"Check the inputs and try again."})]}),t.jsx("button",{type:"button",onClick:()=>H(null),className:"text-rose-300/60 hover:text-rose-200 shrink-0",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]})})}),j.inputs.map((te,_e)=>t.jsxs("div",{className:"absolute flex items-center gap-1",style:{left:-7,top:34+_e*24-7},children:[t.jsx("span",{"data-adf-in":f.id,"data-adf-port":te.id,onMouseUp:vn(f.id,te.id),onPointerDown:us(f,te),onMouseDown:He=>{fe||Kt||pe||(He.stopPropagation(),He.preventDefault(),er(),Mn({nodeId:f.id,port:te.id,kind:te.kind,accepts:ti(te),dir:"in",x:He.clientX,y:He.clientY}))},className:`relative w-3.5 h-3.5 rounded-full bg-[#0E1117] border-2 hover:scale-125 transition-transform cursor-pointer ${Za(te.kind).border}`,title:`${te.label} input (${ti(te).join(" or ")}), click to add a source, or drop a connection here`,children:t.jsx("span",{"aria-hidden":!0,className:"absolute hidden [@media(pointer:coarse)]:block",style:{inset:"-5px -4px -5px -14px"}})}),t.jsx("span",{className:"text-[9px] text-gray-500 bg-[#0E1117]/80 px-1 rounded",children:te.label})]},te.id)),t.jsx("span",{"data-adf-out":f.id,onMouseDown:yi(f.id),onPointerDown:sa(f.id),className:`absolute w-3.5 h-3.5 rounded-full border-2 border-[#0E1117] hover:brightness-125 hover:scale-125 transition-transform cursor-pointer ${Za(j.out).dot}`,style:{right:-7,top:19},title:`Output (${j.out}), click to add a connected node, or drag to an input`,children:t.jsx("span",{"aria-hidden":!0,className:"absolute hidden [@media(pointer:coarse)]:block",style:{inset:"-9px -14px -9px -4px"}})}),t.jsx("span",{className:"absolute text-[9px] text-gray-500 bg-[#0E1117]/80 px-1 rounded pointer-events-none",style:{right:6,top:31},children:"Output"}),t.jsxs("div",{className:"p-2.5",children:[f.type==="input-text"&&t.jsx("textarea",{value:f.value||"",onChange:te=>Ee(f.id,{value:te.target.value,needsRewrite:void 0}),rows:3,maxLength:ps,readOnly:fe,onMouseDown:fe?te=>{te.stopPropagation(),ge("Sign in to edit this workflow.")}:void 0,placeholder:"Type a prompt or description⦠then connect Output â a node",className:nr+" resize-none text-xs"}),f.type==="input-image"&&(f.imageUrl?t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:f.imageUrl,alt:"",loading:"lazy",decoding:"async",className:"w-full h-24 object-contain rounded-lg bg-black/30"}),!fe&&t.jsx("button",{type:"button",onClick:()=>Ee(f.id,{imageUrl:""}),className:"absolute top-1 right-1 w-6 h-6 grid place-items-center rounded-full bg-black/70 text-white",children:t.jsx(ft,{className:"w-3 h-3"})})]}):t.jsxs("label",{className:"flex flex-col items-center justify-center gap-1 h-24 rounded-lg border border-dashed border-white/20 cursor-pointer hover:border-violet-400/50 text-[11px] text-gray-400",onClick:fe?te=>{te.preventDefault(),ge("Sign in to edit this workflow.")}:void 0,onDragOver:fe?void 0:te=>{te.preventDefault(),te.stopPropagation()},onDrop:fe?void 0:te=>{var _e,He;te.preventDefault(),te.stopPropagation(),Bs(f.id,(He=(_e=te.dataTransfer)==null?void 0:_e.files)==null?void 0:He[0])},children:[t.jsx(ho,{className:"w-5 h-5"}),"Drop or upload",t.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/heic,image/heif",disabled:fe,className:"hidden",onChange:te=>{var He;const _e=(He=te.target.files)==null?void 0:He[0];te.target.value="",Bs(f.id,_e)}})]})),f.type==="brand"&&t.jsx(wk,{text:Em(f),placeholder:"Fill in your brand: name, colours, fonts, voice."}),(f.type==="image"||f.type==="upscale"||f.type==="relight"||f.type==="style"||f.type==="background"||f.type==="caption")&&((X=f.out)!=null&&X.url?t.jsxs("div",{className:"relative group/media",children:[t.jsx("img",{src:f.out.url,alt:"",loading:"lazy",decoding:"async",onMouseDown:te=>te.stopPropagation(),onClick:()=>Jn({url:f.out.url,kind:"image"}),className:"w-full max-h-40 object-contain rounded-lg bg-black cursor-zoom-in"}),t.jsx(Vh,{url:f.out.url,onExpand:()=>Jn({url:f.out.url,kind:"image"})})]}):t.jsx(Su,{state:f.status,label:f.type==="upscale"?"Upscaled image":f.type==="relight"?"Relit image":f.type==="style"?"Restyled image":f.type==="background"?"Backgroun
115d output":f.type==="caption"?"Captioned image":"Image output",error:(ae=f.out)==null?void 0:ae.error})),(f.type==="video"||f.type==="assemble")&&((Y=f.out)!=null&&Y.url?t.jsxs("div",{className:"relative group/media",children:[t.jsx("video",{src:f.out.url,controls:!0,playsInline:!0,preload:"none",poster:f.out.poster||void 0,className:"w-full max-h-56 object-contain rounded-lg bg-black"}),t.jsx(Vh,{url:f.out.url,onExpand:()=>Jn({url:f.out.url,kind:"video"})})]}):t.jsx(Su,{state:f.status,label:f.type==="assemble"?"Finished ad":"Video output",error:(he=f.out)==null?void 0:he.error})),(f.type==="music"||f.type==="sfx")&&((ke=f.out)!=null&&ke.url?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("audio",{src:f.out.url,preload:"none",controls:!0,className:"w-full h-9"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("button",{type:"button",onMouseDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),Jn({url:f.out.url,kind:"audio"})},className:"inline-flex items-center gap-1 text-[10px] text-gray-400 hover:text-violet-300",children:[t.jsx(Ts,{className:"w-3 h-3"})," Full screen"]}),t.jsxs("a",{href:ud(f.out.url)||void 0,download:!0,onMouseDown:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] text-gray-400 hover:text-violet-300",children:[t.jsx(go,{className:"w-3 h-3"})," Download"]})]})]}):t.jsx(Su,{state:f.status,label:f.type==="music"?"Music output":"SFX output",error:(Me=f.out)==null?void 0:Me.error}))]})]},f.id)}),A&&(()=>{const f=k.find(he=>he.id===A);if(!f)return null;const j=ir(f.from),P=ir(f.to);if(!j||!P)return null;const $=lt[P.type].inputs.findIndex(he=>he.id===f.toPort),B=Iu(j),re=Xh(P,Math.max(0,$)),X=ku({x:B.x,y:B.y,w:0,h:0},{x:re.x,y:re.y,h:0},sr),ae=(B.x+re.x)/2,Y=(B.y+re.y)/2;return t.jsxs("svg",{className:"absolute left-0 top-0 overflow-visible pointer-events-none",style:{zIndex:45},children:[t.jsx("path",{d:X,fill:"none",stroke:"rgba(244,63,94,0.95)",strokeWidth:"2.4"}),t.jsxs("g",{"data-adf-nodrag":!0,"aria-label":"Remove this connection",style:{pointerEvents:"auto",cursor:"pointer"},onMouseDown:he=>he.stopPropagation(),onClick:he=>{he.stopPropagation(),Jr(f.id)},children:[t.jsx("circle",{cx:ae,cy:Y,r:"22",fill:"transparent",className:"hidden [@media(pointer:coarse)]:block"}),t.jsx("circle",{cx:ae,cy:Y,r:"10",fill:"#1b1020",stroke:"rgba(244,63,94,0.95)",strokeWidth:"1.5"}),t.jsx("path",{d:`M ${ae-3.4} ${Y-3.4} L ${ae+3.4} ${Y+3.4} M ${ae+3.4} ${Y-3.4} L ${ae-3.4} ${Y+3.4}`,stroke:"rgba(244,63,94,1)",strokeWidth:"1.7",strokeLinecap:"round"})]})]})})()]}),w.length===0&&t.jsx("div",{className:"absolute inset-0 grid place-items-center pointer-events-none",children:t.jsxs("div",{className:"text-center max-w-xs px-6",children:[t.jsx("div",{className:"mx-auto mb-3 w-12 h-12 grid place-items-center rounded-2xl bg-violet-500/10 border border-violet-400/20",children:t.jsx(Ko,{className:"w-5 h-5 text-violet-300"})}),t.jsx("h3",{className:"text-sm font-semibold text-gray-200",children:"Start your AdFlow"}),t.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-gray-500",children:"Add a node, or start from a template with New."})]})}),t.jsxs("div",{"data-adf-ui":!0,className:"absolute top-3 left-3 flex flex-col gap-1 rounded-xl border border-white/10 bg-[#0E1117]/90 backdrop-blur p-1 z-20",onMouseDown:f=>f.stopPropagation(),children:[t.jsx("button",{type:"button",onClick:()=>qt("select"),title:"Select / marquee (V)",className:`w-8 h-8 grid place-items-center rounded-lg transition ${ot==="select"?"bg-violet-500/30 text-violet-200":"text-gray-300 hover:bg-white/10"}`,children:t.jsx(u0,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",onClick:()=>qt("hand"),title:"Hand / pan (H)",className:`w-8 h-8 grid place-items-center rounded-lg transition ${ot==="hand"?"bg-violet-500/30 text-violet-200":"text-gray-300 hover:bg-white/10"}`,children:t.jsx(Fs,{className:"w-4 h-4"})}),t.jsx("span",{className:"my-0.5 h-px w-6 self-center bg-white/10"}),t.jsx("button",{type:"button",onClick:()=>An(f=>!f),title:En?"Exit full screen (Esc)":"Full screen",className:"w-8 h-8 grid place-items-center rounded-lg text-gray-300 hover:bg-white/10 transition",children:En?t.jsx(f0,{className:"w-4 h-4"}):t.jsx(Ts,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",onClick:pt,disabled:!$n,title:"Undo (âZ)",className:"w-8 h-8 grid place-items-center rounded-lg text-gray-300 hover:bg-white/10 disabled:opacity-30 transition",children:t.jsx(Pl,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",onClick:_t,disabled:!xn,title:"Redo (ââ§Z)",className:"w-8 h-8 grid place-items-center rounded-lg text-gray-300 hover:bg-white/10 disabled:opacity-30 transition",children:t.jsx(Tc,{className:"w-4 h-4"})})]}),w.length>2&&(()=>{var Ut;const $=Math.min(...w.map(it=>it.x)),B=Math.min(...w.map(it=>it.y)),re=Math.max(...w.map(it=>it.x+rs)),X=Math.max(...w.map(it=>it.y+po(it))),ae=Math.max(1,re-$),Y=Math.max(1,X-B),he=Math.min((168-8*2)/ae,(110-8*2)/Y),ke=8+(168-8*2-ae*he)/2,Me=8+(110-8*2-Y*he)/2,te=(it,Tt)=>({x:ke+(it-$)*he,y:Me+(Tt-B)*he}),_e=(Ut=y.current)==null?void 0:Ut.getBoundingClientRect();let He=null;if(_e){const it=te(-m.x/I,-m.y/I);He={x:it.x,y:it.y,w:_e.width/I*he,h:_e.height/I*he}}const yt=(it,Tt,wn)=>{var g;const an=$+(it-wn.left-ke)/he,ns=B+(Tt-wn.top-Me)/he,Ms=(g=y.current)==null?void 0:g.getBoundingClientRect();Ms&&M({x:Ms.width/2-an*I,y:Ms.height/2-ns*I})},dn=it=>{it.preventDefault(),it.stopPropagation(),er();const Tt=it.currentTarget.getBoundingClientRect();yt(it.clientX,it.clientY,Tt),Qr(it,{move:wn=>yt(wn.clientX,wn.clientY,Tt)})};
115return t.jsx("div",{"data-adf-ui":!0,className:"absolute bottom-3 right-3 rounded-lg border border-white/10 bg-[#0E1117]/90 backdrop-blur z-20 overflow-hidden cursor-grab active:cursor-grabbing hidden sm:block",style:{width:168,height:110},onMouseDown:dn,onPointerDown:it=>{Ur(it)&&dn(it)},title:"Minimap: drag to pan",children:t.jsxs("svg",{width:168,height:110,children:[w.map(it=>{const Tt=te(it.x,it.y),wn=lt[it.type],an=wn!=null&&wn.out?Za(wn.out).stroke:"#6b7280";return t.jsx("rect",{x:Tt.x,y:Tt.y,width:Math.max(2,rs*he),height:Math.max(2,po(it)*he),rx:"1.5",fill:an,fillOpacity:"0.55"},it.id)}),He&&t.jsx("rect",{x:He.x,y:He.y,width:He.w,height:He.h,fill:"none",stroke:"#a78bfa",strokeWidth:"1.5"})]})})})(),t.jsxs("div",{"data-adf-ui":!0,className:"absolute bottom-3 left-3 flex items-center gap-1 rounded-lg border border-white/10 bg-[#0E1117]/90 backdrop-blur px-1.5 py-1 text-xs text-gray-300 z-20",onMouseDown:f=>f.stopPropagation(),children:[t.jsx("button",{type:"button",onClick:()=>es(-.1),title:"Zoom out (â)",className:"w-6 h-6 grid place-items-center rounded hover:bg-white/10",children:"â"}),t.jsxs("span",{className:"w-10 text-center tabular-nums",children:[Math.round(I*100),"%"]}),t.jsx("button",{type:"button",onClick:()=>es(.1),title:"Zoom in (+)",className:"w-6 h-6 grid place-items-center rounded hover:bg-white/10",children:"+"}),t.jsxs("button",{type:"button",onClick:()=>So(),title:"Recenter: fit all nodes (F)",className:"inline-flex items-center gap-1 px-2 h-6 rounded hover:bg-white/10",children:[t.jsx(Ts,{className:"w-3 h-3"})," Recenter"]}),t.jsx("span",{className:"w-px h-4 bg-white/10 mx-0.5"}),t.jsxs("button",{type:"button",onClick:()=>zn(f=>f==="bezier"?"ortho":"bezier"),title:"Connection style (curved / elbow)",className:"inline-flex items-center gap-1 px-2 h-6 rounded hover:bg-white/10",children:[t.jsx(Pb,{className:"w-3.5 h-3.5"}),sr==="ortho"?"Elbow":"Curved"]}),t.jsx("button",{type:"button",onClick:()=>se(!0),title:"Keyboard shortcuts (?)",className:"w-6 h-6 grid place-items-center rounded hover:bg-white/10 font-semibold",children:"?"})]}),q&&!((Ss=lt[q.type])!=null&&Ss.annotation)&&t.jsxs(kk,{title:q.title||lt[q.type].label,desc:lt[q.type].desc,onClose:()=>R(null),readOnly:fe||Kt,runState:q.status,onRun:["input-text","input-image","brand","sticky"].includes(q.type)?void 0:()=>Sa(q.id),runDisabled:Kt||dl(q,k).length>0,onLocked:()=>Kt?me.error("The flow is running, press Stop to edit."):ge("Sign in to edit this workflow."),children:[!cs&&!["input-text","input-image","brand","sticky"].includes(q.type)&&t.jsx("div",{"data-adflow-signup":!0,children:t.jsxs(td,{title:"Sign up to run this flow",onClick:()=>r==null?void 0:r(),children:["Get ",t.jsx("strong",{className:"text-white",children:"7 free credits"})," ","when you sign up, no subscription required. Your board stays as you left it in this tab."]})}),dl(q,k).length>0&&t.jsxs("div",{className:"flex items-start gap-1.5 text-[11px] text-amber-200 bg-amber-500/10 border border-amber-500/25 rounded-lg px-2.5 py-2",children:[t.jsx(Xs,{className:"w-3.5 h-3.5 mt-px shrink-0 text-amber-400"}),t.jsxs("span",{children:["Needs ",dl(q,k).join(" and ")," before this node can run."]})]}),q.type==="input-text"&&t.jsx(Fe,{label:"Value",children:t.jsx("textarea",{value:q.value||"",onChange:f=>Ee(q.id,{value:f.target.value,needsRewrite:void 0}),rows:4,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Type the input textâ¦"})}),q.type==="input-image"&&t.jsx(Fe,{label:"Image URL",children:t.jsx("input",{value:q.imageUrl||"",onChange:f=>Ee(q.id,{imageUrl:f.target.value}),className:nr+" text-xs",placeholder:"Paste an image URL or upload on the node"})}),q.type==="image"&&(()=>{const f=q.mode||"text-to-image";return t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Mode",children:t.jsx(Sn,{options:[{value:"text-to-image",label:"Text to image"},{value:"image-to-image",label:"Image to image"}],selectedValue:f,onSelect:j=>{Ee(q.id,{mode:j,model:""}),Ae(j)}})}),t.jsx(Fe,{label:"Model",hint:`${(O[f]||[]).length||""} models`,children:t.jsx(Nm,{models:O[f]||[],failed:we.has(f),onRetry:()=>Ae(f),value:q.model||"",onSelect:j=>{Ee(q.id,{model:j,config:{}}),ut(j)},loading:W===f})}),q.model&&t.jsx(Uh,{model:q.model,schema:De[q.model],loading:Ye===q.model,values:q.config||{},onChange:j=>Ee(q.id,{config:j}),signIn:j=>ge(j||"Sign in to upload your file.")}),t.jsx(Fe,{label:"Aspect ratio",children:t.jsx(dr,{value:q.aspect||"9x16",onChange:j=>Ee(q.id,{aspect:j}),options:zh})}),t.jsx(Fe,{label:"Prompt",hint:Xt(q.id,"prompt").length?void 0:"Or wire a Text node in",children:Xt(q.id,"prompt").length?t.jsx(Ga,{names:Xt(q.id,"prompt").join(", ")}):t.jsx(t.Fragment,{children:t.jsx("textarea",{value:q.prompt||"",onChange:j=>Ee(q.id,{prompt:j.target.value}),rows:3,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Describe the imageâ¦"})})})]})})(),q.type==="video"&&(()=>
115{const f=q.mode||"text-to-video";return t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Mode",children:t.jsx(Sn,{options:[{value:"text-to-video",label:"Text to video"},{value:"image-to-video",label:"Image to video"}],selectedValue:f,onSelect:j=>{Ee(q.id,{mode:j,model:""}),Ae(j)}})}),t.jsx(Fe,{label:"Model",hint:`${(O[f]||[]).length||""} models`,children:t.jsx(Nm,{models:O[f]||[],failed:we.has(f),onRetry:()=>Ae(f),value:q.model||"",onSelect:j=>{Ee(q.id,{model:j,config:{}}),ut(j)},loading:W===f})}),q.model&&t.jsx(Uh,{model:q.model,schema:De[q.model],loading:Ye===q.model,values:q.config||{},onChange:j=>Ee(q.id,{config:j}),signIn:j=>ge(j||"Sign in to upload your file.")}),t.jsx(Fe,{label:"Aspect ratio",children:t.jsx(dr,{value:q.aspect||"9x16",onChange:j=>Ee(q.id,{aspect:j}),options:zh})}),t.jsx(Fe,{label:"Duration",hint:"Shorter = fewer credits",children:t.jsx(dr,{value:String(q.duration||"5"),onChange:j=>Ee(q.id,{duration:j}),options:[{value:"5",label:"5 seconds"},{value:"10",label:"10 seconds"}]})}),t.jsx(Fe,{label:"Prompt",hint:Xt(q.id,"prompt").length?void 0:"Or wire a Text node in",children:Xt(q.id,"prompt").length?t.jsx(Ga,{names:Xt(q.id,"prompt").join(", ")}):t.jsx(t.Fragment,{children:t.jsx("textarea",{value:q.prompt||"",onChange:j=>Ee(q.id,{prompt:j.target.value}),rows:3,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Describe the motion / sceneâ¦"})})})]})})(),q.type==="music"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Model",children:t.jsx(Sn,{options:Ph.map(f=>({value:f.id,label:f.name})),selectedValue:q.model||"fal-ai/lyria2",onSelect:f=>Ee(q.id,{model:f})})}),((Cs=Ph.find(f=>f.id===q.model))==null?void 0:Cs.duration)&&t.jsx(Fe,{label:"Duration",hint:"Seconds",children:t.jsx(dr,{value:String(q.duration||"30"),onChange:f=>Ee(q.id,{duration:f}),options:[{value:"30",label:"30s"},{value:"60",label:"60s"},{value:"120",label:"120s"}]})}),t.jsx(Fe,{label:"Prompt",hint:Xt(q.id,"text").length?void 0:"Or wire a Text node in",children:Xt(q.id,"text").length?t.jsx(Ga,{names:Xt(q.id,"text").join(", ")}):t.jsx(t.Fragment,{children:t.jsx("textarea",{value:q.prompt||"",onChange:f=>Ee(q.id,{prompt:f.target.value}),rows:3,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Describe the music: mood, genre, tempoâ¦"})})})]}),q.type==="sfx"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Model",children:t.jsx(Sn,{options:Nu.map(f=>({value:f.id,label:f.name})),selectedValue:q.model||Nu[0].id,onSelect:f=>Ee(q.id,{model:f})})}),t.jsx(Fe,{label:"Prompt",hint:Xt(q.id,"text").length?void 0:"Or wire a Text node in",children:Xt(q.id,"text").length?t.jsx(Ga,{names:Xt(q.id,"text").join(", ")}):t.jsx(t.Fragment,{children:t.jsx("textarea",{value:q.prompt||"",onChange:f=>Ee(q.id,{prompt:f.target.value}),rows:3,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Describe the sound effectâ¦"})})})]}),q.type==="upscale"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Upscale factor",hint:"Higher = sharper, slower",children:t.jsx(dr,{value:String(q.scale||"2"),onChange:f=>Ee(q.id,{scale:f}),options:[{value:"2",label:"2Ã"},{value:"4",label:"4Ã"}]})}),t.jsx(Fe,{label:"Creativity",hint:"How much new detail the AI invents. Low = faithful, high = creative hallucination.",children:t.jsx(wu,{value:q.creativity??.35,onChange:f=>Ee(q.id,{creativity:f}),min:0,max:1,step:.05})}),t.jsx(Fe,{label:"Resemblance",hint:"Fidelity to the original. Raise it to counteract Creativity drift.",children:t.jsx(wu,{value:q.resemblance??.6,onChange:f=>Ee(q.id,{resemblance:f}),min:0,max:1,step:.05})}),t.jsx(Fe,{label:"Guidance prompt",hint:"Optional. Steers the new detail",children:t.jsx("textarea",{value:q.prompt||"",onChange:f=>Ee(q.id,{prompt:f.target.value}),rows:2,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"e.g. crisp fabric weave, sharp logo edgesâ¦"})})]}),q.type==="relight"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Light direction / mood",children:t.jsx(dr,{value:q.relightDir||"left",onChange:f=>Ee(q.id,{relightDir:f}),options:[{value:"left",label:"Left"},{value:"right",label:"Right"},{value:"top",label:"Top"},{value:"front",label:"Front"},{value:"back",label:"Backlight"},{value:"golden",label:"Golden hour"},{value:"studio",label:"Studio"},{value:"dramatic",label:"Dramatic"}]})}
115),t.jsx(Fe,{label:"Background",children:t.jsx(dr,{value:q.keepBg!==!1,onChange:f=>Ee(q.id,{keepBg:f}),options:[{value:!0,label:"Keep"},{value:!1,label:"Adapt to light"}]})}),t.jsx(Fe,{label:"Extra direction",hint:"Optional",children:t.jsx("textarea",{value:q.prompt||"",onChange:f=>Ee(q.id,{prompt:f.target.value}),rows:2,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"e.g. cool blue tone, warm rim on the rightâ¦"})})]}),q.type==="style"&&t.jsxs(t.Fragment,{children:[Xt(q.id,"style").length?t.jsx(Ga,{names:Xt(q.id,"style").join(", "),what:"Style ref",overrides:!1}):t.jsxs("p",{className:"text-[11px] text-amber-300/80 bg-amber-500/5 border border-amber-500/20 rounded-lg px-2.5 py-2",children:["Wire a second image into the ",t.jsx("b",{children:"Style ref"})," input, its look is what gets transferred."]}),t.jsx(Fe,{label:"Style strength",children:t.jsx(dr,{value:q.styleStrength||"strong",onChange:f=>Ee(q.id,{styleStrength:f}),options:[{value:"subtle",label:"Subtle"},{value:"strong",label:"Strong"}]})}),t.jsx(Fe,{label:"Extra direction",hint:"Optional",children:t.jsx("textarea",{value:q.prompt||"",onChange:f=>Ee(q.id,{prompt:f.target.value}),rows:2,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"e.g. keep the product colours accurateâ¦"})})]}),q.type==="background"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Mode",children:t.jsx(dr,{value:q.bgMode||"remove",onChange:f=>Ee(q.id,{bgMode:f}),options:[{value:"remove",label:"Remove (cutout)"},{value:"replace",label:"Replace"}]})}),q.bgMode==="replace"&&t.jsx(Fe,{label:"New background",hint:"Describe the scene to place behind the subject",children:t.jsx("textarea",{value:q.prompt||"",onChange:f=>Ee(q.id,{prompt:f.target.value}),rows:3,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"e.g. soft marble surface with warm studio lightâ¦"})})]}),q.type==="brand"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Brand name",children:t.jsx("input",{value:q.brandName||"",onChange:f=>Ee(q.id,{brandName:f.target.value}),className:nr+" text-xs",placeholder:"e.g. Acme Co."})}),t.jsx(Fe,{label:"Colours",hint:"Hex or names, comma separated",children:t.jsx("input",{value:q.colors||"",onChange:f=>Ee(q.id,{colors:f.target.value}),className:nr+" text-xs",placeholder:"#1B1B1B, #F5C518, off-white"})}),t.jsx(Fe,{label:"Fonts",children:t.jsx("input",{value:q.fonts||"",onChange:f=>Ee(q.id,{fonts:f.target.value}),className:nr+" text-xs",placeholder:"e.g. Inter, Playfair Display"})}),t.jsx(Fe,{label:"Tone / voice",children:t.jsx("input",{value:q.tone||"",onChange:f=>Ee(q.id,{tone:f.target.value}),className:nr+" text-xs",placeholder:"e.g. bold, playful, premium"})})]}),q.type==="caption"&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Position",children:t.jsx(dr,{value:q.captionPos||"bottom",onChange:f=>Ee(q.id,{captionPos:f}),options:[{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}]})}),t.jsx(Fe,{label:"Caption",hint:Xt(q.id,"text").length?void 0:"Or wire a Text node into Caption",children:Xt(q.id,"text").length?t.jsx(Ga,{names:Xt(q.id,"text").join(", "),what:"Caption"}):t.jsx("textarea",{value:q.caption||"",onChange:f=>Ee(q.id,{caption:f.target.value}),rows:2,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Headline or CTA to burn onto the imageâ¦"})})]}),q.type==="assemble"&&(()=>{const f=Cm(q,k,ir),j=X=>k.some(ae=>ae.to===q.id&&ae.toPort===X),P=f.some(X=>{var ae,Y;return((Y=lt[(ae=ir(X.from))==null?void 0:ae.type])==null?void 0:Y.out)==="image"}),$=f.filter(X=>Cu(ir(X.from)).url).length,B=(X,ae)=>{const Y=f.map(ke=>ke.from),he=X+ae;he<0||he>=Y.length||([Y[X],Y[he]]=[Y[he],Y[X]],Ee(q.id,{clipOrder:Y}))},re=j("text")||!!String(q.captions||"").trim();return t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Clips",hint:f.length>1?"They play in this order":void 0,children:f.length?t.jsx("ol",{className:"space-y-1","data-adf-clip-order":!0,children:f.map((X,ae)=>{var Me,te;const Y=ir(X.from),he=(Me=lt[Y==null?void 0:Y.type])==null?void 0:Me.out,ke=he==="image"?Zs:$s;return t.jsxs("li",{className:"flex items-center gap-2 rounded-lg border border-white/10 bg-white/[0.03] pl-2 pr-1 py-1",children:[t.jsx("span",{className:"w-4 text-[11px] text-gray-500 tabular-nums",children:ae+1}),t.jsx(ke,{className:`w-3.5 h-3.5 shrink-0 ${Za(he).text}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-gray-200",children:(Y==null?void 0:Y.title)||((te=lt[Y==null?void 0:Y.type])==null?void 0:te.label)}),!Cu(Y).url&&t.jsx("span",{className:"shrink-0 text-[10px] text-gray-500",children:"not made yet"}),t.jsx("button",{type:"button","aria-label":`Play ${(Y==null?void 0:Y.title)||"this clip"} earlier`,disabled:ae===0,onClick:()=>B(ae,-1),className:"w-7 h-7 grid place-items-center rounded-md text-gray-400 hover:text-white hover:bg-white/10 disabled:opacity-25",children:t.jsx(Tb,{className:"w-3.5 h-3.5"})}),t.jsx("button",{type:"button","aria-label":`Play ${(Y==null?void 0:Y.title)||"this clip"} later`,disabled:ae===f.length-1,onClick:()=>B(ae,1),className:"w-7 h-7 grid place-items-center rounded-md text-gray-400 hover:text-white hover:bg-white/10 disabled:opacity-25",children:t.jsx(Ab,{className:"w-3.5 h-3.5"})})]},X.id)})}):t.jsx("p",{className:"text-[11px] leading-snug text-gray-500",children:"Connect Video Gen or image nodes to Clips. You can connect several; they play one after another."})}),t.jsx(Fe,{label:"Size",children:t.jsx(dr,{value:q.aspect||"9x16",onChange:X=>Ee(q.id,{aspect:X}
115),options:[{value:"9x16",label:"9:16"},{value:"4x5",label:"4:5"},{value:"1x1",label:"1:1"},{value:"16x9",label:"16:9"}]})}),t.jsx(Fe,{label:"Framing",children:t.jsx(dr,{value:q.fit||"cover",onChange:X=>Ee(q.id,{fit:X}),options:[{value:"cover",label:"Fill the frame"},{value:"contain",label:"Show all of it"}]})}),t.jsx(Fe,{label:"Between clips",children:t.jsx(dr,{value:q.transition||"cut",onChange:X=>Ee(q.id,{transition:X}),options:[{value:"cut",label:"Cut"},{value:"crossfade",label:"Crossfade"}]})}),P&&t.jsx(Fe,{label:"Each still shows for",children:t.jsx(dr,{value:String(q.imageSeconds??3),onChange:X=>Ee(q.id,{imageSeconds:Number(X)}),options:["2","3","4","5"].map(X=>({value:X,label:`${X}s`}))})}),j("voice")&&t.jsx(Fe,{label:"Ad length",hint:(q.lengthMode||"clips")==="voice"?"The clips repeat or stop to fit the sound":"The sound stops if the clips end first",children:t.jsx(dr,{value:q.lengthMode||"clips",onChange:X=>Ee(q.id,{lengthMode:X}),options:[{value:"clips",label:"Follow the clips"},{value:"voice",label:"Follow the sound"}]})}),j("music")&&t.jsx(Fe,{label:"Music volume",children:t.jsx(wu,{value:q.musicVolume??30,min:0,max:100,step:5,onChange:X=>Ee(q.id,{musicVolume:X}),format:X=>`${Math.round(X)}%`})}),t.jsx(Fe,{label:"Clip sound",children:t.jsx(dr,{value:q.clipSound?"on":"off",onChange:X=>Ee(q.id,{clipSound:X==="on"}),options:[{value:"off",label:"Muted"},{value:"on",label:"Keep it"}]})}),t.jsx(Fe,{label:"Captions",hint:Xt(q.id,"text").length?void 0:"Optional. One caption per line, or per sentence",children:Xt(q.id,"text").length?t.jsx(Ga,{names:Xt(q.id,"text").join(", "),what:"The caption text"}):t.jsx("textarea",{value:q.captions||"",onChange:X=>Ee(q.id,{captions:X.target.value}),rows:3,maxLength:ps,className:nr+" resize-none text-xs",placeholder:"Text to show over the adâ¦"})}),re&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:"Caption position",children:t.jsx(dr,{value:q.captionPos||"bottom",onChange:X=>Ee(q.id,{captionPos:X}),options:[{value:"top",label:"Top"},{value:"middle",label:"Middle"},{value:"bottom",label:"Bottom"}]})}),t.jsx(Fe,{label:"Caption style",children:t.jsx(dr,{value:q.captionStyle||"shadow",onChange:X=>Ee(q.id,{captionStyle:X}),options:[{value:"shadow",label:"White"},{value:"dark",label:"Dark box"},{value:"light",label:"Light box"}]})})]}),a&&t.jsxs("button",{type:"button",onClick:()=>tc(q),disabled:!$||ao,title:$?"Open these pieces in the Video Editor to fine tune them":"Run the flow first, so there's something to open",className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg bg-white/[0.04] border border-white/10 text-gray-200 text-xs font-medium hover:border-violet-400/40 disabled:opacity-40 disabled:hover:border-white/10 transition",children:[ao?t.jsx(Tn,{className:"w-3.5 h-3.5"}):t.jsx(Di,{className:"w-3.5 h-3.5"})," ","Open in Video Editor"]}),t.jsx("p",{className:"text-[11px] leading-snug text-gray-500",children:"Free, no credits used. Ads can be up to 3 minutes, and your account renders one video at a time."})]})})(),["image","video"].includes(q.type)&&t.jsx(Fe,{label:"Batch & variations",hint:"Clone this node wired to the same inputs. They generate in parallel so you can compare and pick.",children:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[[2,3,4].map(f=>t.jsxs("button",{type:"button",onClick:()=>kt(q,f-1),title:`Make ${f} variations of this node`,className:"px-2.5 py-1.5 rounded-lg text-xs font-medium border bg-white/[0.03] border-white/10 text-gray-300 hover:border-violet-400/40 hover:text-violet-200 transition",children:["Ã",f]},f)),t.jsx("button",{type:"button",onClick:()=>on(q),title:"Add copies sized 9:16 · 1:1 · 16:9 for every platform",className:"px-2.5 py-1.5 rounded-lg text-xs font-medium border bg-white/[0.03] border-white/10 text-gray-300 hover:border-violet-400/40 hover:text-violet-200 transition",children:"+ all sizes"})]})}),["image","video"].includes(q.type)&&t.jsx(Fe,{label:"Seed",hint:"Optional. Same seed + inputs reproduces a result (where the model supports it)",children:t.jsx("input",{type:"number",value:q.seed??"",onChange:f=>Ee(q.id,{seed:f.target.value===""?void 0:Number(f.target.value)}),className:nr+" text-xs",placeholder:"random"})}),!["input-text","input-image","sticky"].includes(q.type)&&(((Uo=q.out)==null?void 0:Uo.url)||((Es=q.out)==null?void 0:Es.text))&&t.jsxs("button",{type:"button",onClick:()=>Ee(q.id,{pinned:!q.pinned}),title:"Keep this output so re-running the flow reuses it instead of regenerating (and re-charging)",className:`w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg border text-xs font-medium transition ${q.pinned?"bg-vi
115olet-500/20 border-violet-400/50 text-violet-200":"bg-white/[0.04] border-white/10 text-gray-200 hover:border-violet-400/40"}`,children:[t.jsx(Po,{className:"w-3.5 h-3.5"}),q.pinned?"Output kept. Click to unlock":"Keep this output"]}),((la=q.out)==null?void 0:la.url)&&t.jsxs("button",{type:"button",onClick:()=>ln(!0),title:"Every result your flows have made, saved on a board or not",className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg bg-white/[0.04] border border-white/10 text-gray-200 text-xs font-medium hover:border-violet-400/40 transition",children:[t.jsx(Js,{className:"w-3.5 h-3.5"})," See all results"]}),(()=>{const f=k.filter(j=>j.to===q.id);return f.length?t.jsxs("button",{type:"button",onClick:()=>Ne(q.id),className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg bg-white/[0.04] border border-white/10 text-gray-200 text-xs font-medium hover:border-violet-400/40 transition",children:[t.jsx(Ko,{className:"w-3.5 h-3.5"})," View inputs (",f.length,")"]}):null})(),t.jsxs("button",{type:"button",onClick:()=>bs(q.id),className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg bg-white/[0.04] border border-white/10 text-rose-300 text-xs font-medium hover:border-rose-500/40 transition",children:[t.jsx(ss,{className:"w-3.5 h-3.5"})," Delete node"]})]})]}),t.jsx(Ck,{open:ta,initialName:gt?`${gt.name||"Workflow"} (copy)`:hr,saving:_n,onClose:()=>{Nt(!1),Pt(!1),Mt(null)},onSave:async f=>{if(await ee(f)&&(Nt(!1),Rt&&(Pt(!1),ht(!0)),bt)){const P=bt;Mt(null),Er(P)}}}),t.jsx(Mk,{open:is,loading:_o,workflows:Dn,currentId:gn,onClose:()=>Wt(!1),onOpen:cn,onDelete:aa,onDuplicate:ia,buildShareUrl:It}),t.jsx(Ek,{open:Qs,url:Kn?It(Kn):"",isShared:ze,onClose:()=>eo(!1),onToggle:async f=>{await Pn(f)&&!f&&eo(!1)}}),t.jsx(Uk,{open:ne,onClose:()=>se(!1),isMac:Vt}),t.jsx(Sk,{open:xt,onClose:()=>J(!1),onAdd:Nn}),t.jsx(Vk,{open:Ie,onClose:()=>ht(!1),onPick:f=>Vn(f)}),Et&&t.jsx(Yo,{onClose:()=>Ft(!1),z:"z-[130]",children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl p-5",onMouseDown:f=>f.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:"Start a new board?"}),t.jsx("p",{className:"mt-1.5 text-sm text-gray-400 leading-relaxed",children:"Your current board will be replaced. Save it first if you want to keep it."}),t.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[t.jsxs("button",{type:"button",onClick:ts,className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl bg-violet-500 hover:bg-violet-400 text-white text-sm font-semibold transition",children:[t.jsx(ni,{className:"w-4 h-4"})," Save current, then start new"]}),t.jsx("button",{type:"button",onClick:()=>{Ft(!1),ht(!0)},className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl bg-white/[0.04] border border-white/10 text-gray-200 text-sm font-medium hover:border-white/25 transition",children:"Discard and start new"}),t.jsx("button",{type:"button",onClick:()=>Ft(!1),className:"w-full px-3 py-2 rounded-xl text-gray-400 text-sm font-medium hover:text-white transition",children:"Cancel"})]})]})}),Yt&&t.jsx(Yo,{onClose:()=>St(null),z:"z-[140]",children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl p-5",onMouseDown:f=>f.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:"Open another workflow?"}),t.jsx("p",{className:"mt-1.5 text-sm text-gray-400 leading-relaxed",children:"This board has changes that aren't saved. Opening another one replaces it."}),t.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[t.jsxs("button",{type:"button",onClick:Co,className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl bg-violet-500 hover:bg-violet-400 text-white text-sm font-semibold transition",children:[t.jsx(ni,{className:"w-4 h-4"})," Save this board, then open"]}),t.jsx("button",{type:"button",onClick:()=>{const f=Yt;St(null),Er(f)},className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl bg-white/[0.04] border border-white/10 text-gray-200 text-sm font-medium hover:border-white/25 transition",children:"Discard changes and open"}),t.jsx("button",{type:"button",onClick:()=>St(null),className:"w-full px-3 py-2 rounded-xl text-gray-400 text-sm font-medium hover:text-white transition",children:"Cancel"})]})]})}),t.jsx(Bk,{open:jt,onClose:()=>ln(!1),signedIn:cs,onSignUp:r}),Ht&&t.jsx(Yo,{onClose:()=>Gt(null),z:"z-[140]",children:t.jsxs("div",{className:"modal-pop-in w-full max-w-md rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl p-5",onMouseDown:f=>f.stopPropagation(),children:[t.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[t.jsx(ss,{className:"w-4 h-4 text-rose-400"}),Ht.length>1?`Delete ${Ht.length} nodes?`:"Delete this node?"]}),t.jsx("p",{className:"mt-1.5 text-sm text-gray-400 leading-relaxed",children:Ht.length===1?`â${((ca=w.find(f=>f.id===Ht[0]))==null?void 0:ca.title)||((gr=lt[(Hr=w.find(f=>f.id===Ht[0]))==null?void 0:Hr.type])==null?void 0:gr.label)||"This node"}â and its connections will be removed. You can undo this.`:"The
115se nodes and their connections will be removed. You can undo this."}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>Gt(null),className:"px-3.5 py-2 rounded-xl bg-white/[0.05] border border-white/10 text-gray-200 text-sm hover:border-white/25",children:"Cancel"}),t.jsxs("button",{type:"button",onClick:()=>{yo(Ht),Gt(null)},className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-xl bg-rose-500 hover:bg-rose-400 text-white text-sm font-semibold",children:[t.jsx(ss,{className:"w-4 h-4"})," Delete"]})]})]})}),le&&t.jsx(Yo,{onClose:()=>Ne(null),z:"z-[120]",children:t.jsx("div",{className:"modal-pop-in w-full max-w-lg max-h-[80vh] overflow-y-auto rounded-2xl border border-white/10 bg-[#0E1117] shadow-2xl",onMouseDown:f=>f.stopPropagation(),children:(()=>{var B;const f=w.find(re=>re.id===le);if(!f)return null;const j=lt[f.type],P=k.filter(re=>re.to===le),$={};for(const re of P)($[B=re.toPort]||($[B]=[])).push(re);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/10",children:[t.jsxs("h3",{className:"text-base font-semibold text-white",children:[f.title,", inputs"]}),t.jsx("button",{type:"button",onClick:()=>Ne(null),className:"text-gray-400 hover:text-white",children:t.jsx(ft,{className:"w-5 h-5"})})]}),t.jsx("div",{className:"p-5 space-y-4",children:P.length?((j==null?void 0:j.inputs)||[]).map(re=>{const X=$[re.id]||[];return X.length?t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-semibold text-gray-300 mb-2",children:[re.label," ",t.jsxs("span",{className:"text-gray-500",children:["(",X.length,")"]})]}),t.jsx("div",{className:"grid grid-cols-3 gap-2",children:X.map(ae=>{var te,_e,He,yt;const Y=w.find(dn=>dn.id===ae.from),he=((te=Y==null?void 0:Y.out)==null?void 0:te.url)||(Y==null?void 0:Y.imageUrl)||null,ke=((_e=Y==null?void 0:Y.out)==null?void 0:_e.text)||(Y==null?void 0:Y.value),Me=(He=lt[Y==null?void 0:Y.type])==null?void 0:He.out;return t.jsxs("div",{className:"rounded-lg border border-white/10 bg-black/30 overflow-hidden",children:[he&&Me==="image"?t.jsx("img",{src:he,alt:"",className:"w-full h-24 object-cover"}):he&&Me==="video"?t.jsx("video",{src:he,className:"w-full h-24 object-cover"}):he&&Me==="audio"?t.jsx("div",{className:"p-2 grid place-items-center h-24",children:t.jsx("audio",{src:he,controls:!0,className:"w-full h-8"})}):t.jsx("div",{className:"p-2 text-[11px] text-gray-400 line-clamp-4 h-24",children:ke||"(no output yet)"}),t.jsx("div",{className:"px-2 py-1 text-[10px] text-gray-500 truncate border-t border-white/5",children:(Y==null?void 0:Y.title)||((yt=lt[Y==null?void 0:Y.type])==null?void 0:yt.label)||"node"})]},ae.id)})})]},re.id):null}):t.jsx("p",{className:"text-sm text-gray-500",children:"Nothing is wired into this node yet."})})]})})()})}),t.jsx(jk,{media:jr,onClose:()=>Jn(null)}),vt&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[120]",onMouseDown:()=>Mn(null),onContextMenu:f=>{f.preventDefault(),ra(f)||Mn(null)},children:t.jsxs("div",{"data-adf-menu":!0,className:"absolute w-56 overflow-y-auto overscroll-contain rounded-xl border border-white/10 bg-[#16181a] shadow-2xl p-1.5 text-sm text-gray-200 animate-scaleIn",style:Hh(vt.x,vt.y,224),onMouseDown:f=>f.stopPropagation(),children:[t.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-gray-500",children:vt.dir==="out"?"Add next step":"Add a source"}),(()=>{const f=We(vt.kind,vt.dir,vt.accepts);return f.length?f.map(j=>{const P=lt[j],$=P.icon;return t.jsxs("button",{type:"button",onClick:()=>Fn(vt.nodeId,vt.port,vt.dir,j),title:P.desc||"",className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-white/5 text-left",children:[t.jsx($,{className:"w-3.5 h-3.5 text-violet-300 shrink-0"}),t.jsx("span",{className:"truncate",children:P.label})]},j)}):t.jsxs("div",{className:"px-2 py-2 text-[11px] text-gray-500",children:["No compatible node for this ",vt.kind," ",vt.dir==="out"?"output":"input","."]})})(),(vt.dir==="out"?k.some(j=>j.from===vt.nodeId):k.some(j=>j.to===vt.nodeId&&j.toPort===vt.port))?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 h-px bg-white/10"}),t.jsxs("button",{type:"button",onClick:()=>{Os(vt.nodeId,vt.port,vt.dir),Mn(null)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-rose-500/10 text-rose-300 text-left",children:[t.jsx(ft,{className:"w-3.5 h-3.5 shrink-0"}
115),t.jsxs("span",{children:["Remove connection",vt.dir==="out"?"s":""]})]})]}):null]})}),document.body),Bn&&(Bn.type!=="node"||w.some(f=>f.id===Bn.nodeId))&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[120]",onMouseDown:()=>jn(null),onContextMenu:f=>{f.preventDefault(),ra(f)||jn(null)},children:t.jsx("div",{"data-adf-menu":!0,className:"absolute min-w-[190px] overflow-y-auto overscroll-contain rounded-xl border border-white/10 bg-[#16181a] shadow-2xl p-1.5 text-sm text-gray-200",style:Hh(Bn.x,Bn.y,210),onMouseDown:f=>f.stopPropagation(),children:(()=>{var $;const f=B=>Vt?`â${B}`:`Ctrl+${B}`,j=({label:B,onClick:re,icon:X,kbd:ae,disabled:Y,danger:he})=>t.jsxs("button",{type:"button",disabled:Y,onClick:()=>{re(),jn(null)},className:`w-full flex items-center justify-between gap-4 px-2.5 py-1.5 rounded-lg hover:bg-white/5 disabled:opacity-40 text-left ${he?"text-rose-300 hover:bg-rose-500/10":""}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-2",children:[X,B]}),ae&&t.jsx("span",{className:"text-[10px] text-gray-500",children:ae})]}),P=()=>t.jsx("div",{className:"my-1 border-t border-white/5"});if(Bn.type==="node"){const B=w.find(X=>X.id===Bn.nodeId);if(!B)return null;const re=ro().length;return t.jsxs(t.Fragment,{children:[t.jsx(j,{label:re>1?`Duplicate ${re}`:"Duplicate",onClick:zs,icon:t.jsx(xa,{className:"w-3.5 h-3.5"}),kbd:f("D")}),t.jsx(j,{label:"Copy",onClick:kn,icon:t.jsx(xa,{className:"w-3.5 h-3.5"}),kbd:f("C")}),t.jsx(j,{label:B.locked?"Unlock":"Lock",onClick:()=>Oo(B.id),icon:t.jsx(Po,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Rename",onClick:()=>wo(B),icon:t.jsx(qs,{className:"w-3.5 h-3.5"}),disabled:fe||B.locked}),(($=B.out)==null?void 0:$.url)&&t.jsx(j,{label:"Download",onClick:()=>{var X;return ec(B.out.url,B.title||"adflow",((X=lt[B.type])==null?void 0:X.out)||"image")},icon:t.jsx(go,{className:"w-3.5 h-3.5"})}),t.jsx(P,{}),t.jsx(j,{label:re>1?`Delete ${re}`:"Delete",onClick:oo,icon:t.jsx(ss,{className:"w-3.5 h-3.5"}),kbd:"â«",danger:!0})]})}return t.jsxs(t.Fragment,{children:[t.jsx(j,{label:"Add Image Gen",onClick:()=>Nn("image"),icon:t.jsx(Zs,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Image Upscaler",onClick:()=>Nn("upscale"),icon:t.jsx(Yc,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Relight",onClick:()=>Nn("relight"),icon:t.jsx(Tm,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Style Transfer",onClick:()=>Nn("style"),icon:t.jsx(Li,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Background",onClick:()=>Nn("background"),icon:t.jsx(Di,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Caption / Overlay",onClick:()=>Nn("caption"),icon:t.jsx(Ra,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Brand Kit",onClick:()=>Nn("brand"),icon:t.jsx(p0,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Video Gen",onClick:()=>Nn("video"),icon:t.jsx($s,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Music",onClick:()=>Nn("music"),icon:t.jsx(oi,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Sound Effects",onClick:()=>Nn("sfx"),icon:t.jsx(_i,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Text",onClick:()=>Nn("input-text"),icon:t.jsx(qs,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Assemble Ad",onClick:()=>Nn("assemble"),icon:t.jsx(Js,{className:"w-3.5 h-3.5"})}),t.jsx(j,{label:"Add Sticky note",onClick:()=>Nn("sticky"),icon:t.jsx(Tl,{className:"w-3.5 h-3.5"})}),t.jsx(P,{}),t.jsx(j,{label:"Paste",onClick:ws,icon:t.jsx(xa,{className:"w-3.5 h-3.5"}),kbd:f("V"),disabled:!Zn.current}),t.jsx(j,{label:"Select all",onClick:so,kbd:f("A")}),t.jsx(j,{label:"Recenter",onClick:()=>So(),kbd:"F"})]})})()})}),document.body)]});return En?Un.createPortal(Ks,document.body):Ks}function Cc({title:e,desc:n}){return t.jsx(Rm,{title:e,desc:n})}function Kk({title:e,subtitle:n,actions:r,className:s=""}){return t.jsxs("div",{className:`flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3 mb-5 ${s}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight text-white",children:e}),n&&t.jsx("p",{className:"text-sm text-gray-400 mt-1 max-w-2xl leading-relaxed",children:n})]}),r&&t.jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})]})}
115function ul({value:e,onChange:n,options:r,disabled:s=!1}){return t.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(o=>{const a=e===o.value;return t.jsx("button",{type:"button",onClick:()=>!s&&n(o.value),disabled:s,"aria-pressed":a,className:`px-3 py-1.5 rounded-lg text-xs font-medium border transition-all duration-200 disabled:cursor-not-allowed ${s?"opacity-50":""} ${a?"bg-blue-500/15 border-blue-400/40 text-white ring-1 ring-inset ring-blue-400/20":"bg-white/[0.03] border-white/10 text-gray-400 hover:border-white/20 hover:text-gray-200"}`,children:o.label},o.value)})})}const Ec=[{key:"setup",label:"Setup"},{key:"script",label:"Script"},{key:"frame",label:"Frame"},{key:"generate",label:"Generate"}],Fu=e=>{switch(e){case"draft":return 0;case"scripting":case"script_ready":return 1;case"framing":case"frame_ready":return 2;case"generating":case"composing":case"completed":return 3;default:return 0}},Wk={scripting:"Writing the script",script_ready:"Script ready to check",framing:"Making the starting frame",frame_ready:"Starting frame ready",generating:"Video being made",composing:"Video being made",completed:"Changing a shot",failed:"Stopped, ready to try again"},Yk=(e,n=[])=>{var a,l,c,u;if(!e)return"";if(e.kind==="job"){const d=Wk[(a=e.job)==null?void 0:a.status]||"In progress";return e.title?`${e.title} · ${d}`:d}const r=((l=n.find(d=>d.key===e.styleKey))==null?void 0:l.label)||"",s=((c=e.productUrls)==null?void 0:c.length)||0,o=[r,e.productName,s?`${s} product photo${s===1?"":"s"}`:"",((u=e.creator)==null?void 0:u.name)||""].filter(Boolean);return o.length?o.join(" · "):"Setup in progress"},Jh=["draft","scripting","script_ready","framing","frame_ready","generating","composing","completed"],Ru=["scripting","framing","generating","composing"],Fm=e=>(e==null?void 0:e.mode)==="clone"&&!!e.sourceVideoUrl;function Pu({className:e=""}){return t.jsxs("div",{className:`rounded-xl border border-white/10 bg-white/[0.03] p-3 flex items-start gap-2 ${e}`,children:[t.jsx(Qa,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-blue-300"}),t.jsxs("div",{className:"text-[11px] text-gray-400 leading-relaxed",children:[t.jsx("b",{className:"text-gray-300",children:"Video results vary."})," Video generation is far less predictable than images, so takes differ from each other and will not always match what you pictured. That is normal. Generate a few variations and pick the best, or re-roll a take you do not like."]})]})}const Gk=[{key:"product",label:"Prompt & product",icon:$b},{key:"creator",label:"Who's in it",icon:_b},{key:"output",label:"Output",icon:ba}],qk=[{key:"script",label:"Script",icon:Tl,step:1},{key:"frame",label:"Starting frame",icon:Zs,step:2},{key:"generate",label:"Generate",icon:$s,step:3}],Tu=["creatify","describe","upload","lookalike"],Zh=e=>{const n=(e==null?void 0:e.creatorChoice)||(e==null?void 0:e.creatorMode);if(n==="model"&&e.creatorModelId){const r=pv(e.creatorModelId);return{kind:"model",id:e.creatorModelId,name:(r==null?void 0:r.name)||e.avatarName||"Model",gender:(r==null?void 0:r.gender)||e.avatarGender||"",imageUrl:(r==null?void 0:r.url)||e.creatorImageUrl||"",ready:!0}}return n==="custom"&&e.customModelId?{kind:"custom",id:String(e.customModelId),name:e.avatarName||"My Model",gender:e.avatarGender||"",imageUrl:e.creatorImageUrl||"",ready:!0}:null};function Xk({startedAt:e}){const n=e?new Date(e).getTime():0,[r,s]=i.useState(()=>Date.now());if(i.useEffect(()=>{if(!n)return;const a=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(a)},[n]),!n)return null;const o=Math.max(0,Math.floor((r-n)/1e3));return`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")} elapsed. `}const Jk=[{id:"create",label:"Create from a product"},{id:"clone",label:"Clone a winning ad"}],Io="ugcPrompts",ml="My Favorites";function Rm({title:e,desc:n}){return t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-bold text-white",children:e}),n&&t.jsx("p",{className:"text-sm text-gray-400 mt-0.5",children:n})]})}function Qh({children:e,aside:n}){return t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx("span",{className:"text-xs font-semibold px-2 py-0.5 rounded border text-blue-400 border-blue-500/40 bg-blue-500/10",children:e}),t.jsx("div",{className:"flex-1 h-px bg-white/10"}),n?t.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-[55%]",children:n}):null]})}function Mc({label:e,onClick:n,disabled:r,image:s,emoji:o,title:a,sub:l,muted:c}){return t.jsxs("button",{type:"button",onClick:n,disabled:r,title:r?"Finis
115h the earlier steps first":`Go to ${e}`,className:"w-full text-left rounded-lg -mx-1 px-1 py-1.5 transition-colors hover:bg-white/5 disabled:hover:bg-transparent disabled:opacity-50 disabled:cursor-default",children:[t.jsx("span",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:e}),t.jsxs("span",{className:"mt-1 flex items-center gap-3",children:[s?t.jsx("span",{className:"w-10 h-12 rounded-lg overflow-hidden border border-white/10 bg-black/30 shrink-0",children:t.jsx("img",{src:$l(s,80),alt:"",className:"w-full h-full object-cover"})}):o?t.jsx("span",{className:"w-10 h-10 rounded-lg bg-white/[0.04] border border-white/10 flex items-center justify-center text-lg shrink-0",children:o}):null,t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:`block text-[12px] font-semibold truncate ${c?"text-gray-600":"text-white"}`,children:a}),l&&t.jsx("span",{className:"block text-[10px] text-blue-300/90 truncate",children:l})]})]})]})}function e0({primary:e,busy:n,onClick:r,wide:s=!1}){const o=!!n||!!e.missing;return t.jsx("button",{type:"button",onClick:r,"aria-disabled":o,title:e.missing||void 0,"aria-label":e.missing?`${e.label}, ${e.missing}`:void 0,className:`${s?"w-full":"shrink-0"} inline-flex items-center justify-center gap-2 px-5 py-2.5 rounded-full bg-[#326CB4] text-white text-sm font-semibold transition ${o?"opacity-40 cursor-not-allowed":"hover:bg-[#3A78C6] active:bg-[#285789]"}`,children:n?t.jsxs(t.Fragment,{children:[t.jsx(Tn,{className:"w-4 h-4"})," ",t.jsx("span",{className:"truncate",children:n})]}):t.jsxs(t.Fragment,{children:[e.label==="Next"?null:t.jsx(Ao,{className:"w-4 h-4"}),e.label,e.label==="Next"?t.jsx(Da,{className:"w-4 h-4"}):null]})})}function Zk({adGender:e}){const n=e==="female"||e==="male",r=e==="female"?"woman":"man";return t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/[0.07] p-3 flex items-start gap-2",children:[t.jsx(Xs,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-amber-400"}),t.jsx("div",{className:"text-[11px] text-amber-100/85 leading-relaxed",children:n?t.jsxs(t.Fragment,{children:[t.jsxs("b",{className:"text-amber-100",children:["This ad features a ",e," model."]})," ","For the closest match, choose a model who is a ",r,". Choosing a different gender works against the ad's own pose, wardrobe and framing, and the result can vary a lot."]}):t.jsxs(t.Fragment,{children:[t.jsx("b",{className:"text-amber-100",children:"Match the ad's gender."})," If the ad you are cloning features a specific gender on camera, choose a model of that same gender. Mixing them works against the ad's own direction and the result can vary a lot."]})})]})}const Qk=(e,n)=>n===0?!0:e?n===1?!!e.scriptJson||!!e.analysisJson||(e.beats||[]).length>0||Jh.indexOf(e.status)>=Jh.indexOf("scripting"):n===2?!Fm(e)&&(!!e.startFrameUrl||e.status==="framing"||e.status==="frame_ready"):n===3?(e.variations||[]).length>0||!!e.finalVideoUrl||e.status==="generating"||e.status==="composing"||e.status==="completed":!1:!1,xb=["product","packaging","bag","scene","logo"],jl=(e=[])=>{const n=[];for(const r of Array.isArray(e)?e:[])typeof r=="string"&&r.trim()&&!n.includes(r.trim())&&n.push(r.trim());return n},eS=(e={})=>{const n=[];for(const r of xb)for(const s of jl(e[r]))n.includes(s)||n.push(s);return n},Rp="relative overflow-hidden rounded-2xl border border-white/10 bg-white/[0.025] shadow-[0_14px_44px_-34px_rgba(0,0,0,0.9)] backdrop-blur-sm before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-[linear-gradient(90deg,transparent,rgba(255,255,255,0.18),transparent)]",pl="w-full rounded-xl border border-white/10 bg-[#0E1117] px-3.5 py-2.5 text-sm text-gray-100 placeholder:text-gray-500 outline-none transition-all duration-200 hover:border-white/20 hover:bg-white/[0.04] focus:border-violet-500/50 focus:ring-2 focus:ring-violet-500/40",tS=[{title:"Meme",caption:"Punchy hook",badge:"POV",img:"https://res.cloudinary.com/dkqvdawog/image/upload/v1783684417/studioe-static-ads-out/pjjb0gm1fnv5znotd2se.jpg"}
115,{title:"Before/after",caption:"Simple contrast",badge:"VS",img:"https://res.cloudinary.com/dkqvdawog/image/upload/v1783684565/studioe-static-ads-out/ajazo0x6ulfjh57rzvdr.jpg"},{title:"Checklist",caption:"Benefit stack",badge:"ââ",img:"https://res.cloudinary.com/dkqvdawog/image/upload/v1783684614/studioe-static-ads-out/mi7pvhxrb3uwpbl8cqry.jpg"},{title:"UGC",caption:"Creator-style",badge:"UGC",img:"https://res.cloudinary.com/dkqvdawog/image/upload/v1783684738/studioe-static-ads-out/kuios3zqsvmulwxx5yee.jpg"}],nS=e=>String(e||"").split(/\r?\n/).map(n=>n.trim()).filter(Boolean);function Fi({children:e,className:n=""}){return t.jsx("section",{className:`${Rp} p-4 sm:p-5 ${n}`,children:e})}function Ii({label:e,hint:n,children:r}){return t.jsxs("div",{className:"space-y-2.5",children:[t.jsx("div",{className:"text-[12px] font-semibold text-gray-300",children:e}),r,n&&t.jsx("div",{className:"text-[11px] leading-relaxed text-gray-500",children:n})]})}function t0({title:e,kicker:n}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-base font-semibold text-white",children:e}),n&&t.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-gray-500",children:n})]})}function rS({value:e,active:n}){const r=n?"bg-white/95 shadow-[0_0_18px_rgba(255,255,255,0.2)]":"bg-white/35";return e==="portrait"?t.jsx("span",{className:`h-7 w-3.5 rounded ${r}`}):e==="both"?t.jsxs("span",{className:"flex h-7 w-8 items-center justify-center gap-1",children:[t.jsx("span",{className:`h-[18px] w-[18px] rounded ${r}`}),t.jsx("span",{className:`h-7 w-3 rounded ${r}`})]}):t.jsx("span",{className:`h-5 w-5 rounded ${r}`})}function sS(){return t.jsxs(Fi,{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold text-gray-100",children:"Example output styles"}),t.jsx("div",{className:"mt-0.5 text-[11px] text-gray-500",children:"A quick feel for the mix before you generate."})]}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:tS.map(e=>t.jsxs("div",{className:"group rounded-xl border border-white/10 bg-white/[0.025] p-2 transition-all duration-200 hover:border-white/20 hover:bg-white/[0.04]",children:[t.jsxs("div",{className:"relative aspect-square overflow-hidden rounded-lg bg-slate-950",children:[t.jsx("img",{src:e.img,alt:e.title,loading:"lazy",decoding:"async",className:"h-full w-full object-cover"}),t.jsx("div",{className:"absolute left-2 top-2 rounded-full border border-white/15 bg-black/45 px-1.5 py-0.5 text-[8px] font-bold uppercase tracking-[0.14em] text-white/85 backdrop-blur-sm",children:e.badge})]}),t.jsxs("div",{className:"mt-2",children:[t.jsx("div",{className:"text-[12px] font-semibold text-gray-100",children:e.title}),t.jsx("div",{className:"text-[10px] text-gray-500",children:e.caption})]})]},e.title))})]})}function oS({value:e,onChange:n}){const r=String(e||"").split(/\r?\n/),s=nS(e),o=a=>{let l=-1;const c=r.filter(u=>u.trim()?(l+=1,l!==a):!0).join(` 116`).replace(/\n{3,}/g,` 117 118`).trim();n(c)};return s.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((a,l)=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-2 rounded-full border border-violet-400/20 bg-violet-500/10 px-3 py-1.5 text-[12px] text-violet-100 shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]",children:[t.jsx("span",{className:"truncate",children:a}),t.jsx("button",{type:"button",onClick:()=>o(l),"aria-label":`Remove ${a}`,className:"grid h-4 w-4 shrink-0 place-items-center rounded-full text-violet-200/80 transition duration-150 hover:bg-white/10 hover:text-white",children:t.jsx(ft,{className:"h-3 w-3"})})]},`${a}-${l}`))}):null}function aS({c:e,i:n,onRegen:r,busy:s,onEdit:o}){const a=["pending","rewriting","square","portrait"].includes(e.status),l={pending:"Queued",rewriting:"Writing the promptâ¦",square:"Rendering Squareâ¦",portrait:"Making Portraitâ¦",done:e.error||"Ready",failed:e.error||"Failed"}[e.status]||e.status,c=e.squareUrl||e.portraitUrl;return t.jsxs("div",{className:`${Rp} p-2.5 space-y-2 transition-all duration-200 hover:-translate-y-0.5 hover:border-violet-400/25`,children:[t.jsxs("div",{className:"relative aspect-square rounded-[20px] overflow-hidden bg-black grid place-items-center",children:[c?t.jsx("img",{src:c,alt:e.title,className:"w-full h-full object-cover",loading:"lazy"}):e.status==="failed"?t.jsx("span",{className:"text-amber-400 text-2xl font-bold",children:"!"}):t.jsx(Tn,{className:"w-5 h-5"}),a&&c&&t.jsx("div",{className:"absolute inset-0 bg-black/45 grid place-items-center",children:t.jsx(Tn,{className:"w-4 h-4"})}),t.jsx("span",{className:"absolute top-2 left-2 text-[10px] bg-black/60 text-white px-2 py-1 rounded-full",children:n+1})]}),t.jsx("div",{className:"text-[11px] font-medium text-gray-200 truncate",title:e.title,children:e.title}),t.jsx("div",{className:`text-[10px] ${e.error?"line-clamp-3 break-words":"truncate"} ${e.status==="failed"?"text-amber-300":"text-gray-400"}`,title:e.error||void 0,children:l}),t.jsxs("div",{className:"flex items-center gap-2",children:[e.squareUrl&&t.jsx("a",{href:e.squareUrl,download:!0,target:"_blank",rel:"noreferrer",className:"text-[10px] text-violet-300 hover:text-violet-200",children:"Square â"}),e.portraitUrl&&t.jsx("a",{href:e.portraitUrl,download:!0,target:"_blank",rel:"noreferrer",className:"text-[10px] text-violet-300 hover:text-violet-200",children:"Portrait â"}),c&&t.jsx("button",{type:"button",onClick:()=>o==null?void 0:o(e),title:"Edit in Photo Editor",className:"ml-auto rounded-full p-1 text-gray-400 transition duration-150 hover:bg-white/10 hover:text-violet-300",children:t.jsx(Wc,{className:"w-3 h-3"})}),t.jsx("button",{type:"button",onClick:r,disabled:s||a,title:"Regenerate this creative",className:"ml-auto rounded-full p-1 text-gray-400 transition duration-150 hover:bg-white/10 hover:text-violet-300 disabled:opacity-40",children:t.jsx(fo,{className:"w-3 h-3"})})]})]})}const iS=e=>{var o,a;if(!e)return"";const n=e.productName||"";if(e.kind==="pack"){const l=((o=e.pack)==null?void 0:o.creatives)||[],c=l.f
118ilter(d=>d.status==="done").length,u=e.pack?e.finished?c===0?"No ads came out":c===1?"1 ad ready":`${c} ads ready`:`${c} of ${l.length} ads made`:e.finished?"Ads ready":"Ads being made";return n?`${n} · ${u}`:u}const r=((a=e.productUrls)==null?void 0:a.length)||0,s=[n,r?`${r} product photo${r===1?"":"s"}`:"",e.productUrl?"From a product link":""].filter(Boolean);return s.length?s.join(" · "):"Product in progress"};function fl(e){return(e==null?void 0:e.status)==="generating"||((e==null?void 0:e.creatives)||[]).some(n=>["pending","rewriting","square","portrait"].includes(n.status))}function lS({configured:e,onEditInPhotoEditor:n,requireUser:r,onSignUp:s,onCreditsChanged:o,user:a=null,authLoading:l=!1,canLeaveStudio:c=null}){const u=d0(),d=i.useRef(null);a&&(d.current=String(a._id||a.id||"signed-in"));const h=d.current,p=!!a||!!d.current,[b,y]=i.useState(""),[v,w]=i.useState(null),C=i.useRef(null),[k,E]=i.useState("manual"),[m,M]=i.useState(""),[I,N]=i.useState([]),[F,R]=i.useState([]),[A,V]=i.useState(""),[z,H]=i.useState(""),[ne,se]=i.useState(""),[pe,ie]=i.useState(""),[O,D]=i.useState("square"),[W,oe]=i.useState(20),[we,Re]=i.useState(0);i.useEffect(()=>{let Z=!1;return fetch(`${$t}/api/static-ads/public-config`).then(xe=>xe.ok?xe.json():null).then(xe=>{!Z&&Number(xe==null?void 0:xe.creditPerImage)>0&&Re(Number(xe.creditPerImage))}).catch(()=>{}),()=>{Z=!0}},[]);const le=async(Z,xe)=>{const Le=await Jt(`${$t}/api/static-ads/${Z}`,xe||{});if(Le&&Le.ok===!1)throw new Error(Le.error||"Request failed.");return Le},Ne=async(Z,xe)=>{y(Z);try{return await xe()}catch(Le){if((Le==null?void 0:Le.code)==="INSUFFICIENT_CREDITS"||(Le==null?void 0:Le.code)==="INSUFFICIENT_TOKENS")return;me.error((Le==null?void 0:Le.message)||"Something went wrong.")}finally{y("")}},ce=!!(v!=null&&v.id)&&fl(v);i.useEffect(()=>{if(!(v!=null&&v.id)||!ce)return;let Z=!1,xe=null;const Le=Date.now(),et=async()=>{if(Z)return;if(typeof document>"u"||!document.hidden)try{const pt=await le("get",{jobId:v.id});!Z&&(pt!=null&&pt.job)&&w(pt.job)}catch{}if(Z)return;const ct=Date.now()-Le;xe=setTimeout(et,ct<3e4?3e3:ct<2*6e4?5e3:8e3)};return xe=setTimeout(et,3e3),()=>{Z=!0,clearTimeout(xe)}},[v==null?void 0:v.id,ce]);const[Ae,De]=i.useState(!1),Ze=i.useRef(!1),Ye=i.useRef(!1),[at]=i.useState(()=>k0("static-ads")),ut=i.useRef(!1),Xe=i.useCallback(async()=>{var ct,pt;s1();const Z=await Ho.read();if(!Z||Z.owner&&Z.owner!==$a&&Z.owner!==d.current)return null;let xe=null;if(Z.jobId)try{const _t=await Jt(`${$t}/api/static-ads/get`,{jobId:Z.jobId});xe=(_t==null?void 0:_t.job)||null}catch(_t){if((_t==null?void 0:_t.status)===404)return Ho.clear(),null}const Le=((xe==null?void 0:xe.creatives)||[]).find(_t=>_t.squareUrl||_t.portraitUrl),et=xe?!fl(xe):!!Z.finished;return{...Z,finished:et,kind:Z.jobId?"pack":"setup",pack:xe,currentStep:Z.jobId?et&&(xe==null?void 0:xe.status)!=="failed"?2:1:0,coverUrl:(Le==null?void 0:Le.squareUrl)||(Le==null?void 0:Le.portraitUrl)||((ct=Z.productUrls)==null?void 0:ct[0])||((pt=Z.extractedImages)==null?void 0:pt[0])||null}},[]),nt=()=>{S0("static-ads"),De(!0)};i.useEffect(()=>{if(l||a||Ae)return;let Z=!1;return(async()=>{let xe=null;try{const Le=await Ho.read();(Le==null?void 0:Le.owner)===$a&&(xe=Le)}catch{xe=null}Z||(xe&&!Ye.current&&(E(xe.mode||"manual"),M(xe.productUrl||""),N(xe.productUrls||[]),R(xe.extractedImages||[]),V(xe.productName||""),H(xe.productDescription||""),se(xe.keyPoints||""),ie(xe.brandUrl||""),D(xe.format||"square"),xe.count&&oe(xe.count),Ze.current=!0),De(!0))})(),()=>{Z=!0}},[l,a,Ae]);const xt=i.useRef(!a);i.useEffect(()=>{if(!a){d.current||(xt.current=!0);return}xt.current&&(xt.current=!1,!(v||Ye.current)&&De(!1))},[a,v]);const J=Z=>{Z&&(E(Z.mode||"manual"),M(Z.productUrl||""),N(Z.productUrls||[]),R(Z.extractedImages||[]),V(Z.productName||""),H(Z.productDescription||""),se(Z.keyPoints||""),ie(Z.brandUrl||""),D(Z.format||"square"),Z.count&&oe(Z.count),Z.pack?(fl(Z.pack)&&(C.current=Z.pack.id),w(Z.pack)):Z.jobId&&le("get",{jobId:Z.jobId}).then(xe=>{xe!=null&&xe.job&&(fl(xe.job)&&(C.current=xe.job.id),w(xe.job))}).catch(()=>{})),nt()},Ie=()=>{Ho.clear(),nt()},ht=()=>{ut.current=!0,De(!0)},Et=i.useRef(null),Ft=i.useRef(!!a);Ft.current=!!a;const Rt=Z=>{const xe=Ho.write(Z,{clearWhenEmpty:Ft.current||Ze.current});return Ze.current=xe,xe};i.useEffect(()=>()=>{const Z=Et.current;Z&&(Gc()&&Z.owner!==$a||Rt(Z))},[]);const Pt=fl(v);i.useEffect(()=>{if(!Ae)return;if(ut.current){ut.current=!1;return}const Z={owner:h||$a,jobId:(v==null?void 0:v.id)||null,finished:!!(v!=null&&v.id)&&!Pt,mode:k,productUrl:m,productUrls:I,extractedImages:F,productName:A,productDescription:z,keyPoints:ne,brandUrl:pe,format:O,count:W};Et.current=Z;const xe=setTimeout(()=>{Et.current=null,Rt(Z)},400);return()=>clearTimeout(xe)},[Ae,v==null?void 0:v.id,Pt,k,m,I,F,A,z,ne,pe,O,W]);const Ht=i.useRef(!1);i.useEffect(()=>{if(Pt){Ht.current=!0;return}Ht.current&&(Ht.current=!1,o==null||o())},[Pt]),i.useEffect(()=>{if(!(v!=null&&v.id)||C.current!==v.id||Pt)return;C.current=null;const Z=v.creatives||[],xe=Z.filter(ct=>ct.status==="done"&&(ct.squareUrl||ct.portraitUrl)).length;if(v.status!=="completed"||!xe)return;const Le=Et.current;Et.current=null,Le&&Ho.write({...Le,finished:!0});const et=Z.filter(ct=>ct.status==="failed").length;if(c&&!c()){me.success(t.jsxs("span",{"data-static-ads-ready-toast":!0,children:[et?`${xe} of ${xe+et} static ads came out. They're on your Projects page.`:"Your static ads are ready. They're on your Projects page."," ",t.jsx("button",{type:"button",onClick:()=>u("/projects?tab=allProjects"),className:"font-semibold underline underline-offset-2",children:"View"})]}));return}me.success(et?`${xe} of ${xe+et} static ads came out. Here they are with your other projects.`:"Your static ads are ready. Here they are with your other projects."),u("/projects?tab=allProjects")},[v==null?void 0:v.id,v==null?void 0:v.status,Pt]);const Gt=Z=>{const xe=Array.from(Z.target.files||[]);Z.target&&(Z.target.value=""),xe.length&&r!=null&&r("Sign in to add your product photo.")&&Ne("Uploadingâ¦",async()=>{const Le=[];for(const et of xe.slice(0,6))try{const ct=await ii(et);ct&&Le.push(ct)}catch(ct){qo(ct,"That photo couldn't be uploaded. Try again.")}N(et=>[...et,...Le].slice(0,6))})},Kt=()=>{if(r!=null&&r("Sign in to read your product page."))return Ne("Reading the product pageâ¦",async()=>
118{if(!/^https?:\/\/.+/i.test(m.trim()))return me.error("Paste a valid product URL.");const Z=await le("extract-url",{url:m.trim()});V(Z.productName||""),H(Z.productDescription||""),se(Z.keyPoints||""),ie(Z.brandUrl||""),R(Z.imageUrls||[]),N((Z.imageUrls||[]).slice(0,1)),me.success("Pulled the details, review, pick the image(s), then generate.")})},un=I.length&&A.trim()&&z.trim()&&ne.trim(),jt=!!X0({jobId:(v==null?void 0:v.id)||null,productUrl:m,productUrls:I,productName:A,productDescription:z,keyPoints:ne,brandUrl:pe});Ye.current=jt;const ln=W*(O==="both"?2:1),Je=we?ln*we:0,Qt=Math.max(0,Math.floor(Number(a==null?void 0:a.creditBalance)||0)),rn=(a==null?void 0:a.role)==="admin",Ot=we*(O==="both"?2:1),Qe=Ot?Math.floor(Qt/Ot):0,Vt=!!a&&!rn&&Je>0&&Qt<Je,En=Vt&&Qe<1,An=()=>Ne("Startingâ¦",async()=>{if(!(r!=null&&r("Sign in to make your ads.")))return;if(!un)return me.error("Add a product image, title, description and key points.");const Z=O==="both"?["square","portrait"]:[O],xe=await le("create",{inputMode:k,productUrl:m.trim(),brandUrl:pe.trim(),productImageUrls:I,productName:A.trim(),productDescription:z.trim(),keyPoints:ne.trim(),formats:Z,count:W});xe!=null&&xe.job&&(C.current=xe.job.id,w(xe.job))}),Lr=Z=>Ne("",async()=>{const xe=await le("regenerate",{jobId:v.id,index:Z});C.current=null,xe!=null&&xe.job&&w(xe.job)}),ur=Z=>Ne("",async()=>{const xe=await le("add-format",{jobId:v.id,format:Z});C.current=null,xe!=null&&xe.job&&w(xe.job)}),rt=()=>{C.current=null,w(null),N([]),R([]),V(""),H(""),se(""),ie(""),M(""),Ho.clear()},mt=()=>Ne("Stoppingâ¦",async()=>{C.current=null;const Z=await le("stop",{jobId:v.id});Z!=null&&Z.job&&w(Z.job)}),Ct=()=>Ne("Preparing downloadâ¦",async()=>{const Z=[];if(((v==null?void 0:v.creatives)||[]).forEach((pt,_t)=>{const $n=`${String(_t+1).padStart(2,"0")}-${(pt.title||pt.key||"ad").replace(/[^a-z0-9]+/gi,"-").slice(0,40)}`;pt.squareUrl&&Z.push({name:`${$n}-square.jpg`,url:pt.squareUrl}),pt.portraitUrl&&Z.push({name:`${$n}-portrait.jpg`,url:pt.portraitUrl})}),!Z.length)return me.error("Nothing to download yet.");const xe=(await c0(async()=>{const{default:pt}=await import("./jszip.min-BBttjx9z.js").then(_t=>_t.j);return{default:pt}},__vite__mapDeps([7,2]))).default,Le=new xe;await Promise.all(Z.map(async pt=>{try{const _t=await fetch(pt.url);Le.file(pt.name,await _t.blob())}catch{}}));const et=await Le.generateAsync({type:"blob"}),ct=document.createElement("a");ct.href=URL.createObjectURL(et),ct.download=`${(A||(v==null?void 0:v.title)||"static-ads").replace(/[^a-z0-9]+/gi,"-").slice(0,40)||"static-ads"}.zip`,document.body.appendChild(ct),ct.click(),ct.remove(),setTimeout(()=>URL.revokeObjectURL(ct.href),4e3),me.success("Downloaded all creatives.")}),mr=Z=>N(xe=>xe.includes(Z)?xe.filter(Le=>Le!==Z):[...xe,Z].slice(0,6));if(!e)return t.jsx(Ap,{});if(v){const Z=v.total||20,xe=Math.min(v.doneCount||0,Z),Le=(v.creatives||[]).filter(tt=>tt.status==="failed").length,et=v.status==="generating"||(v.creatives||[]).some(tt=>["pending","rewriting","square","portrait"].includes(tt.status)),ct=(v.creatives||[]).filter(tt=>["pending","rewriting","square","portrait"].includes(tt.status)).length,pt=et?Math.min(Z,Math.max(xe,xe+Math.min(3,ct||3))):xe,_t=Math.min(100,Math.round(xe/Z*100)),$n=v.formats||["square"],xn=$n.includes("square")?$n.includes("portrait")?null:"portrait":"square";return t.jsxs("div",{className:"space-y-7 pb-8",children:[t.jsxs("header",{children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-violet-300/80",children:"Static Ads"}),t.jsxs("h1",{className:"mt-2 text-3xl sm:text-4xl font-black tracking-tight text-white",children:["Your static ads, ",xe,"/",Z]}),t.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-gray-400",children:et?"Generating 3 at a time, they appear here as each one finishes.":"Download any creative, regenerate the ones you want to redo, or add the other aspect ratio below."})]}),t.jsxs(Fi,{className:"p-5 sm:p-6",children:[t.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold text-gray-100",children:et?`Generating ${pt} of ${Z}â¦`:`${xe} of ${Z} ready`}),t.jsx("div",{className:"mt-1 text-[12px] text-gray-500",children:et?"Running in batches of 3 on gpt-image-2.5.":Le?`${Le} failed, successful renders remain available.`:"Generation complete."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[et&&t.jsxs("button",{type:"button",onClick:mt,disabled:!!b,className:"inline-flex items-center gap-1.5 rounded-full border border-rose-400/30 bg-rose-500/10 px-3 py-1.5 text-[11px] font-semibold text-rose-200 transition hover:bg-rose-500/20 disabled:opacity-50",children:[t.jsx(ft,{className:"w-3.5 h-3.5"})," Stop"]}),t.jsxs("div",{className:"rounded-full border border-violet-400/20 bg-violet-500/10 px-3 py-1.5 text-[11px] font-semibold text-violet-100",children:[_t,"% complete"]})]})]}),t.jsx("div",{className:"mt-5 h-2.5 overflow-hidden rounded-full bg-white/10",children:t.jsx("div",{className:`h-full rounded-full bg-gradient-to-r from-violet-400 via-fuchsia-400 to-purple-600 transition-all duration-500 ${et?"animate-pulse":""}`,style:{width:`${_t}%`}})})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:(v.creatives||[]).map((tt,Xn)=>t.jsx(aS,{c:tt,i:Xn,onRegen:()=>Lr(Xn),busy:!!b,onEdit:mn=>n==null?void 0:n(mn.squareUrl||mn.portraitUrl)},`${tt.key}-${Xn}`))}),Le>0&&!et&&t.jsxs("div",{className:"text-[12px] text-amber-300 text-center",children:[Le," failed, only successful renders were charged. Use â» on a card to retry."]}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[xn&&!et&&t.jsxs("button",{type:"button",onClick:()=>ur(xn),disabled:!!b,className:"flex-1 inline-flex items-center justify-center gap-2 rounded-[20px] border border-violet-500/40 bg-violet-500/10 px-4 py-3 text-sm font-semibold text-violet-100 transition duration-200 hover:-translate-y-0.5 hover:bg-violet-500/20 disabled:opacity-50",children:[t.jsx(fs,{className:"w-4 h-4"})," Also generate"," ",xn==="portrait"?"Portrait":"Square"," (",Z,")"]}),xe>0&&t.jsxs("button",{type:"button",onClick:()=>u("/projects?tab=allProjects"),className:"flex-1 inline-flex items-center justify-center gap-2 rounded-[20px] border border-white/15 bg-white/[0.06] px-4 py-3 text-sm font-semibold text-white transition duration-200 hover:-translate-y-0.5 hover:bg-white/[0.1]",children:[t.jsx(zi,{className:"w-4 h-4"})," View in Projects"]}),xe>0&&t.jsxs("button",{type:"button",onClick:Ct,disabled:!!b,className:"flex-1 inline-flex items-center justify-center gap-2 rounded-[20px] border border-violet-500/40 bg-violet-500/10 px-4 py-3 text-sm font-semibold text-violet-100 transition duration-200 hover:-translate-y-0.5 hover:bg-violet-500/20 disabled:opacity-50",children:[t.jsx(go,{className:"w-4 h-4"})," Download all"]}),t.jsxs("button",{type:"button",onClick:rt,className:"flex-1 inline-flex items-center justify-center gap-2 rounded-[20px] bg-gradient-to-br from-violet-500 to-purple-700 px-4 py-3 text-sm font-semibold text-white shadow-[0_18px_44px_-24px_rgba(139,92,246,0.9)] transition duration-200 hover:-translate-y-0.5 hover:shadow-[0_20px_56px_-22px_rgba(168,85,247,1)] active:translate-y-0",children:[t.jsx(Ao,{className:"w-4 h-4"})," New product"]})]})]})}const pr=O==="both"?`${W*2} ads (Square + Portrait)`:O==="portrait"?`${W} Portrait ads`:`${W} Square ads`,rr=`${O==="both"?`${W} Square + ${W} Portrait`:O==="portrait"?`${W} Portrait`:`${W} Square`} on gpt-image-2.5 · 3 at a time · add the other ratio anytime`;I[0];const qn=[{value:"square",label:"Square",sub:"1:1"},{value:"portrait",label:"Portrait",sub:"9:16"},{value:"both",label:"Both",sub:"1:1 + 9:16"}];return t.jsxs("div",{className:"space-y-5 pb-24",children:[!Ae&&t.jsx(b0,{user:a,authLoading:l,autoResume:at,readSession:Xe,clearSession:Ho.clear,onResume:J,onStartFresh:Ie,onDismiss:ht,onNoSession:a?nt:void 0,toolLabel:"Static Ads",stepLabels:["Product","Making the ads","Ads ready"],buildSummary:Z=>({detail:iS(Z)})}),t.jsx(Kk,{title:"Static Ads",subtitle:"Turn one product into up to 20 scroll-stopping static ad creatives, meme, before/after, checklist, UGC and more. Pick Square, Portrait, or both. Powered by gpt-image-2.5."}),t.jsxs("div",{className:"grid items-start gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[t.jsxs("div",{className:"space-y-6",children:[t.jsxs(Fi,{className:"space-y-4",children:[t.jsx(t0,{title:"How do you want to add your product?"}),t.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:[{value:"manual",label:"âï¸ Enter details"},{value:"url",label:"ð From a product URL"}].map(Z=>{const xe=k===Z.value;return t.jsx("button",{type:"button",onClick:()=>E(Z.value),"aria-pressed":xe,className:`rounded-xl border px-3.5 py-2.5 text-left text-sm font-semibold transition-all duration-200 ${xe?"border-violet-500/50 bg-vi
118olet-500/20 text-violet-100":"border-white/10 bg-white/[0.035] text-gray-400 hover:-translate-y-0.5 hover:border-white/20 hover:bg-white/[0.06] hover:text-gray-200"}`,children:Z.label},Z.value)})}),k==="url"&&t.jsxs("div",{className:"space-y-3 pt-1",children:[t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[t.jsx("input",{value:m,onChange:Z=>M(Z.target.value),className:pl,placeholder:"https://yourstore.com/products/â¦"}),t.jsx("button",{type:"button",onClick:Kt,disabled:!!b,className:"inline-flex min-h-[42px] items-center justify-center rounded-xl border border-violet-500/40 bg-violet-500/15 px-4 text-sm font-semibold text-violet-100 transition duration-200 hover:-translate-y-0.5 hover:bg-violet-500/25 disabled:cursor-not-allowed disabled:opacity-50",children:b==="Reading the product pageâ¦"?t.jsx(Tn,{className:"w-4 h-4"}):"Extract"})]}),F.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[11px] text-gray-500",children:"Pick the product image(s), up to 6"}),t.jsx("div",{className:"flex flex-wrap gap-2.5",children:F.map(Z=>t.jsxs("button",{type:"button",onClick:()=>mr(Z),className:`relative h-[68px] w-[68px] overflow-hidden rounded-xl border-2 transition duration-200 hover:-translate-y-0.5 ${I.includes(Z)?"border-violet-400 shadow-[0_0_0_4px_rgba(139,92,246,0.16)]":"border-white/10 hover:border-white/25"}`,children:[t.jsx("img",{src:Z,alt:"",className:"h-full w-full object-cover"}),I.includes(Z)&&t.jsx("span",{className:"absolute inset-0 bg-violet-500/25"})]},Z))})]})]})]}),t.jsxs(Fi,{className:"space-y-5",children:[t.jsx(t0,{title:"Product"}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[I.map((Z,xe)=>t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:Z,alt:"",className:"h-20 w-20 rounded-xl border border-white/10 object-cover shadow-[0_14px_42px_-32px_rgba(0,0,0,0.9)]"}),t.jsx("button",{type:"button",onClick:()=>N(Le=>Le.filter((et,ct)=>ct!==xe)),className:"absolute -right-2 -top-2 grid h-7 w-7 place-items-center rounded-full border border-white/15 bg-black/75 text-white shadow-lg transition duration-150 hover:bg-violet-500","aria-label":"Remove product image",children:t.jsx(ft,{className:"h-3.5 w-3.5"})})]},Z)),I.length<6&&t.jsxs("label",{...wl(Z=>Gt({target:{files:Z,value:""}})),className:"group flex h-20 w-20 cursor-pointer flex-col items-center justify-center gap-1.5 rounded-xl border border-dashed border-white/20 bg-white/[0.02] text-gray-500 transition-all duration-200 hover:-translate-y-0.5 hover:border-violet-500/50 hover:bg-violet-500/10 hover:text-violet-100",children:[t.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Gt,className:"hidden"}),t.jsx("span",{className:"grid h-8 w-8 place-items-center rounded-full bg-white/[0.06] transition duration-200 group-hover:bg-violet-500/20",children:t.jsx(fs,{className:"h-5 w-5"})})]})]}),t.jsx(Ii,{label:"Product title *",children:t.jsx("input",{value:A,onChange:Z=>V(Z.target.value),className:pl,placeholder:"e.g. AG1 Nutrient Boost Pouch"})}),t.jsx(Ii,{label:"Description *",children:t.jsx("textarea",{rows:3,value:z,onChange:Z=>H(Z.target.value),className:`${pl} resize-y leading-relaxed`,placeholder:"What it is and its main benefit"})}),t.jsxs(Ii,{label:"Important points *",hint:"The selling points the ads should lean on, one per line.",children:[t.jsx("textarea",{rows:4,value:ne,onChange:Z=>se(Z.target.value),className:`${pl} resize-y leading-relaxed`,placeholder:`Foundational nutrition in one scoop 119Supports energy & gut health 12075 vitamins, minerals & whole-food sourced`}),t.jsx(oS,{value:ne,onChange:se})]}),t.jsx(Ii,{label:"Brand website (optional)",hint:"Backup context for the brand's tone & colours.",children:t.jsx("input",{value:pe,onChange:Z=>ie(Z.target.value),className:pl,placeholder:"https://yourbrand.com"})})]}),t.jsx(Fi,{children:t.jsx(Ii,{label:"How many creatives",hint:"Generate between 10 and 20 unique ad styles.",children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("input",{type:"range",min:10,max:20,step:1,value:W,onChange:Z=>oe(Number(Z.target.value)),className:"flex-1 accent-violet-500"}),t.jsx("div",{className:"w-14 shrink-0 rounded-lg border border-violet-500/40 bg-violet-500/15 px-2 py-1.5 text-center text-sm font-bold tabular-nums text-violet-100",children:W})]})})}),t.jsx(Fi,{children:t.jsx(Ii,{label:"Aspect ratio",hint:"Pick one to generate faster, you can add the other ratio afterward.",children:t.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:qn.map(Z=>{const xe=O===Z.value;return t.jsxs("button",{type:"button",onClick:()=>D(Z.value),"aria-pressed":xe,className:`group flex min-h-[88px] flex-col items-center justify-center gap-2 rounded-xl border p-3 text-center transition-all duration-200 ${xe?"border-violet-500/50 bg-vi
120olet-500/20 text-violet-100":"border-white/10 bg-white/[0.035] text-gray-400 hover:-translate-y-0.5 hover:border-white/20 hover:bg-white/[0.06] hover:text-gray-200"}`,children:[t.jsx(rS,{value:Z.value,active:xe}),t.jsxs("span",{children:[t.jsxs("span",{className:"block text-sm font-semibold",children:[Z.label," ",Z.sub==="1:1"?"(1:1)":Z.sub==="9:16"?"(9:16)":""]}),Z.value==="both"&&t.jsx("span",{className:"block text-[11px] text-gray-400",children:"Square + Portrait"})]})]},Z.value)})})})})]}),t.jsx("div",{className:"space-y-4 xl:sticky xl:top-5",children:t.jsx(sS,{})})]}),!p&&!l&&jt&&t.jsx("div",{className:"mb-4","data-static-ads-signup":!0,children:t.jsxs(td,{title:"Sign up to generate your ads",onClick:()=>s==null?void 0:s(),note:"Your current session will be saved",children:["Get ",t.jsx("strong",{className:"text-white",children:"7 free credits"})," when you sign up, no subscription required."]})}),Vt&&t.jsxs("div",{className:"mb-4 rounded-xl border border-amber-500/25 bg-amber-500/[0.07] px-4 py-3 flex flex-col sm:flex-row sm:items-center gap-3","data-static-ads-short":!0,children:[t.jsx("p",{className:"text-[12px] text-amber-100/90 leading-relaxed flex-1",children:En?"You have no credits left, so there is nothing to make these ads with.":`This pack is ${Je} credits and you have ${Qt}, so ${Qe} of the ${W} ads will be made.`}),t.jsx("button",{type:"button",onClick:()=>bl({reason:"credits",needed:Je,balance:Qt}),className:"shrink-0 inline-flex items-center justify-center px-4 py-2 rounded-full bg-white/[0.08] border border-white/15 text-[12px] font-semibold text-white hover:bg-white/[0.14] transition",children:"Get credits"})]}),t.jsx("div",{className:"sticky bottom-4 z-20",children:t.jsx("div",{className:`${Rp} p-2.5 sm:p-3`,children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[12px] font-medium text-gray-300",children:rr}),Je>0&&!rn&&t.jsxs("div",{className:"mt-0.5 text-[12px] text-gray-400","data-static-ads-cost":!0,children:[t.jsx("span",{className:"font-semibold text-white",children:Je})," ","credits · ",ln," à ",we]}),b&&t.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-white/10",children:t.jsx("div",{className:"h-full w-2/5 animate-pulse rounded-full bg-gradient-to-r from-violet-400 to-fuchsia-400"})})]}),t.jsx("button",{type:"button",onClick:An,disabled:!!b||!un,className:"inline-flex min-h-[44px] items-center justify-center gap-2 rounded-xl bg-gradient-to-br from-violet-500 via-purple-600 to-fuchsia-700 px-5 text-sm font-bold text-white shadow-[0_16px_42px_-24px_rgba(168,85,247,1)] transition duration-200 hover:-translate-y-0.5 hover:shadow-[0_20px_54px_-24px_rgba(168,85,247,1)] active:translate-y-0 disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:translate-y-0",children:b?t.jsxs(t.Fragment,{children:[t.jsx(Tn,{className:"w-4 h-4"})," ",b||"Workingâ¦"]}):t.jsxs(t.Fragment,{children:[t.jsx(Ao,{className:"w-4 h-4"})," Generate"," ",pr]})})]})})})]})}const Pp="studioe_ugc_last_job_v1",cS=()=>{try{return localStorage.getItem(Pp)||""}catch{return""}},dS=e=>{try{localStorage.setItem(Pp,String(e))}catch{}},Ic=()=>{try{localStorage.removeItem(Pp)}catch{}},Tp="studioe_ugc_fresh_start_v1",n0=()=>{try{return localStorage.getItem(Tp)==="1"}catch{return!1}},r0=()=>{try{localStorage.setItem(Tp,"1")}catch{}},uS=()=>{try{localStorage.removeItem(Tp)}catch{}};function mS({configured:e,authLoading:n=!1,requireUser:r,requirePro:s,onSignUp:o,onJobCreated:a,onGoToProjects:l,onOpenInEditor:c,onEditVideo:u,onCreditsChanged:d,cloneSeed:h,onCloneSeedConsumed:p,user:b,onUpgrade:y,canLeaveStudio:v=null}){var _e,He,yt,dn,Ut,it,Tt,wn,an,ns,Ms;const w=i.useRef(null);b&&(w.current=String(b._id||b.id||"signed-in"));const C=w.current,k=!!b||!!w.current,E=C||"",[m,M]=i.useState(null),[I,N]=i.useState(""),F=i.useRef(null),R=i.useRef(null),A=i.useRef(!1);i.useEffect(()=>{R.current=(m==null?void 0:m.id)||null},[m==null?void 0:m.id]),i.useEffect(()=>{m!=null&&m.id&&(dS(m.id),uS())},[m==null?void 0:m.id]);const V=i.useRef(!1),[z,H]=i.useState({templates:[],voiceDefaults:{},emotionalTriggers:[],tonePresets:[],creditsPerSecond:{}
120,billedSeconds:null,creditCost:{},promptMaxChars:yu}),[ne,se]=i.useState(null),[pe,ie]=i.useState(null),[O,D]=i.useState(!0),[W,oe]=i.useState(null),[we,Re]=i.useState(null),[le,Ne]=i.useState(null),[ce,Ae]=i.useState("create"),[De,Ze]=i.useState([]),[Ye,at]=i.useState({}),[ut,Xe]=i.useState(""),[nt,xt]=i.useState(""),[J,Ie]=i.useState(""),[ht,Et]=i.useState(!1),[Ft,Rt]=i.useState(!1),[Pt,Ht]=i.useState("UGC"),{isFav:Gt,toggleFav:Kt,getFavIds:un}=x0(),jt=un(Io),[ln,Je]=i.useState(""),[Qt,rn]=i.useState(""),Ot=i.useDeferredValue(Qt),[Qe,Vt]=i.useState(null),[En,An]=i.useState("models"),Lr=i.useRef(!1),ur=i.useRef(""),rt=i.useCallback(g=>{Vt(g);const _=g?`${g.kind}:${g.id}`:"";_!==ur.current&&(ur.current=_,!Lr.current&&(g!=null&&g.gender)&&pt(g.gender==="male"?"Will":"Rachel"))},[]),[mt,Ct]=i.useState("9x16"),[mr,pr]=i.useState("720p"),[rr,qn]=i.useState(12),[Z,xe]=i.useState("off"),[Le,et]=i.useState("native"),[ct,pt]=i.useState("Rachel"),[_t,$n]=i.useState(!0),[xn,tt]=i.useState(1),[Xn,mn]=i.useState(""),[Ke,ot]=i.useState(""),[qt,sr]=i.useState(""),[zn,Bn]=i.useState(""),[jn,vt]=i.useState(""),[Mn,fr]=i.useState(""),[or,bo]=i.useState(""),[In,jr]=i.useState("");i.useEffect(()=>{h&&(A.current=!0,Ae("clone"),h.sourceUrl&&jr(h.sourceUrl),p==null||p())},[h]);const[Jn,en]=i.useState(0),[Nr,Zn]=i.useState(0),Or=i.useRef(!1),gn=i.useRef(0),[Hn,hr]=i.useState(1),[kr,ze]=i.useState(!1),Qn=i.useRef(null),Kn=i.useRef(null),ar=()=>{const g=Qn.current;g&&g.getBoundingClientRect().top<96&&g.scrollIntoView({block:"start",behavior:"smooth"})},_n=g=>{Zn(0),hr(g),ar()},bn="w-full px-3 py-2 rounded-lg bg-white/[0.03] border border-white/10 text-sm text-gray-100 placeholder-gray-500 focus:border-blue-500/50 focus:outline-none",Dn="inline-flex items-center gap-1.5 min-h-[38px] px-3.5 py-2 rounded-full border border-white/15 bg-white/[0.05] text-[12px] font-medium text-gray-200 hover:bg-white/[0.1] hover:border-white/30 hover:text-white transition",Se=async(g,_)=>{const G=await Jt(`${$t}/api/ugc-studio/${g}`,_||{});if(G&&G.ok===!1){const de=new Error(G.error||"Request failed.");throw de.code=G.code,de}return G},is=i.useRef({ugc:null,tryOn:(g,_)=>Jt(`${$t}/api/model-try-on/v2/${g}`,_||{}),preparePhoto:async g=>{const _=await y0(g,$t,{strict:!0}),G=await v0(_);let de="";try{de=await w0(G)}catch{de=""}return{file:G,dataUrl:de}}});is.current.ugc=Se;const Wt=i.useCallback(g=>{if((b==null?void 0:b.role)==="admin")return!0;if(!ey(b))return!1;const _=b==null?void 0:b.subscriptionTier;return g==="elite"?_==="elite":g==="pro"?_==="pro"||_==="elite":["lite","pro","elite"].includes(_)},[b==null?void 0:b.role,b==null?void 0:b.subscriptionStatus,b==null?void 0:b.subscriptionTier]),_o=Wt("elite"),Tr=i.useRef(null);Tr.current=g=>{r&&!r("Sign in to use this model.")||y==null||y(g==="elite"?"You need an Elite subscription to use this model.":g==="pro"?"You need a Pro subscription to use this model.":"You need a subscription to use this model.")};const ta=i.useCallback(g=>{var _;return(_=Tr.current)==null?void 0:_.call(Tr,g)},[]),Nt=async(g,_)=>{N(g);try{return await _()}catch(G){if((G==null?void 0:G.code)==="CREATOR_CONSENT_REQUIRED"){me.info("Choose a model for this video to carry on. Its creator is from the earlier UGC Studio."),_n(2);return}if((G==null?void 0:G.code)==="MODEL_TIER_LOCKED"){y==null||y(G.message);return}if((G==null?void 0:G.code)==="INSUFFICIENT_CREDITS"||(G==null?void 0:G.code)==="INSUFFICIENT_TOKENS")return;me.error((G==null?void 0:G.message)||"Something went wrong.")}finally{N("")}},qr=g=>Nt("",async()=>{if(!(m!=null&&m.id))return;const _=await Se("update",{jobId:m.id,...g});_!=null&&_.job&&_.job.id===R.current&&M(_.job)});i.useEffect(()=>{if(!e)return;let g=!1;return D(!0),(async()=>{const _=async()=>E?await Se("templates"):await fetch(`${$t}/api/ugc-studio/public-templates`).then(G=>{if(!G.ok)throw new Error(`templates ${G.status}`);return G.json()});try{let G=null;try{G=await _()}catch{if(g||(await new Promise(Ue=>setTimeout(Ue,1200)),g))return;G=await _()}G!=null&&G.ok&&!g&&H({templates:Array.isArray(G.templates)?G.templates:[],voiceDefaults:G.voiceDefaults||{},emotionalTriggers:G.emotionalTriggers||[],tonePresets:G.tonePresets||[],creditsPerSecond:G.creditsPerSecond||{}
120,billedSeconds:G.billedSeconds||null,creditCost:G.creditCost||{},promptMaxChars:G.promptMaxChars||yu})}catch{}finally{g||D(!1)}})(),()=>{g=!0}},[e,E]);const Wn=i.useRef(null),Vr=i.useCallback(g=>{if(!(g!=null&&g.id)||Wn.current===g.id)return;Wn.current=g.id,(g.mode==="clone"?"clone":"create")!==ce&&(No.current=!0),Ae(g.mode==="clone"?"clone":"create");const _=g.productAssets||{};Ze(jl(_.product||g.productImageUrls||[]));const G={};for(const Ue of xb){if(Ue==="product")continue;const dt=jl(_[Ue]||[]);dt.length&&(G[Ue]=dt)}at(G),Xe(g.productName||""),xt(g.productDetails||""),g.styleKey&&Ie(g.styleKey),Et(!!g.styleKey),Rt(!1),ie(null),jr(g.sourceVideoUrl||""),en(g.sourceDurationSeconds||0),Ct(g.aspectRatio||"9x16"),pr(g.videoResolution||"720p"),qn(g.durationSeconds||12),xe(g.audioMode||"off"),et(g.voiceMode||"native"),pt(g.voice||"Rachel"),$n(g.wantCaptions!==!1),tt(g.batchCount||1),mn(g.industry||""),ot(g.targetAudience||""),sr(g.painPoints||""),Bn(g.desiredOutcome||""),vt(g.emotionalTriggers||""),fr(g.cta||""),bo(g.tone||"");const de=Zh(g);Vt(de),ur.current=de?`${de.kind}:${de.id}`:"",g.voice&&(Lr.current=!0),An((g.creatorChoice||g.creatorMode)==="custom"?"mine":"models")},[ce]),gs=async()=>{const g=await Se("latest");let _=(g==null?void 0:g.job)||null;if(_&&(g==null?void 0:g.session)===void 0&&(n0()||_.status==="completed")&&(_=null),!_&&(g==null?void 0:g.session)===!1&&!n0()){const G=cS();if(G){try{const de=await Se("get",{jobId:G,open:!0});_=(de==null?void 0:de.opened)===!1?null:(de==null?void 0:de.job)||null}catch{_=null}_&&(_.status==="completed"||_.status==="draft")&&(_=null),_||Ic()}}return _},Qs=i.useRef(gs);Qs.current=gs;const eo=i.useRef(!1),gt=g=>{A.current||R.current&&R.current!==g.id||(F.current=g.finalJobId||null,M(g),Vr(g))},[U,ue]=i.useState(()=>!!h),Q=i.useRef(!1),fe=i.useRef(!1),[ge]=i.useState(()=>k0("ugc-studio")),je=i.useRef(null),Oe=i.useRef(!1);i.useEffect(()=>{if(n||b||U)return;let g=!1;return(async()=>{let _=null;try{const G=await Ma.read();(G==null?void 0:G.owner)===$a&&!G.jobId&&(_=G)}catch{_=null}g||(_&&!A.current&&!fe.current&&(Vr(yf(_)),Q.current=!0),ue(!0))})(),()=>{g=!0}},[n,b,U]);const st=i.useRef(!b);i.useEffect(()=>{if(!b){w.current||(st.current=!0);return}st.current&&(st.current=!1,!(m||fe.current||A.current)&&ue(!1))},[b,m]);const Ee=i.useRef(l);Ee.current=l;const tn=i.useCallback(async()=>{var dt,At;let g=null,_=!0;const G=sn=>sn&&(!sn.owner||sn.owner===$a||sn.owner===w.current)?sn:null;try{g=await Qs.current()}catch{g=null,_=!1}const de=G(await Ma.read());let Ue=null;return eo.current=!g&&!!(de!=null&&de.jobId)&&!_,eo.current?Ue=null:g?Ue={kind:"job",job:g,ts:Date.parse(g.updatedAt||"")||(de==null?void 0:de.ts)||Date.now(),currentStep:Fu(g.status),coverUrl:(g.productImageUrls||[])[0]||null,title:g.title||g.productName||""}:de!=null&&de.jobId?(Ma.clear(),de.finished||Jt(`${$t}/api/ugc-studio/get`,{jobId:de.jobId}).then(sn=>{var cr;if(((cr=sn==null?void 0:sn.job)==null?void 0:cr.status)!=="completed"||!sn.job.finalVideoUrl)return;const tr=(sn.job.variations||[]).filter(da=>da.status==="done"&&(da.finalUrl||da.videoUrl)).length||1;me.success(t.jsxs("span",{"data-ugc-finished-away-toast":!0,children:[tr>1?`Your ${tr} UGC videos finished while you were away. They're on your Projects page.`:"Your UGC video finished while you were away. It's on your Projects page."," ",t.jsx("button",{type:"button",onClick:()=>{var da;return(da=Ee.current)==null?void 0:da.call(Ee)},className:"font-semibold underline underline-offset-2",children:"View"})]}))}).catch(()=>{})):de&&(Ue={...de,kind:"setup",currentStep:0,coverUrl:((dt=de.productUrls)==null?void 0:dt[0])||((At=de.creator)==null?void 0:At.imageUrl)||null,title:de.productName||""}),je.current=Ue,Ue},[]),Dt=()=>{S0("ugc-studio"),ue(!0)},Ds=()=>{if(eo.current){Oe.current=!0,ue(!0);return}Dt()},Xr=g=>{(g==null?void 0:g.kind)==="job"?gt(g.job):(g==null?void 0:g.kind)==="setup"&&!A.current&&Vr(yf(g)),Dt()},ls=()=>{const g=je.current;Ma.clear(),(g==null?void 0:g.kind)==="job"&&(Se("leave",{jobId:g.job.id}).catch(()=>{}),Ic(),r0()),Dt()},Do=()=>{Oe.current=!0,ue(!0)},cs=i.useRef(null),Sr=i.useRef(!!b);Sr.current=!!b;const yo=g=>{const _=Ma.write(g,{clearWhenEmpty:Sr.current||Q.current});return Q.current=_,_};i.useEffect(()=>()=>{const g=cs.current;g&&(Gc()&&g.owner!==$a||yo(g))},[]),i.useEffect(()=>{if(!U)return;if(Oe.current){Oe.current=!1;return}const g=Ru.includes(m==null?void 0:m.status)||(m==null?void 0:m.regeneratingFrame)||(m==null?void 0:m.generatingVariation)>=0,_={owner:C||$a,jobId:(m==null?void 0:m.id)||null,jobTitle:(m==null?void 0:m.title)||"",finished:(m==null?void 0:m.status)==="completed"&&!g,mode:ce,productUrls:De,refImages:Ye,productName:ut,productDetails:nt,styleKey:J,creator:Qe,modelTab:En,aspect:mt,resolution:mr,duration:rr,audioMode:Z,voiceMode:Le,voice:ct,wantCaptions:_t,batchCount:xn,industry:Xn,targetAudience:Ke,painPoints:qt,desiredOutcome:zn,emotionalTriggers:jn,cta:Mn,tone:or,sourceUrl:In,sourceDuration:Jn};cs.current=_;const G=setTimeout(()=>{cs.current=null,yo(_)},400);return()=>clearTimeout(G)},[U,m==null?void 0:m.id,m==null?void 0:m.status,m==null?void 0:m.title,m==null?void 0:m.regeneratingFrame,m==null?void 0:m.generatingVariation,ce,De,Ye,ut,nt,J,Qe,En,mt,mr,rr,Z,Le,ct,_t,xn,Xn,Ke,qt,zn,jn,Mn,or,In,Jn]);const Cr=!!(m!=null&&m.id)&&(Ru.includes(m.status)||!!m.regeneratingFrame||m.generatingVariation>=0);i.useEffect(()=>{if(!(m!=null&&m.id)||!Cr)return;let g=!1,_=null;const G=Date.now(),de=()=>typeof document<"u"&&document.hidden,Ue=()=>{if(g)return;if(de()){document.addEventListener("visibilitychange",dt,{once:!0});return}const At=Date.now()-G;_=setTimeout(dt,At<2*6e4?4e3:At<10*6e4?8e3:15e3)};async function dt(){if(!g){if(de())return Ue();try{const At=await Se("get",{jobId:m.id});At!=null&&At.job&&At.job.id===R.current&&M(sn=>V.current&&(sn!=null&&sn.scriptJson)?{...At.job,scriptJson:sn.scriptJson}:At.job)}catch{}Ue()}}return Ue(),()=>{g=!0,clearTimeout(_),document.removeEventListener("visibilitychange",dt)}},[m==null?void 0:m.id,Cr]);const bs=i.useRef(null);i.useEffect(()=>{bs.current!==((m==null?void 0:m.id)||null)&&(bs.current=(m==null?void 0:m.id)||null,es(null),Re(null),k
120o(null),Br(null))},[m==null?void 0:m.id]),i.useEffect(()=>{if(!m){gn.current=0,Zn(0);return}m.status==="script_ready"&&Or.current&&(Or.current=!1,Nt("",async()=>{const G=await Se("generate-frame",{jobId:m.id});G!=null&&G.job&&M(G.job)}));const g=Fu(m.status),_=gn.current;gn.current=g,g>_&&Zn(G=>G===_?g:G)},[m==null?void 0:m.id,m==null?void 0:m.status]);const Ls=i.useRef("");i.useEffect(()=>{if(!(m!=null&&m.id))return;const g=m.status==="generating"||m.status==="composing"||(m.generatingVariation??-1)>=0,_=`${m.id}|${g?"rendering":"idle"}`,G=Ls.current;Ls.current=_,!(!G||G===_)&&G.split("|")[0]===m.id&&(d==null||d())},[m==null?void 0:m.id,m==null?void 0:m.status,m==null?void 0:m.generatingVariation]);const Nn=i.useRef(null),Fn=i.useRef(null);i.useEffect(()=>{m!=null&&m.id&&(m.status==="generating"||m.status==="composing"||(m.generatingVariation??-1)>=0)&&(Nn.current=m.id)},[m==null?void 0:m.id,m==null?void 0:m.status,m==null?void 0:m.generatingVariation]),i.useEffect(()=>{if((m==null?void 0:m.status)==="completed"&&m.finalVideoUrl&&m.finalJobId&&F.current!==m.finalJobId){const g=Fn.current==="completed";if(F.current=m.finalJobId,g)return;const _=String(m.error||"").trim();_||Ic();const G=(m.variations||[]).filter(cr=>cr.status==="done"&&cr.renderJobId&&cr.finalUrl),de=(m.variations||[]).length>1,Ue=(m.variations||[]).filter(cr=>cr.status==="failed").length,dt=Ue?Ue===1?" One didn't finish, and its credits were refunded.":` ${Ue} didn't finish, and their credits were refunded.`:"",At=G.length?G.map(cr=>({id:cr.renderJobId,title:de?`${m.title||"UGC video"} · Variation ${(cr.index??0)+1}`:m.title,resultUrl:cr.finalUrl})):[{id:m.finalJobId,title:m.title,resultUrl:m.finalVideoUrl}],sn=new Date().toISOString();for(const cr of At)a==null||a({...cr,kind:"ugc",mediaType:"video",status:"completed",createdAt:sn});if(_){Nn.current=null,me.warn(t.jsx("span",{"data-ugc-ready-toast":!0,"data-ugc-stopped-short":!0,children:_}),{autoClose:12e3});return}if(Nn.current===m.id&&l&&(!v||v())){Nn.current=null;const cr=cs.current||Ma.readPlain();cs.current=null,cr&&cr.jobId===m.id&&Ma.write({...cr,finished:!0}),me.success(t.jsx("span",{"data-ugc-ready-toast":!0,children:(At.length>1?`Your ${At.length} UGC videos are ready. Here they are with your other videos.`:"Your UGC video is ready. Here it is with your other videos.")+dt})),l();return}const tr=(At.length>1?`Your ${At.length} UGC videos are ready. They're on your Projects page with your other videos.`:"Your UGC video is ready. It's on your Projects page with your other videos.")+dt;me.success(t.jsxs("span",{"data-ugc-ready-toast":!0,children:[tr," ",t.jsx("button",{type:"button",onClick:()=>l==null?void 0:l(),className:"font-semibold underline underline-offset-2",children:"View"})]}))}},[m==null?void 0:m.status,m==null?void 0:m.finalVideoUrl,m==null?void 0:m.finalJobId]),i.useEffect(()=>{Fn.current=(m==null?void 0:m.status)||null},[m==null?void 0:m.id,m==null?void 0:m.status]);const We=i.useMemo(()=>z.templates.find(g=>g.key===J)||null,[z.templates,J]),Ln={imageSlots:[{id:"product",label:"Product photo",hint:"A clean shot of your product on a plain background",required:!0,multiple:!0}],handsOnly:!1},er=(We==null?void 0:We.inputSchema)||Ln,Lo=(er.imageSlots||[]).find(g=>g.id==="product")||Ln.imageSlots[0],yn=(er.imageSlots||[]).filter(g=>g.id!=="product"),to=i.useMemo(()=>{const g={product:jl(De)};if(ce==="create")for(const _ of yn){const G=jl(Ye[_.id]||[]);G.length&&(g[_.id]=G)}return g},[De,ce,yn,Ye]),ds=eS(to),On=ce==="create"?yn.reduce((g,_)=>g+(Ye[_.id]||[]).length,0):0,no=De.length+On,ys=Math.max(0,Ei-no),vs=Math.max(0,Ei-Math.max(1,De.length)-On),vo=We?((_e=We.inputSchema)==null?void 0:_e.needsAvatar)??(We.person&&!We.handsOnly):!0,Jr=Number((He=z.billedSeconds)==null?void 0:He.max)||15,Os=Jd(z,mr,ce==="clone"&&In&&Jn?Jn:rr),Xt=m?typeof m.videoCredits=="number"?m.videoCredits:Jd(z,m.videoResolution,m.mode==="clone"&&m.sourceVideoUrl&&m.sourceDurationSeconds?m.sourceDurationSeconds:m.durationSeconds):0,wo=i.useMemo(()=>{const g=[];for(const _ of z.templates)_.section&&!g.includes(_.section)&&g.push(_.section);return g},[z.templates]),Vs=i.useCallback(g=>Pt==="All"||(Pt===ml?jt.includes(g.key):g.section===Pt),[Pt,jt]),ro=i.useMemo(()=>{const g=new Map;for(const _ of z.templates){if(!Vs(_))continue;const G=_.category||"Other";g.set(G,(g.get(G)||0)+1)}return[...g.entries()].map(([_,G])=>({name:_,count:G}))},[z.templates,Vs]),so=150,Us=i.useMemo(()=>{const g=Ot.trim().toLowerCase();return z.templates.filter(_=>!(!Vs(_)||ln&&_.category!==ln||g&&!`${_.label} ${_.category} ${_.section} ${_.blurb} ${_.prompt||""}`.toLowerCase().includes(g)))},[z.templates,Vs,ln,Ot]),zs=i.useRef(!1),$e=ce==="clone"?!!In:!!J&&(zs.current||!Ft);i.useEffect(()=>{zs.current=$e},[$e]);const kt=ce==="clone"||vo,on=!!Qe&&(Qe.ready||Qe.prepareFailed),kn=m?m.creatorChoice||m.creatorMode:"",ws=!!m&&!Qe&&Tu.includes(m.creatorChoice||m.creatorMode),oo=!!q0({jobId:(m==null?void 0:m.id)||null,productUrls:De,refImages:Ye,styleKey:J,creator:Qe,sourceUrl:In,productName:ut,productDetails:nt,industry:Xn,targetAudience:Ke,painPoints:qt,desiredOutcome:zn,cta:Mn});fe.current=oo;const Oo=ce==="clone"?In?De.length?"":"Add at least one product photo":"Upload the ad you want to clone":J?De.length?ut.trim()?"":"Name your product":"Add at least one product photo":"Choose a prompt",Bs=!Oo,ao=!!m&&!!Qe&&(Qe.kind==="custom"?kn==="custom"&&String(m.customModelId||"")===Qe.id:kn==="model"&&String(m.creatorModelId||"")===Qe.id),na=kt?Qe&&!Qe.ready&&!Qe.prepareFailed&&!ao?"Wait for your model to finish updating":ce==="create"&&!on&&!ws&&!ao?"Choose a model":"":"",io=Bs&&!na,jo=Oo||na,js=i.useMemo(()=>
120!kt||!on?{creatorMode:ce==="clone"?"fal":"none",creatorPrompt:""}:Qe.kind==="custom"?{creatorMode:"custom",customModelId:Qe.id}:{creatorMode:"model",creatorModelId:Qe.id},[ce,kt,on,Qe]),Ur={"9x16":"9:16","1x1":"1:1","4x5":"4:5","16x9":"16:9"},ja=(We==null?void 0:We.label)||"",ra=kt?Qe?Qe.name:ws?m.avatarName||"Creator from the earlier UGC Studio":ce==="clone"?"Matched from the ad":"Not chosen yet":er.handsOnly?"Hands only, nobody on camera":"Product only, nobody on camera",Zr=`${Ur[mt]||mt} · ${mr} · ${rr}s · ${xn} variation${xn>1?"s":""}`,No=i.useRef(!1);i.useEffect(()=>{if(No.current){No.current=!1;return}hr(1),at({})},[ce]);const gi=g=>{Ie(g.key),et(g.speech==="voiceover"?"voiceover":g.speech==="none"?"none":"native"),(g.videoSeconds||g.duration)&&qn(g.videoSeconds||g.duration),typeof g.captions=="boolean"&&$n(g.captions),g.aspect&&Ct(g.aspect),g.resolution&&pr(g.resolution),g.audioHint&&xe(g.audioHint)},Qr=g=>{Ne(null),Re(null),gi(g),oe(null),ie("prompt"),!ht&&Rt(!0)};i.useEffect(()=>{if(!Ft)return;const g=setTimeout(()=>{Et(!0),Rt(!1)},240);return()=>clearTimeout(g)},[Ft]);const Ha=g=>{const _=new Set(jn.split(",").map(G=>G.trim()).filter(Boolean));_.has(g)?_.delete(g):_.add(g),vt([..._].join(", "))},Hs=g=>{const _=Array.from(g.target.files||[]);g.target.value="",_.length&&r!=null&&r("Sign in to add your product photo.")&&Nt("Uploading productâ¦",async()=>{const G=[];for(const de of _.slice(0,ys))try{const Ue=await ii(de);Ue&&G.push(Ue)}catch(Ue){qo(Ue,"That photo couldn't be uploaded. Try again.")}Ze(de=>[...de,...G].slice(0,Math.max(0,Ei-On)))})},Ns=(g,_)=>G=>{const de=Array.from(G.target.files||[]);if(G.target.value="",!de.length||!(r!=null&&r("Sign in to add your images.")))return;const Ue=Math.min(_-(Ye[g]||[]).length,vs);Nt("Uploadingâ¦",async()=>{const dt=[];for(const At of de.slice(0,Math.max(0,Ue)))try{const sn=await ii(At);sn&&dt.push(sn)}catch(sn){qo(sn,"That photo couldn't be uploaded. Try again.")}at(At=>({...At,[g]:[...At[g]||[],...dt].slice(0,Math.min(_||3,(At[g]||[]).length+Math.max(0,Ue)))}))})},ks=(g,_)=>at(G=>({...G,[g]:(G[g]||[]).filter((de,Ue)=>Ue!==_)})),Na=g=>{if(g&&r!=null&&r("Sign in to add the ad you want to clone.")){try{ad(g)}catch(_){me.error(_.code==="file-too-large"?`That video is too large. Keep it under ${vc}MB.`:"Unsupported file. Drop an MP4, MOV or WebM video.");return}if(typeof g.size=="number"&&g.size>vc*1024*1024){me.error(`That video is too large. Keep it under ${vc}MB.`);return}Nt("Uploading reference adâ¦",async()=>{se({name:g.name,phase:"reading",percent:0});try{const _=await U4(g);if(_>vu){me.error(`That ad is ${Ch(_)} long. Clone one up to ${vu} seconds.`);return}const G=await Od(g,Ue=>se(dt=>dt&&dt.phase==="reading"?{...dt,percent:Ue}:dt));se(Ue=>Ue&&{...Ue,phase:"uploading",percent:100});const de=await La(G);if(!de)throw new Error("Upload failed. Try that ad again.");_&&(en(Math.round(_)),qn(Math.min(Jr,Math.max(6,Math.round(_))))),ie("ad"),jr(de)}finally{se(null)}})}},Vo=g=>{var G;const _=(G=g.target.files)==null?void 0:G[0];g.target.value="",Na(_)},[zr,Te]=i.useState(!1),Yn=g=>{var _,G;g.preventDefault(),Te(!1),Na((G=(_=g.dataTransfer)==null?void 0:_.files)==null?void 0:G[0])},Rn=g=>{g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"),Te(!0)},us=g=>{g.currentTarget.contains(g.relatedTarget)||Te(!1)},sa=g=>Object.fromEntries(Object.entries(g).filter(([_,G])=>String(G??"")!==String((m==null?void 0:m[_])??""))),lo=()=>Nt("Saving changesâ¦",async()=>{if(!De.length)return me.error("Add at least one product image.");if(ce==="clone"&&!In)return me.error("Add a reference ad to clone.");const g=await Se("update",{jobId:m.id,productImageUrls:ds,productAssets:to,productName:ut,productDetails:nt,...J?{styleKey:J}:{},...kt&&on?(()=>{const{creatorMode:G,...de}=js;return{...de,creatorChoice:js.creatorMode}})():{},...sa({aspectRatio:mt,videoResolution:mr,durationSeconds:rr,wantCaptions:_t,voiceMode:Le,voice:ct,audioMode:Z,batchCount:xn,industry:Xn,targetAudience:Ke,painPoints:qt,desiredOutcome:zn,emotionalTriggers:jn,cta:Mn,tone:or}),...In?{sourceVideoUrl:In}:{},...Jn?{sourceDurationSeconds:Jn}:{}}),_=!!m.startFrameUrl;g!=null&&g.job&&g.job.id===R.current&&M(g.job),Zn(1),ar(),_&&(g!=null&&g.job)&&!g.job.startFrameUrl?me.info("Changes saved. The starting frame no longer matches, rebuild it on the Frame step."):me.success("Changes saved.")}),bi=()=>Nt(ce==="clone"?"Analyzing the adâ¦":"Writing your scriptâ¦",async()=>
120{if(!(s!=null&&s()))return;if(!De.length)return me.error("Upload at least one product image.");if(ce==="clone"&&!In)return me.error("Upload a reference ad to clone.");if(kt&&Qe&&!Qe.ready)return _n(2),me.info("Your model is still being updated. It only takes a minute or two.");if(ce==="create"&&vo&&!on)return _n(2),me.error("Choose a model for your video.");const _=(await Se("create",{mode:ce,styleKey:J,...ce==="create"&&(le==null?void 0:le.styleKey)===J&&(le!=null&&le.text)?{adaptedPrompt:le.text}:{},productImageUrls:ds,productAssets:to,productName:ut,productDetails:nt,...js,aspectRatio:mt,videoResolution:mr,language:"en",durationSeconds:rr,wantCaptions:_t,voiceMode:Le,voice:ct,audioMode:Z,batchCount:xn,industry:Xn,targetAudience:Ke,painPoints:qt,desiredOutcome:zn,emotionalTriggers:jn,cta:Mn,tone:or,sourceVideoUrl:In||void 0,sourceDurationSeconds:Jn||void 0})).job,G=await Se("generate-script",{jobId:_.id});F.current=null,M((G==null?void 0:G.job)||{..._,status:"scripting"})}),ka=()=>Nt("",async()=>{m.mode!=="clone"&&await Se("update",{jobId:m.id,industry:Xn,targetAudience:Ke,painPoints:qt,desiredOutcome:zn,emotionalTriggers:jn,cta:Mn,tone:or}),Or.current=!!m.startFrameUrl&&!Fm(m);const g=await Se("generate-script",{jobId:m.id});g!=null&&g.job?M(g.job):M(_=>({..._,status:"scripting"}))}),yi=(()=>{if(!m)return"";const g=m.creatorChoice||m.creatorMode;return g==="model"||g==="custom"?m.avatarName?`${m.avatarName}, ${g==="custom"?"one of your models":"one of our models"}.`:"Your chosen model.":Tu.includes(g)?"A creator from the earlier UGC Studio. Choose a model to replace it.":"Nobody chosen, so we'll generate a creator for you. Choose a model if you want a specific person."})(),[vn,es]=i.useState(null),oa=()=>{var _,G,de,Ue;const g=((_=m==null?void 0:m.analysisJson)==null?void 0:_.plan)||{};es({presence:g.presence||(g.faceless?"none":g.handsOnly?"hands_only":"talking_head"),presentation:g.presentation||"held",gender:g.gender||"none",posture:g.posture||"",orientation:g.orientation||"",cameraSummary:g.cameraSummary||"",hasDialogue:!!g.hasDialogue,wantCaptions:!!g.wantCaptions,looksAtCamera:g.looksAtCamera!==!1,notes:Array.isArray(g.notes)?[...g.notes]:[],cutPace:((G=m==null?void 0:m.analysisJson)==null?void 0:G.cut_pace)||"",musicMood:((de=m==null?void 0:m.analysisJson)==null?void 0:de.music_mood)||"",setting:((Ue=m==null?void 0:m.analysisJson)==null?void 0:Ue.setting)||""})},[co,ko]=i.useState(null),[ms,Br]=i.useState(null),So=()=>Nt("Loading the directionâ¦",async()=>{const g=await Se("clone-direction",{jobId:m.id});g!=null&&g.ok&&(ko(g),Br(g.direction||""))}),xr=()=>Nt("Saving the directionâ¦",async()=>{const g=await Se("update",{jobId:m.id,adaptedPrompt:String(ms||"").trim()});g!=null&&g.job&&M(g.job),ko(_=>_&&{..._,direction:ms,edited:!0}),Br(null),me.success("Direction saved. Your version is used exactly as written.")}),vi=()=>Nt("Restoring the directionâ¦",async()=>{const g=await Se("update",{jobId:m.id,adaptedPrompt:""});g!=null&&g.job&&M(g.job),ko(_=>_&&{..._,direction:_.original,edited:!1}),Br(null),me.success("Restored what we wrote from the ad.")}),Ka=()=>Nt("Saving promptâ¦",async()=>{const g=String(we||"").trim();if(!(m!=null&&m.id)){Ne(g?{styleKey:J,text:g}:null),Re(null),me.success("Prompt saved. It will be used when you start.");return}const _=await Se("update",{jobId:m.id,adaptedPrompt:g});_!=null&&_.job&&M(_.job),Re(null),me.success("Prompt saved. The starting frame will rebuild from it.")}),Sa=()=>Nt("Restoring promptâ¦",async()=>{if(!(m!=null&&m.id)){Ne(null),Re(null);return}const g=await Se("update",{jobId:m.id,adaptedPrompt:""});g!=null&&g.job&&M(g.job),Re(null),me.success("Back to the original prompt.")}),Ar=(g,_)=>es(G=>({...G,[g]:_})),Wa=()=>Nt("Updating the planâ¦",async()=>{const{cutPace:g,musicMood:_,setting:G,...de}=vn||{},Ue=await Se("update-plan",{jobId:m.id,plan:de,cutPace:g,musicMood:_,setting:G});Ue!=null&&Ue.job&&M(Ue.job),es(null),me.success("Plan updated.")}),x=(g,_,G)=>M(de=>{var dt;const Ue=[...((dt=de.scriptJson)==null?void 0:dt.sections)||[]];return Ue[g]?(Ue[g]={...Ue[g],[_]:G},{...de,scriptJson:{...de.scriptJson,sections:Ue}}):de}),S=g=>{const _=JSON.parse(JSON.stringify(m.scriptJson||{}));g(_),V.current=!0,M(G=>({...G,scriptJson:_})),qr({scriptJson:_}).finally(()=>{V.current=!1})},T=["hook","personal_intro","problem","product_intro","benefits","differentiation","social_proof","objection","cta","final_push"],L=()=>S(g=>{Array.isArray(g.sections)||(g.sections=[]),g.sections.push({key:"benef
120its",label:"New line",dialogue:"",visual:""})}),K=g=>S(_=>{Array.isArray(_.sections)&&_.sections.splice(g,1)}),ee=(g,_)=>S(G=>{const de=G.sections,Ue=g+_;!Array.isArray(de)||Ue<0||Ue>=de.length||([de[g],de[Ue]]=[de[Ue],de[g]])}),be=()=>Nt("",async()=>{var G;const g={versionName:"Manual",manual:!0,hook:"",sections:[{key:"hook",label:"Hook",dialogue:"",visual:""},{key:"benefits",label:"Body",dialogue:"",visual:""},{key:"cta",label:"Call to action",dialogue:"",visual:""}]},_=await Se("update",{jobId:m.id,scriptJson:g,voiceMode:"native"});if(_!=null&&_.job&&M(_.job),m.mode==="clone"&&((G=m.analysisJson)!=null&&G.plan)){const de=await Se("update-plan",{jobId:m.id,plan:{...m.analysisJson.plan,hasDialogue:!0}});de!=null&&de.job&&M(de.job)}}),Ce=()=>Nt("",async()=>{var _;const g=await Se("update",{jobId:m.id,scriptJson:null,voiceMode:"none"});if(g!=null&&g.job&&M(g.job),m.mode==="clone"&&((_=m.analysisJson)!=null&&_.plan)){const G=await Se("update-plan",{jobId:m.id,plan:{...m.analysisJson.plan,hasDialogue:!1}});G!=null&&G.job&&M(G.job)}}),Be=()=>Nt("",async()=>{const g=await Se("generate-frame",{jobId:m.id});g!=null&&g.job?M(g.job):M(_=>({..._,status:"framing"}))}),Ve=()=>Nt("",async()=>{const g=await Se("generate-frame",{jobId:m.id,regenerate:!0});g!=null&&g.job?M(g.job):M(_=>({..._,status:"framing",regeneratingFrame:!0}))}),wt=g=>Nt("",async()=>{if(!(m!=null&&m.id)||!g||g===m.startFrameUrl)return;const _=await Se("approve-frame",{jobId:m.id,startFrameUrl:g});_!=null&&_.job&&M(_.job)}),Yt=()=>Nt("",async()=>{if(!(s!=null&&s()))return;if(m.status==="frame_ready"&&m.startFrameUrl&&!m.frameApproved){const _=await Se("approve-frame",{jobId:m.id,startFrameUrl:m.startFrameUrl});_!=null&&_.job&&M(_.job)}const g=await Se("generate",{jobId:m.id,batchCount:m.batchCount,...m.status==="completed"?{regenerate:!0}:{}});g!=null&&g.job?M(g.job):M(_=>({..._,status:"generating"}))}),St=async()=>{const g=m==null?void 0:m.id;if(g)try{await Se("delete",{jobId:g})}catch(_){if(!((_==null?void 0:_.code)==="NOT_FOUND"||(_==null?void 0:_.status)===404))return me.error((_==null?void 0:_.message)||"Could not start over. Wait for the render to finish, then try again."),!1}return Ic(),r0(),M(null),F.current=null,!0},[bt,Mt]=i.useState(!1),cn=async()=>{if(!await St()){Mt(!1);return}Zn(0),Ae("create"),Ze([]),at({}),Xe(""),xt(""),jr(""),en(0),Ie(""),Et(!1),Rt(!1),ie(null),Ht("UGC"),Je(""),rn(""),Vt(null),An("models"),Ct("9x16"),pr("720p"),qn(12),xe("off"),et("native"),pt("Rachel"),$n(!0),tt(1),mn(""),ot(""),sr(""),Bn(""),vt(""),fr(""),bo(""),es(null),oe(null),Ne(null),Re(null),ko(null),Br(null),hr(1),ze(!1),Lr.current=!1,Wn.current=null,Mt(!1),me.success("Cleared. Starting fresh.")},Co=()=>Nt("Retryingâ¦",async()=>{if(m.failedStep==="storyboard"||!m.failedStep&&m.storyboardMode&&(m.beats||[]).some(dt=>dt.status==="done"||dt.status==="failed")){const dt=await Se("generate-storyboard",{jobId:m.id});dt!=null&&dt.job?M(dt.job):M(At=>({...At,error:"",status:"generating"}));return}const G={script:"generate-script",frame:"generate-frame",video:"generate"}[m.failedStep]||(m.startFrameUrl?"generate":m.scriptJson||m.analysisJson?"generate-frame":"generate-script"),de=G==="generate"?{jobId:m.id,batchCount:m.batchCount}:{jobId:m.id},Ue=await Se(G,de);Ue!=null&&Ue.job?M(Ue.job):M(dt=>({...dt,error:"",status:G==="generate"?"generating":G==="generate-frame"?"framing":"scripting"}))}),Er=(g,_)=>{m!=null&&m.id&&Se("update-beat",{jobId:m.id,beatId:g,..._}).then(G=>{G!=null&&G.job&&M(G.job)}).catch(()=>{})},aa=()=>Nt("",async()=>{const g=await Se("generate-storyboard",{jobId:m.id,...m.status==="completed"?{regenerate:!0}:{}});g!=null&&g.job?M(g.job):M(_=>({..._,status:"generating"}))}),ia=g=>Nt("",async()=>{const _=await Se("regenerate-beat",{jobId:m.id,beatId:g});_!=null&&_.job&&M(_.job)}),Vn=()=>Nt("",async()=>{const g=await Se("rechain",{jobId:m.id});g!=null&&g.job&&M(g.job)});if(i.useEffect(()=>{const g=Kn.current,_=g==null?void 0:g.querySelector('[data-active="true"]');if(!g||!_)return;const G=g.getBoundingClientRect(),de=_.getBoundingClientRect();(de.left<G.left||de.right>G.right)&&(g.scrollLeft+=de.left-G.left-8)},[Nr,Hn,m==null?void 0:m.status]),i.useEffect(()=>{if(!W)return;const g=z.templates.find(_=>_.key===W.key);g&&g!==W&&oe(g)},[z.templates,W]),!e)return t.jsx(Ap,{});const pn=m==null?void 0:m.status,ts=m&&Ru.includes(pn),It=m?(m.variations||[]).filter(g=>g.status==="done"):[],Pn=!!m&&(m.status==="generating"||m.status==="composing"),$r=((m==null?void 0:m.generatingVariation)??-1)>=0,Ge=!!ts||$r,_r=z.promptMaxChars||yu,q=!!W&&ce!=="clone"&&!Ge&&(m?m.styleKey===W.key:J===W.key),ir=m&&m.styleKey===(W==null?void 0:W.key)&&m.adaptedPrompt||!m&&!!le&&le.styleKey===(W==null?void 0:W.key)&&le.text||(W==null?void 0:W.prompt)||"",Ks=q&&!!ir,Ws=Pn||$r,lr=$r?"A shot is still rendering. You can change this once it finishes.":{scripting:"We are writing your script. You can change this once it finishes.",framing:"We are building your starting frame. You can change this once it finishes.",generating:"Your video is rendering. You can change this once it finishes.",composing:"Your video is being put together. You can change this once it finishes."}[pn]||"",Ss=Ec.map((g,_)=>Qk(m,_)),Cs=g=>g!==2||!Fm(m),Uo=(()=>{for(let g=Math.min(Nr,Ec.length-1);g>=0;g--)if(Ss[g]&&Cs(g))return g;return 0})(),Es=g=>!!m&&Uo===g,la=g=>!!ts&&Fu(pn)===g,ca=(()=>{for(let g=Uo+1;g<Ec.length;g++)if(Ss[g]&&Cs(g))return g;return-1})(),Hr=Uo===0,gr=Math.min(3,Math.max(1,Hn||1)),f=[!0,!!m||Bs,!!m||io],j=!!m&&kt&&on&&(Qe.kind==="custom"?kn!=="custom"||String(m.customModelId||"")!==Qe.id:kn!=="model"||String(m.creatorModelId||"")!==Qe.id),P=[Oo,na,""][gr-1]||"",$=[...Gk.map((g,_)=>({...g,label:_===0&&ce==="clone"?"Ad & product":g.label,active:Hr&&gr===_+1,reachable:f[_],go:()=>_n(_+1)})),...qk.filter(g=>Cs(g.step)).map(g=>({...g,active:!Hr&&Uo===g.step,reachable:Ss[g.step],go:()=>{Zn(g.step),ar()}}))],B=Hr?gr<3?P?null:()=>_n(gr+1):ca>=0?()=>{Zn(ca),ar()}:null:ca>=0?()=>{Zn(ca),ar()}:null,re=Hr&&gr<3||ca>=0,X=m?{label:"Save changes",run:lo,missing:Ge?lr:jo}:gr<3?{label:"Next",run:()=>_n(gr+1),missing:P}:{label:ce==="clone"?"Analyze & adapt the ad":"Write my script",run:bi,missing:jo},ae=()=>{I||X.missing||X.run()},Y=!k&&!n&&oo?t.jsxs(td,{title:"Sign up to generate your video",onClick:()=>o==null?void 0:o(),note:"Your current session will be saved","data-ugc-signup":!0,children:["UGC Studio is part of the ",t.jsx("strong",{className:"text-white",children:"Pro"})," ","plan. Sign up free and everything you have set up here is waiting for you."]}):b&&!Lu(b)&&oo?t.jsxs(td,{title:"Your setup is saved",buttonLabel:"See the plans",onClick:()=>y==null?void 0:y("UGC Studio is available on the Pro plan and above."),"data-ugc-upgrade":!0,children:["Creating videos here is part of the"," ",t.jsx("strong",{className:"text-white",children:"Pro"})," plan. Everything you have set up stays as it is."]}):null,he=(g="")=>m?t.jsxs("button",{type:"button",onClick:()=>Mt(!0),disabled:Pn,title:Pn?"Your video is still rendering. You can start over once it finishes.":"Clear everything and start a new video",className:`inline-flex items-center justify-center gap-1.5 text-[12px] font-medium text-gray-400 hover:text-gray-200 transition disabled:opacity-40 disabled:cursor-not-allowed ${g}`,children:[t.jsx(Pl,{className:"w-3.5 h-3.5"}),"Start over"]}):null,ke=m&&z.templates.find(g=>g.key===m.styleKey)||null,Me=m?Zh(m):null,te=Hr||!m?{prompt:ce==="clone"?In?"Your ad is uploaded":"":ja,promptEmoji:ce==="clone"?"ð¯":(We==null?void 0:We.emoji)||"",productImage:De[0]||"",productName:ut.trim(),creatorImage:kt&&Qe?Qe.imageUrl:"",creatorName:ra,creatorNote:kt&&Qe&&!Qe.ready?"Updating for UGC Studioâ¦":"",output:Zr,cost:xn*Os,costLine:`${xn} à ${Os}`}:{prompt:m.mode==="clone"?"Cloned from your ad":(ke==null?void 0:ke.label)||"",promptEmoji:m.mode==="clone"?"ð¯":(ke==null?void 0:ke.emoji)||"",productImage:(((yt=m.productAssets)==null?void 0:yt.product)||m.productImageUrls||[])[0]||"",productName:m.productName||"",creatorImage:m.creatorMode!=="none"&&m.creatorMode!=="describe"&&m.creatorImageUrl||"",creatorName:m.creatorMode==="none"?"Nobody on camera":(Me==null?void 0:Me.name)||(Tu.includes(m.creatorChoice||m.creatorMode)?m.avatarName||"Creator from the earlier UGC Studio":"Generated for you"),creatorNote:"",output:`${Ur[m.aspectRatio]||m.aspectRatio||"9:16"}
120 · ${m.videoResolution||"720p"} · ${m.durationSeconds||0}s · ${m.batchCount||1} variation${(m.batchCount||1)>1?"s":""}`,cost:m.storyboardMode?null:(m.batchCount||1)*Xt,costLine:`${m.batchCount||1} à ${Xt}`};return t.jsxs("div",{ref:Qn,className:"scroll-mt-24",children:[!U&&t.jsx(b0,{user:b,authLoading:n,autoResume:ge,readSession:tn,clearSession:Ma.clear,onResume:Xr,onStartFresh:ls,onDismiss:Do,onNoSession:b?Ds:void 0,toolLabel:"UGC Studio",stepLabels:Ec.map(g=>g.label),buildSummary:g=>({detail:Yk(g,z.templates)})}),t.jsx("div",{className:"sticky top-24 sm:top-28 z-30 mb-4 bg-[#111318]/80 backdrop-blur-md rounded-2xl px-1.5 py-1.5 border border-white/[0.06] shadow-lg shadow-black/20",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{ref:Kn,className:"flex items-center gap-1 flex-1 min-w-0 overflow-x-auto scrollbar-hide",children:$.map((g,_)=>{const G=g.icon;return t.jsxs("button",{type:"button",onClick:()=>g.reachable&&g.go(),disabled:!g.reachable,"aria-current":g.active?"step":void 0,"data-active":g.active?"true":void 0,title:g.reachable?`Go to ${g.label}`:"Finish the earlier steps first",className:`group relative flex shrink-0 items-center gap-1.5 whitespace-nowrap px-3 sm:px-3.5 py-2 rounded-full text-[13px] sm:text-[14px] font-medium transition-colors duration-200 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-white/30 ${g.active?"bg-blue-500/15 text-white ring-1 ring-inset ring-blue-400/30":g.reachable?"text-white hover:bg-white/[0.05]":"text-gray-600 cursor-default"}`,children:[t.jsx(G,{className:`w-3.5 h-3.5 shrink-0 ${g.active?"text-blue-400":""}`}),t.jsx("span",{className:"text-[11px] text-gray-500 tabular-nums sm:hidden",children:_+1}),g.label]},g.key)})}),re&&t.jsxs("button",{type:"button",onClick:()=>B==null?void 0:B(),disabled:!B,title:Hr&&P?P:void 0,className:`${Hr?"hidden sm:flex":"flex"} shrink-0 items-center gap-1.5 px-3.5 sm:px-5 py-2 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-sm font-semibold text-white transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:["Next ",t.jsx(Da,{className:"w-4 h-4"})]})]})}),t.jsxs("div",{className:"flex gap-6 items-start",children:[t.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[ts&&t.jsxs("div",{className:"rounded-2xl border border-blue-500/20 bg-blue-500/[0.06] p-4 mb-4 flex items-center gap-3 text-sm text-blue-100",children:[t.jsx(Tn,{className:"w-4 h-4"}),pn==="scripting"&&((m==null?void 0:m.mode)==="clone"?"Analyzing the reference ad & adapting the scriptâ¦":"Writing your UGC scriptâ¦"),pn==="framing"&&"Composing your authentic starting frameâ¦",(pn==="generating"||pn==="composing")&&`Generating your video${m.batchCount>1?`s (${It.length}/${m.batchCount})`:""}â¦`]}),ts&&(pn==="generating"||pn==="composing")&&t.jsxs("div",{className:"mt-1 mb-4 text-[11px] leading-relaxed text-gray-500",children:[t.jsx(Xk,{startedAt:m==null?void 0:m.generatingStartedAt}),"Videos usually take 5 to 15 minutes. You can leave this page: when it's done, it's on your Projects page."]}),(m==null?void 0:m.error)&&!ts&&m.status==="completed"&&t.jsx("div",{className:"rounded-xl border border-amber-500/30 bg-amber-500/10 p-3 mb-4","data-ugc-note":!0,children:t.jsx("div",{className:"text-[13px] text-amber-100",children:m.error})}),(m==null?void 0:m.error)&&!ts&&m.status!=="completed"&&t.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-3 mb-4 space-y-2.5",children:[t.jsx("div",{className:"text-[13px] text-red-200",children:m.error}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs("button",{type:"button",onClick:Co,disabled:!!I,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-[12px] font-semibold",children:[t.jsx(fo,{className:"w-3.5 h-3.5"})," Try again"]}),t.jsxs("button",{type:"button",onClick:()=>Mt(!0),disabled:!!I,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 text-[12px]",children:[t.jsx(Pl,{className:"w-3.5 h-3.5"})," Start over"]})]})]}),j&&!Hr&&t.jsxs("div",{className:"rounded-xl border border-blue-500/25 bg-blue-500/[0.07] px-3 py-2.5 flex flex-wrap items-center gap-2 text-[12px] text-blue-100",children:[t.jsx(Qa,{className:"w-3.5 h-3.5 shrink-0 text-blue-300"}),t.jsxs("span",{className:"flex-1 min-w-[12rem]",children:["You chose ",Qe.name," but haven't saved it, so this video still uses its current creator."]}),t.jsx("button",{type:"button",onClick:()=>_n(2),className:Dn,children:"Review and save"})]}),t.jsxs("fieldset",{hidden:!Hr,disabled:Ge,onDragOverCapture:Ge?g=>{g.preventDefault(),g.stopPropagation()}:void 0,onDropCapture:Ge?g=>{g.preventDefault(),g.stopPropagation()}:void 0,className:"min-w-0 border-0 p-0 m-0 space-y-4",children:[Ge&&t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/[0.07] px-3 py-2.5 flex items-start gap-2",children:[t.jsx(Po,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-amber-400"}),t.jsxs("div",{className:"text-[11px] text-amber-100/85 leading-relaxed",children:[lr," Your earlier steps stay open to review."]})]}),t.jsxs("section",{hidden:gr!==1,className:"space-y-5",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:m?"pointer-events-none opacity-60":"",children:t.jsx(Am,{tabs:Jk,value:ce,onChange:g=>!m&&Ae(g),fullWidth:!0,className:"w-full sm:max-w-[420px]"})}),m&&t.jsxs("p",{className:"text-[11px] text-gray-500",children:["This job is a"," ",m.mode==="clone"?"clone"
120:"create from product"," ","job. Use Start over to switch."]})]}),ce==="clone"&&t.jsxs("div",{className:"space-y-2",children:[In?t.jsxs("div",{className:`relative ${pe==="ad"?"ugc-rise":""}`,children:[Hr&&gr===1?t.jsx("video",{src:In,controls:!0,onLoadedMetadata:g=>{if(!g.target.duration)return;const _=Math.round(g.target.duration);en(_),m||qn(Math.min(Jr,Math.max(6,_)))},className:"w-full rounded-xl max-h-64 bg-black border border-white/10"}):t.jsx("div",{className:"w-full h-40 rounded-xl bg-black border border-white/10"}),t.jsxs("button",{type:"button",onClick:()=>{jr(""),en(0)},className:"absolute top-2 right-2 inline-flex items-center gap-1.5 min-h-[40px] rounded-lg bg-black/80 px-3 py-2 text-[12px] text-gray-200 hover:text-white transition",children:[t.jsx(ft,{className:"w-3 h-3"})," Remove"]})]}):ne?t.jsxs("div",{className:"rounded-2xl border border-blue-500/30 bg-blue-500/[0.05] px-4 py-5 space-y-3",role:"status","aria-live":"polite",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Tn,{className:"w-5 h-5 shrink-0 text-blue-300"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-100",children:ne.phase==="reading"?"Reading your adâ¦":"Uploading your adâ¦"}),t.jsx("div",{className:"text-[11px] text-gray-400 truncate",children:ne.name})]}),ne.phase==="reading"&&t.jsxs("span",{className:"text-[12px] tabular-nums text-blue-200 shrink-0",children:[ne.percent,"%"]})]}),t.jsx("div",{className:"h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:ne.phase==="reading"?t.jsx("div",{className:"h-full rounded-full bg-blue-400 transition-[width] duration-200 ease-out",style:{width:`${ne.percent}%`}}):t.jsx("div",{className:"ugc-bar-indeterminate h-full w-1/3 rounded-full bg-blue-400"})}),t.jsx("p",{className:"text-[11px] text-gray-500",children:"A large ad can take a minute. Keep this page open."})]}):t.jsxs("label",{onDragOver:Rn,onDragEnter:Rn,onDragLeave:us,onDrop:Yn,className:`group flex flex-col items-center justify-center gap-2 cursor-pointer rounded-2xl border-2 border-dashed px-4 py-10 text-center transition-all ${zr?"border-blue-400 bg-blue-500/10":"border-white/15 bg-white/[0.02] hover:border-blue-500/50 hover:bg-blue-500/[0.04]"}`,children:[t.jsx("input",{type:"file",accept:"video/*",onChange:Vo,className:"hidden"}),t.jsx("span",{className:`flex items-center justify-center w-12 h-12 rounded-full transition ${zr?"text-blue-300 bg-blue-500/10":"bg-white/[0.04] text-gray-500 group-hover:text-blue-300 group-hover:bg-blue-500/10"}`,children:t.jsx(ho,{className:"w-6 h-6"})}),t.jsx("span",{className:"text-sm font-semibold text-gray-200",children:zr?"Drop to upload":"Drop the winning ad here"}),t.jsx("span",{className:"text-[12px] text-gray-500",children:"MP4 or MOV, we'll recreate its structure with your product"}),t.jsxs("span",{className:"text-[11px] text-gray-500",children:["Up to ",vu," seconds and ",vc,"MB. Anything longer than ",Jr,"s is recreated as a"," ",Jr," second version."]})]}),In&&Jn>Jr&&t.jsxs("p",{className:"text-[11px] text-amber-200/80 flex items-start gap-1.5",children:[t.jsx(Qa,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),"This ad is ",Ch(Jn)," long. We read all of it for the structure and hook, and recreate it as a"," ",Jr," second video, which is what you are billed for."]}),t.jsx("p",{className:"text-[11px] text-gray-500",children:"We copy the structure, pacing and hook, never the footage. Copyright-safe."}),t.jsxs("a",{href:"https://ads.tiktok.com/business/creativecenter/inspiration/topads/pc/en",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-blue-300 hover:text-blue-200 transition",children:["ð Need one? Browse top-performing ads on TikTok Creative Center ",t.jsx("span",{"aria-hidden":"true",children:"â"})]})]}),ce==="create"&&t.jsxs("div",{className:"space-y-2.5",children:[t.jsx(Qh,{aside:`${Us.length} of ${z.templates.length}`,children:"Prompt library"}),J&&ht?t.jsxs("div",{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-3 rounded-xl border border-blue-500/40 bg-blue-500/[0.06] px-3 py-2.5 ${pe==="prompt"?"ugc-rise":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-lg leading-none",children:We==null?void 0:We.emoji}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[13px] font-semibold text-gray-100 truncate",children:(We==null?void 0:We.label)||"Selected prompt"}),t.jsx("div",{className:"text-[10px] text-blue-300/70 truncate",children:m!=null&&m.promptEdited?"Edited by you":(We==null?void 0:We.category)||""})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[We&&t.jsxs("button",{type:"button",onClick:()=>oe(We),className:`flex-1 sm:flex-none justify-center ${Dn}`,children:[t.jsx(qs,{className:"w-3 h-3"}),ce!=="clone"&&!Ge&&We.prompt?"View / Edit prompt":"View prompt"]}),t.jsxs("button",{type:"button",onClick:()=>{ie("reopen"),Et(!1)},className:`flex-1 sm:flex-none justify-center ${Dn}`,children:[t.jsx(Rl,{className:"w-3 h-3"}),"Change"]})]})]},"chosen-prompt"):t.jsx("div",{inert:Ft?"":void 0,className:`ugc-fold ${pe==="reopen"?"ugc-unfold":""} ${Ft?"ugc-fold-closed":""}`,onAnimationEnd:g=>{g.target===g.currentTarget&&pe==="reopen"&&ie(null)},children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{className:"relative",children:[t.jsx(zl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),t.jsx("input",{value:Qt,onChange:g=>rn(g.target.value),className:bn+" pl-9",placeholder:`Search ${z.templates.length||""} promptsâ¦`})]}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:["All",...wo,ml].map(g=>{const _=Pt===g,G=g===ml;return t.jsxs("button",{type:"button",onClick:()=>{Ht(g),Je("")},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-all duration-200 ${_?G?"bg-gradient-to-br from-pink-500/20 to-pink-500/10 border-pink-500/50 text-pink-100":"bg-gradient-to-br from-blue-500/20 to-blue-500/10 border-blue-500/50 text-blue-100":"bg-white/[0.03] border-white/10 text-gray-400 hover:border-white/20 hover:text-gray-200"}`,children:[G&&t.jsx(Nl,{className:`w-3 h-3 ${jt.length?"fill-pink-400 text-pink-400":""}`}),g,G&&jt.length>0&&t.jsx("span",{className:"opacity-60 tabular-nums",children:jt.length})]},g)})}),t.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1 -mx-0.5 px-0.5",children:[t.jsx("button",{type:"button",onClick:()=>Je(""),className:`shrink-0 px-2.5 py-1 rounded-full text-[11px] font-medium border transition whitespace-nowrap ${ln?"bg-white/[0.03] border-white/10 text-gray-400 hover:border-white/20 hover:text-gray-200":"bg-blue-500/20 border-blue-500/50 text-blue-100"}`,children:"All categories"}),ro.map(g=>{const _=ln===g.name;return t.jsxs("button",{type:"button",onClick:()=>Je(_?"":g.name),className:`shrink-0 px-2.5 py-1 rounded-full text-[11px] font-medium border transition whitespace-nowrap ${_?"bg-blue-500/20 border-blue-500/50 text-blue-100":"bg-white/[0.03] border-white/10 text-gray-400 hover:border-white/20 hover:text-gray-200"}`,children:[g.name," ",t.jsx("span",{className:"opacity-60 tabular-nums",children:g.count})]},g.name)}
120)]}),t.jsx("div",{className:"max-h-[60svh] sm:max-h-[54vh] overflow-y-auto overscroll-contain px-1.5 py-1.5 -mx-1.5",children:Us.length===0?t.jsx("div",{className:"rounded-xl border border-dashed border-white/15 p-6 text-center text-[12px] text-gray-500",children:O?"Loading the promptsâ¦":z.templates.length===0?k?"Prompts could not be loaded. Refresh the page, and sign in if you have been signed out.":"Prompts could not be loaded. Refresh the page to try again.":Pt===ml&&!jt.length?"No favorites yet. Tap the heart on any prompt to keep it here.":"No prompts match your search. Try another term or category."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:Us.slice(0,so).map(g=>{var de,Ue,dt,At,sn;const _=J===g.key,G=Gt(Io,g.key);return t.jsxs("div",{role:"button",tabIndex:Ge?-1:0,"aria-pressed":_,"aria-disabled":Ge,title:Ge?lr:void 0,onClick:()=>!Ge&&Qr(g),onKeyDown:tr=>{Ge||tr.target===tr.currentTarget&&(tr.key==="Enter"||tr.key===" ")&&(tr.preventDefault(),Qr(g))},className:`group text-left rounded-xl border p-3 transition-all duration-200 ${Ge?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-white/25 hover:bg-white/[0.03] hover:shadow-md hover:shadow-black/40"} ${_?"border-blue-500/40 bg-blue-500/[0.06] ring-1 ring-blue-500/60":"border-white/10 bg-white/[0.02]"}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-1",children:[t.jsx("div",{className:"text-lg leading-none",children:g.emoji}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("span",{role:"button",tabIndex:0,"aria-pressed":G,"aria-label":`${G?"Remove":"Save"} ${g.label} ${G?"from":"to"} favorites`,title:G?"Remove from My Favorites":"Save to My Favorites",onClick:tr=>{tr.stopPropagation(),Kt(Io,g.key)},onKeyDown:tr=>{tr.key!=="Enter"&&tr.key!==" "||(tr.preventDefault(),tr.stopPropagation(),Kt(Io,g.key))},className:`w-6 h-6 grid place-items-center rounded-full cursor-pointer transition ${G?"bg-pink-500/90 text-white":"bg-white/[0.06] text-gray-400 hover:text-pink-300 opacity-100 lg:opacity-0 lg:group-hover:opacity-100 lg:focus-visible:opacity-100"}`,children:t.jsx(Nl,{className:`w-3 h-3 ${G?"fill-white":""}`})}),t.jsx("span",{className:`text-[8.5px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded-full border ${(de=g.inputSchema)!=null&&de.needsAvatar?"border-blue-500/30 text-blue-200/90 bg-blue-500/10":"border-white/10 text-gray-400 bg-white/[0.03]"}`,title:(Ue=g.inputSchema)!=null&&Ue.needsAvatar?"Creator on camera":(dt=g.inputSchema)!=null&&dt.handsOnly?"First-person POV, hands only, no face":"Product-only",children:(At=g.inputSchema)!=null&&At.needsAvatar?"Creator":(sn=g.inputSchema)!=null&&sn.handsOnly?"POV":"Product"})]})]}),t.jsx("div",{className:"text-[13px] font-semibold text-gray-100 mt-1 leading-tight line-clamp-2",children:g.label}),(Pt==="All"||Pt===ml)&&t.jsx("div",{className:"text-[9px] text-gray-500 truncate",children:g.section}),t.jsx("div",{className:"text-[10px] text-blue-300/60 mt-0.5 truncate",children:g.category}),t.jsx("div",{className:"grid grid-rows-[1fr] opacity-100 mt-1 transition-all duration-200",children:t.jsxs("div",{className:"overflow-hidden",children:[t.jsx("div",{className:"text-[11px] text-gray-400 leading-snug",children:g.blurb}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:tr=>{tr.stopPropagation(),oe(g)},className:Dn,children:_&&!Ge?t.jsxs(t.Fragment,{children:[t.jsx(qs,{className:"w-3 h-3"}),"View / Edit prompt"]}):t.jsxs(t.Fragment,{children:[t.jsx(_u,{className:"w-3 h-3"}),"View prompt"]})}),_&&((m==null?void 0:m.promptEdited)&&m.styleKey===g.key||!m&&(le==null?void 0:le.styleKey)===g.key)&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/15 text-blue-200",children:"Edited"})]})]})})]},g.key)})}),Us.length>so&&t.jsxs("div",{className:"text-center text-[11px] text-gray-500 mt-2",children:["Showing ",so," of ",Us.length,", refine with search or a category."]})]})})]})},"prompt-library")]}),$e&&t.jsxs("div",{className:`space-y-3 ${pe==="prompt"||pe==="ad"?"ugc-rise-late":""}`,children:[t.jsx(Qh,{aside:ce==="create"&&yn.length>0&&We?`tailored to â${We.label}â`:"",children:"Your product"}),no>0&&t.jsxs("div",{className:"text-[11px] text-gray-500 -mt-1",children:[no," of ",Ei," images",ce==="create"&&yn.length>0?", counting the ones below":""]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"text-[11px] font-medium text-gray-300",children:[Lo.label,t.jsx("span",{className:"text-rose-300/70",children:" *"})]}),De.length===0?t.jsxs("label",{...wl(g=>Hs({target:{files:g,value:""}})),className:"group flex flex-col items-center justify-center gap-2 cursor-pointer rounded-2xl border-2 border-dashed border-white/15 bg-white/[0.02] px-4 py-8 text-center transition-all hover:border-blue-500/50 hover:bg-blue-500/[0.04]",children:[t.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Hs,className:"hidden"}),t.jsx("span",{className:"flex items-center justify-center w-11 h-11 rounded-full bg-white/[0.04] text-gray-500 transition group-hover:text-blue-300 group-hover:bg-blue-500/10",children:t.jsx(Zs,{className:"w-5 h-5"})}),t.jsx("span",{className:"text-sm font-semibold text-gray-200",children:"Add your product photos"}),t.jsxs("span",{className:"text-[12px] text-gray-500",children:[Lo.hint," · up to ",Ei," images in all"]})]}):t.jsxs("div",{className:"flex flex-wrap gap-2",children:[De.map((g,_)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:g,alt:"",className:"w-20 h-20 rounded-lg object-cover border border-white/10"}),t.jsx("button",{type:"button",onClick:()=>Ze(G=>G.filter((de,Ue)=>Ue!==_)),className:"absolute top-0.5 right-0.5 inline-flex items-center justify-center w-8 h-8 bg-black/70 rounded-full opacity-90 hover:opacity-100 transition",children:t.jsx(ft,{className:"w-3 h-3 text-white"})})]},g)),ys>0&&t.jsxs("label",{...wl(g=>Hs({target:{files:g,value:""}})),className:"w-20 h-20 rounded-lg border border-dashed border-white/15 flex items-center justify-center cursor-pointer text-gray-500 hover:border-blue-500/50 hover:text-blue-300 transition",children:[t.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Hs,className:"hidden"}),t.jsx(fs,{className:"w-5 h-5"})]})]})]}),ce==="create"&&yn.map(g=>{const _=Ye[g.id]||[];return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"text-[11px] font-medium text-gray-300",children:[g.label,t.jsxs("span",{className:"text-gray-500 font-normal",children:[" ","·"," ",g.required?"required":g.re
120commended?"recommended":"optional"]})]}),t.jsx("div",{className:"text-[11px] text-gray-500 -mt-1 leading-snug",children:g.hint}),_.length===0&&vs===0?t.jsxs("div",{className:"text-[12px] text-gray-500 rounded-xl border border-dashed border-white/10 px-3 py-3",children:[Ei," images is the most a video can use. Remove one to add this."]}):_.length===0?t.jsxs("label",{...wl(G=>Ns(g.id,3)({target:{files:G,value:""},preventDefault(){}})),className:"group flex items-center gap-2 cursor-pointer rounded-xl border border-dashed border-white/15 bg-white/[0.02] px-3 py-3 transition-all hover:border-blue-500/50 hover:bg-blue-500/[0.04]",children:[t.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Ns(g.id,3),className:"hidden"}),t.jsx("span",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-white/[0.04] text-gray-500 transition group-hover:text-blue-300 group-hover:bg-blue-500/10",children:t.jsx(ho,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-[12px] text-gray-400",children:["Add ",g.label.toLowerCase()," image"]})]}):t.jsxs("div",{className:"flex flex-wrap gap-2",children:[_.map((G,de)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:G,alt:"",className:"w-16 h-16 rounded-lg object-cover border border-white/10"}),t.jsx("button",{type:"button",onClick:()=>ks(g.id,de),className:"absolute top-0.5 right-0.5 inline-flex items-center justify-center w-8 h-8 bg-black/70 rounded-full opacity-90 hover:opacity-100 transition",children:t.jsx(ft,{className:"w-3 h-3 text-white"})})]},G)),_.length<3&&vs>0&&t.jsxs("label",{...wl(G=>Ns(g.id,3)({target:{files:G,value:""},preventDefault(){}})),className:"w-16 h-16 rounded-lg border border-dashed border-white/15 flex items-center justify-center cursor-pointer text-gray-500 hover:border-blue-500/50 hover:text-blue-300 transition",children:[t.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Ns(g.id,3),className:"hidden"}),t.jsx(fs,{className:"w-4 h-4"})]})]})]},g.id)}),t.jsx(Fe,{label:"Product name",children:t.jsx("input",{value:ut,onChange:g=>Xe(g.target.value),className:bn,placeholder:"e.g. LUNA Aurora Serum"})}),t.jsx(Fe,{label:"Product details (optional)",children:t.jsx("textarea",{rows:2,value:nt,onChange:g=>xt(g.target.value),className:bn,placeholder:"What it is, key benefit, who it's forâ¦"})}),ce==="create"&&We&&t.jsx("div",{className:"text-[11px] text-gray-500 leading-snug",children:vo?t.jsx(t.Fragment,{children:"ð¤ This style has a creator on camera. You'll choose a model in the next step."}):er.handsOnly?t.jsx(t.Fragment,{children:"𤳠First person, hands only POV, no model needed."}):t.jsx(t.Fragment,{children:"ð¦ Product only style, no model needed."})})]})]}),t.jsxs("section",{hidden:gr!==2,className:"space-y-4",children:[t.jsx(Rm,{title:"Who's in it",desc:kt?ce==="clone"?"Optional. The model who fronts your version, used only if the ad has someone on camera.":"Choose one of our models, describe one, or use one of your own.":"This style has nobody on camera."}),kt?t.jsxs(t.Fragment,{children:[ce==="clone"&&t.jsx(Zk,{adGender:(Ut=(dn=m==null?void 0:m.analysisJson)==null?void 0:dn.plan)==null?void 0:Ut.gender}),ws&&t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.03] p-3 flex items-start gap-3",children:[m.creatorImageUrl&&m.creatorMode!=="describe"&&t.jsx("img",{src:m.creatorImageUrl,alt:"",className:"w-10 h-12 rounded-lg object-cover border border-white/10 shrink-0"}),t.jsxs("p",{className:"text-[12px] text-gray-400 leading-relaxed",children:[t.jsx("b",{className:"text-gray-200",children:m.avatarName||"This video's creator"})," ","is from the earlier UGC Studio and still works for this video. Choose a model below to use one of ours instead."]})]}),Qe&&ce==="clone"&&!m&&t.jsxs("button",{type:"button",onClick:()=>rt(null),className:Dn,children:[t.jsx(ft,{className:"w-3 h-3"}),"No model, match the ad"]}),t.jsx(vv,{value:Qe,onChange:rt,tab:En,onTabChange:An,api:is.current,canUseTier:Wt,hasElite:_o,onLocked:ta,onCreditsChanged:d,signedIn:k,disabled:Ge})]}):t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] p-4 text-[12px] text-gray-400 flex items-start gap-2",children:[t.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-blue-300 shrink-0"}),er.handsOnly?"This prompt is a first person POV, only hands appear on camera, so no model is needed. Carry on to Output.":"This style is product only, no model on camera is needed. Carry on to Output."]})]}),t.jsxs("section",{hidden:gr!==3,className:"space-y-4",children:[t.jsx(Rm,{title:"Output",desc:"Format, and how many variations to make."}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsx(Fe,{label:"Aspect ratio",children:t.jsx(ul,{value:mt,onChange:Ct,options:[{value:"9x16",label:"9:16"},{value:"1x1",label:"1:1"},{value:"16x9",label:"16:9"}]})}),t.jsx(Fe,{label:"How many variations?",children:t.jsx(ul,{value:String(xn),onChange:g=>tt(Number(g)),options:[1,2,3,5,10].map(g=>({value:String(g),label:`${g}`}))})})]}),t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>ze(g=>!g),"aria-expanded":kr,className:"w-full flex items-center justify-between gap-2 px-3.5 py-2.5 text-left transition hover:bg-white/[0.015]",children:[t.jsxs("span",{className:"flex items-center gap-2 text-[13px] font-medium text-gray-200",children:[t.jsx(ba,{className:"w-3.5 h-3.5 text-gray-400"})," Advanced settings",t.jsx("span",{className:"hidden sm:inline text-[11px] text-gray-500 font-normal",children:"resolution, duration, voice, audio, captions"})]}),t.jsx(Al,{className:`w-4 h-4 text-gray-400 transition-transform duration-300 ${kr?"rotate-180":""}`})]}),t.jsx("div",{className:`grid transition-all duration-300 ease-out ${kr?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"}`,children:t.jsx("div",{className:"overflow-hidden",...kr?{}:{inert:""},children:t.jsxs("div",{className:"px-3.5 pb-3.5 pt-3 space-y-3 border-t border-white/5",children:[t.jsx(Fe,{label:"Resolution",children:t.jsx(ul,{value:mr,onCh
120ange:pr,options:[{value:"480p",label:"480p"},{value:"720p",label:"720p"},{value:"1080p",label:"1080p"}]})}),t.jsx(Fe,{label:`Duration, ${rr}s`,children:t.jsx("input",{type:"range",min:6,max:15,value:rr,onChange:g=>qn(Number(g.target.value)),className:"w-full accent-blue-500"})}),ce==="create"&&vo&&t.jsx(Fe,{label:"Voice",hint:Le==="none"?"This prompt is a silent visual format, pick another option to add speech.":void 0,children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(ul,{value:Le,onChange:et,options:[{value:"native",label:"Native (Seedance)"},{value:"brand-voice",label:"Brand voice (lip-sync)"},{value:"voiceover",label:"Voiceover"},{value:"none",label:"No dialogue"}]}),Le!=="native"&&Le!=="none"&&t.jsx(Sn,{options:O4.map(g=>({value:g.value,label:g.label})),selectedValue:ct,onSelect:g=>{Lr.current=!0,pt(g)},disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})]})}),t.jsx(Fe,{label:"Audio",hint:`Talking scenes always speak. "Music" is ${ce==="clone"?"original music that fits the ad's energy & pace (never the ad's own track, copyright-safe)":"AI-composed to fit your selected style"}; "Natural sound" is real ambient audio with no music at all.`,children:t.jsx(ul,{value:Z,onChange:xe,options:[{value:"music",label:"ðµ Music"},{value:"native",label:"ð Natural sound"},{value:"off",label:"ð Silent"}]})}),ce==="create"?t.jsx(Sp,{checked:_t,onChange:$n,label:"Burn captions"}):t.jsxs("div",{className:"text-[11px] text-gray-500 flex items-start gap-2",children:[t.jsx(Qa,{className:"w-3.5 h-3.5 mt-0.5 text-blue-300 shrink-0"}),"Voice, captions and pacing are auto-detected from the ad when you analyze it."]})]})})})]})]})]}),Hr&&Y?t.jsx("div",{className:"xl:hidden mt-4",children:Y}):null,Hr&&t.jsxs("div",{className:"xl:hidden sticky bottom-0 z-20 -mx-2 sm:mx-0 border-t sm:border border-white/10 sm:rounded-2xl bg-[#14161a]/95 backdrop-blur px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] shadow-[0_-4px_20px_rgba(0,0,0,0.5)] space-y-2.5",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[te.creatorImage?t.jsx("img",{src:$l(te.creatorImage,72),alt:"",className:"w-8 h-8 rounded-full object-cover ring-1 ring-white/15 shrink-0"}):null,t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"text-[12px] font-semibold text-white block leading-tight truncate",children:[te.cost," credits",t.jsxs("span",{className:"text-gray-500 font-normal",children:[" ","· ",te.costLine]})]}),t.jsx("span",{className:"text-[11px] leading-tight block truncate text-gray-500",children:te.creatorNote||(j?`Save changes to use ${Qe.name}`:te.output)})]})]}),X.missing&&!I&&t.jsx("p",{className:"text-[11px] text-amber-400/90 text-center leading-tight",children:X.missing}),t.jsxs("div",{className:"flex items-center gap-2",children:[gr>1&&t.jsx("button",{type:"button",onClick:()=>_n(gr-1),"aria-label":"Back",className:"shrink-0 inline-flex items-center justify-center w-10 h-10 rounded-full border border-white/15 text-gray-300 hover:bg-white/[0.06]",children:t.jsx(Du,{className:"w-4 h-4"})}),m&&gr<3&&t.jsxs("button",{type:"button",onClick:()=>_n(gr+1),className:"shrink-0 inline-flex items-center gap-1 px-3.5 h-10 rounded-full border border-white/15 text-[13px] text-gray-200 hover:bg-white/[0.06]",children:["Next ",t.jsx(Da,{className:"w-3.5 h-3.5"})]}),t.jsx("div",{className:"flex-1 min-w-0 flex",children:t.jsx(e0,{primary:X,busy:I,onClick:ae,wide:!0})})]}),he("w-full")]}),Es(1)&&!la(1)&&!m.storyboardMode&&t.jsxs("fieldset",{disabled:Ge,className:"min-w-0 border-0 p-0 m-0 space-y-4",children:[Ge&&t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/[0.07] px-3 py-2.5 flex items-start gap-2",children:[t.jsx(Po,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-amber-400"}),t.jsxs("div",{className:"text-[11px] text-amber-100/85 leading-relaxed",children:[lr," You can still review everything here."]})]}),t.jsx(Cc,{title:m.mode==="clone"?"What we matched from the ad":"Your script",desc:m.mode==="clone"?"We analyzed the reference ad and matched its format. Review the adapted lines (if any), then build the starting frame.":"Generated from your brief. Edit any line, the spoken delivery uses these exact words. The
120n build the starting frame."}),m.mode==="clone"&&((it=m.analysisJson)==null?void 0:it.plan)&&(()=>{const g=m.analysisJson.plan,_=m.analysisJson,G=g.faceless||g.handsOnly;return vn?t.jsxs("div",{className:"rounded-2xl border border-blue-500/30 bg-blue-500/[0.06] p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[13px] font-semibold text-blue-100",children:"Editing what we matched"}),t.jsxs("button",{type:"button",onClick:()=>es(null),className:Dn,title:"Discard these changes",children:[t.jsx(ft,{className:"w-3 h-3"}),"Cancel"]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsx(Fe,{label:"Who's on camera",children:t.jsx(Sn,{options:[{value:"talking_head",label:"Person, talking to camera"},{value:"model",label:"Model / lifestyle"},{value:"hands_only",label:"Hands only"},{value:"none",label:"Nobody (product only)"}],selectedValue:vn.presence,onSelect:de=>Ar("presence",de),disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})}),t.jsx(Fe,{label:"How the product appears",children:t.jsx(Sn,{options:[{value:"worn",label:"Worn on the body"},{value:"held",label:"Held up to camera"},{value:"used",label:"Used / demonstrated"},{value:"hands",label:"In hands only"},{value:"faceless",label:"Product only"}],selectedValue:vn.presentation,onSelect:de=>Ar("presentation",de),disabled:Ge||vn.presence==="none"||vn.presence==="hands_only",usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})})]}),vn.presence!=="none"&&vn.presence!=="hands_only"&&t.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[t.jsx(Fe,{label:"Model",children:t.jsx(Sn,{options:[{value:"none",label:"Any"},{value:"female",label:"Female"},{value:"male",label:"Male"},{value:"mixed",label:"Mixed / group"}],selectedValue:vn.gender,onSelect:de=>Ar("gender",de),disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})}),t.jsx(Fe,{label:"Posture",children:t.jsx("input",{value:vn.posture,onChange:de=>Ar("posture",de.target.value),className:bn,placeholder:"standing, sitting, walkingâ¦"})}),t.jsx(Fe,{label:"Facing",children:t.jsx(Sn,{options:[{value:"",label:"Auto"},{value:"facing_camera",label:"Facing camera"},{value:"three_quarter",label:"Three-quarter"},{value:"side",label:"Side on"},{value:"back_to_camera",label:"Back to camera"},{value:"overhead",label:"Overhead"},{value:"mixed",label:"Mixed"}],selectedValue:vn.orientation,onSelect:de=>Ar("orientation",de),disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})})]}),t.jsx(Fe,{label:"Camera",children:t.jsx("textarea",{rows:2,value:vn.cameraSummary,onChange:de=>Ar("cameraSummary",de.target.value),className:bn,placeholder:"e.g. fixed eye-level medium shot, slow push in"})}),t.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[t.jsx(Fe,{label:"Pace",children:t.jsx("input",{value:vn.cutPace,onChange:de=>Ar("cutPace",de.target.value),className:bn,placeholder:"slow, medium, fast"})}),t.jsx(Fe,{label:"Music / ambience",children:t.jsx("input",{value:vn.musicMood,onChange:de=>Ar("musicMood",de.target.value),className:bn,placeholder:"chill, upbeat, tenseâ¦"})}),t.jsx(Fe,{label:"Setting",children:t.jsx("input",{value:vn.setting,onChange:de=>Ar("setting",de.target.value),className:bn,placeholder:"bedroom, street, studioâ¦"})})]}),t.jsx("div",{className:"flex flex-wrap gap-4",children:[["hasDialogue","Spoken lines"],["wantCaptions","On-screen captions"],...vn.presence==="none"||vn.presence==="hands_only"?[]:[["looksAtCamera","Looks at camera"]]].map(([de,Ue])=>t.jsxs("label",{className:"inline-flex items-center gap-2 text-[12px] text-gray-300 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:!!vn[de],onChange:dt=>Ar(de,dt.target.checked),className:"accent-blue-500"}),Ue]},de))}),t.jsx(Fe,{label:"Extra direction",children:t.jsxs("div",{className:"space-y-2",children:[(vn.notes||[]).map((de,Ue)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:de,onChange:dt=>Ar("notes",vn.notes.map((At,sn)=>sn===Ue?dt.target.value:At)),className:bn,placeholder:"e.g. keep the hood up the whole time"}),t.jsx("button",{type:"button",onClick:()=>Ar("notes",vn.notes.filter((dt,At)=>At!==Ue)),className:"shrink-0 inline-flex items-center justify-center w-10 h-10 rounded-lg text-gray-500 hover:text-red-300 hover:bg-red-500/10 transition",title:"Remove",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]},Ue)),t.jsx("button",{type:"button",onClick:()=>Ar("notes",[...vn.notes||[],""]),className:"inline-flex items-center min-h-[40px] px-1 text-[13px] text-blue-300 hover:text-blue-200",children:"+ Add direction"})]})}),t.jsxs("div",{className:"flex gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:Wa,disabled:!!I,className:"px-4 py-2 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:"Save changes"}),t.jsx("button",{type:"button",onClick:()=>es(null),className:"px-4 py-2 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 text-sm",children:"Cancel"})]}),t.jsx("p",{className:"text-[11px] text-gray-500",children:"Saving rebuilds the starting frame from your changes."})]}):t.jsxs("div",{className:"rounded-2xl border border-blue-500/20 bg-blue-500/[0.06] p-4 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[13px] font-semibold text-blue-100",children:"Detected in the ad"}),t.jsxs("button",{type:"button",onClick:oa,className:Dn,children:[t.jsx(qs,{className:"w-3 h-3"}),"Edit"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:g.formatLabel}),g.presentationLabel&&t.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-blue-500/15 text-blue-100",children:["Product: ",g.presentationLabel]}),g.person&&g.gender&&g.gender!=="none"&&t.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200 capitalize",children:[g.gender," model"]}),t.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:["Captions ",g.wantCaptions?"on":"off"]}),_.cut_pace&&t.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:["Pace: ",_.cut_pace]}),_.music_mood&&t.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:["ðµ ",_.music_mood]})]}),g.cameraSummary&&t.jsxs("div",{className:"text-[11px] text-gray-400",children:["ð¥ ",g.cameraSummary]}
120),(g.notes||[]).filter(Boolean).length>0&&t.jsxs("div",{className:"text-[11px] text-blue-200/80 leading-relaxed",children:["âï¸ Your direction:"," ",g.notes.filter(Boolean).join(" · ")]}),t.jsxs("div",{className:"text-[11px] text-gray-400 leading-relaxed",children:["We'll recreate the same movements, pace, ambience and direction, with your product",g.presentation==="worn"?" worn on the body (not held)":g.presentation==="used"?" shown in use":g.presentation==="hands"?" shown in-hand":g.faceless?" as the hero (no person)":"",".",G?" This ad has no on-camera person, so no model is used.":""," ",g.hasDialogue?"Edit the adapted lines below.":"No spoken lines in the source, so your clone matches its visuals, ambience and pace without dialogue."]})]})})(),m.mode==="clone"&&((Tt=m.analysisJson)==null?void 0:Tt.plan)&&t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-200",children:"Video direction"}),t.jsx("div",{className:"text-[11px] text-gray-500",children:m.promptEdited?`Your version. Keep it under ${_r} characters, anything past that is trimmed.`:"Written from the ad you uploaded."})]}),co?t.jsxs("button",{type:"button",onClick:()=>{ko(null),Br(null)},className:`shrink-0 ${Dn}`,children:[t.jsx(ft,{className:"w-3 h-3"}),"Close"]}):t.jsxs("button",{type:"button",onClick:So,disabled:!!I||Ge,className:`shrink-0 ${Dn} disabled:opacity-40`,title:Ge?lr:void 0,children:[t.jsx(qs,{className:"w-3 h-3"}),"View/Edit Direction"]})]}),co&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{rows:14,value:ms??"",onChange:g=>Br(g.target.value),disabled:Ge,className:"w-full text-[11px] text-gray-200 bg-black/40 rounded-lg p-3 border border-white/10 focus:border-blue-500/50 focus:outline-none font-mono leading-relaxed disabled:opacity-50"}),t.jsxs("div",{className:`text-[11px] text-right ${(ms||"").length>_r?"text-amber-300":"text-gray-500"}`,children:[(ms||"").length," / ",_r," characters",(ms||"").length>_r?". The end will be trimmed to fit.":""]}),t.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed",children:"If your prompt includes spoken lines, keep each line short. Long monologues drift out of sync with the video."}),t.jsxs("div",{className:"rounded-xl border border-blue-500/20 bg-blue-500/[0.06] p-3 flex items-start gap-2",children:[t.jsx(Qa,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-blue-300"}),t.jsx("div",{className:"text-[11px] text-blue-200/80 leading-relaxed",children:"Change the camera, the action, the scene, the pacing. The copyright rules that keep your clone safe to ship are added separately and are not part of this text, so you cannot remove them by accident. Keep the #Image and #Video references, they tell the model which file is which."})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx("button",{type:"button",onClick:xr,disabled:!!I||Ge||(ms??"")===(co.direction??""),className:"px-4 py-2 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:"Save direction"}),t.jsx("button",{type:"button",onClick:vi,disabled:!!I||Ge||!m.promptEdited,className:"px-4 py-2 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 disabled:opacity-40 text-sm",children:"Reset to original"})]})]})]}),m.mode==="clone"&&((an=(wn=m.analysisJson)==null?void 0:wn.plan)==null?void 0:an.person)&&t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-200",children:"Who's in your clone"}),t.jsxs("button",{type:"button",onClick:()=>_n(2),className:Dn,children:[t.jsx(qs,{className:"w-3 h-3"}),"Change"]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[m.creatorImageUrl&&m.creatorMode!=="describe"&&t.jsx("img",{src:$l(m.creatorImageUrl,120),alt:"",className:"w-12 h-16 rounded-lg object-cover border border-white/15"}),t.jsx("div",{className:"text-[12px] text-gray-400 leading-relaxed",children:yi})]})]}),m.scriptJson?t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 space-y-3",children:[m.mode==="clone"&&(((Ms=(ns=m.analysisJson)==null?void 0:ns.plan)==null?void 0:Ms.sourceHasDialogue)===!1||m.scriptJson.manual)&&t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[12px] text-gray-400",children:"Your own lines. The clone will be spoken instead of silent."}),t.jsxs("button",{type:"button",onClick:Ce,disabled:!!I,className:`shrink-0 ${Dn} disabled:opacity-50`,title:"Discard these lines and match the ad's silence",children:[t.jsx(ft,{className:"w-3 h-3"}),"Cancel"]})]}),t.jsx(Fe,{label:"Hook",children:t.jsx("input",{value:m.scriptJson.hook||"",onChange:g=>M(_=>({..._,scriptJson:{..._.scriptJson,hook:g.target.value}})),onBlur:()=>qr({scriptJson:m.scriptJson}),className:bn})}),(m.scriptJson.sections||[]).map((g,_)=>t.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.02] p-2.5 space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Sn,{options:T.map(G=>({value:G,label:G.replace(/_/g," ")}
120)),selectedValue:T.includes(g.key)?g.key:"benefits",onSelect:G=>S(de=>{de.sections[_].key=G,de.sections[_].label=G.replace(/_/g," ").replace(/^\w/,Ue=>Ue.toUpperCase())}),buttonContent:g.label||String(g.key||"").replace(/_/g," "),disabled:Ge,usePortal:!0,className:"w-40",buttonClassName:"!bg-transparent !border-transparent !px-1 !py-1.5 !min-h-[32px] !text-[11px] !text-blue-300 !font-medium hover:!text-blue-200"}),g.timecode?t.jsxs("span",{className:"text-[11px] text-gray-500",children:["· ",g.timecode]}):null,t.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>ee(_,-1),disabled:_===0,className:"inline-flex items-center justify-center w-10 h-10 rounded-lg text-gray-500 hover:text-gray-200 disabled:opacity-25 disabled:hover:text-gray-500 transition",title:"Move up",children:t.jsx(Db,{className:"w-3.5 h-3.5"})}),t.jsx("button",{type:"button",onClick:()=>ee(_,1),disabled:_===(m.scriptJson.sections||[]).length-1,className:"inline-flex items-center justify-center w-10 h-10 rounded-lg text-gray-500 hover:text-gray-200 disabled:opacity-25 disabled:hover:text-gray-500 transition",title:"Move down",children:t.jsx(Al,{className:"w-3.5 h-3.5"})}),t.jsx("button",{type:"button",onClick:()=>K(_),className:"inline-flex items-center justify-center w-10 h-10 rounded-lg text-gray-500 hover:text-red-300 hover:bg-red-500/10 transition",title:"Remove this line",children:t.jsx(ft,{className:"w-3.5 h-3.5"})})]})]}),t.jsx("textarea",{rows:2,value:g.dialogue||"",onChange:G=>x(_,"dialogue",G.target.value),onBlur:()=>qr({scriptJson:m.scriptJson}),className:bn,placeholder:"(no spoken line)"}),t.jsx("input",{value:g.visual||"",onChange:G=>x(_,"visual",G.target.value),onBlur:()=>qr({scriptJson:m.scriptJson}),className:`${bn} text-[11px]`,placeholder:"ð¬ What's on screen for this line (optional)"})]},_)),t.jsx("button",{type:"button",onClick:L,disabled:!!I,className:"inline-flex items-center min-h-[40px] px-1 text-[13px] text-blue-300 hover:text-blue-200 disabled:opacity-50",children:"+ Add a line"})]}):m.mode!=="clone"?t.jsx("div",{className:"text-[13px] text-gray-400",children:"No spoken script for this style."}):t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 space-y-2",children:[t.jsx("div",{className:"text-[13px] text-gray-300",children:"This ad has no spoken lines, so your clone matches it without dialogue."}),t.jsxs("button",{type:"button",onClick:be,disabled:!!I,className:`${Dn} disabled:opacity-50`,children:[t.jsx(fs,{className:"w-3 h-3"}),"Write your own lines instead"]})]}),m.mode!=="clone"&&t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 space-y-3",children:[t.jsxs("div",{className:"text-sm font-semibold text-gray-200",children:["Script brief"," ",t.jsx("span",{className:"text-gray-500 font-normal text-[12px]",children:", optional: add context, then â» Regenerate to rewrite the script"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsx(Fe,{label:"Industry",children:t.jsx("input",{value:Xn,onChange:g=>mn(g.target.value),className:bn,placeholder:"skincare, fitness, SaaSâ¦"})}),t.jsx(Fe,{label:"Target audience",children:t.jsx("input",{value:Ke,onChange:g=>ot(g.target.value),className:bn,placeholder:"who it's for"})})]}),t.jsx(Fe,{label:"Pain points",children:t.jsx("input",{value:qt,onChange:g=>sr(g.target.value),className:bn,placeholder:"2 to 3 struggles they deal with"})}),t.jsx(Fe,{label:"Desired outcome",children:t.jsx("input",{value:zn,onChange:g=>Bn(g.target.value),className:bn,placeholder:"the transformation/result"})}),t.jsx(Fe,{label:"Emotional triggers",children:t.jsx("div",{className:"flex flex-wrap gap-1.5",children:(z.emotionalTriggers||[]).map(g=>t.jsx(q4,{label:g,active:jn.includes(g),onClick:()=>Ha(g)},g))})}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsx(Fe,{label:"Call to action",children:t.jsx("input",{value:Mn,onChange:g=>fr(g.target.value),className:bn,placeholder:"e.g. Use code UGC20"})}),t.jsx(Fe,{label:"Tone",children:t.jsx(Sn,{options:[{value:"",label:"Auto"},...(z.tonePresets||[]).map(g=>({value:g,label:g}))],selectedValue:or,onSelect:bo,disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})})]})]}),m.mode==="clone"&&t.jsx(Pu,{}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx("button",{type:"button",onClick:ka,disabled:!!I,className:"px-4 py-2.5 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 text-sm",children:m.mode==="clone"?"â» Re-analyze":"â» Regenerate"}),t.jsx("button",{type:"button",onClick:m.mode==="clone"?Yt:Be,disabled:!!I,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:m.mode==="clone"?t.jsxs(t.Fragment,{children:[t.jsx(Ao,{className:"w-4 h-4"})," Generate the clone"]}):t.jsxs(t.Fragment,{children:[t.jsx(Zs,{className:"w-4 h-4"})," One quick clip"]})})]})]}),Es(1)&&!la(1)&&m.storyboardMode&&(m.beats||[]).length>0&&t.jsxs("fieldset",{disabled:Ge,className:"min-w-0 border-0 p-0 m-0 space-y-4",children:[t.jsx(Cc,{title:"Storyboard, shot by shot",desc:"Your video, broken into short shots you can fine-tune one at a time."}),t.jsxs("div",{className:"rounded-2xl border border-blue-500/20 bg-blue-500/[0.06] p-4 space-y-1.5",children:[t.jsx("div",{className:"text-[13px] font-semibold text-blue-100",children:"How this works"}),t.jsxs("div",{className:"text-[12px] text-blue-200/80 leading-relaxed",children:["We split"," ",m.mode==="clone"?"the ad you're cloning":"your script"," ","into"," ",t.jsxs("b",{className:"text-blue-100",children:[m.beats.length," short shots"]})," ","(~",m.beats.reduce((g,_)=>g+(_.durationSeconds||3),0),"s total). For each shot you set ",t.jsx("b",{children:"what happens"}),", the"," ",t.jsx("b",{children:"camera"}),", ",t.jsx("b",{children:"how the product appears"})," and"," ",t.jsx("b",{children:"how long"})," it runs. Press ",t.jsx("b",{children:"Generate"})," and we render each shot, then stitch them into one seamless video, afterward you can re-roll any single shot without redoing the rest."]})]}),t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-3 flex flex-wrap items-center gap-3",children:[t.jsxs("span",{className:"text-[12px] font-medium text-gray-200",children:["Audio"," ",t.jsx("span",{className:"text-gray-500 font-normal",children:", whole video"})]}),t.jsx(dr,{value:m.audioMode||"off",onChange:g=>qr({audioMode:g}),options:[{value:"music",label:"ðµ Music"},{value:"native",label:"ð Natural sound"},{value:"off",label:"ð Silent"}]})]}),t.jsx("div",{className:"space-y-3",children:m.beats.map((g,_)=>{const G={hook:"Hook",problem:"Problem",demo:"Demo",proof:"Proof",verdict:"Verdict",cta:"Call to action",show:"Show"}[g.role]||g.role;return t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-3.5 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-lg bg-blue-500/20 text-blue-200 text-[12px] font-bold shrink-0",children:_+1}),t.jsxs("span",{className:"text-[13px] font-semibold text-gray-100",children:["Shot ",_+1]}),t.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-white/[0.06] text-gray-300",children:G})]}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:[g.durationSeconds,"s"]})]}),g.shotType==="talking"&&t.jsxs("label",{className:"block space-y-1",children:[t.jsx("span",{className:"text-[11px] text-gray-400",children:"What's said on camera"}),t.jsx("textarea",{rows:2,defaultValue:g.spokenLine,onBlur:de=>de.target.value!==g.spokenLine&&Er(g.id,{spokenLine:de.target.value}),className:bn,placeholder:"The line spoken in this shotâ¦"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("label",{className:"block space-y-1",children:[t.jsx("span",{className:"text-[11px] text-gray-400",children:"Camera"}),t.jsx(Sn,{options:[["fixed","Fixed (locked off)"],["push_in","Push in"],["pull_out","Pull out"],["pan","Pan"],["tilt","Tilt"],["tracking_follow","Follow subject"],["orbit","Orbit around"],["aerial","Aerial / overhead"]].map(([de,
120Ue])=>({value:de,label:Ue})),selectedValue:g.cameraMove,onSelect:de=>Er(g.id,{cameraMove:de}),disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})]}),t.jsxs("label",{className:"block space-y-1",children:[t.jsx("span",{className:"text-[11px] text-gray-400",children:"Product shown"}),t.jsx(Sn,{options:[["worn","Worn on body"],["held","Held up"],["used","Used / in action"],["hands","In hands only"],["faceless","Product only"]].map(([de,Ue])=>({value:de,label:Ue})),selectedValue:g.productPresentation,onSelect:de=>Er(g.id,{productPresentation:de}),disabled:Ge,usePortal:!0,buttonClassName:"!bg-white/[0.03] !border-white/10 !rounded-lg !py-2 !px-3 !text-sm"})]})]}),t.jsxs("label",{className:"block space-y-1",children:[t.jsxs("span",{className:"text-[11px] text-gray-400",children:["Direction"," ",t.jsx("span",{className:"text-gray-600",children:"(optional)"})]}),t.jsx("input",{defaultValue:g.customInstructions,onBlur:de=>de.target.value!==g.customInstructions&&Er(g.id,{customInstructions:de.target.value}),className:bn,placeholder:"e.g. close-up on the logo, slow reveal, smilingâ¦"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[11px] text-gray-400 w-12 shrink-0",children:"Length"}),t.jsx("input",{type:"range",min:2,max:6,value:g.durationSeconds,onChange:de=>Er(g.id,{durationSeconds:Number(de.target.value)}),className:"flex-1 accent-blue-500"}),t.jsxs("span",{className:"text-[11px] text-gray-300 w-7 text-right shrink-0",children:[g.durationSeconds,"s"]})]})]},g.id)})}),t.jsxs("div",{className:"text-[12px] text-gray-400",children:[m.beats.length," beats · ~",m.beats.reduce((g,_)=>g+(_.durationSeconds||3),0),"s total ·"," ",m.beats.reduce((g,_)=>g+Jd(z,m.videoResolution,_.durationSeconds||3),0)," ","credits"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>qr({storyboardMode:!1}),disabled:!!I,className:"px-4 py-2.5 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 text-sm",children:"â Single clip"}),t.jsxs("button",{type:"button",onClick:aa,disabled:!!I,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:[t.jsx($s,{className:"w-4 h-4"})," ",m.status==="completed"?"Regenerate storyboard video":"Generate storyboard video"]})]})]}),Es(2)&&!la(2)&&!m.startFrameUrl&&t.jsxs("fieldset",{disabled:Ge,className:"min-w-0 rounded-2xl border border-white/10 bg-white/[0.02] p-5 space-y-3",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-200",children:"No starting frame yet"}),t.jsx("p",{className:"text-[12px] text-gray-400 max-w-prose",children:m.frameApproved===!1&&(m.scriptJson||m.analysisJson)?"Your earlier frame was cleared because the setup changed. Build a new one to carry on.":"Build the opening frame that your video is animated from."}),t.jsxs("button",{type:"button",onClick:Be,disabled:!!I,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:[t.jsx(Zs,{className:"w-4 h-4"})," Build the starting frame"]})]}),Es(2)&&!la(2)&&m.startFrameUrl&&t.jsxs("fieldset",{disabled:Ge,className:"min-w-0 border-0 p-0 m-0 space-y-4",children:[Ge&&t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/[0.07] px-3 py-2.5 flex items-start gap-2",children:[t.jsx(Po,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-amber-400"}),t.jsxs("div",{className:"text-[11px] text-amber-100/85 leading-relaxed",children:[lr," You can still review everything here."]})]}),t.jsx(Cc,{title:"Starting frame",desc:m.mode==="clone"?"Your product (and creator, if the ad has one) staged to match the ad's opening shot. Regenerate if it's off, then generate the video(s).":"Your creator + product, staged as an authentic iPhone frame. Regenerate if it's off, then generate the video(s)."}),m.startFrameUrl&&t.jsx("img",{src:m.startFrameUrl,alt:"",className:"w-full max-w-xs mx-auto rounded-xl border border-white/10"}),(m.startFrameOptions||[]).length>1&&t.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:m.startFrameOptions.map(g=>t.jsx("button",{type:"button",onClick:()=>wt(g),"aria-pressed":m.startFrameUrl===g,className:`rounded-lg overflow-hidden border-2 ${m.startFrameUrl===g?"border-blue-500":"border-white/10 hover:border-white/30"}`,children:t.jsx("img",{src:g,alt:"",className:"w-16 h-20 object-cover"})},g))}),t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-4 space-y-3",children:[t.jsx(Fe,{label:"How many variations?",children:t.jsx(dr,{value:String(m.batchCount),onChange:g=>qr({batchCount:Number(g)}),options:[1,2,3,5,10].map(g=>({value:String(g),label:`${g}`}))})}),t.jsxs("div",{className:"text-[12px] text-gray-400",children:["Estimated cost:"," ",t.jsxs("span",{className:"text-gray-200 font-medium",children:[m.batchCount," à ",Xt," ="," ",m.batchCount*Xt," credits"]})]})]}),t.jsx(Pu,{}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:Ve,disabled:!!I,className:"px-4 py-2.5 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 text-sm",children:"â» Regenerate frame"}),t.jsxs("button",{type:"button",onClick:Yt,disabled:!!I,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:[t.jsx($s,{className:"w-4 h-4"})," Generate"," ",m.batchCount>1?`${m.batchCount} videos`:"the video"]})]})]}),Es(3)&&(pn==="generating"||pn==="composing")&&(m.variations||[]).length>0&&t.jsx("div",{className:`grid gap-3 ${m.variations.length>1?"grid-cols-1 sm:grid-cols-2 lg:grid-cols-3":"grid-cols-1 max-w-xs mx-auto"}`,children:m.variations.map(g=>t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] p-2 space-y-1.5",children:[g.finalUrl?t.jsx(wc,{url:g.finalUrl,title:m.variations.length>1?`${m.title||"UGC video"} · Variation ${(g.index??0)+1}`:m.title||"UGC video",poster:g.thumbnailUrl,aspectRatio:m.aspectRatio,children:t.jsxs("span",{className:"absolute top-1 left-1 z-30 pointer-events-none text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded",children:["#",g.index+1]})}):t.jsxs("div",{className:"relative w-full rounded-xl overflow-hidden bg-[#111111] flex items-center justify-center",style:{aspectRatio:vm(m.aspectRatio)},children:[t.jsx(Tn,{className:"w-5 h-5"}),t.jsxs("span",{className:"absolute top-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded",children:["#",g.index+1]})]}),t.jsx("div",{className:"text-[11px] text-gray-400 text-center",children:g.status==="done"?"Ready":g.status==="failed"?g.error||"Failed":"Renderingâ¦"})]},g.index))}),Es(3)&&(pn==="generating"||pn==="composing")&&m.storyboardMode&&(m.beats||[]).length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"text-sm text-blue-100",children:pn==="composing"?"Stitching your shots into one videoâ¦":"Generating each shotâ¦"}),t.jsx("div",{className:"grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:m.beats.map((g,_)=>t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] p-2 space-y-1.5",children:[g.videoUrl?t.jsx(wc,{url:g.videoUrl,title:`${m.title||"UGC video"} · Shot ${_+1}`,aspectRatio:m.aspectRatio,children:t.jsx("span",{className:"absolute top-1 left-1 z-30 pointer-events-none text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded",children:_+1})}):t.jsxs("div",{className:"relative w-full rounded-xl overflow-hidden bg-[#111111] flex items-center justify-center",style:{aspectRatio:vm(m.aspectRatio)},children:[g.startFrameUrl?t.jsx("img",{src:g.startFrameUrl,alt:"",className:"w-full h-full object-cover opacity-60"}):t.jsx(Tn,{className:"w-5 h-5"}),t.jsx("span",{className:"absolute top-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded",children:_+1})]}),t.jsx("div",{className:"text-[11px] text-gray-400 text-center",children:g.status==="done"?"Ready":g.status==="failed"?g.error||"Failed":"Renderingâ¦"})]},g.id))})]}),Es(3)&&!la(3)&&pn!=="completed"&&pn!=="generating"&&pn!=="composing"&&t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-5 space-y-3",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-200",children:"Ready to generate"}),t.jsx("p",{className:"text-[12px] text-gray-400 max-w-prose",children:pn==="failed"&&(m.variations||[]).length>0?"The last run didn't finish, and its credits were given back. Generate again when you're ready.":(m.variations||[]).length>0?"You changed something since your last run. Generating again replaces those results and charges credits.":"Generate your video from the current script and frame."}),!m.storyboardMode&&Xt>0&&t.jsxs("div",{className:"text-[12px] text-gray-400",children:["Estimated cost:"," ",t.jsxs("span",{className:"text-gray-200 font-medium",children:[m.batchCount||1," à ",Xt," ="," ",(m.batchCount||1)*Xt," credits"]})]}),t.jsx(Pu,{}),t.jsxs("button",{type:"button",onClick:Yt,disabled:!!I||!!ts,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:[t.jsx($s,{className:"w-4 h-4"})," Generate"," ",m.batchCount>1?`${m.batchCount} videos`:"video"]})]}),Es(3)&&!la(3)&&pn==="completed"&&t.jsxs("div",{className:"space-y-4",children:[t.jsx(Cc,{title:m.storyboardMode?"Your UGC video":`Your UGC ${It.length>1?"videos":"video"}`,desc:"Saved to your Projects page with your other videos. Download, or open in the Video Editor to add captions, voice and more."}),m.storyboardMode?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 max-w-xs mx-auto gap-3",children:[t.jsx(wc,{url:m.finalVideoUrl,title:m.title||"UGC video",aspectRatio:m.aspectRatio},m.finalVideoUrl),t.jsx(Mh,{url:m.finalVideoUrl,onEdit:u&&(()=>u({url:m.finalVideoUrl,title:m.title||"UGC video",durationSeconds:(m.beats||[]).reduce((g,_)=>g+(_.durationSeconds||3),0)}))})]}),(m.beats||[]).length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[12px] text-gray-400",children:"Regenerate any shot, the video re-stitches automatically."}),(m.beats||[]).some(g=>g.stale)&&t.jsxs("button",{type:"button",onClick:Vn,disabled:!!I||Ws,title:Ws?lr:void 0,className:"text-[12px] inline-flex items-center min-h-[38px] px-3 py-2 rounded-lg bg-amber-500/15 text-amber-200 border border-amber-500/30 hover:bg-amber-500/25 disabled:opacity-40 shrink-0",children:["â» Re-chain ",m.beats.filter(g=>g.stale).length," ","shot",m.beats.filter(g=>g.stale).length>
1201?"s":""]})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:m.beats.map((g,_)=>{const G=g.status==="animating"||m.generatingVariation===_;return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"relative aspect-[9/16] rounded-lg overflow-hidden bg-black",children:[g.videoUrl?t.jsx("video",{src:g.videoUrl,className:"w-full h-full object-cover",muted:!0}):g.startFrameUrl?t.jsx("img",{src:g.startFrameUrl,alt:"",className:"w-full h-full object-cover"}):t.jsx("div",{className:"w-full h-full grid place-items-center text-[10px] text-gray-600",children:_+1}),t.jsx("span",{className:"absolute top-1 left-1 text-[10px] bg-black/60 text-white px-1 rounded",children:_+1}),g.stale&&!G&&t.jsx("span",{className:"absolute top-1 right-1 text-[9px] bg-amber-500/80 text-black font-semibold px-1 rounded",title:"Out of sync after a regenerate, re-chain to fix the seam",children:"stale"}),G&&t.jsx("div",{className:"absolute inset-0 bg-black/55 grid place-items-center",children:t.jsx(Tn,{className:"w-4 h-4"})})]}),t.jsx("button",{type:"button",onClick:()=>ia(g.id),disabled:!!I||Ws,title:Ws?lr:void 0,className:"w-full min-h-[40px] inline-flex items-center justify-center text-[11px] text-blue-300 hover:text-blue-200 disabled:opacity-40",children:"⻠Regenerate"})]},g.id)})})]})]}):t.jsx("div",{className:`grid gap-3 ${It.length>1?"grid-cols-1 sm:grid-cols-2 lg:grid-cols-3":"grid-cols-1 max-w-xs mx-auto"}`,children:It.map(g=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(wc,{url:g.finalUrl,title:(m.variations||[]).length>1?`${m.title||"UGC video"} · Variation ${(g.index??0)+1}`:m.title||"UGC video",poster:g.thumbnailUrl,aspectRatio:m.aspectRatio}),t.jsx(Mh,{url:g.finalUrl,onEdit:u&&(()=>u({url:g.finalUrl,title:(m.variations||[]).length>1?`${m.title||"UGC video"} · Variation ${(g.index??0)+1}`:m.title||"UGC video",durationSeconds:m.durationSeconds||0}))})]},g.index))}),!m.storyboardMode&&(m.variations||[]).some(g=>g.status==="failed")&&t.jsx("div",{className:"text-[12px] text-amber-300 text-center",children:"Some variations failed, only successful ones were charged."}),m.storyboardMode&&(m.beats||[]).some(g=>g.status==="failed")&&t.jsx("div",{className:"text-[12px] text-amber-300 text-center",children:"Some beats failed, only successful ones were stitched & charged."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>l==null?void 0:l(),className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-full border border-white/15 text-gray-200 hover:bg-white/5 text-sm",children:[t.jsx(Js,{className:"w-4 h-4"})," View in Projects"]}),t.jsxs("button",{type:"button",onClick:St,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] text-white text-sm font-semibold",children:[t.jsx(Ao,{className:"w-4 h-4"})," Make another"]})]})]}),!Hr&&m&&t.jsxs("div",{className:"xl:hidden sticky bottom-0 z-20 -mx-2 sm:mx-0 border-t sm:border border-white/10 sm:rounded-2xl bg-[#14161a]/95 backdrop-blur px-4 py-2.5 pb-[max(0.625rem,env(safe-area-inset-bottom))] shadow-[0_-4px_20px_rgba(0,0,0,0.5)] flex items-center gap-3",children:[t.jsxs("span",{className:"min-w-0 flex-1 text-[11px] leading-tight text-gray-500 truncate",children:[te.cost!==null&&t.jsxs("span",{className:"font-semibold text-gray-300",children:[te.cost," credits"]}),te.cost!==null&&" · ",te.output]}),he("shrink-0")]})]}),t.jsx("aside",{className:"hidden xl:block w-[300px] shrink-0 sticky top-40 sm:top-44",children:t.jsxs("div",{className:"rounded-2xl border border-white/10 bg-[#14161a] overflow-hidden",children:[t.jsxs("div",{className:"p-4 space-y-1",children:[t.jsx(Mc,{label:ce==="clone"||(m==null?void 0:m.mode)==="clone"?"Ad":"Prompt",onClick:()=>_n(1),emoji:te.promptEmoji,title:te.prompt||(ce==="clone"?"No ad yet":"No prompt yet"),muted:!te.prompt}),t.jsx("div",{className:"h-px bg-white/5"}),t.jsx(Mc,{label:"Product",onClick:()=>_n(1),image:te.productImage,title:te.productName||(te.productImage?"Unnamed product":"No product yet"),muted:!te.productImage}),t.jsx("div",{className:"h-px bg-white/5"}),t.jsx(Mc,{label:"Who's in it",onClick:()=>_n(2),disabled:!m&&!Bs,image:te.creatorImage,title:te.creatorName,sub:te.creatorNote}),t.jsx("div",{className:"h-px bg-white/5"}),t.jsx(Mc,{label:"Output",onClick:()=>_n(3),disabled:!m&&!io,title:te.output})]}),t.jsxs("div",{className:"border-t border-white/10 p-4 space-y-3",children:[te.cost!==null&&t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Estimated cost"}),t.jsxs("span",{className:"text-sm text-gray-300",children:[t.jsx("span",{className:"font-semibold text-white",children:te.cost})," ","credits",t.jsxs("span",{className:"text-gray-500",children:[" · ",te.costLine]})]})]}),Hr&&t.jsxs(t.Fragment,{children:[Y,X.missing&&!I?t.jsx("p",{className:"text-[11px] text-amber-400/90 leading-snug",children:X.missing}):j?t.jsxs("p",{className:"text-[11px] text-blue-300/90 leading-snug",children:["Save changes to use ",Qe.name," in this video."]}):null,t.jsx(e0,{primary:X,busy:I,onClick:ae,wide:!0}),gr>1&&t.jsxs("button",{type:"button",onClick:()=>_n(gr-1),className:"w-full inline-flex items-center justify-center gap-1.5 px-4 py-2 rounded-full border border-white/15 text-[13px] text-gray-300 hover:bg-white/[0.06]",children:[t.jsx(Du,{className:"w-4 h-4"})," Back"]})]}),he("w-full pt-1")]})]})})]}),t.jsx(Kc,{isOpen:bt,title:"Start over from scratch?",description:"This clears everything in UGC Studio and begins a brand new video.",details:["Your product images, reference ad and chosen prompt are cleared.","The model you chose is cleared. Your saved models stay in My Models.","The script, detected plan, starting frame and this job are deleted.","Videos already finished stay safe on your Projects page."],confirmLabel:"Yes, clear everything",cancelLabel:"Keep my work",tone:"danger",busy:!!I,onConfirm:cn,onClose:()=>Mt(!1)}),W&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>{oe(null),Re(null)},children:t.jsxs("div",{className:"modal-pop-in bg-[#0E1117] border border-white/10 rounded-2xl max-w-lg w-full max-h-[85dvh] flex flex-col overflow-hidden p-4 sm:p-5 space-y-3",onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[(W.section||W.category)&&t.jsx("div",{className:"text-[11px] text-blue-300/70",children:[W.section,W.category].filter(
120Boolean).join(" · ")}),t.jsxs("div",{className:"text-base font-semibold text-gray-100",children:[W.emoji," ",W.label]}),t.jsx("div",{className:"text-[12px] text-gray-400",children:W.blurb}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:W.person?"ð¤ Creator on camera":"ð¬ Product-only"}),W.duration?t.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:[W.duration,"s"]}):null,W.aspect?t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:Ur[W.aspect]||W.aspect}):null,W.resolution?t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-white/[0.06] text-gray-200",children:W.resolution}):null]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{type:"button","aria-pressed":Gt(Io,W.key),title:Gt(Io,W.key)?"Remove from My Favorites":"Save to My Favorites","aria-label":`${Gt(Io,W.key)?"Remove":"Save"} ${W.label} ${Gt(Io,W.key)?"from":"to"} favorites`,onClick:()=>Kt(Io,W.key),className:`w-8 h-8 grid place-items-center rounded-full transition ${Gt(Io,W.key)?"bg-pink-500/90 text-white":"bg-white/[0.06] text-gray-400 hover:text-pink-300"}`,children:t.jsx(Nl,{className:`w-4 h-4 ${Gt(Io,W.key)?"fill-white":""}`})}),t.jsx("button",{type:"button",onClick:()=>{oe(null),Re(null)},className:"text-gray-400 hover:text-gray-200",children:t.jsx(ft,{className:"w-5 h-5"})})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[11px] font-semibold text-gray-300 uppercase tracking-wide",children:"The prompt"}),Ks?t.jsxs("button",{type:"button",disabled:Ge,title:Ge?lr:void 0,onClick:()=>Re(we===null?ir:null),className:`${Dn} disabled:opacity-40 disabled:cursor-not-allowed`,children:[t.jsx(qs,{className:"w-3 h-3"}),we===null?"Edit prompt":"Cancel"]}):t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide px-2 py-0.5 rounded-full border border-white/10 bg-white/[0.04] text-gray-400",children:[t.jsx(Po,{className:"w-3 h-3"}),"Read only"]})]}),we===null?t.jsxs(t.Fragment,{children:[W.promptLocked&&!ir?t.jsxs("div",{className:"flex-1 min-h-0 rounded-lg border border-white/10 bg-black/40 p-4 flex flex-col items-center justify-center text-center gap-2","data-prompt-locked":!0,children:[t.jsx(Po,{className:"w-4 h-4 text-amber-400"}),k?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-[12px] font-semibold text-white",children:"This prompt could not be loaded"}),t.jsx("p",{className:"text-[11px] text-gray-400 max-w-xs leading-relaxed",children:"Refresh the page to see it. You can still choose it and set your video up."})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-[12px] font-semibold text-white",children:"Sign in to read and remix this prompt"}),t.jsxs("p",{className:"text-[11px] text-gray-400 max-w-xs leading-relaxed",children:["You can still choose it now and set your video up.",oo?" Your session is saved.":""]}),t.jsx("button",{type:"button",onClick:()=>o==null?void 0:o(),className:"mt-1 px-4 py-2 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-[13px] font-semibold text-white transition-colors",children:"Get Started For Free"})]})]}):t.jsx("pre",{className:"flex-1 min-h-0 overflow-y-auto overscroll-contain text-[11px] text-gray-300 whitespace-pre-wrap bg-black/40 rounded-lg p-3 border border-white/10",children:ir}),m!=null&&m.promptEdited&&m.styleKey===W.key?t.jsx("p",{className:"text-[11px] text-blue-300",children:"You edited this prompt. It is used exactly as written."}):Ks?t.jsx("p",{className:"text-[11px] text-blue-300/90",children:"This is your selected prompt. Tap Edit prompt to change the wording so it fits your product."}):(m?m.styleKey:J)!==W.key?t.jsx("p",{className:"text-[11px] text-gray-400",children:"Preview only. Choose Use this prompt to select it, then you can edit it to fit your product."}):lr?t.jsx("p",{className:"text-[11px] text-gray-400",children:lr}):null]}):t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col gap-2",children:[t.jsx("textarea",{rows:14,disabled:Ge,value:we,onChange:g=>Re(g.target.value),className:"flex-1 min-h-0 resize-none w-full text-[11px] text-gray-200 bg-black/40 rounded-lg p-3 border border-white/10 focus:border-blue-500/50 focus:outline-none font-mono leading-relaxed"}),t.jsxs("div",{className:`text-[11px] text-right ${(we||"").length>_r?"text-amber-300":"text-gray-500"}`,children:[(we||"").length," / ",_r," characters",(we||"").length>_r?". The end will be trimmed.":""]}),t.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed",children:"If your prompt includes spoken lines, keep each line short. Long monologues drift out of sync with the video."}),t.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed",children:"Change the wording, the scene, the actions. Keep the shot structure (SHOT 1, SHOT 2 and so on), because the opening and closing frames are built from it. Product and creator locks still apply, so your product and chosen person are preserved."}),t.jsxs("div",{className:"sticky bottom-0 z-10 -mx-4 sm:-mx-5 px-4 sm:px-5 pt-3 pb-1 bg-[#0E1117] border-t border-white/10 flex gap-2",children:[t.jsxs("button",{type:"button",onClick:Ka,disabled:!!I||Ge,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 text-white text-sm font-semibold",children:[t.jsx(ga,{className:"w-4 h-4"})," Save prompt"]}),t.jsx("button",{type:"button",onClick:Sa,disabled:!!I||Ge||(m?!m.promptEdited:!le),className:"px-4 py-3 min-h-[44px] rounded-full border border-white/15 text-gray-200 hover:bg-white/5 disabled:opacity-40 text-sm font-semibold",children:"Reset to original"})]})]}),we===null&&t.jsxs("button",{type:"button",onClick:()=>
120{if(m?m.styleKey===W.key:J===W.key){oe(null),Re(null);return}Ge||Qr(W)},disabled:Ge&&(m?m.styleKey:J)!==W.key,title:Ge&&(m?m.styleKey:J)!==W.key?lr:void 0,className:"sticky bottom-0 z-10 w-full inline-flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] rounded-full bg-[#326CB4] hover:bg-[#3A78C6] disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-semibold shadow-[0_-10px_24px_6px_rgba(14,17,23,0.95)]",children:[t.jsx(ga,{className:"w-4 h-4"}),(m?m.styleKey:J)===W.key?"Done":"Use this prompt"]})]})}),document.body)]})}const pS={video:"rgba(139,92,246,0.9)",caption:"rgba(245,158,11,0.9)",audio:"rgba(16,185,129,0.9)",image:"rgba(56,189,248,0.9)",shape:"rgba(244,114,182,0.9)"},fS=[{group:"Playback",items:[[["Space"],"Play or pause"],[["J","K","L"],"Shuttle back, pause, play"],[["â","â"],"Step one frame, hold Shift for ten"],[["â","â"],"Jump to the previous or next cut"],[["Home","End"],"Go to the start or the end"]]},{group:"Editing",items:[[["mod","K"],"Split at the playhead"],[["C"],"Split at the playhead, razor key"],[["mod","D"],"Duplicate the selected clip"],[["mod","C"],"Copy"],[["mod","X"],"Cut"],[["mod","V"],"Paste at the playhead"],[["Delete"],"Delete the selection, leaving the gap"],[["â§","Delete"],"Delete and close the gap"],[["Esc"],"Deselect"]]},{group:"Project",items:[[["mod","S"],"Save the project file"],[["mod","Z"],"Undo"],[["mod","â§","Z"],"Redo"],[["mod","Y"],"Redo, Windows style"]]},{group:"View",items:[[["S"],"Toggle snapping"],[["H"],"Hand tool, drag to pan"],[["â§","Z"],"Zoom the timeline to fit"],[["=","-"],"Zoom the timeline in or out"],[["?"],"Show this panel"]]}],hS=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform||navigator.userAgent||"")?"â":"Ctrl",Fc=600,gb=4e3,s0=e=>Promise.race([e,new Promise(n=>setTimeout(()=>n({}),gb))]),hl="studioe_ve_recover_v1",xS=e=>{const n=Math.max(1,Math.round((Date.now()-Number(e||0))/6e4));if(n<60)return`${n} min ago`;const r=Math.round(n/60);return r<24?`${r} h ago`:`${Math.round(r/24)} d ago`};function o0({open:e,onClose:n}){const r=i.useRef(null),s=i.useRef(null);return i.useEffect(()=>{var a;if(!e)return;s.current=document.activeElement;const o=l=>{if(l.key==="Escape"||l.key==="?"){l.preventDefault(),l.stopPropagation(),n();return}if(l.key!=="Tab")return;const c=r.current;if(!c)return;const u=c.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!u.length){l.preventDefault();return}const d=u[0],h=u[u.length-1],p=document.activeElement;c.contains(p)?l.shiftKey&&p===d?(l.preventDefault(),h.focus()):!l.shiftKey&&p===h&&(l.preventDefault(),d.focus()):(l.preventDefault(),d.focus())};return window.addEventListener("keydown",o,!0),(a=r.current)==null||a.focus(),()=>{var l,c;window.removeEventListener("keydown",o,!0);try{(c=(l=s.current)==null?void 0:l.focus)==null||c.call(l)}catch{}}},[e,n]),e?Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[95] grid place-items-center bg-black/60 backdrop-blur-sm p-4",onMouseDown:n,role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:t.jsxs("div",{ref:r,tabIndex:-1,className:"modal-pop-in w-full max-w-3xl max-h-[80vh] rounded-2xl border border-white/10 bg-[#16161d] shadow-2xl flex flex-col outline-none",onMouseDown:o=>o.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/10 shrink-0",children:[t.jsxs("h3",{className:"text-sm font-semibold text-white inline-flex items-center gap-2",children:[t.jsx(h0,{})," Keyboard shortcuts"]}),t.jsx("button",{type:"button",onClick:n,className:"text-gray-400 hover:text-white","aria-label":"Close",children:t.jsx(ft,{})})]}),t.jsx("div",{className:"ve-scroll p-5 overflow-y-auto grid gap-x-8 gap-y-5 sm:grid-cols-2",children:fS.map(o=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wider text-violet-300/80 font-semibold mb-2",children:o.group}),t.jsx("ul",{className:"space-y-1.5",children:o.items.map(([a,l])=>t.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[t.jsx("span",{className:"text-[12px] text-gray-400 leading-snug",children:l}),t.jsx("span",{className:"flex items-center gap-1 shrink-0",children:a.map((c,u)=>t.jsx("kbd",{className:"min-w-[22px] text-center rounded-md border border-white/15 bg-white/[0.06] px-1.5 py-0.5 text-[11px] font-medium text-gray-200",children:c==="mod"?hS:c},`${l}-${u}`))})]},l))})]},o.group))}),t.jsx("div",{className:"px-5 py-2.5 border-t border-white/10 text-[11px] text-gray-500 shrink-0",children:"Shortcuts pause while you are typing in a field. Press Esc or ? to close."})]})}),document.body):null}function Bo({icon:e,label:n,lines:r,active:s,onClick:o,disabled:a}){return t.jsxs("button",{type:"button",onClick:o,disabled:a,title:n,className:`w-[46px] h-[46px] rounded-xl flex flex-col items-center justify-center gap-0.5 transition disabled:opacity-30 ${s?"bg-violet-600/20 text-violet-200 ring-1 ring-violet-500/40":"text-gray-400 hover:bg-white/[0.06] hover:text-gray-100"}`,children:[t.jsx("span",{className:"text-[16px] leading-none",children:e}),t.jsx("span",{className:"text-[8.5px] font-medium tracking-wide leading-[1.15] text-center",children:r?r.map(l=>t.jsx("span",{className:"block",children:l},l)):n})]})}function Bt({label:e,icon:n,value:r,display:s,suffix:o="",min:a,max:l,accent:c="#8b5cf6",onStart:u,onCh
120ange:d,onType:h,keyState:p,onToggleKey:b}){const y=l>a?Math.max(0,Math.min(100,(Number(r)-a)/(l-a)*100)):0,v=s??(typeof r=="number"?Math.round(r*100)/100:r),[w,C]=i.useState(null),k=()=>{if(w==null)return;const E=parseFloat(w);C(null),!(!Number.isFinite(E)||String(E)===String(v))&&(u&&u(),h?h(E):d&&d({target:{value:Math.max(a,Math.min(l,E))}}))};return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[t.jsxs("span",{className:"text-[11px] text-gray-400 inline-flex items-center gap-1.5 min-w-0",children:[p?t.jsxs("button",{type:"button",onClick:b,title:p==="on"?`Remove the ${e} keyframe at the playhead`:p==="off"?`Add a ${e} keyframe here. ${e} is animated: its keyframes are the yellow diamonds on the clip.`:`Animate ${e}: set a keyframe here, move the playhead, then change the value.`,"aria-label":`${p==="on"?"Remove":"Add"} a ${e} keyframe`,"aria-pressed":p==="on",className:`relative w-3 h-3 shrink-0 grid place-items-center leading-none text-[12px] transition-colors ${p==="on"?"text-amber-300 drop-shadow-[0_0_3px_rgba(252,211,77,0.75)]":p==="off"?"text-amber-300/70 hover:text-amber-200":"text-gray-400 hover:text-white"}`,children:[t.jsx("span",{"aria-hidden":"true",className:"absolute -inset-2.5"}),p==="none"?"â":"â"]}):n,t.jsx("span",{className:"truncate",children:e})]}),t.jsxs("span",{className:"shrink-0 text-[11px] text-gray-200 tabular-nums inline-flex items-center justify-center px-1.5 py-0.5 rounded-md bg-white/[0.06] border border-white/10 focus-within:border-violet-500/60 min-w-[46px]",children:[t.jsx("input",{value:w??v,onFocus:E=>{C(String(v)),E.target.select()},onChange:E=>C(E.target.value),onBlur:k,onKeyDown:E=>{E.key==="Enter"?E.currentTarget.blur():E.key==="Escape"&&(C(null),E.currentTarget.blur())},inputMode:"decimal",className:"w-8 bg-transparent text-right outline-none tabular-nums"}),o]})]}),t.jsx("input",{type:"range",min:a,max:l,value:r,onPointerDown:u,onKeyDown:E=>{!E.repeat&&/^(Arrow|Page|Home$|End$)/.test(E.key)&&u&&u()},onChange:d,className:"ve-range w-full",style:{"--ve-accent":c,"--ve-pct":y}})]})}function gS(e){const n=[];return i.Children.forEach(e,r=>{if(!i.isValidElement(r)||r.type!=="option")return;const s=Array.isArray(r.props.children)?r.props.children.join(""):String(r.props.children??r.props.value??"");n.push({value:String(r.props.value??""),label:s.trim(),disabled:!!r.props.disabled})}),n}function qa({label:e,icon:n,value:r,onChange:s,children:o,disabled:a=!1}){const l=gS(o);return t.jsxs("label",{className:"block",children:[e&&t.jsxs("span",{className:"text-[11px] text-gray-400 inline-flex items-center gap-1.5 mb-1.5",children:[n,e]}),t.jsx("div",{className:"relative mt-0.5",children:t.jsx(Sn,{options:l,selectedValue:String(r??""),onSelect:c=>s==null?void 0:s({target:{value:c}}),disabled:a,usePortal:!0,buttonClassName:"!bg-white/[0.05] !border-white/10 !rounded-lg !py-2 !px-2.5 !text-sm"})})]})}function a0({label:e,icon:n,value:r,onChange:s,onStart:o}){const[a,l]=i.useState(!1),c=i.useRef(!1);return t.jsxs("div",{children:[e&&t.jsxs("span",{className:"text-[11px] text-gray-400 inline-flex items-center gap-1.5 mb-1.5",children:[n,e]}),t.jsxs("button",{type:"button",onClick:()=>{c.current=!1,l(!0)},className:"w-full h-9 mt-0.5 rounded-lg border border-white/10 hover:border-white/25 flex items-center gap-2 px-2 transition",children:[t.jsx("span",{className:"w-5 h-5 rounded-md border border-white/25 shrink-0",style:{background:r}}),t.jsx("span",{className:"text-[11px] text-gray-300 font-mono uppercase",children:r})]}),a&&t.jsx(ty,{isOpen:!0,color:r,onChange:u=>{c.current||(c.current=!0,o==null||o()),s==null||s({target:{value:u}})},onClose:()=>l(!1)})]})}function xl({label:e,icon:n,value:r,onChange:s,options:o}){return t.jsxs("div",{children:[e&&t.jsxs("span",{className:"text-[11px] text-gray-400 inline-flex items-center gap-1.5 mb-1.5",children:[n,e]}),t.jsx("div",{className:"flex mt-0.5 rounded-lg bg-white/[0.05] border border-white/10 p-0.5 gap-0.5",children:o.map(a=>t.jsxs("button",{type:"button",onClick:()=>s(a.value),title:a.title||a.label,className:`flex-1 px-1.5 py-1.5 rounded-md text-[11px] inline-flex items-center justify-center gap-1 transition ${r===a.value?"bg-violet-600/30 text-violet-100 ring-1 ring-violet-500/40":"text-gray-400 hover:text-gray-200 hover:bg-white/[0.04]"}`,children:[a.icon,a.label&&t.jsx("span",{children:a.label})]},a.value))})]})}function bS({label:e,icon:n,checked:r,onChange:s}){return t.jsxs("button",{type:"button",onClick:()=>s(!r),className:"w-full flex items-center justify-between px-2.5 py-2 rounded-lg bg-white/[0.05] border border-white/10 hover:border-white/20 transition",children:[t.jsxs("span",{className:"text-[11px] text-gray-300 inline-flex items-center gap-1.5",children:[n,e]}),t.jsx("span",{className:`relative w-9 h-5 rounded-full transition-colors ${r?"bg-violet-500":"bg-white/15"}`,children:t.jsx("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-all ${r?"left-[18px]":"left-0.5"}`})})]})}const Au=2e3,yS=24,pa=new Map;function vS(e){if(pa.has(e)){const r=pa.get(e);return pa.delete(e),pa.set(e,r),r}const n=(async()=>{const r=window.OfflineAudioContext||window.webkitOfflineAudioContext;if(!r)throw new Error("no audio decoder");const s=await fetch(e);if(!s.ok)throw new Error(`audio ${s.status}`);const o=await s.arrayBuffer(),a=new r(1,1,8e3),l=await new Promise((d,h)=>{const p=a.decodeAudioData(o,d,h);p&&typeof p.then=="function"&&p.then(d,h)}),c=new Float32Array(Au),u=l.length;for(let d=0;d<l.numberOfChannels;d++){const h=l.getChannelData(d);for(let p=0;p<u;
120p++){const b=Math.min(Au-1,Math.floor(p/u*Au)),y=Math.abs(h[p]);y>c[b]&&(c[b]=y)}}return{peaks:c,secs:l.duration||0}})();for(n.catch(()=>pa.delete(e)),pa.set(e,n);pa.size>yS;)pa.delete(pa.keys().next().value);return n}function wS({src:e,width:n,startSec:r=0,durSec:s,loop:o=!1,color:a="rgba(255,255,255,0.65)"}){const[l,c]=i.useState(null);i.useEffect(()=>{let p=!0;return vS(e).then(b=>p&&c(b),()=>p&&c(null)),()=>{p=!1}},[e]);const u=i.useMemo(()=>{if(!l||!(l.secs>0))return null;const p=Math.max(8,Math.min(360,Math.round((n||120)/3))),{peaks:b,secs:y}=l,v=s>0?s:y,w=new Array(p);for(let C=0;C<p;C++){let k=r+v*C/p,E=r+v*(C+1)/p;o&&(k%=y,E=k+v/p);let m=0;const M=Math.floor(k/y*b.length),I=Math.max(M+1,Math.ceil(E/y*b.length));for(let N=M;N<I;N++){const F=b[o?N%b.length:N];F>m&&(m=F)}w[C]=m||0}return w},[l,n,r,s,o]);if(!u||!u.length)return null;const d=Math.max(.01,...u),h=Math.max(1,(n||120)/u.length);return t.jsx("svg",{width:n||120,height:"100%",preserveAspectRatio:"none",className:"absolute inset-0 w-full h-full pointer-events-none opacity-70",children:u.map((p,b)=>{const y=Math.max(2,p/d*100);return t.jsx("rect",{x:b*h,y:`${(100-y)/2}%`,width:Math.max(1,h-1),height:`${y}%`,fill:a},b)})})}function jS({doc:e,playhead:n,sel:r,onSelect:s,snapshot:o,live:a,discard:l}){const c=i.useRef(null),u=e.width||1080,d=e.height||1920,h=(N,F)=>Number.isFinite(Number(N))?Number(N):F,p=N=>Math.round(N*100)/100,b={shape:["width","height"],image:["w","h"],video:["w","h"]},y=[];(e.tracks||[]).forEach(N=>{N.hidden||!["video","image","shape","caption"].includes(N.type)||(N.clips||[]).forEach(F=>{const R=Math.max(0,Math.round(F.fromFrame||0)),A=Math.max(1,Math.round(F.durationInFrames||1));n<R||n>=R+A||y.push({trackId:N.id,clipId:F.id,type:N.type,clip:F})})});const v=(N,F,R)=>h(Go(N,F,Math.max(0,n-Math.round(Number(N.fromFrame)||0)),N[F]??R),R),w=(N,F,R)=>Fr(N,F).length?Hu(N,F,Math.max(0,n-Math.round(Number(N.fromFrame)||0)),R):{...N,[F]:R},C=N=>{const F=N.clip;if(N.type==="caption"){const z=v(F,"size",60),H=String(F.text||"").split(` 121`).length,ne=Math.min(86,Math.max(18,String(F.text||"").length*z*.5/u*100)),se=z*1.3*Math.max(1,H)/d*100;return{x:v(F,"x",50),y:v(F,"y",84),w:ne,h:se}}if(N.type==="video")return{x:v(F,"x",50),y:v(F,"y",50),w:v(F,"w",100),h:v(F,"h",v(F,"w",100))};const R=b[N.type]||["w","h"],A=v(F,R[0],h(F.width??F.w,N.type==="shape"?30:38)),V=v(F,R[1],N.type==="shape"?30:A);return{x:v(F,"x",50),y:v(F,"y",50),w:A,h:V}},k=y.find(N=>r&&N.trackId===r.trackId&&N.clipId===r.clipId),E=(N,F)=>{F.preventDefault();const R=c.current.getBoundingClientRect(),A=C(N),V=F.clientX,z=F.clientY;let H=0,ne=null,se=!1;const pe=()=>{if(H=0,!ne||!se)return;const D=(ne.clientX-V)/R.width*100,W=(ne.clientY-z)/R.height*100;a(oe=>Ps(oe,N.trackId,N.clipId,we=>{const Re=p(ei(A.x+D,wr.min,wr.max)),le=p(ei(A.y+W,wr.min,wr.max));return w(w(we,"x",Re),"y",le)}))},ie=D=>{if(!se){if(Math.hypot(D.clientX-V,D.clientY-z)<3)return;se=!0,o()}ne=D,H||(H=requestAnimationFrame(pe))},O=D=>{if(H&&cancelAnimationFrame(H),window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",O),window.removeEventListener("pointercancel",O),(D==null?void 0:D.type)==="pointercancel"){se&&l();return}pe()};window.addEventListener("pointermove",ie),window.addEventListener("pointerup",O),window.addEventListener("pointercancel",O)},m=(N,F)=>{F.preventDefault(),F.stopPropagation();const R=c.current.getBoundingClientRect(),A=C(N),V=A.x/100*R.width,z=A.y/100*R.height,H=v(N.clip,"size",60),ne=Math.max(8,A.h/100*R.height);let se=0,pe=null,ie=!1;const O=()=>
121{if(se=0,!pe||!ie)return;const oe=Math.max(8,Math.abs(pe.clientX-R.left-V)*2),we=Math.max(8,Math.abs(pe.clientY-R.top-z)*2);if(N.type==="caption")a(Re=>Ps(Re,N.trackId,N.clipId,le=>w(le,"size",ei(Math.round(H*(we/ne)),12,320))));else{const Re=b[N.type]||["w","h"],le=(N.type==="video"||N.type==="image")&&Bu(N.clip,"w")&&N.clip.h==null&&!Bu(N.clip,"h"),Ne=p(ei(oe/R.width*100,2,100)),ce=p(ei(we/R.height*100,2,100));a(Ae=>Ps(Ae,N.trackId,N.clipId,De=>le?w(De,Re[0],Ne):w(w(De,Re[0],Ne),Re[1],ce)))}},D=oe=>{if(!ie){if(Math.hypot(oe.clientX-F.clientX,oe.clientY-F.clientY)<3)return;ie=!0,o()}pe=oe,se||(se=requestAnimationFrame(O))},W=oe=>{if(se&&cancelAnimationFrame(se),window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",W),window.removeEventListener("pointercancel",W),(oe==null?void 0:oe.type)==="pointercancel"){ie&&l();return}O()};window.addEventListener("pointermove",D),window.addEventListener("pointerup",W),window.addEventListener("pointercancel",W)},M=N=>{if(N.button!=null&&N.button!==0)return;const F=c.current.getBoundingClientRect(),R=(N.clientX-F.left)/F.width*100,A=(N.clientY-F.top)/F.height*100;for(let V=y.length-1;V>=0;V--){const z=C(y[V]);if(R>=z.x-z.w/2&&R<=z.x+z.w/2&&A>=z.y-z.h/2&&A<=z.y+z.h/2){s({trackId:y[V].trackId,clipId:y[V].clipId}),E(y[V],N);return}}s(null)},I=k?C(k):null;return t.jsx("div",{ref:c,className:"absolute inset-0 z-10 touch-none",onPointerDown:M,children:I&&t.jsx("div",{className:"absolute border-2 border-violet-400 rounded-[3px]",style:{left:`${I.x-I.w/2}%`,top:`${I.y-I.h/2}%`,width:`${I.w}%`,height:`${I.h}%`,boxShadow:"0 0 0 1px rgba(0,0,0,0.45)",pointerEvents:"none"},children:["-left-1.5 -top-1.5","-right-1.5 -top-1.5","-left-1.5 -bottom-1.5","-right-1.5 -bottom-1.5"].map((N,F)=>t.jsx("span",{onPointerDown:R=>m(k,R),className:`absolute ${N} w-3 h-3 bg-white border border-violet-500 rounded-[2px] shadow pointer-events-auto`,style:{cursor:"nwse-resize"}},F))})})}function NS(e){if(!e||e.status!=="completed"||!e.videoUrl)return null;const n=e.source==="studio";return{id:`${n?"studio":"video"}:${e.id}`,kind:n?e.kind||"ugc":"video_generation",title:e.title||(n?e.kind==="video_edit"?"Video edit":"UGC video":"Video"),resultUrl:e.videoUrl,thumbnailUrl:e.thumbnailUrl||null,durationSeconds:Number(e.durationSeconds||e.duration)||0}}function kS({job:e}){const[n,r]=i.useState(!1),s=e.thumbnailUrl||!n&&Pm(e.resultUrl);return s?t.jsx("img",{src:s,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0),className:"w-full h-full object-cover"}):t.jsx("video",{src:`${e.resultUrl}#t=1.5`,muted:!0,playsInline:!0,preload:"metadata",className:"w-full h-full object-cover"})}function Rc({id:e,size:n=18}){const r=[];if(e==="hold")r.push("2,15","15,15","15,3");else for(let s=0;s<=24;s++){const o=s/24;r.push(`${(2+o*13).toFixed(2)},${(15-Sy(e,o)*12).toFixed(2)}`)}return t.jsxs("svg",{width:n,height:n,viewBox:"0 0 18 18","aria-hidden":"true",className:"shrink-0",children:[t.jsx("rect",{x:"1",y:"1",width:"16",height:"16",rx:"3",fill:"currentColor",opacity:"0.08"}),t.jsx("polyline",{points:r.join(" "),fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})}class SS extends i.Component{constructor(n){super(n),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n){console.error("AdFlow crashed",n)}render(){return this.state.failed?t.jsxs("div",{className:"py-16 px-6 text-center text-gray-300",children:[t.jsx("p",{className:"text-sm font-medium text-gray-100",children:"AdFlow ran into a problem."}),t.jsx("p",{className:"text-xs text-gray-500 mt-1.5",children:"Your board is kept. Try again, or start a new board if it happens again."}),t.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>this.setState({failed:!1}),className:"px-4 py-2 rounded-lg bg-violet-600 hover:bg-violet-500 text-white text-sm font-semibold",children:"Try again"}),t.jsx("button",{type:"button",onClick:()=>{try{sessionStorage.removeItem("adflow:draft")}catch{}this.setState({failed:!1})},className:"px-4 py-2 rounded-lg bg-white/[0.06] border border-white/10 text-gray-200 text-sm font-medium",children:"Start a new board"})]})]}):this.props.children}}class CS extends i.Component{constructor(n){super(n),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n){console.error("Video editor crashed",n)}render(){return this.state.failed?t.jsxs("div",{className:"py-16 px-6 text-center text-gray-300",children:[t.jsx("p",{className:"text-sm font-medium text-gray-100",children:"The video editor ran into a problem."}),t.jsx("p",{className:"text-xs text-gray-500 mt-1.5",children:"Your unsaved work is kept, and is offered back when the editor opens again."}),t.jsx("button",{type:"button",onClick:()=>this.setState({failed:!1}),className:"mt-4 px-4 py-2 rounded-lg bg-violet-600 hover:bg-violet-500 text-white text-sm font-semibold",children:"Open the editor again"})]}):this.props.children}}function ES({editId:e,onJobCreated:n,openRender:r,onOpenRenderConsumed:s,openDoc:o,onOpenDocConsumed:a,requireEditorFile:l,userId:c=null,onUnsavedChange:u=null,mediaWindow:d=rb,active:h=!0}){var Ar,Wa;const[p,b]=i.useState(null),y=i.useRef(c||null);c&&(y.current=c);
121const v=!!c||!!y.current,[w,C]=i.useState(0),k=i.useRef(!1);i.useEffect(()=>{!c||k.current||(k.current=!0,Pc("videoEditor.opened"))},[c]);const[E,m]=i.useState([]),M=i.useRef(new Set),I=i.useRef(null),[N,F]=i.useState(null),[R,A]=i.useState(""),[V,z]=i.useState({doc:null,past:[],future:[]}),[H,ne]=i.useState(null),[se,pe]=i.useState([]),[ie,O]=i.useState(0),[D,W]=i.useState("saved"),[oe,we]=i.useState(90),[Re,le]=i.useState(!0),[Ne,ce]=i.useState(!1),[Ae,De]=i.useState(1),[Ze,Ye]=i.useState({zoom:1,panX:0,panY:0}),[at,ut]=i.useState(!1),[Xe,nt]=i.useState(!1),[xt,J]=i.useState(!1),[Ie,ht]=i.useState(null),[Et,Ft]=i.useState(!1),[Rt,Pt]=i.useState(!1);i.useEffect(()=>{p||J(!1)},[p]);const Ht=i.useRef(null),[Gt,Kt]=i.useState(300),[un,jt]=i.useState(()=>{var x;return typeof window<"u"&&((x=window.matchMedia)==null?void 0:x.call(window,"(min-width: 1024px)").matches)===!1?null:"layers"}),ln=i.useRef(null),[Je,Qt]=i.useState(null),[rn,Ot]=i.useState(null),[Qe,Vt]=i.useState(null),[En,An]=i.useState(!1),[Lr,ur]=i.useState(!1),rt=i.useRef(null),[mt,Ct]=i.useState(null),mr=En||Lr,[pr,rr]=i.useState(!1),qn=i.useRef(null),Z=i.useRef(null),xe=i.useRef(null),Le=i.useRef(null),et=i.useRef(null),ct=i.useRef(null),pt=i.useRef(null),_t=i.useRef(null),$n=i.useRef(null),[xn,tt]=i.useState(null),[Xn,mn]=i.useState(0),Ke=i.useRef(new Map),[ot,qt]=i.useState(!1),sr=12,[zn,Bn]=i.useState(sr),jn=i.useRef(null),[vt,Mn]=i.useState([]),[fr,or]=i.useState(null),[bo,In]=i.useState("idle"),[jr,Jn]=i.useState(!1),en=i.useRef(!1),Nr=i.useRef(new Set),Zn=i.useRef(0);Zn.current=vt.length;const Or=i.useCallback(async x=>{if(!en.current){if(!x)Nr.current=new Set;else{if(Nr.current.has(x))return;Nr.current.add(x)}en.current=!0,x||In("loading"),Jn(!1);try{const S=await Jt(`${$t}/api/video-gen/all`,{limit:24,includeStudio:!0,...x?{before:x}:{}});if(!(S!=null&&S.ok))throw new Error("videos");const T=(S.jobs||[]).map(NS).filter(Boolean);Mn(L=>{const K=x?L:[],ee=new Set(K.map(be=>be.id));return[...K,...T.filter(be=>!ee.has(be.id))]}),or(S.hasMore&&S.nextBefore?S.nextBefore:null),In("ready")}catch{x?(Nr.current.delete(x),Jn(!0)):In("error")}finally{en.current=!1}}},[]);i.useEffect(()=>{ot&&Or(null)},[ot,Or]);const gn=g0();i.useEffect(()=>{ot&&fr&&zn>=vt.length&&gn.auto({ready:()=>!en.current&&!Nr.current.has(fr),load:()=>Or(fr),inReach:()=>{var x;return!!((x=jn.current)!=null&&x.isConnected)}})},[ot,fr,zn,vt.length,Or,gn.auto]),i.useEffect(()=>{ot&&Bn(sr)},[ot]),i.useEffect(()=>{const x=jn.current;if(!ot||!x)return;const S=new IntersectionObserver(T=>{T.some(L=>L.isIntersecting)&&Bn(L=>L>=Zn.current?L:L+sr)},{root:x.closest(".ve-scroll")||null,rootMargin:"300px"});return S.observe(x),()=>S.disconnect()},[ot,zn,vt.length,fr]);const Hn=i.useRef(null),[hr,kr]=i.useState(null),ze=V.doc,Qn=async(x,S)=>{const T=await Jt(`${$t}/api/creatify/editor/${x}`,S||{});if(T&&T.ok===!1)throw new Error(T.error||"Request failed.");return T},Kn=async(x,S)=>{A(x);try{return await S()}catch(T){me.error((T==null?void 0:T.message)||"Something went wrong.")}finally{A("")}},ar=async x=>{const S=V4(await La(await Od(x),"video-editor"));if(!S)throw new Error("Upload failed.");try{await fetch(S,{method:"GET",mode:"no-cors"})}catch{}return S},_n=(x,S)=>{if(!x||Ke.current.has(x))return;const T={file:S,promise:ar(S)};T.promise.then(L=>{T.url=L,mn(K=>K+1)}).catch(()=>mn(L=>L+1)),Ke.current.set(x,T)},bn=async x=>{if(!(x!=null&&x.tracks))return x;const S=Ke.current,T=new Set;for(const K of x.tracks)for(const ee of K.clips||[])typeof ee.src=="string"&&S.has(ee.src)&&T.add(ee.src);if(!T.size)return x;const L={};return await Promise.all([...T].map(async K=>{const ee=S.get(K);try{L[K]=await ee.promise}catch{ee.promise=ar(ee.file),ee.promise.catch(()=>{}),L[K]=await ee.promise}})),{...x,tracks:x.tracks.map(K=>({...K,clips:(K.clips||[]).map(ee=>ee&&L[ee.src]?{...ee,src:L[ee.src]}:ee)}))}},Dn=x=>{z(S=>gy(S,x)),x.type!=="snapshot"&&W("dirty")},Se=()=>Dn({type:"snapshot"}),is=x=>Dn({type:"live",fn:x}),Wt=x=>Dn({type:"commit",fn:x}),_o=()=>Dn({type:"undo"}),Tr=()=>Dn({type:"redo"}),ta=()=>Dn({type:"discard"});i.useEffect(()=>{});const Nt=()=>H?[H,...se]:[],qr=(x,S)=>H&&H.trackId===x&&H.clipId===S||se.some(T=>T.trackId===x&&T.clipId===S),Wn=(x,S,T)=>{if(Ct(null),!T){ne({trackId:x,clipId:S}),pe([]);return}if(!H){ne({trackId:x,clipId:S});return}H.trackId===x&&H.clipId===S||pe(L=>L.some(K=>K.trackId===x&&K.clipId===S)?L.filter(K=>!(K.trackId===x&&K.clipId===S)):[...L,{trackId:x,clipId:S}])},Vr=()=>{ne(null),pe([]),Ct(null)},gs=()=>{var S;
121if(!mt||!ze||!H||H.trackId!==mt.trackId||H.clipId!==mt.clipId)return null;const x=(((S=(ze.tracks||[]).find(T=>T.id===mt.trackId))==null?void 0:S.clips)||[]).find(T=>T.id===mt.clipId);return x&&Xd(x).includes(mt.f)?mt:null},Qs=()=>{const x=gs();return x?(Wt(S=>Ps(S,x.trackId,x.clipId,T=>Cy(T,x.f))),Ct(null),!0):!1},eo=x=>{const S=gs();S&&Wt(T=>Ps(T,S.trackId,S.clipId,L=>My(L,S.f,x)))},gt=(x,S)=>{H&&(S?is:Wt)(T=>Ps(T,H.trackId,H.clipId,x))},U=()=>gt({x:50,y:50,rotation:0}),ue=()=>Math.max(0,Math.min(Math.max(1,Math.round(Number(Te==null?void 0:Te.durationInFrames)||1))-1,ie-Math.round(Number(Te==null?void 0:Te.fromFrame)||0))),Q=(x,S=Jc(Yn,x))=>{if(!Te)return S;const T=Go(Te,x,ue(),Te[x]??S),L=x==="volume"||x==="handheld"?1e3:10;return Number.isFinite(T)?Math.round(T*L)/L:T},fe=x=>{if(Te&&(jy[Yn]||[]).includes(x))return Fr(Te,x).length?sf(Te,x,ue())?"on":"off":"none"},ge=(x,S=Jc(Yn,x))=>{if(!Te)return;const T=ue();Wt(L=>Ps(L,H.trackId,H.clipId,K=>sf(K,x,T)?T0(K,x,T):Hu(K,x,T,Go(K,x,T,S))))},je=(x,S,T,L)=>{if(!Te)return;const K=ue();if(!Fr(Te,x).length){gt({[x]:S},L);return}is(ee=>Ps(ee,H.trackId,H.clipId,be=>Hu(be,x,K,S)))},Oe=(x,S)=>{H&&is(T=>{const L=Ps(T,H.trackId,H.clipId,{transitionIn:Math.max(0,Math.round(x))});return{...L,tracks:L.tracks.map(K=>K.id!==H.trackId?K:{...K,clips:[...K.clips].sort((ee,be)=>(ee.fromFrame||0)-(be.fromFrame||0))})}})},st=x=>{const S=new Set;for(const T of(x==null?void 0:x.tracks)||[])for(const L of T.clips||[])typeof L.src=="string"&&S.add(L.src);for(const T of[...Ke.current.keys()])if(!S.has(T)){try{URL.revokeObjectURL(T)}catch{}Ke.current.delete(T)}};i.useEffect(()=>()=>st(),[]),i.useEffect(()=>{if(p||!v)return;let x=!0;return Jt(`${$t}/api/creatify/jobs`,{origin:"editor",limit:5}).then(S=>{x&&m(((S==null?void 0:S.jobs)||[]).filter(T=>(T==null?void 0:T.resultUrl)&&!M.current.has(String(T.id))).slice(0,3))}).catch(()=>{}),()=>{x=!1}},[p==null?void 0:p.id,!p,v]);const Ee=(x,S)=>{if(C(0),l&&!l())return;st(x==null?void 0:x.editDoc),b(x),F(K=>K&&si.has(K.status)?K:S&&si.has(S.status)?S:null);const T=xy(x.editDoc||{}),L=T.minDurationInFrames==null&&Number(T.durationInFrames)>0&&!kl(T)?{...T,minDurationInFrames:Math.round(Number(T.durationInFrames))}:T;z({doc:$c(ly(L)),past:[],future:[]}),Vr(),O(0),W("saved"),Ye({zoom:1,panX:0,panY:0}),ut(!1)},tn=({name:x,width:S,height:T,fps:L,durationInFrames:K,background:ee})=>{nt(!1),Ee({id:null,title:x||"Untitled Composition",status:"draft",editDoc:{fps:L,width:S,height:T,durationInFrames:K,minDurationInFrames:K,background:ee==="transparent"?null:ee,tracks:[]}},null)},Dt=async()=>{var Ce;if(!ze)return;const x=(Ce=ze.tracks)==null?void 0:Ce.some(Be=>(Be.clips||[]).some(Ve=>typeof Ve.src=="string"&&Ve.src.startsWith("blob:")));let S=ze;
121if(x){A("Preparing mediaâ¦");try{S=await bn(ze)}catch{A(""),me.error("Couldn't finish uploading your video for the project file, try again in a moment.");return}A("")}const T={format:"studioe-video-project",version:1,app:"STUDIOE",title:(p==null?void 0:p.title)||"Untitled project",exportedAt:new Date().toISOString(),doc:S},L=((p==null?void 0:p.title)||"studioe-video").replace(/[^\w-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"studioe-video",K=new Blob([JSON.stringify(T,null,2)],{type:"application/json"}),ee=URL.createObjectURL(K),be=document.createElement("a");be.href=ee,be.download=`${L}.svproj`,document.body.appendChild(be),be.click(),be.remove(),setTimeout(()=>URL.revokeObjectURL(ee),4e3),W("saved");try{localStorage.removeItem(hl)}catch{}me.success(`Project saved to a file. Reopen it to keep editing: the clips it uses stay on our side for ${Ja(d==null?void 0:d.uploadHours)}.`)},Ds=async x=>{if(x)try{if(x.size>25*1024*1024)throw new Error("That file is too large to be a StudioE project.");const S=JSON.parse(await x.text()),T=S!=null&&S.doc&&Array.isArray(S.doc.tracks)?S.doc:Array.isArray(S==null?void 0:S.tracks)?S:null;if(!T)throw new Error("That doesn't look like a StudioE project file.");Ee({id:null,title:(S==null?void 0:S.title)||x.name.replace(/\.[^.]+$/,"")||"Imported project",status:"draft",editDoc:T},null),me.success("Project opened, continue editing. Use âSave Projectâ to export it again."),ls(T)}catch(S){me.error((S==null?void 0:S.message)||"Couldn't open that project file.")}};i.useEffect(()=>{let x=!0;
121return e&&Kn("Loading editâ¦",async()=>{const S=await Qn("get",{editId:e});x&&Ee({...S.edit,id:null},S.job)}),()=>{x=!1}},[e]),i.useEffect(()=>{var x;if(!h){try{(x=Z.current)==null||x.pause()}catch{}ce(!1)}},[h]),i.useEffect(()=>{if(!(!p||!h))return document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.overflow="",document.documentElement.style.overflow=""}},[!!p,h]),i.useEffect(()=>{const x=Ht.current;if(!x)return;const S=T=>{T.preventDefault();const L=x.getBoundingClientRect(),K=T.clientX-L.left-L.width/2,ee=T.clientY-L.top-L.height/2,be=T.deltaY<0?1.1:1/1.1;Ye(Ce=>{const Be=Math.max(.25,Math.min(8,Ce.zoom*be)),Ve=Be/Ce.zoom;return{zoom:Be,panX:K-(K-Ce.panX)*Ve,panY:ee-(ee-Ce.panY)*Ve}})};return x.addEventListener("wheel",S,{passive:!1}),()=>x.removeEventListener("wheel",S)},[p==null?void 0:p.id]),i.useEffect(()=>{if(!p||!ze||D!=="dirty")return;const x=setTimeout(()=>{try{const S=Ke.current,T={...ze,tracks:(ze.tracks||[]).map(L=>({...L,clips:(L.clips||[]).map(K=>{var be;const ee=typeof K.src=="string"?(be=S.get(K.src))==null?void 0:be.url:null;return ee?{...K,src:ee}:K})}))};localStorage.setItem(hl,JSON.stringify({title:(p==null?void 0:p.title)||"Untitled edit",ts:Date.now(),userId:y.current,doc:T}))}catch{}},1200);return()=>clearTimeout(x)},[ze,D,p,Xn]),i.useEffect(()=>{if(!p)try{const x=JSON.parse(localStorage.getItem(hl)||"null");if(x!=null&&x.userId&&!y.current)return;if(y.current&&x&&x.userId!==y.current){localStorage.removeItem(hl);return}x!=null&&x.doc&&Array.isArray(x.doc.tracks)&&tt(x)}catch{}},[p,c]);const Xr=()=>{tt(null);try{localStorage.removeItem(hl)}catch{}},ls=x=>{C(0),Qn("check-media",{editDoc:x}).then(S=>{var T;(T=S==null?void 0:S.missing)!=null&&T.length&&C(S.missing.length)}).catch(()=>{})},Do=()=>{if(!xn)return;let x=0;const S={...xn.doc,tracks:(xn.doc.tracks||[]).map(T=>({...T,clips:(T.clips||[]).filter(L=>{const K=typeof L.src=="string"&&L.src.startsWith("blob:");return K&&x++,!K})}))};Ee({id:null,title:xn.title||"Recovered session",status:"draft",editDoc:S},null),tt(null),W("dirty"),ls(S),x?me.error(x===1?"Restored. One layer used a file that was still uploading when the session ended, so add it again from disk.":`Restored. ${x} layers used files that were still uploading when the session ended, so add them again from disk.`):me.success("Session restored.")};i.useEffect(()=>{if(!(p!=null&&p.id)||p.status!=="rendering")return;const x=setInterval(async()=>{var S,T;try{const L=await Qn("get",{editId:p.id});b(K=>({...K,status:L.edit.status,finalVideoUrl:L.edit.finalVideoUrl})),(S=L.job)!=null&&S.id&&L.job.id===I.current&&F(L.job),((T=L.edit)==null?void 0:T.status)!=="rendering"&&clearInterval(x)}catch{}},5e3);return()=>clearInterval(x)},[p==null?void 0:p.id,p==null?void 0:p.status]);const cs=!!(p!=null&&p.id)&&p.status==="rendering",Sr=cs||!!N&&si.has(N.status),yo=(p==null?void 0:p.finalVideoUrl)||((N==null?void 0:N.status)==="completed"?N.resultUrl:null);i.useEffect(()=>{if(cs||!(N!=null&&N.id)||!si.has(N.status))return;const x=N.id,S=Date.parse(N.createdAt||"")||Date.now();let T=!1,L=0;const K=()=>typeof document<"u"&&document.hidden,ee=()=>{const Ve=Date.now()-S;return Ve<2*6e4?5e3:Ve<10*6e4?1e4:3e4},be=()=>{T||Be()},Ce=()=>{T||(K()?document.addEventListener("visibilitychange",be,{once:!0}):L=setTimeout(Be,ee()))},Be=async()=>{if(!T){if(K())return Ce();try{const Ve=await Jt(`${$t}/api/creatify/jobs/${x}/status`,{});if(T)return;Ve!=null&&Ve.job&&F(Ve.job)}catch(Ve){if((Ve==null?void 0:Ve.status)===404){I.current===x&&(I.current=null),F(wt=>(wt==null?void 0:wt.id)===x?null:wt);return}}Ce()}};return Ce(),()=>{T=!0,clearTimeout(L),typeof document<"u"&&document.removeEventListener("visibilitychange",be)}},[cs,N==null?void 0:N.id,N==null?void 0:N.status]);const Cr=i.useRef(()=>{});Cr.current=(x,S)=>{try{const T=ec(x,S||"Video edit","video");T&&typeof T.catch=="function"&&T.catch(()=>{})}catch{}},i.useEffect(()=>{const x=N;if(!(x!=null&&x.id)||I.current!==x.id)return;if(x.status==="failed"){I.current=null,me.error("Your export didn't finish. Try exporting again.");return}if(x.status!=="completed"||!x.resultUrl)return;I.current=null;const S=x.resultUrl,T=(p==null?void 0:p.title)||x.title||"Video edit";M.current.add(String(x.id)),Cr.current(S,T),me.success(t.jsxs("span",{"data-export-ready-toast":!0,children:["Your video is ready, and should be saving to your computer."," ",t.jsx("button",{type:"button",onClick:()=>Cr.current(S,T),className:"font-semibold underline underline-offset-2",children:"Download"})]}))},[N==null?void 0:N.id,N==null?void 0:N.status,N==null?void 0:N.resultUrl]);const bs=D!=="saved"||!!R;i.useEffect(()=>{if(!bs&&!Sr)return;const x=S=>{S.preventDefault(),S.returnValue=""};return window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[bs,Sr]),i.useEffect(()=>(u==null||u({unsaved:bs,exporting:!!Sr}),Hp(bs),()=>{u==null||u({unsaved:!1,exporting:!1}),Hp(!1)}),[bs,Sr]),i.useEffect(()=>{const x=Z.current;if(!x)return;const S=T=>O(T.detail.frame);try{x.addEventListener("frameupdate",S)}catch{}return()=>{try{x.removeEventListener("frameupdate",S)}catch{}}},[p==null?void 0:p.id,!!ze]);const Ls=i.useRef(!1),Nn=()=>
121{if(Ls.current)return;if(!ze||!Array.isArray(ze.tracks)||!ze.tracks.some(T=>(T.clips||[]).length)){me.error("Add something to the timeline first.");return}const x=E0(ze);if(x){me.error(x);return}Ls.current=!0;const S=()=>{Ls.current=!1};return p!=null&&p.id?Kn("Starting renderâ¦",async()=>{if(D!=="saved")try{await Qn("update",{editId:p.id,editDoc:ze}),W("saved")}catch{}const T=await Qn("render",{editId:p.id,editDoc:ze}).catch(L=>{throw(L==null?void 0:L.code)==="MEDIA_EXPIRED"&&C(Oh(L)),L});T.edit&&b(L=>({...L,status:T.edit.status})),T.job&&(I.current=T.job.id,F(T.job),n==null||n(T.job)),C(0),Pc("videoEditor.export"),me.success("Exporting. When it's done it saves to your computer.")}).finally(S):Kn("Starting renderâ¦",async()=>{const T=await bn(ze),L=await Qn("render-doc",{editDoc:T,title:(p==null?void 0:p.title)||"Video edit"}).catch(K=>{throw(K==null?void 0:K.code)==="MEDIA_EXPIRED"&&C(Oh(K)),K});L.job&&(I.current=L.job.id,F(L.job),n==null||n(L.job)),C(0),Pc("videoEditor.export"),me.success("Exporting. When it's done it saves to your computer.")}).finally(S)},Fn=Math.max(1,Math.round((ze==null?void 0:ze.durationInFrames)||1)),We=(ze==null?void 0:ze.fps)||30,Ln=(Fn/We).toFixed(1),er=i.useMemo(()=>({editDoc:ze}),[ze]),Lo=i.useMemo(()=>ze?t.jsx(XN,{ref:Z,component:P4,inputProps:er,durationInFrames:Fn,fps:We,compositionWidth:ze.width,compositionHeight:ze.height,style:{width:"100%",height:"100%"},acknowledgeRemotionLicense:!0}):null,[er,Fn,We,ze]);i.useEffect(()=>{ie>Fn-1&&On(Fn-1)},[Fn]);const yn=x=>x/We*oe,to=x=>Math.round(x/oe*We),ds=x=>{const S=Math.max(0,Math.round(x)),T=S%We,L=Math.floor(S/We),K=ee=>String(ee).padStart(2,"0");return`${K(Math.floor(L/60))}:${K(L%60)}:${K(T)}`},On=x=>{var T,L;const S=Math.max(0,Math.min(Fn-1,Math.round(x)));O(S);try{(T=Z.current)==null||T.pause(),(L=Z.current)==null||L.seekTo(S)}catch{}},no=()=>{const x=Z.current;if(x)try{x.isPlaying&&x.isPlaying()?x.pause():x.play()}catch{}},ys=x=>On(ie+x),vs=x=>{ht(null);const S=Number(x);if(!Number.isFinite(S)||S<=0)return;const T=Math.max(1,Math.min(Gs,Math.round(S*We))),L=kl(ze);Wt(K=>({...K,minDurationInFrames:T})),T<L&&me.info(`The edit is ${(L/We).toFixed(1)}s because a clip runs that far. Trim or move it to go shorter.`)},vo=()=>{const x=new Set([0]);for(const T of(ze==null?void 0:ze.tracks)||[])for(const L of T.clips||[]){const K=Number(L.fromFrame)||0,ee=Number(L.durationInFrames)||0;x.add(K),x.add(K+ee)}const S=Math.max(0,(Fn||1)-1);return x.add(S),[...x].filter(T=>Number.isFinite(T)&&T>=0&&T<=S).sort((T,L)=>T-L)},Jr=x=>{const S=vo(),T=x<0?[...S].reverse().find(L=>L<ie):S.find(L=>L>ie);T!=null&&On(T)},Os=(x,S)=>{if(!Re)return x;let T=x,L=8.5;for(const K of S){const ee=Math.abs(yn(K)-yn(x));ee<L&&(L=ee,T=K)}return T},Xt=(x,S,T,L)=>{if(x.button===2){x.stopPropagation();return}x.preventDefault(),x.stopPropagation(),Wn(S,T.id,!1),Ct({trackId:S,clipId:T.id,f:L}),ur(!0);const K=x.clientX,ee=Math.round(Number(T.fromFrame)||0),be=Math.max(1,Math.round(Number(T.durationInFrames)||1)),Ce=T,Be=Xd(T).filter(Vn=>Vn!==L).map(Vn=>ee+Vn),Ve=[ie,ee,ee+be-1,...Be];let wt=!1,Yt=0,St=K,bt=L;const Mt=()=>{Yt=0;const Vn=ee+L+to(St-K),pn=Os(Vn,Ve),ts=Math.max(0,Math.min(be-1,pn-ee));bt=ts,Vt(pn!==Vn?ee+ts:null),is(It=>Ps(It,S,T.id,()=>Fy(Ce,L,ts)))},cn=x.pointerId,Co=Vn=>{if(Vn.pointerId===cn){if(!wt){if(Math.abs(Vn.clientX-K)<3)return;wt=!0,Se()}St=Vn.clientX,Yt||(Yt=requestAnimationFrame(Mt))}},Er=Vn=>{if(window.removeEventListener("pointermove",Co),window.removeEventListener("pointerup",aa),window.removeEventListener("pointercancel",ia),Yt&&(cancelAnimationFrame(Yt),Yt=0,Vn||Mt()),Vt(null),ur(!1),Vn){wt&&ta();return}wt?Ct({trackId:S,clipId:T.id,f:bt}):On(ee+L)},aa=Vn=>{Vn.pointerId===cn&&Er(!1)},ia=Vn=>{Vn.pointerId===cn&&Er(!0)};window.addEventListener("pointermove",Co),window.addEventListener("pointerup",aa),window.addEventListener("pointercancel",ia)},wo=(x,S,T,L)=>{var ts;x.preventDefault(),x.stopPropagation();const K=qr(S,T.id);if(x.shiftKey&&L==="move"){Wn(S,T.id,!0);return}K||Wn(S,T.id,!1),Ct(null);const ee=L==="move"?[{trackId:S,clipId:T.id},...K?Nt():[]].filter((It,Pn,$r)=>$r.findIndex(Ge=>Ge.trackId===It.trackId&&Ge.clipId===It.clipId)===Pn):[{trackId:S,clipId:T.id}],be=new Map;for(const It of ee){const Pn=(((ts=(ze.tracks||[]).find($r=>$r.id===It.trackId))==null?void 0:ts.clips)||[]).find($r=>$r.id===It.clipId);Pn&&be.set(`${It.trackId}/${It.clipId}`,Math.round(Number(Pn.fromFrame)||0))}An(!0);const Ce=x.clientX,Be=T.fromFrame||0,Ve=T.durationInFrames||1,wt=T.trimStart||0,Yt=T.keys,St=[0,Fn,ie];for(const It of ze.tracks||[])for(const Pn of It.clips||[])Pn.id!==T.id&&
121(St.push(Pn.fromFrame||0),St.push((Pn.fromFrame||0)+(Pn.durationInFrames||1)));for(let It=0;It<=Fn/We;It++)St.push(It*We);let bt=!1,Mt=Ce,cn=0;const Co=()=>{cn=0;const It=to(Mt-Ce);let Pn=null;if(L==="move"&&ee.length>1){const $r=Math.max(0,Be+It),Ge=Os($r,St);Ge!==$r&&(Pn=Ge);const _r=Math.max(Ge-Be,-Math.min(...be.values()));is(q=>{let ir=q;for(const Ks of ee){const Ws=be.get(`${Ks.trackId}/${Ks.clipId}`)??0;ir=Ps(ir,Ks.trackId,Ks.clipId,{fromFrame:Math.max(0,Ws+_r)})}return ir}),Vt(Pn);return}is($r=>Ps($r,S,T.id,Ge=>{if(L==="move"){const Ss=Math.max(0,Be+It),Cs=Os(Ss,St);return Cs!==Ss&&(Pn=Cs),{...Ge,fromFrame:Math.max(0,Cs)}}if(L==="end"){const Ss=Be+Math.max(2,Ve+It),Cs=Os(Ss,St);Cs!==Ss&&(Pn=Cs);const Uo=C0(Ge),Es=Math.max(2,Cs-Be);return{...Ge,durationInFrames:Uo?Math.min(Es,Uo):Es}}const _r=Math.max(0,Math.min(Be+Ve-2,Be+It)),q=Os(_r,St),ir=Math.max(0,Math.min(Be+Ve-2,q));q!==_r&&(Pn=ir);const Ks=ir-Be,Ws=Math.max(.1,Number(Ge.speed)||1);let lr=Ks;if(Ge.src!=null){const Ss=Math.max(0,wt+Math.round(Ks*Ws));lr=Math.round((Ss-wt)/Ws)}return{...Ge,fromFrame:Be+lr,durationInFrames:Math.max(2,Ve-lr),...Ge.src!=null?{trimStart:Math.max(0,wt+Math.round(lr*Ws))}:{},keys:A0({...Ge,keys:Yt},lr).keys}})),Vt(Pn)},Er=x.pointerId,aa=It=>{if(It.pointerId===Er){if(!bt){if(Math.abs(It.clientX-Ce)<3)return;Se(),bt=!0}Mt=It.clientX,cn||(cn=requestAnimationFrame(Co))}},ia=It=>{if(window.removeEventListener("pointermove",aa),window.removeEventListener("pointerup",Vn),window.removeEventListener("pointercancel",pn),cn&&(cancelAnimationFrame(cn),cn=0,It||Co()),An(!1),Vt(null),It){bt&&ta();return}if(!bt)return;const Pn=L==="move"&&ee.length>1?ee:[{trackId:S,clipId:T.id}];is($r=>Pn.reduce((Ge,_r)=>vy(Ge,_r.trackId,_r.clipId),$r))},Vn=It=>{It.pointerId===Er&&ia(!1)},pn=It=>{It.pointerId===Er&&ia(!0)};window.addEventListener("pointermove",aa),window.addEventListener("pointerup",Vn),window.addEventListener("pointercancel",pn)},Vs=x=>{const S=x.currentTarget.getBoundingClientRect().left,T=be=>On(to(be-S));T(x.clientX);const L=x.pointerId,K=be=>{be.pointerId===L&&T(be.clientX)},ee=be=>{be.pointerId===L&&(window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",ee),window.removeEventListener("pointercancel",ee))};window.addEventListener("pointermove",K),window.addEventListener("pointerup",ee),window.addEventListener("pointercancel",ee)},ro=x=>{var Ce;const S=(Ce=x.target.files)==null?void 0:Ce[0];if(x.target&&(x.target.value=""),!S)return;if(S.size>25*1024*1024){me.error("File too large (max ~25 MB).");return}const T=(S.type||"").startsWith("video/")||/\.(mp4|mov|m4v|webm|mkv|avi)$/i.test(S.name||""),L=Be=>T&&/\/upload\//.test(Be)?Be.replace("/upload/","/upload/f_mp3/").replace(/\.(mp4|mov|m4v|webm|mkv|avi)(\?|$)/i,".mp3$1"):Be,K=T?`${(S.name||"audio").replace(/\.[^.]+$/,"")} (audio)`:S.name,ee=qn.current;qn.current=null;const be=new FileReader;be.onload=()=>Kn(ee?"Replacing audioâ¦":T?"Extracting audioâ¦":"Uploading audioâ¦",async()=>{const Be=await Qn("upload-audio",{file:be.result});if(!Be.url)throw new Error("Upload failed.");const Ve=L(Be.url),wt=(ze==null?void 0:ze.fps)||30,Yt=await Oo(Ve),St=Yt?Math.max(1,Math.round(Yt*wt)):0;if(ee){Wt(Mt=>Ps(Mt,ee.trackId,ee.clipId,cn=>({...cn,src:Ve,name:K,srcFrames:St,trimStart:0,durationInFrames:nc({srcFrames:St,trimStart:0,speed:cn.speed,loop:cn.loop},cn.durationInFrames)}))),me.success("Audio replaced.");return}const bt=Wr("a_");Wt(Mt=>{const cn={id:bt,src:Ve,fromFrame:0,durationInFrames:nc({srcFrames:St},rc(Mt,St||300)),srcFrames:St,volume:1,name:K},{tracks:Co,trackId:Er}=zs(Mt,"audio","Audio",cn);return setTimeout(()=>Wn(Er,bt,!1),0),{...Mt,tracks:Co}}),me.success(T?"Audio extracted & added.":"Audio added.")}),be.readAsDataURL(S)},so=()=>{const x=Wr("c_");Wt(S=>{var be;const T=rc(S,60),L={id:x,text:"New caption",fromFrame:sc(S.durationInFrames,T,ie),durationInFrames:T,x:50,y:84,size:60,color:"#ffffff",align:"center"},{tracks:K,trackId:ee}=el(S,"caption",[L],{prefer:(be=(S.tracks||[]).find(Ce=>Ce.type==="caption"))==null?void 0:be.id,name:"Captions",firstTrackId:"captions"});return setTimeout(()=>Wn(ee,x,!1),0),{...S,tracks:K}})},Us=async x=>{var T;const S=(T=x.target.files)==null?void 0:T[0];if(x.target&&(x.target.value=""),!!S)try{const L=by(await S.text());if(!L.length)throw new Error("No subtitles found in that file (.srt or .vtt).");let K=0;Wt(be=>{var St;const Ce=be.fps||30,Be=Math.max(1,Math.round(be.durationInFrames||1)),Ve=Be>1||kl(be)?Be:Gs,wt=[];for(const bt of L){const Mt=Math.max(0,Math.round(bt.startSec*Ce));if(Mt>=Ve){K++;continue}const cn=Math.min(Ve-Mt,Math.max(1,Math.round((bt.endSec-bt.startSec)*Ce)));wt.push({id:Wr("c_"),text:bt.text,fromFrame:Mt,durationInFrames:cn,x:50,y:84,size:60,color:"#ffffff",align:"center"})}const{tracks:Yt}=el(be,"caption",wt,{prefer:(St=(be.tracks||[]).find(bt=>bt.type==="caption"))==null?void 0:St.id,name:"Captions",firstTrackId:"captions"});return{...be,tracks:Yt}});const ee=L.length-K;me.success(K?`Imported ${ee} caption${ee===1?"":"s"}. ${K} started after the end of the video, so ${K===1?"it was":"they were"} left out.`:`Imported ${ee} caption${ee===1?"":"s"}.`)}catch(L){me.error((L==null?void 0:L.message)||"Couldn't read that subtitle file.")}},zs=(x,S,T,L,K=3)=>{const ee=(x.tracks||[]).filter(be=>be.type===S);if(ee.length<K){const be={id:Wr(S.slice(0,3)+"_"),type:S,name:`${T} ${ee.length+1}`,clips:[L]};return{tracks:[...x.tracks||[],be],trackId:be.id}}return el(x,S,[L],{prefer:ee[ee.length-1].id,name:T})},$e=()=>{const x=Wr("sh_");Wt(S=>{const T=rc(S,90),L={id:x,shape:"rect",fromFrame:sc(S.durationInFrames,T,ie),durationInFrames:T,x:50,y:50,width:42,he
121ight:24,color:"#8b5cf6",opacity:100,rotation:0,radius:16},{tracks:K,trackId:ee}=zs(S,"shape","Shapes",L);return setTimeout(()=>Wn(ee,x,!1),0),{...S,tracks:K}})},kt=x=>{var T;const S=(T=x.target.files)==null?void 0:T[0];x.target&&(x.target.value=""),S&&Kn("Uploading imageâ¦",async()=>{let L=null;try{L=await ii(S,"video-editor")}catch(ee){qo(ee,"Couldn't add that image.");return}if(!L){me.error("Couldn't add that image.");return}const K=Wr("im_");Wt(ee=>{const be=rc(ee,120),Ce={id:K,src:L,fromFrame:sc(ee.durationInFrames,be,ie),durationInFrames:be,x:50,y:50,w:100,rotation:0,radius:0,name:S.name},{tracks:Be,trackId:Ve}=zs(ee,"image","Image",Ce);return setTimeout(()=>Wn(Ve,K,!1),0),{...ee,tracks:Be}}),me.success("Image added.")})},on=x=>{var T;const S=(T=x.target.files)==null?void 0:T[0];if(x.target&&(x.target.value=""),!!S){try{ad(S)}catch{me.error(`Use an mp4, mov or webm video up to ${Il} MB.`);return}Kn("Adding video layerâ¦",async()=>{const L=URL.createObjectURL(S),K=await s0(Bs(L)),ee=Number(K.durationSeconds)||0;if(ee>Fc)throw URL.revokeObjectURL(L),new Error(`That video is ${Math.round(ee)} seconds. The editor takes clips up to ${Math.round(Fc/60)} minutes, so please trim it and try again.`);_n(L,S);const be=ze.fps||30,Ce=ee>0?Math.max(be,Math.round(ee*be)):0,Be=Ce||Math.max(be,Math.round(ze.durationInFrames||10*be)),Ve=Wr("v_");Wt(wt=>{const Yt={id:Ve,src:L,fromFrame:sc(wt.durationInFrames,Be,ie),durationInFrames:Be,srcFrames:Ce,fit:"cover",sceneTitle:(S.name||"Video").replace(/\.[^.]+$/,"")},{tracks:St,trackId:bt}=zs(wt,"video","Video",Yt);return setTimeout(()=>Wn(bt,Ve,!1),0),{...wt,tracks:St.map(Mt=>Mt.id===bt?{...Mt,muted:!1}:Mt)}}),me.success("Video layer added.")})}},kn=(x,S)=>(qn.current=null,x({target:{files:[S],value:""}})),ws=x=>{const S=Array.from(x||[]);if(!S.length)return;S.length>1&&me.info("One file at a time. Only the first was added.");const T=S[0],L=(T.name||"").toLowerCase(),K=T.type||"";if(K.startsWith("video/")||/\.(mp4|mov|webm|mkv|m4v)$/.test(L))return kn(on,T);if(K.startsWith("image/")||/\.(png|jpe?g|webp|heic|heif|avif|gif)$/.test(L))return kn(kt,T);if(K.startsWith("audio/")||/\.(mp3|wav|m4a|aac|ogg|oga|flac)$/.test(L))return kn(ro,T);if(/\.(srt|vtt)$/.test(L))return kn(Us,T);me.error("Unsupported file. Drop a video, an image, an audio file, or an SRT or VTT.")},oo=()=>{var K;if(!H)return;const x=(((K=ze==null?void 0:ze.tracks.find(ee=>ee.id===H.trackId))==null?void 0:K.clips)||[]).find(ee=>ee.id===H.clipId);if(!x)return;if(x.loop){gt(ee=>({loop:!1,durationInFrames:nc({...ee,loop:!1},ee.durationInFrames)}));return}const S=H,T=ee=>Wt(be=>{var bt;const Ce=(be.tracks||[]).find(Mt=>Mt.id===S.trackId),Be=(bt=Ce==null?void 0:Ce.clips)==null?void 0:bt.find(Mt=>Mt.id===S.clipId);if(!Be)return be;const Ve=Math.round(Number(Be.fromFrame)||0),wt=Math.max(1,Math.round(Number(Be.durationInFrames)||1)),Yt=(Ce.clips||[]).filter(Mt=>Mt.id!==Be.id&&Math.round(Number(Mt.fromFrame)||0)>=Ve+wt).reduce((Mt,cn)=>Math.min(Mt,Math.round(Number(cn.fromFrame)||0)),1/0),St=Math.min(Math.round(Number(be.durationInFrames)||1),Yt);return Ps(be,S.trackId,S.clipId,{loop:!0,loopFrames:ee,durationInFrames:Math.max(wt,St-Ve)})}),L=document.createElement("audio");L.preload="metadata",L.crossOrigin="anonymous",L.onloadedmetadata=()=>T(Math.max(1,Math.round((L.duration||0)*We))||x.durationInFrames),L.onerror=()=>T(x.durationInFrames),L.src=x.src},Oo=x=>new Promise(S=>{const T=document.createElement("audio");T.preload="metadata";let L=!1;const K=ee=>{L||(L=!0,T.src="",S(ee))};T.onloadedmetadata=()=>K(isFinite(T.duration)?T.duration:0),T.onerror=()=>K(0),setTimeout(()=>K(0),gb),T.src=x}),Bs=x=>new Promise(S=>{const T=document.createElement("video");T.preload="metadata",T.muted=!0,T.crossOrigin="anonymous";let L=!1;const K=ee=>{L||(L=!0,S(ee))};T.onloadedmetadata=()=>K({width:T.videoWidth||1080,height:T.videoHeight||1920,durationSeconds:isFinite(T.duration)?T.duration:0}),T.onerror=()=>K({width:1080,height:1920,durationSeconds:0}),setTimeout(()=>K({width:1080,height:1920,durationSeconds:0}),12e3),T.src=x}),ao=async(x,{title:S,width:T,height:L,durationSeconds:K})=>{let ee=T,be=L,Ce=K;if(!ee||!be||!Ce){const cn=await Bs(x);ee=ee||cn.width,be=be||cn.height,Ce=Ce||cn.durationSeconds}const Be=30;let Ve=Math.max(16,Math.round(Number(ee)||1080)),wt=Math.max(16,Math.round(Number(be)||1920));const Yt=Math.max(Ve,wt)/4096;Yt>1&&(Ve=Math.max(16,2*Math.round(Ve/Yt/2)),wt=Math.max(16,2*Math.round(wt/Yt/2)));
121const St=Math.max(Be,Math.round((Number(Ce)||10)*Be)),bt=S&&String(S).trim()?String(S).trim().slice(0,160):"Untitled edit";Ee({id:null,title:bt,status:"draft",editDoc:{fps:Be,width:Ve,height:wt,durationInFrames:St,minDurationInFrames:1,tracks:[{id:"scenes",type:"video",name:"Video",muted:!1,clips:[{id:"v_main",src:x,fromFrame:0,durationInFrames:St,fit:"cover",sceneTitle:bt}]},{id:"captions",type:"caption",name:"Captions",clips:[]}]}},null)},na=x=>{if(x&&!(l&&!l())){try{ad(x)}catch{me.error(`Use an mp4, mov or webm video up to ${Il} MB.`);return}Kn("Opening videoâ¦",async()=>{const S=URL.createObjectURL(x),T=await s0(Bs(S)),L=Number(T.durationSeconds)||0;if(L>Fc)throw URL.revokeObjectURL(S),new Error(`That video is ${Math.round(L)} seconds. The editor takes videos up to ${Math.round(Fc/60)} minutes, so please trim it and try again.`);_n(S,x),await ao(S,{title:(x.name||"Uploaded video").replace(/\.[^.]+$/,""),width:T.width,height:T.height,durationSeconds:T.durationSeconds}),me.success("Opened in the editor.")})}},tc=x=>{var T;const S=(T=x.target.files)==null?void 0:T[0];x.target&&(x.target.value=""),na(S)},io=x=>{qt(!1),Kn("Opening renderâ¦",async()=>{await ao(x.resultUrl,{title:x.title||"Render",sourceKind:"render",durationSeconds:x.durationSeconds||0})})};i.useEffect(()=>{if(r!=null&&r.url){if(!jo()){s==null||s();return}Kn("Opening renderâ¦",async()=>{await ao(r.url,{title:r.title||"Render",sourceKind:"render",durationSeconds:r.durationSeconds||0})}),s==null||s()}},[r]);const jo=()=>!p||D!=="dirty"||window.confirm("Open this in the Video Editor? The project you have open has changes you haven't saved, and they will be lost. Click Cancel to go back and use Save Project first.");i.useEffect(()=>{if(o!=null&&o.editDoc){if(!jo()){a==null||a();return}Ee({id:null,title:String(o.title||"Assembled ad").slice(0,160),status:"draft",editDoc:o.editDoc},null),a==null||a()}},[o]);const js=()=>{const x=Nt();x.length&&(Wt(S=>({...S,tracks:S.tracks.map(T=>{const L=new Set(x.filter(K=>K.trackId===T.id).map(K=>K.clipId));return L.size?{...T,clips:T.clips.filter(K=>
121!L.has(K.id))}:T})})),Vr())},Ur=()=>{const x=Nt();x.length&&(Wt(S=>{let T=S;for(const L of[...x].sort((K,ee)=>{const be=Ce=>{var Be,Ve;return Number((Ve=(((Be=(T.tracks||[]).find(wt=>wt.id===Ce.trackId))==null?void 0:Be.clips)||[]).find(wt=>wt.id===Ce.clipId))==null?void 0:Ve.fromFrame)||0};return be(ee)-be(K)}))T=wy(T,L.trackId,L.clipId);return T}),Vr())},ja=x=>{Wt(S=>({...S,tracks:(S.tracks||[]).filter(T=>T.id!==x)})),ne(S=>S&&S.trackId===x?null:S),pe(S=>S.filter(T=>T.trackId!==x))},ra=x=>Wt(S=>({...S,tracks:S.tracks.map(T=>T.id===x?{...T,hidden:!T.hidden}:T)})),Zr=x=>x.type==="video"?x.muted??!0:!!x.muted,No=x=>Wt(S=>({...S,tracks:S.tracks.map(T=>T.id===x?{...T,muted:!Zr(T)}:T)})),gi=(x,S)=>{!x||x===S||Wt(T=>{const L=[...T.tracks||[]].reverse(),K=L.findIndex(Ce=>Ce.id===x);if(K<0)return T;const[ee]=L.splice(K,1);let be=L.findIndex(Ce=>Ce.id===S);return be<0&&(be=L.length),L.splice(be,0,ee),L.reverse(),{...T,tracks:L}})},Qr=x=>S=>{S.preventDefault(),S.stopPropagation(),Hn.current=x,kr(x);const T=K=>{var be;const ee=(be=document.elementFromPoint(K.clientX,K.clientY))==null?void 0:be.closest("[data-trackid]");ee!=null&&ee.dataset.trackid&&kr(ee.dataset.trackid)},L=K=>{var be;window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L);const ee=K.type==="pointercancel"?null:(be=document.elementFromPoint(K.clientX,K.clientY))==null?void 0:be.closest("[data-trackid]");Hn.current&&(ee!=null&&ee.dataset.trackid)&&gi(Hn.current,ee.dataset.trackid),Hn.current=null,kr(null)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L)},Ha={video:"Video",image:"Image",shape:"Shapes",caption:"Captions",audio:"Audio"},Hs=()=>{if(!H)return;const x=Wr("d_");Wt(S=>{var Ce;const T=(S.tracks||[]).find(Be=>Be.id===H.trackId),L=(Ce=T==null?void 0:T.clips)==null?void 0:Ce.find(Be=>Be.id===H.clipId);if(!L)return S;const K={...L,id:x,fromFrame:(L.fromFrame||0)+(L.durationInFrames||1)},{tracks:ee,trackId:be}=el(S,T.type,[K],{prefer:T.id,name:Ha[T.type]});return setTimeout(()=>Wn(be,x,!1),0),{...S,tracks:ee}})},Ns=()=>{var T;if(!ze)return;const x=[];for(const L of Nt()){const K=(ze.tracks||[]).find(be=>be.id===L.trackId),ee=(T=K==null?void 0:K.clips)==null?void 0:T.find(be=>be.id===L.clipId);ee&&x.push({trackId:K.id,type:K.type,clip:JSON.parse(JSON.stringify(ee))})}if(!x.length)return;const S=Math.min(...x.map(L=>Math.round(Number(L.clip.fromFrame)||0)));$n.current={items:x.map(L=>({...L,offset:Math.round(Number(L.clip.fromFrame)||0)-S}))},me.success(x.length===1?"Clip copied, paste at the playhead with âV.":`${x.length} clips copied, paste them at the playhead with âV.`)},ks=()=>{H&&(Ns(),js())},Na=()=>{var T;const x=$n.current;if(!((T=x==null?void 0:x.items)!=null&&T.length)||!ze)return;const S=Math.max(0,Math.round(ie));Wt(L=>{var be;let K=L;const ee=[];for(const Ce of[...x.items].sort((Be,Ve)=>Be.offset-Ve.offset)){const Be=Wr("p_"),Ve={...JSON.parse(JSON.stringify(Ce.clip)),id:Be,fromFrame:S+Ce.offset},wt=(be=(K.tracks||[]).find(bt=>bt.id===Ce.trackId&&bt.type===Ce.type))==null?void 0:be.id,{tracks:Yt,trackId:St}=el(K,Ce.type,[Ve],{prefer:wt,name:Ha[Ce.type]});K={...K,tracks:Yt},ee.push({trackId:St,clipId:Be})}return setTimeout(()=>{Ct(null),ne(ee[0]),pe(ee.slice(1))},0),K})},Vo=()=>{H&&Wt(x=>({...x,tracks:x.tracks.map(S=>{if(S.id!==H.trackId)return S;const T=[];for(const L of S.clips){const K=L.fromFrame||0,ee=L.durationInFrames||1;if(L.id===H.clipId&&ie>K+1&&ie<K+ee-1){const be=ie-K,[Ce,Be]=Ku(L,be),Ve=Math.max(.1,Number(L.speed)||1);T.push({...L,durationInFrames:be,fadeOut:0,keys:Ce,...Uu(L)}),T.push({...L,id:Wr("s_"),fromFrame:ie,durationInFrames:ee-be,fadeIn:0,transitionIn:0,keys:Be,...zu(L,be),...L.src!=null?{trimStart:(L.trimStart||0)+Math.round(be*Ve)}:{}})}else T.push(L)}return{...S,clips:T}})}))};i.useEffect(()=>{const x=Z.current;if(!x)return;const S=()=>ce(!0),T=()=>ce(!1);try{x.addEventListener("play",S),x.addEventListener("pause",T),x.addEventListener("ended",T)}catch{}return()=>{try{x.removeEventListener("play",S),x.removeEventListener("pause",T),x.removeEventListener("ended",T)}catch{}}},[p==null?void 0:p.id,!!ze]),i.useEffect(()=>{if(!p||!h)return;const x=S=>{var ee,be,Ce,Be;const T=(((ee=S.target)==null?void 0:ee.tagName)||"").toLowerCase(),L=T==="input"||T==="textarea"||T==="select"||!!((be=S.target)!=null&&be.isContentEditable),K=(S.key||"").toLowerCase();if((S.metaKey||S.ctrlKey)&&K==="s"){S.preventDefault(),Dt();return}if(!L)if(S.code==="Space")S.preventDefault(),no();else if(S.key==="Delete"||S.key==="Backspace")gs()?(S.preventDefault(),Qs()):H&&(S.preventDefault(),S.shiftKey?Ur():js());else if((S.metaKey||S.ctrlKey)&&K==="z")S.preventDefault(),S.shiftKey?Tr():_o();else if((S.metaKey||S.ctrlKey)&&K==="d")H&&(S.preventDefault(),Hs());else if((S.metaKey||S.ctrlKey)&&K==="c")H&&(S.preventDefault(),Ns());else if((S.metaKey||S.ctrlKey)&&K==="x")H&&(S.preventDefault(),ks());else if((S.metaKey||S.ctrlKey)&&K==="v")$n.current&&(S.preventDefault(),Na());else if((S.metaKey||S.ctrlKey)&&K==="k")H&&(S.preventDefault(),Vo());else if((S.metaKey||S.ctrlKey)&&K==="y")S.preventDefault(),Tr();else if(K==="?"||S.shiftKey&&K==="/")S.preventDefault(),J(Ve=>!Ve);else if(S.key==="Escape")xt?(S.preventDefault(),J(!1)):rn?(S.preventDefault(),Ot(null)):gs()?(S.preventDefault(),Ct(null)):H&&(S.preventDefault(),Vr());else if(S.key==="ArrowUp")S.preventDefault(),Jr(-1);else if(S.key==="ArrowDown")S.preventDefault(),Jr(1);else if(S.key==="ArrowLeft")S.preventDefault(),ys(S.shiftKey?-10:-1);else if(S.key==="ArrowRight")S.preventDefault(),ys(S.shiftKey?10:1);else if(S.key==="Home")S.preventDefault(),On(0);else if(S.key==="End")S.preventDefault(),On(Fn-1);else if(K==="j")S.preventDefault(),ys(-1);else if(K==="k"){S.preventDefault();try{(Ce=Z.current)==null||Ce.pause()}catch{}}else if(K==="l"){S.preventDefault();try{(Be=Z.current)==null||Be.play()}catch{}}else K==="c"?H&&(S.preventDefault(),Vo()):K==="s"&&!S.shiftKey?(S.preventDefault(),le(Ve=>!Ve)):K==="h"?(S.preventDefault(),ut(Ve=>!Ve)):K==="z"&&S.shiftKey?(S.preventDefault(),es()):K==="="||K==="+"?(S.preventDefault(),we(Ve=>Math.min(400,Math.round(Ve*1.25)))):(K==="-"||K==="_")&&(S.preventDefault(),we(Ve=>Math.max(20,Math.round(Ve/1.25))))};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[p,h,H,se,mt,rn,ie,ze,xt]),i.useEffect(()=>{mt&&!gs()&&Ct(null)},[mt,H,ze]),i.useEffect(()=>{mt||Ot(null)},[mt]),i.useEffect(()=>{if(!p||!ze)return;const x=setTimeout(()=>{var T;const S=(T=ln.current)==null?void 0:T.clientWidth;S&&we(Math.max(16,Math.min(260,(S-134-28)/Fn*We)))},140);return()=>clearTimeout(x)},[p==null?void 0:p.id]);const zr=H&&ze?ze.tracks.find(x=>x.id===H.trackId):null,Te=zr?(zr.clips||[]).find(x=>x.id===H.clipId):null,Yn=zr?zr.type:null,Rn=gs(),us=Rn&&Te?rf(Te,Rn.f):null,sa=!!Rn&&!!Te&&Ey(Te,Rn.f);if(i.useEffect(()=>{var x;H&&(x=window.matchMedia)!=null&&x.call(window,"(max-width: 1023px)").matches&&jt(null)},[H]),!p){const x="group text-left rounded-2xl border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] hover:border-white/20 hover:-translate-y-0.5 transition-all duration-200 p-6 flex flex-col gap-3 disabled:opacity-50 shadow-[0_8px_30px_-16px_rgba(0,0,0,0.5)]";return t.jsxs("div",{className:"relative",style:h?void 0:{display:"none"},onDragOver:S=>{var T,L;
121(L=(T=S.dataTransfer)==null?void 0:T.types)!=null&&L.includes("Files")&&(S.preventDefault(),Rt||Pt(!0))},onDragLeave:S=>{S.currentTarget.contains(S.relatedTarget)||Pt(!1)},onDrop:S=>{var L,K;S.preventDefault(),Pt(!1);const T=(K=(L=S.dataTransfer)==null?void 0:L.files)==null?void 0:K[0];T&&na(T)},children:[Rt&&t.jsx("div",{className:"absolute inset-0 z-30 grid place-items-center rounded-2xl border-2 border-dashed border-violet-400 bg-violet-500/10 backdrop-blur-sm pointer-events-none",children:t.jsxs("div",{className:"flex flex-col items-center gap-2 text-violet-100",children:[t.jsx(ho,{className:"w-8 h-8"}),t.jsx("span",{className:"text-sm font-semibold",children:"Drop a video to open it"})]})}),t.jsx("input",{ref:Le,type:"file",accept:"video/*",className:"hidden",onChange:tc}),t.jsx("input",{ref:pt,type:"file",accept:".svproj,.json,application/json",className:"hidden",onChange:S=>{var L;const T=(L=S.target.files)==null?void 0:L[0];S.target.value="",T&&Ds(T)}}),R&&t.jsxs("div",{className:"text-sm text-gray-400 mb-3",children:[t.jsx(fo,{className:"inline animate-spin mr-2"}),R]}),xn&&!R&&t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3 rounded-2xl border border-amber-400/25 bg-amber-500/[0.07] px-4 py-3",children:[t.jsx("span",{className:"w-9 h-9 rounded-xl bg-amber-500/15 text-amber-300 grid place-items-center shrink-0",children:t.jsx(fo,{size:16})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-100",children:"Restore your last session?"}),t.jsxs("div",{className:"text-[12px] text-gray-400 truncate",children:["â",xn.title||"Untitled edit","â, unsaved edits from"," ",xS(xn.ts)," were kept safe in this browser."]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:Do,className:"px-3 py-1.5 rounded-lg bg-amber-500/90 hover:bg-amber-400 text-black text-[12px] font-semibold transition",children:"Restore"}),t.jsx("button",{onClick:Xr,className:"px-3 py-1.5 rounded-lg bg-white/[0.06] border border-white/10 hover:border-white/25 text-[12px] text-gray-300 transition",children:"Discard"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mt-1",children:[t.jsxs("button",{onClick:()=>nt(!0),disabled:!!R,className:x,children:[t.jsx("span",{className:"w-10 h-10 rounded-xl bg-sky-500/15 text-sky-300 grid place-items-center",children:t.jsx(fs,{size:20})}),t.jsx("span",{className:"text-sm font-semibold text-gray-100",children:"New project"}),t.jsx("span",{className:"text-[12px] text-gray-500",children:"Pick a size, TikTok / Reels, YouTube, square and more, set fps and duration, and start on a blank timeline."})]}),t.jsxs("button",{onClick:()=>{var S;return(S=Le.current)==null?void 0:S.click()},disabled:!!R,className:x,children:[t.jsx("span",{className:"w-10 h-10 rounded-xl bg-violet-500/15 text-violet-300 grid place-items-center",children:t.jsx(ho,{size:20})}),t.jsx("span",{className:"text-sm font-semibold text-gray-100",children:"Upload a video"}),t.jsxs("span",{className:"text-[12px] text-gray-500",children:["mp4, mov or webm, up to ",Il," MB. Opens straight on the timeline."]})]}),t.jsxs("button",{onClick:()=>{var S;return(S=pt.current)==null?void 0:S.click()},disabled:!!R,className:x,children:[t.jsx("span",{className:"w-10 h-10 rounded-xl bg-amber-500/15 text-amber-300 grid place-items-center",children:t.jsx(zi,{size:20})}),t.jsx("span",{className:"text-sm font-semibold text-gray-100",children:"Open a project file"}),t.jsx("span",{className:"text-[12px] text-gray-500",children:"Reopen a .svproj you saved earlier and keep editing. The project itself is never stored on our servers."})]}),t.jsxs("button",{onClick:()=>{l&&!l()||qt(!0)},disabled:!!R,className:x,children:[t.jsx("span",{className:"w-10 h-10 rounded-xl bg-emerald-500/15 text-emerald-300 grid place-items-center",children:t.jsx(Js,{size:20})}),t.jsx("span",{className:"text-sm font-semibold text-gray-100",children:"Open a render"}),t.jsx("span",{className:"text-[12px] text-gray-500",children:"Any finished video from your Projects page."})]})]}),E.length>0&&t.jsxs("div",{"data-waiting-exports":!0,role:"status","aria-live":"polite",className:"mt-6 rounded-2xl border border-emerald-400/25 bg-emerald-500/[0.07] px-4 py-3",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-100",children:E.length>1?`${E.length} exports are ready`:"An export is ready"}),t.jsxs("div",{className:"text-[12px] text-gray-400 mt-0.5",children:["Finis
121hed while you were away. Save"," ",E.length>1?"them":"it"," now: we only keep"," ",E.length>1?"them":"it"," for"," ",Ja(d==null?void 0:d.exportHours),"."]}),t.jsx("div",{className:"mt-2.5 flex flex-wrap gap-2",children:E.map(S=>t.jsxs("button",{type:"button","data-waiting-export":S.id,onClick:async()=>{if(await Qn("check-media",{editDoc:{tracks:[{type:"video",clips:[{src:S.resultUrl}]}]}}).then(L=>{var K;return!!((K=L==null?void 0:L.missing)!=null&&K.length)}).catch(()=>!1)){m(L=>L.filter(K=>K.id!==S.id)),me.error("That export isn't here any more. Exports are kept for a short while after they finish.");return}Cr.current(S.resultUrl,S.title)},className:"px-3 py-1.5 rounded-lg bg-emerald-500/90 hover:bg-emerald-400 text-black text-[12px] font-semibold transition inline-flex items-center gap-1.5",children:[t.jsx(go,{size:12})," ",S.title||"Video edit"]},S.id))})]}),t.jsxs("p",{"data-editor-media-note":!0,className:"mt-5 text-[12px] leading-relaxed text-gray-500 max-w-2xl",children:["Your projects and your finished videos live on your computer. A file you bring in is uploaded so we can render it, and kept for"," ",Ja(d==null?void 0:d.uploadHours),"; open a saved project again within that time and everything in it still plays. An export is kept for ",Ja(d==null?void 0:d.exportHours)," in case its download fails, then removed."]}),t.jsx(f1,{mode:"video",open:h&&Xe,onClose:()=>nt(!1),onCreate:tn}),t.jsx(o0,{open:h&&xt,onClose:()=>J(!1)}),ot&&h&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[90] grid place-items-center bg-black/60 backdrop-blur-sm p-4",onMouseDown:()=>qt(!1),onKeyDown:S=>{S.key==="Escape"&&qt(!1)},role:"dialog","aria-modal":"true","aria-label":"Open a generated video",children:t.jsxs("div",{className:"modal-pop-in w-full max-w-2xl max-h-[80vh] rounded-2xl border border-white/10 bg-[#16161d] shadow-2xl flex flex-col",onMouseDown:S=>S.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/10",children:[t.jsxs("h3",{className:"text-sm font-semibold text-white inline-flex items-center gap-2",children:[t.jsx(Js,{})," Open a generated video"]}),t.jsx("button",{type:"button","aria-label":"Close",onClick:()=>qt(!1),className:"text-gray-400 hover:text-white",children:t.jsx(ft,{})})]}),t.jsx("div",{className:"ve-scroll p-3 overflow-y-auto",children:bo==="error"&&!vt.length?t.jsxs("div",{className:"py-12 text-center text-sm text-gray-400",children:["Couldn't load your videos."," ",t.jsx("button",{type:"button",onClick:()=>Or(null),className:"font-semibold underline underline-offset-2",children:"Try again"})]}):bo==="loading"&&!vt.length?t.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"Loading your videosâ¦"}):vt.length?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:vt.slice(0,zn).map(S=>t.jsxs("button",{onClick:()=>io(S),className:"text-left rounded-xl border border-white/10 bg-black/30 hover:border-violet-500/50 overflow-hidden transition",children:[t.jsx("div",{className:"aspect-[9/16] bg-black/50 overflow-hidden grid place-items-center",children:t.jsx(kS,{job:S})}),t.jsxs("div",{className:"p-2",children:[t.jsx("div",{className:"text-[12px] text-gray-200 truncate",children:S.title||"Untitled render"}),t.jsx("div",{className:"text-[10px] text-gray-500 capitalize",children:(S.kind||"video").replace(/_/g," ")})]})]},S.id))}),jr&&zn>=vt.length?t.jsxs("div",{className:"py-6 text-center text-[12px] text-gray-400",children:["Couldn't load more."," ",t.jsx("button",{type:"button",onClick:()=>fr&&Or(fr),className:"font-semibold underline underline-offset-2",children:"Try again"})]}):(zn<vt.length||fr)&&t.jsx("div",{ref:jn,className:"py-6 text-center text-[12px] text-gray-500",children:gn.paused&&zn>=vt.length?t.jsx("button",{type:"button",onClick:()=>gn.resume(()=>fr&&Or(fr)),className:"font-semibold underline underline-offset-2",children:"Load more"}):"Loading moreâ¦"})]}):t.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"No finished videos yet. Make one in UGC Studio or Video Generation first."})})]})}),document.body)]})}const lo=168,bi=46,ka=Math.max(yn(Fn),280),yi=oe<50?5:oe<110?2:1,vn=[];for(let x=0;x<=Fn/We+.001;x+=yi)vn.push(Math.round(x));const es=()=>{var T;const x=(T=ln.current)==null?void 0:T.clientWidth;if(!x)return;const S=Math.max(160,x-lo-28);we(Math.max(16,Math.min(260,S/Fn*We)))},oa=x=>{x.preventDefault();const S=x.clientX,T=x.clientY,L=Ze,K=be=>Ye(Ce=>({...Ce,panX:L.panX+(be.clientX-S),panY:L.panY+(be.clientY-T)})),ee=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",ee),window.removeEventListener("pointercancel",ee)};window.addEventListener("pointermove",K),window.addEventListener("pointerup",ee),window.addEventListener("pointercancel",ee)},co=x=>Ye(S=>{const T=Math.max(.25,Math.min(8,S.zoom*x)),L=T/S.zoom;return{zoom:T,panX:S.panX*L,panY:S.panY*L}}),ko=()=>Ye({zoom:1,panX:0,panY:0}),ms="w-9 h-9 rounded-lg border border-white/10 text-gray-300 hover:bg-white/[0.08] hover:text-white disabled:opacity-30 inline-flex items-center justify-center transition",Br=`${ms} max-sm:w-8 max-sm:h-8`,So="w-8 h-8 max-[359px]:w-7 max-[359px]:h-7 sm:w-9 sm:h-9 rounded-lg border border-white/10 text-gray-300 hover:bg-white/[0.08] hover:text-white disabled:opacity-30 inline-flex items-center justify-center transition",xr="px-2.5 py-1.5 rounded-lg text-xs font-medium text-gray-200 hover:bg-white/[0.08] disabled:opacity-30 inline-flex items-center gap-1.5 transition",vi="w-full mt-1 px-2.5 py-2 rounded-lg bg-white/[0.05] border border-white/10 text-gray-100 text-sm focus:border-violet-500/60 focus:outline-none",Ka={video:"#8b5cf6",caption:"#f59e0b",audio:"#10b981",image:"#38bdf8",shape:"#f472b6"},Sa=x=>x==="audio"?"linear-gradient(180deg, rgba(16,185,129,0.42), rgba(16,185,129,0.2))":x==="caption"?"linear-gradient(180deg, rgba(245,158,11,0.45), rgba(245,158,11,0.22))":x==="image"?"linear-gradient(180deg, rgba(56,189,248,0.45), rgba(56,189,248,0.22))":x==="shape"?"linear-gradient(180deg, rgba(244,114,182,0.45), rgba(244,114,182,0.22))":"linear-gradient(180deg, rgba(139,92,246,0.5), rgba(139,92,246,0.26))";return Un.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[80] flex flex-col bg-[#0b0b0f] text-gray-200 select-none max-lg:overflow-y-auto",style:h?void 0:{display:"none"},onDragOver:x=>{var S,T;(T=(S=x.dataTransfer)==null?void 0:S.types)!=null&&T.includes("Files")&&(x.preventDefault(),x.dataTransfer.dropEffect="copy",Et||Ft(!0))},onDragLeave:x=>{x.currentTarget.contains(x.relatedTarget)||Ft(!1)},onDrop:x=>{var S,T;Ft(!1),(T=(S=x.dataTransfer)==null?void 0:S.types)!=null&&T.includes("Files")&&(x.preventDefault(),ws(x.dataTransfer.files))},children:[t.jsx(o0,{open:xt,onClose:()=>J(!1)}),Et&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-[90] grid place-items-center border-2 border-dashed border-violet-400 bg-vi
121olet-500/10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex flex-col items-center gap-2 text-violet-100",children:[t.jsx(ho,{className:"w-8 h-8"}),t.jsx("span",{className:"text-sm font-semibold",children:"Drop to add a layer"}),t.jsx("span",{className:"text-[11px] text-violet-200/80",children:"Video, image, audio, or SRT and VTT captions"})]})}),t.jsx("style",{children:`.ve-scroll::-webkit-scrollbar{width:10px;height:10px}.ve-scroll::-webkit-scrollbar-thumb{background:rgba(255,255,255,.12);border-radius:8px;border:2px solid transparent;background-clip:content-box}.ve-scroll::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.22);background-clip:content-box}.ve-scroll::-webkit-scrollbar-track{background:transparent} 122 .ve-range{-webkit-appearance:none;appearance:none;height:16px;background:transparent;outline:none;cursor:pointer} 123 .ve-range::-webkit-slider-runnable-track{height:6px;border-radius:9999px;background:linear-gradient(to right,var(--ve-accent,#8b5cf6) calc(var(--ve-pct,0)*1%),rgba(255,255,255,.10) calc(var(--ve-pct,0)*1%))} 124 .ve-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:15px;height:15px;border-radius:9999px;background:#fff;border:2px solid var(--ve-accent,#8b5cf6);box-shadow:0 1px 4px rgba(0,0,0,.55);margin-top:-4.5px;cursor:grab} 125 .ve-range:active::-webkit-slider-thumb{cursor:grabbing;transform:scale(1.15)} 126 .ve-range::-moz-range-track{height:6px;border-radius:9999px;background:rgba(255,255,255,.10)} 127 .ve-range::-moz-range-progress{height:6px;border-radius:9999px;background:var(--ve-accent,#8b5cf6)} 128 .ve-range::-moz-range-thumb{width:15px;height:15px;border-radius:9999px;background:#fff;border:2px solid var(--ve-accent,#8b5cf6);box-shadow:0 1px 4px rgba(0,0,0,.55);cursor:grab} 129 .ve-select option{background:#16161d;color:#e5e7eb}`}),t.jsxs("div",{className:"flex items-center justify-between gap-2 sm:gap-3 px-3 py-2.5 bg-[#16161d] border-b border-white/10 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0",children:[t.jsxs("button",{onClick:()=>{D==="dirty"&&!window.confirm("Close this project? Your unsaved changes will be lost. To keep your work, click Cancel and use Save Project (.svproj).")||(Xr(),b(null))},className:"px-2 sm:px-2.5 py-1.5 rounded-lg text-sm text-gray-300 hover:bg-white/[0.06] inline-flex items-center gap-1.5",title:"Close this project and return to the start screen",children:[t.jsx(Lb,{})," ",t.jsx("span",{className:"hidden sm:inline",children:"Close"})]}),t.jsx("div",{className:"hidden sm:block w-px h-5 bg-white/10"}),t.jsx("h2",{className:"min-w-0 text-sm font-semibold text-gray-100 truncate max-w-[110px] sm:max-w-[240px] max-[359px]:hidden",children:p.title}),Ie===null?t.jsxs("button",{type:"button",onClick:()=>ht(String(Math.round(Fn/We*10)/10)),className:"text-[11px] text-gray-500 hover:text-gray-300 whitespace-nowrap hidden md:inline rounded px-1 -mx-1 hover:bg-white/[0.06]",title:"Composition length. Click to set how long the edit is. Clips that run past it make it longer, so this is the shortest it can be.",children:[ze.width,"Ã",ze.height," · ",Ln,"s · ",We,"fps"]}):t.jsxs("span",{className:"text-[11px] text-gray-400 whitespace-nowrap hidden md:inline-flex items-center gap-1",children:["Length",t.jsx("input",{autoFocus:!0,t
129ype:"number",min:"0.1",step:"0.1",value:Ie,onChange:x=>ht(x.target.value),onKeyDown:x=>{x.stopPropagation(),x.key==="Enter"&&vs(Ie),x.key==="Escape"&&ht(null)},onBlur:()=>vs(Ie),className:"w-16 bg-[#0f1014] border border-white/15 rounded px-1.5 py-0.5 text-[11px] text-gray-100"}),"s"]}),t.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1.5 text-[11px] text-gray-400 whitespace-nowrap",title:`This project lives only in your browser session: the project itself is never stored on our servers. Use Save Project to download a .svproj file you can reopen later. The clips it uses are kept on our side for ${Ja(d==null?void 0:d.uploadHours)} and then removed.`,"aria-label":D==="dirty"?"Unsaved changes":"Session only",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${D==="dirty"?"bg-amber-400":"bg-emerald-400"}`}),t.jsx("span",{className:"hidden lg:inline",children:D==="dirty"?"Unsaved changes":"Session only"})]})]}),t.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5",children:[t.jsx("button",{onClick:()=>rr(!0),className:`${ms} hidden sm:inline-flex`,title:"Keyboard shortcuts",children:"?"}),t.jsx("div",{className:"hidden sm:block w-px h-6 bg-white/10 mx-1"}),t.jsx("button",{onClick:_o,disabled:!V.past.length,className:Br,title:"Undo (âZ)",children:t.jsx(Pl,{})}),t.jsx("button",{onClick:Tr,disabled:!V.future.length,className:Br,title:"Redo (â§âZ)",children:t.jsx(Tc,{})}),t.jsx("div",{className:"w-px h-6 bg-white/10 mx-0.5 sm:mx-1"}),t.jsx("button",{onClick:Dt,className:Br,title:"Save Project to a file (.svproj), reopen later to keep editing (the project itself is never stored on our servers)",children:t.jsx(ni,{})}),t.jsx("button",{onClick:()=>{var x;return(x=pt.current)==null?void 0:x.click()},className:Br,title:"Open a StudioE project file (.svproj)",children:t.jsx(zi,{})}),t.jsx("input",{ref:pt,type:"file",accept:".svproj,.json,application/json",className:"hidden",onChange:x=>{var T;const S=(T=x.target.files)==null?void 0:T[0];x.target.value="",S&&Ds(S)}}),t.jsx("div",{className:"w-px h-6 bg-white/10 mx-0.5 sm:mx-1"}),t.jsx("button",{onClick:Nn,disabled:!!R||Sr,className:"px-3 sm:px-4 py-2 rounded-lg bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-white text-sm font-semibold inline-flex items-center gap-2 shadow-lg shadow-violet-900/30",children:Sr?t.jsxs(t.Fragment,{children:[t.jsx(fo,{className:"animate-spin"})," ",t.jsx("span",{className:"hidden sm:inline",children:"Renderingâ¦"})]}):t.jsxs(t.Fragment,{children:[t.jsx(Js,{})," ",t.jsx("span",{className:"hidden sm:inline",children:"Export"})]})})]})]}),t.jsxs("div",{className:"flex flex-col lg:flex-row flex-1 min-h-0 max-lg:min-h-fit bg-[#0b0b0f]",children:[t.jsxs("div",{className:"flex flex-row lg:flex-col items-center shrink-0 w-full lg:w-[58px] bg-[#101016] border-b lg:border-b-0 lg:border-r border-white/10 px-2 lg:px-0 py-2 lg:py-3 gap-1 lg:gap-1.5 overflow-x-auto lg:overflow-visible",children:[t.jsx(Bo,{icon:t.jsx(Wc,{}),label:"Layers",active:un==="layers",onClick:()=>jt(x=>x==="layers"?null:"layers")}),t.jsx("div",{className:"shrink-0 w-px h-7 mx-1 lg:w-7 lg:h-px lg:mx-0 lg:my-0.5 bg-white/10"}),t.jsx(Bo,{icon:t.jsx(Ra,{}),label:"Caption",onClick:so}),t.jsx(Bo,{icon:t.jsx(Tl,{}),label:"SRT",onClick:()=>{var x;return(x=_t.current)==null?void 0:x.click()}}),t.jsx("input",{ref:_t,type:"file",accept:".srt,.vtt,text/vtt,application/x-subrip",className:"hidden",onChange:Us}),t.jsx(Bo,{icon:t.jsx(oi,{}),label:"Audio",onClick:()=>{var x;return(x=xe.current)==null?void 0:x.click()}}),t.jsx(Bo,{icon:t.jsx($s,{}),label:"Upload Video",lines:["Upload","Video"],onClick:()=>{var x;return(x=et.current)==null?void 0:x.click()}}),t.jsx(Bo,{icon:t.jsx(Zs,{}),label:"Upload Image",lines:["Upload","Image"],onClick:()=>{var x;return(x=ct.current)==null?void 0:x.click()}}),t.jsx(Bo,{icon:t.jsx(Fa,{}),label:"Shape",onClick:$e}),t.jsx("div",{className:"shrink-0 w-px h-7 mx-1 lg:w-7 lg:h-px lg:mx-0 lg:my-0.5 bg-white/10"}),t.jsx(Bo,{icon:t.jsx(Rl,{}),label:"Snap",active:Re,onClick:()=>le(x=>!x)}),t.jsx(Bo,{icon:t.jsx(Ts,{}),label:"Fit",onClick:es}),t.jsx(Bo,{icon:t.jsx(h0,{}),label:"Keys",active:xt,onClick:()=>J(x=>!x)})]}),un==="layers"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"lg:hidden fixed inset-0 z-[67] bg-black/40",onClick:()=>jt(null),"aria-hidden":"true"}),t.jsxs("div",{className:"ve-scroll bg-[#0e0e14] overflow-y-auto fixed inset-x-0 bottom-0 z-[68] max-h-[72vh] border-t border-white/10 rounded-t-2xl shadow-2xl lg:static lg:inset-auto lg:z-auto lg:w-[208px] lg:max-h-none lg:min-h-0 lg:shrink-0 lg:border-t-0 lg:border-r lg:rounded-none lg:shadow-none",children:[t.jsx("div",{className:"lg:hidden flex justify-center pt-2 pb-0.5 cursor-pointer",onClick:()=>jt(null),children:t.jsx("div",{className:"w-10 h-1 rounded-full bg-white/25"})}),t.jsxs("div",{className:"px-3 py-2.5 border-b border-white/10 sticky top-0 bg-[#0e0e14] z-10 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold",children:"Layers"}),t.jsx("button",{type:"button",onClick:()=>jt(null),className:"lg:hidden px-2.5 py-1 rounded-md text-[11px] font-medium text-violet-200 bg-vi
129olet-500/15 hover:bg-violet-500/25",children:"Done"})]}),t.jsx("div",{className:"p-2 space-y-3",children:[...ze.tracks||[]].reverse().map(x=>t.jsxs("div",{"data-trackid":x.id,className:`rounded-md transition ${hr===x.id&&Hn.current&&Hn.current!==x.id?"ring-1 ring-violet-400/70 bg-violet-500/[0.06]":""}`,children:[t.jsxs("div",{className:"flex items-center justify-between px-1 mb-1",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium text-gray-300 capitalize",children:[t.jsx(Fs,{size:12,title:"Drag to reorder layer (front â back)",className:"text-gray-600 hover:text-gray-300 shrink-0 cursor-grab active:cursor-grabbing touch-none",onPointerDown:Qr(x.id)}),t.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:Ka[x.type]||"#888"}}),x.name||x.type]}),t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx("button",{onClick:()=>ra(x.id),title:x.hidden?"Show":"Hide",className:"p-1 rounded text-gray-500 hover:text-gray-200",children:x.hidden?t.jsx(Wp,{size:12}):t.jsx(_u,{size:12})}),(x.type==="audio"||x.type==="video")&&t.jsx("button",{onClick:()=>No(x.id),title:Zr(x)?"Unmute audio":"Mute audio",className:`p-1 rounded ${Zr(x)?"text-gray-600":"text-emerald-300"}`,children:Zr(x)?t.jsx(Gd,{size:12}):t.jsx(Yp,{size:12})}),t.jsx("button",{onClick:()=>ja(x.id),title:"Delete layer","aria-label":`Delete layer ${x.name||x.type}`,className:"p-1 rounded text-gray-500 hover:text-red-400 hover:bg-red-500/10",children:t.jsx(ss,{size:12})})]})]}),t.jsxs("div",{className:"space-y-0.5",children:[(x.clips||[]).map(S=>{const T=H&&H.trackId===x.id&&H.clipId===S.id,L=S.text||S.sceneTitle||S.name||x.type;return t.jsx("button",{onClick:()=>Wn(x.id,S.id,!1),className:`w-full text-left px-2 py-1.5 rounded-md text-[11px] truncate ${T?"bg-violet-600/25 text-violet-100 ring-1 ring-violet-500/40":"text-gray-400 hover:bg-white/[0.05]"}`,children:L},S.id)}),!(x.clips||[]).length&&t.jsx("div",{className:"px-2 py-1 text-[10px] text-gray-600",children:"Empty"})]})]},x.id))})]})]}),t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-[max(40vh,250px)] lg:min-h-0",children:[t.jsxs("div",{ref:Ht,className:`relative flex-1 grid place-items-center min-h-0 overflow-hidden p-5 ${at?"cursor-grab active:cursor-grabbing":""}`,style:{background:"radial-gradient(120% 100% at 50% 0%, #1b1b24 0%, #0c0c11 72%)"},onPointerDown:x=>{x.button===1&&oa(x)},children:[t.jsxs("div",{className:"relative rounded-lg overflow-hidden ring-1 ring-white/10 shadow-[0_24px_70px_-12px_rgba(0,0,0,0.75)]",style:{aspectRatio:`${ze.width} / ${ze.height}`,height:"100%",maxWidth:"100%",transform:`translate(${Ze.panX}px, ${Ze.panY}px) scale(${Ze.zoom})`,willChange:"transform"},children:[t.jsx("div",{style:{position:"absolute",top:0,left:0,width:Ae<1?`${Ae*100}%`:"100%",height:Ae<1?`${Ae*100}%`:"100%",transform:Ae<1?`scale(${1/Ae})`:void 0,transformOrigin:"top left",filter:Ae<1?`blur(${(1-Ae)*1.6}px)`:void 0},children:Lo}),t.jsx(jS,{doc:ze,playhead:ie,sel:H,onSelect:x=>x?Wn(x.trackId,x.clipId,!1):Vr(),snapshot:Se,live:is,discard:ta})]}),at&&t.jsx("div",{className:"absolute inset-0 z-30",onPointerDown:oa}),t.jsxs("div",{className:"absolute bottom-2.5 left-1/2 -translate-x-1/2 z-40 flex items-center gap-0.5 bg-[#16161d]/90 border border-white/10 rounded-xl px-1.5 py-1 backdrop-blur shadow-lg",children:[t.jsx("button",{onClick:()=>ut(x=>!x),title:"Hand tool, drag to pan (or middle-drag / scroll to zoom)",className:`w-7 h-7 rounded-lg inline-flex items-center justify-center transition ${at?"bg-violet-600/30 text-violet-200 ring-1 ring-violet-500/40":"text-gray-300 hover:bg-white/[0.08]"}`,children:t.jsx(Fs,{size:13})}),t.jsx("div",{className:"w-px h-5 bg-white/10 mx-0.5"}),t.jsx("button",{onClick:()=>co(1/1.25),title:"Zoom out",className:"w-7 h-7 rounded-lg text-gray-300 hover:bg-white/[0.08] inline-flex items-center justify-center",children:t.jsx(Gp,{size:14})}),t.jsxs("button",{onClick:ko,title:"Reset to fit (100%)",className:"px-1.5 h-7 rounded-lg text-[11px] font-medium text-gray-200 hover:bg-white/[0.08] tabular-nums min-w-[42px] text-center",children:[Math.round(Ze.zoom*100),"%"]}),t.jsx("button",{onClick:()=>co(1.25),title:"Zoom in",className:"w-7 h-7 rounded-lg text-gray-300 hover:bg-white/[0.08] inline-flex items-center justify-center",children:t.jsx(Yc,{size:14})}),t.jsx("button",{onClick:ko,title:"Fit",className:"w-7 h-7 rounded-lg text-gray-300 hover:bg-white/[0.08] inline-flex items-center justify-center",children:t.jsx(Ts,{size:13})})]})]}),t.jsxs("div",{className:"px-3 sm:px-4 py-2.5 bg-[#101016] border-t border-white/10 flex items-center justify-between gap-2 max-[359px]:gap-1.5 shrink-0",children:[t.jsxs("div",{className:"font-mono text-xs text-violet-300 tabular-nums sm:w-24 whitespace-nowrap",children:[ds(ie)," ",t.jsxs("span",{className:"hidden sm:inline text-gray-600",children:["/ ",Ln,"s"]})]}),t.jsxs("div",{className:"flex items-center gap-1 max-[359px]:gap-0.5 sm:gap-1.5",children:[t.jsx("button",{onClick:()=>On(0),className:So,title:"Jump to start",children:t.jsx(Ob,{size:15})}),t.jsx("button",{onClick:()=>ys(-1),className:So,title:"Back 1 frame (â)",children:t.jsx(Du,{size:17})}),t.jsx("button",{onClick:no,className:"w-10 h-10 max-[359px]:w-9 max-[359px]:h-9 sm:w-11 sm:h-11 rounded-full bg-white text-black hover:bg-gray-200 inline-flex items-center justify-center shadow",title:"Play / Pause (Space)",children:Ne?t.jsx(Vb,{size:18}):t.jsx(Ta,{size:18,className:"ml-0.5"})}),t.jsx("button",{onClick:()=>ys(1),className:So,title:"Forward 1 frame (â)",children:t.jsx(Da,{size:17})}),t.jsx("button",{onClick:()=>On(Fn-1),className:So,title:"Jump to end",children:t.jsx(Ub,{size:15})})]}),t.jsxs("div",{className:"sm:w-24 flex flex-col items-end justify-center gap-0.5",children:[t.jsx("span",{className:"hidden sm:block text-[8px] uppercase tracking-wider text-gray-500 leading-none whitespace-nowrap",children:"Preview quality"}),t.jsx("div",{className:"relative",title:"Preview quality, export always renders at full resolution",children:t.jsx(Sn,{options:[{value:"1",label:"100%"},{value:"0.75",label:"75%"},{value:"0.5",label:"50%"},{value:"0.25",label:"25%"}],selectedValue:String(Ae),onSelect:x=>De(+x),usePortal:!0,className:"w-[68px] sm:w-24",buttonClassName:"!bg-white/[0.05] !border-white/10 !rounded-lg !px-2.5 max-sm:!px-1 !py-1 !text-[11px] !font-medium !text-gray-300"})})]})]})]}),Te&&!mr&&t.jsx("div",{className:"lg:hidden fixed inset-0 z-[65] bg-black/40",onClick:Vr,"aria-hidden":"true"}),t.jsxs("div",{className:`ve-scroll bg-[#0e0e14] overflow-y-auto lg:static lg:inset-auto lg:w-[330px] lg:max-h-none lg:min-h-0 lg:shrink-0 lg:border-l lg:border-t-0 lg:border-white/10 lg:rounded-none lg:shadow-none lg:z-auto lg:block ${Te&&!mr?"block fixed inset-x-0 bottom-0 max-h-[72vh] z-[70] border-t border-white/10 rounded-t-2xl shadow-2xl":"hidden"}`,children:[Te&&t.jsx("div",{className:"lg:hidden flex justify-center pt-2 pb-0.5 cursor-pointer",onClick:Vr,children:t.jsx("div",{className:"w-10 h-1 rounded-full bg-white/25"})}),Te?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"sticky top-0 bg-[#0e0e14] z-10",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-white/10",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 text-xs uppercase tracking-wider font-semibold",style:{color:Ka[Yn]||"#aaa"},children:[Yn==="video"?t.jsx(Js,{size:13}):Yn==="caption"?t.jsx(Ra,{size:13}):Yn==="image"?t.jsx(Zs,{size:13}):Yn==="shape"?t.jsx(Fa,{size:13}):t.jsx(oi,{size:13}),Yn==="video"?"Scene":Yn==="caption"?"Caption":Yn==="image"?"Image":Yn==="shape"?"Shape":"Audio"]}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx("button",{onClick:Vr,className:"lg:hidden mr-1 px-2.5 py-1 rounded-md text-[11px] font-medium text-violet-200 bg-vi
129olet-500/15 hover:bg-violet-500/25",children:"Done"}),Yn!=="audio"&&t.jsx("button",{onClick:U,title:"Reset position (recenter)",className:"p-1.5 rounded-md text-gray-400 hover:text-gray-100 hover:bg-white/[0.06] transition",children:t.jsx(qp,{size:13})}),t.jsx("button",{onClick:Hs,title:"Duplicate",className:"p-1.5 rounded-md text-gray-400 hover:text-gray-100 hover:bg-white/[0.06] transition",children:t.jsx(xa,{size:13})}),t.jsx("button",{onClick:Vo,title:"Split at playhead",className:"p-1.5 rounded-md text-gray-400 hover:text-gray-100 hover:bg-white/[0.06] transition",children:t.jsx(Di,{size:13})}),t.jsx("button",{onClick:js,title:"Delete",className:"p-1.5 rounded-md text-gray-400 hover:text-red-400 hover:bg-red-500/10 transition",children:t.jsx(ss,{size:13})})]})]}),Rn&&t.jsxs("div",{"data-ve-picked-key-bar":!0,className:"px-4 py-2 border-b border-white/10 bg-amber-300/[0.06] space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-[11px] text-amber-200 inline-flex items-center gap-1.5 min-w-0",children:[t.jsx("span",{"aria-hidden":"true",className:"text-amber-300",children:"â"}),t.jsxs("span",{className:"truncate",children:["Keyframe at"," ",ds((Te.fromFrame||0)+Rn.f)]})]}),t.jsxs("button",{type:"button",onClick:Qs,title:"Delete this keyframe (Delete)",className:"shrink-0 inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-amber-100 bg-amber-300/10 hover:bg-red-500/15 hover:text-red-300 transition",children:[t.jsx(ss,{size:11})," Delete keyframe"]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-[11px] text-gray-400 min-w-0",children:[t.jsx("span",{className:"block truncate",children:"Motion to next keyframe"}),t.jsx("span",{"data-ve-ease-hint":!0,className:"block truncate text-[10px] text-gray-500",children:sa?us==="mixed"?"Each property eases its own way here":(Ar=wi.find(x=>x.id===us))==null?void 0:Ar.hint:"The last keyframe: add one after it to shape the motion"})]}),t.jsx(Sn,{options:wi.map(x=>({value:x.id,label:x.label,icon:t.jsx(Rc,{id:x.id})})),selectedValue:us||"linear",buttonContent:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[us!=="mixed"&&t.jsx(Rc,{id:us||"linear"}),us==="mixed"?"Mixed":((Wa=wi.find(x=>x.id===us))==null?void 0:Wa.label)||"Linear"]}),onSelect:eo,disabled:!sa,usePortal:!0,className:"w-[136px] shrink-0",buttonClassName:"!bg-white/[0.05] !border-white/10 !rounded-lg !px-2 !py-1 !text-[11px] !font-medium !text-gray-200"})]})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[Yn==="caption"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("span",{className:"text-[11px] text-gray-400 inline-flex items-center gap-1.5 mb-1.5",children:[t.jsx(Ra,{size:12})," Text"]}),t.jsx("textarea",{value:Te.text||"",onFocus:Se,onChange:x=>gt({text:x.target.value},!0),rows:2,className:vi,placeholder:"Caption text"})]}),t.jsxs(qa,{label:"Font",icon:t.jsx(Ra,{size:12}),value:Te.font||"Inter, Helvetica, Arial, sans-serif",onChange:x=>gt({font:x.target.value}),children:[t.jsx("option",{value:"Inter, Helvetica, Arial, sans-serif",children:"Inter, Sans"}),t.jsx("option",{value:"Georgia, 'Times New Roman', serif",children:"Georgia, Serif"}),t.jsx("option",{value:"'Courier New', monospace",children:"Courier, Mono"}),t.jsx("option",{value:"Impact, Haettenschweiler, sans-serif",children:"Impact, Display"}),t.jsx("option",{value:"'Arial Black', Gadget, sans-serif",children:"Arial Black"})]}),t.jsx(xl,{label:"Weight",icon:t.jsx(zb,{size:12}),value:String(Te.weight||800),onChange:x=>gt({weight:+x}),options:[{value:"400",label:"Regular"},{value:"600",label:"Semibold"},{value:"800",label:"Bold"}]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(xl,{label:"Align",icon:t.jsx(Xp,{size:12}),value:Te.align||"center",onChange:x=>gt({align:x}),options:[{value:"left",icon:t.jsx(Bb,{size:13}),title:"Left"},{value:"center",icon:t.jsx(Xp,{size:13}),title:"Center"},{value:"right",icon:t.jsx(Hb,{size:13}),title:"Right"}]}),t.jsx(xl,{label:"Style",icon:t.jsx(Jp,{size:12}),value:Te.italic?"italic":"normal",onChange:x=>gt({italic:x==="italic"}),options:[{value:"normal",label:"Aa"},{value:"italic",icon:t.jsx(Jp,{size:13}),title:"Italic"}]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Size",keyState:fe("size"),onToggleKey:()=>ge("size"),icon:t.jsx(Ra,{size:11}),value:Q("size"),suffix:"px",min:24,max:160,onStart:Se,onChange:x=>je("size",+x.target.value,void 0,!0)}),t.jsx(a0,{label:"Colour",icon:t.jsx(Li,{size:11}),value:Te.color||"#ffffff",onStart:Se,onChange:x=>gt({color:x.target.value},!0)})]}
129),t.jsx(xl,{label:"Background",icon:t.jsx(Fa,{size:12}),value:Te.bg||"",onChange:x=>gt({bg:x}),options:[{value:"",label:"None"},{value:"rgba(0,0,0,0.6)",label:"Dark"},{value:"rgba(255,255,255,0.92)",label:"Light"},{value:"rgba(139,92,246,0.9)",label:"Brand"}]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Position X",keyState:fe("x"),onToggleKey:()=>ge("x"),icon:t.jsx(Fs,{size:11}),value:Q("x"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("x",+x.target.value,50,!0)}),t.jsx(Bt,{label:"Position Y",keyState:fe("y"),onToggleKey:()=>ge("y"),icon:t.jsx(Fs,{size:11}),value:Q("y"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("y",+x.target.value,84,!0)}),t.jsx(Bt,{label:"Opacity",keyState:fe("opacity"),onToggleKey:()=>ge("opacity"),icon:t.jsx(Mo,{size:11}),value:Math.round(Q("opacity")),suffix:"%",min:0,max:100,onStart:Se,onChange:x=>je("opacity",+x.target.value,100,!0)})]}),t.jsxs(qa,{label:"Animation",icon:t.jsx(Mo,{size:12}),value:Te.anim||"fade",onChange:x=>gt({anim:x.target.value}),children:[t.jsx("option",{value:"none",children:"None"}),t.jsx("option",{value:"fade",children:"Fade"}),t.jsx("option",{value:"pop",children:"Pop"}),t.jsx("option",{value:"slide",children:"Slide up"}),t.jsx("option",{value:"rise",children:"Rise"})]})]}),Yn==="audio"&&t.jsxs(t.Fragment,{children:[t.jsx(Bt,{label:"Volume",keyState:fe("volume"),onToggleKey:()=>ge("volume"),icon:t.jsx(_i,{size:11}),value:Math.round(Q("volume")*100),suffix:"%",min:0,max:100,accent:"#10b981",onStart:Se,onChange:x=>je("volume",+x.target.value/100,1,!0)}),t.jsx(bS,{label:"Loop to fill clip",icon:t.jsx(fo,{size:12}),checked:!!Te.loop,onChange:oo}),t.jsxs("button",{onClick:()=>{var x;qn.current=H,(x=xe.current)==null||x.click()},className:"w-full inline-flex items-center justify-center gap-2 px-2.5 py-2 rounded-lg bg-white/[0.05] border border-white/10 hover:border-white/25 text-[12px] text-gray-200 transition",children:[t.jsx(ho,{size:13})," Replace audio"]}),t.jsxs("div",{className:"text-[11px] text-gray-500 break-all inline-flex items-start gap-1.5",children:[t.jsx(oi,{size:11,className:"mt-0.5 shrink-0"}),t.jsx("span",{children:Te.name||Te.src})]})]}),Yn==="video"&&t.jsxs(t.Fragment,{children:[Te.sceneTitle&&t.jsx("div",{className:"text-sm text-gray-200 font-medium break-all",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},title:Te.sceneTitle,children:Te.sceneTitle}),t.jsxs(t.Fragment,{children:[Te.w!=null&&t.jsxs("div",{className:"text-[11px] text-violet-300/80 inline-flex items-center gap-1.5",children:[t.jsx(Wc,{size:11})," PiP layer, drag & resize it on the preview"]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Size",keyState:fe("w"),onToggleKey:()=>ge("w"),icon:t.jsx(Ts,{size:11}),value:Math.round(Q("w")),suffix:"%",min:8,max:100,onStart:Se,onChange:x=>je("w",+x.target.value,void 0,!0)}),t.jsx(Bt,{label:"Height",keyState:fe("h"),onToggleKey:()=>ge("h",Q("w")),icon:t.jsx(Ts,{size:11}),value:Math.round(Q("h",Q("w"))),suffix:"%",min:8,max:100,onStart:Se,onChange:x=>je("h",+x.target.value,void 0,!0)}),t.jsx(Bt,{label:"Position X",keyState:fe("x"),onToggleKey:()=>ge("x"),icon:t.jsx(Fs,{size:11}),value:Q("x"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("x",+x.target.value,50,!0)}),t.jsx(Bt,{label:"Position Y",keyState:fe("y"),onToggleKey:()=>ge("y"),icon:t.jsx(Fs,{size:11}),value:Q("y"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("y",+x.target.value,84,!0)}),t.jsx(Bt,{label:"Opacity",keyState:fe("opacity"),onToggleKey:()=>ge("opacity"),icon:t.jsx(Mo,{size:11}),value:Math.round(Q("opacity")),suffix:"%",min:0,max:100,onStart:Se,onChange:x=>je("opacity",+x.target.value,100,!0)})]}),t.jsx(Bt,{label:"Round corners",keyState:fe("radius"),onToggleKey:()=>ge("radius"),icon:t.jsx(Fa,{size:11}),value:Q("radius"),suffix:"px",min:0,max:120,onStart:Se,onChange:x=>je("radius",+x.target.value,void 0,!0)})]}),t.jsx(xl,{label:"Fit",icon:t.jsx(Ts,{size:12}),value:Te.fit||"cover",onChange:x=>gt({fit:x}),options:[{value:"cover",icon:t.jsx(Ts,{size:13}),label:"Fill"},{value:"contain",icon:t.jsx(f0,{size:13}),label:"Fit"}]}),t.jsxs(qa,{label:"Transition in",icon:t.jsx(Mo,{size:12}
129),value:Te.anim||"none",onChange:x=>gt({anim:x.target.value}),children:[t.jsx("option",{value:"none",children:"None"}),t.jsx("option",{value:"fade",children:"Fade"}),t.jsx("option",{value:"slide",children:"Slide"}),t.jsx("option",{value:"zoom",children:"Zoom"}),t.jsx("option",{value:"wipe",children:"Wipe"}),t.jsx("option",{value:"blur",children:"Blur"})]}),t.jsx(Bt,{label:"Cross-dissolve (from previous)",icon:t.jsx(Mo,{size:11}),value:Math.round(Te.transitionIn||0),suffix:"f",min:0,max:45,onStart:Se,onChange:x=>Oe(+x.target.value)}),t.jsxs(qa,{label:"Ken Burns (motion)",icon:t.jsx(Fs,{size:12}),value:Te.kenBurns||"none",onChange:x=>gt({kenBurns:x.target.value,kbFrom:void 0,kbTotal:void 0}),children:[t.jsx("option",{value:"none",children:"None"}),t.jsx("option",{value:"in",children:"Zoom in"}),t.jsx("option",{value:"out",children:"Zoom out"}),t.jsx("option",{value:"left",children:"Pan left"}),t.jsx("option",{value:"right",children:"Pan right"}),t.jsx("option",{value:"up",children:"Pan up"}),t.jsx("option",{value:"down",children:"Pan down"})]}),t.jsx(Bt,{label:"Handheld camera",keyState:fe("handheld"),onToggleKey:()=>ge("handheld"),icon:t.jsx($s,{size:11}),value:Math.round(Q("handheld")*100),suffix:"%",min:0,max:100,onStart:Se,onChange:x=>je("handheld",+x.target.value/100,void 0,!0)}),t.jsx(Bt,{label:"Speed",icon:t.jsx(Ri,{size:11}),value:Math.round((Te.speed??1)*100),suffix:"%",min:25,max:300,onStart:()=>{rt.current=Te,Se()},onChange:x=>gt(S=>{var Ce;const T=((Ce=rt.current)==null?void 0:Ce.id)===S.id?rt.current:S,L=Math.max(.25,+x.target.value/100),K=Math.max(.1,Number(T.speed)||1),ee=Math.max(2,Math.round((T.durationInFrames||1)*(K/L))),be=nc({...T,speed:L},ee);return{speed:L,durationInFrames:be,keys:Iy(T,K/L).keys,...T.kbTotal!=null?{kbFrom:Math.round((Number(T.kbFrom)||0)*(K/L)),kbTotal:Math.max(1,Math.round(Number(T.kbTotal)*(K/L)))}:{}}},!0)}),t.jsxs("div",{className:"space-y-2 pt-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Audio"}),t.jsx("button",{type:"button",onClick:()=>No(H.trackId),className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded ${zr&&Zr(zr)?"text-gray-500 hover:text-gray-300":"text-emerald-300 hover:text-emerald-200"}`,title:zr&&Zr(zr)?"Unmute this layer":"Mute this layer",children:zr&&Zr(zr)?t.jsxs(t.Fragment,{children:[t.jsx(Gd,{size:11})," Muted"]}):t.jsxs(t.Fragment,{children:[t.jsx(_i,{size:11})," On"]})})]}),t.jsx(Bt,{label:"Volume",keyState:fe("volume"),onToggleKey:()=>ge("volume"),icon:t.jsx(_i,{size:11}),value:Math.round(Q("volume")*100),suffix:"%",min:0,max:100,accent:"#10b981",onStart:Se,onChange:x=>je("volume",+x.target.value/100,1,!0)})]}),t.jsxs("div",{className:"space-y-3 pt-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Colour"}),(Te.brightness!=null||Te.contrast!=null||Te.saturate!=null)&&(Te.brightness!==100||Te.contrast!==100||Te.saturate!==100)&&t.jsx("button",{type:"button",onClick:()=>gt({brightness:100,contrast:100,saturate:100}),className:"text-[10px] text-gray-500 hover:text-violet-300",children:"Reset"})]}),t.jsx(Bt,{label:"Brightness",keyState:fe("brightness"),onToggleKey:()=>ge("brightness"),icon:t.jsx(Zp,{size:11}),value:Q("brightness"),suffix:"%",min:0,max:200,onStart:Se,onChange:x=>je("brightness",+x.target.value,void 0,!0)}),t.jsx(Bt,{label:"Contrast",keyState:fe("contrast"),onToggleKey:()=>ge("contrast"),icon:t.jsx(Mo,{size:11}),value:Q("contrast"),suffix:"%",min:0,max:200,onStart:Se,onChange:x=>je("contrast",+x.target.value,void 0,!0)}),t.jsx(Bt,{label:"Saturation",keyState:fe("saturate"),onToggleKey:()=>ge("saturate"),icon:t.jsx(Li,{size:11}),value:Q("saturate"),suffix:"%",min:0,max:200,onStart:Se,onChange:x=>je("saturate",+x.target.value,void 0,!0)})]})]}),Yn==="image"&&t.jsxs(t.Fragment,{children:[t.jsx(Bt,{label:"Size",keyState:fe("w"),onToggleKey:()=>ge("w",Te.width??38),icon:t.jsx(Ts,{size:11}),value:Math.round(Q("w",Te.width??38)),suffix:"%",min:5,max:100,onStart:Se,onChange:x=>je("w",+x.target.value,void 0,!0)}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Position X",keyState:fe("x"),onToggleKey:()=>ge("x"),icon:t.jsx(Fs,{size:11}),value:Q("x"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("x",+x.target.value,50,!0)}),t.jsx(Bt,{label:"Position Y",keyState:fe("y"),onToggleKey:()=>ge("y"),icon:t.jsx(Fs,{size:11}),value:Q("y"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("y",+x.target.value,84,!0)}),t.jsx(Bt,{label:"Opacity",keyState:fe("opacity"),onToggleKey:()=>ge("opacity"),icon:t.jsx(Mo,{size:11}),value:Math.round(Q("opacity")),suffix:"%",min:0,max:100,onStart:Se,onChange:x=>je("opacity",+x.target.value,100,!0)})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Rotate",keyState:fe("rotation"),onToggleKey:()=>ge("rotation"),icon:t.jsx(Tc,{size:11}),value:Q("rotation"),suffix:"°",min:-180,max:180,onStart:Se,onChange:x=>je("rotation",+x.target.value,void 0,!0)}),t.jsx(Bt,{label:"Round",keyState:fe("radius"),onToggleKey:()=>ge("radius"),icon:t.jsx(Fa,{size:11}),value:Q("radius"),suffix:"px",min:0,max:140,onStart:Se,onChange:x=>je("radius",+x.target.value,void 0,!0)})]}),t.jsxs(qa,{label:"Transition in",icon:t.jsx(Mo,{size:12}),value:Te.anim||"fade",onChange:x=>gt({anim:x.target.value}),children:[t.jsx("option",{value:"none",children:"None"}),t.jsx("option",{value:"fade",children:"Fade"}),t.jsx("option",{value:"slide",children:"Slide"}),t.jsx("option",{value:"zoom",children:"Zoom"}),t.jsx("option",{value:"blur",children:"Blur"})]}),t.jsx(Bt,{label:"Cross-dissolve (from previous)",icon:t.jsx(Mo,{size:11}),value:Math.round(Te.transitionIn||0),suffix:"f",min:0,max:45,onStart:Se,onChange:x=>Oe(+x.target.value)}),t.jsxs(qa,{label:"Ken Burns (motion)",icon:t.jsx(Fs,{size:12}),value:Te.kenBurns||"none",onChange:x=>gt({kenBurns:x.target.value,kbFrom:void 0,kbTotal:void 0}),children:[t.jsx("option",{value:"none",children:"None"}),t.jsx("option",{value:"in",children:"Zoom in"}),t.jsx("option",{value:"out",children:"Zoom out"}),t.jsx("option",{value:"left",children:"Pan left"}),t.jsx("option",{value:"right",children:"Pan right"})]})]}),Yn==="shape"&&t.jsxs(t.Fragment,{children:[t.jsxs(qa,{label:"Shape",icon:t.jsx(Fa,{size:12}),value:Te.shape||"rect",onChange:x=>gt({shape:x.target.value}),children:[t.jsx("option",{value:"rect",children:"Rectangle"}),t.jsx("option",{value:"circle",children:"Circle"}),t.jsx("option",{value:"ellipse",children:"Ellipse"}),t.jsx("option",{value:"triangle",children:"Triangle"}),t.jsx("option",{value:"star",children:"Star"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(a0,{label:"Fill",icon:t.jsx(Li,{size:11}),value:Te.color||"#8b5cf6",onStart:Se,onChange:x=>gt({color:x.target.value},!0)}),t.jsx(Bt,{label:"Opacity",keyState:fe("opacity"),onToggleKey:()=>ge("opacity"),icon:t.jsx(Mo,{size:11}),value:Math.round(Q("opacity")),suffix:"%",min:0,max:100,onStart:Se,onChange:x=>je("opacity",+x.target.value,1,!0)})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Width",keyState:fe("width"),onToggleKey:()=>ge("width"),icon:t.jsx(Ts,{size:11}),value:Math.round(Q("width")),suffix:"%",min:2,max:100,onStart:Se,onChange:x=>je("width",+x.target.value,void 0,!0)}),t.jsx(Bt,{label:"Height",keyState:fe("height"),onToggleKey:()=>ge("height"),icon:t.jsx(Ts,{size:11}),value:Math.round(Q("height")),suffix:"%",min:2,max:100,onStart:Se,onChange:x=>je("height",+x.target.value,void 0,!0)})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Position X",keyState:fe("x"),onToggleKey:()=>ge("x"),icon:t.jsx(Fs,{size:11}),value:Q("x"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("x",+x.target.value,50,!0)}),t.jsx(Bt,{label:"Position Y",keyState:fe("y"),onToggleKey:()=>ge("y"),icon:t.jsx(Fs,{size:11}),value:Q("y"),suffix:"%",min:wr.min,max:wr.max,onStart:Se,onChange:x=>je("y",+x.target.value,84,!0)})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx(Bt,{label:"Rotate",keyState:fe("rotation"),onToggleKey:()=>ge("rotation"),icon:t.jsx(Tc,{size:11}),value:Q("rotation"),suffix:"°",min:-180,max:180,onStart:Se,onChange:x=>je("rotation",+x.target.value,void 0,!0)}),Te.shape!=="circle"&&Te.shape!=="ellipse"&&Te.shape!=="triangle"&&Te.shape!=="star"&&t.jsx(Bt,{label:"Round",keyState:fe("radius"),onToggleKey:()=>ge("radius"),icon:t.jsx(Fa,{size:11}),value:Q("radius"),suffix:"px",min:0,max:200,onStart:Se,onChange:x=>je("radius",+x.target.value,void 0,!0)}),Te.shape==="star"&&t.jsx(Bt,{label:"Points",keyState:fe("points"),onToggleKey:()=>ge("points"),icon:t.jsx(Mo,{size:11}),value:Q("points"),min:3,max:12,onStart:Se,onChange:x=>je("points",+x.target.value,void 0,!0)})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3 pt-3 border-t border-white/10",children:[t.jsx(Bt,{label:"Fade in",icon:t.jsx(Zp,{size:11}
129),value:Te.fadeIn||0,display:((Te.fadeIn||0)/We).toFixed(1),suffix:"s",min:0,max:Math.min(45,Te.durationInFrames||30),onStart:Se,onChange:x=>gt({fadeIn:+x.target.value},!0),onType:x=>gt({fadeIn:ei(Math.round(x*We),0,Te.durationInFrames||30)})}),t.jsx(Bt,{label:"Fade out",icon:t.jsx(Tm,{size:11}),value:Te.fadeOut||0,display:((Te.fadeOut||0)/We).toFixed(1),suffix:"s",min:0,max:Math.min(45,Te.durationInFrames||30),onStart:Se,onChange:x=>gt({fadeOut:+x.target.value},!0),onType:x=>gt({fadeOut:ei(Math.round(x*We),0,Te.durationInFrames||30)})})]}),t.jsxs("div",{className:"text-[11px] text-gray-500 pt-1 inline-flex items-center gap-1.5",children:[t.jsx(Kb,{size:11})," Starts ",ds(Te.fromFrame||0)," ·"," ",((Te.durationInFrames||0)/We).toFixed(1),"s long"]})]})]}):t.jsxs("div",{className:"text-gray-500 text-sm py-16 px-4 text-center",children:[t.jsx(ba,{className:"mx-auto mb-2 opacity-40",size:22}),"Select a clip to edit it.",t.jsx("div",{className:"text-gray-600 text-[11px] mt-2",children:"Space play · â/â step · C split · â« delete"})]})]})]}),t.jsxs("div",{className:"bg-[#16161d] border-t border-white/10 shrink-0 flex flex-col max-lg:max-h-[40vh]",style:{height:Gt},children:[t.jsx("div",{title:"Drag to resize",onPointerDown:x=>{x.preventDefault();const S=x.clientY,T=Math.round(x.currentTarget.parentElement.getBoundingClientRect().height)||Gt,L=ee=>Kt(Math.max(170,Math.min(580,T-(ee.clientY-S)))),K=()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",K)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",K)},className:"h-1.5 w-full cursor-ns-resize bg-white/[0.04] hover:bg-violet-500/40 transition shrink-0"}),t.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-white/10 flex-wrap max-sm:flex-nowrap max-sm:overflow-x-auto [&>*]:shrink-0 shrink-0",children:[t.jsxs("button",{onClick:so,className:xr,children:[t.jsx(fs,{})," Caption"]}),t.jsxs("button",{onClick:()=>{var x;return(x=xe.current)==null?void 0:x.click()},className:xr,children:[t.jsx(fs,{})," Audio"]}),t.jsx("input",{ref:xe,type:"file",accept:"audio/*,video/*",className:"hidden",onChange:ro}),t.jsxs("button",{onClick:()=>{var x;return(x=et.current)==null?void 0:x.click()},className:xr,children:[t.jsx(fs,{})," Video"]}),t.jsx("input",{ref:et,type:"file",accept:"video/*",className:"hidden",onChange:on}),t.jsxs("button",{onClick:()=>{var x;return(x=ct.current)==null?void 0:x.click()},className:xr,children:[t.jsx(fs,{})," Image"]}),t.jsx("input",{ref:ct,type:"file",accept:"image/*",className:"hidden",onChange:kt}),t.jsxs("button",{onClick:$e,className:xr,children:[t.jsx(fs,{})," Shape"]}),t.jsx("div",{className:"w-px h-5 bg-white/10 mx-1"}),t.jsxs("button",{onClick:Vo,disabled:!H,className:xr,children:[t.jsx(Di,{})," Split"]}),t.jsxs("button",{onClick:Hs,disabled:!H,className:xr,children:[t.jsx(xa,{})," Duplicate"]}),t.jsxs("button",{onClick:Rn?Qs:js,disabled:!H,className:xr,children:[t.jsx(ss,{})," ",Rn?"Delete keyframe":"Delete"]}),t.jsx("div",{className:"flex-1"}),t.jsxs("button",{onClick:()=>le(x=>!x),className:`${xr} ${Re?"text-violet-300 bg-violet-500/10":""}`,title:"Snapping",children:[t.jsx(Rl,{size:12})," Snap"]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-1",children:[t.jsx("button",{onClick:()=>we(x=>Math.max(24,x-22)),className:ms,title:"Zoom out",children:t.jsx(Gp,{size:14})}),t.jsx("input",{type:"range",min:"24",max:"260",value:oe,onChange:x=>we(+x.target.value),className:"ve-range w-24",style:{"--ve-accent":"#8b5cf6","--ve-pct":Math.round((oe-24)/236*100)}}),t.jsx("button",{onClick:()=>we(x=>Math.min(260,x+22)),className:ms,title:"Zoom in",children:t.jsx(Yc,{size:14})}),t.jsxs("button",{onClick:es,className:xr,title:"Fit timeline to view",children:[t.jsx(Ts,{size:12})," Fit"]})]})]}),t.jsx("div",{ref:ln,className:"ve-scroll flex-1 min-h-0 overflow-auto",children:t.jsxs("div",{className:"relative",style:{width:lo+ka},children:[t.jsxs("div",{className:"flex h-7 border-b border-white/10 bg-[#101016]",children:[t.jsx("div",{className:"shrink-0 border-r border-white/10",style:{width:lo}}),t.jsx("div",{className:"relative cursor-ew-resize",style:{width:ka},onPointerDown:Vs,children:vn.map(x=>t.jsxs("div",{className:"absolute top-0 bottom-0",style:{left:yn(x*We)},children:[t.jsxs("span",{className:"text-[9px] text-gray-500 pl-1 tabular-nums",children:[x,"s"]}),t.jsx("span",{className:"absolute bottom-0 left-0 w-px h-2 bg-white/20"})]},x))})]}),[...ze.tracks||[]].reverse().map(x=>t.jsxs("div",{"data-trackid":x.id,className:`flex border-b border-white/[0.06] last:border-0 ${hr===x.id&&Hn.current&&Hn.current!==x.id?"ring-1 ring-inset ring-violet-400/70 bg-vi
129olet-500/[0.05]":""}`,children:[t.jsxs("div",{className:"shrink-0 border-r border-white/10 pl-1.5 pr-2 flex items-center justify-between bg-[#101016]",style:{width:lo,height:bi},children:[t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx(Fs,{size:12,title:"Drag to reorder layer (front â back)",className:"text-gray-600 hover:text-gray-300 shrink-0 cursor-grab active:cursor-grabbing touch-none",onPointerDown:Qr(x.id)}),t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Ka[x.type]||"#888"}}),t.jsx("span",{className:"text-xs text-gray-300 truncate capitalize",children:x.name||x.type})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[t.jsx("button",{onClick:()=>ra(x.id),className:`p-1 rounded ${x.hidden?"text-gray-600":"text-gray-400 hover:text-gray-200"}`,title:x.hidden?"Show track":"Hide track",children:x.hidden?t.jsx(Wp,{size:13}):t.jsx(_u,{size:13})}),(x.type==="audio"||x.type==="video")&&t.jsx("button",{onClick:()=>No(x.id),className:`p-1 rounded ${Zr(x)?"text-gray-600":"text-emerald-300"}`,title:Zr(x)?"Unmute audio":"Mute audio",children:Zr(x)?t.jsx(Gd,{size:13}):t.jsx(Yp,{size:13})}),t.jsx("button",{onClick:()=>ja(x.id),title:"Delete layer","aria-label":`Delete layer ${x.name||x.type}`,className:"p-1 rounded text-gray-500 hover:text-red-400 hover:bg-red-500/10",children:t.jsx(ss,{size:13})})]})]}),t.jsxs("div",{"data-lane":!0,className:"relative",style:{width:ka,height:bi,backgroundImage:`repeating-linear-gradient(90deg, transparent, transparent ${Math.max(1,yn(We)-1)}px, rgba(255,255,255,0.04) ${yn(We)}px)`},onPointerDown:S=>{S.target===S.currentTarget&&Vs(S)},children:[(x.clips||[]).map(S=>{const T=qr(x.id,S.id),L=T&&En,K=yn(S.fromFrame||0),ee=Math.max(10,yn(S.durationInFrames||1)),be=S.text||S.sceneTitle||S.name||(x.type==="audio"?"Audio":x.type);return t.jsxs("div",{"data-ve-clip":S.id,"data-ve-track":x.id,onPointerDown:Ce=>wo(Ce,x.id,S,"move"),onDoubleClick:Ce=>{Ce.stopPropagation(),On(S.fromFrame||0)},onContextMenu:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),qr(x.id,S.id)||Wn(x.id,S.id,!1),Qt({x:Ce.clientX,y:Ce.clientY})},className:`group absolute top-1 bottom-1 rounded-md overflow-hidden cursor-grab active:cursor-grabbing ${L?"z-30":""}`,style:{left:K,width:ee,background:Sa(x.type),border:`1px solid ${T?"#ffffff":pS[x.type]||"rgba(255,255,255,0.25)"}`,transform:L?"translateY(-2px)":void 0,boxShadow:L?"0 0 0 2px rgba(167,139,250,1), 0 12px 26px rgba(0,0,0,0.6)":T?"0 0 0 1.5px rgba(167,139,250,0.9), 0 6px 16px rgba(0,0,0,0.45)":"0 1px 3px rgba(0,0,0,0.35)"},children:[x.type==="video"&&S.src&&t.jsx("video",{src:`${S.src}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 w-full h-full object-cover opacity-60 pointer-events-none"}),x.type==="image"&&S.src&&t.jsx("img",{src:S.src,alt:"",className:"absolute inset-0 w-full h-full object-cover opacity-60 pointer-events-none"}),x.type==="audio"&&S.src&&t.jsx(wS,{src:S.src,width:ee,startSec:S.loop?0:(Number(S.trimStart)||0)/We,durSec:(S.durationInFrames||1)*Math.max(.1,Number(S.speed)||1)/We,loop:!!S.loop}),t.jsxs("div",{className:"absolute inset-0 flex items-center gap-1.5 px-2.5 pointer-events-none bg-gradient-to-r from-black/45 via-black/10 to-transparent",children:[x.type==="caption"&&t.jsx(Ra,{size:10,className:"text-white/90 shrink-0"}),t.jsx("span",{className:"text-[10px] font-medium text-white/95 truncate drop-shadow",children:be})]}),Xd(S).map(Ce=>{var St;const Be=!!Rn&&Rn.trackId===x.id&&Rn.clipId===S.id&&Rn.f===Ce,Ve=rf(S,Ce),wt=Ve==="hold"?"rounded-[1px]":Ve&&Ve!=="linear"&&Ve!=="mixed"?"rounded-full":"rotate-45 rounded-[1px]",Yt=Ve==="mixed"?"mixed":((St=wi.find(bt=>bt.id===Ve))==null?void 0:St.label)||"Linear";return t.jsx("button",{type:"button","data-ve-key":Ce,"data-ve-key-ease":Ve||"linear","data-ve-key-picked":Be?"":void 0,title:`Keyframe at ${ds((S.fromFrame||0)+Ce)}, ${Yt} to the next. Click to pick it, drag to move it, right-click for its motion.`,"aria-label":`Keyframe at ${ds((S.fromFrame||0)+Ce)}`,"aria-pressed":Be,onPointerDown:bt=>Xt(bt,x.id,S,Ce),onContextMenu:bt=>{bt.preventDefault(),bt.stopPropagation(),Wn(x.id,S.id,!1),Ct({trackId:x.id,clipId:S.id,f:Ce}),Ot({x:bt.clientX,y:bt.clientY})},className:`absolute bottom-[3px] w-[9px] h-[9px] -ml-[4.5px] ${wt} border shadow cursor-ew-resize touch-none transition-transform ${Be?"z-30 bg-white border-amber-500 scale-[1.35] ring-2 ring-amber-300/80":"z-20 bg-amber-300 border-black/70 hover:bg-white hover:scale-125"}`,style:{left:yn(Ce)},children:t.jsx("span",{"aria-hidden":"true",className:"absolute -inset-[6px]"})},Ce)}),t.jsx("span",{"data-ve-trim":"start",className:"absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize touch-none bg-black/25 group-hover:bg-white/50 z-10",onPointerDown:Ce=>wo(Ce,x.id,S,"start")}),t.jsx("span",{"data-ve-trim":"end",className:"absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize touch-none bg-black/25 group-hover:bg-white/50 z-10",onPointerDown:Ce=>wo(Ce,x.id,S,"end")})]},S.id)}),Rn&&Rn.trackId===x.id&&(()=>{const S=(x.clips||[]).find(K=>K.id===Rn.clipId);if(!S)return null;const T=yn((S.fromFrame||0)+Rn.f),L=us==="mixed"?null:wi.find(K=>K.id===(us||"linear"));return t.jsxs("button",{type:"button","data-ve-motion-pill":!0,onPointerDown:K=>K.stopPropagation(),onClick:K=>{const ee=K.currentTarget.getBoundingClientRect();Ot({x:ee.left,y:ee.bottom+4})},title:"How this keyframe moves on to the next one",className:"absolute z-40 top-[5px] h-[18px] w-[104px] px-1.5 inline-flex items-center gap-1 rounded-full bg-[#1c1c26]/95 border border-amber-300/60 text-[10px] font-medium text-amber-100 shadow-lg hover:bg-[#262634] transition-colors",style:{left:Math.max(0,T-52)},children:[t.jsx(Rc,{id:(L==null?void 0:L.id)||"linear",size:13}),t.jsx("span",{className:"truncate flex-1 text-left",children:sa?L?L.label:"Mixed":"Last key"}
129),t.jsx(Al,{size:10,className:"shrink-0 opacity-70"})]})})()]})]},x.id)),t.jsxs("div",{className:"absolute top-0 bottom-0 pointer-events-none z-20",style:{left:lo+yn(ie)},children:[t.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 -translate-x-1/2 bg-violet-400"}),t.jsx("div",{className:"absolute top-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-violet-400 rounded-[2px]"})]}),Qe!=null&&t.jsx("div",{className:"absolute top-7 bottom-0 w-px -translate-x-1/2 bg-cyan-300/80 pointer-events-none z-20",style:{left:lo+yn(Qe)}})]})})]}),R&&t.jsxs("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-40 px-3.5 py-2 rounded-full bg-[#16161d] border border-violet-500/40 shadow-xl text-xs text-gray-200 flex items-center gap-2",children:[t.jsx(fo,{className:"animate-spin text-violet-300"})," ",R]}),w!==0&&t.jsxs("div",{"data-missing-media":w,role:"status","aria-live":"polite",className:"absolute top-16 left-1/2 -translate-x-1/2 z-40 max-w-[min(92vw,540px)] px-3.5 py-2 rounded-xl bg-[#16161d] border border-amber-400/40 shadow-xl text-xs text-gray-200 flex items-start gap-2",children:[t.jsx(Xs,{className:"text-amber-300 mt-0.5 shrink-0"}),t.jsxs("span",{children:[w===1?"One clip in this project isn't":w>1?`${w} clips in this project aren't`:"Some clips in this project aren't"," ","here any more. The editor keeps what you bring in for"," ",Ja(d==null?void 0:d.uploadHours)," and then removes it, so add ",w===1?"it":"them"," again from your computer before exporting."]}),t.jsx("button",{type:"button",onClick:()=>C(0),className:"ml-1 shrink-0 text-gray-400 hover:text-white","aria-label":"Dismiss",children:t.jsx(ft,{size:14})})]}),(yo||Sr)&&t.jsx("div",{"data-export-status":Sr?"exporting":"ready",className:"absolute bottom-4 left-4 z-30 px-3 py-2 rounded-xl bg-[#16161d] border border-white/10 shadow-xl text-xs flex items-center gap-2",children:Sr?t.jsxs(t.Fragment,{children:[t.jsx(fo,{className:"animate-spin text-violet-300"})," ",t.jsx("span",{className:"text-gray-300",children:"Exporting⦠When it's done it saves to your computer."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ga,{className:"text-emerald-400"})," ",t.jsx("span",{className:"text-gray-300",children:"Export ready"})," ",t.jsxs("button",{type:"button",onClick:()=>Cr.current(yo,p==null?void 0:p.title),className:"text-violet-300 hover:text-violet-200 inline-flex items-center gap-1",children:["Download ",t.jsx(go,{size:11})]})]})}),rn&&Rn&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[90]",onMouseDown:()=>Ot(null),onContextMenu:x=>{x.preventDefault(),Ot(null)},children:t.jsxs("div",{"data-ve-key-menu":!0,role:"menu",ref:x=>{if(!x)return;const S=x.offsetHeight;x.style.top=`${Math.max(8,Math.min(rn.y,window.innerHeight-S-8))}px`},className:"absolute w-[236px] max-h-[calc(100vh-16px)] overflow-y-auto rounded-xl border border-white/10 bg-[#16161d] shadow-2xl p-1.5 text-sm text-gray-200",style:{left:Math.max(8,Math.min(rn.x,window.innerWidth-244)),top:Math.max(8,rn.y)},onMouseDown:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"px-2.5 pt-1 pb-1.5 text-[11px] text-amber-200 inline-flex items-center gap-1.5",children:[t.jsx("span",{"aria-hidden":"true",className:"text-amber-300",children:"â"}),"Keyframe at ",ds(((Te==null?void 0:Te.fromFrame)||0)+Rn.f)]}),t.jsx("div",{className:"px-2.5 pb-1 text-[10px] uppercase tracking-wider text-gray-500",children:"Motion to the next keyframe"}),!sa&&t.jsx("div",{className:"px-2.5 pb-1.5 text-[11px] text-gray-500",children:"This is the last keyframe. Add one after it to shape the motion between them."}),wi.map(x=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":us===x.id,disabled:!sa,onClick:()=>{eo(x.id),Ot(null)},className:"w-full flex items-center gap-2 px-2.5 py-1 rounded-lg hover:bg-white/5 disabled:opacity-40 disabled:hover:bg-transparent text-left",children:[t.jsx(Rc,{id:x.id}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"block text-[12px] leading-tight",children:x.label}),t.jsx("span",{className:"block text-[10px] leading-tight text-gray-500 truncate",children:x.hint})]}),us===x.id&&t.jsx(ga,{className:"w-3.5 h-3.5 text-amber-300 shrink-0"})]},x.id)),t.jsx("div",{className:"my-1 border-t border-white/5"}),t.jsxs("button",{type:"button",onClick:()=>{On(((Te==null?void 0:Te.fromFrame)||0)+Rn.f),Ot(null)},className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg hover:bg-white/5 text-left text-[12px]",children:[t.jsx(qp,{className:"w-3.5 h-3.5"})," Go to keyframe"]}),t.jsxs("button",{type:"button",onClick:()=>{Qs(),Ot(null)},className:"w-full flex items-center justify-between gap-4 px-2.5 py-1.5 rounded-lg hover:bg-rose-500/10 text-rose-300 text-left text-[12px]",children:[t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(ss,{className:"w-3.5 h-3.5"})," Delete keyframe"]}),t.jsx("span",{className:"text-[10px] text-gray-500",children:"â«"})]})]})}),document.body),Je&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[90]",onMouseDown:()=>Qt(null),onContextMenu:x=>{x.preventDefault(),Qt(null)},children:t.jsxs("div",{className:"absolute min-w-[184px] rounded-xl border border-white/10 bg-[#16161d] shadow-2xl p-1.5 text-sm text-gray-200",style:{left:Math.min(Je.x,window.innerWidth-200),top:Math.min(Je.y,window.innerHeight-220)},onMouseDown:x=>x.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{Vo(),Qt(null)},className:"w-full flex items-center justify-between gap-4 px-2.5 py-1.5 rounded-lg hover:bg-white/5 text-left",children:[t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(Di,{className:"w-3.5 h-3.5"})," Split at playhead"]}),t.jsx("span",{className:"text-[10px] text-gray-500",children:"C"})]}),t.jsxs("button",{onClick:()=>{Hs(),Qt(null)},className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg hover:bg-white/5 text-left",children:[t.jsx(xa,{
129className:"w-3.5 h-3.5"})," Duplicate"]}),Yn==="audio"&&t.jsxs("button",{onClick:()=>{var x;qn.current=H,Qt(null),(x=xe.current)==null||x.click()},className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg hover:bg-white/5 text-left",children:[t.jsx(ho,{className:"w-3.5 h-3.5"})," Replace audioâ¦"]}),t.jsx("div",{className:"my-1 border-t border-white/5"}),t.jsxs("button",{onClick:()=>{js(),Qt(null)},className:"w-full flex items-center justify-between gap-4 px-2.5 py-1.5 rounded-lg hover:bg-rose-500/10 text-rose-300 text-left",children:[t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(ss,{className:"w-3.5 h-3.5"})," Delete"]}),t.jsx("span",{className:"text-[10px] text-gray-500",children:"â«"})]}),t.jsxs("button",{onClick:()=>{Ur(),Qt(null)},title:"Delete and slide everything after it back, so there is no gap",className:"w-full flex items-center justify-between gap-4 px-2.5 py-1.5 rounded-lg hover:bg-rose-500/10 text-rose-300 text-left",children:[t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(ss,{className:"w-3.5 h-3.5"})," Delete and close the gap"]}),t.jsx("span",{className:"text-[10px] text-gray-500",children:"â§â«"})]})]})}),document.body),pr&&Un.createPortal(t.jsx("div",{className:"fixed inset-0 z-[95] grid place-items-center bg-black/60 backdrop-blur-sm p-4",onMouseDown:()=>rr(!1),children:t.jsxs("div",{className:"modal-pop-in w-full max-w-sm rounded-2xl border border-white/10 bg-[#16161d] p-5 shadow-2xl",onMouseDown:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:"Keyboard shortcuts"}),t.jsx("button",{onClick:()=>rr(!1),className:"text-gray-400 hover:text-white",children:t.jsx(ft,{})})]}),t.jsx("div",{className:"divide-y divide-white/5 text-sm",children:[["Play / pause","Space"],["Play / pause / step back","L / K / J"],["Step 1 frame","â / â"],["Step 10 frames","â§â / â§â"],["Go to start / end","Home / End"],["Zoom timeline","= / -"],["Split clip at playhead","C"],["Delete clip","â«"],["Copy / Cut / Paste at playhead","âC / âX / âV"],["Duplicate clip","âD"],["Undo / Redo","âZ / â§âZ"],["Right-click a clip","Menu"],["Double-click a clip","Jump to start"]].map(([x,S])=>t.jsxs("div",{className:"flex items-center justify-between py-2",children:[t.jsx("span",{className:"text-gray-300",children:x}),t.jsx("kbd",{className:"px-2 py-1 rounded-md bg-white/[0.06] border border-white/10 text-[11px] text-gray-200",children:S})]},x))})]})}),document.body)]}),document.body)}function MS({tabKey:e,onSelect:n}){const r=A4[e];if(!r)return null;const s=Nh[r.accent]||Nh.violet,o=r.icon;return t.jsxs("button",{type:"button",onClick:()=>n(e),className:`group relative overflow-hidden rounded-2xl ring-1 ring-white/10 border border-transparent ${s.ring} bg-white/[0.02] text-left transition-all duration-200 hover:-translate-y-1 shadow-[0_8px_30px_-16px_rgba(0,0,0,0.6)] hover:shadow-[0_18px_44px_-18px_rgba(0,0,0,0.75)]`,children:[t.jsxs("div",{className:`relative h-24 sm:h-28 overflow-hidden bg-gradient-to-br ${s.grad}`,children:[t.jsx("div",{className:"absolute inset-0 opacity-60 [background-image:radial-gradient(circle_at_1px_1px,rgba(255,255,255,0.16)_1px,transparent_0)] [background-size:14px_14px]"}),t.jsx("div",{className:"pointer-events-none absolute -right-6 -top-8 h-24 w-24 rounded-full bg-white/10 blur-2xl"}),t.jsx("span",{className:`absolute left-4 bottom-3 w-12 h-12 grid place-items-center rounded-2xl ring-1 ring-white/20 backdrop-blur-sm ${s.ico} transition-transform duration-300 group-hover:scale-110 group-hover:-rotate-3`,children:t.jsx(o,{className:"w-6 h-6"})}),t.jsx(Da,{className:"absolute right-3 top-3 w-5 h-5 text-white/50 group-hover:text-white group-hover:translate-x-0.5 transition"})]}),t.jsxs("div",{className:"p-4 sm:p-5",children:[t.jsx("h3",{className:"text-[15px] font-semibold text-white",children:r.label}),t.jsx("p",{className:"text-[12.5px] text-gray-400 mt-1 leading-snug",children:r.blurb})]})]})}function $u({n:e,title:n,desc:r,Icon:s}){return t.jsxs("div",{className:"group relative overflow-hidden rounded-2xl ring-1 ring-white/10 bg-gradient-to-b from-white/[0.05] to-white/[0.01] p-5 sm:p-6 shadow-[0_8px_30px_-16px_rgba(0,0,0,0.5)] transition-all duration-200 hover:ring-white/20 hover:-translate-y-0.5",children:[t.jsx("span",{className:"pointer-events-none absolute -top-3 right-2 text-6xl font-black leading-none text-white/[0.04] select-none",children:e}),t.jsxs("div",{className:"relative flex items-center gap-3 mb-3",children:[t.jsx("span",{className:"w-9 h-9 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 text-white grid place-items-center text-sm font-bold shadow-lg shadow-violet-500/30 ring-1 ring-white/20",children:e}),t.jsx(s,{className:"w-5 h-5 text-gray-500"})]}),t.jsx("h3",{className:"relative text-[15px] font-semibold text-white",children:n}),t.jsx("p",{className:"relative text-[13px] text-gray-400 mt-1.5 leading-relaxed",children:r})]})}function gl({children:e,className:n="",delay:r=0,as:s="div"}){const o=i.useRef(null),[a,l]=i.useState(!1);return i.useEffect(()=>{const c=o.current;if(!c)return;if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){l(!0);return}
129const u=new IntersectionObserver(([d])=>{d.isIntersecting&&(l(!0),u.disconnect())},{threshold:.12,rootMargin:"0px 0px -8% 0px"});return u.observe(c),()=>u.disconnect()},[]),t.jsx(s,{ref:o,style:{transitionDelay:`${r}ms`},className:`transition-all duration-700 ease-out will-change-transform ${a?"opacity-100 translate-y-0":"opacity-0 translate-y-6"} ${n}`,children:e})}function IS({workKinds:e}){const n=Cb(({currentLocation:y,nextLocation:v})=>y.pathname===v.pathname||_4(v.pathname)?!1:e().length>0),r=i.useRef([]);if(n.state==="blocked"&&!r.current.length&&(r.current=e()),i.useEffect(()=>{n.state!=="blocked"&&(r.current=[])},[n.state]),n.state!=="blocked")return null;const s=r.current.length?r.current:["video"],o=s.includes("video"),a=s.includes("photo"),l=s.includes("export"),c=o&&a,u=c?"your video and photo editors":o?"your video editor":"your photo editor",d=c?"Save Project in the Video Editor and File then Save As PSD in the Photo Editor keep the project files on your computer, ready to open again.":o?"Save Project keeps the project file on your computer, ready to open again.":"File then Save As PSD keeps the project file on your computer, ready to open again.",h=s.includes("adflow"),p=o||a,b=p?"Save your work first?":l?"Your export is still running":"Your AdFlow run is still going";return Un.createPortal(t.jsx("div",{"data-leave-guard":!0,className:"fixed inset-0 z-[150] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",onMouseDown:y=>{var v;y.target===y.currentTarget&&((v=n.reset)==null||v.call(n))},onKeyDown:y=>{var v;y.key==="Escape"&&(y.stopPropagation(),(v=n.reset)==null||v.call(n))},children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"studio-leave-guard-title","aria-describedby":"studio-leave-guard-body",className:"modal-pop-in w-full max-w-md rounded-2xl bg-[#16161d] border border-white/10 shadow-2xl p-5",children:[t.jsx("h3",{id:"studio-leave-guard-title",className:"text-base font-semibold text-white",children:b}),t.jsxs("p",{id:"studio-leave-guard-body",className:"mt-2 text-sm text-gray-300",children:[p?t.jsxs(t.Fragment,{children:["You have unsaved work in ",u,". We don't keep it for you, so leaving this page ends the session and the work goes with it."," ",d," "]}):null,l?t.jsxs(t.Fragment,{children:["The Video Editor is still exporting. It saves the file to your computer the moment it lands, and leaving this page stops it watching, so you would have to fetch that video from the editor yourself."," "]}):null,h?t.jsx(t.Fragment,{children:"An AdFlow run is still going. Leaving this page stops it, and the steps it hasn't reached yet won't run. Stay until it finishes to keep every result on your board."}):null]}),t.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button","data-leave-guard-leave":!0,onClick:()=>{var y;return(y=n.proceed)==null?void 0:y.call(n)},className:"px-3 py-2 rounded-lg text-sm text-gray-300 hover:text-white hover:bg-white/5",children:"Leave anyway"}),t.jsx("button",{type:"button","data-leave-guard-stay":!0,autoFocus:!0,onClick:()=>{var y;return(y=n.reset)==null?void 0:y.call(n)},className:"px-3.5 py-2 rounded-full text-sm font-semibold bg-violet-600 hover:bg-violet-500 text-white",children:p?"Stay and save":"Stay"})]})]})}),document.body)}function aC(){const{user:e,isLoading:n,silentRefresh:r,setCreditBalance:s}=Zb(),{openAuthModal:o}=ny(),a=d0(),l=i.useRef(!1);e&&(l.current=!0);const c=!!e||l.current,u=Lu(e),d=i.useRef(null),h=i.useCallback(()=>{var U;return u?!0:e?(bl({reason:"plan",message:"Editing is a Pro feature. Upgrade to Pro to open or create files."}),!1):((U=d.current)==null||U.call(d,"Sign in to open or create a file."),!1)},[u,a,e]),p=i.useRef(h);p.current=h;const{tab:b}=Nb();i.useEffect(()=>()=>ay(),[]);const y=kb(),v=i.useRef(y.search);v.current=y.search;const[w,C]=i.useState(()=>Ml.includes(b)?b:"discover"),k=i.useRef(w);k.current=w;const E=i.useCallback((U,{replace:ue=!1}={})=>{const Q=typeof U=="function"?U(k.current):U;!Ml.includes(Q)||Q===k.current||(k.current=Q,C(Q),a(D4(Q,v.current),{replace:ue}))},[a]),m=i.useRef(a);m.current=a;const M=y.pathname;i.useEffect(()=>{const U=()=>{k.current!=="discover"&&(k.current="discover",C("discover"))};Ml.includes(b)?b!==k.current&&(k.current=b,C(b)):M==="/content-studio"?U():bu[b]&&bu[b]!=="/content-studio"?m.current(bu[b],{replace:!0}):b!==void 0&&(U(),m.current("/content-studio",{replace:!0}))},[b,M]),i.useEffect(()=>{window.scrollTo({top:0,left:0})},[w]);const[I,N]=i.useState(null),[F,R]=i.useState(null),[A,V]=i.useState(null),[z,H]=i.useState(null),ne=i.useRef(null),se=i.useRef(null),[pe,ie]=i.useState(!1),[O,D]=i.useState(!1),[W,oe]=i.useState(null);i.useEffect(()=>{w==="image-editor"&&ie(!0),w==="editor"&&D(!0)},[w]);const we=i.useRef(!!e);i.useEffect(()=>{const U=we.current;we.current=!!e,!(e||!U||!Gc())&&(D(!1),ie(!1),le(!1),N(null),V(null),H(null),E("discover"))},[e]);const[Re,le]=i.useState(!1);i.useEffect(()=>{w==="adflow"&&le(!0)},[w]);const Ne=i.useRef(!1),ce=i.useRef(!1),Ae=i.useRef(!1),De=i.useRef(!1),Ze=i.useCallback(()=>
129{if(Gc())return[];const U=[];return Ae.current&&U.push("video"),jb()&&U.push("photo"),De.current&&U.push("export"),ce.current&&U.push("adflow"),U},[]),Ye=i.useCallback(()=>!Ne.current&&Ze().length===0,[Ze]),at=!!i.useContext(Sb),ut=i.useRef("signed-out");e!=null&&e.id&&(ut.current=String(e.id));const Xe=ut.current,nt=i.useCallback(U=>{var ue,Q;typeof U=="number"&&Number.isFinite(U)&&(J.current={...J.current,balance:U},s(U),(Q=(ue=se.current)==null?void 0:ue.refreshCredits)==null||Q.call(ue)),r==null||r()},[s,r]),xt=i.useCallback(U=>{var ge,je;const ue=J.current.balance,Q=Number(U)||0;if(typeof ue!="number"||!Q)return;const fe=Math.max(0,ue-Q);J.current={...J.current,balance:fe},s(fe),(je=(ge=se.current)==null?void 0:ge.refreshCredits)==null||je.call(ge)},[s]),J=i.useRef({balance:null,upgrade:()=>{}});J.current={balance:typeof(e==null?void 0:e.creditBalance)=="number"?e.creditBalance:null,upgrade:()=>bl({reason:"credits"})};const Ie=i.useCallback(async(U,ue)=>{try{const Q=await fetch(ue);if(!Q.ok)throw new Error(`HTTP ${Q.status}`);await U.open(await Q.blob())}catch{me.error("Couldn't open that image in the Photo Editor.")}},[]),ht=i.useCallback(U=>{if(!U)return;E("image-editor");const ue=se.current;if(!ue||ue.isDestroyed){ne.current=U;return}ue.isDirty()?oe(U):Ie(ue,U)},[Ie]);i.useEffect(()=>{Eb(Mb(),{photo:U=>ht(U),video:U=>{N(null),V(U),E("editor",{replace:!0})}})},[]),i.useEffect(()=>{try{new URLSearchParams(v.current).get("w")&&E("adflow",{replace:!0})}catch{}},[]);const[Et,Ft]=i.useState(!0),[Rt,Pt]=i.useState(!1),[Ht,Gt]=i.useState(rb),[Kt,un]=i.useState(null),[jt,ln]=i.useState(""),[Je,Qt]=i.useState({}),[rn,Ot]=i.useState(!1),Qe=i.useRef(null);if(Qe.current===null){const U=new URLSearchParams(y.search),ue=U.get("type");Qe.current={type:["image","video","audio"].includes(ue)?ue:null,prompt:(U.get("prompt")||"").trim().slice(0,2e3)}}const[Vt,En]=i.useState(Qe.current.type||"image"),[An,Lr]=i.useState(""),[ur,rt]=i.useState(!1),mt=Xe==="signed-out"?null:Xe,Ct=Lv({enabled:w==="asset-gen"&&!!e&&Rt,owner:mt}),[mr,pr]=i.useState(null);i.useEffect(()=>{pr(null)},[mt]);const[rr,qn]=i.useState(null),Z=i.useRef(null),xe=i.useRef(null),Le=i.useRef(null),[et,ct]=i.useState({top:112,space:200});i.useEffect(()=>{if(w!=="asset-gen"||!Le.current)return;const U=document.documentElement;return U.style.setProperty("--asset-dock-space",`${et.space}px`),U.classList.add("asset-dock-open"),()=>{U.classList.remove("asset-dock-open"),U.style.removeProperty("--asset-dock-space")}},[w,et.space,Rt]),i.useLayoutEffect(()=>{const U=Z.current;U&&(U.style.height="auto",U.style.height=`${U.scrollHeight}px`)},[Je,w]),i.useLayoutEffect(()=>{if(w!=="asset-gen")return;const U=()=>{const fe=xe.current,ge=Le.current;if(!fe||!ge)return;const je=Math.max(0,Math.round(fe.getBoundingClientRect().top+window.scrollY)),Oe=Math.max(0,Math.round(window.innerHeight-ge.getBoundingClientRect().top));ct(st=>st.top===je&&st.space===Oe?st:{top:je,space:Oe})};U();const ue=typeof ResizeObserver<"u"?new ResizeObserver(U):null;ue&&Le.current&&ue.observe(Le.current),window.addEventListener("resize",U);const Q=setTimeout(U,800);return()=>{ue==null||ue.disconnect(),window.removeEventListener("resize",U),clearTimeout(Q)}},[w,Rt,c]);const[pt,_t]=i.useState([]),[$n,xn]=i.useState(!1),[tt,Xn]=i.useState(null),[mn,Ke]=i.useState(!1),[ot,qt]=i.useState(""),[sr,zn]=i.useState(""),[Bn,jn]=i.useState(0),[vt,Mn]=i.useState({}),fr=i.useMemo(()=>({signIn:U=>{var ue;return((ue=d.current)==null?void 0:ue.call(d,U))??!0},begin:()=>jn(U=>U+1),end:()=>jn(U=>Math.max(0,U-1)),setInvalid:(U,ue,Q)=>Mn(fe=>{if(ue)return fe[U]===(Q||"a setting")?fe:{...fe,[U]:Q||"a setting"};if(!(U in fe))return fe;const ge={...fe};return delete ge[U],ge})}),[]),or=tt&&tt.modelName===jt?tt:null,bo=i.useMemo(()=>or?Zd(Je,or.schema,{mediaType:or.mediaType||tl(or.generationType),generationType:or.generationType,modelId:or.modelName}).missing:[],[or,Je]),In=hk(bo),jr=i.useRef(null);jr.current=tt;const Jn=i.useRef(Je);Jn.current=Je;const en=i.useRef(0),Nr=i.useRef(null),[Zn,Or]=i.useState(null),[gn,Hn]=i.useState(null);i.useEffect(()=>{const U=Zn;if(!jc(U)){Hn(null);return}let ue=!1;return Hn({checking:!0}),Jt(`${$t}/api/projects/delete`,{items:[{id:U.id,type:"studio-video"}],dryRun:!0}).then(Q=>{ue||Hn({checking:!1,favoritedCount:(Q==null?void 0:Q.favoritedCount)||0,collections:Array.isArray(Q==null?void 0:Q.collections)?Q.collections:[]})}).catch(()=>{ue||Hn(null)}),()=>{ue=!0}},[Zn]),i.useEffect(()=>{if(n)return;if(!e){Pt(!0),Ft(!1);return}let U=!1;return(async()=>{try{const ue=await Jt(`${$t}/api/creatify/config`,{});if(U)return;Pt(!!(ue!=null&&ue.configured));const Q=ue==null?void 0:ue.editorMedia;Number(Q==null?void 0:Q.uploadHours)>0&&Number(Q==null?void 0:Q.exportHours)>0&&Gt({uploadHours:Number(Q.uploadHours),exportHours:Number(Q.exportHours)})}catch{U||Pt(!1)}finally{U||Ft(!1)}})(),()=>{U=!0}},[e,n]);const hr=i.useCallback(async U=>{var Q,fe,ge;const ue=U==null?void 0:U.id;if(ue)try{if(jc(U)){const Oe=await Jt(`${$t}/api/projects/delete`,{items:[{id:ue,type:"studio-video"}]}),st=((Oe==null?void 0:Oe.results)||[]).find(Ee=>String(Ee==null?void 0:Ee.id)===String(ue));if(!(Oe!=null&&Oe.ok)||(st==null?void 0:st.ok)===!1)throw new Error((st==null?void 0:st.error)||(Oe==null?void 0:Oe.error)||"Could not delete.")}else{const Oe=await Jt(`${$t}/api/creatify/jobs/delete`,{id:ue});if(!(Oe!=null&&Oe.ok))throw new Error((Oe==null?void 0:Oe.error)||"Could not delete.")}const je=((ge=(fe=(Q=Ct.runs.find(Oe=>Oe.id===ue))==null?void 0:Q.outputs)==null?void 0:fe.find(Oe=>Oe.id!==ue))==null?void 0:ge.id)||null;Ct.forget(ue),pr(Oe=>Oe===ue?je:Oe),me.success("Render deleted.")}catch(je){me.error((je==null?void 0:je.message)||"Could not delete render.")}},[Ct.forget,Ct.runs]),kr=i.useCallback(()=>{r==null||r()},[r]),ze=(Ct.runs||[]).filter(U=>U.status==="processing"||U.status==="pending").map(U=>U.id).sort().join(","),Qn=i.useRef(ze);i.useEffect(()=>{const U=Qn.current;Qn.current=ze;
129const ue=new Set(ze.split(",").filter(Boolean));U.split(",").some(Q=>Q&&!ue.has(Q))&&kr()},[ze]);const Kn=U=>e?!0:(me.error(U||"Sign in to generate."),o==null||o("login",{mode:"login"}),!1),ar=()=>o==null?void 0:o("login",{mode:"login"});d.current=Kn;const _n=()=>e?Lu(e)?!0:(bl({reason:"plan",message:"UGC Studio is a Pro feature. Upgrade to Pro to create."}),!1):(me.error("Sign in to use UGC Studio."),o==null||o("login",{mode:"login"}),!1),bn=U=>{bl({reason:"plan",message:U||"Upgrade your plan to unlock this."})},Dn=(U,ue)=>{(U==null?void 0:U.code)==="SUBSCRIPTION_REQUIRED"?me.error(U.message||"An active subscription is required."):me.error((U==null?void 0:U.message)||ue)},Se=(U,ue)=>{var Q,fe,ge;(ge=(fe=(Q=jr.current)==null?void 0:Q.schema)==null?void 0:fe.properties)!=null&&ge[U]&&Qt(je=>({...je,[U]:ue}))},is=(U,ue)=>{Qt(ob(U,ue,Jn.current))},Wt=i.useCallback(async(U,ue,Q)=>{var je;const fe=ue??++en.current,ge=((je=jr.current)==null?void 0:je.schema)||Nr.current;if(ge&&(Nr.current=ge),ln(U),Xn(null),zn(""),!!U){Ke(!0);try{const Oe=await _o("schema",{modelName:U});if(fe!==en.current)return;Oe!=null&&Oe.model?(jr.current=Oe.model,Xn(Oe.model),Q?Qt(Rh(Oe.model.schema,Q)):is(Oe.model.schema,ge),Nr.current=null,rt(!1)):zn((Oe==null?void 0:Oe.error)||"That model's options couldn't be loaded.")}catch(Oe){fe===en.current&&zn((Oe==null?void 0:Oe.message)||"That model's options couldn't be loaded.")}finally{fe===en.current&&Ke(!1)}}},[]),_o=i.useCallback(async(U,ue)=>{if(l.current)return Jt(`${$t}/api/creatify/fal/${U}`,ue);const Q=new URLSearchParams(Object.entries(ue).filter(([,ge])=>ge!=null&&ge!=="")).toString(),fe=await fetch(`${$t}/api/creatify/fal/public-${U}?${Q}`);if(!fe.ok)throw new Error(`fal ${U} ${fe.status}`);return fe.json()},[]),Tr=i.useCallback(async(U,ue)=>{var fe,ge;if(!Rt||!U)return;const Q=++en.current;xn(!0),qt(""),zn(""),(fe=jr.current)!=null&&fe.schema&&(Nr.current=jr.current.schema),_t([]);try{const je=ak[U]||{category:U},Oe=await _o("models",je);if(Q!==en.current)return;const st=Array.isArray(Oe==null?void 0:Oe.models)?Oe.models:[];_t(st);const Ee=(ue==null?void 0:ue.modelName)||((ge=st[0])==null?void 0:ge.id);Ee?Wt(Ee,Q,ue?ue.values||{}:void 0):(ln(""),Xn(null))}catch(je){Q===en.current&&qt((je==null?void 0:je.message)||"The models couldn't be loaded.")}finally{Q===en.current&&xn(!1)}},[Rt]),ta=async U=>{var Oe;if(!U||(pr(U.id),!U.modelName))return;const Q=Object.keys(Mi).find(st=>Mi[st].includes(U.category))||(["image","video","audio"].includes(U.mediaType)?U.mediaType:"image"),fe=Mi[Q]||[];let ge=fe.includes(U.category)?U.category:"";const je=U.inputs||{};if(!ge){const st=++en.current;try{const Ee=await _o("schema",{modelName:U.modelName}),tn=String(((Oe=Ee==null?void 0:Ee.model)==null?void 0:Oe.generationType)||"").replace(/_/g,"-");fe.includes(tn)&&(ge=tn)}catch{}if(st!==en.current)return}if(ge=ge||fe[0]||"",En(Q),rt(!1),ge===An&&pt.some(st=>st.id===U.modelName)){Wt(U.modelName,void 0,je);return}Lr(ge),Tr(ge,{modelName:U.modelName,values:je})},Nt=()=>tt!=null&&tt.schema&&!Aa(tt.schema)?[]:ok(Vt,An),qr=U=>{var Q;const ue=Aa((Q=jr.current)==null?void 0:Q.schema);ue&&(Se(ue,U),requestAnimationFrame(()=>{var fe;return(fe=Z.current)==null?void 0:fe.focus()}))};i.useEffect(()=>{const U=new URLSearchParams(y.search);if(!U.has("type")&&!U.has("prompt"))return;U.delete("type"),U.delete("prompt");const ue=U.toString();m.current(`${y.pathname}${ue?`?${ue}`:""}`,{replace:!0})},[]),i.useEffect(()=>{var fe,ge,je,Oe;const U=(fe=Qe.current)==null?void 0:fe.prompt;if(!U||!(tt!=null&&tt.schema))return;Qe.current.prompt="";const ue=Aa(tt.schema),Q=ue&&((Oe=(je=(ge=tt.schema)==null?void 0:ge.properties)==null?void 0:je[ue])==null?void 0:Oe.maxLength);ue&&Se(ue,Q?U.slice(0,Q):U)},[tt]);const Wn=()=>{pr(null);const U=jr.current;U!=null&&U.schema&&Qt(Rh(U.schema,null))},Vr=U=>{U===An&&(pt.length||$n)||(Lr(U),rt(!1),Tr(U))},gs=U=>{if(U===Vt&&An&&(pt.length||$n))return;En(U);const ue=(Mi[U]||[])[0]||"";Lr(ue),rt(!1),Tr(ue)};i.useEffect(()=>{if(w==="asset-gen"&&Rt&&!pt.length&&!$n){const U=An||(Mi[Vt]||[])[0]||"";Lr(U),Tr(U)}},[w,Rt,c]);const Qs=async()=>{var fe,ge,je,Oe,st,Ee;if(!Kn())return;if(!tt)return me.error("Pick a model first.");if(Bn>0)return me.error("Wait for the upload to finish.");const U=Object.values(vt)[0];if(U){rt(!0),me.error(`Fix "${U}" first.`);return}if(tt.makesFile===!1)return me.error("This model doesn't make an image, video or audio file, so it can't be run here.");const ue=Zd(Je,tt.schema,{mediaType:tt.mediaType||tl(tt.generationType),generationType:tt.generationType,mediaSeconds:In,modelId:tt.modelName});if(ue.problem)return me.error(ue.problem);const Q=Array.isArray((fe=tt.schema)==null?void 0:fe.required)?tt.schema.required:[];for(const tn of Q){const Dt=Je[tn];if(Dt==null||typeof Dt=="string"&&!Dt.trim()||Array.isArray(Dt)&&Dt.length===0){const Xr=((Oe=(je=(ge=tt.schema)==null?void 0:ge.properties)==null?void 0:je[tn])==null?void 0:Oe.title)||Wo(tn),ls=Fh(tt.schema);tn===ls.promptKey?(st=Z.current)==null||st.focus():!ls.quickKeys.includes(tn)&&ls.promptKey&&rt(!0),me.error(`Please fill in "${Xr}".`);return}}Ot(!0);try{const tn=Je,Dt=await Jt(`${$t}/api/creatify/fal/generate`,{modelName:tt.modelName,inputParams:tn,title:tt.name,category:An,promptKey:Aa(tt.schema)||void 0});if((Ee=Dt==null?void 0:Dt.job)!=null&&Ee.id){const Ds=tt.mediaType||tl(tt.generationType),Xr=Aa(tt.schema),ls=Xr&&typeof tn[Xr]=="string"?tn[Xr]:"";
129Ct.addRun({id:Dt.job.id,status:"processing",mediaType:Ds,modelName:tt.modelName,modelLabel:tt.name,category:An,promptKey:Xr||null,prompt:ls.replace(/\s+/g," ").trim().slice(0,300)||null,inputs:tn,error:null,createdAt:new Date().toISOString(),outputs:[{id:Dt.job.id,status:"processing",mediaType:Ds,resultUrl:null,title:tt.name}]}),pr(Dt.job.id),me.success("Generating your assetâ¦"),kr()}else me.error((Dt==null?void 0:Dt.error)||"Couldn't start the generation.")}catch(tn){Dn(tn,"Couldn't start the generation.")}finally{Ot(!1)}},eo=()=>{un({sourceUrl:null}),E("ugc-studio")},gt=()=>{eo()};return Et||n?t.jsx(l0,{children:t.jsx("div",{className:"grid place-items-center py-32",children:t.jsx(Tn,{className:"w-10 h-10"})})}):t.jsxs(l0,{children:[at&&t.jsx(IS,{workKinds:Ze}),t.jsx("style",{children:` 130 /* Arriving on a tool (UGC Studio, Static Ads, Asset Generator, either editor, AdFlow): it 131 fades and lifts in exactly like the app's other pages (components/ScrollReveal.jsx: 14px, 132 700ms, the same easing), but in CSS rather than that component. ScrollReveal reveals once 133 per mount, and the tools kept running in the background stay mounted (shown again with 134 display none to block, which restarts this); and it leaves translateY(0) and will-change 135 on its wrapper for good, which makes the tool, not the window, what the Photo Editor's 136 fixed position submenus are placed against. No fill mode, so once this ends the tool has 137 no transform left; endStudioReveal ends it early on the first click or key press. */ 138 @keyframes studioReveal { 139 from { opacity: 0; transform: translateY(14px); } 140 to { opacity: 1; transform: none; } 141 } 142 .studio-reveal { animation: studioReveal 700ms cubic-bezier(0.2, 0.8, 0.2, 1); } 143 /* the Asset Generator's composer rises into place; no fill mode, so nothing is left on it 144 (a transform would make it what the model list's fixed position menu is placed against) */ 145 @keyframes assetComposerIn { 146 from { opacity: 0; transform: translateY(18px); } 147 to { opacity: 1; transform: none; } 148 } 149 .asset-composer-in { animation: assetComposerIn 500ms cubic-bezier(0.2, 0.8, 0.2, 1); } 150 @keyframes adfDash { to { stroke-dashoffset: -22; } } 151 .adf-edge-flow { animation: adfDash 0.55s linear infinite; } 152 @keyframes gradientShift { 0% { background-position: 0% center; } 50% { background-position: 100% center; } 100% { background-position: 0% center; } } 153 .gradient-anim { background-size: 200% auto; animation: gradientShift 6s ease-in-out infinite; } 154 @media (prefers-reduced-motion: reduce) { 155 .gradient-anim, .studio-reveal, .asset-composer-in { animation: none !important; } 156 } 157 `}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("main",{className:"w-full mx-auto min-w-0 max-w-[1408px] overflow-x-clip studio-reveal",onPointerDownCapture:Ea,onKeyDownCapture:Ea,style:w==="editor"||w==="image-editor"||w==="adflow"?{display:"none"}:void 0,children:[w==="discover"&&t.jsxs("div",{children:[t.jsxs(gl,{as:"section",className:"relative mb-12 sm:mb-16",children:[t.jsx("div",{className:"pointer-events-none absolute -top-24 left-1/2 -translate-x-1/2 h-[440px] w-[820px] max-w-[92vw] bg-[radial-gradient(closest-side,rgba(139,92,246,0.20),rgba(217,70,239,0.10),transparent_78%)] blur-3xl opacity-80"}),t.jsxs("div",{className:"relative max-w-3xl",children:[t.jsxs("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold tracking-[-0.02em] leading-[1.05] text-white text-balance",children:["Turn any product into"," ",t.jsx("span",{className:"gradient-anim bg-gradient-to-r from-violet-300 via-fuchsia-300 to-sky-300 bg-clip-text text-transparent",children:"ads that sell."})]}),t.jsx("p",{className:"mt-5 text-base sm:text-[17px] text-gray-400 max-w-xl leading-relaxed text-pretty",children:"Your whole creative team in one place. Generate UGC videos, static ads and any image, video or audio asset, then polish it in the built in editors. Pick a tool below and go from idea to publish ready in minutes."}),t.jsx("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:t.jsxs("button",{type:"button",onClick:()=>E("ugc-studio"),className:"group inline-flex items-center gap-2 rounded-full bg-gradient-to-r from-violet-500 to-fuchsia-500 px-6 py-3.5 text-sm font-semibold text-white shadow-[0_10px_34px_-8px_rgba(139,92,246,0.6)] hover:shadow-[0_14px_44px_-8px_rgba(139,92,246,0.8)] hover:-translate-y-0.5 transition-all duration-200",children:[t.jsx(Ri,{className:"w-4 h-4"})," Start creating",t.jsx(Da,{className:"w-4 h-4 -ml-0.5 opacity-70 group-hover:translate-x-0.5 transition-transform"})]})}),t.jsxs("div",{className:"mt-7 flex flex-wrap items-center gap-x-6 gap-y-2 text-[11.5px] text-gray-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Yd,{className:"w-3.5 h-3.5 text-emerald-400/80"})," ","Every tool in one place"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Yd,{className:"w-3.5 h-3.5 text-emerald-400/80"})," ","UGC, video and static ads"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Yd,{className:"w-3.5 h-3.5 text-emerald-400/80"})," ","Built in editors"]})]})]})]}),Rt&&t.jsx(gl,{as:"section",className:"mb-12 sm:mb-16",delay:40,children:t.jsxs("button",{type:"button",onClick:gt,className:"group w-full flex items-center gap-4 roun
157ded-2xl ring-1 ring-white/10 bg-gradient-to-b from-white/[0.045] to-white/[0.01] hover:ring-violet-400/40 px-5 py-5 sm:px-6 text-left shadow-[0_8px_30px_-16px_rgba(0,0,0,0.6)] hover:shadow-[0_16px_40px_-18px_rgba(0,0,0,0.7)] hover:-translate-y-0.5 transition-all duration-200",children:[t.jsx("span",{className:"shrink-0 w-11 h-11 grid place-items-center rounded-xl bg-gradient-to-br from-violet-500/30 to-fuchsia-500/20 ring-1 ring-white/10 text-violet-100",children:t.jsx(xa,{className:"w-5 h-5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-[15px] font-semibold text-white",children:"Clone a winning ad"}),t.jsx("p",{className:"text-[13px] text-gray-400 mt-1 leading-relaxed",children:"Upload an ad you like and we'll recreate its style with your product. Most videos take about 5 to 15 minutes."})]}),t.jsx(Da,{className:"ml-auto w-5 h-5 text-gray-500 group-hover:text-white group-hover:translate-x-0.5 transition"})]})}),t.jsx(gl,{as:"section",className:"mb-16 sm:mb-20",delay:60,children:t.jsxs("div",{className:"grid sm:grid-cols-3 gap-4 sm:gap-6",children:[t.jsx($u,{n:"1",Icon:u0,title:"Pick a tool or product",desc:"Start from a product URL, an uploaded image, or a winning ad you want to clone."}),t.jsx($u,{n:"2",Icon:Ri,title:"Generate with AI",desc:"UGC video, static ads, or any image, video or audio asset, made on top tier models in minutes."}),t.jsx($u,{n:"3",Icon:go,title:"Edit & export",desc:"Polish in the built-in video & photo editors, then download publish ready creatives."})]})}),t.jsxs(gl,{as:"section",className:"mb-16 sm:mb-20 space-y-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl sm:text-2xl font-bold tracking-tight text-white text-balance",children:"Everything you need to make ads"}),t.jsx("p",{className:"text-sm text-gray-400 mt-2 leading-relaxed",children:"One studio, every tool you need, from first idea to final export."})]}),[{label:"Create",Icon:Ri,keys:["ugc-studio","static-ads","asset-gen"]},{label:"Edit & build",Icon:qs,keys:["editor","image-editor","adflow"]}].map(U=>t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4 text-[11px] font-semibold uppercase tracking-[0.14em] text-gray-500",children:[t.jsx(U.Icon,{className:"w-3.5 h-3.5"})," ",U.label]}),t.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-3 sm:gap-4",children:U.keys.map(ue=>t.jsx(MS,{tabKey:ue,onSelect:E},ue))})]},U.label))]}),t.jsxs(gl,{as:"section",className:"relative mt-16 sm:mt-24 overflow-hidden rounded-3xl ring-1 ring-white/10 bg-gradient-to-b from-white/[0.05] to-white/[0.01] px-6 py-12 sm:px-12 sm:py-16 text-center shadow-[0_30px_80px_-30px_rgba(0,0,0,0.7)]",children:[t.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(60%_85%_at_50%_0%,rgba(139,92,246,0.22),transparent_70%),radial-gradient(45%_70%_at_82%_115%,rgba(217,70,239,0.16),transparent_70%)]"}),t.jsx("div",{className:"pointer-events-none absolute -inset-x-10 -top-24 h-56 bg-[radial-gradient(closest-side,rgba(139,92,246,0.28),transparent)] blur-3xl opacity-70"}),t.jsxs("div",{className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/10 bg-white/[0.04] px-3 py-1 text-[11px] font-semibold tracking-wide text-violet-100 mb-5",children:[t.jsx(Ao,{className:"w-3.5 h-3.5"})," Your studio awaits"]}),t.jsx("h2",{className:"text-2xl sm:text-4xl font-bold tracking-[-0.02em] text-white text-balance",children:"Ready to create your first ad?"}),t.jsx("p",{className:"mt-3 text-sm sm:text-base text-gray-400 max-w-md mx-auto leading-relaxed",children:"Pick a tool and go from product to publish-ready ad in minutes."}),t.jsx("div",{className:"mt-7 flex flex-wrap justify-center gap-3",children:t.jsxs("button",{type:"button",onClick:()=>E("ugc-studio"),className:"group inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-violet-500 to-fuchsia-500 px-6 py-3.5 text-sm font-semibold text-white shadow-[0_10px_34px_-8px_rgba(139,92,246,0.6)] hover:shadow-[0_14px_44px_-8px_rgba(139,92,246,0.8)] hover:-translate-y-0.5 transition-all duration-200",children:[t.jsx(Ri,{className:"w-4 h-4"})," Start with UGC Studio",t.jsx(Da,{className:"w-4 h-4 -ml-0.5 opacity-70 group-hover:translate-x-0.5 transition-transform"})]})})]})]})]}),w==="ugc-studio"&&t.jsx(mS,{configured:Rt,authLoading:n,requireUser:Kn,requirePro:_
157n,onSignUp:ar,user:e,onUpgrade:bn,onGoToProjects:()=>a("/projects?tab=videos"),canLeaveStudio:Ye,onOpenInEditor:U=>{N(U),E("editor")},onEditVideo:({url:U,title:ue,durationSeconds:Q})=>{U&&(N(null),V({url:U,title:ue,durationSeconds:Q||0}),E("editor"))},onCreditsChanged:r,cloneSeed:Kt,onCloneSeedConsumed:()=>un(null)}),w==="static-ads"&&t.jsx(lS,{configured:Rt,user:e,authLoading:n,requireUser:Kn,onSignUp:ar,onCreditsChanged:kr,onEditInPhotoEditor:ht,canLeaveStudio:Ye}),w==="asset-gen"&&t.jsxs("div",{ref:xe,className:"relative -mb-16 sm:-mb-24","data-asset-master":!0,children:[t.jsx("h1",{className:"sr-only",children:"Asset Generator"}),Rt?t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-asset-canvas":!0,children:c?t.jsx(Jv,{runs:Ct.runs,status:Ct.status,hasMore:Ct.hasMore,loadingMore:Ct.loadingMore,activeId:mr,onOpen:U=>qn(U.id),onLoadMore:Ct.loadMore,onRetry:Ct.load,empty:t.jsx("div",{className:"grid place-items-center",style:{minHeight:`calc(100dvh - ${et.top+et.space+24}px)`},children:t.jsx(gf,{examples:Nt(),onExample:qr})})}):t.jsx("div",{className:"grid place-items-center",style:{minHeight:`calc(100dvh - ${et.top+et.space+24}px)`},children:t.jsx(gf,{examples:Nt(),onExample:qr})})}),t.jsx("div",{"aria-hidden":!0,style:{height:et.space+24}}),(()=>{var Jr,Os,Xt,wo,Vs,ro,so,Us,zs;const U=Mi[Vt]||[],ue=U.includes(An)?An:U[0]||"",Q=tt&&tt.modelName===jt?tt:null,fe=((Jr=Q==null?void 0:Q.schema)==null?void 0:Jr.properties)||{},{aspectKey:ge,sizeKey:je,promptKey:Oe,imageKey:st,imageArrayKey:Ee,countKey:tn,durationKey:Dt,extraImageKeys:Ds,mediaKeys:Xr,quickKeys:ls}=Fh(Q==null?void 0:Q.schema),Do=ge?fe[ge].enum:[],cs=je?Mp(je,fe[je]):null,Sr=new Set(((Os=Q==null?void 0:Q.schema)==null?void 0:Os.required)||[]),yo=[...ls,...((Xt=fe.sync_mode)==null?void 0:Xt.type)==="boolean"?["sync_mode"]:[]],Cr=Ud(Q==null?void 0:Q.schema).filter($e=>!yo.includes($e)),bs=Oe&&Je[Oe]||"",Ls=typeof bs=="string"?bs:"",Nn=Oe&&((wo=fe[Oe])==null?void 0:wo.maxLength)||5e3,Fn=(Q==null?void 0:Q.mediaType)||tl(Q==null?void 0:Q.generationType),We=Zd(Je,Q==null?void 0:Q.schema,{mediaType:Fn,generationType:Q==null?void 0:Q.generationType,mediaSeconds:In,modelId:Q==null?void 0:Q.modelName}),Ln=(Q==null?void 0:Q.makesFile)===!1,er=We.total,Lo=We.basis==="upTo"?"Charged for the longest it can be. Whatever it doesn't use comes back.":We.basis==="input"?Fn==="video"?`Priced by the length of your file: 1 credit a second, up to ${Zc} seconds.`:`Priced by the length of your file: 1 credit a minute, up to ${Qc/60} minutes.`:"",yn=Object.values(vt)[0]||"",to=Array.isArray((Vs=Q==null?void 0:Q.schema)==null?void 0:Vs.required)?Q.schema.required:[],ds=Cr.some($e=>{if(!to.includes($e))return!1;const kt=Je[$e];return kt==null||typeof kt=="string"&&!kt.trim()||Array.isArray(kt)&&kt.length===0}),On=Vt==="audio"?Fl:Vt==="image"?Zs:$s,no=c&&!rn&&!!Q&&!$n&&!ot&&tl(Q==null?void 0:Q.generationType)===Vt&&Bn===0&&!Ln,ys=((ro=pt.find($e=>$e.id===jt))==null?void 0:ro.name)||jt,vs="max-sm:[&>svg]:hidden !h-8 sm:!h-9 !py-0 !px-2.5 sm:!px-3 !rounded-full !text-[12px] sm:!text-[13px] !bg-white/[0.06] !border-white/10 hover:!bg-white/[0.1]",vo="text-[12px] sm:text-[13px] text-gray-100";return Un.createPortal(t.jsx("div",{ref:Le,"data-asset-dock":!0,className:"fixed inset-x-0 bottom-0 z-[45] px-2 sm:px-6 pb-[max(0.5rem,env(safe-area-inset-bottom))] sm:pb-5 pointer-events-none",children:t.jsxs("div",{className:"asset-composer-in pointer-events-auto relative mx-auto max-w-5xl",children:[t.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 rounded-[22px] sm:rounded-[26px] border border-white/[0.12] bg-[#101219]/95 backdrop-blur-xl shadow-[0_-10px_40px_-12px_rgba(0,0,0,0.65),0_24px_70px_-20px_rgba(0,0,0,0.9)]"}),t.jsxs("div",{className:"relative p-2.5 sm:p-4 space-y-2.5 sm:space-y-3","data-asset-composer":!0,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{role:"tablist","aria-label":"What to make","data-asset-type-tabs":!0,className:"shrink-0 inline-flex items-center gap-0.5 p-0.5 rounded-full border border-white/10 bg-black/40",children:[{value:"image",label:"Image",Icon:Zs},{value:"video",label:"Video",Icon:$s},{value:"audio",label:"Audio",Icon:Fl}].map(({value:$e,label:kt,Icon:on})=>{const kn=Vt===$e;return t.jsxs("button",{type:"button",role:"tab","aria-selected":kn,onClick:()=>gs($e),className:`inline-flex items-center gap-1.5 h-8 ${kn?"px-3":"max-sm:px-2.5 px-3"} sm:px-3.5 rounded-full text-[12px] sm:text-[13px] font-medium transition ${kn?"bg-gradient-to-b from-violet-500 to-violet-600 text-white shadow-[0_2px_12px_-2px_rgba(139,92,246,0.6)]":"text-gray-400 hover:text-white"}`,children:[t.jsx(on,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:kn?"":"max-sm:sr-only",children:kt})]},$e)})}),t.jsx(Sn,{options:U.map($e=>({value:$e,label:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(On,{className:"w-3.5 h-3.5 opacity-70"}),ju($e)]})})),selectedValue:ue,onSelect:Vr,buttonContent:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(On,{className:"max-sm:hidden w-3.5 h-3.5 opacity-70"}),ju(ue)]}),dropUp:!0,className:"min-w-0 flex-1 sm:flex-none sm:w-[164px]",buttonClassName:vs,menuClassName:"!rounded-xl !min-w-[176px]"}),t.jsxs("button",{type:"button",onClick:Wn,title:"Start over with the model's defaults",className:"ml-auto shrink-0 inline-flex items-center gap-1.5 h-8 px-2.5 rounded-full text-[12px] font-medium text-gray-400 hover:text-white hover:bg-white/[0.06] transition",children:[t.jsx(Pl,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"max-sm:sr-only",children:"Reset"})]})]}),$n?t.jsx("div",{className:"h-20 rounded-2xl bg-white/[0.04] animate-pulse"}):ot?t.jsx(i0,{message:"The models couldn't be loaded.",onRetry:()=>Tr(ue)}):pt.length?sr?t.jsx(i0,{message:"That model's options couldn't be loaded.",onRetry:()=>Wt(jt)}
157):mn||!Q?t.jsx("div",{className:"h-20 rounded-2xl bg-white/[0.04] animate-pulse"}):t.jsxs(xi.Provider,{value:fr,children:[(st||Ee||Ds.length>0||Xr.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-1",children:[Ds.map($e=>{var kt;return t.jsxs("div",{className:"shrink-0 grid grid-cols-[auto_auto] items-center gap-x-2.5",children:[t.jsx("span",{className:"col-start-2 row-start-1 self-end text-[12px] font-medium text-gray-200",children:((kt=fe[$e])==null?void 0:kt.title)||Wo($e)}),t.jsx("div",{className:"col-start-1 row-start-1 row-span-2",children:t.jsx(ld,{compact:!0,value:typeof Je[$e]=="string"?Je[$e]:"",onChange:on=>Se($e,on)})}),t.jsx("span",{className:"col-start-2 row-start-2 self-start text-[11px] text-amber-200/80",children:"Required"})]},$e)}),Xr.map($e=>{const kt=fe[$e]||{},on=typeof Je[$e]=="string"?Je[$e]:"";return t.jsx("div",{className:"w-full sm:w-[320px]",children:t.jsx(Fe,{as:"div",label:kt.title||Wo($e),hint:"Required",children:ci($e,kt)?t.jsx(Hd,{value:on,onChange:kn=>Se($e,kn)}):t.jsx(Ep,{value:on,onChange:kn=>Se($e,kn)})})},$e)}),st&&(()=>{var kt;const $e=(((kt=Q.schema)==null?void 0:kt.required)||[]).includes(st);return t.jsxs("div",{className:"shrink-0 grid grid-cols-[auto_auto] items-center gap-x-2.5",children:[t.jsx("span",{className:"col-start-2 row-start-1 self-end text-[12px] font-medium text-gray-200",children:$e?"Image":"Reference image"}),t.jsx("div",{className:"col-start-1 row-start-1 row-span-2",children:t.jsx(ld,{compact:!0,value:typeof Je[st]=="string"?Je[st]:"",onChange:on=>Se(st,on),optional:!$e})}),t.jsx("span",{className:`col-start-2 row-start-2 self-start text-[11px] ${$e?"text-amber-200/80":"text-gray-500"}`,children:$e?"Required":"Optional"})]})})(),Ee&&(()=>{var oo,Oo,Bs;const $e=(((oo=Q.schema)==null?void 0:oo.required)||[]).includes(Ee),kt=((Bs=(Oo=Q.schema)==null?void 0:Oo.properties)==null?void 0:Bs[Ee])||{},{cap:on,real:kn}=pb(jt,kt,Q.imageInputLimit),ws=$e?"Required":"Optional";return t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Fe,{as:"div",label:kt.title||"Images",hint:kn?`${ws} · up to ${on} image${on===1?"":"s"}`:ws,children:t.jsx(Ip,{value:Array.isArray(Je[Ee])?Je[Ee]:[],onChange:ao=>Se(Ee,ao),max:on,optional:!$e})})})})()]}),Oe?t.jsxs("div",{children:[t.jsx("textarea",{ref:Z,value:Ls,onChange:$e=>Se(Oe,$e.target.value),onKeyDown:$e=>{$e.key==="Enter"&&($e.metaKey||$e.ctrlKey)&&no&&($e.preventDefault(),Qs())},rows:2,maxLength:Nn,placeholder:"Describe what you want to createâ¦",className:"block w-full min-h-[3.25rem] max-h-[8.5rem] sm:max-h-[11rem] [@media(max-height:560px)]:max-h-[3.5rem] overflow-y-auto bg-transparent px-2 pt-1 text-base sm:text-[15px] leading-relaxed text-gray-100 placeholder-gray-500 resize-none focus:outline-none"}),Ls.length>0&&t.jsx("div",{className:"flex justify-end px-2",children:t.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums",children:[Ls.length," / ",Nn]})})]}):t.jsx("div",{className:"max-h-[42vh] overflow-y-auto px-1 pr-2",children:t.jsx(cd,{schema:Q.schema,values:Je,onChange:Se,exclude:yo,modelId:jt,imageInputLimit:Q.imageInputLimit})}),Oe&&Cr.length>0&&t.jsx(G0,{open:ur,onClose:()=>rt(!1),keepMounted:!0,"data-asset-settings":!0,title:"Advanced settings",subtitle:`${ys} · ${Cr.length} option${Cr.length===1?"":"s"}`,icon:t.jsx(ba,{className:"w-4 h-4 text-violet-300"}),footer:t.jsx("button",{type:"button",onClick:()=>rt(!1),className:"w-full h-11 rounded-full bg-white text-sm font-semibold text-black hover:bg-white/90 transition",children:"Done"}),children:t.jsx(cd,{schema:Q.schema,values:Je,onChange:Se,exclude:yo,modelId:jt,imageInputLimit:Q.imageInputLimit})})]}):t.jsxs("p",{className:"text-sm text-gray-400 text-center py-6",children:["No ",ju(ue).toLowerCase()," models available."]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2 min-w-0",children:[t.jsx(Nm,{variant:"chip",models:pt,value:jt,onSelect:Wt,loading:$n,failed:!!ot,onRetry:()=>Tr(ue)}),Q&&ge&&Do.length>0&&t.jsx(Sn,{options:[...((so=fe[ge])==null?void 0:so.default)===void 0&&!Sr.has(ge)?[{value:"",label:"Auto"}]:[],...Do.map($e=>({value:$e,label:t.jsx(kc,{ratio:$e})}))],selectedValue:Je[ge]??"",buttonContent:Do.includes(Je[ge])?t.jsx(kc,{ratio:Je[ge],className:vo}):void 0,onSelect:$e=>Se(ge,$e),dropUp:!0,className:"shrink-0",buttonClassName:vs,menuClassName:"!rounded-xl !min-w-[128px]"}),Q&&cs&&t.jsx(Sn,{options:[...((Us=fe[je])==null?void 0:Us.default)===void 0&&!Sr.has(je)?[{value:"",label:"Auto"}]:[],...cs.presets.map($e=>({value:$e,label:Nc($e)?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(kc,{ratio:Nc($e)}),/_hd$/i.test(String($e))&&t.jsx("span",{className:"text-[10px] text-gray-400",children:"HD"})]}):Wo(String($e))}
157))],selectedValue:typeof Je[je]=="string"?Je[je]:"",buttonContent:Je[je]&&typeof Je[je]=="object"?`${Je[je].width??"?"}Ã${Je[je].height??"?"}`:Nc(Je[je])?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(kc,{ratio:Nc(Je[je]),className:vo}),/_hd$/i.test(String(Je[je]))&&t.jsx("span",{className:"text-[10px] text-gray-400",children:"HD"})]}):void 0,onSelect:$e=>Se(je,$e),dropUp:!0,className:"shrink-0",buttonClassName:vs,menuClassName:"!rounded-xl !min-w-[128px]"}),Q&&Dt&&t.jsx(Sn,{options:[...((zs=fe[Dt])==null?void 0:zs.default)===void 0&&!Sr.has(Dt)?[{value:"",label:"Auto"}]:[],...sk(fe[Dt]).map($e=>({value:$e,label:/^\d+$/.test(String($e))?`${$e}s`:String($e)}))],selectedValue:Je[Dt]??"",buttonContent:typeof Je[Dt]=="number"?`${Je[Dt]}s`:void 0,onSelect:$e=>Se(Dt,$e),dropUp:!0,className:"shrink-0",buttonClassName:vs,menuClassName:"!rounded-xl !min-w-[96px]"}),Q&&tn&&(()=>{var kn,ws;const $e=((kn=fe[tn])==null?void 0:kn.minimum)??1,kt=Math.min(((ws=fe[tn])==null?void 0:ws.maximum)??4,Wu),on=Number(Je[tn])||$e;return t.jsxs("div",{className:"inline-flex items-center h-8 sm:h-9 rounded-full border border-white/10 bg-white/[0.06]",title:"Outputs",children:[t.jsx("span",{className:"sr-only",children:"Outputs"}),t.jsx("button",{type:"button","aria-label":"Fewer outputs",onClick:()=>Se(tn,Math.max($e,on-1)),disabled:on<=$e,className:"w-7 sm:w-9 h-full grid place-items-center rounded-l-full text-gray-300 hover:text-white disabled:opacity-30 transition",children:"â"}),t.jsxs("span",{className:"min-w-[2.25rem] sm:min-w-[2.5rem] text-center text-[13px] font-semibold text-white tabular-nums",children:[on,"/",kt]}),t.jsx("button",{type:"button","aria-label":"More outputs",onClick:()=>Se(tn,Math.min(kt,on+1)),disabled:on>=kt,className:"w-7 sm:w-9 h-full grid place-items-center rounded-r-full text-gray-300 hover:text-white disabled:opacity-30 transition",children:"+"})]})})(),Q&&Oe&&Cr.length>0&&t.jsxs("button",{type:"button",onClick:()=>rt($e=>!$e),"aria-expanded":ur,title:Cr.slice(0,6).map($e=>Wo($e)).join(", "),className:`inline-flex items-center gap-1.5 h-8 sm:h-9 px-2.5 sm:px-3 rounded-full border text-[12px] sm:text-[13px] font-medium transition ${ur?"bg-violet-500/15 border-violet-500/40 text-violet-200":ds?"bg-amber-400/10 border-amber-400/40 text-amber-100 hover:bg-amber-400/15":"bg-white/[0.06] border-white/10 text-gray-200 hover:bg-white/[0.1]"}`,children:[t.jsx(ba,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"max-lg:sr-only",children:"Settings"}),t.jsx("span",{className:"min-w-5 h-5 px-1 rounded-full grid place-items-center bg-white/10 text-[10px] tabular-nums",children:Cr.length}),ds&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,className:"w-2 h-2 rounded-full bg-amber-400"}),t.jsx("span",{className:"sr-only",children:"needs input"})]})]})]}),c&&t.jsxs("button",{onClick:Qs,disabled:!no,className:"w-full sm:w-auto shrink-0 inline-flex items-center justify-center gap-2 h-12 px-7 rounded-2xl bg-gradient-to-r from-violet-500 to-fuchsia-500 hover:from-violet-400 hover:to-fuchsia-400 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-semibold shadow-[0_8px_28px_-6px_rgba(168,85,247,0.65)] transition",children:[rn||Bn>0?t.jsx(Tn,{className:"w-4 h-4"}):t.jsx(Ao,{className:"w-4 h-4"}),Bn>0?"Uploadingâ¦":t.jsxs(t.Fragment,{children:["Generate",t.jsx("span",{className:"font-normal text-white/60",children:"·"}),er==null?t.jsx("span",{className:"font-normal text-white/80",children:"by length"}):t.jsxs(t.Fragment,{children:[We.basis==="upTo"&&t.jsx("span",{className:"font-normal text-white/80",children:"up to"}),t.jsx("span",{className:"tabular-nums",children:er}),t.jsxs("span",{className:"font-normal text-white/80",children:["credit",er===1?"":"s"]})]})]})]})]}),!c&&t.jsxs("div",{"data-asset-signup":!0,className:"flex items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.03] px-3.5 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex items-center gap-1.5 text-[13px] font-semibold text-white",children:[t.jsx(Ao,{className:"w-4 h-4 shrink-0 text-violet-300"}),"Sign up to generate"]}),t.jsxs("p",{className:"mt-0.5 text-[11px] sm:text-[12px] leading-snug text-gray-400",children:["Get"," ",t.jsx("strong",{className:"text-white",children:"7 free credits"})," ","when you sign up, no subscription required."]})]}),t.jsx("button",{type:"button",onClick:()=>ar(),className:"shrink-0 h-10 sm:h-11 px-4 sm:px-6 rounded-2xl bg-gradient-to-r from-violet-500 to-fuchsia-500 hover:from-violet-400 hover:to-fuchsia-400 text-[13px] sm:text-sm font-semibold text-white shadow-[0_8px_28px_-6
157px_rgba(168,85,247,0.65)] transition",children:"Get Started For Free"})]}),Q&&(Ln||We.problem||yn||Lo)&&t.jsx("p",{className:`px-1 text-[11px] sm:text-right ${Ln||We.problem||yn?"text-amber-300":"text-gray-500"}`,children:Ln?"This model doesn't make an image, video or audio file, so it can't be run here.":We.problem?We.problem:yn?`Fix "${yn}" to generate.`:Lo})]})]})}),document.body)})(),t.jsx(Z4,{run:Ct.runs.find(U=>U.id===rr)||null,onClose:()=>qn(null),onReuse:U=>{qn(null),ta(U)},onOpenActions:R})]}):t.jsx(Ap,{})]}),t.jsx(Kc,{isOpen:!!Zn,title:jc(Zn)?"Delete this video?":"Delete this render?",description:jc(Zn)?"It's deleted for good, here and on your Projects page. Download it first if you want to keep a copy.":"It's deleted for good. Download it first if you want to keep a copy.",confirmLabel:"Delete",cancelLabel:"Keep it",tone:"danger",onConfirm:()=>{const U=Zn;Or(null),U&&hr(U)},onClose:()=>Or(null),children:gn&&t.jsx(Zv,{checking:gn.checking,favoritedCount:gn.favoritedCount,collections:gn.collections})}),t.jsx(tk,{job:F,onClose:()=>R(null),onEditInEditor:U=>{N(null),V({url:U.resultUrl,title:U.title||"Render",durationSeconds:U.durationSeconds||0}),E("editor"),R(null)},onEditInPhotoEditor:U=>{U!=null&&U.resultUrl&&(ht(U.resultUrl),R(null))},onDelete:U=>{R(null),Or(U)}})]},w),(Re||w==="adflow")&&t.jsx("div",{className:"w-full mx-auto min-w-0 max-w-[1408px] studio-reveal",onPointerDownCapture:Ea,onKeyDownCapture:Ea,style:{display:w==="adflow"?void 0:"none"},children:t.jsx(SS,{children:t.jsx(Hk,{visible:w==="adflow",onActiveChange:U=>{Ne.current=U},onRunChange:U=>{ce.current=U},configured:Rt,requireUser:Kn,onSignUp:ar,onCredits:kr,user:e,onOpenInEditor:({title:U,editDoc:ue})=>{N(null),H({title:U,editDoc:ue}),E("editor")}},Xe)})}),(O||w==="editor")&&t.jsx("div",{className:"w-full mx-auto min-w-0 max-w-[1408px] studio-reveal",onPointerDownCapture:Ea,onKeyDownCapture:Ea,style:{display:w==="editor"?void 0:"none"},children:t.jsx(CS,{children:t.jsx(ES,{active:w==="editor",userId:(e==null?void 0:e._id)||(e==null?void 0:e.id)||null,editId:I,mediaWindow:Ht,onUnsavedChange:U=>{Ae.current=!!(U!=null&&U.unsaved),De.current=!!(U!=null&&U.exporting)},openRender:A,onOpenRenderConsumed:()=>V(null),openDoc:z,onOpenDocConsumed:()=>H(null),requireEditorFile:h},Xe)})}),(pe||w==="image-editor")&&t.jsxs("div",{className:"w-full mx-auto min-w-0 max-w-[1408px] studio-reveal",onPointerDownCapture:Ea,onKeyDownCapture:Ea,style:{display:w==="image-editor"?void 0:"none"},children:[t.jsxs("p",{"data-photo-editor-media-note":!0,className:"mb-2 text-[12px] leading-relaxed text-gray-500",children:["Your images and your saved files live on your computer: this editor keeps nothing. Running an AI action here (Generative Fill, Remove Backgroun
157d, Upscale) sends a copy of the picture to be worked on, and that copy is kept for"," ",Ja(Ht==null?void 0:Ht.uploadHours)," and then removed."]}),t.jsx("div",{style:{position:"relative",width:"100%",height:"calc(100vh - 140px)",minHeight:520,borderRadius:12,overflow:"hidden",border:"1px solid #15161a"},children:t.jsx(i.Suspense,{fallback:t.jsx(FS,{}),children:t.jsx(T4,{options:{autosaveOwner:Xe,aiCredits:{cost:{generativeFill:1,removeBackground:1,selectSubject:1,upscale:1},balance:()=>J.current.balance,onUpgrade:()=>J.current.upgrade(),onSpend:(U,ue)=>xt(ue)},onUsage:(U,ue)=>{Xe!=="signed-out"&&Pc(U,ue),/^ai\.[A-Za-z]+\.(done|failed)$/.test(U)&&(r==null||r())},onNotify:(U,ue)=>{ue==="error"?me.error(U):ue==="warn"?me.warn(U):me.info(U)},onFileGate:()=>p.current(),generativeFill:async({image:U,mask:ue,prompt:Q})=>{var Oe;let fe,ge;try{[fe,ge]=await Promise.all([La(await ym(U),"photo-editor"),La(await ym(ue),"photo-editor")])}catch(st){throw(st==null?void 0:st.status)===413?new Error("This image is too large to upload for Generative Fill. Crop or resize it, then try again."):st}if(!fe||!ge)throw new Error("Couldn't upload the image to edit, check your connection and try again.");let je;try{je=await Jt(`${$t}/api/image-editor/ai-fill`,{imageUrl:fe,maskUrl:ge,prompt:Q})}catch(st){throw nt((Oe=st==null?void 0:st.data)==null?void 0:Oe.creditBalance),st}if(!je||je.ok===!1||!je.url)throw new Error((je==null?void 0:je.error)||"AI Fill didn't return an image.");return nt(je.creditBalance),je.url},removeBackground:async({image:U})=>Sh("/api/image-editor/remove-background",U,nt),upscale:async({image:U})=>Sh("/api/image-editor/upscale",U,nt)},onReady:U=>{se.current=U;const ue=ne.current;ue&&(ne.current=null,Ie(U,ue))}},Xe)})}),t.jsx(Kc,{isOpen:!!W,title:"Replace the image you're editing?",description:"Your Photo Editor image has changes you haven't saved or exported. Opening the new image replaces it.",confirmLabel:"Open new image",cancelLabel:"Keep editing",tone:"danger",onConfirm:()=>{const U=W;oe(null);const ue=se.current;U&&ue&&!ue.isDestroyed&&Ie(ue,U)},onClose:()=>oe(null)})]})]})]})}function FS(){return t.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"#1e1e1e",color:"#9aa0a6",font:"14px/1.5 system-ui, sans-serif"},children:"Loading the Photo Editorâ¦"})}function i0({message:e,onRetry:n}){return t.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] py-8 px-4 text-center space-y-3",children:[t.jsx(Xs,{className:"w-5 h-5 mx-auto text-amber-300"}),t.jsx("p",{className:"text-sm text-gray-300",children:e}),t.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-white/15 bg-white/[0.04] text-xs font-medium text-gray-200 hover:border-white/30 hover:text-white transition",children:[t.jsx(fo,{className:"w-3.5 h-3.5"})," Retry"]})]})}function Ap(){return t.jsxs("div",{className:"rounded-2xl border border-amber-500/30 bg-amber-500/[0.06] p-4 mb-6 flex gap-3",children:[t.jsx(Xs,{className:"w-5 h-5 text-amber-300 shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-amber-100/90",children:[t.jsx("p",{className:"font-semibold text-amber-200",children:"We can't connect right now"}),t.jsx("p",{className:"text-xs mt-1 text-amber-100/70",children:"Your network connection may be unstable. Check your connection and refresh the page. If it keeps happening, try again in a few minutes."})]})]})}function l0({children:e}){return t.jsxs("div",{className:"min-h-screen relative text-white",children:[t.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-gray-900"}),t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(900px_circle_at_15%_10%,rgba(160,200,230,0.20),transparent_55%),radial-gradient(900px_circle_at_85%_20%,rgba(180,200,220,0.14),transparent_55%),radial-gradient(1000px_circle_at_50%_90%,rgba(160,190,210,0.10),transparent_60%)]"}),t.jsx("div",{className:"absolute inset-0 opacity-[0.10] [background-image:linear-gradient(to_right,rgba(255,255,255,0.12)_1px,transparent_1px),linear-gradient(to_bottom,rgba(255,255,255,0.12)_1px,transparent_1px)] [background-size:88px_88px]"}),t.jsx("div",{className:"absolute -top-24 left-1/2 -translate-x-[72%] h-[520px] w-[520px] rounded-full bg-gradient-to-br from-[#A0C4E0]/18 to-transparent blur-3xl animate-[heroFloatA_18s_ease-in-out_infinite]"}),t.jsx("div",{className:"absolute top-6 left-1/2 translate-x-[18%] h-[560px] w-[560px] rounded-full bg-gradient-to-br from-[#B0C4D8]/16 to-transparent blur-3xl animate-[heroFloatB_22s_ease-in-out_infinite]"})]}),t.jsx("style",{children:` 158 @keyframes heroFloatA {
159 0%,100% { transform: translateX(-72%) translate3d(0,0,0) scale(1); } 160 50% { transform: translateX(-72%) translate3d(120px, 40px, 0) scale(1.05); } 161 } 162 @keyframes heroFloatB { 163 0%,100% { transform: translateX(18%) translate3d(0,0,0) scale(1); } 164 50% { transform: translateX(18%) translate3d(-140px, 60px, 0) scale(1.06); } 165 } 166 `}),t.jsx("div",{className:"relative z-10 max-w-[2000px] mx-auto px-4 pt-24 sm:pt-28 pb-16 sm:pb-24",children:e})]})}export{Hk as AdFlowEditor,Bk as AdFlowResults,rb as EDITOR_MEDIA_DEFAULT_WINDOW,ES as EditorTab,ek as RenderCard,Ml as STUDIO_TAB_KEYS,lS as StaticAdsTab,IS as StudioLeaveGuard,wc as UgcResultVideo,mS as UgcStudioTab,Mh as UgcVideoLinks,tk as VideoActionsModal,Fh as assetComposerKeys,rk as assetDurationKey,sk as assetDurationOptions,ok as assetExamples,Ud as assetFieldOrder,jm as assetImageArrayKey,wm as assetImageKey,Aa as assetPromptKey,aC as default,ec as downloadMedia,zk as isAdflowRender,jc as isProjectsVideoRender,_4 as isStudioPath,Ja as mediaWindowLabel,Oh as missingFromRefusal,gS as optionsFromChildren,NS as projectVideoAsRender,Vd as renderAge,Rh as restoreAssetValues,ob as seedAssetValues,Nc as sizePresetRatio,fl as staticAdsPackWorking,iS as staticAdsResumeDetail,D4 as studioAddress,$4 as studioTabPath,Zh as ugcCreatorFromJob,Yk as ugcResumeDetail,Fm as ugcSkipsFrame,Fu as ugcStatusStep,Qk as ugcStepReachable,vm as ugcVideoAspect,La as uploadToCloudinary};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.